Socket
Socket
Sign inDemoInstall

@sanity/presentation

Package Overview
Dependencies
Maintainers
55
Versions
134
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/presentation - npm Package Compare versions

Comparing version 1.16.3 to 1.16.4

2

dist/_chunks-es/BroadcastDisplayedDocument.js

@@ -1,1 +0,1 @@

import{memo as e,useEffect as r}from"react";import{d as t}from"./index.js";import{u as o}from"./DisplayedDocumentBroadcaster.js";var u=e((function(e){const u=o(),a=t(!1);return r((()=>{const r=setTimeout((()=>null==u?void 0:u(e.value)),10);return()=>clearTimeout(r)}),[null==a?void 0:a.perspective,e.value,u]),null}));export{u as default};//# sourceMappingURL=BroadcastDisplayedDocument.js.map
import{memo as e,useEffect as r}from"react";import{d as t}from"./index.js";import{u as o}from"./DisplayedDocumentBroadcaster.js";var a=e((function(e){const a=o(),s=t(!1);return r((()=>{const r=setTimeout((()=>a?.(e.value)),10);return()=>clearTimeout(r)}),[s?.perspective,e.value,a]),null}));export{a as default};//# sourceMappingURL=BroadcastDisplayedDocument.js.map

@@ -1,2 +0,2 @@

import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useState as i,useMemo as r,useEffect as o,createContext as s,useContext as a,useCallback as c,createElement as l,useRef as d,useLayoutEffect as u,lazy as p,Suspense as m}from"react";import{useDocumentStore as h,isRecord as f,isReference as v,defineLocaleResourceBundle as y,useTranslation as g,defineDocumentFieldAction as w,useWorkspace as b,pathToString as _,getPublishedId as P,definePlugin as j,isDocumentSchemaType as x}from"sanity";import{ComposeIcon as I,InfoOutlineIcon as T,ChevronRightIcon as S,DesktopIcon as O,WarningOutlineIcon as k,ErrorOutlineIcon as z,MasterDetailIcon as D}from"@sanity/icons";import{Card as A,Flex as E,Box as $,Text as C,Spinner as B,Stack as R,rem as U}from"@sanity/ui";import{styled as H}from"styled-components";import L from"lodash.get";import{Observable as N,switchMap as M,isObservable as Q,from as q,map as F,of as G,combineLatest as J,mergeAll as K,scan as V}from"rxjs";import{useIntentLink as W,useRouter as X,encodeJsonParams as Y,route as Z}from"sanity/router";import{uuid as ee}from"@sanity/uuid";const te=I,ne="presentation",ie="Presentation",re="sanity/structure/comments",oe="presentation",se=3e3,ae="2023-10-16",ce=1e3,le=100,de=2048;function ue(e,t,n){return{...e,[t]:n}}function pe(e={}){return t=>new N((e=>t.subscribe(e))).pipe(M((t=>{const n=(i=t,Object.keys(i)).map((e=>{const n=t[e];return Q(n)?q(n).pipe(F((t=>[e,t]))):G([e,n])}));var i;return e.wait?J(n).pipe(F((e=>e.reduce(((e,[t,n])=>ue(e,t,n)),{})))):q(n).pipe(K(),V(((e,[t,n])=>ue(e,t,n)),{}))})))}const me={locations:[]};function he(e,t,n){if(!e||"object"!=typeof e)return G(e);const i=function(e){return v(e)?e._ref:"_id"in e?e._id:void 0}(e),r=function(e,t){const n=e?{...t,_id:e}:{...t};return"reference"===n._type&&(delete n._type,delete n._ref,delete n._weak,delete n._dataset,delete n._projectId,delete n._strengthenOnPublish),n}(i,e),o=t.filter((e=>!(e[0]in r)));if(i&&o.length){return function(e,t,n){const i=`*[_id==$id][0]{${t.join(", ")}}`,r={id:e};return n.listenQuery(i,r,{perspective:"previewDrafts"})}(i,[...new Set(o.map((e=>e[0])))],n).pipe(M((e=>e?he(e,t,n):G(null))))}const s={};t.forEach((e=>{const[t,...n]=e;s[t]||(s[t]=[]),s[t].push(n)}));const a=Object.keys(s).reduce(((t,i)=>{const r=s[i].filter((e=>e.length>0));return 0===r.length?t[i]=f(e)?e[i]:void 0:t[i]=he(e[i],r,n),t}),r);return G(a).pipe(pe({wait:!0}))}function fe(e){const{id:t,resolvers:n,type:s}=e,a=h(),[c,l]=i(me),d=n&&("function"==typeof n?n:n[s]),[u,p]=i(d?"resolving":"empty"),m=r((()=>{if(d){if("function"==typeof d){const e=d({id:t,type:s},{documentStore:a});return Q(e)?e:G(e)}return"select"in d&&"resolve"in d?function(e,t,n){const{select:i}=t;return he({_type:"reference",_ref:e},Object.values(i).map((e=>String(e).split(".")))||[],n).pipe(F((e=>Object.keys(i).reduce(((t,n)=>(t[n]=L(e,i[n]),t)),{}))),F(t.resolve))}(t,d,a):G(d)}}),[a,t,d,s]);return o((()=>{const e=null==m?void 0:m.subscribe((e=>{l(e||me),p(e?"resolved":"empty")}));return()=>null==e?void 0:e.unsubscribe()}),[m]),{state:c,status:u}}const ve="presentation",ye=y({locale:"en-US",namespace:ve,resources:()=>import("./resources.js")}),ge=s(null);function we(){const e=a(ge);if(!e)throw new Error("Presentation context is missing");return e}const be={positive:T,caution:k,critical:z};function _e(r){const{documentId:o,isResolving:s,options:d,schemaType:u,showPresentationTitle:p}=r,{locations:m,message:h,tone:f}=r.state,v=(null==m?void 0:m.length)||0,{t:y}=g(ve),w=a(ge),[b,_]=i(!1),P=c((()=>{v&&_((e=>!e))}),[v]),j=s?y("locations-banner.resolving.text"):h||y("locations-banner.locations-count",{count:v});return e(A,{padding:1,radius:2,border:!0,tone:f,children:t("div",{style:{margin:-1},children:[!m&&t(E,{align:"flex-start",gap:3,padding:3,children:[f&&e($,{flex:"none",children:e(C,{size:1,children:l(be[f])})}),e($,{flex:1,children:t(C,{size:1,weight:"medium",children:[p&&t(n,{children:[d.title||ie," · "]}),j]})})]}),m&&t(n,{children:[e(A,{as:v?"button":void 0,onClick:P,padding:3,radius:1,tone:"inherit",children:t(E,{gap:3,children:[e($,{flex:"none",children:s?e(B,{size:1}):e(C,{size:1,children:0===v?e(T,{}):e(S,{style:{transform:`rotate(${b?"90deg":0})`,transition:"transform 100ms ease-in-out"}})})}),e($,{flex:1,children:t(C,{size:1,weight:"medium",children:[p&&t(n,{children:[d.title||ie," · "]}),j]})})]})}),e(R,{hidden:!b,marginTop:1,space:1,children:m.map(((t,n)=>e(Pe,{active:(d.name||ne)===(null==w?void 0:w.name)&&t.href===(null==w?void 0:w.params.preview),documentId:o,documentType:u.name,node:t,toolName:d.name||ne},n)))})]})]})})}function Pe(n){const{documentId:i,documentType:r,node:o,active:s,toolName:d}=n,u=a(ge),p=d===function(){try{return we().name}catch{return}}(),m=null==u?void 0:u.navigate,h=W({intent:"edit",params:{id:i,type:r,mode:"presentation",presentation:d,...null==u?void 0:u.structureParams,preview:o.href}}),f=c((()=>{null==m||m({},{preview:o.href})}),[o.href,m]);return l(A,{...p?{}:h,as:"a",key:o.href,onClick:p?f:h.onClick,padding:3,radius:1,pressed:s,tone:"inherit"},t(E,{gap:3,children:[e($,{flex:"none",children:e(C,{size:1,children:e(O,{})})}),t(R,{flex:1,space:2,children:[e(C,{size:1,weight:"medium",children:o.title}),e(C,{muted:!0,size:1,textOverflow:"ellipsis",children:o.href})]})]}))}const je=s(null),xe=H(R)`
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{useState as r,useMemo as i,useEffect as o,createContext as s,useContext as c,useCallback as a,createElement as l,useRef as d,useLayoutEffect as p,lazy as u,Suspense as m}from"react";import{useDocumentStore as h,isRecord as f,isReference as y,defineLocaleResourceBundle as g,useTranslation as v,defineDocumentFieldAction as w,useWorkspace as b,pathToString as _,getPublishedId as P,definePlugin as j,isDocumentSchemaType as x}from"sanity";import{ComposeIcon as I,InfoOutlineIcon as T,ChevronRightIcon as S,DesktopIcon as O,WarningOutlineIcon as k,ErrorOutlineIcon as z,MasterDetailIcon as D}from"@sanity/icons";import{Card as A,Flex as E,Box as $,Text as C,Spinner as B,Stack as R,rem as U}from"@sanity/ui";import{styled as H}from"styled-components";import L from"lodash.get";import{Observable as N,switchMap as M,isObservable as Q,from as q,map as F,of as G,combineLatest as J,mergeAll as K,scan as V}from"rxjs";import{useIntentLink as W,useRouter as X,encodeJsonParams as Y,route as Z}from"sanity/router";import{uuid as ee}from"@sanity/uuid";const te=I,ne="presentation",re="Presentation",ie="sanity/structure/comments",oe="presentation",se=3e3,ce="2023-10-16",ae=1e3,le=100,de=2048;function pe(e,t,n){return{...e,[t]:n}}function ue(e={}){return t=>new N((e=>t.subscribe(e))).pipe(M((t=>{const n=(r=t,Object.keys(r)).map((e=>{const n=t[e];return Q(n)?q(n).pipe(F((t=>[e,t]))):G([e,n])}));var r;return e.wait?J(n).pipe(F((e=>e.reduce(((e,[t,n])=>pe(e,t,n)),{})))):q(n).pipe(K(),V(((e,[t,n])=>pe(e,t,n)),{}))})))}const me={locations:[]};function he(e,t,n){if(!e||"object"!=typeof e)return G(e);const r=function(e){return y(e)?e._ref:"_id"in e?e._id:void 0}(e),i=function(e,t){const n=e?{...t,_id:e}:{...t};return"reference"===n._type&&(delete n._type,delete n._ref,delete n._weak,delete n._dataset,delete n._projectId,delete n._strengthenOnPublish),n}(r,e),o=t.filter((e=>!(e[0]in i)));if(r&&o.length){return function(e,t,n){const r=`*[_id==$id][0]{${t.join(", ")}}`,i={id:e};return n.listenQuery(r,i,{perspective:"previewDrafts"})}(r,[...new Set(o.map((e=>e[0])))],n).pipe(M((e=>e?he(e,t,n):G(null))))}const s={};t.forEach((e=>{const[t,...n]=e;s[t]||(s[t]=[]),s[t].push(n)}));const c=Object.keys(s).reduce(((t,r)=>{const i=s[r].filter((e=>e.length>0));return 0===i.length?t[r]=f(e)?e[r]:void 0:t[r]=he(e[r],i,n),t}),i);return G(c).pipe(ue({wait:!0}))}function fe(e){const{id:t,resolvers:n,type:s}=e,c=h(),[a,l]=r(me),d=n&&("function"==typeof n?n:n[s]),[p,u]=r(d?"resolving":"empty"),m=i((()=>{if(d){if("function"==typeof d){const e=d({id:t,type:s},{documentStore:c});return Q(e)?e:G(e)}return"select"in d&&"resolve"in d?function(e,t,n){const{select:r}=t;return he({_type:"reference",_ref:e},Object.values(r).map((e=>String(e).split(".")))||[],n).pipe(F((e=>Object.keys(r).reduce(((t,n)=>(t[n]=L(e,r[n]),t)),{}))),F(t.resolve))}(t,d,c):G(d)}}),[c,t,d,s]);return o((()=>{const e=m?.subscribe((e=>{l(e||me),u(e?"resolved":"empty")}));return()=>e?.unsubscribe()}),[m]),{state:a,status:p}}const ye="presentation",ge=g({locale:"en-US",namespace:ye,resources:()=>import("./resources.js")}),ve=s(null);function we(){const e=c(ve);if(!e)throw new Error("Presentation context is missing");return e}const be={positive:T,caution:k,critical:z};function _e(i){const{documentId:o,isResolving:s,options:d,schemaType:p,showPresentationTitle:u}=i,{locations:m,message:h,tone:f}=i.state,y=m?.length||0,{t:g}=v(ye),w=c(ve),[b,_]=r(!1),P=a((()=>{y&&_((e=>!e))}),[y]),j=s?g("locations-banner.resolving.text"):h||g("locations-banner.locations-count",{count:y});return e(A,{padding:1,radius:2,border:!0,tone:f,children:t("div",{style:{margin:-1},children:[!m&&t(E,{align:"flex-start",gap:3,padding:3,children:[f&&e($,{flex:"none",children:e(C,{size:1,children:l(be[f])})}),e($,{flex:1,children:t(C,{size:1,weight:"medium",children:[u&&t(n,{children:[d.title||re," · "]}),j]})})]}),m&&t(n,{children:[e(A,{as:y?"button":void 0,onClick:P,padding:3,radius:1,tone:"inherit",children:t(E,{gap:3,children:[e($,{flex:"none",children:s?e(B,{size:1}):e(C,{size:1,children:0===y?e(T,{}):e(S,{style:{transform:`rotate(${b?"90deg":0})`,transition:"transform 100ms ease-in-out"}})})}),e($,{flex:1,children:t(C,{size:1,weight:"medium",children:[u&&t(n,{children:[d.title||re," · "]}),j]})})]})}),e(R,{hidden:!b,marginTop:1,space:1,children:m.map(((t,n)=>e(Pe,{active:(d.name||ne)===w?.name&&t.href===w?.params.preview,documentId:o,documentType:p.name,node:t,toolName:d.name||ne},n)))})]})]})})}function Pe(n){const{documentId:r,documentType:i,node:o,active:s,toolName:d}=n,p=c(ve),u=d===function(){try{return we().name}catch{return}}(),m=p?.navigate,h=W({intent:"edit",params:{id:r,type:i,mode:"presentation",presentation:d,...p?.structureParams,preview:o.href}}),f=a((()=>{m?.({},{preview:o.href})}),[o.href,m]);return l(A,{...u?{}:h,as:"a",key:o.href,onClick:u?f:h.onClick,padding:3,radius:1,pressed:s,tone:"inherit"},t(E,{gap:3,children:[e($,{flex:"none",children:e(C,{size:1,children:e(O,{})})}),t(R,{flex:1,space:2,children:[e(C,{size:1,weight:"medium",children:o.title}),e(C,{muted:!0,size:1,textOverflow:"ellipsis",children:o.href})]})]}))}const je=s(null),xe=H(R)`
min-height: ${U(42)};

@@ -7,2 +7,2 @@

}
`;function Ie(t){var n;const{documentId:i,options:r,schemaType:o}=t,s=a(je),{state:c,status:l}=fe({id:i,resolvers:(null==(n=r.resolve)?void 0:n.locations)||r.locate,type:o.name});if(s&&s.options[0]!==r||"empty"===l)return null;const d=(null==s?void 0:s.options)||[];return e(xe,{marginBottom:5,space:5,children:e(R,{space:2,children:d.map(((t,n)=>e(_e,{documentId:i,isResolving:"resolving"===l,options:t,schemaType:o,showPresentationTitle:d.length>1,state:c},n)))})})}function Te(t){const{children:n,options:o}=t,s=a(je),l=null==s?void 0:s.register,[p,m]=i((()=>[])),h=c((e=>l?l(e):(m((t=>[e].concat(t))),()=>{m((t=>t.filter((t=>t!==e))))})),[l]),f=d(h);f.current=h;const v=r((()=>({options:(null==s?void 0:s.options)||p,register:h})),[p,s,h]);return u((()=>f.current(o)),[o]),e(je.Provider,{value:v,children:n})}const Se=w({name:"presentation/openInStructure",useAction({documentId:e,documentType:t,path:n}){const i=b(),{navigateIntent:o}=X(),s=a(ge),c=r((()=>function(e,t,n){var i;const r=e.map((e=>{var i;return{tool:e,match:null==(i=e.canHandleIntent)?void 0:i.call(e,"edit",{id:t,type:n,mode:"structure"},{})}})),o=r.filter((e=>f(e.match)&&e.match.mode));return o.length>0?o[0].tool:null==(i=r.filter((e=>e.match))[0])?void 0:i.tool}(i.tools,e,t)),[e,t,i.tools]);return{type:"action",hidden:!s||n.length>0||!c,icon:(null==c?void 0:c.icon)||D,title:`Open in ${(null==c?void 0:c.title)||"Structure"}`,onAction(){o("edit",{id:e,type:t,mode:"structure",path:_(n)})},renderAsButton:!0}}});const Oe=["preview","perspective","viewport"];function ke(e,t,n,i){const{id:r,mode:o,path:s,presentation:a,type:c,...l}=t,d={...((null==n?void 0:n._searchParams)||[]).filter((([e])=>Oe.includes(e))).reduce(((e,[t,n])=>({...e,[t]:n})),{}),...l};return"edit"===e&&r?{type:c||"*",id:P(r),path:s,_searchParams:Object.entries(d)}:"create"===e?(d.preview=d.preview||new URLSearchParams(window.location.search).get("preview")||"/",i&&"object"==typeof i&&(d.templateParams=Y(i)),{type:c||"*",id:r||ee(),_searchParams:Object.entries(d)}):{intent:e,params:t,payload:i}}const ze=Z.create("/",{__unsafe_disableScopedSearchParams:!0},[Z.intents("/intent"),Z.create(":type",[Z.create(":id",[Z.create(":path")])])]),De=p((()=>import("./PresentationTool.js"))),Ae=p((()=>import("./BroadcastDisplayedDocument.js")));function Ee(e){return e}function $e(e){return e}const Ce=j((n=>{var i;const r=n.name||ne;"locate"in n&&console.warn("Presentation’s `locate` option is deprecated. Use `resolve.locations` instead.");const o=!!(null!=(i=n.resolve)&&i.locations||n.locate);return{i18n:{bundles:[ye]},document:{unstable_fieldActions:e=>[...e.filter((e=>e.name!==Se.name)),Se]},form:{components:{input:function(i){const r=i.value,s=null!=r&&r._id?P(null==r?void 0:r._id):void 0;return x(i.schemaType)?t(Te,{options:n,children:[o&&s&&e(Ie,{documentId:s,options:n,schemaType:i.schemaType}),i.renderDefault(i),e(m,{children:e(Ae,{value:r},s)},"broadcast-displayed-document")]}):i.renderDefault(i)}}},tools:[{icon:n.icon||te,name:r,title:n.title,component:De,options:n,canHandleIntent:(e,t)=>"create"===e?function(e){return"type"in e&&(!("presentation"in e)||e.presentation===r)&&(!("template"in e)||{template:!0})}(t):"edit"===e&&function(e){return"type"in e&&"id"in e&&(!("presentation"in e)||e.presentation===r)&&(!("mode"in e)||{mode:e.mode===oe})}(t),getIntentState:ke,router:ze}]}})),Be=s(null);function Re(){const e=a(Be);if(!e)throw new Error("Presentation navigate context is missing");return e}const Ue=s(null);function He(e=!0){const t=a(Ue);if(e&&!t)throw new Error("Presentation params context is missing");return t}export{ae as A,re as C,ne as D,oe as E,de as L,se as M,Be as P,Ue as a,ge as b,ce as c,He as d,le as e,Re as f,Ee as g,$e as h,Ce as i,ve as p,we as u};//# sourceMappingURL=index.js.map
`;function Ie(t){const{documentId:n,options:r,schemaType:i}=t,o=c(je),{state:s,status:a}=fe({id:n,resolvers:r.resolve?.locations||r.locate,type:i.name});if(o&&o.options[0]!==r||"empty"===a)return null;const l=o?.options||[];return e(xe,{marginBottom:5,space:5,children:e(R,{space:2,children:l.map(((t,r)=>e(_e,{documentId:n,isResolving:"resolving"===a,options:t,schemaType:i,showPresentationTitle:l.length>1,state:s},r)))})})}function Te(t){const{children:n,options:o}=t,s=c(je),l=s?.register,[u,m]=r((()=>[])),h=a((e=>l?l(e):(m((t=>[e].concat(t))),()=>{m((t=>t.filter((t=>t!==e))))})),[l]),f=d(h);f.current=h;const y=i((()=>({options:s?.options||u,register:h})),[u,s,h]);return p((()=>f.current(o)),[o]),e(je.Provider,{value:y,children:n})}const Se=w({name:"presentation/openInStructure",useAction({documentId:e,documentType:t,path:n}){const r=b(),{navigateIntent:o}=X(),s=c(ve),a=i((()=>function(e,t,n){const r=e.map((e=>{const r=e.canHandleIntent?.("edit",{id:t,type:n,mode:"structure"},{});return{tool:e,match:r}})),i=r.filter((e=>f(e.match)&&e.match.mode));return i.length>0?i[0].tool:r.filter((e=>e.match))[0]?.tool}(r.tools,e,t)),[e,t,r.tools]);return{type:"action",hidden:!s||n.length>0||!a,icon:a?.icon||D,title:`Open in ${a?.title||"Structure"}`,onAction(){o("edit",{id:e,type:t,mode:"structure",path:_(n)})},renderAsButton:!0}}});const Oe=["preview","perspective","viewport"];function ke(e,t,n,r){const{id:i,mode:o,path:s,presentation:c,type:a,...l}=t,d={...(n?._searchParams||[]).filter((([e])=>Oe.includes(e))).reduce(((e,[t,n])=>({...e,[t]:n})),{}),...l};return"edit"===e&&i?{type:a||"*",id:P(i),path:s,_searchParams:Object.entries(d)}:"create"===e?(d.preview=d.preview||new URLSearchParams(window.location.search).get("preview")||"/",r&&"object"==typeof r&&(d.templateParams=Y(r)),{type:a||"*",id:i||ee(),_searchParams:Object.entries(d)}):{intent:e,params:t,payload:r}}const ze=Z.create("/",{__unsafe_disableScopedSearchParams:!0},[Z.intents("/intent"),Z.create(":type",[Z.create(":id",[Z.create(":path")])])]),De=u((()=>import("./PresentationTool.js"))),Ae=u((()=>import("./BroadcastDisplayedDocument.js")));function Ee(e){return e}function $e(e){return e}const Ce=j((n=>{const r=n.name||ne;"locate"in n&&console.warn("Presentation’s `locate` option is deprecated. Use `resolve.locations` instead.");const i=!(!n.resolve?.locations&&!n.locate);return{i18n:{bundles:[ge]},document:{unstable_fieldActions:e=>[...e.filter((e=>e.name!==Se.name)),Se]},form:{components:{input:function(r){const o=r.value,s=o?._id?P(o?._id):void 0;return x(r.schemaType)?t(Te,{options:n,children:[i&&s&&e(Ie,{documentId:s,options:n,schemaType:r.schemaType}),r.renderDefault(r),e(m,{children:e(Ae,{value:o},s)},"broadcast-displayed-document")]}):r.renderDefault(r)}}},tools:[{icon:n.icon||te,name:r,title:n.title,component:De,options:n,canHandleIntent:(e,t)=>"create"===e?function(e){return"type"in e&&(!("presentation"in e)||e.presentation===r)&&(!("template"in e)||{template:!0})}(t):"edit"===e&&function(e){return"type"in e&&"id"in e&&(!("presentation"in e)||e.presentation===r)&&(!("mode"in e)||{mode:e.mode===oe})}(t),getIntentState:ke,router:ze}]}})),Be=s(null);function Re(){const e=c(Be);if(!e)throw new Error("Presentation navigate context is missing");return e}const Ue=s(null);function He(e=!0){const t=c(Ue);if(e&&!t)throw new Error("Presentation params context is missing");return t}export{ce as A,ie as C,ne as D,oe as E,de as L,se as M,Be as P,Ue as a,ve as b,ae as c,He as d,le as e,Re as f,Ee as g,$e as h,Ce as i,ye as p,we as u};//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

import{jsxs as e,Fragment as t,jsx as n}from"react/jsx-runtime";import{useMemo as r,useState as s,useEffect as o,useSyncExternalStore as c,useCallback as a,memo as i}from"react";import{applySourceDocuments as u,getPublishedId as l}from"@sanity/client/csm";import{applyPatch as d}from"mendoza";import p from"mnemonist/lru-cache-with-delete";import{useClient as f}from"sanity";import{L as m,e as h}from"./index.js";function v(e){return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}function w(c){const{liveDocument:a,channel:i,perspective:u,liveQueries:l,documentsOnPage:d}=c,[h]=s((()=>new p(m))),v=f({apiVersion:"2023-10-16"}),w=r((()=>v.config()),[v]),g=r((()=>v.withConfig({resultSourceMap:"withKeyArraySelector"})),[v]);o((()=>{if(i){const{projectId:e,dataset:t}=w;i.send("loaders","loader/perspective",{projectId:e,dataset:t,perspective:u})}}),[i,w,u]);const L=r((()=>{const e=d.map((({_id:e})=>e)),t=[...new Set(e)],n=h.capacity;return t.length>=n&&(t.length=n),t}),[h.capacity,d]),[S,b]=s(0);return e(t,{children:[n(y,{cache:h,client:g,turboIds:L,setDocumentsCacheLastUpdated:b}),Object.entries(l).map((([e,{query:t,params:r,perspective:s}])=>n(I,{cache:h,projectId:w.projectId,dataset:w.dataset,perspective:s,query:t,params:r,channel:i,client:g,refreshInterval:u?2e3:0,liveDocument:a,documentsCacheLastUpdated:S},`${e}${s}`)))]})}const y=i((function(e){const{cache:r,client:c,turboIds:a,setDocumentsCacheLastUpdated:i}=e,[u,l]=s([]);return o((()=>{const e=new Set(u.flat()),t=new Set;for(const n of a)!e.has(n)&&!r.has(n)&&t.add(n);const n=[...t].slice(0,h);0!==n.length&&l((e=>[...e.slice(-h),n]))}),[u,r,a]),o((()=>{const e=c.listen("*",{},{events:["mutation"],effectFormat:"mendoza",includePreviousRevision:!1,includeResult:!1,tag:"presentation-loader"}).subscribe((e=>{var t,n;if("mutation"===e.type&&"disappear"===e.transition&&r.delete(e.documentId)&&i(Date.now()),"mutation"!==e.type||null==(n=null==(t=e.effects)?void 0:t.apply)||!n.length)return;const s=r.peek(e.documentId);if(s){const t={...s};delete t._rev;const n=d(t,e.effects.apply);r.set(e.documentId,n),i(Date.now())}}));return()=>e.unsubscribe()}),[r,c,i]),n(t,{children:u.map((e=>n(g,{cache:r,client:c,ids:e,setDocumentsCacheLastUpdated:i},JSON.stringify(e))))})})),g=i((function(e){const{client:t,cache:n,ids:r,setDocumentsCacheLastUpdated:s}=e;return o((()=>{const e=r.filter((e=>!n.has(e)));0!==e.length&&t.getDocuments(e).then((e=>{for(const t of e)t&&null!=t&&t._id&&(n.set(t._id,t),s(Date.now()))}),console.error)}),[n,t,r,s]),null}));function I(e){const{cache:t,projectId:n,dataset:i,perspective:u,query:l,client:d,refreshInterval:p,liveDocument:f,channel:m,documentsCacheLastUpdated:h}=e,w=function(e){const t=r((()=>JSON.stringify(e||{})),[e]);return r((()=>JSON.parse(t)),[t])}(e.params),y=function(e){const{cache:t,liveDocument:n,client:i,refreshInterval:u,query:l,params:d,perspective:p,documentsCacheLastUpdated:f}=e,[m,h]=s(null),{projectId:w,dataset:y}=r((()=>{const{projectId:e,dataset:t}=i.config();return{projectId:e,dataset:t}}),[i]),[g,I]=s(null);if(g)throw g;const[L,b]=function(e){const{refreshInterval:t}=e,n=function(){const[e,t]=s(!1);o((()=>{t(navigator.onLine);const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e),window.addEventListener("offline",n),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}),[]);const n=c(v,(()=>document.visibilityState),(()=>"hidden"));return!e||"hidden"===n}(),[r,i]=s("hit"),u=a((()=>(i("inflight"),()=>i("hit"))),[]);return o((()=>{if(!t||"hit"!==r)return;const e=setTimeout((()=>i("stale")),t);return()=>clearTimeout(e)}),[t,r]),o((()=>{if("hit"!==r)return;const e=()=>i("stale");return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)}),[t,r]),o((()=>{n&&"hit"===r&&i("stale"),!n&&"stale"===r&&i("refresh")}),[n,r]),[r,u]}({refreshInterval:u}),D="refresh"===L||"inflight"===L;return o((()=>{if(!D)return;let e=!1,t=!1;const n=new AbortController;async function r(){const{signal:r}=n;t=!0;const{result:s,resultSourceMap:o}=await i.fetch(l,d,{tag:"presentation-loader",signal:r,perspective:p,filterResponse:!1});t=!1,r.aborted||(h({result:s,resultSourceMap:o}),e=!0)}const s=b();return r().catch((e=>{t=!1,"AbortError"!==e.name&&I(e)})).finally(s),()=>{!e&&!t&&n.abort()}}),[i,y,n,d,p,w,l,D,b]),r((()=>f&&null!=m&&m.resultSourceMap?{result:S(t,n,m.result,p,m.resultSourceMap),resultSourceMap:m.resultSourceMap}:m),[t,f,n,p,m])}({cache:t,client:d,liveDocument:f,params:w,perspective:u,query:l,refreshInterval:p,documentsCacheLastUpdated:h}),g=null==y?void 0:y.result,I=null==y?void 0:y.resultSourceMap;return o((()=>{I&&m.send("loaders","loader/query-change",{projectId:n,dataset:i,perspective:u,query:l,params:w,result:g,resultSourceMap:I})}),[m,i,w,u,n,l,g,I]),null}g.displayName="GetDocuments";let L=!1;function S(e,t,n,r,s){if("raw"===r)throw new Error("turboChargeResultIfSourceMap does not support raw perspective");return u(n,s,(n=>{if(!n._projectId)return null!=t&&t._id&&l(t._id)===l(n._id)?t:e.get(n._id);L||(console.warn("Cross dataset references are not supported yet, ignoring source document",n),L=!0)}),((e,{previousValue:t})=>"number"==typeof e&&"string"==typeof t?`${e}`:e),r)}export{w as default,S as turboChargeResultIfSourceMap};//# sourceMappingURL=LoaderQueries.js.map
import{jsxs as e,Fragment as t,jsx as n}from"react/jsx-runtime";import{useMemo as r,useState as s,useEffect as o,useSyncExternalStore as c,useCallback as a,memo as i}from"react";import{applySourceDocuments as u,getPublishedId as d}from"@sanity/client/csm";import{applyPatch as l}from"mendoza";import p from"mnemonist/lru-cache-with-delete";import{useClient as f}from"sanity";import{L as m,e as h}from"./index.js";function v(e){return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)}function w(c){const{liveDocument:a,channel:i,perspective:u,liveQueries:d,documentsOnPage:l}=c,[h]=s((()=>new p(m))),v=f({apiVersion:"2023-10-16"}),w=r((()=>v.config()),[v]),g=r((()=>v.withConfig({resultSourceMap:"withKeyArraySelector"})),[v]);o((()=>{if(i){const{projectId:e,dataset:t}=w;i.send("loaders","loader/perspective",{projectId:e,dataset:t,perspective:u})}}),[i,w,u]);const L=r((()=>{const e=l.map((({_id:e})=>e)),t=[...new Set(e)],n=h.capacity;return t.length>=n&&(t.length=n),t}),[h.capacity,l]),[S,b]=s(0);return e(t,{children:[n(y,{cache:h,client:g,turboIds:L,setDocumentsCacheLastUpdated:b}),Object.entries(d).map((([e,{query:t,params:r,perspective:s}])=>n(I,{cache:h,projectId:w.projectId,dataset:w.dataset,perspective:s,query:t,params:r,channel:i,client:g,refreshInterval:u?2e3:0,liveDocument:a,documentsCacheLastUpdated:S},`${e}${s}`)))]})}const y=i((function(e){const{cache:r,client:c,turboIds:a,setDocumentsCacheLastUpdated:i}=e,[u,d]=s([]);return o((()=>{const e=new Set(u.flat()),t=new Set;for(const n of a)!e.has(n)&&!r.has(n)&&t.add(n);const n=[...t].slice(0,h);0!==n.length&&d((e=>[...e.slice(-h),n]))}),[u,r,a]),o((()=>{const e=c.listen("*",{},{events:["mutation"],effectFormat:"mendoza",includePreviousRevision:!1,includeResult:!1,tag:"presentation-loader"}).subscribe((e=>{if("mutation"===e.type&&"disappear"===e.transition&&r.delete(e.documentId)&&i(Date.now()),"mutation"!==e.type||!e.effects?.apply?.length)return;const t=r.peek(e.documentId);if(t){const n={...t};delete n._rev;const s=l(n,e.effects.apply);r.set(e.documentId,s),i(Date.now())}}));return()=>e.unsubscribe()}),[r,c,i]),n(t,{children:u.map((e=>n(g,{cache:r,client:c,ids:e,setDocumentsCacheLastUpdated:i},JSON.stringify(e))))})})),g=i((function(e){const{client:t,cache:n,ids:r,setDocumentsCacheLastUpdated:s}=e;return o((()=>{const e=r.filter((e=>!n.has(e)));0!==e.length&&t.getDocuments(e).then((e=>{for(const t of e)t&&t?._id&&(n.set(t._id,t),s(Date.now()))}),console.error)}),[n,t,r,s]),null}));function I(e){const{cache:t,projectId:n,dataset:i,perspective:u,query:d,client:l,refreshInterval:p,liveDocument:f,channel:m,documentsCacheLastUpdated:h}=e,w=function(e){const t=r((()=>JSON.stringify(e||{})),[e]);return r((()=>JSON.parse(t)),[t])}(e.params),y=function(e){const{cache:t,liveDocument:n,client:i,refreshInterval:u,query:d,params:l,perspective:p,documentsCacheLastUpdated:f}=e,[m,h]=s(null),{projectId:w,dataset:y}=r((()=>{const{projectId:e,dataset:t}=i.config();return{projectId:e,dataset:t}}),[i]),[g,I]=s(null);if(g)throw g;const[L,b]=function(e){const{refreshInterval:t}=e,n=function(){const[e,t]=s(!1);o((()=>{t(navigator.onLine);const e=()=>t(!0),n=()=>t(!1);return window.addEventListener("online",e),window.addEventListener("offline",n),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",n)}}),[]);const n=c(v,(()=>document.visibilityState),(()=>"hidden"));return!e||"hidden"===n}(),[r,i]=s("hit"),u=a((()=>(i("inflight"),()=>i("hit"))),[]);return o((()=>{if(!t||"hit"!==r)return;const e=setTimeout((()=>i("stale")),t);return()=>clearTimeout(e)}),[t,r]),o((()=>{if("hit"!==r)return;const e=()=>i("stale");return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)}),[t,r]),o((()=>{n&&"hit"===r&&i("stale"),!n&&"stale"===r&&i("refresh")}),[n,r]),[r,u]}({refreshInterval:u}),D="refresh"===L||"inflight"===L;return o((()=>{if(!D)return;let e=!1,t=!1;const n=new AbortController;async function r(){const{signal:r}=n;t=!0;const{result:s,resultSourceMap:o}=await i.fetch(d,l,{tag:"presentation-loader",signal:r,perspective:p,filterResponse:!1});t=!1,r.aborted||(h({result:s,resultSourceMap:o}),e=!0)}const s=b();return r().catch((e=>{t=!1,"AbortError"!==e.name&&I(e)})).finally(s),()=>{!e&&!t&&n.abort()}}),[i,y,n,l,p,w,d,D,b]),r((()=>f&&m?.resultSourceMap?{result:S(t,n,m.result,p,m.resultSourceMap),resultSourceMap:m.resultSourceMap}:m),[t,f,n,p,m])}({cache:t,client:l,liveDocument:f,params:w,perspective:u,query:d,refreshInterval:p,documentsCacheLastUpdated:h}),g=y?.result,I=y?.resultSourceMap;return o((()=>{I&&m.send("loaders","loader/query-change",{projectId:n,dataset:i,perspective:u,query:d,params:w,result:g,resultSourceMap:I})}),[m,i,w,u,n,d,g,I]),null}g.displayName="GetDocuments";let L=!1;function S(e,t,n,r,s){if("raw"===r)throw new Error("turboChargeResultIfSourceMap does not support raw perspective");return u(n,s,(n=>{if(!n._projectId)return t?._id&&d(t._id)===d(n._id)?t:e.get(n._id);L||(console.warn("Cross dataset references are not supported yet, ignoring source document",n),L=!0)}),((e,{previousValue:t})=>"number"==typeof e&&"string"==typeof t?`${e}`:e),r)}export{w as default,S as turboChargeResultIfSourceMap};//# sourceMappingURL=LoaderQueries.js.map

@@ -1,1 +0,1 @@

import{jsx as e}from"react/jsx-runtime";import{memo as n,useMemo as r,useState as l,useEffect as t,startTransition as i}from"react";import{getPublishedId as o,useEditState as d}from"sanity";function u(e){const{channel:n,draft:r,published:o,livePreviewEnabled:d}=e,[u,a]=l(r),[s,c]=l(o);return t((()=>{(null==u?void 0:u._rev)!==(null==r?void 0:r._rev)&&(i((()=>a(r))),r&&(null==n||n.send("overlays","presentation/refresh",{source:"mutation",livePreviewEnabled:d,document:v(r)}))),(null==s?void 0:s._rev)!==(null==o?void 0:o._rev)&&(i((()=>c(o))),o&&(null==n||n.send("overlays","presentation/refresh",{source:"mutation",livePreviewEnabled:d,document:v(o)})))}),[n,r,d,null==u?void 0:u._rev,null==s?void 0:s._rev,o]),null}function v(e){const{_id:n,_type:r,_rev:l,slug:t}=e;return{_id:n,_type:r,_rev:l,slug:t}}var a=n((function(n){const{channel:l,type:t,previewKitConnection:i,loadersConnection:v}=n,a=r((()=>o(n.id)),[n.id]),{draft:s,published:c,ready:p}=d(a,t,"low");return p&&s||c?e(u,{channel:l,draft:s,livePreviewEnabled:"connected"===i||"connected"===v,published:c},a):null}));export{a as default};//# sourceMappingURL=PostMessageRefreshMutations.js.map
import{jsx as e}from"react/jsx-runtime";import{memo as n,useMemo as r,useState as t,useEffect as i,startTransition as o}from"react";import{getPublishedId as l,useEditState as a}from"sanity";function d(e){const{channel:n,draft:r,published:l,livePreviewEnabled:a}=e,[d,c]=t(r),[u,v]=t(l);return i((()=>{d?._rev!==r?._rev&&(o((()=>c(r))),r&&n?.send("overlays","presentation/refresh",{source:"mutation",livePreviewEnabled:a,document:s(r)})),u?._rev!==l?._rev&&(o((()=>v(l))),l&&n?.send("overlays","presentation/refresh",{source:"mutation",livePreviewEnabled:a,document:s(l)}))}),[n,r,a,d?._rev,u?._rev,l]),null}function s(e){const{_id:n,_type:r,_rev:t,slug:i}=e;return{_id:n,_type:r,_rev:t,slug:i}}var c=n((function(n){const{channel:t,type:i,previewKitConnection:o,loadersConnection:s}=n,c=r((()=>l(n.id)),[n.id]),{draft:u,published:v,ready:p}=a(c,i,"low");return p&&u||v?e(d,{channel:t,draft:u,livePreviewEnabled:"connected"===o||"connected"===s,published:v},c):null}));export{c as default};//# sourceMappingURL=PostMessageRefreshMutations.js.map

@@ -1,6 +0,6 @@

var e=Object.defineProperty,t=(t,n,r)=>((t,n,r)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r)(t,"symbol"!=typeof n?n+"":n,r);import{jsx as n,jsxs as r,Fragment as i}from"react/jsx-runtime";import{studioPath as o}from"@sanity/client/csm";import{Button as a,Card as s,Flex as c,Container as l,Stack as d,Text as u,Inline as p,Box as m,Code as h,Label as f,ErrorBoundary as v,TextInput as g,MenuItem as y,useToast as w,usePrefersReducedMotion as b,TooltipDelayGroupProvider as x,Tooltip as P,Switch as k,MenuButton as E,Menu as S,Spinner as I,BoundaryElementProvider as _}from"@sanity/ui";import{createContext as z,useContext as D,useLayoutEffect as C,useMemo as $,useRef as O,useState as R,useCallback as j,useEffect as L,forwardRef as T,memo as U,createElement as A,startTransition as W,useReducer as M,Suspense as N,lazy as F}from"react";import{useTranslation as K,useUnique as V,getPublishedId as B,useDocumentPreviewStore as q,getPreviewStateObservable as G,useSchema as H,SanityDefaultPreview as J,getPreviewValueWithFallback as X,PreviewCard as Z,Translate as Q,CommentsIntentProvider as Y,useActiveWorkspace as ee,useClient as te,useCurrentUser as ne,Hotkeys as re,useEditState as ie,useProjectId as oe,useDataset as ae,useWorkspace as se}from"sanity";import{StateLink as ce,useRouter as le,decodeJsonParams as de}from"sanity/router";import{styled as ue}from"styled-components";import{p as pe,u as me,P as he,a as fe,b as ve,A as ge,M as ye,c as we,C as be,E as xe,D as Pe}from"./index.js";import{WarningOutlineIcon as ke,ResetIcon as Ee,LaunchIcon as Se,CopyIcon as Ie,PanelLeftIcon as _e,RefreshIcon as ze,ShareIcon as De,ChevronDownIcon as Ce,CheckmarkIcon as $e,MobileDeviceIcon as Oe,DesktopIcon as Re,EditIcon as je,PublishIcon as Le}from"@sanity/icons";import{PaneRouterContext as Te,PaneLayout as Ue,StructureToolProvider as Ae,DocumentListPane as We,DocumentPane as Me}from"sanity/structure";import{D as Ne}from"./DisplayedDocumentBroadcaster.js";import{hasSecretSearchParams as Fe,setSecretSearchParams as Ke,withoutSecretSearchParams as Ve}from"@sanity/preview-url-secret/without-secret-search-params";import{motion as Be,MotionConfig as qe,AnimatePresence as Ge}from"framer-motion";import{createPreviewSecret as He}from"@sanity/preview-url-secret/create-secret";import Je from"fast-deep-equal";import{match as Xe}from"path-to-regexp";import{definePreviewUrl as Ze}from"@sanity/preview-url-secret/define-preview-url";import{suspend as Qe}from"suspend-react";let Ye;const et=new Uint8Array(16);function tt(){if(!Ye&&(Ye=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Ye))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ye(et)}const nt=[];for(let e=0;e<256;++e)nt.push((e+256).toString(16).slice(1));var rt={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function it(e,t,n){if(rt.randomUUID&&!t&&!e)return rt.randomUUID();const r=(e=e||{}).random||(e.rng||tt)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return nt[e[t+0]]+nt[e[t+1]]+nt[e[t+2]]+nt[e[t+3]]+"-"+nt[e[t+4]]+nt[e[t+5]]+"-"+nt[e[t+6]]+nt[e[t+7]]+"-"+nt[e[t+8]]+nt[e[t+9]]+"-"+nt[e[t+10]]+nt[e[t+11]]+nt[e[t+12]]+nt[e[t+13]]+nt[e[t+14]]+nt[e[t+15]]}(r)}const ot=1e3,at=1e3,st=500,ct=["handshake/syn","handshake/syn-ack","handshake/ack"],lt=e=>ct.some((t=>t===e)),dt=({data:e={}})=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&!("domain"in e)&&["id","type","from","to"].every((t=>t in e))&&e.type.startsWith("handshake/");function ut(e){const t=e.target,n=e.connectTo.map((e=>({buffer:[],config:e,id:"",handler:i,status:"connecting",interval:void 0,heartbeat:void 0})));function r(e){window.clearInterval(e.interval)}function i(e){const{data:t}=e;if(lt(t.type)){const e=n.find((e=>e.config.id===t.from));e&&"handshake/syn-ack"===t.type&&(c(e,"connected"),l(e,"handshake/ack",{id:e.id}))}}const o=t=>{var r,i,o;const a=t.data;if(!lt(a.type)&&n.find((e=>e.id===a.connectionId))){const t=n.find((e=>e.config.id===a.from));if(t){const n=[a.type,a.data];null==(i=(r=t.config).onEvent)||i.call(r,...n),null==(o=e.onEvent)||o.call(e,...n),d(t,"channel/response",{responseTo:a.id},!1)}}};function a(t){var r;if(dt(t))console.error("Visual editing package mismatch detected! Please ensure you are using the latest version of Sanity Studio and any packages listed here:\nhttps://github.com/sanity-io/visual-editing");else if(function(t){const{data:r,origin:i}=t;return"sanity/channels"===r.domain&&r.to==e.id&&n.map((e=>e.config.id)).includes(r.from)&&"channel/response"!==r.type&&i===e.targetOrigin}(t)){const{data:e}=t;null==(r=n.find((t=>t.config.id===e.from)))||r.handler(t)}}function s(e){e.heartbeat&&window.clearInterval(e.heartbeat)}function c(t,n){var a,c,u;t.status=n,null==(c=(a=t.config).onStatusUpdate)||c.call(a,n,t.config.id),null==(u=e.onStatusUpdate)||u.call(e,n,t.config.id),"connecting"===n||"reconnecting"===n?(t.handler=i,s(t),function(e){e.id=it(),e.interval=window.setInterval((()=>{l(e,"handshake/syn",{id:e.id})}),st)}(t)):"connected"===n?(t.handler=o,r(t),function(e){if(s(e),e.config.heartbeat){const t="number"==typeof e.config.heartbeat?e.config.heartbeat:at;e.heartbeat=window.setInterval((()=>{d(e,"channel/heartbeat")}),t)}}(t),function(e){const t=[...e.buffer];e.buffer.splice(0,e.buffer.length),t.forEach((({type:t,data:n})=>{d(e,t,n)}))}(t)):"disconnected"===n&&(t.id=null,t.handler=i,r(t),s(t))}function l(n,r,i){if(!n.id)throw new Error("No channel ID set");const o={connectionId:n.id,data:i,domain:"sanity/channels",from:e.id,id:it(),to:n.config.id,type:r};try{null==t||t.postMessage(o,{targetOrigin:"*"})}catch{throw new Error(`Failed to postMessage '${o.id}' on '${e.id}'`)}}function d(n,r,i,o=!0){const a=it();if("connecting"===n.status||"reconnecting"===n.status||"disconnected"===n.status)return void n.buffer.push({type:r,data:i});if(!n.id)throw new Error("No channel ID set");const s={connectionId:n.id,data:i,domain:"sanity/channels",from:e.id,id:a,to:n.config.id,type:r};if(o){const t=setTimeout((()=>{s.connectionId===n.id&&(window.removeEventListener("message",o,!1),"channel/heartbeat"!==r&&n.buffer.push({type:r,data:i}),c(n,"reconnecting"),console.warn(`Received no response to message '${s.type}' on client '${e.id}' (ID: '${s.id}').`))}),ot),o=e=>{var n;const{data:r}=e;"channel/response"===r.type&&null!=(n=r.data)&&n.responseTo&&r.data.responseTo===s.id&&(window.removeEventListener("message",o,!1),clearTimeout(t))};window.addEventListener("message",o,!1)}try{null==t||t.postMessage(s,{targetOrigin:e.targetOrigin})}catch{throw new Error(`Failed to postMessage '${s.id}' on client '${e.id}'`)}}return window.addEventListener("message",a,!1),n.forEach((e=>{c(e,"connecting")})),{destroy:function(){n.forEach((e=>{["disconnected"].includes(e.status)||(d(e,"channel/disconnect",{id:e.id},!1),c(e,"disconnected"))})),window.removeEventListener("message",a,!1),n.forEach((e=>{s(e),r(e)}))},send:function(e,t,r){(e?Array.isArray(e)?[...e]:[e]:n).forEach((e=>{const i=n.find((t=>t.config.id===e));if(!i)throw new Error("Invalid channel ID");d(i,t,r)}))}}}var pt,mt,ht,ft;function vt(e){var t,n,r;let i=typeof e;return"object"===i&&(i=null!=(r=e&&(null==(n=null==(t=Object.getPrototypeOf(e))?void 0:t.constructor)?void 0:n.name))?r:"null"),"string"===i?`"${e}"`:"number"===i||"bigint"===i||"boolean"===i?`${e}`:i}function gt(e,t,n,r,i){var o,a,s,c,l,d;const u=i&&"input"in i?i.input:n.value,p=null!=(o=null==i?void 0:i.expected)?o:e.expects,m=null!=(a=null==i?void 0:i.received)?a:vt(u),h={kind:e.kind,type:e.type,input:u,expected:p,received:m,message:`Invalid ${t}: ${p?`Expected ${p} but r`:"R"}eceived ${m}`,requirement:e.requirement,path:null==i?void 0:i.path,issues:null==i?void 0:i.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly,skipPipe:r.skipPipe},f="schema"===e.kind,v=null!=(d=null!=(l=null!=(c=null!=(s=e.message)?s:function(e,t){var n;return null==(n=null==ft?void 0:ft.get(e))?void 0:n.get(t)}(e.reference,h.lang))?c:f?(g=h.lang,null==ht?void 0:ht.get(g)):null)?l:r.message)?d:function(e){return null==mt?void 0:mt.get(e)}(h.lang);var g;v&&(h.message="function"==typeof v?v(h):v),f&&(n.typed=!1),n.issues?n.issues.push(h):n.issues=[h]}function yt(e){return"__proto__"!==e&&"prototype"!==e&&"constructor"!==e}var wt=class extends Error{constructor(e){super(e[0].message),t(this,"issues"),this.name="ValiError",this.issues=e}};function bt(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function xt(e){return{kind:"schema",type:"boolean",reference:xt,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:gt(this,"type",e,t),e}}}function Pt(e,t){return{kind:"schema",type:"object",reference:Pt,expects:"Object",async:!1,entries:e,message:t,_run(e,t){var n;const r=e.value;if(r&&"object"==typeof r){e.typed=!0,e.value={};for(const i in this.entries){const o=r[i],a=this.entries[i]._run({typed:!1,value:o},t);if(a.issues){const s={type:"object",origin:"value",input:r,key:i,value:o};for(const t of a.issues)t.path?t.path.unshift(s):t.path=[s],null==(n=e.issues)||n.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),(void 0!==a.value||i in r)&&(e.value[i]=a.value)}}else gt(this,"type",e,t);return e}}}function kt(e,...t){const n={kind:"schema",type:"optional",reference:kt,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=function(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(n.default=t[0]),n}function Et(e){return{kind:"schema",type:"string",reference:Et,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:gt(this,"type",e,t),e}}}function St(e,t,n){const r=e._run({typed:!1,value:t},function(e){var t,n,r;return{lang:null!=(t=null==e?void 0:e.lang)?t:null==pt?void 0:pt.lang,message:null==e?void 0:e.message,abortEarly:null!=(n=null==e?void 0:e.abortEarly)?n:null==pt?void 0:pt.abortEarly,abortPipeEarly:null!=(r=null==e?void 0:e.abortPipeEarly)?r:null==pt?void 0:pt.abortPipeEarly,skipPipe:null==e?void 0:e.skipPipe}}(n));if(r.issues)throw new wt(r.issues);return r.value}const It=/^([A-Za-z]+):([0-9]+)$/,_t=/^([A-Za-z]+):([0-9]+),([0-9]+)$/,zt=/^([A-Za-z]+):([a-z0-9]+)$/;const Dt=function(...e){return{...e[0],pipe:e,_run(t,n){for(let r=0;r<e.length;r++){t=e[r]._run(t,n);const i=e[r+1];if(n.skipPipe||t.issues&&(n.abortEarly||n.abortPipeEarly||"schema"===(null==i?void 0:i.kind)||"transformation"===(null==i?void 0:i.kind))){t.typed=!1;break}}return t}}}(Et(),function e(t,n){return{kind:"validation",type:"min_length",reference:e,async:!1,expects:`>=${t}`,requirement:t,message:n,_run(e,t){return e.typed&&e.value.length<this.requirement&&gt(this,"length",e,t,{received:`${e.value.length}`}),e}}}(1)),Ct=kt(Dt);function $t(e,t){return`${e}-${"string"==typeof t?t:JSON.stringify(t)}`}Pt({baseUrl:Dt,dataset:Ct,id:Dt,path:Dt,projectId:Ct,tool:Ct,type:Ct,workspace:Ct,isDraft:kt(Et())}),Pt({origin:Dt,href:Dt,data:kt(function e(t,n,r){return{kind:"schema",type:"record",reference:e,expects:"Object",async:!1,key:t,value:n,message:r,_run(e,t){var n,r;const i=e.value;if(i&&"object"==typeof i){e.typed=!0,e.value={};for(const o in i)if(yt(o)){const a=i[o],s=this.key._run({typed:!1,value:o},t);if(s.issues){const r={type:"record",origin:"key",input:i,key:o,value:a};for(const t of s.issues)t.path=[r],null==(n=e.issues)||n.push(t);if(e.issues||(e.issues=s.issues),t.abortEarly){e.typed=!1;break}}const c=this.value._run({typed:!1,value:a},t);if(c.issues){const n={type:"record",origin:"value",input:i,key:o,value:a};for(const t of c.issues)t.path?t.path.unshift(n):t.path=[n],null==(r=e.issues)||r.push(t);if(e.issues||(e.issues=c.issues),t.abortEarly){e.typed=!1;break}}(!s.typed||!c.typed)&&(e.typed=!1),s.typed&&(e.value[s.value]=c.value)}}else gt(this,"type",e,t);return e}}}(Et(),function e(){return{kind:"schema",type:"unknown",reference:e,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}()))});const Ot={alt:"altKey",ctrl:"ctrlKey",mod:typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function Rt(e){return"Alt"===e.key}function jt(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,r)}),t)}}const Lt=z(null);Lt.displayName="PanelsContext";const Tt=ue.div`
import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{studioPath as r}from"@sanity/client/csm";import{Button as i,Card as o,Flex as a,Container as s,Stack as c,Text as d,Inline as l,Box as u,Code as p,Label as m,ErrorBoundary as h,TextInput as f,MenuItem as v,useToast as g,usePrefersReducedMotion as y,TooltipDelayGroupProvider as w,Tooltip as b,Switch as x,MenuButton as P,Menu as k,Spinner as E,BoundaryElementProvider as S}from"@sanity/ui";import{createContext as I,useContext as _,useLayoutEffect as z,useMemo as D,useRef as C,useState as $,useCallback as O,useEffect as R,forwardRef as j,memo as L,createElement as T,startTransition as U,useReducer as A,Suspense as W,lazy as M}from"react";import{useTranslation as N,useUnique as F,getPublishedId as K,useDocumentPreviewStore as V,getPreviewStateObservable as B,useSchema as q,SanityDefaultPreview as G,getPreviewValueWithFallback as H,PreviewCard as J,Translate as X,CommentsIntentProvider as Z,useActiveWorkspace as Q,useClient as Y,useCurrentUser as ee,Hotkeys as te,useEditState as ne,useProjectId as re,useDataset as ie,useWorkspace as oe}from"sanity";import{StateLink as ae,useRouter as se,decodeJsonParams as ce}from"sanity/router";import{styled as de}from"styled-components";import{p as le,u as ue,P as pe,a as me,b as he,A as fe,M as ve,c as ge,C as ye,E as we,D as be}from"./index.js";import{WarningOutlineIcon as xe,ResetIcon as Pe,LaunchIcon as ke,CopyIcon as Ee,PanelLeftIcon as Se,RefreshIcon as Ie,ShareIcon as _e,ChevronDownIcon as ze,CheckmarkIcon as De,MobileDeviceIcon as Ce,DesktopIcon as $e,EditIcon as Oe,PublishIcon as Re}from"@sanity/icons";import{PaneRouterContext as je,PaneLayout as Le,StructureToolProvider as Te,DocumentListPane as Ue,DocumentPane as Ae}from"sanity/structure";import{D as We}from"./DisplayedDocumentBroadcaster.js";import{hasSecretSearchParams as Me,setSecretSearchParams as Ne,withoutSecretSearchParams as Fe}from"@sanity/preview-url-secret/without-secret-search-params";import{motion as Ke,MotionConfig as Ve,AnimatePresence as Be}from"framer-motion";import{createPreviewSecret as qe}from"@sanity/preview-url-secret/create-secret";import Ge from"fast-deep-equal";import{match as He}from"path-to-regexp";import{definePreviewUrl as Je}from"@sanity/preview-url-secret/define-preview-url";import{suspend as Xe}from"suspend-react";for(var Ze=[],Qe=0;Qe<256;++Qe)Ze.push((Qe+256).toString(16).slice(1));var Ye,et=new Uint8Array(16);function tt(){if(!Ye&&!(Ye=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Ye(et)}var nt={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function rt(e,t,n){if(nt.randomUUID&&!t&&!e)return nt.randomUUID();var r=(e=e||{}).random||(e.rng||tt)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(Ze[e[t+0]]+Ze[e[t+1]]+Ze[e[t+2]]+Ze[e[t+3]]+"-"+Ze[e[t+4]]+Ze[e[t+5]]+"-"+Ze[e[t+6]]+Ze[e[t+7]]+"-"+Ze[e[t+8]]+Ze[e[t+9]]+"-"+Ze[e[t+10]]+Ze[e[t+11]]+Ze[e[t+12]]+Ze[e[t+13]]+Ze[e[t+14]]+Ze[e[t+15]]).toLowerCase()}(r)}const it=1e3,ot=1e3,at=500,st=["handshake/syn","handshake/syn-ack","handshake/ack"],ct=e=>st.some((t=>t===e)),dt=({data:e={}})=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&!("domain"in e)&&["id","type","from","to"].every((t=>t in e))&&e.type.startsWith("handshake/");function lt(e){const t=e.target,n=e.connectTo.map((e=>({buffer:[],config:e,id:"",handler:i,status:"connecting",interval:void 0,heartbeat:void 0})));function r(e){window.clearInterval(e.interval)}function i(e){const{data:t}=e;if(ct(t.type)){const e=n.find((e=>e.config.id===t.from));e&&"handshake/syn-ack"===t.type&&(c(e,"connected"),d(e,"handshake/ack",{id:e.id}))}}const o=t=>{const r=t.data;if(!ct(r.type)&&n.find((e=>e.id===r.connectionId))){const t=n.find((e=>e.config.id===r.from));if(t){const n=[r.type,r.data];t.config.onEvent?.(...n),e.onEvent?.(...n),l(t,"channel/response",{responseTo:r.id},!1)}}};function a(t){if(dt(t))console.error("Visual editing package mismatch detected! Please ensure you are using the latest version of Sanity Studio and any packages listed here:\nhttps://github.com/sanity-io/visual-editing");else if(function(t){const{data:r,origin:i}=t;return"sanity/channels"===r.domain&&r.to==e.id&&n.map((e=>e.config.id)).includes(r.from)&&"channel/response"!==r.type&&i===e.targetOrigin}(t)){const{data:e}=t;n.find((t=>t.config.id===e.from))?.handler(t)}}function s(e){e.heartbeat&&window.clearInterval(e.heartbeat)}function c(t,n){t.status=n,t.config.onStatusUpdate?.(n,t.config.id),e.onStatusUpdate?.(n,t.config.id),"connecting"===n||"reconnecting"===n?(t.handler=i,s(t),function(e){e.id=rt(),e.interval=window.setInterval((()=>{d(e,"handshake/syn",{id:e.id})}),at)}(t)):"connected"===n?(t.handler=o,r(t),function(e){if(s(e),e.config.heartbeat){const t="number"==typeof e.config.heartbeat?e.config.heartbeat:ot;e.heartbeat=window.setInterval((()=>{l(e,"channel/heartbeat")}),t)}}(t),function(e){const t=[...e.buffer];e.buffer.splice(0,e.buffer.length),t.forEach((({type:t,data:n})=>{l(e,t,n)}))}(t)):"disconnected"===n&&(t.id=null,t.handler=i,r(t),s(t))}function d(n,r,i){if(!n.id)throw new Error("No channel ID set");const o={connectionId:n.id,data:i,domain:"sanity/channels",from:e.id,id:rt(),to:n.config.id,type:r};try{t?.postMessage(o,{targetOrigin:"*"})}catch{throw new Error(`Failed to postMessage '${o.id}' on '${e.id}'`)}}function l(n,r,i,o=!0){const a=rt();if("connecting"===n.status||"reconnecting"===n.status||"disconnected"===n.status)return void n.buffer.push({type:r,data:i});if(!n.id)throw new Error("No channel ID set");const s={connectionId:n.id,data:i,domain:"sanity/channels",from:e.id,id:a,to:n.config.id,type:r};if(o){const t=setTimeout((()=>{s.connectionId===n.id&&(window.removeEventListener("message",o,!1),"channel/heartbeat"!==r&&n.buffer.push({type:r,data:i}),c(n,"reconnecting"),console.warn(`Received no response to message '${s.type}' on client '${e.id}' (ID: '${s.id}').`))}),it),o=e=>{const{data:n}=e;"channel/response"===n.type&&n.data?.responseTo&&n.data.responseTo===s.id&&(window.removeEventListener("message",o,!1),clearTimeout(t))};window.addEventListener("message",o,!1)}try{t?.postMessage(s,{targetOrigin:e.targetOrigin})}catch{throw new Error(`Failed to postMessage '${s.id}' on client '${e.id}'`)}}return window.addEventListener("message",a,!1),n.forEach((e=>{c(e,"connecting")})),{destroy:function(){n.forEach((e=>{["disconnected"].includes(e.status)||(l(e,"channel/disconnect",{id:e.id},!1),c(e,"disconnected"))})),window.removeEventListener("message",a,!1),n.forEach((e=>{s(e),r(e)}))},send:function(e,t,r){(e?Array.isArray(e)?[...e]:[e]:n).forEach((e=>{const i=n.find((t=>t.config.id===e));if(!i)throw new Error("Invalid channel ID");l(i,t,r)}))}}}var ut,pt,mt,ht;function ft(e){let t=typeof e;return"object"===t&&(t=(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null"),"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:t}function vt(e,t,n,r,i){const o=i&&"input"in i?i.input:n.value,a=i?.expected??e.expects,s=i?.received??ft(o),c={kind:e.kind,type:e.type,input:o,expected:a,received:s,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly,skipPipe:r.skipPipe},d="schema"===e.kind,l=e.message??(u=e.reference,p=c.lang,ht?.get(u)?.get(p))??(d?function(e){return mt?.get(e)}(c.lang):null)??r.message??function(e){return pt?.get(e)}(c.lang);var u,p;l&&(c.message="function"==typeof l?l(c):l),d&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function gt(e){return"__proto__"!==e&&"prototype"!==e&&"constructor"!==e}var yt=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function wt(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function bt(e){return{kind:"schema",type:"boolean",reference:bt,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:vt(this,"type",e,t),e}}}function xt(e,t){return{kind:"schema",type:"object",reference:xt,expects:"Object",async:!1,entries:e,message:t,_run(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const r in this.entries){const i=n[r],o=this.entries[r]._run({typed:!1,value:i},t);if(o.issues){const a={type:"object",origin:"value",input:n,key:r,value:i};for(const t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),(void 0!==o.value||r in n)&&(e.value[r]=o.value)}}else vt(this,"type",e,t);return e}}}function Pt(e,...t){const n={kind:"schema",type:"optional",reference:Pt,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=function(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}(this,e,t)),void 0===e.value)?(e.typed=!0,e):this.wrapped._run(e,t)}};return 0 in t&&(n.default=t[0]),n}function kt(e){return{kind:"schema",type:"string",reference:kt,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:vt(this,"type",e,t),e}}}function Et(e,t,n){const r=e._run({typed:!1,value:t},function(e){return{lang:e?.lang??ut?.lang,message:e?.message,abortEarly:e?.abortEarly??ut?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ut?.abortPipeEarly,skipPipe:e?.skipPipe}}(n));if(r.issues)throw new yt(r.issues);return r.value}const St=/^([A-Za-z]+):([0-9]+)$/,It=/^([A-Za-z]+):([0-9]+),([0-9]+)$/,_t=/^([A-Za-z]+):([a-z0-9]+)$/;const zt=function(...e){return{...e[0],pipe:e,_run(t,n){for(let r=0;r<e.length;r++){t=e[r]._run(t,n);const i=e[r+1];if(n.skipPipe||t.issues&&(n.abortEarly||n.abortPipeEarly||"schema"===i?.kind||"transformation"===i?.kind)){t.typed=!1;break}}return t}}}(kt(),function e(t,n){return{kind:"validation",type:"min_length",reference:e,async:!1,expects:`>=${t}`,requirement:t,message:n,_run(e,t){return e.typed&&e.value.length<this.requirement&&vt(this,"length",e,t,{received:`${e.value.length}`}),e}}}(1)),Dt=Pt(zt);function Ct(e,t){return`${e}-${"string"==typeof t?t:JSON.stringify(t)}`}xt({baseUrl:zt,dataset:Dt,id:zt,path:zt,projectId:Dt,tool:Dt,type:Dt,workspace:Dt,isDraft:Pt(kt())}),xt({origin:zt,href:zt,data:Pt(function e(t,n,r){return{kind:"schema",type:"record",reference:e,expects:"Object",async:!1,key:t,value:n,message:r,_run(e,t){const n=e.value;if(n&&"object"==typeof n){e.typed=!0,e.value={};for(const r in n)if(gt(r)){const i=n[r],o=this.key._run({typed:!1,value:r},t);if(o.issues){const a={type:"record",origin:"key",input:n,key:r,value:i};for(const t of o.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}const a=this.value._run({typed:!1,value:i},t);if(a.issues){const o={type:"record",origin:"value",input:n,key:r,value:i};for(const t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}(!o.typed||!a.typed)&&(e.typed=!1),o.typed&&(e.value[o.value]=a.value)}}else vt(this,"type",e,t);return e}}}(kt(),function e(){return{kind:"schema",type:"unknown",reference:e,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}()))});const $t={alt:"altKey",ctrl:"ctrlKey",mod:typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function Ot(e){return"Alt"===e.key}function Rt(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,r)}),t)}}const jt=I(null);jt.displayName="PanelsContext";const Lt=de.div`
overflow: hidden;
flex-basis: 0;
flex-shrink: 1;
`,Ut=function({children:e,defaultSize:t=null,id:r,minWidth:i,maxWidth:o,order:a=0}){const s=D(Lt);if(null===s)throw Error("Panel components must be rendered within a PanelGroup container");const{getPanelStyle:c,registerElement:l,unregisterElement:d}=s,u=c(r);return C((()=>(l(r,{id:r,type:"panel",defaultSize:t,maxWidth:null!=o?o:null,minWidth:null!=i?i:0,order:a}),()=>{d(r)})),[r,t,a,o,i,l,d]),n(Tt,{style:u,children:e})},At="presentation/panels",Wt=()=>JSON.parse(localStorage.getItem(At)||"{}"),Mt=e=>e.map((e=>[e.id,e.order].join(":"))).join(",");function Nt(){return $((()=>{const e=(e,t)=>{const n=Wt(),r=Mt(e);(e=>{localStorage.setItem(At,JSON.stringify(e))})({...n,[r]:t})};return{get:e=>{const t=Wt(),n=Mt(e);return Array.isArray(t[n])&&t[n].some((e=>null===e))?void 0:t[n]},set:e,setDebounced:jt(e,100)}}),[])}function Ft(e,t,n){const{maxWidth:r,minWidth:i}=e,o=null==r?100:r/n*100,a=i/n*100;return Math.min(o,Math.max(a,t))}function Kt(e,t,n){if(1===e.length)return"100";const r=n[e.findIndex((e=>e.id===t))];return null==r?"0":r.toPrecision(10)}function Vt(e,t,n=0,r=null){return e.clientX-(r||t.getBoundingClientRect()).left-n}function Bt(e){return"panel"===e.type}function qt(e){return"resizer"===e.type}function Gt(e){return Array.from(e.values()).sort((({order:e},{order:t})=>null==e&&null==t?0:null==e?-1:null==t?1:e-t))}function Ht(e,t,n){const r=t.reduce(((e,t)=>e+t),0),i=[...t].map((e=>e/r*100));let o=0;for(let t=0;t<e.length;t++){const r=e[t],a=i[t],s=Ft(r,a,n);a!=s&&(o+=a-s,i[t]=s)}if("0.000"!==o.toFixed(3))for(let t=0;t<e.length;t++){const r=e[t];let{maxWidth:a,minWidth:s}=r;s=s/n*100,null!=a&&(a=a/n*100);const c=Math.min(null!=a?a:100,Math.max(s,i[t]+o));if(c!==i[t]&&(o-=c-i[t],i[t]=c,"0.000"===Math.abs(o).toFixed(3)))break}return i}const Jt=ue.div`
`,Tt=function({children:t,defaultSize:n=null,id:r,minWidth:i,maxWidth:o,order:a=0}){const s=_(jt);if(null===s)throw Error("Panel components must be rendered within a PanelGroup container");const{getPanelStyle:c,registerElement:d,unregisterElement:l}=s,u=c(r);return z((()=>(d(r,{id:r,type:"panel",defaultSize:n,maxWidth:o??null,minWidth:i??0,order:a}),()=>{l(r)})),[r,n,a,o,i,d,l]),e(Lt,{style:u,children:t})},Ut="presentation/panels",At=()=>JSON.parse(localStorage.getItem(Ut)||"{}"),Wt=e=>e.map((e=>[e.id,e.order].join(":"))).join(",");function Mt(){return D((()=>{const e=(e,t)=>{const n=At(),r=Wt(e);(e=>{localStorage.setItem(Ut,JSON.stringify(e))})({...n,[r]:t})};return{get:e=>{const t=At(),n=Wt(e);return Array.isArray(t[n])&&t[n].some((e=>null===e))?void 0:t[n]},set:e,setDebounced:Rt(e,100)}}),[])}function Nt(e,t,n){const{maxWidth:r,minWidth:i}=e,o=null==r?100:r/n*100,a=i/n*100;return Math.min(o,Math.max(a,t))}function Ft(e,t,n){if(1===e.length)return"100";const r=n[e.findIndex((e=>e.id===t))];return null==r?"0":r.toPrecision(10)}function Kt(e,t,n=0,r=null){return e.clientX-(r||t.getBoundingClientRect()).left-n}function Vt(e){return"panel"===e.type}function Bt(e){return"resizer"===e.type}function qt(e){return Array.from(e.values()).sort((({order:e},{order:t})=>null==e&&null==t?0:null==e?-1:null==t?1:e-t))}function Gt(e,t,n){const r=t.reduce(((e,t)=>e+t),0),i=[...t].map((e=>e/r*100));let o=0;for(let t=0;t<e.length;t++){const r=e[t],a=i[t],s=Nt(r,a,n);a!=s&&(o+=a-s,i[t]=s)}if("0.000"!==o.toFixed(3))for(let t=0;t<e.length;t++){const r=e[t];let{maxWidth:a,minWidth:s}=r;s=s/n*100,null!=a&&(a=a/n*100);const c=Math.min(a??100,Math.max(s,i[t]+o));if(c!==i[t]&&(o-=c-i[t],i[t]=c,"0.000"===Math.abs(o).toFixed(3)))break}return i}const Ht=de.div`
display: flex;

@@ -11,5 +11,5 @@ flex-direction: row;

width: 100%;
`,Xt=function({children:e}){const t=O(null),[r,i]=R(new Map),o=$((()=>Gt(r).filter(Bt)),[r]),[a,s]=R([]),[c,l]=R(null),d=O({elements:r,panels:o,widths:a}),u=j((e=>({flexGrow:Kt(o,e,a),pointerEvents:null===c?void 0:"none"})),[c,o,a]),p=j(((e,t)=>{i((n=>{if(n.has(e))return n;const r=new Map(n);return r.set(e,t),r}))}),[]),m=j((e=>{i((t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}))}),[]),h=O({containerWidth:window.innerWidth,dragOffset:0,panelAfter:null,panelBefore:null,resizerIndex:-1,resizerRect:null,startX:0,widths:[]}),f=j(((e,t)=>{const n=Gt(r),i=n.findIndex((t=>t.id===e)),o=r.get(e);if(!o||!qt(o))return;const a=o.el.current;a&&(h.current={resizerIndex:i,panelBefore:n.reduce(((e,t,n)=>Bt(t)&&n<i?t:e),null),panelAfter:n.reduce(((e,t,n)=>null===e&&Bt(t)&&n>i?t:e),null),containerWidth:window.innerWidth,startX:t.pageX,dragOffset:Vt(t,a),resizerRect:a.getBoundingClientRect(),widths:d.current.widths},l(e))}),[r]),v=j((()=>{l(null)}),[]),g=j(((e,n)=>{n.preventDefault(),n.stopPropagation();const{containerWidth:i,dragOffset:o,panelBefore:a,panelAfter:c,resizerRect:l}=h.current;if(null==a||null==c)return;const u=r.get(e);if(!u||!qt(u))return;const p=u.el.current;if(!p)return;const m=Vt(n,p,o,l);if(0===m)return;const{widths:f}=d.current,v=function(e,t,n,r,i,o){const{panels:a,widths:s}=i,{widths:c}=o,l=c||s,d=[...l];{const i=e<0?r:n,o=l[a.findIndex((e=>e.id===i.id))],s=Ft(i,o+Math.abs(e),t);if(o===s)return l;e=e<0?o-s:s-o}let u=0,p=e<0?n:r,m=a.findIndex((e=>e.id===p.id));for(;;){const n=a[m],r=l[m],i=Ft(n,r-(Math.abs(e)-Math.abs(u)),t);if(r!==i&&(u+=r-i,d[m]=i,u.toPrecision(10).localeCompare(Math.abs(e).toPrecision(10),void 0,{numeric:!0})>=0))break;if(e<0){if(--m<0)break}else if(++m>=a.length)break}return 0===u?l:(p=e<0?r:n,m=a.findIndex((e=>e.id===p.id)),d[m]=l[m]+u,d)}(m/t.current.getBoundingClientRect().width*100,i,a,c,d.current,h.current);f.some(((e,t)=>e!==v[t]))&&s(v)}),[r]);C((()=>{d.current.elements=r,d.current.panels=o,d.current.widths=a}),[r,o,a]);const y=Nt();C((()=>{const{widths:e}=d.current;if(e.length===o.length)return;const t=y.get(o);if(t){const e=Ht(o,t,window.innerWidth);return void s(e)}const n=function(e){let t=e.length,n=100;const r=e.map((e=>e.defaultSize?(n-=e.defaultSize,t-=1,e.defaultSize):null)),i=n/t;return r.map((e=>null===e?i:e))}(o);s(n)}),[y,o]),L((()=>{a.length&&y.setDebounced(o,a)}),[y,o,a]),C((()=>{const e=new ResizeObserver((()=>{const{panels:e,widths:t}=d.current,n=Ht(e,t,window.innerWidth);t.some(((e,t)=>e!==n[t]))&&s(n)}));return e.observe(t.current),()=>{e.disconnect()}}),[]);const w=$((()=>({activeResizer:c,drag:g,getPanelStyle:u,registerElement:p,startDragging:f,stopDragging:v,unregisterElement:m})),[c,g,u,p,f,v,m]);return n(Lt.Provider,{value:w,children:n(Jt,{ref:t,children:e})})};function Zt(e){const{children:t,message:i,onRetry:o,onContinueAnyway:h,...f}=e,{t:v}=K(pe),g=n(a,{fontSize:1,mode:"ghost",onClick:o,text:v("error-card.retry-button.text")}),y=n(a,{fontSize:1,mode:"ghost",tone:"critical",onClick:h,text:v("error-card.continue-button.text")});return n(s,{height:"fill",...f,children:n(c,{align:"center",height:"fill",justify:"center",children:n(l,{padding:4,sizing:"border",width:0,children:r(d,{space:4,children:[r(d,{space:3,children:[n(u,{size:1,weight:"semibold",children:v("error-card.title")}),n(u,{muted:!0,size:1,children:i})]}),t,o&&h?r(p,{space:2,children:[g,y]}):o?n(m,{children:g}):h?n(m,{children:y}):null]})})})})}function Qt(e){const t=["comment","inspect","instruction","pathKey","rev","since","template","view"];return function(e={}){const t=Object.entries(e).map((([e,t])=>`${e}=${t}`)).join("&");return t.length?`?${t}`:""}(Object.entries(e).filter((([e])=>t.includes(e))).reduce(((e,[t,n])=>null==n?e:{...e,[t]:n}),{}))}const Yt=T((function(e,t){const{searchParams:r,...i}=e;return n(ce,{...i,ref:t,state:{type:void 0,_searchParams:Object.entries(r)},title:void 0})})),en=T((function(e,t){const{documentId:r,documentType:i,parentRefPath:o,template:a,searchParams:s,...c}=e;return n(ce,{...c,ref:t,state:{id:r,type:i,_searchParams:Object.entries(s)},title:void 0})}));function tn(e){const{children:t,onStructureParams:r,structureParams:o,searchParams:a,refs:s}=e,{state:c,resolvePathFromState:l}=le(),d=V(Object.fromEntries(c._searchParams||[])),u=j((e=>`${l(c)}${Qt({...d,...e})}`),[l,d,c]),p=$((()=>({index:0,groupIndex:0,siblingIndex:0,payload:{},params:o,hasGroupSiblings:!1,groupLength:1,routerPanesState:[],ChildLink:e=>{const{childId:t,...r}=e,i=null==s?void 0:s.find((e=>e._id===t||B(e._id)===t));return i?n(ce,{...r,state:{id:t,type:i._type,_searchParams:Object.entries(a)}}):n("div",{...r})},BackLink:e=>n(Yt,{...e,searchParams:a}),ReferenceChildLink:e=>n(en,{...e,searchParams:a}),ParameterizedLink:()=>n(i,{children:"ParameterizedLink"}),closeCurrentAndAfter:()=>{console.warn("closeCurrentAndAfter")},handleEditReference:e=>{console.warn("handleEditReference",e)},replaceCurrent:e=>{console.warn("replaceCurrent",e)},closeCurrent:()=>{console.warn("closeCurrent")},duplicateCurrent:e=>{console.warn("duplicateCurrent",e)},setView:e=>{console.warn("setView",e)},setParams:e=>{var t;r({...e,inspect:null!=(t=e.inspect)?t:void 0})},setPayload:e=>{console.warn("setPayload",e)},navigateIntent:(e,t,n)=>{console.warn("navigateIntent",e,t,n)},createPathWithParams:u})),[u,r,s,a,o]);return n(Te.Provider,{value:p,children:t})}const nn=ue(Ue)`
`,Jt=function({children:t}){const n=C(null),[r,i]=$(new Map),o=D((()=>qt(r).filter(Vt)),[r]),[a,s]=$([]),[c,d]=$(null),l=C({elements:r,panels:o,widths:a}),u=O((e=>({flexGrow:Ft(o,e,a),pointerEvents:null===c?void 0:"none"})),[c,o,a]),p=O(((e,t)=>{i((n=>{if(n.has(e))return n;const r=new Map(n);return r.set(e,t),r}))}),[]),m=O((e=>{i((t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}))}),[]),h=C({containerWidth:window.innerWidth,dragOffset:0,panelAfter:null,panelBefore:null,resizerIndex:-1,resizerRect:null,startX:0,widths:[]}),f=O(((e,t)=>{const n=qt(r),i=n.findIndex((t=>t.id===e)),o=r.get(e);if(!o||!Bt(o))return;const a=o.el.current;a&&(h.current={resizerIndex:i,panelBefore:n.reduce(((e,t,n)=>Vt(t)&&n<i?t:e),null),panelAfter:n.reduce(((e,t,n)=>null===e&&Vt(t)&&n>i?t:e),null),containerWidth:window.innerWidth,startX:t.pageX,dragOffset:Kt(t,a),resizerRect:a.getBoundingClientRect(),widths:l.current.widths},d(e))}),[r]),v=O((()=>{d(null)}),[]),g=O(((e,t)=>{t.preventDefault(),t.stopPropagation();const{containerWidth:i,dragOffset:o,panelBefore:a,panelAfter:c,resizerRect:d}=h.current;if(null==a||null==c)return;const u=r.get(e);if(!u||!Bt(u))return;const p=u.el.current;if(!p)return;const m=Kt(t,p,o,d);if(0===m)return;const{widths:f}=l.current,v=function(e,t,n,r,i,o){const{panels:a,widths:s}=i,{widths:c}=o,d=c||s,l=[...d];{const i=e<0?r:n,o=d[a.findIndex((e=>e.id===i.id))],s=Nt(i,o+Math.abs(e),t);if(o===s)return d;e=e<0?o-s:s-o}let u=0,p=e<0?n:r,m=a.findIndex((e=>e.id===p.id));for(;;){const n=a[m],r=d[m],i=Nt(n,r-(Math.abs(e)-Math.abs(u)),t);if(r!==i&&(u+=r-i,l[m]=i,u.toPrecision(10).localeCompare(Math.abs(e).toPrecision(10),void 0,{numeric:!0})>=0))break;if(e<0){if(--m<0)break}else if(++m>=a.length)break}return 0===u?d:(p=e<0?r:n,m=a.findIndex((e=>e.id===p.id)),l[m]=d[m]+u,l)}(m/n.current.getBoundingClientRect().width*100,i,a,c,l.current,h.current);f.some(((e,t)=>e!==v[t]))&&s(v)}),[r]);z((()=>{l.current.elements=r,l.current.panels=o,l.current.widths=a}),[r,o,a]);const y=Mt();z((()=>{const{widths:e}=l.current;if(e.length===o.length)return;const t=y.get(o);if(t){const e=Gt(o,t,window.innerWidth);return void s(e)}const n=function(e){let t=e.length,n=100;const r=e.map((e=>e.defaultSize?(n-=e.defaultSize,t-=1,e.defaultSize):null)),i=n/t;return r.map((e=>null===e?i:e))}(o);s(n)}),[y,o]),R((()=>{a.length&&y.setDebounced(o,a)}),[y,o,a]),z((()=>{const e=new ResizeObserver((()=>{const{panels:e,widths:t}=l.current,n=Gt(e,t,window.innerWidth);t.some(((e,t)=>e!==n[t]))&&s(n)}));return e.observe(n.current),()=>{e.disconnect()}}),[]);const w=D((()=>({activeResizer:c,drag:g,getPanelStyle:u,registerElement:p,startDragging:f,stopDragging:v,unregisterElement:m})),[c,g,u,p,f,v,m]);return e(jt.Provider,{value:w,children:e(Ht,{ref:n,children:t})})};function Xt(n){const{children:r,message:p,onRetry:m,onContinueAnyway:h,...f}=n,{t:v}=N(le),g=e(i,{fontSize:1,mode:"ghost",onClick:m,text:v("error-card.retry-button.text")}),y=e(i,{fontSize:1,mode:"ghost",tone:"critical",onClick:h,text:v("error-card.continue-button.text")});return e(o,{height:"fill",...f,children:e(a,{align:"center",height:"fill",justify:"center",children:e(s,{padding:4,sizing:"border",width:0,children:t(c,{space:4,children:[t(c,{space:3,children:[e(d,{size:1,weight:"semibold",children:v("error-card.title")}),e(d,{muted:!0,size:1,children:p})]}),r,m&&h?t(l,{space:2,children:[g,y]}):m?e(u,{children:g}):h?e(u,{children:y}):null]})})})})}function Zt(e){const t=["comment","inspect","instruction","pathKey","rev","since","template","view"];return function(e={}){const t=Object.entries(e).map((([e,t])=>`${e}=${t}`)).join("&");return t.length?`?${t}`:""}(Object.entries(e).filter((([e])=>t.includes(e))).reduce(((e,[t,n])=>null==n?e:{...e,[t]:n}),{}))}const Qt=j((function(t,n){const{searchParams:r,...i}=t;return e(ae,{...i,ref:n,state:{type:void 0,_searchParams:Object.entries(r)},title:void 0})})),Yt=j((function(t,n){const{documentId:r,documentType:i,parentRefPath:o,template:a,searchParams:s,...c}=t;return e(ae,{...c,ref:n,state:{id:r,type:i,_searchParams:Object.entries(s)},title:void 0})}));function en(t){const{children:r,onStructureParams:i,structureParams:o,searchParams:a,refs:s}=t,{state:c,resolvePathFromState:d}=se(),l=F(Object.fromEntries(c._searchParams||[])),u=O((e=>`${d(c)}${Zt({...l,...e})}`),[d,l,c]),p=D((()=>({index:0,groupIndex:0,siblingIndex:0,payload:{},params:o,hasGroupSiblings:!1,groupLength:1,routerPanesState:[],ChildLink:t=>{const{childId:n,...r}=t,i=s?.find((e=>e._id===n||K(e._id)===n));return i?e(ae,{...r,state:{id:n,type:i._type,_searchParams:Object.entries(a)}}):e("div",{...r})},BackLink:t=>e(Qt,{...t,searchParams:a}),ReferenceChildLink:t=>e(Yt,{...t,searchParams:a}),ParameterizedLink:()=>e(n,{children:"ParameterizedLink"}),closeCurrentAndAfter:()=>{console.warn("closeCurrentAndAfter")},handleEditReference:e=>{console.warn("handleEditReference",e)},replaceCurrent:e=>{console.warn("replaceCurrent",e)},closeCurrent:()=>{console.warn("closeCurrent")},duplicateCurrent:e=>{console.warn("duplicateCurrent",e)},setView:e=>{console.warn("setView",e)},setParams:e=>{i({...e,inspect:e.inspect??void 0})},setPayload:e=>{console.warn("setPayload",e)},navigateIntent:(e,t,n)=>{console.warn("navigateIntent",e,t,n)},createPathWithParams:u})),[u,i,s,a,o]);return e(je.Provider,{value:p,children:r})}const tn=de(Le)`
height: 100%;
`,rn=ue(c)`
`,nn=de(a)`
& > div {

@@ -19,9 +19,9 @@ min-width: none !important;

}
`,on=ue(h)`
`,rn=de(p)`
white-space: pre-wrap;
`;function an(e){const{mainDocumentState:t,onStructureParams:i,searchParams:o,refs:a}=e,{t:c}=K(pe),{devMode:l}=me(),u=$((()=>a.filter((e=>{var n;return B(e._id)!==(null==(n=null==t?void 0:t.document)?void 0:n._id)})).map((e=>e._id))),[t,a]),p=$((()=>({id:"$root",options:{filter:"_id in $ids",params:{ids:u}},schemaTypeName:"",title:c("document-list-pane.document-list.title"),type:"documentList"})),[u,c]),[m,h]=R(null),g=j((()=>h(null)),[]),[y]=R((()=>({})));return L((()=>h(null)),[a]),m?n(Zt,{flex:1,message:c("document-list-pane.error.text"),onRetry:g,children:l&&n(s,{overflow:"auto",padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(f,{muted:!0,size:0,children:c("presentation-error.label")}),n(on,{size:1,children:m.error.message})]})})}):n(v,{onCatch:h,children:n(nn,{children:n(Ae,{children:n(tn,{onStructureParams:i,structureParams:y,searchParams:o,refs:a,children:n(rn,{direction:"column",flex:1,children:n(We,{index:0,itemId:"$root",pane:p,paneKey:"$root"})})})})})})}const sn=ue(h)`
`;function on(n){const{mainDocumentState:r,onStructureParams:i,searchParams:a,refs:s}=n,{t:d}=N(le),{devMode:l}=ue(),u=D((()=>s.filter((e=>K(e._id)!==r?.document?._id)).map((e=>e._id))),[r,s]),p=D((()=>({id:"$root",options:{filter:"_id in $ids",params:{ids:u}},schemaTypeName:"",title:d("document-list-pane.document-list.title"),type:"documentList"})),[u,d]),[f,v]=$(null),g=O((()=>v(null)),[]),[y]=$((()=>({})));return R((()=>v(null)),[s]),f?e(Xt,{flex:1,message:d("document-list-pane.error.text"),onRetry:g,children:l&&e(o,{overflow:"auto",padding:3,radius:2,tone:"critical",children:t(c,{space:3,children:[e(m,{muted:!0,size:0,children:d("presentation-error.label")}),e(rn,{size:1,children:f.error.message})]})})}):e(h,{onCatch:v,children:e(tn,{children:e(Te,{children:e(en,{onStructureParams:i,structureParams:y,searchParams:a,refs:s,children:e(nn,{direction:"column",flex:1,children:e(Ue,{index:0,itemId:"$root",pane:p,paneKey:"$root"})})})})})})}const an=de(p)`
white-space: pre-wrap;
`;function cn(e){const{documentId:t,documentType:i,onFocusPath:o,onStructureParams:a,searchParams:c,structureParams:l}=e,{template:u,templateParams:p}=l,{t:m}=K(pe),{devMode:h}=me(),g=$((()=>({id:t,options:{id:t,type:i,template:u,templateParameters:de(p)},title:"",type:"document"})),[t,i,u,p]),[y,w]=R(null),b=j((()=>w(null)),[]);return L((()=>{w(null)}),[t,i,l]),y?n(Zt,{flex:1,message:m("document-pane.error.text"),onRetry:b,children:h&&n(s,{overflow:"auto",padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(f,{muted:!0,size:0,children:m("presentation-error.label")}),n(sn,{size:1,children:y.error.message})]})})}):n(v,{onCatch:w,children:n(Ue,{style:{height:"100%"},children:n(tn,{searchParams:c,onStructureParams:a,structureParams:l,children:n(Me,{paneKey:"document",index:1,itemId:"document",pane:g,onFocusPath:o})})})})}function ln(e){const{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,searchParams:a,structureParams:s}=e;return n(Ae,{children:n(cn,{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,searchParams:a,structureParams:s})})}function dn(e){var t;const{documentId:i,documentType:o,mainDocumentState:a,onFocusPath:l,onStructureParams:d,refs:p,searchParams:h,structureParams:f}=e,{t:v}=K(pe),g=H(),y=j((e=>n(ce,{...e,state:{id:a.document._id,type:a.document._type,_searchParams:Object.entries(h)}})),[a,h]),w=$((()=>{var e;return g.get((null==(e=null==a?void 0:a.document)?void 0:e._type)||"shoe")}),[a,g]),b=function(e,t){const n=q(),[r,i]=R({});return L((()=>{if(!t)return;const r=G(n,t,e,"").subscribe((e=>{i(e)}));return()=>{null==r||r.unsubscribe()}}),[n,t,e]),r}((null==(t=null==a?void 0:a.document)?void 0:t._id)||"",w),x=$((()=>null!=a&&a.document?n(J,{...X({value:a.document,published:b.published,draft:b.draft}),schemaType:w,status:n(s,{padding:1,radius:2,shadow:1,children:n(u,{muted:!0,size:0,weight:"medium",children:v("main-document.label")})})}):null),[a,w,v,b]);return i&&o?n(ln,{documentId:i,documentType:o,onFocusPath:l,onStructureParams:d,searchParams:h,structureParams:f}):r(c,{direction:"column",flex:1,height:"fill",children:[a&&n(s,{padding:3,tone:a.document?"inherit":"caution",children:a.document?n(Z,{__unstable_focusRing:!0,as:y,"data-as":"a",radius:2,sizing:"border",tone:"inherit",children:x}):n(s,{padding:2,radius:2,tone:"inherit",children:r(c,{gap:3,children:[n(m,{flex:"none",children:n(u,{size:1,children:n(ke,{})})}),n(m,{flex:1,children:n(u,{size:1,children:n(Q,{t:v,i18nKey:"main-document.missing.text",components:{Code:"code"},values:{path:a.path}})})})]})})}),n(an,{mainDocumentState:a,onStructureParams:d,searchParams:h,refs:p})]})}const un=ue.div`
`;function sn(n){const{documentId:r,documentType:i,onFocusPath:a,onStructureParams:s,searchParams:d,structureParams:l}=n,{template:u,templateParams:p}=l,{t:f}=N(le),{devMode:v}=ue(),g=D((()=>({id:r,options:{id:r,type:i,template:u,templateParameters:ce(p)},title:"",type:"document"})),[r,i,u,p]),[y,w]=$(null),b=O((()=>w(null)),[]);return R((()=>{w(null)}),[r,i,l]),y?e(Xt,{flex:1,message:f("document-pane.error.text"),onRetry:b,children:v&&e(o,{overflow:"auto",padding:3,radius:2,tone:"critical",children:t(c,{space:3,children:[e(m,{muted:!0,size:0,children:f("presentation-error.label")}),e(an,{size:1,children:y.error.message})]})})}):e(h,{onCatch:w,children:e(Le,{style:{height:"100%"},children:e(en,{searchParams:d,onStructureParams:s,structureParams:l,children:e(Ae,{paneKey:"document",index:1,itemId:"document",pane:g,onFocusPath:a})})})})}function cn(t){const{documentId:n,documentType:r,onFocusPath:i,onStructureParams:o,searchParams:a,structureParams:s}=t;return e(Te,{children:e(sn,{documentId:n,documentType:r,onFocusPath:i,onStructureParams:o,searchParams:a,structureParams:s})})}function dn(n){const{documentId:r,documentType:i,mainDocumentState:s,onFocusPath:c,onStructureParams:l,refs:p,searchParams:m,structureParams:h}=n,{t:f}=N(le),v=q(),g=O((t=>e(ae,{...t,state:{id:s.document._id,type:s.document._type,_searchParams:Object.entries(m)}})),[s,m]),y=D((()=>v.get(s?.document?._type||"shoe")),[s,v]),w=function(e,t){const n=V(),[r,i]=$({});return R((()=>{if(!t)return;const r=B(n,t,e,"").subscribe((e=>{i(e)}));return()=>{r?.unsubscribe()}}),[n,t,e]),r}(s?.document?._id||"",y),b=D((()=>s?.document?e(G,{...H({value:s.document,published:w.published,draft:w.draft}),schemaType:y,status:e(o,{padding:1,radius:2,shadow:1,children:e(d,{muted:!0,size:0,weight:"medium",children:f("main-document.label")})})}):null),[s,y,f,w]);return r&&i?e(cn,{documentId:r,documentType:i,onFocusPath:c,onStructureParams:l,searchParams:m,structureParams:h}):t(a,{direction:"column",flex:1,height:"fill",children:[s&&e(o,{padding:3,tone:s.document?"inherit":"caution",children:s.document?e(J,{__unstable_focusRing:!0,as:g,"data-as":"a",radius:2,sizing:"border",tone:"inherit",children:b}):e(o,{padding:2,radius:2,tone:"inherit",children:t(a,{gap:3,children:[e(u,{flex:"none",children:e(d,{size:1,children:e(xe,{})})}),e(u,{flex:1,children:e(d,{size:1,children:e(X,{t:f,i18nKey:"main-document.missing.text",components:{Code:"code"},values:{path:s.path}})})})]})})}),e(on,{mainDocumentState:s,onStructureParams:l,searchParams:m,refs:p})]})}const ln=de.div`
position: relative;
`,pn=ue.div`
`,un=de.div`
position: absolute;

@@ -47,3 +47,3 @@ top: 0;

${({$disabled:e})=>!e&&"\n /* Hover effect */\n & > span:nth-child(2) {\n display: block;\n position: absolute;\n top: 0;\n left: 0;\n width: 9px;\n bottom: 0;\n background-color: var(--card-border-color);\n opacity: 0;\n transition: opacity 150ms;\n }\n\n @media (hover: hover) {\n &:hover > span:nth-child(2) {\n opacity: 0.2;\n }\n }\n "}
`,mn=function({id:e,order:t,disabled:i=!1}){const o=O(null),a=D(Lt);if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const s=function(e){return O(e||it()).current}(e),{activeResizer:c,drag:l,startDragging:d,stopDragging:u,registerElement:p,unregisterElement:m}=a,h=c===s;if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const f=j((e=>{d(s,e.nativeEvent)}),[s,d]),v=j((e=>{l(s,e)}),[s,l]),g=j((()=>{o.current.blur(),u()}),[u]);return L((()=>{if(!h||i)return;const e=function(){const e=document.body.style,t=document.documentElement.style,{cursor:n}=t,{userSelect:r}=e;return t.cursor="ew-resize",e.userSelect="none",()=>{n?t.cursor=n:t.removeProperty("cursor"),r?e.userSelect=r:e.removeProperty("user-select")}}();return window.addEventListener("mousemove",v),window.addEventListener("mouseup",g),window.addEventListener("contextmenu",g),()=>{e(),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",g),window.removeEventListener("contextmenu",g)}}),[i,h,v,g]),C((()=>(p(s,{id:s,order:t,type:"resizer",el:o}),()=>{m(s)})),[s,t,p,m]),n(un,{onMouseDown:f,ref:o,children:r(pn,{$disabled:i,children:[n("span",{}),n("span",{})]})})},hn=e=>{const{documentId:t,setDisplayedDocument:o,getCommentIntent:a}=e;return r(i,{children:[n(mn,{order:4}),n(Ut,{id:"content",minWidth:325,order:5,children:n(Ne,{documentId:t,setDisplayedDocument:o,children:n(Y,{getIntent:a,children:e.children})})})]})},fn=e=>{const{documentId:t,documentsOnPage:r,documentType:i,getCommentIntent:o,mainDocumentState:a,onFocusPath:s,onStructureParams:c,searchParams:l,setDisplayedDocument:d,structureParams:u}=e;return n(hn,{documentId:t,getCommentIntent:o,setDisplayedDocument:d,children:n(dn,{documentId:t,documentType:i,mainDocumentState:a,onFocusPath:s,onStructureParams:c,refs:r,searchParams:l,structureParams:u})})},vn=function(e){const{children:t,navigate:r}=e,i=j(((e,t=void 0)=>{r(t||{},e?{preview:e}:{})}),[r]);return n(he.Provider,{value:i,children:t})};function gn(e){const{unstable_navigator:t}=e,r=!(null==t||!t.component),[o,a]=function(e,t){const[n,r]=R((()=>{var n;return JSON.parse(null!=(n=localStorage.getItem(e))?n:JSON.stringify(t))}));return L((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,r]}("presentation/navigator",r),s=!!r&&o,c=$((()=>{if(r)return()=>a((e=>!e))}),[r,a]),l=j((function(){return n(i,{children:s&&n(yn,{...t})})}),[s,t]);return[{navigatorEnabled:s,toggleNavigator:c},l]}const yn=U((function(e){const{minWidth:t,maxWidth:o,component:a}=e,s=null!=t&&null!=o&&t===o;return r(i,{children:[n(Ut,{id:"navigator",minWidth:t,maxWidth:o,order:1,children:n(a,{})}),n(mn,{order:2,disabled:s})]})})),wn=function(e){const{children:t,params:r}=e,i=$((()=>r),[r]);return n(fe.Provider,{value:i,children:t})},bn=function(e){const{children:t,devMode:r,name:i,navigate:o,params:a,searchParams:s,structureParams:c}=e,l=$((()=>({devMode:r,name:i,navigate:o,params:a,searchParams:s,structureParams:c})),[r,i,o,a,s,c]);return n(ve.Provider,{value:l,children:t})},xn="ACTION_IFRAME_LOADED",Pn="ACTION_IFRAME_REFRESH",kn="ACTION_IFRAME_RELOAD",En="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",Sn=(e,t)=>{switch(t.type){case xn:return"loaded"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"loaded"}};case Pn:return"refreshing"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"refreshing"}};case kn:return"reloading"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"reloading"}};case En:return In(e,t);default:return e}},In=(e,t)=>e.visualEditing.overlaysEnabled===t.enabled?e:{...e,visualEditing:{...e.visualEditing,overlaysEnabled:t.enabled}},_n=($n=xt(),On=!1,{...$n,fallback:On,_run(e,t){return $n._run(e,t),e.issues?{typed:!0,value:bt(this,e,t)}:e}}),zn=function e(t,n){return{kind:"schema",type:"picklist",reference:e,expects:t.map(vt).join(" | ")||"never",async:!1,options:t,message:n,_run(e,t){return this.options.includes(e.value)?e.typed=!0:gt(this,"type",e,t),e}}}(["loading","loaded","refreshing","reloading"]),Dn=Pt({mainDocument:_n,iframe:Pt({status:zn}),visualEditing:Pt({overlaysEnabled:xt()})}),Cn={mainDocument:!1,iframe:{status:"loading"},visualEditing:{overlaysEnabled:!1}};var $n,On;function Rn(e){return St(Dn,{...Cn,...e})}const jn=Be(ue.iframe`
`,pn=function({id:n,order:r,disabled:i=!1}){const o=C(null),a=_(jt);if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const s=function(e){return C(e||rt()).current}(n),{activeResizer:c,drag:d,startDragging:l,stopDragging:u,registerElement:p,unregisterElement:m}=a,h=c===s;if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const f=O((e=>{l(s,e.nativeEvent)}),[s,l]),v=O((e=>{d(s,e)}),[s,d]),g=O((()=>{o.current.blur(),u()}),[u]);return R((()=>{if(!h||i)return;const e=function(){const e=document.body.style,t=document.documentElement.style,{cursor:n}=t,{userSelect:r}=e;return t.cursor="ew-resize",e.userSelect="none",()=>{n?t.cursor=n:t.removeProperty("cursor"),r?e.userSelect=r:e.removeProperty("user-select")}}();return window.addEventListener("mousemove",v),window.addEventListener("mouseup",g),window.addEventListener("contextmenu",g),()=>{e(),window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",g),window.removeEventListener("contextmenu",g)}}),[i,h,v,g]),z((()=>(p(s,{id:s,order:r,type:"resizer",el:o}),()=>{m(s)})),[s,r,p,m]),e(ln,{onMouseDown:f,ref:o,children:t(un,{$disabled:i,children:[e("span",{}),e("span",{})]})})},mn=r=>{const{documentId:i,setDisplayedDocument:o,getCommentIntent:a}=r;return t(n,{children:[e(pn,{order:4}),e(Tt,{id:"content",minWidth:325,order:5,children:e(We,{documentId:i,setDisplayedDocument:o,children:e(Z,{getIntent:a,children:r.children})})})]})},hn=t=>{const{documentId:n,documentsOnPage:r,documentType:i,getCommentIntent:o,mainDocumentState:a,onFocusPath:s,onStructureParams:c,searchParams:d,setDisplayedDocument:l,structureParams:u}=t;return e(mn,{documentId:n,getCommentIntent:o,setDisplayedDocument:l,children:e(dn,{documentId:n,documentType:i,mainDocumentState:a,onFocusPath:s,onStructureParams:c,refs:r,searchParams:d,structureParams:u})})},fn=function(t){const{children:n,navigate:r}=t,i=O(((e,t=void 0)=>{r(t||{},e?{preview:e}:{})}),[r]);return e(pe.Provider,{value:i,children:n})};function vn(t){const{unstable_navigator:r}=t,i=!!r?.component,[o,a]=function(e,t){const[n,r]=$((()=>JSON.parse(localStorage.getItem(e)??JSON.stringify(t))));return R((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,r]}("presentation/navigator",i),s=!!i&&o,c=D((()=>{if(i)return()=>a((e=>!e))}),[i,a]),d=O((function(){return e(n,{children:s&&e(gn,{...r})})}),[s,r]);return[{navigatorEnabled:s,toggleNavigator:c},d]}const gn=L((function(r){const{minWidth:i,maxWidth:o,component:a}=r,s=null!=i&&null!=o&&i===o;return t(n,{children:[e(Tt,{id:"navigator",minWidth:i,maxWidth:o,order:1,children:e(a,{})}),e(pn,{order:2,disabled:s})]})})),yn=function(t){const{children:n,params:r}=t,i=D((()=>r),[r]);return e(me.Provider,{value:i,children:n})},wn=function(t){const{children:n,devMode:r,name:i,navigate:o,params:a,searchParams:s,structureParams:c}=t,d=D((()=>({devMode:r,name:i,navigate:o,params:a,searchParams:s,structureParams:c})),[r,i,o,a,s,c]);return e(he.Provider,{value:d,children:n})},bn="ACTION_IFRAME_LOADED",xn="ACTION_IFRAME_REFRESH",Pn="ACTION_IFRAME_RELOAD",kn="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",En=(e,t)=>{switch(t.type){case bn:return"loaded"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"loaded"}};case xn:return"refreshing"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"refreshing"}};case Pn:return"reloading"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"reloading"}};case kn:return Sn(e,t);default:return e}},Sn=(e,t)=>e.visualEditing.overlaysEnabled===t.enabled?e:{...e,visualEditing:{...e.visualEditing,overlaysEnabled:t.enabled}},In=(Cn=bt(),$n=!1,{...Cn,fallback:$n,_run(e,t){return Cn._run(e,t),e.issues?{typed:!0,value:wt(this,e,t)}:e}}),_n=function e(t,n){return{kind:"schema",type:"picklist",reference:e,expects:t.map(ft).join(" | ")||"never",async:!1,options:t,message:n,_run(e,t){return this.options.includes(e.value)?e.typed=!0:vt(this,"type",e,t),e}}}(["loading","loaded","refreshing","reloading"]),zn=xt({mainDocument:In,iframe:xt({status:_n}),visualEditing:xt({overlaysEnabled:bt()})}),Dn={mainDocument:!1,iframe:{status:"loading"},visualEditing:{overlaysEnabled:!1}};var Cn,$n;function On(e){return Et(zn,{...Dn,...e})}const Rn=Ke(de.iframe`
box-shadow: 0 0 0 1px var(--card-border-color);

@@ -56,8 +56,8 @@ border-top: 1px solid transparent;

width: 100%;
`),Ln=ue(m)`
`),jn=de(u)`
position: absolute;
inset: 0;
background: transparent;
`,Tn=T((function(e,t){const{animate:o,initial:a,onLoad:s,preventClick:c,src:l,variants:d}=e;return r(i,{children:[n(jn,{animate:o,initial:a,onLoad:s,ref:t,src:l,variants:d}),c&&n(Ln,{})]})})),Un=function(e){var t;const{fontSize:r=1,onChange:o,origin:a,padding:s=3,prefix:c,suffix:l,value:d}=e,{t:u}=K(pe),{basePath:p="/"}=(null==(t=ee())?void 0:t.activeWorkspace)||{},m=O(null),[h,f]=R(void 0),[v,y]=R(void 0),w=j((e=>{f(e.currentTarget.value)}),[]),b=j((e=>{var t;if("Enter"===e.key){if(void 0===h)return;const e=h.startsWith("/")||""===h?`${a}${h}`:h;if(!e.startsWith(a+"/")&&e!==a)return void y(u("preview-location-input.error",{origin:a,context:"missing-origin"}));if(!a&&(e.startsWith(`${p}/`)||e===p))return void y(u("preview-location-input.error",{basePath:p,context:"same-base-path"}));const n=e===a?a+"/":e;y(void 0),f(void 0),o(n.slice(a.length)),null==(t=m.current)||t.blur()}"Escape"===e.key&&(y(void 0),f(void 0))}),[p,o,a,h,u]),x=j((()=>{y(void 0),f(void 0)}),[]);L((()=>{y(void 0),f(void 0)}),[a,d]);const P=$((()=>({icon:Ee})),[]);return n(i,{children:n(g,{clearButton:v?P:void 0,customValidity:v,fontSize:r,onBlur:x,onClear:()=>{y(void 0),f(a+d)},onChange:w,onKeyDownCapture:b,padding:s,prefix:c,style:{zIndex:1},radius:2,ref:m,space:s,suffix:l,value:void 0===h?`${a}${d}`:h})})};function An(e){const{initialUrl:t,openPopup:o,previewLocationOrigin:a,previewLocationRoute:s}=e,{t:c}=K(pe),l=j((e=>{e.preventDefault(),o(e.currentTarget.href)}),[o]);return r(i,{children:[n(Wn,{initialUrl:t,previewLocationOrigin:a,previewLocationRoute:s}),n(y,{icon:Se,text:c("share-url.menu-item.open.text"),as:"a",href:`${a}${s}`,onClick:l,rel:"opener",target:"_blank"})]})}function Wn(e){const{initialUrl:t,previewLocationOrigin:r,previewLocationRoute:i}=e,{t:o}=K(pe),{push:a}=w(),s=te({apiVersion:ge}),c=ne(),[l,d]=R(!1);return n(y,{disabled:l,onClick:()=>{if(null==navigator||!navigator.clipboard)return a({closable:!0,status:"error",title:o("share-url.clipboard.status",{context:"unsupported"})}),!1;let e;d(!0);const n=`${r}${i}`,l=()=>{a({id:e,closable:!0,status:"success",title:o("share-url.clipboard.status",{context:"success"})}),d(!1)},u=e=>{a({closable:!0,status:"error",title:o("share-url.clipboard.status",{context:"failed"}),description:e.message||e.toString()}),d(!1)};if(Fe(t)){const n=async()=>{e=a({closable:!0,title:o("share-url.clipboard.status",{context:"copying"})});const n=await He(s,"@sanity/presentation",typeof window>"u"?"":location.href,null==c?void 0:c.id);return Ke(t,n.secret,i).toString()};if(typeof ClipboardItem<"u"){const e="text/plain",t=new ClipboardItem({[e]:n().then((t=>new Blob([t],{type:e})))});navigator.clipboard.write([t]).then(l).catch(u)}else n().then((e=>navigator.clipboard.writeText(e))).then(l).catch(u)}else navigator.clipboard.writeText(n).then(l).catch(u)},text:o("share-url.menu-item.copy.text"),icon:Ie})}const Mn=Be(c),Nn={previewDrafts:"preview-frame.perspective.previewDrafts.title",published:"preview-frame.perspective.published.title"},Fn="caution",Kn="positive",Vn={previewDrafts:je,published:Le},Bn=T((function(e,t){const{dispatch:o,iframe:l,initialUrl:p,loadersConnection:v,navigatorEnabled:g,onPathChange:w,onRefresh:_,openPopup:z,overlaysConnection:D,perspective:C,previewUrl:O,setPerspective:T,setViewport:U,targetOrigin:W,toggleNavigator:M,toggleOverlay:N,viewport:F,visualEditing:{overlaysEnabled:V}}=e,{t:B}=K(pe),{devMode:q}=me(),G=b(),H=j((()=>U("desktop"===F?"mobile":"desktop")),[U,F]),J="loading"===l.status||"reloading"===l.status,[X,Z]=R(!1),Q="refreshing"===l.status,[Y,ee]=R(!1),te=J||Q||"connecting"===D,ne=$((()=>W===location.origin?"":W),[W]),ie=j((()=>{_((()=>{"function"==typeof t||null==t||!t.current||(o({type:kn}),t.current.src=`${W}${O||"/"}`)}))}),[o,_,O,W,t]),oe=j((()=>{"function"==typeof t||null==t||!t.current||(t.current.src=p.toString(),o({type:kn}))}),[o,t,p]),ae=j((()=>{ce(!0)}),[]),[se,ce]=R(!1),[le,de]=R(!1);L((()=>{if(!(J||Q||"connecting"!==D&&"reconnecting"!==D)){const e=setTimeout((()=>{de(!0)}),1e3);return()=>clearTimeout(e)}}),[D,J,Q]),L((()=>{if(!J&&!Q&&le){if("connected"===D&&(ee(!1),de(!1),Z(!1),ce(!1)),"connecting"===D){const e=setTimeout((()=>{Z(!0),console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly")}),ye);return()=>clearTimeout(e)}if("reconnecting"===D){const e=setTimeout((()=>{Z(!0),ee(!0)}),ye);return()=>clearTimeout(e)}"disconnected"===D&&ee(!0)}}),[J,D,Q,le]);const ue=$((()=>{const e=new URL(O||"/",W),{pathname:t,search:n}=Ve(e);return`${t}${n}`}),[O,W]),he=j((()=>{o({type:xn})}),[o]);L((()=>{if("function"==typeof t||null==t||!t.current)return;const e=t.current;function n(){e===document.activeElement&&e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0}))}return window.addEventListener("blur",n),()=>{window.removeEventListener("blur",n)}}),[t]);const fe=$((()=>(J||"connecting"===D&&"refreshing"!==l.status)&&!se),[se,l.status,J,D]),ve=$((()=>[fe?"background":"active",J?"reloading":"idle",F,le&&!se?"timedOut":""]),[se,J,fe,le,F]);return n(qe,{transition:G?{duration:0}:void 0,children:r(x,{delay:1e3,children:[n(s,{flex:"none",padding:2,shadow:1,style:{position:"relative"},children:r(c,{align:"center",style:{minHeight:0},children:[M&&n(m,{flex:"none",marginRight:1,padding:1,children:n(P,{animate:!0,content:n(u,{size:1,children:B("preview-frame.navigator.toggle-button.tooltip")}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":B("preview-frame.navigator.toggle-button.aria-label"),fontSize:1,icon:_e,mode:"bleed",onClick:M,padding:2,selected:g})})}),n(P,{animate:!0,content:r(c,{align:"center",style:{whiteSpace:"nowrap"},children:[n(m,{padding:1,children:n(u,{size:1,children:B("preview-frame.overlay.toggle-button.tooltip",{context:V?"disable":"enable"})})}),n(m,{paddingY:1,children:n(re,{keys:["Alt"],style:{marginTop:-4,marginBottom:-4}})})]}),fallbackPlacements:["bottom-start"],padding:1,placement:"bottom",portal:!0,children:n(s,{as:"label",flex:"none",marginRight:1,padding:3,style:{lineHeight:0,borderRadius:999,userSelect:"none"},tone:V?"transparent":void 0,children:r(c,{align:"center",gap:3,children:[n("div",{style:{margin:-4},children:n(k,{checked:V,onChange:N,disabled:"loading"===l.status||"connected"!==D})}),n(m,{children:n(u,{muted:!V,size:1,weight:"medium",children:B("preview-frame.overlay.toggle-button.text")})})]})})}),n(m,{flex:1,marginX:1,children:n(Un,{prefix:n(m,{padding:1,children:n(P,{animate:!0,content:n(u,{size:1,children:"loaded"===l.status?B("preview-frame.refresh-button.tooltip"):B("preview-frame.status",{context:l.status})}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":B("preview-frame.refresh-button.aria-label"),fontSize:1,icon:ze,mode:"bleed",loading:"reloading"===l.status||"refreshing"===l.status,onClick:ie,padding:2})})}),onChange:w,origin:ne,suffix:n(m,{padding:1,children:n(E,{button:n(a,{fontSize:1,iconRight:De,mode:"bleed",padding:2,space:2}),id:"location-menu",menu:n(S,{children:n(An,{initialUrl:p,openPopup:z,previewLocationOrigin:ne,previewLocationRoute:ue})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),value:ue})}),n(c,{align:"center",flex:"none",gap:1,padding:1,children:n(E,{button:n(a,{fontSize:1,iconRight:Ce,mode:"bleed",padding:2,space:2,text:B(Nn["connected"===v?C:"previewDrafts"]),loading:"reconnecting"===v&&"loaded"!==l.status,disabled:"connected"!==v}),id:"perspective-menu",menu:r(S,{style:{maxWidth:240},children:[n(y,{fontSize:1,onClick:()=>T("previewDrafts"),padding:3,pressed:"previewDrafts"===C,tone:Fn,children:r(c,{align:"flex-start",gap:3,children:[n(m,{flex:"none",children:n(u,{size:1,children:A(Vn.previewDrafts)})}),r(d,{flex:1,space:2,children:[n(u,{size:1,weight:"medium",children:B(Nn.previewDrafts)}),n(u,{muted:!0,size:1,children:B("preview-frame.perspective.previewDrafts.text")})]}),n(m,{flex:"none",children:n(u,{muted:!0,size:1,style:{opacity:"previewDrafts"===C?1:0},children:n($e,{})})})]})}),n(y,{fontSize:1,onClick:()=>T("published"),padding:3,pressed:"published"===C,tone:Kn,children:r(c,{align:"flex-start",gap:3,children:[n(m,{flex:"none",children:n(u,{size:1,children:A(Vn.published)})}),r(d,{flex:1,space:2,children:[n(u,{size:1,weight:"medium",children:B(Nn.published)}),n(u,{muted:!0,size:1,children:B("preview-frame.perspective.published.text")})]}),n(m,{flex:"none",children:n(u,{muted:!0,size:1,style:{opacity:"published"===C?1:0},children:n($e,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),n(c,{align:"center",flex:"none",gap:1,children:n(P,{animate:!0,content:n(u,{size:1,children:B("preview-frame.viewport-button.tooltip",{context:"desktop"===F?"narrow":"full"})}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":B("preview-frame.viewport-button.aria-label"),fontSize:1,icon:"desktop"===F?Oe:Re,mode:"bleed",onClick:H,padding:2})})})]})}),n(s,{flex:1,tone:"transparent",children:r(c,{align:"center",height:"fill",justify:"center",padding:"desktop"===F?0:2,sizing:"border",style:{position:"relative",cursor:te?"wait":void 0},children:[n(Ge,{children:Y||J||Q||!le||se?(J||"connecting"===D&&"refreshing"!==l.status)&&!se?n(Mn,{initial:"initial",animate:"animate",exit:"exit",variants:Gn,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:r(c,{style:{...qn[F]},justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(u,{muted:!0,size:1,children:B("preview-frame.status",{context:"loading"})})]})}):Y&&!se?n(Mn,{initial:"initial",animate:"animate",exit:"exit",variants:Hn,justify:"center",align:"center",style:{background:"var(--card-bg-color)",inset:"0",position:"absolute",borderTop:"1px solid transparent",boxShadow:"0 0 0 1px var(--card-border-color)"},children:n(Zt,{flex:1,message:B("preview-frame.connection.error.text"),onRetry:oe,onContinueAnyway:ae,children:q&&r(i,{children:["connected"!==D&&n(s,{padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(f,{muted:!0,size:0,children:B("preview-frame.overlay.connection-status.label")}),n(h,{size:1,children:B("channel.status",{context:D})})]})}),"connected"!==v&&n(s,{padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(f,{muted:!0,size:0,children:B("preview-frame.loader.connection-status.label")}),n(h,{size:1,children:B("channel.status",{context:v})})]})})]})})}):null:n(Mn,{initial:"initial",animate:"animate",exit:"exit",variants:Gn,justify:"center",align:"center",style:{inset:"0",position:"absolute",backdropFilter:X?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",transition:"backdrop-filter 0.2s ease-in-out",WebkitBackdropFilter:X?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",WebkitTransition:"-webkit-backdrop-filter 0.2s ease-in-out",zIndex:1},children:r(c,{style:{...qn[F]},justify:"center",align:"center",direction:"column",gap:4,children:[X&&n(a,{disabled:!0,fontSize:1,mode:"ghost",text:B("preview-frame.continue-button.text"),style:{opacity:0}}),n(s,{radius:2,tone:X?"caution":"inherit",padding:4,shadow:1,children:r(c,{justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(u,{muted:!0,size:1,children:B("preview-frame.status",X?{context:"timeout"}:{context:"connecting"})})]})}),X&&n(a,{fontSize:1,tone:"critical",onClick:ae,text:B("preview-frame.continue-button.text")})]})})}),n(Tn,{animate:ve,initial:["background"],onLoad:he,preventClick:fe,ref:t,src:p.toString(),variants:Jn})]})})]})})})),qn={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},Gn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Hn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Jn={desktop:{...qn.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...qn.mobile,boxShadow:"0 0 0 1px var(--card-border-color)"},background:{opacity:0,scale:1},idle:{scale:1},reloading:{scale:[1,1,1,.98]},active:{opacity:[0,0,1],scale:1},timedOut:{opacity:[0,0,1]}};const Xn=function(e){const{documentId:t,documentType:n,navigate:r,perspective:i,documentRevision:o}=e,a=ie(t,n);return function(e,t,n,r,i){const o=O(r),a=j(t,n);L((()=>{const t=o.current;if(o.current=e,e!==t)return a(e,t)}),[a,i,e])}(i,(e=>{let t;if("published"===e&&a.published){const{_updatedAt:e,_rev:n}=a.published;t=`${e}/${n}`}o!==t&&r({},{rev:t},!0)}),[a,r,o]),null};let Zn=!1;function Qn(e,t){return e instanceof Function?e(t):e}function Yn(e,t){const n=Array.isArray(e)?e:[e];for(e of n){let n,r=e;if("string"==typeof e)try{const t=new URL(e);n=t.origin,r=t.pathname}catch{}if(!n||t.origin===n)try{const e=Xe(r,{decode:decodeURIComponent})(t.pathname);if(e){const{params:t,path:r}=e;return{origin:n,params:t,path:r}}}catch{throw new Error(`"${e}" is not a valid route pattern`)}}}function er(e){const{navigate:t,navigationHistory:n,path:r,previewUrl:i,resolvers:o=[]}=e,{state:a}=le(),s=te({apiVersion:ge}),[c,l]=R(void 0),d=O(void 0),u=$((()=>{var e,t;const n=r||(null==(t=null==(e=a._searchParams)?void 0:e.find((([e])=>"preview"===e)))?void 0:t[1])||"",o="string"==typeof i?i:"object"==typeof i&&(null==i?void 0:i.origin)||location.origin;return new URL(n,o)}),[r,i,a._searchParams]),p=j((()=>{l(void 0),d.current=void 0}),[]);return L((()=>{if(o.length&&u){let p;for(const e of o){const t=Yn(e.route,u);if(t){p={context:t,resolver:e};break}}if(p){const o=function(e,t){var n;if(e.resolve){const r=null==(n=e.resolve(t))?void 0:n.filter;return r?`*[${r}][0]{_id, _type}`:void 0}return"type"in e?`*[_type == "${e.type}"][0]{_id, _type}`:`*[${Qn(e.filter,t)}][0]{_id, _type}`}(p.resolver,p.context),m=(e=p.resolver,r=p.context,e.resolve?null!=(a=null==(i=e.resolve(r))?void 0:i.params)?a:r.params:"type"in e?{}:null!=(c=Qn(e.params,r))?c:r.params);if(o){const e=new AbortController,r={perspective:"previewDrafts",signal:e.signal};return s.fetch(o,m,r).then((e=>{var r,i;(!e||d.current!==e._id)&&(l({document:e,path:u.pathname}),d.current=null==e?void 0:e._id,(null==(r=n.at(-1))?void 0:r.id)===(null==(i=n.at(-2))?void 0:i.id)&&(null==t||t({id:null==e?void 0:e._id,type:null==e?void 0:e._type})))})).catch((e=>{e instanceof Error&&"AbortError"===e.name||(l({document:void 0,path:u.pathname}),d.current=void 0)})),()=>{e.abort()}}}}var e,r,i,a,c;p()}),[s,p,t,n,o,u]),c}function tr(e){var t;if(void 0===e)return;const n=null==(t=decodeURIComponent(e))?void 0:t.split(".");return"drafts"===n[0]&&n.shift(),n.join(".")}function nr(e){if(void 0!==e)return o.toString(function(e){const t=[];for(const n of e.split(".")){const e=It.exec(n);if(e){t.push(e[1],Number(e[2]));continue}const r=_t.exec(n);if(r){t.push(r[1],[Number(r[2]),Number(r[3])]);continue}const i=zt.exec(n);i?t.push(i[1],{_key:i[2]}):t.push(n)}return t}(decodeURIComponent(e)))}function rr(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function ir({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:r,frameStateRef:i}){const o=$((()=>{const{id:t,path:i,type:o}={id:tr((a=n).id),path:nr(a.path),type:a.type};var a;return{id:t,type:o,path:i,preview:r.preview||`${e.pathname}${e.search}`,perspective:r.perspective,viewport:r.viewport,inspect:r.inspect,rev:r.rev,since:r.since,template:r.template,templateParams:r.templateParams,view:r.view,pathKey:r.pathKey,instruction:r.instruction,comment:r.comment}}),[n,r,e]),a=$((()=>rr({inspect:o.inspect,path:o.path,rev:o.rev,since:o.since,template:o.template,templateParams:o.templateParams,view:o.view,pathKey:o.pathKey,instruction:o.instruction,comment:o.comment})),[o.comment,o.inspect,o.instruction,o.path,o.pathKey,o.rev,o.since,o.template,o.templateParams,o.view]),s=$((()=>rr({perspective:o.perspective,preview:o.preview,viewport:o.viewport})),[o.perspective,o.preview,o.viewport]),c=O(n);L((()=>{c.current=n}),[n]);const[l,d]=R([n]);return{navigate:j(((e,n={},r)=>{e.id&&(e.id=B(e.id));const{_searchParams:o,...a}=c.current,s=(o||[]).reduce(((e,[t,n])=>(e[t]=n,e)),{}),l=rr({...a,...e}),u=rr({...s,...n});a.id!==l.id&&(delete u.template,delete u.templateParams),l._searchParams=Object.entries(u).reduce(((e,[t,n])=>[...e,[t,n]]),[]);const p=null!=r?r:u.preview===i.current.url;d((e=>[...e,l])),t(l,{replace:p})}),[t,i]),navigationHistory:l,params:o,searchParams:s,structureParams:a}}function or(e,t,n){var r,i;const o=te({apiVersion:ge}),a=ee(),s=(null==(r=null==a?void 0:a.activeWorkspace)?void 0:r.basePath)||"/",c=(null==(i=null==a?void 0:a.activeWorkspace)?void 0:i.name)||"default",l=function(e,t,n,r){const[i,o]=R((()=>r||"")),a=O(0);L((()=>{if(i&&r)return window.clearTimeout(a.current),()=>{a.current=window.setTimeout((()=>{o("")}),100)}}),[i,r]);const s=ne();return $((()=>["@sanity/presentation",t,n,e,null==s?void 0:s.id,ar,i]),[t,null==s?void 0:s.id,e,n,i])}(t,s,c,n),d=function(e,t){const n=te({apiVersion:ge}),r=ne(),[i,o]=R(""),a=e?Qe((async()=>await He(n,"@sanity/presentation",typeof window>"u"?"":location.href,null==r?void 0:r.id)),[...t,i]):null;return L((()=>{if(!a)return;const e=setTimeout((()=>{W((()=>o(a.expiresAt.toString())))}),a.expiresAt.getTime()-Date.now());return()=>clearTimeout(e)}),[a]),(null==a?void 0:a.secret)||null}("object"==typeof e||"function"==typeof e,l);return Qe((async()=>{if("string"==typeof e){const t=new URL(e,location.origin);let r=t;try{if(n){const e=new URL(n,t);e.origin===t.origin&&(r=e)}else if(document.referrer){const e=new URL(document.referrer);e.origin===t.origin&&(r=e)}}catch{}return location.origin!==r.origin||!r.pathname.startsWith(`${s}/`)&&r.pathname!==s?r:t}const t=await("object"==typeof e?Ze(e):e)({client:o,previewUrlSecret:d,previewSearchParam:n,referrer:typeof document>"u"?null:document.referrer,studioBasePath:s});return new URL(t,location.origin)}),[...l,d])}const ar=Symbol();const sr=F((()=>import("./LoaderQueries.js"))),cr=F((()=>import("./PostMessageRefreshMutations.js"))),lr=ue(c)`
`,Ln=j((function(r,i){const{animate:o,initial:a,onLoad:s,preventClick:c,src:d,variants:l}=r;return t(n,{children:[e(Rn,{animate:o,initial:a,onLoad:s,ref:i,src:d,variants:l}),c&&e(jn,{})]})})),Tn=function(t){const{fontSize:r=1,onChange:i,origin:o,padding:a=3,prefix:s,suffix:c,value:d}=t,{t:l}=N(le),{basePath:u="/"}=Q()?.activeWorkspace||{},p=C(null),[m,h]=$(void 0),[v,g]=$(void 0),y=O((e=>{h(e.currentTarget.value)}),[]),w=O((e=>{if("Enter"===e.key){if(void 0===m)return;const e=m.startsWith("/")||""===m?`${o}${m}`:m;if(!e.startsWith(o+"/")&&e!==o)return void g(l("preview-location-input.error",{origin:o,context:"missing-origin"}));if(!o&&(e.startsWith(`${u}/`)||e===u))return void g(l("preview-location-input.error",{basePath:u,context:"same-base-path"}));const t=e===o?o+"/":e;g(void 0),h(void 0),i(t.slice(o.length)),p.current?.blur()}"Escape"===e.key&&(g(void 0),h(void 0))}),[u,i,o,m,l]),b=O((()=>{g(void 0),h(void 0)}),[]);R((()=>{g(void 0),h(void 0)}),[o,d]);const x=D((()=>({icon:Pe})),[]);return e(n,{children:e(f,{clearButton:v?x:void 0,customValidity:v,fontSize:r,onBlur:b,onClear:()=>{g(void 0),h(o+d)},onChange:y,onKeyDownCapture:w,padding:a,prefix:s,style:{zIndex:1},radius:2,ref:p,space:a,suffix:c,value:void 0===m?`${o}${d}`:m})})};function Un(r){const{initialUrl:i,openPopup:o,previewLocationOrigin:a,previewLocationRoute:s}=r,{t:c}=N(le),d=O((e=>{e.preventDefault(),o(e.currentTarget.href)}),[o]);return t(n,{children:[e(An,{initialUrl:i,previewLocationOrigin:a,previewLocationRoute:s}),e(v,{icon:ke,text:c("share-url.menu-item.open.text"),as:"a",href:`${a}${s}`,onClick:d,rel:"opener",target:"_blank"})]})}function An(t){const{initialUrl:n,previewLocationOrigin:r,previewLocationRoute:i}=t,{t:o}=N(le),{push:a}=g(),s=Y({apiVersion:fe}),c=ee(),[d,l]=$(!1);return e(v,{disabled:d,onClick:()=>{if(!navigator?.clipboard)return a({closable:!0,status:"error",title:o("share-url.clipboard.status",{context:"unsupported"})}),!1;let e;l(!0);const t=`${r}${i}`,d=()=>{a({id:e,closable:!0,status:"success",title:o("share-url.clipboard.status",{context:"success"})}),l(!1)},u=e=>{a({closable:!0,status:"error",title:o("share-url.clipboard.status",{context:"failed"}),description:e.message||e.toString()}),l(!1)};if(Me(n)){const t=async()=>{e=a({closable:!0,title:o("share-url.clipboard.status",{context:"copying"})});const t=await qe(s,"@sanity/presentation",typeof window>"u"?"":location.href,c?.id);return Ne(n,t.secret,i).toString()};if(typeof ClipboardItem<"u"){const e="text/plain",n=new ClipboardItem({[e]:t().then((t=>new Blob([t],{type:e})))});navigator.clipboard.write([n]).then(d).catch(u)}else t().then((e=>navigator.clipboard.writeText(e))).then(d).catch(u)}else navigator.clipboard.writeText(t).then(d).catch(u)},text:o("share-url.menu-item.copy.text"),icon:Ee})}const Wn=Ke(a),Mn={previewDrafts:"preview-frame.perspective.previewDrafts.title",published:"preview-frame.perspective.published.title"},Nn="caution",Fn="positive",Kn={previewDrafts:Oe,published:Re},Vn=j((function(r,s){const{dispatch:l,iframe:h,initialUrl:f,loadersConnection:g,navigatorEnabled:S,onPathChange:I,onRefresh:_,openPopup:z,overlaysConnection:C,perspective:j,previewUrl:L,setPerspective:U,setViewport:A,targetOrigin:W,toggleNavigator:M,toggleOverlay:F,viewport:K,visualEditing:{overlaysEnabled:V}}=r,{t:B}=N(le),{devMode:q}=ue(),G=y(),H=O((()=>A("desktop"===K?"mobile":"desktop")),[A,K]),J="loading"===h.status||"reloading"===h.status,[X,Z]=$(!1),Q="refreshing"===h.status,[Y,ee]=$(!1),ne=J||Q||"connecting"===C,re=D((()=>W===location.origin?"":W),[W]),ie=O((()=>{_((()=>{"function"==typeof s||!s?.current||(l({type:Pn}),s.current.src=`${W}${L||"/"}`)}))}),[l,_,L,W,s]),oe=O((()=>{"function"==typeof s||!s?.current||(s.current.src=f.toString(),l({type:Pn}))}),[l,s,f]),ae=O((()=>{ce(!0)}),[]),[se,ce]=$(!1),[de,pe]=$(!1);R((()=>{if(!(J||Q||"connecting"!==C&&"reconnecting"!==C)){const e=setTimeout((()=>{pe(!0)}),1e3);return()=>clearTimeout(e)}}),[C,J,Q]),R((()=>{if(!J&&!Q&&de){if("connected"===C&&(ee(!1),pe(!1),Z(!1),ce(!1)),"connecting"===C){const e=setTimeout((()=>{Z(!0),console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly")}),ve);return()=>clearTimeout(e)}if("reconnecting"===C){const e=setTimeout((()=>{Z(!0),ee(!0)}),ve);return()=>clearTimeout(e)}"disconnected"===C&&ee(!0)}}),[J,C,Q,de]);const me=D((()=>{const e=new URL(L||"/",W),{pathname:t,search:n}=Fe(e);return`${t}${n}`}),[L,W]),he=O((()=>{l({type:bn})}),[l]);R((()=>{if("function"==typeof s||!s?.current)return;const e=s.current;function t(){e===document.activeElement&&e.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,cancelable:!0}))}return window.addEventListener("blur",t),()=>{window.removeEventListener("blur",t)}}),[s]);const fe=D((()=>(J||"connecting"===C&&"refreshing"!==h.status)&&!se),[se,h.status,J,C]),ge=D((()=>[fe?"background":"active",J?"reloading":"idle",K,de&&!se?"timedOut":""]),[se,J,fe,de,K]);return e(Ve,{transition:G?{duration:0}:void 0,children:t(w,{delay:1e3,children:[e(o,{flex:"none",padding:2,shadow:1,style:{position:"relative"},children:t(a,{align:"center",style:{minHeight:0},children:[M&&e(u,{flex:"none",marginRight:1,padding:1,children:e(b,{animate:!0,content:e(d,{size:1,children:B("preview-frame.navigator.toggle-button.tooltip")}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:e(i,{"aria-label":B("preview-frame.navigator.toggle-button.aria-label"),fontSize:1,icon:Se,mode:"bleed",onClick:M,padding:2,selected:S})})}),e(b,{animate:!0,content:t(a,{align:"center",style:{whiteSpace:"nowrap"},children:[e(u,{padding:1,children:e(d,{size:1,children:B("preview-frame.overlay.toggle-button.tooltip",{context:V?"disable":"enable"})})}),e(u,{paddingY:1,children:e(te,{keys:["Alt"],style:{marginTop:-4,marginBottom:-4}})})]}),fallbackPlacements:["bottom-start"],padding:1,placement:"bottom",portal:!0,children:e(o,{as:"label",flex:"none",marginRight:1,padding:3,style:{lineHeight:0,borderRadius:999,userSelect:"none"},tone:V?"transparent":void 0,children:t(a,{align:"center",gap:3,children:[e("div",{style:{margin:-4},children:e(x,{checked:V,onChange:F,disabled:"loading"===h.status||"connected"!==C})}),e(u,{children:e(d,{muted:!V,size:1,weight:"medium",children:B("preview-frame.overlay.toggle-button.text")})})]})})}),e(u,{flex:1,marginX:1,children:e(Tn,{prefix:e(u,{padding:1,children:e(b,{animate:!0,content:e(d,{size:1,children:"loaded"===h.status?B("preview-frame.refresh-button.tooltip"):B("preview-frame.status",{context:h.status})}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:e(i,{"aria-label":B("preview-frame.refresh-button.aria-label"),fontSize:1,icon:Ie,mode:"bleed",loading:"reloading"===h.status||"refreshing"===h.status,onClick:ie,padding:2})})}),onChange:I,origin:re,suffix:e(u,{padding:1,children:e(P,{button:e(i,{fontSize:1,iconRight:_e,mode:"bleed",padding:2,space:2}),id:"location-menu",menu:e(k,{children:e(Un,{initialUrl:f,openPopup:z,previewLocationOrigin:re,previewLocationRoute:me})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),value:me})}),e(a,{align:"center",flex:"none",gap:1,padding:1,children:e(P,{button:e(i,{fontSize:1,iconRight:ze,mode:"bleed",padding:2,space:2,text:B(Mn["connected"===g?j:"previewDrafts"]),loading:"reconnecting"===g&&"loaded"!==h.status,disabled:"connected"!==g}),id:"perspective-menu",menu:t(k,{style:{maxWidth:240},children:[e(v,{fontSize:1,onClick:()=>U("previewDrafts"),padding:3,pressed:"previewDrafts"===j,tone:Nn,children:t(a,{align:"flex-start",gap:3,children:[e(u,{flex:"none",children:e(d,{size:1,children:T(Kn.previewDrafts)})}),t(c,{flex:1,space:2,children:[e(d,{size:1,weight:"medium",children:B(Mn.previewDrafts)}),e(d,{muted:!0,size:1,children:B("preview-frame.perspective.previewDrafts.text")})]}),e(u,{flex:"none",children:e(d,{muted:!0,size:1,style:{opacity:"previewDrafts"===j?1:0},children:e(De,{})})})]})}),e(v,{fontSize:1,onClick:()=>U("published"),padding:3,pressed:"published"===j,tone:Fn,children:t(a,{align:"flex-start",gap:3,children:[e(u,{flex:"none",children:e(d,{size:1,children:T(Kn.published)})}),t(c,{flex:1,space:2,children:[e(d,{size:1,weight:"medium",children:B(Mn.published)}),e(d,{muted:!0,size:1,children:B("preview-frame.perspective.published.text")})]}),e(u,{flex:"none",children:e(d,{muted:!0,size:1,style:{opacity:"published"===j?1:0},children:e(De,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),e(a,{align:"center",flex:"none",gap:1,children:e(b,{animate:!0,content:e(d,{size:1,children:B("preview-frame.viewport-button.tooltip",{context:"desktop"===K?"narrow":"full"})}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:e(i,{"aria-label":B("preview-frame.viewport-button.aria-label"),fontSize:1,icon:"desktop"===K?Ce:$e,mode:"bleed",onClick:H,padding:2})})})]})}),e(o,{flex:1,tone:"transparent",children:t(a,{align:"center",height:"fill",justify:"center",padding:"desktop"===K?0:2,sizing:"border",style:{position:"relative",cursor:ne?"wait":void 0},children:[e(Be,{children:Y||J||Q||!de||se?(J||"connecting"===C&&"refreshing"!==h.status)&&!se?e(Wn,{initial:"initial",animate:"animate",exit:"exit",variants:qn,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:t(a,{style:{...Bn[K]},justify:"center",align:"center",direction:"column",gap:4,children:[e(E,{muted:!0}),e(d,{muted:!0,size:1,children:B("preview-frame.status",{context:"loading"})})]})}):Y&&!se?e(Wn,{initial:"initial",animate:"animate",exit:"exit",variants:Gn,justify:"center",align:"center",style:{background:"var(--card-bg-color)",inset:"0",position:"absolute",borderTop:"1px solid transparent",boxShadow:"0 0 0 1px var(--card-border-color)"},children:e(Xt,{flex:1,message:B("preview-frame.connection.error.text"),onRetry:oe,onContinueAnyway:ae,children:q&&t(n,{children:["connected"!==C&&e(o,{padding:3,radius:2,tone:"critical",children:t(c,{space:3,children:[e(m,{muted:!0,size:0,children:B("preview-frame.overlay.connection-status.label")}),e(p,{size:1,children:B("channel.status",{context:C})})]})}),"connected"!==g&&e(o,{padding:3,radius:2,tone:"critical",children:t(c,{space:3,children:[e(m,{muted:!0,size:0,children:B("preview-frame.loader.connection-status.label")}),e(p,{size:1,children:B("channel.status",{context:g})})]})})]})})}):null:e(Wn,{initial:"initial",animate:"animate",exit:"exit",variants:qn,justify:"center",align:"center",style:{inset:"0",position:"absolute",backdropFilter:X?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",transition:"backdrop-filter 0.2s ease-in-out",WebkitBackdropFilter:X?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",WebkitTransition:"-webkit-backdrop-filter 0.2s ease-in-out",zIndex:1},children:t(a,{style:{...Bn[K]},justify:"center",align:"center",direction:"column",gap:4,children:[X&&e(i,{disabled:!0,fontSize:1,mode:"ghost",text:B("preview-frame.continue-button.text"),style:{opacity:0}}),e(o,{radius:2,tone:X?"caution":"inherit",padding:4,shadow:1,children:t(a,{justify:"center",align:"center",direction:"column",gap:4,children:[e(E,{muted:!0}),e(d,{muted:!0,size:1,children:B("preview-frame.status",X?{context:"timeout"}:{context:"connecting"})})]})}),X&&e(i,{fontSize:1,tone:"critical",onClick:ae,text:B("preview-frame.continue-button.text")})]})})}),e(Ln,{animate:ge,initial:["background"],onLoad:he,preventClick:fe,ref:s,src:f.toString(),variants:Hn})]})})]})})})),Bn={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},qn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Gn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Hn={desktop:{...Bn.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...Bn.mobile,boxShadow:"0 0 0 1px var(--card-border-color)"},background:{opacity:0,scale:1},idle:{scale:1},reloading:{scale:[1,1,1,.98]},active:{opacity:[0,0,1],scale:1},timedOut:{opacity:[0,0,1]}};const Jn=function(e){const{documentId:t,documentType:n,navigate:r,perspective:i,documentRevision:o}=e,a=ne(t,n);return function(e,t,n,r,i){const o=C(r),a=O(t,n);R((()=>{const t=o.current;if(o.current=e,e!==t)return a(e,t)}),[a,i,e])}(i,(e=>{let t;if("published"===e&&a.published){const{_updatedAt:e,_rev:n}=a.published;t=`${e}/${n}`}o!==t&&r({},{rev:t},!0)}),[a,r,o]),null};let Xn=!1;function Zn(e,t){return e instanceof Function?e(t):e}function Qn(e,t){const n=Array.isArray(e)?e:[e];for(e of n){let n,r=e;if("string"==typeof e)try{const t=new URL(e);n=t.origin,r=t.pathname}catch{}if(!n||t.origin===n)try{const e=He(r,{decode:decodeURIComponent})(t.pathname);if(e){const{params:t,path:r}=e;return{origin:n,params:t,path:r}}}catch{throw new Error(`"${e}" is not a valid route pattern`)}}}function Yn(e){const{navigate:t,navigationHistory:n,path:r,previewUrl:i,resolvers:o=[]}=e,{state:a}=se(),s=Y({apiVersion:fe}),[c,d]=$(void 0),l=C(void 0),u=D((()=>{const e=r||a._searchParams?.find((([e])=>"preview"===e))?.[1]||"",t="string"==typeof i?i:"object"==typeof i&&i?.origin||location.origin;return new URL(e,t)}),[r,i,a._searchParams]),p=O((()=>{d(void 0),l.current=void 0}),[]);return R((()=>{if(o.length&&u){let i;for(const e of o){const t=Qn(e.route,u);if(t){i={context:t,resolver:e};break}}if(i){const o=function(e,t){if(e.resolve){const n=e.resolve(t)?.filter;return n?`*[${n}][0]{_id, _type}`:void 0}return"type"in e?`*[_type == "${e.type}"][0]{_id, _type}`:`*[${Zn(e.filter,t)}][0]{_id, _type}`}(i.resolver,i.context),a=(e=i.resolver,r=i.context,e.resolve?e.resolve(r)?.params??r.params:"type"in e?{}:Zn(e.params,r)??r.params);if(o){const e=new AbortController,r={perspective:"previewDrafts",signal:e.signal};return s.fetch(o,a,r).then((e=>{(!e||l.current!==e._id)&&(d({document:e,path:u.pathname}),l.current=e?._id,n.at(-1)?.id===n.at(-2)?.id&&t?.({id:e?._id,type:e?._type}))})).catch((e=>{e instanceof Error&&"AbortError"===e.name||(d({document:void 0,path:u.pathname}),l.current=void 0)})),()=>{e.abort()}}}}var e,r;p()}),[s,p,t,n,o,u]),c}function er(e){if(void 0===e)return;const t=decodeURIComponent(e)?.split(".");return"drafts"===t[0]&&t.shift(),t.join(".")}function tr(e){if(void 0!==e)return r.toString(function(e){const t=[];for(const n of e.split(".")){const e=St.exec(n);if(e){t.push(e[1],Number(e[2]));continue}const r=It.exec(n);if(r){t.push(r[1],[Number(r[2]),Number(r[3])]);continue}const i=_t.exec(n);i?t.push(i[1],{_key:i[2]}):t.push(n)}return t}(decodeURIComponent(e)))}function nr(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function rr({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:r,frameStateRef:i}){const o=D((()=>{const{id:t,path:i,type:o}={id:er((a=n).id),path:tr(a.path),type:a.type};var a;return{id:t,type:o,path:i,preview:r.preview||`${e.pathname}${e.search}`,perspective:r.perspective,viewport:r.viewport,inspect:r.inspect,rev:r.rev,since:r.since,template:r.template,templateParams:r.templateParams,view:r.view,pathKey:r.pathKey,instruction:r.instruction,comment:r.comment}}),[n,r,e]),a=D((()=>nr({inspect:o.inspect,path:o.path,rev:o.rev,since:o.since,template:o.template,templateParams:o.templateParams,view:o.view,pathKey:o.pathKey,instruction:o.instruction,comment:o.comment})),[o.comment,o.inspect,o.instruction,o.path,o.pathKey,o.rev,o.since,o.template,o.templateParams,o.view]),s=D((()=>nr({perspective:o.perspective,preview:o.preview,viewport:o.viewport})),[o.perspective,o.preview,o.viewport]),c=C(n);R((()=>{c.current=n}),[n]);const[d,l]=$([n]);return{navigate:O(((e,n={},r)=>{e.id&&(e.id=K(e.id));const{_searchParams:o,...a}=c.current,s=(o||[]).reduce(((e,[t,n])=>(e[t]=n,e)),{}),d=nr({...a,...e}),u=nr({...s,...n});a.id!==d.id&&(delete u.template,delete u.templateParams),d._searchParams=Object.entries(u).reduce(((e,[t,n])=>[...e,[t,n]]),[]);const p=r??u.preview===i.current.url;l((e=>[...e,d])),t(d,{replace:p})}),[t,i]),navigationHistory:d,params:o,searchParams:s,structureParams:a}}function ir(e,t,n){const r=Y({apiVersion:fe}),i=Q(),o=i?.activeWorkspace?.basePath||"/",a=function(e,t,n,r){const[i,o]=$((()=>r||"")),a=C(0);R((()=>{if(i&&r)return window.clearTimeout(a.current),()=>{a.current=window.setTimeout((()=>{o("")}),100)}}),[i,r]);const s=ee();return D((()=>["@sanity/presentation",t,n,e,s?.id,or,i]),[t,s?.id,e,n,i])}(t,o,i?.activeWorkspace?.name||"default",n),s=function(e,t){const n=Y({apiVersion:fe}),r=ee(),[i,o]=$(""),a=e?Xe((async()=>await qe(n,"@sanity/presentation",typeof window>"u"?"":location.href,r?.id)),[...t,i]):null;return R((()=>{if(!a)return;const e=setTimeout((()=>{U((()=>o(a.expiresAt.toString())))}),a.expiresAt.getTime()-Date.now());return()=>clearTimeout(e)}),[a]),a?.secret||null}("object"==typeof e||"function"==typeof e,a);return Xe((async()=>{if("string"==typeof e){const t=new URL(e,location.origin);let r=t;try{if(n){const e=new URL(n,t);e.origin===t.origin&&(r=e)}else if(document.referrer){const e=new URL(document.referrer);e.origin===t.origin&&(r=e)}}catch{}return location.origin!==r.origin||!r.pathname.startsWith(`${o}/`)&&r.pathname!==o?r:t}const t=await("object"==typeof e?Je(e):e)({client:r,previewUrlSecret:s,previewSearchParam:n,referrer:typeof document>"u"?null:document.referrer,studioBasePath:o});return new URL(t,location.origin)}),[...a,s])}const or=Symbol();const ar=M((()=>import("./LoaderQueries.js"))),sr=M((()=>import("./PostMessageRefreshMutations.js"))),cr=de(a)`
overflow-x: auto;
`;function dr(e){var t,a,s,l;const{previewUrl:d,components:u}=null!=(t=e.tool.options)?t:{},p=e.tool.name||Pe,{unstable_navigator:m}=u||{},{navigate:h,state:f}=le(),v=V(Object.fromEntries(f._searchParams||[])),g=or(d||"/",p,v.preview||null),[y]=R((()=>{var t;const n=null==(t=e.tool.options)?void 0:t.devMode;return"function"==typeof n?n():"boolean"==typeof n?n:typeof window<"u"&&"localhost"===window.location.hostname})),w=$((()=>g.origin),[g.origin]),b=O(null),[x,P]=R(),[k,E]=R({}),S=O({title:void 0,url:void 0}),{navigate:I,navigationHistory:z,params:D,searchParams:C,structureParams:T}=ir({initialPreviewUrl:g,routerNavigate:h,routerState:f,routerSearchParams:v,frameStateRef:S}),U=$((()=>jt(I,50)),[I]),[A,W]=M(Sn,{},Rn),F=$((()=>D.perspective?"published":"previewDrafts"),[D.perspective]),K=$((()=>D.viewport?"mobile":"desktop"),[D.viewport]),[B,q]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,r]=R({}),[i,o]=R({}),a=O(""),s=j(((e,n,i=[])=>{const s=i.filter((e=>"_projectId"in e&&e._projectId?(Zn||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Zn=!0),!1):e));("published"===n?r:o)((n=>{const r={};for(const e of s)r[e._id]=e;if(a.current!==t.current.url)return a.current=t.current.url,{[e]:r};const i=n[e];return Je(i,r)?n:{...n,[e]:r}}))}),[t]);return[$((()=>{const t=Object.values("published"===e?n:i).reduce(((e,t)=>(Object.values(t).forEach((t=>{e[t._id]=t})),e)),{});return Object.values(t)}),[e,i,n]),s]}(F,S),G=oe(),H=ae(),J=er({navigate:I,navigationHistory:z,path:D.preview,previewUrl:null==(a=e.tool.options)?void 0:a.previewUrl,resolvers:null==(l=null==(s=e.tool.options)?void 0:s.resolve)?void 0:l.mainDocuments}),[X,Z]=R("connecting"),[Q,Y]=R("connecting"),[ee,te]=R("connecting"),[ne]=R((()=>new Set)),re=j((e=>{const t=window.open(e,"_blank");t&&ne.add(t)}),[ne]);L((()=>{if(ne.size&&x)for(const e of ne)e&&"closed"in e&&!e.closed&&x.addSource(e)}),[x,ne,ne.size]),L((()=>{var e;const t=null==(e=b.current)?void 0:e.contentWindow;if(!t)return;const n=function(e){const{destroy:t,send:n}=ut(e),r=new Set,i=new WeakMap,o=new Set;return{destroy:()=>{t();for(const e of o)e()},send:(e,...t)=>{n(e,...t);for(const n of r)n&&"closed"in n&&!n.closed&&i.has(n)&&i.get(n)(e,...t)},addSource(t){if(r.has(t))return;if(!("closed"in t))throw console.warn("Source is unsupported",{source:t}),new Error("Source is unsupported");if(t.closed)throw new Error("Source is closed");const{send:n,destroy:a}=ut({...e,target:t,connectTo:e.connectTo.map((e=>{const{onStatusUpdate:t,onEvent:n,...r}=e;return{...r,onEvent:n?(...e)=>{const[t]=e;if("preview-kit/documents"!==t&&"overlay/navigate"!==t&&"loader/documents"!==t)return n(...e)}:void 0}}))});o.add(a),i.set(t,n),r.add(t)}}}({id:"presentation",target:t,targetOrigin:w,connectTo:[{id:"overlays",heartbeat:!0,onStatusUpdate:Z,onEvent(e,t){if("visual-editing/focus"!==e&&"overlay/focus"!==e||!("id"in t))if("visual-editing/navigate"===e||"overlay/navigate"===e){const{title:e,url:n}=t;S.current.url!==n&&U({},{preview:n}),S.current={title:e,url:n}}else"visual-editing/meta"===e?S.current.title=t.title:"visual-editing/toggle"===e||"overlay/toggle"===e?W({type:En,enabled:t.enabled}):"visual-editing/documents"===e?q("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(Ee.current):"visual-editing/refreshing"===e&&"mutation"===t.source?W({type:Pn}):"visual-editing/refreshed"===e&&W({type:xn});else U({type:t.type,id:t.id,path:t.path})}},{id:"loaders",heartbeat:!0,onStatusUpdate:Y,onEvent(e,t){if("loader/documents"===e&&t.projectId===G&&t.dataset===H)q("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===G&&t.dataset===H){if("number"==typeof t.heartbeat&&t.heartbeat<we)throw new Error(`Loader query listen heartbeat interval must be at least ${we}ms`);E((e=>{var n;return{...e,[$t(t.query,t.params)]:{perspective:t.perspective,query:t.query,params:t.params,receivedAt:Date.now(),heartbeat:null!=(n=t.heartbeat)&&n}}}))}}},{id:"preview-kit",heartbeat:!0,onStatusUpdate:te,onEvent(e,t){"preview-kit/documents"===e&&t.projectId===G&&t.dataset===H&&q("preview-kit",t.perspective,t.documents)}}]});return P(n),()=>{n.destroy(),P(void 0)}}),[H,G,q,U,w]),L((()=>{const e=setInterval((()=>E((e=>{if(Object.keys(e).length<1)return e;const t=Date.now();if(!Object.values(e).some((e=>!1!==e.heartbeat&&t>e.receivedAt+e.heartbeat)))return e;const n={};for(const[r,i]of Object.entries(e))!1!==i.heartbeat&&t>i.receivedAt+i.heartbeat||(n[r]=i);return n}))),we);return()=>clearInterval(e)}),[]);const ie=j((e=>{U({path:o.toString(e)},{},!0)}),[U]),ce=j((e=>{const t=new URL(e,g.origin),n=t.pathname+t.search;t.origin===g.origin&&n!==D.preview&&U({},{preview:n})}),[g,D,U]),de=j((e=>{U({},e)}),[U]);L((()=>{null==x||x.send("overlays","presentation/perspective",{perspective:F})}),[x,F]),L((()=>{D.id&&D.path?null==x||x.send("overlays","presentation/focus",{id:D.id,path:D.path}):null==x||x.send("overlays","presentation/blur",void 0)}),[x,D.id,D.path]),L((()=>{S.current.url&&D.preview&&S.current.url!==D.preview&&(S.current.url=D.preview,"connected"!==X&&b.current?b.current.src=`${w}${D.preview}`:null==x||x.send("overlays","presentation/navigate",{url:D.preview,type:"replace"}))}),[x,X,w,D.preview]);const ue=j((()=>null==x?void 0:x.send("overlays","presentation/toggleOverlay",void 0)),[x]),[pe,me]=R(null);L((()=>{const e=e=>{Rt(e)&&ue()},t=e=>{var t;Rt(e)&&ue(),t=e,["mod","\\"].every((e=>Ot[e]?t[Ot[e]]:t.key===e.toUpperCase()))&&ue()};return window.addEventListener("keydown",t),window.addEventListener("keyup",e),()=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",e)}}),[ue]);const[he,fe]=R(null),[{navigatorEnabled:ve,toggleNavigator:ge},ye]=gn({unstable_navigator:m}),ke=O(D.id);L((()=>{D.rev&&ke.current&&D.id!==ke.current&&U({},{rev:void 0}),ke.current=D.id}));const Ee=O(),Se=j((e=>{if(W({type:Pn}),x)return Ee.current=window.setTimeout(e,300),void x.send("overlays","presentation/refresh",{source:"manual",livePreviewEnabled:"connected"===ee||"connected"===Q});e()}),[x,Q,ee]),Ie=se(),_e=j((({id:e,type:t,path:n})=>{if(S.current.url)return{title:S.current.title||S.current.url,name:"edit",params:{id:e,path:n,type:t,inspect:be,workspace:Ie.name,mode:xe,preview:D.preview}}}),[D.preview,Ie.name]),ze=j((e=>{U({},{viewport:"desktop"===e?void 0:"mobile"},!0)}),[U]),De=j((e=>{U({},{perspective:"previewDrafts"===e?void 0:e})}),[U]);return r(i,{children:[n(bn,{devMode:y,name:p,navigate:U,params:D,searchParams:C,structureParams:T,children:n(vn,{navigate:U,children:n(wn,{params:D,children:n(lr,{height:"fill",children:r(Xt,{children:[n(ye,{}),n(Ut,{id:"preview",minWidth:325,defaultSize:ve?50:75,order:3,children:n(c,{direction:"column",flex:1,height:"fill",ref:fe,children:n(_,{element:he,children:n(Bn,{dispatch:W,iframe:A.iframe,initialUrl:g,loadersConnection:Q,navigatorEnabled:ve,onPathChange:ce,onRefresh:Se,openPopup:re,overlaysConnection:X,previewUrl:D.preview,perspective:F,ref:b,setPerspective:De,setViewport:ze,targetOrigin:w,toggleNavigator:ge,toggleOverlay:ue,viewport:K,visualEditing:A.visualEditing})})})}),n(fn,{documentId:D.id,documentsOnPage:B,documentType:D.type,getCommentIntent:_e,mainDocumentState:J,onFocusPath:ie,onStructureParams:de,searchParams:C,setDisplayedDocument:me,structureParams:T})]})})})})}),x&&n(N,{children:n(sr,{channel:x,liveQueries:k,perspective:F,liveDocument:pe,documentsOnPage:B})}),x&&D.id&&D.type&&n(N,{children:n(cr,{channel:x,id:D.id,type:D.type,loadersConnection:Q,previewKitConnection:ee})}),D.id&&D.type&&n(Xn,{documentId:D.id,documentRevision:D.rev,documentType:D.type,navigate:U,perspective:F})]})}export{dr as default};//# sourceMappingURL=PresentationTool.js.map
`;function dr(i){const{previewUrl:o,components:s}=i.tool.options??{},c=i.tool.name||be,{unstable_navigator:d}=s||{},{navigate:l,state:u}=se(),p=F(Object.fromEntries(u._searchParams||[])),m=ir(o||"/",c,p.preview||null),[h]=$((()=>{const e=i.tool.options?.devMode;return"function"==typeof e?e():"boolean"==typeof e?e:typeof window<"u"&&"localhost"===window.location.hostname})),f=D((()=>m.origin),[m.origin]),v=C(null),[g,y]=$(),[w,b]=$({}),x=C({title:void 0,url:void 0}),{navigate:P,navigationHistory:k,params:E,searchParams:I,structureParams:_}=rr({initialPreviewUrl:m,routerNavigate:l,routerState:u,routerSearchParams:p,frameStateRef:x}),z=D((()=>Rt(P,50)),[P]),[j,L]=A(En,{},On),T=D((()=>E.perspective?"published":"previewDrafts"),[E.perspective]),U=D((()=>E.viewport?"mobile":"desktop"),[E.viewport]),[M,N]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,r]=$({}),[i,o]=$({}),a=C(""),s=O(((e,n,i=[])=>{const s=i.filter((e=>"_projectId"in e&&e._projectId?(Xn||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Xn=!0),!1):e));("published"===n?r:o)((n=>{const r={};for(const e of s)r[e._id]=e;if(a.current!==t.current.url)return a.current=t.current.url,{[e]:r};const i=n[e];return Ge(i,r)?n:{...n,[e]:r}}))}),[t]);return[D((()=>{const t=Object.values("published"===e?n:i).reduce(((e,t)=>(Object.values(t).forEach((t=>{e[t._id]=t})),e)),{});return Object.values(t)}),[e,i,n]),s]}(T,x),K=re(),V=ie(),B=Yn({navigate:P,navigationHistory:k,path:E.preview,previewUrl:i.tool.options?.previewUrl,resolvers:i.tool.options?.resolve?.mainDocuments}),[q,G]=$("connecting"),[H,J]=$("connecting"),[X,Z]=$("connecting"),[Q]=$((()=>new Set)),Y=O((e=>{const t=window.open(e,"_blank");t&&Q.add(t)}),[Q]);R((()=>{if(Q.size&&g)for(const e of Q)e&&"closed"in e&&!e.closed&&g.addSource(e)}),[g,Q,Q.size]),R((()=>{const e=v.current?.contentWindow;if(!e)return;const t=function(e){const{destroy:t,send:n}=lt(e),r=new Set,i=new WeakMap,o=new Set;return{destroy:()=>{t();for(const e of o)e()},send:(e,...t)=>{n(e,...t);for(const n of r)n&&"closed"in n&&!n.closed&&i.has(n)&&i.get(n)(e,...t)},addSource(t){if(r.has(t))return;if(!("closed"in t))throw console.warn("Source is unsupported",{source:t}),new Error("Source is unsupported");if(t.closed)throw new Error("Source is closed");const{send:n,destroy:a}=lt({...e,target:t,connectTo:e.connectTo.map((e=>{const{onStatusUpdate:t,onEvent:n,...r}=e;return{...r,onEvent:n?(...e)=>{const[t]=e;if("preview-kit/documents"!==t&&"overlay/navigate"!==t&&"loader/documents"!==t)return n(...e)}:void 0}}))});o.add(a),i.set(t,n),r.add(t)}}}({id:"presentation",target:e,targetOrigin:f,connectTo:[{id:"overlays",heartbeat:!0,onStatusUpdate:G,onEvent(e,t){if("visual-editing/focus"!==e&&"overlay/focus"!==e||!("id"in t))if("visual-editing/navigate"===e||"overlay/navigate"===e){const{title:e,url:n}=t;x.current.url!==n&&z({},{preview:n}),x.current={title:e,url:n}}else"visual-editing/meta"===e?x.current.title=t.title:"visual-editing/toggle"===e||"overlay/toggle"===e?L({type:kn,enabled:t.enabled}):"visual-editing/documents"===e?N("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(ve.current):"visual-editing/refreshing"===e&&"mutation"===t.source?L({type:xn}):"visual-editing/refreshed"===e&&L({type:bn});else z({type:t.type,id:t.id,path:t.path})}},{id:"loaders",heartbeat:!0,onStatusUpdate:J,onEvent(e,t){if("loader/documents"===e&&t.projectId===K&&t.dataset===V)N("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===K&&t.dataset===V){if("number"==typeof t.heartbeat&&t.heartbeat<ge)throw new Error(`Loader query listen heartbeat interval must be at least ${ge}ms`);b((e=>({...e,[Ct(t.query,t.params)]:{perspective:t.perspective,query:t.query,params:t.params,receivedAt:Date.now(),heartbeat:t.heartbeat??!1}})))}}},{id:"preview-kit",heartbeat:!0,onStatusUpdate:Z,onEvent(e,t){"preview-kit/documents"===e&&t.projectId===K&&t.dataset===V&&N("preview-kit",t.perspective,t.documents)}}]});return y(t),()=>{t.destroy(),y(void 0)}}),[V,K,N,z,f]),R((()=>{const e=setInterval((()=>b((e=>{if(Object.keys(e).length<1)return e;const t=Date.now();if(!Object.values(e).some((e=>!1!==e.heartbeat&&t>e.receivedAt+e.heartbeat)))return e;const n={};for(const[r,i]of Object.entries(e))!1!==i.heartbeat&&t>i.receivedAt+i.heartbeat||(n[r]=i);return n}))),ge);return()=>clearInterval(e)}),[]);const ee=O((e=>{z({path:r.toString(e)},{},!0)}),[z]),te=O((e=>{const t=new URL(e,m.origin),n=t.pathname+t.search;t.origin===m.origin&&n!==E.preview&&z({},{preview:n})}),[m,E,z]),ne=O((e=>{z({},e)}),[z]);R((()=>{g?.send("overlays","presentation/perspective",{perspective:T})}),[g,T]),R((()=>{E.id&&E.path?g?.send("overlays","presentation/focus",{id:E.id,path:E.path}):g?.send("overlays","presentation/blur",void 0)}),[g,E.id,E.path]),R((()=>{x.current.url&&E.preview&&x.current.url!==E.preview&&(x.current.url=E.preview,"connected"!==q&&v.current?v.current.src=`${f}${E.preview}`:g?.send("overlays","presentation/navigate",{url:E.preview,type:"replace"}))}),[g,q,f,E.preview]);const ae=O((()=>g?.send("overlays","presentation/toggleOverlay",void 0)),[g]),[ce,de]=$(null);R((()=>{const e=e=>{Ot(e)&&ae()},t=e=>{var t;Ot(e)&&ae(),t=e,["mod","\\"].every((e=>$t[e]?t[$t[e]]:t.key===e.toUpperCase()))&&ae()};return window.addEventListener("keydown",t),window.addEventListener("keyup",e),()=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",e)}}),[ae]);const[le,ue]=$(null),[{navigatorEnabled:pe,toggleNavigator:me},he]=vn({unstable_navigator:d}),fe=C(E.id);R((()=>{E.rev&&fe.current&&E.id!==fe.current&&z({},{rev:void 0}),fe.current=E.id}));const ve=C(),xe=O((e=>{if(L({type:xn}),g)return ve.current=window.setTimeout(e,300),void g.send("overlays","presentation/refresh",{source:"manual",livePreviewEnabled:"connected"===X||"connected"===H});e()}),[g,H,X]),Pe=oe(),ke=O((({id:e,type:t,path:n})=>{if(x.current.url)return{title:x.current.title||x.current.url,name:"edit",params:{id:e,path:n,type:t,inspect:ye,workspace:Pe.name,mode:we,preview:E.preview}}}),[E.preview,Pe.name]),Ee=O((e=>{z({},{viewport:"desktop"===e?void 0:"mobile"},!0)}),[z]),Se=O((e=>{z({},{perspective:"previewDrafts"===e?void 0:e})}),[z]);return t(n,{children:[e(wn,{devMode:h,name:c,navigate:z,params:E,searchParams:I,structureParams:_,children:e(fn,{navigate:z,children:e(yn,{params:E,children:e(cr,{height:"fill",children:t(Jt,{children:[e(he,{}),e(Tt,{id:"preview",minWidth:325,defaultSize:pe?50:75,order:3,children:e(a,{direction:"column",flex:1,height:"fill",ref:ue,children:e(S,{element:le,children:e(Vn,{dispatch:L,iframe:j.iframe,initialUrl:m,loadersConnection:H,navigatorEnabled:pe,onPathChange:te,onRefresh:xe,openPopup:Y,overlaysConnection:q,previewUrl:E.preview,perspective:T,ref:v,setPerspective:Se,setViewport:Ee,targetOrigin:f,toggleNavigator:me,toggleOverlay:ae,viewport:U,visualEditing:j.visualEditing})})})}),e(hn,{documentId:E.id,documentsOnPage:M,documentType:E.type,getCommentIntent:ke,mainDocumentState:B,onFocusPath:ee,onStructureParams:ne,searchParams:I,setDisplayedDocument:de,structureParams:_})]})})})})}),g&&e(W,{children:e(ar,{channel:g,liveQueries:w,perspective:T,liveDocument:ce,documentsOnPage:M})}),g&&E.id&&E.type&&e(W,{children:e(sr,{channel:g,id:E.id,type:E.type,loadersConnection:H,previewKitConnection:X})}),E.id&&E.type&&e(Jn,{documentId:E.id,documentRevision:E.rev,documentType:E.type,navigate:z,perspective:T})]})}export{dr as default};//# sourceMappingURL=PresentationTool.js.map
{
"name": "@sanity/presentation",
"version": "1.16.3",
"version": "1.16.4",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/presentation#readme",

@@ -93,5 +93,4 @@ "bugs": {

"dependencies": {
"@sanity/icons": "^3.2.0",
"@sanity/preview-url-secret": "^1.6.19",
"@sanity/ui": "^2.6.1",
"@sanity/icons": "^3.3.1",
"@sanity/ui": "^2.8.8",
"@sanity/uuid": "3.0.2",

@@ -107,21 +106,22 @@ "@types/lodash.isequal": "^4.5.8",

"rxjs": "^7.8.1",
"suspend-react": "0.1.3"
"suspend-react": "0.1.3",
"@sanity/preview-url-secret": "^1.6.20"
},
"devDependencies": {
"@repo/channels": "0.4.0",
"@repo/visual-editing-helpers": "0.6.19",
"@sanity/client": "^6.21.1",
"@sanity/client": "^6.21.2",
"@sanity/pkg-utils": "6.9.3",
"@types/lodash.get": "^4.4.9",
"happy-dom": "^14.12.0",
"happy-dom": "^14.12.3",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"sanity": "^3.47.1",
"styled-components": "6.1.11",
"sanity": "^3.53.0",
"styled-components": "6.1.12",
"typescript": "5.4.5",
"vitest": "^1.6.0",
"@repo/package.config": "0.0.0"
"vitest": "^2.0.5",
"@repo/channels": "0.4.0",
"@repo/package.config": "0.0.0",
"@repo/visual-editing-helpers": "0.6.20"
},
"peerDependencies": {
"@sanity/client": "^6.21.1"
"@sanity/client": "^6.21.2"
},

@@ -136,6 +136,6 @@ "engines": {

"build": "pkg build --strict --check --clean",
"dev": "pkg build --strict",
"lint": "eslint .",
"test": "vitest --typecheck",
"watch": "pkg watch --strict"
"test": "vitest --typecheck"
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc