Socket
Socket
Sign inDemoInstall

@sanity/presentation

Package Overview
Dependencies
89
Maintainers
48
Versions
127
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.12.6 to 1.12.7

34

dist/_chunks-es/PresentationTool.js

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

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),r);import{jsx as n,jsxs as r,Fragment as i}from"react/jsx-runtime";import{studioPath as o}from"@sanity/client/csm";import{Card as a,Flex as s,Container as c,Stack as l,Text as d,Inline as u,Box as p,Button as h,Code as f,Label as m,ErrorBoundary as v,TextInput as g,MenuItem as y,useToast as w,Switch as b,usePrefersReducedMotion as x,TooltipDelayGroupProvider as P,Tooltip as E,MenuButton as k,Menu as S,Spinner as I,BoundaryElementProvider as z}from"@sanity/ui";import{useContext as C,forwardRef as O,useCallback as R,useMemo as U,useState as $,useEffect as j,createContext as L,useLayoutEffect as D,useRef as T,memo as A,createElement as _,startTransition as W,useReducer as M,Suspense as N,lazy as F}from"react";import{useUnique as V,getPublishedId as B,useActiveWorkspace as K,useClient as q,useCurrentUser as G,Hotkeys as J,useProjectId as H,useDataset as X,useWorkspace as Z}from"sanity";import{StateLink as Q,useRouter as Y,decodeJsonParams as ee}from"sanity/router";import{PaneRouterContext as te,PaneLayout as ne,StructureToolProvider as re,DocumentListPane as ie,DocumentPane as oe,CommentsIntentProvider as ae}from"sanity/structure";import{styled as se}from"styled-components";import{P as ce,a as le,b as de,A as ue,M as pe,c as he,C as fe,E as me,D as ve}from"./index.js";import{D as ge}from"./DisplayedDocumentBroadcaster.js";import{ResetIcon as ye,LaunchIcon as we,CopyIcon as be,PanelLeftIcon as xe,RefreshIcon as Pe,ShareIcon as Ee,ChevronDownIcon as ke,CheckmarkIcon as Se,DesktopIcon as Ie,MobileDeviceIcon as ze,EditIcon as Ce,PublishIcon as Oe}from"@sanity/icons";import{hasSecretSearchParams as Re,setSecretSearchParams as Ue,withoutSecretSearchParams as $e}from"@sanity/preview-url-secret/without-secret-search-params";import{motion as je,MotionConfig as Le,AnimatePresence as De}from"framer-motion";import{createPreviewSecret as Te}from"@sanity/preview-url-secret/create-secret";import Ae from"fast-deep-equal";import{definePreviewUrl as _e}from"@sanity/preview-url-secret/define-preview-url";import{suspend as We}from"suspend-react";let Me;const Ne=new Uint8Array(16);function Fe(){if(!Me&&(Me=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Me))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Me(Ne)}const Ve=[];for(let e=0;e<256;++e)Ve.push((e+256).toString(16).slice(1));var Be={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ke(e,t,n){if(Be.randomUUID&&!t&&!e)return Be.randomUUID();const r=(e=e||{}).random||(e.rng||Fe)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return Ve[e[t+0]]+Ve[e[t+1]]+Ve[e[t+2]]+Ve[e[t+3]]+"-"+Ve[e[t+4]]+Ve[e[t+5]]+"-"+Ve[e[t+6]]+Ve[e[t+7]]+"-"+Ve[e[t+8]]+Ve[e[t+9]]+"-"+Ve[e[t+10]]+Ve[e[t+11]]+Ve[e[t+12]]+Ve[e[t+13]]+Ve[e[t+14]]+Ve[e[t+15]]}(r)}const qe=1e3,Ge=1e3,Je=500,He=["handshake/syn","handshake/syn-ack","handshake/ack"],Xe=e=>He.some((t=>t===e)),Ze=({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 Qe(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(Xe(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(!Xe(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(Ze(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=Ke(),e.interval=window.setInterval((()=>{l(e,"handshake/syn",{id:e.id})}),Je)}(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:Ge;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:Ke(),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=Ke();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}').`))}),qe),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 Ye,et,tt,nt,rt=class extends Error{constructor(e){super(e[0].message),t(this,"issues"),this.name="ValiError",this.issues=e}};function it(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function ot(e,t,n,r,i){var o,a,s,c,l;const d=null!=(l=null!=(c=null!=(s=null!=(a=null!=(o=t.message)?o:function(e,t){var n;return null==(n=null==nt?void 0:nt.get(e))?void 0:n.get(t)}(n,i.lang))?a:e?(u=i.lang,null==tt?void 0:tt.get(u)):null)?s:null==r?void 0:r.message)?c:function(e){return null==et?void 0:et.get(e)}(i.lang))?l:i.message;var u;return"function"==typeof d?d(i):d}function at(e,t,n){return{typed:e,output:t,issues:n}}function st(e){let t=typeof e;return"object"===t&&(t=e?Object.getPrototypeOf(e).constructor.name:"null"),"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:t}function ct(e,t,n){var r;const i=null!=(r=n.received)?r:st(n.input),o={reason:e.type,context:n.context.type,expected:n.context.expects,received:i,message:`Invalid ${n.label}: ${n.context.expects?`Expected ${n.context.expects} but r`:"R"}eceived ${i}`,input:n.input,requirement:n.context.requirement,path:n.path,lang:null==t?void 0:t.lang,abortEarly:null==t?void 0:t.abortEarly,abortPipeEarly:null==t?void 0:t.abortPipeEarly,skipPipe:null==t?void 0:t.skipPipe};return o.message=ot(!1,n.context,n.reference,t,o),o}function lt(e,t,n,r){if(e.pipe&&(null==n||!n.skipPipe))for(const i of e.pipe){const o=i._parse(t);if(o.issues){for(const t of o.issues){const i=ct(e,n,t);r?r.push(i):r=[i]}if(null!=n&&n.abortEarly||null!=n&&n.abortPipeEarly)break}else t=o.output}return at(!0,t,r)}function dt(e,t,n,r,i){var o,a;const s=st(n),c=null!=(o=null==i?void 0:i.expected)?o:e.expects,l={reason:null!=(a=null==i?void 0:i.reason)?a:"type",context:e.type,expected:c,received:s,message:`Invalid type: Expected ${c} but received ${s}`,input:n,path:null==i?void 0:i.path,issues:null==i?void 0:i.issues,lang:null==r?void 0:r.lang,abortEarly:null==r?void 0:r.abortEarly,abortPipeEarly:null==r?void 0:r.abortPipeEarly,skipPipe:null==r?void 0:r.skipPipe};return l.message=ot(!0,e,t,r,l),{typed:!1,output:n,issues:[l]}}function ut(e,t){return{...e,fallback:t,_parse(t,n){const r=e._parse(t,n);return r.issues?at(!0,function(e,t){return"function"==typeof e.fallback?e.fallback(t):e.fallback}(this,{input:t,issues:r.issues})):r}}}function pt(e,t,n,r){const[i,o,a]=function(e,t,n){if(!e||"object"==typeof e&&!Array.isArray(e)){const[r,i]=it(t,n);return[e,r,i]}const[r,i]=it(e,t);return[void 0,r,i]}(t,n,r);let s;return{type:"object",expects:"Object",async:!1,entries:e,rest:i,message:o,pipe:a,_parse(e,t){if(e&&"object"==typeof e){s=null!=s?s:Object.entries(this.entries);let n,r=!0;const i={};for(const[o,a]of s){const s=e[o],c=a._parse(s,t);if(c.issues){const i={type:"object",origin:"value",input:e,key:o,value:s};for(const e of c.issues)e.path?e.path.unshift(i):e.path=[i],null==n||n.push(e);if(n||(n=c.issues),null!=t&&t.abortEarly){r=!1;break}}c.typed||(r=!1),(void 0!==c.output||o in e)&&(i[o]=c.output)}if(this.rest&&(null==t||!t.abortEarly||!n))for(const o in e)if(!(o in this.entries)){const a=e[o],s=this.rest._parse(a,t);if(s.issues){const i={type:"object",origin:"value",input:e,key:o,value:a};for(const e of s.issues)e.path?e.path.unshift(i):e.path=[i],null==n||n.push(e);if(n||(n=s.issues),null!=t&&t.abortEarly){r=!1;break}}s.typed||(r=!1),i[o]=s.output}return r?lt(this,i,t,n):at(!1,i,n)}return dt(this,pt,e,t)}}}function ht(e,t){return{type:"picklist",expects:e.map(st).join(" | "),async:!1,options:e,message:t,_parse(e,t){return this.options.includes(e)?at(!0,e):dt(this,ht,e,t)}}}function ft(e,t,n){const r=e._parse(t,function(e){var t,n,r,i;return{lang:null!=(t=null==e?void 0:e.lang)?t:null==Ye?void 0:Ye.lang,message:null==e?void 0:e.message,abortEarly:null!=(n=null==e?void 0:e.abortEarly)?n:null==Ye?void 0:Ye.abortEarly,abortPipeEarly:null!=(r=null==e?void 0:e.abortPipeEarly)?r:null==Ye?void 0:Ye.abortPipeEarly,skipPipe:null!=(i=null==e?void 0:e.skipPipe)?i:null==Ye?void 0:Ye.skipPipe}}(n));if(r.issues)throw new rt(r.issues);return r.output}const mt=/^([A-Za-z]+):([0-9]+)$/,vt=/^([A-Za-z]+):([0-9]+),([0-9]+)$/,gt=/^([A-Za-z]+):([a-z0-9]+)$/;function yt(e,t){return`${e}-${"string"==typeof t?t:JSON.stringify(t)}`}const wt={alt:"altKey",ctrl:"ctrlKey",mod:typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function bt(e){return"Alt"===e.key}function xt(e){const{children:t,message:i,onRetry:o,onContinueAnyway:f,...m}=e,v=n(h,{fontSize:1,mode:"ghost",onClick:o,text:"Retry"}),g=n(h,{fontSize:1,mode:"ghost",tone:"critical",onClick:f,text:"Continue anyway"});return n(a,{height:"fill",...m,children:n(s,{align:"center",height:"fill",justify:"center",children:n(c,{padding:4,sizing:"border",width:0,children:r(l,{space:4,children:[r(l,{space:3,children:[n(d,{size:1,weight:"semibold",children:"An error occured"}),n(d,{muted:!0,size:1,children:i})]}),t,o&&f?r(u,{space:2,children:[v,g]}):o?n(p,{children:v}):f?n(p,{children:g}):null]})})})})}function Pt(){const e=C(ce);if(!e)throw new Error("Presentation context is missing");return e}function Et(e){const t=["comment","inspect","instruction","pathKey","rev","since","template","view"];return function(e={}){const t=Object.entries(e).map((([e,t])=>`${e}=${t}`)).join("&");return t.length?`?${t}`:""}(Object.entries(e).filter((([e])=>t.includes(e))).reduce(((e,[t,n])=>null==n?e:{...e,[t]:n}),{}))}const kt=O((function(e,t){const{params:r,structureParams:i}=Pt();return n(Q,{...e,ref:t,state:{type:void 0,_searchParams:Object.entries({...i,preview:r.preview})},title:void 0})})),St=O((function(e,t){const{documentId:r,documentType:i,parentRefPath:o,template:a,...s}=e;return n(Q,{...s,ref:t,state:{id:r,type:i,_searchParams:Object.entries({preview:e.previewUrl})},title:void 0})}));function It(e){const{children:t,onStructureParams:r,params:o,previewUrl:a,refs:s}=e,{state:c,resolvePathFromState:l}=Y(),d=V(Object.fromEntries(c._searchParams||[])),u=R((e=>`${l(c)}${Et({...d,...e})}`),[l,d,c]),p=U((()=>({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(Q,{...r,state:{id:t,type:i._type,_searchParams:Object.entries({preview:a})}}):n("div",{...r})},BackLink:kt,ReferenceChildLink:e=>n(St,{...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(te.Provider,{value:p,children:t})}const zt=se(ne)`
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),r);import{jsx as n,jsxs as r,Fragment as i}from"react/jsx-runtime";import{studioPath as o}from"@sanity/client/csm";import{Card as a,Flex as s,Container as c,Stack as l,Text as d,Inline as u,Box as p,Button as h,Code as f,Label as m,ErrorBoundary as v,TextInput as g,MenuItem as y,useToast as w,usePrefersReducedMotion as b,TooltipDelayGroupProvider as x,Tooltip as P,Switch as E,MenuButton as k,Menu as S,Spinner as I,BoundaryElementProvider as z}from"@sanity/ui";import{useContext as C,forwardRef as O,useCallback as R,useMemo as U,useState as $,useEffect as j,createContext as L,useLayoutEffect as D,useRef as T,memo as A,createElement as _,startTransition as W,useReducer as M,Suspense as N,lazy as F}from"react";import{useUnique as V,getPublishedId as B,useActiveWorkspace as K,useClient as q,useCurrentUser as G,Hotkeys as J,useProjectId as X,useDataset as H,useWorkspace as Z}from"sanity";import{StateLink as Q,useRouter as Y,decodeJsonParams as ee}from"sanity/router";import{PaneRouterContext as te,PaneLayout as ne,StructureToolProvider as re,DocumentListPane as ie,DocumentPane as oe,CommentsIntentProvider as ae}from"sanity/structure";import{styled as se}from"styled-components";import{P as ce,a as le,b as de,A as ue,M as pe,c as he,C as fe,E as me,D as ve}from"./index.js";import{D as ge}from"./DisplayedDocumentBroadcaster.js";import{ResetIcon as ye,LaunchIcon as we,CopyIcon as be,PanelLeftIcon as xe,RefreshIcon as Pe,ShareIcon as Ee,ChevronDownIcon as ke,CheckmarkIcon as Se,DesktopIcon as Ie,MobileDeviceIcon as ze,EditIcon as Ce,PublishIcon as Oe}from"@sanity/icons";import{hasSecretSearchParams as Re,setSecretSearchParams as Ue,withoutSecretSearchParams as $e}from"@sanity/preview-url-secret/without-secret-search-params";import{motion as je,MotionConfig as Le,AnimatePresence as De}from"framer-motion";import{createPreviewSecret as Te}from"@sanity/preview-url-secret/create-secret";import Ae from"fast-deep-equal";import{definePreviewUrl as _e}from"@sanity/preview-url-secret/define-preview-url";import{suspend as We}from"suspend-react";let Me;const Ne=new Uint8Array(16);function Fe(){if(!Me&&(Me=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Me))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Me(Ne)}const Ve=[];for(let e=0;e<256;++e)Ve.push((e+256).toString(16).slice(1));var Be={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ke(e,t,n){if(Be.randomUUID&&!t&&!e)return Be.randomUUID();const r=(e=e||{}).random||(e.rng||Fe)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return function(e,t=0){return Ve[e[t+0]]+Ve[e[t+1]]+Ve[e[t+2]]+Ve[e[t+3]]+"-"+Ve[e[t+4]]+Ve[e[t+5]]+"-"+Ve[e[t+6]]+Ve[e[t+7]]+"-"+Ve[e[t+8]]+Ve[e[t+9]]+"-"+Ve[e[t+10]]+Ve[e[t+11]]+Ve[e[t+12]]+Ve[e[t+13]]+Ve[e[t+14]]+Ve[e[t+15]]}(r)}const qe=1e3,Ge=1e3,Je=500,Xe=["handshake/syn","handshake/syn-ack","handshake/ack"],He=e=>Xe.some((t=>t===e)),Ze=({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 Qe(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(He(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(!He(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(Ze(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=Ke(),e.interval=window.setInterval((()=>{l(e,"handshake/syn",{id:e.id})}),Je)}(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:Ge;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:Ke(),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=Ke();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}').`))}),qe),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 Ye,et,tt,nt,rt=class extends Error{constructor(e){super(e[0].message),t(this,"issues"),this.name="ValiError",this.issues=e}};function it(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function ot(e,t,n,r,i){var o,a,s,c,l;const d=null!=(l=null!=(c=null!=(s=null!=(a=null!=(o=t.message)?o:function(e,t){var n;return null==(n=null==nt?void 0:nt.get(e))?void 0:n.get(t)}(n,i.lang))?a:e?(u=i.lang,null==tt?void 0:tt.get(u)):null)?s:null==r?void 0:r.message)?c:function(e){return null==et?void 0:et.get(e)}(i.lang))?l:i.message;var u;return"function"==typeof d?d(i):d}function at(e,t,n){return{typed:e,output:t,issues:n}}function st(e){let t=typeof e;return"object"===t&&(t=e?Object.getPrototypeOf(e).constructor.name:"null"),"string"===t?`"${e}"`:"number"===t||"bigint"===t||"boolean"===t?`${e}`:t}function ct(e,t,n){var r;const i=null!=(r=n.received)?r:st(n.input),o={reason:e.type,context:n.context.type,expected:n.context.expects,received:i,message:`Invalid ${n.label}: ${n.context.expects?`Expected ${n.context.expects} but r`:"R"}eceived ${i}`,input:n.input,requirement:n.context.requirement,path:n.path,lang:null==t?void 0:t.lang,abortEarly:null==t?void 0:t.abortEarly,abortPipeEarly:null==t?void 0:t.abortPipeEarly,skipPipe:null==t?void 0:t.skipPipe};return o.message=ot(!1,n.context,n.reference,t,o),o}function lt(e,t,n,r){if(e.pipe&&(null==n||!n.skipPipe))for(const i of e.pipe){const o=i._parse(t);if(o.issues){for(const t of o.issues){const i=ct(e,n,t);r?r.push(i):r=[i]}if(null!=n&&n.abortEarly||null!=n&&n.abortPipeEarly)break}else t=o.output}return at(!0,t,r)}function dt(e,t,n,r,i){var o,a;const s=st(n),c=null!=(o=null==i?void 0:i.expected)?o:e.expects,l={reason:null!=(a=null==i?void 0:i.reason)?a:"type",context:e.type,expected:c,received:s,message:`Invalid type: Expected ${c} but received ${s}`,input:n,path:null==i?void 0:i.path,issues:null==i?void 0:i.issues,lang:null==r?void 0:r.lang,abortEarly:null==r?void 0:r.abortEarly,abortPipeEarly:null==r?void 0:r.abortPipeEarly,skipPipe:null==r?void 0:r.skipPipe};return l.message=ot(!0,e,t,r,l),{typed:!1,output:n,issues:[l]}}function ut(e,t){return{...e,fallback:t,_parse(t,n){const r=e._parse(t,n);return r.issues?at(!0,function(e,t){return"function"==typeof e.fallback?e.fallback(t):e.fallback}(this,{input:t,issues:r.issues})):r}}}function pt(e,t,n,r){const[i,o,a]=function(e,t,n){if(!e||"object"==typeof e&&!Array.isArray(e)){const[r,i]=it(t,n);return[e,r,i]}const[r,i]=it(e,t);return[void 0,r,i]}(t,n,r);let s;return{type:"object",expects:"Object",async:!1,entries:e,rest:i,message:o,pipe:a,_parse(e,t){if(e&&"object"==typeof e){s=null!=s?s:Object.entries(this.entries);let n,r=!0;const i={};for(const[o,a]of s){const s=e[o],c=a._parse(s,t);if(c.issues){const i={type:"object",origin:"value",input:e,key:o,value:s};for(const e of c.issues)e.path?e.path.unshift(i):e.path=[i],null==n||n.push(e);if(n||(n=c.issues),null!=t&&t.abortEarly){r=!1;break}}c.typed||(r=!1),(void 0!==c.output||o in e)&&(i[o]=c.output)}if(this.rest&&(null==t||!t.abortEarly||!n))for(const o in e)if(!(o in this.entries)){const a=e[o],s=this.rest._parse(a,t);if(s.issues){const i={type:"object",origin:"value",input:e,key:o,value:a};for(const e of s.issues)e.path?e.path.unshift(i):e.path=[i],null==n||n.push(e);if(n||(n=s.issues),null!=t&&t.abortEarly){r=!1;break}}s.typed||(r=!1),i[o]=s.output}return r?lt(this,i,t,n):at(!1,i,n)}return dt(this,pt,e,t)}}}function ht(e,t){return{type:"picklist",expects:e.map(st).join(" | "),async:!1,options:e,message:t,_parse(e,t){return this.options.includes(e)?at(!0,e):dt(this,ht,e,t)}}}function ft(e,t,n){const r=e._parse(t,function(e){var t,n,r,i;return{lang:null!=(t=null==e?void 0:e.lang)?t:null==Ye?void 0:Ye.lang,message:null==e?void 0:e.message,abortEarly:null!=(n=null==e?void 0:e.abortEarly)?n:null==Ye?void 0:Ye.abortEarly,abortPipeEarly:null!=(r=null==e?void 0:e.abortPipeEarly)?r:null==Ye?void 0:Ye.abortPipeEarly,skipPipe:null!=(i=null==e?void 0:e.skipPipe)?i:null==Ye?void 0:Ye.skipPipe}}(n));if(r.issues)throw new rt(r.issues);return r.output}const mt=/^([A-Za-z]+):([0-9]+)$/,vt=/^([A-Za-z]+):([0-9]+),([0-9]+)$/,gt=/^([A-Za-z]+):([a-z0-9]+)$/;function yt(e,t){return`${e}-${"string"==typeof t?t:JSON.stringify(t)}`}const wt={alt:"altKey",ctrl:"ctrlKey",mod:typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function bt(e){return"Alt"===e.key}function xt(e){const{children:t,message:i,onRetry:o,onContinueAnyway:f,...m}=e,v=n(h,{fontSize:1,mode:"ghost",onClick:o,text:"Retry"}),g=n(h,{fontSize:1,mode:"ghost",tone:"critical",onClick:f,text:"Continue anyway"});return n(a,{height:"fill",...m,children:n(s,{align:"center",height:"fill",justify:"center",children:n(c,{padding:4,sizing:"border",width:0,children:r(l,{space:4,children:[r(l,{space:3,children:[n(d,{size:1,weight:"semibold",children:"An error occured"}),n(d,{muted:!0,size:1,children:i})]}),t,o&&f?r(u,{space:2,children:[v,g]}):o?n(p,{children:v}):f?n(p,{children:g}):null]})})})})}function Pt(){const e=C(ce);if(!e)throw new Error("Presentation context is missing");return e}function Et(e){const t=["comment","inspect","instruction","pathKey","rev","since","template","view"];return function(e={}){const t=Object.entries(e).map((([e,t])=>`${e}=${t}`)).join("&");return t.length?`?${t}`:""}(Object.entries(e).filter((([e])=>t.includes(e))).reduce(((e,[t,n])=>null==n?e:{...e,[t]:n}),{}))}const kt=O((function(e,t){const{params:r,structureParams:i}=Pt();return n(Q,{...e,ref:t,state:{type:void 0,_searchParams:Object.entries({...i,preview:r.preview})},title:void 0})})),St=O((function(e,t){const{documentId:r,documentType:i,parentRefPath:o,template:a,...s}=e;return n(Q,{...s,ref:t,state:{id:r,type:i,_searchParams:Object.entries({preview:e.previewUrl})},title:void 0})}));function It(e){const{children:t,onStructureParams:r,params:o,previewUrl:a,refs:s}=e,{state:c,resolvePathFromState:l}=Y(),d=V(Object.fromEntries(c._searchParams||[])),u=R((e=>`${l(c)}${Et({...d,...e})}`),[l,d,c]),p=U((()=>({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(Q,{...r,state:{id:t,type:i._type,_searchParams:Object.entries({preview:a})}}):n("div",{...r})},BackLink:kt,ReferenceChildLink:e=>n(St,{...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(te.Provider,{value:p,children:t})}const zt=se(ne)`
height: 100%;

@@ -39,3 +39,3 @@ `,Ct=se(s)`

${({$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 "}
`,Mt=function({id:e,order:t,disabled:i=!1}){const o=T(null),a=C(Dt);if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const s=function(e){return T(e||Ke()).current}(e),{activeResizer:c,drag:l,startDragging:d,stopDragging:u,registerElement:p,unregisterElement:h}=a,f=c===s;if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const m=R((e=>{d(s,e.nativeEvent)}),[s,d]),v=R((e=>{l(s,e)}),[s,l]),g=R((()=>{o.current.blur(),u()}),[u]);return j((()=>{if(f&&!i)return window.addEventListener("mousemove",v),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",g)}}),[i,f,v,g]),D((()=>(p(s,{id:s,order:t,type:"resizer",el:o}),()=>{h(s)})),[s,t,p,h]),n(_t,{onMouseDown:m,ref:o,children:r(Wt,{$disabled:i,children:[n("span",{}),n("span",{})]})})};function Nt(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,r)}),t)}}const Ft="presentation/panels",Vt=()=>JSON.parse(localStorage.getItem(Ft)||"{}"),Bt=e=>e.map((e=>[e.id,e.order].join(":"))).join(",");function Kt(){return U((()=>{const e=(e,t)=>{const n=Vt(),r=Bt(e);(e=>{localStorage.setItem(Ft,JSON.stringify(e))})({...n,[r]:t})};return{get:e=>Vt()[Bt(e)],set:e,setDebounced:Nt(e,100)}}),[])}function qt(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 Gt(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 Jt(e,t,n=0,r=null){return e.clientX-(r||t.getBoundingClientRect()).left-n}function Ht(e){return"panel"===e.type}function Xt(e){return"resizer"===e.type}function Zt(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=qt(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 Yt=se.div`
`,Mt=function({id:e,order:t,disabled:i=!1}){const o=T(null),a=C(Dt);if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const s=function(e){return T(e||Ke()).current}(e),{activeResizer:c,drag:l,startDragging:d,stopDragging:u,registerElement:p,unregisterElement:h}=a,f=c===s;if(null===a)throw Error("Panel components must be rendered within a PanelGroup container");const m=R((e=>{d(s,e.nativeEvent)}),[s,d]),v=R((e=>{l(s,e)}),[s,l]),g=R((()=>{o.current.blur(),u()}),[u]);return j((()=>{if(f&&!i)return window.addEventListener("mousemove",v),window.addEventListener("mouseup",g),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",g)}}),[i,f,v,g]),D((()=>(p(s,{id:s,order:t,type:"resizer",el:o}),()=>{h(s)})),[s,t,p,h]),n(_t,{onMouseDown:m,ref:o,children:r(Wt,{$disabled:i,children:[n("span",{}),n("span",{})]})})};function Nt(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout((()=>{e.apply(e,r)}),t)}}const Ft="presentation/panels",Vt=()=>JSON.parse(localStorage.getItem(Ft)||"{}"),Bt=e=>e.map((e=>[e.id,e.order].join(":"))).join(",");function Kt(){return U((()=>{const e=(e,t)=>{const n=Vt(),r=Bt(e);(e=>{localStorage.setItem(Ft,JSON.stringify(e))})({...n,[r]:t})};return{get:e=>Vt()[Bt(e)],set:e,setDebounced:Nt(e,100)}}),[])}function qt(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 Gt(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 Jt(e,t,n=0,r=null){return e.clientX-(r||t.getBoundingClientRect()).left-n}function Xt(e){return"panel"===e.type}function Ht(e){return"resizer"===e.type}function Zt(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=qt(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 Yt=se.div`
display: flex;

@@ -46,3 +46,3 @@ flex-direction: row;

width: 100%;
`,en=function({children:e}){const t=T(null),[r,i]=$(new Map),o=U((()=>Zt(r).filter(Ht)),[r]),[a,s]=$([]),[c,l]=$(null),d=T({elements:r,panels:o,widths:a}),u=R((e=>({flexGrow:Gt(o,e,a),pointerEvents:null===c?void 0:"none"})),[c,o,a]),p=R(((e,t)=>{i((n=>{if(n.has(e))return n;const r=new Map(n);return r.set(e,t),r}))}),[]),h=R((e=>{i((t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}))}),[]),f=T({containerWidth:window.innerWidth,dragOffset:0,panelAfter:null,panelBefore:null,resizerIndex:-1,resizerRect:null,startX:0,widths:[]}),m=R(((e,t)=>{const n=Zt(r),i=n.findIndex((t=>t.id===e)),o=r.get(e);if(!o||!Xt(o))return;const a=o.el.current;a&&(f.current={resizerIndex:i,panelBefore:n.reduce(((e,t,n)=>Ht(t)&&n<i?t:e),null),panelAfter:n.reduce(((e,t,n)=>null===e&&Ht(t)&&n>i?t:e),null),containerWidth:window.innerWidth,startX:t.pageX,dragOffset:Jt(t,a),resizerRect:a.getBoundingClientRect(),widths:d.current.widths},l(e))}),[r]),v=R((()=>{l(null)}),[]),g=R(((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||!Xt(u))return;const p=u.el.current;if(!p)return;const h=Jt(n,p,o,l);if(0===h)return;const{widths:m}=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=qt(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=qt(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,f.current);m.some(((e,t)=>e!==v[t]))&&s(v)}),[r]);D((()=>{d.current.elements=r,d.current.panels=o,d.current.widths=a}),[r,o,a]);const y=Kt();D((()=>{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]),j((()=>{a.length&&y.setDebounced(o,a)}),[y,o,a]),D((()=>{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=U((()=>({activeResizer:c,drag:g,getPanelStyle:u,registerElement:p,startDragging:m,stopDragging:v,unregisterElement:h})),[c,g,u,p,m,v,h]);return n(Dt.Provider,{value:w,children:n(Yt,{ref:t,children:e})})},tn=function(e){const{children:t,navigate:r}=e,i=R(((e,t=void 0)=>{r(t||{},e?{preview:e}:{})}),[r]);return n(le.Provider,{value:i,children:t})};function nn(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 j((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,r]}("presentation/navigator",r),s=!!r&&o,c=U((()=>{if(r)return()=>a((e=>!e))}),[r,a]),l=R((function(){return n(i,{children:s&&n(rn,{...t})})}),[s,t]);return[{navigatorEnabled:s,toggleNavigator:c},l]}const rn=A((function(e){const{minWidth:t,maxWidth:o,component:a}=e,s=null!=t&&null!=o&&t===o;return r(i,{children:[n(At,{id:"navigator",minWidth:t,maxWidth:o,order:1,children:n(a,{})}),n(Mt,{order:2,disabled:s})]})})),on=function(e){const{children:t,params:r}=e,i=U((()=>r),[r]);return n(de.Provider,{value:i,children:t})},an=function(e){const{children:t,devMode:r,name:i,navigate:o,params:a,structureParams:s}=e,c=U((()=>({devMode:r,name:i,navigate:o,params:a,structureParams:s})),[r,i,o,a,s]);return n(ce.Provider,{value:c,children:t})},sn="ACTION_IFRAME_LOADED",cn="ACTION_IFRAME_REFRESH",ln="ACTION_IFRAME_RELOAD",dn="ACTION_PERSPECTIVE",un="ACTION_VIEWPORT",pn="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",hn=(e,t)=>{switch(t.type){case sn:return"loaded"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"loaded"}};case cn:return"refreshing"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"refreshing"}};case ln:return"reloading"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"reloading"}};case dn:return{...e,perspective:ft(vn,t.perspective)};case un:return{...e,viewport:ft(gn,t.viewport)};case pn:return fn(e,t);default:return e}},fn=(e,t)=>e.visualEditing.overlaysEnabled===t.enabled?e:{...e,visualEditing:{...e.visualEditing,overlaysEnabled:t.enabled}},mn=ht(["loading","loaded","refreshing","reloading"]),vn=ut(ht(["published","previewDrafts"]),"previewDrafts"),gn=ut(ht(["desktop","mobile"]),"desktop"),yn=pt({iframe:pt({status:mn}),perspective:vn,viewport:gn,visualEditing:pt({overlaysEnabled:function e(t,n){const[r,i]=it(t,n);return{type:"boolean",expects:"boolean",async:!1,message:r,pipe:i,_parse(t,n){return"boolean"==typeof t?lt(this,t,n):dt(this,e,t,n)}}}()})}),wn={iframe:{status:"loading"},perspective:"previewDrafts",viewport:"desktop",visualEditing:{overlaysEnabled:!1}};function bn(e){return ft(yn,{...wn,...e})}const xn=je(se.iframe`
`,en=function({children:e}){const t=T(null),[r,i]=$(new Map),o=U((()=>Zt(r).filter(Xt)),[r]),[a,s]=$([]),[c,l]=$(null),d=T({elements:r,panels:o,widths:a}),u=R((e=>({flexGrow:Gt(o,e,a),pointerEvents:null===c?void 0:"none"})),[c,o,a]),p=R(((e,t)=>{i((n=>{if(n.has(e))return n;const r=new Map(n);return r.set(e,t),r}))}),[]),h=R((e=>{i((t=>{if(!t.has(e))return t;const n=new Map(t);return n.delete(e),n}))}),[]),f=T({containerWidth:window.innerWidth,dragOffset:0,panelAfter:null,panelBefore:null,resizerIndex:-1,resizerRect:null,startX:0,widths:[]}),m=R(((e,t)=>{const n=Zt(r),i=n.findIndex((t=>t.id===e)),o=r.get(e);if(!o||!Ht(o))return;const a=o.el.current;a&&(f.current={resizerIndex:i,panelBefore:n.reduce(((e,t,n)=>Xt(t)&&n<i?t:e),null),panelAfter:n.reduce(((e,t,n)=>null===e&&Xt(t)&&n>i?t:e),null),containerWidth:window.innerWidth,startX:t.pageX,dragOffset:Jt(t,a),resizerRect:a.getBoundingClientRect(),widths:d.current.widths},l(e))}),[r]),v=R((()=>{l(null)}),[]),g=R(((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||!Ht(u))return;const p=u.el.current;if(!p)return;const h=Jt(n,p,o,l);if(0===h)return;const{widths:m}=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=qt(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=qt(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,f.current);m.some(((e,t)=>e!==v[t]))&&s(v)}),[r]);D((()=>{d.current.elements=r,d.current.panels=o,d.current.widths=a}),[r,o,a]);const y=Kt();D((()=>{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]),j((()=>{a.length&&y.setDebounced(o,a)}),[y,o,a]),D((()=>{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=U((()=>({activeResizer:c,drag:g,getPanelStyle:u,registerElement:p,startDragging:m,stopDragging:v,unregisterElement:h})),[c,g,u,p,m,v,h]);return n(Dt.Provider,{value:w,children:n(Yt,{ref:t,children:e})})},tn=function(e){const{children:t,navigate:r}=e,i=R(((e,t=void 0)=>{r(t||{},e?{preview:e}:{})}),[r]);return n(le.Provider,{value:i,children:t})};function nn(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 j((()=>{localStorage.setItem(e,JSON.stringify(n))}),[e,n]),[n,r]}("presentation/navigator",r),s=!!r&&o,c=U((()=>{if(r)return()=>a((e=>!e))}),[r,a]),l=R((function(){return n(i,{children:s&&n(rn,{...t})})}),[s,t]);return[{navigatorEnabled:s,toggleNavigator:c},l]}const rn=A((function(e){const{minWidth:t,maxWidth:o,component:a}=e,s=null!=t&&null!=o&&t===o;return r(i,{children:[n(At,{id:"navigator",minWidth:t,maxWidth:o,order:1,children:n(a,{})}),n(Mt,{order:2,disabled:s})]})})),on=function(e){const{children:t,params:r}=e,i=U((()=>r),[r]);return n(de.Provider,{value:i,children:t})},an=function(e){const{children:t,devMode:r,name:i,navigate:o,params:a,structureParams:s}=e,c=U((()=>({devMode:r,name:i,navigate:o,params:a,structureParams:s})),[r,i,o,a,s]);return n(ce.Provider,{value:c,children:t})},sn="ACTION_IFRAME_LOADED",cn="ACTION_IFRAME_REFRESH",ln="ACTION_IFRAME_RELOAD",dn="ACTION_PERSPECTIVE",un="ACTION_VIEWPORT",pn="ACTION_VISUAL_EDITING_OVERLAYS_TOGGLE",hn=(e,t)=>{switch(t.type){case sn:return"loaded"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"loaded"}};case cn:return"refreshing"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"refreshing"}};case ln:return"reloading"===e.iframe.status?e:{...e,iframe:{...e.iframe,status:"reloading"}};case dn:return{...e,perspective:ft(vn,t.perspective)};case un:return{...e,viewport:ft(gn,t.viewport)};case pn:return fn(e,t);default:return e}},fn=(e,t)=>e.visualEditing.overlaysEnabled===t.enabled?e:{...e,visualEditing:{...e.visualEditing,overlaysEnabled:t.enabled}},mn=ht(["loading","loaded","refreshing","reloading"]),vn=ut(ht(["published","previewDrafts"]),"previewDrafts"),gn=ut(ht(["desktop","mobile"]),"desktop"),yn=pt({iframe:pt({status:mn}),perspective:vn,viewport:gn,visualEditing:pt({overlaysEnabled:function e(t,n){const[r,i]=it(t,n);return{type:"boolean",expects:"boolean",async:!1,message:r,pipe:i,_parse(t,n){return"boolean"==typeof t?lt(this,t,n):dt(this,e,t,n)}}}()})}),wn={iframe:{status:"loading"},perspective:"previewDrafts",viewport:"desktop",visualEditing:{overlaysEnabled:!1}};function bn(e){return ft(yn,{...wn,...e})}const xn=je(se.iframe`
border: 0;

@@ -52,28 +52,4 @@ max-height: 100%;

display: block;
`),Pn=function(e){var t;const{basePath:r="/"}=(null==(t=K())?void 0:t.activeWorkspace)||{},{fontSize:o=1,onChange:a,origin:s,padding:c=3,value:l}=e,d=T(null),[u,p]=$(void 0),[h,f]=$(void 0),m=R((e=>{p(e.currentTarget.value)}),[]),v=R((e=>{var t;if("Enter"===e.key){if(void 0===u)return;const e=u.startsWith("/")||""===u?`${s}${u}`:u;if(!e.startsWith(s+"/")&&e!==s)return void f(`URL must start with ${s}`);if(!s&&(e.startsWith(`${r}/`)||e===r))return void f(`URL can't have the same base path as the Studio ${r}`);const n=e===s?s+"/":e;f(void 0),p(void 0),a(n.slice(s.length)),null==(t=d.current)||t.blur()}"Escape"===e.key&&(f(void 0),p(void 0))}),[r,a,s,u]),y=R((()=>{f(void 0),p(void 0)}),[]);j((()=>{f(void 0),p(void 0)}),[s,l]);const w=U((()=>({icon:ye})),[]);return n(i,{children:n(g,{clearButton:h?w:void 0,customValidity:h,fontSize:o,onBlur:y,onClear:()=>{f(void 0),p(s+l)},onChange:m,onKeyDownCapture:v,padding:c,style:{zIndex:1},radius:2,ref:d,space:c,value:void 0===u?`${s}${l}`:u})})};function En(e){const{initialUrl:t,openPopup:o,previewLocationOrigin:a,previewLocationRoute:s}=e,c=R((e=>{e.preventDefault(),o(e.currentTarget.href)}),[o]);return r(i,{children:[n(kn,{initialUrl:t,previewLocationOrigin:a,previewLocationRoute:s}),n(y,{icon:we,text:"Open preview",as:"a",href:`${a}${s}`,onClick:c,rel:"opener",target:"_blank"})]})}function kn(e){const{initialUrl:t,previewLocationOrigin:r,previewLocationRoute:i}=e,{push:o}=w(),a=q({apiVersion:ue}),s=G(),[c,l]=$(!1);return n(y,{disabled:c,onClick:()=>{if(null==navigator||!navigator.clipboard)return o({closable:!0,status:"error",title:"Clipboard not supported"}),!1;l(!0);let e,n=`${r}${i}`;const c=()=>{o({id:e,closable:!0,status:"success",title:"The URL is copied to the clipboard"}),l(!1)},d=e=>{o({closable:!0,status:"error",title:"Copy failed",description:e.message||e.toString()}),l(!1)};if(Re(t)&&typeof ClipboardItem<"u"){const r="text/plain",l=async()=>{e=o({closable:!0,title:"Copying URL to clipboard…"});const c=await Te(a,"@sanity/presentation",typeof window>"u"?"":location.href,null==s?void 0:s.id);return n=Ue(t,c.secret,i).toString(),new Blob([n],{type:r})},u=new ClipboardItem({[r]:l()});navigator.clipboard.write([u]).then(c).catch(d)}else navigator.clipboard.writeText(n).then(c).catch(d)},text:"Copy link",icon:be})}const Sn=je(s),In=se(b)`
& > span {
width: 21px;
height: 13px;
overflow: hidden;
& > span:nth-child(1) {
width: 21px;
height: 13px;
}
& > span:nth-child(2) {
width: 9px;
height: 9px;
top: 2px;
left: 2px;
}
}
& input:checked + span {
& > span:nth-child(2) {
transform: translate3d(8px, 0, 0) !important;
}
}
`,zn={previewDrafts:"Drafts",published:"Published"},Cn="caution",On="positive",Rn={previewDrafts:Ce,published:Oe},Un=O((function(e,t){const{dispatch:o,iframe:c,initialUrl:u,loadersConnection:v,navigatorEnabled:g,onPathChange:w,onRefresh:b,openPopup:z,overlaysConnection:C,params:O,perspective:L,targetOrigin:D,toggleNavigator:T,toggleOverlay:A,viewport:W,visualEditing:{overlaysEnabled:M}}=e,{devMode:N}=Pt(),F=x(),V=R((()=>o({type:un,viewport:"desktop"})),[o]),B=R((()=>o({type:un,viewport:"mobile"})),[o]),K="loading"===c.status||"reloading"===c.status,[q,G]=$(!1),H="refreshing"===c.status,[X,Z]=$(!1),Q=K||H||"connecting"===C,Y=U((()=>D===location.origin?"":D),[D]),ee=R((()=>{b((()=>{"function"==typeof t||null==t||!t.current||(o({type:ln}),t.current.src=`${D}${O.preview||"/"}`)}))}),[o,b,O.preview,D,t]),te=R((()=>{"function"==typeof t||null==t||!t.current||(t.current.src=u.toString(),o({type:ln}))}),[o,t,u]),ne=R((()=>{ie(!0)}),[]),[re,ie]=$(!1),[oe,ae]=$(!1);j((()=>{if(!(K||H||"connecting"!==C&&"reconnecting"!==C)){const e=setTimeout((()=>{ae(!0)}),1e3);return()=>clearTimeout(e)}}),[C,K,H]),j((()=>{if(!K&&!H&&oe){if("connected"===C&&(Z(!1),ae(!1),G(!1),ie(!1)),"connecting"===C){const e=setTimeout((()=>{G(!0),console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly")}),pe);return()=>clearTimeout(e)}if("reconnecting"===C){const e=setTimeout((()=>{G(!0),Z(!0)}),pe);return()=>clearTimeout(e)}"disconnected"===C&&Z(!0)}}),[K,C,H,oe]);const se=U((()=>{const e=new URL(O.preview||"/",D),{pathname:t,search:n}=$e(e);return`${t}${n}`}),[O.preview,D]),ce=R((()=>{o({type:sn})}),[o]);return j((()=>{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(Le,{transition:F?{duration:0}:void 0,children:r(P,{delay:1e3,children:[n(a,{flex:"none",padding:2,shadow:1,style:{position:"relative"},children:r(s,{align:"center",gap:2,style:{minHeight:0},children:[T&&n(E,{animate:!0,content:n(d,{size:1,children:"Toggle navigator"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Toggle navigator",fontSize:1,icon:xe,mode:"bleed",onClick:T,padding:3,selected:g})}),n(E,{animate:!0,content:r(s,{align:"center",style:{whiteSpace:"nowrap"},children:[n(p,{padding:1,children:n(d,{size:1,children:M?"Disable edit overlay":"Enable edit overlay"})}),n(p,{paddingY:1,children:n(J,{keys:["Alt"],style:{marginTop:-4,marginBottom:-4}})})]}),fallbackPlacements:["bottom-start"],padding:1,placement:"bottom",portal:!0,children:n(a,{as:"label",flex:"none",padding:3,style:{lineHeight:0,borderRadius:999,userSelect:"none"},tone:M?"positive":void 0,children:r(s,{align:"center",gap:2,children:[n("div",{style:{margin:-2},children:n(In,{checked:M,onChange:A,disabled:"loading"===c.status||"connected"!==C})}),n(p,{children:n(d,{muted:!0,size:1,weight:"medium",children:"Edit"})})]})})}),n(E,{animate:!0,content:n(d,{size:1,children:"loading"===c.status?"Loading…":"reloading"===c.status||"refreshing"===c.status?"Refreshing…":"Refresh preview"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Refresh preview",fontSize:1,icon:Pe,mode:"bleed",loading:"reloading"===c.status||"refreshing"===c.status,onClick:ee,padding:3})}),n(p,{flex:1,children:n(Pn,{onChange:w,origin:Y,value:se})}),n(s,{align:"center",flex:"none",gap:1,children:n(k,{button:n(h,{fontSize:1,iconRight:Ee,mode:"bleed",padding:3,space:2}),id:"location-menu",menu:n(S,{children:n(En,{initialUrl:u,openPopup:z,previewLocationOrigin:Y,previewLocationRoute:se})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),n(s,{align:"center",flex:"none",gap:1,children:n(k,{button:n(h,{fontSize:1,iconRight:ke,mode:"bleed",padding:3,space:2,text:zn["connected"===v?L:"previewDrafts"],loading:"reconnecting"===v&&"loaded"!==c.status,disabled:"connected"!==v}),id:"perspective-menu",menu:r(S,{style:{maxWidth:240},children:[n(y,{fontSize:1,onClick:()=>o({type:dn,perspective:"previewDrafts"}),padding:3,pressed:"previewDrafts"===L,tone:Cn,children:r(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:_(Rn.previewDrafts)})}),r(l,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:zn.previewDrafts}),n(d,{muted:!0,size:1,children:"View this page with latest draft content"})]}),n(p,{flex:"none",children:n(d,{muted:!0,size:1,style:{opacity:"previewDrafts"===L?1:0},children:n(Se,{})})})]})}),n(y,{fontSize:1,onClick:()=>o({type:dn,perspective:"published"}),padding:3,pressed:"published"===L,tone:On,children:r(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:_(Rn.published)})}),r(l,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:zn.published}),n(d,{muted:!0,size:1,children:"View this page with published content"})]}),n(p,{flex:"none",children:n(d,{muted:!0,size:1,style:{opacity:"published"===L?1:0},children:n(Se,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),r(s,{align:"center",flex:"none",gap:1,children:[n(E,{animate:!0,content:n(d,{size:1,children:"Full viewport"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Full viewport",fontSize:1,icon:Ie,mode:"bleed",onClick:V,padding:3,selected:"desktop"===W})}),n(E,{animate:!0,content:n(d,{size:1,children:"Narrow viewport"}),padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Narrow viewport",fontSize:1,icon:ze,mode:"bleed",onClick:B,padding:3,selected:"mobile"===W})})]})]})}),n(a,{flex:1,tone:"transparent",children:r(s,{align:"center",height:"fill",justify:"center",padding:"desktop"===W?0:2,sizing:"border",style:{position:"relative",cursor:Q?"wait":void 0},children:[n(De,{children:X||K||H||!oe||re?(K||"connecting"===C&&"refreshing"!==c.status)&&!re?n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:jn,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:r(s,{style:{...$n[W]},justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(d,{muted:!0,size:1,children:"Loading…"})]})}):X&&!re?n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:Ln,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:"Could not connect to the preview",onRetry:te,onContinueAnyway:ne,children:N&&r(i,{children:["connected"!==C&&n(a,{padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Overlay connection status"}),n(f,{size:1,children:C})]})}),"connected"!==v&&n(a,{padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Loader connection status"}),n(f,{size:1,children:v})]})})]})})}):null:n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:jn,justify:"center",align:"center",style:{inset:"0",position:"absolute",backdropFilter:q?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",transition:"backdrop-filter 0.2s ease-in-out",WebkitBackdropFilter:q?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",WebkitTransition:"-webkit-backdrop-filter 0.2s ease-in-out",zIndex:1},children:r(s,{style:{...$n[W]},justify:"center",align:"center",direction:"column",gap:4,children:[q&&n(h,{disabled:!0,fontSize:1,mode:"ghost",text:"Continue anyway",style:{opacity:0}}),n(a,{radius:2,tone:q?"caution":"inherit",padding:4,shadow:1,children:r(s,{justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(d,{muted:!0,size:1,children:q?n(i,{children:"Unable to connect, check the browser console for more information."}):"Connecting…"})]})}),q&&n(h,{fontSize:1,tone:"critical",onClick:ne,text:"Continue anyway"})]})})}),n(xn,{ref:t,style:{pointerEvents:(K||"connecting"===C&&"refreshing"!==c.status)&&!re?"none":"auto",boxShadow:"0 0 0 1px var(--card-border-color)",borderTop:"1px solid transparent"},src:u.toString(),initial:["background"],variants:Dn,animate:[(K||"connecting"===C&&"refreshing"!==c.status)&&!re?"background":"active",K?"reloading":"idle",W,oe&&!re?"timedOut":""],onLoad:ce})]})})]})})})),$n={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},jn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Ln={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Dn={desktop:{...$n.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...$n.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 Tn=!1;function An(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 _n(e){if(void 0!==e)return o.toString(function(e){const t=[];for(const n of e.split(".")){const e=mt.exec(n);if(e){t.push(e[1],Number(e[2]));continue}const r=vt.exec(n);if(r){t.push(r[1],[Number(r[2]),Number(r[3])]);continue}const i=gt.exec(n);i?t.push(i[1],{_key:i[2]}):t.push(n)}return t}(decodeURIComponent(e)))}function Wn(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function Mn({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:r,frameStateRef:i}){const o=U((()=>{const{id:t,path:i,type:o}={id:An((a=n).id),path:_n(a.path),type:a.type};var a;return{id:t,type:o,path:i,preview:r.preview||`${e.pathname}${e.search}`,perspective:r.perspective,viewport:r.viewport,inspect:r.inspect,rev:r.rev,since:r.since,template:r.template,templateParams:r.templateParams,view:r.view,pathKey:r.pathKey,instruction:r.instruction,comment:r.comment}}),[n,r,e]),a=U((()=>Wn({inspect:o.inspect,path:o.path,rev:o.rev,since:o.since,template:o.template,templateParams:o.templateParams,view:o.view,pathKey:o.pathKey,instruction:o.instruction,comment:o.comment})),[o.comment,o.inspect,o.instruction,o.path,o.pathKey,o.rev,o.since,o.template,o.templateParams,o.view]),s=T(n);j((()=>{s.current=n}),[n]);return{structureParams:a,navigate:U((()=>Nt(((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=Wn({...a,...e}),d=Wn({...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})}),50)),[t,i]),params:o}}function Nn(e,t,n){var r,i;const o=q({apiVersion:ue}),a=K(),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){const r=G();return U((()=>["@sanity/presentation",t,n,e,null==r?void 0:r.id,Fn]),[t,null==r?void 0:r.id,e,n])}(t,s,c),d=function(e,t){const n=q({apiVersion:ue}),r=G(),[i,o]=$(""),a=e?We((async()=>await Te(n,"@sanity/presentation",typeof window>"u"?"":location.href,null==r?void 0:r.id)),[...t,i]):null;return j((()=>{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 We((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?_e(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 Fn=Symbol();const Vn=F((()=>import("./LoaderQueries.js"))),Bn=F((()=>import("./PostMessageRefreshMutations.js"))),Kn=se(s)`
`),Pn=function(e){var t;const{basePath:r="/"}=(null==(t=K())?void 0:t.activeWorkspace)||{},{fontSize:o=1,onChange:a,origin:s,padding:c=3,prefix:l,suffix:d,value:u}=e,p=T(null),[h,f]=$(void 0),[m,v]=$(void 0),y=R((e=>{f(e.currentTarget.value)}),[]),w=R((e=>{var t;if("Enter"===e.key){if(void 0===h)return;const e=h.startsWith("/")||""===h?`${s}${h}`:h;if(!e.startsWith(s+"/")&&e!==s)return void v(`URL must start with ${s}`);if(!s&&(e.startsWith(`${r}/`)||e===r))return void v(`URL can't have the same base path as the Studio ${r}`);const n=e===s?s+"/":e;v(void 0),f(void 0),a(n.slice(s.length)),null==(t=p.current)||t.blur()}"Escape"===e.key&&(v(void 0),f(void 0))}),[r,a,s,h]),b=R((()=>{v(void 0),f(void 0)}),[]);j((()=>{v(void 0),f(void 0)}),[s,u]);const x=U((()=>({icon:ye})),[]);return n(i,{children:n(g,{clearButton:m?x:void 0,customValidity:m,fontSize:o,onBlur:b,onClear:()=>{v(void 0),f(s+u)},onChange:y,onKeyDownCapture:w,padding:c,prefix:l,style:{zIndex:1},radius:2,ref:p,space:c,suffix:d,value:void 0===h?`${s}${u}`:h})})};function En(e){const{initialUrl:t,openPopup:o,previewLocationOrigin:a,previewLocationRoute:s}=e,c=R((e=>{e.preventDefault(),o(e.currentTarget.href)}),[o]);return r(i,{children:[n(kn,{initialUrl:t,previewLocationOrigin:a,previewLocationRoute:s}),n(y,{icon:we,text:"Open preview",as:"a",href:`${a}${s}`,onClick:c,rel:"opener",target:"_blank"})]})}function kn(e){const{initialUrl:t,previewLocationOrigin:r,previewLocationRoute:i}=e,{push:o}=w(),a=q({apiVersion:ue}),s=G(),[c,l]=$(!1);return n(y,{disabled:c,onClick:()=>{if(null==navigator||!navigator.clipboard)return o({closable:!0,status:"error",title:"Clipboard not supported"}),!1;l(!0);let e,n=`${r}${i}`;const c=()=>{o({id:e,closable:!0,status:"success",title:"The URL is copied to the clipboard"}),l(!1)},d=e=>{o({closable:!0,status:"error",title:"Copy failed",description:e.message||e.toString()}),l(!1)};if(Re(t)&&typeof ClipboardItem<"u"){const r="text/plain",l=async()=>{e=o({closable:!0,title:"Copying URL to clipboard…"});const c=await Te(a,"@sanity/presentation",typeof window>"u"?"":location.href,null==s?void 0:s.id);return n=Ue(t,c.secret,i).toString(),new Blob([n],{type:r})},u=new ClipboardItem({[r]:l()});navigator.clipboard.write([u]).then(c).catch(d)}else navigator.clipboard.writeText(n).then(c).catch(d)},text:"Copy link",icon:be})}const Sn=je(s),In={previewDrafts:"Drafts",published:"Published"},zn="caution",Cn="positive",On={previewDrafts:Ce,published:Oe},Rn=O((function(e,t){const{dispatch:o,iframe:c,initialUrl:u,loadersConnection:v,navigatorEnabled:g,onPathChange:w,onRefresh:z,openPopup:C,overlaysConnection:O,params:L,perspective:D,targetOrigin:T,toggleNavigator:A,toggleOverlay:W,viewport:M,visualEditing:{overlaysEnabled:N}}=e,{devMode:F}=Pt(),V=b(),B=R((()=>o({type:un,viewport:"desktop"})),[o]),K=R((()=>o({type:un,viewport:"mobile"})),[o]),q="loading"===c.status||"reloading"===c.status,[G,X]=$(!1),H="refreshing"===c.status,[Z,Q]=$(!1),Y=q||H||"connecting"===O,ee=U((()=>T===location.origin?"":T),[T]),te=R((()=>{z((()=>{"function"==typeof t||null==t||!t.current||(o({type:ln}),t.current.src=`${T}${L.preview||"/"}`)}))}),[o,z,L.preview,T,t]),ne=R((()=>{"function"==typeof t||null==t||!t.current||(t.current.src=u.toString(),o({type:ln}))}),[o,t,u]),re=R((()=>{oe(!0)}),[]),[ie,oe]=$(!1),[ae,se]=$(!1);j((()=>{if(!(q||H||"connecting"!==O&&"reconnecting"!==O)){const e=setTimeout((()=>{se(!0)}),1e3);return()=>clearTimeout(e)}}),[O,q,H]),j((()=>{if(!q&&!H&&ae){if("connected"===O&&(Q(!1),se(!1),X(!1),oe(!1)),"connecting"===O){const e=setTimeout((()=>{X(!0),console.error("Unable to connect to visual editing. Make sure you've setup '@sanity/visual-editing' correctly")}),pe);return()=>clearTimeout(e)}if("reconnecting"===O){const e=setTimeout((()=>{X(!0),Q(!0)}),pe);return()=>clearTimeout(e)}"disconnected"===O&&Q(!0)}}),[q,O,H,ae]);const ce=U((()=>{const e=new URL(L.preview||"/",T),{pathname:t,search:n}=$e(e);return`${t}${n}`}),[L.preview,T]),le=R((()=>{o({type:sn})}),[o]);return j((()=>{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(Le,{transition:V?{duration:0}:void 0,children:r(x,{delay:1e3,children:[n(a,{flex:"none",padding:2,shadow:1,style:{position:"relative"},children:r(s,{align:"center",style:{minHeight:0},children:[A&&n(p,{flex:"none",marginRight:1,padding:1,children:n(P,{animate:!0,content:n(d,{size:1,children:"Toggle navigator"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Toggle navigator",fontSize:1,icon:xe,mode:"bleed",onClick:A,padding:2,selected:g})})}),n(P,{animate:!0,content:r(s,{align:"center",style:{whiteSpace:"nowrap"},children:[n(p,{padding:1,children:n(d,{size:1,children:N?"Disable edit overlay":"Enable edit overlay"})}),n(p,{paddingY:1,children:n(J,{keys:["Alt"],style:{marginTop:-4,marginBottom:-4}})})]}),fallbackPlacements:["bottom-start"],padding:1,placement:"bottom",portal:!0,children:n(a,{as:"label",flex:"none",marginRight:1,padding:3,style:{lineHeight:0,borderRadius:999,userSelect:"none"},tone:N?"transparent":void 0,children:r(s,{align:"center",gap:3,children:[n("div",{style:{margin:-4},children:n(E,{checked:N,onChange:W,disabled:"loading"===c.status||"connected"!==O})}),n(p,{children:n(d,{muted:!N,size:1,weight:"medium",children:"Edit"})})]})})}),n(p,{flex:1,marginX:1,children:n(Pn,{prefix:n(p,{padding:1,children:n(P,{animate:!0,content:n(d,{size:1,children:"loading"===c.status?"Loading…":"reloading"===c.status||"refreshing"===c.status?"Refreshing…":"Refresh preview"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Refresh preview",fontSize:1,icon:Pe,mode:"bleed",loading:"reloading"===c.status||"refreshing"===c.status,onClick:te,padding:2})})}),onChange:w,origin:ee,suffix:n(p,{padding:1,children:n(k,{button:n(h,{fontSize:1,iconRight:Ee,mode:"bleed",padding:2,space:2}),id:"location-menu",menu:n(S,{children:n(En,{initialUrl:u,openPopup:C,previewLocationOrigin:ee,previewLocationRoute:ce})}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),value:ce})}),n(s,{align:"center",flex:"none",gap:1,padding:1,children:n(k,{button:n(h,{fontSize:1,iconRight:ke,mode:"bleed",padding:2,space:2,text:In["connected"===v?D:"previewDrafts"],loading:"reconnecting"===v&&"loaded"!==c.status,disabled:"connected"!==v}),id:"perspective-menu",menu:r(S,{style:{maxWidth:240},children:[n(y,{fontSize:1,onClick:()=>o({type:dn,perspective:"previewDrafts"}),padding:3,pressed:"previewDrafts"===D,tone:zn,children:r(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:_(On.previewDrafts)})}),r(l,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:In.previewDrafts}),n(d,{muted:!0,size:1,children:"View this page with latest draft content"})]}),n(p,{flex:"none",children:n(d,{muted:!0,size:1,style:{opacity:"previewDrafts"===D?1:0},children:n(Se,{})})})]})}),n(y,{fontSize:1,onClick:()=>o({type:dn,perspective:"published"}),padding:3,pressed:"published"===D,tone:Cn,children:r(s,{align:"flex-start",gap:3,children:[n(p,{flex:"none",children:n(d,{size:1,children:_(On.published)})}),r(l,{flex:1,space:2,children:[n(d,{size:1,weight:"medium",children:In.published}),n(d,{muted:!0,size:1,children:"View this page with published content"})]}),n(p,{flex:"none",children:n(d,{muted:!0,size:1,style:{opacity:"published"===D?1:0},children:n(Se,{})})})]})})]}),popover:{animate:!0,constrainSize:!0,placement:"bottom",portal:!0}})}),r(s,{align:"center",flex:"none",gap:1,padding:1,children:[n(P,{animate:!0,content:n(d,{size:1,children:"Full viewport"}),fallbackPlacements:["bottom-start"],padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Full viewport",fontSize:1,icon:Ie,mode:"bleed",onClick:B,padding:2,selected:"desktop"===M})}),n(P,{animate:!0,content:n(d,{size:1,children:"Narrow viewport"}),padding:2,placement:"bottom",portal:!0,children:n(h,{"aria-label":"Narrow viewport",fontSize:1,icon:ze,mode:"bleed",onClick:K,padding:2,selected:"mobile"===M})})]})]})}),n(a,{flex:1,tone:"transparent",children:r(s,{align:"center",height:"fill",justify:"center",padding:"desktop"===M?0:2,sizing:"border",style:{position:"relative",cursor:Y?"wait":void 0},children:[n(De,{children:Z||q||H||!ae||ie?(q||"connecting"===O&&"refreshing"!==c.status)&&!ie?n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:$n,justify:"center",align:"center",style:{inset:"0",position:"absolute"},children:r(s,{style:{...Un[M]},justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(d,{muted:!0,size:1,children:"Loading…"})]})}):Z&&!ie?n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:jn,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:"Could not connect to the preview",onRetry:ne,onContinueAnyway:re,children:F&&r(i,{children:["connected"!==O&&n(a,{padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Overlay connection status"}),n(f,{size:1,children:O})]})}),"connected"!==v&&n(a,{padding:3,radius:2,tone:"critical",children:r(l,{space:3,children:[n(m,{muted:!0,size:0,children:"Loader connection status"}),n(f,{size:1,children:v})]})})]})})}):null:n(Sn,{initial:"initial",animate:"animate",exit:"exit",variants:$n,justify:"center",align:"center",style:{inset:"0",position:"absolute",backdropFilter:G?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",transition:"backdrop-filter 0.2s ease-in-out",WebkitBackdropFilter:G?"blur(16px) saturate(0.5) grayscale(0.5)":"blur(2px)",WebkitTransition:"-webkit-backdrop-filter 0.2s ease-in-out",zIndex:1},children:r(s,{style:{...Un[M]},justify:"center",align:"center",direction:"column",gap:4,children:[G&&n(h,{disabled:!0,fontSize:1,mode:"ghost",text:"Continue anyway",style:{opacity:0}}),n(a,{radius:2,tone:G?"caution":"inherit",padding:4,shadow:1,children:r(s,{justify:"center",align:"center",direction:"column",gap:4,children:[n(I,{muted:!0}),n(d,{muted:!0,size:1,children:G?n(i,{children:"Unable to connect, check the browser console for more information."}):"Connecting…"})]})}),G&&n(h,{fontSize:1,tone:"critical",onClick:re,text:"Continue anyway"})]})})}),n(xn,{ref:t,style:{pointerEvents:(q||"connecting"===O&&"refreshing"!==c.status)&&!ie?"none":"auto",boxShadow:"0 0 0 1px var(--card-border-color)",borderTop:"1px solid transparent"},src:u.toString(),initial:["background"],variants:Ln,animate:[(q||"connecting"===O&&"refreshing"!==c.status)&&!ie?"background":"active",q?"reloading":"idle",M,ae&&!ie?"timedOut":""],onLoad:le})]})})]})})})),Un={desktop:{width:"100%",height:"100%"},mobile:{width:375,height:650}},$n={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},jn={initial:{opacity:1},animate:{opacity:[0,0,1]},exit:{opacity:[1,0,0]}},Ln={desktop:{...Un.desktop,boxShadow:"0 0 0 0px var(--card-border-color)"},mobile:{...Un.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 Dn=!1;function Tn(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 An(e){if(void 0!==e)return o.toString(function(e){const t=[];for(const n of e.split(".")){const e=mt.exec(n);if(e){t.push(e[1],Number(e[2]));continue}const r=vt.exec(n);if(r){t.push(r[1],[Number(r[2]),Number(r[3])]);continue}const i=gt.exec(n);i?t.push(i[1],{_key:i[2]}):t.push(n)}return t}(decodeURIComponent(e)))}function _n(e){return Object.fromEntries(Object.entries(e).filter((([,e])=>void 0!==e&&""!==e&&null!==e)))}function Wn({initialPreviewUrl:e,routerNavigate:t,routerState:n,routerSearchParams:r,frameStateRef:i}){const o=U((()=>{const{id:t,path:i,type:o}={id:Tn((a=n).id),path:An(a.path),type:a.type};var a;return{id:t,type:o,path:i,preview:r.preview||`${e.pathname}${e.search}`,perspective:r.perspective,viewport:r.viewport,inspect:r.inspect,rev:r.rev,since:r.since,template:r.template,templateParams:r.templateParams,view:r.view,pathKey:r.pathKey,instruction:r.instruction,comment:r.comment}}),[n,r,e]),a=U((()=>_n({inspect:o.inspect,path:o.path,rev:o.rev,since:o.since,template:o.template,templateParams:o.templateParams,view:o.view,pathKey:o.pathKey,instruction:o.instruction,comment:o.comment})),[o.comment,o.inspect,o.instruction,o.path,o.pathKey,o.rev,o.since,o.template,o.templateParams,o.view]),s=T(n);j((()=>{s.current=n}),[n]);return{structureParams:a,navigate:U((()=>Nt(((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=_n({...a,...e}),d=_n({...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})}),50)),[t,i]),params:o}}function Mn(e,t,n){var r,i;const o=q({apiVersion:ue}),a=K(),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){const r=G();return U((()=>["@sanity/presentation",t,n,e,null==r?void 0:r.id,Nn]),[t,null==r?void 0:r.id,e,n])}(t,s,c),d=function(e,t){const n=q({apiVersion:ue}),r=G(),[i,o]=$(""),a=e?We((async()=>await Te(n,"@sanity/presentation",typeof window>"u"?"":location.href,null==r?void 0:r.id)),[...t,i]):null;return j((()=>{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 We((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?_e(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 Nn=Symbol();const Fn=F((()=>import("./LoaderQueries.js"))),Vn=F((()=>import("./PostMessageRefreshMutations.js"))),Bn=se(s)`
overflow-x: auto;
`;function qn(e){var t;const{previewUrl:a,components:c}=null!=(t=e.tool.options)?t:{},l=e.tool.name||ve,{unstable_navigator:d}=c||{},{navigate:u,state:p}=Y(),h=V(Object.fromEntries(p._searchParams||[])),f=Nn(a||"/",l,h.preview||null),[m]=$((()=>{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})),v=U((()=>f.origin),[f.origin]),g=T(null),[y,w]=$(),[b,x]=$({}),P=T({title:void 0,url:void 0}),{navigate:E,params:k,structureParams:S}=Mn({initialPreviewUrl:f,routerNavigate:u,routerState:p,routerSearchParams:h,frameStateRef:P}),[I,C]=M(hn,{perspective:k.perspective,viewport:k.viewport},bn),[O,L]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,r]=$({}),[i,o]=$({}),a=T(""),s=R(((e,n,i=[])=>{const s=i.filter((e=>"_projectId"in e&&e._projectId?(Tn||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Tn=!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 Ae(i,r)?n:{...n,[e]:r}}))}),[t]);return[U((()=>{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]}(I.perspective,P),D=H(),A=X();j((()=>{(I.perspective!==k.perspective||I.viewport!==k.viewport)&&E({},{perspective:"previewDrafts"===I.perspective?void 0:I.perspective,viewport:"desktop"===I.viewport?void 0:I.viewport})}),[k.perspective,I.perspective,E,I.viewport,k.viewport]);const[_,F]=$("connecting"),[B,K]=$("connecting"),[q,G]=$("connecting"),[J]=$((()=>new Set)),Q=R((e=>{const t=window.open(e,"_blank");t&&J.add(t)}),[J]);j((()=>{if(J.size&&y)for(const e of J)e&&"closed"in e&&!e.closed&&y.addSource(e)}),[y,J,J.size]),j((()=>{var e;const t=null==(e=g.current)?void 0:e.contentWindow;if(!t)return;const n=function(e){const{destroy:t,send:n}=Qe(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}=Qe({...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:v,connectTo:[{id:"overlays",heartbeat:!0,onStatusUpdate:F,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;P.current.url!==n&&E({},{preview:n}),P.current={title:e,url:n}}else"visual-editing/meta"===e?P.current.title=t.title:"visual-editing/toggle"===e||"overlay/toggle"===e?C({type:pn,enabled:t.enabled}):"visual-editing/documents"===e?L("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(ye.current):"visual-editing/refreshing"===e&&"mutation"===t.source?C({type:cn}):"visual-editing/refreshed"===e&&C({type:sn});else E({type:t.type,id:t.id,path:t.path})}},{id:"loaders",heartbeat:!0,onStatusUpdate:K,onEvent(e,t){if("loader/documents"===e&&t.projectId===D&&t.dataset===A)L("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===D&&t.dataset===A){if("number"==typeof t.heartbeat&&t.heartbeat<he)throw new Error(`Loader query listen heartbeat interval must be at least ${he}ms`);x((e=>{var n;return{...e,[yt(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:G,onEvent(e,t){"preview-kit/documents"===e&&t.projectId===D&&t.dataset===A&&L("preview-kit",t.perspective,t.documents)}}]});return w(n),()=>{n.destroy(),w(void 0)}}),[A,D,L,E,v]),j((()=>{const e=setInterval((()=>W((()=>x((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 ee=R((e=>{E({path:o.toString(e)},{},!0)}),[E]),te=R((e=>{const t=new URL(e,f.origin),n=t.pathname+t.search;t.origin===f.origin&&n!==k.preview&&E({},{preview:n})}),[f,k,E]),ne=R((e=>{E({},e)}),[E]);j((()=>{null==y||y.send("overlays","presentation/perspective",{perspective:I.perspective})}),[y,I.perspective]),j((()=>{k.id&&k.path?null==y||y.send("overlays","presentation/focus",{id:k.id,path:k.path}):null==y||y.send("overlays","presentation/blur",void 0)}),[y,k.id,k.path]),j((()=>{P.current.url&&k.preview&&P.current.url!==k.preview&&(P.current.url=k.preview,"connected"!==_&&g.current?g.current.src=`${v}${k.preview}`:null==y||y.send("overlays","presentation/navigate",{url:k.preview,type:"replace"}))}),[y,_,v,k.preview]);const re=R((()=>null==y?void 0:y.send("overlays","presentation/toggleOverlay",void 0)),[y]),[ie,oe]=$(null);j((()=>{const e=e=>{bt(e)&&re()},t=e=>{var t;bt(e)&&re(),t=e,["mod","\\"].every((e=>wt[e]?t[wt[e]]:t.key===e.toUpperCase()))&&re()};return window.addEventListener("keydown",t),window.addEventListener("keyup",e),()=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",e)}}),[re]);const[se,ce]=$(null),[{navigatorEnabled:le,toggleNavigator:de},ue]=nn({unstable_navigator:d}),pe=T(k.id);j((()=>{k.rev&&pe.current&&k.id!==pe.current&&E({},{rev:void 0}),pe.current=k.id}));const ye=T(),we=R((e=>{if(C({type:cn}),y)return ye.current=window.setTimeout(e,300),void y.send("overlays","presentation/refresh",{source:"manual",livePreviewEnabled:"connected"===q||"connected"===B});e()}),[y,B,q]),be=Z(),xe=R((({id:e,type:t,path:n})=>{if(P.current.url)return{title:P.current.title||P.current.url,name:"edit",params:{id:e,path:n,type:t,inspect:fe,workspace:be.name,mode:me,preview:k.preview}}}),[k.preview,be.name]);return r(i,{children:[n(an,{devMode:m,name:l,navigate:E,params:k,structureParams:S,children:n(tn,{navigate:E,children:n(on,{params:k,children:n(Kn,{height:"fill",children:r(en,{children:[n(ue,{}),n(At,{id:"preview",minWidth:325,defaultSize:le?50:75,order:3,children:n(s,{direction:"column",flex:1,height:"fill",ref:ce,children:n(z,{element:se,children:n(Un,{dispatch:C,iframe:I.iframe,initialUrl:f,loadersConnection:B,navigatorEnabled:le,onPathChange:te,onRefresh:we,openPopup:Q,overlaysConnection:_,params:k,perspective:I.perspective,ref:g,targetOrigin:v,toggleNavigator:de,toggleOverlay:re,viewport:I.viewport,visualEditing:I.visualEditing})})})}),n(Mt,{order:4}),n(At,{id:"content",minWidth:325,order:5,children:n(ge,{documentId:k.id,setDisplayedDocument:oe,children:n(ae,{getIntent:xe,children:n(Lt,{documentId:k.id,documentType:k.type,onFocusPath:ee,onStructureParams:ne,previewUrl:k.preview,refs:O,structureParams:S})})})})]})})})})}),y&&n(N,{children:n(Vn,{channel:y,liveQueries:b,perspective:I.perspective,liveDocument:ie,documentsOnPage:O})}),y&&k.id&&k.type&&n(N,{children:n(Bn,{channel:y,id:k.id,type:k.type,loadersConnection:B,previewKitConnection:q})})]})}export{qn as default};//# sourceMappingURL=PresentationTool.js.map
`;function Kn(e){var t;const{previewUrl:a,components:c}=null!=(t=e.tool.options)?t:{},l=e.tool.name||ve,{unstable_navigator:d}=c||{},{navigate:u,state:p}=Y(),h=V(Object.fromEntries(p._searchParams||[])),f=Mn(a||"/",l,h.preview||null),[m]=$((()=>{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})),v=U((()=>f.origin),[f.origin]),g=T(null),[y,w]=$(),[b,x]=$({}),P=T({title:void 0,url:void 0}),{navigate:E,params:k,structureParams:S}=Wn({initialPreviewUrl:f,routerNavigate:u,routerState:p,routerSearchParams:h,frameStateRef:P}),[I,C]=M(hn,{perspective:k.perspective,viewport:k.viewport},bn),[O,L]=function(e,t){if("published"!==e&&"previewDrafts"!==e)throw new Error(`Invalid perspective: ${e}`);const[n,r]=$({}),[i,o]=$({}),a=T(""),s=R(((e,n,i=[])=>{const s=i.filter((e=>"_projectId"in e&&e._projectId?(Dn||(console.warn("Cross dataset references are not supported yet, ignoring source document",e),Dn=!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 Ae(i,r)?n:{...n,[e]:r}}))}),[t]);return[U((()=>{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]}(I.perspective,P),D=X(),A=H();j((()=>{(I.perspective!==k.perspective||I.viewport!==k.viewport)&&E({},{perspective:"previewDrafts"===I.perspective?void 0:I.perspective,viewport:"desktop"===I.viewport?void 0:I.viewport})}),[k.perspective,I.perspective,E,I.viewport,k.viewport]);const[_,F]=$("connecting"),[B,K]=$("connecting"),[q,G]=$("connecting"),[J]=$((()=>new Set)),Q=R((e=>{const t=window.open(e,"_blank");t&&J.add(t)}),[J]);j((()=>{if(J.size&&y)for(const e of J)e&&"closed"in e&&!e.closed&&y.addSource(e)}),[y,J,J.size]),j((()=>{var e;const t=null==(e=g.current)?void 0:e.contentWindow;if(!t)return;const n=function(e){const{destroy:t,send:n}=Qe(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}=Qe({...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:v,connectTo:[{id:"overlays",heartbeat:!0,onStatusUpdate:F,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;P.current.url!==n&&E({},{preview:n}),P.current={title:e,url:n}}else"visual-editing/meta"===e?P.current.title=t.title:"visual-editing/toggle"===e||"overlay/toggle"===e?C({type:pn,enabled:t.enabled}):"visual-editing/documents"===e?L("visual-editing",t.perspective,t.documents):"visual-editing/refreshing"===e&&"manual"===t.source?clearTimeout(ye.current):"visual-editing/refreshing"===e&&"mutation"===t.source?C({type:cn}):"visual-editing/refreshed"===e&&C({type:sn});else E({type:t.type,id:t.id,path:t.path})}},{id:"loaders",heartbeat:!0,onStatusUpdate:K,onEvent(e,t){if("loader/documents"===e&&t.projectId===D&&t.dataset===A)L("loaders",t.perspective,t.documents);else if("loader/query-listen"===e&&t.projectId===D&&t.dataset===A){if("number"==typeof t.heartbeat&&t.heartbeat<he)throw new Error(`Loader query listen heartbeat interval must be at least ${he}ms`);x((e=>{var n;return{...e,[yt(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:G,onEvent(e,t){"preview-kit/documents"===e&&t.projectId===D&&t.dataset===A&&L("preview-kit",t.perspective,t.documents)}}]});return w(n),()=>{n.destroy(),w(void 0)}}),[A,D,L,E,v]),j((()=>{const e=setInterval((()=>W((()=>x((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 ee=R((e=>{E({path:o.toString(e)},{},!0)}),[E]),te=R((e=>{const t=new URL(e,f.origin),n=t.pathname+t.search;t.origin===f.origin&&n!==k.preview&&E({},{preview:n})}),[f,k,E]),ne=R((e=>{E({},e)}),[E]);j((()=>{null==y||y.send("overlays","presentation/perspective",{perspective:I.perspective})}),[y,I.perspective]),j((()=>{k.id&&k.path?null==y||y.send("overlays","presentation/focus",{id:k.id,path:k.path}):null==y||y.send("overlays","presentation/blur",void 0)}),[y,k.id,k.path]),j((()=>{P.current.url&&k.preview&&P.current.url!==k.preview&&(P.current.url=k.preview,"connected"!==_&&g.current?g.current.src=`${v}${k.preview}`:null==y||y.send("overlays","presentation/navigate",{url:k.preview,type:"replace"}))}),[y,_,v,k.preview]);const re=R((()=>null==y?void 0:y.send("overlays","presentation/toggleOverlay",void 0)),[y]),[ie,oe]=$(null);j((()=>{const e=e=>{bt(e)&&re()},t=e=>{var t;bt(e)&&re(),t=e,["mod","\\"].every((e=>wt[e]?t[wt[e]]:t.key===e.toUpperCase()))&&re()};return window.addEventListener("keydown",t),window.addEventListener("keyup",e),()=>{window.removeEventListener("keydown",t),window.removeEventListener("keyup",e)}}),[re]);const[se,ce]=$(null),[{navigatorEnabled:le,toggleNavigator:de},ue]=nn({unstable_navigator:d}),pe=T(k.id);j((()=>{k.rev&&pe.current&&k.id!==pe.current&&E({},{rev:void 0}),pe.current=k.id}));const ye=T(),we=R((e=>{if(C({type:cn}),y)return ye.current=window.setTimeout(e,300),void y.send("overlays","presentation/refresh",{source:"manual",livePreviewEnabled:"connected"===q||"connected"===B});e()}),[y,B,q]),be=Z(),xe=R((({id:e,type:t,path:n})=>{if(P.current.url)return{title:P.current.title||P.current.url,name:"edit",params:{id:e,path:n,type:t,inspect:fe,workspace:be.name,mode:me,preview:k.preview}}}),[k.preview,be.name]);return r(i,{children:[n(an,{devMode:m,name:l,navigate:E,params:k,structureParams:S,children:n(tn,{navigate:E,children:n(on,{params:k,children:n(Bn,{height:"fill",children:r(en,{children:[n(ue,{}),n(At,{id:"preview",minWidth:325,defaultSize:le?50:75,order:3,children:n(s,{direction:"column",flex:1,height:"fill",ref:ce,children:n(z,{element:se,children:n(Rn,{dispatch:C,iframe:I.iframe,initialUrl:f,loadersConnection:B,navigatorEnabled:le,onPathChange:te,onRefresh:we,openPopup:Q,overlaysConnection:_,params:k,perspective:I.perspective,ref:g,targetOrigin:v,toggleNavigator:de,toggleOverlay:re,viewport:I.viewport,visualEditing:I.visualEditing})})})}),n(Mt,{order:4}),n(At,{id:"content",minWidth:325,order:5,children:n(ge,{documentId:k.id,setDisplayedDocument:oe,children:n(ae,{getIntent:xe,children:n(Lt,{documentId:k.id,documentType:k.type,onFocusPath:ee,onStructureParams:ne,previewUrl:k.preview,refs:O,structureParams:S})})})})]})})})})}),y&&n(N,{children:n(Fn,{channel:y,liveQueries:b,perspective:I.perspective,liveDocument:ie,documentsOnPage:O})}),y&&k.id&&k.type&&n(N,{children:n(Vn,{channel:y,id:k.id,type:k.type,loadersConnection:B,previewKitConnection:q})})]})}export{Kn as default};//# sourceMappingURL=PresentationTool.js.map

10

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

@@ -94,3 +94,3 @@ "bugs": {

"@sanity/icons": "^2.11.8",
"@sanity/preview-url-secret": "^1.6.10",
"@sanity/preview-url-secret": "^1.6.11",
"@sanity/ui": "^2.1.4",

@@ -109,4 +109,4 @@ "@sanity/uuid": "3.0.2",

"@repo/channels": "0.4.0",
"@repo/visual-editing-helpers": "0.6.7",
"@sanity/client": "^6.15.19",
"@repo/visual-editing-helpers": "0.6.8",
"@sanity/client": "^6.15.20",
"@sanity/pkg-utils": "6.8.1",

@@ -123,3 +123,3 @@ "happy-dom": "^14.7.1",

"peerDependencies": {
"@sanity/client": "^6.15.19"
"@sanity/client": "^6.15.20"
},

@@ -126,0 +126,0 @@ "engines": {

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

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc