PluginProbe
Assistant – Every Day Productivity Apps / 1.5.5.1
Assistant – Every Day Productivity Apps v1.5.5.1
1.5.5.1 1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 All 72 releases
← All changes | build/chunk-app-libraries.js +1 -1 0.6.0 → 1.5.5.1 View file →
@@ -1 +1 @@
1 -(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{264:function(e,t,a){var r=a(265);"string"==typeof r&&(r=[[e.i,r,""]]);var n={sourceMap:!0,hmr:!0,transform:undefined,insertInto:void 0};a(8)(r,n);r.locals&&(e.exports=r.locals)},265:function(e,t,a){"use strict";a.r(t)},266:function(e,t,a){var r=a(267);"string"==typeof r&&(r=[[e.i,r,""]]);var n={sourceMap:!0,hmr:!0,transform:undefined,insertInto:void 0};a(8)(r,n);r.locals&&(e.exports=r.locals)},267:function(e,t,a){"use strict";a.r(t)},268:function(e,t,a){var r=a(269);"string"==typeof r&&(r=[[e.i,r,""]]);var n={sourceMap:!0,hmr:!0,transform:undefined,insertInto:void 0};a(8)(r,n);r.locals&&(e.exports=r.locals)},269:function(e,t,a){"use strict";a.r(t)},271:function(e,t,a){"use strict";a.r(t);var r={};a.r(r),a.d(r,"getActions",(function(){return f}));var n={};a.r(n),a.d(n,"getActions",(function(){return j}));var l={};a.r(l),a.d(l,"getActions",(function(){return v}));var i={};a.r(i),a.d(i,"post",(function(){return r})),a.d(i,"image",(function(){return n})),a.d(i,"svg",(function(){return l}));var o=a(0),c=a.n(o),s=a(7),u=a(6),m=a(1),d=a(106),p=a(3),b=()=>{const e=Object(s.useHistory)(),{pathname:t}=Object(s.useLocation)(),{library:a,showUpload:r,setShowUpload:n}=d.a.LibraryContext.use(),l="/libraries/".concat(a.id);if(!a.permissions.update&&!a.permissions.edit_items)return null;return c.a.createElement(c.a.Fragment,null,a.permissions.edit_items&&c.a.createElement(p.Button,{appearance:"transparent",isSelected:r&&!t.includes("/settings"),onClick:()=>{n(!r),t!==l&&e.goBack()},style:{marginLeft:"auto"}},c.a.createElement(p.Icon.Plus,null)),a.permissions.update&&c.a.createElement(p.Button,{appearance:"transparent",isSelected:t.includes("/settings"),onClick:()=>{t===l&&e.push("".concat(l,"/settings"))}},c.a.createElement(p.Icon.Cog,null)))},y=()=>{const{library:e,showUpload:t,uploader:a}=d.a.LibraryContext.use();return e.permissions.edit_items?c.a.createElement(c.a.Fragment,null,t&&c.a.createElement(d.a.LibraryUpload,null),!!a.queuedFiles.length&&c.a.createElement(p.Layout.Box,{padY:!1},c.a.createElement(d.b.FileList,{files:a.queuedFiles}))):null},_=()=>{const{library:e}=d.a.LibraryContext.use();return c.a.createElement(c.a.Fragment,null,c.a.createElement(p.Layout.Box,{style:{textAlign:"center",padding:0}},c.a.createElement(p.Layout.Headline,{style:{margin:10}},e.name),e.description&&c.a.createElement("div",{style:{marginTop:"var(--fluid-sm-space)"}},e.description)),c.a.createElement(d.a.LibraryMemberThumbs,null))},g=()=>{const{useItemsFilter:e}=Object(u.getAppHooks)("libraries"),[t,a]=e(),{defaultItemsFilter:r}=Object(u.useAppState)("libraries",["defaultItemsFilter"]),n=()=>"type"===t.viewBy?c.a.createElement(p.Filter.RadioGroupItem,{title:Object(m.__)("Type"),items:d.a.getItemTypeOptions(),value:t.type,defaultValue:r.type,onChange:e=>a({...t,type:e})}):c.a.createElement(p.Filter.RadioGroupItem,{title:Object(m.__)("Collection"),items:d.a.getCollectionOptions(),value:t.collection,defaultValue:r.collection,onChange:e=>a({...t,collection:e})});return c.a.createElement(p.Filter,null,c.a.createElement(p.Filter.RadioGroupItem,{title:Object(m.__)("View By"),items:{type:Object(m.__)("Type"),collection:Object(m.__)("Collection")},value:t.viewBy,defaultValue:r.viewBy,onChange:e=>a({...t,viewBy:e})}),c.a.createElement(n,null),c.a.createElement(p.Filter.RadioGroupItem,{title:Object(m.__)("Sort By"),items:{name:Object(m.__)("Title"),created_at:Object(m.__)("Date Created"),updated_at:Object(m.__)("Last Updated")},value:t.orderBy,defaultValue:r.orderBy,onChange:e=>a({...t,orderBy:e})}),c.a.createElement(p.Filter.RadioGroupItem,{title:Object(m.__)("Order"),items:{ASC:Object(m.__)("Ascending"),DESC:Object(m.__)("Descending")},value:t.order,defaultValue:r.order,onChange:e=>a({...t,order:e})}),c.a.createElement(p.Filter.Button,{onClick:()=>a(r)},Object(m.__)("Reset Filter")))};a(264);const E=({library:e,onDrop:t,children:a})=>e.permissions.edit_items?c.a.createElement(p.Layout.DropArea,{onDrop:t},a):c.a.createElement("div",null,a);var h=()=>{const{library:e,items:t,showUpload:a,uploader:r}=d.a.LibraryContext.use(),{defaultItemsFilter:n}=Object(u.useAppState)("libraries","defaultItemsFilter"),{useItemsFilter:l}=Object(u.getAppHooks)("libraries"),[i,o]=l(),s=d.a.getFilteredItems(i,t),b=t&&!!t.length;return c.a.createElement(E,{library:e,onDrop:r.handleDrop},b&&c.a.createElement(g,null),c.a.createElement(_,null),c.a.createElement(y,null),b&&c.a.createElement(d.a.ItemsList,null),(()=>{const{viewBy:e,type:a,collection:r}=i;if(t&&!Object.keys(s).length){if("type"===e&&"all"!==a)return!0;if("collection"===e&&"all"!==r)return!0}return!1})()&&!a&&c.a.createElement(c.a.Fragment,null,c.a.createElement(p.Layout.Box,{style:{textAlign:"center"}},Object(m.__)("No results found.")),c.a.createElement(p.Layout.Row,null,c.a.createElement(p.Button,{onClick:()=>o(n)},Object(m.__)("Reset Filter")))),t&&!b&&!a&&c.a.createElement(p.Layout.Box,{style:{textAlign:"center"}},Object(m.__)("This library doesn't have any items yet.")))},O=a(28);const f=(e,t)=>{const{createNotice:a}=d.a.ItemContext.use(),[r,n]=Object(o.useState)(!1),[l,i]=Object(o.useState)(!1),u=Object(s.useHistory)(),p=Object(O.getWpRest)().posts();return t.push({label:Object(m.__)("Import"),onClick:()=>{n(!0),p.importFromLibrary(e.id).then((e=>{n(!1),e.data.error?a({status:"error",content:Object(m.__)("Error importing content.")}):a({status:"success",content:c.a.createElement(c.a.Fragment,null,Object(m.__)("Content imported!"),c.a.createElement("a",{style:{textDecoration:"underline",marginLeft:"var(--fluid-sm-space)"},onClick:()=>{u.push("/fl-content/post/".concat(e.data.id),{item:e.data})}},Object(m.__)("View content.")))})}))},disabled:r}),t.push({label:Object(m.__)("Preview"),onClick:()=>{i(!0),p.previewLibraryPost(e.id).then((e=>{i(!1),window.open(e.data.url)}))},disabled:l}),t},j=(e,t)=>{const{createNotice:a}=d.a.ItemContext.use(),[r,n]=Object(o.useState)(!1),l=Object(O.getWpRest)();return t.push({label:Object(m.__)("Import"),onClick:()=>{n(!0),l.libraries().importItem(e).then((e=>{a({status:e.data.error?"error":"success",content:e.data.error?e.data.error:Object(m.__)("Item imported!")})})).catch((e=>{a({status:"error",content:e.response.data.message})})).finally((()=>{n(!1)}))},disabled:r}),t},v=(e,t)=>{const{createNotice:a}=d.a.ItemContext.use(),[r,n]=Object(o.useState)(!1),l=Object(O.getWpRest)();return t.push({label:Object(m.__)("Import"),onClick:()=>{n(!0),l.libraries().importItem(e).then((e=>{a({status:e.data.error?"error":"success",content:e.data.error?e.data.error:Object(m.__)("Item imported!")})})).catch((e=>{a({status:"error",content:e.response.data.message})})).finally((()=>{n(!1)}))},disabled:r}),t};var C=()=>c.a.createElement("div",{style:{display:"flex",position:"absolute",top:0,right:0,bottom:0,left:0,width:"100%"}},c.a.createElement(d.a.ItemDetail,{formConfig:i})),L=()=>{const{items:e}=d.a.LibraryContext.use(),[t,a]=Object(o.useState)(null),[r,n]=Object(o.useState)(!1);Object(o.useEffect)((()=>{null!==t&&l()}),[t]);const l=()=>{const a=e[t],r=Object(O.getWpRest)();"color"===a.type?i():"post"===a.type?r.posts().importFromLibrary(a.id).finally(i):r.libraries().importItem(a).finally(i)},i=()=>{const r=null===t?0:t+1;if(!e[r])return a(null),void n(!0);a(r)};return null!==t||r?c.a.createElement(c.a.Fragment,null,c.a.createElement("p",null,Object(m.__)("Import in progress. Navigating away from this view will stop the import process!")),c.a.createElement(w,{progress:null===t?100:t/e.length*100}),c.a.createElement("p",{style:{fontStyle:"italic",fontSize:"12px",marginTop:"var(--fluid-sm-space)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},null!==t&&Object(m.sprintf)(Object(m.__)("Importing %s"),e[t].name),null===t&&Object(m.__)("Import Complete!"))):c.a.createElement(I,{onClick:()=>i()})};const I=({onClick:e})=>c.a.createElement(c.a.Fragment,null,c.a.createElement("p",null,Object(m.__)("Click the button below to import all items in this library into your site.")),c.a.createElement(p.Button,{onClick:e},Object(m.__)("Import Library"))),w=({progress:e})=>c.a.createElement("div",{style:{background:"var(--fluid-transparent-10)",borderRadius:"var(--fluid-radius)",height:"6px"}},c.a.createElement("div",{style:{background:"var(--fluid-transparent-4)",borderRadius:"var(--fluid-radius)",height:"6px",width:"".concat(e,"%")}}));var F=()=>{const{library:e}=d.a.LibraryContext.use();return c.a.createElement(c.a.Fragment,null,c.a.createElement(p.Layout.Box,{padY:!1},c.a.createElement(p.Page.Section,{label:Object(m.__)("Library Settings"),padY:!1},c.a.createElement(d.a.LibrarySettingsForm,null))),c.a.createElement(p.Layout.Box,{padY:!1},c.a.createElement(p.Page.Section,{label:Object(m.__)("Library Collections")},c.a.createElement(d.a.LibraryCollectionsForm,null))),c.a.createElement(p.Layout.Box,{padY:!1},c.a.createElement(p.Page.Section,{label:Object(m.__)("Import Library")},c.a.createElement(L,null))),e.permissions.delete&&c.a.createElement(p.Layout.Box,null,c.a.createElement(p.Page.Section,{label:Object(m.__)("Danger Zone")},c.a.createElement(p.Layout.Headline,null,Object(m.__)("Delete This Library")),c.a.createElement("p",{style:{margin:"0"}},Object(m.__)("Once a library has been deleted, it is gone forever. Please be sure you want to delete this library."))),c.a.createElement(d.a.LibraryDeleteForm,null)))},S=()=>{const{pathname:e}=Object(s.useLocation)();return c.a.createElement(d.a.LibraryDetail,null,c.a.createElement("div",{style:{visibility:e.includes("/items/")?"hidden":"",width:"100%",flex:"1 1 auto",display:"flex",position:"absolute",top:0,bottom:0}},c.a.createElement(p.Page,{title:Object(m.__)("Library"),shouldShowBackButton:!0,actions:c.a.createElement(b,null),padX:!1,padY:!1},c.a.createElement(s.Switch,null,c.a.createElement(s.Route,{path:"/libraries/:id/settings",component:F}),c.a.createElement(s.Route,{path:"/libraries/:id",component:h})))),c.a.createElement(s.Switch,null,c.a.createElement(s.Route,{path:"/libraries/:id/item/:itemId",component:C})))},x=a(13),B=a.n(x),k=()=>{const{cloudConfig:e}=Object(u.getSystemConfig)(),t=B.a.session.getUser();return c.a.createElement(c.a.Fragment,null,c.a.createElement(p.Button,{className:"fl-asst-cloud-gravatar-link",href:e.appUrl,target:"_blank",appearance:"elevator",size:"sm",style:{backgroundImage:"url(".concat(t.gravatar.sm,")"),backgroundSize:"contain",height:"25px",width:"25px",minHeight:"0",minWidth:"0"}}))},R=()=>{const{useDefaultFilter:e,useFilter:t}=Object(u.getAppHooks)("libraries"),[a]=e(),[r,n]=t(),l=e=>{n(e),d.a.loadAppState()};return c.a.createElement(p.Filter,null,c.a.createElement(p.Filter.RadioGroupItem,{title:Object(m.__)("Owner"),items:d.a.getLibraryOwnerOptions(),value:r.owner,defaultValue:a.owner,onChange:e=>l({...r,owner:e})}),c.a.createElement(p.Filter.RadioGroupItem,{title:Object(m.__)("Sort By"),items:{name:Object(m.__)("Title"),created_at:Object(m.__)("Date Created"),updated_at:Object(m.__)("Last Updated")},value:r.orderBy,defaultValue:a.orderBy,onChange:e=>l({...r,orderBy:e})}),c.a.createElement(p.Filter.RadioGroupItem,{title:Object(m.__)("Order"),items:{ASC:Object(m.__)("Ascending"),DESC:Object(m.__)("Descending")},value:r.order,defaultValue:a.order,onChange:e=>l({...r,order:e})}),c.a.createElement(p.Filter.RadioGroupItem,{title:Object(m.__)("Display As"),items:{grid:Object(m.__)("Grid"),list:Object(m.__)("List")},value:r.displayAs,defaultValue:a.displayAs,onChange:e=>l({...r,displayAs:e})}),c.a.createElement(p.Filter.Button,{onClick:()=>l(a)},Object(m.__)("Reset Filter")))},A=(a(266),({headline:e="",type:t="user",team:a=null})=>{const{libraries:r,isLoadingLibraries:n}=Object(u.useAppState)("libraries"),l=a?a.id:0,i=l?r[t][l]:r[t],s=i&&0<i.length,b=!a||a.permissions.edit_libraries,[y,_]=Object(o.useState)(!1);return c.a.createElement(p.Layout.Box,{className:"fl-asst-libraries-grid",padX:!1,padY:!1},!y&&c.a.createElement(p.Layout.Toolbar,{style:{paddingLeft:20}},c.a.createElement(p.Text.Title,null,e),"shared"!==t&&b&&c.a.createElement(p.Button,{appearance:"transparent",shape:"round",onClick:()=>_(!0),style:{marginLeft:"auto"}},c.a.createElement(p.Icon.PlusSmall,null))),y&&c.a.createElement(p.Layout.Toolbar,null,c.a.createElement(d.a.LibraryInlineCreate,{teamId:l}),c.a.createElement(p.Button,{onClick:()=>_(!1),style:{marginLeft:5}},c.a.createElement(p.Icon.CloseCompact,null))),!n&&!s&&c.a.createElement(p.Layout.Box,{style:{textAlign:"center"}},Object(m.__)("You don't currently have any libraries. Create one to get started!")),c.a.createElement(d.a.LibrariesList,{type:t,team:a}))}),D=()=>{const{filter:e,libraries:t,teams:a}=Object(u.useAppState)("libraries"),{owner:r,...n}=e,l=B.a.session.getUser();return c.a.createElement(p.Page,{title:Object(m.__)("Libraries"),icon:c.a.createElement(p.Icon.Library,{context:"sidebar"}),shouldShowBackButton:!1,actions:c.a.createElement(k,null),padX:!1,padY:!1},c.a.createElement(R,null),c.a.createElement("div",{className:"fl-asst-libraries"},("all"===r||"user"===r)&&c.a.createElement(A,{headline:l.name.endsWith("s")?"".concat(l.name,"'"):"".concat(l.name,"'s"),query:n}),!!t.shared.length&&c.a.createElement(A,{headline:Object(m.__)("Shared Libraries"),type:"shared",query:n}),a.map(((e,t)=>{if("all"===r||"team_".concat(e.id)===r)return c.a.createElement(A,{key:t,headline:l.name.endsWith("s")?"".concat(e.name,"'"):"".concat(e.name,"'s"),type:"team",team:e,query:n})}))))};a(268),t.default=({baseURL:e})=>{const t=Object(s.useHistory)(),{isCloudConnected:a}=Object(u.useSystemState)("isCloudConnected");return a?c.a.createElement(s.Switch,null,c.a.createElement(s.Route,{exact:!0,path:"".concat(e),component:D}),c.a.createElement(s.Route,{path:"".concat(e,"/:id"),component:S})):(t.replace("/fl-cloud-connect"),null)}}}]);
1 +"use strict";(self.webpackChunkfl_assistant=self.webpackChunkfl_assistant||[]).push([[634],{8168:(e,t,a)=>{function r(){return r=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)({}).hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},r.apply(null,arguments)}a.d(t,{A:()=>r})},9843:(e,t,a)=>{a.r(t),a.d(t,{default:()=>Q});var r={};a.r(r),a.d(r,{getActions:()=>D});var n={};a.r(n),a.d(n,{getActions:()=>N});var i={};a.r(i),a.d(i,{getActions:()=>O});var s={};a.r(s),a.d(s,{getActions:()=>W});var l={};a.r(l),a.d(l,{getActions:()=>$});var o={};a.r(o),a.d(o,{getActions:()=>H});var c={};a.r(c),a.d(c,{code:()=>o,document:()=>s,image:()=>n,post:()=>r,settings:()=>l,svg:()=>i});var m=a(1594),u=a.n(m),d=a(9665),p=a(2578),g=a(6075),y=a(2470),b=a(1112),_=a(2405);const h=()=>{const e=(0,d.useHistory)(),{cloudUser:t}=(0,g.useSystemState)(),{pathname:a}=(0,d.useLocation)(),{isReadOnly:r,library:n,items:i,showUpload:s,setShowUpload:l,showFilters:o,setShowFilters:c}=b.Libraries.LibraryContext.use(),m=`/libraries/${n.id}`,h=t.id===n.permissions.permissions_user_id,{isSelecting:E,setIsSelecting:f}=p.Selection.use(),w=i&&!!i.length;if(!(n.permissions.update||n.permissions.edit_items||n.permissions.shared||h))return null;return u().createElement(u().Fragment,null,w&&!a.includes("/settings")&&u().createElement(u().Fragment,null,u().createElement(_.Button,{onClick:()=>f(!0),isSelected:E},(0,y.__)("Select")),u().createElement(_.Button,{appearance:"transparent",isSelected:o,onClick:()=>c(!o),title:(0,y.__)("Search")},u().createElement(_.Icon.Search,null))),!r&&n.permissions.edit_items&&u().createElement(_.Button,{appearance:"transparent",isSelected:s&&!a.includes("/settings"),title:(0,y.__)("Add Items"),onClick:()=>{l(!s),a!==m&&e.goBack()},style:{marginLeft:"auto"}},u().createElement(_.Icon.Plus,null)),(n.permissions.update||n.permissions.shared||h)&&u().createElement(_.Button,{appearance:"transparent",isSelected:a.includes("/settings"),title:(0,y.__)("Settings"),onClick:()=>{a===m&&e.push(`${m}/settings`)}},u().createElement(_.Icon.Cog,null)))};var E=a(8168);const f=()=>{const{isReadOnly:e,library:t,showUpload:a,uploader:r}=b.Libraries.LibraryContext.use();return e||!t.permissions.edit_items?null:u().createElement(u().Fragment,null,a&&u().createElement(b.Libraries.LibraryUpload,null),!!r.queuedFiles.length&&u().createElement(_.Layout.Box,{padY:!1},u().createElement(b.Uploader.FileList,{files:r.queuedFiles})))},w=()=>{const{library:e}=b.Libraries.LibraryContext.use();return u().createElement(u().Fragment,null,u().createElement(_.Layout.Box,{style:{textAlign:"center",padding:0}},u().createElement(_.Layout.Headline,{style:{margin:20}},e.name),e.description&&u().createElement("div",{style:{lineHeight:1.4,margin:"0 20px"}},e.description)),u().createElement(b.Libraries.LibraryMemberThumbs,null))},v=e=>{const{useItemsFilter:t}=(0,g.getAppHooks)("libraries"),[a,r]=t(),{defaultItemsFilter:n,showFilters:i}=(0,g.useAppState)("libraries",["defaultItemsFilter","showFilters"]),s=()=>"type"===a.viewBy?u().createElement(_.Filter.RadioGroupItem,{title:(0,y.__)("Type"),items:b.Libraries.getItemTypeOptions(),value:a.type,defaultValue:n.type,onChange:e=>r({...a,type:e})}):u().createElement(_.Filter.RadioGroupItem,{title:(0,y.__)("Collection"),items:b.Libraries.getCollectionOptions(),value:a.collection,defaultValue:n.collection,onChange:e=>r({...a,collection:e})});return u().createElement(u().Fragment,null,u().createElement(_.Filter,e,i&&u().createElement(_.Filter.TextInputItem,{className:"fl-asst-filter-item-full-width fl-asst-filter-item-search",title:(0,y.__)("Search"),placeholder:(0,y.__)("Filter..."),value:a.search,onChange:e=>r({...a,search:e})}),u().createElement(_.Filter.RadioGroupItem,{title:(0,y.__)("View By"),items:{type:(0,y.__)("Type"),collection:(0,y.__)("Collection")},value:a.viewBy,defaultValue:n.viewBy,onChange:e=>r({...a,viewBy:e})}),u().createElement(s,null),u().createElement(_.Filter.RadioGroupItem,{title:(0,y.__)("Sort By"),items:{name:(0,y.__)("Title"),created_at:(0,y.__)("Date Created"),updated_at:(0,y.__)("Last Updated")},value:a.orderBy,defaultValue:n.orderBy,onChange:e=>r({...a,orderBy:e})}),u().createElement(_.Filter.RadioGroupItem,{title:(0,y.__)("Order"),items:{ASC:(0,y.__)("Ascending"),DESC:(0,y.__)("Descending")},value:a.order,defaultValue:n.order,onChange:e=>r({...a,order:e})}),u().createElement(_.Filter.Button,{onClick:()=>r(n)},(0,y.__)("Reset Filter"))))};var S=a(816),C=a.n(S);const L=()=>{const{items:e,setItems:t}=b.Libraries.LibraryContext.use(),{items:a,clearSelection:r,totalSelectedItems:n}=p.Selection.use();return React.createElement(_.Button,{status:"destructive",icon:React.createElement(_.Icon.Trash,null),disabled:0>=n,onClick:()=>{confirm((0,y.__)("Do you really want to delete these items?"))&&(async(n=[])=>{C().libraries.deleteItem(n).finally((()=>{t([...e.filter((e=>!a.includes(e.id)))]),r()}))})(a)}},(0,y.__)("Delete"))};var I=a(9489);const R=()=>{const e=(0,I.getWpRest)().libraries(),t=(0,m.useRef)(0),a=(t,a,n)=>{e.importPostThumb(t.id,a.media.thumb).finally((()=>{r(t,a,n)}))},r=(a,n,i)=>{const{attachments:s}=n.media;if(void 0===s)return void i(a);const l=s[t.current];void 0===l?(t.current=0,i(a)):e.importPostMedia(a.id,l).finally((()=>{t.current++,r(a,n,i)}))};return(e,t)=>new Promise((n=>{t.media.thumb?a(e,t,n):r(e,t,n)}))},x=()=>{const{items:e,setItems:t,createNotice:a}=b.Libraries.LibraryContext.use(),{items:r,clearSelection:n,totalSelectedItems:i}=p.Selection.use(),[s,l]=(0,m.useState)(null),[o,c]=(0,m.useState)(0),u=R(),d=(0,I.getWpRest)().libraries();return React.createElement(React.Fragment,null,React.createElement(_.Button,{disabled:null!==s,onClick:async()=>{let t=0,i=0,s=[];const o=(()=>{const t=[];return r.forEach((a=>{const r=e.find((e=>e.id===a));r&&"settings"===r.type&&confirm((0,y.__)("Importing these settings will overwrite your existing settings, do you wish to continue?")+"\n"+r.name)&&t.push(r.id)})),t})();for(const a of r){const r=e.find((e=>e.id===a));void 0!==r&&(l(r),"color"===r.type||"code"===r.type||("post"===r.type?await C().libraries.getItem(r.id).then((async e=>{await d.importPost(e.data).then((async t=>{if(t.data.error&&"post_type_not_registered"===t.data.error_code)return s.push({name:r.name,type:t.data.post_type}),void i++;await u(t.data,e.data)}))})):"settings"===r.type?o.includes(r.id)&&await d.importSettings(r.id):await d.importItem(r))),t++,c(t)}const m=s.map((e=>React.createElement("li",{key:e.name},e.name," (",e.type,")")));a(i<t?{status:"success",shouldDismiss:!1,content:React.createElement(React.Fragment,null,(0,y.__)("Library items imported!"),i>0&&React.createElement(React.Fragment,null," ",(0,y.__)("Some items were not able to be imported due to these post types not being registered on this site: "),React.createElement("br",null),React.createElement("ul",null,m)))}:{status:"error",shouldDismiss:!1,content:React.createElement(React.Fragment,null,(0,y.__)("The selected items were not able to be imported due to these post types not being registered on this site: "),React.createElement("br",null),React.createElement("ul",null,m))}),c(0),n()}},(0,y.__)("Import")),null!==s&&React.createElement("div",{className:"fl-asst-import-bar"},React.createElement("p",null,(0,y.__)("Import in progress. Navigating away from this view will stop the import process!")),React.createElement(k,{progress:o/r.length*100}),React.createElement("p",{style:{fontStyle:"italic",fontSize:"12px",marginTop:"var(--fluid-sm-space)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},(0,y.__)("Importing")," ",s.name)))},k=({progress:e})=>React.createElement("div",{style:{background:"var(--fluid-transparent-10)",borderRadius:"var(--fluid-radius)",height:"6px"}},React.createElement("div",{style:{background:"var(--fluid-transparent-4)",borderRadius:"var(--fluid-radius)",height:"6px",width:`${e}%`}})),F=({children:e,...t})=>{const{isReadOnly:a,library:r,uploader:n}=b.Libraries.LibraryContext.use();return!a&&r.permissions.edit_items?u().createElement(_.Layout.DropArea,(0,E.A)({onDrop:n.handleDrop},t),e):u().createElement("div",t,e)},B=()=>{const e=(0,d.useLocation)(),{items:t,showUpload:a,library:r}=b.Libraries.LibraryContext.use(),{defaultItemsFilter:n}=(0,g.useAppState)("libraries","defaultItemsFilter"),{useItemsFilter:i}=(0,g.getAppHooks)("libraries"),[s,l]=i(),o=b.Libraries.getFilteredItems(s,t),c=t&&!!t.length,{isSelecting:m}=p.Selection.use(),h=r.permissions.edit_items&&!((e,t=[])=>t.some((t=>e.endsWith(t))))(e.pathname,["/share","/settings","/collections"]);return u().createElement(F,{className:"fl-asst-library-content"},u().createElement("div",{className:"fl-asst-library-sticky"},u().createElement(v,null),m&&u().createElement(p.Selection.Toolbar,{style:{minHeight:48,flexBasis:48,width:"100%",top:"auto"},isSticky:!1},u().createElement(x,null),u().createElement(L,null))),u().createElement(p.Selection.Box,{itemSelector:".fluid-collection-item",mapElementToData:e=>parseInt(e.dataset.selectionId),isEnabled:h},u().createElement(w,null),u().createElement(f,null),u().createElement(b.Libraries.ItemsList,null),(()=>{const{viewBy:e,type:a,collection:r}=s;if(t&&!Object.keys(o).length){if("type"===e&&"all"!==a)return!0;if("collection"===e&&"all"!==r)return!0}return!1})()&&!a&&u().createElement(u().Fragment,null,u().createElement(_.Layout.Box,{style:{textAlign:"center"}},(0,y.__)("No results found.")),u().createElement(_.Layout.Row,null,u().createElement(_.Button,{onClick:()=>l(n)},(0,y.__)("Reset Filter")))),t&&!c&&!a&&u().createElement(_.Layout.Box,{style:{textAlign:"center"}},(0,y.__)("This library doesn't have any items yet."))))},D=(e,t)=>{const{library:a}=b.Libraries.LibraryContext.use();return t.unshift({component:u().createElement(P,{item:e})}),t.unshift({component:u().createElement(T,{item:e}),shouldRender:a.permissions.edit_items}),t.unshift({component:u().createElement(A,{item:e})}),t},P=({item:e})=>{const{createNotice:t}=b.Libraries.ItemContext.use(),[a,r]=(0,m.useState)(!1),n=(0,I.getWpRest)().libraries(),i=e=>{!e||e.data.error?t({status:"error",content:(0,y.__)("Error previewing content.")}):window.open(e.data.url)};return u().createElement(_.Button,{onClick:()=>{r(!0),n.previewPost(e).then((e=>{i(e)})).catch((()=>{i()})).finally((()=>{r(!1)}))},disabled:a},(0,y.__)("Preview"))},T=({item:e})=>{const{currentPageView:t,isLocalhost:a}=(0,g.getSystemConfig)(),{id:r,type:n,isSingular:i}=t,[s,l]=(0,m.useState)(!1),{updateItems:o}=b.Libraries.LibraryContext.use(),{createNotice:c,setItem:d}=b.Libraries.ItemContext.use(),{updateFormValues:p}=b.Libraries.ItemFormContext.use(),h=(0,I.getWpRest)().libraries(),E=(0,I.getWpRest)().posts(),f=[{label:(0,y.__)("Cancel"),disabled:s,onClick:({closeDialog:e})=>e()}];i&&f.push({label:s?(0,y.__)("Updating..."):(0,y.__)("Update"),isSelected:!0,disabled:s,onClick:({closeDialog:t})=>{const a=(0,y.sprintf)((0,y.__)("Do you really want to update this library item and replace its content with the current %s? This cannot be undone."),n.toLowerCase());if(!confirm(a))return;l(!0);E.findById(r).then((({data:a})=>{b.Uploader.screenshotUrl(a.previewUrl).then((a=>{((a="")=>{h.syncLibraryPost(r,e,{screenshot:a}).then((e=>{d(e.data),o(e.data),p(e.data),c({status:"success",content:(0,y.__)("Library item updated!"),shouldDismiss:!1})})).catch((()=>{c({status:"error",content:(0,y.__)("Error updating library item."),shouldDismiss:!1})})).finally((()=>{l(!1),t()}))})(a)}))}))}});const[w,v]=_.Modal.useDialog({title:(0,y.__)("Update this Library Item"),message:u().createElement(U,null),buttons:f});return u().createElement(u().Fragment,null,u().createElement(_.Button,{onClick:w},(0,y.__)("Update")),u().createElement(v,null))},U=()=>{const{currentPageView:e}=(0,g.getSystemConfig)(),{intro:t,name:a,type:r,isSingular:n}=e;return n?u().createElement(u().Fragment,null,u().createElement("div",{style:{padding:"var(--fluid-med-space) 0"}},u().createElement("strong",null,t,":")," ",a),u().createElement("div",null,(0,y.sprintf)((0,y.__)("Updating this library item will replace its content with the content of the current %s."),r.toLowerCase()))):(0,y.__)("Updating is currently not available. To update this library item, navigate to the post or page you'd like to update it with and click the update button again.")},A=({item:e})=>{const{currentPageView:t,contentTypes:a}=(0,g.getSystemConfig)(),{createNotice:r}=b.Libraries.ItemContext.use(),[n,i]=(0,m.useState)(null),[s,l]=(0,m.useState)(!1),o=(0,I.getWpRest)().libraries(),c=R(),d=e=>{const{editUrl:t,type:n,postTypeRegistered:s}=e,o=a[n]?a[n].labels.singular:(0,y.__)("Content");i(null),l(!1),e.error?r({status:"error",shouldDismiss:!1,content:(0,y.__)("Error importing library item.")}):r({status:"success",shouldDismiss:!1,content:u().createElement(u().Fragment,null,s&&(0,y.__)("Library item imported!"),!s&&u().createElement(u().Fragment,null,(0,y.__)("The library item was not able to be imported.")," ",(0,y.__)("The post type"),' "',u().createElement("strong",null,n),'" ',(0,y.__)("is not registered on this site.")),t&&u().createElement("a",{style:{textDecoration:"underline",marginLeft:"var(--fluid-sm-space)"},onClick:()=>{window.location.href=t}},(0,y.sprintf)((0,y.__)("Edit %s."),o)))})},p=e=>{i(null),l(!1),!e||e.error?r({status:"error",shouldDismiss:!1,content:(0,y.sprintf)((0,y.__)("Error replacing %s."),t.type.toLowerCase())}):(r({status:"success",shouldDismiss:!1,content:(0,y.sprintf)((0,y.__)("%s replaced!"),t.type)}),window.location.reload())};return(0,m.useEffect)((()=>{"create"===n?o.importPost(e).then((t=>{t.data.error&&"post_type_not_registered"===t.data.error_code?r({status:"error",shouldDismiss:!1,content:u().createElement(u().Fragment,null,(0,y.__)("The library item was not able to be imported.")," ",(0,y.__)("The post type"),' "',u().createElement("strong",null,t.data.post_type),'" ',(0,y.__)("is not registered on this site."))}):(l(!0),c(t.data,e).then(d))})).catch((()=>{i(null),l(!1),r({status:"error",content:(0,y.__)("Error importing library item.")})})):"replace"===n&&(()=>{if(!t.isSingular)return alert((0,y.__)("Replacing is currently not available. Navigate to the post or page you'd like to replace and click the import button again.")),void i(null);const a=(0,y.sprintf)((0,y.__)("Do you really want to replace the current %s with this library item? This cannot be undone."),t.type.toLowerCase());confirm(a)?o.syncPost(t.id,e).then((t=>{l(!0),c(t.data,e).then((()=>{p(t.data)}))})).catch((()=>{p()})):i(null)})()}),[n]),u().createElement(u().Fragment,null,u().createElement("select",{value:"",onChange:e=>i(e.target.value),disabled:n},u().createElement("option",{value:""},!s&&!n&&(0,y.__)("Import..."),!s&&n&&(0,y.__)("Importing..."),s&&(0,y.__)("Importing media...")),u().createElement("option",{value:"create"},(0,y.__)("Create New")),u().createElement("option",{value:"replace"},t.isSingular?(0,y.sprintf)((0,y.__)("Replace Current %s"),t.type):(0,y.__)("Replace Current Page"))))},N=(e,t)=>{const{createNotice:a}=b.Libraries.ItemContext.use(),[r,n]=(0,m.useState)(!1),i=(0,I.getWpRest)();return t.unshift({label:(0,y.__)("Import"),onClick:()=>{n(!0),i.libraries().importItem(e).then((e=>{a({status:e.data.error?"error":"success",content:e.data.error?e.data.error:(0,y.__)("Item imported!")})})).catch((e=>{a({status:"error",content:e.response.data.message})})).finally((()=>{n(!1)}))},disabled:r}),t},O=(e,t)=>{const{createNotice:a}=b.Libraries.ItemContext.use(),[r,n]=(0,m.useState)(!1),i=(0,I.getWpRest)();return t.unshift({label:(0,y.__)("Import"),onClick:()=>{n(!0),i.libraries().importItem(e).then((e=>{a({status:e.data.error?"error":"success",content:e.data.error?e.data.error:(0,y.__)("Item imported!")})})).catch((e=>{a({status:"error",content:e.response.data.message})})).finally((()=>{n(!1)}))},disabled:r}),t},W=(e,t)=>{const{createNotice:a}=b.Libraries.ItemContext.use(),[r,n]=(0,m.useState)(!1),i=(0,I.getWpRest)();return t.unshift({label:(0,y.__)("Import"),onClick:()=>{n(!0),i.libraries().importItem(e).then((e=>{a({status:e.data.error?"error":"success",content:e.data.error?e.data.error:(0,y.__)("Item imported!")})})).catch((e=>{a({status:"error",content:e.response.data.message})})).finally((()=>{n(!1)}))},disabled:r}),t},$=(e,t)=>{const{adminURLs:a,themeSlug:r,themeParentSlug:n}=(0,g.getSystemConfig)(),{createNotice:i}=b.Libraries.ItemContext.use(),[s,l]=(0,m.useState)(!1),o=(0,I.getWpRest)().libraries(),c=()=>{const{name:t,slug:a,parent:i}=e.data.theme;return(!i||i.slug!==r&&i.slug!==n)&&(a!==r&&a!==n&&(i?alert((0,y.sprintf)((0,y.__)('The themes "%s" or "%s" must be active to apply or preview these settings.'),i.name,t)):alert((0,y.sprintf)((0,y.__)('The theme "%s" must be active to apply or preview these settings.'),t)),!0))};return t.unshift({label:(0,y.__)("Apply Settings"),onClick:()=>{if("theme_settings"===e.subtype){if(c())return;if(!confirm((0,y.__)("Do you really want to import these theme settings? This will update your site design and cannot be undone.")))return}("bb_settings"!==e.subtype||confirm((0,y.__)("Do you really want to import these Beaver Builder settings? This may update your site design and cannot be undone.")))&&(l(!0),o.importSettings(e.id).then((e=>{l(!1),e.data.data.error?i({status:"error",content:e.data.data.error,shouldDismiss:!1}):(i({status:"success",content:(0,y.__)("Settings imported!")}),window.location.reload())})))},disabled:s}),t.unshift({label:(0,y.__)("Preview"),onClick:()=>{c()||window.open(`${a.customizeBase}?fl-asst-customizer-preview-init=${e.id}`)}}),t},H=(e,t)=>{const{createNotice:a}=b.Libraries.ItemContext.use(),[r,n]=(0,m.useState)(!1),i=(0,I.getWpRest)();return t.unshift({label:(0,y.__)("Import"),onClick:()=>{n(!0),i.libraries().importItem(e).then((e=>{a({status:e.data.error?"error":"success",content:e.data.error?e.data.error:(0,y.__)("Item imported!")})})).catch((e=>{a({status:"error",content:e.response.data.message})})).finally((()=>{n(!1)}))},disabled:r}),t},z=()=>u().createElement("div",{style:{display:"flex",position:"absolute",top:0,right:0,bottom:0,left:0,width:"100%"}},u().createElement(b.Libraries.ItemDetail,{formConfig:c})),V=()=>{const{items:e,createNotice:t}=b.Libraries.LibraryContext.use(),[a,r]=(0,m.useState)(null),[n,i]=(0,m.useState)([]),[s,l]=(0,m.useState)(!1),[o,c]=(0,m.useState)(0),d=R(),p=(0,I.getWpRest)().libraries(),g=async a=>{let n=0,s=0,o=0,m=[],g=[];if("all"===a)g=e.map((e=>e.id));else if("all-content"===a)g=e.filter((e=>"post"===e.type)).map((e=>e.id));else if("bb-content"===a)g=e.filter((e=>"post"===e.type&&"beaver-builder"===e.subtype)).map((e=>e.id));else if(a.startsWith("post_type:")){const t=a.replace("post_type:","");g=e.filter((e=>"post"===e.type&&e.data.post.post_type===t)).map((e=>e.id))}else"all-settings"===a?g=e.filter((e=>"settings"===e.type)).map((e=>e.id)):"theme-settings"===a?g=e.filter((e=>"settings"===e.type&&"theme_settings"===e.subtype)).map((e=>e.id)):"bb-settings"===a?g=e.filter((e=>"settings"===e.type&&"bb_settings"===e.subtype)).map((e=>e.id)):"all-images"===a&&(g=e.filter((e=>"image"===e.type||"svg"===e.type)).map((e=>e.id)));i(g),l(!1);const b=(t=>{const a=[];return t.forEach((t=>{const r=e.find((e=>e.id===t));r&&"settings"===r.type&&confirm((0,y.__)("Importing these settings will overwrite your existing settings, do you wish to continue?")+"\n"+r.name)&&a.push(r.id)})),a})(g);for(const t of g){const a=e.find((e=>e.id===t));void 0!==a&&(r(a),"color"===a.type||"code"===a.type||("post"===a.type?await C().libraries.getItem(a.id).then((async e=>{await p.importPost(e.data).then((async t=>{if(t.data.error&&"post_type_not_registered"===t.data.error_code)return m.push({name:a.name,type:t.data.post_type}),void o++;await d(t.data,e.data),s++}))})):"settings"===a.type?b.includes(a.id)&&(await p.importSettings(a.id),s++):(await p.importItem(a),s++))),n++,c(n)}const _=m.map((e=>u().createElement("li",{key:e.name},e.name," (",e.type,")")));s>0?t({status:"success",shouldDismiss:!1,content:u().createElement(u().Fragment,null,(0,y.__)("Library items imported!"),o>0&&u().createElement(u().Fragment,null," ",(0,y.__)("Some items were not able to be imported due to these post types not being registered on this site: "),u().createElement("br",null),u().createElement("ul",null,_)))}):o>0&&t({status:"error",shouldDismiss:!1,content:u().createElement(u().Fragment,null,(0,y.__)("The selected items were not able to be imported due to these post types not being registered on this site: "),u().createElement("br",null),u().createElement("ul",null,_))}),c(0),l(!0)};let _=[];e&&(_=[...new Set(e.filter((e=>"post"===e.type)).map((e=>e.data.post.post_type)))]);const h={anyContent:!1,bbContent:!1,images:!1,allSettings:!1,themeSettings:!1,bbSettings:!1};return e&&(h.anyContent=e.some((e=>"post"===e.type)),h.bbContent=e.some((e=>"post"===e.type&&"beaver-builder"===e.subtype)),h.images=e.some((e=>"image"===e.type||"svg"===e.type)),h.allSettings=e.some((e=>"settings"===e.type)),h.themeSettings=e.some((e=>"settings"===e.type&&"theme_settings"===e.subtype)),h.bbSettings=e.some((e=>"settings"===e.type&&"bb_settings"===e.subtype))),null!==a||s?u().createElement("div",{style:{gridColumn:"span 2"}},!s&&u().createElement("p",null,(0,y.__)("Import in progress. Navigating away from this view will stop the import process!")),u().createElement(Y,{progress:o/n.length*100}),u().createElement("p",{style:{fontStyle:"italic",fontSize:"12px",marginTop:"var(--fluid-sm-space)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},null!==a&&!s&&(0,y.sprintf)((0,y.__)("Importing %s"),a.name),s&&(0,y.__)("Import Complete!"))):u().createElement("select",{title:(0,y.__)("Import all items in this library into your site."),onChange:e=>g(e.target.value)},u().createElement("option",{value:""},(0,y.__)("Import Library...")),u().createElement("option",{value:"all"},"All Items"),u().createElement("optgroup",{label:(0,y.__)("Content")},u().createElement("option",{value:"all-content",disabled:!h.anyContent},(0,y.__)("All Content")),u().createElement("option",{value:"bb-content",disabled:!h.bbContent},(0,y.__)("Beaver Builder Content")),_.map((e=>u().createElement("option",{key:e,value:"post_type:"+e},"Post Type: ",e)))),u().createElement("optgroup",{label:(0,y.__)("Settings")},u().createElement("option",{value:"all-settings",disabled:!h.allSettings},(0,y.__)("All Settings")),u().createElement("option",{value:"theme-settings",disabled:!h.themeSettings},(0,y.__)("Theme Settings")),u().createElement("option",{value:"bb-settings",disabled:!h.bbSettings},(0,y.__)("Beaver Builder Settings"))),u().createElement("option",{value:"all-images",disabled:!h.images},(0,y.__)("Images")))},Y=({progress:e})=>u().createElement("div",{style:{background:"var(--fluid-transparent-10)",borderRadius:"var(--fluid-radius)",height:"6px"}},u().createElement("div",{style:{background:"var(--fluid-transparent-4)",borderRadius:"var(--fluid-radius)",height:"6px",width:`${e}%`}})),M=(e,t)=>{const a=URL.createObjectURL(e),r=document.createElement("a");r.href=a,r.download=t||"library.zip",document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(a)},j=()=>{const{library:e}=b.Libraries.LibraryContext.use(),[t,a]=(0,m.useState)(!1),[r,n]=(0,m.useState)(null),[i,s]=(0,m.useState)(!1);return u().createElement(u().Fragment,null,u().createElement(_.Modal.Dialog,{isShowing:t,setIsShowing:a,className:"fl-asst-download-preparing-dialog",message:u().createElement(u().Fragment,null,u().createElement(_.Layout.Headline,{style:{marginBottom:"var(--fluid-lg-space)"}},r?(0,y.__)("Download issue"):(0,y.__)("Preparing your download...")),r?u().createElement("p",null,r):u().createElement(u().Fragment,null,u().createElement("p",{style:{marginBottom:"var(--fluid-lg-space)"}},(0,y.__)("Do not navigate away from this page. Your library will automatically be downloaded when ready.")),u().createElement(_.Layout.Loading,{style:{justifyContent:"center"}}))),buttons:r?[{label:(0,y.__)("Close"),onClick:({closeDialog:e})=>{n(null),e()}}]:[]}),u().createElement(_.Button,{title:(0,y.__)("Download a ZIP file of all items in this library."),disabled:i,onClick:async()=>{s(!0);try{const t=await C().libraries.requestDownload(e.id);if(202===t.status){const e=await t.data.text(),r=JSON.parse(e);if(r.download_token)return void await(async e=>{a(!0),n(null);const t=async()=>{try{const r=await C().libraries.getDownloadStatus(e);if("ready"===r.status){const t=await C().libraries.getDownloadBlob(e);return M(t.data,r.filename),a(!1),s(!1),void b.Libraries.loadAppState()}if("expired"===r.status)return n(r.message||(0,y.__)("Download link expired. Please try again.")),void s(!1);setTimeout(t,2e3)}catch(e){const t=e?.response?.data?.message,a=e?.response?.data?.status;n(404===e?.response?.status&&"expired"===a?e?.response?.data?.message||(0,y.__)("Download link expired. Please try again."):t&&"string"==typeof t?t:(0,y.__)("Something went wrong. Please try again.")),s(!1)}};t()})(r.download_token)}if(200===t.status){const a=t.headers["content-disposition"]?(/filename="?([^";\n]+)"?/.exec(t.headers["content-disposition"])||[])[1]:null;M(t.data,a||`${e.name||"library"}.zip`)}}catch(e){a(!0),n((0,y.__)("Download failed. Please try again."))}s(!1)}},(0,y.__)("Download ZIP")))},G=()=>{const{library:e,createNotice:t}=b.Libraries.LibraryContext.use(),{cloudConfig:a}=(0,g.getSystemConfig)(),r=`${(a.appUrl||"").replace(/\/$/,"")}/community/library/${e.id}`;return u().createElement(_.Button,{title:(0,y.__)("Copy the link to this library on Assistant Pro."),onClick:async()=>{await(async e=>{try{return await navigator.clipboard.writeText(e),!0}catch{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t),t.select();try{return document.execCommand("copy")}finally{document.body.removeChild(t)}}})(r)?t("success",(0,y.__)("Public URL copied to clipboard.")):t("error",(0,y.__)("Could not copy URL."))}},(0,y.__)("Copy Public URL"))},q=()=>{const{isReadOnly:e,library:t}=b.Libraries.LibraryContext.use(),{cloudUser:a}=(0,g.useSystemState)(),r=a.id===t.permissions.permissions_user_id&&!t.permissions.owner,n=t.permissions.shared&&!t.permissions.owner||r;return u().createElement(u().Fragment,null,!e&&u().createElement(_.Layout.Box,{padY:!1},u().createElement(_.Page.Section,{label:(0,y.__)("Actions")},u().createElement(_.Button.Group,{appearance:"grid"},u().createElement(V,null),u().createElement(j,null),"public"===t.visibility&&u().createElement(G,null)))),!n&&u().createElement(_.Layout.Box,{padY:!1,className:"fl-asst-library-settings"},u().createElement(_.Page.Section,{label:(0,y.__)("Library Settings"),padY:!1},u().createElement(b.Libraries.LibrarySettingsForm,null))),!e&&u().createElement(u().Fragment,null,(!n||n&&t.permissions.edit_collections)&&u().createElement(_.Layout.Box,{padY:!1},u().createElement(_.Page.Section,{label:(0,y.__)("Library Collections")},u().createElement(b.Libraries.LibraryCollectionsForm,null)))),t.permissions.delete&&u().createElement(_.Layout.Box,null,u().createElement(_.Page.Section,{label:(0,y.__)("Danger Zone")},u().createElement(_.Layout.Headline,null,(0,y.__)("Delete This Library")),u().createElement("p",{style:{margin:"0"}},(0,y.__)("Once a library has been deleted, it is gone forever. Please be sure you want to delete this library."))),u().createElement(b.Libraries.LibraryDeleteForm,null)))},Z=()=>{const{pathname:e}=(0,d.useLocation)();return u().createElement(b.Libraries.LibraryDetail,null,u().createElement("div",{style:{visibility:e.includes("/items/")?"hidden":"",width:"100%",flex:"1 1 auto",display:"flex",position:"absolute",top:0,bottom:0}},u().createElement(_.Page,{title:(0,y.__)("Library"),shouldShowBackButton:!0,actions:u().createElement(h,null),padX:!1,padY:!1},u().createElement(d.Switch,null,u().createElement(d.Route,{path:"/libraries/:id/settings",component:q}),u().createElement(d.Route,{path:"/libraries/:id",component:B})))),u().createElement(d.Switch,null,u().createElement(d.Route,{path:"/libraries/:id/item/:itemId",component:z})))},X=()=>{const{cloudConfig:e}=(0,g.getSystemConfig)(),{cloudUser:t}=(0,g.useSystemState)(),[a,r]=(0,m.useState)(!1),n=()=>u().createElement(u().Fragment,null,u().createElement(_.Menu.Item,{href:e.appUrl,target:"_blank"},(0,y.__)("Launch Cloud")),u().createElement(_.Menu.Item,{onClick:()=>C().auth.logout()},(0,y.__)("Disconnect")));return u().createElement(_.Menu,{content:u().createElement(n,null),isShowing:a,onOutsideClick:()=>r(!1),style:{zIndex:9}},u().createElement(_.Button,{onClick:()=>r(!a),className:"fl-asst-cloud-gravatar-link",appearance:"elevator",size:"sm",style:{backgroundImage:`url(${t.gravatar.sm})`,backgroundSize:"contain",height:"25px",width:"25px",minHeight:"0",minWidth:"0"}}))},J=(e,t,a)=>{const r=(e="user",t=null)=>{const r=t?a[e][t]:a[e];return r?r.map(b.formatItem):[]},n=r("access"),i=[{key:"user",label:e?e.name:"",avatar:e.avatar?e.avatar.sizes.thumb.url:e.gravatar.md,to:"/libraries/user",items:r(),canCreateLibraries:!0},{key:"shared",label:(0,y.__)("Shared Libraries"),avatar:u().createElement(_.Icon.Shared,null),to:"/libraries/shared",isEnabled:!!a?.shared?.length,items:r("shared"),canCreateLibraries:!1},{key:"community",label:(0,y.__)("Community Libraries"),avatar:u().createElement(_.Icon.Swirl,null),isEnabled:!!n.length,items:n,canCreateLibraries:!1},...((e=[])=>e.map((e=>({...(0,b.formatSection)(e),items:r("team",e.id),canCreateLibraries:e.permissions.edit_libraries}))))(t)];return i},K=({preloadedLib:e=!1,preloadedTeams:t=!1})=>{const{cloudUser:a}=(0,g.useSystemState)(),{filter:r,libraries:n,teams:i}=(0,g.useAppState)("libraries"),{owner:s,...l}=r,o=e||n,c=t||i;return u().createElement(_.Page,{title:(0,y.__)("Libraries"),icon:u().createElement(_.Icon.Library,{context:"sidebar"}),shouldShowBackButton:!1,actions:u().createElement(X,null),padX:!1,padY:!1},u().createElement(b.LibraryNav,{sections:J(a,c,o),isLoading:!1,linkSectionHeaders:!1,displayItemsAs:"grid"}))},Q=({baseURL:e})=>{const t=(0,d.useHistory)(),{isCloudConnected:a}=(0,g.useSystemState)("isCloudConnected"),{isBBExtension:r}=(0,g.getSystemConfig)();return a?u().createElement(p.Selection.Provider,null,u().createElement(d.Switch,null,u().createElement(d.Route,{exact:!0,path:`${e}`,component:K}),u().createElement(d.Route,{path:`${e}/:id`,component:Z}))):(r?t.replace("/bbapp"):t.replace("/fl-cloud-connect"),null)}}}]);