payload-live-preview 1.8.0 → 2.0.0-beta.0

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 (98) hide show
  1. package/README.md +301 -93
  2. package/dist/adapters/astro/PreviewBoundary.astro +66 -0
  3. package/dist/adapters/astro/RichText.astro +6 -0
  4. package/dist/adapters/astro/index.d.ts +165 -134
  5. package/dist/adapters/astro/index.js +1 -1
  6. package/dist/adapters/astro/index.js.map +1 -1
  7. package/dist/adapters/astro/middleware-entry.d.ts +4 -9
  8. package/dist/adapters/astro/middleware-entry.js +1 -1
  9. package/dist/adapters/astro/middleware-entry.js.map +1 -1
  10. package/dist/adapters/nextjs/index.d.ts +13 -80
  11. package/dist/adapters/nextjs/index.js +1 -1
  12. package/dist/adapters/nextjs/index.js.map +1 -1
  13. package/dist/adapters/nuxt/index.d.ts +46 -106
  14. package/dist/adapters/nuxt/index.js +1 -1
  15. package/dist/adapters/nuxt/index.js.map +1 -1
  16. package/dist/adapters/sveltekit/index.d.ts +10 -75
  17. package/dist/adapters/sveltekit/index.js +1 -1
  18. package/dist/adapters/sveltekit/index.js.map +1 -1
  19. package/dist/client.cjs +2 -0
  20. package/dist/client.cjs.map +1 -0
  21. package/dist/client.d.cts +747 -0
  22. package/dist/client.d.ts +747 -0
  23. package/dist/client.js +2 -0
  24. package/dist/client.js.map +1 -0
  25. package/dist/codegen-astro.d.ts +5 -27
  26. package/dist/codegen-astro.js +1 -1
  27. package/dist/codegen-astro.js.map +1 -1
  28. package/dist/codegen-cli.d.ts +3 -16
  29. package/dist/codegen-cli.js +1 -1
  30. package/dist/codegen-cli.js.map +1 -1
  31. package/dist/codegen.cjs +1 -1
  32. package/dist/codegen.cjs.map +1 -1
  33. package/dist/codegen.d.cts +37 -124
  34. package/dist/codegen.d.ts +37 -124
  35. package/dist/codegen.js +1 -1
  36. package/dist/codegen.js.map +1 -1
  37. package/dist/core.cjs +1 -1
  38. package/dist/core.cjs.map +1 -1
  39. package/dist/core.d.cts +647 -1100
  40. package/dist/core.d.ts +647 -1100
  41. package/dist/core.js +1 -1
  42. package/dist/core.js.map +1 -1
  43. package/dist/doctor-cli.d.ts +3 -28
  44. package/dist/doctor-cli.js +1 -1
  45. package/dist/doctor-cli.js.map +1 -1
  46. package/dist/doctor.d.ts +16 -32
  47. package/dist/doctor.js +1 -1
  48. package/dist/doctor.js.map +1 -1
  49. package/dist/fragment.cjs +2 -0
  50. package/dist/fragment.cjs.map +1 -0
  51. package/dist/fragment.d.cts +333 -0
  52. package/dist/fragment.d.ts +333 -0
  53. package/dist/fragment.js +2 -0
  54. package/dist/fragment.js.map +1 -0
  55. package/dist/index.cjs +1 -1
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.cts +885 -1531
  58. package/dist/index.d.ts +885 -1531
  59. package/dist/index.js +1 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/lexical.cjs +2 -0
  62. package/dist/lexical.cjs.map +1 -0
  63. package/dist/lexical.d.cts +90 -0
  64. package/dist/lexical.d.ts +90 -0
  65. package/dist/lexical.js +2 -0
  66. package/dist/lexical.js.map +1 -0
  67. package/dist/middleware-CEPsY1P7.d.ts +40 -0
  68. package/dist/migrate.d.ts +73 -0
  69. package/dist/migrate.js +2 -0
  70. package/dist/migrate.js.map +1 -0
  71. package/dist/options-CEzzfHJu.d.ts +197 -0
  72. package/dist/payload.cjs +1 -1
  73. package/dist/payload.cjs.map +1 -1
  74. package/dist/payload.d.cts +11 -80
  75. package/dist/payload.d.ts +11 -80
  76. package/dist/payload.js +1 -1
  77. package/dist/payload.js.map +1 -1
  78. package/dist/plugins.cjs +2 -0
  79. package/dist/plugins.cjs.map +1 -0
  80. package/dist/plugins.d.cts +509 -0
  81. package/dist/plugins.d.ts +509 -0
  82. package/dist/plugins.js +2 -0
  83. package/dist/plugins.js.map +1 -0
  84. package/dist/{probe-tMHdim5y.d.ts → probe-CYtvj_Lm.d.ts} +43 -77
  85. package/dist/server.cjs +2 -0
  86. package/dist/server.cjs.map +1 -0
  87. package/dist/server.d.cts +435 -0
  88. package/dist/server.d.ts +435 -0
  89. package/dist/server.js +2 -0
  90. package/dist/server.js.map +1 -0
  91. package/dist/structural.cjs +3 -0
  92. package/dist/structural.cjs.map +1 -0
  93. package/dist/structural.d.cts +243 -0
  94. package/dist/structural.d.ts +243 -0
  95. package/dist/structural.js +3 -0
  96. package/dist/structural.js.map +1 -0
  97. package/package.json +86 -7
  98. package/dist/middleware-DD4Hwomt.d.ts +0 -189
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=Object.defineProperty,t=(t,i)=>e(t,"name",{value:i,configurable:!0}),i="1.8.0",n="data-payload-field",r="data-payload-type",l="data-payload-attribute",s="data-payload-href",o="data-payload-src",a="data-payload-alt",u="data-payload-array-template",d="data-payload-array-separator",h="data-payload-locale",c="data-payload-richtext",f="data-payload-html",p="data-payload-array",g="data-payload-structural",m="data-payload-owner",v=[n,r,l,s,o,a,u,d,h,c,f,p,g,m,"type"],y=`[${n}]`,b=`[${m}]`;function w(e){let t=e.closest(b)?.getAttribute(m);return null==t||0===t.length?void 0:t}t(w,"resolveBindingOwner");var S=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"]),A=class{static{t(this,"ElementCache")}#e=new Map;#t=new WeakMap;#i;constructor(e={}){this.#i=e.filter??k}buildFromRoot(e){let t=performance.now();this.clear();let i=e.querySelectorAll(y),n=0;for(let e of i)void 0!==this.add(e)&&(n+=1);return{elementCount:n,fieldCount:this.#e.size,durationMs:performance.now()-t}}add(e){let t=this.#i(e)?this.#n(e):void 0,i=this.#t.get(e);if(void 0!==t)return void 0!==i&&this.#r(i,t)?(this.#t.set(e,t),t):(void 0!==i&&this.#l(e,i),this.#s(t),this.#t.set(e,t),t);void 0!==i&&this.#l(e,i)}remove(e){let t=this.#t.get(e);return!!t&&this.#l(e,t)}#r(e,t){if(e.fieldName!==t.fieldName)return!1;let i=this.#e.get(e.fieldName);if(!i)return!1;let n=i.indexOf(e);return!(n<0||(i[n]=t,0))}#l(e,t){let i=this.#e.get(t.fieldName);if(!i)return this.#t.delete(e),!1;let n=i.indexOf(t);return n<0?(this.#t.delete(e),!1):(i.splice(n,1),0===i.length&&this.#e.delete(t.fieldName),this.#t.delete(e),!0)}get(e){return this.#e.get(e)}getByElement(e){return this.#t.get(e)}get fieldCount(){return this.#e.size}get elementCount(){let e=0;for(let t of this.#e.values())e+=t.length;return e}entries(){return this.#e.entries()}*values(){for(let e of this.#e.values())yield*e}has(e){return this.#t.has(e)}clear(){this.#e.clear(),this.#t=new WeakMap}#s(e){let t=this.#e.get(e.fieldName);t?t.push(e):this.#e.set(e.fieldName,[e])}#n(e){let t=e.getAttribute(n);if(null===t||0===t.length)return;let i=e.getAttribute(r),c=T(e),f=e.getAttribute(l),p=e.getAttribute(s),g=e.getAttribute(o),m=e.getAttribute(a),v=e.getAttribute(u),y=e.getAttribute(d),b=e.getAttribute(h),A=w(e);return{element:e,fieldName:t,fieldType:c,explicitFieldType:null!==i&&S.has(i),...null!==f&&f.length>0?{targetAttribute:f}:{},...null!==p&&p.length>0?{hrefField:p}:{},...null!==g&&g.length>0?{srcField:g}:{},...null!==m&&m.length>0?{altField:m}:{},...null!==v?{arrayTemplate:v}:{},...null!==y?{arraySeparator:y}:{},...null!==b&&b.length>0?{locale:b}:{},...void 0!==A?{owner:A}:{}}}};function T(e){let t=e.getAttribute(r);if(null!==t&&S.has(t))return t;if(e.hasAttribute(c))return"richText";if(e.hasAttribute(f))return"html";if(e.hasAttribute(g))return"structural-array";if(e.hasAttribute(p))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 k(){return!0}function $(e){return`global:${e}`}function N(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function x(e){return"string"==typeof e&&e.length>0}function M(e){if(x(e.globalSlug))return[$(e.globalSlug)];if(!x(e.collectionSlug))return null;let t=N(e.collectionSlug);return x(e.documentId)?[t,N(e.collectionSlug,e.documentId)]:[t]}function C(e,t){return null!==t&&void 0!==e&&t.includes(e)}function L(e){let t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}t(T,"resolveFieldType"),t(k,"alwaysTrue"),t($,"globalOwnerKey"),t(N,"collectionOwnerKey"),t(x,"nonEmpty"),t(M,"messageOwnerKeys"),t(C,"isBindingInScope"),t(L,"readDocumentId");var O=class{static{t(this,"ObserverManager")}s;constructor(e,t={}){this.s=[e,t.mutationDebounceMs??100,t.intersectionRootMargin??"200px",new Set,null,null,null,0]}start(e){let t=this.s[7];this.stop();let i=t+1;if(this.s[7]!==i)return;let n=null,r=null;try{n=new MutationObserver(e=>{this.#e(e,i)}),r=new IntersectionObserver(e=>{this.#t(e,i)},{rootMargin:this.s[2],threshold:0}),n.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...v]})}catch(e){throw n?.disconnect(),r?.disconnect(),e}if(this.s[7]!==i)return n.disconnect(),void r.disconnect();this.s[4]=n,this.s[5]=r}observeElement(e){this.s[5]?.observe(e)}unobserveElement(e){this.s[5]?.unobserve(e),this.s[3].delete(e)}markVisible(e,t){t?this.s[3].add(e):this.s[3].delete(e)}isVisible(e){return this.s[3].has(e)}stop(){this.s[7]+=1;let e=this.s[6],t=this.s[4],i=this.s[5];this.s[6]=null,this.s[4]=null,this.s[5]=null,this.s[3].clear(),null!==e&&clearTimeout(e);try{t?.disconnect()}finally{i?.disconnect()}}#e(e,t){if(!this.#i(t)||!R(e)||!this.#i(t))return;null!==this.s[6]&&clearTimeout(this.s[6]);let i=setTimeout(()=>{!this.#i(t)||this.s[6]!==i||(this.s[6]=null,this.s[0].onStructuralChange())},this.s[1]);this.s[6]=i}#t(e,t){for(let i of e){if(!this.#i(t))return;let e=i.target;if(i.isIntersecting){if(!this.s[3].has(e)&&(this.s[3].add(e),this.s[0].onVisibilityChange(e,!0),!this.#i(t)))return}else if(this.s[3].has(e)&&(this.s[3].delete(e),this.s[0].onVisibilityChange(e,!1),!this.#i(t)))return}}#i(e){return this.s[7]===e&&null!==this.s[5]}};function R(e){for(let t of e){if("attributes"===t.type&&null!==t.attributeName&&v.includes(t.attributeName)&&(t.attributeName===n||t.attributeName===m||1===t.target.nodeType&&t.target.hasAttribute(n)))return!0;for(let e of t.addedNodes)if(P(e))return!0;for(let e of t.removedNodes)if(P(e))return!0}return!1}function P(e){if(1!==e.nodeType)return!1;let t=e;return!!t.hasAttribute(n)||null!==t.querySelector(`[${n}]`)}function I(e){if(!Array.isArray(e))return[];let t=[];for(let i of e){let e=E(i);e&&t.push(e)}return t}function E(e){if("object"!=typeof e||null===e)return;let t=e,i=t.name,n=t.type;if("string"!=typeof i||0===i.length||"string"!=typeof n||0===n.length)return;let r=I(t.fields),l=j(t.blocks),s={...t,name:i,type:n};return r.length>0?s.fields=r:delete s.fields,l.length>0?s.blocks=l:delete s.blocks,s}function j(e){if(!Array.isArray(e))return[];let t=[];for(let i of e){if("object"!=typeof i||null===i)continue;let e=i,n=e.slug;if("string"!=typeof n||0===n.length)continue;let r=I(e.fields);t.push({...e,slug:n,fields:r})}return t}t(R,"hasStructuralImpact"),t(P,"containsTrackedElement"),t(I,"parseFieldSchema"),t(E,"parseFieldEntry"),t(j,"parseBlockSchema");var F=4,D={basic:1,"schema-json":2,"preview-token":3,"nested-arrays":4,"recursive-diffs":4};function U(e){let t="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,i=Math.min(4,t??1),n=new Set;for(let[e,t]of Object.entries(D))i>=t&&n.add(e);return{ours:4,...void 0!==t?{theirs:t}:{theirs:void 0},negotiated:i,capabilities:n}}function _(e,t){return e.capabilities.has(t)}function W(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}t(U,"negotiateProtocol"),t(_,"hasCapability"),t(W,"observeThenableResult");var q=class{static{t(this,"MessageBus")}s;constructor(e,t){this.s=[e,t,void 0,void 0,0,0,[],0]}attach(e=window){if(void 0!==this.s[3])return;let i=!1,n=t(e=>{if(!i||this.s[2]!==n)return;let t=this.s[4];try{this.#e(e,t)}catch{let i="";try{i=e.origin}catch{}this.#s("shape",i,t)}},"listener");this.s[4]+=1,this.#o(),this.s[3]=e,this.s[2]=n;try{e.addEventListener("message",n)}catch(t){this.s[2]===n&&(this.s[3]=void 0,this.s[2]=void 0,this.#o());try{e.removeEventListener("message",n)}catch{}throw t}if(this.s[2]===n)i=!0;else try{e.removeEventListener("message",n)}catch{}}detach(e){let t=this.s[3],i=this.s[2];void 0===t||void 0===i||(this.s[3]=void 0,this.s[2]=void 0,this.#o(),t.removeEventListener("message",i))}advanceGeneration(){return void 0!==this.s[3]&&(this.s[4]+=1,this.#o(),!0)}static sendReady(e,t){let i=e.length>0;if(!i||0===t.length)return;let n={type:"payload-live-preview",ready:i,protocolVersion:4};for(let i of e)for(let e of t)try{i.postMessage(n,e)}catch{}}#e(e,t){if(!this.#a(t))return;let i=e.origin;if(!this.#a(t))return;if(!this.#n(i,t))return void this.#s("origin",i,t);let n=e.data;if(!this.#a(t))return;let r=V(n);if(!this.#a(t))return;if(!r)return void this.#s("shape",i,t);let l=n.type;if(this.#a(t))switch(l){case"payload-live-preview":{let e=z(n);if(!this.#a(t))return;if(!e)return void this.#s("shape",i,t);let r=Z(n);if(!this.#a(t))return;return void this.#t(r,i,t)}case"payload-document-event":{let e,r=B(n);if(!this.#a(t))return;if(!r)return void this.#s("shape",i,t);try{e=this.s[1].onDocumentEvent}catch{return}if(!this.#a(t))return;return void this.#u(e,n,i)}default:this.#s("type",i,t)}}#t(e,t,i){if(!this.#a(i))return;let n=e.data;if(!this.#a(i))return;let r=J(n);if(!this.#a(i))return;let l,s=r?{generation:i,revision:this.s[5]+=1}:void 0;try{l=this.s[1].validateToken}catch{return}if(!this.#a(i))return;if(void 0===l)return void this.#l(e,t,i,s);if(!0===e.ready&&void 0===n)return void this.#l(e,t,i,void 0);let o,a={generation:i,message:e,origin:t,messageRevision:s,settled:!1,approved:!1};this.s[6].push(a);try{o=l(e.previewToken,t)}catch{return void this.#i(a,!1)}"boolean"!=typeof o?Promise.resolve(o).then(e=>{this.#i(a,!0===e)},()=>{this.#i(a,!1)}):this.#i(a,o)}#i(e,t){this.#a(e.generation)&&(e.approved=t,e.settled=!0,this.#r(e.generation))}#r(e){for(;this.#a(e);){let t=this.s[6][this.s[7]];if(void 0===t)return;if(this.#n(t.origin,e)){if(!t.settled)return;this.#d(t)&&(t.approved?this.#l(t.message,t.origin,t.generation,t.messageRevision):this.#s("token",t.origin,t.generation))}else{if(!this.#d(t))continue;this.#s("origin",t.origin,t.generation)}}}#l(e,t,i,n){if(!this.#a(i))return;let r;try{r=this.s[1].onUpdate}catch{return}this.#a(i)&&(void 0===n?this.#u(r,e,t):this.#u(r,e,t,n))}#s(e,t,i){if(!this.#a(i))return;let n;try{n=this.s[1].onInvalid}catch{return}this.#a(i)&&void 0!==n&&this.#u(n,e,t)}#n(e,t){if(!this.#a(t))return!1;try{return!0===this.s[0](e)&&this.#a(t)}catch{return!1}}#u(e,...t){try{W(e(...t))}catch{}}#a(e){return void 0!==this.s[3]&&this.s[4]===e}#d(e){let t=this.s;return t[6][t[7]]===e&&(t[7]+=1,t[7]===t[6].length?(this.#o(),!0):(t[7]>=1024&&2*t[7]>=t[6].length&&(t[6]=t[6].slice(t[7]),t[7]=0),!0))}#o(){this.s[6]=[],this.s[7]=0}};function V(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type}function z(e){let t=e;return!!((void 0===t.data||null===t.data||J(t.data))&&H(t.fieldSchemaJSON,e=>Array.isArray(e))&&H(t.globalSlug,e=>"string"==typeof e)&&H(t.collectionSlug,e=>"string"==typeof e)&&H(t.locale,e=>"string"==typeof e)&&H(t.ready,e=>"boolean"==typeof e)&&H(t.previewToken,e=>"string"==typeof e)&&H(t.protocolVersion,e=>"number"==typeof e))}function B(e){let t=e;return!(!G(t.action,e=>"updated"===e||"created"===e||"deleted"===e)||!G(t.slug,e=>"string"==typeof e)||!G(t.id,e=>"string"==typeof e||"number"==typeof e&&Number.isFinite(e)))}function G(e,t){return void 0===e||t(e)}function H(e,t){return null==e||t(e)}function J(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}t(V,"isObjectMessage"),t(z,"isLivePreviewMessage"),t(B,"isDocumentEventMessage"),t(G,"optionalDocumentFieldOk"),t(H,"optionalTypeOk"),t(J,"isPlainObject");var Q=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"];function Z(e){let t,i={...e};for(let e of Q)null===Reflect.get(i,e)&&Reflect.deleteProperty(i,e);if(!Array.isArray(i.fieldSchemaJSON))return i;try{t=I(i.fieldSchemaJSON)}catch{t=[]}return{...i,fieldSchemaJSON:t}}t(Z,"normalizeLivePreviewMessage");var X=class{static{t(this,"HeartbeatTimer")}s;constructor(e){this.s=[e.timeoutMs??0,e.onTimeout,null,0]}kick(){if(this.s[3]=Date.now(),this.s[0]<=0)return;null!==this.s[2]&&clearTimeout(this.s[2]);let e=setTimeout(()=>{this.s[2]===e&&(this.s[2]=null,this.s[1]())},this.s[0]);this.s[2]=e}stop(){null!==this.s[2]&&(clearTimeout(this.s[2]),this.s[2]=null)}get lastKickAt(){return this.s[3]}get pending(){return null!==this.s[2]}},K=class{static{t(this,"ConnectionState")}s;constructor(e){this.s=["disconnected",e]}get status(){return this.s[0]}markConnected(){return this.transition("connected")}markConnecting(){return this.transition("connecting")}markDisconnected(){return this.transition("disconnected")}transition(e){if(this.s[0]===e)return!1;let t=this.s[0];return this.s[0]=e,this.s[1](e,t),!0}};function Y(e){return(...t)=>{try{W(e(...t))}catch{}}}function ee(){}t(Y,"isolateDiagnostic"),t(ee,"noopDiagnostic");var te=Y((...e)=>console.error(...e)),ie=Y((...e)=>console.warn(...e)),ne=Y((...e)=>console.debug(...e));function re(e){for(let t of e){let e=t.codePointAt(0);if(void 0!==e&&(e<=31||127===e))return!0}return!1}function le(e){if(void 0===e||0===e.length||e.length>128||"."===e||".."===e||e.includes("/")||e.includes("\\")||e.includes("?")||e.includes("#")||re(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}function se(e){if("number"==typeof e)return Number.isFinite(e);if("string"!=typeof e||0===e.length||e.length>512||"."===e||".."===e||e.includes("/")||e.includes("\\")||re(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}t(re,"hasControlCharacter"),t(le,"isSafeSlug"),t(se,"isSafeId");var oe=class{static{t(this,"DataMerger")}s;constructor(e){let t=e.serverURL.replace(/\/+$/,""),i=e.apiRoute??"/api";this.s=[t,i.startsWith("/")?i:`/${i}`,e.depth??1,e.fetchFn,void 0===e.log?ee:Y(e.log),null,0,0]}canMerge(e){try{return e.globalSlug?le(e.globalSlug):!!le(e.collectionSlug)&&se(e.data.id)}catch{return!1}}async merge(e){if(this.s[7]>0)return{status:"superseded"};let t=this.s[6]+1;this.s[6]=t;let i=this.s[5];this.s[5]=null;let n=null;try{if(i?.abort(),!ae(this.s,t))return{status:"superseded"};if(!this.canMerge(e))return ae(this.s,t)?{status:"unavailable"}:{status:"superseded"};if(!ae(this.s,t))return{status:"superseded"};let r=this.s[3]??("function"==typeof fetch?fetch:void 0);if(!ae(this.s,t))return{status:"superseded"};if(void 0===r)return{status:"unavailable"};if(n=new AbortController,!ae(this.s,t))return n.abort(),{status:"superseded"};this.s[5]=n;let l=e.globalSlug?`globals/${encodeURIComponent(e.globalSlug)}`:`${encodeURIComponent(e.collectionSlug??"")}/${encodeURIComponent(String(e.data.id))}`,s=`${this.s[0]}${this.s[1]}/${l}`,o=JSON.stringify({data:e.data,depth:this.s[2],flattenLocales:!1,...void 0!==e.locale?{locale:e.locale}:{}});if(!ae(this.s,t))return{status:"superseded"};let a=await r(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:o,signal:n.signal});if(!ae(this.s,t)||ue(n.signal))return{status:"superseded"};let u=a.ok;if(!ae(this.s,t))return{status:"superseded"};if(!u){let e=a.status;return ae(this.s,t)?(this.s[4]("merge HTTP",e,s),ae(this.s,t)?{status:"unavailable"}:{status:"superseded"}):{status:"superseded"}}let d=await a.json();return!ae(this.s,t)||ue(n.signal)?{status:"superseded"}:null===d||"object"!=typeof d||Array.isArray(d)?(this.s[4]("merge invalid",s),ae(this.s,t)?{status:"unavailable"}:{status:"superseded"}):{status:"merged",doc:d}}catch(e){return!ae(this.s,t)||null!==n&&ue(n.signal)?{status:"superseded"}:(this.s[4]("merge exception",e),ae(this.s,t)?{status:"unavailable"}:{status:"superseded"})}finally{null!==n&&ae(this.s,t)&&this.s[5]===n&&(this.s[5]=null)}}destroy(){this.s[6]+=1;let e=this.s[5];this.s[5]=null,this.s[7]+=1;try{e?.abort()}finally{this.s[7]-=1}}};function ae(e,t){return e[6]===t}function ue(e){return e.aborted}t(ae,"isLatestAttempt"),t(ue,"isAborted");var de=new Set(["http:","https:","mailto:","tel:"]),he=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,ce=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/;function fe(e){if("string"!=typeof e||0===e.length)return!1;let t=e.trim();if(0===t.length||he.test(t))return!1;if(t.startsWith("#")||t.startsWith("?")||t.startsWith("//")||t.startsWith("/"))return!0;try{let e=new URL(t);return de.has(e.protocol)}catch{return ce.test(t)}}function pe(e){if(!fe(e))return!1;let t=e.trim();return/^https?:\/\//i.test(t)||/^\/\/[^/]/.test(t)}t(fe,"isSafeUrl"),t(pe,"isExternalHttpUrl");var ge=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),me=new Set(["href","src","poster","cite","action","xlink:href","data"]);function ve(e,t,i){let n=t.toLowerCase().trim();if(0===n.length||n.startsWith("on")||ge.has(n))return"blocked";if(null==i)return e.removeAttribute(n),"applied";if("string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i)return"blocked";let r=String(i);return me.has(n)&&!fe(r)?"blocked":(e.setAttribute(n,r),"applied")}t(ve,"applyAttributeBinding");var ye=new WeakSet;function be(e){return ye.add(e),e}function we(e){return ye.has(e)}function Se(e){return ye.has(e.render)}t(be,"markNoWriteCallback"),t(we,"usesNoWriteOutcome"),t(Se,"rendererUsesNoWriteOutcome");var Ae=class{static{t(this,"UpdateScheduler")}s;constructor(e,t){let i=t.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):e=>setTimeout(()=>{e(performance.now())},0)),n=t.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):e=>{clearTimeout(e)});this.s=[e,t.debounceMs??50,t.isVisible,t.visibilityGateThreshold??50,t.disableVisibilityGate??!1,t.getCacheSize,t.onFlush,i,n,new Map,new Map,new Set,null,0,null,0,null,!1]}schedule(e){if(void 0!==e.identity&&(this.s[17]||!Te(e.identity,this.s[16])))return;let t=this.s[9],i=t.get(e.target.element);i?(i.value=e.value,i.allFields=e.allFields,i.identity=e.identity,i.data=e.data):t.set(e.target.element,{...e,identity:e.identity,data:e.data}),this.#e()}acceptRevision(e){let t=this.s[16];Te(e,t)||null!==t&&ke(e,t)<0||(this.#a(),this.#n(),this.s[16]=e,this.s[17]=!1)}cancelRevision(e){Te(e,this.s[16])&&(this.#a(),this.#n(),this.s[17]=!0)}flushNow(){return this.#a(),this.#i()}notifyVisible(e){let t=this.s[10],i=t.get(e);if(!i||(t.delete(e),!this.#r(i)))return;let n=performance.now(),r=this.#l(i)?1:0;this.s[6]?.(this.#u(i,r,0,performance.now()-n,1===r?[i.target.fieldName]:[]))}retarget(e){this.#s(this.s[9],e),this.#s(this.s[10],e);for(let t of this.s[11])this.#s(t,e)}forget(e){this.s[9].delete(e),this.s[10].delete(e);for(let t of this.s[11])t.delete(e)}destroy(){this.#a(),this.#n(),this.s[16]=null,this.s[17]=!1}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}get gateThreshold(){return this.s[3]}get gateActive(){return!this.s[4]&&this.s[5]()>this.s[3]}#e(){let e=this.s[13]+=1,t=this.s[12];if(this.s[12]=null,null!==t&&clearTimeout(t),this.s[13]!==e)return;let i=setTimeout(()=>{this.s[13]===e&&(this.s[12]=null,this.#t())},this.s[1]);this.s[13]===e&&(this.s[12]=i)}#t(){let e=this.s[15]+=1,t=this.s[14];if(this.s[14]=null,null!==t&&this.s[8](t),this.s[15]!==e)return;let i=!1,n=this.s[7](()=>{this.s[15]===e&&(i=!0,this.s[14]=null,this.#i())});!i&&this.s[15]===e&&(this.s[14]=n)}#i(){let e=performance.now(),t=!this.s[4]&&this.s[5]()>this.s[3],i=this.s[9];this.s[9]=new Map;let n,r=0,l=[],s=0;this.s[11].add(i);try{for(let e of i.values()){if(!this.#r(e))continue;let i=!t||this.s[2](e.target.element);if(this.#r(e)){if(n??=e,!i){this.s[10].set(e.target.element,e),s+=1;continue}this.s[10].delete(e.target.element),this.#l(e)&&(r+=1,l.push(e.target.fieldName))}}}finally{this.s[11].delete(i)}let o=this.#u(n,r,s,performance.now()-e,l);return this.s[6]?.(o),o}#r(e){return void 0===e.identity||!this.s[17]&&Te(e.identity,this.s[16])}#l(e){let t=this.s[0];return!1!==t(e)||!we(t)}#s(e,t){let i=e.get(t.element);if(void 0!==i){if(i.target.fieldName!==t.fieldName||i.target.locale!==t.locale)return void e.delete(t.element);i.target=t}}#n(){this.s[9].clear(),this.s[10].clear();for(let e of this.s[11])e.clear()}#u(e,t,i,n,r){return{applied:t,appliedFields:r,deferred:i,durationMs:n,...void 0!==e?.identity?{identity:e.identity}:{},...void 0!==e?.data?{data:e.data}:{}}}#a(){let e=this.s[12],t=this.s[14];this.s[13]+=1,this.s[15]+=1,this.s[12]=null,this.s[14]=null,null!==e&&clearTimeout(e),null!==t&&this.s[8](t)}};function Te(e,t){return null!==t&&e.generation===t.generation&&e.revision===t.revision}function ke(e,t){return e.generation!==t.generation?e.generation-t.generation:e.revision-t.revision}t(Te,"sameIdentity"),t(ke,"compareIdentity");var $e=new Set(["__proto__","prototype","constructor"]);function Ne(e,t,i,n=!1){if(n&&void 0!==i){let n=xe(e,`${t}_${i}`);if(void 0!==n)return n}let r=xe(e,t);if(void 0!==r)return r;if(t.includes(".")){let i=e,n=!0;for(let e of t.split(".")){if($e.has(e)||null===i||"object"!=typeof i){n=!1;break}if(i=xe(i,e),void 0===i){n=!1;break}}if(n)return i}return void 0===i?void 0:xe(e,`${t}_${i}`)}function xe(e,t){if(!$e.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Me(){let e=Ce();if(void 0!==e)return e;let t=Le();return void 0!==t?t:"en"}function Ce(){if(typeof document>"u")return;let e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}function Le(){if(typeof navigator>"u")return;let e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}t(Ne,"resolveFieldValue"),t(xe,"readOwn"),t(Me,"detectInitialLocale"),t(Ce,"readHtmlLang"),t(Le,"readNavigatorLanguage");var Oe="payload-live-preview-a11y";function Re(e){return/^de(?:[-_]|$)/i.test(e)}t(Re,"isGerman");var Pe=new WeakMap;function Ie(e){let t=Pe.get(e);return t??=[null,!1,null,0,null],Pe.set(e,t),t[3]+=1,t}function Ee(e){null!==e[4]&&(clearTimeout(e[4]),e[4]=null),e[2]?.remove(),e[2]=null}t(Ie,"acquireDocumentLease"),t(Ee,"clearLeaseMessage");var je=class{static{t(this,"A11yAnnouncer")}s;constructor(e,t){let i=t??(typeof document>"u"?null:document),n=i?.documentElement.getAttribute("lang")??"";this.s=[Re(e??(n.length>0?n:Me())),i,null]}mount(){let e=this.s[1];if(null==e?.body)return null;let t=this.s[2];null===t&&(t=Ie(e),this.s[2]=t);let i=t[0];if(i?.isConnected&&i.ownerDocument===e)return i;if(null!==i){let e=t[1];Ee(t),e&&i.remove()}let n=e.getElementById(Oe);return t[1]=null===n,n||(n=e.createElement("div"),n.id=Oe,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"),n.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(n)),t[0]=n,n}announceConnected(){this.say(this.s[0]?"Vorschau verbunden":"Live preview connected")}announceDisconnected(){this.say(this.s[0]?"Vorschau getrennt":"Live preview disconnected")}announceUpdate(e){e<=0||this.say(this.s[0]?`${String(e)} ${1===e?"Änderung":"Änderungen"} angewendet`:`${String(e)} ${1===e?"change":"changes"} applied`)}detach(){let e=this.s[2],t=this.s[1];if(null===e||null===t||(this.s[2]=null,e[3]-=1,e[3]>0))return;let i=e[0];null!==i&&Ee(e),e[1]&&i?.remove(),e[0]=null,Pe.delete(t)}say(e){let t=this.mount(),i=this.s[2];if(null===t||null===i)return;let n=i[2];n?.parentNode!==t?(n?.remove(),n=t.ownerDocument.createTextNode(t.hasChildNodes()?` ${e}`:e),i[2]=n,t.appendChild(n)):n.data=null===n.previousSibling?e:` ${e}`,null!==i[4]&&clearTimeout(i[4]);let r=setTimeout(()=>{i[4]===r&&i[0]===t&&Ee(i)},1500);i[4]=r}},Fe=new Set(["tabs","row","collapsible"]);function De(e,t=""){let i=new Map;return Ue(e,t,i),i}function Ue(e,t,i){for(let n of e){if(Fe.has(n.type)){n.fields&&Ue(n.fields,t,i);continue}if("group"===n.type){let e=""===t?n.name:`${t}.${n.name}`;i.set(e,n),n.fields&&Ue(n.fields,e,i);continue}let e=""===t?n.name:`${t}.${n.name}`;if(i.set(e,n),"array"===n.type&&n.fields)Ue(n.fields,`${e}.*`,i);else if("blocks"===n.type&&n.blocks)for(let t of n.blocks)Ue(t.fields,`${e}.*.${t.slug}`,i)}}function _e(e,t){if(e.has(t))return e.get(t);let i=t.replace(/\.\d+(?=\.|$)/g,".*");return e.has(i)?e.get(i):void 0}function We(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function qe(e){if("object"!=typeof e||null===e)return;let t=e.blockType;return"string"==typeof t?t:void 0}function Ve(e,t){return t.every(e=>void 0!==We(e))?ze(e,t):Be(e,t)}function ze(e,t){let i=[],n=new Map;for(let t=0;t<e.length;t+=1){let i=We(e[t]);void 0!==i&&n.set(i,t)}let r=new Set;for(let l=0;l<t.length;l+=1){let s=t[l],o=We(s);if(void 0===o){i.push({kind:"insert",index:l,value:s});continue}let a=n.get(o);if(void 0===a){i.push({kind:"insert",index:l,value:s});continue}r.add(a);let u=e[a];qe(u)===qe(s)?(a!==l&&i.push({kind:"move",from:a,to:l,value:s}),Ge(u,s)||i.push({kind:"update",index:l,value:s})):i.push({kind:"replace",index:l,oldValue:u,value:s})}for(let t=0;t<e.length;t+=1)r.has(t)||i.push({kind:"remove",index:t,value:e[t]});return i}function Be(e,t){let i=[],n=Math.min(e.length,t.length);for(let r=0;r<n;r+=1)Ge(e[r],t[r])||i.push({kind:"update",index:r,value:t[r]});if(t.length>e.length)for(let n=e.length;n<t.length;n+=1)i.push({kind:"insert",index:n,value:t[n]});if(e.length>t.length)for(let n=t.length;n<e.length;n+=1)i.push({kind:"remove",index:n,value:e[n]});return i}function Ge(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||"object"!=typeof t||null===e||null===t)return!1;let i=e,n=t,r=Object.keys(i),l=Object.keys(n);if(r.length!==l.length)return!1;for(let e of r)if(!Object.is(i[e],n[e]))return!1;return!0}t(De,"buildSchemaIndex"),t(Ue,"walk"),t(_e,"lookupSchema"),t(We,"getId"),t(qe,"getBlockType"),t(Ve,"diffArray"),t(ze,"diffById"),t(Be,"diffByPosition"),t(Ge,"shallowEqual");var He={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"};function Je(e){if(Object.prototype.hasOwnProperty.call(He,e))return He[e]}t(Je,"payloadTypeToRenderer");var Qe=[0,500,1e3,2e3],Ze=class{static{t(this,"LivePreviewRuntime")}d;l;constructor(e){let i=e.emitter,n=e.renderers,r=e.resolveRenderer??(e=>n[e]),l=e.transformValue,s=e.root??(typeof document<"u"?document:null),o=e.readyTargets,a=e.sendReady??nt,u=e.onHeartbeatTimeout,d=void 0===e.log?ee:Y(e.log),h=void 0===e.warn?ie:Y(e.warn),c=Ye(e),f=void 0!==e.dataMerge?new oe({serverURL:e.dataMerge.serverURL,...void 0!==e.dataMerge.apiRoute?{apiRoute:e.dataMerge.apiRoute}:{},...void 0!==e.dataMerge.depth?{depth:e.dataMerge.depth}:{},...void 0!==e.dataMerge.fetchFn?{fetchFn:e.dataMerge.fetchFn}:{},log:t((...e)=>{d(...e)},"log")}):null,p=new A,g=new O({onStructuralChange:t(()=>{this.#s()},"onStructuralChange"),onVisibilityChange:t((e,t)=>{t&&this.d[3].notifyVisible(e)},"onVisibilityChange")},{...void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}}),m=new Ae(be(e=>this.#h(e)),{...void 0!==e.debounceMs?{debounceMs:e.debounceMs}:{},...void 0!==e.disableVisibilityGate?{disableVisibilityGate:e.disableVisibilityGate}:{},...void 0!==e.visibilityGateThreshold?{visibilityGateThreshold:e.visibilityGateThreshold}:{},isVisible:t(e=>g.isVisible(e),"isVisible"),getCacheSize:t(()=>p.elementCount,"getCacheSize"),onFlush:t(e=>{this.#c(e)},"onFlush")}),v=new q(e.originMatcher,{onUpdate:t((e,t,i)=>{this.#u(e,t,i)},"onUpdate"),onDocumentEvent:t(()=>{i.emit("documentSave",{timestamp:Date.now()})},"onDocumentEvent"),onInvalid:t((e,t)=>{if("token"===e){let e=new Error(`Preview token rejected (origin: ${t})`);i.emit("error",{error:e,context:"token",code:"LP0502"})}d("LP0501 message rejected:",e,t)},"onInvalid"),...void 0!==e.validateToken?{validateToken:e.validateToken}:{}}),y=new K(()=>{}),b=new X({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:t(()=>{this.#f()},"onTimeout")});this.d=[i,p,g,m,v,y,b,n,r,l,s,o,a,u,d,h,[],c,f,!0===e.scopeBindingsByOwner,e.lockedOrigin??(()=>{})],this.l=[void 0,void 0,void 0,U(void 0),!1,null,0,null,new Set,!1,!1,0,null,new Set]}start(){if(this.l[4])return!1;this.l[4]=!0;let e=this.d[10];if(et(e)&&"loading"===e.readyState){let i=t(()=>{if(this.l[4]){this.l[5]=null;try{this.#e()}catch(e){this.#i(),this.#p(e,"startup","LP0605")}}},"onReady");this.l[5]=i;try{e.addEventListener("DOMContentLoaded",i,{once:!0})}catch(e){throw this.#i(),e}return!0}try{return this.#e(),!0}catch(e){throw this.#i(),e}}#e(){if(!this.l[4])return;let e=et(this.d[10])?tt(this.d[10]):this.d[10];if(null===e)throw new Error("LivePreviewRuntime: document.body unavailable");if(this.d[2].start(e),this.#l(),this.#g()&&(this.d[4].attach(),this.d[0].emitWhile("init",{timestamp:Date.now()},()=>this.l[4]),this.#g()))for(let e of Qe){if(!this.#g())return;if(0===e){if(this.d[12](this.d[11]),!this.#g())return}else{let t=setTimeout(()=>{this.l[4]&&this.#m()},e);this.d[16].push(t)}}}suspend(){return!!this.l[4]&&(this.#t()&&this.d[0].emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0)}destroy(){this.l[4]&&(this.#t()&&this.d[0].emit("disconnect",{reason:"destroy",timestamp:Date.now()}),this.d[17]?.detach(),this.d[0].emit("destroy",{timestamp:Date.now()}))}#t(){this.l[7]=null,this.l[4]=!1;let e=this.l[5];this.l[5]=null,null!==e&&et(this.d[10])&&this.#r(()=>{this.d[10].removeEventListener("DOMContentLoaded",e)});for(let e of this.d[16])this.#r(()=>{clearTimeout(e)});return this.d[16].length=0,this.#r(()=>{this.d[6].stop()}),this.#r(()=>{this.d[4].detach()}),this.#r(()=>{this.d[2].stop()}),this.#r(()=>{this.d[3].destroy()}),this.#r(()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()}#i(){this.#t(),this.#r(()=>{this.d[17]?.detach()})}#r(e){try{e()}catch(e){this.d[14]("cleanup failed:",e)}}refreshCache(){this.l[4]&&this.#s()}get status(){return this.d[5].status}get cache(){return this.d[1]}get updateCount(){return this.l[6]}get protocol(){return this.l[3]}inspect(){let e=this.d[1],t=this.d[3],n=this.l[3],r=this.l[7],l=this.l[12],s=[],o=new Set;for(let[t,i]of e.entries()){s.push(t);for(let e of i)void 0!==e.owner&&o.add(e.owner)}return{version:i,started:this.l[4],status:this.d[5].status,origins:{trusted:[...this.d[11]],locked:this.d[20]()},protocol:{ours:n.ours,theirs:n.theirs,negotiated:n.negotiated,capabilities:[...n.capabilities].sort()},revisions:{accepted:this.l[6],superseded:this.l[11],active:null===r?void 0:r.identity.revision},bindings:{elements:e.elementCount,fields:e.fieldCount,fieldNames:s.sort(),absentFields:[...this.l[13]].sort(),orphanFields:[...this.l[8]].sort(),ownerScoped:this.d[19],owners:[...o].sort()},scheduler:{pending:t.pendingCount,deferred:t.replayCount,visibilityGateThreshold:t.gateThreshold,visibilityGateActive:t.gateActive,lastFlush:null===l?void 0:{applied:l.applied,appliedFields:l.appliedFields,deferred:l.deferred,durationMs:l.durationMs}},renderers:Object.keys(this.d[7]).sort()}}#l(){if(!this.l[4])return;let e=this.d[1].buildFromRoot(this.d[10]);if(this.d[14]("cache",e),this.#g()&&(this.d[0].emitWhile("cacheRefresh",e,()=>this.l[4]),this.#g()))for(let e of this.d[1].values()){if(!this.#g())return;this.d[2].observeElement(e.element)}}#s(){if(!this.l[4])return;let e=new Map;for(let t of this.d[1].values())e.set(t.element,t),this.d[2].unobserveElement(t.element);if(this.#l(),this.#g()){for(let t of this.d[1].values())e.get(t.element)?.fieldName===t.fieldName?this.d[3].retarget(t):this.d[3].forget(t.element),e.delete(t.element);for(let t of e.values())this.d[3].forget(t.element)}}#n(e){let t=this.l[3];if(t.theirs===e)return;let i=U(e);this.l[3]=i,i.negotiated!==t.negotiated&&this.d[14]("protocol","ours=4",`theirs=${e}`,`negotiated=${i.negotiated}`)}#u(e,t,i){if(this.d[6].kick(),void 0===e.data)return void(void 0!==e.protocolVersion&&this.#n(e.protocolVersion));if(void 0===i)return;"string"==typeof e.locale&&(this.l[0]=e.locale),Array.isArray(e.fieldSchemaJSON)&&(this.l[1]=e.fieldSchemaJSON,this.l[2]=De(e.fieldSchemaJSON));let n={identity:i,message:e,locale:this.l[0],schema:this.l[1],schemaIndex:this.l[2],cancelled:!1};null!==this.l[7]&&(this.l[11]+=1),this.l[7]=n,this.d[3].acceptRevision(i),this.l[6]+=1,(void 0===e.protocolVersion||(this.#n(e.protocolVersion),this.l[4]&&this.l[7]===n))&&(this.d[5].markConnected()&&(this.d[17]?.announceConnected(),this.d[0].emit("connect",{origin:t,timestamp:Date.now()}),!this.l[4]||this.l[7]!==n||(this.d[14]("connection","disconnected","→","connected"),!this.l[4]||this.l[7]!==n))||this.#a(n))}async#a(e){let i=await this.#d(e);if(null===i||!this.l[4]||this.l[7]!==e)return;let{message:n}=e,r={fields:i,...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}:{}};this.d[0].listenerCount("beforeUpdate")>0&&(!await this.d[0].emitWhile("beforeUpdate",{data:r,revision:e.identity.revision,cancel:t(()=>{e.cancelled=!0,this.d[3].cancelRevision(e.identity)},"cancel")},()=>!e.cancelled&&this.l[4]&&this.l[7]===e)||e.cancelled||!this.l[4]||this.l[7]!==e)||this.l[4]&&this.l[7]===e&&this.#o(e,r)}async#d(e){let{message:t}=e,i=t.data??{};if(null===this.d[18])return i;let n=await this.d[18].merge({collectionSlug:t.collectionSlug,globalSlug:t.globalSlug,data:i,locale:e.locale});return this.l[4]&&this.l[7]===e?"merged"===n.status?n.doc:"superseded"===n.status?null:i:null}#o(e,i){if(!this.l[4]||this.l[7]!==e)return;let n=t(()=>this.l[4]&&this.l[7]===e,"isCurrent"),r=this.#v(e,i.fields);for(let[t,l]of this.d[1].entries()){if(!this.l[4]||this.l[7]!==e)return;for(let s of l){if(!1!==r&&!C(s.owner,r))continue;let l=Ne(i.fields,t,s.locale??e.locale,void 0!==s.locale);if(void 0===l){this.l[13].add(t);continue}if(!this.l[4]||this.l[7]!==e)return;let o=this.#y(s,l,i.fields,n);if(!this.l[4]||this.l[7]!==e)return;let a={target:s,value:o,allFields:i.fields,identity:e.identity,data:i};if(!this.l[4]||this.l[7]!==e)return;this.d[3].schedule(a)}}this.#b(i.fields,e.locale,r)}#v(e,t){if(!this.d[19])return!1;let{message:i}=e,n=M({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:L(t)});return null===n&&!this.l[9]&&(this.l[9]=!0,this.d[15]("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),n}#w(e){for(let t of this.d[1].values())if(C(t.owner,e))return!0;return!1}#S(e,t){let i=this.d[1].get(e);return void 0!==i&&(!1===t||i.some(e=>C(e.owner,t)))}#b(e,t,i){if(0===this.d[1].fieldCount||!1!==i&&!this.#w(i))return;let n;for(let[r,l]of Object.entries(e)){if(this.l[8].has(r)||lt.has(r)||!st(l))continue;let e=ot(r,t);if(!(this.#S(r,i)||e!==r&&this.#S(e,i))){if(void 0===n){n=new Set;for(let[e,t]of this.d[1].entries())for(let r of t)!1!==i&&!C(r.owner,i)||void 0!==r.locale&&n.add(`${e}_${r.locale}`)}n.has(r)||(this.l[8].add(r),this.d[15](`[live-preview] LP0201: update arrived for field "${r}" but no <… data-payload-field="${e}"> element exists on this page. Render the binding anchor unconditionally in your template so live edits to an initially-empty field have somewhere to land.`))}}}#y(e,t,i,n){if(void 0===this.d[9])return t;try{let r=this.d[9](e.fieldName,t,{element:e.element,allFields:i},n),l=W(r);if(!n())return t;if(l)throw new TypeError(`Transform for "${e.fieldName}" returned a Promise/thenable; transforms must be synchronous`);return r}catch(e){if(!n())return t;let i=e instanceof Error?e:new Error(String(e));return this.d[0].emit("error",{error:i,context:"transform",code:"LP0602"}),t}}#g(){return this.l[4]}#A(e){0!==e.deferred&&(this.l[10]||(this.l[10]=!0,this.d[15](`[live-preview] LP0301: visibility gate held ${String(e.deferred)} offscreen update(s) until scrolled into view; see visibilityGateThreshold.`)))}#h(e){let t=this.l[7];if(null===t||void 0===e.identity||!rt(t.identity,e.identity)||!this.l[4]||this.l[7]!==t)return!1;let i,n=void 0!==t.schemaIndex?_e(t.schemaIndex,e.target.fieldName):void 0,r=e.value,l=Xe(e.target,n?.type);"text"===l&&!0!==e.target.explicitFieldType&&it(r)&&(l="richText");try{i=this.d[8](l)}catch(e){if(!this.l[4]||this.l[7]!==t)return!1;let i=e instanceof Error?e:new Error(String(e));return this.d[0].emitWhile("error",{error:i,context:"renderer",code:"LP0603"},()=>this.l[4]&&this.l[7]===t),!1}if(!this.l[4]||this.l[7]!==t)return!1;let s=this.d[0].listenerCount("elementUpdate")>0,o=s?at(e.target.element):void 0;if(!this.l[4]||this.l[7]!==t)return!1;let a={allFields:e.allFields,locale:e.target.locale??t.locale,schema:n};try{if(void 0!==e.target.targetAttribute){if("blocked"===ve(e.target.element,e.target.targetAttribute,r))return this.d[15](`[live-preview] LP0401: refused to write field "${e.target.fieldName}" into attribute "${e.target.targetAttribute}" (unsafe attribute or value)`),!1}else{if(!i)return this.d[14]("no renderer for",l),!1;if(!1===Ke(i,e.target,r,a)&&Se(i))return!1}}catch(e){if(!this.l[4]||this.l[7]!==t)return!1;let i=e instanceof Error?e:new Error(String(e));return this.d[0].emitWhile("error",{error:i,context:"renderer",code:"LP0603"},()=>this.l[4]&&this.l[7]===t),!1}return!(!this.l[4]||this.l[7]!==t)&&(s&&this.d[0].emitWhile("elementUpdate",{element:e.target.element,fieldName:e.target.fieldName,previousValue:o,nextValue:r,revision:t.identity.revision},()=>this.l[4]&&this.l[7]===t),this.l[4]&&this.l[7]===t)}#c(e){this.l[12]=e,this.#A(e);let{identity:i,data:n}=e;if(0===e.applied||void 0===i||void 0===n)return;let r=this.l[7];if(null===r||!this.l[4]||this.l[7]!==r||!rt(r.identity,i))return;let l=t(()=>this.l[4]&&this.l[7]===r&&rt(r.identity,i),"isCurrent");this.d[17]?.announceUpdate(e.applied),l()&&0!==this.d[0].listenerCount("afterUpdate")&&this.d[0].emitWhile("afterUpdate",{data:n,updatedCount:e.applied,durationMs:e.durationMs,revision:i.revision},l)}#f(){if(!this.#g())return;this.d[4].advanceGeneration();let e=this.l[7];this.l[7]=null,null!==e&&this.d[3].cancelRevision(e.identity),this.d[18]?.destroy();let t=this.d[5].markDisconnected();try{this.d[13]?.()}catch(e){this.d[14]("heartbeat:",e)}this.#g()&&(t&&this.#T()&&(this.d[17]?.announceDisconnected(),this.d[0].emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>this.#T()),!this.#g()||this.#T()&&(this.d[14]("connection","connected","→","disconnected"),!this.#g()))||this.#g()&&this.#m())}#m(){try{this.d[12](this.d[11])}catch(e){this.#p(e,"ready","LP0606")}}#p(e,t,i){let n=e instanceof Error?e:new Error(String(e));this.d[0].emit("error",{error:n,context:t,code:i})}#T(){return this.l[4]&&"disconnected"===this.d[5].status&&null===this.l[7]}};function Xe(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){let e=Je(t);if(void 0!==e)return e}return e.fieldType}function Ke(e,t,i,n){return e.render(t,i,n)}function Ye(e){if(!1===e.enableA11y)return null;let t=void 0===e.root?void 0:9===e.root.nodeType?e.root:e.root.ownerDocument;return new je(e.a11yLocale,t)}function et(e){return 9===e.nodeType}function tt(e){return e.body}function it(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)}function nt(e){if(typeof window>"u")return;let t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),q.sendReady(t,e)}function rt(e,t){return e.generation===t.generation&&e.revision===t.revision}t(Xe,"resolveRuntimeFieldType"),t(Ke,"invokeRenderer"),t(Ye,"createA11y"),t(et,"isDocumentRoot"),t(tt,"readDocumentBody"),t(it,"looksLikeLexicalRoot"),t(nt,"defaultSendReady"),t(rt,"sameRevision");var lt=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function st(e){return null!=e&&("string"==typeof e||"number"==typeof e||"boolean"==typeof e||"bigint"==typeof e)}function ot(e,t){if(!t)return e;let i=`_${t}`;return e.endsWith(i)?e.slice(0,-i.length):e}function at(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:"IMG"===e.tagName?e.src:e.textContent}t(st,"isLiveBindableScalar"),t(ot,"stripLocaleSuffix"),t(at,"readElementSnapshot");var ut,dt=class{static{t(this,"EventEmitter")}#e=new Map;#t=new Map;on(e,t){return this.#r(this.#e,e,t)}once(e,t){return this.#r(this.#t,e,t)}off(e,t){this.#l(this.#e,e,t),this.#l(this.#t,e,t)}async emit(e,t){await this.#i(e,t)}async emitWhile(e,t,i){return this.#i(e,t,i)}async#i(e,i,n){let r=t(()=>n?.()??!0,"eligible");if(!r())return!1;let l=this.#e.get(e);if(l)for(let t of[...l])if(!r()||(await this.#s(t,i,e),!r()))return!1;if(!r())return!1;let s=this.#t.get(e);if(s&&s.size>0){let t=[...s];this.#t.delete(e);for(let n of t)if(!r()||(await this.#s(n,i,e),!r()))return!1}return r()}listenerCount(e){return(this.#e.get(e)?.size??0)+(this.#t.get(e)?.size??0)}removeAllListeners(e){if(void 0===e)return this.#e.clear(),void this.#t.clear();this.#e.delete(e),this.#t.delete(e)}eventNames(){let e=new Set;for(let t of this.#e.keys())e.add(t);for(let t of this.#t.keys())e.add(t);return[...e]}#r(e,t,i){let n=e.get(t);return n||(n=new Set,e.set(t,n)),n.add(i),()=>{this.#l(e,t,i)}}#l(e,t,i){let n=e.get(t);void 0!==n&&(n.delete(i),0===n.size&&e.delete(t))}async#s(e,t,i){try{await e(t)}catch(e){let t="string"==typeof i||"number"==typeof i?String(i):"<event>";te(`[live-preview] LP0601: handler for "${t}" threw:`,e)}}};function ht(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function ct(){return!(typeof window>"u")&&null!=window.opener}function ft(){return ht()||ct()}function pt(){let e=mt();if(void 0!==e)return"production"!==e;let t=vt();if(void 0!==t)return t;if(typeof window<"u"){let e=window.location.hostname;if("localhost"===e||"127.0.0.1"===e)return!0}return!1}function gt(e){if(typeof process<"u"){let t=process.env[e];if("string"==typeof t&&t.length>0)return t}let t=yt();if(t){let i=t[e];if("string"==typeof i&&i.length>0)return i}}function mt(){if(typeof process>"u")return;let e=process.env.NODE_ENV;return"string"==typeof e?e:void 0}function vt(){let e=yt();if(!e)return;let t=e.DEV;return"boolean"==typeof t?t:void 0}function yt(){if(!(typeof __INLINE_RUNTIME_BUILD__<"u"&&__INLINE_RUNTIME_BUILD__)){if(void 0!==ut)return ut??void 0;ut=null;try{let e=new Function("try { return import.meta && import.meta.env; } catch (_) { return undefined; }")();if(e&&"object"==typeof e)return ut=e}catch{}}}t(ht,"isInIframe"),t(ct,"isInPopup"),t(ft,"isInPreviewContext"),t(pt,"isDevMode"),t(gt,"getEnvVar"),t(mt,"readNodeEnv"),t(vt,"readImportMetaDev"),t(yt,"tryReadImportMetaEnv");var bt=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,wt=/^https?:\/\/[^/?#\s]+$/i,St=["PAYLOAD_ADMIN_ORIGIN","PUBLIC_PAYLOAD_ADMIN_ORIGIN","NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN"],At=class{static{t(this,"OriginDetector")}#e;constructor(e={}){let t,i=new Set;for(let t of e.additionalOrigins??[]){let e=kt(t);void 0!==e&&i.add(e)}for(let e of St){let t=gt(e);if(void 0!==t)for(let e of t.split(",")){let t=kt(e);void 0!==t&&i.add(t)}}if(e.enableReferrerDetection??1){let i=e.referrer??(typeof document<"u"?document.referrer:"");if(i.length>0)try{let e=new URL(i).origin;e&&"null"!==e&&(t=e)}catch{}}let n=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??pt());this.#e=[i,t,n,void 0!==t,void 0]}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==this.#e[4]?e===this.#e[4]:!!(this.#e[0].has(e)||0===this.#e[0].size&&void 0!==this.#e[1]&&e===this.#e[1]||this.#e[2]&&bt.test(e)))}lockOrigin(e){return!!this.matches(e)&&(this.#e[4]=e,!0)}unlockOrigin(){let e=this.#e[4];return this.#e[4]=void 0,e}get lockedOrigin(){return this.#e[4]}enumerate(){if(void 0!==this.#e[4])return[this.#e[4]];let e=new Set(this.#e[0]);if(0===this.#e[0].size&&void 0!==this.#e[1]&&e.add(this.#e[1]),this.#e[2])for(let t of Tt)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return this.#e[3]}get isProductionUnconfigured(){return!(!ht()||this.#e[0].size>0||this.#e[2]||void 0!==this.#e[1])}get isReferrerOnlyTrust(){return!(this.#e[0].size>0||this.#e[2])&&void 0!==this.#e[1]}},Tt=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3];function kt(e){let t=e.trim();if(0!==t.length)try{let e=new URL(t);return"http:"!==e.protocol&&"https:"!==e.protocol||!wt.test(e.origin)?void 0:e.origin}catch{return}}t(kt,"normaliseOrigin");var $t=t(()=>{},"noopDisposer");function Nt(e){return"function"==typeof e}t(Nt,"isPluginDisposer");var xt,Mt=class{static{t(this,"ResourceScope")}#e;#t;#i=new Set;#r="staging";constructor(e,t){this.#e=e,this.#t=t}assertOpen(){if("closed"===this.#r)throw new Error(`Plugin context for "${this.#e}" is no longer active`)}get active(){return"active"===this.#r}eligible(){return"closed"!==this.#r}own(e){return this.assertOpen(),this.#l({acquire:void 0,finalize:void 0,cleanup:e,disposed:!1})}stage(e,t){this.assertOpen();let i={acquire:e,finalize:t,cleanup:void 0,disposed:!1},n=this.#l(i);if("active"===this.#r)try{this.#s(i)}catch(e){throw this.#n(i),e}return n}commit(){if("staging"!==this.#r)throw new Error(`Plugin context for "${this.#e}" cannot be committed`);this.#r="committing";try{for(let e of this.#i)this.#s(e);this.#r="active"}catch(e){throw this.close(),e}}close(){if("closed"!==this.#r){this.#r="closed";for(let e of[...this.#i].reverse())this.#n(e);this.#i.clear()}}#l(e){return this.#i.add(e),()=>{this.#n(e)}}#s(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;let t=e.acquire();e.cleanup=t??$t}#n(e){if(e.disposed)return;e.disposed=!0,this.#i.delete(e);let t=e.cleanup;if(e.cleanup=void 0,void 0!==t)try{W(t())&&this.#t(`plugin "${this.#e}" cleanup returned a Promise/thenable; cleanups must be synchronous`)}catch(e){this.#t(`plugin "${this.#e}" cleanup failed:`,e)}try{e.finalize?.()}catch(e){this.#t(`plugin "${this.#e}" cleanup failed:`,e)}}},Ct=class extends dt{static{t(this,"ScopedPluginEvents")}#e;#t;#i=new Set;constructor(e,t){super(),this.#e=e,this.#t=t}on(e,t){return this.#r("on",e,t)}once(e,t){return this.#r("once",e,t)}off(e,t){let i=t;for(let t of[...this.#i])t.event===e&&t.handler===i&&t.dispose()}emit(e,t){return this.#t.assertOpen(),this.#e.emit(e,t)}emitWhile(e,t,i){return this.#t.assertOpen(),this.#e.emitWhile(e,t,()=>{if(!this.#t.eligible())return!1;let e=i();return!!this.#t.eligible()&&e})}listenerCount(e){let t=0;for(let i of this.#i)i.event===e&&(t+=1);return t}removeAllListeners(e){for(let t of[...this.#i])(void 0===e||t.event===e)&&t.dispose()}eventNames(){let e=new Set;for(let t of this.#i)e.add(t.event);return[...e]}#r(e,i,n){this.#t.assertOpen();let r=n,l=[...this.#i].find(t=>t.kind===e&&t.event===i&&t.handler===r);if(void 0!==l)return l.dispose;let s=$t,o=!0,a=t(async t=>{!this.#t.active||!o||("once"===e&&s(),await n(t))},"wrapped"),u={kind:e,event:i,handler:r,dispose:$t};return s=this.#t.stage(()=>this.#e[e](i,a),()=>{o=!1,this.#i.delete(u)}),u.dispose=s,this.#i.add(u),s}},Lt=class{static{t(this,"PluginManager")}#e;#t;#i;#r;#l;#s=new Map;#n=new Map;#u=new Map;#a=new Set;#d=new Map;#o=Promise.resolve();#v=0;constructor(e){this.#e=e.events,this.#t=e.config,this.#i=e.registerFieldRenderer,this.#l=Y(e.log);let t=e.onTransformError;this.#r=void 0===t?void 0:Y((...e)=>{let i=e[0];if(i instanceof Error)try{return t(i)}catch(e){return void this.#l("transform error reporter failed:",e)}})}register(e){return this.#v>0?this.#w(e):this.#h(()=>this.#w(e))}unregister(e){return this.#v>0?this.#b(e):this.#h(async()=>{await this.#b(e)})}destroyAll(){return this.#v>0?this.#g():this.#h(async()=>{await this.#g()})}applyTransforms(e,t,i,n){let r=this.#d.get(e);if(void 0===r||0===r.length)return t;let l=t;for(let s of[...r]){if(!s.active)continue;let{transform:r}=s;if(!1===n?.())return t;try{l=r(l,{fieldName:e,element:i.element,allFields:i.allFields});let s=W(l);if(!1===n?.())return t;if(s)throw new TypeError(`Transform for "${e}" returned a Promise/thenable; transforms must be synchronous`)}catch(i){if(!1===n?.())return t;let r=i instanceof Error?i:new Error(String(i));return this.#l(`transform for "${e}" failed:`,r),this.#r?.(r),t}}return l}list(){return[...this.#s.keys()]}get size(){return this.#s.size}async#w(e){if(this.#s.has(e.name)||this.#n.has(e.name)||this.#u.has(e.name))return void this.#l(`plugin "${e.name}" already registered`);let t=new Mt(e.name,this.#l),i=this.#S(e.name,t),n={scope:t,cancelled:!1};this.#n.set(e.name,n);try{if(await this.#A(()=>e.init(i)),n.cancelled)return;t.commit()}catch(i){return t.close(),void(n.cancelled||this.#l(`plugin "${e.name}" init failed:`,i))}finally{this.#n.get(e.name)===n&&this.#n.delete(e.name)}this.#s.set(e.name,{plugin:e,scope:t}),this.#l(`plugin "${e.name}" registered`)}#S(e,i){return{events:new Ct(this.#e,i),registerFieldRenderer:t(e=>{i.stage(()=>{let t=this.#i(e);return Nt(t)?t:void 0})},"registerFieldRenderer"),registerTransform:t((e,t)=>{let n={transform:t,active:!1};i.stage(()=>{n.active=!0;let t=this.#d.get(e);return void 0===t?this.#d.set(e,[n]):t.push(n),()=>{n.active=!1;let t=this.#d.get(e);if(void 0===t)return;let i=t.indexOf(n);i>=0&&t.splice(i,1),0===t.length&&this.#d.delete(e)}})},"registerTransform"),registerCleanup:t(e=>{i.own(e)},"registerCleanup"),getConfig:t(()=>this.#t,"getConfig"),log:t((...t)=>{this.#l(`[${e}]`,...t)},"log")}}#b(e){let t=this.#n.get(e);if(void 0!==t)return t.cancelled=!0,t.scope.close(),Promise.resolve();let i=this.#u.get(e);if(void 0!==i)return this.#a.has(e)?Promise.resolve():i;let n=this.#s.get(e);if(void 0===n)return Promise.resolve();this.#s.delete(e),n.scope.close();let r=Promise.resolve().then(()=>this.#y(e,n.plugin));return this.#u.set(e,r),r.then(()=>{this.#u.get(e)===r&&this.#u.delete(e)}),r}async#y(e,t){if(void 0!==t.destroy){this.#a.add(e);try{await this.#A(()=>t.destroy?.())}catch(t){this.#l(`plugin "${e}" destroy failed:`,t)}finally{this.#a.delete(e)}}}async#g(){for(let e of this.#n.values())e.cancelled=!0,e.scope.close();let e=[...this.#s.keys()];for(let t of e)await this.#b(t)}async#A(e){this.#v+=1;try{await e()}finally{this.#v-=1}}#h(e){let t=this.#o.then(e);return this.#o=t.catch(e=>{this.#l("plugin manager mutation failed:",e)}),t}},Ot=class{static{t(this,"RendererRegistry")}#e;#t;#i=new Map;constructor(e){this.#e=e,this.#t={...e}}get renderers(){return this.#t}resolve(e){return this.#t[e]}register(e){let t=e.name,i={renderer:e},n=this.#i.get(t);void 0===n?this.#i.set(t,[i]):n.push(i),this.#t[t]=e;let r=!0;return()=>{if(!r)return;r=!1;let e=this.#i.get(t);if(void 0===e)return;let n=e.indexOf(i);if(n<0)return;let l=n===e.length-1;if(e.splice(n,1),0===e.length&&this.#i.delete(t),!l)return;let s=e.at(-1)?.renderer??this.#e[t];void 0===s?Reflect.deleteProperty(this.#t,t):this.#t[t]=s}}},Rt=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"]),Pt=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),It=new Set(["id","class","lang","dir","title","role","tabindex"]),Et={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"])},jt=new Set(["href","src","cite","poster"]),Ft=class extends Error{static{t(this,"SanitizerEnvironmentError")}name="SanitizerEnvironmentError"};function Dt(e){if(!e){let e=new Map;for(let[t,i]of Object.entries(Et))e.set(t,i);return{allowedTags:Rt,attrByTag:e}}let t=new Set(Rt);for(let i of e.additionalAllowedTags??[])t.add(i);let i=new Map;for(let[e,t]of Object.entries(Et))i.set(e,t);for(let[t,n]of Object.entries(e.additionalAllowedAttributes??{})){let e=i.get(t),r=new Set(e??[]);for(let e of n)r.add(e);i.set(t,r)}return{allowedTags:t,attrByTag:i}}function Ut(e){xt=e??void 0}function _t(e,t){let i=Wt();if(!i)throw new Ft("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===e)return"";let n=Dt(t),r=i.createElement("template");return r.innerHTML=e,Vt(r.content,n),r.innerHTML}function Wt(){return xt||(typeof document>"u"?void 0:document)}function qt(){return void 0!==Wt()}function Vt(e,t){for(let i of Array.from(e.childNodes))1===i.nodeType?zt(i,t):8===i.nodeType&&i.remove()}function zt(e,t){let i=e.tagName.toLowerCase();if(Pt.has(i))e.remove();else{if(!t.allowedTags.has(i)){Vt(e,t);let i=e.parentNode;if(i){for(;e.firstChild;)i.insertBefore(e.firstChild,e);e.remove()}return}Bt(e,i,t),"a"===i&&Ht(e),Vt(e,t)}}function Bt(e,t,i){let n=i.attrByTag.get(t);for(let t of Array.from(e.attributes)){let i=t.name.toLowerCase();if(i.startsWith("on"))e.removeAttribute(t.name);else if("style"!==i){if(!(It.has(i)||i.startsWith("aria-")||i.startsWith("data-"))){if(n?.has(i)){(jt.has(i)&&!fe(t.value)||"srcset"===i&&!Gt(t.value))&&e.removeAttribute(t.name);continue}e.removeAttribute(t.name)}}else e.removeAttribute(t.name)}}function Gt(e){let t=e.split(",");for(let e of t){let t=e.trim();if(0===t.length)continue;let i=t.search(/\s/);if(!fe(-1===i?t:t.slice(0,i)))return!1}return!0}function Ht(e){let t=e.getAttribute("href");null===t||!pe(t)||(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}t(Dt,"resolvePolicy"),t(Ut,"setSanitizerDocument"),t(_t,"sanitizeHtml"),t(Wt,"resolveDocument"),t(qt,"hasSanitizerDocument"),t(Vt,"sanitizeFragment"),t(zt,"sanitizeElement"),t(Bt,"sanitizeAttributes"),t(Gt,"isSafeSrcset"),t(Ht,"hardenAnchor");var Jt=new Map;function Qt(e,t){Jt.set(e,t)}function Zt(e){return Jt.get(e)}t(Qt,"register"),t(Zt,"lookup");var Xt={1:"left",2:"center",3:"right",4:"justify"},Kt=new Set(["left","center","right","justify","start","end"]);function Yt(e){let t=e.format;if("string"==typeof t&&Kt.has(t))return t;if("number"==typeof t){let e=Xt[t];if(void 0!==e)return e}}function ei(e){let t=e.indent;return"number"==typeof t&&t>0?t:0}function ti(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function ii(e){let t=Yt(e),i=ei(e),n=[];return void 0!==t&&n.push(`text-align:${t}`),i>0&&n.push(`padding-inline-start:${String(40*i)}px`),0===n.length?"":` style="${n.join(";")}"`}t(Yt,"resolveAlignment"),t(ei,"resolveIndent"),t(ti,"dirAttribute"),t(ii,"styleAttribute");var ni=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),ri=/[&<>"'/`=]/g;function li(e){return""===e?"":e.replace(ri,e=>ni[e])}function si(e){return e.replace(/['"()\\]/g,"\\$&")}t(li,"escapeHtml"),t(si,"escapeCssUrl");var oi=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}),ai=/[&<>"']/g;function ui(e){return""===e?"":e.replace(ai,e=>oi[e])}function di(e){return li(e).replace(/\r\n|\r|\n/g,"<br>")}t(ui,"escapeHtmlAttribute"),t(di,"escapeAndLinebreak");var hi=t(e=>{let t=li("string"==typeof e.text?e.text:""),i="number"==typeof e.format?e.format:0;return!!(16&i)&&(t=`<code>${t}</code>`),!!(1&i)&&(t=`<strong>${t}</strong>`),!!(2&i)&&(t=`<em>${t}</em>`),!!(8&i)&&(t=`<u>${t}</u>`),!!(4&i)&&(t=`<s>${t}</s>`),!!(32&i)&&(t=`<sub>${t}</sub>`),!!(64&i)&&(t=`<sup>${t}</sup>`),!!(128&i)&&(t=`<mark>${t}</mark>`),t},"textRenderer"),ci=t((e,t)=>{let i=t.renderChildren(e.children??[]);return`<p${ti(e)}${ii(e)}>${i}</p>`},"paragraphRenderer"),fi=new Set(["h1","h2","h3","h4","h5","h6"]),pi=t((e,t)=>{let i="string"==typeof e.tag?e.tag.toLowerCase():"h2",n=fi.has(i)?i:"h2",r=t.renderChildren(e.children??[]);return`<${n}${ti(e)}${ii(e)}>${r}</${n}>`},"headingRenderer"),gi=t((e,t)=>{let i="string"==typeof e.listType?e.listType:"bullet",n="number"===i?"ol":"ul",r="number"===i&&"number"==typeof e.start&&e.start>1?` start="${String(e.start)}"`:"",l="check"===i?' role="list"':"",s=t.renderChildren(e.children??[]);return`<${n}${ti(e)}${ii(e)}${r}${l}>${s}</${n}>`},"listRenderer"),mi=t((e,t)=>{let i=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${ii(e)}>${i}</li>`;let n="number"==typeof e.value?` value="${li(String(e.value))}"`:"";return`<li${ti(e)}${ii(e)}${n}>${i}</li>`},"listItemRenderer"),vi=t((e,t)=>{let i="string"==typeof e.url?e.url:"",n=t.renderChildren(e.children??[]);if(0===i.length||!fe(i))return n;let r=pe(i)?' target="_blank" rel="noopener noreferrer"':yi(e),l="string"==typeof e.title?` title="${li(e.title)}"`:"";return`<a href="${ui(i)}"${r}${l}>${n}</a>`},"linkRenderer");function yi(e){let t="string"==typeof e.target?e.target:"";if(0===t.length)return"";let i=li(t);return"_blank"===t?' target="_blank" rel="noopener noreferrer"':` target="${i}"`}t(yi,"buildOptionalAttrs");var bi=t((e,t)=>{let i=t.renderChildren(e.children??[]);return`<blockquote${ti(e)}${ii(e)}>${i}</blockquote>`},"quoteRenderer"),wi=t(e=>{let t=Ti("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${li(Ai(e))}</code></pre>`},"codeRenderer"),Si=t(e=>{let t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${Ti(e.highlightType)}"`:""}>${li(t)}</span>`},"codeHighlightRenderer");function Ai(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(let i of e.children)t+=Ai(i);return t}function Ti(e){return e.replace(/[^a-zA-Z0-9_-]/g,"")}t(Ai,"extractText"),t(Ti,"sanitizeLangClass");var ki=t(()=>"<br>","linebreakRenderer"),$i=t(()=>"<hr>","horizontalRuleRenderer"),Ni=t(()=>"\t","tabRenderer"),xi=t(e=>{let t=Mi(e);if(void 0===t)return"";let i=t.url;if("string"!=typeof i||!fe(i))return"";let n="string"==typeof t.mimeType?t.mimeType:"";return n.startsWith("video/")?Li(t,i):n.startsWith("audio/")?Oi(t,i):""===n||n.startsWith("image/")?Ci(t,i):Ri(t,i)},"uploadRenderer");function Mi(e){let t=e.value;if("object"==typeof t&&null!==t)return t}function Ci(e,t){let i="string"==typeof e.alt?li(e.alt):"",n="number"==typeof e.width?` width="${String(e.width)}"`:"",r="number"==typeof e.height?` height="${String(e.height)}"`:"";return`<img src="${ui(t)}" alt="${i}"${n}${r} loading="lazy" decoding="async">`}function Li(e,t){let i="number"==typeof e.width?` width="${String(e.width)}"`:"",n="number"==typeof e.height?` height="${String(e.height)}"`:"",r="string"==typeof e.mimeType?` type="${ui(e.mimeType)}"`:"";return`<video controls${i}${n}><source src="${ui(t)}"${r}></video>`}function Oi(e,t){let i="string"==typeof e.mimeType?` type="${ui(e.mimeType)}"`:"";return`<audio controls><source src="${ui(t)}"${i}></audio>`}function Ri(e,t){let i="string"==typeof e.filename?li(e.filename):li(t);return`<a href="${ui(t)}" target="_blank" rel="noopener noreferrer">${i}</a>`}t(Mi,"readUploadValue"),t(Ci,"renderImage"),t(Li,"renderVideo"),t(Oi,"renderAudio"),t(Ri,"renderFallbackLink");var Pi=t(e=>{let t="string"==typeof e.relationTo?e.relationTo:"",i=Ii(e),n=li(Ei(i,t)),r=""===t?"":` data-relation-to="${li(t)}"`,l=i?.url;return"string"==typeof l&&fe(l)?`<a href="${ui(l)}"${r}>${n}</a>`:`<span${r}>${n}</span>`},"relationshipRenderer");function Ii(e){let t=e.value;if("object"==typeof t&&null!==t)return t}function Ei(e,t){return void 0===e?""===t?"#":`#${t}`:"string"==typeof e.title&&e.title.length>0?e.title:"string"==typeof e.name&&e.name.length>0?e.name:"string"==typeof e.slug&&e.slug.length>0?e.slug:void 0!==e.id?String(e.id):""===t?"#":`#${t}`}t(Ii,"readValue"),t(Ei,"pickLabel");var ji=new Map;function Fi(e,t){ji.set(e,t)}function Di(e){return ji.get(e)}t(Fi,"registerBlockRenderer"),t(Di,"lookupBlockRenderer");var Ui=t((e,t)=>{let i=_i(e),n="string"==typeof i.blockType?i.blockType:"",r=Wi(n);if(""!==n){let e=Di(n)??Di(r);if(e)return e(i,{renderChildren:t.renderChildren})}let l=[];""!==r&&l.push(`data-block-type="${li(r)}"`);for(let[e,t]of Object.entries(i)){if("blockType"===e||"id"===e||null==t)continue;let i="string"==typeof t||"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t);l.push(`data-block-${Wi(e)}="${li(i)}"`)}return`<div${0===l.length?"":` ${l.join(" ")}`}></div>`},"blockRenderer");function _i(e){let t=e.fields;return"object"!=typeof t||null===t?{}:t}function Wi(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}t(_i,"readFields"),t(Wi,"sanitizeIdent"),Qt("text",hi),Qt("paragraph",ci),Qt("heading",pi),Qt("list",gi),Qt("listitem",mi),Qt("link",vi),Qt("autolink",vi),Qt("quote",bi),Qt("code",wi),Qt("code-highlight",Si),Qt("linebreak",ki),Qt("horizontalrule",$i),Qt("tab",Ni),Qt("upload",xi),Qt("relationship",Pi),Qt("block",Ui);var qi={renderChildren:Gi,resolveAlignment:Yt,resolveIndent:ei};function Vi(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 zi(e,t={}){if(!Vi(e))return"";let i=Gi(e.root.children);return!1!==t.sanitize&&qt()?_t(i):i}function Bi(e){return Vi(e)?e.root.children.map(Ji).join("\n").trim():""}function Gi(e){let t="";for(let i of e)t+=Hi(i);return t}function Hi(e){let t=Zt(e.type);return t?t(e,qi):void 0!==e.children?Gi(e.children):""}function Ji(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 i of e.children)t+=Ji(i);return t}function Qi(){let e=new WeakSet;return{name:"text",render:be((t,i)=>{let n=t.element,r=Ki(i);if("INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName)return Zi(n)&&!n.hasAttribute("data-payload-text")?(Xi(e,n,t.fieldName),!1):void(r.includes("\n")||r.includes("\r")?n.innerHTML=di(r):n.textContent=r);n.value=r})}}function Zi(e){return null!==e.firstElementChild}function Xi(e,t,i){e.has(t)||(e.add(t),ie(`[live-preview] LP0402: Skipping text update for "${i}": <${t.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}function Ki(e){return null==e?"":Vi(e)?Bi(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e)}function Yi(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""}}t(Vi,"isLexicalContent"),t(zi,"lexicalToHtml"),t(Bi,"lexicalToPlainText"),t(Gi,"renderChildren"),t(Hi,"renderNode"),t(Ji,"extractPlainText"),t(Qi,"createTextRenderer"),t(Zi,"hasStructuredChildren"),t(Xi,"warnOnce"),t(Ki,"toPlainString"),t(Yi,"safeStringify");var en={name:"textarea",render(e,t){let i=e.element,n=Vi(t)?Bi(t):Yi(t);"INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName?i.innerHTML=di(n):i.value=n}},tn={name:"richText",render:be((e,t)=>{if(Vi(t))e.element.innerHTML=zi(t);else{if("string"!=typeof t)return!1;e.element.innerHTML=_t(t)}})},nn={name:"html",render(e,t){if(null==t)return void(e.element.textContent="");let i="string"==typeof t?t:Yi(t);e.element.innerHTML=_t(i)}},rn={name:"url",render(e,t,i){let n=e.element,r=Yi(t);if("A"===n.tagName){let l=n,s=e.hrefField,o=void 0===s||0===s.length?t:Ne(i.allFields,s,i.locale,void 0!==e.locale);return"string"==typeof o&&fe(o)&&(l.href=o),void(l.textContent=r)}"INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName?n.textContent=r:n.value=r}},ln={name:"image",render:be((e,t,i)=>{let n=e.element,r=sn(t),l=void 0!==e.locale,s=on(r,t,e.srcField,i.allFields,i.locale,l);if(void 0===s)return!1;if("IMG"===n.tagName){let t=n;t.src=s;let o=an(r,e.altField,i.allFields,i.locale,l);return void(void 0!==o&&(t.alt=o))}n.style.backgroundImage=`url('${si(s)}')`})};function sn(e){if("object"==typeof e&&null!==e)return e}function on(e,t,i,n,r,l){if(void 0!==i&&i.length>0){let e=Ne(n,i,r,l);if("string"==typeof e&&fe(e))return e;let t=sn(e);return void 0!==t?.url&&fe(t.url)?t.url:void 0}return void 0!==e?.url&&fe(e.url)?e.url:"string"==typeof t&&fe(t)?t:void 0}function an(e,t,i,n,r){if(void 0!==t&&t.length>0){let e=Ne(i,t,n,r);return"string"==typeof e?e:void 0}if(void 0!==e?.alt)return e.alt}t(sn,"readMedia"),t(on,"pickUrl"),t(an,"pickAlt");var un={name:"upload",render:be((e,t)=>{let i=e.element,n=dn(t);if(void 0===n)return!1;let r=n.url;if("string"!=typeof r||!fe(r))return!1;if("IMG"===i.tagName){let e=i;return e.src=r,void(void 0!==n.alt&&(e.alt=n.alt))}if("A"===i.tagName){let e=i;return e.href=r,void(e.textContent=n.filename??r)}let l=void 0!==n.filename?li(n.filename):li(r);i.innerHTML=`<a href="${ui(r)}">${l}</a>`})};function dn(e){if("object"==typeof e&&null!==e)return e}t(dn,"readMedia");var hn={name:"relationship",render(e,t){let i=e.element,n=cn(t).join(", ");if("A"===i.tagName&&!Array.isArray(t)){let e=i,r=t?.url;return"string"==typeof r&&fe(r)&&(e.href=r),void(e.textContent=n)}i.textContent=n}};function cn(e){return null==e?[""]:Array.isArray(e)?e.map(fn):[fn(e)]}function fn(e){if("object"==typeof e&&null!==e){let t=e;return"string"==typeof t.title&&t.title.length>0?t.title:"string"==typeof t.name&&t.name.length>0?t.name:"string"==typeof t.slug&&t.slug.length>0?t.slug:void 0!==t.id?String(t.id):""}return Yi(e)}t(cn,"collectLabels"),t(fn,"pickLabel");var pn={name:"select",render(e,t){let i=e.element,n=gn(t);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){let e=i;return void(e.checked=e.value===n)}i.textContent=n}else i.value=n}};function gn(e){return Array.isArray(e)?e.map(e=>gn(e)).join(", "):Yi(e)}t(gn,"stringify");var mn={name:"checkbox",render(e,t){let i=e.element,n=!!t;"INPUT"!==i.tagName||"checkbox"!==i.type?i.hasAttribute("aria-checked")?i.setAttribute("aria-checked",n?"true":"false"):i.textContent=n?"true":"false":i.checked=n}},vn=new Map,yn=new Map;function bn(e,t){let i=Sn(e,t),n=vn.get(i);if(void 0!==n)return vn.delete(i),vn.set(i,n),n;let r=new Intl.NumberFormat(e,t);return vn.set(i,r),Tn(vn),r}function wn(e,t){let i=Sn(e,t),n=yn.get(i);if(void 0!==n)return yn.delete(i),yn.set(i,n),n;let r=new Intl.DateTimeFormat(e,t);return yn.set(i,r),Tn(yn),r}function Sn(e,t){let i=e??"";if(null==t)return i;let n=An(t);return"{}"===n?i:`${i}|${n}`}function An(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>An(e)).join(",")}]`;let t=e,i=Object.keys(t).sort(),n=[];for(let e of i){let i=t[e];void 0!==i&&n.push(`${JSON.stringify(e)}:${An(i)}`)}return`{${n.join(",")}}`}function Tn(e){for(;e.size>64;){let t=e.keys().next().value;if(void 0===t)break;e.delete(t)}}t(bn,"getNumberFormat"),t(wn,"getDateTimeFormat"),t(Sn,"buildKey"),t(An,"stableStringify"),t(Tn,"trimToLimit");var kn={name:"date",render(e,t,i){let n=e.element;if(null==t||""===t)return void("INPUT"===n.tagName?n.value="":("TIME"===n.tagName&&n.removeAttribute("datetime"),n.textContent=""));let r="string"==typeof t?t:Yi(t),l=new Date(r),s=!Number.isNaN(l.getTime());if("INPUT"!==n.tagName)return"TIME"===n.tagName?(n.setAttribute("datetime",s?l.toISOString():r),void(n.textContent=s?$n(l,i):r)):void(n.textContent=s?$n(l,i):r);n.value=s?Nn(n.type,l):r}};function $n(e,t){let i=t.locale??Me();try{return wn(i,{dateStyle:"medium",timeStyle:"short"}).format(e)}catch{return e.toISOString()}}function Nn(e,t){return"date"===e?t.toISOString().slice(0,10):"datetime-local"===e?t.toISOString().slice(0,16):t.toISOString()}t($n,"formatDate"),t(Nn,"toIsoForInput");var xn={name:"number",render(e,t,i){let n=e.element;if(null==t||""===t)return void("INPUT"===n.tagName?n.value="":n.textContent="");let r="number"==typeof t?t:Number(Yi(t));Number.isNaN(r)?n.textContent=Yi(t):"INPUT"!==n.tagName?n.textContent=Mn(r,i):n.value=String(r)}};function Mn(e,t){let i=t.locale??Me();try{return bn(i).format(e)}catch{return String(e)}}t(Mn,"format");var Cn=/\{\{([\s\S]*?)\}\}/g;function Ln(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function On(e,t,i,n){let r="object"==typeof t&&null!==t?t:null;return e.replace(Cn,(e,l)=>null!==r&&Ln(r,l)?li(n(Reflect.get(r,l))):null===r&&"value"===l?li(n(t)):"index"===l?String(i):e)}t(Ln,"hasOwn"),t(On,"interpolateArrayTemplate");var Rn={name:"array",render:be((e,t)=>{let i=e.element;if(!Array.isArray(t))return!1;let n=e.arrayTemplate;if(void 0!==n&&n.length>0){let e=Pn(n,t);return void(i.innerHTML=_t(e))}let r=e.arraySeparator??", ";i.textContent=t.map(En).join(r)})};function Pn(e,t){let i="";for(let n=0;n<t.length;n+=1)i+=In(e,t[n],n);return i}function In(e,t,i){return On(e,t,i,Yi)}function En(e){return Yi(e)}t(Pn,"renderTemplate"),t(In,"interpolate"),t(En,"stringify");var jn="data-payload-key",Fn="data-payload-nested-key",Dn="data-payload-nested-template";function Un(){return new WeakMap}function _n(e){let{template:t,container:i,patches:n,nextItems:r,store:l,forceRender:s=!1}=e,o=Wn(i,t,n,r,s,l);return null===o?null:qn(o,l)}function Wn(e,t,i,n,r,l){let s=Vn(e,t,n,zn(i),r,l.get(e),l);return null===s?null:[e,s,n]}function qn(e,t){let[i,n,r]=e,l=new Set,s=!1;for(let e of n){let[n,r,o,a]=e,u=r;if(void 0!==o){for(let e of a)null!==e[0]&&(Hn(e[0],e[1]),e[1].replaceWith(e[0])),void 0!==e[2]&&qn(e[2],t);null!==r&&(r.replaceWith(o),s=!0),u=o}if(null===u)continue;let d=i.children[n]??null;u!==d&&(i.insertBefore(u,d),s=!0),l.add(u)}for(let e of Array.from(i.children))l.has(e)||(e.remove(),s=!0);let o=Qn(i,t);o.clear();for(let e of r)Zn(o,e);return s}function Vn(e,t,i,n,r,l,s){let o=Array.from(e.children),a=Kn(o,jn),u=new Set,d=[];for(let h=0;h<i.length;h+=1){let c=i[h],f=Xn(c),p=void 0===f?o[h]??null:Yn(a,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=n.replaces.has(h),m=r||n.renders.has(h)||null===p?er(e.ownerDocument,t,c,h):void 0;if(null===m)return null;let v=void 0===m?[]:Bn(g?null:p,m,c,l,s);if(null===v)return null;d.push([h,p,m??void 0,v])}return d}function zn(e){let t=new Set,i=new Set;for(let n of e)"insert"===n.kind||"update"===n.kind?t.add(n.index):"replace"===n.kind&&(t.add(n.index),i.add(n.index));return{renders:t,replaces:i}}function Bn(e,t,i,n,r){let l=Kn(null===e?[]:Gn(e),Fn),s=Xn(i),o=void 0!==s?n?.get(s):void 0,a=[];for(let e of Gn(t)){let t=e.getAttribute(Fn);if(null===t)continue;let n,s=Yn(l,t)??null,u=e.getAttribute(Dn),d=u?s:null,h=d?.getAttribute(Dn)??null;if(u){let l=Jn(i,t);if(void 0!==l||null!==d){let i=l??[],s=Ve(null===d?[]:Jn(o,t)??[],i),a=null!==d&&h!==u;if((s.length>0||a)&&(n=Wn(d??e,u,s,i,a,r)??void 0,void 0===n))return null}}a.push([d,e,n])}return a}function Gn(e){return Array.from(e.querySelectorAll(`[${Fn}]`)).filter(t=>{let i=t.parentElement;for(;null!==i&&i!==e;){if(i.hasAttribute(Fn))return!1;i=i.parentElement}return i===e})}function Hn(e,t){for(let i of Array.from(e.attributes))t.hasAttribute(i.name)||e.removeAttribute(i.name);for(let i of Array.from(t.attributes))e.getAttribute(i.name)!==i.value&&e.setAttribute(i.name,i.value)}function Jn(e,t){if("object"!=typeof e||null===e)return;let i=e[t];return Array.isArray(i)?i:void 0}function Qn(e,t){let i=t.get(e);return i||(i=new Map,t.set(e,i)),i}function Zn(e,t){let i=Xn(t);void 0!==i&&e.set(i,t)}function Xn(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Kn(e,t){let i=new Map;for(let n=e.length-1;n>=0;n-=1){let r=e[n];if(void 0===r)continue;let l=r.getAttribute(t);if(null===l)continue;let s=i.get(l);void 0===s?i.set(l,[r]):s.push(r)}return i}function Yn(e,t){return e.get(t)?.pop()}function er(e,t,i,n){let r=_t(tr(t,i,n)),l=e.createElement("template");l.innerHTML=r;let s=l.content.firstElementChild;if(!s)return null;let o=Xn(i);return void 0!==o&&s.setAttribute(jn,o),s}function tr(e,t,i){return On(e,t,i,Yi)}function ir(){let e=new WeakMap,t=new WeakSet,i=Un();return{name:"structural-array",render:be((n,r)=>{if(!Array.isArray(r))return!1;let l=n.element,s=n.arrayTemplate;if(void 0===s||0===s.length)return or(t,l,n.fieldName),!1;let o=e.get(l),a=rr(l),u=Ve(o?.values??lr(a),r),d=nr(o,s,a);if(0===u.length&&!d)return e.set(l,{values:r.slice(),template:s,domSnapshot:a}),!1;let h=_n({template:s,container:l,patches:u,nextItems:r,store:i,forceRender:d});return null!==h&&(e.set(l,{values:r.slice(),template:s,domSnapshot:rr(l)}),!!h&&void 0)})}}function nr(e,t,i){return void 0===e||e.template!==t||!sr(e.domSnapshot,i)}function rr(e){return Array.from(e.children,e=>e.getAttribute(jn))}function lr(e){return e.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e})}function sr(e,t){return e.length===t.length&&e.every((e,i)=>e===t[i])}function or(e,t,i){e.has(t)||(e.add(t),ie(`[live-preview] LP0403: Skipping structural update for "${i}": <${t.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}t(Un,"createStructuralStore"),t(_n,"applyStructuralPatches"),t(Wn,"prepareStructuralPlan"),t(qn,"commitStructuralPlan"),t(Vn,"prepareReconciliation"),t(zn,"createPatchPlan"),t(Bn,"prepareNestedSlots"),t(Gn,"findDirectNestedSlots"),t(Hn,"synchronizeAttributes"),t(Jn,"readNestedArray"),t(Qn,"getMemory"),t(Zn,"rememberItem"),t(Xn,"readKey"),t(Kn,"indexByAttribute"),t(Yn,"takeIndexedElement"),t(er,"renderItem"),t(tr,"fillTemplate"),t(ir,"createStructuralArrayRenderer"),t(nr,"needsForcedRender"),t(rr,"readDomKeySnapshot"),t(lr,"valuesFromDomSnapshot"),t(sr,"sameDomKeySnapshot"),t(or,"warnMissingTemplate");var ar=new Map;function ur(e=[]){let t={};for(let i of e)t[i.name]=i;for(let[e,i]of ar)t[e]=i;return Object.freeze(t)}function dr(e){ar.set(e.name,e)}t(ur,"buildBuiltinRenderers"),t(dr,"registerBuiltinRenderer");var hr=[en,tn,nn,rn,{...rn,name:"email"},ln,un,hn,pn,{...pn,name:"radio"},mn,kn,xn,Rn,{...Rn,name:"blocks"}];function cr(){return ur([Qi(),...hr,ir()])}t(cr,"buildBuiltinRenderers");var fr=class{static{t(this,"LivePreviewClient")}#e=new dt;#t;#i;#r;#l;#s;#n=!1;#u=!1;#a=null;constructor(e={}){let i=e.debug??pt();this.#s=i?(...e)=>{ne("[live-preview]",...e)}:ee,this.#t=new At({...void 0!==e.allowedOrigins?{additionalOrigins:e.allowedOrigins}:{},...void 0!==e.disableReferrerDetection?{enableReferrerDetection:!e.disableReferrerDetection}:{},...void 0!==e.disableLocalhostMatching?{enableLocalhostMatching:!e.disableLocalhostMatching}:{}}),this.#t.isProductionUnconfigured&&this.#s("no trusted origin could be detected — set allowedOrigins or PAYLOAD_ADMIN_ORIGIN"),this.#i=new Ot(cr()),this.#l=new Lt({events:this.#e,config:Object.freeze({...e}),registerFieldRenderer:t(e=>this.#i.register(e),"registerFieldRenderer"),onTransformError:t(e=>{this.#e.emit("error",{error:e,context:"transform",code:"LP0602"})},"onTransformError"),log:this.#s}),this.#r=new Ze({...void 0!==e.root?{root:e.root}:{},renderers:this.#i.renderers,resolveRenderer:t(e=>this.#i.resolve(e),"resolveRenderer"),transformValue:t((e,t,i,n)=>this.#l.applyTransforms(e,t,i,n),"transformValue"),originMatcher:t(e=>this.#t.matches(e),"originMatcher"),readyTargets:this.#t.enumerate(),emitter:this.#e,...void 0!==e.serverURL&&""!==e.serverURL?{dataMerge:{serverURL:e.serverURL,...void 0!==e.apiRoute?{apiRoute:e.apiRoute}:{},...void 0!==e.mergeDepth?{depth:e.mergeDepth}:{},...void 0!==e.mergeFetch?{fetchFn:e.mergeFetch}:{}}}:{},...void 0!==e.debounceMs?{debounceMs:e.debounceMs}:{},...void 0!==e.heartbeatMs?{heartbeatMs:e.heartbeatMs}:{},...void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{},...void 0!==e.scopeBindingsByOwner?{scopeBindingsByOwner:e.scopeBindingsByOwner}:{},...void 0!==e.disableVisibilityGate?{disableVisibilityGate:e.disableVisibilityGate}:{},...void 0!==e.visibilityGateThreshold?{visibilityGateThreshold:e.visibilityGateThreshold}:{},...void 0!==e.enableA11y?{enableA11y:e.enableA11y}:{},...void 0!==e.a11yLocale?{a11yLocale:e.a11yLocale}:{},onHeartbeatTimeout:t(()=>{this.#t.unlockOrigin()},"onHeartbeatTimeout"),lockedOrigin:t(()=>this.#t.lockedOrigin,"lockedOrigin"),...void 0!==e.validateToken?{validateToken:e.validateToken}:{},log:this.#s}),this.#e.on("connect",e=>{this.#t.lockOrigin(e.origin)}),!1!==e.autoStart&&this.start()}start(){if(this.#u)return!1;if(this.#n)return this.#r.start(),!0;if(!ft())return!1;let e=this.#r.start();return e&&(this.#n=!0),e}suspend(){return!(this.#u||!this.#n)&&this.#r.suspend()}resume(){return!(this.#u||!this.#n)&&this.#r.start()}destroy(){if(null!==this.#a)return this.#a;this.#u=!0;let e,t,i=new Promise((i,n)=>{e=i,t=n});this.#a=i;try{this.#r.destroy(),this.#l.destroyAll().finally(()=>{this.#e.removeAllListeners()}).then(e,t)}catch(e){this.#e.removeAllListeners(),t(e)}return i}async use(e){if(this.#u)throw new Error("LivePreviewClient: already destroyed");await this.#l.register(e)}async unuse(e){await this.#l.unregister(e)}refreshCache(){this.#r.refreshCache()}get events(){return this.#e}get plugins(){return this.#l.list()}get status(){return this.#r.status}inspect(){return this.#r.inspect()}get updateCount(){return this.#r.updateCount}get destroyed(){return this.#u}};function pr(e={}){let t=new fr({...e,autoStart:!1});return t.start()?t:null}function gr(e,i={}){let n=i.windowTarget??globalThis.window,r=i.documentTarget??globalThis.document,l=i.softNavigationEvents??[],s=t(()=>{e.suspend()},"onPageHide"),o=t(t=>{!0===t.persisted&&e.resume()},"onPageShow"),a=t(()=>{e.refreshCache()},"onSoftNavigation");n?.addEventListener("pagehide",s),n?.addEventListener("pageshow",o);for(let e of l)r?.addEventListener(e,a);let u=!1;return()=>{if(!u){u=!0,n?.removeEventListener("pagehide",s),n?.removeEventListener("pageshow",o);for(let e of l)r?.removeEventListener(e,a)}}}t(pr,"initLivePreview"),t(gr,"bindNavigationLifecycle");var mr=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",OrphanField:"LP0201",UnattributableUpdate:"LP0202",VisibilityGateDeferred:"LP0301",UnsafeAttributeWrite:"LP0401",TextTargetHasChildren:"LP0402",MissingArrayTemplate:"LP0403",MessageRejected:"LP0501",TokenRejected:"LP0502",HandlerThrew:"LP0601",TransformThrew:"LP0602",RendererThrew:"LP0603",StartupFailed:"LP0605",ReadyFailed:"LP0606",AuditRuntimeMissing:"LP0701",AuditNoFrameAncestors:"LP0702",AuditFrameOptionsBlocks:"LP0703",AuditBindingsExposed:"LP0704",AuditGateThresholdExceeded:"LP0705",AuditUnownedBindings:"LP0706",AuditNoBindings:"LP0707",AuditNotAPage:"LP0708"}),vr='(()=>{function t(t){return("object"==typeof t&&null!==t||"function"==typeof t)&&"function"==typeof t.then&&(Promise.resolve(t).catch(()=>{}),!0)}function e(e){return(...i)=>{try{t(e(...i))}catch{}}}function i(){}function n(){return!0}function r(t){return`global:${t}`}function l(t,e){return void 0===e||""===e?`collection:${t}`:`collection:${t}:${e}`}function s(t){return"string"==typeof t&&t.length>0}function o(t,e){return null!==e&&void 0!==t&&e.includes(t)}function a(t){let e=t.id;return"string"==typeof e&&e.length>0?e:"number"==typeof e&&Number.isFinite(e)?String(e):void 0}function u(t){if(t.nodeType!==Ze)return!1;let e=t;return!!e.hasAttribute(ke)||null!==e.querySelector(`[${ke}]`)}function h(t){if(!Array.isArray(t))return[];let e=[];for(let i of t){let t=d(i);t&&e.push(t)}return e}function d(t){if("object"!=typeof t||null===t)return;let e=t,i=e.name,n=e.type;if("string"!=typeof i||0===i.length||"string"!=typeof n||0===n.length)return;let r=h(e.fields),l=function(t){if(!Array.isArray(t))return[];let e=[];for(let i of t){if("object"!=typeof i||null===i)continue;let t=i,n=t.slug;if("string"!=typeof n||0===n.length)continue;let r=h(t.fields);e.push({...t,slug:n,fields:r})}return e}(e.blocks),s={...e,name:i,type:n};return r.length>0?s.fields=r:delete s.fields,l.length>0?s.blocks=l:delete s.blocks,s}function c(t){let e="number"==typeof t&&Number.isFinite(t)&&t>=1?Math.floor(t):void 0,i=Math.min(4,e??1),n=new Set;for(let[t,e]of Object.entries(ni))i>=e&&n.add(t);return{ours:4,...void 0!==e?{theirs:e}:{theirs:void 0},negotiated:i,capabilities:n}}function f(t,e){return void 0===t||e(t)}function p(t,e){return null==t||e(t)}function g(t){if("object"!=typeof t||null===t)return!1;let e=Object.getPrototypeOf(t);return null===e||null===Object.getPrototypeOf(e)}function m(t){for(let e of t){let t=e.codePointAt(0);if(void 0!==t&&(t<=31||127===t))return!0}return!1}function y(t){if(void 0===t||0===t.length||t.length>128||"."===t||".."===t||t.includes("/")||t.includes("\\\\")||t.includes("?")||t.includes("#")||m(t))return!1;try{return encodeURIComponent(t),!0}catch{return!1}}function v(t,e){return t[6]===e}function b(t){return t.aborted}function w(t){if("string"!=typeof t||0===t.length)return!1;let e=t.trim();if(0===e.length||$i.test(e))return!1;if(e.startsWith("#")||e.startsWith("?")||e.startsWith("//")||e.startsWith("/"))return!0;try{let t=new URL(e);return Si.has(t.protocol)}catch{return Ai.test(e)}}function S(t){if(!w(t))return!1;let e=t.trim();return/^https?:\\/\\//i.test(e)||/^\\/\\/[^/]/.test(e)}function $(t){return Ni.add(t),t}function A(t,e){return null!==e&&t.generation===e.generation&&t.revision===e.revision}function k(t,e,i,n=!1){if(n&&void 0!==i){let n=T(t,`${e}_${i}`);if(void 0!==n)return n}let r=T(t,e);if(void 0!==r)return r;if(e.includes(".")){let i=t,n=!0;for(let t of e.split(".")){if(Fi.has(t)||null===i||"object"!=typeof i){n=!1;break}if(i=T(i,t),void 0===i){n=!1;break}}if(n)return i}return void 0===i?void 0:T(t,`${e}_${i}`)}function T(t,e){if(!Fi.has(e)&&Object.prototype.hasOwnProperty.call(t,e))return t[e]}function N(){let t=function(){if(typeof document>"u")return;let t=document.documentElement.getAttribute("lang");return null===t||0===t.length?void 0:t}();if(void 0!==t)return t;let e=function(){if(typeof navigator>"u")return;let t=navigator.language;return"string"==typeof t&&t.length>0?t:void 0}();return void 0!==e?e:"en"}function x(t){return/^de(?:[-_]|$)/i.test(t)}function M(t){null!==t[4]&&(clearTimeout(t[4]),t[4]=null),t[2]?.remove(),t[2]=null}function C(t,e=""){let i=new Map;return O(t,e,i),i}function O(t,e,i){for(let n of t){if(Vi.has(n.type)){n.fields&&O(n.fields,e,i);continue}if("group"===n.type){let t=""===e?n.name:`${e}.${n.name}`;i.set(t,n),n.fields&&O(n.fields,t,i);continue}let t=""===e?n.name:`${e}.${n.name}`;if(i.set(t,n),"array"===n.type&&n.fields)O(n.fields,`${t}.*`,i);else if("blocks"===n.type&&n.blocks)for(let e of n.blocks)O(e.fields,`${t}.*.${e.slug}`,i)}}function L(t){if("object"!=typeof t||null===t)return;let e=t.id;return"string"==typeof e||"number"==typeof e?e:void 0}function j(t){if("object"!=typeof t||null===t)return;let e=t.blockType;return"string"==typeof e?e:void 0}function E(t,e){return e.every(t=>void 0!==L(t))?function(t,e){let i=[],n=new Map;for(let e=0;e<t.length;e+=1){let i=L(t[e]);void 0!==i&&n.set(i,e)}let r=new Set;for(let l=0;l<e.length;l+=1){let s=e[l],o=L(s);if(void 0===o){i.push({kind:"insert",index:l,value:s});continue}let a=n.get(o);if(void 0===a){i.push({kind:"insert",index:l,value:s});continue}r.add(a);let u=t[a];j(u)===j(s)?(a!==l&&i.push({kind:"move",from:a,to:l,value:s}),I(u,s)||i.push({kind:"update",index:l,value:s})):i.push({kind:"replace",index:l,oldValue:u,value:s})}for(let e=0;e<t.length;e+=1)r.has(e)||i.push({kind:"remove",index:e,value:t[e]});return i}(t,e):function(t,e){let i=[],n=Math.min(t.length,e.length);for(let r=0;r<n;r+=1)I(t[r],e[r])||i.push({kind:"update",index:r,value:e[r]});if(e.length>t.length)for(let n=t.length;n<e.length;n+=1)i.push({kind:"insert",index:n,value:e[n]});if(t.length>e.length)for(let n=e.length;n<t.length;n+=1)i.push({kind:"remove",index:n,value:t[n]});return i}(t,e)}function I(t,e){if(Object.is(t,e))return!0;if("object"!=typeof t||"object"!=typeof e||null===t||null===e)return!1;let i=t,n=e,r=Object.keys(i),l=Object.keys(n);if(r.length!==l.length)return!1;for(let t of r)if(!Object.is(i[t],n[t]))return!1;return!0}function P(t){return 9===t.nodeType}function R(t){if(typeof window>"u")return;let e=[];window.parent!==window&&e.push(window.parent),window.opener instanceof Window&&e.push(window.opener),ri.sendReady(e,t)}function _(t,e){return t.generation===e.generation&&t.revision===e.revision}function W(t){return null!=t&&("string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)}function F(t,e){if(!e)return t;let i=`_${e}`;return t.endsWith(i)?t.slice(0,-i.length):t}function D(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function U(t){if(typeof process<"u"){let e=process.env[t];if("string"==typeof e&&e.length>0)return e}}function z(t){let e=t.trim();if(0!==e.length)try{let t=new URL(e);return"http:"!==t.protocol&&"https:"!==t.protocol||!Sn.test(t.origin)?void 0:t.origin}catch{return}}function V(t,e){let i=G();if(!i)throw new Pn("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===t)return"";let n=function(t){if(!t){let t=new Map;for(let[e,i]of Object.entries(Ln))t.set(e,i);return{allowedTags:Nn,attrByTag:t}}let e=new Set(Nn);for(let i of t.additionalAllowedTags??[])e.add(i);let i=new Map;for(let[t,e]of Object.entries(Ln))i.set(t,e);for(let[e,n]of Object.entries(t.additionalAllowedAttributes??{})){let t=i.get(e),r=new Set(t??[]);for(let t of n)r.add(t);i.set(e,r)}return{allowedTags:e,attrByTag:i}}(e),r=i.createElement("template");return r.innerHTML=t,B(r.content,n),r.innerHTML}function G(){if(!(typeof document>"u"))return document}function B(t,e){for(let i of Array.from(t.childNodes))i.nodeType===En?H(i,e):i.nodeType===In&&i.remove()}function H(t,e){let i=t.tagName.toLowerCase();if(xn.has(i))t.remove();else{if(!e.allowedTags.has(i)){B(t,e);let i=t.parentNode;if(i){for(;t.firstChild;)i.insertBefore(t.firstChild,t);t.remove()}return}(function(t,e,i){let n=i.attrByTag.get(e);for(let e of Array.from(t.attributes)){let i=e.name.toLowerCase();if(i.startsWith("on"))t.removeAttribute(e.name);else if("style"!==i){if(!(Mn.has(i)||i.startsWith(Cn)||i.startsWith(On))){if(n?.has(i)){(jn.has(i)&&!w(e.value)||"srcset"===i&&!q(e.value))&&t.removeAttribute(e.name);continue}t.removeAttribute(e.name)}}else t.removeAttribute(e.name)}})(t,i,e),"a"===i&&function(t){let e=t.getAttribute("href");null===e||!S(e)||(t.setAttribute("rel","noopener noreferrer"),t.hasAttribute("target")||t.setAttribute("target","_blank"))}(t),B(t,e)}}function q(t){let e=t.split(",");for(let t of e){let e=t.trim();if(0===e.length)continue;let i=e.search(/\\s/);if(!w(-1===i?e:e.slice(0,i)))return!1}return!0}function J(t,e){Rn.set(t,e)}function X(t){let e=t.format;if("string"==typeof e&&Wn.has(e))return e;if("number"==typeof e){let t=_n[e];if(void 0!==t)return t}}function Y(t){let e=t.indent;return"number"==typeof e&&e>0?e:0}function Z(t){return"rtl"===t.direction?\' dir="rtl"\':"ltr"===t.direction?\' dir="ltr"\':""}function K(t){let e=X(t),i=Y(t),n=[];return void 0!==e&&n.push(`text-align:${e}`),i>0&&n.push(`padding-inline-start:${String(40*i)}px`),0===n.length?"":` style="${n.join(";")}"`}function Q(t){return""===t?"":t.replace(Dn,t=>Fn[t])}function tt(t){return""===t?"":t.replace(zn,t=>Un[t])}function et(t){return Q(t).replace(/\\r\\n|\\r|\\n/g,"<br>")}function it(t){if("string"==typeof t.text)return t.text;if(!t.children)return"";let e="";for(let i of t.children)e+=it(i);return e}function nt(t){return t.replace(/[^a-zA-Z0-9_-]/g,"")}function rt(t){return Bn.get(t)}function lt(t){return t.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function st(t){if("object"!=typeof t||null===t||!("root"in t))return!1;let e=t.root;return"object"==typeof e&&null!==e&&"children"in e&&Array.isArray(e.children)}function ot(t){return st(t)?t.root.children.map(ht).join("\\n").trim():""}function at(t){let e="";for(let i of t)e+=ut(i);return e}function ut(t){let e=function(t){return Rn.get(t)}(t.type);return e?e(t,Rt):void 0!==t.children?at(t.children):""}function ht(t){if("string"==typeof t.text)return t.text;if("linebreak"===t.type)return"\\n";if(void 0===t.children)return"";let e="";for(let i of t.children)e+=ht(i);return e}function dt(){let t=new WeakSet;return{name:"text",render:$((e,i)=>{let n=e.element,r=function(t){return null==t?"":st(t)?ot(t):"string"==typeof t?t:"number"==typeof t||"boolean"==typeof t?String(t):JSON.stringify(t)}(i);if("INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName){if(function(t){return null!==t.firstElementChild}(n)&&!n.hasAttribute(_t))return function(t,e,i){t.has(e)||(t.add(e),pe(`[live-preview] LP0402: Skipping text update for "${i}": <${e.tagName.toLowerCase()}> has structured children. Move data-payload-field to the value element, or add data-payload-text to replace them.`))}(t,n,e.fieldName),!1;r.includes("\\n")||r.includes("\\r")?n.innerHTML=et(r):n.textContent=r}else n.value=r})}}function ct(t){if(null==t)return"";if("string"==typeof t)return t;if("number"==typeof t||"boolean"==typeof t||"bigint"==typeof t)return String(t);try{return JSON.stringify(t)}catch{return""}}function ft(t){if("object"==typeof t&&null!==t)return t}function pt(t){if("object"==typeof t&&null!==t){let e=t;return"string"==typeof e.title&&e.title.length>0?e.title:"string"==typeof e.name&&e.name.length>0?e.name:"string"==typeof e.slug&&e.slug.length>0?e.slug:void 0!==e.id?String(e.id):""}return ct(t)}function gt(t){return Array.isArray(t)?t.map(t=>gt(t)).join(", "):ct(t)}function mt(t,e){let i=t??"";if(null==e)return i;let n=yt(e);return"{}"===n?i:`${i}|${n}`}function yt(t){if(null===t||"object"!=typeof t)return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(t=>yt(t)).join(",")}]`;let e=t,i=Object.keys(e).sort(),n=[];for(let t of i){let i=e[t];void 0!==i&&n.push(`${JSON.stringify(t)}:${yt(i)}`)}return`{${n.join(",")}}`}function vt(t){for(;t.size>Xt;){let e=t.keys().next().value;if(void 0===e)break;t.delete(e)}}function bt(t,e,i,n){let r="object"==typeof e&&null!==e?e:null;return t.replace(Kt,(t,l)=>null!==r&&function(t,e){return Object.prototype.hasOwnProperty.call(t,e)}(r,l)?Q(n(Reflect.get(r,l))):null===r&&"value"===l?Q(n(e)):"index"===l?String(i):t)}function wt(t,e,i){return bt(t,e,i,ct)}function St(t){return ct(t)}function $t(t){let{template:e,container:i,patches:n,nextItems:r,store:l,forceRender:s=!1}=t,o=At(i,e,n,r,s,l);return null===o?null:kt(o,l)}function At(t,e,i,n,r,l){let s=function(t){let e=new Set,i=new Set;for(let n of t)"insert"===n.kind||"update"===n.kind?e.add(n.index):"replace"===n.kind&&(e.add(n.index),i.add(n.index));return{renders:e,replaces:i}}(i),o=function(t,e,i,n,r,l,s){let o=Array.from(t.children),a=Lt(o,te),u=new Set,h=[];for(let d=0;d<i.length;d+=1){let c=i[d],f=Ot(c),p=void 0===f?o[d]??null:jt(a,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=n.replaces.has(d),m=r||n.renders.has(d)||null===p?Et(t.ownerDocument,e,c,d):void 0;if(null===m)return null;let y=void 0===m?[]:Tt(g?null:p,m,c,l,s);if(null===y)return null;h.push([d,p,m??void 0,y])}return h}(t,e,n,s,r,l.get(t),l);return null===o?null:[t,o,n]}function kt(t,e){let[i,n,r]=t,l=new Set,s=!1;for(let t of n){let[n,r,o,a]=t,u=r;if(void 0!==o){for(let t of a)null!==t[0]&&(xt(t[0],t[1]),t[1].replaceWith(t[0])),void 0!==t[2]&&kt(t[2],e);null!==r&&(r.replaceWith(o),s=!0),u=o}if(null===u)continue;let h=i.children[n]??null;u!==h&&(i.insertBefore(u,h),s=!0),l.add(u)}for(let t of Array.from(i.children))l.has(t)||(t.remove(),s=!0);let o=function(t,e){let i=e.get(t);return i||(i=new Map,e.set(t,i)),i}(i,e);o.clear();for(let t of r)Ct(o,t);return s}function Tt(t,e,i,n,r){let l=Lt(null===t?[]:Nt(t),ee),s=Ot(i),o=void 0!==s?n?.get(s):void 0,a=[];for(let t of Nt(e)){let e=t.getAttribute(ee);if(null===e)continue;let n,s=jt(l,e)??null,u=t.getAttribute(ie),h=u?s:null,d=h?.getAttribute(ie)??null;if(u){let l=Mt(i,e);if(void 0!==l||null!==h){let i=l??[],s=E(null===h?[]:Mt(o,e)??[],i),a=null!==h&&d!==u;if((s.length>0||a)&&(n=At(h??t,u,s,i,a,r)??void 0,void 0===n))return null}}a.push([h,t,n])}return a}function Nt(t){return Array.from(t.querySelectorAll(`[${ee}]`)).filter(e=>{let i=e.parentElement;for(;null!==i&&i!==t;){if(i.hasAttribute(ee))return!1;i=i.parentElement}return i===t})}function xt(t,e){for(let i of Array.from(t.attributes))e.hasAttribute(i.name)||t.removeAttribute(i.name);for(let i of Array.from(e.attributes))t.getAttribute(i.name)!==i.value&&t.setAttribute(i.name,i.value)}function Mt(t,e){if("object"!=typeof t||null===t)return;let i=t[e];return Array.isArray(i)?i:void 0}function Ct(t,e){let i=Ot(e);void 0!==i&&t.set(i,e)}function Ot(t){if("object"!=typeof t||null===t)return;let e=t.id;return"string"==typeof e||"number"==typeof e?String(e):void 0}function Lt(t,e){let i=new Map;for(let n=t.length-1;n>=0;n-=1){let r=t[n];if(void 0===r)continue;let l=r.getAttribute(e);if(null===l)continue;let s=i.get(l);void 0===s?i.set(l,[r]):s.push(r)}return i}function jt(t,e){return t.get(e)?.pop()}function Et(t,e,i,n){let r=function(t,e,i){return bt(t,e,i,ct)}(e,i,n),l=V(r),s=t.createElement("template");s.innerHTML=l;let o=s.content.firstElementChild;if(!o)return null;let a=Ot(i);return void 0!==a&&o.setAttribute(te,a),o}function It(){let t=new WeakMap,e=new WeakSet,i=new WeakMap;return{name:"structural-array",render:$((n,r)=>{if(!Array.isArray(r))return!1;let l=n.element,s=n.arrayTemplate;if(void 0===s||0===s.length)return function(t,e,i){t.has(e)||(t.add(e),pe(`[live-preview] LP0403: Skipping structural update for "${i}": <${e.tagName.toLowerCase()} data-payload-structural> needs data-payload-array-template (for example "<li>{{label}}</li>").`))}(e,l,n.fieldName),!1;let o=t.get(l),a=Pt(l),u=o?.values??function(t){return t.map((t,e)=>null===t?{__payloadDomPosition:e}:{id:t})}(a),h=E(u,r),d=function(t,e,i){return void 0===t||t.template!==e||!function(t,e){return t.length===e.length&&t.every((t,i)=>t===e[i])}(t.domSnapshot,i)}(o,s,a);if(0===h.length&&!d)return t.set(l,{values:r.slice(),template:s,domSnapshot:a}),!1;let c=$t({template:s,container:l,patches:h,nextItems:r,store:i,forceRender:d});return null!==c&&(t.set(l,{values:r.slice(),template:s,domSnapshot:Pt(l)}),!!c&&void 0)})}}function Pt(t){return Array.from(t.children,t=>t.getAttribute(te))}var Rt,_t,Wt,Ft,Dt,Ut,zt,Vt,Gt,Bt,Ht,qt,Jt,Xt,Yt,Zt,Kt,Qt,te,ee,ie,ne,re,le=Object.defineProperty,se=t=>{throw TypeError(t)},oe=(t,e,i)=>((t,e,i)=>e in t?le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i)(t,"symbol"!=typeof e?e+"":e,i),ae=(t,e,i)=>e.has(t)||se("Cannot "+i),ue=(t,e,i)=>(ae(t,e,"read from private field"),i?i.call(t):e.get(t)),he=(t,e,i)=>e.has(t)?se("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),de=(t,e,i,n)=>(ae(t,e,"write to private field"),n?n.call(t,i):e.set(t,i),i),ce=(t,e,i)=>(ae(t,e,"access private method"),i),fe=e((...t)=>console.error(...t)),pe=e((...t)=>console.warn(...t)),ge=e((...t)=>console.debug(...t)),me=class{constructor(){he(this,be);he(this,ye,new Map);he(this,ve,new Map)}on(t,e){return ce(this,be,Se).call(this,ue(this,ye),t,e)}once(t,e){return ce(this,be,Se).call(this,ue(this,ve),t,e)}off(t,e){ce(this,be,$e).call(this,ue(this,ye),t,e),ce(this,be,$e).call(this,ue(this,ve),t,e)}async emit(t,e){await ce(this,be,we).call(this,t,e)}async emitWhile(t,e,i){return ce(this,be,we).call(this,t,e,i)}listenerCount(t){return(ue(this,ye).get(t)?.size??0)+(ue(this,ve).get(t)?.size??0)}removeAllListeners(t){void 0!==t?(ue(this,ye).delete(t),ue(this,ve).delete(t)):(ue(this,ye).clear(),ue(this,ve).clear())}eventNames(){let t=new Set;for(let e of ue(this,ye).keys())t.add(e);for(let e of ue(this,ve).keys())t.add(e);return[...t]}},ye=new WeakMap,ve=new WeakMap,be=new WeakSet,we=async function(t,e,i){let n=()=>i?.()??!0;if(!n())return!1;let r=ue(this,ye).get(t);if(r)for(let i of[...r])if(!n()||(await ce(this,be,Ae).call(this,i,e,t),!n()))return!1;if(!n())return!1;let l=ue(this,ve).get(t);if(l&&l.size>0){let i=[...l];ue(this,ve).delete(t);for(let r of i)if(!n()||(await ce(this,be,Ae).call(this,r,e,t),!n()))return!1}return n()},Se=function(t,e,i){let n=t.get(e);return n||(n=new Set,t.set(e,n)),n.add(i),()=>{ce(this,be,$e).call(this,t,e,i)}},$e=function(t,e,i){let n=t.get(e);void 0!==n&&(n.delete(i),0===n.size&&t.delete(e))},Ae=async function(t,e,i){try{await t(e)}catch(t){let e="string"==typeof i||"number"==typeof i?String(i):"<event>";fe(`[live-preview] LP0601: handler for "${e}" threw:`,t)}},ke="data-payload-field",Te="data-payload-type",Ne="data-payload-attribute",xe="data-payload-href",Me="data-payload-src",Ce="data-payload-alt",Oe="data-payload-array-template",Le="data-payload-array-separator",je="data-payload-locale",Ee="data-payload-richtext",Ie="data-payload-html",Pe="data-payload-array",Re="data-payload-structural",_e="data-payload-owner",We=[ke,Te,Ne,xe,Me,Ce,Oe,Le,je,Ee,Ie,Pe,Re,_e,"type"],Fe=`[${ke}]`,De=`[${_e}]`,Ue=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"]),ze=class{constructor(t={}){he(this,He);he(this,Ve,new Map);he(this,Ge,new WeakMap);he(this,Be);de(this,Be,t.filter??n)}buildFromRoot(t){let e=performance.now();this.clear();let i=t.querySelectorAll(Fe),n=0;for(let t of i)void 0!==this.add(t)&&(n+=1);return{elementCount:n,fieldCount:ue(this,Ve).size,durationMs:performance.now()-e}}add(t){let e=ue(this,Be).call(this,t)?ce(this,He,Ye).call(this,t):void 0,i=ue(this,Ge).get(t);if(void 0!==e)return void 0!==i&&ce(this,He,qe).call(this,i,e)?(ue(this,Ge).set(t,e),e):(void 0!==i&&ce(this,He,Je).call(this,t,i),ce(this,He,Xe).call(this,e),ue(this,Ge).set(t,e),e);void 0!==i&&ce(this,He,Je).call(this,t,i)}remove(t){let e=ue(this,Ge).get(t);return!!e&&ce(this,He,Je).call(this,t,e)}get(t){return ue(this,Ve).get(t)}getByElement(t){return ue(this,Ge).get(t)}get fieldCount(){return ue(this,Ve).size}get elementCount(){let t=0;for(let e of ue(this,Ve).values())t+=e.length;return t}entries(){return ue(this,Ve).entries()}*values(){for(let t of ue(this,Ve).values())yield*t}has(t){return ue(this,Ge).has(t)}clear(){ue(this,Ve).clear(),de(this,Ge,new WeakMap)}},Ve=new WeakMap,Ge=new WeakMap,Be=new WeakMap,He=new WeakSet,qe=function(t,e){if(t.fieldName!==e.fieldName)return!1;let i=ue(this,Ve).get(t.fieldName);if(!i)return!1;let n=i.indexOf(t);return!(n<0||(i[n]=e,0))},Je=function(t,e){let i=ue(this,Ve).get(e.fieldName);if(!i)return ue(this,Ge).delete(t),!1;let n=i.indexOf(e);return n<0?(ue(this,Ge).delete(t),!1):(i.splice(n,1),0===i.length&&ue(this,Ve).delete(e.fieldName),ue(this,Ge).delete(t),!0)},Xe=function(t){let e=ue(this,Ve).get(t.fieldName);e?e.push(t):ue(this,Ve).set(t.fieldName,[t])},Ye=function(t){let e=t.getAttribute(ke);if(null===e||0===e.length)return;let i=t.getAttribute(Te),n=function(t){let e=t.getAttribute(Te);if(null!==e&&Ue.has(e))return e;if(t.hasAttribute(Ee))return"richText";if(t.hasAttribute(Ie))return"html";if(t.hasAttribute(Re))return"structural-array";if(t.hasAttribute(Pe))return"array";if("IMG"===t.tagName)return"image";if("A"===t.tagName)return"url";if("TIME"===t.tagName)return"date";if("INPUT"===t.tagName){let e=t.type;if("checkbox"===e)return"checkbox";if("number"===e)return"number";if("date"===e||"datetime-local"===e)return"date"}return"text"}(t),r=t.getAttribute(Ne),l=t.getAttribute(xe),s=t.getAttribute(Me),o=t.getAttribute(Ce),a=t.getAttribute(Oe),u=t.getAttribute(Le),h=t.getAttribute(je),d=function(t){let e=t.closest(De)?.getAttribute(_e);return null==e||0===e.length?void 0:e}(t);return{element:t,fieldName:e,fieldType:n,explicitFieldType:null!==i&&Ue.has(i),...null!==r&&r.length>0?{targetAttribute:r}:{},...null!==l&&l.length>0?{hrefField:l}:{},...null!==s&&s.length>0?{srcField:s}:{},...null!==o&&o.length>0?{altField:o}:{},...null!==a?{arrayTemplate:a}:{},...null!==u?{arraySeparator:u}:{},...null!==h&&h.length>0?{locale:h}:{},...void 0!==d?{owner:d}:{}}},Ze=1,Ke=class{constructor(t,e={}){he(this,Qe);oe(this,"s");this.s=[t,e.mutationDebounceMs??100,e.intersectionRootMargin??"200px",new Set,null,null,null,0]}start(t){let e=this.s[7];this.stop();let i=e+1;if(this.s[7]!==i)return;let n=null,r=null;try{n=new MutationObserver(t=>{ce(this,Qe,ti).call(this,t,i)}),r=new IntersectionObserver(t=>{ce(this,Qe,ei).call(this,t,i)},{rootMargin:this.s[2],threshold:0}),n.observe(t,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...We]})}catch(t){throw n?.disconnect(),r?.disconnect(),t}this.s[7]===i?(this.s[4]=n,this.s[5]=r):(n.disconnect(),r.disconnect())}observeElement(t){this.s[5]?.observe(t)}unobserveElement(t){this.s[5]?.unobserve(t),this.s[3].delete(t)}markVisible(t,e){e?this.s[3].add(t):this.s[3].delete(t)}isVisible(t){return this.s[3].has(t)}stop(){this.s[7]+=1;let t=this.s[6],e=this.s[4],i=this.s[5];this.s[6]=null,this.s[4]=null,this.s[5]=null,this.s[3].clear(),null!==t&&clearTimeout(t);try{e?.disconnect()}finally{i?.disconnect()}}},Qe=new WeakSet,ti=function(t,e){if(!ce(this,Qe,ii).call(this,e)||!function(t){for(let e of t){if("attributes"===e.type&&null!==e.attributeName&&We.includes(e.attributeName)&&(e.attributeName===ke||e.attributeName===_e||e.target.nodeType===Ze&&e.target.hasAttribute(ke)))return!0;for(let t of e.addedNodes)if(u(t))return!0;for(let t of e.removedNodes)if(u(t))return!0}return!1}(t)||!ce(this,Qe,ii).call(this,e))return;null!==this.s[6]&&clearTimeout(this.s[6]);let i=setTimeout(()=>{!ce(this,Qe,ii).call(this,e)||this.s[6]!==i||(this.s[6]=null,this.s[0].onStructuralChange())},this.s[1]);this.s[6]=i},ei=function(t,e){for(let i of t){if(!ce(this,Qe,ii).call(this,e))return;let t=i.target;if(i.isIntersecting){if(!this.s[3].has(t)&&(this.s[3].add(t),this.s[0].onVisibilityChange(t,!0),!ce(this,Qe,ii).call(this,e)))return}else if(this.s[3].has(t)&&(this.s[3].delete(t),this.s[0].onVisibilityChange(t,!1),!ce(this,Qe,ii).call(this,e)))return}},ii=function(t){return this.s[7]===t&&null!==this.s[5]},ni={basic:1,"schema-json":2,"preview-token":3,"nested-arrays":4,"recursive-diffs":4},ri=class{constructor(t,e){he(this,li);oe(this,"s");this.s=[t,e,void 0,void 0,0,0,[],0]}attach(t=window){if(void 0!==this.s[3])return;let e=!1,i=t=>{if(!e||this.s[2]!==i)return;let n=this.s[4];try{ce(this,li,si).call(this,t,n)}catch{let e="";try{e=t.origin}catch{}ce(this,li,di).call(this,"shape",e,n)}};this.s[4]+=1,ce(this,li,mi).call(this),this.s[3]=t,this.s[2]=i;try{t.addEventListener("message",i)}catch(e){this.s[2]===i&&(this.s[3]=void 0,this.s[2]=void 0,ce(this,li,mi).call(this));try{t.removeEventListener("message",i)}catch{}throw e}if(this.s[2]===i)e=!0;else try{t.removeEventListener("message",i)}catch{}}detach(t){let e=this.s[3],i=this.s[2];void 0===e||void 0===i||(this.s[3]=void 0,this.s[2]=void 0,ce(this,li,mi).call(this),e.removeEventListener("message",i))}advanceGeneration(){return void 0!==this.s[3]&&(this.s[4]+=1,ce(this,li,mi).call(this),!0)}static sendReady(t,e){let i=t.length>0;if(!i||0===e.length)return;let n={type:"payload-live-preview",ready:i,protocolVersion:4};for(let i of t)for(let t of e)try{i.postMessage(n,t)}catch{}}},li=new WeakSet,si=function(t,e){if(!ce(this,li,pi).call(this,e))return;let i=t.origin;if(!ce(this,li,pi).call(this,e))return;if(!ce(this,li,ci).call(this,i,e)){ce(this,li,di).call(this,"origin",i,e);return}let n=t.data;if(!ce(this,li,pi).call(this,e))return;let r=function(t){return"object"==typeof t&&null!==t&&"type"in t&&"string"==typeof t.type}(n);if(!ce(this,li,pi).call(this,e))return;if(!r){ce(this,li,di).call(this,"shape",i,e);return}let l=n.type;if(ce(this,li,pi).call(this,e))switch(l){case"payload-live-preview":{let t=function(t){let e=t;return!!((void 0===e.data||null===e.data||g(e.data))&&p(e.fieldSchemaJSON,t=>Array.isArray(t))&&p(e.globalSlug,t=>"string"==typeof t)&&p(e.collectionSlug,t=>"string"==typeof t)&&p(e.locale,t=>"string"==typeof t)&&p(e.ready,t=>"boolean"==typeof t)&&p(e.previewToken,t=>"string"==typeof t)&&p(e.protocolVersion,t=>"number"==typeof t))}(n);if(!ce(this,li,pi).call(this,e))return;if(!t){ce(this,li,di).call(this,"shape",i,e);return}let r=function(t){let e={...t};for(let t of yi)null===Reflect.get(e,t)&&Reflect.deleteProperty(e,t);if(!Array.isArray(e.fieldSchemaJSON))return e;let i;try{i=h(e.fieldSchemaJSON)}catch{i=[]}return{...e,fieldSchemaJSON:i}}(n);if(!ce(this,li,pi).call(this,e))return;ce(this,li,oi).call(this,r,i,e);return}case"payload-document-event":{let t=function(t){let e=t;return!(!f(e.action,t=>"updated"===t||"created"===t||"deleted"===t)||!f(e.slug,t=>"string"==typeof t)||!f(e.id,t=>"string"==typeof t||"number"==typeof t&&Number.isFinite(t)))}(n);if(!ce(this,li,pi).call(this,e))return;if(!t){ce(this,li,di).call(this,"shape",i,e);return}let r;try{r=this.s[1].onDocumentEvent}catch{return}if(!ce(this,li,pi).call(this,e))return;ce(this,li,fi).call(this,r,n,i);return}default:ce(this,li,di).call(this,"type",i,e)}},oi=function(t,e,i){if(!ce(this,li,pi).call(this,i))return;let n=t.data;if(!ce(this,li,pi).call(this,i))return;let r=g(n);if(!ce(this,li,pi).call(this,i))return;let l,s=r?{generation:i,revision:this.s[5]+=1}:void 0;try{l=this.s[1].validateToken}catch{return}if(!ce(this,li,pi).call(this,i))return;if(void 0===l){ce(this,li,hi).call(this,t,e,i,s);return}if(!0===t.ready&&void 0===n){ce(this,li,hi).call(this,t,e,i,void 0);return}let o={generation:i,message:t,origin:e,messageRevision:s,settled:!1,approved:!1};this.s[6].push(o);let a;try{a=l(t.previewToken,e)}catch{ce(this,li,ai).call(this,o,!1);return}"boolean"!=typeof a?Promise.resolve(a).then(t=>{ce(this,li,ai).call(this,o,!0===t)},()=>{ce(this,li,ai).call(this,o,!1)}):ce(this,li,ai).call(this,o,a)},ai=function(t,e){ce(this,li,pi).call(this,t.generation)&&(t.approved=e,t.settled=!0,ce(this,li,ui).call(this,t.generation))},ui=function(t){for(;ce(this,li,pi).call(this,t);){let e=this.s[6][this.s[7]];if(void 0===e)return;if(ce(this,li,ci).call(this,e.origin,t)){if(!e.settled)return;ce(this,li,gi).call(this,e)&&(e.approved?ce(this,li,hi).call(this,e.message,e.origin,e.generation,e.messageRevision):ce(this,li,di).call(this,"token",e.origin,e.generation))}else{if(!ce(this,li,gi).call(this,e))continue;ce(this,li,di).call(this,"origin",e.origin,e.generation)}}},hi=function(t,e,i,n){if(!ce(this,li,pi).call(this,i))return;let r;try{r=this.s[1].onUpdate}catch{return}ce(this,li,pi).call(this,i)&&(void 0===n?ce(this,li,fi).call(this,r,t,e):ce(this,li,fi).call(this,r,t,e,n))},di=function(t,e,i){if(!ce(this,li,pi).call(this,i))return;let n;try{n=this.s[1].onInvalid}catch{return}ce(this,li,pi).call(this,i)&&void 0!==n&&ce(this,li,fi).call(this,n,t,e)},ci=function(t,e){if(!ce(this,li,pi).call(this,e))return!1;try{return!0===this.s[0](t)&&ce(this,li,pi).call(this,e)}catch{return!1}},fi=function(e,...i){try{t(e(...i))}catch{}},pi=function(t){return void 0!==this.s[3]&&this.s[4]===t},gi=function(t){let e=this.s;return e[6][e[7]]===t&&(e[7]+=1,e[7]===e[6].length?(ce(this,li,mi).call(this),!0):(e[7]>=1024&&2*e[7]>=e[6].length&&(e[6]=e[6].slice(e[7]),e[7]=0),!0))},mi=function(){this.s[6]=[],this.s[7]=0},yi=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],vi=class{constructor(t){oe(this,"s");this.s=[t.timeoutMs??0,t.onTimeout,null,0]}kick(){if(this.s[3]=Date.now(),this.s[0]<=0)return;null!==this.s[2]&&clearTimeout(this.s[2]);let t=setTimeout(()=>{this.s[2]===t&&(this.s[2]=null,this.s[1]())},this.s[0]);this.s[2]=t}stop(){null!==this.s[2]&&(clearTimeout(this.s[2]),this.s[2]=null)}get lastKickAt(){return this.s[3]}get pending(){return null!==this.s[2]}},bi=class{constructor(t){oe(this,"s");this.s=["disconnected",t]}get status(){return this.s[0]}markConnected(){return this.transition("connected")}markConnecting(){return this.transition("connecting")}markDisconnected(){return this.transition("disconnected")}transition(t){if(this.s[0]===t)return!1;let e=this.s[0];return this.s[0]=t,this.s[1](t,e),!0}},wi=class{constructor(t){oe(this,"s");let n=t.serverURL.replace(/\\/+$/,""),r=t.apiRoute??"/api";this.s=[n,r.startsWith("/")?r:`/${r}`,t.depth??1,t.fetchFn,void 0===t.log?i:e(t.log),null,0,0]}canMerge(t){try{return t.globalSlug?y(t.globalSlug):!!y(t.collectionSlug)&&function(t){if("number"==typeof t)return Number.isFinite(t);if("string"!=typeof t||0===t.length||t.length>512||"."===t||".."===t||t.includes("/")||t.includes("\\\\")||m(t))return!1;try{return encodeURIComponent(t),!0}catch{return!1}}(t.data.id)}catch{return!1}}async merge(t){if(this.s[7]>0)return{status:"superseded"};let e=this.s[6]+1;this.s[6]=e;let i=this.s[5];this.s[5]=null;let n=null;try{if(i?.abort(),!v(this.s,e))return{status:"superseded"};if(!this.canMerge(t))return v(this.s,e)?{status:"unavailable"}:{status:"superseded"};if(!v(this.s,e))return{status:"superseded"};let r=this.s[3]??("function"==typeof fetch?fetch:void 0);if(!v(this.s,e))return{status:"superseded"};if(void 0===r)return{status:"unavailable"};if(n=new AbortController,!v(this.s,e))return n.abort(),{status:"superseded"};this.s[5]=n;let l=t.globalSlug?`globals/${encodeURIComponent(t.globalSlug)}`:`${encodeURIComponent(t.collectionSlug??"")}/${encodeURIComponent(String(t.data.id))}`,s=`${this.s[0]}${this.s[1]}/${l}`,o=JSON.stringify({data:t.data,depth:this.s[2],flattenLocales:!1,...void 0!==t.locale?{locale:t.locale}:{}});if(!v(this.s,e))return{status:"superseded"};let a=await r(s,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Payload-HTTP-Method-Override":"GET"},body:o,signal:n.signal});if(!v(this.s,e)||b(n.signal))return{status:"superseded"};let u=a.ok;if(!v(this.s,e))return{status:"superseded"};if(!u){let t=a.status;return v(this.s,e)?(this.s[4]("merge HTTP",t,s),v(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"superseded"}}let h=await a.json();return!v(this.s,e)||b(n.signal)?{status:"superseded"}:null===h||"object"!=typeof h||Array.isArray(h)?(this.s[4]("merge invalid",s),v(this.s,e)?{status:"unavailable"}:{status:"superseded"}):{status:"merged",doc:h}}catch(t){return!v(this.s,e)||null!==n&&b(n.signal)?{status:"superseded"}:(this.s[4]("merge exception",t),v(this.s,e)?{status:"unavailable"}:{status:"superseded"})}finally{null!==n&&v(this.s,e)&&this.s[5]===n&&(this.s[5]=null)}}destroy(){this.s[6]+=1;let t=this.s[5];this.s[5]=null,this.s[7]+=1;try{t?.abort()}finally{this.s[7]-=1}}},Si=new Set(["http:","https:","mailto:","tel:"]),$i=/^\\s*(?:javascript|data|vbscript|file|blob|about)\\s*:/i,Ai=/^(?:\\.{1,2}\\/|[a-zA-Z0-9_-]+\\/?)/,ki=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),Ti=new Set(["href","src","poster","cite","action","xlink:href","data"]),Ni=new WeakSet,xi=class{constructor(t,e){he(this,Mi);oe(this,"s");let i=e.scheduleFrame??("function"==typeof requestAnimationFrame?requestAnimationFrame.bind(globalThis):t=>setTimeout(()=>{t(performance.now())},0)),n=e.cancelFrame??("function"==typeof cancelAnimationFrame?cancelAnimationFrame.bind(globalThis):t=>{clearTimeout(t)});this.s=[t,e.debounceMs??50,e.isVisible,e.visibilityGateThreshold??50,e.disableVisibilityGate??!1,e.getCacheSize,e.onFlush,i,n,new Map,new Map,new Set,null,0,null,0,null,!1]}schedule(t){if(void 0!==t.identity&&(this.s[17]||!A(t.identity,this.s[16])))return;let e=this.s[9],i=e.get(t.target.element);i?(i.value=t.value,i.allFields=t.allFields,i.identity=t.identity,i.data=t.data):e.set(t.target.element,{...t,identity:t.identity,data:t.data}),ce(this,Mi,Ci).call(this)}acceptRevision(t){let e=this.s[16];A(t,e)||null!==e&&function(t,e){return t.generation!==e.generation?t.generation-e.generation:t.revision-e.revision}(t,e)<0||(ce(this,Mi,_i).call(this),ce(this,Mi,Pi).call(this),this.s[16]=t,this.s[17]=!1)}cancelRevision(t){A(t,this.s[16])&&(ce(this,Mi,_i).call(this),ce(this,Mi,Pi).call(this),this.s[17]=!0)}flushNow(){return ce(this,Mi,_i).call(this),ce(this,Mi,Li).call(this)}notifyVisible(t){let e=this.s[10],i=e.get(t);if(!i||(e.delete(t),!ce(this,Mi,ji).call(this,i)))return;let n=performance.now(),r=ce(this,Mi,Ei).call(this,i)?1:0;this.s[6]?.(ce(this,Mi,Ri).call(this,i,r,0,performance.now()-n,1===r?[i.target.fieldName]:[]))}retarget(t){ce(this,Mi,Ii).call(this,this.s[9],t),ce(this,Mi,Ii).call(this,this.s[10],t);for(let e of this.s[11])ce(this,Mi,Ii).call(this,e,t)}forget(t){this.s[9].delete(t),this.s[10].delete(t);for(let e of this.s[11])e.delete(t)}destroy(){ce(this,Mi,_i).call(this),ce(this,Mi,Pi).call(this),this.s[16]=null,this.s[17]=!1}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}get gateThreshold(){return this.s[3]}get gateActive(){return!this.s[4]&&this.s[5]()>this.s[3]}},Mi=new WeakSet,Ci=function(){let t=this.s[13]+=1,e=this.s[12];if(this.s[12]=null,null!==e&&clearTimeout(e),this.s[13]!==t)return;let i=setTimeout(()=>{this.s[13]===t&&(this.s[12]=null,ce(this,Mi,Oi).call(this))},this.s[1]);this.s[13]===t&&(this.s[12]=i)},Oi=function(){let t=this.s[15]+=1,e=this.s[14];if(this.s[14]=null,null!==e&&this.s[8](e),this.s[15]!==t)return;let i=!1,n=this.s[7](()=>{this.s[15]===t&&(i=!0,this.s[14]=null,ce(this,Mi,Li).call(this))});!i&&this.s[15]===t&&(this.s[14]=n)},Li=function(){let t=performance.now(),e=!this.s[4]&&this.s[5]()>this.s[3],i=this.s[9];this.s[9]=new Map;let n,r=0,l=[],s=0;this.s[11].add(i);try{for(let t of i.values()){if(!ce(this,Mi,ji).call(this,t))continue;let i=!e||this.s[2](t.target.element);if(ce(this,Mi,ji).call(this,t)){if(n??(n=t),!i){this.s[10].set(t.target.element,t),s+=1;continue}this.s[10].delete(t.target.element),ce(this,Mi,Ei).call(this,t)&&(r+=1,l.push(t.target.fieldName))}}}finally{this.s[11].delete(i)}let o=ce(this,Mi,Ri).call(this,n,r,s,performance.now()-t,l);return this.s[6]?.(o),o},ji=function(t){return void 0===t.identity||!this.s[17]&&A(t.identity,this.s[16])},Ei=function(t){let e=this.s[0];return!1!==e(t)||!function(t){return Ni.has(t)}(e)},Ii=function(t,e){let i=t.get(e.element);if(void 0!==i){if(i.target.fieldName!==e.fieldName||i.target.locale!==e.locale){t.delete(e.element);return}i.target=e}},Pi=function(){this.s[9].clear(),this.s[10].clear();for(let t of this.s[11])t.clear()},Ri=function(t,e,i,n,r){return{applied:e,appliedFields:r,deferred:i,durationMs:n,...void 0!==t?.identity?{identity:t.identity}:{},...void 0!==t?.data?{data:t.data}:{}}},_i=function(){let t=this.s[12],e=this.s[14];this.s[13]+=1,this.s[15]+=1,this.s[12]=null,this.s[14]=null,null!==t&&clearTimeout(t),null!==e&&this.s[8](e)},Wi="1.8.0",Fi=new Set(["__proto__","prototype","constructor"]),Di="payload-live-preview-a11y",Ui=new WeakMap,zi=class{constructor(t,e){oe(this,"s");let i=e??(typeof document>"u"?null:document),n=i?.documentElement.getAttribute("lang")??"";this.s=[x(t??(n.length>0?n:N())),i,null]}mount(){let t=this.s[1];if(null==t?.body)return null;let e=this.s[2];null===e&&(e=function(t){let e=Ui.get(t);return e??(e=[null,!1,null,0,null]),Ui.set(t,e),e[3]+=1,e}(t),this.s[2]=e);let i=e[0];if(i?.isConnected&&i.ownerDocument===t)return i;if(null!==i){let t=e[1];M(e),t&&i.remove()}let n=t.getElementById(Di);return e[1]=null===n,n||(n=t.createElement("div"),n.id=Di,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-atomic","true"),n.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"),t.body.appendChild(n)),e[0]=n,n}announceConnected(){this.say(this.s[0]?"Vorschau verbunden":"Live preview connected")}announceDisconnected(){this.say(this.s[0]?"Vorschau getrennt":"Live preview disconnected")}announceUpdate(t){t<=0||this.say(this.s[0]?`${String(t)} ${1===t?"\\xc4nderung":"\\xc4nderungen"} angewendet`:`${String(t)} ${1===t?"change":"changes"} applied`)}detach(){let t=this.s[2],e=this.s[1];if(null===t||null===e||(this.s[2]=null,t[3]-=1,t[3]>0))return;let i=t[0];null!==i&&M(t),t[1]&&i?.remove(),t[0]=null,Ui.delete(e)}say(t){let e=this.mount(),i=this.s[2];if(null===e||null===i)return;let n=i[2];n?.parentNode!==e?(n?.remove(),n=e.ownerDocument.createTextNode(e.hasChildNodes()?` ${t}`:t),i[2]=n,e.appendChild(n)):n.data=null===n.previousSibling?t:` ${t}`,null!==i[4]&&clearTimeout(i[4]);let r=setTimeout(()=>{i[4]===r&&i[0]===e&&M(i)},1500);i[4]=r}},Vi=new Set(["tabs","row","collapsible"]),Gi={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"},Bi=[0,500,1e3,2e3],Hi=class{constructor(t){he(this,qi);oe(this,"d");oe(this,"l");let n=t.emitter,r=t.renderers,l=t.resolveRenderer??(t=>r[t]),s=t.transformValue,o=t.root??(typeof document<"u"?document:null),a=t.readyTargets,u=t.sendReady??R,h=t.onHeartbeatTimeout,d=void 0===t.log?i:e(t.log),f=void 0===t.warn?pe:e(t.warn),p=function(t){if(!1===t.enableA11y)return null;let e=void 0===t.root?void 0:9===t.root.nodeType?t.root:t.root.ownerDocument;return new zi(t.a11yLocale,e)}(t),g=void 0!==t.dataMerge?new wi({serverURL:t.dataMerge.serverURL,...void 0!==t.dataMerge.apiRoute?{apiRoute:t.dataMerge.apiRoute}:{},...void 0!==t.dataMerge.depth?{depth:t.dataMerge.depth}:{},...void 0!==t.dataMerge.fetchFn?{fetchFn:t.dataMerge.fetchFn}:{},log:(...t)=>{d(...t)}}):null,m=new ze,y=new Ke({onStructuralChange:()=>{ce(this,qi,Qi).call(this)},onVisibilityChange:(t,e)=>{e&&this.d[3].notifyVisible(t)}},{...void 0!==t.intersectionRootMargin?{intersectionRootMargin:t.intersectionRootMargin}:{}}),v=new xi($(t=>ce(this,qi,fn).call(this,t)),{...void 0!==t.debounceMs?{debounceMs:t.debounceMs}:{},...void 0!==t.disableVisibilityGate?{disableVisibilityGate:t.disableVisibilityGate}:{},...void 0!==t.visibilityGateThreshold?{visibilityGateThreshold:t.visibilityGateThreshold}:{},isVisible:t=>y.isVisible(t),getCacheSize:()=>m.elementCount,onFlush:t=>{ce(this,qi,pn).call(this,t)}}),b=new ri(t.originMatcher,{onUpdate:(t,e,i)=>{ce(this,qi,en).call(this,t,e,i)},onDocumentEvent:()=>{n.emit("documentSave",{timestamp:Date.now()})},onInvalid:(t,e)=>{if("token"===t){let t=new Error(`Preview token rejected (origin: ${e})`);n.emit("error",{error:t,context:"token",code:"LP0502"})}d("LP0501 message rejected:",t,e)},...void 0!==t.validateToken?{validateToken:t.validateToken}:{}}),w=new bi(()=>{}),S=new vi({...void 0!==t.heartbeatMs?{timeoutMs:t.heartbeatMs}:{},onTimeout:()=>{ce(this,qi,gn).call(this)}});this.d=[n,m,y,v,b,w,S,r,l,s,o,a,u,h,d,f,[],p,g,!0===t.scopeBindingsByOwner,t.lockedOrigin??(()=>{})],this.l=[void 0,void 0,void 0,c(void 0),!1,null,0,null,new Set,!1,!1,0,null,new Set]}start(){if(this.l[4])return!1;this.l[4]=!0;let t=this.d[10];if(P(t)&&"loading"===t.readyState){let e=()=>{if(this.l[4]){this.l[5]=null;try{ce(this,qi,Ji).call(this)}catch(t){ce(this,qi,Yi).call(this),ce(this,qi,yn).call(this,t,"startup","LP0605")}}};this.l[5]=e;try{t.addEventListener("DOMContentLoaded",e,{once:!0})}catch(t){throw ce(this,qi,Yi).call(this),t}return!0}try{return ce(this,qi,Ji).call(this),!0}catch(t){throw ce(this,qi,Yi).call(this),t}}suspend(){return!!this.l[4]&&(ce(this,qi,Xi).call(this)&&this.d[0].emit("disconnect",{reason:"unload",timestamp:Date.now()}),!0)}destroy(){this.l[4]&&(ce(this,qi,Xi).call(this)&&this.d[0].emit("disconnect",{reason:"destroy",timestamp:Date.now()}),this.d[17]?.detach(),this.d[0].emit("destroy",{timestamp:Date.now()}))}refreshCache(){this.l[4]&&ce(this,qi,Qi).call(this)}get status(){return this.d[5].status}get cache(){return this.d[1]}get updateCount(){return this.l[6]}get protocol(){return this.l[3]}inspect(){let t=this.d[1],e=this.d[3],i=this.l[3],n=this.l[7],r=this.l[12],l=[],s=new Set;for(let[e,i]of t.entries()){l.push(e);for(let t of i)void 0!==t.owner&&s.add(t.owner)}return{version:Wi,started:this.l[4],status:this.d[5].status,origins:{trusted:[...this.d[11]],locked:this.d[20]()},protocol:{ours:i.ours,theirs:i.theirs,negotiated:i.negotiated,capabilities:[...i.capabilities].sort()},revisions:{accepted:this.l[6],superseded:this.l[11],active:null===n?void 0:n.identity.revision},bindings:{elements:t.elementCount,fields:t.fieldCount,fieldNames:l.sort(),absentFields:[...this.l[13]].sort(),orphanFields:[...this.l[8]].sort(),ownerScoped:this.d[19],owners:[...s].sort()},scheduler:{pending:e.pendingCount,deferred:e.replayCount,visibilityGateThreshold:e.gateThreshold,visibilityGateActive:e.gateActive,lastFlush:null===r?void 0:{applied:r.applied,appliedFields:r.appliedFields,deferred:r.deferred,durationMs:r.durationMs}},renderers:Object.keys(this.d[7]).sort()}}},qi=new WeakSet,Ji=function(){if(!this.l[4])return;let t=P(this.d[10])?function(t){return t.body}(this.d[10]):this.d[10];if(null===t)throw new Error("LivePreviewRuntime: document.body unavailable");if(this.d[2].start(t),ce(this,qi,Ki).call(this),ce(this,qi,dn).call(this)&&(this.d[4].attach(),this.d[0].emitWhile("init",{timestamp:Date.now()},()=>this.l[4]),ce(this,qi,dn).call(this)))for(let t of Bi){if(!ce(this,qi,dn).call(this))return;if(0===t){if(this.d[12](this.d[11]),!ce(this,qi,dn).call(this))return}else{let e=setTimeout(()=>{this.l[4]&&ce(this,qi,mn).call(this)},t);this.d[16].push(e)}}},Xi=function(){this.l[7]=null,this.l[4]=!1;let t=this.l[5];this.l[5]=null,null!==t&&P(this.d[10])&&ce(this,qi,Zi).call(this,()=>{this.d[10].removeEventListener("DOMContentLoaded",t)});for(let t of this.d[16])ce(this,qi,Zi).call(this,()=>{clearTimeout(t)});return this.d[16].length=0,ce(this,qi,Zi).call(this,()=>{this.d[6].stop()}),ce(this,qi,Zi).call(this,()=>{this.d[4].detach()}),ce(this,qi,Zi).call(this,()=>{this.d[2].stop()}),ce(this,qi,Zi).call(this,()=>{this.d[3].destroy()}),ce(this,qi,Zi).call(this,()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()},Yi=function(){ce(this,qi,Xi).call(this),ce(this,qi,Zi).call(this,()=>{this.d[17]?.detach()})},Zi=function(t){try{t()}catch(t){this.d[14]("cleanup failed:",t)}},Ki=function(){if(!this.l[4])return;let t=this.d[1].buildFromRoot(this.d[10]);if(this.d[14]("cache",t),ce(this,qi,dn).call(this)&&(this.d[0].emitWhile("cacheRefresh",t,()=>this.l[4]),ce(this,qi,dn).call(this)))for(let t of this.d[1].values()){if(!ce(this,qi,dn).call(this))return;this.d[2].observeElement(t.element)}},Qi=function(){if(!this.l[4])return;let t=new Map;for(let e of this.d[1].values())t.set(e.element,e),this.d[2].unobserveElement(e.element);if(ce(this,qi,Ki).call(this),ce(this,qi,dn).call(this)){for(let e of this.d[1].values())t.get(e.element)?.fieldName===e.fieldName?this.d[3].retarget(e):this.d[3].forget(e.element),t.delete(e.element);for(let e of t.values())this.d[3].forget(e.element)}},tn=function(t){let e=this.l[3];if(e.theirs===t)return;let i=c(t);this.l[3]=i,i.negotiated!==e.negotiated&&this.d[14]("protocol","ours=4",`theirs=${t}`,`negotiated=${i.negotiated}`)},en=function(t,e,i){if(this.d[6].kick(),void 0===t.data){void 0!==t.protocolVersion&&ce(this,qi,tn).call(this,t.protocolVersion);return}if(void 0===i)return;"string"==typeof t.locale&&(this.l[0]=t.locale),Array.isArray(t.fieldSchemaJSON)&&(this.l[1]=t.fieldSchemaJSON,this.l[2]=C(t.fieldSchemaJSON));let n={identity:i,message:t,locale:this.l[0],schema:this.l[1],schemaIndex:this.l[2],cancelled:!1};null!==this.l[7]&&(this.l[11]+=1),this.l[7]=n,this.d[3].acceptRevision(i),this.l[6]+=1,(void 0===t.protocolVersion||(ce(this,qi,tn).call(this,t.protocolVersion),this.l[4]&&this.l[7]===n))&&(this.d[5].markConnected()&&(this.d[17]?.announceConnected(),this.d[0].emit("connect",{origin:e,timestamp:Date.now()}),!this.l[4]||this.l[7]!==n||(this.d[14]("connection","disconnected","\\u2192","connected"),!this.l[4]||this.l[7]!==n))||ce(this,qi,nn).call(this,n))},nn=async function(t){let e=await ce(this,qi,rn).call(this,t);if(null===e||!this.l[4]||this.l[7]!==t)return;let{message:i}=t,n={fields:e,...void 0!==t.schema?{schema:t.schema}:{},..."string"==typeof i.globalSlug?{globalSlug:i.globalSlug}:{},..."string"==typeof i.collectionSlug?{collectionSlug:i.collectionSlug}:{},...void 0!==t.locale?{locale:t.locale}:{}};this.d[0].listenerCount("beforeUpdate")>0&&(!await this.d[0].emitWhile("beforeUpdate",{data:n,revision:t.identity.revision,cancel:()=>{t.cancelled=!0,this.d[3].cancelRevision(t.identity)}},()=>!t.cancelled&&this.l[4]&&this.l[7]===t)||t.cancelled||!this.l[4]||this.l[7]!==t)||this.l[4]&&this.l[7]===t&&ce(this,qi,ln).call(this,t,n)},rn=async function(t){let{message:e}=t,i=e.data??{};if(null===this.d[18])return i;let n=await this.d[18].merge({collectionSlug:e.collectionSlug,globalSlug:e.globalSlug,data:i,locale:t.locale});return this.l[4]&&this.l[7]===t?"merged"===n.status?n.doc:"superseded"===n.status?null:i:null},ln=function(t,e){if(!this.l[4]||this.l[7]!==t)return;let i=()=>this.l[4]&&this.l[7]===t,n=ce(this,qi,sn).call(this,t,e.fields);for(let[r,l]of this.d[1].entries()){if(!this.l[4]||this.l[7]!==t)return;for(let s of l){if(!1!==n&&!o(s.owner,n))continue;let l=k(e.fields,r,s.locale??t.locale,void 0!==s.locale);if(void 0===l){this.l[13].add(r);continue}if(!this.l[4]||this.l[7]!==t)return;let a=ce(this,qi,hn).call(this,s,l,e.fields,i);if(!this.l[4]||this.l[7]!==t)return;let u={target:s,value:a,allFields:e.fields,identity:t.identity,data:e};if(!this.l[4]||this.l[7]!==t)return;this.d[3].schedule(u)}}ce(this,qi,un).call(this,e.fields,t.locale,n)},sn=function(t,e){if(!this.d[19])return!1;let{message:i}=t,n=function(t){if(s(t.globalSlug))return[r(t.globalSlug)];if(!s(t.collectionSlug))return null;let e=l(t.collectionSlug);return s(t.documentId)?[e,l(t.collectionSlug,t.documentId)]:[e]}({globalSlug:"string"==typeof i.globalSlug?i.globalSlug:void 0,collectionSlug:"string"==typeof i.collectionSlug?i.collectionSlug:void 0,documentId:a(e)});return null===n&&!this.l[9]&&(this.l[9]=!0,this.d[15]("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),n},on=function(t){for(let e of this.d[1].values())if(o(e.owner,t))return!0;return!1},an=function(t,e){let i=this.d[1].get(t);return void 0!==i&&(!1===e||i.some(t=>o(t.owner,e)))},un=function(t,e,i){if(0===this.d[1].fieldCount||!1!==i&&!ce(this,qi,on).call(this,i))return;let n;for(let[r,l]of Object.entries(t)){if(this.l[8].has(r)||bn.has(r)||!W(l))continue;let t=F(r,e);if(!(ce(this,qi,an).call(this,r,i)||t!==r&&ce(this,qi,an).call(this,t,i))){if(void 0===n){n=new Set;for(let[t,e]of this.d[1].entries())for(let r of e)!1!==i&&!o(r.owner,i)||void 0!==r.locale&&n.add(`${t}_${r.locale}`)}n.has(r)||(this.l[8].add(r),this.d[15](`[live-preview] LP0201: update arrived for field "${r}" but no <\\u2026 data-payload-field="${t}"> element exists on this page. Render the binding anchor unconditionally in your template so live edits to an initially-empty field have somewhere to land.`))}}},hn=function(e,i,n,r){if(void 0===this.d[9])return i;try{let l=this.d[9](e.fieldName,i,{element:e.element,allFields:n},r),s=t(l);if(!r())return i;if(s)throw new TypeError(`Transform for "${e.fieldName}" returned a Promise/thenable; transforms must be synchronous`);return l}catch(t){if(!r())return i;let e=t instanceof Error?t:new Error(String(t));return this.d[0].emit("error",{error:e,context:"transform",code:"LP0602"}),i}},dn=function(){return this.l[4]},cn=function(t){0!==t.deferred&&(this.l[10]||(this.l[10]=!0,this.d[15](`[live-preview] LP0301: visibility gate held ${String(t.deferred)} offscreen update(s) until scrolled into view; see visibilityGateThreshold.`)))},fn=function(t){let e=this.l[7];if(null===e||void 0===t.identity||!_(e.identity,t.identity)||!this.l[4]||this.l[7]!==e)return!1;let i=void 0!==e.schemaIndex?function(t,e){if(t.has(e))return t.get(e);let i=e.replace(/\\.\\d+(?=\\.|$)/g,".*");return t.has(i)?t.get(i):void 0}(e.schemaIndex,t.target.fieldName):void 0,n=t.value,r=function(t,e){if(t.explicitFieldType)return t.fieldType;if(void 0!==e){let t=function(t){if(Object.prototype.hasOwnProperty.call(Gi,t))return Gi[t]}(e);if(void 0!==t)return t}return t.fieldType}(t.target,i?.type);"text"===r&&!0!==t.target.explicitFieldType&&function(t){if("object"!=typeof t||null===t||!("root"in t))return!1;let e=t.root;return"object"==typeof e&&null!==e&&Array.isArray(e.children)}(n)&&(r="richText");let l;try{l=this.d[8](r)}catch(t){if(!this.l[4]||this.l[7]!==e)return!1;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:i,context:"renderer",code:"LP0603"},()=>this.l[4]&&this.l[7]===e),!1}if(!this.l[4]||this.l[7]!==e)return!1;let s=this.d[0].listenerCount("elementUpdate")>0,o=s?function(t){return"INPUT"===t.tagName||"TEXTAREA"===t.tagName?t.value:"IMG"===t.tagName?t.src:t.textContent}(t.target.element):void 0;if(!this.l[4]||this.l[7]!==e)return!1;let a={allFields:t.allFields,locale:t.target.locale??e.locale,schema:i};try{if(void 0!==t.target.targetAttribute){if("blocked"===function(t,e,i){let n=e.toLowerCase().trim();if(0===n.length||n.startsWith("on")||ki.has(n))return"blocked";if(null==i)return t.removeAttribute(n),"applied";if("string"!=typeof i&&"number"!=typeof i&&"boolean"!=typeof i)return"blocked";let r=String(i);return Ti.has(n)&&!w(r)?"blocked":(t.setAttribute(n,r),"applied")}(t.target.element,t.target.targetAttribute,n))return this.d[15](`[live-preview] LP0401: refused to write field "${t.target.fieldName}" into attribute "${t.target.targetAttribute}" (unsafe attribute or value)`),!1}else{if(!l)return this.d[14]("no renderer for",r),!1;if(!1===function(t,e,i,n){return t.render(e,i,n)}(l,t.target,n,a)&&function(t){return Ni.has(t.render)}(l))return!1}}catch(t){if(!this.l[4]||this.l[7]!==e)return!1;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile("error",{error:i,context:"renderer",code:"LP0603"},()=>this.l[4]&&this.l[7]===e),!1}return!(!this.l[4]||this.l[7]!==e)&&(s&&this.d[0].emitWhile("elementUpdate",{element:t.target.element,fieldName:t.target.fieldName,previousValue:o,nextValue:n,revision:e.identity.revision},()=>this.l[4]&&this.l[7]===e),this.l[4]&&this.l[7]===e)},pn=function(t){this.l[12]=t,ce(this,qi,cn).call(this,t);let{identity:e,data:i}=t;if(0===t.applied||void 0===e||void 0===i)return;let n=this.l[7];if(null===n||!this.l[4]||this.l[7]!==n||!_(n.identity,e))return;let r=()=>this.l[4]&&this.l[7]===n&&_(n.identity,e);this.d[17]?.announceUpdate(t.applied),r()&&0!==this.d[0].listenerCount("afterUpdate")&&this.d[0].emitWhile("afterUpdate",{data:i,updatedCount:t.applied,durationMs:t.durationMs,revision:e.revision},r)},gn=function(){if(!ce(this,qi,dn).call(this))return;this.d[4].advanceGeneration();let t=this.l[7];this.l[7]=null,null!==t&&this.d[3].cancelRevision(t.identity),this.d[18]?.destroy();let e=this.d[5].markDisconnected();try{this.d[13]?.()}catch(t){this.d[14]("heartbeat:",t)}ce(this,qi,dn).call(this)&&(e&&ce(this,qi,vn).call(this)&&(this.d[17]?.announceDisconnected(),this.d[0].emitWhile("disconnect",{reason:"timeout",timestamp:Date.now()},()=>ce(this,qi,vn).call(this)),!ce(this,qi,dn).call(this)||ce(this,qi,vn).call(this)&&(this.d[14]("connection","connected","\\u2192","disconnected"),!ce(this,qi,dn).call(this)))||ce(this,qi,dn).call(this)&&ce(this,qi,mn).call(this))},mn=function(){try{this.d[12](this.d[11])}catch(t){ce(this,qi,yn).call(this,t,"ready","LP0606")}},yn=function(t,e,i){let n=t instanceof Error?t:new Error(String(t));this.d[0].emit("error",{error:n,context:e,code:i})},vn=function(){return this.l[4]&&"disconnected"===this.d[5].status&&null===this.l[7]},bn=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]),wn=/^https?:\\/\\/(localhost|127\\.0\\.0\\.1)(?::\\d+)?$/i,Sn=/^https?:\\/\\/[^/?#\\s]+$/i,$n=["PAYLOAD_ADMIN_ORIGIN","PUBLIC_PAYLOAD_ADMIN_ORIGIN","NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN"],An=class{constructor(t={}){he(this,kn);let e=new Set;for(let i of t.additionalOrigins??[]){let t=z(i);void 0!==t&&e.add(t)}for(let t of $n){let i=U(t);if(void 0!==i)for(let t of i.split(",")){let i=z(t);void 0!==i&&e.add(i)}}let i;if(t.enableReferrerDetection??1){let e=t.referrer??(typeof document<"u"?document.referrer:"");if(e.length>0)try{let t=new URL(e).origin;t&&"null"!==t&&(i=t)}catch{}}let n=(t.enableLocalhostMatching??!0)&&(t.forceDevMode??function(){let t=function(){if(!(typeof process>"u"))return"production"}();if(void 0!==t)return"production"!==t;0;if(typeof window<"u"){let t=window.location.hostname;if("localhost"===t||"127.0.0.1"===t)return!0}return!1}());de(this,kn,[e,i,n,void 0!==i,void 0])}matches(t){return 0!==t.length&&"null"!==t&&(void 0!==ue(this,kn)[4]?t===ue(this,kn)[4]:!!(ue(this,kn)[0].has(t)||0===ue(this,kn)[0].size&&void 0!==ue(this,kn)[1]&&t===ue(this,kn)[1]||ue(this,kn)[2]&&wn.test(t)))}lockOrigin(t){return!!this.matches(t)&&(ue(this,kn)[4]=t,!0)}unlockOrigin(){let t=ue(this,kn)[4];return ue(this,kn)[4]=void 0,t}get lockedOrigin(){return ue(this,kn)[4]}enumerate(){if(void 0!==ue(this,kn)[4])return[ue(this,kn)[4]];let t=new Set(ue(this,kn)[0]);if(0===ue(this,kn)[0].size&&void 0!==ue(this,kn)[1]&&t.add(ue(this,kn)[1]),ue(this,kn)[2])for(let e of Tn)t.add(`http://localhost:${String(e)}`),t.add(`http://127.0.0.1:${String(e)}`);return[...t]}get referrerWasAvailable(){return ue(this,kn)[3]}get isProductionUnconfigured(){return!(!D()||ue(this,kn)[0].size>0||ue(this,kn)[2]||void 0!==ue(this,kn)[1])}get isReferrerOnlyTrust(){return!(ue(this,kn)[0].size>0||ue(this,kn)[2])&&void 0!==ue(this,kn)[1]}},kn=new WeakMap,Tn=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],Nn=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"]),xn=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),Mn=new Set(["id","class","lang","dir","title","role","tabindex"]),Cn="aria-",On="data-",Ln={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"])},jn=new Set(["href","src","cite","poster"]),En=1,In=8,Pn=class extends Error{constructor(){super(...arguments);oe(this,"name","SanitizerEnvironmentError")}},Rn=(Object.freeze({allowedTags:Nn,removeCompletely:xn,globalAttributes:Mn,attributesByTag:Ln,urlAttributes:jn}),new Map),_n={1:"left",2:"center",3:"right",4:"justify"},Wn=new Set(["left","center","right","justify","start","end"]),Fn=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),Dn=/[&<>"\'/`=]/g,Un=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;"}),zn=/[&<>"\']/g,Vn=new Set(["h1","h2","h3","h4","h5","h6"]),Gn=(t,e)=>{let i="string"==typeof t.url?t.url:"",n=e.renderChildren(t.children??[]);if(0===i.length||!w(i))return n;let r=S(i)?\' target="_blank" rel="noopener noreferrer"\':function(t){let e="string"==typeof t.target?t.target:"";if(0===e.length)return"";let i=Q(e);return"_blank"===e?\' target="_blank" rel="noopener noreferrer"\':` target="${i}"`}(t),l="string"==typeof t.title?` title="${Q(t.title)}"`:"";return`<a href="${tt(i)}"${r}${l}>${n}</a>`},Bn=new Map;J("text",t=>{let e=Q("string"==typeof t.text?t.text:""),i="number"==typeof t.format?t.format:0;return!!(16&i)&&(e=`<code>${e}</code>`),!!(1&i)&&(e=`<strong>${e}</strong>`),!!(2&i)&&(e=`<em>${e}</em>`),!!(8&i)&&(e=`<u>${e}</u>`),!!(4&i)&&(e=`<s>${e}</s>`),!!(32&i)&&(e=`<sub>${e}</sub>`),!!(64&i)&&(e=`<sup>${e}</sup>`),!!(128&i)&&(e=`<mark>${e}</mark>`),e});J("paragraph",(t,e)=>{let i=e.renderChildren(t.children??[]);return`<p${Z(t)}${K(t)}>${i}</p>`});J("heading",(t,e)=>{let i="string"==typeof t.tag?t.tag.toLowerCase():"h2",n=Vn.has(i)?i:"h2",r=e.renderChildren(t.children??[]);return`<${n}${Z(t)}${K(t)}>${r}</${n}>`});J("list",(t,e)=>{let i="string"==typeof t.listType?t.listType:"bullet",n="number"===i?"ol":"ul",r="number"===i&&"number"==typeof t.start&&t.start>1?` start="${String(t.start)}"`:"",l="check"===i?\' role="list"\':"",s=e.renderChildren(t.children??[]);return`<${n}${Z(t)}${K(t)}${r}${l}>${s}</${n}>`});J("listitem",(t,e)=>{let i=e.renderChildren(t.children??[]);if("boolean"==typeof t.checked)return`<li role="checkbox" aria-checked="${t.checked?"true":"false"}"${K(t)}>${i}</li>`;let n="number"==typeof t.value?` value="${Q(String(t.value))}"`:"";return`<li${Z(t)}${K(t)}${n}>${i}</li>`});J("link",Gn);J("autolink",Gn);J("quote",(t,e)=>{let i=e.renderChildren(t.children??[]);return`<blockquote${Z(t)}${K(t)}>${i}</blockquote>`});J("code",t=>{let e=nt("string"==typeof t.language?t.language:"");return`<pre><code${""===e?"":` class="language-${e}"`}>${Q(it(t))}</code></pre>`});J("code-highlight",t=>{let e="string"==typeof t.text?t.text:"";return`<span${"string"==typeof t.highlightType?` class="token-${nt(t.highlightType)}"`:""}>${Q(e)}</span>`});J("linebreak",()=>"<br>");J("horizontalrule",()=>"<hr>");J("tab",()=>"\\t");J("upload",t=>{let e=function(t){let e=t.value;if("object"==typeof e&&null!==e)return e}(t);if(void 0===e)return"";let i=e.url;if("string"!=typeof i||!w(i))return"";let n="string"==typeof e.mimeType?e.mimeType:"";return n.startsWith("video/")?function(t,e){let i="number"==typeof t.width?` width="${String(t.width)}"`:"",n="number"==typeof t.height?` height="${String(t.height)}"`:"",r="string"==typeof t.mimeType?` type="${tt(t.mimeType)}"`:"";return`<video controls${i}${n}><source src="${tt(e)}"${r}></video>`}(e,i):n.startsWith("audio/")?function(t,e){let i="string"==typeof t.mimeType?` type="${tt(t.mimeType)}"`:"";return`<audio controls><source src="${tt(e)}"${i}></audio>`}(e,i):""===n||n.startsWith("image/")?function(t,e){let i="string"==typeof t.alt?Q(t.alt):"",n="number"==typeof t.width?` width="${String(t.width)}"`:"",r="number"==typeof t.height?` height="${String(t.height)}"`:"";return`<img src="${tt(e)}" alt="${i}"${n}${r} loading="lazy" decoding="async">`}(e,i):function(t,e){let i="string"==typeof t.filename?Q(t.filename):Q(e);return`<a href="${tt(e)}" target="_blank" rel="noopener noreferrer">${i}</a>`}(e,i)});J("relationship",t=>{let e="string"==typeof t.relationTo?t.relationTo:"",i=function(t){let e=t.value;if("object"==typeof e&&null!==e)return e}(t),n=function(t,e){return void 0===t?""===e?"#":`#${e}`:"string"==typeof t.title&&t.title.length>0?t.title:"string"==typeof t.name&&t.name.length>0?t.name:"string"==typeof t.slug&&t.slug.length>0?t.slug:void 0!==t.id?String(t.id):""===e?"#":`#${e}`}(i,e),r=Q(n),l=""===e?"":` data-relation-to="${Q(e)}"`,s=i?.url;return"string"==typeof s&&w(s)?`<a href="${tt(s)}"${l}>${r}</a>`:`<span${l}>${r}</span>`});J("block",(t,e)=>{let i=function(t){let e=t.fields;return"object"!=typeof e||null===e?{}:e}(t),n="string"==typeof i.blockType?i.blockType:"",r=lt(n);if(""!==n){let t=rt(n)??rt(r);if(t)return t(i,{renderChildren:e.renderChildren})}let l=[];""!==r&&l.push(`data-block-type="${Q(r)}"`);for(let[t,e]of Object.entries(i)){if("blockType"===t||"id"===t||null==e)continue;let i="string"==typeof e||"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e);l.push(`data-block-${lt(t)}="${Q(i)}"`)}return`<div${0===l.length?"":` ${l.join(" ")}`}></div>`});Rt={renderChildren:at,resolveAlignment:X,resolveIndent:Y};_t="data-payload-text";Wt={name:"textarea",render(t,e){let i=t.element,n=st(e)?ot(e):ct(e);"INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName?i.innerHTML=et(n):i.value=n}};Ft={name:"richText",render:$((t,e)=>{if(st(e))t.element.innerHTML=function(t,e={}){if(!st(t))return"";let i=at(t.root.children);return!1===e.sanitize||void 0===G()?i:V(i)}(e);else{if("string"!=typeof e)return!1;t.element.innerHTML=V(e)}})};Dt={name:"html",render(t,e){if(null==e){t.element.textContent="";return}let i="string"==typeof e?e:ct(e);t.element.innerHTML=V(i)}};Ut={name:"url",render(t,e,i){let n=t.element,r=ct(e);if("A"===n.tagName){let l=n,s=t.hrefField,o=void 0===s||0===s.length?e:k(i.allFields,s,i.locale,void 0!==t.locale);"string"==typeof o&&w(o)&&(l.href=o),l.textContent=r;return}"INPUT"!==n.tagName&&"TEXTAREA"!==n.tagName?n.textContent=r:n.value=r}};zt={name:"image",render:$((t,e,i)=>{let n=t.element,r=ft(e),l=void 0!==t.locale,s=function(t,e,i,n,r,l){if(void 0!==i&&i.length>0){let t=k(n,i,r,l);if("string"==typeof t&&w(t))return t;let e=ft(t);return void 0!==e?.url&&w(e.url)?e.url:void 0}return void 0!==t?.url&&w(t.url)?t.url:"string"==typeof e&&w(e)?e:void 0}(r,e,t.srcField,i.allFields,i.locale,l);if(void 0===s)return!1;if("IMG"===n.tagName){let e=n;e.src=s;let o=function(t,e,i,n,r){if(void 0!==e&&e.length>0){let t=k(i,e,n,r);return"string"==typeof t?t:void 0}if(void 0!==t?.alt)return t.alt}(r,t.altField,i.allFields,i.locale,l);void 0!==o&&(e.alt=o);return}n.style.backgroundImage=`url(\'${function(t){return t.replace(/[\'"()\\\\]/g,"\\\\$&")}(s)}\')`})};Vt={name:"upload",render:$((t,e)=>{let i=t.element,n=function(t){if("object"==typeof t&&null!==t)return t}(e);if(void 0===n)return!1;let r=n.url;if("string"!=typeof r||!w(r))return!1;if("IMG"===i.tagName){let t=i;t.src=r,void 0!==n.alt&&(t.alt=n.alt);return}if("A"===i.tagName){let t=i;t.href=r,t.textContent=n.filename??r;return}let l=void 0!==n.filename?Q(n.filename):Q(r);i.innerHTML=`<a href="${tt(r)}">${l}</a>`})};Gt={name:"relationship",render(t,e){let i=t.element,n=function(t){return null==t?[""]:Array.isArray(t)?t.map(pt):[pt(t)]}(e).join(", ");if("A"===i.tagName&&!Array.isArray(e)){let t=i,r=e?.url;"string"==typeof r&&w(r)&&(t.href=r),t.textContent=n;return}i.textContent=n}};Bt={name:"select",render(t,e){let i=t.element,n=gt(e);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){let t=i;t.checked=t.value===n;return}i.textContent=n}else i.value=n}};Ht={name:"checkbox",render(t,e){let i=t.element,n=!!e;"INPUT"!==i.tagName||"checkbox"!==i.type?i.hasAttribute("aria-checked")?i.setAttribute("aria-checked",n?"true":"false"):i.textContent=n?"true":"false":i.checked=n}};qt=new Map,Jt=new Map,Xt=64;Yt={name:"date",render(t,e,i){let n=t.element;if(null==e||""===e){"INPUT"===n.tagName?n.value="":("TIME"===n.tagName&&n.removeAttribute("datetime"),n.textContent="");return}let r="string"==typeof e?e:ct(e),l=new Date(r),s=!Number.isNaN(l.getTime());"INPUT"!==n.tagName?("TIME"!==n.tagName||n.setAttribute("datetime",s?l.toISOString():r),n.textContent=s?function(t,e){let i=e.locale??N();try{return function(t,e){let i=mt(t,e),n=Jt.get(i);if(void 0!==n)return Jt.delete(i),Jt.set(i,n),n;let r=new Intl.DateTimeFormat(t,e);return Jt.set(i,r),vt(Jt),r}(i,{dateStyle:"medium",timeStyle:"short"}).format(t)}catch{return t.toISOString()}}(l,i):r):n.value=s?function(t,e){return"date"===t?e.toISOString().slice(0,10):"datetime-local"===t?e.toISOString().slice(0,16):e.toISOString()}(n.type,l):r}};Zt={name:"number",render(t,e,i){let n=t.element;if(null==e||""===e){"INPUT"===n.tagName?n.value="":n.textContent="";return}let r="number"==typeof e?e:Number(ct(e));Number.isNaN(r)?n.textContent=ct(e):"INPUT"!==n.tagName?n.textContent=function(t,e){let i=e.locale??N();try{return function(t,e){let i=mt(t,e),n=qt.get(i);if(void 0!==n)return qt.delete(i),qt.set(i,n),n;let r=new Intl.NumberFormat(t,e);return qt.set(i,r),vt(qt),r}(i).format(t)}catch{return String(t)}}(r,i):n.value=String(r)}};Kt=/\\{\\{([\\s\\S]*?)\\}\\}/g;Qt={name:"array",render:$((t,e)=>{let i=t.element;if(!Array.isArray(e))return!1;let n=t.arrayTemplate;if(void 0!==n&&n.length>0){let t=function(t,e){let i="";for(let n=0;n<e.length;n+=1)i+=wt(t,e[n],n);return i}(n,e);i.innerHTML=V(t);return}let r=t.arraySeparator??", ";i.textContent=e.map(St).join(r)})};te="data-payload-key",ee="data-payload-nested-key",ie="data-payload-nested-template";ne=new Map;re=[Wt,Ft,Dt,Ut,{...Ut,name:"email"},zt,Vt,Gt,Bt,{...Bt,name:"radio"},Ht,Yt,Zt,Qt,{...Qt,name:"blocks"}];!function(){if(typeof window>"u"||!D()&&(typeof window>"u"||null==window.opener))return;let t=window.__livePreview;if(void 0!==t)return t;let[e=[],i="",n="/api",r=1,l=!1,s=50,o=!0,a=0,u=!1,h=50,d="200px",c=!1,f=!1,p=!1]=typeof __LIVE_PREVIEW_CONFIG__>"u"?[]:__LIVE_PREVIEW_CONFIG__,g=new An({additionalOrigins:e,enableReferrerDetection:!c,enableLocalhostMatching:!f});g.isProductionUnconfigured?pe("[live-preview] LP0101: No trusted origin. Set PAYLOAD_ADMIN_ORIGIN or pass allowedOrigins to generateInlineScript()."):g.isReferrerOnlyTrust&&pe("[live-preview] LP0102: document.referrer fallback trusts any framing site. Set allowedOrigins and a frame-ancestors CSP in production.");let m=new me,y=function(t=[]){let e={};for(let i of t)e[i.name]=i;for(let[t,i]of ne)e[t]=i;return Object.freeze(e)}([dt(),...re,It()]),v=new Hi({renderers:y,originMatcher:t=>g.matches(t),lockedOrigin:()=>g.lockedOrigin,readyTargets:g.enumerate(),emitter:m,...""!==i?{dataMerge:{serverURL:i,apiRoute:n,depth:r}}:{},debounceMs:s,heartbeatMs:a,intersectionRootMargin:d,disableVisibilityGate:u,visibilityGateThreshold:h,enableA11y:o,scopeBindingsByOwner:p,onHeartbeatTimeout:()=>{g.unlockOrigin()},...l?{log:(...t)=>{ge("[live-preview]",...t)}}:{}});m.on("connect",t=>{g.lockOrigin(t.origin)}),v.start();let b=function(t,e={}){let i=e.windowTarget??globalThis.window,n=e.documentTarget??globalThis.document,r=e.softNavigationEvents??[],l=()=>{t.suspend()},s=e=>{!0===e.persisted&&t.resume()},o=()=>{t.refreshCache()};i?.addEventListener("pagehide",l),i?.addEventListener("pageshow",s);for(let t of r)n?.addEventListener(t,o);let a=!1;return()=>{if(!a){a=!0,i?.removeEventListener("pagehide",l),i?.removeEventListener("pageshow",s);for(let t of r)n?.removeEventListener(t,o)}}}({suspend:()=>v.suspend(),resume:()=>v.start(),refreshCache:()=>{v.refreshCache()}}),w=Object.freeze({version:Wi,destroy:()=>{b(),v.destroy();let t=window;t.__livePreview===w&&delete t.__livePreview},refresh:()=>{v.refreshCache()},enumerateOrigins:()=>g.enumerate(),inspect:()=>v.inspect()});try{Object.defineProperty(window,"__livePreview",{value:w,writable:!1,configurable:!0})}catch(t){throw b(),v.destroy(),t}}()})();',yr={generatedAt:"2026-08-25T22:49:43.000Z",size:67950};function br(e={}){if(0===vr.length)throw new Error("[live-preview] runtime.generated.ts is empty. Run `npm run build:runtime` before bundling.");return[`var __LIVE_PREVIEW_CONFIG__=${wr(e)};`,vr].join("\n")}function wr(e){let t=[e.allowedOrigins,e.serverURL,e.apiRoute,e.mergeDepth,e.debug,e.debounceMs,e.enableA11y,e.heartbeatMs,e.disableVisibilityGate,e.visibilityGateThreshold,e.intersectionRootMargin,e.disableReferrerDetection,e.disableLocalhostMatching,e.scopeBindingsByOwner];for(;t.length>0&&void 0===t.at(-1);)t.pop();return`[${t.map(e=>void 0===e?"":JSON.stringify(e)).join(",")}]`.replace(/</g,"\\u003C")}function Sr(e,t={}){return`<script${void 0!==t.nonce?` nonce="${Tr(t.nonce)}"`:""}>${e}<\/script>`}function Ar(){return yr}function Tr(e){if(!/^[A-Za-z0-9+/=_-]+$/.test(e))throw new RangeError("wrapWithScriptTag: nonce contains invalid characters");return e}t(br,"generateInlineScript"),t(wr,"buildConfigLiteral"),t(Sr,"wrapWithScriptTag"),t(Ar,"runtimeBuildInfo"),t(Tr,"escapeNonce");var kr,$r=/[\t\n\f\r ]+/,Nr=/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g;function xr(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function Mr(e){kr=e??void 0}function Cr(e=16){if(!Number.isInteger(e)||e<8)throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(e)}`);let t=Lr();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.");let i=new Uint8Array(e);return t.getRandomValues(i),Or(i)}function Lr(){if(kr?.getRandomValues)return kr;let e=globalThis.crypto;return e?.getRandomValues?e:void 0}function Or(e){let t="";for(let i of e)t+=String.fromCharCode(i);return("function"==typeof btoa?btoa(t):Buffer.from(e).toString("base64")).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}function Rr(e={}){let{self:t=!0,origins:i=[],allowNone:n=!1}=e,r=new Set,l=[];if(n&&!t&&0===i.length)return"'none'";t&&(l.push("'self'"),r.add("'self'"));for(let e of i){let t=e.trim();0===t.length||r.has(t)||(r.add(t),l.push(t))}return l.length>0?l.join(" "):"'none'"}function Pr(e,t={}){if(0===e.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");let{self:i=!0,extra:n=[],strictDynamic:r=!1}=t,l=[];i&&l.push("'self'"),l.push(`'nonce-${e}'`),r&&l.push("'strict-dynamic'");for(let e of n){let t=e.trim();t.length>0&&l.push(t)}return l.join(" ")}function Ir(e,t){let i=new Map;for(let t of e.split(";")){let e=t.replace(Nr,"");if(0===e.length)continue;let n=e.search($r),r=xr(n<0?e:e.slice(0,n));if(i.has(r))continue;let l=n<0?"":e.slice(n).replace(Nr,"");i.set(r,l)}for(let[e,n]of Object.entries(t)){let t=xr(e),r="string"==typeof n?{value:n}:n,l=r.mode??"union",s=i.get(t);if("replace"===l||void 0===s||0===s.length){i.set(t,r.value);continue}let o=new Set,a=[];for(let e of[...s.split($r),...r.value.split($r)])0===e.length||o.has(e)||(o.add(e),a.push(e));let u=a.filter(e=>"'none'"!==e);i.set(t,(u.length>0?u:a).join(" "))}let n=[];for(let[e,t]of i)n.push(0===t.length?e:`${e} ${t}`);return n.join("; ")}t(xr,"asciiLowercase"),t(Mr,"setCspCrypto"),t(Cr,"generateCspNonce"),t(Lr,"resolveCrypto"),t(Or,"base64UrlEncode"),t(Rr,"buildFrameAncestors"),t(Pr,"buildScriptSrcWithNonce"),t(Ir,"mergeCspHeader");var Er=["preview","draft","livePreview"];function jr(e,t={}){let i=new Set(t.signals??["query","fetch-dest","referer"]),n=t.queryParams??Er,r=(t.checkFetchDest??!0)&&i.has("fetch-dest");if(i.has("query")){let t;try{t=new URL(e.url)}catch{t=void 0}if(void 0!==t)for(let e of n){let i=t.searchParams.get(e);if("true"===i||"1"===i)return!0}}if(r&&"iframe"===e.headers.get("sec-fetch-dest"))return!0;let l=i.has("referer")?t.adminOrigins??[]:[];if(l.length>0){let t=e.headers.get("referer");if(null!==t)try{let e=new URL(t).origin;for(let t of l)try{if(new URL(t).origin===e)return!0}catch{}}catch{}}return!1}async function Fr(e){let t=_r(e);if(void 0!==e.id)return qr(`${Ur(e)}/${encodeURIComponent(e.collection)}/${encodeURIComponent(String(e.id))}?${t.toString()}`,e);void 0!==e.where&&Wr(t,e.where,["where"]),t.set("limit","1");let i=`${Ur(e)}/${encodeURIComponent(e.collection)}?${t.toString()}`;return(await qr(i,e))?.docs?.[0]??null}async function Dr(e){let t=_r(e);return qr(`${Ur(e)}/globals/${encodeURIComponent(e.global)}?${t.toString()}`,e)}function Ur(e){let t=e.serverURL.replace(/\/+$/,""),i=e.apiRoute??"/api";return`${t}${i.startsWith("/")?i:`/${i}`}`}function _r(e){let t=new URLSearchParams;return t.set("depth",String(e.depth??1)),(e.draft??!0)&&t.set("draft","true"),void 0!==e.locale&&t.set("locale",e.locale),t}function Wr(e,t,i){for(let[n,r]of Object.entries(t)){let t=[...i,n];if(null!==r&&"object"==typeof r&&!Array.isArray(r)){Wr(e,r,t);continue}let l=t.map((e,t)=>0===t?e:`[${e}]`).join("");Array.isArray(r)?e.set(l,r.map(String).join(",")):e.set(l,String(r))}}async function qr(e,t){let i=t.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===i)return null;try{let n=await i(e,{credentials:"include",headers:{Accept:"application/json",...t.headers??{}}});if(!n.ok)return null;let r=await n.json();return null===r||"object"!=typeof r?null:r}catch{return null}}t(jr,"isPreviewRequest"),t(Fr,"fetchPreviewDocument"),t(Dr,"fetchPreviewGlobal"),t(Ur,"apiBase"),t(_r,"baseParams"),t(Wr,"appendWhere"),t(qr,"requestJson");var Vr="payload-live-preview-highlight",zr=new WeakMap,Br=new WeakMap,Gr={name:"highlight",version:"1.0.0",init:t(e=>{if(typeof document>"u"||typeof window>"u")return;let i="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,n=Hr(document,i),r=i?1e3:600,l=new WeakMap,s=new Set;e.registerCleanup?.(()=>{for(let e of[...s])e();n()}),e.events.on("elementUpdate",e=>{let i=e.element;l.get(i)?.();let n=Jr(i),o=!1,a=t(()=>{o||(o=!0,window.clearTimeout(u),l.get(i)===a&&l.delete(i),s.delete(a),n())},"disposeTimer"),u=window.setTimeout(a,r);s.add(a),l.set(i,a)})},"init")};function Hr(e,t){let i=zr.get(e);if(void 0!==i&&!i.element.isConnected&&(zr.delete(e),i=void 0),void 0===i){let n=e.getElementById(Vr),r=n instanceof HTMLStyleElement?n:e.createElement("style"),l=null===n;l&&(r.id=Vr,r.textContent=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;}",e.head.appendChild(r)),i={element:r,pluginOwned:l,owners:0},zr.set(e,i)}let n=i;n.owners+=1;let r=!0;return()=>{r&&(r=!1,n.owners-=1,!(n.owners>0)&&(zr.get(e)===n&&zr.delete(e),n.pluginOwned&&n.element.remove()))}}function Jr(e){let t=Br.get(e);void 0===t&&(t={owners:0,pluginAdded:!e.classList.contains("lp-highlight")},Br.set(e,t));let i=t;i.owners+=1,e.classList.add("lp-highlight");let n=!0;return()=>{n&&(n=!1,i.owners-=1,!(i.owners>0)&&(Br.delete(e),i.pluginAdded&&e.classList.remove("lp-highlight")))}}t(Hr,"acquireStyle"),t(Jr,"acquireHighlight");var Qr={name:"debug",version:"1.0.0",init:t(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)})},"init")};function Zr(){let e=0,i=0,n=0;return{name:"analytics",version:"1.0.0",init:t(t=>{t.events.on("afterUpdate",t=>{e+=1,i+=t.updatedCount,n+=t.durationMs})},"init"),getStats:t(()=>({updateCount:e,totalElements:i,totalDurationMs:n,averageDurationMs:0===e?0:n/e}),"getStats")}}t(Zr,"createAnalyticsPlugin");var Xr="payload-live-preview:scroll";function Kr(){if(!(typeof window>"u"))try{sessionStorage.setItem(Xr,JSON.stringify({href:window.location.href,x:window.scrollX,y:window.scrollY}))}catch{}}function Yr(){if(!(typeof window>"u"))try{let e=sessionStorage.getItem(Xr);if(null===e)return;sessionStorage.removeItem(Xr);let t=JSON.parse(e);if(t.href!==window.location.href)return;window.scrollTo(t.x??0,t.y??0)}catch{}}function el(){typeof window>"u"||(Kr(),window.location.reload())}function tl(e={}){let i=e.strategy??"silent";return{name:"document-save",version:"1.1.0",init:t(t=>{let n=!0,r=new Set;t.registerCleanup?.(()=>{n=!1;for(let e of r)e.abort();r.clear()}),Yr(),t.events.on("documentSave",()=>{if(!n||"silent"===i)return;if("reload"===i)return void el();let l=new AbortController;r.add(l),("fetch"===i?il(e,t.log,l.signal,()=>n):nl(e,t.log,l.signal,()=>n)).finally(()=>{r.delete(l)})})},"init")}}async function il(e,t,i,n){if(e.handler)try{await e.handler(i)}catch(e){if(!n()||i.aborted)return;t("document-save handler threw:",e)}else t("document-save: fetch strategy selected but no handler supplied")}async function nl(e,t,i,n){if(typeof fetch>"u")return void t("document-save: revalidate strategy needs fetch — not available");let r=e.revalidateUrl??"/api/revalidate",l=!1;try{let s=await fetch(r,{method:"POST",signal:i,headers:{"Content-Type":"application/json",...e.revalidateHeaders??{}},body:JSON.stringify({source:"payload-live-preview"})});if(!n()||i.aborted)return;l=s.ok,l||t("document-save revalidate non-2xx:",s.status)}catch(e){if(!n()||i.aborted)return;t("document-save revalidate failed:",e)}!l&&"reload"===e.onRevalidateFailure&&el()}function rl(e,t){return sl(e,t)}function ll(e,t){let i=ol(e);if(0===i.length)throw new Error("bindByPath: the picker did not read any field — return data.<field> instead of a constant");return sl(i.join("."),t)}function sl(e,t){if(0===e.length)throw new Error("bind: field name must be a non-empty string");let i={"data-payload-field":e};return void 0!==t?.attribute&&(i["data-payload-attribute"]=t.attribute),void 0!==t?.type&&(i["data-payload-type"]=t.type),!0===t?.richtext&&(i["data-payload-richtext"]=""),!0===t?.html&&(i["data-payload-html"]=""),void 0!==t?.locale&&(i["data-payload-locale"]=t.locale),i}function ol(e){let t=[],i=new Proxy({},{get(e,n){if("symbol"!=typeof n)return/^\d+$/.test(n)||t.push(n),i}});try{e(i)}catch{}return t}t(Kr,"saveScrollPosition"),t(Yr,"restoreScrollPosition"),t(el,"reloadPreservingScroll"),t(tl,"documentSavePlugin"),t(il,"runFetch"),t(nl,"runRevalidate"),t(rl,"bind"),t(ll,"bindByPath"),t(sl,"buildAttributes"),t(ol,"recordPath");var al=Object.freeze({});function ul(e){let{authorized:i}=e,n=void 0!==e.owner&&e.owner.length>0?e.owner:void 0;return Object.freeze({authorized:i,bind:t((e,t)=>i?rl(e,t):al,"bind"),bindByPath:t((e,t)=>i?ll(e,t):al,"bindByPath"),owner:t(()=>i&&void 0!==n?{"data-payload-owner":n}:al,"owner")})}t(ul,"createPreviewBindings");export{mr as DIAGNOSTIC_CODES,dt as EventEmitter,F as LIBRARY_PROTOCOL_VERSION,fr as LivePreviewClient,At as OriginDetector,i as VERSION,rl as bind,ll as bindByPath,gr as bindNavigationLifecycle,cr as buildBuiltinRenderers,Rr as buildFrameAncestors,Pr as buildScriptSrcWithNonce,Zr as createAnalyticsPlugin,ul as createPreviewBindings,Qr as debugPlugin,Me as detectInitialLocale,tl as documentSavePlugin,li as escapeHtml,ui as escapeHtmlAttribute,Fr as fetchPreviewDocument,Dr as fetchPreviewGlobal,Cr as generateCspNonce,br as generateInlineScript,_ as hasCapability,Gr as highlightPlugin,pr as initLivePreview,pt as isDevMode,pe as isExternalHttpUrl,ht as isInIframe,ct as isInPopup,ft as isInPreviewContext,Vi as isLexicalContent,jr as isPreviewRequest,fe as isSafeUrl,zi as lexicalToHtml,Bi as lexicalToPlainText,Ir as mergeCspHeader,U as negotiateProtocol,Fi as registerBlockRenderer,dr as registerBuiltinRenderer,Ar as runtimeBuildInfo,_t as sanitizeHtml,Mr as setCspCrypto,Ut as setSanitizerDocument,Sr as wrapWithScriptTag};
1
+ var e="2.0.0-beta.0";function detectInitialLocale(){return function(){if("undefined"==typeof document)return;const e=document.documentElement.getAttribute("lang");return null===e||0===e.length?void 0:e}()??function(){if("undefined"==typeof navigator)return;const e=navigator.language;return"string"==typeof e&&e.length>0?e:void 0}()??"en"}var t="payload-live-preview-a11y",n=/* @__PURE__ */new WeakMap;function i(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}var r=class{german;document;lease=null;constructor(e,t){const n=t??("undefined"==typeof document?null:document),i=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(i.length>0?i:detectInitialLocale())),this.document=n}mount(){const e=this.document;if(null==e?.body)return null;this.lease??=function(e){let t=n.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},n.set(e,t)),t.refs+=1,t}(e);const r=this.lease,o=r.element;if(o?.isConnected&&o.ownerDocument===e)return o;if(null!==o){const e=r.owned;i(r),e&&o.remove()}let s=e.getElementById(t);return r.owned=null===s,null===s&&(s=e.createElement("div"),s.id=t,s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),s.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)),r.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 r=e.element;null!==r&&i(e),e.owned&&r?.remove(),e.element=null,n.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 o(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){const e=s(n);e&&t.push(e)}return t}function s(e){if("object"!=typeof e||null===e)return;const t=e,n=t.name,i=t.type;if("string"!=typeof n||0===n.length)return;if("string"!=typeof i||0===i.length)return;const r=o(t.fields),s=function(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if("object"!=typeof n||null===n)continue;const e=n,i=e.slug;if("string"!=typeof i||0===i.length)continue;const r=o(e.fields);t.push({...e,slug:i,fields:r})}return t}(t.blocks),a={...t,name:n,type:i};return r.length>0?a.fields=r:delete a.fields,s.length>0?a.blocks=s:delete a.blocks,a}var a=/* @__PURE__ */new Set(["tabs","row","collapsible"]);function l(e,t=""){const n=/* @__PURE__ */new Map;return u(e,t,n),n}function u(e,t,n){for(const i of e){if(a.has(i.type)){i.fields&&u(i.fields,t,n);continue}const e=""===t?i.name:`${t}.${i.name}`;if(n.set(e,i),"group"===i.type)i.fields&&u(i.fields,e,n);else if("array"===i.type&&i.fields)u(i.fields,`${e}.*`,n);else if("blocks"===i.type&&i.blocks)for(const t of i.blocks)u(t.fields,`${e}.*.${t.slug}`,n)}}function d(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function c(e){if("object"!=typeof e||null===e)return;const t=e.blockType;return"string"==typeof t?t:void 0}function h(e,t){return t.every(e=>void 0!==d(e))?function(e,t){const n=[],i=/* @__PURE__ */new Map;for(let t=0;t<e.length;t+=1){const n=d(e[t]);void 0!==n&&i.set(n,t)}const r=/* @__PURE__ */new Set;for(let o=0;o<t.length;o+=1){const s=t[o],a=d(s);if(void 0===a){n.push({kind:"insert",index:o,value:s});continue}const l=i.get(a);if(void 0===l){n.push({kind:"insert",index:o,value:s});continue}r.add(l);const u=e[l];c(u)===c(s)?(l!==o&&n.push({kind:"move",from:l,to:o,value:s}),f(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)r.has(t)||n.push({kind:"remove",index:t,value:e[t]});return n}(e,t):function(e,t){const n=[],i=Math.min(e.length,t.length);for(let r=0;r<i;r+=1)f(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 f(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,i=t,r=Object.keys(n),o=Object.keys(i);if(r.length!==o.length)return!1;for(const e of r)if(!Object.is(n[e],i[e]))return!1;return!0}var p={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"},g=/* @__PURE__ */new Set(["http:","https:","mailto:","tel:"]),m=/^\s*(?:javascript|data|vbscript|file|blob|about)\s*:/i,v=/^(?:\.{1,2}\/|[a-zA-Z0-9_-]+\/?)/,y=/^[\\/]{2}/,b=/[\t\n\r]/g;function isSafeUrl(e){if("string"!=typeof e||0===e.length)return!1;const t=e.trim().replace(b,"");if(0===t.length)return!1;if(m.test(t))return!1;if(t.startsWith("#")||t.startsWith("?"))return!0;if(y.test(t))return!0;if(t.startsWith("/"))return!0;try{const e=new URL(t);return g.has(e.protocol)}catch{return v.test(t)}}function isExternalHttpUrl(e){if(!isSafeUrl(e))return!1;const t=e.trim().replace(b,"");return/^https?:\/\//i.test(t)||y.test(t)}var w=/* @__PURE__ */new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),S=/* @__PURE__ */new Set(["href","src","poster","cite","action","xlink:href","data"]),k=/* @__PURE__ */new WeakSet;function A(e){return k.add(e),e}function T(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 C=class{previous=null;diff(e,t){const n=this.previous,i=/* @__PURE__ */new Map,r=/* @__PURE__ */new Set;for(const[t,o]of Object.entries(e)){const e=T(o);i.set(t,e),null!==n&&void 0!==e&&n.get(t)===e||r.add(t)}if(null!==n)for(const e of n.keys())i.has(e)||r.add(e);this.previous=i;const o=/* @__PURE__ */new Set;for(const[e,n]of Object.entries(t))if(r.has(e))for(const e of n)o.add(e);return{changed:r,invalidated:o}}reset(){this.previous=null}},$=4,R={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"}},x=Object.keys(R);function negotiateProtocol(e,t=[]){const n="number"==typeof e&&Number.isFinite(e)&&e>=1?Math.floor(e):void 0,i=n??1,r=Math.min(4,i),o=new Set(t),s=/* @__PURE__ */new Set;for(const e of x)(r>=R[e].since||o.has(e))&&s.add(e);return{ours:4,...void 0!==n?{theirs:n}:{theirs:void 0},negotiated:r,capabilities:s,observed:o}}function hasCapability(e,t){return e.capabilities.has(t)}var F=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 i=negotiateProtocol(e,this.observed);this.negotiation=i,i.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${i.negotiated}`)}};function N(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}var M=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(),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:N(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){this.#e=void 0}};function L(e,t){return e.generation===t.generation&&e.revision===t.revision}var E=class{started=!1;suspended=!1;deferredStart=null;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;lastAppliedIdentity=/* @__PURE__ */new WeakMap;seenFieldIdentity=/* @__PURE__ */new Map;fragmentStats={rendered:0,failed:0,superseded:0};routeStats={refreshes:0,failed:0,loopStopped:0};fragmentController=null;routeController=null;readyTimers=[];revealer=new M;changes=new C;protocol=new F;isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){e.completed||(e.completed=!0,this.completedCount+=1)}abortStrategies(){for(const e of["fragmentController","routeController"]){const t=this[e];null!==t&&(this[e]=null,t.abort())}}},P=class{constructor(e,t){this.deps=e,this.state=t}deps;state;apply(e){const{deps:t,state:n}=this,i=n.activeUpdate;if(null===i||void 0===e.identity||!L(i.identity,e.identity)||!n.isCurrent(i))return!1;const{target:r,value:o}=e,s=void 0!==i.schemaIndex?function(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}(i.schemaIndex,r.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(p,e))return p[e]}(t);if(void 0!==e)return e}return e.fieldType}(r,s?.type);"text"===l&&!0!==r.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,r)}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;const u=t.emitter.listenerCount("elementUpdate")>0,d=u?"INPUT"===(c=r.element).tagName||"TEXTAREA"===c.tagName?c.value:"IMG"===c.tagName?c.src:c.textContent:void 0;var c;if(!n.isCurrent(i))return!1;const h={allFields:e.allFields,locale:r.locale??i.locale,schema:s,...void 0!==t.renderRichText?{renderRichText:t.renderRichText}:{}};!0===r.boundary&&r.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!==r.targetAttribute){if("blocked"===function(e,t,n){const i=t.toLowerCase().trim();if(0===i.length)return"blocked";if(i.startsWith("on"))return"blocked";if(w.has(i))return"blocked";if(null==n)return e.removeAttribute(i),"applied";if("string"!=typeof n&&"number"!=typeof n&&"boolean"!=typeof n)return"blocked";const r=String(n);return S.has(i)&&!isSafeUrl(r)?"blocked":(e.setAttribute(i,r),"applied")}(r.element,r.targetAttribute,o))return t.warn(`[live-preview] LP0401: refused to write "${r.fieldName}" into attribute "${r.targetAttribute}"`),!1}else{if(void 0===a)return t.log("no renderer for",l),!1;{const e=function(e,t,n,i){return e.render(t,n,i)}(a,r,o,h);if(!1===e&&function(e){return k.has(e.render)}(a))return!1}}}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;u&&t.emitter.emitWhile("elementUpdate",{element:r.element,fieldName:r.fieldName,previousValue:d,nextValue:o,revision:i.identity.revision,receivedAt:i.receivedAt,source:"patch"},()=>n.isCurrent(i));const f=n.isCurrent(i);return f&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(r.element,e.valueIdentity):n.lastAppliedIdentity.delete(r.element)),f}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 I(...e){const t=/* @__PURE__ */new Map;for(const n of e)for(const[e,i]of Object.entries(n)){let n=t.get(e);void 0===n&&(n=/* @__PURE__ */new Set,t.set(e,n));for(const e of i)n.add(e)}const n={};for(const[e,i]of t)n[e]=[...i];return n}function O(e,t){const n={};for(const i of t)i!==e&&(n[i]=[e]);return n}var U="payload-live-preview:update",j="data-payload-island",D=`astro-island, [${j}]`;function H(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(j)}function z(e){return"patch"===e.getAttribute(j)}function isInsideIsland(e){let t=e;for(;null!==t;){if(H(t)&&!z(t))return!0;t=t.parentElement}return!1}function W(e){return e.closest("[data-payload-fragment]")}function B(e){const t=e.getAttribute("data-payload-strategy");return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==W(e)?"fragment":null!==e.closest("head")?"route":"patch"}var V="data-payload-field",_="data-payload-type",q="data-payload-attribute",G="data-payload-href",J="data-payload-src",K="data-payload-alt",Q="data-payload-array-template",X="data-payload-array-separator",Z="data-payload-locale",Y="data-payload-richtext",ee="data-payload-html",te="data-payload-array",ne="data-payload-structural",ie="data-payload-owner",re="data-payload-depends",oe="data-payload-strategy",se="data-payload-boundary",ae=[V,_,q,G,J,K,Q,X,Z,Y,ee,te,ne,ie,re,oe,se,"type"],le=`[${V}]`,ue=`[${ie}]`,de=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,ce=/* @__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 he(e){return ce.has(e)||de.test(e)}var fe=class{entriesByField=/* @__PURE__ */new Map;entryByElement=/* @__PURE__ */new WeakMap;filter;count=0;dependencies=null;islandRoots=[];constructor(e={}){this.filter=e.filter??ge}dependencyMap(){if(null!==this.dependencies)return this.dependencies;const e=[];for(const t of this.values())void 0!==t.dependsOn&&e.push(O(t.fieldName,t.dependsOn));return this.dependencies=I(...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(le))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){const t=[];for(const n of e.querySelectorAll(D))z(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),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);const 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){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(V);if(null===t||0===t.length)return;const n=e.getAttribute(_),i=e.getAttribute(q),r=e.getAttribute(G),o=e.getAttribute(J),s=e.getAttribute(K),a=e.getAttribute(Q),l=e.getAttribute(X),u=e.getAttribute(Z),d=function(e){const t=e.closest(ue)?.getAttribute(ie);return null==t||0===t.length?void 0:t}(e),c=function(e){if(null==e)return[];const t=/* @__PURE__ */new Set,n=[];for(const i of e.split(/[\s,]+/)){const e=i.trim();0===e.length||t.has(e)||(t.add(e),n.push(e))}return n}(e.getAttribute(re)),h=e.getAttribute(oe),f=W(e);return{element:e,fieldName:t,fieldType:pe(e),explicitFieldType:null!==n&&he(n),strategyKind:B(e)??"unknown",...null!==f?{fragmentBoundary:f}:{},...null!==i&&i.length>0?{targetAttribute:i}:{},...null!==r&&r.length>0?{hrefField:r}:{},...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}:{},...void 0!==d?{owner:d}:{},...c.length>0?{dependsOn:c}:{},...null!==h&&h.length>0?{strategy:h}:{},...e.hasAttribute(se)?{boundary:!0}:{}}}};function pe(e){const t=e.getAttribute(_);if(null!==t&&he(t))return t;if(e.hasAttribute(Y))return"richText";if(e.hasAttribute(ee))return"html";if(e.hasAttribute(ne))return"structural-array";if(e.hasAttribute(te))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 ge(){return!0}function me(e){return("object"==typeof e&&null!==e||"function"==typeof e)&&"function"==typeof e.then&&(Promise.resolve(e).catch(()=>{}),!0)}function ve(e){return(...t)=>{try{me(e(...t))}catch{}}}function ye(){}var be=ve((...e)=>console.error(...e)),we=ve((...e)=>console.warn(...e)),Se=ve((...e)=>console.debug(...e));function ke(e){for(const t of e){const e=t.codePointAt(0);if(void 0!==e&&(e<=31||127===e))return!0}return!1}function Ae(e){if(void 0===e||0===e.length||e.length>128||"."===e||".."===e||e.includes("/")||e.includes("\\")||e.includes("?")||e.includes("#")||ke(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}var Te=class{serverURL;apiRoute;depth;fetchFn;log;inflight=null;attempt=0;destroyDepth=0;constructor(e){this.serverURL=e.serverURL.replace(/\/+$/,"");const t=e.apiRoute??"/api";this.apiRoute=t.startsWith("/")?t:`/${t}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=void 0===e.log?ye:ve(e.log)}canMerge(e){try{return e.globalSlug?Ae(e.globalSlug):!!Ae(e.collectionSlug)&&function(e){if("number"==typeof e)return Number.isFinite(e);if("string"!=typeof e||0===e.length||e.length>512||"."===e||".."===e||e.includes("/")||e.includes("\\")||ke(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}(e.data.id)}catch{return!1}}async merge(e){if(this.destroyDepth>0)return{status:"superseded"};const t=this.attempt+=1,n=this.inflight;this.inflight=null;let i=null;const r=()=>this.attempt!==t;try{if(n?.abort(),r())return{status:"superseded"};if(!this.canMerge(e))return r()?{status:"superseded"}:{status:"unavailable"};const t=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===t)return{status:"unavailable"};i=new AbortController,this.inflight=i;const o=e.globalSlug?`globals/${encodeURIComponent(e.globalSlug)}`:`${encodeURIComponent(e.collectionSlug??"")}/${encodeURIComponent(String(e.data.id))}`,s=`${this.serverURL}${this.apiRoute}/${o}`,a=await t(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,...void 0!==e.locale?{locale:e.locale}:{}}),signal:i.signal});if(r()||Ce(i.signal))return{status:"superseded"};if(!a.ok)return this.log("merge HTTP",a.status,s),{status:"unavailable"};const l=await a.json();return r()||Ce(i.signal)?{status:"superseded"}:null===l||"object"!=typeof l||Array.isArray(l)?(this.log("merge invalid",s),{status:"unavailable"}):{status:"merged",doc:l}}catch(e){return r()||null!==i&&Ce(i.signal)?{status:"superseded"}:(this.log("merge exception",e),{status:"unavailable"})}finally{null===i||r()||this.inflight!==i||(this.inflight=null)}}destroy(){this.attempt+=1;const e=this.inflight;this.inflight=null,this.destroyDepth+=1;try{e?.abort()}finally{this.destroyDepth-=1}}};function Ce(e){return e.aborted}var $e={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},Re={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},xe={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1};function detectProtocolProfile(e){return e.has("schema-json")?$e:e.has("document-events")||e.has("relationship-events")?Re:xe}function Fe(e,t){return void 0===e||t(e)}function Ne(e,t){return null==e||t(e)}function Me(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}var Le=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],Ee=class{matcher;handlers;boundListener=void 0;attachedTarget=void 0;generation=0;revision=0;queue=[];queueHead=0;constructor(e,t){this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1;const n=e=>{if(!t||this.boundListener!==n)return;const i=this.generation;try{this.receive(e,i)}catch{let t;try{t=e.origin}catch{t=""}this.reportInvalid("shape",t,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){if(0===e.length||0===t.length)return;const n={type:"payload-live-preview",ready:!0,protocolVersion:4};for(const i of e)for(const e of t)try{i.postMessage(n,e)}catch{}}receive(e,t){if(!this.isCurrentGeneration(t))return;const n=e.origin;if(!this.matchesOrigin(n,t))return void this.reportInvalid("origin",n,t);if(!this.matchesSource(e))return void this.reportInvalid("source",n,t);const i=e.data;var r;if("object"==typeof(r=i)&&null!==r&&"type"in r&&"string"==typeof r.type)switch(i.type){case"payload-live-preview":return function(e){const t=e;return!(void 0!==t.data&&null!==t.data&&!Me(t.data))&&Ne(t.fieldSchemaJSON,e=>Array.isArray(e))&&Ne(t.globalSlug,e=>"string"==typeof e)&&Ne(t.collectionSlug,e=>"string"==typeof e)&&Ne(t.locale,e=>"string"==typeof e)&&Ne(t.ready,e=>"boolean"==typeof e)&&Ne(t.previewToken,e=>"string"==typeof e)&&Ne(t.protocolVersion,e=>"number"==typeof e)}(i)?void this.dispatchUpdate(function(e){const t={...e};for(const e of Le)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);if(!Array.isArray(t.fieldSchemaJSON))return t;let n;try{n=o(t.fieldSchemaJSON)}catch{n=[]}return{...t,fieldSchemaJSON:n}}(i),n,t):void this.reportInvalid("shape",n,t);case"payload-document-event":return function(e){const t=e;return Fe(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&Fe(t.slug,e=>"string"==typeof e)&&Fe(t.id,e=>"string"==typeof e||"number"==typeof e&&Number.isFinite(e))}(i)?void this.invokeHandler(t,this.handlers.onDocumentEvent,i,n):void this.reportInvalid("shape",n,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);if(void 0===e)return void this.reportInvalid("shape",n,t);const r=this.handlers.onFocusField;return void(void 0!==r&&this.invokeHandler(t,r,e,n))}default:this.reportInvalid("type",n,t)}else this.reportInvalid("shape",n,t)}dispatchUpdate(e,t,n){const i=Me(e.data);if(!this.isCurrentGeneration(n))return;const r=i?{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,r);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:r,settled:!1,approved:!1};let a;this.queue.push(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){this.isCurrentGeneration(e.generation)&&(e.approved=t,e.settled=!0,this.drainQueue(e.generation))}drainQueue(e){for(;this.isCurrentGeneration(e);){const t=this.queue[this.queueHead];if(void 0===t)return;if(this.matchesOrigin(t.origin,e)){if(!t.settled)return;this.dequeue(t)&&(t.approved?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){this.isCurrentGeneration(n)&&(void 0===i?this.invokeHandler(n,this.handlers.onUpdate,e,t):this.invokeHandler(n,this.handlers.onUpdate,e,t,i))}reportInvalid(e,t,n){if(!this.isCurrentGeneration(n))return;const i=this.handlers.onInvalid;void 0!==i&&this.invokeHandler(n,i,e,t)}matchesSource(e){if("parent-or-opener"!==this.handlers.sourcePolicy)return!0;const t=this.attachedTarget;if(void 0===t)return!1;try{const n=e.source;if(null===n)return!1;const i=t.parent;if(i!==t&&n===i)return!0;const r=t.opener;return null!=r&&n===r}catch{return!1}}matchesOrigin(e,t){if(!this.isCurrentGeneration(t))return!1;try{return!0===this.matcher(e)&&this.isCurrentGeneration(t)}catch{return!1}}invokeHandler(e,t,...n){if(this.isCurrentGeneration(e))try{me(t(...n))}catch{}}isCurrentGeneration(e){return void 0!==this.attachedTarget&&this.generation===e}dequeue(e){return this.queue[this.queueHead]===e&&(this.queueHead+=1,this.queueHead===this.queue.length?(this.resetQueue(),!0):(this.queueHead>=1024&&2*this.queueHead>=this.queue.length&&(this.queue=this.queue.slice(this.queueHead),this.queueHead=0),!0))}resetQueue(){this.queue=[],this.queueHead=0}},Pe=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 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:[...ae]})}catch(e){throw i?.disconnect(),r?.disconnect(),e}if(this.generation!==n)return i.disconnect(),void r.disconnect();this.mutation=i,this.intersection=r}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&&ae.includes(t.attributeName)&&(t.attributeName===V||t.attributeName===ie||1===t.target.nodeType&&t.target.hasAttribute(V)))return!0;for(const e of t.addedNodes)if(Ie(e))return!0;for(const e of t.removedNodes)if(Ie(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 Ie(e){if(1!==e.nodeType)return!1;const t=e;return t.hasAttribute(V)||null!==t.querySelector(`[${V}]`)}var Oe=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}},Ue=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)}};function je(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function De(e){return"string"==typeof e&&e.length>0}function He(e,t){return null!==t&&void 0!==e&&t.includes(e)}function ze(e){const t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}var We=/* @__PURE__ */new Set(["__proto__","prototype","constructor"]);function Be(e,t,n,i=!1){if(i&&void 0!==n){const i=Ve(e,`${t}_${n}`);if(void 0!==i)return i}const r=Ve(e,t);if(void 0!==r)return r;if(t.includes(".")){let n=e,i=!0;for(const e of t.split(".")){if(We.has(e)||null===n||"object"!=typeof n){i=!1;break}if(n=Ve(n,e),void 0===n){i=!1;break}}if(i)return n}return void 0===n?void 0:Ve(e,`${t}_${n}`)}function Ve(e,t){if(!We.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}var _e=/* @__PURE__ */new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]);function qe(e,t,n){const i=e.get(t);return void 0!==i&&(!1===n||i.some(e=>He(e.owner,n)))}function Ge(e,t){const n=/* @__PURE__ */new Set;for(const[i,r]of e.entries())for(const e of r)(!1===t||He(e.owner,t))&&void 0!==e.locale&&n.add(`${i}_${e.locale}`);return n}function Je(e){const t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function Ke(e,t){if(void 0===t||0===t.length)return e;const n=`_${t}`;return e.endsWith(n)?e.slice(0,-n.length):e}var Qe,Xe,Ze="payload-live-preview";function Ye(e){Qe=e}function et(e){const t=function(){if(void 0!==Qe)return Qe;if(void 0!==Xe)return Xe;const e=function(){const e=globalThis.trustedTypes;if("object"==typeof e&&null!==e)return"function"==typeof e.createPolicy?e:void 0}();if(void 0===e)return Xe=null,null;try{Xe=e.createPolicy(Ze,{createHTML:e=>e})}catch{Xe=null}return Xe}();return null===t?e:t.createHTML(e)}var tt=/* @__PURE__ */new Set(["open","value","checked","selected"]);function nt(e,t){for(const n of t.keyAttributes){const t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function it(e){if(e.tagName.toLowerCase().includes("-"))return!0;if(e.hasAttribute(j)||e.hasAttribute("data-payload-owned"))return!0;const t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function rt(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!it(e)&&!it(t)}(e,t))return t;const i=function(e){const t=e.ownerDocument.activeElement;if(!(t instanceof HTMLElement&&e.contains(t)))return null;return{element:t,selection:t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?[t.selectionStart,t.selectionEnd]:null}}(e);return function(e,t){for(const n of Array.from(e.attributes))t.hasAttribute(n.name)||tt.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 i=function(e,t){const n=/* @__PURE__ */new Map;let i;for(const r of Array.from(e.children)){const e=nt(r,t);void 0!==e&&(n.has(e)?i??=e.slice(e.indexOf("=")+1):n.set(e,r))}return void 0!==i&&t.onDuplicateKey?.(e,i),n}(e,n),r=new Set(i.values()),o=Array.from(e.childNodes).filter(e=>!r.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 r=l[t];let c=null,h=r instanceof Element?nt(r,n):void 0;if(void 0!==h&&a.has(h)&&(h=void 0),void 0!==h){a.add(h);const e=i.get(h);if(void 0!==e&&!s.has(e)&&(c=ot(e,r,n)===e?e:null,null===c)){e.replaceWith(r),s.add(r),u=r.nextSibling;continue}}else{for(;d<o.length;){const i=o[d];if(d+=1,!s.has(i)){if(at(i,r)){c=ot(i,r,n)===i?i:null,null===c&&(e.replaceChild(r,i),s.add(r),u=r.nextSibling);break}if(i instanceof Element){const n=l[t+1];if(!(r instanceof Element)||void 0!==n&&at(i,n)){d-=1;break}e.replaceChild(r,i),s.add(r),u=r.nextSibling;break}if(!(r instanceof Element)){e.replaceChild(r,i),s.add(r),u=r.nextSibling;break}}}if(null===c&&s.has(r))continue}const f=c??r;for(s.add(f);null!==u&&u!==f&&!s.has(u)&&st(u);)u=u.nextSibling;f!==u&&e.insertBefore(f,u),u=f.nextSibling}for(const t of Array.from(e.childNodes))s.has(t)||t.remove()}(e,t,n),function(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,i]=n??[null,null];null!==e&&null!==i&&t.setSelectionRange(e,i)}catch{}}(i),e}function ot(e,t,n){return e instanceof Element&&t instanceof Element?it(e)&&it(t)?e:rt(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function st(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function at(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}var lt,ut=/* @__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"]),dt=/* @__PURE__ */new Set(["input","button","textarea","select","option","label"]),ct=/* @__PURE__ */new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),ht=/* @__PURE__ */new Set(["id","class","lang","dir","title","role","tabindex"]),ft="aria-",pt="data-",gt={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"])},mt=/* @__PURE__ */new Set(["href","src","cite","poster"]),vt=class extends Error{name="SanitizerEnvironmentError"},yt=/* @__PURE__ */new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"]),bt="strict";function wt(e){bt=e}function setSanitizerDocument(e){lt=e??void 0}function sanitizeHtml(e,t){const n=St();if(!n)throw"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__?new Error("sanitizeHtml needs a DOM"):new vt("sanitizeHtml needs a DOM; provide one with setSanitizerDocument() during SSR.");if(""===e)return"";const i=function(e){if(!e){const e=/* @__PURE__ */new Map;for(const[t,n]of Object.entries(gt))e.set(t,n);return{allowedTags:ut,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:bt,allowedData:/* @__PURE__ */new Set}}const t=new Set(ut);for(const n of e.additionalAllowedTags??[])t.add(n);if(!0===e.allowFormControls)for(const e of dt)t.add(e);const n=/* @__PURE__ */new Map;for(const[e,t]of Object.entries(gt))n.set(e,t);for(const[t,i]of Object.entries(e.additionalAllowedAttributes??{})){const e=n.get(t),r=new Set(e??[]);for(const e of i)r.add(e);n.set(t,r)}return{allowedTags:t,attrByTag:n,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:e.policy??bt,allowedData:new Set((e.allowedDataAttributes??[]).map(e=>e.toLowerCase()))}}(t),r=n.createElement("template");return r.innerHTML=et(e),kt(r.content,i),r.innerHTML}function St(){return"undefined"!=typeof __INLINE_BUILD__&&__INLINE_BUILD__||!lt?"undefined"!=typeof document?document:void 0:lt}function kt(e,t){for(const n of Array.from(e.childNodes))1===n.nodeType?At(n,t):8===n.nodeType&&n.remove()}function At(e,t){const n=e.tagName.toLowerCase();if(!ct.has(n)||t.allowFormControls&&dt.has(n)){if(!t.allowedTags.has(n)){kt(e,t);const n=e.parentNode;if(n){for(;e.firstChild;)n.insertBefore(e.firstChild,e);e.remove()}return}!function(e,t,n){const i=n.attrByTag.get(t);for(const t of Array.from(e.attributes)){const r=t.name.toLowerCase();if(r.startsWith("on")||"style"===r)e.removeAttribute(t.name);else{if("strict"===n.mode){if(n.templateMode&&yt.has(r))continue;if("id"===r||"name"===r||r.startsWith("data-payload-")){e.removeAttribute(t.name);continue}if(r.startsWith(pt)){n.allowedData.has(r)||e.removeAttribute(t.name);continue}if(ht.has(r)||r.startsWith(ft))continue}else if(ht.has(r)||r.startsWith(ft)||r.startsWith(pt))continue;i?.has(r)?mt.has(r)&&!isSafeUrl(t.value)?e.removeAttribute(t.name):"srcset"!==r||Tt(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),kt(e,t)}else e.remove()}function Tt(e){for(const t of e.split(",")){const e=t.trim();if(0===e.length)continue;const n=e.search(/\s/);if(!isSafeUrl(-1===n?e:e.slice(0,n)))return!1}return!0}var Ct=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"}),$t=/[&<>"'/`=]/g;function escapeHtml(e){return""===e?"":e.replace($t,e=>Ct[e])}var Rt=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}),xt=/[&<>"']/g;function escapeHtmlAttribute(e){return""===e?"":e.replace(xt,e=>Rt[e])}var Ft=/\{\{([\s\S]*?)\}\}/g;function Nt(e,t,n,i){const r="object"==typeof t&&null!==t?t:null;return e.replace(Ft,(e,o)=>null!==r&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(r,o)?escapeHtml(i(Reflect.get(r,o))):null===r&&"value"===o?escapeHtml(i(t)):"index"===o?String(n):e)}function Mt(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 Lt(e){return null==e||""===e}var Et=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],Pt=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],It=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\b/gi,Ot=/* @__PURE__ */new Map;function Ut(e){const t=Ot.get(e);if(void 0!==t)return t;const n=new Set(Et);for(const t of e.matchAll(It)){const e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}const i={};for(const e of n)i[e]=Pt;const r={additionalAllowedTags:[...n],additionalAllowedAttributes:i,allowFormControls:!0,templateMode:!0};return Ot.set(e,r),r}var jt="data-payload-key",Dt="data-payload-nested-key",Ht="data-payload-nested-template";function zt(e){const{template:t,container:n,patches:i,nextItems:r,store:o,forceRender:s=!1}=e,a=Bt(n,t,i,r,s,o);return null===a?null:Vt(a,o,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function Wt(e,t){return t.hasAttribute(Dt)&&t.hasAttribute(Ht)}function Bt(e,t,n,i,r,o){const s=function(e,t,n,i,r,o,s){const a=Array.from(e.children),l=Xt(a,jt),u=/* @__PURE__ */new Set,d=[];for(let c=0;c<n.length;c+=1){const h=n[c],f=Qt(h);let p=void 0===f?a[c]??null:Zt(l,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);const g=i.replaces.has(c),m=r||i.renders.has(c)||null===p?Yt(e.ownerDocument,t,h,c):void 0;if(null===m)return null;const v=void 0===m?[]:_t(g?null:p,m,h,o,s);if(null===v)return null;d.push([c,p,m??void 0,v,g])}return d}(e,t,i,function(e){const t=/* @__PURE__ */new Set,n=/* @__PURE__ */new Set;for(const 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}}(n),r,o.get(e),o);return null===s?null:[e,s,i]}function Vt(e,t,n){const[i,r,o]=e,s=/* @__PURE__ */new Set;let a=!1;for(const[e,o,l,u,d]of r){let r=o;if(void 0!==l){const e=!(!n.morph||d||null===o)&&rt(o,l,{keyAttributes:[jt,Dt],retainChildrenOf:Wt,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===o;if(!e)for(const[e,t]of u)null!==e&&(Gt(e,t),t.replaceWith(e));for(const[,,e]of u)void 0!==e&&Vt(e,t,n);e?a=!0:(null!==o&&(o.replaceWith(l),a=!0),r=l)}if(null===r)continue;const c=i.children[e]??null;r!==c&&(i.insertBefore(r,c),a=!0),s.add(r)}for(const e of Array.from(i.children))s.has(e)||(e.remove(),a=!0);const l=function(e,t){let n=t.get(e);return n||(n=/* @__PURE__ */new Map,t.set(e,n)),n}(i,t);l.clear();for(const e of o)Kt(l,e);return a}function _t(e,t,n,i,r){const o=Xt(null===e?[]:qt(e),Dt),s=Qt(n),a=void 0!==s?i?.get(s):void 0,l=[];for(const e of qt(t)){const t=e.getAttribute(Dt);if(null===t)continue;const i=Zt(o,t)??null,s=e.getAttribute(Ht),u=s?i:null,d=u?.getAttribute(Ht)??null;let c;if(s){const i=Jt(n,t);if(void 0!==i||null!==u){const n=i??[],o=h(null===u?[]:Jt(a,t)??[],n),l=null!==u&&d!==s;if((o.length>0||l)&&(c=Bt(u??e,s,o,n,l,r)??void 0,void 0===c))return null}}l.push([u,e,c])}return l}function qt(e){return Array.from(e.querySelectorAll(`[${Dt}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(Dt))return!1;n=n.parentElement}return n===e})}function Gt(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 Jt(e,t){if("object"!=typeof e||null===e)return;const n=e[t];return Array.isArray(n)?n:void 0}function Kt(e,t){const n=Qt(t);void 0!==n&&e.set(n,t)}function Qt(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Xt(e,t){const n=/* @__PURE__ */new Map;for(let i=e.length-1;i>=0;i-=1){const r=e[i];if(void 0===r)continue;const o=r.getAttribute(t);if(null===o)continue;const s=n.get(o);void 0===s?n.set(o,[r]):s.push(r)}return n}function Zt(e,t){return e.get(t)?.pop()}function Yt(e,t,n,i){const r=sanitizeHtml(Nt(t,n,i,Mt),Ut(t)),o=e.createElement("template");o.innerHTML=et(r);const s=o.content.firstElementChild;if(!s)return null;const a=Qt(n);return void 0!==a&&s.setAttribute(jt,a),s}var en=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;if(void 0===t)return null;const n=t.plan(this.deps.root,e),i=new Set(n);return{boundaries:n,strategy:t,covers:e=>void 0!==e.fragmentBoundary&&i.has(e.fragmentBoundary)}}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:i,state:r}=this,o=new AbortController;r.fragmentController=o;const s=()=>r.isCurrent(e)&&!o.signal.aborted,{emitter:a}=i,{message:l}=e,u=e.identity.revision,d=e.receivedAt,c={root:i.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)=>{i.log("fragment",e,t)},morph:(e,t)=>{!function(e,t){const n=e.ownerDocument.createElement("template");n.innerHTML=et(t);const i=e.cloneNode(!1);i.append(n.content),rt(e,i,{keyAttributes:[jt]})}(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},s)},failed:(t,n,i,r,o)=>{e.pendingFragments-=1,a.emitWhile("error",{error:new Error(`fragment "${n}" fell back to patch: ${o}`),context:"fragment",code:r},s),a.emitWhile("fragmentRender",{element:t,id:n,key:i,status:"failed",code:r,revision:u,receivedAt:d},s)}};let h={rendered:0,failed:0,superseded:0};try{h=await n.strategy.render(c,n.boundaries)}catch(r){if(i.log("fragment","LP0801",r),s()){for(const 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,s()&&(r.fragmentController===o&&(r.fragmentController=null),e.pendingFragments=0,0===i.scheduler.pendingCount&&r.complete(e),this.host.revealPending(e),s()&&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"},s))}async refreshRoute(e,t,n){const{deps:i,state:r}=this,o=r.routeStats;if(e.routeRefreshed)return o.loopStopped+=1,void i.log("route","LP0805",`revision ${String(e.identity.revision)} asked for a second refresh`);e.routeRefreshed=!0;const s=new AbortController;r.routeController=s;const a=()=>r.isCurrent(e)&&!s.signal.aborted;let l;try{l=await n.refresh({revision:e.identity.revision,receivedAt:e.receivedAt,signal:s.signal,isCurrent:a,log:(e,t)=>{i.log("route",e,t)}})}catch(e){i.log("route","LP0801",e),l="failed"}if(a()){if(r.routeController===s&&(r.routeController=null),"refreshed"===l){if(o.refreshes+=1,r.lastAppliedIdentity=/* @__PURE__ */new WeakMap,this.host.rebuildCache(),!a())return;return this.host.reapply(e,t),void(i.emitter.listenerCount("afterUpdate")>0&&i.emitter.emitWhile("afterUpdate",{data:t,updatedCount:i.cache.elementCount,durationMs:Date.now()-e.receivedAt,revision:e.identity.revision,receivedAt:e.receivedAt,source:"route"},a))}"failed"===l&&(o.failed+=1),this.host.reapply(e,t)}}warnFragmentFallback(e){this.state.warnedFragmentFallback||(this.state.warnedFragmentFallback=!0,this.deps.warn(`[live-preview] LP0806: "${e.fieldName}" asks for the fragment strategy but no handler is configured; patching instead`))}warnUnsupportedStrategy(e){this.state.warnedStrategy.has(e.element)||(this.state.warnedStrategy.add(e.element),this.deps.warn(`[live-preview] LP0407: "${e.fieldName}" asks for strategy "${String(e.strategy)}"; only patch, fragment and route exist`))}patchFallback(e,t,n){for(const[i,r]of this.deps.cache.entries())for(const o of r){if(o.fragmentBoundary!==n)continue;const r=Be(t.fields,i,o.locale??e.locale,void 0!==o.locale);void 0!==r&&this.deps.scheduler.schedule({target:o,value:this.host.transform(o,r,t.fields,()=>!0),allFields:t.fields,identity:e.identity,data:t})}}},tn=class{constructor(e,t,n){this.deps=e,this.state=t,this.strategies=new en(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(e,t,n,i)=>this.transformForBinding(e,t,n,i),rebuildCache:n,revealPending:e=>{this.revealPending(e)}})}deps;state;strategies;handleUpdate(e,t,n){const{deps:i,state:r}=this;if(i.heartbeat.kick(),r.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),i.log),void 0===e.data)return void(void 0!==e.protocolVersion&&r.protocol.applyVersion(e.protocolVersion,i.log));if(void 0===n)return;const o=e.externallyUpdatedRelationship,s="object"==typeof o&&null!==o;s&&i.emitter.emit("relationshipUpdate",{detail:o,timestamp:Date.now()}),"string"==typeof e.locale&&(r.locale=e.locale),Array.isArray(e.fieldSchemaJSON)&&(r.schema=e.fieldSchemaJSON,r.schemaIndex=l(e.fieldSchemaJSON));const a={identity:n,message:e,locale:r.locale,schema:r.schema,schemaIndex:r.schemaIndex,receivedAt:Date.now(),forceRender:s,touched:/* @__PURE__ */new Set,invalidated:/* @__PURE__ */new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1},u=r.activeUpdate;if(r.abortStrategies(),null===u||u.completed||(r.supersededCount+=1),r.activeUpdate=a,i.scheduler.acceptRevision(n),r.updateCount+=1,void 0===e.protocolVersion||(r.protocol.applyVersion(e.protocolVersion,i.log),r.isCurrent(a))){if(i.connection.markConnected()){if(i.a11y?.announceConnected(),i.emitter.emit("connect",{origin:t,timestamp:Date.now()}),!r.isCurrent(a))return;if(i.log("connection","disconnected","→","connected"),!r.isCurrent(a))return}this.processUpdate(a).catch(e=>{i.log("update failed:",e)})}}async processUpdate(e){const{deps:t,state:n}=this,i=await this.resolveIncomingFields(e);if(null===i||!n.isCurrent(e))return;const{message:r}=e,o={fields:i,...void 0!==e.schema?{schema:e.schema}:{},..."string"==typeof r.globalSlug?{globalSlug:r.globalSlug}:{},..."string"==typeof r.collectionSlug?{collectionSlug:r.collectionSlug}:{},...void 0!==e.locale?{locale:e.locale}:{}};if(t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:o,revision:e.identity.revision,receivedAt:e.receivedAt,source:"patch",cancel:()=>{e.cancelled=!0,t.scheduler.cancelRevision(e.identity)}},()=>!e.cancelled&&n.isCurrent(e))||e.cancelled||!n.isCurrent(e)))return;const s=I(t.dependencies,t.cache.dependencyMap()),a=n.changes.diff(i,s);e.invalidated=a.invalidated,e.touched=/* @__PURE__ */new Set([...a.changed,...a.invalidated]),this.scheduleAllFields(e,o)}async resolveIncomingFields(e){const{deps:t,state:n}=this,i=e.message.data??{};if(null===t.merger)return i;if("admin"===detectProtocolProfile(n.protocol.observed).populatesRelationships)return i;const{message:r}=e,o=await t.merger.merge({collectionSlug:r.collectionSlug,globalSlug:r.globalSlug,data:i,locale:e.locale});return n.isCurrent(e)?"merged"===o.status?o.doc:"superseded"===o.status?null:i:null}scheduleAllFields(e,t){const{deps:n,state:i}=this;if(!i.isCurrent(e))return;const r=()=>i.isCurrent(e),o=this.ownerKeysForUpdate(e,t.fields),{touched:s}=e,a=n.strategies.route;if(void 0!==a&&!e.routeRefreshed&&(a.plan(n.root,s)||this.strategies.hasRouteBinding(s)))return void this.strategies.refreshRoute(e,t,a);const l=this.strategies.planFragments(s),u=n.skipUnchanged;let d=0;for(const[s,a]of n.cache.entries()){if(!r())return;for(const c of a){if(!1!==o&&!He(c.owner,o))continue;if(!0===l?.covers(c)){n.revealEditedField&&this.noteRevealCandidate(e,c,this.rawValue(e,c,t));continue}const a=c.strategyKind??B(c.element)??"unknown";if("unknown"===a){this.strategies.warnUnsupportedStrategy(c);continue}"fragment"===a&&null===l&&this.strategies.warnFragmentFallback(c);const h=Be(t.fields,s,c.locale??e.locale,void 0!==c.locale);if(void 0===h){i.absentFields.add(s);continue}if(this.noteRevealCandidate(e,c,h),!r())return;const f=this.transformForBinding(c,h,t.fields,r);if(!r())return;const p=u?nn(c,f,t.fields,e.locale):void 0,g=i.lastAppliedIdentity.get(c.element);if(!e.forceRender&&n.skipUnchanged&&void 0!==p&&g===p&&!e.invalidated.has(s)){i.skippedUnchangedCount+=1;continue}const m={target:c,value:f,allFields:t.fields,identity:e.identity,data:t,valueIdentity:p};n.scheduler.schedule(m),d+=1}}(function(e,t,n,i){const{cache:r,warned:o,warn:s}=e;if(0===r.fieldCount)return;if(!1!==i&&!function(e,t){for(const n of e.values())if(He(n.owner,t))return!0;return!1}(r,i))return;let a;for(const[e,l]of Object.entries(t)){if(o.has(e)||_e.has(e))continue;if(!Je(l))continue;const t=Ke(e,n);qe(r,e,i)||t!==e&&qe(r,t,i)||(a??=Ge(r,i),a.has(e)||(o.add(e),s(`[live-preview] LP0201: no <… data-payload-field="${t}"> for field "${e}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)))}})({cache:n.cache,warned:i.warnedOrphanFields,warn:n.warn},t.fields,e.locale,o),null!==l&&l.boundaries.length>0&&(e.pendingFragments=l.boundaries.length,this.strategies.runFragments(e,t,l)),0===d&&0===e.pendingFragments&&(i.complete(e),this.revealPending(e))}rawValue(e,t,n){return Be(n.fields,t.fieldName,t.locale??e.locale,void 0!==t.locale)}noteRevealCandidate(e,t,n){const{deps:i,state:r}=this;if(!i.revealEditedField)return;const o=T(n);if(void 0===o)return;const s=`${t.owner??""}\0${t.locale??""}\0${t.fieldName}`,a=r.seenFieldIdentity.get(s);void 0!==a?a!==o&&(e.revealIdentities.push([s,o]),e.revealTarget??=t):r.seenFieldIdentity.set(s,o)}ownerKeysForUpdate(e,t){const{deps:n,state:i}=this;if(!n.scopeBindingsByOwner)return!1;const{message:r}=e,o=function(e){if(De(e.globalSlug))return[(t=e.globalSlug,`global:${t}`)];var t;if(!De(e.collectionSlug))return null;const n=je(e.collectionSlug);return De(e.documentId)?[n,je(e.collectionSlug,e.documentId)]:[n]}({globalSlug:"string"==typeof r.globalSlug?r.globalSlug:void 0,collectionSlug:"string"==typeof r.collectionSlug?r.collectionSlug:void 0,documentId:ze(t)});return null!==o||i.warnedUnattributableMessage||(i.warnedUnattributableMessage=!0,n.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),o}transformForBinding(e,t,n,i){const r=this.deps.transformValue;if(void 0===r)return t;try{const o=r(e.fieldName,t,{element:e.element,allFields:n},i),s=me(o);if(!i())return t;if(s)throw new TypeError(`Transform for "${e.fieldName}" returned a thenable; transforms must be synchronous`);return o}catch(e){if(!i())return t;const n=e instanceof Error?e:new Error(String(e));return this.deps.emitter.emit("error",{error:n,context:"transform",code:"LP0602"}),t}}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{identity:i,data:r}=e;if(void 0===i)return;const o=n.activeUpdate;if(null===o||!n.isCurrent(o)||!L(o.identity,i))return;0===o.pendingFragments&&n.complete(o);const s=()=>n.isCurrent(o)&&L(o.identity,i);this.revealPending(o),s()&&0!==e.applied&&void 0!==r&&(t.a11y?.announceUpdate(e.applied),s()&&(function(e,t){for(const n of e)n.dispatchEvent(new CustomEvent(U,{detail:t,bubbles:!1}));e.length}(t.cache.islands,{fields:r.fields,revision:i.revision,receivedAt:o.receivedAt,locale:o.locale}),s()&&0!==t.emitter.listenerCount("afterUpdate")&&t.emitter.emitWhile("afterUpdate",{data:r,updatedCount:e.applied,durationMs:e.durationMs,revision:i.revision,receivedAt:o.receivedAt,source:"patch"},s)))}revealPending(e){for(const[t,n]of e.revealIdentities)this.state.seenFieldIdentity.set(t,n);e.revealIdentities=[];const t=e.revealTarget;if(void 0!==t){e.revealTarget=void 0;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 i=`${e.owner??""} ${e.fieldName}`;return this.state.revealer.reveal(i,t,n)}};function nn(e,t,n,i){const r=T(t);if(void 0===r)return;const o=[e.hrefField,e.srcField,e.altField];let s=r;for(const t of o){if(void 0===t||0===t.length)continue;const r=T(Be(n,t,e.locale??i,void 0!==e.locale));if(void 0===r)return;s+=`|${t}=${r}`}return s}var rn=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;activeIdentity=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.identity){if(this.activeRevisionCancelled)return;if(!on(e.identity,this.activeIdentity))return}const t=this.pending.get(e.target.element);t?(t.value=e.value,t.allFields=e.allFields,t.identity=e.identity,t.data=e.data,t.valueIdentity=e.valueIdentity):this.pending.set(e.target.element,{target:e.target,value:e.value,allFields:e.allFields,identity:e.identity,data:e.data,valueIdentity:e.valueIdentity}),this.armDebounce()}acceptRevision(e){var t,n;on(e,this.activeIdentity)||null!==this.activeIdentity&&(t=e,n=this.activeIdentity,(t.generation!==n.generation?t.generation-n.generation:t.revision-n.revision)<0)||(this.cancelScheduledWork(),this.clearWork(),this.activeIdentity=e,this.activeRevisionCancelled=!1)}cancelRevision(e){on(e,this.activeIdentity)&&(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(),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(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.activeIdentity=null,this.activeRevisionCancelled=!1}get pendingCount(){return this.pending.size}get replayCount(){return this.replay.size}get gateThreshold(){return this.gateThresholdValue}get gateActive(){return!this.gateDisabled&&this.getCacheSize()>this.gateThresholdValue}armDebounce(){const e=this.debounceToken+=1,t=this.debounceTimer;if(this.debounceTimer=null,null!==t&&clearTimeout(t),this.debounceToken!==e)return;const n=setTimeout(()=>{this.debounceToken===e&&(this.debounceTimer=null,this.requestFrame())},this.debounceMs);this.debounceToken===e&&(this.debounceTimer=n),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 i=this.scheduleFrame(()=>{this.frameToken===e&&(n=!0,this.frameHandle=null,this.flush())});n||this.frameToken!==e||(this.frameHandle=i)}flush(){const e=performance.now();this.clearDeadline();const t=this.gateActive,n=this.pending;this.pending=/* @__PURE__ */new Map;let i=0;const r=[];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)&&(i+=1,r.push(e.target.fieldName))):(this.replay.set(e.target.element,e),s+=1))}}finally{this.activeFlushes.delete(n)}const a=this.statsFor(o,i,s,performance.now()-e,r);return this.onFlush?.(a),a}isCurrent(e){return void 0===e.identity||!this.activeRevisionCancelled&&on(e.identity,this.activeIdentity)}didApply(e){return!1!==this.apply(e)||(t=this.apply,!k.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,i,r){return{applied:t,appliedFields:r,deferred:n,durationMs:i,...void 0!==e?.identity?{identity:e.identity}:{},...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)}};function on(e,t){return null!==t&&e.generation===t.generation&&e.revision===t.revision}var sn=[0,500,1e3,2e3],an=class{deps;state=new E;pipeline;writer;rootSentinel=null;observedRoot=null;constructor(e){const{emitter:t,renderers:n}=e,i=void 0===e.log?ye:ve(e.log),r=void 0===e.warn?we:ve(e.warn),o=e.root??("undefined"!=typeof document?document:null),s=new fe({filter:e=>!isInsideIsland(e)}),a=new Pe({onStructuralChange:()=>{this.rebuildCache()},onVisibilityChange:(e,t)=>{t&&l.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),l=new rn(A(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 Ee(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],i),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"})}i("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 Ue,heartbeat:new Oe({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:n,resolveRenderer:e.resolveRenderer??(e=>n[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,root:o,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:/* @__PURE__ */(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??cn,onHeartbeatTimeout:e.onHeartbeatTimeout,log:i,warn:r,a11y:ln(e),merger:void 0===d?null:new Te({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:i}),scopeBindingsByOwner:!0===e.scopeBindingsByOwner,lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField},this.writer=new P(this.deps,this.state),this.pipeline=new tn(this.deps,this.state,()=>{this.rebuildCache()})}start(){const{state:e,deps:t}=this;if(e.isRunning())return!1;if(e.started=!0,e.suspended=!1,un(t.root)&&"loading"===t.root.readyState){const n=()=>{if(e.isRunning()){e.deferredStart=null;try{this.startNow()}catch(e){this.rollbackFailedStart(),this.reportError(e,"startup","LP0605")}}};e.deferredStart=n;try{t.root.addEventListener("DOMContentLoaded",n,{once:!0})}catch(e){throw this.rollbackFailedStart(),e}return!0}try{return this.startNow(),!0}catch(e){throw this.rollbackFailedStart(),e}}startNow(){const{state:e,deps:t}=this;if(!e.isRunning())return;const n=un(t.root)?dn(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 sn){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&&un(t.root)&&this.runCleanup(()=>{t.root.removeEventListener("DOMContentLoaded",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()}),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;un(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()||!un(e))return!1;const t=dn(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:i,scheduler:r}=t,o=n.protocol.negotiation,s=n.activeUpdate,a=n.lastFlush,l=[],u=/* @__PURE__ */new Set;for(const[e,t]of i.entries()){l.push(e);for(const e of t)void 0!==e.owner&&u.add(e.owner)}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.identity.revision},bindings:{elements:i.elementCount,fields:i.fieldCount,fieldNames:l.sort(),absentFields:[...n.absentFields].sort(),orphanFields:[...n.warnedOrphanFields].sort(),ownerScoped:t.scopeBindingsByOwner,owners:[...u].sort()},route:{handler:void 0!==t.strategies.route,...n.routeStats},fragments:{handler:void 0!==t.strategies.fragment,inFlight:s?.pendingFragments??0,...n.fragmentStats},scheduler:{pending:r.pendingCount,deferred:r.replayCount,visibilityGateThreshold:r.gateThreshold,visibilityGateActive:r.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 i=n.get(e.element);i?.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.identity),t.merger?.destroy();const i=t.connection.markDisconnected();try{t.onHeartbeatTimeout?.()}catch(e){t.log("heartbeat:",e)}if(e.isRunning()){if(i&&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 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}};function ln(e){if(!1===e.enableA11y)return null;const t=e.root,n=void 0===t?void 0:un(t)?t:t.ownerDocument;return new r(e.a11yLocale,n)}function un(e){return 9===e.nodeType}function dn(e){return e.body}function cn(e){if("undefined"==typeof window)return;const t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),Ee.sendReady(t,e)}var EventEmitter=class{#t=/* @__PURE__ */new Map;#n=/* @__PURE__ */new Map;on(e,t){return this.#i(this.#t,e,t)}once(e,t){return this.#i(this.#n,e,t)}off(e,t){this.#r(this.#t,e,t),this.#r(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 i=()=>n?.()??!0;if(!i())return!1;const r=this.#t.get(e);if(r)for(const n of[...r]){if(!i())return!1;if(await this.#s(n,t,e),!i())return!1}if(!i())return!1;const o=this.#n.get(e);if(o&&o.size>0){const n=[...o];this.#n.delete(e);for(const r of n){if(!i())return!1;if(await this.#s(r,t,e),!i())return!1}}return i()}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]}#i(e,t,n){let i=e.get(t);return i||(i=/* @__PURE__ */new Set,e.set(t,i)),i.add(n),()=>{this.#r(e,t,n)}}#r(e,t,n){const i=e.get(t);void 0!==i&&(i.delete(n),0===i.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>";be(`[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 hn=/^https?:\/\/(localhost|127\.0\.0\.1)(?::\d+)?$/i,fn=/^https?:\/\/[^/?#\s]+$/i,pn=[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=gn(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 i=(e.enableLocalhostMatching??!0)&&(e.forceDevMode??isDevMode());this.#a=[t,n,i,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]||!hn.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 pn)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 gn(e){const t=e.trim();if(0!==t.length)try{const e=new URL(t);if("http:"!==e.protocol&&"https:"!==e.protocol)return;if(!fn.test(e.origin))return;return e.origin}catch{return}}var mn=()=>{},vn=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 i={kind:e,acquire:t,finalize:n,cleanup:void 0,disposed:!1},r=this.#c(i);if("active"===this.#a)try{this.#h(i)}catch(e){throw this.#f(i),e}return r}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.#h(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.#f(e);this.#d.clear()}}#c(e){return this.#d.add(e),()=>{this.#f(e)}}#h(e){if(e.disposed||void 0!==e.cleanup||void 0===e.acquire)return;const t=e.acquire();e.cleanup=t??mn}#f(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{me(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)}}},yn=class{#p;#g;#m=/* @__PURE__ */new Set;constructor(e,t){this.#p=e,this.#g=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.#m])t.event===e&&t.handler===n&&t.dispose()}emit(e,t){return this.#g.assertOpen(),this.#p.emit(e,t)}emitWhile(e,t,n){return this.#g.assertOpen(),this.#p.emitWhile(e,t,()=>{if(!this.#g.eligible())return!1;const e=n();return!!this.#g.eligible()&&e})}listenerCount(e){let t=0;for(const n of this.#m)n.event===e&&(t+=1);return t}removeAllListeners(e){for(const t of[...this.#m])void 0!==e&&t.event!==e||t.dispose()}eventNames(){const e=/* @__PURE__ */new Set;for(const t of this.#m)e.add(t.event);return[...e]}#v(e,t,n){this.#g.assertOpen();const i=n,r=[...this.#m].find(n=>n.kind===e&&n.event===t&&n.handler===i);if(void 0!==r)return r.dispose;let o=mn,s=!0;const a=async t=>{this.#g.active&&s&&("once"===e&&o(),await n(t))},l={kind:e,event:t,handler:i,dispose:mn};return o=this.#g.stage("subscription",()=>this.#p[e](t,a),()=>{s=!1,this.#m.delete(l)}),l.dispose=o,this.#m.add(l),o}},bn=class{#p;#y;#b;#w;#u;#S=/* @__PURE__ */new Map;#k=/* @__PURE__ */new Map;#A=/* @__PURE__ */new Map;#T=/* @__PURE__ */new Set;#C=/* @__PURE__ */new Map;#$=Promise.resolve();#R=0;constructor(e){this.#p=e.events,this.#y=e.config,this.#b=e.registerFieldRenderer,this.#u=ve(e.log);const t=e.onTransformError;this.#w=void 0===t?void 0:ve((...e)=>{const n=e[0];try{return t(n)}catch(e){return void this.#u("transform error reporter failed:",e)}})}register(e){return this.#R>0?this.#x(e,!1):this.#F(()=>this.#x(e,!0))}unregister(e){return this.#R>0?this.#N(e,!1):this.#F(async()=>{await this.#N(e,!0)})}destroyAll(){return this.#R>0?this.#M(!1):this.#F(async()=>{await this.#M(!0)})}applyTransforms(e,t,n,i){const r=this.#C.get(e);if(void 0===r||0===r.length)return t;let o=t;for(const s of[...r]){if(!s.active)continue;const{transform:r}=s;if(!1===i?.())return t;try{o=r(o,{fieldName:e,element:n.element,allFields:n.allFields});const s=me(o);if(!1===i?.())return t;if(s)throw new TypeError(`Transform for "${e}" returned a Promise/thenable; transforms must be synchronous`)}catch(n){if(!1===i?.())return t;const r=n instanceof Error?n:new Error(String(n));return this.#u(`transform for "${e}" failed:`,r),this.#w?.(r),t}}return o}list(){return[...this.#S.keys()]}snapshot(){const e=[],t=(e,t,n,i)=>{const r=i.counts();return{name:e,version:t,state:n,registrations:{transforms:r.transform,renderers:r.renderer,subscriptions:r.subscription,cleanups:r.cleanup}}};for(const[n,i]of this.#k)e.push(t(n,void 0,"initializing",i.scope));for(const[n,i]of this.#S)e.push(t(n,i.plugin.version,"active",i.scope));for(const t of this.#A.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#x(t,n){if(this.#S.has(t.name)||this.#k.has(t.name)||this.#A.has(t.name))return void this.#u(`plugin "${t.name}" already registered`);const i=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 i=e.trim().split(/\s+/).filter(e=>e.length>0);return 0===i.length?""===e.trim()&&""===t.trim():i.every(e=>function(e,t){const n=t.trim();if(""===n||"*"===n)return!0;const i=/^(\^|~|>=|<=|>|<|=)?\s*v?(\d+)\.(\d+)\.(\d+)/.exec(n);if(null===i)return!1;const r=i[1]??"=",o=[Number(i[2]),Number(i[3]),Number(i[4])],s=function(e,t){for(let n=0;n<3;n+=1){const i=(e[n]??0)-(t[n]??0);if(0!==i)return i}return 0}(e,o);switch(r){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!==i)return void this.#L(t.name,i);const r=new vn(t.name,this.#u),o=this.#E(t.name,r),s={scope:r,cancelled:!1};this.#k.set(t.name,s);try{if(await this.#P(()=>t.init(o),n),s.cancelled)return;r.commit()}catch(e){return r.close(),void(s.cancelled||this.#u(`plugin "${t.name}" init failed:`,e))}finally{this.#k.get(t.name)===s&&this.#k.delete(t.name)}this.#S.set(t.name,{plugin:t,scope:r}),this.#u(`plugin "${t.name}" registered`)}#L(e,t){const n=`plugin "${e}" refused: ${t}`;this.#u(n),this.#p.emit("error",{error:new Error(n),context:"plugin",code:"LP0103"})}#E(e,t){return{events:new yn(this.#p,t),registerFieldRenderer:e=>{t.stage("renderer",()=>{const t=this.#b(e);return"function"==typeof t?t:void 0})},registerTransform:(e,n)=>{const i={transform:n,active:!1};t.stage("transform",()=>{i.active=!0;const t=this.#C.get(e);return void 0===t?this.#C.set(e,[i]):t.push(i),()=>{i.active=!1;const t=this.#C.get(e);if(void 0===t)return;const n=t.indexOf(i);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)}}}#N(e,t){const n=this.#k.get(e);if(void 0!==n)return n.cancelled=!0,n.scope.close(),Promise.resolve();const i=this.#A.get(e);if(void 0!==i)return this.#T.has(e)?Promise.resolve():t?this.#I(i):i;const r=this.#S.get(e);if(void 0===r)return Promise.resolve();this.#S.delete(e),r.scope.close();const o=Promise.resolve().then(()=>this.#O(e,r.plugin,t));return this.#A.set(e,o),o.then(()=>{this.#A.get(e)===o&&this.#A.delete(e)}),o}async#O(e,t,n){if(void 0!==t.destroy){this.#T.add(e);try{await this.#P(()=>t.destroy?.(),n)}catch(t){this.#u(`plugin "${e}" destroy failed:`,t)}finally{this.#T.delete(e)}}}async#M(e){for(const e of this.#k.values())e.cancelled=!0,e.scope.close();const t=[...this.#S.keys()];for(const n of t)await this.#N(n,e)}async#P(e,t){t?await this.#I(Promise.resolve().then(e)):await e()}async#I(e){this.#R+=1;try{await e}finally{this.#R-=1}}#F(e){const t=this.#$.then(e);return this.#$=t.catch(e=>{this.#u("plugin manager mutation failed:",e)}),t}},wn=class{#U;#j;#D=/* @__PURE__ */new Map;constructor(e){this.#U=e,this.#j={...e}}get renderers(){return this.#j}resolve(e){return this.#j[e]}register(e){const t=e.name,n={renderer:e},i=this.#D.get(t);void 0===i?this.#D.set(t,[n]):i.push(n),this.#j[t]=e;let r=!0;return()=>{if(!r)return;r=!1;const e=this.#D.get(t);if(void 0===e)return;const i=e.indexOf(n);if(i<0)return;const o=i===e.length-1;if(e.splice(i,1),0===e.length&&this.#D.delete(t),!o)return;const s=e.at(-1),a=s?.renderer??this.#U[t];void 0===a?Reflect.deleteProperty(this.#j,t):this.#j[t]=a}}},Sn={1:"left",2:"center",3:"right",4:"justify"},kn=/* @__PURE__ */new Set(["left","center","right","justify","start","end"]);function An(e){const t=e.format;return"string"==typeof t&&kn.has(t)?t:"number"==typeof t?Sn[t]:void 0}function Tn(e){const t=e.indent;return"number"==typeof t&&t>0?t:0}function Cn(e){return"rtl"===e.direction?' dir="rtl"':"ltr"===e.direction?' dir="ltr"':""}function $n(e){const t=An(e),n=Tn(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(" ")}"`}var Rn=/* @__PURE__ */new Set(["h1","h2","h3","h4","h5","h6"]);function xn(e){return"object"==typeof e&&null!==e?e:void 0}function Fn(e){return xn(e)}function Nn(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function Mn(e){return"string"==typeof e&&e.length>0?e:void 0}function Ln(e){const t=Mn(e.title)??Mn(e.name)??Mn(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}var En=' target="_blank" rel="noopener noreferrer"',Pn=(e,t)=>{const n=t.renderChildren(e.children??[]),i=xn(e.fields),r=function(e,t){if("internal"===t?.linkType)return function(e){const t=xn(xn(e)?.value),n=t?.url;if("string"==typeof n&&n.length>0)return n;const i=t?.slug;return"string"==typeof i&&i.length>0?`/${i}`:void 0}(t.doc);const n=t?.url??e.url;return"string"==typeof n&&n.length>0?n:void 0}(e,i);if(void 0===r||!isSafeUrl(r))return n;const o="string"==typeof e.title?` title="${escapeHtml(e.title)}"`:"";return`<a href="${escapeHtmlAttribute(r)}"${function(e,t,n){if(!0===t?.newTab||isExternalHttpUrl(n))return En;const i="string"==typeof e.target?e.target:"";return""===i?"":"_blank"===i?En:` target="${escapeHtml(i)}"`}(e,i,r)}${o}>${n}</a>`};function In(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(const n of e.children)t+=In(n);return t}function On(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function Un(e){return"string"==typeof e.mimeType?` type="${escapeHtmlAttribute(e.mimeType)}"`:""}var jn=/* @__PURE__ */new Map;function Dn(e,t){jn.set(e,t)}function Hn(e){return jn.get(e)}function zn(e,t,n,i){const r=xn(e.fields)??{},o="string"==typeof r.blockType?r.blockType:"",s=Nn(o);if(""!==o){const e=Hn(o)??Hn(s);if(e)return e(r,{renderChildren:t.renderChildren})}return`<${n} class="${""===s?i:`${i} ${i}--${s}`}"></${n}>`}function Wn(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}var Bn={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${Cn(e)}${$n(e)}>${n}</p>`},heading:(e,t)=>{const n="string"==typeof e.tag?e.tag.toLowerCase():"h2",i=Rn.has(n)?n:"h2",r=t.renderChildren(e.children??[]);return`<${i}${Cn(e)}${$n(e)}>${r}</${i}>`},list:(e,t)=>{const 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)}"`:"",o="check"===n?' role="list"':"",s=t.renderChildren(e.children??[]);return`<${i}${Cn(e)}${$n(e)}${r}${o}>${s}</${i}>`},listitem:(e,t)=>{const n=t.renderChildren(e.children??[]);if("boolean"==typeof e.checked)return`<li role="checkbox" aria-checked="${e.checked?"true":"false"}"${$n(e)}>${n}</li>`;const i="number"==typeof e.value?` value="${escapeHtml(String(e.value))}"`:"";return`<li${Cn(e)}${$n(e)}${i}>${n}</li>`},link:Pn,autolink:Pn,quote:(e,t)=>{const n=t.renderChildren(e.children??[]);return`<blockquote${Cn(e)}${$n(e)}>${n}</blockquote>`},code:e=>{const t=Nn("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${escapeHtml(In(e))}</code></pre>`},"code-highlight":e=>{const t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${Nn(e.highlightType)}"`:""}>${escapeHtml(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\t",upload:e=>{const t=Fn(e.value);if(void 0===t)return"";const n=t.url;if("string"!=typeof n||!isSafeUrl(n))return"";const i="string"==typeof t.mimeType?t.mimeType:"";return i.startsWith("video/")?function(e,t){return`<video controls${On(e)}><source src="${escapeHtmlAttribute(t)}"${Un(e)}></video>`}(t,n):i.startsWith("audio/")?function(e,t){return`<audio controls><source src="${escapeHtmlAttribute(t)}"${Un(e)}></audio>`}(t,n):""===i||i.startsWith("image/")?function(e,t){const n="string"==typeof e.alt?escapeHtml(e.alt):"";return`<img src="${escapeHtmlAttribute(t)}" alt="${n}"${On(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=xn(e.value),i=escapeHtml((n&&Ln(n))??`#${t}`),r=Nn(t),o=""===r?' class="lp-relation"':` class="lp-relation lp-relation--${r}"`,s=n?.url;return"string"==typeof s&&isSafeUrl(s)?`<a href="${escapeHtmlAttribute(s)}"${o}>${i}</a>`:`<span${o}>${i}</span>`},block:(e,t)=>zn(e,t,"div","lp-block"),inlineBlock:(e,t)=>zn(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${Cn(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,i=3&n?"th":"td";return`<${i}${1===n?' scope="col"':2===n?' scope="row"':""}${Wn("colspan",e.colSpan)}${Wn("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${i}>`}},Vn=/* @__PURE__ */new Map,_n={renderChildren:Qn,resolveAlignment:An,resolveIndent:Tn},qn=!1;function Gn(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 Jn(e,t={}){if(!Gn(e))return"";const n=Qn(e.root.children);return!1===t.sanitize?n:void 0!==St()?sanitizeHtml(n):(function(){if(!qn){qn=!0;try{console.warn("[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; call setSanitizerDocument() (linkedom/jsdom) for server rendering, see docs/security.md §3.")}catch{}}}(),n)}function Kn(e){return Gn(e)?e.root.children.map(Zn).join("\n").trim():""}function Qn(e){let t="";for(const n of e)t+=Xn(n);return t}function Xn(e){const t=(n=e.type,Vn.get(n)??Bn[n]);var n;return t?t(e,_n):void 0!==e.children?Qn(e.children):""}function Zn(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+=Zn(n);return t}function Yn(e="text"){const t=/* @__PURE__ */new WeakSet;return{name:e,render:/* @__PURE__ */A((e,n)=>{const i=e.element,r=function(e){return null==e?"":Gn(e)?Kn(e):"string"==typeof e?e:"number"==typeof e||"boolean"==typeof e?String(e):JSON.stringify(e)}(n);if("INPUT"!==i.tagName&&"TEXTAREA"!==i.tagName)return function(e){return null!==e.querySelector(":scope > :not(br)")}(i)&&!i.hasAttribute("data-payload-text")?(function(e,t,n){e.has(t)||(e.add(t),we(`[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):void(r.includes("\n")||r.includes("\r")?i.innerHTML=et(function(e){return escapeHtml(e).replace(/\r\n|\r|\n/g,"<br>")}(r)):i.textContent=r);i.value=r})}}var ei={name:"richText",render:/* @__PURE__ */A((e,t,n)=>{const i=e.element;if(Lt(t))i.textContent="";else{if(void 0!==n.renderRichText){const r=n.renderRichText(t,{fieldName:e.fieldName,element:i,locale:n.locale});return void(i.innerHTML=et(sanitizeHtml(r)))}if(Gn(t))i.innerHTML=et(Jn(t));else{if("string"!=typeof t)return!1;i.innerHTML=et(sanitizeHtml(t))}}})},ti={name:"html",render(e,t){if(Lt(t))return void(e.element.textContent="");const n="string"==typeof t?t:Mt(t);e.element.innerHTML=et(sanitizeHtml(n))}},ni=/* @__PURE__ */new WeakSet;function ii(e,t,n){return"string"!=typeof n||0===n.length?{kind:"none"}:isSafeUrl(n)?{kind:"safe",url:n}:(ni.has(e)||(ni.add(e),we(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function ri(e,t=e=>e){return{name:e,render(e,n,i){const r=e.element;if(Lt(n))return void function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(r);const o=Mt(n);if("INPUT"!==r.tagName&&"TEXTAREA"!==r.tagName){if("A"===r.tagName){const n=e.hrefField,s=void 0===n||0===n.length?t(o):Be(i.allFields,n,i.locale,void 0!==e.locale),a=ii(r,e.fieldName,s);"safe"===a.kind?r.setAttribute("href",a.url):"unsafe"===a.kind&&r.removeAttribute("href")}r.textContent=o}else r.value=o}}}var oi=ri("url"),si=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,ai=ri("email",function(e){const t=e.trim();return si.test(t)||!t.includes("@")?t:`mailto:${t}`}),li=["src","srcset","sizes"];function ui(e){for(const t of li)e.removeAttribute(t)}function di(e,t,n){e.src=t;const i=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(`${ci(n.url)} ${String(n.width)}w`);return 0!==t.length?("number"==typeof e.width&&"string"==typeof e.url&&isSafeUrl(e.url)&&t.push(`${ci(e.url)} ${String(e.width)}w`),t.join(", ")):void 0}(n);if(void 0===i)return e.removeAttribute("srcset"),void e.removeAttribute("sizes");e.setAttribute("srcset",i)}function ci(e){return e.replace(/[\s,]/g,encodeURIComponent)}var hi={name:"image",render:/* @__PURE__ */A((e,t,n)=>{const i=e.element;if(Lt(t))return void fi(i);const r=void 0!==e.locale,{media:o,candidate:s}=function(e,t,n,i){const r=void 0!==e.srcField&&e.srcField.length>0?Be(n.allFields,e.srcField,n.locale,i):t,o=Fn(r);return{media:o,candidate:void 0===o?r:o.url}}(e,t,n,r),a=ii(i,e.fieldName,s);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===i.tagName){const t=i;di(t,a.url,o);const s=function(e,t,n,i,r){if(void 0!==t&&t.length>0){const e=Be(n,t,i,r);return"string"==typeof e?e:void 0}return e?.alt}(o,e.altField,n.allFields,n.locale,r);return void(void 0!==s&&(t.alt=s))}i.style.backgroundImage=`url('${function(e){return e.replace(/['"()\\]/g,"\\$&")}(a.url)}')`}else fi(i)})};function fi(e){"IMG"===e.tagName?ui(e):e.style.backgroundImage=""}var pi={name:"upload",render:/* @__PURE__ */A((e,t)=>{const n=e.element;if(Lt(t))return void gi(n);const i=Fn(t);if(void 0===i)return!1;const r=ii(n,e.fieldName,i.url);if("none"===r.kind)return!1;if("unsafe"===r.kind)return void gi(n);const o=r.url;if("IMG"===n.tagName){const e=n;return di(e,o,i),void(void 0!==i.alt&&(e.alt=i.alt))}if("A"===n.tagName)return n.setAttribute("href",o),void(n.textContent=i.filename??o);const s=escapeHtml(i.filename??o);n.innerHTML=et(`<a href="${escapeHtmlAttribute(o)}">${s}</a>`)})};function gi(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):ui(e)}var mi={name:"relationship",render(e,t){const n=e.element;if(Lt(t))return n.removeAttribute("href"),void(n.textContent="");if("A"===n.tagName&&!Array.isArray(t)){const i=ii(n,e.fieldName,xn(t)?.url);"safe"===i.kind?n.setAttribute("href",i.url):"unsafe"===i.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(vi).join(", "):vi(t)}};function vi(e){const t=xn(e);return void 0===t?Mt(e):Ln(t)??""}var yi={name:"select",render(e,t,n){const i=e.element,r=Lt(t)?[]:function(e){return Array.isArray(e)?e.map(Mt):[Mt(e)]}(t);if("SELECT"!==i.tagName){if("INPUT"===i.tagName&&"radio"===i.type){const e=i;return void(e.checked=r.includes(e.value))}i.textContent=r.map(e=>function(e,t){const n=t.schema?.options;if(!Array.isArray(n))return e;for(const t of n){const n=xn(t);if(void 0!==n&&Mt(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]??""}(i,r)}},bi=/* @__PURE__ */new Set(["","false","0","off","no"]),wi={name:"checkbox",render(e,t){const n=e.element,i=function(e){return"boolean"==typeof e?e:"string"==typeof e?!bi.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}},Si=/* @__PURE__ */new Map,ki=/* @__PURE__ */new Map;function Ai(e,t){const n=e??"";if(null==t)return n;const i=Ti(t);return"{}"===i?n:`${n}|${i}`}function Ti(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>Ti(e)).join(",")}]`;const t=e,n=Object.keys(t).sort(),i=[];for(const e of n){const n=t[e];void 0!==n&&i.push(`${JSON.stringify(e)}:${Ti(n)}`)}return`{${i.join(",")}}`}function Ci(e){for(;e.size>64;){const t=e.keys().next().value;if(void 0===t)break;e.delete(t)}}var $i={name:"date",render(e,t,n){const i=e.element;if(Lt(t))return void("INPUT"===i.tagName?i.value="":(i.removeAttribute("datetime"),i.textContent=""));const r="number"==typeof t?t:Mt(t),o=new Date(r),s=!Number.isNaN(o.getTime()),a=String(r);"INPUT"!==i.tagName?("TIME"===i.tagName&&i.setAttribute("datetime",s?o.toISOString():a),i.textContent=s?function(e,t){const n=t.locale??detectInitialLocale();try{return function(e,t){const n=Ai(e,t),i=ki.get(n);if(void 0!==i)return ki.delete(n),ki.set(n,i),i;const r=new Intl.DateTimeFormat(e,t);return ki.set(n,r),Ci(ki),r}(n,{dateStyle:"medium",timeStyle:"short"}).format(e)}catch{return e.toISOString()}}(o,n):a):i.value=s?function(e,t){const n=`${String(t.getFullYear()).padStart(4,"0")}-${Ri(t.getMonth()+1)}-${Ri(t.getDate())}`,i=`${Ri(t.getHours())}:${Ri(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${i}`:"time"===e?i:t.toISOString()}(i.type,o):a}};function Ri(e){return String(e).padStart(2,"0")}var xi={name:"number",render(e,t,n){const i=e.element;if(Lt(t))return void("INPUT"===i.tagName?i.value="":i.textContent="");const r="number"==typeof t?t:Number(Mt(t));Number.isNaN(r)?i.textContent=Mt(t):"INPUT"!==i.tagName?i.textContent=function(e,t){const n=t.locale??detectInitialLocale();try{return function(e,t){const n=Ai(e,t),i=Si.get(n);if(void 0!==i)return Si.delete(n),Si.set(n,i),i;const r=new Intl.NumberFormat(e,t);return Si.set(n,r),Ci(Si),r}(n).format(e)}catch{return String(e)}}(r,n):i.value=String(r)}},Fi={name:"array",render:/* @__PURE__ */A((e,t)=>{const n=e.element;if(Lt(t))return void(n.textContent="");if(!Array.isArray(t))return!1;const i=e.arrayTemplate;if(void 0!==i&&i.length>0){const e=function(e,t){let n="";for(let i=0;i<t.length;i+=1)n+=Nt(e,t[i],i,Mt);return n}(i,t);return void(n.innerHTML=et(sanitizeHtml(e,Ut(i))))}n.textContent=t.map(Mt).join(e.arraySeparator??", ")})};function Ni(){const e=/* @__PURE__ */new WeakMap,t=/* @__PURE__ */new WeakSet,n=/* @__PURE__ */new WeakMap,i=/* @__PURE__ */new WeakMap;return{name:"structural-array",render:/* @__PURE__ */A((r,o)=>{const s=Lt(o)?[]:o;if(!Array.isArray(s))return!1;const a=r.element,l=r.arrayTemplate;if(void 0===l||0===l.length)return function(e,t,n){e.has(t)||(e.add(t),we(`[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,a,r.fieldName),!1;const u=e.get(a),d=Mi(a),c=h(u?.values??d.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e}),s),f=function(e,t,n){return void 0===e||e.template!==t||!function(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}(e.domSnapshot,n)}(u,l,d);if(0===c.length&&!f)return e.set(a,{values:s.slice(),template:l,domSnapshot:d}),!1;!function(e,t,n,i,r){const o=r.map(Li),s=/* @__PURE__ */new Set,a=o.find(e=>!(void 0===e||!s.has(e)&&(s.add(e),1)));if(void 0!==a&&Ei(e,t,n,a),o.some(e=>void 0===e)&&Pi(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){const r=new Set(i.map(Li).filter(e=>void 0!==e)),s=o.some(e=>void 0!==e&&r.has(e));r.size>0&&!s&&Pi(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,a,r.fieldName,u?.values,s);const p=zt({template:l,container:a,patches:c,nextItems:s,store:i,forceRender:f,onDuplicateKey:(e,t)=>{Ei(n,e,r.fieldName,t)}});return null!==p&&(e.set(a,{values:s.slice(),template:l,domSnapshot:Mi(a)}),!!p&&void 0)})}}function Mi(e){return Array.from(e.children,e=>e.getAttribute(jt))}function Li(e){if("object"!=typeof e||null===e)return;const t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function Ei(e,t,n,i){Pi(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${i}"; later ones pair by position. Make \`id\` unique per item.`)}function Pi(e,t,n,i){let r=e.get(t);void 0===r&&(r=/* @__PURE__ */new Set,e.set(t,r)),r.has(n)||(r.add(n),we(`[live-preview] ${i}`))}var Ii=/* @__PURE__ */new Map;function Oi(e){Ii.set(e.name,e)}function Ui(){const e=[ei,ti,oi,ai,hi,pi,mi,yi,{...yi,name:"radio"},wi,$i,xi,Fi,{...Fi,name:"blocks"}];return function(e=[]){const t={};for(const n of e)t[n.name]=n;for(const[e,n]of Ii)t[e]=n;return Object.freeze(t)}([Yn("text"),Yn("textarea"),...e,Ni()])}function ji(e){const t={};for(const[n,i]of Object.entries(e))void 0!==i&&(t[n]=i);return t}var Di=Object.freeze({disableReferrerDetection:!0,eventSourcePolicy:"parent-or-opener",skipUnchanged:!0,sanitizerPolicy:"strict"}),Hi=Object.freeze({disableReferrerDetection:!1,eventSourcePolicy:"any",skipUnchanged:!1,sanitizerPolicy:"compat"});function zi(e){return void 0===e?void 0:!e}var LivePreviewClient=class{#H=new EventEmitter;#z;#W;#B;#S;#u;#V=!1;#_=!1;#q=!1;#G=null;constructor(e={}){const t=function(e){if("v1"===e.defaults)return e;const t="v1"===e.defaults?Hi:Di;return{...e,skipUnchanged:e.skipUnchanged??t.skipUnchanged,disableReferrerDetection:e.disableReferrerDetection??t.disableReferrerDetection,eventSourcePolicy:e.eventSourcePolicy??t.eventSourcePolicy,sanitizerPolicy:e.sanitizerPolicy??t.sanitizerPolicy}}(e),n=t.serverURL??"";if("v1"!==e.defaults&&""!==n&&void 0===t.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).");void 0!==t.sanitizerPolicy&&wt(t.sanitizerPolicy);const i=t.debug??isDevMode();this.#u=i?(...e)=>{Se("[live-preview]",...e)}:ye,this.#z=new OriginDetector(ji({additionalOrigins:t.allowedOrigins,enableReferrerDetection:zi(t.disableReferrerDetection),enableLocalhostMatching:zi(t.disableLocalhostMatching)})),this.#z.isProductionUnconfigured&&this.#u("no trusted origin could be detected — set allowedOrigins"),this.#W=new wn(Ui()),this.#S=new bn({events:this.#H,config:Object.freeze({...t}),registerFieldRenderer:e=>this.#W.register(e),onTransformError:e=>{this.#H.emit("error",{error:e,context:"transform",code:"LP0602"})},log:this.#u}),this.#B=new an(ji({root:t.root,renderers:this.#W.renderers,resolveRenderer:(e,n)=>t.resolveRenderer?.(e,n)??this.#W.resolve(e),renderRichText:t.renderRichText,transformValue:(e,t,n,i)=>this.#S.applyTransforms(e,t,n,i),originMatcher:e=>this.#z.matches(e),readyTargets:()=>this.#z.enumerate(),emitter:this.#H,dataMerge:""===n?void 0:ji({serverURL:n,apiRoute:t.apiRoute,depth:t.mergeDepth,fetchFn:t.mergeFetch}),debounceMs:t.debounceMs,heartbeatMs:t.heartbeatMs,intersectionRootMargin:t.intersectionRootMargin,scopeBindingsByOwner:t.scopeBindingsByOwner,skipUnchanged:t.skipUnchanged,revealEditedField:t.revealEditedField,eventSourcePolicy:t.eventSourcePolicy,dependencies:t.dependencies,strategies:t.strategies,disableVisibilityGate:t.disableVisibilityGate,visibilityGateThreshold:t.visibilityGateThreshold,enableA11y:t.enableA11y,a11yLocale:t.a11yLocale,onHeartbeatTimeout:()=>{this.#z.unlockOrigin()},lockedOrigin:()=>this.#z.lockedOrigin,validateToken:t.validateToken,log:this.#u})),this.#H.on("connect",e=>{this.#z.lockOrigin(e.origin)}),!1!==t.autoStart&&this.start()}start(){if(this.#_)return!1;if(this.#V)return this.#B.start(),!0;if(!isInPreviewContext())return!1;const e=this.#B.start();return e&&(this.#V=!0),e}suspend(){return!(this.#_||!this.#V)&&this.#B.suspend()}resume(){return!(this.#_||!this.#V)&&this.#B.start()}destroy(){if(null!==this.#G)return this.#G;let e,t;this.#_=!0;const n=new Promise((n,i)=>{e=n,t=i});this.#G=n;const i=()=>{this.#H.removeAllListeners(),this.#q=!0};try{this.#B.destroy(),this.#S.destroyAll().finally(i).then(e,t)}catch(e){i(),t(e)}return n}async use(e){if(this.#_)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.#B.refreshCache()}get events(){return this.#H}get plugins(){return this.#S.list()}get status(){return this.#B.status}inspect(){return{...this.#B.inspect(),plugins:this.#S.snapshot()}}get updateCount(){return this.#B.updateCount}get destroyed(){return this.#_}};function initLivePreview(e={}){const t=new LivePreviewClient({...e,autoStart:!1});return t.start()?t:null}function Wi(e,t,n){if(0===t.length)return;const i={type:"payload-live-preview-focus",field:t};e.postMessage(i,n)}function Bi(e,t){return n=>{const i=e();null!=i&&Wi(i,n,t)}}function Vi(e,t={}){const n=t.windowTarget??globalThis.window,i=t.documentTarget??globalThis.document,r=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 r)i?.addEventListener(e,a);let l=!1;return()=>{if(!l){l=!0,n?.removeEventListener("pagehide",o),n?.removeEventListener("pageshow",s);for(const e of r)i?.removeEventListener(e,a)}}}var _i=Object.freeze({NoTrustedOrigin:"LP0101",ReferrerOnlyTrust:"LP0102",PluginIncompatible:"LP0103",OrphanField:"LP0201",UnattributableUpdate:"LP0202",VisibilityGateDeferred:"LP0301",UnsafeAttributeWrite:"LP0401",TextTargetHasChildren:"LP0402",MissingArrayTemplate:"LP0403",StructuralItemUnkeyed:"LP0404",StructuralDuplicateKey:"LP0405",StructuralUnstableKeys:"LP0406",UnsupportedStrategy:"LP0407",MessageRejected:"LP0501",TokenRejected:"LP0502",HandlerThrew:"LP0601",TransformThrew:"LP0602",RendererThrew:"LP0603",StartupFailed:"LP0605",ReadyFailed:"LP0606",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",V2ReadinessGap:"LP0709",RuntimeOnPublicPage:"LP0710"}),qi='(()=>{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(){return function(){if(typeof 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 r(e){null!==e.timer&&(clearTimeout(e.timer),e.timer=null),e.messageNode?.remove(),e.messageNode=null}function l(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=o(n);e&&t.push(e)}return t}function o(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=l(t.fields),o=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=l(e.fields);t.push({...e,slug:i,fields:r})}return t}(t.blocks),a={...t,name:n,type:i};return r.length>0?a.fields=r:delete a.fields,o.length>0?a.blocks=o:delete a.blocks,a}function a(e,t=""){let n=new Map;return s(e,t,n),n}function s(e,t,n){for(let i of e){if(Dt.has(i.type)){i.fields&&s(i.fields,t,n);continue}let e=""===t?i.name:`${t}.${i.name}`;if(n.set(e,i),"group"===i.type)i.fields&&s(i.fields,e,n);else if("array"===i.type&&i.fields)s(i.fields,`${e}.*`,n);else if("blocks"===i.type&&i.blocks)for(let t of i.blocks)s(t.fields,`${e}.*.${t.slug}`,n)}}function u(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?t:void 0}function d(e){if("object"!=typeof e||null===e)return;let t=e.blockType;return"string"==typeof t?t:void 0}function c(e,t){return t.every(e=>void 0!==u(e))?function(e,t){let n=[],i=new Map;for(let t=0;t<e.length;t+=1){let n=u(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=u(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 c=e[s];d(c)===d(o)?(s!==l&&n.push({kind:"move",from:s,to:l,value:o}),h(c,o)||n.push({kind:"update",index:l,value:o})):n.push({kind:"replace",index:l,oldValue:c,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)h(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 h(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 f(e){if("string"!=typeof e||0===e.length)return!1;let t=e.trim().replace(Gt,"");if(0===t.length||_t.test(t))return!1;if(t.startsWith("#")||t.startsWith("?")||zt.test(t)||t.startsWith("/"))return!0;try{let e=new URL(t);return Bt.has(e.protocol)}catch{return Ht.test(t)}}function p(e){if(!f(e))return!1;let t=e.trim().replace(Gt,"");return/^https?:\\/\\//i.test(t)||zt.test(t)}function g(e){return Kt.add(e),e}function m(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 v(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 Zt)(i>=Xt[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 y(e){try{return!0===e.matchMedia?.("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function b(e,t){return e.generation===t.generation&&e.revision===t.revision}function w(...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 S(e,t){let n={};for(let i of t)i!==e&&(n[i]=[e]);return n}function k(e){return"astro-island"===e.tagName.toLowerCase()||e.hasAttribute(ln)}function T(e){return"patch"===e.getAttribute(ln)}function A(e){return e.closest(`[${an}]`)}function C(e){let t=e.getAttribute(sn);return null!==t&&t.length>0?"patch"===t||"fragment"===t||"route"===t?t:void 0:null!==A(e)?"fragment":null!==e.closest("head")?"route":"patch"}function $(e){return Mn.has(e)||Nn.test(e)}function F(e){let t=e.getAttribute(dn);if(null!==t&&$(t))return t;if(e.hasAttribute(yn))return"richText";if(e.hasAttribute(bn))return"html";if(e.hasAttribute(Sn))return"structural-array";if(e.hasAttribute(wn))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 R(){return!0}function N(e){for(let t of e){let e=t.codePointAt(0);if(void 0!==e&&(e<=31||127===e))return!0}return!1}function M(e){if(void 0===e||0===e.length||e.length>128||"."===e||".."===e||e.includes("/")||e.includes("\\\\")||e.includes("?")||e.includes("#")||N(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}function x(e){return e.aborted}function E(e){return e.has("schema-json")?Ln:e.has("document-events")||e.has("relationship-events")?On:Un}function I(e,t){return void 0===e||t(e)}function L(e,t){return null==e||t(e)}function O(e){if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return null===t||null===Object.getPrototypeOf(t)}function U(e){if(e.nodeType!==Wn)return!1;let t=e;return t.hasAttribute(un)||null!==t.querySelector(`[${un}]`)}function P(e){return`global:${e}`}function j(e,t){return void 0===t||""===t?`collection:${e}`:`collection:${e}:${t}`}function W(e){return"string"==typeof e&&e.length>0}function D(e,t){return null!==t&&void 0!==e&&t.includes(e)}function V(e){let t=e.id;return"string"==typeof t&&t.length>0?t:"number"==typeof t&&Number.isFinite(t)?String(t):void 0}function B(e,t,n,i=!1){if(i&&void 0!==n){let i=_(e,`${t}_${n}`);if(void 0!==i)return i}let r=_(e,t);if(void 0!==r)return r;if(t.includes(".")){let n=e,i=!0;for(let e of t.split(".")){if(_n.has(e)||null===n||"object"!=typeof n){i=!1;break}if(n=_(n,e),void 0===n){i=!1;break}}if(i)return n}return void 0===n?void 0:_(e,`${t}_${n}`)}function _(e,t){if(!_n.has(t)&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function H(e,t,n){let i=e.get(t);return void 0!==i&&(!1===n||i.some(e=>D(e.owner,n)))}function z(e,t){let n=new Set;for(let[i,r]of e.entries())for(let e of r)!1!==t&&!D(e.owner,t)||void 0!==e.locale&&n.add(`${i}_${e.locale}`);return n}function G(e){let t=typeof e;return"string"===t||"number"===t||"boolean"===t||"bigint"===t}function q(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 J(e){let t=function(){if(void 0!==vt)return vt;let e=function(){let e=globalThis.trustedTypes;return"object"!=typeof e||null===e?void 0:"function"==typeof e.createPolicy?e:void 0}();if(void 0===e)return vt=null,null;try{vt=e.createPolicy(zn,{createHTML:e=>e})}catch{vt=null}return vt}();return null===t?e:t.createHTML(e)}function K(e,t){for(let n of t.keyAttributes){let t=e.getAttribute(n);if(null!==t&&t.length>0)return`${n}=${t}`}}function Q(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(ln)||e.hasAttribute(Gn))return!0;let t=e.getAttribute("contenteditable");return null!==t&&"false"!==t}function X(e,t,n){if(!function(e,t){return e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI&&!Q(e)&&!Q(t)}(e,t))return t;let i=function(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}(e);return function(e,t){for(let n of Array.from(e.attributes))t.hasAttribute(n.name)||qn.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=K(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?K(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=Z(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(ee(i,r)){c=Z(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&&ee(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)&&Y(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),function(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{}}(i),e}function Z(e,t,n){return e instanceof Element&&t instanceof Element?Q(e)&&Q(t)?e:X(e,t,n):(e.nodeValue!==t.nodeValue&&(e.nodeValue=t.nodeValue),e)}function Y(e){return e.nodeType===Node.TEXT_NODE&&0===(e.nodeValue??"").trim().length}function ee(e,t){return e.nodeType===t.nodeType&&(!(e instanceof Element&&t instanceof Element)||e.tagName===t.tagName&&e.namespaceURI===t.namespaceURI)}function te(e,t){let n=ne();if(!n)throw new Error("sanitizeHtml needs a DOM");if(""===e)return"";let i=function(e){if(!e){let e=new Map;for(let[t,n]of Object.entries(ti))e.set(t,n);return{allowedTags:Jn,attrByTag:e,allowFormControls:!1,templateMode:!1,mode:oi,allowedData:new Set}}let t=new Set(Jn);for(let n of e.additionalAllowedTags??[])t.add(n);if(!0===e.allowFormControls)for(let e of Kn)t.add(e);let n=new Map;for(let[e,t]of Object.entries(ti))n.set(e,t);for(let[t,i]of Object.entries(e.additionalAllowedAttributes??{})){let e=n.get(t),r=new Set(e??[]);for(let e of i)r.add(e);n.set(t,r)}return{allowedTags:t,attrByTag:n,allowFormControls:!0===e.allowFormControls,templateMode:!0===e.templateMode,mode:e.policy??oi,allowedData:new Set((e.allowedDataAttributes??[]).map(e=>e.toLowerCase()))}}(t),r=n.createElement("template");return r.innerHTML=J(e),ie(r.content,i),r.innerHTML}function ne(){if(!(typeof document>"u"))return document}function ie(e,t){for(let n of Array.from(e.childNodes))n.nodeType===ii?re(n,t):n.nodeType===ri&&n.remove()}function re(e,t){let n=e.tagName.toLowerCase();if(!Qn.has(n)||t.allowFormControls&&Kn.has(n)){if(!t.allowedTags.has(n)){ie(e,t);let n=e.parentNode;if(n){for(;e.firstChild;)n.insertBefore(e.firstChild,e);e.remove()}return}(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&&li.has(r))continue;if("id"===r||"name"===r||r.startsWith(ei)){e.removeAttribute(t.name);continue}if(r.startsWith(Yn)){n.allowedData.has(r)||e.removeAttribute(t.name);continue}if(Xn.has(r)||r.startsWith(Zn))continue}else if(Xn.has(r)||r.startsWith(Zn)||r.startsWith(Yn))continue;i?.has(r)?(ni.has(r)&&!f(t.value)||"srcset"===r&&!le(t.value))&&e.removeAttribute(t.name):e.removeAttribute(t.name)}}})(e,n,t),"a"===n&&function(e){let t=e.getAttribute("href");null===t||!p(t)||(e.setAttribute("rel","noopener noreferrer"),e.hasAttribute("target")||e.setAttribute("target","_blank"))}(e),ie(e,t)}else e.remove()}function le(e){for(let t of e.split(",")){let e=t.trim();if(0===e.length)continue;let n=e.search(/\\s/);if(!f(-1===n?e:e.slice(0,n)))return!1}return!0}function oe(e){return""===e?"":e.replace(si,e=>ai[e])}function ae(e){return""===e?"":e.replace(di,e=>ui[e])}function se(e,t,n,i){let r="object"==typeof t&&null!==t?t:null;return e.replace(ci,(e,l)=>null!==r&&function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}(r,l)?oe(i(Reflect.get(r,l))):null===r&&"value"===l?oe(i(t)):"index"===l?String(n):e)}function ue(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 de(e){return null==e||""===e}function ce(e){let t=gi.get(e);if(void 0!==t)return t;let n=new Set(hi);for(let t of e.matchAll(pi)){let e=t[1]?.toLowerCase();void 0!==e&&n.add(e)}let i={};for(let e of n)i[e]=fi;let r={additionalAllowedTags:[...n],additionalAllowedAttributes:i,allowFormControls:!0,templateMode:!0};return gi.set(e,r),r}function he(e){let{template:t,container:n,patches:i,nextItems:r,store:l,forceRender:o=!1}=e,a=pe(n,t,i,r,o,l);return null===a?null:ge(a,l,{morph:e.morph??!0,onDuplicateKey:e.onDuplicateKey})}function fe(e,t){return t.hasAttribute(vi)&&t.hasAttribute(yi)}function pe(e,t,n,i,r,l){let o=function(e,t,n,i,r,l,o){let a=Array.from(e.children),s=ke(a,mi),u=new Set,d=[];for(let c=0;c<n.length;c+=1){let h=n[c],f=Se(h),p=void 0===f?a[c]??null:Te(s,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=i.replaces.has(c),m=r||i.renders.has(c)||null===p?Ae(e.ownerDocument,t,h,c):void 0;if(null===m)return null;let v=void 0===m?[]:me(g?null:p,m,h,l,o);if(null===v)return null;d.push([c,p,m??void 0,v,g])}return d}(e,t,i,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}}(n),r,l.get(e),l);return null===o?null:[e,o,i]}function ge(e,t,n){let[i,r,l]=e,o=new Set,a=!1;for(let[e,l,s,u,d]of r){let r=l;if(void 0!==s){let e=!(!n.morph||d||null===l)&&X(l,s,{keyAttributes:[mi,vi],retainChildrenOf:fe,...void 0!==n.onDuplicateKey?{onDuplicateKey:n.onDuplicateKey}:{}})===l;if(!e)for(let[e,t]of u)null!==e&&(ye(e,t),t.replaceWith(e));for(let[,,e]of u)void 0!==e&&ge(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);let s=function(e,t){let n=t.get(e);return n||(n=new Map,t.set(e,n)),n}(i,t);s.clear();for(let e of l)we(s,e);return a}function me(e,t,n,i,r){let l=ke(null===e?[]:ve(e),vi),o=Se(n),a=void 0!==o?i?.get(o):void 0,s=[];for(let e of ve(t)){let t=e.getAttribute(vi);if(null===t)continue;let i,o=Te(l,t)??null,u=e.getAttribute(yi),d=u?o:null,h=d?.getAttribute(yi)??null;if(u){let l=be(n,t);if(void 0!==l||null!==d){let n=l??[],o=c(null===d?[]:be(a,t)??[],n),s=null!==d&&h!==u;if((o.length>0||s)&&(i=pe(d??e,u,o,n,s,r)??void 0,void 0===i))return null}}s.push([d,e,i])}return s}function ve(e){return Array.from(e.querySelectorAll(`[${vi}]`)).filter(t=>{let n=t.parentElement;for(;null!==n&&n!==e;){if(n.hasAttribute(vi))return!1;n=n.parentElement}return n===e})}function ye(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 be(e,t){if("object"!=typeof e||null===e)return;let n=e[t];return Array.isArray(n)?n:void 0}function we(e,t){let n=Se(t);void 0!==n&&e.set(n,t)}function Se(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function ke(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 Te(e,t){return e.get(t)?.pop()}function Ae(e,t,n,i){let r=te(se(t,n,i,ue),ce(t)),l=e.createElement("template");l.innerHTML=J(r);let o=l.content.firstElementChild;if(!o)return null;let a=Se(n);return void 0!==a&&o.setAttribute(mi,a),o}function Ce(e,t,n,i){let r=m(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=m(B(n,t,e.locale??i,void 0!==e.locale));if(void 0===r)return;o+=`|${t}=${r}`}return o}function $e(e,t){return null!==t&&e.generation===t.generation&&e.revision===t.revision}function Fe(e){if(!1===e.enableA11y)return null;let t=e.root,n=void 0===t?void 0:Re(t)?t:t.ownerDocument;return new Wt(e.a11yLocale,n)}function Re(e){return 9===e.nodeType}function Ne(e){return e.body}function Me(e){if(typeof window>"u")return;let t=[];window.parent!==window&&t.push(window.parent),window.opener instanceof Window&&t.push(window.opener),jn.sendReady(t,e)}function xe(){if(typeof window>"u")return!1;try{return window.self!==window.top}catch{return!0}}function Ee(e){let t=e.trim();if(0!==t.length)try{let e=new URL(t);return"http:"!==e.protocol&&"https:"!==e.protocol||!Ci.test(e.origin)?void 0:e.origin}catch{return}}function Ie(e){let t=e.format;return"string"==typeof t&&Mi.has(t)?t:"number"==typeof t?Ni[t]:void 0}function Le(e){let t=e.indent;return"number"==typeof t&&t>0?t:0}function Oe(e){return"rtl"===e.direction?\' dir="rtl"\':"ltr"===e.direction?\' dir="ltr"\':""}function Ue(e){let t=Ie(e),n=Le(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 Pe(e){return"object"==typeof e&&null!==e?e:void 0}function je(e){return Pe(e)}function We(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-").toLowerCase()}function De(e){return"string"==typeof e&&e.length>0?e:void 0}function Ve(e){let t=De(e.title)??De(e.name)??De(e.slug);return void 0!==t?t:void 0===e.id?void 0:String(e.id)}function Be(e){if("string"==typeof e.text)return e.text;if(!e.children)return"";let t="";for(let n of e.children)t+=Be(n);return t}function _e(e){return`${"number"==typeof e.width?` width="${String(e.width)}"`:""}${"number"==typeof e.height?` height="${String(e.height)}"`:""}`}function He(e){return"string"==typeof e.mimeType?` type="${ae(e.mimeType)}"`:""}function ze(e){return Li.get(e)}function Ge(e,t,n,i){let r=Pe(e.fields)??{},l="string"==typeof r.blockType?r.blockType:"",o=We(l);if(""!==l){let e=ze(l)??ze(o);if(e)return e(r,{renderChildren:t.renderChildren})}return`<${n} class="${""===o?i:`${i} ${i}--${o}`}"></${n}>`}function qe(e,t){return"number"==typeof t&&t>1?` ${e}="${String(t)}"`:""}function Je(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 Ke(e){let t="";for(let n of e)t+=Qe(n);return t}function Qe(e){let t=function(e){return Ui.get(e)??Oi[e]}(e.type);return t?t(e,Pi):void 0!==e.children?Ke(e.children):""}function Xe(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+=Xe(n);return t}function Ze(e="text"){let t=new WeakSet;return{name:e,render:g((e,n)=>{let i=e.element,r=function(e){return null==e?"":Je(e)?function(e){return Je(e)?e.root.children.map(Xe).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(Wi))return function(e,t,n){e.has(t)||(e.add(t),Ft(`[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=J(function(e){return oe(e).replace(/\\r\\n|\\r|\\n/g,"<br>")}(r)):i.textContent=r}else i.value=r})}}function Ye(e,t,n){return"string"!=typeof n||0===n.length?{kind:"none"}:f(n)?{kind:"safe",url:n}:(Bi.has(e)||(Bi.add(e),Ft(`[live-preview] LP0401: refused an unsafe URL for "${t}" on <${e.tagName.toLowerCase()}>; the attribute was cleared.`)),{kind:"unsafe"})}function et(e,t=e=>e){return{name:e,render(e,n,i){let r=e.element;if(de(n)){!function(e){"INPUT"!==e.tagName&&"TEXTAREA"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):e.value=""}(r);return}let l=ue(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):B(i.allFields,n,i.locale,void 0!==e.locale),a=Ye(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 tt(e){for(let t of Gi)e.removeAttribute(t)}function nt(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||!f(n.url)||t.push(`${it(n.url)} ${String(n.width)}w`);return 0!==t.length?("number"==typeof e.width&&"string"==typeof e.url&&f(e.url)&&t.push(`${it(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 it(e){return e.replace(/[\\s,]/g,encodeURIComponent)}function rt(e){"IMG"===e.tagName?tt(e):e.style.backgroundImage=""}function lt(e){"IMG"!==e.tagName?(e.removeAttribute("href"),e.textContent=""):tt(e)}function ot(e){let t=Pe(e);return void 0===t?ue(e):Ve(t)??""}function at(e,t){let n=e??"";if(null==t)return n;let i=st(t);return"{}"===i?n:`${n}|${i}`}function st(e){if(null===e||"object"!=typeof e)return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(e=>st(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)}:${st(n)}`)}return`{${i.join(",")}}`}function ut(e){for(;e.size>tr;){let t=e.keys().next().value;if(void 0===t)break;e.delete(t)}}function dt(e){return String(e).padStart(2,"0")}function ct(){let e=new WeakMap,t=new WeakSet,n=new WeakMap,i=new WeakMap;return{name:"structural-array",render:g((r,l)=>{let o=de(l)?[]:l;if(!Array.isArray(o))return!1;let a=r.element,s=r.arrayTemplate;if(void 0===s||0===s.length)return function(e,t,n){e.has(t)||(e.add(t),Ft(`[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,a,r.fieldName),!1;let u=e.get(a),d=ht(a),h=u?.values??function(e){return e.map((e,t)=>null===e?{__payloadDomPosition:t}:{id:e})}(d),f=c(h,o),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)}(u,s,d);if(0===f.length&&!p)return e.set(a,{values:o.slice(),template:s,domSnapshot:d}),!1;!function(e,t,n,i,r){let l=r.map(ft),o=new Set,a=l.find(e=>!(void 0===e||!o.has(e)&&(o.add(e),1)));if(void 0!==a&&pt(e,t,n,a),l.some(e=>void 0===e)&&gt(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(ft).filter(e=>void 0!==e)),o=l.some(e=>void 0!==e&&r.has(e));r.size>0&&!o&&gt(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,a,r.fieldName,u?.values,o);let g=he({template:s,container:a,patches:f,nextItems:o,store:i,forceRender:p,onDuplicateKey:(e,t)=>{pt(n,e,r.fieldName,t)}});return null!==g&&(e.set(a,{values:o.slice(),template:s,domSnapshot:ht(a)}),!!g&&void 0)})}}function ht(e){return Array.from(e.children,e=>e.getAttribute(mi))}function ft(e){if("object"!=typeof e||null===e)return;let t=e.id;return"string"==typeof t||"number"==typeof t?String(t):void 0}function pt(e,t,n,i){gt(e,t,"LP0405",`LP0405: two items of "${n}" share the key "${i}"; later ones pair by position. Make \\`id\\` unique per item.`)}function gt(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),Ft(`[live-preview] ${i}`))}function mt(){return typeof __LIVE_PREVIEW_CONFIG__>"u"?[]:__LIVE_PREVIEW_CONFIG__}var vt,yt=Object.defineProperty,bt=e=>{throw TypeError(e)},wt=(e,t,n)=>((e,t,n)=>t in e?yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),St=(e,t,n)=>t.has(e)||bt("Cannot "+n),kt=(e,t,n)=>(St(e,t,"read from private field"),n?n.call(e):t.get(e)),Tt=(e,t,n)=>t.has(e)?bt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),At=(e,t,n,i)=>(St(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),Ct=(e,t,n)=>(St(e,t,"access private method"),n),$t=t((...e)=>console.error(...e)),Ft=t((...e)=>console.warn(...e)),Rt=t((...e)=>console.debug(...e)),Nt=class{constructor(){Tt(this,Et);Tt(this,Mt,new Map);Tt(this,xt,new Map)}on(e,t){return Ct(this,Et,Lt).call(this,kt(this,Mt),e,t)}once(e,t){return Ct(this,Et,Lt).call(this,kt(this,xt),e,t)}off(e,t){Ct(this,Et,Ot).call(this,kt(this,Mt),e,t),Ct(this,Et,Ot).call(this,kt(this,xt),e,t)}async emit(e,t){await Ct(this,Et,It).call(this,e,t)}async emitWhile(e,t,n){return Ct(this,Et,It).call(this,e,t,n)}listenerCount(e){return(kt(this,Mt).get(e)?.size??0)+(kt(this,xt).get(e)?.size??0)}removeAllListeners(e){void 0!==e?(kt(this,Mt).delete(e),kt(this,xt).delete(e)):(kt(this,Mt).clear(),kt(this,xt).clear())}eventNames(){let e=new Set;for(let t of kt(this,Mt).keys())e.add(t);for(let t of kt(this,xt).keys())e.add(t);return[...e]}},Mt=new WeakMap,xt=new WeakMap,Et=new WeakSet,It=async function(e,t,n){let i=()=>n?.()??!0;if(!i())return!1;let r=kt(this,Mt).get(e);if(r)for(let n of[...r])if(!i()||(await Ct(this,Et,Ut).call(this,n,t,e),!i()))return!1;if(!i())return!1;let l=kt(this,xt).get(e);if(l&&l.size>0){let n=[...l];kt(this,xt).delete(e);for(let r of n)if(!i()||(await Ct(this,Et,Ut).call(this,r,t,e),!i()))return!1}return i()},Lt=function(e,t,n){let i=e.get(t);return i||(i=new Set,e.set(t,i)),i.add(n),()=>{Ct(this,Et,Ot).call(this,e,t,n)}},Ot=function(e,t,n){let i=e.get(t);void 0!==i&&(i.delete(n),0===i.size&&e.delete(t))},Ut=async function(e,t,n){try{await e(t)}catch(e){let t="string"==typeof n||"number"==typeof n?String(n):"<event>";$t(`[live-preview] LP0601: handler for "${t}" threw:`,e)}},Pt="payload-live-preview-a11y",jt=new WeakMap,Wt=class{constructor(e,t){wt(this,"german");wt(this,"document");wt(this,"lease",null);let n=t??(typeof document>"u"?null:document),r=n?.documentElement.getAttribute("lang")??"";this.german=function(e){return/^de(?:[-_]|$)/i.test(e)}(e??(r.length>0?r:i())),this.document=n}mount(){let e=this.document;if(null==e?.body)return null;this.lease??(this.lease=function(e){let t=jt.get(e);return void 0===t&&(t={element:null,owned:!1,messageNode:null,refs:0,timer:null},jt.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;r(t),e&&n.remove()}let i=e.getElementById(Pt);return t.owned=null===i,null===i&&(i=e.createElement("div"),i.id=Pt,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&&r(e),e.owned&&n?.remove(),e.element=null,jt.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 l=setTimeout(()=>{n.timer===l&&n.element===t&&r(n)},1500);n.timer=l}},Dt=new Set(["tabs","row","collapsible"]),Vt={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"},Bt=new Set(["http:","https:","mailto:","tel:"]),_t=/^\\s*(?:javascript|data|vbscript|file|blob|about)\\s*:/i,Ht=/^(?:\\.{1,2}\\/|[a-zA-Z0-9_-]+\\/?)/,zt=/^[\\\\/]{2}/,Gt=/[\\t\\n\\r]/g,qt=new Set(["style","srcdoc","formaction","form","id","name","is","srcset","imagesrcset"]),Jt=new Set(["href","src","poster","cite","action","xlink:href","data"]),Kt=new WeakSet,Qt=class{constructor(){wt(this,"previous",null)}diff(e,t){let n=this.previous,i=new Map,r=new Set;for(let[t,l]of Object.entries(e)){let e=m(l);i.set(t,e),(null===n||void 0===e||n.get(t)!==e)&&r.add(t)}if(null!==n)for(let e of n.keys())i.has(e)||r.add(e);this.previous=i;let l=new Set;for(let[e,n]of Object.entries(t))if(r.has(e))for(let e of n)l.add(e);return{changed:r,invalidated:l}}reset(){this.previous=null}},Xt={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"}},Zt=Object.keys(Xt),Yt=class{constructor(){wt(this,"negotiation",v(void 0));wt(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=v(this.negotiation.theirs,this.observed),t("protocol",`observed=${n.join(",")}`)}}applyVersion(e,t){let n=this.negotiation;if(n.theirs===e)return;let i=v(e,this.observed);this.negotiation=i,i.negotiated!==n.negotiated&&t("protocol","ours=4",`theirs=${e}`,`negotiated=${i.negotiated}`)}},en=class{constructor(){Tt(this,tn)}reveal(e,t,n){return e===kt(this,tn)?"skipped-same":(At(this,tn,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:y(t)?"auto":"smooth",block:"center"}),"revealed")}(t,n))}reset(){At(this,tn,void 0)}},tn=new WeakMap,nn=class{constructor(){wt(this,"started",!1);wt(this,"suspended",!1);wt(this,"deferredStart",null);wt(this,"activeUpdate",null);wt(this,"locale");wt(this,"schema");wt(this,"schemaIndex");wt(this,"updateCount",0);wt(this,"supersededCount",0);wt(this,"completedCount",0);wt(this,"skippedUnchangedCount",0);wt(this,"lastFlush",null);wt(this,"absentFields",new Set);wt(this,"warnedOrphanFields",new Set);wt(this,"warnedStrategy",new WeakSet);wt(this,"warnedUnattributableMessage",!1);wt(this,"warnedVisibilityGate",!1);wt(this,"warnedFragmentFallback",!1);wt(this,"lastAppliedIdentity",new WeakMap);wt(this,"seenFieldIdentity",new Map);wt(this,"fragmentStats",{rendered:0,failed:0,superseded:0});wt(this,"routeStats",{refreshes:0,failed:0,loopStopped:0});wt(this,"fragmentController",null);wt(this,"routeController",null);wt(this,"readyTimers",[]);wt(this,"revealer",new en);wt(this,"changes",new Qt);wt(this,"protocol",new Yt)}isRunning(){return this.started}isCurrent(e){return this.started&&this.activeUpdate===e}complete(e){e.completed||(e.completed=!0,this.completedCount+=1)}abortStrategies(){for(let e of["fragmentController","routeController"]){let t=this[e];null!==t&&(this[e]=null,t.abort())}}},rn=class{constructor(e,t){wt(this,"deps",e);wt(this,"state",t)}apply(e){let{deps:t,state:n}=this,i=n.activeUpdate;if(null===i||void 0===e.identity||!b(i.identity,e.identity)||!n.isCurrent(i))return!1;let{target:r,value:l}=e,o=void 0!==i.schemaIndex?function(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}(i.schemaIndex,r.fieldName):void 0,a=function(e,t){if(e.explicitFieldType)return e.fieldType;if(void 0!==t){let e=function(e){if(Object.prototype.hasOwnProperty.call(Vt,e))return Vt[e]}(t);if(void 0!==e)return e}return e.fieldType}(r,o?.type);"text"===a&&!0!==r.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)}(l)&&(a="richText");let s;try{s=t.resolveRenderer(a,r)}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;let u=t.emitter.listenerCount("elementUpdate")>0,d=u?function(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName?e.value:"IMG"===e.tagName?e.src:e.textContent}(r.element):void 0;if(!n.isCurrent(i))return!1;let c={allFields:e.allFields,locale:r.locale??i.locale,schema:o,...void 0!==t.renderRichText?{renderRichText:t.renderRichText}:{}};!0===r.boundary&&r.element.toggleAttribute("hidden",function(e){return null==e||("string"==typeof e?0===e.trim().length:Array.isArray(e)&&0===e.length)}(l));try{if(void 0!==r.targetAttribute){if("blocked"===function(e,t,n){let i=t.toLowerCase().trim();if(0===i.length||i.startsWith("on")||qt.has(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 Jt.has(i)&&!f(r)?"blocked":(e.setAttribute(i,r),"applied")}(r.element,r.targetAttribute,l))return t.warn(`[live-preview] LP0401: refused to write "${r.fieldName}" into attribute "${r.targetAttribute}"`),!1}else{if(void 0===s)return t.log("no renderer for",a),!1;if(!1===function(e,t,n,i){return e.render(t,n,i)}(s,r,l,c)&&function(e){return Kt.has(e.render)}(s))return!1}}catch(e){return this.fail(i,e)}if(!n.isCurrent(i))return!1;u&&t.emitter.emitWhile("elementUpdate",{element:r.element,fieldName:r.fieldName,previousValue:d,nextValue:l,revision:i.identity.revision,receivedAt:i.receivedAt,source:"patch"},()=>n.isCurrent(i));let h=n.isCurrent(i);return h&&(void 0!==e.valueIdentity?n.lastAppliedIdentity.set(r.element,e.valueIdentity):n.lastAppliedIdentity.delete(r.element)),h}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}},ln="data-payload-island",on=`astro-island, [${ln}]`,an="data-payload-fragment",sn="data-payload-strategy",un="data-payload-field",dn="data-payload-type",cn="data-payload-attribute",hn="data-payload-href",fn="data-payload-src",pn="data-payload-alt",gn="data-payload-array-template",mn="data-payload-array-separator",vn="data-payload-locale",yn="data-payload-richtext",bn="data-payload-html",wn="data-payload-array",Sn="data-payload-structural",kn="data-payload-owner",Tn="data-payload-depends",An="data-payload-strategy",Cn="data-payload-boundary",$n=[un,dn,cn,hn,fn,pn,gn,mn,vn,yn,bn,wn,Sn,kn,Tn,An,Cn,"type"],Fn=`[${un}]`,Rn=`[${kn}]`,Nn=/^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/i,Mn=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"]),xn=class{constructor(e={}){wt(this,"entriesByField",new Map);wt(this,"entryByElement",new WeakMap);wt(this,"filter");wt(this,"count",0);wt(this,"dependencies",null);wt(this,"islandRoots",[]);this.filter=e.filter??R}dependencyMap(){if(null!==this.dependencies)return this.dependencies;let e=[];for(let t of this.values())void 0!==t.dependsOn&&e.push(S(t.fieldName,t.dependsOn));return this.dependencies=w(...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(Fn))void 0!==this.add(t)&&(n+=1);return this.islandRoots=function(e){let t=[];for(let n of e.querySelectorAll(on))T(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(un);if(null===t||0===t.length)return;let n=e.getAttribute(dn),i=e.getAttribute(cn),r=e.getAttribute(hn),l=e.getAttribute(fn),o=e.getAttribute(pn),a=e.getAttribute(gn),s=e.getAttribute(mn),u=e.getAttribute(vn),d=function(e){let t=e.closest(Rn)?.getAttribute(kn);return null==t||0===t.length?void 0:t}(e),c=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(Tn)),h=e.getAttribute(An),f=A(e);return{element:e,fieldName:t,fieldType:F(e),explicitFieldType:null!==n&&$(n),strategyKind:C(e)??"unknown",...null!==f?{fragmentBoundary:f}:{},...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}:{},...void 0!==d?{owner:d}:{},...c.length>0?{dependsOn:c}:{},...null!==h&&h.length>0?{strategy:h}:{},...e.hasAttribute(Cn)?{boundary:!0}:{}}}},En=class{constructor(e){wt(this,"serverURL");wt(this,"apiRoute");wt(this,"depth");wt(this,"fetchFn");wt(this,"log");wt(this,"inflight",null);wt(this,"attempt",0);wt(this,"destroyDepth",0);this.serverURL=e.serverURL.replace(/\\/+$/,"");let i=e.apiRoute??"/api";this.apiRoute=i.startsWith("/")?i:`/${i}`,this.depth=e.depth??1,this.fetchFn=e.fetchFn,this.log=void 0===e.log?n:t(e.log)}canMerge(e){try{return e.globalSlug?M(e.globalSlug):!!M(e.collectionSlug)&&function(e){if("number"==typeof e)return Number.isFinite(e);if("string"!=typeof e||0===e.length||e.length>512||"."===e||".."===e||e.includes("/")||e.includes("\\\\")||N(e))return!1;try{return encodeURIComponent(e),!0}catch{return!1}}(e.data.id)}catch{return!1}}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"};if(!this.canMerge(e))return r()?{status:"superseded"}:{status:"unavailable"};let t=this.fetchFn??("function"==typeof fetch?fetch:void 0);if(void 0===t)return{status:"unavailable"};i=new AbortController,this.inflight=i;let l=e.globalSlug?`globals/${encodeURIComponent(e.globalSlug)}`:`${encodeURIComponent(e.collectionSlug??"")}/${encodeURIComponent(String(e.data.id))}`,o=`${this.serverURL}${this.apiRoute}/${l}`,a=await t(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,...void 0!==e.locale?{locale:e.locale}:{}}),signal:i.signal});if(r()||x(i.signal))return{status:"superseded"};if(!a.ok)return this.log("merge HTTP",a.status,o),{status:"unavailable"};let s=await a.json();return r()||x(i.signal)?{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()||null!==i&&x(i.signal)?{status:"superseded"}:(this.log("merge exception",e),{status:"unavailable"})}finally{null!==i&&!r()&&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}}},In="2.0.0-beta.0",Ln={name:"payload-2",fieldTyping:"schema",populatesRelationships:"admin",documentEvents:!1},On={name:"payload-3",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!0},Un={name:"unknown",fieldTyping:"heuristic",populatesRelationships:"server",documentEvents:!1},Pn=["data","fieldSchemaJSON","globalSlug","collectionSlug","locale","ready","previewToken","protocolVersion"],jn=class{constructor(e,t){wt(this,"matcher");wt(this,"handlers");wt(this,"boundListener");wt(this,"attachedTarget");wt(this,"generation",0);wt(this,"revision",0);wt(this,"queue",[]);wt(this,"queueHead",0);this.matcher=e,this.handlers=t}attach(e=window){if(void 0!==this.attachedTarget)return;let t=!1,n=e=>{if(!t||this.boundListener!==n)return;let i=this.generation;try{this.receive(e,i)}catch{let t;try{t=e.origin}catch{t=""}this.reportInvalid("shape",t,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(){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){if(0===e.length||0===t.length)return;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){if(!this.isCurrentGeneration(t))return;let n=e.origin;if(!this.matchesOrigin(n,t)){this.reportInvalid("origin",n,t);return}if(!this.matchesSource(e)){this.reportInvalid("source",n,t);return}let i=e.data;if(function(e){return"object"==typeof e&&null!==e&&"type"in e&&"string"==typeof e.type}(i))switch(i.type){case"payload-live-preview":if(!function(e){let t=e;return!(void 0!==t.data&&null!==t.data&&!O(t.data))&&L(t.fieldSchemaJSON,e=>Array.isArray(e))&&L(t.globalSlug,e=>"string"==typeof e)&&L(t.collectionSlug,e=>"string"==typeof e)&&L(t.locale,e=>"string"==typeof e)&&L(t.ready,e=>"boolean"==typeof e)&&L(t.previewToken,e=>"string"==typeof e)&&L(t.protocolVersion,e=>"number"==typeof e)}(i)){this.reportInvalid("shape",n,t);return}this.dispatchUpdate(function(e){let t={...e};for(let e of Pn)null===Reflect.get(t,e)&&Reflect.deleteProperty(t,e);if(!Array.isArray(t.fieldSchemaJSON))return t;let n;try{n=l(t.fieldSchemaJSON)}catch{n=[]}return{...t,fieldSchemaJSON:n}}(i),n,t);return;case"payload-document-event":if(!function(e){let t=e;return I(t.action,e=>"updated"===e||"created"===e||"deleted"===e)&&I(t.slug,e=>"string"==typeof e)&&I(t.id,e=>"string"==typeof e||"number"==typeof e&&Number.isFinite(e))}(i)){this.reportInvalid("shape",n,t);return}this.invokeHandler(t,this.handlers.onDocumentEvent,i,n);return;case"payload-live-preview-focus":{let e=function(e){let t=e.field;return"string"==typeof t&&t.length>0?t:void 0}(i);if(void 0===e){this.reportInvalid("shape",n,t);return}let r=this.handlers.onFocusField;void 0!==r&&this.invokeHandler(t,r,e,n);return}default:this.reportInvalid("type",n,t)}else this.reportInvalid("shape",n,t)}dispatchUpdate(e,t,n){let i=O(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,settled:!1,approved:!1};this.queue.push(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){this.isCurrentGeneration(e.generation)&&(e.approved=t,e.settled=!0,this.drainQueue(e.generation))}drainQueue(e){for(;this.isCurrentGeneration(e);){let t=this.queue[this.queueHead];if(void 0===t)return;if(this.matchesOrigin(t.origin,e)){if(!t.settled)return;this.dequeue(t)&&(t.approved?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){this.isCurrentGeneration(n)&&(void 0===i?this.invokeHandler(n,this.handlers.onUpdate,e,t):this.invokeHandler(n,this.handlers.onUpdate,e,t,i))}reportInvalid(e,t,n){if(!this.isCurrentGeneration(n))return;let i=this.handlers.onInvalid;void 0!==i&&this.invokeHandler(n,i,e,t)}matchesSource(e){if("parent-or-opener"!==this.handlers.sourcePolicy)return!0;let t=this.attachedTarget;if(void 0===t)return!1;try{let n=e.source;if(null===n)return!1;let i=t.parent;if(i!==t&&n===i)return!0;let r=t.opener;return null!=r&&n===r}catch{return!1}}matchesOrigin(e,t){if(!this.isCurrentGeneration(t))return!1;try{return!0===this.matcher(e)&&this.isCurrentGeneration(t)}catch{return!1}}invokeHandler(t,n,...i){if(this.isCurrentGeneration(t))try{e(n(...i))}catch{}}isCurrentGeneration(e){return void 0!==this.attachedTarget&&this.generation===e}dequeue(e){return this.queue[this.queueHead]===e&&(this.queueHead+=1,this.queueHead===this.queue.length?(this.resetQueue(),!0):(this.queueHead>=1024&&2*this.queueHead>=this.queue.length&&(this.queue=this.queue.slice(this.queueHead),this.queueHead=0),!0))}resetQueue(){this.queue=[],this.queueHead=0}},Wn=1,Dn=class{constructor(e,t={}){wt(this,"callbacks");wt(this,"debounceMs");wt(this,"rootMargin");wt(this,"visible",new Set);wt(this,"mutation",null);wt(this,"intersection",null);wt(this,"debounceTimer",null);wt(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:[...$n]})}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&&$n.includes(t.attributeName)&&(t.attributeName===un||t.attributeName===kn||t.target.nodeType===Wn&&t.target.hasAttribute(un)))return!0;for(let e of t.addedNodes)if(U(e))return!0;for(let e of t.removedNodes)if(U(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}},Vn=class{constructor(e){wt(this,"timeoutMs");wt(this,"onTimeout");wt(this,"handle",null);wt(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}},Bn=class{constructor(){wt(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)}},_n=new Set(["__proto__","prototype","constructor"]),Hn=new Set(["id","_id","createdAt","updatedAt","createdBy","updatedBy","_status","globalType","collection","locale","localized"]),zn="payload-live-preview",Gn="data-payload-owned",qn=new Set(["open","value","checked","selected"]),Jn=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"]),Kn=new Set(["input","button","textarea","select","option","label"]),Qn=new Set(["script","style","iframe","object","embed","link","meta","base","form","input","button","select","textarea","svg","math","template","frame","frameset","noframes","noscript"]),Xn=new Set(["id","class","lang","dir","title","role","tabindex"]),Zn="aria-",Yn="data-",ei="data-payload-",ti={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"])},ni=new Set(["href","src","cite","poster"]),ii=1,ri=8,li=(Error,new Set(["id","name","data-payload-key","data-payload-nested-key","data-payload-nested-template"])),oi="strict",ai=(Object.freeze({allowedTags:Jn,removeCompletely:Qn,globalAttributes:Xn,attributesByTag:ti,urlAttributes:ni}),Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"})),si=/[&<>"\'/`=]/g,ui=Object.freeze({"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#x27;"}),di=/[&<>"\']/g,ci=/\\{\\{([\\s\\S]*?)\\}\\}/g,hi=["input","textarea","select","option","button","label","details","summary","dialog","video","audio","progress","meter"],fi=["type","name","placeholder","open","disabled","readonly","required","checked","selected","value","min","max","step","rows","cols","for","controls","muted","loop","poster","src"],pi=/<([a-z][a-z0-9]*(?:-[a-z0-9]+)+)\\b/gi,gi=new Map,mi="data-payload-key",vi="data-payload-nested-key",yi="data-payload-nested-template",bi=class{constructor(e,t,n){wt(this,"deps",e);wt(this,"state",t);wt(this,"host",n)}planFragments(e){let t=this.deps.strategies.fragment;if(void 0===t)return null;let n=t.plan(this.deps.root,e),i=new Set(n);return{boundaries:n,strategy:t,covers:e=>void 0!==e.fragmentBoundary&&i.has(e.fragmentBoundary)}}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.identity.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=J(t);let i=e.cloneNode(!1);i.append(n.content),X(e,i,{keyAttributes:[mi]})}(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,i,r,l)=>{e.pendingFragments-=1,a.emitWhile("error",{error:new Error(`fragment "${n}" fell back to patch: ${l}`),context:"fragment",code:r},o),a.emitWhile("fragmentRender",{element:t,id:n,key:i,status:"failed",code:r,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,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,l=r.routeStats;if(e.routeRefreshed){l.loopStopped+=1,i.log("route","LP0805",`revision ${String(e.identity.revision)} asked for a second refresh`);return}e.routeRefreshed=!0;let o=new AbortController;r.routeController=o;let a,s=()=>r.isCurrent(e)&&!o.signal.aborted;try{a=await n.refresh({revision:e.identity.revision,receivedAt:e.receivedAt,signal:o.signal,isCurrent:s,log:(e,t)=>{i.log("route",e,t)}})}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.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.identity.revision,receivedAt:e.receivedAt,source:"route"},s);return}"failed"===a&&(l.failed+=1),this.host.reapply(e,t)}}warnFragmentFallback(e){this.state.warnedFragmentFallback||(this.state.warnedFragmentFallback=!0,this.deps.warn(`[live-preview] LP0806: "${e.fieldName}" asks for the fragment strategy but no handler is configured; patching instead`))}warnUnsupportedStrategy(e){this.state.warnedStrategy.has(e.element)||(this.state.warnedStrategy.add(e.element),this.deps.warn(`[live-preview] LP0407: "${e.fieldName}" asks for strategy "${String(e.strategy)}"; only patch, fragment and route exist`))}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=B(t.fields,i,l.locale??e.locale,void 0!==l.locale);void 0!==r&&this.deps.scheduler.schedule({target:l,value:this.host.transform(l,r,t.fields,()=>!0),allFields:t.fields,identity:e.identity,data:t})}}},wi=class{constructor(e,t,n){wt(this,"deps",e);wt(this,"state",t);wt(this,"strategies");this.strategies=new bi(e,t,{reapply:(e,t)=>{this.scheduleAllFields(e,t)},transform:(e,t,n,i)=>this.transformForBinding(e,t,n,i),rebuildCache:n,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=e.externallyUpdatedRelationship,o="object"==typeof l&&null!==l;o&&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=a(e.fieldSchemaJSON));let s={identity:n,message:e,locale:r.locale,schema:r.schema,schemaIndex:r.schemaIndex,receivedAt:Date.now(),forceRender:o,touched:new Set,invalidated:new Set,revealTarget:void 0,revealIdentities:[],pendingFragments:0,routeRefreshed:!1,cancelled:!1,completed:!1},u=r.activeUpdate;r.abortStrategies(),null!==u&&!u.completed&&(r.supersededCount+=1),r.activeUpdate=s,i.scheduler.acceptRevision(n),r.updateCount+=1,(void 0===e.protocolVersion||(r.protocol.applyVersion(e.protocolVersion,i.log),r.isCurrent(s)))&&(i.connection.markConnected()&&(i.a11y?.announceConnected(),i.emitter.emit("connect",{origin:t,timestamp:Date.now()}),!r.isCurrent(s)||(i.log("connection","disconnected","\\u2192","connected"),!r.isCurrent(s)))||this.processUpdate(s).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{message:r}=e,l={fields:i,...void 0!==e.schema?{schema:e.schema}:{},..."string"==typeof r.globalSlug?{globalSlug:r.globalSlug}:{},..."string"==typeof r.collectionSlug?{collectionSlug:r.collectionSlug}:{},...void 0!==e.locale?{locale:e.locale}:{}};if(t.emitter.listenerCount("beforeUpdate")>0&&(!await t.emitter.emitWhile("beforeUpdate",{data:l,revision:e.identity.revision,receivedAt:e.receivedAt,source:"patch",cancel:()=>{e.cancelled=!0,t.scheduler.cancelRevision(e.identity)}},()=>!e.cancelled&&n.isCurrent(e))||e.cancelled||!n.isCurrent(e)))return;let o=w(t.dependencies,t.cache.dependencyMap()),a=n.changes.diff(i,o);e.invalidated=a.invalidated,e.touched=new Set([...a.changed,...a.invalidated]),this.scheduleAllFields(e,l)}async resolveIncomingFields(e){let{deps:t,state:n}=this,i=e.message.data??{};if(null===t.merger||"admin"===E(n.protocol.observed).populatesRelationships)return i;let{message:r}=e,l=await t.merger.merge({collectionSlug:r.collectionSlug,globalSlug:r.globalSlug,data:i,locale:e.locale});return n.isCurrent(e)?"merged"===l.status?l.doc:"superseded"===l.status?null:i:null}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;if(void 0!==a&&!e.routeRefreshed&&(a.plan(n.root,o)||this.strategies.hasRouteBinding(o))){this.strategies.refreshRoute(e,t,a);return}let s=this.strategies.planFragments(o),u=n.skipUnchanged,d=0;for(let[o,a]of n.cache.entries()){if(!r())return;for(let c of a){if(!1!==l&&!D(c.owner,l))continue;if(!0===s?.covers(c)){n.revealEditedField&&this.noteRevealCandidate(e,c,this.rawValue(e,c,t));continue}let a=c.strategyKind??C(c.element)??"unknown";if("unknown"===a){this.strategies.warnUnsupportedStrategy(c);continue}"fragment"===a&&null===s&&this.strategies.warnFragmentFallback(c);let h=B(t.fields,o,c.locale??e.locale,void 0!==c.locale);if(void 0===h){i.absentFields.add(o);continue}if(this.noteRevealCandidate(e,c,h),!r())return;let f=this.transformForBinding(c,h,t.fields,r);if(!r())return;let p=u?Ce(c,f,t.fields,e.locale):void 0,g=i.lastAppliedIdentity.get(c.element);if(!e.forceRender&&n.skipUnchanged&&void 0!==p&&g===p&&!e.invalidated.has(o)){i.skippedUnchangedCount+=1;continue}let m={target:c,value:f,allFields:t.fields,identity:e.identity,data:t,valueIdentity:p};n.scheduler.schedule(m),d+=1}}(function(e,t,n,i){let{cache:r,warned:l,warn:o}=e;if(0===r.fieldCount||!1!==i&&!function(e,t){for(let n of e.values())if(D(n.owner,t))return!0;return!1}(r,i))return;let a;for(let[e,s]of Object.entries(t)){if(l.has(e)||Hn.has(e)||!G(s))continue;let t=q(e,n);H(r,e,i)||t!==e&&H(r,t,i)||(a??(a=z(r,i)),!a.has(e)&&(l.add(e),o(`[live-preview] LP0201: no <\\u2026 data-payload-field="${t}"> for field "${e}"; render the anchor unconditionally so edits to an empty field have somewhere to land.`)))}})({cache:n.cache,warned:i.warnedOrphanFields,warn:n.warn},t.fields,e.locale,l),null!==s&&s.boundaries.length>0&&(e.pendingFragments=s.boundaries.length,this.strategies.runFragments(e,t,s)),0===d&&0===e.pendingFragments&&(i.complete(e),this.revealPending(e))}rawValue(e,t,n){return B(n.fields,t.fieldName,t.locale??e.locale,void 0!==t.locale)}noteRevealCandidate(e,t,n){let{deps:i,state:r}=this;if(!i.revealEditedField)return;let l=m(n);if(void 0===l)return;let o=`${t.owner??""}\\0${t.locale??""}\\0${t.fieldName}`,a=r.seenFieldIdentity.get(o);void 0!==a?a!==l&&(e.revealIdentities.push([o,l]),e.revealTarget??(e.revealTarget=t)):r.seenFieldIdentity.set(o,l)}ownerKeysForUpdate(e,t){let{deps:n,state:i}=this;if(!n.scopeBindingsByOwner)return!1;let{message:r}=e,l=function(e){if(W(e.globalSlug))return[P(e.globalSlug)];if(!W(e.collectionSlug))return null;let t=j(e.collectionSlug);return W(e.documentId)?[t,j(e.collectionSlug,e.documentId)]:[t]}({globalSlug:"string"==typeof r.globalSlug?r.globalSlug:void 0,collectionSlug:"string"==typeof r.collectionSlug?r.collectionSlug:void 0,documentId:V(t)});return null===l&&!i.warnedUnattributableMessage&&(i.warnedUnattributableMessage=!0,n.warn("[live-preview] LP0202: scopeBindingsByOwner: update names no document; nothing applied")),l}transformForBinding(t,n,i,r){let l=this.deps.transformValue;if(void 0===l)return n;try{let o=l(t.fieldName,n,{element:t.element,allFields:i},r),a=e(o);if(!r())return n;if(a)throw new TypeError(`Transform for "${t.fieldName}" returned a thenable; transforms must be synchronous`);return o}catch(e){if(!r())return n;let t=e instanceof Error?e:new Error(String(e));return this.deps.emitter.emit("error",{error:t,context:"transform",code:"LP0602"}),n}}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{identity:i,data:r}=e;if(void 0===i)return;let l=n.activeUpdate;if(null===l||!n.isCurrent(l)||!b(l.identity,i))return;0===l.pendingFragments&&n.complete(l);let o=()=>n.isCurrent(l)&&b(l.identity,i);this.revealPending(l),o()&&(0===e.applied||void 0===r||(t.a11y?.announceUpdate(e.applied),o()&&(function(e,t){for(let n of e)n.dispatchEvent(new CustomEvent("payload-live-preview:update",{detail:t,bubbles:!1}));e.length}(t.cache.islands,{fields:r.fields,revision:i.revision,receivedAt:l.receivedAt,locale:l.locale}),o()&&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){for(let[t,n]of e.revealIdentities)this.state.seenFieldIdentity.set(t,n);e.revealIdentities=[];let t=e.revealTarget;if(void 0!==t){e.revealTarget=void 0;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)}},Si=class{constructor(e,t){wt(this,"apply");wt(this,"debounceMs");wt(this,"maxWaitMs");wt(this,"isVisible");wt(this,"gateThresholdValue");wt(this,"gateDisabled");wt(this,"getCacheSize");wt(this,"onFlush");wt(this,"scheduleFrame");wt(this,"cancelFrame");wt(this,"pending",new Map);wt(this,"replay",new Map);wt(this,"activeFlushes",new Set);wt(this,"debounceTimer",null);wt(this,"debounceToken",0);wt(this,"deadlineTimer",null);wt(this,"frameHandle",null);wt(this,"frameToken",0);wt(this,"activeIdentity",null);wt(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.identity&&(this.activeRevisionCancelled||!$e(e.identity,this.activeIdentity)))return;let t=this.pending.get(e.target.element);t?(t.value=e.value,t.allFields=e.allFields,t.identity=e.identity,t.data=e.data,t.valueIdentity=e.valueIdentity):this.pending.set(e.target.element,{target:e.target,value:e.value,allFields:e.allFields,identity:e.identity,data:e.data,valueIdentity:e.valueIdentity}),this.armDebounce()}acceptRevision(e){$e(e,this.activeIdentity)||null!==this.activeIdentity&&function(e,t){return e.generation!==t.generation?e.generation-t.generation:e.revision-t.revision}(e,this.activeIdentity)<0||(this.cancelScheduledWork(),this.clearWork(),this.activeIdentity=e,this.activeRevisionCancelled=!1)}cancelRevision(e){$e(e,this.activeIdentity)&&(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.activeIdentity=null,this.activeRevisionCancelled=!1}get pendingCount(){return this.pending.size}get replayCount(){return this.replay.size}get gateThreshold(){return this.gateThresholdValue}get gateActive(){return!this.gateDisabled&&this.getCacheSize()>this.gateThresholdValue}armDebounce(){let e=this.debounceToken+=1,t=this.debounceTimer;if(this.debounceTimer=null,null!==t&&clearTimeout(t),this.debounceToken!==e)return;let n=setTimeout(()=>{this.debounceToken===e&&(this.debounceTimer=null,this.requestFrame())},this.debounceMs);this.debounceToken===e&&(this.debounceTimer=n),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.identity||!this.activeRevisionCancelled&&$e(e.identity,this.activeIdentity)}didApply(e){return!1!==this.apply(e)||!function(e){return Kt.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?.identity?{identity:e.identity}:{},...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)}},ki=[0,500,1e3,2e3],Ti=class{constructor(e){wt(this,"deps");wt(this,"state",new nn);wt(this,"pipeline");wt(this,"writer");wt(this,"rootSentinel",null);wt(this,"observedRoot",null);let{emitter:i,renderers:r}=e,l=void 0===e.log?n:t(e.log),o=void 0===e.warn?Ft:t(e.warn),a=e.root??(typeof document<"u"?document:null),s=new xn({filter:e=>!function(e){let t=e;for(;null!==t;){if(k(t)&&!T(t))return!0;t=t.parentElement}return!1}(e)}),u=new Dn({onStructuralChange:()=>{this.rebuildCache()},onVisibilityChange:(e,t)=>{t&&d.notifyVisible(e)}},void 0!==e.intersectionRootMargin?{intersectionRootMargin:e.intersectionRootMargin}:{}),d=new Si(g(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=>u.isVisible(e),getCacheSize:()=>s.elementCount,onFlush:e=>{this.pipeline.onFlush(e)}}),c=new jn(e.originMatcher,{onUpdate:(e,t,n)=>{this.pipeline.handleUpdate(e,t,n)},onDocumentEvent:()=>{this.state.protocol.observe(["document-events"],l),i.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})`);i.emit("error",{error:e,context:"token",code:"LP0502"})}l("LP0501 message rejected:",e,t)},...void 0!==e.validateToken?{validateToken:e.validateToken}:{},...void 0!==e.eventSourcePolicy?{sourcePolicy:e.eventSourcePolicy}:{}}),h=e.dataMerge;this.deps={emitter:i,cache:s,observers:u,scheduler:d,bus:c,connection:new Bn,heartbeat:new Vn({...void 0!==e.heartbeatMs?{timeoutMs:e.heartbeatMs}:{},onTimeout:()=>{this.onHeartbeatTimeout()}}),renderers:r,resolveRenderer:e.resolveRenderer??(e=>r[e]),transformValue:e.transformValue,renderRichText:e.renderRichText,root:a,readyTargets:"function"==typeof e.readyTargets?e.readyTargets:(e=>()=>e)(e.readyTargets),sendReady:e.sendReady??Me,onHeartbeatTimeout:e.onHeartbeatTimeout,log:l,warn:o,a11y:Fe(e),merger:void 0===h?null:new En({serverURL:h.serverURL,...void 0!==h.apiRoute?{apiRoute:h.apiRoute}:{},...void 0!==h.depth?{depth:h.depth}:{},...void 0!==h.fetchFn?{fetchFn:h.fetchFn}:{},log:l}),scopeBindingsByOwner:!0===e.scopeBindingsByOwner,lockedOrigin:e.lockedOrigin??(()=>{}),skipUnchanged:!0===e.skipUnchanged,dependencies:e.dependencies??{},strategies:e.strategies??{},revealEditedField:!0===e.revealEditedField},this.writer=new rn(this.deps,this.state),this.pipeline=new wi(this.deps,this.state,()=>{this.rebuildCache()})}start(){let{state:e,deps:t}=this;if(e.isRunning())return!1;if(e.started=!0,e.suspended=!1,Re(t.root)&&"loading"===t.root.readyState){let n=()=>{if(e.isRunning()){e.deferredStart=null;try{this.startNow()}catch(e){this.rollbackFailedStart(),this.reportError(e,"startup","LP0605")}}};e.deferredStart=n;try{t.root.addEventListener("DOMContentLoaded",n,{once:!0})}catch(e){throw this.rollbackFailedStart(),e}return!0}try{return this.startNow(),!0}catch(e){throw this.rollbackFailedStart(),e}}startNow(){let{state:e,deps:t}=this;if(!e.isRunning())return;let n=Re(t.root)?Ne(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 ki){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&&Re(t.root)&&this.runCleanup(()=>{t.root.removeEventListener("DOMContentLoaded",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()}),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;!Re(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()||!Re(e))return!1;let t=Ne(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;for(let[e,t]of n.entries()){a.push(e);for(let e of t)void 0!==e.owner&&s.add(e.owner)}return{version:In,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:E(r.observed).name},revisions:{accepted:t.updateCount,superseded:t.supersededCount,completed:t.completedCount,skippedUnchanged:t.skippedUnchangedCount,active:null===l?void 0:l.identity.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()},route:{handler:void 0!==e.strategies.route,...t.routeStats},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.identity),t.merger?.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}},Ai=/^https?:\\/\\/(localhost|127\\.0\\.0\\.1)(?::\\d+)?$/i,Ci=/^https?:\\/\\/[^/?#\\s]+$/i,$i=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],Fi=class{constructor(e={}){Tt(this,Ri);let t=new Set;for(let n of e.additionalOrigins??[]){let e=Ee(n);void 0!==e&&t.add(e)}let n;if(e.enableReferrerDetection??1){let t=e.referrer??(typeof 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(!(typeof process>"u"))return"production"}();if(void 0!==e)return"production"!==e;if(typeof window<"u"){let e=window.location.hostname;return"localhost"===e||"127.0.0.1"===e}return!1}());At(this,Ri,[t,n,i,void 0!==n,void 0])}matches(e){return 0!==e.length&&"null"!==e&&(void 0!==kt(this,Ri)[4]?e===kt(this,Ri)[4]:!!(kt(this,Ri)[0].has(e)||0===kt(this,Ri)[0].size&&void 0!==kt(this,Ri)[1]&&e===kt(this,Ri)[1]||kt(this,Ri)[2]&&Ai.test(e)))}lockOrigin(e){return!!this.matches(e)&&(kt(this,Ri)[4]=e,!0)}unlockOrigin(){let e=kt(this,Ri)[4];return kt(this,Ri)[4]=void 0,e}get lockedOrigin(){return kt(this,Ri)[4]}enumerate(){if(void 0!==kt(this,Ri)[4])return[kt(this,Ri)[4]];let e=new Set(kt(this,Ri)[0]);if(0===kt(this,Ri)[0].size&&void 0!==kt(this,Ri)[1]&&e.add(kt(this,Ri)[1]),kt(this,Ri)[2])for(let t of $i)e.add(`http://localhost:${String(t)}`),e.add(`http://127.0.0.1:${String(t)}`);return[...e]}get referrerWasAvailable(){return kt(this,Ri)[3]}get isProductionUnconfigured(){return!(!xe()||kt(this,Ri)[0].size>0||kt(this,Ri)[2]||void 0!==kt(this,Ri)[1])}get isReferrerOnlyTrust(){return!(kt(this,Ri)[0].size>0||kt(this,Ri)[2])&&void 0!==kt(this,Ri)[1]}},Ri=new WeakMap,Ni={1:"left",2:"center",3:"right",4:"justify"},Mi=new Set(["left","center","right","justify","start","end"]),xi=new Set(["h1","h2","h3","h4","h5","h6"]),Ei=\' target="_blank" rel="noopener noreferrer"\',Ii=(e,t)=>{let n=t.renderChildren(e.children??[]),i=Pe(e.fields),r=function(e,t){if("internal"===t?.linkType)return function(e){let t=Pe(Pe(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||!f(r))return n;let l="string"==typeof e.title?` title="${oe(e.title)}"`:"";return`<a href="${ae(r)}"${function(e,t,n){if(!0===t?.newTab||p(n))return Ei;let i="string"==typeof e.target?e.target:"";return""===i?"":"_blank"===i?Ei:` target="${oe(i)}"`}(e,i,r)}${l}>${n}</a>`},Li=new Map,Oi={text:e=>{let t=oe("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${Oe(e)}${Ue(e)}>${n}</p>`},heading:(e,t)=>{let n="string"==typeof e.tag?e.tag.toLowerCase():"h2",i=xi.has(n)?n:"h2",r=t.renderChildren(e.children??[]);return`<${i}${Oe(e)}${Ue(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}${Oe(e)}${Ue(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"}"${Ue(e)}>${n}</li>`;let i="number"==typeof e.value?` value="${oe(String(e.value))}"`:"";return`<li${Oe(e)}${Ue(e)}${i}>${n}</li>`},link:Ii,autolink:Ii,quote:(e,t)=>{let n=t.renderChildren(e.children??[]);return`<blockquote${Oe(e)}${Ue(e)}>${n}</blockquote>`},code:e=>{let t=We("string"==typeof e.language?e.language:"");return`<pre><code${""===t?"":` class="language-${t}"`}>${oe(Be(e))}</code></pre>`},"code-highlight":e=>{let t="string"==typeof e.text?e.text:"";return`<span${"string"==typeof e.highlightType?` class="token-${We(e.highlightType)}"`:""}>${oe(t)}</span>`},linebreak:()=>"<br>",horizontalrule:()=>"<hr>",tab:()=>"\\t",upload:e=>{let t=je(e.value);if(void 0===t)return"";let n=t.url;if("string"!=typeof n||!f(n))return"";let i="string"==typeof t.mimeType?t.mimeType:"";return i.startsWith("video/")?function(e,t){return`<video controls${_e(e)}><source src="${ae(t)}"${He(e)}></video>`}(t,n):i.startsWith("audio/")?function(e,t){return`<audio controls><source src="${ae(t)}"${He(e)}></audio>`}(t,n):""===i||i.startsWith("image/")?function(e,t){let n="string"==typeof e.alt?oe(e.alt):"";return`<img src="${ae(t)}" alt="${n}"${_e(e)} loading="lazy" decoding="async">`}(t,n):function(e,t){let n="string"==typeof e.filename?oe(e.filename):oe(t);return`<a href="${ae(t)}" target="_blank" rel="noopener noreferrer">${n}</a>`}(t,n)},relationship:e=>{let t="string"==typeof e.relationTo?e.relationTo:"",n=Pe(e.value),i=oe((n&&Ve(n))??`#${t}`),r=We(t),l=""===r?\' class="lp-relation"\':` class="lp-relation lp-relation--${r}"`,o=n?.url;return"string"==typeof o&&f(o)?`<a href="${ae(o)}"${l}>${i}</a>`:`<span${l}>${i}</span>`},block:(e,t)=>Ge(e,t,"div","lp-block"),inlineBlock:(e,t)=>Ge(e,t,"span","lp-inline-block"),table:(e,t)=>`<table${Oe(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"\':""}${qe("colspan",e.colSpan)}${qe("rowspan",e.rowSpan)}>${t.renderChildren(e.children??[])}</${i}>`}},Ui=new Map,Pi={renderChildren:Ke,resolveAlignment:Ie,resolveIndent:Le},ji=!1,Wi="data-payload-text",Di={name:"richText",render:g((e,t,n)=>{let i=e.element;if(de(t))i.textContent="";else{if(void 0!==n.renderRichText){let r=n.renderRichText(t,{fieldName:e.fieldName,element:i,locale:n.locale});i.innerHTML=J(te(r));return}if(Je(t))i.innerHTML=J(function(e,t={}){if(!Je(e))return"";let n=Ke(e.root.children);return!1===t.sanitize?n:void 0!==ne()?te(n):(function(){if(!ji){ji=!0;try{console.warn("[live-preview] lexicalToHtml() has no sanitizer document and returned unsanitised HTML; call setSanitizerDocument() (linkedom/jsdom) for server rendering, see docs/security.md \\xa73.")}catch{}}}(),n)}(t));else{if("string"!=typeof t)return!1;i.innerHTML=J(te(t))}}})},Vi={name:"html",render(e,t){if(de(t)){e.element.textContent="";return}let n="string"==typeof t?t:ue(t);e.element.innerHTML=J(te(n))}},Bi=new WeakSet,_i=et("url"),Hi=/^[a-zA-Z][a-zA-Z0-9+.-]*:/,zi=et("email",function(e){let t=e.trim();return Hi.test(t)||!t.includes("@")?t:`mailto:${t}`}),Gi=["src","srcset","sizes"],qi={name:"image",render:g((e,t,n)=>{let i=e.element;if(de(t)){rt(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?B(n.allFields,e.srcField,n.locale,i):t,l=je(r);return{media:l,candidate:void 0===l?r:l.url}}(e,t,n,r),a=Ye(i,e.fieldName,o);if("none"===a.kind)return!1;if("unsafe"!==a.kind){if("IMG"===i.tagName){let t=i;nt(t,a.url,l);let o=function(e,t,n,i,r){if(void 0!==t&&t.length>0){let e=B(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 rt(i)})},Ji={name:"upload",render:g((e,t)=>{let n=e.element;if(de(t)){lt(n);return}let i=je(t);if(void 0===i)return!1;let r=Ye(n,e.fieldName,i.url);if("none"===r.kind)return!1;if("unsafe"===r.kind){lt(n);return}let l=r.url;if("IMG"===n.tagName){let e=n;nt(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=oe(i.filename??l);n.innerHTML=J(`<a href="${ae(l)}">${o}</a>`)})},Ki={name:"relationship",render(e,t){let n=e.element;if(de(t))n.removeAttribute("href"),n.textContent="";else{if("A"===n.tagName&&!Array.isArray(t)){let i=Ye(n,e.fieldName,Pe(t)?.url);"safe"===i.kind?n.setAttribute("href",i.url):"unsafe"===i.kind&&n.removeAttribute("href")}n.textContent=Array.isArray(t)?t.map(ot).join(", "):ot(t)}}},Qi={name:"select",render(e,t,n){let i=e.element,r=de(t)?[]:function(e){return Array.isArray(e)?e.map(ue):[ue(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=Pe(t);if(void 0!==n&&ue(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)}},Xi=new Set(["","false","0","off","no"]),Zi={name:"checkbox",render(e,t){let n=e.element,i=function(e){return"boolean"==typeof e?e:"string"==typeof e?!Xi.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}},Yi=new Map,er=new Map,tr=64,nr={name:"date",render(e,t,n){let r=e.element;if(de(t)){"INPUT"===r.tagName?r.value="":(r.removeAttribute("datetime"),r.textContent="");return}let l="number"==typeof t?t:ue(t),o=new Date(l),a=!Number.isNaN(o.getTime()),s=String(l);"INPUT"!==r.tagName?("TIME"===r.tagName&&r.setAttribute("datetime",a?o.toISOString():s),r.textContent=a?function(e,t){let n=t.locale??i();try{return function(e,t){let n=at(e,t),i=er.get(n);if(void 0!==i)return er.delete(n),er.set(n,i),i;let r=new Intl.DateTimeFormat(e,t);return er.set(n,r),ut(er),r}(n,{dateStyle:"medium",timeStyle:"short"}).format(e)}catch{return e.toISOString()}}(o,n):s):r.value=a?function(e,t){let n=`${String(t.getFullYear()).padStart(4,"0")}-${dt(t.getMonth()+1)}-${dt(t.getDate())}`,i=`${dt(t.getHours())}:${dt(t.getMinutes())}`;return"date"===e?n:"datetime-local"===e?`${n}T${i}`:"time"===e?i:t.toISOString()}(r.type,o):s}},ir={name:"number",render(e,t,n){let r=e.element;if(de(t)){"INPUT"===r.tagName?r.value="":r.textContent="";return}let l="number"==typeof t?t:Number(ue(t));Number.isNaN(l)?r.textContent=ue(t):"INPUT"!==r.tagName?r.textContent=function(e,t){let n=t.locale??i();try{return function(e,t){let n=at(e,t),i=Yi.get(n);if(void 0!==i)return Yi.delete(n),Yi.set(n,i),i;let r=new Intl.NumberFormat(e,t);return Yi.set(n,r),ut(Yi),r}(n).format(e)}catch{return String(e)}}(l,n):r.value=String(l)}},rr={name:"array",render:g((e,t)=>{let n=e.element;if(de(t)){n.textContent="";return}if(!Array.isArray(t))return!1;let i=e.arrayTemplate;if(void 0!==i&&i.length>0){let e=function(e,t){let n="";for(let i=0;i<t.length;i+=1)n+=se(e,t[i],i,ue);return n}(i,t);n.innerHTML=J(te(e,ce(i)));return}n.textContent=t.map(ue).join(e.arraySeparator??", ")})},lr=new Map;!function(){if(typeof window>"u"||!xe()&&(typeof window>"u"||null==window.opener))return;let e=window.__livePreview,t=JSON.stringify(mt());if(void 0!==e&&(void 0===e.configSignature||e.configSignature===t))return e.refresh(),e;let[n=[],i="",r="/api",l=1,o=!1,a=50,s=!0,u=0,d=!1,c=50,h="200px",f=!0,p=!1,g=!1,m=!0,v="parent-or-opener",y="strict",b,w=!1]=mt(),S=typeof __LIVE_PREVIEW_FRAGMENT__<"u"&&"string"==typeof b&&b.length>0?{fragment:__LIVE_PREVIEW_FRAGMENT__.createFragmentStrategy({endpoint:b}),route:__LIVE_PREVIEW_FRAGMENT__.createRouteStrategy()}:void 0;!function(e){oi=e}(y);let k=new Fi({additionalOrigins:n,enableReferrerDetection:!f,enableLocalhostMatching:!p});k.isProductionUnconfigured?Ft("[live-preview] LP0101: No trusted origin. Pass allowedOrigins to generateInlineScript() (or to the adapter) \\u2014 the runtime reads no environment variable in the browser."):k.isReferrerOnlyTrust&&Ft("[live-preview] LP0102: document.referrer fallback trusts any framing site. Set allowedOrigins and a frame-ancestors CSP in production.");let T=new Nt,A=function(){let e=[Di,Vi,_i,zi,qi,Ji,Ki,Qi,{...Qi,name:"radio"},Zi,nr,ir,rr,{...rr,name:"blocks"}];return function(e=[]){let t={};for(let n of e)t[n.name]=n;for(let[e,n]of lr)t[e]=n;return Object.freeze(t)}([Ze("text"),Ze("textarea"),...e,ct()])}(),C=new Ti({renderers:A,originMatcher:e=>k.matches(e),lockedOrigin:()=>k.lockedOrigin,readyTargets:()=>k.enumerate(),emitter:T,eventSourcePolicy:v,...""!==i?{dataMerge:{serverURL:i,apiRoute:r,depth:l}}:{},debounceMs:a,heartbeatMs:u,intersectionRootMargin:h,disableVisibilityGate:d,visibilityGateThreshold:c,enableA11y:s,scopeBindingsByOwner:g,skipUnchanged:m,revealEditedField:w,...void 0!==S?{strategies:S}:{},onHeartbeatTimeout:()=>{k.unlockOrigin()},...o?{log:(...e)=>{Rt("[live-preview]",...e)}}:{}});T.on("connect",e=>{k.lockOrigin(e.origin)}),C.start(),e?.destroy();let $=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:()=>C.suspend(),resume:()=>C.start(),refreshCache:()=>{C.refreshCache()}}),F=Object.freeze({version:In,configSignature:t,destroy:()=>{$(),C.destroy();let e=window;e.__livePreview===F&&delete e.__livePreview},refresh:()=>{C.refreshCache()},enumerateOrigins:()=>k.enumerate(),inspect:()=>C.inspect()});try{Object.defineProperty(window,"__livePreview",{value:F,writable:!1,configurable:!0})}catch(e){throw $(),C.destroy(),e}}()})();',Gi={generatedAt:"2026-09-04T21:17:52.000Z",size:93041},Ji='"use strict";var __LIVE_PREVIEW_FRAGMENT__=(()=>{var N=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var Z=Object.prototype.hasOwnProperty;var ee=(e,n)=>{for(var t in n)N(e,t,{get:n[t],enumerable:!0})},ne=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Q(n))!Z.call(e,r)&&r!==t&&N(e,r,{get:()=>n[r],enumerable:!(o=J(n,r))||o.enumerable});return e};var te=e=>ne(N({},"__esModule",{value:!0}),e);var De={};ee(De,{createFragmentStrategy:()=>z,createRouteStrategy:()=>X});var R="data-payload-island",Pe=`astro-island, [${R}]`;function re(e){return e.tagName.toLowerCase()==="astro-island"||e.hasAttribute(R)}function oe(e){return e.getAttribute(R)==="patch"}function _(e){let n=e;for(;n!==null;){if(re(n)&&!oe(n))return!0;n=n.parentElement}return!1}function w(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 b="data-payload-fragment";var D="data-payload-fragment-key",ae="data-payload-depends";function M(e){let n=e.getAttribute(b);if(n===null||n.length===0)return null;let t=e.getAttribute(D);return{element:e,id:n,key:t===null||t.length===0?void 0:t,dependsOn:w(e.getAttribute(ae))}}function L(e,n){let t=[];for(let o of e.querySelectorAll(`[${b}]`)){let r=M(o);r===null||_(o)||r.dependsOn.length>0&&!r.dependsOn.some(a=>n.has(a))||t.push(r)}return t}var B="x-payload-fragment-version";function v(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function C(e){if(!v(e))return null;let{html:n,boundary:t,revision:o,metadata:r}=e;return typeof n!="string"||!v(t)||typeof t.id!="string"||t.key!==void 0&&typeof t.key!="string"||typeof o!="number"||!v(r)||typeof r.renderedAt!="string"||typeof r.renderer!="string"?null:e}function U(e){let n={};for(let[t,o]of Object.entries(e))o!==void 0&&(n[t]=o);return n}function H(e){let n=0,t=[],o=()=>{let r=t.shift();r===void 0?n-=1:r()};return async r=>{n<e?n+=1:await new Promise(a=>{t.push(a)});try{return await r()}finally{o()}}}var le=5e3,se=4,de=512*1024,A={status:"superseded"};function h(e,n){return{status:"failed",code:e,reason:n}}function ue(e){return e instanceof Error?e.message:String(e)}function ce(e){let n=()=>{throw new TypeError(\'createFragmentStrategy: endpoint must be a same-origin path starting with "/"\')};if((typeof e!="string"||!e.startsWith("/")||e.startsWith("//")||e.includes("\\\\"))&&n(),typeof location<"u"){let t;try{t=new URL(e,location.href)}catch{t=void 0}t?.origin!==location.origin&&n()}return e}function fe(e){return typeof e=="object"&&e!==null&&typeof e.getReader=="function"}async function me(e,n,t){let o=e.body;if(!fe(o)){let s=await e.text();return new TextEncoder().encode(s).byteLength>n?null:s}let r=o.getReader(),a=()=>{r.cancel().catch(()=>{})};t.addEventListener("abort",a,{once:!0});let l=new TextDecoder,i="",u=0;try{for(;;){let{done:s,value:y}=await r.read();if(s)break;if(u+=y.byteLength,u>n)return a(),null;i+=l.decode(y,{stream:!0})}}finally{t.removeEventListener("abort",a)}return i+l.decode()}function K(e){let n=ce(e.endpoint),t=e.timeoutMs??le,o=e.maxResponseBytes??de,r=H(Math.max(1,e.maxConcurrent??se)),a=new Map;async function l(i,u){let s=()=>i.signal.aborted;if(s())return A;let y=e.location??location,m=U({fragment:u.id,key:u.key,route:y.pathname,search:y.search,revision:i.revision,locale:i.locale,collectionSlug:i.collectionSlug,globalSlug:i.globalSlug,fields:i.fields}),d=new AbortController,f=()=>{d.abort()};i.signal.addEventListener("abort",f,{once:!0});let g={timedOut:!1},E=setTimeout(()=>{g.timedOut=!0,d.abort()},t),c=p=>s()?A:g.timedOut?h("LP0801",`timeout after ${String(t)} ms`):h("LP0801",ue(p));try{let p;try{p=await(e.fetch??fetch)(n,{method:"POST",credentials:"same-origin",headers:{...e.headers,accept:"application/json","content-type":"application/json",[B]:String(1)},body:JSON.stringify(m),signal:d.signal})}catch(O){return c(O)}if(s())return A;if(p.status===401||p.status===403)return h("LP0803",`endpoint refused the preview (${String(p.status)})`);if(!p.ok)return h("LP0801",`endpoint answered ${String(p.status)}`);let T=p.headers.get("content-type")??"";if(!T.toLowerCase().startsWith("application/json"))return h("LP0802",`unexpected content type "${T}"`);if(Number(p.headers.get("content-length")??"0")>o)return h("LP0802","response exceeds the size limit");let k;try{k=await me(p,o,d.signal)}catch(O){return c(O)}if(s())return A;if(g.timedOut)return h("LP0801",`timeout after ${String(t)} ms`);if(k===null)return h("LP0802","response exceeds the size limit");let I;try{I=JSON.parse(k)}catch{return h("LP0802","response is not JSON")}let S=C(I);return S===null?h("LP0802","response has the wrong shape"):S.boundary.id!==u.id?h("LP0802","response is for another boundary"):S.revision!==i.revision?A:{status:"rendered",html:S.html,metadata:S.metadata}}finally{clearTimeout(E),i.signal.removeEventListener("abort",f)}}return(i,u)=>{let s=`${u.id} ${u.key??""} ${String(i.revision)}`,y=a.get(s);if(y!==void 0)return y;let m=r(()=>l(i,u));a.set(s,m);let d=()=>{a.get(s)===m&&a.delete(s)};return m.then(d,d),m}}var F="data-payload-owned",ye=new Set(["open","value","checked","selected"]);function q(e,n){for(let t of n.keyAttributes){let o=e.getAttribute(t);if(o!==null&&o.length>0)return`${t}=${o}`}}function x(e){if(e.tagName.toLowerCase().includes("-")||e.hasAttribute(R)||e.hasAttribute(F))return!0;let n=e.getAttribute("contenteditable");return n!==null&&n!=="false"}function ge(e,n){return e.tagName===n.tagName&&e.namespaceURI===n.namespaceURI&&!x(e)&&!x(n)}function P(e,n,t){if(!ge(e,n))return n;let o=Se(e);return pe(e,n),t.retainChildrenOf?.(e,n)!==!0&&he(e,n,t),Re(o),e}function pe(e,n){for(let t of Array.from(e.attributes))n.hasAttribute(t.name)||ye.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 he(e,n,t){let o=be(e,t),r=new Set(o.values()),a=Array.from(e.childNodes).filter(m=>!r.has(m)),l=new Set,i=new Set,u=Array.from(n.childNodes),s=e.firstChild,y=0;for(let m=0;m<u.length;m+=1){let d=u[m],f=null,g=d instanceof Element?q(d,t):void 0;if(g!==void 0&&i.has(g)&&(g=void 0),g!==void 0){i.add(g);let c=o.get(g);if(c!==void 0&&!l.has(c)&&(f=$(c,d,t)===c?c:null,f===null)){c.replaceWith(d),l.add(d),s=d.nextSibling;continue}}else{for(;y<a.length;){let c=a[y];if(y+=1,!l.has(c)){if(G(c,d)){f=$(c,d,t)===c?c:null,f===null&&(e.replaceChild(d,c),l.add(d),s=d.nextSibling);break}if(c instanceof Element){let p=u[m+1];if(!(d instanceof Element)||p!==void 0&&G(c,p)){y-=1;break}e.replaceChild(d,c),l.add(d),s=d.nextSibling;break}if(!(d instanceof Element)){e.replaceChild(d,c),l.add(d),s=d.nextSibling;break}}}if(f===null&&l.has(d))continue}let E=f??d;for(l.add(E);s!==null&&s!==E&&!l.has(s)&&Ee(s);)s=s.nextSibling;E!==s&&e.insertBefore(E,s),s=E.nextSibling}for(let m of Array.from(e.childNodes))l.has(m)||m.remove()}function $(e,n,t){return e instanceof Element&&n instanceof Element?x(e)&&x(n)?e:P(e,n,t):(e.nodeValue!==n.nodeValue&&(e.nodeValue=n.nodeValue),e)}function Ee(e){return e.nodeType===Node.TEXT_NODE&&(e.nodeValue??"").trim().length===0}function G(e,n){return e.nodeType!==n.nodeType?!1:e instanceof Element&&n instanceof Element?e.tagName===n.tagName&&e.namespaceURI===n.namespaceURI:!0}function be(e,n){let t=new Map,o;for(let r of Array.from(e.children)){let a=q(r,n);if(a!==void 0){if(t.has(a)){o??(o=a.slice(a.indexOf("=")+1));continue}t.set(a,r)}}return o!==void 0&&n.onDuplicateKey?.(e,o),t}function Se(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 Re(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 V="data-payload-key";var W="data-payload-strategy",Y="data-payload-field",Ae="data-payload-depends",Te="x-payload-live-preview",we=8e3,xe=1e3;function Fe(e){let n=e.getAttribute(W);return n!==null?n==="route":e.closest("head")!==null}function ke(e){let n=e.getAttribute(Y),t=w(e.getAttribute(Ae));return n===null||n.length===0?t:[n,...t]}function j(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 Oe(e,n){n.title!==e.title&&(e.title=n.title);let t=new Map;for(let r of e.head.querySelectorAll("meta, link")){let a=j(r);a!==null&&!t.has(a)&&t.set(a,r)}let o=new Set;for(let r of n.head.querySelectorAll("meta, link")){let a=j(r);if(a===null)continue;o.add(a);let l=t.get(a);if(l===void 0){e.head.append(e.importNode(r,!0));continue}if(!l.hasAttribute(F))for(let i of Array.from(r.attributes))l.getAttribute(i.name)!==i.value&&l.setAttribute(i.name,i.value)}for(let[r,a]of t)!o.has(r)&&!a.hasAttribute(F)&&a.remove()}function X(e={}){let n=e.timeoutMs??we,t=e.minIntervalMs??xe,o=-1/0;return{plan(r,a){for(let l of r.querySelectorAll(`[${Y}], [${W}="route"]`)){if(!Fe(l))continue;let i=ke(l);if(i.length===0||i.some(u=>a.has(u)))return!0}return!1},async refresh(r){let a=Date.now();if(a-o<t)return r.log("LP0805",`route refresh for revision ${String(r.revision)} refused: the previous one was ${String(a-o)} ms ago`),"failed";o=a;let l=e.document??document,i=e.location??location,u=e.window??window,s=new AbortController,y=()=>{s.abort()};r.signal.addEventListener("abort",y,{once:!0});let m=setTimeout(()=>{s.abort()},n),d=f=>r.signal.aborted?"superseded":(r.log("LP0801",f instanceof Error?f.message:String(f)),"failed");try{let f;try{f=await(e.fetch??fetch)(i.href,{method:"GET",credentials:"same-origin",cache:"no-store",headers:{accept:"text/html",[Te]:"route"},signal:s.signal})}catch(g){return d(g)}if(r.signal.aborted)return"superseded";if(!f.ok||!(f.headers.get("content-type")??"").includes("text/html"))return r.log("LP0802",`route answered ${String(f.status)} ${f.headers.get("content-type")??""}`),"failed";try{let g=await f.text();if(!r.isCurrent())return"superseded";let E=new DOMParser().parseFromString(g,"text/html"),c=u.scrollX,p=u.scrollY;return Oe(l,E),P(l.body,E.body,{keyAttributes:[V,D,b],retainChildrenOf:T=>T.hasAttribute(b)}),u.scrollTo(c,p),"refreshed"}catch(g){return d(g)}}finally{clearTimeout(m),r.signal.removeEventListener("abort",y)}}}}function Ne(e){return{plan:(n,t)=>L(n,t).map(o=>o.element),async render(n,t){let o={rendered:0,failed:0,superseded:0},r={revision:n.revision,receivedAt:n.receivedAt,fields:n.fields,locale:n.locale,collectionSlug:n.collectionSlug,globalSlug:n.globalSlug,signal:n.signal};return await Promise.all(t.map(async a=>{let l=M(a);if(l===null)return;let i;try{i=await e(r,l)}catch(u){i={status:"failed",code:"LP0801",reason:u instanceof Error?u.message:String(u)}}if(!n.isCurrent()||i.status==="superseded"){o.superseded+=1,n.log("LP0804",`fragment "${l.id}" for revision ${String(r.revision)} discarded as superseded`);return}if(i.status==="rendered"){n.morph(a,i.html),n.rendered(a,l.id,l.key),o.rendered+=1;return}n.failed(a,l.id,l.key,i.code,i.reason),n.isCurrent()&&n.patch(a),o.failed+=1})),o}}}function z(e){return Ne(K(e))}return te(De);})();',Ki=["allowedOrigins","serverURL","apiRoute","mergeDepth","debug","debounceMs","enableA11y","heartbeatMs","disableVisibilityGate","visibilityGateThreshold","intersectionRootMargin","disableReferrerDetection","disableLocalhostMatching","scopeBindingsByOwner","skipUnchanged","eventSourcePolicy","sanitizerPolicy","fragmentEndpoint","revealEditedField"];function Qi(e,t){if(0===e.length)throw new Error(`[live-preview] ${t} is empty. Run \`npm run build:runtime\` before bundling.`)}function generateInlineScript(e={}){return Qi(qi,"runtime.generated.ts"),[Zi(e),...Xi(e),qi].join("\n")}function Xi(e){return null==e.fragmentEndpoint?[]:(Qi(Ji,"fragment.generated.ts"),[Ji])}function Zi(e){return`var __LIVE_PREVIEW_CONFIG__=${function(e){if("v1"!==e.defaults&&""!==(e.serverURL??"")&&null==e.mergeDepth)throw new Error("payload-live-preview: `serverURL` needs an explicit `mergeDepth` under the 2.0 defaults — choose the population depth deliberately (0 for none), or pass `defaults: 'v1'` to keep the 1.x default of 1 while migrating (ADR 0007, entry 10).");const t=Ki.map(t=>e[t]??void 0);for(;t.length>0&&void 0===t.at(-1);)t.pop();return`[${t.map(e=>void 0===e?"":JSON.stringify(e)).join(",")}]`.replace(/</g,"\\u003C")}(e)};`}function Yi(e,t={}){return`<script${void 0!==t.nonce?` nonce="${function(e){if(!/^[A-Za-z0-9+/=_-]+$/.test(e))throw new RangeError("wrapWithScriptTag: nonce contains invalid characters");return e}(t.nonce)}"`:""}>${e}<\/script>`}function er(){return Gi}var tr,nr=/[\t\n\f\r ]+/;function ir(e,t){const n=e.charCodeAt(t);return 9===n||10===n||12===n||13===n||32===n}function rr(e){let t=0,n=e.length;for(;t<n&&ir(e,t);)t+=1;for(;n>t&&ir(e,n-1);)n-=1;return 0===t&&n===e.length?e:e.slice(t,n)}function or(e){return e.replace(/[A-Z]/g,e=>e.toLowerCase())}function setCspCrypto(e){tr=e??void 0}function generateCspNonce(e=16){if(!Number.isInteger(e)||e<8)throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(e)}`);const t=function(){if(tr?.getRandomValues)return tr;const e=globalThis.crypto;return e?.getRandomValues?e:void 0}();if(!t)throw new Error("generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) once at startup, or run with --experimental-global-webcrypto. We won't fabricate a predictable nonce — that would silently defeat the entire CSP.");const n=new Uint8Array(e);return t.getRandomValues(n),function(e){let t="";for(const n of e)t+=String.fromCharCode(n);return("function"==typeof btoa?btoa(t):Buffer.from(e).toString("base64")).replaceAll("+","-").replaceAll("/","_").replaceAll("=","")}(n)}function buildFrameAncestors(e={}){const{self:t=!0,origins:n=[],allowNone:i=!1}=e,r=/* @__PURE__ */new Set,o=[];if(i&&!t&&0===n.length)return"'none'";t&&(o.push("'self'"),r.add("'self'"));for(const e of n){const t=e.trim();0===t.length||r.has(t)||(r.add(t),o.push(t))}return o.length>0?o.join(" "):"'none'"}function buildScriptSrcWithNonce(e,t={}){if(0===e.length)throw new RangeError("buildScriptSrcWithNonce: nonce is empty");const{self:n=!0,extra:i=[],strictDynamic:r=!1}=t,o=[];n&&o.push("'self'"),o.push(`'nonce-${e}'`),r&&o.push("'strict-dynamic'");for(const e of i){const t=e.trim();t.length>0&&o.push(t)}return o.join(" ")}function sr(e,t){const n=e.split(",").filter(e=>e.trim().length>0);return 0===n.length?ar("",t):n.map(e=>ar(e,t)).join(", ")}function ar(e,t){const n=/* @__PURE__ */new Map;for(const t of e.split(";")){const e=rr(t);if(0===e.length)continue;const i=e.search(nr),r=or(i<0?e:e.slice(0,i));if(n.has(r))continue;const o=i<0?"":rr(e.slice(i));n.set(r,o)}for(const[e,i]of Object.entries(t)){const t=or(e),r="string"==typeof i?{value:i}:i,o=r.mode??"union",s=n.get(t);if("replace"===o||void 0===s||0===s.length){n.set(t,r.value);continue}const a=/* @__PURE__ */new Set,l=[];for(const e of[...s.split(nr),...r.value.split(nr)])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 i=[];for(const[e,t]of n)i.push(0===t.length?e:`${e} ${t}`);return i.join("; ")}var lr="payload-live-preview.authorized-preview-context",ur=Symbol.for(lr);function isAuthorizedPreviewContext(e){return"object"==typeof e&&null!==e&&!0===e[ur]&&Object.isFrozen(e)}function dr(e){return Object.freeze({...e,scope:Object.freeze({...e.scope}),payloadHeaders:Object.freeze({...e.payloadHeaders}),[ur]:!0,[lr]:!0})}var cr=class extends Error{name="PreviewConfigurationError"};function hr(e){return{authorized:!1,outcome:e,context:null}}var fr="users",pr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,gr=/^[A-Za-z0-9._~-]+$/;var mr,vr="live-preview",yr="v1";function br(){return mr??=new TextEncoder,mr}function wr(e){const t="string"==typeof e?br().encode(e):e;if(t.byteLength<32)throw new cr(`payload-live-preview: the preview token secret must be at least ${String(32)} bytes`);return t}function Sr(e){if(void 0!==e)return e;const t=globalThis.crypto;return"object"==typeof t?.subtle?t:void 0}async function kr(e,t){return e.subtle.importKey("raw",t,{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}function Ar(e){let t="";for(const n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Tr(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}}async function Cr(e,t){const n=Sr(t.crypto);if(void 0===n)throw new Error("payload-live-preview: no Web Crypto implementation available to sign tokens");const i=wr(t.secret),r=(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??vr,iat:r,exp:r+o,jti:Ar(s)},l=Ar(br().encode(JSON.stringify(a))),u=`${yr}.${l}`,d=await kr(n,i);return`${u}.${Ar(new Uint8Array(await n.subtle.sign("HMAC",d,br().encode(u))))}`}async function $r(e,t){switch(t.type){case"payload-session":return async function(e,t){const n=function(e){const t=e??"payload-token";if(!pr.test(t))throw new cr(`payload-live-preview: cookie name "${t}" is not a valid cookie-name token`);return t}(t.cookieName),i=function(e){let t;try{t=new URL(e)}catch{throw new cr(`payload-live-preview: serverURL "${e}" is not an absolute URL`)}if("https:"!==t.protocol&&"http:"!==t.protocol)throw new cr(`payload-live-preview: serverURL must be http(s), got "${t.protocol}"`);return t.origin}(t.serverURL),r=function(e,t,n=4096){if(null===e||0===e.length)return null;const i=`${t}=`,r=[];for(const t of e.split(";")){const e=t.trim();e.startsWith(i)&&r.push(e.slice(i.length))}if(1!==r.length)return null;const o=r[0]??"";return 0===o.length||o.length>n||!gr.test(o)?null:o}(e.headers.get("cookie"),n,t.maxCookieLength??4096);if(null===r)return hr("missing-credential");const o=t.now??Date.now,s=Math.max(250,t.timeoutMs??3e3),a=t.fetch??globalThis.fetch,l=encodeURIComponent(t.usersSlug??fr),u=`${n}=${r}`;let d;try{const e=await a(`${i}/api/${l}/me?depth=0`,{headers:{cookie:u,accept:"application/json"},signal:AbortSignal.timeout(s)});if(!e.ok)return hr(401===e.status?"invalid":"unavailable");d=await e.json()}catch{return hr("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 i=e.collection??n.collection;if(void 0!==i&&i!==t)return null;const r=n.id;return"string"==typeof r&&r.length>0?r:"number"==typeof r&&Number.isFinite(r)?String(r):null}(d,t.usersSlug??fr);if(null===c)return hr("invalid");const h=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!==h&&h<=o()?hr("expired"):{authorized:!0,outcome:"authorized",context:dr({strategy:"payload-session",subject:c,authorizedAt:o(),expiresAt:h,scope:{},payloadHeaders:{cookie:u}})}}(e,t);case"signed-token":return async function(e,t){const n=wr(t.secret),i=Sr(t.crypto);if(void 0===i)return hr("unavailable");const r=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 i=n.searchParams.getAll(t?.param??"previewToken");return 1===i.length?i[0]??null:null}(e,t.transport);if(null===r||0===r.length)return hr("missing-credential");if(r.length>4096)return hr("invalid");const o=r.split(".");if(3!==o.length||o[0]!==yr)return hr("invalid");const s=o[1]??"",a=Tr(s),l=Tr(o[2]??"");if(void 0===a||32!==l?.byteLength)return hr("invalid");let u;try{const e=await kr(i,n);u=await i.subtle.verify("HMAC",e,l,br().encode(`${yr}.${s}`))}catch{return hr("unavailable")}if(!u)return hr("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,i=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&&i("pth")&&i("loc")&&i("sub")?n:void 0}(a);if(void 0===d)return hr("invalid");const c=(t.now??Date.now)();if(d.exp<=c||d.iat>d.exp)return hr("expired");if(d.aud!==t.audience)return hr("wrong-audience");if(d.pur!==(t.purpose??vr))return hr("wrong-purpose");if(void 0!==d.pth){let t;try{t=new URL(e.url).pathname}catch{return hr("invalid")}if(d.pth!==t)return hr("wrong-path")}if(void 0!==d.loc){const n=t.locale?.(e);if(n!==d.loc)return hr("wrong-locale")}if(void 0!==t.replay)try{if(await t.replay.isUsed(d.jti))return hr("replayed");await t.replay.markUsed(d.jti,d.exp)}catch{return hr("unavailable")}return{authorized:!0,outcome:"authorized",context:dr({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 hr("unavailable")}if(null===n)return hr("invalid");const i=(t.now??Date.now)();return void 0!==n.expiresAt&&n.expiresAt<=i?hr("expired"):{authorized:!0,outcome:"authorized",context:dr({strategy:"verifier",subject:n.subject,authorizedAt:i,expiresAt:n.expiresAt,scope:n.scope??{},payloadHeaders:n.payloadHeaders??{}})}}(e,t)}}var Rr=["preview","draft","livePreview"];function xr(e,t={}){const n=new Set(t.signals??["query","fetch-dest","referer"]),i=t.queryParams??Rr;if(n.has("query")){let t;try{t=new URL(e.url)}catch{t=void 0}if(void 0!==t)for(const e of i){const n=t.searchParams.get(e);if("true"===n||"1"===n)return!0}}if(n.has("fetch-dest")&&"iframe"===e.headers.get("sec-fetch-dest"))return!0;const r=n.has("referer")?t.adminOrigins??[]:[];if(r.length>0){const t=e.headers.get("referer");if(null!==t)try{const e=new URL(t).origin;for(const t of r)try{if(new URL(t).origin===e)return!0}catch{}}catch{}}return!1}var Fr="payload-live-preview-highlight",Nr=/* @__PURE__ */new WeakMap,Mr=/* @__PURE__ */new WeakMap,Lr={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=Nr.get(e);void 0===n||n.connected()||(Nr.delete(e),n=void 0),void 0===n&&(n=function(e,t){const n=e.getElementById(Fr);if(n instanceof HTMLStyleElement)return{pluginOwned:!1,connected:()=>n.isConnected,remove:()=>{},owners:0};const i=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!==i)return{pluginOwned:!0,connected:()=>e.adoptedStyleSheets.includes(i),remove:()=>{e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==i)},owners:0};const r=e.createElement("style");return r.id=Fr,r.textContent=t,e.head.appendChild(r),{pluginOwned:!0,connected:()=>r.isConnected,remove:()=>{r.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;}"),Nr.set(e,n));const i=n;i.owners+=1;let r=!0;return()=>{r&&(r=!1,i.owners-=1,i.owners>0||(Nr.get(e)===i&&Nr.delete(e),i.pluginOwned&&i.remove()))}}(document,t),i=t?1e3:600,r=/* @__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;r.get(t)?.();const n=function(e){let t=Mr.get(e);void 0===t&&(t={owners:0,pluginAdded:!e.classList.contains("lp-highlight")},Mr.set(e,t));const n=t;n.owners+=1,e.classList.add("lp-highlight");let i=!0;return()=>{i&&(i=!1,n.owners-=1,n.owners>0||(Mr.delete(e),n.pluginAdded&&e.classList.remove("lp-highlight")))}}(t);let s=!1;const a=()=>{s||(s=!0,window.clearTimeout(l),r.get(t)===a&&r.delete(t),o.delete(a),n())},l=window.setTimeout(a,i);o.add(a),r.set(t,a)})}},Er={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)})}};function Pr(){let e=0,t=0,n=0;return{name:"analytics",version:"1.0.0",init:i=>{i.events.on("afterUpdate",i=>{e+=1,t+=i.updatedCount,n+=i.durationMs})},getStats:()=>({updateCount:e,totalElements:t,totalDurationMs:n,averageDurationMs:0===e?0:n/e})}}var Ir="payload-live-preview:scroll";function Or(){"undefined"!=typeof window&&(function(){if("undefined"!=typeof window)try{sessionStorage.setItem(Ir,JSON.stringify({href:window.location.href,x:window.scrollX,y:window.scrollY}))}catch{}}(),window.location.reload())}function Ur(e={}){const t=e.strategy??"silent";return{name:"document-save",version:"1.1.0",init:n=>{let i=!0;const r=/* @__PURE__ */new Set;n.registerCleanup?.(()=>{i=!1;for(const e of r)e.abort();r.clear()}),function(){if("undefined"!=typeof window)try{const e=sessionStorage.getItem(Ir);if(null===e)return;sessionStorage.removeItem(Ir);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(!i)return;if("silent"===t)return;if("reload"===t)return void Or();const o=new AbortController;r.add(o);const s="fetch"===t?async function(e,t,n){if(e.handler)try{await e.handler(n)}catch(e){if(!i||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,i){if("undefined"==typeof fetch)return void t("document-save: revalidate strategy needs fetch — not available");const r=e.revalidateUrl??"/api/revalidate";let o=!1;try{const s=await fetch(r,{method:"POST",signal:n,headers:{"Content-Type":"application/json",...e.revalidateHeaders??{}},body:JSON.stringify({source:"payload-live-preview"})});if(!i()||n.aborted)return;o=s.ok,o||t("document-save revalidate non-2xx:",s.status)}catch(e){if(!i()||n.aborted)return;t("document-save revalidate failed:",e)}o||"reload"!==e.onRevalidateFailure||Or()}(e,n.log,o.signal,()=>i);s.finally(()=>{r.delete(o)})})}}}var jr={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"}};function bind(e,t){return Dr(e,t)}function bindByPath(e,t){const n=function(e){const t=[],n=new Proxy({},{get(e,i){if("symbol"!=typeof i)return/^\d+$/.test(i)||t.push(i),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 Dr(n.join("."),t)}function Dr(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 Hr=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):Hr,bindByPath:(e,n)=>t?bindByPath(e,n):Hr,owner:()=>t&&void 0!==n?{"data-payload-owner":n}:Hr})}export{lr as AUTHORIZED_PREVIEW_BRAND_KEY,R as CAPABILITY_DECLARATIONS,jr as CAPABILITY_DOCUMENTATION,_i as DIAGNOSTIC_CODES,EventEmitter,U as ISLAND_EVENT,$ as LIBRARY_PROTOCOL_VERSION,LivePreviewClient,OriginDetector,x as PROTOCOL_CAPABILITIES,Ze as TRUSTED_TYPES_POLICY_NAME,e as VERSION,$r as authorizePreviewRequest,bind,bindByPath,Vi as bindNavigationLifecycle,Ui as buildBuiltinRenderers,buildFrameAncestors,buildScriptSrcWithNonce,Pr as createAnalyticsPlugin,createPreviewBindings,Bi as createPreviewFocusReporter,Er as debugPlugin,detectInitialLocale,detectProtocolProfile,Ur as documentSavePlugin,escapeHtml,escapeHtmlAttribute,generateCspNonce,generateInlineScript,hasCapability,xr as hasPreviewIntent,Lr as highlightPlugin,initLivePreview,isAuthorizedPreviewContext,isDevMode,isExternalHttpUrl,isInIframe,isInPopup,isInPreviewContext,isInsideIsland,Gn as isLexicalContent,isSafeUrl,Cr as issuePreviewToken,Jn as lexicalToHtml,Kn as lexicalToPlainText,sr as mergeCspHeader,negotiateProtocol,Dn as registerBlockRenderer,Oi as registerBuiltinRenderer,Wi as reportPreviewFocus,er as runtimeBuildInfo,sanitizeHtml,setCspCrypto,setSanitizerDocument,wt as setSanitizerPolicy,Ye as setTrustedTypesPolicy,et as trustedHtml,Yi as wrapWithScriptTag};
2
2
  //# sourceMappingURL=index.js.map