"use strict";(globalThis.webpackChunk_affine_web=globalThis.webpackChunk_affine_web||[]).push([[8962],{68962:(e,a,s)=>{s.r(a),s.d(a,{Component:()=>a0,DetailPage:()=>aQ});var t=s(36870),r=s(63234),o=s(89716),i=s(22943),n=s(50233),l=s(6503),c=s(4892),d=s(19918),m=s(10871),p=s(21167),u=s(69050),h=s(45483),x=s(10980),f=s(61569),g=s(58507),j=s(17049),y=s(33907),v=s(16146),b=s(70154),k=s(37064),w=s(86326),C=s(42277),$=s(61362),S=s(55683),N=s(34310),I=s(77846),M=s(71006),D=s(49791),E=s(5863),_=s(24069);let O=new WeakMap;function P(e,a){let s=function(e,a){O.has(e)||O.set(e,new Map);let s=O.get(e);if((0,M.Z1)(s),s.has(a))return s.get(a);{let t=(0,D.eU)(e.getDoc(a)?.meta?.title||"Untitled");return t.onMount=s=>{let t=e.meta.docMetaUpdated.on(()=>{let t=e.getDoc(a);s(t?.meta?.title||"Untitled")});return()=>{t.dispose()}},s.set(a,t),t}}(e,a);(0,M.Z1)(s);let t=(0,E.md)(s),{localizedJournalDate:r}=(0,_.Bn)(e,a);return r||t}var F=s(94002),T=s(61953),B=s(52114),L=s(24312),R=s(55137),U=s(16820);let A=(0,D.eU)({open:!1,pageId:""});var Y=s(8473),V=s(23110),X="_2ct5f60",z=s(71344);let W={value:"edgeless",label:(0,t.jsx)(z._,{}),testId:"switch-edgeless-mode-button",className:X},H={value:"page",label:(0,t.jsx)(z.n,{}),testId:"switch-page-mode-button",className:X},Z=({mode:e,setMode:a,hidePage:s,hideEdgeless:o})=>{let i=(0,w.useMemo)(()=>[...s?[]:[H],...o?[]:[W]],[o,s]);return(0,t.jsx)(r.z6,{iconMode:!0,itemHeight:24,borderRadius:8,padding:4,gap:8,value:e,items:i,onChange:a})};var K=s(43392),q=s(52490),G=s(21817),J=s(73711),Q=s(96269),ee=s(89679),ea=s(14486),es=s(52600);let et=new q.k("page-history"),er=(e,a)=>{let{data:s,loadingMore:t,loadMore:r}=(0,ea.e6)({query:G.DX,getVariables:(s,t)=>({pageDocId:a,workspaceId:e,before:t?.workspace.histories.at(-1)?.timestamp,take:10})}),o=(0,w.useMemo)(()=>{if(!s)return!1;let e=s.at(-1);return!!e&&10===e.workspace.histories.length},[s]);return[(0,w.useMemo)(()=>s?s.flatMap(e=>e.workspace.histories):[],[s]),!!o&&r,!!t]},eo=async([e,a,s])=>{if(!s)return null;let t=await fetch(`/api/workspaces/${e}/docs/${a}/histories/${s}`);if(!t.ok)throw Error("Failed to fetch snapshot");let r=await t.arrayBuffer();if(!r)throw Error("Invalid snapshot");return r},ei=new Map,en=e=>{let a=ei.get(e);if(!a){let s=new es.c(e);a=new J.rl({id:e,blobSources:{main:s},schema:v.G,disableBacklinkIndex:!0,disableSearchIndex:!0}),ei.set(e,a),a.doc.emit("sync",[!0,a.doc])}return a},el=(e,a,s)=>{let{data:t}=(0,Q.A)([e,a,s],{fetcher:eo,suspense:!1});return t??void 0},ec=(e,a,s)=>{let t=el(e.id,a,s),r=(0,w.useMemo)(()=>{if(!s)return;let r=a+"-"+s,o=en(e.id),i=o.getDoc(r);if(!i&&t){(i=o.createDoc({id:r})).awarenessStore.setReadonly(i.blockCollection,!0);let e=i.spaceDoc;i.load(()=>{(0,U.applyUpdate)(e,new Uint8Array(t)),o.schema.upgradeDoc(0,{},e)})}return i??void 0},[a,t,s,e]);return(0,w.useEffect)(()=>{let a=en(e.id),s=(0,U.encodeStateAsUpdate)(e.doc);(0,U.applyUpdate)(a.doc,s)},[e]),r},ed=e=>{let a=new Map;for(let s of e){let e=(0,L.U$)(s.timestamp,{relative:{max:[1,"week"],accuracy:"day",weekday:!0},absolute:{accuracy:"day",noYear:!0}}),t=a.get(e)??[];t.push(s),a.set(e,t)}return[...a.entries()]},em=(e,a)=>{let s=(0,K.D)(e,a),t=(0,ee.i)(),{trigger:r,isMutating:o}=(0,ee.n)({mutation:G.C8}),{getDocMeta:i,setDocTitle:n}=(0,c.B)(e);return{onRestore:(0,w.useMemo)(()=>async(o,l)=>{if(!s)return;let c=s.spaceDoc.guid;!function(e,a,s){let t=new U.Doc;(0,U.applyUpdate)(t,a);let r=(0,U.encodeStateVector)(e),o=(0,U.encodeStateVector)(t),i=(0,U.encodeStateAsUpdate)(e,o),n=new U.UndoManager([...t.share.keys()].map(e=>{let a=s(e);if("Text"===a)return t.getText(e);if("Map"===a)return t.getMap(e);if("Array"===a)return t.getArray(e);throw Error("Unknown type")}));(0,U.applyUpdate)(t,i),n.undo();let l=(0,U.encodeStateAsUpdate)(t,r);(0,U.applyUpdate)(e,l)}(s.spaceDoc,l,e=>((0,M.U2)(e,"blocks"),"Map"));let d=s.meta?.title??"";i(a)?.title!==d&&n(a,d),await r({docId:c,timestamp:o,workspaceId:e.id}),await t(G.DX,a=>a.pageDocId===c&&a.workspaceId===e.id),et.info("Page restored",c,o)},[i,t,s,a,r,n,e.id]),isMutating:o}},ep=()=>(0,t.jsxs)("svg",{width:"200",height:"174",viewBox:"0 0 200 174",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,t.jsx)("rect",{x:"51.724",y:"38.4615",width:"96.5517",height:"96.5517",stroke:"var(--affine-text-disable-color)"}),(0,t.jsx)("path",{d:"M51.8339 86.7374L99.9999 38.5714L148.166 86.7374L99.9999 134.903L51.8339 86.7374Z",stroke:"var(--affine-text-disable-color)"}),(0,t.jsx)("path",{d:"M99.6052 38.1966C107.662 33.4757 117.043 30.7695 127.055 30.7695C157.087 30.7695 181.432 55.1148 181.432 85.1462C181.432 107.547 167.887 126.783 148.541 135.113",stroke:"var(--affine-text-disable-color)"}),(0,t.jsx)("path",{d:"M148.375 86.4722C153.096 94.5291 155.802 103.91 155.802 113.922C155.802 143.954 131.457 168.299 101.426 168.299C79.0254 168.299 59.7886 154.754 51.4587 135.408",stroke:"var(--affine-text-disable-color)"}),(0,t.jsx)("path",{d:"M100.394 135.113C92.3373 139.834 82.9568 142.54 72.9441 142.54C42.9127 142.54 18.5675 118.195 18.5675 88.1634C18.5675 65.763 32.1124 46.5261 51.4587 38.1963",stroke:"var(--affine-text-disable-color)"}),(0,t.jsx)("path",{d:"M51.4585 87.1318C46.7377 79.0749 44.0315 69.6943 44.0315 59.6817C44.0315 29.6503 68.3767 5.30503 98.4081 5.30503C120.809 5.30503 140.045 18.8499 148.375 38.1963",stroke:"var(--affine-text-disable-color)"}),(0,t.jsx)("path",{d:"M51.4587 38.1963L148.541 135.279",stroke:"var(--affine-text-disable-color)"}),(0,t.jsx)("path",{d:"M148.541 38.1963L51.4587 135.279",stroke:"var(--affine-text-disable-color)"}),(0,t.jsx)("path",{d:"M99.9998 38.1963V135.279",stroke:"var(--affine-text-disable-color)"}),(0,t.jsx)("path",{d:"M148.541 86.7378L51.4588 86.7378",stroke:"var(--affine-text-disable-color)"}),(0,t.jsx)("ellipse",{cx:"148.275",cy:"38.4617",rx:"3.97878",ry:"3.97878",fill:"var(--affine-text-primary-color)"}),(0,t.jsx)("ellipse",{cx:"148.275",cy:"135.013",rx:"3.97878",ry:"3.97878",fill:"var(--affine-text-primary-color)"}),(0,t.jsx)("ellipse",{cx:"148.275",cy:"86.7376",rx:"3.97878",ry:"3.97878",fill:"var(--affine-text-primary-color)"}),(0,t.jsx)("ellipse",{cx:"51.7241",cy:"38.4617",rx:"3.97878",ry:"3.97878",fill:"var(--affine-text-primary-color)"}),(0,t.jsx)("ellipse",{cx:"51.7241",cy:"135.013",rx:"3.97878",ry:"3.97878",fill:"var(--affine-text-primary-color)"}),(0,t.jsx)("ellipse",{cx:"51.7241",cy:"86.7376",rx:"3.97878",ry:"3.97878",fill:"var(--affine-text-primary-color)"}),(0,t.jsx)("ellipse",{cx:"100",cy:"38.4617",rx:"3.97878",ry:"3.97878",transform:"rotate(-90 100 38.4617)",fill:"var(--affine-text-primary-color)"}),(0,t.jsx)("ellipse",{cx:"100",cy:"86.2073",rx:"3.97878",ry:"3.97878",transform:"rotate(-90 100 86.2073)",fill:"var(--affine-text-primary-color)"}),(0,t.jsx)("ellipse",{cx:"100",cy:"135.013",rx:"3.97878",ry:"3.97878",transform:"rotate(-90 100 135.013)",fill:"var(--affine-text-primary-color)"})]});var eu="_9fbys55";let eh={"data-testid":"page-history-modal",onPointerDownOutside:e=>{e.preventDefault()},style:{padding:0,maxWidth:944,backgroundColor:"var(--affine-background-primary-color)",overflow:"hidden"}},ex=({onOpenChange:e,open:a,children:s})=>(0,t.jsx)(N.aF,{open:a,onOpenChange:e,width:"calc(100% - 64px)",height:"80%",withoutCloseButton:!0,contentOptions:eh,children:s}),ef=({ts:e,historyList:a,snapshotPage:s,onModeChange:o,mode:i,title:n})=>{let l=(0,w.useCallback)(e=>{F.u4.$.docHistory.$.switchPageMode({mode:e}),o(e)},[o]),c=(0,w.useMemo)(()=>(0,t.jsxs)("div",{className:"_9fbys58",children:[(0,t.jsxs)("div",{className:"_9fbys59",children:[(0,t.jsx)(Z,{mode:i,setMode:l}),(0,t.jsx)("div",{className:"_9fbys5a",children:n}),(0,t.jsx)("div",{className:"_9fbys5b",children:e?(0,L.U$)(e,{absolute:{accuracy:"minute",noDate:!0}}):null})]}),s?(0,t.jsx)($.E,{children:(0,t.jsxs)(r.yE.Root,{children:[(0,t.jsx)(r.yE.Viewport,{className:"affine-page-viewport",children:(0,t.jsx)(Y.H,{className:"_9fbys5c",mode:i,page:s})}),(0,t.jsx)(r.yE.Scrollbar,{})]})}):(0,t.jsx)("div",{className:"_9fbys5e",children:(0,t.jsx)(r.Rh,{size:24})})]}),[i,l,s,n,e]);return(0,t.jsx)("div",{className:"_9fbys56",children:a.map((s,r)=>{let o=a.findIndex(a=>a.timestamp===e),i=r-o,n=i>20?"> 20":i<-20?"< -20":i.toString();return(0,t.jsx)("div",{"data-distance":n,className:"_9fbys57",children:o===r?c:null},r)})})},eg=(0,D.eU)(!1),ej=()=>{let e=(0,x.h1)(B.P);(0,w.useEffect)(()=>{e.quota.revalidate()},[e]);let a=(0,f.S)(e.quota.quota$),s=(0,w.useMemo)(()=>a?"free"!==a.humanReadable.name.toLowerCase():null,[a]),r=(0,x.h1)(T.Q),o=(0,f.S)(r.permission.isOwner$);(0,w.useEffect)(()=>{r.permission.revalidate()},[r]);let i=(0,E.Xr)(I.JO),[n,l]=(0,E.fp)(eg),c=(0,w.useCallback)(()=>{l(!0)},[l]),d=(0,w.useCallback)(()=>{i({open:!0,activeTab:"plans",scrollAnchor:"cloudPricingPlan"}),F.u4.$.docHistory.$.viewPlans()},[i]),m=(0,L.s9)(),p=(0,w.useMemo)(()=>(0,t.jsxs)("div",{className:"_9fbys5x",children:[null!==s?s?m["com.arms.history.confirm-restore-modal.plan-prompt.title"]():m["com.arms.history.confirm-restore-modal.plan-prompt.limited-title"]():"",(0,t.jsx)(S.K0,{onClick:c,children:(0,t.jsx)(h.CloseIcon,{})})]}),[c,s,m]),u=(0,w.useMemo)(()=>s?(0,t.jsxs)(L.x6,{i18nKey:"com.arms.history.confirm-restore-modal.pro-plan-prompt.description",children:["With the workspace creator's Pro account, every member enjoys the privilege of accessing up to ",(0,t.jsx)("b",{children:"30 days"})," of version history."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(L.x6,{i18nKey:"com.arms.history.confirm-restore-modal.free-plan-prompt.description",children:["With the workspace creator's Free account, every member can access up to ",(0,t.jsx)("b",{children:"7 days"})," of version history."]}),o?(0,t.jsx)("span",{className:"_9fbys5y",onClick:d,children:m["com.arms.history.confirm-restore-modal.pro-plan-prompt.upgrade"]()}):null]}),[o,s,d,m]);return n?null:(0,t.jsx)("div",{className:"_9fbys5v",children:(0,t.jsxs)("div",{className:"_9fbys5w",children:[p,u]})})},ey=({historyList:e,onLoadMore:a,loadingMore:s,activeVersion:o,onVersionChange:i})=>{let n=(0,L.s9)(),l=(0,w.useMemo)(()=>ed(e),[e]),[c,d]=(0,w.useState)({});return(0,w.useLayoutEffect)(()=>{e.length>0&&!o&&i(e[0].timestamp)},[o,e,i]),(0,t.jsxs)("div",{className:"_9fbys5f",children:[(0,t.jsx)("div",{className:"_9fbys5i",children:n["com.arms.history.version-history"]()}),(0,t.jsxs)(r.yE.Root,{className:"_9fbys5g",children:[(0,t.jsxs)(r.yE.Viewport,{className:"_9fbys5h",children:[(0,t.jsx)(ej,{}),l.map(([e,a],s)=>{let r=c[s];return(0,t.jsxs)(R.bL,{open:!r,className:"_9fbys5j",children:[(0,t.jsxs)(R.l9,{role:"button",onClick:()=>d(e=>({...e,[s]:!r})),className:"_9fbys5k",children:[(0,t.jsx)("div",{"data-testid":"page-list-group-header-collapsed-button",className:"_9fbys5u",children:(0,t.jsx)(h.ToggleCollapseIcon,{className:"_9fbys5t","data-collapsed":!!r})}),e]}),(0,t.jsx)(R.UC,{children:a.map((e,s)=>(0,t.jsxs)(w.Fragment,{children:[(0,t.jsx)("div",{className:"_9fbys5l _9fbys5d","data-testid":"version-history-item",onClick:a=>{a.stopPropagation(),i(e.timestamp)},"data-active":o===e.timestamp,children:(0,t.jsx)("button",{children:(0,L.U$)(e.timestamp,{absolute:{noDate:!0,accuracy:"minute"}})})}),s>a.length-1?(0,t.jsx)("div",{className:"_9fbys5m _9fbys5d"}):null]},e.timestamp))})]},e)}),a?(0,t.jsx)(S.$n,{variant:"plain",loading:s,disabled:s,className:"_9fbys5n _9fbys5l _9fbys5d",onClick:a,children:n["com.arms.history.confirm-restore-modal.load-more"]()}):null]}),(0,t.jsx)(r.yE.Scrollbar,{})]})]})},ev=()=>{let e=(0,L.s9)();return(0,t.jsxs)("div",{className:"_9fbys5q","data-testid":"empty-history-prompt",children:[(0,t.jsx)(ep,{}),(0,t.jsx)("div",{className:"_9fbys5r",children:e["com.arms.history.empty-prompt.title"]()}),(0,t.jsx)("div",{className:"_9fbys5s",children:e["com.arms.history.empty-prompt.description"]()})]})},eb=({docCollection:e,pageId:a,onClose:s})=>{let r=e.id,[o,i]=(0,w.useState)(),n=(0,w.useMemo)(()=>e.getDoc(a)?.spaceDoc.guid??a,[a,e]),{openConfirmModal:l}=(0,N.fl)(),c=ec(e,n,o),d=(0,L.s9)(),{onRestore:m,isMutating:p}=em(e,a),u=(0,w.useMemo)(()=>async()=>{if(!o||!c)return;let e=(0,U.encodeStateAsUpdate)(c.spaceDoc);await m(o,new Uint8Array(e)),s()},[o,s,m,c]),h=(0,x.h1)(g.s).doc,[f,j]=(0,w.useState)(h.mode$.value),y=P(e,a),v=(0,w.useCallback)(()=>{l({title:d["com.arms.history.restore-current-version"](),description:d["com.arms.history.confirm-restore-modal.hint"](),cancelText:d.Cancel(),contentOptions:{"data-testid":"confirm-restore-history-modal",style:{padding:"20px 26px"}},confirmText:d["com.arms.history.confirm-restore-modal.restore"](),confirmButtonOptions:{variant:"primary","data-testid":"confirm-restore-history-button"},onConfirm:u})},[u,l,d]),[b,k,C]=er(r,n);return(0,t.jsxs)("div",{className:"_9fbys54",children:[(0,t.jsxs)("div",{className:eu,"data-empty":!o,children:[(0,t.jsx)(ef,{ts:o,historyList:b,snapshotPage:c,mode:f,onModeChange:j,title:y}),(0,t.jsx)(ey,{historyList:b,onLoadMore:k,loadingMore:C,activeVersion:o,onVersionChange:i})]}),o?null:(0,t.jsx)("div",{className:eu,children:(0,t.jsx)(ev,{})}),(0,t.jsxs)("div",{className:"_9fbys5o",children:[(0,t.jsx)(S.$n,{onClick:s,children:d["com.arms.history.back-to-page"]()}),(0,t.jsx)("div",{className:"_9fbys5p"}),(0,t.jsx)(S.$n,{variant:"primary",onClick:v,disabled:p||!o,children:d["com.arms.history.restore-current-version"]()})]})]})},ek=({onOpenChange:e,open:a,pageId:s,docCollection:r})=>{let i=(0,w.useCallback)(()=>{e(!1)},[e]);return(0,t.jsx)(ex,{onOpenChange:e,open:a,children:(0,t.jsx)(w.Suspense,{fallback:(0,t.jsx)(o.a,{}),children:(0,t.jsx)(eb,{onClose:i,pageId:s,docCollection:r})})})},ew=()=>{let[{open:e,pageId:a},s]=(0,E.fp)(A),r=(0,x.h1)(j.j).workspace,o=(0,w.useCallback)(e=>{F.u4.$.docHistory.$[e?"open":"close"](),s(a=>({...a,open:e}))},[s]);return(0,t.jsx)(ek,{open:e,onOpenChange:o,pageId:a,docCollection:r.docCollection})};var eC=s(45609),e$=s(92781),eS=s(69628),eN=s(93965),eI=s(86639),eM="_2r0hpk3",eD="_2r0hpk4";let eE=()=>{let e=(0,x.h1)(j.j).workspace,a=e.docCollection,s=(0,x.h1)(g.s).doc,r=(0,L.s9)(),{appSettings:o}=(0,l.V)(),{jumpToSubPath:i}=(0,eS.P)(),{restoreFromTrash:n}=(0,e$._)(a),[c,d]=(0,w.useState)(!1),m=r["com.arms.cmdk.affine.editor.trash-footer-hint"](),p=(0,w.useCallback)(()=>{n(s.id),(0,eI.oR)(r["com.arms.toastMessage.restored"]({title:s.meta$.value.title||"Untitled"}))},[s.id,s.meta$.value.title,n,r]),u=(0,w.useCallback)(()=>{i(e.id,eN.Tk.ALL),a.removeDoc(s.id),(0,eI.oR)(r["com.arms.toastMessage.permanentlyDeleted"]())},[i,e.id,a,s.id,r]),f=(0,w.useCallback)(()=>{d(!0)},[]);return(0,t.jsxs)("div",{className:"_2r0hpk1","data-has-background":!o.clientBorder,children:[(0,t.jsx)("div",{className:"_2r0hpk2",children:m}),(0,t.jsxs)("div",{className:"_2r0hpk0",children:[(0,t.jsx)(S.$n,{tooltip:r["com.arms.trashOperation.restoreIt"](),"data-testid":"page-restore-button",variant:"primary",onClick:p,className:eM,prefix:(0,t.jsx)(h.ResetIcon,{}),prefixClassName:eD}),(0,t.jsx)(S.$n,{tooltip:r["com.arms.trashOperation.deletePermanently"](),variant:"error",onClick:f,className:eM,prefix:(0,t.jsx)(h.DeleteIcon,{}),prefixClassName:eD})]}),(0,t.jsx)(N.uo,{title:r["com.arms.trashOperation.delete.title"](),cancelText:r["com.arms.confirmModal.button.cancel"](),description:r["com.arms.trashOperation.delete.description"](),confirmText:r["com.arms.trashOperation.delete"](),confirmButtonOptions:{variant:"error"},open:c,onConfirm:u,onOpenChange:d})]})},e_=({show:e,onClose:a,message:s})=>e?(0,t.jsxs)("div",{className:"_57ftle0",children:[s,(0,t.jsx)("div",{className:"_57ftle1",onClick:a,children:(0,t.jsx)(h.CloseIcon,{className:"_57ftle2"})})]}):null;var eO=s(99971);let eP=({onClose:e,isLoggedIn:a,onLogin:s,onEnableCloud:r})=>{let o=(0,L.s9)(),i=a?o["Enable AFFiNE Cloud"]():o["Sign in and Enable"](),n=(0,w.useCallback)(()=>a?r():s(),[a,r,s]);return(0,t.jsxs)("div",{className:"_57ftle3","data-testid":"local-demo-tips",children:[(0,t.jsx)("div",{className:"_57ftle4",children:o["com.arms.banner.local-warning"]()}),(0,t.jsxs)("div",{className:"_57ftle5",children:[(0,t.jsx)(S.$n,{style:{background:(0,eO.Vg)("white")},onClick:n,children:i}),(0,t.jsx)(S.K0,{onClick:e,size:"20","data-testid":"local-demo-tips-close-button",children:(0,t.jsx)(h.CloseIcon,{})})]})]})};var eF=s(21823),eT=s(38711),eB=s(59481);let eL=!environment.isDesktop&&!!environment.isBrowser&&(!!environment.isMobile||!!environment.isChrome&&environment.chromeVersion<106),eR=()=>{let e=(0,L.s9)(),a=environment.isBrowser&&!environment.isChrome,s=environment.isBrowser&&environment.isChrome&&environment.chromeVersion<106;return"isMobile"in environment&&environment.isMobile?(0,t.jsx)("span",{children:e["com.arms.top-tip.mobile"]()}):a?(0,t.jsx)("span",{children:(0,t.jsxs)(L.x6,{i18nKey:"recommendBrowser",children:["We recommend the ",(0,t.jsx)("strong",{children:"Chrome"})," browser for an optimal experience."]})}):s?(0,t.jsx)("span",{children:e.upgradeBrowser()}):null},eU=({pageId:e,workspace:a})=>{let s=(0,f.S)((0,x.h1)(eB.uR).session.status$),[r,o]=(0,w.useState)(eL),[i,n]=(0,w.useState)(!0),l=(0,eT.K)(),c=(0,E.Xr)(I.W7),d=(0,w.useCallback)(()=>{c({openModal:!0,state:"signIn"})},[c]);return i&&!environment.isDesktop&&a.flavour===eF.j.LOCAL?(0,t.jsx)(eP,{isLoggedIn:"authenticated"===s,onLogin:d,onEnableCloud:()=>l(a,{openPageId:e}),onClose:()=>{n(!1)}}):(0,t.jsx)(e_,{show:r,message:(0,t.jsx)(eR,{}),onClose:()=>{o(!1)}})};var eA=s(16439),eY=s(37272),eV=s(81427),eX=s(30397);async function ez({page:e,type:a}){let s=document.querySelector("editor-host"),t=null;switch(s&&(t=s.spec.getService("affine:page")),F.u4.$.sharePanel.$.export({type:a}),a){case"html":await p.FZ8.exportDoc(e);break;case"markdown":await p.TG.exportDoc(e);break;case"pdf":if(environment.isDesktop&&e.meta?.mode==="page")await eV.Ok?.export.savePDFFileAs(e.root.title.toString());else{if(!t)return;await t.exportManager.exportPdf()}break;case"png":if(!t)return;await t.exportManager.exportPng()}}let eW=e=>{let a=(0,E.Xr)(eY.$A),s=(0,E.Xr)(eY.p0),t=(0,L.s9)();return(0,w.useCallback)(async o=>{let i=(0,eX.Ak)();a({key:i});try{await ez({page:e,type:o}),r.me.success({title:t["com.arms.export.success.title"](),message:t["com.arms.export.success.message"]()})}catch(e){console.error(e),r.me.error({title:t["com.arms.export.error.title"](),message:t["com.arms.export.error.message"]()})}finally{s(i)}},[e,a,s,t])};var eH=s(80696),eZ=s(40274),eK=s(90039),eq=s(84064),eG=s(26582),eJ=s(78059),eQ=s(77562);let e0=e=>{let a=(0,L.s9)(),s=(0,x.h1)(eA.Mn),t=(0,f.S)(s.isFavorite$(e,"doc")),r=(0,w.useCallback)(()=>{s.toggle(e,"doc"),(0,eI.oR)(t?a["com.arms.toastMessage.removedFavorites"]():a["com.arms.toastMessage.addedFavorites"]())},[t,e,a,s]);return{favorite:t,toggleFavorite:r}},e1=({pageId:e})=>{let{favorite:a,toggleFavorite:s}=e0(e),r=(0,w.useCallback)(()=>{F.u4.$.header.actions.toggleFavorite(),s()},[s]);return(0,t.jsx)(eQ.f6,{"data-testid":"pin-button",active:!!a,onClick:r})},e9=()=>{let e=(0,E.Xr)(I.hX),a=(0,L.s9)(),s=(0,w.useCallback)(()=>{F.u4.$.header.actions.openDocInfo(),e(!0)},[e]);return(0,t.jsx)(r.K0,{size:"20",tooltip:a["com.arms.page-properties.page-info.view"](),"data-testid":"header-info-button",onClick:s,children:(0,t.jsx)(h.InformationIcon,{})})};var e4=s(94343),e8=s.n(e4);let e5={maxWidth:800,width:"100%"},e3=({docCollection:e,page:a})=>{let s=(0,w.useRef)(null),{journalDate:o}=(0,_.Bn)(e,a.id),{openJournal:i}=(0,_.mM)(e),[n,l]=(0,w.useState)((o??e8()()).format("YYYY-MM-DD"));return(0,w.useEffect)(()=>{o&&(l(o.format("YYYY-MM-DD")),s.current?.setCursor?.(o))},[o]),(0,t.jsx)(r.bC,{handleRef:s,style:e5,value:n,onChange:i})},e7=({docCollection:e})=>{let a=(0,L.s9)(),s=(0,_.mM)(e),o=(0,w.useCallback)(()=>{s.openToday()},[s]);return(0,t.jsx)(r.$n,{size:"default",onClick:o,style:{height:32,padding:"0px 8px"},children:a["com.arms.today"]()})};var e2=s(14277),e6=s(63035),ae=s(8055),aa="_1yta8g3b",as="_1yta8g33",at="_1yta8g32",ar="_1yta8g31",ao="_1yta8g3c",ai="_1yta8g39",an=s(796);let al=({workspaceId:e,pageId:a,urlType:s,blockId:t})=>{let r=(0,an.T)();if(!r)return null;try{return new URL(`${r}/${s}/${e}/${a}${"workspace"===s&&t?`#${t}`:""}`).toString()}catch(e){return null}},ac=({workspaceId:e,pageId:a,urlType:s})=>{let t=(0,L.s9)(),[o,i]=(0,w.useState)(""),[n]=(0,eZ.U)(),l=(0,w.useMemo)(()=>al({workspaceId:e,pageId:a,urlType:s,blockId:o.length>0?o:void 0}),[e,a,s,o]),c=(0,w.useCallback)(()=>{l?(navigator.clipboard.writeText(l).then(()=>{r.me.success({title:t["Copied link to clipboard"]()})}).catch(e=>{console.error(e)}),F.u4.$.sharePanel.$.copyShareLink({type:"share"===s?"public":"private"})):r.me.error({title:"Network not available"})},[l,t,s]);return(0,w.useEffect)(()=>{let e=null,a=n?.host?.selection;if("workspace"!==s||!a)return;let t=a.find("block");return t&&i(`#${t.blockId}`),e=a.slots.changed.on(e=>{i(a=>e[0]&&"block"===e[0].type?`#${e[0].blockId}`:a.length>0?"":a)}),()=>{e?.dispose()}},[n?.host?.selection,s]),{sharingUrl:l,onClickCopyLink:c}},ad=({workspaceMetadata:e,currentPage:a})=>{let s=(0,L.s9)(),o=(0,x.h1)(g.s).doc,{sharingUrl:i,onClickCopyLink:n}=ac({workspaceId:e.id,pageId:a.id,urlType:"workspace"}),l=eW(a),c=(0,f.S)(o.mode$),d=environment.isBrowser&&environment.isMacOs;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:ai,children:s["com.arms.share-menu.ShareViaExport"]()}),(0,t.jsx)("div",{className:as,children:s["com.arms.share-menu.ShareViaExportDescription"]()}),(0,t.jsx)("div",{children:(0,t.jsx)(eQ.uw,{exportHandler:l,className:at,pageMode:c})}),e.flavour!==eF.j.LOCAL?(0,t.jsxs)("div",{className:aa,children:[(0,t.jsx)(e6.c,{size:"thinner"}),(0,t.jsx)("div",{className:ai,children:s["com.arms.share-menu.share-privately"]()}),(0,t.jsx)("div",{className:as,children:s["com.arms.share-menu.share-privately.description"]()}),(0,t.jsx)("div",{children:(0,t.jsx)(r.Dr,{className:"_1yta8g3j",onSelect:n,block:!0,disabled:!i,preFix:(0,t.jsx)(r.ZB,{children:(0,t.jsx)(h.CopyIcon,{fontSize:16})}),endFix:(0,t.jsx)("div",{className:"_1yta8g3l",children:d?"⌘ + ⌥ + C":"Ctrl + Shift + C"}),children:s["com.arms.share-menu.copy-private-link"]()})})]}):null]})};var am=s(20464),ap=s(4285),au=s(53216),ah=s(31523),ax=s(7776);let af=e=>{let a=(0,L.s9)();return(0,t.jsxs)("div",{className:"_1yta8g3g",children:[(0,t.jsxs)("div",{className:aa,style:{gap:"12px"},children:[(0,t.jsx)("div",{className:as,style:{maxWidth:"230px"},children:a["com.arms.share-menu.EnableCloudDescription"]()}),(0,t.jsx)("div",{children:(0,t.jsx)(S.$n,{onClick:e.onEnableAffineCloud,variant:"primary","data-testid":"share-menu-enable-affine-cloud-button",children:a["Enable AFFiNE Cloud"]()})})]}),(0,t.jsx)("div",{className:"_1yta8g3h",children:(0,t.jsx)(ax.u,{})})]})},ag=e=>{let{workspaceMetadata:{id:a}}=e,s=(0,x.h1)(g.s).doc,o=(0,x.h1)(ae.Dw),i=(0,x.h1)(eB.BB).serverConfig;(0,w.useEffect)(()=>{o.share.revalidate()},[o]);let n=(0,f.S)(o.share.isShared$),l=(0,f.S)(o.share.sharedMode$),c=(0,f.S)(i.config$.map(e=>e?.baseUrl)),d=null===n||null===l||null===c,[m,p]=(0,w.useState)(!1),u=(0,f.S)(s.mode$),j=(0,w.useMemo)(()=>n&&l?l.toLowerCase():u,[u,n,l]),{sharingUrl:y,onClickCopyLink:v}=ac({workspaceId:a,pageId:s.id,urlType:"share"}),b=(0,L.s9)(),k=(0,w.useMemo)(()=>[{value:"page",label:b["com.arms.pageMode.page"]()},{value:"edgeless",label:b["com.arms.pageMode.edgeless"]()}],[b]),C=(0,ap.V)(async()=>{try{await o.share.enableShare("edgeless"===j?au.Yh.Edgeless:au.Yh.Page),F.u4.$.sharePanel.$.createShareLink({mode:j}),r.me.success({title:b["com.arms.share-menu.create-public-link.notification.success.title"](),message:b["com.arms.share-menu.create-public-link.notification.success.message"](),style:"normal",icon:(0,t.jsx)(h.SingleSelectSelectSolidIcon,{color:(0,eO.Vg)("primaryColor")})}),y&&navigator.clipboard.writeText(y).catch(e=>{console.error(e)})}catch(e){r.me.error({title:b["com.arms.share-menu.confirm-modify-mode.notification.fail.title"](),message:b["com.arms.share-menu.confirm-modify-mode.notification.fail.message"]()}),console.error(e)}},[j,o.share,y,b]),$=(0,ap.V)(async()=>{try{await o.share.disableShare(),r.me.error({title:b["com.arms.share-menu.disable-publish-link.notification.success.title"](),message:b["com.arms.share-menu.disable-publish-link.notification.success.message"]()})}catch(e){r.me.error({title:b["com.arms.share-menu.disable-publish-link.notification.fail.title"](),message:b["com.arms.share-menu.disable-publish-link.notification.fail.message"]()}),console.log(e)}p(!1)},[o,b]),N=(0,ap.V)(async e=>{try{n&&(await o.share.changeShare("edgeless"===e?au.Yh.Edgeless:au.Yh.Page),r.me.success({title:b["com.arms.share-menu.confirm-modify-mode.notification.success.title"](),message:b["com.arms.share-menu.confirm-modify-mode.notification.success.message"]({preMode:"edgeless"===e?b.Page():b.Edgeless(),currentMode:"edgeless"===e?b.Edgeless():b.Page()}),style:"normal",icon:(0,t.jsx)(h.SingleSelectSelectSolidIcon,{color:(0,eO.Vg)("primaryColor")})}))}catch(e){r.me.error({title:b["com.arms.share-menu.confirm-modify-mode.notification.fail.title"](),message:b["com.arms.share-menu.confirm-modify-mode.notification.fail.message"]()}),console.error(e)}},[n,o.share,b]);return d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.EA,{height:100}),(0,t.jsx)(r.EA,{height:40})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:ai,children:b["com.arms.share-menu.publish-to-web"]()}),(0,t.jsx)("div",{className:aa,children:(0,t.jsx)("div",{className:as,children:b["com.arms.share-menu.publish-to-web.description"]()})}),(0,t.jsxs)("div",{className:ao,children:[(0,t.jsx)(r.pd,{inputStyle:{color:"var(--affine-text-secondary-color)",fontSize:"var(--affine-font-xs)",lineHeight:"20px"},value:n&&y||`${c}/...`,readOnly:!0}),n?(0,t.jsx)(S.$n,{onClick:v,"data-testid":"share-menu-copy-link-button",style:{padding:"4px 12px",whiteSpace:"nowrap"},disabled:!y,children:b.Copy()}):(0,t.jsx)(S.$n,{onClick:C,variant:"primary","data-testid":"share-menu-create-link-button",style:{padding:"4px 12px",whiteSpace:"nowrap"},children:b.Create()})]}),(0,t.jsxs)("div",{className:ao,children:[(0,t.jsx)("div",{className:"_1yta8g3a",children:b["com.arms.share-menu.ShareMode"]()}),(0,t.jsx)("div",{children:(0,t.jsx)(r.z6,{className:"_1yta8g3d",value:j,onChange:N,items:k})})]}),n?(0,t.jsxs)(t.Fragment,{children:[!1,(0,t.jsx)(e2.Dr,{endFix:(0,t.jsx)(h.ArrowRightSmallIcon,{}),block:!0,type:"danger",className:at,onSelect:e=>{e.preventDefault(),p(!0)},children:(0,t.jsx)("div",{className:"_1yta8g3f",children:b["Disable Public Link"]()})}),(0,t.jsx)(am.r,{open:m,onConfirm:$,onOpenChange:p})]}):null]})},aj=e=>{if(e.workspaceMetadata.flavour===eF.j.LOCAL)return(0,t.jsx)(af,{...e});if(e.workspaceMetadata.flavour===eF.j.AFFINE_CLOUD)return(0,t.jsx)(ah.tH,{fallback:null,children:(0,t.jsx)(w.Suspense,{children:(0,t.jsx)(ag,{...e})})});throw Error("Unreachable")},ay=e=>{let a=(0,L.s9)();return(0,t.jsxs)("div",{className:"_1yta8g36",children:[(0,t.jsxs)("div",{className:"_1yta8g30",children:[(0,t.jsx)("div",{className:"_1yta8g3i",children:(0,t.jsx)(h.WebIcon,{})}),a["com.arms.share-menu.SharePage"]()]}),(0,t.jsx)(aj,{...e}),(0,t.jsx)("div",{className:aa,children:(0,t.jsx)(e6.c,{size:"thinner"})}),(0,t.jsx)(ad,{...e})]})},av=(0,w.forwardRef)(function(e,a){let s=(0,L.s9)(),r=(0,x.h1)(ae.Dw),o=(0,f.S)(r.share.isShared$);return(0,w.useEffect)(()=>{r.share.revalidate()},[r]),(0,t.jsx)(S.$n,{ref:a,className:"_1yta8g3k",variant:"primary",children:o?s["com.arms.share-menu.sharedButton"]():s["com.arms.share-menu.shareButton"]()})}),ab=e=>(0,t.jsx)(e2.W1,{items:(0,t.jsx)(ay,{...e}),contentOptions:{className:ar,"data-testid":"local-share-menu"},rootOptions:{modal:!1,onOpenChange:e.onOpenShareModal},children:(0,t.jsx)("div",{"data-testid":"local-share-menu-button",children:e.children||(0,t.jsx)(av,{})})}),ak=e=>(0,t.jsx)(e2.W1,{items:(0,t.jsx)(ay,{...e}),contentOptions:{className:ar,"data-testid":"cloud-share-menu"},rootOptions:{modal:!1,onOpenChange:e.onOpenShareModal},children:(0,t.jsx)("div",{"data-testid":"cloud-share-menu-button",children:e.children||(0,t.jsx)(av,{})})}),aw=e=>{let{workspaceMetadata:a}=e;return a.flavour===eF.j.LOCAL?(0,t.jsx)(ab,{...e}):(0,t.jsx)(ak,{...e})};var aC=s(69992);let a$=e=>{let a=(0,f.S)((0,x.h1)(g.s).doc.mode$),s=(0,x.h1)(eq.TR).workbench,t=(0,aC.s)(),r=(0,f.S)(s.views$.map(e=>e.length)),o=(0,f.S)(s.sidebarOpen$),i=e<500||r>1,n=e<400||"edgeless"!==a,l=t.isLast&&!o&&!(n&&i)&&!environment.isDesktop;return{hideShare:i,hidePresent:n,hideCollect:e<300,hideToday:e<300,showDivider:l}},aS=(0,w.forwardRef)((e,a)=>(0,t.jsx)(S.K0,{ref:a,...e,"data-testid":"header-dropDownButton",className:"_14uy6a10",children:(0,t.jsx)(h.MoreHorizontalIcon,{})}));aS.displayName="HeaderDropDownButton";var aN=s(26605);let aI=({rename:e,page:a,isJournal:s,containerWidth:r})=>{let o=a?.id,i=(0,L.s9)(),{hideShare:n}=a$(r),l=(0,eT.K)(),c=(0,x.h1)(j.j).workspace,d=c.docCollection,p=(0,x.h1)(g.s).doc,u=(0,f.S)(p.meta$.map(e=>e.trash)),y=(0,f.S)(p.mode$),v=(0,x.h1)(eq.TR).workbench,{favorite:b,toggleFavorite:k}=e0(o),{duplicate:C}=(0,e$._)(d),{importFile:$}=(0,aN.z)(d),{setTrashModal:S}=(0,eH.T)(d),N=(0,x.h1)(m.z).view,M=(0,w.useCallback)(e=>{v.openSidebar(),N.activeSidebarTab(e)},[v,N]),D=(0,w.useCallback)(()=>{M("frame")},[M]),_=(0,w.useCallback)(()=>{M("outline")},[M]),[O,P]=(0,w.useState)(!1),T=(0,E.Xr)(I.Jr),B=(0,w.useCallback)(()=>(F.u4.$.header.history.open(),c.flavour===eF.j.AFFINE_CLOUD)?P(!0):T(!0),[T,c.flavour]),R=(0,E.Xr)(I.hX),U=(0,w.useCallback)(()=>{F.u4.$.header.pageInfo.open(),R(!0)},[R]),A=(0,w.useCallback)(()=>{v.openDoc(o,{at:"new-tab"})},[o,v]),Y=(0,w.useCallback)(()=>{v.openDoc(o,{at:"tail"})},[o,v]),V=(0,w.useCallback)(()=>{F.u4.$.header.docOptions.deleteDoc(),S({open:!0,pageIds:[o],pageTitles:[p.meta$.value.title??""]})},[p.meta$.value.title,o,S]),X=(0,w.useCallback)(()=>{e?.(),F.u4.$.header.docOptions.renameDoc()},[e]),z={padding:"4px 12px",transition:"all 0.3s"},W=(0,w.useCallback)(e=>{e&&F.u4.$.header.docOptions.open()},[]),H=eW(p.blockSuiteDoc),Z=(0,w.useCallback)(()=>{C(o),F.u4.$.header.docOptions.createDoc({control:"duplicate"})},[C,o]),K=(0,ap.V)(async()=>{let e=await $();F.u4.$.header.docOptions.import(),e.isWorkspaceFile?F.u4.$.header.actions.createWorkspace({control:"import"}):F.u4.$.header.actions.createDoc({control:"import"})},[$]),q=(0,w.useCallback)(e=>{e&&F.u4.$.sharePanel.$.open()},[]),G=(0,w.useCallback)(()=>{F.u4.$.header.docOptions.toggleFavorite(),k()},[k]),J=(0,t.jsxs)(t.Fragment,{children:[n?(0,t.jsx)(e2.aC,{subContentOptions:{sideOffset:12,alignOffset:-8},items:(0,t.jsx)("div",{style:{padding:4},children:(0,t.jsx)(ay,{workspaceMetadata:c.meta,currentPage:a,onEnableAffineCloud:()=>l(c,{openPageId:a.id})})}),triggerOptions:{preFix:(0,t.jsx)(e2.ZB,{children:(0,t.jsx)(h.ShareIcon,{})})},subOptions:{onOpenChange:q},children:i["com.arms.share-menu.shareButton"]()}):null,(0,t.jsx)(e2.bX,{})]}),Q=(0,t.jsxs)(t.Fragment,{children:[n?J:null,!s&&(0,t.jsx)(e2.Dr,{preFix:(0,t.jsx)(e2.ZB,{children:(0,t.jsx)(h.EditIcon,{})}),"data-testid":"editor-option-menu-rename",onSelect:X,style:z,children:i.Rename()}),(0,t.jsx)(e2.Dr,{"data-testid":"editor-option-menu-favorite",onSelect:G,style:z,preFix:(0,t.jsx)(e2.ZB,{children:b?(0,t.jsx)(h.FavoritedIcon,{style:{color:"var(--affine-primary-color)"}}):(0,t.jsx)(h.FavoriteIcon,{})}),children:b?i["com.arms.favoritePageOperation.remove"]():i["com.arms.favoritePageOperation.add"]()}),(0,t.jsx)(e2.bX,{}),(0,t.jsx)(e2.Dr,{preFix:(0,t.jsx)(e2.ZB,{children:(0,t.jsx)(h.OpenInNewIcon,{})}),"data-testid":"editor-option-menu-open-in-new-tab",onSelect:A,style:z,children:i["com.arms.workbench.tab.page-menu-open"]()}),environment.isDesktop&&(0,t.jsx)(e2.Dr,{preFix:(0,t.jsx)(e2.ZB,{children:(0,t.jsx)(h.SplitViewIcon,{})}),"data-testid":"editor-option-menu-open-in-split-new",onSelect:Y,style:z,children:i["com.arms.workbench.split-view.page-menu-open"]()}),(0,t.jsx)(e2.bX,{}),(0,t.jsx)(e2.Dr,{preFix:(0,t.jsx)(e2.ZB,{children:(0,t.jsx)(h.InformationIcon,{})}),"data-testid":"editor-option-menu-info",onSelect:U,style:z,children:i["com.arms.page-properties.page-info.view"]()}),"page"===y?(0,t.jsx)(e2.Dr,{preFix:(0,t.jsx)(e2.ZB,{children:(0,t.jsx)(h.TocIcon,{})}),"data-testid":"editor-option-toc",onSelect:_,style:z,children:i["com.arms.header.option.view-toc"]()}):(0,t.jsx)(e2.Dr,{preFix:(0,t.jsx)(e2.ZB,{children:(0,t.jsx)(h.FrameIcon,{})}),"data-testid":"editor-option-frame",onSelect:D,style:z,children:i["com.arms.header.option.view-frame"]()}),(0,t.jsx)(e2.Dr,{preFix:(0,t.jsx)(e2.ZB,{children:(0,t.jsx)(h.HistoryIcon,{})}),"data-testid":"editor-option-menu-history",onSelect:B,style:z,children:i["com.arms.history.view-history-version"]()}),(0,t.jsx)(e2.bX,{}),!s&&(0,t.jsx)(e2.Dr,{preFix:(0,t.jsx)(e2.ZB,{children:(0,t.jsx)(h.DuplicateIcon,{})}),"data-testid":"editor-option-menu-duplicate",onSelect:Z,style:z,children:i["com.arms.header.option.duplicate"]()}),(0,t.jsx)(e2.Dr,{preFix:(0,t.jsx)(e2.ZB,{children:(0,t.jsx)(h.ImportIcon,{})}),"data-testid":"editor-option-menu-import",onSelect:K,style:z,children:i.Import()}),(0,t.jsx)(eQ.FN,{exportHandler:H,pageMode:y}),(0,t.jsx)(e2.bX,{}),(0,t.jsx)(eQ.fB,{"data-testid":"editor-option-menu-delete",onSelect:V})]});return u?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e2.W1,{items:Q,contentOptions:{align:"center"},rootOptions:{onOpenChange:W},children:(0,t.jsx)(aS,{})}),c.flavour===eF.j.AFFINE_CLOUD?(0,t.jsx)(ek,{docCollection:c.docCollection,open:O,pageId:o,onOpenChange:P}):null]})};var aM=s(39840);let aD=()=>{let{isPresent:e,handlePresent:a}=(0,aM.D)();return(0,t.jsx)(r.K0,{style:{flexShrink:0},size:"24",onClick:()=>a(!e),children:(0,t.jsx)(h.PresentationIcon,{})})},aE=({workspace:e,page:a})=>{let s=(0,eT.K)(),r=(0,w.useCallback)(e=>{e&&F.u4.$.sharePanel.$.open()},[]);return(0,t.jsx)(aw,{workspaceMetadata:e.meta,currentPage:a,onEnableAffineCloud:()=>s(e,{openPageId:a.id}),onOpenShareModal:r})};var a_=s(5445),aO=s(75806),aP=s(65423),aF="_198gvz10";let aT=(0,w.forwardRef)(({children:e,style:a,className:s},r)=>{let o=(0,E.md)(a_.XK);return(0,t.jsx)("div",{"data-testid":"header",style:a,className:s,ref:r,"data-sidebar-floating":o,children:e})});function aB({page:e,workspace:a}){let s=(0,w.useRef)(null),[o,i]=(0,w.useState)(0);(0,w.useEffect)(()=>{let e=s.current;if(e)return(0,r.vy)(e,e=>{i(e.contentRect.width)})},[]);let{hideShare:n,hideToday:l}=a$(o),c=P(a.docCollection,e?.id);return(0,t.jsxs)(aT,{className:aF,ref:s,children:[(0,t.jsx)(eq.EY,{title:c}),(0,t.jsx)(eq.tC,{icon:"journal"}),(0,t.jsx)("div",{className:"_198gvz12",children:(0,t.jsx)(e3,{docCollection:a.docCollection,page:e})}),l?null:(0,t.jsx)(e7,{docCollection:a.docCollection}),(0,t.jsx)(aP.L,{}),(0,t.jsx)(aI,{isJournal:!0,page:e,containerWidth:o}),e&&!n?(0,t.jsx)(aE,{workspace:a,page:e}):null]})}function aL({page:e,workspace:a}){let s=(0,w.useRef)(null),o=(0,w.useRef)(null),[i,n]=(0,w.useState)(0);(0,w.useEffect)(()=>{let e=o.current;if(e)return(0,r.vy)(e,e=>{n(e.contentRect.width)})},[]);let{hideCollect:l,hideShare:c,hidePresent:d,showDivider:m}=a$(i),p=(0,w.useCallback)(()=>{setTimeout(()=>s.current?.triggerEdit())},[]),u=P(a.docCollection,e?.id),h=(0,x.h1)(g.s).doc,j=(0,f.S)(h.mode$),y=(0,w.useCallback)(()=>{F.u4.$.header.actions.renameDoc()},[]);return(0,t.jsxs)(aT,{className:aF,ref:o,children:[(0,t.jsx)(eq.EY,{title:u}),(0,t.jsx)(eq.tC,{icon:j??"page"}),(0,t.jsx)(aO.b,{inputHandleRef:s,pageId:e?.id,docCollection:a.docCollection,onEditSave:y}),(0,t.jsxs)("div",{className:"_198gvz13",children:[l?null:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(e1,{pageId:e?.id}),(0,t.jsx)(e9,{})]}),(0,t.jsx)(aI,{rename:p,page:e,containerWidth:i})]}),(0,t.jsx)("div",{className:"_198gvz11"}),d?null:(0,t.jsx)(aD,{}),e&&!c?(0,t.jsx)(aE,{workspace:a,page:e}):null,m?(0,t.jsx)(r.cG,{orientation:"vertical",style:{height:20,marginLeft:4}}):null]})}function aR(e){let{page:a,workspace:s}=e,{isJournal:r}=(0,_.Bn)(a.collection,a.id),o=a.meta?.trash,[i,n]=(0,E.fp)(I.hX);return!function({workspaceMeta:e,docId:a}){let s=(0,eq.Tq)(),t=e.id,r=e.flavour===eF.j.AFFINE_CLOUD,{onClickCopyLink:o}=ac({workspaceId:t,pageId:a,urlType:"workspace"});(0,w.useEffect)(()=>{let e=[];return e.push((0,V.uu)({id:`affine:share-private-link:${a}`,category:"affine:general",preconditionStrategy:V.ON.Never,keyBinding:{binding:"$mod+Shift+c"},label:"",icon:null,run(){F.u4.$.cmdk.general.copyShareLink({type:"private"}),s&&r&&o()}})),()=>{e.forEach(e=>e())}},[a,s,r,o])}({workspaceMeta:s.meta,docId:a.id}),(0,t.jsxs)(t.Fragment,{children:[r&&!o?(0,t.jsx)(aB,{...e}):(0,t.jsx)(aL,{...e}),(0,t.jsx)(eJ.Wh,{open:i,onOpenChange:n,docId:a.id})]})}aT.displayName="forwardRef(Header)";var aU=s(50822),aA="uiyc497";let aY=({count:e,max:a=99,...s})=>(0,t.jsx)("span",{...s,children:e>a?`${a}+`:e}),aV=({docRecord:e,right:a,className:s,...r})=>{let o=(0,f.S)(e.mode$),i=(0,x.h1)(j.j).workspace,n=P(i.docCollection,e.id),{isJournal:l}=(0,_.Bn)(i.docCollection,e.id),c=l?h.TodayIcon:"edgeless"===o?h.EdgelessIcon:h.PageIcon;return(0,t.jsxs)(eq.Sj,{"aria-label":n,to:`/${e.id}`,className:(0,k.A)(s,"uiyc49a uiyc490"),...r,children:[(0,t.jsx)("div",{className:"uiyc49b",children:(0,t.jsx)(c,{width:20,height:20})}),(0,t.jsx)("span",{className:"uiyc49c",children:n}),a]})},aX=()=>{let e=(0,L.s9)(),a=(0,x.h1)(g.s).doc,s=(0,x.h1)(j.j).workspace,{journalDate:o,isJournal:i}=(0,_.Bn)(s.docCollection,a.id),{openJournal:n}=(0,_.mM)(s.docCollection),[l,c]=(0,w.useState)(e8()().format("YYYY-MM-DD"));(0,w.useEffect)(()=>{o&&c(o.format("YYYY-MM-DD"))},[o]);let d=(0,w.useCallback)(e=>{o&&e8()(e).isSame(e8()(o))||n(e)},[o,n]),m=(0,w.useCallback)(e=>(0,t.jsxs)("button",{className:"uiyc49g uiyc490","data-is-date-cell":!0,tabIndex:e.focused?0:-1,"data-is-today":e.isToday,"data-not-current-month":e.notCurrentMonth,"data-selected":e.selected,"data-is-journal":i,"data-has-journal":!1,children:[e.label,null]}),[i]);return(0,t.jsxs)("div",{className:"uiyc492","data-is-journal":i,children:[(0,t.jsx)("div",{className:"uiyc491",children:(0,t.jsx)(r.lr,{weekDays:e["com.arms.calendar-date-picker.week-days"](),monthNames:e["com.arms.calendar-date-picker.month-names"](),todayLabel:e["com.arms.calendar-date-picker.today"](),customDayRenderer:m,value:l,onChange:d})}),(0,t.jsx)(aK,{date:e8()(l)}),(0,t.jsx)(aH,{date:e8()(l)})]})},az=(e,a,s="desc")=>[...e].sort((e,t)=>("asc"===s?1:-1)*e8()(t.meta$.value[a]).diff(e8()(e.meta$.value[a]))),aW=({name:e})=>{let a=(0,L.s9)();return(0,t.jsx)("div",{className:"uiyc499",children:"createdToday"===e?a["com.arms.journal.daily-count-created-empty-tips"]():a["com.arms.journal.daily-count-updated-empty-tips"]()})},aH=({date:e})=>{let a=(0,w.useRef)(null),s=(0,L.s9)(),[o,i]=(0,w.useState)("createdToday"),n=(0,f.S)((0,x.h1)(b.F).list.docs$),l=(0,w.useCallback)(a=>az(n.filter(s=>{let t=s.meta$.value;return!t.trash&&t[a]&&e8()(t[a]).isSame(e,"day")}),a),[e,n]),c=(0,w.useMemo)(()=>l("createDate"),[l]),d=(0,w.useMemo)(()=>l("updatedDate"),[l]),m=(0,w.useMemo)(()=>[{name:"createdToday",label:s["com.arms.journal.created-today"](),count:c.length},{name:"updatedToday",label:s["com.arms.journal.updated-today"](),count:d.length}],[c.length,s,d.length]),p=m.findIndex(({name:e})=>e===o),u=(0,aU.D)({"--active-index":String(p),"--item-count":String(m.length)});return(0,t.jsxs)("div",{className:"uiyc493",style:u,children:[(0,t.jsx)("header",{className:"uiyc494",children:m.map(({label:e,count:a,name:s},r)=>(0,t.jsxs)("button",{onClick:()=>i(s),"aria-selected":o===s,className:"uiyc495 uiyc490",children:[e," ",(0,t.jsx)(aY,{count:a})]},r))}),(0,t.jsx)("main",{className:"uiyc496","data-active":o,children:m.map(({name:e})=>{let s="createdToday"===e?c:d;return 0===s.length?(0,t.jsx)("div",{className:aA,children:(0,t.jsx)(aW,{name:e})},e):(0,t.jsxs)(r.yE.Root,{className:aA,children:[(0,t.jsx)(r.yE.Scrollbar,{}),(0,t.jsx)(r.yE.Viewport,{children:(0,t.jsx)("div",{className:"uiyc498",ref:a,children:s.map((a,s)=>(0,t.jsx)(aV,{tabIndex:e===o?0:-1,docRecord:a},s))})})]},e)})})]})},aZ=({docRecords:e,children:a,className:s,...o})=>{let i=(0,x.h1)(j.j).workspace,n=(0,x.h1)(g.s).doc,{setTrashModal:l}=(0,eH.T)(i.docCollection),c=(0,w.useCallback)(e=>{l({open:!0,pageIds:[e.id],pageTitles:[e.title$.value]})},[l]);return(0,t.jsxs)("div",{className:(0,k.A)("uiyc49e",s),...o,children:[e.map(e=>{let a=e.id===n.id;return(0,t.jsx)(aV,{"aria-selected":a,docRecord:e,right:(0,t.jsx)(r.W1,{items:(0,t.jsx)(eQ.fB,{onSelect:()=>c(e)}),children:(0,t.jsx)(r.K0,{children:(0,t.jsx)(h.MoreHorizontalIcon,{})})})},e.id)}),a]})},aK=({date:e})=>{let a=(0,L.s9)(),s=(0,x.h1)(j.j).workspace,o=(0,x.h1)(b.F).list,i=(0,_.lx)(s.docCollection).getJournalsByDate(e.format("YYYY-MM-DD")),n=(0,f.S)(o.docs$.map(e=>e.filter(e=>i.some(a=>a.id===e.id))));return i.length<=1?null:(0,t.jsx)(aZ,{className:"uiyc49d",docRecords:n.slice(0,5),children:i.length>5?(0,t.jsx)(r.W1,{items:(0,t.jsx)(aZ,{docRecords:n.slice(5)}),children:(0,t.jsx)("div",{className:"uiyc49f uiyc490",children:a["com.arms.journal.conflict-show-more"]({count:(n.length-5).toFixed(0)})})}):null})};var aq=s(52153);let aG=({editor:e})=>{let a=(0,w.useRef)(null),s=(0,w.useCallback)(e=>{if(e){if(null===a.current){console.error("outline panel should be initialized");return}e.append(a.current)}},[]);if(e)return a.current||(a.current=new aq.bP),e!==a.current?.editor&&(a.current.editor=e,a.current.fitPadding=[20,20,20,20]),(0,t.jsx)("div",{className:"_1je7lp20",ref:s})},aJ=(0,w.memo)(function(){let e=(0,x.h1)(eq.TR).workbench,a=(0,x.h1)(m.z).view,s=(0,f.S)(a.activeSidebarTab$),o=(0,x.h1)(g.s).doc,d=(0,f.S)(o.meta$.map(e=>e.trash)),{openPage:b,jumpToPageBlock:C,jumpToTag:S}=(0,eS.P)(),[N,M]=(0,w.useState)(null),D=(0,x.h1)(j.j).workspace,_=(0,x.h1)(y.q).globalContext,O=D.docCollection,P=(0,f.S)(o.mode$),T=(0,f.S)(e.sidebarOpen$),{appSettings:B}=(0,l.V)(),{setDocReadonly:R}=(0,c.B)(D.docCollection),U=(0,eq.Tq)(),[Y,X]=(0,eZ.U)();(0,w.useEffect)(()=>{U&&X(N)},[N,U,X]),(0,w.useEffect)(()=>{let s=i.uj.slots.requestOpenWithChat.on(()=>{e.openSidebar(),a.activeSidebarTab("journal")});return()=>s.dispose()},[s,a,e]),(0,w.useEffect)(()=>{if(U)return _.docId.set(o.id),_.isDoc.set(!0),()=>{_.docId.set(null),_.isDoc.set(!1)}},[o,_,U]),(0,w.useEffect)(()=>{if(U)return _.docMode.set(P),()=>{_.docMode.set(null)}},[o,_,U,P]),(0,w.useEffect)(()=>{"isMobile"in environment&&environment.isMobile&&R(o.id,!0)},[o.id,R]),(0,w.useEffect)(()=>{if(U)return _.isTrashDoc.set(!!d),()=>{_.isTrashDoc.set(null)}},[_,U,d]),function(){let e=(0,x.h1)(g.s).doc,a=e.id,s=(0,f.S)(e.mode$),o=(0,L.s9)(),i=(0,x.h1)(j.j).workspace,n=i.docCollection,l=(0,x.h1)(eA.Mn),c=(0,f.S)(l.isFavorite$(a,"doc")),d=(0,f.S)(e.trash$),m=(0,E.Xr)(A),p=(0,E.Xr)(I.hX),u=(0,w.useCallback)(()=>{m(()=>({pageId:a,open:!0}))},[a,m]),y=(0,w.useCallback)(()=>{p(!0)},[p]),{duplicate:v}=(0,e$._)(n),b=eW(e.blockSuiteDoc),{setTrashModal:k}=(0,eH.T)(n),C=(0,w.useCallback)(e=>{k({open:!0,pageIds:[a],pageTitles:[e]})},[a,k]),$=i.flavour===eF.j.AFFINE_CLOUD;(0,w.useEffect)(()=>{let i=[],n=()=>V.ON.InPaperOrEdgeless&&!d;return i.push((0,V.uu)({id:`editor:${s}-view-info`,preconditionStrategy:()=>V.ON.InPaperOrEdgeless&&!d&&!0,category:`editor:${s}`,icon:"page"===s?(0,t.jsx)(h.PageIcon,{}):(0,t.jsx)(h.EdgelessIcon,{}),label:o["com.arms.page-properties.page-info.view"](),run(){F.u4.$.cmdk.docInfo.open(),y()}})),i.push((0,V.uu)({id:`editor:${s}-${c?"remove-from":"add-to"}-favourites`,preconditionStrategy:n,category:`editor:${s}`,icon:"page"===s?(0,t.jsx)(h.PageIcon,{}):(0,t.jsx)(h.EdgelessIcon,{}),label:c?o["com.arms.favoritePageOperation.remove"]():o["com.arms.favoritePageOperation.add"](),run(){l.toggle(a,"doc"),F.u4.$.cmdk.editor.toggleFavorite(),(0,r.oR)(c?o["com.arms.cmdk.affine.editor.remove-from-favourites"]():o["com.arms.cmdk.affine.editor.add-to-favourites"]())}})),i.push((0,V.uu)({id:`editor:${s}-convert-to-${"page"===s?"edgeless":"page"}`,preconditionStrategy:n,category:`editor:${s}`,icon:"page"===s?(0,t.jsx)(h.PageIcon,{}):(0,t.jsx)(h.EdgelessIcon,{}),label:`${o["Convert to "]()}${"page"===s?o["com.arms.pageMode.edgeless"]():o["com.arms.pageMode.page"]()}`,run(){F.u4.$.cmdk.editor.switchPageMode({mode:"page"===s?"edgeless":"page"}),e.toggleMode(),(0,r.oR)("page"===s?o["com.arms.toastMessage.edgelessMode"]():o["com.arms.toastMessage.pageMode"]())}})),i.push((0,V.uu)({id:`editor:${s}-duplicate`,preconditionStrategy:n,category:`editor:${s}`,icon:"page"===s?(0,t.jsx)(h.PageIcon,{}):(0,t.jsx)(h.EdgelessIcon,{}),label:o["com.arms.header.option.duplicate"](),run(){v(a),F.u4.$.cmdk.editor.createDoc({control:"duplicate"})}})),i.push((0,V.uu)({id:`editor:${s}-export-to-pdf`,preconditionStrategy:()=>"page"===s&&!d,category:`editor:${s}`,icon:"page"===s?(0,t.jsx)(h.PageIcon,{}):(0,t.jsx)(h.EdgelessIcon,{}),label:o["Export to PDF"](),async run(){F.u4.$.cmdk.editor.export({type:"pdf"}),await b("pdf")}})),i.push((0,V.uu)({id:`editor:${s}-export-to-html`,preconditionStrategy:n,category:`editor:${s}`,icon:"page"===s?(0,t.jsx)(h.PageIcon,{}):(0,t.jsx)(h.EdgelessIcon,{}),label:o["Export to HTML"](),async run(){F.u4.$.cmdk.editor.export({type:"html"}),await b("html")}})),i.push((0,V.uu)({id:`editor:${s}-export-to-png`,preconditionStrategy:()=>"page"===s&&!d,category:`editor:${s}`,icon:"page"===s?(0,t.jsx)(h.PageIcon,{}):(0,t.jsx)(h.EdgelessIcon,{}),label:o["Export to PNG"](),async run(){F.u4.$.cmdk.editor.export({type:"png"}),await b("png")}})),i.push((0,V.uu)({id:`editor:${s}-export-to-markdown`,preconditionStrategy:n,category:`editor:${s}`,icon:"page"===s?(0,t.jsx)(h.PageIcon,{}):(0,t.jsx)(h.EdgelessIcon,{}),label:o["Export to Markdown"](),async run(){F.u4.$.cmdk.editor.export({type:"markdown"}),await b("markdown")}})),i.push((0,V.uu)({id:`editor:${s}-move-to-trash`,preconditionStrategy:n,category:`editor:${s}`,icon:"page"===s?(0,t.jsx)(h.PageIcon,{}):(0,t.jsx)(h.EdgelessIcon,{}),label:o["com.arms.moveToTrash.title"](),run(){F.u4.$.cmdk.editor.deleteDoc(),C(e.title$.value)}})),i.push((0,V.uu)({id:`editor:${s}-restore-from-trash`,preconditionStrategy:()=>V.ON.InPaperOrEdgeless&&d,category:`editor:${s}`,icon:"page"===s?(0,t.jsx)(h.PageIcon,{}):(0,t.jsx)(h.EdgelessIcon,{}),label:o["com.arms.cmdk.affine.editor.restore-from-trash"](),run(){F.u4.$.cmdk.editor.restoreDoc(),e.restoreFromTrash()}})),$&&i.push((0,V.uu)({id:`editor:${s}-page-history`,category:`editor:${s}`,icon:(0,t.jsx)(h.HistoryIcon,{}),label:o["com.arms.cmdk.affine.editor.reveal-page-history-modal"](),run(){F.u4.$.cmdk.docHistory.open(),u()}})),i.push((0,V.uu)({id:"alert-ctrl-s",category:"affine:general",preconditionStrategy:V.ON.Never,keyBinding:{binding:"$mod+s"},label:"",icon:null,run(){(0,r.oR)(o.Save())}})),()=>{i.forEach(e=>e())}},[c,s,C,b,o,d,$,u,v,l,a,e,y])}();let z=(0,f.S)(o.title$);(0,eK.k)(z);let W=(0,w.useCallback)((e,a)=>{try{let a=e.getBlockByFlavour("affine:surface")[0];a&&"$blocksuite:internal:native$"!==a.yBlock.get("prop:elements").get("type")&&v.G.upgradeDoc(0,{"affine:surface":3},e.spaceDoc)}catch{}let s=a.host;s?.std.clipboard.use(p.xqQ("/api/worker/image-proxy")),p.mFI.setImageProxyURL("/api/worker/image-proxy"),p.dYB.setLinkPreviewEndpoint("/api/worker/link-preview"),p.dyY.setLinkPreviewEndpoint("/api/worker/link-preview"),p.J3u.setLinkPreviewEndpoint("/api/worker/link-preview"),p.PoU.setLinkPreviewEndpoint("/api/worker/link-preview");let t=s?.std.spec.getService("affine:page"),r=new u.K;return t&&(r.add(t.slots.docLinkClicked.on(({docId:e,blockId:a})=>a?C(O.id,e,a):b(O.id,e))),r.add(t.slots.tagClicked.on(({tagId:e})=>{S(D.id,e)}))),M(a),()=>{r.dispose()}},[C,O.id,b,S,D.id]),[H,Z]=(0,r.IF)(),K=environment.isDesktop,q=(0,w.useCallback)(()=>{e.openSidebar(),a.activeSidebarTab("outline")},[e,a]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(eq.XP,{children:(0,t.jsx)(aR,{page:o.blockSuiteDoc,workspace:D})}),(0,t.jsx)(eq.s$,{children:(0,t.jsxs)("div",{className:"igi9w50","data-dynamic-top-border":K,"data-has-scroll-top":Z,children:[(0,t.jsxs)($.E,{children:[(0,t.jsx)(eU,{pageId:o.id,workspace:D}),(0,t.jsxs)(r.yE.Root,{children:[(0,t.jsx)(r.yE.Viewport,{ref:H,className:(0,k.A)("affine-page-viewport","igi9w52","igi9w51"),children:(0,t.jsx)(eC.q,{pageId:o.id,onLoad:W,docCollection:O})}),(0,t.jsx)(r.yE.Scrollbar,{className:(0,k.A)({igi9w53:!B.clientBorder})})]}),(0,t.jsx)(n.E,{editor:N,show:"page"===P&&!T,openOutlinePanel:q})]},o.id),d?(0,t.jsx)(eE,{}):null]})}),(0,t.jsx)(eq.$Q,{tabId:"journal",icon:(0,t.jsx)(h.TodayIcon,{}),children:(0,t.jsx)(aX,{})}),(0,t.jsx)(eq.$Q,{tabId:"outline",icon:(0,t.jsx)(h.TocIcon,{}),children:(0,t.jsx)(aG,{editor:N})}),(0,t.jsx)(ew,{})]})}),aQ=({pageId:e})=>{let a=(0,x.h1)(j.j).workspace,s=(0,x.h1)(b.F),r=s.list,i=(0,f.S)(r.isReady$),n=(0,f.S)(r.doc$(e)),[l,c]=(0,w.useState)(null);(0,w.useLayoutEffect)(()=>{if(!n)return;let{doc:a,release:t}=s.open(e);return c(a),()=>{t()}},[n,s,e]),(0,w.useEffect)(()=>(a.engine.doc.setPriority(e,10),()=>{a.engine.doc.setPriority(e,5)}),[a,e]);let d=(0,f.S)(l?.meta$.map(e=>e.trash));return((0,w.useEffect)(()=>{l&&d&&a.docCollection.awarenessStore.setReadonly(l.blockSuiteDoc.blockCollection,!0)},[a.docCollection.awarenessStore,l,d]),i&&!l)?(0,t.jsx)(eG.PageNotFound,{noPermission:!0}):l?(0,t.jsx)(x.xc,{scope:l.scope,children:(0,t.jsx)(aJ,{})}):(0,t.jsx)(o.g,{},"current-page-is-null")},a0=()=>{eN.xG.debug("DetailPage");let e=(0,C.g)(),a=(0,x.h1)(d.Oq);(0,w.useEffect)(()=>{if(e.pageId){let s=e.pageId;localStorage.setItem("last_page_id",s),a.addRecentDoc(s)}},[e,a]);let s=e.pageId;return s?(0,t.jsx)(aQ,{pageId:s}):null}}}]); //# sourceMappingURL=chunk.8962.f36903fd.js.map