PageSourceSearch

https://www.leedsapp.com/_next/static/chunks/433.46fe93cea1c865e0.js

js leedsapp.com collected 2026-10-02 16:03:09 UTC 116,467 bytes, 182 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[433],{433:(e,t,n)=>{let r;n.r(t),n.d(t,{default:()=>oP});var i,o,a,s,u,l,c,d,p=n(95155),f=n(48307),m=n(12115),y=n(47650);let h=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,g=/_key\s*==\s*['"](.*)['"]/,v=/^\d*:\d*$/;function b(e){return"number"==typeof e||"string"==typeof e&&/^\[\d+\]$/.test(e)}function w(e){return"string"==typeof e?g.test(e.trim()):"object"==typeof e&&"_key"in e}function x(e){if("string"==typeof e&&v.test(e))return!0;if(!Array.isArray(e)||2!==e.length)return!1;let[t,n]=e;return("number"==typeof t||""===t)&&("number"==typeof n||""===n)}function E(e){if(!Array.isArray(e))throw Error("Path is not an array");return e.reduce((e,t,n)=>{let r=typeof t;if("number"===r)return`${e}[${t}]`;if("string"===r)return`${e}${0===n?"":"."}${t}`;if(w(t)&&t._key)return`${e}[_key=="${t._key}"]`;if(Array.isArray(t)){let[n,r]=t;return`${e}[${n}:${r}]`}throw Error(`Unsupported path segment \`${JSON.stringify(t)}\``)},"")}function j(e){if("string"!=typeof e)throw Error("Path is not a string");let t=e.match(h);if(!t)throw Error("Invalid path string");return t.map(_)}function _(e){return b(e)?Number(e.replace(/[^\d]/g,"")):w(e)?{_key:e.match(g)[1]}:x(e)?function(e){let[t,n]=e.split(":").map(e=>""===e?e:Number(e));return[t,n]}(e):e}var k=Object.freeze({__proto__:null,fromString:j,get:function(e,t,n){let r="string"==typeof t?j(t):t;if(!Array.isArray(r))throw Error("Path must be an array or a string");let i=e;for(let e=0;e<r.length;e++){let t=r[e];if(b(t)){if(!Array.isArray(i))return n;i=i[t]}if(w(t)){if(!Array.isArray(i))return n;i=i.find(e=>e._key===t._key)}if("string"==typeof t&&(i="object"==typeof i&&null!==i?i[t]:void 0),typeof i>"u")return n}return i},isIndexSegment:b,isIndexTuple:x,isKeySegment:w,reKeySegment:g,toString:E});let I="drafts.";function M(e){return e.startsWith(I)}function $(e){return e.startsWith("versions.")}function S(e){return $(e)?I+C(e):M(e)?e:I+e}function C(e){return $(e)?e.split(".").slice(2).join("."):M(e)?e.slice(I.length):e}var A=n(91611),O=n(65285);function T(e){return e.split(/[[.\]]/g).filter(Boolean).map(e=>e.includes("==")?function(e){let[t,n]=e.split("==");if("_key"!==t)throw Error(`Currently only "_key" is supported as path segment. Found ${t}`);if(typeof n>"u")throw Error('Invalid path segment, expected `key=="value"`');return{_key:n.replace(/^['"]/,"").replace(/['"]$/,"")}}(e):P.test(e)?Number(e):e)}let P=/^-?\d+$/,R=/^[a-z_$]+/;function z(e){return e.map((e,t)=>{var n;return n=0===t,Array.isArray(e)?`[${e[0]}:${e[1]||""}]`:"number"==typeof e?`[${e}]`:"object"==typeof e&&"_key"in e&&"string"==typeof e._key?`[_key==${JSON.stringify(e._key)}]`:"string"==typeof e&&R.test(e)?n?e:`.${e}`:`['${e}']`}).join("")}function L(e){if("createIfNotExists"in e)return{type:"createIfNotExists",document:e.createIfNotExists};if("createOrReplace"in e)return{type:"createOrReplace",document:e.createOrReplace};if("create"in e)return{type:"create",document:e.create};if("delete"in e)return{id:e.delete.id,type:"delete"};if("patch"in e){var t,n;return{type:"patch",id:e.patch.id,patches:[..."set"in(n=t=e.patch)?Object.keys(n.set).map(e=>({path:T(e),op:{type:"set",value:n.set[e]}})):[],..."setIfMissing"in t?Object.keys(t.setIfMissing).map(e=>({path:T(e),op:{type:"setIfMissing",value:t.setIfMissing[e]}})):[],..."unset"in t?t.unset.map(e=>({path:T(e),op:{type:"unset"}})):[],..."inc"in t?Object.keys(t.inc).map(e=>({path:T(e),op:{type:"inc",amount:t.inc[e]}})):[],..."inc"in t?Object.keys(t.dec).map(e=>({path:T(e),op:{type:"dec",amount:t.dec[e]}})):[],...function(e){if(!("insert"in e))return[];let t=function(e){let t=D.filter(t=>t in e);if(t.length>1)throw Error(`Insert patch is ambiguous. Should only contain one of: ${D.join(", ")}, instead found ${t.join(", ")}`);return t[0]}(e.insert);if(!t)throw Error("Insert patch missing position");let n=T(e.insert[t]),r=n.pop();return[{path:n,op:{type:"insert",position:t,referenceItem:r,items:e.insert.items}}]}(t)]}}throw Error(`Unknown mutation: ${JSON.stringify(e)}`)}let D=["before","replace","after"];function N(e){return V(e)}function U(e){return e.flatMap(N)}function V(e){if("create"===e.type||"createIfNotExists"===e.type||"createOrReplace"===e.type)return{[e.type]:e.document};if("delete"===e.type)return{delete:{id:e.id}};let t=e.options?.ifRevision;return e.patches.map(n=>({patch:{id:e.id,...t&&{ifRevisionID:t},...function(e){let{path:t,op:n}=e;if("unset"===n.type)return{unset:[z(t)]};if("insert"===n.type)return{insert:{[n.position]:z([...t,n.referenceItem]),items:n.items}};if("diffMatchPatch"===n.type)return{diffMatchPatch:{[z(t)]:n.value}};if("inc"===n.type)return{inc:{[z(t)]:n.amount}};if("dec"===n.type)return{dec:{[z(t)]:n.amount}};if("set"===n.type||"setIfMissing"===n.type)return{[n.type]:{[z(t)]:n.value}};if("truncate"===n.type){let e=[n.startIndex,"number"==typeof n.endIndex?n.endIndex:""].join(":");return{unset:[`${z(t)}[${e}]`]}}if("upsert"===n.type)return{unset:n.items.map(e=>
1z([...t,{_key:e._key}])),insert:{[n.position]:z([...t,n.referenceItem]),items:n.items}};if("assign"===n.type)return{set:Object.fromEntries(Object.keys(n.value).map(e=>[z(t.concat(e)),n.value[e]]))};if("unassign"===n.type)return{unset:n.keys.map(e=>z(t.concat(e)))};if("replace"===n.type)return{insert:{replace:z(t.concat(n.referenceItem)),items:n.items}};if("remove"===n.type)return{unset:[z(t.concat(n.referenceItem))]};throw Error(`Unknown operation type ${n.type}`)}(n)}}))}function q(e){return Array.isArray(e)?e:[e]}var F=Object.freeze({__proto__:null,decode:function(e){return L(e)},decodeAll:function(e){return e.map(L)},encode:N,encodeAll:U,encodeMutation:V,encodeTransaction:function(e){return{transactionId:e.id,mutations:U(e.mutations)}}});function W(e,t,n){return{type:"insert",referenceItem:n,position:t,items:q(e)}}function Y(e,t){return{type:"truncate",startIndex:e,endIndex:t}}function B(e){return{type:"remove",referenceItem:e}}function G(e,t){return{path:"string"==typeof e?T(e):e,op:t}}var X=n(8691),H=n(33720),J=n(47289),K=n(97752),Z=n(24531),Q="object"==typeof global&&global&&global.Object===Object&&global,ee="object"==typeof self&&self&&self.Object===Object&&self,et=Q||ee||Function("return this")(),en=et.Symbol,er=Object.prototype,ei=er.hasOwnProperty,eo=er.toString,ea=en?en.toStringTag:void 0;let es=function(e){var t=ei.call(e,ea),n=e[ea];try{e[ea]=void 0;var r=!0}catch(e){}var i=eo.call(e);return r&&(t?e[ea]=n:delete e[ea]),i};var eu=Object.prototype.toString,el=en?en.toStringTag:void 0;let ec=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":el&&el in Object(e)?es(e):eu.call(e)},ed=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},ep=function(e){if(!ed(e))return!1;var t=ec(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t};var ef=et["__core-js_shared__"],em=function(){var e=/[^.]+$/.exec(ef&&ef.keys&&ef.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),ey=Function.prototype.toString;let eh=function(e){if(null!=e){try{return ey.call(e)}catch(e){}try{return e+""}catch(e){}}return""};var eg=/^\[object .+?Constructor\]$/,ev=Object.prototype,eb=Function.prototype.toString,ew=ev.hasOwnProperty,ex=RegExp("^"+eb.call(ew).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");let eE=function(e,t){var n,r=null==e?void 0:e[t];return ed(n=r)&&(!em||!(em in n))&&(ep(n)?ex:eg).test(eh(n))?r:void 0};var ej=function(){try{var e=eE(Object,"defineProperty");return e({},"",{}),e}catch(e){}}();let e_=function(e,t,n){"__proto__"==t&&ej?ej(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},ek=function(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i<o;){var a=e[i];t(r,a,n(a),e)}return r},eI=function(e,t,n){for(var r=-1,i=Object(e),o=n(e),a=o.length;a--;){var s=o[++r];if(!1===t(i[s],s,i))break}return e},eM=function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r},e$=function(e){return null!=e&&"object"==typeof e},eS=function(e){return e$(e)&&"[object Arguments]"==ec(e)};var eC=Object.prototype,eA=eC.hasOwnProperty,eO=eC.propertyIsEnumerable,eT=eS(function(){return arguments}())?eS:function(e){return e$(e)&&eA.call(e,"callee")&&!eO.call(e,"callee")},eP=Array.isArray,eR="object"==typeof exports&&exports&&!exports.nodeType&&exports,ez=eR&&"object"==typeof module&&module&&!module.nodeType&&module,eL=ez&&ez.exports===eR?et.Buffer:void 0;let eD=(eL?eL.isBuffer:void 0)||function(){return!1};var eN=/^(?:0|[1-9]\d*)$/;let eU=function(e,t){var n=typeof e;return!!(t=null==t?0x1fffffffffffff:t)&&("number"==n||"symbol"!=n&&eN.test(e))&&e>-1&&e%1==0&&e<t},eV=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=0x1fffffffffffff};var eq={};eq["[object Float32Array]"]=eq["[object Float64Array]"]=eq["[object Int8Array]"]=eq["[object Int16Array]"]=eq["[object Int32Array]"]=eq["[object Uint8Array]"]=eq["[object Uint8ClampedArray]"]=eq["[object Uint16Array]"]=eq["[object Uint32Array]"]=!0,eq["[object Arguments]"]=eq["[object Array]"]=eq["[object ArrayBuffer]"]=eq["[object Boolean]"]=eq["[object DataView]"]=eq["[object Date]"]=eq["[object Error]"]=eq["[object Function]"]=eq["[object Map]"]=eq["[object Number]"]=eq["[object Object]"]=eq["[object RegExp]"]=eq["[object Set]"]=eq["[object String]"]=eq["[object WeakMap]"]=!1;var eF="object"==typeof exports&&exports&&!exports.nodeType&&exports,eW=eF&&"object"==typeof module&&module&&!module.nodeType&&module,eY=eW&&eW.exp
1orts===eF&&Q.process,eB=function(){try{var e=eW&&eW.require&&eW.require("util").types;if(e)return e;return eY&&eY.binding&&eY.binding("util")}catch(e){}}(),eG=eB&&eB.isTypedArray,eX=eG?function(e){return eG(e)}:function(e){return e$(e)&&eV(e.length)&&!!eq[ec(e)]},eH=Object.prototype.hasOwnProperty;let eJ=function(e,t){var n=eP(e),r=!n&&eT(e),i=!n&&!r&&eD(e),o=!n&&!r&&!i&&eX(e),a=n||r||i||o,s=a?eM(e.length,String):[],u=s.length;for(var l in e)(t||eH.call(e,l))&&!(a&&("length"==l||i&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||eU(l,u)))&&s.push(l);return s};var eK=Object.prototype;let eZ=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||eK)};var eQ=(a=Object.keys,s=Object,function(e){return a(s(e))}),e0=Object.prototype.hasOwnProperty;let e1=function(e){if(!eZ(e))return eQ(e);var t=[];for(var n in Object(e))e0.call(e,n)&&"constructor"!=n&&t.push(n);return t},e2=function(e){return null!=e&&eV(e.length)&&!ep(e)},e5=function(e){return e2(e)?eJ(e):e1(e)};var e3=(i=function(e,t){return e&&eI(e,t,e5)},function(e,t){if(null==e)return e;if(!e2(e))return i(e,t);for(var n=e.length,r=-1,o=Object(e);++r<n&&!1!==t(o[r],r,o););return e});let e4=function(e,t){return e===t||e!=e&&t!=t},e9=function(e,t){for(var n=e.length;n--;)if(e4(e[n][0],t))return n;return -1};var e6=Array.prototype.splice;function e8(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}e8.prototype.clear=function(){this.__data__=[],this.size=0},e8.prototype.delete=function(e){var t=this.__data__,n=e9(t,e);return!(n<0)&&(n==t.length-1?t.pop():e6.call(t,n,1),--this.size,!0)},e8.prototype.get=function(e){var t=this.__data__,n=e9(t,e);return n<0?void 0:t[n][1]},e8.prototype.has=function(e){return e9(this.__data__,e)>-1},e8.prototype.set=function(e,t){var n=this.__data__,r=e9(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var e7=eE(et,"Map"),te=eE(Object,"create"),tt=Object.prototype.hasOwnProperty,tn=Object.prototype.hasOwnProperty;function tr(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}tr.prototype.clear=function(){this.__data__=te?te(null):{},this.size=0},tr.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},tr.prototype.get=function(e){var t=this.__data__;if(te){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return tt.call(t,e)?t[e]:void 0},tr.prototype.has=function(e){var t=this.__data__;return te?void 0!==t[e]:tn.call(t,e)},tr.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=te&&void 0===t?"__lodash_hash_undefined__":t,this};let ti=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e},to=function(e,t){var n=e.__data__;return ti(t)?n["string"==typeof t?"string":"hash"]:n.map};function ta(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ts(e){var t=this.__data__=new e8(e);this.size=t.size}function tu(e){var t=-1,n=null==e?0:e.length;for(this.__data__=new ta;++t<n;)this.add(e[t])}ta.prototype.clear=function(){this.size=0,this.__data__={hash:new tr,map:new(e7||e8),string:new tr}},ta.prototype.delete=function(e){var t=to(this,e).delete(e);return this.size-=t?1:0,t},ta.prototype.get=function(e){return to(this,e).get(e)},ta.prototype.has=function(e){return to(this,e).has(e)},ta.prototype.set=function(e,t){var n=to(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},ts.prototype.clear=function(){this.__data__=new e8,this.size=0},ts.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},ts.prototype.get=function(e){return this.__data__.get(e)},ts.prototype.has=function(e){return this.__data__.has(e)},ts.prototype.set=function(e,t){var n=this.__data__;if(n instanceof e8){var r=n.__data__;if(!e7||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new ta(r)}return n.set(e,t),this.size=n.size,this},tu.prototype.add=tu.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},tu.prototype.has=function(e){return this.__data__.has(e)};let tl=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}
1,tc=function(e,t,n,r,i,o){var a=1&n,s=e.length,u=t.length;if(s!=u&&!(a&&u>s))return!1;var l=o.get(e),c=o.get(t);if(l&&c)return l==t&&c==e;var d=-1,p=!0,f=2&n?new tu:void 0;for(o.set(e,t),o.set(t,e);++d<s;){var m=e[d],y=t[d];if(r)var h=a?r(y,m,d,t,e,o):r(m,y,d,e,t,o);if(void 0!==h){if(h)continue;p=!1;break}if(f){if(!tl(t,function(e,t){if(!f.has(t)&&(m===e||i(m,e,n,r,o)))return f.push(t)})){p=!1;break}}else if(!(m===y||i(m,y,n,r,o))){p=!1;break}}return o.delete(e),o.delete(t),p};var td=et.Uint8Array;let tp=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n},tf=function(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n};var tm=en?en.prototype:void 0,ty=tm?tm.valueOf:void 0;let th=function(e,t,n,r,i,o,a){switch(n){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)break;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":if(e.byteLength!=t.byteLength||!o(new td(e),new td(t)))break;return!0;case"[object Boolean]":case"[object Date]":case"[object Number]":return e4(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var s=tp;case"[object Set]":var u=1&r;if(s||(s=tf),e.size!=t.size&&!u)break;var l=a.get(e);if(l)return l==t;r|=2,a.set(e,t);var c=tc(s(e),s(t),r,i,o,a);return a.delete(e),c;case"[object Symbol]":if(ty)return ty.call(e)==ty.call(t)}return!1},tg=function(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e},tv=function(e,t,n){var r=t(e);return eP(e)?r:tg(r,n(e))},tb=function(e,t){for(var n=-1,r=null==e?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o};var tw=Object.prototype.propertyIsEnumerable,tx=Object.getOwnPropertySymbols,tE=tx?function(e){return null==e?[]:tb(tx(e=Object(e)),function(t){return tw.call(e,t)})}:function(){return[]};let tj=function(e){return tv(e,e5,tE)};var t_=Object.prototype.hasOwnProperty;let tk=function(e,t,n,r,i,o){var a=1&n,s=tj(e),u=s.length;if(u!=tj(t).length&&!a)return!1;for(var l=u;l--;){var c=s[l];if(!(a?c in t:t_.call(t,c)))return!1}var d=o.get(e),p=o.get(t);if(d&&p)return d==t&&p==e;var f=!0;o.set(e,t),o.set(t,e);for(var m=a;++l<u;){var y=e[c=s[l]],h=t[c];if(r)var g=a?r(h,y,c,t,e,o):r(y,h,c,e,t,o);if(!(void 0===g?y===h||i(y,h,n,r,o):g)){f=!1;break}m||(m="constructor"==c)}if(f&&!m){var v=e.constructor,b=t.constructor;v!=b&&"constructor"in e&&"constructor"in t&&!("function"==typeof v&&v instanceof v&&"function"==typeof b&&b instanceof b)&&(f=!1)}return o.delete(e),o.delete(t),f};var tI=eE(et,"DataView"),tM=eE(et,"Promise"),t$=eE(et,"Set"),tS=eE(et,"WeakMap"),tC="[object Map]",tA="[object Promise]",tO="[object Set]",tT="[object WeakMap]",tP="[object DataView]",tR=eh(tI),tz=eh(e7),tL=eh(tM),tD=eh(t$),tN=eh(tS),tU=ec;(tI&&tU(new tI(new ArrayBuffer(1)))!=tP||e7&&tU(new e7)!=tC||tM&&tU(tM.resolve())!=tA||t$&&tU(new t$)!=tO||tS&&tU(new tS)!=tT)&&(tU=function(e){var t=ec(e),n="[object Object]"==t?e.constructor:void 0,r=n?eh(n):"";if(r)switch(r){case tR:return tP;case tz:return tC;case tL:return tA;case tD:return tO;case tN:return tT}return t});let tV=tU;var tq="[object Arguments]",tF="[object Array]",tW="[object Object]",tY=Object.prototype.hasOwnProperty;let tB=function(e,t,n,r,i,o){var a=eP(e),s=eP(t),u=a?tF:tV(e),l=s?tF:tV(t);u=u==tq?tW:u,l=l==tq?tW:l;var c=u==tW,d=l==tW,p=u==l;if(p&&eD(e)){if(!eD(t))return!1;a=!0,c=!1}if(p&&!c)return o||(o=new ts),a||eX(e)?tc(e,t,n,r,i,o):th(e,t,u,n,r,i,o);if(!(1&n)){var f=c&&tY.call(e,"__wrapped__"),m=d&&tY.call(t,"__wrapped__");
1if(f||m){var y=f?e.value():e,h=m?t.value():t;return o||(o=new ts),i(y,h,n,r,o)}}return!!p&&(o||(o=new ts),tk(e,t,n,r,i,o))},tG=function e(t,n,r,i,o){return t===n||(null!=t&&null!=n&&(e$(t)||e$(n))?tB(t,n,r,i,e,o):t!=t&&n!=n)},tX=function(e,t,n,r){var i=n.length,o=i,a=!r;if(null==e)return!o;for(e=Object(e);i--;){var s=n[i];if(a&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<o;){var u=(s=n[i])[0],l=e[u],c=s[1];if(a&&s[2]){if(void 0===l&&!(u in e))return!1}else{var d=new ts;if(r)var p=r(l,c,u,e,t,d);if(!(void 0===p?tG(c,l,3,r,d):p))return!1}}return!0},tH=function(e){return e==e&&!ed(e)},tJ=function(e){for(var t=e5(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,tH(i)]}return t},tK=function(e,t){return function(n){return null!=n&&n[e]===t&&(void 0!==t||e in Object(n))}},tZ=function(e){var t=tJ(e);return 1==t.length&&t[0][2]?tK(t[0][0],t[0][1]):function(n){return n===e||tX(n,e,t)}},tQ=function(e){return"symbol"==typeof e||e$(e)&&"[object Symbol]"==ec(e)};var t0=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,t1=/^\w*$/;let t2=function(e,t){if(eP(e))return!1;var n=typeof e;return!!("number"==n||"symbol"==n||"boolean"==n||null==e||tQ(e))||t1.test(e)||!t0.test(e)||null!=t&&e in Object(t)};function t5(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw TypeError("Expected a function");var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(t5.Cache||ta),n}t5.Cache=ta;var t3=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t4=/\\(\\)?/g,t9=function(e){var t=t5(e,function(e){return 500===n.size&&n.clear(),e}),n=t.cache;return t}(function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(t3,function(e,n,r,i){t.push(r?i.replace(t4,"$1"):n||e)}),t});let t6=function(e,t){for(var n=-1,r=null==e?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i};var t8=1/0,t7=en?en.prototype:void 0,ne=t7?t7.toString:void 0;let nt=function e(t){if("string"==typeof t)return t;if(eP(t))return t6(t,e)+"";if(tQ(t))return ne?ne.call(t):"";var n=t+"";return"0"==n&&1/t==-t8?"-0":n},nn=function(e,t){return eP(e)?e:t2(e,t)?[e]:t9(null==e?"":nt(e))};var nr=1/0;let ni=function(e){if("string"==typeof e||tQ(e))return e;var t=e+"";return"0"==t&&1/e==-nr?"-0":t},no=function(e,t){t=nn(t,e);for(var n=0,r=t.length;null!=e&&n<r;)e=e[ni(t[n++])];return n&&n==r?e:void 0},na=function(e,t,n){var r=null==e?void 0:no(e,t);return void 0===r?n:r},ns=function(e,t){return null!=e&&t in Object(e)},nu=function(e,t,n){t=nn(t,e);for(var r=-1,i=t.length,o=!1;++r<i;){var a=ni(t[r]);if(!(o=null!=e&&n(e,a)))break;e=e[a]}return o||++r!=i?o:!!(i=null==e?0:e.length)&&eV(i)&&eU(a,i)&&(eP(e)||eT(e))},nl=function(e){return e},nc=function(e){var t;return t2(e)?(t=ni(e),function(e){return null==e?void 0:e[t]}):function(t){return no(t,e)}},nd=function(e){if("function"==typeof e)return e;if(null==e)return nl;if("object"==typeof e){var t,n;return eP(e)?(t=e[0],n=e[1],t2(t)&&tH(n)?tK(ni(t),n):function(e){var r=na(e,t);return void 0===r&&r===n?null!=e&&nu(e,t,ns):tG(n,r,3)}):tZ(e)}return nc(e)};var np=Object.prototype.hasOwnProperty,nf=(o=function(e,t,n){np.call(e,n)?e[n].push(t):e_(e,n,[t])},function(e,t){return(eP(e)?ek:function(e,t,n,r){return e3(e,function(e,i,o){t(r,e,n(e),o)}),r})(e,o,nd(t,2),{})}),nm=n(56918),ny=n(28983),nh=n(30070),ng=n(48179),nv=n(12260),nb=n(59176),nw=n(53825),nx=n(40223);function nE(e){if("patch"===e.type)return e.id;if("create"===e.type)return e.document._id;if("delete"===e.type)return e.id;if("createIfNotExists"===e.type||"createOrReplace"===e.type)return e.document._id;throw Error("Invalid mutation type")}let nj=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e));for(;e--;)t+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[63&n[e]];return t};function n_(e){return"string"==typeof e?._key}function nk(e){return"object"==typeof e&&"_key"in e&&"string"==typeof e._key}function nI(e){return"number"==typeof e||nk(e)}function nM(e,t){if(0===e.length)return t;let n=t;for(let t of e){if(nI(t)){if(!Array.isArray(n))return;if(nk(t)){n=n.find(e=>e._key===t._key);continue}n=n[t];continue}n=n[t]}return n}let n$=/^[a-z_$]+/;function nS(e){return e.map((e,t)=>{var n;return n=0===t,Array.isArray(e)?`[${e[0]}:${e[1]||""}]`:"number"==typeof e?`[${e}
1]`:nk(e)?`[_key==${JSON.stringify(e._key)}]`:"string"==typeof e&&n$.test(e)?n?e:`.${e}`:`['${e}']`}).join("")}function nC(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function nA(e,t){if("number"==typeof t)return function(e,t){if(0===e&&(-1===t||0===t))return 0;let n=t<0?e+t:t;return n>=e||n<0?null:n}(e.length,t);if(nk(t)){let n=e.findIndex(e=>(null!==e&&"object"==typeof e&&"string"==typeof e._key&&e._key||null)===t._key);return -1===n?null:n}throw Error(`Expected path segment to be addressing a single array item either by numeric index or by '_key'. Instead saw ${JSON.stringify(t)}`)}function nO(e,t,n,r){let i=e.slice();return i.splice(t,n,...r||[]),i}function nT(e,t){if(!Array.isArray(t))throw TypeError('Cannot apply "insert()" on non-array value');let n=nA(t,e.referenceItem);if(null===n)throw Error(`Found no matching array element to insert ${e.position}`);return 0===t.length?e.items:nO(t,"before"===e.position?n:n+1,0,e.items)}let nP=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);var nR=Object.freeze({__proto__:null,assign:function(e,t){if(!nC(t))throw TypeError('Cannot apply "assign()" on non-object value');return!function(e){for(let t in e)if(nP(e,t))return!1;return!0}(e.value)?{...t,...e.value}:t},dec:function(e,t){if("number"!=typeof t)throw TypeError('Cannot apply "dec()" on non-numeric value');return t-e.amount},diffMatchPatch:function(e,t){if("string"!=typeof t)throw TypeError('Cannot apply "diffMatchPatch()" on non-string value');return(0,Z.$i)((0,Z.iz)(e.value),t)[0]},inc:function(e,t){if("number"!=typeof t)throw TypeError('Cannot apply "inc()" on non-numeric value');return t+e.amount},insert:nT,remove:function(e,t){if(!Array.isArray(t))throw TypeError('Cannot apply "remove()" on non-array value');let n=nA(t,e.referenceItem);if(null===n)throw Error("Found no matching array element to replace");return nO(t,n,1,[])},replace:function(e,t){if(!Array.isArray(t))throw TypeError('Cannot apply "replace()" on non-array value');let n=nA(t,e.referenceItem);if(null===n)throw Error("Found no matching array element to replace");return nO(t,n,e.items.length,e.items)},set:function(e,t){return e.value},setIfMissing:function(e,t){return t??e.value},truncate:function(e,t){if(!Array.isArray(t))throw TypeError('Cannot apply "truncate()" on non-array value');return"number"==typeof e.endIndex?t.slice(0,e.startIndex).concat(t.slice(e.endIndex)):t.slice(0,e.startIndex)},unassign:function(e,t){if(!nC(t))throw TypeError('Cannot apply "unassign()" on non-object value');return 0===e.keys.length?t:function(e,t){let n={...e};for(let e of t)delete n[e];return n}(t,e.keys)},unset:function(e){},upsert:function(e,t){if(!Array.isArray(t))throw TypeError('Cannot apply "upsert()" on non-array value');
1if(0===e.items.length)return t;let n=[],r=[];if(e.items.forEach((e,i)=>{let o=t.findIndex(t=>t?._key===e._key);o>=0?n[o]=i:r.push(e)}),0===n.length&&0==r.length)return t;let i=[...t];for(let t of n)i[t]=e.items[n[t]];return nT({type:"insert",items:r,referenceItem:e.referenceItem,position:e.position},i)}});function nz(e,t){return e.reduce((e,t)=>nL(t,e),t)}function nL(e,t){return function e(t,n,r){if(!(t.length>0))return function(e,t){if(!(e.type in nR))throw Error(`Invalid operation type: "${e.type}"`);return nR[e.type](e,t)}(n,r);let[i,...o]=t;if(nI(i)&&Array.isArray(r))return function(t,n,r,i){let o=nA(i,t);if(null===o||-1===o)return i;let a=i[o],s=e(n,r,a);return s===a?i:nO(i,o,1,[s])}(i,o,n,r);if("string"==typeof i&&nC(r))return function(t,n,r,i){let o=i[t];if(void 0===o&&n.length>0)return i;let a=e(n,r,o);return a===o?i:{...i,[t]:a}}(i,o,n,r);throw Error(`Cannot apply operation of type "${n.type}" to path ${nS(t)} on ${typeof r} value`)}(e.path,e.op,t)}function nD(e){return"_id"in e}function nN(e,t){return t.reduce((e,t)=>{let n=nU(e,t);if("error"===n.status)throw Error(n.message);return"noop"===n.status?e:n.after},e)}function nU(e,t){if("create"===t.type)return function(e,t){var n;if(e)return{status:"error",message:"Document already exist"};let r=nD(n=t.document)?n:{...n,_id:nj()};return{status:"created",id:r._id,after:r}}(e,t);if("createIfNotExists"===t.type)return nD(t.document)?e?{status:"noop"}:{status:"created",id:t.document._id,after:t.document}:{status:"error",message:"Cannot createIfNotExists on document without _id"};if("delete"===t.type)return e?t.id!==e._id?{status:"error",message:"Delete mutation targeted wrong document"}:{status:"deleted",id:t.id,before:e,after:void 0}:{status:"noop"};if("createOrReplace"===t.type)return nD(t.document)?e?{status:"updated",id:t.document._id,before:e,after:t.document}:{status:"created",id:t.document._id,after:t.document}:{status:"error",message:"Cannot createIfNotExists on document without _id"};if("patch"===t.type)return function(e,t){if(!e)return{status:"error",message:"Cannot apply patch on nonexistent document"};let n=function(e,t){if(e.options?.ifRevision&&t._rev!==e.options.ifRevision)throw Error("Revision mismatch");if(e.id!==t._id)throw Error(`Document id mismatch. Refusing to apply mutation for document with id="${e.id}" on the given document with id="${t._id}"`);return nz(e.patches,t)}(t,e);return e===n?{status:"noop"}:{status:"updated",id:t.id,before:e,after:n}}(e,t);throw Error(`Invalid mutation type: ${t.type}`)}function nV(e,t,n){let r=[];for(let n of e.slice().reverse()){if(t(n))return r;r.push(n)}return r.reverse()}function nq(e,t){return nS(e)===nS(t)}function nF(e,t){let n=e;return t.reduce((e,t)=>{let r=n;if(n=nL(t,n),"set"===t.op.type&&"string"==typeof t.op.value){let n=nM(t.path,r);if("string"==typeof n){let r={...t,op:{type:"diffMatchPatch",value:(0,Z.w1)((0,Z.jW)(n,t.op.value))}};return e.flatMap(e=>nq(e.path,t.path)&&"diffMatchPatch"===e.op.type?[]:e).concat(r)}}return e.push(t),e},[])}function nW(e,t,n,r){let i=t,o=r.map(t=>{let n=t.mutations.flatMap(t=>{if(nE(t)!==e)return[];let n=i;return i=nN(i,[t]),n&&"patch"===t.type?{type:"dmpified",mutation:{...t,dmpPatches:nF(n,t.patches),original:t.patches}}:t});return{...t,mutations:n}}),a=n;return o.map(t=>{let n=[];return t.mutations.forEach(t=>{if("dmpified"===t.type)try{a=nz(t.mutation.dmpPatches,a),n.push(t)}catch{console.warn("Failed to apply dmp patch, falling back to original");try{a=nz(t.mutation.original,a),n.push(t)}catch(t){throw Error(`Failed to apply patch for document "${e}": ${t.message}`)}}else a=nN(a,[t])})}),[r.map(t=>({...t,mutations:t.mutations.map(t=>"patch"!==t.type||nE(t)!==e?t:{...t,patches:t.patches.map(e=>"set"!==e.op.type?e:{...e,op:{...e.op,value:nM(e.path,a)}})})})),a]}function nY(e){return function(e){if("create"===e.type||"createIfNotExists"===e.type||"createOrReplace"===e.type)return{[e.type]:e.document};if("delete"===e.type)return{delete:{id:e.id}};let t=e.options?.ifRevision;return e.patches.map(n=>({patch:{id:e.id,...t&&{ifRevisionID:t},...function(e){let{path:t,op:n}=e;if("unset"===n.type)return{unset:[nS(t)]};if("insert"===n.type)return{insert:{[n.position]:nS([...t,n.referenceItem]),items:n.items}};if("diffMatchPatch"===n.type)return{diffMatchPatch:{[nS(t)]:n.value}};if("inc"===n.type)return{inc:{[nS(t)]:n.amount}};if("dec"===n.type)return{dec:{[nS(t)]:n.amount}};if("set"===n.type||"setIfMissing"===n.type)return{[n.type]:{[nS(t)]:n.value}};if("truncate"===n.type){let e=[n.startIndex,"number"==typeof n.endIndex?n.endIndex:""].join(":");return{unset:[`${nS(t)}[${e}]`]}}if("upsert"===n.type)return{unset:n.items.map(e=>
1nS([...t,{_key:e._key}])),insert:{[n.position]:nS([...t,n.referenceItem]),items:n.items}};if("assign"===n.type)return{set:Object.fromEntries(Object.keys(n.value).map(e=>[nS(t.concat(e)),n.value[e]]))};if("unassign"===n.type)return{unset:n.keys.map(e=>nS(t.concat(e)))};if("replace"===n.type)return{insert:{replace:nS(t.concat(n.referenceItem)),items:n.items}};if("remove"===n.type)return{unset:[nS(t.concat(n.referenceItem))]};throw Error(`Unknown operation type ${n.type}`)}(n)}}))}(e)}function nB(e){let t=e.listen('*[!(_id in path("_.**"))]',{},{events:["welcome","mutation","reconnect"],includeResult:!1,includePreviousRevision:!1,visibility:"transaction",effectFormat:"mendoza",includeMutations:!1}).pipe((0,ny.u)({resetOnRefCountZero:!0})),n=t.pipe((0,nh.p)(e=>"reconnect"===e.type)),r=t.pipe((0,nh.p)(e=>"welcome"===e.type)),i=t.pipe((0,nh.p)(e=>"mutation"===e.type)),o=(0,ng.h)(r,n).pipe((0,nv.t)({bufferSize:1,refCount:!0})).pipe((0,nh.p)(e=>"welcome"===e.type));return(0,ng.h)(o,i,n)}let nG=(0,J.mj)({types:{},actions:{"assign error to context":(0,H.a)({error:({event:e})=>e}),"clear error from context":(0,H.a)({error:void 0}),"connect to server-sent events":(0,K.O)({type:"connect"}),"listen to server-sent events":(0,K.P)("server-sent events",{id:"listener",input:({context:e})=>({listener:e.sharedListener||nB(e.client),id:e.id})}),"stop listening to server-sent events":(0,K.R)("listener"),"buffer remote mutation events":(0,H.a)({mutationEvents:({event:e,context:t})=>((0,J.DT)(e,"mutation"),[...t.mutationEvents,e])}),"restore stashed changes":(0,H.a)({stagedChanges:({event:e,context:t})=>((0,J.DT)(e,"xstate.done.actor.submitTransactions"),t.stashedChanges),stashedChanges:[]}),"rebase fetched remote snapshot":(0,H.b)(({enqueue:e})=>{e.assign(({event:e,context:t})=>{(0,J.DT)(e,"xstate.done.actor.getDocument");let n=t.remote,r=e.output,i=!1;for(let e of t.mutationEvents)e.effects?.apply&&(e.previousRev||"appear"===e.transition)&&(i||e.previousRev!==r?._rev||(i=!0),i&&(r=nX(r,e.effects.apply,e.resultRev)));t.cache&&(!t.cache.has(t.id)||t.cache.get(t.id)._rev!==r?._rev)&&t.cache.set(t.id,r);let[o,a]=nW(t.id,null===n?void 0:n,null===r?void 0:r,t.stagedChanges);return{remote:r,local:a,stagedChanges:o,mutationEvents:[]}}),e.sendParent(({context:e})=>({type:"rebased.remote",id:e.id,document:e.remote}))}),"apply mendoza patch":(0,H.a)(({event:e,context:t})=>{(0,J.DT)(e,"mutation");let n=t.remote;if(e.transactionId===n?._rev)return{};let r=nX(n,e.effects.apply,e.resultRev);t.cache&&(!t.cache.has(t.id)||t.cache.get(t.id)._rev!==r?._rev)&&t.cache.set(t.id,r);let[i,o]=nW(t.id,null===n?void 0:n,null===r?void 0:r,t.stagedChanges);return{remote:r,local:o,stagedChanges:i}}),"increment fetch attempts":(0,H.a)({fetchRemoteSnapshotAttempts:({context:e})=>e.fetchRemoteSnapshotAttempts+1}),"reset fetch attempts":(0,H.a)({fetchRemoteSnapshotAttempts:0}),"increment submit attempts":(0,H.a)({submitTransactionsAttempts:({context:e})=>e.submitTransactionsAttempts+1}),"reset submit attempts":(0,H.a)({submitTransactionsAttempts:0}),"stage mutation":(0,H.a)({stagedChanges:({event:e,context:t})=>((0,J.DT)(e,"mutate"),[...t.stagedChanges,{transaction:!1,mutations:e.mutations}])}),"stash mutation":(0,H.a)({stashedChanges:({event:e,context:t})=>((0,J.DT)(e,"mutate"),[...t.stashedChanges,{transaction:!1,mutations:e.mutations}])}),"rebase local snapshot":(0,H.b)(({enqueue:e})=>{e.assign({local:({event:e,context:t})=>{(0,J.DT)(e,"mutate");let n=new Map;return t.local&&n.set(t.id,t.local),function(e,t){e.forEach(e=>{("created"===e.status||"updated"===e.status)&&t.set(e.id,e.after),"deleted"===e.status&&t.delete(e.id)})}(function(e,t){let n=Object.create(null);for(let r of e){let e=nE(r);if(!e)throw Error("Unable to get document id from mutation");let i=n[e]?.after||t.get(e),o=nU(i,r);if("error"===o.status)throw Error(o.message);"noop"!==o.status&&("updated"===o.status||"created"===o.status||"deleted"===o.status)&&(e in n||(n[e]={before:i,after:void 0,muts:[]}),n[e].after=o.after)}return Object.entries(n).map(([e,{before:t,after:n,muts:r}])=>({id:e,status:n?t?"updated":"created":"deleted",mutations:r,before:t,after:n}))}(e.mutations,n),n),n.get(t.id)}}),e.sendParent(({context:e})=>({type:"rebased.local",id:e.id,document:e.local}))}),"send pristine event to parent":(0,H.s)(({context:e})=>({type:"pristine",id:e.id})),"send sync event to parent":(0,H.s)(({context:e})=>({type:"sync",id:e.id,document:e.remote})),"send mutation event to parent":(0,H.s)(({context:e,event:t})=>((0,J.DT)(t,"mutation"),{type:"mutation",id:e.id,previousRev:t.previousRev,resultRev:t.resultRev,effects:t.effects}))},actors:{"server-sent events":(0,X.OX)(({input:e})=>{let{listener:t,id:n}=e;return(0,nb.v)(()=>t).pipe((0,nh.p)(e=>"welcome"===e.type||"reconnect"===e.type||"mutation"===e.type&&e.documentId===n),(0,nw.Q)(nx.$))}),"fetch remote snapshot":(0,X.Sx)(async({input:e,signal:t})=>{let{client:n,id:r}=e;return await n.getDocument(r,{signal:t}).catch(e=>{if(!(e instanceof Error&&"AbortError"===e.name))throw e})}),"submit mutations as transactions":(0,X.Sx)(async({input:e,signal:t})=>{let{client:n,transactions:r}=e;for(let e of r){if(t.aborted)return;await n.dataRequest("mutate",function(e){return{transactionId:e.id,mutations:e.mutations.flatMap(nY)}}(e),{visibility:"async",returnDocuments:!1,signal:t}).catch(e=>{if(!(e instanceof Error&&"AbortError"===e.name))throw e})}})},delays:{fetchRemoteSnapshotTimeout:({context:e})=>1e3*Math.pow(2,e.fetchRemoteSnapshotAttempts),submitTransactionsTimeout:({context:e})=>1e3*Math.pow(2,e.submitTransactionsAttempts)}}).createMachine({id:"document-mutator",context:({input:e})=>({client:e.client.withConfig({allowReconfigure:!1}),sharedListener:e.sharedListener,id:e.id,remote:void 0,local:void 0,mutationEvents:[],stagedChanges:[],stashedChanges:[],error:void 0,fetchRemoteSnapshotAttempts:0,submitTransactionsAttempts:0,cache:e.cache}),entry:["connect to server-sent events"],on:{mutate:{actions:["rebase local snapshot","stage mutation"]}},initial:"disconnected",states:{disconnected:{on:{connect:{target:"connecting",actions:["listen to server-sent events"]}}},connecting:{on:{welcome:"connected",reconnect:"reconnecting",error:"connectFailure"},tags:["busy"]},connectFailure:{on:{connect:{target:"connecting",actions:["listen to server-sent events"]}},entry:["stop listening to server-sent events","assign error to context"],exit:["clear error from context"],tags:["error"]},reconnecting:{on:{welcome:{target:"connected"},error:{target:"connectFailure"}},tags:["busy","error"]},connected:{on:{mutation:{actions:["buffer remote mutation events"]},reconnect:"reconnecting"},entry:["clear error from context"],initial:"loading",states:{loading:{invoke:{src:"fetch remote snapshot",id:"getDocument",input:({context:e})=>({client:e.client,id:e.id}),onError:{target:"loadFailure"},onDone:{target:"loaded",actions:["rebase fetched remote snapshot","reset fetch attempts"]}},tags:["busy"]},loaded:{entry:["send sync event to parent"],on:{mutation:{actions:["apply mendoza patch","send mutation event to parent"]}},initial:"pristine",states:{pristine:{on:{mutate:{actions:["rebase local snapshot","stage mutation"],target:"dirty"}},tags:["ready"]},dirty:{on:{submit:"submitting"},tags:["ready"]},submitting:{on:{mutate:{actions:["rebase local snapshot","stash mutation"]}},invoke:{src:"submit mutations as transactions",id:"submitTransactions",input:({context:e})=>{let t=new Map;return t.set(e.id,e.remote),{client:e.client,transactions:(function(e,t){let n=[],r=[];
1return e.forEach(e=>{t(e)?r.push(e):(r.length>0&&n.push(r),r=[],n.push([e]))}),r.length>0&&n.push(r),n})(e.stagedChanges,e=>!e.transaction).flatMap(e=>({...e[0],mutations:e.flatMap(e=>e.mutations)})).map(e=>({...e,mutations:Object.values(nf(e.mutations,nE)).flatMap(e=>{var t;return(0===(t=0===e.length?e:e.reduce((e,t)=>"delete"===t.type?[t]:(e.push(t),e),[])).length?t:t.reduce((e,t)=>("createIfNotExists"!==t.type?e.push(t):nV(e,e=>"delete"===e.type).find(e=>"createIfNotExists"===e.type)||e.push(t),e),[])).flat().reduce((e,t)=>{let n=e[e.length-1];return n&&"patch"!==n.type||"patch"!==t.type?e.concat(t):e.slice(0,-1).concat({...t,patches:(n?.patches||[]).concat(t.patches)})},[])})})).map(e=>({...e,mutations:e.mutations.map(e=>"patch"!==e.type?e:{...e,patches:e.patches.reduce((e,t)=>{if("unset"!==t.op.type)return e.push(t),e;let n=e.filter(e=>{var n,r;return n=t.path,r=e.path,!(n.length<=r.length&&n.every((e,t)=>{var n;return n=function(e,t){if(t<0||t>=e.length)throw Error("Index out of bounds");return e[t]}(r,t),n_(e)&&n_(n)?e._key===n._key:"number"==typeof e?Number(e)===Number(n):e===n}))});return n.push(t),n},[]).reduceRight((e,t)=>(e.find(e=>{var n,r;return n=e.op,("set"===(r=t.op).type||"unset"===r.type)&&("set"===n.type||"unset"===n.type)&&nq(e.path,t.path)})||e.unshift(t),e),[]).reduce((e,t)=>("setIfMissing"!==t.op.type?e.push(t):nV(e,e=>"unset"===e.op.type).find(e=>"setIfMissing"===e.op.type&&nq(e.path,t.path))||e.push(t),e),[])})})).map(e=>({...e,mutations:e.mutations.map((e,n)=>{var r;return"patch"===e.type&&(r=t.get(e.id))?{...e,patches:nF(r,e.patches)}:e})})).map(e=>e.transaction&&void 0!==e.id?{id:e.id,mutations:e.mutations}:{mutations:e.mutations})}},onError:{target:"submitFailure"},onDone:{target:"pristine",actions:["restore stashed changes","reset submit attempts","send pristine event to parent"]}},tags:["busy","ready"]},submitFailure:{exit:["clear error from context"],after:{submitTransactionsTimeout:{actions:["increment submit attempts"],target:"submitting"}},on:{retry:"submitting"},tags:["error","ready"]}}},loadFailure:{exit:["clear error from context"],after:{fetchRemoteSnapshotTimeout:{actions:["increment fetch attempts"],target:"loading"}},on:{retry:"loading"},tags:["error"]}}}}});function nX(e,t,n){let r=(0,nm.X)(function(e){if(!e)return null;let{_rev:t,...n}=e;return n}(e),t);return r?Object.assign(r,{_rev:n}):null}let nH=e=>{let t=(0,X.Sx)(async({input:t,signal:n})=>{let{id:r}=t,{snapshot:i}=await e.fetch("visual-editing/fetch-snapshot",{documentId:r},{signal:n});return i}),n=(0,X.Sx)(async({input:t})=>{let{transactions:n}=t;for(let t of n){let n=F.encodeTransaction(t);return e.post("visual-editing/mutate",n)}});return nG.provide({actions:{"send sync event to parent":(0,H.b)(({enqueue:e})=>{e.sendParent(({context:e})=>({type:"sync",id:e.id,document:e.remote})),e.emit(({context:e})=>({type:"ready",snapshot:e.local}))})},actors:{"fetch remote snapshot":t,"submit mutations as transactions":n}})},nJ=(0,J.mj)({types:{},actions:{"emit sync event":(0,H.e)(({event:e})=>((0,J.DT)(e,"sync"),e)),"emit mutation event":(0,H.e)(({event:e})=>((0,J.DT)(e,"mutation"),e)),"emit rebased event":(0,H.e)(({event:e})=>((0,J.DT)(e,["rebased.local","rebased.remote"]),e)),"emit pristine event":(0,H.e)(({event:e})=>((0,J.DT)(e,["pristine"]),e)),"add document actor":(0,H.a)({documents:({context:e,event:t,spawn:n})=>{(0,J.DT)(t,"observe");let r=t.documentId;return e.documents[r]?e.documents:{...e.documents,[r]:n("documentMutatorMachine",{input
1:{id:r,client:e.client,sharedListener:e.sharedListener||nB(e.client)},id:r})}}}),"stop remote snapshot":(0,K.R)(({context:e,event:t})=>((0,J.DT)(t,"unobserve"),e.documents[t.documentId])),"remove remote snapshot from context":(0,H.a)({documents:({context:e,event:t})=>{if((0,J.DT)(t,"unobserve"),!e.documents[t.documentId])return e.documents;let{[t.documentId]:n,...r}=e.documents;return r}})},actors:{documentMutatorMachine:nG}}).createMachine({id:"dataset-mutator",context:({input:e})=>({documents:{},client:e.client,sharedListener:e.sharedListener}),on:{sync:{actions:["emit sync event"]},mutation:{actions:["emit mutation event"]},"rebased.*":{actions:["emit rebased event"]},pristine:{actions:["emit pristine event"]},observe:{actions:["add document actor"]},unobserve:{actions:["stop remote snapshot","remove remote snapshot from context"]}},initial:"pristine",states:{pristine:{}}}),nK=e=>nJ.provide({actors:{documentMutatorMachine:nH(e)}}),nZ=(0,X.H6)(),nQ=nZ,n0=new Set;var n1=n(49293);let n2=/_key\s*==\s*['"](.*)['"]/,n5=/^\d*:\d*$/;function n3(e){return"number"==typeof e||"string"==typeof e&&/^\[\d+\]$/.test(e)}function n4(e){return"string"==typeof e?n2.test(e.trim()):"object"==typeof e&&"_key"in e}let n9=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n6=/_key\s*==\s*['"](.*)['"]/;function n8(e,t,n){let r="string"==typeof t?function(e){if("string"!=typeof e)throw Error("Path is not a string");let t=e.match(n9);if(!t)throw Error("Invalid path string");return t.map(n7)}(t):t;if(!Array.isArray(r))throw Error("Path must be an array or a string");let i=e;for(let e=0;e<r.length;e++){let t=r[e];if(n3(t)){if(!Array.isArray(i))return n;i=i[t]}if(n4(t)){if(!Array.isArray(i))return n;i=i.find(e=>e._key===t._key)}if("string"==typeof t&&(i="object"==typeof i&&null!==i?i[t]:void 0),typeof i>"u")return n}return i}function n7(e){return n3(e)?Number(e.replace(/[^\d]/g,"")):n4(e)?{_key:e.match(n6)[1]}:!function(e){if("string"==typeof e&&n5.test(e))return!0;if(!Array.isArray(e)||2!==e.length)return!1;let[t,n]=e;return("number"==typeof t||""===t)&&("number"==typeof n||""===n)}(e)?e:function(e){let[t,n]=e.split(":").map(e=>""===e?e:Number(e));return[t,n]}(e)}function re(){let e=(0,m.useCallback)(e=>(n0.add(e),()=>n0.delete(e)),[]);return(0,m.useSyncExternalStore)(e,()=>nQ,()=>nZ)}function rt(){let e=re();return(0,m.useMemo)(()=>e!==nZ,[e])}function rn(e,t){let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(e,r)},t)}}function rr(e,t){let n=(0,f.Fk)(),r=(0,f.v$)();if(t===nZ||!n&&!r)throw Error("The `useDocuments` hook cannot be used in this context");let i=S(e),o=C(e),a=t.getSnapshot().context?.documents,s=a?.[i],u=a?.[o],l=s||u;if(!l)throw Error(`Document "${e}" not found`);let c=s.getSnapshot().context?.local||u.getSnapshot().context?.local,d=new Promise(e=>{if(c)e(c);else{let t=l.on("ready",n=>{let{snapshot:r}=n;e(r||null),t.unsubscribe()})}});return{draftDoc:s,draftId:i,getSnapshot:()=>d,publishedDoc:u,publishedId:o,get snapshot(){if(!c)throw Error(`Snapshot for document "${e}" not found`);return c}}}function ri(){let e=re();return{getDocument:(0,m.useCallback)(t=>({id:t,commit:()=>{let{draftDoc:n}=rr(t,e);n.send({type:"submit"})},get:n=>{let{snapshot:r}=rr(t,e);return n?n8(r,n):r},getSnapshot:function(e,t){let{getSnapshot:n}=rr(e,t);return n}(t,e),patch:async(n,r)=>{let i=rr(t,e),{draftDoc:o,draftId:a,getSnapshot:s,publishedId:u}=i,{commit:l=!0}=r||{},c=await ("function"==typeof n?n({draftId:a,publishedId:u,get snapshot(){return i.snapshot},getSnapshot:s}):n),d=await s();if(!d)throw Error(`Snapshot for document "${t}" not found`);o.send({type:"mutate",mutations:[{type:"createIfNotExists",document:{...d,_id:a}},{type:"patch",id:a,patches:q(c)}]}),l&&("object"==typeof l&&"debounce"in l?rn(()=>o.send({type:"submit"}),l.debounce)():o.send({type:"submit"}))}}),[e]),mutateDocument:(0,m.useCallback)((t,n,r)=>{let{draftDoc:i}=rr(t,e),{commit:o=!0}=r||{};i.send({type:"mutate",mutations:n}),o&&("object"==typeof o&&"debounce"in o?rn(()=>i.send({type:"submit"}),o.debounce)():i.send({type:"submit"}))},[e])}}let ro=(()=>{let e;return()=>{if(e)return e;e=[];for(let t=0;t<256;++t)e[t]=(t+256).toString(16).slice(1);return e}})();function ra(e){let t=ro();return(function(e=16){let t=new Uint8Array(e);return(0,n1.A)(t),t})(e).reduce((e,n)=>e+t[n],"").slice(0,e)}function rs(e){let t,n;let r="string"==typeof e?e:e.path,i=r.lastIndexOf("."),o=r.substring(i+1,r.length);if(!o.indexOf("["))throw Error("Invalid path: not an array");let a=r.lastIndexOf("["),s=r.substring(0,a);if(o.includes("_key")){let e=o.indexOf('"')+1,r=o.indexOf('"',e);t=o.substring(e,r),n=!0}else{let e=o.indexOf("[")+1,r=o.indexOf("]",e);t=o.substring(e,r),n=!1}if(!s||!t)throw Error("Invalid path");return{path:s,key:t,hasExplicitKey:n}}async function ru(e,t,n){if(!e.type)throw Error("Node type is missing");let{path:r,key:i}=rs(e),o=await t.getSnapshot(),a=n8(o,r),s=n8(o,e.path),u=a.findIndex(e=>e._key===i),l=-1,c="before";if("first"===n){if(0===u)return[];l=0,c="before"}else if("last"===n){if(u===a.length-1)return[];l=-1,c="after"}else if("next"===n){if(u===a.length-1)return[];l=u,c="after"}else if("previous"===n){if(0===u)return[];l=u-1,c="before"}return[G(r,Y(u,u+1)),G(r,W(s,c,l))]}function rl(e){return{lang:e?.lang??u?.lang,message:e?.message,abortEarly:e?.abortEarly??u?.abortEarly,abortPipeEarly:e?.abortPipeEarly??u?.abortPipeEarly,skipPipe:e?.skipPipe}}function rc(e,t,n,r,i){var o,a,s,u;let p;let f=i&&"input"in i?i.input:n.value,m=i?.expected??e.expects,y=i?.received??("object"==(p=typeof f)&&(p=(f&&Object.getPrototypeOf(f)?.constructor?.name)??"null"),"string"===p?`"${f}"`:"number"===p||"bigint"===p||"boolean"===p?`${f}`:p),h={kind:e.kind,type:e.type,input:f,expected:m,received:y,message:`Invalid ${t}: ${m?`Expected ${m} but r`:"R"}eceived ${y}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly,skipPipe:r.skipPipe},g="schema"===e.kind,v=e.message??(o=e.reference,a=h.lang,d?.get(o)?.get(a))??(g?(s=h.lang,c?.get(s)):null)??r.message??(u=h.lang,l?.get(u));v&&(h.message="function"==typeof v?v(h):v),g&&(n.typed=!1),n.issues?n.issues.push(h):n.issues=[h]}
1var rd=class extends Error{issues;constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function rp(e,t){return{kind:"validation",type:"min_length",reference:rp,async:!1,expects:`>=${e}`,requirement:e,message:t,_run(e,t){return e.typed&&e.value.length<this.requirement&&rc(this,"length",e,t,{received:`${e.value.length}`}),e}}}function rf(e,t,n){return"function"==typeof e.fallback?e.fallback(t,n):e.fallback}function rm(e,t,n){return"function"==typeof e.default?e.default(t,n):e.default}function ry(e){if("entries"in e){let t={};for(let n in e.entries)t[n]=ry(e.entries[n]);return t}return"items"in e?e.items.map(ry):rm(e)}async function rh(e){return"entries"in e?Object.fromEntries(await Promise.all(Object.entries(e.entries).map(async([e,t])=>[e,await rh(t)]))):"items"in e?Promise.all(e.items.map(rh)):rm(e)}function rg(e){if("entries"in e){let t={};for(let n in e.entries)t[n]=rg(e.entries[n]);return t}return"items"in e?e.items.map(rg):rf(e)}async function rv(e){return"entries"in e?Object.fromEntries(await Promise.all(Object.entries(e.entries).map(async([e,t])=>[e,await rv(t)]))):"items"in e?Promise.all(e.items.map(rv)):rf(e)}function rb(e,t){return{kind:"schema",type:"object",reference:rb,expects:"Object",async:!1,entries:e,message:t,_run(e,t){let n=e.value;if(n&&"object"==typeof n)for(let r in e.typed=!0,e.value={},this.entries){let i=n[r],o=this.entries[r]._run({typed:!1,value:i},t);if(o.issues){let a={type:"object",origin:"value",input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),(void 0!==o.value||r in n)&&(e.value[r]=o.value)}else rc(this,"type",e,t);return e}}}function rw(e,...t){let n={kind:"schema",type:"optional",reference:rw,expects:`${e.expects} | undefined`,async:!1,wrapped:e,_run(e,t){return void 0===e.value&&("default"in this&&(e.value=rm(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 rx(e){return{kind:"schema",type:"string",reference:rx,expects:"string",async:!1,message:e,_run(e,t){return"string"==typeof e.value?e.typed=!0:rc(this,"type",e,t),e}}}function rE(...e){return{...e[0],pipe:e,_run(t,n){for(let r=0;r<e.length;r++){t=e[r]._run(t,n);let i=e[r+1];if(n.skipPipe||t.issues&&(n.abortEarly||n.abortPipeEarly||i?.kind==="schema"||i?.kind==="transformation")){t.typed=!1;break}}return t}}}function rj(e,t,n){let r=e._run({typed:!1,value:t},rl(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}let r_=rE(rx(),rp(1)),rk=rw(r_),rI=rb({baseUrl:r_,dataset:rk,id:r_,path:r_,projectId:rk,tool:rk,type:rk,workspace:rk}),rM=/^([\w-]+):(0|[1-9][0-9]*)$/,r$=/^([\w-]+):([0-9]+),([0-9]+)$/,rS=/^([\w-]+):([\w-]+)$/,rC=rE(rx(),rp(1)),rA=rb({origin:rC,href:rC,data:rw(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){let n=e.value;if(n&&"object"==typeof n){for(let r in e.typed=!0,e.value={},n)if("__proto__"!==r&&"prototype"!==r&&"constructor"!==r){let i=n[r],o=this.key._run({typed:!1,value:r},t);if(o.issues){let a={type:"record",origin:"key",input:n,key:r,value:i};for(let t of o.issues)t.path=[a],e.issues?.push(t);if(e.issues||(e.issues=o.issues),t.abortEarly){e.typed=!1;break}}let a=this.value._run({typed:!1,value:i},t);if(a.issues){let o={type:"record",origin:"value",input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||(e.issues=a.issues),t.abortEarly){e.typed=!1;break}}o.typed&&a.typed||(e.typed=!1),o.typed&&(e.value[o.value]=a.value)}}else rc(this,"type",e,t);return e}}}(rx(),function e(){return{kind:"schema",type:"unknown",reference:e,expects:"unknown",async:!1,_run:e=>(e.typed=!0,e)}}()))});function rO(e){let t=rj(rI,e);if(t.success)return t.output;let n=rj(rA,e);if(n.success)try{let e=new URL(n.output.href,typeof document>"u"?"https://example.com":location.origin);return e.searchParams.size>0?function(e,t,n){let r=e._run({typed:!1,value:t},rl(void 0));if(r.issues)throw new rd(r.issues);return r.value}
1(rI,Object.fromEntries(e.searchParams.entries())):n.output}catch(e){return console.error("Failed to parse sanity node",e),n.output}}var rT={0:8203,1:8204,2:8205,3:8290,4:8291,5:8288,6:65279,7:8289,8:119155,9:119156,a:119157,b:119158,c:119159,d:119160,e:119161,f:119162},rP={0:8203,1:8204,2:8205,3:65279},rR=[,,,,].fill(String.fromCodePoint(rP[0])).join(""),rz=Object.fromEntries(Object.entries(rP).map(e=>e.reverse())),rL=Object.fromEntries(Object.entries(rT).map(e=>e.reverse())),rD=`${Object.values(rT).map(e=>`\\u{${e.toString(16)}}`).join("")}`,rN=RegExp(`[${rD}]{4,}`,"gu");let rU=[];for(let e=0;e<256;++e)rU.push((e+256).toString(16).slice(1));let rV=new Uint8Array(16);var rq={randomUUID:"u">typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function rF(e){let t=e.getBoundingClientRect();return{x:t.x+scrollX,y:t.y+scrollY,w:t.width,h:t.height}}function rW(e,t,n){return"x"===n?{x:e.x+t,y:e.y,w:e.w-2*t,h:e.h}:{x:e.x,y:e.y+t,w:e.w,h:e.h-2*t}}function rY(e,t){return e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h}function rB(e,t){let n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}function rG(e,t,n){let r,i;let o={x:e.x1,y:e.y1};if(t.some(e=>(function(e,t){let n=e.x>=t.x&&e.x<=t.x+t.w,r=e.y>=t.y&&e.y<=t.y+t.h;return n&&r})(o,rW(e,Math.min(e.w,e.h)/10,"horizontal"===n?"x":"y"))))return null;for(let a of t){let t=function(e,t){let n=[{x1:t.x,y1:t.y,x2:t.x+t.w,y2:t.y},{x1:t.x+t.w,y1:t.y,x2:t.x+t.w,y2:t.y+t.h},{x1:t.x+t.w,y1:t.y+t.h,x2:t.x,y2:t.y+t.h},{x1:t.x,y1:t.y+t.h,x2:t.x,y2:t.y}],r=[];for(let t=0;t<n.length;t++){let i=function(e,t){let{x1:n,y1:r,x2:i,y2:o}=e,{x1:a,y1:s,x2:u,y2:l}=t;if(n===i&&r===o||a===u&&s===l)return!1;let c=(l-s)*(i-n)-(u-a)*(o-r);if(0===c)return!1;let d=((u-a)*(r-s)-(l-s)*(n-a))/c,p=((i-n)*(r-s)-(o-r)*(n-a))/c;return!(d<0)&&!(d>1)&&!(p<0)&&!(p>1)&&{x:n+d*(i-n),y:r+d*(o-r)}}(e,n[t]);if(i){let e=!1;for(let t=0;t<r.length;t++)r[t].x===i.x&&r[t].y===i.y&&(e=!0);e||r.push(i)}}return 0!==r.length&&r.sort((t,n)=>rB(t,{x:e.x1,y:e.y1})-rB(n,{x:e.x1,y:e.y1}))}(e,rW(a,Math.min(a.w,a.h)/10,"horizontal"===n?"x":"y"));if(t){let e=t[0];r?rB(o,e)<rB(o,r)&&(r=e,i=a):(r=e,i=a)}}return i||null}function rX(e,t,n){let{x:r,y:i,w:o,h:a}=e,{x:s,y:u}=n;return{x:s+(r-s)*t,y:u+(i-u)*t,w:o*t,h:a*t}}function rH(e){let t=Math.max(0,Math.min(...e.map(e=>e.y))),n=Math.min(document.body.scrollHeight,Math.max(...e.map(e=>e.y+e.h)));return{min:t,max:n,height:n-t}}function rJ(e,t){return t.find(t=>rY(rF(t.elements.element),e))?.sanity}function rK(e,t,n){return Object.values(t).every(e=>null===e)?null:"horizontal"===n?{left:t.left?{rect:t.left,sanity:rJ(t.left,e)}:null,right:t.right?{rect:t.right,sanity:rJ(t.right,e)}:null}:{top:t.top?{rect:t.top,sanity:rJ(t.top,e)}:null,bottom:t.bottom?{rect:t.bottom,sanity:rJ(t.bottom,e)}:null}}function rZ(e){let t=document.body.getBoundingClientRect();return{x:Math.max(t.x,Math.min(e.clientX,t.x+t.width)),y:e.clientY+window.scrollY}}function rQ(e,t,n){let r=rF(t),i=[...t.querySelectorAll(":where(h1, h2, h3, h4, p, a, img, span, button):not(:has(*))")];e.x<=r.x&&(e.x=r.x),e.x>=r.x+r.w&&(e.x=r.x+r.w),e.y>=r.y+r.h&&(e.y=r.y+r.h),e.y<=r.y&&(e.y=r.y);let o=i.map(e=>{let t=rX(rF(e),n,{x:r.x,y:r.y});return{x:t.x-r.x,y:t.y-r.y,w:t.w,h:t.h,tagName:e.tagName}});return{offsetX:(r.x-e.x)*n,offsetY:(r.y-e.y)*n,w:r.w*n,h:r.h*n,maxWidth:r.w*n*.75,childRects:o}}async function r0(e,t,n,r,i){return new Promise(o=>{e.addEventListener("transitionend",()=>{setTimeout(()=>{r({type:"overlay/dragEndMinimapTransition"})},2*i),o()},{once:!0}),r({type:"overlay/dragStartMinimapTransition"}),r({type:"overlay/dragToggleMinimap",display:!0}),document.body.style.overflow="hidden",document.body.style.height="100%",document.documentElement.style.overflow="initial",document.documentElement.style.height="100%",setTimeout(()=>{e.style.transformOrigin="50% 0px",e.style.transition="transform 150ms ease",e.style.transform=`translate3d(0px, ${-n+scrollY}px, 0px) scale(${t})`},25)})}function r1(e){let t=function(e){let t=Math.max(0,Math.min(...e.map(e=>e.x))),n=Math.min(document.body.offsetWidth,Math.max(...e.map(e=>e.x+e.w)));return{min:t,max:n,width:n-t}}(e),n=rH(e),r=t.min>8&&t.min+t.width<=window.innerWidth-8,i=n.min>8&&n.min+n.height<=document.body.scrollHeight-8,o=r&&i;return{x:o?t.min-8:t.min,y:o?n.min-8:n.min,w:o?t.width+16:t.width,h:o?n.height+16:n.height}}async function r2(e,t,n,r,i,o){return new Promise(a=>{if(1===new DOMMatrix(window.getComputedStyle(t).transform).a)return;let s=n-window.innerHeight,u=scrollY;(e-=window.innerHeight/2)<0&&(e=0),t.addEventListener("transitionend",()=>{t.style.transition="none",t.style.transform="none",scrollTo({top:e,behavior:"instant"}),setTimeout(()=>{r({type:"overlay/dragEndMinimapTransition"}),r({type:"overlay/dragToggleMinimap",display:!1})},2*i),a()},{once:!0}),r({type:"overlay/dragStartMinimapTransition"}),t.style.transform=`translateY(${Math.max(u-e,-s+u)}px) scale(1)`,o&&(document.body.style.overflow=o.body.overflow,document.body.style.height=o.body.height,document.documentElement.style.overflow=o.documentElement.overflow,document.documentElement.style.height=o.documentElement.height)})}let r5=!1,r3={y:0},r4={x:0,y:0},r9=typeof document>"u"?0:document.documentElement.scrollHeight,r6=null,r8=e=>e instanceof HTMLElement||e instanceof SVGElement,r7=e=>e&&r8(e)?e.dataset?.sanityOverlayElement?e:r7(e.parentElement):null;function ie(e,t=!1){return(rN.lastIndex=0,rN.test(e))?function(e,t=!1){try{let n=function(e){let t=e.match(rN);if(t)return function(e,t=!1){let n=Array.from(e);if(n.length%2==0){if(n.length%4||!e.startsWith(rR))return function(e,t){var n;let r=[];for(let t=.5*e.length;t--;){let n=`${rL[e[2*t].codePointAt(0)]}${rL[e[2*t+1].codePointAt(0)]}`;r.unshift(String.fromCharCode(parseInt(n,16)))}let i=[],o=[r.join("")],a=10;for(;o.length;){let e=o.shift();try{if(i.push(JSON.parse(e)),t)break}catch(r){if(!a--)throw r;let t=+(null==(n=r.message.match(/\sposition\s(\d+)$/))?void 0:n[1]);if(!t)throw r;o.unshift(e.substring(0,t),e.substring(t))}}return i}(n,t)}
1else throw Error("Encoded data has invalid length");let r=[];for(let e=.25*n.length;e--;){let t=n.slice(4*e,4*e+4).map(e=>rz[e.codePointAt(0)]).join("");r.unshift(String.fromCharCode(parseInt(t,4)))}if(t){r.shift();let e=r.indexOf("\0");return -1===e&&(e=r.length),[JSON.parse(r.slice(0,e).join(""))]}return r.join("").split("\0").filter(Boolean).map(e=>JSON.parse(e))}(t[0],!0)[0]}(e);return n&&"sanity.io"===n.origin?(t&&(n.href=n.href?.replace(".alt","")),n):null}catch(t){return console.error("Failed to decode stega for string: ",e,"with the original error: ",t),null}}(e,t):null}let it=e=>e.nodeType===Node.ELEMENT_NODE,ir=e=>"IMG"===e.tagName,ii=e=>"TIME"===e.tagName,io=e=>"SVG"===e.tagName.toUpperCase();function ia(e){return"path"in e}function is(e){let t=e.lastIndexOf(".");return e.substring(t,e.length).includes("[")}function iu(e){if(!is(e))return null;let t=e.split(".");return t[t.length-1]=t[t.length-1].replace(/\[.*?\]/g,"[]"),t.join(".")}function il(e,t){return!!(is(e.path)&&is(t.path))&&iu(e.path)===iu(t.path)}function ic(e,t,n,r){if(!e.getAttribute("data-sanity")||e.getAttribute("data-sanity-drag-disable")||!t||!ia(t)||!is(t.path))return null;let i=e.getAttribute("data-sanity-drag-group"),o=[...n].reduce((e,n)=>{let o=r.get(n),a=n.getAttribute("data-sanity-drag-disable"),s=n.getAttribute("data-sanity-drag-group"),u=null!==n.getAttribute("data-sanity");return o&&!a&&ia(o.sanity)&&il(t,o.sanity)&&(null===i||i===s)&&u&&e.push(o),e},[]);return o.length<=1?null:o}let id=(0,m.createContext)(null);var ip=n(45054),im=n(64775),iy=n(78592),ih=n(13553);function ig(e){let t=function e(t){return!!t&&("object"==typeof t||"function"==typeof t)&&("reference"===t.name||e(t.type))}(e)&&1===(e.to??[]).length?e.to[0].icon:void 0;return e.icon??e.type?.icon??t}function iv(e,t){return{query:"change query"===t.type?t.query:e.query,groups:"select group"===t.type?e.groups.map(e=>({...e,selected:t.name===e.name})):e.groups,views:"toggle view"===t.type?e.views.map(e=>({...e,selected:t.name===e.name})):e.views}}let ib="all-items",iw={gridTemplateColumns:"repeat(auto-fill, minmax(118px, 1fr))"};function ix(e){let t,n,r,i,o,a,s,u,l,c,d,f,y,h,g,v;let b=(0,ip.c)(54),w=void 0===e.showIcons||e.showIcons,x=void 0===e.filter||"auto"===e.filter?e.schemaTypes.length>5:e.filter;b[0]!==e.groups||b[1]!==e.labels?(t=e.groups?[{name:ib,title:e.labels["insert-menu.filter.all-items"],selected:!0},...e.groups.map(i_)]:[],b[0]=e.groups,b[1]=e.labels,b[2]=t):t=b[2],b[3]!==e.views?(n=e.views??[{name:"list"}],b[3]=e.views,b[4]=n):n=b[4],b[5]!==n?(r=n.map(ij),b[5]=n,b[6]=r):r=b[6],b[7]!==t||b[8]!==r?(i={query:"",groups:t,views:r},b[7]=t,b[8]=r,b[9]=i):i=b[9];let[E,j]=(0,m.useReducer)(iv,i);if(b[10]!==e||b[11]!==x||b[12]!==w||b[13]!==E.groups||b[14]!==E.query||b[15]!==E.views){var _,k,I;let t,n,r;let i=(_=e.schemaTypes,k=E.query,I=E.groups,_.filter(e=>(function(e,t){let n=t.find(e=>e.selected);return!n||n.name===ib||n.of?.includes(e.name)})(e,I)&&function(e,t){let n=t.trim().toLowerCase();return e.title?e.title?.toLowerCase().includes(n):e.name.includes(n)}(e,k))),m=E.views.find(iE),h=x||E.views.length>1,g=E.groups&&E.groups.length>0,v=h||g;s=A.W1,y=0,a=A.so,c="column",d="fill",b[25]!==v?(t=v?{style:{borderBottom:"1px solid var(--card-border-color)"},paddingBottom:1}:{},b[25]=v,b[26]=t):t=b[26],b[27]!==e.labels||b[28]!==x||b[29]!==h||b[30]!==E.query||b[31]!==E.views?(n=h?(0,p.jsxs)(A.so,{flex:"none",align:"center",paddingTop:1,paddingX:1,gap:1,children:[x?(0,p.jsx)(A.az,{flex:1,children:(0,p.jsx)(A.ks,{autoFocus:!0,border:!1,fontSize:1,icon:im.WIv,onChange:e=>{j({type:"change query",query:e.target.value})},placeholder:e.labels["insert-menu.search.placeholder"],value:E.query})}):null,E.views.length>1?(0,p.jsx)(A.az,{flex:"none",children:(0,p.jsx)(iM,{views:E.views,onToggle:e=>{j({type:"toggle view",name:e})},labels:e.labels})}):null]}):null,b[27]=e.labels,b[28]=x,b[29]=h,b[30]=E.query,b[31]=E.views,b[32]=n):n=b[32],b[33]!==g||b[34]!==E.groups?(r=g?(0,p.jsx)(A.az,{paddingTop:1,paddingX:1,children:(0,p.jsx)(A.wb,{space:1,children:E.groups.map(e=>(0,p.jsx)(A.oz,{id:`${e.name}-tab`,"aria-controls":`${e.name}-panel`,label:e.title??iy(e.name),selected:e.selected,onClick:()=>{j({type:"select group",name:e.name})}},e.name))})}):null,b[33]=g,b[34]=E.groups,b[35]=r):r=b[35],b[36]!==t||b[37]!==n||b[38]!==r?(f=(0,p.jsxs)(A.az,{...t,children:[n,r]}),b[36]=t,b[37]=n,b[38]=r,b[39]=f):f=b[39],o=A.az,u=1,l=0===i.length?(0,p.jsx)(A.az,{padding:2,children:(0,p.jsx)(A.EY,{muted:!0,size:1,children:e.labels["insert-menu.search.no-results"]})}):m?"grid"===m.name?(0,p.jsx)(A.xA,{autoRows:"auto",flex:1,gap:1,style:iw,children:i.map(t=>(0,p.jsx)(iS,{icon:w?ig(t):void 0,onClick:()=>{e.onSelect(t)},previewImageUrl:m.previewImageUrl?.(t.name),schemaType:t}
1,t.name))}):(0,p.jsx)(A.BJ,{flex:1,space:1,children:i.map(t=>(0,p.jsx)(A.Dr,{icon:w?ig(t):void 0,onClick:()=>{e.onSelect(t)},text:t.title??iy(t.name)},t.name))}):null,b[10]=e,b[11]=x,b[12]=w,b[13]=E.groups,b[14]=E.query,b[15]=E.views,b[16]=o,b[17]=a,b[18]=s,b[19]=u,b[20]=l,b[21]=c,b[22]=d,b[23]=f,b[24]=y}else o=b[16],a=b[17],s=b[18],u=b[19],l=b[20],c=b[21],d=b[22],f=b[23],y=b[24];return b[40]!==o||b[41]!==u||b[42]!==l?(h=(0,p.jsx)(o,{padding:u,children:l}),b[40]=o,b[41]=u,b[42]=l,b[43]=h):h=b[43],b[44]!==a||b[45]!==h||b[46]!==c||b[47]!==d||b[48]!==f?(g=(0,p.jsxs)(a,{direction:c,height:d,children:[f,h]}),b[44]=a,b[45]=h,b[46]=c,b[47]=d,b[48]=f,b[49]=g):g=b[49],b[50]!==s||b[51]!==g||b[52]!==y?(v=(0,p.jsx)(s,{padding:y,children:g}),b[50]=s,b[51]=g,b[52]=y,b[53]=v):v=b[53],v}function iE(e){return e.selected}function ij(e,t){return{...e,selected:0===t}}function i_(e){return{...e,selected:!1}}let ik={grid:im.jxC,list:im.r$9},iI={grid:"insert-menu.toggle-grid-view.tooltip",list:"insert-menu.toggle-list-view.tooltip"};function iM(e){let t,n,r,i;let o=(0,ip.c)(11),a=e.views.findIndex(i$),s=e.views[a+1]??e.views[0],u=e.labels[iI[s.name]];o[0]!==u?(t=(0,p.jsx)(A.EY,{size:1,children:u}),o[0]=u,o[1]=t):t=o[1];let l=ik[s.name];return o[2]!==s.name||o[3]!==e?(n=()=>{e.onToggle(s.name)},o[2]=s.name,o[3]=e,o[4]=n):n=o[4],o[5]!==l||o[6]!==n?(r=(0,p.jsx)(A.$n,{mode:"bleed",icon:l,onClick:n}),o[5]=l,o[6]=n,o[7]=r):r=o[7],o[8]!==t||o[9]!==r?(i=(0,p.jsx)(A.m_,{content:t,placement:"top",portal:!0,children:r}),o[8]=t,o[9]=r,o[10]=i):i=o[10],i}function i$(e){return e.selected}function iS(e){let t,n,r,i,o,a,s,u,l;let c=(0,ip.c)(19),[d,f]=(0,m.useState)(!1),y=e.icon;c[0]===Symbol.for("react.memo_cache_sentinel")?(t={overflow:"hidden"},c[0]=t):t=c[0],c[1]===Symbol.for("react.memo_cache_sentinel")?(n={backgroundColor:"var(--card-muted-bg-color)",paddingBottom:"66.6%",position:"relative"},c[1]=n):n=c[1],c[2]!==y?(r=(0,ih.isValidElementType)(y)?(0,p.jsx)(A.so,{align:"center",justify:"center",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%"},children:(0,p.jsx)(A.EY,{size:1,children:(0,p.jsx)(y,{})})}):null,c[2]=y,c[3]=r):r=c[3],c[4]!==d||c[5]!==e.previewImageUrl?(i=!e.previewImageUrl||d?null:(0,p.jsx)("img",{src:e.previewImageUrl,style:{objectFit:"contain",width:"100%",height:"100%",position:"absolute",inset:0},onError:()=>{f(!0)}}),c[4]=d,c[5]=e.previewImageUrl,c[6]=i):i=c[6],c[7]===Symbol.for("react.memo_cache_sentinel")?(o=(0,p.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",boxShadow:"inset 0 0 0 0.5px var(--card-fg-color)",opacity:.1}}),c[7]=o):o=c[7],c[8]!==r||c[9]!==i?(a=(0,p.jsxs)(A.az,{flex:"none",style:n,children:[r,i,o]}),c[8]=r,c[9]=i,c[10]=a):a=c[10];let h=e.schemaType.title??e.schemaType.name;return c[11]!==h?(s=(0,p.jsx)(A.az,{flex:1,padding:2,children:(0,p.jsx)(A.EY,{size:1,weight:"medium",children:h})}),c[11]=h,c[12]=s):s=c[12],c[13]!==a||c[14]!==s?(u=(0,p.jsxs)(A.so,{direction:"column",gap:1,padding:1,children:[a,s]}),c[13]=a,c[14]=s,c[15]=u):u=c[15],c[16]!==e.onClick||c[17]!==u?(l=(0,p.jsx)(A.Dr,{padding:0,radius:2,onClick:e.onClick,style:t,children:u}),c[16]=e.onClick,c[17]=u,c[18]=l):l=c[18],l}function iC(e){if(!e)return(0,p.jsx)(im.XRf,{});if("string"===e.type)return(0,p.jsx)(im.H3M,{});if("number"===e.type)return(0,p.jsx)(im.bZn,{});let{value:t}=e;if("icon"in e&&e.icon)return(0,p.jsx)("div",{dangerouslySetInnerHTML:{__html:e.icon}});let{type:n}=t;if("string"===n)return(0,p.jsx)(im.H3M,{});if("boolean"===n)return(0,p.jsx)(im.Dee,{});if("number"===n)return(0,p.jsx)(im.bZn,{});if("array"===n||"union"===n)return(Array.isArray(t.of)?t.of:[t.of]).some(e=>"name"in e&&"block"===e.name)?(0,p.jsx)(im.a1,{}):(0,p.jsx)(im.Ss4,{});if("object"===n){if("image"===e.name)return(0,p.jsx)(im.xfq,{});if("block"===e.name)return(0,p.jsx)(im.H3M,{})}return(0,p.jsx)(im.XRf,{})}let iA=O.I4.div`
2  height: 100%;
3  inset: 0;
4  overflow-y: scroll;
5  overscroll-behavior: contain;
6  pointer-events: all;
7  position: fixed;
8  width: 100%;
9  -ms-overflow-style: none;
10  scrollbar-width: none;
11  display: flex;
12  justify-content: center;
13  align-items: center;
14  &:before {
15    content: '';
16    display: block;
17    height: calc(100% + 1px);
18    position: absolute;
19    top: 0;
20    width: 100%;
21    z-index: -1;
22  }
23`,iO=O.I4.div`
24  background: transparent;
25  height: 100%;
26  inset: 0;
27  position: absolute;
28  width: 100%;
29`,iT=e=>{let{children:t,onDismiss:n,setBoundaryElement:r}=e;return(0,p.jsx)(A.ZL,{children:(0,p.jsxs)(iA,{"data-sanity-overlay-element":!0,ref:r,onClick:e=>{e.stopPropagation()},children:[(0,p.jsx)(iO,{onClickCapture:n}),t]})})};function iP(e){return{type:"log",name:e.name,version:e.version,description:e.description,schema:void 0}}let iR={"Visual Editing Drag Sequence Completed":iP({name:"Visual Editing Drag Sequence Completed",description:"An array is successfully reordered using drag and drop.",version:1}),"Visual Editing Drag Minimap Enabled":iP({name:"Visual Editing Drag Minimap Enabled",description:"The zoomed-out minimap view is enabled during a drag sequence.",version:1}),"Visual Editing Context Menu Item Removed":iP({name:"Visual Editing Context Menu Item Removed",description:"An item is removed using the Context Menu.",version:1}),"Visual Editing Context Menu Item Duplicated":iP({name:"Visual Editing Context Menu Item Duplicated",description:"An item is duplicated using the Context Menu.",version:1}),"Visual Editing Context Menu Item Moved":iP({name:"Visual Editing Context Menu Item Moved",description:"An item is moved using the Context Menu.",version:1}),"Visual Editing Context Menu Item Inserted":iP({name:"Visual Editing Context Menu Item Inserted",description:"An item is inserted using the Context Menu.",version:1}),"Visual Editing Insert Menu Item Inserted":iP({name:"Visual Editing Insert Menu Item Inserted",description:"An item is inserted using the Insert Menu.",version:1}),"Visual Editing Overlay Clicked":iP({name:"Visual Editing Overlay Clicked",description:"An Overlay is clicked.",version:1})},iz=(0,m.createContext)(void 0);function iL(){let e=(0,m.useContext)(iz);
29if(!e)throw Error("Telemetry context is missing");return e}let iD={"insert-menu.filter.all-items":"All","insert-menu.search.no-results":"No results","insert-menu.search.placeholder":"Filter types…","insert-menu.toggle-grid-view.tooltip":"Toggle grid view","insert-menu.toggle-list-view.tooltip":"Toggle list view"},iN=e=>{let{node:t,onSelect:n}=e,r=t.options?.insertMenu||{},i=r.views?.map(e=>"grid"===e.name?{...e,previewImageUrl:t=>e.previewImageUrls?.[t]}:e);return(0,p.jsx)(ix,{...r,labels:iD,schemaTypes:t.of.map(e=>({...e,icon:iC(e)})),onSelect:n,views:i})},iU=({children:e,style:t,...n})=>(0,p.jsx)("div",{style:{...t,pointerEvents:"all"},"data-sanity-overlay-element":!0,...n,children:e});var iV=n(93067),iq=n(3620),iF=n(87659),iW=n(66677);let iY=e=>{let{comlink:t,history:n}=e;return(0,m.useEffect)(()=>t?.on("presentation/navigate",e=>{n?.update(e)}),[t,n]),(0,m.useEffect)(()=>{if(n)return n.subscribe(e=>{e.title=e.title||document.title,t?.post("visual-editing/navigate",e)})},[t,n]),null},iB=e=>{let{comlink:t}=e;return(0,m.useEffect)(()=>{let e=()=>{t.post("visual-editing/meta",{title:document.title})},n=new MutationObserver(([t])=>{"TITLE"===t.target.nodeName&&e()});return n.observe(document.head,{subtree:!0,characterData:!0,childList:!0}),e(),()=>n.disconnect()},[t]),null},iG=(0,m.createContext)(null);function iX(){let e=(0,m.useContext)(iG);if(!e)throw Error("Schema context is missing");return e}function iH(e,t,n,r){if(!e.type)throw Error("Node type is missing");return()=>t.patch(()=>(function(e,t,n){let{path:r,key:i}=rs(e);return[G(r,W([{_type:t,_key:ra()}],n,{_key:i}))]})(e,n,r))}function iJ(e){let{node:t,doc:n}=e;return n?[{type:"action",label:"Duplicate",icon:im.TdU,action:function(e,t){if(!e.type)throw Error("Node type is missing");return()=>t.patch(async({getSnapshot:t})=>(function(e,t,n="after"){let{path:r,key:i}=rs(e);return[G(r,W({...n8(t,e.path),_key:ra()},n,{_key:i}))]})(e,await t()))}(t,n),telemetryEvent:"Visual Editing Context Menu Item Duplicated"}]:[]}function iK(e){let{node:t,doc:n}=e;return n?[{type:"action",label:"Remove",icon:im.YPx,action:function(e,t){if(!e.type)throw Error("Node type is missing");return()=>t.patch(async({getSnapshot:t})=>(function(e,t){let{path:n,key:r}=rs(e),i=n8(t,n).findIndex(e=>e._key===r);return[G(n,Y(i,i+1))]})(e,await t()))}(t,n),telemetryEvent:"Visual Editing Context Menu Item Removed"}]:[]}async function iZ(e,t=!0){let{node:n,doc:r}=e;if(!r)return[];let i=[],o=[],[a,s,u,l]=await Promise.all([ru(n,r,"previous"),ru(n,r,"next"),ru(n,r,"first"),ru(n,r,"last")]);return u.length&&o.push({type:"action",label:"To top",icon:im.VQ$,action:()=>r.patch(u),telemetryEvent:"Visual Editing Context Menu Item Moved"}),a.length&&o.push({type:"action",label:"Up",icon:im.Kpk,action:()=>r.patch(a),telemetryEvent:"Visual Editing Context Menu Item Moved"}),s.length&&o.push({type:"action",label:"Down",icon:im.ZLN,action:()=>r.patch(s),telemetryEvent:"Visual Editing Context Menu Item Moved"}),l.length&&o.push({type:"action",label:"To bottom",icon:im.wvk,action:()=>r.patch(l),telemetryEvent:"Visual Editing Context Menu Item Moved"}),o.length&&(i.push({type:"group",label:"Move",icon:im.ycB,items:o}),t&&i.push({type:"divider"})),i}async function iQ(e){let{node:t,field:n,doc:r}=e,i=[];return i.push(...iJ(e)),i.push(...iK(e)),i.push(...await iZ(e)),i.push({type:"action",label:"Insert before",icon:im.SKY,action:iH(t,r,n.name,"before"),telemetryEvent:"Visual Editing Context Menu Item Inserted"}),i.push({type:"action",label:"Insert after",icon:im.amD,action:iH(t,r,n.name,"after"),telemetryEvent:"Visual Editing Context Menu Item Inserted"}),i}let i0=e=>{let{label:t,parent:n,width:r,onSelect:i,boundaryElement:o}=e;return(0,p.jsx)(A.rX,{fontSize:1,icon:im.amD,padding:2,popover:{arrow:!1,constrainSize:!0,floatingBoundary:o,padding:0,placement:"right-start",fallbackPlacements:["left-start","right","left","right-end","left-end","bottom","top"],preventOverflow:!0,width:r,__unstable_margins:[4,4,4,4]},space:2,text:t,children:(0,p.jsx)(iN,{node:n,onSelect:i})})};async function i1(e){let{doc:t,node:n,parent:r}=e,i=[];if(i.push(...iJ(e)),i.push(...iK(e)),i.push(...await iZ(e)),r.options?.insertMenu){let e=(r.options.insertMenu||{}).views?.some(e=>"grid"===e.name)?0:void 0;i.push({type:"custom",component:({boundaryElement:i,sendTelemetry:o})=>(0,p.jsx)(i0,{label:"Insert before",onSelect:e=>{iH(n,t,e.name,"before")(),o("Visual Editing Context Menu Item Inserted",null)},parent:r,width:e,boundaryElement:i})}),i.push({type:"custom",component:({boundaryElement:i,sendTelemetry:o})=>(0,p.jsx)(i0,{label:"Insert after",onSelect:e=>{iH(n,t,e.name,"after")(),o("Visual Editing Context Menu Item Inserted",null)},parent:r,width:e,boundaryElement:i})})}else i.push({type:"group",label:"Insert before",icon:im.SKY,items:r.of.filter(e=>"unionOption"===e.type).map(e=>({type:"action",icon:iC(e),label:"block"===e.name?"Paragraph":e.title||e.name,action:iH(n,t,e.name,"before"),telemetryEvent:"Visual Editing Context Menu Item Inserted"}))}),i.push({type:"group",label:"Insert after",icon:im.amD,items:r.of.filter(e=>"unionOption"===e.type).map(e=>({type:"action",label:"block"===e.name?"Paragraph":e.title||e.name,icon:iC(e),action:iH(n,t,e.name,"after"),telemetryEvent:"Visual Editing Context Menu Item Inserted"}))});return i}let i2=[-4,4,-4,4];function i5(e){let{node:t,onDismiss:n,boundaryElement:r}=e,i=iL(),o=(0,m.useCallback)(()=>{"action"===t.type&&(t.action?.(),n?.(),t.telemetryEvent&&i(t.telemetryEvent,null))},[t,n,i]);if("divider"===t.type)return(0,p.jsx)(A.Nj,{});if("action"===t.type)return(0,p.jsx)(A.Dr,{fontSize:1,hotkeys:t.hotkeys,icon:t.icon,padding:2,space:2,text:t.label,disabled:!t.action,onClick:o});if("group"===t.type)return(0,p.jsx)(A.rX,{fontSize:1,icon:t.icon,padding:2,popover:{arrow:!1,constrainSize:!0,placement:"right-start",fallbackPlacements:["left-start","right","left","right-end","left-end","bottom","top"],preventOverflow:!0,__unstable_margins:i2},space:2,text:t.label,children:t.items.map((e,t)=>(0,p.jsx)(i5,{node:e,onDismiss:n,boundaryElement:r},t))});
29if("custom"===t.type){let{component:e}=t;return(0,p.jsx)(e,{boundaryElement:r,sendTelemetry:i})}return null}let i3=e=>{let{node:t,onDismiss:n,position:{x:r,y:i}}=e,[o,a]=(0,m.useState)(null),{getField:s}=iX(),{getDocument:u}=ri(),{field:l,parent:c}=s(t),d=(0,m.useMemo)(()=>l?.title||l?.name||"Unknown type",[l]),[f,y]=(0,m.useState)(void 0);(0,m.useEffect)(()=>{(async()=>{let e=u(t.id);e&&y(await function(e){let{node:t,field:n,parent:r,doc:i}=e;return n?.type==="arrayItem"?iQ({node:t,field:n,doc:i}):r?.type==="union"?i1({node:t,parent:r,doc:i}):Promise.resolve([])}({node:t,field:l,parent:c,doc:e}))})()},[l,t,c,u]);let h=(0,m.useMemo)(()=>({getBoundingClientRect:()=>({bottom:i,left:r,right:r,top:i,width:0,height:0})}),[r,i]),g=(0,m.useMemo)(()=>iC(l),[l]);return(0,p.jsx)(iT,{setBoundaryElement:a,onDismiss:n,children:(0,p.jsx)(A.AM,{__unstable_margins:i2,arrow:!1,open:!0,placement:"right-start",referenceElement:h,content:(0,p.jsxs)(A.W1,{style:{minWidth:120,maxWidth:160},children:[(0,p.jsxs)(A.so,{gap:2,padding:2,children:[(0,p.jsx)(A.az,{flex:"none",children:f?(0,p.jsx)(A.EY,{size:1,children:g}):(0,p.jsx)(A.y$,{size:1})}),(0,p.jsx)(A.BJ,{flex:1,space:2,children:(0,p.jsx)(A.EY,{size:1,weight:"semibold",children:f?d:"Loading..."})})]}),f&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(A.Nj,{}),f.map((e,t)=>(0,p.jsx)(i5,{node:e,onDismiss:n,boundaryElement:o},t))]})]}),children:(0,p.jsx)("div",{style:{position:"absolute",left:r,top:i}},`${r}-${i}`)})})},i4=(0,m.createContext)(null),i9=e=>(0,m.isValidElement)(e),i6=(0,O.I4)(A.Zp)`
30  background-color: var(--overlay-bg);
31  border-radius: 3px;
32  pointer-events: none;
33  position: absolute;
34  will-change: transform;
35  box-shadow: var(--overlay-box-shadow);
36  transition: none;
37
38  --overlay-bg: transparent;
39  --overlay-box-shadow: inset 0 0 0 1px transparent;
40
41  [data-overlays] & {
42    --overlay-bg: color-mix(in srgb, transparent 95%, var(--card-focus-ring-color));
43    --overlay-box-shadow: inset 0 0 0 2px
44      color-mix(in srgb, transparent 50%, var(--card-focus-ring-color));
45  }
46
47  [data-fading-out] & {
48    transition:
49      box-shadow 1550ms,
50      background-color 1550ms;
51
52    --overlay-bg: rgba(0, 0, 255, 0);
53    --overlay-box-shadow: inset 0 0 0 1px transparent;
54  }
55
56  &[data-focused] {
57    --overlay-box-shadow: inset 0 0 0 1px var(--card-focus-ring-color);
58  }
59
60  &[data-hovered]:not([data-focused]) {
61    transition: none;
62    --overlay-box-shadow: inset 0 0 0 2px var(--card-focus-ring-color);
63  }
64
65  /* [data-unmounted] & {
66    --overlay-box-shadow: inset 0 0 0 1px var(--card-focus-ring-color);
67  } */
68
69  :link {
70    text-decoration: none;
71  }
72`,i8=(0,O.I4)(A.so)`
73  bottom: 100%;
74  cursor: pointer;
75  pointer-events: none;
76  position: absolute;
77  right: 0;
78
79  [data-hovered] & {
80    pointer-events: all;
81  }
82
83  [data-flipped] & {
84    bottom: auto;
85    top: 100%;
86  }
87`,i7=(0,O.I4)(A.so)`
88  bottom: 100%;
89  cursor: pointer;
90  pointer-events: none;
91  position: absolute;
92  left: 0;
93
94  [data-hovered] & {
95    pointer-events: all;
96  }
97
98  [data-flipped] & {
99    bottom: auto;
100    top: 100%;
101  }
102`,oe=(0,O.I4)(A.Zp)`
103  cursor: pointer;
104  background-color: var(--card-focus-ring-color);
105  right: 0;
106  border-radius: 3px;
107
108  & [data-ui='Text'] {
109    color: #fff;
110    white-space: nowrap;
111  }
112`,ot=(0,O.I4)(A.so)`
113  display: flex;
114  align-items: center;
115  background-color: var(--card-focus-ring-color);
116  right: 0;
117  border-radius: 3px;
118  & [data-ui='Text'],
119  & [data-sanity-icon] {
120    color: #fff;
121    white-space: nowrap;
122  }
123`,on=e=>{let{element:t,focused:n,componentResolver:r,node:i,showActions:o,draggable:a}=e,{getField:s,getType:u}=iX(),l=u(i),{field:c,parent:d}=s(i),f="path"in i?function(e){let{id:t,type:n,path:r,baseUrl:i,tool:o,workspace:a}=e;return function(e){let{baseUrl:t,workspace:n="default",tool:r="default",id:i,type:o,path:a,projectId:s,dataset:u}=e;if(!t)throw Error("baseUrl is required");if(!a)throw Error("path is required");if(!i)throw Error("id is required");if("/"!==t&&t.endsWith("/"))throw Error("baseUrl must not end with a slash");let l="default"===n?void 0:n,c="default"===r?void 0:r,d=C(i),p=Array.isArray(a)?E(a.map(e=>{if("string"==typeof e||"number"==typeof e)return e;if(""!==e._key)return{_key:e._key};if(-1!==e._index)return e._index;throw Error(`invalid segment:${JSON.stringify(e)}`)})):a,f=new URLSearchParams({baseUrl:t,id:d,type:o,path:p});if(l&&f.set("workspace",l),c&&f.set("tool",c),s&&f.set("projectId",s),u&&f.set("dataset",u),M(i)||$(i)){if($(i)){let e=function(e){if(!$(e))return;let[t,n,...r]=e.split(".");return n}(i);f.set("perspective",e)}}else f.set("perspective","published");let m=["/"===t?"":t];l&&m.push(l);let y=["mode=presentation",`id=${d}`,`type=${o}`,`path=${encodeURIComponent(p)}`];return c&&y.push(`tool=${c}`),m.push("intent","edit",`${y.join(";")}?${f}`),m.join("/")}({baseUrl:i,workspace:a,tool:o,type:n,id:t,path:function(e){let t="";for(let n of e){if("string"==typeof n){t&&(t+="."),t+=n;continue}if("number"==typeof n){t&&(t+=":"),t+=`${n}`;continue}if(null!==n&&Array.isArray(n)){t&&(t+=":"),t+=`${n.join(",")}}`;continue}if(n._key){t&&(t+=":"),t+=`${n._key}`;continue}}return t}(k.fromString(r))})}(i):i.href,y=function(){let e=(0,m.useContext)(i4);if(!e)throw Error("Preview Snapshots context is missing");return e}(),h=(0,m.useMemo)(()=>
123{if("path"in i)return y.find(e=>e._id===i.id)?.title},[i,y]),g=(0,m.useMemo)(()=>{if(!("path"in i)||!c||!l)return;let e=c.value.type;return{document:l,element:t,field:c,focused:!!n,node:i,parent:d,type:e}},[l,t,c,n,i,d]),v=function(e,t){return(0,m.useMemo)(()=>{if(!e)return;let n=t?.(e);if(n)return i9(n)?n:(Array.isArray(n)?n:[n]).map(e=>"object"==typeof e&&"component"in e?e:{component:e,props:{}})},[t,e])}(g,r),b=l?.icon?(0,p.jsx)("div",{dangerouslySetInnerHTML:{__html:l.icon}}):(0,p.jsx)(im.pyG,{});return(0,p.jsxs)(p.Fragment,{children:[o?(0,p.jsx)(i8,{gap:1,paddingY:1,"data-sanity-overlay-element":!0,children:(0,p.jsx)(oi,{href:f})}):null,h&&(0,p.jsx)(i7,{gap:1,paddingY:1,children:(0,p.jsxs)(ot,{gap:2,padding:2,children:[a&&(0,p.jsx)(A.az,{marginRight:1,children:(0,p.jsx)(A.EY,{className:"drag-handle",size:0,children:(0,p.jsx)(im.GG1,{})})}),(0,p.jsx)(A.EY,{size:0,children:b}),(0,p.jsx)(A.EY,{size:1,weight:"medium",children:h})]})}),Array.isArray(v)?v.map(({component:e,props:t},n)=>(0,p.jsx)(e,{PointerEvents:iU,...g,...t},n)):v]})},or=(0,m.memo)(function(e){let{draggable:t,focused:n,hovered:r,rect:i,wasMaybeCollapsed:o,enableScrollIntoView:a}=e,s=(0,m.useRef)(null),u=(0,m.useRef)(!1),l=(0,m.useMemo)(()=>({width:`${i.w}px`,height:`${i.h}px`,transform:`translate(${i.x}px, ${i.y}px)`}),[i]);(0,m.useEffect)(()=>{if(!u.current&&!o&&!0===n&&s.current&&a){let e=s.current;(0,iV.A)(s.current,{behavior:t=>{0!==t.length&&e.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})},scrollMode:"if-needed",block:"center",inline:"nearest"})}u.current=!0===n},[n,o,a]);let[c,d]=(0,m.useState)(!1);return(0,m.useEffect)(()=>{if(!s.current||!r)return;let e=new IntersectionObserver(([e])=>{d(e.boundingClientRect.top<0)},{threshold:1});return e.observe(s.current),()=>e.disconnect()},[r,c]),(0,p.jsx)(i6,{"data-focused":n?"":void 0,"data-hovered":r?"":void 0,"data-flipped":c?"":void 0,"data-draggable":t?"":void 0,ref:s,style:l,children:r&&(0,p.jsx)(on,{...e})})}),oi=(0,m.memo)(function(e){let t=(0,m.useSyncExternalStore)((0,m.useCallback)(e=>{let t=()=>e();return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[]),()=>window.location.href),n=(0,m.useMemo)(()=>(function e(t,n){try{let r=new URL(t,typeof location>"u"?void 0:location.origin);if(r.hash){let t=new URL(e(r.hash.slice(1),n));return`${r.origin}${r.pathname}${r.search}#${t.pathname}${t.search}`}return r.searchParams.set("preview",n),r.toString()}catch{return t}})(e.href,t),[e.href,t]);return(0,p.jsx)(A.az,{as:"a",href:n,target:"_blank",rel:"noopener noreferrer",children:(0,p.jsx)(oe,{padding:2,children:(0,p.jsx)(A.EY,{size:1,weight:"medium",children:"Open in Studio"})})})}),oo=({dragGroupRect:e})=>(0,p.jsx)("div",{style:{position:"absolute",top:`${e.y}px`,left:`${e.x}px`,width:`${e.w-1}px`,height:`${e.h-1}px`,border:"1px dashed #f0709b",pointerEvents:"none"}}),oa=({dragInsertPosition:e})=>{if(null===e)return;let t=e?.left||e?.right?"horizontal":"vertical",n=0,r=0,i=0,o=0;if("horizontal"===t){let{left:t,right:a}=e;if(i=6,a&&t){let e=t.rect.x+t.rect.w,i=a.rect.x,s=.0125*Math.min(a.rect.h,t.rect.h);n=.5*e+.5*i-3,r=t.rect.y+s,o=Math.min(a.rect.h,t.rect.h)-2*s}else if(a&&!t){let e=.0125*a.rect.h;n=a.rect.x-3,r=a.rect.y+e,o=a.rect.h-2*e}else if(t&&!a){let e=.0125*t.rect.h;n=t.rect.x+t.rect.w-3,r=t.rect.y+e,o=t.rect.h-2*e}}else{let{bottom:t,top:a}=e;if(t&&a){let e=Math.min(a.rect.x,t.rect.x),s=a.rect.y+a.rect.h,u=t.rect.y,l=.0125*Math.min(t.rect.w,a.rect.w);o=6,n=e+l,r=.5*s+.5*u-3,i=Math.max(t.rect.w,a.rect.w)-2*l}else if(t&&!a){let e=.0125*t.rect.w;n=t.rect.x+e,r=t.rect.y-3,i=t.rect.w-2*e,o=6}else if(a&&!t){let e=.0125*a.rect.w;n=a.rect.x+e,r=a.rect.y+a.rect.h-3,i=a.rect.w-2*e,o=6}}return(0,p.jsx)("div",{style:{position:"absolute",width:`${i}px`,height:`${o}px`,transform:`translate(${n}px, ${r}px)`,background:"#556bfc",border:"2px solid white",borderRadius:"999px",zIndex:"999999"}})},os=O.I4.div`
124  --drag-preview-opacity: 0.98;
125  --drag-preview-skeleton-stroke: #ffffff;
126
127  @media (prefers-color-scheme: dark) {
128    --drag-preview-skeleton-stroke: #383d51;
129  }
130
131  position: fixed;
132  display: grid;
133  transform: ${({$scaleFactor:e,$width:t,$height:n})=>`translate(calc(var(--drag-preview-x) - ${t/2}px), calc(var(--drag-preview-y) - ${n/2}px)) scale(${e})`};
134  width: ${({$width:e})=>`${e}px`};
135  height: ${({$height:e})=>`${e}px`};
136  z-index: 9999999;
137  opacity: var(--drag-preview-opacity);
138  cursor: move;
139
140  .drag-preview-content-wrapper {
141    position: relative;
142    width: 100%;
143    height: 100%;
144    container-type: inline-size;
145  }
146
147  [data-ui='card'] {
148    position: relative;
149    width: 100%;
150    height: 100%;
151  }
152
153  .drag-preview-skeleton {
154    position: absolute;
155    inset: 0;
156
157    rect {
158      stroke: var(--drag-preview-skeleton-stroke);
159    }
160  }
161
162  .drag-preview-handle {
163    position: absolute;
164    top: 4cqmin;
165    left: 4cqmin;
166    width: 6cqmin;
167    fill: var(--drag-preview-handle-fill);
168  }
169`,ou=({skeleton:e})=>{let t=Math.min(e.maxWidth,window.innerWidth/2),n=e.w>t?t/e.w:1,r=e.offsetX*n,i=e.offsetY*n,o=(0,A.Xy)(),a=(0,A.M4)(),s=a.radius[~~function(e,t,n,r,i){var o;return(o=(e-0)*(i-1)/1920+1)<1?r:o>i?i:o}(e.w,0,0,1,a.radius.length-2)],u=e.childRects.filter(e=>"IMG"===e.tagName),l=e.childRects.filter(e=>"IMG"!==e.tagName);return(0,p.jsx)(os,{$width:e.w,$height:e.h,$offsetX:r,$offsetY:i,$scaleFactor:n,children:(0,p.jsx)(A.Zp,{radius:s,shadow:4,overflow:"hidden",tone:"transparent",scheme:o?"dar
169k":"light",children:(0,p.jsx)("div",{className:"drag-preview-content-wrapper",children:(0,p.jsx)("svg",{className:"drag-preview-skeleton",viewBox:`0 0 ${e.w} ${e.h}`,children:[...u,...l].map((e,t)=>(0,p.jsx)("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:a.color.skeleton.from},t))})})})})},ol=(0,O.I4)(A.Zp)`
170  position: fixed;
171  bottom: 2rem;
172  left: 2rem;
173`,oc=()=>(0,p.jsx)(ol,{padding:2,shadow:2,radius:2,style:{zIndex:"999999"},children:(0,p.jsxs)(A.so,{align:"center",gap:2,children:[(0,p.jsx)(A.qW,{keys:["Shift"]}),(0,p.jsx)(A.EY,{size:1,children:"Zoom Out"}),(0,p.jsx)(im.mSu,{})]})}),od=(e,t)=>{let{type:n}=t;switch(n){case"element/register":return e.find(e=>e.id===t.id)?e:[...e,{id:t.id,activated:!1,element:t.element,focused:!1,hovered:!1,rect:t.rect,sanity:t.sanity,dragDisabled:t.dragDisabled}];case"element/activate":return e.map(e=>e.id===t.id?{...e,activated:!0}:e);case"element/update":return e.map(e=>e.id===t.id?{...e,sanity:t.sanity,rect:t.rect}:e);case"element/unregister":return e.filter(e=>e.id!==t.id);case"element/deactivate":return e.map(e=>e.id===t.id?{...e,activated:!1,hovered:!1}:e);case"element/mouseenter":return e.map(e=>e.id===t.id?{...e,rect:t.rect,hovered:!0}:{...e,hovered:!1});case"element/mouseleave":return e.map(e=>e.id===t.id?{...e,hovered:!1}:e);case"element/updateRect":return e.map(e=>e.id===t.id?{...e,rect:t.rect}:e);case"element/click":return e.map(e=>({...e,focused:e.id===t.id&&"clicked"}));case"overlay/blur":return e.map(e=>({...e,focused:!1}));case"presentation/blur":return e.map(e=>({...e,focused:!1}));case"presentation/focus":{let n=e.find(e=>"clicked"===e.focused);return e.map(e=>{let r="path"in e.sanity&&e.sanity.id===t.data.id&&e.sanity.path===t.data.path;return n&&e===n&&r?e:{...e,focused:r&&n?"duplicate":r}})}default:return e}};function op(e,t){let{type:n}=t,{contextMenu:r,focusPath:i,perspective:o,isDragging:a,dragInsertPosition:s,dragShowMinimap:u,dragShowMinimapPrompt:l,dragSkeleton:c,dragMinimapTransition:d,dragGroupRect:p}=e,f=!1;if("presentation/focus"===n){let n=e.focusPath;n!==(i=t.data.path)&&(f=n.slice(i.length).startsWith("["))}return"presentation/perspective"===n&&(o=t.data.perspective),"element/contextmenu"===n&&(r="sanity"in t?{node:t.sanity,position:t.position}:null),("element/click"===n||"element/mouseleave"===n||"overlay/blur"===n||"presentation/blur"===n||"presentation/focus"===n)&&(r=null),"overlay/dragUpdateInsertPosition"===n&&(s=t.insertPosition),"overlay/dragStart"===n&&(a=!0),"overlay/dragUpdateSkeleton"===t.type&&(c=t.skeleton),"overlay/dragEnd"===n&&(a=!1),"overlay/dragToggleMinimapPrompt"===t.type&&(l=t.display),"overlay/dragStartMinimapTransition"===n&&(d=!0),"overlay/dragEndMinimapTransition"===n&&(d=!1),"overlay/dragUpdateGroupRect"===n&&(p=t.groupRect),"overlay/dragToggleMinimap"===n&&(u=t.display),{...e,contextMenu:r,elements:od(e.elements,t),dragInsertPosition:s,dragSkeleton:c,dragGroupRect:p,isDragging:a,focusPath:i,perspective:o,wasMaybeCollapsed:f,dragShowMinimap:u,dragShowMinimapPrompt:l,dragMinimapTransition:d}}let of=function(e){let{comlink:t,children:n}=e,[r,i]=(0,m.useState)([]),o=(0,m.useCallback)(async e=>{if(t)try{let n=await t.fetch("visual-editing/preview-snapshots",void 0,{signal:e,suppressWarnings:!0});i(n.snapshots)}catch{}},[t]);(0,m.useEffect)(()=>{if(!t)return;let e=new AbortController,n=t.onStatus(()=>{o(e.signal)},"connected");return()=>{e.abort(),n()}},[t,o]),(0,m.useEffect)(()=>t?.on("presentation/preview-snapshots",e=>{i(e.snapshots)}),[t]);let a=(0,m.useMemo)(()=>r,[r]);return(0,p.jsx)(i4.Provider,{value:a,children:n})};function om(e){return"document"===e.type}function oy(e){return"type"===e.type}let oh=function(e){let{comlink:t,children:n,elements:r}=e,[i,o]=(0,m.useState)(new Map),[a,s]=(0,m.useState)(null),u=(0,m.useCallback)(async e=>{if(t)try{let n=await t.fetch("visual-editing/schema",void 0,{signal:e,suppressWarnings:!0});s(n.schema)}catch{}},[t]);(0,m.useEffect)(()=>{if(!t)return;let e=new AbortController,n=t.onStatus(()=>{u(e.signal)},"connected");return()=>{e.abort(),n()}},[t,u]);let l=(0,m.useRef)([]);(0,m.useEffect)(()=>{let e=async(e,n)=>{if(!(!e.length||!t))try{let r=await t.fetch("visual-editing/schema-union-types",{paths:e},{signal:n,suppressWarnings:!0});o(r.types),l.current=e}catch{}},n=new AbortController,i=r.reduce((e,t)=>
173{let{sanity:n}=t;if(!("id"in n)||!n.path.includes("[_key=="))return e;let r=n.path.split(".").toReversed().reduce((e,t)=>e.length?[t,...e]:t.includes("[_key==")?[t]:[],[]).join(".");return e.find(e=>e.id===n.id&&e.path===r)||e.push({id:n.id,path:r}),e},[]);return i.some(e=>!l.current.find(({id:t,path:n})=>t===e.id&&n===e.path))&&e(i,n.signal),()=>n.abort()},[t,r]);let c=(0,m.useCallback)((e,t)=>{if(!a||"string"!=typeof e&&(!("path"in e)||!Array.isArray(a)))return;let n="string"==typeof e?e:e.type;return a.filter("document"===(t||"document")?om:oy).find(e=>e.name===n)},[a]),d=(0,m.useCallback)(e=>{if(!("path"in e))return{field:void 0,parent:void 0};let t=c(e);if(!t)return{field:void 0,parent:void 0};let n=e.path.split(".").flatMap(e=>e.includes("[")?e.split(/(\[.+\])/,2):[e]);try{return function t(n,r,o,a=[]){if(!n)return{field:void 0,parent:void 0};let[s,...u]=r;if("fields"in n){let e=n.fields[s];if(!e&&"rest"in n)return t(n.rest,r,n,a);if(!u.length)return{field:e,parent:o};if(!e)throw Error(`[@sanity/visual-editing] No field could be resolved at path: "${[...a,...r].join(".")}"`);return t(e.value,u,n,[...a,s])}if("array"===n.type)return t(n.of,r,n,a);if("arrayItem"===n.type)return u.length?t(n.value,u,n,[...a,s]):{field:n,parent:o};if("union"===n.type){let r=s.startsWith("[_key==")?i?.get(e.id)?.get([a.join("."),s].filter(Boolean).join("")):s;return t(n.of.find(e=>"unionOption"===e.type?e.name===r:e),u,n,[...a,s])}if("unionOption"===n.type)return s?t(n.value,r,n,a):{field:n,parent:o};if("inline"===n.type)return t(c(n.name,"type").value,r,n,a);throw Error(`[@sanity/visual-editing] No field could be resolved at path: "${[...a,...r].join(".")}"`)}(t,n,void 0)}catch(e){return e instanceof Error&&console.warn(e.message),{field:void 0,parent:void 0}}},[c,i]),f=(0,m.useMemo)(()=>({getField:d,getType:c,resolvedTypes:i,schema:a||[]}),[d,c,i,a]);return(0,p.jsx)(iG.Provider,{value:f,children:n})},og=(e=>{let t=e,n=new Set;return{getState:()=>t,setState:e=>{t=e(t),n.forEach(e=>e())},subscribe:e=>(n.add(e),()=>n.delete(e))}})({}),ov=e=>{let{comlink:t,children:n}=e;(0,m.useEffect)(()=>t?.on("presentation/shared-state",e=>{"value"in e?og.setState(t=>({...t,[e.key]:e.value})):og.setState(t=>Object.fromEntries(Object.entries(t).filter(([t])=>t!==e.key)))}),[t]),(0,m.useEffect)(()=>{(async function(){let e=await t?.fetch("visual-editing/shared-state",void 0,{suppressWarnings:!0});e&&og.setState(()=>e.state)})().catch(e=>{console.debug(e),console.warn("[@sanity/visual-editing]: Failed to fetch shared state. Check your version of `sanity` is up-to-date")})},[t]);let r=(0,m.useMemo)(()=>({comlink:t,store:og}),[t]);return(0,p.jsx)(id.Provider,{value:r,children:n})},ob=({children:e,comlink:t})=>{let n=(0,m.useCallback)((e,n)=>{if(!t)return;let r=iR[e];if(r)t.post("visual-editing/telemetry-log",{event:r,data:n});else throw Error(`Telemetry event: ${e} does not exist`)},[t]);return(0,p.jsx)(iz.Provider,{value:n,children:e})},ow=O.I4.div`
174  background-color: transparent;
175  direction: ltr;
176  inset: 0;
177  pointer-events: none;
178  position: absolute;
179  width: 100%;
180  height: 100%;
181  z-index: ${({$zIndex:e})=>e??"9999999"};
182`;function ox(e){let t,n;return t=requestAnimationFrame(()=>{n=requestAnimationFrame(e)}),()=>{void 0!==t&&cancelAnimationFrame(t),void 0!==n&&cancelAnimationFrame(n)}}let oE=e=>{let{documentIds:t}=e,[n,r]=(0,m.useState)([]);(0,m.useEffect)(()=>{r(e=>{let n=Array.from(new Set(t));return e.length===n.length&&e.reduce((e,t)=>e.filter(e=>e!==t),n)?.length===0?e:n})},[t]);let i=re();return(0,m.useEffect)(()=>{for(let e of n)i.send({type:"observe",documentId:S(e)}),i.send({type:"observe",documentId:C(e)});return()=>{for(let e of n)i.send({type:"unobserve",documentId:S(e)}),i.send({type:"unobserve",documentId:C(e)})}},[i,n]),null},oj=e=>{let{comlink:t,dispatch:n,inFrame:i,inPopUp:o,onDrag:a,overlayEnabled:s,rootElement:u}=e,{dispatchDragEndEvent:l}=function(){let{getDocument:e}=ri();return(0,m.useEffect)(()=>{let t=t=>{let{insertPosition:n,target:r,preventInsertDefault:i}=t.detail;if(i)return;let o=function(e){if(e){let{top:t,right:n,bottom:r,left:i}=e;if(i||t)return{node:(i??t).sanity,position:"after"};if(n||r)return{node:(n??r).sanity,position:"before"}}}(n);if(o){let t=e(r.id),{node:n,position:i}=o,{key:a,hasExplicitKey:s}=rs(r),{path:u,key:l}=rs(n);u&&l&&l!==a&&t.patch(async({getSnapshot:e})=>{let t=n8(await e(),r.path);return s?[G(u,B({_key:a})),G(u,W(t,i,{_key:l}))]:[G(u,B(~~a)),G(u,W(t,i,l>a?~~l-1:~~l))]})}};return window.addEventListener("sanity/dragEnd",t),()=>{window.removeEventListener("sanity/dragEnd",t)}},[e]),{dispatchDragEndEvent:(0,m.useCallback)(e=>{let t=new CustomEvent("sanity/dragEnd",{detail:e,cancelable:!0});window.dispatchEvent(t)},[])}}(),c=iL(),d=function(e,t,n,i){let o=(0,m.useRef)(void 0),a=rt();return(0,m.useEffect)(()=>
182{if(e)return o.current=function({handler:e,overlayElement:t,inFrame:n,inPopUp:i,optimisticActorReady:o}){let a=!1,s=new Map,u=new WeakMap,l=new Set,c=new WeakMap,d=new WeakMap,p,f,m,y=!1,h=[],g=()=>h[h.length-1];function v(e,t){e.removeEventListener("click",t.click,{capture:!0}),e.removeEventListener("contextmenu",t.contextmenu,{capture:!0}),e.removeEventListener("mousemove",t.mousemove,{capture:!0}),e.removeEventListener("mousedown",t.mousedown,{capture:!0}),e.removeEventListener("mouseenter",t.mouseenter),e.removeEventListener("mouseleave",t.mouseleave)}function b({id:t,elements:n,handlers:r}){let{element:i,measureElement:o}=n;i.addEventListener("click",r.click,{capture:!0}),i.addEventListener("contextmenu",r.contextmenu,{capture:!0}),i.addEventListener("mousemove",r.mousemove,{once:!0,capture:!0}),i.addEventListener("mousedown",r.mousedown,{capture:!0}),p.observe(o),e({type:"element/activate",id:t})}function w({id:t,elements:n,handlers:r}){let{element:i,measureElement:o}=n;v(i,r),p.unobserve(o),h=h.filter(e=>e!==i),e({type:"element/deactivate",id:t})}function x(t){if(!(!n&&!i||!o))for(let n of h){if(t===n){let n=u.get(t)?.sanity;if(!n||!ia(n))return;if(ic(t,n,l,u)){let n=t.style.cursor;n&&d.set(t,n),e({type:"overlay/setCursor",element:t,cursor:"move"});continue}}E(n)}}function E(t){let n=d.get(t);e({type:"overlay/setCursor",element:t,cursor:n})}function j(d){for(let p of function e(t){let n=[];function r(e,t){let r=function(e){if("object"==typeof e&&null!==e)return rO(e);try{let t=JSON.parse(e);return rO(t)}catch{return function(e){var t;let n=e.split(";").reduce((e,t)=>{let[n,r]=t.split("=");if(!n||t.includes("=")&&!r)return e;switch(n){case"id":e.id=r;break;case"type":e.type=r;break;case"path":e.path=k.toString(function(e){let t=[];for(let n of e.split(".")){let e=rM.exec(n);if(e){t.push(e[1],Number(e[2]));continue}let r=r$.exec(n);if(r){t.push(r[1],[Number(r[2]),Number(r[3])]);continue}let i=rS.exec(n);if(i){t.push(i[1],{_key:i[2]});continue}t.push(n)}return t}(r));break;case"base":e.baseUrl=decodeURIComponent(r);break;case"tool":e.tool=r;break;case"workspace":e.workspace=r;break;case"projectId":e.projectId=r;break;case"dataset":e.dataset=r}return e},{});if(t=n,!rI._run({typed:!1,value:t},{abortEarly:!0}).issues)return n}(e)}}(t);if(!r)return;let i=function e(t){let{display:n}=window.getComputedStyle(t);if("inline"!==n)return t;let r=t.parentElement;return r?e(r):null}(e);i&&n.push({elements:{element:e,measureElement:i},sanity:r})}if(t)for(let i of t.childNodes){let{nodeType:t,parentElement:o,textContent:a}=i;if(it(i)&&i.dataset?.sanityEditTarget!==void 0){let t=e(i).map(({sanity:e})=>e);if(!t.map(e=>ia(e)).every((e,t,n)=>e===n[0]))continue;let r=function(e){if(!e.length||!e.map(e=>ia(e)).every((e,t,n)=>e===n[0]))return;if(!ia(e[0]))return e[0];let t=e.filter(ia),n=e[0],r=["projectId","dataset","id","baseUrl","workspace","tool"];for(let e=1;e<t.length;e++){let i=t[e];if(r.some(e=>i[e]!==n?.[e])){n=void 0;break}n.path=function(e,t){let n=e.split("."),r=t.split("."),i=Math.min(n.length,r.length);return n=n.slice(0,i).reverse(),r=r.slice(0,i).reverse(),n.reduce((e,t,n)=>t===r[n]?[...e,t]:[],[]).reverse().join(".")}(n.path,i.path)}return n}(t);r&&n.push({elements:{element:i,measureElement:i},sanity:r})}else if(t===Node.TEXT_NODE&&o&&a){let e=ie(a);if(!e)continue;r(o,e)}else if(it(i)){if("SCRIPT"===i.tagName||"SANITY-VISUAL-EDITING"===i.tagName)continue;if(i.dataset?.sanity)r(i,i.dataset.sanity);else if(i.dataset?.sanityEditInfo)r(i,i.dataset.sanityEditInfo);else if(ir(i)){let e=ie(i.alt,!0);if(!e)continue;r(i,e);continue}else if(ii(i)){let e=ie(i.dateTime,!0);if(!e)continue;r(i,e)}else if(io(i)){if(!i.ariaLabel)continue;let e=ie(i.ariaLabel,!0);if(!e)continue;r(i,e)}n.push(...e(i))}}return n}(d)){let{element:d}=p.elements;u.has(d)?function({elements:t,sanity:n}){let{element:r}=t,i=u.get(r);i&&(u.set(r,{...i,sanity:n}),e({type:"element/update",id:i.id,rect:rF(r),sanity:n}))}(p):function({elements:d,sanity:p}){let{element:m,measureElement:v}=d,w={click(t){let r=t.target;if(m===g()&&m.contains(r)){n&&(t.preventDefault(),t.stopPropagation());let r=u.get(m)?.sanity;r&&!y&&e({type:"element/click",id:j,sanity:r})}},contextmenu(t){if(!("path"in p)||!n&&!i||!o||!p.path.split(".").pop()?.includes("[_key=="))return;let r=t.target;m===g()&&m.contains(r)&&((n||i)&&(t.preventDefault(),t.stopPropagation()),e({type:"element/contextmenu",id:j,position:{x:t.clientX,y:t.clientY},sanity:p}))},mousedown(t){if(t.preventDefault(),t.currentTarget!==h.at(-1)||m.getAttribute("data-sanity-drag-disable")||!n&&!i||!o)return;let r=u.get(m)?.sanity;if(!r||!ia(r)||!is(r.path))return;let a=ic(m,p,l,u);a&&function(e){var t;let{mouseEvent:n,element:r,overlayGroup:i,handler:o,target:a,onSequenceStart:s,onSequenceEnd:u}=e;if(0!==n.button)return;window.focus();let l=i.map(e=>rF(e.elements.element)),c=r.getAttribute("data-sanity-drag-flow")||((t=l).some(e=>t.filter(t=>!rY(e,t)).some(t=>e.y===t.y))?"horizontal":"vertical"),d=r.getAttribute("data-sanity-drag-group"),p=!!r.getAttribute("data-sanity-drag-minima
182p-disable"),f=!!r.getAttribute("data-sanity-drag-prevent-default"),m=r.getAttribute("data-unstable_sanity-drag-document-height"),y=r.getAttribute("data-unstable_sanity-drag-group-height"),h=null,g=rZ(n),v=document.body,{minYScaled:b,scaleFactor:w}=function(e,t){let n=t||rH(e).height,r=(n+=200)>window.innerHeight?window.innerHeight/n:1,{min:i}=rH(e.map(e=>rX(e,r,{x:window.innerWidth/2,y:0})));return{scaleFactor:r,minYScaled:i-100*r}}(l,y?~~y:null),x=!1,E=!1,j=!0;r5||(r6={body:{overflow:window.getComputedStyle(document.body).overflow,height:window.getComputedStyle(document.body).height},documentElement:{overflow:window.getComputedStyle(document.documentElement).overflow,height:window.getComputedStyle(document.documentElement).height}},r9=m?~~m:document.documentElement.scrollHeight);let _=setInterval(()=>{l=i.map(e=>rF(e.elements.element))},150),k=()=>{w>=1||(o({type:"overlay/dragUpdateSkeleton",skeleton:rQ(r4,r,w)}),o({type:"overlay/dragToggleMinimapPrompt",display:!1}),r0(v,w,b,o,150).then(()=>{setTimeout(()=>{o({type:"overlay/dragUpdateGroupRect",groupRect:r1(l)})},300)}))},I=e=>{Math.abs(e.deltaY)>=10&&w<1&&!r5&&!E&&!p&&j&&(o({type:"overlay/dragToggleMinimapPrompt",display:!0}),E=!0),!e.shiftKey||r5||p||(window.dispatchEvent(new CustomEvent("unstable_sanity/dragApplyMinimap")),r5=!0,setTimeout(()=>{k()},50))},M=e=>{if(e.preventDefault(),r3=function(e){let t=document.body,n=window.getComputedStyle(t).transform;if("none"===n)return{x:e.x,y:e.y};let r=new DOMMatrix(n).inverse(),i=new DOMPoint(e.x,e.y).matrixTransform(r);return{x:i.x,y:i.y}}(r4=rZ(e)),4>Math.abs(rB(r4,g)))return;if(!x){let e=r1(l),t=rQ(r4,r,1);o({type:"overlay/dragStart",flow:c}),o({type:"overlay/dragUpdateSkeleton",skeleton:t}),o({type:"overlay/dragUpdateGroupRect",groupRect:e}),x=!0,s()}o({type:"overlay/dragUpdateCursorPosition",x:r4.x,y:r4.y}),!e.shiftKey||r5||p||(window.dispatchEvent(new CustomEvent("unstable_sanity/dragApplyMinimap")),r5=!0,setTimeout(()=>{k()},50));let t=function(e,t,n){if("horizontal"===n){let r={x1:e.x,y1:e.y,x2:e.x-1e8,y2:e.y},i={x1:e.x,y1:e.y,x2:e.x+1e8,y2:e.y};return{left:rG(r,t,n),right:rG(i,t,n)}}{let r={x1:e.x,y1:e.y,x2:e.x,y2:e.y-1e8},i={x1:e.x,y1:e.y,x2:e.x,y2:e.y+1e8};return{top:rG(r,t,n),bottom:rG(i,t,n)}}}(r4,l,c);JSON.stringify(h)!==JSON.stringify(t)&&o({type:"overlay/dragUpdateInsertPosition",insertPosition:rK(i,h=t,c)})},$=()=>{j=!1,o({type:"overlay/dragEnd",target:a,insertPosition:h?rK(i,h,c):null,dragGroup:d,flow:c,preventInsertDefault:f}),E&&o({type:"overlay/dragToggleMinimapPrompt",display:!1}
182),r5||(clearInterval(_),u(),T(),O()),A()},S=e=>{"Shift"===e.key&&r5&&(r5=!1,o({type:"overlay/dragUpdateSkeleton",skeleton:rQ(r4,r,1/w)}),window.dispatchEvent(new CustomEvent("unstable_sanity/dragResetMinimap")),setTimeout(()=>{r2(r3.y,v,r9,o,150,r6)},50),o({type:"overlay/dragUpdateGroupRect",groupRect:null}),j||(clearInterval(_),A(),T(),O(),u()))},C=()=>{o({type:"overlay/dragUpdateGroupRect",groupRect:null}),window.dispatchEvent(new CustomEvent("unstable_sanity/dragResetMinimap")),setTimeout(()=>{r2(r3.y,v,r9,o,150,r6).then(()=>{r5=!1})},50),clearInterval(_),A(),T(),O(),u()},A=()=>{window.removeEventListener("mousemove",M),window.removeEventListener("wheel",I),window.removeEventListener("mouseup",$)},O=()=>{window.removeEventListener("keyup",S)},T=()=>{window.removeEventListener("blur",C)};window.addEventListener("blur",C),window.addEventListener("keyup",S),window.addEventListener("wheel",I),window.addEventListener("mousemove",M),window.addEventListener("mouseup",$)}({element:m,handler:e,mouseEvent:t,overlayGroup:a,target:r,onSequenceStart:()=>{y=!0},onSequenceEnd:()=>{setTimeout(()=>{y=!1},250)}})},mousemove(e){w.mouseenter(e);let t=e.currentTarget;t&&(t.addEventListener("mouseenter",w.mouseenter),t.addEventListener("mouseleave",w.mouseleave))},mouseenter(){document.querySelector("vercel-live-feedback")&&m.closest("[data-vercel-edit-info]")||m.closest("[data-vercel-edit-target]")||(h.push(m),e({type:"element/mouseenter",id:j,rect:rF(m)}),x(m))},mouseleave(n){function r(){h.pop();let t=g();if(e({type:"element/mouseleave",id:j}),t){x(t);let n=u.get(t);n&&e({type:"element/mouseenter",id:n.id,rect:rF(t)})}E(m)}let{relatedTarget:i}=n,o=r7(i),a=t.contains(o);if(r8(o)&&a)return function e(t){let n=i=>{let{relatedTarget:o}=i;r7(o)?o&&r8(o)&&(t.removeEventListener("mouseleave",n),e(o)):(t.removeEventListener("mouseleave",n),r())};t.addEventListener("mouseleave",n)}(o);r()}},j=function(e,t,n){if(rq.randomUUID&&!e)return rq.randomUUID();let i=(e=e||{}).random??e.rng?.()??function(){if(!r){if(typeof crypto>"u"||!crypto.getRandomValues)throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");r=crypto.getRandomValues.bind(crypto)}return r(rV)}();if(i.length<16)throw Error("Random bytes length must be >= 16");return i[6]=15&i[6]|64,i[8]=63&i[8]|128,function(e,t=0){return(rU[e[t+0]]+rU[e[t+1]]+rU[e[t+2]]+rU[e[t+3]]+"-"+rU[e[t+4]]+rU[e[t+5]]+"-"+rU[e[t+6]]+rU[e[t+7]]+"-"+rU[e[t+8]]+rU[e[t+9]]+"-"+rU[e[t+10]]+rU[e[t+11]]+rU[e[t+12]]+rU[e[t+13]]+rU[e[t+14]]+rU[e[t+15]]).toLowerCase()}(i)}(),_={id:j,elements:d,sanity:p,handlers:w};l.add(m),c.set(v,m),s.set(j,m),u.set(m,_),f?.observe(m),e({type:"element/register",id:j,element:m,rect:rF(m),sanity:p,dragDisabled:!!m.getAttribute("data-sanity-drag-disable")}),a&&b(_)}(p)}}function _(t){let n=u.get(t);if(n){let{id:r,handlers:i}=n;v(t,i),p.unobserve(t),u.delete(t),l.delete(t),s.delete(r),e({type:"element/unregister",id:r})}}function I(t){let n=u.get(t);n&&e({type:"element/updateRect",id:n.id,rect:rF(t)})}function M(e){if(a)for(let t of e){let{target:e}=t,n=r8(e)&&u.get(e);n&&(t.isIntersecting?b(n):w(n))}}function $(t){let n=r7(t.target);if(n){"capture"===n.dataset.sanityOverlayElement&&(t.preventDefault(),t.stopPropagation());return}h=[],e({type:"overlay/blur"})}function S(){for(let e of l)I(e)}function C(t){"Escape"===t.key&&(h=[],e({type:"overlay/blur"}))}function A(e){let{target:t}=e;if(!(t===window.document||!r8(t)))for(let e of l)t.contains(e)&&I(e)}function O(){a||(f=new IntersectionObserver(M,{threshold:.3}),l.forEach(e=>f.observe(e)),e({type:"overlay/activate"}),a=!0)}function T(){a&&(f?.disconnect(),l.forEach(e=>{let t=u.get(e);t&&w(t)}),e({type:"overlay/deactivate"}),a=!1)}return window.document.fonts.ready.then(()=>{for(let e of l)I(e)}),window.addEventListener("click",$),window.addEventListener("contextmenu",$),window.addEventListener("keydown",C),window.addEventListener("resize",S),window.addEventListener("scroll",A,{capture:!0,passive:!0}),p=new ResizeObserver(function(e){for(let t of e){let e=t.target;if(r8(e)){let t=c.get(e);if(!t)return;I(t)}}}),(m=new MutationObserver(function(e){let n=!1;for(let r of e){let{target:e,type:i}=r,o="characterData"===i?e.parentElement:e;o===t||t.contains(o)||(n=!0,r8(o)&&j({childNodes:[o]}))}if(n)for(let e of l)e.isConnected||_(e)})).observe(document.body,{attributes:!0,characterData:!0,childList:!0,subtree:!0}),j(document.body),O(),{activate:O,deactivate:T,destroy:function(){window.removeEventListener("click",$),window.removeEventListener("contextmenu",$),window.removeEventListener("keydown",C),window.removeEventListener("resize",S),window.removeEventListener("scroll",A),m.disconnect(),p.disconnect(),l.forEach(e
182=>{_(e)}),s.clear(),l.clear(),h=[],T()}}}({handler:t,overlayElement:e,inFrame:n,inPopUp:i,optimisticActorReady:a}),()=>{o.current?.destroy(),o.current=void 0}},[e,t,n,i,a]),o}(u,(0,m.useCallback)(e=>{if("element/click"===e.type){let{sanity:n}=e;t?.post("visual-editing/focus",n),c("Visual Editing Overlay Clicked",null)}else if("overlay/activate"===e.type)t?.post("visual-editing/toggle",{enabled:!0});else if("overlay/deactivate"===e.type)t?.post("visual-editing/toggle",{enabled:!1});else if("overlay/dragEnd"===e.type){let{insertPosition:t,target:n,dragGroup:r,flow:i,preventInsertDefault:o}=e;l({insertPosition:t,target:n,dragGroup:r,flow:i,preventInsertDefault:o}),t&&c("Visual Editing Drag Sequence Completed",null)}else if("overlay/dragUpdateCursorPosition"===e.type){a(e.x,e.y);return}else if("overlay/dragToggleMinimap"===e.type&&!0===e.display)c("Visual Editing Drag Minimap Enabled",null);else if("overlay/setCursor"===e.type){let{element:t,cursor:n}=e;n?t.style.cursor=n:t.style.removeProperty("cursor")}n(e)},[t,n,l,a,c]),i,o);return(0,m.useEffect)(()=>{s?d.current?.activate():d.current?.deactivate()},[d,s]),null},o_=e=>{let{comlink:t,comlinkStatus:n,componentResolver:r,inFrame:i,inPopUp:o,zIndex:a}=e,s=(0,A.Xy)(),[{contextMenu:u,dragInsertPosition:l,dragShowMinimap:c,dragShowMinimapPrompt:d,dragSkeleton:f,elements:y,isDragging:h,perspective:g,wasMaybeCollapsed:v,dragMinimapTransition:b,dragGroupRect:w},x]=(0,m.useReducer)(op,{contextMenu:null,dragInsertPosition:null,dragShowMinimap:!1,dragShowMinimapPrompt:!1,dragSkeleton:null,elements:[],focusPath:"",isDragging:!1,perspective:"published",wasMaybeCollapsed:!1,dragMinimapTransition:!1,dragGroupRect:null}),[E,j]=(0,m.useState)(null),[_,k]=(0,m.useState)(!0);(0,m.useEffect)(()=>{let e=[t?.on("presentation/focus",e=>{x({type:"presentation/focus",data:e})}),t?.on("presentation/blur",e=>{x({type:"presentation/blur",data:e})}),t?.on("presentation/toggle-overlay",()=>{k(e=>!e)})].filter(Boolean);return()=>e.forEach(e=>e())},[t]),function(e,t){(0,m.useEffect)(()=>{let n=new AbortController;e?.fetch("visual-editing/fetch-perspective",void 0,{signal:n.signal,suppressWarnings:!0}).then(e=>{t({type:"presentation/perspective",data:e})}).catch(()=>{});let r=e?.on("presentation/perspective",e=>{t({type:"presentation/perspective",data:e})});return()=>{r?.(),n.abort()}},[e,t])}(t,x),function(e,t,n){let r=(0,m.useRef)(void 0),i=(0,m.useCallback)((t,n)=>{e?.post("visual-editing/documents",{documents:t,perspective:n})},[e]);(0,m.useEffect)(()=>{let e=t.map(e=>{let{sanity:t}=e;return"id"in t?t:null}).filter(e=>!!e),o=new Set(e.map(e=>e.id));if(!r.current||!function(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}(o,r.current.nodeIds)||n!==r.current.perspective){let t=Array.from(o).map(t=>{let{type:n,projectId:r,dataset:i}=e.find(e=>e.id===t);return r&&i?{_id:t,_type:n,_projectId:r,_dataset:i}:{_id:t,_type:n}});r.current={nodeIds:o,perspective:n},i(t,n)}},[t,n,i])}(t,y,g);let I=(0,m.useCallback)((e,t)=>{E&&(E.style.setProperty("--drag-preview-x",`${e}px`),E.style.setProperty("--drag-preview-y",`${t-window.scrollY}px`))},[E]);(0,m.useEffect)(()=>{let e=e=>{let t=e.target;if(((0,A.nY)(t)||(0,A.sb)(t)&&t.closest("a"))&&e.altKey){e.preventDefault(),e.stopPropagation();let t=new MouseEvent(e.type,{...e,altKey:!1,bubbles:!0,cancelable:!0});e.target?.dispatchEvent(t)}},t=e=>{oI(e)&&k(e=>!e)},n=e=>{oI(e)&&k(e=>!e),function(e,t){return e.every(e=>ok[e]?t[ok[e]]:t.key===e.toUpperCase())}(["mod","\\"],e)&&k(e=>!e)};return window.addEventListener("click",e),window.addEventListener("keydown",n),window.addEventListener("keyup",t),()=>{window.removeEventListener("click",e),window.removeEventListener("keydown",n),window.removeEventListener("keyup",t)}},[k]);let[M,$]=(0,m.useState)(!1),[S,C]=(0,m.useState)(!1),O=(0,m.useRef)(void 0);(0,m.useEffect)(()=>{if(_)return ox(()=>{$(!0),ox(()=>{C(!0),O.current=setTimeout(()=>{C(!1),$(!1)},1500)})});O.current&&(clearTimeout(O.current),$(!1),C(!1))},[_]);let T=(0,m.useMemo)(()=>y.flatMap(e=>"id"in e.sanity?[e.sanity.id]:[]),[y]),P=(0,m.useCallback)(()=>{x({type:"overlay/blur"})},[]),R=rt(),z=(0,m.useMemo)(()=>R?r:void 0,[r,R]),L=(0,m.useMemo)(()=>(i||o)&&"connected"!==n||h?[]:y.filter(e=>e.activated||e.focused).map(({id:e,element:t,focused:n,hovered:r,rect:o,sanity:a,dragDisabled:s})=>{let u=!s&&!!t.getAttribute("data-sanity")&&R&&y.some(e=>"id"in e.sanity&&"id"in a&&il(e.sanity,a)&&e.sanity.path!==a.path);return(0,p.jsx)(or,{componentResolver:z,element:t,enableScrollIntoView:!h&&!b&&!c,focused:n,hovered:r,node:a,rect:o,showActions:!i,draggable:u,isDragging:h||b,wasMaybeCollapsed:n&&v},e)}),[z,b,c,y,i,o,h,R,n,v]);return(0,p.jsx)(ob,{comlink:t,children:(0,p.jsx)(A.NP,{scheme:s?"dark":"light",theme:A.Qx,tone:"transparent",children:(0,p.jsx)(A.XS,{children:(0,p.jsx)(A.GD,{element:E,children:(0,p.jsx)(oh,{comlink:t,elements:y,children:(0,p.jsx)(of,{comlink:t,children:(0,p.jsx)(ov,{comlink:t,children:(0,p.jsxs)(ow,{"data-fading-out":S?"":void 0,"data-overlays":M?"":void 0,ref:j,$zIndex:a,children:[(0,p.jsx)(oE,{documentIds:T,perspective:g}),(0,p.jsx)(oj,{comlink:t,dispatch:x,inFrame:i,inPopUp:o,onDrag:I,overlayEnabled:_,rootElement:E}),u&&(0,p.jsx)(i3,{...u,onDismiss:P}),L,h&&!b&&(0,p.jsxs)(p.Fragment,{children:[l&&(0,p.jsx)(oa,{dragInsertPosition:l}),d&&(0,p.jsx)(oc,{}),w&&(0,p.jsx)(oo,{dragGroupRect:w})]}),h&&f&&(0,p.jsx)(ou,{skeleton:f})]})})})})})})})})},ok={alt:"altKey",ctrl:"ctrlKey",mod:"u">typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform)?"metaKey":"ctrlKey",shift:"shiftKey"};function oI(e){return"Alt"===e.key}let oM=e=>{let{comlink:t,refresh:n}=e,r=(0,m.useRef)(0),i=(0,m.useRef)(0);return(0,m.useEffect)(()=>t.on("presentation/refresh",e=>{if("manual"===e.source){clearTimeout(r.current);let i=n(e);if(!1===i)return;t.post("visual-editing/refreshing",e);let o=!1;r.current=window.setTimeout(()=>{t.post("visual-editing/refreshed",e),o=!0},3e3),i?.finally?.(()=>{o||(clearTimeout(r.current),t.post("visual-editing/refreshed",e))})}else if("mutation"===e.source){clearTimeout(i.current);let r=n(e);if(!1===r)return;t.post("visual-editing/refreshing",e),i.current=window.setTimeout(()=>{let r=n(e);!1!==r&&(t.post("visual-editing/refreshing",e),r?.finally?.(()=>{t.post("visual-editing/refreshed",e)})||t.post("visual-editing/refreshed",e))},1e3),r?.finally?.(()=>{t.post("visual-editing/refreshed",e)})||t.post("visual-editing/refreshed",e)}}),[t,n]),null},o$=e=>{let{components:t,history:n,portal:r=!0,refresh:i,zIndex:o}=e,[a,s]=(0,m.useState)(null),[u,l]=(0,m.useState)(null);(0,m.useEffect)(()=>{s((0,f.Fk)()),l((0,f.v$)())},[]);let[c,d]=(0,m.useState)(null);(0,m.useEffect)(()=>
182{if(!1===r)return;let e=document.createElement("sanity-visual-editing");return document.documentElement.appendChild(e),d(e),()=>{d(null),document.documentElement.contains(e)&&document.documentElement.removeChild(e)}},[r]);let[h,g]=function(e=!0){let[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)("idle");return(0,m.useEffect)(()=>{if(!e)return;let t=(0,iq.RM)({name:"visual-editing",connectTo:"presentation"},(0,iq.Uc)().provide({actors:(0,f.jF)()})),r=t.onStatus(()=>i("connected"),"connected");n(t);let o=t.start();return()=>{r(),o(),n(void 0)}},[e]),[t,r]}(!0===a||!0===u);!function(e){(0,m.useEffect)(()=>{if(!e)return;let t=function(e){let t=new iF.m(1),n=new iW.B;return e.fetch("visual-editing/snapshot-welcome",void 0,{suppressWarnings:!0}).then(e=>{t.next(e.event)}).catch(()=>{}),e.on("presentation/snapshot-event",e=>{"reconnect"===e.event.type&&t.next(e.event),"mutation"===e.event.type&&n.next(e.event)}),(0,ng.h)(t,n)}(e),n=nK(e),r=(0,K.A)(n,{input:{client:{withConfig:()=>{}},sharedListener:t}});r.start();let i=new AbortController;return e.fetch("visual-editing/features",void 0,{signal:i.signal,suppressWarnings:!0}).then(e=>{e.features.optimistic&&function(e){for(let t of(nQ=e,n0))t()}(r)}).catch(()=>{console.warn("[@sanity/visual-editing] Package version mismatch detected: Please update your Sanity studio to prevent potential compatibility issues.")}),()=>{r.stop(),i.abort()}},[e])}("connected"===g?h:void 0);let v=(0,p.jsxs)(p.Fragment,{children:[null!==a&&null!==u&&(0,p.jsx)(o_,{comlink:h,comlinkStatus:g,componentResolver:t,inFrame:a,inPopUp:u,zIndex:o}),h&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(iY,{comlink:h,history:n}),(0,p.jsx)(iB,{comlink:h}),i&&(0,p.jsx)(oM,{comlink:h,refresh:i})]})]});return!1!==r&&c?(0,y.createPortal)(v,c):v};o$.displayName="VisualEditing";var oS=n(76046),oC=n(83297);function oA(e){let t=e.indexOf("#"),n=e.indexOf("?"),r=n>-1&&(t<0||n<t);return r||t>-1?{pathname:e.substring(0,r?n:t),query:r?e.substring(n,t>-1?t:void 0):"",hash:t>-1?e.slice(t):""}:{pathname:e,query:"",hash:""}}function oO(e,t){if(!function(e,t){if("string"!=typeof e)return!1;let{pathname:n}=oA(e);return n===t||n.startsWith(`${t}/`)}(e,t))return e;let n=e.slice(t.length);return n.startsWith("/")?n:`/${n}`}let oT=(e,t)=>{let{pathname:n,query:r,hash:i}=oA(e);return t?n.endsWith("/")?`${n}${r}${i}`:`${n}/${r}${i}`:`${n.replace(/\/$/,"")||"/"}${r}${i}`};function oP(e){let{basePath:t="",components:n,refresh:r,trailingSlash:i=!1,zIndex:o}=e,a=(0,oS.useRouter)(),s=(0,m.useRef)(a),[u,l]=(0,m.useState)();(0,m.useEffect)(()=>{s.current=a},[a]);let c=(0,m.useMemo)(()=>({subscribe:e=>(l(()=>e),()=>l(void 0)),update:e=>{switch(e.type){case"push":return s.current.push(oO(e.url,t));case"pop":return s.current.back();case"replace":return s.current.replace(oO(e.url,t));default:throw Error(`Unknown update type: ${e.type}`)}}}),[t]),d=(0,oS.usePathname)(),f=(0,oS.useSearchParams)();(0,m.useEffect)(()=>{u&&u({type:"push",url:oT(function(e,t){if(!e.startsWith("/")||!t)return e;if("/"===e&&t)return t;let{pathname:n,query:r,hash:i}=oA(e);return`${t}${n}${r}${i}`}(`${d}${f?.size?`?${f}`:""}`,t),i)})},[t,u,d,f,i]);let y=(0,m.useCallback)(e=>{if(r)return r(e);switch(e.source){case"manual":return e.livePreviewEnabled?(console.debug("Live preview is setup, calling router.refresh() to refresh the server components without refetching cached data"),s.current.refresh(),Promise.resolve()):(console.debug("No loaders in live mode detected, or preview kit setup, revalidating root layout"),(0,oC.q)());case"mutation":return e.livePreviewEnabled?(console.debug("Live preview is setup, mutation is skipped assuming its handled by the live preview"),!1):(console.debug("No loaders in live mode detected, or preview kit setup, revalidating root layout"),(0,oC.q)());default:throw Error("Unknown refresh source",{cause:e})}},[r]);return(0,p.jsx)(o$,{components:n,history:c,portal:!0,refresh:y,zIndex:o})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.