payload-live-preview 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -16
- package/dist/adapters/astro/index.js +1 -1
- package/dist/adapters/astro/index.js.map +1 -1
- package/dist/adapters/astro/middleware-entry.js +1 -1
- package/dist/adapters/astro/middleware-entry.js.map +1 -1
- package/dist/adapters/nextjs/index.js +1 -1
- package/dist/adapters/nextjs/index.js.map +1 -1
- package/dist/adapters/nuxt/index.js +1 -1
- package/dist/adapters/nuxt/index.js.map +1 -1
- package/dist/adapters/react/index.js +1 -1
- package/dist/adapters/react/index.js.map +1 -1
- package/dist/adapters/sveltekit/index.js +1 -1
- package/dist/adapters/sveltekit/index.js.map +1 -1
- package/dist/adapters/vue/index.js +1 -1
- package/dist/adapters/vue/index.js.map +1 -1
- package/dist/client.cjs +1 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lean.cjs +1 -1
- package/dist/lean.cjs.map +1 -1
- package/dist/lean.js +1 -1
- package/dist/lean.js.map +1 -1
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.cjs.map +1 -1
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +1 -1
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e="2.3.0";function detectInitialLocale(){return function(){if("undefined"==typeof document)return;const e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}()??function(){if("undefined"==typeof navigator)return;const e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}()??"en"}var t="payload-live-preview-a11y",n=/* @__PURE__ */new WeakMap;function r(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}var i=class{german;document;lease=null;constructor(e,t){const n=t??("undefined"==typeof document?null:document),r=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(r.length>0?r:detectInitialLocale())),this.document=n}mount(){const e=this.document;if(null==e?.body)return null;this.lease??=function(e){let t=n.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},n.set(e,t)),t.refs+=1,t}(e);const i=this.lease,o=i.element;if(o?.isConnected&&o.ownerDocument===e)return o;if(null!==o){const e=i.owned;r(i),e&&o.remove()}let s=e.getElementById(t);return i.owned=null===s,null===s&&(s=e.createElement("div"),s.id=t,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),s.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0",e.body.appendChild(s)),i.element=s,s}announceConnected(){this.say(this.german?"Vorschau verbunden":"Live preview connected")}announceDisconnected(){this.say(this.german?"Vorschau getrennt":"Live preview disconnected")}announceUpdate(e){e<=0||this.say(this.german?`${String(e)} ${1===e?"Änderung":"Änderungen"} angewendet`:`${String(e)} ${1===e?"change":"changes"} applied`)}announcePartial(){this.say(this.german?"Vorschau teilweise aktualisiert":"Preview partly updated")}detach(){const e=this.lease,t=this.document;if(null===e||null===t)return;if(this.lease=null,e.refs-=1,e.refs>0)return;const i=e.element;null!==i&&r(e),e.owned&&i?.remove(),e.element=null,n.delete(t)}say(e){const t=this.mount(),n=this.lease;if(null===t||null===n)return;let i=n.messageNode;i?.parentNode!==t?(i?.remove(),i=t.ownerDocument.createTextNode(t.hasChildNodes()?` ${e}`:e),n.messageNode=i,t.appendChild(i)):i.data=null===i.previousSibling?e:` ${e}`,null!==n.timer&&clearTimeout(n.timer);const o=setTimeout(()=>{n.timer===o&&n.element===t&&r(n)},1500);n.timer=o}};function o(e){if(++e.nodes>1e4)throw new Error("invalid or oversized field schema")}function s(e,t,n){if(o(t),n>64||t.active.has(e))throw new Error("invalid or oversized field schema");t.active.add(e)}function a(e){try{return l(e,{nodes:0,active:/* @__PURE__ */new WeakSet},0)}catch{return[]}}function l(e,t,n){if(!Array.isArray(e))return[];s(e,t,n);const r=[];for(const i of e){const e=d(i,t,n);e&&r.push(e)}return t.active.delete(e),r}function d(e,t,n){if(o(t),"object"!=typeof e||null===e)return;const r=e,i=r.name,a=r.type;if("string"!=typeof i||0===i.length)return;if("string"!=typeof a||0===a.length)return;const d=l(r.fields,t,n+1),u=function(e,t,n){if("object"==typeof e&&null!==e&&!Array.isArray(e)){s(e,t,n);const r=[];for(const i in e){if(!Object.hasOwn(e,i))continue;o(t);const s=Reflect.get(e,i);"object"!=typeof s||null===s||["__proto__","constructor","prototype"].includes(i)||r.push({...s,slug:i,fields:l(s.fields,t,n+1)})}return t.active.delete(e),r}if(!Array.isArray(e))return[];s(e,t,n);const r=[];for(const i of e){if(o(t),"object"!=typeof i||null===i)continue;const e=i,s=e.slug;if("string"!=typeof s||0===s.length)continue;const a=l(e.fields,t,n+1);r.push({...e,slug:s,fields:a})}return t.active.delete(e),r}(r.blocks,t,n+1),c={...r,name:i,type:a},h=r.relationTo;if(Array.isArray(h)){const e=[];for(const n of h)o(t),e.push(n);c.relationTo=e}return d.length>0?c.fields=d:delete c.fields,u.length>0?c.blocks=u:delete c.blocks,c}function u(e,t){return void 0===e||t(e)}function c(e,t){return null==e||t(e)}function h(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}var f=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],p=4,g={basic:{since:1},"schema-json":{since:2,observed:"schema"},locale:{since:2,observed:"locale"},"preview-token":{since:3,observed:"preview-token"},"nested-arrays":{since:4},"recursive-diffs":{since:4},"document-events":{since:4,observed:"document-event"},"relationship-events":{since:4,observed:"relationship-event"}},m=Object.keys(g);function negotiateProtocol(e,t=[]){const n="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,r=n??1,i=Math.min(4,r),o=new Set(t),s=/* @__PURE__ */new Set;for(const e of m)(i>=g[e].since||o.has(e))&&s.add(e);return{ours:4,...void 0!==n?{theirs:n}:{theirs:void 0},negotiated:i,capabilities:s,observed:o}}function hasCapability(e,t){return e.capabilities.has(t)}var v="[payload-live-preview] This admin sends fieldSchemaJSON, which only Payload 2 does. Every 2.x release of this package supports Payload 2; 3.0 supports Payload 3 and 4.";function y(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function b(e,t){return e.generation===t.generation&&e.revision===t.revision}var w=class{matcher;handlers;boundListener=void 0;attachedTarget=void 0;generation=0;revision=0;queueHead=void 0;queueTail=void 0;lastAccepted=void 0;replayedGeneration=0;latestAcceptedAttempt=void 0;constructor(e,t){this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1;const n=r=>{if(!t||this.boundListener!==n)return;const i=this.generation;try{this.receive(r,i,e)}catch{let e;try{e=r.origin}catch{e=""}this.reportInvalid("shape",e,i)}};this.generation+=1,this.resetQueue(),this.attachedTarget=e,this.boundListener=n;try{e.addEventListener("message",n)}catch(t){this.boundListener===n&&(this.attachedTarget=void 0,this.boundListener=void 0,this.resetQueue());try{e.removeEventListener("message",n)}catch{}throw t}if(this.boundListener===n)t=!0;else try{e.removeEventListener("message",n)}catch{}}detach(){const e=this.attachedTarget,t=this.boundListener;void 0!==e&&void 0!==t&&(this.attachedTarget=void 0,this.boundListener=void 0,this.resetQueue(),e.removeEventListener("message",t))}advanceGeneration(){return void 0!==this.attachedTarget&&(this.generation+=1,this.resetQueue(),!0)}replayLastAccepted(){const e=this.lastAccepted,t=this.generation,n=this.handlers.onReplay;if(void 0===n||void 0===e||e.generation>=t||this.replayedGeneration===t)return!1;if(!this.matchesOrigin(e.origin,t)||this.lastAccepted!==e)return!1;this.replayedGeneration=t;const r={generation:t,revision:this.revision+=1};return this.invokeHandler(t,n,structuredClone(e.message),e.origin,r),!0}forgetLastAccepted(){this.lastAccepted=void 0,this.replayedGeneration=0,this.latestAcceptedAttempt=void 0}static sendReady(e,t){const n={type:"payload-live-preview",ready:!0,protocolVersion:4};for(const r of e)for(const e of t)try{r.postMessage(n,e)}catch{}}receive(e,t,n){const r=e.origin;if(!this.matchesOrigin(r,t))return void this.reportInvalid("origin",r,t);if(!this.matchesSource(e,n))return void this.reportInvalid("source",r,t);const i=e.data;var o;if("object"==typeof(o=i)&&null!==o&&"type"in o&&"string"==typeof o.type)switch(i.type){case"payload-live-preview":return function(e){const t=e;return!(void 0!==t.data&&null!==t.data&&!h(t.data))&&c(t.fieldSchemaJSON,e=>Array.isArray(e))&&c(t.globalSlug,e=>"string"==typeof e)&&c(t.collectionSlug,e=>"string"==typeof e)&&c(t.locale,e=>"string"==typeof e)&&c(t.ready,e=>"boolean"==typeof e)&&c(t.previewToken,e=>"string"==typeof e)&&c(t.protocolVersion,e=>"number"==typeof e)}(i)?void this.dispatchUpdate(function(e){const t={...e};for(const e of f)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);return Array.isArray(t.fieldSchemaJSON)?{...t,fieldSchemaJSON:a(t.fieldSchemaJSON)}:t}(i),r,t):void this.reportInvalid("shape",r,t);case"payload-document-event":return function(e){const t=e;return u(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&u(t.slug,e=>"string"==typeof e)&&u(t.id,e=>"string"==typeof e||Number.isFinite(e))}(i)?void this.invokeHandler(t,this.handlers.onDocumentEvent,i,r):void this.reportInvalid("shape",r,t);case"payload-live-preview-focus":{const e=function(e){const t=e.field;return"string"==typeof t&&t.length>0?t:void 0}(i);return void 0===e?void this.reportInvalid("shape",r,t):void this.invokeHandler(t,this.handlers.onFocusField,e,r)}default:this.reportInvalid("type",r,t)}else this.reportInvalid("shape",r,t)}dispatchUpdate(e,t,n){const r=h(e.data);if(!this.isCurrentGeneration(n))return;const i=r?{generation:n,revision:this.revision+=1}:void 0,o=this.handlers.validateToken;if(!this.isCurrentGeneration(n))return;if(void 0===o)return void this.commitUpdate(e,t,n,i);if(!0===e.ready&&void 0===e.data)return void this.commitUpdate(e,t,n,void 0);const s={generation:n,message:e,origin:t,messageRevision:i,verdict:void 0,next:void 0};let a;this.enqueue(s);try{a=o(e.previewToken,t)}catch{return void this.settleValidation(s,!1)}"boolean"!=typeof a?Promise.resolve(a).then(e=>{this.settleValidation(s,!0===e)},()=>{this.settleValidation(s,!1)}):this.settleValidation(s,a)}settleValidation(e,t){e.verdict=t,this.drainQueue(e.generation)}drainQueue(e){for(;this.isCurrentGeneration(e);){const t=this.queueHead;if(void 0===t)return;if(this.matchesOrigin(t.origin,e)){if(void 0===t.verdict)return;this.dequeue(t)&&(t.verdict?this.commitUpdate(t.message,t.origin,t.generation,t.messageRevision):this.reportInvalid("token",t.origin,t.generation))}else{if(!this.dequeue(t))continue;this.reportInvalid("origin",t.origin,t.generation)}}}commitUpdate(e,t,n,r){if(void 0===r)this.invokeHandler(n,this.handlers.onUpdate,e,t);else{const i={};this.latestAcceptedAttempt=i;const o=function(e){const t={...e};delete t.previewToken;try{return structuredClone(t)}catch{return null}}(e);if(this.latestAcceptedAttempt!==i||!this.isCurrentGeneration(n))return;this.lastAccepted=null===o?void 0:{generation:n,message:o,origin:t},this.invokeHandler(n,this.handlers.onUpdate,e,t,r)}}reportInvalid(e,t,n){this.invokeHandler(n,this.handlers.onInvalid,e,t)}matchesSource(e,t){if("parent-or-opener"!==this.handlers.sourcePolicy)return!0;try{const n=e.source;if("object"!=typeof n||null===n)return!1;const r=t.parent;return r!==t&&n===r||n===t.opener}catch{return!1}}matchesOrigin(e,t){try{return!0===(this.isCurrentGeneration(t)&&this.matcher(e))&&this.isCurrentGeneration(t)}catch{return!1}}invokeHandler(e,t,...n){if(void 0!==t&&this.isCurrentGeneration(e))try{y(t(...n))}catch{}}isCurrentGeneration(e){return void 0!==this.attachedTarget&&this.generation===e}enqueue(e){void 0===this.queueTail?this.queueHead=e:this.queueTail.next=e,this.queueTail=e}dequeue(e){return this.queueHead===e&&(this.queueHead=e.next,void 0===this.queueHead&&(this.queueTail=void 0),!0)}resetQueue(){this.queueHead=void 0,this.queueTail=void 0}};function S(e){return(...t)=>{try{y(e(...t))}catch{}}}function A(){}var k=S((...e)=>console.error(...e)),R=S((...e)=>console.warn(...e)),T=S((...e)=>console.debug(...e)),C={"structural arrays":'data-payload-type="array" and keyed lists',"array templates":"data-payload-array-template","server-rendered fragments":"data-payload-fragment boundaries","route refreshes":'data-payload-strategy="route" and bindings in <head>',"screen-reader announcements":"the aria-live region","auto-binding":"autoBind: 'unique'"},P=/* @__PURE__ */new Set;function L(e){P.has(e)||(P.add(e),R(`[live-preview] LP0104: this page carries the lean runtime, which leaves out ${e} (${C[e]}). The elements are left as the server rendered them. Remove \`runtime: LEAN_RUNTIME\` to get the full runtime.`))}function $(e){return"undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e){return!1!==e.enableA11y&&L("screen-reader announcements"),null}(e):function(e){if(!1===e.enableA11y)return null;const t=e.root,n=void 0===t?void 0:function(e){return 9===e.nodeType}(t)?t:t.ownerDocument;return new i(e.a11yLocale,n)}(e)}function N(e){if("undefined"==typeof window)return;const t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),w.sendReady(t,e)}function F(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}var U=/* @__PURE__ */new Set(["tabs","row","collapsible"]);function x(e,t,n,r){for(const i of e){if(U.has(i.type)){const e=i.fields;e&&x(e,r&&"tabs"===i.type?""===t?i.name:`${t}.${i.name}`:t,n,r);continue}const e=""===t?i.name:`${t}.${i.name}`;if(n.set(e,i),"group"===i.type)i.fields&&x(i.fields,e,n,r);else if("array"===i.type&&i.fields)x(i.fields,`${e}.*`,n,r);else if("blocks"===i.type&&i.blocks)for(const t of i.blocks)x(t.fields,`${e}.*.${t.slug}`,n,r)}}function M(e,t){if(e.has(t))return e.get(t);const n=t.replace(/\.\d+(?=\.|$)/g,".*");return e.has(n)?e.get(n):void 0}function E(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function O(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function I(e,t){return t.every(e=>void 0!==E(e))?function(e,t){const n=[],r=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=E(e[t]);void 0!==n&&r.set(n,t)}const i=/* @__PURE__ */new Set;for(let o=0;o<t.length;o+=1){const s=t[o],a=E(s);if(void 0===a){n.push({kind:"insert",index:o,value:s});continue}const l=r.get(a);if(void 0===l){n.push({kind:"insert",index:o,value:s});continue}i.add(l);const d=e[l];O(d)===O(s)?(l!==o&&n.push({kind:"move",from:l,to:o,value:s}),D(d,s)||n.push({kind:"update",index:o,value:s})):n.push({kind:"replace",index:o,oldValue:d,value:s})}for(let t=0;t<e.length;t+=1)i.has(t)||n.push({kind:"remove",index:t,value:e[t]});return n}(e,t):function(e,t){const n=[],r=Math.min(e.length,t.length);for(let i=0;i<r;i+=1)D(e[i],t[i])||n.push({kind:"update",index:i,value:t[i]});if(t.length>e.length)for(let r=e.length;r<t.length;r+=1)n.push({kind:"insert",index:r,value:t[r]});if(e.length>t.length)for(let r=t.length;r<e.length;r+=1)n.push({kind:"remove",index:r,value:e[r]});return n}(e,t)}function D(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;const n=e,r=t,i=Object.keys(n),o=Object.keys(r);if(i.length!==o.length)return!1;for(const e of i)if(!Object.is(n[e],r[e]))return!1;return!0}var _={text:"text",textarea:"textarea",richText:"richText",email:"email",number:"number",checkbox:"checkbox",date:"date",select:"select",radio:"radio",array:"array",blocks:"blocks",group:"text",tabs:"text",row:"text",collapsible:"text",relationship:"relationship",upload:"upload",point:"text",json:"text",code:"text",ui:"text"},B=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),z=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,j=/^[\\/]{2}/,H=/[\t\n\r]/g,W=/[\s\u0000-\u001f\u180e\u2000-\u2029]/g,q=/^([a-z][a-z0-9+.-]*):/i;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(H,"");if(0===t.length)return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(j.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return B.has(e.protocol)}catch{return z.test(t)&&!function(e){const t=q.exec(e.replace(W,""))?.[1];return void 0!==t&&!B.has(`${t.toLowerCase()}:`)}(t)}}function isExternalHttpUrl(e){const t=e.trim().replace(H,"");return/^https?:\/\//i.test(t)||j.test(t)}var V=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),G=/* @__PURE__ */new Set(["href","src","poster","cite","action","xlink:href","data"]);function K(e){return!e.startsWith("on")&&!V.has(e)}function J(e){switch(typeof e){case"string":return e.length>65536?void 0:`s:${e}`;case"number":return`n:${Object.is(e,-0)?"-0":String(e)}`;case"boolean":return"b:"+(e?"1":"0");case"bigint":return`i:${String(e)}`;case"undefined":return"u";case"object":{if(null===e)return"z";let t;try{t=JSON.stringify(e)}catch{return}return t.length>65536?void 0:`o:${t}`}case"symbol":case"function":return}}function Q(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function X(e,t,n,r,i){const o=e.onUnfaithfulPatch,s=t.reportedUnfaithful.get(n.element),a=J(i),l=Date.now(),d=void 0!==s&&("escalate"!==o||void 0===a||a===s.identity||l-s.at<1e3);if((d||"escalate"!==o)&&t.display.shortfall(t.activeUpdate,{kind:"unfaithful",field:n.fieldName}),!d){if(t.reportedUnfaithful.set(n.element,{identity:a,at:l}),void 0===s){if(t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName),"ignore"===o)return;if("warn"===o)return void e.warn(`[live-preview] LP0411: "${n.fieldName}" ${r}`)}e.log("LP0411",n.fieldName,r),t.unfaithfulPatches.push(n)}}function Z(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}var Y=/* @__PURE__ */new Set(["date","number","checkbox","select","radio"]);function ee(e){return"select"===e||"radio"===e}function te(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function ne(e){const t=e.trim();return JSON.stringify(t.length>40?`${t.slice(0,40)}…`:t)}var re=/* @__PURE__ */new WeakSet;function ie(e){return re.add(e),e}var oe=class{previous=null;lastFields;priorFields;keepValues=!1;get previousFields(){return this.priorFields}get isBaseline(){return null===this.previous}diff(e,t,n=se){const r=this.previous,i=null===r,o=/* @__PURE__ */new Map,s=/* @__PURE__ */new Set,a=Object.entries(e);if(!n())return null;for(const[e,t]of a){const i=J(t);if(!n())return null;o.set(e,i),null!==r&&void 0!==i&&r.get(e)===i||s.add(e)}if(null!==r)for(const e of r.keys())o.has(e)||s.add(e);const l=/* @__PURE__ */new Set,d=Object.entries(t);if(!n())return null;for(const[e,t]of d)if(s.has(e))for(const e of t)if(l.add(e),!n())return null;return n()?(this.previous=o,this.priorFields=this.keepValues?this.lastFields:void 0,this.lastFields=this.keepValues?e:void 0,{changed:s,invalidated:l,baseline:i}):null}reset(){this.previous=null,this.lastFields=void 0,this.priorFields=void 0}};function se(){return!0}var ae=/* @__PURE__ */new Set(["__proto__","prototype","constructor"]);function le(e,t,n,r=!1){if(r&&void 0!==n){const r=de(e,`${t}_${n}`);if(void 0!==r)return r}const i=de(e,t);if(void 0!==i)return i;if(t.includes(".")){let n=e,r=!0;for(const e of t.split(".")){if(ae.has(e)||null===n||"object"!=typeof n){r=!1;break}if(n=de(n,e),void 0===n){r=!1;break}}if(r)return n}return void 0===n?void 0:de(e,`${t}_${n}`)}function de(e,t){if(!ae.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function ue(e,t,n,r){return le(e,n,t.locale??r,void 0!==t.locale)}function ce(e,t,n,r){const i=J(t);if(void 0===i)return;const o=[e.hrefField,e.srcField,e.altField];let s=JSON.stringify([e.format,e.locale??r])+i;for(const t of o){if(void 0===t||0===t.length)continue;const i=J(ue(n,e,t,r));if(void 0===i)return;s+=`|${t}=${i}`}return s}var he="data-payload-fragment",fe="data-payload-fragment-key";function pe(e){return e.closest(`[${he}]`)}function ge(e,t,n){const r=new Set(t);return{boundaries:t,strategy:e,ownerKeys:n,covers:e=>void 0!==e.fragmentBoundary&&r.has(e.fragmentBoundary)}}function me(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==pe(e)?"fragment":null!==e.closest("head")?"route":"patch"}function ve(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function ye(e){return"string"==typeof e&&e.length>0}function be(e,t){return null!==t&&void 0!==e&&t.includes(e)}function we(e){const t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}function Se(e){return"object"==typeof e&&null!==e}function Ae(e){return Array.isArray(e)?"array":Se(e)?"object":"scalar"}function ke(e,t){return Se(e)?e[t]:void 0}function Re(e,t){return("string"==typeof t||"number"==typeof t)&&Se(e)&&!Array.isArray(e)&&e.id===t}function Te(e,t){if(!Se(e)||!Se(t))return Re(e,t)||Re(t,e)||J(e)===J(t);if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(n=>Object.hasOwn(e,n)&&Te(ke(e,n),ke(t,n)))}function Ce(e,t){const n=J(t),r=J(e);return void 0!==n&&n===r||!(!Re(e,t)&&!Re(t,e))||void 0!==n&&void 0!==r&&Te(e,t)}function Pe(e,t,n){let r=t,i=n;for(const t of e.split("."))r=ke(r,t),i=ke(i,t);return!Ce(r,i)}function Le(e,t,n,r){const i=[];let o=0;const s=(e,t,n,a)=>{if(o+=1,r.covers(e)||Ce(t,n))return;if(!((void 0===t||Ae(t)===Ae(n))&&Se(n)&&r.reachesBelow(e)&&a<8))return void i.push({path:e,value:n});const l=function(e,t){const n=new Set(Object.keys(t));if(Se(e))for(const t of Object.keys(e))n.add(t);return[...n]}(t,n);0===l.length&&i.push({path:e,value:n});for(const r of l){if(o>=1024)return void i.push({path:e,value:n});s(`${e}.${r}`,ke(t,r),ke(n,r),a+1)}};return s(e,t,n,0),i}var $e=/* @__PURE__ */new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function Ne(e,t,n={}){const r=e=>!1===t||be(e,t),i=[];for(const[t,n]of e.entries())n.some(e=>r(e.owner))&&i.push(t);const o=e.rendered.filter(e=>void 0!==n[e.strategy]);return function(e,t){const n=new Set(e),r=[...t],i=(e,t)=>{const n=`${t}.`;for(const t of e)if(t.startsWith(n))return!0;return!1};return{covers:e=>n.has(e)||r.some(t=>t===e||e.startsWith(`${t}.`)),reachesBelow:e=>i(n,e)||i(r,e)}}(i,[...e.covers,...o].filter(e=>r(e.owner)).flatMap(e=>e.paths))}function Fe(e,t){if(void 0===t||0===t.length)return e;const n=`_${t}`;return e.endsWith(n)?e.slice(0,-n.length):e}function Ue(e,t,n,r=Ne(e,n)){let i;const o=r.covers,s=r.reachesBelow;return r=>{const a=Fe(r,t);return o(r)||a!==r&&o(a)?"whole":(i??=function(e,t){const n=/* @__PURE__ */new Set;for(const[r,i]of e.entries())for(const e of i)(!1===t||be(e.owner,t))&&void 0!==e.locale&&n.add(`${r}_${e.locale}`);return n}(e,n),i.has(r)?"whole":s(r)||a!==r&&s(a)?"below":"none")}}function xe(e,t,n,r,i){const o=Ne(e,r,i),s=Ue(e,n,r,o),a=[];for(const[e,r]of Object.entries(t)){if($e.has(e)||"below"!==s(e))continue;const t=Fe(e,n);a.push(...Le(t,void 0,r,o))}return a}function Me(e,t,n){return"declared"===e&&void 0!==t&&void 0!==n?{previous:t,next:n}:void 0}function Ee(e,t,n,r,i,o){const s=Ne(e,r,o),a=Ue(e,n,r,s),l=[];for(const e of t){if($e.has(e))continue;const t=a(e);if("none"===t&&l.push(e),"below"!==t||void 0===i)continue;const r=Fe(e,n),{previous:o,next:d}=i;for(const{path:t}of Le(r,o[e],d[e],s))l.push(t)}return l}var Oe=/* @__PURE__ */new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),Ie=/* @__PURE__ */new Set(["root","paragraph","text","heading","quote","list","listitem","linebreak","tab","horizontalrule","code","code-highlight","table","tablerow","tablecell","link","autolink"]),De={},_e=class{rawChanges=new oe;resolved=null;resolvedLocale=null;trailing=null;openUntil=0;requestAttempt=0;decide(e,t){const n=t.rawData;if(!function(e){const{cache:t,emitter:n}=e;if(t.islands.length>0)return!0;if(n.listenerCount("beforeUpdate")>0||n.listenerCount("afterUpdate")>0)return!0;for(const e of t.values()){if(ze(e)||e.fieldName.includes("."))return!0;if(We(e.hrefField)||We(e.srcField)||We(e.altField))return!0}return void 0!==e.strategies.fragment&&null!==e.root.querySelector(`[${he}]`)}(e)&&!function(e,t,n){for(const r of e.values()){if("text"!==r.fieldType||!0===r.explicitFieldType)continue;const e=ue(t,r,r.fieldName,n);if(it(e)&&je(e.root))return!0}return!1}(e.cache,n,t.locale))return t.forceRender&&(this.resolvedLocale=null),{merge:!1,fields:n};const{changed:r}=this.rawChanges.diff(n,De),i=this.resolvedLocale!==t.locale,o=this.resolved;if(null===o)return this.resolved=n,{merge:!0,fields:n};const s={...o};t.forceRender&&(this.resolvedLocale=null);let a=t.forceRender||i;for(const i of r){const r=n[i];if($e.has(i)){s[i]=r;continue}const l=Be(i,o[i],r,e.cache,t.schemaIndex);"own"!==l&&(a=!0,this.resolvedLocale=null),"keep"!==l&&(s[i]=r)}return this.resolved=s,{merge:a,fields:s}}request(e,t,n){const r=++this.requestAttempt,i=Date.now();if(i>=this.openUntil)return this.openUntil=i+t,this.dropQueued(),this.requestAttempt!==r?{leading:!0,result:Promise.resolve({status:"superseded"})}:{leading:!0,result:e.merge(n)};const o=this.trailing,s=o?.pending??function(){let e;return{promise:new Promise(t=>{e=t}),settle:e}}(),a={request:n,pending:s,timer:null};if(this.trailing=a,this.openUntil=i+t,null!==o&&null!==o.timer&&clearTimeout(o.timer),this.trailing!==a)return{leading:!1,result:s.promise};const l=setTimeout(()=>{this.flush(e,a)},t);return this.trailing===a?a.timer=l:clearTimeout(l),{leading:!1,result:s.promise}}recordMerged(e,t){this.resolved=e,this.resolvedLocale=t}resetRawChanges(){this.rawChanges.reset()}destroy(){this.requestAttempt+=1,this.openUntil=0,this.dropQueued()}dropQueued(){const e=this.trailing;this.trailing=null,null!==e&&(null!==e.timer&&clearTimeout(e.timer),e.pending.settle({status:"superseded"}))}flush(e,t){this.trailing===t&&(this.trailing=null,t.timer=null,e.merge(t.request).then(t.pending.settle))}};function Be(e,t,n,r,i){return He(n)?!He(t)||function(e,t,n){const r=void 0===n?void 0:M(n,e);return void 0!==r&&!Oe.has(r.type)||!0===t.get(e)?.some(ze)||function(e,t){const n=`${t}.`;for(const[t,r]of e.entries())if(t.startsWith(n))return!0;return!1}(t,e)}(e,r,i)?"keep":null==t?"ask":"own":"ask"}function ze(e){return!Oe.has(e.fieldType)}function je(e){const t=[e],n=/* @__PURE__ */new Set;for(let e=t.pop();void 0!==e;e=t.pop()){if("object"!=typeof e||null===e||n.has(e))continue;n.add(e);const{type:r,fields:i,children:o}=e;if(!Ie.has(r))return!0;if("internal"===i?.linkType)return!0;if(Array.isArray(o))for(const e of o)t.push(e)}return!1}function He(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function We(e){return!0===e?.includes(".")}function isInIframe(){if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch{return!0}}function isInPopup(){return"undefined"!=typeof window&&null!=window.opener}function isInPreviewContext(){return isInIframe()||isInPopup()}function isDevMode(){const e=function(){if("undefined"==typeof process)return;const e=process.env.NODE_ENV;return"string"==typeof e?e:void 0}();if(void 0!==e)return"production"!==e;if("undefined"!=typeof window){const e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}return!1}var qe=class{negotiation=negotiateProtocol(void 0);observed=/* @__PURE__ */new Set;observe(e,t,n){const r=e.filter(e=>!this.observed.has(e));if(0!==r.length){for(const e of r)this.observed.add(e);this.negotiation=negotiateProtocol(this.negotiation.theirs,this.observed),t("protocol",`observed=${r.join(",")}`),"undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__||!r.includes("schema-json")||!isDevMode()||n(v)}}applyVersion(e,t){const n=this.negotiation;if(n.theirs===e)return;const r=negotiateProtocol(e,this.observed);this.negotiation=r,r.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${r.negotiated}`)}};function Ve(e,t){const n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;const r=we(e),i=we(t.data??{});return void 0!==r&&void 0!==i&&r!==i}function Ge(e){return null!==e&&e.forceRender&&!e.completed}var Ke=class{lastIdentity=void 0;inspect(e){const t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;const n=JSON.stringify([t.entitySlug,we(t),t.updatedAt]);return{identity:n,edit:n!==this.lastIdentity&&Ve(t,e)?t:null}}commit(e){const t=e.identity!==this.lastIdentity;return this.lastIdentity=e.identity,t?e.edit:null}};function Je(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var Qe=class{#e;reveal(e,t,n){return e===this.#e?"skipped-same":(this.#e=e,function(e,t){for(let t;t=e.closest?.("details:not([open])");)t.setAttribute("open","");return function(e,t){const n=e.getBoundingClientRect(),r=n.bottom>0&&n.top<t.innerHeight,i=n.right>0&&n.left<t.innerWidth;return r&&i}(e,t)?"already-visible":(e.scrollIntoView({behavior:Je(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){this.#e=void 0}};function Xe(e,t){const n=t.element.ownerDocument.defaultView;return null===n?"no-element":e.reveal(`${t.owner??""} ${t.fieldName}`,t.element,n)}var Ze=class{seen=/* @__PURE__ */new Map;note(e,t,n){const r=J(n);if(void 0===r)return;const i=`${t.owner??""}\0${t.locale??""}\0${t.fieldName}`,o=this.seen.get(i);void 0!==o?o!==r&&(e.revealIdentities.push([i,r]),e.revealTarget??=t):this.seen.set(i,r)}commit(e){for(const[t,n]of e.revealIdentities)this.seen.set(t,n);e.revealIdentities=[];const t=e.revealTarget;return e.revealTarget=void 0,t}},Ye=()=>{},et=class{host={outstanding:()=>!1,report:Ye,failed:Ye};entry=null;ended;begin(e,t){const n=this.entry,r=null===n?void 0:this.view(n);null!==n&&(n.key=void 0),this.ended=void 0,this.entry={key:e,revision:t,shortfalls:[],seen:/* @__PURE__ */new Set,deferred:0,awaiting:0,reported:void 0,queued:!1},null!==n&&void 0!==r&&this.publish(n,"pending"===r.state?{...r,state:"superseded"}:r)}end(){const e=this.entry;if(null!==e){this.entry=null;try{this.ended=this.view(e)}finally{e.key=void 0}}}snapshot(){return null!==this.entry?this.view(this.entry):void 0===this.ended?void 0:{...this.ended,shortfalls:[...this.ended.shortfalls]}}shortfall(e,t){const n=this.entry;if(n?.key!==e)return;const r=JSON.stringify(t);n.seen.has(r)||(n.seen.add(r),n.shortfalls.push(t),this.requestSettle(n.key))}deferred(e,t){this.entry?.key===e&&(this.entry.deferred=t)}handIsland(e){const t=this.entry;if(t?.key!==e)return Ye;t.awaiting+=1;let n=!1;return()=>{n||this.entry!==t||(n=!0,t.awaiting-=1,this.settle(t))}}requestSettle(e){const t=this.entry;t?.key!==e||t.queued||(t.queued=!0,queueMicrotask(()=>{t.queued=!1;try{this.entry===t&&this.settle(t)}catch(e){this.host.failed(e)}}))}settle(e){const t=this.view(e);"pending"!==t.state&&this.publish(e,t)}publish(e,t){e.reported!==t.state&&(e.reported=t.state,this.host.report(t))}view(e){const t=void 0!==e.key&&this.host.outstanding(e.key)?"pending":e.shortfalls.length>0?"partial":e.awaiting>0?"unconfirmed":"current";return{revision:e.revision,state:t,shortfalls:[...e.shortfalls],deferred:e.deferred,awaitingIslands:e.awaiting}}};function tt(e){const t=e.getAttribute(fe);return{kind:"fragment",id:e.getAttribute(he)??"",key:null===t||0===t.length?void 0:t,code:"LP0801"}}var nt=class{started=!1;suspended=!1;deferredStart=null;hydration="idle";activeUpdate=null;locale=void 0;schema=void 0;schemaIndex=void 0;updateCount=0;supersededCount=0;completedCount=0;skippedUnchangedCount=0;lastFlush=null;absentFields=/* @__PURE__ */new Set;warnedOrphanFields=/* @__PURE__ */new Set;warnedStrategy=/* @__PURE__ */new WeakSet;warnedUnattributableMessage=!1;warnedVisibilityGate=!1;warnedFragmentFallback=!1;warnedIslandStart=!1;warnedEscalationUnavailable=!1;warnedProtocolShape=!1;reportedUnfaithful=/* @__PURE__ */new WeakMap;checkedServerFormat=/* @__PURE__ */new WeakSet;rowsOfBinding=/* @__PURE__ */new WeakMap;unfaithfulPatches=[];unfaithfulCount=0;escalatedCount=0;unfaithfulFields=/* @__PURE__ */new Set;autoBindSearchMs=void 0;autoBindGuesses=null;warnedForeignSource=!1;lastAppliedIdentity=/* @__PURE__ */new WeakMap;navigationReplayPending=!1;navigationBindingReplay=!1;revealLedger=new Ze;display=new et;fragmentStats={rendered:0,failed:0,superseded:0};routeStats={refreshes:0,partial:0,failed:0,refused:0,loopStopped:0};fragmentControllers=/* @__PURE__ */new Map;routeController=null;routeRetry=null;routeRefreshOwed=!1;routeAwaitsSave=!1;fragmentsOwed=/* @__PURE__ */new Set;readyTimers=[];revealer=new Qe;changes=new oe;merges=new _e;protocol=new qe;relationships=new Ke;isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){this.display.requestSettle(e),e.completed||(e.completed=!0,e.countsAsUpdate&&(this.completedCount+=1))}forgetOwedWork(){this.routeRefreshOwed=!1,this.routeAwaitsSave=!1,this.fragmentsOwed.clear()}supersedeStrategies(){null!==this.routeRetry&&(clearTimeout(this.routeRetry),this.routeRetry=null,this.routeRefreshOwed=!0);for(const[e,t]of this.fragmentControllers){for(const e of t)this.fragmentsOwed.add(e);e.abort()}this.fragmentControllers.clear()}abortStrategies(){this.supersedeStrategies();const e=this.routeController;this.routeController=null,e?.abort()}},rt=class{constructor(e,t){this.deps=e,this.state=t,this.instanceContext=F({renderRichText:e.renderRichText,internalLinkPattern:e.internalLinkPattern,sanitizerPolicy:e.sanitizerPolicy,serverURL:e.serverURL,reportUnfaithful:(n,r)=>{X(e,t,n,r,this.writing)}})}deps;state;writing;instanceContext;apply(e){const{deps:t,state:n}=this,r=n.activeUpdate;if(null===r||void 0===e.revision||!b(r.revision,e.revision)||!n.isCurrent(r))return!1;const{target:i,value:o}=e,s=void 0!==r.schemaIndex?M(r.schemaIndex,i.fieldName):void 0;let a,l=function(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){const e=function(e){if(Object.prototype.hasOwnProperty.call(_,e))return _[e]}(t);if(void 0!==e)return e}return e.fieldType}(i,s?.type);"text"===l&&!0!==i.explicitFieldType&&it(o)&&(l="richText");try{a=t.resolveRenderer(l,i)}catch(e){return this.fail(r,i.fieldName,e)}if(!n.isCurrent(r))return!1;const d=t.emitter.listenerCount("elementUpdate")>0,u=d?"INPUT"===(c=i.element).tagName||"TEXTAREA"===c.tagName?c.value:"IMG"===c.tagName?c.src:c.textContent:void 0;var c;if(!n.isCurrent(r))return!1;const h={allFields:e.allFields,locale:i.locale??r.locale,schema:s,...this.instanceContext};!0===i.hidesWhenEmpty&&i.element.toggleAttribute("hidden",function(e){return null==e||("string"==typeof e?0===e.trim().length:Array.isArray(e)&&0===e.length||ot(e))}(o));try{if(void 0!==i.targetAttribute){if("blocked"===function(e,t,n){const r=t.toLowerCase().trim();if(0===r.length)return"blocked";if(!K(r))return"blocked";if(null==n)return e.removeAttribute(r),"applied";if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return"blocked";const i=String(n);return G.has(r)&&!isSafeUrl(i)?"blocked":(e.setAttribute(r,i),"applied")}(i.element,i.targetAttribute,o))return t.warn(`[live-preview] LP0401: refused to write "${i.fieldName}" into attribute "${i.targetAttribute}"`),n.display.shortfall(r,{kind:"write",field:i.fieldName,code:"LP0401"}),!1}else{if(void 0===a)return t.log("no renderer for",l),X(t,n,i,`has no renderer for "${l}"`,o),!1;{const e=function(e,t,n,r){if("ignore"===e.onUnfaithfulPatch)return;if(void 0!==n.format||!Y.has(r))return;if(ee(r)&&n.element.matches("select,input"))return;if(t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);const i=te(n.element);return i.trim().length>0?i:void 0}(t,n,i,l);this.writing=o;const r=function(e,t,n,r){return e.render(t,n,r)}(a,i,o,h);if(!1===r&&function(e){return re.has(e.render)}(a))return X(t,n,i,`is a value ${a.name} cannot render`,o),!1;void 0!==e&&function(e,t,n,r){const i=te(t.element);i!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${ne(n)}, the patch wrote ${ne(i)} — `+(ee(r)?'Payload sends the value of an option, not its label. Render the label in a data-payload-fragment boundary, or bind it with data-payload-strategy="route".':"either an edit that arrived before the preview connected, or a template that formats this value differently. Set data-payload-format to match it."))}(t,i,e,l)}}}catch(e){return this.fail(r,i.fieldName,e)}if(!n.isCurrent(r))return!1;d&&t.emitter.emitWhile("elementUpdate",{element:i.element,fieldName:i.fieldName,previousValue:u,nextValue:o,revision:r.revision.revision,receivedAt:r.receivedAt,source:"patch"},()=>n.isCurrent(r));const f=n.isCurrent(r);return f&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(i.element,e.valueIdentity):n.lastAppliedIdentity.delete(i.element)),f}fail(e,t,n){if(!this.state.isCurrent(e))return!1;this.state.display.shortfall(e,{kind:"write",field:t,code:"LP0603"});const r=n instanceof Error?n:new Error(String(n));return this.deps.emitter.emitWhile("error",{error:r,context:"renderer",code:"LP0603"},()=>this.state.isCurrent(e)),!1}};function it(e){if("object"!=typeof e||null===e||!("root"in e))return!1;const t=e.root;return"object"==typeof t&&null!==t&&Array.isArray(t.children)}function ot(e){return!!it(e)&&e.root.children.every(e=>{const{type:t,children:n}=e??{};return"paragraph"===t&&(!Array.isArray(n)||0===n.length)})}function st(e){if(null==e)return[];const t=/* @__PURE__ */new Set,n=[];for(const r of e.split(/[\s,]+/)){const e=r.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}function at(...e){const t=/* @__PURE__ */new Map;for(const n of e)for(const[e,r]of Object.entries(n)){let n=t.get(e);void 0===n&&(n=/* @__PURE__ */new Set,t.set(e,n));for(const e of r)n.add(e)}const n={};for(const[e,r]of t)n[e]=[...r];return n}function lt(e,t){const n={};for(const r of t)r!==e&&(n[r]=[e]);return n}var dt="payload-live-preview:update",ut="data-payload-island",ct=`astro-island, [${ut}]`,ht="data-payload-owned";function ft(e){if(e.tagName.toLowerCase().includes("-")&&!e.hasAttribute("data-payload-morph"))return!0;if(gt(e)||e.hasAttribute(ht))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function pt(e){return"patch"===e.getAttribute(ut)}function gt(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(ut)}(e)&&!pt(e)}function isInsideIsland(e){let t=e;for(;null!==t;){if(gt(t))return!0;t=t.parentElement}return!1}function mt(e){return"astro-island"===e.tagName.toLowerCase()&&e.hasAttribute("ssr")}var vt=["component-url","component-export","renderer-url","client","opts","before-hydration-url"],yt=/* @__PURE__ */new WeakMap,bt=/* @__PURE__ */new WeakSet;function wt(e){return"astro-island"===e.tagName.toLowerCase()}function St(e){let t="";for(const n of e.querySelectorAll("astro-slot, template[data-astro-template]"))n.parentElement?.closest("astro-island")===e&&(t+=`${n.getAttribute("name")??n.getAttribute("data-astro-template")??""}\0${n.innerHTML}\0`);return t}function At(e,t){if(!wt(e)||!wt(t))return!0;const n=St(t);if(!vt.every(n=>e.getAttribute(n)===t.getAttribute(n))||(yt.get(e)??St(e))!==n||e.getAttribute("props")!==t.getAttribute("props")&&!function(e){const t=e.ownerDocument.defaultView?.customElements.get("astro-island");return void 0!==t&&e instanceof t&&Array.isArray(t.observedAttributes)&&t.observedAttributes.includes("props")}(e))return yt.set(t,n),!1;yt.set(e,n);const r=t.getAttribute("props");return r!==e.getAttribute("props")&&(e.setAttribute("ssr",""),null===r?e.removeAttribute("props"):e.setAttribute("props",r)),!0}function kt(e){return Array.from(e.querySelectorAll("astro-island"))}function Rt(e){const t=e.ownerDocument.defaultView;if(void 0===t?.customElements.get("astro-island"))return"element";const n=e.getAttribute("client"),r=Reflect.get(t,"Astro");return null===n||"object"!=typeof r||null===r||void 0===Reflect.get(r,n)?"directive":void 0}var Tt="data-payload-field",Ct="data-payload-type",Pt="data-payload-attribute",Lt="data-payload-href",$t="data-payload-src",Nt="data-payload-alt",Ft="data-payload-array-template",Ut="data-payload-array-separator",xt="data-payload-locale",Mt="data-payload-format",Et="data-payload-richtext",Ot="data-payload-html",It="data-payload-array",Dt="data-payload-structural",_t="data-payload-owner",Bt="data-payload-depends",zt="data-payload-strategy",jt="data-payload-boundary",Ht="data-payload-guessed",Wt="data-payload-covers",qt=[Tt,Ct,Pt,Lt,$t,Nt,Ft,Ut,xt,Mt,Et,Ot,It,Dt,_t,Bt,zt,jt,"type"],Vt=`[${Tt}]`,Gt=`[${_t}]`,Kt=`[${he}], [${zt}="route"]`;function Jt(e){const t=e.closest(Gt)?.getAttribute(_t);return null==t||0===t.length?void 0:t}var Qt=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,Xt=/* @__PURE__ */new Set(["text","textarea","richText","email","number","checkbox","date","select","radio","array","blocks","group","tabs","row","collapsible","relationship","upload","point","json","code","ui","html","url","image","structural-array"]);function Zt(e){return Xt.has(e)||Qt.test(e)}function Yt(e,t){return e.fieldName===t.fieldName&&e.locale===t.locale&&e.owner===t.owner&&e.strategyKind===t.strategyKind&&e.fragmentBoundary===t.fragmentBoundary}var en=class{entriesByField=/* @__PURE__ */new Map;entryByElement=/* @__PURE__ */new WeakMap;filter;count=0;dependencies=null;islandRoots=[];ownersByIsland=/* @__PURE__ */new Map;navigationRoots=[];coverDeclarations=[];renderedDeclarations=[];constructor(e={}){this.filter=e.filter??nn}dependencyMap(){if(null!==this.dependencies)return this.dependencies;const e=[];for(const t of this.values())void 0!==t.dependsOn&&e.push(lt(t.fieldName,t.dependsOn));return this.dependencies=at(...e),this.dependencies}get islands(){return this.islandRoots}get islandOwners(){return this.ownersByIsland}get covers(){return this.coverDeclarations}get rendered(){return this.renderedDeclarations}get navigationReplayRoots(){return this.navigationRoots}buildFromRoot(e){const t=performance.now();this.clear();let n=0;for(const t of e.querySelectorAll(Vt))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){const t=[];for(const n of e.querySelectorAll(ct))pt(n)||t.push(n);return t}(e),this.ownersByIsland=new Map(this.islandRoots.map(e=>[e,Jt(e)])),this.navigationRoots=[...e.querySelectorAll(Kt)].filter(e=>this.filter(e)&&(e.hasAttribute(he)||0===(e.getAttribute(Tt)??"").length)),this.coverDeclarations=[...e.querySelectorAll(`[${Wt}]`)].filter(e=>this.filter(e)).map(e=>({paths:st(e.getAttribute(Wt)),owner:Jt(e)})),this.renderedDeclarations=[...e.querySelectorAll(`[${Bt}]`)].filter(e=>this.filter(e)).flatMap(e=>{const t=function(e){if((e.getAttribute(he)??"").length>0)return"fragment";const t=e.getAttribute(zt);return null!==t?"route"===t?"route":void 0:e.hasAttribute(Tt)&&null!==e.closest("head")?"route":void 0}(e);return void 0===t?[]:[{strategy:t,paths:st(e.getAttribute(Bt)),owner:Jt(e)}]}),{elementCount:n,fieldCount:this.entriesByField.size,durationMs:performance.now()-t}}add(e){const t=this.filter(e)?this.resolveBinding(e):void 0,n=this.entryByElement.get(e);if(this.dependencies=null,void 0!==t)return void 0!==n&&this.replaceEntry(n,t)?(this.entryByElement.set(e,t),t):(void 0!==n&&this.removeEntry(e,n),this.append(t),this.entryByElement.set(e,t),t);void 0!==n&&this.removeEntry(e,n)}remove(e){const t=this.entryByElement.get(e);return!!t&&(this.dependencies=null,this.removeEntry(e,t))}get(e){return this.entriesByField.get(e)}getByElement(e){return this.entryByElement.get(e)}get fieldCount(){return this.entriesByField.size}get elementCount(){return this.count}entries(){return this.entriesByField.entries()}*values(){for(const e of this.entriesByField.values())yield*e}has(e){return this.entryByElement.has(e)}clear(){this.entriesByField.clear(),this.entryByElement=/* @__PURE__ */new WeakMap,this.count=0,this.dependencies=null,this.islandRoots=[],this.ownersByIsland=/* @__PURE__ */new Map,this.navigationRoots=[],this.coverDeclarations=[],this.renderedDeclarations=[]}replaceEntry(e,t){if(e.fieldName!==t.fieldName)return!1;const n=this.entriesByField.get(e.fieldName),r=void 0===n?-1:n.indexOf(e);return!(void 0===n||r<0||(n[r]=t,0))}removeEntry(e,t){this.entryByElement.delete(e);const n=this.entriesByField.get(t.fieldName),r=void 0===n?-1:n.indexOf(t);return!(void 0===n||r<0||(n.splice(r,1),0===n.length&&this.entriesByField.delete(t.fieldName),this.count-=1,0))}append(e){const t=this.entriesByField.get(e.fieldName);t?t.push(e):this.entriesByField.set(e.fieldName,[e]),this.count+=1}resolveBinding(e){const t=e.getAttribute(Tt);if(null===t||0===t.length)return;const n=e.getAttribute(Ct),r=e.getAttribute(Pt),i=e.getAttribute(Lt),o=e.getAttribute($t),s=e.getAttribute(Nt),a=e.getAttribute(Ft),l=e.getAttribute(Ut),d=e.getAttribute(xt),u=e.getAttribute(Mt),c=Jt(e),h=st(e.getAttribute(Bt)),f=e.getAttribute(zt),p=e.getAttribute(Ht),g=pe(e);return{element:e,fieldName:t,fieldType:tn(e),explicitFieldType:null!==n&&Zt(n),strategyKind:me(e)??"unknown",...null!==g?{fragmentBoundary:g}:{},...null!==r&&r.length>0?{targetAttribute:r}:{},...null!==i&&i.length>0?{hrefField:i}:{},...null!==o&&o.length>0?{srcField:o}:{},...null!==s&&s.length>0?{altField:s}:{},...null!==a?{arrayTemplate:a}:{},...null!==l?{arraySeparator:l}:{},...null!==d&&d.length>0?{locale:d}:{},...null!==u&&u.length>0?{format:u}:{},...void 0!==c?{owner:c}:{},...h.length>0?{dependsOn:h}:{},...null!==f&&f.length>0?{strategy:f}:{},...e.hasAttribute(jt)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}};function tn(e){const t=e.getAttribute(Ct);if(null!==t&&Zt(t))return t;if(e.hasAttribute(Et))return"richText";if(e.hasAttribute(Ot))return"html";if(e.hasAttribute(Dt))return"structural-array";if(e.hasAttribute(It))return"array";if("IMG"===e.tagName)return"image";if("A"===e.tagName)return"url";if("TIME"===e.tagName)return"date";if("INPUT"===e.tagName){const t=e.type;if("checkbox"===t)return"checkbox";if("number"===t)return"number";if("date"===t||"datetime-local"===t)return"date"}return"text"}function nn(){return!0}var rn=1e4,on=1048576,sn=/* @__PURE__ */new Set(["__proto__","constructor","prototype"]);function an(){throw new Error("invalid or oversized legacy population")}function ln(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n<=31||127===n)return!0}return!1}function dn(e,t){if("string"!=typeof e||0===e.length||e.length>t||"."===e||".."===e)return!1;if(e.includes("/")||e.includes("\\")||ln(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}function un(e){return dn(e,128)&&!/[?#%]/u.test(e)&&!sn.has(e)}function cn(e){return Number.isFinite(e)?String(e):dn(e,512)?e:an()}function hn(e,t){return Object.hasOwn(e,t)?Reflect.get(e,t):void 0}function fn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0,enumerable:!0})}function pn(e){let t=e.length;for(;t>0&&47===e.charCodeAt(t-1);)t-=1;return e.slice(0,t)}function gn(e){const t=/* @__PURE__ */new WeakSet;let n=0,r=0;return function e(i,o){if(++n>rn||o>64)return an();if("string"==typeof i)return r+=i.length,r>on&&an(),i;if(null==i||"boolean"==typeof i)return i;if("number"==typeof i)return Number.isFinite(i)?i:an();if(!Array.isArray(i)&&!h(i))return an();if(Array.isArray(i)){i.length>rn&&an();for(let e=0;e<i.length;e+=1)Object.hasOwn(i,e)||an()}if(t.has(i))return an();t.add(i);const s=Array.isArray(i)?[]:{};for(const t of Object.keys(i))fn(s,t,e(Reflect.get(i,t),o+1));return t.delete(i),s}(e,0)}function mn(e,t,n,r,i,o){if(!Number.isSafeInteger(i)||i<0||i>64)return an();void 0!==o&&("string"!=typeof o||o.length>128||ln(o))&&an();const s=gn(e);if(!h(s))return an();const a=/* @__PURE__ */new Map,l=/* @__PURE__ */new Set;let d=0;const u=/* @__PURE__ */new WeakSet,c=e=>{(++d>rn||e>64)&&an()};function f(e,t,n,r){if(null==r||""===r)return;const o=h(r)?hn(r,"id"):r,s=cn(o);if(0===i)return void fn(e,t,o);const d=JSON.stringify([n,s]);l.add(d),l.size>1e3&&an();const u=a.get(n)??[];u.push({owner:e,key:t,id:s}),a.set(n,u)}function p(e,t,n){void 0!==n.hasMany&&"boolean"!=typeof n.hasMany&&an();const r=n.relationTo,i=hn(e,t);if(Array.isArray(r)){0===r.length&&an();const e=h(i)?hn(i,"relationTo"):void 0;let t;for(const n of r)c(0),un(n)||an(),n===e&&(t=n);if(null==i||""===i)return;h(i)&&void 0!==t||an(),f(i,"value",t,hn(i,"value"))}else un(r)||an(),f(e,t,r,i)}function g(e,t){if(c(t),Array.isArray(e)||h(e)){if(h(e)&&Object.hasOwn(e,"relationTo")&&Object.hasOwn(e,"value")){const t=hn(e,"relationTo");return un(t)||an(),void f(e,"value",t,hn(e,"value"))}for(const n of Object.keys(e))g(Reflect.get(e,n),t+1)}}!function e(t,n,r){c(r),u.has(t)&&an(),u.add(t);for(const i of t){c(r),h(i)&&dn(i.name,512)&&!sn.has(i.name)||an();const t=hn(n,i.name);if("relationship"===i.type||"upload"===i.type)if(i.hasMany)if(null==t||Array.isArray(t)||an(),Array.isArray(t))for(let e=0;e<t.length;e+=1)p(t,e,i);else p(n,i.name,i);else p(n,i.name,i);else if("group"===i.type||"tabs"===i.type)null==t||h(t)||an(),h(t)&&i.fields&&e(i.fields,t,r+1);else if("row"===i.type||"collapsible"===i.type)i.fields&&e(i.fields,n,r+1);else if("array"===i.type||"blocks"===i.type){if(0===t?fn(n,i.name,[]):null==t||Array.isArray(t)||an(),Array.isArray(t))for(const n of t)if(h(n)||an(),"array"===i.type&&i.fields)e(i.fields,n,r+1);else if("blocks"===i.type){const t=hn(n,"blockType"),o=i.blocks?.find(e=>(c(r),e.slug===t));void 0===o&&an(),e(o.fields,n,r+1)}}else"richText"===i.type&&g(t,r+1)}u.delete(t)}(t,s,0),a.size>25&&an();const m=[];if(0===a.size)return{doc:s,requests:m};const v=new URL(n);(!["http:","https:"].includes(v.protocol)||v.username||v.password||v.search||v.hash)&&an(),(!r.startsWith("/")||r.includes("\\")||/[%?#]/u.test(r)||ln(r))&&an(),r.split("/").some(e=>"."===e||".."===e)&&an();const y=`${pn(n)}${pn(r)}/`;for(const[e,t]of a){const n=[...new Set(t.map(e=>e.id))];let r=0;for(;r<n.length;){const s=n[r];void 0===s&&an();const a=s.includes(","),l=[];let d="";for(;r<n.length&&l.length<20;){const t=n[r];if(void 0===t||l.length>0&&(a||t.includes(",")))break;const s=[...l,t],u=new URLSearchParams({depth:String(i),limit:String(s.length)});void 0!==o&&u.set("locale",o),u.set(a?"where[id][equals]":"where[id][in]",a?t:s.join(","));const c=`${y}${encodeURIComponent(e)}?${u}`;if(c.length>8192){0===l.length&&an();break}new URL(c).origin!==v.origin&&an(),l.push(t),r+=1,d=c}(0===l.length||m.length>=64)&&an();const u=new Set(l);m.push({url:d,ids:u,slots:t.filter(e=>u.has(e.id))})}}return{doc:s,requests:m}}async function vn(e,t,n){let r,i=!1,o=!1;const s=/* @__PURE__ */Symbol();let a;const l=new Promise(e=>{a=()=>{e(s)}}),d=()=>{n()&&!t.aborted||an()},u=()=>{if(void 0!==r&&!i){i=!0;try{Promise.resolve(r.cancel()).catch(()=>{})}catch{}}},c=()=>{a?.(),u()};t.addEventListener("abort",c,{once:!0});try{d();const t=e.body??null;if(d(),null===t){const t=e.json.bind(e);d();const n=await Promise.race([Promise.resolve().then(()=>(d(),t())),l]);return d(),n===s&&an(),n}const n=t.getReader.bind(t);d();const i=n();r=i,d();const a=[];let u=0,c=0;for(;;){const e=Promise.resolve().then(()=>{d();const e=i.read.bind(i);return d(),e()}),t=await Promise.race([e,l]);if(d(),t===s&&an(),t.done)break;u+=t.value.byteLength,(++c>1e4||u>on)&&an(),a.push(t.value)}o=!0;const h=new Uint8Array(u);let f=0;for(const e of a)h.set(e,f),f+=e.byteLength;try{return JSON.parse((new TextDecoder).decode(h))}catch{return an()}}finally{t.removeEventListener("abort",c),o||u();try{r?.releaseLock()}catch{}}}function yn(e,t){const n=gn(t);h(n)||an();const r=hn(n,"docs");(!Array.isArray(r)||r.length>20)&&an();const i=/* @__PURE__ */new Map;for(const t of r){h(t)||an();const n=cn(hn(t,"id"));e.ids.has(n)&&!i.has(n)||an(),i.set(n,t)}i.size!==e.ids.size&&an();for(const t of e.slots)fn(t.owner,t.key,i.get(t.id))}function bn(e,t){return e.length>0&&e.length<=t&&"."!==e&&".."!==e&&!e.includes("/")&&!e.includes("\\")&&!function(e){for(const t of e){const e=t.codePointAt(0)??0;if(e<=31||127===e)return!0}return!1}(e)}function wn(e){return bn(e,128)&&!e.includes("?")&&!e.includes("#")}function Sn(e){return"number"==typeof e?Number.isFinite(e):"string"==typeof e&&bn(e,512)}var An=new Error,kn=class{serverURL;apiRoute;depth;fetchFn;log;timeoutMs;inflight=null;attempt=0;destroyDepth=0;constructor(e){this.serverURL=function(e){let t=e.length;for(;e.endsWith("/",t);)t-=1;return e.slice(0,t)}(e.serverURL);const t=e.apiRoute??"/api";this.apiRoute=t.startsWith("/")?t:`/${t}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=S(e.log??A);const n=e.timeoutMs??0;this.timeoutMs=n>0&&n<Number.POSITIVE_INFINITY?n:void 0}canMerge(e){try{const t=e.schema;return void 0!==t?(mn(e.data,t,this.serverURL,this.apiRoute,this.depth,e.locale),!0):null!==this.endpointOf(e)}catch{return!1}}endpointOf(e){try{const t=e.globalSlug;if(t)return wn(t)?{path:`globals/${encodeURIComponent(t)}`,field:"globalType",value:t}:null;const n=e.collectionSlug??"",r=e.data.id;return wn(n)&&Sn(r)?{path:`${encodeURIComponent(n)}/${encodeURIComponent(String(r))}`,field:"id",value:String(r)}:null}catch{return null}}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};const t=this.attempt+=1,n=this.inflight;this.inflight=null;let r=null,i=!1;const o=()=>this.attempt!==t,s=this.timeoutMs;let a,l;const d=(e,t)=>void 0===s?e:(void 0===l&&(l=new Promise((e,n)=>{a=setTimeout(()=>{t.abort(),n(An)},s)}),l.catch(()=>{})),Promise.race([e,l]));try{if(n?.abort(),o())return{status:"superseded"};const t=e.schema;if(i=void 0!==t,void 0!==t){const n=mn(e.data,t,this.serverURL,this.apiRoute,this.depth,e.locale);if(o())return{status:"superseded"};if(0===n.requests.length)return{status:"merged",doc:n.doc};const i=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(o())return{status:"superseded"};if(void 0===i)return{status:"unavailable"};r=new AbortController,this.inflight=r;for(const e of n.requests){const t=await d(i(e.url,{method:"GET",credentials:"include",redirect:"error",signal:r.signal}),r);if(o())return{status:"superseded"};const n=t.ok;if(o())return{status:"superseded"};if(!n){const e=t.status;return o()?{status:"superseded"}:(r.abort(),o()?{status:"superseded"}:(this.log("merge HTTP",e),o()?{status:"superseded"}:{status:"unavailable"}))}const s=await d(vn(t,r.signal,()=>!o()),r);if(o())return{status:"superseded"};if(yn(e,s),o())return{status:"superseded"}}return{status:"merged",doc:n.doc}}const s=this.endpointOf(e);if(o())return{status:"superseded"};if(null===s)return{status:"unavailable"};const a=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(o())return{status:"superseded"};if(void 0===a)return{status:"unavailable"};const l=JSON.stringify({data:e.data,depth:this.depth,flattenLocales:!1,locale:e.locale});if(o())return{status:"superseded"};r=new AbortController,this.inflight=r;const u=`${this.serverURL}${this.apiRoute}/${s.path}`,c=await d(a(u,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:l,signal:r.signal}),r);if(o())return{status:"superseded"};const h=c.ok;if(o())return{status:"superseded"};if(!h){const e=c.status;return o()?{status:"superseded"}:(this.log("merge HTTP",e,u),o()?{status:"superseded"}:{status:"unavailable"})}const f=c.json.bind(c);if(o())return{status:"superseded"};const p=await d(f(),r);if(o())return{status:"superseded"};if(null===p||"object"!=typeof p||Array.isArray(p))return this.log("merge invalid",u),o()?{status:"superseded"}:{status:"unavailable"};const g=p,m=g[s.field],v=Object.hasOwn(g,s.field)&&("id"===s.field?!Sn(m)||String(m)!==s.value:m!==s.value);return o()?{status:"superseded"}:v?(this.log("merge invalid",u),o()?{status:"superseded"}:{status:"unavailable"}):{status:"merged",doc:g}}catch(e){return o()?{status:"superseded"}:e===An?(this.log("merge timeout",s),{status:"unavailable"}):i&&(r?.abort(),o())?{status:"superseded"}:(this.log("merge exception",i?new Error("legacy population could not be resolved"):e),o()?{status:"superseded"}:{status:"unavailable"})}finally{clearTimeout(a),this.inflight===r&&(this.inflight=null)}}destroy(){this.attempt+=1;const e=this.inflight;this.inflight=null,this.destroyDepth+=1;try{e?.abort()}finally{this.destroyDepth-=1}}},Rn={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},Tn={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},Cn={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1};function detectProtocolProfile(e){return e.has("schema-json")?Rn:e.has("document-events")||e.has("relationship-events")?Tn:Cn}var Pn="ssr",Ln=[Tt,_t,Wt,Bt],$n=`[${Tt}], [${Wt}], ${ct}, ${Kt}`,Nn=class{callbacks;debounceMs;rootMargin;visible=/* @__PURE__ */new Set;mutation=null;intersection=null;debounceTimer=null;generation=0;constructor(e,t={}){this.callbacks=e,this.debounceMs=t.mutationDebounceMs??100,this.rootMargin=t.intersectionRootMargin??"200px"}start(e){const t=this.generation;this.stop();const n=t+1;if(this.generation!==n)return;let r=null,i=null;try{r=new MutationObserver(e=>{this.handleMutations(e,n)}),i=new IntersectionObserver(e=>{this.handleIntersection(e,n)},{rootMargin:this.rootMargin,threshold:0}),r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...qt,Wt,ut,Pn]})}catch(e){throw r?.disconnect(),i?.disconnect(),e}if(this.generation!==n)return r.disconnect(),void i.disconnect();this.mutation=r,this.intersection=i}observeElement(e){this.intersection?.observe(e)}unobserveElement(e){this.intersection?.unobserve(e),this.visible.delete(e)}markVisible(e,t){t?this.visible.add(e):this.visible.delete(e)}isVisible(e){return this.visible.has(e)}stop(){this.generation+=1;const e=this.debounceTimer,t=this.mutation,n=this.intersection;this.debounceTimer=null,this.mutation=null,this.intersection=null,this.visible.clear(),null!==e&&clearTimeout(e);try{t?.disconnect()}finally{n?.disconnect()}}handleMutations(e,t){if(!this.isCurrentGeneration(t))return;for(const n of e){const e=Fn(n);if(null!==e&&(this.callbacks.onIslandHydrated?.(e),!this.isCurrentGeneration(t)))return}if(!function(e){for(const t of e){if("attributes"===t.type&&t.attributeName===ut)return!0;if("attributes"===t.type&&null!==t.attributeName){if(Ln.includes(t.attributeName))return!0;if(qt.includes(t.attributeName)&&1===t.target.nodeType&&t.target.hasAttribute(Tt))return!0}for(const e of t.addedNodes)if(Un(e))return!0;for(const e of t.removedNodes)if(Un(e))return!0}return!1}(e))return;null!==this.debounceTimer&&clearTimeout(this.debounceTimer);const n=setTimeout(()=>{this.isCurrentGeneration(t)&&this.debounceTimer===n&&(this.debounceTimer=null,this.callbacks.onStructuralChange())},this.debounceMs);this.debounceTimer=n}handleIntersection(e,t){for(const n of e){if(!this.isCurrentGeneration(t))return;const{target:e}=n;if(n.isIntersecting){if(this.visible.has(e))continue;this.visible.add(e),this.callbacks.onVisibilityChange(e,!0)}else this.visible.has(e)&&(this.visible.delete(e),this.callbacks.onVisibilityChange(e,!1))}}isCurrentGeneration(e){return this.generation===e&&null!==this.intersection}};function Fn(e){if("attributes"!==e.type||e.attributeName!==Pn||1!==e.target.nodeType)return null;const t=e.target;return"astro-island"!==t.tagName.toLowerCase()||t.hasAttribute(Pn)?null:t}function Un(e){if(1!==e.nodeType)return!1;const t=e;return t.matches($n)||null!==t.querySelector($n)}var xn=class{#t=[];#n;#r=!1;constructor(e){this.#n=e}get closed(){return this.#r}own(e){this.#r?this.#i(e):this.#t.push(e)}close(){if(this.#r)return;this.#r=!0;const e=this.#t.splice(0).reverse();for(const t of e)this.#i(t)}#i(e){try{e()}catch(e){this.#n("runtime cleanup failed:",e)}}},Mn="[data-payload-field]";function En(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewHydration??={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]}}function On(){const e=En();if(void 0===e||e.armed)return;e.armed=!0;const t=window,n=t.__REACT_DEVTOOLS_GLOBAL_HOOK__??=function(){const e=/* @__PURE__ */new Map;return{supportsFiber:!0,renderers:e,inject:t=>{const n=e.size+1;return e.set(n,t),n}}}(),r=n.onCommitFiberRoot;n.onCommitFiberRoot=function(t,n,...i){try{r?.call(this,t,n,...i)}catch{}void 0===e.onCommit?e.commits.push(n):e.onCommit(n)}}function In(e){e.committed=!0;const t=e.waiters;e.waiters=[];for(const e of t)e()}function Dn(e,t){const n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function _n(e,t,n){if(e.committed)return null;let r=null;const i=()=>{null!==r&&clearTimeout(r),r=null,t("committed")};return e.waiters.push(i),r=setTimeout(()=>{r=null,Dn(e,i),t("timed-out")},n),()=>{null!==r&&clearTimeout(r),r=null,Dn(e,i)}}var Bn="__vue_app__";function zn(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewVueHydration??={armed:!1,committed:!1,waiters:[]}}function jn(e){return Object.prototype.hasOwnProperty.call(e,Bn)?e[Bn]:void 0}function Hn(){const e=zn();if(void 0===e||e.armed)return;e.armed=!0;const t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,Bn)&&Object.defineProperty(t,Bn,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,Bn,{value:e,writable:!0,configurable:!0,enumerable:!0});const t=zn();void 0===t||t.committed||null===this.querySelector(Mn)||function(e,t){const n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?In(e):n.hook("app:suspense:resolve",()=>{e.committed||In(e)})}(t,e)}})}function Wn(e){const t=e.hydration;if(void 0===t)return void e.startNow();const n=qn[t](e.root,n=>{e.later(()=>{Gn(e,t,n)})});null!==n?(e.defer(n),e.hydrated("waiting")):Gn(e,t,"committed")}var qn={react:(e,t)=>function(e,t=5e3){On();const n=En();if(void 0===n)return null;if(void 0===n.onCommit){const e=e=>{!n.committed&&function(e){const t=e;return null!=t&&function(e){const t=e;return 9===t?.nodeType||null!=t?.querySelector?.(Mn)}(t.containerInfo)&&!function(e){const t=[];for(null!==e.current&&void 0!==e.current&&t.push(e.current);t.length>0;){const e=t.pop();if(void 0===e)continue;const n=e.memoizedState;if((13===e.tag||31===e.tag)&&"object"==typeof n&&null!==n&&"dehydrated"in n&&"object"==typeof n.dehydrated&&null!==n.dehydrated&&"nodeType"in n.dehydrated&&8===n.dehydrated.nodeType)return!0;null!==e.sibling&&void 0!==e.sibling&&t.push(e.sibling),null!==e.child&&void 0!==e.child&&t.push(e.child)}return!1}(t)}(e)&&In(n)};n.onCommit=e;for(const t of n.commits.splice(0))e(t)}return _n(n,e,t)}(t),vue:function(e,t,n=5e3){Hn();const r=zn();return void 0===r?null:(!r.committed&&function(e){for(let t=e.querySelector(Mn);null!==t;t=t.parentElement)if(void 0!==jn(t))return!0;return!1}(e)&&In(r),_n(r,t,n))},sveltekit:function(e,t,n=5e3){const r=e.ownerDocument??e,i=()=>null!==r.querySelector("#svelte-announcer");if(i()||!Object.keys(window).some(e=>e.startsWith("__sveltekit_")))return null;const o={committed:!1,waiters:[]},s=new MutationObserver(()=>{!o.committed&&i()&&In(o)});s.observe(r,{childList:!0,subtree:!0});const a=_n(o,e=>{s.disconnect(),t(e)},n);return()=>{s.disconnect(),a?.()}},manual:function(e,t,n=5e3){const r=function(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewHydrated??={committed:!1,waiters:[]}}();return void 0===r?null:_n(r,t,n)}},Vn={react:"React commit",vue:"Vue mount",sveltekit:"SvelteKit mount",manual:"markHydrated() call"};function Gn(e,t,n){e.hydrated(n),"timed-out"===n&&e.warn(`[live-preview] LP0607: no ${Vn[t]} in ${String(5e3)} ms; started without waiting for hydration.`),e.startNow()}function Kn(e){return 9===e.nodeType}function Jn(e){return e.body}var Qn=class{timeoutMs;onTimeout;handle=null;lastKick=null;constructor(e){this.timeoutMs=e.timeoutMs??0,this.onTimeout=e.onTimeout}kick(){this.lastKick=Date.now(),this.timeoutMs<=0||(this.stop(),this.arm(this.timeoutMs))}resume(){if(this.timeoutMs<=0||null!==this.handle||null===this.lastKick)return!1;const e=Math.max(0,Date.now()-this.lastKick),t=this.timeoutMs-e;return t<=0?(this.lastKick=null,this.onTimeout(),!0):(this.arm(Math.min(t,this.timeoutMs)),!1)}arm(e){const t=setTimeout(()=>{this.handle===t&&(this.handle=null,this.lastKick=null,this.onTimeout())},e);this.handle=t}stop(){null!==this.handle&&(clearTimeout(this.handle),this.handle=null)}get lastKickAt(){return this.lastKick??0}get pending(){return null!==this.handle}},Xn=class{current="disconnected";get status(){return this.current}markConnected(){return this.transition("connected")}markDisconnected(){return this.transition("disconnected")}transition(e){return this.current!==e&&(this.current=e,!0)}},Zn=/* @__PURE__ */new Set(["true","false","yes","no","on","off"]),Yn=/^[\d\s.,:+/-]+$/u,er=/^[a-z][a-z0-9_-]*$/u,tr=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,nr=/* @__PURE__ */new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]);function rr(e,t=13){if("string"!=typeof e)return!1;const n=e.trim();return!(n.length<t||Yn.test(n)||Zn.has(n.toLowerCase())||er.test(n)||tr.test(n))}function ir(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function or(e,t,n=13){const r=/* @__PURE__ */new Map,i=(e,t,n)=>{r.set(e,r.has(e)?null:{field:t,media:n})};for(const[r,o]of Object.entries(e)){if($e.has(r))continue;const e=Fe(r,t);if(rr(o,n))i(o.trim(),e,!1);else if(ir(o))if("string"==typeof o.url)i(o.url,e,!0);else if(!("id"in o)&&!("_id"in o))for(const[t,r]of Object.entries(o))!$e.has(t)&&rr(r,n)&&i(r.trim(),`${e}.${t}`,!1)}return r}function sr(e){if("http://www.w3.org/1999/xhtml"!==e.namespaceURI||nr.has(e.tagName))return!0;if(e.hasAttribute(Tt)||e.hasAttribute("data-payload-no-bind")||e.hasAttribute(ht)||gt(e))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function ar(e){let t;for(let n=e.firstChild;null!==n;n=n.nextSibling){if(1===n.nodeType)return;if(3!==n.nodeType)continue;const e=n.data.trim();if(0!==e.length){if(void 0!==t)return;t=e}}return t}function lr(e){return K(e)&&!e.startsWith("data-payload-")&&"value"!==e}function dr(e,t,n){let r=e.byElement.get(t);void 0===r&&(r={attributes:/* @__PURE__ */new Map},e.byElement.set(t,r));let i=e.byField.get(n.field);return void 0===i&&(i=/* @__PURE__ */new Set,e.byField.set(n.field,i)),i.add(t),r}function ur(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(sr(n))continue;const e=ar(n),r=void 0===e?void 0:t.values.get(e);null==r||r.media||(dr(t,n,r).text=r.field);for(const e of n.getAttributeNames()){if(!lr(e))continue;const r=t.values.get(n.getAttribute(e)??"");null!=r&&(!r.media||"IMG"===n.tagName&&"src"===e)&&dr(t,n,r).attributes.set(e,r)}ur(n,t)}}function cr(e,t,n){const r=e.tagName;if(void 0!==t){const i={[Tt]:t};if("A"===r){const e=n.get("href");void 0===e?i[Ct]="text":e!==t&&(i[Lt]=e)}return{element:e,fieldName:t,matched:ar(e)??"",stamps:i}}if("IMG"===r){const t=n.get("src");if(void 0!==t){const r=n.get("alt");return{element:e,fieldName:t,matched:e.getAttribute("src")??"",attribute:"src",stamps:{[Tt]:t,...void 0!==r&&r!==t?{[Nt]:r}:{}}}}}const i=n.entries().next();if(i.done)return;const[o,s]=i.value;return{element:e,fieldName:s,matched:e.getAttribute(o)??"",attribute:o,stamps:{[Tt]:s,[Pt]:o}}}function hr(e,t){const n={values:t,byElement:/* @__PURE__ */new Map,byField:/* @__PURE__ */new Map};t.size>0&&!sr(e)&&ur(e,n);const r=e=>1===n.byField.get(e)?.size,i=[];for(const[e,t]of n.byElement){const n=void 0!==t.text&&r(t.text)?t.text:void 0,o=/* @__PURE__ */new Map;for(const[e,n]of t.attributes)r(n.field)&&o.set(e,n.field);const s=cr(e,n,o);void 0!==s&&i.push(s)}return i}function fr(e){return 9===e.nodeType?e.body:e}function pr(e,t){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(void 0!==r){r.observed&&e.observers.unobserveElement(r.element);for(let e=r.attributes.length-1;e>=0;e-=1){const t=r.attributes[e];if(void 0===t)continue;const{name:n,before:i,written:o}=t;i!==o&&r.element.getAttribute(n)===o&&(null===i?r.element.removeAttribute(n):r.element.setAttribute(n,i))}r.cacheTouched&&(r.element.hasAttribute(Tt)?e.cache.add(r.element):e.cache.remove(r.element))}}}function gr(e,t,n,r,i){const o=[],s=[],a=()=>(pr(e,s),[]);for(const l of t){if(!i())return a();const{element:t}=l;if(t.hasAttribute(Tt))continue;if(!i())return a();if(!1!==n&&!be(Jt(t),n))continue;if(!i())return a();const d={element:t,attributes:[],cacheTouched:!1,observed:!1};s.push(d);for(const[e,n]of[...Object.entries(l.stamps),[Ht,l.matched]]){const r=t.getAttribute(e);if(!i())return a();if(d.attributes.push({name:e,before:r,written:n}),t.setAttribute(e,n),!i())return a()}if(d.cacheTouched=!0,void 0!==e.cache.add(t)){if(!i())return a();if(e.observers.observeElement(t),d.observed=!0,!i())return a();if(e.log("autoBind",l.fieldName,"→",`<${t.tagName.toLowerCase()}>`,l.attribute??"text",JSON.stringify(l.matched),r),!i())return a();o.push(l)}else pr(e,[d]),s.pop()}return o}function mr(e,t,n,r,i){if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)return;const o=function(e,t){let n,r=e;for(const e of t.split(".")){if("object"!=typeof r||null===r)break;r=r[e];const t=/^\d+$/.test(e)?r?.id:null;"string"!=typeof t&&"number"!=typeof t||(n=`${n??""}/${String(t)}`)}return n}(r,n.fieldName);if(void 0===o)return;if(i)return void t.rowsOfBinding.delete(n.element);const s=t.rowsOfBinding.get(n.element);t.rowsOfBinding.set(n.element,o),void 0!==s&&s!==o&&X(e,t,n,"stands in a row that moved",o)}function vr(e,t,n,r){if(!e.scopeBindingsByOwner)return!1;const{message:i}=n,o=function(e){if(ye(e.globalSlug))return[(t=e.globalSlug,`global:${t}`)];var t;if(!ye(e.collectionSlug))return null;const n=ve(e.collectionSlug);return ye(e.documentId)?[n,ve(e.collectionSlug,e.documentId)]:[n]}({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:we(r)});return null!==o||t.warnedUnattributableMessage||(t.warnedUnattributableMessage=!0,e.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),o}var yr=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;awaitingHydration=/* @__PURE__ */new WeakSet;delivered=/* @__PURE__ */new WeakMap;confirmations=/* @__PURE__ */new WeakMap;reapplyBindings(e){const t=this.currentTransaction();void 0!==t?.renderData&&this.host.schedule(t,t.renderData,e)}reapplyIslands(e,t=!1){const n=t?e.filter(e=>this.awaitingHydration.delete(e)):e,r=this.state.activeUpdate,i=t&&null!==r&&this.state.isCurrent(r)?r:this.currentTransaction();void 0!==i?.renderData&&this.dispatchIslands(i,i.renderData,n)}dispatchIslands(e,t,n){const r=vr(this.deps,this.state,e,t.fields),i=()=>!e.cancelled&&this.state.isCurrent(e);if(!i())return;let o=this.delivered.get(t);void 0===o&&(o=/* @__PURE__ */new WeakSet,this.delivered.set(t,o));for(const s of n){const n=Jt(s);if(!i())return;if(!1!==r&&!be(n,r)){this.awaitingHydration.delete(s);continue}const a=this.confirmation(s,e);if(mt(s))this.awaitingHydration.add(s);else{if(this.awaitingHydration.delete(s),o.has(s))continue;o.add(s),br(e,t,[s],i,a)}}}hasLateRouteBinding(e,t,n,r){for(const r of e){if((r.getAttribute(Tt)??"").length>0||"route"!==r.getAttribute(zt))continue;if(!1!==t&&!be(Jt(r),t))continue;const e=st(r.getAttribute(Bt));if(0===e.length||e.some(e=>n.touched.has(e)))return!0}for(const[i,o]of this.deps.cache.entries())for(const s of o){if(!e.has(s.element))continue;if(!1!==t&&!be(s.owner,t))continue;if("route"!==(s.strategyKind??me(s.element)??"unknown"))continue;const o=ue(r.fields,s,i,n.locale);if(!this.state.isCurrent(n))return!1;if(void 0!==o)return!0}return!1}fieldsForElements(e,t){const n=new Set(t);for(const[t,r]of this.deps.cache.entries())r.some(t=>e.has(t.element))&&n.add(t);return n}unrunFragmentPlan(e,t,n){if(null===t)return null;const r=t.boundaries.filter(t=>!e.fragmentBoundariesRun.has(t)&&(void 0===n||[...n].some(e=>e===t||t.contains(e))));return ge(t.strategy,r,t.ownerKeys)}confirmation(e,t){const n=this.confirmations.get(e);if(n?.transaction===t)return n.displayed;const r=this.state.display.handIsland(t);return this.confirmations.set(e,{transaction:t,displayed:r}),r}currentTransaction(){const e=this.state.activeUpdate;return this.state.navigationBindingReplay&&null!==e&&this.state.isCurrent(e)?e:null}};function br(e,t,n,r,i){!function(e,t,n){let r=0;for(const i of e){if(!n())break;if(i.dispatchEvent(new CustomEvent(dt,{detail:t,bubbles:!1})),r+=1,!n())break}}(n,{fields:t.fields,revision:e.revision.revision,receivedAt:e.receivedAt,locale:e.locale,displayed:i},r)}var wr=" subfieldCoverage";function Sr(e,t,n,r,i){const{warned:o,warn:s}=e;if(o.has(n)||t(n))return;o.add(n);const a=`data-payload-field="${Fe(n,r)}"`;s(""!==i?`[live-preview] LP0203: field "${n}" has a value and no <… ${a}> on this page; editing it changes nothing here. Expected where the page shows part of the document: inspect().fidelity.fields lists these, onUnfaithfulPatch decides whether a server render is asked for.`:`[live-preview] LP0201: no <… ${a}> for the empty field "${n}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)}function Ar(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function kr(e){return Array.isArray(e.docs)&&"boolean"==typeof e.hasNextPage}function Rr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var Tr=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function Cr(e){const t=function(){const e=function(){const e=globalThis,t=e[Tr];if(void 0!==t)return t;const n={};return e[Tr]=n,n}();if(void 0!==e.override)return e.override;if(void 0!==e.auto)return e.auto;const t=function(){const e=globalThis.trustedTypes;if("object"==typeof e&&null!==e)return"function"==typeof e.createPolicy?e:void 0}();try{e.auto=void 0===t?null:t.createPolicy("payload-live-preview",{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===t?e:t.createHTML(e)}var Pr=/* @__PURE__ */new Set(["open","value","checked","selected"]);function Lr(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function $r(e,t,n){if(!Ur(e,t))return t;const r=n.boundary??ft,i=r(e),o=r(t);if(i||o)return i&&o&&(n.retainBoundary?.(e,t)??1)?e:t;const s=xr(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||Pr.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(const n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}(e,t),!0!==n.retainChildrenOf?.(e,t)&&function(e,t,n){const r=function(e,t){const n=/* @__PURE__ */new Map;let r;for(const i of Array.from(e.children)){const e=Lr(i,t);void 0!==e&&(n.has(e)?r??=e.slice(e.indexOf("=")+1):n.set(e,i))}return void 0!==r&&t.onDuplicateKey?.(e,r),n}(e,n),i=new Set(r.values()),o=Array.from(e.childNodes).filter(e=>!i.has(e)),s=/* @__PURE__ */new Set,a=/* @__PURE__ */new Set,l=Array.from(t.childNodes);let d=e.firstChild,u=0;for(let t=0;t<l.length;t+=1){const i=l[t];let c=null,h=i instanceof Element?Lr(i,n):void 0;if(void 0!==h&&a.has(h)&&(h=void 0),void 0!==h){a.add(h);const e=r.get(h);if(void 0!==e&&!s.has(e)&&(c=Nr(e,i,n)===e?e:null,null===c)){e.replaceWith(i),s.add(i),d=i.nextSibling;continue}}else{for(;u<o.length;){const r=o[u];if(u+=1,!s.has(r)){if(Ur(r,i)){c=Nr(r,i,n)===r?r:null,null===c&&(e.replaceChild(i,r),s.add(i),d=i.nextSibling);break}if(r instanceof Element){const n=l[t+1];if(!(i instanceof Element)||void 0!==n&&Ur(r,n)){u-=1;break}e.replaceChild(i,r),s.add(i),d=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,r),s.add(i),d=i.nextSibling;break}}}if(null===c&&s.has(i))continue}const f=c??i;for(s.add(f);null!==d&&d!==f&&!s.has(d)&&Fr(d);)d=d.nextSibling;f!==d&&e.insertBefore(f,d),d=f.nextSibling}for(const t of Array.from(e.childNodes))s.has(t)||t.remove()}(e,t,n),Mr(s),e}function Nr(e,t,n){return e instanceof Element&&t instanceof Element?$r(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function Fr(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function Ur(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function xr(e){const t=e.ownerDocument.activeElement;return t instanceof HTMLElement&&e.contains(t)?{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}:null}function Mr(e){if(null===e)return;const{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});const[e,r]=n??[null,null];null!==e&&null!==r&&t.setSelectionRange(e,r)}catch{}}function Er(e,t){if(!function(){try{const e=globalThis.process?.env;return void 0!==e&&"production"!==e.NODE_ENV}catch{return!1}}())return;const n=globalThis,r=n.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!r.has(e)){r.add(e);try{console.warn(`[payload-live-preview] ${t}`)}catch{}}}var Or=/* @__PURE__ */new Set;function Ir(e){Or.has(e)||(Or.add(e),function(e){try{console.warn(e)}catch{}}(`[live-preview] LP0409: the strict sanitizer removed \`${e}\` from written markup; the 1.x default (\`sanitizerPolicy: 'compat'\`) kept it. ${function(e){return e.startsWith("data-payload-")?"A binding inside CMS content is refused by design — an editor could otherwise aim a write at any element on the page (docs/security.md)":"id"===e||"name"===e?"CMS content that can name an element can shadow a global of that name — DOM clobbering, refused by design (docs/security.md)":"Put it on an element the template owns, or set `sanitizerPolicy: 'compat'` to keep every `data-*` as 1.x did"}(e)}.`))}var Dr=/* @__PURE__ */new Set(["p","br","strong","b","em","i","u","s","strike","mark","small","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","blockquote","code","pre","kbd","samp","var","a","span","div","section","article","aside","header","footer","nav","figure","figcaption","img","picture","source","audio","video","sub","sup","hr","time","abbr","cite","q","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col"]),_r=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),Br=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),zr=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),jr="aria-",Hr="data-",Wr={a:/* @__PURE__ */new Set(["href","target","rel","download","hreflang","type"]),img:/* @__PURE__ */new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:/* @__PURE__ */new Set([]),source:/* @__PURE__ */new Set(["src","srcset","sizes","type","media"]),audio:/* @__PURE__ */new Set(["src","controls","autoplay","loop","muted","preload"]),video:/* @__PURE__ */new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:/* @__PURE__ */new Set(["datetime"]),abbr:/* @__PURE__ */new Set(["title"]),q:/* @__PURE__ */new Set(["cite"]),blockquote:/* @__PURE__ */new Set(["cite"]),table:/* @__PURE__ */new Set(["summary"]),th:/* @__PURE__ */new Set(["colspan","rowspan","scope","headers","abbr"]),td:/* @__PURE__ */new Set(["colspan","rowspan","headers"]),col:/* @__PURE__ */new Set(["span"]),colgroup:/* @__PURE__ */new Set(["span"]),ol:/* @__PURE__ */new Set(["start","reversed","type"]),li:/* @__PURE__ */new Set(["value"]),code:/* @__PURE__ */new Set(["class"]),pre:/* @__PURE__ */new Set(["class"])},qr=/* @__PURE__ */new Set(["href","src","cite","poster","action","formaction"]),Vr=class extends Error{name="SanitizerEnvironmentError"},Gr=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-morph","data-payload-nested-key","data-payload-nested-template"]),Kr=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function setSanitizerDocument(e){Er("set-sanitizer-document","`setSanitizerDocument()` is removed in 3.0: pass the document per call, `sanitizeHtml(html, { document })` or `lexicalToHtml(content, { document })` (ADR 0026)."),globalThis[Kr]=e??void 0}function sanitizeHtml(e,t){return Jr(e,void 0,t)}function Jr(e,t,n){const r=n?.document??Zr();if(!r)throw Qr();if(""===e)return"";const i=function(e,t){const n=e?.policy??t??"strict";if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(Wr))e.set(t,n);return{allowedTags:Dr,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const r=new Set(Dr);if(e.additionalAllowedTags?.forEach(e=>r.add(e)),!0===e.allowFormControls)for(const e of _r)r.add(e);const i=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(Wr))i.set(e,t);for(const[t,n]of Object.entries(e.additionalAllowedAttributes??{})){const e=new Set(i.get(t));for(const t of n)e.add(t);i.set(t,e)}return{allowedTags:r,attrByTag:i,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(n,t);let o=e;for(let e=0;e<6;e+=1){const e=r.createElement("template");e.innerHTML=Cr(o);const t=e.content;Yr(t,i);const n=Xr(t);if(n===o)return n;o=n}return Er("sanitizer-unsettled",`sanitizeHtml: the output did not settle after ${String(6)} passes, so it returned an empty string (ADR 0016).`),""}function Qr(){return"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new Vr("sanitizeHtml needs a DOM; pass one per call during SSR: { document } (linkedom, jsdom).")}function Xr(e){const t=e.ownerDocument?.createElement("div");if(void 0===t)throw Qr();const n=e.firstChild;if(t.append(e),t.firstChild!==n)throw Qr();return t.innerHTML}function Zr(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[Kr];if(e)return e}if("undefined"!=typeof document)return document}function Yr(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?ei(n,t):8===n.nodeType&&n.remove()}function ei(e,t){const n=e.tagName.toLowerCase();if(!Br.has(n)||t.allowFormControls&&_r.has(n)){if(!t.allowedTags.has(n))return Yr(e,t),void e.replaceWith(...e.childNodes);!function(e,t,n){const r=n.attrByTag.get(t);for(const t of Array.from(e.attributes)){const i=t.name.toLowerCase();if(i.startsWith("on")||"style"===i)e.removeAttribute(t.name);else if("is"!==i){if("strict"===n.mode){if(n.templateMode&&Gr.has(i))continue;if("id"===i||"name"===i||i.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===i&&!0!==r?.has(i)||Ir(i);continue}if(i.startsWith(Hr)){n.allowedData.has(i)||(e.removeAttribute(t.name),Ir(i));continue}if(zr.has(i)||i.startsWith(jr))continue}else if(zr.has(i)||i.startsWith(jr)||i.startsWith(Hr))continue;r?.has(i)?qr.has(i)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):("srcset"!==i||ti(t.value))&&("ping"!==i||t.value.trim().split(/\s+/u).every(isSafeUrl))||e.removeAttribute(t.name):e.removeAttribute(t.name)}else e.setAttribute("is","")}}(e,n,t),"a"===n&&function(e){const t=e.getAttribute("href");null!==t&&isExternalHttpUrl(t)&&(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),Yr(e,t)}else e.remove()}function ti(e){for(const t of e.split(",")){const e=t.trim();if(0===e.length)continue;const[n=e]=e.split(/\s/,1);if(!isSafeUrl(n)||!isSafeUrl(e))return!1}return!0}var ni=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}),ri=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(ri,e=>ni[e])}var ii=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'"}),oi=/[&<>"']/g;function escapeHtmlAttribute(e){return e.replace(oi,e=>ii[e])}var si=/\{\{([\s\S]*?)\}\}/g;function ai(e){const t=/* @__PURE__ */new Set;for(const n of e)if("object"==typeof n&&null!==n)for(const e of Object.keys(n))t.add(e);return t}function li(e,t,n,r,i){const o="object"==typeof t&&null!==t?t:null;return e.replace(si,(e,s)=>null!==o&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(o,s)?escapeHtml(r(Reflect.get(o,s))):null===o&&"value"===s?escapeHtml(r(t)):"index"===s?String(n):null!==o&&!0===i?.has(s)?"":e)}function di(e){const t=e.children,n=t[0];if(void 0===n)return[];const r=[];for(const{name:e,value:i}of Array.from(n.attributes)){if(!K(e)||e.startsWith("data-payload-"))continue;let n=!0;for(let r=1;r<t.length&&n;r+=1)n=t[r]?.getAttribute(e)===i;n&&r.push([e,i])}return r}function ui(e,t){for(const[n,r]of t)e.hasAttribute(n)||e.setAttribute(n,r)}function ci(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)return String(e);try{return JSON.stringify(e)}catch{return""}}function hi(e){return null==e||""===e}function fi(e,t){const n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function pi(e,t,n,r){return e.set(t,n),function(e,t){for(const n of e.keys()){if(e.size<=t)break;e.delete(n)}}(e,r),n}var gi=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],mi=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],vi=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,yi=/* @__PURE__ */new Map;function bi(e){const t=fi(yi,e);if(void 0!==t)return t;const n=new Set(gi);for(const t of e.matchAll(vi)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const r={};for(const e of n)r[e]=mi;const i={additionalAllowedTags:[...n],additionalAllowedAttributes:r,allowFormControls:!0,templateMode:!0};return pi(yi,e,i,64)}var wi="data-payload-key",Si="data-payload-nested-key",Ai="data-payload-nested-template";function ki(e){const t=Ti(e.container,e.patches,e);return null===t?null:Ci(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function Ri(e,t){return t.hasAttribute(Si)&&t.hasAttribute(Ai)}function Ti(e,t,n){const r=function(e,t,n){const{template:r,nextItems:i,forceRender:o=!1,store:s,sanitizerPolicy:a}=n,l=s.get(e),d=di(e),u=ai(i),c=Array.from(e.children),h=xi(c,wi),f=/* @__PURE__ */new Set,p=[];for(let s=0;s<i.length;s+=1){const g=i[s],m=Ui(g);let v=void 0===m?c[s]??null:Mi(h,m)??null;null!==v&&f.has(v)&&(v=null),null!==v&&f.add(v);const y=t.replaces.has(s),b=o||t.renders.has(s)||null===v?Ei(e.ownerDocument,r,g,s,a,d,u):void 0;if(null===b)return null;const w=void 0===b?[]:Pi(y?null:v,b,g,void 0===m?void 0:l?.get(m),n);if(null===w)return null;p.push([s,v,b,w,y])}return p}(e,function(e){const t=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set;for(const r of e)"insert"===r.kind||"update"===r.kind?t.add(r.index):"replace"===r.kind&&(t.add(r.index),n.add(r.index));return{renders:t,replaces:n}}(t),n);return null===r?null:[e,r,n.nextItems]}function Ci(e,t,n){const[r,i,o]=e,s=/* @__PURE__ */new Set;let a=!1;const l=xr(r);for(const[e,o,l,d,u]of i){let i=o;if(void 0!==l){const e=!(!n.morph||u||null===o)&&$r(o,l,{keyAttributes:[wi,Si],boundary:ft,retainBoundary:At,retainChildrenOf:Ri,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===o;if(!e)for(const[e,t]of d)null!==e&&($i(e,t),t.replaceWith(e));for(const[,,e]of d)void 0!==e&&Ci(e,t,n);e?a=!0:(null!==o&&(o.replaceWith(l),a=!0),i=l)}if(null===i)continue;const c=r.children[e]??null;i!==c&&(r.insertBefore(i,c),a=!0),s.add(i)}for(const e of Array.from(r.children))s.has(e)||(e.remove(),a=!0);Mr(l);const d=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(r,t);d.clear();for(const e of o)Fi(d,e);return a}function Pi(e,t,n,r,i){const o=xi(null===e?[]:Li(e),Si),s=[];for(const e of Li(t)){const t=e.getAttribute(Si);if(null===t)continue;const a=Mi(o,t)??null,l=e.getAttribute(Ai),d=l?a:null,u=d?.getAttribute(Ai)??null;let c;if(l){const o=Ni(n,t);if(void 0!==o||null!==d){const n=o??[],s=I(null===d?[]:Ni(r,t)??[],n),a=null!==d&&u!==l;if((s.length>0||a)&&(c=Ti(d??e,s,{template:l,nextItems:n,forceRender:a,store:i.store,sanitizerPolicy:i.sanitizerPolicy})??void 0,void 0===c))return null}}s.push([d,e,c])}return s}function Li(e){return Array.from(e.querySelectorAll(`[${Si}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(Si))return!1;n=n.parentElement}return n===e})}function $i(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||e.removeAttribute(n.name);for(const n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function Ni(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function Fi(e,t){const n=Ui(t);void 0!==n&&e.set(n,t)}function Ui(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function xi(e,t){const n=/* @__PURE__ */new Map;for(let r=e.length-1;r>=0;r-=1){const i=e[r];if(void 0===i)continue;const o=i.getAttribute(t);if(null===o)continue;const s=n.get(o);void 0===s?n.set(o,[i]):s.push(i)}return n}function Mi(e,t){return e.get(t)?.pop()}function Ei(e,t,n,r,i,o,s){const a=Jr(li(t,n,r,ci,s),i,bi(t)),l=e.createElement("template");l.innerHTML=Cr(a);const d=l.content.firstElementChild;if(!d)return null;ui(d,o);const u=Ui(n);return void 0!==u&&d.setAttribute(wi,u),d}function Oi(e,t,n){t.warnedFragmentFallback||(t.warnedFragmentFallback=!0,e.warn(`[live-preview] LP0806: "${n.fieldName}" asks for the fragment strategy but no handler is configured; patching instead`))}function Ii(e,t,n){t.warnedStrategy.has(n.element)||(t.warnedStrategy.add(n.element),e.warn(`[live-preview] LP0407: "${n.fieldName}" asks for strategy "${String(n.strategy)}"; only patch, fragment and route exist`))}function Di(e,t,n){if(t.warnedEscalationUnavailable)return;t.warnedEscalationUnavailable=!0;const r=`[live-preview] LP0808: onUnfaithfulPatch: 'escalate' has nowhere to go: ${String(n)} field(s) fell short`,i="or onUnfaithfulPatch: 'warn' to keep the patch and say so.";e.warn(void 0===e.strategies.fragment?`${r} and no route or fragment strategy is configured. Set routeStrategy: true or fragments: { endpoint }, ${i}`:`${r}, not all of them inside a data-payload-fragment boundary of this document, and no route strategy is configured. Cover them with a boundary or add the route strategy, ${i}`)}var _i=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;planFragments(e,t){const{deps:n,state:r}=this,i=n.strategies.fragment;if(void 0===i)return null;const o=new Set(i.plan(n.root,e));for(const e of r.fragmentsOwed)n.root.contains(e)?o.add(e):r.fragmentsOwed.delete(e);return ge(i,[...o].filter(e=>Bi(e,t)),t)}escalateUnfaithful(e,t,n,r){if(e.routeRefreshed)return void this.kept(e,n);const{fragment:i,route:o}=this.deps.strategies,s=void 0===i?void 0:function(e){const t=[];for(const n of e){const e=n.fragmentBoundary;if(void 0===e)return;t.includes(e)||t.push(e)}return t}(n),a=void 0===s||s.every(e=>Bi(e,r))?s:void 0;return void 0!==i&&void 0!==a?(this.state.escalatedCount+=n.length,e.pendingFragments+=a.length,void this.runFragments(e,t,ge(i,a,r))):void 0===o?(Di(this.deps,this.state,n.length),void this.kept(e,n)):(this.state.escalatedCount+=n.length,void this.refreshRoute(e,t,o))}kept(e,t){for(const n of t)this.state.display.shortfall(e,{kind:"unfaithful",field:n.fieldName})}hasUnboundChange(e,t){const{deps:n,state:r}=this;if(e.baseline||e.routeRefreshed)return!1;const i=Ee(n.cache,e.touched,e.locale,t,this.subfields(e),n.strategies);let o=0;for(const e of i)Z(r,e)&&(o+=1);const[s]=i;if(void 0===s)return!1;if("escalate"!==n.onUnfaithfulPatch||void 0===n.strategies.route){"escalate"===n.onUnfaithfulPatch&&Di(n,r,i.length);for(const t of i)r.display.shortfall(e,{kind:"unbound",field:t});return!1}return e.navigated?(r.routeAwaitsSave=!0,r.display.shortfall(e,{kind:"route-saved"}),!1):(n.log("route","LP0807",`field "${s}" has no binding; refreshing the route`),r.escalatedCount+=o,!0)}subfields(e){const{previousFields:t}=this.state.changes;return Me(this.deps.subfieldCoverage,t,e.renderData?.fields)}plansRoute(e,t,n){const r=e=>!1===n||be(e,n),i=function(e,t,n){const r=e.rendered.flatMap(e=>"route"===e.strategy?e.paths:[]);for(const[t,n]of e.entries())n.some(e=>"route"===e.strategyKind)&&r.push(t);const i=new Set(t);for(const e of r){const[r=e]=e.split(".");t.has(r)&&(void 0===n||Pe(e,n.previous,n.next))&&i.add(e)}return i}(this.deps.cache,t.touched,this.subfields(t));if(e.plan(this.deps.root,i,{inScope:e=>r(Jt(e))}))return!0;for(const[e,t]of this.deps.cache.entries())if(i.has(e)&&t.some(e=>"route"===e.strategyKind&&r(e.owner)))return!0;return!1}async runFragments(e,t,n){const{deps:r,state:i}=this,o=new AbortController,s=new Set(n.boundaries);for(const e of s)i.fragmentsOwed.delete(e);i.fragmentControllers.set(o,s);const a=t=>{s.delete(t)&&(e.pendingFragments-=1)},l=()=>i.isCurrent(e)&&!o.signal.aborted,d=e=>function(e,t,n){if(t.isConnected)return t;const r=t.getAttribute(he),i=t.getAttribute(fe);let o;for(const t of e.querySelectorAll(`[${he}]`))if(t.getAttribute(he)===r&&t.getAttribute(fe)===i&&n(t)){if(void 0!==o)return;o=t}return o}(r.root,e,e=>Bi(e,n.ownerKeys)),{emitter:u}=r,{message:c}=e,h=e.revision.revision,f=e.receivedAt,p={root:r.root,revision:h,receivedAt:f,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof c.collectionSlug?c.collectionSlug:void 0,globalSlug:"string"==typeof c.globalSlug?c.globalSlug:void 0,signal:o.signal,isCurrent:l,log:(e,t)=>{r.log("fragment",e,t)},morph:(e,t)=>{const n=l()?d(e):void 0;void 0!==n&&function(e,t,n){const r=e.ownerDocument.createElement("template");r.innerHTML=Cr(t);const i=e.cloneNode(!1);i.append(r.content);const o=kt(e);$r(e,i,{keyAttributes:[wi],boundary:ft,retainBoundary:At}),function(e){for(const t of e)t.isConnected||bt.has(t)||(bt.add(t),t.dispatchEvent(new CustomEvent("astro:unmount")))}(o);const s=new Set(o);for(const t of kt(e)){const e=s.has(t)?void 0:Rt(t);void 0!==e&&n(t,e)}}(n,t,(e,t)=>{!function(e,t,n,r){if(t.warnedIslandStart)return;t.warnedIslandStart=!0;const i="element"===r?"<astro-island>":`client:${n.getAttribute("client")??""}`;e.warn(`[live-preview] LP0809: a fragment island cannot start: this page never loaded ${i}; render one on the page`)}(this.deps,this.state,e,t)})},patch:r=>{const i=d(r);void 0!==i&&(i!==r&&this.host.rebuildCache(),this.patchFallback(e,t,i,n.ownerKeys,l))},rendered:(e,t,n)=>{a(e);const r=d(e)??e;u.emitWhile("fragmentRender",{element:r,id:t,key:n,status:"rendered",revision:h,receivedAt:f},l)},failed:(t,n,o,s,c)=>{a(t);const p=d(t)??t;i.display.shortfall(e,{kind:"fragment",id:n,key:o,code:s});const g=`fragment "${n}" fell back to patch: ${c}`;r.log("fragment",s,g),u.emitWhile("error",{error:new Error(g),context:"fragment",code:s},l),u.emitWhile("fragmentRender",{element:p,id:n,key:o,status:"failed",code:s,revision:h,receivedAt:f},l)}};let g={rendered:0,failed:0,superseded:0};try{g=await n.strategy.render(p,n.boundaries)}catch(t){if(r.log("fragment","LP0801",t),l()){for(const t of n.boundaries)p.patch(t),i.display.shortfall(e,tt(t));g={rendered:0,failed:n.boundaries.length,superseded:0}}}i.fragmentStats.rendered+=g.rendered,i.fragmentStats.failed+=g.failed,i.fragmentStats.superseded+=g.superseded,i.fragmentControllers.delete(o);for(const e of s)a(e);l()&&(g.rendered>0&&this.host.restoreGuesses(e,t),0===e.pendingFragments&&0===r.scheduler.pendingCount&&i.complete(e),this.host.revealPending(e),l()&&0!==g.rendered&&0!==u.listenerCount("afterUpdate")&&u.emitWhile("afterUpdate",{data:t,updatedCount:g.rendered,durationMs:Date.now()-f,revision:h,receivedAt:f,source:"fragment"},l))}async refreshRoute(e,t,n){const{deps:r,state:i}=this;if(e.routeRefreshed)return i.routeStats.loopStopped+=1,void r.log("route","LP0805",`revision ${String(e.revision.revision)} asked for a second refresh`);e.routeRefreshed=!0,await this.runRoute(e,t,n,!1).catch(e=>{this.routeFailed(e)})}refreshAfterSave(){const{deps:e,state:t}=this,{route:n}=e.strategies,r=t.activeUpdate;t.routeAwaitsSave&&void 0!==n&&void 0!==r?.renderData&&(e.log("route","document saved; refreshing the route"),this.runRoute(r,r.renderData,n,!0).catch(e=>{this.routeFailed(e)}))}routeFailed(e){this.deps.log("route refresh failed:",e)}armRouteRetry(e,t,n,r,i){const{state:o}=this;null!==o.routeRetry&&clearTimeout(o.routeRetry),o.routeRetry=setTimeout(()=>{o.routeRetry=null,o.isCurrent(e)&&this.runRoute(e,t,n,i).catch(e=>{this.routeFailed(e)})},r)}async runRoute(e,t,n,r){const{deps:i,state:o}=this;if(i.routeAfterSave&&!r)return o.routeAwaitsSave=!0,void o.display.shortfall(e,{kind:"route-saved"});const s=o.routeStats,a=new AbortController;o.routeController?.abort(),o.routeController=a;const l=()=>!a.signal.aborted;let d;try{d=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:a.signal,isCurrent:l,log:(e,t)=>{i.log("route",e,t)},retryAfter:i=>{this.armRouteRetry(e,t,n,i,r)}})}catch(e){i.log("route","LP0801",e),d="failed"}if(!l())return;o.routeController=null;const u=o.activeUpdate;if(null===u)return;const c=u.renderData,h=()=>o.isCurrent(u);if("partial"===d?o.display.shortfall(u,{kind:"route-saved"}):("failed"===d||"superseded"===d||"refused"===d&&null===o.routeRetry)&&o.display.shortfall(u,{kind:"route-failed",outcome:d}),"refreshed"===d||"partial"===d){if(s.refreshes+=1,"partial"===d&&(s.partial+=1),o.routeAwaitsSave="partial"===d&&!r,o.lastAppliedIdentity=/* @__PURE__ */new WeakMap,void 0!==c&&this.host.restoreGuesses(u,c),this.host.rebuildCache(),void 0===c||!h())return;return this.host.reapply(u,c),void(i.emitter.listenerCount("afterUpdate")>0&&i.emitter.emitWhile("afterUpdate",{data:c,updatedCount:i.cache.elementCount,durationMs:Date.now()-u.receivedAt,revision:u.revision.revision,receivedAt:u.receivedAt,source:"route"},h))}"failed"===d?s.failed+=1:"refused"===d&&(s.refused+=1),void 0!==c&&this.host.reapply(u,c)}warnFragmentFallback(e){Oi(this.deps,this.state,e)}warnUnsupportedStrategy(e){Ii(this.deps,this.state,e)}patchFallback(e,t,n,r,i){if(i())for(const[o,s]of this.deps.cache.entries())for(const a of s){if(a.fragmentBoundary!==n)continue;if(!1!==r&&!be(a.owner,r))continue;const s=ue(t.fields,a,o,e.locale);void 0!==s&&i()&&this.deps.scheduler.schedule({target:a,value:this.host.transform(a,s,t.fields,i),allFields:t.fields,revision:e.revision,data:t})}}};function Bi(e,t){return!1===t||be(Jt(e),t)}function zi(e,t,n,r,i){const o=e.transformValue;if(void 0===o)return n;try{const e=o(t.fieldName,n,{element:t.element,allFields:r},i),s=y(e);if(!i())return n;if(s)throw new TypeError(`Transform for "${t.fieldName}" returned a thenable; transforms must be synchronous`);return e}catch(t){if(!i())return n;const r=t instanceof Error?t:new Error(String(t));return e.emitter.emit("error",{error:r,context:"transform",code:"LP0602"}),n}}var ji=/* @__PURE__ */new Set,Hi={kind:"merge"},Wi=class{constructor(e,t,n){this.deps=e,this.state=t,t.changes.keepValues="declared"===e.subfieldCoverage,t.display.host=function(e,t){return{outstanding:n=>!n.completed||n.pendingFragments>0||null!==t.routeController||null!==t.routeRetry||e.scheduler.pendingCount>0,report:t=>{"partial"===t.state&&e.a11y?.announcePartial(),e.emitter.emit("revisionDisplay",t)},failed:t=>{e.log("revision display failed:",t)}}}(e,t),this.strategies="undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e,t){return{planFragments:()=>null,escalateUnfaithful:(e,n,r)=>{for(const{fieldName:n}of r)t.display.shortfall(e,{kind:"unfaithful",field:n})},hasUnboundChange:(n,r)=>{if(n.baseline)return!1;const i=Ee(e.cache,n.touched,n.locale,r,Me(e.subfieldCoverage,t.changes.previousFields,n.renderData?.fields));for(const e of i)Z(t,e),t.display.shortfall(n,{kind:"unbound",field:e});return!1},plansRoute:()=>!1,runFragments:()=>Promise.resolve(),refreshRoute:()=>(L("route refreshes"),Promise.resolve()),refreshAfterSave:()=>{},warnFragmentFallback:n=>{L("server-rendered fragments"),Oi(e,t,n)},warnUnsupportedStrategy:n=>{Ii(e,t,n)}}}(e,t):new _i(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,r,i)=>zi(e,t,n,r,i),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}}),this.navigationReplay=new yr(e,t,{schedule:(e,t,n)=>{this.scheduleAllFields(e,t,n)}})}deps;state;strategies;navigationReplay;handleUpdate(e,t,n){const{deps:r,state:i}=this;r.heartbeat.kick(),i.protocol.observe(function(e){const t=[];return Array.isArray(e.fieldSchemaJSON)&&t.push("schema-json"),"string"==typeof e.locale&&t.push("locale"),"string"==typeof e.previewToken&&t.push("preview-token"),"object"==typeof e.externallyUpdatedRelationship&&null!==e.externallyUpdatedRelationship&&t.push("relationship-events"),t}(e),r.log,r.warn);const o=e.data;void 0!==o?void 0!==n&&this.acceptDataUpdate(e,o,t,n,!0):void 0!==e.protocolVersion&&i.protocol.applyVersion(e.protocolVersion,r.log)}handleReplay(e,t,n){const r=e.data;void 0!==r&&this.acceptDataUpdate(e,r,t,n,!1)}reapplyNavigationBindings(e){this.navigationReplay.reapplyBindings(e)}reapplyNavigationIslands(e,t=!1){this.navigationReplay.reapplyIslands(e,t)}acceptDataUpdate(e,t,n,r,i){const{deps:o,state:s}=this,a=i?s.relationships.inspect(e):null,l="string"==typeof e.locale?e.locale:s.locale;let d=s.schema,u=s.schemaIndex;Array.isArray(e.fieldSchemaJSON)&&(d=e.fieldSchemaJSON,u=function(e,t=""){const n=/* @__PURE__ */new Map;return x(e,t,n,!1),x(e,t,n,!0),n}(e.fieldSchemaJSON));const c=s.activeUpdate;if(!s.isRunning()||null!==c&&c.revision.revision>r.revision)return;const h=null===a?null:s.relationships.commit(a),f=c,p={revision:r,message:e,rawData:t,locale:l,schema:d,schemaIndex:u,receivedAt:Date.now(),forceRender:null!==h||Ge(f),countsAsUpdate:i,renderData:void 0,fragmentBoundariesRun:/* @__PURE__ */new WeakSet,touched:/* @__PURE__ */new Set,baseline:!1,navigated:!1,invalidated:/* @__PURE__ */new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1};if(s.locale=l,s.schema=d,s.schemaIndex=u,null!==f&&!f.completed&&f.countsAsUpdate&&(s.supersededCount+=1),s.activeUpdate=p,i&&(s.updateCount+=1),s.display.begin(p,r.revision),s.isCurrent(p)&&(o.scheduler.acceptRevision(r),s.isCurrent(p)&&(s.supersedeStrategies(),s.isCurrent(p)&&(null===h||(o.emitter.emitWhile("relationshipUpdate",{detail:h,timestamp:Date.now()},()=>s.isCurrent(p)),s.isCurrent(p)))&&(!i||void 0===e.protocolVersion||(s.protocol.applyVersion(e.protocolVersion,o.log),s.isCurrent(p)))))){if(i&&o.connection.markConnected()){if(o.a11y?.announceConnected(),o.emitter.emit("connect",{origin:n,timestamp:Date.now()}),!s.isCurrent(p))return;if(o.log("connection","disconnected","→","connected"),!s.isCurrent(p))return}this.processUpdate(p).catch(e=>{o.log("update failed:",e)})}}async processUpdate(e){const{deps:t,state:n}=this,r=await this.resolveIncomingFields(e);if(null===r||!n.isCurrent(e))return;const i=this.dataFor(e,r);t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:i,revision:e.revision.revision,receivedAt:e.receivedAt,source:"patch",cancel:()=>{e.cancelled=!0,t.scheduler.cancelRevision(e.revision)}},()=>!e.cancelled&&n.isCurrent(e))||e.cancelled||!n.isCurrent(e))||this.applyFields(e,i,!1)}dataFor(e,t){const{message:n}=e;return{fields:t,...void 0!==e.schema?{schema:e.schema}:{},..."string"==typeof n.globalSlug?{globalSlug:n.globalSlug}:{},..."string"==typeof n.collectionSlug?{collectionSlug:n.collectionSlug}:{},...void 0!==e.locale?{locale:e.locale}:{}}}applyFields(e,t,n){const{deps:r,state:i}=this;if(!i.isCurrent(e))return;if(i.changes.isBaseline&&!n&&"off"!==r.autoBind){if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)L("auto-binding");else{const n=vr(r,i,e,t.fields);!function(e,t,n,r,i,o){if(!o())return 0;const s=performance.now(),a=fr(e.root),l=or(n,r);if(!o())return 0;const d=null===a?[]:hr(a,l);if(!o())return 0;const u=gr(e,d,i,"on the first message",o);if(!o())return 0;const c=function(e,t){const n=/* @__PURE__ */new Set;for(const{fieldName:e,stamps:r}of t){n.add(e);for(const e of[Lt,Nt]){const t=r[e];void 0!==t&&n.add(t)}}const r=/* @__PURE__ */new Map;for(const[t,i]of e)null!==i&&n.has(i.field)&&r.set(t,i);return{fields:n,values:r}}(l,u),h=performance.now()-s;o()&&(t.autoBindGuesses=c,t.autoBindSearchMs=h,u.length)}(r,i,t.fields,e.locale,n,()=>i.isCurrent(e))}if(!i.isCurrent(e))return}const o=at(r.dependencies,r.cache.dependencyMap());if(!i.isCurrent(e))return;const s=i.changes.diff(t.fields,o,()=>i.isCurrent(e));if(null===s)return;const a=!n&&i.navigationReplayPending;a&&(i.navigationReplayPending=!1,i.navigationBindingReplay=!0),e.baseline=s.baseline&&!a,e.navigated=a,e.invalidated=n?ji:s.invalidated,e.touched=n?ji:/* @__PURE__ */new Set([...s.changed,...s.invalidated]),e.renderData=t,this.scheduleAllFields(e,t)}async resolveIncomingFields(e){const{deps:t,state:n}=this,r=e.rawData;if(null===t.merger)return r;const i=n.merges.decide(t,e);if(!i.merge)return i.fields;const{message:o}=e,s=n.merges.request(t.merger,t.mergeWindowMs,{collectionSlug:o.collectionSlug,globalSlug:o.globalSlug,data:r,...void 0===e.schema?{}:{schema:e.schema},locale:e.locale});if(!s.leading)return this.applyMerged(e,s.result).catch(e=>{t.log("update failed:",e)}),i.fields;const a=await s.result;return n.isCurrent(e)?"merged"===a.status?(n.merges.recordMerged(a.doc,e.locale),a.doc):"superseded"===a.status?null:(n.display.shortfall(e,Hi),i.fields):null}async applyMerged(e,t){const{state:n}=this,r=await t;"unavailable"===r.status&&n.display.shortfall(e,Hi),"merged"===r.status&&n.isCurrent(e)&&(n.merges.recordMerged(r.doc,e.locale),this.applyFields(e,this.dataFor(e,r.doc),!0))}scheduleAllFields(e,t,n){const{deps:r,state:i}=this;if(!i.isCurrent(e))return;const o=void 0!==n,s=()=>i.isCurrent(e),a=vr(r,i,e,t.fields);if(!s())return;const{touched:l}=e,d=r.strategies.route;if(o&&void 0!==d&&!e.routeRefreshed&&this.navigationReplay.hasLateRouteBinding(n,a,e,t))return void(s()&&this.strategies.refreshRoute(e,t,d));const u=!o&&this.strategies.hasUnboundChange(e,a),c=i.routeRefreshOwed;if(!o&&void 0!==d&&!e.routeRefreshed&&(u||c||this.strategies.plansRoute(d,e,a))&&s())return i.routeRefreshOwed=!1,void this.strategies.refreshRoute(e,t,d);const h=o?this.navigationReplay.fieldsForElements(n,l):l,f=this.navigationReplay.unrunFragmentPlan(e,this.strategies.planFragments(h,a),n);if(!s())return;const p=r.skipUnchanged;let g=0;for(const[l,d]of r.cache.entries()){if(!s())return;for(const u of d){if(void 0!==n&&!n.has(u.element))continue;if(!1!==a&&!be(u.owner,a))continue;if(!0===f?.covers(u)){if(r.revealEditedField){const n=ue(t.fields,u,l,e.locale);i.revealLedger.note(e,u,n)}continue}const d=u.strategyKind??me(u.element)??"unknown";if("unknown"===d){this.strategies.warnUnsupportedStrategy(u);continue}"fragment"===d&&null===f&&this.strategies.warnFragmentFallback(u);const c=ue(t.fields,u,l,e.locale);if(void 0===c){i.absentFields.add(l);continue}if(mr(r,i,u,t.fields,e.navigated),!o&&r.revealEditedField&&i.revealLedger.note(e,u,c),!s())return;const h=zi(r,u,c,t.fields,s);if(!s())return;const m=p?ce(u,h,t.fields,e.locale):void 0,v=i.lastAppliedIdentity.get(u.element);if(!e.forceRender&&r.skipUnchanged&&void 0!==m&&v===m&&!e.invalidated.has(l)){i.skippedUnchangedCount+=1;continue}const y={target:u,value:h,allFields:t.fields,revision:e.revision,...o?{}:{data:t},valueIdentity:m};r.scheduler.schedule(y),g+=1}}if(o||function(e,t,n,r,i){const{cache:o,strategies:s}=e,a={warned:t,warn:e.warn};if(0===o.fieldCount)return;if(!1!==i&&!function(e,t){for(const n of e.values())if(be(n.owner,t))return!0;return!1}(o,i))return;const l=function(e,t,n,r){const i=Ue(e,t,n,Ne(e,n,r));return e=>"none"!==i(e)}(o,r,i,s);for(const[e,t]of Object.entries(n)){if($e.has(e))continue;if(Ar(t)){Sr(a,l,e,r,t);continue}if(!Rr(t)||l(e)||kr(t))continue;const n=Fe(e,r);for(const[e,i]of Object.entries(t))Ar(i)&&!$e.has(e)&&Sr(a,l,`${n}.${e}`,r,i)}if("declared"!==e.subfieldCoverage)return void function(e,t,n,r,i){if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)return;if(!e.coverageByDefault||t.has(wr)||!isDevMode())return;t.add(wr);const[o]=xe(e.cache,n,r,i,e.strategies);void 0!==o&&e.warn(`[live-preview] LP0204: no binding names "${o.path}", and a binding elsewhere in its group covers it, so an edit there changes nothing on the page. 3.0 makes subfieldCoverage: 'declared' the default, where it refreshes the route. Set the option to choose now.`)}(e,t,n,r,i);const d=xe(o,n,r,i,s);for(const{path:e,value:t}of d)if(Ar(t)&&Sr(a,l,e,r,t),Rr(t)&&!kr(t))for(const[n,i]of Object.entries(t))Ar(i)&&Sr(a,l,`${e}.${n}`,r,i)}(r,i.warnedOrphanFields,e.rawData,e.locale,a),s()){if(null!==f&&f.boundaries.length>0){for(const t of f.boundaries)e.fragmentBoundariesRun.add(t);e.pendingFragments+=f.boundaries.length,this.strategies.runFragments(e,t,f)}!o&&s()&&0===g&&(0===e.pendingFragments&&0===r.scheduler.pendingCount&&(i.complete(e),this.revealPending(e)),this.notifyIslands(e,t))}}notifyIslands(e,t){0!==e.touched.size&&this.navigationReplay.dispatchIslands(e,t,this.deps.cache.islands)}restoreGuesses(e,t){const{deps:n,state:r}=this;if("off"!==n.autoBind&&null!==r.autoBindGuesses&&("undefined"==typeof __LEAN_BUILD__||!__LEAN_BUILD__)){const i=vr(n,r,e,t.fields);!function(e,t,n,r,i,o){if(!o())return 0;const s=t.autoBindGuesses,a=fr(e.root);if(null===s||0===s.fields.size||null===a)return 0;const l=new Map(s.values);for(const[e,t]of or(n,r)){if(null===t||!s.fields.has(t.field))continue;const n=l.get(e);void 0===n?l.set(e,t):n?.field!==t.field&&l.set(e,null)}if(!o())return 0;const d=hr(a,l);o()&&gr(e,d,i,"after a server render",o).length}(n,r,t.fields,e.locale,i,()=>r.isCurrent(e))}}onFlush(e){const{deps:t,state:n}=this;n.lastFlush=e,e.deferred>0&&!n.warnedVisibilityGate&&(n.warnedVisibilityGate=!0,t.warn(`[live-preview] LP0301: visibility gate held ${String(e.deferred)} off-screen update(s) until scrolled into view; see visibilityGateThreshold`));const{revision:r,data:i}=e;if(void 0===r)return;const o=n.activeUpdate;if(null===o||!n.isCurrent(o)||!b(o.revision,r))return;n.display.deferred(o,e.deferred),0===o.pendingFragments&&n.complete(o);const s=()=>n.isCurrent(o)&&b(o.revision,r),a=i??o.renderData;if(this.revealPending(o),!s())return;const l=n.unfaithfulPatches;if(l.length>0){if(n.unfaithfulPatches=[],void 0!==a){const e=vr(t,n,o,a.fields);this.strategies.escalateUnfaithful(o,a,l,e)}if(!s())return}void 0!==i&&(e.applied>0&&t.a11y?.announceUpdate(e.applied),s()&&(this.notifyIslands(o,i),s()&&0!==e.applied&&0!==t.emitter.listenerCount("afterUpdate")&&t.emitter.emitWhile("afterUpdate",{data:i,updatedCount:e.applied,durationMs:e.durationMs,revision:r.revision,receivedAt:o.receivedAt,source:"patch"},s)))}revealPending(e){const t=this.state.revealLedger.commit(e);if(void 0!==t)try{Xe(this.state.revealer,t)}catch(e){this.deps.log("reveal",e)}}revealField(e){const t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":Xe(this.state.revealer,t)}documentSaved(){this.strategies.refreshAfterSave()}},qi=class{apply;debounceMs;maxWaitMs;isVisible;gateThresholdValue;gateDisabled;getCacheSize;onFlush;scheduleFrame;cancelFrame;pending=/* @__PURE__ */new Map;replay=/* @__PURE__ */new Map;activeFlushes=/* @__PURE__ */new Set;debounceTimer=null;debounceToken=0;deadlineTimer=null;frameHandle=null;frameFallback=null;frameToken=0;windowUntil=0;activeRevision=null;activeRevisionCancelled=!1;destroying=!1;constructor(e,t){this.apply=e,this.debounceMs=t.debounceMs??50,this.maxWaitMs=t.maxWaitMs??4*this.debounceMs,this.isVisible=t.isVisible,this.gateThresholdValue=t.visibilityGateThreshold??50,this.gateDisabled=t.disableVisibilityGate??!1,this.getCacheSize=t.getCacheSize,this.onFlush=t.onFlush,this.scheduleFrame=t.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):e=>setTimeout(()=>{e(performance.now())},0)),this.cancelFrame=t.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):e=>{clearTimeout(e)})}schedule(e){if(this.destroying)return;if(void 0!==e.revision){if(this.activeRevisionCancelled)return;if(null===this.activeRevision||!b(e.revision,this.activeRevision))return}const t=this.pending.get(e.target.element);t?(t.value=e.value,t.allFields=e.allFields,t.revision=e.revision,t.data=e.data,t.valueIdentity=e.valueIdentity):this.pending.set(e.target.element,{target:e.target,value:e.value,allFields:e.allFields,revision:e.revision,data:e.data,valueIdentity:e.valueIdentity}),this.armDebounce()}acceptRevision(e){var t,n;this.destroying||null!==this.activeRevision&&b(e,this.activeRevision)||null!==this.activeRevision&&(t=e,n=this.activeRevision,(t.generation!==n.generation?t.generation-n.generation:t.revision-n.revision)<0)||(this.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1,this.cancelScheduledWork())}cancelRevision(e){null!==this.activeRevision&&b(e,this.activeRevision)&&(this.clearWork(),this.activeRevisionCancelled=!0,this.cancelScheduledWork())}flushNow(){return this.cancelScheduledWork(),this.flush()}notifyVisible(e){const t=this.replay.get(e);if(!t)return;if(this.replay.delete(e),!this.isCurrent(t))return;const n=performance.now(),r=this.didApply(t)?1:0;this.onFlush?.(this.statsFor(t,r,0,performance.now()-n,1===r?[t.target.fieldName]:[]))}retarget(e){this.retargetBuffer(this.pending,e),this.retargetBuffer(this.replay,e);for(const t of this.activeFlushes)this.retargetBuffer(t,e)}forget(e){this.pending.delete(e),this.replay.delete(e);for(const t of this.activeFlushes)t.delete(e)}destroy(){if(!this.destroying){this.destroying=!0;try{this.clearWork(),this.activeRevision=null,this.activeRevisionCancelled=!1,this.windowUntil=0,this.cancelScheduledWork()}finally{this.destroying=!1}}}get pendingCount(){return this.pending.size}get replayCount(){return this.replay.size}get gateThreshold(){return this.gateThresholdValue}get gateActive(){return!this.gateDisabled&&this.getCacheSize()>this.gateThresholdValue}armDebounce(){const e=Date.now(),t=e>=this.windowUntil;if(this.windowUntil=e+this.debounceMs,t)return void this.requestFrame();const n=this.debounceToken+=1,r=this.debounceTimer;if(this.debounceTimer=null,null!==r&&clearTimeout(r),this.debounceToken!==n)return;const i=setTimeout(()=>{this.debounceToken===n&&(this.debounceTimer=null,this.pending.size>0&&this.requestFrame())},this.debounceMs);this.debounceToken===n&&(this.debounceTimer=i),null===this.deadlineTimer&&this.maxWaitMs>this.debounceMs&&(this.deadlineTimer=setTimeout(()=>{this.deadlineTimer=null,this.pending.size>0&&this.requestFrame()},this.maxWaitMs))}requestFrame(){const e=this.frameToken+=1,t=this.frameHandle;if(this.frameHandle=null,this.clearFrameFallback(),null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1;const r=()=>{if(this.frameToken!==e||n)return;n=!0;const t=this.frameHandle;this.frameHandle=null,this.clearFrameFallback(),null!==t&&this.cancelFrame(t),this.flush()},i=this.scheduleFrame(r);n||this.frameToken!==e||(this.frameHandle=i,this.frameFallback=setTimeout(r,100))}clearFrameFallback(){clearTimeout(this.frameFallback??void 0),this.frameFallback=null}flush(){const e=performance.now();this.clearDeadline();const t=this.gateActive,n=this.pending;this.pending=/* @__PURE__ */new Map;let r=0;const i=[];let o,s=0;this.activeFlushes.add(n);try{for(const e of n.values()){if(!this.isCurrent(e))continue;const n=!t||this.isVisible(e.target.element)||Vi(e.target);this.isCurrent(e)&&(o??=e,n?(this.replay.delete(e.target.element),this.didApply(e)&&(r+=1,i.push(e.target.fieldName))):(this.replay.set(e.target.element,e),s+=1))}}finally{this.activeFlushes.delete(n)}const a=this.statsFor(o,r,s,performance.now()-e,i);return this.onFlush?.(a),a}isCurrent(e){return void 0===e.revision||!this.activeRevisionCancelled&&null!==this.activeRevision&&b(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||(t=this.apply,!re.has(t));var t}retargetBuffer(e,t){const n=e.get(t.element);void 0!==n&&(Yt(n.target,t)?n.target=t:e.delete(t.element))}clearWork(){this.pending.clear(),this.replay.clear();for(const e of this.activeFlushes)e.clear()}statsFor(e,t,n,r,i){return{applied:t,appliedFields:i,deferred:n,durationMs:r,...void 0!==e?.revision?{revision:e.revision}:{},...void 0!==e?.data?{data:e.data}:{}}}clearDeadline(){null!==this.deadlineTimer&&(clearTimeout(this.deadlineTimer),this.deadlineTimer=null)}cancelScheduledWork(){const e=this.debounceTimer,t=this.frameHandle;this.debounceToken+=1,this.frameToken+=1,this.debounceTimer=null,this.frameHandle=null,this.clearDeadline(),this.clearFrameFallback(),null!==e&&clearTimeout(e),null!==t&&this.cancelFrame(t)}};function Vi(e){if(!0!==e.hidesWhenEmpty)return!1;const{element:t}=e;if(t.hasAttribute("hidden"))return!0;const n=t.getBoundingClientRect();return 0===n.width||0===n.height}var Gi=[0,500,1e3,2e3],Ki=class{deps;state=new nt;pipeline;writer;rootSentinel=null;scope=null;closingSession=!1;observedRoot=null;replayRetainedOnStart=!1;constructor(e){const{emitter:t,renderers:n}=e,r=void 0===e.log?A:S(e.log),i=void 0===e.warn?R:S(e.warn),o=e.root??("undefined"!=typeof document?document:void 0);if(void 0===o)throw new Error("LivePreviewRuntime: no document; pass options.root");const s=new en({filter:e=>!isInsideIsland(e)}),a=new Nn({onStructuralChange:()=>{this.rebuildCache()},onIslandHydrated:e=>{this.pipeline.reapplyNavigationIslands([e],!0)},onVisibilityChange:(e,t)=>{t&&l.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),l=new qi(ie(e=>this.writer.apply(e)),{...void 0!==e.debounceMs?{debounceMs:e.debounceMs}:{},...void 0!==e.disableVisibilityGate?{disableVisibilityGate:e.disableVisibilityGate}:{},...void 0!==e.visibilityGateThreshold?{visibilityGateThreshold:e.visibilityGateThreshold}:{},isVisible:e=>a.isVisible(e),getCacheSize:()=>s.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),d=new w(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onReplay:(e,t,n)=>{this.pipeline.handleReplay(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],r,i),t.emit("documentSave",{timestamp:Date.now()}),this.pipeline.documentSaved()},onFocusField:e=>{this.deps.revealEditedField&&this.pipeline.revealField(e)},onInvalid:(e,n)=>{if("token"===e){const e=new Error(`Preview token rejected (origin: ${n})`);t.emit("error",{error:e,context:"token",code:"LP0502"})}"shape"!==e&&"type"!==e||this.state.warnedProtocolShape||(this.state.warnedProtocolShape=!0,i(`[live-preview] LP0503: ${n} posted a message this runtime does not recognise (${"type"===e?"unknown message type":"unexpected shape"}); it was ignored. A newer Payload or a custom sender: check that the versions match.`)),"source"!==e||this.state.warnedForeignSource||(this.state.warnedForeignSource=!0,i(`[live-preview] LP0501: a message from ${n} was ignored because it did not come from the window that framed or opened this page. \`eventSourcePolicy\` is 'parent-or-opener' by default since 2.0, where 1.x accepted any window on a trusted origin. Set \`eventSourcePolicy: 'any'\` if the admin posts from elsewhere.`)),r("LP0501 message rejected:",e,n)},...void 0!==e.validateToken?{validateToken:e.validateToken}:{},...void 0!==e.eventSourcePolicy?{sourcePolicy:e.eventSourcePolicy}:{}}),u=e.dataMerge;this.deps={emitter:t,cache:s,observers:a,scheduler:l,bus:d,connection:new Xn,heartbeat:new Qn({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:n,resolveRenderer:e.resolveRenderer??(e=>n[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,internalLinkPattern:e.internalLinkPattern,routeAfterSave:!0===e.routeAfterSave,sanitizerPolicy:e.sanitizerPolicy,root:o,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:/* @__PURE__ */(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??N,onHeartbeatTimeout:e.onHeartbeatTimeout,log:r,warn:i,a11y:$(e),serverURL:u?.serverURL,merger:void 0===u?null:new kn({...u,log:r}),mergeWindowMs:e.debounceMs??50,scopeBindingsByOwner:!0===e.scopeBindingsByOwner,subfieldCoverage:e.subfieldCoverage??"descendant",coverageByDefault:void 0===e.subfieldCoverage,lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField,onUnfaithfulPatch:Q(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new rt(this.deps,this.state),this.pipeline=new Wi(this.deps,this.state,()=>{this.rebuildCache()})}start(){const{state:e}=this;if(e.isRunning()||this.closingSession)return!1;e.suspended&&(this.replayRetainedOnStart=!0),e.started=!0,e.suspended=!1,this.openScope();try{return function(e){"react"===e.hydration?On():"vue"===e.hydration&&Hn();const{root:t}=e;if(!Kn(t)||"loading"!==t.readyState)return void Wn(e);const n=()=>{e.isRunning()&&e.later(()=>{Wn(e)})};t.addEventListener("DOMContentLoaded",n,{once:!0}),e.defer(()=>{t.removeEventListener("DOMContentLoaded",n)})}(this.startupHost()),!0}catch(e){throw this.rollbackFailedStart(),e}}startupHost(){const{state:e,deps:t}=this;return{root:t.root,hydration:t.hydration,isRunning:()=>e.isRunning(),defer:t=>{e.deferredStart=t,this.scope?.own(()=>{e.deferredStart===t&&(e.deferredStart=null,t())})},later:t=>{e.deferredStart=null;try{t()}catch(e){this.rollbackFailedStart(),this.reportError(e,"startup","LP0605")}},hydrated:t=>{e.hydration=t},warn:t.warn,startNow:()=>{this.startNow()}}}startNow(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=Kn(t.root)?Jn(t.root):t.root;if(null===n)throw new Error("LivePreviewRuntime: document.body unavailable");if(t.observers.start(n),this.observedRoot=n,this.watchRootReplacement(),this.buildCacheAndObserve(),!e.isRunning())return;if(t.bus.attach(),t.emitter.emitWhile("init",{timestamp:Date.now()},()=>e.isRunning()),!e.isRunning())return;const r=this.replayRetainedOnStart;this.replayRetainedOnStart=!1;const i=r&&t.heartbeat.resume();if(e.isRunning()&&(!r||i||(e.forgetOwedWork(),e.merges.resetRawChanges(),e.unfaithfulPatches=[],e.revealer.reset(),e.lastAppliedIdentity=/* @__PURE__ */new WeakMap,e.changes.reset(),e.navigationReplayPending=!0,t.bus.replayLastAccepted()||(e.navigationReplayPending=!1),e.isRunning())))for(const n of Gi){if(!e.isRunning())return;0===n?t.sendReady(t.readyTargets()):e.readyTimers.push(setTimeout(()=>{e.isRunning()&&this.sendReadyAfterStart()},n))}}suspend(){if(!this.state.isRunning())return!1;const e=this.release();return this.state.suspended=!0,e&&this.deps.emitter.emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0}destroy(){const{state:e,deps:t}=this;if(!e.isRunning()&&!e.suspended)return;const n=!!e.isRunning()&&this.release();e.suspended=!1,this.replayRetainedOnStart=!1,t.bus.forgetLastAccepted(),n&&t.emitter.emit("disconnect",{reason:"destroy",timestamp:Date.now()}),t.a11y?.detach(),t.emitter.emit("destroy",{timestamp:Date.now()})}openScope(){const{state:e,deps:t}=this,n=new xn(t.log);n.own(()=>{t.merger?.destroy(),e.merges.destroy()}),n.own(()=>{t.scheduler.destroy()}),n.own(()=>{t.observers.stop()}),n.own(()=>{this.rootSentinel?.disconnect(),this.rootSentinel=null,this.observedRoot=null}),n.own(()=>{e.abortStrategies()}),n.own(()=>{t.bus.detach()}),n.own(()=>{t.heartbeat.stop()}),n.own(()=>{for(const t of e.readyTimers)clearTimeout(t);e.readyTimers.length=0}),this.scope=n}release(){const{state:e,deps:t}=this;e.display.end(),e.activeUpdate=null,e.navigationBindingReplay=!1,e.started=!1;const n=this.scope;this.scope=null,this.closingSession=!0;try{n?.close()}finally{this.closingSession=!1}return t.cache.clear(),t.connection.markDisconnected()}rollbackFailedStart(){this.release();try{this.deps.a11y?.detach()}catch(e){this.deps.log("runtime cleanup failed:",e)}}refreshCache(){this.state.isRunning()&&(this.state.revealer.reset(),this.followReplacedRoot()||this.rebuildCache())}navigationCommit(){const{state:e,deps:t}=this;e.isRunning()&&null===e.deferredStart&&(this.cancelActiveUpdate(!0),t.merger?.destroy(),e.merges.destroy(),e.abortStrategies(),this.cancelActiveUpdate(!0),e.forgetOwedWork(),e.merges.resetRawChanges(),e.unfaithfulPatches=[],e.revealer.reset(),e.lastAppliedIdentity=/* @__PURE__ */new WeakMap,e.changes.reset(),e.isRunning()&&(t.bus.advanceGeneration(),e.navigationReplayPending=!0,this.followReplacedRoot()||this.rebuildCache(),e.isRunning()&&(t.bus.replayLastAccepted(),e.isRunning()&&this.sendReadyAfterStart())))}watchRootReplacement(){const{root:e}=this.deps;Kn(e)&&"undefined"!=typeof MutationObserver&&(this.rootSentinel?.disconnect(),this.rootSentinel=new MutationObserver(()=>{this.followReplacedRoot()}),this.rootSentinel.observe(e.documentElement,{childList:!0}))}followReplacedRoot(){const{root:e}=this.deps;if(!this.state.isRunning()||!Kn(e))return!1;const t=Jn(e);return null!==t&&t!==this.observedRoot&&(this.observedRoot=t,this.deps.observers.start(t),this.rebuildCache(),!0)}get status(){return this.deps.connection.status}get cache(){return this.deps.cache}get updateCount(){return this.state.updateCount}get protocol(){return this.state.protocol.negotiation}inspect(){return function(t,n){const{cache:r,scheduler:i}=t,o=n.protocol.negotiation,s=n.activeUpdate,a=n.lastFlush,l=[],d=/* @__PURE__ */new Set,u=[];for(const[e,t]of r.entries()){l.push(e);for(const n of t)void 0!==n.owner&&d.add(n.owner),void 0!==n.guessed&&u.push({field:e,matched:n.guessed,attribute:n.targetAttribute??("IMG"===n.element.tagName?"src":void 0)})}return{version:e,started:n.started,status:t.connection.status,origins:{trusted:[...t.readyTargets()],locked:t.lockedOrigin()},protocol:{ours:o.ours,theirs:o.theirs,negotiated:o.negotiated,capabilities:[...o.capabilities].sort(),observed:[...o.observed].sort(),profile:detectProtocolProfile(o.observed).name},revisions:{accepted:n.updateCount,superseded:n.supersededCount,completed:n.completedCount,skippedUnchanged:n.skippedUnchangedCount,active:null===s?void 0:s.revision.revision,display:n.display.snapshot()},bindings:{elements:r.elementCount,fields:r.fieldCount,fieldNames:l.sort(),absentFields:[...n.absentFields].sort(),orphanFields:[...n.warnedOrphanFields].sort(),ownerScoped:t.scopeBindingsByOwner,owners:[...d].sort(),guessed:u.sort((e,t)=>e.field.localeCompare(t.field)),autoBind:{mode:t.autoBind,searchMs:n.autoBindSearchMs}},route:{handler:void 0!==t.strategies.route,...n.routeStats},fidelity:{mode:t.onUnfaithfulPatch,canEscalate:void 0!==t.strategies.fragment||void 0!==t.strategies.route,unfaithful:n.unfaithfulCount,escalated:n.escalatedCount,fields:[...n.unfaithfulFields].sort()},hydration:{mode:t.hydration??"off",state:n.hydration},fragments:{handler:void 0!==t.strategies.fragment,inFlight:s?.pendingFragments??0,...n.fragmentStats},scheduler:{pending:i.pendingCount,deferred:i.replayCount,visibilityGateThreshold:i.gateThreshold,visibilityGateActive:i.gateActive,lastFlush:null===a?void 0:{applied:a.applied,appliedFields:a.appliedFields,deferred:a.deferred,durationMs:a.durationMs}},plugins:[],renderers:Object.keys(t.renderers).sort()}}(this.deps,this.state)}buildCacheAndObserve(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=t.cache.buildFromRoot(t.root);if(t.log("cache",n),e.isRunning()&&(t.emitter.emitWhile("cacheRefresh",n,()=>e.isRunning()),e.isRunning()))for(const n of t.cache.values()){if(!e.isRunning())return;t.observers.observeElement(n.element)}}rebuildCache(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=/* @__PURE__ */new Map,r=t.cache.islandOwners,i=new Set(t.cache.navigationReplayRoots);for(const e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),!e.isRunning())return;const o=new Set(t.cache.navigationReplayRoots.filter(e=>!i.has(e)));for(const e of t.cache.values()){const r=n.get(e.element);void 0!==r&&Yt(r,e)?t.scheduler.retarget(e):(t.scheduler.forget(e.element),o.add(e.element)),n.delete(e.element)}for(const e of n.values())t.scheduler.forget(e.element);o.size>0&&this.pipeline.reapplyNavigationBindings(o);const s=t.cache.islands.filter(e=>!r.has(e)||t.scopeBindingsByOwner&&r.get(e)!==t.cache.islandOwners.get(e));s.length>0&&this.pipeline.reapplyNavigationIslands(s)}onHeartbeatTimeout(){const{state:e,deps:t}=this;if(!e.isRunning())return;if(this.cancelActiveUpdate(!1),t.merger?.destroy(),e.merges.destroy(),e.abortStrategies(),this.cancelActiveUpdate(!1),!e.isRunning())return;t.bus.advanceGeneration(),t.bus.forgetLastAccepted(),e.navigationBindingReplay=!1;const n=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}if(e.isRunning()){if(n&&this.isIdleDisconnected()){if(t.a11y?.announceDisconnected(),t.emitter.emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.isIdleDisconnected()),!e.isRunning())return;if(this.isIdleDisconnected()&&t.log("connection","connected","→","disconnected"),!e.isRunning())return}this.sendReadyAfterStart()}}cancelActiveUpdate(e){const{state:t,deps:n}=this,r=t.activeUpdate;t.display.end(),t.activeUpdate=null,null!==r&&(r.cancelled=!0,n.scheduler.cancelRevision(r.revision),e&&!r.completed&&r.countsAsUpdate&&(t.supersededCount+=1))}sendReadyAfterStart(){try{this.deps.sendReady(this.deps.readyTargets())}catch(e){this.reportError(e,"ready","LP0606")}}reportError(e,t,n){const r=e instanceof Error?e:new Error(String(e));this.deps.emitter.emit("error",{error:r,context:t,code:n})}isIdleDisconnected(){return this.state.isRunning()&&"disconnected"===this.deps.connection.status&&null===this.state.activeUpdate}},EventEmitter=class{#o=/* @__PURE__ */new Map;#s=/* @__PURE__ */new Map;on(e,t){return this.#a(this.#o,e,t)}once(e,t){return this.#a(this.#s,e,t)}off(e,t){this.#l(this.#o,e,t),this.#l(this.#s,e,t)}async emit(e,t){await this.#d(e,t)}async emitWhile(e,t,n){return this.#d(e,t,n)}async#d(e,t,n){const r=()=>n?.()??!0;if(!r())return!1;const i=this.#o.get(e);if(i)for(const n of[...i]){if(!r())return!1;if(await this.#u(n,t,e),!r())return!1}if(!r())return!1;const o=this.#s.get(e);if(o&&o.size>0){const n=[...o];this.#s.delete(e);for(const i of n){if(!r())return!1;if(await this.#u(i,t,e),!r())return!1}}return r()}listenerCount(e){return(this.#o.get(e)?.size??0)+(this.#s.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#o.clear(),void this.#s.clear();this.#o.delete(e),this.#s.delete(e)}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#o.keys())e.add(t);for(const t of this.#s.keys())e.add(t);return[...e]}#a(e,t,n){let r=e.get(t);return r||(r=/* @__PURE__ */new Set,e.set(t,r)),r.add(n),()=>{this.#l(e,t,n)}}#l(e,t,n){const r=e.get(t);void 0!==r&&(r.delete(n),0===r.size&&e.delete(t))}async#u(e,t,n){try{await e(t)}catch(e){const t="string"==typeof n||"number"==typeof n?String(n):"<event>";k(`[live-preview] LP0601: handler for "${t}" threw:`,e)}}},Ji=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,Qi=/^https?:\/\/[^/?#\s]+$/i,Xi=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function Zi(){if("undefined"==typeof location)return;const e=location.ancestorOrigins;return e?.[0]}var OriginDetector=class{#c;constructor(e={}){const t=/* @__PURE__ */new Set;for(const n of e.additionalOrigins??[]){const e=Yi(n);void 0!==e&&t.add(e)}let n;if(e.enableReferrerDetection??1){const t=e.referrer??("undefined"!=typeof document?document.referrer:"");if(t.length>0)try{const e=new URL(t).origin;e&&"null"!==e&&(n=e)}catch{}}const r=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??isDevMode());this.#c=[t,n,r,void 0!==n,void 0,Zi()]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#c[4]?e===this.#c[4]:!!this.#c[0].has(e)||0===this.#c[0].size&&void 0!==this.#c[1]&&e===this.#c[1]||!(!this.#c[2]||!Ji.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#c[4]=e,!0)}unlockOrigin(){const e=this.#c[4];return this.#c[4]=void 0,e}get lockedOrigin(){return this.#c[4]}enumerate(){if(void 0!==this.#c[4])return[this.#c[4]];const e=new Set(this.#c[0]);0===this.#c[0].size&&void 0!==this.#c[1]&&e.add(this.#c[1]);const t=this.#c[5];if(this.#c[2]&&void 0!==t)Ji.test(t)&&e.add(t);else if(this.#c[2])for(const t of Xi)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#c[3]}get isProductionUnconfigured(){return!(!isInIframe()||this.#c[0].size>0||this.#c[2]||void 0!==this.#c[1])}get isReferrerOnlyTrust(){return!(this.#c[0].size>0||this.#c[2]||void 0===this.#c[1])}};function Yi(e){const t=e.trim();if(0!==t.length)try{const e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return;if(!Qi.test(e.origin))return;return e.origin}catch{return}}var eo=()=>{},to=class{#h;#n;#f=/* @__PURE__ */new Set;#c="staging";constructor(e,t){this.#h=e,this.#n=t}assertOpen(){if("closed"===this.#c)throw new Error(`Plugin context for "${this.#h}" is no longer active`)}get active(){return"active"===this.#c}eligible(){return"closed"!==this.#c}own(e){return this.assertOpen(),this.#p({kind:"cleanup",acquire:void 0,finalize:void 0,cleanup:e,disposed:!1})}stage(e,t,n){this.assertOpen();const r={kind:e,acquire:t,finalize:n,cleanup:void 0,disposed:!1},i=this.#p(r);if("active"===this.#c)try{this.#g(r)}catch(e){throw this.#m(r),e}return i}counts(){const e={transform:0,renderer:0,subscription:0,cleanup:0};for(const t of this.#f)e[t.kind]+=1;return e}commit(){if("staging"!==this.#c)throw new Error(`Plugin context for "${this.#h}" cannot be committed`);this.#c="committing";try{for(const e of this.#f)this.#g(e);this.#c="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#c){this.#c="closed";for(const e of[...this.#f].reverse())this.#m(e);this.#f.clear()}}#p(e){return this.#f.add(e),()=>{this.#m(e)}}#g(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;const t=e.acquire();e.cleanup=t??eo}#m(e){if(e.disposed)return;e.disposed=!0,this.#f.delete(e);const t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{y(t())&&this.#n(`plugin "${this.#h}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#n(`plugin "${this.#h}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#n(`plugin "${this.#h}" cleanup failed:`,e)}}},no=class{#v;#y;#b=/* @__PURE__ */new Set;constructor(e,t){this.#v=e,this.#y=t}on(e,t){return this.#w("on",e,t)}once(e,t){return this.#w("once",e,t)}off(e,t){const n=t;for(const t of[...this.#b])t.event===e&&t.handler===n&&t.dispose()}emit(e,t){return this.#y.assertOpen(),this.#v.emit(e,t)}emitWhile(e,t,n){return this.#y.assertOpen(),this.#v.emitWhile(e,t,()=>{if(!this.#y.eligible())return!1;const e=n();return!!this.#y.eligible()&&e})}listenerCount(e){let t=0;for(const n of this.#b)n.event===e&&(t+=1);return t}removeAllListeners(e){for(const t of[...this.#b])void 0!==e&&t.event!==e||t.dispose()}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#b)e.add(t.event);return[...e]}#w(e,t,n){this.#y.assertOpen();const r=n,i=[...this.#b].find(n=>n.kind===e&&n.event===t&&n.handler===r);if(void 0!==i)return i.dispose;let o=eo,s=!0;const a=async t=>{this.#y.active&&s&&("once"===e&&o(),await n(t))},l={kind:e,event:t,handler:r,dispose:eo};return o=this.#y.stage("subscription",()=>this.#v[e](t,a),()=>{s=!1,this.#b.delete(l)}),l.dispose=o,this.#b.add(l),o}},ro=class{#v;#S;#A;#k;#n;#R=/* @__PURE__ */new Map;#T=/* @__PURE__ */new Map;#C=/* @__PURE__ */new Map;#P=/* @__PURE__ */new Set;#L=/* @__PURE__ */new Map;#$=Promise.resolve();#N=0;constructor(e){this.#v=e.events,this.#S=e.config,this.#A=e.registerFieldRenderer,this.#n=S(e.log);const t=e.onTransformError;this.#k=void 0===t?void 0:S((...e)=>{const n=e[0];try{return t(n)}catch(e){return void this.#n("transform error reporter failed:",e)}})}register(e){return this.#N>0?this.#F(e,!1):this.#U(()=>this.#F(e,!0))}unregister(e){return this.#N>0?this.#x(e,!1):this.#U(async()=>{await this.#x(e,!0)})}destroyAll(){return this.#N>0?this.#M(!1):this.#U(async()=>{await this.#M(!0)})}applyTransforms(e,t,n,r){const i=this.#L.get(e);if(void 0===i||0===i.length)return t;let o=t;for(const s of[...i]){if(!s.active)continue;const{transform:i}=s;if(!1===r?.())return t;try{o=i(o,{fieldName:e,element:n.element,allFields:n.allFields});const s=y(o);if(!1===r?.())return t;if(s)throw new TypeError(`Transform for "${e}" returned a Promise/thenable; transforms must be synchronous`)}catch(n){if(!1===r?.())return t;const i=n instanceof Error?n:new Error(String(n));return this.#n(`transform for "${e}" failed:`,i),this.#k?.(i),t}}return o}list(){return[...this.#R.keys()]}snapshot(){const e=[],t=(e,t,n,r)=>{const i=r.counts();return{name:e,version:t,state:n,registrations:{transforms:i.transform,renderers:i.renderer,subscriptions:i.subscription,cleanups:i.cleanup}}};for(const[n,r]of this.#T)e.push(t(n,void 0,"initializing",r.scope));for(const[n,r]of this.#R)e.push(t(n,r.plugin.version,"active",r.scope));for(const t of this.#C.keys())e.push({name:t,version:void 0,state:"tearing-down",registrations:{transforms:0,renderers:0,subscriptions:0,cleanups:0}});return e}get size(){return this.#R.size}async#F(t,n){if(this.#R.has(t.name)||this.#T.has(t.name)||this.#C.has(t.name))return void this.#n(`plugin "${t.name}" already registered`);const r=function(e,t){if(void 0!==e){if(void 0!==e.runtime&&!function(e,t){const n=function(e){const t=/^v?(\d+)\.(\d+)\.(\d+)/.exec(e.trim());if(null!==t)return[Number(t[1]),Number(t[2]),Number(t[3])]}(e);return void 0!==n&&t.split("||").some(e=>{const r=e.trim().split(/\s+/).filter(e=>e.length>0);return 0===r.length?""===e.trim()&&""===t.trim():r.every(e=>function(e,t){const n=t.trim();if(""===n||"*"===n)return!0;const r=/^(\^|~|>=|<=|>|<|=)?\s*v?(\d+)\.(\d+)\.(\d+)/.exec(n);if(null===r)return!1;const i=r[1]??"=",o=[Number(r[2]),Number(r[3]),Number(r[4])],s=function(e,t){for(let n=0;n<3;n+=1){const r=(e[n]??0)-(t[n]??0);if(0!==r)return r}return 0}(e,o);switch(i){case"=":return 0===s;case">":return s>0;case">=":return s>=0;case"<":return s<0;case"<=":return s<=0;case"~":return s>=0&&e[0]===o[0]&&e[1]===o[1];case"^":return!(s<0)&&(o[0]>0?e[0]===o[0]:o[1]>0?0===e[0]&&e[1]===o[1]:0===e[0]&&0===e[1]&&e[2]===o[2]);default:return!1}}(n,e))})}(t,e.runtime))return`declares runtime ${e.runtime}, this runtime is ${t}`;if(void 0!==e.protocol){if(!Number.isInteger(e.protocol)||e.protocol<1)return`declares an invalid protocol version ${String(e.protocol)}`;if(e.protocol<4)return`declares protocol ${String(e.protocol)}, this runtime speaks ${String(4)}`}}}(t.compat,e);if(void 0!==r)return void this.#E(t.name,r);const i=new to(t.name,this.#n),o=this.#O(t.name,i),s={scope:i,cancelled:!1};this.#T.set(t.name,s);try{if(await this.#I(()=>t.init(o),n),s.cancelled)return;i.commit()}catch(e){return i.close(),void(s.cancelled||this.#n(`plugin "${t.name}" init failed:`,e))}finally{this.#T.get(t.name)===s&&this.#T.delete(t.name)}this.#R.set(t.name,{plugin:t,scope:i}),this.#n(`plugin "${t.name}" registered`)}#E(e,t){const n=`plugin "${e}" refused: ${t}`;this.#n(n),this.#v.emit("error",{error:new Error(n),context:"plugin",code:"LP0103"})}#O(e,t){return{events:new no(this.#v,t),registerFieldRenderer:e=>{t.stage("renderer",()=>{const t=this.#A(e);return"function"==typeof t?t:void 0})},registerTransform:(e,n)=>{const r={transform:n,active:!1};t.stage("transform",()=>{r.active=!0;const t=this.#L.get(e);return void 0===t?this.#L.set(e,[r]):t.push(r),()=>{r.active=!1;const t=this.#L.get(e);if(void 0===t)return;const n=t.indexOf(r);n>=0&&t.splice(n,1),0===t.length&&this.#L.delete(e)}})},registerCleanup:e=>{t.own(e)},getConfig:()=>this.#S,log:(...t)=>{this.#n(`[${e}]`,...t)}}}#x(e,t){const n=this.#T.get(e);if(void 0!==n)return n.cancelled=!0,n.scope.close(),Promise.resolve();const r=this.#C.get(e);if(void 0!==r)return this.#P.has(e)?Promise.resolve():t?this.#D(r):r;const i=this.#R.get(e);if(void 0===i)return Promise.resolve();this.#R.delete(e),i.scope.close();const o=Promise.resolve().then(()=>this.#_(e,i.plugin,t));return this.#C.set(e,o),o.then(()=>{this.#C.get(e)===o&&this.#C.delete(e)}),o}async#_(e,t,n){if(void 0!==t.destroy){this.#P.add(e);try{await this.#I(()=>t.destroy?.(),n)}catch(t){this.#n(`plugin "${e}" destroy failed:`,t)}finally{this.#P.delete(e)}}}async#M(e){for(const e of this.#T.values())e.cancelled=!0,e.scope.close();const t=[...this.#R.keys()];for(const n of t)await this.#x(n,e)}async#I(e,t){t?await this.#D(Promise.resolve().then(e)):await e()}async#D(e){this.#N+=1;try{await e}finally{this.#N-=1}}#U(e){const t=this.#$.then(e);return this.#$=t.catch(e=>{this.#n("plugin manager mutation failed:",e)}),t}},io=class{#B;#z;#j=/* @__PURE__ */new Map;constructor(e){this.#B=e,this.#z={...e}}get renderers(){return this.#z}resolve(e){return this.#z[e]}register(e){const t=e.name,n={renderer:e},r=this.#j.get(t);void 0===r?this.#j.set(t,[n]):r.push(n),this.#z[t]=e;let i=!0;return()=>{if(!i)return;i=!1;const e=this.#j.get(t);if(void 0===e)return;const r=e.indexOf(n);if(r<0)return;const o=r===e.length-1;if(e.splice(r,1),0===e.length&&this.#j.delete(t),!o)return;const s=e.at(-1),a=s?.renderer??this.#B[t];void 0===a?Reflect.deleteProperty(this.#z,t):this.#z[t]=a}}},oo={1:"left",2:"center",3:"right",4:"justify"},so=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function ao(e){const t=e.format;return"string"==typeof t&&so.has(t)?t:"number"==typeof t?oo[t]:void 0}function lo(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function uo(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function co(e){const t=ao(e),n=lo(e),r=[];return void 0!==t&&r.push(`lp-align-${t}`),n>0&&r.push(`lp-indent-${String(n)}`),0===r.length?"":` class="${r.join(" ")}"`}var ho=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function fo(e){return"object"==typeof e&&null!==e?e:void 0}function po(e){return fo(e)}function go(e,t){if(void 0===t||""===t||!e.startsWith("/"))return e;try{const n=new URL(t),r=new URL(e,n);return r.origin===n.origin?r.href:e}catch{return e}}function mo(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function vo(e){return"string"==typeof e&&e.length>0?e:void 0}function yo(e){const t=vo(e.title)??vo(e.name)??vo(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}var bo=/\{(slug|id|collection|locale)\}/gu,wo=' target="_blank" rel="noopener noreferrer"',So=(e,t)=>{const n=t.renderChildren(e.children??[]),r=fo(e.fields),i=function(e,t,n){if("internal"===t?.linkType)return function(e,t){const n=fo(e),r=fo(n?.value),i=r?.url;if("string"==typeof i&&i.length>0)return i;const o=void 0===t.internalLinkPattern?void 0:function(e,t){const n=e=>{const n=t[e];return"string"==typeof n&&n.length>0||"number"==typeof n?encodeURIComponent(n):void 0};for(const[,t=""]of e.matchAll(bo))if(void 0===n(t))return;return e.replace(bo,(e,t)=>n(t)??"")}(t.internalLinkPattern,{slug:r?.slug,id:void 0===r?n?.value:r.id,collection:n?.relationTo,locale:t.locale});if(void 0!==o)return o;const s=r?.slug;return"string"==typeof s&&s.length>0?`/${s}`:void 0}(t.doc,n);const r=t?.url??e.url;return"string"==typeof r&&r.length>0?r:void 0}(e,r,t);if(void 0===i||!isSafeUrl(i))return n;const o="string"==typeof e.title?` title="${escapeHtml(e.title)}"`:"";return`<a href="${escapeHtmlAttribute(i)}"${function(e,t,n){if(!0===t?.newTab||isExternalHttpUrl(n))return wo;const r="string"==typeof e.target?e.target:"";return""===r?"":"_blank"===r?wo:` target="${escapeHtml(r)}"`}(e,r,i)}${o}>${n}</a>`};function Ao(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=Ao(n);return t}function ko(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function Ro(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var To=/* @__PURE__ */new Map;function Co(e){return To.get(e)}var Po=".lp-block:empty,.lp-inline-block:empty";function Lo(e,t,n,r){const i=fo(e.fields)??{},o="string"==typeof i.blockType?i.blockType:"",s=mo(o),a=""===s?r:`${r} ${r}--${s}`;if(""!==o){const e=Co(o)??Co(s);if(e)return e(i,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(o,a,i)}return`<${n} class="${a}"></${n}>`}function $o(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var No={text:e=>{let t=escapeHtml("string"==typeof e.text?e.text:"");const n="number"==typeof e.format?e.format:0;return!!(16&n)&&(t=`<code>${t}</code>`),!!(1&n)&&(t=`<strong>${t}</strong>`),!!(2&n)&&(t=`<em>${t}</em>`),!!(8&n)&&(t=`<u>${t}</u>`),!!(4&n)&&(t=`<s>${t}</s>`),!!(32&n)&&(t=`<sub>${t}</sub>`),!!(64&n)&&(t=`<sup>${t}</sup>`),!!(128&n)&&(t=`<mark>${t}</mark>`),t},paragraph:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<p${uo(e)}${co(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",r=ho.has(n)?n:"h2",i=t.renderChildren(e.children??[]);return`<${r}${uo(e)}${co(e)}>${i}</${r}>`},list:(e,t)=>{const n="string"==typeof e.listType?e.listType:"bullet",r="number"===n?"ol":"ul",i="number"===n&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",o="check"===n?' role="list"':"",s=t.renderChildren(e.children??[]);return`<${r}${uo(e)}${co(e)}${i}${o}>${s}</${r}>`},listitem:(e,t)=>{const n=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${co(e)}>${n}</li>`;const r="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${uo(e)}${co(e)}${r}>${n}</li>`},link:So,autolink:So,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${uo(e)}${co(e)}>${n}</blockquote>`},code:e=>{const t=mo("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(Ao(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${mo(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=po(e.value);if(void 0===t)return"";const n=t.url;if("string"!=typeof n||!isSafeUrl(n))return"";const r="string"==typeof t.mimeType?t.mimeType:"";return r.startsWith("video/")?function(e,t){return`<video controls${ko(e)}><source src="${escapeHtmlAttribute(t)}"${Ro(e)}></video>`}(t,n):r.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${Ro(e)}></audio>`}(t,n):""===r||r.startsWith("image/")?function(e,t){const n="string"==typeof e.alt?escapeHtml(e.alt):"";return`<img src="${escapeHtmlAttribute(t)}" alt="${n}"${ko(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){const n="string"==typeof e.filename?escapeHtml(e.filename):escapeHtml(t);return`<a href="${escapeHtmlAttribute(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{const t="string"==typeof e.relationTo?e.relationTo:"",n=fo(e.value),r=escapeHtml((n&&yo(n))??`#${t}`),i=mo(t),o=""===i?' class="lp-relation"':` class="lp-relation lp-relation--${i}"`,s=n?.url;return"string"==typeof s&&isSafeUrl(s)?`<a href="${escapeHtmlAttribute(s)}"${o}>${r}</a>`:`<span${o}>${r}</span>`},block:(e,t)=>Lo(e,t,"div","lp-block"),inlineBlock:(e,t)=>Lo(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${uo(e)}><tbody>${t.renderChildren(e.children??[])}</tbody></table>`,tablerow:(e,t)=>`<tr>${t.renderChildren(e.children??[])}</tr>`,tablecell:(e,t)=>{const n="number"==typeof e.headerState?e.headerState:0,r=3&n?"th":"td";return`<${r}${1===n?' scope="col"':2===n?' scope="row"':""}${$o("colspan",e.colSpan)}${$o("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${r}>`}},Fo=/* @__PURE__ */new Map,Uo=!1;function xo(e){if("object"!=typeof e||null===e)return!1;if(!("root"in e))return!1;const t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function Mo(e,t){const n=(r=e.type,Fo.get(r)??No[r]);var r;return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function Eo(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\n";if(void 0===e.children)return"";let t="";for(const n of e.children)t+=Eo(n);return t}function Oo(e="text"){const t=/* @__PURE__ */new WeakSet;return{name:e,render:/* @__PURE__ */ie((e,n)=>{const r=e.element,i=function(e){return null==e?"":xo(e)?xo(t=e)?t.root.children.map(Eo).join("\n").trim():"":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e);var t}(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName){if(r.textContent.trim()!==i.trim())return function(e){return null!==e.querySelector(":scope > :not(br)")}(r)&&!r.hasAttribute("data-payload-text")?(function(e,t,n){e.has(t)||(e.add(t),R(`[live-preview] LP0402: Skipping text update for "${n}": <${t.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}(t,r,e.fieldName),!1):void(i.includes("\n")||i.includes("\r")?r.innerHTML=Cr(function(e){return escapeHtml(e).replace(/\r\n|\r|\n/g,"<br>")}(i)):r.textContent=i)}else r.value=i})}}var Io=/* @__PURE__ */new Set,Do=/* @__PURE__ */new Set,_o=/* @__PURE__ */new WeakMap,Bo=/* @__PURE__ */new Set(["DIV","SECTION","ARTICLE"]),zo={name:"richText",render:/* @__PURE__ */ie((e,t,n)=>{const r=e.element;if(hi(t))return void(r.textContent="");const i=n.sanitizerPolicy;if(void 0!==n.renderRichText){const o=n.renderRichText(t,{fieldName:e.fieldName,element:r,locale:n.locale});return void(r.innerHTML=Cr(Jr(o,i)))}if(xo(t)){if(ot(t))return void(r.textContent="");const o=/* @__PURE__ */new Map,s=[],a=function(e,t){const n=e.cloneNode(!1);n.innerHTML=Cr(t);const r=function(e,t){const n=e.firstElementChild,r=1===t.children.length?t.firstElementChild:null;if(null!==n?.nextElementSibling||0===t.children.length)return null;if(!Bo.has(n.tagName)||n.hasAttribute(Tt))return null;if(r?.tagName===n.tagName||!0===r?.matches(Po))return null;for(const e of t.children)if(e.tagName===n.tagName&&e.className===n.className)return null;return n}(e,n)??e,i=/* @__PURE__ */new Map,o=n.querySelectorAll(Po);if(o.length>0&&null!==r.firstElementChild){const e=[];jo(r,n,e);for(const[t,n]of e)t.replaceWith(n),n.matches(Po)||i.set(t.className,!1);for(const e of o)null!==e.parentNode&&i.set(e.className,!0)}return r.replaceChildren(...n.childNodes),i}(r,Jr(function(e,t={}){if(!xo(e))return"";const n=function(e){const t={renderChildren:e=>{let n="";for(const r of e)n+=Mo(r,t);return n},resolveAlignment:ao,resolveIndent:lo,onUnrenderedBlock:e.onUnrenderedBlock,internalLinkPattern:e.internalLinkPattern,locale:e.locale};return t}(t).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==t.document?sanitizeHtml(n,{document:t.document}):!0===t.requireDocument||void 0!==Zr()?sanitizeHtml(n):(function(){if(!Uo){Uo=!0;try{console.warn('[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; pass { document } (linkedom, jsdom) per call. 3.0 throws here instead: opt in now with { requireDocument: true }. See "HTML sanitization" in docs/security.md.')}catch{}}}(),n)}(t,{sanitize:!1,internalLinkPattern:n.internalLinkPattern,locale:n.locale,onUnrenderedBlock:(e,t,n)=>{o.set(t,e),s.push(n)}}),i));for(const[t,r]of a){const i=o.get(t);void 0!==i&&Ho(e,n,i,r)}return void function(e,t,n,r){const i=function(e){try{return JSON.stringify(e,(e,t)=>"object"==typeof t&&null!==t&&"id"in t&&"updatedAt"in t?t.id:t)}catch{return}}(n),o=_o.get(e.element);void 0===i?_o.delete(e.element):_o.set(e.element,i),void 0!==i&&void 0!==o&&i!==o&&[...r.values()].includes(!1)&&t.reportUnfaithful?.(e,"changed a block no renderer draws")}(e,n,s,a)}if("string"!=typeof t)return!1;r.innerHTML=Cr(Jr(t,i))})};function jo(e,t,n){const r=(e,t)=>{e.matches(Po)?n.push([e,t]):jo(t,e,n)};let i=e.firstElementChild,o=t.firstElementChild;if(e.children.length===t.children.length){for(;null!==i&&null!==o;i=i.nextElementSibling)r(o,i),o=o.nextElementSibling;return}const s=/* @__PURE__ */new Set;for(const e of t.children)e.matches(Po)||s.add(e.tagName);const a=(e,t)=>e.matches(Po)?!s.has(t.tagName):e.tagName===t.tagName;let l=0;for(;null!==i&&null!==o&&a(o,i);l+=1)r(o,i),i=i.nextElementSibling,o=o.nextElementSibling;const d=Math.min(e.children.length,t.children.length);i=e.lastElementChild,o=t.lastElementChild;for(let e=l;e<d&&null!==i&&null!==o;e+=1){if(!a(o,i))return;r(o,i),i=i.previousElementSibling,o=o.previousElementSibling}}function Ho(e,t,n,r){r&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);const i=r?Do:Io;i.has(n)||(i.add(n),R(`[live-preview] ${r?`LP0413: no renderer for block "${n}", and the markup the server rendered for it is lost.`:`LP0410: no renderer for block "${n}"; keeping what the server rendered for it.`} Register one with registerBlockRenderer().`))}var Wo={name:"html",render(e,t,n){if(hi(t))return void(e.element.textContent="");const r="string"==typeof t?t:ci(t);e.element.innerHTML=Cr(Jr(r,n.sanitizerPolicy))}},qo=/* @__PURE__ */new WeakSet;function Vo(e,t,n,r){if("string"!=typeof n||0===n.length)return{kind:"none"};const i=go(n,r);return isSafeUrl(i)?{kind:"safe",url:i}:(qo.has(e)||(qo.add(e),R(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function Go(e,t=e=>e){return{name:e,render(e,n,r){const i=e.element;if(hi(n))return void function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(i);const o=ci(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName){if("A"===i.tagName){const n=e.hrefField,s=void 0===n||0===n.length?t(o):le(r.allFields,n,r.locale,void 0!==e.locale),a=Vo(i,e.fieldName,s);"safe"===a.kind?i.setAttribute("href",a.url):"unsafe"===a.kind&&i.removeAttribute("href")}i.textContent=o}else i.value=o}}}var Ko=Go("url"),Jo=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,Qo=Go("email",function(e){const t=e.trim();return Jo.test(t)||!t.includes("@")?t:`mailto:${t}`}),Xo=["src","srcset","sizes"],Zo=/* @__PURE__ */new WeakMap;function Yo(e){for(const t of Xo)e.removeAttribute(t);es(e)}function es(e){if("PICTURE"===e.parentElement?.tagName)for(const t of e.parentElement.querySelectorAll("source"))t.remove()}function ts(e,t,n,r){const i=function(e,t){const n=[];for(const[r,i]of Object.entries(e?.sizes??e?.variants??{})){if("string"!=typeof i.url||"number"!=typeof i.width)continue;const e=go(i.url,t);isSafeUrl(e)&&n.push({...i,name:r,url:e,width:i.width})}return n}(n,r),o=e.getAttribute("src"),s=i.find(t=>null!==o&&ns(e,t.url,o))??i.find(t=>t.name===Zo.get(e));void 0===s?.name?Zo.delete(e):Zo.set(e,s.name),(null===o||void 0===s&&!ns(e,t,o))&&es(e),e.src=s?.url??t;const a=s??n,l=i.filter(e=>rs(e,a));if(0===l.length)return e.removeAttribute("srcset"),void e.removeAttribute("sizes");if("number"==typeof n?.width&&"string"==typeof n.url){const e=go(n.url,r),t={...n,url:e,width:n.width};isSafeUrl(e)&&rs(t,a)&&l.push(t)}const d=/* @__PURE__ */new Set,u=[];for(const e of l)d.has(e.width)||(d.add(e.width),u.push(`${is(e.url)} ${String(e.width)}w`));const c=u.join(", ");e.setAttribute("srcset",c)}function ns(e,t,n){try{return new URL(t,e.baseURI).href===new URL(n,e.baseURI).href}catch{return t===n}}function rs(e,t){if(void 0===t)return!0;if("string"==typeof e.mimeType&&"string"==typeof t.mimeType&&e.mimeType!==t.mimeType)return!1;const{width:n,height:r}=t;return"number"!=typeof n||"number"!=typeof r||"number"!=typeof e.width||"number"!=typeof e.height||Math.abs(e.width*r-e.height*n)<=Math.max(n,e.width)}function is(e){return e.replace(/[\s,]/g,encodeURIComponent)}var os=/^\S*[/.:]\S*$/,ss={name:"image",render:/* @__PURE__ */ie((e,t,n)=>{const r=e.element;if("IMG"===r.tagName&&e.altField===e.fieldName&&void 0===e.srcField&&("string"==typeof t||hi(t)))return void(r.alt=t??"");if(hi(t))return void as(r);const i=void 0!==e.locale,{media:o,candidate:s}=function(e,t,n,r){const i=void 0!==e.srcField&&e.srcField.length>0?le(n.allFields,e.srcField,n.locale,r):t,o=po(i);return{media:o,candidate:void 0===o?i:o.url}}(e,t,n,i);if(void 0===o&&"string"==typeof s&&!os.test(s.trim()))return!1;const a=Vo(r,e.fieldName,s,void 0===o?void 0:n.serverURL);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===r.tagName){const t=r;ts(t,a.url,o,n.serverURL);const s=function(e,t,n,r,i){if(void 0!==t&&t.length>0){const e=le(n,t,r,i);return"string"==typeof e?e:void 0}return e?.alt}(o,e.altField,n.allFields,n.locale,i);return void(void 0!==s&&(t.alt=s))}r.style.backgroundImage=`url('${function(e){return e.replace(/['"()\\]/g,"\\$&")}(a.url)}')`}else as(r)})};function as(e){"IMG"===e.tagName?Yo(e):e.style.backgroundImage=""}var ls={name:"upload",render:/* @__PURE__ */ie((e,t,n)=>{const r=e.element;if(hi(t))return void ds(r);const i=po(t);if(void 0===i)return!1;const o=Vo(r,e.fieldName,i.url,n.serverURL);if("none"===o.kind)return!1;if("unsafe"===o.kind)return void ds(r);const s=o.url;if("IMG"===r.tagName){const e=r;return ts(e,s,i,n.serverURL),void(void 0!==i.alt&&(e.alt=i.alt))}if("A"===r.tagName)return r.setAttribute("href",s),void(r.textContent=i.filename??s);const a=escapeHtml(i.filename??s);r.innerHTML=Cr(`<a href="${escapeHtmlAttribute(s)}">${a}</a>`)})};function ds(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):Yo(e)}var us={name:"relationship",render(e,t){const n=e.element;if(hi(t))return n.removeAttribute("href"),void(n.textContent="");if("A"===n.tagName&&!Array.isArray(t)){const r=Vo(n,e.fieldName,fo(t)?.url);"safe"===r.kind?n.setAttribute("href",r.url):"unsafe"===r.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(cs).join(", "):cs(t)}};function cs(e){const t=fo(e);return void 0===t?ci(e):yo(t)??""}var hs={name:"select",render(e,t,n){const r=e.element,i=hi(t)?[]:function(e){return Array.isArray(e)?e.map(ci):[ci(e)]}(t);if("SELECT"!==r.tagName){if("INPUT"===r.tagName&&"radio"===r.type){const e=r;return void(e.checked=i.includes(e.value))}r.textContent=i.map(e=>function(e,t){const n=t.schema?.options;if(!Array.isArray(n))return e;for(const t of n){const n=fo(t);if(void 0!==n&&ci(n.value)===e)return"string"==typeof n.label?n.label:e}return e}(e,n)).join(", ")}else!function(e,t){if(e.multiple)for(const n of Array.from(e.options))n.selected=t.includes(n.value);else e.value=t[0]??""}(r,i)}},fs=/* @__PURE__ */new Set(["","false","0","off","no"]),ps={name:"checkbox",render(e,t){const n=e.element,r=function(e){return"boolean"==typeof e?e:"string"==typeof e?!fs.has(e.trim().toLowerCase()):"number"==typeof e?0!==e:null!=e}(t);"INPUT"!==n.tagName||"checkbox"!==n.type?n.hasAttribute("aria-checked")?n.setAttribute("aria-checked",r?"true":"false"):n.textContent=r?"true":"false":n.checked=r}},gs=/* @__PURE__ */new Map,ms=/* @__PURE__ */new Map;function vs(e,t){const n=e??"";if(null==t)return n;const r=ys(t);return"{}"===r?n:`${n}|${r}`}function ys(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>ys(e)).join(",")}]`;const t=e,n=Object.keys(t).sort(),r=[];for(const e of n){const n=t[e];void 0!==n&&r.push(`${JSON.stringify(e)}:${ys(n)}`)}return`{${r.join(",")}}`}var bs=/* @__PURE__ */new Set(["short","medium","long","full"]),ws=/* @__PURE__ */new Set(["short","medium","long","full"]),Ss=/^[A-Za-z]{3}$/u,As=/^[0-4]$/u;function ks(e){return{kind:"date",options:e}}function Rs(e){return{kind:"number",options:e}}var Ts=/* @__PURE__ */new WeakSet;function Cs(e,t,n,r){if(void 0===t||""===t)return;const i=function(e){const t=e.indexOf(":"),n=-1===t?e:e.slice(0,t),r=-1===t?void 0:e.slice(t+1);switch(n){case"date":return void 0===r?ks({dateStyle:"medium"}):bs.has(r)?ks({dateStyle:r}):void 0;case"time":return void 0===r?ks({timeStyle:"short"}):ws.has(r)?ks({timeStyle:r}):void 0;case"datetime":return void 0===r?ks({dateStyle:"medium",timeStyle:"short"}):bs.has(r)?ks({dateStyle:r,timeStyle:"short"===r?"short":"medium"}):void 0;case"number":if(void 0===r)return Rs({});if(!As.test(r))return;return Rs({minimumFractionDigits:Number(r),maximumFractionDigits:Number(r)});case"currency":if(void 0===r||!Ss.test(r))return;return Rs({style:"currency",currency:r.toUpperCase()});case"percent":return void 0===r?Rs({style:"percent"}):void 0;default:return}}(t);if(void 0!==i){if(i.kind===e)return i.options}else!function(e,t,n){Ts.has(e)||(Ts.add(e),R(`[live-preview] LP0408: data-payload-format="${n}" on "${t}" is not a known format; the default formatting was used. Known: date, time, datetime (each also :short|medium|long|full), number, number:0-4, currency:XXX, percent.`))}(n,r,t)}var Ps={name:"date",render(e,t,n){const r=e.element;if(hi(t))return void("INPUT"===r.tagName?r.value="":(r.removeAttribute("datetime"),r.textContent=""));const i="number"==typeof t?t:ci(t),o=new Date(i),s=!Number.isNaN(o.getTime()),a=String(i);"INPUT"!==r.tagName?("TIME"===r.tagName&&r.setAttribute("datetime",s?o.toISOString():a),r.textContent=s?function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=Cs("date",t.format,t.element,t.fieldName)??Ls;try{return function(e,t){const n=vs(e,t);return fi(ms,n)??pi(ms,n,new Intl.DateTimeFormat(e,t),64)}(r,i).format(e)}catch{return e.toISOString()}}(o,e,n):a):r.value=s?function(e,t){const n=`${String(t.getFullYear()).padStart(4,"0")}-${$s(t.getMonth()+1)}-${$s(t.getDate())}`,r=`${$s(t.getHours())}:${$s(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${r}`:"time"===e?r:t.toISOString()}(r.type,o):a}},Ls={dateStyle:"medium",timeStyle:"short"};function $s(e){return String(e).padStart(2,"0")}var Ns={name:"number",render(e,t,n){const r=e.element;if(hi(t))return void("INPUT"===r.tagName?r.value="":r.textContent="");const i="number"==typeof t?t:Number(ci(t));Number.isNaN(i)?r.textContent=ci(t):"INPUT"!==r.tagName?r.textContent=function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=Cs("number",t.format,t.element,t.fieldName);try{return function(e,t){const n=vs(e,t);return fi(gs,n)??pi(gs,n,new Intl.NumberFormat(e,t),64)}(r,i).format(e)}catch{return String(e)}}(i,e,n):r.value=String(i)}},Fs={name:"array",render:/* @__PURE__ */ie((e,t,n)=>{const r=e.element;if(hi(t))return void(r.textContent="");if(!Array.isArray(t))return!1;const i=e.arrayTemplate;if(void 0!==i&&i.length>0){const e=function(e,t){const n=ai(t);let r="";for(let i=0;i<t.length;i+=1)r+=li(e,t[i],i,ci,n);return r}(i,t),o=n.sanitizerPolicy,s=bi(i),a=di(r);r.innerHTML=Cr(Jr(e,o,s));for(const e of Array.from(r.children))ui(e,a);return}r.textContent=t.map(ci).join(e.arraySeparator??", ")})};function Us(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,n=/* @__PURE__ */new WeakMap,r=/* @__PURE__ */new WeakMap;return{name:"structural-array",render:/* @__PURE__ */ie((i,o,s)=>{const a=hi(o)?[]:o;if(!Array.isArray(a))return!1;const l=i.element,d=i.arrayTemplate;if(void 0===d||0===d.length)return function(e,t,n){e.has(t)||(e.add(t),R(`[live-preview] LP0403: Skipping structural update for "${n}": <${t.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(t,l,i.fieldName),!1;const u=e.get(l),c=xs(l),h=I(u?.values??c.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e}),a),f=function(e,t,n){return void 0===e||e.template!==t||!function(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}(e.domSnapshot,n)}(u,d,c);if(0===h.length&&!f)return e.set(l,{values:a.slice(),template:d,domSnapshot:c}),!1;!function(e,t,n,r,i){const o=i.map(Ms),s=/* @__PURE__ */new Set,a=o.find(e=>!(void 0===e||!s.has(e)&&(s.add(e),1)));if(void 0!==a&&Es(e,t,n,a),o.some(e=>void 0===e)&&Os(e,t,"LP0404",`LP0404: an item of "${n}" has no id and pairs by position, so an insert re-renders every row after it. Give items a stable id.`),r?.length===i.length&&i.length>1){const i=new Set(r.map(Ms).filter(e=>void 0!==e)),s=o.some(e=>void 0!==e&&i.has(e));i.size>0&&!s&&Os(e,t,"LP0406",`LP0406: every key of "${n}" changed at once; the source generates ids per message, so no item can be retained across updates.`)}}(n,l,i.fieldName,u?.values,a);const p=ki({template:d,container:l,patches:h,nextItems:a,store:r,forceRender:f,sanitizerPolicy:s.sanitizerPolicy,onDuplicateKey:(e,t)=>{Es(n,e,i.fieldName,t)}});return null!==p&&(e.set(l,{values:a.slice(),template:d,domSnapshot:xs(l)}),!!p&&void 0)})}}function xs(e){return Array.from(e.children,e=>e.getAttribute(wi))}function Ms(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Es(e,t,n,r){Os(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${r}"; later ones pair by position. Make \`id\` unique per item.`)}function Os(e,t,n,r){let i=e.get(t);void 0===i&&(i=/* @__PURE__ */new Set,e.set(t,i)),i.has(n)||(i.add(n),R(`[live-preview] ${r}`))}var Is=/* @__PURE__ */new Map;function Ds(e,t){return{name:e,render(){L(t)}}}var _s=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),Bs=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"});function zs(e){return void 0===e?void 0:!e}var js,LivePreviewClient=class{#H=new EventEmitter;#W;#q;#V;#R;#n;#G=!1;#K=!1;#J=!1;#Q=null;constructor(e={}){const t=function(e){const t="v1"===e.defaults?Bs:_s;return{...e,skipUnchanged:e.skipUnchanged??t.skipUnchanged,disableReferrerDetection:e.disableReferrerDetection??t.disableReferrerDetection,eventSourcePolicy:e.eventSourcePolicy??t.eventSourcePolicy,sanitizerPolicy:e.sanitizerPolicy??t.sanitizerPolicy}}(e),n=t.serverURL??"";!function(e){if("v1"!==e.defaults&&""!==(e.serverURL??"")&&null==e.mergeDepth)throw new Error("payload-live-preview: `serverURL` needs an explicit `mergeDepth` under the 2.0 defaults — choose the population depth deliberately (0 for none), or pass `defaults: 'v1'` to keep the 1.x default of 1 while migrating (ADR 0007, entry 10).")}({defaults:e.defaults,serverURL:n,mergeDepth:t.mergeDepth});const r=t.debug??isDevMode();this.#n=r?(...e)=>{T("[live-preview]",...e)}:A,this.#W=new OriginDetector(F({additionalOrigins:t.allowedOrigins,enableReferrerDetection:zs(t.disableReferrerDetection),enableLocalhostMatching:zs(t.disableLocalhostMatching)})),this.#W.isProductionUnconfigured&&this.#n("no trusted origin could be detected — set allowedOrigins"),this.#q=new io(function(){const e=[zo,Wo,Ko,Qo,ss,ls,us,hs,{...hs,name:"radio"},ps,Ps,Ns,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[Ds("array","structural arrays"),Ds("blocks","structural arrays")]:[Fs,{...Fs,name:"blocks"}]];return function(e=[]){const t={};for(const n of e)t[n.name]=n;for(const[e,n]of Is)t[e]=n;return Object.freeze(t)}([Oo("text"),Oo("textarea"),...e,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[]:[Us()]])}()),this.#R=new ro({events:this.#H,config:Object.freeze({...t}),registerFieldRenderer:e=>this.#q.register(e),onTransformError:e=>{this.#H.emit("error",{error:e,context:"transform",code:"LP0602"})},log:this.#n}),this.#V=new Ki(F({root:t.root,renderers:this.#q.renderers,resolveRenderer:(e,n)=>t.resolveRenderer?.(e,n)??this.#q.resolve(e),renderRichText:t.renderRichText,internalLinkPattern:t.internalLinkPattern,routeAfterSave:t.routeAfterSave,sanitizerPolicy:t.sanitizerPolicy,transformValue:(e,t,n,r)=>this.#R.applyTransforms(e,t,n,r),originMatcher:e=>this.#W.matches(e),readyTargets:()=>this.#W.enumerate(),emitter:this.#H,dataMerge:""===n?void 0:F({serverURL:n,apiRoute:t.apiRoute,depth:t.mergeDepth,timeoutMs:t.mergeTimeoutMs,fetchFn:t.mergeFetch}),debounceMs:t.debounceMs,heartbeatMs:t.heartbeatMs,intersectionRootMargin:t.intersectionRootMargin,scopeBindingsByOwner:t.scopeBindingsByOwner,skipUnchanged:t.skipUnchanged,revealEditedField:t.revealEditedField,autoBind:t.autoBind,subfieldCoverage:t.subfieldCoverage,eventSourcePolicy:t.eventSourcePolicy,dependencies:t.dependencies,strategies:t.strategies,disableVisibilityGate:t.disableVisibilityGate,visibilityGateThreshold:t.visibilityGateThreshold,enableA11y:t.enableA11y,a11yLocale:t.a11yLocale,onHeartbeatTimeout:()=>{this.#W.unlockOrigin()},lockedOrigin:()=>this.#W.lockedOrigin,validateToken:t.validateToken,log:this.#n})),this.#H.on("connect",e=>{this.#W.lockOrigin(e.origin)}),!1!==t.autoStart&&this.start()}start(){if(this.#K)return!1;if(this.#G)return this.#V.start(),!0;if(!isInPreviewContext())return!1;const e=this.#V.start();return e&&(this.#G=!0),e}suspend(){return!(this.#K||!this.#G)&&this.#V.suspend()}resume(){return!(this.#K||!this.#G)&&this.#V.start()}destroy(){if(null!==this.#Q)return this.#Q;let e,t;this.#K=!0;const n=new Promise((n,r)=>{e=n,t=r});this.#Q=n;const r=()=>{this.#H.removeAllListeners(),this.#J=!0};try{this.#V.destroy(),this.#R.destroyAll().finally(r).then(e,t)}catch(e){r(),t(e)}return n}async use(e){if(this.#K)throw new Error("LivePreviewClient: already destroyed");await this.#R.register(e)}async unuse(e){if(this.#J)throw new Error("LivePreviewClient: already destroyed");await this.#R.unregister(e)}refreshCache(){this.#V.refreshCache()}refreshAfterNavigation(){this.#V.navigationCommit()}get events(){return this.#H}get plugins(){return this.#R.list()}get status(){return this.#V.status}inspect(){return{...this.#V.inspect(),plugins:this.#R.snapshot()}}get updateCount(){return this.#V.updateCount}get destroyed(){return this.#K}};function initLivePreview(e={}){const t=new LivePreviewClient({...e,autoStart:!1});return t.start()?t:null}function setCspCrypto(e){js=e??void 0}function generateCspNonce(e=16){if(!Number.isInteger(e)||e<8)throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(e)}`);const t=function(){if(js?.getRandomValues)return js;const e=globalThis.crypto;return e?.getRandomValues?e:void 0}();if(!t)throw new Error("generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) once at startup, or run with --experimental-global-webcrypto. We won't fabricate a predictable nonce — that would silently defeat the entire CSP.");const n=new Uint8Array(e);return t.getRandomValues(n),function(e){let t="";for(const n of e)t+=String.fromCharCode(n);return("function"==typeof btoa?btoa(t):Buffer.from(e).toString("base64")).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}(n)}function buildFrameAncestors(e={}){const{self:t=!0,origins:n=[],allowNone:r=!1}=e,i=/* @__PURE__ */new Set,o=[];if(r&&!t&&0===n.length)return"'none'";t&&(o.push("'self'"),i.add("'self'"));for(const e of n){const t=e.trim();0===t.length||i.has(t)||(i.add(t),o.push(t))}return o.length>0?o.join(" "):"'none'"}function buildScriptSrcWithNonce(e,t={}){if(0===e.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");const{self:n=!0,extra:r=[],strictDynamic:i=!1}=t,o=[];n&&o.push("'self'"),o.push(`'nonce-${e}'`),i&&o.push("'strict-dynamic'");for(const e of r){const t=e.trim();t.length>0&&o.push(t)}return o.join(" ")}var Hs="payload-live-preview.authorized-preview-context",Ws=Symbol.for(Hs);function isAuthorizedPreviewContext(e){return"object"==typeof e&&null!==e&&!0===e[Ws]&&Object.isFrozen(e)}var qs={basic:{gates:"data updates are applied to bound elements",fallback:"none — every peer has it"},"schema-json":{gates:"field typing from fieldSchemaJSON (Payload 2.x) and the payload-2 profile",fallback:"field types come from DOM heuristics and Lexical auto-detection"},locale:{gates:"locale-aware field resolution (`title_de` before `title`) and the locale on island events",fallback:"bindings resolve the unsuffixed field value"},"preview-token":{gates:"per-message token validation (library extension)",fallback:"messages carry no token; validateToken cannot be satisfied"},"nested-arrays":{gates:"keyed array diffs below the top level",fallback:"array updates replace the whole array"},"recursive-diffs":{gates:"recursive object diffs",fallback:"nested objects re-render as a unit"},"document-events":{gates:"the `documentSave` runtime event, the document-save plugin and the payload-3 profile",fallback:"no documentSave event; a save is not distinguishable from an edit"},"relationship-events":{gates:"the `relationshipUpdate` runtime event and an unconditional re-render of the update that carries it",fallback:"a related document edited in a drawer shows up on the next data update only"}},Vs="__livePreviewRouteRefresh";function registerRouteRefresh(e){const t="undefined"==typeof window?void 0:window;return void 0===t?()=>{}:(t[Vs]=e,()=>{t[Vs]===e&&(t[Vs]=void 0)})}var Gs=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",ProfileFeatureOmitted:"LP0104",OrphanField:"LP0201",UnattributableUpdate:"LP0202",UnboundField:"LP0203",CoverageDefaultChanges:"LP0204",VisibilityGateDeferred:"LP0301",UnsafeAttributeWrite:"LP0401",TextTargetHasChildren:"LP0402",MissingArrayTemplate:"LP0403",StructuralItemUnkeyed:"LP0404",StructuralDuplicateKey:"LP0405",StructuralUnstableKeys:"LP0406",UnsupportedStrategy:"LP0407",UnknownValueFormat:"LP0408",SanitizerDroppedAttribute:"LP0409",UnrenderedBlockKept:"LP0410",UnfaithfulPatch:"LP0411",ServerFormatReplaced:"LP0412",UnrenderedBlockLost:"LP0413",MessageRejected:"LP0501",TokenRejected:"LP0502",ProtocolShapeUnknown:"LP0503",HandlerThrew:"LP0601",TransformThrew:"LP0602",RendererThrew:"LP0603",StartupFailed:"LP0605",ReadyFailed:"LP0606",HydrationWaitTimedOut:"LP0607",AuditRuntimeMissing:"LP0701",AuditNoFrameAncestors:"LP0702",AuditFrameOptionsBlocks:"LP0703",AuditBindingsExposed:"LP0704",AuditGateThresholdExceeded:"LP0705",AuditUnownedBindings:"LP0706",AuditNoBindings:"LP0707",AuditNotAPage:"LP0708",FragmentRequestFailed:"LP0801",FragmentResponseInvalid:"LP0802",FragmentUnauthorized:"LP0803",FragmentSuperseded:"LP0804",RouteRefreshLoop:"LP0805",FragmentStrategyUnavailable:"LP0806",UnboundChangeRefresh:"LP0807",EscalationUnavailable:"LP0808",IslandStartUnavailable:"LP0809",RouteRefreshUnconfirmed:"LP0810",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710",AuditModifierWithoutField:"LP0711"});function bind(e,t){return Ks(e,t)}function bindByPath(e,t){const n=function(e){const t=[],n=new Proxy({},{get(e,r){if("symbol"!=typeof r)return/^\d+$/.test(r)||t.push(r),n}});try{e(n)}catch{}return t}(e);if(0===n.length)throw new Error("bindByPath: the picker did not read any field — return data.<field> instead of a constant");return Ks(n.join("."),t)}function Ks(e,t){if(0===e.length)throw new Error("bind: field name must be a non-empty string");const n={"data-payload-field":e};return void 0!==t?.attribute&&(n["data-payload-attribute"]=t.attribute),void 0!==t?.type&&(n["data-payload-type"]=t.type),!0===t?.richtext&&(n["data-payload-richtext"]=""),!0===t?.html&&(n["data-payload-html"]=""),void 0!==t?.locale&&(n["data-payload-locale"]=t.locale),void 0!==t?.alt&&(n["data-payload-alt"]=t.alt),void 0!==t?.href&&(n["data-payload-href"]=t.href),void 0!==t?.arrayTemplate&&(n["data-payload-array-template"]=t.arrayTemplate),void 0!==t?.format&&(n["data-payload-format"]=t.format),!0===t?.text&&(n["data-payload-text"]=""),void 0!==t?.strategy&&(n["data-payload-strategy"]=t.strategy),void 0!==t?.dependsOn&&t.dependsOn.length>0&&(n["data-payload-depends"]=t.dependsOn.join(",")),!0===t?.anchor&&(n["data-payload-boundary"]=""),n}var Js=/^[a-z][a-z0-9-]{0,63}$/u,Qs=Object.freeze({});function createPreviewBindings(e){const t=isAuthorizedPreviewContext(e.authorization),n=void 0!==e.owner&&e.owner.length>0?e.owner:void 0;return Object.freeze({authorized:t,bind:(e,n)=>t?bind(e,n):Qs,bindByPath:(e,n)=>t?bindByPath(e,n):Qs,owner:()=>t&&void 0!==n?{"data-payload-owner":n}:Qs,boundary:(e,n={})=>{const r=function(e,t){if(!Js.test(e))throw new RangeError(`createPreviewBindings().boundary(): "${e}" is not a registry id — lowercase, starting with a letter, then letters, digits or hyphens (max 64). The runtime would post it and the endpoint would refuse it.`);const n=t.key;if(void 0!==n&&(0===n.length||n.length>128))throw new RangeError(`createPreviewBindings().boundary(): the key for "${e}" must be 1 to ${String(128)} characters.`);const r=t.dependsOn??[];return{"data-payload-fragment":e,...void 0!==n?{"data-payload-fragment-key":n}:{},...r.length>0?{"data-payload-depends":r.join(",")}:{}}}(e,n);return t?r:Qs},covers:(...e)=>{const n=function(e){for(const t of e)if(0===t.length||/[\s,]/u.test(t))throw new RangeError(`createPreviewBindings().covers(): "${t}" is not a field path — a name or a dotted path without spaces or commas.`);return{"data-payload-covers":e.join(" ")}}(e);return t&&e.length>0?n:Qs}})}function Xs(e){const[t,n]=e;return"merge HTTP"===t?`the server answered ${String(n)}`:"merge timeout"===t?`the server did not answer within ${String(n)} ms`:"merge invalid"===t?"the server answered with something other than a document":"merge exception"===t?n instanceof Error?n.message:"the request failed":"the update could not be merged"}var Zs=class{#X;#Z;#W;#Y;#ee=/* @__PURE__ */new Set;#te;#ne;#re=0;#ie=[];#oe=!1;#se;#ae;#le;#de=!1;#ue=!1;constructor(e,t){this.#W=new OriginDetector({...void 0!==t.allowedOrigins?{additionalOrigins:t.allowedOrigins}:{},enableReferrerDetection:t.enableReferrerDetection??!1,...void 0!==t.enableLocalhostMatching?{enableLocalhostMatching:t.enableLocalhostMatching}:{}}),this.#X=new kn({serverURL:t.serverURL,...void 0!==t.apiRoute?{apiRoute:t.apiRoute}:{},...void 0!==t.depth?{depth:t.depth}:{},...void 0!==t.timeoutMs?{timeoutMs:t.timeoutMs}:{},...void 0!==t.fetchFn?{fetchFn:t.fetchFn}:{},log:(...e)=>{this.#ie=e}}),this.#Z=new w(e=>this.#W.matches(e),{onUpdate:e=>{this.#ce(e)},onDocumentEvent:()=>{},sourcePolicy:t.eventSourcePolicy??"parent-or-opener"}),this.#Y=t.target,this.#le=t.document,this.#te={data:e,isLoading:!0,status:"idle",error:void 0,revision:0},this.#ne=this.#te}subscribe=e=>(this.#ee.add(e),this.#oe||this.#he(),()=>{this.#ee.delete(e),0===this.#ee.size&&this.#fe()});getSnapshot=()=>this.#ne;getServerSnapshot=()=>this.#te;#he(){"undefined"==typeof window&&void 0===this.#Y||(this.#oe=!0,this.#Z.attach(this.#Y??window),w.sendReady(this.#pe(),this.#W.enumerate()))}#fe(){this.#oe&&(this.#oe=!1,this.#re+=1,this.#Z.detach(),this.#X.destroy())}#pe(){const e=this.#Y??("undefined"==typeof window?void 0:window);if(void 0===e)return[];const t=[];e.parent!==e&&t.push(e.parent);const n=e.opener;return null!=n&&n!==e&&t.push(n),t}#ge(e){return this.#oe&&e===this.#re}#me(e,t){const n=this.#le;if(void 0===n)return!0;const{locale:r,globalSlug:i,collectionSlug:o}=e;if(void 0!==n.locale&&void 0!==r&&r!==n.locale)return!1;if("global"in n){if(void 0!==i)return i===n.global;if(void 0!==o)return!1}else{if(void 0!==i)return!1;if(void 0!==o&&o!==n.collection)return!1;const e=void 0===o?void 0:we(t);if(void 0!==e)return e===String(n.id)}return this.#ve(n),!1}#ve(e){if(this.#de||!isDevMode())return;this.#de=!0;const t="global"in e?`global "${e.global}"`:`collection "${e.collection}", id "${String(e.id)}"`;console.warn(`[payload-live-preview] This hook previews ${t} and ignored an update that does not say which document it is for: Payload 2 sends no collection or global slug, and a create screen has no id yet.`)}async#ce(e){const t=e.data;if(void 0===t)return;if(void 0!==e.fieldSchemaJSON&&!this.#ue&&isDevMode()&&(this.#ue=!0,console.warn(v)),!this.#me(e,t))return;const n=this.#re+=1;void 0!==e.fieldSchemaJSON&&(this.#se=e.fieldSchemaJSON);const r=this.#se;void 0!==e.locale&&(this.#ae=e.locale);const i=void 0===r?e.locale:this.#ae;if(this.#ye({...this.#ne,isLoading:!0}),!this.#ge(n))return;this.#ie=[];const o=await this.#X.merge({data:t,...void 0===r?{}:{schema:r},...void 0!==e.collectionSlug?{collectionSlug:e.collectionSlug}:{},...void 0!==e.globalSlug?{globalSlug:e.globalSlug}:{},...void 0!==i?{locale:i}:{}});this.#ge(n)&&"superseded"!==o.status&&("unavailable"!==o.status?this.#ye({data:o.doc,isLoading:!1,status:"live",error:void 0,revision:n}):this.#ye({...this.#ne,isLoading:!1,status:"unavailable",error:new Error(`live preview: ${Xs(this.#ie)}`)}))}#ye(e){const t=this.#ne;if(t.data!==e.data||t.isLoading!==e.isLoading||t.status!==e.status||t.error!==e.error||t.revision!==e.revision){this.#ne=e;for(const e of[...this.#ee])e()}}};function createDocumentSession(e,t){return new Zs(e,t)}var Ys=!0;export{Hs as AUTHORIZED_PREVIEW_BRAND_KEY,g as CAPABILITY_DECLARATIONS,qs as CAPABILITY_DOCUMENTATION,Ys as CORE_ENTRY,Gs as DIAGNOSTIC_CODES,EventEmitter,dt as ISLAND_EVENT,p as LIBRARY_PROTOCOL_VERSION,LivePreviewClient,OriginDetector,m as PROTOCOL_CAPABILITIES,e as VERSION,bind,bindByPath,buildFrameAncestors,buildScriptSrcWithNonce,createDocumentSession,createPreviewBindings,detectInitialLocale,detectProtocolProfile,escapeHtml,escapeHtmlAttribute,generateCspNonce,hasCapability,initLivePreview,isAuthorizedPreviewContext,isDevMode,isExternalHttpUrl,isInIframe,isInPopup,isInPreviewContext,isInsideIsland,isSafeUrl,negotiateProtocol,registerRouteRefresh,sanitizeHtml,setCspCrypto,setSanitizerDocument};
|
|
1
|
+
var e="2.3.1";function detectInitialLocale(){return function(){if("undefined"==typeof document)return;const e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}()??function(){if("undefined"==typeof navigator)return;const e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}()??"en"}var t="payload-live-preview-a11y",n=/* @__PURE__ */new WeakMap;function r(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}var i=class{german;document;lease=null;constructor(e,t){const n=t??("undefined"==typeof document?null:document),r=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(r.length>0?r:detectInitialLocale())),this.document=n}mount(){const e=this.document;if(null==e?.body)return null;this.lease??=function(e){let t=n.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},n.set(e,t)),t.refs+=1,t}(e);const i=this.lease,o=i.element;if(o?.isConnected&&o.ownerDocument===e)return o;if(null!==o){const e=i.owned;r(i),e&&o.remove()}let s=e.getElementById(t);return i.owned=null===s,null===s&&(s=e.createElement("div"),s.id=t,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),s.style.cssText="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0",e.body.appendChild(s)),i.element=s,s}announceConnected(){this.say(this.german?"Vorschau verbunden":"Live preview connected")}announceDisconnected(){this.say(this.german?"Vorschau getrennt":"Live preview disconnected")}announceUpdate(e){e<=0||this.say(this.german?`${String(e)} ${1===e?"Änderung":"Änderungen"} angewendet`:`${String(e)} ${1===e?"change":"changes"} applied`)}announcePartial(){this.say(this.german?"Vorschau teilweise aktualisiert":"Preview partly updated")}detach(){const e=this.lease,t=this.document;if(null===e||null===t)return;if(this.lease=null,e.refs-=1,e.refs>0)return;const i=e.element;null!==i&&r(e),e.owned&&i?.remove(),e.element=null,n.delete(t)}say(e){const t=this.mount(),n=this.lease;if(null===t||null===n)return;let i=n.messageNode;i?.parentNode!==t?(i?.remove(),i=t.ownerDocument.createTextNode(t.hasChildNodes()?` ${e}`:e),n.messageNode=i,t.appendChild(i)):i.data=null===i.previousSibling?e:` ${e}`,null!==n.timer&&clearTimeout(n.timer);const o=setTimeout(()=>{n.timer===o&&n.element===t&&r(n)},1500);n.timer=o}};function o(e){if(++e.nodes>1e4)throw new Error("invalid or oversized field schema")}function s(e,t,n){if(o(t),n>64||t.active.has(e))throw new Error("invalid or oversized field schema");t.active.add(e)}function a(e){try{return l(e,{nodes:0,active:/* @__PURE__ */new WeakSet},0)}catch{return[]}}function l(e,t,n){if(!Array.isArray(e))return[];s(e,t,n);const r=[];for(const i of e){const e=d(i,t,n);e&&r.push(e)}return t.active.delete(e),r}function d(e,t,n){if(o(t),"object"!=typeof e||null===e)return;const r=e,i=r.name,a=r.type;if("string"!=typeof i||0===i.length)return;if("string"!=typeof a||0===a.length)return;const d=l(r.fields,t,n+1),u=function(e,t,n){if("object"==typeof e&&null!==e&&!Array.isArray(e)){s(e,t,n);const r=[];for(const i in e){if(!Object.hasOwn(e,i))continue;o(t);const s=Reflect.get(e,i);"object"!=typeof s||null===s||["__proto__","constructor","prototype"].includes(i)||r.push({...s,slug:i,fields:l(s.fields,t,n+1)})}return t.active.delete(e),r}if(!Array.isArray(e))return[];s(e,t,n);const r=[];for(const i of e){if(o(t),"object"!=typeof i||null===i)continue;const e=i,s=e.slug;if("string"!=typeof s||0===s.length)continue;const a=l(e.fields,t,n+1);r.push({...e,slug:s,fields:a})}return t.active.delete(e),r}(r.blocks,t,n+1),c={...r,name:i,type:a},h=r.relationTo;if(Array.isArray(h)){const e=[];for(const n of h)o(t),e.push(n);c.relationTo=e}return d.length>0?c.fields=d:delete c.fields,u.length>0?c.blocks=u:delete c.blocks,c}function u(e,t){return void 0===e||t(e)}function c(e,t){return null==e||t(e)}function h(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}var f=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],p=4,g={basic:{since:1},"schema-json":{since:2,observed:"schema"},locale:{since:2,observed:"locale"},"preview-token":{since:3,observed:"preview-token"},"nested-arrays":{since:4},"recursive-diffs":{since:4},"document-events":{since:4,observed:"document-event"},"relationship-events":{since:4,observed:"relationship-event"}},m=Object.keys(g);function negotiateProtocol(e,t=[]){const n="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,r=n??1,i=Math.min(4,r),o=new Set(t),s=/* @__PURE__ */new Set;for(const e of m)(i>=g[e].since||o.has(e))&&s.add(e);return{ours:4,...void 0!==n?{theirs:n}:{theirs:void 0},negotiated:i,capabilities:s,observed:o}}function hasCapability(e,t){return e.capabilities.has(t)}var v="[payload-live-preview] This admin sends fieldSchemaJSON, which only Payload 2 does. Every 2.x release of this package supports Payload 2; 3.0 supports Payload 3 and 4.";function y(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function b(e,t){return e.generation===t.generation&&e.revision===t.revision}var w=class{matcher;handlers;boundListener=void 0;attachedTarget=void 0;generation=0;revision=0;queueHead=void 0;queueTail=void 0;lastAccepted=void 0;replayedGeneration=0;latestAcceptedAttempt=void 0;constructor(e,t){this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1;const n=r=>{if(!t||this.boundListener!==n)return;const i=this.generation;try{this.receive(r,i,e)}catch{let e;try{e=r.origin}catch{e=""}this.reportInvalid("shape",e,i)}};this.generation+=1,this.resetQueue(),this.attachedTarget=e,this.boundListener=n;try{e.addEventListener("message",n)}catch(t){this.boundListener===n&&(this.attachedTarget=void 0,this.boundListener=void 0,this.resetQueue());try{e.removeEventListener("message",n)}catch{}throw t}if(this.boundListener===n)t=!0;else try{e.removeEventListener("message",n)}catch{}}detach(){const e=this.attachedTarget,t=this.boundListener;void 0!==e&&void 0!==t&&(this.attachedTarget=void 0,this.boundListener=void 0,this.resetQueue(),e.removeEventListener("message",t))}advanceGeneration(){return void 0!==this.attachedTarget&&(this.generation+=1,this.resetQueue(),!0)}replayLastAccepted(){const e=this.lastAccepted,t=this.generation,n=this.handlers.onReplay;if(void 0===n||void 0===e||e.generation>=t||this.replayedGeneration===t)return!1;if(!this.matchesOrigin(e.origin,t)||this.lastAccepted!==e)return!1;this.replayedGeneration=t;const r={generation:t,revision:this.revision+=1};return this.invokeHandler(t,n,structuredClone(e.message),e.origin,r),!0}forgetLastAccepted(){this.lastAccepted=void 0,this.replayedGeneration=0,this.latestAcceptedAttempt=void 0}static sendReady(e,t){const n={type:"payload-live-preview",ready:!0,protocolVersion:4};for(const r of e)for(const e of t)try{r.postMessage(n,e)}catch{}}receive(e,t,n){const r=e.origin;if(!this.matchesOrigin(r,t))return void this.reportInvalid("origin",r,t);if(!this.matchesSource(e,n))return void this.reportInvalid("source",r,t);const i=e.data;var o;if("object"==typeof(o=i)&&null!==o&&"type"in o&&"string"==typeof o.type)switch(i.type){case"payload-live-preview":return function(e){const t=e;return!(void 0!==t.data&&null!==t.data&&!h(t.data))&&c(t.fieldSchemaJSON,e=>Array.isArray(e))&&c(t.globalSlug,e=>"string"==typeof e)&&c(t.collectionSlug,e=>"string"==typeof e)&&c(t.locale,e=>"string"==typeof e)&&c(t.ready,e=>"boolean"==typeof e)&&c(t.previewToken,e=>"string"==typeof e)&&c(t.protocolVersion,e=>"number"==typeof e)}(i)?void this.dispatchUpdate(function(e){const t={...e};for(const e of f)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);return Array.isArray(t.fieldSchemaJSON)?{...t,fieldSchemaJSON:a(t.fieldSchemaJSON)}:t}(i),r,t):void this.reportInvalid("shape",r,t);case"payload-document-event":return function(e){const t=e;return u(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&u(t.slug,e=>"string"==typeof e)&&u(t.id,e=>"string"==typeof e||Number.isFinite(e))}(i)?void this.invokeHandler(t,this.handlers.onDocumentEvent,i,r):void this.reportInvalid("shape",r,t);case"payload-live-preview-focus":{const e=function(e){const t=e.field;return"string"==typeof t&&t.length>0?t:void 0}(i);return void 0===e?void this.reportInvalid("shape",r,t):void this.invokeHandler(t,this.handlers.onFocusField,e,r)}default:this.reportInvalid("type",r,t)}else this.reportInvalid("shape",r,t)}dispatchUpdate(e,t,n){const r=h(e.data);if(!this.isCurrentGeneration(n))return;const i=r?{generation:n,revision:this.revision+=1}:void 0,o=this.handlers.validateToken;if(!this.isCurrentGeneration(n))return;if(void 0===o)return void this.commitUpdate(e,t,n,i);if(!0===e.ready&&void 0===e.data)return void this.commitUpdate(e,t,n,void 0);const s={generation:n,message:e,origin:t,messageRevision:i,verdict:void 0,next:void 0};let a;this.enqueue(s);try{a=o(e.previewToken,t)}catch{return void this.settleValidation(s,!1)}"boolean"!=typeof a?Promise.resolve(a).then(e=>{this.settleValidation(s,!0===e)},()=>{this.settleValidation(s,!1)}):this.settleValidation(s,a)}settleValidation(e,t){e.verdict=t,this.drainQueue(e.generation)}drainQueue(e){for(;this.isCurrentGeneration(e);){const t=this.queueHead;if(void 0===t)return;if(this.matchesOrigin(t.origin,e)){if(void 0===t.verdict)return;this.dequeue(t)&&(t.verdict?this.commitUpdate(t.message,t.origin,t.generation,t.messageRevision):this.reportInvalid("token",t.origin,t.generation))}else{if(!this.dequeue(t))continue;this.reportInvalid("origin",t.origin,t.generation)}}}commitUpdate(e,t,n,r){if(void 0===r)this.invokeHandler(n,this.handlers.onUpdate,e,t);else{const i={};this.latestAcceptedAttempt=i;const o=function(e){const t={...e};delete t.previewToken;try{return structuredClone(t)}catch{return null}}(e);if(this.latestAcceptedAttempt!==i||!this.isCurrentGeneration(n))return;this.lastAccepted=null===o?void 0:{generation:n,message:o,origin:t},this.invokeHandler(n,this.handlers.onUpdate,e,t,r)}}reportInvalid(e,t,n){this.invokeHandler(n,this.handlers.onInvalid,e,t)}matchesSource(e,t){if("parent-or-opener"!==this.handlers.sourcePolicy)return!0;try{const n=e.source;if("object"!=typeof n||null===n)return!1;const r=t.parent;return r!==t&&n===r||n===t.opener}catch{return!1}}matchesOrigin(e,t){try{return!0===(this.isCurrentGeneration(t)&&this.matcher(e))&&this.isCurrentGeneration(t)}catch{return!1}}invokeHandler(e,t,...n){if(void 0!==t&&this.isCurrentGeneration(e))try{y(t(...n))}catch{}}isCurrentGeneration(e){return void 0!==this.attachedTarget&&this.generation===e}enqueue(e){void 0===this.queueTail?this.queueHead=e:this.queueTail.next=e,this.queueTail=e}dequeue(e){return this.queueHead===e&&(this.queueHead=e.next,void 0===this.queueHead&&(this.queueTail=void 0),!0)}resetQueue(){this.queueHead=void 0,this.queueTail=void 0}};function S(e){return(...t)=>{try{y(e(...t))}catch{}}}function A(){}var k=S((...e)=>console.error(...e)),R=S((...e)=>console.warn(...e)),T=S((...e)=>console.debug(...e)),C={"structural arrays":'data-payload-type="array" and keyed lists',"array templates":"data-payload-array-template","server-rendered fragments":"data-payload-fragment boundaries","route refreshes":'data-payload-strategy="route" and bindings in <head>',"screen-reader announcements":"the aria-live region","auto-binding":"autoBind: 'unique'"},P=/* @__PURE__ */new Set;function L(e){P.has(e)||(P.add(e),R(`[live-preview] LP0104: this page carries the lean runtime, which leaves out ${e} (${C[e]}). The elements are left as the server rendered them. Remove \`runtime: LEAN_RUNTIME\` to get the full runtime.`))}function $(e){return"undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e){return!1!==e.enableA11y&&L("screen-reader announcements"),null}(e):function(e){if(!1===e.enableA11y)return null;const t=e.root,n=void 0===t?void 0:function(e){return 9===e.nodeType}(t)?t:t.ownerDocument;return new i(e.a11yLocale,n)}(e)}function N(e){if("undefined"==typeof window)return;const t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),w.sendReady(t,e)}function F(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}var U=/* @__PURE__ */new Set(["tabs","row","collapsible"]);function x(e,t,n,r){for(const i of e){if(U.has(i.type)){const e=i.fields;e&&x(e,r&&"tabs"===i.type?""===t?i.name:`${t}.${i.name}`:t,n,r);continue}const e=""===t?i.name:`${t}.${i.name}`;if(n.set(e,i),"group"===i.type)i.fields&&x(i.fields,e,n,r);else if("array"===i.type&&i.fields)x(i.fields,`${e}.*`,n,r);else if("blocks"===i.type&&i.blocks)for(const t of i.blocks)x(t.fields,`${e}.*.${t.slug}`,n,r)}}function M(e,t){if(e.has(t))return e.get(t);const n=t.replace(/\.\d+(?=\.|$)/g,".*");return e.has(n)?e.get(n):void 0}function E(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function O(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function I(e,t){return t.every(e=>void 0!==E(e))?function(e,t){const n=[],r=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=E(e[t]);void 0!==n&&r.set(n,t)}const i=/* @__PURE__ */new Set;for(let o=0;o<t.length;o+=1){const s=t[o],a=E(s);if(void 0===a){n.push({kind:"insert",index:o,value:s});continue}const l=r.get(a);if(void 0===l){n.push({kind:"insert",index:o,value:s});continue}i.add(l);const d=e[l];O(d)===O(s)?(l!==o&&n.push({kind:"move",from:l,to:o,value:s}),D(d,s)||n.push({kind:"update",index:o,value:s})):n.push({kind:"replace",index:o,oldValue:d,value:s})}for(let t=0;t<e.length;t+=1)i.has(t)||n.push({kind:"remove",index:t,value:e[t]});return n}(e,t):function(e,t){const n=[],r=Math.min(e.length,t.length);for(let i=0;i<r;i+=1)D(e[i],t[i])||n.push({kind:"update",index:i,value:t[i]});if(t.length>e.length)for(let r=e.length;r<t.length;r+=1)n.push({kind:"insert",index:r,value:t[r]});if(e.length>t.length)for(let r=t.length;r<e.length;r+=1)n.push({kind:"remove",index:r,value:e[r]});return n}(e,t)}function D(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;const n=e,r=t,i=Object.keys(n),o=Object.keys(r);if(i.length!==o.length)return!1;for(const e of i)if(!Object.is(n[e],r[e]))return!1;return!0}var _={text:"text",textarea:"textarea",richText:"richText",email:"email",number:"number",checkbox:"checkbox",date:"date",select:"select",radio:"radio",array:"array",blocks:"blocks",group:"text",tabs:"text",row:"text",collapsible:"text",relationship:"relationship",upload:"upload",point:"text",json:"text",code:"text",ui:"text"},B=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),z=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,j=/^[\\/]{2}/,H=/[\t\n\r]/g,W=/[\s\u0000-\u001f\u180e\u2000-\u2029]/g,q=/^([a-z][a-z0-9+.-]*):/i;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(H,"");if(0===t.length)return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(j.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return B.has(e.protocol)}catch{return z.test(t)&&!function(e){const t=q.exec(e.replace(W,""))?.[1];return void 0!==t&&!B.has(`${t.toLowerCase()}:`)}(t)}}function isExternalHttpUrl(e){const t=e.trim().replace(H,"");return/^https?:\/\//i.test(t)||j.test(t)}var V=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),G=/* @__PURE__ */new Set(["href","src","poster","cite","action","xlink:href","data"]);function K(e){return!e.startsWith("on")&&!V.has(e)}function J(e){switch(typeof e){case"string":return e.length>65536?void 0:`s:${e}`;case"number":return`n:${Object.is(e,-0)?"-0":String(e)}`;case"boolean":return"b:"+(e?"1":"0");case"bigint":return`i:${String(e)}`;case"undefined":return"u";case"object":{if(null===e)return"z";let t;try{t=JSON.stringify(e)}catch{return}return t.length>65536?void 0:`o:${t}`}case"symbol":case"function":return}}function Q(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function X(e,t,n,r,i){const o=e.onUnfaithfulPatch,s=t.reportedUnfaithful.get(n.element),a=J(i),l=Date.now(),d=void 0!==s&&("escalate"!==o||void 0===a||a===s.identity||l-s.at<1e3);if((d||"escalate"!==o)&&t.display.shortfall(t.activeUpdate,{kind:"unfaithful",field:n.fieldName}),!d){if(t.reportedUnfaithful.set(n.element,{identity:a,at:l}),void 0===s){if(t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName),"ignore"===o)return;if("warn"===o)return void e.warn(`[live-preview] LP0411: "${n.fieldName}" ${r}`)}e.log("LP0411",n.fieldName,r),t.unfaithfulPatches.push(n)}}function Z(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}var Y=/* @__PURE__ */new Set(["date","number","checkbox","select","radio"]);function ee(e){return"select"===e||"radio"===e}function te(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function ne(e){const t=e.trim();return JSON.stringify(t.length>40?`${t.slice(0,40)}…`:t)}var re=/* @__PURE__ */new WeakSet;function ie(e){return re.add(e),e}var oe=class{previous=null;lastFields;priorFields;keepValues=!1;get previousFields(){return this.priorFields}get isBaseline(){return null===this.previous}diff(e,t,n=se){const r=this.previous,i=null===r,o=/* @__PURE__ */new Map,s=/* @__PURE__ */new Set,a=Object.entries(e);if(!n())return null;for(const[e,t]of a){const i=J(t);if(!n())return null;o.set(e,i),null!==r&&void 0!==i&&r.get(e)===i||s.add(e)}if(null!==r)for(const e of r.keys())o.has(e)||s.add(e);const l=/* @__PURE__ */new Set,d=Object.entries(t);if(!n())return null;for(const[e,t]of d)if(s.has(e))for(const e of t)if(l.add(e),!n())return null;return n()?(this.previous=o,this.priorFields=this.keepValues?this.lastFields:void 0,this.lastFields=this.keepValues?e:void 0,{changed:s,invalidated:l,baseline:i}):null}reset(){this.previous=null,this.lastFields=void 0,this.priorFields=void 0}};function se(){return!0}var ae=/* @__PURE__ */new Set(["__proto__","prototype","constructor"]);function le(e,t,n,r=!1){if(r&&void 0!==n){const r=de(e,`${t}_${n}`);if(void 0!==r)return r}const i=de(e,t);if(void 0!==i)return i;if(t.includes(".")){let n=e,r=!0;for(const e of t.split(".")){if(ae.has(e)||null===n||"object"!=typeof n){r=!1;break}if(n=de(n,e),void 0===n){r=!1;break}}if(r)return n}return void 0===n?void 0:de(e,`${t}_${n}`)}function de(e,t){if(!ae.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function ue(e,t,n,r){return le(e,n,t.locale??r,void 0!==t.locale)}function ce(e,t,n,r){const i=J(t);if(void 0===i)return;const o=[e.hrefField,e.srcField,e.altField];let s=JSON.stringify([e.format,e.locale??r])+i;for(const t of o){if(void 0===t||0===t.length)continue;const i=J(ue(n,e,t,r));if(void 0===i)return;s+=`|${t}=${i}`}return s}var he="data-payload-fragment",fe="data-payload-fragment-key";function pe(e){return e.closest(`[${he}]`)}function ge(e,t,n){const r=new Set(t);return{boundaries:t,strategy:e,ownerKeys:n,covers:e=>void 0!==e.fragmentBoundary&&r.has(e.fragmentBoundary)}}function me(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==pe(e)?"fragment":null!==e.closest("head")?"route":"patch"}function ve(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function ye(e){return"string"==typeof e&&e.length>0}function be(e,t){return null!==t&&void 0!==e&&t.includes(e)}function we(e){const t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}function Se(e){return"object"==typeof e&&null!==e}function Ae(e){return Array.isArray(e)?"array":Se(e)?"object":"scalar"}function ke(e,t){return Se(e)?e[t]:void 0}function Re(e,t){return("string"==typeof t||"number"==typeof t)&&Se(e)&&!Array.isArray(e)&&e.id===t}function Te(e,t){if(!Se(e)||!Se(t))return Re(e,t)||Re(t,e)||J(e)===J(t);if(Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(n=>Object.hasOwn(e,n)&&Te(ke(e,n),ke(t,n)))}function Ce(e,t){const n=J(t),r=J(e);return void 0!==n&&n===r||!(!Re(e,t)&&!Re(t,e))||void 0!==n&&void 0!==r&&Te(e,t)}function Pe(e,t,n){let r=t,i=n;for(const t of e.split("."))r=ke(r,t),i=ke(i,t);return!Ce(r,i)}function Le(e,t,n,r){const i=[];let o=0;const s=(e,t,n,a)=>{if(o+=1,r.covers(e)||Ce(t,n))return;if(!((void 0===t||Ae(t)===Ae(n))&&Se(n)&&r.reachesBelow(e)&&a<8))return void i.push({path:e,value:n});const l=function(e,t){const n=new Set(Object.keys(t));if(Se(e))for(const t of Object.keys(e))n.add(t);return[...n]}(t,n);0===l.length&&i.push({path:e,value:n});for(const r of l){if(o>=1024)return void i.push({path:e,value:n});s(`${e}.${r}`,ke(t,r),ke(n,r),a+1)}};return s(e,t,n,0),i}var $e=/* @__PURE__ */new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function Ne(e,t,n={}){const r=e=>!1===t||be(e,t),i=[];for(const[t,n]of e.entries())n.some(e=>r(e.owner))&&i.push(t);const o=e.rendered.filter(e=>void 0!==n[e.strategy]);return function(e,t){const n=new Set(e),r=[...t],i=(e,t)=>{const n=`${t}.`;for(const t of e)if(t.startsWith(n))return!0;return!1};return{covers:e=>n.has(e)||r.some(t=>t===e||e.startsWith(`${t}.`)),reachesBelow:e=>i(n,e)||i(r,e)}}(i,[...e.covers,...o].filter(e=>r(e.owner)).flatMap(e=>e.paths))}function Fe(e,t){if(void 0===t||0===t.length)return e;const n=`_${t}`;return e.endsWith(n)?e.slice(0,-n.length):e}function Ue(e,t,n,r=Ne(e,n)){let i;const o=r.covers,s=r.reachesBelow;return r=>{const a=Fe(r,t);return o(r)||a!==r&&o(a)?"whole":(i??=function(e,t){const n=/* @__PURE__ */new Set;for(const[r,i]of e.entries())for(const e of i)(!1===t||be(e.owner,t))&&void 0!==e.locale&&n.add(`${r}_${e.locale}`);return n}(e,n),i.has(r)?"whole":s(r)||a!==r&&s(a)?"below":"none")}}function xe(e,t,n,r,i){const o=Ne(e,r,i),s=Ue(e,n,r,o),a=[];for(const[e,r]of Object.entries(t)){if($e.has(e)||"below"!==s(e))continue;const t=Fe(e,n);a.push(...Le(t,void 0,r,o))}return a}function Me(e,t,n){return"declared"===e&&void 0!==t&&void 0!==n?{previous:t,next:n}:void 0}function Ee(e,t,n,r,i,o){const s=Ne(e,r,o),a=Ue(e,n,r,s),l=[];for(const e of t){if($e.has(e))continue;const t=a(e);if("none"===t&&l.push(e),"below"!==t||void 0===i)continue;const r=Fe(e,n),{previous:o,next:d}=i;for(const{path:t}of Le(r,o[e],d[e],s))l.push(t)}return l}var Oe=/* @__PURE__ */new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),Ie=/* @__PURE__ */new Set(["root","paragraph","text","heading","quote","list","listitem","linebreak","tab","horizontalrule","code","code-highlight","table","tablerow","tablecell","link","autolink"]),De={},_e=class{rawChanges=new oe;resolved=null;resolvedLocale=null;trailing=null;openUntil=0;requestAttempt=0;decide(e,t){const n=t.rawData;if(!function(e){const{cache:t,emitter:n}=e;if(t.islands.length>0)return!0;if(n.listenerCount("beforeUpdate")>0||n.listenerCount("afterUpdate")>0)return!0;for(const e of t.values()){if(ze(e)||e.fieldName.includes("."))return!0;if(We(e.hrefField)||We(e.srcField)||We(e.altField))return!0}return void 0!==e.strategies.fragment&&null!==e.root.querySelector(`[${he}]`)}(e)&&!function(e,t,n){for(const r of e.values()){if("text"!==r.fieldType||!0===r.explicitFieldType)continue;const e=ue(t,r,r.fieldName,n);if(it(e)&&je(e.root))return!0}return!1}(e.cache,n,t.locale))return t.forceRender&&(this.resolvedLocale=null),{merge:!1,fields:n};const{changed:r}=this.rawChanges.diff(n,De),i=this.resolvedLocale!==t.locale,o=this.resolved;if(null===o)return this.resolved=n,{merge:!0,fields:n};const s={...o};t.forceRender&&(this.resolvedLocale=null);let a=t.forceRender||i;for(const i of r){const r=n[i];if($e.has(i)){s[i]=r;continue}const l=Be(i,o[i],r,e.cache,t.schemaIndex);"own"!==l&&(a=!0,this.resolvedLocale=null),"keep"!==l&&(s[i]=r)}return this.resolved=s,{merge:a,fields:s}}request(e,t,n){const r=++this.requestAttempt,i=Date.now();if(i>=this.openUntil)return this.openUntil=i+t,this.dropQueued(),this.requestAttempt!==r?{leading:!0,result:Promise.resolve({status:"superseded"})}:{leading:!0,result:e.merge(n)};const o=this.trailing,s=o?.pending??function(){let e;return{promise:new Promise(t=>{e=t}),settle:e}}(),a={request:n,pending:s,timer:null};if(this.trailing=a,this.openUntil=i+t,null!==o&&null!==o.timer&&clearTimeout(o.timer),this.trailing!==a)return{leading:!1,result:s.promise};const l=setTimeout(()=>{this.flush(e,a)},t);return this.trailing===a?a.timer=l:clearTimeout(l),{leading:!1,result:s.promise}}recordMerged(e,t){this.resolved=e,this.resolvedLocale=t}resetRawChanges(){this.rawChanges.reset()}destroy(){this.requestAttempt+=1,this.openUntil=0,this.dropQueued()}dropQueued(){const e=this.trailing;this.trailing=null,null!==e&&(null!==e.timer&&clearTimeout(e.timer),e.pending.settle({status:"superseded"}))}flush(e,t){this.trailing===t&&(this.trailing=null,t.timer=null,e.merge(t.request).then(t.pending.settle))}};function Be(e,t,n,r,i){return He(n)?!He(t)||function(e,t,n){const r=void 0===n?void 0:M(n,e);return void 0!==r&&!Oe.has(r.type)||!0===t.get(e)?.some(ze)||function(e,t){const n=`${t}.`;for(const[t,r]of e.entries())if(t.startsWith(n))return!0;return!1}(t,e)}(e,r,i)?"keep":null==t?"ask":"own":"ask"}function ze(e){return!Oe.has(e.fieldType)}function je(e){const t=[e],n=/* @__PURE__ */new Set;for(let e=t.pop();void 0!==e;e=t.pop()){if("object"!=typeof e||null===e||n.has(e))continue;n.add(e);const{type:r,fields:i,children:o}=e;if(!Ie.has(r))return!0;if("internal"===i?.linkType)return!0;if(Array.isArray(o))for(const e of o)t.push(e)}return!1}function He(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function We(e){return!0===e?.includes(".")}function isInIframe(){if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch{return!0}}function isInPopup(){return"undefined"!=typeof window&&null!=window.opener}function isInPreviewContext(){return isInIframe()||isInPopup()}function isDevMode(){const e=function(){if("undefined"==typeof process)return;const e=process.env.NODE_ENV;return"string"==typeof e?e:void 0}();if(void 0!==e)return"production"!==e;if("undefined"!=typeof window){const e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}return!1}var qe=class{negotiation=negotiateProtocol(void 0);observed=/* @__PURE__ */new Set;observe(e,t,n){const r=e.filter(e=>!this.observed.has(e));if(0!==r.length){for(const e of r)this.observed.add(e);this.negotiation=negotiateProtocol(this.negotiation.theirs,this.observed),t("protocol",`observed=${r.join(",")}`),"undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__||!r.includes("schema-json")||!isDevMode()||n(v)}}applyVersion(e,t){const n=this.negotiation;if(n.theirs===e)return;const r=negotiateProtocol(e,this.observed);this.negotiation=r,r.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${r.negotiated}`)}};function Ve(e,t){const n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;const r=we(e),i=we(t.data??{});return void 0!==r&&void 0!==i&&r!==i}function Ge(e){return null!==e&&e.forceRender&&!e.completed}var Ke=class{lastIdentity=void 0;inspect(e){const t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;const n=JSON.stringify([t.entitySlug,we(t),t.updatedAt]);return{identity:n,edit:n!==this.lastIdentity&&Ve(t,e)?t:null}}commit(e){const t=e.identity!==this.lastIdentity;return this.lastIdentity=e.identity,t?e.edit:null}};function Je(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var Qe=class{#e;reveal(e,t,n){return e===this.#e?"skipped-same":(this.#e=e,function(e,t){for(let t;t=e.closest?.("details:not([open])");)t.setAttribute("open","");return function(e,t){const n=e.getBoundingClientRect(),r=n.bottom>0&&n.top<t.innerHeight,i=n.right>0&&n.left<t.innerWidth;return r&&i}(e,t)?"already-visible":(e.scrollIntoView({behavior:Je(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){this.#e=void 0}};function Xe(e,t){const n=t.element.ownerDocument.defaultView;return null===n?"no-element":e.reveal(`${t.owner??""} ${t.fieldName}`,t.element,n)}var Ze=class{seen=/* @__PURE__ */new Map;note(e,t,n){const r=J(n);if(void 0===r)return;const i=`${t.owner??""}\0${t.locale??""}\0${t.fieldName}`,o=this.seen.get(i);void 0!==o?o!==r&&(e.revealIdentities.push([i,r]),e.revealTarget??=t):this.seen.set(i,r)}commit(e){for(const[t,n]of e.revealIdentities)this.seen.set(t,n);e.revealIdentities=[];const t=e.revealTarget;return e.revealTarget=void 0,t}},Ye=()=>{},et=class{host={outstanding:()=>!1,report:Ye,failed:Ye};entry=null;ended;begin(e,t){const n=this.entry,r=null===n?void 0:this.view(n);null!==n&&(n.key=void 0),this.ended=void 0,this.entry={key:e,revision:t,shortfalls:[],seen:/* @__PURE__ */new Set,deferred:0,awaiting:0,reported:void 0,queued:!1},null!==n&&void 0!==r&&this.publish(n,"pending"===r.state?{...r,state:"superseded"}:r)}end(){const e=this.entry;if(null!==e){this.entry=null;try{this.ended=this.view(e)}finally{e.key=void 0}}}snapshot(){return null!==this.entry?this.view(this.entry):void 0===this.ended?void 0:{...this.ended,shortfalls:[...this.ended.shortfalls]}}shortfall(e,t){const n=this.entry;if(n?.key!==e)return;const r=JSON.stringify(t);n.seen.has(r)||(n.seen.add(r),n.shortfalls.push(t),this.requestSettle(n.key))}deferred(e,t){this.entry?.key===e&&(this.entry.deferred=t)}handIsland(e){const t=this.entry;if(t?.key!==e)return Ye;t.awaiting+=1;let n=!1;return()=>{n||this.entry!==t||(n=!0,t.awaiting-=1,this.settle(t))}}requestSettle(e){const t=this.entry;t?.key!==e||t.queued||(t.queued=!0,queueMicrotask(()=>{t.queued=!1;try{this.entry===t&&this.settle(t)}catch(e){this.host.failed(e)}}))}settle(e){const t=this.view(e);"pending"!==t.state&&this.publish(e,t)}publish(e,t){e.reported!==t.state&&(e.reported=t.state,this.host.report(t))}view(e){const t=void 0!==e.key&&this.host.outstanding(e.key)?"pending":e.shortfalls.length>0?"partial":e.awaiting>0?"unconfirmed":"current";return{revision:e.revision,state:t,shortfalls:[...e.shortfalls],deferred:e.deferred,awaitingIslands:e.awaiting}}};function tt(e){const t=e.getAttribute(fe);return{kind:"fragment",id:e.getAttribute(he)??"",key:null===t||0===t.length?void 0:t,code:"LP0801"}}var nt=class{started=!1;suspended=!1;deferredStart=null;hydration="idle";activeUpdate=null;locale=void 0;schema=void 0;schemaIndex=void 0;updateCount=0;supersededCount=0;completedCount=0;skippedUnchangedCount=0;lastFlush=null;absentFields=/* @__PURE__ */new Set;warnedOrphanFields=/* @__PURE__ */new Set;warnedStrategy=/* @__PURE__ */new WeakSet;warnedUnattributableMessage=!1;warnedVisibilityGate=!1;warnedFragmentFallback=!1;warnedIslandStart=!1;warnedEscalationUnavailable=!1;warnedProtocolShape=!1;reportedUnfaithful=/* @__PURE__ */new WeakMap;checkedServerFormat=/* @__PURE__ */new WeakSet;rowsOfBinding=/* @__PURE__ */new WeakMap;unfaithfulPatches=[];unfaithfulCount=0;escalatedCount=0;unfaithfulFields=/* @__PURE__ */new Set;autoBindSearchMs=void 0;autoBindGuesses=null;warnedForeignSource=!1;lastAppliedIdentity=/* @__PURE__ */new WeakMap;navigationReplayPending=!1;navigationBindingReplay=!1;revealLedger=new Ze;display=new et;fragmentStats={rendered:0,failed:0,superseded:0};routeStats={refreshes:0,partial:0,failed:0,refused:0,loopStopped:0};fragmentControllers=/* @__PURE__ */new Map;routeController=null;routeRetry=null;routeRefreshOwed=!1;routeAwaitsSave=!1;fragmentsOwed=/* @__PURE__ */new Set;readyTimers=[];revealer=new Qe;changes=new oe;merges=new _e;protocol=new qe;relationships=new Ke;isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){this.display.requestSettle(e),e.completed||(e.completed=!0,e.countsAsUpdate&&(this.completedCount+=1))}forgetOwedWork(){this.routeRefreshOwed=!1,this.routeAwaitsSave=!1,this.fragmentsOwed.clear()}supersedeStrategies(){null!==this.routeRetry&&(clearTimeout(this.routeRetry),this.routeRetry=null,this.routeRefreshOwed=!0);for(const[e,t]of this.fragmentControllers){for(const e of t)this.fragmentsOwed.add(e);e.abort()}this.fragmentControllers.clear()}abortStrategies(){this.supersedeStrategies();const e=this.routeController;this.routeController=null,e?.abort()}},rt=class{constructor(e,t){this.deps=e,this.state=t,this.instanceContext=F({renderRichText:e.renderRichText,internalLinkPattern:e.internalLinkPattern,sanitizerPolicy:e.sanitizerPolicy,serverURL:e.serverURL,reportUnfaithful:(n,r)=>{X(e,t,n,r,this.writing)}})}deps;state;writing;instanceContext;apply(e){const{deps:t,state:n}=this,r=n.activeUpdate;if(null===r||void 0===e.revision||!b(r.revision,e.revision)||!n.isCurrent(r))return!1;const{target:i,value:o}=e,s=void 0!==r.schemaIndex?M(r.schemaIndex,i.fieldName):void 0;let a,l=function(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){const e=function(e){if(Object.prototype.hasOwnProperty.call(_,e))return _[e]}(t);if(void 0!==e)return e}return e.fieldType}(i,s?.type);"text"===l&&!0!==i.explicitFieldType&&it(o)&&(l="richText");try{a=t.resolveRenderer(l,i)}catch(e){return this.fail(r,i.fieldName,e)}if(!n.isCurrent(r))return!1;const d=t.emitter.listenerCount("elementUpdate")>0,u=d?"INPUT"===(c=i.element).tagName||"TEXTAREA"===c.tagName?c.value:"IMG"===c.tagName?c.src:c.textContent:void 0;var c;if(!n.isCurrent(r))return!1;const h={allFields:e.allFields,locale:i.locale??r.locale,schema:s,...this.instanceContext};!0===i.hidesWhenEmpty&&i.element.toggleAttribute("hidden",function(e){return null==e||("string"==typeof e?0===e.trim().length:Array.isArray(e)&&0===e.length||ot(e))}(o));try{if(void 0!==i.targetAttribute){if("blocked"===function(e,t,n){const r=t.toLowerCase().trim();if(0===r.length)return"blocked";if(!K(r))return"blocked";if(null==n)return e.removeAttribute(r),"applied";if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return"blocked";const i=String(n);return G.has(r)&&!isSafeUrl(i)?"blocked":(e.setAttribute(r,i),"applied")}(i.element,i.targetAttribute,o))return t.warn(`[live-preview] LP0401: refused to write "${i.fieldName}" into attribute "${i.targetAttribute}"`),n.display.shortfall(r,{kind:"write",field:i.fieldName,code:"LP0401"}),!1}else{if(void 0===a)return t.log("no renderer for",l),X(t,n,i,`has no renderer for "${l}"`,o),!1;{const e=function(e,t,n,r){if("ignore"===e.onUnfaithfulPatch)return;if(void 0!==n.format||!Y.has(r))return;if(ee(r)&&n.element.matches("select,input"))return;if(t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);const i=te(n.element);return i.trim().length>0?i:void 0}(t,n,i,l);this.writing=o;const r=function(e,t,n,r){return e.render(t,n,r)}(a,i,o,h);if(!1===r&&function(e){return re.has(e.render)}(a))return X(t,n,i,`is a value ${a.name} cannot render`,o),!1;void 0!==e&&function(e,t,n,r){const i=te(t.element);i!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${ne(n)}, the patch wrote ${ne(i)} — `+(ee(r)?'Payload sends the value of an option, not its label. Render the label in a data-payload-fragment boundary, or bind it with data-payload-strategy="route".':"either an edit that arrived before the preview connected, or a template that formats this value differently. Set data-payload-format to match it."))}(t,i,e,l)}}}catch(e){return this.fail(r,i.fieldName,e)}if(!n.isCurrent(r))return!1;d&&t.emitter.emitWhile("elementUpdate",{element:i.element,fieldName:i.fieldName,previousValue:u,nextValue:o,revision:r.revision.revision,receivedAt:r.receivedAt,source:"patch"},()=>n.isCurrent(r));const f=n.isCurrent(r);return f&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(i.element,e.valueIdentity):n.lastAppliedIdentity.delete(i.element)),f}fail(e,t,n){if(!this.state.isCurrent(e))return!1;this.state.display.shortfall(e,{kind:"write",field:t,code:"LP0603"});const r=n instanceof Error?n:new Error(String(n));return this.deps.emitter.emitWhile("error",{error:r,context:"renderer",code:"LP0603"},()=>this.state.isCurrent(e)),!1}};function it(e){if("object"!=typeof e||null===e||!("root"in e))return!1;const t=e.root;return"object"==typeof t&&null!==t&&Array.isArray(t.children)}function ot(e){return!!it(e)&&e.root.children.every(e=>{const{type:t,children:n}=e??{};return"paragraph"===t&&(!Array.isArray(n)||0===n.length)})}function st(e){if(null==e)return[];const t=/* @__PURE__ */new Set,n=[];for(const r of e.split(/[\s,]+/)){const e=r.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}function at(...e){const t=/* @__PURE__ */new Map;for(const n of e)for(const[e,r]of Object.entries(n)){let n=t.get(e);void 0===n&&(n=/* @__PURE__ */new Set,t.set(e,n));for(const e of r)n.add(e)}const n={};for(const[e,r]of t)n[e]=[...r];return n}function lt(e,t){const n={};for(const r of t)r!==e&&(n[r]=[e]);return n}var dt="payload-live-preview:update",ut="data-payload-island",ct=`astro-island, [${ut}]`,ht="data-payload-owned";function ft(e){if(e.tagName.toLowerCase().includes("-")&&!e.hasAttribute("data-payload-morph"))return!0;if(gt(e)||e.hasAttribute(ht))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function pt(e){return"patch"===e.getAttribute(ut)}function gt(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(ut)}(e)&&!pt(e)}function isInsideIsland(e){let t=e;for(;null!==t;){if(gt(t))return!0;t=t.parentElement}return!1}function mt(e){return"astro-island"===e.tagName.toLowerCase()&&e.hasAttribute("ssr")}var vt=["component-url","component-export","renderer-url","client","opts","before-hydration-url"],yt=/* @__PURE__ */new WeakMap,bt=/* @__PURE__ */new WeakSet;function wt(e){return"astro-island"===e.tagName.toLowerCase()}function St(e){let t="";for(const n of e.querySelectorAll("astro-slot, template[data-astro-template]"))n.parentElement?.closest("astro-island")===e&&(t+=`${n.getAttribute("name")??n.getAttribute("data-astro-template")??""}\0${n.innerHTML}\0`);return t}function At(e,t){if(!wt(e)||!wt(t))return!0;const n=St(t);if(!vt.every(n=>e.getAttribute(n)===t.getAttribute(n))||(yt.get(e)??St(e))!==n||e.getAttribute("props")!==t.getAttribute("props")&&!function(e){const t=e.ownerDocument.defaultView?.customElements.get("astro-island");return void 0!==t&&e instanceof t&&Array.isArray(t.observedAttributes)&&t.observedAttributes.includes("props")}(e))return yt.set(t,n),!1;yt.set(e,n);const r=t.getAttribute("props");return r!==e.getAttribute("props")&&(e.setAttribute("ssr",""),null===r?e.removeAttribute("props"):e.setAttribute("props",r)),!0}function kt(e){return Array.from(e.querySelectorAll("astro-island"))}function Rt(e){const t=e.ownerDocument.defaultView;if(void 0===t?.customElements.get("astro-island"))return"element";const n=e.getAttribute("client"),r=Reflect.get(t,"Astro");return null===n||"object"!=typeof r||null===r||void 0===Reflect.get(r,n)?"directive":void 0}var Tt="data-payload-field",Ct="data-payload-type",Pt="data-payload-attribute",Lt="data-payload-href",$t="data-payload-src",Nt="data-payload-alt",Ft="data-payload-array-template",Ut="data-payload-array-separator",xt="data-payload-locale",Mt="data-payload-format",Et="data-payload-richtext",Ot="data-payload-html",It="data-payload-array",Dt="data-payload-structural",_t="data-payload-owner",Bt="data-payload-depends",zt="data-payload-strategy",jt="data-payload-boundary",Ht="data-payload-guessed",Wt="data-payload-covers",qt=[Tt,Ct,Pt,Lt,$t,Nt,Ft,Ut,xt,Mt,Et,Ot,It,Dt,_t,Bt,zt,jt,"type"],Vt=`[${Tt}]`,Gt=`[${_t}]`,Kt=`[${he}], [${zt}="route"]`;function Jt(e){const t=e.closest(Gt)?.getAttribute(_t);return null==t||0===t.length?void 0:t}var Qt=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,Xt=/* @__PURE__ */new Set(["text","textarea","richText","email","number","checkbox","date","select","radio","array","blocks","group","tabs","row","collapsible","relationship","upload","point","json","code","ui","html","url","image","structural-array"]);function Zt(e){return Xt.has(e)||Qt.test(e)}function Yt(e,t){return e.fieldName===t.fieldName&&e.locale===t.locale&&e.owner===t.owner&&e.strategyKind===t.strategyKind&&e.fragmentBoundary===t.fragmentBoundary}var en=class{entriesByField=/* @__PURE__ */new Map;entryByElement=/* @__PURE__ */new WeakMap;filter;count=0;dependencies=null;islandRoots=[];ownersByIsland=/* @__PURE__ */new Map;navigationRoots=[];coverDeclarations=[];renderedDeclarations=[];constructor(e={}){this.filter=e.filter??nn}dependencyMap(){if(null!==this.dependencies)return this.dependencies;const e=[];for(const t of this.values())void 0!==t.dependsOn&&e.push(lt(t.fieldName,t.dependsOn));return this.dependencies=at(...e),this.dependencies}get islands(){return this.islandRoots}get islandOwners(){return this.ownersByIsland}get covers(){return this.coverDeclarations}get rendered(){return this.renderedDeclarations}get navigationReplayRoots(){return this.navigationRoots}buildFromRoot(e){const t=performance.now();this.clear();let n=0;for(const t of e.querySelectorAll(Vt))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){const t=[];for(const n of e.querySelectorAll(ct))pt(n)||t.push(n);return t}(e),this.ownersByIsland=new Map(this.islandRoots.map(e=>[e,Jt(e)])),this.navigationRoots=[...e.querySelectorAll(Kt)].filter(e=>this.filter(e)&&(e.hasAttribute(he)||0===(e.getAttribute(Tt)??"").length)),this.coverDeclarations=[...e.querySelectorAll(`[${Wt}]`)].filter(e=>this.filter(e)).map(e=>({paths:st(e.getAttribute(Wt)),owner:Jt(e)})),this.renderedDeclarations=[...e.querySelectorAll(`[${Bt}]`)].filter(e=>this.filter(e)).flatMap(e=>{const t=function(e){if((e.getAttribute(he)??"").length>0)return"fragment";const t=e.getAttribute(zt);return null!==t?"route"===t?"route":void 0:e.hasAttribute(Tt)&&null!==e.closest("head")?"route":void 0}(e);return void 0===t?[]:[{strategy:t,paths:st(e.getAttribute(Bt)),owner:Jt(e)}]}),{elementCount:n,fieldCount:this.entriesByField.size,durationMs:performance.now()-t}}add(e){const t=this.filter(e)?this.resolveBinding(e):void 0,n=this.entryByElement.get(e);if(this.dependencies=null,void 0!==t)return void 0!==n&&this.replaceEntry(n,t)?(this.entryByElement.set(e,t),t):(void 0!==n&&this.removeEntry(e,n),this.append(t),this.entryByElement.set(e,t),t);void 0!==n&&this.removeEntry(e,n)}remove(e){const t=this.entryByElement.get(e);return!!t&&(this.dependencies=null,this.removeEntry(e,t))}get(e){return this.entriesByField.get(e)}getByElement(e){return this.entryByElement.get(e)}get fieldCount(){return this.entriesByField.size}get elementCount(){return this.count}entries(){return this.entriesByField.entries()}*values(){for(const e of this.entriesByField.values())yield*e}has(e){return this.entryByElement.has(e)}clear(){this.entriesByField.clear(),this.entryByElement=/* @__PURE__ */new WeakMap,this.count=0,this.dependencies=null,this.islandRoots=[],this.ownersByIsland=/* @__PURE__ */new Map,this.navigationRoots=[],this.coverDeclarations=[],this.renderedDeclarations=[]}replaceEntry(e,t){if(e.fieldName!==t.fieldName)return!1;const n=this.entriesByField.get(e.fieldName),r=void 0===n?-1:n.indexOf(e);return!(void 0===n||r<0||(n[r]=t,0))}removeEntry(e,t){this.entryByElement.delete(e);const n=this.entriesByField.get(t.fieldName),r=void 0===n?-1:n.indexOf(t);return!(void 0===n||r<0||(n.splice(r,1),0===n.length&&this.entriesByField.delete(t.fieldName),this.count-=1,0))}append(e){const t=this.entriesByField.get(e.fieldName);t?t.push(e):this.entriesByField.set(e.fieldName,[e]),this.count+=1}resolveBinding(e){const t=e.getAttribute(Tt);if(null===t||0===t.length)return;const n=e.getAttribute(Ct),r=e.getAttribute(Pt),i=e.getAttribute(Lt),o=e.getAttribute($t),s=e.getAttribute(Nt),a=e.getAttribute(Ft),l=e.getAttribute(Ut),d=e.getAttribute(xt),u=e.getAttribute(Mt),c=Jt(e),h=st(e.getAttribute(Bt)),f=e.getAttribute(zt),p=e.getAttribute(Ht),g=pe(e);return{element:e,fieldName:t,fieldType:tn(e),explicitFieldType:null!==n&&Zt(n),strategyKind:me(e)??"unknown",...null!==g?{fragmentBoundary:g}:{},...null!==r&&r.length>0?{targetAttribute:r}:{},...null!==i&&i.length>0?{hrefField:i}:{},...null!==o&&o.length>0?{srcField:o}:{},...null!==s&&s.length>0?{altField:s}:{},...null!==a?{arrayTemplate:a}:{},...null!==l?{arraySeparator:l}:{},...null!==d&&d.length>0?{locale:d}:{},...null!==u&&u.length>0?{format:u}:{},...void 0!==c?{owner:c}:{},...h.length>0?{dependsOn:h}:{},...null!==f&&f.length>0?{strategy:f}:{},...e.hasAttribute(jt)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}};function tn(e){const t=e.getAttribute(Ct);if(null!==t&&Zt(t))return t;if(e.hasAttribute(Et))return"richText";if(e.hasAttribute(Ot))return"html";if(e.hasAttribute(Dt))return"structural-array";if(e.hasAttribute(It))return"array";if("IMG"===e.tagName)return"image";if("A"===e.tagName)return"url";if("TIME"===e.tagName)return"date";if("INPUT"===e.tagName){const t=e.type;if("checkbox"===t)return"checkbox";if("number"===t)return"number";if("date"===t||"datetime-local"===t)return"date"}return"text"}function nn(){return!0}var rn=1e4,on=1048576,sn=/* @__PURE__ */new Set(["__proto__","constructor","prototype"]);function an(){throw new Error("invalid or oversized legacy population")}function ln(e){for(let t=0;t<e.length;t+=1){const n=e.charCodeAt(t);if(n<=31||127===n)return!0}return!1}function dn(e,t){if("string"!=typeof e||0===e.length||e.length>t||"."===e||".."===e)return!1;if(e.includes("/")||e.includes("\\")||ln(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}function un(e){return dn(e,128)&&!/[?#%]/u.test(e)&&!sn.has(e)}function cn(e){return Number.isFinite(e)?String(e):dn(e,512)?e:an()}function hn(e,t){return Object.hasOwn(e,t)?Reflect.get(e,t):void 0}function fn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0,enumerable:!0})}function pn(e){let t=e.length;for(;t>0&&47===e.charCodeAt(t-1);)t-=1;return e.slice(0,t)}function gn(e){const t=/* @__PURE__ */new WeakSet;let n=0,r=0;return function e(i,o){if(++n>rn||o>64)return an();if("string"==typeof i)return r+=i.length,r>on&&an(),i;if(null==i||"boolean"==typeof i)return i;if("number"==typeof i)return Number.isFinite(i)?i:an();if(!Array.isArray(i)&&!h(i))return an();if(Array.isArray(i)){i.length>rn&&an();for(let e=0;e<i.length;e+=1)Object.hasOwn(i,e)||an()}if(t.has(i))return an();t.add(i);const s=Array.isArray(i)?[]:{};for(const t of Object.keys(i))fn(s,t,e(Reflect.get(i,t),o+1));return t.delete(i),s}(e,0)}function mn(e,t,n,r,i,o){if(!Number.isSafeInteger(i)||i<0||i>64)return an();void 0!==o&&("string"!=typeof o||o.length>128||ln(o))&&an();const s=gn(e);if(!h(s))return an();const a=/* @__PURE__ */new Map,l=/* @__PURE__ */new Set;let d=0;const u=/* @__PURE__ */new WeakSet,c=e=>{(++d>rn||e>64)&&an()};function f(e,t,n,r){if(null==r||""===r)return;const o=h(r)?hn(r,"id"):r,s=cn(o);if(0===i)return void fn(e,t,o);const d=JSON.stringify([n,s]);l.add(d),l.size>1e3&&an();const u=a.get(n)??[];u.push({owner:e,key:t,id:s}),a.set(n,u)}function p(e,t,n){void 0!==n.hasMany&&"boolean"!=typeof n.hasMany&&an();const r=n.relationTo,i=hn(e,t);if(Array.isArray(r)){0===r.length&&an();const e=h(i)?hn(i,"relationTo"):void 0;let t;for(const n of r)c(0),un(n)||an(),n===e&&(t=n);if(null==i||""===i)return;h(i)&&void 0!==t||an(),f(i,"value",t,hn(i,"value"))}else un(r)||an(),f(e,t,r,i)}function g(e,t){if(c(t),Array.isArray(e)||h(e)){if(h(e)&&Object.hasOwn(e,"relationTo")&&Object.hasOwn(e,"value")){const t=hn(e,"relationTo");return un(t)||an(),void f(e,"value",t,hn(e,"value"))}for(const n of Object.keys(e))g(Reflect.get(e,n),t+1)}}!function e(t,n,r){c(r),u.has(t)&&an(),u.add(t);for(const i of t){c(r),h(i)&&dn(i.name,512)&&!sn.has(i.name)||an();const t=hn(n,i.name);if("relationship"===i.type||"upload"===i.type)if(i.hasMany)if(null==t||Array.isArray(t)||an(),Array.isArray(t))for(let e=0;e<t.length;e+=1)p(t,e,i);else p(n,i.name,i);else p(n,i.name,i);else if("group"===i.type||"tabs"===i.type)null==t||h(t)||an(),h(t)&&i.fields&&e(i.fields,t,r+1);else if("row"===i.type||"collapsible"===i.type)i.fields&&e(i.fields,n,r+1);else if("array"===i.type||"blocks"===i.type){if(0===t?fn(n,i.name,[]):null==t||Array.isArray(t)||an(),Array.isArray(t))for(const n of t)if(h(n)||an(),"array"===i.type&&i.fields)e(i.fields,n,r+1);else if("blocks"===i.type){const t=hn(n,"blockType"),o=i.blocks?.find(e=>(c(r),e.slug===t));void 0===o&&an(),e(o.fields,n,r+1)}}else"richText"===i.type&&g(t,r+1)}u.delete(t)}(t,s,0),a.size>25&&an();const m=[];if(0===a.size)return{doc:s,requests:m};const v=new URL(n);(!["http:","https:"].includes(v.protocol)||v.username||v.password||v.search||v.hash)&&an(),(!r.startsWith("/")||r.includes("\\")||/[%?#]/u.test(r)||ln(r))&&an(),r.split("/").some(e=>"."===e||".."===e)&&an();const y=`${pn(n)}${pn(r)}/`;for(const[e,t]of a){const n=[...new Set(t.map(e=>e.id))];let r=0;for(;r<n.length;){const s=n[r];void 0===s&&an();const a=s.includes(","),l=[];let d="";for(;r<n.length&&l.length<20;){const t=n[r];if(void 0===t||l.length>0&&(a||t.includes(",")))break;const s=[...l,t],u=new URLSearchParams({depth:String(i),limit:String(s.length)});void 0!==o&&u.set("locale",o),u.set(a?"where[id][equals]":"where[id][in]",a?t:s.join(","));const c=`${y}${encodeURIComponent(e)}?${u}`;if(c.length>8192){0===l.length&&an();break}new URL(c).origin!==v.origin&&an(),l.push(t),r+=1,d=c}(0===l.length||m.length>=64)&&an();const u=new Set(l);m.push({url:d,ids:u,slots:t.filter(e=>u.has(e.id))})}}return{doc:s,requests:m}}async function vn(e,t,n){let r,i=!1,o=!1;const s=/* @__PURE__ */Symbol();let a;const l=new Promise(e=>{a=()=>{e(s)}}),d=()=>{n()&&!t.aborted||an()},u=()=>{if(void 0!==r&&!i){i=!0;try{Promise.resolve(r.cancel()).catch(()=>{})}catch{}}},c=()=>{a?.(),u()};t.addEventListener("abort",c,{once:!0});try{d();const t=e.body??null;if(d(),null===t){const t=e.json.bind(e);d();const n=await Promise.race([Promise.resolve().then(()=>(d(),t())),l]);return d(),n===s&&an(),n}const n=t.getReader.bind(t);d();const i=n();r=i,d();const a=[];let u=0,c=0;for(;;){const e=Promise.resolve().then(()=>{d();const e=i.read.bind(i);return d(),e()}),t=await Promise.race([e,l]);if(d(),t===s&&an(),t.done)break;u+=t.value.byteLength,(++c>1e4||u>on)&&an(),a.push(t.value)}o=!0;const h=new Uint8Array(u);let f=0;for(const e of a)h.set(e,f),f+=e.byteLength;try{return JSON.parse((new TextDecoder).decode(h))}catch{return an()}}finally{t.removeEventListener("abort",c),o||u();try{r?.releaseLock()}catch{}}}function yn(e,t){const n=gn(t);h(n)||an();const r=hn(n,"docs");(!Array.isArray(r)||r.length>20)&&an();const i=/* @__PURE__ */new Map;for(const t of r){h(t)||an();const n=cn(hn(t,"id"));e.ids.has(n)&&!i.has(n)||an(),i.set(n,t)}i.size!==e.ids.size&&an();for(const t of e.slots)fn(t.owner,t.key,i.get(t.id))}function bn(e,t){return e.length>0&&e.length<=t&&"."!==e&&".."!==e&&!e.includes("/")&&!e.includes("\\")&&!function(e){for(const t of e){const e=t.codePointAt(0)??0;if(e<=31||127===e)return!0}return!1}(e)}function wn(e){return bn(e,128)&&!e.includes("?")&&!e.includes("#")}function Sn(e){return"number"==typeof e?Number.isFinite(e):"string"==typeof e&&bn(e,512)}var An=new Error,kn=class{serverURL;apiRoute;depth;fetchFn;log;timeoutMs;inflight=null;attempt=0;destroyDepth=0;constructor(e){this.serverURL=function(e){let t=e.length;for(;e.endsWith("/",t);)t-=1;return e.slice(0,t)}(e.serverURL);const t=e.apiRoute??"/api";this.apiRoute=t.startsWith("/")?t:`/${t}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=S(e.log??A);const n=e.timeoutMs??0;this.timeoutMs=n>0&&n<Number.POSITIVE_INFINITY?n:void 0}canMerge(e){try{const t=e.schema;return void 0!==t?(mn(e.data,t,this.serverURL,this.apiRoute,this.depth,e.locale),!0):null!==this.endpointOf(e)}catch{return!1}}endpointOf(e){try{const t=e.globalSlug;if(t)return wn(t)?{path:`globals/${encodeURIComponent(t)}`,field:"globalType",value:t}:null;const n=e.collectionSlug??"",r=e.data.id;return wn(n)&&Sn(r)?{path:`${encodeURIComponent(n)}/${encodeURIComponent(String(r))}`,field:"id",value:String(r)}:null}catch{return null}}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};const t=this.attempt+=1,n=this.inflight;this.inflight=null;let r=null,i=!1;const o=()=>this.attempt!==t,s=this.timeoutMs;let a,l,d=!1;const u=(e,t)=>void 0===s?e:(void 0===l&&(l=new Promise((e,n)=>{a=setTimeout(()=>{d=!0,t.abort(),n(An)},s)}),l.catch(()=>{})),Promise.race([e,l]));try{if(n?.abort(),o())return{status:"superseded"};const t=e.schema;if(i=void 0!==t,void 0!==t){const n=mn(e.data,t,this.serverURL,this.apiRoute,this.depth,e.locale);if(o())return{status:"superseded"};if(0===n.requests.length)return{status:"merged",doc:n.doc};const i=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(o())return{status:"superseded"};if(void 0===i)return{status:"unavailable"};r=new AbortController,this.inflight=r;for(const e of n.requests){const t=await u(i(e.url,{method:"GET",credentials:"include",redirect:"error",signal:r.signal}),r);if(o())return{status:"superseded"};const n=t.ok;if(o())return{status:"superseded"};if(!n){const e=t.status;return o()?{status:"superseded"}:(r.abort(),o()?{status:"superseded"}:(this.log("merge HTTP",e),o()?{status:"superseded"}:{status:"unavailable"}))}const s=await u(vn(t,r.signal,()=>!o()),r);if(o())return{status:"superseded"};if(yn(e,s),o())return{status:"superseded"}}return{status:"merged",doc:n.doc}}const s=this.endpointOf(e);if(o())return{status:"superseded"};if(null===s)return{status:"unavailable"};const a=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(o())return{status:"superseded"};if(void 0===a)return{status:"unavailable"};const l=JSON.stringify({data:e.data,depth:this.depth,flattenLocales:!1,locale:e.locale});if(o())return{status:"superseded"};r=new AbortController,this.inflight=r;const d=`${this.serverURL}${this.apiRoute}/${s.path}`,c=await u(a(d,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:l,signal:r.signal}),r);if(o())return{status:"superseded"};const h=c.ok;if(o())return{status:"superseded"};if(!h){const e=c.status;return o()?{status:"superseded"}:(this.log("merge HTTP",e,d),o()?{status:"superseded"}:{status:"unavailable"})}const f=c.json.bind(c);if(o())return{status:"superseded"};const p=await u(f(),r);if(o())return{status:"superseded"};if(null===p||"object"!=typeof p||Array.isArray(p))return this.log("merge invalid",d),o()?{status:"superseded"}:{status:"unavailable"};const g=p,m=g[s.field],v=Object.hasOwn(g,s.field)&&("id"===s.field?!Sn(m)||String(m)!==s.value:m!==s.value);return o()?{status:"superseded"}:v?(this.log("merge invalid",d),o()?{status:"superseded"}:{status:"unavailable"}):{status:"merged",doc:g}}catch(e){return o()?{status:"superseded"}:d?(this.log("merge timeout",s),{status:"unavailable"}):i&&(r?.abort(),o())?{status:"superseded"}:(this.log("merge exception",i?new Error("legacy population could not be resolved"):e),o()?{status:"superseded"}:{status:"unavailable"})}finally{clearTimeout(a),this.inflight===r&&(this.inflight=null)}}destroy(){this.attempt+=1;const e=this.inflight;this.inflight=null,this.destroyDepth+=1;try{e?.abort()}finally{this.destroyDepth-=1}}},Rn={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},Tn={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},Cn={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1};function detectProtocolProfile(e){return e.has("schema-json")?Rn:e.has("document-events")||e.has("relationship-events")?Tn:Cn}var Pn="ssr",Ln=[Tt,_t,Wt,Bt],$n=`[${Tt}], [${Wt}], ${ct}, ${Kt}`,Nn=class{callbacks;debounceMs;rootMargin;visible=/* @__PURE__ */new Set;mutation=null;intersection=null;debounceTimer=null;generation=0;constructor(e,t={}){this.callbacks=e,this.debounceMs=t.mutationDebounceMs??100,this.rootMargin=t.intersectionRootMargin??"200px"}start(e){const t=this.generation;this.stop();const n=t+1;if(this.generation!==n)return;let r=null,i=null;try{r=new MutationObserver(e=>{this.handleMutations(e,n)}),i=new IntersectionObserver(e=>{this.handleIntersection(e,n)},{rootMargin:this.rootMargin,threshold:0}),r.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...qt,Wt,ut,Pn]})}catch(e){throw r?.disconnect(),i?.disconnect(),e}if(this.generation!==n)return r.disconnect(),void i.disconnect();this.mutation=r,this.intersection=i}observeElement(e){this.intersection?.observe(e)}unobserveElement(e){this.intersection?.unobserve(e),this.visible.delete(e)}markVisible(e,t){t?this.visible.add(e):this.visible.delete(e)}isVisible(e){return this.visible.has(e)}stop(){this.generation+=1;const e=this.debounceTimer,t=this.mutation,n=this.intersection;this.debounceTimer=null,this.mutation=null,this.intersection=null,this.visible.clear(),null!==e&&clearTimeout(e);try{t?.disconnect()}finally{n?.disconnect()}}handleMutations(e,t){if(!this.isCurrentGeneration(t))return;for(const n of e){const e=Fn(n);if(null!==e&&(this.callbacks.onIslandHydrated?.(e),!this.isCurrentGeneration(t)))return}if(!function(e){for(const t of e){if("attributes"===t.type&&t.attributeName===ut)return!0;if("attributes"===t.type&&null!==t.attributeName){if(Ln.includes(t.attributeName))return!0;if(qt.includes(t.attributeName)&&1===t.target.nodeType&&t.target.hasAttribute(Tt))return!0}for(const e of t.addedNodes)if(Un(e))return!0;for(const e of t.removedNodes)if(Un(e))return!0}return!1}(e))return;null!==this.debounceTimer&&clearTimeout(this.debounceTimer);const n=setTimeout(()=>{this.isCurrentGeneration(t)&&this.debounceTimer===n&&(this.debounceTimer=null,this.callbacks.onStructuralChange())},this.debounceMs);this.debounceTimer=n}handleIntersection(e,t){for(const n of e){if(!this.isCurrentGeneration(t))return;const{target:e}=n;if(n.isIntersecting){if(this.visible.has(e))continue;this.visible.add(e),this.callbacks.onVisibilityChange(e,!0)}else this.visible.has(e)&&(this.visible.delete(e),this.callbacks.onVisibilityChange(e,!1))}}isCurrentGeneration(e){return this.generation===e&&null!==this.intersection}};function Fn(e){if("attributes"!==e.type||e.attributeName!==Pn||1!==e.target.nodeType)return null;const t=e.target;return"astro-island"!==t.tagName.toLowerCase()||t.hasAttribute(Pn)?null:t}function Un(e){if(1!==e.nodeType)return!1;const t=e;return t.matches($n)||null!==t.querySelector($n)}var xn=class{#t=[];#n;#r=!1;constructor(e){this.#n=e}get closed(){return this.#r}own(e){this.#r?this.#i(e):this.#t.push(e)}close(){if(this.#r)return;this.#r=!0;const e=this.#t.splice(0).reverse();for(const t of e)this.#i(t)}#i(e){try{e()}catch(e){this.#n("runtime cleanup failed:",e)}}},Mn="[data-payload-field]";function En(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewHydration??={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]}}function On(){const e=En();if(void 0===e||e.armed)return;e.armed=!0;const t=window,n=t.__REACT_DEVTOOLS_GLOBAL_HOOK__??=function(){const e=/* @__PURE__ */new Map;return{supportsFiber:!0,renderers:e,inject:t=>{const n=e.size+1;return e.set(n,t),n}}}(),r=n.onCommitFiberRoot;n.onCommitFiberRoot=function(t,n,...i){try{r?.call(this,t,n,...i)}catch{}void 0===e.onCommit?e.commits.push(n):e.onCommit(n)}}function In(e){e.committed=!0;const t=e.waiters;e.waiters=[];for(const e of t)e()}function Dn(e,t){const n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function _n(e,t,n){if(e.committed)return null;let r=null;const i=()=>{null!==r&&clearTimeout(r),r=null,t("committed")};return e.waiters.push(i),r=setTimeout(()=>{r=null,Dn(e,i),t("timed-out")},n),()=>{null!==r&&clearTimeout(r),r=null,Dn(e,i)}}var Bn="__vue_app__";function zn(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewVueHydration??={armed:!1,committed:!1,waiters:[]}}function jn(e){return Object.prototype.hasOwnProperty.call(e,Bn)?e[Bn]:void 0}function Hn(){const e=zn();if(void 0===e||e.armed)return;e.armed=!0;const t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,Bn)&&Object.defineProperty(t,Bn,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,Bn,{value:e,writable:!0,configurable:!0,enumerable:!0});const t=zn();void 0===t||t.committed||null===this.querySelector(Mn)||function(e,t){const n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?In(e):n.hook("app:suspense:resolve",()=>{e.committed||In(e)})}(t,e)}})}function Wn(e){const t=e.hydration;if(void 0===t)return void e.startNow();const n=qn[t](e.root,n=>{e.later(()=>{Gn(e,t,n)})});null!==n?(e.defer(n),e.hydrated("waiting")):Gn(e,t,"committed")}var qn={react:(e,t)=>function(e,t=5e3){On();const n=En();if(void 0===n)return null;if(void 0===n.onCommit){const e=e=>{!n.committed&&function(e){const t=e;return null!=t&&function(e){const t=e;return 9===t?.nodeType||null!=t?.querySelector?.(Mn)}(t.containerInfo)&&!function(e){const t=[];for(null!==e.current&&void 0!==e.current&&t.push(e.current);t.length>0;){const e=t.pop();if(void 0===e)continue;const n=e.memoizedState;if((13===e.tag||31===e.tag)&&"object"==typeof n&&null!==n&&"dehydrated"in n&&"object"==typeof n.dehydrated&&null!==n.dehydrated&&"nodeType"in n.dehydrated&&8===n.dehydrated.nodeType)return!0;null!==e.sibling&&void 0!==e.sibling&&t.push(e.sibling),null!==e.child&&void 0!==e.child&&t.push(e.child)}return!1}(t)}(e)&&In(n)};n.onCommit=e;for(const t of n.commits.splice(0))e(t)}return _n(n,e,t)}(t),vue:function(e,t,n=5e3){Hn();const r=zn();return void 0===r?null:(!r.committed&&function(e){for(let t=e.querySelector(Mn);null!==t;t=t.parentElement)if(void 0!==jn(t))return!0;return!1}(e)&&In(r),_n(r,t,n))},sveltekit:function(e,t,n=5e3){const r=e.ownerDocument??e,i=()=>null!==r.querySelector("#svelte-announcer");if(i()||!Object.keys(window).some(e=>e.startsWith("__sveltekit_")))return null;const o={committed:!1,waiters:[]},s=new MutationObserver(()=>{!o.committed&&i()&&In(o)});s.observe(r,{childList:!0,subtree:!0});const a=_n(o,e=>{s.disconnect(),t(e)},n);return()=>{s.disconnect(),a?.()}},manual:function(e,t,n=5e3){const r=function(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewHydrated??={committed:!1,waiters:[]}}();return void 0===r?null:_n(r,t,n)}},Vn={react:"React commit",vue:"Vue mount",sveltekit:"SvelteKit mount",manual:"markHydrated() call"};function Gn(e,t,n){e.hydrated(n),"timed-out"===n&&e.warn(`[live-preview] LP0607: no ${Vn[t]} in ${String(5e3)} ms; started without waiting for hydration.`),e.startNow()}function Kn(e){return 9===e.nodeType}function Jn(e){return e.body}var Qn=class{timeoutMs;onTimeout;handle=null;lastKick=null;constructor(e){this.timeoutMs=e.timeoutMs??0,this.onTimeout=e.onTimeout}kick(){this.lastKick=Date.now(),this.timeoutMs<=0||(this.stop(),this.arm(this.timeoutMs))}resume(){if(this.timeoutMs<=0||null!==this.handle||null===this.lastKick)return!1;const e=Math.max(0,Date.now()-this.lastKick),t=this.timeoutMs-e;return t<=0?(this.lastKick=null,this.onTimeout(),!0):(this.arm(Math.min(t,this.timeoutMs)),!1)}arm(e){const t=setTimeout(()=>{this.handle===t&&(this.handle=null,this.lastKick=null,this.onTimeout())},e);this.handle=t}stop(){null!==this.handle&&(clearTimeout(this.handle),this.handle=null)}get lastKickAt(){return this.lastKick??0}get pending(){return null!==this.handle}},Xn=class{current="disconnected";get status(){return this.current}markConnected(){return this.transition("connected")}markDisconnected(){return this.transition("disconnected")}transition(e){return this.current!==e&&(this.current=e,!0)}},Zn=/* @__PURE__ */new Set(["true","false","yes","no","on","off"]),Yn=/^[\d\s.,:+/-]+$/u,er=/^[a-z][a-z0-9_-]*$/u,tr=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,nr=/* @__PURE__ */new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]);function rr(e,t=13){if("string"!=typeof e)return!1;const n=e.trim();return!(n.length<t||Yn.test(n)||Zn.has(n.toLowerCase())||er.test(n)||tr.test(n))}function ir(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function or(e,t,n=13){const r=/* @__PURE__ */new Map,i=(e,t,n)=>{r.set(e,r.has(e)?null:{field:t,media:n})};for(const[r,o]of Object.entries(e)){if($e.has(r))continue;const e=Fe(r,t);if(rr(o,n))i(o.trim(),e,!1);else if(ir(o))if("string"==typeof o.url)i(o.url,e,!0);else if(!("id"in o)&&!("_id"in o))for(const[t,r]of Object.entries(o))!$e.has(t)&&rr(r,n)&&i(r.trim(),`${e}.${t}`,!1)}return r}function sr(e){if("http://www.w3.org/1999/xhtml"!==e.namespaceURI||nr.has(e.tagName))return!0;if(e.hasAttribute(Tt)||e.hasAttribute("data-payload-no-bind")||e.hasAttribute(ht)||gt(e))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function ar(e){let t;for(let n=e.firstChild;null!==n;n=n.nextSibling){if(1===n.nodeType)return;if(3!==n.nodeType)continue;const e=n.data.trim();if(0!==e.length){if(void 0!==t)return;t=e}}return t}function lr(e){return K(e)&&!e.startsWith("data-payload-")&&"value"!==e}function dr(e,t,n){let r=e.byElement.get(t);void 0===r&&(r={attributes:/* @__PURE__ */new Map},e.byElement.set(t,r));let i=e.byField.get(n.field);return void 0===i&&(i=/* @__PURE__ */new Set,e.byField.set(n.field,i)),i.add(t),r}function ur(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(sr(n))continue;const e=ar(n),r=void 0===e?void 0:t.values.get(e);null==r||r.media||(dr(t,n,r).text=r.field);for(const e of n.getAttributeNames()){if(!lr(e))continue;const r=t.values.get(n.getAttribute(e)??"");null!=r&&(!r.media||"IMG"===n.tagName&&"src"===e)&&dr(t,n,r).attributes.set(e,r)}ur(n,t)}}function cr(e,t,n){const r=e.tagName;if(void 0!==t){const i={[Tt]:t};if("A"===r){const e=n.get("href");void 0===e?i[Ct]="text":e!==t&&(i[Lt]=e)}return{element:e,fieldName:t,matched:ar(e)??"",stamps:i}}if("IMG"===r){const t=n.get("src");if(void 0!==t){const r=n.get("alt");return{element:e,fieldName:t,matched:e.getAttribute("src")??"",attribute:"src",stamps:{[Tt]:t,...void 0!==r&&r!==t?{[Nt]:r}:{}}}}}const i=n.entries().next();if(i.done)return;const[o,s]=i.value;return{element:e,fieldName:s,matched:e.getAttribute(o)??"",attribute:o,stamps:{[Tt]:s,[Pt]:o}}}function hr(e,t){const n={values:t,byElement:/* @__PURE__ */new Map,byField:/* @__PURE__ */new Map};t.size>0&&!sr(e)&&ur(e,n);const r=e=>1===n.byField.get(e)?.size,i=[];for(const[e,t]of n.byElement){const n=void 0!==t.text&&r(t.text)?t.text:void 0,o=/* @__PURE__ */new Map;for(const[e,n]of t.attributes)r(n.field)&&o.set(e,n.field);const s=cr(e,n,o);void 0!==s&&i.push(s)}return i}function fr(e){return 9===e.nodeType?e.body:e}function pr(e,t){for(let n=t.length-1;n>=0;n-=1){const r=t[n];if(void 0!==r){r.observed&&e.observers.unobserveElement(r.element);for(let e=r.attributes.length-1;e>=0;e-=1){const t=r.attributes[e];if(void 0===t)continue;const{name:n,before:i,written:o}=t;i!==o&&r.element.getAttribute(n)===o&&(null===i?r.element.removeAttribute(n):r.element.setAttribute(n,i))}r.cacheTouched&&(r.element.hasAttribute(Tt)?e.cache.add(r.element):e.cache.remove(r.element))}}}function gr(e,t,n,r,i){const o=[],s=[],a=()=>(pr(e,s),[]);for(const l of t){if(!i())return a();const{element:t}=l;if(t.hasAttribute(Tt))continue;if(!i())return a();if(!1!==n&&!be(Jt(t),n))continue;if(!i())return a();const d={element:t,attributes:[],cacheTouched:!1,observed:!1};s.push(d);for(const[e,n]of[...Object.entries(l.stamps),[Ht,l.matched]]){const r=t.getAttribute(e);if(!i())return a();if(d.attributes.push({name:e,before:r,written:n}),t.setAttribute(e,n),!i())return a()}if(d.cacheTouched=!0,void 0!==e.cache.add(t)){if(!i())return a();if(e.observers.observeElement(t),d.observed=!0,!i())return a();if(e.log("autoBind",l.fieldName,"→",`<${t.tagName.toLowerCase()}>`,l.attribute??"text",JSON.stringify(l.matched),r),!i())return a();o.push(l)}else pr(e,[d]),s.pop()}return o}function mr(e,t,n,r,i){if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)return;const o=function(e,t){let n,r=e;for(const e of t.split(".")){if("object"!=typeof r||null===r)break;r=r[e];const t=/^\d+$/.test(e)?r?.id:null;"string"!=typeof t&&"number"!=typeof t||(n=`${n??""}/${String(t)}`)}return n}(r,n.fieldName);if(void 0===o)return;if(i)return void t.rowsOfBinding.delete(n.element);const s=t.rowsOfBinding.get(n.element);t.rowsOfBinding.set(n.element,o),void 0!==s&&s!==o&&X(e,t,n,"stands in a row that moved",o)}function vr(e,t,n,r){if(!e.scopeBindingsByOwner)return!1;const{message:i}=n,o=function(e){if(ye(e.globalSlug))return[(t=e.globalSlug,`global:${t}`)];var t;if(!ye(e.collectionSlug))return null;const n=ve(e.collectionSlug);return ye(e.documentId)?[n,ve(e.collectionSlug,e.documentId)]:[n]}({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:we(r)});return null!==o||t.warnedUnattributableMessage||(t.warnedUnattributableMessage=!0,e.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),o}var yr=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;awaitingHydration=/* @__PURE__ */new WeakSet;delivered=/* @__PURE__ */new WeakMap;confirmations=/* @__PURE__ */new WeakMap;reapplyBindings(e){const t=this.currentTransaction();void 0!==t?.renderData&&this.host.schedule(t,t.renderData,e)}reapplyIslands(e,t=!1){const n=t?e.filter(e=>this.awaitingHydration.delete(e)):e,r=this.state.activeUpdate,i=t&&null!==r&&this.state.isCurrent(r)?r:this.currentTransaction();void 0!==i?.renderData&&this.dispatchIslands(i,i.renderData,n)}dispatchIslands(e,t,n){const r=vr(this.deps,this.state,e,t.fields),i=()=>!e.cancelled&&this.state.isCurrent(e);if(!i())return;let o=this.delivered.get(t);void 0===o&&(o=/* @__PURE__ */new WeakSet,this.delivered.set(t,o));for(const s of n){const n=Jt(s);if(!i())return;if(!1!==r&&!be(n,r)){this.awaitingHydration.delete(s);continue}const a=this.confirmation(s,e);if(mt(s))this.awaitingHydration.add(s);else{if(this.awaitingHydration.delete(s),o.has(s))continue;o.add(s),br(e,t,[s],i,a)}}}hasLateRouteBinding(e,t,n,r){for(const r of e){if((r.getAttribute(Tt)??"").length>0||"route"!==r.getAttribute(zt))continue;if(!1!==t&&!be(Jt(r),t))continue;const e=st(r.getAttribute(Bt));if(0===e.length||e.some(e=>n.touched.has(e)))return!0}for(const[i,o]of this.deps.cache.entries())for(const s of o){if(!e.has(s.element))continue;if(!1!==t&&!be(s.owner,t))continue;if("route"!==(s.strategyKind??me(s.element)??"unknown"))continue;const o=ue(r.fields,s,i,n.locale);if(!this.state.isCurrent(n))return!1;if(void 0!==o)return!0}return!1}fieldsForElements(e,t){const n=new Set(t);for(const[t,r]of this.deps.cache.entries())r.some(t=>e.has(t.element))&&n.add(t);return n}unrunFragmentPlan(e,t,n){if(null===t)return null;const r=t.boundaries.filter(t=>!e.fragmentBoundariesRun.has(t)&&(void 0===n||[...n].some(e=>e===t||t.contains(e))));return ge(t.strategy,r,t.ownerKeys)}confirmation(e,t){const n=this.confirmations.get(e);if(n?.transaction===t)return n.displayed;const r=this.state.display.handIsland(t);return this.confirmations.set(e,{transaction:t,displayed:r}),r}currentTransaction(){const e=this.state.activeUpdate;return this.state.navigationBindingReplay&&null!==e&&this.state.isCurrent(e)?e:null}};function br(e,t,n,r,i){!function(e,t,n){let r=0;for(const i of e){if(!n())break;if(i.dispatchEvent(new CustomEvent(dt,{detail:t,bubbles:!1})),r+=1,!n())break}}(n,{fields:t.fields,revision:e.revision.revision,receivedAt:e.receivedAt,locale:e.locale,displayed:i},r)}var wr=" subfieldCoverage";function Sr(e,t,n,r,i){const{warned:o,warn:s}=e;if(o.has(n)||t(n))return;o.add(n);const a=`data-payload-field="${Fe(n,r)}"`;s(""!==i?`[live-preview] LP0203: field "${n}" has a value and no <… ${a}> on this page; editing it changes nothing here. Expected where the page shows part of the document: inspect().fidelity.fields lists these, onUnfaithfulPatch decides whether a server render is asked for.`:`[live-preview] LP0201: no <… ${a}> for the empty field "${n}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)}function Ar(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function kr(e){return Array.isArray(e.docs)&&"boolean"==typeof e.hasNextPage}function Rr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var Tr=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function Cr(e){const t=function(){const e=function(){const e=globalThis,t=e[Tr];if(void 0!==t)return t;const n={};return e[Tr]=n,n}();if(void 0!==e.override)return e.override;if(void 0!==e.auto)return e.auto;const t=function(){const e=globalThis.trustedTypes;if("object"==typeof e&&null!==e)return"function"==typeof e.createPolicy?e:void 0}();try{e.auto=void 0===t?null:t.createPolicy("payload-live-preview",{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===t?e:t.createHTML(e)}var Pr=/* @__PURE__ */new Set(["open","value","checked","selected"]);function Lr(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function $r(e,t,n){if(!Ur(e,t))return t;const r=n.boundary??ft,i=r(e),o=r(t);if(i||o)return i&&o&&(n.retainBoundary?.(e,t)??1)?e:t;const s=xr(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||Pr.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(const n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}(e,t),!0!==n.retainChildrenOf?.(e,t)&&function(e,t,n){const r=function(e,t){const n=/* @__PURE__ */new Map;let r;for(const i of Array.from(e.children)){const e=Lr(i,t);void 0!==e&&(n.has(e)?r??=e.slice(e.indexOf("=")+1):n.set(e,i))}return void 0!==r&&t.onDuplicateKey?.(e,r),n}(e,n),i=new Set(r.values()),o=Array.from(e.childNodes).filter(e=>!i.has(e)),s=/* @__PURE__ */new Set,a=/* @__PURE__ */new Set,l=Array.from(t.childNodes);let d=e.firstChild,u=0;for(let t=0;t<l.length;t+=1){const i=l[t];let c=null,h=i instanceof Element?Lr(i,n):void 0;if(void 0!==h&&a.has(h)&&(h=void 0),void 0!==h){a.add(h);const e=r.get(h);if(void 0!==e&&!s.has(e)&&(c=Nr(e,i,n)===e?e:null,null===c)){e.replaceWith(i),s.add(i),d=i.nextSibling;continue}}else{for(;u<o.length;){const r=o[u];if(u+=1,!s.has(r)){if(Ur(r,i)){c=Nr(r,i,n)===r?r:null,null===c&&(e.replaceChild(i,r),s.add(i),d=i.nextSibling);break}if(r instanceof Element){const n=l[t+1];if(!(i instanceof Element)||void 0!==n&&Ur(r,n)){u-=1;break}e.replaceChild(i,r),s.add(i),d=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,r),s.add(i),d=i.nextSibling;break}}}if(null===c&&s.has(i))continue}const f=c??i;for(s.add(f);null!==d&&d!==f&&!s.has(d)&&Fr(d);)d=d.nextSibling;f!==d&&e.insertBefore(f,d),d=f.nextSibling}for(const t of Array.from(e.childNodes))s.has(t)||t.remove()}(e,t,n),Mr(s),e}function Nr(e,t,n){return e instanceof Element&&t instanceof Element?$r(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function Fr(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function Ur(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function xr(e){const t=e.ownerDocument.activeElement;return t instanceof HTMLElement&&e.contains(t)?{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}:null}function Mr(e){if(null===e)return;const{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});const[e,r]=n??[null,null];null!==e&&null!==r&&t.setSelectionRange(e,r)}catch{}}function Er(e,t){if(!function(){try{const e=globalThis.process?.env;return void 0!==e&&"production"!==e.NODE_ENV}catch{return!1}}())return;const n=globalThis,r=n.__payloadLivePreviewDeprecationsWarned??=/* @__PURE__ */new Set;if(!r.has(e)){r.add(e);try{console.warn(`[payload-live-preview] ${t}`)}catch{}}}var Or=/* @__PURE__ */new Set;function Ir(e){Or.has(e)||(Or.add(e),function(e){try{console.warn(e)}catch{}}(`[live-preview] LP0409: the strict sanitizer removed \`${e}\` from written markup; the 1.x default (\`sanitizerPolicy: 'compat'\`) kept it. ${function(e){return e.startsWith("data-payload-")?"A binding inside CMS content is refused by design — an editor could otherwise aim a write at any element on the page (docs/security.md)":"id"===e||"name"===e?"CMS content that can name an element can shadow a global of that name — DOM clobbering, refused by design (docs/security.md)":"Put it on an element the template owns, or set `sanitizerPolicy: 'compat'` to keep every `data-*` as 1.x did"}(e)}.`))}var Dr=/* @__PURE__ */new Set(["p","br","strong","b","em","i","u","s","strike","mark","small","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","blockquote","code","pre","kbd","samp","var","a","span","div","section","article","aside","header","footer","nav","figure","figcaption","img","picture","source","audio","video","sub","sup","hr","time","abbr","cite","q","table","thead","tbody","tfoot","tr","th","td","caption","colgroup","col"]),_r=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),Br=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),zr=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),jr="aria-",Hr="data-",Wr={a:/* @__PURE__ */new Set(["href","target","rel","download","hreflang","type"]),img:/* @__PURE__ */new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:/* @__PURE__ */new Set([]),source:/* @__PURE__ */new Set(["src","srcset","sizes","type","media"]),audio:/* @__PURE__ */new Set(["src","controls","autoplay","loop","muted","preload"]),video:/* @__PURE__ */new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:/* @__PURE__ */new Set(["datetime"]),abbr:/* @__PURE__ */new Set(["title"]),q:/* @__PURE__ */new Set(["cite"]),blockquote:/* @__PURE__ */new Set(["cite"]),table:/* @__PURE__ */new Set(["summary"]),th:/* @__PURE__ */new Set(["colspan","rowspan","scope","headers","abbr"]),td:/* @__PURE__ */new Set(["colspan","rowspan","headers"]),col:/* @__PURE__ */new Set(["span"]),colgroup:/* @__PURE__ */new Set(["span"]),ol:/* @__PURE__ */new Set(["start","reversed","type"]),li:/* @__PURE__ */new Set(["value"]),code:/* @__PURE__ */new Set(["class"]),pre:/* @__PURE__ */new Set(["class"])},qr=/* @__PURE__ */new Set(["href","src","cite","poster","action","formaction"]),Vr=class extends Error{name="SanitizerEnvironmentError"},Gr=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-morph","data-payload-nested-key","data-payload-nested-template"]),Kr=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function setSanitizerDocument(e){Er("set-sanitizer-document","`setSanitizerDocument()` is removed in 3.0: pass the document per call, `sanitizeHtml(html, { document })` or `lexicalToHtml(content, { document })` (ADR 0026)."),globalThis[Kr]=e??void 0}function sanitizeHtml(e,t){return Jr(e,void 0,t)}function Jr(e,t,n){const r=n?.document??Zr();if(!r)throw Qr();if(""===e)return"";const i=function(e,t){const n=e?.policy??t??"strict";if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(Wr))e.set(t,n);return{allowedTags:Dr,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const r=new Set(Dr);if(e.additionalAllowedTags?.forEach(e=>r.add(e)),!0===e.allowFormControls)for(const e of _r)r.add(e);const i=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(Wr))i.set(e,t);for(const[t,n]of Object.entries(e.additionalAllowedAttributes??{})){const e=new Set(i.get(t));for(const t of n)e.add(t);i.set(t,e)}return{allowedTags:r,attrByTag:i,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(n,t);let o=e;for(let e=0;e<6;e+=1){const e=r.createElement("template");e.innerHTML=Cr(o);const t=e.content;Yr(t,i);const n=Xr(t);if(n===o)return n;o=n}return Er("sanitizer-unsettled",`sanitizeHtml: the output did not settle after ${String(6)} passes, so it returned an empty string (ADR 0016).`),""}function Qr(){return"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new Vr("sanitizeHtml needs a DOM; pass one per call during SSR: { document } (linkedom, jsdom).")}function Xr(e){const t=e.ownerDocument?.createElement("div");if(void 0===t)throw Qr();const n=e.firstChild;if(t.append(e),t.firstChild!==n)throw Qr();return t.innerHTML}function Zr(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[Kr];if(e)return e}if("undefined"!=typeof document)return document}function Yr(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?ei(n,t):8===n.nodeType&&n.remove()}function ei(e,t){const n=e.tagName.toLowerCase();if(!Br.has(n)||t.allowFormControls&&_r.has(n)){if(!t.allowedTags.has(n))return Yr(e,t),void e.replaceWith(...e.childNodes);!function(e,t,n){const r=n.attrByTag.get(t);for(const t of Array.from(e.attributes)){const i=t.name.toLowerCase();if(i.startsWith("on")||"style"===i)e.removeAttribute(t.name);else if("is"!==i){if("strict"===n.mode){if(n.templateMode&&Gr.has(i))continue;if("id"===i||"name"===i||i.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===i&&!0!==r?.has(i)||Ir(i);continue}if(i.startsWith(Hr)){n.allowedData.has(i)||(e.removeAttribute(t.name),Ir(i));continue}if(zr.has(i)||i.startsWith(jr))continue}else if(zr.has(i)||i.startsWith(jr)||i.startsWith(Hr))continue;r?.has(i)?qr.has(i)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):("srcset"!==i||ti(t.value))&&("ping"!==i||t.value.trim().split(/\s+/u).every(isSafeUrl))||e.removeAttribute(t.name):e.removeAttribute(t.name)}else e.setAttribute("is","")}}(e,n,t),"a"===n&&function(e){const t=e.getAttribute("href");null!==t&&isExternalHttpUrl(t)&&(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),Yr(e,t)}else e.remove()}function ti(e){for(const t of e.split(",")){const e=t.trim();if(0===e.length)continue;const[n=e]=e.split(/\s/,1);if(!isSafeUrl(n)||!isSafeUrl(e))return!1}return!0}var ni=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="}),ri=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(ri,e=>ni[e])}var ii=Object.freeze({"&":"&","<":"<",">":">",'"':""","'":"'"}),oi=/[&<>"']/g;function escapeHtmlAttribute(e){return e.replace(oi,e=>ii[e])}var si=/\{\{([\s\S]*?)\}\}/g;function ai(e){const t=/* @__PURE__ */new Set;for(const n of e)if("object"==typeof n&&null!==n)for(const e of Object.keys(n))t.add(e);return t}function li(e,t,n,r,i){const o="object"==typeof t&&null!==t?t:null;return e.replace(si,(e,s)=>null!==o&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(o,s)?escapeHtml(r(Reflect.get(o,s))):null===o&&"value"===s?escapeHtml(r(t)):"index"===s?String(n):null!==o&&!0===i?.has(s)?"":e)}function di(e){const t=e.children,n=t[0];if(void 0===n)return[];const r=[];for(const{name:e,value:i}of Array.from(n.attributes)){if(!K(e)||e.startsWith("data-payload-"))continue;let n=!0;for(let r=1;r<t.length&&n;r+=1)n=t[r]?.getAttribute(e)===i;n&&r.push([e,i])}return r}function ui(e,t){for(const[n,r]of t)e.hasAttribute(n)||e.setAttribute(n,r)}function ci(e){if(null==e)return"";if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)return String(e);try{return JSON.stringify(e)}catch{return""}}function hi(e){return null==e||""===e}function fi(e,t){const n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function pi(e,t,n,r){return e.set(t,n),function(e,t){for(const n of e.keys()){if(e.size<=t)break;e.delete(n)}}(e,r),n}var gi=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],mi=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],vi=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,yi=/* @__PURE__ */new Map;function bi(e){const t=fi(yi,e);if(void 0!==t)return t;const n=new Set(gi);for(const t of e.matchAll(vi)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const r={};for(const e of n)r[e]=mi;const i={additionalAllowedTags:[...n],additionalAllowedAttributes:r,allowFormControls:!0,templateMode:!0};return pi(yi,e,i,64)}var wi="data-payload-key",Si="data-payload-nested-key",Ai="data-payload-nested-template";function ki(e){const t=Ti(e.container,e.patches,e);return null===t?null:Ci(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function Ri(e,t){return t.hasAttribute(Si)&&t.hasAttribute(Ai)}function Ti(e,t,n){const r=function(e,t,n){const{template:r,nextItems:i,forceRender:o=!1,store:s,sanitizerPolicy:a}=n,l=s.get(e),d=di(e),u=ai(i),c=Array.from(e.children),h=xi(c,wi),f=/* @__PURE__ */new Set,p=[];for(let s=0;s<i.length;s+=1){const g=i[s],m=Ui(g);let v=void 0===m?c[s]??null:Mi(h,m)??null;null!==v&&f.has(v)&&(v=null),null!==v&&f.add(v);const y=t.replaces.has(s),b=o||t.renders.has(s)||null===v?Ei(e.ownerDocument,r,g,s,a,d,u):void 0;if(null===b)return null;const w=void 0===b?[]:Pi(y?null:v,b,g,void 0===m?void 0:l?.get(m),n);if(null===w)return null;p.push([s,v,b,w,y])}return p}(e,function(e){const t=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set;for(const r of e)"insert"===r.kind||"update"===r.kind?t.add(r.index):"replace"===r.kind&&(t.add(r.index),n.add(r.index));return{renders:t,replaces:n}}(t),n);return null===r?null:[e,r,n.nextItems]}function Ci(e,t,n){const[r,i,o]=e,s=/* @__PURE__ */new Set;let a=!1;const l=xr(r);for(const[e,o,l,d,u]of i){let i=o;if(void 0!==l){const e=!(!n.morph||u||null===o)&&$r(o,l,{keyAttributes:[wi,Si],boundary:ft,retainBoundary:At,retainChildrenOf:Ri,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===o;if(!e)for(const[e,t]of d)null!==e&&($i(e,t),t.replaceWith(e));for(const[,,e]of d)void 0!==e&&Ci(e,t,n);e?a=!0:(null!==o&&(o.replaceWith(l),a=!0),i=l)}if(null===i)continue;const c=r.children[e]??null;i!==c&&(r.insertBefore(i,c),a=!0),s.add(i)}for(const e of Array.from(r.children))s.has(e)||(e.remove(),a=!0);Mr(l);const d=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(r,t);d.clear();for(const e of o)Fi(d,e);return a}function Pi(e,t,n,r,i){const o=xi(null===e?[]:Li(e),Si),s=[];for(const e of Li(t)){const t=e.getAttribute(Si);if(null===t)continue;const a=Mi(o,t)??null,l=e.getAttribute(Ai),d=l?a:null,u=d?.getAttribute(Ai)??null;let c;if(l){const o=Ni(n,t);if(void 0!==o||null!==d){const n=o??[],s=I(null===d?[]:Ni(r,t)??[],n),a=null!==d&&u!==l;if((s.length>0||a)&&(c=Ti(d??e,s,{template:l,nextItems:n,forceRender:a,store:i.store,sanitizerPolicy:i.sanitizerPolicy})??void 0,void 0===c))return null}}s.push([d,e,c])}return s}function Li(e){return Array.from(e.querySelectorAll(`[${Si}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(Si))return!1;n=n.parentElement}return n===e})}function $i(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||e.removeAttribute(n.name);for(const n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function Ni(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function Fi(e,t){const n=Ui(t);void 0!==n&&e.set(n,t)}function Ui(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function xi(e,t){const n=/* @__PURE__ */new Map;for(let r=e.length-1;r>=0;r-=1){const i=e[r];if(void 0===i)continue;const o=i.getAttribute(t);if(null===o)continue;const s=n.get(o);void 0===s?n.set(o,[i]):s.push(i)}return n}function Mi(e,t){return e.get(t)?.pop()}function Ei(e,t,n,r,i,o,s){const a=Jr(li(t,n,r,ci,s),i,bi(t)),l=e.createElement("template");l.innerHTML=Cr(a);const d=l.content.firstElementChild;if(!d)return null;ui(d,o);const u=Ui(n);return void 0!==u&&d.setAttribute(wi,u),d}function Oi(e,t,n){t.warnedFragmentFallback||(t.warnedFragmentFallback=!0,e.warn(`[live-preview] LP0806: "${n.fieldName}" asks for the fragment strategy but no handler is configured; patching instead`))}function Ii(e,t,n){t.warnedStrategy.has(n.element)||(t.warnedStrategy.add(n.element),e.warn(`[live-preview] LP0407: "${n.fieldName}" asks for strategy "${String(n.strategy)}"; only patch, fragment and route exist`))}function Di(e,t,n){if(t.warnedEscalationUnavailable)return;t.warnedEscalationUnavailable=!0;const r=`[live-preview] LP0808: onUnfaithfulPatch: 'escalate' has nowhere to go: ${String(n)} field(s) fell short`,i="or onUnfaithfulPatch: 'warn' to keep the patch and say so.";e.warn(void 0===e.strategies.fragment?`${r} and no route or fragment strategy is configured. Set routeStrategy: true or fragments: { endpoint }, ${i}`:`${r}, not all of them inside a data-payload-fragment boundary of this document, and no route strategy is configured. Cover them with a boundary or add the route strategy, ${i}`)}var _i=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;planFragments(e,t){const{deps:n,state:r}=this,i=n.strategies.fragment;if(void 0===i)return null;const o=new Set(i.plan(n.root,e));for(const e of r.fragmentsOwed)n.root.contains(e)?o.add(e):r.fragmentsOwed.delete(e);return ge(i,[...o].filter(e=>Bi(e,t)),t)}escalateUnfaithful(e,t,n,r){if(e.routeRefreshed)return void this.kept(e,n);const{fragment:i,route:o}=this.deps.strategies,s=void 0===i?void 0:function(e){const t=[];for(const n of e){const e=n.fragmentBoundary;if(void 0===e)return;t.includes(e)||t.push(e)}return t}(n),a=void 0===s||s.every(e=>Bi(e,r))?s:void 0;return void 0!==i&&void 0!==a?(this.state.escalatedCount+=n.length,e.pendingFragments+=a.length,void this.runFragments(e,t,ge(i,a,r))):void 0===o?(Di(this.deps,this.state,n.length),void this.kept(e,n)):(this.state.escalatedCount+=n.length,void this.refreshRoute(e,t,o))}kept(e,t){for(const n of t)this.state.display.shortfall(e,{kind:"unfaithful",field:n.fieldName})}hasUnboundChange(e,t){const{deps:n,state:r}=this;if(e.baseline||e.routeRefreshed)return!1;const i=Ee(n.cache,e.touched,e.locale,t,this.subfields(e),n.strategies);let o=0;for(const e of i)Z(r,e)&&(o+=1);const[s]=i;if(void 0===s)return!1;if("escalate"!==n.onUnfaithfulPatch||void 0===n.strategies.route){"escalate"===n.onUnfaithfulPatch&&Di(n,r,i.length);for(const t of i)r.display.shortfall(e,{kind:"unbound",field:t});return!1}return e.navigated?(r.routeAwaitsSave=!0,r.display.shortfall(e,{kind:"route-saved"}),!1):(n.log("route","LP0807",`field "${s}" has no binding; refreshing the route`),r.escalatedCount+=o,!0)}subfields(e){const{previousFields:t}=this.state.changes;return Me(this.deps.subfieldCoverage,t,e.renderData?.fields)}plansRoute(e,t,n){const r=e=>!1===n||be(e,n),i=function(e,t,n){const r=e.rendered.flatMap(e=>"route"===e.strategy?e.paths:[]);for(const[t,n]of e.entries())n.some(e=>"route"===e.strategyKind)&&r.push(t);const i=new Set(t);for(const e of r){const[r=e]=e.split(".");t.has(r)&&(void 0===n||Pe(e,n.previous,n.next))&&i.add(e)}return i}(this.deps.cache,t.touched,this.subfields(t));if(e.plan(this.deps.root,i,{inScope:e=>r(Jt(e))}))return!0;for(const[e,t]of this.deps.cache.entries())if(i.has(e)&&t.some(e=>"route"===e.strategyKind&&r(e.owner)))return!0;return!1}async runFragments(e,t,n){const{deps:r,state:i}=this,o=new AbortController,s=new Set(n.boundaries);for(const e of s)i.fragmentsOwed.delete(e);i.fragmentControllers.set(o,s);const a=t=>{s.delete(t)&&(e.pendingFragments-=1)},l=()=>i.isCurrent(e)&&!o.signal.aborted,d=e=>function(e,t,n){if(t.isConnected)return t;const r=t.getAttribute(he),i=t.getAttribute(fe);let o;for(const t of e.querySelectorAll(`[${he}]`))if(t.getAttribute(he)===r&&t.getAttribute(fe)===i&&n(t)){if(void 0!==o)return;o=t}return o}(r.root,e,e=>Bi(e,n.ownerKeys)),{emitter:u}=r,{message:c}=e,h=e.revision.revision,f=e.receivedAt,p={root:r.root,revision:h,receivedAt:f,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof c.collectionSlug?c.collectionSlug:void 0,globalSlug:"string"==typeof c.globalSlug?c.globalSlug:void 0,signal:o.signal,isCurrent:l,log:(e,t)=>{r.log("fragment",e,t)},morph:(e,t)=>{const n=l()?d(e):void 0;void 0!==n&&function(e,t,n){const r=e.ownerDocument.createElement("template");r.innerHTML=Cr(t);const i=e.cloneNode(!1);i.append(r.content);const o=kt(e);$r(e,i,{keyAttributes:[wi],boundary:ft,retainBoundary:At}),function(e){for(const t of e)t.isConnected||bt.has(t)||(bt.add(t),t.dispatchEvent(new CustomEvent("astro:unmount")))}(o);const s=new Set(o);for(const t of kt(e)){const e=s.has(t)?void 0:Rt(t);void 0!==e&&n(t,e)}}(n,t,(e,t)=>{!function(e,t,n,r){if(t.warnedIslandStart)return;t.warnedIslandStart=!0;const i="element"===r?"<astro-island>":`client:${n.getAttribute("client")??""}`;e.warn(`[live-preview] LP0809: a fragment island cannot start: this page never loaded ${i}; render one on the page`)}(this.deps,this.state,e,t)})},patch:r=>{const i=d(r);void 0!==i&&(i!==r&&this.host.rebuildCache(),this.patchFallback(e,t,i,n.ownerKeys,l))},rendered:(e,t,n)=>{a(e);const r=d(e)??e;u.emitWhile("fragmentRender",{element:r,id:t,key:n,status:"rendered",revision:h,receivedAt:f},l)},failed:(t,n,o,s,c)=>{a(t);const p=d(t)??t;i.display.shortfall(e,{kind:"fragment",id:n,key:o,code:s});const g=`fragment "${n}" fell back to patch: ${c}`;r.log("fragment",s,g),u.emitWhile("error",{error:new Error(g),context:"fragment",code:s},l),u.emitWhile("fragmentRender",{element:p,id:n,key:o,status:"failed",code:s,revision:h,receivedAt:f},l)}};let g={rendered:0,failed:0,superseded:0};try{g=await n.strategy.render(p,n.boundaries)}catch(t){if(r.log("fragment","LP0801",t),l()){for(const t of n.boundaries)p.patch(t),i.display.shortfall(e,tt(t));g={rendered:0,failed:n.boundaries.length,superseded:0}}}i.fragmentStats.rendered+=g.rendered,i.fragmentStats.failed+=g.failed,i.fragmentStats.superseded+=g.superseded,i.fragmentControllers.delete(o);for(const e of s)a(e);l()&&(g.rendered>0&&this.host.restoreGuesses(e,t),0===e.pendingFragments&&0===r.scheduler.pendingCount&&i.complete(e),this.host.revealPending(e),l()&&0!==g.rendered&&0!==u.listenerCount("afterUpdate")&&u.emitWhile("afterUpdate",{data:t,updatedCount:g.rendered,durationMs:Date.now()-f,revision:h,receivedAt:f,source:"fragment"},l))}async refreshRoute(e,t,n){const{deps:r,state:i}=this;if(e.routeRefreshed)return i.routeStats.loopStopped+=1,void r.log("route","LP0805",`revision ${String(e.revision.revision)} asked for a second refresh`);e.routeRefreshed=!0,await this.runRoute(e,t,n,!1).catch(e=>{this.routeFailed(e)})}refreshAfterSave(){const{deps:e,state:t}=this,{route:n}=e.strategies,r=t.activeUpdate;t.routeAwaitsSave&&void 0!==n&&void 0!==r?.renderData&&(e.log("route","document saved; refreshing the route"),this.runRoute(r,r.renderData,n,!0).catch(e=>{this.routeFailed(e)}))}routeFailed(e){this.deps.log("route refresh failed:",e)}armRouteRetry(e,t,n,r,i){const{state:o}=this;null!==o.routeRetry&&clearTimeout(o.routeRetry),o.routeRetry=setTimeout(()=>{o.routeRetry=null,o.isCurrent(e)&&this.runRoute(e,t,n,i).catch(e=>{this.routeFailed(e)})},r)}async runRoute(e,t,n,r){const{deps:i,state:o}=this;if(i.routeAfterSave&&!r)return o.routeAwaitsSave=!0,void o.display.shortfall(e,{kind:"route-saved"});const s=o.routeStats,a=new AbortController;o.routeController?.abort(),o.routeController=a;const l=()=>!a.signal.aborted;let d;try{d=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:a.signal,isCurrent:l,log:(e,t)=>{i.log("route",e,t)},retryAfter:i=>{this.armRouteRetry(e,t,n,i,r)}})}catch(e){i.log("route","LP0801",e),d="failed"}if(!l())return;o.routeController=null;const u=o.activeUpdate;if(null===u)return;const c=u.renderData,h=()=>o.isCurrent(u);if("partial"===d?o.display.shortfall(u,{kind:"route-saved"}):("failed"===d||"superseded"===d||"refused"===d&&null===o.routeRetry)&&o.display.shortfall(u,{kind:"route-failed",outcome:d}),"refreshed"===d||"partial"===d){if(s.refreshes+=1,"partial"===d&&(s.partial+=1),o.routeAwaitsSave="partial"===d&&!r,o.lastAppliedIdentity=/* @__PURE__ */new WeakMap,void 0!==c&&this.host.restoreGuesses(u,c),this.host.rebuildCache(),void 0===c||!h())return;return this.host.reapply(u,c),void(i.emitter.listenerCount("afterUpdate")>0&&i.emitter.emitWhile("afterUpdate",{data:c,updatedCount:i.cache.elementCount,durationMs:Date.now()-u.receivedAt,revision:u.revision.revision,receivedAt:u.receivedAt,source:"route"},h))}"failed"===d?s.failed+=1:"refused"===d&&(s.refused+=1),void 0!==c&&this.host.reapply(u,c)}warnFragmentFallback(e){Oi(this.deps,this.state,e)}warnUnsupportedStrategy(e){Ii(this.deps,this.state,e)}patchFallback(e,t,n,r,i){if(i())for(const[o,s]of this.deps.cache.entries())for(const a of s){if(a.fragmentBoundary!==n)continue;if(!1!==r&&!be(a.owner,r))continue;const s=ue(t.fields,a,o,e.locale);void 0!==s&&i()&&this.deps.scheduler.schedule({target:a,value:this.host.transform(a,s,t.fields,i),allFields:t.fields,revision:e.revision,data:t})}}};function Bi(e,t){return!1===t||be(Jt(e),t)}function zi(e,t,n,r,i){const o=e.transformValue;if(void 0===o)return n;try{const e=o(t.fieldName,n,{element:t.element,allFields:r},i),s=y(e);if(!i())return n;if(s)throw new TypeError(`Transform for "${t.fieldName}" returned a thenable; transforms must be synchronous`);return e}catch(t){if(!i())return n;const r=t instanceof Error?t:new Error(String(t));return e.emitter.emit("error",{error:r,context:"transform",code:"LP0602"}),n}}var ji=/* @__PURE__ */new Set,Hi={kind:"merge"},Wi=class{constructor(e,t,n){this.deps=e,this.state=t,t.changes.keepValues="declared"===e.subfieldCoverage,t.display.host=function(e,t){return{outstanding:n=>!n.completed||n.pendingFragments>0||null!==t.routeController||null!==t.routeRetry||e.scheduler.pendingCount>0,report:t=>{"partial"===t.state&&e.a11y?.announcePartial(),e.emitter.emit("revisionDisplay",t)},failed:t=>{e.log("revision display failed:",t)}}}(e,t),this.strategies="undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e,t){return{planFragments:()=>null,escalateUnfaithful:(e,n,r)=>{for(const{fieldName:n}of r)t.display.shortfall(e,{kind:"unfaithful",field:n})},hasUnboundChange:(n,r)=>{if(n.baseline)return!1;const i=Ee(e.cache,n.touched,n.locale,r,Me(e.subfieldCoverage,t.changes.previousFields,n.renderData?.fields));for(const e of i)Z(t,e),t.display.shortfall(n,{kind:"unbound",field:e});return!1},plansRoute:()=>!1,runFragments:()=>Promise.resolve(),refreshRoute:()=>(L("route refreshes"),Promise.resolve()),refreshAfterSave:()=>{},warnFragmentFallback:n=>{L("server-rendered fragments"),Oi(e,t,n)},warnUnsupportedStrategy:n=>{Ii(e,t,n)}}}(e,t):new _i(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,r,i)=>zi(e,t,n,r,i),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}}),this.navigationReplay=new yr(e,t,{schedule:(e,t,n)=>{this.scheduleAllFields(e,t,n)}})}deps;state;strategies;navigationReplay;handleUpdate(e,t,n){const{deps:r,state:i}=this;r.heartbeat.kick(),i.protocol.observe(function(e){const t=[];return Array.isArray(e.fieldSchemaJSON)&&t.push("schema-json"),"string"==typeof e.locale&&t.push("locale"),"string"==typeof e.previewToken&&t.push("preview-token"),"object"==typeof e.externallyUpdatedRelationship&&null!==e.externallyUpdatedRelationship&&t.push("relationship-events"),t}(e),r.log,r.warn);const o=e.data;void 0!==o?void 0!==n&&this.acceptDataUpdate(e,o,t,n,!0):void 0!==e.protocolVersion&&i.protocol.applyVersion(e.protocolVersion,r.log)}handleReplay(e,t,n){const r=e.data;void 0!==r&&this.acceptDataUpdate(e,r,t,n,!1)}reapplyNavigationBindings(e){this.navigationReplay.reapplyBindings(e)}reapplyNavigationIslands(e,t=!1){this.navigationReplay.reapplyIslands(e,t)}acceptDataUpdate(e,t,n,r,i){const{deps:o,state:s}=this,a=i?s.relationships.inspect(e):null,l="string"==typeof e.locale?e.locale:s.locale;let d=s.schema,u=s.schemaIndex;Array.isArray(e.fieldSchemaJSON)&&(d=e.fieldSchemaJSON,u=function(e,t=""){const n=/* @__PURE__ */new Map;return x(e,t,n,!1),x(e,t,n,!0),n}(e.fieldSchemaJSON));const c=s.activeUpdate;if(!s.isRunning()||null!==c&&c.revision.revision>r.revision)return;const h=null===a?null:s.relationships.commit(a),f=c,p={revision:r,message:e,rawData:t,locale:l,schema:d,schemaIndex:u,receivedAt:Date.now(),forceRender:null!==h||Ge(f),countsAsUpdate:i,renderData:void 0,fragmentBoundariesRun:/* @__PURE__ */new WeakSet,touched:/* @__PURE__ */new Set,baseline:!1,navigated:!1,invalidated:/* @__PURE__ */new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1};if(s.locale=l,s.schema=d,s.schemaIndex=u,null!==f&&!f.completed&&f.countsAsUpdate&&(s.supersededCount+=1),s.activeUpdate=p,i&&(s.updateCount+=1),s.display.begin(p,r.revision),s.isCurrent(p)&&(o.scheduler.acceptRevision(r),s.isCurrent(p)&&(s.supersedeStrategies(),s.isCurrent(p)&&(null===h||(o.emitter.emitWhile("relationshipUpdate",{detail:h,timestamp:Date.now()},()=>s.isCurrent(p)),s.isCurrent(p)))&&(!i||void 0===e.protocolVersion||(s.protocol.applyVersion(e.protocolVersion,o.log),s.isCurrent(p)))))){if(i&&o.connection.markConnected()){if(o.a11y?.announceConnected(),o.emitter.emit("connect",{origin:n,timestamp:Date.now()}),!s.isCurrent(p))return;if(o.log("connection","disconnected","→","connected"),!s.isCurrent(p))return}this.processUpdate(p).catch(e=>{o.log("update failed:",e)})}}async processUpdate(e){const{deps:t,state:n}=this,r=await this.resolveIncomingFields(e);if(null===r||!n.isCurrent(e))return;const i=this.dataFor(e,r);t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:i,revision:e.revision.revision,receivedAt:e.receivedAt,source:"patch",cancel:()=>{e.cancelled=!0,t.scheduler.cancelRevision(e.revision)}},()=>!e.cancelled&&n.isCurrent(e))||e.cancelled||!n.isCurrent(e))||this.applyFields(e,i,!1)}dataFor(e,t){const{message:n}=e;return{fields:t,...void 0!==e.schema?{schema:e.schema}:{},..."string"==typeof n.globalSlug?{globalSlug:n.globalSlug}:{},..."string"==typeof n.collectionSlug?{collectionSlug:n.collectionSlug}:{},...void 0!==e.locale?{locale:e.locale}:{}}}applyFields(e,t,n){const{deps:r,state:i}=this;if(!i.isCurrent(e))return;if(i.changes.isBaseline&&!n&&"off"!==r.autoBind){if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)L("auto-binding");else{const n=vr(r,i,e,t.fields);!function(e,t,n,r,i,o){if(!o())return 0;const s=performance.now(),a=fr(e.root),l=or(n,r);if(!o())return 0;const d=null===a?[]:hr(a,l);if(!o())return 0;const u=gr(e,d,i,"on the first message",o);if(!o())return 0;const c=function(e,t){const n=/* @__PURE__ */new Set;for(const{fieldName:e,stamps:r}of t){n.add(e);for(const e of[Lt,Nt]){const t=r[e];void 0!==t&&n.add(t)}}const r=/* @__PURE__ */new Map;for(const[t,i]of e)null!==i&&n.has(i.field)&&r.set(t,i);return{fields:n,values:r}}(l,u),h=performance.now()-s;o()&&(t.autoBindGuesses=c,t.autoBindSearchMs=h,u.length)}(r,i,t.fields,e.locale,n,()=>i.isCurrent(e))}if(!i.isCurrent(e))return}const o=at(r.dependencies,r.cache.dependencyMap());if(!i.isCurrent(e))return;const s=i.changes.diff(t.fields,o,()=>i.isCurrent(e));if(null===s)return;const a=!n&&i.navigationReplayPending;a&&(i.navigationReplayPending=!1,i.navigationBindingReplay=!0),e.baseline=s.baseline&&!a,e.navigated=a,e.invalidated=n?ji:s.invalidated,e.touched=n?ji:/* @__PURE__ */new Set([...s.changed,...s.invalidated]),e.renderData=t,this.scheduleAllFields(e,t)}async resolveIncomingFields(e){const{deps:t,state:n}=this,r=e.rawData;if(null===t.merger)return r;const i=n.merges.decide(t,e);if(!i.merge)return i.fields;const{message:o}=e,s=n.merges.request(t.merger,t.mergeWindowMs,{collectionSlug:o.collectionSlug,globalSlug:o.globalSlug,data:r,...void 0===e.schema?{}:{schema:e.schema},locale:e.locale});if(!s.leading)return this.applyMerged(e,s.result).catch(e=>{t.log("update failed:",e)}),i.fields;const a=await s.result;return n.isCurrent(e)?"merged"===a.status?(n.merges.recordMerged(a.doc,e.locale),a.doc):"superseded"===a.status?null:(n.display.shortfall(e,Hi),i.fields):null}async applyMerged(e,t){const{state:n}=this,r=await t;"unavailable"===r.status&&n.display.shortfall(e,Hi),"merged"===r.status&&n.isCurrent(e)&&(n.merges.recordMerged(r.doc,e.locale),this.applyFields(e,this.dataFor(e,r.doc),!0))}scheduleAllFields(e,t,n){const{deps:r,state:i}=this;if(!i.isCurrent(e))return;const o=void 0!==n,s=()=>i.isCurrent(e),a=vr(r,i,e,t.fields);if(!s())return;const{touched:l}=e,d=r.strategies.route;if(o&&void 0!==d&&!e.routeRefreshed&&this.navigationReplay.hasLateRouteBinding(n,a,e,t))return void(s()&&this.strategies.refreshRoute(e,t,d));const u=!o&&this.strategies.hasUnboundChange(e,a),c=i.routeRefreshOwed;if(!o&&void 0!==d&&!e.routeRefreshed&&(u||c||this.strategies.plansRoute(d,e,a))&&s())return i.routeRefreshOwed=!1,void this.strategies.refreshRoute(e,t,d);const h=o?this.navigationReplay.fieldsForElements(n,l):l,f=this.navigationReplay.unrunFragmentPlan(e,this.strategies.planFragments(h,a),n);if(!s())return;const p=r.skipUnchanged;let g=0;for(const[l,d]of r.cache.entries()){if(!s())return;for(const u of d){if(void 0!==n&&!n.has(u.element))continue;if(!1!==a&&!be(u.owner,a))continue;if(!0===f?.covers(u)){if(r.revealEditedField){const n=ue(t.fields,u,l,e.locale);i.revealLedger.note(e,u,n)}continue}const d=u.strategyKind??me(u.element)??"unknown";if("unknown"===d){this.strategies.warnUnsupportedStrategy(u);continue}"fragment"===d&&null===f&&this.strategies.warnFragmentFallback(u);const c=ue(t.fields,u,l,e.locale);if(void 0===c){i.absentFields.add(l);continue}if(mr(r,i,u,t.fields,e.navigated),!o&&r.revealEditedField&&i.revealLedger.note(e,u,c),!s())return;const h=zi(r,u,c,t.fields,s);if(!s())return;const m=p?ce(u,h,t.fields,e.locale):void 0,v=i.lastAppliedIdentity.get(u.element);if(!e.forceRender&&r.skipUnchanged&&void 0!==m&&v===m&&!e.invalidated.has(l)){i.skippedUnchangedCount+=1;continue}const y={target:u,value:h,allFields:t.fields,revision:e.revision,...o?{}:{data:t},valueIdentity:m};r.scheduler.schedule(y),g+=1}}if(o||function(e,t,n,r,i){const{cache:o,strategies:s}=e,a={warned:t,warn:e.warn};if(0===o.fieldCount)return;if(!1!==i&&!function(e,t){for(const n of e.values())if(be(n.owner,t))return!0;return!1}(o,i))return;const l=function(e,t,n,r){const i=Ue(e,t,n,Ne(e,n,r));return e=>"none"!==i(e)}(o,r,i,s);for(const[e,t]of Object.entries(n)){if($e.has(e))continue;if(Ar(t)){Sr(a,l,e,r,t);continue}if(!Rr(t)||l(e)||kr(t))continue;const n=Fe(e,r);for(const[e,i]of Object.entries(t))Ar(i)&&!$e.has(e)&&Sr(a,l,`${n}.${e}`,r,i)}if("declared"!==e.subfieldCoverage)return void function(e,t,n,r,i){if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)return;if(!e.coverageByDefault||t.has(wr)||!isDevMode())return;t.add(wr);const[o]=xe(e.cache,n,r,i,e.strategies);void 0!==o&&e.warn(`[live-preview] LP0204: no binding names "${o.path}", and a binding elsewhere in its group covers it, so an edit there changes nothing on the page. 3.0 makes subfieldCoverage: 'declared' the default, where it refreshes the route. Set the option to choose now.`)}(e,t,n,r,i);const d=xe(o,n,r,i,s);for(const{path:e,value:t}of d)if(Ar(t)&&Sr(a,l,e,r,t),Rr(t)&&!kr(t))for(const[n,i]of Object.entries(t))Ar(i)&&Sr(a,l,`${e}.${n}`,r,i)}(r,i.warnedOrphanFields,e.rawData,e.locale,a),s()){if(null!==f&&f.boundaries.length>0){for(const t of f.boundaries)e.fragmentBoundariesRun.add(t);e.pendingFragments+=f.boundaries.length,this.strategies.runFragments(e,t,f)}!o&&s()&&0===g&&(0===e.pendingFragments&&0===r.scheduler.pendingCount&&(i.complete(e),this.revealPending(e)),this.notifyIslands(e,t))}}notifyIslands(e,t){0!==e.touched.size&&this.navigationReplay.dispatchIslands(e,t,this.deps.cache.islands)}restoreGuesses(e,t){const{deps:n,state:r}=this;if("off"!==n.autoBind&&null!==r.autoBindGuesses&&("undefined"==typeof __LEAN_BUILD__||!__LEAN_BUILD__)){const i=vr(n,r,e,t.fields);!function(e,t,n,r,i,o){if(!o())return 0;const s=t.autoBindGuesses,a=fr(e.root);if(null===s||0===s.fields.size||null===a)return 0;const l=new Map(s.values);for(const[e,t]of or(n,r)){if(null===t||!s.fields.has(t.field))continue;const n=l.get(e);void 0===n?l.set(e,t):n?.field!==t.field&&l.set(e,null)}if(!o())return 0;const d=hr(a,l);o()&&gr(e,d,i,"after a server render",o).length}(n,r,t.fields,e.locale,i,()=>r.isCurrent(e))}}onFlush(e){const{deps:t,state:n}=this;n.lastFlush=e,e.deferred>0&&!n.warnedVisibilityGate&&(n.warnedVisibilityGate=!0,t.warn(`[live-preview] LP0301: visibility gate held ${String(e.deferred)} off-screen update(s) until scrolled into view; see visibilityGateThreshold`));const{revision:r,data:i}=e;if(void 0===r)return;const o=n.activeUpdate;if(null===o||!n.isCurrent(o)||!b(o.revision,r))return;n.display.deferred(o,e.deferred),0===o.pendingFragments&&n.complete(o);const s=()=>n.isCurrent(o)&&b(o.revision,r),a=i??o.renderData;if(this.revealPending(o),!s())return;const l=n.unfaithfulPatches;if(l.length>0){if(n.unfaithfulPatches=[],void 0!==a){const e=vr(t,n,o,a.fields);this.strategies.escalateUnfaithful(o,a,l,e)}if(!s())return}void 0!==i&&(e.applied>0&&t.a11y?.announceUpdate(e.applied),s()&&(this.notifyIslands(o,i),s()&&0!==e.applied&&0!==t.emitter.listenerCount("afterUpdate")&&t.emitter.emitWhile("afterUpdate",{data:i,updatedCount:e.applied,durationMs:e.durationMs,revision:r.revision,receivedAt:o.receivedAt,source:"patch"},s)))}revealPending(e){const t=this.state.revealLedger.commit(e);if(void 0!==t)try{Xe(this.state.revealer,t)}catch(e){this.deps.log("reveal",e)}}revealField(e){const t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":Xe(this.state.revealer,t)}documentSaved(){this.strategies.refreshAfterSave()}},qi=class{apply;debounceMs;maxWaitMs;isVisible;gateThresholdValue;gateDisabled;getCacheSize;onFlush;scheduleFrame;cancelFrame;pending=/* @__PURE__ */new Map;replay=/* @__PURE__ */new Map;activeFlushes=/* @__PURE__ */new Set;debounceTimer=null;debounceToken=0;deadlineTimer=null;frameHandle=null;frameFallback=null;frameToken=0;windowUntil=0;activeRevision=null;activeRevisionCancelled=!1;destroying=!1;constructor(e,t){this.apply=e,this.debounceMs=t.debounceMs??50,this.maxWaitMs=t.maxWaitMs??4*this.debounceMs,this.isVisible=t.isVisible,this.gateThresholdValue=t.visibilityGateThreshold??50,this.gateDisabled=t.disableVisibilityGate??!1,this.getCacheSize=t.getCacheSize,this.onFlush=t.onFlush,this.scheduleFrame=t.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):e=>setTimeout(()=>{e(performance.now())},0)),this.cancelFrame=t.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):e=>{clearTimeout(e)})}schedule(e){if(this.destroying)return;if(void 0!==e.revision){if(this.activeRevisionCancelled)return;if(null===this.activeRevision||!b(e.revision,this.activeRevision))return}const t=this.pending.get(e.target.element);t?(t.value=e.value,t.allFields=e.allFields,t.revision=e.revision,t.data=e.data,t.valueIdentity=e.valueIdentity):this.pending.set(e.target.element,{target:e.target,value:e.value,allFields:e.allFields,revision:e.revision,data:e.data,valueIdentity:e.valueIdentity}),this.armDebounce()}acceptRevision(e){var t,n;this.destroying||null!==this.activeRevision&&b(e,this.activeRevision)||null!==this.activeRevision&&(t=e,n=this.activeRevision,(t.generation!==n.generation?t.generation-n.generation:t.revision-n.revision)<0)||(this.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1,this.cancelScheduledWork())}cancelRevision(e){null!==this.activeRevision&&b(e,this.activeRevision)&&(this.clearWork(),this.activeRevisionCancelled=!0,this.cancelScheduledWork())}flushNow(){return this.cancelScheduledWork(),this.flush()}notifyVisible(e){const t=this.replay.get(e);if(!t)return;if(this.replay.delete(e),!this.isCurrent(t))return;const n=performance.now(),r=this.didApply(t)?1:0;this.onFlush?.(this.statsFor(t,r,0,performance.now()-n,1===r?[t.target.fieldName]:[]))}retarget(e){this.retargetBuffer(this.pending,e),this.retargetBuffer(this.replay,e);for(const t of this.activeFlushes)this.retargetBuffer(t,e)}forget(e){this.pending.delete(e),this.replay.delete(e);for(const t of this.activeFlushes)t.delete(e)}destroy(){if(!this.destroying){this.destroying=!0;try{this.clearWork(),this.activeRevision=null,this.activeRevisionCancelled=!1,this.windowUntil=0,this.cancelScheduledWork()}finally{this.destroying=!1}}}get pendingCount(){return this.pending.size}get replayCount(){return this.replay.size}get gateThreshold(){return this.gateThresholdValue}get gateActive(){return!this.gateDisabled&&this.getCacheSize()>this.gateThresholdValue}armDebounce(){const e=Date.now(),t=e>=this.windowUntil;if(this.windowUntil=e+this.debounceMs,t)return void this.requestFrame();const n=this.debounceToken+=1,r=this.debounceTimer;if(this.debounceTimer=null,null!==r&&clearTimeout(r),this.debounceToken!==n)return;const i=setTimeout(()=>{this.debounceToken===n&&(this.debounceTimer=null,this.pending.size>0&&this.requestFrame())},this.debounceMs);this.debounceToken===n&&(this.debounceTimer=i),null===this.deadlineTimer&&this.maxWaitMs>this.debounceMs&&(this.deadlineTimer=setTimeout(()=>{this.deadlineTimer=null,this.pending.size>0&&this.requestFrame()},this.maxWaitMs))}requestFrame(){const e=this.frameToken+=1,t=this.frameHandle;if(this.frameHandle=null,this.clearFrameFallback(),null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1;const r=()=>{if(this.frameToken!==e||n)return;n=!0;const t=this.frameHandle;this.frameHandle=null,this.clearFrameFallback(),null!==t&&this.cancelFrame(t),this.flush()},i=this.scheduleFrame(r);n||this.frameToken!==e||(this.frameHandle=i,this.frameFallback=setTimeout(r,100))}clearFrameFallback(){clearTimeout(this.frameFallback??void 0),this.frameFallback=null}flush(){const e=performance.now();this.clearDeadline();const t=this.gateActive,n=this.pending;this.pending=/* @__PURE__ */new Map;let r=0;const i=[];let o,s=0;this.activeFlushes.add(n);try{for(const e of n.values()){if(!this.isCurrent(e))continue;const n=!t||this.isVisible(e.target.element)||Vi(e.target);this.isCurrent(e)&&(o??=e,n?(this.replay.delete(e.target.element),this.didApply(e)&&(r+=1,i.push(e.target.fieldName))):(this.replay.set(e.target.element,e),s+=1))}}finally{this.activeFlushes.delete(n)}const a=this.statsFor(o,r,s,performance.now()-e,i);return this.onFlush?.(a),a}isCurrent(e){return void 0===e.revision||!this.activeRevisionCancelled&&null!==this.activeRevision&&b(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||(t=this.apply,!re.has(t));var t}retargetBuffer(e,t){const n=e.get(t.element);void 0!==n&&(Yt(n.target,t)?n.target=t:e.delete(t.element))}clearWork(){this.pending.clear(),this.replay.clear();for(const e of this.activeFlushes)e.clear()}statsFor(e,t,n,r,i){return{applied:t,appliedFields:i,deferred:n,durationMs:r,...void 0!==e?.revision?{revision:e.revision}:{},...void 0!==e?.data?{data:e.data}:{}}}clearDeadline(){null!==this.deadlineTimer&&(clearTimeout(this.deadlineTimer),this.deadlineTimer=null)}cancelScheduledWork(){const e=this.debounceTimer,t=this.frameHandle;this.debounceToken+=1,this.frameToken+=1,this.debounceTimer=null,this.frameHandle=null,this.clearDeadline(),this.clearFrameFallback(),null!==e&&clearTimeout(e),null!==t&&this.cancelFrame(t)}};function Vi(e){if(!0!==e.hidesWhenEmpty)return!1;const{element:t}=e;if(t.hasAttribute("hidden"))return!0;const n=t.getBoundingClientRect();return 0===n.width||0===n.height}var Gi=[0,500,1e3,2e3],Ki=class{deps;state=new nt;pipeline;writer;rootSentinel=null;scope=null;closingSession=!1;observedRoot=null;replayRetainedOnStart=!1;constructor(e){const{emitter:t,renderers:n}=e,r=void 0===e.log?A:S(e.log),i=void 0===e.warn?R:S(e.warn),o=e.root??("undefined"!=typeof document?document:void 0);if(void 0===o)throw new Error("LivePreviewRuntime: no document; pass options.root");const s=new en({filter:e=>!isInsideIsland(e)}),a=new Nn({onStructuralChange:()=>{this.rebuildCache()},onIslandHydrated:e=>{this.pipeline.reapplyNavigationIslands([e],!0)},onVisibilityChange:(e,t)=>{t&&l.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),l=new qi(ie(e=>this.writer.apply(e)),{...void 0!==e.debounceMs?{debounceMs:e.debounceMs}:{},...void 0!==e.disableVisibilityGate?{disableVisibilityGate:e.disableVisibilityGate}:{},...void 0!==e.visibilityGateThreshold?{visibilityGateThreshold:e.visibilityGateThreshold}:{},isVisible:e=>a.isVisible(e),getCacheSize:()=>s.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),d=new w(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onReplay:(e,t,n)=>{this.pipeline.handleReplay(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],r,i),t.emit("documentSave",{timestamp:Date.now()}),this.pipeline.documentSaved()},onFocusField:e=>{this.deps.revealEditedField&&this.pipeline.revealField(e)},onInvalid:(e,n)=>{if("token"===e){const e=new Error(`Preview token rejected (origin: ${n})`);t.emit("error",{error:e,context:"token",code:"LP0502"})}"shape"!==e&&"type"!==e||this.state.warnedProtocolShape||(this.state.warnedProtocolShape=!0,i(`[live-preview] LP0503: ${n} posted a message this runtime does not recognise (${"type"===e?"unknown message type":"unexpected shape"}); it was ignored. A newer Payload or a custom sender: check that the versions match.`)),"source"!==e||this.state.warnedForeignSource||(this.state.warnedForeignSource=!0,i(`[live-preview] LP0501: a message from ${n} was ignored because it did not come from the window that framed or opened this page. \`eventSourcePolicy\` is 'parent-or-opener' by default since 2.0, where 1.x accepted any window on a trusted origin. Set \`eventSourcePolicy: 'any'\` if the admin posts from elsewhere.`)),r("LP0501 message rejected:",e,n)},...void 0!==e.validateToken?{validateToken:e.validateToken}:{},...void 0!==e.eventSourcePolicy?{sourcePolicy:e.eventSourcePolicy}:{}}),u=e.dataMerge;this.deps={emitter:t,cache:s,observers:a,scheduler:l,bus:d,connection:new Xn,heartbeat:new Qn({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:n,resolveRenderer:e.resolveRenderer??(e=>n[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,internalLinkPattern:e.internalLinkPattern,routeAfterSave:!0===e.routeAfterSave,sanitizerPolicy:e.sanitizerPolicy,root:o,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:/* @__PURE__ */(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??N,onHeartbeatTimeout:e.onHeartbeatTimeout,log:r,warn:i,a11y:$(e),serverURL:u?.serverURL,merger:void 0===u?null:new kn({...u,log:r}),mergeWindowMs:e.debounceMs??50,scopeBindingsByOwner:!0===e.scopeBindingsByOwner,subfieldCoverage:e.subfieldCoverage??"descendant",coverageByDefault:void 0===e.subfieldCoverage,lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField,onUnfaithfulPatch:Q(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new rt(this.deps,this.state),this.pipeline=new Wi(this.deps,this.state,()=>{this.rebuildCache()})}start(){const{state:e}=this;if(e.isRunning()||this.closingSession)return!1;e.suspended&&(this.replayRetainedOnStart=!0),e.started=!0,e.suspended=!1,this.openScope();try{return function(e){"react"===e.hydration?On():"vue"===e.hydration&&Hn();const{root:t}=e;if(!Kn(t)||"loading"!==t.readyState)return void Wn(e);const n=()=>{e.isRunning()&&e.later(()=>{Wn(e)})};t.addEventListener("DOMContentLoaded",n,{once:!0}),e.defer(()=>{t.removeEventListener("DOMContentLoaded",n)})}(this.startupHost()),!0}catch(e){throw this.rollbackFailedStart(),e}}startupHost(){const{state:e,deps:t}=this;return{root:t.root,hydration:t.hydration,isRunning:()=>e.isRunning(),defer:t=>{e.deferredStart=t,this.scope?.own(()=>{e.deferredStart===t&&(e.deferredStart=null,t())})},later:t=>{e.deferredStart=null;try{t()}catch(e){this.rollbackFailedStart(),this.reportError(e,"startup","LP0605")}},hydrated:t=>{e.hydration=t},warn:t.warn,startNow:()=>{this.startNow()}}}startNow(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=Kn(t.root)?Jn(t.root):t.root;if(null===n)throw new Error("LivePreviewRuntime: document.body unavailable");if(t.observers.start(n),this.observedRoot=n,this.watchRootReplacement(),this.buildCacheAndObserve(),!e.isRunning())return;if(t.bus.attach(),t.emitter.emitWhile("init",{timestamp:Date.now()},()=>e.isRunning()),!e.isRunning())return;const r=this.replayRetainedOnStart;this.replayRetainedOnStart=!1;const i=r&&t.heartbeat.resume();if(e.isRunning()&&(!r||i||(e.forgetOwedWork(),e.merges.resetRawChanges(),e.unfaithfulPatches=[],e.revealer.reset(),e.lastAppliedIdentity=/* @__PURE__ */new WeakMap,e.changes.reset(),e.navigationReplayPending=!0,t.bus.replayLastAccepted()||(e.navigationReplayPending=!1),e.isRunning())))for(const n of Gi){if(!e.isRunning())return;0===n?t.sendReady(t.readyTargets()):e.readyTimers.push(setTimeout(()=>{e.isRunning()&&this.sendReadyAfterStart()},n))}}suspend(){if(!this.state.isRunning())return!1;const e=this.release();return this.state.suspended=!0,e&&this.deps.emitter.emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0}destroy(){const{state:e,deps:t}=this;if(!e.isRunning()&&!e.suspended)return;const n=!!e.isRunning()&&this.release();e.suspended=!1,this.replayRetainedOnStart=!1,t.bus.forgetLastAccepted(),n&&t.emitter.emit("disconnect",{reason:"destroy",timestamp:Date.now()}),t.a11y?.detach(),t.emitter.emit("destroy",{timestamp:Date.now()})}openScope(){const{state:e,deps:t}=this,n=new xn(t.log);n.own(()=>{t.merger?.destroy(),e.merges.destroy()}),n.own(()=>{t.scheduler.destroy()}),n.own(()=>{t.observers.stop()}),n.own(()=>{this.rootSentinel?.disconnect(),this.rootSentinel=null,this.observedRoot=null}),n.own(()=>{e.abortStrategies()}),n.own(()=>{t.bus.detach()}),n.own(()=>{t.heartbeat.stop()}),n.own(()=>{for(const t of e.readyTimers)clearTimeout(t);e.readyTimers.length=0}),this.scope=n}release(){const{state:e,deps:t}=this;e.display.end(),e.activeUpdate=null,e.navigationBindingReplay=!1,e.started=!1;const n=this.scope;this.scope=null,this.closingSession=!0;try{n?.close()}finally{this.closingSession=!1}return t.cache.clear(),t.connection.markDisconnected()}rollbackFailedStart(){this.release();try{this.deps.a11y?.detach()}catch(e){this.deps.log("runtime cleanup failed:",e)}}refreshCache(){this.state.isRunning()&&(this.state.revealer.reset(),this.followReplacedRoot()||this.rebuildCache())}navigationCommit(){const{state:e,deps:t}=this;e.isRunning()&&null===e.deferredStart&&(this.cancelActiveUpdate(!0),t.merger?.destroy(),e.merges.destroy(),e.abortStrategies(),this.cancelActiveUpdate(!0),e.forgetOwedWork(),e.merges.resetRawChanges(),e.unfaithfulPatches=[],e.revealer.reset(),e.lastAppliedIdentity=/* @__PURE__ */new WeakMap,e.changes.reset(),e.isRunning()&&(t.bus.advanceGeneration(),e.navigationReplayPending=!0,this.followReplacedRoot()||this.rebuildCache(),e.isRunning()&&(t.bus.replayLastAccepted(),e.isRunning()&&this.sendReadyAfterStart())))}watchRootReplacement(){const{root:e}=this.deps;Kn(e)&&"undefined"!=typeof MutationObserver&&(this.rootSentinel?.disconnect(),this.rootSentinel=new MutationObserver(()=>{this.followReplacedRoot()}),this.rootSentinel.observe(e.documentElement,{childList:!0}))}followReplacedRoot(){const{root:e}=this.deps;if(!this.state.isRunning()||!Kn(e))return!1;const t=Jn(e);return null!==t&&t!==this.observedRoot&&(this.observedRoot=t,this.deps.observers.start(t),this.rebuildCache(),!0)}get status(){return this.deps.connection.status}get cache(){return this.deps.cache}get updateCount(){return this.state.updateCount}get protocol(){return this.state.protocol.negotiation}inspect(){return function(t,n){const{cache:r,scheduler:i}=t,o=n.protocol.negotiation,s=n.activeUpdate,a=n.lastFlush,l=[],d=/* @__PURE__ */new Set,u=[];for(const[e,t]of r.entries()){l.push(e);for(const n of t)void 0!==n.owner&&d.add(n.owner),void 0!==n.guessed&&u.push({field:e,matched:n.guessed,attribute:n.targetAttribute??("IMG"===n.element.tagName?"src":void 0)})}return{version:e,started:n.started,status:t.connection.status,origins:{trusted:[...t.readyTargets()],locked:t.lockedOrigin()},protocol:{ours:o.ours,theirs:o.theirs,negotiated:o.negotiated,capabilities:[...o.capabilities].sort(),observed:[...o.observed].sort(),profile:detectProtocolProfile(o.observed).name},revisions:{accepted:n.updateCount,superseded:n.supersededCount,completed:n.completedCount,skippedUnchanged:n.skippedUnchangedCount,active:null===s?void 0:s.revision.revision,display:n.display.snapshot()},bindings:{elements:r.elementCount,fields:r.fieldCount,fieldNames:l.sort(),absentFields:[...n.absentFields].sort(),orphanFields:[...n.warnedOrphanFields].sort(),ownerScoped:t.scopeBindingsByOwner,owners:[...d].sort(),guessed:u.sort((e,t)=>e.field.localeCompare(t.field)),autoBind:{mode:t.autoBind,searchMs:n.autoBindSearchMs}},route:{handler:void 0!==t.strategies.route,...n.routeStats},fidelity:{mode:t.onUnfaithfulPatch,canEscalate:void 0!==t.strategies.fragment||void 0!==t.strategies.route,unfaithful:n.unfaithfulCount,escalated:n.escalatedCount,fields:[...n.unfaithfulFields].sort()},hydration:{mode:t.hydration??"off",state:n.hydration},fragments:{handler:void 0!==t.strategies.fragment,inFlight:s?.pendingFragments??0,...n.fragmentStats},scheduler:{pending:i.pendingCount,deferred:i.replayCount,visibilityGateThreshold:i.gateThreshold,visibilityGateActive:i.gateActive,lastFlush:null===a?void 0:{applied:a.applied,appliedFields:a.appliedFields,deferred:a.deferred,durationMs:a.durationMs}},plugins:[],renderers:Object.keys(t.renderers).sort()}}(this.deps,this.state)}buildCacheAndObserve(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=t.cache.buildFromRoot(t.root);if(t.log("cache",n),e.isRunning()&&(t.emitter.emitWhile("cacheRefresh",n,()=>e.isRunning()),e.isRunning()))for(const n of t.cache.values()){if(!e.isRunning())return;t.observers.observeElement(n.element)}}rebuildCache(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=/* @__PURE__ */new Map,r=t.cache.islandOwners,i=new Set(t.cache.navigationReplayRoots);for(const e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),!e.isRunning())return;const o=new Set(t.cache.navigationReplayRoots.filter(e=>!i.has(e)));for(const e of t.cache.values()){const r=n.get(e.element);void 0!==r&&Yt(r,e)?t.scheduler.retarget(e):(t.scheduler.forget(e.element),o.add(e.element)),n.delete(e.element)}for(const e of n.values())t.scheduler.forget(e.element);o.size>0&&this.pipeline.reapplyNavigationBindings(o);const s=t.cache.islands.filter(e=>!r.has(e)||t.scopeBindingsByOwner&&r.get(e)!==t.cache.islandOwners.get(e));s.length>0&&this.pipeline.reapplyNavigationIslands(s)}onHeartbeatTimeout(){const{state:e,deps:t}=this;if(!e.isRunning())return;if(this.cancelActiveUpdate(!1),t.merger?.destroy(),e.merges.destroy(),e.abortStrategies(),this.cancelActiveUpdate(!1),!e.isRunning())return;t.bus.advanceGeneration(),t.bus.forgetLastAccepted(),e.navigationBindingReplay=!1;const n=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}if(e.isRunning()){if(n&&this.isIdleDisconnected()){if(t.a11y?.announceDisconnected(),t.emitter.emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.isIdleDisconnected()),!e.isRunning())return;if(this.isIdleDisconnected()&&t.log("connection","connected","→","disconnected"),!e.isRunning())return}this.sendReadyAfterStart()}}cancelActiveUpdate(e){const{state:t,deps:n}=this,r=t.activeUpdate;t.display.end(),t.activeUpdate=null,null!==r&&(r.cancelled=!0,n.scheduler.cancelRevision(r.revision),e&&!r.completed&&r.countsAsUpdate&&(t.supersededCount+=1))}sendReadyAfterStart(){try{this.deps.sendReady(this.deps.readyTargets())}catch(e){this.reportError(e,"ready","LP0606")}}reportError(e,t,n){const r=e instanceof Error?e:new Error(String(e));this.deps.emitter.emit("error",{error:r,context:t,code:n})}isIdleDisconnected(){return this.state.isRunning()&&"disconnected"===this.deps.connection.status&&null===this.state.activeUpdate}},EventEmitter=class{#o=/* @__PURE__ */new Map;#s=/* @__PURE__ */new Map;on(e,t){return this.#a(this.#o,e,t)}once(e,t){return this.#a(this.#s,e,t)}off(e,t){this.#l(this.#o,e,t),this.#l(this.#s,e,t)}async emit(e,t){await this.#d(e,t)}async emitWhile(e,t,n){return this.#d(e,t,n)}async#d(e,t,n){const r=()=>n?.()??!0;if(!r())return!1;const i=this.#o.get(e);if(i)for(const n of[...i]){if(!r())return!1;if(await this.#u(n,t,e),!r())return!1}if(!r())return!1;const o=this.#s.get(e);if(o&&o.size>0){const n=[...o];this.#s.delete(e);for(const i of n){if(!r())return!1;if(await this.#u(i,t,e),!r())return!1}}return r()}listenerCount(e){return(this.#o.get(e)?.size??0)+(this.#s.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#o.clear(),void this.#s.clear();this.#o.delete(e),this.#s.delete(e)}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#o.keys())e.add(t);for(const t of this.#s.keys())e.add(t);return[...e]}#a(e,t,n){let r=e.get(t);return r||(r=/* @__PURE__ */new Set,e.set(t,r)),r.add(n),()=>{this.#l(e,t,n)}}#l(e,t,n){const r=e.get(t);void 0!==r&&(r.delete(n),0===r.size&&e.delete(t))}async#u(e,t,n){try{await e(t)}catch(e){const t="string"==typeof n||"number"==typeof n?String(n):"<event>";k(`[live-preview] LP0601: handler for "${t}" threw:`,e)}}},Ji=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,Qi=/^https?:\/\/[^/?#\s]+$/i,Xi=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function Zi(){if("undefined"==typeof location)return;const e=location.ancestorOrigins;return e?.[0]}var OriginDetector=class{#c;constructor(e={}){const t=/* @__PURE__ */new Set;for(const n of e.additionalOrigins??[]){const e=Yi(n);void 0!==e&&t.add(e)}let n;if(e.enableReferrerDetection??1){const t=e.referrer??("undefined"!=typeof document?document.referrer:"");if(t.length>0)try{const e=new URL(t).origin;e&&"null"!==e&&(n=e)}catch{}}const r=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??isDevMode());this.#c=[t,n,r,void 0!==n,void 0,Zi()]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#c[4]?e===this.#c[4]:!!this.#c[0].has(e)||0===this.#c[0].size&&void 0!==this.#c[1]&&e===this.#c[1]||!(!this.#c[2]||!Ji.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#c[4]=e,!0)}unlockOrigin(){const e=this.#c[4];return this.#c[4]=void 0,e}get lockedOrigin(){return this.#c[4]}enumerate(){if(void 0!==this.#c[4])return[this.#c[4]];const e=new Set(this.#c[0]);0===this.#c[0].size&&void 0!==this.#c[1]&&e.add(this.#c[1]);const t=this.#c[5];if(this.#c[2]&&void 0!==t)Ji.test(t)&&e.add(t);else if(this.#c[2])for(const t of Xi)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#c[3]}get isProductionUnconfigured(){return!(!isInIframe()||this.#c[0].size>0||this.#c[2]||void 0!==this.#c[1])}get isReferrerOnlyTrust(){return!(this.#c[0].size>0||this.#c[2]||void 0===this.#c[1])}};function Yi(e){const t=e.trim();if(0!==t.length)try{const e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return;if(!Qi.test(e.origin))return;return e.origin}catch{return}}var eo=()=>{},to=class{#h;#n;#f=/* @__PURE__ */new Set;#c="staging";constructor(e,t){this.#h=e,this.#n=t}assertOpen(){if("closed"===this.#c)throw new Error(`Plugin context for "${this.#h}" is no longer active`)}get active(){return"active"===this.#c}eligible(){return"closed"!==this.#c}own(e){return this.assertOpen(),this.#p({kind:"cleanup",acquire:void 0,finalize:void 0,cleanup:e,disposed:!1})}stage(e,t,n){this.assertOpen();const r={kind:e,acquire:t,finalize:n,cleanup:void 0,disposed:!1},i=this.#p(r);if("active"===this.#c)try{this.#g(r)}catch(e){throw this.#m(r),e}return i}counts(){const e={transform:0,renderer:0,subscription:0,cleanup:0};for(const t of this.#f)e[t.kind]+=1;return e}commit(){if("staging"!==this.#c)throw new Error(`Plugin context for "${this.#h}" cannot be committed`);this.#c="committing";try{for(const e of this.#f)this.#g(e);this.#c="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#c){this.#c="closed";for(const e of[...this.#f].reverse())this.#m(e);this.#f.clear()}}#p(e){return this.#f.add(e),()=>{this.#m(e)}}#g(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;const t=e.acquire();e.cleanup=t??eo}#m(e){if(e.disposed)return;e.disposed=!0,this.#f.delete(e);const t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{y(t())&&this.#n(`plugin "${this.#h}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#n(`plugin "${this.#h}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#n(`plugin "${this.#h}" cleanup failed:`,e)}}},no=class{#v;#y;#b=/* @__PURE__ */new Set;constructor(e,t){this.#v=e,this.#y=t}on(e,t){return this.#w("on",e,t)}once(e,t){return this.#w("once",e,t)}off(e,t){const n=t;for(const t of[...this.#b])t.event===e&&t.handler===n&&t.dispose()}emit(e,t){return this.#y.assertOpen(),this.#v.emit(e,t)}emitWhile(e,t,n){return this.#y.assertOpen(),this.#v.emitWhile(e,t,()=>{if(!this.#y.eligible())return!1;const e=n();return!!this.#y.eligible()&&e})}listenerCount(e){let t=0;for(const n of this.#b)n.event===e&&(t+=1);return t}removeAllListeners(e){for(const t of[...this.#b])void 0!==e&&t.event!==e||t.dispose()}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#b)e.add(t.event);return[...e]}#w(e,t,n){this.#y.assertOpen();const r=n,i=[...this.#b].find(n=>n.kind===e&&n.event===t&&n.handler===r);if(void 0!==i)return i.dispose;let o=eo,s=!0;const a=async t=>{this.#y.active&&s&&("once"===e&&o(),await n(t))},l={kind:e,event:t,handler:r,dispose:eo};return o=this.#y.stage("subscription",()=>this.#v[e](t,a),()=>{s=!1,this.#b.delete(l)}),l.dispose=o,this.#b.add(l),o}},ro=class{#v;#S;#A;#k;#n;#R=/* @__PURE__ */new Map;#T=/* @__PURE__ */new Map;#C=/* @__PURE__ */new Map;#P=/* @__PURE__ */new Set;#L=/* @__PURE__ */new Map;#$=Promise.resolve();#N=0;constructor(e){this.#v=e.events,this.#S=e.config,this.#A=e.registerFieldRenderer,this.#n=S(e.log);const t=e.onTransformError;this.#k=void 0===t?void 0:S((...e)=>{const n=e[0];try{return t(n)}catch(e){return void this.#n("transform error reporter failed:",e)}})}register(e){return this.#N>0?this.#F(e,!1):this.#U(()=>this.#F(e,!0))}unregister(e){return this.#N>0?this.#x(e,!1):this.#U(async()=>{await this.#x(e,!0)})}destroyAll(){return this.#N>0?this.#M(!1):this.#U(async()=>{await this.#M(!0)})}applyTransforms(e,t,n,r){const i=this.#L.get(e);if(void 0===i||0===i.length)return t;let o=t;for(const s of[...i]){if(!s.active)continue;const{transform:i}=s;if(!1===r?.())return t;try{o=i(o,{fieldName:e,element:n.element,allFields:n.allFields});const s=y(o);if(!1===r?.())return t;if(s)throw new TypeError(`Transform for "${e}" returned a Promise/thenable; transforms must be synchronous`)}catch(n){if(!1===r?.())return t;const i=n instanceof Error?n:new Error(String(n));return this.#n(`transform for "${e}" failed:`,i),this.#k?.(i),t}}return o}list(){return[...this.#R.keys()]}snapshot(){const e=[],t=(e,t,n,r)=>{const i=r.counts();return{name:e,version:t,state:n,registrations:{transforms:i.transform,renderers:i.renderer,subscriptions:i.subscription,cleanups:i.cleanup}}};for(const[n,r]of this.#T)e.push(t(n,void 0,"initializing",r.scope));for(const[n,r]of this.#R)e.push(t(n,r.plugin.version,"active",r.scope));for(const t of this.#C.keys())e.push({name:t,version:void 0,state:"tearing-down",registrations:{transforms:0,renderers:0,subscriptions:0,cleanups:0}});return e}get size(){return this.#R.size}async#F(t,n){if(this.#R.has(t.name)||this.#T.has(t.name)||this.#C.has(t.name))return void this.#n(`plugin "${t.name}" already registered`);const r=function(e,t){if(void 0!==e){if(void 0!==e.runtime&&!function(e,t){const n=function(e){const t=/^v?(\d+)\.(\d+)\.(\d+)/.exec(e.trim());if(null!==t)return[Number(t[1]),Number(t[2]),Number(t[3])]}(e);return void 0!==n&&t.split("||").some(e=>{const r=e.trim().split(/\s+/).filter(e=>e.length>0);return 0===r.length?""===e.trim()&&""===t.trim():r.every(e=>function(e,t){const n=t.trim();if(""===n||"*"===n)return!0;const r=/^(\^|~|>=|<=|>|<|=)?\s*v?(\d+)\.(\d+)\.(\d+)/.exec(n);if(null===r)return!1;const i=r[1]??"=",o=[Number(r[2]),Number(r[3]),Number(r[4])],s=function(e,t){for(let n=0;n<3;n+=1){const r=(e[n]??0)-(t[n]??0);if(0!==r)return r}return 0}(e,o);switch(i){case"=":return 0===s;case">":return s>0;case">=":return s>=0;case"<":return s<0;case"<=":return s<=0;case"~":return s>=0&&e[0]===o[0]&&e[1]===o[1];case"^":return!(s<0)&&(o[0]>0?e[0]===o[0]:o[1]>0?0===e[0]&&e[1]===o[1]:0===e[0]&&0===e[1]&&e[2]===o[2]);default:return!1}}(n,e))})}(t,e.runtime))return`declares runtime ${e.runtime}, this runtime is ${t}`;if(void 0!==e.protocol){if(!Number.isInteger(e.protocol)||e.protocol<1)return`declares an invalid protocol version ${String(e.protocol)}`;if(e.protocol<4)return`declares protocol ${String(e.protocol)}, this runtime speaks ${String(4)}`}}}(t.compat,e);if(void 0!==r)return void this.#E(t.name,r);const i=new to(t.name,this.#n),o=this.#O(t.name,i),s={scope:i,cancelled:!1};this.#T.set(t.name,s);try{if(await this.#I(()=>t.init(o),n),s.cancelled)return;i.commit()}catch(e){return i.close(),void(s.cancelled||this.#n(`plugin "${t.name}" init failed:`,e))}finally{this.#T.get(t.name)===s&&this.#T.delete(t.name)}this.#R.set(t.name,{plugin:t,scope:i}),this.#n(`plugin "${t.name}" registered`)}#E(e,t){const n=`plugin "${e}" refused: ${t}`;this.#n(n),this.#v.emit("error",{error:new Error(n),context:"plugin",code:"LP0103"})}#O(e,t){return{events:new no(this.#v,t),registerFieldRenderer:e=>{t.stage("renderer",()=>{const t=this.#A(e);return"function"==typeof t?t:void 0})},registerTransform:(e,n)=>{const r={transform:n,active:!1};t.stage("transform",()=>{r.active=!0;const t=this.#L.get(e);return void 0===t?this.#L.set(e,[r]):t.push(r),()=>{r.active=!1;const t=this.#L.get(e);if(void 0===t)return;const n=t.indexOf(r);n>=0&&t.splice(n,1),0===t.length&&this.#L.delete(e)}})},registerCleanup:e=>{t.own(e)},getConfig:()=>this.#S,log:(...t)=>{this.#n(`[${e}]`,...t)}}}#x(e,t){const n=this.#T.get(e);if(void 0!==n)return n.cancelled=!0,n.scope.close(),Promise.resolve();const r=this.#C.get(e);if(void 0!==r)return this.#P.has(e)?Promise.resolve():t?this.#D(r):r;const i=this.#R.get(e);if(void 0===i)return Promise.resolve();this.#R.delete(e),i.scope.close();const o=Promise.resolve().then(()=>this.#_(e,i.plugin,t));return this.#C.set(e,o),o.then(()=>{this.#C.get(e)===o&&this.#C.delete(e)}),o}async#_(e,t,n){if(void 0!==t.destroy){this.#P.add(e);try{await this.#I(()=>t.destroy?.(),n)}catch(t){this.#n(`plugin "${e}" destroy failed:`,t)}finally{this.#P.delete(e)}}}async#M(e){for(const e of this.#T.values())e.cancelled=!0,e.scope.close();const t=[...this.#R.keys()];for(const n of t)await this.#x(n,e)}async#I(e,t){t?await this.#D(Promise.resolve().then(e)):await e()}async#D(e){this.#N+=1;try{await e}finally{this.#N-=1}}#U(e){const t=this.#$.then(e);return this.#$=t.catch(e=>{this.#n("plugin manager mutation failed:",e)}),t}},io=class{#B;#z;#j=/* @__PURE__ */new Map;constructor(e){this.#B=e,this.#z={...e}}get renderers(){return this.#z}resolve(e){return this.#z[e]}register(e){const t=e.name,n={renderer:e},r=this.#j.get(t);void 0===r?this.#j.set(t,[n]):r.push(n),this.#z[t]=e;let i=!0;return()=>{if(!i)return;i=!1;const e=this.#j.get(t);if(void 0===e)return;const r=e.indexOf(n);if(r<0)return;const o=r===e.length-1;if(e.splice(r,1),0===e.length&&this.#j.delete(t),!o)return;const s=e.at(-1),a=s?.renderer??this.#B[t];void 0===a?Reflect.deleteProperty(this.#z,t):this.#z[t]=a}}},oo={1:"left",2:"center",3:"right",4:"justify"},so=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function ao(e){const t=e.format;return"string"==typeof t&&so.has(t)?t:"number"==typeof t?oo[t]:void 0}function lo(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function uo(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function co(e){const t=ao(e),n=lo(e),r=[];return void 0!==t&&r.push(`lp-align-${t}`),n>0&&r.push(`lp-indent-${String(n)}`),0===r.length?"":` class="${r.join(" ")}"`}var ho=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function fo(e){return"object"==typeof e&&null!==e?e:void 0}function po(e){return fo(e)}function go(e,t){if(void 0===t||""===t||!e.startsWith("/"))return e;try{const n=new URL(t),r=new URL(e,n);return r.origin===n.origin?r.href:e}catch{return e}}function mo(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function vo(e){return"string"==typeof e&&e.length>0?e:void 0}function yo(e){const t=vo(e.title)??vo(e.name)??vo(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}var bo=/\{(slug|id|collection|locale)\}/gu,wo=' target="_blank" rel="noopener noreferrer"',So=(e,t)=>{const n=t.renderChildren(e.children??[]),r=fo(e.fields),i=function(e,t,n){if("internal"===t?.linkType)return function(e,t){const n=fo(e),r=fo(n?.value),i=r?.url;if("string"==typeof i&&i.length>0)return i;const o=void 0===t.internalLinkPattern?void 0:function(e,t){const n=e=>{const n=t[e];return"string"==typeof n&&n.length>0||"number"==typeof n?encodeURIComponent(n):void 0};for(const[,t=""]of e.matchAll(bo))if(void 0===n(t))return;return e.replace(bo,(e,t)=>n(t)??"")}(t.internalLinkPattern,{slug:r?.slug,id:void 0===r?n?.value:r.id,collection:n?.relationTo,locale:t.locale});if(void 0!==o)return o;const s=r?.slug;return"string"==typeof s&&s.length>0?`/${s}`:void 0}(t.doc,n);const r=t?.url??e.url;return"string"==typeof r&&r.length>0?r:void 0}(e,r,t);if(void 0===i||!isSafeUrl(i))return n;const o="string"==typeof e.title?` title="${escapeHtml(e.title)}"`:"";return`<a href="${escapeHtmlAttribute(i)}"${function(e,t,n){if(!0===t?.newTab||isExternalHttpUrl(n))return wo;const r="string"==typeof e.target?e.target:"";return""===r?"":"_blank"===r?wo:` target="${escapeHtml(r)}"`}(e,r,i)}${o}>${n}</a>`};function Ao(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=Ao(n);return t}function ko(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function Ro(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var To=/* @__PURE__ */new Map;function Co(e){return To.get(e)}var Po=".lp-block:empty,.lp-inline-block:empty";function Lo(e,t,n,r){const i=fo(e.fields)??{},o="string"==typeof i.blockType?i.blockType:"",s=mo(o),a=""===s?r:`${r} ${r}--${s}`;if(""!==o){const e=Co(o)??Co(s);if(e)return e(i,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(o,a,i)}return`<${n} class="${a}"></${n}>`}function $o(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var No={text:e=>{let t=escapeHtml("string"==typeof e.text?e.text:"");const n="number"==typeof e.format?e.format:0;return!!(16&n)&&(t=`<code>${t}</code>`),!!(1&n)&&(t=`<strong>${t}</strong>`),!!(2&n)&&(t=`<em>${t}</em>`),!!(8&n)&&(t=`<u>${t}</u>`),!!(4&n)&&(t=`<s>${t}</s>`),!!(32&n)&&(t=`<sub>${t}</sub>`),!!(64&n)&&(t=`<sup>${t}</sup>`),!!(128&n)&&(t=`<mark>${t}</mark>`),t},paragraph:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<p${uo(e)}${co(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",r=ho.has(n)?n:"h2",i=t.renderChildren(e.children??[]);return`<${r}${uo(e)}${co(e)}>${i}</${r}>`},list:(e,t)=>{const n="string"==typeof e.listType?e.listType:"bullet",r="number"===n?"ol":"ul",i="number"===n&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",o="check"===n?' role="list"':"",s=t.renderChildren(e.children??[]);return`<${r}${uo(e)}${co(e)}${i}${o}>${s}</${r}>`},listitem:(e,t)=>{const n=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${co(e)}>${n}</li>`;const r="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${uo(e)}${co(e)}${r}>${n}</li>`},link:So,autolink:So,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${uo(e)}${co(e)}>${n}</blockquote>`},code:e=>{const t=mo("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(Ao(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${mo(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=po(e.value);if(void 0===t)return"";const n=t.url;if("string"!=typeof n||!isSafeUrl(n))return"";const r="string"==typeof t.mimeType?t.mimeType:"";return r.startsWith("video/")?function(e,t){return`<video controls${ko(e)}><source src="${escapeHtmlAttribute(t)}"${Ro(e)}></video>`}(t,n):r.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${Ro(e)}></audio>`}(t,n):""===r||r.startsWith("image/")?function(e,t){const n="string"==typeof e.alt?escapeHtml(e.alt):"";return`<img src="${escapeHtmlAttribute(t)}" alt="${n}"${ko(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){const n="string"==typeof e.filename?escapeHtml(e.filename):escapeHtml(t);return`<a href="${escapeHtmlAttribute(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{const t="string"==typeof e.relationTo?e.relationTo:"",n=fo(e.value),r=escapeHtml((n&&yo(n))??`#${t}`),i=mo(t),o=""===i?' class="lp-relation"':` class="lp-relation lp-relation--${i}"`,s=n?.url;return"string"==typeof s&&isSafeUrl(s)?`<a href="${escapeHtmlAttribute(s)}"${o}>${r}</a>`:`<span${o}>${r}</span>`},block:(e,t)=>Lo(e,t,"div","lp-block"),inlineBlock:(e,t)=>Lo(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${uo(e)}><tbody>${t.renderChildren(e.children??[])}</tbody></table>`,tablerow:(e,t)=>`<tr>${t.renderChildren(e.children??[])}</tr>`,tablecell:(e,t)=>{const n="number"==typeof e.headerState?e.headerState:0,r=3&n?"th":"td";return`<${r}${1===n?' scope="col"':2===n?' scope="row"':""}${$o("colspan",e.colSpan)}${$o("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${r}>`}},Fo=/* @__PURE__ */new Map,Uo=!1;function xo(e){if("object"!=typeof e||null===e)return!1;if(!("root"in e))return!1;const t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function Mo(e,t){const n=(r=e.type,Fo.get(r)??No[r]);var r;return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function Eo(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\n";if(void 0===e.children)return"";let t="";for(const n of e.children)t+=Eo(n);return t}function Oo(e="text"){const t=/* @__PURE__ */new WeakSet;return{name:e,render:/* @__PURE__ */ie((e,n)=>{const r=e.element,i=function(e){return null==e?"":xo(e)?xo(t=e)?t.root.children.map(Eo).join("\n").trim():"":"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e);var t}(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName){if(r.textContent.trim()!==i.trim())return function(e){return null!==e.querySelector(":scope > :not(br)")}(r)&&!r.hasAttribute("data-payload-text")?(function(e,t,n){e.has(t)||(e.add(t),R(`[live-preview] LP0402: Skipping text update for "${n}": <${t.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}(t,r,e.fieldName),!1):void(i.includes("\n")||i.includes("\r")?r.innerHTML=Cr(function(e){return escapeHtml(e).replace(/\r\n|\r|\n/g,"<br>")}(i)):r.textContent=i)}else r.value=i})}}var Io=/* @__PURE__ */new Set,Do=/* @__PURE__ */new Set,_o=/* @__PURE__ */new WeakMap,Bo=/* @__PURE__ */new Set(["DIV","SECTION","ARTICLE"]),zo={name:"richText",render:/* @__PURE__ */ie((e,t,n)=>{const r=e.element;if(hi(t))return void(r.textContent="");const i=n.sanitizerPolicy;if(void 0!==n.renderRichText){const o=n.renderRichText(t,{fieldName:e.fieldName,element:r,locale:n.locale});return void(r.innerHTML=Cr(Jr(o,i)))}if(xo(t)){if(ot(t))return void(r.textContent="");const o=/* @__PURE__ */new Map,s=[],a=function(e,t){const n=e.cloneNode(!1);n.innerHTML=Cr(t);const r=function(e,t){const n=e.firstElementChild,r=1===t.children.length?t.firstElementChild:null;if(null!==n?.nextElementSibling||0===t.children.length)return null;if(!Bo.has(n.tagName)||n.hasAttribute(Tt))return null;if(r?.tagName===n.tagName||!0===r?.matches(Po))return null;for(const e of t.children)if(e.tagName===n.tagName&&e.className===n.className)return null;return n}(e,n)??e,i=/* @__PURE__ */new Map,o=n.querySelectorAll(Po);if(o.length>0&&null!==r.firstElementChild){const e=[];jo(r,n,e);for(const[t,n]of e)t.replaceWith(n),n.matches(Po)||i.set(t.className,!1);for(const e of o)null!==e.parentNode&&i.set(e.className,!0)}return r.replaceChildren(...n.childNodes),i}(r,Jr(function(e,t={}){if(!xo(e))return"";const n=function(e){const t={renderChildren:e=>{let n="";for(const r of e)n+=Mo(r,t);return n},resolveAlignment:ao,resolveIndent:lo,onUnrenderedBlock:e.onUnrenderedBlock,internalLinkPattern:e.internalLinkPattern,locale:e.locale};return t}(t).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==t.document?sanitizeHtml(n,{document:t.document}):!0===t.requireDocument||void 0!==Zr()?sanitizeHtml(n):(function(){if(!Uo){Uo=!0;try{console.warn('[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; pass { document } (linkedom, jsdom) per call. 3.0 throws here instead: opt in now with { requireDocument: true }. See "HTML sanitization" in docs/security.md.')}catch{}}}(),n)}(t,{sanitize:!1,internalLinkPattern:n.internalLinkPattern,locale:n.locale,onUnrenderedBlock:(e,t,n)=>{o.set(t,e),s.push(n)}}),i));for(const[t,r]of a){const i=o.get(t);void 0!==i&&Ho(e,n,i,r)}return void function(e,t,n,r){const i=function(e){try{return JSON.stringify(e,(e,t)=>"object"==typeof t&&null!==t&&"id"in t&&"updatedAt"in t?t.id:t)}catch{return}}(n),o=_o.get(e.element);void 0===i?_o.delete(e.element):_o.set(e.element,i),void 0!==i&&void 0!==o&&i!==o&&[...r.values()].includes(!1)&&t.reportUnfaithful?.(e,"changed a block no renderer draws")}(e,n,s,a)}if("string"!=typeof t)return!1;r.innerHTML=Cr(Jr(t,i))})};function jo(e,t,n){const r=(e,t)=>{e.matches(Po)?n.push([e,t]):jo(t,e,n)};let i=e.firstElementChild,o=t.firstElementChild;if(e.children.length===t.children.length){for(;null!==i&&null!==o;i=i.nextElementSibling)r(o,i),o=o.nextElementSibling;return}const s=/* @__PURE__ */new Set;for(const e of t.children)e.matches(Po)||s.add(e.tagName);const a=(e,t)=>e.matches(Po)?!s.has(t.tagName):e.tagName===t.tagName;let l=0;for(;null!==i&&null!==o&&a(o,i);l+=1)r(o,i),i=i.nextElementSibling,o=o.nextElementSibling;const d=Math.min(e.children.length,t.children.length);i=e.lastElementChild,o=t.lastElementChild;for(let e=l;e<d&&null!==i&&null!==o;e+=1){if(!a(o,i))return;r(o,i),i=i.previousElementSibling,o=o.previousElementSibling}}function Ho(e,t,n,r){r&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);const i=r?Do:Io;i.has(n)||(i.add(n),R(`[live-preview] ${r?`LP0413: no renderer for block "${n}", and the markup the server rendered for it is lost.`:`LP0410: no renderer for block "${n}"; keeping what the server rendered for it.`} Register one with registerBlockRenderer().`))}var Wo={name:"html",render(e,t,n){if(hi(t))return void(e.element.textContent="");const r="string"==typeof t?t:ci(t);e.element.innerHTML=Cr(Jr(r,n.sanitizerPolicy))}},qo=/* @__PURE__ */new WeakSet;function Vo(e,t,n,r){if("string"!=typeof n||0===n.length)return{kind:"none"};const i=go(n,r);return isSafeUrl(i)?{kind:"safe",url:i}:(qo.has(e)||(qo.add(e),R(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function Go(e,t=e=>e){return{name:e,render(e,n,r){const i=e.element;if(hi(n))return void function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(i);const o=ci(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName){if("A"===i.tagName){const n=e.hrefField,s=void 0===n||0===n.length?t(o):le(r.allFields,n,r.locale,void 0!==e.locale),a=Vo(i,e.fieldName,s);"safe"===a.kind?i.setAttribute("href",a.url):"unsafe"===a.kind&&i.removeAttribute("href")}i.textContent=o}else i.value=o}}}var Ko=Go("url"),Jo=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,Qo=Go("email",function(e){const t=e.trim();return Jo.test(t)||!t.includes("@")?t:`mailto:${t}`}),Xo=["src","srcset","sizes"],Zo=/* @__PURE__ */new WeakMap;function Yo(e){for(const t of Xo)e.removeAttribute(t);es(e)}function es(e){if("PICTURE"===e.parentElement?.tagName)for(const t of e.parentElement.querySelectorAll("source"))t.remove()}function ts(e,t,n,r){const i=function(e,t){const n=[];for(const[r,i]of Object.entries(e?.sizes??e?.variants??{})){if("string"!=typeof i.url||"number"!=typeof i.width)continue;const e=go(i.url,t);isSafeUrl(e)&&n.push({...i,name:r,url:e,width:i.width})}return n}(n,r),o=e.getAttribute("src"),s=i.find(t=>null!==o&&ns(e,t.url,o))??i.find(t=>t.name===Zo.get(e));void 0===s?.name?Zo.delete(e):Zo.set(e,s.name),null!==o&&(ns(e,t,o)||i.some(t=>ns(e,t.url,o)))||es(e),e.src=s?.url??t;const a=s??n,l=i.filter(e=>rs(e,a)),d=l.length>0?l:i.filter(e=>rs({...e,mimeType:void 0},a));if(0===d.length)return e.removeAttribute("srcset"),void e.removeAttribute("sizes");if("number"==typeof n?.width&&"string"==typeof n.url){const e=go(n.url,r),t={...n,url:e,width:n.width};isSafeUrl(e)&&rs(t,a)&&d.push(t)}const u=/* @__PURE__ */new Set,c=[];for(const e of d)u.has(e.width)||(u.add(e.width),c.push(`${is(e.url)} ${String(e.width)}w`));const h=c.join(", ");e.setAttribute("srcset",h)}function ns(e,t,n){try{return new URL(t,e.baseURI).href===new URL(n,e.baseURI).href}catch{return t===n}}function rs(e,t){if(void 0===t)return!0;if("string"==typeof e.mimeType&&"string"==typeof t.mimeType&&e.mimeType!==t.mimeType)return!1;const{width:n,height:r}=t;return"number"!=typeof n||"number"!=typeof r||"number"!=typeof e.width||"number"!=typeof e.height||Math.abs(e.width*r-e.height*n)<=Math.max(n,e.width)}function is(e){return e.replace(/[\s,]/g,encodeURIComponent)}var os=/^(?:\.{0,2}\/|\S*[/.:]\S*$|.*\.(?:avif|bmp|gif|ico|jpe?g|png|svg|tiff?|webp)$)/i,ss={name:"image",render:/* @__PURE__ */ie((e,t,n)=>{const r=e.element;if("IMG"===r.tagName&&e.altField===e.fieldName&&void 0===e.srcField&&("string"==typeof t||hi(t)))return void(r.alt=t??"");if(hi(t))return void as(r);const i=void 0!==e.locale,{media:o,candidate:s}=function(e,t,n,r){const i=void 0!==e.srcField&&e.srcField.length>0?le(n.allFields,e.srcField,n.locale,r):t,o=po(i);return{media:o,candidate:void 0===o?i:o.url}}(e,t,n,i);if(void 0===o&&"string"==typeof s&&!os.test(s.trim()))return!1;const a=Vo(r,e.fieldName,s,void 0===o?void 0:n.serverURL);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===r.tagName){const t=r;ts(t,a.url,o,n.serverURL);const s=function(e,t,n,r,i){if(void 0!==t&&t.length>0){const e=le(n,t,r,i);return"string"==typeof e?e:void 0}return e?.alt}(o,e.altField,n.allFields,n.locale,i);return void(void 0!==s&&(t.alt=s))}r.style.backgroundImage=`url('${function(e){return e.replace(/['"()\\]/g,"\\$&")}(a.url)}')`}else as(r)})};function as(e){"IMG"===e.tagName?Yo(e):e.style.backgroundImage=""}var ls={name:"upload",render:/* @__PURE__ */ie((e,t,n)=>{const r=e.element;if(hi(t))return void ds(r);const i=po(t);if(void 0===i)return!1;const o=Vo(r,e.fieldName,i.url,n.serverURL);if("none"===o.kind)return!1;if("unsafe"===o.kind)return void ds(r);const s=o.url;if("IMG"===r.tagName){const e=r;return ts(e,s,i,n.serverURL),void(void 0!==i.alt&&(e.alt=i.alt))}if("A"===r.tagName)return r.setAttribute("href",s),void(r.textContent=i.filename??s);const a=escapeHtml(i.filename??s);r.innerHTML=Cr(`<a href="${escapeHtmlAttribute(s)}">${a}</a>`)})};function ds(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):Yo(e)}var us={name:"relationship",render(e,t){const n=e.element;if(hi(t))return n.removeAttribute("href"),void(n.textContent="");if("A"===n.tagName&&!Array.isArray(t)){const r=Vo(n,e.fieldName,fo(t)?.url);"safe"===r.kind?n.setAttribute("href",r.url):"unsafe"===r.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(cs).join(", "):cs(t)}};function cs(e){const t=fo(e);return void 0===t?ci(e):yo(t)??""}var hs={name:"select",render(e,t,n){const r=e.element,i=hi(t)?[]:function(e){return Array.isArray(e)?e.map(ci):[ci(e)]}(t);if("SELECT"!==r.tagName){if("INPUT"===r.tagName&&"radio"===r.type){const e=r;return void(e.checked=i.includes(e.value))}r.textContent=i.map(e=>function(e,t){const n=t.schema?.options;if(!Array.isArray(n))return e;for(const t of n){const n=fo(t);if(void 0!==n&&ci(n.value)===e)return"string"==typeof n.label?n.label:e}return e}(e,n)).join(", ")}else!function(e,t){if(e.multiple)for(const n of Array.from(e.options))n.selected=t.includes(n.value);else e.value=t[0]??""}(r,i)}},fs=/* @__PURE__ */new Set(["","false","0","off","no"]),ps={name:"checkbox",render(e,t){const n=e.element,r=function(e){return"boolean"==typeof e?e:"string"==typeof e?!fs.has(e.trim().toLowerCase()):"number"==typeof e?0!==e:null!=e}(t);"INPUT"!==n.tagName||"checkbox"!==n.type?n.hasAttribute("aria-checked")?n.setAttribute("aria-checked",r?"true":"false"):n.textContent=r?"true":"false":n.checked=r}},gs=/* @__PURE__ */new Map,ms=/* @__PURE__ */new Map;function vs(e,t){const n=e??"";if(null==t)return n;const r=ys(t);return"{}"===r?n:`${n}|${r}`}function ys(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>ys(e)).join(",")}]`;const t=e,n=Object.keys(t).sort(),r=[];for(const e of n){const n=t[e];void 0!==n&&r.push(`${JSON.stringify(e)}:${ys(n)}`)}return`{${r.join(",")}}`}var bs=/* @__PURE__ */new Set(["short","medium","long","full"]),ws=/* @__PURE__ */new Set(["short","medium","long","full"]),Ss=/^[A-Za-z]{3}$/u,As=/^[0-4]$/u;function ks(e){return{kind:"date",options:e}}function Rs(e){return{kind:"number",options:e}}var Ts=/* @__PURE__ */new WeakSet;function Cs(e,t,n,r){if(void 0===t||""===t)return;const i=function(e){const t=e.indexOf(":"),n=-1===t?e:e.slice(0,t),r=-1===t?void 0:e.slice(t+1);switch(n){case"date":return void 0===r?ks({dateStyle:"medium"}):bs.has(r)?ks({dateStyle:r}):void 0;case"time":return void 0===r?ks({timeStyle:"short"}):ws.has(r)?ks({timeStyle:r}):void 0;case"datetime":return void 0===r?ks({dateStyle:"medium",timeStyle:"short"}):bs.has(r)?ks({dateStyle:r,timeStyle:"short"===r?"short":"medium"}):void 0;case"number":if(void 0===r)return Rs({});if(!As.test(r))return;return Rs({minimumFractionDigits:Number(r),maximumFractionDigits:Number(r)});case"currency":if(void 0===r||!Ss.test(r))return;return Rs({style:"currency",currency:r.toUpperCase()});case"percent":return void 0===r?Rs({style:"percent"}):void 0;default:return}}(t);if(void 0!==i){if(i.kind===e)return i.options}else!function(e,t,n){Ts.has(e)||(Ts.add(e),R(`[live-preview] LP0408: data-payload-format="${n}" on "${t}" is not a known format; the default formatting was used. Known: date, time, datetime (each also :short|medium|long|full), number, number:0-4, currency:XXX, percent.`))}(n,r,t)}var Ps={name:"date",render(e,t,n){const r=e.element;if(hi(t))return void("INPUT"===r.tagName?r.value="":(r.removeAttribute("datetime"),r.textContent=""));const i="number"==typeof t?t:ci(t),o=new Date(i),s=!Number.isNaN(o.getTime()),a=String(i);"INPUT"!==r.tagName?("TIME"===r.tagName&&r.setAttribute("datetime",s?o.toISOString():a),r.textContent=s?function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=Cs("date",t.format,t.element,t.fieldName)??Ls;try{return function(e,t){const n=vs(e,t);return fi(ms,n)??pi(ms,n,new Intl.DateTimeFormat(e,t),64)}(r,i).format(e)}catch{return e.toISOString()}}(o,e,n):a):r.value=s?function(e,t){const n=`${String(t.getFullYear()).padStart(4,"0")}-${$s(t.getMonth()+1)}-${$s(t.getDate())}`,r=`${$s(t.getHours())}:${$s(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${r}`:"time"===e?r:t.toISOString()}(r.type,o):a}},Ls={dateStyle:"medium",timeStyle:"short"};function $s(e){return String(e).padStart(2,"0")}var Ns={name:"number",render(e,t,n){const r=e.element;if(hi(t))return void("INPUT"===r.tagName?r.value="":r.textContent="");const i="number"==typeof t?t:Number(ci(t));Number.isNaN(i)?r.textContent=ci(t):"INPUT"!==r.tagName?r.textContent=function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=Cs("number",t.format,t.element,t.fieldName);try{return function(e,t){const n=vs(e,t);return fi(gs,n)??pi(gs,n,new Intl.NumberFormat(e,t),64)}(r,i).format(e)}catch{return String(e)}}(i,e,n):r.value=String(i)}},Fs={name:"array",render:/* @__PURE__ */ie((e,t,n)=>{const r=e.element;if(hi(t))return void(r.textContent="");if(!Array.isArray(t))return!1;const i=e.arrayTemplate;if(void 0!==i&&i.length>0){const e=function(e,t){const n=ai(t);let r="";for(let i=0;i<t.length;i+=1)r+=li(e,t[i],i,ci,n);return r}(i,t),o=n.sanitizerPolicy,s=bi(i),a=di(r);r.innerHTML=Cr(Jr(e,o,s));for(const e of Array.from(r.children))ui(e,a);return}r.textContent=t.map(ci).join(e.arraySeparator??", ")})};function Us(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,n=/* @__PURE__ */new WeakMap,r=/* @__PURE__ */new WeakMap;return{name:"structural-array",render:/* @__PURE__ */ie((i,o,s)=>{const a=hi(o)?[]:o;if(!Array.isArray(a))return!1;const l=i.element,d=i.arrayTemplate;if(void 0===d||0===d.length)return function(e,t,n){e.has(t)||(e.add(t),R(`[live-preview] LP0403: Skipping structural update for "${n}": <${t.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(t,l,i.fieldName),!1;const u=e.get(l),c=xs(l),h=I(u?.values??c.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e}),a),f=function(e,t,n){return void 0===e||e.template!==t||!function(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}(e.domSnapshot,n)}(u,d,c);if(0===h.length&&!f)return e.set(l,{values:a.slice(),template:d,domSnapshot:c}),!1;!function(e,t,n,r,i){const o=i.map(Ms),s=/* @__PURE__ */new Set,a=o.find(e=>!(void 0===e||!s.has(e)&&(s.add(e),1)));if(void 0!==a&&Es(e,t,n,a),o.some(e=>void 0===e)&&Os(e,t,"LP0404",`LP0404: an item of "${n}" has no id and pairs by position, so an insert re-renders every row after it. Give items a stable id.`),r?.length===i.length&&i.length>1){const i=new Set(r.map(Ms).filter(e=>void 0!==e)),s=o.some(e=>void 0!==e&&i.has(e));i.size>0&&!s&&Os(e,t,"LP0406",`LP0406: every key of "${n}" changed at once; the source generates ids per message, so no item can be retained across updates.`)}}(n,l,i.fieldName,u?.values,a);const p=ki({template:d,container:l,patches:h,nextItems:a,store:r,forceRender:f,sanitizerPolicy:s.sanitizerPolicy,onDuplicateKey:(e,t)=>{Es(n,e,i.fieldName,t)}});return null!==p&&(e.set(l,{values:a.slice(),template:d,domSnapshot:xs(l)}),!!p&&void 0)})}}function xs(e){return Array.from(e.children,e=>e.getAttribute(wi))}function Ms(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Es(e,t,n,r){Os(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${r}"; later ones pair by position. Make \`id\` unique per item.`)}function Os(e,t,n,r){let i=e.get(t);void 0===i&&(i=/* @__PURE__ */new Set,e.set(t,i)),i.has(n)||(i.add(n),R(`[live-preview] ${r}`))}var Is=/* @__PURE__ */new Map;function Ds(e,t){return{name:e,render(){L(t)}}}var _s=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),Bs=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"});function zs(e){return void 0===e?void 0:!e}var js,LivePreviewClient=class{#H=new EventEmitter;#W;#q;#V;#R;#n;#G=!1;#K=!1;#J=!1;#Q=null;constructor(e={}){const t=function(e){const t="v1"===e.defaults?Bs:_s;return{...e,skipUnchanged:e.skipUnchanged??t.skipUnchanged,disableReferrerDetection:e.disableReferrerDetection??t.disableReferrerDetection,eventSourcePolicy:e.eventSourcePolicy??t.eventSourcePolicy,sanitizerPolicy:e.sanitizerPolicy??t.sanitizerPolicy}}(e),n=t.serverURL??"";!function(e){if("v1"!==e.defaults&&""!==(e.serverURL??"")&&null==e.mergeDepth)throw new Error("payload-live-preview: `serverURL` needs an explicit `mergeDepth` under the 2.0 defaults — choose the population depth deliberately (0 for none), or pass `defaults: 'v1'` to keep the 1.x default of 1 while migrating (ADR 0007, entry 10).")}({defaults:e.defaults,serverURL:n,mergeDepth:t.mergeDepth});const r=t.debug??isDevMode();this.#n=r?(...e)=>{T("[live-preview]",...e)}:A,this.#W=new OriginDetector(F({additionalOrigins:t.allowedOrigins,enableReferrerDetection:zs(t.disableReferrerDetection),enableLocalhostMatching:zs(t.disableLocalhostMatching)})),this.#W.isProductionUnconfigured&&this.#n("no trusted origin could be detected — set allowedOrigins"),this.#q=new io(function(){const e=[zo,Wo,Ko,Qo,ss,ls,us,hs,{...hs,name:"radio"},ps,Ps,Ns,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[Ds("array","structural arrays"),Ds("blocks","structural arrays")]:[Fs,{...Fs,name:"blocks"}]];return function(e=[]){const t={};for(const n of e)t[n.name]=n;for(const[e,n]of Is)t[e]=n;return Object.freeze(t)}([Oo("text"),Oo("textarea"),...e,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[]:[Us()]])}()),this.#R=new ro({events:this.#H,config:Object.freeze({...t}),registerFieldRenderer:e=>this.#q.register(e),onTransformError:e=>{this.#H.emit("error",{error:e,context:"transform",code:"LP0602"})},log:this.#n}),this.#V=new Ki(F({root:t.root,renderers:this.#q.renderers,resolveRenderer:(e,n)=>t.resolveRenderer?.(e,n)??this.#q.resolve(e),renderRichText:t.renderRichText,internalLinkPattern:t.internalLinkPattern,routeAfterSave:t.routeAfterSave,sanitizerPolicy:t.sanitizerPolicy,transformValue:(e,t,n,r)=>this.#R.applyTransforms(e,t,n,r),originMatcher:e=>this.#W.matches(e),readyTargets:()=>this.#W.enumerate(),emitter:this.#H,dataMerge:""===n?void 0:F({serverURL:n,apiRoute:t.apiRoute,depth:t.mergeDepth,timeoutMs:t.mergeTimeoutMs,fetchFn:t.mergeFetch}),debounceMs:t.debounceMs,heartbeatMs:t.heartbeatMs,intersectionRootMargin:t.intersectionRootMargin,scopeBindingsByOwner:t.scopeBindingsByOwner,skipUnchanged:t.skipUnchanged,revealEditedField:t.revealEditedField,autoBind:t.autoBind,subfieldCoverage:t.subfieldCoverage,eventSourcePolicy:t.eventSourcePolicy,dependencies:t.dependencies,strategies:t.strategies,disableVisibilityGate:t.disableVisibilityGate,visibilityGateThreshold:t.visibilityGateThreshold,enableA11y:t.enableA11y,a11yLocale:t.a11yLocale,onHeartbeatTimeout:()=>{this.#W.unlockOrigin()},lockedOrigin:()=>this.#W.lockedOrigin,validateToken:t.validateToken,log:this.#n})),this.#H.on("connect",e=>{this.#W.lockOrigin(e.origin)}),!1!==t.autoStart&&this.start()}start(){if(this.#K)return!1;if(this.#G)return this.#V.start(),!0;if(!isInPreviewContext())return!1;const e=this.#V.start();return e&&(this.#G=!0),e}suspend(){return!(this.#K||!this.#G)&&this.#V.suspend()}resume(){return!(this.#K||!this.#G)&&this.#V.start()}destroy(){if(null!==this.#Q)return this.#Q;let e,t;this.#K=!0;const n=new Promise((n,r)=>{e=n,t=r});this.#Q=n;const r=()=>{this.#H.removeAllListeners(),this.#J=!0};try{this.#V.destroy(),this.#R.destroyAll().finally(r).then(e,t)}catch(e){r(),t(e)}return n}async use(e){if(this.#K)throw new Error("LivePreviewClient: already destroyed");await this.#R.register(e)}async unuse(e){if(this.#J)throw new Error("LivePreviewClient: already destroyed");await this.#R.unregister(e)}refreshCache(){this.#V.refreshCache()}refreshAfterNavigation(){this.#V.navigationCommit()}get events(){return this.#H}get plugins(){return this.#R.list()}get status(){return this.#V.status}inspect(){return{...this.#V.inspect(),plugins:this.#R.snapshot()}}get updateCount(){return this.#V.updateCount}get destroyed(){return this.#K}};function initLivePreview(e={}){const t=new LivePreviewClient({...e,autoStart:!1});return t.start()?t:null}function setCspCrypto(e){js=e??void 0}function generateCspNonce(e=16){if(!Number.isInteger(e)||e<8)throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(e)}`);const t=function(){if(js?.getRandomValues)return js;const e=globalThis.crypto;return e?.getRandomValues?e:void 0}();if(!t)throw new Error("generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) once at startup, or run with --experimental-global-webcrypto. We won't fabricate a predictable nonce — that would silently defeat the entire CSP.");const n=new Uint8Array(e);return t.getRandomValues(n),function(e){let t="";for(const n of e)t+=String.fromCharCode(n);return("function"==typeof btoa?btoa(t):Buffer.from(e).toString("base64")).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}(n)}function buildFrameAncestors(e={}){const{self:t=!0,origins:n=[],allowNone:r=!1}=e,i=/* @__PURE__ */new Set,o=[];if(r&&!t&&0===n.length)return"'none'";t&&(o.push("'self'"),i.add("'self'"));for(const e of n){const t=e.trim();0===t.length||i.has(t)||(i.add(t),o.push(t))}return o.length>0?o.join(" "):"'none'"}function buildScriptSrcWithNonce(e,t={}){if(0===e.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");const{self:n=!0,extra:r=[],strictDynamic:i=!1}=t,o=[];n&&o.push("'self'"),o.push(`'nonce-${e}'`),i&&o.push("'strict-dynamic'");for(const e of r){const t=e.trim();t.length>0&&o.push(t)}return o.join(" ")}var Hs="payload-live-preview.authorized-preview-context",Ws=Symbol.for(Hs);function isAuthorizedPreviewContext(e){return"object"==typeof e&&null!==e&&!0===e[Ws]&&Object.isFrozen(e)}var qs={basic:{gates:"data updates are applied to bound elements",fallback:"none — every peer has it"},"schema-json":{gates:"field typing from fieldSchemaJSON (Payload 2.x) and the payload-2 profile",fallback:"field types come from DOM heuristics and Lexical auto-detection"},locale:{gates:"locale-aware field resolution (`title_de` before `title`) and the locale on island events",fallback:"bindings resolve the unsuffixed field value"},"preview-token":{gates:"per-message token validation (library extension)",fallback:"messages carry no token; validateToken cannot be satisfied"},"nested-arrays":{gates:"keyed array diffs below the top level",fallback:"array updates replace the whole array"},"recursive-diffs":{gates:"recursive object diffs",fallback:"nested objects re-render as a unit"},"document-events":{gates:"the `documentSave` runtime event, the document-save plugin and the payload-3 profile",fallback:"no documentSave event; a save is not distinguishable from an edit"},"relationship-events":{gates:"the `relationshipUpdate` runtime event and an unconditional re-render of the update that carries it",fallback:"a related document edited in a drawer shows up on the next data update only"}},Vs="__livePreviewRouteRefresh";function registerRouteRefresh(e){const t="undefined"==typeof window?void 0:window;return void 0===t?()=>{}:(t[Vs]=e,()=>{t[Vs]===e&&(t[Vs]=void 0)})}var Gs=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",ProfileFeatureOmitted:"LP0104",OrphanField:"LP0201",UnattributableUpdate:"LP0202",UnboundField:"LP0203",CoverageDefaultChanges:"LP0204",VisibilityGateDeferred:"LP0301",UnsafeAttributeWrite:"LP0401",TextTargetHasChildren:"LP0402",MissingArrayTemplate:"LP0403",StructuralItemUnkeyed:"LP0404",StructuralDuplicateKey:"LP0405",StructuralUnstableKeys:"LP0406",UnsupportedStrategy:"LP0407",UnknownValueFormat:"LP0408",SanitizerDroppedAttribute:"LP0409",UnrenderedBlockKept:"LP0410",UnfaithfulPatch:"LP0411",ServerFormatReplaced:"LP0412",UnrenderedBlockLost:"LP0413",MessageRejected:"LP0501",TokenRejected:"LP0502",ProtocolShapeUnknown:"LP0503",HandlerThrew:"LP0601",TransformThrew:"LP0602",RendererThrew:"LP0603",StartupFailed:"LP0605",ReadyFailed:"LP0606",HydrationWaitTimedOut:"LP0607",AuditRuntimeMissing:"LP0701",AuditNoFrameAncestors:"LP0702",AuditFrameOptionsBlocks:"LP0703",AuditBindingsExposed:"LP0704",AuditGateThresholdExceeded:"LP0705",AuditUnownedBindings:"LP0706",AuditNoBindings:"LP0707",AuditNotAPage:"LP0708",FragmentRequestFailed:"LP0801",FragmentResponseInvalid:"LP0802",FragmentUnauthorized:"LP0803",FragmentSuperseded:"LP0804",RouteRefreshLoop:"LP0805",FragmentStrategyUnavailable:"LP0806",UnboundChangeRefresh:"LP0807",EscalationUnavailable:"LP0808",IslandStartUnavailable:"LP0809",RouteRefreshUnconfirmed:"LP0810",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710",AuditModifierWithoutField:"LP0711"});function bind(e,t){return Ks(e,t)}function bindByPath(e,t){const n=function(e){const t=[],n=new Proxy({},{get(e,r){if("symbol"!=typeof r)return/^\d+$/.test(r)||t.push(r),n}});try{e(n)}catch{}return t}(e);if(0===n.length)throw new Error("bindByPath: the picker did not read any field — return data.<field> instead of a constant");return Ks(n.join("."),t)}function Ks(e,t){if(0===e.length)throw new Error("bind: field name must be a non-empty string");const n={"data-payload-field":e};return void 0!==t?.attribute&&(n["data-payload-attribute"]=t.attribute),void 0!==t?.type&&(n["data-payload-type"]=t.type),!0===t?.richtext&&(n["data-payload-richtext"]=""),!0===t?.html&&(n["data-payload-html"]=""),void 0!==t?.locale&&(n["data-payload-locale"]=t.locale),void 0!==t?.alt&&(n["data-payload-alt"]=t.alt),void 0!==t?.href&&(n["data-payload-href"]=t.href),void 0!==t?.arrayTemplate&&(n["data-payload-array-template"]=t.arrayTemplate),void 0!==t?.format&&(n["data-payload-format"]=t.format),!0===t?.text&&(n["data-payload-text"]=""),void 0!==t?.strategy&&(n["data-payload-strategy"]=t.strategy),void 0!==t?.dependsOn&&t.dependsOn.length>0&&(n["data-payload-depends"]=t.dependsOn.join(",")),!0===t?.anchor&&(n["data-payload-boundary"]=""),n}var Js=/^[a-z][a-z0-9-]{0,63}$/u,Qs=Object.freeze({});function createPreviewBindings(e){const t=isAuthorizedPreviewContext(e.authorization),n=void 0!==e.owner&&e.owner.length>0?e.owner:void 0;return Object.freeze({authorized:t,bind:(e,n)=>t?bind(e,n):Qs,bindByPath:(e,n)=>t?bindByPath(e,n):Qs,owner:()=>t&&void 0!==n?{"data-payload-owner":n}:Qs,boundary:(e,n={})=>{const r=function(e,t){if(!Js.test(e))throw new RangeError(`createPreviewBindings().boundary(): "${e}" is not a registry id — lowercase, starting with a letter, then letters, digits or hyphens (max 64). The runtime would post it and the endpoint would refuse it.`);const n=t.key;if(void 0!==n&&(0===n.length||n.length>128))throw new RangeError(`createPreviewBindings().boundary(): the key for "${e}" must be 1 to ${String(128)} characters.`);const r=t.dependsOn??[];return{"data-payload-fragment":e,...void 0!==n?{"data-payload-fragment-key":n}:{},...r.length>0?{"data-payload-depends":r.join(",")}:{}}}(e,n);return t?r:Qs},covers:(...e)=>{const n=function(e){for(const t of e)if(0===t.length||/[\s,]/u.test(t))throw new RangeError(`createPreviewBindings().covers(): "${t}" is not a field path — a name or a dotted path without spaces or commas.`);return{"data-payload-covers":e.join(" ")}}(e);return t&&e.length>0?n:Qs}})}function Xs(e){const[t,n]=e;return"merge HTTP"===t?`the server answered ${String(n)}`:"merge timeout"===t?`the server did not answer within ${String(n)} ms`:"merge invalid"===t?"the server answered with something other than a document":"merge exception"===t?n instanceof Error?n.message:"the request failed":"the update could not be merged"}var Zs=class{#X;#Z;#W;#Y;#ee=/* @__PURE__ */new Set;#te;#ne;#re=0;#ie=[];#oe=!1;#se;#ae;#le;#de=!1;#ue=!1;constructor(e,t){this.#W=new OriginDetector({...void 0!==t.allowedOrigins?{additionalOrigins:t.allowedOrigins}:{},enableReferrerDetection:t.enableReferrerDetection??!1,...void 0!==t.enableLocalhostMatching?{enableLocalhostMatching:t.enableLocalhostMatching}:{}}),this.#X=new kn({serverURL:t.serverURL,...void 0!==t.apiRoute?{apiRoute:t.apiRoute}:{},...void 0!==t.depth?{depth:t.depth}:{},...void 0!==t.timeoutMs?{timeoutMs:t.timeoutMs}:{},...void 0!==t.fetchFn?{fetchFn:t.fetchFn}:{},log:(...e)=>{this.#ie=e}}),this.#Z=new w(e=>this.#W.matches(e),{onUpdate:e=>{this.#ce(e)},onDocumentEvent:()=>{},sourcePolicy:t.eventSourcePolicy??"parent-or-opener"}),this.#Y=t.target,this.#le=t.document,this.#te={data:e,isLoading:!0,status:"idle",error:void 0,revision:0},this.#ne=this.#te}subscribe=e=>(this.#ee.add(e),this.#oe||this.#he(),()=>{this.#ee.delete(e),0===this.#ee.size&&this.#fe()});getSnapshot=()=>this.#ne;getServerSnapshot=()=>this.#te;#he(){"undefined"==typeof window&&void 0===this.#Y||(this.#oe=!0,this.#Z.attach(this.#Y??window),w.sendReady(this.#pe(),this.#W.enumerate()))}#fe(){this.#oe&&(this.#oe=!1,this.#re+=1,this.#Z.detach(),this.#X.destroy())}#pe(){const e=this.#Y??("undefined"==typeof window?void 0:window);if(void 0===e)return[];const t=[];e.parent!==e&&t.push(e.parent);const n=e.opener;return null!=n&&n!==e&&t.push(n),t}#ge(e){return this.#oe&&e===this.#re}#me(e,t){const n=this.#le;if(void 0===n)return!0;const{locale:r,globalSlug:i,collectionSlug:o}=e;if(void 0!==n.locale&&void 0!==r&&r!==n.locale)return!1;if("global"in n){if(void 0!==i)return i===n.global;if(void 0!==o)return!1}else{if(void 0!==i)return!1;if(void 0!==o&&o!==n.collection)return!1;const e=void 0===o?void 0:we(t);if(void 0!==e)return e===String(n.id)}return this.#ve(n),!1}#ve(e){if(this.#de||!isDevMode())return;this.#de=!0;const t="global"in e?`global "${e.global}"`:`collection "${e.collection}", id "${String(e.id)}"`;console.warn(`[payload-live-preview] This hook previews ${t} and ignored an update that does not say which document it is for: Payload 2 sends no collection or global slug, and a create screen has no id yet.`)}async#ce(e){const t=e.data;if(void 0===t)return;if(void 0!==e.fieldSchemaJSON&&!this.#ue&&isDevMode()&&(this.#ue=!0,console.warn(v)),!this.#me(e,t))return;const n=this.#re+=1;void 0!==e.fieldSchemaJSON&&(this.#se=e.fieldSchemaJSON);const r=this.#se;void 0!==e.locale&&(this.#ae=e.locale);const i=void 0===r?e.locale:this.#ae;if(this.#ye({...this.#ne,isLoading:!0}),!this.#ge(n))return;this.#ie=[];const o=await this.#X.merge({data:t,...void 0===r?{}:{schema:r},...void 0!==e.collectionSlug?{collectionSlug:e.collectionSlug}:{},...void 0!==e.globalSlug?{globalSlug:e.globalSlug}:{},...void 0!==i?{locale:i}:{}});this.#ge(n)&&"superseded"!==o.status&&("unavailable"!==o.status?this.#ye({data:o.doc,isLoading:!1,status:"live",error:void 0,revision:n}):this.#ye({...this.#ne,isLoading:!1,status:"unavailable",error:new Error(`live preview: ${Xs(this.#ie)}`)}))}#ye(e){const t=this.#ne;if(t.data!==e.data||t.isLoading!==e.isLoading||t.status!==e.status||t.error!==e.error||t.revision!==e.revision){this.#ne=e;for(const e of[...this.#ee])e()}}};function createDocumentSession(e,t){return new Zs(e,t)}var Ys=!0;export{Hs as AUTHORIZED_PREVIEW_BRAND_KEY,g as CAPABILITY_DECLARATIONS,qs as CAPABILITY_DOCUMENTATION,Ys as CORE_ENTRY,Gs as DIAGNOSTIC_CODES,EventEmitter,dt as ISLAND_EVENT,p as LIBRARY_PROTOCOL_VERSION,LivePreviewClient,OriginDetector,m as PROTOCOL_CAPABILITIES,e as VERSION,bind,bindByPath,buildFrameAncestors,buildScriptSrcWithNonce,createDocumentSession,createPreviewBindings,detectInitialLocale,detectProtocolProfile,escapeHtml,escapeHtmlAttribute,generateCspNonce,hasCapability,initLivePreview,isAuthorizedPreviewContext,isDevMode,isExternalHttpUrl,isInIframe,isInPopup,isInPreviewContext,isInsideIsland,isSafeUrl,negotiateProtocol,registerRouteRefresh,sanitizeHtml,setCspCrypto,setSanitizerDocument};
|
|
2
2
|
//# sourceMappingURL=core.js.map
|