payload-live-preview 1.2.0 → 1.2.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["I","Object","defineProperty","s","e","t","value","configurable","RUNTIME_SOURCE","generateInlineScript","config","length","Error","compactConfig","allowedOrigins","serverURL","apiRoute","mergeDepth","debug","debounceMs","enableA11y","heartbeatMs","disableVisibilityGate","visibilityGateThreshold","intersectionRootMargin","disableReferrerDetection","disableLocalhostMatching","scopeBindingsByOwner","at","pop","map","JSON","stringify","join","replace","wrapWithScriptTag","body","options","nonce","escapeNonce","test","RangeError","__name","VIRTUAL_OPTIONS_ID","RESOLVED_VIRTUAL_OPTIONS_ID","livePreview","name","hooks","ctx","mode","setupMiddlewareMode","autoInject","script","injectScript","addMiddleware","updateConfig","shouldInject","_mode","_shouldInject","serializable","optionsModule","vite","plugins","resolveId","id","load","entrypoint","order","CSP_ASCII_WHITESPACE","CSP_EDGE_ASCII_WHITESPACE","asciiLowercase","character","toLowerCase","generateCspNonce","bytes","Number","isInteger","String","crypto","resolveCrypto","buffer","Uint8Array","getRandomValues","base64UrlEncode","fromGlobal","globalThis","binary","byte","fromCharCode","btoa","Buffer","from","toString","replaceAll","buildFrameAncestors","self","origins","allowNone","seen","Set","out","push","add","origin","trimmed","trim","has","buildScriptSrcWithNonce","extra","strictDynamic","parts","mergeCspHeader","existing","additions","directives","Map","part","split","whitespaceIndex","search","slice","set","rawName","rawAddition","entries","addition","current","get","merged","token","withoutNone","filter","DEFAULT_QUERY_PARAMS","isPreviewRequest","request","signals","queryParams","checkFetchDest","url","URL","param","searchParams","headers","adminOrigins","referer","refererOrigin","adminOrigin","NONCE_LOCALS_KEY","HTML_CONTENT_TYPE","HEAD_INSERT","createLivePreviewMiddleware","cachedScriptBody","injectMode","inject","manageCsp","normalizeManageCsp","scriptBody","async","context","next","locals","response","isPrerendered","previewQueryParams","previewSignals","outResponse","contentType","applyCspHeaders","html","text","Headers","delete","Response","status","statusText","scriptTag","match","frameAncestorsExtra","scriptSrcExtra","renderLivePreviewScript","C","U","b","E","G"],"sources":["../../../src/inline/runtime.generated.ts","../../../src/inline/generator.ts","../../../src/adapters/astro/integration.ts","../../../src/security/csp.ts","../../../src/adapters/shared/preview-request.ts","../../../src/adapters/astro/middleware.ts","../../../src/adapters/astro/component.ts"],"sourcesContent":["// Auto-generated by scripts/build-runtime.ts — do not edit.\nexport interface RuntimeBuildInfo { readonly generatedAt: string; readonly size: number }\nexport const RUNTIME_SOURCE: string = \"(()=>{function t(t){return(\\\"object\\\"!=typeof t||null===t)&&\\\"function\\\"!=typeof t||\\\"function\\\"!=typeof t.then?0:(Promise.resolve(t).catch(()=>{}),1)}function e(e){return(...i)=>{try{t(e(...i))}catch{}}}function i(){}function n(){return 1}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?0: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 0;let e=t;return e.hasAttribute(ke)?1:null!==e.querySelector(`[${ke}]`)}function h(t){if(!Array.isArray(t))return[];let e=[];for(let i of t){let t=c(i);t&&e.push(t)}return e}function c(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 d(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?1:e(t)}function g(t){if(\\\"object\\\"!=typeof t||null===t)return 0;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 1}return 0}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 0;try{return encodeURIComponent(t),1}catch{return 0}}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 0;let e=t.trim();if(0===e.length||$i.test(e))return 0;if(e.startsWith(\\\"#\\\")||e.startsWith(\\\"?\\\")||e.startsWith(\\\"//\\\")||e.startsWith(\\\"/\\\"))return 1;try{let t=new URL(e);return Si.has(t.protocol)}catch{return Ai.test(e)}}function S(t){if(!w(t))return 0;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=0){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=1;for(let t of e.split(\\\".\\\")){if(Pi.has(t)||null===i||\\\"object\\\"!=typeof i){n=0;break}if(i=T(i,t),void 0===i){n=0;break}}if(n)return i}return void 0===i?void 0:T(t,`${e}_${i}`)}function T(t,e){if(!Pi.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(zi.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 j(t){if(\\\"object\\\"!=typeof t||null===t)return;let e=t.id;return\\\"string\\\"==typeof e||\\\"number\\\"==typeof e?e:void 0}function I(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!==j(t))?function(t,e){let i=[],n=new Map;for(let e=0;e<t.length;e+=1){let i=j(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=j(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];I(u)===I(s)?(a!==l&&i.push({kind:\\\"move\\\",from:a,to:l,value:s}),R(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)R(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 R(t,e){if(Object.is(t,e))return 1;if(\\\"object\\\"!=typeof t||\\\"object\\\"!=typeof e||null===t||null===e)return 0;let i=t,n=e,r=Object.keys(i),l=Object.keys(n);if(r.length!==l.length)return 0;for(let t of r)if(!Object.is(i[t],n[t]))return 0;return 1}function _(t){return 9===t.nodeType}function L(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 W(t,e){return t.generation===e.generation&&t.revision===e.revision}function P(t){return null==t?0:\\\"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 0;try{return window.self!==window.top}catch{return 1}}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||!bn.test(t.origin)?void 0:t.origin}catch{return}}function V(t,e){let i=G();if(!i)throw new En(\\\"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(Cn))t.set(e,i);return{allowedTags:kn,attrByTag:t}}let e=new Set(kn);for(let i of t.additionalAllowedTags??[])e.add(i);let i=new Map;for(let[t,e]of Object.entries(Cn))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===jn?H(i,e):i.nodeType===In&&i.remove()}function H(t,e){let i=t.tagName.toLowerCase();if(Tn.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(!(Nn.has(i)||i.startsWith(xn)||i.startsWith(Mn))){if(n?.has(i)){(On.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 0}return 1}function J(t,e){Rn.set(t,e)}function X(t){let e=t.format;if(\\\"string\\\"==typeof e&&Ln.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(Pn,t=>Wn[t])}function tt(t){return\\\"\\\"===t?\\\"\\\":t.replace(Dn,t=>Fn[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 Vn.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 0;let e=t.root;return\\\"object\\\"==typeof e&&null!==e&&\\\"children\\\"in e?Array.isArray(e.children):0}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,Lt):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 ct(){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(Wt))return function(t,e,i){t.has(e)||(t.add(e),pe(`[live-preview] 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),0;r.includes(\\\"\\\\n\\\")||r.includes(\\\"\\\\r\\\")?n.innerHTML=et(r):n.textContent=r}else n.value=r})}}function dt(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 dt(t)}function gt(t){return Array.isArray(t)?t.map(t=>gt(t)).join(\\\", \\\"):dt(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,dt)}function St(t){return dt(t)}function $t(t){let{template:e,container:i,patches:n,nextItems:r,store:l,forceRender:s=0}=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=jt(o,te),u=new Set,h=[];for(let c=0;c<i.length;c+=1){let d=i[c],f=Ot(d),p=void 0===f?o[c]??null:It(a,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=n.replaces.has(c),m=r||n.renders.has(c)||null===p?Et(t.ownerDocument,e,d,c):void 0;if(null===m)return null;let y=void 0===m?[]:Tt(g?null:p,m,d,l,s);if(null===y)return null;h.push([c,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=0;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=1),u=o}if(null===u)continue;let h=i.children[n]??null;u!==h&&(i.insertBefore(u,h),s=1),l.add(u)}for(let t of Array.from(i.children))l.has(t)||(t.remove(),s=1);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=jt(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=It(l,e)??null,u=t.getAttribute(ie),h=u?s:null,c=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&&c!==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 0;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 jt(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 It(t,e){return t.get(e)?.pop()}function Et(t,e,i,n){let r=function(t,e,i){return bt(t,e,i,dt)}(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 Rt(){let t=new WeakMap,e=new WeakSet,i=new WeakMap;return{name:\\\"structural-array\\\",render:$((n,r)=>{if(!Array.isArray(r))return 0;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] 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),0;let o=t.get(l),a=_t(l),u=o?.values??function(t){return t.map((t,e)=>null===t?{__payloadDomPosition:e}:{id:t})}(a),h=E(u,r),c=function(t,e,i){return void 0===t?1:t.template!==e||!function(t,e){return t.length!==e.length?0:t.every((t,i)=>t===e[i])}(t.domSnapshot,i)}(o,s,a);if(0===h.length&&!c)return t.set(l,{values:r.slice(),template:s,domSnapshot:a}),0;let d=$t({template:s,container:l,patches:h,nextItems:r,store:i,forceRender:c});return null===d?0:(t.set(l,{values:r.slice(),template:s,domSnapshot:_t(l)}),d?void 0:0)})}}function _t(t){return Array.from(t.children,t=>t.getAttribute(te))}var Lt,Wt,Pt,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:1,configurable:1,writable:1,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),ce=(t,e,i,n)=>(ae(t,e,\\\"write to private field\\\"),n?n.call(t,i):e.set(t,i),i),de=(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 de(this,be,Se).call(this,ue(this,ye),t,e)}once(t,e){return de(this,be,Se).call(this,ue(this,ve),t,e)}off(t,e){de(this,be,$e).call(this,ue(this,ye),t,e),de(this,be,$e).call(this,ue(this,ve),t,e)}async emit(t,e){await de(this,be,we).call(this,t,e)}async emitWhile(t,e,i){return de(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?.()??1;if(!n())return 0;let r=ue(this,ye).get(t);if(r)for(let i of[...r])if(!n()||(await de(this,be,Ae).call(this,i,e,t),!n()))return 0;if(!n())return 0;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 de(this,be,Ae).call(this,r,e,t),!n()))return 0}return n()},Se=function(t,e,i){let n=t.get(e);return n||(n=new Set,t.set(e,n)),n.add(i),()=>{de(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] 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\\\",je=\\\"data-payload-array-separator\\\",Ie=\\\"data-payload-locale\\\",Ee=\\\"data-payload-richtext\\\",Re=\\\"data-payload-html\\\",_e=\\\"data-payload-array\\\",Le=\\\"data-payload-structural\\\",We=\\\"data-payload-owner\\\",Pe=[ke,Te,Ne,xe,Me,Ce,Oe,je,Ie,Ee,Re,_e,Le,We,\\\"type\\\"],Fe=`[${ke}]`,De=`[${We}]`,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);ce(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)?de(this,He,Ye).call(this,t):void 0,i=ue(this,Ge).get(t);if(void 0!==e)return void 0!==i&&de(this,He,qe).call(this,i,e)?(ue(this,Ge).set(t,e),e):(void 0!==i&&de(this,He,Je).call(this,t,i),de(this,He,Xe).call(this,e),ue(this,Ge).set(t,e),e);void 0!==i&&de(this,He,Je).call(this,t,i)}remove(t){let e=ue(this,Ge).get(t);return e?de(this,He,Je).call(this,t,e):0}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(),ce(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 0;let i=ue(this,Ve).get(t.fieldName);if(!i)return 0;let n=i.indexOf(t);return n<0?0:(i[n]=e,1)},Je=function(t,e){let i=ue(this,Ve).get(e.fieldName);if(!i)return ue(this,Ge).delete(t),0;let n=i.indexOf(e);return n<0?(ue(this,Ge).delete(t),0):(i.splice(n,1),0===i.length&&ue(this,Ve).delete(e.fieldName),ue(this,Ge).delete(t),1)},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(Re))return\\\"html\\\";if(t.hasAttribute(Le))return\\\"structural-array\\\";if(t.hasAttribute(_e))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(je),h=t.getAttribute(Ie),c=function(t){let e=t.closest(De)?.getAttribute(We);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!==c?{owner:c}:{}}},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=>{de(this,Qe,ti).call(this,t,i)}),r=new IntersectionObserver(t=>{de(this,Qe,ei).call(this,t,i)},{rootMargin:this.s[2],threshold:0}),n.observe(t,{childList:1,subtree:1,attributes:1,attributeFilter:[...Pe]})}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(!de(this,Qe,ii).call(this,e)||!function(t){for(let e of t){if(\\\"attributes\\\"===e.type&&null!==e.attributeName&&Pe.includes(e.attributeName)&&(e.attributeName===ke||e.attributeName===We||e.target.nodeType===Ze&&e.target.hasAttribute(ke)))return 1;for(let t of e.addedNodes)if(u(t))return 1;for(let t of e.removedNodes)if(u(t))return 1}return 0}(t)||!de(this,Qe,ii).call(this,e))return;null!==this.s[6]&&clearTimeout(this.s[6]);let i=setTimeout(()=>{!de(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(!de(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,1),!de(this,Qe,ii).call(this,e)))return}else if(this.s[3].has(t)&&(this.s[3].delete(t),this.s[0].onVisibilityChange(t,0),!de(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=0,i=t=>{if(!e||this.s[2]!==i)return;let n=this.s[4];try{de(this,li,si).call(this,t,n)}catch{let e=\\\"\\\";try{e=t.origin}catch{}de(this,li,ci).call(this,\\\"shape\\\",e,n)}};this.s[4]+=1,de(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,de(this,li,mi).call(this));try{t.removeEventListener(\\\"message\\\",i)}catch{}throw e}if(this.s[2]===i)e=1;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,de(this,li,mi).call(this),e.removeEventListener(\\\"message\\\",i))}advanceGeneration(){return void 0===this.s[3]?0:(this.s[4]+=1,de(this,li,mi).call(this),1)}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(!de(this,li,pi).call(this,e))return;let i=t.origin;if(!de(this,li,pi).call(this,e))return;if(!de(this,li,di).call(this,i,e)){de(this,li,ci).call(this,\\\"origin\\\",i,e);return}let n=t.data;if(!de(this,li,pi).call(this,e))return;let r=function(t){return\\\"object\\\"==typeof t&&null!==t&&\\\"type\\\"in t?\\\"string\\\"==typeof t.type:0}(n);if(!de(this,li,pi).call(this,e))return;if(!r){de(this,li,ci).call(this,\\\"shape\\\",i,e);return}let l=n.type;if(de(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(!de(this,li,pi).call(this,e))return;if(!t){de(this,li,ci).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(!de(this,li,pi).call(this,e))return;de(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(!de(this,li,pi).call(this,e))return;if(!t){de(this,li,ci).call(this,\\\"shape\\\",i,e);return}let r;try{r=this.s[1].onDocumentEvent}catch{return}if(!de(this,li,pi).call(this,e))return;de(this,li,fi).call(this,r,n,i);return}default:de(this,li,ci).call(this,\\\"type\\\",i,e)}},oi=function(t,e,i){if(!de(this,li,pi).call(this,i))return;let n=t.data;if(!de(this,li,pi).call(this,i))return;let r=g(n);if(!de(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(!de(this,li,pi).call(this,i))return;if(void 0===l){de(this,li,hi).call(this,t,e,i,s);return}if(1==t.ready&&void 0===n){de(this,li,hi).call(this,t,e,i,void 0);return}let o={generation:i,message:t,origin:e,messageRevision:s,settled:0,approved:0};this.s[6].push(o);let a;try{a=l(t.previewToken,e)}catch{de(this,li,ai).call(this,o,0);return}\\\"boolean\\\"!=typeof a?Promise.resolve(a).then(t=>{de(this,li,ai).call(this,o,1==t)},()=>{de(this,li,ai).call(this,o,0)}):de(this,li,ai).call(this,o,a)},ai=function(t,e){de(this,li,pi).call(this,t.generation)&&(t.approved=e,t.settled=1,de(this,li,ui).call(this,t.generation))},ui=function(t){for(;de(this,li,pi).call(this,t);){let e=this.s[6][this.s[7]];if(void 0===e)return;if(de(this,li,di).call(this,e.origin,t)){if(!e.settled)return;de(this,li,gi).call(this,e)&&(e.approved?de(this,li,hi).call(this,e.message,e.origin,e.generation,e.messageRevision):de(this,li,ci).call(this,\\\"token\\\",e.origin,e.generation))}else{if(!de(this,li,gi).call(this,e))continue;de(this,li,ci).call(this,\\\"origin\\\",e.origin,e.generation)}}},hi=function(t,e,i,n){if(!de(this,li,pi).call(this,i))return;let r;try{r=this.s[1].onUpdate}catch{return}de(this,li,pi).call(this,i)&&(void 0===n?de(this,li,fi).call(this,r,t,e):de(this,li,fi).call(this,r,t,e,n))},ci=function(t,e,i){if(!de(this,li,pi).call(this,i))return;let n;try{n=this.s[1].onInvalid}catch{return}de(this,li,pi).call(this,i)&&void 0!==n&&de(this,li,fi).call(this,n,t,e)},di=function(t,e){if(!de(this,li,pi).call(this,e))return 0;try{return 1==this.s[0](t)&&de(this,li,pi).call(this,e)}catch{return 0}},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?0:(e[7]+=1,e[7]===e[6].length?(de(this,li,mi).call(this),1):(e[7]>=1024&&2*e[7]>=e[6].length&&(e[6]=e[6].slice(e[7]),e[7]=0),1))},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 0;let e=this.s[0];return this.s[0]=t,this.s[1](t,e),1}},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 0;try{return encodeURIComponent(t),1}catch{return 0}}(t.data.id):0}catch{return 0}}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:0,...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??0,e.getCacheSize,e.onFlush,i,n,new Map,new Map,new Set,null,0,null,0,null,0]}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}),de(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||(de(this,Mi,Wi).call(this),de(this,Mi,_i).call(this),this.s[16]=t,this.s[17]=0)}cancelRevision(t){A(t,this.s[16])&&(de(this,Mi,Wi).call(this),de(this,Mi,_i).call(this),this.s[17]=1)}flushNow(){return de(this,Mi,Wi).call(this),de(this,Mi,ji).call(this)}notifyVisible(t){let e=this.s[10],i=e.get(t);if(!i||(e.delete(t),!de(this,Mi,Ii).call(this,i)))return;let n=performance.now(),r=de(this,Mi,Ei).call(this,i)?1:0;this.s[6]?.(de(this,Mi,Li).call(this,i,r,0,performance.now()-n))}retarget(t){de(this,Mi,Ri).call(this,this.s[9],t),de(this,Mi,Ri).call(this,this.s[10],t);for(let e of this.s[11])de(this,Mi,Ri).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(){de(this,Mi,Wi).call(this),de(this,Mi,_i).call(this),this.s[16]=null,this.s[17]=0}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}},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,de(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=0,n=this.s[7](()=>{this.s[15]===t&&(i=1,this.s[14]=null,de(this,Mi,ji).call(this))});!i&&this.s[15]===t&&(this.s[14]=n)},ji=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=0;this.s[11].add(i);try{for(let t of i.values()){if(!de(this,Mi,Ii).call(this,t))continue;let i=!e||this.s[2](t.target.element);if(de(this,Mi,Ii).call(this,t)){if(n??(n=t),!i){this.s[10].set(t.target.element,t),l+=1;continue}this.s[10].delete(t.target.element),de(this,Mi,Ei).call(this,t)&&(r+=1)}}}finally{this.s[11].delete(i)}let s=de(this,Mi,Li).call(this,n,r,l,performance.now()-t);return this.s[6]?.(s),s},Ii=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 0!=e(t)||!function(t){return Ni.has(t)}(e)},Ri=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}},_i=function(){this.s[9].clear(),this.s[10].clear();for(let t of this.s[11])t.clear()},Li=function(t,e,i,n){return{applied:e,deferred:i,durationMs:n,...void 0!==t?.identity?{identity:t.identity}:{},...void 0!==t?.data?{data:t.data}:{}}},Wi=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)},Pi=new Set([\\\"__proto__\\\",\\\"prototype\\\",\\\"constructor\\\"]),Fi=\\\"payload-live-preview-a11y\\\",Di=new WeakMap,Ui=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=Di.get(t);return e??(e=[null,0,null,0,null]),Di.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(Fi);return e[1]=null===n,n||(n=t.createElement(\\\"div\\\"),n.id=Fi,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,Di.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}},zi=new Set([\\\"tabs\\\",\\\"row\\\",\\\"collapsible\\\"]),Vi={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\\\"},Gi=[0,500,1e3,2e3],Bi=class{constructor(t){he(this,Hi);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??L,h=t.onHeartbeatTimeout,c=void 0===t.log?i:e(t.log),f=void 0===t.warn?pe:e(t.warn),p=function(t){if(0==t.enableA11y)return null;let e=void 0===t.root?void 0:9===t.root.nodeType?t.root:t.root.ownerDocument;return new Ui(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)=>{c(...t)}}):null,m=new ze,y=new Ke({onStructuralChange:()=>{de(this,Hi,Ki).call(this)},onVisibilityChange:(t,e)=>{e&&this.d[3].notifyVisible(t)}},{...void 0!==t.intersectionRootMargin?{intersectionRootMargin:t.intersectionRootMargin}:{}}),v=new xi($(t=>de(this,Hi,cn).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=>{de(this,Hi,dn).call(this,t)}}),b=new ri(t.originMatcher,{onUpdate:(t,e,i)=>{de(this,Hi,tn).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\\\"})}c(\\\"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:()=>{de(this,Hi,fn).call(this)}});this.d=[n,m,y,v,b,w,S,r,l,s,o,a,u,h,c,f,[],p,g,1==t.scopeBindingsByOwner],this.l=[void 0,void 0,void 0,d(void 0),0,null,0,null,new Set,0]}start(){if(this.l[4])return 0;this.l[4]=1;let t=this.d[10];if(_(t)&&\\\"loading\\\"===t.readyState){let e=()=>{if(this.l[4]){this.l[5]=null;try{de(this,Hi,qi).call(this)}catch(t){de(this,Hi,Xi).call(this),de(this,Hi,gn).call(this,t,\\\"startup\\\")}}};this.l[5]=e;try{t.addEventListener(\\\"DOMContentLoaded\\\",e,{once:1})}catch(t){throw de(this,Hi,Xi).call(this),t}return 1}try{return de(this,Hi,qi).call(this),1}catch(t){throw de(this,Hi,Xi).call(this),t}}destroy(){this.l[4]&&(de(this,Hi,Ji).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]&&de(this,Hi,Ki).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]}},Hi=new WeakSet,qi=function(){if(!this.l[4])return;let t=_(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),de(this,Hi,Zi).call(this),de(this,Hi,hn).call(this)&&(this.d[4].attach(),this.d[0].emitWhile(\\\"init\\\",{timestamp:Date.now()},()=>this.l[4]),de(this,Hi,hn).call(this)))for(let t of Gi){if(!de(this,Hi,hn).call(this))return;if(0===t){if(this.d[12](this.d[11]),!de(this,Hi,hn).call(this))return}else{let e=setTimeout(()=>{this.l[4]&&de(this,Hi,pn).call(this)},t);this.d[16].push(e)}}},Ji=function(){this.l[7]=null,this.l[4]=0;let t=this.l[5];this.l[5]=null,null!==t&&_(this.d[10])&&de(this,Hi,Yi).call(this,()=>{this.d[10].removeEventListener(\\\"DOMContentLoaded\\\",t)});for(let t of this.d[16])de(this,Hi,Yi).call(this,()=>{clearTimeout(t)});return this.d[16].length=0,de(this,Hi,Yi).call(this,()=>{this.d[6].stop()}),de(this,Hi,Yi).call(this,()=>{this.d[4].detach()}),de(this,Hi,Yi).call(this,()=>{this.d[2].stop()}),de(this,Hi,Yi).call(this,()=>{this.d[3].destroy()}),de(this,Hi,Yi).call(this,()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()},Xi=function(){de(this,Hi,Ji).call(this),de(this,Hi,Yi).call(this,()=>{this.d[17]?.detach()})},Yi=function(t){try{t()}catch(t){this.d[14](\\\"cleanup failed:\\\",t)}},Zi=function(){if(!this.l[4])return;let t=this.d[1].buildFromRoot(this.d[10]);if(this.d[14](\\\"cache\\\",t),de(this,Hi,hn).call(this)&&(this.d[0].emitWhile(\\\"cacheRefresh\\\",t,()=>this.l[4]),de(this,Hi,hn).call(this)))for(let t of this.d[1].values()){if(!de(this,Hi,hn).call(this))return;this.d[2].observeElement(t.element)}},Ki=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(de(this,Hi,Zi).call(this),de(this,Hi,hn).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)}},Qi=function(t){let e=d(t);e.negotiated!==this.l[3].negotiated&&(this.l[3]=e,this.d[14](\\\"protocol\\\",\\\"ours=4\\\",`theirs=${t}`,`negotiated=${e.negotiated}`))},tn=function(t,e,i){if(this.d[6].kick(),void 0===t.data){void 0!==t.protocolVersion&&de(this,Hi,Qi).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:0};this.l[7]=n,this.d[3].acceptRevision(i),this.l[6]+=1,(void 0===t.protocolVersion||(de(this,Hi,Qi).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))||de(this,Hi,en).call(this,n))},en=async function(t){let e=await de(this,Hi,nn).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=1,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&&de(this,Hi,rn).call(this,t,n)},nn=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},rn=function(t,e){if(!this.l[4]||this.l[7]!==t)return;let i=()=>this.l[4]&&this.l[7]===t,n=de(this,Hi,ln).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(0!=n&&!o(s.owner,n))continue;let l=k(e.fields,r,s.locale??t.locale,void 0!==s.locale);if(void 0===l)continue;if(!this.l[4]||this.l[7]!==t)return;let a=de(this,Hi,un).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)}}de(this,Hi,an).call(this,e.fields,t.locale,n)},ln=function(t,e){if(!this.d[19])return 0;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]=1,this.d[15](\\\"[live-preview] scopeBindingsByOwner: update names no document; nothing applied\\\")),n},sn=function(t){for(let e of this.d[1].values())if(o(e.owner,t))return 1;return 0},on=function(t,e){let i=this.d[1].get(t);return void 0===i?0:0==e?1:i.some(t=>o(t.owner,e))},an=function(t,e,i){if(0===this.d[1].fieldCount||0!=i&&!de(this,Hi,sn).call(this,i))return;let n;for(let[r,l]of Object.entries(t)){if(this.l[8].has(r)||yn.has(r)||!P(l))continue;let t=F(r,e);if(!(de(this,Hi,on).call(this,r,i)||t!==r&&de(this,Hi,on).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)0!=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] 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.`))}}},un=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\\\"}),i}},hn=function(){return this.l[4]},cn=function(t){let e=this.l[7];if(null===e||void 0===t.identity||!W(e.identity,t.identity)||!this.l[4]||this.l[7]!==e)return 0;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(Vi,t))return Vi[t]}(e);if(void 0!==t)return t}return t.fieldType}(t.target,i?.type);\\\"text\\\"===r&&1!=t.target.explicitFieldType&&function(t){if(\\\"object\\\"!=typeof t||null===t||!(\\\"root\\\"in t))return 0;let e=t.root;return\\\"object\\\"!=typeof e||null===e?0: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 0;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile(\\\"error\\\",{error:i,context:\\\"renderer\\\"},()=>this.l[4]&&this.l[7]===e),0}if(!this.l[4]||this.l[7]!==e)return 0;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 0;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] refused to write field \\\"${t.target.fieldName}\\\" into attribute \\\"${t.target.targetAttribute}\\\" (unsafe attribute or value)`),0}else{if(!l)return this.d[14](\\\"no renderer for\\\",r),0;if(0==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 0}}catch(t){if(!this.l[4]||this.l[7]!==e)return 0;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile(\\\"error\\\",{error:i,context:\\\"renderer\\\"},()=>this.l[4]&&this.l[7]===e),0}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):0},dn=function(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||!W(n.identity,e))return;let r=()=>this.l[4]&&this.l[7]===n&&W(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)},fn=function(){if(!de(this,Hi,hn).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)}de(this,Hi,hn).call(this)&&(e&&de(this,Hi,mn).call(this)&&(this.d[17]?.announceDisconnected(),this.d[0].emitWhile(\\\"disconnect\\\",{reason:\\\"timeout\\\",timestamp:Date.now()},()=>de(this,Hi,mn).call(this)),!de(this,Hi,hn).call(this)||de(this,Hi,mn).call(this)&&(this.d[14](\\\"connection\\\",\\\"connected\\\",\\\"\\\\u2192\\\",\\\"disconnected\\\"),!de(this,Hi,hn).call(this)))||de(this,Hi,hn).call(this)&&de(this,Hi,pn).call(this))},pn=function(){try{this.d[12](this.d[11])}catch(t){de(this,Hi,gn).call(this,t,\\\"ready\\\")}},gn=function(t,e){let i=t instanceof Error?t:new Error(String(t));this.d[0].emit(\\\"error\\\",{error:i,context:e})},mn=function(){return this.l[4]&&\\\"disconnected\\\"===this.d[5].status&&null===this.l[7]},yn=new Set([\\\"id\\\",\\\"_id\\\",\\\"createdAt\\\",\\\"updatedAt\\\",\\\"createdBy\\\",\\\"updatedBy\\\",\\\"_status\\\",\\\"globalType\\\",\\\"collection\\\",\\\"locale\\\",\\\"localized\\\"]),vn=/^https?:\\\\/\\\\/(localhost|127\\\\.0\\\\.0\\\\.1)(?::\\\\d+)?$/i,bn=/^https?:\\\\/\\\\/[^/?#\\\\s]+$/i,wn=[\\\"PAYLOAD_ADMIN_ORIGIN\\\",\\\"PUBLIC_PAYLOAD_ADMIN_ORIGIN\\\",\\\"NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN\\\"],Sn=class{constructor(t={}){he(this,$n);let e=new Set;for(let i of t.additionalOrigins??[]){let t=z(i);void 0!==t&&e.add(t)}for(let t of wn){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??1)&&(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 1}return 0}());ce(this,$n,[e,i,n,void 0!==i,void 0])}matches(t){return 0===t.length||\\\"null\\\"===t?0:void 0!==ue(this,$n)[4]?t===ue(this,$n)[4]:!!(ue(this,$n)[0].has(t)||0===ue(this,$n)[0].size&&void 0!==ue(this,$n)[1]&&t===ue(this,$n)[1]||ue(this,$n)[2]&&vn.test(t))}lockOrigin(t){return this.matches(t)?(ue(this,$n)[4]=t,1):0}unlockOrigin(){let t=ue(this,$n)[4];return ue(this,$n)[4]=void 0,t}get lockedOrigin(){return ue(this,$n)[4]}enumerate(){if(void 0!==ue(this,$n)[4])return[ue(this,$n)[4]];let t=new Set(ue(this,$n)[0]);if(0===ue(this,$n)[0].size&&void 0!==ue(this,$n)[1]&&t.add(ue(this,$n)[1]),ue(this,$n)[2])for(let e of An)t.add(`http://localhost:${String(e)}`),t.add(`http://127.0.0.1:${String(e)}`);return[...t]}get referrerWasAvailable(){return ue(this,$n)[3]}get isProductionUnconfigured(){return!(!D()||ue(this,$n)[0].size>0||ue(this,$n)[2]||void 0!==ue(this,$n)[1])}get isReferrerOnlyTrust(){return ue(this,$n)[0].size>0||ue(this,$n)[2]?0:void 0!==ue(this,$n)[1]}},$n=new WeakMap,An=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],kn=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\\\"]),Tn=new Set([\\\"script\\\",\\\"style\\\",\\\"iframe\\\",\\\"object\\\",\\\"embed\\\",\\\"link\\\",\\\"meta\\\",\\\"base\\\",\\\"form\\\",\\\"input\\\",\\\"button\\\",\\\"select\\\",\\\"textarea\\\",\\\"svg\\\",\\\"math\\\",\\\"template\\\",\\\"frame\\\",\\\"frameset\\\",\\\"noframes\\\",\\\"noscript\\\"]),Nn=new Set([\\\"id\\\",\\\"class\\\",\\\"lang\\\",\\\"dir\\\",\\\"title\\\",\\\"role\\\",\\\"tabindex\\\"]),xn=\\\"aria-\\\",Mn=\\\"data-\\\",Cn={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\\\"])},On=new Set([\\\"href\\\",\\\"src\\\",\\\"cite\\\",\\\"poster\\\"]),jn=1,In=8,En=class extends Error{constructor(){super(...arguments);oe(this,\\\"name\\\",\\\"SanitizerEnvironmentError\\\")}},Rn=(Object.freeze({allowedTags:kn,removeCompletely:Tn,globalAttributes:Nn,attributesByTag:Cn,urlAttributes:On}),new Map),_n={1:\\\"left\\\",2:\\\"center\\\",3:\\\"right\\\",4:\\\"justify\\\"},Ln=new Set([\\\"left\\\",\\\"center\\\",\\\"right\\\",\\\"justify\\\",\\\"start\\\",\\\"end\\\"]),Wn=Object.freeze({\\\"&\\\":\\\"&amp;\\\",\\\"<\\\":\\\"&lt;\\\",\\\">\\\":\\\"&gt;\\\",'\\\"':\\\"&quot;\\\",\\\"'\\\":\\\"&#x27;\\\",\\\"/\\\":\\\"&#x2F;\\\",\\\"`\\\":\\\"&#x60;\\\",\\\"=\\\":\\\"&#x3D;\\\"}),Pn=/[&<>\\\"'/`=]/g,Fn=Object.freeze({\\\"&\\\":\\\"&amp;\\\",\\\"<\\\":\\\"&lt;\\\",\\\">\\\":\\\"&gt;\\\",'\\\"':\\\"&quot;\\\",\\\"'\\\":\\\"&#x27;\\\"}),Dn=/[&<>\\\"']/g,Un=new Set([\\\"h1\\\",\\\"h2\\\",\\\"h3\\\",\\\"h4\\\",\\\"h5\\\",\\\"h6\\\"]),zn=(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>`},Vn=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=Un.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\\\",zn);J(\\\"autolink\\\",zn);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>`});Lt={renderChildren:at,resolveAlignment:X,resolveIndent:Y};Wt=\\\"data-payload-text\\\";Pt={name:\\\"textarea\\\",render(t,e){let i=t.element,n=st(e)?ot(e):dt(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 0==e.sanitize||void 0===G()?i:V(i)}(e);else{if(\\\"string\\\"!=typeof e)return 0;t.element.innerHTML=V(e)}})};Dt={name:\\\"html\\\",render(t,e){if(null==e){t.element.textContent=\\\"\\\";return}let i=\\\"string\\\"==typeof e?e:dt(e);t.element.innerHTML=V(i)}};Ut={name:\\\"url\\\",render(t,e,i){let n=t.element,r=dt(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 0;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 0;let r=n.url;if(\\\"string\\\"!=typeof r||!w(r))return 0;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:dt(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(dt(e));Number.isNaN(r)?n.textContent=dt(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 0;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=[Pt,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=0,s=50,o=1,a=0,u=0,h=50,c=\\\"200px\\\",d=0,f=0,p=0]=typeof __LIVE_PREVIEW_CONFIG__>\\\"u\\\"?[]:__LIVE_PREVIEW_CONFIG__,g=new Sn({additionalOrigins:e,enableReferrerDetection:!d,enableLocalhostMatching:!f});g.isProductionUnconfigured?pe(\\\"[live-preview] No trusted origin. Set PAYLOAD_ADMIN_ORIGIN or pass allowedOrigins to generateInlineScript().\\\"):g.isReferrerOnlyTrust&&pe(\\\"[live-preview] 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)}([ct(),...re,Rt()]),v=new Bi({renderers:y,originMatcher:t=>g.matches(t),readyTargets:g.enumerate(),emitter:m,...\\\"\\\"!==i?{dataMerge:{serverURL:i,apiRoute:n,depth:r}}:{},debounceMs:s,heartbeatMs:a,intersectionRootMargin:c,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=Object.freeze({version:\\\"1.2.0\\\",destroy:()=>{v.destroy();let t=window;t.__livePreview===b&&delete t.__livePreview},refresh:()=>{v.refreshCache()},enumerateOrigins:()=>g.enumerate()});try{Object.defineProperty(window,\\\"__livePreview\\\",{value:b,writable:0,configurable:1})}catch(t){throw v.destroy(),t}}()})();\";\nexport const RUNTIME_BUILD_INFO: RuntimeBuildInfo = { generatedAt: \"2026-08-17T22:37:41.000Z\", size: 65423 };\n","/**\n * Inline script generator.\n *\n * Wraps the build-time-generated runtime IIFE with consumer-provided\n * configuration. Returns a JavaScript string suitable for embedding\n * via `<script>` in any framework.\n *\n * The runtime body is identical to the one used by the high-level\n * client because both originate from `src/core/runtime.ts`. There is\n * no parallel implementation to drift out of sync.\n *\n * @module @inline/generator\n */\n\nimport { RUNTIME_SOURCE, RUNTIME_BUILD_INFO, type RuntimeBuildInfo } from './runtime.generated';\n\nexport interface InlineScriptConfig {\n /** Additional trusted origins to merge with auto-detected ones. */\n readonly allowedOrigins?: readonly string[];\n /**\n * Payload server origin, e.g. `https://cms.example.com`. When set,\n * every incoming update is re-fetched through the Payload REST API\n * (`X-Payload-HTTP-Method-Override: GET`, same strategy as the\n * official client) so relationship and upload fields render\n * populated instead of as bare IDs. Strongly recommended for\n * Payload 3.x. Requires the preview page to be able to reach the\n * API with credentials (same-site cookies or CORS `credentials`).\n */\n readonly serverURL?: string;\n /** REST API route prefix used with `serverURL`. Defaults to `/api`. */\n readonly apiRoute?: string;\n /** Population depth used with `serverURL`. Defaults to `1`. */\n readonly mergeDepth?: number;\n /** Enable verbose console logging. Defaults to `false`. */\n readonly debug?: boolean;\n /** Debounce window for incoming updates in ms. Defaults to `50`. */\n readonly debounceMs?: number;\n /** Enable screen-reader live region. Defaults to `true`. */\n readonly enableA11y?: boolean;\n /**\n * Heartbeat timeout in ms. Defaults to `0` (disabled). The Payload\n * admin only posts messages on form edits — there is no protocol\n * keepalive — so an idle-based timeout would fire spurious\n * disconnects while the editor pauses. Enable only if your admin\n * setup sends periodic messages.\n */\n readonly heartbeatMs?: number;\n /**\n * Bypass the visibility-gate optimisation and apply every update\n * regardless of viewport position. Default `false` — the gate kicks\n * in when the cache exceeds `visibilityGateThreshold` entries.\n */\n readonly disableVisibilityGate?: boolean;\n /**\n * Cache-size threshold above which the visibility gate activates.\n * Default `50`. Off-screen elements above this threshold are queued\n * for replay on intersection instead of being updated immediately.\n */\n readonly visibilityGateThreshold?: number;\n /**\n * `rootMargin` passed to the `IntersectionObserver` watching the\n * cached elements. Default `'200px'`. Increase to pre-render\n * further off-screen content; decrease for tighter visibility.\n */\n readonly intersectionRootMargin?: string;\n /**\n * Opt out of `document.referrer`-based origin auto-detection.\n * Useful when the page is loaded under `Referrer-Policy: no-referrer`\n * and you want predictable behaviour. Default `false`.\n */\n readonly disableReferrerDetection?: boolean;\n /**\n * Opt out of the dev-mode localhost-pattern matcher (any port on\n * `localhost` / `127.0.0.1`). Useful when running locally against\n * a production-like origin list. Default `false`.\n */\n readonly disableLocalhostMatching?: boolean;\n /**\n * Restrict each update to the bindings owned by the document it describes,\n * declared in markup with `data-payload-owner` and resolved from the nearest\n * ancestor. Default `false`, which keeps matching on the field name alone.\n *\n * Enable it when one page previews more than one document. While enabled a\n * binding without an owner is never updated.\n */\n readonly scopeBindingsByOwner?: boolean;\n /**\n * Retained for 1.x source compatibility, but has no effect here:\n * `generateInlineScript()` returns a script body and creates no tag.\n * Pass the nonce separately to `wrapWithScriptTag(body, { nonce })`.\n *\n * @deprecated Use the second argument of `wrapWithScriptTag()`.\n */\n readonly nonce?: string;\n}\n\n/**\n * Build an inline script body. The result is a self-contained IIFE\n * with the build-time runtime, prefixed by a configuration block.\n *\n * The string does NOT include the `<script>` tags — use\n * `wrapWithScriptTag()` when you need them.\n */\nexport function generateInlineScript(config: InlineScriptConfig = {}): string {\n if (RUNTIME_SOURCE.length === 0) {\n throw new Error(\n '[live-preview] runtime.generated.ts is empty. Run `npm run build:runtime` before bundling.',\n );\n }\n // Compact private wire format; keep this order aligned with\n // `RuntimeBuildConfig` in `src/core/runtime.ts`.\n const compactConfig: unknown[] = [\n config.allowedOrigins,\n config.serverURL,\n config.apiRoute,\n config.mergeDepth,\n config.debug,\n config.debounceMs,\n config.enableA11y,\n config.heartbeatMs,\n config.disableVisibilityGate,\n config.visibilityGateThreshold,\n config.intersectionRootMargin,\n config.disableReferrerDetection,\n config.disableLocalhostMatching,\n config.scopeBindingsByOwner,\n ];\n while (compactConfig.length > 0 && compactConfig.at(-1) === undefined) compactConfig.pop();\n // Preserve omitted interior options as sparse JavaScript slots. JSON arrays\n // encode `undefined` as `null`, which would bypass the runtime's destructuring\n // defaults and can turn an omitted serverURL into an invalid configured value.\n // `<` must never appear literally inside an inline <script> body — a\n // consumer-supplied string containing `</script>` would terminate the tag.\n const configLiteral = `[${compactConfig\n .map((value) => (value === undefined ? '' : JSON.stringify(value)))\n .join(',')}]`.replace(/</g, '\\\\u003C');\n // The IIFE declares its own scope. We inject the config via a global\n // assignment that the bundled runtime reads back through the\n // `__LIVE_PREVIEW_CONFIG__` constant placeholder. The identifier is retained\n // across 1.0.x because existing deployments use it as a non-secret runtime\n // presence/leak signal in response-level integration tests.\n return [`var __LIVE_PREVIEW_CONFIG__=${configLiteral};`, RUNTIME_SOURCE].join('\\n');\n}\n\n/**\n * Wrap an inline script body in a `<script>` tag. When a nonce is\n * provided it is added as the `nonce` attribute so CSP policies that\n * require `'nonce-...'` accept the script.\n */\nexport function wrapWithScriptTag(body: string, options: { nonce?: string } = {}): string {\n const nonceAttr = options.nonce !== undefined ? ` nonce=\"${escapeNonce(options.nonce)}\"` : '';\n return `<script${nonceAttr}>${body}</script>`;\n}\n\n/**\n * Snapshot of the build-time information for diagnostics.\n */\nexport function runtimeBuildInfo(): RuntimeBuildInfo {\n return RUNTIME_BUILD_INFO;\n}\n\nfunction escapeNonce(nonce: string): string {\n if (!/^[A-Za-z0-9+/=_-]+$/.test(nonce)) {\n throw new RangeError('wrapWithScriptTag: nonce contains invalid characters');\n }\n return nonce;\n}\n","/**\n * Astro integration for Payload Live Preview.\n *\n * Drop into `astro.config.mjs`:\n *\n * ```ts\n * import { defineConfig } from 'astro/config';\n * import { livePreview } from 'payload-live-preview/astro';\n *\n * export default defineConfig({\n * integrations: [livePreview({ allowedOrigins: ['https://admin.example.com'] })],\n * });\n * ```\n *\n * Two injection modes:\n *\n * - **`mode: 'inline'`** (default) — `injectScript('head-inline', …)`\n * bakes the runtime into every page at build time. Right choice\n * for `output: 'static'`, where no middleware runs at request\n * time. The runtime stays inert outside the admin iframe.\n * - **`mode: 'middleware'`** — registers the preview middleware via\n * `addMiddleware()`: the runtime is injected at request time into\n * requests carrying preview intent, and `frame-ancestors` CSP is\n * managed. This is a delivery gate, not authentication. For\n * authorization-gated response changes, register\n * `createLivePreviewMiddleware()` manually after the application's\n * server-side verifier. (`shouldInject` is not supported in this\n * mode: options travel through a serialized virtual module.)\n *\n * @module @adapters/astro/integration\n */\n\nimport { generateInlineScript } from '@inline/generator';\nimport type { LivePreviewAstroOptions } from './types';\n\n// Local Astro type shims — keep `astro` as a runtime-optional peer.\ntype ScriptStage = 'head-inline' | 'page' | 'before-hydration' | 'page-ssr';\ninterface VitePluginLike {\n readonly name: string;\n readonly resolveId: (id: string) => string | undefined;\n readonly load: (id: string) => string | undefined;\n}\ninterface AstroConfigSetupContext {\n readonly injectScript: (stage: ScriptStage, content: string) => void;\n readonly addMiddleware?: (entry: { entrypoint: string; order: 'pre' | 'post' }) => void;\n readonly updateConfig?: (config: { vite?: { plugins?: VitePluginLike[] } }) => void;\n}\n\nexport interface AstroIntegrationLike {\n readonly name: string;\n readonly hooks: {\n readonly 'astro:config:setup': (ctx: AstroConfigSetupContext) => void;\n };\n}\n\nconst VIRTUAL_OPTIONS_ID = 'virtual:payload-live-preview/options';\nconst RESOLVED_VIRTUAL_OPTIONS_ID = `\\0${VIRTUAL_OPTIONS_ID}`;\nconst MIDDLEWARE_ENTRYPOINT = 'payload-live-preview/astro/middleware-entry';\n\n/**\n * Build the Astro integration. The injected script auto-detects the\n * browser preview context and stays inert on ordinary top-level pages.\n * Browser-context detection does not authorize HTTP response changes.\n */\nexport function livePreview(options: LivePreviewAstroOptions = {}): AstroIntegrationLike {\n return {\n name: 'payload-live-preview',\n hooks: {\n 'astro:config:setup': (ctx): void => {\n if (options.mode === 'middleware') {\n setupMiddlewareMode(ctx, options);\n return;\n }\n if (options.autoInject === false) return;\n const script = generateInlineScript({\n ...(options.allowedOrigins !== undefined\n ? { allowedOrigins: options.allowedOrigins }\n : {}),\n ...(options.serverURL !== undefined ? { serverURL: options.serverURL } : {}),\n ...(options.apiRoute !== undefined ? { apiRoute: options.apiRoute } : {}),\n ...(options.mergeDepth !== undefined ? { mergeDepth: options.mergeDepth } : {}),\n ...(options.debug !== undefined ? { debug: options.debug } : {}),\n ...(options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {}),\n ...(options.heartbeatMs !== undefined ? { heartbeatMs: options.heartbeatMs } : {}),\n });\n ctx.injectScript('head-inline', script);\n },\n },\n };\n}\n\nfunction setupMiddlewareMode(ctx: AstroConfigSetupContext, options: LivePreviewAstroOptions): void {\n if (ctx.addMiddleware === undefined || ctx.updateConfig === undefined) {\n throw new Error(\n \"payload-live-preview: mode 'middleware' needs Astro's addMiddleware/updateConfig \" +\n 'hooks (Astro >= 4). Upgrade Astro or use the default inline mode.',\n );\n }\n if (options.shouldInject !== undefined) {\n throw new Error(\n \"payload-live-preview: `shouldInject` cannot be used with mode 'middleware' — \" +\n 'options are serialized into the build. Use `previewQueryParams`/`previewSignals`, ' +\n 'or register createLivePreviewMiddleware() manually in src/middleware.ts.',\n );\n }\n\n // Everything except functions serializes cleanly.\n const { mode: _mode, shouldInject: _shouldInject, ...serializable } = options;\n const optionsModule = `export default ${JSON.stringify(serializable).replace(/</g, '\\\\u003C')};`;\n\n ctx.updateConfig({\n vite: {\n plugins: [\n {\n name: 'payload-live-preview-options',\n resolveId: (id) => (id === VIRTUAL_OPTIONS_ID ? RESOLVED_VIRTUAL_OPTIONS_ID : undefined),\n load: (id) => (id === RESOLVED_VIRTUAL_OPTIONS_ID ? optionsModule : undefined),\n },\n ],\n },\n });\n ctx.addMiddleware({ entrypoint: MIDDLEWARE_ENTRYPOINT, order: 'pre' });\n}\n","/**\n * Content-Security-Policy helpers.\n *\n * Two responsibilities:\n *\n * 1. Generate cryptographic nonces so consumers can opt into a strict\n * `script-src 'nonce-...'` policy and avoid `'unsafe-inline'`.\n * 2. Build the `frame-ancestors` directive value, restricting which\n * origins may embed the preview page in an iframe.\n *\n * Both functions are isomorphic — they work in browsers, Node, and\n * edge runtimes that expose Web Crypto via `globalThis.crypto`.\n *\n * @module @security/csp\n */\n\n/**\n * Default byte-length for nonces. 16 bytes → 22 base64url characters,\n * which exceeds the 128-bit entropy threshold recommended by OWASP.\n */\nconst DEFAULT_NONCE_BYTES = 16;\n\n/** CSP3's exact whitespace set: HTAB, LF, FF, CR, and SPACE. */\nconst CSP_ASCII_WHITESPACE = /[\\t\\n\\f\\r ]+/;\nconst CSP_EDGE_ASCII_WHITESPACE = /^[\\t\\n\\f\\r ]+|[\\t\\n\\f\\r ]+$/g;\n\n/** CSP names are ASCII strings; Unicode case folding must not create directives. */\nfunction asciiLowercase(value: string): string {\n return value.replace(/[A-Z]/g, (character) => character.toLowerCase());\n}\n\n/**\n * Minimal Web-Crypto surface area we actually call. The full `Crypto`\n * type drags in browser-only declarations that don't typecheck cleanly\n * against Node's `webcrypto` shape — this narrower interface accepts\n * both without an unsafe cast.\n */\ninterface WebCryptoLike {\n getRandomValues: <T extends ArrayBufferView | null>(array: T) => T;\n}\n\nlet cryptoOverride: WebCryptoLike | undefined;\n\n/**\n * Inject a Web Crypto implementation to use when `globalThis.crypto`\n * is unavailable.\n *\n * Node.js exposed `globalThis.crypto` globally starting with v19. On\n * Node 18 (still LTS at time of writing) consumers can flip the\n * `--experimental-global-webcrypto` flag *or* call this function once\n * at startup:\n *\n * ```ts\n * import { webcrypto } from 'node:crypto';\n * import { setCspCrypto } from 'payload-live-preview';\n * setCspCrypto(webcrypto as { getRandomValues: typeof webcrypto.getRandomValues });\n * ```\n *\n * Browser bundles never need to call this — `globalThis.crypto` is\n * always present there, and the override only matters when the global\n * is missing.\n *\n * Pass `null` to clear a previous override (mostly useful for tests).\n */\nexport function setCspCrypto(crypto: WebCryptoLike | null): void {\n cryptoOverride = crypto ?? undefined;\n}\n\n/**\n * Generate a base64url-encoded cryptographic nonce.\n *\n * Uses `crypto.getRandomValues` everywhere — falls back to throwing\n * if no Web Crypto implementation is available, because a predictable\n * nonce would silently defeat the entire CSP.\n *\n * @param bytes Number of random bytes (defaults to 16 → 128-bit entropy).\n */\nexport function generateCspNonce(bytes: number = DEFAULT_NONCE_BYTES): string {\n if (!Number.isInteger(bytes) || bytes < 8) {\n throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(bytes)}`);\n }\n const crypto = resolveCrypto();\n if (!crypto) {\n throw new Error(\n 'generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) ' +\n \"once at startup, or run with --experimental-global-webcrypto. We won't fabricate \" +\n 'a predictable nonce — that would silently defeat the entire CSP.',\n );\n }\n const buffer = new Uint8Array(bytes);\n crypto.getRandomValues(buffer);\n return base64UrlEncode(buffer);\n}\n\nfunction resolveCrypto(): WebCryptoLike | undefined {\n if (cryptoOverride?.getRandomValues) return cryptoOverride;\n const fromGlobal = (globalThis as { crypto?: WebCryptoLike }).crypto;\n if (fromGlobal?.getRandomValues) return fromGlobal;\n return undefined;\n}\n\nfunction base64UrlEncode(bytes: Uint8Array): string {\n let binary = '';\n for (const byte of bytes) binary += String.fromCharCode(byte);\n const base64 = typeof btoa === 'function' ? btoa(binary) : Buffer.from(bytes).toString('base64');\n return base64.replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '');\n}\n\n/**\n * Sources allowed in the `frame-ancestors` directive.\n *\n * Conceptually a union of `'self'`, `'none'`, or an explicit origin\n * string. TypeScript collapses literal-vs-string unions, so we expose\n * a `string` alias and document the special values.\n */\nexport type FrameAncestorSource = string;\n\nexport interface FrameAncestorsOptions {\n readonly self?: boolean;\n readonly origins?: readonly string[];\n readonly allowNone?: boolean;\n}\n\n/**\n * Build the value for `frame-ancestors` in a `Content-Security-Policy`\n * header.\n *\n * Returns `'none'` if `allowNone: true` and no other sources are\n * provided. Otherwise concatenates `'self'` (if requested) with the\n * given origins, deduplicating and trimming entries.\n *\n * @example\n * `frame-ancestors ${buildFrameAncestors({ self: true, origins: [adminUrl] })}`\n */\nexport function buildFrameAncestors(options: FrameAncestorsOptions = {}): string {\n const { self = true, origins = [], allowNone = false } = options;\n const seen = new Set<string>();\n const out: FrameAncestorSource[] = [];\n if (allowNone && !self && origins.length === 0) return \"'none'\";\n if (self) {\n out.push(\"'self'\");\n seen.add(\"'self'\");\n }\n for (const origin of origins) {\n const trimmed = origin.trim();\n if (trimmed.length === 0 || seen.has(trimmed)) continue;\n seen.add(trimmed);\n out.push(trimmed);\n }\n return out.length > 0 ? out.join(' ') : \"'none'\";\n}\n\n/**\n * Build a `script-src` value that permits a single nonce plus optional\n * extra sources.\n *\n * `'strict-dynamic'` is **opt-in**: under CSP 3 it makes browsers\n * ignore `'self'` and every host source in the directive, so any\n * parser-inserted script without a nonce (framework hydration scripts,\n * consumer `<script>` tags) would be blocked. Only enable it when every\n * script on the page carries the nonce.\n */\nexport function buildScriptSrcWithNonce(\n nonce: string,\n options: {\n readonly self?: boolean;\n readonly extra?: readonly string[];\n readonly strictDynamic?: boolean;\n } = {},\n): string {\n if (nonce.length === 0) throw new RangeError('buildScriptSrcWithNonce: nonce is empty');\n const { self = true, extra = [], strictDynamic = false } = options;\n const parts: string[] = [];\n if (self) parts.push(\"'self'\");\n parts.push(`'nonce-${nonce}'`);\n if (strictDynamic) parts.push(\"'strict-dynamic'\");\n for (const e of extra) {\n const trimmed = e.trim();\n if (trimmed.length > 0) parts.push(trimmed);\n }\n return parts.join(' ');\n}\n\n/**\n * How a directive is merged into an existing CSP header value.\n *\n * - `union` (default) — the new sources are added to the existing\n * directive's sources (deduplicated). An existing `'none'` is\n * dropped when real sources are added, since `'none'` may not be\n * combined with other sources.\n * - `replace` — the new value overwrites the existing directive.\n */\nexport interface CspDirectiveMerge {\n readonly value: string;\n readonly mode?: 'union' | 'replace';\n}\n\n/**\n * Merge directives into an existing `Content-Security-Policy` header\n * value without clobbering what a consumer (or another middleware)\n * already configured. Directives not mentioned in `additions` pass\n * through untouched; new directives are appended. Existing policy parsing\n * follows CSP3's ASCII-whitespace and first-duplicate-wins rules.\n *\n * This is the single CSP-merge implementation shared by every adapter.\n */\nexport function mergeCspHeader(\n existing: string,\n additions: Readonly<Record<string, string | CspDirectiveMerge>>,\n): string {\n const directives = new Map<string, string>();\n for (const part of existing.split(';')) {\n const trimmed = part.replace(CSP_EDGE_ASCII_WHITESPACE, '');\n if (trimmed.length === 0) continue;\n const whitespaceIndex = trimmed.search(CSP_ASCII_WHITESPACE);\n const name = asciiLowercase(whitespaceIndex < 0 ? trimmed : trimmed.slice(0, whitespaceIndex));\n\n // CSP3 §2.2.1 is first-wins: a user agent ignores every later\n // case-insensitive duplicate. Mirroring that rule before merging prevents a\n // later, looser duplicate from becoming the policy we serialize.\n if (directives.has(name)) continue;\n\n const value =\n whitespaceIndex < 0\n ? ''\n : trimmed.slice(whitespaceIndex).replace(CSP_EDGE_ASCII_WHITESPACE, '');\n directives.set(name, value);\n }\n\n for (const [rawName, rawAddition] of Object.entries(additions)) {\n const name = asciiLowercase(rawName);\n const addition: CspDirectiveMerge =\n typeof rawAddition === 'string' ? { value: rawAddition } : rawAddition;\n const mode = addition.mode ?? 'union';\n const current = directives.get(name);\n if (mode === 'replace' || current === undefined || current.length === 0) {\n directives.set(name, addition.value);\n continue;\n }\n const seen = new Set<string>();\n const merged: string[] = [];\n for (const token of [\n ...current.split(CSP_ASCII_WHITESPACE),\n ...addition.value.split(CSP_ASCII_WHITESPACE),\n ]) {\n if (token.length === 0 || seen.has(token)) continue;\n seen.add(token);\n merged.push(token);\n }\n // `'none'` cannot coexist with other sources.\n const withoutNone = merged.filter((token) => token !== \"'none'\");\n directives.set(name, (withoutNone.length > 0 ? withoutNone : merged).join(' '));\n }\n\n const out: string[] = [];\n for (const [name, value] of directives) {\n out.push(value.length === 0 ? name : `${name} ${value}`);\n }\n return out.join('; ');\n}\n","/**\n * Server-side preview-intent detection.\n *\n * The live-preview runtime only ever activates inside the Payload\n * admin's iframe, but the *server* still has to decide whether a\n * request expresses preview intent before doing optional preview\n * work. Adapters use this predicate as a delivery optimisation, and\n * consumers with hand-rolled middleware can import it directly.\n *\n * IMPORTANT: every signal inspected here is controlled or triggerable\n * by the client. A positive result is never proof of identity,\n * authentication, or permission to read drafts. Before forwarding\n * credentials, fetching draft data, bypassing caches, changing CSP,\n * or injecting the runtime, verify the request with an application-\n * owned server session or a short-lived signed authorization. Use the\n * same verified decision for all of those effects.\n *\n * Preview intent is present when any of these hold:\n *\n * 1. A preview query parameter is present (`?preview=true`,\n * `?draft=true`, `?livePreview=true` — configurable).\n * 2. `Sec-Fetch-Dest: iframe` — the document is being loaded as an\n * iframe, which is exactly how the Payload admin embeds it.\n * (Sent by all evergreen browsers; absence never *excludes* a\n * request, presence includes it.)\n * 3. The `Referer` points at one of the given admin origins.\n *\n * @module @adapters/shared/preview-request\n */\n\n/** The individual signals the predicate can consider. */\nexport type PreviewSignal = 'query' | 'fetch-dest' | 'referer';\n\nexport interface PreviewRequestOptions {\n /**\n * Which signals count as preview intent. Default: all three.\n * Restricting this to `['query']` reduces accidental activation, but\n * an explicit `?preview=true` is still client-controlled and must not\n * authorize response changes or privileged data access by itself.\n */\n readonly signals?: readonly PreviewSignal[];\n /**\n * Query parameters (with values `true` or `1`) that signal preview\n * intent. Default: `['preview', 'draft', 'livePreview']`.\n */\n readonly queryParams?: readonly string[];\n /**\n * Treat `Sec-Fetch-Dest: iframe` as a preview-intent signal. Default `true`.\n * Legacy alias for excluding `'fetch-dest'` from `signals`.\n */\n readonly checkFetchDest?: boolean;\n /**\n * Admin origins whose `Referer` signals preview intent, e.g.\n * `['https://cms.example.com']`. Referer matching is not HTTP-request\n * authentication.\n */\n readonly adminOrigins?: readonly string[];\n}\n\nconst DEFAULT_QUERY_PARAMS = ['preview', 'draft', 'livePreview'] as const;\n\n/**\n * The minimal request surface the predicate needs. The standard\n * `Request` satisfies it structurally, and server frameworks without\n * fetch-style requests (e.g. Nitro/H3) can supply a tiny shim.\n */\nexport interface PreviewRequestLike {\n readonly url: string;\n readonly headers: { get(name: string): string | null };\n}\n\n/**\n * Detect whether `request` carries live-preview intent. See the module\n * docblock for the exact signals and the required authorization\n * boundary. This compatibility name does not imply authentication.\n */\nexport function isPreviewRequest(\n request: PreviewRequestLike,\n options: PreviewRequestOptions = {},\n): boolean {\n const signals = new Set<PreviewSignal>(options.signals ?? ['query', 'fetch-dest', 'referer']);\n const queryParams = options.queryParams ?? DEFAULT_QUERY_PARAMS;\n const checkFetchDest = (options.checkFetchDest ?? true) && signals.has('fetch-dest');\n\n if (signals.has('query')) {\n let url: URL | undefined;\n try {\n url = new URL(request.url);\n } catch {\n url = undefined;\n }\n if (url !== undefined) {\n for (const param of queryParams) {\n const value = url.searchParams.get(param);\n if (value === 'true' || value === '1') return true;\n }\n }\n }\n\n if (checkFetchDest && request.headers.get('sec-fetch-dest') === 'iframe') {\n return true;\n }\n\n const adminOrigins = signals.has('referer') ? (options.adminOrigins ?? []) : [];\n if (adminOrigins.length > 0) {\n const referer = request.headers.get('referer');\n if (referer !== null) {\n try {\n const refererOrigin = new URL(referer).origin;\n for (const adminOrigin of adminOrigins) {\n try {\n if (new URL(adminOrigin).origin === refererOrigin) return true;\n } catch {\n // skip malformed configured origin\n }\n }\n } catch {\n // malformed referer — not a preview signal\n }\n }\n }\n\n return false;\n}\n","/**\n * Astro middleware for Payload Live Preview.\n *\n * Responsibilities (per request):\n *\n * 1. Generate a per-response CSP nonce and stash it on\n * `Astro.locals.livePreviewNonce` so consumers can reference it.\n * 2. On requests carrying **preview intent** (see\n * `isPreviewRequest`), rewrite the HTML response to inject the\n * live-preview `<script>` tag.\n * 3. On those requests, merge `frame-ancestors` into the\n * `Content-Security-Policy` header so the Payload admin may embed\n * the page. Full `script-src` nonce management is opt-in via\n * `manageCsp: 'full'`.\n *\n * The intent signals are client-controlled and this middleware does\n * not authenticate them. For protected preview responses, first verify\n * an application-owned server session or short-lived authorization,\n * then invoke this middleware with that same decision also governing\n * draft reads, credentials, and cache policy. `shouldInject` filters\n * script insertion only; it is not an authorization boundary and does\n * not disable CSP handling.\n *\n * Prerendered pages are skipped entirely: Astro runs middleware at\n * build time for those, where per-request nonces and response headers\n * are meaningless.\n *\n * @module @adapters/astro/middleware\n */\n\nimport {\n generateCspNonce,\n buildFrameAncestors,\n buildScriptSrcWithNonce,\n mergeCspHeader,\n} from '@security/csp';\nimport { generateInlineScript, wrapWithScriptTag } from '@inline/generator';\nimport { isPreviewRequest } from '@adapters/shared/preview-request';\nimport type { LivePreviewAstroOptions } from './types';\n\n// Astro type imports are deferred via a local declaration so consumers\n// without Astro installed (e.g., type-checking the library itself) can\n// still build the adapter. At runtime the function signature matches.\ntype MiddlewareNext = () => Promise<Response>;\ninterface MiddlewareContext {\n readonly request: Request;\n readonly locals: Record<string, unknown>;\n /** Present in Astro ≥ 5: `true` while prerendering at build time. */\n readonly isPrerendered?: boolean;\n}\nexport type LivePreviewMiddleware = (\n context: MiddlewareContext,\n next: MiddlewareNext,\n) => Promise<Response>;\n\n/**\n * Key on `Astro.locals` carrying the request-scoped nonce. Consumers\n * can read `Astro.locals.livePreviewNonce` from `.astro` templates to\n * set the `nonce` attribute on their own scripts.\n */\nexport const NONCE_LOCALS_KEY = 'livePreviewNonce';\n\nconst HTML_CONTENT_TYPE = /text\\/html/i;\nconst HEAD_INSERT = /<head(\\s[^>]*)?>/i;\n\n/**\n * Build the Astro-compatible middleware. Register it in\n * `src/middleware.ts`:\n *\n * ```ts\n * import { createLivePreviewMiddleware } from 'payload-live-preview/astro';\n * export const onRequest = createLivePreviewMiddleware({\n * allowedOrigins: [import.meta.env.PUBLIC_PAYLOAD_ADMIN_ORIGIN],\n * });\n * ```\n */\nexport function createLivePreviewMiddleware(\n options: LivePreviewAstroOptions = {},\n): LivePreviewMiddleware {\n const allowedOrigins = options.allowedOrigins ?? [];\n const autoInject = options.autoInject ?? true;\n const injectMode = options.inject ?? 'preview-only';\n const manageCsp = normalizeManageCsp(options.manageCsp);\n const shouldInject = options.shouldInject;\n\n // The script body is configuration-static (the nonce only decorates\n // the surrounding tag) — generate it once, not per request.\n let cachedScriptBody: string | undefined;\n const scriptBody = (): string => {\n cachedScriptBody ??= generateInlineScript({\n ...(options.allowedOrigins !== undefined ? { allowedOrigins: options.allowedOrigins } : {}),\n ...(options.serverURL !== undefined ? { serverURL: options.serverURL } : {}),\n ...(options.apiRoute !== undefined ? { apiRoute: options.apiRoute } : {}),\n ...(options.mergeDepth !== undefined ? { mergeDepth: options.mergeDepth } : {}),\n ...(options.debug !== undefined ? { debug: options.debug } : {}),\n ...(options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {}),\n ...(options.heartbeatMs !== undefined ? { heartbeatMs: options.heartbeatMs } : {}),\n });\n return cachedScriptBody;\n };\n\n return async (context, next) => {\n const nonce = generateCspNonce();\n context.locals[NONCE_LOCALS_KEY] = nonce;\n\n const response = await next();\n\n // Build-time prerendering: no meaningful request headers, no\n // response headers in the static output, and a baked-forever nonce.\n if (context.isPrerendered === true) return response;\n\n const isPreview =\n injectMode === 'always' ||\n isPreviewRequest(context.request, {\n ...(options.previewQueryParams !== undefined\n ? { queryParams: options.previewQueryParams }\n : {}),\n ...(options.previewSignals !== undefined ? { signals: options.previewSignals } : {}),\n adminOrigins: allowedOrigins,\n });\n if (!isPreview) return response;\n\n let outResponse = response;\n\n const contentType = response.headers.get('content-type') ?? '';\n const apply = autoInject && (shouldInject?.(context.request) ?? true);\n if (apply && HTML_CONTENT_TYPE.test(contentType)) {\n outResponse = await injectScript(response, nonce, scriptBody());\n }\n\n if (manageCsp !== false) {\n outResponse = applyCspHeaders(outResponse, nonce, allowedOrigins, manageCsp, options);\n }\n\n return outResponse;\n };\n}\n\nfunction normalizeManageCsp(\n value: LivePreviewAstroOptions['manageCsp'],\n): false | 'frame-ancestors' | 'full' {\n if (value === false) return false;\n if (value === 'full') return 'full';\n // `true` (legacy) and `undefined` both mean the safe default.\n return 'frame-ancestors';\n}\n\nasync function injectScript(response: Response, nonce: string, body: string): Promise<Response> {\n const html = await response.text();\n const headers = new Headers(response.headers);\n headers.delete('content-length');\n\n // Fragment responses (server islands, page partials) have no <head>;\n // injecting a roughly 60 KB runtime into each of them would corrupt every\n // fragment for zero benefit — the full document already carries it.\n if (!HEAD_INSERT.test(html)) {\n return new Response(html, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n }\n\n const scriptTag = wrapWithScriptTag(body, { nonce });\n const out = html.replace(HEAD_INSERT, (match) => `${match}${scriptTag}`);\n return new Response(out, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n}\n\nfunction applyCspHeaders(\n response: Response,\n nonce: string,\n allowedOrigins: readonly string[],\n mode: 'frame-ancestors' | 'full',\n options: LivePreviewAstroOptions,\n): Response {\n const frameAncestors = buildFrameAncestors({\n self: true,\n origins: [...allowedOrigins, ...(options.frameAncestorsExtra ?? [])],\n });\n\n const additions: Record<string, string> = { 'frame-ancestors': frameAncestors };\n if (mode === 'full') {\n additions['script-src'] = buildScriptSrcWithNonce(nonce, {\n self: true,\n strictDynamic: options.strictDynamic ?? false,\n ...(options.scriptSrcExtra !== undefined ? { extra: options.scriptSrcExtra } : {}),\n });\n }\n\n const previous = response.headers.get('content-security-policy') ?? '';\n const next = mergeCspHeader(previous, additions);\n\n // Responses passed through from `fetch()` can carry immutable\n // headers — clone into a mutable Response instead of mutating.\n try {\n response.headers.set('content-security-policy', next);\n return response;\n } catch {\n const headers = new Headers(response.headers);\n headers.set('content-security-policy', next);\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n }\n}\n","/**\n * Helpers for embedding the live preview manually in `.astro` templates.\n *\n * Most consumers should prefer the `livePreview()` integration which\n * auto-injects the script. This module exists for advanced cases where\n * the script needs to live inside a specific layout or behind a\n * conditional.\n *\n * Usage in a `.astro` file:\n *\n * ```astro\n * ---\n * import { renderLivePreviewScript } from 'payload-live-preview/astro';\n * const script = renderLivePreviewScript({\n * allowedOrigins: ['https://admin.example.com'],\n * nonce: Astro.locals.livePreviewNonce,\n * });\n * ---\n * <Fragment set:html={script} />\n * ```\n *\n * @module @adapters/astro/component\n */\n\nimport { generateInlineScript, wrapWithScriptTag } from '@inline/generator';\nimport type { LivePreviewAstroOptions } from './types';\n\nexport interface RenderScriptOptions extends LivePreviewAstroOptions {\n /**\n * CSP nonce to set on the `<script>` tag. Read from\n * `Astro.locals.livePreviewNonce` after registering the live-preview\n * middleware.\n */\n readonly nonce?: string;\n}\n\n/**\n * Render the full `<script>` tag (wrapped with attributes) for embedding\n * in a `.astro` layout. The result is a single string suitable for\n * `set:html={…}`.\n */\nexport function renderLivePreviewScript(options: RenderScriptOptions = {}): string {\n const body = generateInlineScript({\n ...(options.allowedOrigins !== undefined ? { allowedOrigins: options.allowedOrigins } : {}),\n ...(options.serverURL !== undefined ? { serverURL: options.serverURL } : {}),\n ...(options.apiRoute !== undefined ? { apiRoute: options.apiRoute } : {}),\n ...(options.mergeDepth !== undefined ? { mergeDepth: options.mergeDepth } : {}),\n ...(options.debug !== undefined ? { debug: options.debug } : {}),\n ...(options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {}),\n ...(options.heartbeatMs !== undefined ? { heartbeatMs: options.heartbeatMs } : {}),\n ...(options.nonce !== undefined ? { nonce: options.nonce } : {}),\n });\n return wrapWithScriptTag(body, options.nonce !== undefined ? { nonce: options.nonce } : {});\n}\n"],"mappings":"AAEO,IAAAA,EAAAC,OAAAC,eAAAC,EAAA,CAAAC,EAAAC,IAAAL,EAAAI,EAAA,QAAAE,MAAAD,EAAAE,cAAA,IAAMC,EAAyB,09/DCqG/B,SAASC,EAAqBC,EAA6B,IAChE,GAA8B,IAA1BF,EAAeG,OACjB,MAAM,IAAIC,MACR,8FAKJ,IAAMC,EAA2B,CAC/BH,EAAOI,eACPJ,EAAOK,UACPL,EAAOM,SACPN,EAAOO,WACPP,EAAOQ,MACPR,EAAOS,WACPT,EAAOU,WACPV,EAAOW,YACPX,EAAOY,sBACP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,CAAEA,MAAOmB,EAAQnB,OAAU,WAClC,IAAvBmB,EAAQlB,WAA2B,CAAEA,WAAYkB,EAAQlB,YAAe,WAChD,IAAxBkB,EAAQhB,YAA4B,CAAEA,YAAagB,EAAQhB,aAAgB,WACzD,IAAlBgB,EAAQC,MAAsB,CAAEA,MAAOD,EAAQC,OAAU,UAEd,IAAlBD,EAAQC,MAAsB,CAAEA,MAAOD,EAAQC,OAAU,GAC1F,CDuBgBI,EAAA4G,EAAA,+BA8DP5G,EAAAiH,EAAA,sBASMjH,EAAAW,EAAA,gBAyBNX,EAAA6H,EAAA,mBCnIO7H,EAAAyI,EAAA,kCAAAC,sBAAAC,iCAAAC,sBAAAC,iBAAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["I","Object","defineProperty","s","e","t","value","configurable","RUNTIME_SOURCE","generateInlineScript","config","length","Error","compactConfig","allowedOrigins","serverURL","apiRoute","mergeDepth","debug","debounceMs","enableA11y","heartbeatMs","disableVisibilityGate","visibilityGateThreshold","intersectionRootMargin","disableReferrerDetection","disableLocalhostMatching","scopeBindingsByOwner","at","pop","map","JSON","stringify","join","replace","wrapWithScriptTag","body","options","nonce","escapeNonce","test","RangeError","__name","VIRTUAL_OPTIONS_ID","RESOLVED_VIRTUAL_OPTIONS_ID","livePreview","name","hooks","ctx","mode","setupMiddlewareMode","autoInject","script","injectScript","addMiddleware","updateConfig","shouldInject","_mode","_shouldInject","serializable","optionsModule","vite","plugins","resolveId","id","load","entrypoint","order","CSP_ASCII_WHITESPACE","CSP_EDGE_ASCII_WHITESPACE","asciiLowercase","character","toLowerCase","generateCspNonce","bytes","Number","isInteger","String","crypto","resolveCrypto","buffer","Uint8Array","getRandomValues","base64UrlEncode","fromGlobal","globalThis","binary","byte","fromCharCode","btoa","Buffer","from","toString","replaceAll","buildFrameAncestors","self","origins","allowNone","seen","Set","out","push","add","origin","trimmed","trim","has","buildScriptSrcWithNonce","extra","strictDynamic","parts","mergeCspHeader","existing","additions","directives","Map","part","split","whitespaceIndex","search","slice","set","rawName","rawAddition","entries","addition","current","get","merged","token","withoutNone","filter","DEFAULT_QUERY_PARAMS","isPreviewRequest","request","signals","queryParams","checkFetchDest","url","URL","param","searchParams","headers","adminOrigins","referer","refererOrigin","adminOrigin","NONCE_LOCALS_KEY","HTML_CONTENT_TYPE","HEAD_INSERT","createLivePreviewMiddleware","cachedScriptBody","injectMode","inject","manageCsp","normalizeManageCsp","scriptBody","async","context","next","locals","response","isPrerendered","previewQueryParams","previewSignals","outResponse","contentType","applyCspHeaders","html","text","Headers","delete","Response","status","statusText","scriptTag","match","frameAncestorsExtra","scriptSrcExtra","renderLivePreviewScript","C","U","b","E","z"],"sources":["../../../src/inline/runtime.generated.ts","../../../src/inline/generator.ts","../../../src/adapters/astro/integration.ts","../../../src/security/csp.ts","../../../src/adapters/shared/preview-request.ts","../../../src/adapters/astro/middleware.ts","../../../src/adapters/astro/component.ts"],"sourcesContent":["// Auto-generated by scripts/build-runtime.ts — do not edit.\nexport interface RuntimeBuildInfo { readonly generatedAt: string; readonly size: number }\nexport const RUNTIME_SOURCE: string = \"(()=>{function t(t){return(\\\"object\\\"!=typeof t||null===t)&&\\\"function\\\"!=typeof t||\\\"function\\\"!=typeof t.then?0:(Promise.resolve(t).catch(()=>{}),1)}function e(e){return(...i)=>{try{t(e(...i))}catch{}}}function i(){}function n(){return 1}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?0: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 0;let e=t;return e.hasAttribute(ke)?1:null!==e.querySelector(`[${ke}]`)}function h(t){if(!Array.isArray(t))return[];let e=[];for(let i of t){let t=c(i);t&&e.push(t)}return e}function c(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 d(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?1:e(t)}function g(t){if(\\\"object\\\"!=typeof t||null===t)return 0;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 1}return 0}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 0;try{return encodeURIComponent(t),1}catch{return 0}}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 0;let e=t.trim();if(0===e.length||$i.test(e))return 0;if(e.startsWith(\\\"#\\\")||e.startsWith(\\\"?\\\")||e.startsWith(\\\"//\\\")||e.startsWith(\\\"/\\\"))return 1;try{let t=new URL(e);return Si.has(t.protocol)}catch{return Ai.test(e)}}function S(t){if(!w(t))return 0;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=0){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=1;for(let t of e.split(\\\".\\\")){if(Pi.has(t)||null===i||\\\"object\\\"!=typeof i){n=0;break}if(i=T(i,t),void 0===i){n=0;break}}if(n)return i}return void 0===i?void 0:T(t,`${e}_${i}`)}function T(t,e){if(!Pi.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(zi.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 j(t){if(\\\"object\\\"!=typeof t||null===t)return;let e=t.id;return\\\"string\\\"==typeof e||\\\"number\\\"==typeof e?e:void 0}function I(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!==j(t))?function(t,e){let i=[],n=new Map;for(let e=0;e<t.length;e+=1){let i=j(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=j(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];I(u)===I(s)?(a!==l&&i.push({kind:\\\"move\\\",from:a,to:l,value:s}),R(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)R(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 R(t,e){if(Object.is(t,e))return 1;if(\\\"object\\\"!=typeof t||\\\"object\\\"!=typeof e||null===t||null===e)return 0;let i=t,n=e,r=Object.keys(i),l=Object.keys(n);if(r.length!==l.length)return 0;for(let t of r)if(!Object.is(i[t],n[t]))return 0;return 1}function _(t){return 9===t.nodeType}function L(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 W(t,e){return t.generation===e.generation&&t.revision===e.revision}function P(t){return null==t?0:\\\"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 0;try{return window.self!==window.top}catch{return 1}}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||!wn.test(t.origin)?void 0:t.origin}catch{return}}function V(t,e){let i=G();if(!i)throw new Rn(\\\"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(On))t.set(e,i);return{allowedTags:Tn,attrByTag:t}}let e=new Set(Tn);for(let i of t.additionalAllowedTags??[])e.add(i);let i=new Map;for(let[t,e]of Object.entries(On))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===In?H(i,e):i.nodeType===En&&i.remove()}function H(t,e){let i=t.tagName.toLowerCase();if(Nn.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(!(xn.has(i)||i.startsWith(Mn)||i.startsWith(Cn))){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 0}return 1}function J(t,e){_n.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=Ln[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(Fn,t=>Pn[t])}function tt(t){return\\\"\\\"===t?\\\"\\\":t.replace(Un,t=>Dn[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 Gn.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 0;let e=t.root;return\\\"object\\\"==typeof e&&null!==e&&\\\"children\\\"in e?Array.isArray(e.children):0}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 _n.get(t)}(t.type);return e?e(t,Lt):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 ct(){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(Wt))return function(t,e,i){t.has(e)||(t.add(e),pe(`[live-preview] 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),0;r.includes(\\\"\\\\n\\\")||r.includes(\\\"\\\\r\\\")?n.innerHTML=et(r):n.textContent=r}else n.value=r})}}function dt(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 dt(t)}function gt(t){return Array.isArray(t)?t.map(t=>gt(t)).join(\\\", \\\"):dt(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,dt)}function St(t){return dt(t)}function $t(t){let{template:e,container:i,patches:n,nextItems:r,store:l,forceRender:s=0}=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=jt(o,te),u=new Set,h=[];for(let c=0;c<i.length;c+=1){let d=i[c],f=Ot(d),p=void 0===f?o[c]??null:It(a,f)??null;null!==p&&u.has(p)&&(p=null),null!==p&&u.add(p);let g=n.replaces.has(c),m=r||n.renders.has(c)||null===p?Et(t.ownerDocument,e,d,c):void 0;if(null===m)return null;let y=void 0===m?[]:Tt(g?null:p,m,d,l,s);if(null===y)return null;h.push([c,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=0;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=1),u=o}if(null===u)continue;let h=i.children[n]??null;u!==h&&(i.insertBefore(u,h),s=1),l.add(u)}for(let t of Array.from(i.children))l.has(t)||(t.remove(),s=1);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=jt(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=It(l,e)??null,u=t.getAttribute(ie),h=u?s:null,c=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&&c!==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 0;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 jt(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 It(t,e){return t.get(e)?.pop()}function Et(t,e,i,n){let r=function(t,e,i){return bt(t,e,i,dt)}(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 Rt(){let t=new WeakMap,e=new WeakSet,i=new WeakMap;return{name:\\\"structural-array\\\",render:$((n,r)=>{if(!Array.isArray(r))return 0;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] 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),0;let o=t.get(l),a=_t(l),u=o?.values??function(t){return t.map((t,e)=>null===t?{__payloadDomPosition:e}:{id:t})}(a),h=E(u,r),c=function(t,e,i){return void 0===t?1:t.template!==e||!function(t,e){return t.length!==e.length?0:t.every((t,i)=>t===e[i])}(t.domSnapshot,i)}(o,s,a);if(0===h.length&&!c)return t.set(l,{values:r.slice(),template:s,domSnapshot:a}),0;let d=$t({template:s,container:l,patches:h,nextItems:r,store:i,forceRender:c});return null===d?0:(t.set(l,{values:r.slice(),template:s,domSnapshot:_t(l)}),d?void 0:0)})}}function _t(t){return Array.from(t.children,t=>t.getAttribute(te))}var Lt,Wt,Pt,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:1,configurable:1,writable:1,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),ce=(t,e,i,n)=>(ae(t,e,\\\"write to private field\\\"),n?n.call(t,i):e.set(t,i),i),de=(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 de(this,be,Se).call(this,ue(this,ye),t,e)}once(t,e){return de(this,be,Se).call(this,ue(this,ve),t,e)}off(t,e){de(this,be,$e).call(this,ue(this,ye),t,e),de(this,be,$e).call(this,ue(this,ve),t,e)}async emit(t,e){await de(this,be,we).call(this,t,e)}async emitWhile(t,e,i){return de(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?.()??1;if(!n())return 0;let r=ue(this,ye).get(t);if(r)for(let i of[...r])if(!n()||(await de(this,be,Ae).call(this,i,e,t),!n()))return 0;if(!n())return 0;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 de(this,be,Ae).call(this,r,e,t),!n()))return 0}return n()},Se=function(t,e,i){let n=t.get(e);return n||(n=new Set,t.set(e,n)),n.add(i),()=>{de(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] 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\\\",je=\\\"data-payload-array-separator\\\",Ie=\\\"data-payload-locale\\\",Ee=\\\"data-payload-richtext\\\",Re=\\\"data-payload-html\\\",_e=\\\"data-payload-array\\\",Le=\\\"data-payload-structural\\\",We=\\\"data-payload-owner\\\",Pe=[ke,Te,Ne,xe,Me,Ce,Oe,je,Ie,Ee,Re,_e,Le,We,\\\"type\\\"],Fe=`[${ke}]`,De=`[${We}]`,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);ce(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)?de(this,He,Ye).call(this,t):void 0,i=ue(this,Ge).get(t);if(void 0!==e)return void 0!==i&&de(this,He,qe).call(this,i,e)?(ue(this,Ge).set(t,e),e):(void 0!==i&&de(this,He,Je).call(this,t,i),de(this,He,Xe).call(this,e),ue(this,Ge).set(t,e),e);void 0!==i&&de(this,He,Je).call(this,t,i)}remove(t){let e=ue(this,Ge).get(t);return e?de(this,He,Je).call(this,t,e):0}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(),ce(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 0;let i=ue(this,Ve).get(t.fieldName);if(!i)return 0;let n=i.indexOf(t);return n<0?0:(i[n]=e,1)},Je=function(t,e){let i=ue(this,Ve).get(e.fieldName);if(!i)return ue(this,Ge).delete(t),0;let n=i.indexOf(e);return n<0?(ue(this,Ge).delete(t),0):(i.splice(n,1),0===i.length&&ue(this,Ve).delete(e.fieldName),ue(this,Ge).delete(t),1)},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(Re))return\\\"html\\\";if(t.hasAttribute(Le))return\\\"structural-array\\\";if(t.hasAttribute(_e))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(je),h=t.getAttribute(Ie),c=function(t){let e=t.closest(De)?.getAttribute(We);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!==c?{owner:c}:{}}},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=>{de(this,Qe,ti).call(this,t,i)}),r=new IntersectionObserver(t=>{de(this,Qe,ei).call(this,t,i)},{rootMargin:this.s[2],threshold:0}),n.observe(t,{childList:1,subtree:1,attributes:1,attributeFilter:[...Pe]})}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(!de(this,Qe,ii).call(this,e)||!function(t){for(let e of t){if(\\\"attributes\\\"===e.type&&null!==e.attributeName&&Pe.includes(e.attributeName)&&(e.attributeName===ke||e.attributeName===We||e.target.nodeType===Ze&&e.target.hasAttribute(ke)))return 1;for(let t of e.addedNodes)if(u(t))return 1;for(let t of e.removedNodes)if(u(t))return 1}return 0}(t)||!de(this,Qe,ii).call(this,e))return;null!==this.s[6]&&clearTimeout(this.s[6]);let i=setTimeout(()=>{!de(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(!de(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,1),!de(this,Qe,ii).call(this,e)))return}else if(this.s[3].has(t)&&(this.s[3].delete(t),this.s[0].onVisibilityChange(t,0),!de(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=0,i=t=>{if(!e||this.s[2]!==i)return;let n=this.s[4];try{de(this,li,si).call(this,t,n)}catch{let e=\\\"\\\";try{e=t.origin}catch{}de(this,li,ci).call(this,\\\"shape\\\",e,n)}};this.s[4]+=1,de(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,de(this,li,mi).call(this));try{t.removeEventListener(\\\"message\\\",i)}catch{}throw e}if(this.s[2]===i)e=1;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,de(this,li,mi).call(this),e.removeEventListener(\\\"message\\\",i))}advanceGeneration(){return void 0===this.s[3]?0:(this.s[4]+=1,de(this,li,mi).call(this),1)}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(!de(this,li,pi).call(this,e))return;let i=t.origin;if(!de(this,li,pi).call(this,e))return;if(!de(this,li,di).call(this,i,e)){de(this,li,ci).call(this,\\\"origin\\\",i,e);return}let n=t.data;if(!de(this,li,pi).call(this,e))return;let r=function(t){return\\\"object\\\"==typeof t&&null!==t&&\\\"type\\\"in t?\\\"string\\\"==typeof t.type:0}(n);if(!de(this,li,pi).call(this,e))return;if(!r){de(this,li,ci).call(this,\\\"shape\\\",i,e);return}let l=n.type;if(de(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(!de(this,li,pi).call(this,e))return;if(!t){de(this,li,ci).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(!de(this,li,pi).call(this,e))return;de(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(!de(this,li,pi).call(this,e))return;if(!t){de(this,li,ci).call(this,\\\"shape\\\",i,e);return}let r;try{r=this.s[1].onDocumentEvent}catch{return}if(!de(this,li,pi).call(this,e))return;de(this,li,fi).call(this,r,n,i);return}default:de(this,li,ci).call(this,\\\"type\\\",i,e)}},oi=function(t,e,i){if(!de(this,li,pi).call(this,i))return;let n=t.data;if(!de(this,li,pi).call(this,i))return;let r=g(n);if(!de(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(!de(this,li,pi).call(this,i))return;if(void 0===l){de(this,li,hi).call(this,t,e,i,s);return}if(1==t.ready&&void 0===n){de(this,li,hi).call(this,t,e,i,void 0);return}let o={generation:i,message:t,origin:e,messageRevision:s,settled:0,approved:0};this.s[6].push(o);let a;try{a=l(t.previewToken,e)}catch{de(this,li,ai).call(this,o,0);return}\\\"boolean\\\"!=typeof a?Promise.resolve(a).then(t=>{de(this,li,ai).call(this,o,1==t)},()=>{de(this,li,ai).call(this,o,0)}):de(this,li,ai).call(this,o,a)},ai=function(t,e){de(this,li,pi).call(this,t.generation)&&(t.approved=e,t.settled=1,de(this,li,ui).call(this,t.generation))},ui=function(t){for(;de(this,li,pi).call(this,t);){let e=this.s[6][this.s[7]];if(void 0===e)return;if(de(this,li,di).call(this,e.origin,t)){if(!e.settled)return;de(this,li,gi).call(this,e)&&(e.approved?de(this,li,hi).call(this,e.message,e.origin,e.generation,e.messageRevision):de(this,li,ci).call(this,\\\"token\\\",e.origin,e.generation))}else{if(!de(this,li,gi).call(this,e))continue;de(this,li,ci).call(this,\\\"origin\\\",e.origin,e.generation)}}},hi=function(t,e,i,n){if(!de(this,li,pi).call(this,i))return;let r;try{r=this.s[1].onUpdate}catch{return}de(this,li,pi).call(this,i)&&(void 0===n?de(this,li,fi).call(this,r,t,e):de(this,li,fi).call(this,r,t,e,n))},ci=function(t,e,i){if(!de(this,li,pi).call(this,i))return;let n;try{n=this.s[1].onInvalid}catch{return}de(this,li,pi).call(this,i)&&void 0!==n&&de(this,li,fi).call(this,n,t,e)},di=function(t,e){if(!de(this,li,pi).call(this,e))return 0;try{return 1==this.s[0](t)&&de(this,li,pi).call(this,e)}catch{return 0}},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?0:(e[7]+=1,e[7]===e[6].length?(de(this,li,mi).call(this),1):(e[7]>=1024&&2*e[7]>=e[6].length&&(e[6]=e[6].slice(e[7]),e[7]=0),1))},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 0;let e=this.s[0];return this.s[0]=t,this.s[1](t,e),1}},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 0;try{return encodeURIComponent(t),1}catch{return 0}}(t.data.id):0}catch{return 0}}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:0,...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??0,e.getCacheSize,e.onFlush,i,n,new Map,new Map,new Set,null,0,null,0,null,0]}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}),de(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||(de(this,Mi,Wi).call(this),de(this,Mi,_i).call(this),this.s[16]=t,this.s[17]=0)}cancelRevision(t){A(t,this.s[16])&&(de(this,Mi,Wi).call(this),de(this,Mi,_i).call(this),this.s[17]=1)}flushNow(){return de(this,Mi,Wi).call(this),de(this,Mi,ji).call(this)}notifyVisible(t){let e=this.s[10],i=e.get(t);if(!i||(e.delete(t),!de(this,Mi,Ii).call(this,i)))return;let n=performance.now(),r=de(this,Mi,Ei).call(this,i)?1:0;this.s[6]?.(de(this,Mi,Li).call(this,i,r,0,performance.now()-n))}retarget(t){de(this,Mi,Ri).call(this,this.s[9],t),de(this,Mi,Ri).call(this,this.s[10],t);for(let e of this.s[11])de(this,Mi,Ri).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(){de(this,Mi,Wi).call(this),de(this,Mi,_i).call(this),this.s[16]=null,this.s[17]=0}get pendingCount(){return this.s[9].size}get replayCount(){return this.s[10].size}},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,de(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=0,n=this.s[7](()=>{this.s[15]===t&&(i=1,this.s[14]=null,de(this,Mi,ji).call(this))});!i&&this.s[15]===t&&(this.s[14]=n)},ji=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=0;this.s[11].add(i);try{for(let t of i.values()){if(!de(this,Mi,Ii).call(this,t))continue;let i=!e||this.s[2](t.target.element);if(de(this,Mi,Ii).call(this,t)){if(n??(n=t),!i){this.s[10].set(t.target.element,t),l+=1;continue}this.s[10].delete(t.target.element),de(this,Mi,Ei).call(this,t)&&(r+=1)}}}finally{this.s[11].delete(i)}let s=de(this,Mi,Li).call(this,n,r,l,performance.now()-t);return this.s[6]?.(s),s},Ii=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 0!=e(t)||!function(t){return Ni.has(t)}(e)},Ri=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}},_i=function(){this.s[9].clear(),this.s[10].clear();for(let t of this.s[11])t.clear()},Li=function(t,e,i,n){return{applied:e,deferred:i,durationMs:n,...void 0!==t?.identity?{identity:t.identity}:{},...void 0!==t?.data?{data:t.data}:{}}},Wi=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)},Pi=new Set([\\\"__proto__\\\",\\\"prototype\\\",\\\"constructor\\\"]),Fi=\\\"payload-live-preview-a11y\\\",Di=new WeakMap,Ui=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=Di.get(t);return e??(e=[null,0,null,0,null]),Di.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(Fi);return e[1]=null===n,n||(n=t.createElement(\\\"div\\\"),n.id=Fi,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,Di.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}},zi=new Set([\\\"tabs\\\",\\\"row\\\",\\\"collapsible\\\"]),Vi={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\\\"},Gi=[0,500,1e3,2e3],Bi=class{constructor(t){he(this,Hi);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??L,h=t.onHeartbeatTimeout,c=void 0===t.log?i:e(t.log),f=void 0===t.warn?pe:e(t.warn),p=function(t){if(0==t.enableA11y)return null;let e=void 0===t.root?void 0:9===t.root.nodeType?t.root:t.root.ownerDocument;return new Ui(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)=>{c(...t)}}):null,m=new ze,y=new Ke({onStructuralChange:()=>{de(this,Hi,Ki).call(this)},onVisibilityChange:(t,e)=>{e&&this.d[3].notifyVisible(t)}},{...void 0!==t.intersectionRootMargin?{intersectionRootMargin:t.intersectionRootMargin}:{}}),v=new xi($(t=>de(this,Hi,dn).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=>{de(this,Hi,fn).call(this,t)}}),b=new ri(t.originMatcher,{onUpdate:(t,e,i)=>{de(this,Hi,tn).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\\\"})}c(\\\"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:()=>{de(this,Hi,pn).call(this)}});this.d=[n,m,y,v,b,w,S,r,l,s,o,a,u,h,c,f,[],p,g,1==t.scopeBindingsByOwner],this.l=[void 0,void 0,void 0,d(void 0),0,null,0,null,new Set,0,0]}start(){if(this.l[4])return 0;this.l[4]=1;let t=this.d[10];if(_(t)&&\\\"loading\\\"===t.readyState){let e=()=>{if(this.l[4]){this.l[5]=null;try{de(this,Hi,qi).call(this)}catch(t){de(this,Hi,Xi).call(this),de(this,Hi,mn).call(this,t,\\\"startup\\\")}}};this.l[5]=e;try{t.addEventListener(\\\"DOMContentLoaded\\\",e,{once:1})}catch(t){throw de(this,Hi,Xi).call(this),t}return 1}try{return de(this,Hi,qi).call(this),1}catch(t){throw de(this,Hi,Xi).call(this),t}}destroy(){this.l[4]&&(de(this,Hi,Ji).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]&&de(this,Hi,Ki).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]}},Hi=new WeakSet,qi=function(){if(!this.l[4])return;let t=_(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),de(this,Hi,Zi).call(this),de(this,Hi,hn).call(this)&&(this.d[4].attach(),this.d[0].emitWhile(\\\"init\\\",{timestamp:Date.now()},()=>this.l[4]),de(this,Hi,hn).call(this)))for(let t of Gi){if(!de(this,Hi,hn).call(this))return;if(0===t){if(this.d[12](this.d[11]),!de(this,Hi,hn).call(this))return}else{let e=setTimeout(()=>{this.l[4]&&de(this,Hi,gn).call(this)},t);this.d[16].push(e)}}},Ji=function(){this.l[7]=null,this.l[4]=0;let t=this.l[5];this.l[5]=null,null!==t&&_(this.d[10])&&de(this,Hi,Yi).call(this,()=>{this.d[10].removeEventListener(\\\"DOMContentLoaded\\\",t)});for(let t of this.d[16])de(this,Hi,Yi).call(this,()=>{clearTimeout(t)});return this.d[16].length=0,de(this,Hi,Yi).call(this,()=>{this.d[6].stop()}),de(this,Hi,Yi).call(this,()=>{this.d[4].detach()}),de(this,Hi,Yi).call(this,()=>{this.d[2].stop()}),de(this,Hi,Yi).call(this,()=>{this.d[3].destroy()}),de(this,Hi,Yi).call(this,()=>{this.d[18]?.destroy()}),this.d[1].clear(),this.d[5].markDisconnected()},Xi=function(){de(this,Hi,Ji).call(this),de(this,Hi,Yi).call(this,()=>{this.d[17]?.detach()})},Yi=function(t){try{t()}catch(t){this.d[14](\\\"cleanup failed:\\\",t)}},Zi=function(){if(!this.l[4])return;let t=this.d[1].buildFromRoot(this.d[10]);if(this.d[14](\\\"cache\\\",t),de(this,Hi,hn).call(this)&&(this.d[0].emitWhile(\\\"cacheRefresh\\\",t,()=>this.l[4]),de(this,Hi,hn).call(this)))for(let t of this.d[1].values()){if(!de(this,Hi,hn).call(this))return;this.d[2].observeElement(t.element)}},Ki=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(de(this,Hi,Zi).call(this),de(this,Hi,hn).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)}},Qi=function(t){let e=d(t);e.negotiated!==this.l[3].negotiated&&(this.l[3]=e,this.d[14](\\\"protocol\\\",\\\"ours=4\\\",`theirs=${t}`,`negotiated=${e.negotiated}`))},tn=function(t,e,i){if(this.d[6].kick(),void 0===t.data){void 0!==t.protocolVersion&&de(this,Hi,Qi).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:0};this.l[7]=n,this.d[3].acceptRevision(i),this.l[6]+=1,(void 0===t.protocolVersion||(de(this,Hi,Qi).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))||de(this,Hi,en).call(this,n))},en=async function(t){let e=await de(this,Hi,nn).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=1,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&&de(this,Hi,rn).call(this,t,n)},nn=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},rn=function(t,e){if(!this.l[4]||this.l[7]!==t)return;let i=()=>this.l[4]&&this.l[7]===t,n=de(this,Hi,ln).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(0!=n&&!o(s.owner,n))continue;let l=k(e.fields,r,s.locale??t.locale,void 0!==s.locale);if(void 0===l)continue;if(!this.l[4]||this.l[7]!==t)return;let a=de(this,Hi,un).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)}}de(this,Hi,an).call(this,e.fields,t.locale,n)},ln=function(t,e){if(!this.d[19])return 0;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]=1,this.d[15](\\\"[live-preview] scopeBindingsByOwner: update names no document; nothing applied\\\")),n},sn=function(t){for(let e of this.d[1].values())if(o(e.owner,t))return 1;return 0},on=function(t,e){let i=this.d[1].get(t);return void 0===i?0:0==e?1:i.some(t=>o(t.owner,e))},an=function(t,e,i){if(0===this.d[1].fieldCount||0!=i&&!de(this,Hi,sn).call(this,i))return;let n;for(let[r,l]of Object.entries(t)){if(this.l[8].has(r)||vn.has(r)||!P(l))continue;let t=F(r,e);if(!(de(this,Hi,on).call(this,r,i)||t!==r&&de(this,Hi,on).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)0!=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] 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.`))}}},un=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\\\"}),i}},hn=function(){return this.l[4]},cn=function(t){0!==t.deferred&&(this.l[10]||(this.l[10]=1,this.d[15](`[live-preview] visibility gate held ${String(t.deferred)} offscreen update(s) until scrolled into view; see visibilityGateThreshold.`)))},dn=function(t){let e=this.l[7];if(null===e||void 0===t.identity||!W(e.identity,t.identity)||!this.l[4]||this.l[7]!==e)return 0;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(Vi,t))return Vi[t]}(e);if(void 0!==t)return t}return t.fieldType}(t.target,i?.type);\\\"text\\\"===r&&1!=t.target.explicitFieldType&&function(t){if(\\\"object\\\"!=typeof t||null===t||!(\\\"root\\\"in t))return 0;let e=t.root;return\\\"object\\\"!=typeof e||null===e?0: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 0;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile(\\\"error\\\",{error:i,context:\\\"renderer\\\"},()=>this.l[4]&&this.l[7]===e),0}if(!this.l[4]||this.l[7]!==e)return 0;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 0;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] refused to write field \\\"${t.target.fieldName}\\\" into attribute \\\"${t.target.targetAttribute}\\\" (unsafe attribute or value)`),0}else{if(!l)return this.d[14](\\\"no renderer for\\\",r),0;if(0==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 0}}catch(t){if(!this.l[4]||this.l[7]!==e)return 0;let i=t instanceof Error?t:new Error(String(t));return this.d[0].emitWhile(\\\"error\\\",{error:i,context:\\\"renderer\\\"},()=>this.l[4]&&this.l[7]===e),0}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):0},fn=function(t){de(this,Hi,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||!W(n.identity,e))return;let r=()=>this.l[4]&&this.l[7]===n&&W(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)},pn=function(){if(!de(this,Hi,hn).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)}de(this,Hi,hn).call(this)&&(e&&de(this,Hi,yn).call(this)&&(this.d[17]?.announceDisconnected(),this.d[0].emitWhile(\\\"disconnect\\\",{reason:\\\"timeout\\\",timestamp:Date.now()},()=>de(this,Hi,yn).call(this)),!de(this,Hi,hn).call(this)||de(this,Hi,yn).call(this)&&(this.d[14](\\\"connection\\\",\\\"connected\\\",\\\"\\\\u2192\\\",\\\"disconnected\\\"),!de(this,Hi,hn).call(this)))||de(this,Hi,hn).call(this)&&de(this,Hi,gn).call(this))},gn=function(){try{this.d[12](this.d[11])}catch(t){de(this,Hi,mn).call(this,t,\\\"ready\\\")}},mn=function(t,e){let i=t instanceof Error?t:new Error(String(t));this.d[0].emit(\\\"error\\\",{error:i,context:e})},yn=function(){return this.l[4]&&\\\"disconnected\\\"===this.d[5].status&&null===this.l[7]},vn=new Set([\\\"id\\\",\\\"_id\\\",\\\"createdAt\\\",\\\"updatedAt\\\",\\\"createdBy\\\",\\\"updatedBy\\\",\\\"_status\\\",\\\"globalType\\\",\\\"collection\\\",\\\"locale\\\",\\\"localized\\\"]),bn=/^https?:\\\\/\\\\/(localhost|127\\\\.0\\\\.0\\\\.1)(?::\\\\d+)?$/i,wn=/^https?:\\\\/\\\\/[^/?#\\\\s]+$/i,Sn=[\\\"PAYLOAD_ADMIN_ORIGIN\\\",\\\"PUBLIC_PAYLOAD_ADMIN_ORIGIN\\\",\\\"NEXT_PUBLIC_PAYLOAD_ADMIN_ORIGIN\\\"],$n=class{constructor(t={}){he(this,An);let e=new Set;for(let i of t.additionalOrigins??[]){let t=z(i);void 0!==t&&e.add(t)}for(let t of Sn){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??1)&&(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 1}return 0}());ce(this,An,[e,i,n,void 0!==i,void 0])}matches(t){return 0===t.length||\\\"null\\\"===t?0:void 0!==ue(this,An)[4]?t===ue(this,An)[4]:!!(ue(this,An)[0].has(t)||0===ue(this,An)[0].size&&void 0!==ue(this,An)[1]&&t===ue(this,An)[1]||ue(this,An)[2]&&bn.test(t))}lockOrigin(t){return this.matches(t)?(ue(this,An)[4]=t,1):0}unlockOrigin(){let t=ue(this,An)[4];return ue(this,An)[4]=void 0,t}get lockedOrigin(){return ue(this,An)[4]}enumerate(){if(void 0!==ue(this,An)[4])return[ue(this,An)[4]];let t=new Set(ue(this,An)[0]);if(0===ue(this,An)[0].size&&void 0!==ue(this,An)[1]&&t.add(ue(this,An)[1]),ue(this,An)[2])for(let e of kn)t.add(`http://localhost:${String(e)}`),t.add(`http://127.0.0.1:${String(e)}`);return[...t]}get referrerWasAvailable(){return ue(this,An)[3]}get isProductionUnconfigured(){return!(!D()||ue(this,An)[0].size>0||ue(this,An)[2]||void 0!==ue(this,An)[1])}get isReferrerOnlyTrust(){return ue(this,An)[0].size>0||ue(this,An)[2]?0:void 0!==ue(this,An)[1]}},An=new WeakMap,kn=[3e3,3001,3333,4e3,4321,5e3,5173,5174,8e3,8080,8888,9e3],Tn=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\\\"]),Nn=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\\\"]),Mn=\\\"aria-\\\",Cn=\\\"data-\\\",On={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\\\"]),In=1,En=8,Rn=class extends Error{constructor(){super(...arguments);oe(this,\\\"name\\\",\\\"SanitizerEnvironmentError\\\")}},_n=(Object.freeze({allowedTags:Tn,removeCompletely:Nn,globalAttributes:xn,attributesByTag:On,urlAttributes:jn}),new Map),Ln={1:\\\"left\\\",2:\\\"center\\\",3:\\\"right\\\",4:\\\"justify\\\"},Wn=new Set([\\\"left\\\",\\\"center\\\",\\\"right\\\",\\\"justify\\\",\\\"start\\\",\\\"end\\\"]),Pn=Object.freeze({\\\"&\\\":\\\"&amp;\\\",\\\"<\\\":\\\"&lt;\\\",\\\">\\\":\\\"&gt;\\\",'\\\"':\\\"&quot;\\\",\\\"'\\\":\\\"&#x27;\\\",\\\"/\\\":\\\"&#x2F;\\\",\\\"`\\\":\\\"&#x60;\\\",\\\"=\\\":\\\"&#x3D;\\\"}),Fn=/[&<>\\\"'/`=]/g,Dn=Object.freeze({\\\"&\\\":\\\"&amp;\\\",\\\"<\\\":\\\"&lt;\\\",\\\">\\\":\\\"&gt;\\\",'\\\"':\\\"&quot;\\\",\\\"'\\\":\\\"&#x27;\\\"}),Un=/[&<>\\\"']/g,zn=new Set([\\\"h1\\\",\\\"h2\\\",\\\"h3\\\",\\\"h4\\\",\\\"h5\\\",\\\"h6\\\"]),Vn=(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>`},Gn=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=zn.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\\\",Vn);J(\\\"autolink\\\",Vn);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>`});Lt={renderChildren:at,resolveAlignment:X,resolveIndent:Y};Wt=\\\"data-payload-text\\\";Pt={name:\\\"textarea\\\",render(t,e){let i=t.element,n=st(e)?ot(e):dt(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 0==e.sanitize||void 0===G()?i:V(i)}(e);else{if(\\\"string\\\"!=typeof e)return 0;t.element.innerHTML=V(e)}})};Dt={name:\\\"html\\\",render(t,e){if(null==e){t.element.textContent=\\\"\\\";return}let i=\\\"string\\\"==typeof e?e:dt(e);t.element.innerHTML=V(i)}};Ut={name:\\\"url\\\",render(t,e,i){let n=t.element,r=dt(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 0;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 0;let r=n.url;if(\\\"string\\\"!=typeof r||!w(r))return 0;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:dt(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(dt(e));Number.isNaN(r)?n.textContent=dt(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 0;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=[Pt,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=0,s=50,o=1,a=0,u=0,h=50,c=\\\"200px\\\",d=0,f=0,p=0]=typeof __LIVE_PREVIEW_CONFIG__>\\\"u\\\"?[]:__LIVE_PREVIEW_CONFIG__,g=new $n({additionalOrigins:e,enableReferrerDetection:!d,enableLocalhostMatching:!f});g.isProductionUnconfigured?pe(\\\"[live-preview] No trusted origin. Set PAYLOAD_ADMIN_ORIGIN or pass allowedOrigins to generateInlineScript().\\\"):g.isReferrerOnlyTrust&&pe(\\\"[live-preview] 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)}([ct(),...re,Rt()]),v=new Bi({renderers:y,originMatcher:t=>g.matches(t),readyTargets:g.enumerate(),emitter:m,...\\\"\\\"!==i?{dataMerge:{serverURL:i,apiRoute:n,depth:r}}:{},debounceMs:s,heartbeatMs:a,intersectionRootMargin:c,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=Object.freeze({version:\\\"1.2.2\\\",destroy:()=>{v.destroy();let t=window;t.__livePreview===b&&delete t.__livePreview},refresh:()=>{v.refreshCache()},enumerateOrigins:()=>g.enumerate()});try{Object.defineProperty(window,\\\"__livePreview\\\",{value:b,writable:0,configurable:1})}catch(t){throw v.destroy(),t}}()})();\";\nexport const RUNTIME_BUILD_INFO: RuntimeBuildInfo = { generatedAt: \"2026-08-20T15:53:37.000Z\", size: 65661 };\n","/**\n * Inline script generator.\n *\n * Wraps the build-time-generated runtime IIFE with consumer-provided\n * configuration. Returns a JavaScript string suitable for embedding\n * via `<script>` in any framework.\n *\n * The runtime body is identical to the one used by the high-level\n * client because both originate from `src/core/runtime.ts`. There is\n * no parallel implementation to drift out of sync.\n *\n * @module @inline/generator\n */\n\nimport { RUNTIME_SOURCE, RUNTIME_BUILD_INFO, type RuntimeBuildInfo } from './runtime.generated';\n\nexport interface InlineScriptConfig {\n /** Additional trusted origins to merge with auto-detected ones. */\n readonly allowedOrigins?: readonly string[];\n /**\n * Payload server origin, e.g. `https://cms.example.com`. When set,\n * every incoming update is re-fetched through the Payload REST API\n * (`X-Payload-HTTP-Method-Override: GET`, same strategy as the\n * official client) so relationship and upload fields render\n * populated instead of as bare IDs. Strongly recommended for\n * Payload 3.x. Requires the preview page to be able to reach the\n * API with credentials (same-site cookies or CORS `credentials`).\n */\n readonly serverURL?: string;\n /** REST API route prefix used with `serverURL`. Defaults to `/api`. */\n readonly apiRoute?: string;\n /** Population depth used with `serverURL`. Defaults to `1`. */\n readonly mergeDepth?: number;\n /** Enable verbose console logging. Defaults to `false`. */\n readonly debug?: boolean;\n /** Debounce window for incoming updates in ms. Defaults to `50`. */\n readonly debounceMs?: number;\n /** Enable screen-reader live region. Defaults to `true`. */\n readonly enableA11y?: boolean;\n /**\n * Heartbeat timeout in ms. Defaults to `0` (disabled). The Payload\n * admin only posts messages on form edits — there is no protocol\n * keepalive — so an idle-based timeout would fire spurious\n * disconnects while the editor pauses. Enable only if your admin\n * setup sends periodic messages.\n */\n readonly heartbeatMs?: number;\n /**\n * Bypass the visibility-gate optimisation and apply every update\n * regardless of viewport position. Default `false` — the gate kicks\n * in when the cache exceeds `visibilityGateThreshold` entries.\n */\n readonly disableVisibilityGate?: boolean;\n /**\n * Cache-size threshold above which the visibility gate activates.\n * Default `50`. Off-screen elements above this threshold are queued\n * for replay on intersection instead of being updated immediately.\n */\n readonly visibilityGateThreshold?: number;\n /**\n * `rootMargin` passed to the `IntersectionObserver` watching the\n * cached elements. Default `'200px'`. Increase to pre-render\n * further off-screen content; decrease for tighter visibility.\n */\n readonly intersectionRootMargin?: string;\n /**\n * Opt out of `document.referrer`-based origin auto-detection.\n * Useful when the page is loaded under `Referrer-Policy: no-referrer`\n * and you want predictable behaviour. Default `false`.\n */\n readonly disableReferrerDetection?: boolean;\n /**\n * Opt out of the dev-mode localhost-pattern matcher (any port on\n * `localhost` / `127.0.0.1`). Useful when running locally against\n * a production-like origin list. Default `false`.\n */\n readonly disableLocalhostMatching?: boolean;\n /**\n * Restrict each update to the bindings owned by the document it describes,\n * declared in markup with `data-payload-owner` and resolved from the nearest\n * ancestor. Default `false`, which keeps matching on the field name alone.\n *\n * Enable it when one page previews more than one document. While enabled a\n * binding without an owner is never updated.\n */\n readonly scopeBindingsByOwner?: boolean;\n /**\n * Retained for 1.x source compatibility, but has no effect here:\n * `generateInlineScript()` returns a script body and creates no tag.\n * Pass the nonce separately to `wrapWithScriptTag(body, { nonce })`.\n *\n * @deprecated Use the second argument of `wrapWithScriptTag()`.\n */\n readonly nonce?: string;\n}\n\n/**\n * Build an inline script body. The result is a self-contained IIFE\n * with the build-time runtime, prefixed by a configuration block.\n *\n * The string does NOT include the `<script>` tags — use\n * `wrapWithScriptTag()` when you need them.\n */\nexport function generateInlineScript(config: InlineScriptConfig = {}): string {\n if (RUNTIME_SOURCE.length === 0) {\n throw new Error(\n '[live-preview] runtime.generated.ts is empty. Run `npm run build:runtime` before bundling.',\n );\n }\n // Compact private wire format; keep this order aligned with\n // `RuntimeBuildConfig` in `src/core/runtime.ts`.\n const compactConfig: unknown[] = [\n config.allowedOrigins,\n config.serverURL,\n config.apiRoute,\n config.mergeDepth,\n config.debug,\n config.debounceMs,\n config.enableA11y,\n config.heartbeatMs,\n config.disableVisibilityGate,\n config.visibilityGateThreshold,\n config.intersectionRootMargin,\n config.disableReferrerDetection,\n config.disableLocalhostMatching,\n config.scopeBindingsByOwner,\n ];\n while (compactConfig.length > 0 && compactConfig.at(-1) === undefined) compactConfig.pop();\n // Preserve omitted interior options as sparse JavaScript slots. JSON arrays\n // encode `undefined` as `null`, which would bypass the runtime's destructuring\n // defaults and can turn an omitted serverURL into an invalid configured value.\n // `<` must never appear literally inside an inline <script> body — a\n // consumer-supplied string containing `</script>` would terminate the tag.\n const configLiteral = `[${compactConfig\n .map((value) => (value === undefined ? '' : JSON.stringify(value)))\n .join(',')}]`.replace(/</g, '\\\\u003C');\n // The IIFE declares its own scope. We inject the config via a global\n // assignment that the bundled runtime reads back through the\n // `__LIVE_PREVIEW_CONFIG__` constant placeholder. The identifier is retained\n // across 1.0.x because existing deployments use it as a non-secret runtime\n // presence/leak signal in response-level integration tests.\n return [`var __LIVE_PREVIEW_CONFIG__=${configLiteral};`, RUNTIME_SOURCE].join('\\n');\n}\n\n/**\n * Wrap an inline script body in a `<script>` tag. When a nonce is\n * provided it is added as the `nonce` attribute so CSP policies that\n * require `'nonce-...'` accept the script.\n */\nexport function wrapWithScriptTag(body: string, options: { nonce?: string } = {}): string {\n const nonceAttr = options.nonce !== undefined ? ` nonce=\"${escapeNonce(options.nonce)}\"` : '';\n return `<script${nonceAttr}>${body}</script>`;\n}\n\n/**\n * Snapshot of the build-time information for diagnostics.\n */\nexport function runtimeBuildInfo(): RuntimeBuildInfo {\n return RUNTIME_BUILD_INFO;\n}\n\nfunction escapeNonce(nonce: string): string {\n if (!/^[A-Za-z0-9+/=_-]+$/.test(nonce)) {\n throw new RangeError('wrapWithScriptTag: nonce contains invalid characters');\n }\n return nonce;\n}\n","/**\n * Astro integration for Payload Live Preview.\n *\n * Drop into `astro.config.mjs`:\n *\n * ```ts\n * import { defineConfig } from 'astro/config';\n * import { livePreview } from 'payload-live-preview/astro';\n *\n * export default defineConfig({\n * integrations: [livePreview({ allowedOrigins: ['https://admin.example.com'] })],\n * });\n * ```\n *\n * Two injection modes:\n *\n * - **`mode: 'inline'`** (default) — `injectScript('head-inline', …)`\n * bakes the runtime into every page at build time. Right choice\n * for `output: 'static'`, where no middleware runs at request\n * time. The runtime stays inert outside the admin iframe.\n * - **`mode: 'middleware'`** — registers the preview middleware via\n * `addMiddleware()`: the runtime is injected at request time into\n * requests carrying preview intent, and `frame-ancestors` CSP is\n * managed. This is a delivery gate, not authentication. For\n * authorization-gated response changes, register\n * `createLivePreviewMiddleware()` manually after the application's\n * server-side verifier. (`shouldInject` is not supported in this\n * mode: options travel through a serialized virtual module.)\n *\n * @module @adapters/astro/integration\n */\n\nimport { generateInlineScript } from '@inline/generator';\nimport type { LivePreviewAstroOptions } from './types';\n\n// Local Astro type shims — keep `astro` as a runtime-optional peer.\ntype ScriptStage = 'head-inline' | 'page' | 'before-hydration' | 'page-ssr';\ninterface VitePluginLike {\n readonly name: string;\n readonly resolveId: (id: string) => string | undefined;\n readonly load: (id: string) => string | undefined;\n}\ninterface AstroConfigSetupContext {\n readonly injectScript: (stage: ScriptStage, content: string) => void;\n readonly addMiddleware?: (entry: { entrypoint: string; order: 'pre' | 'post' }) => void;\n readonly updateConfig?: (config: { vite?: { plugins?: VitePluginLike[] } }) => void;\n}\n\nexport interface AstroIntegrationLike {\n readonly name: string;\n readonly hooks: {\n readonly 'astro:config:setup': (ctx: AstroConfigSetupContext) => void;\n };\n}\n\nconst VIRTUAL_OPTIONS_ID = 'virtual:payload-live-preview/options';\nconst RESOLVED_VIRTUAL_OPTIONS_ID = `\\0${VIRTUAL_OPTIONS_ID}`;\nconst MIDDLEWARE_ENTRYPOINT = 'payload-live-preview/astro/middleware-entry';\n\n/**\n * Build the Astro integration. The injected script auto-detects the\n * browser preview context and stays inert on ordinary top-level pages.\n * Browser-context detection does not authorize HTTP response changes.\n */\nexport function livePreview(options: LivePreviewAstroOptions = {}): AstroIntegrationLike {\n return {\n name: 'payload-live-preview',\n hooks: {\n 'astro:config:setup': (ctx): void => {\n if (options.mode === 'middleware') {\n setupMiddlewareMode(ctx, options);\n return;\n }\n if (options.autoInject === false) return;\n const script = generateInlineScript({\n ...(options.allowedOrigins !== undefined\n ? { allowedOrigins: options.allowedOrigins }\n : {}),\n ...(options.serverURL !== undefined ? { serverURL: options.serverURL } : {}),\n ...(options.apiRoute !== undefined ? { apiRoute: options.apiRoute } : {}),\n ...(options.mergeDepth !== undefined ? { mergeDepth: options.mergeDepth } : {}),\n ...(options.debug !== undefined ? { debug: options.debug } : {}),\n ...(options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {}),\n ...(options.heartbeatMs !== undefined ? { heartbeatMs: options.heartbeatMs } : {}),\n });\n ctx.injectScript('head-inline', script);\n },\n },\n };\n}\n\nfunction setupMiddlewareMode(ctx: AstroConfigSetupContext, options: LivePreviewAstroOptions): void {\n if (ctx.addMiddleware === undefined || ctx.updateConfig === undefined) {\n throw new Error(\n \"payload-live-preview: mode 'middleware' needs Astro's addMiddleware/updateConfig \" +\n 'hooks (Astro >= 4). Upgrade Astro or use the default inline mode.',\n );\n }\n if (options.shouldInject !== undefined) {\n throw new Error(\n \"payload-live-preview: `shouldInject` cannot be used with mode 'middleware' — \" +\n 'options are serialized into the build. Use `previewQueryParams`/`previewSignals`, ' +\n 'or register createLivePreviewMiddleware() manually in src/middleware.ts.',\n );\n }\n\n // Everything except functions serializes cleanly.\n const { mode: _mode, shouldInject: _shouldInject, ...serializable } = options;\n const optionsModule = `export default ${JSON.stringify(serializable).replace(/</g, '\\\\u003C')};`;\n\n ctx.updateConfig({\n vite: {\n plugins: [\n {\n name: 'payload-live-preview-options',\n resolveId: (id) => (id === VIRTUAL_OPTIONS_ID ? RESOLVED_VIRTUAL_OPTIONS_ID : undefined),\n load: (id) => (id === RESOLVED_VIRTUAL_OPTIONS_ID ? optionsModule : undefined),\n },\n ],\n },\n });\n ctx.addMiddleware({ entrypoint: MIDDLEWARE_ENTRYPOINT, order: 'pre' });\n}\n","/**\n * Content-Security-Policy helpers.\n *\n * Two responsibilities:\n *\n * 1. Generate cryptographic nonces so consumers can opt into a strict\n * `script-src 'nonce-...'` policy and avoid `'unsafe-inline'`.\n * 2. Build the `frame-ancestors` directive value, restricting which\n * origins may embed the preview page in an iframe.\n *\n * Both functions are isomorphic — they work in browsers, Node, and\n * edge runtimes that expose Web Crypto via `globalThis.crypto`.\n *\n * @module @security/csp\n */\n\n/**\n * Default byte-length for nonces. 16 bytes → 22 base64url characters,\n * which exceeds the 128-bit entropy threshold recommended by OWASP.\n */\nconst DEFAULT_NONCE_BYTES = 16;\n\n/** CSP3's exact whitespace set: HTAB, LF, FF, CR, and SPACE. */\nconst CSP_ASCII_WHITESPACE = /[\\t\\n\\f\\r ]+/;\nconst CSP_EDGE_ASCII_WHITESPACE = /^[\\t\\n\\f\\r ]+|[\\t\\n\\f\\r ]+$/g;\n\n/** CSP names are ASCII strings; Unicode case folding must not create directives. */\nfunction asciiLowercase(value: string): string {\n return value.replace(/[A-Z]/g, (character) => character.toLowerCase());\n}\n\n/**\n * Minimal Web-Crypto surface area we actually call. The full `Crypto`\n * type drags in browser-only declarations that don't typecheck cleanly\n * against Node's `webcrypto` shape — this narrower interface accepts\n * both without an unsafe cast.\n */\ninterface WebCryptoLike {\n getRandomValues: <T extends ArrayBufferView | null>(array: T) => T;\n}\n\nlet cryptoOverride: WebCryptoLike | undefined;\n\n/**\n * Inject a Web Crypto implementation to use when `globalThis.crypto`\n * is unavailable.\n *\n * Node.js exposed `globalThis.crypto` globally starting with v19. On\n * Node 18 (still LTS at time of writing) consumers can flip the\n * `--experimental-global-webcrypto` flag *or* call this function once\n * at startup:\n *\n * ```ts\n * import { webcrypto } from 'node:crypto';\n * import { setCspCrypto } from 'payload-live-preview';\n * setCspCrypto(webcrypto as { getRandomValues: typeof webcrypto.getRandomValues });\n * ```\n *\n * Browser bundles never need to call this — `globalThis.crypto` is\n * always present there, and the override only matters when the global\n * is missing.\n *\n * Pass `null` to clear a previous override (mostly useful for tests).\n */\nexport function setCspCrypto(crypto: WebCryptoLike | null): void {\n cryptoOverride = crypto ?? undefined;\n}\n\n/**\n * Generate a base64url-encoded cryptographic nonce.\n *\n * Uses `crypto.getRandomValues` everywhere — falls back to throwing\n * if no Web Crypto implementation is available, because a predictable\n * nonce would silently defeat the entire CSP.\n *\n * @param bytes Number of random bytes (defaults to 16 → 128-bit entropy).\n */\nexport function generateCspNonce(bytes: number = DEFAULT_NONCE_BYTES): string {\n if (!Number.isInteger(bytes) || bytes < 8) {\n throw new RangeError(`generateCspNonce: bytes must be an integer >= 8, got ${String(bytes)}`);\n }\n const crypto = resolveCrypto();\n if (!crypto) {\n throw new Error(\n 'generateCspNonce: Web Crypto is unavailable. On Node 18 call setCspCrypto(webcrypto) ' +\n \"once at startup, or run with --experimental-global-webcrypto. We won't fabricate \" +\n 'a predictable nonce — that would silently defeat the entire CSP.',\n );\n }\n const buffer = new Uint8Array(bytes);\n crypto.getRandomValues(buffer);\n return base64UrlEncode(buffer);\n}\n\nfunction resolveCrypto(): WebCryptoLike | undefined {\n if (cryptoOverride?.getRandomValues) return cryptoOverride;\n const fromGlobal = (globalThis as { crypto?: WebCryptoLike }).crypto;\n if (fromGlobal?.getRandomValues) return fromGlobal;\n return undefined;\n}\n\nfunction base64UrlEncode(bytes: Uint8Array): string {\n let binary = '';\n for (const byte of bytes) binary += String.fromCharCode(byte);\n const base64 = typeof btoa === 'function' ? btoa(binary) : Buffer.from(bytes).toString('base64');\n return base64.replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '');\n}\n\n/**\n * Sources allowed in the `frame-ancestors` directive.\n *\n * Conceptually a union of `'self'`, `'none'`, or an explicit origin\n * string. TypeScript collapses literal-vs-string unions, so we expose\n * a `string` alias and document the special values.\n */\nexport type FrameAncestorSource = string;\n\nexport interface FrameAncestorsOptions {\n readonly self?: boolean;\n readonly origins?: readonly string[];\n readonly allowNone?: boolean;\n}\n\n/**\n * Build the value for `frame-ancestors` in a `Content-Security-Policy`\n * header.\n *\n * Returns `'none'` if `allowNone: true` and no other sources are\n * provided. Otherwise concatenates `'self'` (if requested) with the\n * given origins, deduplicating and trimming entries.\n *\n * @example\n * `frame-ancestors ${buildFrameAncestors({ self: true, origins: [adminUrl] })}`\n */\nexport function buildFrameAncestors(options: FrameAncestorsOptions = {}): string {\n const { self = true, origins = [], allowNone = false } = options;\n const seen = new Set<string>();\n const out: FrameAncestorSource[] = [];\n if (allowNone && !self && origins.length === 0) return \"'none'\";\n if (self) {\n out.push(\"'self'\");\n seen.add(\"'self'\");\n }\n for (const origin of origins) {\n const trimmed = origin.trim();\n if (trimmed.length === 0 || seen.has(trimmed)) continue;\n seen.add(trimmed);\n out.push(trimmed);\n }\n return out.length > 0 ? out.join(' ') : \"'none'\";\n}\n\n/**\n * Build a `script-src` value that permits a single nonce plus optional\n * extra sources.\n *\n * `'strict-dynamic'` is **opt-in**: under CSP 3 it makes browsers\n * ignore `'self'` and every host source in the directive, so any\n * parser-inserted script without a nonce (framework hydration scripts,\n * consumer `<script>` tags) would be blocked. Only enable it when every\n * script on the page carries the nonce.\n */\nexport function buildScriptSrcWithNonce(\n nonce: string,\n options: {\n readonly self?: boolean;\n readonly extra?: readonly string[];\n readonly strictDynamic?: boolean;\n } = {},\n): string {\n if (nonce.length === 0) throw new RangeError('buildScriptSrcWithNonce: nonce is empty');\n const { self = true, extra = [], strictDynamic = false } = options;\n const parts: string[] = [];\n if (self) parts.push(\"'self'\");\n parts.push(`'nonce-${nonce}'`);\n if (strictDynamic) parts.push(\"'strict-dynamic'\");\n for (const e of extra) {\n const trimmed = e.trim();\n if (trimmed.length > 0) parts.push(trimmed);\n }\n return parts.join(' ');\n}\n\n/**\n * How a directive is merged into an existing CSP header value.\n *\n * - `union` (default) — the new sources are added to the existing\n * directive's sources (deduplicated). An existing `'none'` is\n * dropped when real sources are added, since `'none'` may not be\n * combined with other sources.\n * - `replace` — the new value overwrites the existing directive.\n */\nexport interface CspDirectiveMerge {\n readonly value: string;\n readonly mode?: 'union' | 'replace';\n}\n\n/**\n * Merge directives into an existing `Content-Security-Policy` header\n * value without clobbering what a consumer (or another middleware)\n * already configured. Directives not mentioned in `additions` pass\n * through untouched; new directives are appended. Existing policy parsing\n * follows CSP3's ASCII-whitespace and first-duplicate-wins rules.\n *\n * This is the single CSP-merge implementation shared by every adapter.\n */\nexport function mergeCspHeader(\n existing: string,\n additions: Readonly<Record<string, string | CspDirectiveMerge>>,\n): string {\n const directives = new Map<string, string>();\n for (const part of existing.split(';')) {\n const trimmed = part.replace(CSP_EDGE_ASCII_WHITESPACE, '');\n if (trimmed.length === 0) continue;\n const whitespaceIndex = trimmed.search(CSP_ASCII_WHITESPACE);\n const name = asciiLowercase(whitespaceIndex < 0 ? trimmed : trimmed.slice(0, whitespaceIndex));\n\n // CSP3 §2.2.1 is first-wins: a user agent ignores every later\n // case-insensitive duplicate. Mirroring that rule before merging prevents a\n // later, looser duplicate from becoming the policy we serialize.\n if (directives.has(name)) continue;\n\n const value =\n whitespaceIndex < 0\n ? ''\n : trimmed.slice(whitespaceIndex).replace(CSP_EDGE_ASCII_WHITESPACE, '');\n directives.set(name, value);\n }\n\n for (const [rawName, rawAddition] of Object.entries(additions)) {\n const name = asciiLowercase(rawName);\n const addition: CspDirectiveMerge =\n typeof rawAddition === 'string' ? { value: rawAddition } : rawAddition;\n const mode = addition.mode ?? 'union';\n const current = directives.get(name);\n if (mode === 'replace' || current === undefined || current.length === 0) {\n directives.set(name, addition.value);\n continue;\n }\n const seen = new Set<string>();\n const merged: string[] = [];\n for (const token of [\n ...current.split(CSP_ASCII_WHITESPACE),\n ...addition.value.split(CSP_ASCII_WHITESPACE),\n ]) {\n if (token.length === 0 || seen.has(token)) continue;\n seen.add(token);\n merged.push(token);\n }\n // `'none'` cannot coexist with other sources.\n const withoutNone = merged.filter((token) => token !== \"'none'\");\n directives.set(name, (withoutNone.length > 0 ? withoutNone : merged).join(' '));\n }\n\n const out: string[] = [];\n for (const [name, value] of directives) {\n out.push(value.length === 0 ? name : `${name} ${value}`);\n }\n return out.join('; ');\n}\n","/**\n * Server-side preview-intent detection.\n *\n * The live-preview runtime only ever activates inside the Payload\n * admin's iframe, but the *server* still has to decide whether a\n * request expresses preview intent before doing optional preview\n * work. Adapters use this predicate as a delivery optimisation, and\n * consumers with hand-rolled middleware can import it directly.\n *\n * IMPORTANT: every signal inspected here is controlled or triggerable\n * by the client. A positive result is never proof of identity,\n * authentication, or permission to read drafts. Before forwarding\n * credentials, fetching draft data, bypassing caches, changing CSP,\n * or injecting the runtime, verify the request with an application-\n * owned server session or a short-lived signed authorization. Use the\n * same verified decision for all of those effects.\n *\n * Preview intent is present when any of these hold:\n *\n * 1. A preview query parameter is present (`?preview=true`,\n * `?draft=true`, `?livePreview=true` — configurable).\n * 2. `Sec-Fetch-Dest: iframe` — the document is being loaded as an\n * iframe, which is exactly how the Payload admin embeds it.\n * (Sent by all evergreen browsers; absence never *excludes* a\n * request, presence includes it.)\n * 3. The `Referer` points at one of the given admin origins.\n *\n * @module @adapters/shared/preview-request\n */\n\n/** The individual signals the predicate can consider. */\nexport type PreviewSignal = 'query' | 'fetch-dest' | 'referer';\n\nexport interface PreviewRequestOptions {\n /**\n * Which signals count as preview intent. Default: all three.\n * Restricting this to `['query']` reduces accidental activation, but\n * an explicit `?preview=true` is still client-controlled and must not\n * authorize response changes or privileged data access by itself.\n */\n readonly signals?: readonly PreviewSignal[];\n /**\n * Query parameters (with values `true` or `1`) that signal preview\n * intent. Default: `['preview', 'draft', 'livePreview']`.\n */\n readonly queryParams?: readonly string[];\n /**\n * Treat `Sec-Fetch-Dest: iframe` as a preview-intent signal. Default `true`.\n * Legacy alias for excluding `'fetch-dest'` from `signals`.\n */\n readonly checkFetchDest?: boolean;\n /**\n * Admin origins whose `Referer` signals preview intent, e.g.\n * `['https://cms.example.com']`. Referer matching is not HTTP-request\n * authentication.\n */\n readonly adminOrigins?: readonly string[];\n}\n\nconst DEFAULT_QUERY_PARAMS = ['preview', 'draft', 'livePreview'] as const;\n\n/**\n * The minimal request surface the predicate needs. The standard\n * `Request` satisfies it structurally, and server frameworks without\n * fetch-style requests (e.g. Nitro/H3) can supply a tiny shim.\n */\nexport interface PreviewRequestLike {\n readonly url: string;\n readonly headers: { get(name: string): string | null };\n}\n\n/**\n * Detect whether `request` carries live-preview intent. See the module\n * docblock for the exact signals and the required authorization\n * boundary. This compatibility name does not imply authentication.\n */\nexport function isPreviewRequest(\n request: PreviewRequestLike,\n options: PreviewRequestOptions = {},\n): boolean {\n const signals = new Set<PreviewSignal>(options.signals ?? ['query', 'fetch-dest', 'referer']);\n const queryParams = options.queryParams ?? DEFAULT_QUERY_PARAMS;\n const checkFetchDest = (options.checkFetchDest ?? true) && signals.has('fetch-dest');\n\n if (signals.has('query')) {\n let url: URL | undefined;\n try {\n url = new URL(request.url);\n } catch {\n url = undefined;\n }\n if (url !== undefined) {\n for (const param of queryParams) {\n const value = url.searchParams.get(param);\n if (value === 'true' || value === '1') return true;\n }\n }\n }\n\n if (checkFetchDest && request.headers.get('sec-fetch-dest') === 'iframe') {\n return true;\n }\n\n const adminOrigins = signals.has('referer') ? (options.adminOrigins ?? []) : [];\n if (adminOrigins.length > 0) {\n const referer = request.headers.get('referer');\n if (referer !== null) {\n try {\n const refererOrigin = new URL(referer).origin;\n for (const adminOrigin of adminOrigins) {\n try {\n if (new URL(adminOrigin).origin === refererOrigin) return true;\n } catch {\n // skip malformed configured origin\n }\n }\n } catch {\n // malformed referer — not a preview signal\n }\n }\n }\n\n return false;\n}\n","/**\n * Astro middleware for Payload Live Preview.\n *\n * Responsibilities (per request):\n *\n * 1. Generate a per-response CSP nonce and stash it on\n * `Astro.locals.livePreviewNonce` so consumers can reference it.\n * 2. On requests carrying **preview intent** (see\n * `isPreviewRequest`), rewrite the HTML response to inject the\n * live-preview `<script>` tag.\n * 3. On those requests, merge `frame-ancestors` into the\n * `Content-Security-Policy` header so the Payload admin may embed\n * the page. Full `script-src` nonce management is opt-in via\n * `manageCsp: 'full'`.\n *\n * The intent signals are client-controlled and this middleware does\n * not authenticate them. For protected preview responses, first verify\n * an application-owned server session or short-lived authorization,\n * then invoke this middleware with that same decision also governing\n * draft reads, credentials, and cache policy. `shouldInject` filters\n * script insertion only; it is not an authorization boundary and does\n * not disable CSP handling.\n *\n * Prerendered pages are skipped entirely: Astro runs middleware at\n * build time for those, where per-request nonces and response headers\n * are meaningless.\n *\n * @module @adapters/astro/middleware\n */\n\nimport {\n generateCspNonce,\n buildFrameAncestors,\n buildScriptSrcWithNonce,\n mergeCspHeader,\n} from '@security/csp';\nimport { generateInlineScript, wrapWithScriptTag } from '@inline/generator';\nimport { isPreviewRequest } from '@adapters/shared/preview-request';\nimport type { LivePreviewAstroOptions } from './types';\n\n// Astro type imports are deferred via a local declaration so consumers\n// without Astro installed (e.g., type-checking the library itself) can\n// still build the adapter. At runtime the function signature matches.\ntype MiddlewareNext = () => Promise<Response>;\ninterface MiddlewareContext {\n readonly request: Request;\n readonly locals: Record<string, unknown>;\n /** Present in Astro ≥ 5: `true` while prerendering at build time. */\n readonly isPrerendered?: boolean;\n}\nexport type LivePreviewMiddleware = (\n context: MiddlewareContext,\n next: MiddlewareNext,\n) => Promise<Response>;\n\n/**\n * Key on `Astro.locals` carrying the request-scoped nonce. Consumers\n * can read `Astro.locals.livePreviewNonce` from `.astro` templates to\n * set the `nonce` attribute on their own scripts.\n */\nexport const NONCE_LOCALS_KEY = 'livePreviewNonce';\n\nconst HTML_CONTENT_TYPE = /text\\/html/i;\nconst HEAD_INSERT = /<head(\\s[^>]*)?>/i;\n\n/**\n * Build the Astro-compatible middleware. Register it in\n * `src/middleware.ts`:\n *\n * ```ts\n * import { createLivePreviewMiddleware } from 'payload-live-preview/astro';\n * export const onRequest = createLivePreviewMiddleware({\n * allowedOrigins: [import.meta.env.PUBLIC_PAYLOAD_ADMIN_ORIGIN],\n * });\n * ```\n */\nexport function createLivePreviewMiddleware(\n options: LivePreviewAstroOptions = {},\n): LivePreviewMiddleware {\n const allowedOrigins = options.allowedOrigins ?? [];\n const autoInject = options.autoInject ?? true;\n const injectMode = options.inject ?? 'preview-only';\n const manageCsp = normalizeManageCsp(options.manageCsp);\n const shouldInject = options.shouldInject;\n\n // The script body is configuration-static (the nonce only decorates\n // the surrounding tag) — generate it once, not per request.\n let cachedScriptBody: string | undefined;\n const scriptBody = (): string => {\n cachedScriptBody ??= generateInlineScript({\n ...(options.allowedOrigins !== undefined ? { allowedOrigins: options.allowedOrigins } : {}),\n ...(options.serverURL !== undefined ? { serverURL: options.serverURL } : {}),\n ...(options.apiRoute !== undefined ? { apiRoute: options.apiRoute } : {}),\n ...(options.mergeDepth !== undefined ? { mergeDepth: options.mergeDepth } : {}),\n ...(options.debug !== undefined ? { debug: options.debug } : {}),\n ...(options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {}),\n ...(options.heartbeatMs !== undefined ? { heartbeatMs: options.heartbeatMs } : {}),\n });\n return cachedScriptBody;\n };\n\n return async (context, next) => {\n const nonce = generateCspNonce();\n context.locals[NONCE_LOCALS_KEY] = nonce;\n\n const response = await next();\n\n // Build-time prerendering: no meaningful request headers, no\n // response headers in the static output, and a baked-forever nonce.\n if (context.isPrerendered === true) return response;\n\n const isPreview =\n injectMode === 'always' ||\n isPreviewRequest(context.request, {\n ...(options.previewQueryParams !== undefined\n ? { queryParams: options.previewQueryParams }\n : {}),\n ...(options.previewSignals !== undefined ? { signals: options.previewSignals } : {}),\n adminOrigins: allowedOrigins,\n });\n if (!isPreview) return response;\n\n let outResponse = response;\n\n const contentType = response.headers.get('content-type') ?? '';\n const apply = autoInject && (shouldInject?.(context.request) ?? true);\n if (apply && HTML_CONTENT_TYPE.test(contentType)) {\n outResponse = await injectScript(response, nonce, scriptBody());\n }\n\n if (manageCsp !== false) {\n outResponse = applyCspHeaders(outResponse, nonce, allowedOrigins, manageCsp, options);\n }\n\n return outResponse;\n };\n}\n\nfunction normalizeManageCsp(\n value: LivePreviewAstroOptions['manageCsp'],\n): false | 'frame-ancestors' | 'full' {\n if (value === false) return false;\n if (value === 'full') return 'full';\n // `true` (legacy) and `undefined` both mean the safe default.\n return 'frame-ancestors';\n}\n\nasync function injectScript(response: Response, nonce: string, body: string): Promise<Response> {\n const html = await response.text();\n const headers = new Headers(response.headers);\n headers.delete('content-length');\n\n // Fragment responses (server islands, page partials) have no <head>;\n // injecting a roughly 60 KB runtime into each of them would corrupt every\n // fragment for zero benefit — the full document already carries it.\n if (!HEAD_INSERT.test(html)) {\n return new Response(html, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n }\n\n const scriptTag = wrapWithScriptTag(body, { nonce });\n const out = html.replace(HEAD_INSERT, (match) => `${match}${scriptTag}`);\n return new Response(out, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n}\n\nfunction applyCspHeaders(\n response: Response,\n nonce: string,\n allowedOrigins: readonly string[],\n mode: 'frame-ancestors' | 'full',\n options: LivePreviewAstroOptions,\n): Response {\n const frameAncestors = buildFrameAncestors({\n self: true,\n origins: [...allowedOrigins, ...(options.frameAncestorsExtra ?? [])],\n });\n\n const additions: Record<string, string> = { 'frame-ancestors': frameAncestors };\n if (mode === 'full') {\n additions['script-src'] = buildScriptSrcWithNonce(nonce, {\n self: true,\n strictDynamic: options.strictDynamic ?? false,\n ...(options.scriptSrcExtra !== undefined ? { extra: options.scriptSrcExtra } : {}),\n });\n }\n\n const previous = response.headers.get('content-security-policy') ?? '';\n const next = mergeCspHeader(previous, additions);\n\n // Responses passed through from `fetch()` can carry immutable\n // headers — clone into a mutable Response instead of mutating.\n try {\n response.headers.set('content-security-policy', next);\n return response;\n } catch {\n const headers = new Headers(response.headers);\n headers.set('content-security-policy', next);\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers,\n });\n }\n}\n","/**\n * Helpers for embedding the live preview manually in `.astro` templates.\n *\n * Most consumers should prefer the `livePreview()` integration which\n * auto-injects the script. This module exists for advanced cases where\n * the script needs to live inside a specific layout or behind a\n * conditional.\n *\n * Usage in a `.astro` file:\n *\n * ```astro\n * ---\n * import { renderLivePreviewScript } from 'payload-live-preview/astro';\n * const script = renderLivePreviewScript({\n * allowedOrigins: ['https://admin.example.com'],\n * nonce: Astro.locals.livePreviewNonce,\n * });\n * ---\n * <Fragment set:html={script} />\n * ```\n *\n * @module @adapters/astro/component\n */\n\nimport { generateInlineScript, wrapWithScriptTag } from '@inline/generator';\nimport type { LivePreviewAstroOptions } from './types';\n\nexport interface RenderScriptOptions extends LivePreviewAstroOptions {\n /**\n * CSP nonce to set on the `<script>` tag. Read from\n * `Astro.locals.livePreviewNonce` after registering the live-preview\n * middleware.\n */\n readonly nonce?: string;\n}\n\n/**\n * Render the full `<script>` tag (wrapped with attributes) for embedding\n * in a `.astro` layout. The result is a single string suitable for\n * `set:html={…}`.\n */\nexport function renderLivePreviewScript(options: RenderScriptOptions = {}): string {\n const body = generateInlineScript({\n ...(options.allowedOrigins !== undefined ? { allowedOrigins: options.allowedOrigins } : {}),\n ...(options.serverURL !== undefined ? { serverURL: options.serverURL } : {}),\n ...(options.apiRoute !== undefined ? { apiRoute: options.apiRoute } : {}),\n ...(options.mergeDepth !== undefined ? { mergeDepth: options.mergeDepth } : {}),\n ...(options.debug !== undefined ? { debug: options.debug } : {}),\n ...(options.debounceMs !== undefined ? { debounceMs: options.debounceMs } : {}),\n ...(options.heartbeatMs !== undefined ? { heartbeatMs: options.heartbeatMs } : {}),\n ...(options.nonce !== undefined ? { nonce: options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