1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,914778,e=>{"use strict";var t=e.i(500932),n=e.i(618566),o=e.i(271645),i=e.i(72545),a=e.i(31234),r=e.i(806398),l=e.i(467592),s=e.i(343676);e.s(["AddToHomeEffect",0,function(){let e,c,d,u=(0,t.c)(11),m=(0,n.useSearchParams)(),p=(0,n.usePathname)(),h=(0,n.useRouter)();u[0]!==m?(e=m.has("addToHome"),u[0]=m,u[1]=e):e=u[1];let f=e,{permission_token:x}=(0,l.useReplicache)(),{identity:y,identityPending:g}=(0,r.useIdentityData)(),b=(0,o.useRef)(!1);return u[2]!==y||u[3]!==g||u[4]!==p||u[5]!==x||u[6]!==h||u[7]!==m||u[8]!==f?(c=()=>{!f||b.current||g||(b.current=!0,y||((0,a.addDocToHome)(x),(0,i.mutate)("leaflets")),(0,s.replaceWithoutParams)(h,p,m,["addToHome"]))},d=[f,y,g,x,h,p,m],u[2]=y,u[3]=g,u[4]=p,u[5]=x,u[6]=h,u[7]=m,u[8]=f,u[9]=c,u[10]=d):(c=u[9],d=u[10]),(0,o.useEffect)(c,d),null},"useAddToHomeParam",0,function(){let e,o=(0,t.c)(2),i=(0,n.useSearchParams)();return o[0]!==i?(e=i.has("addToHome"),o[0]=i,o[1]=e):e=o[1],e}])},594769,591422,e=>{"use strict";var t=e.i(843476),n=e.i(500932),o=e.i(522016),i=e.i(492122),a=e.i(727378),r=e.i(618566),l=e.i(806398),s=e.i(467592),c=e.i(95187);let d=(0,c.createServerReference)("40ca0806e867603143a45ca09348a211f4396b2b9f",c.callServer,void 0,c.findSourceMapURL,"addLeafletToHome");var u=e.i(793610);let m=e=>{let o,i=(0,n.c)(1);return i[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M20.2108 1.06435C18.2026 1.27704 16.4279 2.08514 15.062 3.57676C14.2367 4.47793 13.5856 5.60101 13.1154 6.9388L11.9454 4.47784C11.7083 3.97905 11.1117 3.76693 10.6129 4.00406C10.1141 4.24119 9.90202 4.83777 10.1391 5.33655L12.5221 10.349C12.6387 10.5942 12.8499 10.7814 13.1074 10.8677C13.3648 10.954 13.6463 10.9319 13.8871 10.8065L18.6299 8.33675C19.1197 8.08167 19.31 7.47778 19.055 6.98793C18.7999 6.49809 18.196 6.30778 17.7061 6.56286L14.8565 8.04681C15.263 6.71029 15.842 5.68633 16.5369 4.92747C17.5357 3.83683 18.8399 3.22073 20.4214 3.05322C20.9706 2.99506 21.3687 2.50267 21.3105 1.95346C21.2524 1.40425 20.76 1.00618 20.2108 1.06435ZM7.3401 7.52353C7.55331 7.54947 7.74516 7.66557 7.86705 7.84241L9.08429 9.60844L9.34152 9.434C9.68433 9.20152 10.1507 9.29096 10.3832 9.63378C10.6157 9.9766 10.5262 10.443 10.1834 10.6755L9.93558 10.8435L13.3263 15.7629L19.8556 12.8502L18.4067 10.8971C18.16 10.5644 18.2296 10.0947 18.5622 9.84791C18.8949 9.60112 19.3647 9.67074 19.6114 10.0034L21.6174 12.7074C21.7529 12.8901 21.7982 13.1244 21.7405 13.3445C21.6828 13.5645 21.5283 13.7465 21.3206 13.8392L20.7814 14.0797L20.7814 14.0844L20.7814 18.4378C20.7814 18.7168 20.6265 18.9728 20.3793 19.1022L12.356 23.3031C12.1639 23.4037 11.9377 23.4162 11.7356 23.3375L8.4716 22.065C8.18363 21.9527 7.99402 21.6753 7.99402 21.3662L7.99402 19.5861L5.80331 20.8539C5.7914 20.8631 5.77916 20.8721 5.76662 20.8806C5.72248 20.9108 5.67573 20.9359 5.62724 20.9558L5.60922 20.9662L5.60764 20.9635C5.43659 21.0279 5.24562 21.0284 5.07141 20.9607L2.49577 19.9597C2.20742 19.8476 2.01747 19.57 2.01747 19.2606L2.01747 13.9072L1.99747 13.9249C1.68748 14.1996 1.21347 14.171 0.938734 13.861C0.664001 13.5511 0.692583 13.077 1.00257 12.8023L6.75207 7.70675C6.91281 7.5643 7.1269 7.49759 7.3401 7.52353ZM7.99402 18.1012L7.99402 18.1418L6.0931 19.2419L6.0931 17.0428C6.0931 16.6763 6.2215 16.3562 6.38727 16.1652C6.5406 15.9886 6.68564 15.9526 6.8279 15.9852C7.07537 16.0419 7.37055 16.2866 7.62505 16.764C7.87163 17.2266 7.99402 17.7544 7.99402 18.1012ZM13.3681 17.3868L19.2814 14.7488L19.2814 17.9839L12.6145 21.4746L12.6145 18.9253C12.6145 18.5801 12.3347 18.3003 11.9895 18.3003C11.6443 18.3003 11.3645 18.5801 11.3645 18.9253L11.3645 21.5828L9.49402 20.8536L9.49402 18.1012C9.49402 17.4825 9.29834 16.7143 8.94873 16.0584C8.60704 15.4174 8.02793 14.7213 7.16293 14.5231C6.37611 14.3428 5.695 14.6744 5.25444 15.182C4.82632 15.6753 4.5931 16.3561 4.5931 17.0428L4.5931 19.1655L3.51747 18.7474L3.51747 12.6176C3.51747 12.6046 3.51714 12.5916 3.51648 12.5787L7.11285 9.39132L8.272 11.0731L12.445 17.1274C12.6501 17.425 13.0381 17.534 13.3681 17.3868Z",fill:"currentColor"})}),i[0]=o):o=i[0],o},p=e=>{let o,i,a=(0,n.c)(3);return a[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.7066 1.65454C18.3926 1.51114 18.0218 1.64942 17.8784 1.9634C17.8089 2.11556 17.8056 2.28108 17.8563 2.42758C17.85 2.43434 17.8456 2.43822 17.844 2.43967C17.7408 2.50967 17.6154 2.61065 17.5169 2.74933C17.4138 2.89456 17.3166 3.11886 17.3652 3.38982C17.412 3.65115 17.573 3.8323
11 17.7183 3.94652C17.8637 4.06083 18.041 4.14714 18.2284 4.21706C18.3145 4.2492 18.3824 4.27985 18.4345 4.30764L18.4258 4.31721C18.4258 4.31721 18.4243 4.31876 18.4213 4.32147C18.4182 4.32435 18.4135 4.3284 18.4067 4.33377C18.3924 4.34523 18.3738 4.35873 18.3449 4.37865L18.3253 4.39198C18.2748 4.42626 18.1786 4.49152 18.0989 4.56396C17.9946 4.65876 17.8596 4.81464 17.804 5.04782C17.7485 5.28088 17.7936 5.50019 17.87 5.68345C18.0027 6.0021 18.3686 6.15282 18.6872 6.02011C18.9424 5.91384 19.0899 5.65804 19.0704 5.39672C19.1399 5.34841 19.2466 5.27096 19.3447 5.16465C19.5076 4.98797 19.6493 4.78073 19.7161 4.54056C19.7881 4.28148 19.7625 4.01854 19.641 3.78406C19.4757 3.46487 19.1687 3.2667 18.8882 3.13789C18.9696 3.02693 19.0348 2.90823 19.0802 2.79358C19.1293 2.66937 19.1798 2.48891 19.1581 2.2888C19.1331 2.0588 19.0038 1.79027 18.7066 1.65454ZM15.5641 4.19457C15.3529 3.92421 14.9852 3.83164 14.6711 3.96978L7.26728 7.22658C7.19603 7.25793 7.13008 7.30018 7.07182 7.35181L1.32232 12.4474C1.01233 12.7221 0.98375 13.1961 1.25848 13.5061C1.53322 13.8161 2.00723 13.8447 2.31722 13.57L2.33722 13.5522V18.9057C2.33722 19.215 2.52717 19.4927 2.81552 19.6047L5.39115 20.6058C5.56538 20.6735 5.75637 20.673 5.92742 20.6085L5.92897 20.6112L5.94654 20.601C5.99519 20.5811 6.04209 20.556 6.08636 20.5257C6.09904 20.517 6.1114 20.508 6.12344 20.4986L8.31377 19.2311V21.0113C8.31377 21.3204 8.50338 21.5978 8.79135 21.7101L12.0554 22.9825C12.2574 23.0613 12.4836 23.0488 12.6757 22.9482L20.6991 18.7473C20.9463 18.6179 21.1012 18.3619 21.1012 18.0828V13.7295L21.1012 13.7248L21.6403 13.4842C21.8511 13.3902 22.0068 13.2044 22.0626 12.9805C22.1183 12.7566 22.0679 12.5194 21.9258 12.3376C21.5519 11.859 21.2022 11.3379 20.7921 10.8902V7.34595C20.7921 6.93173 20.4563 6.59595 20.0421 6.59595H17.066C16.6518 6.59595 16.316 6.93173 16.316 7.34595V9.39619C16.316 9.8104 16.6518 10.1462 17.066 10.1462C17.4802 10.1462 17.816 9.8104 17.816 9.39619V8.09595H19.2921V11.0584C19.2921 11.3559 19.4862 11.6314 19.7162 11.9458L20.1532 12.5052L13.646 15.408L8.7016 8.23437L14.7412 5.57768L15.3052 6.29968C15.5602 6.62609 16.0316 6.68397 16.358 6.42897C16.6844 6.17396 16.7423 5.70263 16.4873 5.37622L15.5641 4.19457ZM8.31377 17.7868L6.41285 18.8869V16.6879C6.41285 16.3214 6.54125 16.0013 6.70702 15.8103C6.86035 15.6337 7.00539 15.5976 7.14764 15.6302C7.39512 15.6869 7.6903 15.9316 7.94479 16.4091C8.19138 16.8716 8.31377 17.3994 8.31377 17.7463V17.7868ZM19.6012 14.3939L13.6878 17.0318C13.3578 17.179 12.9698 17.07 12.7648 16.7725L7.4326 9.03638L3.83622 12.2237C3.83688 12.2366 3.83722 12.2496 3.83722 12.2627V18.3925L4.91285 18.8106V16.6879C4.91285 16.0011 5.14607 15.3204 5.57419 14.8271C6.01475 14.3195 6.69585 13.9878 7.48268 14.1681C8.34767 14.3663 8.92679 15.0625 9.26848 15.7035C9.61808 16.3593 9.81377 17.1276 9.81377 17.7463V20.4987L11.6843 21.2279V18.5704C11.6843 18.2252 11.9641 17.9454 12.3093 17.9454C12.6544 17.9454 12.9343 18.2252 12.9343 18.5704V21.1196L19.6012 17.629V14.3939Z",fill:"currentColor"}),a[0]=o):o=a[0],a[1]!==e?(i=(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:o}),a[1]=e,a[2]=i):i=a[2],i};var h=e.i(606368),f=e.i(31234),x=e.i(72545);e.s(["AddToHomeButton",0,e=>{let o,i,r,c=(0,n.c)(8),{permission_token:p}=(0,s.useReplicache)(),{identity:y,mutate:g}=(0,l.useIdentityData)(),b=(0,u.useSmoker)();return c[0]!==y||c[1]!==g||c[2]!==p||c[3]!==b?(o=async e=>{y?(await d(p.id),g(e=>{if(e)return(0,h.produce)(e=>{e.permission_token_on_homepage.push({created_at:new Date().toISOString(),archived:null,permission_tokens:{...p,title:null,description:null,leaflets_to_documents:[],leaflets_in_publications:[]}})})(e)})):((0,f.addDocToHome)(p),(0,x.mutate)("leaflets")),b({position:{x:e.clientX+64,y:e.clientY},text:"Leaflet added to your home!"})},c[0]=y,c[1]=g,c[2]=p,c[3]=b,c[4]=o):o=c[4],c[5]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)(m,{}),c[5]=i):i=c[5],c[6]!==o?(r=(0,t.jsx)(a.ActionButton,{primary:!0,labelOnMobile:!0,className:"sm:w-full! w-fit!",onClick:o,icon:i,label:"Save to Home"}),c[6]=o,c[7]=r):r=c[7],r},"HomeButton",0,function(){let e,l,s=(0,n.c)(2);return(0,i.useEntitySetContext)(),(0,r.useSearchParams)(),s[0]===Symbol.for("react.memo_cache_sentinel")?(e={textDecorationLine:"none !important"},s[0]=e):e=s[0],s[1]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(t.Fragment,{children:(0,t.jsx)(o.default,{href:"/home",prefetch:!0,className:"hover:no-underline",style:e,children:(0,t.jsx)(a.ActionButton,{icon:(0,t.jsx)(p,{}),label:"Back Home"})})}),s[1]=l):l=s[1],l}],594769);var y=e.i(28524),g=e.i(250209),b=e.i(634622),v=e.i(69278),C=e.i(650470),D=e.i(804511),j=e.i(784192),I=e.i(876082),k=e.i(814649),w=e.i(899169),S=e.i(788613),L=e.i(314192),N=e.i(124670),E=e.i(620196),P=e.i(271645),_=e.i(227086),T=e.i(789606),B=e.i(393991),M=e.i(616009),R=e.i(734582),A=e.i(310845);let F=(0,c.createServerReference)("789cd1184110403df94e5eda800d9de5536d483c27",c.callServer,void 0,c.findSourceMapURL,"moveLeafletToPublication");var $=e.i(121993),O=e.i(450030),H=e.i(410275),U=e.i(107461),V=e.i(671473);let z=()=>{let[e,n]=(0,P.useState)(!1),{data:o,mutate:i,normalizedDocument:r}=(0,I.useLeafletPublicationData)(),{permission_token:c,rootEntity:d,rep:m}=(0,s.useReplicache)(),{identity:p}=(0,l.useIdentityData)(),h=(0,u.useToaster)(),f=(0,T.useSubscribe)(m,e=>e.get("publication_title")),x=(0,T.useSubscribe)(m,e=>e.get("publication_description")),b="string"==typeof f?f:o?.title||"",v="string"==typeof x?x:o?.description||"",C=(0,T.useSubscribe)(m,e=>e.get("publication_tags")),j=Array.isArray(C)?C:r?.tags??[],k=(0,T.useSubscribe)(m,e=>e.get("post_preferences")),L=(0,U.useLocalPublishedAt)(e=>o?.doc?e[o?.doc]:void 0);return(0,t.jsx)(a.ActionButton,{primary:!0,className:"w-fit! sm:w-fill!",labelOnMobile:!0,icon:(0,t.jsx)(D.PublishSmall,{className:"shrink-0"}),label:e?(0,t.jsx)(S.DotLoader,{}):"Update!",disabled:e,onClick:async()=>{let a;if(!o||e)return;n(!0);try{a=await (0,y.publishToPublication)({root_entity:d,publication_uri:o.publications?.uri,leaflet_id:c.id,title:b,description:v,tags:j,publishedAt:L?.toISOString(),postPreferences:k})}catch(e){console.error(e),h({content:"We couldn't publish this. Please try again!",type:"error"});return}finally{n(!1),i()}if(!a.success)return void h({content:(0,H.isOAuthSessionError)(a.error)?(0,t.jsx)(H.OAuthErrorMessage,{error:a.error}):a.error.message,type:"error"});let r=o.publications?`${(0,g.getPublicationURL)(o.publications)}/${a.rkey}`:`https://leaflet.pub/p/${p?.atp_did}/${a.rkey}`;h({content:(0,t.jsxs)("div",{className:"font-bold",children:[o.doc?"Updated! ":"Published! ",(0,t.jsx)(w.SpeedyLink,{className:"underline text-accent-2!",href:r,children:"See Published Post"})]}),type:"success"})}})},Z=e=>{let o,i,c,d,u,m=(0,n.c)(20),{identity:p}=(0,l.useIdentityData)(),{permission_token:h}=(0,s.useReplicache)(),f=(0,r.useSearchParams)(),[x,y]=(0,P.useState)(null!==f.get("publish")),g=(0,_.useIsMobile)();p&&p.atp_did&&p.publications.length;let[C,j]=(0,P.useState)(void 0),I=(0,r.useRouter)(),{title:w,entitiesToDelete:S}=G(e.entityID),[L,N]=(0,P.useState)("");e:{let e;if(!p){let e;m[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],m[0]=e):e=m[0],o=e;break e}if(m[1]!==p.contributor_publications||m[2]!==p.publications){let t=new Map;for(let e of[...p.publications,...p.contributor_publications])t.set(e.uri,e);e=[...t.values()],m[1]=p.contributor_publications,m[2]=p.publications,m[3]=e}else e=m[3];o=e}let E=o;m[4]===Symbol.for("react.memo_cache_sentinel")?(i=e=>y(e),m[4]=i):i=m[4];let T=g?"top":"right",B=g?"center":"start";return m[5]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(a.ActionButton,{primary:!0,className:"sm:w-full! w-fit!",labelOnMobile:!0,icon:(0,t.jsx)(D.PublishSmall,{className:"shrink-0"}),label:"Publish!"}),m[5]=c):c=m[5],m[6]!==L||m[7]!==S||m[8]!==p||m[9]!==h||m[10]!==E||m[11]!==I||m[12]!==C||m[13]!==w?(d=p&&p.atp_did?(0,t.jsxs)("div",{className:"publishToPubForm p-3 flex flex-col overflow-scroll max-h-full min-h-0",children:[(0,t.jsx)(K,{title:w,description:L,setDescription:N}),(0,t.jsx)("hr",{className:"border-border-light my-3"}),(0,t.jsx)("div",{children:(0,t.jsx)(Y,{publications:E,selectedPub:C,setSelectedPub:j})}),(0,t.jsx)("hr",{className:"border-border-light mt-3 mb-2"}),(0,t.jsxs)("div",{className:"flex gap-2 items-center place-self-end",children:["looseleaf"!==C&&C&&(0,t.jsx)(W,{selectedPub:C,leafletId:h.id,metadata:{title:w,description:L},entitiesToDelete:S}),(0,t.jsxs)(v.ButtonPrimary,{disabled:void 0===C,onClick:async e=>{C&&(e.preventDefault(),"create"!==C&&("looseleaf"===C?I.push(`${h.id}/publish?title=${encodeURIComponent(w)}&description=${encodeURIComponent(L)}&entitiesToDelete=${encodeURIComponent(JSON.stringify(S))}`):I.push(`${h.id}/publish?publication_uri=${encodeURIComponent(C)}&title=${encodeURIComponent(w)}&description=${encodeURIComponent(L)}&entitiesToDelete=${encodeURIComponent(JSON.stringify(S))}`)))},children:["Next","create"===C&&": Create Pub!"]})]})]}):(0,t.jsx)("div",{className:"p-1",children:(0,t.jsxs)("div",{className:"bg-[var(--accent-light)] w-full rounded-md flex flex-col text-center justify-center p-2 pb-4 ",children:[(0,t.jsx)("div",{className:"mx-auto pt-2 scale-90",children:(0,t.jsx)(b.PubListEmptyIllo,{})}),(0,t.jsx)("div",{className:"pt-1 font-bold",children:"Publish to Atmosphere"}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"pb-2 text-secondary text-sm",children:[p?"Link":"Log in with"," an Atmosphere account",(0,t.jsx)("br",{})," to start publishing!"]}),(0,t.jsx)(V.LoginModal,{noEmailLogin:!0,trigger:(0,t.jsx)(v.ButtonPrimary,{compact:!0,className:"mx-auto",children:p?"Link":"Log in"})})]})]})}),m[6]=L,m[7]=S,m[8]=p,m[9]=h,m[10]=E,m[11]=I,m[12]=C,m[13]=w,m[14]=d):d=m[14],m[15]!==x||m[16]!==T||m[17]!==B||m[18]!==d?(u=(0,t.jsx)(k.Popover,{asChild:!0,open:x,onOpenChange:i,side:T,align:B,className:"sm:max-w-xs w-[1000px] p-0!",trigger:c,children:d}),m[15]=x,m[16]=T,m[17]=B,m[18]=d,m[19]=u):u=m[19],u},W=e=>{let o,a,r,l=(0,n.c)(14),{mutate:c}=(0,I.useLeafletPublicationData)(),{rep:d,rootEntity:u}=(0,s.useReplicache)(),m=(0,i.useEntitySetContext)(),p=(0,s.useEntity)(u,"root/page")[0]?.data.value,[h,f]=(0,P.useState)(!1);return l[0]!==m||l[1]!==p||l[2]!==c||l[3]!==e.entitiesToDelete||l[4]!==e.leafletId||l[5]!==e.metadata||l[6]!==e.selectedPub||l[7]!==d?(o=async t=>{e.selectedPub&&"create"!==e.selectedPub&&(t.preventDefault(),f(!0),await F(e.leafletId,e.selectedPub,e.metadata,e.entitiesToDelete),d&&p&&await (0,$.addPostHeaderBlock)(d,{page:p,permission_set:m.set}),await Promise.all([d?.pull(),c()]),f(!1))},l[0]=m,l[1]=p,l[2]=c,l[3]=e.entitiesToDelete,l[4]=e.leafletId,l[5]=e.metadata,l[6]=e.selectedPub,l[7]=d,l[8]=o):o=l[8],l[9]!==h?(a=h?(0,t.jsx)(S.DotLoader,{}):"Save as Draft",l[9]=h,l[10]=a):a=l[10],l[11]!==o||l[12]!==a?(r=(0,t.jsx)(v.ButtonTertiary,{onClick:o,children:a}),l[11]=o,l[12]=a,l[13]=r):r=l[13],r},K=e=>{let o,i,a,r,l,s=(0,n.c)(11);return s[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("div",{className:"text-sm text-tertiary",children:"Post Details"}),s[0]=o):o=s[0],s[1]!==e.title?(i=(0,t.jsx)(j.InputWithLabel,{label:"Title",value:e.title,disabled:!0}),s[1]=e.title,s[2]=i):i=s[2],s[3]!==e?(a=t=>e.setDescription(t.currentTarget.value),s[3]=e,s[4]=a):a=s[4],s[5]!==e.description||s[6]!==a?(r=(0,t.jsx)(j.InputWithLabel,{label:"Description (optional)",textarea:!0,value:e.description,className:"h-[4lh]",onChange:a}),s[5]=e.description,s[6]=a,s[7]=r):r=s[7],s[8]!==i||s[9]!==r?(l=(0,t.jsxs)("div",{className:"postDetailsContent flex flex-col gap-1 ",children:[o,(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[i,r]})]}),s[8]=i,s[9]=r,s[10]=l):l=s[10],l},Y=e=>{let o,i,a=(0,n.c)(3);return a[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("div",{className:"text-sm text-tertiary",children:"Publish toâ¦"}),a[0]=o):o=a[0],a[1]!==e?(i=(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[o,0===e.publications.length||void 0===e.publications?(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(q,{selected:"looseleaf"===e.selectedPub,onSelect:()=>e.setSelectedPub("looseleaf"),children:[(0,t.jsx)(C.LooseLeafSmall,{}),(0,t.jsxs)("div",{className:"flex flex-col leading-snug",children:[(0,t.jsx)("div",{className:"text-secondary font-bold",children:"Publish as Looseleaf"}),(0,t.jsx)("div",{className:"text-tertiary text-sm font-normal",children:"Publish as a one-off doc to AT Proto"})]})]}),(0,t.jsxs)("div",{className:"flex gap-2 px-2 py-1 ",children:[(0,t.jsx)(D.PublishSmall,{className:"shrink-0 text-border"}),(0,t.jsxs)("div",{className:"flex flex-col leading-snug",children:[(0,t.jsx)("div",{className:"text-border font-bold",children:"Publish to Publication"}),(0,t.jsx)("div",{className:"text-border text-sm font-normal",children:"Publish to a blog on AT Proto"}),(0,t.jsx)("hr",{className:"my-2 border-border-light border-dashed"}),(0,t.jsxs)("div",{className:"text-tertiary text-sm font-normal ",children:["You don't have any Publications yet."," ",(0,t.jsx)("a",{target:"_blank",href:"/lish/createPub",children:"Create one"})," ","to get started!"]})]})]})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)(q,{selected:"looseleaf"===e.selectedPub,onSelect:()=>e.setSelectedPub("looseleaf"),children:[(0,t.jsx)(C.LooseLeafSmall,{}),"Publish as Looseleaf"]}),(0,t.jsx)("hr",{className:"border-border-light border-dashed "}),e.publications.map(n=>{let o=(0,L.normalizePublicationRecord)(n.record);return(0,t.jsx)(q,{selected:e.selectedPub===n.uri,onSelect:()=>e.setSelectedPub(n.uri),children:(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(b.PubIcon,{icon:o?.icon?(0,N.blobRefToSrc)(o.icon.ref,new E.AtUri(n.uri).host):void 0,pubName:n.name}),n.name]})},n.uri)}),(0,t.jsxs)("div",{className:"flex items-center px-2 py-1 text-accent-contrast gap-2",children:[(0,t.jsx)(O.AddTiny,{className:"m-1 shrink-0"}),(0,t.jsx)("a",{target:"_blank",href:"/lish/createPub",children:"Start a new Publication"})]})]})]}),a[1]=e,a[2]=i):i=a[2],i},q=e=>{let o,i,a=(0,n.c)(6),r=`flex gap-2 menuItem font-bold text-secondary ${e.selected&&"bg-[var(--accent-light)]! outline! outline-offset-1! outline-accent-contrast!"}`;return a[0]!==e?(o=()=>{e.onSelect()},a[0]=e,a[1]=o):o=a[1],a[2]!==e.children||a[3]!==r||a[4]!==o?(i=(0,t.jsx)("button",{className:r,onClick:o,children:e.children}),a[2]=e.children,a[3]=r,a[4]=o,a[5]=i):i=a[5],i},G=e=>
1{let t=(0,s.useEntity)(e,"root/page")[0].data.value,n=(0,B.useCanvasBlocksWithType)(t).filter(e=>"text"===e.type||"heading"===e.type),o=(0,B.useBlocks)(t).filter(e=>"text"===e.type||"heading"===e.type),i=n[0]?.value??o[0]?.entityID??null,a=n[0]?.type??o[0]?.type,r=(0,s.useEntity)(i,"block/text")?.data.value,l=(0,P.useMemo)(()=>{if(!r)return"Untitled";let e=new M.Doc,t=R.toByteArray(r);M.applyUpdate(e,t);let n=e.getXmlElement("prosemirror").toArray();return(0,A.YJSFragmentToString)(n[0])||"Untitled"},[r]),c=n.length>0,d=c?void 0:o[1],u=(0,s.useEntity)(d?.entityID||null,"block/text")?.data.value,m=(0,P.useMemo)(()=>{if(!u)return"";let e=new M.Doc,t=R.toByteArray(u);M.applyUpdate(e,t);let n=e.getXmlElement("prosemirror").toArray();return(0,A.YJSFragmentToString)(n[0])||""},[u]);return{title:l,entitiesToDelete:(0,P.useMemo)(()=>{let e=[];return"heading"===a&&i&&e.push(i),c||""!==m.trim()||d?.type!=="text"||e.push(d.entityID),e},[i,a,m,d,c])}};e.s(["PublishButton",0,e=>{let o,i=(0,n.c)(7),{data:s}=(0,I.useLeafletPublicationData)(),{identity:c}=(0,l.useIdentityData)(),d=(0,r.useParams)(),u=(0,r.useRouter)();if(!s){let n;return i[0]!==e.entityID?(n=(0,t.jsx)(Z,{entityID:e.entityID}),i[0]=e.entityID,i[1]=n):n=i[1],n}let m=s.publications;if(m&&!(c?.atp_did&&(c.atp_did===m.identity_did||m.publication_contributors?.some(e=>e.contributor_did===c.atp_did&&e.confirmed))))return null;if(!s?.doc){let e,n;return i[2]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(D.PublishSmall,{className:"shrink-0"}),i[2]=e):e=i[2],i[3]!==d.leaflet_id||i[4]!==u?(n=(0,t.jsx)(a.ActionButton,{primary:!0,labelOnMobile:!0,className:"sm:w-full! w-fit!",icon:e,label:"Publish!",onClick:()=>{u.push(`/${d.leaflet_id}/publish`)}}),i[3]=d.leaflet_id,i[4]=u,i[5]=n):n=i[5],n}return i[6]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(z,{}),i[6]=o):o=i[6],o}],591422)},375421,e=>{"use strict";var t=e.i(500932),n=e.i(758459),o=e.i(227086),i=e.i(871040),a=e.i(658610),r=e.i(510038);let l=e=>{let o,l,s=(0,t.c)(6),c=(0,n.useClientSearchParams)(),d=c.get("interactionDrawer");s[0]!==c?(o=c.get("page"),s[0]=c,s[1]=o):o=s[1];let u=o,{drawerOpen:m,drawer:p,pageId:h,threadStack:f}=(0,i.useInteractionState)(e);if(!(0,r.usePostFrame)().drawer||!1===m||void 0===m&&!d)return null;let x=(0,a.parseDrawerParam)(d,e);p=p||x.tab;let y=f[f.length-1]??x.thread,g=h??u??void 0;return s[2]!==p||s[3]!==g||s[4]!==y?(l={drawer:p,thread:y,pageId:g},s[2]=p,s[3]=g,s[4]=y,s[5]=l):l=s[5],l};e.s(["useDrawerOpen",0,l,"useInlineDrawer",0,e=>{let t=l(e);return(0,o.useIsMobile)()?null:t}])},618270,693666,995346,735764,502961,e=>{"use strict";var t=e.i(843476),n=e.i(500932),o=e.i(813029),i=e.i(427550),a=e.i(887710),r=e.i(129362),l=e.i(492122),s=e.i(525507),c=e.i(50203),d=e.i(782963),u=e.i(594769),m=e.i(591422),p=e.i(587098),h=e.i(707475),f=e.i(876082),x=e.i(806398),y=e.i(467592),g=e.i(795122),b=e.i(484575),v=e.i(283599),C=e.i(31234),D=e.i(914778);function j(e){return"text"===e||"heading"===e||"blockquote"===e||"button"===e||"datetime"===e||"image"===e}function I(e){e.currentTarget===e.target&&e.preventDefault()}function k(e){e.currentTarget===e.target&&e.preventDefault()}function w(){return(0,C.getHomeDocs)()}function S(e){return e.focusedEntity}function L(e){e.currentTarget===e.target&&e.preventDefault()}function N(e){e.currentTarget===e.target&&e.preventDefault()}function E(e){return e.focusedEntity}e.s(["LeafletFooter",0,function(e){let C,L,N,E=(0,n.c)(14),P=(0,o.useUIState)(S),_=(0,l.useEntitySetContext)(),{identity:T}=(0,x.useIdentityData)(),{permission_token:B}=(0,y.useReplicache)(),{data:M}=(0,f.useLeafletPublicationData)();E[0]===Symbol.for("react.memo_cache_sentinel")?(C={fallbackData:[]},E[0]=C):C=E[0];let{data:R}=(0,v.default)("leaflets",w,C),A=(0,y.useEntity)(P?.entityID||null,"block/type")?.data.value,F=(0,D.useAddToHomeParam)();E[1]!==F||E[2]!==T||E[3]!==R||E[4]!==B?(L=F||(T?!!T.permission_token_on_homepage.find(e=>e.permission_tokens.id===B.id):!!R.find(e=>e.token.id===B.id)),E[1]=F,E[2]=T,E[3]=R,E[4]=B,E[5]=L):L=E[5];let $=L,O=!!M?.publications&&!!T?.atp_did&&M.publications.identity_did===T.atp_did,H=!!M?.publications&&!!T?.atp_did&&!!M.publications.publication_contributors?.some(e=>e.contributor_did===T.atp_did&&e.confirmed),U=O||H;return E[6]!==A||E[7]!==U||E[8]!==_||E[9]!==P||E[10]!==$||E[11]!==e.entityID||E[12]!==M?(N=(0,t.jsx)(i.Media,{mobile:!0,className:"mobileLeafletFooter w-full z-10 touch-none -mt-[54px]",children:P&&"block"==P.entityType&&j(A)&&_.permissions.write?(0,t.jsx)(s.FooterLayout,{onMouseDown:k,children:(0,t.jsx)(a.Toolbar,{pageID:P.parent,blockID:P.entityID,blockType:A})}):P&&"footnote"===P.entityType&&_.permissions.write?(0,t.jsx)(s.FooterLayout,{onMouseDown:I,children:(0,t.jsx)(r.FootnoteToolbar,{pageID:P.parent})}):_.permissions.write?(0,t.jsxs)(s.FooterLayout,{children:[U&&M?.publications?(0,t.jsx)(h.BackToPubButton,{publication:M.publications}):(0,t.jsx)(u.HomeButton,{}),(0,t.jsxs)("div",{className:"mobileLeafletActions flex gap-2 shrink-0",children:[U||$?(0,t.jsx)(m.PublishButton,{entity
1ID:e.entityID}):(0,t.jsx)(u.AddToHomeButton,{primary:!0}),(0,t.jsx)(d.ShareOptions,{}),(0,t.jsx)(g.PostSettings,{}),(0,t.jsx)(b.VersionHistory,{}),(0,t.jsx)(c.ThemePopover,{entityID:e.entityID})]})]}):(0,t.jsx)("div",{className:"pb-2 px-2 z-10 flex justify-end",children:(0,t.jsx)(p.Watermark,{mobile:!0})})}),E[6]=A,E[7]=U,E[8]=_,E[9]=P,E[10]=$,E[11]=e.entityID,E[12]=M,E[13]=N):N=E[13],N},"hasBlockToolbar",0,j],693666),e.s(["DesktopPageFooter",0,function(e){let s,c,d,u=(0,n.c)(14),m=(0,o.useUIState)(E),p=m?.entityType==="page"?m.entityID:m?.parent,h=(0,l.useEntitySetContext)(),f=(0,y.useEntity)(m?.entityID||null,"block/type")?.data.value,x=m?.entityType==="footnote"&&m.parent===e.pageID,g=e.flow?"desktopPageFooter fixed inset-x-0 bottom-3 z-10 pointer-events-none":"desktopPageFooter absolute bottom-[40px] left-0 right-0 z-10 pointer-events-none";return u[0]!==f||u[1]!==h||u[2]!==p||u[3]!==m||u[4]!==e.pageID?(s=m&&"block"===m.entityType&&j(f)&&h.permissions.write&&p===e.pageID&&(0,t.jsx)("div",{className:"pointer-events-auto w-fit mx-auto py-1 px-3 h-9 bg-bg-page border border-border rounded-full shadow-sm",onMouseDown:N,children:(0,t.jsx)(a.Toolbar,{blockType:f,pageID:p,blockID:m.entityID})}),u[0]=f,u[1]=h,u[2]=p,u[3]=m,u[4]=e.pageID,u[5]=s):s=u[5],u[6]!==h||u[7]!==x||u[8]!==e.pageID?(c=x&&h.permissions.write&&(0,t.jsx)("div",{className:"pointer-events-auto w-fit mx-auto py-1 px-3 h-9 bg-bg-page border border-border rounded-full shadow-sm",onMouseDown:L,children:(0,t.jsx)(r.FootnoteToolbar,{pageID:e.pageID})}),u[6]=h,u[7]=x,u[8]=e.pageID,u[9]=c):c=u[9],u[10]!==g||u[11]!==s||u[12]!==c?(d=(0,t.jsxs)(i.Media,{mobile:!1,className:g,children:[s,c]}),u[10]=g,u[11]=s,u[12]=c,u[13]=d):d=u[13],d}],618270);var P=e.i(271645),_=e.i(308054),T=e.i(219746),B=e.i(680016),M=e.i(393991),R=e.i(988314),A=e.i(762268),F=e.i(394191),$=e.i(468034),O=e.i(616009),H=e.i(734582),U=e.i(310845),V=e.i(173275),z=e.i(581869),Z=e.i(752316),W=e.i(829975),K=e.i(135537);function Y(e,t){return t.unfold?.length&&(0,_.unfoldBlocks)(e,t.unfold),(0,$.addBlockBelow)(e,{parent:t.parent,position:t.position,nextPosition:null,permission_set:t.permission_set,type:"text"})}function q(e){let o,i,a,r,s=(0,n.c)(13),{rep:c}=(0,y.useReplicache)(),d=(0,l.useEntitySetContext)();s[0]!==e.lastBlock?(o=t=>{let n=e.lastBlock?.type==="text"?t.editorStates[e.lastBlock.entityID]?.editor:null;return!n||n.doc.content.size<=2},s[0]=e.lastBlock,s[1]=o):o=s[1];let u=(0,R.useEditorStates)(o);return!d.permissions.write||(e.lastBlock?.type==="text"||e.lastBlock?.type==="heading")&&u?null:(s[2]!==d.set||s[3]!==e.entityID||s[4]!==e.lastBlock?.position||s[5]!==e.unfoldOnAppend||s[6]!==c?(i=async()=>{if(!c)return;let t=await Y(c,{parent:e.entityID,position:e.lastBlock?.position||null,unfold:e.unfoldOnAppend,permission_set:d.set});(0,$.focusNewTextBlock)(t)},s[2]=d.set,s[3]=e.entityID,s[4]=e.lastBlock?.position,s[5]=e.unfoldOnAppend,s[6]=c,s[7]=i):i=s[7],s[8]!==e.lastBlock?(a=e.lastBlock?" ":(0,t.jsx)("div",{className:"pt-2 sm:pt-3",children:"write something..."}),s[8]=e.lastBlock,s[9]=a):a=s[9],s[10]!==i||s[11]!==a?(r=(0,t.jsx)("div",{className:"newBlockButton flex items-center justify-between group/text px-3 sm:px-4",children:(0,t.jsx)("div",{className:"h-6 hover:cursor-text italic text-tertiary grow",onMouseDown:i,children:a})}),s[10]=i,s[11]=a,s[12]=r):r=s[12],r)}let G=e=>{let o,i,a,r=(0,n.c)(16),{rep:s}=(0,y.useReplicache)(),c=(0,l.useEntitySetContext)(),d=e.lastRootBlock?.position||null;r[0]!==e.entityID||r[1]!==d?(o={parent:e.entityID,position:d,nextPosition:null},r[0]=e.entityID,r[1]=d,r[2]=o):o=r[2];let u=(0,Z.useHandleDrop)(o),m=e.trailingBlock,p=!!m&&!!A.isTextBlock[m.type],h=(0,y.useEntity)(p?m.entityID:null,"block/text");if(c.permissions.write&&!e.areFootnotes)return r[3]!==c.set||r[4]!==e.entityID||r[5]!==e.lastRootBlock?.position||r[6]!==e.unfoldOnAppend||r[7]!==e.unfoldToReachTrailing||r[8]!==s||r[9]!==m||r[10]!==p||r[11]!==h?.data?(i=()=>{let t=p?R.useEditorStates.getState().editorStates[m.entityID]?.editor:null;p&&(t?t.doc.content.size<=2:function(e){if(!e)return!0;let t=new O.Doc;return(0,O.applyUpdate)(t,H.toByteArray(e)),t.getXmlElement("prosemirror").toArray().every(e=>""===(0,U.YJSFragmentToString)(e))}(h?.data.value))?(e.unfoldToReachTrailing?.length&&(0,_.unfoldBlocks)(s,e.unfoldToReachTrailing),(0,F.focusBlock)(m,{type:"end"})):s&&Y(s,{parent:e.entityID,position:e.lastRootBlock?.position||null,unfold:e.unfoldOnAppend,permission_set:c.set}).then($.focusNewTextBlock)},r[3]=c.set,r[4]=e.entityID,r[5]=e.lastRootBlock?.position,r[6]=e.unfoldOnAppend,r[7]=e.unfoldToReachTrailing,r[8]=s,r[9]=m,r[10]=p,r[11]=h?.data,r[12]=i):i=r[12],r[13]!==u||r[14]!==i?(a=(0,t.jsx)("div",{className:"blockListClickableBottomArea grow min-h-[50vh]",onClick:i,onDragOver:J,onDrop:u}),r[13]=u,r[14]=i,r[15]=a):a=r[15],a};function J(e){e.preventDefault(),e.stopPropagation()}e.s(["Blocks",0,function(e){let n=(0,o.useUIState)(t=>t.zoomedBlocks[e.entityID]),i=(0,o.useIsPageFocused)(e.entityID),a=(0,M.useBlocks)(e.entityID),r=(0,P.useMemo)(()=>(0,B.filterBlocksForZoom)(a,n),[a,n]),{rep:l}=(0,y.useReplicache)(),s=(0,T.useFoldedBlocks)(),c=(0,P.useMemo)(()=>{var e;let t;return t=new Set((e=r).map(e=>e.entityID)),new Set(e.flatMap(e=>[...e.listData?.path.slice(0,-1).map(e=>e.entity)??[],...e.headingPath??[]]).filter(e=>t.has(e)))},[r]),d=(0,P.useMemo)(()=>{let e=s.filter(e=>c.has(e));return r.filter(t=>!(0,B.isBlockHidden)(t,e))},[r,s,c]),u=n?r[0]?.listData?.depth:void 0,m=a.length>0;(0,P.useEffect)(()=>{n&&m&&void 0===u&&o.useUIState.getState().zoomOutOfBlock(e.entityID)},[m,e.entityID,u,n]),(0,P.useEffect)(()=>
1{if(i)return(0,z.addShortcut)([{altKey:!0,metaKey:!0,key:"ArrowUp",shift:!0,handler:()=>{(0,_.foldBlocks)(l,[...c])}},{altKey:!0,metaKey:!0,key:"ArrowDown",shift:!0,handler:()=>{(0,_.unfoldBlocks)(l,[...c])}}])},[c,i,l]);let p=n?r.findLast(e=>e.listData?.parent===n):r.findLast(e=>!e.listData||1===e.listData.depth),h=n?void 0:p?.headingPath,f=(0,P.useMemo)(()=>{let e=r.at(-1);if(!e)return;let t=s.filter(e=>c.has(e)&&!h?.includes(e));return(0,B.isBlockHidden)(e,t)?d.at(-1):e},[r,d,s,c,h]),x=f&&f!==d.at(-1)?h:void 0;(0,P.useEffect)(()=>(W.listDndPages.set(e.entityID,{pageID:e.entityID,blocks:d,zoomDepth:u}),()=>void W.listDndPages.delete(e.entityID)),[e.entityID,d,u]);let{footnotes:g}=(0,K.useFootnoteContext)(),[b,v]=(0,P.useState)(!1);return(0,P.useEffect)(()=>{v(g.length>0)},[g.length]),(0,t.jsxs)("div",{className:`blocks w-full flow-root outline-hidden ${b?"h-fit":"min-h-full"}`,children:[d.map((e,t,n)=>{let o,i=n[t+1];return o=(e.listData?.depth||1)===(i?.listData?.depth||1)&&i?.position||null,(0,P.createElement)(V.Block,{pageType:"doc",...e,key:e.entityID,entityID:e.entityID,previousBlock:n[t-1]||null,nextBlock:n[t+1]||null,nextPosition:o,headingFoldable:c.has(e.entityID)&&!e.listData,displayDepth:u&&e.listData?e.listData.depth-u+1:void 0})}),(0,t.jsx)(q,{lastBlock:p||null,unfoldOnAppend:h,entityID:n??e.entityID}),(0,t.jsx)(G,{trailingBlock:f,unfoldToReachTrailing:x,lastRootBlock:p||void 0,unfoldOnAppend:h,entityID:n??e.entityID,areFootnotes:b})]})}],995346);var X=e.i(522016),Q=e.i(618566),ee=e.i(72545),et=e.i(69278),en=e.i(416504),eo=e.i(857592),ei=e.i(788613),ea=e.i(793610),er=e.i(227086),el=e.i(338448),es=e.i(95187);let ec=(0,es.createServerReference)("60662429324370f9a3a937b1ef2e277a5c02287b6a",es.callServer,void 0,es.findSourceMapURL,"restoreVersion"),ed=(0,es.createServerReference)("6023e8e002b3c1bd0b85be94307341da28c97fc500",es.callServer,void 0,es.findSourceMapURL,"forkVersionAsNewLeaflet"),eu=(0,P.createContext)(null),em=()=>(0,P.useContext)(eu);e.s(["SavedVersionContext",0,eu,"useIsVersion",0,em],735764);var ep=e.i(859015),eh=e.i(541019);function ef(e){let o,i,a=(0,n.c)(5),{className:r}=e,l=em();return l?(a[0]!==l?(o=(0,t.jsx)(ex,{version:l}),a[0]=l,a[1]=o):o=a[1],a[2]!==r||a[3]!==o?(i=(0,t.jsx)("div",{className:r,children:o}),a[2]=r,a[3]=o,a[4]=i):i=a[4],i):null}function ex(e){let o,i,a,r,l,s,c,d,u,m=(0,n.c)(19),{version:p}=e,h=new Date(p.savedAt).getFullYear()===new Date().getFullYear();m[0]!==h?(o={month:"short",day:"numeric",...h?{}:{year:"numeric"}},m[0]=h,m[1]=o):o=m[1];let f=(0,el.useLocalizedDate)(p.savedAt,o);m[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,t.jsx)("div",{className:"font-bold",children:"VIEW ONLY"}),m[2]=i):i=m[2],m[3]!==p?(a=(0,t.jsxs)("div",{className:"sm:w-fit w-full flex justify-between",children:[i,(0,t.jsx)("div",{className:"sm:hidden",children:(0,t.jsx)(ey,{version:p})})]}),m[3]=p,m[4]=a):a=m[4];let x=p.name?`${p.name}`:"Saved Version";return m[5]!==x?(r=(0,t.jsxs)("div",{className:"min-w-0 truncate",children:[x," "]}),m[5]=x,m[6]=r):r=m[6],m[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("div",{children:"·"}),m[7]=l):l=m[7],m[8]!==f||m[9]!==r?(s=(0,t.jsxs)("div",{className:"flex gap-1 grow min-w-0",children:[r,l,f]}),m[8]=f,m[9]=r,m[10]=s):s=m[10],m[11]!==a||m[12]!==s?(c=(0,t.jsxs)("div",{className:" flex sm:flex-row flex-col sm:gap-3 text-tertiary truncate w-full",children:[a,s]}),m[11]=a,m[12]=s,m[13]=c):c=m[13],m[14]!==p?(d=(0,t.jsx)("div",{className:"sm:block hidden",children:(0,t.jsx)(ey,{version:p})}),m[14]=p,m[15]=d):d=m[15],m[16]!==c||m[17]!==d?(u=(0,t.jsxs)("div",{className:"flex sm:flex-row flex-col items-start justify-between gap-x-4 gap-y-1 text-sm w-full",children:[c,d]}),m[16]=c,m[17]=d,m[18]=u):u=m[18],u}function ey(e){let o,i,a,r,l=(0,n.c)(8),{version:s}=e,c=`/${s.tokenId}`;return l[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(eh.GoToArrowLined,{className:"rotate-180"}),l[0]=o):o=l[0],l[1]!==c?(i=(0,t.jsxs)(X.default,{href:c,className:"text-sm text-accent-contrast font-bold flex gap-1 items-center no-underline!",children:[o," Back"]}),l[1]=c,l[2]=i):i=l[2],l[3]!==s?(a=s.canModify&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(ep.Separator,{classname:"h-4!"}),(0,t.jsx)(eg,{version:s})]}),l[3]=s,l[4]=a):a=l[4],l[5]!==i||l[6]!==a?(r=(0,t.jsxs)("div",{className:"flex gap-2 items-center shrink-0",children:[i,a]}),l[5]=i,l[6]=a,l[7]=r):r=l[7],r}function eg({version:e}){let[n,o]=(0,P.useState)(null),[i,a]=(0,P.useState)(!1),r=(0,ea.useToaster)(),{identity:l}=(0,x.useIdentityData)(),s=(0,Q.useRouter)(),c=(0,er.useIsMobile)(),d=async()=>
1{if(!i){a(!0);try{let t=await ec(e.tokenId,e.versionId);if(!t.ok)return r({content:t.error,type:"error"});o(null),r({content:"Version restored",type:"success"}),s.push(`/${e.tokenId}`)}finally{a(!1)}}},u=async()=>{if(!i){a(!0);try{let t=await ed(e.tokenId,e.versionId);if(!t.ok)return r({content:t.error,type:"error"});l||((0,C.addDocToHome)(t.value.token),(0,ee.mutate)("leaflets")),o(null),c?window.location.href=`/${t.value.token.id}`:window.open(`/${t.value.token.id}`,"_blank")}finally{a(!1)}}};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(en.Menu,{align:"end",trigger:(0,t.jsx)("div",{className:"font-bold text-accent-contrast flex items-center","aria-label":"Version options",children:"Options"}),children:[(0,t.jsx)(en.MenuItem,{onSelect:()=>o("restore"),className:"justify-end py-0.5!",children:"Restore this version"}),(0,t.jsx)(en.MenuItem,{onSelect:()=>o("fork"),className:"justify-end py-0.5!",children:"Create new from version"})]}),(0,t.jsxs)(eb,{open:"restore"===n,onClose:()=>o(null),title:"Restore?",confirmLabel:"Restore",busy:i,onConfirm:d,children:[(0,t.jsxs)("div",{className:"font-bold",children:["This will replace the current doc",(0,t.jsx)("br",{})," with this version."]}),"The current doc will also be saved as a version, so you can get it back!"]}),(0,t.jsxs)(eb,{open:"fork"===n,onClose:()=>o(null),title:"Create a new document?",confirmLabel:"Create new",busy:i,onConfirm:u,children:[(0,t.jsx)("div",{children:"This will copy this version into a new doc and open it in a new tab."}),"The current doc will be left as is."]})]})}function eb(e){let o,i,a,r,l,s,c,d,u=(0,n.c)(25);return u[0]!==e?(o=t=>{t||e.busy||e.onClose()},u[0]=e,u[1]=o):o=u[1],u[2]!==e.children?(i=(0,t.jsx)("div",{className:"flex flex-col gap-1",children:e.children}),u[2]=e.children,u[3]=i):i=u[3],u[4]!==e.busy||u[5]!==e.onClose?(a=(0,t.jsx)(et.ButtonTertiary,{type:"button",onClick:e.onClose,disabled:e.busy,children:"Nevermind"}),u[4]=e.busy,u[5]=e.onClose,u[6]=a):a=u[6],u[7]!==e.busy||u[8]!==e.confirmLabel?(r=e.busy?(0,t.jsx)(ei.DotLoader,{}):e.confirmLabel,u[7]=e.busy,u[8]=e.confirmLabel,u[9]=r):r=u[9],u[10]!==e.busy||u[11]!==e.onConfirm||u[12]!==r?(l=(0,t.jsx)(et.ButtonPrimary,{type:"button",onClick:e.onConfirm,disabled:e.busy,children:r}),u[10]=e.busy,u[11]=e.onConfirm,u[12]=r,u[13]=l):l=u[13],u[14]!==a||u[15]!==l?(s=(0,t.jsxs)("div",{className:"flex gap-3 pt-2 justify-center",children:[a,l]}),u[14]=a,u[15]=l,u[16]=s):s=u[16],u[17]!==i||u[18]!==s?(c=(0,t.jsxs)("div",{className:"flex flex-col gap-2 text-center text-secondary leading-snug",children:[i,s]}),u[17]=i,u[18]=s,u[19]=c):c=u[19],u[20]!==e.open||u[21]!==e.title||u[22]!==o||u[23]!==c?(d=(0,t.jsx)(eo.Modal,{open:e.open,onOpenChange:o,title:e.title,className:"max-w-full w-sm text-center",children:c}),u[20]=e.open,u[21]=e.title,u[22]=o,u[23]=c,u[24]=d):d=u[24],d}e.s(["FloatingVersionBanner",0,function(){let e,o=(0,n.c)(1);return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ef,{className:"floatingVersionBanner accent-container fixed top-2 left-1/2 -translate-x-1/2 z-20 opaque-container rounded-md px-2 py-1 shadow-md max-w-[calc(100vw-16px)]"}),o[0]=e):e=o[0],e},"InlineVersionBanner",0,function(){let e,o=(0,n.c)(1);return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(ef,{className:"\n inlineVersionBanner accent-container px-2 py-1 sm:mx-2 mx-1 mt-2 mb-0"}),o[0]=e):e=o[0],e}],502961)},413458,607895,e=>{"use strict";var t=e.i(843476),n=e.i(500932),o=e.i(271645),i=e.i(813029),a=e.i(553445),r=e.i(467592),l=e.i(618270),s=e.i(637777),c=e.i(995346),d=e.i(432801),u=e.i(581869),m=e.i(332111),p=e.i(502961),h=e.i(876082),f=e.i(960622),x=e.i(433823),y=e.i(823035),g=e.i(497366),b=e.i(970827),v=e.i(375421),C=e.i(379343),D=e.i(261355),j=e.i(680016),I=e.i(150248);let k=[...D.blockListAttributes,"canvas/block","block/footnote"];var w=e.i(135537),S=e.i(640682),L=e.i(492122),N=e.i(473080),E=e.i(182193),P=e.i(453386);function _(e){let o,i,a=(0,n.c)(10),{footnotes:l}=(0,w.useFootnoteContext)(),{permissions:s}=(0,L.useEntitySetContext)(),c=(0,r.useReplicache)();if(0===l.length)return null;let d=e.hiddenOnDesktop?"xl:hidden":"";if(a[0]!==l||a[1]!==s||a[2]!==c){let e;a[4]!==s||a[5]!==c?(e=e=>(0,t.jsx)(S.FootnoteEditor,{footnoteEntityID:e.footnoteEntityID,index:e.index,sourcePreview:{footnoteID:e.footnoteEntityID,sourceSelector:`.footnote-ref[data-footnote-id="${CSS.escape(e.footnoteEntityID)}"]`,content:(0,t.jsx)(P.EditorFootnoteSourcePreview,{blockID:e.blockID})},editable:s.write,onDelete:s.write?()=>{(0,N.deleteFootnoteFromBlock)(e.footnoteEntityID,e.blockID,c.rep)}:void 0},e.footnoteEntityID),a[4]=s,a[5]=c,a[6]=e):e=a[6],o=l.map(e),a[0]=l,a[1]=s,a[2]=c,a[3]=o}else o=a[3];return a[7]!==d||a[8]!==o?(i=(0,t.jsx)(E.FootnoteSectionLayout,{className:d,children:o}),a[7]=d,a[8]=o,a[9]=i):i=a[9],i}var T=e.i(612192);let B=[...D.blockListAttributes,"canvas/block","block/comment"];var M=e.i(18421),R=e.i(806398),A=e.i(975191);function F(e){let n=(0,o.useRef)(null),i=(0,o.useRef)(null),[a,r]=(0,o.useState)([]),l=(0,o.useCallback)(()=>{let t=n.current,o=i.current;if(!t||!o||0===e.items.length)return void r([]);let a=t.closest(".pageWrapper")?.querySelector(".pageScrollWrapper");if(!a)return;let l=a.scrollTop,s=t.getBoundingClientRect();o.style.transform=`translateY(-${l}px)`;let c=[];for(let t of e.items){let n=a.querySelector(e.getAnchorSelector(t));if(!n)continue;let i=n.getBoundingClientRect().top-s.top+l-4,r=o.querySelector(`[data-footnote-side-id="${t.id}"]`),d=r?r.offsetHeight:54;c.push({...t,anchorTop:i,height:d})}c.sort((e,t)=>
1e.anchorTop-t.anchorTop);let d=[],u=0;for(let e of c){let t=Math.max(e.anchorTop,u);d.push({...e,top:t}),u=t+e.height+4}r(d)},[e.items,e.getAnchorSelector]);return((0,o.useEffect)(()=>{if(!e.visible)return;l();let t=n.current?.closest(".pageWrapper")?.querySelector(".pageScrollWrapper");if(!t)return;let o=()=>{let e=i.current;e&&(e.style.transform=`translateY(-${t.scrollTop}px)`)};t.addEventListener("scroll",o,{passive:!0});let a=n.current,r=e=>{t.scrollTop+=e.deltaY};a.addEventListener("wheel",r,{passive:!0});let s=new ResizeObserver(l);s.observe(t);let c=()=>{let e=i.current;if(e)for(let t of e.querySelectorAll("[data-footnote-side-id]"))s.observe(t)};c();let d=new MutationObserver(()=>{l(),c()});d.observe(t,{childList:!0,subtree:!0,characterData:!0});let u=i.current;return u&&d.observe(u,{childList:!0,subtree:!0}),()=>{t.removeEventListener("scroll",o),a.removeEventListener("wheel",r),s.disconnect(),d.disconnect()}},[e.visible,l]),e.visible&&0!==e.items.length)?(0,t.jsx)("div",{ref:n,className:`footnote-side-column hidden lg:block absolute top-0 ${e.columnClassName??"w-[250px]"} ${e.fullPageScroll?"left-[calc(50%+var(--page-width-units)/2+12px)]":"left-full ml-3"}`,style:{height:"100%"},children:(0,t.jsx)("div",{ref:i,className:"relative",children:a.map(n=>(0,t.jsx)($,{id:n.id,top:n.top,className:e.getItemClassName?.(n),focusKind:e.getItemFocusKind?.(n)??"footnote",children:e.renderItem(n)},n.id))})}):null}function $(e){let a,r,l,s,c,d,u,m=(0,n.c)(20),p=(0,o.useRef)(null),[h,f]=(0,o.useState)(!1);m[0]!==e.focusKind||m[1]!==e.id?(a=t=>t.focusedEntity?.entityType===e.focusKind&&t.focusedEntity.entityID===e.id,m[0]=e.focusKind,m[1]=e.id,m[2]=a):a=m[2];let x=(0,i.useUIState)(a),y="comment"===e.focusKind?"editor-comment-side-focused":"footnote-side-focused",g="comment"===e.focusKind;m[3]!==g||m[4]!==e.id?(r=t=>g&&t.hoveredCommentIDs.includes(e.id),m[3]=g,m[4]=e.id,m[5]=r):r=m[5];let b=(0,A.useHoveredEditorCommentStore)(r);m[6]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{let e=p.current;if(!e)return;let t=()=>f(e.scrollHeight>e.clientHeight+1);t();let n=new MutationObserver(t);return n.observe(e,{childList:!0,subtree:!0,characterData:!0}),()=>{n.disconnect()}},s=[],m[6]=l,m[7]=s):(l=m[6],s=m[7]),(0,o.useEffect)(l,s);let v=`absolute left-0 text-sm footnote-side-enter ${e.className??"right-0 footnote-side-item"}${h?" has-overflow":""}${x?` ${y}`:""}${b?" editor-comment-side-hovered":""}`;m[8]!==e.top?(c={top:e.top},m[8]=e.top,m[9]=c):c=m[9],m[10]!==g||m[11]!==e.id?(d=g?()=>A.useHoveredEditorCommentStore.setState({hoveredCommentIDs:[e.id]}):void 0,m[10]=g,m[11]=e.id,m[12]=d):d=m[12];let C=g?O:void 0;return m[13]!==e.children||m[14]!==e.id||m[15]!==v||m[16]!==c||m[17]!==d||m[18]!==C?(u=(0,t.jsx)("div",{ref:p,"data-footnote-side-id":e.id,className:v,style:c,onMouseEnter:d,onMouseLeave:C,children:e.children}),m[13]=e.children,m[14]=e.id,m[15]=v,m[16]=c,m[17]=d,m[18]=C,m[19]=u):u=m[19],u}function O(){return A.useHoveredEditorCommentStore.setState({hoveredCommentIDs:[]})}e.s(["FootnoteSideColumnLayout",0,F],607895);var H=e.i(630564),U=e.i(616009),V=e.i(734582),z=e.i(220511),Z=e.i(827121),W=e.i(571141),K=e.i(172604),Y=e.i(929987),q=e.i(69497),G=e.i(657460),J=e.i(734255),X=e.i(38168),Q=e.i(186915),ee=e.i(438424),et=e.i(69278),en=e.i(645522),eo=e.i(229008);function ei(e){let o,i,a,r,l,s,c=(0,n.c)(16),{data:d}=(0,eo.useRecordFromDid)(e.did??void 0),u=`editor-comment-message flex flex-col gap-0.5 ${e.className??""}`,m=d?.avatar,p=d?.displayName||d?.handle;c[0]!==m||c[1]!==p?(o=(0,t.jsx)(en.Avatar,{src:m,displayName:p,size:"tiny"}),c[0]=m,c[1]=p,c[2]=o):o=c[2];let h=d?.displayName||d?.handle||"...";return c[3]!==h?(i=(0,t.jsx)("div",{className:"font-bold text-sm text-secondary truncate min-w-0 ",children:h}),c[3]=h,c[4]=i):i=c[4],c[5]!==e.headerActions||c[6]!==o||c[7]!==i?(a=(0,t.jsxs)("div",{className:"flex gap-1 items-center min-w-0",children:[o,i,e.headerActions]}),c[5]=e.headerActions,c[6]=o,c[7]=i,c[8]=a):a=c[8],c[9]===Symbol.for("react.memo_cache_sentinel")?(r={wordBreak:"break-word"},c[9]=r):r=c[9],c[10]!==e.children?(l=(0,t.jsx)("div",{className:"editor-comment-message-content relative text-sm text-primary pl-5",style:r,children:e.children}),c[10]=e.children,c[11]=l):l=c[11],c[12]!==u||c[13]!==a||c[14]!==l?(s=(0,t.jsxs)("div",{className:u,children:[a,l]}),c[12]=u,c[13]=a,c[14]=l,c[15]=s):s=c[15],s}function ea(e){let n=(0,o.useRef)(null),i=(0,o.useRef)(null),[a,r]=(0,o.useState)(!0),{identity:l}=(0,R.useIdentityData)(),s=(0,o.useRef)(()=>{}),c=(0,o.useRef)(e.onSubmit);c.current=e.onSubmit;let d=(0,o.useRef)(e.onPersistDraft);d.current=e.onPersistDraft;let u=async()=>{let e=i.current;e&&""!==e.state.doc.textContent.trim()&&(await c.current((0,z.prosemirrorToYDoc)(e.state.doc)),s.current())},m=(0,o.useRef)(u);return m.current=u,(0,o.useLayoutEffect)(()=>{let t;if(!n.current)return;let o=(e,t)=>{let n=q.schema.nodes.hard_break.create();return t&&t(e.tr.replaceSelectionWith(n).scrollIntoView()),!0},a=[(0,Y.keymap)({...(0,X.formattingKeymap)(q.schema.marks),"Shift-Enter":o,"Mod-Enter":o,Enter:()=>(m.current(),!0)}),(0,Y.keymap)(K.baseKeymap),(0,J.autolink)({type:q.schema.marks.link,shouldAutoLink:()=>!0,defaultProtocol:"https"})];if(e.initialContent){let n=new U.Doc;U.applyUpdate(n,V.toByteArray(e.initialContent)),t=(0,z.yDocToProsemirror)(q.schema,n)}let l=Z.EditorState.create({schema:q.schema,doc:t,plugins:a}),c=new W.EditorView({mount:n.current},{state:l,transformPasted:G.stripCommentMarks,handlePaste:(e,t)=>
1{let n=t.clipboardData?.getData("text");if(n&&(0,ee.betterIsUrl)(n))return(0,Q.applyLinkPaste)(e,q.schema.marks.link,n)},dispatchTransaction(e){let t=this.state.apply(e);this.updateState(t),r(""===t.doc.textContent.trim())}});return i.current=c,s.current=()=>{c.updateState(Z.EditorState.create({schema:q.schema,plugins:a})),r(!0)},r(""===l.doc.textContent.trim()),e.autoFocus&&setTimeout(()=>c.focus(),50),()=>{if(d.current){let e=""===c.state.doc.textContent.trim();d.current(e?null:V.fromByteArray(U.encodeStateAsUpdate((0,z.prosemirrorToYDoc)(c.state.doc))))}i.current=null,c.destroy()}},[]),(0,t.jsxs)("div",{className:"editorCommentComposer flex flex-col gap-2",children:[(0,t.jsxs)(ei,{did:l?.atp_did,children:[a&&(0,t.jsx)("div",{className:"absolute top-0 left-5 text-tertiary italic pointer-events-none",children:e.placeholder||"Add a commentâ¦"}),(0,t.jsx)("div",{ref:n,className:"outline-hidden [&_.ProseMirror]:outline-hidden min-h-[1.5em]"})]}),(0,t.jsxs)("div",{className:"flex gap-2 justify-end items-center",children:[e.onCancel&&(0,t.jsx)(et.ButtonTertiary,{compact:!0,type:"button",className:"text-sm",onClick:()=>{s.current(),e.onCancel?.()},children:"Cancel"}),(0,t.jsx)(et.ButtonPrimary,{compact:!0,type:"button",className:"text-sm",disabled:a,onMouseDown:e=>e.preventDefault(),onClick:()=>u(),children:e.submitLabel||"Comment"})]})]})}var er=e.i(671473);function el(e){let o,i,a,r,l=(0,n.c)(11),{identity:s}=(0,R.useIdentityData)();if(s?.atp_did)return null;let c=e.action??"comment",d=s?"Link":"Log in";l[0]!==d?(o=(0,t.jsx)("span",{className:"text-accent-contrast font-bold not-italic",children:(0,t.jsx)(er.LoginModal,{noEmailLogin:!0,trigger:d})}),l[0]=d,l[1]=o):o=l[1];let u=s?"":"with ";return l[2]!==c||l[3]!==o||l[4]!==u?(i=(0,t.jsxs)("div",{children:[o," ",u,"an Atmosphere account to ",c]}),l[2]=c,l[3]=o,l[4]=u,l[5]=i):i=l[5],l[6]!==e.onCancel?(a=e.onCancel&&(0,t.jsx)("button",{className:"text-xs text-tertiary hover:text-accent-contrast",onClick:e.onCancel,children:"Cancel"}),l[6]=e.onCancel,l[7]=a):a=l[7],l[8]!==i||l[9]!==a?(r=(0,t.jsxs)("div",{className:"editorCommentLoginPrompt flex flex-col gap-1 text-sm text-tertiary text-center italic p-1",children:[i,a]}),l[8]=i,l[9]=a,l[10]=r):r=l[10],r}var es=e.i(110383),ec=e.i(478802),ed=e.i(30552),eu=e.i(276452),em=e.i(864460),ep=e.i(853915);function eh(e){let n=(0,r.useReplicache)(),i=(0,L.useEntitySetContext)(),{identity:a}=(0,R.useIdentityData)(),l=(0,r.useEntity)(e.commentEntityID,"comment/reply").toSorted((e,t)=>e.data.position>t.data.position?1:-1),[s,c]=(0,o.useState)(()=>new Set),d=(0,o.useCallback)((e,t)=>{c(n=>{if(n.has(e)===t)return n;let o=new Set(n);return t?o.add(e):o.delete(e),o})},[]),u=async t=>{if(!n.rep||!a?.atp_did)return;let o=l.length>0?l[l.length-1].data.position:null;n.undoManager.startGroup();try{await n.rep.mutate.createEditorCommentReply({replyEntityID:(0,es.v7)(),replyFactID:(0,es.v7)(),commentEntityID:e.commentEntityID,permission_set:i.set,position:(0,ec.generateKeyBetween)(o,null),authorDid:a.atp_did,createdAt:new Date().toISOString(),content:V.fromByteArray(U.encodeStateAsUpdate(t))})}finally{n.undoManager.endGroup()}};return(0,t.jsxs)("div",{className:"editor-comment-thread flex flex-col gap-4","data-editor-comment-thread":e.commentEntityID,children:[(0,t.jsx)(ef,{entityID:e.commentEntityID,onEditingChange:d,onResolve:i.permissions.write?async()=>{if(n.rep){n.undoManager.startGroup();try{(0,H.removeEditorCommentMark)(e.blockID,e.commentEntityID),await n.rep.mutate.deleteEditorComment({commentEntityID:e.commentEntityID,blockID:e.blockID})}finally{n.undoManager.endGroup()}}}:void 0}),l.length>0&&(0,t.jsxs)("div",{className:"editor-comment-thread-replies flex flex-col gap-4",children:[(0,t.jsx)("hr",{className:"border-border-light -mx-3"}),l.map(o=>(0,t.jsx)(ef,{entityID:o.data.value,onEditingChange:d,onDelete:async()=>{n.undoManager.startGroup();try{await n.rep?.mutate.deleteEditorCommentReply({replyEntityID:o.data.value,commentEntityID:e.commentEntityID})}finally{n.undoManager.endGroup()}}},o.data.value))]}),!i.permissions.write||s.size>0?null:(0,t.jsx)("div",{className:"editor-comment-thread-actions",children:a?.atp_did?(0,t.jsx)("div",{className:"opaque-container p-1 w-full",children:(0,t.jsx)(ea,{placeholder:"Replyâ¦",submitLabel:"Reply",autoF
1ocus:!0,onSubmit:u})}):(0,t.jsx)(el,{action:"reply"})})]})}function ef(e){let n=(0,r.useReplicache)(),{permissions:i}=(0,L.useEntitySetContext)(),a=(0,r.useEntity)(e.entityID,"block/text"),l=(0,r.useEntity)(e.entityID,"comment/author"),s=(0,r.useEntity)(e.entityID,"comment/created-at"),{identity:c}=(0,R.useIdentityData)(),d=l?.data.value,u=!!c?.atp_did&&c.atp_did===d&&i.write,[m,p]=(0,o.useState)(!1),{onEditingChange:h,entityID:f}=e;(0,o.useEffect)(()=>{if(m)return h?.(f,!0),()=>h?.(f,!1)},[m,h,f]);let x=async t=>{if(d){n.undoManager.startGroup();try{await n.rep?.mutate.editEditorComment({entityID:e.entityID,authorDid:d,content:V.fromByteArray(U.encodeStateAsUpdate(t))})}finally{n.undoManager.endGroup()}p(!1)}},y="shrink-0 text-tertiary hover:text-accent-contrast opacity-100 xl:opacity-0 xl:group-hover/editor-comment-message:opacity-100 xl:focus:opacity-100";return m?(0,t.jsx)(ea,{autoFocus:!0,submitLabel:"Save",initialContent:a?.data.value,onSubmit:x,onCancel:()=>p(!1)}):(0,t.jsx)(ei,{did:d,className:"group/editor-comment-message",headerActions:(0,t.jsxs)("div",{className:" flex flex-row grow justify-between gap-3 items-center shrink-0",children:[s&&(0,t.jsx)("div",{className:"text-xs text-tertiary shrink-0",children:function(e){let t=new Date(e);if(isNaN(t.getTime()))return"";let n=new Date,o=t.getFullYear()===n.getFullYear();return t.toLocaleDateString(void 0,{month:"short",day:"numeric",...o?{}:{year:"numeric"}})}(s.data.value)}),(0,t.jsxs)("div",{className:"flex flex-row shrink-0 gap-1 items-center",children:[u&&(0,t.jsx)("button",{className:y,onClick:()=>p(!0),title:"Edit comment",children:(0,t.jsx)(ep.EditTiny,{})}),u&&e.onDelete&&(0,t.jsx)("button",{className:y,onClick:e.onDelete,title:"Delete comment",children:(0,t.jsx)(eu.DeleteTiny,{})}),e.onResolve&&(0,t.jsx)("div",{className:"-m-1 p-1",children:(0,t.jsxs)(et.ButtonPrimary,{compact:!0,className:"shrink-0 text-xs ml-1 gap-1! hover:outline-transparent! ",onClick:e.onResolve,title:"Resolve comment",children:["Resolve ",(0,t.jsx)(em.CheckTiny,{className:"scale-80"})]})})]})]}),children:(0,t.jsx)(ed.RenderYJSFragment,{value:a?.data.value||"",wrapper:"p"})})}function ex(e){let{footnotes:n}=(0,w.useFootnoteContext)(),{comments:i}=(0,M.useEditorCommentContext)(),a=(0,A.useEditorCommentDraftStore)(e=>e.draft),{permissions:l}=(0,L.useEntitySetContext)(),s=(0,r.useReplicache)(),c=[...n.map(e=>({kind:"footnote",id:e.footnoteEntityID,index:e.index,footnoteEntityID:e.footnoteEntityID,blockID:e.blockID})),...i.map(e=>({kind:"comment",id:e.commentEntityID,commentEntityID:e.commentEntityID,blockID:e.blockID}))];a&&a.pageID===e.pageEntityID&&l.write&&c.push({kind:"draft",id:"comment-draft",blockID:a.blockID});let d=(0,o.useCallback)(e=>"footnote"===e.kind?`.footnote-ref[data-footnote-id="${e.id}"]`:"draft"===e.kind?".comment-draft-anchor":`.comment-anchor[data-comment-id~="${e.id}"]`,[]),u=(0,o.useCallback)(e=>"footnote"===e.kind?"w-[250px] footnote-side-item":"draft"===e.kind?"w-[320px] editor-comment-side-item editor-comment-side-focused":"w-[320px] editor-comment-side-item",[]),m=(0,o.useCallback)(e=>"footnote"===e.kind?"footnote":"comment",[]),p=(0,o.useCallback)(n=>"footnote"===n.kind?(0,t.jsx)(S.FootnoteEditor,{footnoteEntityID:n.footnoteEntityID,index:n.index,editable:l.write,onDelete:l.write?()=>(0,N.deleteFootnoteFromBlock)(n.footnoteEntityID,n.blockID,s.rep):void 0}):"draft"===n.kind?(0,t.jsx)(ey,{}):(0,t.jsx)(eh,{commentEntityID:n.commentEntityID,blockID:n.blockID,pageID:e.pageEntityID}),[l.write,s.rep,e.pageEntityID]);return(0,t.jsx)(F,{items:c,visible:e.visible,fullPageScroll:e.fullPageScroll,getAnchorSelector:d,getItemClassName:u,getItemFocusKind:m,columnClassName:"w-[320px]",renderItem:p})}function ey(e){let o,i,a=(0,n.c)(9),l=(0,r.useReplicache)(),s=(0,L.useEntitySetContext)(),{identity:c}=(0,R.useIdentityData)();if(!s.permissions.write)return null;if(!c?.atp_did){let e;return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)(el,{onCancel:H.cancelEditorCommentDraft}),a[0]=e):e=a[0],e}let d=c.atp_did,u=e.autoFocus??!0;
1return a[1]!==d||a[2]!==s.set||a[3]!==l.rep||a[4]!==l.undoManager?(o=async e=>{if(!l.rep)return;let t=await (0,H.submitEditorCommentDraft)({rep:l.rep,undoManager:l.undoManager,permissionSet:s.set,authorDid:d,ydoc:e}),n=A.useEditorCommentSheetStore.getState();t&&n.pageID&&n.openSheet(n.pageID,t)},a[1]=d,a[2]=s.set,a[3]=l.rep,a[4]=l.undoManager,a[5]=o):o=a[5],a[6]!==u||a[7]!==o?(i=(0,t.jsx)(ea,{autoFocus:u,placeholder:"Add a commentâ¦",submitLabel:"Submit",onSubmit:o,onCancel:H.cancelEditorCommentDraft}),a[6]=u,a[7]=o,a[8]=i):i=a[8],i}var eg=e.i(824488),eb=e.i(988314),ev=e.i(580714),eC=e.i(917718);function eD(){let e,o,i,a,r=(0,n.c)(15),{pageID:l,comments:s}=(0,M.useEditorCommentContext)(),{pageID:c,focusedCommentID:d,close:u}=(0,A.useEditorCommentSheetStore)(),m=(0,A.useEditorCommentDraftStore)(ej),p=m?.pageID===l;r[0]!==s||r[1]!==d?(e=d?s.find(e=>e.commentEntityID===d):void 0,r[0]=s,r[1]=d,r[2]=e):e=r[2];let h=e,f=c===l&&""!==l&&(!!h||p);r[3]!==u||r[4]!==p?(o=e=>{e||(p&&(0,H.cancelEditorCommentDraft)(),u())},r[3]=u,r[4]=p,r[5]=o):o=r[5];let x=h?"Comment":"New Comment";return r[6]!==m||r[7]!==h||r[8]!==l?(i=h?(0,t.jsxs)("div",{className:"editor-comment-sheet-item",children:[(0,t.jsx)("div",{className:"light-container py-1 px-1.5 mb-4",children:(0,t.jsx)(eI,{commentEntityID:h.commentEntityID,blockID:h.blockID})}),(0,t.jsx)(eh,{commentEntityID:h.commentEntityID,blockID:h.blockID,pageID:l})]}):m&&m.pageID===l?(0,t.jsxs)("div",{className:"editor-comment-sheet-item ",children:[(0,t.jsx)("div",{className:"light-container py-1 px-1.5 mb-4",children:(0,t.jsx)(ek,{blockID:m.blockID})}),(0,t.jsx)("div",{className:"opaque-container p-1 w-full",children:(0,t.jsx)(ey,{autoFocus:!0})})]}):null,r[6]=m,r[7]=h,r[8]=l,r[9]=i):i=r[9],r[10]!==f||r[11]!==o||r[12]!==x||r[13]!==i?(a=(0,t.jsx)(eg.MobileSheet,{open:f,onOpenChange:o,title:x,children:i}),r[10]=f,r[11]=o,r[12]=x,r[13]=i,r[14]=a):a=r[14],a}function ej(e){return e.draft}function eI(e){let o,i,a,l=(0,n.c)(5),s=(0,r.useEntity)(e.blockID,"block/text");s?.data.value;let c=s?.data.value;return l[0]!==e.commentEntityID||l[1]!==c?(i=(0,eC.getEditorCommentQuoteText)(c,e.commentEntityID),l[0]=e.commentEntityID,l[1]=c,l[2]=i):i=l[2],o=i,l[3]!==o?(a=(0,t.jsx)(ew,{quote:o}),l[3]=o,l[4]=a):a=l[4],a}function ek(e){let o,i,a=(0,n.c)(6);a[0]!==e.blockID?(o=t=>t.editorStates[e.blockID]?.editor,a[0]=e.blockID,a[1]=o):o=a[1];let r=(0,eb.useEditorStates)(o),l="";if(r)if(a[2]!==r){let e=(0,ev.getCommentDraftRange)(r);e&&(l=r.doc.textBetween(e.from,e.to," ","")),a[2]=r,a[3]=l}else l=a[3];return a[4]!==l?(i=(0,t.jsx)(ew,{quote:l}),a[4]=l,a[5]=i):i=a[5],i}function ew(e){let o,i=(0,n.c)(2);return e.quote?(i[0]!==e.quote?(o=(0,t.jsx)("div",{className:"editor-comment-quote text-sm text-tertiary italic line-clamp-3",children:e.quote}),i[0]=e.quote,i[1]=o):o=i[1],o):null}var eS=e.i(216425);function eL(){let e,i,r,l,s=(0,n.c)(6),{permissions:c}=(0,L.useEntitySetContext)(),{pageID:d}=(0,M.useEditorCommentContext)(),u=(0,A.useHoveredEditorCommentStore)(eP);s[0]!==d||s[1]!==c.write?(e=()=>{if(!c.write)return;let e=document.getElementById(a.elementId.page(d).container);if(e)return e.addEventListener("pointerover",eE),e.addEventListener("pointerleave",eN),()=>{e.removeEventListener("pointerover",eE),e.removeEventListener("pointerleave",eN)}},i=[c.write,d],s[0]=d,s[1]=c.write,s[2]=e,s[3]=i):(e=s[2],i=s[3]),(0,o.useEffect)(e,i);e:{if(!c.write||0===u.length){r="";break e}let e=`[id="${a.elementId.page(d).container}"] `,t=u.map(t=>`${e}.comment-anchor[data-comment-id~="${t}"]`).join(",\n");r=`${t} { 2 background: color-mix(in oklab, rgb(var(--accent-contrast)), transparent 75%); 3 border-bottom: 2px solid rgb(var(--accent-contrast)); 4}`}let m=r;return m?(s[4]!==m?(l=(0,t.jsx)("style",{children:m}),s[4]=m,s[5]=l):l=s[5],l):null}function eN(){return A.useHoveredEditorCommentStore.setState({hoveredCommentIDs:[]})}function eE(e){let t=e.target?.closest?.(".comment-anchor[data-comment-id]"),n=t?.getAttribute("data-comment-id")?.split(" ").filter(Boolean)??[],o=A.useHoveredEditorCommentStore.getState().hoveredCommentIDs;o.length===n.length&&o.every(e=>n.includes(e))||A.useHoveredEditorCommentStore.setState({hoveredCommentIDs:n})}function eP(e){return e.hoveredCommentIDs}var e_=e.i(434988);let eT=e=>{let o,i,a,r,l=(0,n.c)(18),s=(0,f.useCardBorderHidden)(),{ref:c}=(0,C.usePreserveScroll)(e.id),d=`pageWrapper relative shrink-0 ${e.flow?"":"h-full"} ${e.fullPageScroll?"w-full":"w-max"}`,u=` 5 pageScrollWrapper 6 footnote-scope 7 publicationScrollContainer 8 grow relative 9 shrink-0 snap-center 10 ${e.flow?"":"hidden"===e.overflow?"overflow-hidden":"overflow-y-scroll"} 11 ${!s&&`border 12 bg-[rgba(var(--bg-page),var(--bg-page-alpha))] 13 ${e.flow?"":"h-full"} 14 ${e.drawerOpen?"rounded-l-lg ":"rounded-lg"} 15 ${e.isFocused?"shadow-md border-border":"border-border-light"}`}
16 ${s&&(e.flow?"sm:pt-6 pt-3":"sm:h-[calc(100%+48px)] h-[calc(100%+20px)] sm:-my-6 -my-3 sm:pt-6 pt-3")} 17 ${e.fullPageScroll&&"max-w-full "} 18 ${"doc"===e.pageType&&!e.fullPageScroll?e.fixedWidth?"w-[10000px] sm:max-w-prose max-w-[var(--page-width-units)]":"w-[10000px] sm:mx-0 max-w-[var(--page-width-units)]":""} 19 ${"canvas"===e.pageType&&!e.fullPageScroll&&"max-w-[var(--page-width-units)] sm:max-w-[calc(var(--leaflet-layout-width,100vw)-128px)] lg:max-w-fit lg:w-[calc(var(--page-width-units)*2 + 24px))]"} 20 21`,m=`postPageContent static 22 ${e.fullPageScroll?"h-full sm:max-w-[var(--page-width-units)] mx-auto":` contents w-full ${e.flow?"":"h-full"}`} 23 `;return l[0]!==e.noBottomSpacer||l[1]!==e.pageType?(o="doc"===e.pageType&&!e.noBottomSpacer&&(0,t.jsx)("div",{className:"h-4 sm:h-6 w-full"}),l[0]=e.noBottomSpacer,l[1]=e.pageType,l[2]=o):o=l[2],l[3]!==e.children||l[4]!==m||l[5]!==o?(i=(0,t.jsxs)("div",{className:m,children:[e.children,o]}),l[3]=e.children,l[4]=m,l[5]=o,l[6]=i):i=l[6],l[7]!==e.id||l[8]!==e.onClickAction||l[9]!==c||l[10]!==u||l[11]!==i?(a=(0,t.jsx)("div",{ref:c,onClick:e.onClickAction,id:e.id,className:u,children:i}),l[7]=e.id,l[8]=e.onClickAction,l[9]=c,l[10]=u,l[11]=i,l[12]=a):a=l[12],l[13]!==e.footnoteSideColumn||l[14]!==e.pageOptions||l[15]!==d||l[16]!==a?(r=(0,t.jsxs)("div",{className:d,children:[a,e.pageOptions,e.footnoteSideColumn]}),l[13]=e.footnoteSideColumn,l[14]=e.pageOptions,l[15]=d,l[16]=a,l[17]=r):r=l[17],r},eB=e=>{let o,i=(0,n.c)(6);if("doc"===((0,r.useEntity)(e.entityID,"page/type")?.data.value||"doc")){let n;return i[0]!==e.entityID||i[1]!==e.zoomedBlock?(n=(0,t.jsx)(eM,{entityID:e.entityID,zoomedBlock:e.zoomedBlock}),i[0]=e.entityID,i[1]=e.zoomedBlock,i[2]=n):n=i[2],n}return i[3]!==e.entityID||i[4]!==e.first?(o=(0,t.jsx)(s.Canvas,{entityID:e.entityID,first:e.first}),i[3]=e.entityID,i[4]=e.first,i[5]=o):o=i[5],o},eM=e=>{let o,i,a,l,s,d,u=(0,n.c)(16),{rootEntity:m}=(0,r.useReplicache)(),p=(0,f.useCardBorderHidden)(e.entityID),h=(0,r.useEntity)(m,"theme/card-background-image"),x=(0,r.useEntity)(m,"theme/card-background-image-repeat"),y=(0,r.useEntity)(m,"theme/card-background-image-opacity"),g=(0,r.useEntity)(e.entityID,"theme/card-background-image"),b=(0,r.useEntity)(e.entityID,"theme/card-background-image-repeat"),v=(0,r.useEntity)(e.entityID,"theme/card-background-image-opacity"),C=g||h,D=g?b?.data?.value:x?.data.value,j=g?v?.data.value:y?.data.value||1;return u[0]!==C||u[1]!==j||u[2]!==D||u[3]!==p?(o=p?null:(0,t.jsx)("div",{className:`pageBackgroun
23d 24 absolute top-0 left-0 right-0 bottom-0 25 pointer-events-none 26 rounded-lg 27 `,style:{backgroundImage:C?`url(${C.data.src}), url(${C.data.fallback})`:void 0,backgroundRepeat:D?"repeat":"no-repeat",backgroundPosition:"center",backgroundSize:D||"cover",opacity:C?.data.src?j:1}}),u[0]=C,u[1]=j,u[2]=D,u[3]=p,u[4]=o):o=u[4],u[5]!==e.entityID||u[6]!==e.zoomedBlock?(i=e.zoomedBlock?(0,t.jsx)(eR,{pageEntity:e.entityID,entityID:e.zoomedBlock}):null,u[5]=e.entityID,u[6]=e.zoomedBlock,u[7]=i):i=u[7],u[8]!==e.entityID?(a=(0,t.jsx)(c.Blocks,{entityID:e.entityID}),u[8]=e.entityID,u[9]=a):a=u[9],u[10]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)(_,{}),s=(0,t.jsx)("div",{className:"h-4 sm:h-6 w-full"}),u[10]=l,u[11]=s):(l=u[10],s=u[11]),u[12]!==o||u[13]!==i||u[14]!==a?(d=(0,t.jsxs)(t.Fragment,{children:[o,i,a,l,s]}),u[12]=o,u[13]=i,u[14]=a,u[15]=d):d=u[15],d},eR=e=>{let a,l,s,c,m,p=(0,n.c)(12),[h]=(0,r.useReferenceToEntity)("card/block",e.entityID),f=(0,i.useUIState)(eA),x=(0,i.useIsPageFocused)(e.pageEntity),g=h?.entity;return p[0]!==x||p[1]!==g||p[2]!==e.pageEntity||p[3]!==f?(a=()=>{if(x)return(0,u.addShortcut)({metaKey:!0,shift:!0,key:["H","h"],skipIfDefaultPrevented:!0,handler:()=>{g&&g!==e.pageEntity?(0,y.zoomIntoBlock)(e.pageEntity,g):f(e.pageEntity)}})},l=[x,g,e.pageEntity,f],p[0]=x,p[1]=g,p[2]=e.pageEntity,p[3]=f,p[4]=a,p[5]=l):(a=p[4],l=p[5]),(0,o.useEffect)(a,l),p[6]!==e.pageEntity||p[7]!==f?(s=t=>{t.preventDefault(),f(e.pageEntity)},p[6]=e.pageEntity,p[7]=f,p[8]=s):s=p[8],p[9]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(d.GoBackTiny,{}),p[9]=c):c=p[9],p[10]!==s?(m=(0,t.jsx)("div",{className:"px-3 sm:px-4 pt-2 sm:pt-3",children:(0,t.jsxs)("button",{className:"flex items-center gap-1 text-sm text-tertiary hover:text-accent-contrast",onClick:s,children:[c," back to full document"]})}),p[10]=s,p[11]=m):m=p[11],m};function eA(e){return e.zoomOutOfBlock}e.s(["Page",0,function(e){var o;let s,c,d,u,f,y,C,D,S,N,E,P,_,R,A,F,$,O,H,U,V,z,Z,W,K=(0,n.c)(66),{rep:Y}=(0,r.useReplicache)(),q=(0,h.useLeafletPublicationPage)();K[0]!==e.entityID?(s=t=>t.zoomedBlocks[e.entityID],K[0]=e.entityID,K[1]=s):s=K[1];let G=(0,i.useUIState)(s),J=(0,i.useIsPageFocused)(e.entityID),X=(0,r.useEntity)(e.entityID,"page/type")?.data.value||"doc",Q=(0,v.useDrawerOpen)(e.entityID),ee=(o=e.entityID,(Z=(0,n.c)(6))[0]!==o?(U=e=>(function(e,t){let n=(0,j.getBlocksFromMirror)(e,t),o=e.eav(t,"canvas/block").map(e=>({value:e.data.value,position:e.data.position})).toSorted((e,t)=>e.position.y===t.position.y?e.position.x-t.position.x:e.position.y-t.position.y),i=[...n.map(e=>({value:e.entityID})),...o],a=[],r={},l=1;for(let t of i)for(let n of e.eav(t.value,"block/footnote").toSorted((e,t)=>e.data.position>t.data.position?1:-1))a.push({footnoteEntityID:n.data.value,blockID:t.value,index:l}),r[n.data.value]=l,l++;return{pageID:t,footnotes:a,indexMap:r}})(e,o),V=[o],Z[0]=o,Z[1]=U,Z[2]=V):(U=Z[1],V=Z[2]),W=(0,I.useMirrorQuery)(k,U,V),Z[3]!==W||Z[4]!==o?(z=W||{pageID:o,footnotes:[],indexMap:{}},Z[3]=W,Z[4]=o,Z[5]=z):z=Z[5],z),et=function(e){let t,o,i=(0,n.c)(6),{permissions:a}=(0,L.useEntitySetContext)();i[0]!==e?(t=t=>(function(e,t){let n=(0,j.getBlocksFromMirror)(e,t),o=e.eav(t,"canvas/block").map(e=>({value:e.data.value,position:e.data.position})).toSorted((e,t)=>e.position.y===t.position.y?e.position.x-t.position.x:e.position.y-t.position.y),i=[...n.map(e=>({value:e.entityID})),...o],a=[];for(let t of i)for(let n of e.eav(t.value,"block/comment").toSorted((e,t)=>e.data.position>t.data.position?1:-1))a.push({commentEntityID:n.data.value,blockID:t.value});return{pageID:t,comments:a}})(t,e),o=[e],i[0]=e,i[1]=t,i[2]=o):(t=i[1],o=i[2]);let r=(0,I.useMirrorQuery)(B,t,o);if(!a.write||!r){let t,n;return i[3]===Symbol.for("react.memo_cache_sentinel")?(t=[],i[3]=t):t=i[3],i[4]!==e?(n={pageID:e,comments:t},i[4]=e,i[5]=n):n=i[5],n}return r}(e.entityID);K[2]!==e.entityID?(c=t=>{let n=t.openPages;return 0===n.length||n[n.length-1]===e.entityID},K[2]=e.entityID,K[3]=c):c=K[3];let en=(0,i.useUIState)(c),eo="doc"===X&&!Q&&en,ei=e.entityID;K[4]!==J||K[5]!==e.entityID||K[6]!==Y?(d=t=>{!t.defaultPrevented&&Y&&(J||(0,x.focusPage)(e.entityID,Y))},K[4]=J,K[5]=e.entityID,K[6]=Y,K[7]=d):d=K[7],K[8]!==e.entityID?(u=a.elementId.page(e.entityID),K[8]=e.entityID,K[9]=u):u=K[9];let ea=!!Q;return K[10]!==J||K[11]!==e.entityID||K[12]!==e.first?(f=(0,t.jsx)(g.PageOptions,{entity
27ID:e.entityID,first:e.first,isFocused:J}),K[10]=J,K[11]=e.entityID,K[12]=e.first,K[13]=f):f=K[13],K[14]!==e.entityID||K[15]!==e.fullPageScroll||K[16]!==eo?(y=(0,t.jsx)(ex,{pageEntityID:e.entityID,visible:eo,fullPageScroll:e.fullPageScroll}),K[14]=e.entityID,K[15]=e.fullPageScroll,K[16]=eo,K[17]=y):y=K[17],K[18]!==X||K[19]!==e.first||K[20]!==q||K[21]!==G?(C=e.first&&"doc"===X&&!q&&!G&&(0,t.jsx)(m.PublicationMetadata,{}),K[18]=X,K[19]=e.first,K[20]=q,K[21]=G,K[22]=C):C=K[22],K[23]!==X||K[24]!==e.first?(D=e.first&&"doc"===X&&(0,t.jsx)(p.InlineVersionBanner,{}),K[23]=X,K[24]=e.first,K[25]=D):D=K[25],K[26]!==e.entityID||K[27]!==e.first||K[28]!==G?(S=(0,t.jsx)(eB,{entityID:e.entityID,first:e.first,zoomedBlock:G}),K[26]=e.entityID,K[27]=e.first,K[28]=G,K[29]=S):S=K[29],K[30]!==J||K[31]!==X||K[32]!==e.flow||K[33]!==e.fullPageScroll||K[34]!==e.header||K[35]!==S||K[36]!==d||K[37]!==u.container||K[38]!==ea||K[39]!==f||K[40]!==y||K[41]!==C||K[42]!==D?(N=(0,t.jsxs)(eT,{onClickAction:d,id:u.container,drawerOpen:ea,isFocused:J,fullPageScroll:e.fullPageScroll,flow:e.flow,pageType:X,pageOptions:f,footnoteSideColumn:y,children:[e.header,C,D,S]}),K[30]=J,K[31]=X,K[32]=e.flow,K[33]=e.fullPageScroll,K[34]=e.header,K[35]=S,K[36]=d,K[37]=u.container,K[38]=ea,K[39]=f,K[40]=y,K[41]=C,K[42]=D,K[43]=N):N=K[43],K[44]!==e.entityID||K[45]!==e.flow?(E=(0,t.jsx)(l.DesktopPageFooter,{pageID:e.entityID,flow:e.flow}),K[44]=e.entityID,K[45]=e.flow,K[46]=E):E=K[46],K[47]!==e.entityID?(P=(0,t.jsx)(T.FootnotePopover,{pageID:e.entityID}),K[47]=e.entityID,K[48]=P):P=K[48],K[49]===Symbol.for("react.memo_cache_sentinel")?(_=(0,t.jsx)(eS.EditorCommentPopover,{}),R=(0,t.jsx)(eD,{}),A=(0,t.jsx)(eL,{}),K[49]=_,K[50]=R,K[51]=A):(_=K[49],R=K[50],A=K[51]),K[52]!==e.entityID?(F=(0,t.jsx)(e_.LinkPopover,{pageID:e.entityID}),K[52]=e.entityID,K[53]=F):F=K[53],K[54]!==et||K[55]!==N||K[56]!==E||K[57]!==P||K[58]!==F?($=(0,t.jsxs)(M.EditorCommentContext.Provider,{value:et,children:[N,E,P,_,R,A,F]}),K[54]=et,K[55]=N,K[56]=E,K[57]=P,K[58]=F,K[59]=$):$=K[59],K[60]!==ee||K[61]!==$?(O=(0,t.jsx)(w.FootnoteContext.Provider,{value:ee,children:$}),K[60]=ee,K[61]=$,K[62]=O):O=K[62],K[63]!==e.entityID||K[64]!==O?(H=(0,t.jsx)(b.CardThemeProvider,{entityID:ei,children:O}),K[63]=e.entityID,K[64]=O,K[65]=H):H=K[65],H},"PageWrapper",0,eT],413458)},497366,e=>{"use strict";var t=e.i(843476),n=e.i(500932),o=e.i(271645),i=e.i(813029),a=e.i(492122),r=e.i(467592),l=e.i(427550),s=e.i(416504),c=e.i(50203),d=e.i(464367),u=e.i(69278),m=e.i(461875),p=e.i(651677);let h=e=>{let{rootEntity:n}=(0,r.useReplicache)(),i=(0,a.useEntitySetContext)().permissions.write,[l,s]=(0,o.useState)("null"),u=(0,r.useEntity)(n,"theme/background-image"),h=(0,r.useEntity)(n,"theme/background-image-repeat");if(!i)return null;let{rep:y}=(0,r.useReplicache)();return(0,o.useMemo)(()=>(0,c.setColorAttribute)(y,e.entityID),[y,e.entityID]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"pageThemeSetter flex flex-row gap-2 px-3 py-1 z-10",children:[(0,t.jsxs)("div",{className:"gap-2 flex font-bold ",children:[(0,t.jsx)(m.PaintSmall,{})," Theme Page"]}),(0,t.jsx)(f,{entityID:e.entityID})]}),(0,t.jsxs)("div",{className:"pageThemeSetterContent bg-bg-leaflet w-80 p-3 pb-0 flex flex-col gap-4 roun
27ded-md -mb-1",style:{backgroundImage:u?`url(${u.data.src})`:void 0,backgroundPosition:"center",backgroundRepeat:h?"repeat":"no-repeat",backgroundSize:h?`calc(${h.data.value}px / 2 )`:"cover"},children:[(0,t.jsx)("div",{className:"pageThemeBG flex flex-col gap-2 h-full text-primary bg-bg-leaflet p-2 rounded-md border border-primary shadow-[0_0_0_1px_rgb(var(--bg-page))]",style:{backgroundColor:"rgba(var(--bg-page), 0.6)"},children:(0,t.jsx)(d.SubpageBackgroundPicker,{entityID:e.entityID,openPicker:l,setOpenPicker:s})}),(0,t.jsx)("div",{className:"flex flex-col z-10",children:(0,t.jsx)(d.PageThemePickers,{entityID:e.entityID,openPicker:l,setOpenPicker:e=>s(e),hideFonts:!0})}),(0,t.jsx)(p.AccentPickers,{entityID:e.entityID,openPicker:l,setOpenPicker:e=>s(e)}),(0,t.jsx)(x,{entityID:e.entityID})]})]})},f=e=>{let o,i=(0,n.c)(3),{rep:a}=(0,r.useReplicache)();return i[0]!==e.entityID||i[1]!==a?(o=(0,t.jsx)(u.ButtonPrimary,{compact:!0,onClick:()=>{a&&a.mutate.retractAttribute({entity:e.entityID,attribute:["theme/primary","theme/card-background","theme/accent-background","theme/accent-text","theme/card-background-image","theme/card-background-image-repeat","theme/card-background-image-opacity","theme/card-border-hidden","canvas/background-pattern"]})},children:"reset"}),i[0]=e.entityID,i[1]=a,i[2]=o):o=i[2],o},x=e=>{let o,i,a,l,s,c,d,u,m=(0,n.c)(17),{rootEntity:p}=(0,r.useReplicache)(),h=(0,r.useEntity)(p,"theme/card-background-image"),f=(0,r.useEntity)(p,"theme/card-background-image-repeat"),x=(0,r.useEntity)(p,"theme/card-background-image-opacity"),y=(0,r.useEntity)(e.entityID,"theme/card-background-image")||h,g=(0,r.useEntity)(e.entityID,"theme/card-background-image-repeat")||f,b=(0,r.useEntity)(e.entityID,"theme/card-background-image-opacity")||x,v=(0,r.useEntity)(p,"theme/card-border-hidden"),C=(0,r.useEntity)(e.entityID,"theme/card-border-hidden"),D=(C||v)?.data.value,j=D?"relative py-2 px-0 border border-transparent":"relative rounded-t-lg p-2 shadow-md text-primary border border-border border-b-transparent";return m[0]!==D?(o=D?void 0:{backgroundColor:"rgba(var(--bg-page), var(--bg-page-alpha))"},m[0]=D,m[1]=o):o=m[1],m[2]!==y||m[3]!==b?.data||m[4]!==g||m[5]!==D?(i=D?void 0:{backgroundImage:y?`url(${y.data.src})`:void 0,backgroundRepeat:g?"repeat":"no-repeat",opacity:b?.data.value||1,backgroundSize:g?.data.value?`calc(${g.data.value}px / 2 )`:"cover"},m[2]=y,m[3]=b?.data,m[4]=g,m[5]=D,m[6]=i):i=m[6],m[7]!==i?(a=(0,t.jsx)("div",{className:"background absolute top-0 right-0 bottom-0 left-0 z-0 rounded-t-lg",style:i}),m[7]=i,m[8]=a):a=m[8],m[9]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("p",{className:"font-bold",children:"Theme Each Page!"}),m[9]=l):l=m[9],m[10]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)("span",{className:"font-bold text-accent-contrast",children:"Leaflet"}),m[10]=s):s=m[10],m[11]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsxs)("small",{className:"",children:["OMG! You can theme each page individually in"," ",s,"!",(0,t.jsx)("br",{})," Buttons and sections appear like:"]}),m[11]=c):c=m[11],m[12]===Symbol.for("react.memo_cache_sentinel")?(d=(0,t.jsxs)("div",{className:"relative",children:[l,c,(0,t.jsxs)("div",{className:"p-2 mt-2 border border-border bg-bg-page rounded-md text-sm flex justify-between items-center font-bold text-secondary",children:["Happy Theming!",(0,t.jsx)("div",{className:"bg-accent-1 text-accent-2 py-0.5 px-2 w-fit text-center text-sm font-bold rounded-md",children:"Button"})]})]}),m[12]=d):d=m[12],m[13]!==j||m[14]!==o||m[15]!==a?(u=(0,t.jsxs)("div",{className:j,style:o,children:[a,d]}),m[13]=j,m[14]=o,m[15]=a,m[16]=u):u=m[16],u};var y=e.i(876082),g=e.i(782963);let b=e=>{let i,a,r,l,s,c,d,u=(0,n.c)(12),m=(0,g.useReadOnlyShareLink)(),{data:p}=(0,y.useLeafletDomains)(),[h,f]=(0,o.useState)(null);u[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{f(window.location.pathname)},a=[],u[0]=i,u[1]=a):(i=u[0],a=u[1]),(0,o.useEffect)(i,a);let x=`${h}?page=${e.entityID}`;u[2]!==x?(r=(0,t.jsx)(g.ShareButton,{text:"Share Edit Link",smokerText:"Edit link copied!",id:"get-page-collab-link",link:x}),u[2]=x,u[3]=r):r=u[3];let b=p?.[0]?`https://${p[0].domain}${p[0].route}?page=${e.entityID}`:void 0,v=`${m}?page=${e.entityID}`;return u[4]!==b||u[5]!==v?(l=(0,t.jsx)(g.ShareButton,{text:"Share View Link",smokerText:"View link copied!",id:"get-page-publish-link",fullLink:b,link:v}),u[4]=b,u[5]=v,u[6]=l):l=u[6],u[7]===Symbol.for("react.memo_cache_sentinel")?(s=(0,t.jsx)("hr",{className:"my-1"}),c=(0,t.jsx)("div",{className:"max-w-xs px-2 pt-1 pb-2 leading-snug text-tertiary text-sm",children:"Link recipients can view this
27subpage and any pages it links to."}),u[7]=s,u[8]=c):(s=u[7],c=u[8]),u[9]!==r||u[10]!==l?(d=(0,t.jsxs)("div",{children:[r,l,s,c]}),u[9]=r,u[10]=l,u[11]=d):d=u[11],d};var v=e.i(417223),C=e.i(133564),D=e.i(681299),j=e.i(233801),I=e.i(960622);let k=e=>{let o,i,a,r,l,s,c=(0,n.c)(10);c[0]!==e?({children:o,secondary:l,className:i,disabled:a,...r}=e,c[0]=e,c[1]=o,c[2]=i,c[3]=a,c[4]=r,c[5]=l):(o=c[1],i=c[2],a=c[3],r=c[4],l=c[5]);let d=(0,I.useCardBorderHidden)(),u=` 28 pageOptionsTrigger 29 shrink-0 30 pt-[2px] h-5 w-5 p-0.5 mx-auto 31 border border-border 32 ${l?"bg-border text-bg-page":"bg-bg-page text-border"} 33 ${a&&"opacity-50"} 34 ${d?"rounded-md":"rounded-b-md sm:rounded-l-none sm:rounded-r-md"} 35 flex items-center justify-center 36 ${i} 37 38 `;return c[6]!==o||c[7]!==r||c[8]!==u?(s=(0,t.jsx)("button",{className:u,...r,children:o}),c[6]=o,c[7]=r,c[8]=u,c[9]=s):s=c[9],s},w=()=>{let e,o,i=(0,n.c)(6),a=(0,v.useUndoState)(),{undoManager:s}=(0,r.useReplicache)();return i[0]!==s||i[1]!==a.canRedo||i[2]!==a.canUndo?(e=a.canUndo&&(0,t.jsxs)("div",{className:"gap-1 flex sm:flex-col",children:[(0,t.jsx)(k,{secondary:!0,onClick:()=>s.undo(),children:(0,t.jsx)(L,{})}),(0,t.jsx)(k,{secondary:!0,onClick:()=>s.redo(),disabled:!a.canRedo,children:(0,t.jsx)(N,{})})]}),i[0]=s,i[1]=a.canRedo,i[2]=a.canUndo,i[3]=e):e=i[3],i[4]!==e?(o=(0,t.jsx)(l.Media,{mobile:!0,children:e}),i[4]=e,i[5]=o):o=i[5],o},S=e=>{let[n,i]=(0,o.useState)("normal"),{permissions:r}=(0,a.useEntitySetContext)();if(!r.write)return null;let{data:l,mutate:c}=(0,y.useLeafletPublicationData)();if(!l||!e.first)return(0,t.jsx)(s.Menu,{align:"end",asChild:!0,onOpenChange:e=>{e||i("normal")},trigger:(0,t.jsx)(k,{className:"!w-8 !h-5 sm:!w-5 sm:!h-8",children:(0,t.jsx)(D.MoreOptionsTiny,{className:"sm:rotate-90"})}),children:"normal"===n?(0,t.jsxs)(t.Fragment,{children:[!e.first&&(0,t.jsxs)(s.MenuItem,{onSelect:e=>{e.preventDefault(),i("share")},children:[(0,t.jsx)(j.ShareSmall,{})," Share Page"]}),!l&&(0,t.jsxs)(s.MenuItem,{onSelect:e=>{e.preventDefault(),i("theme")},children:[(0,t.jsx)(m.PaintSmall,{})," Theme Page"]})]}):"theme"===n?(0,t.jsx)(h,{entityID:e.entityID}):"share"===n?(0,t.jsx)(b,{entityID:e.entityID}):null})},L=()=>{let e,o=(0,n.c)(1);return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M5.98775 3.14543C6.37828 2.75491 6.37828 2.12174 5.98775 1.73122C5.59723 1.34069 4.96407 1.34069 4.57354 1.73122L1.20732 5.09744C0.816798 5.48796 0.816798 6.12113 1.20732 6.51165L4.57354 9.87787C4.96407 10.2684 5.59723 10.2684 5.98775 9.87787C6.37828 9.48735 6.37828 8.85418 5.98775 8.46366L4.32865 6.80456H9.6299C12.1732 6.80456 13.0856 8.27148 13.0856 9.21676C13.0856 9.84525 12.8932 10.5028 12.5318 10.9786C12.1942 11.4232 11.6948 11.7367 10.9386 11.7367H9.43173C8.87944 11.7367 8.43173 12.1844 8.43173 12.7367C8.43173 13.2889 8.87944 13.7367 9.43173 13.7367H10.9386C12.3587 13.7367 13.4328 13.0991 14.1246 12.1883C14.7926 11.3086 15.0856 10.2062 15.0856 9.21676C15.0856 6.92612 13.0205 4.80456 9.6299 4.80456L4.32863 4.80456L5.98775 3.14543Z",fill:"currentColor"})}),o[0]=e):e=o[0],e},N=()=>{let e,o=(0,n.c)(1);return o[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,t.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M10.0122 3.14543C9.62172 2.75491 9.62172 2.12174 10.0122 1.73122C10.4028 1.34069
3811.0359 1.34069 11.4265 1.73122L14.7927 5.09744C15.1832 5.48796 15.1832 6.12113 14.7927 6.51165L11.4265 9.87787C11.0359 10.2684 10.4028 10.2684 10.0122 9.87787C9.62172 9.48735 9.62172 8.85418 10.0122 8.46366L11.6713 6.80456H6.3701C3.82678 6.80456 2.91443 8.27148 2.91443 9.21676C2.91443 9.84525 3.10681 10.5028 3.46817 10.9786C3.8058 11.4232 4.30523 11.7367 5.06143 11.7367H6.56827C7.12056 11.7367 7.56827 12.1844 7.56827 12.7367C7.56827 13.2889 7.12056 13.7367 6.56827 13.7367H5.06143C3.6413 13.7367 2.56723 13.0991 1.87544 12.1883C1.20738 11.3086 0.914429 10.2062 0.914429 9.21676C0.914429 6.92612 2.97946 4.80456 6.3701 4.80456L11.6714 4.80456L10.0122 3.14543Z",fill:"currentColor"})}),o[0]=e):e=o[0],e};e.s(["PageOptionButton",0,k,"PageOptions",0,e=>{let o,a,r,l,s=(0,n.c)(11);if((0,y.useLeafletPublicationPage)())return null;let c=`pageOptions w-fit z-10 39 ${e.isFocused?"block":"sm:hidden block"} 40 absolute sm:-right-[19px] right-3 sm:top-3 top-0 41 flex sm:flex-col flex-row-reverse gap-1 items-start`;s[0]!==e.entityID||s[1]!==e.first?(o=!e.first&&(0,t.jsx)(k,{secondary:!0,onClick:()=>{i.useUIState.getState().closePage(e.entityID)},children:(0,t.jsx)(C.CloseTiny,{})}),s[0]=e.entityID,s[1]=e.first,s[2]=o):o=s[2];let d=!!e.first;return s[3]!==e.entityID||s[4]!==d?(a=(0,t.jsx)(S,{entityID:e.entityID,first:d}),s[3]=e.entityID,s[4]=d,s[5]=a):a=s[5],s[6]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(w,{}),s[6]=r):r=s[6],s[7]!==c||s[8]!==o||s[9]!==a?(l=(0,t.jsxs)("div",{className:c,children:[o,a,r]}),s[7]=c,s[8]=o,s[9]=a,s[10]=l):l=s[10],l}],497366)},795122,484575,e=>{"use strict";var t=e.i(843476),n=e.i(727378),o=e.i(111176),i=e.i(103136),a=e.i(814649),r=e.i(876082),l=e.i(467592),s=e.i(789606),c=e.i(227086);e.s(["PostSettings",0,function(){let{data:e,normalizedPublication:d,normalizedDocument:u}=(0,r.useLeafletPublicationData)(),{rep:m}=(0,l.useReplicache)(),p=(0,s.useSubscribe)(m,e=>e.get("post_preferences"));if(!e)return null;let h=!!e.doc;if(!e.publications&&!h)return null;let f=d?.preferences,x=p?.showInDiscover??u?.preferences?.showInDiscover??!0,y=p?.showComments??f?.showComments??!0,g=p?.showMentions??f?.showMentions??!0,b=p?.showRecommends??f?.showRecommends??!0,v=(e,t)=>{let n=p||{};m?.mutate.updatePublicationDraft({preferences:{...n,[e]:t}})},C=(0,c.useIsMobile)();return(0,t.jsx)(a.Popover,{asChild:!0,side:C?"top":"right",align:"start",className:"max-w-xs w-[1000px]",trigger:(0,t.jsx)(n.ActionButton,{icon:(0,t.jsx)(o.SettingsSmall,{}),label:"Settings"}),children:(0,t.jsxs)("div",{className:"text-primary flex flex-col",children:[(0,t.jsx)("h3",{className:"pb-2",children:"Settings for this post"}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[h&&(0,t.jsx)(i.ToggleWithLabel,{toggle:x,onToggle:()=>v("showInDiscover",!x),label:"Show in Discover",helpText:"List this post in Leaflet's Discover feed and other\n standard.site reader feeds"}),e.publications&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("hr",{}),(0,t.jsx)(i.ToggleWithLabel,{toggle:b,onToggle:()=>v("showRecommends",!b),label:"Show Recommends",helpText:"Allow readers to recommend/like your post"}),(0,t.jsx)("hr",{}),(0,t.jsx)(i.ToggleWithLabel,{toggle:y,onToggle:()=>v("showComments",!y),label:"Show Comments",helpText:"Allow readers to comment on your post"}),(0,t.jsx)("hr",{}),(0,t.jsx)(i.ToggleWithLabel,{toggle:g,onToggle:()=>v("showMentions",!g),label:"Show Mentions",helpText:"Display Bluesky posts that mention this post"})]})]})]})})}],795122);var d=e.i(500932),u=e.i(271645),m=e.i(522016),p=e.i(283599),h=e.i(857592);let f=e=>{let n,o,i=(0,d.c)(3);return i[0]===Symbol.for("react.memo_cache_sentinel")?(n=(0,t.jsx)("path",{d:"M4.01171 3.7442C4.17069 2.17328 5.61482 1.05288 7.17772 1.29597L12.0859 2.06061C12.7646 2.16628 13.38 2.52178 13.8096 3.05768L15.1894 4.77935L18.5449 5.29107C19.1051 5.37653 19.6096 5.67808 19.9502 6.13091L22.4834 9.49906C22.8419 9.97593 22.9885 10.58 22.8877 11.168L21.2168 21.0332C21.0169 22.1972 19.9215 22.9884 18.7539 22.8105L10.749 21.5889C9.70084 21.429 8.94565 20.544 8.91015 19.5244C8.24855 19.9043 7.39557 20.206 6.38085 19.9102C5.77509 19.7335 5.3669 19.3883 5.10741 18.9561C4.86937 18.5595 4.77933 18.1227 4.72069 17.8174
41C4.69948 17.7069 4.67344 17.1727 4.53417 17.1553C4.25061 17.12 3.91725 17.2923 3.6455 17.3574C3.09919 17.4883 2.43824 17.5174 1.64061 17.0625C1.0341 16.7165 0.713199 16.0765 0.794912 15.3838C0.865196 14.7899 1.19517 14.1921 1.60351 13.6524C2.46098 12.5191 3.12835 10.9501 3.37792 9.3477C3.53803 8.3192 3.81734 5.66645 4.01171 3.7442ZM16.3506 6.47368C16.4958 6.87874 16.5487 7.31365 16.499 7.74516C16.2038 10.3108 16.0562 13.0894 15.6484 15.709C15.4779 16.8041 15.2167 17.741 14.834 18.4248C14.4521 19.1071 13.8548 19.6844 12.998 19.6846C12.0777 19.6846 11.5971 19.065 11.3437 18.7793C11.1567 18.5684 10.8904 18.2741 10.5693 18.415L10.418 19.3359C10.357 19.7028 10.607 20.0501 10.9746 20.1064L18.9795 21.3271C19.3389 21.382 19.6766 21.1386 19.7383 20.7803L21.4082 10.9161L21.4092 10.9151C21.4402 10.734 21.3945 10.5473 21.2842 10.4004L18.7519 7.03228C18.6471 6.89283 18.4908 6.80078 18.3183 6.77446L16.3506 6.47368ZM6.94628 2.77839C6.23599 2.66815 5.57761 3.17765 5.50487 3.89557C5.31243 5.79877 5.02818 8.5 4.86034 9.57817C4.57498 11.4108 3.81584 13.2149 2.79979 14.5576C2.45043 15.0194 2.30792 15.3596 2.28417 15.5606C2.23247 16.0015 3.03361 15.962 3.29491 15.8994C3.77145 15.7852 4.21671 15.6039 4.72069 15.667C5.24437 15.7326 5.68237 16.0412 5.91405 16.5156C6.16826 17.0368 6.09682 17.6888 6.39354 18.1836C6.84443 18.9347 8.02596 18.3419 8.52636 17.9961C9.17638 17.5469 9.84076 16.8801 10.6797 16.8799C11.6511 16.8801 12.1565 17.4343 12.4668 17.7842C12.7916 18.1504 12.8465 18.1845 12.9971 18.1846C13.075 18.1846 13.268 18.1503 13.5244 17.6924C13.7801 17.2355 14.0067 16.5016 14.166 15.4785C14.5715 12.8737 14.696 10.2916 15.0088 7.57329C15.0488 7.22514 14.9509 6.88039 14.7392 6.61626L12.6387 3.99518C12.4435 3.75181 12.1637 3.5901 11.8555 3.54205L6.94628 2.77839ZM11.4307 9.12504C12.4187 9.19767 12.804 10.1745 12.7402 11.045C12.6823 11.8333 12.301 12.8369 11.3398 12.7666C10.3752 12.6957 9.77903 11.7502 9.85546 10.833C9.91631 10.0082 10.4939 9.05639 11.4307 9.12504ZM18.166 7.1231C18.5753 7.18681 18.8557 7.57026 18.792 7.97954L18.5283 9.67192C18.512 9.77811 18.5852 9.87804 18.6914 9.89457L20.3135 10.1475C20.7227 10.2112 21.0032 10.5947 20.9394 11.0039C20.8754 11.4128 20.492 11.6926 20.083 11.6289L18.4599 11.377C17.5354 11.2329 16.9023 10.366 17.0459 9.44145L17.3096 7.74809C17.3734 7.33903 17.7569 7.0595 18.166 7.1231ZM11.2685 10.4453C11.1952 10.5368 11.1223 10.697 11.1035 10.9073C11.1081 11.2232 11.1906 11.368 11.2402 11.4268C11.4514 11.6768 11.4839 11.0795 11.4932 10.9541C11.499 10.8746 11.4849 10.176 11.2685 10.4453ZM7.14647 8.34477C8.04113 8.49388 8.29901 9.39399 8.17479 10.1758C8.0121 11.1994 6.71522 11.939 5.88866 11.1582C5.44947 10.7432 5.44404 10.0942 5.51659 9.53617C5.62192 8.72779 6.36147 8.24268 7.14647 8.34477ZM6.75585 9.69731C6.74619 9.77162 6.65283 10.339 6.82323 10.1895C6.94853 10.0791 6.96069 9.89774 6.95995 9.74125C6.95907 9.57007 6.78074 9.50754 6.75585 9.69731ZM11.7676 3.84186C12.1767 3.90556 12.457 4.2892 12.3935 4.6983L12.1387 6.33697C12.1174 6.47338 12.2112 6.60088 12.3476 6.62212L13.915 6.86626C14.3242 6.92996 14.6045 7.31357 14.541 7.7227C14.4773 8.13196 14.0938 8.41235 13.6846 8.34868L12.1162 8.10454C11.1615 7.95576 10.5078 7.06127 10.6562 6.1065L10.9111 4.46783C10.975 4.05888 11.3586 3.77844 11.7676 3.84186Z",fill:"currentColor"}),i[0]=n):n=i[0],i[1]!==e?(o=(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:n}),i[1]=e,i[2]=o):o=i[2],o};var x=e.i(784192),y=e.i(69278),g=e.i(788613),b=e.i(124851),v=e.i(793610),C=e.i(101065),D=e.i(338448),j=e.i(794900),I=e.i(95187);let k=(0,I.createServerReference)("40cce26295b13137f38a154f1a68a2c505dc20563f",I.callServer,void 0,I.findSourceMapURL,"getVersioningAccess"),w=(0,I.createServerReference)("40bb347823a7802a60146aecabe1b83981b21e299e",I.callServer,void 0,I.findSourceMapURL,"getVersions"),S=(0,I.createServerReference)("60cd08636880389dc9a9bf102eaabd1e22977076c1",I.callServer,void 0,I.findSourceMapURL,"saveVersion");function L(e){let[n,o]=(0,u.useState)(""),[i,a]=(0,u.useState)(!1),r=(0,v.useToaster)();return(0,t.jsxs)("form",{className:"flex flex-col gap-2 items-center light-container p-3",onSubmit:async t=>{if(t.preventDefault(),!i){a(!0);try{await e.flush();let t=await S(e.tokenId,n);if(!t.ok){var l;return l=t.error,void r({content:l,type:"error"})}if(t.value.unchanged)return void r({content:"No changes since the last version",type:"info"});o(""),e.onSaved()}finally{a(!1)}}},children:[(0,t.jsx)(x.Input,{autoFocus:!0,className:"input-with-border grow min-w-0
41w-full",placeholder:"Version name (optional)",value:n,maxLength:120,onChange:e=>o(e.currentTarget.value)}),(0,t.jsx)(y.ButtonPrimary,{type:"submit",disabled:i,fullWidth:!0,className:"shrink-0",compact:!0,children:i?(0,t.jsx)(g.DotLoader,{}):"Save Version"})]})}function N(e){let n,o,i,a,r,l,s=(0,d.c)(17),{version:c}=e;s[0]===Symbol.for("react.memo_cache_sentinel")?(n={month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"numeric",hour12:!0},s[0]=n):n=s[0];let u=(0,D.useLocalizedDate)(c.created_at,n),p=Date.now()-new Date(c.created_at).getTime()<864e5,h=`/${e.tokenId}/versions/${c.id}`,f=c.name||("pre_restore"===c.kind?"Backup before restore":u);s[1]!==f?(o=(0,t.jsx)("div",{className:"font-bold truncate",children:f}),s[1]=f,s[2]=o):o=s[2],s[3]!==u||s[4]!==c.created_at||s[5]!==p?(i=p?(0,j.timeAgo)(c.created_at):u,s[3]=u,s[4]=c.created_at,s[5]=p,s[6]=i):i=s[6];let x=c.author_name||"Someone";return s[7]!==u||s[8]!==i||s[9]!==x?(a=(0,t.jsxs)("div",{className:"text-tertiary font-normal italic text-sm truncate",title:u,children:[i," ·"," ",x]}),s[7]=u,s[8]=i,s[9]=x,s[10]=a):a=s[10],s[11]!==o||s[12]!==a?(r=(0,t.jsxs)("div",{className:" menuItem px-3! flex flex-col gap-0! leading-snug min-w-0",children:[o,a]}),s[11]=o,s[12]=a,s[13]=r):r=s[13],s[14]!==h||s[15]!==r?(l=(0,t.jsx)(m.default,{href:h,className:"no-underline! ",children:r}),s[14]=h,s[15]=r,s[16]=l):l=s[16],l}e.s(["VersionHistory",0,function(){let e,o,i,a,r,s,c,x,y,v,D,j,I=(0,d.c)(31),{permission_token:S,rep:E}=(0,l.useReplicache)(),[P,_]=(0,u.useState)(!1),T=S.id;I[0]!==E?(e=async()=>{await (0,C.flushPendingTextWrites)(),await E?.push()},I[0]=E,I[1]=e):e=I[1];let B=e;I[2]!==T?(o=()=>k(T),I[2]=T,I[3]=o):o=I[3];let{data:M}=(0,p.default)(`version-access-${T}`,o),R=M?.enabled&&(P||!M.canModify);I[4]!==T?(i=async()=>{let e=await w(T);return e.ok?e.value:[]},I[4]=T,I[5]=i):i=I[5];let{data:A,mutate:F}=(0,p.default)(R?`versions-${T}`:null,i);return M?.canModify||A?.length?(I[6]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)(n.ActionButton,{icon:(0,t.jsx)(f,{}),label:"Versions"}),I[6]=a):a=I[6],I[7]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("h3",{children:"Version History"}),I[7]=r):r=I[7],I[8]!==A?(s=void 0===A?null:0===A.length?(0,t.jsx)(t.Fragment,{children:"Saved versions of your document will appear here. You can restore or copy them later."}):"Select a version to view it.",I[8]=A,I[9]=s):s=I[9],I[10]!==M?.canModify?(c=!M?.canModify&&(0,t.jsxs)(t.Fragment,{children:[" ","To save versions, upgrade to"," ",(0,t.jsx)(m.default,{href:"/upgrade",children:"Leaflet Pro"}),"!"]}),I[10]=M?.canModify,I[11]=c):c=I[11],I[12]!==s||I[13]!==c?(x=(0,t.jsxs)("div",{className:"flex flex-col gap-0 leading-snug",children:[r,(0,t.jsxs)("div",{className:"text-sm text-tertiary",children:[s,c]})]}),I[12]=s,I[13]=c,I[14]=x):x=I[14],I[15]!==M?.canModify||I[16]!==B||I[17]!==F||I[18]!==T?(y=M?.canModify&&(0,t.jsx)(L,{tokenId:T,flush:B,onSaved:F}),I[15]=M?.canModify,I[16]=B,I[17]=F,I[18]=T,I[19]=y):y=I[19],I[20]!==M?.canModify||I[21]!==T||I[22]!==A?(v=void 0===A?(0,t.jsxs)("div",{className:"flex items-center justify-center gap-1 text-tertiary italic text-sm py-8",children:[(0,t.jsx)("span",{children:"loading"}),(0,t.jsx)(g.DotLoader,{})]}):0===A.length?(0,t.jsxs)(b.EmptyState,{container:"light",children:[(0,t.jsx)("div",{className:"font-bold",children:"No versions yetâ¦"}),(0,t.jsx)("div",{children:M?.canModify?"Once you've saved a version of this document, you can view and restore versions here.":"Once a version of this document has been saved, you can view it here."})]}):(0,t.jsx)(t.Fragment,{children:(0,t.jsx)("div",{className:"flex flex-col gap-0.5",children:A.map(e=>(0,t.jsxs)(u.Fragment,{children:[(0,t.jsx)(N,{version:e,tokenId:T}),(0,t.jsx)("hr",{className:"last:hidden"})]},e.id))})}),I[20]=M?.canModify,I[21]=T,I[22]=A,I[23]=v):v=I[23],I[24]!==x||I[25]!==y||I[26]!==v?(D=(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[x,y,v]}),I[24]=x,I[25]=y,I[26]=v,I[27]=D):D=I[27],I[28]!==P||I[29]!==D?(j=(0,t.jsx)(h.Modal,{asChild:!0,sheetOnMobile:!0,className:"sm:w-[1000px] max-w-md w-full",open:P,onOpenChange:_,trigger:a,children:D}),I[28]=P,I[29]=D,I[30]=j):j=I[30],j):null}],484575)},129362,525507,e=>{"use strict";var t=e.i(843476),n=e.i(500932),o=e.i(271645),i=e.i(743756),a=e.i(988314),r=e.i(813029),l=e.i(186336),s=e.i(581869),c=e.i(859015),d=e.i(839028),u=e.i(543291);let m=e=>{let o,a,r,l,s,m=(0,n.c)(9);return m[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(d.TextMarkButtons,{}),m[0]=o):o=m[0],m[1]!==e.setToolbarState?(a=(0,t.jsx)(u.HighlightButton,{setToolbarState:e.setToolbarState}),m[1]=e.setToolbarState,m[2]=a):a=m[2],m[3]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(c.Separator,{classname:"h-6!"}),m[3]=r):r=m[3],m[4]!==e.setToolbarState?(l=(0,t.jsx)(i.LinkButton,{setToolbarState:e.setToolbarState}),m[4]=e.setToolbarState,m[5]=l):l=m[5],m[6]!==a||m[7]!==l?(s=(0,t.jsxs)(t.Fragment,{children:[o,a,r,l]}),m[6]=a,m[7]=l,m[8]=s):s=m[8],s};var p=e.i(227086),h=e.i(133564),f=e.i(887710);e.s(["FootnoteToolbar",0,e=>{let c,d,x,y,g,b,v,C,D,j=(0,n.c)(21),[I,k]=(0,o.useState)("default");j[0]!==I?(c=()=>
41{if("default"!==I)return;let e=(0,s.addShortcut)({metaKey:!0,key:"k",handler:()=>{k("link")}});return()=>{e()}},d=[I],j[0]=I,j[1]=c,j[2]=d):(c=j[1],d=j[2]),(0,o.useEffect)(c,d);let w=(0,p.useIsMobile)(),S=`toolbar flex gap-2 items-center justify-between w-full 42 ${w?"":"h-[26px]"}`;return j[3]!==e.pageID||j[4]!==I?(x="default"===I?(0,t.jsx)(m,{setToolbarState:k}):"highlight"===I?(0,t.jsx)(u.HighlightToolbar,{pageID:e.pageID,onClose:()=>k("default")}):"link"===I?(0,t.jsx)(i.InlineLinkToolbar,{onClose:()=>{let e=r.useUIState.getState().focusedEntity;e&&a.useEditorStates.getState().editorStates[e.entityID]?.view?.focus(),k("default")}}):null,j[3]=e.pageID,j[4]=I,j[5]=x):x=j[5],j[6]!==x?(y=(0,t.jsx)("div",{className:"toolbarOptions flex gap-1 sm:gap-[6px] items-center grow",children:x}),j[6]=x,j[7]=y):y=j[7],j[8]!==e.pageID||j[9]!==I?(g=t=>{t.preventDefault(),"default"===I?r.useUIState.setState(()=>({focusedEntity:{entityType:"page",entityID:e.pageID},selectedBlocks:[]})):k("default")},j[8]=e.pageID,j[9]=I,j[10]=g):g=j[10],j[11]===Symbol.for("react.memo_cache_sentinel")?(b=(0,t.jsx)(h.CloseTiny,{}),j[11]=b):b=j[11],j[12]!==g?(v=(0,t.jsx)("button",{className:"toolbarBackToDefault hover:text-accent-contrast",onMouseDown:g,children:b}),j[12]=g,j[13]=v):v=j[13],j[14]!==S||j[15]!==y||j[16]!==v?(C=(0,t.jsx)(l.Provider,{children:(0,t.jsxs)("div",{className:S,children:[y,v]})}),j[14]=S,j[15]=y,j[16]=v,j[17]=C):C=j[17],j[18]!==e.pageID||j[19]!==C?(D=(0,t.jsx)(f.ToolbarPageTypeProvider,{pageID:e.pageID,children:C}),j[18]=e.pageID,j[19]=C,j[20]=D):D=j[20],D}],129362),e.s(["FooterLayout",0,function(e){let o,i=(0,n.c)(4),a=` 43 leafletFooter touch-none shrink-0 z-10 44 px-2 pt-1 pb-[max(var(--safe-padding-bottom),16px)] 45 flex justify-between 46 w-fill 47 pwa-padding-x 48 h-[calc(38px+max(var(--safe-padding-bottom),16px))] 49 ${e.noBackground?"bg-bg-page":"bg-[rgba(var(--bg-page),0.5)] border-t border-border-light"} `;return i[0]!==e.children||i[1]!==e.onMouseDown||i[2]!==a?(o=(0,t.jsx)("div",{onMouseDown:e.onMouseDown,className:a,children:e.children}),i[0]=e.children,i[1]=e.onMouseDown,i[2]=a,i[3]=o):o=i[3],o}],525507)},587098,707475,e=>{"use strict";var t=e.i(843476),n=e.i(500932),o=e.i(885718),i=e.i(467592);let a=e=>{let o,i,a,r,l,s,c=(0,n.c)(12);c[0]!==e?({strokeColor:a,fillColor:i,...o}=e,c[0]=e,c[1]=o,c[2]=i,c[3]=a):(o=c[1],i=c[2],a=c[3]),c[4]!==a?(r=(0,t.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.32215 16.4108C1.57824 17.6533 0.898485 19.0047 0.309311 20.4716C-0.150671 21.6168 0.404821 22.9181 1.55002 23.378C2.69523 23.838 3.99649 23.2825 4.45647 22.1373C4.57293 21.8474 4.68516 21.5618 4.79357 21.2859L4.79458 21.2833C5.20745 20.2328 5.56352 19.3338 5.99429 18.5241C6.47944 18.4978 7.03415 18.4938 7.65963 18.4902L7.73825 18.4898C8.87897 18.4835 10.2533 18.476 11.4384 18.2361C12.6242 17.9961 14.0917 17.4287 14.7404 15.909C14.916 15.4976 15.0941 14.8903 14.9382 14.2734C14.985 14.2734 15.0329 14.2734 15.0821 14.2734C15.1084 14.2734 15.1353 14.2734 15.1626 14.2734C15.7884 14.2738 16.6691 14.2744 17.4563 14.0603C18.3749 13.8104 19.3408 13.2187 19.7646 11.9723C19.9177 11.5219 19.946 11.0489 19.8139 10.6019C19.8544 10.5948 19.8959 10.5875 19.9385 10.58C19.959 10.5764 19.9798 10.5728 20.0009 10.5691C20.5388 10.4751 21.2588 10.3493 21.8739 10.1191C22.4722 9.89531 23.4554 9.39523 23.75 8.24915C23.9179 7.5959 23.9003 6.90435 23.5231 6.2798C23.3663 6.02011 23.1667 5.81564 22.9897 5.66485C23.1546 5.45852 23.3642 5.17147 23.5087 4.85478C23.7592 4.30533 23.8884 3.49804 23.3759 2.70818C22.7942 1.81172 21.7967 1.65512 21.3033 1.61454C20.7902 1.57235 20.2386 1.61742 19.8422 1.65324C19.7884 1.52139 19.7143 1.38273 19.6118 1.24589C19.0616 0.511039 18.208 0.449277 17.7276 0.462196C16.757 0.488299 15.9979 0.918975 15.4491 1.36566C15.1611 1.6001 14.9015 1.86418 14.6773 2.11348C14.2327 1.65325 13.6218 1.42654 13.0163 1.33322C11.8407 1.15205 10.8811 1.94149 10.2041 2.8079C9.36031 3.8879 8.79706 5.14254 8.05202 6.28553C7.78598 6.11247 7.37758 5.92468 6.87391 5.94808C6.04405 5.98662 5.45234 6.54928 5.09562 6.93422C4.47486 7.60409 4.09699 8.64071 3.82812 9.54678C3.53705 10.5277 3.28551 11.6885 3.04921 12.838C2.90284 13.5499 2.87051 13.8888 3.01223 15.1868C2.57773 15.8871 2.66239 15.7879 2.32215 16.4108Z",fill:a}),c[4]=a,c[5]=r):r=c[5];let d=i||"currentColor";return c[6]!==d?(l=(0,t.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.40173 7.68265C7.64462 7.89605 7.92928 8.14615 8.54339 7.93249C8.94492 7.79279 9.46383 6.88268 10.0428 5.86718C10.8892 4.38281 11.8639 2.67329 12.788 2.81571C13.9026 2.9875 13.834 3.60458 13.7812 4.0792C13.7442 4.41212 13.715 4.67494 14.1074 4.66485C14.5071 4.65457 14.896 4.18484 15.3474 3.63974C15.971 2.88678 16.7136 1.99 17.768 1.96164C18.5115 1.94165 18.4998 2.26202 18.4879 2.58691C18.4803 2.79457 18.4726 3.00408 18.662 3.12774C18.8486 3.24955 19.3179 3.20699 19.8573 3.15805C20.7221 3.0796 21.7673 2.98479 22.1177 3.52468C22.4257 3.99932 22.0333 4.47107 21.6572 4.92323C21.3386 5.30622 21.0317 5.67516 21.172 6.0199C21.2865 6.30118 21.5215 6.45965 21.7518 6.61499C22.1286 6.86906 22.4929 7.11477 22.2973 7.87571C22.0905 8.68031 20.8462 8.89822 19.6799 9.10247C18.7028 9.27359 17.7804 9.43512 17.5686 9.92398C17.4357 10.2306 17.6561 10.3734 17.9031 10.5333C18.1982 10.7245 18.5312 10.9402 18.3445 11.4894C17.908 12.7733 16.4503 12.7733 15.0822 12.7734C13.9079 12.7734 12.7997 12.7734 12.4599 13.5853C12.2637 14.0541 12.5606 14.1368 12.8864 14.2276C13.2852 14.3388 13.7272 14.462 13.3609 15.3201C12.66 16.9622 10.0451 16.9768 7.6513 16.9903C6.77358 16.9952 5.92559 16.9999 5.21259 17.0847C5.1312 17.0944 5.05901 17.1411 5.01636 17.2111C4.36027 18.2876 3.89495 19.4717 3.3986 20.7347C3.28956 21.0122 3.17903 21.2935 3.06464 21.5782C2.91343 21.9547 2.48566 22.1373 2.10919 21.9861C1.73272 21.8349 1.55011 21.4071 1.70132 21.0307C2.26451 19.6285 2.91425 18.3391 3.6247 17.1555C4.78415 15.0203 7.06972 12.4007 9.48667 10.4328C11.6372 8.64231 13.6909 7.30217 16.081 6.28526C16.3802 6.15796 16.2914 5.80807 15.9791 5.89834C13.8592 6.51095 11.9852 7.72607 10.0428 8.95064C7.93016 10.2825 6.15972 12.0837 5.07026 13.3932C4.87817 13.6241 4.45809 13.4342 4.51857 13.14C4.99173 10.8384 5.48007 8.72627 6.19593 7.95378C6.87557 7.22037 7.10812 7.42469 7.40173 7.68265Z",fill:d}),c[6]=d,c[7]=l):l=c[7],c[8]!==o||c[9]!==r||c[10]!==l?(s=(0,t.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...o,children:[r,l]}),c[8]=o,c[9]=r,c[10]=l,c[11]=s):s=c[11],s};e.s(["Watermark",0,e=>{let r,l,s,c,d,u=(0,n.c)(8),{rootEntity:m}=(0,i.useReplicache)(),p=(0,i.useEntity)(m,"theme/page-leaflet-watermark");if(!p?.data.value)return null;let h=e.mobile?"horizontal-tb":"vertical-lr";return u[0]!==h?(r={writingMode:h,backgroundColor:"rgba(var(--bg-page), 0.7)"},u[0]=h,u[1]=r):r=u[1],u[2]===Symbol.for("react.memo_cache_sentinel")?(l=(0,t.jsx)("span",{className:"text-accent-1 font-bold",children:"Leaflet"}),u[2]=l):l=u[2],u[3]!==r?(s=(0,t.jsxs)("div",{className:"sm:hidden group-hover/watermark:block sm:rotate-180 sm:py-1 sm:px-0 px-1 w-max rounded-md h-fit whitespace-nowrap text-sm text-tertiary",style:r,children:["made using ",l]}),u[3]=r,u[4]=s):s=u[4],u[5]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)(a,{strokeColor:o.theme.colors["bg-page"],className:"text-accent-1 sm:text-tertiary group-hover/watermark:text-accent-1"}),u[5]=c):c=u[5],u[6]!==s?(d=(0,t.jsx)("a",{href:"https://about.leaflet.pub",className:"hover:no-underline w-fit italic",target:"_blank",children:(0,t.jsxs)("div",{className:"sm:mb-2 sm:ml-4 group/watermark flex sm:flex-col gap-2 items-center justify-center ",children:[s,c]})}),u[6]=s,u[7]=d):d=u[7],d}],587098);var r=e.i(250209),l=e.i(727378);let s=e=>{let o,i,a=(0,n.c)(3);return a[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)("path",{d:"M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2ZM12.6826 5.96582C12.2921 5.57556 11.659 5.57557 11.2686 5.96582
49L5.94141 11.293C5.55114 11.6834 5.55114 12.3166 5.94141 12.707L11.2686 18.0332L11.3438 18.1025C11.7365 18.4229 12.3165 18.3993 12.6826 18.0332C13.0484 17.6671 13.0712 17.088 12.751 16.6953L12.6826 16.6191L9.06348 13H17.9473L18.0498 12.9951C18.5538 12.9438 18.9471 12.5175 18.9473 12C18.9472 11.4824 18.5538 11.0563 18.0498 11.0049L17.9473 11H9.06152L12.6826 7.37988C13.0729 6.98941 13.0729 6.35629 12.6826 5.96582Z",fill:"currentColor"}),a[0]=o):o=a[0],a[1]!==e?(i=(0,t.jsx)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:o}),a[1]=e,a[2]=i):i=a[2],i};var c=e.i(899169);e.s(["BackToPubButton",0,e=>{let o,i,a=(0,n.c)(3),d=`${(0,r.getBasePublicationURL)(e.publication)}/dashboard`;return a[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(l.ActionButton,{icon:(0,t.jsx)(s,{className:"shrink-0"}),label:"To Pub"}),a[0]=o):o=a[0],a[1]!==d?(i=(0,t.jsx)(c.SpeedyLink,{href:d,className:"hover:no-underline!",children:o}),a[1]=d,a[2]=i):i=a[2],i}],707475)}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.