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.7.1 → 1.5.5.1 View file →
@@ -1 +1 @@
1 -"use strict";(self.webpackChunkfl_assistant=self.webpackChunkfl_assistant||[]).push([[999],{9650:(e,t,r)=>{r.r(t),r.d(t,{default:()=>H});var a={};r.r(a),r.d(a,{getActions:()=>w});var n={};r.r(n),r.d(n,{getActions:()=>x});var l={};r.r(l),r.d(l,{getActions:()=>B});var i={};r.r(i),r.d(i,{getActions:()=>k});var s={};r.r(s),r.d(s,{image:()=>n,post:()=>a,svg:()=>l,theme_settings:()=>i});var o=r(7363),c=r.n(o),u=r(6711),m=r(9818),d=r(8003),p=r(5112),_=r(4533);const y=()=>{const e=(0,u.useHistory)(),{pathname:t}=(0,u.useLocation)(),{library:r,showUpload:a,setShowUpload:n}=p.Libraries.LibraryContext.use(),l=`/libraries/${r.id}`;if(!r.permissions.update&&!r.permissions.edit_items)return null;return c().createElement(c().Fragment,null,r.permissions.edit_items&&c().createElement(_.Button,{appearance:"transparent",isSelected:a&&!t.includes("/settings"),onClick:()=>{n(!a),t!==l&&e.goBack()},style:{marginLeft:"auto"}},c().createElement(_.Icon.Plus,null)),r.permissions.update&&c().createElement(_.Button,{appearance:"transparent",isSelected:t.includes("/settings"),onClick:()=>{t===l&&e.push(`${l}/settings`)}},c().createElement(_.Icon.Cog,null)))};var g=r(7462);const b=()=>{const{library:e,showUpload:t,uploader:r}=p.Libraries.LibraryContext.use();return e.permissions.edit_items?c().createElement(c().Fragment,null,t&&c().createElement(p.Libraries.LibraryUpload,null),!!r.queuedFiles.length&&c().createElement(_.Layout.Box,{padY:!1},c().createElement(p.Uploader.FileList,{files:r.queuedFiles}))):null},h=()=>{const{library:e}=p.Libraries.LibraryContext.use();return c().createElement(c().Fragment,null,c().createElement(_.Layout.Box,{style:{textAlign:"center",padding:0}},c().createElement(_.Layout.Headline,{style:{margin:10}},e.name),e.description&&c().createElement("div",{style:{marginTop:"var(--fluid-sm-space)"}},e.description)),c().createElement(p.Libraries.LibraryMemberThumbs,null))},E=()=>{const{useItemsFilter:e}=(0,m.getAppHooks)("libraries"),[t,r]=e(),{defaultItemsFilter:a}=(0,m.useAppState)("libraries",["defaultItemsFilter"]),n=()=>"type"===t.viewBy?c().createElement(_.Filter.RadioGroupItem,{title:(0,d.__)("Type"),items:p.Libraries.getItemTypeOptions(),value:t.type,defaultValue:a.type,onChange:e=>r({...t,type:e})}):c().createElement(_.Filter.RadioGroupItem,{title:(0,d.__)("Collection"),items:p.Libraries.getCollectionOptions(),value:t.collection,defaultValue:a.collection,onChange:e=>r({...t,collection:e})});return c().createElement(_.Filter,null,c().createElement(_.Filter.RadioGroupItem,{title:(0,d.__)("View By"),items:{type:(0,d.__)("Type"),collection:(0,d.__)("Collection")},value:t.viewBy,defaultValue:a.viewBy,onChange:e=>r({...t,viewBy:e})}),c().createElement(n,null),c().createElement(_.Filter.RadioGroupItem,{title:(0,d.__)("Sort By"),items:{name:(0,d.__)("Title"),created_at:(0,d.__)("Date Created"),updated_at:(0,d.__)("Last Updated")},value:t.orderBy,defaultValue:a.orderBy,onChange:e=>r({...t,orderBy:e})}),c().createElement(_.Filter.RadioGroupItem,{title:(0,d.__)("Order"),items:{ASC:(0,d.__)("Ascending"),DESC:(0,d.__)("Descending")},value:t.order,defaultValue:a.order,onChange:e=>r({...t,order:e})}),c().createElement(_.Filter.Button,{onClick:()=>r(a)},(0,d.__)("Reset Filter")))},f=({library:e,onDrop:t,children:r,...a})=>e.permissions.edit_items?c().createElement(_.Layout.DropArea,(0,g.Z)({onDrop:t},a),r):c().createElement("div",a,r),L=()=>{const{library:e,items:t,showUpload:r,uploader:a}=p.Libraries.LibraryContext.use(),{defaultItemsFilter:n}=(0,m.useAppState)("libraries","defaultItemsFilter"),{useItemsFilter:l}=(0,m.getAppHooks)("libraries"),[i,s]=l(),o=p.Libraries.getFilteredItems(i,t),u=t&&!!t.length;return c().createElement(f,{library:e,onDrop:a.handleDrop,className:"fl-asst-library-content"},u&&c().createElement(E,null),c().createElement(h,null),c().createElement(b,null),u&&c().createElement(p.Libraries.ItemsList,null),(()=>{const{viewBy:e,type:r,collection:a}=i;if(t&&!Object.keys(o).length){if("type"===e&&"all"!==r)return!0;if("collection"===e&&"all"!==a)return!0}return!1})()&&!r&&c().createElement(c().Fragment,null,c().createElement(_.Layout.Box,{style:{textAlign:"center"}},(0,d.__)("No results found.")),c().createElement(_.Layout.Row,null,c().createElement(_.Button,{onClick:()=>s(n)},(0,d.__)("Reset Filter")))),t&&!u&&!r&&c().createElement(_.Layout.Box,{style:{textAlign:"center"}},(0,d.__)("This library doesn't have any items yet.")))};var C=r(1871);const v=()=>{const e=(0,C.getWpRest)().libraries(),t=(0,o.useRef)(0),r=(t,r,n)=>{e.importPostThumb(t.id,r.media.thumb).finally((()=>{a(t,r,n)}))},a=(r,n,l)=>{const{attachments:i}=n.media;if(void 0===i)return void l(r);const s=i[t.current];void 0===s?(t.current=0,l(r)):e.importPostMedia(r.id,s).finally((()=>{t.current++,a(r,n,l)}))};return(e,t)=>new Promise((n=>{t.media.thumb?r(e,t,n):a(e,t,n)}))},w=(e,t)=>(t.unshift({component:c().createElement(S,{item:e})}),t.unshift({component:c().createElement(F,{item:e})}),t.unshift({component:c().createElement(I,{item:e})}),t),S=({item:e})=>{const{createNotice:t}=p.Libraries.ItemContext.use(),[r,a]=(0,o.useState)(!1),n=(0,C.getWpRest)().libraries(),l=e=>{!e||e.data.error?t({status:"error",content:(0,d.__)("Error previewing content.")}):window.open(e.data.url)};return c().createElement(_.Button,{onClick:()=>{a(!0),n.previewPost(e).then((e=>{l(e)})).catch((()=>{l()})).finally((()=>{a(!1)}))},disabled:r},(0,d.__)("Preview"))},I=({item:e})=>{const t=(0,u.useHistory)(),{createNotice:r}=p.Libraries.ItemContext.use(),[a,n]=(0,o.useState)(null),[l,i]=(0,o.useState)(!1),s=(0,C.getWpRest)().libraries(),m=v(),_=t=>{if("create"===a){const{type:r}=e.data.builder,{bbEditUrl:a,editUrl:n}=t;window.location.href="beaver-builder"===r&&a?a:n}else y(t);n(null),i(!1)},y=e=>{e.error?r({status:"error",content:(0,d.__)("Error importing content.")}):r({status:"success",content:c().createElement(c().Fragment,null,(0,d.__)("Content imported!"),c().createElement("a",{style:{textDecoration:"underline",marginLeft:"var(--fluid-sm-space)"},onClick:()=>{t.push(`/fl-content/post/${e.id}`,{item:e})}},(0,d.__)("View content.")))})};return(0,o.useEffect)((()=>{a&&s.importPost(e).then((t=>{i(!0),m(t.data,e).then(_)})).catch((()=>{n(null),i(!1),r({status:"error",content:(0,d.__)("Error importing content.")})}))}),[a]),c().createElement(c().Fragment,null,c().createElement("select",{value:"",onChange:e=>n(e.target.value),disabled:a},c().createElement("option",{value:""},!l&&!a&&(0,d.__)("Create New..."),!l&&"create"===a&&(0,d.__)("Creating..."),!l&&"import"===a&&(0,d.__)("Importing..."),l&&(0,d.__)("Importing media...")),c().createElement("option",{value:"create"},(0,d.__)("Create and Edit")),c().createElement("option",{value:"import"},(0,d.__)("Import"))))},F=({item:e})=>{const{contentTypes:t}=(0,m.getSystemConfig)(),{post_type:r}=e.data.post,{createNotice:a}=p.Libraries.ItemContext.use(),[n,l]=(0,o.useState)(!1),[i,s]=(0,o.useState)(null),[u,_]=(0,o.useState)(null),y=(0,C.getWpRest)().posts(),g=(0,C.getWpRest)().libraries(),b=t[r]?t[r].labels.plural:`${r}s`,h=t[r]?t[r].labels.singular:`${r}`,E=v();(0,o.useEffect)((()=>{y.findWhere({post_type:r,posts_per_page:-1,orderby:"post_title",order:"ASC",post_status:"any"}).then((e=>{_(e.data.items)})).catch((()=>{_([])}))}),[]);const f=e=>{s(null),l(!1),!e||e.error?a({status:"error",content:(0,d.__)("Error replacing content.")}):a({status:"success",content:(0,d.__)("Content replaced!")})},L=()=>u.map(((e,t)=>c().createElement("option",{key:t,value:e.id},e.title)));return c().createElement(c().Fragment,null,c().createElement("select",{value:"",onChange:t=>(t=>{const r=(0,d.sprintf)((0,d.__)("Do you really want to replace the selected %s with this library item? This cannot be undone."),h.toLowerCase());t&&confirm(r)&&(s(t),g.syncPost(t,e).then((t=>{l(!0),E(t.data,e).then((()=>{f()}))})).catch((()=>{f()})))})(t.target.value),disabled:i},c().createElement("option",{value:""},!n&&!i&&(0,d.__)("Replace..."),!n&&i&&(0,d.__)("Replacing..."),n&&(0,d.__)("Importing media...")),null===u&&c().createElement("optgroup",{label:(0,d.__)("Loading...")}),null!==u&&!u.length&&c().createElement("optgroup",{label:(0,d.sprintf)((0,d.__)("No %s found"),b.toLowerCase())}),null!==u&&!!u.length&&c().createElement(L,null)))},x=(e,t)=>{const{createNotice:r}=p.Libraries.ItemContext.use(),[a,n]=(0,o.useState)(!1),l=(0,C.getWpRest)();return t.unshift({label:(0,d.__)("Import"),onClick:()=>{n(!0),l.libraries().importItem(e).then((e=>{r({status:e.data.error?"error":"success",content:e.data.error?e.data.error:(0,d.__)("Item imported!")})})).catch((e=>{r({status:"error",content:e.response.data.message})})).finally((()=>{n(!1)}))},disabled:a}),t},B=(e,t)=>{const{createNotice:r}=p.Libraries.ItemContext.use(),[a,n]=(0,o.useState)(!1),l=(0,C.getWpRest)();return t.unshift({label:(0,d.__)("Import"),onClick:()=>{n(!0),l.libraries().importItem(e).then((e=>{r({status:e.data.error?"error":"success",content:e.data.error?e.data.error:(0,d.__)("Item imported!")})})).catch((e=>{r({status:"error",content:e.response.data.message})})).finally((()=>{n(!1)}))},disabled:a}),t},k=(e,t)=>{const{adminURLs:r,themeSlug:a,themeParentSlug:n}=(0,m.getSystemConfig)(),{createNotice:l}=p.Libraries.ItemContext.use(),[i,s]=(0,o.useState)(!1),c=(0,C.getWpRest)().libraries(),u=()=>{const{name:t,slug:r,parent:l}=e.data.theme;return r!==a&&((!l||l.slug!==a)&&((!n||r!==n)&&(l?alert((0,d.sprintf)((0,d.__)('The themes "%s" or "%s" must be active to apply or preview these settings.'),l.name,t)):alert((0,d.sprintf)((0,d.__)('The theme "%s" must be active to apply or preview these settings.'),t)),!0)))};return t.unshift({label:(0,d.__)("Apply to Theme"),onClick:()=>{u()||confirm((0,d.__)("Do you really want to import these theme settings? This will update your site design and cannot be undone."))&&(s(!0),c.importThemeSettings(e.id).then((e=>{s(!1),e.data.error?l({status:"error",content:e.data.error,shouldDismiss:!1}):(l({status:"success",content:(0,d.__)("Settings imported!")}),window.location.reload())})))},disabled:i}),t.unshift({label:(0,d.__)("Preview"),onClick:()=>{u()||window.open(`${r.customizeBase}?fl-asst-customizer-preview-init=${e.id}`)}}),t},R=()=>c().createElement("div",{style:{display:"flex",position:"absolute",top:0,right:0,bottom:0,left:0,width:"100%"}},c().createElement(p.Libraries.ItemDetail,{formConfig:s}));var A=r(3895),D=r.n(A);const T=()=>{const{items:e}=p.Libraries.LibraryContext.use(),[t,r]=(0,o.useState)(null),[a,n]=(0,o.useState)(!1),l=v();(0,o.useEffect)((()=>{null!==t&&i()}),[t]);const i=()=>{const r=e[t],a=(0,C.getWpRest)().libraries();"color"===r.type||"theme_settings"===r.type?s():"post"===r.type?D().libraries.getItem(r.id).then((e=>{a.importPost(e.data).then((t=>{l(t.data,e.data).then((()=>{s()}))})).catch((()=>{s()}))})).catch((()=>{s()})):a.importItem(r).finally(s)},s=()=>{const a=null===t?0:t+1;if(!e[a])return r(null),void n(!0);r(a)};return null!==t||a?c().createElement(c().Fragment,null,c().createElement("p",null,(0,d.__)("Import in progress. Navigating away from this view will stop the import process!")),c().createElement($,{progress:null===t?100:t/e.length*100}),c().createElement("p",{style:{fontStyle:"italic",fontSize:"12px",marginTop:"var(--fluid-sm-space)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"}},null!==t&&(0,d.sprintf)((0,d.__)("Importing %s"),e[t].name),null===t&&(0,d.__)("Import Complete!"))):c().createElement(P,{onClick:()=>s()})},P=({onClick:e})=>c().createElement(c().Fragment,null,c().createElement("p",null,(0,d.__)("Click the button below to import all items in this library into your site.")),c().createElement(_.Button,{onClick:e},(0,d.__)("Import Library"))),$=({progress:e})=>c().createElement("div",{style:{background:"var(--fluid-transparent-10)",borderRadius:"var(--fluid-radius)",height:"6px"}},c().createElement("div",{style:{background:"var(--fluid-transparent-4)",borderRadius:"var(--fluid-radius)",height:"6px",width:`${e}%`}})),N=()=>{const{library:e}=p.Libraries.LibraryContext.use();return c().createElement(c().Fragment,null,c().createElement(_.Layout.Box,{padY:!1,className:"fl-asst-library-settings"},c().createElement(_.Page.Section,{label:(0,d.__)("Library Settings"),padY:!1},c().createElement(p.Libraries.LibrarySettingsForm,null))),c().createElement(_.Layout.Box,{padY:!1},c().createElement(_.Page.Section,{label:(0,d.__)("Library Collections")},c().createElement(p.Libraries.LibraryCollectionsForm,null))),c().createElement(_.Layout.Box,{padY:!1},c().createElement(_.Page.Section,{label:(0,d.__)("Import Library")},c().createElement(T,null))),e.permissions.delete&&c().createElement(_.Layout.Box,null,c().createElement(_.Page.Section,{label:(0,d.__)("Danger Zone")},c().createElement(_.Layout.Headline,null,(0,d.__)("Delete This Library")),c().createElement("p",{style:{margin:"0"}},(0,d.__)("Once a library has been deleted, it is gone forever. Please be sure you want to delete this library."))),c().createElement(p.Libraries.LibraryDeleteForm,null)))},U=()=>{const{pathname:e}=(0,u.useLocation)();return c().createElement(p.Libraries.LibraryDetail,null,c().createElement("div",{style:{visibility:e.includes("/items/")?"hidden":"",width:"100%",flex:"1 1 auto",display:"flex",position:"absolute",top:0,bottom:0}},c().createElement(_.Page,{title:(0,d.__)("Library"),shouldShowBackButton:!0,actions:c().createElement(y,null),padX:!1,padY:!1},c().createElement(u.Switch,null,c().createElement(u.Route,{path:"/libraries/:id/settings",component:N}),c().createElement(u.Route,{path:"/libraries/:id",component:L})))),c().createElement(u.Switch,null,c().createElement(u.Route,{path:"/libraries/:id/item/:itemId",component:R})))},O=()=>{const{cloudConfig:e}=(0,m.getSystemConfig)(),{cloudUser:t}=(0,m.useSystemState)();return c().createElement(c().Fragment,null,c().createElement(_.Button,{className:"fl-asst-cloud-gravatar-link",href:e.appUrl,target:"_blank",appearance:"elevator",size:"sm",style:{backgroundImage:`url(${t.gravatar.sm})`,backgroundSize:"contain",height:"25px",width:"25px",minHeight:"0",minWidth:"0"}}))},W=()=>{const{useDefaultFilter:e,useFilter:t}=(0,m.getAppHooks)("libraries"),[r]=e(),[a,n]=t(),l=e=>{n(e),p.Libraries.loadAppState()};return c().createElement(_.Filter,null,c().createElement(_.Filter.RadioGroupItem,{title:(0,d.__)("Owner"),items:p.Libraries.getLibraryOwnerOptions(),value:a.owner,defaultValue:r.owner,onChange:e=>l({...a,owner:e})}),c().createElement(_.Filter.RadioGroupItem,{title:(0,d.__)("Sort By"),items:{name:(0,d.__)("Title"),created_at:(0,d.__)("Date Created"),updated_at:(0,d.__)("Last Updated")},value:a.orderBy,defaultValue:r.orderBy,onChange:e=>l({...a,orderBy:e})}),c().createElement(_.Filter.RadioGroupItem,{title:(0,d.__)("Order"),items:{ASC:(0,d.__)("Ascending"),DESC:(0,d.__)("Descending")},value:a.order,defaultValue:r.order,onChange:e=>l({...a,order:e})}),c().createElement(_.Filter.RadioGroupItem,{title:(0,d.__)("Display As"),items:{grid:(0,d.__)("Grid"),list:(0,d.__)("List")},value:a.displayAs,defaultValue:r.displayAs,onChange:e=>l({...a,displayAs:e})}),c().createElement(_.Filter.Button,{onClick:()=>l(r)},(0,d.__)("Reset Filter")))},V=({headline:e="",type:t="user",team:r=null})=>{const{libraries:a,isLoadingLibraries:n}=(0,m.useAppState)("libraries"),l=r?r.id:0,i=l?a[t][l]:a[t],s=i&&0<i.length,u=!r||r.permissions.edit_libraries,[y,g]=(0,o.useState)(!1);return c().createElement(_.Layout.Box,{className:"fl-asst-libraries-grid",padX:!1,padY:!1},!y&&c().createElement(_.Layout.Toolbar,{style:{paddingLeft:20}},c().createElement(_.Text.Title,null,e),"shared"!==t&&u&&c().createElement(_.Button,{appearance:"transparent",shape:"round",onClick:()=>g(!0),style:{marginLeft:"auto"}},c().createElement(_.Icon.PlusSmall,null))),y&&c().createElement(_.Layout.Toolbar,null,c().createElement(p.Libraries.LibraryInlineCreate,{team:r}),c().createElement(_.Button,{onClick:()=>g(!1),style:{marginLeft:5}},c().createElement(_.Icon.CloseCompact,null))),!n&&!s&&c().createElement(_.Layout.Box,{style:{textAlign:"center"}},(0,d.__)("You don't currently have any libraries. Create one to get started!")),c().createElement(p.Libraries.LibrariesList,{type:t,team:r,maxItems:6}))},G=()=>{const{cloudUser:e}=(0,m.useSystemState)(),{filter:t,libraries:r,teams:a}=(0,m.useAppState)("libraries"),{owner:n,...l}=t;return c().createElement(_.Page,{title:(0,d.__)("Libraries"),icon:c().createElement(_.Icon.Library,{context:"sidebar"}),shouldShowBackButton:!1,actions:c().createElement(O,null),padX:!1,padY:!1},c().createElement(W,null),c().createElement("div",{className:"fl-asst-libraries"},("all"===n||"user"===n)&&c().createElement(V,{headline:e.name.endsWith("s")?`${e.name}'`:`${e.name}'s`,query:l}),!!r.shared.length&&c().createElement(V,{headline:(0,d.__)("Shared Libraries"),type:"shared",query:l}),a.map(((t,r)=>{if("all"===n||`team_${t.id}`===n)return c().createElement(V,{key:r,headline:e.name.endsWith("s")?`${t.name}'`:`${t.name}'s`,type:"team",team:t,query:l})}))))},H=({baseURL:e})=>{const t=(0,u.useHistory)(),{isCloudConnected:r}=(0,m.useSystemState)("isCloudConnected");return r?c().createElement(u.Switch,null,c().createElement(u.Route,{exact:!0,path:`${e}`,component:G}),c().createElement(u.Route,{path:`${e}/:id`,component:U})):(t.replace("/fl-cloud-connect"),null)}},7462:(e,t,r)=>{function a(){return a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},a.apply(this,arguments)}r.d(t,{Z:()=>a})}}]);
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)}}}]);