Socket
Socket
Sign inDemoInstall

@sanity/presentation

Package Overview
Dependencies
13
Maintainers
54
Versions
127
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.15.14 to 1.15.15

src/editor/usePreviewState.ts

22

dist/_chunks-es/PresentationTool.js

@@ -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 f,Label as h,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 z}from"@sanity/ui";import{createContext as _,useContext as D,useLayoutEffect as C,useMemo as O,useRef as L,useState as $,useCallback as U,useEffect as R,forwardRef as j,memo as T,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,useSchema as q,Preview as G,Translate as J,CommentsIntentProvider as X,useActiveWorkspace as H,useClient as Z,useCurrentUser as Q,Hotkeys as Y,useDocumentStore as ee,useProjectId as te,useDataset as ne,useWorkspace as re}from"sanity";import{StateLink as ie,useRouter as oe,decodeJsonParams as ae}from"sanity/router";import{styled as se}from"styled-components";import{p as ce,u as le,P as de,a as ue,b as pe,A as me,M as fe,c as he,C as ve,E as ge,D as ye}from"./index.js";import{WarningOutlineIcon as we,ResetIcon as be,LaunchIcon as xe,CopyIcon as Pe,PanelLeftIcon as ke,RefreshIcon as Ee,ShareIcon as Se,ChevronDownIcon as Ie,CheckmarkIcon as ze,DesktopIcon as _e,MobileDeviceIcon as De,EditIcon as Ce,PublishIcon as Oe}from"@sanity/icons";import{PaneRouterContext as Le,PaneLayout as $e,StructureToolProvider as Ue,DocumentListPane as Re,DocumentPane as je}from"sanity/structure";import{D as Te}from"./DisplayedDocumentBroadcaster.js";import{hasSecretSearchParams as Ae,setSecretSearchParams as We,withoutSecretSearchParams as Me}from"@sanity/preview-url-secret/without-secret-search-params";import{motion as Ne,MotionConfig as Fe,AnimatePresence as Ke}from"framer-motion";import{createPreviewSecret as Ve}from"@sanity/preview-url-secret/create-secret";import Be from"fast-deep-equal";import{match as qe}from"path-to-regexp";import{definePreviewUrl as Ge}from"@sanity/preview-url-secret/define-preview-url";import{suspend as Je}from"suspend-react";let Xe;const He=new Uint8Array(16);function Ze(){if(!Xe&&(Xe=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Xe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Xe(He)}const Qe=[];for(let e=0;e<256;++e)Qe.push((e+256).toString(16).slice(1));var Ye={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function et(e,t,n){if(Ye.randomUUID&&!t&&!e)return Ye.randomUUID();const r=(e=e||{}).random||(e.rng||Ze)();return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return Qe[e[t+0]]+Qe[e[t+1]]+Qe[e[t+2]]+Qe[e[t+3]]+"-"+Qe[e[t+4]]+Qe[e[t+5]]+"-"+Qe[e[t+6]]+Qe[e[t+7]]+"-"+Qe[e[t+8]]+Qe[e[t+9]]+"-"+Qe[e[t+10]]+Qe[e[t+11]]+Qe[e[t+12]]+Qe[e[t+13]]+Qe[e[t+14]]+Qe[e[t+15]]}(r)}const tt=1e3,nt=1e3,rt=500,it=["handshake/syn","handshake/syn-ack","handshake/ack"],ot=e=>it.some((t=>t===e)),at=({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 st(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(ot(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(!ot(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(at(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=et(),e.interval=window.setInterval((()=>{l(e,"handshake/syn",{id:e.id})}),rt)}(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:nt;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:et(),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=et();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}').`))}),tt),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 ct,lt,dt,ut;function pt(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 mt(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:pt(u),f={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},h="schema"===e.kind,v=null!=(d=null!=(l=null!=(c=null!=(s=e.message)?s:function(e,t){var n;return null==(n=null==ut?void 0:ut.get(e))?void 0:n.get(t)}(e.reference,f.lang))?c:h?(g=f.lang,null==dt?void 0:dt.get(g)):null)?l:r.message)?d:function(e){return null==lt?void 0:lt.get(e)}(f.lang);var g;v&&(f.message="function"==typeof v?v(f):v),h&&(n.typed=!1),n.issues?n.issues.push(f):n.issues=[f]}function ft(e){return"__proto__"!==e&&"prototype"!==e&&"constructor"!==e}var ht=class extends Error{constructor(e){super(e[0].message),t(this,"issues"),this.name="ValiError",this.issues=e}};function vt(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function gt(e,t){return{...e,fallback:t,_run(t,n){return e._run(t,n),t.issues?{typed:!0,value:vt(this,t,n)}:t}}}function yt(e){return{kind:"schema",type:"boolean",reference:yt,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:mt(this,"type",e,t),e}}}function wt(e,t){return{kind:"schema",type:"object",reference:wt,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 mt(this,"type",e,t);return e}}}function bt(e,...t){const n={kind:"schema",type:"optional",reference:bt,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 xt(e,t){return{kind:"schema",type:"picklist",reference:xt,expects:e.map(pt).join(" | ")||"never",async:!1,options:e,message:t,_run(e,t){return this.options.includes(e.value)?e.typed=!0:mt(this,"type",e,t),e}}}function Pt(e){return{kind:"schema",type:"string",reference:Pt,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:mt(this,"type",e,t),e}}}function kt(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==ct?void 0:ct.lang,message:null==e?void 0:e.message,abortEarly:null!=(n=null==e?void 0:e.abortEarly)?n:null==ct?void 0:ct.abortEarly,abortPipeEarly:null!=(r=null==e?void 0:e.abortPipeEarly)?r:null==ct?void 0:ct.abortPipeEarly,skipPipe:null==e?void 0:e.skipPipe}}(n));if(r.issues)throw new ht(r.issues);return r.value}const Et=/^([A-Za-z]+):([0-9]+)$/,St=/^([A-Za-z]+):([0-9]+),([0-9]+)$/,It=/^([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"===(null==i?void 0:i.kind)||"transformation"===(null==i?void 0:i.kind))){t.typed=!1;break}}return t}}}(Pt(),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&&mt(this,"length",e,t,{received:`${e.value.length}`}),e}}}(1)),_t=bt(zt);function Dt(e,t){return`${e}-${"string"==typeof t?t:JSON.stringify(t)}`}wt({baseUrl:zt,dataset:_t,id:zt,path:zt,projectId:_t,tool:_t,type:_t,workspace:_t,isDraft:bt(Pt())}),wt({origin:zt,href:zt,data:bt(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(ft(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 mt(this,"type",e,t);return e}}}(Pt(),function e(){return{kind:"schema",type:"unknown",reference:e,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}()))});const Ct={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 Lt(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,r)}),t)}}const $t=_(null);$t.displayName="PanelsContext";const Ut=se.div`
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 h,Code as m,Label as f,ErrorBoundary as v,TextInput as g,MenuItem as y,useToast as b,usePrefersReducedMotion as w,TooltipDelayGroupProvider as P,Tooltip as x,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 L,useRef as O,useState as $,useCallback as j,useEffect as R,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 J,SanityDefaultPreview as X,getPreviewValueWithFallback as H,PreviewCard as Z,Translate as Q,CommentsIntentProvider as Y,useActiveWorkspace as ee,useClient as te,useCurrentUser as ne,Hotkeys as re,useDocumentStore 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 he,P as me,a as fe,b as ve,A as ge,M as ye,c as be,C as we,E as Pe,D as xe}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 Le,DesktopIcon as Oe,MobileDeviceIcon as $e,EditIcon as je,PublishIcon as Re}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 Je}from"@sanity/preview-url-secret/create-secret";import Xe from"fast-deep-equal";import{match as He}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,ht,mt,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,h=null!=(a=null==i?void 0:i.received)?a:vt(u),m={kind:e.kind,type:e.type,input:u,expected:p,received:h,message:`Invalid ${t}: ${p?`Expected ${p} but r`:"R"}eceived ${h}`,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,m.lang))?c:f?(g=m.lang,null==mt?void 0:mt.get(g)):null)?l:r.message)?d:function(e){return null==ht?void 0:ht.get(e)}(m.lang);var g;v&&(m.message="function"==typeof v?v(m):v),f&&(n.typed=!1),n.issues?n.issues.push(m):n.issues=[m]}function yt(e){return"__proto__"!==e&&"prototype"!==e&&"constructor"!==e}var bt=class extends Error{constructor(e){super(e[0].message),t(this,"issues"),this.name="ValiError",this.issues=e}};function wt(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function Pt(e){return{kind:"schema",type:"boolean",reference:Pt,expects:"boolean",async:!1,message:e,_run(e,t){return"boolean"==typeof e.value?e.typed=!0:gt(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){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 bt(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 Lt(e,t){return`${e}-${"string"==typeof t?t:JSON.stringify(t)}`}xt({baseUrl:Dt,dataset:Ct,id:Dt,path:Dt,projectId:Ct,tool:Ct,type:Ct,workspace:Ct,isDraft:kt(Et())}),xt({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 $t(e){return"Alt"===e.key}function jt(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,r)}),t)}}const Rt=z(null);Rt.displayName="PanelsContext";const Tt=ue.div`
overflow: hidden;
flex-basis: 0;
flex-shrink: 1;
`,Rt=function({children:e,defaultSize:t=null,id:r,minWidth:i,maxWidth:o,order:a=0}){const s=D($t);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(Ut,{style:u,children:e})},jt="presentation/panels",Tt=()=>JSON.parse(localStorage.getItem(jt)||"{}"),At=e=>e.map((e=>[e.id,e.order].join(":"))).join(",");function Wt(){return O((()=>{const e=(e,t)=>{const n=Tt(),r=At(e);(e=>{localStorage.setItem(jt,JSON.stringify(e))})({...n,[r]:t})};return{get:e=>{const t=Tt(),n=At(e);return Array.isArray(t[n])&&t[n].some((e=>null===e))?void 0:t[n]},set:e,setDebounced:Lt(e,100)}}),[])}function Mt(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 Nt(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 Ft(e,t,n=0,r=null){return e.clientX-(r||t.getBoundingClientRect()).left-n}function Kt(e){return"panel"===e.type}function Vt(e){return"resizer"===e.type}function Bt(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 qt(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=Mt(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 Gt=se.div`
`,Ut=function({children:e,defaultSize:t=null,id:r,minWidth:i,maxWidth:o,order:a=0}){const s=D(Rt);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 L((()=>{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 Jt(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 Xt=ue.div`
display: flex;

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

width: 100%;
`,Jt=function({children:e}){const t=L(null),[r,i]=$(new Map),o=O((()=>Bt(r).filter(Kt)),[r]),[a,s]=$([]),[c,l]=$(null),d=L({elements:r,panels:o,widths:a}),u=U((e=>({flexGrow:Nt(o,e,a),pointerEvents:null===c?void 0:"none"})),[c,o,a]),p=U(((e,t)=>{i((n=>{if(n.has(e))return n;const r=new Map(n);return r.set(e,t),r}))}),[]),m=U((e=>{i((t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}))}),[]),f=L({containerWidth:window.innerWidth,dragOffset:0,panelAfter:null,panelBefore:null,resizerIndex:-1,resizerRect:null,startX:0,widths:[]}),h=U(((e,t)=>{const n=Bt(r),i=n.findIndex((t=>t.id===e)),o=r.get(e);if(!o||!Vt(o))return;const a=o.el.current;a&&(f.current={resizerIndex:i,panelBefore:n.reduce(((e,t,n)=>Kt(t)&&n<i?t:e),null),panelAfter:n.reduce(((e,t,n)=>null===e&&Kt(t)&&n>i?t:e),null),containerWidth:window.innerWidth,startX:t.pageX,dragOffset:Ft(t,a),resizerRect:a.getBoundingClientRect(),widths:d.current.widths},l(e))}),[r]),v=U((()=>{l(null)}),[]),g=U(((e,n)=>{n.preventDefault(),n.stopPropagation();const{containerWidth:i,dragOffset:o,panelBefore:a,panelAfter:c,resizerRect:l}=f.current;if(null==a||null==c)return;const u=r.get(e);if(!u||!Vt(u))return;const p=u.el.current;if(!p)return;const m=Ft(n,p,o,l);if(0===m)return;const{widths:h}=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=Mt(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=Mt(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,f.current);h.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=Wt();C((()=>{const{widths:e}=d.current;if(e.length===o.length)return;const t=y.get(o);if(t){const e=qt(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]),C((()=>{const e=new ResizeObserver((()=>{const{panels:e,widths:t}=d.current,n=qt(e,t,window.innerWidth);t.some(((e,t)=>e!==n[t]))&&s(n)}));return e.observe(t.current),()=>{e.disconnect()}}),[]);const w=O((()=>({activeResizer:c,drag:g,getPanelStyle:u,registerElement:p,startDragging:h,stopDragging:v,unregisterElement:m})),[c,g,u,p,h,v,m]);return n($t.Provider,{value:w,children:n(Gt,{ref:t,children:e})})};function Xt(e){const{children:t,message:i,onRetry:o,onContinueAnyway:f,...h}=e,{t:v}=K(ce),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:f,text:v("error-card.continue-button.text")});return n(s,{height:"fill",...h,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&&f?r(p,{space:2,children:[g,y]}):o?n(m,{children:g}):f?n(m,{children:y}):null]})})})})}function Ht(e){const t=["comment","inspect","instruction","pathKey","rev","since","template","prefersLatestPublished","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 Zt=j((function(e,t){const{params:r,structureParams:i}=le();return n(ie,{...e,ref:t,state:{type:void 0,_searchParams:Object.entries({...i,perspective:r.perspective,preview:r.preview})},title:void 0})})),Qt=j((function(e,t){const{documentId:r,documentType:i,parentRefPath:o,template:a,previewUrl:s,...c}=e,{params:l}=le();return n(ie,{...c,ref:t,state:{id:r,type:i,_searchParams:Object.entries({preview:s,prefersLatestPublished:"published"===l.perspective?"true":void 0})},title:void 0})}));function Yt(e){const{children:t,onStructureParams:r,params:o,previewUrl:a,refs:s}=e,{state:c,resolvePathFromState:l}=oe(),d=V(Object.fromEntries(c._searchParams||[])),u=U((e=>`${l(c)}${Ht({...d,...e})}`),[l,d,c]),p=O((()=>({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)),{params:o}=le();return i?n(ie,{...r,state:{id:t,type:i._type,_searchParams:Object.entries({preview:a,prefersLatestPublished:"published"===o.perspective?"true":void 0})}}):n("div",{...r})},BackLink:Zt,ReferenceChildLink:e=>n(Qt,{...e,previewUrl: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,o,a,s]);return n(Le.Provider,{value:p,children:t})}const en=se($e)`
`,Ht=function({children:e}){const t=O(null),[r,i]=$(new Map),o=L((()=>Gt(r).filter(Bt)),[r]),[a,s]=$([]),[c,l]=$(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}))}),[]),h=j((e=>{i((t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}))}),[]),m=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&&(m.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}=m.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 h=Vt(n,p,o,l);if(0===h)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,h=a.findIndex((e=>e.id===p.id));for(;;){const n=a[h],r=l[h],i=Ft(n,r-(Math.abs(e)-Math.abs(u)),t);if(r!==i&&(u+=r-i,d[h]=i,u.toPrecision(10).localeCompare(Math.abs(e).toPrecision(10),void 0,{numeric:!0})>=0))break;if(e<0){if(--h<0)break}else if(++h>=a.length)break}return 0===u?l:(p=e<0?r:n,h=a.findIndex((e=>e.id===p.id)),d[h]=l[h]+u,d)}(h/t.current.getBoundingClientRect().width*100,i,a,c,d.current,m.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=Jt(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]),C((()=>{const e=new ResizeObserver((()=>{const{panels:e,widths:t}=d.current,n=Jt(e,t,window.innerWidth);t.some(((e,t)=>e!==n[t]))&&s(n)}));return e.observe(t.current),()=>{e.disconnect()}}),[]);const b=L((()=>({activeResizer:c,drag:g,getPanelStyle:u,registerElement:p,startDragging:f,stopDragging:v,unregisterElement:h})),[c,g,u,p,f,v,h]);return n(Rt.Provider,{value:b,children:n(Xt,{ref:t,children:e})})};function Zt(e){const{children:t,message:i,onRetry:o,onContinueAnyway:m,...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:m,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&&m?r(p,{space:2,children:[g,y]}):o?n(h,{children:g}):m?n(h,{children:y}):null]})})})})}function Qt(e){const t=["comment","inspect","instruction","pathKey","rev","since","template","prefersLatestPublished","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,prefersLatestPublished:"published"===s.perspective?"true":void 0})},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=L((()=>({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,prefersLatestPublished:"published"===(null==a?void 0:a.perspective)?"true":void 0})}}):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)`
height: 100%;
`,tn=se(c)`
`,rn=ue(c)`
& > div {

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

}
`,nn=se(f)`
`,on=ue(m)`
white-space: pre-wrap;
`;function rn(e){const{mainDocumentState:t,onStructureParams:i,previewUrl:o,refs:a}=e,{t:c}=K(ce),{devMode:l}=le(),u=O((()=>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=O((()=>({id:"$root",options:{filter:"_id in $ids",params:{ids:u}},schemaTypeName:"",title:c("document-list-pane.document-list.title"),type:"documentList"})),[u,c]),[m,f]=$(null),g=U((()=>f(null)),[]),[y]=$((()=>({})));return R((()=>f(null)),[a]),m?n(Xt,{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(h,{muted:!0,size:0,children:c("presentation-error.label")}),n(nn,{size:1,children:m.error.message})]})})}):n(v,{onCatch:f,children:n(en,{children:n(Ue,{children:n(Yt,{onStructureParams:i,params:y,previewUrl:o,refs:a,children:n(tn,{direction:"column",flex:1,children:n(Re,{index:0,itemId:"$root",pane:p,paneKey:"$root"})})})})})})}const on=se(f)`
`;function an(e){const{mainDocumentState:t,onStructureParams:i,searchParams:o,refs:a}=e,{t:c}=K(pe),{devMode:l}=he(),u=L((()=>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=L((()=>({id:"$root",options:{filter:"_id in $ids",params:{ids:u}},schemaTypeName:"",title:c("document-list-pane.document-list.title"),type:"documentList"})),[u,c]),[h,m]=$(null),g=j((()=>m(null)),[]),[y]=$((()=>({})));return R((()=>m(null)),[a]),h?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:h.error.message})]})})}):n(v,{onCatch:m,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(m)`
white-space: pre-wrap;
`;function an(e){const{documentId:t,documentType:i,onFocusPath:o,onStructureParams:a,params:c,previewUrl:l}=e,{template:u,templateParams:p}=c,{t:m}=K(ce),{devMode:f}=le(),g=O((()=>({id:t,options:{id:t,type:i,template:u,templateParameters:ae(p)},title:"",type:"document"})),[t,i,u,p]),[y,w]=$(null),b=U((()=>w(null)),[]);return R((()=>{w(null)}),[t,i,c]),y?n(Xt,{flex:1,message:m("document-pane.error.text"),onRetry:b,children:f&&n(s,{overflow:"auto",padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(h,{muted:!0,size:0,children:m("presentation-error.label")}),n(on,{size:1,children:y.error.message})]})})}):n(v,{onCatch:w,children:n($e,{style:{height:"100%"},children:n(Yt,{onStructureParams:a,params:c,previewUrl:l,children:n(je,{paneKey:"document",index:1,itemId:"document",pane:g,onFocusPath:o})})})})}function sn(e){const{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,previewUrl:a,structureParams:s}=e;return n(Ue,{children:n(an,{documentId:t,documentType:r,onFocusPath:i,onStructureParams:o,params:s,previewUrl:a})})}function cn(e){const{documentId:t,documentType:i,mainDocumentState:o,onFocusPath:a,onStructureParams:l,previewUrl:d,refs:p,structureParams:f}=e,{t:h}=K(ce),v=q(),g=U((e=>n(ie,{...e,state:{id:o.document._id,type:o.document._type,_searchParams:Object.entries({preview:d})}})),[o,d]);return t&&i?n(sn,{documentId:t,documentType:i,onFocusPath:a,onStructureParams:l,previewUrl:d,structureParams:f}):r(c,{direction:"column",flex:1,height:"fill",children:[o&&n(s,{padding:3,tone:o.document?"inherit":"caution",children:o.document?n(s,{as:g,"data-as":"a",padding:0,radius:2,children:n(G,{schemaType:v.get(o.document._type),status:n(s,{padding:1,radius:2,shadow:1,children:n(u,{muted:!0,size:0,weight:"medium",children:h("main-document.label")})}),value:o.document})}):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(we,{})})}),n(m,{flex:1,children:n(u,{size:1,children:n(J,{t:h,i18nKey:"main-document.missing.text",components:{Code:"code"},values:{path:o.path}})})})]})})}),n(rn,{mainDocumentState:o,onStructureParams:l,previewUrl:d,refs:p})]})}const ln=se.div`
`;function cn(e){const{documentId:t,documentType:i,onFocusPath:o,onStructureParams:a,searchParams:c,structureParams:l}=e,{template:u,templateParams:p}=l,{t:h}=K(pe),{devMode:m}=he(),g=L((()=>({id:t,options:{id:t,type:i,template:u,templateParameters:de(p)},title:"",type:"document"})),[t,i,u,p]),[y,b]=$(null),w=j((()=>b(null)),[]);return R((()=>{b(null)}),[t,i,l]),y?n(Zt,{flex:1,message:h("document-pane.error.text"),onRetry:w,children:m&&n(s,{overflow:"auto",padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(f,{muted:!0,size:0,children:h("presentation-error.label")}),n(sn,{size:1,children:y.error.message})]})})}):n(v,{onCatch:b,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:m,structureParams:f}=e,{t:v}=K(pe),g=J(),y=j((e=>n(ce,{...e,state:{id:a.document._id,type:a.document._type,_searchParams:Object.entries({...m,prefersLatestPublished:"published"===(null==m?void 0:m.perspective)?"true":void 0})}})),[a,m]),b=L((()=>{var e;return g.get((null==(e=null==a?void 0:a.document)?void 0:e._type)||"shoe")}),[a,g]),w=function(e,t){const n=q(),[r,i]=$({});return R((()=>{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)||"",b),P=L((()=>a?n(X,{...H({value:a.document,published:w.published,draft:w.draft}),schemaType:b,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,b,v,w]);return i&&o?n(ln,{documentId:i,documentType:o,onFocusPath:l,onStructureParams:d,searchParams:m,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:P}):n(s,{padding:2,radius:2,tone:"inherit",children:r(c,{gap:3,children:[n(h,{flex:"none",children:n(u,{size:1,children:n(ke,{})})}),n(h,{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:m,refs:p})]})}const un=ue.div`
position: relative;
`,dn=se.div`
`,pn=ue.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 "}
`,un=function({id:e,order:t,disabled:i=!1}){const o=L(null),a=D($t);if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const s=function(e){return L(e||et()).current}(e),{activeResizer:c,drag:l,startDragging:d,stopDragging:u,registerElement:p,unregisterElement:m}=a,f=c===s;if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const h=U((e=>{d(s,e.nativeEvent)}),[s,d]),v=U((e=>{l(s,e)}),[s,l]),g=U((()=>{o.current.blur(),u()}),[u]);return R((()=>{if(f&&!i)return window.addEventListener("mousemove",v),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",g)}}),[i,f,v,g]),C((()=>(p(s,{id:s,order:t,type:"resizer",el:o}),()=>{m(s)})),[s,t,p,m]),n(ln,{onMouseDown:h,ref:o,children:r(dn,{$disabled:i,children:[n("span",{}),n("span",{})]})})},pn=e=>{const{documentId:t,setDisplayedDocument:o,getCommentIntent:a}=e;return r(i,{children:[n(un,{order:4}),n(Rt,{id:"content",minWidth:325,order:5,children:n(Te,{documentId:t,setDisplayedDocument:o,children:n(X,{getIntent:a,children:e.children})})})]})},mn=e=>{const{documentsOnPage:t,getCommentIntent:r,mainDocumentState:i,onFocusPath:o,onStructureParams:a,params:s,setDisplayedDocument:c,structureParams:l}=e;return n(pn,{documentId:s.id,getCommentIntent:r,setDisplayedDocument:c,children:n(cn,{documentId:s.id,documentType:s.type,mainDocumentState:i,onFocusPath:o,onStructureParams:a,previewUrl:s.preview,refs:t,structureParams:l})})},fn=function(e){const{children:t,navigate:r}=e,i=U(((e,t=void 0)=>{r(t||{},e?{preview:e}:{})}),[r]);return n(de.Provider,{value:i,children:t})};function hn(e){const{unstable_navigator:t}=e,r=!(null==t||!t.component),[o,a]=function(e,t){const[n,r]=$((()=>{var n;return JSON.parse(null!=(n=localStorage.getItem(e))?n:JSON.stringify(t))}));return R((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,r]}("presentation/navigator",r),s=!!r&&o,c=O((()=>{if(r)return()=>a((e=>!e))}),[r,a]),l=U((function(){return n(i,{children:s&&n(vn,{...t})})}),[s,t]);return[{navigatorEnabled:s,toggleNavigator:c},l]}const vn=T((function(e){const{minWidth:t,maxWidth:o,component:a}=e,s=null!=t&&null!=o&&t===o;return r(i,{children:[n(Rt,{id:"navigator",minWidth:t,maxWidth:o,order:1,children:n(a,{})}),n(un,{order:2,disabled:s})]})})),gn=function(e){const{children:t,params:r}=e,i=O((()=>r),[r]);return n(ue.Provider,{value:i,children:t})},yn=function(e){const{children:t,devMode:r,name:i,navigate:o,params:a,structureParams:s}=e,c=O((()=>({devMode:r,name:i,navigate:o,params:a,structureParams:s})),[r,i,o,a,s]);return n(pe.Provider,{value:c,children:t})},wn="ACTION_IFRAME_LOADED",bn="ACTION_IFRAME_REFRESH",xn="ACTION_IFRAME_RELOAD",Pn="ACTION_PERSPECTIVE",kn="ACTION_VIEWPORT",En="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",Sn=(e,t)=>{switch(t.type){case wn:return"loaded"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"loaded"}};case bn:return"refreshing"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"refreshing"}};case xn:return"reloading"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"reloading"}};case Pn:return{...e,perspective:kt(Dn,t.perspective)};case kn:return{...e,viewport:kt(Cn,t.viewport)};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}},zn=gt(yt(),!1),_n=xt(["loading","loaded","refreshing","reloading"]),Dn=gt(xt(["published","previewDrafts"]),"previewDrafts"),Cn=gt(xt(["desktop","mobile"]),"desktop"),On=wt({mainDocument:zn,iframe:wt({status:_n}),perspective:Dn,viewport:Cn,visualEditing:wt({overlaysEnabled:yt()})}),Ln={mainDocument:!1,iframe:{status:"loading"},perspective:"previewDrafts",viewport:"desktop",visualEditing:{overlaysEnabled:!1}};function $n(e){return kt(On,{...Ln,...e})}const Un=Ne(se.iframe`
`,hn=function({id:e,order:t,disabled:i=!1}){const o=O(null),a=D(Rt);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:h}=a,m=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 R((()=>{if(m&&!i)return window.addEventListener("mousemove",v),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",g)}}),[i,m,v,g]),C((()=>(p(s,{id:s,order:t,type:"resizer",el:o}),()=>{h(s)})),[s,t,p,h]),n(un,{onMouseDown:f,ref:o,children:r(pn,{$disabled:i,children:[n("span",{}),n("span",{})]})})},mn=e=>{const{documentId:t,setDisplayedDocument:o,getCommentIntent:a}=e;return r(i,{children:[n(hn,{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(mn,{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(me.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]=$((()=>{var n;return JSON.parse(null!=(n=localStorage.getItem(e))?n:JSON.stringify(t))}));return R((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,r]}("presentation/navigator",r),s=!!r&&o,c=L((()=>{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(hn,{order:2,disabled:s})]})})),bn=function(e){const{children:t,params:r}=e,i=L((()=>r),[r]);return n(fe.Provider,{value:i,children:t})},wn=function(e){const{children:t,devMode:r,name:i,navigate:o,params:a,searchParams:s,structureParams:c}=e,l=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})},Pn="ACTION_IFRAME_LOADED",xn="ACTION_IFRAME_REFRESH",kn="ACTION_IFRAME_RELOAD",En="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",Sn=(e,t)=>{switch(t.type){case Pn: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 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=(Ln=Pt(),On=!1,{...Ln,fallback:On,_run(e,t){return Ln._run(e,t),e.issues?{typed:!0,value:wt(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=xt({mainDocument:_n,iframe:xt({status:zn}),visualEditing:xt({overlaysEnabled:Pt()})}),Cn={mainDocument:!1,iframe:{status:"loading"},visualEditing:{overlaysEnabled:!1}};var Ln,On;function $n(e){return St(Dn,{...Cn,...e})}const jn=Be(ue.iframe`
border: 0;

@@ -53,4 +53,4 @@ max-height: 100%;

display: block;
`),Rn=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(ce),{basePath:p="/"}=(null==(t=H())?void 0:t.activeWorkspace)||{},m=L(null),[f,h]=$(void 0),[v,y]=$(void 0),w=U((e=>{h(e.currentTarget.value)}),[]),b=U((e=>{var t;if("Enter"===e.key){if(void 0===f)return;const e=f.startsWith("/")||""===f?`${a}${f}`:f;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),h(void 0),o(n.slice(a.length)),null==(t=m.current)||t.blur()}"Escape"===e.key&&(y(void 0),h(void 0))}),[p,o,a,f,u]),x=U((()=>{y(void 0),h(void 0)}),[]);R((()=>{y(void 0),h(void 0)}),[a,d]);const P=O((()=>({icon:be})),[]);return n(i,{children:n(g,{clearButton:v?P:void 0,customValidity:v,fontSize:r,onBlur:x,onClear:()=>{y(void 0),h(a+d)},onChange:w,onKeyDownCapture:b,padding:s,prefix:c,style:{zIndex:1},radius:2,ref:m,space:s,suffix:l,value:void 0===f?`${a}${d}`:f})})};function jn(e){const{initialUrl:t,openPopup:o,previewLocationOrigin:a,previewLocationRoute:s}=e,{t:c}=K(ce),l=U((e=>{e.preventDefault(),o(e.currentTarget.href)}),[o]);return r(i,{children:[n(Tn,{initialUrl:t,previewLocationOrigin:a,previewLocationRoute:s}),n(y,{icon:xe,text:c("share-url.menu-item.open.text"),as:"a",href:`${a}${s}`,onClick:l,rel:"opener",target:"_blank"})]})}function Tn(e){const{initialUrl:t,previewLocationOrigin:r,previewLocationRoute:i}=e,{t:o}=K(ce),{push:a}=w(),s=Z({apiVersion:me}),c=Q(),[l,d]=$(!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(Ae(t)){const n=async()=>{e=a({closable:!0,title:o("share-url.clipboard.status",{context:"copying"})});const n=await Ve(s,"@sanity/presentation",typeof window>"u"?"":location.href,null==c?void 0:c.id);return We(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:Pe})}const An=Ne(c),Wn={previewDrafts:"preview-frame.perspective.previewDrafts.title",published:"preview-frame.perspective.published.title"},Mn="caution",Nn="positive",Fn={previewDrafts:Ce,published:Oe},Kn=j((function(e,t){const{dispatch:o,iframe:l,initialUrl:p,loadersConnection:v,navigatorEnabled:g,onPathChange:w,onRefresh:z,openPopup:_,overlaysConnection:D,params:C,perspective:L,targetOrigin:j,toggleNavigator:T,toggleOverlay:W,viewport:M,visualEditing:{overlaysEnabled:N}}=e,{t:F}=K(ce),{devMode:V}=le(),B=b(),q=U((()=>o({type:kn,viewport:"desktop"})),[o]),G=U((()=>o({type:kn,viewport:"mobile"})),[o]),J="loading"===l.status||"reloading"===l.status,[X,H]=$(!1),Z="refreshing"===l.status,[Q,ee]=$(!1),te=J||Z||"connecting"===D,ne=O((()=>j===location.origin?"":j),[j]),re=U((()=>{z((()=>{"function"==typeof t||null==t||!t.current||(o({type:xn}),t.current.src=`${j}${C.preview||"/"}`)}))}),[o,z,C.preview,j,t]),ie=U((()=>{"function"==typeof t||null==t||!t.current||(t.current.src=p.toString(),o({type:xn}))}),[o,t,p]),oe=U((()=>{se(!0)}),[]),[ae,se]=$(!1),[de,ue]=$(!1);R((()=>{if(!(J||Z||"connecting"!==D&&"reconnecting"!==D)){const e=setTimeout((()=>{ue(!0)}),1e3);return()=>clearTimeout(e)}}),[D,J,Z]),R((()=>{if(!J&&!Z&&de){if("connected"===D&&(ee(!1),ue(!1),H(!1),se(!1)),"connecting"===D){const e=setTimeout((()=>{H(!0),console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly")}),fe);return()=>clearTimeout(e)}if("reconnecting"===D){const e=setTimeout((()=>{H(!0),ee(!0)}),fe);return()=>clearTimeout(e)}"disconnected"===D&&ee(!0)}}),[J,D,Z,de]);const pe=O((()=>{const e=new URL(C.preview||"/",j),{pathname:t,search:n}=Me(e);return`${t}${n}`}),[C.preview,j]),me=U((()=>{o({type:wn})}),[o]);return R((()=>{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]),n(Fe,{transition:B?{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:[T&&n(m,{flex:"none",marginRight:1,padding:1,children:n(P,{animate:!0,content:n(u,{size:1,children:F("preview-frame.navigator.toggle-button.tooltip")}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":F("preview-frame.navigator.toggle-button.aria-label"),fontSize:1,icon:ke,mode:"bleed",onClick:T,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:F("preview-frame.overlay.toggle-button.tooltip",{context:N?"disable":"enable"})})}),n(m,{paddingY:1,children:n(Y,{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:N?"transparent":void 0,children:r(c,{align:"center",gap:3,children:[n("div",{style:{margin:-4},children:n(k,{checked:N,onChange:W,disabled:"loading"===l.status||"connected"!==D})}),n(m,{children:n(u,{muted:!N,size:1,weight:"medium",children:F("preview-frame.overlay.toggle-button.text")})})]})})}),n(m,{flex:1,marginX:1,children:n(Rn,{prefix:n(m,{padding:1,children:n(P,{animate:!0,content:n(u,{size:1,children:"loaded"===l.status?F("preview-frame.refresh-button.tooltip"):F("preview-frame.status",{context:l.status})}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":F("preview-frame.refresh-button.aria-label"),fontSize:1,icon:Ee,mode:"bleed",loading:"reloading"===l.status||"refreshing"===l.status,onClick:re,padding:2})})}),onChange:w,origin:ne,suffix:n(m,{padding:1,children:n(E,{button:n(a,{fontSize:1,iconRight:Se,mode:"bleed",padding:2,space:2}),id:"location-menu",menu:n(S,{children:n(jn,{initialUrl:p,openPopup:_,previewLocationOrigin:ne,previewLocationRoute:pe})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),value:pe})}),n(c,{align:"center",flex:"none",gap:1,padding:1,children:n(E,{button:n(a,{fontSize:1,iconRight:Ie,mode:"bleed",padding:2,space:2,text:F(Wn["connected"===v?L:"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:()=>o({type:Pn,perspective:"previewDrafts"}),padding:3,pressed:"previewDrafts"===L,tone:Mn,children:r(c,{align:"flex-start",gap:3,children:[n(m,{flex:"none",children:n(u,{size:1,children:A(Fn.previewDrafts)})}),r(d,{flex:1,space:2,children:[n(u,{size:1,weight:"medium",children:F(Wn.previewDrafts)}),n(u,{muted:!0,size:1,children:F("preview-frame.perspective.previewDrafts.text")})]}),n(m,{flex:"none",children:n(u,{muted:!0,size:1,style:{opacity:"previewDrafts"===L?1:0},children:n(ze,{})})})]})}),n(y,{fontSize:1,onClick:()=>o({type:Pn,perspective:"published"}),padding:3,pressed:"published"===L,tone:Nn,children:r(c,{align:"flex-start",gap:3,children:[n(m,{flex:"none",children:n(u,{size:1,children:A(Fn.published)})}),r(d,{flex:1,space:2,children:[n(u,{size:1,weight:"medium",children:F(Wn.published)}),n(u,{muted:!0,size:1,children:F("preview-frame.perspective.published.text")})]}),n(m,{flex:"none",children:n(u,{muted:!0,size:1,style:{opacity:"published"===L?1:0},children:n(ze,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),r(c,{align:"center",flex:"none",gap:1,padding:1,children:[n(P,{animate:!0,content:n(u,{size:1,children:F("preview-frame.viewport-full-button.tooltip")}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":F("preview-frame.viewport-full-button.aria-label"),fontSize:1,icon:_e,mode:"bleed",onClick:q,padding:2,selected:"desktop"===M})}),n(P,{animate:!0,content:n(u,{size:1,children:F("preview-frame.viewport-narrow-button.tooltip")}),padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":F("preview-frame.viewport-narrow-button.aria-label"),fontSize:1,icon:De,mode:"bleed",onClick:G,padding:2,selected:"mobile"===M})})]})]})}),n(s,{flex:1,tone:"transparent",children:r(c,{align:"center",height:"fill",justify:"center",padding:"desktop"===M?0:2,sizing:"border",style:{position:"relative",cursor:te?"wait":void 0},children:[n(Ke,{children:Q||J||Z||!de||ae?(J||"connecting"===D&&"refreshing"!==l.status)&&!ae?n(An,{initial:"initial",animate:"animate",exit:"exit",variants:Bn,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:r(c,{style:{...Vn[M]},justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(u,{muted:!0,size:1,children:F("preview-frame.status",{context:"loading"})})]})}):Q&&!ae?n(An,{initial:"initial",animate:"animate",exit:"exit",variants:qn,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(Xt,{flex:1,message:F("preview-frame.connection.error.text"),onRetry:ie,onContinueAnyway:oe,children:V&&r(i,{children:["connected"!==D&&n(s,{padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(h,{muted:!0,size:0,children:F("preview-frame.overlay.connection-status.label")}),n(f,{size:1,children:F("channel.status",{context:D})})]})}),"connected"!==v&&n(s,{padding:3,radius:2,tone:"critical",children:r(d,{space:3,children:[n(h,{muted:!0,size:0,children:F("preview-frame.loader.connection-status.label")}),n(f,{size:1,children:F("channel.status",{context:v})})]})})]})})}):null:n(An,{initial:"initial",animate:"animate",exit:"exit",variants:Bn,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:{...Vn[M]},justify:"center",align:"center",direction:"column",gap:4,children:[X&&n(a,{disabled:!0,fontSize:1,mode:"ghost",text:F("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:F("preview-frame.status",X?{context:"timeout"}:{context:"connecting"})})]})}),X&&n(a,{fontSize:1,tone:"critical",onClick:oe,text:F("preview-frame.continue-button.text")})]})})}),n(Un,{ref:t,style:{pointerEvents:(J||"connecting"===D&&"refreshing"!==l.status)&&!ae?"none":"auto",boxShadow:"0 0 0 1px var(--card-border-color)",borderTop:"1px solid transparent"},src:p.toString(),initial:["background"],variants:Gn,animate:[(J||"connecting"===D&&"refreshing"!==l.status)&&!ae?"background":"active",J?"reloading":"idle",M,de&&!ae?"timedOut":""],onLoad:me})]})})]})})})),Vn={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},Bn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},qn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Gn={desktop:{...Vn.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...Vn.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]}};let Jn=!1;function Xn(e,t){return e instanceof Function?e(t):e}function Hn(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=qe(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 Zn(e){const{navigate:t,resolvers:n=[],path:r,previewUrl:i}=e,{state:o}=oe(),a=ee(),s=Z({apiVersion:me}),[c,l]=$(void 0),d=L(void 0),u=O((()=>{var e,t;const n=r||(null==(t=null==(e=o._searchParams)?void 0:e.find((([e])=>"preview"===e)))?void 0:t[1])||"",a="string"==typeof i?i:"object"==typeof i&&(null==i?void 0:i.origin)||location.origin;return new URL(n,a)}),[r,i,o._searchParams]),p=U((()=>{l(void 0),d.current=void 0}),[]);return R((()=>{if(n.length&&u){let c;for(const e of n){const t=Hn(e.route,u);if(t){c={context:t,resolver:e};break}}if(c){const n=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}`:`*[${Xn(e.filter,t)}][0]{_id, _type}`}(c.resolver,c.context),p=(e=c.resolver,r=c.context,e.resolve?null!=(o=null==(i=e.resolve(r))?void 0:i.params)?o:r.params:"type"in e?{}:null!=(a=Xn(e.params,r))?a:r.params);if(n){const e=new AbortController,r={perspective:"previewDrafts",signal:e.signal};return s.fetch(n,p,r).then((e=>{(!e||d.current!==e._id)&&(l({document:e,path:u.pathname}),null==t||t({id:null==e?void 0:e._id,type:null==e?void 0:e._type}),d.current=null==e?void 0:e._id)})).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,o,a;p()}),[s,p,a,t,n,u]),c}function Qn(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 Yn(e){if(void 0!==e)return o.toString(function(e){const t=[];for(const n of e.split(".")){const e=Et.exec(n);if(e){t.push(e[1],Number(e[2]));continue}const r=St.exec(n);if(r){t.push(r[1],[Number(r[2]),Number(r[3])]);continue}const i=It.exec(n);i?t.push(i[1],{_key:i[2]}):t.push(n)}return t}(decodeURIComponent(e)))}function er(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function tr({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:r,frameStateRef:i}){const o=O((()=>{const{id:t,path:i,type:o}={id:Qn((a=n).id),path:Yn(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,prefersLatestPublished:r.prefersLatestPublished,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=O((()=>er({inspect:o.inspect,path:o.path,rev:o.rev,prefersLatestPublished:o.prefersLatestPublished,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.prefersLatestPublished,o.rev,o.since,o.template,o.templateParams,o.view]),s=L(n);R((()=>{s.current=n}),[n]);return{structureParams:a,navigate:U(((e,n={},r)=>{e.id&&(e.id=B(e.id));const{_searchParams:o,...a}=s.current,c=(o||[]).reduce(((e,[t,n])=>(e[t]=n,e)),{}),l=er({...a,...e}),d=er({...c,...n});a.id!==l.id&&(delete d.template,delete d.templateParams),l._searchParams=Object.entries(d).reduce(((e,[t,n])=>[...e,[t,n]]),[]);const u=null!=r?r:d.preview===i.current.url;t(l,{replace:u})}),[t,i]),params:o}}function nr(e,t,n){var r,i;const o=Z({apiVersion:me}),a=H(),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||"")),a=L(0);R((()=>{if(i&&r)return window.clearTimeout(a.current),()=>{a.current=window.setTimeout((()=>{o("")}),100)}}),[i,r]);const s=Q();return O((()=>["@sanity/presentation",t,n,e,null==s?void 0:s.id,rr,i]),[t,null==s?void 0:s.id,e,n,i])}(t,s,c,n),d=function(e,t){const n=Z({apiVersion:me}),r=Q(),[i,o]=$(""),a=e?Je((async()=>await Ve(n,"@sanity/presentation",typeof window>"u"?"":location.href,null==r?void 0:r.id)),[...t,i]):null;return R((()=>{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 Je((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?Ge(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 rr=Symbol();const ir=F((()=>import("./LoaderQueries.js"))),or=F((()=>import("./PostMessageRefreshMutations.js"))),ar=se(c)`
`),Rn=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)||{},h=O(null),[m,f]=$(void 0),[v,y]=$(void 0),b=j((e=>{f(e.currentTarget.value)}),[]),w=j((e=>{var t;if("Enter"===e.key){if(void 0===m)return;const e=m.startsWith("/")||""===m?`${a}${m}`:m;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=h.current)||t.blur()}"Escape"===e.key&&(y(void 0),f(void 0))}),[p,o,a,m,u]),P=j((()=>{y(void 0),f(void 0)}),[]);R((()=>{y(void 0),f(void 0)}),[a,d]);const x=L((()=>({icon:Ee})),[]);return n(i,{children:n(g,{clearButton:v?x:void 0,customValidity:v,fontSize:r,onBlur:P,onClear:()=>{y(void 0),f(a+d)},onChange:b,onKeyDownCapture:w,padding:s,prefix:c,style:{zIndex:1},radius:2,ref:h,space:s,suffix:l,value:void 0===m?`${a}${d}`:m})})};function Tn(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(Un,{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 Un(e){const{initialUrl:t,previewLocationOrigin:r,previewLocationRoute:i}=e,{t:o}=K(pe),{push:a}=b(),s=te({apiVersion:ge}),c=ne(),[l,d]=$(!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 Je(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 An=Be(c),Wn={previewDrafts:"preview-frame.perspective.previewDrafts.title",published:"preview-frame.perspective.published.title"},Mn="caution",Nn="positive",Fn={previewDrafts:je,published:Re},Kn=T((function(e,t){const{dispatch:o,iframe:l,initialUrl:p,loadersConnection:v,navigatorEnabled:g,onPathChange:b,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}=he(),G=w(),J="loading"===l.status||"reloading"===l.status,[X,H]=$(!1),Z="refreshing"===l.status,[Q,Y]=$(!1),ee=J||Z||"connecting"===D,te=L((()=>W===location.origin?"":W),[W]),ne=j((()=>{_((()=>{"function"==typeof t||null==t||!t.current||(o({type:kn}),t.current.src=`${W}${O||"/"}`)}))}),[o,_,O,W,t]),ie=j((()=>{"function"==typeof t||null==t||!t.current||(t.current.src=p.toString(),o({type:kn}))}),[o,t,p]),oe=j((()=>{se(!0)}),[]),[ae,se]=$(!1),[ce,le]=$(!1);R((()=>{if(!(J||Z||"connecting"!==D&&"reconnecting"!==D)){const e=setTimeout((()=>{le(!0)}),1e3);return()=>clearTimeout(e)}}),[D,J,Z]),R((()=>{if(!J&&!Z&&ce){if("connected"===D&&(Y(!1),le(!1),H(!1),se(!1)),"connecting"===D){const e=setTimeout((()=>{H(!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((()=>{H(!0),Y(!0)}),ye);return()=>clearTimeout(e)}"disconnected"===D&&Y(!0)}}),[J,D,Z,ce]);const de=L((()=>{const e=new URL(O||"/",W),{pathname:t,search:n}=Ve(e);return`${t}${n}`}),[O,W]),ue=j((()=>{o({type:Pn})}),[o]);return R((()=>{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]),n(qe,{transition:G?{duration:0}:void 0,children:r(P,{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(h,{flex:"none",marginRight:1,padding:1,children:n(x,{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(x,{animate:!0,content:r(c,{align:"center",style:{whiteSpace:"nowrap"},children:[n(h,{padding:1,children:n(u,{size:1,children:B("preview-frame.overlay.toggle-button.tooltip",{context:V?"disable":"enable"})})}),n(h,{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(h,{children:n(u,{muted:!V,size:1,weight:"medium",children:B("preview-frame.overlay.toggle-button.text")})})]})})}),n(h,{flex:1,marginX:1,children:n(Rn,{prefix:n(h,{padding:1,children:n(x,{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:ne,padding:2})})}),onChange:b,origin:te,suffix:n(h,{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(Tn,{initialUrl:p,openPopup:z,previewLocationOrigin:te,previewLocationRoute:de})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),value:de})}),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(Wn["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:Mn,children:r(c,{align:"flex-start",gap:3,children:[n(h,{flex:"none",children:n(u,{size:1,children:A(Fn.previewDrafts)})}),r(d,{flex:1,space:2,children:[n(u,{size:1,weight:"medium",children:B(Wn.previewDrafts)}),n(u,{muted:!0,size:1,children:B("preview-frame.perspective.previewDrafts.text")})]}),n(h,{flex:"none",children:n(u,{muted:!0,size:1,style:{opacity:"previewDrafts"===C?1:0},children:n(Le,{})})})]})}),n(y,{fontSize:1,onClick:()=>T("published"),padding:3,pressed:"published"===C,tone:Nn,children:r(c,{align:"flex-start",gap:3,children:[n(h,{flex:"none",children:n(u,{size:1,children:A(Fn.published)})}),r(d,{flex:1,space:2,children:[n(u,{size:1,weight:"medium",children:B(Wn.published)}),n(u,{muted:!0,size:1,children:B("preview-frame.perspective.published.text")})]}),n(h,{flex:"none",children:n(u,{muted:!0,size:1,style:{opacity:"published"===C?1:0},children:n(Le,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),r(c,{align:"center",flex:"none",gap:1,padding:1,children:[n(x,{animate:!0,content:n(u,{size:1,children:B("preview-frame.viewport-full-button.tooltip")}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":B("preview-frame.viewport-full-button.aria-label"),fontSize:1,icon:Oe,mode:"bleed",onClick:()=>U("desktop"),padding:2,selected:"desktop"===F})}),n(x,{animate:!0,content:n(u,{size:1,children:B("preview-frame.viewport-narrow-button.tooltip")}),padding:2,placement:"bottom",portal:!0,children:n(a,{"aria-label":B("preview-frame.viewport-narrow-button.aria-label"),fontSize:1,icon:$e,mode:"bleed",onClick:()=>U("mobile"),padding:2,selected:"mobile"===F})})]})]})}),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:ee?"wait":void 0},children:[n(Ge,{children:Q||J||Z||!ce||ae?(J||"connecting"===D&&"refreshing"!==l.status)&&!ae?n(An,{initial:"initial",animate:"animate",exit:"exit",variants:Bn,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:r(c,{style:{...Vn[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"})})]})}):Q&&!ae?n(An,{initial:"initial",animate:"animate",exit:"exit",variants:qn,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:ie,onContinueAnyway:oe,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(m,{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(m,{size:1,children:B("channel.status",{context:v})})]})})]})})}):null:n(An,{initial:"initial",animate:"animate",exit:"exit",variants:Bn,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:{...Vn[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:oe,text:B("preview-frame.continue-button.text")})]})})}),n(jn,{ref:t,style:{pointerEvents:(J||"connecting"===D&&"refreshing"!==l.status)&&!ae?"none":"auto",boxShadow:"0 0 0 1px var(--card-border-color)",borderTop:"1px solid transparent"},src:p.toString(),initial:["background"],variants:Gn,animate:[(J||"connecting"===D&&"refreshing"!==l.status)&&!ae?"background":"active",J?"reloading":"idle",F,ce&&!ae?"timedOut":""],onLoad:ue})]})})]})})})),Vn={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},Bn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},qn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Gn={desktop:{...Vn.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...Vn.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]}};let Jn=!1;function Xn(e,t){return e instanceof Function?e(t):e}function Hn(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 Zn(e){const{navigate:t,resolvers:n=[],path:r,previewUrl:i}=e,{state:o}=le(),a=ie(),s=te({apiVersion:ge}),[c,l]=$(void 0),d=O(void 0),u=L((()=>{var e,t;const n=r||(null==(t=null==(e=o._searchParams)?void 0:e.find((([e])=>"preview"===e)))?void 0:t[1])||"",a="string"==typeof i?i:"object"==typeof i&&(null==i?void 0:i.origin)||location.origin;return new URL(n,a)}),[r,i,o._searchParams]),p=j((()=>{l(void 0),d.current=void 0}),[]);return R((()=>{if(n.length&&u){let c;for(const e of n){const t=Hn(e.route,u);if(t){c={context:t,resolver:e};break}}if(c){const n=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}`:`*[${Xn(e.filter,t)}][0]{_id, _type}`}(c.resolver,c.context),p=(e=c.resolver,r=c.context,e.resolve?null!=(o=null==(i=e.resolve(r))?void 0:i.params)?o:r.params:"type"in e?{}:null!=(a=Xn(e.params,r))?a:r.params);if(n){const e=new AbortController,r={perspective:"previewDrafts",signal:e.signal};return s.fetch(n,p,r).then((e=>{(!e||d.current!==e._id)&&(l({document:e,path:u.pathname}),null==t||t({id:null==e?void 0:e._id,type:null==e?void 0:e._type}),d.current=null==e?void 0:e._id)})).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,o,a;p()}),[s,p,a,t,n,u]),c}function Qn(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 Yn(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 er(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function tr({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:r,frameStateRef:i}){const o=L((()=>{const{id:t,path:i,type:o}={id:Qn((a=n).id),path:Yn(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,prefersLatestPublished:r.prefersLatestPublished,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=L((()=>er({inspect:o.inspect,path:o.path,rev:o.rev,prefersLatestPublished:o.prefersLatestPublished,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.prefersLatestPublished,o.rev,o.since,o.template,o.templateParams,o.view]),s=L((()=>er({perspective:o.perspective,preview:o.preview,viewport:o.viewport})),[o.perspective,o.preview,o.viewport]),c=O(n);return R((()=>{c.current=n}),[n]),{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=er({...a,...e}),d=er({...s,...n});a.id!==l.id&&(delete d.template,delete d.templateParams),l._searchParams=Object.entries(d).reduce(((e,[t,n])=>[...e,[t,n]]),[]);const u=null!=r?r:d.preview===i.current.url;t(l,{replace:u})}),[t,i]),params:o,searchParams:s,structureParams:a}}function nr(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||"")),a=O(0);R((()=>{if(i&&r)return window.clearTimeout(a.current),()=>{a.current=window.setTimeout((()=>{o("")}),100)}}),[i,r]);const s=ne();return L((()=>["@sanity/presentation",t,n,e,null==s?void 0:s.id,rr,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]=$(""),a=e?Qe((async()=>await Je(n,"@sanity/presentation",typeof window>"u"?"":location.href,null==r?void 0:r.id)),[...t,i]):null;return R((()=>{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 rr=Symbol();const ir=F((()=>import("./LoaderQueries.js"))),or=F((()=>import("./PostMessageRefreshMutations.js"))),ar=ue(c)`
overflow-x: auto;
`;function sr(e){var t,a,s,l;const{previewUrl:d,components:u}=null!=(t=e.tool.options)?t:{},p=e.tool.name||ye,{unstable_navigator:m}=u||{},{navigate:f,state:h}=oe(),v=V(Object.fromEntries(h._searchParams||[])),g=nr(d||"/",p,v.preview||null),[y]=$((()=>{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=O((()=>g.origin),[g.origin]),b=L(null),[x,P]=$(),[k,E]=$({}),S=L({title:void 0,url:void 0}),{navigate:I,params:_,structureParams:D}=tr({initialPreviewUrl:g,routerNavigate:f,routerState:h,routerSearchParams:v,frameStateRef:S}),C=O((()=>Lt(I,50)),[I]),[j,T]=M(Sn,{perspective:_.perspective,viewport:_.viewport},$n),[A,W]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,r]=$({}),[i,o]=$({}),a=L(""),s=U(((e,n,i=[])=>{const s=i.filter((e=>"_projectId"in e&&e._projectId?(Jn||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Jn=!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 Be(i,r)?n:{...n,[e]:r}}))}),[t]);return[O((()=>{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]}(j.perspective,S),F=te(),K=ne(),B=Zn({resolvers:null==(s=null==(a=e.tool.options)?void 0:a.resolve)?void 0:s.mainDocuments,previewUrl:null==(l=e.tool.options)?void 0:l.previewUrl,path:_.preview,navigate:I});R((()=>{(j.perspective!==_.perspective||j.viewport!==_.viewport)&&C({},{perspective:"previewDrafts"===j.perspective?void 0:j.perspective,viewport:"desktop"===j.viewport?void 0:j.viewport})}),[_.perspective,j.perspective,C,j.viewport,_.viewport,_.rev,_.prefersLatestPublished]);const[q,G]=$("connecting"),[J,X]=$("connecting"),[H,Z]=$("connecting"),[Q]=$((()=>new Set)),Y=U((e=>{const t=window.open(e,"_blank");t&&Q.add(t)}),[Q]);R((()=>{if(Q.size&&x)for(const e of Q)e&&"closed"in e&&!e.closed&&x.addSource(e)}),[x,Q,Q.size]);const ee=L(j.perspective);R((()=>{ee.current=j.perspective}),[j.perspective]),R((()=>{var e;const t=null==(e=b.current)?void 0:e.contentWindow;if(!t)return;const n=function(e){const{destroy:t,send:n}=st(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}=st({...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: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;S.current.url!==n&&C({},{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?T({type:En,enabled:t.enabled}):"visual-editing/documents"===e?W("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(xe.current):"visual-editing/refreshing"===e&&"mutation"===t.source?T({type:bn}):"visual-editing/refreshed"===e&&T({type:wn});else C({type:t.type,id:t.id,path:t.path},{prefersLatestPublished:"isDraft"in t||"previewDrafts"===ee.current?void 0:"true"})}},{id:"loaders",heartbeat:!0,onStatusUpdate:X,onEvent(e,t){if("loader/documents"===e&&t.projectId===F&&t.dataset===K)W("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===F&&t.dataset===K){if("number"==typeof t.heartbeat&&t.heartbeat<he)throw new Error(`Loader query listen heartbeat interval must be at least ${he}ms`);E((e=>{var n;return{...e,[Dt(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:Z,onEvent(e,t){"preview-kit/documents"===e&&t.projectId===F&&t.dataset===K&&W("preview-kit",t.perspective,t.documents)}}]});return P(n),()=>{n.destroy(),P(void 0)}}),[K,F,W,C,w]),R((()=>{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}))),he);return()=>clearInterval(e)}),[]);const ie=U((e=>{C({path:o.toString(e)},{},!0)}),[C]),ae=U((e=>{const t=new URL(e,g.origin),n=t.pathname+t.search;t.origin===g.origin&&n!==_.preview&&C({},{preview:n})}),[g,_,C]),se=U((e=>{C({},e)}),[C]);R((()=>{null==x||x.send("overlays","presentation/perspective",{perspective:j.perspective})}),[x,j.perspective]),R((()=>{_.id&&_.path?null==x||x.send("overlays","presentation/focus",{id:_.id,path:_.path}):null==x||x.send("overlays","presentation/blur",void 0)}),[x,_.id,_.path]),R((()=>{"published"===j.perspective&&_.id&&!_.rev&&!_.prefersLatestPublished&&C({},{prefersLatestPublished:"true"})}),[C,_.id,_.prefersLatestPublished,_.rev,j.perspective]),R((()=>{S.current.url&&_.preview&&S.current.url!==_.preview&&(S.current.url=_.preview,"connected"!==q&&b.current?b.current.src=`${w}${_.preview}`:null==x||x.send("overlays","presentation/navigate",{url:_.preview,type:"replace"}))}),[x,q,w,_.preview]);const ce=U((()=>null==x?void 0:x.send("overlays","presentation/toggleOverlay",void 0)),[x]),[le,de]=$(null);R((()=>{const e=e=>{Ot(e)&&ce()},t=e=>{var t;Ot(e)&&ce(),t=e,["mod","\\"].every((e=>Ct[e]?t[Ct[e]]:t.key===e.toUpperCase()))&&ce()};return window.addEventListener("keydown",t),window.addEventListener("keyup",e),()=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",e)}}),[ce]);const[ue,pe]=$(null),[{navigatorEnabled:me,toggleNavigator:fe},we]=hn({unstable_navigator:m}),be=L(_.id);R((()=>{_.rev&&be.current&&_.id!==be.current&&C({},{rev:void 0}),be.current=_.id}));const xe=L(),Pe=U((e=>{if(T({type:bn}),x)return xe.current=window.setTimeout(e,300),void x.send("overlays","presentation/refresh",{source:"manual",livePreviewEnabled:"connected"===H||"connected"===J});e()}),[x,J,H]),ke=re(),Ee=U((({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:ve,workspace:ke.name,mode:ge,preview:_.preview}}}),[_.preview,ke.name]);return r(i,{children:[n(yn,{devMode:y,name:p,navigate:C,params:_,structureParams:D,children:n(fn,{navigate:C,children:n(gn,{params:_,children:n(ar,{height:"fill",children:r(Jt,{children:[n(we,{}),n(Rt,{id:"preview",minWidth:325,defaultSize:me?50:75,order:3,children:n(c,{direction:"column",flex:1,height:"fill",ref:pe,children:n(z,{element:ue,children:n(Kn,{dispatch:T,iframe:j.iframe,initialUrl:g,loadersConnection:J,navigatorEnabled:me,onPathChange:ae,onRefresh:Pe,openPopup:Y,overlaysConnection:q,params:_,perspective:j.perspective,ref:b,targetOrigin:w,toggleNavigator:fe,toggleOverlay:ce,viewport:j.viewport,visualEditing:j.visualEditing})})})}),n(mn,{mainDocumentState:B,params:_,documentsOnPage:A,getCommentIntent:Ee,onFocusPath:ie,onStructureParams:se,setDisplayedDocument:de,structureParams:D})]})})})})}),x&&n(N,{children:n(ir,{channel:x,liveQueries:k,perspective:j.perspective,liveDocument:le,documentsOnPage:A})}),x&&_.id&&_.type&&n(N,{children:n(or,{channel:x,id:_.id,type:_.type,loadersConnection:J,previewKitConnection:H})})]})}export{sr as default};//# sourceMappingURL=PresentationTool.js.map
`;function sr(e){var t,a,s,l;const{previewUrl:d,components:u}=null!=(t=e.tool.options)?t:{},p=e.tool.name||xe,{unstable_navigator:h}=u||{},{navigate:m,state:f}=le(),v=V(Object.fromEntries(f._searchParams||[])),g=nr(d||"/",p,v.preview||null),[y]=$((()=>{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})),b=L((()=>g.origin),[g.origin]),w=O(null),[P,x]=$(),[k,E]=$({}),S=O({title:void 0,url:void 0}),{navigate:I,params:z,searchParams:D,structureParams:C}=tr({initialPreviewUrl:g,routerNavigate:m,routerState:f,routerSearchParams:v,frameStateRef:S}),T=L((()=>jt(I,50)),[I]),[U,A]=M(Sn,{},$n),W=L((()=>z.perspective?"published":"previewDrafts"),[z.perspective]),F=L((()=>z.viewport?"mobile":"desktop"),[z.viewport]),[K,B]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,r]=$({}),[i,o]=$({}),a=O(""),s=j(((e,n,i=[])=>{const s=i.filter((e=>"_projectId"in e&&e._projectId?(Jn||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Jn=!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 Xe(i,r)?n:{...n,[e]:r}}))}),[t]);return[L((()=>{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]}(W,S),q=oe(),G=ae(),J=Zn({resolvers:null==(s=null==(a=e.tool.options)?void 0:a.resolve)?void 0:s.mainDocuments,previewUrl:null==(l=e.tool.options)?void 0:l.previewUrl,path:z.preview,navigate:I}),[X,H]=$("connecting"),[Z,Q]=$("connecting"),[Y,ee]=$("connecting"),[te]=$((()=>new Set)),ne=j((e=>{const t=window.open(e,"_blank");t&&te.add(t)}),[te]);R((()=>{if(te.size&&P)for(const e of te)e&&"closed"in e&&!e.closed&&P.addSource(e)}),[P,te,te.size]);const re=O(W);R((()=>{re.current=W}),[W]),R((()=>{var e;const t=null==(e=w.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:b,connectTo:[{id:"overlays",heartbeat:!0,onStatusUpdate:H,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&&T({},{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?A({type:En,enabled:t.enabled}):"visual-editing/documents"===e?B("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(Se.current):"visual-editing/refreshing"===e&&"mutation"===t.source?A({type:xn}):"visual-editing/refreshed"===e&&A({type:Pn});else T({type:t.type,id:t.id,path:t.path},{prefersLatestPublished:"isDraft"in t||"previewDrafts"===re.current?void 0:"true"})}},{id:"loaders",heartbeat:!0,onStatusUpdate:Q,onEvent(e,t){if("loader/documents"===e&&t.projectId===q&&t.dataset===G)B("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===q&&t.dataset===G){if("number"==typeof t.heartbeat&&t.heartbeat<be)throw new Error(`Loader query listen heartbeat interval must be at least ${be}ms`);E((e=>{var n;return{...e,[Lt(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:ee,onEvent(e,t){"preview-kit/documents"===e&&t.projectId===q&&t.dataset===G&&B("preview-kit",t.perspective,t.documents)}}]});return x(n),()=>{n.destroy(),x(void 0)}}),[G,q,B,T,b]),R((()=>{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}))),be);return()=>clearInterval(e)}),[]);const ie=j((e=>{T({path:o.toString(e)},{},!0)}),[T]),ce=j((e=>{const t=new URL(e,g.origin),n=t.pathname+t.search;t.origin===g.origin&&n!==z.preview&&T({},{preview:n})}),[g,z,T]),de=j((e=>{T({},{...e,prefersLatestPublished:void 0})}),[T]);R((()=>{null==P||P.send("overlays","presentation/perspective",{perspective:W})}),[P,W]),R((()=>{z.id&&z.path?null==P||P.send("overlays","presentation/focus",{id:z.id,path:z.path}):null==P||P.send("overlays","presentation/blur",void 0)}),[P,z.id,z.path]);const ue=O(void 0);R((()=>{"published"===W&&z.id&&z.id!==ue.current&&!z.rev&&!z.prefersLatestPublished&&T({},{prefersLatestPublished:"true"},!0),ue.current=z.id}),[T,z.id,z.prefersLatestPublished,z.rev,W]),R((()=>{S.current.url&&z.preview&&S.current.url!==z.preview&&(S.current.url=z.preview,"connected"!==X&&w.current?w.current.src=`${b}${z.preview}`:null==P||P.send("overlays","presentation/navigate",{url:z.preview,type:"replace"}))}),[P,X,b,z.preview]);const pe=j((()=>null==P?void 0:P.send("overlays","presentation/toggleOverlay",void 0)),[P]),[he,me]=$(null);R((()=>{const e=e=>{$t(e)&&pe()},t=e=>{var t;$t(e)&&pe(),t=e,["mod","\\"].every((e=>Ot[e]?t[Ot[e]]:t.key===e.toUpperCase()))&&pe()};return window.addEventListener("keydown",t),window.addEventListener("keyup",e),()=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",e)}}),[pe]);const[fe,ve]=$(null),[{navigatorEnabled:ge,toggleNavigator:ye},ke]=gn({unstable_navigator:h}),Ee=O(z.id);R((()=>{z.rev&&Ee.current&&z.id!==Ee.current&&T({},{rev:void 0}),Ee.current=z.id}));const Se=O(),Ie=j((e=>{if(A({type:xn}),P)return Se.current=window.setTimeout(e,300),void P.send("overlays","presentation/refresh",{source:"manual",livePreviewEnabled:"connected"===Y||"connected"===Z});e()}),[P,Z,Y]),_e=se(),ze=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:we,workspace:_e.name,mode:Pe,preview:z.preview}}}),[z.preview,_e.name]),De=j((e=>{T({},{viewport:"desktop"===e?void 0:"mobile"},!0)}),[T]),Ce=j((e=>{T({},{perspective:"previewDrafts"===e?void 0:e})}),[T]);return r(i,{children:[n(wn,{devMode:y,name:p,navigate:T,params:z,searchParams:D,structureParams:C,children:n(vn,{navigate:T,children:n(bn,{params:z,children:n(ar,{height:"fill",children:r(Ht,{children:[n(ke,{}),n(Ut,{id:"preview",minWidth:325,defaultSize:ge?50:75,order:3,children:n(c,{direction:"column",flex:1,height:"fill",ref:ve,children:n(_,{element:fe,children:n(Kn,{dispatch:A,iframe:U.iframe,initialUrl:g,loadersConnection:Z,navigatorEnabled:ge,onPathChange:ce,onRefresh:Ie,openPopup:ne,overlaysConnection:X,previewUrl:z.preview,perspective:W,ref:w,setPerspective:Ce,setViewport:De,targetOrigin:b,toggleNavigator:ye,toggleOverlay:pe,viewport:F,visualEditing:U.visualEditing})})})}),n(fn,{documentId:z.id,documentsOnPage:K,documentType:z.type,getCommentIntent:ze,mainDocumentState:J,onFocusPath:ie,onStructureParams:de,searchParams:D,setDisplayedDocument:me,structureParams:C})]})})})})}),P&&n(N,{children:n(ir,{channel:P,liveQueries:k,perspective:W,liveDocument:he,documentsOnPage:K})}),P&&z.id&&z.type&&n(N,{children:n(or,{channel:P,id:z.id,type:z.type,loadersConnection:Z,previewKitConnection:Y})})]})}export{sr as default};//# sourceMappingURL=PresentationTool.js.map

@@ -14,4 +14,12 @@ /// <reference types="react" />

/**
* All possible URL search parameters used by the Presentation tool
* @internal
*/
export declare interface CombinedSearchParams
extends StructureDocumentPaneParams,
PresentationSearchParams {}
/**
* @internal
*/
export declare type ContextFn<T> = (context: DocumentResolverContext) => T

@@ -197,3 +205,3 @@

nextState: PresentationStateParams,
nextSearchState?: PresentationSearchParams,
nextSearchState?: CombinedSearchParams,
forceReplace?: boolean,

@@ -210,11 +218,14 @@ ) => void

export declare interface PresentationParams
extends PresentationStateParams,
StructureDocumentPaneParams {
id?: string
preview?: string
perspective?: string
viewport?: string
}
/**
* All possible parameters that can be used to describe the state of the
* Presentation tool, stored in the pathname and as search parameters of the URL
* @internal
*/
export declare interface PresentationParams extends PresentationStateParams, CombinedSearchParams {}
export declare type PresentationPerspective = Extract<
'published' | 'previewDrafts',
ClientPerspective
>
export declare interface PresentationPluginOptions {

@@ -243,3 +254,8 @@ devMode?: boolean | (() => boolean)

export declare interface PresentationSearchParams extends StructureDocumentPaneParams {
/**
* Presentation specific URL search parameters, they should persist when
* navigating between the document pane and document list pane
* @internal
*/
export declare interface PresentationSearchParams {
preview?: string

@@ -250,2 +266,6 @@ perspective?: string

/**
* Presentation specific state that is stored in the pathname section of the URL
* @internal
*/
export declare interface PresentationStateParams {

@@ -259,2 +279,4 @@ type?: string

export declare type PresentationViewport = 'desktop' | 'mobile'
export declare type PreviewUrlOption =

@@ -269,2 +291,7 @@ | string

/**
* Document Pane specific URL search parameters, they should not persist when
* navigating between the document pane and document list pane
* @internal
*/
export declare interface StructureDocumentPaneParams {

@@ -271,0 +298,0 @@ inspect?: string

{
"name": "@sanity/presentation",
"version": "1.15.14",
"version": "1.15.15",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/presentation#readme",

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

"dependencies": {
"@sanity/icons": "^3.0.0",
"@sanity/icons": "^3.2.0",
"@sanity/preview-url-secret": "^1.6.17",
"@sanity/ui": "^2.2.0",
"@sanity/ui": "^2.3.3",
"@sanity/uuid": "3.0.2",

@@ -110,5 +110,5 @@ "@types/lodash.isequal": "^4.5.8",

"@repo/channels": "0.4.0",
"@repo/visual-editing-helpers": "0.6.16",
"@repo/visual-editing-helpers": "0.6.17",
"@sanity/client": "^6.19.1",
"@sanity/pkg-utils": "6.9.0",
"@sanity/pkg-utils": "6.9.3",
"happy-dom": "^14.12.0",

@@ -115,0 +115,0 @@ "react": "^18.3.1",

@@ -13,10 +13,21 @@ /**

type DocumentStore,
getPreviewStateObservable,
getPreviewValueWithFallback,
getPublishedId,
isRecord,
type Path,
pathToString,
Preview,
PreviewCard,
type PreviewValue,
type PublishedId,
SanityDefaultPreview,
type SanityDocument,
Translate,
useActiveWorkspace,
useDocumentPreviewStore,
useDocumentStore,
useEditState,
useSchema,
useTranslation,
useUnique,

@@ -23,0 +34,0 @@ useWorkspace,

import {createContext} from 'react'
import type {PresentationNavigate, PresentationParams, StructureDocumentPaneParams} from './types'
import type {
PresentationNavigate,
PresentationParams,
PresentationSearchParams,
StructureDocumentPaneParams,
} from './types'

@@ -11,4 +16,5 @@ export interface PresentationContextValue {

structureParams: StructureDocumentPaneParams
searchParams: PresentationSearchParams
}
export const PresentationContext = createContext<PresentationContextValue | null>(null)

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

import type {ClientPerspective} from '@sanity/client'
import type {Dispatch, Reducer} from 'react'

@@ -10,10 +9,2 @@ import {boolean, fallback, object, parse, picklist} from 'valibot'

}
/**
* The selected perspective that all previews should use
*/
perspective: Extract<'published' | 'previewDrafts', ClientPerspective>
/**
* The viewport size of the preview iframe is currently hardcoded, using this enum to determine the size
*/
viewport: 'desktop' | 'mobile'
visualEditing: {

@@ -27,4 +18,2 @@ overlaysEnabled: boolean

export const ACTION_IFRAME_RELOAD = 'ACTION_IFRAME_RELOAD'
export const ACTION_PERSPECTIVE = 'ACTION_PERSPECTIVE'
export const ACTION_VIEWPORT = 'ACTION_VIEWPORT'
export const ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE = 'ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE'

@@ -41,10 +30,2 @@

}
interface PerspectiveAction {
type: typeof ACTION_PERSPECTIVE
perspective: PresentationState['perspective']
}
interface ViewportAction {
type: typeof ACTION_VIEWPORT
viewport: PresentationState['viewport']
}
interface VisualEditingOverlaysToggleAction {

@@ -59,4 +40,2 @@ type: typeof ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE

| IframeReloadAction
| PerspectiveAction
| ViewportAction
| VisualEditingOverlaysToggleAction

@@ -99,12 +78,2 @@

}
case ACTION_PERSPECTIVE:
return {
...state,
perspective: parse(perspectiveSchema, action.perspective),
}
case ACTION_VIEWPORT:
return {
...state,
viewport: parse(viewportSchema, action.viewport),
}
case ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE:

@@ -134,10 +103,3 @@ return toggleVisualEditingOverlays(state, action)

const iframeStatusSchema = picklist(['loading', 'loaded', 'refreshing', 'reloading'])
const perspectiveSchema = fallback(
picklist(['published', 'previewDrafts'] satisfies PresentationState['perspective'][]),
'previewDrafts',
)
const viewportSchema = fallback(
picklist(['desktop', 'mobile'] satisfies PresentationState['viewport'][]),
'desktop',
)
const initStateSchema = object({

@@ -148,4 +110,2 @@ mainDocument: mainDocumentSchema,

}),
perspective: perspectiveSchema,
viewport: viewportSchema,
visualEditing: object({overlaysEnabled: boolean()}),

@@ -159,4 +119,2 @@ })

},
perspective: 'previewDrafts',
viewport: 'desktop',
visualEditing: {

@@ -166,10 +124,5 @@ overlaysEnabled: false,

} as const satisfies PresentationState
export function presentationReducerInit(
state: Readonly<
Partial<{
mainDocument: boolean
perspective: string
viewport: string
}>
>,
state: Readonly<Partial<PresentationState>>,
): Readonly<PresentationState> {

@@ -176,0 +129,0 @@ return parse(initStateSchema, {...INITIAL_PRESENTATION_STATE, ...state})

@@ -158,2 +158,6 @@ import type {ClientPerspective, QueryParams} from '@sanity/client'

/**
* Presentation specific state that is stored in the pathname section of the URL
* @internal
*/
export interface PresentationStateParams {

@@ -165,2 +169,18 @@ type?: string

/**
* Presentation specific URL search parameters, they should persist when
* navigating between the document pane and document list pane
* @internal
*/
export interface PresentationSearchParams {
preview?: string
perspective?: string
viewport?: string
}
/**
* Document Pane specific URL search parameters, they should not persist when
* navigating between the document pane and document list pane
* @internal
*/
export interface StructureDocumentPaneParams {

@@ -184,21 +204,27 @@ inspect?: string

export interface PresentationParams extends PresentationStateParams, StructureDocumentPaneParams {
id?: string
preview?: string
perspective?: string
viewport?: string
}
/**
* All possible URL search parameters used by the Presentation tool
* @internal
*/
export interface CombinedSearchParams
extends StructureDocumentPaneParams,
PresentationSearchParams {}
export interface PresentationSearchParams extends StructureDocumentPaneParams {
preview?: string
perspective?: string
viewport?: string
}
/**
* All possible parameters that can be used to describe the state of the
* Presentation tool, stored in the pathname and as search parameters of the URL
* @internal
*/
export interface PresentationParams extends PresentationStateParams, CombinedSearchParams {}
export type PresentationNavigate = (
nextState: PresentationStateParams,
nextSearchState?: PresentationSearchParams,
nextSearchState?: CombinedSearchParams,
forceReplace?: boolean,
) => void
export type PresentationPerspective = Extract<'published' | 'previewDrafts', ClientPerspective>
export type PresentationViewport = 'desktop' | 'mobile'
/** @internal */

@@ -205,0 +231,0 @@ export type LiveQueriesState = Record<string, LiveQueriesStateValue>

@@ -5,4 +5,3 @@ import type {ClientPerspective} from '@sanity/client'

import type {PresentationState} from './reducers/presentationReducer'
import type {FrameState} from './types'
import type {FrameState, PresentationPerspective} from './types'

@@ -20,7 +19,7 @@ export type DocumentOnPage = {

export function useDocumentsOnPage(
perspective: PresentationState['perspective'],
perspective: PresentationPerspective,
frameStateRef: MutableRefObject<FrameState>,
): [
DocumentOnPage[],
(key: string, perspective: PresentationState['perspective'], state: DocumentOnPage[]) => void,
(key: string, perspective: PresentationPerspective, state: DocumentOnPage[]) => void,
] {

@@ -27,0 +26,0 @@ if (perspective !== 'published' && perspective !== 'previewDrafts') {

@@ -7,2 +7,3 @@ import {type MutableRefObject, useCallback, useEffect, useMemo, useRef} from 'react'

import type {
CombinedSearchParams,
FrameState,

@@ -41,2 +42,3 @@ PresentationNavigate,

params: PresentationParams
searchParams: PresentationSearchParams
structureParams: StructureDocumentPaneParams

@@ -101,2 +103,11 @@ } {

const searchParams = useMemo<PresentationSearchParams>(() => {
const pruned = pruneObject({
perspective: params.perspective,
preview: params.preview,
viewport: params.viewport,
})
return pruned
}, [params.perspective, params.preview, params.viewport])
const routerStateRef = useRef(routerState)

@@ -118,4 +129,4 @@

const routerSearchState = (routerSearchParams || []).reduce(
(acc, [key, value]) => ((acc[key as keyof PresentationSearchParams] = value), acc),
{} as PresentationSearchParams,
(acc, [key, value]) => ((acc[key as keyof CombinedSearchParams] = value), acc),
{} as CombinedSearchParams,
)

@@ -154,6 +165,7 @@

return {
structureParams,
navigate,
params,
searchParams,
structureParams,
}
}

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc