"use strict";(globalThis.webpackChunk_affine_web=globalThis.webpackChunk_affine_web||[]).push([[8175],{68175:(e,s,a)=>{a.r(s),a.d(s,{Component:()=>W,ErrorBoundary:()=>G,downloadBinaryFromCloud:()=>T,loader:()=>X});var t=a(36870),r=a(63234),l=a(40274),n=a(90039),o=a(59481),i=a(21823),c=a(24312),d=a(64816),u=a(45483),h=a(10980),j=a(98504),m=a(27887),p=a(88082),x=a(7684),f=a(70154),g=a(61569),b=a(37064),v=a(86326),k=a(15010),w=a(42277),y=a(12077),_=a(45609);let S=()=>(0,t.jsxs)("div",{style:{width:"100%",height:"100vh",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[(0,t.jsx)("a",{href:"https://affine.pro/",target:"_blank",rel:"noreferrer",style:{position:"absolute",top:"16px",left:"16px",fontSize:"24px",cursor:"pointer"},children:(0,t.jsx)(u.Logo1Icon,{})}),(0,t.jsx)(r.Sv,{description:"You do not have access or this content does not exist."})]});var N=a(8158),C=a(64161),I=a(52600);let B=()=>{let e=(0,c.s9)();return(0,t.jsx)("div",{className:"_1y013ek0",children:(0,t.jsxs)("div",{className:"_1y013ek1",children:[(0,t.jsx)("div",{className:"_1y013ek2",children:e["com.arms.share-page.footer.description"]()}),(0,t.jsxs)("a",{className:"_1y013ek3",href:"https://affine.pro/",target:"_blank",rel:"noreferrer",children:[e["com.arms.share-page.footer.get-started"](),(0,t.jsx)(u.ArrowRightBigIcon,{fontSize:16})]})]})})};var D=a(55683),E=a(69628);let R=({setIsMember:e,...s})=>{let{workspaceId:a,pageId:r}=s,l=(0,h.h1)(j.q),n=(0,g.S)(l.list.workspaces$),o=n?.some(e=>e.id===a),i=(0,c.s9)(),{jumpToPage:d}=(0,E.P)(),u=(0,v.useCallback)(()=>{d(a,r)},[a,r,d]);return((0,v.useEffect)(()=>{o&&e(!0)},[o,e]),o)?(0,t.jsx)(D.$n,{className:"_3b2jam4",onClick:u,"data-testid":"share-page-edit-button",children:i.Edit()}):null};var $=a(39840);let F=()=>{let e=(0,c.s9)(),{isPresent:s,handlePresent:a}=(0,$.D)();return(0,t.jsx)(D.$n,{prefix:(0,t.jsx)(u.PresentationIcon,{}),className:"_3b2jam3",onClick:()=>a(),disabled:s,children:e["com.arms.share-page.header.present"]()})};var M=a(80198),A=a(14277),L=a(4285);let P=()=>{let e=(0,h.h1)(o.uR),s=(0,g.S)(e.session.account$),a=(0,h.h1)(o.nC).subscription;(0,v.useEffect)(()=>{a.revalidate()},[a]);let r=g.S(a.pro$)?.plan;return s?(0,t.jsxs)("div",{className:"_3b2jam6",children:[(0,t.jsx)(M.e,{size:28,name:s.label,url:s.avatar,className:"_3b2jam7"}),(0,t.jsxs)("div",{className:"_3b2jam8",children:[(0,t.jsxs)("div",{className:"_3b2jam9",children:[(0,t.jsx)("div",{className:"_3b2jama",title:s.label,children:s.label}),r&&(0,t.jsx)("div",{className:"_3b2jam5",children:r})]}),(0,t.jsx)("div",{className:"_3b2jamb",title:s.email,children:s.email})]})]}):null},z=()=>{let e=(0,h.h1)(o.uR),s=(0,g.S)(e.session.account$),a=(0,c.s9)(),r=(0,L.V)(async()=>{await e.signOut()},[e]),l=(0,v.useMemo)(()=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(P,{}),(0,t.jsx)(A.bX,{}),(0,t.jsx)(A.Dr,{preFix:(0,t.jsx)(A.ZB,{children:(0,t.jsx)(u.SignOutIcon,{})}),"data-testid":"share-page-sign-out-option",onClick:r,children:a["com.arms.workspace.cloud.account.logout"]()})]}),[r,a]);return s?(0,t.jsx)(A.W1,{items:l,contentOptions:{style:{transform:"translateX(-16px)"}},children:(0,t.jsx)("div",{className:"_3b2jam0","data-testid":"share-page-user-avatar",children:(0,t.jsx)(M.e,{size:24,url:s.avatar,name:s.label})})}):null},O=({...e})=>{let s=(0,g.S)((0,h.h1)(o.uR).session.status$),{publishMode:a}=e,[r,l]=(0,v.useState)(!1);return(0,t.jsxs)("div",{className:"_3b2jam1",children:["authenticated"===s?(0,t.jsx)(R,{setIsMember:l,...e}):null,"edgeless"===a?(0,t.jsx)(F,{}):null,"authenticated"===s?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"_3b2jam2","data-is-member":r,"data-is-edgeless":"edgeless"===a}),(0,t.jsx)(z,{})]}):null]})};var U=a(75806);function q({pageId:e,publishMode:s,docCollection:a}){return(0,t.jsxs)("div",{className:"_1losfdc0",children:[(0,t.jsx)(U.b,{docCollection:a,pageId:e,isPublic:!0}),(0,t.jsx)("div",{className:"_1losfdc1"}),(0,t.jsx)(O,{workspaceId:a.id,pageId:e,publishMode:s})]})}async function T(e,s){let a=await fetch(`/api/workspaces/${e}/docs/${s}`);if(a.ok){let e=a.headers.get("publish-mode")||"page";return{arrayBuffer:await a.arrayBuffer(),publishMode:e}}return null}function V(e){if(!e||!(e.arrayBuffer instanceof ArrayBuffer)||"string"!=typeof e.publishMode)throw Error("value is not a valid download response")}let X=async({params:e})=>{let s=e?.workspaceId,a=e?.pageId;if(!s||!a)return(0,k.V2)("/404");let[t,r]=await Promise.all([T(s,s),T(s,a)]);V(t);let{arrayBuffer:l}=t;V(r);let{arrayBuffer:n,publishMode:o}=r;return{workspaceId:s,pageId:a,publishMode:o,workspaceArrayBuffer:l,pageArrayBuffer:n}},W=()=>{let{workspaceId:e,pageId:s,publishMode:a,workspaceArrayBuffer:k,pageArrayBuffer:S}=(0,w.LG)(),D=(0,h.h1)(j.q),E=(0,c.s9)(),[R,$]=(0,v.useState)(null),[F,M]=(0,v.useState)(null),[A,L]=(0,l.U)(),P=D.framework.get((0,m.k)("CLOUD"));(0,v.useEffect)(()=>{let{workspace:a}=D.open({metadata:{id:e,flavour:i.j.AFFINE_CLOUD},isSharedMode:!0},{...P,getEngineProvider:e=>({getDocStorage:()=>new p.WM({[e]:new Uint8Array(k),[s]:new Uint8Array(S)}),getAwarenessConnections:()=>[],getDocServer:()=>null,getLocalBlobStorage:()=>x.km,getRemoteBlobStorages:()=>[new I.c(e)]})});$(a),a.engine.waitForRootDocReady().then(()=>{let{doc:e}=a.scope.get(f.F).open(s);a.docCollection.awarenessStore.setReadonly(e.blockSuiteDoc.blockCollection,!0),M(e)}).catch(e=>{console.error(e)})},[P,S,s,k,e,D]);let z=(0,g.S)(F?.title$);(0,n.k)(z);let O=(0,h.h1)(o.uR),U=(0,g.S)(O.session.status$),T=(0,v.useCallback)((e,s)=>(L(s),d.lQ),[L]);if(R&&F)return(0,t.jsx)(h.xc,{scope:R.scope,children:(0,t.jsx)(h.xc,{scope:F.scope,children:(0,t.jsxs)(y.R,{children:[(0,t.jsx)(N.J3,{children:(0,t.jsx)("div",{className:"kdchtr0",children:(0,t.jsxs)("div",{className:"kdchtr1",children:[(0,t.jsx)(q,{pageId:F.id,publishMode:a,docCollection:F.blockSuiteDoc.collection}),(0,t.jsxs)(r.yE.Root,{children:[(0,t.jsxs)(r.yE.Viewport,{className:(0,b.A)("affine-page-viewport","kdchtr2"),children:[(0,t.jsx)(_.q,{isPublic:!0,publishMode:a,docCollection:F.blockSuiteDoc.collection,pageId:F.id,onLoad:T}),"page"===a?(0,t.jsx)(B,{}):null]}),(0,t.jsx)(r.yE.Scrollbar,{})]}),"authenticated"!==U?(0,t.jsxs)("a",{href:"https://affine.pro",target:"_blank",className:"kdchtr3",rel:"noreferrer",children:[(0,t.jsx)("span",{className:"kdchtr4",children:E["com.arms.share-page.footer.built-with"]()}),(0,t.jsx)(u.Logo1Icon,{fontSize:20})]}):null]})})}),(0,t.jsx)(C.hv,{})]})})})};function G(){let e=(0,w.r5)();return(0,k.pX)(e)?(0,t.jsxs)("h1",{children:[e.status," ",e.statusText]}):(0,t.jsx)(S,{})}}}]); //# sourceMappingURL=chunk.8175.502fa2ba.js.map