"use strict";(globalThis.webpackChunk_affine_web=globalThis.webpackChunk_affine_web||[]).push([[9909],{19909:(e,l,i)=>{i.r(l),i.d(l,{CollectionDetail:()=>I,Component:()=>k});var t=i(36870),n=i(63234),o=i(77562),s=i(4285),c=i(79085),a=i(24312),r=i(45483),d=i(10980),x=i(33907),h=i(61569),f=i(17049),p=i(86326),g=i(42277),m=i(69628),j=i(84064),u=i(93965),y="xpxsif0",v=i(65423),C=i(26798),b=i(37064);let w=({showCreateNew:e,onCreate:l})=>(0,t.jsx)(v.Y,{right:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.K0,{size:"16",icon:(0,t.jsx)(r.PlusIcon,{}),onClick:l,className:(0,b.A)("xpxsif2","xpxsif3",!e&&"xpxsif4")}),(0,t.jsx)(o.ze,{})]}),center:(0,t.jsx)(C.w,{activeFilter:"collections"})}),I=({collection:e})=>{let{node:l,open:i}=(0,o.is)(),n=(0,d.h1)(c.Y),[a,r]=(0,p.useState)(!0),x=(0,s.V)(async()=>{let l=await i({...e},"page");n.updateCollection(l.id,()=>l)},[e,n,i]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(j.XP,{children:(0,t.jsx)(w,{showCreateNew:!a,onCreate:x})}),(0,t.jsx)(j.s$,{children:(0,t.jsx)(o.jF,{collection:e,setHideHeaderCreateNewPage:r})}),l]})},k=function(){let{collectionService:e,globalContextService:l}=(0,d.A$)({CollectionService:c.Y,GlobalContextService:x.q}),i=l.globalContext,o=(0,h.S)(e.collections$),s=(0,m.P)(),a=(0,g.g)(),r=(0,d.h1)(f.j).workspace,y=o.find(e=>e.id===a.collectionId),v=(0,j.Tq)(),C=(0,p.useCallback)(()=>{s.jumpToSubPath(r.id,u.Tk.ALL);let l=e.collectionsTrash$.value.find(e=>e.collection.id===a.collectionId),i="Collection does not exist";return l&&(i=l.userId?`${l.collection.name} has been deleted by ${l.userName}`:`${l.collection.name} has been deleted`),n.me.error({title:i})},[e,s,a.collectionId,r.id]);if((0,p.useEffect)(()=>{if(v&&y)return i.collectionId.set(y.id),i.isCollection.set(!0),()=>{i.collectionId.set(null),i.isCollection.set(!1)}},[y,i,v]),(0,p.useEffect)(()=>{y||C()},[y,C]),!y)return null;let b=P(y)?(0,t.jsx)(S,{collection:y}):(0,t.jsx)(I,{collection:y});return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(j.tC,{icon:"collection"}),(0,t.jsx)(j.EY,{title:y.name}),b]})},S=({collection:e})=>{let l=(0,d.h1)(f.j).workspace,i=(0,d.h1)(c.Y),{node:n,open:x}=(0,o.is)(),{jumpToCollections:h}=(0,m.P)(),g=(0,s.V)(async()=>{let l=await x({...e},"page");i.updateCollection(l.id,()=>l)},[x,e,i]),u=(0,s.V)(async()=>{let l=await x({...e},"rule");i.updateCollection(l.id,()=>l)},[e,x,i]),[v,C]=(0,p.useState)(!1);(0,p.useEffect)(()=>{C(!localStorage.getItem("hide-empty-collection-help-info"))},[]);let b=(0,p.useCallback)(()=>{C(!1),localStorage.setItem("hide-empty-collection-help-info","true")},[]),w=(0,a.s9)(),I=(0,p.useCallback)(()=>{h(l.id)},[h,l]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(j.XP,{children:(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:"var(--affine-font-xs)"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4,cursor:"pointer",color:"var(--affine-text-secondary-color)",WebkitAppRegion:"no-drag"},onClick:I,children:[(0,t.jsx)(r.ViewLayersIcon,{style:{color:"var(--affine-icon-color)"},fontSize:14}),w["com.arms.collection.allCollections"](),(0,t.jsx)("div",{children:"/"})]}),(0,t.jsx)("div",{"data-testid":"collection-name",style:{fontWeight:600,color:"var(--affine-text-primary-color)",WebkitAppRegion:"no-drag"},children:e.name}),(0,t.jsx)("div",{style:{flex:1}})]})}),(0,t.jsx)(j.s$,{children:(0,t.jsxs)("div",{style:{display:"flex",flex:1,flexDirection:"column",alignItems:"center",gap:64},children:[(0,t.jsxs)("div",{style:{maxWidth:432,marginTop:118,display:"flex",flexDirection:"column",alignItems:"center",gap:18,margin:"118px 12px 0"},children:[(0,t.jsx)(o.Ee,{}),(0,t.jsx)("div",{style:{fontSize:20,lineHeight:"28px",fontWeight:600,color:"var(--affine-text-primary-color)"},children:w["com.arms.collection.emptyCollection"]()}),(0,t.jsx)("div",{style:{fontSize:12,lineHeight:"20px",color:"var(--affine-text-secondary-color)",textAlign:"center"},children:w["com.arms.collection.emptyCollectionDescription"]()}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"12px 32px",flexWrap:"wrap",justifyContent:"center"},children:[(0,t.jsxs)("div",{onClick:g,className:y,children:[(0,t.jsx)(r.PageIcon,{style:{width:20,height:20,color:"var(--affine-icon-color)"}}),(0,t.jsx)("span",{style:{padding:"0 4px"},children:w["com.arms.collection.addPages"]()})]}),(0,t.jsxs)("div",{onClick:u,className:y,children:[(0,t.jsx)(r.FilterIcon,{style:{width:20,height:20,color:"var(--affine-icon-color)"}}),(0,t.jsx)("span",{style:{padding:"0 4px"},children:w["com.arms.collection.addRules"]()})]})]})]}),v?(0,t.jsxs)("div",{style:{maxWidth:452,borderRadius:8,display:"flex",flexDirection:"column",backgroundColor:"var(--affine-background-overlay-panel-color)",padding:10,gap:14,margin:"0 12px"},children:[(0,t.jsxs)("div",{style:{fontWeight:600,fontSize:12,lineHeight:"20px",color:"var(--affine-text-secondary-color)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[(0,t.jsx)("div",{children:w["com.arms.collection.helpInfo"]()}),(0,t.jsx)(r.CloseIcon,{className:"xpxsif1",style:{width:16,height:16},onClick:b})]}),(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:10,fontSize:12,lineHeight:"20px"},children:[(0,t.jsx)("div",{children:(0,t.jsxs)(a.x6,{i18nKey:"com.arms.collection.addPages.tips",children:[(0,t.jsx)("span",{style:{fontWeight:600},children:"Add pages:"})," You can freely select pages and add them to the collection."]})}),(0,t.jsx)("div",{children:(0,t.jsxs)(a.x6,{i18nKey:"com.arms.collection.addRules.tips",children:[(0,t.jsx)("span",{style:{fontWeight:600},children:"Add rules:"})," Rules are based on filtering. After adding rules, pages that meet the requirements will be automatically added to the current collection."]})})]})]}):null]})}),n]})},P=e=>0===e.allowList.length&&0===e.filterList.length}}]); //# sourceMappingURL=chunk.9909.e2f69b66.js.map