payload-live-preview 2.0.5 → 2.0.6

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.
Files changed (44) hide show
  1. package/README.md +3 -2
  2. package/dist/adapters/astro/index.js +1 -1
  3. package/dist/adapters/astro/index.js.map +1 -1
  4. package/dist/adapters/astro/middleware-entry.js +1 -1
  5. package/dist/adapters/astro/middleware-entry.js.map +1 -1
  6. package/dist/adapters/nextjs/index.js +1 -1
  7. package/dist/adapters/nextjs/index.js.map +1 -1
  8. package/dist/adapters/nuxt/index.js +1 -1
  9. package/dist/adapters/nuxt/index.js.map +1 -1
  10. package/dist/adapters/sveltekit/index.js +1 -1
  11. package/dist/adapters/sveltekit/index.js.map +1 -1
  12. package/dist/client.cjs +1 -1
  13. package/dist/client.cjs.map +1 -1
  14. package/dist/client.js +1 -1
  15. package/dist/client.js.map +1 -1
  16. package/dist/core.cjs +1 -1
  17. package/dist/core.cjs.map +1 -1
  18. package/dist/core.js +1 -1
  19. package/dist/core.js.map +1 -1
  20. package/dist/fragment.cjs +1 -1
  21. package/dist/fragment.cjs.map +1 -1
  22. package/dist/fragment.js +1 -1
  23. package/dist/fragment.js.map +1 -1
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.js +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/lean.cjs +1 -1
  29. package/dist/lean.cjs.map +1 -1
  30. package/dist/lean.js +1 -1
  31. package/dist/lean.js.map +1 -1
  32. package/dist/lexical.cjs +1 -1
  33. package/dist/lexical.cjs.map +1 -1
  34. package/dist/lexical.js +1 -1
  35. package/dist/lexical.js.map +1 -1
  36. package/dist/plugins.cjs +1 -1
  37. package/dist/plugins.cjs.map +1 -1
  38. package/dist/plugins.js +1 -1
  39. package/dist/plugins.js.map +1 -1
  40. package/dist/structural.cjs +1 -1
  41. package/dist/structural.cjs.map +1 -1
  42. package/dist/structural.js +1 -1
  43. package/dist/structural.js.map +1 -1
  44. package/package.json +3 -1
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var e="2.0.5";function t(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).")}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 n="payload-live-preview-a11y",r=/* @__PURE__ */new WeakMap;function i(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}var o=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=r.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},r.set(e,t)),t.refs+=1,t}(e);const t=this.lease,o=t.element;if(o?.isConnected&&o.ownerDocument===e)return o;if(null!==o){const e=t.owned;i(t),e&&o.remove()}let s=e.getElementById(n);return t.owned=null===s,null===s&&(s=e.createElement("div"),s.id=n,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),s.setAttribute("style","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)),t.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`)}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 n=e.element;null!==n&&i(e),e.owned&&n?.remove(),e.element=null,r.delete(t)}say(e){const t=this.mount(),n=this.lease;if(null===t||null===n)return;let r=n.messageNode;r?.parentNode!==t?(r?.remove(),r=t.ownerDocument.createTextNode(t.hasChildNodes()?` ${e}`:e),n.messageNode=r,t.appendChild(r)):r.data=null===r.previousSibling?e:` ${e}`,null!==n.timer&&clearTimeout(n.timer);const o=setTimeout(()=>{n.timer===o&&n.element===t&&i(n)},1500);n.timer=o}};function s(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const e=a(n);e&&t.push(e)}return t}function a(e){if("object"!=typeof e||null===e)return;const t=e,n=t.name,r=t.type;if("string"!=typeof n||0===n.length)return;if("string"!=typeof r||0===r.length)return;const i=s(t.fields),o=function(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if("object"!=typeof n||null===n)continue;const e=n,r=e.slug;if("string"!=typeof r||0===r.length)continue;const i=s(e.fields);t.push({...e,slug:r,fields:i})}return t}(t.blocks),a={...t,name:n,type:r};return i.length>0?a.fields=i:delete a.fields,o.length>0?a.blocks=o:delete a.blocks,a}function l(e,t){return void 0===e||t(e)}function u(e,t){return null==e||t(e)}function d(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}var c=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],f={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"}},h=Object.keys(f);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 h)(i>=f[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 p(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function m(e,t){return e.generation===t.generation&&e.revision===t.revision}var g=class{matcher;handlers;boundListener=void 0;attachedTarget=void 0;generation=0;revision=0;queueHead=void 0;queueTail=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)}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&&!d(t.data))&&u(t.fieldSchemaJSON,e=>Array.isArray(e))&&u(t.globalSlug,e=>"string"==typeof e)&&u(t.collectionSlug,e=>"string"==typeof e)&&u(t.locale,e=>"string"==typeof e)&&u(t.ready,e=>"boolean"==typeof e)&&u(t.previewToken,e=>"string"==typeof e)&&u(t.protocolVersion,e=>"number"==typeof e)}(i)?void this.dispatchUpdate(function(e){const t={...e};for(const e of c)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);if(!Array.isArray(t.fieldSchemaJSON))return t;let n;try{n=s(t.fieldSchemaJSON)}catch{n=[]}return{...t,fieldSchemaJSON:n}}(i),r,t):void this.reportInvalid("shape",r,t);case"payload-document-event":return function(e){const t=e;return l(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&l(t.slug,e=>"string"==typeof e)&&l(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=d(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){void 0===r?this.invokeHandler(n,this.handlers.onUpdate,e,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{p(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 v(e){return(...t)=>{try{p(e(...t))}catch{}}}function y(){}var b=v((...e)=>console.error(...e)),w=v((...e)=>console.warn(...e)),S=v((...e)=>console.debug(...e)),A={"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'"},k=/* @__PURE__ */new Set;function T(e){k.has(e)||(k.add(e),w(`[live-preview] LP0104: this page carries the lean runtime, which leaves out ${e} (${A[e]}). The elements are left as the server rendered them. Remove \`runtime: LEAN_RUNTIME\` to get the full runtime.`))}function C(e){return"undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e){return!1!==e.enableA11y&&T("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 o(e.a11yLocale,n)}(e)}function $(e){if("undefined"==typeof window)return;const t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),g.sendReady(t,e)}function x(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}var R=/* @__PURE__ */new Set(["tabs","row","collapsible"]);function N(e,t=""){const n=/* @__PURE__ */new Map;return P(e,t,n),n}function P(e,t,n){for(const r of e){if(R.has(r.type)){r.fields&&P(r.fields,t,n);continue}const e=""===t?r.name:`${t}.${r.name}`;if(n.set(e,r),"group"===r.type)r.fields&&P(r.fields,e,n);else if("array"===r.type&&r.fields)P(r.fields,`${e}.*`,n);else if("blocks"===r.type&&r.blocks)for(const t of r.blocks)P(t.fields,`${e}.*.${t.slug}`,n)}}function E(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 F(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function L(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function M(e,t){return t.every(e=>void 0!==F(e))?function(e,t){const n=[],r=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=F(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=F(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 u=e[l];L(u)===L(s)?(l!==o&&n.push({kind:"move",from:l,to:o,value:s}),O(u,s)||n.push({kind:"update",index:o,value:s})):n.push({kind:"replace",index:o,oldValue:u,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)O(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 O(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 U={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"},I=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),_=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,j=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,D=/^[\\/]{2}/,z=/[\t\n\r]/g;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(z,"");if(0===t.length)return!1;if(_.test(t))return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(D.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return I.has(e.protocol)}catch{return j.test(t)}}function isExternalHttpUrl(e){const t=e.trim().replace(z,"");return/^https?:\/\//i.test(t)||D.test(t)}var B=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),W=/* @__PURE__ */new Set(["href","src","poster","cite","action","xlink:href","data"]);function H(e){return!e.startsWith("on")&&!B.has(e)}function V(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function q(e,t,n,r){if(t.reportedUnfaithful.has(n.element))return;t.reportedUnfaithful.add(n.element),t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName);const i=e.onUnfaithfulPatch;"ignore"!==i&&("warn"!==i?(e.log("LP0411",n.fieldName,r),t.unfaithfulPatches.push(n)):e.warn(`[live-preview] LP0411: "${n.fieldName}" ${r}`))}function G(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}var K=/* @__PURE__ */new Set(["date","number","checkbox"]);function J(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function Z(e){const t=e.trim();return JSON.stringify(t.length>40?`${t.slice(0,40)}…`:t)}var X=/* @__PURE__ */new WeakSet;function Q(e){return X.add(e),e}function Y(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}}var ee=class{previous=null;diff(e,t){const n=this.previous,r=null===n,i=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set;for(const[t,r]of Object.entries(e)){const e=Y(r);i.set(t,e),null!==n&&void 0!==e&&n.get(t)===e||o.add(t)}if(null!==n)for(const e of n.keys())i.has(e)||o.add(e);this.previous=i;const s=/* @__PURE__ */new Set;for(const[e,n]of Object.entries(t))if(o.has(e))for(const e of n)s.add(e);return{changed:o,invalidated:s,baseline:r}}reset(){this.previous=null}},te="data-payload-fragment";function ne(e){return e.closest(`[${te}]`)}function re(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==ne(e)?"fragment":null!==e.closest("head")?"route":"patch"}function ie(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function oe(e){return"string"==typeof e&&e.length>0}function se(e,t){return null!==t&&void 0!==e&&t.includes(e)}function ae(e){const t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}var le=/* @__PURE__ */new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function ue(e,t,n){const r=e.get(t);return void 0!==r&&(!1===n||r.some(e=>se(e.owner,n)))}function de(e,t,n){const r=`${t}.`;for(const[t,i]of e.entries())if(t.startsWith(r)){if(!1===n)return!0;if(i.some(e=>se(e.owner,n)))return!0}return!1}function ce(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 fe(e,t,n){let r;return i=>{if(ue(e,i,n))return!0;const o=ce(i,t);return!(o===i||!ue(e,o,n))||!!de(e,i,n)||!(o===i||!de(e,o,n))||(r??=function(e,t){const n=/* @__PURE__ */new Set;for(const[r,i]of e.entries())for(const e of i)(!1===t||se(e.owner,t))&&void 0!==e.locale&&n.add(`${r}_${e.locale}`);return n}(e,n),r.has(i))}}function he(e,t,n,r){const i=fe(e,n,r),o=[];for(const e of t)le.has(e)||i(e)||o.push(e);return o}var pe=/* @__PURE__ */new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),me={},ge=class{rawChanges=new ee;resolved=null;queued=null;pending=null;timer=null;openUntil=0;decide(e,t){const n=t.message.data??{},{changed:r}=this.rawChanges.diff(n,me);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(ye(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(`[${te}]`)}(e))return{merge:!1,fields:n};const i=this.resolved;if(null===i)return this.resolved=n,{merge:!0,fields:n};const o={...i};let s=t.forceRender;for(const a of r){const r=n[a];if(le.has(a)){o[a]=r;continue}const l=ve(a,i[a],r,e.cache,t.schemaIndex);"own"!==l&&(s=!0),"keep"!==l&&(o[a]=r)}return this.resolved=o,{merge:s,fields:o}}request(e,t,n){const r=Date.now();return r>=this.openUntil?(this.dropQueued(),this.openUntil=r+t,{leading:!0,result:e.merge(n)}):(this.queued=n,this.openUntil=r+t,this.pending??=function(){let e;return{promise:new Promise(t=>{e=t}),settle:e}}(),null!==this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush(e)},t),{leading:!1,result:this.pending.promise})}recordMerged(e){this.resolved=e}destroy(){this.dropQueued(),this.openUntil=0}dropQueued(){null!==this.timer&&clearTimeout(this.timer),this.timer=null,this.queued=null,this.pending?.settle({status:"superseded"}),this.pending=null}flush(e){const t=this.pending,n=this.queued;this.timer=null,this.pending=null,this.queued=null,null!==t&&null!==n&&e.merge(n).then(t.settle,()=>{t.settle({status:"unavailable"})})}};function ve(e,t,n,r,i){return be(n)?!be(t)||function(e,t,n){const r=void 0===n?void 0:E(n,e);return void 0!==r&&!pe.has(r.type)||!0===t.get(e)?.some(ye)||de(t,e,!1)}(e,r,i)?"keep":null==t?"ask":"own":"ask"}function ye(e){return!pe.has(e.fieldType)}function be(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function we(e){return!0===e?.includes(".")}var Se=class{negotiation=negotiateProtocol(void 0);observed=/* @__PURE__ */new Set;observe(e,t){const n=e.filter(e=>!this.observed.has(e));if(0!==n.length){for(const e of n)this.observed.add(e);this.negotiation=negotiateProtocol(this.negotiation.theirs,this.observed),t("protocol",`observed=${n.join(",")}`)}}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 Ae(e){return null!==e&&e.forceRender&&!e.completed}var ke=class{lastIdentity=void 0;edit(e){const t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;const n=JSON.stringify([t.entitySlug,ae(t),t.updatedAt]),r=n!==this.lastIdentity;return this.lastIdentity=n,r&&function(e,t){const n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;const r=ae(e),i=ae(t.data??{});return void 0!==r&&void 0!==i&&r!==i}(t,e)?t:null}};function Te(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var Ce=class{#e;reveal(e,t,n){return e===this.#e?"skipped-same":(this.#e=e,function(e,t){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:Te(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){this.#e=void 0}},$e=class{seen=/* @__PURE__ */new Map;note(e,t,n){const r=Y(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}},xe=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;warnedEscalationUnavailable=!1;warnedProtocolShape=!1;reportedUnfaithful=/* @__PURE__ */new WeakSet;checkedServerFormat=/* @__PURE__ */new WeakSet;unfaithfulPatches=[];unfaithfulCount=0;escalatedCount=0;unfaithfulFields=/* @__PURE__ */new Set;autoBindSearchMs=void 0;autoBindGuesses=null;warnedForeignSource=!1;lastAppliedIdentity=/* @__PURE__ */new WeakMap;revealLedger=new $e;fragmentStats={rendered:0,failed:0,superseded:0};routeStats={refreshes:0,failed:0,refused:0,loopStopped:0};fragmentController=null;routeController=null;routeRetry=null;routeRefreshOwed=!1;readyTimers=[];revealer=new Ce;changes=new ee;merges=new ge;protocol=new Se;relationships=new ke;isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){e.completed||(e.completed=!0,this.completedCount+=1)}abortStrategies(){null!==this.routeRetry&&(clearTimeout(this.routeRetry),this.routeRetry=null,this.routeRefreshOwed=!0);for(const e of["fragmentController","routeController"]){const t=this[e];null!==t&&(this[e]=null,t.abort())}}},Re=class{constructor(e,t){this.deps=e,this.state=t,this.instanceContext=x({renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,reportUnfaithful:(n,r)=>{q(e,t,n,r)}})}deps;state;instanceContext;apply(e){const{deps:t,state:n}=this,r=n.activeUpdate;if(null===r||void 0===e.revision||!m(r.revision,e.revision)||!n.isCurrent(r))return!1;const{target:i,value:o}=e,s=void 0!==r.schemaIndex?E(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(U,e))return U[e]}(t);if(void 0!==e)return e}return e.fieldType}(i,s?.type);"text"===l&&!0!==i.explicitFieldType&&function(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)}(o)&&(l="richText");try{a=t.resolveRenderer(l,i)}catch(e){return this.fail(r,e)}if(!n.isCurrent(r))return!1;const u=t.emitter.listenerCount("elementUpdate")>0,d=u?"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 f={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)}(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(!H(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 W.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}"`),!1}else{if(void 0===a)return t.log("no renderer for",l),q(t,n,i,`has no renderer for "${l}"`),!1;{const e=function(e,t,n,r){if("ignore"===e.onUnfaithfulPatch)return;if(void 0!==n.format||!K.has(r))return;if(t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);const i=J(n.element);return i.trim().length>0?i:void 0}(t,n,i,l),r=function(e,t,n,r){return e.render(t,n,r)}(a,i,o,f);if(!1===r&&function(e){return X.has(e.render)}(a))return q(t,n,i,`is a value ${a.name} cannot render`),!1;void 0!==e&&function(e,t,n){const r=J(t.element);r!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${Z(n)}, the patch wrote ${Z(r)} — 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)}}}catch(e){return this.fail(r,e)}if(!n.isCurrent(r))return!1;u&&t.emitter.emitWhile("elementUpdate",{element:i.element,fieldName:i.fieldName,previousValue:d,nextValue:o,revision:r.revision.revision,receivedAt:r.receivedAt,source:"patch"},()=>n.isCurrent(r));const h=n.isCurrent(r);return h&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(i.element,e.valueIdentity):n.lastAppliedIdentity.delete(i.element)),h}fail(e,t){if(!this.state.isCurrent(e))return!1;const n=t instanceof Error?t:new Error(String(t));return this.deps.emitter.emitWhile("error",{error:n,context:"renderer",code:"LP0603"},()=>this.state.isCurrent(e)),!1}};function Ne(...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 Pe(e,t){const n={};for(const r of t)r!==e&&(n[r]=[e]);return n}var Ee="payload-live-preview:update",Fe="data-payload-island",Le=`astro-island, [${Fe}]`;function Me(e){return"patch"===e.getAttribute(Fe)}function Oe(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(Fe)}(e)&&!Me(e)}function isInsideIsland(e){let t=e;for(;null!==t;){if(Oe(t))return!0;t=t.parentElement}return!1}var Ue="data-payload-field",Ie="data-payload-type",_e="data-payload-attribute",je="data-payload-href",De="data-payload-src",ze="data-payload-alt",Be="data-payload-array-template",We="data-payload-array-separator",He="data-payload-locale",Ve="data-payload-richtext",qe="data-payload-html",Ge="data-payload-array",Ke="data-payload-structural",Je="data-payload-owner",Ze="data-payload-depends",Xe="data-payload-strategy",Qe="data-payload-boundary",Ye="data-payload-guessed",et=[Ue,Ie,_e,je,De,ze,Be,We,He,Ve,qe,Ge,Ke,Je,Ze,Xe,Qe,"type"],tt=`[${Ue}]`,nt=`[${Je}]`;function rt(e){const t=e.closest(nt)?.getAttribute(Je);return null==t||0===t.length?void 0:t}var it=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,ot=/* @__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 st(e){return ot.has(e)||it.test(e)}var at=class{entriesByField=/* @__PURE__ */new Map;entryByElement=/* @__PURE__ */new WeakMap;filter;count=0;dependencies=null;islandRoots=[];constructor(e={}){this.filter=e.filter??ut}dependencyMap(){if(null!==this.dependencies)return this.dependencies;const e=[];for(const t of this.values())void 0!==t.dependsOn&&e.push(Pe(t.fieldName,t.dependsOn));return this.dependencies=Ne(...e),this.dependencies}get islands(){return this.islandRoots}buildFromRoot(e){const t=performance.now();this.clear();let n=0;for(const t of e.querySelectorAll(tt))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){const t=[];for(const n of e.querySelectorAll(Le))Me(n)||t.push(n);return t}(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=[]}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(Ue);if(null===t||0===t.length)return;const n=e.getAttribute(Ie),r=e.getAttribute(_e),i=e.getAttribute(je),o=e.getAttribute(De),s=e.getAttribute(ze),a=e.getAttribute(Be),l=e.getAttribute(We),u=e.getAttribute(He),d=e.getAttribute("data-payload-format"),c=rt(e),f=function(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}(e.getAttribute(Ze)),h=e.getAttribute(Xe),p=e.getAttribute(Ye),m=ne(e);return{element:e,fieldName:t,fieldType:lt(e),explicitFieldType:null!==n&&st(n),strategyKind:re(e)??"unknown",...null!==m?{fragmentBoundary:m}:{},...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!==u&&u.length>0?{locale:u}:{},...null!==d&&d.length>0?{format:d}:{},...void 0!==c?{owner:c}:{},...f.length>0?{dependsOn:f}:{},...null!==h&&h.length>0?{strategy:h}:{},...e.hasAttribute(Qe)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}};function lt(e){const t=e.getAttribute(Ie);if(null!==t&&st(t))return t;if(e.hasAttribute(Ve))return"richText";if(e.hasAttribute(qe))return"html";if(e.hasAttribute(Ke))return"structural-array";if(e.hasAttribute(Ge))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 ut(){return!0}function dt(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 ct(e){return dt(e,128)&&!e.includes("?")&&!e.includes("#")}var ft=class{serverURL;apiRoute;depth;fetchFn;log;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=v(e.log??y)}canMerge(e){return null!==this.endpointOf(e)}endpointOf(e){try{const n=e.globalSlug;if(n)return ct(n)?`globals/${encodeURIComponent(n)}`:null;const r=e.collectionSlug??"",i=e.data.id;return ct(r)&&("number"==typeof(t=i)?Number.isFinite(t):"string"==typeof t&&dt(t,512))?`${encodeURIComponent(r)}/${encodeURIComponent(String(i))}`:null}catch{return null}var t}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};const t=this.attempt+=1,n=this.inflight;this.inflight=null;let r=null;const i=()=>this.attempt!==t;try{if(n?.abort(),i())return{status:"superseded"};const t=this.endpointOf(e);if(null===t)return i()?{status:"superseded"}:{status:"unavailable"};const o=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===o)return{status:"unavailable"};r=new AbortController,this.inflight=r;const s=`${this.serverURL}${this.apiRoute}/${t}`,a=await o(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:JSON.stringify({data:e.data,depth:this.depth,flattenLocales:!1,locale:e.locale}),signal:r.signal});if(i())return{status:"superseded"};if(!a.ok)return this.log("merge HTTP",a.status,s),{status:"unavailable"};const l=await a.json();return i()?{status:"superseded"}:null===l||"object"!=typeof l||Array.isArray(l)?(this.log("merge invalid",s),{status:"unavailable"}):{status:"merged",doc:l}}catch(e){return i()?{status:"superseded"}:(this.log("merge exception",e),{status:"unavailable"})}finally{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}}},ht={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},pt={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},mt={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1};function detectProtocolProfile(e){return e.has("schema-json")?ht:e.has("document-events")||e.has("relationship-events")?pt:mt}var gt=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:[...et]})}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)||!function(e){for(const t of e){if("attributes"===t.type&&null!==t.attributeName&&et.includes(t.attributeName)&&(t.attributeName===Ue||t.attributeName===Je||1===t.target.nodeType&&t.target.hasAttribute(Ue)))return!0;for(const e of t.addedNodes)if(vt(e))return!0;for(const e of t.removedNodes)if(vt(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 vt(e){if(1!==e.nodeType)return!1;const t=e;return t.hasAttribute(Ue)||null!==t.querySelector(`[${Ue}]`)}var yt="[data-payload-field]";function bt(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewHydration??={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]}}function wt(){const e=bt();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{}const o=n?.containerInfo;void 0===e.onCommit?e.commits.push(o):e.onCommit(o)}}function St(e){e.committed=!0;const t=e.waiters;e.waiters=[];for(const e of t)e()}function At(e,t){const n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function kt(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,At(e,i),t("timed-out")},n),()=>{null!==r&&clearTimeout(r),r=null,At(e,i)}}var Tt="__vue_app__";function Ct(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewVueHydration??={armed:!1,committed:!1,waiters:[]}}function $t(e){return Object.prototype.hasOwnProperty.call(e,Tt)?e[Tt]:void 0}function xt(){const e=Ct();if(void 0===e||e.armed)return;e.armed=!0;const t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,Tt)&&Object.defineProperty(t,Tt,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,Tt,{value:e,writable:!0,configurable:!0,enumerable:!0});const t=Ct();void 0===t||t.committed||null===this.querySelector(yt)||function(e,t){const n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?St(e):n.hook("app:suspense:resolve",()=>{e.committed||St(e)})}(t,e)}})}function Rt(e){if(void 0===e.hydration)return void e.startNow();const t=t=>{e.later(()=>{Nt(e,t)})},n="react"===e.hydration?function(e,t=5e3){wt();const n=bt();if(void 0===n)return null;if(void 0===n.onCommit){const e=e=>{!n.committed&&function(e){const t=e;return 9===t?.nodeType||null!=t?.querySelector?.(yt)}(e)&&St(n)};n.onCommit=e;for(const t of n.commits.splice(0))e(t)}return kt(n,e,t)}(t):function(e,t,n=5e3){xt();const r=Ct();return void 0===r?null:(!r.committed&&function(e){for(let t=e.querySelector(yt);null!==t;t=t.parentElement)if(void 0!==$t(t))return!0;return!1}(e)&&St(r),kt(r,t,n))}(e.root,t);null!==n?(e.defer(n),e.hydrated("waiting")):Nt(e,"committed")}function Nt(e,t){e.hydrated(t),"timed-out"===t&&e.warn(`[live-preview] LP0607: no ${"react"===e.hydration?"React commit":"Vue mount"} in ${String(5e3)} ms; started without waiting for hydration.`),e.startNow()}var Pt=class{timeoutMs;onTimeout;handle=null;lastKick=0;constructor(e){this.timeoutMs=e.timeoutMs??0,this.onTimeout=e.onTimeout}kick(){if(this.lastKick=Date.now(),this.timeoutMs<=0)return;null!==this.handle&&clearTimeout(this.handle);const e=setTimeout(()=>{this.handle===e&&(this.handle=null,this.onTimeout())},this.timeoutMs);this.handle=e}stop(){null!==this.handle&&(clearTimeout(this.handle),this.handle=null)}get lastKickAt(){return this.lastKick}get pending(){return null!==this.handle}},Et=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)}},Ft=/* @__PURE__ */new Set(["true","false","yes","no","on","off"]),Lt=/^[\d\s.,:+/-]+$/u,Mt=/^[a-z][a-z0-9_-]*$/u,Ot=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,Ut=/* @__PURE__ */new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]);function It(e,t=13){if("string"!=typeof e)return!1;const n=e.trim();return!(n.length<t||Lt.test(n)||Ft.has(n.toLowerCase())||Mt.test(n)||Ot.test(n))}function _t(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function jt(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(le.has(r))continue;const e=ce(r,t);if(It(o,n))i(o.trim(),e,!1);else if(_t(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))!le.has(t)&&It(r,n)&&i(r.trim(),`${e}.${t}`,!1)}return r}function Dt(e){if("http://www.w3.org/1999/xhtml"!==e.namespaceURI||Ut.has(e.tagName))return!0;if(e.hasAttribute(Ue)||e.hasAttribute("data-payload-no-bind")||e.hasAttribute("data-payload-owned")||Oe(e))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function zt(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 Bt(e){return H(e)&&!e.startsWith("data-payload-")&&"value"!==e}function Wt(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 Ht(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(Dt(n))continue;const e=zt(n),r=void 0===e?void 0:t.values.get(e);null==r||r.media||(Wt(t,n,r).text=r.field);for(const e of n.getAttributeNames()){if(!Bt(e))continue;const r=t.values.get(n.getAttribute(e)??"");null!=r&&(!r.media||"IMG"===n.tagName&&"src"===e)&&Wt(t,n,r).attributes.set(e,r)}Ht(n,t)}}function Vt(e,t,n){const r=e.tagName;if(void 0!==t){const i={[Ue]:t};if("A"===r){const e=n.get("href");void 0===e?i[Ie]="text":e!==t&&(i[je]=e)}return{element:e,fieldName:t,matched:zt(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:{[Ue]:t,...void 0!==r&&r!==t?{[ze]: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:{[Ue]:s,[_e]:o}}}function qt(e,t){const n={values:t,byElement:/* @__PURE__ */new Map,byField:/* @__PURE__ */new Map};t.size>0&&!Dt(e)&&Ht(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=Vt(e,n,o);void 0!==s&&i.push(s)}return i}function Gt(e){return 9===e.nodeType?e.body:e}function Kt(e,t,n,r){const i=[];for(const o of t){const{element:t}=o;if(!t.hasAttribute(Ue)&&(!1===n||se(rt(t),n))){for(const[e,n]of Object.entries(o.stamps))t.setAttribute(e,n);if(t.setAttribute(Ye,o.matched),void 0!==e.cache.add(t))e.observers.observeElement(t),e.log("autoBind",o.fieldName,"→",`<${t.tagName.toLowerCase()}>`,o.attribute??"text",JSON.stringify(o.matched),r),i.push(o);else{for(const e of Object.keys(o.stamps))t.removeAttribute(e);t.removeAttribute(Ye)}}}return i}var Jt=/* @__PURE__ */new Set(["__proto__","prototype","constructor"]);function Zt(e,t,n,r=!1){if(r&&void 0!==n){const r=Xt(e,`${t}_${n}`);if(void 0!==r)return r}const i=Xt(e,t);if(void 0!==i)return i;if(t.includes(".")){let n=e,r=!0;for(const e of t.split(".")){if(Jt.has(e)||null===n||"object"!=typeof n){r=!1;break}if(n=Xt(n,e),void 0===n){r=!1;break}}if(r)return n}return void 0===n?void 0:Xt(e,`${t}_${n}`)}function Xt(e,t){if(!Jt.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Qt(e,t,n,r){return Zt(e,n,t.locale??r,void 0!==t.locale)}function Yt(e,t,n,r){const i=Y(t);if(void 0===i)return;const o=[e.hrefField,e.srcField,e.altField];let s=i;for(const t of o){if(void 0===t||0===t.length)continue;const i=Y(Qt(n,e,t,r));if(void 0===i)return;s+=`|${t}=${i}`}return s}function en(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="${ce(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 tn(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function nn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var rn="payload-live-preview",on=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function sn(){const e=globalThis,t=e[on];if(void 0!==t)return t;const n={};return e[on]=n,n}function an(e){const t=function(){const e=sn();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(rn,{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===t?e:t.createHTML(e)}var ln=/* @__PURE__ */new Set(["open","value","checked","selected"]);function un(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function dn(e){if(e.tagName.toLowerCase().includes("-"))return!0;if(e.hasAttribute(Fe)||e.hasAttribute("data-payload-owned"))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function cn(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!dn(e)&&!dn(t)}(e,t))return t;const r=mn(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||ln.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=un(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 u=e.firstChild,d=0;for(let t=0;t<l.length;t+=1){const i=l[t];let c=null,f=i instanceof Element?un(i,n):void 0;if(void 0!==f&&a.has(f)&&(f=void 0),void 0!==f){a.add(f);const e=r.get(f);if(void 0!==e&&!s.has(e)&&(c=fn(e,i,n)===e?e:null,null===c)){e.replaceWith(i),s.add(i),u=i.nextSibling;continue}}else{for(;d<o.length;){const r=o[d];if(d+=1,!s.has(r)){if(pn(r,i)){c=fn(r,i,n)===r?r:null,null===c&&(e.replaceChild(i,r),s.add(i),u=i.nextSibling);break}if(r instanceof Element){const n=l[t+1];if(!(i instanceof Element)||void 0!==n&&pn(r,n)){d-=1;break}e.replaceChild(i,r),s.add(i),u=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,r),s.add(i),u=i.nextSibling;break}}}if(null===c&&s.has(i))continue}const h=c??i;for(s.add(h);null!==u&&u!==h&&!s.has(u)&&hn(u);)u=u.nextSibling;h!==u&&e.insertBefore(h,u),u=h.nextSibling}for(const t of Array.from(e.childNodes))s.has(t)||t.remove()}(e,t,n),gn(r),e}function fn(e,t,n){return e instanceof Element&&t instanceof Element?dn(e)&&dn(t)?e:cn(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function hn(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function pn(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function mn(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 gn(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{}}var vn=/* @__PURE__ */new Set;function yn(e){vn.has(e)||(vn.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)":"List it in `allowedDataAttributes` if the page needs it, or set `sanitizerPolicy: 'compat'` to keep every `data-*` as 1.x did"}(e)}.`))}var bn=/* @__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"]),wn=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),Sn=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),An=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),kn="aria-",Tn="data-",Cn={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"])},$n=/* @__PURE__ */new Set(["href","src","cite","poster"]),xn=class extends Error{name="SanitizerEnvironmentError"},Rn=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"]),Nn="strict",Pn=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function sanitizeHtml(e,t){return En(e,void 0,t)}function En(e,t,n){const r=Fn();if(!r)throw"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new xn("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===e)return"";const i=function(e,t){const n=e?.policy??t??Nn;if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(Cn))e.set(t,n);return{allowedTags:bn,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const r=new Set(bn);if(e.additionalAllowedTags?.forEach(e=>r.add(e)),!0===e.allowFormControls)for(const e of wn)r.add(e);const i=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(Cn))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),o=r.createElement("template");return o.innerHTML=an(e),Ln(o.content,i),o.innerHTML}function Fn(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[Pn];if(e)return e}if("undefined"!=typeof document)return document}function Ln(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?Mn(n,t):8===n.nodeType&&n.remove()}function Mn(e,t){const n=e.tagName.toLowerCase();if(!Sn.has(n)||t.allowFormControls&&wn.has(n)){if(!t.allowedTags.has(n))return Ln(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("strict"===n.mode){if(n.templateMode&&Rn.has(i))continue;if("id"===i||"name"===i||i.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===i&&!0!==r?.has(i)||yn(i);continue}if(i.startsWith(Tn)){n.allowedData.has(i)||(e.removeAttribute(t.name),yn(i));continue}if(An.has(i)||i.startsWith(kn))continue}else if(An.has(i)||i.startsWith(kn)||i.startsWith(Tn))continue;r?.has(i)?$n.has(i)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):"srcset"!==i||On(t.value)||e.removeAttribute(t.name):e.removeAttribute(t.name)}}}(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),Ln(e,t)}else e.remove()}function On(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))return!1}return!0}var Un=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),In=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(In,e=>Un[e])}var _n=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}),jn=/[&<>"']/g;function escapeHtmlAttribute(e){return e.replace(jn,e=>_n[e])}var Dn=/\{\{([\s\S]*?)\}\}/g;function zn(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 Bn(e,t,n,r,i){const o="object"==typeof t&&null!==t?t:null;return e.replace(Dn,(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 Wn(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(!H(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 Hn(e,t){for(const[n,r]of t)e.hasAttribute(n)||e.setAttribute(n,r)}function Vn(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 qn(e){return null==e||""===e}function Gn(e,t){const n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function Kn(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 Jn=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],Zn=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],Xn=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,Qn=/* @__PURE__ */new Map;function Yn(e){const t=Gn(Qn,e);if(void 0!==t)return t;const n=new Set(Jn);for(const t of e.matchAll(Xn)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const r={};for(const e of n)r[e]=Zn;const i={additionalAllowedTags:[...n],additionalAllowedAttributes:r,allowFormControls:!0,templateMode:!0};return Kn(Qn,e,i,64)}var er="data-payload-key",tr="data-payload-nested-key",nr="data-payload-nested-template";function rr(e){const t=or(e.container,e.patches,e);return null===t?null:sr(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function ir(e,t){return t.hasAttribute(tr)&&t.hasAttribute(nr)}function or(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),u=Wn(e),d=zn(i),c=Array.from(e.children),f=hr(c,er),h=/* @__PURE__ */new Set,p=[];for(let s=0;s<i.length;s+=1){const m=i[s],g=fr(m);let v=void 0===g?c[s]??null:pr(f,g)??null;null!==v&&h.has(v)&&(v=null),null!==v&&h.add(v);const y=t.replaces.has(s),b=o||t.renders.has(s)||null===v?mr(e.ownerDocument,r,m,s,a,u,d):void 0;if(null===b)return null;const w=void 0===b?[]:ar(y?null:v,b,m,void 0===g?void 0:l?.get(g),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 sr(e,t,n){const[r,i,o]=e,s=/* @__PURE__ */new Set;let a=!1;const l=mn(r);for(const[e,o,l,u,d]of i){let i=o;if(void 0!==l){const e=!(!n.morph||d||null===o)&&cn(o,l,{keyAttributes:[er,tr],retainChildrenOf:ir,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===o;if(!e)for(const[e,t]of u)null!==e&&(ur(e,t),t.replaceWith(e));for(const[,,e]of u)void 0!==e&&sr(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);gn(l);const u=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(r,t);u.clear();for(const e of o)cr(u,e);return a}function ar(e,t,n,r,i){const o=hr(null===e?[]:lr(e),tr),s=[];for(const e of lr(t)){const t=e.getAttribute(tr);if(null===t)continue;const a=pr(o,t)??null,l=e.getAttribute(nr),u=l?a:null,d=u?.getAttribute(nr)??null;let c;if(l){const o=dr(n,t);if(void 0!==o||null!==u){const n=o??[],s=M(null===u?[]:dr(r,t)??[],n),a=null!==u&&d!==l;if((s.length>0||a)&&(c=or(u??e,s,{template:l,nextItems:n,forceRender:a,store:i.store,sanitizerPolicy:i.sanitizerPolicy})??void 0,void 0===c))return null}}s.push([u,e,c])}return s}function lr(e){return Array.from(e.querySelectorAll(`[${tr}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(tr))return!1;n=n.parentElement}return n===e})}function ur(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 dr(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function cr(e,t){const n=fr(t);void 0!==n&&e.set(n,t)}function fr(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function hr(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 pr(e,t){return e.get(t)?.pop()}function mr(e,t,n,r,i,o,s){const a=En(Bn(t,n,r,Vn,s),i,Yn(t)),l=e.createElement("template");l.innerHTML=an(a);const u=l.content.firstElementChild;if(!u)return null;Hn(u,o);const d=fr(n);return void 0!==d&&u.setAttribute(er,d),u}function gr(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 vr(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`))}var yr=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;planFragments(e){const t=this.deps.strategies.fragment;return void 0===t?null:br(t,t.plan(this.deps.root,e))}escalateUnfaithful(e,t,n){if(e.routeRefreshed)return;const{fragment:r,route:i}=this.deps.strategies,o=void 0===r?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);if(void 0!==r&&void 0!==o)return this.state.escalatedCount+=n.length,e.pendingFragments+=o.length,void this.runFragments(e,t,br(r,o));void 0!==i?(this.state.escalatedCount+=n.length,this.refreshRoute(e,t,i)):this.warnEscalationUnavailable(n.length)}warnEscalationUnavailable(e){const{deps:t,state:n}=this;n.warnedEscalationUnavailable||(n.warnedEscalationUnavailable=!0,t.warn(`[live-preview] LP0808: onUnfaithfulPatch: 'escalate' has nowhere to go: ${String(e)} field(s) fell short and no route or fragment strategy is configured. Set routeStrategy: true or fragments: { endpoint }, or onUnfaithfulPatch: 'warn' to keep the patch and say so.`))}hasUnboundChange(e,t){const{deps:n,state:r}=this;if(e.baseline||e.routeRefreshed)return!1;const i=he(n.cache,e.touched,e.locale,t);let o=0;for(const e of i)G(r,e)&&(o+=1);const[s]=i;return void 0!==s&&"escalate"===n.onUnfaithfulPatch&&(void 0===n.strategies.route?(this.warnEscalationUnavailable(i.length),!1):(n.log("route","LP0807",`field "${s}" has no binding; refreshing the route`),r.escalatedCount+=o,!0))}hasRouteBinding(e){for(const[t,n]of this.deps.cache.entries())if(e.has(t)&&n.some(e=>"route"===e.strategyKind))return!0;return!1}async runFragments(e,t,n){const{deps:r,state:i}=this,o=new AbortController;i.fragmentController=o;const s=()=>i.isCurrent(e)&&!o.signal.aborted,{emitter:a}=r,{message:l}=e,u=e.revision.revision,d=e.receivedAt,c={root:r.root,revision:u,receivedAt:d,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof l.collectionSlug?l.collectionSlug:void 0,globalSlug:"string"==typeof l.globalSlug?l.globalSlug:void 0,signal:o.signal,isCurrent:s,log:(e,t)=>{r.log("fragment",e,t)},morph:(e,t)=>{!function(e,t){const n=e.ownerDocument.createElement("template");n.innerHTML=an(t);const r=e.cloneNode(!1);r.append(n.content),cn(e,r,{keyAttributes:[er]})}(e,t)},patch:n=>{this.patchFallback(e,t,n)},rendered:(t,n,r)=>{e.pendingFragments-=1,a.emitWhile("fragmentRender",{element:t,id:n,key:r,status:"rendered",revision:u,receivedAt:d},s)},failed:(t,n,i,o,l)=>{e.pendingFragments-=1;const c=`fragment "${n}" fell back to patch: ${l}`;r.log("fragment",o,c),a.emitWhile("error",{error:new Error(c),context:"fragment",code:o},s),a.emitWhile("fragmentRender",{element:t,id:n,key:i,status:"failed",code:o,revision:u,receivedAt:d},s)}};let f={rendered:0,failed:0,superseded:0};try{f=await n.strategy.render(c,n.boundaries)}catch(i){if(r.log("fragment","LP0801",i),s()){for(const r of n.boundaries)this.patchFallback(e,t,r);f={rendered:0,failed:n.boundaries.length,superseded:0}}}i.fragmentStats.rendered+=f.rendered,i.fragmentStats.failed+=f.failed,i.fragmentStats.superseded+=f.superseded,s()&&(i.fragmentController===o&&(i.fragmentController=null),e.pendingFragments=0,f.rendered>0&&this.host.restoreGuesses(e,t),0===r.scheduler.pendingCount&&i.complete(e),this.host.revealPending(e),s()&&0!==f.rendered&&0!==a.listenerCount("afterUpdate")&&a.emitWhile("afterUpdate",{data:t,updatedCount:f.rendered,durationMs:Date.now()-d,revision:u,receivedAt:d,source:"fragment"},s))}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)}armRouteRetry(e,t,n,r){const{state:i}=this;null!==i.routeRetry&&clearTimeout(i.routeRetry),i.routeRetry=setTimeout(()=>{i.routeRetry=null,i.isCurrent(e)&&this.runRoute(e,t,n)},r)}async runRoute(e,t,n){const{deps:r,state:i}=this,o=i.routeStats,s=new AbortController;i.routeController=s;const a=()=>i.isCurrent(e)&&!s.signal.aborted;let l;try{l=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:s.signal,isCurrent:a,log:(e,t)=>{r.log("route",e,t)},retryAfter:r=>{this.armRouteRetry(e,t,n,r)}})}catch(e){r.log("route","LP0801",e),l="failed"}if(a()){if(i.routeController===s&&(i.routeController=null),"refreshed"===l){if(o.refreshes+=1,i.lastAppliedIdentity=/* @__PURE__ */new WeakMap,this.host.restoreGuesses(e,t),this.host.rebuildCache(),!a())return;return this.host.reapply(e,t),void(r.emitter.listenerCount("afterUpdate")>0&&r.emitter.emitWhile("afterUpdate",{data:t,updatedCount:r.cache.elementCount,durationMs:Date.now()-e.receivedAt,revision:e.revision.revision,receivedAt:e.receivedAt,source:"route"},a))}"failed"===l?o.failed+=1:"refused"===l&&(o.refused+=1),this.host.reapply(e,t)}}warnFragmentFallback(e){gr(this.deps,this.state,e)}warnUnsupportedStrategy(e){vr(this.deps,this.state,e)}patchFallback(e,t,n){for(const[r,i]of this.deps.cache.entries())for(const o of i){if(o.fragmentBoundary!==n)continue;const i=Qt(t.fields,o,r,e.locale);void 0!==i&&this.deps.scheduler.schedule({target:o,value:this.host.transform(o,i,t.fields,()=>!0),allFields:t.fields,revision:e.revision,data:t})}}};function br(e,t){const n=new Set(t);return{boundaries:t,strategy:e,covers:e=>void 0!==e.fragmentBoundary&&n.has(e.fragmentBoundary)}}function wr(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=p(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 Sr=/* @__PURE__ */new Set,Ar=class{constructor(e,t,n){this.deps=e,this.state=t,this.strategies="undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e,t){return{planFragments:()=>null,escalateUnfaithful:()=>{},hasUnboundChange:(n,r)=>{if(n.baseline)return!1;const i=he(e.cache,n.touched,n.locale,r);for(const e of i)G(t,e);return!1},hasRouteBinding:()=>!1,runFragments:()=>Promise.resolve(),refreshRoute:()=>(T("route refreshes"),Promise.resolve()),warnFragmentFallback:n=>{T("server-rendered fragments"),gr(e,t,n)},warnUnsupportedStrategy:n=>{vr(e,t,n)}}}(e,t):new yr(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,r,i)=>wr(e,t,n,r,i),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}})}deps;state;strategies;handleUpdate(e,t,n){const{deps:r,state:i}=this;if(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),void 0===e.data)return void(void 0!==e.protocolVersion&&i.protocol.applyVersion(e.protocolVersion,r.log));if(void 0===n)return;const o=i.relationships.edit(e);null!==o&&r.emitter.emit("relationshipUpdate",{detail:o,timestamp:Date.now()}),"string"==typeof e.locale&&(i.locale=e.locale),Array.isArray(e.fieldSchemaJSON)&&(i.schema=e.fieldSchemaJSON,i.schemaIndex=N(e.fieldSchemaJSON));const s={revision:n,message:e,locale:i.locale,schema:i.schema,schemaIndex:i.schemaIndex,receivedAt:Date.now(),forceRender:null!==o||Ae(i.activeUpdate),touched:/* @__PURE__ */new Set,baseline:!1,invalidated:/* @__PURE__ */new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1},a=i.activeUpdate;if(i.abortStrategies(),null===a||a.completed||(i.supersededCount+=1),i.activeUpdate=s,r.scheduler.acceptRevision(n),i.updateCount+=1,void 0===e.protocolVersion||(i.protocol.applyVersion(e.protocolVersion,r.log),i.isCurrent(s))){if(r.connection.markConnected()){if(r.a11y?.announceConnected(),r.emitter.emit("connect",{origin:t,timestamp:Date.now()}),!i.isCurrent(s))return;if(r.log("connection","disconnected","→","connected"),!i.isCurrent(s))return}this.processUpdate(s).catch(e=>{r.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,o=Ne(r.dependencies,r.cache.dependencyMap()),s=i.changes.diff(t.fields,o);if(s.baseline&&!n&&"off"!==r.autoBind)if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)T("auto-binding");else{const n=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,r,i){const o=performance.now(),s=Gt(e.root),a=jt(n,r),l=null===s?[]:Kt(e,qt(s,a),i,"on the first message");t.autoBindGuesses=function(e,t){const n=/* @__PURE__ */new Set;for(const{fieldName:e,stamps:r}of t){n.add(e);for(const e of[je,ze]){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}}(a,l),t.autoBindSearchMs=performance.now()-o,l.length}(r,i,t.fields,e.locale,n)}e.baseline=s.baseline,e.invalidated=n?Sr:s.invalidated,e.touched=n?Sr:/* @__PURE__ */new Set([...s.changed,...s.invalidated]),this.scheduleAllFields(e,t)}async resolveIncomingFields(e){const{deps:t,state:n}=this,r=e.message.data??{};if(null===t.merger)return r;if("admin"===detectProtocolProfile(n.protocol.observed).populatesRelationships)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,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),a.doc):"superseded"===a.status?null:i.fields:null}async applyMerged(e,t){const{state:n}=this,r=await t;"merged"===r.status&&n.isCurrent(e)&&(n.merges.recordMerged(r.doc),this.applyFields(e,this.dataFor(e,r.doc),!0))}scheduleAllFields(e,t){const{deps:n,state:r}=this;if(!r.isCurrent(e))return;const i=()=>r.isCurrent(e),o=this.ownerKeysForUpdate(e,t.fields),{touched:s}=e,a=n.strategies.route,l=this.strategies.hasUnboundChange(e,o),u=r.routeRefreshOwed;if(void 0!==a&&!e.routeRefreshed&&(l||u||a.plan(n.root,s)||this.strategies.hasRouteBinding(s)))return r.routeRefreshOwed=!1,void this.strategies.refreshRoute(e,t,a);const d=this.strategies.planFragments(s),c=n.skipUnchanged;let f=0;for(const[s,a]of n.cache.entries()){if(!i())return;for(const l of a){if(!1!==o&&!se(l.owner,o))continue;if(!0===d?.covers(l)){if(n.revealEditedField){const n=Qt(t.fields,l,s,e.locale);r.revealLedger.note(e,l,n)}continue}const a=l.strategyKind??re(l.element)??"unknown";if("unknown"===a){this.strategies.warnUnsupportedStrategy(l);continue}"fragment"===a&&null===d&&this.strategies.warnFragmentFallback(l);const u=Qt(t.fields,l,s,e.locale);if(void 0===u){r.absentFields.add(s);continue}if(n.revealEditedField&&r.revealLedger.note(e,l,u),!i())return;const h=wr(n,l,u,t.fields,i);if(!i())return;const p=c?Yt(l,h,t.fields,e.locale):void 0,m=r.lastAppliedIdentity.get(l.element);if(!e.forceRender&&n.skipUnchanged&&void 0!==p&&m===p&&!e.invalidated.has(s)){r.skippedUnchangedCount+=1;continue}const g={target:l,value:h,allFields:t.fields,revision:e.revision,data:t,valueIdentity:p};n.scheduler.schedule(g),f+=1}}(function(e,t,n,r){const{cache:i}=e;if(0===i.fieldCount)return;if(!1!==r&&!function(e,t){for(const n of e.values())if(se(n.owner,t))return!0;return!1}(i,r))return;const o=fe(i,n,r);for(const[r,i]of Object.entries(t)){if(le.has(r))continue;if(tn(i)){en(e,o,r,n,i);continue}if(!nn(i)||o(r))continue;const t=ce(r,n);for(const[r,s]of Object.entries(i))tn(s)&&!le.has(r)&&en(e,o,`${t}.${r}`,n,s)}})({cache:n.cache,warned:r.warnedOrphanFields,warn:n.warn},t.fields,e.locale,o),null!==d&&d.boundaries.length>0&&(e.pendingFragments=d.boundaries.length,this.strategies.runFragments(e,t,d)),0===f&&0===e.pendingFragments&&(r.complete(e),this.revealPending(e),this.notifyIslands(e,t))}notifyIslands(e,t){0!==e.touched.size&&function(e,t){for(const n of e)n.dispatchEvent(new CustomEvent(Ee,{detail:t,bubbles:!1}));e.length}(this.deps.cache.islands,{fields:t.fields,revision:e.revision.revision,receivedAt:e.receivedAt,locale:e.locale})}restoreGuesses(e,t){const{deps:n,state:r}=this;if("off"!==n.autoBind&&null!==r.autoBindGuesses&&("undefined"==typeof __LEAN_BUILD__||!__LEAN_BUILD__)){const i=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,r,i){const o=t.autoBindGuesses,s=Gt(e.root);if(null===o||0===o.fields.size||null===s)return 0;const a=new Map(o.values);for(const[e,t]of jt(n,r)){if(null===t||!o.fields.has(t.field))continue;const n=a.get(e);void 0===n?a.set(e,t):n?.field!==t.field&&a.set(e,null)}Kt(e,qt(s,a),i,"after a server render").length}(n,r,t.fields,e.locale,i)}}ownerKeysForUpdate(e,t){const{deps:n,state:r}=this;if(!n.scopeBindingsByOwner)return!1;const{message:i}=e,o=function(e){if(oe(e.globalSlug))return[(t=e.globalSlug,`global:${t}`)];var t;if(!oe(e.collectionSlug))return null;const n=ie(e.collectionSlug);return oe(e.documentId)?[n,ie(e.collectionSlug,e.documentId)]:[n]}({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:ae(t)});return null!==o||r.warnedUnattributableMessage||(r.warnedUnattributableMessage=!0,n.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),o}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)||!m(o.revision,r))return;0===o.pendingFragments&&n.complete(o);const s=()=>n.isCurrent(o)&&m(o.revision,r);if(this.revealPending(o),!s())return;const a=n.unfaithfulPatches;a.length>0&&(n.unfaithfulPatches=[],void 0!==i&&this.strategies.escalateUnfaithful(o,i,a),!s())||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{this.revealBinding(t)}catch(e){this.deps.log("reveal",e)}}revealField(e){const t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":this.revealBinding(t)}revealBinding(e){const{element:t}=e,n=t.ownerDocument.defaultView;if(null===n)return"no-element";const r=`${e.owner??""} ${e.fieldName}`;return this.state.revealer.reveal(r,t,n)}},kr=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;frameToken=0;windowUntil=0;activeRevision=null;activeRevisionCancelled=!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(void 0!==e.revision){if(this.activeRevisionCancelled)return;if(null===this.activeRevision||!m(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;null!==this.activeRevision&&m(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.cancelScheduledWork(),this.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1)}cancelRevision(e){null!==this.activeRevision&&m(e,this.activeRevision)&&(this.cancelScheduledWork(),this.clearWork(),this.activeRevisionCancelled=!0)}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(){this.cancelScheduledWork(),this.clearWork(),this.activeRevision=null,this.activeRevisionCancelled=!1,this.windowUntil=0}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,null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1;const r=this.scheduleFrame(()=>{this.frameToken===e&&(n=!0,this.frameHandle=null,this.flush())});n||this.frameToken!==e||(this.frameHandle=r)}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);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&&m(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||(t=this.apply,!X.has(t));var t}retargetBuffer(e,t){const n=e.get(t.element);void 0!==n&&(n.target.fieldName===t.fieldName&&n.target.locale===t.locale?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(),null!==e&&clearTimeout(e),null!==t&&this.cancelFrame(t)}},Tr=[0,500,1e3,2e3],Cr=class{deps;state=new xe;pipeline;writer;rootSentinel=null;observedRoot=null;constructor(e){const{emitter:t,renderers:n}=e,r=void 0===e.log?y:v(e.log),i=void 0===e.warn?w:v(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 at({filter:e=>!isInsideIsland(e)}),a=new gt({onStructuralChange:()=>{this.rebuildCache()},onVisibilityChange:(e,t)=>{t&&l.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),l=new kr(Q(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)}}),u=new g(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],r),t.emit("documentSave",{timestamp:Date.now()})},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}:{}}),d=e.dataMerge;this.deps={emitter:t,cache:s,observers:a,scheduler:l,bus:u,connection:new Et,heartbeat:new Pt({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:n,resolveRenderer:e.resolveRenderer??(e=>n[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,root:o,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:/* @__PURE__ */(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??$,onHeartbeatTimeout:e.onHeartbeatTimeout,log:r,warn:i,a11y:C(e),merger:void 0===d?null:new ft({serverURL:d.serverURL,...void 0!==d.apiRoute?{apiRoute:d.apiRoute}:{},...void 0!==d.depth?{depth:d.depth}:{},...void 0!==d.fetchFn?{fetchFn:d.fetchFn}:{},log:r}),mergeWindowMs:e.debounceMs??50,scopeBindingsByOwner:!0===e.scopeBindingsByOwner,lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField,onUnfaithfulPatch:V(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new Re(this.deps,this.state),this.pipeline=new Ar(this.deps,this.state,()=>{this.rebuildCache()})}start(){const{state:e}=this;if(e.isRunning())return!1;e.started=!0,e.suspended=!1;try{return function(e){"react"===e.hydration?wt():"vue"===e.hydration&&xt();const{root:t}=e;if(!function(e){return 9===e.nodeType}(t)||"loading"!==t.readyState)return void Rt(e);const n=()=>{e.isRunning()&&e.later(()=>{Rt(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},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=$r(t.root)?xr(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()&&(t.bus.attach(),t.emitter.emitWhile("init",{timestamp:Date.now()},()=>e.isRunning()),e.isRunning()))for(const n of Tr){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,n&&t.emitter.emit("disconnect",{reason:"destroy",timestamp:Date.now()}),t.a11y?.detach(),t.emitter.emit("destroy",{timestamp:Date.now()})}release(){const{state:e,deps:t}=this;e.activeUpdate=null,e.started=!1;const n=e.deferredStart;e.deferredStart=null,null!==n&&this.runCleanup(n);for(const t of e.readyTimers)this.runCleanup(()=>{clearTimeout(t)});return e.readyTimers.length=0,this.runCleanup(()=>{t.heartbeat.stop()}),this.runCleanup(()=>{t.bus.detach()}),e.abortStrategies(),this.runCleanup(()=>{this.rootSentinel?.disconnect(),this.rootSentinel=null,this.observedRoot=null}),this.runCleanup(()=>{t.observers.stop()}),this.runCleanup(()=>{t.scheduler.destroy()}),this.runCleanup(()=>{t.merger?.destroy(),e.merges.destroy()}),t.cache.clear(),t.connection.markDisconnected()}rollbackFailedStart(){this.release(),this.runCleanup(()=>{this.deps.a11y?.detach()})}runCleanup(e){try{e()}catch(e){this.deps.log("cleanup failed:",e)}}refreshCache(){this.state.isRunning()&&(this.state.revealer.reset(),this.followReplacedRoot()||this.rebuildCache())}watchRootReplacement(){const{root:e}=this.deps;$r(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()||!$r(e))return!1;const t=xr(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=[],u=/* @__PURE__ */new Set,d=[];for(const[e,t]of r.entries()){l.push(e);for(const n of t)void 0!==n.owner&&u.add(n.owner),void 0!==n.guessed&&d.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},bindings:{elements:r.elementCount,fields:r.fieldCount,fieldNames:l.sort(),absentFields:[...n.absentFields].sort(),orphanFields:[...n.warnedOrphanFields].sort(),ownerScoped:t.scopeBindingsByOwner,owners:[...u].sort(),guessed:d.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;for(const e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),e.isRunning()){for(const e of t.cache.values()){const r=n.get(e.element);r?.fieldName===e.fieldName?t.scheduler.retarget(e):t.scheduler.forget(e.element),n.delete(e.element)}for(const e of n.values())t.scheduler.forget(e.element)}}onHeartbeatTimeout(){const{state:e,deps:t}=this;if(!e.isRunning())return;t.bus.advanceGeneration();const n=e.activeUpdate;e.activeUpdate=null,null!==n&&t.scheduler.cancelRevision(n.revision),t.merger?.destroy(),e.merges.destroy();const r=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}if(e.isRunning()){if(r&&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()}}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}};function $r(e){return 9===e.nodeType}function xr(e){return e.body}var EventEmitter=class{#t=/* @__PURE__ */new Map;#n=/* @__PURE__ */new Map;on(e,t){return this.#r(this.#t,e,t)}once(e,t){return this.#r(this.#n,e,t)}off(e,t){this.#i(this.#t,e,t),this.#i(this.#n,e,t)}async emit(e,t){await this.#o(e,t)}async emitWhile(e,t,n){return this.#o(e,t,n)}async#o(e,t,n){const r=()=>n?.()??!0;if(!r())return!1;const i=this.#t.get(e);if(i)for(const n of[...i]){if(!r())return!1;if(await this.#s(n,t,e),!r())return!1}if(!r())return!1;const o=this.#n.get(e);if(o&&o.size>0){const n=[...o];this.#n.delete(e);for(const i of n){if(!r())return!1;if(await this.#s(i,t,e),!r())return!1}}return r()}listenerCount(e){return(this.#t.get(e)?.size??0)+(this.#n.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#t.clear(),void this.#n.clear();this.#t.delete(e),this.#n.delete(e)}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#t.keys())e.add(t);for(const t of this.#n.keys())e.add(t);return[...e]}#r(e,t,n){let r=e.get(t);return r||(r=/* @__PURE__ */new Set,e.set(t,r)),r.add(n),()=>{this.#i(e,t,n)}}#i(e,t,n){const r=e.get(t);void 0!==r&&(r.delete(n),0===r.size&&e.delete(t))}async#s(e,t,n){try{await e(t)}catch(e){const t="string"==typeof n||"number"==typeof n?String(n):"<event>";b(`[live-preview] LP0601: handler for "${t}" threw:`,e)}}};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 Rr=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,Nr=/^https?:\/\/[^/?#\s]+$/i,Pr=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],OriginDetector=class{#a;constructor(e={}){const t=/* @__PURE__ */new Set;for(const n of e.additionalOrigins??[]){const e=Er(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.#a=[t,n,r,void 0!==n,void 0]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#a[4]?e===this.#a[4]:!!this.#a[0].has(e)||0===this.#a[0].size&&void 0!==this.#a[1]&&e===this.#a[1]||!(!this.#a[2]||!Rr.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#a[4]=e,!0)}unlockOrigin(){const e=this.#a[4];return this.#a[4]=void 0,e}get lockedOrigin(){return this.#a[4]}enumerate(){if(void 0!==this.#a[4])return[this.#a[4]];const e=new Set(this.#a[0]);if(0===this.#a[0].size&&void 0!==this.#a[1]&&e.add(this.#a[1]),this.#a[2])for(const t of Pr)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#a[3]}get isProductionUnconfigured(){return!(!isInIframe()||this.#a[0].size>0||this.#a[2]||void 0!==this.#a[1])}get isReferrerOnlyTrust(){return!(this.#a[0].size>0||this.#a[2]||void 0===this.#a[1])}};function Er(e){const t=e.trim();if(0!==t.length)try{const e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return;if(!Nr.test(e.origin))return;return e.origin}catch{return}}var Fr=()=>{},Lr=class{#l;#u;#d=/* @__PURE__ */new Set;#a="staging";constructor(e,t){this.#l=e,this.#u=t}assertOpen(){if("closed"===this.#a)throw new Error(`Plugin context for "${this.#l}" is no longer active`)}get active(){return"active"===this.#a}eligible(){return"closed"!==this.#a}own(e){return this.assertOpen(),this.#c({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.#c(r);if("active"===this.#a)try{this.#f(r)}catch(e){throw this.#h(r),e}return i}counts(){const e={transform:0,renderer:0,subscription:0,cleanup:0};for(const t of this.#d)e[t.kind]+=1;return e}commit(){if("staging"!==this.#a)throw new Error(`Plugin context for "${this.#l}" cannot be committed`);this.#a="committing";try{for(const e of this.#d)this.#f(e);this.#a="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#a){this.#a="closed";for(const e of[...this.#d].reverse())this.#h(e);this.#d.clear()}}#c(e){return this.#d.add(e),()=>{this.#h(e)}}#f(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;const t=e.acquire();e.cleanup=t??Fr}#h(e){if(e.disposed)return;e.disposed=!0,this.#d.delete(e);const t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{p(t())&&this.#u(`plugin "${this.#l}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#u(`plugin "${this.#l}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#u(`plugin "${this.#l}" cleanup failed:`,e)}}},Mr=class{#p;#m;#g=/* @__PURE__ */new Set;constructor(e,t){this.#p=e,this.#m=t}on(e,t){return this.#v("on",e,t)}once(e,t){return this.#v("once",e,t)}off(e,t){const n=t;for(const t of[...this.#g])t.event===e&&t.handler===n&&t.dispose()}emit(e,t){return this.#m.assertOpen(),this.#p.emit(e,t)}emitWhile(e,t,n){return this.#m.assertOpen(),this.#p.emitWhile(e,t,()=>{if(!this.#m.eligible())return!1;const e=n();return!!this.#m.eligible()&&e})}listenerCount(e){let t=0;for(const n of this.#g)n.event===e&&(t+=1);return t}removeAllListeners(e){for(const t of[...this.#g])void 0!==e&&t.event!==e||t.dispose()}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#g)e.add(t.event);return[...e]}#v(e,t,n){this.#m.assertOpen();const r=n,i=[...this.#g].find(n=>n.kind===e&&n.event===t&&n.handler===r);if(void 0!==i)return i.dispose;let o=Fr,s=!0;const a=async t=>{this.#m.active&&s&&("once"===e&&o(),await n(t))},l={kind:e,event:t,handler:r,dispose:Fr};return o=this.#m.stage("subscription",()=>this.#p[e](t,a),()=>{s=!1,this.#g.delete(l)}),l.dispose=o,this.#g.add(l),o}},Or=class{#p;#y;#b;#w;#u;#S=/* @__PURE__ */new Map;#A=/* @__PURE__ */new Map;#k=/* @__PURE__ */new Map;#T=/* @__PURE__ */new Set;#C=/* @__PURE__ */new Map;#$=Promise.resolve();#x=0;constructor(e){this.#p=e.events,this.#y=e.config,this.#b=e.registerFieldRenderer,this.#u=v(e.log);const t=e.onTransformError;this.#w=void 0===t?void 0:v((...e)=>{const n=e[0];try{return t(n)}catch(e){return void this.#u("transform error reporter failed:",e)}})}register(e){return this.#x>0?this.#R(e,!1):this.#N(()=>this.#R(e,!0))}unregister(e){return this.#x>0?this.#P(e,!1):this.#N(async()=>{await this.#P(e,!0)})}destroyAll(){return this.#x>0?this.#E(!1):this.#N(async()=>{await this.#E(!0)})}applyTransforms(e,t,n,r){const i=this.#C.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=p(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.#u(`transform for "${e}" failed:`,i),this.#w?.(i),t}}return o}list(){return[...this.#S.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.#A)e.push(t(n,void 0,"initializing",r.scope));for(const[n,r]of this.#S)e.push(t(n,r.plugin.version,"active",r.scope));for(const t of this.#k.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.#S.size}async#R(t,n){if(this.#S.has(t.name)||this.#A.has(t.name)||this.#k.has(t.name))return void this.#u(`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.#F(t.name,r);const i=new Lr(t.name,this.#u),o=this.#L(t.name,i),s={scope:i,cancelled:!1};this.#A.set(t.name,s);try{if(await this.#M(()=>t.init(o),n),s.cancelled)return;i.commit()}catch(e){return i.close(),void(s.cancelled||this.#u(`plugin "${t.name}" init failed:`,e))}finally{this.#A.get(t.name)===s&&this.#A.delete(t.name)}this.#S.set(t.name,{plugin:t,scope:i}),this.#u(`plugin "${t.name}" registered`)}#F(e,t){const n=`plugin "${e}" refused: ${t}`;this.#u(n),this.#p.emit("error",{error:new Error(n),context:"plugin",code:"LP0103"})}#L(e,t){return{events:new Mr(this.#p,t),registerFieldRenderer:e=>{t.stage("renderer",()=>{const t=this.#b(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.#C.get(e);return void 0===t?this.#C.set(e,[r]):t.push(r),()=>{r.active=!1;const t=this.#C.get(e);if(void 0===t)return;const n=t.indexOf(r);n>=0&&t.splice(n,1),0===t.length&&this.#C.delete(e)}})},registerCleanup:e=>{t.own(e)},getConfig:()=>this.#y,log:(...t)=>{this.#u(`[${e}]`,...t)}}}#P(e,t){const n=this.#A.get(e);if(void 0!==n)return n.cancelled=!0,n.scope.close(),Promise.resolve();const r=this.#k.get(e);if(void 0!==r)return this.#T.has(e)?Promise.resolve():t?this.#O(r):r;const i=this.#S.get(e);if(void 0===i)return Promise.resolve();this.#S.delete(e),i.scope.close();const o=Promise.resolve().then(()=>this.#U(e,i.plugin,t));return this.#k.set(e,o),o.then(()=>{this.#k.get(e)===o&&this.#k.delete(e)}),o}async#U(e,t,n){if(void 0!==t.destroy){this.#T.add(e);try{await this.#M(()=>t.destroy?.(),n)}catch(t){this.#u(`plugin "${e}" destroy failed:`,t)}finally{this.#T.delete(e)}}}async#E(e){for(const e of this.#A.values())e.cancelled=!0,e.scope.close();const t=[...this.#S.keys()];for(const n of t)await this.#P(n,e)}async#M(e,t){t?await this.#O(Promise.resolve().then(e)):await e()}async#O(e){this.#x+=1;try{await e}finally{this.#x-=1}}#N(e){const t=this.#$.then(e);return this.#$=t.catch(e=>{this.#u("plugin manager mutation failed:",e)}),t}},Ur=class{#I;#_;#j=/* @__PURE__ */new Map;constructor(e){this.#I=e,this.#_={...e}}get renderers(){return this.#_}resolve(e){return this.#_[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.#_[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.#I[t];void 0===a?Reflect.deleteProperty(this.#_,t):this.#_[t]=a}}},Ir={1:"left",2:"center",3:"right",4:"justify"},_r=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function jr(e){const t=e.format;return"string"==typeof t&&_r.has(t)?t:"number"==typeof t?Ir[t]:void 0}function Dr(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function zr(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function Br(e){const t=jr(e),n=Dr(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 Wr=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function Hr(e){return"object"==typeof e&&null!==e?e:void 0}function Vr(e){return Hr(e)}function qr(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function Gr(e){return"string"==typeof e&&e.length>0?e:void 0}function Kr(e){const t=Gr(e.title)??Gr(e.name)??Gr(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}var Jr=' target="_blank" rel="noopener noreferrer"',Zr=(e,t)=>{const n=t.renderChildren(e.children??[]),r=Hr(e.fields),i=function(e,t){if("internal"===t?.linkType)return function(e){const t=Hr(Hr(e)?.value),n=t?.url;if("string"==typeof n&&n.length>0)return n;const r=t?.slug;return"string"==typeof r&&r.length>0?`/${r}`:void 0}(t.doc);const n=t?.url??e.url;return"string"==typeof n&&n.length>0?n:void 0}(e,r);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 Jr;const r="string"==typeof e.target?e.target:"";return""===r?"":"_blank"===r?Jr:` target="${escapeHtml(r)}"`}(e,r,i)}${o}>${n}</a>`};function Xr(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=Xr(n);return t}function Qr(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function Yr(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var ei=/* @__PURE__ */new Map;function ti(e){return ei.get(e)}var ni=".lp-block:empty,.lp-inline-block:empty";function ri(e,t,n,r){const i=Hr(e.fields)??{},o="string"==typeof i.blockType?i.blockType:"",s=qr(o),a=""===s?r:`${r} ${r}--${s}`;if(""!==o){const e=ti(o)??ti(s);if(e)return e(i,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(o,a)}return`<${n} class="${a}"></${n}>`}function ii(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var oi={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${zr(e)}${Br(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",r=Wr.has(n)?n:"h2",i=t.renderChildren(e.children??[]);return`<${r}${zr(e)}${Br(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}${zr(e)}${Br(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"}"${Br(e)}>${n}</li>`;const r="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${zr(e)}${Br(e)}${r}>${n}</li>`},link:Zr,autolink:Zr,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${zr(e)}${Br(e)}>${n}</blockquote>`},code:e=>{const t=qr("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(Xr(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${qr(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=Vr(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${Qr(e)}><source src="${escapeHtmlAttribute(t)}"${Yr(e)}></video>`}(t,n):r.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${Yr(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}"${Qr(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=Hr(e.value),r=escapeHtml((n&&Kr(n))??`#${t}`),i=qr(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)=>ri(e,t,"div","lp-block"),inlineBlock:(e,t)=>ri(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${zr(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"':""}${ii("colspan",e.colSpan)}${ii("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${r}>`}},si=/* @__PURE__ */new Map,ai=!1;function li(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 ui(e,t={}){if(!li(e))return"";const n=function(e){const t={renderChildren:e=>{let n="";for(const r of e)n+=ci(r,t);return n},resolveAlignment:jr,resolveIndent:Dr,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==Fn()?sanitizeHtml(n):(function(){if(!ai){ai=!0;try{console.warn('[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; call setSanitizerDocument() (linkedom/jsdom) for server rendering, see "HTML sanitization" in docs/security.md.')}catch{}}}(),n)}function di(e){return li(e)?e.root.children.map(fi).join("\n").trim():""}function ci(e,t){const n=(r=e.type,si.get(r)??oi[r]);var r;return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function fi(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+=fi(n);return t}function hi(e="text"){const t=/* @__PURE__ */new WeakSet;return{name:e,render:/* @__PURE__ */Q((e,n)=>{const r=e.element,i=function(e){return null==e?"":li(e)?di(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e)}(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName)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),w(`[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=an(function(e){return escapeHtml(e).replace(/\r\n|\r|\n/g,"<br>")}(i)):r.textContent=i);r.value=i})}}var pi=/* @__PURE__ */new Set,mi=/* @__PURE__ */new Set,gi=/* @__PURE__ */new Set(["DIV","SECTION","ARTICLE"]),vi={name:"richText",render:/* @__PURE__ */Q((e,t,n)=>{const r=e.element;if(qn(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=an(En(o,i)))}if(li(t)){const o=/* @__PURE__ */new Map,s=function(e,t){const n=e.cloneNode(!1);n.innerHTML=an(t);const r=function(e,t){const n=e.firstElementChild;if(null!==n?.nextElementSibling||t.children.length<2)return null;if(!gi.has(n.tagName)||n.hasAttribute(Ue))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(ni);if(o.length>0&&null!==r.firstElementChild){const e=[];yi(r,n,e);for(const[t,n]of e)t.replaceWith(n),n.matches(ni)||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,En(ui(t,{sanitize:!1,onUnrenderedBlock:(e,t)=>{o.set(t,e)}}),i));for(const[t,r]of s){const i=o.get(t);void 0!==i&&bi(e,n,i,r)}return}if("string"!=typeof t)return!1;r.innerHTML=an(En(t,i))})};function yi(e,t,n){if(e.children.length!==t.children.length)return;let r=e.firstElementChild,i=t.firstElementChild;for(;null!==r&&null!==i;)i.matches(ni)?n.push([i,r]):yi(r,i,n),r=r.nextElementSibling,i=i.nextElementSibling}function bi(e,t,n,r){r&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);const i=r?mi:pi;i.has(n)||(i.add(n),w(`[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 wi={name:"html",render(e,t,n){if(qn(t))return void(e.element.textContent="");const r="string"==typeof t?t:Vn(t);e.element.innerHTML=an(En(r,n.sanitizerPolicy))}},Si=/* @__PURE__ */new WeakSet;function Ai(e,t,n){return"string"!=typeof n||0===n.length?{kind:"none"}:isSafeUrl(n)?{kind:"safe",url:n}:(Si.has(e)||(Si.add(e),w(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function ki(e,t=e=>e){return{name:e,render(e,n,r){const i=e.element;if(qn(n))return void function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(i);const o=Vn(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):Zt(r.allFields,n,r.locale,void 0!==e.locale),a=Ai(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 Ti=ki("url"),Ci=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,$i=ki("email",function(e){const t=e.trim();return Ci.test(t)||!t.includes("@")?t:`mailto:${t}`}),xi=["src","srcset","sizes"];function Ri(e){for(const t of xi)e.removeAttribute(t)}function Ni(e,t,n){e.src=t;const r=function(e){if(void 0===e?.sizes)return;const t=[];for(const n of Object.values(e.sizes))"string"==typeof n.url&&"number"==typeof n.width&&isSafeUrl(n.url)&&t.push(`${Pi(n.url)} ${String(n.width)}w`);return 0!==t.length?("number"==typeof e.width&&"string"==typeof e.url&&isSafeUrl(e.url)&&t.push(`${Pi(e.url)} ${String(e.width)}w`),t.join(", ")):void 0}(n);if(void 0===r)return e.removeAttribute("srcset"),void e.removeAttribute("sizes");e.setAttribute("srcset",r)}function Pi(e){return e.replace(/[\s,]/g,encodeURIComponent)}var Ei={name:"image",render:/* @__PURE__ */Q((e,t,n)=>{const r=e.element;if(qn(t))return void Fi(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?Zt(n.allFields,e.srcField,n.locale,r):t,o=Vr(i);return{media:o,candidate:void 0===o?i:o.url}}(e,t,n,i),a=Ai(r,e.fieldName,s);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===r.tagName){const t=r;Ni(t,a.url,o);const s=function(e,t,n,r,i){if(void 0!==t&&t.length>0){const e=Zt(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 Fi(r)})};function Fi(e){"IMG"===e.tagName?Ri(e):e.style.backgroundImage=""}var Li={name:"upload",render:/* @__PURE__ */Q((e,t)=>{const n=e.element;if(qn(t))return void Mi(n);const r=Vr(t);if(void 0===r)return!1;const i=Ai(n,e.fieldName,r.url);if("none"===i.kind)return!1;if("unsafe"===i.kind)return void Mi(n);const o=i.url;if("IMG"===n.tagName){const e=n;return Ni(e,o,r),void(void 0!==r.alt&&(e.alt=r.alt))}if("A"===n.tagName)return n.setAttribute("href",o),void(n.textContent=r.filename??o);const s=escapeHtml(r.filename??o);n.innerHTML=an(`<a href="${escapeHtmlAttribute(o)}">${s}</a>`)})};function Mi(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):Ri(e)}var Oi={name:"relationship",render(e,t){const n=e.element;if(qn(t))return n.removeAttribute("href"),void(n.textContent="");if("A"===n.tagName&&!Array.isArray(t)){const r=Ai(n,e.fieldName,Hr(t)?.url);"safe"===r.kind?n.setAttribute("href",r.url):"unsafe"===r.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(Ui).join(", "):Ui(t)}};function Ui(e){const t=Hr(e);return void 0===t?Vn(e):Kr(t)??""}var Ii={name:"select",render(e,t,n){const r=e.element,i=qn(t)?[]:function(e){return Array.isArray(e)?e.map(Vn):[Vn(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=Hr(t);if(void 0!==n&&Vn(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)}},_i=/* @__PURE__ */new Set(["","false","0","off","no"]),ji={name:"checkbox",render(e,t){const n=e.element,r=function(e){return"boolean"==typeof e?e:"string"==typeof e?!_i.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}},Di=/* @__PURE__ */new Map,zi=/* @__PURE__ */new Map;function Bi(e,t){const n=e??"";if(null==t)return n;const r=Wi(t);return"{}"===r?n:`${n}|${r}`}function Wi(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Wi(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)}:${Wi(n)}`)}return`{${r.join(",")}}`}var Hi=/* @__PURE__ */new Set(["short","medium","long","full"]),Vi=/* @__PURE__ */new Set(["short","medium","long","full"]),qi=/^[A-Za-z]{3}$/u,Gi=/^[0-4]$/u;function Ki(e){return{kind:"date",options:e}}function Ji(e){return{kind:"number",options:e}}var Zi=/* @__PURE__ */new WeakSet;function Xi(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?Ki({dateStyle:"medium"}):Hi.has(r)?Ki({dateStyle:r}):void 0;case"time":return void 0===r?Ki({timeStyle:"short"}):Vi.has(r)?Ki({timeStyle:r}):void 0;case"datetime":return void 0===r?Ki({dateStyle:"medium",timeStyle:"short"}):Hi.has(r)?Ki({dateStyle:r,timeStyle:"short"===r?"short":"medium"}):void 0;case"number":if(void 0===r)return Ji({});if(!Gi.test(r))return;return Ji({minimumFractionDigits:Number(r),maximumFractionDigits:Number(r)});case"currency":if(void 0===r||!qi.test(r))return;return Ji({style:"currency",currency:r.toUpperCase()});case"percent":return void 0===r?Ji({style:"percent"}):void 0;default:return}}(t);if(void 0!==i){if(i.kind===e)return i.options}else!function(e,t,n){Zi.has(e)||(Zi.add(e),w(`[live-preview] LP0408: data-payload-format="${n}" on "${t}" is not a known format; the default formatting was used. Known: date, date:short|medium|long|full, time, datetime, number, number:0-4, currency:XXX, percent.`))}(n,r,t)}var Qi={name:"date",render(e,t,n){const r=e.element;if(qn(t))return void("INPUT"===r.tagName?r.value="":(r.removeAttribute("datetime"),r.textContent=""));const i="number"==typeof t?t:Vn(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=Xi("date",t.format,t.element,t.fieldName)??Yi;try{return function(e,t){const n=Bi(e,t);return Gn(zi,n)??Kn(zi,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")}-${eo(t.getMonth()+1)}-${eo(t.getDate())}`,r=`${eo(t.getHours())}:${eo(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${r}`:"time"===e?r:t.toISOString()}(r.type,o):a}},Yi={dateStyle:"medium",timeStyle:"short"};function eo(e){return String(e).padStart(2,"0")}var to={name:"number",render(e,t,n){const r=e.element;if(qn(t))return void("INPUT"===r.tagName?r.value="":r.textContent="");const i="number"==typeof t?t:Number(Vn(t));Number.isNaN(i)?r.textContent=Vn(t):"INPUT"!==r.tagName?r.textContent=function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=Xi("number",t.format,t.element,t.fieldName);try{return function(e,t){const n=Bi(e,t);return Gn(Di,n)??Kn(Di,n,new Intl.NumberFormat(e,t),64)}(r,i).format(e)}catch{return String(e)}}(i,e,n):r.value=String(i)}},no={name:"array",render:/* @__PURE__ */Q((e,t,n)=>{const r=e.element;if(qn(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=zn(t);let r="";for(let i=0;i<t.length;i+=1)r+=Bn(e,t[i],i,Vn,n);return r}(i,t),o=n.sanitizerPolicy,s=Yn(i),a=Wn(r);r.innerHTML=an(En(e,o,s));for(const e of Array.from(r.children))Hn(e,a);return}r.textContent=t.map(Vn).join(e.arraySeparator??", ")})};function ro(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,n=/* @__PURE__ */new WeakMap,r=/* @__PURE__ */new WeakMap;return{name:"structural-array",render:/* @__PURE__ */Q((i,o,s)=>{const a=qn(o)?[]:o;if(!Array.isArray(a))return!1;const l=i.element,u=i.arrayTemplate;if(void 0===u||0===u.length)return function(e,t,n){e.has(t)||(e.add(t),w(`[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 d=e.get(l),c=io(l),f=M(d?.values??c.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e}),a),h=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)}(d,u,c);if(0===f.length&&!h)return e.set(l,{values:a.slice(),template:u,domSnapshot:c}),!1;!function(e,t,n,r,i){const o=i.map(oo),s=/* @__PURE__ */new Set,a=o.find(e=>!(void 0===e||!s.has(e)&&(s.add(e),1)));if(void 0!==a&&so(e,t,n,a),o.some(e=>void 0===e)&&ao(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(oo).filter(e=>void 0!==e)),s=o.some(e=>void 0!==e&&i.has(e));i.size>0&&!s&&ao(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,d?.values,a);const p=rr({template:u,container:l,patches:f,nextItems:a,store:r,forceRender:h,sanitizerPolicy:s.sanitizerPolicy,onDuplicateKey:(e,t)=>{so(n,e,i.fieldName,t)}});return null!==p&&(e.set(l,{values:a.slice(),template:u,domSnapshot:io(l)}),!!p&&void 0)})}}function io(e){return Array.from(e.children,e=>e.getAttribute(er))}function oo(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function so(e,t,n,r){ao(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${r}"; later ones pair by position. Make \`id\` unique per item.`)}function ao(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),w(`[live-preview] ${r}`))}var lo=/* @__PURE__ */new Map;function uo(e,t){return{name:e,render(){T(t)}}}function co(){const e=[vi,wi,Ti,$i,Ei,Li,Oi,Ii,{...Ii,name:"radio"},ji,Qi,to,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[uo("array","structural arrays"),uo("blocks","structural arrays")]:[no,{...no,name:"blocks"}]];return function(e=[]){const t={};for(const n of e)t[n.name]=n;for(const[e,n]of lo)t[e]=n;return Object.freeze(t)}([hi("text"),hi("textarea"),...e,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[]:[ro()]])}var fo=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),ho=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"});function po(e){return void 0===e?void 0:!e}var LivePreviewClient=class{#D=new EventEmitter;#z;#B;#W;#S;#u;#H=!1;#V=!1;#q=!1;#G=null;constructor(e={}){const n=function(e){const t="v1"===e.defaults?ho:fo;return{...e,skipUnchanged:e.skipUnchanged??t.skipUnchanged,disableReferrerDetection:e.disableReferrerDetection??t.disableReferrerDetection,eventSourcePolicy:e.eventSourcePolicy??t.eventSourcePolicy,sanitizerPolicy:e.sanitizerPolicy??t.sanitizerPolicy}}(e),r=n.serverURL??"";t({defaults:e.defaults,serverURL:r,mergeDepth:n.mergeDepth});const i=n.debug??isDevMode();this.#u=i?(...e)=>{S("[live-preview]",...e)}:y,this.#z=new OriginDetector(x({additionalOrigins:n.allowedOrigins,enableReferrerDetection:po(n.disableReferrerDetection),enableLocalhostMatching:po(n.disableLocalhostMatching)})),this.#z.isProductionUnconfigured&&this.#u("no trusted origin could be detected — set allowedOrigins"),this.#B=new Ur(co()),this.#S=new Or({events:this.#D,config:Object.freeze({...n}),registerFieldRenderer:e=>this.#B.register(e),onTransformError:e=>{this.#D.emit("error",{error:e,context:"transform",code:"LP0602"})},log:this.#u}),this.#W=new Cr(x({root:n.root,renderers:this.#B.renderers,resolveRenderer:(e,t)=>n.resolveRenderer?.(e,t)??this.#B.resolve(e),renderRichText:n.renderRichText,sanitizerPolicy:n.sanitizerPolicy,transformValue:(e,t,n,r)=>this.#S.applyTransforms(e,t,n,r),originMatcher:e=>this.#z.matches(e),readyTargets:()=>this.#z.enumerate(),emitter:this.#D,dataMerge:""===r?void 0:x({serverURL:r,apiRoute:n.apiRoute,depth:n.mergeDepth,fetchFn:n.mergeFetch}),debounceMs:n.debounceMs,heartbeatMs:n.heartbeatMs,intersectionRootMargin:n.intersectionRootMargin,scopeBindingsByOwner:n.scopeBindingsByOwner,skipUnchanged:n.skipUnchanged,revealEditedField:n.revealEditedField,autoBind:n.autoBind,eventSourcePolicy:n.eventSourcePolicy,dependencies:n.dependencies,strategies:n.strategies,disableVisibilityGate:n.disableVisibilityGate,visibilityGateThreshold:n.visibilityGateThreshold,enableA11y:n.enableA11y,a11yLocale:n.a11yLocale,onHeartbeatTimeout:()=>{this.#z.unlockOrigin()},lockedOrigin:()=>this.#z.lockedOrigin,validateToken:n.validateToken,log:this.#u})),this.#D.on("connect",e=>{this.#z.lockOrigin(e.origin)}),!1!==n.autoStart&&this.start()}start(){if(this.#V)return!1;if(this.#H)return this.#W.start(),!0;if(!isInPreviewContext())return!1;const e=this.#W.start();return e&&(this.#H=!0),e}suspend(){return!(this.#V||!this.#H)&&this.#W.suspend()}resume(){return!(this.#V||!this.#H)&&this.#W.start()}destroy(){if(null!==this.#G)return this.#G;let e,t;this.#V=!0;const n=new Promise((n,r)=>{e=n,t=r});this.#G=n;const r=()=>{this.#D.removeAllListeners(),this.#q=!0};try{this.#W.destroy(),this.#S.destroyAll().finally(r).then(e,t)}catch(e){r(),t(e)}return n}async use(e){if(this.#V)throw new Error("LivePreviewClient: already destroyed");await this.#S.register(e)}async unuse(e){if(this.#q)throw new Error("LivePreviewClient: already destroyed");await this.#S.unregister(e)}refreshCache(){this.#W.refreshCache()}get events(){return this.#D}get plugins(){return this.#S.list()}get status(){return this.#W.status}inspect(){return{...this.#W.inspect(),plugins:this.#S.snapshot()}}get updateCount(){return this.#W.updateCount}get destroyed(){return this.#V}};function mo(e,t,n){if(0===t.length)return;const r={type:"payload-live-preview-focus",field:t};e.postMessage(r,n)}var go="__livePreviewRouteRefresh",vo=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",ProfileFeatureOmitted:"LP0104",OrphanField:"LP0201",UnattributableUpdate:"LP0202",UnboundField:"LP0203",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",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710"}),yo=/* @__PURE__ */['(()=>{function e(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function t(t){return(...n)=>{try{e(t(...n))}catch{}}}function n(){}function i(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function r(e,t,n,i){if(t.reportedUnfaithful.has(n.element))return;t.reportedUnfaithful.add(n.element),t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName);let r=e.onUnfaithfulPatch;if("ignore"!==r){if("warn"===r){e.warn(`[live-preview] LP0411: "${n.fieldName}" ${i}`);return}e.log("LP0411",n.fieldName,i),t.unfaithfulPatches.push(n)}}function l(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}function o(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function a(e){let t=e.trim();return JSON.stringify(t.length>Ln?`${t.slice(0,Ln)}\\u2026`:t)}function s(){return function(){if(typ','eof document>"u")return;let e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}()??function(){if(typeof navigator>"u")return;let e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}()??"en"}function u(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}function d(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=c(n);e&&t.push(e)}return t}function c(e){if("object"!=typeof e||null===e)return;let t=e,n=t.name,i=t.type;if("string"!=typeof n||0===n.length||"string"!=typeof i||0===i.length)return;let r=d(t.fields),l=function(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if("object"!=typeof n||null===n)continue;let e=n,i=e.slug;if("string"!=typeof i||0===i.length)continue;let r=d(e.fields);t.push({...e,slug:i,fields:r})}return t}(t.blocks),o={...t,name:n,type:i};return r.length>0?o.fields=r:delete o.fields,l.length>0?o.blocks=l:delete o.blocks,o}function h(e,t){return void 0===e||t(e)}function f(e,t){return null==e||t(e)}function p(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}function m(e,t=[]){let n="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,i=Math.min(4,n??1),r=new Set(t),l=new Set;for(let e of Bn)(i>=Wn[e].since||r.has(e))&&l.add(e);return{ours:4,...void 0!==n?{theirs:n}:{theirs:void 0},negotiated:i,capabilities:l,observed:r}}function g(e,t){return e.generation===t.generation&&e.revision===t.revision}function v(e){return function(e){if(!1===e.enableA11y)return null;let t=e.root,n=void 0===t?void 0:function(e){return 9===e.nodeType}(t)?t:t.ownerDocument;return new jn(e.a11yLocale,n)}(e)}function y(e){if(typ','eof window>"u")return;let t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),zn.sendReady(t,e)}function b(e,t=""){let n=new Map;return w(e,t,n),n}function w(e,t,n){for(let i of e){if(Dn.has(i.type)){i.fields&&w(i.fields,t,n);continue}let e=""===t?i.name:`${t}.${i.name}`;if(n.set(e,i),"group"===i.type)i.fields&&w(i.fields,e,n);else if("array"===i.type&&i.fields)w(i.fields,`${e}.*`,n);else if("blocks"===i.type&&i.blocks)for(let t of i.blocks)w(t.fields,`${e}.*.${t.slug}`,n)}}function S(e,t){if(e.has(t))return e.get(t);let n=t.replace(/\\.\\d+(?=\\.|$)/g,".*");return e.has(n)?e.get(n):void 0}function T(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function k(e){if("object"!=typeof e||null===e)return;let t=e.blockType;return"string"==typeof t?t:void 0}function A(e,t){return t.every(e=>void 0!==T(e))?function(e,t){let n=[],i=new Map;for(let t=0;t<e.length;t+=1){let n=T(e[t]);void 0!==n&&i.set(n,t)}let r=new Set;for(let l=0;l<t.length;l+=1){let o=t[l],a=T(o);if(void 0===a){n.push({kind:"insert",index:l,value:o});continue}let s=i.get(a);if(void 0===s){n.push({kind:"insert",index:l,value:o});continue}r.add(s);let u=e[s];k(u)===k(o)?(s!==l&&n.push({kind:"move",from:s,to:l,value:o}),C(u,o)||n.push({kind:"update",index:l,value:o})):n.push({kind:"replace",index:l,oldValue:u,value:o})}for(let t=0;t<e.length;t+=1)r.has(t)||n.push({kind:"remove",index:t,value:e[t]});return n}(e,t):function(e,t){let n=[],i=Math.min(e.length,t.length);for(let r=0;r<i;r+=1)C(e[r],t[r])||n.push({kind:"update",index:r,value:t[r]});if(t.length>e.length)for(let i=e.length;i<t.length;i+=1)n.push({kind:"insert",index:i,value:t[i]});if(e.length>t.length)for(let i=t.length;i<e.length;i+=1)n.push({kind:"remove",index:i,value:e[i]});return n}(e,t)}function C(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;let n=e,i=t,r=Object.keys(n),l=Object.keys(i);if(r.length!==l.length)return!1;for(let e of r)if(!Object.is(n[e],i[e]))return!1;return!0}function $(e){if("string"!=typeof e)return!1;let t=e.trim().replace(Jn,"");if(0===t.length||Gn.test(t))return!1;if(t.startsWith("#")||t.startsWith("?")||Kn.test(t)||t.startsWith("/"))return!0;try{let e=new URL(t);return Hn.has(e.protocol)}catch{return qn.test(t)}}function R(e){let t=e.trim().replace(Jn,"");return/^https?:\\/\\//i.test(t)||Kn.test(t)}function F(e){return!e.startsWith("on")&&!Xn.has(e)}function N(e){return Zn.add(e),e}function x(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 M(e){return e.closest(`[${ei}]`)}function E(e){let t=e.getAttribute(ti);return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==M(e)?"fragment":null!==e.closest("head")?"route":"patch"}function O(e){return`global:${e}`}function P(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function L(e){return"string"==typeof e&&e.length>0}function U(e,t){return null!==t&&void 0!==e&&t.includes(e)}function I(e){let t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}function j(e,t,n){let i=e.get(t);return void 0!==i&&(!1===n||i.some(e=>U(e.owner,n)))}function _(e,t,n){let i=`${t}.`;for(let[t,r]of e.entries())if(t.startsWith(i)&&(!1===n||r.some(e=>U(e.owner,n))))return!0;return!1}function W(e,t){if(void 0===t||0===t.length)return e;let n=`_${t}`;return e.endsWith(n)?e.slice(0,-n.length):e}function B(e,t,n){let i;return r=>{if(j(e,r,n))return!0;let l=W(r,t);return!!(l!==r&&j(e,l,n)||_(e,r,n)||l!==r&&_(e,l,n))||(i??(i=function(e,t){let n=new Set;for(let[i,r]of e.entries())for(let e of r)!1!==t&&!U(e.owner,t)||void 0!==e.locale&&n.add(`${i}_${e.locale}`);return n}(e,n)),i.has(r))}}function z(e,t,n,i,r){return V(n)?!V(t)||function(e,t,n){let i=void 0===n?void 0:S(n,e);return void 0!==i&&!ii.has(i.type)||!0===t.get(e)?.some(D)||_(t,e,!1)}(e,i,r)?"keep":null==t?"ask":"own":"ask"}function D(e){return!ii.has(e.fieldType)}function V(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function H(e){return!0===e?.includes(".")}function G(e){return null!==e&&e.forceRender&&!e.completed}function q(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function K(...e){let t=new Map;for(let n of e)for(let[e,i]of Object.entries(n)){let n=t.get(e);void 0===n&&(n=new Set,t.set(e,n));for(let e of i)n.add(e)}let n={};for(let[e,i]of t)n[e]=[...i];return n}function J(e,t){let n={};for(let i of t)i!==e&&(n[i]=[e]);return n}function X(e){return"patch"===e.getAttribute(fi)}function Q(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(fi)}(e)&&!X(e)}function Z(e){let t=e.closest(Li)?.getAttribute(Fi);return null==t||0===t.length?void 0:t}function Y(e){return Ii.has(e)||Ui.test(e)}function ee(e){let t=e.getAttribute(gi);if(null!==t&&Y(t))return t;if(e.hasAttribute(Ai))return"richText";if(e.hasAttribute(Ci))return"html";if(e.hasAttribute(Ri))return"structural-array";if(e.hasAttribute($i))return"array";if("IMG"===e.tagName)return"image";if("A"===e.tagName)return"url";if("TIME"===e.tagName)return"date";if("INPUT"===e.tagName){let t=e.type;if("checkbox"===t)return"checkbox";if("number"===t)return"number";if("date"===t||"datetime-local"===t)return"date"}return"text"}function te(){return!0}function ne(e,t){return e.length>0&&e.length<=t&&"."!==e&&".."!==e&&!e.includes("/")&&!e.includes("\\\\")&&!function(e){for(let t of e){let e=t.codePointAt(0)??0;if(e<=31||127===e)return!0}return!1}(e)}function ie(e){return ne(e,128)&&!e.includes("?")&&!e.includes("#")}function re(e){return e.has("schema-json")?Bi:e.has("document-events")||e.has("relationship-events")?zi:Di}function le(e){if(e.nodeType!==Vi)return!1;let t=e;return t.hasAttribute(mi)||null!==t.querySelector(`[${mi}]`)}function oe(){if(typ','eof window>"u")return;let e=window;return e[Gi]??(e[Gi]={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]})}function ae(){let e=oe();if(void 0===e||e.armed)return;e.armed=!0;let t=window,n=t.__REACT_DEVTOOLS_GLOBAL_HOOK__??(t.__REACT_DEVTOOLS_GLOBAL_HOOK__=function(){let e=new Map;return{supportsFiber:!0,renderers:e,inject:t=>{let n=e.size+1;return e.set(n,t),n}}}()),i=n.onCommitFiberRoot;n.onCommitFiberRoot=function(t,n,...r){try{i?.call(this,t,n,...r)}catch{}let l=n?.containerInfo;void 0===e.onCommit?e.commits.push(l):e.onCommit(l)}}function se(e){e.committed=!0;let t=e.waiters;e.waiters=[];for(let e of t)e()}function ue(e,t){let n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function de(e,t,n){if(e.committed)return null;let i=null,r=()=>{null!==i&&clearTimeout(i),i=null,t("committed")};return e.waiters.push(r),i=setTimeout(()=>{i=null,ue(e,r),t("timed-out")},n),()=>{null!==i&&clearTimeout(i),i=null,ue(e,r)}}function ce(){if(typ','eof window>"u")return;let e=window;return e[Ji]??(e[Ji]={armed:!1,committed:!1,waiters:[]})}function he(e){return Object.prototype.hasOwnProperty.call(e,Ki)?e[Ki]:void 0}function fe(){let e=ce();if(void 0===e||e.armed)return;e.armed=!0;let t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,Ki)&&Object.defineProperty(t,Ki,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,Ki,{value:e,writable:!0,configurable:!0,enumerable:!0});let t=ce();void 0===t||t.committed||null===this.querySelector(qi)||function(e,t){let n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?se(e):n.hook(Xi,()=>{e.committed||se(e)})}(t,e)}})}function pe(e){if(void 0===e.hydration){e.startNow();return}let t=t=>{e.later(()=>{me(e,t)})},n="react"===e.hydration?function(e,t=5e3){ae();let n=oe();if(void 0===n)return null;if(void 0===n.onCommit){let e=e=>{!n.committed&&function(e){let t=e;return 9===t?.nodeType||null!=t?.querySelector?.(qi)}(e)&&se(n)};n.onCommit=e;for(let t of n.commits.splice(0))e(t)}return de(n,e,t)}(t):function(e,t,n=5e3){fe();let i=ce();return void 0===i?null:(!i.committed&&function(e){for(let t=e.querySelector(qi);null!==t;t=t.parentElement)if(void 0!==he(t))return!0;return!1}(e)&&se(i),de(i,t,n))}(e.root,t);null!==n?(e.defer(n),e.hydrated("waiting")):me(e,"committed")}function me(e,t){e.hydrated(t),"timed-out"===t&&e.warn(`[live-preview] LP0607: no ${"react"===e.hydration?"React commit":"Vue mount"} in ${String(5e3)} ms; started without waiting for hydration.`),e.startNow()}function ge(e,t=tr){if("string"!=typeof e)return!1;let n=e.trim();return!(n.length<t||ir.test(n)||nr.has(n.toLowerCase())||rr.test(n)||lr.test(n))}function ve(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ye(e,t,n=tr){let i=new Map,r=(e,t,n)=>{i.set(e,i.has(e)?null:{field:t,media:n})};for(let[i,l]of Object.entries(e)){if(ni.has(i))continue;let e=W(i,t);if(ge(l,n))r(l.trim(),e,!1);else if(ve(l))if("string"==typeof l.url)r(l.url,e,!0);else if(!("id"in l)&&!("_id"in l))for(let[t,i]of Object.entries(l))ni.has(t)||!ge(i,n)||r(i.trim(),`${e}.${t}`,!1)}return i}function be(e){if(e.namespaceURI!==ar||or.has(e.tagName)||e.hasAttribute(mi)||e.hasAttribute(Yi)||e.hasAttribute(er)||Q(e))return!0;let t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function we(e){let t;for(let n=e.firstChild;null!==n;n=n.nextSibling){if(1===n.nodeType)return;if(3!==n.nodeType)continue;let e=n.data.trim();if(0!==e.length){if(void 0!==t)return;t=e}}return t}function Se(e){return F(e)&&!e.startsWith("data-payload-")&&"value"!==e}function Te(e,t,n){let i=e.byElement.get(t);void 0===i&&(i={attributes:new Map},e.byElement.set(t,i));let r=e.byField.get(n.field);return void 0===r&&(r=new Set,e.byField.set(n.field,r)),r.add(t),i}function ke(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(be(n))continue;let e=we(n),i=void 0===e?void 0:t.values.get(e);null!=i&&!i.media&&(Te(t,n,i).text=i.field);for(let e of n.getAttributeNames()){if(!Se(e))continue;let i=t.values.get(n.getAttribute(e)??"");null!=i&&(i.media&&("IMG"!==n.tagName||"src"!==e)||Te(t,n,i).attributes.set(e,i))}ke(n,t)}}function Ae(e,t,n){let i=e.tagName;if(void 0!==t){let r={[mi]:t};if("A"===i){let e=n.get("href");void 0===e?r[gi]="text":e!==t&&(r[yi]=e)}return{element:e,fieldName:t,matched:we(e)??"",stamps:r}}if("IMG"===i){let t=n.get("src");if(void 0!==t){let i=n.get("alt");return{element:e,fieldName:t,matched:e.getAttribute("src")??"",attribute:"src",stamps:{[mi]:t,...void 0!==i&&i!==t?{[wi]:i}:{}}}}}let r=n.entries().next();if(r.done)return;let[l,o]=r.value;return{element:e,fieldName:o,matched:e.getAttribute(l)??"",attribute:l,stamps:{[mi]:o,[vi]:l}}}function Ce(e,t){let n={values:t,byElement:new Map,byField:new Map};t.size>0&&!be(e)&&ke(e,n);let i=e=>1===n.byField.get(e)?.size,r=[];for(let[e,t]of n.byElement){let n=void 0!==t.text&&i(t.text)?t.text:void 0,l=new Map;for(let[e,n]of t.attributes)i(n.field)&&l.set(e,n.field);let o=Ae(e,n,l);void 0!==o&&r.push(o)}return r}function $e(e){return 9===e.nodeType?e.body:e}function Re(e,t,n,i){let r=[];for(let l of t){let{element:t}=l;if(!t.hasAttribute(mi)&&(!1===n||U(Z(t),n))){for(let[e,n]of Object.entries(l.stamps))t.setAttribute(e,n);if(t.setAttribute(Ei,l.matched),void 0===e.cache.add(t)){for(let e of Object.keys(l.stamps))t.removeAttribute(e);t.removeAttribute(Ei);continue}e.observers.observeElement(t),e.log("autoBind",l.fieldName,"\\u2192",`<${t.tagName.toLowerCase()}>`,l.attribute??"text",JSON.stringify(l.matched),i),r.push(l)}}return r}function Fe(e,t,n,i=!1){if(i&&void 0!==n){let i=Ne(e,`${t}_${n}`);if(void 0!==i)return i}let r=Ne(e,t);if(void 0!==r)return r;if(t.includes(".")){let n=e,i=!0;for(let e of t.split(".")){if(sr.has(e)||null===n||"object"!=typeof n){i=!1;break}if(n=Ne(n,e),void 0===n){i=!1;break}}if(i)return n}return void 0===n?void 0:Ne(e,`${t}_${n}`)}function Ne(e,t){if(!sr.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function xe(e,t,n,i){return Fe(e,n,t.locale??i,void 0!==t.locale)}function Me(e,t,n,i){let r=x(t);if(void 0===r)return;let l=[e.hrefField,e.srcField,e.altField],o=r;for(let t of l){if(void 0===t||0===t.length)continue;let r=x(xe(n,e,t,i));if(void 0===r)return;o+=`|${t}=${r}`}return o}function Ee(e,t,n,i,r){let{warned:l,warn:o}=e;if(l.has(n)||t(n))return;l.add(n);let a=`data-payload-field="${W(n,i)}"`;o(""!==r?`[live-preview] LP0203: field "${n}" has a value and no <\\u2026 ${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 <\\u2026 ${a}> for the empty field "${n}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)}function Oe(e){let t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function Pe(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Le(e){let t=function(){let e=function(){let e=globalThis,t=e[dr];if(void 0!==t)return t;let n={};return e[dr]=n,n}();if(void 0!==e.override)return e.override;if(void 0!==e.auto)return e.auto;let t=function(){let e=globalThis.trustedTypes;return"object"!=typeof e||null===e?void 0:"function"==typeof e.createPolicy?e:void 0}();try{e.auto=void 0===t?null:t.createPolicy(ur,{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===t?e:t.createHTML(e)}function Ue(e,t){for(let n of t.keyAttributes){let t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function Ie(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(fi)||e.hasAttribute(cr))return!0;let t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function je(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!Ie(e)&&!Ie(t)}(e,t))return t;let i=ze(e);return function(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||hr.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(let 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){let i=function(e,t){let n,i=new Map;for(let r of Array.from(e.children)){let e=Ue(r,t);if(void 0!==e){if(i.has(e)){n??(n=e.slice(e.indexOf("=")+1));continue}i.set(e,r)}}return void 0!==n&&t.onDuplicateKey?.(e,n),i}(e,n),r=new Set(i.values()),l=Array.from(e.childNodes).filter(e=>!r.has(e)),o=new Set,a=new Set,s=Array.from(t.childNodes),u=e.firstChild,d=0;for(let t=0;t<s.length;t+=1){let r=s[t],c=null,h=r instanceof Element?Ue(r,n):void 0;if(void 0!==h&&a.has(h)&&(h=void 0),void 0!==h){a.add(h);let e=i.get(h);if(void 0!==e&&!o.has(e)&&(c=_e(e,r,n)===e?e:null,null===c)){e.replaceWith(r),o.add(r),u=r.nextSibling;continue}}else{for(;d<l.length;){let i=l[d];if(d+=1,!o.has(i)){if(Be(i,r)){c=_e(i,r,n)===i?i:null,null===c&&(e.replaceChild(r,i),o.add(r),u=r.nextSibling);break}if(i instanceof Element){let n=s[t+1];if(!(r instanceof Element)||void 0!==n&&Be(i,n)){d-=1;break}e.replaceChild(r,i),o.add(r),u=r.nextSibling;break}if(!(r instanceof Element)){e.replaceChild(r,i),o.add(r),u=r.nextSibling;break}}}if(null===c&&o.has(r))continue}let f=c??r;for(o.add(f);null!==u&&u!==f&&!o.has(u)&&We(u);)u=u.nextSibling;f!==u&&e.insertBefore(f,u),u=f.nextSibling}for(let t of Array.from(e.childNodes))o.has(t)||t.remove()}(e,t,n),De(i),e}function _e(e,t,n){return e instanceof Element&&t instanceof Element?Ie(e)&&Ie(t)?e:je(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function We(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function Be(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function ze(e){let 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 De(e){if(null===e)return;let{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});let[e,i]=n??[null,null];null!==e&&null!==i&&t.setSelectionRange(e,i)}catch{}}function Ve(e){fr.has(e)||(fr.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(pr)?"A binding inside CMS content is refused by design \\u2014 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 \\u2014 DOM clobbering, refused by design (docs/security.md)":"List it in `allowedDataAttributes` if the page needs it, or set `sanitizerPolicy: \'compat\'` to keep every `data-*` as 1.x did"}(e)}.`))}function He(e,t,n){let i=Ge();if(!i)throw new Error("sanitizeHtml needs a DOM");if(""===e)return"";let r=function(e,t){let n=e?.policy??t??Rr;if(!e){let e=new Map;for(let[t,n]of Object.entries(Tr))e.set(t,n);return{allowedTags:mr,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:new Set}}let i=new Set(mr);if(e.additionalAllowedTags?.forEach(e=>i.add(e)),!0===e.allowFormControls)for(let e of gr)i.add(e);let r=new Map;for(let[e,t]of Object.entries(Tr))r.set(e,t);for(let[t,n]of Object.entries(e.additionalAllowedAttributes??{})){let e=new Set(r.get(t));for(let t of n)e.add(t);r.set(t,e)}return{allowedTags:i,attrByTag:r,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(n,t),l=i.createElement("template");return l.innerHTML=Le(e),qe(l.content,r),l.innerHTML}function Ge(){if(!(typ','eof document>"u"))return document}function qe(e,t){for(let n of Array.from(e.childNodes))n.nodeType===Ar?Ke(n,t):n.nodeType===Cr&&n.remove()}function Ke(e,t){let n=e.tagName.toLowerCase();!vr.has(n)||t.allowFormControls&&gr.has(n)?t.allowedTags.has(n)?(function(e,t,n){let i=n.attrByTag.get(t);for(let t of Array.from(e.attributes)){let r=t.name.toLowerCase();if(r.startsWith("on")||"style"===r)e.removeAttribute(t.name);else{if("strict"===n.mode){if(n.templateMode&&$r.has(r))continue;if("id"===r||"name"===r||r.startsWith(Sr)){e.removeAttribute(t.name),("name"!==r||!0===i?.has(r))&&Ve(r);continue}if(r.startsWith(wr)){n.allowedData.has(r)||(e.removeAttribute(t.name),Ve(r));continue}if(yr.has(r)||r.startsWith(br))continue}else if(yr.has(r)||r.startsWith(br)||r.startsWith(wr))continue;i?.has(r)?(kr.has(r)&&!$(t.value)||"srcset"===r&&!Je(t.value))&&e.removeAttribute(t.name):e.removeAttribute(t.name)}}}(e,n,t),"a"===n&&function(e){let t=e.getAttribute("href");null===t||!R(t)||(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),qe(e,t)):(qe(e,t),e.replaceWith(...e.childNodes)):e.remove()}function Je(e){for(let t of e.split(",")){let e=t.trim();if(0===e.length)continue;let[n=e]=e.split(/\\s/,1);if(!$(n))return!1}return!0}function Xe(e){return e.replace(Nr,e=>Fr[e])}function Qe(e){return e.replace(Mr,e=>xr[e])}function Ze(e){let t=new Set;for(let n of e)if("object"==typeof n&&null!==n)for(let e of Object.keys(n))t.add(e);return t}function Ye(e,t,n,i,r){let l="object"==typeof t&&null!==t?t:null;return e.replace(Er,(e,o)=>null!==l&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(l,o)?Xe(i(Reflect.get(l,o))):null===l&&"value"===o?Xe(i(t)):"index"===o?String(n):null!==l&&!0===r?.has(o)?"":e)}function et(e){let t=e.children,n=t[0];if(void 0===n)return[];let i=[];for(let{name:e,value:r}of Array.from(n.attributes)){if(!F(e)||e.startsWith(Or))continue;let n=!0;for(let i=1;i<t.length&&n;i+=1)n=t[i]?.getAttribute(e)===r;n&&i.push([e,r])}return i}function tt(e,t){for(let[n,i]of t)e.hasAttribute(n)||e.setAttribute(n,i)}function nt(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 it(e){return null==e||""===e}function rt(e,t){let n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function lt(e,t,n,i){return e.set(t,n),function(e,t){for(let n of e.keys()){if(e.size<=t)break;e.delete(n)}}(e,i),n}function ot(e){let t=rt(jr,e);if(void 0!==t)return t;let n=new Set(Pr);for(let t of e.matchAll(Ur)){let e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}let i={};for(let e of n)i[e]=Lr;let r={additionalAllowedTags:[...n],additionalAllowedAttributes:i,allowFormControls:!0,templateMode:!0};return lt(jr,e,r,Ir)}function at(e){let t=ut(e.container,e.patches,e);return null===t?null:dt(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function st(e,t){return t.hasAttribute(Wr)&&t.hasAttribute(Br)}function ut(e,t,n){let i=function(e,t,n){let{template:i,nextItems:r,forceRender:l=!1,store:o,sanitizerPolicy:a}=n,s=o.get(e),u=et(e),d=Ze(r),c=Array.from(e.children),h=vt(c,_r),f=new Set,p=[];for(let o=0;o<r.length;o+=1){let m=r[o],g=gt(m),v=void 0===g?c[o]??null:yt(h,g)??null;null!==v&&f.has(v)&&(v=null),null!==v&&f.add(v);let y=t.replaces.has(o),b=l||t.renders.has(o)||null===v?bt(e.ownerDocument,i,m,o,a,u,d):void 0;if(null===b)return null;let w=void 0===b?[]:ct(y?null:v,b,m,void 0===g?void 0:s?.get(g),n);if(null===w)return null;p.push([o,v,b,w,y])}return p}(e,function(e){let t=new Set,n=new Set;for(let i of e)"insert"===i.kind||"update"===i.kind?t.add(i.index):"replace"===i.kind&&(t.add(i.index),n.add(i.index));return{renders:t,replaces:n}}(t),n);return null===i?null:[e,i,n.nextItems]}function dt(e,t,n){let[i,r,l]=e,o=new Set,a=!1,s=ze(i);for(let[e,l,s,u,d]of r){let r=l;if(void 0!==s){let e=!(!n.morph||d||null===l)&&je(l,s,{keyAttributes:[_r,Wr],retainChildrenOf:st,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===l;if(!e)for(let[e,t]of u)null!==e&&(ft(e,t),t.replaceWith(e));for(let[,,e]of u)void 0!==e&&dt(e,t,n);e?a=!0:(null!==l&&(l.replaceWith(s),a=!0),r=s)}if(null===r)continue;let c=i.children[e]??null;r!==c&&(i.insertBefore(r,c),a=!0),o.add(r)}for(let e of Array.from(i.children))o.has(e)||(e.remove(),a=!0);De(s);let u=function(e,t){let n=t.get(e);return n||(n=new Map,t.set(e,n)),n}(i,t);u.clear();for(let e of l)mt(u,e);return a}function ct(e,t,n,i,r){let l=vt(null===e?[]:ht(e),Wr),o=[];for(let e of ht(t)){let t=e.getAttribute(Wr);if(null===t)continue;let a,s=yt(l,t)??null,u=e.getAttribute(Br),d=u?s:null,c=d?.getAttribute(Br)??null;if(u){let l=pt(n,t);if(void 0!==l||null!==d){let n=l??[],o=A(null===d?[]:pt(i,t)??[],n),s=null!==d&&c!==u;if((o.length>0||s)&&(a=ut(d??e,o,{template:u,nextItems:n,forceRender:s,store:r.store,sanitizerPolicy:r.sanitizerPolicy})??void 0,void 0===a))return null}}o.push([d,e,a])}return o}function ht(e){return Array.from(e.querySelectorAll(`[${Wr}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(Wr))return!1;n=n.parentElement}return n===e})}function ft(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||e.removeAttribute(n.name);for(let n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function pt(e,t){if("object"!=typeof e||null===e)return;let n=e[t];return Array.isArray(n)?n:void 0}function mt(e,t){let n=gt(t);void 0!==n&&e.set(n,t)}function gt(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function vt(e,t){let n=new Map;for(let i=e.length-1;i>=0;i-=1){let r=e[i];if(void 0===r)continue;let l=r.getAttribute(t);if(null===l)continue;let o=n.get(l);void 0===o?n.set(l,[r]):o.push(r)}return n}function yt(e,t){return e.get(t)?.pop()}function bt(e,t,n,i,r,l,o){let a=He(Ye(t,n,i,nt,o),r,ot(t)),s=e.createElement("template");s.innerHTML=Le(a);let u=s.content.firstElementChild;if(!u)return null;tt(u,l);let d=gt(n);return void 0!==d&&u.setAttribute(_r,d),u}function wt(e,t){let n=new Set(t);return{boundaries:t,strategy:e,covers:e=>void 0!==e.fragmentBoundary&&n.has(e.fragmentBoundary)}}function St(t,n,i,r,l){let o=t.transformValue;if(void 0===o)return i;try{let t=o(n.fieldName,i,{element:n.element,allFields:r},l),a=e(t);if(!l())return i;if(a)throw new TypeError(`Transform for "${n.fieldName}" returned a thenable; transforms must be synchronous`);return t}catch(e){if(!l())return i;let n=e instanceof Error?e:new Error(String(e));return t.emitter.emit("error",{error:n,context:"transform",code:"LP0602"}),i}}function Tt(e){return 9===e.nodeType}function kt(e){return e.body}function At(){if(typ','eof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function Ct(e){let t=e.trim();if(0!==t.length)try{let e=new URL(t);return"http:"!==e.protocol&&"https:"!==e.protocol||!Jr.test(e.origin)?void 0:e.origin}catch{return}}function $t(e){let t=e.format;return"string"==typeof t&&el.has(t)?t:"number"==typeof t?Yr[t]:void 0}function Rt(e){let t=e.indent;return"number"==typeof t&&t>0?t:0}function Ft(e){return"rtl"===e.direction?\' dir="rtl"\':"ltr"===e.direction?\' dir="ltr"\':""}function Nt(e){let t=$t(e),n=Rt(e),i=[];return void 0!==t&&i.push(`lp-align-${t}`),n>0&&i.push(`lp-indent-${String(n)}`),0===i.length?"":` class="${i.join(" ")}"`}function xt(e){return"object"==typeof e&&null!==e?e:void 0}function Mt(e){return xt(e)}function Et(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function Ot(e){return"string"==typeof e&&e.length>0?e:void 0}function Pt(e){let t=Ot(e.title)??Ot(e.name)??Ot(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}function Lt(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(let n of e.children)t+=Lt(n);return t}function Ut(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function It(e){return"string"==typeof e.mimeType?` type="${Qe(e.mimeType)}"`:""}function jt(e){return rl.get(e)}function _t(e,t,n,i){let r=xt(e.fields)??{},l="string"==typeof r.blockType?r.blockType:"",o=Et(l),a=""===o?i:`${i} ${i}--${o}`;if(""!==l){let e=jt(l)??jt(o);if(e)return e(r,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(l,a)}return`<${n} class="${a}"></${n}>`}function Wt(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}function Bt(e){if("object"!=typeof e||null===e||!("root"in e))return!1;let t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function zt(e,t){let n=function(e){return al.get(e)??ol[e]}(e.type);return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function Dt(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\\n";if(void 0===e.children)return"";let t="";for(let n of e.children)t+=Dt(n);return t}function Vt(e="text"){let t=new WeakSet;return{name:e,render:N((e,n)=>{let i=e.element,r=function(e){return null==e?"":Bt(e)?function(e){return Bt(e)?e.root.children.map(Dt).join("\\n").trim():""}(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e)}(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName){if(function(e){return null!==e.querySelector(":scope > :not(br)")}(i)&&!i.hasAttribute(ul))return function(e,t,n){e.has(t)||(e.add(t),An(`[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,i,e.fieldName),!1;r.includes("\\n")||r.includes("\\r")?i.innerHTML=Le(function(e){return Xe(e).replace(/\\r\\n|\\r|\\n/g,"<br>")}(r)):i.textContent=r}else i.value=r})}}function Ht(e,t){let n=e.cloneNode(!1);n.innerHTML=Le(t);let i=function(e,t){let n=e.firstElementChild;if(null!==n?.nextElementSibling||t.children.length<2||!hl.has(n.tagName)||n.hasAttribute(mi))return null;for(let e of t.children)if(e.tagName===n.tagName&&e.className===n.className)return null;return n}(e,n)??e,r=new Map,l=n.querySelectorAll(ll);if(l.length>0&&null!==i.firstElementChild){let e=[];Gt(i,n,e);for(let[t,n]of e)t.replaceWith(n),n.matches(ll)||r.set(t.className,!1);for(let e of l)null!==e.parentNode&&r.set(e.className,!0)}return i.replaceChildren(...n.childNodes),r}function Gt(e,t,n){if(e.children.length!==t.children.length)return;let i=e.firstElementChild,r=t.firstElementChild;for(;null!==i&&null!==r;)r.matches(ll)?n.push([r,i]):Gt(i,r,n),i=i.nextElementSibling,r=r.nextElementSibling}function qt(e,t,n,i){i&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);let r=i?cl:dl;r.has(n)||(r.add(n),An(`[live-preview] ${i?`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().`))}function Kt(e,t,n){return"string"!=typeof n||0===n.length?{kind:"none"}:$(n)?{kind:"safe",url:n}:(ml.has(e)||(ml.add(e),An(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function Jt(e,t=e=>e){return{name:e,render(e,n,i){let r=e.element;if(it(n)){!function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(r);return}let l=nt(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName){if("A"===r.tagName){let n=e.hrefField,o=void 0===n||0===n.length?t(l):Fe(i.allFields,n,i.locale,void 0!==e.locale),a=Kt(r,e.fieldName,o);"safe"===a.kind?r.setAttribute("href",a.url):"unsafe"===a.kind&&r.removeAttribute("href")}r.textContent=l}else r.value=l}}}function Xt(e){for(let t of bl)e.removeAttribute(t)}function Qt(e,t,n){e.src=t;let i=function(e){if(void 0===e?.sizes)return;let t=[];for(let n of Object.values(e.sizes))"string"!=typeof n.url||"number"!=typeof n.width||!$(n.url)||t.push(`${Zt(n.url)} ${String(n.width)}w`);return 0!==t.length?("number"==typeof e.width&&"string"==typeof e.url&&$(e.url)&&t.push(`${Zt(e.url)} ${String(e.width)}w`),t.join(", ")):void 0}(n);void 0!==i?e.setAttribute("srcset",i):(e.removeAttribute("srcset"),e.removeAttribute("sizes"))}function Zt(e){return e.replace(/[\\s,]/g,encodeURIComponent)}function Yt(e){"IMG"===e.tagName?Xt(e):e.style.backgroundImage=""}function en(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):Xt(e)}function tn(e){let t=xt(e);return void 0===t?nt(e):Pt(t)??""}function nn(e,t){let n=e??"";if(null==t)return n;let i=rn(t);return"{}"===i?n:`${n}|${i}`}function rn(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>rn(e)).join(",")}]`;let t=e,n=Object.keys(t).sort(),i=[];for(let e of n){let n=t[e];void 0!==n&&i.push(`${JSON.stringify(e)}:${rn(n)}`)}return`{${i.join(",")}}`}function ln(e){return{kind:"date",options:e}}function on(e){return{kind:"number",options:e}}function an(e,t,n,i){if(void 0===t||""===t)return;let r=function(e){let t=e.indexOf(":"),n=-1===t?e:e.slice(0,t),i=-1===t?void 0:e.slice(t+1);switch(n){case"date":return void 0===i?ln({dateStyle:"medium"}):Fl.has(i)?ln({dateStyle:i}):void 0;case"time":return void 0===i?ln({timeStyle:"short"}):Nl.has(i)?ln({timeStyle:i}):void 0;case"datetime":return void 0===i?ln({dateStyle:"medium",timeStyle:"short"}):Fl.has(i)?ln({dateStyle:i,timeStyle:"short"===i?"short":"medium"}):void 0;case"number":return void 0===i?on({}):Ml.test(i)?on({minimumFractionDigits:Number(i),maximumFractionDigits:Number(i)}):void 0;case"currency":return void 0!==i&&xl.test(i)?on({style:"currency",currency:i.toUpperCase()}):void 0;case"percent":return void 0===i?on({style:"percent"}):void 0;default:return}}(t);if(void 0!==r)return r.kind===e?r.options:void 0;!function(e,t,n){El.has(e)||(El.add(e),An(`[live-preview] LP0408: data-payload-format="${n}" on "${t}" is not a known format; the default formatting was used. Known: date, date:short|medium|long|full, time, datetime, number, number:0-4, currency:XXX, percent.`))}(n,i,t)}function sn(e){return String(e).padStart(2,"0")}function un(){let e=new WeakMap,t=new WeakSet,n=new WeakMap,i=new WeakMap;return{name:"structural-array",render:N((r,l,o)=>{let a=it(l)?[]:l;if(!Array.isArray(a))return!1;let s=r.element,u=r.arrayTemplate;if(void 0===u||0===u.length)return function(e,t,n){e.has(t)||(e.add(t),An(`[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,s,r.fieldName),!1;let d=e.get(s),c=dn(s),h=d?.values??function(e){return e.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e})}(c),f=A(h,a),p=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)}(d,u,c);if(0===f.length&&!p)return e.set(s,{values:a.slice(),template:u,domSnapshot:c}),!1;!function(e,t,n,i,r){let l=r.map(cn),o=new Set,a=l.find(e=>!(void 0===e||!o.has(e)&&(o.add(e),1)));if(void 0!==a&&hn(e,t,n,a),l.some(e=>void 0===e)&&fn(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.`),i?.length===r.length&&r.length>1){let r=new Set(i.map(cn).filter(e=>void 0!==e)),o=l.some(e=>void 0!==e&&r.has(e));r.size>0&&!o&&fn(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,s,r.fieldName,d?.values,a);let m=at({template:u,container:s,patches:f,nextItems:a,store:i,forceRender:p,sanitizerPolicy:o.sanitizerPolicy,onDuplicateKey:(e,t)=>{hn(n,e,r.fieldName,t)}});return null!==m&&(e.set(s,{values:a.slice(),template:u,domSnapshot:dn(s)}),!!m&&void 0)})}}function dn(e){return Array.from(e.children,e=>e.getAttribute(_r))}function cn(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function hn(e,t,n,i){fn(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${i}"; later ones pair by position. Make \\`id\\` unique per item.`)}function fn(e,t,n,i){let r=e.get(t);void 0===r&&(r=new Set,e.set(t,r)),!r.has(n)&&(r.add(n),An(`[live-preview] ${i}`))}function pn(){return typeof __LIVE_PREVIEW_CONFIG__>"u"?[]:__LIVE_PREVIEW_CONFIG__}var mn=Object.defineProperty,gn=e=>{throw TypeError(e)},vn=(e,t,n)=>((e,t,n)=>t in e?mn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),yn=(e,t,n)=>t.has(e)||gn("Cannot "+n),bn=(e,t,n)=>(yn(e,t,"read from private field"),n?n.call(e):t.get(e)),wn=(e,t,n)=>t.has(e)?gn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Sn=(e,t,n,i)=>(yn(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),Tn=(e,t,n)=>(yn(e,t,"access private method"),n),kn=t((...e)=>console.error(...e)),An=t((...e)=>console.warn(...e)),Cn=t((...e)=>console.debug(...e)),$n=class{constructor(){wn(this,Nn);wn(this,Rn,new Map);wn(this,Fn,new Map)}on(e,t){return Tn(this,Nn,Mn).call(this,bn(this,Rn),e,t)}once(e,t){return Tn(this,Nn,Mn).call(this,bn(this,Fn),e,t)}off(e,t){Tn(this,Nn,En).call(this,bn(this,Rn),e,t),Tn(this,Nn,En).call(this,bn(this,Fn),e,t)}async emit(e,t){await Tn(this,Nn,xn).call(this,e,t)}async emitWhile(e,t,n){return Tn(this,Nn,xn).call(this,e,t,n)}listenerCount(e){return(bn(this,Rn).get(e)?.size??0)+(bn(this,Fn).get(e)?.size??0)}removeAllListeners(e){void 0!==e?(bn(this,Rn).delete(e),bn(this,Fn).delete(e)):(bn(this,Rn).clear(),bn(this,Fn).clear())}eventNames(){let e=new Set;for(let t of bn(this,Rn).keys())e.add(t);for(let t of bn(this,Fn).keys())e.add(t);return[...e]}},Rn=new WeakMap,Fn=new WeakMap,Nn=new WeakSet,xn=async function(e,t,n){let i=()=>n?.()??!0;if(!i())return!1;let r=bn(this,Rn).get(e);if(r)for(let n of[...r])if(!i()||(await Tn(this,Nn,On).call(this,n,t,e),!i()))return!1;if(!i())return!1;let l=bn(this,Fn).get(e);if(l&&l.size>0){let n=[...l];bn(this,Fn).delete(e);for(let r of n)if(!i()||(await Tn(this,Nn,On).call(this,r,t,e),!i()))return!1}return i()},Mn=function(e,t,n){let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(n),()=>{Tn(this,Nn,En).call(this,e,t,n)}},En=function(e,t,n){let i=e.get(t);void 0!==i&&(i.delete(n),0===i.size&&e.delete(t))},On=async function(e,t,n){try{await e(t)}catch(e){let t="string"==typeof n||"number"==typeof n?String(n):"<event>";kn(`[live-preview] LP0601: handler for "${t}" threw:`,e)}},Pn=new Set(["date","number","checkbox"]),Ln=40,Un="payload-live-preview-a11y",In=new WeakMap,jn=class{constructor(e,t){vn(this,"german");vn(this,"document");vn(this,"lease",null);let n=t??(typ','eof document>"u"?null:document),i=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(i.length>0?i:s())),this.document=n}mount(){let e=this.document;if(null==e?.body)return null;this.lease??(this.lease=function(e){let t=In.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},In.set(e,t)),t.refs+=1,t}(e));let t=this.lease,n=t.element;if(n?.isConnected&&n.ownerDocument===e)return n;if(null!==n){let e=t.owned;u(t),e&&n.remove()}let i=e.getElementById(Un);return t.owned=null===i,null===i&&(i=e.createElement("div"),i.id=Un,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-atomic","true"),i.setAttribute("style","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(i)),t.element=i,i}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?"\\xc4nderung":"\\xc4nderungen"} angewendet`:`${String(e)} ${1===e?"change":"changes"} applied`)}detach(){let e=this.lease,t=this.document;if(null===e||null===t||(this.lease=null,e.refs-=1,e.refs>0))return;let n=e.element;null!==n&&u(e),e.owned&&n?.remove(),e.element=null,In.delete(t)}say(e){let 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);let r=setTimeout(()=>{n.timer===r&&n.element===t&&u(n)},1500);n.timer=r}},_n=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],Wn={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"}},Bn=Object.keys(Wn),zn=class{constructor(e,t){vn(this,"matcher");vn(this,"handlers");vn(this,"boundListener");vn(this,"attachedTarget");vn(this,"generation",0);vn(this,"revision",0);vn(this,"queueHead");vn(this,"queueTail");this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1,n=i=>{if(!t||this.boundListener!==n)return;let r=this.generation;try{this.receive(i,r,e)}catch{let e;try{e=i.origin}catch{e=""}this.reportInvalid("shape",e,r)}};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(){let 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)}static sendReady(e,t){let n={type:"payload-live-preview",ready:!0,protocolVersion:4};for(let i of e)for(let e of t)try{i.postMessage(n,e)}catch{}}receive(e,t,n){let i=e.origin;if(!this.matchesOrigin(i,t)){this.reportInvalid("origin",i,t);return}if(!this.matchesSource(e,n)){this.reportInvalid("source",i,t);return}let r=e.data;if(function(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type}(r))switch(r.type){case"payload-live-preview":if(!function(e){let t=e;return!(void 0!==t.data&&null!==t.data&&!p(t.data))&&f(t.fieldSchemaJSON,e=>Array.isArray(e))&&f(t.globalSlug,e=>"string"==typeof e)&&f(t.collectionSlug,e=>"string"==typeof e)&&f(t.locale,e=>"string"==typeof e)&&f(t.ready,e=>"boolean"==typeof e)&&f(t.previewToken,e=>"string"==typeof e)&&f(t.protocolVersion,e=>"number"==typeof e)}(r)){this.reportInvalid("shape",i,t);return}this.dispatchUpdate(function(e){let t={...e};for(let e of _n)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);if(!Array.isArray(t.fieldSchemaJSON))return t;let n;try{n=d(t.fieldSchemaJSON)}catch{n=[]}return{...t,fieldSchemaJSON:n}}(r),i,t);return;case"payload-document-event":if(!function(e){let t=e;return h(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&h(t.slug,e=>"string"==typeof e)&&h(t.id,e=>"string"==typeof e||Number.isFinite(e))}(r)){this.reportInvalid("shape",i,t);return}this.invokeHandler(t,this.handlers.onDocumentEvent,r,i);return;case"payload-live-preview-focus":{let e=function(e){let t=e.field;return"string"==typeof t&&t.length>0?t:void 0}(r);if(void 0===e){this.reportInvalid("shape",i,t);return}this.invokeHandler(t,this.handlers.onFocusField,e,i);return}default:this.reportInvalid("type",i,t)}else this.reportInvalid("shape",i,t)}dispatchUpdate(e,t,n){let i=p(e.data);if(!this.isCurrentGeneration(n))return;let r=i?{generation:n,revision:this.revision+=1}:void 0,l=this.handlers.validateToken;if(!this.isCurrentGeneration(n))return;if(void 0===l){this.commitUpdate(e,t,n,r);return}if(!0===e.ready&&void 0===e.data){this.commitUpdate(e,t,n,void 0);return}let o={generation:n,message:e,origin:t,messageRevision:r,verdict:void 0,next:void 0};this.enqueue(o);let a;try{a=l(e.previewToken,t)}catch{this.settleValidation(o,!1);return}"boolean"!=typeof a?Promise.resolve(a).then(e=>{this.settleValidation(o,!0===e)},()=>{this.settleValidation(o,!1)}):this.settleValidation(o,a)}settleValidation(e,t){e.verdict=t,this.drainQueue(e.generation)}drainQueue(e){for(;this.isCurrentGeneration(e);){let 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,i){void 0===i?this.invokeHandler(n,this.handlers.onUpdate,e,t):this.invokeHandler(n,this.handlers.onUpdate,e,t,i)}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{let n=e.source;if("object"!=typeof n||null===n)return!1;let i=t.parent;return i!==t&&n===i||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(t,n,...i){if(void 0!==n&&this.isCurrentGeneration(t))try{e(n(...i))}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}},Dn=new Set(["tabs","row","collapsible"]),Vn={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"},Hn=new Set(["http:","https:","mailto:","tel:"]),Gn=/^\\s*(?:javascript|data|vbscript|file|blob|about)\\s*:/i,qn=/^(?:\\.{1,2}\\/|[a-zA-Z0-9_-]+\\/?)/,Kn=/^[\\\\/]{2}/,Jn=/[\\t\\n\\r]/g,Xn=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),Qn=new Set(["href","src","poster","cite","action","xlink:href","data"]),Zn=new WeakSet,Yn=class{constructor(){vn(this,"previous",null)}diff(e,t){let n=this.previous,i=null===n,r=new Map,l=new Set;for(let[t,i]of Object.entries(e)){let e=x(i);r.set(t,e),(null===n||void 0===e||n.get(t)!==e)&&l.add(t)}if(null!==n)for(let e of n.keys())r.has(e)||l.add(e);this.previous=r;let o=new Set;for(let[e,n]of Object.entries(t))if(l.has(e))for(let e of n)o.add(e);return{changed:l,invalidated:o,baseline:i}}reset(){this.previous=null}},ei="data-payload-fragment",ti="data-payload-strategy",ni=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]),ii=new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),ri={},li=class{constructor(){vn(this,"rawChanges",new Yn);vn(this,"resolved",null);vn(this,"queued",null);vn(this,"pending",null);vn(this,"timer",null);vn(this,"openUntil",0)}decide(e,t){let n=t.message.data??{},{changed:i}=this.rawChanges.diff(n,ri);if(!function(e){let{cache:t,emitter:n}=e;if(t.islands.length>0||n.listenerCount("beforeUpdate")>0||n.listenerCount("afterUpdate")>0)return!0;for(let e of t.values())if(D(e)||e.fieldName.includes(".")||H(e.hrefField)||H(e.srcField)||H(e.altField))return!0;return void 0!==e.strategies.fragment&&null!==e.root.querySelector(`[${ei}]`)}(e))return{merge:!1,fields:n};let r=this.resolved;if(null===r)return this.resolved=n,{merge:!0,fields:n};let l={...r},o=t.forceRender;for(let a of i){let i=n[a];if(ni.has(a)){l[a]=i;continue}let s=z(a,r[a],i,e.cache,t.schemaIndex);"own"!==s&&(o=!0),"keep"!==s&&(l[a]=i)}return this.resolved=l,{merge:o,fields:l}}request(e,t,n){let i=Date.now();return i>=this.openUntil?(this.dropQueued(),this.openUntil=i+t,{leading:!0,result:e.merge(n)}):(this.queued=n,this.openUntil=i+t,this.pending??(this.pending=function(){let e;return{promise:new Promise(t=>{e=t}),settle:e}}()),null!==this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush(e)},t),{leading:!1,result:this.pending.promise})}recordMerged(e){this.resolved=e}destroy(){this.dropQueued(),this.openUntil=0}dropQueued(){null!==this.timer&&clearTimeout(this.timer),this.timer=null,this.queued=null,this.pending?.settle({status:"superseded"}),this.pending=null}flush(e){let t=this.pending,n=this.queued;this.timer=null,this.pending=null,this.queued=null,null!==t&&null!==n&&e.merge(n).then(t.settle,()=>{t.settle({status:"unavailable"})})}},oi=class{constructor(){vn(this,"negotiation",m(void 0));vn(this,"observed",new Set)}observe(e,t){let n=e.filter(e=>!this.observed.has(e));if(0!==n.length){for(let e of n)this.observed.add(e);this.negotiation=m(this.negotiation.theirs,this.observed),t("protocol",`observed=${n.join(",")}`)}}applyVersion(e,t){let n=this.negotiation;if(n.theirs===e)return;let i=m(e,this.observed);this.negotiation=i,i.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${i.negotiated}`)}},ai=class{constructor(){vn(this,"lastIdentity")}edit(e){let t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;let n=JSON.stringify([t.entitySlug,I(t),t.updatedAt]),i=n!==this.lastIdentity;return this.lastIdentity=n,i&&function(e,t){let n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;let i=I(e),r=I(t.data??{});return void 0!==i&&void 0!==r&&i!==r}(t,e)?t:null}},si=class{constructor(){wn(this,ui)}reveal(e,t,n){return e===bn(this,ui)?"skipped-same":(Sn(this,ui,e),function(e,t){return function(e,t){let n=e.getBoundingClientRect(),i=n.bottom>0&&n.top<t.innerHeight,r=n.right>0&&n.left<t.innerWidth;return i&&r}(e,t)?"already-visible":(e.scrollIntoView({behavior:q(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){Sn(this,ui,void 0)}},ui=new WeakMap,di=class{constructor(){vn(this,"seen",new Map)}note(e,t,n){let i=x(n);if(void 0===i)return;let r=`${t.owner??""}\\0${t.locale??""}\\0${t.fieldName}`,l=this.seen.get(r);void 0!==l?l!==i&&(e.revealIdentities.push([r,i]),e.revealTarget??(e.revealTarget=t)):this.seen.set(r,i)}commit(e){for(let[t,n]of e.revealIdentities)this.seen.set(t,n);e.revealIdentities=[];let t=e.revealTarget;return e.revealTarget=void 0,t}},ci=class{constructor(){vn(this,"started",!1);vn(this,"suspended",!1);vn(this,"deferredStart",null);vn(this,"hydration","idle");vn(this,"activeUpdate",null);vn(this,"locale");vn(this,"schema");vn(this,"schemaIndex");vn(this,"updateCount",0);vn(this,"supersededCount",0);vn(this,"completedCount",0);vn(this,"skippedUnchangedCount",0);vn(this,"lastFlush",null);vn(this,"absentFields",new Set);vn(this,"warnedOrphanFields",new Set);vn(this,"warnedStrategy",new WeakSet);vn(this,"warnedUnattributableMessage",!1);vn(this,"warnedVisibilityGate",!1);vn(this,"warnedFragmentFallback",!1);vn(this,"warnedEscalationUnavailable",!1);vn(this,"warnedProtocolShape",!1);vn(this,"reportedUnfaithful",new WeakSet);vn(this,"checkedServerFormat",new WeakSet);vn(this,"unfaithfulPatches",[]);vn(this,"unfaithfulCount",0);vn(this,"escalatedCount",0);vn(this,"unfaithfulFields",new Set);vn(this,"autoBindSearchMs");vn(this,"autoBindGuesses",null);vn(this,"warnedForeignSource",!1);vn(this,"lastAppliedIdentity",new WeakMap);vn(this,"revealLedger",new di);vn(this,"fragmentStats",{rendered:0,failed:0,superseded:0});vn(this,"routeStats",{refreshes:0,failed:0,refused:0,loopStopped:0});vn(this,"fragmentController",null);vn(this,"routeController",null);vn(this,"routeRetry",null);vn(this,"routeRefreshOwed",!1);vn(this,"readyTimers",[]);vn(this,"revealer",new si);vn(this,"changes",new Yn);vn(this,"merges",new li);vn(this,"protocol",new oi);vn(this,"relationships",new ai)}isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){e.completed||(e.completed=!0,this.completedCount+=1)}abortStrategies(){null!==this.routeRetry&&(clearTimeout(this.routeRetry),this.routeRetry=null,this.routeRefreshOwed=!0);for(let e of["fragmentController","routeController"]){let t=this[e];null!==t&&(this[e]=null,t.abort())}}},hi=class{constructor(e,t){vn(this,"deps",e);vn(this,"state",t);vn(this,"instanceContext");this.instanceContext=function(e){let t={};for(let[n,i]of Object.entries(e))void 0!==i&&(t[n]=i);return t}({renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,reportUnfaithful:(n,i)=>{r(e,t,n,i)}})}apply(e){let{deps:t,state:n}=this,i=n.activeUpdate;if(null===i||void 0===e.revision||!g(i.revision,e.revision)||!n.isCurrent(i))return!1;let{target:l,value:s}=e,u=void 0!==i.schemaIndex?S(i.schemaIndex,l.fieldName):void 0,d=function(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){let e=function(e){if(Object.prototype.hasOwnProperty.call(Vn,e))return Vn[e]}(t);if(void 0!==e)return e}return e.fieldType}(l,u?.type);"text"===d&&!0!==l.explicitFieldType&&function(e){if("object"!=typeof e||null===e||!("root"in e))return!1;let t=e.root;return"object"==typeof t&&null!==t&&Array.isArray(t.children)}(s)&&(d="richText");let c;try{c=t.resolveRenderer(d,l)}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;let h=t.emitter.listenerCount("elementUpdate")>0,f=h?function(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:"IMG"===e.tagName?e.src:e.textContent}(l.element):void 0;if(!n.isCurrent(i))return!1;let p={allFields:e.allFields,locale:l.locale??i.locale,schema:u,...this.instanceContext};!0===l.hidesWhenEmpty&&l.element.toggleAttribute("hidden",function(e){return null==e||("string"==typeof e?0===e.trim().length:Array.isArray(e)&&0===e.length)}(s));try{if(void 0!==l.targetAttribute){if("blocked"===function(e,t,n){let i=t.toLowerCase().trim();if(0===i.length||!F(i))return"blocked";if(null==n)return e.removeAttribute(i),"applied";if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return"blocked";let r=String(n);return Qn.has(i)&&!$(r)?"blocked":(e.setAttribute(i,r),"applied")}(l.element,l.targetAttribute,s))return t.warn(`[live-preview] LP0401: refused to write "${l.fieldName}" into attribute "${l.targetAttribute}"`),!1}else{if(void 0===c)return t.log("no renderer for",d),r(t,n,l,`has no renderer for "${d}"`),!1;{let e=function(e,t,n,i){if("ignore"===e.onUnfaithfulPatch||void 0!==n.format||!Pn.has(i)||t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);let r=o(n.element);return r.trim().length>0?r:void 0}(t,n,l,d);if(!1===function(e,t,n,i){return e.render(t,n,i)}(c,l,s,p)&&function(e){return Zn.has(e.render)}(c))return r(t,n,l,`is a value ${c.name} cannot render`),!1;void 0!==e&&function(e,t,n){let i=o(t.element);i!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${a(n)}, the patch wrote ${a(i)} \\u2014 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,l,e)}}}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;h&&t.emitter.emitWhile("elementUpdate",{element:l.element,fieldName:l.fieldName,previousValue:f,nextValue:s,revision:i.revision.revision,receivedAt:i.receivedAt,source:"patch"},()=>n.isCurrent(i));let m=n.isCurrent(i);return m&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(l.element,e.valueIdentity):n.lastAppliedIdentity.delete(l.element)),m}fail(e,t){if(!this.state.isCurrent(e))return!1;let n=t instanceof Error?t:new Error(String(t));return this.deps.emitter.emitWhile("error",{error:n,context:"renderer",code:"LP0603"},()=>this.state.isCurrent(e)),!1}},fi="data-payload-island",pi=`astro-island, [${fi}]`,mi="data-payload-field",gi="data-payload-type",vi="data-payload-attribute",yi="data-payload-href",bi="data-payload-src",wi="data-payload-alt",Si="data-payload-array-template",Ti="data-payload-array-separator",ki="data-payload-locale",Ai="data-payload-richtext",Ci="data-payload-html",$i="data-payload-array",Ri="data-payload-structural",Fi="data-payload-owner",Ni="data-payload-depends",xi="data-payload-strategy",Mi="data-payload-boundary",Ei="data-payload-guessed",Oi=[mi,gi,vi,yi,bi,wi,Si,Ti,ki,Ai,Ci,$i,Ri,Fi,Ni,xi,Mi,"type"],Pi=`[${mi}]`,Li=`[${Fi}]`,Ui=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,Ii=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"]),ji=class{constructor(e={}){vn(this,"entriesByField",new Map);vn(this,"entryByElement",new WeakMap);vn(this,"filter");vn(this,"count",0);vn(this,"dependencies",null);vn(this,"islandRoots",[]);this.filter=e.filter??te}dependencyMap(){if(null!==this.dependencies)return this.dependencies;let e=[];for(let t of this.values())void 0!==t.dependsOn&&e.push(J(t.fieldName,t.dependsOn));return this.dependencies=K(...e),this.dependencies}get islands(){return this.islandRoots}buildFromRoot(e){let t=performance.now();this.clear();let n=0;for(let t of e.querySelectorAll(Pi))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){let t=[];for(let n of e.querySelectorAll(pi))X(n)||t.push(n);return t}(e),{elementCount:n,fieldCount:this.entriesByField.size,durationMs:performance.now()-t}}add(e){let 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){let 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(let e of this.entriesByField.values())yield*e}has(e){return this.entryByElement.has(e)}clear(){this.entriesByField.clear(),this.entryByElement=new WeakMap,this.count=0,this.dependencies=null,this.islandRoots=[]}replaceEntry(e,t){if(e.fieldName!==t.fieldName)return!1;let n=this.entriesByField.get(e.fieldName),i=void 0===n?-1:n.indexOf(e);return!(void 0===n||i<0||(n[i]=t,0))}removeEntry(e,t){this.entryByElement.delete(e);let n=this.entriesByField.get(t.fieldName),i=void 0===n?-1:n.indexOf(t);return!(void 0===n||i<0||(n.splice(i,1),0===n.length&&this.entriesByField.delete(t.fieldName),this.count-=1,0))}append(e){let t=this.entriesByField.get(e.fieldName);t?t.push(e):this.entriesByField.set(e.fieldName,[e]),this.count+=1}resolveBinding(e){let t=e.getAttribute(mi);if(null===t||0===t.length)return;let n=e.getAttribute(gi),i=e.getAttribute(vi),r=e.getAttribute(yi),l=e.getAttribute(bi),o=e.getAttribute(wi),a=e.getAttribute(Si),s=e.getAttribute(Ti),u=e.getAttribute(ki),d=e.getAttribute("data-payload-format"),c=Z(e),h=function(e){if(null==e)return[];let t=new Set,n=[];for(let i of e.split(/[\\s,]+/)){let e=i.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}(e.getAttribute(Ni)),f=e.getAttribute(xi),p=e.getAttribute(Ei),m=M(e);return{element:e,fieldName:t,fieldType:ee(e),explicitFieldType:null!==n&&Y(n),strategyKind:E(e)??"unknown",...null!==m?{fragmentBoundary:m}:{},...null!==i&&i.length>0?{targetAttribute:i}:{},...null!==r&&r.length>0?{hrefField:r}:{},...null!==l&&l.length>0?{srcField:l}:{},...null!==o&&o.length>0?{altField:o}:{},...null!==a?{arrayTemplate:a}:{},...null!==s?{arraySeparator:s}:{},...null!==u&&u.length>0?{locale:u}:{},...null!==d&&d.length>0?{format:d}:{},...void 0!==c?{owner:c}:{},...h.length>0?{dependsOn:h}:{},...null!==f&&f.length>0?{strategy:f}:{},...e.hasAttribute(Mi)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}},_i=class{constructor(e){vn(this,"serverURL");vn(this,"apiRoute");vn(this,"depth");vn(this,"fetchFn");vn(this,"log");vn(this,"inflight",null);vn(this,"attempt",0);vn(this,"destroyDepth",0);this.serverURL=function(e){let t=e.length;for(;e.endsWith("/",t);)t-=1;return e.slice(0,t)}(e.serverURL);let i=e.apiRoute??"/api";this.apiRoute=i.startsWith("/")?i:`/${i}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=t(e.log??n)}canMerge(e){return null!==this.endpointOf(e)}endpointOf(e){try{let t=e.globalSlug;if(t)return ie(t)?`globals/${encodeURIComponent(t)}`:null;let n=e.collectionSlug??"",i=e.data.id;return ie(n)&&function(e){return"number"==typeof e?Number.isFinite(e):"string"==typeof e&&ne(e,512)}(i)?`${encodeURIComponent(n)}/${encodeURIComponent(String(i))}`:null}catch{return null}}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};let t=this.attempt+=1,n=this.inflight;this.inflight=null;let i=null,r=()=>this.attempt!==t;try{if(n?.abort(),r())return{status:"superseded"};let t=this.endpointOf(e);if(null===t)return r()?{status:"superseded"}:{status:"unavailable"};let l=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===l)return{status:"unavailable"};i=new AbortController,this.inflight=i;let o=`${this.serverURL}${this.apiRoute}/${t}`,a=await l(o,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:JSON.stringify({data:e.data,depth:this.depth,flattenLocales:!1,locale:e.locale}),signal:i.signal});if(r())return{status:"superseded"};if(!a.ok)return this.log("merge HTTP",a.status,o),{status:"unavailable"};let s=await a.json();return r()?{status:"superseded"}:null===s||"object"!=typeof s||Array.isArray(s)?(this.log("merge invalid",o),{status:"unavailable"}):{status:"merged",doc:s}}catch(e){return r()?{status:"superseded"}:(this.log("merge exception",e),{status:"unavailable"})}finally{this.inflight===i&&(this.inflight=null)}}destroy(){this.attempt+=1;let e=this.inflight;this.inflight=null,this.destroyDepth+=1;try{e?.abort()}finally{this.destroyDepth-=1}}},Wi="2.0.5",Bi={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},zi={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},Di={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1},Vi=1,Hi=class{constructor(e,t={}){vn(this,"callbacks");vn(this,"debounceMs");vn(this,"rootMargin");vn(this,"visible",new Set);vn(this,"mutation",null);vn(this,"intersection",null);vn(this,"debounceTimer",null);vn(this,"generation",0);this.callbacks=e,this.debounceMs=t.mutationDebounceMs??100,this.rootMargin=t.intersectionRootMargin??"200px"}start(e){let t=this.generation;this.stop();let n=t+1;if(this.generation!==n)return;let i=null,r=null;try{i=new MutationObserver(e=>{this.handleMutations(e,n)}),r=new IntersectionObserver(e=>{this.handleIntersection(e,n)},{rootMargin:this.rootMargin,threshold:0}),i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...Oi]})}catch(e){throw i?.disconnect(),r?.disconnect(),e}this.generation===n?(this.mutation=i,this.intersection=r):(i.disconnect(),r.disconnect())}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;let 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)||!function(e){for(let t of e){if("attributes"===t.type&&null!==t.attributeName&&Oi.includes(t.attributeName)&&(t.attributeName===mi||t.attributeName===Fi||t.target.nodeType===Vi&&t.target.hasAttribute(mi)))return!0;for(let e of t.addedNodes)if(le(e))return!0;for(let e of t.removedNodes)if(le(e))return!0}return!1}(e))return;null!==this.debounceTimer&&clearTimeout(this.debounceTimer);let n=setTimeout(()=>{!this.isCurrentGeneration(t)||this.debounceTimer!==n||(this.debounceTimer=null,this.callbacks.onStructuralChange())},this.debounceMs);this.debounceTimer=n}handleIntersection(e,t){for(let n of e){if(!this.isCurrentGeneration(t))return;let{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}},Gi="__livePreviewHydration",qi="[data-payload-field]",Ki="__vue_app__",Ji="__livePreviewVueHydration",Xi="app:suspense:resolve",Qi=class{constructor(e){vn(this,"timeoutMs");vn(this,"onTimeout");vn(this,"handle",null);vn(this,"lastKick",0);this.timeoutMs=e.timeoutMs??0,this.onTimeout=e.onTimeout}kick(){if(this.lastKick=Date.now(),this.timeoutMs<=0)return;null!==this.handle&&clearTimeout(this.handle);let e=setTimeout(()=>{this.handle===e&&(this.handle=null,this.onTimeout())},this.timeoutMs);this.handle=e}stop(){null!==this.handle&&(clearTimeout(this.handle),this.handle=null)}get lastKickAt(){return this.lastKick}get pending(){return null!==this.handle}},Zi=class{constructor(){vn(this,"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)}},Yi="data-payload-no-bind",er="data-payload-owned",tr=13,nr=new Set(["true","false","yes","no","on","off"]),ir=/^[\\d\\s.,:+/-]+$/u,rr=/^[a-z][a-z0-9_-]*$/u,lr=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,or=new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]),ar="http://www.w3.org/1999/xhtml",sr=new Set(["__proto__","prototype","constructor"]),ur="payload-live-preview",dr=Symbol.for("payload-live-preview.trusted-types"),cr="data-payload-owned",hr=new Set(["open","value","checked","selected"]),fr=new Set,pr="data-payload-",mr=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"]),gr=new Set(["input","button","textarea","select","option","label"]),vr=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),yr=new Set(["id","class","lang","dir","title","role","tabindex"]),br="aria-",wr="data-",Sr="data-payload-",Tr={a:new Set(["href","target","rel","download","hreflang","type"]),img:new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:new Set([]),source:new Set(["src","srcset","sizes","type","media"]),audio:new Set(["src","controls","autoplay","loop","muted","preload"]),video:new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:new Set(["datetime"]),abbr:new Set(["title"]),q:new Set(["cite"]),blockquote:new Set(["cite"]),table:new Set(["summary"]),th:new Set(["colspan","rowspan","scope","headers","abbr"]),td:new Set(["colspan","rowspan","headers"]),col:new Set(["span"]),colgroup:new Set(["span"]),ol:new Set(["start","reversed","type"]),li:new Set(["value"]),code:new Set(["class"]),pre:new Set(["class"])},kr=new Set(["href","src","cite","poster"]),Ar=1,Cr=8,$r=(Error,new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"])),Rr="strict",Fr=(Object.freeze({allowedTags:mr,removeCompletely:vr,globalAttributes:yr,attributesByTag:Tr,urlAttributes:kr}),Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"})),Nr=/[&<>"\'/`=]/g,xr=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;"}),Mr=/[&<>"\']/g,Er=/\\{\\{([\\s\\S]*?)\\}\\}/g,Or="data-payload-",Pr=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],Lr=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],Ur=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\\b/gi,Ir=64,jr=new Map,_r="data-payload-key",Wr="data-payload-nested-key",Br="data-payload-nested-template",zr=class{constructor(e,t,n){vn(this,"deps",e);vn(this,"state",t);vn(this,"host",n)}planFragments(e){let t=this.deps.strategies.fragment;return void 0===t?null:wt(t,t.plan(this.deps.root,e))}escalateUnfaithful(e,t,n){if(e.routeRefreshed)return;let{fragment:i,route:r}=this.deps.strategies,l=void 0===i?void 0:function(e){let t=[];for(let n of e){let e=n.fragmentBoundary;if(void 0===e)return;t.includes(e)||t.push(e)}return t}(n);void 0===i||void 0===l?void 0!==r?(this.state.escalatedCount+=n.length,this.refreshRoute(e,t,r)):this.warnEscalationUnavailable(n.length):(this.state.escalatedCount+=n.length,e.pendingFragments+=l.length,this.runFragments(e,t,wt(i,l)))}warnEscalationUnavailable(e){let{deps:t,state:n}=this;n.warnedEscalationUnavailable||(n.warnedEscalationUnavailable=!0,t.warn(`[live-preview] LP0808: onUnfaithfulPatch: \'escalate\' has nowhere to go: ${String(e)} field(s) fell short and no route or fragment strategy is configured. Set routeStrategy: true or fragments: { endpoint }, or onUnfaithfulPatch: \'warn\' to keep the patch and say so.`))}hasUnboundChange(e,t){let{deps:n,state:i}=this;if(e.baseline||e.routeRefreshed)return!1;let r=function(e,t,n,i){let r=B(e,n,i),l=[];for(let e of t)!ni.has(e)&&!r(e)&&l.push(e);return l}(n.cache,e.touched,e.locale,t),o=0;for(let e of r)l(i,e)&&(o+=1);let[a]=r;return void 0!==a&&"escalate"===n.onUnfaithfulPatch&&(void 0===n.strategies.route?(this.warnEscalationUnavailable(r.length),!1):(n.log("route","LP0807",`field "${a}" has no binding; refreshing the route`),i.escalatedCount+=o,!0))}hasRouteBinding(e){for(let[t,n]of this.deps.cache.entries())if(e.has(t)&&n.some(e=>"route"===e.strategyKind))return!0;return!1}async runFragments(e,t,n){let{deps:i,state:r}=this,l=new AbortController;r.fragmentController=l;let o=()=>r.isCurrent(e)&&!l.signal.aborted,{emitter:a}=i,{message:s}=e,u=e.revision.revision,d=e.receivedAt,c={root:i.root,revision:u,receivedAt:d,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof s.collectionSlug?s.collectionSlug:void 0,globalSlug:"string"==typeof s.globalSlug?s.globalSlug:void 0,signal:l.signal,isCurrent:o,log:(e,t)=>{i.log("fragment",e,t)},morph:(e,t)=>{!function(e,t){let n=e.ownerDocument.createElement("template");n.innerHTML=Le(t);let i=e.cloneNode(!1);i.append(n.content),je(e,i,{keyAttributes:[_r]})}(e,t)},patch:n=>{this.patchFallback(e,t,n)},rendered:(t,n,i)=>{e.pendingFragments-=1,a.emitWhile("fragmentRender",{element:t,id:n,key:i,status:"rendered",revision:u,receivedAt:d},o)},failed:(t,n,r,l,s)=>{e.pendingFragments-=1;let c=`fragment "${n}" fell back to patch: ${s}`;i.log("fragment",l,c),a.emitWhile("error",{error:new Error(c),context:"fragment",code:l},o),a.emitWhile("fragmentRender",{element:t,id:n,key:r,status:"failed",code:l,revision:u,receivedAt:d},o)}},h={rendered:0,failed:0,superseded:0};try{h=await n.strategy.render(c,n.boundaries)}catch(r){if(i.log("fragment","LP0801",r),o()){for(let i of n.boundaries)this.patchFallback(e,t,i);h={rendered:0,failed:n.boundaries.length,superseded:0}}}r.fragmentStats.rendered+=h.rendered,r.fragmentStats.failed+=h.failed,r.fragmentStats.superseded+=h.superseded,o()&&(r.fragmentController===l&&(r.fragmentController=null),e.pendingFragments=0,h.rendered>0&&this.host.restoreGuesses(e,t),0===i.scheduler.pendingCount&&r.complete(e),this.host.revealPending(e),o()&&(0===h.rendered||0===a.listenerCount("afterUpdate")||a.emitWhile("afterUpdate",{data:t,updatedCount:h.rendered,durationMs:Date.now()-d,revision:u,receivedAt:d,source:"fragment"},o)))}async refreshRoute(e,t,n){let{deps:i,state:r}=this;e.routeRefreshed?(r.routeStats.loopStopped+=1,i.log("route","LP0805",`revision ${String(e.revision.revision)} asked for a second refresh`)):(e.routeRefreshed=!0,await this.runRoute(e,t,n))}armRouteRetry(e,t,n,i){let{state:r}=this;null!==r.routeRetry&&clearTimeout(r.routeRetry),r.routeRetry=setTimeout(()=>{r.routeRetry=null,r.isCurrent(e)&&this.runRoute(e,t,n)},i)}async runRoute(e,t,n){let{deps:i,state:r}=this,l=r.routeStats,o=new AbortController;r.routeController=o;let a,s=()=>r.isCurrent(e)&&!o.signal.aborted;try{a=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:o.signal,isCurrent:s,log:(e,t)=>{i.log("route",e,t)},retryAfter:i=>{this.armRouteRetry(e,t,n,i)}})}catch(e){i.log("route","LP0801",e),a="failed"}if(s()){if(r.routeController===o&&(r.routeController=null),"refreshed"===a){if(l.refreshes+=1,r.lastAppliedIdentity=new WeakMap,this.host.restoreGuesses(e,t),this.host.rebuildCache(),!s())return;this.host.reapply(e,t),i.emitter.listenerCount("afterUpdate")>0&&i.emitter.emitWhile("afterUpdate",{data:t,updatedCount:i.cache.elementCount,durationMs:Date.now()-e.receivedAt,revision:e.revision.revision,receivedAt:e.receivedAt,source:"route"},s);return}"failed"===a?l.failed+=1:"refused"===a&&(l.refused+=1),this.host.reapply(e,t)}}warnFragmentFallback(e){!function(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`))}(this.deps,this.state,e)}warnUnsupportedStrategy(e){!function(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`))}(this.deps,this.state,e)}patchFallback(e,t,n){for(let[i,r]of this.deps.cache.entries())for(let l of r){if(l.fragmentBoundary!==n)continue;let r=xe(t.fields,l,i,e.locale);void 0!==r&&this.deps.scheduler.schedule({target:l,value:this.host.transform(l,r,t.fields,()=>!0),allFields:t.fields,revision:e.revision,data:t})}}},Dr=new Set,Vr=class{constructor(e,t,n){vn(this,"deps",e);vn(this,"state",t);vn(this,"strategies");this.strategies=new zr(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,i,r)=>St(e,t,n,i,r),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}})}handleUpdate(e,t,n){let{deps:i,state:r}=this;if(i.heartbeat.kick(),r.protocol.observe(function(e){let 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),i.log),void 0===e.data){void 0!==e.protocolVersion&&r.protocol.applyVersion(e.protocolVersion,i.log);return}if(void 0===n)return;let l=r.relationships.edit(e);null!==l&&i.emitter.emit("relationshipUpdate",{detail:l,timestamp:Date.now()}),"string"==typeof e.locale&&(r.locale=e.locale),Array.isArray(e.fieldSchemaJSON)&&(r.schema=e.fieldSchemaJSON,r.schemaIndex=b(e.fieldSchemaJSON));let o={revision:n,message:e,locale:r.locale,schema:r.schema,schemaIndex:r.schemaIndex,receivedAt:Date.now(),forceRender:null!==l||G(r.activeUpdate),touched:new Set,baseline:!1,invalidated:new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1},a=r.activeUpdate;r.abortStrategies(),null!==a&&!a.completed&&(r.supersededCount+=1),r.activeUpdate=o,i.scheduler.acceptRevision(n),r.updateCount+=1,(void 0===e.protocolVersion||(r.protocol.applyVersion(e.protocolVersion,i.log),r.isCurrent(o)))&&(i.connection.markConnected()&&(i.a11y?.announceConnected(),i.emitter.emit("connect",{origin:t,timestamp:Date.now()}),!r.isCurrent(o)||(i.log("connection","disconnected","\\u2192","connected"),!r.isCurrent(o)))||this.processUpdate(o).catch(e=>{i.log("update failed:",e)}))}async processUpdate(e){let{deps:t,state:n}=this,i=await this.resolveIncomingFields(e);if(null===i||!n.isCurrent(e))return;let r=this.dataFor(e,i);t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:r,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,r,!1)}dataFor(e,t){let{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){let{deps:i,state:r}=this,l=K(i.dependencies,i.cache.dependencyMap()),o=r.changes.diff(t.fields,l);if(o.baseline&&!n&&"off"!==i.autoBind){let n=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,i,r){let l=performance.now(),o=$e(e.root),a=ye(n,i),s=null===o?[]:Re(e,Ce(o,a),r,"on the first message");t.autoBindGuesses=function(e,t){let n=new Set;for(let{fieldName:e,stamps:i}of t){n.add(e);for(let e of[yi,wi]){let t=i[e];void 0!==t&&n.add(t)}}let i=new Map;for(let[t,r]of e)null!==r&&n.has(r.field)&&i.set(t,r);return{fields:n,values:i}}(a,s),t.autoBindSearchMs=performance.now()-l,s.length}(i,r,t.fields,e.locale,n)}e.baseline=o.baseline,e.invalidated=n?Dr:o.invalidated,e.touched=n?Dr:new Set([...o.changed,...o.invalidated]),this.scheduleAllFields(e,t)}async resolveIncomingFields(e){let{deps:t,state:n}=this,i=e.message.data??{};if(null===t.merger||"admin"===re(n.protocol.observed).populatesRelationships)return i;let r=n.merges.decide(t,e);if(!r.merge)return r.fields;let{message:l}=e,o=n.merges.request(t.merger,t.mergeWindowMs,{collectionSlug:l.collectionSlug,globalSlug:l.globalSlug,data:i,locale:e.locale});if(!o.leading)return this.applyMerged(e,o.result).catch(e=>{t.log("update failed:",e)}),r.fields;let a=await o.result;return n.isCurrent(e)?"merged"===a.status?(n.merges.recordMerged(a.doc),a.doc):"superseded"===a.status?null:r.fields:null}async applyMerged(e,t){let{state:n}=this,i=await t;"merged"!==i.status||!n.isCurrent(e)||(n.merges.recordMerged(i.doc),this.applyFields(e,this.dataFor(e,i.doc),!0))}scheduleAllFields(e,t){let{deps:n,state:i}=this;if(!i.isCurrent(e))return;let r=()=>i.isCurrent(e),l=this.ownerKeysForUpdate(e,t.fields),{touched:o}=e,a=n.strategies.route,s=this.strategies.hasUnboundChange(e,l),u=i.routeRefreshOwed;if(void 0!==a&&!e.routeRefreshed&&(s||u||a.plan(n.root,o)||this.strategies.hasRouteBinding(o))){i.routeRefreshOwed=!1,this.strategies.refreshRoute(e,t,a);return}let d=this.strategies.planFragments(o),c=n.skipUnchanged,h=0;for(let[o,a]of n.cache.entries()){if(!r())return;for(let s of a){if(!1!==l&&!U(s.owner,l))continue;if(!0===d?.covers(s)){if(n.revealEditedField){let n=xe(t.fields,s,o,e.locale);i.revealLedger.note(e,s,n)}continue}let a=s.strategyKind??E(s.element)??"unknown";if("unknown"===a){this.strategies.warnUnsupportedStrategy(s);continue}"fragment"===a&&null===d&&this.strategies.warnFragmentFallback(s);let u=xe(t.fields,s,o,e.locale);if(void 0===u){i.absentFields.add(o);continue}if(n.revealEditedField&&i.revealLedger.note(e,s,u),!r())return;let f=St(n,s,u,t.fields,r);if(!r())return;let p=c?Me(s,f,t.fields,e.locale):void 0,m=i.lastAppliedIdentity.get(s.element);if(!e.forceRender&&n.skipUnchanged&&void 0!==p&&m===p&&!e.invalidated.has(o)){i.skippedUnchangedCount+=1;continue}let g={target:s,value:f,allFields:t.fields,revision:e.revision,data:t,valueIdentity:p};n.scheduler.schedule(g),h+=1}}(function(e,t,n,i){let{cache:r}=e;if(0===r.fieldCount||!1!==i&&!function(e,t){for(let n of e.values())if(U(n.owner,t))return!0;return!1}(r,i))return;let l=B(r,n,i);for(let[i,r]of Object.entries(t)){if(ni.has(i))continue;if(Oe(r)){Ee(e,l,i,n,r);continue}if(!Pe(r)||l(i))continue;let t=W(i,n);for(let[i,o]of Object.entries(r))!Oe(o)||ni.has(i)||Ee(e,l,`${t}.${i}`,n,o)}})({cache:n.cache,warned:i.warnedOrphanFields,warn:n.warn},t.fields,e.locale,l),null!==d&&d.boundaries.length>0&&(e.pendingFragments=d.boundaries.length,this.strategies.runFragments(e,t,d)),0===h&&0===e.pendingFragments&&(i.complete(e),this.revealPending(e),this.notifyIslands(e,t))}notifyIslands(e,t){0!==e.touched.size&&function(e,t){for(let n of e)n.dispatchEvent(new CustomEvent("payload-live-preview:update",{detail:t,bubbles:!1}));e.length}(this.deps.cache.islands,{fields:t.fields,revision:e.revision.revision,receivedAt:e.receivedAt,locale:e.locale})}restoreGuesses(e,t){let{deps:n,state:i}=this;if("off"!==n.autoBind&&null!==i.autoBindGuesses){let r=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,i,r){let l=t.autoBindGuesses,o=$e(e.root);if(null===l||0===l.fields.size||null===o)return 0;let a=new Map(l.values);for(let[e,t]of ye(n,i)){if(null===t||!l.fields.has(t.field))continue;let n=a.get(e);void 0===n?a.set(e,t):n?.field!==t.field&&a.set(e,null)}Re(e,Ce(o,a),r,"after a server render").length}(n,i,t.fields,e.locale,r)}}ownerKeysForUpdate(e,t){let{deps:n,state:i}=this;if(!n.scopeBindingsByOwner)return!1;let{message:r}=e,l=function(e){if(L(e.globalSlug))return[O(e.globalSlug)];if(!L(e.collectionSlug))return null;let t=P(e.collectionSlug);return L(e.documentId)?[t,P(e.collectionSlug,e.documentId)]:[t]}({globalSlug:"string"==typeof r.globalSlug?r.globalSlug:void 0,collectionSlug:"string"==typeof r.collectionSlug?r.collectionSlug:void 0,documentId:I(t)});return null===l&&!i.warnedUnattributableMessage&&(i.warnedUnattributableMessage=!0,n.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),l}onFlush(e){let{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`));let{revision:i,data:r}=e;if(void 0===i)return;let l=n.activeUpdate;if(null===l||!n.isCurrent(l)||!g(l.revision,i))return;0===l.pendingFragments&&n.complete(l);let o=()=>n.isCurrent(l)&&g(l.revision,i);if(this.revealPending(l),!o())return;let a=n.unfaithfulPatches;a.length>0&&(n.unfaithfulPatches=[],void 0!==r&&this.strategies.escalateUnfaithful(l,r,a),!o())||void 0!==r&&(e.applied>0&&t.a11y?.announceUpdate(e.applied),o()&&(this.notifyIslands(l,r),o()&&0!==e.applied&&0!==t.emitter.listenerCount("afterUpdate")&&t.emitter.emitWhile("afterUpdate",{data:r,updatedCount:e.applied,durationMs:e.durationMs,revision:i.revision,receivedAt:l.receivedAt,source:"patch"},o)))}revealPending(e){let t=this.state.revealLedger.commit(e);if(void 0!==t)try{this.revealBinding(t)}catch(e){this.deps.log("reveal",e)}}revealField(e){let t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":this.revealBinding(t)}revealBinding(e){let{element:t}=e,n=t.ownerDocument.defaultView;if(null===n)return"no-element";let i=`${e.owner??""} ${e.fieldName}`;return this.state.revealer.reveal(i,t,n)}},Hr=class{constructor(e,t){vn(this,"apply");vn(this,"debounceMs");vn(this,"maxWaitMs");vn(this,"isVisible");vn(this,"gateThresholdValue");vn(this,"gateDisabled");vn(this,"getCacheSize");vn(this,"onFlush");vn(this,"scheduleFrame");vn(this,"cancelFrame");vn(this,"pending",new Map);vn(this,"replay",new Map);vn(this,"activeFlushes",new Set);vn(this,"debounceTimer",null);vn(this,"debounceToken",0);vn(this,"deadlineTimer",null);vn(this,"frameHandle",null);vn(this,"frameToken",0);vn(this,"windowUntil",0);vn(this,"activeRevision",null);vn(this,"activeRevisionCancelled",!1);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(void 0!==e.revision&&(this.activeRevisionCancelled||null===this.activeRevision||!g(e.revision,this.activeRevision)))return;let 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){null!==this.activeRevision&&g(e,this.activeRevision)||null!==this.activeRevision&&function(e,t){return e.generation!==t.generation?e.generation-t.generation:e.revision-t.revision}(e,this.activeRevision)<0||(this.cancelScheduledWork(),this.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1)}cancelRevision(e){null===this.activeRevision||!g(e,this.activeRevision)||(this.cancelScheduledWork(),this.clearWork(),this.activeRevisionCancelled=!0)}flushNow(){return this.cancelScheduledWork(),this.flush()}notifyVisible(e){let t=this.replay.get(e);if(!t||(this.replay.delete(e),!this.isCurrent(t)))return;let n=performance.now(),i=this.didApply(t)?1:0;this.onFlush?.(this.statsFor(t,i,0,performance.now()-n,1===i?[t.target.fieldName]:[]))}retarget(e){this.retargetBuffer(this.pending,e),this.retargetBuffer(this.replay,e);for(let t of this.activeFlushes)this.retargetBuffer(t,e)}forget(e){this.pending.delete(e),this.replay.delete(e);for(let t of this.activeFlushes)t.delete(e)}destroy(){this.cancelScheduledWork(),this.clearWork(),this.activeRevision=null,this.activeRevisionCancelled=!1,this.windowUntil=0}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(){let e=Date.now(),t=e>=this.windowUntil;if(this.windowUntil=e+this.debounceMs,t){this.requestFrame();return}let n=this.debounceToken+=1,i=this.debounceTimer;if(this.debounceTimer=null,null!==i&&clearTimeout(i),this.debounceToken!==n)return;let r=setTimeout(()=>{this.debounceToken===n&&(this.debounceTimer=null,this.pending.size>0&&this.requestFrame())},this.debounceMs);this.debounceToken===n&&(this.debounceTimer=r),null===this.deadlineTimer&&this.maxWaitMs>this.debounceMs&&(this.deadlineTimer=setTimeout(()=>{this.deadlineTimer=null,this.pending.size>0&&this.requestFrame()},this.maxWaitMs))}requestFrame(){let e=this.frameToken+=1,t=this.frameHandle;if(this.frameHandle=null,null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1,i=this.scheduleFrame(()=>{this.frameToken===e&&(n=!0,this.frameHandle=null,this.flush())});!n&&this.frameToken===e&&(this.frameHandle=i)}flush(){let e=performance.now();this.clearDeadline();let t=this.gateActive,n=this.pending;this.pending=new Map;let i,r=0,l=[],o=0;this.activeFlushes.add(n);try{for(let e of n.values()){if(!this.isCurrent(e))continue;let n=!t||this.isVisible(e.target.element);if(this.isCurrent(e)){if(i??(i=e),!n){this.replay.set(e.target.element,e),o+=1;continue}this.replay.delete(e.target.element),this.didApply(e)&&(r+=1,l.push(e.target.fieldName))}}}finally{this.activeFlushes.delete(n)}let a=this.statsFor(i,r,o,performance.now()-e,l);return this.onFlush?.(a),a}isCurrent(e){return void 0===e.revision||!this.activeRevisionCancelled&&null!==this.activeRevision&&g(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||!function(e){return Zn.has(e)}(this.apply)}retargetBuffer(e,t){let n=e.get(t.element);if(void 0!==n){if(n.target.fieldName!==t.fieldName||n.target.locale!==t.locale){e.delete(t.element);return}n.target=t}}clearWork(){this.pending.clear(),this.replay.clear();for(let e of this.activeFlushes)e.clear()}statsFor(e,t,n,i,r){return{applied:t,appliedFields:r,deferred:n,durationMs:i,...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(){let e=this.debounceTimer,t=this.frameHandle;this.debounceToken+=1,this.frameToken+=1,this.debounceTimer=null,this.frameHandle=null,this.clearDeadline(),null!==e&&clearTimeout(e),null!==t&&this.cancelFrame(t)}},Gr=[0,500,1e3,2e3],qr=class{constructor(e){vn(this,"deps");vn(this,"state",new ci);vn(this,"pipeline");vn(this,"writer");vn(this,"rootSentinel",null);vn(this,"observedRoot",null);let{emitter:r,renderers:l}=e,o=void 0===e.log?n:t(e.log),a=void 0===e.warn?An:t(e.warn),s=e.root??(typ','eof document<"u"?document:void 0);if(void 0===s)throw new Error("LivePreviewRuntime: no document; pass options.root");let u=new ji({filter:e=>!function(e){let t=e;for(;null!==t;){if(Q(t))return!0;t=t.parentElement}return!1}(e)}),d=new Hi({onStructuralChange:()=>{this.rebuildCache()},onVisibilityChange:(e,t)=>{t&&c.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),c=new Hr(N(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=>d.isVisible(e),getCacheSize:()=>u.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),h=new zn(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],o),r.emit("documentSave",{timestamp:Date.now()})},onFocusField:e=>{this.deps.revealEditedField&&this.pipeline.revealField(e)},onInvalid:(e,t)=>{if("token"===e){let e=new Error(`Preview token rejected (origin: ${t})`);r.emit("error",{error:e,context:"token",code:"LP0502"})}("shape"===e||"type"===e)&&!this.state.warnedProtocolShape&&(this.state.warnedProtocolShape=!0,a(`[live-preview] LP0503: ${t} 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,a(`[live-preview] LP0501: a message from ${t} 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.`)),o("LP0501 message rejected:",e,t)},...void 0!==e.validateToken?{validateToken:e.validateToken}:{},...void 0!==e.eventSourcePolicy?{sourcePolicy:e.eventSourcePolicy}:{}}),f=e.dataMerge;this.deps={emitter:r,cache:u,observers:d,scheduler:c,bus:h,connection:new Zi,heartbeat:new Qi({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:l,resolveRenderer:e.resolveRenderer??(e=>l[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,root:s,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??y,onHeartbeatTimeout:e.onHeartbeatTimeout,log:o,warn:a,a11y:v(e),merger:void 0===f?null:new _i({serverURL:f.serverURL,...void 0!==f.apiRoute?{apiRoute:f.apiRoute}:{},...void 0!==f.depth?{depth:f.depth}:{},...void 0!==f.fetchFn?{fetchFn:f.fetchFn}:{},log:o}),mergeWindowMs:e.debounceMs??50,scopeBindingsByOwner:!0===e.scopeBindingsByOwner,lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField,onUnfaithfulPatch:i(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new hi(this.deps,this.state),this.pipeline=new Vr(this.deps,this.state,()=>{this.rebuildCache()})}start(){let{state:e}=this;if(e.isRunning())return!1;e.started=!0,e.suspended=!1;try{return function(e){"react"===e.hydration?ae():"vue"===e.hydration&&fe();let{root:t}=e;if(!function(e){return 9===e.nodeType}(t)||"loading"!==t.readyState){pe(e);return}let n=()=>{e.isRunning()&&e.later(()=>{pe(e)})};t.addEventListener("DOMContentLoaded",n,{once:!0}),e.defer(()=>{t.removeEventListener("DOMContentLoaded",n)})}(this.startupHost()),!0}catch(e){throw this.rollbackFailedStart(),e}}startupHost(){let{state:e,deps:t}=this;return{root:t.root,hydration:t.hydration,isRunning:()=>e.isRunning(),defer:t=>{e.deferredStart=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(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=Tt(t.root)?kt(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()&&(t.bus.attach(),t.emitter.emitWhile("init",{timestamp:Date.now()},()=>e.isRunning()),e.isRunning()))for(let n of Gr){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;let e=this.release();return this.state.suspended=!0,e&&this.deps.emitter.emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0}destroy(){let{state:e,deps:t}=this;if(!e.isRunning()&&!e.suspended)return;let n=!!e.isRunning()&&this.release();e.suspended=!1,n&&t.emitter.emit("disconnect",{reason:"destroy",timestamp:Date.now()}),t.a11y?.detach(),t.emitter.emit("destroy",{timestamp:Date.now()})}release(){let{state:e,deps:t}=this;e.activeUpdate=null,e.started=!1;let n=e.deferredStart;e.deferredStart=null,null!==n&&this.runCleanup(n);for(let t of e.readyTimers)this.runCleanup(()=>{clearTimeout(t)});return e.readyTimers.length=0,this.runCleanup(()=>{t.heartbeat.stop()}),this.runCleanup(()=>{t.bus.detach()}),e.abortStrategies(),this.runCleanup(()=>{this.rootSentinel?.disconnect(),this.rootSentinel=null,this.observedRoot=null}),this.runCleanup(()=>{t.observers.stop()}),this.runCleanup(()=>{t.scheduler.destroy()}),this.runCleanup(()=>{t.merger?.destroy(),e.merges.destroy()}),t.cache.clear(),t.connection.markDisconnected()}rollbackFailedStart(){this.release(),this.runCleanup(()=>{this.deps.a11y?.detach()})}runCleanup(e){try{e()}catch(e){this.deps.log("cleanup failed:",e)}}refreshCache(){this.state.isRunning()&&(this.state.revealer.reset(),this.followReplacedRoot()||this.rebuildCache())}watchRootReplacement(){let{root:e}=this.deps;!Tt(e)||typeof MutationObserver>"u"||(this.rootSentinel?.disconnect(),this.rootSentinel=new MutationObserver(()=>{this.followReplacedRoot()}),this.rootSentinel.observe(e.documentElement,{childList:!0}))}followReplacedRoot(){let{root:e}=this.deps;if(!this.state.isRunning()||!Tt(e))return!1;let t=kt(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(e,t){let{cache:n,scheduler:i}=e,r=t.protocol.negotiation,l=t.activeUpdate,o=t.lastFlush,a=[],s=new Set,u=[];for(let[e,t]of n.entries()){a.push(e);for(let n of t)void 0!==n.owner&&s.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:Wi,started:t.started,status:e.connection.status,origins:{trusted:[...e.readyTargets()],locked:e.lockedOrigin()},protocol:{ours:r.ours,theirs:r.theirs,negotiated:r.negotiated,capabilities:[...r.capabilities].sort(),observed:[...r.observed].sort(),profile:re(r.observed).name},revisions:{accepted:t.updateCount,superseded:t.supersededCount,completed:t.completedCount,skippedUnchanged:t.skippedUnchangedCount,active:null===l?void 0:l.revision.revision},bindings:{elements:n.elementCount,fields:n.fieldCount,fieldNames:a.sort(),absentFields:[...t.absentFields].sort(),orphanFields:[...t.warnedOrphanFields].sort(),ownerScoped:e.scopeBindingsByOwner,owners:[...s].sort(),guessed:u.sort((e,t)=>e.field.localeCompare(t.field)),autoBind:{mode:e.autoBind,searchMs:t.autoBindSearchMs}},route:{handler:void 0!==e.strategies.route,...t.routeStats},fidelity:{mode:e.onUnfaithfulPatch,canEscalate:void 0!==e.strategies.fragment||void 0!==e.strategies.route,unfaithful:t.unfaithfulCount,escalated:t.escalatedCount,fields:[...t.unfaithfulFields].sort()},hydration:{mode:e.hydration??"off",state:t.hydration},fragments:{handler:void 0!==e.strategies.fragment,inFlight:l?.pendingFragments??0,...t.fragmentStats},scheduler:{pending:i.pendingCount,deferred:i.replayCount,visibilityGateThreshold:i.gateThreshold,visibilityGateActive:i.gateActive,lastFlush:null===o?void 0:{applied:o.applied,appliedFields:o.appliedFields,deferred:o.deferred,durationMs:o.durationMs}},plugins:[],renderers:Object.keys(e.renderers).sort()}}(this.deps,this.state)}buildCacheAndObserve(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=t.cache.buildFromRoot(t.root);if(t.log("cache",n),e.isRunning()&&(t.emitter.emitWhile("cacheRefresh",n,()=>e.isRunning()),e.isRunning()))for(let n of t.cache.values()){if(!e.isRunning())return;t.observers.observeElement(n.element)}}rebuildCache(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=new Map;for(let e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),e.isRunning()){for(let e of t.cache.values())n.get(e.element)?.fieldName===e.fieldName?t.scheduler.retarget(e):t.scheduler.forget(e.element),n.delete(e.element);for(let e of n.values())t.scheduler.forget(e.element)}}onHeartbeatTimeout(){let{state:e,deps:t}=this;if(!e.isRunning())return;t.bus.advanceGeneration();let n=e.activeUpdate;e.activeUpdate=null,null!==n&&t.scheduler.cancelRevision(n.revision),t.merger?.destroy(),e.merges.destroy();let i=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}e.isRunning()&&(i&&this.isIdleDisconnected()&&(t.a11y?.announceDisconnected(),t.emitter.emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.isIdleDisconnected()),!e.isRunning()||(this.isIdleDisconnected()&&t.log("connection","connected","\\u2192","disconnected"),!e.isRunning()))||this.sendReadyAfterStart())}sendReadyAfterStart(){try{this.deps.sendReady(this.deps.readyTargets())}catch(e){this.reportError(e,"ready","LP0606")}}reportError(e,t,n){let i=e instanceof Error?e:new Error(String(e));this.deps.emitter.emit("error",{error:i,context:t,code:n})}isIdleDisconnected(){return this.state.isRunning()&&"disconnected"===this.deps.connection.status&&null===this.state.activeUpdate}},Kr=/^https?:\\/\\/(localhost|127\\.0\\.0\\.1)(?::\\d+)?$/i,Jr=/^https?:\\/\\/[^/?#\\s]+$/i,Xr=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],Qr=class{constructor(e={}){wn(this,Zr);let t=new Set;for(let n of e.additionalOrigins??[]){let e=Ct(n);void 0!==e&&t.add(e)}let n;if(e.enableReferrerDetection??1){let t=e.referrer??(typ','eof document<"u"?document.referrer:"");if(t.length>0)try{let e=new URL(t).origin;e&&"null"!==e&&(n=e)}catch{}}let i=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??function(){let e=function(){if(!(typ','eof process>"u"))return"production"}();if(void 0!==e)return"production"!==e;if(typ','eof window<"u"){let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}return!1}());Sn(this,Zr,[t,n,i,void 0!==n,void 0])}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==bn(this,Zr)[4]?e===bn(this,Zr)[4]:!!(bn(this,Zr)[0].has(e)||0===bn(this,Zr)[0].size&&void 0!==bn(this,Zr)[1]&&e===bn(this,Zr)[1]||bn(this,Zr)[2]&&Kr.test(e)))}lockOrigin(e){return!!this.matches(e)&&(bn(this,Zr)[4]=e,!0)}unlockOrigin(){let e=bn(this,Zr)[4];return bn(this,Zr)[4]=void 0,e}get lockedOrigin(){return bn(this,Zr)[4]}enumerate(){if(void 0!==bn(this,Zr)[4])return[bn(this,Zr)[4]];let e=new Set(bn(this,Zr)[0]);if(0===bn(this,Zr)[0].size&&void 0!==bn(this,Zr)[1]&&e.add(bn(this,Zr)[1]),bn(this,Zr)[2])for(let t of Xr)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return bn(this,Zr)[3]}get isProductionUnconfigured(){return!(!At()||bn(this,Zr)[0].size>0||bn(this,Zr)[2]||void 0!==bn(this,Zr)[1])}get isReferrerOnlyTrust(){return!(bn(this,Zr)[0].size>0||bn(this,Zr)[2])&&void 0!==bn(this,Zr)[1]}},Zr=new WeakMap,Yr={1:"left",2:"center",3:"right",4:"justify"},el=new Set(["left","center","right","justify","start","end"]),tl=new Set(["h1","h2","h3","h4","h5","h6"]),nl=\' target="_blank" rel="noopener noreferrer"\',il=(e,t)=>{let n=t.renderChildren(e.children??[]),i=xt(e.fields),r=function(e,t){if("internal"===t?.linkType)return function(e){let t=xt(xt(e)?.value),n=t?.url;if("string"==typeof n&&n.length>0)return n;let i=t?.slug;return"string"==typeof i&&i.length>0?`/${i}`:void 0}(t.doc);let n=t?.url??e.url;return"string"==typeof n&&n.length>0?n:void 0}(e,i);if(void 0===r||!$(r))return n;let l="string"==typeof e.title?` title="${Xe(e.title)}"`:"";return`<a href="${Qe(r)}"${function(e,t,n){if(!0===t?.newTab||R(n))return nl;let i="string"==typeof e.target?e.target:"";return""===i?"":"_blank"===i?nl:` target="${Xe(i)}"`}(e,i,r)}${l}>${n}</a>`},rl=new Map,ll=".lp-block:empty,.lp-inline-block:empty",ol={text:e=>{let t=Xe("string"==typeof e.text?e.text:""),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)=>{let n=t.renderChildren(e.children??[]);return`<p${Ft(e)}${Nt(e)}>${n}</p>`},heading:(e,t)=>{let n="string"==typeof e.tag?e.tag.toLowerCase():"h2",i=tl.has(n)?n:"h2",r=t.renderChildren(e.children??[]);return`<${i}${Ft(e)}${Nt(e)}>${r}</${i}>`},list:(e,t)=>{let n="string"==typeof e.listType?e.listType:"bullet",i="number"===n?"ol":"ul",r="number"===n&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",l="check"===n?\' role="list"\':"",o=t.renderChildren(e.children??[]);return`<${i}${Ft(e)}${Nt(e)}${r}${l}>${o}</${i}>`},listitem:(e,t)=>{let n=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${Nt(e)}>${n}</li>`;let i="number"==typeof e.value?` value="${Xe(String(e.value))}"`:"";return`<li${Ft(e)}${Nt(e)}${i}>${n}</li>`},link:il,autolink:il,quote:(e,t)=>{let n=t.renderChildren(e.children??[]);return`<blockquote${Ft(e)}${Nt(e)}>${n}</blockquote>`},code:e=>{let t=Et("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${Xe(Lt(e))}</code></pre>`},"code-highlight":e=>{let t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${Et(e.highlightType)}"`:""}>${Xe(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\\t",upload:e=>{let t=Mt(e.value);if(void 0===t)return"";let n=t.url;if("string"!=typeof n||!$(n))return"";let i="string"==typeof t.mimeType?t.mimeType:"";return i.startsWith("video/")?function(e,t){return`<video controls${Ut(e)}><source src="${Qe(t)}"${It(e)}></video>`}(t,n):i.startsWith("audio/")?function(e,t){return`<audio controls><source src="${Qe(t)}"${It(e)}></audio>`}(t,n):""===i||i.startsWith("image/")?function(e,t){let n="string"==typeof e.alt?Xe(e.alt):"";return`<img src="${Qe(t)}" alt="${n}"${Ut(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){let n="string"==typeof e.filename?Xe(e.filename):Xe(t);return`<a href="${Qe(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{let t="string"==typeof e.relationTo?e.relationTo:"",n=xt(e.value),i=Xe((n&&Pt(n))??`#${t}`),r=Et(t),l=""===r?\' class="lp-relation"\':` class="lp-relation lp-relation--${r}"`,o=n?.url;return"string"==typeof o&&$(o)?`<a href="${Qe(o)}"${l}>${i}</a>`:`<span${l}>${i}</span>`},block:(e,t)=>_t(e,t,"div","lp-block"),inlineBlock:(e,t)=>_t(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${Ft(e)}><tbody>${t.renderChildren(e.children??[])}</tbody></table>`,tablerow:(e,t)=>`<tr>${t.renderChildren(e.children??[])}</tr>`,tablecell:(e,t)=>{let n="number"==typeof e.headerState?e.headerState:0,i=3&n?"th":"td";return`<${i}${1===n?\' scope="col"\':2===n?\' scope="row"\':""}${Wt("colspan",e.colSpan)}${Wt("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${i}>`}},al=new Map,sl=!1,ul="data-payload-text",dl=new Set,cl=new Set,hl=new Set(["DIV","SECTION","ARTICLE"]),fl={name:"richText",render:N((e,t,n)=>{let i=e.element;if(it(t)){i.textContent="";return}let r=n.sanitizerPolicy;if(void 0!==n.renderRichText){let l=n.renderRichText(t,{fieldName:e.fieldName,element:i,locale:n.locale});i.innerHTML=Le(He(l,r));return}if(Bt(t)){let l=new Map,o=Ht(i,He(function(e,t={}){if(!Bt(e))return"";let n=function(e){let t={renderChildren:e=>{let n="";for(let i of e)n+=zt(i,t);return n},resolveAlignment:$t,resolveIndent:Rt,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==Ge()?function(e){return He(e,void 0,void 0)}(n):(function(){if(!sl){sl=!0;try{console.warn(\'[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; call setSanitizerDocument() (linkedom/jsdom) for server rendering, see "HTML sanitization" in docs/security.md.\')}catch{}}}(),n)}(t,{sanitize:!1,onUnrenderedBlock:(e,t)=>{l.set(t,e)}}),r));for(let[t,i]of o){let r=l.get(t);void 0!==r&&qt(e,n,r,i)}return}if("string"!=typeof t)return!1;i.innerHTML=Le(He(t,r))})},pl={name:"html",render(e,t,n){if(it(t)){e.element.textContent="";return}let i="string"==typeof t?t:nt(t);e.element.innerHTML=Le(He(i,n.sanitizerPolicy))}},ml=new WeakSet,gl=Jt("url"),vl=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,yl=Jt("email",function(e){let t=e.trim();return vl.test(t)||!t.includes("@")?t:`mailto:${t}`}),bl=["src","srcset","sizes"],wl={name:"image",render:N((e,t,n)=>{let i=e.element;if(it(t)){Yt(i);return}let r=void 0!==e.locale,{media:l,candidate:o}=function(e,t,n,i){let r=void 0!==e.srcField&&e.srcField.length>0?Fe(n.allFields,e.srcField,n.locale,i):t,l=Mt(r);return{media:l,candidate:void 0===l?r:l.url}}(e,t,n,r),a=Kt(i,e.fieldName,o);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===i.tagName){let t=i;Qt(t,a.url,l);let o=function(e,t,n,i,r){if(void 0!==t&&t.length>0){let e=Fe(n,t,i,r);return"string"==typeof e?e:void 0}return e?.alt}(l,e.altField,n.allFields,n.locale,r);void 0!==o&&(t.alt=o);return}i.style.backgroundImage=`url(\'${function(e){return e.replace(/[\'"()\\\\]/g,"\\\\$&")}(a.url)}\')`}else Yt(i)})},Sl={name:"upload",render:N((e,t)=>{let n=e.element;if(it(t)){en(n);return}let i=Mt(t);if(void 0===i)return!1;let r=Kt(n,e.fieldName,i.url);if("none"===r.kind)return!1;if("unsafe"===r.kind){en(n);return}let l=r.url;if("IMG"===n.tagName){let e=n;Qt(e,l,i),void 0!==i.alt&&(e.alt=i.alt);return}if("A"===n.tagName){n.setAttribute("href",l),n.textContent=i.filename??l;return}let o=Xe(i.filename??l);n.innerHTML=Le(`<a href="${Qe(l)}">${o}</a>`)})},Tl={name:"relationship",render(e,t){let n=e.element;if(it(t))n.removeAttribute("href"),n.textContent="";else{if("A"===n.tagName&&!Array.isArray(t)){let i=Kt(n,e.fieldName,xt(t)?.url);"safe"===i.kind?n.setAttribute("href",i.url):"unsafe"===i.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(tn).join(", "):tn(t)}}},kl={name:"select",render(e,t,n){let i=e.element,r=it(t)?[]:function(e){return Array.isArray(e)?e.map(nt):[nt(e)]}(t);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){let e=i;e.checked=r.includes(e.value);return}i.textContent=r.map(e=>function(e,t){let n=t.schema?.options;if(!Array.isArray(n))return e;for(let t of n){let n=xt(t);if(void 0!==n&&nt(n.value)===e)return"string"==typeof n.label?n.label:e}return e}(e,n)).join(", ")}else!function(e,t){if(e.multiple)for(let n of Array.from(e.options))n.selected=t.includes(n.value);else e.value=t[0]??""}(i,r)}},Al=new Set(["","false","0","off","no"]),Cl={name:"checkbox",render(e,t){let n=e.element,i=function(e){return"boolean"==typeof e?e:"string"==typeof e?!Al.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",i?"true":"false"):n.textContent=i?"true":"false":n.checked=i}},$l=new Map,Rl=new Map,Fl=new Set(["short","medium","long","full"]),Nl=new Set(["short","medium","long","full"]),xl=/^[A-Za-z]{3}$/u,Ml=/^[0-4]$/u,El=new WeakSet,Ol={name:"date",render(e,t,n){let i=e.element;if(it(t)){"INPUT"===i.tagName?i.value="":(i.removeAttribute("datetime"),i.textContent="");return}let r="number"==typeof t?t:nt(t),l=new Date(r),o=!Number.isNaN(l.getTime()),a=String(r);"INPUT"!==i.tagName?("TIME"===i.tagName&&i.setAttribute("datetime",o?l.toISOString():a),i.textContent=o?function(e,t,n){let i=t.locale??n.locale??s(),r=an("date",t.format,t.element,t.fieldName)??Pl;try{return function(e,t){let n=nn(e,t);return rt(Rl,n)??lt(Rl,n,new Intl.DateTimeFormat(e,t),64)}(i,r).format(e)}catch{return e.toISOString()}}(l,e,n):a):i.value=o?function(e,t){let n=`${String(t.getFullYear()).padStart(4,"0")}-${sn(t.getMonth()+1)}-${sn(t.getDate())}`,i=`${sn(t.getHours())}:${sn(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${i}`:"time"===e?i:t.toISOString()}(i.type,l):a}},Pl={dateStyle:"medium",timeStyle:"short"},Ll={name:"number",render(e,t,n){let i=e.element;if(it(t)){"INPUT"===i.tagName?i.value="":i.textContent="";return}let r="number"==typeof t?t:Number(nt(t));Number.isNaN(r)?i.textContent=nt(t):"INPUT"!==i.tagName?i.textContent=function(e,t,n){let i=t.locale??n.locale??s(),r=an("number",t.format,t.element,t.fieldName);try{return function(e,t){let n=nn(e,t);return rt($l,n)??lt($l,n,new Intl.NumberFormat(e,t),64)}(i,r).format(e)}catch{return String(e)}}(r,e,n):i.value=String(r)}},Ul={name:"array",render:N((e,t,n)=>{let i=e.element;if(it(t)){i.textContent="";return}if(!Array.isArray(t))return!1;let r=e.arrayTemplate;if(void 0!==r&&r.length>0){let e=function(e,t){let n=Ze(t),i="";for(let r=0;r<t.length;r+=1)i+=Ye(e,t[r],r,nt,n);return i}(r,t),l=n.sanitizerPolicy,o=ot(r),a=et(i);i.innerHTML=Le(He(e,l,o));for(let e of Array.from(i.children))tt(e,a);return}i.textContent=t.map(nt).join(e.arraySeparator??", ")})},Il=new Map;!function(){if(typ','eof window>"u"||!At()&&(typ','eof window>"u"||null==window.opener))return;let e=window.__livePreview,t=JSON.stringify(pn());if(void 0!==e&&(void 0===e.configSignature||e.configSignature===t))return e.refresh(),e;let[n=[],r="",l="/api",o=1,a=!1,s=50,u=!0,d=0,c=!1,h=50,f="200px",p=!0,m=!1,g=!1,v=!0,y="parent-or-opener",b="strict",w,S=!1,T=!1,k,A,C="off",$]=pn(),R=function(e){let t=typeof __LIVE_PREVIEW_FRAGMENT__<"u"?__LIVE_PREVIEW_FRAGMENT__:void 0,n=t??(typeof __LIVE_PREVIEW_ROUTE__<"u"?__LIVE_PREVIEW_ROUTE__:void 0);if(void 0===n)return;let i=n.createRouteStrategy();return void 0===t||void 0===e||""===e?{route:i}:{fragment:t.createFragmentStrategy({endpoint:e}),route:i}}(w),F=new Qr({additionalOrigins:n,enableReferrerDetection:!p,enableLocalhostMatching:!m});F.isProductionUnconfigured?An("[live-preview] LP0101: No trusted origin. Pass allowedOrigins to generateInlineScript() (or to the adapter) \\u2014 the runtime reads no environment variable in the browser."):F.isReferrerOnlyTrust&&An("[live-preview] LP0102: document.referrer fallback trusts any framing site. Set allowedOrigins and a frame-ancestors CSP in production.");let N=new $n,x=function(){let e=[fl,pl,gl,yl,wl,Sl,Tl,kl,{...kl,name:"radio"},Cl,Ol,Ll,Ul,{...Ul,name:"blocks"}];return function(e=[]){let t={};for(let n of e)t[n.name]=n;for(let[e,n]of Il)t[e]=n;return Object.freeze(t)}([Vt("text"),Vt("textarea"),...e,un()])}(),M=new qr({renderers:x,originMatcher:e=>F.matches(e),lockedOrigin:()=>F.lockedOrigin,readyTargets:()=>F.enumerate(),emitter:N,eventSourcePolicy:y,...""!==r?{dataMerge:{serverURL:r,apiRoute:l,depth:o}}:{},debounceMs:s,heartbeatMs:d,intersectionRootMargin:f,disableVisibilityGate:c,visibilityGateThreshold:h,enableA11y:u,scopeBindingsByOwner:g,skipUnchanged:v,revealEditedField:S,onUnfaithfulPatch:i({onUnfaithfulPatch:A,onUnboundChange:k}),autoBind:C,...void 0!==$?{hydration:$}:{},sanitizerPolicy:b,...void 0!==R?{strategies:R}:{},onHeartbeatTimeout:()=>{F.unlockOrigin()},...a?{log:(...e)=>{Cn("[live-preview]",...e)}}:{}});N.on("connect",e=>{F.lockOrigin(e.origin)}),M.start(),e?.destroy();let E=function(e,t={}){let n=t.windowTarget??globalThis.window,i=t.documentTarget??globalThis.document,r=t.softNavigationEvents??[],l=()=>{e.suspend()},o=t=>{!0===t.persisted&&e.resume()},a=()=>{e.refreshCache()};n?.addEventListener("pagehide",l),n?.addEventListener("pageshow",o);for(let e of r)i?.addEventListener(e,a);let s=!1;return()=>{if(!s){s=!0,n?.removeEventListener("pagehide",l),n?.removeEventListener("pageshow",o);for(let e of r)i?.removeEventListener(e,a)}}}({suspend:()=>M.suspend(),resume:()=>M.start(),refreshCache:()=>{M.refreshCache()}}),O=Object.freeze({version:Wi,configSignature:t,destroy:()=>{E(),M.destroy();let e=window;e.__livePreview===O&&delete e.__livePreview},refresh:()=>{M.refreshCache()},enumerateOrigins:()=>F.enumerate(),inspect:()=>M.inspect()});try{Object.defineProperty(window,"__livePreview",{value:O,writable:!1,configurable:!0})}catch(e){throw E(),M.destroy(),e}}()})();'].join(""),bo={generatedAt:"2026-09-19T08:27:03.000Z",size:114844},wo=/* @__PURE__ */['"use strict";var __LIVE_PREVIEW_FRAGMENT__=(()=>{var P=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Z(t))!ee.call(e,r)&&r!==n&&P(e,r,{get:()=>t[r],enumerable:!(o=Q(t,r))||o.enumerable});return e};var re=e=>ne(P({},"__esModule",{value:!0}),e);var De={};te(De,{createFragmentStrategy:()=>J,createRouteStrategy:()=>X});function w(e,t){let n=new AbortController,o=!1,r=()=>{n.abort()};e.addEventListener("abort",r,{once:!0});let i=setTimeout(()=>{o=!0,n.abort()},t);return{signal:n.signal,timedOut:()=>o,dispose:()=>{clearTimeout(i),e.removeEventListener("abort",r)}}}function S(e){return e instanceof Error?e.message:String(e)}var A="data-payload-island",Le=`astro-island, [${A}]`;function oe(e){return e.tagName.toLowerCase()==="astro-island"||e.hasAttribute(A)}function ie(e){return e.getAttribute(A)==="patch"}function ae(e){return oe(e)&&!ie(e)}function _(e){let t=e;for(;t!==null;){if(ae(t))return!0;t=t.parentElement}return!1}function k(e){if(e==null)return[];let t=new Set,n=[];for(let o of e.split(/[\\s,]+/)){let r=o.trim();r.length===0||t.has(r)||(t.add(r),n.push(r))}return n}var b="data-payload-fragment";var N="data-payload-fragment-key",le="data-payload-depends";function I(e){let t=e.getAttribute(b);if(t===null||t.length===0)return null;let n=e.getAttribute(N);return{element:e,id:t,key:n===null||n.length===0?void 0:n,dependsOn:k(e.getAttribute(le))}}function L(e,t){let n=[];for(let o of e.querySelectorAll(`[${b}]`)){let r=I(o);r===null||_(o)||r.dependsOn.length>0&&!r.dependsOn.some(i=>t.has(i))||n.push(r)}return n}var B="x-payload-fragment-version";function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function C(e){if(!D(e))return null;let{html:t,boundary:n,revision:o,metadata:r}=e;return typeof t!="string"||!D(n)||typeof n.id!="string"||n.key!==void 0&&typeof n.key!="string"||typeof o!="number"||!D(r)||typeof r.renderedAt!="string"||typeof r.renderer!="string"?null:e}function U(e){let t={};for(let[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t}function H(e){let t=0,n=[],o=()=>{let r=n.shift();r===void 0?t-=1:r()};return async r=>{t<e?t+=1:await new Promise(i=>{n.push(i)});try{return await r()}finally{o()}}}var de=5e3,ue=4,ce=512*1024,T={status:"superseded"};function h(e,t){return{status:"failed",code:e,reason:t}}function fe(e){let t=()=>{throw new TypeError(\'createFragmentStrategy: endpoint must be a same-origin path starting with "/"\')};if((typeof e!="string"||!e.startsWith("/")||e.startsWith("//")||e.includes("\\\\"))&&t(),typeof location<"u"){let n;try{n=new URL(e,location.href)}catch{n=void 0}n?.origin!==location.origin&&t()}return e}function me(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}async function ye(e,t,n){let o=e.body;if(!me(o)){let d=await e.text();return new TextEncoder().encode(d).byteLength>t?null:d}let r=o.getReader(),i=()=>{r.cancel().catch(()=>{})};n.addEventListener("abort",i,{once:!0});let s=new TextDecoder,a="",c=0;try{for(;;){let{done:d,value:p}=await r.read();if(d)break;if(c+=p.byteLength,c>t)return i(),null;a+=s.decode(p,{stream:!0})}}finally{n.removeEventListener("abort",i)}return a+s.decode()}function K(e){let t=fe(e.endpoint),n=e.timeoutMs??de,o=e.maxResponseBytes??ce,r=H(Math.max(1,e.maxConcurrent??ue)),i=new Map;async function s(a,c){let d=()=>a.signal.aborted;if(d())return T;let p=e.location??location,f=U({fragment:c.id,key:c.key,route:p.pathname,search:p.search,revision:a.revision,locale:a.locale,collectionSlug:a.collectionSlug,globalSlug:a.globalSlug,fields:a.fields}),l=w(a.signal,n),y=u=>d()?T:l.timedOut()?h("LP0801",`timeout after ${String(n)} ms`):h("LP0801",S(u));try{let u;try{u=await(e.fetch??fetch)(t,{method:"POST",credentials:"same-origin",headers:{...e.headers,accept:"application/json","content-type":"application/json",[B]:String(1)},body:JSON.stringify(f),signal:l.signal})}catch(M){return y(M)}if(d())return T;if(u.status===401||u.status===403)return h("LP0803",`endpoint refused the preview (${String(u.status)})`);if(!u.ok)return h("LP0801",`endpoint answered ${String(u.status)}`);let g=u.headers.get("content-type")??"";if(!g.toLowerCase().startsWith("application/json"))return h("LP0802",`unexpected content type "${g}"`);if(Number(u.headers.get("content-length")??"0")>o)return h("LP0802","response exceeds the size limit");let E;try{E=await ye(u,o,l.signal)}catch(M){return y(M)}if(d())return T;if(l.timedOut())return h("LP0801",`timeout after ${String(n)} ms`);if(E===null)return h("LP0802","response exceeds the size limit");let x;try{x=JSON.parse(E)}catch{return h("LP0802","response is not JSON")}let R=C(x);return R===null?h("LP0802","response has the wrong shape"):R.boundary.id!==c.id?h("LP0802","response is for another boundary"):R.revision!==a.revision?T:{status:"rendered",html:R.html,metadata:R.metadata}}finally{l.dispose()}}return(a,c)=>{let d=`${c.id} ${c.key??""} ${String(a.revision)}`,p=i.get(d);if(p!==void 0)return p;let f=r(()=>s(a,c));i.set(d,f);let l=()=>{i.get(d)===f&&i.delete(d)};return f.then(l,l),f}}var O="data-payload-owned",pe=new Set(["open","value","checked","selected"]);function q(e,t){for(let n of t.keyAttributes){let o=e.getAttribute(n);if(o!==null&&o.length>0)return`${n}=${o}`}}function F(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(A)||e.hasAttribute(O))return!0;let t=e.getAttribute("contenteditable");return t!==null&&t!=="false"}function ge(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!F(e)&&!F(t)}function v(e,t,n){if(!ge(e,t))return t;let o=Re(e);return he(e,t),n.retainChildrenOf?.(e,t)!==!0&&Ee(e,t,n),Ae(o),e}function he(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||pe.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(let n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function Ee(e,t,n){let o=be(e,n),r=new Set(o.values()),i=Array.from(e.childNodes).filter(f=>!r.has(f)),s=new Set,a=new Set,c=Array.from(t.childNodes),d=e.firstChild,p=0;for(let f=0;f<c.length;f+=1){let l=c[f],y=null,u=l instanceof Element?q(l,n):void 0;if(u!==void 0&&a.has(u)&&(u=void 0),u!==void 0){a.add(u);let m=o.get(u);if(m!==void 0&&!s.has(m)&&(y=$(m,l,n)===m?m:null,y===null)){m.replaceWith(l),s.add(l),d=l.nextSibling;continue}}else{for(;p<i.length;){let m=i[p];if(p+=1,!s.has(m)){if(G(m,l)){y=$(m,l,n)===m?m:null,y===null&&(e.replaceChild(l,m),s.add(l),d=l.nextSibling);break}if(m instanceof Element){let E=c[f+1];if(!(l instanceof Element)||E!==void 0&&G(m,E)){p-=1;break}e.replaceChild(l,m),s.add(l),d=l.nextSibling;break}if(!(l instanceof Element)){e.replaceChild(l,m),s.add(l),d=l.nextSibling;break}}}if(y===null&&s.has(l))continue}let g=y??l;for(s.add(g);d!==null&&d!==g&&!s.has(d)&&Se(d);)d=d.nextSibling;g!==d&&e.insertBefore(g,d),d=g.nextSibling}for(let f of Array.from(e.childNodes))s.has(f)||f.remove()}function $(e,t,n){return e instanceof Element&&t instanceof Element?F(e)&&F(t)?e:v(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function Se(e){return e.nodeType===Node.TEXT_NODE&&(e.nodeValue??"").trim().length===0}function G(e,t){return e.nodeType!==t.nodeType?!1:e instanceof Element&&t instanceof Element?e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI:!0}function be(e,t){let n=new Map,o;for(let r of Array.from(e.children)){let i=q(r,t);if(i!==void 0){if(n.has(i)){o??(o=i.slice(i.indexOf("=")+1));continue}n.set(i,r)}}return o!==void 0&&t.onDuplicateKey?.(e,o),n}function Re(e){let t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement)||!e.contains(t))return null;let n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null;return{element:t,selection:n}}function Ae(e){if(e===null)return;let{element:t,selection:n}=e;if(!(t.ownerDocument.activeElement===t||!t.isConnected))try{t.focus({preventScroll:!0});let[o,r]=n??[null,null];o!==null&&r!==null&&t.setSelectionRange(o,r)}catch{}}var W="data-payload-key";var Te="__livePreviewRouteRefresh";function xe(){return typ','eof window>"u"?void 0:window}function z(){return xe()?.[Te]}var j="data-payload-strategy",Y="data-payload-field",we="data-payload-depends",ke="x-payload-live-preview",Fe=8e3,Oe=1e3;function Me(e){let t=e.getAttribute(j);return t!==null?t==="route":e.closest("head")!==null}function Pe(e){let t=e.getAttribute(Y),n=k(e.getAttribute(we));return t===null||t.length===0?n:[t,...n]}function V(e){if(e.tagName==="META"){let t=e.getAttribute("name")??e.getAttribute("property");return t===null?null:`meta:${t}`}return e.tagName==="LINK"&&e.getAttribute("rel")==="canonical"?"link:canonical":null}function Ne(e,t){t.title!==e.title&&(e.title=t.title);let n=new Map;for(let r of e.head.querySelectorAll("meta, link")){let i=V(r);i!==null&&!n.has(i)&&n.set(i,r)}let o=new Set;for(let r of t.head.querySelectorAll("meta, link")){let i=V(r);if(i===null)continue;o.add(i);let s=n.get(i);if(s===void 0){e.head.append(e.importNode(r,!0));continue}if(!s.hasAttribute(O))for(let a of Array.from(r.attributes))s.getAttribute(a.name)!==a.value&&s.setAttribute(a.name,a.value)}for(let[r,i]of n)!o.has(r)&&!i.hasAttribute(O)&&i.remove()}function X(e={}){let t=e.timeoutMs??Fe,n=e.minIntervalMs??Oe,o=-1/0;return{plan(r,i){for(let s of r.querySelectorAll(`[${Y}], [${j}="route"]`)){if(!Me(s))continue;let a=Pe(s);if(a.length===0||a.some(c=>i.has(c)))return!0}return!1},async refresh(r){let i=Date.now(),s=n-(i-o);if(s>0)return r.retryAfter?.(s),r.log("LP0805",`route refresh for revision ${String(r.revision)} refused: the previous one was ${String(i-o)} ms ago`),"refused";o=i;let a=e.document??document,c=e.location??location,d=e.window??window,p=w(r.signal,t),f=l=>{if(r.signal.aborted)return"superseded";let y=p.timedOut()?`route refresh timed out after ${String(t)} ms`:S(l);return r.log("LP0801",y),"failed"};try{let l=z();if(l!==void 0){try{await l()}catch(u){return f(u)}return r.isCurrent()?"refreshed":"superseded"}let y;try{y=await(e.fetch??fetch)(c.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[ke]:"route"},signal:p.signal})}catch(u){return f(u)}if(r.signal.aborted)return"superseded";if(!y.ok||!(y.headers.get("content-type")??"").includes("text/html"))return r.log("LP0802",`route answered ${String(y.status)} ${y.headers.get("content-type")??""}`),"failed";try{let u=await y.text();if(!r.isCurrent())return"superseded";let g=new DOMParser().parseFromString(u,"text/html"),m=d.scrollX,E=d.scrollY;return Ne(a,g),v(a.body,g.body,{keyAttributes:[W,N,b],retainChildrenOf:x=>x.hasAttribute(b)}),d.scrollTo(m,E),"refreshed"}catch(u){return f(u)}}finally{p.dispose()}}}}function Ie(e){return{plan:(t,n)=>L(t,n).map(o=>o.element),async render(t,n){let o={rendered:0,failed:0,superseded:0},r={revision:t.revision,receivedAt:t.receivedAt,fields:t.fields,locale:t.locale,collectionSlug:t.collectionSlug,globalSlug:t.globalSlug,signal:t.signal};return await Promise.all(n.map(async i=>{let s=I(i);if(s===null)return;let a;try{a=await e(r,s)}catch(c){a={status:"failed",code:"LP0801",reason:S(c)}}if(!t.isCurrent()||a.status==="superseded"){o.superseded+=1,t.log("LP0804",`fragment "${s.id}" for revision ${String(r.revision)} discarded as superseded`);return}if(a.status==="rendered"){t.morph(i,a.html),t.rendered(i,s.id,s.key),o.rendered+=1;return}t.failed(i,s.id,s.key,a.code,a.reason),t.isCurrent()&&t.patch(i),o.failed+=1})),o}}}function J(e){return Ie(K(e))}return re(De);})();'].join(""),So=/* @__PURE__ */['"use strict";var __LIVE_PREVIEW_ROUTE__=(()=>{var S=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var $=(e,n)=>{for(var t in n)S(e,t,{get:n[t],enumerable:!0})},H=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of L(n))!K.call(e,r)&&r!==t&&S(e,r,{get:()=>n[r],enumerable:!(o=U(n,r))||o.enumerable});return e};var z=e=>H(S({},"__esModule",{value:!0}),e);var ae={};$(ae,{createRouteStrategy:()=>B});var A="data-payload-island",se=`astro-island, [${A}]`;var b="data-payload-owned",W=new Set(["open","value","checked","selected"]);function k(e,n){for(let t of n.keyAttributes){let o=e.getAttribute(t);if(o!==null&&o.length>0)return`${t}=${o}`}}function E(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(A)||e.hasAttribute(b))return!0;let n=e.getAttribute("contenteditable");return n!==null&&n!=="false"}function q(e,n){return e.tagName===n.tagName&&e.namespaceURI===n.namespaceURI&&!E(e)&&!E(n)}function R(e,n,t){if(!q(e,n))return n;let o=X(e);return Y(e,n),t.retainChildrenOf?.(e,n)!==!0&&G(e,n,t),J(o),e}function Y(e,n){for(let t of Array.from(e.attributes))n.hasAttribute(t.name)||W.has(t.name.toLowerCase())||e.removeAttribute(t.name);for(let t of Array.from(n.attributes))e.getAttribute(t.name)!==t.value&&e.setAttribute(t.name,t.value)}function G(e,n,t){let o=j(e,t),r=new Set(o.values()),l=Array.from(e.childNodes).filter(m=>!r.has(m)),a=new Set,f=new Set,g=Array.from(n.childNodes),s=e.firstChild,y=0;for(let m=0;m<g.length;m+=1){let i=g[m],u=null,c=i instanceof Element?k(i,t):void 0;if(c!==void 0&&f.has(c)&&(c=void 0),c!==void 0){f.add(c);let d=o.get(c);if(d!==void 0&&!a.has(d)&&(u=x(d,i,t)===d?d:null,u===null)){d.replaceWith(i),a.add(i),s=i.nextSibling;continue}}else{for(;y<l.length;){let d=l[y];if(y+=1,!a.has(d)){if(w(d,i)){u=x(d,i,t)===d?d:null,u===null&&(e.replaceChild(i,d),a.add(i),s=i.nextSibling);break}if(d instanceof Element){let h=g[m+1];if(!(i instanceof Element)||h!==void 0&&w(d,h)){y-=1;break}e.replaceChild(i,d),a.add(i),s=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,d),a.add(i),s=i.nextSibling;break}}}if(u===null&&a.has(i))continue}let p=u??i;for(a.add(p);s!==null&&s!==p&&!a.has(s)&&V(s);)s=s.nextSibling;p!==s&&e.insertBefore(p,s),s=p.nextSibling}for(let m of Array.from(e.childNodes))a.has(m)||m.remove()}function x(e,n,t){return e instanceof Element&&n instanceof Element?E(e)&&E(n)?e:R(e,n,t):(e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue),e)}function V(e){return e.nodeType===Node.TEXT_NODE&&(e.nodeValue??"").trim().length===0}function w(e,n){return e.nodeType!==n.nodeType?!1:e instanceof Element&&n instanceof Element?e.tagName===n.tagName&&e.namespaceURI===n.namespaceURI:!0}function j(e,n){let t=new Map,o;for(let r of Array.from(e.children)){let l=k(r,n);if(l!==void 0){if(t.has(l)){o??(o=l.slice(l.indexOf("=")+1));continue}t.set(l,r)}}return o!==void 0&&n.onDuplicateKey?.(e,o),t}function X(e){let n=e.ownerDocument.activeElement;if(!(n instanceof HTMLElement)||!e.contains(n))return null;let t=n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement?[n.selectionStart,n.selectionEnd]:null;return{element:n,selection:t}}function J(e){if(e===null)return;let{element:n,selection:t}=e;if(!(n.ownerDocument.activeElement===n||!n.isConnected))try{n.focus({preventScroll:!0});let[o,r]=t??[null,null];o!==null&&r!==null&&n.setSelectionRange(o,r)}catch{}}var I="data-payload-key";function N(e){if(e==null)return[];let n=new Set,t=[];for(let o of e.split(/[\\s,]+/)){let r=o.trim();r.length===0||n.has(r)||(n.add(r),t.push(r))}return t}var Q="__livePreviewRouteRefresh";function Z(){return typ','eof window>"u"?void 0:window}function M(){return Z()?.[Q]}var T="data-payload-fragment";function v(e,n){let t=new AbortController,o=!1,r=()=>{t.abort()};e.addEventListener("abort",r,{once:!0});let l=setTimeout(()=>{o=!0,t.abort()},n);return{signal:t.signal,timedOut:()=>o,dispose:()=>{clearTimeout(l),e.removeEventListener("abort",r)}}}function D(e){return e instanceof Error?e.message:String(e)}var P="data-payload-fragment-key";var C="data-payload-strategy",_="data-payload-field",ee="data-payload-depends",ne="x-payload-live-preview",te=8e3,re=1e3;function oe(e){let n=e.getAttribute(C);return n!==null?n==="route":e.closest("head")!==null}function le(e){let n=e.getAttribute(_),t=N(e.getAttribute(ee));return n===null||n.length===0?t:[n,...t]}function O(e){if(e.tagName==="META"){let n=e.getAttribute("name")??e.getAttribute("property");return n===null?null:`meta:${n}`}return e.tagName==="LINK"&&e.getAttribute("rel")==="canonical"?"link:canonical":null}function ie(e,n){n.title!==e.title&&(e.title=n.title);let t=new Map;for(let r of e.head.querySelectorAll("meta, link")){let l=O(r);l!==null&&!t.has(l)&&t.set(l,r)}let o=new Set;for(let r of n.head.querySelectorAll("meta, link")){let l=O(r);if(l===null)continue;o.add(l);let a=t.get(l);if(a===void 0){e.head.append(e.importNode(r,!0));continue}if(!a.hasAttribute(b))for(let f of Array.from(r.attributes))a.getAttribute(f.name)!==f.value&&a.setAttribute(f.name,f.value)}for(let[r,l]of t)!o.has(r)&&!l.hasAttribute(b)&&l.remove()}function B(e={}){let n=e.timeoutMs??te,t=e.minIntervalMs??re,o=-1/0;return{plan(r,l){for(let a of r.querySelectorAll(`[${_}], [${C}="route"]`)){if(!oe(a))continue;let f=le(a);if(f.length===0||f.some(g=>l.has(g)))return!0}return!1},async refresh(r){let l=Date.now(),a=t-(l-o);if(a>0)return r.retryAfter?.(a),r.log("LP0805",`route refresh for revision ${String(r.revision)} refused: the previous one was ${String(l-o)} ms ago`),"refused";o=l;let f=e.document??document,g=e.location??location,s=e.window??window,y=v(r.signal,n),m=i=>{if(r.signal.aborted)return"superseded";let u=y.timedOut()?`route refresh timed out after ${String(n)} ms`:D(i);return r.log("LP0801",u),"failed"};try{let i=M();if(i!==void 0){try{await i()}catch(c){return m(c)}return r.isCurrent()?"refreshed":"superseded"}let u;try{u=await(e.fetch??fetch)(g.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[ne]:"route"},signal:y.signal})}catch(c){return m(c)}if(r.signal.aborted)return"superseded";if(!u.ok||!(u.headers.get("content-type")??"").includes("text/html"))return r.log("LP0802",`route answered ${String(u.status)} ${u.headers.get("content-type")??""}`),"failed";try{let c=await u.text();if(!r.isCurrent())return"superseded";let p=new DOMParser().parseFromString(c,"text/html"),d=s.scrollX,h=s.scrollY;return ie(f,p),R(f.body,p.body,{keyAttributes:[I,P,T],retainChildrenOf:F=>F.hasAttribute(T)}),s.scrollTo(d,h),"refreshed"}catch(c){return m(c)}}finally{y.dispose()}}}}return z(ae);})();'].join(""),Ao=["allowedOrigins","serverURL","apiRoute","mergeDepth","debug","debounceMs","enableA11y","heartbeatMs","disableVisibilityGate","visibilityGateThreshold","intersectionRootMargin","disableReferrerDetection","disableLocalhostMatching","scopeBindingsByOwner","skipUnchanged","eventSourcePolicy","sanitizerPolicy","fragmentEndpoint","revealEditedField","routeStrategy","onUnboundChange","onUnfaithfulPatch","autoBind","hydration","defaults"];function ko(e,t){if(0===e.length)throw new Error(`[live-preview] ${t} is empty. Run \`npm run build:runtime\` before bundling.`)}function To(e){return null!=e.fragmentEndpoint?(ko(wo,"fragment.generated.ts"),[wo]):!0===e.routeStrategy?(ko(So,"route.generated.ts"),[So]):[]}function Co(e){return`var __LIVE_PREVIEW_CONFIG__=${function(e){t(e);const n=function(e){const t=e.defaults??"v2";return"v1"===t?{...ho,defaults:t}:{defaults:t}}(e);return`[${Ao.map(t=>e[t]??n[t]).map(e=>void 0===e?"":JSON.stringify(e)).join(",")}]`.replace(/</g,"\\u003C")}(e)};`}var $o,xo=/[\t\n\f\r ]+/;function Ro(e,t){const n=e.charCodeAt(t);return 9===n||10===n||12===n||13===n||32===n}function No(e){let t=0,n=e.length;for(;t<n&&Ro(e,t);)t+=1;for(;n>t&&Ro(e,n-1);)n-=1;return 0===t&&n===e.length?e:e.slice(t,n)}function Po(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function Eo(e,t){const n=/* @__PURE__ */new Map;for(const t of e.split(";")){const e=No(t);if(0===e.length)continue;const r=e.search(xo),i=Po(r<0?e:e.slice(0,r));if(n.has(i))continue;const o=r<0?"":No(e.slice(r));n.set(i,o)}for(const[e,r]of Object.entries(t)){const t=Po(e),i="string"==typeof r?{value:r}:r,o=i.mode??"union",s=n.get(t);if("replace"===o||void 0===s||0===s.length){n.set(t,i.value);continue}const a=/* @__PURE__ */new Set,l=[];for(const e of[...s.split(xo),...i.value.split(xo)])0===e.length||a.has(e)||(a.add(e),l.push(e));const u=l.filter(e=>"'none'"!==e);n.set(t,(u.length>0?u:l).join(" "))}const r=[];for(const[e,t]of n)r.push(0===t.length?e:`${e} ${t}`);return r.join("; ")}var Fo="payload-live-preview.authorized-preview-context",Lo=Symbol.for(Fo);function isAuthorizedPreviewContext(e){return"object"==typeof e&&null!==e&&!0===e[Lo]&&Object.isFrozen(e)}function Mo(e){return Object.freeze({...e,scope:Object.freeze({...e.scope}),payloadHeaders:Object.freeze({...e.payloadHeaders}),[Lo]:!0,[Fo]:!0})}var Oo=class extends Error{name="PreviewConfigurationError"};function Uo(e){return{authorized:!1,outcome:e,context:null}}var Io="users",_o=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,jo=/^[A-Za-z0-9._~-]+$/;var Do,zo="live-preview",Bo="v1";function Wo(){return Do??=new TextEncoder,Do}function Ho(e){const t="string"==typeof e?Wo().encode(e):e;if(t.byteLength<32)throw new Oo(`payload-live-preview: the preview token secret must be at least ${String(32)} bytes`);return t}function Vo(e){if(void 0!==e)return e;const t=globalThis.crypto;return"object"==typeof t?.subtle?t:void 0}async function qo(e,t){return e.subtle.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}function Go(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ko(e){if(!/^[A-Za-z0-9_-]*$/.test(e))return;const t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4);try{const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)n[t]=e.charCodeAt(t);return n}catch{return}}var Jo=["preview","draft","livePreview"];function Zo(e,t={}){const n=new Set(t.signals??["query","fetch-dest","referer"]),r=t.queryParams??Jo;if(n.has("query")){let t;try{t=new URL(e.url)}catch{t=void 0}if(void 0!==t)for(const e of r){const n=t.searchParams.getAll(e).at(-1);if("true"===n||"1"===n)return!0}}if(n.has("fetch-dest")&&"iframe"===e.headers.get("sec-fetch-dest"))return!0;const i=t.allowedOrigins??t.adminOrigins??[],o=n.has("referer")?i:[];if(o.length>0){const t=e.headers.get("referer");if(null!==t)try{const e=new URL(t).origin;for(const t of o)try{if(new URL(t).origin===e)return!0}catch{}}catch{}}return!1}var Xo=Zo,Qo="payload-live-preview-highlight",Yo=/* @__PURE__ */new WeakMap,es=/* @__PURE__ */new WeakMap,ts={name:"highlight",version:"1.0.0",init:e=>{if("undefined"==typeof document||"undefined"==typeof window)return;const t="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,n=function(e,t){let n=Yo.get(e);void 0===n||n.connected()||(Yo.delete(e),n=void 0),void 0===n&&(n=function(e,t){const n=e.getElementById(Qo);if(n instanceof HTMLStyleElement)return{pluginOwned:!1,connected:()=>n.isConnected,remove:()=>{},owners:0};const r=function(e,t){try{if(!Array.isArray(e.adoptedStyleSheets)||"function"!=typeof CSSStyleSheet)return;const n=new CSSStyleSheet;if("function"!=typeof n.replaceSync)return;return n.replaceSync(t),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n],n}catch{return}}(e,t);if(void 0!==r)return{pluginOwned:!0,connected:()=>e.adoptedStyleSheets.includes(r),remove:()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==r)},owners:0};const i=e.createElement("style");return i.id=Qo,i.textContent=t,e.head.appendChild(i),{pluginOwned:!0,connected:()=>i.isConnected,remove:()=>{i.remove()},owners:0}}(e,t?".lp-highlight{outline:2px solid rgba(0,102,204,0.85);outline-offset:2px;}":"@keyframes lp-highlight{0%{outline:2px solid rgba(0,102,204,0.85);outline-offset:2px}100%{outline:2px solid transparent;outline-offset:2px}}.lp-highlight{animation:lp-highlight 0.6s ease-out;}"),Yo.set(e,n));const r=n;r.owners+=1;let i=!0;return()=>{i&&(i=!1,r.owners-=1,r.owners>0||(Yo.get(e)===r&&Yo.delete(e),r.pluginOwned&&r.remove()))}}(document,t),r=t?1e3:600,i=/* @__PURE__ */new WeakMap,o=/* @__PURE__ */new Set;e.registerCleanup?.(()=>{for(const e of[...o])e();n()}),e.events.on("elementUpdate",e=>{const t=e.element;i.get(t)?.();const n=function(e){let t=es.get(e);void 0===t&&(t={owners:0,pluginAdded:!e.classList.contains("lp-highlight")},es.set(e,t));const n=t;n.owners+=1,e.classList.add("lp-highlight");let r=!0;return()=>{r&&(r=!1,n.owners-=1,n.owners>0||(es.delete(e),n.pluginAdded&&e.classList.remove("lp-highlight")))}}(t);let s=!1;const a=()=>{s||(s=!0,window.clearTimeout(l),i.get(t)===a&&i.delete(t),o.delete(a),n())},l=window.setTimeout(a,r);o.add(a),i.set(t,a)})}},ns={name:"debug",version:"1.0.0",init:e=>{e.events.on("init",()=>{e.log("init")}),e.events.on("connect",t=>{e.log("connect ←",t.origin)}),e.events.on("disconnect",t=>{e.log("disconnect (",t.reason,")")}),e.events.on("cacheRefresh",t=>{e.log("cacheRefresh",t.elementCount,"elements,",t.fieldCount,"fields")}),e.events.on("beforeUpdate",t=>{e.log("beforeUpdate",Object.keys(t.data.fields).length,"fields")}),e.events.on("afterUpdate",t=>{e.log("afterUpdate",t.updatedCount,"in",t.durationMs.toFixed(2),"ms")}),e.events.on("error",t=>{e.log("error in",t.context,":",t.error.message)})}},rs="payload-live-preview:scroll";function is(){"undefined"!=typeof window&&(function(){if("undefined"!=typeof window)try{sessionStorage.setItem(rs,JSON.stringify({href:window.location.href,x:window.scrollX,y:window.scrollY}))}catch{}}(),window.location.reload())}function bind(e,t){return os(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 os(n.join("."),t)}function os(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),n}var ss=/^[a-z][a-z0-9-]{0,63}$/u,as=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):as,bindByPath:(e,n)=>t?bindByPath(e,n):as,owner:()=>t&&void 0!==n?{"data-payload-owner":n}:as,boundary:(e,n={})=>{const r=function(e,t){if(!ss.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:as}})}exports.AUTHORIZED_PREVIEW_BRAND_KEY=Fo,exports.CAPABILITY_DECLARATIONS=f,exports.CAPABILITY_DOCUMENTATION={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"}},exports.DIAGNOSTIC_CODES=vo,exports.EventEmitter=EventEmitter,exports.ISLAND_EVENT=Ee,exports.LIBRARY_PROTOCOL_VERSION=4,exports.LivePreviewClient=LivePreviewClient,exports.OriginDetector=OriginDetector,exports.PROTOCOL_CAPABILITIES=h,exports.TRUSTED_TYPES_POLICY_NAME=rn,exports.VERSION=e,exports.authorizePreviewRequest=async function(e,t){switch(t.type){case"payload-session":return async function(e,t){const n=function(e){const t=e??"payload-token";if(!_o.test(t))throw new Oo(`payload-live-preview: cookie name "${t}" is not a valid cookie-name token`);return t}(t.cookieName),r=function(e){let t;try{t=new URL(e)}catch{throw new Oo(`payload-live-preview: serverURL "${e}" is not an absolute URL`)}if("https:"!==t.protocol&&"http:"!==t.protocol)throw new Oo(`payload-live-preview: serverURL must be http(s), got "${t.protocol}"`);return t.origin}(t.serverURL),i=function(e,t,n=4096){if(null===e||0===e.length)return null;const r=`${t}=`,i=[];for(const t of e.split(";")){const e=t.trim();e.startsWith(r)&&i.push(e.slice(r.length))}if(1!==i.length)return null;const o=i[0]??"";return 0===o.length||o.length>n||!jo.test(o)?null:o}(e.headers.get("cookie"),n,t.maxCookieLength??4096);if(null===i)return Uo("missing-credential");const o=t.now??Date.now,s=Math.max(250,t.timeoutMs??3e3),a=t.fetch??globalThis.fetch,l=encodeURIComponent(t.usersSlug??Io),u=`${n}=${i}`;let d;try{const e=await a(`${r}/api/${l}/me?depth=0`,{headers:{cookie:u,accept:"application/json"},signal:AbortSignal.timeout(s)});if(!e.ok)return Uo(401===e.status?"invalid":"unavailable");d=await e.json()}catch{return Uo("unavailable")}const c=function(e,t){if("object"!=typeof e||null===e||Array.isArray(e))return null;const n=e.user;if("object"!=typeof n||null===n||Array.isArray(n))return null;const r=e.collection??n.collection;if(void 0!==r&&r!==t)return null;const i=n.id;return"string"==typeof i&&i.length>0?i:"number"==typeof i&&Number.isFinite(i)?String(i):null}(d,t.usersSlug??Io);if(null===c)return Uo("invalid");const f=function(e){const t=e.exp;return"number"!=typeof t||!Number.isFinite(t)||t<=0?void 0:t<1e11?1e3*t:t}(d);return void 0!==f&&f<=o()?Uo("expired"):{authorized:!0,outcome:"authorized",context:Mo({strategy:"payload-session",subject:c,authorizedAt:o(),expiresAt:f,scope:{},payloadHeaders:{cookie:u}})}}(e,t);case"signed-token":return async function(e,t){const n=Ho(t.secret),r=Vo(t.crypto);if(void 0===r)return Uo("unavailable");const i=function(e,t){if("header"===t?.kind)return e.headers.get(t.name??"x-preview-token");let n;try{n=new URL(e.url)}catch{return null}const r=n.searchParams.getAll(t?.param??"previewToken");return 1===r.length?r[0]??null:null}(e,t.transport);if(null===i||0===i.length)return Uo("missing-credential");if(i.length>4096)return Uo("invalid");const o=i.split(".");if(3!==o.length||o[0]!==Bo)return Uo("invalid");const s=o[1]??"",a=Ko(s),l=Ko(o[2]??"");if(void 0===a||32!==l?.byteLength)return Uo("invalid");let u;try{const e=await qo(r,n);u=await r.subtle.verify("HMAC",e,l,Wo().encode(`${Bo}.${s}`))}catch{return Uo("unavailable")}if(!u)return Uo("invalid");const d=function(e){let t;try{t=JSON.parse((new TextDecoder).decode(e))}catch{return}if("object"!=typeof t||null===t)return;const n=t,r=e=>void 0===n[e]||"string"==typeof n[e];return 1===n.v&&"string"==typeof n.aud&&"string"==typeof n.pur&&"number"==typeof n.iat&&"number"==typeof n.exp&&"string"==typeof n.jti&&r("pth")&&r("loc")&&r("sub")?n:void 0}(a);if(void 0===d)return Uo("invalid");const c=(t.now??Date.now)();if(d.exp<=c||d.iat>d.exp)return Uo("expired");if(d.aud!==t.audience)return Uo("wrong-audience");if(d.pur!==(t.purpose??zo))return Uo("wrong-purpose");if(void 0!==d.pth){let t;try{t=new URL(e.url).pathname}catch{return Uo("invalid")}if(d.pth!==t)return Uo("wrong-path")}if(void 0!==d.loc){const n=t.locale?.(e);if(n!==d.loc)return Uo("wrong-locale")}if(void 0!==t.replay){let e;try{e=await async function(e,t,n){return"consume"in e?!0===await e.consume(t,n):!await e.isUsed(t)&&(await e.markUsed(t,n),!0)}(t.replay,d.jti,d.exp)}catch{return Uo("unavailable")}if(!e)return Uo("replayed")}return{authorized:!0,outcome:"authorized",context:Mo({strategy:"signed-token",subject:d.sub,authorizedAt:c,expiresAt:d.exp,scope:{audience:d.aud,...void 0!==d.pth?{path:d.pth}:{},...void 0!==d.loc?{locale:d.loc}:{}},payloadHeaders:{}})}}(e,t);case"verifier":return async function(e,t){let n;try{n=await t.verify(e)}catch{return Uo("unavailable")}if(null===n)return Uo("invalid");const r=(t.now??Date.now)();return void 0!==n.expiresAt&&n.expiresAt<=r?Uo("expired"):{authorized:!0,outcome:"authorized",context:Mo({strategy:"verifier",subject:n.subject,authorizedAt:r,expiresAt:n.expiresAt,scope:n.scope??{},payloadHeaders:n.payloadHeaders??{}})}}(e,t)}},exports.bind=bind,exports.bindByPath=bindByPath,exports.bindNavigationLifecycle=function(e,t={}){const n=t.windowTarget??globalThis.window,r=t.documentTarget??globalThis.document,i=t.softNavigationEvents??[],o=()=>{e.suspend()},s=t=>{!0===t.persisted&&e.resume()},a=()=>{e.refreshCache()};n?.addEventListener("pagehide",o),n?.addEventListener("pageshow",s);for(const e of i)r?.addEventListener(e,a);let l=!1;return()=>{if(!l){l=!0,n?.removeEventListener("pagehide",o),n?.removeEventListener("pageshow",s);for(const e of i)r?.removeEventListener(e,a)}}},exports.buildBuiltinRenderers=co,exports.buildFrameAncestors=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'"},exports.buildScriptSrcWithNonce=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(" ")},exports.createAnalyticsPlugin=function(){let e=0,t=0,n=0;return{name:"analytics",version:"1.0.0",init:r=>{r.events.on("afterUpdate",r=>{e+=1,t+=r.updatedCount,n+=r.durationMs})},getStats:()=>({updateCount:e,totalElements:t,totalDurationMs:n,averageDurationMs:0===e?0:n/e})}},exports.createPreviewBindings=createPreviewBindings,exports.createPreviewFocusReporter=function(e,t){return n=>{const r=e();null!=r&&mo(r,n,t)}},exports.debugPlugin=ns,exports.detectInitialLocale=detectInitialLocale,exports.detectProtocolProfile=detectProtocolProfile,exports.documentSavePlugin=function(e={}){const t=e.strategy??"silent";return{name:"document-save",version:"1.1.0",init:n=>{let r=!0;const i=/* @__PURE__ */new Set;n.registerCleanup?.(()=>{r=!1;for(const e of i)e.abort();i.clear()}),function(){if("undefined"!=typeof window)try{const e=sessionStorage.getItem(rs);if(null===e)return;sessionStorage.removeItem(rs);const t=JSON.parse(e);if(t.href!==window.location.href)return;window.scrollTo(t.x??0,t.y??0)}catch{}}(),n.events.on("documentSave",()=>{if(!r)return;if("silent"===t)return;if("reload"===t)return void is();const o=new AbortController;i.add(o);const s="fetch"===t?async function(e,t,n){if(e.handler)try{await e.handler(n)}catch(e){if(!r||n.aborted)return;t("document-save handler threw:",e)}else t("document-save: fetch strategy selected but no handler supplied")}(e,n.log,o.signal):async function(e,t,n,r){if("undefined"==typeof fetch)return void t("document-save: revalidate strategy needs fetch — not available");const i=e.revalidateUrl??"/api/revalidate";let o=!1;try{const s=await fetch(i,{method:"POST",signal:n,headers:{"Content-Type":"application/json",...e.revalidateHeaders??{}},body:JSON.stringify({source:"payload-live-preview"})});if(!r()||n.aborted)return;o=s.ok,o||t("document-save revalidate non-2xx:",s.status)}catch(e){if(!r()||n.aborted)return;t("document-save revalidate failed:",e)}o||"reload"!==e.onRevalidateFailure||is()}(e,n.log,o.signal,()=>r);s.finally(()=>{i.delete(o)})})}}},exports.escapeHtml=escapeHtml,exports.escapeHtmlAttribute=escapeHtmlAttribute,exports.generateCspNonce=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($o?.getRandomValues)return $o;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)},exports.generateInlineScript=function generateInlineScript(e={}){const t=function(e){const t=e.runtime;if(void 0===t)return ko(yo,"runtime.generated.ts"),yo;if(ko(t.source,`the ${t.profile} runtime`),null!=e.fragmentEndpoint||!0===e.routeStrategy)throw new Error(`[live-preview] the ${t.profile} runtime and the fragment or route strategy exclude each other: it carries no strategy runner, so the prelude would have nothing to talk to. Drop the runtime option, or drop \`fragmentEndpoint\`/\`routeStrategy\`.`);return t.source}(e);return[Co(e),...To(e),t].join("\n")},exports.hasCapability=function hasCapability(e,t){return e.capabilities.has(t)},exports.hasPreviewIntent=Zo,exports.highlightPlugin=ts,exports.initLivePreview=function initLivePreview(e={}){const t=new LivePreviewClient({...e,autoStart:!1});return t.start()?t:null},exports.isAuthorizedPreviewContext=isAuthorizedPreviewContext,exports.isDevMode=isDevMode,exports.isExternalHttpUrl=isExternalHttpUrl,exports.isInIframe=isInIframe,exports.isInPopup=isInPopup,exports.isInPreviewContext=isInPreviewContext,exports.isInsideIsland=isInsideIsland,exports.isLexicalContent=li,exports.isPreviewRequest=Xo,exports.isSafeUrl=isSafeUrl,exports.issuePreviewToken=async function(e,t){const n=Vo(t.crypto);if(void 0===n)throw new Error("payload-live-preview: no Web Crypto implementation available to sign tokens");const r=Ho(t.secret),i=(t.now??Date.now)(),o=Math.min(36e5,Math.max(1,e.ttlMs??6e5)),s=new Uint8Array(16);n.getRandomValues(s);const a={v:1,aud:e.audience,...void 0!==e.path?{pth:e.path}:{},...void 0!==e.locale?{loc:e.locale}:{},...void 0!==e.subject?{sub:e.subject}:{},pur:e.purpose??zo,iat:i,exp:i+o,jti:Go(s)},l=Go(Wo().encode(JSON.stringify(a))),u=`${Bo}.${l}`,d=await qo(n,r);return`${u}.${Go(new Uint8Array(await n.subtle.sign("HMAC",d,Wo().encode(u))))}`},exports.lexicalToHtml=ui,exports.lexicalToPlainText=di,exports.mergeCspHeader=function(e,t){const n=e.split(",").filter(e=>e.trim().length>0);return 0===n.length?Eo("",t):n.map(e=>Eo(e,t)).join(", ")},exports.negotiateProtocol=negotiateProtocol,exports.previewBindingsFromLocals=function(e,t={}){return createPreviewBindings({authorization:("object"==typeof e&&null!==e?e.livePreviewAuthorization:void 0)??null,...void 0!==t.owner?{owner:t.owner}:{}})},exports.registerBlockRenderer=function(e,t){ei.set(e,t)},exports.registerBuiltinRenderer=function(e){lo.set(e.name,e)},exports.registerRouteRefresh=function registerRouteRefresh(e){const t="undefined"==typeof window?void 0:window;return void 0===t?()=>{}:(t[go]=e,()=>{t[go]===e&&(t[go]=void 0)})},exports.reportPreviewFocus=mo,exports.runtimeBuildInfo=function(){return bo},exports.sanitizeHtml=sanitizeHtml,exports.setCspCrypto=function setCspCrypto(e){$o=e??void 0},exports.setSanitizerDocument=function setSanitizerDocument(e){globalThis[Pn]=e??void 0},exports.setSanitizerPolicy=function(e){Nn=e},exports.setTrustedTypesPolicy=function(e){sn().override=e},exports.trustedHtml=an,exports.wrapWithScriptTag=function(e,t={}){return`<script${void 0!==t.nonce?` nonce="${function(e){if(!/^[A-Za-z0-9+/=_-]+$/.test(e))throw new RangeError("nonce contains characters CSP does not allow");return e}(t.nonce)}"`:""}>${e}<\/script>`};
1
+ "use strict";var e="2.0.6";function t(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).")}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 n="payload-live-preview-a11y",r=/* @__PURE__ */new WeakMap;function i(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}var o=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=r.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},r.set(e,t)),t.refs+=1,t}(e);const t=this.lease,o=t.element;if(o?.isConnected&&o.ownerDocument===e)return o;if(null!==o){const e=t.owned;i(t),e&&o.remove()}let s=e.getElementById(n);return t.owned=null===s,null===s&&(s=e.createElement("div"),s.id=n,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),s.setAttribute("style","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)),t.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`)}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 n=e.element;null!==n&&i(e),e.owned&&n?.remove(),e.element=null,r.delete(t)}say(e){const t=this.mount(),n=this.lease;if(null===t||null===n)return;let r=n.messageNode;r?.parentNode!==t?(r?.remove(),r=t.ownerDocument.createTextNode(t.hasChildNodes()?` ${e}`:e),n.messageNode=r,t.appendChild(r)):r.data=null===r.previousSibling?e:` ${e}`,null!==n.timer&&clearTimeout(n.timer);const o=setTimeout(()=>{n.timer===o&&n.element===t&&i(n)},1500);n.timer=o}};function s(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const e=a(n);e&&t.push(e)}return t}function a(e){if("object"!=typeof e||null===e)return;const t=e,n=t.name,r=t.type;if("string"!=typeof n||0===n.length)return;if("string"!=typeof r||0===r.length)return;const i=s(t.fields),o=function(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if("object"!=typeof n||null===n)continue;const e=n,r=e.slug;if("string"!=typeof r||0===r.length)continue;const i=s(e.fields);t.push({...e,slug:r,fields:i})}return t}(t.blocks),a={...t,name:n,type:r};return i.length>0?a.fields=i:delete a.fields,o.length>0?a.blocks=o:delete a.blocks,a}function l(e,t){return void 0===e||t(e)}function u(e,t){return null==e||t(e)}function d(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}var c=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],f={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"}},h=Object.keys(f);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 h)(i>=f[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 p(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function m(e,t){return e.generation===t.generation&&e.revision===t.revision}var g=class{matcher;handlers;boundListener=void 0;attachedTarget=void 0;generation=0;revision=0;queueHead=void 0;queueTail=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)}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&&!d(t.data))&&u(t.fieldSchemaJSON,e=>Array.isArray(e))&&u(t.globalSlug,e=>"string"==typeof e)&&u(t.collectionSlug,e=>"string"==typeof e)&&u(t.locale,e=>"string"==typeof e)&&u(t.ready,e=>"boolean"==typeof e)&&u(t.previewToken,e=>"string"==typeof e)&&u(t.protocolVersion,e=>"number"==typeof e)}(i)?void this.dispatchUpdate(function(e){const t={...e};for(const e of c)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);if(!Array.isArray(t.fieldSchemaJSON))return t;let n;try{n=s(t.fieldSchemaJSON)}catch{n=[]}return{...t,fieldSchemaJSON:n}}(i),r,t):void this.reportInvalid("shape",r,t);case"payload-document-event":return function(e){const t=e;return l(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&l(t.slug,e=>"string"==typeof e)&&l(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=d(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){void 0===r?this.invokeHandler(n,this.handlers.onUpdate,e,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{p(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 v(e){return(...t)=>{try{p(e(...t))}catch{}}}function y(){}var b=v((...e)=>console.error(...e)),w=v((...e)=>console.warn(...e)),S=v((...e)=>console.debug(...e)),A={"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'"},k=/* @__PURE__ */new Set;function T(e){k.has(e)||(k.add(e),w(`[live-preview] LP0104: this page carries the lean runtime, which leaves out ${e} (${A[e]}). The elements are left as the server rendered them. Remove \`runtime: LEAN_RUNTIME\` to get the full runtime.`))}function C(e){return"undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e){return!1!==e.enableA11y&&T("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 o(e.a11yLocale,n)}(e)}function $(e){if("undefined"==typeof window)return;const t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),g.sendReady(t,e)}function x(e){const t={};for(const[n,r]of Object.entries(e))void 0!==r&&(t[n]=r);return t}var R=/* @__PURE__ */new Set(["tabs","row","collapsible"]);function N(e,t=""){const n=/* @__PURE__ */new Map;return P(e,t,n),n}function P(e,t,n){for(const r of e){if(R.has(r.type)){r.fields&&P(r.fields,t,n);continue}const e=""===t?r.name:`${t}.${r.name}`;if(n.set(e,r),"group"===r.type)r.fields&&P(r.fields,e,n);else if("array"===r.type&&r.fields)P(r.fields,`${e}.*`,n);else if("blocks"===r.type&&r.blocks)for(const t of r.blocks)P(t.fields,`${e}.*.${t.slug}`,n)}}function E(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 F(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function L(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function M(e,t){return t.every(e=>void 0!==F(e))?function(e,t){const n=[],r=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=F(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=F(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 u=e[l];L(u)===L(s)?(l!==o&&n.push({kind:"move",from:l,to:o,value:s}),O(u,s)||n.push({kind:"update",index:o,value:s})):n.push({kind:"replace",index:o,oldValue:u,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)O(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 O(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 U={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"},I=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),_=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,j=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,D=/^[\\/]{2}/,z=/[\t\n\r]/g;function isSafeUrl(e){if("string"!=typeof e)return!1;const t=e.trim().replace(z,"");if(0===t.length)return!1;if(_.test(t))return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(D.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return I.has(e.protocol)}catch{return j.test(t)}}function isExternalHttpUrl(e){const t=e.trim().replace(z,"");return/^https?:\/\//i.test(t)||D.test(t)}var B=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),W=/* @__PURE__ */new Set(["href","src","poster","cite","action","xlink:href","data"]);function H(e){return!e.startsWith("on")&&!B.has(e)}function V(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function q(e,t,n,r){if(t.reportedUnfaithful.has(n.element))return;t.reportedUnfaithful.add(n.element),t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName);const i=e.onUnfaithfulPatch;"ignore"!==i&&("warn"!==i?(e.log("LP0411",n.fieldName,r),t.unfaithfulPatches.push(n)):e.warn(`[live-preview] LP0411: "${n.fieldName}" ${r}`))}function G(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}var K=/* @__PURE__ */new Set(["date","number","checkbox"]);function J(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function Z(e){const t=e.trim();return JSON.stringify(t.length>40?`${t.slice(0,40)}…`:t)}var X=/* @__PURE__ */new WeakSet;function Q(e){return X.add(e),e}function Y(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}}var ee=class{previous=null;diff(e,t){const n=this.previous,r=null===n,i=/* @__PURE__ */new Map,o=/* @__PURE__ */new Set;for(const[t,r]of Object.entries(e)){const e=Y(r);i.set(t,e),null!==n&&void 0!==e&&n.get(t)===e||o.add(t)}if(null!==n)for(const e of n.keys())i.has(e)||o.add(e);this.previous=i;const s=/* @__PURE__ */new Set;for(const[e,n]of Object.entries(t))if(o.has(e))for(const e of n)s.add(e);return{changed:o,invalidated:s,baseline:r}}reset(){this.previous=null}},te="data-payload-fragment";function ne(e){return e.closest(`[${te}]`)}function re(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==ne(e)?"fragment":null!==e.closest("head")?"route":"patch"}function ie(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function oe(e){return"string"==typeof e&&e.length>0}function se(e,t){return null!==t&&void 0!==e&&t.includes(e)}function ae(e){const t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}var le=/* @__PURE__ */new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function ue(e,t,n){const r=e.get(t);return void 0!==r&&(!1===n||r.some(e=>se(e.owner,n)))}function de(e,t,n){const r=`${t}.`;for(const[t,i]of e.entries())if(t.startsWith(r)){if(!1===n)return!0;if(i.some(e=>se(e.owner,n)))return!0}return!1}function ce(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 fe(e,t,n){let r;return i=>{if(ue(e,i,n))return!0;const o=ce(i,t);return!(o===i||!ue(e,o,n))||!!de(e,i,n)||!(o===i||!de(e,o,n))||(r??=function(e,t){const n=/* @__PURE__ */new Set;for(const[r,i]of e.entries())for(const e of i)(!1===t||se(e.owner,t))&&void 0!==e.locale&&n.add(`${r}_${e.locale}`);return n}(e,n),r.has(i))}}function he(e,t,n,r){const i=fe(e,n,r),o=[];for(const e of t)le.has(e)||i(e)||o.push(e);return o}var pe=/* @__PURE__ */new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),me={},ge=class{rawChanges=new ee;resolved=null;queued=null;pending=null;timer=null;openUntil=0;decide(e,t){const n=t.message.data??{},{changed:r}=this.rawChanges.diff(n,me);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(ye(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(`[${te}]`)}(e))return{merge:!1,fields:n};const i=this.resolved;if(null===i)return this.resolved=n,{merge:!0,fields:n};const o={...i};let s=t.forceRender;for(const a of r){const r=n[a];if(le.has(a)){o[a]=r;continue}const l=ve(a,i[a],r,e.cache,t.schemaIndex);"own"!==l&&(s=!0),"keep"!==l&&(o[a]=r)}return this.resolved=o,{merge:s,fields:o}}request(e,t,n){const r=Date.now();return r>=this.openUntil?(this.dropQueued(),this.openUntil=r+t,{leading:!0,result:e.merge(n)}):(this.queued=n,this.openUntil=r+t,this.pending??=function(){let e;return{promise:new Promise(t=>{e=t}),settle:e}}(),null!==this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush(e)},t),{leading:!1,result:this.pending.promise})}recordMerged(e){this.resolved=e}destroy(){this.dropQueued(),this.openUntil=0}dropQueued(){null!==this.timer&&clearTimeout(this.timer),this.timer=null,this.queued=null,this.pending?.settle({status:"superseded"}),this.pending=null}flush(e){const t=this.pending,n=this.queued;this.timer=null,this.pending=null,this.queued=null,null!==t&&null!==n&&e.merge(n).then(t.settle,()=>{t.settle({status:"unavailable"})})}};function ve(e,t,n,r,i){return be(n)?!be(t)||function(e,t,n){const r=void 0===n?void 0:E(n,e);return void 0!==r&&!pe.has(r.type)||!0===t.get(e)?.some(ye)||de(t,e,!1)}(e,r,i)?"keep":null==t?"ask":"own":"ask"}function ye(e){return!pe.has(e.fieldType)}function be(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function we(e){return!0===e?.includes(".")}var Se=class{negotiation=negotiateProtocol(void 0);observed=/* @__PURE__ */new Set;observe(e,t){const n=e.filter(e=>!this.observed.has(e));if(0!==n.length){for(const e of n)this.observed.add(e);this.negotiation=negotiateProtocol(this.negotiation.theirs,this.observed),t("protocol",`observed=${n.join(",")}`)}}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 Ae(e){return null!==e&&e.forceRender&&!e.completed}var ke=class{lastIdentity=void 0;edit(e){const t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;const n=JSON.stringify([t.entitySlug,ae(t),t.updatedAt]),r=n!==this.lastIdentity;return this.lastIdentity=n,r&&function(e,t){const n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;const r=ae(e),i=ae(t.data??{});return void 0!==r&&void 0!==i&&r!==i}(t,e)?t:null}};function Te(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var Ce=class{#e;reveal(e,t,n){return e===this.#e?"skipped-same":(this.#e=e,function(e,t){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:Te(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){this.#e=void 0}},$e=class{seen=/* @__PURE__ */new Map;note(e,t,n){const r=Y(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}},xe=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;warnedEscalationUnavailable=!1;warnedProtocolShape=!1;reportedUnfaithful=/* @__PURE__ */new WeakSet;checkedServerFormat=/* @__PURE__ */new WeakSet;unfaithfulPatches=[];unfaithfulCount=0;escalatedCount=0;unfaithfulFields=/* @__PURE__ */new Set;autoBindSearchMs=void 0;autoBindGuesses=null;warnedForeignSource=!1;lastAppliedIdentity=/* @__PURE__ */new WeakMap;revealLedger=new $e;fragmentStats={rendered:0,failed:0,superseded:0};routeStats={refreshes:0,failed:0,refused:0,loopStopped:0};fragmentController=null;routeController=null;routeRetry=null;routeRefreshOwed=!1;readyTimers=[];revealer=new Ce;changes=new ee;merges=new ge;protocol=new Se;relationships=new ke;isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){e.completed||(e.completed=!0,this.completedCount+=1)}abortStrategies(){null!==this.routeRetry&&(clearTimeout(this.routeRetry),this.routeRetry=null,this.routeRefreshOwed=!0);for(const e of["fragmentController","routeController"]){const t=this[e];null!==t&&(this[e]=null,t.abort())}}},Re=class{constructor(e,t){this.deps=e,this.state=t,this.instanceContext=x({renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,reportUnfaithful:(n,r)=>{q(e,t,n,r)}})}deps;state;instanceContext;apply(e){const{deps:t,state:n}=this,r=n.activeUpdate;if(null===r||void 0===e.revision||!m(r.revision,e.revision)||!n.isCurrent(r))return!1;const{target:i,value:o}=e,s=void 0!==r.schemaIndex?E(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(U,e))return U[e]}(t);if(void 0!==e)return e}return e.fieldType}(i,s?.type);"text"===l&&!0!==i.explicitFieldType&&function(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)}(o)&&(l="richText");try{a=t.resolveRenderer(l,i)}catch(e){return this.fail(r,e)}if(!n.isCurrent(r))return!1;const u=t.emitter.listenerCount("elementUpdate")>0,d=u?"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 f={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)}(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(!H(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 W.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}"`),!1}else{if(void 0===a)return t.log("no renderer for",l),q(t,n,i,`has no renderer for "${l}"`),!1;{const e=function(e,t,n,r){if("ignore"===e.onUnfaithfulPatch)return;if(void 0!==n.format||!K.has(r))return;if(t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);const i=J(n.element);return i.trim().length>0?i:void 0}(t,n,i,l),r=function(e,t,n,r){return e.render(t,n,r)}(a,i,o,f);if(!1===r&&function(e){return X.has(e.render)}(a))return q(t,n,i,`is a value ${a.name} cannot render`),!1;void 0!==e&&function(e,t,n){const r=J(t.element);r!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${Z(n)}, the patch wrote ${Z(r)} — 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)}}}catch(e){return this.fail(r,e)}if(!n.isCurrent(r))return!1;u&&t.emitter.emitWhile("elementUpdate",{element:i.element,fieldName:i.fieldName,previousValue:d,nextValue:o,revision:r.revision.revision,receivedAt:r.receivedAt,source:"patch"},()=>n.isCurrent(r));const h=n.isCurrent(r);return h&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(i.element,e.valueIdentity):n.lastAppliedIdentity.delete(i.element)),h}fail(e,t){if(!this.state.isCurrent(e))return!1;const n=t instanceof Error?t:new Error(String(t));return this.deps.emitter.emitWhile("error",{error:n,context:"renderer",code:"LP0603"},()=>this.state.isCurrent(e)),!1}};function Ne(...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 Pe(e,t){const n={};for(const r of t)r!==e&&(n[r]=[e]);return n}var Ee="payload-live-preview:update",Fe="data-payload-island",Le=`astro-island, [${Fe}]`;function Me(e){return"patch"===e.getAttribute(Fe)}function Oe(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(Fe)}(e)&&!Me(e)}function isInsideIsland(e){let t=e;for(;null!==t;){if(Oe(t))return!0;t=t.parentElement}return!1}var Ue="data-payload-field",Ie="data-payload-type",_e="data-payload-attribute",je="data-payload-href",De="data-payload-src",ze="data-payload-alt",Be="data-payload-array-template",We="data-payload-array-separator",He="data-payload-locale",Ve="data-payload-richtext",qe="data-payload-html",Ge="data-payload-array",Ke="data-payload-structural",Je="data-payload-owner",Ze="data-payload-depends",Xe="data-payload-strategy",Qe="data-payload-boundary",Ye="data-payload-guessed",et=[Ue,Ie,_e,je,De,ze,Be,We,He,Ve,qe,Ge,Ke,Je,Ze,Xe,Qe,"type"],tt=`[${Ue}]`,nt=`[${Je}]`;function rt(e){const t=e.closest(nt)?.getAttribute(Je);return null==t||0===t.length?void 0:t}var it=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,ot=/* @__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 st(e){return ot.has(e)||it.test(e)}var at=class{entriesByField=/* @__PURE__ */new Map;entryByElement=/* @__PURE__ */new WeakMap;filter;count=0;dependencies=null;islandRoots=[];constructor(e={}){this.filter=e.filter??ut}dependencyMap(){if(null!==this.dependencies)return this.dependencies;const e=[];for(const t of this.values())void 0!==t.dependsOn&&e.push(Pe(t.fieldName,t.dependsOn));return this.dependencies=Ne(...e),this.dependencies}get islands(){return this.islandRoots}buildFromRoot(e){const t=performance.now();this.clear();let n=0;for(const t of e.querySelectorAll(tt))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){const t=[];for(const n of e.querySelectorAll(Le))Me(n)||t.push(n);return t}(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=[]}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(Ue);if(null===t||0===t.length)return;const n=e.getAttribute(Ie),r=e.getAttribute(_e),i=e.getAttribute(je),o=e.getAttribute(De),s=e.getAttribute(ze),a=e.getAttribute(Be),l=e.getAttribute(We),u=e.getAttribute(He),d=e.getAttribute("data-payload-format"),c=rt(e),f=function(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}(e.getAttribute(Ze)),h=e.getAttribute(Xe),p=e.getAttribute(Ye),m=ne(e);return{element:e,fieldName:t,fieldType:lt(e),explicitFieldType:null!==n&&st(n),strategyKind:re(e)??"unknown",...null!==m?{fragmentBoundary:m}:{},...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!==u&&u.length>0?{locale:u}:{},...null!==d&&d.length>0?{format:d}:{},...void 0!==c?{owner:c}:{},...f.length>0?{dependsOn:f}:{},...null!==h&&h.length>0?{strategy:h}:{},...e.hasAttribute(Qe)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}};function lt(e){const t=e.getAttribute(Ie);if(null!==t&&st(t))return t;if(e.hasAttribute(Ve))return"richText";if(e.hasAttribute(qe))return"html";if(e.hasAttribute(Ke))return"structural-array";if(e.hasAttribute(Ge))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 ut(){return!0}function dt(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 ct(e){return dt(e,128)&&!e.includes("?")&&!e.includes("#")}var ft=class{serverURL;apiRoute;depth;fetchFn;log;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=v(e.log??y)}canMerge(e){return null!==this.endpointOf(e)}endpointOf(e){try{const n=e.globalSlug;if(n)return ct(n)?`globals/${encodeURIComponent(n)}`:null;const r=e.collectionSlug??"",i=e.data.id;return ct(r)&&("number"==typeof(t=i)?Number.isFinite(t):"string"==typeof t&&dt(t,512))?`${encodeURIComponent(r)}/${encodeURIComponent(String(i))}`:null}catch{return null}var t}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};const t=this.attempt+=1,n=this.inflight;this.inflight=null;let r=null;const i=()=>this.attempt!==t;try{if(n?.abort(),i())return{status:"superseded"};const t=this.endpointOf(e);if(null===t)return i()?{status:"superseded"}:{status:"unavailable"};const o=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===o)return{status:"unavailable"};r=new AbortController,this.inflight=r;const s=`${this.serverURL}${this.apiRoute}/${t}`,a=await o(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:JSON.stringify({data:e.data,depth:this.depth,flattenLocales:!1,locale:e.locale}),signal:r.signal});if(i())return{status:"superseded"};if(!a.ok)return this.log("merge HTTP",a.status,s),{status:"unavailable"};const l=await a.json();return i()?{status:"superseded"}:null===l||"object"!=typeof l||Array.isArray(l)?(this.log("merge invalid",s),{status:"unavailable"}):{status:"merged",doc:l}}catch(e){return i()?{status:"superseded"}:(this.log("merge exception",e),{status:"unavailable"})}finally{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}}},ht={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},pt={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},mt={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1};function detectProtocolProfile(e){return e.has("schema-json")?ht:e.has("document-events")||e.has("relationship-events")?pt:mt}var gt=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:[...et]})}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)||!function(e){for(const t of e){if("attributes"===t.type&&null!==t.attributeName&&et.includes(t.attributeName)&&(t.attributeName===Ue||t.attributeName===Je||1===t.target.nodeType&&t.target.hasAttribute(Ue)))return!0;for(const e of t.addedNodes)if(vt(e))return!0;for(const e of t.removedNodes)if(vt(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 vt(e){if(1!==e.nodeType)return!1;const t=e;return t.hasAttribute(Ue)||null!==t.querySelector(`[${Ue}]`)}var yt="[data-payload-field]";function bt(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewHydration??={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]}}function wt(){const e=bt();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{}const o=n?.containerInfo;void 0===e.onCommit?e.commits.push(o):e.onCommit(o)}}function St(e){e.committed=!0;const t=e.waiters;e.waiters=[];for(const e of t)e()}function At(e,t){const n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function kt(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,At(e,i),t("timed-out")},n),()=>{null!==r&&clearTimeout(r),r=null,At(e,i)}}var Tt="__vue_app__";function Ct(){if("undefined"==typeof window)return;const e=window;return e.__livePreviewVueHydration??={armed:!1,committed:!1,waiters:[]}}function $t(e){return Object.prototype.hasOwnProperty.call(e,Tt)?e[Tt]:void 0}function xt(){const e=Ct();if(void 0===e||e.armed)return;e.armed=!0;const t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,Tt)&&Object.defineProperty(t,Tt,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,Tt,{value:e,writable:!0,configurable:!0,enumerable:!0});const t=Ct();void 0===t||t.committed||null===this.querySelector(yt)||function(e,t){const n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?St(e):n.hook("app:suspense:resolve",()=>{e.committed||St(e)})}(t,e)}})}function Rt(e){if(void 0===e.hydration)return void e.startNow();const t=t=>{e.later(()=>{Nt(e,t)})},n="react"===e.hydration?function(e,t=5e3){wt();const n=bt();if(void 0===n)return null;if(void 0===n.onCommit){const e=e=>{!n.committed&&function(e){const t=e;return 9===t?.nodeType||null!=t?.querySelector?.(yt)}(e)&&St(n)};n.onCommit=e;for(const t of n.commits.splice(0))e(t)}return kt(n,e,t)}(t):function(e,t,n=5e3){xt();const r=Ct();return void 0===r?null:(!r.committed&&function(e){for(let t=e.querySelector(yt);null!==t;t=t.parentElement)if(void 0!==$t(t))return!0;return!1}(e)&&St(r),kt(r,t,n))}(e.root,t);null!==n?(e.defer(n),e.hydrated("waiting")):Nt(e,"committed")}function Nt(e,t){e.hydrated(t),"timed-out"===t&&e.warn(`[live-preview] LP0607: no ${"react"===e.hydration?"React commit":"Vue mount"} in ${String(5e3)} ms; started without waiting for hydration.`),e.startNow()}var Pt=class{timeoutMs;onTimeout;handle=null;lastKick=0;constructor(e){this.timeoutMs=e.timeoutMs??0,this.onTimeout=e.onTimeout}kick(){if(this.lastKick=Date.now(),this.timeoutMs<=0)return;null!==this.handle&&clearTimeout(this.handle);const e=setTimeout(()=>{this.handle===e&&(this.handle=null,this.onTimeout())},this.timeoutMs);this.handle=e}stop(){null!==this.handle&&(clearTimeout(this.handle),this.handle=null)}get lastKickAt(){return this.lastKick}get pending(){return null!==this.handle}},Et=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)}},Ft=/* @__PURE__ */new Set(["true","false","yes","no","on","off"]),Lt=/^[\d\s.,:+/-]+$/u,Mt=/^[a-z][a-z0-9_-]*$/u,Ot=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,Ut=/* @__PURE__ */new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]);function It(e,t=13){if("string"!=typeof e)return!1;const n=e.trim();return!(n.length<t||Lt.test(n)||Ft.has(n.toLowerCase())||Mt.test(n)||Ot.test(n))}function _t(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function jt(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(le.has(r))continue;const e=ce(r,t);if(It(o,n))i(o.trim(),e,!1);else if(_t(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))!le.has(t)&&It(r,n)&&i(r.trim(),`${e}.${t}`,!1)}return r}function Dt(e){if("http://www.w3.org/1999/xhtml"!==e.namespaceURI||Ut.has(e.tagName))return!0;if(e.hasAttribute(Ue)||e.hasAttribute("data-payload-no-bind")||e.hasAttribute("data-payload-owned")||Oe(e))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function zt(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 Bt(e){return H(e)&&!e.startsWith("data-payload-")&&"value"!==e}function Wt(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 Ht(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(Dt(n))continue;const e=zt(n),r=void 0===e?void 0:t.values.get(e);null==r||r.media||(Wt(t,n,r).text=r.field);for(const e of n.getAttributeNames()){if(!Bt(e))continue;const r=t.values.get(n.getAttribute(e)??"");null!=r&&(!r.media||"IMG"===n.tagName&&"src"===e)&&Wt(t,n,r).attributes.set(e,r)}Ht(n,t)}}function Vt(e,t,n){const r=e.tagName;if(void 0!==t){const i={[Ue]:t};if("A"===r){const e=n.get("href");void 0===e?i[Ie]="text":e!==t&&(i[je]=e)}return{element:e,fieldName:t,matched:zt(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:{[Ue]:t,...void 0!==r&&r!==t?{[ze]: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:{[Ue]:s,[_e]:o}}}function qt(e,t){const n={values:t,byElement:/* @__PURE__ */new Map,byField:/* @__PURE__ */new Map};t.size>0&&!Dt(e)&&Ht(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=Vt(e,n,o);void 0!==s&&i.push(s)}return i}function Gt(e){return 9===e.nodeType?e.body:e}function Kt(e,t,n,r){const i=[];for(const o of t){const{element:t}=o;if(!t.hasAttribute(Ue)&&(!1===n||se(rt(t),n))){for(const[e,n]of Object.entries(o.stamps))t.setAttribute(e,n);if(t.setAttribute(Ye,o.matched),void 0!==e.cache.add(t))e.observers.observeElement(t),e.log("autoBind",o.fieldName,"→",`<${t.tagName.toLowerCase()}>`,o.attribute??"text",JSON.stringify(o.matched),r),i.push(o);else{for(const e of Object.keys(o.stamps))t.removeAttribute(e);t.removeAttribute(Ye)}}}return i}var Jt=/* @__PURE__ */new Set(["__proto__","prototype","constructor"]);function Zt(e,t,n,r=!1){if(r&&void 0!==n){const r=Xt(e,`${t}_${n}`);if(void 0!==r)return r}const i=Xt(e,t);if(void 0!==i)return i;if(t.includes(".")){let n=e,r=!0;for(const e of t.split(".")){if(Jt.has(e)||null===n||"object"!=typeof n){r=!1;break}if(n=Xt(n,e),void 0===n){r=!1;break}}if(r)return n}return void 0===n?void 0:Xt(e,`${t}_${n}`)}function Xt(e,t){if(!Jt.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Qt(e,t,n,r){return Zt(e,n,t.locale??r,void 0!==t.locale)}function Yt(e,t,n,r){const i=Y(t);if(void 0===i)return;const o=[e.hrefField,e.srcField,e.altField];let s=i;for(const t of o){if(void 0===t||0===t.length)continue;const i=Y(Qt(n,e,t,r));if(void 0===i)return;s+=`|${t}=${i}`}return s}function en(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="${ce(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 tn(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function nn(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var rn="payload-live-preview",on=/* @__PURE__ */Symbol.for("payload-live-preview.trusted-types");function sn(){const e=globalThis,t=e[on];if(void 0!==t)return t;const n={};return e[on]=n,n}function an(e){const t=function(){const e=sn();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(rn,{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===t?e:t.createHTML(e)}var ln=/* @__PURE__ */new Set(["open","value","checked","selected"]);function un(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function dn(e){if(e.tagName.toLowerCase().includes("-"))return!0;if(e.hasAttribute(Fe)||e.hasAttribute("data-payload-owned"))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function cn(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!dn(e)&&!dn(t)}(e,t))return t;const r=mn(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||ln.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=un(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 u=e.firstChild,d=0;for(let t=0;t<l.length;t+=1){const i=l[t];let c=null,f=i instanceof Element?un(i,n):void 0;if(void 0!==f&&a.has(f)&&(f=void 0),void 0!==f){a.add(f);const e=r.get(f);if(void 0!==e&&!s.has(e)&&(c=fn(e,i,n)===e?e:null,null===c)){e.replaceWith(i),s.add(i),u=i.nextSibling;continue}}else{for(;d<o.length;){const r=o[d];if(d+=1,!s.has(r)){if(pn(r,i)){c=fn(r,i,n)===r?r:null,null===c&&(e.replaceChild(i,r),s.add(i),u=i.nextSibling);break}if(r instanceof Element){const n=l[t+1];if(!(i instanceof Element)||void 0!==n&&pn(r,n)){d-=1;break}e.replaceChild(i,r),s.add(i),u=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,r),s.add(i),u=i.nextSibling;break}}}if(null===c&&s.has(i))continue}const h=c??i;for(s.add(h);null!==u&&u!==h&&!s.has(u)&&hn(u);)u=u.nextSibling;h!==u&&e.insertBefore(h,u),u=h.nextSibling}for(const t of Array.from(e.childNodes))s.has(t)||t.remove()}(e,t,n),gn(r),e}function fn(e,t,n){return e instanceof Element&&t instanceof Element?dn(e)&&dn(t)?e:cn(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function hn(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function pn(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function mn(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 gn(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{}}var vn=/* @__PURE__ */new Set;function yn(e){vn.has(e)||(vn.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)":"List it in `allowedDataAttributes` if the page needs it, or set `sanitizerPolicy: 'compat'` to keep every `data-*` as 1.x did"}(e)}.`))}var bn=/* @__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"]),wn=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),Sn=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),An=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),kn="aria-",Tn="data-",Cn={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"])},$n=/* @__PURE__ */new Set(["href","src","cite","poster"]),xn=class extends Error{name="SanitizerEnvironmentError"},Rn=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"]),Nn="strict",Pn=/* @__PURE__ */Symbol.for("payload-live-preview.sanitizer-document");function sanitizeHtml(e,t){return En(e,void 0,t)}function En(e,t,n){const r=Fn();if(!r)throw"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new xn("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===e)return"";const i=function(e,t){const n=e?.policy??t??Nn;if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(Cn))e.set(t,n);return{allowedTags:bn,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:/* @__PURE__ */new Set}}const r=new Set(bn);if(e.additionalAllowedTags?.forEach(e=>r.add(e)),!0===e.allowFormControls)for(const e of wn)r.add(e);const i=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(Cn))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),o=r.createElement("template");return o.innerHTML=an(e),Ln(o.content,i),o.innerHTML}function Fn(){if("undefined"==typeof __INLINE_BUILD__||!__INLINE_BUILD__){const e=globalThis[Pn];if(e)return e}if("undefined"!=typeof document)return document}function Ln(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?Mn(n,t):8===n.nodeType&&n.remove()}function Mn(e,t){const n=e.tagName.toLowerCase();if(!Sn.has(n)||t.allowFormControls&&wn.has(n)){if(!t.allowedTags.has(n))return Ln(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&&Rn.has(i))continue;if("id"===i||"name"===i||i.startsWith("data-payload-")){e.removeAttribute(t.name),"name"===i&&!0!==r?.has(i)||yn(i);continue}if(i.startsWith(Tn)){n.allowedData.has(i)||(e.removeAttribute(t.name),yn(i));continue}if(An.has(i)||i.startsWith(kn))continue}else if(An.has(i)||i.startsWith(kn)||i.startsWith(Tn))continue;r?.has(i)?$n.has(i)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):"srcset"!==i||On(t.value)||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),Ln(e,t)}else e.remove()}function On(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))return!1}return!0}var Un=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),In=/[&<>"'/`=]/g;function escapeHtml(e){return e.replace(In,e=>Un[e])}var _n=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}),jn=/[&<>"']/g;function escapeHtmlAttribute(e){return e.replace(jn,e=>_n[e])}var Dn=/\{\{([\s\S]*?)\}\}/g;function zn(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 Bn(e,t,n,r,i){const o="object"==typeof t&&null!==t?t:null;return e.replace(Dn,(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 Wn(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(!H(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 Hn(e,t){for(const[n,r]of t)e.hasAttribute(n)||e.setAttribute(n,r)}function Vn(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 qn(e){return null==e||""===e}function Gn(e,t){const n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function Kn(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 Jn=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],Zn=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],Xn=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,Qn=/* @__PURE__ */new Map;function Yn(e){const t=Gn(Qn,e);if(void 0!==t)return t;const n=new Set(Jn);for(const t of e.matchAll(Xn)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const r={};for(const e of n)r[e]=Zn;const i={additionalAllowedTags:[...n],additionalAllowedAttributes:r,allowFormControls:!0,templateMode:!0};return Kn(Qn,e,i,64)}var er="data-payload-key",tr="data-payload-nested-key",nr="data-payload-nested-template";function rr(e){const t=or(e.container,e.patches,e);return null===t?null:sr(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function ir(e,t){return t.hasAttribute(tr)&&t.hasAttribute(nr)}function or(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),u=Wn(e),d=zn(i),c=Array.from(e.children),f=hr(c,er),h=/* @__PURE__ */new Set,p=[];for(let s=0;s<i.length;s+=1){const m=i[s],g=fr(m);let v=void 0===g?c[s]??null:pr(f,g)??null;null!==v&&h.has(v)&&(v=null),null!==v&&h.add(v);const y=t.replaces.has(s),b=o||t.renders.has(s)||null===v?mr(e.ownerDocument,r,m,s,a,u,d):void 0;if(null===b)return null;const w=void 0===b?[]:ar(y?null:v,b,m,void 0===g?void 0:l?.get(g),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 sr(e,t,n){const[r,i,o]=e,s=/* @__PURE__ */new Set;let a=!1;const l=mn(r);for(const[e,o,l,u,d]of i){let i=o;if(void 0!==l){const e=!(!n.morph||d||null===o)&&cn(o,l,{keyAttributes:[er,tr],retainChildrenOf:ir,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===o;if(!e)for(const[e,t]of u)null!==e&&(ur(e,t),t.replaceWith(e));for(const[,,e]of u)void 0!==e&&sr(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);gn(l);const u=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(r,t);u.clear();for(const e of o)cr(u,e);return a}function ar(e,t,n,r,i){const o=hr(null===e?[]:lr(e),tr),s=[];for(const e of lr(t)){const t=e.getAttribute(tr);if(null===t)continue;const a=pr(o,t)??null,l=e.getAttribute(nr),u=l?a:null,d=u?.getAttribute(nr)??null;let c;if(l){const o=dr(n,t);if(void 0!==o||null!==u){const n=o??[],s=M(null===u?[]:dr(r,t)??[],n),a=null!==u&&d!==l;if((s.length>0||a)&&(c=or(u??e,s,{template:l,nextItems:n,forceRender:a,store:i.store,sanitizerPolicy:i.sanitizerPolicy})??void 0,void 0===c))return null}}s.push([u,e,c])}return s}function lr(e){return Array.from(e.querySelectorAll(`[${tr}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(tr))return!1;n=n.parentElement}return n===e})}function ur(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 dr(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function cr(e,t){const n=fr(t);void 0!==n&&e.set(n,t)}function fr(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function hr(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 pr(e,t){return e.get(t)?.pop()}function mr(e,t,n,r,i,o,s){const a=En(Bn(t,n,r,Vn,s),i,Yn(t)),l=e.createElement("template");l.innerHTML=an(a);const u=l.content.firstElementChild;if(!u)return null;Hn(u,o);const d=fr(n);return void 0!==d&&u.setAttribute(er,d),u}function gr(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 vr(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`))}var yr=class{constructor(e,t,n){this.deps=e,this.state=t,this.host=n}deps;state;host;planFragments(e){const t=this.deps.strategies.fragment;return void 0===t?null:br(t,t.plan(this.deps.root,e))}escalateUnfaithful(e,t,n){if(e.routeRefreshed)return;const{fragment:r,route:i}=this.deps.strategies,o=void 0===r?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);if(void 0!==r&&void 0!==o)return this.state.escalatedCount+=n.length,e.pendingFragments+=o.length,void this.runFragments(e,t,br(r,o));void 0!==i?(this.state.escalatedCount+=n.length,this.refreshRoute(e,t,i)):this.warnEscalationUnavailable(n.length)}warnEscalationUnavailable(e){const{deps:t,state:n}=this;n.warnedEscalationUnavailable||(n.warnedEscalationUnavailable=!0,t.warn(`[live-preview] LP0808: onUnfaithfulPatch: 'escalate' has nowhere to go: ${String(e)} field(s) fell short and no route or fragment strategy is configured. Set routeStrategy: true or fragments: { endpoint }, or onUnfaithfulPatch: 'warn' to keep the patch and say so.`))}hasUnboundChange(e,t){const{deps:n,state:r}=this;if(e.baseline||e.routeRefreshed)return!1;const i=he(n.cache,e.touched,e.locale,t);let o=0;for(const e of i)G(r,e)&&(o+=1);const[s]=i;return void 0!==s&&"escalate"===n.onUnfaithfulPatch&&(void 0===n.strategies.route?(this.warnEscalationUnavailable(i.length),!1):(n.log("route","LP0807",`field "${s}" has no binding; refreshing the route`),r.escalatedCount+=o,!0))}hasRouteBinding(e){for(const[t,n]of this.deps.cache.entries())if(e.has(t)&&n.some(e=>"route"===e.strategyKind))return!0;return!1}async runFragments(e,t,n){const{deps:r,state:i}=this,o=new AbortController;i.fragmentController=o;const s=()=>i.isCurrent(e)&&!o.signal.aborted,{emitter:a}=r,{message:l}=e,u=e.revision.revision,d=e.receivedAt,c={root:r.root,revision:u,receivedAt:d,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof l.collectionSlug?l.collectionSlug:void 0,globalSlug:"string"==typeof l.globalSlug?l.globalSlug:void 0,signal:o.signal,isCurrent:s,log:(e,t)=>{r.log("fragment",e,t)},morph:(e,t)=>{!function(e,t){const n=e.ownerDocument.createElement("template");n.innerHTML=an(t);const r=e.cloneNode(!1);r.append(n.content),cn(e,r,{keyAttributes:[er]})}(e,t)},patch:n=>{this.patchFallback(e,t,n)},rendered:(t,n,r)=>{e.pendingFragments-=1,a.emitWhile("fragmentRender",{element:t,id:n,key:r,status:"rendered",revision:u,receivedAt:d},s)},failed:(t,n,i,o,l)=>{e.pendingFragments-=1;const c=`fragment "${n}" fell back to patch: ${l}`;r.log("fragment",o,c),a.emitWhile("error",{error:new Error(c),context:"fragment",code:o},s),a.emitWhile("fragmentRender",{element:t,id:n,key:i,status:"failed",code:o,revision:u,receivedAt:d},s)}};let f={rendered:0,failed:0,superseded:0};try{f=await n.strategy.render(c,n.boundaries)}catch(i){if(r.log("fragment","LP0801",i),s()){for(const r of n.boundaries)this.patchFallback(e,t,r);f={rendered:0,failed:n.boundaries.length,superseded:0}}}i.fragmentStats.rendered+=f.rendered,i.fragmentStats.failed+=f.failed,i.fragmentStats.superseded+=f.superseded,s()&&(i.fragmentController===o&&(i.fragmentController=null),e.pendingFragments=0,f.rendered>0&&this.host.restoreGuesses(e,t),0===r.scheduler.pendingCount&&i.complete(e),this.host.revealPending(e),s()&&0!==f.rendered&&0!==a.listenerCount("afterUpdate")&&a.emitWhile("afterUpdate",{data:t,updatedCount:f.rendered,durationMs:Date.now()-d,revision:u,receivedAt:d,source:"fragment"},s))}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)}armRouteRetry(e,t,n,r){const{state:i}=this;null!==i.routeRetry&&clearTimeout(i.routeRetry),i.routeRetry=setTimeout(()=>{i.routeRetry=null,i.isCurrent(e)&&this.runRoute(e,t,n)},r)}async runRoute(e,t,n){const{deps:r,state:i}=this,o=i.routeStats,s=new AbortController;i.routeController=s;const a=()=>i.isCurrent(e)&&!s.signal.aborted;let l;try{l=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:s.signal,isCurrent:a,log:(e,t)=>{r.log("route",e,t)},retryAfter:r=>{this.armRouteRetry(e,t,n,r)}})}catch(e){r.log("route","LP0801",e),l="failed"}if(a()){if(i.routeController===s&&(i.routeController=null),"refreshed"===l){if(o.refreshes+=1,i.lastAppliedIdentity=/* @__PURE__ */new WeakMap,this.host.restoreGuesses(e,t),this.host.rebuildCache(),!a())return;return this.host.reapply(e,t),void(r.emitter.listenerCount("afterUpdate")>0&&r.emitter.emitWhile("afterUpdate",{data:t,updatedCount:r.cache.elementCount,durationMs:Date.now()-e.receivedAt,revision:e.revision.revision,receivedAt:e.receivedAt,source:"route"},a))}"failed"===l?o.failed+=1:"refused"===l&&(o.refused+=1),this.host.reapply(e,t)}}warnFragmentFallback(e){gr(this.deps,this.state,e)}warnUnsupportedStrategy(e){vr(this.deps,this.state,e)}patchFallback(e,t,n){for(const[r,i]of this.deps.cache.entries())for(const o of i){if(o.fragmentBoundary!==n)continue;const i=Qt(t.fields,o,r,e.locale);void 0!==i&&this.deps.scheduler.schedule({target:o,value:this.host.transform(o,i,t.fields,()=>!0),allFields:t.fields,revision:e.revision,data:t})}}};function br(e,t){const n=new Set(t);return{boundaries:t,strategy:e,covers:e=>void 0!==e.fragmentBoundary&&n.has(e.fragmentBoundary)}}function wr(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=p(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 Sr=/* @__PURE__ */new Set,Ar=class{constructor(e,t,n){this.deps=e,this.state=t,this.strategies="undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?function(e,t){return{planFragments:()=>null,escalateUnfaithful:()=>{},hasUnboundChange:(n,r)=>{if(n.baseline)return!1;const i=he(e.cache,n.touched,n.locale,r);for(const e of i)G(t,e);return!1},hasRouteBinding:()=>!1,runFragments:()=>Promise.resolve(),refreshRoute:()=>(T("route refreshes"),Promise.resolve()),warnFragmentFallback:n=>{T("server-rendered fragments"),gr(e,t,n)},warnUnsupportedStrategy:n=>{vr(e,t,n)}}}(e,t):new yr(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,r,i)=>wr(e,t,n,r,i),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}})}deps;state;strategies;handleUpdate(e,t,n){const{deps:r,state:i}=this;if(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),void 0===e.data)return void(void 0!==e.protocolVersion&&i.protocol.applyVersion(e.protocolVersion,r.log));if(void 0===n)return;const o=i.relationships.edit(e);null!==o&&r.emitter.emit("relationshipUpdate",{detail:o,timestamp:Date.now()}),"string"==typeof e.locale&&(i.locale=e.locale),Array.isArray(e.fieldSchemaJSON)&&(i.schema=e.fieldSchemaJSON,i.schemaIndex=N(e.fieldSchemaJSON));const s={revision:n,message:e,locale:i.locale,schema:i.schema,schemaIndex:i.schemaIndex,receivedAt:Date.now(),forceRender:null!==o||Ae(i.activeUpdate),touched:/* @__PURE__ */new Set,baseline:!1,invalidated:/* @__PURE__ */new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1},a=i.activeUpdate;if(i.abortStrategies(),null===a||a.completed||(i.supersededCount+=1),i.activeUpdate=s,r.scheduler.acceptRevision(n),i.updateCount+=1,void 0===e.protocolVersion||(i.protocol.applyVersion(e.protocolVersion,r.log),i.isCurrent(s))){if(r.connection.markConnected()){if(r.a11y?.announceConnected(),r.emitter.emit("connect",{origin:t,timestamp:Date.now()}),!i.isCurrent(s))return;if(r.log("connection","disconnected","→","connected"),!i.isCurrent(s))return}this.processUpdate(s).catch(e=>{r.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,o=Ne(r.dependencies,r.cache.dependencyMap()),s=i.changes.diff(t.fields,o);if(s.baseline&&!n&&"off"!==r.autoBind)if("undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__)T("auto-binding");else{const n=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,r,i){const o=performance.now(),s=Gt(e.root),a=jt(n,r),l=null===s?[]:Kt(e,qt(s,a),i,"on the first message");t.autoBindGuesses=function(e,t){const n=/* @__PURE__ */new Set;for(const{fieldName:e,stamps:r}of t){n.add(e);for(const e of[je,ze]){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}}(a,l),t.autoBindSearchMs=performance.now()-o,l.length}(r,i,t.fields,e.locale,n)}e.baseline=s.baseline,e.invalidated=n?Sr:s.invalidated,e.touched=n?Sr:/* @__PURE__ */new Set([...s.changed,...s.invalidated]),this.scheduleAllFields(e,t)}async resolveIncomingFields(e){const{deps:t,state:n}=this,r=e.message.data??{};if(null===t.merger)return r;if("admin"===detectProtocolProfile(n.protocol.observed).populatesRelationships)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,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),a.doc):"superseded"===a.status?null:i.fields:null}async applyMerged(e,t){const{state:n}=this,r=await t;"merged"===r.status&&n.isCurrent(e)&&(n.merges.recordMerged(r.doc),this.applyFields(e,this.dataFor(e,r.doc),!0))}scheduleAllFields(e,t){const{deps:n,state:r}=this;if(!r.isCurrent(e))return;const i=()=>r.isCurrent(e),o=this.ownerKeysForUpdate(e,t.fields),{touched:s}=e,a=n.strategies.route,l=this.strategies.hasUnboundChange(e,o),u=r.routeRefreshOwed;if(void 0!==a&&!e.routeRefreshed&&(l||u||a.plan(n.root,s)||this.strategies.hasRouteBinding(s)))return r.routeRefreshOwed=!1,void this.strategies.refreshRoute(e,t,a);const d=this.strategies.planFragments(s),c=n.skipUnchanged;let f=0;for(const[s,a]of n.cache.entries()){if(!i())return;for(const l of a){if(!1!==o&&!se(l.owner,o))continue;if(!0===d?.covers(l)){if(n.revealEditedField){const n=Qt(t.fields,l,s,e.locale);r.revealLedger.note(e,l,n)}continue}const a=l.strategyKind??re(l.element)??"unknown";if("unknown"===a){this.strategies.warnUnsupportedStrategy(l);continue}"fragment"===a&&null===d&&this.strategies.warnFragmentFallback(l);const u=Qt(t.fields,l,s,e.locale);if(void 0===u){r.absentFields.add(s);continue}if(n.revealEditedField&&r.revealLedger.note(e,l,u),!i())return;const h=wr(n,l,u,t.fields,i);if(!i())return;const p=c?Yt(l,h,t.fields,e.locale):void 0,m=r.lastAppliedIdentity.get(l.element);if(!e.forceRender&&n.skipUnchanged&&void 0!==p&&m===p&&!e.invalidated.has(s)){r.skippedUnchangedCount+=1;continue}const g={target:l,value:h,allFields:t.fields,revision:e.revision,data:t,valueIdentity:p};n.scheduler.schedule(g),f+=1}}(function(e,t,n,r){const{cache:i}=e;if(0===i.fieldCount)return;if(!1!==r&&!function(e,t){for(const n of e.values())if(se(n.owner,t))return!0;return!1}(i,r))return;const o=fe(i,n,r);for(const[r,i]of Object.entries(t)){if(le.has(r))continue;if(tn(i)){en(e,o,r,n,i);continue}if(!nn(i)||o(r))continue;const t=ce(r,n);for(const[r,s]of Object.entries(i))tn(s)&&!le.has(r)&&en(e,o,`${t}.${r}`,n,s)}})({cache:n.cache,warned:r.warnedOrphanFields,warn:n.warn},t.fields,e.locale,o),null!==d&&d.boundaries.length>0&&(e.pendingFragments=d.boundaries.length,this.strategies.runFragments(e,t,d)),0===f&&0===e.pendingFragments&&(r.complete(e),this.revealPending(e),this.notifyIslands(e,t))}notifyIslands(e,t){0!==e.touched.size&&function(e,t){for(const n of e)n.dispatchEvent(new CustomEvent(Ee,{detail:t,bubbles:!1}));e.length}(this.deps.cache.islands,{fields:t.fields,revision:e.revision.revision,receivedAt:e.receivedAt,locale:e.locale})}restoreGuesses(e,t){const{deps:n,state:r}=this;if("off"!==n.autoBind&&null!==r.autoBindGuesses&&("undefined"==typeof __LEAN_BUILD__||!__LEAN_BUILD__)){const i=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,r,i){const o=t.autoBindGuesses,s=Gt(e.root);if(null===o||0===o.fields.size||null===s)return 0;const a=new Map(o.values);for(const[e,t]of jt(n,r)){if(null===t||!o.fields.has(t.field))continue;const n=a.get(e);void 0===n?a.set(e,t):n?.field!==t.field&&a.set(e,null)}Kt(e,qt(s,a),i,"after a server render").length}(n,r,t.fields,e.locale,i)}}ownerKeysForUpdate(e,t){const{deps:n,state:r}=this;if(!n.scopeBindingsByOwner)return!1;const{message:i}=e,o=function(e){if(oe(e.globalSlug))return[(t=e.globalSlug,`global:${t}`)];var t;if(!oe(e.collectionSlug))return null;const n=ie(e.collectionSlug);return oe(e.documentId)?[n,ie(e.collectionSlug,e.documentId)]:[n]}({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:ae(t)});return null!==o||r.warnedUnattributableMessage||(r.warnedUnattributableMessage=!0,n.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),o}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)||!m(o.revision,r))return;0===o.pendingFragments&&n.complete(o);const s=()=>n.isCurrent(o)&&m(o.revision,r);if(this.revealPending(o),!s())return;const a=n.unfaithfulPatches;a.length>0&&(n.unfaithfulPatches=[],void 0!==i&&this.strategies.escalateUnfaithful(o,i,a),!s())||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{this.revealBinding(t)}catch(e){this.deps.log("reveal",e)}}revealField(e){const t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":this.revealBinding(t)}revealBinding(e){const{element:t}=e,n=t.ownerDocument.defaultView;if(null===n)return"no-element";const r=`${e.owner??""} ${e.fieldName}`;return this.state.revealer.reveal(r,t,n)}},kr=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;frameToken=0;windowUntil=0;activeRevision=null;activeRevisionCancelled=!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(void 0!==e.revision){if(this.activeRevisionCancelled)return;if(null===this.activeRevision||!m(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;null!==this.activeRevision&&m(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.cancelScheduledWork(),this.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1)}cancelRevision(e){null!==this.activeRevision&&m(e,this.activeRevision)&&(this.cancelScheduledWork(),this.clearWork(),this.activeRevisionCancelled=!0)}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(){this.cancelScheduledWork(),this.clearWork(),this.activeRevision=null,this.activeRevisionCancelled=!1,this.windowUntil=0}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,null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1;const r=this.scheduleFrame(()=>{this.frameToken===e&&(n=!0,this.frameHandle=null,this.flush())});n||this.frameToken!==e||(this.frameHandle=r)}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);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&&m(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||(t=this.apply,!X.has(t));var t}retargetBuffer(e,t){const n=e.get(t.element);void 0!==n&&(n.target.fieldName===t.fieldName&&n.target.locale===t.locale?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(),null!==e&&clearTimeout(e),null!==t&&this.cancelFrame(t)}},Tr=[0,500,1e3,2e3],Cr=class{deps;state=new xe;pipeline;writer;rootSentinel=null;observedRoot=null;constructor(e){const{emitter:t,renderers:n}=e,r=void 0===e.log?y:v(e.log),i=void 0===e.warn?w:v(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 at({filter:e=>!isInsideIsland(e)}),a=new gt({onStructuralChange:()=>{this.rebuildCache()},onVisibilityChange:(e,t)=>{t&&l.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),l=new kr(Q(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)}}),u=new g(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],r),t.emit("documentSave",{timestamp:Date.now()})},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}:{}}),d=e.dataMerge;this.deps={emitter:t,cache:s,observers:a,scheduler:l,bus:u,connection:new Et,heartbeat:new Pt({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:n,resolveRenderer:e.resolveRenderer??(e=>n[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,root:o,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:/* @__PURE__ */(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??$,onHeartbeatTimeout:e.onHeartbeatTimeout,log:r,warn:i,a11y:C(e),merger:void 0===d?null:new ft({serverURL:d.serverURL,...void 0!==d.apiRoute?{apiRoute:d.apiRoute}:{},...void 0!==d.depth?{depth:d.depth}:{},...void 0!==d.fetchFn?{fetchFn:d.fetchFn}:{},log:r}),mergeWindowMs:e.debounceMs??50,scopeBindingsByOwner:!0===e.scopeBindingsByOwner,lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField,onUnfaithfulPatch:V(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new Re(this.deps,this.state),this.pipeline=new Ar(this.deps,this.state,()=>{this.rebuildCache()})}start(){const{state:e}=this;if(e.isRunning())return!1;e.started=!0,e.suspended=!1;try{return function(e){"react"===e.hydration?wt():"vue"===e.hydration&&xt();const{root:t}=e;if(!function(e){return 9===e.nodeType}(t)||"loading"!==t.readyState)return void Rt(e);const n=()=>{e.isRunning()&&e.later(()=>{Rt(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},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=$r(t.root)?xr(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()&&(t.bus.attach(),t.emitter.emitWhile("init",{timestamp:Date.now()},()=>e.isRunning()),e.isRunning()))for(const n of Tr){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,n&&t.emitter.emit("disconnect",{reason:"destroy",timestamp:Date.now()}),t.a11y?.detach(),t.emitter.emit("destroy",{timestamp:Date.now()})}release(){const{state:e,deps:t}=this;e.activeUpdate=null,e.started=!1;const n=e.deferredStart;e.deferredStart=null,null!==n&&this.runCleanup(n);for(const t of e.readyTimers)this.runCleanup(()=>{clearTimeout(t)});return e.readyTimers.length=0,this.runCleanup(()=>{t.heartbeat.stop()}),this.runCleanup(()=>{t.bus.detach()}),e.abortStrategies(),this.runCleanup(()=>{this.rootSentinel?.disconnect(),this.rootSentinel=null,this.observedRoot=null}),this.runCleanup(()=>{t.observers.stop()}),this.runCleanup(()=>{t.scheduler.destroy()}),this.runCleanup(()=>{t.merger?.destroy(),e.merges.destroy()}),t.cache.clear(),t.connection.markDisconnected()}rollbackFailedStart(){this.release(),this.runCleanup(()=>{this.deps.a11y?.detach()})}runCleanup(e){try{e()}catch(e){this.deps.log("cleanup failed:",e)}}refreshCache(){this.state.isRunning()&&(this.state.revealer.reset(),this.followReplacedRoot()||this.rebuildCache())}watchRootReplacement(){const{root:e}=this.deps;$r(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()||!$r(e))return!1;const t=xr(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=[],u=/* @__PURE__ */new Set,d=[];for(const[e,t]of r.entries()){l.push(e);for(const n of t)void 0!==n.owner&&u.add(n.owner),void 0!==n.guessed&&d.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},bindings:{elements:r.elementCount,fields:r.fieldCount,fieldNames:l.sort(),absentFields:[...n.absentFields].sort(),orphanFields:[...n.warnedOrphanFields].sort(),ownerScoped:t.scopeBindingsByOwner,owners:[...u].sort(),guessed:d.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;for(const e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),e.isRunning()){for(const e of t.cache.values()){const r=n.get(e.element);r?.fieldName===e.fieldName?t.scheduler.retarget(e):t.scheduler.forget(e.element),n.delete(e.element)}for(const e of n.values())t.scheduler.forget(e.element)}}onHeartbeatTimeout(){const{state:e,deps:t}=this;if(!e.isRunning())return;t.bus.advanceGeneration();const n=e.activeUpdate;e.activeUpdate=null,null!==n&&t.scheduler.cancelRevision(n.revision),t.merger?.destroy(),e.merges.destroy();const r=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}if(e.isRunning()){if(r&&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()}}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}};function $r(e){return 9===e.nodeType}function xr(e){return e.body}var EventEmitter=class{#t=/* @__PURE__ */new Map;#n=/* @__PURE__ */new Map;on(e,t){return this.#r(this.#t,e,t)}once(e,t){return this.#r(this.#n,e,t)}off(e,t){this.#i(this.#t,e,t),this.#i(this.#n,e,t)}async emit(e,t){await this.#o(e,t)}async emitWhile(e,t,n){return this.#o(e,t,n)}async#o(e,t,n){const r=()=>n?.()??!0;if(!r())return!1;const i=this.#t.get(e);if(i)for(const n of[...i]){if(!r())return!1;if(await this.#s(n,t,e),!r())return!1}if(!r())return!1;const o=this.#n.get(e);if(o&&o.size>0){const n=[...o];this.#n.delete(e);for(const i of n){if(!r())return!1;if(await this.#s(i,t,e),!r())return!1}}return r()}listenerCount(e){return(this.#t.get(e)?.size??0)+(this.#n.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#t.clear(),void this.#n.clear();this.#t.delete(e),this.#n.delete(e)}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#t.keys())e.add(t);for(const t of this.#n.keys())e.add(t);return[...e]}#r(e,t,n){let r=e.get(t);return r||(r=/* @__PURE__ */new Set,e.set(t,r)),r.add(n),()=>{this.#i(e,t,n)}}#i(e,t,n){const r=e.get(t);void 0!==r&&(r.delete(n),0===r.size&&e.delete(t))}async#s(e,t,n){try{await e(t)}catch(e){const t="string"==typeof n||"number"==typeof n?String(n):"<event>";b(`[live-preview] LP0601: handler for "${t}" threw:`,e)}}};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 Rr=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,Nr=/^https?:\/\/[^/?#\s]+$/i,Pr=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],OriginDetector=class{#a;constructor(e={}){const t=/* @__PURE__ */new Set;for(const n of e.additionalOrigins??[]){const e=Er(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.#a=[t,n,r,void 0!==n,void 0]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#a[4]?e===this.#a[4]:!!this.#a[0].has(e)||0===this.#a[0].size&&void 0!==this.#a[1]&&e===this.#a[1]||!(!this.#a[2]||!Rr.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#a[4]=e,!0)}unlockOrigin(){const e=this.#a[4];return this.#a[4]=void 0,e}get lockedOrigin(){return this.#a[4]}enumerate(){if(void 0!==this.#a[4])return[this.#a[4]];const e=new Set(this.#a[0]);if(0===this.#a[0].size&&void 0!==this.#a[1]&&e.add(this.#a[1]),this.#a[2])for(const t of Pr)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#a[3]}get isProductionUnconfigured(){return!(!isInIframe()||this.#a[0].size>0||this.#a[2]||void 0!==this.#a[1])}get isReferrerOnlyTrust(){return!(this.#a[0].size>0||this.#a[2]||void 0===this.#a[1])}};function Er(e){const t=e.trim();if(0!==t.length)try{const e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return;if(!Nr.test(e.origin))return;return e.origin}catch{return}}var Fr=()=>{},Lr=class{#l;#u;#d=/* @__PURE__ */new Set;#a="staging";constructor(e,t){this.#l=e,this.#u=t}assertOpen(){if("closed"===this.#a)throw new Error(`Plugin context for "${this.#l}" is no longer active`)}get active(){return"active"===this.#a}eligible(){return"closed"!==this.#a}own(e){return this.assertOpen(),this.#c({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.#c(r);if("active"===this.#a)try{this.#f(r)}catch(e){throw this.#h(r),e}return i}counts(){const e={transform:0,renderer:0,subscription:0,cleanup:0};for(const t of this.#d)e[t.kind]+=1;return e}commit(){if("staging"!==this.#a)throw new Error(`Plugin context for "${this.#l}" cannot be committed`);this.#a="committing";try{for(const e of this.#d)this.#f(e);this.#a="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#a){this.#a="closed";for(const e of[...this.#d].reverse())this.#h(e);this.#d.clear()}}#c(e){return this.#d.add(e),()=>{this.#h(e)}}#f(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;const t=e.acquire();e.cleanup=t??Fr}#h(e){if(e.disposed)return;e.disposed=!0,this.#d.delete(e);const t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{p(t())&&this.#u(`plugin "${this.#l}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#u(`plugin "${this.#l}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#u(`plugin "${this.#l}" cleanup failed:`,e)}}},Mr=class{#p;#m;#g=/* @__PURE__ */new Set;constructor(e,t){this.#p=e,this.#m=t}on(e,t){return this.#v("on",e,t)}once(e,t){return this.#v("once",e,t)}off(e,t){const n=t;for(const t of[...this.#g])t.event===e&&t.handler===n&&t.dispose()}emit(e,t){return this.#m.assertOpen(),this.#p.emit(e,t)}emitWhile(e,t,n){return this.#m.assertOpen(),this.#p.emitWhile(e,t,()=>{if(!this.#m.eligible())return!1;const e=n();return!!this.#m.eligible()&&e})}listenerCount(e){let t=0;for(const n of this.#g)n.event===e&&(t+=1);return t}removeAllListeners(e){for(const t of[...this.#g])void 0!==e&&t.event!==e||t.dispose()}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#g)e.add(t.event);return[...e]}#v(e,t,n){this.#m.assertOpen();const r=n,i=[...this.#g].find(n=>n.kind===e&&n.event===t&&n.handler===r);if(void 0!==i)return i.dispose;let o=Fr,s=!0;const a=async t=>{this.#m.active&&s&&("once"===e&&o(),await n(t))},l={kind:e,event:t,handler:r,dispose:Fr};return o=this.#m.stage("subscription",()=>this.#p[e](t,a),()=>{s=!1,this.#g.delete(l)}),l.dispose=o,this.#g.add(l),o}},Or=class{#p;#y;#b;#w;#u;#S=/* @__PURE__ */new Map;#A=/* @__PURE__ */new Map;#k=/* @__PURE__ */new Map;#T=/* @__PURE__ */new Set;#C=/* @__PURE__ */new Map;#$=Promise.resolve();#x=0;constructor(e){this.#p=e.events,this.#y=e.config,this.#b=e.registerFieldRenderer,this.#u=v(e.log);const t=e.onTransformError;this.#w=void 0===t?void 0:v((...e)=>{const n=e[0];try{return t(n)}catch(e){return void this.#u("transform error reporter failed:",e)}})}register(e){return this.#x>0?this.#R(e,!1):this.#N(()=>this.#R(e,!0))}unregister(e){return this.#x>0?this.#P(e,!1):this.#N(async()=>{await this.#P(e,!0)})}destroyAll(){return this.#x>0?this.#E(!1):this.#N(async()=>{await this.#E(!0)})}applyTransforms(e,t,n,r){const i=this.#C.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=p(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.#u(`transform for "${e}" failed:`,i),this.#w?.(i),t}}return o}list(){return[...this.#S.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.#A)e.push(t(n,void 0,"initializing",r.scope));for(const[n,r]of this.#S)e.push(t(n,r.plugin.version,"active",r.scope));for(const t of this.#k.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.#S.size}async#R(t,n){if(this.#S.has(t.name)||this.#A.has(t.name)||this.#k.has(t.name))return void this.#u(`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.#F(t.name,r);const i=new Lr(t.name,this.#u),o=this.#L(t.name,i),s={scope:i,cancelled:!1};this.#A.set(t.name,s);try{if(await this.#M(()=>t.init(o),n),s.cancelled)return;i.commit()}catch(e){return i.close(),void(s.cancelled||this.#u(`plugin "${t.name}" init failed:`,e))}finally{this.#A.get(t.name)===s&&this.#A.delete(t.name)}this.#S.set(t.name,{plugin:t,scope:i}),this.#u(`plugin "${t.name}" registered`)}#F(e,t){const n=`plugin "${e}" refused: ${t}`;this.#u(n),this.#p.emit("error",{error:new Error(n),context:"plugin",code:"LP0103"})}#L(e,t){return{events:new Mr(this.#p,t),registerFieldRenderer:e=>{t.stage("renderer",()=>{const t=this.#b(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.#C.get(e);return void 0===t?this.#C.set(e,[r]):t.push(r),()=>{r.active=!1;const t=this.#C.get(e);if(void 0===t)return;const n=t.indexOf(r);n>=0&&t.splice(n,1),0===t.length&&this.#C.delete(e)}})},registerCleanup:e=>{t.own(e)},getConfig:()=>this.#y,log:(...t)=>{this.#u(`[${e}]`,...t)}}}#P(e,t){const n=this.#A.get(e);if(void 0!==n)return n.cancelled=!0,n.scope.close(),Promise.resolve();const r=this.#k.get(e);if(void 0!==r)return this.#T.has(e)?Promise.resolve():t?this.#O(r):r;const i=this.#S.get(e);if(void 0===i)return Promise.resolve();this.#S.delete(e),i.scope.close();const o=Promise.resolve().then(()=>this.#U(e,i.plugin,t));return this.#k.set(e,o),o.then(()=>{this.#k.get(e)===o&&this.#k.delete(e)}),o}async#U(e,t,n){if(void 0!==t.destroy){this.#T.add(e);try{await this.#M(()=>t.destroy?.(),n)}catch(t){this.#u(`plugin "${e}" destroy failed:`,t)}finally{this.#T.delete(e)}}}async#E(e){for(const e of this.#A.values())e.cancelled=!0,e.scope.close();const t=[...this.#S.keys()];for(const n of t)await this.#P(n,e)}async#M(e,t){t?await this.#O(Promise.resolve().then(e)):await e()}async#O(e){this.#x+=1;try{await e}finally{this.#x-=1}}#N(e){const t=this.#$.then(e);return this.#$=t.catch(e=>{this.#u("plugin manager mutation failed:",e)}),t}},Ur=class{#I;#_;#j=/* @__PURE__ */new Map;constructor(e){this.#I=e,this.#_={...e}}get renderers(){return this.#_}resolve(e){return this.#_[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.#_[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.#I[t];void 0===a?Reflect.deleteProperty(this.#_,t):this.#_[t]=a}}},Ir={1:"left",2:"center",3:"right",4:"justify"},_r=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function jr(e){const t=e.format;return"string"==typeof t&&_r.has(t)?t:"number"==typeof t?Ir[t]:void 0}function Dr(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function zr(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function Br(e){const t=jr(e),n=Dr(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 Wr=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function Hr(e){return"object"==typeof e&&null!==e?e:void 0}function Vr(e){return Hr(e)}function qr(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function Gr(e){return"string"==typeof e&&e.length>0?e:void 0}function Kr(e){const t=Gr(e.title)??Gr(e.name)??Gr(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}var Jr=' target="_blank" rel="noopener noreferrer"',Zr=(e,t)=>{const n=t.renderChildren(e.children??[]),r=Hr(e.fields),i=function(e,t){if("internal"===t?.linkType)return function(e){const t=Hr(Hr(e)?.value),n=t?.url;if("string"==typeof n&&n.length>0)return n;const r=t?.slug;return"string"==typeof r&&r.length>0?`/${r}`:void 0}(t.doc);const n=t?.url??e.url;return"string"==typeof n&&n.length>0?n:void 0}(e,r);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 Jr;const r="string"==typeof e.target?e.target:"";return""===r?"":"_blank"===r?Jr:` target="${escapeHtml(r)}"`}(e,r,i)}${o}>${n}</a>`};function Xr(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=Xr(n);return t}function Qr(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function Yr(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var ei=/* @__PURE__ */new Map;function ti(e){return ei.get(e)}var ni=".lp-block:empty,.lp-inline-block:empty";function ri(e,t,n,r){const i=Hr(e.fields)??{},o="string"==typeof i.blockType?i.blockType:"",s=qr(o),a=""===s?r:`${r} ${r}--${s}`;if(""!==o){const e=ti(o)??ti(s);if(e)return e(i,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(o,a)}return`<${n} class="${a}"></${n}>`}function ii(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var oi={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${zr(e)}${Br(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",r=Wr.has(n)?n:"h2",i=t.renderChildren(e.children??[]);return`<${r}${zr(e)}${Br(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}${zr(e)}${Br(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"}"${Br(e)}>${n}</li>`;const r="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${zr(e)}${Br(e)}${r}>${n}</li>`},link:Zr,autolink:Zr,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${zr(e)}${Br(e)}>${n}</blockquote>`},code:e=>{const t=qr("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(Xr(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${qr(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=Vr(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${Qr(e)}><source src="${escapeHtmlAttribute(t)}"${Yr(e)}></video>`}(t,n):r.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${Yr(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}"${Qr(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=Hr(e.value),r=escapeHtml((n&&Kr(n))??`#${t}`),i=qr(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)=>ri(e,t,"div","lp-block"),inlineBlock:(e,t)=>ri(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${zr(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"':""}${ii("colspan",e.colSpan)}${ii("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${r}>`}},si=/* @__PURE__ */new Map,ai=!1;function li(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 ui(e,t={}){if(!li(e))return"";const n=function(e){const t={renderChildren:e=>{let n="";for(const r of e)n+=ci(r,t);return n},resolveAlignment:jr,resolveIndent:Dr,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==Fn()?sanitizeHtml(n):(function(){if(!ai){ai=!0;try{console.warn('[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; call setSanitizerDocument() (linkedom/jsdom) for server rendering, see "HTML sanitization" in docs/security.md.')}catch{}}}(),n)}function di(e){return li(e)?e.root.children.map(fi).join("\n").trim():""}function ci(e,t){const n=(r=e.type,si.get(r)??oi[r]);var r;return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function fi(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+=fi(n);return t}function hi(e="text"){const t=/* @__PURE__ */new WeakSet;return{name:e,render:/* @__PURE__ */Q((e,n)=>{const r=e.element,i=function(e){return null==e?"":li(e)?di(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e)}(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName)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),w(`[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=an(function(e){return escapeHtml(e).replace(/\r\n|\r|\n/g,"<br>")}(i)):r.textContent=i);r.value=i})}}var pi=/* @__PURE__ */new Set,mi=/* @__PURE__ */new Set,gi=/* @__PURE__ */new Set(["DIV","SECTION","ARTICLE"]),vi={name:"richText",render:/* @__PURE__ */Q((e,t,n)=>{const r=e.element;if(qn(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=an(En(o,i)))}if(li(t)){const o=/* @__PURE__ */new Map,s=function(e,t){const n=e.cloneNode(!1);n.innerHTML=an(t);const r=function(e,t){const n=e.firstElementChild;if(null!==n?.nextElementSibling||t.children.length<2)return null;if(!gi.has(n.tagName)||n.hasAttribute(Ue))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(ni);if(o.length>0&&null!==r.firstElementChild){const e=[];yi(r,n,e);for(const[t,n]of e)t.replaceWith(n),n.matches(ni)||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,En(ui(t,{sanitize:!1,onUnrenderedBlock:(e,t)=>{o.set(t,e)}}),i));for(const[t,r]of s){const i=o.get(t);void 0!==i&&bi(e,n,i,r)}return}if("string"!=typeof t)return!1;r.innerHTML=an(En(t,i))})};function yi(e,t,n){if(e.children.length!==t.children.length)return;let r=e.firstElementChild,i=t.firstElementChild;for(;null!==r&&null!==i;)i.matches(ni)?n.push([i,r]):yi(r,i,n),r=r.nextElementSibling,i=i.nextElementSibling}function bi(e,t,n,r){r&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);const i=r?mi:pi;i.has(n)||(i.add(n),w(`[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 wi={name:"html",render(e,t,n){if(qn(t))return void(e.element.textContent="");const r="string"==typeof t?t:Vn(t);e.element.innerHTML=an(En(r,n.sanitizerPolicy))}},Si=/* @__PURE__ */new WeakSet;function Ai(e,t,n){return"string"!=typeof n||0===n.length?{kind:"none"}:isSafeUrl(n)?{kind:"safe",url:n}:(Si.has(e)||(Si.add(e),w(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function ki(e,t=e=>e){return{name:e,render(e,n,r){const i=e.element;if(qn(n))return void function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(i);const o=Vn(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):Zt(r.allFields,n,r.locale,void 0!==e.locale),a=Ai(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 Ti=ki("url"),Ci=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,$i=ki("email",function(e){const t=e.trim();return Ci.test(t)||!t.includes("@")?t:`mailto:${t}`}),xi=["src","srcset","sizes"];function Ri(e){for(const t of xi)e.removeAttribute(t)}function Ni(e,t,n){e.src=t;const r=function(e){if(void 0===e?.sizes)return;const t=[];for(const n of Object.values(e.sizes))"string"==typeof n.url&&"number"==typeof n.width&&isSafeUrl(n.url)&&t.push(`${Pi(n.url)} ${String(n.width)}w`);return 0!==t.length?("number"==typeof e.width&&"string"==typeof e.url&&isSafeUrl(e.url)&&t.push(`${Pi(e.url)} ${String(e.width)}w`),t.join(", ")):void 0}(n);if(void 0===r)return e.removeAttribute("srcset"),void e.removeAttribute("sizes");e.setAttribute("srcset",r)}function Pi(e){return e.replace(/[\s,]/g,encodeURIComponent)}var Ei={name:"image",render:/* @__PURE__ */Q((e,t,n)=>{const r=e.element;if(qn(t))return void Fi(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?Zt(n.allFields,e.srcField,n.locale,r):t,o=Vr(i);return{media:o,candidate:void 0===o?i:o.url}}(e,t,n,i),a=Ai(r,e.fieldName,s);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===r.tagName){const t=r;Ni(t,a.url,o);const s=function(e,t,n,r,i){if(void 0!==t&&t.length>0){const e=Zt(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 Fi(r)})};function Fi(e){"IMG"===e.tagName?Ri(e):e.style.backgroundImage=""}var Li={name:"upload",render:/* @__PURE__ */Q((e,t)=>{const n=e.element;if(qn(t))return void Mi(n);const r=Vr(t);if(void 0===r)return!1;const i=Ai(n,e.fieldName,r.url);if("none"===i.kind)return!1;if("unsafe"===i.kind)return void Mi(n);const o=i.url;if("IMG"===n.tagName){const e=n;return Ni(e,o,r),void(void 0!==r.alt&&(e.alt=r.alt))}if("A"===n.tagName)return n.setAttribute("href",o),void(n.textContent=r.filename??o);const s=escapeHtml(r.filename??o);n.innerHTML=an(`<a href="${escapeHtmlAttribute(o)}">${s}</a>`)})};function Mi(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):Ri(e)}var Oi={name:"relationship",render(e,t){const n=e.element;if(qn(t))return n.removeAttribute("href"),void(n.textContent="");if("A"===n.tagName&&!Array.isArray(t)){const r=Ai(n,e.fieldName,Hr(t)?.url);"safe"===r.kind?n.setAttribute("href",r.url):"unsafe"===r.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(Ui).join(", "):Ui(t)}};function Ui(e){const t=Hr(e);return void 0===t?Vn(e):Kr(t)??""}var Ii={name:"select",render(e,t,n){const r=e.element,i=qn(t)?[]:function(e){return Array.isArray(e)?e.map(Vn):[Vn(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=Hr(t);if(void 0!==n&&Vn(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)}},_i=/* @__PURE__ */new Set(["","false","0","off","no"]),ji={name:"checkbox",render(e,t){const n=e.element,r=function(e){return"boolean"==typeof e?e:"string"==typeof e?!_i.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}},Di=/* @__PURE__ */new Map,zi=/* @__PURE__ */new Map;function Bi(e,t){const n=e??"";if(null==t)return n;const r=Wi(t);return"{}"===r?n:`${n}|${r}`}function Wi(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Wi(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)}:${Wi(n)}`)}return`{${r.join(",")}}`}var Hi=/* @__PURE__ */new Set(["short","medium","long","full"]),Vi=/* @__PURE__ */new Set(["short","medium","long","full"]),qi=/^[A-Za-z]{3}$/u,Gi=/^[0-4]$/u;function Ki(e){return{kind:"date",options:e}}function Ji(e){return{kind:"number",options:e}}var Zi=/* @__PURE__ */new WeakSet;function Xi(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?Ki({dateStyle:"medium"}):Hi.has(r)?Ki({dateStyle:r}):void 0;case"time":return void 0===r?Ki({timeStyle:"short"}):Vi.has(r)?Ki({timeStyle:r}):void 0;case"datetime":return void 0===r?Ki({dateStyle:"medium",timeStyle:"short"}):Hi.has(r)?Ki({dateStyle:r,timeStyle:"short"===r?"short":"medium"}):void 0;case"number":if(void 0===r)return Ji({});if(!Gi.test(r))return;return Ji({minimumFractionDigits:Number(r),maximumFractionDigits:Number(r)});case"currency":if(void 0===r||!qi.test(r))return;return Ji({style:"currency",currency:r.toUpperCase()});case"percent":return void 0===r?Ji({style:"percent"}):void 0;default:return}}(t);if(void 0!==i){if(i.kind===e)return i.options}else!function(e,t,n){Zi.has(e)||(Zi.add(e),w(`[live-preview] LP0408: data-payload-format="${n}" on "${t}" is not a known format; the default formatting was used. Known: date, date:short|medium|long|full, time, datetime, number, number:0-4, currency:XXX, percent.`))}(n,r,t)}var Qi={name:"date",render(e,t,n){const r=e.element;if(qn(t))return void("INPUT"===r.tagName?r.value="":(r.removeAttribute("datetime"),r.textContent=""));const i="number"==typeof t?t:Vn(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=Xi("date",t.format,t.element,t.fieldName)??Yi;try{return function(e,t){const n=Bi(e,t);return Gn(zi,n)??Kn(zi,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")}-${eo(t.getMonth()+1)}-${eo(t.getDate())}`,r=`${eo(t.getHours())}:${eo(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${r}`:"time"===e?r:t.toISOString()}(r.type,o):a}},Yi={dateStyle:"medium",timeStyle:"short"};function eo(e){return String(e).padStart(2,"0")}var to={name:"number",render(e,t,n){const r=e.element;if(qn(t))return void("INPUT"===r.tagName?r.value="":r.textContent="");const i="number"==typeof t?t:Number(Vn(t));Number.isNaN(i)?r.textContent=Vn(t):"INPUT"!==r.tagName?r.textContent=function(e,t,n){const r=t.locale??n.locale??detectInitialLocale(),i=Xi("number",t.format,t.element,t.fieldName);try{return function(e,t){const n=Bi(e,t);return Gn(Di,n)??Kn(Di,n,new Intl.NumberFormat(e,t),64)}(r,i).format(e)}catch{return String(e)}}(i,e,n):r.value=String(i)}},no={name:"array",render:/* @__PURE__ */Q((e,t,n)=>{const r=e.element;if(qn(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=zn(t);let r="";for(let i=0;i<t.length;i+=1)r+=Bn(e,t[i],i,Vn,n);return r}(i,t),o=n.sanitizerPolicy,s=Yn(i),a=Wn(r);r.innerHTML=an(En(e,o,s));for(const e of Array.from(r.children))Hn(e,a);return}r.textContent=t.map(Vn).join(e.arraySeparator??", ")})};function ro(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,n=/* @__PURE__ */new WeakMap,r=/* @__PURE__ */new WeakMap;return{name:"structural-array",render:/* @__PURE__ */Q((i,o,s)=>{const a=qn(o)?[]:o;if(!Array.isArray(a))return!1;const l=i.element,u=i.arrayTemplate;if(void 0===u||0===u.length)return function(e,t,n){e.has(t)||(e.add(t),w(`[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 d=e.get(l),c=io(l),f=M(d?.values??c.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e}),a),h=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)}(d,u,c);if(0===f.length&&!h)return e.set(l,{values:a.slice(),template:u,domSnapshot:c}),!1;!function(e,t,n,r,i){const o=i.map(oo),s=/* @__PURE__ */new Set,a=o.find(e=>!(void 0===e||!s.has(e)&&(s.add(e),1)));if(void 0!==a&&so(e,t,n,a),o.some(e=>void 0===e)&&ao(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(oo).filter(e=>void 0!==e)),s=o.some(e=>void 0!==e&&i.has(e));i.size>0&&!s&&ao(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,d?.values,a);const p=rr({template:u,container:l,patches:f,nextItems:a,store:r,forceRender:h,sanitizerPolicy:s.sanitizerPolicy,onDuplicateKey:(e,t)=>{so(n,e,i.fieldName,t)}});return null!==p&&(e.set(l,{values:a.slice(),template:u,domSnapshot:io(l)}),!!p&&void 0)})}}function io(e){return Array.from(e.children,e=>e.getAttribute(er))}function oo(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function so(e,t,n,r){ao(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${r}"; later ones pair by position. Make \`id\` unique per item.`)}function ao(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),w(`[live-preview] ${r}`))}var lo=/* @__PURE__ */new Map;function uo(e,t){return{name:e,render(){T(t)}}}function co(){const e=[vi,wi,Ti,$i,Ei,Li,Oi,Ii,{...Ii,name:"radio"},ji,Qi,to,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[uo("array","structural arrays"),uo("blocks","structural arrays")]:[no,{...no,name:"blocks"}]];return function(e=[]){const t={};for(const n of e)t[n.name]=n;for(const[e,n]of lo)t[e]=n;return Object.freeze(t)}([hi("text"),hi("textarea"),...e,..."undefined"!=typeof __LEAN_BUILD__&&__LEAN_BUILD__?[]:[ro()]])}var fo=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),ho=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"});function po(e){return void 0===e?void 0:!e}var LivePreviewClient=class{#D=new EventEmitter;#z;#B;#W;#S;#u;#H=!1;#V=!1;#q=!1;#G=null;constructor(e={}){const n=function(e){const t="v1"===e.defaults?ho:fo;return{...e,skipUnchanged:e.skipUnchanged??t.skipUnchanged,disableReferrerDetection:e.disableReferrerDetection??t.disableReferrerDetection,eventSourcePolicy:e.eventSourcePolicy??t.eventSourcePolicy,sanitizerPolicy:e.sanitizerPolicy??t.sanitizerPolicy}}(e),r=n.serverURL??"";t({defaults:e.defaults,serverURL:r,mergeDepth:n.mergeDepth});const i=n.debug??isDevMode();this.#u=i?(...e)=>{S("[live-preview]",...e)}:y,this.#z=new OriginDetector(x({additionalOrigins:n.allowedOrigins,enableReferrerDetection:po(n.disableReferrerDetection),enableLocalhostMatching:po(n.disableLocalhostMatching)})),this.#z.isProductionUnconfigured&&this.#u("no trusted origin could be detected — set allowedOrigins"),this.#B=new Ur(co()),this.#S=new Or({events:this.#D,config:Object.freeze({...n}),registerFieldRenderer:e=>this.#B.register(e),onTransformError:e=>{this.#D.emit("error",{error:e,context:"transform",code:"LP0602"})},log:this.#u}),this.#W=new Cr(x({root:n.root,renderers:this.#B.renderers,resolveRenderer:(e,t)=>n.resolveRenderer?.(e,t)??this.#B.resolve(e),renderRichText:n.renderRichText,sanitizerPolicy:n.sanitizerPolicy,transformValue:(e,t,n,r)=>this.#S.applyTransforms(e,t,n,r),originMatcher:e=>this.#z.matches(e),readyTargets:()=>this.#z.enumerate(),emitter:this.#D,dataMerge:""===r?void 0:x({serverURL:r,apiRoute:n.apiRoute,depth:n.mergeDepth,fetchFn:n.mergeFetch}),debounceMs:n.debounceMs,heartbeatMs:n.heartbeatMs,intersectionRootMargin:n.intersectionRootMargin,scopeBindingsByOwner:n.scopeBindingsByOwner,skipUnchanged:n.skipUnchanged,revealEditedField:n.revealEditedField,autoBind:n.autoBind,eventSourcePolicy:n.eventSourcePolicy,dependencies:n.dependencies,strategies:n.strategies,disableVisibilityGate:n.disableVisibilityGate,visibilityGateThreshold:n.visibilityGateThreshold,enableA11y:n.enableA11y,a11yLocale:n.a11yLocale,onHeartbeatTimeout:()=>{this.#z.unlockOrigin()},lockedOrigin:()=>this.#z.lockedOrigin,validateToken:n.validateToken,log:this.#u})),this.#D.on("connect",e=>{this.#z.lockOrigin(e.origin)}),!1!==n.autoStart&&this.start()}start(){if(this.#V)return!1;if(this.#H)return this.#W.start(),!0;if(!isInPreviewContext())return!1;const e=this.#W.start();return e&&(this.#H=!0),e}suspend(){return!(this.#V||!this.#H)&&this.#W.suspend()}resume(){return!(this.#V||!this.#H)&&this.#W.start()}destroy(){if(null!==this.#G)return this.#G;let e,t;this.#V=!0;const n=new Promise((n,r)=>{e=n,t=r});this.#G=n;const r=()=>{this.#D.removeAllListeners(),this.#q=!0};try{this.#W.destroy(),this.#S.destroyAll().finally(r).then(e,t)}catch(e){r(),t(e)}return n}async use(e){if(this.#V)throw new Error("LivePreviewClient: already destroyed");await this.#S.register(e)}async unuse(e){if(this.#q)throw new Error("LivePreviewClient: already destroyed");await this.#S.unregister(e)}refreshCache(){this.#W.refreshCache()}get events(){return this.#D}get plugins(){return this.#S.list()}get status(){return this.#W.status}inspect(){return{...this.#W.inspect(),plugins:this.#S.snapshot()}}get updateCount(){return this.#W.updateCount}get destroyed(){return this.#V}};function mo(e,t,n){if(0===t.length)return;const r={type:"payload-live-preview-focus",field:t};e.postMessage(r,n)}var go="__livePreviewRouteRefresh",vo=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",ProfileFeatureOmitted:"LP0104",OrphanField:"LP0201",UnattributableUpdate:"LP0202",UnboundField:"LP0203",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",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710"}),yo=/* @__PURE__ */['(()=>{function e(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function t(t){return(...n)=>{try{e(t(...n))}catch{}}}function n(){}function i(e){return e.onUnfaithfulPatch??("ignore"===e.onUnboundChange?"ignore":"escalate")}function r(e,t,n,i){if(t.reportedUnfaithful.has(n.element))return;t.reportedUnfaithful.add(n.element),t.unfaithfulCount+=1,t.unfaithfulFields.add(n.fieldName);let r=e.onUnfaithfulPatch;if("ignore"!==r){if("warn"===r){e.warn(`[live-preview] LP0411: "${n.fieldName}" ${i}`);return}e.log("LP0411",n.fieldName,i),t.unfaithfulPatches.push(n)}}function l(e,t){return!e.unfaithfulFields.has(t)&&(e.unfaithfulFields.add(t),e.unfaithfulCount+=1,!0)}function o(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:e.textContent}function a(e){let t=e.trim();return JSON.stringify(t.length>Ln?`${t.slice(0,Ln)}\\u2026`:t)}function s(){return function(){if(typ','eof document>"u")return;let e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}()??function(){if(typeof navigator>"u")return;let e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}()??"en"}function u(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}function d(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=c(n);e&&t.push(e)}return t}function c(e){if("object"!=typeof e||null===e)return;let t=e,n=t.name,i=t.type;if("string"!=typeof n||0===n.length||"string"!=typeof i||0===i.length)return;let r=d(t.fields),l=function(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if("object"!=typeof n||null===n)continue;let e=n,i=e.slug;if("string"!=typeof i||0===i.length)continue;let r=d(e.fields);t.push({...e,slug:i,fields:r})}return t}(t.blocks),o={...t,name:n,type:i};return r.length>0?o.fields=r:delete o.fields,l.length>0?o.blocks=l:delete o.blocks,o}function h(e,t){return void 0===e||t(e)}function f(e,t){return null==e||t(e)}function p(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}function m(e,t=[]){let n="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,i=Math.min(4,n??1),r=new Set(t),l=new Set;for(let e of Bn)(i>=Wn[e].since||r.has(e))&&l.add(e);return{ours:4,...void 0!==n?{theirs:n}:{theirs:void 0},negotiated:i,capabilities:l,observed:r}}function g(e,t){return e.generation===t.generation&&e.revision===t.revision}function v(e){return function(e){if(!1===e.enableA11y)return null;let t=e.root,n=void 0===t?void 0:function(e){return 9===e.nodeType}(t)?t:t.ownerDocument;return new jn(e.a11yLocale,n)}(e)}function y(e){if(typ','eof window>"u")return;let t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),zn.sendReady(t,e)}function b(e,t=""){let n=new Map;return w(e,t,n),n}function w(e,t,n){for(let i of e){if(Dn.has(i.type)){i.fields&&w(i.fields,t,n);continue}let e=""===t?i.name:`${t}.${i.name}`;if(n.set(e,i),"group"===i.type)i.fields&&w(i.fields,e,n);else if("array"===i.type&&i.fields)w(i.fields,`${e}.*`,n);else if("blocks"===i.type&&i.blocks)for(let t of i.blocks)w(t.fields,`${e}.*.${t.slug}`,n)}}function S(e,t){if(e.has(t))return e.get(t);let n=t.replace(/\\.\\d+(?=\\.|$)/g,".*");return e.has(n)?e.get(n):void 0}function T(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function k(e){if("object"!=typeof e||null===e)return;let t=e.blockType;return"string"==typeof t?t:void 0}function A(e,t){return t.every(e=>void 0!==T(e))?function(e,t){let n=[],i=new Map;for(let t=0;t<e.length;t+=1){let n=T(e[t]);void 0!==n&&i.set(n,t)}let r=new Set;for(let l=0;l<t.length;l+=1){let o=t[l],a=T(o);if(void 0===a){n.push({kind:"insert",index:l,value:o});continue}let s=i.get(a);if(void 0===s){n.push({kind:"insert",index:l,value:o});continue}r.add(s);let u=e[s];k(u)===k(o)?(s!==l&&n.push({kind:"move",from:s,to:l,value:o}),C(u,o)||n.push({kind:"update",index:l,value:o})):n.push({kind:"replace",index:l,oldValue:u,value:o})}for(let t=0;t<e.length;t+=1)r.has(t)||n.push({kind:"remove",index:t,value:e[t]});return n}(e,t):function(e,t){let n=[],i=Math.min(e.length,t.length);for(let r=0;r<i;r+=1)C(e[r],t[r])||n.push({kind:"update",index:r,value:t[r]});if(t.length>e.length)for(let i=e.length;i<t.length;i+=1)n.push({kind:"insert",index:i,value:t[i]});if(e.length>t.length)for(let i=t.length;i<e.length;i+=1)n.push({kind:"remove",index:i,value:e[i]});return n}(e,t)}function C(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;let n=e,i=t,r=Object.keys(n),l=Object.keys(i);if(r.length!==l.length)return!1;for(let e of r)if(!Object.is(n[e],i[e]))return!1;return!0}function $(e){if("string"!=typeof e)return!1;let t=e.trim().replace(Jn,"");if(0===t.length||Gn.test(t))return!1;if(t.startsWith("#")||t.startsWith("?")||Kn.test(t)||t.startsWith("/"))return!0;try{let e=new URL(t);return Hn.has(e.protocol)}catch{return qn.test(t)}}function R(e){let t=e.trim().replace(Jn,"");return/^https?:\\/\\//i.test(t)||Kn.test(t)}function F(e){return!e.startsWith("on")&&!Xn.has(e)}function N(e){return Zn.add(e),e}function x(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 M(e){return e.closest(`[${ei}]`)}function E(e){let t=e.getAttribute(ti);return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==M(e)?"fragment":null!==e.closest("head")?"route":"patch"}function O(e){return`global:${e}`}function P(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function L(e){return"string"==typeof e&&e.length>0}function U(e,t){return null!==t&&void 0!==e&&t.includes(e)}function I(e){let t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}function j(e,t,n){let i=e.get(t);return void 0!==i&&(!1===n||i.some(e=>U(e.owner,n)))}function _(e,t,n){let i=`${t}.`;for(let[t,r]of e.entries())if(t.startsWith(i)&&(!1===n||r.some(e=>U(e.owner,n))))return!0;return!1}function W(e,t){if(void 0===t||0===t.length)return e;let n=`_${t}`;return e.endsWith(n)?e.slice(0,-n.length):e}function B(e,t,n){let i;return r=>{if(j(e,r,n))return!0;let l=W(r,t);return!!(l!==r&&j(e,l,n)||_(e,r,n)||l!==r&&_(e,l,n))||(i??(i=function(e,t){let n=new Set;for(let[i,r]of e.entries())for(let e of r)!1!==t&&!U(e.owner,t)||void 0!==e.locale&&n.add(`${i}_${e.locale}`);return n}(e,n)),i.has(r))}}function z(e,t,n,i,r){return V(n)?!V(t)||function(e,t,n){let i=void 0===n?void 0:S(n,e);return void 0!==i&&!ii.has(i.type)||!0===t.get(e)?.some(D)||_(t,e,!1)}(e,i,r)?"keep":null==t?"ask":"own":"ask"}function D(e){return!ii.has(e.fieldType)}function V(e){return null===e||"object"!=typeof e&&"function"!=typeof e}function H(e){return!0===e?.includes(".")}function G(e){return null!==e&&e.forceRender&&!e.completed}function q(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function K(...e){let t=new Map;for(let n of e)for(let[e,i]of Object.entries(n)){let n=t.get(e);void 0===n&&(n=new Set,t.set(e,n));for(let e of i)n.add(e)}let n={};for(let[e,i]of t)n[e]=[...i];return n}function J(e,t){let n={};for(let i of t)i!==e&&(n[i]=[e]);return n}function X(e){return"patch"===e.getAttribute(fi)}function Q(e){return function(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(fi)}(e)&&!X(e)}function Z(e){let t=e.closest(Li)?.getAttribute(Fi);return null==t||0===t.length?void 0:t}function Y(e){return Ii.has(e)||Ui.test(e)}function ee(e){let t=e.getAttribute(gi);if(null!==t&&Y(t))return t;if(e.hasAttribute(Ai))return"richText";if(e.hasAttribute(Ci))return"html";if(e.hasAttribute(Ri))return"structural-array";if(e.hasAttribute($i))return"array";if("IMG"===e.tagName)return"image";if("A"===e.tagName)return"url";if("TIME"===e.tagName)return"date";if("INPUT"===e.tagName){let t=e.type;if("checkbox"===t)return"checkbox";if("number"===t)return"number";if("date"===t||"datetime-local"===t)return"date"}return"text"}function te(){return!0}function ne(e,t){return e.length>0&&e.length<=t&&"."!==e&&".."!==e&&!e.includes("/")&&!e.includes("\\\\")&&!function(e){for(let t of e){let e=t.codePointAt(0)??0;if(e<=31||127===e)return!0}return!1}(e)}function ie(e){return ne(e,128)&&!e.includes("?")&&!e.includes("#")}function re(e){return e.has("schema-json")?Bi:e.has("document-events")||e.has("relationship-events")?zi:Di}function le(e){if(e.nodeType!==Vi)return!1;let t=e;return t.hasAttribute(mi)||null!==t.querySelector(`[${mi}]`)}function oe(){if(typ','eof window>"u")return;let e=window;return e[Gi]??(e[Gi]={armed:!1,committed:!1,commits:[],onCommit:void 0,waiters:[]})}function ae(){let e=oe();if(void 0===e||e.armed)return;e.armed=!0;let t=window,n=t.__REACT_DEVTOOLS_GLOBAL_HOOK__??(t.__REACT_DEVTOOLS_GLOBAL_HOOK__=function(){let e=new Map;return{supportsFiber:!0,renderers:e,inject:t=>{let n=e.size+1;return e.set(n,t),n}}}()),i=n.onCommitFiberRoot;n.onCommitFiberRoot=function(t,n,...r){try{i?.call(this,t,n,...r)}catch{}let l=n?.containerInfo;void 0===e.onCommit?e.commits.push(l):e.onCommit(l)}}function se(e){e.committed=!0;let t=e.waiters;e.waiters=[];for(let e of t)e()}function ue(e,t){let n=e.waiters.indexOf(t);n>=0&&e.waiters.splice(n,1)}function de(e,t,n){if(e.committed)return null;let i=null,r=()=>{null!==i&&clearTimeout(i),i=null,t("committed")};return e.waiters.push(r),i=setTimeout(()=>{i=null,ue(e,r),t("timed-out")},n),()=>{null!==i&&clearTimeout(i),i=null,ue(e,r)}}function ce(){if(typ','eof window>"u")return;let e=window;return e[Ji]??(e[Ji]={armed:!1,committed:!1,waiters:[]})}function he(e){return Object.prototype.hasOwnProperty.call(e,Ki)?e[Ki]:void 0}function fe(){let e=ce();if(void 0===e||e.armed)return;e.armed=!0;let t=Element.prototype;void 0===Object.getOwnPropertyDescriptor(t,Ki)&&Object.defineProperty(t,Ki,{configurable:!0,get:()=>{},set(e){Object.defineProperty(this,Ki,{value:e,writable:!0,configurable:!0,enumerable:!0});let t=ce();void 0===t||t.committed||null===this.querySelector(qi)||function(e,t){let n=t?.$nuxt;!0!==n?.isHydrating||"function"!=typeof n.hook?se(e):n.hook(Xi,()=>{e.committed||se(e)})}(t,e)}})}function pe(e){if(void 0===e.hydration){e.startNow();return}let t=t=>{e.later(()=>{me(e,t)})},n="react"===e.hydration?function(e,t=5e3){ae();let n=oe();if(void 0===n)return null;if(void 0===n.onCommit){let e=e=>{!n.committed&&function(e){let t=e;return 9===t?.nodeType||null!=t?.querySelector?.(qi)}(e)&&se(n)};n.onCommit=e;for(let t of n.commits.splice(0))e(t)}return de(n,e,t)}(t):function(e,t,n=5e3){fe();let i=ce();return void 0===i?null:(!i.committed&&function(e){for(let t=e.querySelector(qi);null!==t;t=t.parentElement)if(void 0!==he(t))return!0;return!1}(e)&&se(i),de(i,t,n))}(e.root,t);null!==n?(e.defer(n),e.hydrated("waiting")):me(e,"committed")}function me(e,t){e.hydrated(t),"timed-out"===t&&e.warn(`[live-preview] LP0607: no ${"react"===e.hydration?"React commit":"Vue mount"} in ${String(5e3)} ms; started without waiting for hydration.`),e.startNow()}function ge(e,t=tr){if("string"!=typeof e)return!1;let n=e.trim();return!(n.length<t||ir.test(n)||nr.has(n.toLowerCase())||rr.test(n)||lr.test(n))}function ve(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function ye(e,t,n=tr){let i=new Map,r=(e,t,n)=>{i.set(e,i.has(e)?null:{field:t,media:n})};for(let[i,l]of Object.entries(e)){if(ni.has(i))continue;let e=W(i,t);if(ge(l,n))r(l.trim(),e,!1);else if(ve(l))if("string"==typeof l.url)r(l.url,e,!0);else if(!("id"in l)&&!("_id"in l))for(let[t,i]of Object.entries(l))ni.has(t)||!ge(i,n)||r(i.trim(),`${e}.${t}`,!1)}return i}function be(e){if(e.namespaceURI!==ar||or.has(e.tagName)||e.hasAttribute(mi)||e.hasAttribute(Yi)||e.hasAttribute(er)||Q(e))return!0;let t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function we(e){let t;for(let n=e.firstChild;null!==n;n=n.nextSibling){if(1===n.nodeType)return;if(3!==n.nodeType)continue;let e=n.data.trim();if(0!==e.length){if(void 0!==t)return;t=e}}return t}function Se(e){return F(e)&&!e.startsWith("data-payload-")&&"value"!==e}function Te(e,t,n){let i=e.byElement.get(t);void 0===i&&(i={attributes:new Map},e.byElement.set(t,i));let r=e.byField.get(n.field);return void 0===r&&(r=new Set,e.byField.set(n.field,r)),r.add(t),i}function ke(e,t){for(let n=e.firstElementChild;null!==n;n=n.nextElementSibling){if(be(n))continue;let e=we(n),i=void 0===e?void 0:t.values.get(e);null!=i&&!i.media&&(Te(t,n,i).text=i.field);for(let e of n.getAttributeNames()){if(!Se(e))continue;let i=t.values.get(n.getAttribute(e)??"");null!=i&&(i.media&&("IMG"!==n.tagName||"src"!==e)||Te(t,n,i).attributes.set(e,i))}ke(n,t)}}function Ae(e,t,n){let i=e.tagName;if(void 0!==t){let r={[mi]:t};if("A"===i){let e=n.get("href");void 0===e?r[gi]="text":e!==t&&(r[yi]=e)}return{element:e,fieldName:t,matched:we(e)??"",stamps:r}}if("IMG"===i){let t=n.get("src");if(void 0!==t){let i=n.get("alt");return{element:e,fieldName:t,matched:e.getAttribute("src")??"",attribute:"src",stamps:{[mi]:t,...void 0!==i&&i!==t?{[wi]:i}:{}}}}}let r=n.entries().next();if(r.done)return;let[l,o]=r.value;return{element:e,fieldName:o,matched:e.getAttribute(l)??"",attribute:l,stamps:{[mi]:o,[vi]:l}}}function Ce(e,t){let n={values:t,byElement:new Map,byField:new Map};t.size>0&&!be(e)&&ke(e,n);let i=e=>1===n.byField.get(e)?.size,r=[];for(let[e,t]of n.byElement){let n=void 0!==t.text&&i(t.text)?t.text:void 0,l=new Map;for(let[e,n]of t.attributes)i(n.field)&&l.set(e,n.field);let o=Ae(e,n,l);void 0!==o&&r.push(o)}return r}function $e(e){return 9===e.nodeType?e.body:e}function Re(e,t,n,i){let r=[];for(let l of t){let{element:t}=l;if(!t.hasAttribute(mi)&&(!1===n||U(Z(t),n))){for(let[e,n]of Object.entries(l.stamps))t.setAttribute(e,n);if(t.setAttribute(Ei,l.matched),void 0===e.cache.add(t)){for(let e of Object.keys(l.stamps))t.removeAttribute(e);t.removeAttribute(Ei);continue}e.observers.observeElement(t),e.log("autoBind",l.fieldName,"\\u2192",`<${t.tagName.toLowerCase()}>`,l.attribute??"text",JSON.stringify(l.matched),i),r.push(l)}}return r}function Fe(e,t,n,i=!1){if(i&&void 0!==n){let i=Ne(e,`${t}_${n}`);if(void 0!==i)return i}let r=Ne(e,t);if(void 0!==r)return r;if(t.includes(".")){let n=e,i=!0;for(let e of t.split(".")){if(sr.has(e)||null===n||"object"!=typeof n){i=!1;break}if(n=Ne(n,e),void 0===n){i=!1;break}}if(i)return n}return void 0===n?void 0:Ne(e,`${t}_${n}`)}function Ne(e,t){if(!sr.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function xe(e,t,n,i){return Fe(e,n,t.locale??i,void 0!==t.locale)}function Me(e,t,n,i){let r=x(t);if(void 0===r)return;let l=[e.hrefField,e.srcField,e.altField],o=r;for(let t of l){if(void 0===t||0===t.length)continue;let r=x(xe(n,e,t,i));if(void 0===r)return;o+=`|${t}=${r}`}return o}function Ee(e,t,n,i,r){let{warned:l,warn:o}=e;if(l.has(n)||t(n))return;l.add(n);let a=`data-payload-field="${W(n,i)}"`;o(""!==r?`[live-preview] LP0203: field "${n}" has a value and no <\\u2026 ${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 <\\u2026 ${a}> for the empty field "${n}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)}function Oe(e){let t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function Pe(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Le(e){let t=function(){let e=function(){let e=globalThis,t=e[dr];if(void 0!==t)return t;let n={};return e[dr]=n,n}();if(void 0!==e.override)return e.override;if(void 0!==e.auto)return e.auto;let t=function(){let e=globalThis.trustedTypes;return"object"!=typeof e||null===e?void 0:"function"==typeof e.createPolicy?e:void 0}();try{e.auto=void 0===t?null:t.createPolicy(ur,{createHTML:e=>e})}catch{e.auto=null}return e.auto}();return null===t?e:t.createHTML(e)}function Ue(e,t){for(let n of t.keyAttributes){let t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function Ie(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(fi)||e.hasAttribute(cr))return!0;let t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function je(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!Ie(e)&&!Ie(t)}(e,t))return t;let i=ze(e);return function(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||hr.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(let 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){let i=function(e,t){let n,i=new Map;for(let r of Array.from(e.children)){let e=Ue(r,t);if(void 0!==e){if(i.has(e)){n??(n=e.slice(e.indexOf("=")+1));continue}i.set(e,r)}}return void 0!==n&&t.onDuplicateKey?.(e,n),i}(e,n),r=new Set(i.values()),l=Array.from(e.childNodes).filter(e=>!r.has(e)),o=new Set,a=new Set,s=Array.from(t.childNodes),u=e.firstChild,d=0;for(let t=0;t<s.length;t+=1){let r=s[t],c=null,h=r instanceof Element?Ue(r,n):void 0;if(void 0!==h&&a.has(h)&&(h=void 0),void 0!==h){a.add(h);let e=i.get(h);if(void 0!==e&&!o.has(e)&&(c=_e(e,r,n)===e?e:null,null===c)){e.replaceWith(r),o.add(r),u=r.nextSibling;continue}}else{for(;d<l.length;){let i=l[d];if(d+=1,!o.has(i)){if(Be(i,r)){c=_e(i,r,n)===i?i:null,null===c&&(e.replaceChild(r,i),o.add(r),u=r.nextSibling);break}if(i instanceof Element){let n=s[t+1];if(!(r instanceof Element)||void 0!==n&&Be(i,n)){d-=1;break}e.replaceChild(r,i),o.add(r),u=r.nextSibling;break}if(!(r instanceof Element)){e.replaceChild(r,i),o.add(r),u=r.nextSibling;break}}}if(null===c&&o.has(r))continue}let f=c??r;for(o.add(f);null!==u&&u!==f&&!o.has(u)&&We(u);)u=u.nextSibling;f!==u&&e.insertBefore(f,u),u=f.nextSibling}for(let t of Array.from(e.childNodes))o.has(t)||t.remove()}(e,t,n),De(i),e}function _e(e,t,n){return e instanceof Element&&t instanceof Element?Ie(e)&&Ie(t)?e:je(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function We(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function Be(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function ze(e){let 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 De(e){if(null===e)return;let{element:t,selection:n}=e;if(t.ownerDocument.activeElement!==t&&t.isConnected)try{t.focus({preventScroll:!0});let[e,i]=n??[null,null];null!==e&&null!==i&&t.setSelectionRange(e,i)}catch{}}function Ve(e){fr.has(e)||(fr.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(pr)?"A binding inside CMS content is refused by design \\u2014 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 \\u2014 DOM clobbering, refused by design (docs/security.md)":"List it in `allowedDataAttributes` if the page needs it, or set `sanitizerPolicy: \'compat\'` to keep every `data-*` as 1.x did"}(e)}.`))}function He(e,t,n){let i=Ge();if(!i)throw new Error("sanitizeHtml needs a DOM");if(""===e)return"";let r=function(e,t){let n=e?.policy??t??Rr;if(!e){let e=new Map;for(let[t,n]of Object.entries(Tr))e.set(t,n);return{allowedTags:mr,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:n,allowedData:new Set}}let i=new Set(mr);if(e.additionalAllowedTags?.forEach(e=>i.add(e)),!0===e.allowFormControls)for(let e of gr)i.add(e);let r=new Map;for(let[e,t]of Object.entries(Tr))r.set(e,t);for(let[t,n]of Object.entries(e.additionalAllowedAttributes??{})){let e=new Set(r.get(t));for(let t of n)e.add(t);r.set(t,e)}return{allowedTags:i,attrByTag:r,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:n,allowedData:new Set(e.allowedDataAttributes?.map(e=>e.toLowerCase()))}}(n,t),l=i.createElement("template");return l.innerHTML=Le(e),qe(l.content,r),l.innerHTML}function Ge(){if(!(typ','eof document>"u"))return document}function qe(e,t){for(let n of Array.from(e.childNodes))n.nodeType===Ar?Ke(n,t):n.nodeType===Cr&&n.remove()}function Ke(e,t){let n=e.tagName.toLowerCase();!vr.has(n)||t.allowFormControls&&gr.has(n)?t.allowedTags.has(n)?(function(e,t,n){let i=n.attrByTag.get(t);for(let t of Array.from(e.attributes)){let r=t.name.toLowerCase();if(r.startsWith("on")||"style"===r)e.removeAttribute(t.name);else if("is"!==r){if("strict"===n.mode){if(n.templateMode&&$r.has(r))continue;if("id"===r||"name"===r||r.startsWith(Sr)){e.removeAttribute(t.name),("name"!==r||!0===i?.has(r))&&Ve(r);continue}if(r.startsWith(wr)){n.allowedData.has(r)||(e.removeAttribute(t.name),Ve(r));continue}if(yr.has(r)||r.startsWith(br))continue}else if(yr.has(r)||r.startsWith(br)||r.startsWith(wr))continue;i?.has(r)?(kr.has(r)&&!$(t.value)||"srcset"===r&&!Je(t.value))&&e.removeAttribute(t.name):e.removeAttribute(t.name)}else e.setAttribute("is","")}}(e,n,t),"a"===n&&function(e){let t=e.getAttribute("href");null===t||!R(t)||(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),qe(e,t)):(qe(e,t),e.replaceWith(...e.childNodes)):e.remove()}function Je(e){for(let t of e.split(",")){let e=t.trim();if(0===e.length)continue;let[n=e]=e.split(/\\s/,1);if(!$(n))return!1}return!0}function Xe(e){return e.replace(Nr,e=>Fr[e])}function Qe(e){return e.replace(Mr,e=>xr[e])}function Ze(e){let t=new Set;for(let n of e)if("object"==typeof n&&null!==n)for(let e of Object.keys(n))t.add(e);return t}function Ye(e,t,n,i,r){let l="object"==typeof t&&null!==t?t:null;return e.replace(Er,(e,o)=>null!==l&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(l,o)?Xe(i(Reflect.get(l,o))):null===l&&"value"===o?Xe(i(t)):"index"===o?String(n):null!==l&&!0===r?.has(o)?"":e)}function et(e){let t=e.children,n=t[0];if(void 0===n)return[];let i=[];for(let{name:e,value:r}of Array.from(n.attributes)){if(!F(e)||e.startsWith(Or))continue;let n=!0;for(let i=1;i<t.length&&n;i+=1)n=t[i]?.getAttribute(e)===r;n&&i.push([e,r])}return i}function tt(e,t){for(let[n,i]of t)e.hasAttribute(n)||e.setAttribute(n,i)}function nt(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 it(e){return null==e||""===e}function rt(e,t){let n=e.get(t);return void 0!==n&&(e.delete(t),e.set(t,n)),n}function lt(e,t,n,i){return e.set(t,n),function(e,t){for(let n of e.keys()){if(e.size<=t)break;e.delete(n)}}(e,i),n}function ot(e){let t=rt(jr,e);if(void 0!==t)return t;let n=new Set(Pr);for(let t of e.matchAll(Ur)){let e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}let i={};for(let e of n)i[e]=Lr;let r={additionalAllowedTags:[...n],additionalAllowedAttributes:i,allowFormControls:!0,templateMode:!0};return lt(jr,e,r,Ir)}function at(e){let t=ut(e.container,e.patches,e);return null===t?null:dt(t,e.store,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function st(e,t){return t.hasAttribute(Wr)&&t.hasAttribute(Br)}function ut(e,t,n){let i=function(e,t,n){let{template:i,nextItems:r,forceRender:l=!1,store:o,sanitizerPolicy:a}=n,s=o.get(e),u=et(e),d=Ze(r),c=Array.from(e.children),h=vt(c,_r),f=new Set,p=[];for(let o=0;o<r.length;o+=1){let m=r[o],g=gt(m),v=void 0===g?c[o]??null:yt(h,g)??null;null!==v&&f.has(v)&&(v=null),null!==v&&f.add(v);let y=t.replaces.has(o),b=l||t.renders.has(o)||null===v?bt(e.ownerDocument,i,m,o,a,u,d):void 0;if(null===b)return null;let w=void 0===b?[]:ct(y?null:v,b,m,void 0===g?void 0:s?.get(g),n);if(null===w)return null;p.push([o,v,b,w,y])}return p}(e,function(e){let t=new Set,n=new Set;for(let i of e)"insert"===i.kind||"update"===i.kind?t.add(i.index):"replace"===i.kind&&(t.add(i.index),n.add(i.index));return{renders:t,replaces:n}}(t),n);return null===i?null:[e,i,n.nextItems]}function dt(e,t,n){let[i,r,l]=e,o=new Set,a=!1,s=ze(i);for(let[e,l,s,u,d]of r){let r=l;if(void 0!==s){let e=!(!n.morph||d||null===l)&&je(l,s,{keyAttributes:[_r,Wr],retainChildrenOf:st,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===l;if(!e)for(let[e,t]of u)null!==e&&(ft(e,t),t.replaceWith(e));for(let[,,e]of u)void 0!==e&&dt(e,t,n);e?a=!0:(null!==l&&(l.replaceWith(s),a=!0),r=s)}if(null===r)continue;let c=i.children[e]??null;r!==c&&(i.insertBefore(r,c),a=!0),o.add(r)}for(let e of Array.from(i.children))o.has(e)||(e.remove(),a=!0);De(s);let u=function(e,t){let n=t.get(e);return n||(n=new Map,t.set(e,n)),n}(i,t);u.clear();for(let e of l)mt(u,e);return a}function ct(e,t,n,i,r){let l=vt(null===e?[]:ht(e),Wr),o=[];for(let e of ht(t)){let t=e.getAttribute(Wr);if(null===t)continue;let a,s=yt(l,t)??null,u=e.getAttribute(Br),d=u?s:null,c=d?.getAttribute(Br)??null;if(u){let l=pt(n,t);if(void 0!==l||null!==d){let n=l??[],o=A(null===d?[]:pt(i,t)??[],n),s=null!==d&&c!==u;if((o.length>0||s)&&(a=ut(d??e,o,{template:u,nextItems:n,forceRender:s,store:r.store,sanitizerPolicy:r.sanitizerPolicy})??void 0,void 0===a))return null}}o.push([d,e,a])}return o}function ht(e){return Array.from(e.querySelectorAll(`[${Wr}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(Wr))return!1;n=n.parentElement}return n===e})}function ft(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||e.removeAttribute(n.name);for(let n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function pt(e,t){if("object"!=typeof e||null===e)return;let n=e[t];return Array.isArray(n)?n:void 0}function mt(e,t){let n=gt(t);void 0!==n&&e.set(n,t)}function gt(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function vt(e,t){let n=new Map;for(let i=e.length-1;i>=0;i-=1){let r=e[i];if(void 0===r)continue;let l=r.getAttribute(t);if(null===l)continue;let o=n.get(l);void 0===o?n.set(l,[r]):o.push(r)}return n}function yt(e,t){return e.get(t)?.pop()}function bt(e,t,n,i,r,l,o){let a=He(Ye(t,n,i,nt,o),r,ot(t)),s=e.createElement("template");s.innerHTML=Le(a);let u=s.content.firstElementChild;if(!u)return null;tt(u,l);let d=gt(n);return void 0!==d&&u.setAttribute(_r,d),u}function wt(e,t){let n=new Set(t);return{boundaries:t,strategy:e,covers:e=>void 0!==e.fragmentBoundary&&n.has(e.fragmentBoundary)}}function St(t,n,i,r,l){let o=t.transformValue;if(void 0===o)return i;try{let t=o(n.fieldName,i,{element:n.element,allFields:r},l),a=e(t);if(!l())return i;if(a)throw new TypeError(`Transform for "${n.fieldName}" returned a thenable; transforms must be synchronous`);return t}catch(e){if(!l())return i;let n=e instanceof Error?e:new Error(String(e));return t.emitter.emit("error",{error:n,context:"transform",code:"LP0602"}),i}}function Tt(e){return 9===e.nodeType}function kt(e){return e.body}function At(){if(typ','eof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function Ct(e){let t=e.trim();if(0!==t.length)try{let e=new URL(t);return"http:"!==e.protocol&&"https:"!==e.protocol||!Jr.test(e.origin)?void 0:e.origin}catch{return}}function $t(e){let t=e.format;return"string"==typeof t&&el.has(t)?t:"number"==typeof t?Yr[t]:void 0}function Rt(e){let t=e.indent;return"number"==typeof t&&t>0?t:0}function Ft(e){return"rtl"===e.direction?\' dir="rtl"\':"ltr"===e.direction?\' dir="ltr"\':""}function Nt(e){let t=$t(e),n=Rt(e),i=[];return void 0!==t&&i.push(`lp-align-${t}`),n>0&&i.push(`lp-indent-${String(n)}`),0===i.length?"":` class="${i.join(" ")}"`}function xt(e){return"object"==typeof e&&null!==e?e:void 0}function Mt(e){return xt(e)}function Et(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function Ot(e){return"string"==typeof e&&e.length>0?e:void 0}function Pt(e){let t=Ot(e.title)??Ot(e.name)??Ot(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}function Lt(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(let n of e.children)t+=Lt(n);return t}function Ut(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function It(e){return"string"==typeof e.mimeType?` type="${Qe(e.mimeType)}"`:""}function jt(e){return rl.get(e)}function _t(e,t,n,i){let r=xt(e.fields)??{},l="string"==typeof r.blockType?r.blockType:"",o=Et(l),a=""===o?i:`${i} ${i}--${o}`;if(""!==l){let e=jt(l)??jt(o);if(e)return e(r,{renderChildren:t.renderChildren});t.onUnrenderedBlock?.(l,a)}return`<${n} class="${a}"></${n}>`}function Wt(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}function Bt(e){if("object"!=typeof e||null===e||!("root"in e))return!1;let t=e.root;return"object"==typeof t&&null!==t&&"children"in t&&Array.isArray(t.children)}function zt(e,t){let n=function(e){return al.get(e)??ol[e]}(e.type);return n?n(e,t):void 0!==e.children?t.renderChildren(e.children):""}function Dt(e){if("string"==typeof e.text)return e.text;if("linebreak"===e.type)return"\\n";if(void 0===e.children)return"";let t="";for(let n of e.children)t+=Dt(n);return t}function Vt(e="text"){let t=new WeakSet;return{name:e,render:N((e,n)=>{let i=e.element,r=function(e){return null==e?"":Bt(e)?function(e){return Bt(e)?e.root.children.map(Dt).join("\\n").trim():""}(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e)}(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName){if(function(e){return null!==e.querySelector(":scope > :not(br)")}(i)&&!i.hasAttribute(ul))return function(e,t,n){e.has(t)||(e.add(t),An(`[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,i,e.fieldName),!1;r.includes("\\n")||r.includes("\\r")?i.innerHTML=Le(function(e){return Xe(e).replace(/\\r\\n|\\r|\\n/g,"<br>")}(r)):i.textContent=r}else i.value=r})}}function Ht(e,t){let n=e.cloneNode(!1);n.innerHTML=Le(t);let i=function(e,t){let n=e.firstElementChild;if(null!==n?.nextElementSibling||t.children.length<2||!hl.has(n.tagName)||n.hasAttribute(mi))return null;for(let e of t.children)if(e.tagName===n.tagName&&e.className===n.className)return null;return n}(e,n)??e,r=new Map,l=n.querySelectorAll(ll);if(l.length>0&&null!==i.firstElementChild){let e=[];Gt(i,n,e);for(let[t,n]of e)t.replaceWith(n),n.matches(ll)||r.set(t.className,!1);for(let e of l)null!==e.parentNode&&r.set(e.className,!0)}return i.replaceChildren(...n.childNodes),r}function Gt(e,t,n){if(e.children.length!==t.children.length)return;let i=e.firstElementChild,r=t.firstElementChild;for(;null!==i&&null!==r;)r.matches(ll)?n.push([r,i]):Gt(i,r,n),i=i.nextElementSibling,r=r.nextElementSibling}function qt(e,t,n,i){i&&t.reportUnfaithful?.(e,`lost the markup the server drew for block "${n}"`);let r=i?cl:dl;r.has(n)||(r.add(n),An(`[live-preview] ${i?`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().`))}function Kt(e,t,n){return"string"!=typeof n||0===n.length?{kind:"none"}:$(n)?{kind:"safe",url:n}:(ml.has(e)||(ml.add(e),An(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function Jt(e,t=e=>e){return{name:e,render(e,n,i){let r=e.element;if(it(n)){!function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(r);return}let l=nt(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName){if("A"===r.tagName){let n=e.hrefField,o=void 0===n||0===n.length?t(l):Fe(i.allFields,n,i.locale,void 0!==e.locale),a=Kt(r,e.fieldName,o);"safe"===a.kind?r.setAttribute("href",a.url):"unsafe"===a.kind&&r.removeAttribute("href")}r.textContent=l}else r.value=l}}}function Xt(e){for(let t of bl)e.removeAttribute(t)}function Qt(e,t,n){e.src=t;let i=function(e){if(void 0===e?.sizes)return;let t=[];for(let n of Object.values(e.sizes))"string"!=typeof n.url||"number"!=typeof n.width||!$(n.url)||t.push(`${Zt(n.url)} ${String(n.width)}w`);return 0!==t.length?("number"==typeof e.width&&"string"==typeof e.url&&$(e.url)&&t.push(`${Zt(e.url)} ${String(e.width)}w`),t.join(", ")):void 0}(n);void 0!==i?e.setAttribute("srcset",i):(e.removeAttribute("srcset"),e.removeAttribute("sizes"))}function Zt(e){return e.replace(/[\\s,]/g,encodeURIComponent)}function Yt(e){"IMG"===e.tagName?Xt(e):e.style.backgroundImage=""}function en(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):Xt(e)}function tn(e){let t=xt(e);return void 0===t?nt(e):Pt(t)??""}function nn(e,t){let n=e??"";if(null==t)return n;let i=rn(t);return"{}"===i?n:`${n}|${i}`}function rn(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>rn(e)).join(",")}]`;let t=e,n=Object.keys(t).sort(),i=[];for(let e of n){let n=t[e];void 0!==n&&i.push(`${JSON.stringify(e)}:${rn(n)}`)}return`{${i.join(",")}}`}function ln(e){return{kind:"date",options:e}}function on(e){return{kind:"number",options:e}}function an(e,t,n,i){if(void 0===t||""===t)return;let r=function(e){let t=e.indexOf(":"),n=-1===t?e:e.slice(0,t),i=-1===t?void 0:e.slice(t+1);switch(n){case"date":return void 0===i?ln({dateStyle:"medium"}):Fl.has(i)?ln({dateStyle:i}):void 0;case"time":return void 0===i?ln({timeStyle:"short"}):Nl.has(i)?ln({timeStyle:i}):void 0;case"datetime":return void 0===i?ln({dateStyle:"medium",timeStyle:"short"}):Fl.has(i)?ln({dateStyle:i,timeStyle:"short"===i?"short":"medium"}):void 0;case"number":return void 0===i?on({}):Ml.test(i)?on({minimumFractionDigits:Number(i),maximumFractionDigits:Number(i)}):void 0;case"currency":return void 0!==i&&xl.test(i)?on({style:"currency",currency:i.toUpperCase()}):void 0;case"percent":return void 0===i?on({style:"percent"}):void 0;default:return}}(t);if(void 0!==r)return r.kind===e?r.options:void 0;!function(e,t,n){El.has(e)||(El.add(e),An(`[live-preview] LP0408: data-payload-format="${n}" on "${t}" is not a known format; the default formatting was used. Known: date, date:short|medium|long|full, time, datetime, number, number:0-4, currency:XXX, percent.`))}(n,i,t)}function sn(e){return String(e).padStart(2,"0")}function un(){let e=new WeakMap,t=new WeakSet,n=new WeakMap,i=new WeakMap;return{name:"structural-array",render:N((r,l,o)=>{let a=it(l)?[]:l;if(!Array.isArray(a))return!1;let s=r.element,u=r.arrayTemplate;if(void 0===u||0===u.length)return function(e,t,n){e.has(t)||(e.add(t),An(`[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,s,r.fieldName),!1;let d=e.get(s),c=dn(s),h=d?.values??function(e){return e.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e})}(c),f=A(h,a),p=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)}(d,u,c);if(0===f.length&&!p)return e.set(s,{values:a.slice(),template:u,domSnapshot:c}),!1;!function(e,t,n,i,r){let l=r.map(cn),o=new Set,a=l.find(e=>!(void 0===e||!o.has(e)&&(o.add(e),1)));if(void 0!==a&&hn(e,t,n,a),l.some(e=>void 0===e)&&fn(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.`),i?.length===r.length&&r.length>1){let r=new Set(i.map(cn).filter(e=>void 0!==e)),o=l.some(e=>void 0!==e&&r.has(e));r.size>0&&!o&&fn(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,s,r.fieldName,d?.values,a);let m=at({template:u,container:s,patches:f,nextItems:a,store:i,forceRender:p,sanitizerPolicy:o.sanitizerPolicy,onDuplicateKey:(e,t)=>{hn(n,e,r.fieldName,t)}});return null!==m&&(e.set(s,{values:a.slice(),template:u,domSnapshot:dn(s)}),!!m&&void 0)})}}function dn(e){return Array.from(e.children,e=>e.getAttribute(_r))}function cn(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function hn(e,t,n,i){fn(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${i}"; later ones pair by position. Make \\`id\\` unique per item.`)}function fn(e,t,n,i){let r=e.get(t);void 0===r&&(r=new Set,e.set(t,r)),!r.has(n)&&(r.add(n),An(`[live-preview] ${i}`))}function pn(){return typeof __LIVE_PREVIEW_CONFIG__>"u"?[]:__LIVE_PREVIEW_CONFIG__}var mn=Object.defineProperty,gn=e=>{throw TypeError(e)},vn=(e,t,n)=>((e,t,n)=>t in e?mn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),yn=(e,t,n)=>t.has(e)||gn("Cannot "+n),bn=(e,t,n)=>(yn(e,t,"read from private field"),n?n.call(e):t.get(e)),wn=(e,t,n)=>t.has(e)?gn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Sn=(e,t,n,i)=>(yn(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),Tn=(e,t,n)=>(yn(e,t,"access private method"),n),kn=t((...e)=>console.error(...e)),An=t((...e)=>console.warn(...e)),Cn=t((...e)=>console.debug(...e)),$n=class{constructor(){wn(this,Nn);wn(this,Rn,new Map);wn(this,Fn,new Map)}on(e,t){return Tn(this,Nn,Mn).call(this,bn(this,Rn),e,t)}once(e,t){return Tn(this,Nn,Mn).call(this,bn(this,Fn),e,t)}off(e,t){Tn(this,Nn,En).call(this,bn(this,Rn),e,t),Tn(this,Nn,En).call(this,bn(this,Fn),e,t)}async emit(e,t){await Tn(this,Nn,xn).call(this,e,t)}async emitWhile(e,t,n){return Tn(this,Nn,xn).call(this,e,t,n)}listenerCount(e){return(bn(this,Rn).get(e)?.size??0)+(bn(this,Fn).get(e)?.size??0)}removeAllListeners(e){void 0!==e?(bn(this,Rn).delete(e),bn(this,Fn).delete(e)):(bn(this,Rn).clear(),bn(this,Fn).clear())}eventNames(){let e=new Set;for(let t of bn(this,Rn).keys())e.add(t);for(let t of bn(this,Fn).keys())e.add(t);return[...e]}},Rn=new WeakMap,Fn=new WeakMap,Nn=new WeakSet,xn=async function(e,t,n){let i=()=>n?.()??!0;if(!i())return!1;let r=bn(this,Rn).get(e);if(r)for(let n of[...r])if(!i()||(await Tn(this,Nn,On).call(this,n,t,e),!i()))return!1;if(!i())return!1;let l=bn(this,Fn).get(e);if(l&&l.size>0){let n=[...l];bn(this,Fn).delete(e);for(let r of n)if(!i()||(await Tn(this,Nn,On).call(this,r,t,e),!i()))return!1}return i()},Mn=function(e,t,n){let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(n),()=>{Tn(this,Nn,En).call(this,e,t,n)}},En=function(e,t,n){let i=e.get(t);void 0!==i&&(i.delete(n),0===i.size&&e.delete(t))},On=async function(e,t,n){try{await e(t)}catch(e){let t="string"==typeof n||"number"==typeof n?String(n):"<event>";kn(`[live-preview] LP0601: handler for "${t}" threw:`,e)}},Pn=new Set(["date","number","checkbox"]),Ln=40,Un="payload-live-preview-a11y",In=new WeakMap,jn=class{constructor(e,t){vn(this,"german");vn(this,"document");vn(this,"lease",null);let n=t??(typ','eof document>"u"?null:document),i=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(i.length>0?i:s())),this.document=n}mount(){let e=this.document;if(null==e?.body)return null;this.lease??(this.lease=function(e){let t=In.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},In.set(e,t)),t.refs+=1,t}(e));let t=this.lease,n=t.element;if(n?.isConnected&&n.ownerDocument===e)return n;if(null!==n){let e=t.owned;u(t),e&&n.remove()}let i=e.getElementById(Un);return t.owned=null===i,null===i&&(i=e.createElement("div"),i.id=Un,i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),i.setAttribute("aria-atomic","true"),i.setAttribute("style","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(i)),t.element=i,i}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?"\\xc4nderung":"\\xc4nderungen"} angewendet`:`${String(e)} ${1===e?"change":"changes"} applied`)}detach(){let e=this.lease,t=this.document;if(null===e||null===t||(this.lease=null,e.refs-=1,e.refs>0))return;let n=e.element;null!==n&&u(e),e.owned&&n?.remove(),e.element=null,In.delete(t)}say(e){let 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);let r=setTimeout(()=>{n.timer===r&&n.element===t&&u(n)},1500);n.timer=r}},_n=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],Wn={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"}},Bn=Object.keys(Wn),zn=class{constructor(e,t){vn(this,"matcher");vn(this,"handlers");vn(this,"boundListener");vn(this,"attachedTarget");vn(this,"generation",0);vn(this,"revision",0);vn(this,"queueHead");vn(this,"queueTail");this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1,n=i=>{if(!t||this.boundListener!==n)return;let r=this.generation;try{this.receive(i,r,e)}catch{let e;try{e=i.origin}catch{e=""}this.reportInvalid("shape",e,r)}};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(){let 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)}static sendReady(e,t){let n={type:"payload-live-preview",ready:!0,protocolVersion:4};for(let i of e)for(let e of t)try{i.postMessage(n,e)}catch{}}receive(e,t,n){let i=e.origin;if(!this.matchesOrigin(i,t)){this.reportInvalid("origin",i,t);return}if(!this.matchesSource(e,n)){this.reportInvalid("source",i,t);return}let r=e.data;if(function(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type}(r))switch(r.type){case"payload-live-preview":if(!function(e){let t=e;return!(void 0!==t.data&&null!==t.data&&!p(t.data))&&f(t.fieldSchemaJSON,e=>Array.isArray(e))&&f(t.globalSlug,e=>"string"==typeof e)&&f(t.collectionSlug,e=>"string"==typeof e)&&f(t.locale,e=>"string"==typeof e)&&f(t.ready,e=>"boolean"==typeof e)&&f(t.previewToken,e=>"string"==typeof e)&&f(t.protocolVersion,e=>"number"==typeof e)}(r)){this.reportInvalid("shape",i,t);return}this.dispatchUpdate(function(e){let t={...e};for(let e of _n)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);if(!Array.isArray(t.fieldSchemaJSON))return t;let n;try{n=d(t.fieldSchemaJSON)}catch{n=[]}return{...t,fieldSchemaJSON:n}}(r),i,t);return;case"payload-document-event":if(!function(e){let t=e;return h(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&h(t.slug,e=>"string"==typeof e)&&h(t.id,e=>"string"==typeof e||Number.isFinite(e))}(r)){this.reportInvalid("shape",i,t);return}this.invokeHandler(t,this.handlers.onDocumentEvent,r,i);return;case"payload-live-preview-focus":{let e=function(e){let t=e.field;return"string"==typeof t&&t.length>0?t:void 0}(r);if(void 0===e){this.reportInvalid("shape",i,t);return}this.invokeHandler(t,this.handlers.onFocusField,e,i);return}default:this.reportInvalid("type",i,t)}else this.reportInvalid("shape",i,t)}dispatchUpdate(e,t,n){let i=p(e.data);if(!this.isCurrentGeneration(n))return;let r=i?{generation:n,revision:this.revision+=1}:void 0,l=this.handlers.validateToken;if(!this.isCurrentGeneration(n))return;if(void 0===l){this.commitUpdate(e,t,n,r);return}if(!0===e.ready&&void 0===e.data){this.commitUpdate(e,t,n,void 0);return}let o={generation:n,message:e,origin:t,messageRevision:r,verdict:void 0,next:void 0};this.enqueue(o);let a;try{a=l(e.previewToken,t)}catch{this.settleValidation(o,!1);return}"boolean"!=typeof a?Promise.resolve(a).then(e=>{this.settleValidation(o,!0===e)},()=>{this.settleValidation(o,!1)}):this.settleValidation(o,a)}settleValidation(e,t){e.verdict=t,this.drainQueue(e.generation)}drainQueue(e){for(;this.isCurrentGeneration(e);){let 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,i){void 0===i?this.invokeHandler(n,this.handlers.onUpdate,e,t):this.invokeHandler(n,this.handlers.onUpdate,e,t,i)}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{let n=e.source;if("object"!=typeof n||null===n)return!1;let i=t.parent;return i!==t&&n===i||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(t,n,...i){if(void 0!==n&&this.isCurrentGeneration(t))try{e(n(...i))}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}},Dn=new Set(["tabs","row","collapsible"]),Vn={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"},Hn=new Set(["http:","https:","mailto:","tel:"]),Gn=/^\\s*(?:javascript|data|vbscript|file|blob|about)\\s*:/i,qn=/^(?:\\.{1,2}\\/|[a-zA-Z0-9_-]+\\/?)/,Kn=/^[\\\\/]{2}/,Jn=/[\\t\\n\\r]/g,Xn=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),Qn=new Set(["href","src","poster","cite","action","xlink:href","data"]),Zn=new WeakSet,Yn=class{constructor(){vn(this,"previous",null)}diff(e,t){let n=this.previous,i=null===n,r=new Map,l=new Set;for(let[t,i]of Object.entries(e)){let e=x(i);r.set(t,e),(null===n||void 0===e||n.get(t)!==e)&&l.add(t)}if(null!==n)for(let e of n.keys())r.has(e)||l.add(e);this.previous=r;let o=new Set;for(let[e,n]of Object.entries(t))if(l.has(e))for(let e of n)o.add(e);return{changed:l,invalidated:o,baseline:i}}reset(){this.previous=null}},ei="data-payload-fragment",ti="data-payload-strategy",ni=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]),ii=new Set(["text","textarea","email","number","checkbox","date","select","radio","point","code","json","ui","html"]),ri={},li=class{constructor(){vn(this,"rawChanges",new Yn);vn(this,"resolved",null);vn(this,"queued",null);vn(this,"pending",null);vn(this,"timer",null);vn(this,"openUntil",0)}decide(e,t){let n=t.message.data??{},{changed:i}=this.rawChanges.diff(n,ri);if(!function(e){let{cache:t,emitter:n}=e;if(t.islands.length>0||n.listenerCount("beforeUpdate")>0||n.listenerCount("afterUpdate")>0)return!0;for(let e of t.values())if(D(e)||e.fieldName.includes(".")||H(e.hrefField)||H(e.srcField)||H(e.altField))return!0;return void 0!==e.strategies.fragment&&null!==e.root.querySelector(`[${ei}]`)}(e))return{merge:!1,fields:n};let r=this.resolved;if(null===r)return this.resolved=n,{merge:!0,fields:n};let l={...r},o=t.forceRender;for(let a of i){let i=n[a];if(ni.has(a)){l[a]=i;continue}let s=z(a,r[a],i,e.cache,t.schemaIndex);"own"!==s&&(o=!0),"keep"!==s&&(l[a]=i)}return this.resolved=l,{merge:o,fields:l}}request(e,t,n){let i=Date.now();return i>=this.openUntil?(this.dropQueued(),this.openUntil=i+t,{leading:!0,result:e.merge(n)}):(this.queued=n,this.openUntil=i+t,this.pending??(this.pending=function(){let e;return{promise:new Promise(t=>{e=t}),settle:e}}()),null!==this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.flush(e)},t),{leading:!1,result:this.pending.promise})}recordMerged(e){this.resolved=e}destroy(){this.dropQueued(),this.openUntil=0}dropQueued(){null!==this.timer&&clearTimeout(this.timer),this.timer=null,this.queued=null,this.pending?.settle({status:"superseded"}),this.pending=null}flush(e){let t=this.pending,n=this.queued;this.timer=null,this.pending=null,this.queued=null,null!==t&&null!==n&&e.merge(n).then(t.settle,()=>{t.settle({status:"unavailable"})})}},oi=class{constructor(){vn(this,"negotiation",m(void 0));vn(this,"observed",new Set)}observe(e,t){let n=e.filter(e=>!this.observed.has(e));if(0!==n.length){for(let e of n)this.observed.add(e);this.negotiation=m(this.negotiation.theirs,this.observed),t("protocol",`observed=${n.join(",")}`)}}applyVersion(e,t){let n=this.negotiation;if(n.theirs===e)return;let i=m(e,this.observed);this.negotiation=i,i.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${i.negotiated}`)}},ai=class{constructor(){vn(this,"lastIdentity")}edit(e){let t=e.externallyUpdatedRelationship;if("object"!=typeof t||null===t)return null;let n=JSON.stringify([t.entitySlug,I(t),t.updatedAt]),i=n!==this.lastIdentity;return this.lastIdentity=n,i&&function(e,t){let n=t.globalSlug??t.collectionSlug;if("string"!=typeof n||e.entitySlug!==n)return!0;let i=I(e),r=I(t.data??{});return void 0!==i&&void 0!==r&&i!==r}(t,e)?t:null}},si=class{constructor(){wn(this,ui)}reveal(e,t,n){return e===bn(this,ui)?"skipped-same":(Sn(this,ui,e),function(e,t){return function(e,t){let n=e.getBoundingClientRect(),i=n.bottom>0&&n.top<t.innerHeight,r=n.right>0&&n.left<t.innerWidth;return i&&r}(e,t)?"already-visible":(e.scrollIntoView({behavior:q(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){Sn(this,ui,void 0)}},ui=new WeakMap,di=class{constructor(){vn(this,"seen",new Map)}note(e,t,n){let i=x(n);if(void 0===i)return;let r=`${t.owner??""}\\0${t.locale??""}\\0${t.fieldName}`,l=this.seen.get(r);void 0!==l?l!==i&&(e.revealIdentities.push([r,i]),e.revealTarget??(e.revealTarget=t)):this.seen.set(r,i)}commit(e){for(let[t,n]of e.revealIdentities)this.seen.set(t,n);e.revealIdentities=[];let t=e.revealTarget;return e.revealTarget=void 0,t}},ci=class{constructor(){vn(this,"started",!1);vn(this,"suspended",!1);vn(this,"deferredStart",null);vn(this,"hydration","idle");vn(this,"activeUpdate",null);vn(this,"locale");vn(this,"schema");vn(this,"schemaIndex");vn(this,"updateCount",0);vn(this,"supersededCount",0);vn(this,"completedCount",0);vn(this,"skippedUnchangedCount",0);vn(this,"lastFlush",null);vn(this,"absentFields",new Set);vn(this,"warnedOrphanFields",new Set);vn(this,"warnedStrategy",new WeakSet);vn(this,"warnedUnattributableMessage",!1);vn(this,"warnedVisibilityGate",!1);vn(this,"warnedFragmentFallback",!1);vn(this,"warnedEscalationUnavailable",!1);vn(this,"warnedProtocolShape",!1);vn(this,"reportedUnfaithful",new WeakSet);vn(this,"checkedServerFormat",new WeakSet);vn(this,"unfaithfulPatches",[]);vn(this,"unfaithfulCount",0);vn(this,"escalatedCount",0);vn(this,"unfaithfulFields",new Set);vn(this,"autoBindSearchMs");vn(this,"autoBindGuesses",null);vn(this,"warnedForeignSource",!1);vn(this,"lastAppliedIdentity",new WeakMap);vn(this,"revealLedger",new di);vn(this,"fragmentStats",{rendered:0,failed:0,superseded:0});vn(this,"routeStats",{refreshes:0,failed:0,refused:0,loopStopped:0});vn(this,"fragmentController",null);vn(this,"routeController",null);vn(this,"routeRetry",null);vn(this,"routeRefreshOwed",!1);vn(this,"readyTimers",[]);vn(this,"revealer",new si);vn(this,"changes",new Yn);vn(this,"merges",new li);vn(this,"protocol",new oi);vn(this,"relationships",new ai)}isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){e.completed||(e.completed=!0,this.completedCount+=1)}abortStrategies(){null!==this.routeRetry&&(clearTimeout(this.routeRetry),this.routeRetry=null,this.routeRefreshOwed=!0);for(let e of["fragmentController","routeController"]){let t=this[e];null!==t&&(this[e]=null,t.abort())}}},hi=class{constructor(e,t){vn(this,"deps",e);vn(this,"state",t);vn(this,"instanceContext");this.instanceContext=function(e){let t={};for(let[n,i]of Object.entries(e))void 0!==i&&(t[n]=i);return t}({renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,reportUnfaithful:(n,i)=>{r(e,t,n,i)}})}apply(e){let{deps:t,state:n}=this,i=n.activeUpdate;if(null===i||void 0===e.revision||!g(i.revision,e.revision)||!n.isCurrent(i))return!1;let{target:l,value:s}=e,u=void 0!==i.schemaIndex?S(i.schemaIndex,l.fieldName):void 0,d=function(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){let e=function(e){if(Object.prototype.hasOwnProperty.call(Vn,e))return Vn[e]}(t);if(void 0!==e)return e}return e.fieldType}(l,u?.type);"text"===d&&!0!==l.explicitFieldType&&function(e){if("object"!=typeof e||null===e||!("root"in e))return!1;let t=e.root;return"object"==typeof t&&null!==t&&Array.isArray(t.children)}(s)&&(d="richText");let c;try{c=t.resolveRenderer(d,l)}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;let h=t.emitter.listenerCount("elementUpdate")>0,f=h?function(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:"IMG"===e.tagName?e.src:e.textContent}(l.element):void 0;if(!n.isCurrent(i))return!1;let p={allFields:e.allFields,locale:l.locale??i.locale,schema:u,...this.instanceContext};!0===l.hidesWhenEmpty&&l.element.toggleAttribute("hidden",function(e){return null==e||("string"==typeof e?0===e.trim().length:Array.isArray(e)&&0===e.length)}(s));try{if(void 0!==l.targetAttribute){if("blocked"===function(e,t,n){let i=t.toLowerCase().trim();if(0===i.length||!F(i))return"blocked";if(null==n)return e.removeAttribute(i),"applied";if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return"blocked";let r=String(n);return Qn.has(i)&&!$(r)?"blocked":(e.setAttribute(i,r),"applied")}(l.element,l.targetAttribute,s))return t.warn(`[live-preview] LP0401: refused to write "${l.fieldName}" into attribute "${l.targetAttribute}"`),!1}else{if(void 0===c)return t.log("no renderer for",d),r(t,n,l,`has no renderer for "${d}"`),!1;{let e=function(e,t,n,i){if("ignore"===e.onUnfaithfulPatch||void 0!==n.format||!Pn.has(i)||t.checkedServerFormat.has(n.element))return;t.checkedServerFormat.add(n.element);let r=o(n.element);return r.trim().length>0?r:void 0}(t,n,l,d);if(!1===function(e,t,n,i){return e.render(t,n,i)}(c,l,s,p)&&function(e){return Zn.has(e.render)}(c))return r(t,n,l,`is a value ${c.name} cannot render`),!1;void 0!==e&&function(e,t,n){let i=o(t.element);i!==n&&e.warn(`[live-preview] LP0412: "${t.fieldName}" showed ${a(n)}, the patch wrote ${a(i)} \\u2014 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,l,e)}}}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;h&&t.emitter.emitWhile("elementUpdate",{element:l.element,fieldName:l.fieldName,previousValue:f,nextValue:s,revision:i.revision.revision,receivedAt:i.receivedAt,source:"patch"},()=>n.isCurrent(i));let m=n.isCurrent(i);return m&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(l.element,e.valueIdentity):n.lastAppliedIdentity.delete(l.element)),m}fail(e,t){if(!this.state.isCurrent(e))return!1;let n=t instanceof Error?t:new Error(String(t));return this.deps.emitter.emitWhile("error",{error:n,context:"renderer",code:"LP0603"},()=>this.state.isCurrent(e)),!1}},fi="data-payload-island",pi=`astro-island, [${fi}]`,mi="data-payload-field",gi="data-payload-type",vi="data-payload-attribute",yi="data-payload-href",bi="data-payload-src",wi="data-payload-alt",Si="data-payload-array-template",Ti="data-payload-array-separator",ki="data-payload-locale",Ai="data-payload-richtext",Ci="data-payload-html",$i="data-payload-array",Ri="data-payload-structural",Fi="data-payload-owner",Ni="data-payload-depends",xi="data-payload-strategy",Mi="data-payload-boundary",Ei="data-payload-guessed",Oi=[mi,gi,vi,yi,bi,wi,Si,Ti,ki,Ai,Ci,$i,Ri,Fi,Ni,xi,Mi,"type"],Pi=`[${mi}]`,Li=`[${Fi}]`,Ui=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,Ii=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"]),ji=class{constructor(e={}){vn(this,"entriesByField",new Map);vn(this,"entryByElement",new WeakMap);vn(this,"filter");vn(this,"count",0);vn(this,"dependencies",null);vn(this,"islandRoots",[]);this.filter=e.filter??te}dependencyMap(){if(null!==this.dependencies)return this.dependencies;let e=[];for(let t of this.values())void 0!==t.dependsOn&&e.push(J(t.fieldName,t.dependsOn));return this.dependencies=K(...e),this.dependencies}get islands(){return this.islandRoots}buildFromRoot(e){let t=performance.now();this.clear();let n=0;for(let t of e.querySelectorAll(Pi))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){let t=[];for(let n of e.querySelectorAll(pi))X(n)||t.push(n);return t}(e),{elementCount:n,fieldCount:this.entriesByField.size,durationMs:performance.now()-t}}add(e){let 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){let 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(let e of this.entriesByField.values())yield*e}has(e){return this.entryByElement.has(e)}clear(){this.entriesByField.clear(),this.entryByElement=new WeakMap,this.count=0,this.dependencies=null,this.islandRoots=[]}replaceEntry(e,t){if(e.fieldName!==t.fieldName)return!1;let n=this.entriesByField.get(e.fieldName),i=void 0===n?-1:n.indexOf(e);return!(void 0===n||i<0||(n[i]=t,0))}removeEntry(e,t){this.entryByElement.delete(e);let n=this.entriesByField.get(t.fieldName),i=void 0===n?-1:n.indexOf(t);return!(void 0===n||i<0||(n.splice(i,1),0===n.length&&this.entriesByField.delete(t.fieldName),this.count-=1,0))}append(e){let t=this.entriesByField.get(e.fieldName);t?t.push(e):this.entriesByField.set(e.fieldName,[e]),this.count+=1}resolveBinding(e){let t=e.getAttribute(mi);if(null===t||0===t.length)return;let n=e.getAttribute(gi),i=e.getAttribute(vi),r=e.getAttribute(yi),l=e.getAttribute(bi),o=e.getAttribute(wi),a=e.getAttribute(Si),s=e.getAttribute(Ti),u=e.getAttribute(ki),d=e.getAttribute("data-payload-format"),c=Z(e),h=function(e){if(null==e)return[];let t=new Set,n=[];for(let i of e.split(/[\\s,]+/)){let e=i.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}(e.getAttribute(Ni)),f=e.getAttribute(xi),p=e.getAttribute(Ei),m=M(e);return{element:e,fieldName:t,fieldType:ee(e),explicitFieldType:null!==n&&Y(n),strategyKind:E(e)??"unknown",...null!==m?{fragmentBoundary:m}:{},...null!==i&&i.length>0?{targetAttribute:i}:{},...null!==r&&r.length>0?{hrefField:r}:{},...null!==l&&l.length>0?{srcField:l}:{},...null!==o&&o.length>0?{altField:o}:{},...null!==a?{arrayTemplate:a}:{},...null!==s?{arraySeparator:s}:{},...null!==u&&u.length>0?{locale:u}:{},...null!==d&&d.length>0?{format:d}:{},...void 0!==c?{owner:c}:{},...h.length>0?{dependsOn:h}:{},...null!==f&&f.length>0?{strategy:f}:{},...e.hasAttribute(Mi)?{hidesWhenEmpty:!0}:{},...null!==p?{guessed:p}:{}}}},_i=class{constructor(e){vn(this,"serverURL");vn(this,"apiRoute");vn(this,"depth");vn(this,"fetchFn");vn(this,"log");vn(this,"inflight",null);vn(this,"attempt",0);vn(this,"destroyDepth",0);this.serverURL=function(e){let t=e.length;for(;e.endsWith("/",t);)t-=1;return e.slice(0,t)}(e.serverURL);let i=e.apiRoute??"/api";this.apiRoute=i.startsWith("/")?i:`/${i}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=t(e.log??n)}canMerge(e){return null!==this.endpointOf(e)}endpointOf(e){try{let t=e.globalSlug;if(t)return ie(t)?`globals/${encodeURIComponent(t)}`:null;let n=e.collectionSlug??"",i=e.data.id;return ie(n)&&function(e){return"number"==typeof e?Number.isFinite(e):"string"==typeof e&&ne(e,512)}(i)?`${encodeURIComponent(n)}/${encodeURIComponent(String(i))}`:null}catch{return null}}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};let t=this.attempt+=1,n=this.inflight;this.inflight=null;let i=null,r=()=>this.attempt!==t;try{if(n?.abort(),r())return{status:"superseded"};let t=this.endpointOf(e);if(null===t)return r()?{status:"superseded"}:{status:"unavailable"};let l=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===l)return{status:"unavailable"};i=new AbortController,this.inflight=i;let o=`${this.serverURL}${this.apiRoute}/${t}`,a=await l(o,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:JSON.stringify({data:e.data,depth:this.depth,flattenLocales:!1,locale:e.locale}),signal:i.signal});if(r())return{status:"superseded"};if(!a.ok)return this.log("merge HTTP",a.status,o),{status:"unavailable"};let s=await a.json();return r()?{status:"superseded"}:null===s||"object"!=typeof s||Array.isArray(s)?(this.log("merge invalid",o),{status:"unavailable"}):{status:"merged",doc:s}}catch(e){return r()?{status:"superseded"}:(this.log("merge exception",e),{status:"unavailable"})}finally{this.inflight===i&&(this.inflight=null)}}destroy(){this.attempt+=1;let e=this.inflight;this.inflight=null,this.destroyDepth+=1;try{e?.abort()}finally{this.destroyDepth-=1}}},Wi="2.0.6",Bi={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},zi={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},Di={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1},Vi=1,Hi=class{constructor(e,t={}){vn(this,"callbacks");vn(this,"debounceMs");vn(this,"rootMargin");vn(this,"visible",new Set);vn(this,"mutation",null);vn(this,"intersection",null);vn(this,"debounceTimer",null);vn(this,"generation",0);this.callbacks=e,this.debounceMs=t.mutationDebounceMs??100,this.rootMargin=t.intersectionRootMargin??"200px"}start(e){let t=this.generation;this.stop();let n=t+1;if(this.generation!==n)return;let i=null,r=null;try{i=new MutationObserver(e=>{this.handleMutations(e,n)}),r=new IntersectionObserver(e=>{this.handleIntersection(e,n)},{rootMargin:this.rootMargin,threshold:0}),i.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...Oi]})}catch(e){throw i?.disconnect(),r?.disconnect(),e}this.generation===n?(this.mutation=i,this.intersection=r):(i.disconnect(),r.disconnect())}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;let 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)||!function(e){for(let t of e){if("attributes"===t.type&&null!==t.attributeName&&Oi.includes(t.attributeName)&&(t.attributeName===mi||t.attributeName===Fi||t.target.nodeType===Vi&&t.target.hasAttribute(mi)))return!0;for(let e of t.addedNodes)if(le(e))return!0;for(let e of t.removedNodes)if(le(e))return!0}return!1}(e))return;null!==this.debounceTimer&&clearTimeout(this.debounceTimer);let n=setTimeout(()=>{!this.isCurrentGeneration(t)||this.debounceTimer!==n||(this.debounceTimer=null,this.callbacks.onStructuralChange())},this.debounceMs);this.debounceTimer=n}handleIntersection(e,t){for(let n of e){if(!this.isCurrentGeneration(t))return;let{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}},Gi="__livePreviewHydration",qi="[data-payload-field]",Ki="__vue_app__",Ji="__livePreviewVueHydration",Xi="app:suspense:resolve",Qi=class{constructor(e){vn(this,"timeoutMs");vn(this,"onTimeout");vn(this,"handle",null);vn(this,"lastKick",0);this.timeoutMs=e.timeoutMs??0,this.onTimeout=e.onTimeout}kick(){if(this.lastKick=Date.now(),this.timeoutMs<=0)return;null!==this.handle&&clearTimeout(this.handle);let e=setTimeout(()=>{this.handle===e&&(this.handle=null,this.onTimeout())},this.timeoutMs);this.handle=e}stop(){null!==this.handle&&(clearTimeout(this.handle),this.handle=null)}get lastKickAt(){return this.lastKick}get pending(){return null!==this.handle}},Zi=class{constructor(){vn(this,"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)}},Yi="data-payload-no-bind",er="data-payload-owned",tr=13,nr=new Set(["true","false","yes","no","on","off"]),ir=/^[\\d\\s.,:+/-]+$/u,rr=/^[a-z][a-z0-9_-]*$/u,lr=/^[a-z]{2,3}(?:[-_][A-Za-z0-9]{2,8})*$/u,or=new Set(["SCRIPT","STYLE","TEMPLATE","TITLE","NOSCRIPT","TEXTAREA","SELECT","OPTION","INPUT","IFRAME"]),ar="http://www.w3.org/1999/xhtml",sr=new Set(["__proto__","prototype","constructor"]),ur="payload-live-preview",dr=Symbol.for("payload-live-preview.trusted-types"),cr="data-payload-owned",hr=new Set(["open","value","checked","selected"]),fr=new Set,pr="data-payload-",mr=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"]),gr=new Set(["input","button","textarea","select","option","label"]),vr=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),yr=new Set(["id","class","lang","dir","title","role","tabindex"]),br="aria-",wr="data-",Sr="data-payload-",Tr={a:new Set(["href","target","rel","download","hreflang","type"]),img:new Set(["src","srcset","sizes","alt","width","height","loading","decoding"]),picture:new Set([]),source:new Set(["src","srcset","sizes","type","media"]),audio:new Set(["src","controls","autoplay","loop","muted","preload"]),video:new Set(["src","poster","controls","autoplay","loop","muted","preload","width","height","playsinline"]),time:new Set(["datetime"]),abbr:new Set(["title"]),q:new Set(["cite"]),blockquote:new Set(["cite"]),table:new Set(["summary"]),th:new Set(["colspan","rowspan","scope","headers","abbr"]),td:new Set(["colspan","rowspan","headers"]),col:new Set(["span"]),colgroup:new Set(["span"]),ol:new Set(["start","reversed","type"]),li:new Set(["value"]),code:new Set(["class"]),pre:new Set(["class"])},kr=new Set(["href","src","cite","poster"]),Ar=1,Cr=8,$r=(Error,new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"])),Rr="strict",Fr=(Object.freeze({allowedTags:mr,removeCompletely:vr,globalAttributes:yr,attributesByTag:Tr,urlAttributes:kr}),Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"})),Nr=/[&<>"\'/`=]/g,xr=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;"}),Mr=/[&<>"\']/g,Er=/\\{\\{([\\s\\S]*?)\\}\\}/g,Or="data-payload-",Pr=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],Lr=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],Ur=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\\b/gi,Ir=64,jr=new Map,_r="data-payload-key",Wr="data-payload-nested-key",Br="data-payload-nested-template",zr=class{constructor(e,t,n){vn(this,"deps",e);vn(this,"state",t);vn(this,"host",n)}planFragments(e){let t=this.deps.strategies.fragment;return void 0===t?null:wt(t,t.plan(this.deps.root,e))}escalateUnfaithful(e,t,n){if(e.routeRefreshed)return;let{fragment:i,route:r}=this.deps.strategies,l=void 0===i?void 0:function(e){let t=[];for(let n of e){let e=n.fragmentBoundary;if(void 0===e)return;t.includes(e)||t.push(e)}return t}(n);void 0===i||void 0===l?void 0!==r?(this.state.escalatedCount+=n.length,this.refreshRoute(e,t,r)):this.warnEscalationUnavailable(n.length):(this.state.escalatedCount+=n.length,e.pendingFragments+=l.length,this.runFragments(e,t,wt(i,l)))}warnEscalationUnavailable(e){let{deps:t,state:n}=this;n.warnedEscalationUnavailable||(n.warnedEscalationUnavailable=!0,t.warn(`[live-preview] LP0808: onUnfaithfulPatch: \'escalate\' has nowhere to go: ${String(e)} field(s) fell short and no route or fragment strategy is configured. Set routeStrategy: true or fragments: { endpoint }, or onUnfaithfulPatch: \'warn\' to keep the patch and say so.`))}hasUnboundChange(e,t){let{deps:n,state:i}=this;if(e.baseline||e.routeRefreshed)return!1;let r=function(e,t,n,i){let r=B(e,n,i),l=[];for(let e of t)!ni.has(e)&&!r(e)&&l.push(e);return l}(n.cache,e.touched,e.locale,t),o=0;for(let e of r)l(i,e)&&(o+=1);let[a]=r;return void 0!==a&&"escalate"===n.onUnfaithfulPatch&&(void 0===n.strategies.route?(this.warnEscalationUnavailable(r.length),!1):(n.log("route","LP0807",`field "${a}" has no binding; refreshing the route`),i.escalatedCount+=o,!0))}hasRouteBinding(e){for(let[t,n]of this.deps.cache.entries())if(e.has(t)&&n.some(e=>"route"===e.strategyKind))return!0;return!1}async runFragments(e,t,n){let{deps:i,state:r}=this,l=new AbortController;r.fragmentController=l;let o=()=>r.isCurrent(e)&&!l.signal.aborted,{emitter:a}=i,{message:s}=e,u=e.revision.revision,d=e.receivedAt,c={root:i.root,revision:u,receivedAt:d,fields:t.fields,locale:e.locale,collectionSlug:"string"==typeof s.collectionSlug?s.collectionSlug:void 0,globalSlug:"string"==typeof s.globalSlug?s.globalSlug:void 0,signal:l.signal,isCurrent:o,log:(e,t)=>{i.log("fragment",e,t)},morph:(e,t)=>{!function(e,t){let n=e.ownerDocument.createElement("template");n.innerHTML=Le(t);let i=e.cloneNode(!1);i.append(n.content),je(e,i,{keyAttributes:[_r]})}(e,t)},patch:n=>{this.patchFallback(e,t,n)},rendered:(t,n,i)=>{e.pendingFragments-=1,a.emitWhile("fragmentRender",{element:t,id:n,key:i,status:"rendered",revision:u,receivedAt:d},o)},failed:(t,n,r,l,s)=>{e.pendingFragments-=1;let c=`fragment "${n}" fell back to patch: ${s}`;i.log("fragment",l,c),a.emitWhile("error",{error:new Error(c),context:"fragment",code:l},o),a.emitWhile("fragmentRender",{element:t,id:n,key:r,status:"failed",code:l,revision:u,receivedAt:d},o)}},h={rendered:0,failed:0,superseded:0};try{h=await n.strategy.render(c,n.boundaries)}catch(r){if(i.log("fragment","LP0801",r),o()){for(let i of n.boundaries)this.patchFallback(e,t,i);h={rendered:0,failed:n.boundaries.length,superseded:0}}}r.fragmentStats.rendered+=h.rendered,r.fragmentStats.failed+=h.failed,r.fragmentStats.superseded+=h.superseded,o()&&(r.fragmentController===l&&(r.fragmentController=null),e.pendingFragments=0,h.rendered>0&&this.host.restoreGuesses(e,t),0===i.scheduler.pendingCount&&r.complete(e),this.host.revealPending(e),o()&&(0===h.rendered||0===a.listenerCount("afterUpdate")||a.emitWhile("afterUpdate",{data:t,updatedCount:h.rendered,durationMs:Date.now()-d,revision:u,receivedAt:d,source:"fragment"},o)))}async refreshRoute(e,t,n){let{deps:i,state:r}=this;e.routeRefreshed?(r.routeStats.loopStopped+=1,i.log("route","LP0805",`revision ${String(e.revision.revision)} asked for a second refresh`)):(e.routeRefreshed=!0,await this.runRoute(e,t,n))}armRouteRetry(e,t,n,i){let{state:r}=this;null!==r.routeRetry&&clearTimeout(r.routeRetry),r.routeRetry=setTimeout(()=>{r.routeRetry=null,r.isCurrent(e)&&this.runRoute(e,t,n)},i)}async runRoute(e,t,n){let{deps:i,state:r}=this,l=r.routeStats,o=new AbortController;r.routeController=o;let a,s=()=>r.isCurrent(e)&&!o.signal.aborted;try{a=await n.refresh({revision:e.revision.revision,receivedAt:e.receivedAt,signal:o.signal,isCurrent:s,log:(e,t)=>{i.log("route",e,t)},retryAfter:i=>{this.armRouteRetry(e,t,n,i)}})}catch(e){i.log("route","LP0801",e),a="failed"}if(s()){if(r.routeController===o&&(r.routeController=null),"refreshed"===a){if(l.refreshes+=1,r.lastAppliedIdentity=new WeakMap,this.host.restoreGuesses(e,t),this.host.rebuildCache(),!s())return;this.host.reapply(e,t),i.emitter.listenerCount("afterUpdate")>0&&i.emitter.emitWhile("afterUpdate",{data:t,updatedCount:i.cache.elementCount,durationMs:Date.now()-e.receivedAt,revision:e.revision.revision,receivedAt:e.receivedAt,source:"route"},s);return}"failed"===a?l.failed+=1:"refused"===a&&(l.refused+=1),this.host.reapply(e,t)}}warnFragmentFallback(e){!function(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`))}(this.deps,this.state,e)}warnUnsupportedStrategy(e){!function(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`))}(this.deps,this.state,e)}patchFallback(e,t,n){for(let[i,r]of this.deps.cache.entries())for(let l of r){if(l.fragmentBoundary!==n)continue;let r=xe(t.fields,l,i,e.locale);void 0!==r&&this.deps.scheduler.schedule({target:l,value:this.host.transform(l,r,t.fields,()=>!0),allFields:t.fields,revision:e.revision,data:t})}}},Dr=new Set,Vr=class{constructor(e,t,n){vn(this,"deps",e);vn(this,"state",t);vn(this,"strategies");this.strategies=new zr(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(t,n,i,r)=>St(e,t,n,i,r),rebuildCache:n,restoreGuesses:(e,t)=>{this.restoreGuesses(e,t)},revealPending:e=>{this.revealPending(e)}})}handleUpdate(e,t,n){let{deps:i,state:r}=this;if(i.heartbeat.kick(),r.protocol.observe(function(e){let 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),i.log),void 0===e.data){void 0!==e.protocolVersion&&r.protocol.applyVersion(e.protocolVersion,i.log);return}if(void 0===n)return;let l=r.relationships.edit(e);null!==l&&i.emitter.emit("relationshipUpdate",{detail:l,timestamp:Date.now()}),"string"==typeof e.locale&&(r.locale=e.locale),Array.isArray(e.fieldSchemaJSON)&&(r.schema=e.fieldSchemaJSON,r.schemaIndex=b(e.fieldSchemaJSON));let o={revision:n,message:e,locale:r.locale,schema:r.schema,schemaIndex:r.schemaIndex,receivedAt:Date.now(),forceRender:null!==l||G(r.activeUpdate),touched:new Set,baseline:!1,invalidated:new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1},a=r.activeUpdate;r.abortStrategies(),null!==a&&!a.completed&&(r.supersededCount+=1),r.activeUpdate=o,i.scheduler.acceptRevision(n),r.updateCount+=1,(void 0===e.protocolVersion||(r.protocol.applyVersion(e.protocolVersion,i.log),r.isCurrent(o)))&&(i.connection.markConnected()&&(i.a11y?.announceConnected(),i.emitter.emit("connect",{origin:t,timestamp:Date.now()}),!r.isCurrent(o)||(i.log("connection","disconnected","\\u2192","connected"),!r.isCurrent(o)))||this.processUpdate(o).catch(e=>{i.log("update failed:",e)}))}async processUpdate(e){let{deps:t,state:n}=this,i=await this.resolveIncomingFields(e);if(null===i||!n.isCurrent(e))return;let r=this.dataFor(e,i);t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:r,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,r,!1)}dataFor(e,t){let{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){let{deps:i,state:r}=this,l=K(i.dependencies,i.cache.dependencyMap()),o=r.changes.diff(t.fields,l);if(o.baseline&&!n&&"off"!==i.autoBind){let n=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,i,r){let l=performance.now(),o=$e(e.root),a=ye(n,i),s=null===o?[]:Re(e,Ce(o,a),r,"on the first message");t.autoBindGuesses=function(e,t){let n=new Set;for(let{fieldName:e,stamps:i}of t){n.add(e);for(let e of[yi,wi]){let t=i[e];void 0!==t&&n.add(t)}}let i=new Map;for(let[t,r]of e)null!==r&&n.has(r.field)&&i.set(t,r);return{fields:n,values:i}}(a,s),t.autoBindSearchMs=performance.now()-l,s.length}(i,r,t.fields,e.locale,n)}e.baseline=o.baseline,e.invalidated=n?Dr:o.invalidated,e.touched=n?Dr:new Set([...o.changed,...o.invalidated]),this.scheduleAllFields(e,t)}async resolveIncomingFields(e){let{deps:t,state:n}=this,i=e.message.data??{};if(null===t.merger||"admin"===re(n.protocol.observed).populatesRelationships)return i;let r=n.merges.decide(t,e);if(!r.merge)return r.fields;let{message:l}=e,o=n.merges.request(t.merger,t.mergeWindowMs,{collectionSlug:l.collectionSlug,globalSlug:l.globalSlug,data:i,locale:e.locale});if(!o.leading)return this.applyMerged(e,o.result).catch(e=>{t.log("update failed:",e)}),r.fields;let a=await o.result;return n.isCurrent(e)?"merged"===a.status?(n.merges.recordMerged(a.doc),a.doc):"superseded"===a.status?null:r.fields:null}async applyMerged(e,t){let{state:n}=this,i=await t;"merged"!==i.status||!n.isCurrent(e)||(n.merges.recordMerged(i.doc),this.applyFields(e,this.dataFor(e,i.doc),!0))}scheduleAllFields(e,t){let{deps:n,state:i}=this;if(!i.isCurrent(e))return;let r=()=>i.isCurrent(e),l=this.ownerKeysForUpdate(e,t.fields),{touched:o}=e,a=n.strategies.route,s=this.strategies.hasUnboundChange(e,l),u=i.routeRefreshOwed;if(void 0!==a&&!e.routeRefreshed&&(s||u||a.plan(n.root,o)||this.strategies.hasRouteBinding(o))){i.routeRefreshOwed=!1,this.strategies.refreshRoute(e,t,a);return}let d=this.strategies.planFragments(o),c=n.skipUnchanged,h=0;for(let[o,a]of n.cache.entries()){if(!r())return;for(let s of a){if(!1!==l&&!U(s.owner,l))continue;if(!0===d?.covers(s)){if(n.revealEditedField){let n=xe(t.fields,s,o,e.locale);i.revealLedger.note(e,s,n)}continue}let a=s.strategyKind??E(s.element)??"unknown";if("unknown"===a){this.strategies.warnUnsupportedStrategy(s);continue}"fragment"===a&&null===d&&this.strategies.warnFragmentFallback(s);let u=xe(t.fields,s,o,e.locale);if(void 0===u){i.absentFields.add(o);continue}if(n.revealEditedField&&i.revealLedger.note(e,s,u),!r())return;let f=St(n,s,u,t.fields,r);if(!r())return;let p=c?Me(s,f,t.fields,e.locale):void 0,m=i.lastAppliedIdentity.get(s.element);if(!e.forceRender&&n.skipUnchanged&&void 0!==p&&m===p&&!e.invalidated.has(o)){i.skippedUnchangedCount+=1;continue}let g={target:s,value:f,allFields:t.fields,revision:e.revision,data:t,valueIdentity:p};n.scheduler.schedule(g),h+=1}}(function(e,t,n,i){let{cache:r}=e;if(0===r.fieldCount||!1!==i&&!function(e,t){for(let n of e.values())if(U(n.owner,t))return!0;return!1}(r,i))return;let l=B(r,n,i);for(let[i,r]of Object.entries(t)){if(ni.has(i))continue;if(Oe(r)){Ee(e,l,i,n,r);continue}if(!Pe(r)||l(i))continue;let t=W(i,n);for(let[i,o]of Object.entries(r))!Oe(o)||ni.has(i)||Ee(e,l,`${t}.${i}`,n,o)}})({cache:n.cache,warned:i.warnedOrphanFields,warn:n.warn},t.fields,e.locale,l),null!==d&&d.boundaries.length>0&&(e.pendingFragments=d.boundaries.length,this.strategies.runFragments(e,t,d)),0===h&&0===e.pendingFragments&&(i.complete(e),this.revealPending(e),this.notifyIslands(e,t))}notifyIslands(e,t){0!==e.touched.size&&function(e,t){for(let n of e)n.dispatchEvent(new CustomEvent("payload-live-preview:update",{detail:t,bubbles:!1}));e.length}(this.deps.cache.islands,{fields:t.fields,revision:e.revision.revision,receivedAt:e.receivedAt,locale:e.locale})}restoreGuesses(e,t){let{deps:n,state:i}=this;if("off"!==n.autoBind&&null!==i.autoBindGuesses){let r=this.ownerKeysForUpdate(e,t.fields);!function(e,t,n,i,r){let l=t.autoBindGuesses,o=$e(e.root);if(null===l||0===l.fields.size||null===o)return 0;let a=new Map(l.values);for(let[e,t]of ye(n,i)){if(null===t||!l.fields.has(t.field))continue;let n=a.get(e);void 0===n?a.set(e,t):n?.field!==t.field&&a.set(e,null)}Re(e,Ce(o,a),r,"after a server render").length}(n,i,t.fields,e.locale,r)}}ownerKeysForUpdate(e,t){let{deps:n,state:i}=this;if(!n.scopeBindingsByOwner)return!1;let{message:r}=e,l=function(e){if(L(e.globalSlug))return[O(e.globalSlug)];if(!L(e.collectionSlug))return null;let t=P(e.collectionSlug);return L(e.documentId)?[t,P(e.collectionSlug,e.documentId)]:[t]}({globalSlug:"string"==typeof r.globalSlug?r.globalSlug:void 0,collectionSlug:"string"==typeof r.collectionSlug?r.collectionSlug:void 0,documentId:I(t)});return null===l&&!i.warnedUnattributableMessage&&(i.warnedUnattributableMessage=!0,n.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),l}onFlush(e){let{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`));let{revision:i,data:r}=e;if(void 0===i)return;let l=n.activeUpdate;if(null===l||!n.isCurrent(l)||!g(l.revision,i))return;0===l.pendingFragments&&n.complete(l);let o=()=>n.isCurrent(l)&&g(l.revision,i);if(this.revealPending(l),!o())return;let a=n.unfaithfulPatches;a.length>0&&(n.unfaithfulPatches=[],void 0!==r&&this.strategies.escalateUnfaithful(l,r,a),!o())||void 0!==r&&(e.applied>0&&t.a11y?.announceUpdate(e.applied),o()&&(this.notifyIslands(l,r),o()&&0!==e.applied&&0!==t.emitter.listenerCount("afterUpdate")&&t.emitter.emitWhile("afterUpdate",{data:r,updatedCount:e.applied,durationMs:e.durationMs,revision:i.revision,receivedAt:l.receivedAt,source:"patch"},o)))}revealPending(e){let t=this.state.revealLedger.commit(e);if(void 0!==t)try{this.revealBinding(t)}catch(e){this.deps.log("reveal",e)}}revealField(e){let t=this.deps.cache.get(e)?.[0];return void 0===t?"no-element":this.revealBinding(t)}revealBinding(e){let{element:t}=e,n=t.ownerDocument.defaultView;if(null===n)return"no-element";let i=`${e.owner??""} ${e.fieldName}`;return this.state.revealer.reveal(i,t,n)}},Hr=class{constructor(e,t){vn(this,"apply");vn(this,"debounceMs");vn(this,"maxWaitMs");vn(this,"isVisible");vn(this,"gateThresholdValue");vn(this,"gateDisabled");vn(this,"getCacheSize");vn(this,"onFlush");vn(this,"scheduleFrame");vn(this,"cancelFrame");vn(this,"pending",new Map);vn(this,"replay",new Map);vn(this,"activeFlushes",new Set);vn(this,"debounceTimer",null);vn(this,"debounceToken",0);vn(this,"deadlineTimer",null);vn(this,"frameHandle",null);vn(this,"frameToken",0);vn(this,"windowUntil",0);vn(this,"activeRevision",null);vn(this,"activeRevisionCancelled",!1);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(void 0!==e.revision&&(this.activeRevisionCancelled||null===this.activeRevision||!g(e.revision,this.activeRevision)))return;let 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){null!==this.activeRevision&&g(e,this.activeRevision)||null!==this.activeRevision&&function(e,t){return e.generation!==t.generation?e.generation-t.generation:e.revision-t.revision}(e,this.activeRevision)<0||(this.cancelScheduledWork(),this.clearWork(),this.activeRevision=e,this.activeRevisionCancelled=!1)}cancelRevision(e){null===this.activeRevision||!g(e,this.activeRevision)||(this.cancelScheduledWork(),this.clearWork(),this.activeRevisionCancelled=!0)}flushNow(){return this.cancelScheduledWork(),this.flush()}notifyVisible(e){let t=this.replay.get(e);if(!t||(this.replay.delete(e),!this.isCurrent(t)))return;let n=performance.now(),i=this.didApply(t)?1:0;this.onFlush?.(this.statsFor(t,i,0,performance.now()-n,1===i?[t.target.fieldName]:[]))}retarget(e){this.retargetBuffer(this.pending,e),this.retargetBuffer(this.replay,e);for(let t of this.activeFlushes)this.retargetBuffer(t,e)}forget(e){this.pending.delete(e),this.replay.delete(e);for(let t of this.activeFlushes)t.delete(e)}destroy(){this.cancelScheduledWork(),this.clearWork(),this.activeRevision=null,this.activeRevisionCancelled=!1,this.windowUntil=0}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(){let e=Date.now(),t=e>=this.windowUntil;if(this.windowUntil=e+this.debounceMs,t){this.requestFrame();return}let n=this.debounceToken+=1,i=this.debounceTimer;if(this.debounceTimer=null,null!==i&&clearTimeout(i),this.debounceToken!==n)return;let r=setTimeout(()=>{this.debounceToken===n&&(this.debounceTimer=null,this.pending.size>0&&this.requestFrame())},this.debounceMs);this.debounceToken===n&&(this.debounceTimer=r),null===this.deadlineTimer&&this.maxWaitMs>this.debounceMs&&(this.deadlineTimer=setTimeout(()=>{this.deadlineTimer=null,this.pending.size>0&&this.requestFrame()},this.maxWaitMs))}requestFrame(){let e=this.frameToken+=1,t=this.frameHandle;if(this.frameHandle=null,null!==t&&this.cancelFrame(t),this.frameToken!==e)return;let n=!1,i=this.scheduleFrame(()=>{this.frameToken===e&&(n=!0,this.frameHandle=null,this.flush())});!n&&this.frameToken===e&&(this.frameHandle=i)}flush(){let e=performance.now();this.clearDeadline();let t=this.gateActive,n=this.pending;this.pending=new Map;let i,r=0,l=[],o=0;this.activeFlushes.add(n);try{for(let e of n.values()){if(!this.isCurrent(e))continue;let n=!t||this.isVisible(e.target.element);if(this.isCurrent(e)){if(i??(i=e),!n){this.replay.set(e.target.element,e),o+=1;continue}this.replay.delete(e.target.element),this.didApply(e)&&(r+=1,l.push(e.target.fieldName))}}}finally{this.activeFlushes.delete(n)}let a=this.statsFor(i,r,o,performance.now()-e,l);return this.onFlush?.(a),a}isCurrent(e){return void 0===e.revision||!this.activeRevisionCancelled&&null!==this.activeRevision&&g(e.revision,this.activeRevision)}didApply(e){return!1!==this.apply(e)||!function(e){return Zn.has(e)}(this.apply)}retargetBuffer(e,t){let n=e.get(t.element);if(void 0!==n){if(n.target.fieldName!==t.fieldName||n.target.locale!==t.locale){e.delete(t.element);return}n.target=t}}clearWork(){this.pending.clear(),this.replay.clear();for(let e of this.activeFlushes)e.clear()}statsFor(e,t,n,i,r){return{applied:t,appliedFields:r,deferred:n,durationMs:i,...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(){let e=this.debounceTimer,t=this.frameHandle;this.debounceToken+=1,this.frameToken+=1,this.debounceTimer=null,this.frameHandle=null,this.clearDeadline(),null!==e&&clearTimeout(e),null!==t&&this.cancelFrame(t)}},Gr=[0,500,1e3,2e3],qr=class{constructor(e){vn(this,"deps");vn(this,"state",new ci);vn(this,"pipeline");vn(this,"writer");vn(this,"rootSentinel",null);vn(this,"observedRoot",null);let{emitter:r,renderers:l}=e,o=void 0===e.log?n:t(e.log),a=void 0===e.warn?An:t(e.warn),s=e.root??(typ','eof document<"u"?document:void 0);if(void 0===s)throw new Error("LivePreviewRuntime: no document; pass options.root");let u=new ji({filter:e=>!function(e){let t=e;for(;null!==t;){if(Q(t))return!0;t=t.parentElement}return!1}(e)}),d=new Hi({onStructuralChange:()=>{this.rebuildCache()},onVisibilityChange:(e,t)=>{t&&c.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),c=new Hr(N(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=>d.isVisible(e),getCacheSize:()=>u.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),h=new zn(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],o),r.emit("documentSave",{timestamp:Date.now()})},onFocusField:e=>{this.deps.revealEditedField&&this.pipeline.revealField(e)},onInvalid:(e,t)=>{if("token"===e){let e=new Error(`Preview token rejected (origin: ${t})`);r.emit("error",{error:e,context:"token",code:"LP0502"})}("shape"===e||"type"===e)&&!this.state.warnedProtocolShape&&(this.state.warnedProtocolShape=!0,a(`[live-preview] LP0503: ${t} 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,a(`[live-preview] LP0501: a message from ${t} 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.`)),o("LP0501 message rejected:",e,t)},...void 0!==e.validateToken?{validateToken:e.validateToken}:{},...void 0!==e.eventSourcePolicy?{sourcePolicy:e.eventSourcePolicy}:{}}),f=e.dataMerge;this.deps={emitter:r,cache:u,observers:d,scheduler:c,bus:h,connection:new Zi,heartbeat:new Qi({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:l,resolveRenderer:e.resolveRenderer??(e=>l[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,sanitizerPolicy:e.sanitizerPolicy,root:s,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??y,onHeartbeatTimeout:e.onHeartbeatTimeout,log:o,warn:a,a11y:v(e),merger:void 0===f?null:new _i({serverURL:f.serverURL,...void 0!==f.apiRoute?{apiRoute:f.apiRoute}:{},...void 0!==f.depth?{depth:f.depth}:{},...void 0!==f.fetchFn?{fetchFn:f.fetchFn}:{},log:o}),mergeWindowMs:e.debounceMs??50,scopeBindingsByOwner:!0===e.scopeBindingsByOwner,lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField,onUnfaithfulPatch:i(e),autoBind:e.autoBind??"off",hydration:e.hydration},this.writer=new hi(this.deps,this.state),this.pipeline=new Vr(this.deps,this.state,()=>{this.rebuildCache()})}start(){let{state:e}=this;if(e.isRunning())return!1;e.started=!0,e.suspended=!1;try{return function(e){"react"===e.hydration?ae():"vue"===e.hydration&&fe();let{root:t}=e;if(!function(e){return 9===e.nodeType}(t)||"loading"!==t.readyState){pe(e);return}let n=()=>{e.isRunning()&&e.later(()=>{pe(e)})};t.addEventListener("DOMContentLoaded",n,{once:!0}),e.defer(()=>{t.removeEventListener("DOMContentLoaded",n)})}(this.startupHost()),!0}catch(e){throw this.rollbackFailedStart(),e}}startupHost(){let{state:e,deps:t}=this;return{root:t.root,hydration:t.hydration,isRunning:()=>e.isRunning(),defer:t=>{e.deferredStart=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(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=Tt(t.root)?kt(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()&&(t.bus.attach(),t.emitter.emitWhile("init",{timestamp:Date.now()},()=>e.isRunning()),e.isRunning()))for(let n of Gr){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;let e=this.release();return this.state.suspended=!0,e&&this.deps.emitter.emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0}destroy(){let{state:e,deps:t}=this;if(!e.isRunning()&&!e.suspended)return;let n=!!e.isRunning()&&this.release();e.suspended=!1,n&&t.emitter.emit("disconnect",{reason:"destroy",timestamp:Date.now()}),t.a11y?.detach(),t.emitter.emit("destroy",{timestamp:Date.now()})}release(){let{state:e,deps:t}=this;e.activeUpdate=null,e.started=!1;let n=e.deferredStart;e.deferredStart=null,null!==n&&this.runCleanup(n);for(let t of e.readyTimers)this.runCleanup(()=>{clearTimeout(t)});return e.readyTimers.length=0,this.runCleanup(()=>{t.heartbeat.stop()}),this.runCleanup(()=>{t.bus.detach()}),e.abortStrategies(),this.runCleanup(()=>{this.rootSentinel?.disconnect(),this.rootSentinel=null,this.observedRoot=null}),this.runCleanup(()=>{t.observers.stop()}),this.runCleanup(()=>{t.scheduler.destroy()}),this.runCleanup(()=>{t.merger?.destroy(),e.merges.destroy()}),t.cache.clear(),t.connection.markDisconnected()}rollbackFailedStart(){this.release(),this.runCleanup(()=>{this.deps.a11y?.detach()})}runCleanup(e){try{e()}catch(e){this.deps.log("cleanup failed:",e)}}refreshCache(){this.state.isRunning()&&(this.state.revealer.reset(),this.followReplacedRoot()||this.rebuildCache())}watchRootReplacement(){let{root:e}=this.deps;!Tt(e)||typeof MutationObserver>"u"||(this.rootSentinel?.disconnect(),this.rootSentinel=new MutationObserver(()=>{this.followReplacedRoot()}),this.rootSentinel.observe(e.documentElement,{childList:!0}))}followReplacedRoot(){let{root:e}=this.deps;if(!this.state.isRunning()||!Tt(e))return!1;let t=kt(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(e,t){let{cache:n,scheduler:i}=e,r=t.protocol.negotiation,l=t.activeUpdate,o=t.lastFlush,a=[],s=new Set,u=[];for(let[e,t]of n.entries()){a.push(e);for(let n of t)void 0!==n.owner&&s.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:Wi,started:t.started,status:e.connection.status,origins:{trusted:[...e.readyTargets()],locked:e.lockedOrigin()},protocol:{ours:r.ours,theirs:r.theirs,negotiated:r.negotiated,capabilities:[...r.capabilities].sort(),observed:[...r.observed].sort(),profile:re(r.observed).name},revisions:{accepted:t.updateCount,superseded:t.supersededCount,completed:t.completedCount,skippedUnchanged:t.skippedUnchangedCount,active:null===l?void 0:l.revision.revision},bindings:{elements:n.elementCount,fields:n.fieldCount,fieldNames:a.sort(),absentFields:[...t.absentFields].sort(),orphanFields:[...t.warnedOrphanFields].sort(),ownerScoped:e.scopeBindingsByOwner,owners:[...s].sort(),guessed:u.sort((e,t)=>e.field.localeCompare(t.field)),autoBind:{mode:e.autoBind,searchMs:t.autoBindSearchMs}},route:{handler:void 0!==e.strategies.route,...t.routeStats},fidelity:{mode:e.onUnfaithfulPatch,canEscalate:void 0!==e.strategies.fragment||void 0!==e.strategies.route,unfaithful:t.unfaithfulCount,escalated:t.escalatedCount,fields:[...t.unfaithfulFields].sort()},hydration:{mode:e.hydration??"off",state:t.hydration},fragments:{handler:void 0!==e.strategies.fragment,inFlight:l?.pendingFragments??0,...t.fragmentStats},scheduler:{pending:i.pendingCount,deferred:i.replayCount,visibilityGateThreshold:i.gateThreshold,visibilityGateActive:i.gateActive,lastFlush:null===o?void 0:{applied:o.applied,appliedFields:o.appliedFields,deferred:o.deferred,durationMs:o.durationMs}},plugins:[],renderers:Object.keys(e.renderers).sort()}}(this.deps,this.state)}buildCacheAndObserve(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=t.cache.buildFromRoot(t.root);if(t.log("cache",n),e.isRunning()&&(t.emitter.emitWhile("cacheRefresh",n,()=>e.isRunning()),e.isRunning()))for(let n of t.cache.values()){if(!e.isRunning())return;t.observers.observeElement(n.element)}}rebuildCache(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=new Map;for(let e of t.cache.values())n.set(e.element,e),t.observers.unobserveElement(e.element);if(this.buildCacheAndObserve(),e.isRunning()){for(let e of t.cache.values())n.get(e.element)?.fieldName===e.fieldName?t.scheduler.retarget(e):t.scheduler.forget(e.element),n.delete(e.element);for(let e of n.values())t.scheduler.forget(e.element)}}onHeartbeatTimeout(){let{state:e,deps:t}=this;if(!e.isRunning())return;t.bus.advanceGeneration();let n=e.activeUpdate;e.activeUpdate=null,null!==n&&t.scheduler.cancelRevision(n.revision),t.merger?.destroy(),e.merges.destroy();let i=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}e.isRunning()&&(i&&this.isIdleDisconnected()&&(t.a11y?.announceDisconnected(),t.emitter.emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.isIdleDisconnected()),!e.isRunning()||(this.isIdleDisconnected()&&t.log("connection","connected","\\u2192","disconnected"),!e.isRunning()))||this.sendReadyAfterStart())}sendReadyAfterStart(){try{this.deps.sendReady(this.deps.readyTargets())}catch(e){this.reportError(e,"ready","LP0606")}}reportError(e,t,n){let i=e instanceof Error?e:new Error(String(e));this.deps.emitter.emit("error",{error:i,context:t,code:n})}isIdleDisconnected(){return this.state.isRunning()&&"disconnected"===this.deps.connection.status&&null===this.state.activeUpdate}},Kr=/^https?:\\/\\/(localhost|127\\.0\\.0\\.1)(?::\\d+)?$/i,Jr=/^https?:\\/\\/[^/?#\\s]+$/i,Xr=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],Qr=class{constructor(e={}){wn(this,Zr);let t=new Set;for(let n of e.additionalOrigins??[]){let e=Ct(n);void 0!==e&&t.add(e)}let n;if(e.enableReferrerDetection??1){let t=e.referrer??(typ','eof document<"u"?document.referrer:"");if(t.length>0)try{let e=new URL(t).origin;e&&"null"!==e&&(n=e)}catch{}}let i=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??function(){let e=function(){if(!(typ','eof process>"u"))return"production"}();if(void 0!==e)return"production"!==e;if(typ','eof window<"u"){let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}return!1}());Sn(this,Zr,[t,n,i,void 0!==n,void 0])}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==bn(this,Zr)[4]?e===bn(this,Zr)[4]:!!(bn(this,Zr)[0].has(e)||0===bn(this,Zr)[0].size&&void 0!==bn(this,Zr)[1]&&e===bn(this,Zr)[1]||bn(this,Zr)[2]&&Kr.test(e)))}lockOrigin(e){return!!this.matches(e)&&(bn(this,Zr)[4]=e,!0)}unlockOrigin(){let e=bn(this,Zr)[4];return bn(this,Zr)[4]=void 0,e}get lockedOrigin(){return bn(this,Zr)[4]}enumerate(){if(void 0!==bn(this,Zr)[4])return[bn(this,Zr)[4]];let e=new Set(bn(this,Zr)[0]);if(0===bn(this,Zr)[0].size&&void 0!==bn(this,Zr)[1]&&e.add(bn(this,Zr)[1]),bn(this,Zr)[2])for(let t of Xr)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return bn(this,Zr)[3]}get isProductionUnconfigured(){return!(!At()||bn(this,Zr)[0].size>0||bn(this,Zr)[2]||void 0!==bn(this,Zr)[1])}get isReferrerOnlyTrust(){return!(bn(this,Zr)[0].size>0||bn(this,Zr)[2])&&void 0!==bn(this,Zr)[1]}},Zr=new WeakMap,Yr={1:"left",2:"center",3:"right",4:"justify"},el=new Set(["left","center","right","justify","start","end"]),tl=new Set(["h1","h2","h3","h4","h5","h6"]),nl=\' target="_blank" rel="noopener noreferrer"\',il=(e,t)=>{let n=t.renderChildren(e.children??[]),i=xt(e.fields),r=function(e,t){if("internal"===t?.linkType)return function(e){let t=xt(xt(e)?.value),n=t?.url;if("string"==typeof n&&n.length>0)return n;let i=t?.slug;return"string"==typeof i&&i.length>0?`/${i}`:void 0}(t.doc);let n=t?.url??e.url;return"string"==typeof n&&n.length>0?n:void 0}(e,i);if(void 0===r||!$(r))return n;let l="string"==typeof e.title?` title="${Xe(e.title)}"`:"";return`<a href="${Qe(r)}"${function(e,t,n){if(!0===t?.newTab||R(n))return nl;let i="string"==typeof e.target?e.target:"";return""===i?"":"_blank"===i?nl:` target="${Xe(i)}"`}(e,i,r)}${l}>${n}</a>`},rl=new Map,ll=".lp-block:empty,.lp-inline-block:empty",ol={text:e=>{let t=Xe("string"==typeof e.text?e.text:""),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)=>{let n=t.renderChildren(e.children??[]);return`<p${Ft(e)}${Nt(e)}>${n}</p>`},heading:(e,t)=>{let n="string"==typeof e.tag?e.tag.toLowerCase():"h2",i=tl.has(n)?n:"h2",r=t.renderChildren(e.children??[]);return`<${i}${Ft(e)}${Nt(e)}>${r}</${i}>`},list:(e,t)=>{let n="string"==typeof e.listType?e.listType:"bullet",i="number"===n?"ol":"ul",r="number"===n&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",l="check"===n?\' role="list"\':"",o=t.renderChildren(e.children??[]);return`<${i}${Ft(e)}${Nt(e)}${r}${l}>${o}</${i}>`},listitem:(e,t)=>{let n=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${Nt(e)}>${n}</li>`;let i="number"==typeof e.value?` value="${Xe(String(e.value))}"`:"";return`<li${Ft(e)}${Nt(e)}${i}>${n}</li>`},link:il,autolink:il,quote:(e,t)=>{let n=t.renderChildren(e.children??[]);return`<blockquote${Ft(e)}${Nt(e)}>${n}</blockquote>`},code:e=>{let t=Et("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${Xe(Lt(e))}</code></pre>`},"code-highlight":e=>{let t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${Et(e.highlightType)}"`:""}>${Xe(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\\t",upload:e=>{let t=Mt(e.value);if(void 0===t)return"";let n=t.url;if("string"!=typeof n||!$(n))return"";let i="string"==typeof t.mimeType?t.mimeType:"";return i.startsWith("video/")?function(e,t){return`<video controls${Ut(e)}><source src="${Qe(t)}"${It(e)}></video>`}(t,n):i.startsWith("audio/")?function(e,t){return`<audio controls><source src="${Qe(t)}"${It(e)}></audio>`}(t,n):""===i||i.startsWith("image/")?function(e,t){let n="string"==typeof e.alt?Xe(e.alt):"";return`<img src="${Qe(t)}" alt="${n}"${Ut(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){let n="string"==typeof e.filename?Xe(e.filename):Xe(t);return`<a href="${Qe(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{let t="string"==typeof e.relationTo?e.relationTo:"",n=xt(e.value),i=Xe((n&&Pt(n))??`#${t}`),r=Et(t),l=""===r?\' class="lp-relation"\':` class="lp-relation lp-relation--${r}"`,o=n?.url;return"string"==typeof o&&$(o)?`<a href="${Qe(o)}"${l}>${i}</a>`:`<span${l}>${i}</span>`},block:(e,t)=>_t(e,t,"div","lp-block"),inlineBlock:(e,t)=>_t(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${Ft(e)}><tbody>${t.renderChildren(e.children??[])}</tbody></table>`,tablerow:(e,t)=>`<tr>${t.renderChildren(e.children??[])}</tr>`,tablecell:(e,t)=>{let n="number"==typeof e.headerState?e.headerState:0,i=3&n?"th":"td";return`<${i}${1===n?\' scope="col"\':2===n?\' scope="row"\':""}${Wt("colspan",e.colSpan)}${Wt("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${i}>`}},al=new Map,sl=!1,ul="data-payload-text",dl=new Set,cl=new Set,hl=new Set(["DIV","SECTION","ARTICLE"]),fl={name:"richText",render:N((e,t,n)=>{let i=e.element;if(it(t)){i.textContent="";return}let r=n.sanitizerPolicy;if(void 0!==n.renderRichText){let l=n.renderRichText(t,{fieldName:e.fieldName,element:i,locale:n.locale});i.innerHTML=Le(He(l,r));return}if(Bt(t)){let l=new Map,o=Ht(i,He(function(e,t={}){if(!Bt(e))return"";let n=function(e){let t={renderChildren:e=>{let n="";for(let i of e)n+=zt(i,t);return n},resolveAlignment:$t,resolveIndent:Rt,onUnrenderedBlock:e};return t}(t.onUnrenderedBlock).renderChildren(e.root.children);return!1===t.sanitize?n:void 0!==Ge()?function(e){return He(e,void 0,void 0)}(n):(function(){if(!sl){sl=!0;try{console.warn(\'[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; call setSanitizerDocument() (linkedom/jsdom) for server rendering, see "HTML sanitization" in docs/security.md.\')}catch{}}}(),n)}(t,{sanitize:!1,onUnrenderedBlock:(e,t)=>{l.set(t,e)}}),r));for(let[t,i]of o){let r=l.get(t);void 0!==r&&qt(e,n,r,i)}return}if("string"!=typeof t)return!1;i.innerHTML=Le(He(t,r))})},pl={name:"html",render(e,t,n){if(it(t)){e.element.textContent="";return}let i="string"==typeof t?t:nt(t);e.element.innerHTML=Le(He(i,n.sanitizerPolicy))}},ml=new WeakSet,gl=Jt("url"),vl=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,yl=Jt("email",function(e){let t=e.trim();return vl.test(t)||!t.includes("@")?t:`mailto:${t}`}),bl=["src","srcset","sizes"],wl={name:"image",render:N((e,t,n)=>{let i=e.element;if(it(t)){Yt(i);return}let r=void 0!==e.locale,{media:l,candidate:o}=function(e,t,n,i){let r=void 0!==e.srcField&&e.srcField.length>0?Fe(n.allFields,e.srcField,n.locale,i):t,l=Mt(r);return{media:l,candidate:void 0===l?r:l.url}}(e,t,n,r),a=Kt(i,e.fieldName,o);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===i.tagName){let t=i;Qt(t,a.url,l);let o=function(e,t,n,i,r){if(void 0!==t&&t.length>0){let e=Fe(n,t,i,r);return"string"==typeof e?e:void 0}return e?.alt}(l,e.altField,n.allFields,n.locale,r);void 0!==o&&(t.alt=o);return}i.style.backgroundImage=`url(\'${function(e){return e.replace(/[\'"()\\\\]/g,"\\\\$&")}(a.url)}\')`}else Yt(i)})},Sl={name:"upload",render:N((e,t)=>{let n=e.element;if(it(t)){en(n);return}let i=Mt(t);if(void 0===i)return!1;let r=Kt(n,e.fieldName,i.url);if("none"===r.kind)return!1;if("unsafe"===r.kind){en(n);return}let l=r.url;if("IMG"===n.tagName){let e=n;Qt(e,l,i),void 0!==i.alt&&(e.alt=i.alt);return}if("A"===n.tagName){n.setAttribute("href",l),n.textContent=i.filename??l;return}let o=Xe(i.filename??l);n.innerHTML=Le(`<a href="${Qe(l)}">${o}</a>`)})},Tl={name:"relationship",render(e,t){let n=e.element;if(it(t))n.removeAttribute("href"),n.textContent="";else{if("A"===n.tagName&&!Array.isArray(t)){let i=Kt(n,e.fieldName,xt(t)?.url);"safe"===i.kind?n.setAttribute("href",i.url):"unsafe"===i.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(tn).join(", "):tn(t)}}},kl={name:"select",render(e,t,n){let i=e.element,r=it(t)?[]:function(e){return Array.isArray(e)?e.map(nt):[nt(e)]}(t);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){let e=i;e.checked=r.includes(e.value);return}i.textContent=r.map(e=>function(e,t){let n=t.schema?.options;if(!Array.isArray(n))return e;for(let t of n){let n=xt(t);if(void 0!==n&&nt(n.value)===e)return"string"==typeof n.label?n.label:e}return e}(e,n)).join(", ")}else!function(e,t){if(e.multiple)for(let n of Array.from(e.options))n.selected=t.includes(n.value);else e.value=t[0]??""}(i,r)}},Al=new Set(["","false","0","off","no"]),Cl={name:"checkbox",render(e,t){let n=e.element,i=function(e){return"boolean"==typeof e?e:"string"==typeof e?!Al.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",i?"true":"false"):n.textContent=i?"true":"false":n.checked=i}},$l=new Map,Rl=new Map,Fl=new Set(["short","medium","long","full"]),Nl=new Set(["short","medium","long","full"]),xl=/^[A-Za-z]{3}$/u,Ml=/^[0-4]$/u,El=new WeakSet,Ol={name:"date",render(e,t,n){let i=e.element;if(it(t)){"INPUT"===i.tagName?i.value="":(i.removeAttribute("datetime"),i.textContent="");return}let r="number"==typeof t?t:nt(t),l=new Date(r),o=!Number.isNaN(l.getTime()),a=String(r);"INPUT"!==i.tagName?("TIME"===i.tagName&&i.setAttribute("datetime",o?l.toISOString():a),i.textContent=o?function(e,t,n){let i=t.locale??n.locale??s(),r=an("date",t.format,t.element,t.fieldName)??Pl;try{return function(e,t){let n=nn(e,t);return rt(Rl,n)??lt(Rl,n,new Intl.DateTimeFormat(e,t),64)}(i,r).format(e)}catch{return e.toISOString()}}(l,e,n):a):i.value=o?function(e,t){let n=`${String(t.getFullYear()).padStart(4,"0")}-${sn(t.getMonth()+1)}-${sn(t.getDate())}`,i=`${sn(t.getHours())}:${sn(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${i}`:"time"===e?i:t.toISOString()}(i.type,l):a}},Pl={dateStyle:"medium",timeStyle:"short"},Ll={name:"number",render(e,t,n){let i=e.element;if(it(t)){"INPUT"===i.tagName?i.value="":i.textContent="";return}let r="number"==typeof t?t:Number(nt(t));Number.isNaN(r)?i.textContent=nt(t):"INPUT"!==i.tagName?i.textContent=function(e,t,n){let i=t.locale??n.locale??s(),r=an("number",t.format,t.element,t.fieldName);try{return function(e,t){let n=nn(e,t);return rt($l,n)??lt($l,n,new Intl.NumberFormat(e,t),64)}(i,r).format(e)}catch{return String(e)}}(r,e,n):i.value=String(r)}},Ul={name:"array",render:N((e,t,n)=>{let i=e.element;if(it(t)){i.textContent="";return}if(!Array.isArray(t))return!1;let r=e.arrayTemplate;if(void 0!==r&&r.length>0){let e=function(e,t){let n=Ze(t),i="";for(let r=0;r<t.length;r+=1)i+=Ye(e,t[r],r,nt,n);return i}(r,t),l=n.sanitizerPolicy,o=ot(r),a=et(i);i.innerHTML=Le(He(e,l,o));for(let e of Array.from(i.children))tt(e,a);return}i.textContent=t.map(nt).join(e.arraySeparator??", ")})},Il=new Map;!function(){if(typ','eof window>"u"||!At()&&(typ','eof window>"u"||null==window.opener))return;let e=window.__livePreview,t=JSON.stringify(pn());if(void 0!==e&&(void 0===e.configSignature||e.configSignature===t))return e.refresh(),e;let[n=[],r="",l="/api",o=1,a=!1,s=50,u=!0,d=0,c=!1,h=50,f="200px",p=!0,m=!1,g=!1,v=!0,y="parent-or-opener",b="strict",w,S=!1,T=!1,k,A,C="off",$]=pn(),R=function(e){let t=typeof __LIVE_PREVIEW_FRAGMENT__<"u"?__LIVE_PREVIEW_FRAGMENT__:void 0,n=t??(typeof __LIVE_PREVIEW_ROUTE__<"u"?__LIVE_PREVIEW_ROUTE__:void 0);if(void 0===n)return;let i=n.createRouteStrategy();return void 0===t||void 0===e||""===e?{route:i}:{fragment:t.createFragmentStrategy({endpoint:e}),route:i}}(w),F=new Qr({additionalOrigins:n,enableReferrerDetection:!p,enableLocalhostMatching:!m});F.isProductionUnconfigured?An("[live-preview] LP0101: No trusted origin. Pass allowedOrigins to generateInlineScript() (or to the adapter) \\u2014 the runtime reads no environment variable in the browser."):F.isReferrerOnlyTrust&&An("[live-preview] LP0102: document.referrer fallback trusts any framing site. Set allowedOrigins and a frame-ancestors CSP in production.");let N=new $n,x=function(){let e=[fl,pl,gl,yl,wl,Sl,Tl,kl,{...kl,name:"radio"},Cl,Ol,Ll,Ul,{...Ul,name:"blocks"}];return function(e=[]){let t={};for(let n of e)t[n.name]=n;for(let[e,n]of Il)t[e]=n;return Object.freeze(t)}([Vt("text"),Vt("textarea"),...e,un()])}(),M=new qr({renderers:x,originMatcher:e=>F.matches(e),lockedOrigin:()=>F.lockedOrigin,readyTargets:()=>F.enumerate(),emitter:N,eventSourcePolicy:y,...""!==r?{dataMerge:{serverURL:r,apiRoute:l,depth:o}}:{},debounceMs:s,heartbeatMs:d,intersectionRootMargin:f,disableVisibilityGate:c,visibilityGateThreshold:h,enableA11y:u,scopeBindingsByOwner:g,skipUnchanged:v,revealEditedField:S,onUnfaithfulPatch:i({onUnfaithfulPatch:A,onUnboundChange:k}),autoBind:C,...void 0!==$?{hydration:$}:{},sanitizerPolicy:b,...void 0!==R?{strategies:R}:{},onHeartbeatTimeout:()=>{F.unlockOrigin()},...a?{log:(...e)=>{Cn("[live-preview]",...e)}}:{}});N.on("connect",e=>{F.lockOrigin(e.origin)}),M.start(),e?.destroy();let E=function(e,t={}){let n=t.windowTarget??globalThis.window,i=t.documentTarget??globalThis.document,r=t.softNavigationEvents??[],l=()=>{e.suspend()},o=t=>{!0===t.persisted&&e.resume()},a=()=>{e.refreshCache()};n?.addEventListener("pagehide",l),n?.addEventListener("pageshow",o);for(let e of r)i?.addEventListener(e,a);let s=!1;return()=>{if(!s){s=!0,n?.removeEventListener("pagehide",l),n?.removeEventListener("pageshow",o);for(let e of r)i?.removeEventListener(e,a)}}}({suspend:()=>M.suspend(),resume:()=>M.start(),refreshCache:()=>{M.refreshCache()}}),O=Object.freeze({version:Wi,configSignature:t,destroy:()=>{E(),M.destroy();let e=window;e.__livePreview===O&&delete e.__livePreview},refresh:()=>{M.refreshCache()},enumerateOrigins:()=>F.enumerate(),inspect:()=>M.inspect()});try{Object.defineProperty(window,"__livePreview",{value:O,writable:!1,configurable:!0})}catch(e){throw E(),M.destroy(),e}}()})();'].join(""),bo={generatedAt:"2026-10-03T23:41:51.000Z",size:114885},wo=/* @__PURE__ */['"use strict";var __LIVE_PREVIEW_FRAGMENT__=(()=>{var P=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var ee=Object.prototype.hasOwnProperty;var te=(e,t)=>{for(var n in t)P(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Z(t))!ee.call(e,r)&&r!==n&&P(e,r,{get:()=>t[r],enumerable:!(o=Q(t,r))||o.enumerable});return e};var re=e=>ne(P({},"__esModule",{value:!0}),e);var De={};te(De,{createFragmentStrategy:()=>J,createRouteStrategy:()=>X});function w(e,t){let n=new AbortController,o=!1,r=()=>{n.abort()};e.addEventListener("abort",r,{once:!0});let i=setTimeout(()=>{o=!0,n.abort()},t);return{signal:n.signal,timedOut:()=>o,dispose:()=>{clearTimeout(i),e.removeEventListener("abort",r)}}}function S(e){return e instanceof Error?e.message:String(e)}var A="data-payload-island",Le=`astro-island, [${A}]`;function oe(e){return e.tagName.toLowerCase()==="astro-island"||e.hasAttribute(A)}function ie(e){return e.getAttribute(A)==="patch"}function ae(e){return oe(e)&&!ie(e)}function _(e){let t=e;for(;t!==null;){if(ae(t))return!0;t=t.parentElement}return!1}function k(e){if(e==null)return[];let t=new Set,n=[];for(let o of e.split(/[\\s,]+/)){let r=o.trim();r.length===0||t.has(r)||(t.add(r),n.push(r))}return n}var b="data-payload-fragment";var N="data-payload-fragment-key",le="data-payload-depends";function I(e){let t=e.getAttribute(b);if(t===null||t.length===0)return null;let n=e.getAttribute(N);return{element:e,id:t,key:n===null||n.length===0?void 0:n,dependsOn:k(e.getAttribute(le))}}function L(e,t){let n=[];for(let o of e.querySelectorAll(`[${b}]`)){let r=I(o);r===null||_(o)||r.dependsOn.length>0&&!r.dependsOn.some(i=>t.has(i))||n.push(r)}return n}var B="x-payload-fragment-version";function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function C(e){if(!D(e))return null;let{html:t,boundary:n,revision:o,metadata:r}=e;return typeof t!="string"||!D(n)||typeof n.id!="string"||n.key!==void 0&&typeof n.key!="string"||typeof o!="number"||!D(r)||typeof r.renderedAt!="string"||typeof r.renderer!="string"?null:e}function U(e){let t={};for(let[n,o]of Object.entries(e))o!==void 0&&(t[n]=o);return t}function H(e){let t=0,n=[],o=()=>{let r=n.shift();r===void 0?t-=1:r()};return async r=>{t<e?t+=1:await new Promise(i=>{n.push(i)});try{return await r()}finally{o()}}}var de=5e3,ue=4,ce=512*1024,T={status:"superseded"};function h(e,t){return{status:"failed",code:e,reason:t}}function fe(e){let t=()=>{throw new TypeError(\'createFragmentStrategy: endpoint must be a same-origin path starting with "/"\')};if((typeof e!="string"||!e.startsWith("/")||e.startsWith("//")||e.includes("\\\\"))&&t(),typeof location<"u"){let n;try{n=new URL(e,location.href)}catch{n=void 0}n?.origin!==location.origin&&t()}return e}function me(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}async function ye(e,t,n){let o=e.body;if(!me(o)){let d=await e.text();return new TextEncoder().encode(d).byteLength>t?null:d}let r=o.getReader(),i=()=>{r.cancel().catch(()=>{})};n.addEventListener("abort",i,{once:!0});let s=new TextDecoder,a="",c=0;try{for(;;){let{done:d,value:p}=await r.read();if(d)break;if(c+=p.byteLength,c>t)return i(),null;a+=s.decode(p,{stream:!0})}}finally{n.removeEventListener("abort",i)}return a+s.decode()}function K(e){let t=fe(e.endpoint),n=e.timeoutMs??de,o=e.maxResponseBytes??ce,r=H(Math.max(1,e.maxConcurrent??ue)),i=new Map;async function s(a,c){let d=()=>a.signal.aborted;if(d())return T;let p=e.location??location,f=U({fragment:c.id,key:c.key,route:p.pathname,search:p.search,revision:a.revision,locale:a.locale,collectionSlug:a.collectionSlug,globalSlug:a.globalSlug,fields:a.fields}),l=w(a.signal,n),y=u=>d()?T:l.timedOut()?h("LP0801",`timeout after ${String(n)} ms`):h("LP0801",S(u));try{let u;try{u=await(e.fetch??fetch)(t,{method:"POST",credentials:"same-origin",headers:{...e.headers,accept:"application/json","content-type":"application/json",[B]:String(1)},body:JSON.stringify(f),signal:l.signal})}catch(M){return y(M)}if(d())return T;if(u.status===401||u.status===403)return h("LP0803",`endpoint refused the preview (${String(u.status)})`);if(!u.ok)return h("LP0801",`endpoint answered ${String(u.status)}`);let g=u.headers.get("content-type")??"";if(!g.toLowerCase().startsWith("application/json"))return h("LP0802",`unexpected content type "${g}"`);if(Number(u.headers.get("content-length")??"0")>o)return h("LP0802","response exceeds the size limit");let E;try{E=await ye(u,o,l.signal)}catch(M){return y(M)}if(d())return T;if(l.timedOut())return h("LP0801",`timeout after ${String(n)} ms`);if(E===null)return h("LP0802","response exceeds the size limit");let x;try{x=JSON.parse(E)}catch{return h("LP0802","response is not JSON")}let R=C(x);return R===null?h("LP0802","response has the wrong shape"):R.boundary.id!==c.id?h("LP0802","response is for another boundary"):R.revision!==a.revision?T:{status:"rendered",html:R.html,metadata:R.metadata}}finally{l.dispose()}}return(a,c)=>{let d=`${c.id} ${c.key??""} ${String(a.revision)}`,p=i.get(d);if(p!==void 0)return p;let f=r(()=>s(a,c));i.set(d,f);let l=()=>{i.get(d)===f&&i.delete(d)};return f.then(l,l),f}}var O="data-payload-owned",pe=new Set(["open","value","checked","selected"]);function q(e,t){for(let n of t.keyAttributes){let o=e.getAttribute(n);if(o!==null&&o.length>0)return`${n}=${o}`}}function F(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(A)||e.hasAttribute(O))return!0;let t=e.getAttribute("contenteditable");return t!==null&&t!=="false"}function ge(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!F(e)&&!F(t)}function v(e,t,n){if(!ge(e,t))return t;let o=Re(e);return he(e,t),n.retainChildrenOf?.(e,t)!==!0&&Ee(e,t,n),Ae(o),e}function he(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||pe.has(n.name.toLowerCase())||e.removeAttribute(n.name);for(let n of Array.from(t.attributes))e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function Ee(e,t,n){let o=be(e,n),r=new Set(o.values()),i=Array.from(e.childNodes).filter(f=>!r.has(f)),s=new Set,a=new Set,c=Array.from(t.childNodes),d=e.firstChild,p=0;for(let f=0;f<c.length;f+=1){let l=c[f],y=null,u=l instanceof Element?q(l,n):void 0;if(u!==void 0&&a.has(u)&&(u=void 0),u!==void 0){a.add(u);let m=o.get(u);if(m!==void 0&&!s.has(m)&&(y=$(m,l,n)===m?m:null,y===null)){m.replaceWith(l),s.add(l),d=l.nextSibling;continue}}else{for(;p<i.length;){let m=i[p];if(p+=1,!s.has(m)){if(G(m,l)){y=$(m,l,n)===m?m:null,y===null&&(e.replaceChild(l,m),s.add(l),d=l.nextSibling);break}if(m instanceof Element){let E=c[f+1];if(!(l instanceof Element)||E!==void 0&&G(m,E)){p-=1;break}e.replaceChild(l,m),s.add(l),d=l.nextSibling;break}if(!(l instanceof Element)){e.replaceChild(l,m),s.add(l),d=l.nextSibling;break}}}if(y===null&&s.has(l))continue}let g=y??l;for(s.add(g);d!==null&&d!==g&&!s.has(d)&&Se(d);)d=d.nextSibling;g!==d&&e.insertBefore(g,d),d=g.nextSibling}for(let f of Array.from(e.childNodes))s.has(f)||f.remove()}function $(e,t,n){return e instanceof Element&&t instanceof Element?F(e)&&F(t)?e:v(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function Se(e){return e.nodeType===Node.TEXT_NODE&&(e.nodeValue??"").trim().length===0}function G(e,t){return e.nodeType!==t.nodeType?!1:e instanceof Element&&t instanceof Element?e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI:!0}function be(e,t){let n=new Map,o;for(let r of Array.from(e.children)){let i=q(r,t);if(i!==void 0){if(n.has(i)){o??(o=i.slice(i.indexOf("=")+1));continue}n.set(i,r)}}return o!==void 0&&t.onDuplicateKey?.(e,o),n}function Re(e){let t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement)||!e.contains(t))return null;let n=t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null;return{element:t,selection:n}}function Ae(e){if(e===null)return;let{element:t,selection:n}=e;if(!(t.ownerDocument.activeElement===t||!t.isConnected))try{t.focus({preventScroll:!0});let[o,r]=n??[null,null];o!==null&&r!==null&&t.setSelectionRange(o,r)}catch{}}var W="data-payload-key";var Te="__livePreviewRouteRefresh";function xe(){return typ','eof window>"u"?void 0:window}function z(){return xe()?.[Te]}var j="data-payload-strategy",Y="data-payload-field",we="data-payload-depends",ke="x-payload-live-preview",Fe=8e3,Oe=1e3;function Me(e){let t=e.getAttribute(j);return t!==null?t==="route":e.closest("head")!==null}function Pe(e){let t=e.getAttribute(Y),n=k(e.getAttribute(we));return t===null||t.length===0?n:[t,...n]}function V(e){if(e.tagName==="META"){let t=e.getAttribute("name")??e.getAttribute("property");return t===null?null:`meta:${t}`}return e.tagName==="LINK"&&e.getAttribute("rel")==="canonical"?"link:canonical":null}function Ne(e,t){t.title!==e.title&&(e.title=t.title);let n=new Map;for(let r of e.head.querySelectorAll("meta, link")){let i=V(r);i!==null&&!n.has(i)&&n.set(i,r)}let o=new Set;for(let r of t.head.querySelectorAll("meta, link")){let i=V(r);if(i===null)continue;o.add(i);let s=n.get(i);if(s===void 0){e.head.append(e.importNode(r,!0));continue}if(!s.hasAttribute(O))for(let a of Array.from(r.attributes))s.getAttribute(a.name)!==a.value&&s.setAttribute(a.name,a.value)}for(let[r,i]of n)!o.has(r)&&!i.hasAttribute(O)&&i.remove()}function X(e={}){let t=e.timeoutMs??Fe,n=e.minIntervalMs??Oe,o=-1/0;return{plan(r,i){for(let s of r.querySelectorAll(`[${Y}], [${j}="route"]`)){if(!Me(s))continue;let a=Pe(s);if(a.length===0||a.some(c=>i.has(c)))return!0}return!1},async refresh(r){let i=Date.now(),s=n-(i-o);if(s>0)return r.retryAfter?.(s),r.log("LP0805",`route refresh for revision ${String(r.revision)} refused: the previous one was ${String(i-o)} ms ago`),"refused";o=i;let a=e.document??document,c=e.location??location,d=e.window??window,p=w(r.signal,t),f=l=>{if(r.signal.aborted)return"superseded";let y=p.timedOut()?`route refresh timed out after ${String(t)} ms`:S(l);return r.log("LP0801",y),"failed"};try{let l=z();if(l!==void 0){try{await l()}catch(u){return f(u)}return r.isCurrent()?"refreshed":"superseded"}let y;try{y=await(e.fetch??fetch)(c.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[ke]:"route"},signal:p.signal})}catch(u){return f(u)}if(r.signal.aborted)return"superseded";if(!y.ok||!(y.headers.get("content-type")??"").includes("text/html"))return r.log("LP0802",`route answered ${String(y.status)} ${y.headers.get("content-type")??""}`),"failed";try{let u=await y.text();if(!r.isCurrent())return"superseded";let g=new DOMParser().parseFromString(u,"text/html"),m=d.scrollX,E=d.scrollY;return Ne(a,g),v(a.body,g.body,{keyAttributes:[W,N,b],retainChildrenOf:x=>x.hasAttribute(b)}),d.scrollTo(m,E),"refreshed"}catch(u){return f(u)}}finally{p.dispose()}}}}function Ie(e){return{plan:(t,n)=>L(t,n).map(o=>o.element),async render(t,n){let o={rendered:0,failed:0,superseded:0},r={revision:t.revision,receivedAt:t.receivedAt,fields:t.fields,locale:t.locale,collectionSlug:t.collectionSlug,globalSlug:t.globalSlug,signal:t.signal};return await Promise.all(n.map(async i=>{let s=I(i);if(s===null)return;let a;try{a=await e(r,s)}catch(c){a={status:"failed",code:"LP0801",reason:S(c)}}if(!t.isCurrent()||a.status==="superseded"){o.superseded+=1,t.log("LP0804",`fragment "${s.id}" for revision ${String(r.revision)} discarded as superseded`);return}if(a.status==="rendered"){t.morph(i,a.html),t.rendered(i,s.id,s.key),o.rendered+=1;return}t.failed(i,s.id,s.key,a.code,a.reason),t.isCurrent()&&t.patch(i),o.failed+=1})),o}}}function J(e){return Ie(K(e))}return re(De);})();'].join(""),So=/* @__PURE__ */['"use strict";var __LIVE_PREVIEW_ROUTE__=(()=>{var S=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var $=(e,n)=>{for(var t in n)S(e,t,{get:n[t],enumerable:!0})},H=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of L(n))!K.call(e,r)&&r!==t&&S(e,r,{get:()=>n[r],enumerable:!(o=U(n,r))||o.enumerable});return e};var z=e=>H(S({},"__esModule",{value:!0}),e);var ae={};$(ae,{createRouteStrategy:()=>B});var A="data-payload-island",se=`astro-island, [${A}]`;var b="data-payload-owned",W=new Set(["open","value","checked","selected"]);function k(e,n){for(let t of n.keyAttributes){let o=e.getAttribute(t);if(o!==null&&o.length>0)return`${t}=${o}`}}function E(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(A)||e.hasAttribute(b))return!0;let n=e.getAttribute("contenteditable");return n!==null&&n!=="false"}function q(e,n){return e.tagName===n.tagName&&e.namespaceURI===n.namespaceURI&&!E(e)&&!E(n)}function R(e,n,t){if(!q(e,n))return n;let o=X(e);return Y(e,n),t.retainChildrenOf?.(e,n)!==!0&&G(e,n,t),J(o),e}function Y(e,n){for(let t of Array.from(e.attributes))n.hasAttribute(t.name)||W.has(t.name.toLowerCase())||e.removeAttribute(t.name);for(let t of Array.from(n.attributes))e.getAttribute(t.name)!==t.value&&e.setAttribute(t.name,t.value)}function G(e,n,t){let o=j(e,t),r=new Set(o.values()),l=Array.from(e.childNodes).filter(m=>!r.has(m)),a=new Set,f=new Set,g=Array.from(n.childNodes),s=e.firstChild,y=0;for(let m=0;m<g.length;m+=1){let i=g[m],u=null,c=i instanceof Element?k(i,t):void 0;if(c!==void 0&&f.has(c)&&(c=void 0),c!==void 0){f.add(c);let d=o.get(c);if(d!==void 0&&!a.has(d)&&(u=x(d,i,t)===d?d:null,u===null)){d.replaceWith(i),a.add(i),s=i.nextSibling;continue}}else{for(;y<l.length;){let d=l[y];if(y+=1,!a.has(d)){if(w(d,i)){u=x(d,i,t)===d?d:null,u===null&&(e.replaceChild(i,d),a.add(i),s=i.nextSibling);break}if(d instanceof Element){let h=g[m+1];if(!(i instanceof Element)||h!==void 0&&w(d,h)){y-=1;break}e.replaceChild(i,d),a.add(i),s=i.nextSibling;break}if(!(i instanceof Element)){e.replaceChild(i,d),a.add(i),s=i.nextSibling;break}}}if(u===null&&a.has(i))continue}let p=u??i;for(a.add(p);s!==null&&s!==p&&!a.has(s)&&V(s);)s=s.nextSibling;p!==s&&e.insertBefore(p,s),s=p.nextSibling}for(let m of Array.from(e.childNodes))a.has(m)||m.remove()}function x(e,n,t){return e instanceof Element&&n instanceof Element?E(e)&&E(n)?e:R(e,n,t):(e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue),e)}function V(e){return e.nodeType===Node.TEXT_NODE&&(e.nodeValue??"").trim().length===0}function w(e,n){return e.nodeType!==n.nodeType?!1:e instanceof Element&&n instanceof Element?e.tagName===n.tagName&&e.namespaceURI===n.namespaceURI:!0}function j(e,n){let t=new Map,o;for(let r of Array.from(e.children)){let l=k(r,n);if(l!==void 0){if(t.has(l)){o??(o=l.slice(l.indexOf("=")+1));continue}t.set(l,r)}}return o!==void 0&&n.onDuplicateKey?.(e,o),t}function X(e){let n=e.ownerDocument.activeElement;if(!(n instanceof HTMLElement)||!e.contains(n))return null;let t=n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement?[n.selectionStart,n.selectionEnd]:null;return{element:n,selection:t}}function J(e){if(e===null)return;let{element:n,selection:t}=e;if(!(n.ownerDocument.activeElement===n||!n.isConnected))try{n.focus({preventScroll:!0});let[o,r]=t??[null,null];o!==null&&r!==null&&n.setSelectionRange(o,r)}catch{}}var I="data-payload-key";function N(e){if(e==null)return[];let n=new Set,t=[];for(let o of e.split(/[\\s,]+/)){let r=o.trim();r.length===0||n.has(r)||(n.add(r),t.push(r))}return t}var Q="__livePreviewRouteRefresh";function Z(){return typ','eof window>"u"?void 0:window}function M(){return Z()?.[Q]}var T="data-payload-fragment";function v(e,n){let t=new AbortController,o=!1,r=()=>{t.abort()};e.addEventListener("abort",r,{once:!0});let l=setTimeout(()=>{o=!0,t.abort()},n);return{signal:t.signal,timedOut:()=>o,dispose:()=>{clearTimeout(l),e.removeEventListener("abort",r)}}}function D(e){return e instanceof Error?e.message:String(e)}var P="data-payload-fragment-key";var C="data-payload-strategy",_="data-payload-field",ee="data-payload-depends",ne="x-payload-live-preview",te=8e3,re=1e3;function oe(e){let n=e.getAttribute(C);return n!==null?n==="route":e.closest("head")!==null}function le(e){let n=e.getAttribute(_),t=N(e.getAttribute(ee));return n===null||n.length===0?t:[n,...t]}function O(e){if(e.tagName==="META"){let n=e.getAttribute("name")??e.getAttribute("property");return n===null?null:`meta:${n}`}return e.tagName==="LINK"&&e.getAttribute("rel")==="canonical"?"link:canonical":null}function ie(e,n){n.title!==e.title&&(e.title=n.title);let t=new Map;for(let r of e.head.querySelectorAll("meta, link")){let l=O(r);l!==null&&!t.has(l)&&t.set(l,r)}let o=new Set;for(let r of n.head.querySelectorAll("meta, link")){let l=O(r);if(l===null)continue;o.add(l);let a=t.get(l);if(a===void 0){e.head.append(e.importNode(r,!0));continue}if(!a.hasAttribute(b))for(let f of Array.from(r.attributes))a.getAttribute(f.name)!==f.value&&a.setAttribute(f.name,f.value)}for(let[r,l]of t)!o.has(r)&&!l.hasAttribute(b)&&l.remove()}function B(e={}){let n=e.timeoutMs??te,t=e.minIntervalMs??re,o=-1/0;return{plan(r,l){for(let a of r.querySelectorAll(`[${_}], [${C}="route"]`)){if(!oe(a))continue;let f=le(a);if(f.length===0||f.some(g=>l.has(g)))return!0}return!1},async refresh(r){let l=Date.now(),a=t-(l-o);if(a>0)return r.retryAfter?.(a),r.log("LP0805",`route refresh for revision ${String(r.revision)} refused: the previous one was ${String(l-o)} ms ago`),"refused";o=l;let f=e.document??document,g=e.location??location,s=e.window??window,y=v(r.signal,n),m=i=>{if(r.signal.aborted)return"superseded";let u=y.timedOut()?`route refresh timed out after ${String(n)} ms`:D(i);return r.log("LP0801",u),"failed"};try{let i=M();if(i!==void 0){try{await i()}catch(c){return m(c)}return r.isCurrent()?"refreshed":"superseded"}let u;try{u=await(e.fetch??fetch)(g.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[ne]:"route"},signal:y.signal})}catch(c){return m(c)}if(r.signal.aborted)return"superseded";if(!u.ok||!(u.headers.get("content-type")??"").includes("text/html"))return r.log("LP0802",`route answered ${String(u.status)} ${u.headers.get("content-type")??""}`),"failed";try{let c=await u.text();if(!r.isCurrent())return"superseded";let p=new DOMParser().parseFromString(c,"text/html"),d=s.scrollX,h=s.scrollY;return ie(f,p),R(f.body,p.body,{keyAttributes:[I,P,T],retainChildrenOf:F=>F.hasAttribute(T)}),s.scrollTo(d,h),"refreshed"}catch(c){return m(c)}}finally{y.dispose()}}}}return z(ae);})();'].join(""),Ao=["allowedOrigins","serverURL","apiRoute","mergeDepth","debug","debounceMs","enableA11y","heartbeatMs","disableVisibilityGate","visibilityGateThreshold","intersectionRootMargin","disableReferrerDetection","disableLocalhostMatching","scopeBindingsByOwner","skipUnchanged","eventSourcePolicy","sanitizerPolicy","fragmentEndpoint","revealEditedField","routeStrategy","onUnboundChange","onUnfaithfulPatch","autoBind","hydration","defaults"];function ko(e,t){if(0===e.length)throw new Error(`[live-preview] ${t} is empty. Run \`npm run build:runtime\` before bundling.`)}function To(e){return null!=e.fragmentEndpoint?(ko(wo,"fragment.generated.ts"),[wo]):!0===e.routeStrategy?(ko(So,"route.generated.ts"),[So]):[]}function Co(e){return`var __LIVE_PREVIEW_CONFIG__=${function(e){t(e);const n=function(e){const t=e.defaults??"v2";return"v1"===t?{...ho,defaults:t}:{defaults:t}}(e);return`[${Ao.map(t=>e[t]??n[t]).map(e=>void 0===e?"":JSON.stringify(e)).join(",")}]`.replace(/</g,"\\u003C")}(e)};`}var $o,xo=/[\t\n\f\r ]+/;function Ro(e,t){const n=e.charCodeAt(t);return 9===n||10===n||12===n||13===n||32===n}function No(e){let t=0,n=e.length;for(;t<n&&Ro(e,t);)t+=1;for(;n>t&&Ro(e,n-1);)n-=1;return 0===t&&n===e.length?e:e.slice(t,n)}function Po(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function Eo(e,t){const n=/* @__PURE__ */new Map;for(const t of e.split(";")){const e=No(t);if(0===e.length)continue;const r=e.search(xo),i=Po(r<0?e:e.slice(0,r));if(n.has(i))continue;const o=r<0?"":No(e.slice(r));n.set(i,o)}for(const[e,r]of Object.entries(t)){const t=Po(e),i="string"==typeof r?{value:r}:r,o=i.mode??"union",s=n.get(t);if("replace"===o||void 0===s||0===s.length){n.set(t,i.value);continue}const a=/* @__PURE__ */new Set,l=[];for(const e of[...s.split(xo),...i.value.split(xo)])0===e.length||a.has(e)||(a.add(e),l.push(e));const u=l.filter(e=>"'none'"!==e);n.set(t,(u.length>0?u:l).join(" "))}const r=[];for(const[e,t]of n)r.push(0===t.length?e:`${e} ${t}`);return r.join("; ")}var Fo="payload-live-preview.authorized-preview-context",Lo=Symbol.for(Fo);function isAuthorizedPreviewContext(e){return"object"==typeof e&&null!==e&&!0===e[Lo]&&Object.isFrozen(e)}function Mo(e){return Object.freeze({...e,scope:Object.freeze({...e.scope}),payloadHeaders:Object.freeze({...e.payloadHeaders}),[Lo]:!0,[Fo]:!0})}var Oo=class extends Error{name="PreviewConfigurationError"};function Uo(e){return{authorized:!1,outcome:e,context:null}}var Io="users",_o=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,jo=/^[A-Za-z0-9._~-]+$/;var Do,zo="live-preview",Bo="v1";function Wo(){return Do??=new TextEncoder,Do}function Ho(e){const t="string"==typeof e?Wo().encode(e):e;if(t.byteLength<32)throw new Oo(`payload-live-preview: the preview token secret must be at least ${String(32)} bytes`);return t}function Vo(e){if(void 0!==e)return e;const t=globalThis.crypto;return"object"==typeof t?.subtle?t:void 0}async function qo(e,t){return e.subtle.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}function Go(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ko(e){if(!/^[A-Za-z0-9_-]*$/.test(e))return;const t=e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4);try{const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t+=1)n[t]=e.charCodeAt(t);return n}catch{return}}var Jo=["preview","draft","livePreview"];function Zo(e,t={}){const n=new Set(t.signals??["query","fetch-dest","referer"]),r=t.queryParams??Jo;if(n.has("query")){let t;try{t=new URL(e.url)}catch{t=void 0}if(void 0!==t)for(const e of r){const n=t.searchParams.getAll(e).at(-1);if("true"===n||"1"===n)return!0}}if(n.has("fetch-dest")&&"iframe"===e.headers.get("sec-fetch-dest"))return!0;const i=t.allowedOrigins??t.adminOrigins??[],o=n.has("referer")?i:[];if(o.length>0){const t=e.headers.get("referer");if(null!==t)try{const e=new URL(t).origin;for(const t of o)try{if(new URL(t).origin===e)return!0}catch{}}catch{}}return!1}var Xo=Zo,Qo="payload-live-preview-highlight",Yo=/* @__PURE__ */new WeakMap,es=/* @__PURE__ */new WeakMap,ts={name:"highlight",version:"1.0.0",init:e=>{if("undefined"==typeof document||"undefined"==typeof window)return;const t="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,n=function(e,t){let n=Yo.get(e);void 0===n||n.connected()||(Yo.delete(e),n=void 0),void 0===n&&(n=function(e,t){const n=e.getElementById(Qo);if(n instanceof HTMLStyleElement)return{pluginOwned:!1,connected:()=>n.isConnected,remove:()=>{},owners:0};const r=function(e,t){try{if(!Array.isArray(e.adoptedStyleSheets)||"function"!=typeof CSSStyleSheet)return;const n=new CSSStyleSheet;if("function"!=typeof n.replaceSync)return;return n.replaceSync(t),e.adoptedStyleSheets=[...e.adoptedStyleSheets,n],n}catch{return}}(e,t);if(void 0!==r)return{pluginOwned:!0,connected:()=>e.adoptedStyleSheets.includes(r),remove:()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==r)},owners:0};const i=e.createElement("style");return i.id=Qo,i.textContent=t,e.head.appendChild(i),{pluginOwned:!0,connected:()=>i.isConnected,remove:()=>{i.remove()},owners:0}}(e,t?".lp-highlight{outline:2px solid rgba(0,102,204,0.85);outline-offset:2px;}":"@keyframes lp-highlight{0%{outline:2px solid rgba(0,102,204,0.85);outline-offset:2px}100%{outline:2px solid transparent;outline-offset:2px}}.lp-highlight{animation:lp-highlight 0.6s ease-out;}"),Yo.set(e,n));const r=n;r.owners+=1;let i=!0;return()=>{i&&(i=!1,r.owners-=1,r.owners>0||(Yo.get(e)===r&&Yo.delete(e),r.pluginOwned&&r.remove()))}}(document,t),r=t?1e3:600,i=/* @__PURE__ */new WeakMap,o=/* @__PURE__ */new Set;e.registerCleanup?.(()=>{for(const e of[...o])e();n()}),e.events.on("elementUpdate",e=>{const t=e.element;i.get(t)?.();const n=function(e){let t=es.get(e);void 0===t&&(t={owners:0,pluginAdded:!e.classList.contains("lp-highlight")},es.set(e,t));const n=t;n.owners+=1,e.classList.add("lp-highlight");let r=!0;return()=>{r&&(r=!1,n.owners-=1,n.owners>0||(es.delete(e),n.pluginAdded&&e.classList.remove("lp-highlight")))}}(t);let s=!1;const a=()=>{s||(s=!0,window.clearTimeout(l),i.get(t)===a&&i.delete(t),o.delete(a),n())},l=window.setTimeout(a,r);o.add(a),i.set(t,a)})}},ns={name:"debug",version:"1.0.0",init:e=>{e.events.on("init",()=>{e.log("init")}),e.events.on("connect",t=>{e.log("connect ←",t.origin)}),e.events.on("disconnect",t=>{e.log("disconnect (",t.reason,")")}),e.events.on("cacheRefresh",t=>{e.log("cacheRefresh",t.elementCount,"elements,",t.fieldCount,"fields")}),e.events.on("beforeUpdate",t=>{e.log("beforeUpdate",Object.keys(t.data.fields).length,"fields")}),e.events.on("afterUpdate",t=>{e.log("afterUpdate",t.updatedCount,"in",t.durationMs.toFixed(2),"ms")}),e.events.on("error",t=>{e.log("error in",t.context,":",t.error.message)})}},rs="payload-live-preview:scroll";function is(){"undefined"!=typeof window&&(function(){if("undefined"!=typeof window)try{sessionStorage.setItem(rs,JSON.stringify({href:window.location.href,x:window.scrollX,y:window.scrollY}))}catch{}}(),window.location.reload())}function bind(e,t){return os(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 os(n.join("."),t)}function os(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),n}var ss=/^[a-z][a-z0-9-]{0,63}$/u,as=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):as,bindByPath:(e,n)=>t?bindByPath(e,n):as,owner:()=>t&&void 0!==n?{"data-payload-owner":n}:as,boundary:(e,n={})=>{const r=function(e,t){if(!ss.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:as}})}exports.AUTHORIZED_PREVIEW_BRAND_KEY=Fo,exports.CAPABILITY_DECLARATIONS=f,exports.CAPABILITY_DOCUMENTATION={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"}},exports.DIAGNOSTIC_CODES=vo,exports.EventEmitter=EventEmitter,exports.ISLAND_EVENT=Ee,exports.LIBRARY_PROTOCOL_VERSION=4,exports.LivePreviewClient=LivePreviewClient,exports.OriginDetector=OriginDetector,exports.PROTOCOL_CAPABILITIES=h,exports.TRUSTED_TYPES_POLICY_NAME=rn,exports.VERSION=e,exports.authorizePreviewRequest=async function(e,t){switch(t.type){case"payload-session":return async function(e,t){const n=function(e){const t=e??"payload-token";if(!_o.test(t))throw new Oo(`payload-live-preview: cookie name "${t}" is not a valid cookie-name token`);return t}(t.cookieName),r=function(e){let t;try{t=new URL(e)}catch{throw new Oo(`payload-live-preview: serverURL "${e}" is not an absolute URL`)}if("https:"!==t.protocol&&"http:"!==t.protocol)throw new Oo(`payload-live-preview: serverURL must be http(s), got "${t.protocol}"`);return t.origin}(t.serverURL),i=function(e,t,n=4096){if(null===e||0===e.length)return null;const r=`${t}=`,i=[];for(const t of e.split(";")){const e=t.trim();e.startsWith(r)&&i.push(e.slice(r.length))}if(1!==i.length)return null;const o=i[0]??"";return 0===o.length||o.length>n||!jo.test(o)?null:o}(e.headers.get("cookie"),n,t.maxCookieLength??4096);if(null===i)return Uo("missing-credential");const o=t.now??Date.now,s=Math.max(250,t.timeoutMs??3e3),a=t.fetch??globalThis.fetch,l=encodeURIComponent(t.usersSlug??Io),u=`${n}=${i}`;let d;try{const e=await a(`${r}/api/${l}/me?depth=0`,{headers:{cookie:u,accept:"application/json"},signal:AbortSignal.timeout(s)});if(!e.ok)return Uo(401===e.status?"invalid":"unavailable");d=await e.json()}catch{return Uo("unavailable")}const c=function(e,t){if("object"!=typeof e||null===e||Array.isArray(e))return null;const n=e.user;if("object"!=typeof n||null===n||Array.isArray(n))return null;const r=e.collection??n.collection;if(void 0!==r&&r!==t)return null;const i=n.id;return"string"==typeof i&&i.length>0?i:"number"==typeof i&&Number.isFinite(i)?String(i):null}(d,t.usersSlug??Io);if(null===c)return Uo("invalid");const f=function(e){const t=e.exp;return"number"!=typeof t||!Number.isFinite(t)||t<=0?void 0:t<1e11?1e3*t:t}(d);return void 0!==f&&f<=o()?Uo("expired"):{authorized:!0,outcome:"authorized",context:Mo({strategy:"payload-session",subject:c,authorizedAt:o(),expiresAt:f,scope:{},payloadHeaders:{cookie:u}})}}(e,t);case"signed-token":return async function(e,t){const n=Ho(t.secret),r=Vo(t.crypto);if(void 0===r)return Uo("unavailable");const i=function(e,t){if("header"===t?.kind)return e.headers.get(t.name??"x-preview-token");let n;try{n=new URL(e.url)}catch{return null}const r=n.searchParams.getAll(t?.param??"previewToken");return 1===r.length?r[0]??null:null}(e,t.transport);if(null===i||0===i.length)return Uo("missing-credential");if(i.length>4096)return Uo("invalid");const o=i.split(".");if(3!==o.length||o[0]!==Bo)return Uo("invalid");const s=o[1]??"",a=Ko(s),l=Ko(o[2]??"");if(void 0===a||32!==l?.byteLength)return Uo("invalid");let u;try{const e=await qo(r,n);u=await r.subtle.verify("HMAC",e,l,Wo().encode(`${Bo}.${s}`))}catch{return Uo("unavailable")}if(!u)return Uo("invalid");const d=function(e){let t;try{t=JSON.parse((new TextDecoder).decode(e))}catch{return}if("object"!=typeof t||null===t)return;const n=t,r=e=>void 0===n[e]||"string"==typeof n[e];return 1===n.v&&"string"==typeof n.aud&&"string"==typeof n.pur&&"number"==typeof n.iat&&"number"==typeof n.exp&&"string"==typeof n.jti&&r("pth")&&r("loc")&&r("sub")?n:void 0}(a);if(void 0===d)return Uo("invalid");const c=(t.now??Date.now)();if(d.exp<=c||d.iat>d.exp)return Uo("expired");if(d.aud!==t.audience)return Uo("wrong-audience");if(d.pur!==(t.purpose??zo))return Uo("wrong-purpose");if(void 0!==d.pth){let t;try{t=new URL(e.url).pathname}catch{return Uo("invalid")}if(d.pth!==t)return Uo("wrong-path")}if(void 0!==d.loc){const n=t.locale?.(e);if(n!==d.loc)return Uo("wrong-locale")}if(void 0!==t.replay){let e;try{e=await async function(e,t,n){return"consume"in e?!0===await e.consume(t,n):!await e.isUsed(t)&&(await e.markUsed(t,n),!0)}(t.replay,d.jti,d.exp)}catch{return Uo("unavailable")}if(!e)return Uo("replayed")}return{authorized:!0,outcome:"authorized",context:Mo({strategy:"signed-token",subject:d.sub,authorizedAt:c,expiresAt:d.exp,scope:{audience:d.aud,...void 0!==d.pth?{path:d.pth}:{},...void 0!==d.loc?{locale:d.loc}:{}},payloadHeaders:{}})}}(e,t);case"verifier":return async function(e,t){let n;try{n=await t.verify(e)}catch{return Uo("unavailable")}if(null===n)return Uo("invalid");const r=(t.now??Date.now)();return void 0!==n.expiresAt&&n.expiresAt<=r?Uo("expired"):{authorized:!0,outcome:"authorized",context:Mo({strategy:"verifier",subject:n.subject,authorizedAt:r,expiresAt:n.expiresAt,scope:n.scope??{},payloadHeaders:n.payloadHeaders??{}})}}(e,t)}},exports.bind=bind,exports.bindByPath=bindByPath,exports.bindNavigationLifecycle=function(e,t={}){const n=t.windowTarget??globalThis.window,r=t.documentTarget??globalThis.document,i=t.softNavigationEvents??[],o=()=>{e.suspend()},s=t=>{!0===t.persisted&&e.resume()},a=()=>{e.refreshCache()};n?.addEventListener("pagehide",o),n?.addEventListener("pageshow",s);for(const e of i)r?.addEventListener(e,a);let l=!1;return()=>{if(!l){l=!0,n?.removeEventListener("pagehide",o),n?.removeEventListener("pageshow",s);for(const e of i)r?.removeEventListener(e,a)}}},exports.buildBuiltinRenderers=co,exports.buildFrameAncestors=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'"},exports.buildScriptSrcWithNonce=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(" ")},exports.createAnalyticsPlugin=function(){let e=0,t=0,n=0;return{name:"analytics",version:"1.0.0",init:r=>{r.events.on("afterUpdate",r=>{e+=1,t+=r.updatedCount,n+=r.durationMs})},getStats:()=>({updateCount:e,totalElements:t,totalDurationMs:n,averageDurationMs:0===e?0:n/e})}},exports.createPreviewBindings=createPreviewBindings,exports.createPreviewFocusReporter=function(e,t){return n=>{const r=e();null!=r&&mo(r,n,t)}},exports.debugPlugin=ns,exports.detectInitialLocale=detectInitialLocale,exports.detectProtocolProfile=detectProtocolProfile,exports.documentSavePlugin=function(e={}){const t=e.strategy??"silent";return{name:"document-save",version:"1.1.0",init:n=>{let r=!0;const i=/* @__PURE__ */new Set;n.registerCleanup?.(()=>{r=!1;for(const e of i)e.abort();i.clear()}),function(){if("undefined"!=typeof window)try{const e=sessionStorage.getItem(rs);if(null===e)return;sessionStorage.removeItem(rs);const t=JSON.parse(e);if(t.href!==window.location.href)return;window.scrollTo(t.x??0,t.y??0)}catch{}}(),n.events.on("documentSave",()=>{if(!r)return;if("silent"===t)return;if("reload"===t)return void is();const o=new AbortController;i.add(o);const s="fetch"===t?async function(e,t,n){if(e.handler)try{await e.handler(n)}catch(e){if(!r||n.aborted)return;t("document-save handler threw:",e)}else t("document-save: fetch strategy selected but no handler supplied")}(e,n.log,o.signal):async function(e,t,n,r){if("undefined"==typeof fetch)return void t("document-save: revalidate strategy needs fetch — not available");const i=e.revalidateUrl??"/api/revalidate";let o=!1;try{const s=await fetch(i,{method:"POST",signal:n,headers:{"Content-Type":"application/json",...e.revalidateHeaders??{}},body:JSON.stringify({source:"payload-live-preview"})});if(!r()||n.aborted)return;o=s.ok,o||t("document-save revalidate non-2xx:",s.status)}catch(e){if(!r()||n.aborted)return;t("document-save revalidate failed:",e)}o||"reload"!==e.onRevalidateFailure||is()}(e,n.log,o.signal,()=>r);s.finally(()=>{i.delete(o)})})}}},exports.escapeHtml=escapeHtml,exports.escapeHtmlAttribute=escapeHtmlAttribute,exports.generateCspNonce=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($o?.getRandomValues)return $o;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)},exports.generateInlineScript=function generateInlineScript(e={}){const t=function(e){const t=e.runtime;if(void 0===t)return ko(yo,"runtime.generated.ts"),yo;if(ko(t.source,`the ${t.profile} runtime`),null!=e.fragmentEndpoint||!0===e.routeStrategy)throw new Error(`[live-preview] the ${t.profile} runtime and the fragment or route strategy exclude each other: it carries no strategy runner, so the prelude would have nothing to talk to. Drop the runtime option, or drop \`fragmentEndpoint\`/\`routeStrategy\`.`);return t.source}(e);return[Co(e),...To(e),t].join("\n")},exports.hasCapability=function hasCapability(e,t){return e.capabilities.has(t)},exports.hasPreviewIntent=Zo,exports.highlightPlugin=ts,exports.initLivePreview=function initLivePreview(e={}){const t=new LivePreviewClient({...e,autoStart:!1});return t.start()?t:null},exports.isAuthorizedPreviewContext=isAuthorizedPreviewContext,exports.isDevMode=isDevMode,exports.isExternalHttpUrl=isExternalHttpUrl,exports.isInIframe=isInIframe,exports.isInPopup=isInPopup,exports.isInPreviewContext=isInPreviewContext,exports.isInsideIsland=isInsideIsland,exports.isLexicalContent=li,exports.isPreviewRequest=Xo,exports.isSafeUrl=isSafeUrl,exports.issuePreviewToken=async function(e,t){const n=Vo(t.crypto);if(void 0===n)throw new Error("payload-live-preview: no Web Crypto implementation available to sign tokens");const r=Ho(t.secret),i=(t.now??Date.now)(),o=Math.min(36e5,Math.max(1,e.ttlMs??6e5)),s=new Uint8Array(16);n.getRandomValues(s);const a={v:1,aud:e.audience,...void 0!==e.path?{pth:e.path}:{},...void 0!==e.locale?{loc:e.locale}:{},...void 0!==e.subject?{sub:e.subject}:{},pur:e.purpose??zo,iat:i,exp:i+o,jti:Go(s)},l=Go(Wo().encode(JSON.stringify(a))),u=`${Bo}.${l}`,d=await qo(n,r);return`${u}.${Go(new Uint8Array(await n.subtle.sign("HMAC",d,Wo().encode(u))))}`},exports.lexicalToHtml=ui,exports.lexicalToPlainText=di,exports.mergeCspHeader=function(e,t){const n=e.split(",").filter(e=>e.trim().length>0);return 0===n.length?Eo("",t):n.map(e=>Eo(e,t)).join(", ")},exports.negotiateProtocol=negotiateProtocol,exports.previewBindingsFromLocals=function(e,t={}){return createPreviewBindings({authorization:("object"==typeof e&&null!==e?e.livePreviewAuthorization:void 0)??null,...void 0!==t.owner?{owner:t.owner}:{}})},exports.registerBlockRenderer=function(e,t){ei.set(e,t)},exports.registerBuiltinRenderer=function(e){lo.set(e.name,e)},exports.registerRouteRefresh=function registerRouteRefresh(e){const t="undefined"==typeof window?void 0:window;return void 0===t?()=>{}:(t[go]=e,()=>{t[go]===e&&(t[go]=void 0)})},exports.reportPreviewFocus=mo,exports.runtimeBuildInfo=function(){return bo},exports.sanitizeHtml=sanitizeHtml,exports.setCspCrypto=function setCspCrypto(e){$o=e??void 0},exports.setSanitizerDocument=function setSanitizerDocument(e){globalThis[Pn]=e??void 0},exports.setSanitizerPolicy=function(e){Nn=e},exports.setTrustedTypesPolicy=function(e){sn().override=e},exports.trustedHtml=an,exports.wrapWithScriptTag=function(e,t={}){return`<script${void 0!==t.nonce?` nonce="${function(e){if(!/^[A-Za-z0-9+/=_-]+$/.test(e))throw new RangeError("nonce contains characters CSP does not allow");return e}(t.nonce)}"`:""}>${e}<\/script>`};
2
2
  //# sourceMappingURL=index.cjs.map