@panphora/hyper-cms 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- var hypercms=(()=>{var Ci=Object.defineProperty;var Qd=Object.getOwnPropertyDescriptor;var eh=Object.getOwnPropertyNames;var th=Object.prototype.hasOwnProperty;var _i=(e,t)=>{for(var n in t)Ci(e,n,{get:t[n],enumerable:!0})},nh=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of eh(t))!th.call(e,o)&&o!==n&&Ci(e,o,{get:()=>t[o],enumerable:!(r=Qd(t,o))||r.enumerable});return e};var rh=e=>nh(Ci({},"__esModule",{value:!0}),e);var A0={};_i(A0,{cms:()=>w0,default:()=>S0});var ks=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Po=new Set(ks),Mi=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Vr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),_a=new Set(["checked","selected","disabled","readOnly","paused"]);function Ri(e,t){return t==null?_a.has(e)?!1:"":_a.has(e)?t==="false"?!1:!!t:t}function Kt(e){let t=0,n=null,r=-1;for(let o=0;o<e.length;o++){let s=e[o];s==="\\"?o++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:s==="@"&&t===0&&(r=o)}return r}function jo(e){let t=Kt(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function Li(e){let t=0,n=null,r=-1,o=!1;for(let s=0;s<e.length;s++){let i=e[s];i==="\\"?s++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:t===0&&i===">"?r=s:t===0&&i===","&&(o=!0)}return o||r===-1||!oh(e,r+1)?null:e.slice(0,r).trim()||null}function oh(e,t){let n=t,r=e.replace(/\s+$/,"").length;for(;n<r&&/\s/.test(e[n]);)n++;let o=0,s=null;for(;n<r;n++){let i=e[n];if(i==="\\")n++;else if(s)i===s&&(s=null);else if(i==='"'||i==="'")s=i;else if(i==="["||i==="(")o++;else if(i==="]"||i===")")o>0&&o--;else if(o===0&&(i==="+"||i==="~"||/\s/.test(i)))return!1}return!0}function ys(e,t){if(typeof e=="string"){let n=t&&t.defaultView,r=n&&n.DOMParser||globalThis.DOMParser;return new r().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Ii(e){let t=new Map;return(n,r)=>{if(typeof r!="string")return ys(r,e);let o=t.get(n);if(o&&o.text===r)return o.doc;let s=ys(r,e);return t.set(n,{text:r,doc:s}),s}}function Ra(e,t){let n=t.doctype;if(!n)return!1;let r=e.doctype;if(r&&r.name===n.name&&r.publicId===n.publicId&&r.systemId===n.systemId)return!1;let o=e.implementation.createDocumentType(n.name,n.publicId,n.systemId);return r?e.replaceChild(o,r):e.insertBefore(o,e.documentElement),!0}var Pi=()=>!1;function ji(e,t=[]){if(typeof e!="function")return Pi;let n=new WeakMap,r=new Set(t);return o=>{if(!o||o.nodeType!==1)return!1;let s=n.get(o);if(s!==void 0)return s;let i=[],l=o,a=!1;for(;l&&l.nodeType===1;){let c=n.get(l);if(c!==void 0){a=c;break}if(i.push(l),e(l,r.has(l))){a=!0;break}if(r.has(l))break;l=l.parentElement}for(let c of i)n.set(c,a);return a}}var z0=Object.freeze(["root-tag","equal","root-attrs","root-level","not-in-body","ignored-ancestor","remote-wins-ancestor","form-ancestor","script-or-template","no-live-twin","live-detached","ancestor-live","sibling-live","outside-id-changed","chain-unpaired"]);function ar(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function qi(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let r=t["~"],o=typeof r=="string"?r.split(",").map(Number):null,s=o&&typeof t["^"]=="string"?t["^"].split(","):null,i=u=>Number.isInteger(u)&&u>=0,l=0,a=!1,c=u=>{let f=u;for(;f>0;){let h=o[l++];if(l>o.length||!i(h))return!1;f+=h-1}return!0},p=(u,f)=>{if(a)return;if(o){let v=l++,g=o[v];if(v>=o.length||!i(g)){a=!0;return}let m=!s||s[v]===u.tagName.toLowerCase();if(!m||g!==u.children.length){let k=m&&t[f];typeof k=="string"&&k&&n.set(u,k),c(g)||(a=!0);return}}let h=t[f];typeof h=="string"&&h&&n.set(u,h);let d=u.children;for(let v=0;v<d.length;v++)p(d[v],f===""?String(v):`${f}.${v}`)};return p(e,""),n}function La(e){return t=>{for(let n of e){let r=n(t);if(typeof r=="string"&&r!=="")return r}return null}}var vn=La([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function vs(e,t,n,r=null,o=null){let s=new Map,i=new Set,l=a=>{if(n(a))return;let c=t(a);c&&(s.has(c)?i.add(c):s.set(c,a))};if(r){let a=c=>{for(let p of c.querySelectorAll(r))l(p);for(let p of c.querySelectorAll("template"))p.content&&a(p.content)};l(e),a(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let a=c=>{l(c);let p=c.tagName==="TEMPLATE"&&c.content?c.content.children:c.children;for(let u=0;u<p.length;u++)a(p[u])};a(e)}for(let a of i)s.delete(a),o&&o.add(a),Di(a);return s}function Di(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var ih=new Set(["href","src","name","type","role"]),Pa=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function Wr(e,t=5381){let n=t;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return n>>>0}function Ia(e){return e.replace(/\s+/g," ")}var lh=0;function ja({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let r=new WeakMap,o=new WeakMap;function s(T){let N=T.attributes,C=N.length;if(C===0)return{all:"",sig:T.tagName+"|"};let I=[],q="",V=[];for(let U=0;U<C;U++){let F=N[U],A=F.name;t(T,A)||I.push(A+"="+F.value),A==="class"?q=F.value.indexOf(" ")<0?F.value:F.value.split(/\s+/).filter(Boolean).sort().join(" "):ih.has(A)&&V.push(A+"="+F.value)}return I.length>1&&I.sort(),V.length>1&&V.sort(),{all:I.join(""),sig:T.tagName+"|"+q+(V.length?"|"+V.join("|"):"")}}function i(T){return T.nodeType===1&&T.tagName==="TEMPLATE"&&T.content?T.content.childNodes:T.childNodes}function l(T){let N=r.get(T);if(N)return N;if(T.nodeType===3)N={hash:"T"+Wr(T.nodeValue),hint:Ia(T.nodeValue).slice(0,64),sig:null,tok:null};else if(T.nodeType===8)N={hash:"C"+Wr(T.nodeValue),hint:"",sig:null,tok:null};else if(T.nodeType===1){let C=s(T),I=Wr(T.tagName+""+C.all),q="";for(let V of c(T))if(V.nodeType===1){let U=l(V);I=Wr(U.hash,I),q.length<64&&(q+=" "+U.hint)}else I=Wr(p(V),I),V.kind==="text"&&q.length<64&&(q+=V.value.slice(0,64));N={hash:"E"+I,hint:Ia(q).trim().slice(0,64),sig:C.sig,tok:null}}else N={hash:"N"+T.nodeType,hint:"",sig:null,tok:null};return r.set(T,N),N}function a(T){if(!T.tok){T.tok=new Set;for(let N of T.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))N&&T.tok.add(N)}return T.tok}function c(T){let N=o.get(T);if(N)return N;N=[];let C=null,I=()=>{C&&(C.value=C.nodes.map(q=>q.nodeValue).join(""),N.push(C),C=null)};for(let q of i(T)){if(q.nodeType===3){C||(C={kind:"text",nodes:[],value:"",parent:T,hash:void 0}),C.nodes.push(q);continue}I(),q.nodeType===8?N.push({kind:"comment",nodes:[q],value:q.nodeValue,parent:T,hash:void 0}):q.nodeType===1&&!e(q)&&N.push(q)}return I(),o.set(T,N),N}function p(T){return T.nodeType===1?l(T).hash:(T.hash===void 0&&(T.hash=(T.kind==="text"?"T":"C")+Wr(T.value)),T.hash)}function u(T,N){let C=a(l(T)),I=a(l(N));if(C.size===0&&I.size===0)return{coef:1,share:1};if(C.size===0||I.size===0)return null;let q=0;for(let V of C)I.has(V)&&q++;return{coef:q/Math.min(C.size,I.size),share:q/Math.max(C.size,I.size)}}function f(T,N){let C=u(T,N);return!!C&&C.coef>=.5}let h=new WeakMap;function d(T){let N=h.get(T);if(N)return N;N=[];for(let C of T.attributes)t(T,C.name)||N.push([C.namespaceURI||"",C.localName,C.value]);return N.sort((C,I)=>C[0]<I[0]?-1:C[0]>I[0]?1:C[1]<I[1]?-1:C[1]>I[1]?1:0),h.set(T,N),N}let v=new WeakMap;function g(T,N){if(T===N)return!0;if(p(T)!==p(N))return!1;let C=v.get(T);if(C&&C.has(N))return C.get(N);let I=v.get(N);if(I&&I.has(T))return I.get(T);let q=m(T,N),V=q===!0;return q===!1&&n&&n.hashRejected++,C||v.set(T,C=new WeakMap),C.set(N,V),V}function m(T,N){if(T.nodeType===1){if(N.nodeType!==1||T.tagName!==N.tagName||T.namespaceURI!==N.namespaceURI)return!1;let C=d(T),I=d(N);if(C.length!==I.length)return!1;for(let U=0;U<C.length;U++)if(C[U][0]!==I[U][0]||C[U][1]!==I[U][1]||C[U][2]!==I[U][2])return!1;let q=c(T),V=c(N);if(q.length!==V.length)return!1;for(let U=0;U<q.length;U++){if(p(q[U])!==p(V[U]))return!1;if(!g(q[U],V[U]))return lh}return!0}return N.nodeType===1?!1:T.kind===N.kind&&T.value===N.value}let k=new WeakMap,S=new Map,x=0;function w(T){let N=k.get(T);if(N)return N;let C=p(T),I=S.get(C);I||S.set(C,I=[]);let q=I.find(V=>g(V.unit,T));return N=q?q.key:"K"+x++,q||I.push({unit:T,key:N}),k.set(T,N),N}return{meta:l,unitsOf:c,unitHash:p,similar:f,score:u,childrenOf:i,equalUnits:g,exactUnitKey:w,ignored:e}}var qa=16,ah=2e3,ch=3,Fi={align:0,certifyVisited:0,certifyScheduled:0};function Bi(e,t,n){let{meta:r,unitsOf:o,unitHash:s,similar:i,score:l,childrenOf:a,equalUnits:c,ignored:p}=n.analyzer,u=n.baseId||(()=>null),f=n.sideId||(()=>null),h=n.baseKey||(()=>null),d=n.sideKey||(()=>null),v=n.baseDropped||new Set,g=n.sideDropped||new Set,m=n.stats||null,k=m?new Set:null,S=m?new Set:null,x=new Map,w=new Map,T=new Set,N=new Map,C=new Set,I=new Set,q=new Set,V=[],U=[],F=[],A=[],E=ah,X=new Map,B=new Map,z=($,Z)=>{x.set($,Z),w.set(Z,$)},Ce=new Set,Me=new Set,Be=null,me=$=>{let Z=$.nodeType?$.parentNode:$.parent;if(!Z||Z.nodeType!==11)return Z;if(!Be){Be=new WeakMap;let ke=we=>{for(let ve of we.querySelectorAll("template"))ve.content&&(Be.set(ve.content,ve),ke(ve.content))};for(let we of[e,t])ke(we.tagName==="TEMPLATE"&&we.content?we.content:we)}return Be.get(Z)||null},Te=($,Z)=>{for(let ke=me($);ke&&!Ce.has(ke);ke=me(ke))Ce.add(ke);for(let ke=me(Z);ke&&!Me.has(ke);ke=me(ke))Me.add(ke)},Xe=$=>{for(let Z=me($);Z;Z=me(Z))if(x.has(Z))return I.has(Z);return!1},_e=$=>{for(let Z=me($);Z;Z=me(Z)){let ke=w.get(Z);if(ke!==void 0)return I.has(ke)}return!1},O=$=>!!$&&$.nodeType===1,K=($,Z)=>{let ke=N.get($);return!!ke&&ke.has(Z)},fe=$=>Pa.has($.tagName),ae=n.comparisons||n.scope,qe=($,Z)=>{if(ae){if(ae.same.get($)===Z)return!0;if(ae.differ.get($)===Z)return!1}if(!$.isEqualNode(Z))return!1;if($.tagName==="TEMPLATE")return c($,Z);let ke=$.getElementsByTagName("template");if(ke.length===0)return!0;let we=Z.getElementsByTagName("template");if(ke.length!==we.length)return!1;for(let ve=0;ve<ke.length;ve++)if(!c(ke[ve],we[ve]))return!1;return!0},ze=($,Z)=>{let ke=u($);if(!ke)return!0;let we=f(Z);return!we||ke===we},Ee=$=>{let Z=h($);return Z&&n.baseIndex.get(Z)===$&&!g.has(Z)?Z:null},ot=$=>{let Z=d($);return Z&&n.sideIndex.get(Z)===$&&!v.has(Z)?Z:null},rt=($,Z)=>{let ke=Ee($);if(!ke)return!0;let we=ot(Z);return!we||ke===we},xt=globalThis.__hyperMorphProfile,nt=xt?performance.now():0;xt&&!n.scope&&(r(e),r(t),xt.meta=(xt.meta||0)+(performance.now()-nt),nt=performance.now()),z(e,t);let te=new Set;for(let[$,Z]of n.baseIndex){let ke=n.sideIndex.get($);ke&&ke.tagName===Z.tagName&&!x.has(Z)&&!w.has(ke)&&(z(Z,ke),Te(Z,ke),te.add(Z))}if(te.size){let $=[];if(n.scope)for(let ve of n.scope.chain)te.has(ve)&&$.push(ve);let Z=[n.scope?n.scope.root:e];for(;Z.length;){let ve=Z.pop();te.has(ve)&&$.push(ve);let ne=a(ve);for(let se=ne.length-1;se>=0;se--)ne[se].nodeType===1&&Z.push(ne[se])}let ke=new Set;for(let ve=$.length-1;ve>=0;ve--){let ne=$[ve];n.scope&&n.scope.onChain.has(ne)?ke.add(ne):Ge(ne,x.get(ne),ke)?(I.add(ne),q.add(ne),m&&m.certificationPairs++):ke.add(ne)}let we=new Set;for(let ve of $)I.has(ve)&&!we.has(ve)&&Ae(ve,we)}n.scope&&n.scope.head&&Et(n.scope.head[0],n.scope.head[1]);function Ae($,Z){let ke=[$];for(;ke.length;){let we=ke.pop();if(!Z.has(we)){Z.add(we),M(we);for(let ve of o(we))O(ve)&&x.has(ve)&&ke.push(ve)}}}A.push([e,t]);for(let[$,Z]of x)O($)&&$!==e&&A.push([$,Z]);return et(),je(),xt&&(xt.align=(xt.align||0)+(performance.now()-nt)),{map:x,reverse:w,moved:C,identical:I,pairIdenticalChildren:M,weak:T,unpair:Fe,rematch:je,insertedByHash:He,refused:S,identityPaired:te};function je(){Oe(),et();for(let $=0;$<F.length;){let Z=F.length;yt($,Z),$=Z,et(),Oe(),et()}}function Fe($){let Z=x.get($);if(!Z)return;N.has($)||N.set($,new Set),N.get($).add(Z);let ke=(ve,ne)=>{x.delete(ve),w.delete(ne),C.delete(ve),I.delete(ve),T.delete(ve),q.delete(ve)},we=(ve,ne)=>{for(let se of o(ve)){let W=x.get(se);!W||te.has(se)||!(O(W)?ne.contains(W):ne.contains(W.nodes[0]))||(ke(se,W),O(se)&&we(se,W))}};ke($,Z),O($)&&we($,Z),V.push($),U.push(Z)}function He(){let $=new Map;for(let Z of new Set(U)){if(w.has(Z))continue;let ke=r(Z).hash;$.has(ke)||$.set(ke,[]),$.get(ke).push(Z)}return $}function et(){for(;A.length;){let[$,Z]=A.shift();x.get($)!==Z||q.has($)||I.has($)||Ft($,Z)}}function bt($,Z){if(!fe($))for(let ke of o($))O(ke)&&(Z.push(ke),bt(ke,Z))}function Ft($,Z){q.add($);let ke=o($),we=o(Z);Fi.align+=ke.length+we.length,X=new Map,B=new Map;for(let ce=0;ce<ke.length;ce++)X.set(ke[ce],ce);for(let ce=0;ce<we.length;ce++)B.set(we[ce],ce);if($.tagName==="HTML")for(let ce of["HEAD","BODY"]){let Ne=ke.find(De=>O(De)&&De.tagName===ce),Pe=we.find(De=>O(De)&&De.tagName===ce);Ne&&Pe&&!x.has(Ne)&&!w.has(Pe)&&z(Ne,Pe)}for(let ce=0;ce<ke.length&&ce<we.length;ce++){let Ne=ke[ce],Pe=we[ce];x.has(Ne)||w.has(Pe)||(O(Ne)?O(Pe)&&Ne.tagName===Pe.tagName&&qe(Ne,Pe)&&Et(Ne,Pe):!O(Pe)&&Ne.kind===Pe.kind&&Ne.value===Pe.value&&Et(Ne,Pe))}de(ke,we);let ve=ke.filter(ce=>!x.has(ce)),ne=we.filter(ce=>!w.has(ce));ve.length&&ne.length&&(en(ve,ne),P(ve,ne),H(ve,ne,ke,we),ge(ke,we));let se=!1,W=!1;for(let ce of ke){if(!x.has(ce)){O(ce)&&(V.push(ce),bt(ce,V),se=!0);continue}O(ce)&&!I.has(ce)&&A.push([ce,x.get(ce)])}for(let ce of we)!w.has(ce)&&O(ce)&&(U.push(ce),bt(ce,U),W=!0);se&&W&&F.push([$,Z])}function yt($,Z){for(let ke=$;ke<Z;ke++){let[we,ve]=F[ke];if(x.get(we)!==ve)continue;let ne=o(we),se=o(ve),W=new Map,ce=new Map,Ne=null;for(let Pe of ne)O(Pe)&&(x.has(Pe)?Ne=Pe:(W.has(Ne)||W.set(Ne,[]),W.get(Ne).push(Pe)));Ne=null;for(let Pe of se)O(Pe)&&(w.has(Pe)?Ne=w.get(Pe):(ce.has(Ne)||ce.set(Ne,[]),ce.get(Ne).push(Pe)));for(let[Pe,De]of W){let Se=ce.get(Pe);if(!(!Se||De.length!==Se.length)&&De.every((tt,lt)=>Se[lt].tagName===tt.tagName&&ze(tt,Se[lt])&&!K(tt,Se[lt])))for(let tt=0;tt<De.length;tt++)Lt(De[tt],Se[tt])}}}function Lt($,Z){z($,Z),T.add($),A.push([$,Z]),et()}function en($,Z){let ke=Kr($,s),we=Kr(Z,s),ve=new Map;for(let ne of Z){let se=s(ne);we.get(se)===1&&ve.set(se,ne)}for(let ne of $){if(x.has(ne))continue;let se=s(ne);if(ke.get(se)!==1)continue;let W=ve.get(se);W&&!w.has(W)&&c(ne,W)&&Et(ne,W)}}function Ge($,Z,ke){let we=[[$,Z]];for(;we.length;){let[ve,ne]=we.pop();if(Fi.certifyVisited++,m&&m.certificationVisited++,ve.nodeType!==ne.nodeType)return!1;if(ve.nodeType===3||ve.nodeType===8){if(ve.nodeValue!==ne.nodeValue)return!1;continue}if(ve.nodeType!==1){if(!ve.isEqualNode(ne))return!1;continue}if(ve.tagName!==ne.tagName||ve.namespaceURI!==ne.namespaceURI||p(ve)!==p(ne))return!1;let se=ve.attributes,W=ne.attributes;if(se.length!==W.length)return!1;for(let Se=0;Se<se.length;Se++){let tt=se[Se];if(ne.getAttributeNS(tt.namespaceURI,tt.localName)!==tt.value)return!1}let ce=x.get(ve);if(ce!==void 0&&ce!==ne)return!1;let Ne=w.get(ne);if(Ne!==void 0&&Ne!==ve)return!1;if(ve!==$){if(I.has(ve))continue;if(ke.has(ve))return!1}let Pe=a(ve),De=a(ne);if(Pe.length!==De.length)return!1;Fi.certifyScheduled+=Pe.length;for(let Se=Pe.length-1;Se>=0;Se--)we.push([Pe[Se],De[Se]])}return!0}function Ct($,Z){return!O($)||!(Ce.has($)||Me.has(Z))?!0:!!Y($,Z)||!(Ee($)||ot(Z))}function Et($,Z){if(O($)&&(Ce.has($)||Me.has(Z))){let ke=Y($,Z);if(!ke){if(Ee($)||ot(Z))return;z($,Z),A.push([$,Z]);return}for(let we=0;we<ke.length;we+=2){let ve=ke[we],ne=ke[we+1],se=x.get(ve);se!==void 0&&se!==ne&&Jt(ve,se);let W=w.get(ne);W!==void 0&&W!==ve&&Jt(W,ne),x.get(ve)===ne&&(C.delete(ve),T.delete(ve),I.add(ve),q.add(ve))}}y($,Z)}function Jt($,Z){x.delete($),w.delete(Z),C.delete($),I.delete($),T.delete($),q.delete($)}function Y($,Z){let ke=[$,Z,!1],we=[];for(;ke.length;){let ve=ke.pop(),ne=ke.pop(),se=ke.pop(),W=x.get(se),ce=w.get(ne);if(se!==$&&(W!==void 0&&W!==ne&&te.has(se)||ce!==void 0&&ce!==se&&te.has(ce)))return null;if(!(W===ne&&I.has(se))&&((W!==void 0||ce!==void 0)&&we.push(se,ne),!!O(se))){if(ve||W!==void 0&&W!==ne||ce!==void 0&&ce!==se){let Ne=o(se),Pe=o(ne);for(let De=0;De<Ne.length&&De<Pe.length;De++)ke.push(Ne[De],Pe[De],!0)}else if(Ce.has(se)||Me.has(ne)){let Ne=se.tagName==="TEMPLATE"?se.content:se,Pe=ne.tagName==="TEMPLATE"?ne.content:ne;for(let De=Ne.firstElementChild,Se=Pe.firstElementChild;De&&Se;){if(p(De)){De=De.nextElementSibling;continue}if(p(Se)){Se=Se.nextElementSibling;continue}(x.has(De)||w.has(Se)||Ce.has(De)||Me.has(Se))&&ke.push(De,Se,!1),De=De.nextElementSibling,Se=Se.nextElementSibling}}}}return we}function y($,Z){z($,Z),I.add($),O($)&&q.add($)}function M($){let Z=x.get($);if(!Z||!O($))return;let ke=o($),we=o(Z);for(let ve=0;ve<ke.length&&ve<we.length;ve++)x.has(ke[ve])||y(ke[ve],we[ve])}function P($,Z){let ke=se=>O(se)&&!fe(se)?r(se).sig+""+r(se).hint:null,we=Kr($,ke),ve=Kr(Z,ke),ne=new Map;for(let se of Z){let W=ke(se);W!=null&&ve.get(W)===1&&ne.set(W,se)}for(let se of $){if(x.has(se))continue;let W=ke(se);if(W==null||we.get(W)!==1)continue;let ce=ne.get(W);ce&&!w.has(ce)&&ze(se,ce)&&z(se,ce)}}function H($,Z,ke,we){let ve=new Map;for(let se of Z){if(!O(se)||w.has(se)||fe(se))continue;let W=r(se).sig;ve.has(W)||ve.set(W,[]),ve.get(W).push({el:se,index:B.get(se)})}let ne=[];for(let se of $){if(x.has(se)||!O(se)||fe(se))continue;let W=ve.get(r(se).sig);if(!W||!W.length)continue;let ce=X.get(se),Ne=W.filter(Pe=>!w.has(Pe.el)).map(Pe=>({c:Pe,d:Math.abs(Pe.index-ce)}));Ne.sort((Pe,De)=>Pe.d-De.d),Ne.length>qa&&(Ne=Ne.slice(0,qa));for(let{c:Pe,d:De}of Ne){if(!ze(se,Pe.el))continue;let Se=l(se,Pe.el);Se&&Se.coef>=.5&&ne.push({b:se,s:Pe.el,coef:Se.coef,share:Se.share,d:De,bi:ce})}}if(ne.sort((se,W)=>W.coef-se.coef||W.share-se.share||se.d-W.d||se.bi-W.bi),m&&ne.length>1){let se=new Map;for(let W of ne){let ce=se.get(W.b);ce?ce.coef===W.coef&&(ce.share===W.share?ce.strict++:ce.loose++):se.set(W.b,{coef:W.coef,share:W.share,strict:0,loose:0})}for(let[W,ce]of se)k.has(W)||!(ce.strict||ce.loose)||(k.add(W),ce.strict?m.similarTiesStrict++:m.similarTiesLoose++)}for(let se of ne)!x.has(se.b)&&!w.has(se.s)&&z(se.b,se.s)}function Q($,Z){return O($)!==O(Z)?!1:O($)?$.tagName!==Z.tagName||!ze($,Z)?!1:fe($)||r($).hint===""||r(Z).hint===""?!0:i($,Z):$.kind===Z.kind}function D($,Z){let ke=(ve,ne)=>{let se=ne===null?-1:ve===Z?B.get(ne):X.get(ne),W=ve[se+1];return W&&!O(W)?W:null},we=null;for(let ve of $){if(O(ve)){we=ve;continue}if(x.has(ve))continue;let ne=we===null?null:x.get(we);if(we!==null&&!ne)continue;let se=ke(Z,ne);se&&!w.has(se)&&se.kind===ve.kind&&z(ve,se)}}function ge($,Z){D($,Z);let ke=xe($,Z),we=(ne,se)=>O(ne)&&r(ne).hint!==""&&r(se).hint===""&&!!se.querySelector("br")&&!ke(ne,se),ve=0;for(let ne of $){if(x.has(ne)){let W=B.get(x.get(ne));W!==void 0&&W>=ve&&(ve=W+1);continue}let se=0;for(let W=ve;W<Z.length&&se<ch;W++){let ce=Z[W];if(!w.has(ce)&&(se++,Q(ne,ce)&&!K(ne,ce)&&!we(ne,ce))){z(ne,ce),O(ne)&&(r(ne).hint===""||r(ce).hint==="")&&T.add(ne),ve=W+1;break}}}de($,Z)}function xe($,Z){let ke=(we,ve,ne)=>{for(let se=ve-1;se>=0;se--)if(O(we[se])&&ne(we[se]))return we[se];return null};return(we,ve)=>{let ne=X.get(we),se=B.get(ve);if(ne===se)return!0;let W=ke($,ne,Ne=>x.has(Ne)),ce=ke(Z,se,Ne=>w.has(Ne));return W?x.get(W)===ce:!ce}}function de($,Z){let ke=$.filter(W=>O(W)&&!x.has(W)),we=Z.filter(W=>O(W)&&!w.has(W));if(!ke.length||!we.length)return;let ve=Kr(ke,W=>W.tagName),ne=Kr(we,W=>W.tagName),se=xe($,Z);for(let W of ke){let ce=W.tagName;if(ve.get(ce)!==1||ne.get(ce)!==1)continue;let Ne=we.find(Pe=>Pe.tagName===ce);Ne&&!w.has(Ne)&&se(W,Ne)&&ze(W,Ne)&&!K(W,Ne)&&(c(W,Ne)?Et(W,Ne):(z(W,Ne),T.add(W)))}}function Oe(){let $=new Map;for(let W of T)if(O(W)&&O(x.get(W))){let ce=r(W).hash;$.has(ce)||$.set(ce,[]),$.get(ce).push(W)}if($.size)for(let W of U){if(w.has(W)||!O(W)||_e(W))continue;let ce=$.get(r(W).hash),Ne=ce&&ce.find(Pe=>T.has(Pe)&&!K(Pe,W)&&ze(Pe,W)&&rt(Pe,W)&&c(Pe,W)&&Ct(Pe,W));Ne&&(Fe(Ne),Et(Ne,W),Te(Ne,W),C.add(Ne))}let Z=new Map,ke=new Map,we=new Map;for(let W of T){let ce=x.get(W);O(W)&&O(ce)&&we.set(ce,W)}let ve=(W,ce)=>{if(!w.has(W))return!_e(W);let Ne=we.get(W);return Ne===w.get(W)&&Ne!==ce&&!Ne.contains(ce)},ne=W=>{if(w.has(W)){let ce=we.get(W);we.delete(W),Fe(ce)}};for(let W of[...U,...we.keys()]){if(w.has(W)&&!we.has(W))continue;let ce=r(W).hash;if(Z.has(ce)||Z.set(ce,[]),Z.get(ce).push(W),fe(W))continue;let Ne=r(W).sig;ke.has(Ne)||ke.set(Ne,[]),ke.get(Ne).push(W)}let se=new Set;for(let W of T){let ce=x.get(W);!O(W)||!O(ce)||fe(W)||r(W).hint===""||r(ce).hint===""||i(W,ce)||se.add(W)}for(let W of[...V,...se]){let ce=x.get(W);if(ce?!(T.has(W)&&se.has(W)):Xe(W))continue;let Ne=lt=>{ce&&Fe(W),ne(lt)},Pe=Z.get(r(W).hash);if(Pe){let lt=Pe.find(it=>it!==ce&&ve(it,W)&&!K(W,it)&&rt(W,it)&&c(W,it)&&Ct(W,it));if(lt){Ne(lt),Et(W,lt),Te(W,lt),C.add(W);continue}}if(fe(W)||E<=0)continue;let De=ke.get(r(W).sig);if(!De)continue;let Se=null,tt=0;for(let lt of De)if(!(lt===ce||!ve(lt,W)||!ze(W,lt)||!rt(W,lt)||K(W,lt))&&(E--<=0||i(W,lt)&&(tt++,Se=lt,tt>1)))break;tt>1&&S&&S.add(W),tt===1&&(Ne(Se),z(W,Se),Te(W,Se),C.add(W),A.push([W,Se]))}}}function Kr(e,t){let n=new Map;for(let r of e){let o=t(r);o!=null&&n.set(o,(n.get(o)||0)+1)}return n}var uh={diff:0},Da=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,fh=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,dh=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,hh=/\P{M}\p{M}*/gu;function mh(e){if(e==="")return[];if(Da){let n=[];for(let r of Da.segment(e))n.push(r.segment);return n}let t=[];for(let n of e.match(dh))if(fh.test(n))for(let r of n.match(hh))t.push(r);else t.push(n);return t}var ph=/^[  ]+$/,gh=e=>ph.test(e)?" ".repeat(e.length):e,cr=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),Nt="",$i=e=>e.every(t=>cr(t)||t.k===Nt),bh=/^[\x00-\x7f\u00A0]*$/,kh=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function yh(e){return e===""?[]:e.match(kh)}function fn(e,t=!1){return(t?yh(e):mh(e)).map(n=>({k:gh(n),raw:n,len:n.length}))}var xn=(...e)=>e.every(t=>bh.test(t));function Ui(e,t,n){let r=e.length,o=t.length,s=Math.min(r+o,n),i=s+1,l=new Int32Array(2*s+3),a=[],c=r===0&&o===0;for(let h=0;h<=s&&!c;h++){a.push(l.slice(i-h,i+h+1));for(let d=-h;d<=h;d+=2){let v;d===-h||d!==h&&l[i+d-1]<l[i+d+1]?v=l[i+d+1]:v=l[i+d-1]+1;let g=v-d,m=v;for(;v<r&&g<o&&e[v].k===t[g].k;)v++,g++;if(uh.diff+=1+v-m,l[i+d]=v,v>=r&&g>=o){c=!0;break}}}if(!c)return null;let p=[],u=r,f=o;for(let h=a.length-1;h>0;h--){let d=a[h],v=u-f,g=v+h,m=v===-h||v!==h&&d[g-1]<d[g+1]?v+1:v-1,k=d[m+h],S=k-m;for(;u>k&&f>S;)p.push([0,u-1,f-1]),u--,f--;u===k?(p.push([1,u,f-1]),f--):(p.push([-1,u-1,f]),u--)}for(;u>0&&f>0;)p.push([0,u-1,f-1]),u--,f--;return p.reverse(),p}function vh(e,t,n){let r=u=>u.k===Nt;if(!e.some(r)&&!t.some(r))return Ui(e,t,n);let o=[],s=[];for(let u=0;u<e.length;u++)r(e[u])||o.push(u);for(let u=0;u<t.length;u++)r(t[u])||s.push(u);let i=Ui(o.map(u=>e[u]),s.map(u=>t[u]),n);if(!i)return null;let l=[],a=0,c=0,p=(u,f)=>{for(;a<u&&c<f&&e[a].k===t[c].k;)l.push([0,a++,c++]);let h=Ui(e.slice(a,u),t.slice(c,f),n);if(!h)return!1;for(let[d,v,g]of h)l.push([d,v+a,g+c]);return a=u,c=f,!0};for(let[u,f,h]of i)if(u===0){if(!p(o[f],s[h]))return null;l.push([0,a,c]),a++,c++}return p(e.length,t.length)?l:null}function Jn(e,t,n=4e3){let r=[],o=0;for(;o<e.length&&o<t.length&&e[o].k===t[o].k;)e[o].raw!==t[o].raw&&r.push({bi:o,tok:t[o]}),o++;let s=0;for(;s<e.length-o&&s<t.length-o&&e[e.length-1-s].k===t[t.length-1-s].k;)e[e.length-1-s].raw!==t[t.length-1-s].raw&&r.push({bi:e.length-1-s,tok:t[t.length-1-s]}),s++;let i=e.slice(o,e.length-s),l=t.slice(o,t.length-s),a=Eh(i,l)?null:vh(i,l,n);if(!a){let m=i.length||l.length?[{bs:o,be:o+i.length,toks:l}]:[];return{hunks:m,cosmetic:r,coarse:!0,parts:m.map(k=>({...k,gap:[],group:0})),cosmeticEq:r}}let c=[],p=(m,k)=>{i[m].raw!==l[k].raw&&r.push({bi:o+m,tok:l[k]})},u=null,f=[],h=0,d=0,v=()=>{u&&c.push(u),u=null;for(let[m,k]of f)p(m,k);f=[],h++};for(let[m,k,S]of a){if(m===0){u&&cr(i[k])&&!i[k].k.includes(`
2
- `)?f.push([k,S]):(v(),p(k,S)),d=k+1;continue}(!u||f.length)&&(u&&c.push(u),u={bs:o+d,be:o+d,toks:[],gap:f.map(([x,w])=>({bi:o+x,tok:l[w]})),group:h},f=[]),m===-1?(u.be=o+d+1,d=k+1):u.toks.push(l[S])}v(),xh(c,e);let g=zi(c);return{hunks:g.hunks,cosmetic:r.concat(g.cosmetic),parts:c,cosmeticEq:r}}function xh(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r.gap.length)continue;let o=n+1<e.length?e[n+1].bs:1/0;if(r.toks.length){if(r.bs===r.be)for(;r.bs+1<o&&r.bs<t.length&&r.toks[0].k===Nt&&t[r.bs].k===Nt;)r.toks=[...r.toks.slice(1),r.toks[0]],r.bs++,r.be++}else for(;r.be+1<o&&r.be<t.length&&t[r.bs].k===Nt&&t[r.be].k===Nt;)r.bs++,r.be++}}function zi(e,t=()=>!1){let n=[],r=[],o=null,s=-1;for(let i of e){let l=t(i);if(o&&!o.alone&&!l&&i.group===s){o.be=i.be;for(let a of i.gap)o.toks.push(a.tok);for(let a of i.toks)o.toks.push(a);continue}o&&n.push({bs:o.bs,be:o.be,toks:o.toks});for(let a of i.gap)r.push(a);o={bs:i.bs,be:i.be,toks:i.toks.slice(),alone:l},s=i.group}return o&&n.push({bs:o.bs,be:o.be,toks:o.toks}),{hunks:n,cosmetic:r}}var wh=(e,t)=>e.bs===t.bs&&e.be===t.be&&Ki(e.toks,t.toks);function Wi(e,t,n){let r=p=>u=>p.some(f=>wh(u,f)),o=zi(e.parts,r(t.parts)),s=zi(t.parts,r(e.parts)),i=e.cosmeticEq.concat(o.cosmetic),l=t.cosmeticEq.concat(s.cosmetic),[a,c]=n?Sh(o.hunks,s.hunks,n,i,l):[o.hunks,s.hunks];return{lh:a,rh:c,cosL:i,cosR:l}}function Sh(e,t,n,r,o){let s=(d,v)=>d.k===v.k&&d.raw===v.raw,i=[{list:e.map(d=>({...d})),resp:new Set(r.map(d=>d.bi)),raw:new Map(r.map(d=>[d.bi,d.tok]))},{list:t.map(d=>({...d})),resp:new Set(o.map(d=>d.bi)),raw:new Map(o.map(d=>[d.bi,d.tok]))}],l=d=>d.bs===d.be,a=(d,v,g,m)=>{let k=d.list[v];if(!l(k))return m(k)===g?k.toks:null;let S=v?d.list[v-1].be:0,x=v+1<d.list.length?d.list[v+1].bs:n.length;if(g<S||g>x)return null;let w=k.toks,T=k.bs;for(;T>g;){let N=w[w.length-1];if(!s(N,n[T-1])||d.resp.has(T-1))return null;w=[N,...w.slice(0,-1)],T--}for(;T<g;){if(!s(w[0],n[T])||d.resp.has(T))return null;w=[...w.slice(1),w[0]],T++}return w},c=(d,v,g,m,k,S)=>{let x=d.list[v],w=k?g.slice(g.length-m):g.slice(0,m),T=k?g.slice(0,g.length-m):g.slice(m),N={bs:S,be:S,toks:w};if(l(x)){if(!T.length){d.list[v]=N;return}let I={bs:S,be:S,toks:T};k&&(I.lead=!0),d.list.splice(v,1,...k?[I,N]:[N,I]);return}let C={bs:x.bs,be:x.be,toks:T};d.list.splice(v,1,...k?[C,N]:[N,C])},p=(d,v,g,m,k)=>{let S=d.list[v],x=k?g.slice(g.length-m):g.slice(0,m),w=k?g.slice(0,g.length-m):g.slice(m),T={bs:S.bs,be:S.be,toks:x};if(!w.length){d.list[v]=T;return}let N=k?{bs:S.bs,be:S.bs,toks:w,lead:!0}:{bs:S.be,be:S.be,toks:w};d.list.splice(v,1,...k?[N,T]:[T,N])},u=(d,v,g,m)=>{let k=d.list[v],S=g.list[m],x=k.be,w=S.bs;if(x>=w||v+1<d.list.length&&d.list[v+1].bs<=S.be||m>0&&g.list[m-1].be>=k.bs)return!1;for(let B=x;B<w;B++)if(!cr(n[B])||n[B].k.includes(`
3
- `))return!1;let T=B=>n.slice(x,w).map((z,Ce)=>B.raw.get(x+Ce)||z),N=[...k.toks,...T(d)],C=[...T(g),...S.toks],I=(B,z,Ce)=>z>=0&&z+Ce.length<=B.length&&Ce.every((Me,Be)=>B[z+Be].k===Me.k),q=(B,z,Ce)=>$i(B)&&n.slice(z,Ce).some(Me=>!cr(Me)),V=B=>B.some(z=>!cr(z)),U,F,A,E;if(l(k)&&V(k.toks)&&I(C,0,k.toks)){let B=C.slice(k.toks.length);q(B,x,S.be)||(U=x,F=k.toks,A=C.slice(0,k.toks.length),E=[null,{bs:x,be:S.be,toks:B}])}if(U===void 0&&l(S)&&V(S.toks)){let B=N.length-S.toks.length,z=N.slice(0,B);I(N,B,S.toks)&&!q(z,k.bs,w)&&(U=w,F=N.slice(B),A=S.toks,E=[{bs:k.bs,be:w,toks:z},null])}if(U===void 0)return!1;let X=B=>B&&(B.bs<B.be||B.toks.length);return d.list.splice(v,1,...[E[0],{bs:U,be:U,toks:F}].filter(X)),g.list.splice(m,1,...[{bs:U,be:U,toks:A},E[1]].filter(X)),!0},f=i[0],h=i[1];for(let d=0;d<64;d++){let v=!1;e:for(let g=0;g<f.list.length;g++)for(let m=0;m<h.list.length;m++){let k=f.list[g],S=h.list[m];if(!(k.bs===S.bs&&k.be===S.be&&Ki(k.toks,S.toks))){for(let x of[!0,!1]){let w=N=>x?N.be:N.bs,T=l(k)?[w(S),k.bs]:[w(k)];for(let N of T){let C=a(f,g,N,w),I=C&&a(h,m,N,w);if(!I)continue;let q=(E,X)=>x?E[E.length-1-X]:E[X],V=0;for(;V<C.length&&V<I.length&&q(C,V).k===q(I,V).k;)V++;if(!V)continue;let U=x?C.slice(0,C.length-V):C.slice(V),F=x?I.slice(0,I.length-V):I.slice(V);if(!(V<C.length&&V<I.length&&!$i(U)&&!$i(F)&&(l(k)&&l(S)||k.bs===S.bs&&k.be===S.be)||!(x?C.slice(C.length-V):C.slice(0,V)).some(E=>!cr(E)))){if(V===C.length&&V===I.length&&l(k)&&l(S)){if(k.bs===N&&S.bs===N)continue;f.list[g]={bs:N,be:N,toks:C},h.list[m]={bs:N,be:N,toks:I}}else!l(k)&&k.bs===S.bs&&k.be===S.be?(p(f,g,C,V,x),p(h,m,I,V,x)):(c(f,g,C,V,x,N),c(h,m,I,V,x,N));v=!0;break e}}}if(u(f,g,h,m)||u(h,m,f,g)){v=!0;break e}}}if(!v)break}return[f.list,h.list]}var Ah=48,Th=.3;function Eh(e,t){let n=e.filter(i=>!cr(i)),r=t.filter(i=>!cr(i));if(Math.min(n.length,r.length)<Ah)return!1;let o=new Map;for(let i of n)o.set(i.k,(o.get(i.k)||0)+1);let s=0;for(let i of r){let l=o.get(i.k);l>0&&(s++,o.set(i.k,l-1))}return s/Math.min(n.length,r.length)<Th}var Oh=(e,t)=>{let n=new Set;for(let r of e.toks)typeof r.k!="string"&&n.add(r.k.el);for(let r=e.bs;r<e.be;r++)typeof t[r].k!="string"&&n.add(t[r].k.el);return n},Ki=(e,t)=>e.length===t.length&&e.every((n,r)=>n.k===t[r].k);function Fa(e,t,n,r="remote"){let o=Jn(e,t),s=Jn(e,n),{lh:i,rh:l,cosL:a,cosR:c}=Wi(o,s,e),p=O=>O.bs===O.be,u=O=>O.toks.some(K=>typeof K.k=="string"),f=O=>p(O)&&!u(O),h=(O,K)=>K.bs<O.be&&O.bs<K.be,d=(O,K)=>!h(O,K)&&K.bs<=O.be&&O.bs<=K.be&&(p(O)&&u(O)||p(K)&&u(K))&&!(p(O)&&p(K)),v=(O,K)=>O.bs===K.bs&&O.be===K.be&&Ki(O.toks,K.toks),g=[],m=new Set;for(let O of i){let K=l.find(fe=>!m.has(fe)&&v(O,fe));K?(m.add(K),g.push({bs:O.bs,be:O.be,side:"both",l:O,r:K,toks:O.toks})):g.push({bs:O.bs,be:O.be,side:"L",l:O,toks:O.toks,lead:!!O.lead})}for(let O of l)m.has(O)||g.push({bs:O.bs,be:O.be,side:"R",r:O,toks:O.toks,lead:!!O.lead});g.sort((O,K)=>O.bs-K.bs||O.be-K.be||K.lead-O.lead);let k=0,S=0;for(let O of g)O.side==="both"&&(k+=O.toks.length-(O.be-O.bs));let x=g.map((O,K)=>K),w=O=>x[O]===O?O:x[O]=w(x[O]),T=(O,K)=>(O=w(O),K=w(K),O===K?!1:(x[O]=K,!0)),N=g.map(O=>Oh({bs:O.bs,be:O.be,toks:O.toks},e)),C={L:new Map,R:new Map};g.forEach((O,K)=>{let fe=O.side==="both"?["L","R"]:[O.side];for(let ae of fe)for(let qe of N[K])C[ae].has(qe)||C[ae].set(qe,[]),C[ae].get(qe).push(K)});for(let O of[C.L,C.R])for(let K of O.values())for(let fe=1;fe<K.length;fe++)T(K[0],K[fe]);for(let O=0;O<g.length;O++)for(let K=O+1;K<g.length;K++){let fe=g[O],ae=g[K];fe.side===ae.side&&fe.side!=="both"||fe.bs>ae.be||(h(fe,ae)||d(fe,ae)?T(O,K):fe.bs===ae.bs&&p(fe)&&p(ae)&&S++)}let I=(O,K)=>{let fe=O==="L"?i:l;for(let ae of fe)if(ae.toks.some(qe=>qe.kind==="close"&&qe.k.el===K.el))return ae.bs;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="close"&&e[ae].k.el===K.el)return ae;return-1};g.forEach((O,K)=>{if(!(!f(O)||O.side==="both"))for(let fe of O.toks){if(fe.kind!=="open")continue;let ae=I(O.side,fe.k);if(ae<=O.bs)continue;let qe=new Uint8Array(ae-O.bs),ze=[];if(g.forEach((Ee,ot)=>{if(!(Ee.side===O.side||p(Ee))&&Ee.bs<ae&&Ee.be>O.bs){ze.push(ot);for(let rt=Math.max(Ee.bs,O.bs);rt<Math.min(Ee.be,ae);rt++)qe[rt-O.bs]=1}}),ze.length&&qe.every(Ee=>Ee===1))for(let Ee of ze)T(K,Ee)}});let q=!0;for(;q;){q=!1;let O=new Map;g.forEach((K,fe)=>{let ae=w(fe),qe=O.get(ae)||{bs:K.bs,be:K.be,L:!1,R:!1};qe.bs=Math.min(qe.bs,K.bs),qe.be=Math.max(qe.be,K.be),K.side!=="R"&&(qe.L=!0),K.side!=="L"&&(qe.R=!0),O.set(ae,qe)}),g.forEach((K,fe)=>{for(let[ae,qe]of O){if(w(fe)===w(ae)||!(qe.L&&qe.R))continue;let ze=K.bs<qe.be&&K.be>qe.bs,Ee=p(K)&&u(K)&&(K.bs===qe.be||K.bs===qe.bs);(ze||Ee)&&T(fe,ae)&&(q=!0)}})}let V=new Map;g.forEach((O,K)=>{let fe=w(K);V.has(fe)||V.set(fe,[]),V.get(fe).push(O)});let U=[];for(let O of V.values()){let K=O.some(ae=>ae.side==="L"),fe=O.some(ae=>ae.side==="R");if(K&&fe){let ae=Math.min(...O.map(ot=>ot.bs)),qe=Math.max(...O.map(ot=>ot.be)),ze=O.filter(ot=>ot.side!=="R").map(ot=>ot.l).sort((ot,rt)=>ot.bs-rt.bs),Ee=O.filter(ot=>ot.side!=="L").map(ot=>ot.r).sort((ot,rt)=>ot.bs-rt.bs);U.push({bs:ae,be:qe,kind:"conflict",localHunks:ze,remoteHunks:Ee})}else for(let ae of O)U.push({bs:ae.bs,be:ae.be,kind:ae.side,u:ae})}let F=(O,K)=>{let fe=O==="L"?i:l;for(let ae of fe)if(ae.toks.some(qe=>qe.kind==="close"&&qe.k.el===K.el))return ae.bs+.5;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="close"&&e[ae].k.el===K.el)return ae;return 1/0},A=(O,K)=>{let fe=O==="L"?i:l;for(let ae of fe)if(ae.toks.some(qe=>qe.kind==="open"&&qe.k.el===K.el))return ae.bs-.5;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="open"&&e[ae].k.el===K.el)return ae;return-1/0},E=O=>O.kind==="R"?"R":"L",X=O=>O.kind==="R"?1:0;U.sort((O,K)=>{if(O.bs!==K.bs)return O.bs-K.bs;let fe=O.bs===O.be,ae=K.bs===K.be;if(fe!==ae)return fe?-1:1;if(fe&&ae&&O.kind!=="conflict"&&K.kind!=="conflict"){let ze=O.u.toks,Ee=K.u.toks,ot=xt=>xt.length&&xt.every(nt=>nt.kind==="open"),rt=xt=>xt.length&&xt.every(nt=>nt.kind==="close");if(ot(ze)&&ot(Ee)){let xt=Math.max(...ze.map(te=>F(E(O),te.k))),nt=Math.max(...Ee.map(te=>F(E(K),te.k)));if(xt!==nt)return nt-xt}if(rt(ze)&&rt(Ee)){let xt=Math.min(...ze.map(te=>A(E(O),te.k))),nt=Math.min(...Ee.map(te=>A(E(K),te.k)));return xt!==nt?nt-xt:X(K)-X(O)}}let qe=ze=>ze.u&&ze.u.lead?1:0;return qe(K)-qe(O)||X(O)-X(K)||O.be-K.be});let B=[],z=[],Ce=0,Me=O=>{O>Ce&&(B.push({bs:Ce,be:O,toks:e.slice(Ce,O),source:"base"}),Ce=O)};for(let O of U){if(Me(O.bs),O.kind==="conflict"){let K=Vi(e,O.localHunks,O.bs,O.be),fe=Vi(e,O.remoteHunks,O.bs,O.be),ae=r==="local"?K:r==="both"?K.concat(fe):fe,qe=(ot,rt)=>{let xt=0;for(let nt of ot)nt.be<=O.bs&&!rt.includes(nt)&&(xt+=nt.toks.length-(nt.be-nt.bs));return xt},ze=O.bs+qe(i,O.localHunks),Ee=O.bs+qe(l,O.remoteHunks);z.push({bs:O.bs,be:O.be,ls:ze,le:ze+K.length,rs:Ee,re:Ee+fe.length,ms:0,me:0,base:e.slice(O.bs,O.be),local:K,remote:fe,resolved:ae}),B.push({bs:O.bs,be:O.be,toks:ae,source:"conflict",localHunks:O.localHunks,localToks:K,keepsLocal:r!=="remote"})}else B.push({bs:O.bs,be:O.be,toks:O.u.toks,source:O.kind==="R"?"remote":"local",localHunks:O.kind==="R"?[]:[O.u.l]});Ce=Math.max(Ce,O.be)}Me(e.length);let Be=0,me=0;for(let O of B)O.source==="conflict"&&(z[me].ms=Be,z[me].me=Be+O.toks.length,me++),Be+=O.toks.length;let Te=new Map(a.map(O=>[O.bi,O.tok])),Xe=new Map(c.map(O=>[O.bi,O.tok])),_e=[];for(let O of B){O.source==="base"&&(O.toks=O.toks.map((K,fe)=>{let ae=O.bs+fe,qe=Te.get(ae),ze=Xe.get(ae),Ee=qe&&ze?r==="remote"?ze:qe:qe||ze||K;return Ee===K?K:{...Ee,cosmetic:!0}}));for(let K of O.toks)_e.push({...K,src:O.source})}return{tokens:_e,segments:B,conflicts:z,localHunks:i,remoteHunks:l,collapsedDelta:k,samePoint:S,mapLocalOffset:Nh(e,i,B)}}function Vi(e,t,n,r){let o=[],s=n;for(let i of t)o=o.concat(e.slice(s,i.bs),i.toks),s=i.be;return o.concat(e.slice(s,r))}var Hi=e=>e.reduce((t,n)=>t+n.len,0);function Nh(e,t,n){let r=new Int32Array(e.length+1);for(let i=0;i<e.length;i++)r[i+1]=r[i]+e[i].len;let o=t.map(i=>({bs:r[i.bs],be:r[i.be],text:i.toks.map(l=>l.raw).join(""),ref:i})),s=n.map(i=>({bs:r[i.bs],be:r[i.be],len:Hi(i.toks),source:i.source,localHunks:i.localHunks||[],localLen:i.localToks?Hi(i.localToks):0,keepsLocal:i.keepsLocal,ref:i}));return i=>{let l=null,a=null,c=0,p=0,u=0;for(let h of o){let d=h.bs-u;if(i<=p+d){l=u+(i-p);break}if(p+=d,u=h.bs,i<=p+h.text.length){a=h,c=i-p,l=h.bs;break}p+=h.text.length,u=h.be}l===null&&(l=u+(i-p));let f=0;for(let h of s){if(!a&&l<=h.bs)return f;if(!(a?h.localHunks.includes(a.ref):l<h.be)){f+=h.len;continue}if(h.source==="base")return f+(l-h.bs);if(h.source==="remote")return f+h.len;if(h.source==="local")return f+Math.min(c,h.len);if(!h.keepsLocal||!a)return f+h.len;let v=h.localHunks.indexOf(a.ref),g=Hi(Vi(e,h.localHunks.slice(0,v),h.ref.bs,a.ref.bs));return f+Math.min(g+c,h.localLen)}return f}}function qo(e,t,n,r="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:m=>Math.min(m,t.length),granularity:"word"};let o=xn(e,t,n),s=fn(e,o),i=fn(t,o),l=fn(n,o),a=s.length<=2e4&&i.length<=2e4&&l.length<=2e4?Fa(s,i,l,r):null,c="word",p=s;if(!a){let m=k=>k.split(/(?<=\n)/).map(S=>({k:S,raw:S,len:S.length}));p=m(e),a=Fa(p,m(t),m(n),r),c="line"}let u=m=>m.map(k=>k.raw).join(""),f=m=>{let k=[0];for(let S of m)k.push(k[k.length-1]+S.len);return k},h=f(p),d=null,v=null,g=null;if(a.conflicts.length){let m=k=>k.split(/(?<=\n)/).map(S=>({k:S,raw:S,len:S.length}));d=f(c==="line"?m(t):i),v=f(c==="line"?m(n):l),g=f(a.tokens)}return{text:u(a.tokens),conflicts:a.conflicts.map(m=>({bs:h[m.bs],be:h[m.be],ls:d[m.ls],le:d[m.le],rs:v[m.rs],re:v[m.re],ms:g[m.ms],me:g[m.me],base:u(m.base),local:u(m.local),remote:u(m.remote),resolved:u(m.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:c}}function Er(e,t,n=4e3){if(e===t)return[];let r=xn(e,t),o=fn(e,r),s=fn(t,r),i=Jn(o,s,n),l=[0];for(let a of o)l.push(l[l.length-1]+a.len);return i.hunks.map(a=>({bs:l[a.bs],be:l[a.be],text:a.toks.map(c=>c.raw).join("")}))}function Gt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function zn({base:e,side:t,retained:n,transfers:r,baseAtomKey:o=l=>l.el,sideAtomKey:s=l=>l.el,budget:i=Gt()}){let l=[],a=w=>({status:"fallback",reason:w}),c=w=>w>i.remaining?!1:(i.remaining-=w,!0);if(!c((n.length+r.length)*3))return a("work-limit");for(let[w,T]of[["retained",n],["transfer",r]])for(let N of T){let{from:C,to:I,target:q}=N;if(!Number.isInteger(C)||!Number.isInteger(I)||!Number.isInteger(q)||C<0||I<=C||I>e.text.length||q<0||q+I-C>t.text.length)return a("invalid-range");l.push({...N,kind:w})}let p=Symbol(),u=w=>(T,N)=>{if(!c(1))throw p;return i.sortComparisons++,w(T,N)},f,h;try{f=l.slice().sort(u((w,T)=>w.from-T.from||w.to-T.to)),h=l.slice().sort(u((w,T)=>w.target-T.target||w.to-w.from-(T.to-T.from)))}catch(w){if(w===p)return a("work-limit");throw w}if(!c(l.length*2))return a("work-limit");for(let w=1;w<f.length;w++)if(f[w].from<f[w-1].to)return a("source-overlap");for(let w=1;w<h.length;w++)if(h[w].target<h[w-1].target+h[w-1].to-h[w-1].from)return a("target-overlap");for(let w of f){let T=w.to-w.from;if(!c(T))return a("work-limit");for(let N=0;N<T;N++){let C=w.from+N,I=w.target+N;if(i.comparisons++,e.text[C]!==t.text[I])return a("unequal-occurrence");let q=e.atomAt.get(C),V=t.atomAt.get(I);if(!!q!=!!V||q&&o(q)!==s(V))return a("different-atom")}}let d=e.text.length+t.text.length+2,v=l.reduce((w,T)=>w+(T.to-T.from)*2,2);if(!c(d+v+l.length))return a("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),m=new Int32Array(t.text.length+1).fill(-1);i.mapCells+=d,i.mapWrites+=v;let k=-1,S=!0;for(let w of f){w.target<k&&(S=!1),k=w.target+w.to-w.from;for(let T=0;T<w.to-w.from;T++)g[w.from+T]=w.target+T,m[w.target+T]=w.from+T}return g[e.text.length]=t.text.length,m[t.text.length]=e.text.length,{status:"ready",runs:f,bTo:g,toB:m,monotone:S,covers:(w,T)=>{if(!c(T-w))return null;i.coverageChecks+=T-w;for(let N=w;N<T;N++)if(e.text[N]!==Nt&&!/\s/.test(e.text[N])&&g[N]<0)return!1;return!0}}}function Gi({base:e,side:t,baseOf:n=()=>null,budget:r=Gt()}){if(e.text===t.text||!e.text.includes(Nt)&&!t.text.includes(Nt))return{status:"none"};let o=(e.text.length+t.text.length)*8;if(o>r.remaining)return{status:"fallback",reason:"work-limit"};r.remaining-=o,r.boundarySteps=(r.boundarySteps||0)+o;let s=(d,v)=>v<d.length&&(d[v]===Nt||/\s/.test(d[v])),i=new Map,l=Symbol(),a=(d,v)=>{let g=d.stackAt[v]||[];if(!i.has(g)){if(g.length>r.remaining)throw l;r.remaining-=g.length,r.boundarySteps+=g.length,i.set(g,g.find(m=>m.block)?.el||null)}return i.get(g)},c=[],p=(d,v)=>{let g=a(e,d),m=a(t,v),k=g&&m&&n(m)!==g?"transfer":"retained",S=c[c.length-1];S&&S.to===d&&S.target+S.to-S.from===v&&S.kind===k&&S.destination===m?S.to++:c.push({from:d,to:d+1,target:v,destination:m,kind:k})},u=0,f=0,h=!1;try{for(;u<e.text.length||f<t.text.length;){if(u<e.text.length&&f<t.text.length&&e.text[u]===t.text[f]){let S=e.atomAt.get(u),x=t.atomAt.get(f);if(!!S!=!!x||S&&n(x.el)!==S.el)return{status:"none"};p(u++,f++);continue}if(!s(e.text,u)&&!s(t.text,f))return{status:"none"};let d=u,v=f;for(;s(e.text,u);)u++;for(;s(t.text,f);)f++;let g=e.text.slice(d,u),m=t.text.slice(v,f);(g.includes(Nt)||m.includes(Nt))&&(h=!0);let k=0;for(;k<u-d&&k<f-v&&e.text[u-k-1]===t.text[f-k-1];)k++;for(let S=k;S>0;S--)p(u-S,f-S)}}catch(d){if(d===l)return{status:"fallback",reason:"work-limit"};throw d}return h?zn({base:e,side:t,retained:c.filter(d=>d.kind==="retained"),transfers:c.filter(d=>d.kind==="transfer"),sideAtomKey:d=>n(d.el)||d.el,budget:r}):{status:"none"}}var Ba=/\s/,xs=/\S/;function Ln(e,t,n,r,o,s,i=-1,l=-1){if(!e.length)return-1;o(r,e.length);let a=new Int32Array(e.length),c=0;for(let h=1;h<e.length;h++){for(o(r,1);c&&(o(r,1),e[c]!==e[h]);)c=a[c-1];o(r,1),e[c]===e[h]&&c++,a[h]=c}let p=-1,u=0,f=0;c=0;for(let h=0;h<t.length;h++){for(o(r,1);c&&(o(r,1),e[c]!==t[h]);)c=a[c-1];if(o(r,1),e[c]===t[h]&&c++,c!==e.length)continue;let d=h+1-e.length,v=h+1;for(c=a[c-1];u<n.length&&n[u].from<d;)o(r,1),u++;for(;f<n.length&&n[f].to<v;)o(r,1),f++;if(o(r,6),!(u===n.length||f===n.length||n[u].from!==d||n[f].to!==v||i>=0&&d<l&&v>i)){if(!s)return d;if(p>=0)return-1;p=d}}return p}function Do(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function Yi(e,t,n,r){let o=null;for(let i of t)if(r(n,1),!(i.source!==e.source||i.side!==e.side))for(let l of i.runs){if(r(n,1),l.source!==e.source)continue;let a=Math.max(e.from,l.from),c=Math.min(e.to,l.to);a>=c||(o||(r(n,e.to-e.from),o=new Uint8Array(e.to-e.from)),r(n,c-a),o.fill(1,a-e.from,c-e.from))}if(!o)return!1;r(n,e.to-e.from);let s=!1;for(let i=e.from;i<e.to;i++)if(xs.test(e.flat.text[i])){if(!o[i-e.from])return!1;s=!0}return s}function Xi({source:e,side:t,views:n,eligible:r,blocked:o,baseId:s,model:i,tokensOf:l,budget:a,charge:c}){let{V:p,A:u,idOf:f}=n[t],h=n[1-t];if(e.nodeType!==1||u.identical.has(e)||h.A.identical.has(e)||o.has(e)||!r(e))return null;let d=p.twin(e),v=h.V.twin(e);if(!d||!v||u.map.get(e)!==d||u.reverse.get(d)!==e||h.A.map.get(e)!==v||h.A.reverse.get(v)!==e||!p.here(d)||!h.V.here(v)||!r(d)||!r(v))return null;let g=s(e);if(g!==f(d)||g!==h.idOf(v))return null;let m=i(e,null,a),k=i(d,u,a),S=i(v,h.A,a);if(!Do(m)||!Do(k)||!Do(S))return null;let x=m.flat.text,w=k.flat.text;if(c(a,x.length+w.length*3),!xs.test(w)||w.length>=x.length)return null;let T=x.startsWith(w),N=x.endsWith(w);if(T===N)return null;let C=T?w.length:0,I=T?x.length:x.length-w.length,q=C,V=I;for(;q<V&&(c(a,1),!!Ba.test(x[q]));)q++;for(;V>q&&(c(a,1),!!Ba.test(x[V-1]));)V--;if(q===V)return null;let U=l(m,a),F=!1,A=!1;for(let E of U)c(a,1),E.from===q&&(F=!0),E.to===V&&(A=!0);return!F||!A?null:{source:e,side:t,flat:m.flat,from:C,to:I}}function $a({base:e,views:t,side:n,attempt:r,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,certificates:c,charge:p,exhausted:u,limit:f}){if(f<=0)return null;let h=Gt(f),{V:d,A:v,idOf:g}=t[n],m=t[1-n],[k,S,x,w]=r,T=null;try{for(let N=k;N<=S;N++){p(h,1);let C=e[N];if(C.nodeType!==1||v.identical.has(C)||m.A.identical.has(C)||s.has(C)||!o(C))continue;let I=Xi({source:C,side:n,views:t,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,budget:h,charge:p});if(!I||Yi(I,c,h,p))continue;let{flat:q,from:V,to:U}=I;p(h,(U-V)*2);let F=q.text.slice(V,U).trim();for(let A=x;A<=w;A++){p(h,1);let E=d.units[A],X=d.baseOf(E);if(!X||X===C||X.nodeType!==1||E.nodeType!==1||X.parentNode!==C.parentNode||E.parentNode!==v.map.get(C).parentNode||v.map.get(X)!==E||v.reverse.get(E)!==X||s.has(X)||!o(X)||!o(E)||i(X)!==g(E))continue;let B=l(X,null,h),z=l(E,v,h);if(!Do(B)||!Do(z))continue;let Ce=B.flat.text,Me=z.flat.text;if(p(h,Ce.length),!xs.test(Ce)||Me.length<=Ce.length)continue;let Be=a(z,h),me=Ln(Ce,Me,Be,h,p,!0);if(!(me<0)&&!(Ln(F,Me,Be,h,p,!1,me,me+Ce.length)<0)){(T||=[]).push(I);break}}}}catch(N){if(N!==u)throw N}return T}function Ua(e,t,n,r,o,s,i){if(s==="both"||n.atoms.length||r.atoms.length||o.atoms.length)return s;let l=s==="remote";if(l?i.rss!==i.rse||i.lss===i.lse||i.local===i.base:i.lss!==i.lse||i.rss===i.rse||i.remote===i.base)return s;for(let a of e){if(a.source!==t||a.side!==(l?1:0)||a.flat.text!==n.text||a.flat.nodes.length!==n.nodes.length||i.be<=a.from||i.bs>=a.to)continue;let c=!0;for(let u=0;u<n.nodes.length;u++){let f=a.flat.nodes[u],h=n.nodes[u];if(f.node!==h.node||f.s!==h.s||f.e!==h.e){c=!1;break}}if(!c)continue;let p=!1;for(let u=i.bs;u<i.be;u++)if(xs.test(n.text[u])){if(u<a.from||u>=a.to){c=!1;break}p=!0}if(c&&p)return l?"local":"remote"}return s}var Vn="\uFFFC";var Ch={caret:0},wn=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),Xa=new Set(["BR","WBR","IMG"]),Ji=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function Wn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||Xa.has(e.tagName))return!0;if(!wn.has(e.tagName))return!Ji.has(e.tagName);if(t.remoteWins&&t.remoteWins(e))return!1;let n=t.inlineCache&&t.inlineCache.get(e);if(n!==void 0)return n;let r=!0;for(let o of e.childNodes)if(!Wn(o,t)){r=!1;break}return t.inlineCache&&t.inlineCache.set(e,r),r}function _h(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function Qt(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},r=(o,s)=>{for(let i of o){if(i.nodeType===3){let u=i.nodeValue;if(!u)continue;n.nodes.push({node:i,s:n.text.length,e:n.text.length+u.length}),n.text+=u;for(let f=0;f<u.length;f++)n.stackAt.push(s);continue}if(i.nodeType!==1)continue;if(t.ignored&&t.ignored(i)){n.pins.push({el:i,i:n.text.length});continue}if(t.skip&&t.skip.has(i))continue;let l=t.via&&t.via(i)||i;l!==i&&(n.via||(n.via=new Map)).set(l,i);let a=i.tagName;if(t.blocks&&t.blocks.has(i)){n.text.length&&n.text[n.text.length-1]!==Nt&&(n.stackAt.push(s),n.text+=Nt);let u={el:i,tag:a,from:n.text.length,to:-1,depth:s.length,block:!0};n.marks.push(u);let f=s.concat([u]);r(l.childNodes,f),n.stackAt.push(f),n.text+=Nt,u.to=n.text.length;continue}let c=wn.has(a)&&_h(l);if(Xa.has(a)||!wn.has(a)||t.remoteWins&&t.remoteWins(i)||t.atomize&&t.atomize(i)||c){n.atoms.push({i:n.text.length,el:i,key:c?a+":empty":a,stack:s}),n.stackAt.push(s),n.text+=Vn;continue}let p={el:i,tag:a,from:n.text.length,to:-1,depth:s.length};n.marks.push(p),r(l.childNodes,s.concat([p])),p.to=n.text.length}};if(r(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&As(n).trim()===""){let o=n.atoms[0];n.placeholder=o.el,n.text=n.text.slice(0,o.i)+n.text.slice(o.i+1),n.stackAt.splice(o.i,1);for(let s of n.nodes)s.s>o.i&&(s.s--,s.e--);n.atoms=[]}return n.atomAt=new Map(n.atoms.map(o=>[o.i,o])),n}function Mh(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Rh(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,"&quot;")}"`;return t+">"}function Yr(e,t,n){let r="",o=[];for(let s=t;s<n;s++){let i=e.stackAt[s],l=0;for(;l<o.length&&l<i.length&&o[l]===i[l];)l++;for(;o.length>l;)r+=`</${o.pop().tag.toLowerCase()}>`;for(;o.length<i.length;){let c=i[o.length];r+=Rh(c.el),o.push(c)}let a=e.atomAt.get(s);r+=a?a.el.outerHTML:e.text[s]===Nt?"":Mh(e.text[s])}for(;o.length;)r+=`</${o.pop().tag.toLowerCase()}>`;return r}function Lh(e,t){let n=[...e.el.attributes].filter(r=>!t(e.el,r.name)).map(r=>r.name+"="+r.value).sort().join("");return e.tag+"|"+n}function Ja(e,t){let n=[...e.attributes].filter(r=>!t(e,r.name)).map(r=>r.name+"="+r.value).sort().join("");return e.tagName+"|"+n+"|"+e.innerHTML}function Ha(e,t=()=>!1){let n=new Map,r=s=>{let i=n.get(s);return i===void 0&&(i="{"+s.map(l=>Lh(l,t)).sort().join(",")+"}",n.set(s,i)),i},o="";for(let s=0;s<e.text.length;s++){let i=e.atomAt.get(s);o+=(i?"["+Ja(i.el,t)+"]":e.text[s])+r(e.stackAt[s])}return e.text.length===0&&e.placeholder&&(o+="[br]"),o}function Gr(e,t,n,r=o=>o.key){let o=[],s=e.text,i=0,l=a=>{if(a<=i)return;let c=s.slice(i,a);if(n)for(let p of c.split(/(?<=\n)/))o.push({k:p,raw:p,len:p.length});else for(let p of fn(c,t))o.push(p)};for(let a of e.atoms)l(a.i),o.push({k:"\0"+r(a),raw:Vn,len:1,atom:!0}),i=a.i+1;return l(s.length),o}function As(e){if(!e.atoms.length)return e.text;let t="",n=0;for(let r of e.atoms)t+=e.text.slice(n,r.i),n=r.i+1;return t+e.text.slice(n)}var Xr=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n].len;return t};function ws(e,t,n,r){let o=Xr(t),s=Xr(n),i=[],l=0,a=0;for(let p of r.hunks){a+=p.bs-l;let u=a+p.toks.length;i.push({bs:o[p.bs],be:o[p.be],ss:s[a],se:s[u],text:e.text.slice(s[a],s[u]),toks:p.toks,lead:!!p.lead}),a=u,l=p.be}let c=new Map;for(let p of r.cosmetic)c.set(p.bi,p.tok.raw);return{hunks:i,respell:c}}function za(e,t,n){let r=i=>i===Nt||/\s/.test(i),o=i=>i.replace(/[\u001E\s]/g,""),s=[];for(let i of e){let l=t.slice(i.bs,i.be),a=n.slice(i.ss,i.se);if(!l.includes(Nt)&&!a.includes(Nt)||l.includes(Vn)||a.includes(Vn)||o(l)!==o(a)){s.push(i);continue}let c=0,p=0;for(;;){let u=c,f=p;for(;u<l.length&&r(l[u]);)u++;for(;f<a.length&&r(a[f]);)f++;let h=c,d=p;for(;h<u&&d<f&&l[h]===a[d];)h++,d++;let v=u,g=f;for(;v>h&&g>d&&l[v-1]===a[g-1];)v--,g--;if(v>h||g>d){let m=a.slice(d,g);s.push({bs:i.bs+h,be:i.bs+v,ss:i.ss+d,se:i.ss+g,text:m,toks:[...m].map(k=>({k,raw:k,len:1})),lead:i.lead})}if(u>=l.length)break;c=u+1,p=f+1}}return s}function Va(e,t,n){let r=new Int32Array(t+1).fill(-1),o=new Int32Array(n+1).fill(-1),s=0,i=0,l=a=>{for(;s<a;)r[s]=i,o[i]=s,s++,i++};for(let a of e)l(a.bs),s=a.be,i=a.se;return l(t),r[t]=i,o[i]=t,{bTo:r,toB:o}}function Wa(e,t,n){let r=[],o=0,s=0,i=(l,a)=>{if(o===l&&s===a)return;let c=t.text.slice(s,a);r.push({bs:o,be:l,ss:s,se:a,text:c,toks:fn(c,xn(c)),lead:!1})};for(let l of n.runs)i(l.from,l.target),o=l.to,s=l.target+l.to-l.from;return i(e.text.length,t.text.length),{hunks:r,respell:new Map}}function Ka(e,t,n,r){let o=Xr(t),s=Xr(n),i=(a,c)=>{let p=0,u=a.length;for(;p<u;){let f=p+u>>>1;a[f]<c?p=f+1:u=f}return a[p]===c?p:-1};for(let a of e.hunks)if(i(o,a.bs)<0||i(o,a.be)<0)return null;if(e.hunks.some(a=>i(s,a.ss)<0||i(s,a.se)<0)){if(!r)return null;let a=[];for(let f of e.hunks)a.push(f.ss,f.se);let c=[],p=0,u=0;for(let f of n){let h=u+f.len;for(;p<a.length&&a[p]<=u;)p++;let d=u;for(;p<a.length&&a[p]<h;){let v=a[p++];if(v>d){let g=f.raw.slice(d-u,v-u);c.push(...fn(g,xn(g))),d=v}}if(d===u)c.push(f);else{let v=f.raw.slice(d-u);c.push(...fn(v,xn(v)))}u=h}n=c,s=Xr(n)}let l=[];for(let a of e.hunks){let c=i(o,a.bs),p=i(o,a.be),u=i(s,a.ss),f=i(s,a.se);if(c<0||p<0||u<0||f<0)return null;l.push({bs:c,be:p,toks:n.slice(u,f),gap:[],group:l.length})}return{parts:l,cosmeticEq:[],tokens:n}}function Zi(e,t,n,r={},o=null){return Za(e,t,n,r.base,r.local,r.remote,o,{})}function Za(e,t,n,r,o,s,i,l){let a=xn(As(e),As(t),As(n)),c=Gr(e,a,!1,r),p=Gr(t,a,!1,o),u=Gr(n,a,!1,s),f=c.length>2e4||p.length>2e4||u.length>2e4;f&&(c=Gr(e,a,!0,r),p=Gr(t,a,!0,o),u=Gr(n,a,!0,s));let h=i?.local?Wa(e,t,i.local):null,d=i?.remote?Wa(e,n,i.remote):null,v=h?Ka(h,c,p,!f):Jn(c,p),g=d?Ka(d,c,u,!f):Jn(c,u);h&&v&&(p=v.tokens),d&&g&&(u=g.tokens);let m,k;if(v&&g){let S=Wi(v,g,c);m=ws(t,c,p,{hunks:S.lh,cosmetic:S.cosL}),k=ws(n,c,u,{hunks:S.rh,cosmetic:S.cosR})}else m=h||ws(t,c,p,v),k=d||ws(n,c,u,g);return m.hunks=za(m.hunks,e.text,t.text),k.hunks=za(k.hunks,e.text,n.text),l.base=e,l.local=t,l.remote=n,l.lines=f,l.baseTokens=c,l.localEdits=m,l.remoteEdits=k,l.localMap=Va(m.hunks,e.text.length,t.text.length),l.remoteMap=Va(k.hunks,e.text.length,n.text.length),l.full=null,l}function Ga(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Jr=/\s/;function Ss(e,t,n){for(let r=t;r<n;r++)if(!Jr.test(e[r]))return!1;return!0}function Ih(e,t,n){let r=e.cache[n]||(e.cache[n]=new Map);if(r.has(t))return r.get(t);let o=n===0?"local":"remote",s=n===0?"remote":"local",i=t.baseMark,l=t[s+"Mark"],a=!t.block&&!t[o]&&!!l&&i.to>i.from;if(a){let c=n===0?e.ML:e.MR,p=n===0?e.MR:e.ML,u=n===0?e.fr:e.fl,f=!1;for(let h=i.from;h<i.to;h++){if(c.bTo[h]>=0){a=!1;break}p.bTo[h]<0&&!Jr.test(e.fb.text[h])&&(f=!0)}if(a&&!f){for(let h=l.from;h<l.to;h++)if(p.toB[h]<0&&!Jr.test(u.text[h])){f=!0;break}}a&&=f}return r.set(t,a),a}function Ya(e,t,n,r,o,s,i,l,a){let c=l===0?e.fl:e.fr,p=null;for(let u=n;u<r;u++){let f=t[u];if(!Ss(c.text,f.ss,f.se))return null;if(Ss(e.fb.text,f.bs,f.be)){if(f.bs<f.be&&f.ss<f.se||Jr.test(e.fb.text[f.bs-1]||"")||Jr.test(e.fb.text[f.be]||""))continue;return null}let h=!1;for(let d=f.bs;d<f.be;d++){if(Jr.test(e.fb.text[d]))continue;let v=null;for(let g of e.fb.stackAt[d]){let m=e.byEl.get(g.el);if(m&&Ih(e,m,l)){v=m;break}}if(!v)return null;(p||(p=new Set)).add(v),h=!0}if(!h)return null}if(!p){if((l===0?"local":"remote")!==a)return null;let u=l===0?e.fr:e.fl,f=!1;for(let h=s;h<i;h++){let d=o[h];if(!Ss(e.fb.text,d.bs,d.be))return null;Ss(u.text,d.ss,d.se)||(f=!0)}if(!f)return null}return p||0}function Ts(e){let{out:t,policy:n="remote",L:r,R:o}=e,s=e.provenance||new WeakMap,i=e.textMappers||new WeakMap,l=e.conflicts||[],a=e.decisions||[],c=l.length,p=e.conflict||(b=>l.push(b)),u={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},f=[],h=!!(r&&r.reverse&&r.map&&o&&o.reverse&&o.map),d={base:null,local:null,remote:null};if(!e.prepared&&h&&e.moveIn){let b=ye=>Ie=>ye.some(pe=>pe===Ie||pe.nodeType===1&&pe.contains(Ie)),_=b(e.local),L=b(e.remote),j=b(e.base),G=new Set,oe=ye=>{if(!wn.has(ye.tagName))return;let Ie=r.map.get(ye),pe=o.map.get(ye);(Ie&&!_(Ie)||pe&&!L(pe))&&G.add(ye);for(let Le of ye.children)oe(Le)};for(let ye of e.base)ye.nodeType===1&&oe(ye);let be=ye=>Ie=>{if(!wn.has(Ie.tagName))return!1;let pe=ye.reverse.get(Ie);return!!pe&&(G.has(pe)||!j(pe))};G.size&&(d.base=ye=>G.has(ye)),d.local=be(r),d.remote=be(o)}let v={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&h&&e.moveIn){let b=j=>G=>j.some(oe=>oe===G||oe.nodeType===1&&oe.contains(G)),_=b(e.local),L=b(e.remote);for(let j of Qt(e.base,{...e,atomize:d.base}).atoms){let G=r.map.get(j.el),oe=o.map.get(j.el),be=!!G&&!_(G),ye=!!oe&&!L(oe);!be&&!ye||(be&&e.movePlanned?.(j.el,"local",G,null),ye&&e.movePlanned?.(j.el,"remote",oe,null),v.base.add(j.el),G&&!be&&v.local.add(G),oe&&!ye&&v.remote.add(oe),_(j.el)&&v.local.add(j.el),L(j.el)&&v.remote.add(j.el))}}let g=e.prepared?.base||Qt(e.base,{...e,atomize:d.base,skip:v.base}),m=e.prepared?.local||Qt(e.local,{...e,atomize:d.local,skip:v.local}),k=e.prepared?.remote||Qt(e.remote,{...e,atomize:d.remote,skip:v.remote}),S=new Map(g.atoms.map(b=>[b.el,b])),x={},w=b=>e.prepared?e.prepared.full?.(b)||null:v[b].size?(x[b]||(x[b]=Qt(e[b],{...e,atomize:d[b]})),x[b]):null,T=(b,_,L)=>{_.namespaceURI?b.setAttributeNS(_.namespaceURI,_.name,L):b.setAttribute(_.name,L)},N=(b,_,L,j)=>{if(!_&&(!L||!j)){for(let oe of(L||j).attributes)T(b,oe,oe.value);return}let G=new Map;for(let oe of[_,L,j])if(oe)for(let be of oe.attributes)G.set(be.name,be);for(let[oe,be]of G){let ye=_?_.getAttribute(oe):null,Ie=L?L.getAttribute(oe):ye,pe=j?j.getAttribute(oe):ye,Le;Ie===pe?Le=Ie:Ie===ye?(Le=pe,a.push({kind:"attr",el:b,name:oe,source:"remote"})):pe===ye?(Le=Ie,a.push({kind:"attr",el:b,name:oe,source:"local"})):(Le=n==="local"?Ie:pe,p({kind:"attr",el:b,name:oe,base:ye,local:Ie,remote:pe,resolved:Le},{el:b,sample:be}),a.push({kind:"attr",el:b,name:oe,source:"both"})),Le!=null&&T(b,be,Le)}},C=(b,_,L,j)=>b&&e.mergeAttrs?e.mergeAttrs(b,_,L,j):N(j,b,_,L),I=e.mergeElement||((b,_,L)=>{let j=t.createElement(b.tagName);C(b,_,L,j);let G=_||b,oe=L||b,be=n==="local"?G.isEqualNode(b)?oe:G:oe.isEqualNode(b)?G:oe;for(let ye of be.childNodes)j.appendChild(t.importNode(ye,!0));return s.set(j,{base:b,local:_,remote:L}),j}),q=e.cloneUnit||((b,_)=>{let L=t.importNode(b,!0);return s.set(L,{base:null,local:_==="local"?b:null,remote:_==="remote"?b:null}),L}),V=e.atomKey||(b=>Ja(b,()=>!1)),U=(b,_)=>{let L=new Map;for(let j of b.atoms)if(e.remoteWins&&e.remoteWins(j.el)&&wn.has(j.el.tagName))L.set(j,"w"+j.el.tagName+"#"+(j.el.id||""));else if(!h)L.set(j,j.key);else if(b===g)L.set(j,"="+V(j.el));else{let G=_.reverse.get(j.el),oe=G?S.get(G):null;oe?L.set(j,"="+V(oe.el)):G?L.set(j,"m"+V(j.el)):L.set(j,"="+V(j.el))}return j=>L.get(j)},F=U(g,null),A=U(m,r),E=U(k,o),X=e.certifiedOrigins?e.certifiedOrigins(g,m,k,F,A,E):null;if(X?.fallback)return null;if(!X&&!e.prepared&&e.blocks){let b=Gt(),_=Gi({base:g,side:m,baseOf:j=>r?.reverse?.get(j)||null,budget:b}),L=Gi({base:g,side:k,baseOf:j=>o?.reverse?.get(j)||null,budget:b});(_.status==="ready"||L.status==="ready")&&(X={local:_.status==="ready"?_:null,remote:L.status==="ready"?L:null})}let B=e.prepared||Za(g,m,k,F,A,E,X,u),z=B.lines,Ce=B.baseTokens,Me=B.localEdits,Be=B.remoteEdits,me=B.localMap,Te=B.remoteMap,Xe=g.text.length,_e=b=>new Map(b.atoms.map(_=>[_.el,_])),O=_e(m),K=_e(k),fe=(b,_,L)=>{let j=new Set;if(!h)return j;for(let G of b.atoms){let oe=S.get(_.reverse.get(G.el));oe&&L.bTo[oe.i]<0&&j.add(oe)}return j},ae=fe(m,r,me),qe=fe(k,o,Te),ze=b=>!Wn(b,{...e,remoteWins:null}),Ee=new Set;if(h)for(let b of g.atoms){if(!ze(b.el))continue;let _=r.map.get(b.el)||null,L=o.map.get(b.el)||null,j=_&&!L?_:L&&!_?L:null;j&&(O.has(j)||K.has(j))&&!j.isEqualNode(b.el)&&Ee.add(b)}let ot=1,rt=(b,_)=>({id:ot++,tag:b,base:null,local:null,remote:null,rank:_}),xt=new Map,nt=[];for(let b of g.marks){let _=rt(b.tag,b.depth);_.block=!!b.block,_.base=b.el,_.baseMark=b,xt.set(b.el,_),nt.push(_)}let te=(b,_)=>{let L=-1,j=-1;for(let G=b.from;G<b.to;G++){let oe=_[G];oe>=0&&(L<0&&(L=oe),j=oe+1)}return L<0?null:[L,j]},Ae=(b,_,L,j)=>{for(let G of b.marks){let oe=L?L.reverse.get(G.el):null;oe&&L.identical.has(oe)&&L.pairIdenticalChildren&&L.pairIdenticalChildren(oe);let be=oe?xt.get(oe):null;if(be&&be[_]&&(be=null),!be){let ye=te(G,j),Ie=0;if(ye)for(let pe of nt){if(pe.tag!==G.tag||pe[_]||!!pe.block!=!!G.block)continue;let Le=Math.min(ye[1],pe.baseMark.to)-Math.max(ye[0],pe.baseMark.from);(Le>Ie||Le===Ie&&Le>0&&Math.abs(pe.rank-G.depth)<Math.abs(be.rank-G.depth))&&(be=pe,Ie=Le)}}be||(be=rt(G.tag,G.depth),be.block=!!G.block,be.new=_),be[_]=G.el,be[_+"Mark"]=G,xt.set(G.el,be)}};Ae(m,"local",r,me.toB),Ae(k,"remote",o,Te.toB);let je=b=>b.merged||b,Fe=b=>{let _=new Set;for(let L of b)L.block||_.add(xt.get(L.el));return _},He=new Map,et=b=>{let _=He.get(b);return _||(_=Fe(b),He.set(b,_)),_},bt=(b,_)=>{let L=[],j=null;for(let G=0;G<Xe;G++){let oe=_[G];if(oe<0){j&&L.push(j),j=null;continue}let be=et(g.stackAt[G]),ye=et(b.stackAt[oe]),Ie=new Set,pe=new Set;for(let Le of ye)be.has(Le)||Ie.add(Le);for(let Le of be)ye.has(Le)||pe.add(Le);if(!Ie.size&&!pe.size){j&&L.push(j),j=null;continue}if(j&&Ga(j.added,Ie)&&Ga(j.removed,pe)){j.be=G+1;continue}j&&L.push(j),j={bs:G,be:G+1,added:Ie,removed:pe}}return j&&L.push(j),L},Ft=bt(m,me.bTo),yt=bt(k,Te.bTo),Lt=b=>b.be>b.bs?[b.bs,b.be-1]:[b.bs-1,b.bs],en=(b,_)=>{if(Xe===0)return null;let[L,j]=Lt(b);for(let G of _){if(G.be<=L)continue;if(G.bs>j)break;let oe=G.bs<=L&&j<G.be;return oe&&b.text===""&&G.bs===b.bs&&G.be===b.be?"straddle":oe?G:b.be>b.bs?"straddle":null}return null},Ge=b=>b.bs===b.be,Ct=(b,_,L=null)=>{let j=!1;for(let G=b.bs;G<b.be;G++){let oe=g.text[G];if(oe===Nt)j=!0;else if(!/\s/.test(oe))return!1}for(let G=b.ss;G<b.se;G++){let oe=_.text[G];if(oe===Nt)j=!0;else if(!/\s/.test(oe)){let be=L&&e.scopeUnits&&Ge(b)&&_.atomAt.get(G);if(!be||!ze(be.el)||L.ss!==L.se||L.bs>=L.be)return!1;for(let Ie=L.bs;Ie<L.be;Ie++)if(!/\s/.test(g.text[Ie]))return!1;let ye=_===m?1:2;if(!e.scopeUnits[ye].includes(be.el)||(ye===1?r:o)?.reverse.has(be.el))return!1;j=!0}}return j},Et=(b,_)=>b.bs<_.be&&_.bs<b.be,Jt=(b,_)=>b.bs<=_.be&&_.bs<=b.be&&Ge(b)!==Ge(_),Y=(b,_)=>g.text.slice(b.bs,b.be).includes(Nt)||_.text.slice(b.ss,b.se).includes(Nt),y=b=>{if(Ge(b))return!1;let _=b.bs,L=b.be;for(;_>0&&/\s/.test(g.text[_-1]);)_--;for(;L<g.text.length&&/\s/.test(g.text[L]);)L++;return(_===0||g.text[_-1]===Nt)&&(L===g.text.length||g.text[L]===Nt)},M=(b,_)=>!Y(b,_)&&!y(b),P=(b,_)=>Et(b,_)||Jt(b,_)&&!(b.transferIn||b.transferOut||_.transferIn||_.transferOut)&&!(Ct(b,m,_)&&M(_,k))&&!(Ct(_,k,b)&&M(b,m)),H=(b,_)=>{if(b.bs!==_.bs||b.be!==_.be||b.toks.length!==_.toks.length)return!1;let L=b.ss,j=_.ss;for(let G=0;G<b.toks.length;G++){let oe=b.toks[G],be=_.toks[G];if(oe.k!==be.k||oe.atom&&!m.atomAt.get(L).el.isEqualNode(k.atomAt.get(j).el))return!1;L+=oe.len,j+=be.len}return!0},Q=(b,_,L,j)=>{for(let G of g.atoms){if(G.i<b.bs||G.i>=b.be||j.has(G)||Ee.has(G))continue;let oe=_.bTo[G.i],be=oe>=0?L.atomAt.get(oe):null;if(be&&!be.el.isEqualNode(G.el))return!0}return!1},D=[],ge=null,xe=null,de=Me.hunks,Oe=Be.hunks,$=0,Z=0,ke=0,we=0,ve=0,ne=b=>{b>ke&&(D.push({src:"base",from:ke,to:b,dL:we,dR:ve}),ke=b)};for(;$<de.length||Z<Oe.length;){let b=de[$],_=Oe[Z],L=!!b&&(!_||b.bs<_.bs||b.bs===_.bs&&b.be<=_.be&&!_.lead);if(b&&_&&b.bs===_.bs&&Ge(b)&&Ge(_)){let zt=Ct(b,m),Io=Ct(_,k);zt!==Io&&(L=Io)}let j=L?b:_,G=L?_:b,oe=!!G&&H(b,_),be=!!G&&(L?!!de[$+1]&&H(de[$+1],_):!!Oe[Z+1]&&H(b,Oe[Z+1])),ye=!!G&&!oe&&!be&&(Xe===0||P(b,_)),Ie=ye,pe=en(j,L?yt:Ft);if(pe==="straddle"&&(Ie=!0),!Ie&&j.be>j.bs&&(Ie=Q(j,L?Te:me,L?k:m,L?ae:qe)),!Ie&&oe){ne(j.bs),D.push({src:"both",lfrom:b.ss,rfrom:_.ss,len:j.text.length,owner:b.owner||_.owner||null,transfer:b.transferIn||_.transferIn||null}),ke=j.be,we+=j.text.length-(j.be-j.bs),ve+=j.text.length-(j.be-j.bs),$++,Z++;continue}if(!Ie){ne(j.bs),D.push({src:L?"local":"remote",from:j.ss,to:j.se,inherit:pe&&pe!=="straddle"?pe:null,owner:j.owner||null,transfer:j.transferIn||null}),ke=j.be,L?(we+=j.text.length-(j.be-j.bs),$++):(ve+=j.text.length-(j.be-j.bs),Z++);continue}let Le=j.bs,st=j.be,ct=$,gt=Z,$t=zt=>zt.bs<st&&zt.be>Le||Ge(zt)&&(zt.bs===Le||zt.bs===st);L?ct++:gt++,ye&&(Le=Math.min(Le,G.bs),st=Math.max(st,G.be),L?gt++:ct++);let Dt=!0;for(;Dt;){for(Dt=!1;ct<de.length&&$t(de[ct]);)Le=Math.min(Le,de[ct].bs),st=Math.max(st,de[ct].be),ct++,Dt=!0;for(;gt<Oe.length&&$t(Oe[gt]);)Le=Math.min(Le,Oe[gt].bs),st=Math.max(st,Oe[gt].be),gt++,Dt=!0}let pn=Le+we,cn=Le+ve,yn=st-Le,Tn=st-Le;for(let zt=$;zt<ct;zt++)yn+=de[zt].text.length-(de[zt].be-de[zt].bs);for(let zt=Z;zt<gt;zt++)Tn+=Oe[zt].text.length-(Oe[zt].be-Oe[zt].bs);let Un=pn+yn,Hn=cn+Tn;if(ne(Le),$<ct&&Z<gt&&!X&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!m.atoms.length&&!k.atoms.length&&!g.pins.length&&!m.pins.length&&!k.pins.length){ge||={fb:g,fl:m,fr:k,ML:me,MR:Te,byEl:xt,cache:[null,null]};let zt=Ya(ge,de,$,ct,Oe,Z,gt,0,n),Io=Ya(ge,Oe,Z,gt,de,$,ct,1,n);if(zt===null!=(Io===null)){let Ni=zt!==null,Na=Ni?zt:Io;if(Na){xe||=new Map;for(let Zd of Na)xe.set(Zd,Ni?"local":"remote")}D.push(Ni?{src:"remote",from:cn,to:Hn}:{src:"local",from:pn,to:Un}),ke=st,we+=yn-(st-Le),ve+=Tn-(st-Le),$=ct,Z=gt;continue}}let Yt={kind:"text",node:e.node||null,base:Yr(g,Le,st),local:Yr(m,pn,Un),remote:Yr(k,cn,Hn),resolved:null,range:null,bs:Le,be:st,lss:pn,lse:Un,rss:cn,rse:Hn},Ar=e.sourceRetentions?Ua(e.sourceRetentions,e.scope?.base,g,m,k,n,Yt):n;Yt.resolved=Ar==="local"?Yt.local:Ar==="remote"?Yt.remote:Yt.local+Yt.remote,Ar!=="remote"&&D.push({src:"local",from:pn,to:Un,conflict:Yt}),Ar!=="local"&&D.push({src:"remote",from:cn,to:Hn,conflict:Yt});let Tr={site:"inline",policy:Ar,fb:g,fl:m,fr:k,scope:e.scope||null,synthetic:!!e.synthetic,full:w,merged:u};f.push(Tr),p(Yt,Tr),ke=st,we+=yn-(st-Le),ve+=Tn-(st-Le),$=ct,Z=gt}ne(Xe);let se=g.text,W=[];if(Me.respell.size||Be.respell.size){let b=Xr(Ce),_=[];for(let L=0;L<Ce.length;L++){let j=Ce[L].raw,G=Me.respell.get(L)??j,oe=Be.respell.get(L)??j;(G!==j||oe!==j)&&W.push([b[L],G!==j&&oe!==j?"both":G!==j?"local":"remote"]),_.push(G===oe?G:G===j?oe:oe===j||n==="local"?G:oe)}se=_.join("")}let ce="",Ne=[],Pe=[],De=[],Se=[];for(let b of D){let _=ce.length;if(b.src==="base"){for(let L=b.from;L<b.to;L++)Ne.push(L),Pe.push(e.nativeTransfers?me.bTo[L]:L+b.dL),De.push(e.nativeTransfers?Te.bTo[L]:L+b.dR),Se.push(b);ce+=se.slice(b.from,b.to)}else if(b.src==="both"){for(let L=0;L<b.len;L++){let j=b.transfer&&(b.transfer.side==="remote"?b.rfrom+L:b.lfrom+L);Ne.push(b.transfer&&j>=b.transfer.ss&&j<b.transfer.se?b.transfer.bs+j-b.transfer.ss:-1),Pe.push(b.lfrom+L),De.push(b.rfrom+L),Se.push(b)}ce+=m.text.slice(b.lfrom,b.lfrom+b.len)}else{let L=b.src==="local"?m:k,j=b.transfer&&e.nativeTransfers.byOrigin[b.src==="local"?"remote":"local"].get(b.transfer.key);for(let G=b.from;G<b.to;G++){let oe=b.transfer&&G>=b.transfer.ss&&G<b.transfer.se?b.transfer.bs+G-b.transfer.ss:-1,be=oe>=0&&(!j||j.destination===b.owner)?(b.src==="local"?Te:me).bTo[oe]:-1;Ne.push(oe),Pe.push(b.src==="local"?G:be),De.push(b.src==="remote"?G:be),Se.push(b)}ce+=L.text.slice(b.from,b.to)}b.ms=_,b.me=ce.length,b.conflict&&(b.conflict.range||(b.conflict.range=[_,_]),b.conflict.range[1]=ce.length)}let tt=ce.length,lt=new Int32Array(Xe+1).fill(-1),it=new Int32Array(m.text.length+1).fill(-1),Ht=new Int32Array(k.text.length+1).fill(-1);for(let b=0;b<tt;b++)Ne[b]>=0&&(lt[Ne[b]]=b),Pe[b]>=0&&(it[Pe[b]]=b),De[b]>=0&&(Ht[De[b]]=b);let It=(b,_)=>{let L=-1,j=-1;for(let G=b.from;G<b.to;G++){let oe=_[G];oe>=0&&(L<0&&(L=oe),j=oe+1)}return L<0?null:[L,j]},Zt=[],Bt=[];for(let b of new Set(xt.values()))b.new==="local"?Zt.push(b):b.new==="remote"&&Bt.push(b);let Wt=(b,_)=>{b.remote=_.remote,b.remoteMark=_.remoteMark,b.new="both",_.merged=b,xt.set(_.remote,b)};if(Zt.length&&Bt.length){let b=e.idOf;for(let _ of Zt){let L=b?b.local(_.local):null;if(!L)continue;let j=Bt.find(G=>!G.merged&&G.tag===_.tag&&!!G.block==!!_.block&&b.remote(G.remote)===L);j&&Wt(_,j)}for(let _ of Zt){if(_.remote)continue;let L=It(_.localMark,it);if(L)for(let j of Bt){if(j.merged||j.tag!==_.tag||!!j.block!=!!_.block)continue;let G=It(j.remoteMark,Ht);if(G&&Math.min(L[1],G[1])-Math.max(L[0],G[0])>0){Wt(_,j);break}}}}He.clear();let R=b=>{for(let _ of b)if(_.block)return je(xt.get(_.el));return null},J=g.marks.some(b=>b.block)||m.marks.some(b=>b.block)||k.marks.some(b=>b.block),ue=new Array(tt).fill(null),he=new Set;if(e.nativeTransfers)for(let b=0;b<tt;b++){let _=Se[b].owner;ue[b]=_?je(xt.get(_)):Ne[b]>=0?R(g.stackAt[Ne[b]]):null}else if(J){let b=(pe,Le,st)=>{let ct=new Set([pe,Le,st]);ct.delete(null);let gt=[];for(let Dt of ct){let pn=Dt===pe,cn=Dt===Le,yn=Dt===st;(cn===yn?cn:cn===pn?yn:cn)&&gt.push(Dt)}if(gt.length<=1)return gt[0]||null;let $t=n==="local"?Le:st;return gt.includes($t)?$t:gt[0]},_=(pe,Le)=>Le>=0?R(pe.stackAt[Le]):null,L=new Map;for(let pe=0;pe<tt;pe++){if(ce[pe]!==Nt)continue;let Le=Ne[pe]>=0?_(g,Ne[pe]):null,st=_(m,Pe[pe]),ct=_(k,De[pe]);L.set(pe,[Le,Ne[pe]>=0?b(Le,st,ct):st||ct])}let j=new Set([...L.values()].map(pe=>pe[1])),G=pe=>pe!==Nt&&pe!==Vn&&!/\s/.test(pe),oe=(pe,Le)=>{let st=pe;for(;st<Le&&!G(ce[st]);)st++;return st<Le&&Ne[st]>=0?_(g,Ne[st]):null},be=new Map,ye=0;for(let pe=0;pe<tt;pe++){if(ce[pe]!==Nt)continue;let[Le,st]=L.get(pe),ct=oe(ye,pe),gt=st,$t=be.get(gt)===gt&&ct===gt;gt&&be.has(gt)&&!$t&&Le&&!be.has(Le)&&!j.has(Le)&&(gt=Le),gt&&!be.has(gt)&&be.set(gt,ct);for(let Dt=ye;Dt<=pe;Dt++)ue[Dt]=gt;ye=pe+1}let Ie=pe=>{for(let Le=0;Le<pe.text.length;Le++)if(G(pe.text[Le])&&!_(pe,Le))return!0;return!1};if(!Ie(g)&&!Ie(m)&&!Ie(k)){let pe=[],Le=0;for(let ct=0;ct<tt;ct++)(ce[ct]===Nt||ct===tt-1)&&(pe.push([Le,ct]),Le=ct+1);let st=new Set(ue);for(let ct=0;ct<pe.length;ct++){let[gt,$t]=pe[ct];if(ue[$t])continue;let Dt=gt;for(;Dt<=$t&&!G(ce[Dt]);)Dt++;if(Dt>$t)continue;let pn=_(g,Ne[Dt]),cn=_(m,Pe[Dt]),yn=_(k,De[Dt]),Tn=b(pn,cn,yn)||cn||yn||pn;if(Tn&&!st.has(Tn)){st.add(Tn);for(let Yt=gt;Yt<=$t;Yt++)ue[Yt]=Tn;continue}let Un=ct>0&&ue[pe[ct-1][1]],Hn=ct+1<pe.length&&ue[pe[ct+1][1]];if(Un)he.add(pe[ct-1][1]);else if(Hn&&ce[$t]===Nt)he.add($t);else continue;for(let Yt=gt;Yt<=$t;Yt++)ue[Yt]=Un||Hn}}}let le=new Map,ee=b=>{let _=le.get(b);if(_)return _;_=[1/0,-1/0];for(let[L,j]of[[b.baseMark,lt],[b.localMark,it],[b.remoteMark,Ht]]){let G=L&&It(L,j);G&&(_[0]=Math.min(_[0],G[0]),_[1]=Math.max(_[1],G[1]))}return le.set(b,_),_},ie=(b,_,L)=>{let j=-1,G=-1;for(let oe=0;oe<b.length;oe++){let be=xt.get(b[oe].el);be===_&&(j=oe),be===L&&(G=oe)}return j>=0&&G>=0?j-G:0},Re=(b,_)=>[...b].sort((L,j)=>{for(let be of _){let ye=ie(be,L,j);if(ye)return ye}let G=ee(L),oe=ee(j);return G[0]-oe[0]||oe[1]-G[1]||L.rank-j.rank||L.id-j.id}),We=new Map,Je=new Map,at=e.nativeTransfers?[]:null,dt=b=>{if(at)return at;let _=Ne[b],L=Pe[b],j=De[b],G=Se[b];if(_>=0){let ct=g.stackAt[_],gt=m.stackAt[L],$t=k.stackAt[j],Dt=We.get(ct);Dt||We.set(ct,Dt=new Map);let pn=Dt.get(gt);pn||Dt.set(gt,pn=new Map);let cn=pn.get($t);if(cn)return cn;let yn=et(ct),Tn=et(gt),Un=et($t),Hn=new Set;for(let Yt of new Set([...yn,...Tn,...Un])){let Ar=yn.has(Yt),Tr=Tn.has(Yt),zt=Un.has(Yt);(Tr===zt?Tr:Tr===Ar?zt:Tr)&&Hn.add(Yt)}return cn=Re(Hn,[gt,$t,ct]),pn.set($t,cn),cn}if(G.src==="both"){let ct=m.stackAt[L],gt=k.stackAt[j];return Re(new Set([...et(ct),...et(gt)]),[ct,gt])}let be=(G.src==="local"?m:k).stackAt[G.src==="local"?L:j];if(!G.inherit)return Re(et(be),[be]);let ye=Je.get(G);ye||Je.set(G,ye=new Map);let Ie=ye.get(be);if(Ie)return Ie;let pe=new Set(et(be));for(let ct of G.inherit.added)pe.add(je(ct));for(let ct of G.inherit.removed)pe.delete(je(ct));let Le=G.src==="local"?k:m,st=(G.src==="local"?Te.bTo:me.bTo)[G.inherit.bs];return Ie=Re(pe,[be,Le.stackAt[st]]),ye.set(be,Ie),Ie},ht=new Int32Array(m.text.length+1);ht[m.text.length]=tt;for(let b=m.text.length-1;b>=0;b--)ht[b]=it[b]>=0?it[b]:ht[b+1];Ch.caret+=m.text.length;let ft=b=>b<=0?0:(b>m.text.length&&(b=m.text.length),it[b-1]>=0?it[b-1]+1:ht[b]),Mt=[],_t=[],Pt=null,Ye=[],St="",Rt=-1,Ut=b=>{Pt?Pt.appendChild(b):Mt.push(b)},jt=b=>{if(!St)return;let _=t.createTextNode(St);Ut(_),_t.push({node:_,ms:Rt,me:b,local:[],u:Ye.length?Ye[Ye.length-1].u:null}),St=""},Mn=new Set,an=new Map,sr=new Set,kn=b=>{let _=t.createElement(b.tag);if(b.block&&$e.add(_),!an.has(b)){an.set(b,_),C(b.base,b.local,b.remote,_),s.set(_,{base:b.base,local:b.local,remote:b.remote});let j=(be,ye)=>h&&b[ye]&&be.reverse.get(b[ye])?ye:null,G=!b.base&&(j(r,"local")||j(o,"remote"));if(G){let be=G==="local"?r.reverse.get(b.local):o.reverse.get(b.remote),ye=s.get(_);ye.local=ye.local||r.map.get(be)||null,ye.remote=ye.remote||o.map.get(be)||null,a.push({kind:"move",el:_,source:G}),e.moveBuilt?.(be,G,b[G],_)}else b.base||a.push({kind:"insert",el:_,source:b.local&&b.remote?"both":b.local?"local":"remote"});let oe=s.get(_);oe.local&&(sr.has(oe.local)?oe.local=null:sr.add(oe.local))}else{let j=an.get(b);for(let G of j.attributes)G.name!=="id"&&G.name!=="data-id"&&T(_,G,G.value);s.set(_,{base:null,local:null,remote:null})}Ut(_),Ye.push({u:b,el:_}),Pt=_},xr=new Set,Rn=new Map;for(let b of m.pins){let _=ft(b.i);Rn.has(_)||Rn.set(_,[]),Rn.get(_).push(b)}let $r=b=>{let _=Rn.get(b);if(_){jt(b);for(let L of _){let j=L.el.namespaceURI&&L.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(L.el.namespaceURI,L.el.tagName):t.createElement(L.el.tagName);s.set(j,{base:null,local:L.el,remote:null,pinned:!0}),xr.add(j),Ut(j)}}},Co=g.atoms.length||m.atoms.length||k.atoms.length,tn=b=>{if(!Co)return null;let _=Ne[b]>=0?g.atomAt.get(Ne[b]):null,L=Pe[b]>=0?m.atomAt.get(Pe[b]):null,j=De[b]>=0?k.atomAt.get(De[b]):null;return _||L||j?{ab:_,al:L,ar:j}:null},Yn=(b,_,L)=>{let j=e.idOf;if(!j||!j.base)return!1;let G=j.base(b.el);return G!=null&&G===j[L](_.el)},_o=(b,_,L,j,G)=>{if(!b||!h)return null;let oe=S.get(_.reverse.get(b.el))||null;return!oe||oe===j||(j?oe.el.isEqualNode(j.el)&&!Yn(oe,b,G):L.bTo[oe.i]>=0)?null:oe},Ur=(b,_)=>{if(!b||!h||!e.moveIn)return null;let L=_.reverse.get(b.el);return L&&!S.has(L)?L:null},wr=(b,_)=>{let L=new Map;for(let j of b.atoms)L.set(_(j),(L.get(_(j))||0)+1);return L},Fn=wr(g,F),ms=wr(m,A),ps=wr(k,E),gs=b=>{let _=F(b);return Fn.get(_)===1&&(ms.get(_)||0)<=1&&(ps.get(_)||0)<=1},Xn=new Map,ir=new Set,Sr=new Set,Mo=new Set,Hr=null;for(let b=0;b<tt;b++){let _=tn(b);if(!_)continue;let{ab:L,al:j,ar:G}=_,oe=_o(G,o,Te,L,"remote"),be=_o(j,r,me,L,"local"),ye=L,Ie=null;if(oe?(ye=oe,Ie="remote"):be&&(ye=be,Ie="local"),ye){L&&ye!==L&&(Hr||=new Map).set(L,Ie),ir.has(ye)?Xn.set(b,{dup:ye.el}):(ir.add(ye),Xn.set(b,{bk:ye,from:Ie,al:j,ar:G}));continue}let pe=Ur(G,o),Le=Ur(j,r),st=pe||Le;if(st){Sr.has(st)?Xn.set(b,{dup:st}):(Sr.add(st),Xn.set(b,{moveIn:st,side:pe?"remote":"local",sideEl:pe?G.el:j.el}));continue}let ct=($t,Dt)=>$t&&h&&S.get(Dt.reverse.get($t.el))||null,gt=ct(G,o)||ct(j,r);if(gt&&(Mo.add(gt),Se[b].conflict&&(gs(gt)||G&&(G.el===gt.el||o.identityPaired?.has(gt.el))&&Yn(gt,G,"remote")||j&&(j.el===gt.el||r.identityPaired?.has(gt.el))&&Yn(gt,j,"local")))){if(ir.has(gt)){Xn.set(b,{dup:gt.el});continue}ir.add(gt)}Xn.set(b,{al:j,ar:G})}let Bn=new Map,Ro,Lo,bs=(b,_)=>{if(b[_]>=0)return b[_];for(let L=_-1;L>=0;L--)if(b[L]>=0)return b[L]+1;return 0};if(h)for(let b of g.atoms){if(ir.has(b)||Mo.has(b))continue;let _=r.map.get(b.el)||null,L=o.map.get(b.el)||null,j=_&&O.get(_),G=L&&K.get(L);if(_&&!j||L&&!G)continue;let oe=!(j&&G)&&Ee.has(b);if(!oe&&!(j&&G&&(gs(b)||Hr?.has(b)||(j.el===b.el||r.identityPaired?.has(b.el))&&(G.el===b.el||o.identityPaired?.has(b.el))&&Yn(b,j,"local")&&Yn(b,G,"remote"))))continue;let be=Hr?.get(b),ye=n;if(be){let ct=be==="local"?k:m,gt=be==="local"?o:r,$t=be==="local"?Lo:Ro;if($t===void 0){$t=ct.atoms.length===g.atoms.length;for(let Dt=0;$t&&Dt<g.atoms.length;Dt++)$t=gt.reverse.get(ct.atoms[Dt].el)===g.atoms[Dt].el;be==="local"?Lo=$t:Ro=$t}$t&&(ye=be)}let Ie=ye==="local"?[[j,it],[G,Ht]]:[[G,Ht],[j,it]],[pe,Le]=Ie.find(([ct])=>ct),st=bs(Le,pe.i);Bn.has(st)||Bn.set(st,[]),Bn.get(st).push({a:b,lt:_,rt:L,edited:oe}),ir.add(b)}if(h&&e.moveIn){let b=[[m,r,it,"local"],[k,o,Ht,"remote"]];n!=="local"&&b.reverse();for(let[_,L,j,G]of b)for(let oe of _.atoms){let be=Ur(oe,L);if(!be||Sr.has(be))continue;Sr.add(be);let ye=bs(j,oe.i);Bn.has(ye)||Bn.set(ye,[]),Bn.get(ye).push({move:be,side:G,sideEl:oe.el})}}let re=b=>{let _=Bn.get(b);if(_){if(jt(b),_.some(L=>ze(L.move?L.sideEl:L.a.el)))for(;Ye.length;)Ye.pop(),Pt=Ye.length?Ye[Ye.length-1].el:null;for(let{a:L,lt:j,rt:G,edited:oe,move:be,side:ye,sideEl:Ie}of _){if(be){let Le=e.moveIn(be,ye,Ie);Le&&Ut(Le);continue}Mn.add(L);let pe=I(L.el,j,G);oe&&(p({kind:"structure",el:pe,detail:"edit-beats-delete",base:L.el},{subject:L.el,deleted:j?"remote":"local"}),a.push({kind:"insert",el:pe,source:j?"local":"remote"})),Ut(pe)}}},$e=new Set,Ue=l.length>c;for(let b=0;b<tt;b++){let _=tn(b),L=e.scopeUnits&&_&&(_.ab?.stack.some(be=>be.block)||_.al?.stack.some(be=>be.block)||_.ar?.stack.some(be=>be.block)),G=!!_&&ze((_.ab||_.al||_.ar).el)&&!L?[]:ue[b]?[ue[b],...dt(b)]:dt(b),oe=0;for(;oe<Ye.length&&oe<G.length&&Ye[oe].u===G[oe];)oe++;if(oe<Ye.length)for(jt(b);Ye.length>oe;)Ye.pop(),Pt=Ye.length?Ye[Ye.length-1].el:null;if($r(b),re(b),G.length>Ye.length)for(jt(b);Ye.length<G.length;)kn(G[Ye.length]);if(ce[b]===Nt){if(he.has(b))continue;jt(b);let be=Ye.length;for(;be>0&&!Ye[be-1].u.block;)be--;if(be>0)for(Ue&&u.breakOut.set(b,Ye[be-1].el);Ye.length>=be;)Ye.pop(),Pt=Ye.length?Ye[Ye.length-1].el:null;continue}if(_){jt(b);let be=Xn.get(b),ye;if(be.dup){p({kind:"structure",el:null,detail:"both-moved",base:be.dup},{subject:be.dup});continue}if(be.moveIn){if(ye=e.moveIn(be.moveIn,be.side,be.sideEl),!ye)continue}else if(be.bk){let Ie=be.bk;if(Mn.add(Ie),Ie===_.ab)ye=I(Ie.el,be.al.el,be.ar.el);else{let pe=r.map.get(Ie.el)||null,Le=o.map.get(Ie.el)||null;ye=I(Ie.el,pe,Le),(!pe||!Le)&&p({kind:"structure",el:null,detail:"move-beats-delete",base:Ie.el},{subject:Ie.el,deleted:pe?"remote":"local"}),a.push({kind:"move",el:ye,source:be.from})}}else be.al?(ye=q(be.al.el,"local"),be.ar&&(s.get(ye).remote=be.ar.el),a.push({kind:"insert",el:ye,source:be.ar?"both":"local"})):(ye=q(be.ar.el,"remote"),a.push({kind:"insert",el:ye,source:"remote"}));Ue&&u.atomOut.set(b,ye),Ut(ye);continue}St||(Rt=b),St+=ce[b]}if(jt(tt),(Rn.has(tt)||Bn.has(tt))&&(Ye.length=0,Pt=null,$r(tt),re(tt)),tt===0&&(m.placeholder||k.placeholder||g.placeholder)){let b=t.createElement("br");s.set(b,{base:g.placeholder,local:m.placeholder,remote:k.placeholder}),Mt.push(b)}let Ze=0,wt=b=>{for(;Ze>0&&_t[Ze-1].me>=b;)Ze--;for(;Ze<_t.length&&_t[Ze].me<b;)Ze++;let _=_t[Ze];if(!_)return _t[_t.length-1]||null;let L=_t[Ze+1];return _.me===b&&L&&L.ms===b?L:_},Ke=new Map,Ve={},mt=(b,_,L)=>{let j=wt(b)||(L?Ve:null);if(!j)return;let G=Ke.get(j)||{l:!1,r:!1};_!=="remote"&&(G.l=!0),_!=="local"&&(G.r=!0),Ke.set(j,G)},Qe=b=>{if(b.conflict)return!0;let _=b.src==="local"?m.text:b.src==="remote"?k.text:"";for(let L=b.from;L<b.to;L++)if(_[L]!==Vn&&_[L]!==Nt)return!0;return!1};for(let b of D)b.src!=="base"&&mt(b.ms,b.conflict?"both":b.src,Qe(b));for(let[b,_]of W)lt[b]>=0&&mt(lt[b],_);for(let b of _t.length?_t:[Ve]){let _=Ke.get(b);_&&a.push({kind:"text",node:b.node||null,source:_.l&&_.r?"both":_.l?"local":"remote"})}for(let b of nt){if(an.has(b))continue;let _=!b.local&&!(h&&r.map.get(b.base)),L=!b.remote&&!(h&&o.map.get(b.base));!_&&!L||a.push({kind:"remove",source:_&&L?"both":_?"local":"remote",base:b.base})}if(xe)for(let[b,_]of xe)an.has(b)&&p({kind:"structure",el:an.get(b),detail:"edit-beats-delete",base:b.base},{subject:b.base,deleted:_});let pt=(b,_,L)=>{if(_<=b)return!1;for(let j=b;j<_;j++)if(L[j]>=0)return!1;return!0};for(let b of nt)for(let _ of["local","remote"]){let L=b[_+"Mark"],j=b.baseMark;if(!L)continue;let G=_==="local"?me:Te;if(!pt(j.from,j.to,G.bTo)||!pt(L.from,L.to,G.toB))continue;let oe=(_==="local"?de:Oe).find(be=>be.ss<=L.from&&L.from<be.se);oe&&(oe.be<=j.from||oe.bs>=j.to)&&a.push({kind:"move",el:an.get(b)||null,source:_})}let kt=b=>{let _=xt.get(b.node.parentNode);return _?je(_):null};for(let b of m.nodes){let _=-1;for(let j=b.s;j<b.e;j++)if(it[j]>=0){_=it[j];break}let L;if(_>=0)L=wt(_);else{let j=ft(b.s),G=kt(b);L=_t.find(oe=>oe.u===G&&oe.me>=j)||_t.filter(oe=>oe.u===G).pop()}L&&L.local.push(b)}let Ot=new Map,At=_t[_t.length-1]||null,qt=0;for(let b of m.nodes){let _=null;for(let L=b.s;L<=b.e;L++){let j=ft(L);for(;qt>0&&_t[qt-1].me>=j;)qt--;for(;qt<_t.length&&_t[qt].me<j;)qt++;let G=be=>be&&j>=be.ms&&j<=be.me&&(j<be.me||L===b.e||be===_),oe=G(_t[qt])?_t[qt]:G(_t[qt+1])?_t[qt+1]:_t[qt]||At;if(!oe)break;if(_===oe){let be=Ot.get(oe);be[be.length-1].to=L-b.s;continue}_=oe,Ot.has(oe)||Ot.set(oe,[]),Ot.get(oe).push({node:b.node,from:L-b.s,to:L-b.s,flatStart:b.s})}}for(let b of _t){let _=b.local,L=!1;for(let be of _)for(let ye=be.s;ye<be.e&&!L;ye++)(it[ye]<b.ms||it[ye]>=b.me)&&(L=!0);s.set(b.node,{base:null,local:_.map(be=>be.node),remote:null,caret:Ot.get(b)||[],partial:L});let j=b.ms,G=b.me-b.ms,oe=be=>{let ye=0,Ie=-1;for(let pe of _){let Le=pe.e-pe.s;if(be<=ye+Le){Ie=pe.s+(be-ye);break}ye+=Le}return Ie<0&&(Ie=_.length?_[_.length-1].e:0),Math.max(0,Math.min(ft(Ie)-j,G))};oe.flat=be=>Math.max(0,Math.min(ft(be)-j,G)),i.set(b.node,oe)}function $n(){if(!m.text.includes(Nt))return[{flatLocal:m.text,localNodes:m.nodes,textNodes:_t,lToM:it,mapLocal:ft}];let b=[],_=0,L=0;for(let j=0;j<=m.text.length;j++){if(j<m.text.length&&m.text[j]!==Nt)continue;let G=_,oe=j;if(oe>G){let be=[];for(;L<m.nodes.length&&m.nodes[L].e<=G;)L++;for(let ye=L;ye<m.nodes.length&&m.nodes[ye].s<oe;ye++){let Ie=m.nodes[ye],pe=Math.max(Ie.s,G),Le=Math.min(Ie.e,oe);pe<Le&&be.push({node:Ie.node,s:pe-G,e:Le-G})}b.push({flatLocal:m.text.slice(G,oe),localNodes:be,textNodes:_t,lToM:it.subarray?it.subarray(G,oe+1):it.slice(G,oe+1),mapLocal:ye=>ft(G+Math.max(0,Math.min(ye,oe-G)))})}_=j+1}return b}let lr={...e,blocks:$e,ignored:b=>xr.has(b)||(e.ignored?e.ignored(b):!1)},zr=e.ignoreAttribute||(()=>!1),Oi=Ha(Qt(Mt,lr),zr)!==Ha(k,zr);if(f.length){let b=_=>{let L=s.get(_);return L&&L.unchanged?L.remote:null};u.text=ce,u.textNodes=_t,u.out=Qt(Mt,{...lr,via:b})}let vt=null;if(e.scopeUnits){vt=new Map;let b=new Set(Mt),_=ye=>{for(;ye&&!b.has(ye);)ye=ye.parentNode;return ye},L=e.scopeUnits.map(ye=>{let Ie=new Map;for(let pe of ye)if(pe.nodeType===1)Ie.set(pe,pe);else for(let Le of pe.nodes)Ie.set(Le,pe);return Ie}),j=(ye,Ie)=>{for(;ye&&!Ie.has(ye);)ye=ye.parentNode;return ye?Ie.get(ye):null},G=[g,m,k].map((ye,Ie)=>{let pe=new Array(ye.text.length);for(let Le of ye.nodes){let st=j(Le.node,L[Ie]);st&&pe.fill(st,Le.s,Le.e)}for(let Le of ye.atoms)pe[Le.i]=j(Le.el,L[Ie]);return pe}),oe=(ye,Ie)=>{if(!ye||!Ie)return;let pe=vt.get(ye);pe||vt.set(ye,pe=new Set),pe.add(Ie)};for(let ye of Mt){let Ie=s.get(ye);Ie&&(oe(j(Ie.base,L[0]),ye),oe(j(Ie.local,L[1]),ye),oe(j(Ie.remote,L[2]),ye))}for(let ye of _t){let Ie=_(ye.node);for(let pe=ye.ms;pe<ye.me;pe++)oe(G[0][Ne[pe]],Ie),oe(G[1][Pe[pe]],Ie),oe(G[2][De[pe]],Ie)}let be=new Map(Mt.map((ye,Ie)=>[ye,Ie]));for(let[ye,Ie]of vt)vt.set(ye,Array.from(Ie).sort((pe,Le)=>be.get(pe)-be.get(Le)))}return{unitOutputs:vt,nodes:Mt,text:ce,textNodes:_t,localDiverged:Oi,mapLocal:ft,conflicts:l.slice(c),granularity:z?"line":"word",segments:$n(),localHunks:de,remoteHunks:Oe,lToM:it}}var Qi=Symbol("lost");function ec(){return{links:new Map,removed:new Set,consumed:new Set,link(e,t){this.links.set(e,t)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let t of e.nodes)this.removed.add(t)},consume(e){for(let t of e)this.consumed.add(t)}}}var Qa=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function tc({locals:e,rec:t,root:n,provenance:r,segments:o,ignored:s}){let i=new Map,l=(x,w)=>{let T=i.get(x);T||i.set(x,T=new Set),T.add(w)},a=new Set,c=new Set;for(let x of o){let w=x.textNodes;for(let T of w)a.add(T.node);for(let T of x.localNodes){c.add(T.node);let N=0,C=null;for(let I=T.s;I<T.e;I++){let q=x.lToM[I];if(q<0)continue;for((!w[N]||q<w[N].ms)&&(N=0);N<w.length&&w[N].me<=q;)N++;let V=w[N]&&w[N].ms<=q?w[N].node:Qi;V!==C&&l(T.node,V),C=V}}}let p=new Set,u=new Map,f=new Set;(function x(w){p.add(w);let T=r.get(w);if(w.nodeType===1)T&&T.local&&T.local.nodeType===1&&(l(T.local,w),T.unchanged&&f.add(T.local)),w.tagName==="TEMPLATE"&&w.content&&u.set(w.content,w);else if(T&&Array.isArray(T.local)&&!a.has(w))for(let N of T.local)l(N,w);for(let N=Qa(w).firstChild;N;N=N.nextSibling)x(N)})(n);let h=new Set;for(let[x,w]of t.links)l(x,w),h.add(x);let d=x=>{let w=x.parentNode;return w&&w.nodeType===11?u.get(w)||null:w},v=(x,w)=>{for(let T=x;T;T=d(T))if(T===w)return!0;return!1},g=x=>t.removed.has(x)||t.consumed.has(x),m=x=>{for(let w=x.parentNode;w&&w.nodeType===1;w=w.parentNode){if(f.has(w))return"kept";if(g(w))return"decided";if(i.has(w))return null}return null},k=new Map;for(let x of e)k.set(x,S(x));return k;function S(x){let w=i.get(x);if(w&&(w.size!==1||w.has(Qi)))return{kind:"unknown",reason:"several-outputs"};let T=w?w.values().next().value:null;if(T&&(T.nodeType!==1||!p.has(T)))return{kind:"unknown",reason:"output-not-placed"};if(!T){let q=g(x)?"decided":m(x);if(q==="kept")return{kind:"untouched"};if(q!=="decided")return{kind:"unknown",reason:"unmapped"}}let N=[],C=I(x,!!T&&(f.has(x)||h.has(x)),!T||g(x));if(C)return{kind:"unknown",reason:C};return T?{kind:"single",output:T,owned:N,carried:h.has(x)}:{kind:"removed"};function I(q,V,U){for(let F=Qa(q).firstChild;F;F=F.nextSibling){if(F.nodeType===1?s(F):F.nodeType!==3&&F.nodeType!==8)continue;let A=i.get(F);if(A)for(let E of A){if(E===Qi||!p.has(E))return"output-not-placed";if(!T)return"survives-elsewhere";if(!v(E,T))return"escaped";N.push(E)}else if(!V&&!U&&!g(F)&&!c.has(F))return"unmapped";if(F.nodeType===1){let E=I(F,V||f.has(F)||h.has(F),U||g(F));if(E)return E}}return null}}}function nc(e,t){if(!t)return!1;let n=t.nodeType===1&&t.tagName==="TEMPLATE"?[t,...t.querySelectorAll("template")]:[...t.querySelectorAll("template")];for(let r of n)if(r.content.contains(e)||nc(e,r.content))return!0;return!1}function rc(e,t){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let n=[],r=new Set;for(let o of Array.from(e.elements)){if(!o||o.nodeType!==1||o.ownerDocument!==t&&!nc(o,t.documentElement))throw new TypeError("lineage.elements must be elements of the live document");r.has(o)||(r.add(o),n.push(o))}return n}var oc=new WeakMap;function sc(e){let t=new Map;for(let n of e){let r=[],o=!1;(function s(i){i.nodeType===1&&i.namespaceURI==="http://www.w3.org/1999/xhtml"&&i.localName==="template"&&(o=!0);for(let l=i.firstChild;l;l=l.nextSibling)r.push(l),l.nodeType===1&&s(l)})(n),t.set(n,{nodes:r,opaque:o})}return t}function el(e,t,n){if(e.lineage===void 0)return n(e);if(!t||t.nodeType!==1)throw new TypeError("lineage requires an element root");let r=e.lineage,o=rc(r,t.ownerDocument),s=!1,i={...e,lineage:{elements:o,onResult(l,a){if(!s)return s=!0,r.onResult(l,a)}}};try{return oc.set(i.lineage,sc(o)),n(i)}catch(l){if(!s){s=!0;try{r.onResult({version:1,root:t,status:"incomplete",entries:o.map(En)},null)}catch{}}throw l}}function tl(e,{liveRoot:t,localRoot:n,toLive:r}){let o=rc(e,t.ownerDocument),s=c=>c===t||t.contains(c),i=new Map,l=new Set(o.filter(s));if(l.size&&n===t)for(let c of l)i.set(c,c);else l.size&&(function c(p){let u=r(p);l.delete(u)&&i.set(u,p);for(let f=p.firstElementChild;f&&l.size;f=f.nextElementSibling)c(f)})(n);return{spec:e,watched:o,root:t,locals:Array.from(new Set(i.values())),before:oc.get(e)||sc(o),delivered:!1,result:null,finish(c,p){return this.resolve=p,this.plans=c,this.result={version:1,root:this.root,status:"complete",entries:o.map(u=>Ph(u,i.get(u),c,p,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(c,p){this.root=p;let u=this.resolve,f=d=>{let v=u(d);return v===c?p:v};return this.finish(this.plans,f)},deliver(c){this.delivered||(this.delivered=!0,e.onResult(this.result,c))}}}var En=e=>({from:e,to:[],kind:"unknown",complete:!1});function Ph(e,t,n,r,o){let s=o.root,i=f=>!!f&&(f===s||s.contains(f)),l=t&&n?n.get(t):null;if(!l||l.kind==="unknown")return En(e);let a=o.before.get(e);if(!a||a.opaque)return En(e);let c=a.nodes,p=f=>i(f)||!!(f&&f.ownerDocument===s.ownerDocument&&s.ownerDocument.documentElement?.contains(f));if(l.kind==="untouched"){if(!i(e))return En(e);for(let f of c)if(p(f)&&!e.contains(f))return En(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(l.kind==="removed")return p(e)||c.some(p)?En(e):{from:e,to:[],kind:"removed",complete:!0};let u=r(l.output);if(!u||u.nodeType!==1||!i(u)||u!==e&&p(e))return En(e);for(let f of c)if(p(f)&&!u.contains(f))return En(e);for(let f of l.owned){let h=r(f),d=Array.isArray(h)?h:[h];for(let v of d)if(!v||!i(v)||!u.contains(v))return En(e)}return l.carried&&!ic(u,l.output,r)?En(e):{from:e,to:[u],kind:u===e?"retained":"replaced",complete:!0}}function ic(e,t,n){for(let r=t.firstChild;r;r=r.nextSibling){let o=n(r),s=Array.isArray(o)?o:[o];for(let i of s)if(!i||!e.contains(i))return!1;if(r.nodeType===1&&!ic(e,r,n))return!1}return!0}function Fo(e,t,n){let r=tl(e,{liveRoot:t,localRoot:t,toLive:o=>o});return r.result={version:1,root:t,status:"complete",entries:r.watched.map(o=>En(o))},n.lineage=r.result,r}function lc(e,t,n,r,o){if(!o(e.length*8+1))return null;let s=0,i=t===0,l=!1;for(let a of fn(e,r)){if(!o(1))return null;if(s+=a.len,s===t&&(i=!0),s===n&&(l=!0),s>=n)break}return i&&l}function jh(e,t,n,r,o,s,i){if(!i(t.length*2))return!1;let l=new Map,a=new Map,c=new Set;for(let p of t){let u=p.bs<p.be,f=u?n[p.ownerIndex].text.base:n[p.ownerIndex].text[e],h=u?p.bs:p.ss,d=u?p.be:p.se;if(!i((d-h)*4+1))return!1;for(;h<d&&/\s/.test(f[h]);)h++;for(;d>h&&/\s/.test(f[d-1]);)d--;if(h===d)continue;let v=f.slice(h,d),g=u?l:a;u&&p.text&&c.add(v),g.has(v)?g.set(v,null):g.set(v,{h:p,from:h,to:d})}for(let p of r){if(!i(1))return!1;if(p.side!==e)continue;let u=p.deletion,f=n[u.ownerIndex].text.base;if(!i((u.be-u.bs)*3)||c.has(f.slice(u.bs,u.be).trim()))return!1}for(let[p,u]of l){if(!i(p.length+1))return!1;let f=a.get(p);if(!u||!f)continue;let h=u.h,d=f.h;if(!h.text||h.transferOut||d.transferIn||h.owner===d.owner)continue;let v=n[h.ownerIndex],g=n[d.ownerIndex];if(!i(v.text.base.length))return!1;if(!/\S/.test(v.text.base.slice(0,h.bs)+v.text.base.slice(h.be)))continue;let m=lc(v.text.base,u.from,u.to,s,i),k=lc(g.text[e],f.from,f.to,s,i);if(m===null||k===null)return!1;if(!m||!k)continue;let S=`${v.index}:${u.from}:${u.to}`,x={key:S,side:e,source:h.owner,destination:d.owner,deletion:h,insertion:d,sourceOffset:u.from-h.bs,targetOffset:f.from-d.ss,length:u.to-u.from};h.transferOut=x,d.transferIn=x,o[e].set(S,x),r.push(x)}return!0}function ac({base:e,local:t,remote:n,localTwin:r,remoteTwin:o,eligible:s,nodes:i,budget:l=Gt(2e4*32)}){let a=C=>C>l.remaining?!1:(l.remaining-=C,l.nativeSteps=(l.nativeSteps||0)+C,!0);if(e.length<2||t.length!==e.length||n.length!==e.length||!a(e.length*12))return null;for(let[C,I]of[["base",e],["local",t],["remote",n]]){let q=i[C];if(q.length!==I.length||q.some((V,U)=>V!==I[U]))return null}let c=[],p=0;for(let C=0;C<e.length;C++){let I=e[C],q=t[C],V=n[C];if(r(I)!==q||o(I)!==V)return null;let U={};for(let[F,A]of[["base",I],["local",q],["remote",V]]){if(!s(A)||A.tagName!==I.tagName||A.namespaceURI!==I.namespaceURI||!a(A.childNodes.length+1))return null;let E="";for(let X of A.childNodes){if(X.nodeType!==3||!a(X.data.length*4+1))return null;E+=X.data}if(E.includes(Nt)||(p+=E.length+1,p>2e4))return null;U[F]=E}c.push({base:I,local:q,remote:V,index:C,text:U})}let u=c.every(C=>xn(C.text.base,C.text.local,C.text.remote)),f={local:[],remote:[]};for(let C of c){C.hunks={local:[],remote:[]};for(let I of["local","remote"]){let q=C.text.base,V=C.text[I];if(q===V)continue;let U=q.length+V.length+4,F=U*8;if(!a(F))return null;let A=Math.floor(l.remaining/8),E=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(U*U+A)-U)/2)));if(E<1||!a(4*(E+1)*(U+E+1)))return null;let X=0;for(let B of Er(q,V,E)){if(!a(B.text.length+1))return null;let z=B.bs+X,Ce={...B,ss:z,se:z+B.text.length,toks:fn(B.text,u),owner:C.base,ownerIndex:C.index};C.hunks[I].push(Ce),f[I].push(Ce),X+=B.text.length-(B.be-B.bs)}}}let h=[],d={local:new Map,remote:new Map};for(let C of["local","remote"]){let I=new Map,q=new Map,V=!1,U=(F,A,E)=>{F.has(A)?F.set(A,null):F.set(A,E)};for(let F of f[C]){if(!a(1))return null;let A=c[F.ownerIndex].text.base;if(F.bs<F.be&&F.text===""){let E=A.slice(F.bs,F.be);if(!a(E.length*2))return null;/\S/.test(E)&&U(I,E,F)}else if(F.bs===F.be&&/\S/.test(F.text)){if(!a(F.text.length*2))return null;U(q,F.text,F)}else F.bs<F.be&&(V=!0)}for(let[F,A]of I){if(!a(F.length+1))return null;let E=q.get(F);if(!A||!E||A.owner===E.owner)continue;let X=c[A.ownerIndex];if(!a(X.text.base.length))return null;if(!/\S/.test(X.text.base.slice(0,A.bs)+X.text.base.slice(A.be)))continue;let B=`${X.index}:${A.bs}:${A.be}`,z={key:B,side:C,source:A.owner,destination:E.owner,deletion:A,insertion:E};A.transferOut=z,E.transferIn=z,d[C].set(B,z),h.push(z)}if(V&&q.size&&!jh(C,f[C],c,h,d,u,a))return null}if(!h.length)return null;let v=(C,I)=>C.bs<I.be&&I.bs<C.be,g=C=>C.bs===C.be,m=(C,I)=>C.bs<=I.be&&I.bs<=C.be&&g(C)!==g(I),k=(C,I)=>C.bs===I.bs&&C.be===I.be&&C.text===I.text,S=(C,I)=>!!(C.transferIn||C.transferOut&&(!C.text||I.bs===C.be&&/\s/.test(I.text[0])||I.bs===C.bs&&/\s/.test(I.text[I.text.length-1])));for(let C of h){let I=C.side==="local"?"remote":"local",q=c[C.deletion.ownerIndex];for(let V of q.hunks[I])if(!a(1)||v(C.deletion,V)&&V.transferOut?.key!==C.key)return null}for(let C of c)for(let I of C.hunks.local)for(let q of C.hunks.remote){if(!a(1))return null;if(k(I,q)){if(I.transferIn?.key!==q.transferIn?.key)return null;continue}if(v(I,q)||m(I,q)&&!S(I,q)&&!S(q,I))return null}if(!a(p*8))return null;let x=new Set([...e,...t,...n]),w={base:Qt(e,{blocks:x}),local:Qt(t,{blocks:x}),remote:Qt(n,{blocks:x})},T={};for(let C of["base","local","remote"]){let I=w[C];if(I.atoms.length||I.pins.length)return null;T[C]=new Map(I.marks.filter(q=>q.block).map(q=>[q.el,q.from]))}for(let C of c){let I=T.base.get(C.base);if(I===void 0)return null;for(let q of["local","remote"]){let V=T[q].get(C[q]);if(V===void 0)return null;for(let U of C.hunks[q])U.bs+=I,U.be+=I,U.ss+=V,U.se+=V}}for(let C of h)C.bs=C.deletion.bs+(C.sourceOffset||0),C.be=C.length===void 0?C.deletion.be:C.bs+C.length,C.ss=C.insertion.ss+(C.targetOffset||0),C.se=C.length===void 0?C.insertion.se:C.ss+C.length;let N={};for(let C of["local","remote"]){let I=0,q=0,V=[];for(let F of f[C]){if(!a(1))return null;F.bs>I&&V.push({from:I,to:F.bs,target:q}),I=F.be,q=F.se}I<w.base.text.length&&V.push({from:I,to:w.base.text.length,target:q});let U=h.filter(F=>F.side===C).map(F=>({from:F.bs,to:F.be,target:F.ss,destination:F.destination}));if(N[C]=zn({base:w.base,side:w[C],retained:V,transfers:U,budget:l}),N[C].status!=="ready")return null}return a(w.base.text.length)?{owners:c,blocks:x,transfers:h,byOrigin:d,budget:l,prepared:{base:w.base,local:w.local,remote:w.remote,lines:!1,baseTokens:fn(w.base.text,u),localEdits:{hunks:f.local,respell:new Map},remoteEdits:{hunks:f.remote,respell:new Map},localMap:N.local,remoteMap:N.remote,full:null}}:null}var nl=/\S/;function cc({certificates:e,scopes:t,views:n,eligible:r,baseId:o,limit:s=2e4*32}){let i=Gt(s),l=Symbol(),a=[],c=u=>{if(u>i.remaining)throw l;i.remaining-=u},p=(u,f=null)=>{if(c(1),!u||u.nodeType!==1||u.parentNode?.nodeType!==1||!r(u))return null;for(let v=u.parentNode;v;v=v.parentNode)if(c(1),v.nodeType===11)return null;let h="",d=0;for(let v of u.childNodes){if(c(1),v.nodeType!==3)return null;if(c(v.data.length*4+1),f){let g=f.flat.nodes[d++];if(!g||g.node!==v||g.s!==h.length||g.e!==h.length+v.data.length)return null}h+=v.data}return c(h.length*3+1),f&&(f.flat.atoms.length||f.flat.pins?.length||d!==f.flat.nodes.length||f.flat.text!==h)?null:nl.test(h)?h:null};try{c(t[0].length+t[1].length+t[2].length+e.length);let u=t.map(h=>new Set(h)),f=new Map;for(let h of e){c(1);let d=f.get(h.source);d||f.set(h.source,d=[]),d.push(h)}for(let h of f.values()){let d=[null,null],v=[];for(let g of h){c(1);let{source:m,target:k,side:S,models:x,runs:w}=g;if(S!==0&&S!==1||!u[0].has(m)||!u[S+1].has(k))continue;let{V:T,A:N,idOf:C}=n[S],I=n[1-S],q=T.twin(m),V=I.V.twin(m),U=T.baseOf(k);if(!q||!V||!U||U===m||!u[0].has(U)||!u[S+1].has(q)||!u[2-S].has(V)||N.map.get(m)!==q||N.reverse.get(q)!==m||I.A.map.get(m)!==V||I.A.reverse.get(V)!==m||N.map.get(U)!==k||N.reverse.get(k)!==U||k.parentNode!==q.parentNode||U.parentNode!==m.parentNode||m.tagName!==q.tagName||m.tagName!==V.tagName||o(m)!==C(q)||o(m)!==I.idOf(V)||o(U)!==C(k))continue;let F=x.get(m),A=x.get(k);if(!F||!A)continue;let E=p(m,F),X=p(k,A),B=p(q),z=p(V);if(c((E?.length||0)+(z?.length||0)),E===null||X===null||B===null||z===null||z===E)continue;let Ce=w.length>0,Me=!1;for(let me of w){if(c(1),me.source!==m||me.target!==k||!Number.isInteger(me.from)||!Number.isInteger(me.to)||!Number.isInteger(me.targetFrom)||me.from<0||me.to<=me.from||me.to>E.length||me.targetFrom<0||me.targetFrom+me.to-me.from>X.length){Ce=!1;break}c((me.to-me.from)*3);for(let Te=me.from;Te<me.to;Te++){if(E[Te]!==X[me.targetFrom+Te-me.from]){Ce=!1;break}nl.test(E[Te])&&(Me=!0)}if(!Ce)break}if(!Ce||!Me)continue;let Be=d[S];Be||(c(E.length),Be=d[S]={source:m,side:S,flat:F.flat,before:E,covered:new Uint8Array(E.length)});for(let me of w)c(me.to-me.from),Be.covered.fill(1,me.from,me.to)}for(let g of d){if(!g)continue;let{source:m,side:k,flat:S,before:x,covered:w}=g;c(x.length*3+1);let T=-1,N=-1;for(let C=0;C<=x.length;C++)C<x.length&&w[C]?(T<0&&(T=C),N=C+1):(C===x.length||nl.test(x[C]))&&T>=0&&(v.push({source:m,side:k,flat:S,from:T,to:N}),T=N=-1)}c(v.length),a.push(...v)}}catch(u){if(u!==l)throw u}return{records:a,budget:i}}var qh="http://www.w3.org/1999/xhtml";function Dh(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function mn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===qh}function Fh(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Os(e,t){let n=e.getAttribute("src"),r=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(n){let o=n;try{let s=new URL(n,t);o=s.origin+s.pathname+s.search}catch{}return"script|src|"+r+"|"+o}return"script|inline|"+r+"|"+Dh(e.textContent.trim())}var Bh={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function Zr(e,t=[],n=!1){if(!mn(e)||e.hasAttribute("src"))return null;let r=[Bh,...t];for(let o=0;o<r.length;o++){let s=r[o];if(!s.match(e))continue;if(!Fh(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let i=s.identity(e);return i==null||i===""?null:{key:o+":"+i,raw:i,recognizer:s}}return null}function uc(e,t,n){let r=new Set,o=s=>{mn(s)&&!t(s)&&r.add(Os(s,n))};o(e);for(let s of e.querySelectorAll("script"))o(s);return r}function Bo(e,t){let n=t.createElement("div");n.innerHTML="<script><\/script>";let r=n.firstChild;for(let o of e.attributes)r.setAttribute(o.name,o.value);return r.textContent=e.textContent,r}function fc(e,t,n){let r=[],o=[],s=new Map,i=n.trackRecovery?new Set:null,l=Array.from(e.querySelectorAll("script"));mn(e)&&l.unshift(e);for(let a of l){if(!mn(a)||n.ignored(a)||n.skip.has(a)||t.has(Os(a,n.baseURI)))continue;let c=a.ownerDocument.createElement("script");for(let p of a.attributes)c.setAttribute(p.name,p.value);if(c.textContent=a.textContent,n.beforeNodeAdded(c)===!1){i?.add(a);continue}c.hasAttribute("src")&&o.push(new Promise(p=>{c.addEventListener("load",()=>p()),c.addEventListener("error",()=>p())})),a.replaceWith(c),s.set(a,c),n.afterNodeAdded(c),r.push(c)}return{executed:r,loads:o,swapped:s,vetoed:i}}function $h(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function Uh(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function dc(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Os(e,t);if(n==="LINK"){let r=e.getAttribute("href");return r?"link|"+(e.getAttribute("rel")||"")+"|"+Uh(r,t):e.outerHTML}if(n==="META"){for(let r of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(r))return"meta|"+r+"="+e.getAttribute(r);return e.outerHTML}return n==="STYLE"?"style|"+$h(e.textContent):e.outerHTML}function rl(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
4
- `;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);if(n===-1)return e.length;t=n+2;continue}return t}}function Hh(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var zh=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Vh=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ol(e){try{return JSON.parse(e)}catch{return JSON.parse(Wh(e))}}function Wh(e){let t="",n=0,r=(o,s)=>{throw new Error(`Invalid relaxed JSON: ${o} at position ${s}`)};for(;n<e.length&&(n=rl(e,n),!(n>=e.length));){let o=e[n];if("{}[]:".includes(o)){t+=o,n++;continue}if(o===","){let l=rl(e,n+1);if(e[l]==="}"||e[l]==="]"){n++;continue}t+=o,n++;continue}if(o==='"'||o==="'"){let l=n+1;for(;l<e.length&&e[l]!==o;)e[l]==="\\"&&l++,l++;l>=e.length&&r("unterminated string",n);let a=e.slice(n+1,l);o==="'"&&(a=Hh(a)),t+='"'+a+'"',n=l+1;continue}let s=n;for(;s<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[s]);)s++;s===n&&r("unexpected character "+JSON.stringify(o),n);let i=e.slice(n,s);if(i==="true"||i==="false"||i==="null"||zh.test(i)){t+=i,n=s;continue}if(Vh.test(i)){if(e[rl(e,s)]===":"){t+='"'+i+'"',n=s;continue}r("unquoted value "+JSON.stringify(i),n)}r("invalid token "+JSON.stringify(i),n)}return t}var Vt=Symbol("hyper-morph-json-merge:missing"),Kh=["id","_id","uuid","key","slug","code","name"];function Qr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $o(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Gh(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}var Yh=/^[A-Za-z_$][\w$]*$/;function Xh(e,t){return Yh.test(t)?e===""?t:e+"."+t:e+"["+JSON.stringify(t)+"]"}function Jh(e,t){return e===""?t:e+"."+t}function Ns(e,t,n,r,o,s){if(e.onConflict){let i=l=>l===Vt?void 0:l;e.onConflict({path:t,base:i(n),local:i(r),remote:i(o),resolved:i(s)})}return s}function Zn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Zn(e[n],t[n]))return!1;return!0}if(Qr(e)&&Qr(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!$o(t,r)||!Zn(e[r],t[r]))return!1;return!0}return!1}function sl(e,t,n,r,o,s){return Zn(t,n)?t:Zn(t,e)?n:Zn(n,e)?t:Qr(t)&&Qr(n)?Zh(Qr(e)?e:{},t,n,r,o,s):Array.isArray(t)&&Array.isArray(n)?nm(e,t,n,r,o,s):Ns(r,o,e,t,n,n)}function hc(e,t,n,r,o,s){return t===Vt&&n===Vt?Vt:t===Vt?e===Vt?n:Zn(n,e)?Vt:Ns(r,o,e,t,n,n):n===Vt?e===Vt?t:Zn(t,e)?Vt:Ns(r,o,e,t,n,Vt):sl(e,t,n,r,o,s)}function Zh(e,t,n,r,o,s){let i={},l=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let a of l){let c=hc($o(e,a)?e[a]:Vt,$o(t,a)?t[a]:Vt,$o(n,a)?n[a]:Vt,r,Xh(o,a),Jh(s,a));c!==Vt&&Gh(i,a,c)}return i}function Qh(e){return e===null||typeof e!="object"}function Cs(e){return typeof e+":"+String(e)}function em(e,t){for(let n of t){let r=new Set;for(let o of n){if(!$o(o,e))return!1;let s=o[e];if(typeof s!="string"&&typeof s!="number")return!1;let i=Cs(s);if(r.has(i))return!1;r.add(i)}}return!0}function tm(e,t,n,r,o){let s=[e,t,n],i=!0;for(let l of s)for(let a of l)Qr(a)||(i=!1);if(i){let l=r.keyPaths.get(o),a=l!==void 0?[l]:r.keyCandidates;for(let c of a)if(em(c,s))return{kind:"keyed",field:c};return null}for(let l of s){let a=new Set;for(let c of l){if(!Qh(c))return null;let p=Cs(c);if(a.has(p))return null;a.add(p)}}return{kind:"self"}}function nm(e,t,n,r,o,s){let i=Array.isArray(e)?e:[],l=tm(i,t,n,r,s),a=Array.isArray(e)&&e.length===t.length&&e.length===n.length;if(!l||l.kind==="self"&&a)return a?t.map((S,x)=>sl(e[x],S,n[x],r,o+"["+x+"]",s)):Ns(r,o,e,t,n,n);let c=l.kind==="self"?Cs:S=>Cs(S[l.field]),p=S=>l.kind==="self"?o+"["+JSON.stringify(S)+"]":o+"["+l.field+"="+JSON.stringify(S[l.field])+"]",u=new Map,f=S=>{let x=new Map;for(let w of S){let T=c(w);x.set(T,w),u.has(T)||u.set(T,p(w))}return x},h=f(i),d=f(t),v=f(n),g=new Map,m=new Set([...h.keys(),...d.keys(),...v.keys()]);for(let S of m){let x=hc(h.has(S)?h.get(S):Vt,d.has(S)?d.get(S):Vt,v.has(S)?v.get(S):Vt,r,u.get(S),s);x!==Vt&&g.set(S,x)}let k=[];for(let S of n){let x=c(S);g.has(x)&&k.push(x)}for(let S=0;S<t.length;S++){let x=c(t[S]);if(!g.has(x)||k.includes(x))continue;let w=0;for(let T=S-1;T>=0;T--){let N=k.indexOf(c(t[T]));if(N!==-1){w=N+1;break}}k.splice(w,0,x)}return k.map(S=>g.get(S))}function rm(e){let t=new Map,n=[];for(let r of e.keyCandidates||[]){let o=r.lastIndexOf(":");o>=0?t.set(r.slice(0,o),r.slice(o+1)):n.push(r)}return{keyCandidates:[...n,...Kh],keyPaths:t,onConflict:e.onConflict||null}}function mc(e,t,n,r={}){return sl(e===void 0?Vt:e,t,n,rm(r),"","")}function om(e,t){let n=/^\s*/.exec(t)[0],r=/\s*$/.exec(t.slice(n.length))[0],o=t.slice(n.length,t.length-r.length),s=n.slice(n.lastIndexOf(`
1
+ var hypercms=(()=>{var Oi=Object.defineProperty;var Dd=Object.getOwnPropertyDescriptor;var Fd=Object.getOwnPropertyNames;var Bd=Object.prototype.hasOwnProperty;var Ni=(e,t)=>{for(var n in t)Oi(e,n,{get:t[n],enumerable:!0})},$d=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Fd(t))!Bd.call(e,o)&&o!==n&&Oi(e,o,{get:()=>t[o],enumerable:!(r=Dd(t,o))||r.enumerable});return e};var Ud=e=>$d(Oi({},"__esModule",{value:!0}),e);var Jb={};Ni(Jb,{cms:()=>Yb,default:()=>Xb});var gs=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],Io=new Set(gs),Ci=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Hr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),Aa=new Set(["checked","selected","disabled","readOnly","paused"]);function _i(e,t){return t==null?Aa.has(e)?!1:"":Aa.has(e)?t==="false"?!1:!!t:t}function Kt(e){let t=0,n=null,r=-1;for(let o=0;o<e.length;o++){let s=e[o];s==="\\"?o++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:s==="@"&&t===0&&(r=o)}return r}function Lo(e){let t=Kt(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function Mi(e){let t=0,n=null,r=-1,o=!1;for(let s=0;s<e.length;s++){let i=e[s];i==="\\"?s++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:t===0&&i===">"?r=s:t===0&&i===","&&(o=!0)}return o||r===-1||!Hd(e,r+1)?null:e.slice(0,r).trim()||null}function Hd(e,t){let n=t,r=e.replace(/\s+$/,"").length;for(;n<r&&/\s/.test(e[n]);)n++;let o=0,s=null;for(;n<r;n++){let i=e[n];if(i==="\\")n++;else if(s)i===s&&(s=null);else if(i==='"'||i==="'")s=i;else if(i==="["||i==="(")o++;else if(i==="]"||i===")")o>0&&o--;else if(o===0&&(i==="+"||i==="~"||/\s/.test(i)))return!1}return!0}function bs(e,t){if(typeof e=="string"){let n=t&&t.defaultView,r=n&&n.DOMParser||globalThis.DOMParser;return new r().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Ri(e){let t=new Map;return(n,r)=>{if(typeof r!="string")return bs(r,e);let o=t.get(n);if(o&&o.text===r)return o.doc;let s=bs(r,e);return t.set(n,{text:r,doc:s}),s}}function Ea(e,t){let n=t.doctype;if(!n)return!1;let r=e.doctype;if(r&&r.name===n.name&&r.publicId===n.publicId&&r.systemId===n.systemId)return!1;let o=e.implementation.createDocumentType(n.name,n.publicId,n.systemId);return r?e.replaceChild(o,r):e.insertBefore(o,e.documentElement),!0}var Ii=()=>!1;function Li(e,t=[]){if(typeof e!="function")return Ii;let n=new WeakMap,r=new Set(t);return o=>{if(!o||o.nodeType!==1)return!1;let s=n.get(o);if(s!==void 0)return s;let i=[],l=o,a=!1;for(;l&&l.nodeType===1;){let c=n.get(l);if(c!==void 0){a=c;break}if(i.push(l),e(l,r.has(l))){a=!0;break}if(r.has(l))break;l=l.parentElement}for(let c of i)n.set(c,a);return a}}var b0=Object.freeze(["root-tag","equal","root-attrs","root-level","not-in-body","ignored-ancestor","remote-wins-ancestor","form-ancestor","script-or-template","no-live-twin","live-detached","ancestor-live","sibling-live","outside-id-changed","chain-unpaired"]);function lr(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Pi(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let r=t["~"],o=typeof r=="string"?r.split(",").map(Number):null,s=o&&typeof t["^"]=="string"?t["^"].split(","):null,i=u=>Number.isInteger(u)&&u>=0,l=0,a=!1,c=u=>{let f=u;for(;f>0;){let p=o[l++];if(l>o.length||!i(p))return!1;f+=p-1}return!0},m=(u,f)=>{if(a)return;if(o){let v=l++,g=o[v];if(v>=o.length||!i(g)){a=!0;return}let d=!s||s[v]===u.tagName.toLowerCase();if(!d||g!==u.children.length){let k=d&&t[f];typeof k=="string"&&k&&n.set(u,k),c(g)||(a=!0);return}}let p=t[f];typeof p=="string"&&p&&n.set(u,p);let h=u.children;for(let v=0;v<h.length;v++)m(h[v],f===""?String(v):`${f}.${v}`)};return m(e,""),n}function Oa(e){return t=>{for(let n of e){let r=n(t);if(typeof r=="string"&&r!=="")return r}return null}}var vn=Oa([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function ks(e,t,n,r=null,o=null){let s=new Map,i=new Set,l=a=>{if(n(a))return;let c=t(a);c&&(s.has(c)?i.add(c):s.set(c,a))};if(r){let a=c=>{for(let m of c.querySelectorAll(r))l(m);for(let m of c.querySelectorAll("template"))m.content&&a(m.content)};l(e),a(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let a=c=>{l(c);let m=c.tagName==="TEMPLATE"&&c.content?c.content.children:c.children;for(let u=0;u<m.length;u++)a(m[u])};a(e)}for(let a of i)s.delete(a),o&&o.add(a),ji(a);return s}function ji(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var Vd=new Set(["href","src","name","type","role"]),Ca=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function zr(e,t=5381){let n=t;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return n>>>0}function Na(e){return e.replace(/\s+/g," ")}var Wd=0;function _a({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let r=new WeakMap,o=new WeakMap;function s(T){let N=T.attributes,C=N.length;if(C===0)return{all:"",sig:T.tagName+"|"};let L=[],q="",V=[];for(let U=0;U<C;U++){let F=N[U],A=F.name;t(T,A)||L.push(A+"="+F.value),A==="class"?q=F.value.indexOf(" ")<0?F.value:F.value.split(/\s+/).filter(Boolean).sort().join(" "):Vd.has(A)&&V.push(A+"="+F.value)}return L.length>1&&L.sort(),V.length>1&&V.sort(),{all:L.join(""),sig:T.tagName+"|"+q+(V.length?"|"+V.join("|"):"")}}function i(T){return T.nodeType===1&&T.tagName==="TEMPLATE"&&T.content?T.content.childNodes:T.childNodes}function l(T){let N=r.get(T);if(N)return N;if(T.nodeType===3)N={hash:"T"+zr(T.nodeValue),hint:Na(T.nodeValue).slice(0,64),sig:null,tok:null};else if(T.nodeType===8)N={hash:"C"+zr(T.nodeValue),hint:"",sig:null,tok:null};else if(T.nodeType===1){let C=s(T),L=zr(T.tagName+""+C.all),q="";for(let V of c(T))if(V.nodeType===1){let U=l(V);L=zr(U.hash,L),q.length<64&&(q+=" "+U.hint)}else L=zr(m(V),L),V.kind==="text"&&q.length<64&&(q+=V.value.slice(0,64));N={hash:"E"+L,hint:Na(q).trim().slice(0,64),sig:C.sig,tok:null}}else N={hash:"N"+T.nodeType,hint:"",sig:null,tok:null};return r.set(T,N),N}function a(T){if(!T.tok){T.tok=new Set;for(let N of T.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))N&&T.tok.add(N)}return T.tok}function c(T){let N=o.get(T);if(N)return N;N=[];let C=null,L=()=>{C&&(C.value=C.nodes.map(q=>q.nodeValue).join(""),N.push(C),C=null)};for(let q of i(T)){if(q.nodeType===3){C||(C={kind:"text",nodes:[],value:"",parent:T,hash:void 0}),C.nodes.push(q);continue}L(),q.nodeType===8?N.push({kind:"comment",nodes:[q],value:q.nodeValue,parent:T,hash:void 0}):q.nodeType===1&&!e(q)&&N.push(q)}return L(),o.set(T,N),N}function m(T){return T.nodeType===1?l(T).hash:(T.hash===void 0&&(T.hash=(T.kind==="text"?"T":"C")+zr(T.value)),T.hash)}function u(T,N){let C=a(l(T)),L=a(l(N));if(C.size===0&&L.size===0)return{coef:1,share:1};if(C.size===0||L.size===0)return null;let q=0;for(let V of C)L.has(V)&&q++;return{coef:q/Math.min(C.size,L.size),share:q/Math.max(C.size,L.size)}}function f(T,N){let C=u(T,N);return!!C&&C.coef>=.5}let p=new WeakMap;function h(T){let N=p.get(T);if(N)return N;N=[];for(let C of T.attributes)t(T,C.name)||N.push([C.namespaceURI||"",C.localName,C.value]);return N.sort((C,L)=>C[0]<L[0]?-1:C[0]>L[0]?1:C[1]<L[1]?-1:C[1]>L[1]?1:0),p.set(T,N),N}let v=new WeakMap;function g(T,N){if(T===N)return!0;if(m(T)!==m(N))return!1;let C=v.get(T);if(C&&C.has(N))return C.get(N);let L=v.get(N);if(L&&L.has(T))return L.get(T);let q=d(T,N),V=q===!0;return q===!1&&n&&n.hashRejected++,C||v.set(T,C=new WeakMap),C.set(N,V),V}function d(T,N){if(T.nodeType===1){if(N.nodeType!==1||T.tagName!==N.tagName||T.namespaceURI!==N.namespaceURI)return!1;let C=h(T),L=h(N);if(C.length!==L.length)return!1;for(let U=0;U<C.length;U++)if(C[U][0]!==L[U][0]||C[U][1]!==L[U][1]||C[U][2]!==L[U][2])return!1;let q=c(T),V=c(N);if(q.length!==V.length)return!1;for(let U=0;U<q.length;U++){if(m(q[U])!==m(V[U]))return!1;if(!g(q[U],V[U]))return Wd}return!0}return N.nodeType===1?!1:T.kind===N.kind&&T.value===N.value}let k=new WeakMap,S=new Map,x=0;function w(T){let N=k.get(T);if(N)return N;let C=m(T),L=S.get(C);L||S.set(C,L=[]);let q=L.find(V=>g(V.unit,T));return N=q?q.key:"K"+x++,q||L.push({unit:T,key:N}),k.set(T,N),N}return{meta:l,unitsOf:c,unitHash:m,similar:f,score:u,childrenOf:i,equalUnits:g,exactUnitKey:w,ignored:e}}var Ma=16,Kd=2e3,Gd=3,qi={align:0,certifyVisited:0,certifyScheduled:0};function Di(e,t,n){let{meta:r,unitsOf:o,unitHash:s,similar:i,score:l,childrenOf:a,equalUnits:c,ignored:m}=n.analyzer,u=n.baseId||(()=>null),f=n.sideId||(()=>null),p=n.baseKey||(()=>null),h=n.sideKey||(()=>null),v=n.baseDropped||new Set,g=n.sideDropped||new Set,d=n.stats||null,k=d?new Set:null,S=d?new Set:null,x=new Map,w=new Map,T=new Set,N=new Map,C=new Set,L=new Set,q=new Set,V=[],U=[],F=[],A=[],E=Kd,X=new Map,B=new Map,z=($,Z)=>{x.set($,Z),w.set(Z,$)},Ce=new Set,Me=new Set,Be=null,me=$=>{let Z=$.nodeType?$.parentNode:$.parent;if(!Z||Z.nodeType!==11)return Z;if(!Be){Be=new WeakMap;let ke=we=>{for(let ve of we.querySelectorAll("template"))ve.content&&(Be.set(ve.content,ve),ke(ve.content))};for(let we of[e,t])ke(we.tagName==="TEMPLATE"&&we.content?we.content:we)}return Be.get(Z)||null},Te=($,Z)=>{for(let ke=me($);ke&&!Ce.has(ke);ke=me(ke))Ce.add(ke);for(let ke=me(Z);ke&&!Me.has(ke);ke=me(ke))Me.add(ke)},Xe=$=>{for(let Z=me($);Z;Z=me(Z))if(x.has(Z))return L.has(Z);return!1},_e=$=>{for(let Z=me($);Z;Z=me(Z)){let ke=w.get(Z);if(ke!==void 0)return L.has(ke)}return!1},O=$=>!!$&&$.nodeType===1,K=($,Z)=>{let ke=N.get($);return!!ke&&ke.has(Z)},fe=$=>Ca.has($.tagName),ae=n.comparisons||n.scope,qe=($,Z)=>{if(ae){if(ae.same.get($)===Z)return!0;if(ae.differ.get($)===Z)return!1}if(!$.isEqualNode(Z))return!1;if($.tagName==="TEMPLATE")return c($,Z);let ke=$.getElementsByTagName("template");if(ke.length===0)return!0;let we=Z.getElementsByTagName("template");if(ke.length!==we.length)return!1;for(let ve=0;ve<ke.length;ve++)if(!c(ke[ve],we[ve]))return!1;return!0},ze=($,Z)=>{let ke=u($);if(!ke)return!0;let we=f(Z);return!we||ke===we},Ee=$=>{let Z=p($);return Z&&n.baseIndex.get(Z)===$&&!g.has(Z)?Z:null},ot=$=>{let Z=h($);return Z&&n.sideIndex.get(Z)===$&&!v.has(Z)?Z:null},rt=($,Z)=>{let ke=Ee($);if(!ke)return!0;let we=ot(Z);return!we||ke===we},xt=globalThis.__hyperMorphProfile,nt=xt?performance.now():0;xt&&!n.scope&&(r(e),r(t),xt.meta=(xt.meta||0)+(performance.now()-nt),nt=performance.now()),z(e,t);let te=new Set;for(let[$,Z]of n.baseIndex){let ke=n.sideIndex.get($);ke&&ke.tagName===Z.tagName&&!x.has(Z)&&!w.has(ke)&&(z(Z,ke),Te(Z,ke),te.add(Z))}if(te.size){let $=[];if(n.scope)for(let ve of n.scope.chain)te.has(ve)&&$.push(ve);let Z=[n.scope?n.scope.root:e];for(;Z.length;){let ve=Z.pop();te.has(ve)&&$.push(ve);let ne=a(ve);for(let se=ne.length-1;se>=0;se--)ne[se].nodeType===1&&Z.push(ne[se])}let ke=new Set;for(let ve=$.length-1;ve>=0;ve--){let ne=$[ve];n.scope&&n.scope.onChain.has(ne)?ke.add(ne):Ge(ne,x.get(ne),ke)?(L.add(ne),q.add(ne),d&&d.certificationPairs++):ke.add(ne)}let we=new Set;for(let ve of $)L.has(ve)&&!we.has(ve)&&Ae(ve,we)}n.scope&&n.scope.head&&Tt(n.scope.head[0],n.scope.head[1]);function Ae($,Z){let ke=[$];for(;ke.length;){let we=ke.pop();if(!Z.has(we)){Z.add(we),M(we);for(let ve of o(we))O(ve)&&x.has(ve)&&ke.push(ve)}}}A.push([e,t]);for(let[$,Z]of x)O($)&&$!==e&&A.push([$,Z]);return et(),je(),xt&&(xt.align=(xt.align||0)+(performance.now()-nt)),{map:x,reverse:w,moved:C,identical:L,pairIdenticalChildren:M,weak:T,unpair:Fe,rematch:je,insertedByHash:He,refused:S,identityPaired:te};function je(){Oe(),et();for(let $=0;$<F.length;){let Z=F.length;yt($,Z),$=Z,et(),Oe(),et()}}function Fe($){let Z=x.get($);if(!Z)return;N.has($)||N.set($,new Set),N.get($).add(Z);let ke=(ve,ne)=>{x.delete(ve),w.delete(ne),C.delete(ve),L.delete(ve),T.delete(ve),q.delete(ve)},we=(ve,ne)=>{for(let se of o(ve)){let W=x.get(se);!W||te.has(se)||!(O(W)?ne.contains(W):ne.contains(W.nodes[0]))||(ke(se,W),O(se)&&we(se,W))}};ke($,Z),O($)&&we($,Z),V.push($),U.push(Z)}function He(){let $=new Map;for(let Z of new Set(U)){if(w.has(Z))continue;let ke=r(Z).hash;$.has(ke)||$.set(ke,[]),$.get(ke).push(Z)}return $}function et(){for(;A.length;){let[$,Z]=A.shift();x.get($)!==Z||q.has($)||L.has($)||Ft($,Z)}}function bt($,Z){if(!fe($))for(let ke of o($))O(ke)&&(Z.push(ke),bt(ke,Z))}function Ft($,Z){q.add($);let ke=o($),we=o(Z);qi.align+=ke.length+we.length,X=new Map,B=new Map;for(let ce=0;ce<ke.length;ce++)X.set(ke[ce],ce);for(let ce=0;ce<we.length;ce++)B.set(we[ce],ce);if($.tagName==="HTML")for(let ce of["HEAD","BODY"]){let Ne=ke.find(De=>O(De)&&De.tagName===ce),Pe=we.find(De=>O(De)&&De.tagName===ce);Ne&&Pe&&!x.has(Ne)&&!w.has(Pe)&&z(Ne,Pe)}for(let ce=0;ce<ke.length&&ce<we.length;ce++){let Ne=ke[ce],Pe=we[ce];x.has(Ne)||w.has(Pe)||(O(Ne)?O(Pe)&&Ne.tagName===Pe.tagName&&qe(Ne,Pe)&&Tt(Ne,Pe):!O(Pe)&&Ne.kind===Pe.kind&&Ne.value===Pe.value&&Tt(Ne,Pe))}de(ke,we);let ve=ke.filter(ce=>!x.has(ce)),ne=we.filter(ce=>!w.has(ce));ve.length&&ne.length&&(en(ve,ne),P(ve,ne),H(ve,ne,ke,we),ge(ke,we));let se=!1,W=!1;for(let ce of ke){if(!x.has(ce)){O(ce)&&(V.push(ce),bt(ce,V),se=!0);continue}O(ce)&&!L.has(ce)&&A.push([ce,x.get(ce)])}for(let ce of we)!w.has(ce)&&O(ce)&&(U.push(ce),bt(ce,U),W=!0);se&&W&&F.push([$,Z])}function yt($,Z){for(let ke=$;ke<Z;ke++){let[we,ve]=F[ke];if(x.get(we)!==ve)continue;let ne=o(we),se=o(ve),W=new Map,ce=new Map,Ne=null;for(let Pe of ne)O(Pe)&&(x.has(Pe)?Ne=Pe:(W.has(Ne)||W.set(Ne,[]),W.get(Ne).push(Pe)));Ne=null;for(let Pe of se)O(Pe)&&(w.has(Pe)?Ne=w.get(Pe):(ce.has(Ne)||ce.set(Ne,[]),ce.get(Ne).push(Pe)));for(let[Pe,De]of W){let Se=ce.get(Pe);if(!(!Se||De.length!==Se.length)&&De.every((tt,lt)=>Se[lt].tagName===tt.tagName&&ze(tt,Se[lt])&&!K(tt,Se[lt])))for(let tt=0;tt<De.length;tt++)It(De[tt],Se[tt])}}}function It($,Z){z($,Z),T.add($),A.push([$,Z]),et()}function en($,Z){let ke=Vr($,s),we=Vr(Z,s),ve=new Map;for(let ne of Z){let se=s(ne);we.get(se)===1&&ve.set(se,ne)}for(let ne of $){if(x.has(ne))continue;let se=s(ne);if(ke.get(se)!==1)continue;let W=ve.get(se);W&&!w.has(W)&&c(ne,W)&&Tt(ne,W)}}function Ge($,Z,ke){let we=[[$,Z]];for(;we.length;){let[ve,ne]=we.pop();if(qi.certifyVisited++,d&&d.certificationVisited++,ve.nodeType!==ne.nodeType)return!1;if(ve.nodeType===3||ve.nodeType===8){if(ve.nodeValue!==ne.nodeValue)return!1;continue}if(ve.nodeType!==1){if(!ve.isEqualNode(ne))return!1;continue}if(ve.tagName!==ne.tagName||ve.namespaceURI!==ne.namespaceURI||m(ve)!==m(ne))return!1;let se=ve.attributes,W=ne.attributes;if(se.length!==W.length)return!1;for(let Se=0;Se<se.length;Se++){let tt=se[Se];if(ne.getAttributeNS(tt.namespaceURI,tt.localName)!==tt.value)return!1}let ce=x.get(ve);if(ce!==void 0&&ce!==ne)return!1;let Ne=w.get(ne);if(Ne!==void 0&&Ne!==ve)return!1;if(ve!==$){if(L.has(ve))continue;if(ke.has(ve))return!1}let Pe=a(ve),De=a(ne);if(Pe.length!==De.length)return!1;qi.certifyScheduled+=Pe.length;for(let Se=Pe.length-1;Se>=0;Se--)we.push([Pe[Se],De[Se]])}return!0}function Ct($,Z){return!O($)||!(Ce.has($)||Me.has(Z))?!0:!!Y($,Z)||!(Ee($)||ot(Z))}function Tt($,Z){if(O($)&&(Ce.has($)||Me.has(Z))){let ke=Y($,Z);if(!ke){if(Ee($)||ot(Z))return;z($,Z),A.push([$,Z]);return}for(let we=0;we<ke.length;we+=2){let ve=ke[we],ne=ke[we+1],se=x.get(ve);se!==void 0&&se!==ne&&Jt(ve,se);let W=w.get(ne);W!==void 0&&W!==ve&&Jt(W,ne),x.get(ve)===ne&&(C.delete(ve),T.delete(ve),L.add(ve),q.add(ve))}}y($,Z)}function Jt($,Z){x.delete($),w.delete(Z),C.delete($),L.delete($),T.delete($),q.delete($)}function Y($,Z){let ke=[$,Z,!1],we=[];for(;ke.length;){let ve=ke.pop(),ne=ke.pop(),se=ke.pop(),W=x.get(se),ce=w.get(ne);if(se!==$&&(W!==void 0&&W!==ne&&te.has(se)||ce!==void 0&&ce!==se&&te.has(ce)))return null;if(!(W===ne&&L.has(se))&&((W!==void 0||ce!==void 0)&&we.push(se,ne),!!O(se))){if(ve||W!==void 0&&W!==ne||ce!==void 0&&ce!==se){let Ne=o(se),Pe=o(ne);for(let De=0;De<Ne.length&&De<Pe.length;De++)ke.push(Ne[De],Pe[De],!0)}else if(Ce.has(se)||Me.has(ne)){let Ne=se.tagName==="TEMPLATE"?se.content:se,Pe=ne.tagName==="TEMPLATE"?ne.content:ne;for(let De=Ne.firstElementChild,Se=Pe.firstElementChild;De&&Se;){if(m(De)){De=De.nextElementSibling;continue}if(m(Se)){Se=Se.nextElementSibling;continue}(x.has(De)||w.has(Se)||Ce.has(De)||Me.has(Se))&&ke.push(De,Se,!1),De=De.nextElementSibling,Se=Se.nextElementSibling}}}}return we}function y($,Z){z($,Z),L.add($),O($)&&q.add($)}function M($){let Z=x.get($);if(!Z||!O($))return;let ke=o($),we=o(Z);for(let ve=0;ve<ke.length&&ve<we.length;ve++)x.has(ke[ve])||y(ke[ve],we[ve])}function P($,Z){let ke=se=>O(se)&&!fe(se)?r(se).sig+""+r(se).hint:null,we=Vr($,ke),ve=Vr(Z,ke),ne=new Map;for(let se of Z){let W=ke(se);W!=null&&ve.get(W)===1&&ne.set(W,se)}for(let se of $){if(x.has(se))continue;let W=ke(se);if(W==null||we.get(W)!==1)continue;let ce=ne.get(W);ce&&!w.has(ce)&&ze(se,ce)&&z(se,ce)}}function H($,Z,ke,we){let ve=new Map;for(let se of Z){if(!O(se)||w.has(se)||fe(se))continue;let W=r(se).sig;ve.has(W)||ve.set(W,[]),ve.get(W).push({el:se,index:B.get(se)})}let ne=[];for(let se of $){if(x.has(se)||!O(se)||fe(se))continue;let W=ve.get(r(se).sig);if(!W||!W.length)continue;let ce=X.get(se),Ne=W.filter(Pe=>!w.has(Pe.el)).map(Pe=>({c:Pe,d:Math.abs(Pe.index-ce)}));Ne.sort((Pe,De)=>Pe.d-De.d),Ne.length>Ma&&(Ne=Ne.slice(0,Ma));for(let{c:Pe,d:De}of Ne){if(!ze(se,Pe.el))continue;let Se=l(se,Pe.el);Se&&Se.coef>=.5&&ne.push({b:se,s:Pe.el,coef:Se.coef,share:Se.share,d:De,bi:ce})}}if(ne.sort((se,W)=>W.coef-se.coef||W.share-se.share||se.d-W.d||se.bi-W.bi),d&&ne.length>1){let se=new Map;for(let W of ne){let ce=se.get(W.b);ce?ce.coef===W.coef&&(ce.share===W.share?ce.strict++:ce.loose++):se.set(W.b,{coef:W.coef,share:W.share,strict:0,loose:0})}for(let[W,ce]of se)k.has(W)||!(ce.strict||ce.loose)||(k.add(W),ce.strict?d.similarTiesStrict++:d.similarTiesLoose++)}for(let se of ne)!x.has(se.b)&&!w.has(se.s)&&z(se.b,se.s)}function Q($,Z){return O($)!==O(Z)?!1:O($)?$.tagName!==Z.tagName||!ze($,Z)?!1:fe($)||r($).hint===""||r(Z).hint===""?!0:i($,Z):$.kind===Z.kind}function D($,Z){let ke=(ve,ne)=>{let se=ne===null?-1:ve===Z?B.get(ne):X.get(ne),W=ve[se+1];return W&&!O(W)?W:null},we=null;for(let ve of $){if(O(ve)){we=ve;continue}if(x.has(ve))continue;let ne=we===null?null:x.get(we);if(we!==null&&!ne)continue;let se=ke(Z,ne);se&&!w.has(se)&&se.kind===ve.kind&&z(ve,se)}}function ge($,Z){D($,Z);let ke=xe($,Z),we=(ne,se)=>O(ne)&&r(ne).hint!==""&&r(se).hint===""&&!!se.querySelector("br")&&!ke(ne,se),ve=0;for(let ne of $){if(x.has(ne)){let W=B.get(x.get(ne));W!==void 0&&W>=ve&&(ve=W+1);continue}let se=0;for(let W=ve;W<Z.length&&se<Gd;W++){let ce=Z[W];if(!w.has(ce)&&(se++,Q(ne,ce)&&!K(ne,ce)&&!we(ne,ce))){z(ne,ce),O(ne)&&(r(ne).hint===""||r(ce).hint==="")&&T.add(ne),ve=W+1;break}}}de($,Z)}function xe($,Z){let ke=(we,ve,ne)=>{for(let se=ve-1;se>=0;se--)if(O(we[se])&&ne(we[se]))return we[se];return null};return(we,ve)=>{let ne=X.get(we),se=B.get(ve);if(ne===se)return!0;let W=ke($,ne,Ne=>x.has(Ne)),ce=ke(Z,se,Ne=>w.has(Ne));return W?x.get(W)===ce:!ce}}function de($,Z){let ke=$.filter(W=>O(W)&&!x.has(W)),we=Z.filter(W=>O(W)&&!w.has(W));if(!ke.length||!we.length)return;let ve=Vr(ke,W=>W.tagName),ne=Vr(we,W=>W.tagName),se=xe($,Z);for(let W of ke){let ce=W.tagName;if(ve.get(ce)!==1||ne.get(ce)!==1)continue;let Ne=we.find(Pe=>Pe.tagName===ce);Ne&&!w.has(Ne)&&se(W,Ne)&&ze(W,Ne)&&!K(W,Ne)&&(c(W,Ne)?Tt(W,Ne):(z(W,Ne),T.add(W)))}}function Oe(){let $=new Map;for(let W of T)if(O(W)&&O(x.get(W))){let ce=r(W).hash;$.has(ce)||$.set(ce,[]),$.get(ce).push(W)}if($.size)for(let W of U){if(w.has(W)||!O(W)||_e(W))continue;let ce=$.get(r(W).hash),Ne=ce&&ce.find(Pe=>T.has(Pe)&&!K(Pe,W)&&ze(Pe,W)&&rt(Pe,W)&&c(Pe,W)&&Ct(Pe,W));Ne&&(Fe(Ne),Tt(Ne,W),Te(Ne,W),C.add(Ne))}let Z=new Map,ke=new Map,we=new Map;for(let W of T){let ce=x.get(W);O(W)&&O(ce)&&we.set(ce,W)}let ve=(W,ce)=>{if(!w.has(W))return!_e(W);let Ne=we.get(W);return Ne===w.get(W)&&Ne!==ce&&!Ne.contains(ce)},ne=W=>{if(w.has(W)){let ce=we.get(W);we.delete(W),Fe(ce)}};for(let W of[...U,...we.keys()]){if(w.has(W)&&!we.has(W))continue;let ce=r(W).hash;if(Z.has(ce)||Z.set(ce,[]),Z.get(ce).push(W),fe(W))continue;let Ne=r(W).sig;ke.has(Ne)||ke.set(Ne,[]),ke.get(Ne).push(W)}let se=new Set;for(let W of T){let ce=x.get(W);!O(W)||!O(ce)||fe(W)||r(W).hint===""||r(ce).hint===""||i(W,ce)||se.add(W)}for(let W of[...V,...se]){let ce=x.get(W);if(ce?!(T.has(W)&&se.has(W)):Xe(W))continue;let Ne=lt=>{ce&&Fe(W),ne(lt)},Pe=Z.get(r(W).hash);if(Pe){let lt=Pe.find(it=>it!==ce&&ve(it,W)&&!K(W,it)&&rt(W,it)&&c(W,it)&&Ct(W,it));if(lt){Ne(lt),Tt(W,lt),Te(W,lt),C.add(W);continue}}if(fe(W)||E<=0)continue;let De=ke.get(r(W).sig);if(!De)continue;let Se=null,tt=0;for(let lt of De)if(!(lt===ce||!ve(lt,W)||!ze(W,lt)||!rt(W,lt)||K(W,lt))&&(E--<=0||i(W,lt)&&(tt++,Se=lt,tt>1)))break;tt>1&&S&&S.add(W),tt===1&&(Ne(Se),z(W,Se),Te(W,Se),C.add(W),A.push([W,Se]))}}}function Vr(e,t){let n=new Map;for(let r of e){let o=t(r);o!=null&&n.set(o,(n.get(o)||0)+1)}return n}var Yd={diff:0},Ra=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,Xd=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,Jd=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,Zd=/\P{M}\p{M}*/gu;function Qd(e){if(e==="")return[];if(Ra){let n=[];for(let r of Ra.segment(e))n.push(r.segment);return n}let t=[];for(let n of e.match(Jd))if(Xd.test(n))for(let r of n.match(Zd))t.push(r);else t.push(n);return t}var eh=/^[  ]+$/,th=e=>eh.test(e)?" ".repeat(e.length):e,ar=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),Ot="",Fi=e=>e.every(t=>ar(t)||t.k===Ot),nh=/^[\x00-\x7f\u00A0]*$/,rh=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function oh(e){return e===""?[]:e.match(rh)}function un(e,t=!1){return(t?oh(e):Qd(e)).map(n=>({k:th(n),raw:n,len:n.length}))}var xn=(...e)=>e.every(t=>nh.test(t));function Bi(e,t,n){let r=e.length,o=t.length,s=Math.min(r+o,n),i=s+1,l=new Int32Array(2*s+3),a=[],c=r===0&&o===0;for(let p=0;p<=s&&!c;p++){a.push(l.slice(i-p,i+p+1));for(let h=-p;h<=p;h+=2){let v;h===-p||h!==p&&l[i+h-1]<l[i+h+1]?v=l[i+h+1]:v=l[i+h-1]+1;let g=v-h,d=v;for(;v<r&&g<o&&e[v].k===t[g].k;)v++,g++;if(Yd.diff+=1+v-d,l[i+h]=v,v>=r&&g>=o){c=!0;break}}}if(!c)return null;let m=[],u=r,f=o;for(let p=a.length-1;p>0;p--){let h=a[p],v=u-f,g=v+p,d=v===-p||v!==p&&h[g-1]<h[g+1]?v+1:v-1,k=h[d+p],S=k-d;for(;u>k&&f>S;)m.push([0,u-1,f-1]),u--,f--;u===k?(m.push([1,u,f-1]),f--):(m.push([-1,u-1,f]),u--)}for(;u>0&&f>0;)m.push([0,u-1,f-1]),u--,f--;return m.reverse(),m}function sh(e,t,n){let r=u=>u.k===Ot;if(!e.some(r)&&!t.some(r))return Bi(e,t,n);let o=[],s=[];for(let u=0;u<e.length;u++)r(e[u])||o.push(u);for(let u=0;u<t.length;u++)r(t[u])||s.push(u);let i=Bi(o.map(u=>e[u]),s.map(u=>t[u]),n);if(!i)return null;let l=[],a=0,c=0,m=(u,f)=>{for(;a<u&&c<f&&e[a].k===t[c].k;)l.push([0,a++,c++]);let p=Bi(e.slice(a,u),t.slice(c,f),n);if(!p)return!1;for(let[h,v,g]of p)l.push([h,v+a,g+c]);return a=u,c=f,!0};for(let[u,f,p]of i)if(u===0){if(!m(o[f],s[p]))return null;l.push([0,a,c]),a++,c++}return m(e.length,t.length)?l:null}function Xn(e,t,n=4e3){let r=[],o=0;for(;o<e.length&&o<t.length&&e[o].k===t[o].k;)e[o].raw!==t[o].raw&&r.push({bi:o,tok:t[o]}),o++;let s=0;for(;s<e.length-o&&s<t.length-o&&e[e.length-1-s].k===t[t.length-1-s].k;)e[e.length-1-s].raw!==t[t.length-1-s].raw&&r.push({bi:e.length-1-s,tok:t[t.length-1-s]}),s++;let i=e.slice(o,e.length-s),l=t.slice(o,t.length-s),a=fh(i,l)?null:sh(i,l,n);if(!a){let d=i.length||l.length?[{bs:o,be:o+i.length,toks:l}]:[];return{hunks:d,cosmetic:r,coarse:!0,parts:d.map(k=>({...k,gap:[],group:0})),cosmeticEq:r}}let c=[],m=(d,k)=>{i[d].raw!==l[k].raw&&r.push({bi:o+d,tok:l[k]})},u=null,f=[],p=0,h=0,v=()=>{u&&c.push(u),u=null;for(let[d,k]of f)m(d,k);f=[],p++};for(let[d,k,S]of a){if(d===0){u&&ar(i[k])&&!i[k].k.includes(`
2
+ `)?f.push([k,S]):(v(),m(k,S)),h=k+1;continue}(!u||f.length)&&(u&&c.push(u),u={bs:o+h,be:o+h,toks:[],gap:f.map(([x,w])=>({bi:o+x,tok:l[w]})),group:p},f=[]),d===-1?(u.be=o+h+1,h=k+1):u.toks.push(l[S])}v(),ih(c,e);let g=Ui(c);return{hunks:g.hunks,cosmetic:r.concat(g.cosmetic),parts:c,cosmeticEq:r}}function ih(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r.gap.length)continue;let o=n+1<e.length?e[n+1].bs:1/0;if(r.toks.length){if(r.bs===r.be)for(;r.bs+1<o&&r.bs<t.length&&r.toks[0].k===Ot&&t[r.bs].k===Ot;)r.toks=[...r.toks.slice(1),r.toks[0]],r.bs++,r.be++}else for(;r.be+1<o&&r.be<t.length&&t[r.bs].k===Ot&&t[r.be].k===Ot;)r.bs++,r.be++}}function Ui(e,t=()=>!1){let n=[],r=[],o=null,s=-1;for(let i of e){let l=t(i);if(o&&!o.alone&&!l&&i.group===s){o.be=i.be;for(let a of i.gap)o.toks.push(a.tok);for(let a of i.toks)o.toks.push(a);continue}o&&n.push({bs:o.bs,be:o.be,toks:o.toks});for(let a of i.gap)r.push(a);o={bs:i.bs,be:i.be,toks:i.toks.slice(),alone:l},s=i.group}return o&&n.push({bs:o.bs,be:o.be,toks:o.toks}),{hunks:n,cosmetic:r}}var lh=(e,t)=>e.bs===t.bs&&e.be===t.be&&Vi(e.toks,t.toks);function zi(e,t,n){let r=m=>u=>m.some(f=>lh(u,f)),o=Ui(e.parts,r(t.parts)),s=Ui(t.parts,r(e.parts)),i=e.cosmeticEq.concat(o.cosmetic),l=t.cosmeticEq.concat(s.cosmetic),[a,c]=n?ah(o.hunks,s.hunks,n,i,l):[o.hunks,s.hunks];return{lh:a,rh:c,cosL:i,cosR:l}}function ah(e,t,n,r,o){let s=(h,v)=>h.k===v.k&&h.raw===v.raw,i=[{list:e.map(h=>({...h})),resp:new Set(r.map(h=>h.bi)),raw:new Map(r.map(h=>[h.bi,h.tok]))},{list:t.map(h=>({...h})),resp:new Set(o.map(h=>h.bi)),raw:new Map(o.map(h=>[h.bi,h.tok]))}],l=h=>h.bs===h.be,a=(h,v,g,d)=>{let k=h.list[v];if(!l(k))return d(k)===g?k.toks:null;let S=v?h.list[v-1].be:0,x=v+1<h.list.length?h.list[v+1].bs:n.length;if(g<S||g>x)return null;let w=k.toks,T=k.bs;for(;T>g;){let N=w[w.length-1];if(!s(N,n[T-1])||h.resp.has(T-1))return null;w=[N,...w.slice(0,-1)],T--}for(;T<g;){if(!s(w[0],n[T])||h.resp.has(T))return null;w=[...w.slice(1),w[0]],T++}return w},c=(h,v,g,d,k,S)=>{let x=h.list[v],w=k?g.slice(g.length-d):g.slice(0,d),T=k?g.slice(0,g.length-d):g.slice(d),N={bs:S,be:S,toks:w};if(l(x)){if(!T.length){h.list[v]=N;return}let L={bs:S,be:S,toks:T};k&&(L.lead=!0),h.list.splice(v,1,...k?[L,N]:[N,L]);return}let C={bs:x.bs,be:x.be,toks:T};h.list.splice(v,1,...k?[C,N]:[N,C])},m=(h,v,g,d,k)=>{let S=h.list[v],x=k?g.slice(g.length-d):g.slice(0,d),w=k?g.slice(0,g.length-d):g.slice(d),T={bs:S.bs,be:S.be,toks:x};if(!w.length){h.list[v]=T;return}let N=k?{bs:S.bs,be:S.bs,toks:w,lead:!0}:{bs:S.be,be:S.be,toks:w};h.list.splice(v,1,...k?[N,T]:[T,N])},u=(h,v,g,d)=>{let k=h.list[v],S=g.list[d],x=k.be,w=S.bs;if(x>=w||v+1<h.list.length&&h.list[v+1].bs<=S.be||d>0&&g.list[d-1].be>=k.bs)return!1;for(let B=x;B<w;B++)if(!ar(n[B])||n[B].k.includes(`
3
+ `))return!1;let T=B=>n.slice(x,w).map((z,Ce)=>B.raw.get(x+Ce)||z),N=[...k.toks,...T(h)],C=[...T(g),...S.toks],L=(B,z,Ce)=>z>=0&&z+Ce.length<=B.length&&Ce.every((Me,Be)=>B[z+Be].k===Me.k),q=(B,z,Ce)=>Fi(B)&&n.slice(z,Ce).some(Me=>!ar(Me)),V=B=>B.some(z=>!ar(z)),U,F,A,E;if(l(k)&&V(k.toks)&&L(C,0,k.toks)){let B=C.slice(k.toks.length);q(B,x,S.be)||(U=x,F=k.toks,A=C.slice(0,k.toks.length),E=[null,{bs:x,be:S.be,toks:B}])}if(U===void 0&&l(S)&&V(S.toks)){let B=N.length-S.toks.length,z=N.slice(0,B);L(N,B,S.toks)&&!q(z,k.bs,w)&&(U=w,F=N.slice(B),A=S.toks,E=[{bs:k.bs,be:w,toks:z},null])}if(U===void 0)return!1;let X=B=>B&&(B.bs<B.be||B.toks.length);return h.list.splice(v,1,...[E[0],{bs:U,be:U,toks:F}].filter(X)),g.list.splice(d,1,...[{bs:U,be:U,toks:A},E[1]].filter(X)),!0},f=i[0],p=i[1];for(let h=0;h<64;h++){let v=!1;e:for(let g=0;g<f.list.length;g++)for(let d=0;d<p.list.length;d++){let k=f.list[g],S=p.list[d];if(!(k.bs===S.bs&&k.be===S.be&&Vi(k.toks,S.toks))){for(let x of[!0,!1]){let w=N=>x?N.be:N.bs,T=l(k)?[w(S),k.bs]:[w(k)];for(let N of T){let C=a(f,g,N,w),L=C&&a(p,d,N,w);if(!L)continue;let q=(E,X)=>x?E[E.length-1-X]:E[X],V=0;for(;V<C.length&&V<L.length&&q(C,V).k===q(L,V).k;)V++;if(!V)continue;let U=x?C.slice(0,C.length-V):C.slice(V),F=x?L.slice(0,L.length-V):L.slice(V);if(!(V<C.length&&V<L.length&&!Fi(U)&&!Fi(F)&&(l(k)&&l(S)||k.bs===S.bs&&k.be===S.be)||!(x?C.slice(C.length-V):C.slice(0,V)).some(E=>!ar(E)))){if(V===C.length&&V===L.length&&l(k)&&l(S)){if(k.bs===N&&S.bs===N)continue;f.list[g]={bs:N,be:N,toks:C},p.list[d]={bs:N,be:N,toks:L}}else!l(k)&&k.bs===S.bs&&k.be===S.be?(m(f,g,C,V,x),m(p,d,L,V,x)):(c(f,g,C,V,x,N),c(p,d,L,V,x,N));v=!0;break e}}}if(u(f,g,p,d)||u(p,d,f,g)){v=!0;break e}}}if(!v)break}return[f.list,p.list]}var ch=48,uh=.3;function fh(e,t){let n=e.filter(i=>!ar(i)),r=t.filter(i=>!ar(i));if(Math.min(n.length,r.length)<ch)return!1;let o=new Map;for(let i of n)o.set(i.k,(o.get(i.k)||0)+1);let s=0;for(let i of r){let l=o.get(i.k);l>0&&(s++,o.set(i.k,l-1))}return s/Math.min(n.length,r.length)<uh}var dh=(e,t)=>{let n=new Set;for(let r of e.toks)typeof r.k!="string"&&n.add(r.k.el);for(let r=e.bs;r<e.be;r++)typeof t[r].k!="string"&&n.add(t[r].k.el);return n},Vi=(e,t)=>e.length===t.length&&e.every((n,r)=>n.k===t[r].k);function Ia(e,t,n,r="remote"){let o=Xn(e,t),s=Xn(e,n),{lh:i,rh:l,cosL:a,cosR:c}=zi(o,s,e),m=O=>O.bs===O.be,u=O=>O.toks.some(K=>typeof K.k=="string"),f=O=>m(O)&&!u(O),p=(O,K)=>K.bs<O.be&&O.bs<K.be,h=(O,K)=>!p(O,K)&&K.bs<=O.be&&O.bs<=K.be&&(m(O)&&u(O)||m(K)&&u(K))&&!(m(O)&&m(K)),v=(O,K)=>O.bs===K.bs&&O.be===K.be&&Vi(O.toks,K.toks),g=[],d=new Set;for(let O of i){let K=l.find(fe=>!d.has(fe)&&v(O,fe));K?(d.add(K),g.push({bs:O.bs,be:O.be,side:"both",l:O,r:K,toks:O.toks})):g.push({bs:O.bs,be:O.be,side:"L",l:O,toks:O.toks,lead:!!O.lead})}for(let O of l)d.has(O)||g.push({bs:O.bs,be:O.be,side:"R",r:O,toks:O.toks,lead:!!O.lead});g.sort((O,K)=>O.bs-K.bs||O.be-K.be||K.lead-O.lead);let k=0,S=0;for(let O of g)O.side==="both"&&(k+=O.toks.length-(O.be-O.bs));let x=g.map((O,K)=>K),w=O=>x[O]===O?O:x[O]=w(x[O]),T=(O,K)=>(O=w(O),K=w(K),O===K?!1:(x[O]=K,!0)),N=g.map(O=>dh({bs:O.bs,be:O.be,toks:O.toks},e)),C={L:new Map,R:new Map};g.forEach((O,K)=>{let fe=O.side==="both"?["L","R"]:[O.side];for(let ae of fe)for(let qe of N[K])C[ae].has(qe)||C[ae].set(qe,[]),C[ae].get(qe).push(K)});for(let O of[C.L,C.R])for(let K of O.values())for(let fe=1;fe<K.length;fe++)T(K[0],K[fe]);for(let O=0;O<g.length;O++)for(let K=O+1;K<g.length;K++){let fe=g[O],ae=g[K];fe.side===ae.side&&fe.side!=="both"||fe.bs>ae.be||(p(fe,ae)||h(fe,ae)?T(O,K):fe.bs===ae.bs&&m(fe)&&m(ae)&&S++)}let L=(O,K)=>{let fe=O==="L"?i:l;for(let ae of fe)if(ae.toks.some(qe=>qe.kind==="close"&&qe.k.el===K.el))return ae.bs;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="close"&&e[ae].k.el===K.el)return ae;return-1};g.forEach((O,K)=>{if(!(!f(O)||O.side==="both"))for(let fe of O.toks){if(fe.kind!=="open")continue;let ae=L(O.side,fe.k);if(ae<=O.bs)continue;let qe=new Uint8Array(ae-O.bs),ze=[];if(g.forEach((Ee,ot)=>{if(!(Ee.side===O.side||m(Ee))&&Ee.bs<ae&&Ee.be>O.bs){ze.push(ot);for(let rt=Math.max(Ee.bs,O.bs);rt<Math.min(Ee.be,ae);rt++)qe[rt-O.bs]=1}}),ze.length&&qe.every(Ee=>Ee===1))for(let Ee of ze)T(K,Ee)}});let q=!0;for(;q;){q=!1;let O=new Map;g.forEach((K,fe)=>{let ae=w(fe),qe=O.get(ae)||{bs:K.bs,be:K.be,L:!1,R:!1};qe.bs=Math.min(qe.bs,K.bs),qe.be=Math.max(qe.be,K.be),K.side!=="R"&&(qe.L=!0),K.side!=="L"&&(qe.R=!0),O.set(ae,qe)}),g.forEach((K,fe)=>{for(let[ae,qe]of O){if(w(fe)===w(ae)||!(qe.L&&qe.R))continue;let ze=K.bs<qe.be&&K.be>qe.bs,Ee=m(K)&&u(K)&&(K.bs===qe.be||K.bs===qe.bs);(ze||Ee)&&T(fe,ae)&&(q=!0)}})}let V=new Map;g.forEach((O,K)=>{let fe=w(K);V.has(fe)||V.set(fe,[]),V.get(fe).push(O)});let U=[];for(let O of V.values()){let K=O.some(ae=>ae.side==="L"),fe=O.some(ae=>ae.side==="R");if(K&&fe){let ae=Math.min(...O.map(ot=>ot.bs)),qe=Math.max(...O.map(ot=>ot.be)),ze=O.filter(ot=>ot.side!=="R").map(ot=>ot.l).sort((ot,rt)=>ot.bs-rt.bs),Ee=O.filter(ot=>ot.side!=="L").map(ot=>ot.r).sort((ot,rt)=>ot.bs-rt.bs);U.push({bs:ae,be:qe,kind:"conflict",localHunks:ze,remoteHunks:Ee})}else for(let ae of O)U.push({bs:ae.bs,be:ae.be,kind:ae.side,u:ae})}let F=(O,K)=>{let fe=O==="L"?i:l;for(let ae of fe)if(ae.toks.some(qe=>qe.kind==="close"&&qe.k.el===K.el))return ae.bs+.5;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="close"&&e[ae].k.el===K.el)return ae;return 1/0},A=(O,K)=>{let fe=O==="L"?i:l;for(let ae of fe)if(ae.toks.some(qe=>qe.kind==="open"&&qe.k.el===K.el))return ae.bs-.5;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="open"&&e[ae].k.el===K.el)return ae;return-1/0},E=O=>O.kind==="R"?"R":"L",X=O=>O.kind==="R"?1:0;U.sort((O,K)=>{if(O.bs!==K.bs)return O.bs-K.bs;let fe=O.bs===O.be,ae=K.bs===K.be;if(fe!==ae)return fe?-1:1;if(fe&&ae&&O.kind!=="conflict"&&K.kind!=="conflict"){let ze=O.u.toks,Ee=K.u.toks,ot=xt=>xt.length&&xt.every(nt=>nt.kind==="open"),rt=xt=>xt.length&&xt.every(nt=>nt.kind==="close");if(ot(ze)&&ot(Ee)){let xt=Math.max(...ze.map(te=>F(E(O),te.k))),nt=Math.max(...Ee.map(te=>F(E(K),te.k)));if(xt!==nt)return nt-xt}if(rt(ze)&&rt(Ee)){let xt=Math.min(...ze.map(te=>A(E(O),te.k))),nt=Math.min(...Ee.map(te=>A(E(K),te.k)));return xt!==nt?nt-xt:X(K)-X(O)}}let qe=ze=>ze.u&&ze.u.lead?1:0;return qe(K)-qe(O)||X(O)-X(K)||O.be-K.be});let B=[],z=[],Ce=0,Me=O=>{O>Ce&&(B.push({bs:Ce,be:O,toks:e.slice(Ce,O),source:"base"}),Ce=O)};for(let O of U){if(Me(O.bs),O.kind==="conflict"){let K=Hi(e,O.localHunks,O.bs,O.be),fe=Hi(e,O.remoteHunks,O.bs,O.be),ae=r==="local"?K:r==="both"?K.concat(fe):fe,qe=(ot,rt)=>{let xt=0;for(let nt of ot)nt.be<=O.bs&&!rt.includes(nt)&&(xt+=nt.toks.length-(nt.be-nt.bs));return xt},ze=O.bs+qe(i,O.localHunks),Ee=O.bs+qe(l,O.remoteHunks);z.push({bs:O.bs,be:O.be,ls:ze,le:ze+K.length,rs:Ee,re:Ee+fe.length,ms:0,me:0,base:e.slice(O.bs,O.be),local:K,remote:fe,resolved:ae}),B.push({bs:O.bs,be:O.be,toks:ae,source:"conflict",localHunks:O.localHunks,localToks:K,keepsLocal:r!=="remote"})}else B.push({bs:O.bs,be:O.be,toks:O.u.toks,source:O.kind==="R"?"remote":"local",localHunks:O.kind==="R"?[]:[O.u.l]});Ce=Math.max(Ce,O.be)}Me(e.length);let Be=0,me=0;for(let O of B)O.source==="conflict"&&(z[me].ms=Be,z[me].me=Be+O.toks.length,me++),Be+=O.toks.length;let Te=new Map(a.map(O=>[O.bi,O.tok])),Xe=new Map(c.map(O=>[O.bi,O.tok])),_e=[];for(let O of B){O.source==="base"&&(O.toks=O.toks.map((K,fe)=>{let ae=O.bs+fe,qe=Te.get(ae),ze=Xe.get(ae),Ee=qe&&ze?r==="remote"?ze:qe:qe||ze||K;return Ee===K?K:{...Ee,cosmetic:!0}}));for(let K of O.toks)_e.push({...K,src:O.source})}return{tokens:_e,segments:B,conflicts:z,localHunks:i,remoteHunks:l,collapsedDelta:k,samePoint:S,mapLocalOffset:hh(e,i,B)}}function Hi(e,t,n,r){let o=[],s=n;for(let i of t)o=o.concat(e.slice(s,i.bs),i.toks),s=i.be;return o.concat(e.slice(s,r))}var $i=e=>e.reduce((t,n)=>t+n.len,0);function hh(e,t,n){let r=new Int32Array(e.length+1);for(let i=0;i<e.length;i++)r[i+1]=r[i]+e[i].len;let o=t.map(i=>({bs:r[i.bs],be:r[i.be],text:i.toks.map(l=>l.raw).join(""),ref:i})),s=n.map(i=>({bs:r[i.bs],be:r[i.be],len:$i(i.toks),source:i.source,localHunks:i.localHunks||[],localLen:i.localToks?$i(i.localToks):0,keepsLocal:i.keepsLocal,ref:i}));return i=>{let l=null,a=null,c=0,m=0,u=0;for(let p of o){let h=p.bs-u;if(i<=m+h){l=u+(i-m);break}if(m+=h,u=p.bs,i<=m+p.text.length){a=p,c=i-m,l=p.bs;break}m+=p.text.length,u=p.be}l===null&&(l=u+(i-m));let f=0;for(let p of s){if(!a&&l<=p.bs)return f;if(!(a?p.localHunks.includes(a.ref):l<p.be)){f+=p.len;continue}if(p.source==="base")return f+(l-p.bs);if(p.source==="remote")return f+p.len;if(p.source==="local")return f+Math.min(c,p.len);if(!p.keepsLocal||!a)return f+p.len;let v=p.localHunks.indexOf(a.ref),g=$i(Hi(e,p.localHunks.slice(0,v),p.ref.bs,a.ref.bs));return f+Math.min(g+c,p.localLen)}return f}}function Po(e,t,n,r="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:d=>Math.min(d,t.length),granularity:"word"};let o=xn(e,t,n),s=un(e,o),i=un(t,o),l=un(n,o),a=s.length<=2e4&&i.length<=2e4&&l.length<=2e4?Ia(s,i,l,r):null,c="word",m=s;if(!a){let d=k=>k.split(/(?<=\n)/).map(S=>({k:S,raw:S,len:S.length}));m=d(e),a=Ia(m,d(t),d(n),r),c="line"}let u=d=>d.map(k=>k.raw).join(""),f=d=>{let k=[0];for(let S of d)k.push(k[k.length-1]+S.len);return k},p=f(m),h=null,v=null,g=null;if(a.conflicts.length){let d=k=>k.split(/(?<=\n)/).map(S=>({k:S,raw:S,len:S.length}));h=f(c==="line"?d(t):i),v=f(c==="line"?d(n):l),g=f(a.tokens)}return{text:u(a.tokens),conflicts:a.conflicts.map(d=>({bs:p[d.bs],be:p[d.be],ls:h[d.ls],le:h[d.le],rs:v[d.rs],re:v[d.re],ms:g[d.ms],me:g[d.me],base:u(d.base),local:u(d.local),remote:u(d.remote),resolved:u(d.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:c}}function Ar(e,t,n=4e3){if(e===t)return[];let r=xn(e,t),o=un(e,r),s=un(t,r),i=Xn(o,s,n),l=[0];for(let a of o)l.push(l[l.length-1]+a.len);return i.hunks.map(a=>({bs:l[a.bs],be:l[a.be],text:a.toks.map(c=>c.raw).join("")}))}function Gt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Hn({base:e,side:t,retained:n,transfers:r,baseAtomKey:o=l=>l.el,sideAtomKey:s=l=>l.el,budget:i=Gt()}){let l=[],a=w=>({status:"fallback",reason:w}),c=w=>w>i.remaining?!1:(i.remaining-=w,!0);if(!c((n.length+r.length)*3))return a("work-limit");for(let[w,T]of[["retained",n],["transfer",r]])for(let N of T){let{from:C,to:L,target:q}=N;if(!Number.isInteger(C)||!Number.isInteger(L)||!Number.isInteger(q)||C<0||L<=C||L>e.text.length||q<0||q+L-C>t.text.length)return a("invalid-range");l.push({...N,kind:w})}let m=Symbol(),u=w=>(T,N)=>{if(!c(1))throw m;return i.sortComparisons++,w(T,N)},f,p;try{f=l.slice().sort(u((w,T)=>w.from-T.from||w.to-T.to)),p=l.slice().sort(u((w,T)=>w.target-T.target||w.to-w.from-(T.to-T.from)))}catch(w){if(w===m)return a("work-limit");throw w}if(!c(l.length*2))return a("work-limit");for(let w=1;w<f.length;w++)if(f[w].from<f[w-1].to)return a("source-overlap");for(let w=1;w<p.length;w++)if(p[w].target<p[w-1].target+p[w-1].to-p[w-1].from)return a("target-overlap");for(let w of f){let T=w.to-w.from;if(!c(T))return a("work-limit");for(let N=0;N<T;N++){let C=w.from+N,L=w.target+N;if(i.comparisons++,e.text[C]!==t.text[L])return a("unequal-occurrence");let q=e.atomAt.get(C),V=t.atomAt.get(L);if(!!q!=!!V||q&&o(q)!==s(V))return a("different-atom")}}let h=e.text.length+t.text.length+2,v=l.reduce((w,T)=>w+(T.to-T.from)*2,2);if(!c(h+v+l.length))return a("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),d=new Int32Array(t.text.length+1).fill(-1);i.mapCells+=h,i.mapWrites+=v;let k=-1,S=!0;for(let w of f){w.target<k&&(S=!1),k=w.target+w.to-w.from;for(let T=0;T<w.to-w.from;T++)g[w.from+T]=w.target+T,d[w.target+T]=w.from+T}return g[e.text.length]=t.text.length,d[t.text.length]=e.text.length,{status:"ready",runs:f,bTo:g,toB:d,monotone:S,covers:(w,T)=>{if(!c(T-w))return null;i.coverageChecks+=T-w;for(let N=w;N<T;N++)if(e.text[N]!==Ot&&!/\s/.test(e.text[N])&&g[N]<0)return!1;return!0}}}function Wi({base:e,side:t,baseOf:n=()=>null,budget:r=Gt()}){if(e.text===t.text||!e.text.includes(Ot)&&!t.text.includes(Ot))return{status:"none"};let o=(e.text.length+t.text.length)*8;if(o>r.remaining)return{status:"fallback",reason:"work-limit"};r.remaining-=o,r.boundarySteps=(r.boundarySteps||0)+o;let s=(h,v)=>v<h.length&&(h[v]===Ot||/\s/.test(h[v])),i=new Map,l=Symbol(),a=(h,v)=>{let g=h.stackAt[v]||[];if(!i.has(g)){if(g.length>r.remaining)throw l;r.remaining-=g.length,r.boundarySteps+=g.length,i.set(g,g.find(d=>d.block)?.el||null)}return i.get(g)},c=[],m=(h,v)=>{let g=a(e,h),d=a(t,v),k=g&&d&&n(d)!==g?"transfer":"retained",S=c[c.length-1];S&&S.to===h&&S.target+S.to-S.from===v&&S.kind===k&&S.destination===d?S.to++:c.push({from:h,to:h+1,target:v,destination:d,kind:k})},u=0,f=0,p=!1;try{for(;u<e.text.length||f<t.text.length;){if(u<e.text.length&&f<t.text.length&&e.text[u]===t.text[f]){let S=e.atomAt.get(u),x=t.atomAt.get(f);if(!!S!=!!x||S&&n(x.el)!==S.el)return{status:"none"};m(u++,f++);continue}if(!s(e.text,u)&&!s(t.text,f))return{status:"none"};let h=u,v=f;for(;s(e.text,u);)u++;for(;s(t.text,f);)f++;let g=e.text.slice(h,u),d=t.text.slice(v,f);(g.includes(Ot)||d.includes(Ot))&&(p=!0);let k=0;for(;k<u-h&&k<f-v&&e.text[u-k-1]===t.text[f-k-1];)k++;for(let S=k;S>0;S--)m(u-S,f-S)}}catch(h){if(h===l)return{status:"fallback",reason:"work-limit"};throw h}return p?Hn({base:e,side:t,retained:c.filter(h=>h.kind==="retained"),transfers:c.filter(h=>h.kind==="transfer"),sideAtomKey:h=>n(h.el)||h.el,budget:r}):{status:"none"}}var La=/\s/,ys=/\S/;function Rn(e,t,n,r,o,s,i=-1,l=-1){if(!e.length)return-1;o(r,e.length);let a=new Int32Array(e.length),c=0;for(let p=1;p<e.length;p++){for(o(r,1);c&&(o(r,1),e[c]!==e[p]);)c=a[c-1];o(r,1),e[c]===e[p]&&c++,a[p]=c}let m=-1,u=0,f=0;c=0;for(let p=0;p<t.length;p++){for(o(r,1);c&&(o(r,1),e[c]!==t[p]);)c=a[c-1];if(o(r,1),e[c]===t[p]&&c++,c!==e.length)continue;let h=p+1-e.length,v=p+1;for(c=a[c-1];u<n.length&&n[u].from<h;)o(r,1),u++;for(;f<n.length&&n[f].to<v;)o(r,1),f++;if(o(r,6),!(u===n.length||f===n.length||n[u].from!==h||n[f].to!==v||i>=0&&h<l&&v>i)){if(!s)return h;if(m>=0)return-1;m=h}}return m}function jo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function Ki(e,t,n,r){let o=null;for(let i of t)if(r(n,1),!(i.source!==e.source||i.side!==e.side))for(let l of i.runs){if(r(n,1),l.source!==e.source)continue;let a=Math.max(e.from,l.from),c=Math.min(e.to,l.to);a>=c||(o||(r(n,e.to-e.from),o=new Uint8Array(e.to-e.from)),r(n,c-a),o.fill(1,a-e.from,c-e.from))}if(!o)return!1;r(n,e.to-e.from);let s=!1;for(let i=e.from;i<e.to;i++)if(ys.test(e.flat.text[i])){if(!o[i-e.from])return!1;s=!0}return s}function Gi({source:e,side:t,views:n,eligible:r,blocked:o,baseId:s,model:i,tokensOf:l,budget:a,charge:c}){let{V:m,A:u,idOf:f}=n[t],p=n[1-t];if(e.nodeType!==1||u.identical.has(e)||p.A.identical.has(e)||o.has(e)||!r(e))return null;let h=m.twin(e),v=p.V.twin(e);if(!h||!v||u.map.get(e)!==h||u.reverse.get(h)!==e||p.A.map.get(e)!==v||p.A.reverse.get(v)!==e||!m.here(h)||!p.V.here(v)||!r(h)||!r(v))return null;let g=s(e);if(g!==f(h)||g!==p.idOf(v))return null;let d=i(e,null,a),k=i(h,u,a),S=i(v,p.A,a);if(!jo(d)||!jo(k)||!jo(S))return null;let x=d.flat.text,w=k.flat.text;if(c(a,x.length+w.length*3),!ys.test(w)||w.length>=x.length)return null;let T=x.startsWith(w),N=x.endsWith(w);if(T===N)return null;let C=T?w.length:0,L=T?x.length:x.length-w.length,q=C,V=L;for(;q<V&&(c(a,1),!!La.test(x[q]));)q++;for(;V>q&&(c(a,1),!!La.test(x[V-1]));)V--;if(q===V)return null;let U=l(d,a),F=!1,A=!1;for(let E of U)c(a,1),E.from===q&&(F=!0),E.to===V&&(A=!0);return!F||!A?null:{source:e,side:t,flat:d.flat,from:C,to:L}}function Pa({base:e,views:t,side:n,attempt:r,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,certificates:c,charge:m,exhausted:u,limit:f}){if(f<=0)return null;let p=Gt(f),{V:h,A:v,idOf:g}=t[n],d=t[1-n],[k,S,x,w]=r,T=null;try{for(let N=k;N<=S;N++){m(p,1);let C=e[N];if(C.nodeType!==1||v.identical.has(C)||d.A.identical.has(C)||s.has(C)||!o(C))continue;let L=Gi({source:C,side:n,views:t,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,budget:p,charge:m});if(!L||Ki(L,c,p,m))continue;let{flat:q,from:V,to:U}=L;m(p,(U-V)*2);let F=q.text.slice(V,U).trim();for(let A=x;A<=w;A++){m(p,1);let E=h.units[A],X=h.baseOf(E);if(!X||X===C||X.nodeType!==1||E.nodeType!==1||X.parentNode!==C.parentNode||E.parentNode!==v.map.get(C).parentNode||v.map.get(X)!==E||v.reverse.get(E)!==X||s.has(X)||!o(X)||!o(E)||i(X)!==g(E))continue;let B=l(X,null,p),z=l(E,v,p);if(!jo(B)||!jo(z))continue;let Ce=B.flat.text,Me=z.flat.text;if(m(p,Ce.length),!ys.test(Ce)||Me.length<=Ce.length)continue;let Be=a(z,p),me=Rn(Ce,Me,Be,p,m,!0);if(!(me<0)&&!(Rn(F,Me,Be,p,m,!1,me,me+Ce.length)<0)){(T||=[]).push(L);break}}}}catch(N){if(N!==u)throw N}return T}function ja(e,t,n,r,o,s,i){if(s==="both"||n.atoms.length||r.atoms.length||o.atoms.length)return s;let l=s==="remote";if(l?i.rss!==i.rse||i.lss===i.lse||i.local===i.base:i.lss!==i.lse||i.rss===i.rse||i.remote===i.base)return s;for(let a of e){if(a.source!==t||a.side!==(l?1:0)||a.flat.text!==n.text||a.flat.nodes.length!==n.nodes.length||i.be<=a.from||i.bs>=a.to)continue;let c=!0;for(let u=0;u<n.nodes.length;u++){let f=a.flat.nodes[u],p=n.nodes[u];if(f.node!==p.node||f.s!==p.s||f.e!==p.e){c=!1;break}}if(!c)continue;let m=!1;for(let u=i.bs;u<i.be;u++)if(ys.test(n.text[u])){if(u<a.from||u>=a.to){c=!1;break}m=!0}if(c&&m)return l?"local":"remote"}return s}var zn="\uFFFC";var mh={caret:0},wn=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),za=new Set(["BR","WBR","IMG"]),Yi=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function Vn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||za.has(e.tagName))return!0;if(!wn.has(e.tagName))return!Yi.has(e.tagName);if(t.remoteWins&&t.remoteWins(e))return!1;let n=t.inlineCache&&t.inlineCache.get(e);if(n!==void 0)return n;let r=!0;for(let o of e.childNodes)if(!Vn(o,t)){r=!1;break}return t.inlineCache&&t.inlineCache.set(e,r),r}function ph(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function Qt(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},r=(o,s)=>{for(let i of o){if(i.nodeType===3){let u=i.nodeValue;if(!u)continue;n.nodes.push({node:i,s:n.text.length,e:n.text.length+u.length}),n.text+=u;for(let f=0;f<u.length;f++)n.stackAt.push(s);continue}if(i.nodeType!==1)continue;if(t.ignored&&t.ignored(i)){n.pins.push({el:i,i:n.text.length});continue}if(t.skip&&t.skip.has(i))continue;let l=t.via&&t.via(i)||i;l!==i&&(n.via||(n.via=new Map)).set(l,i);let a=i.tagName;if(t.blocks&&t.blocks.has(i)){n.text.length&&n.text[n.text.length-1]!==Ot&&(n.stackAt.push(s),n.text+=Ot);let u={el:i,tag:a,from:n.text.length,to:-1,depth:s.length,block:!0};n.marks.push(u);let f=s.concat([u]);r(l.childNodes,f),n.stackAt.push(f),n.text+=Ot,u.to=n.text.length;continue}let c=wn.has(a)&&ph(l);if(za.has(a)||!wn.has(a)||t.remoteWins&&t.remoteWins(i)||t.atomize&&t.atomize(i)||c){n.atoms.push({i:n.text.length,el:i,key:c?a+":empty":a,stack:s}),n.stackAt.push(s),n.text+=zn;continue}let m={el:i,tag:a,from:n.text.length,to:-1,depth:s.length};n.marks.push(m),r(l.childNodes,s.concat([m])),m.to=n.text.length}};if(r(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&ws(n).trim()===""){let o=n.atoms[0];n.placeholder=o.el,n.text=n.text.slice(0,o.i)+n.text.slice(o.i+1),n.stackAt.splice(o.i,1);for(let s of n.nodes)s.s>o.i&&(s.s--,s.e--);n.atoms=[]}return n.atomAt=new Map(n.atoms.map(o=>[o.i,o])),n}function gh(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function bh(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,"&quot;")}"`;return t+">"}function Kr(e,t,n){let r="",o=[];for(let s=t;s<n;s++){let i=e.stackAt[s],l=0;for(;l<o.length&&l<i.length&&o[l]===i[l];)l++;for(;o.length>l;)r+=`</${o.pop().tag.toLowerCase()}>`;for(;o.length<i.length;){let c=i[o.length];r+=bh(c.el),o.push(c)}let a=e.atomAt.get(s);r+=a?a.el.outerHTML:e.text[s]===Ot?"":gh(e.text[s])}for(;o.length;)r+=`</${o.pop().tag.toLowerCase()}>`;return r}function kh(e,t){let n=[...e.el.attributes].filter(r=>!t(e.el,r.name)).map(r=>r.name+"="+r.value).sort().join("");return e.tag+"|"+n}function Va(e,t){let n=[...e.attributes].filter(r=>!t(e,r.name)).map(r=>r.name+"="+r.value).sort().join("");return e.tagName+"|"+n+"|"+e.innerHTML}function qa(e,t=()=>!1){let n=new Map,r=s=>{let i=n.get(s);return i===void 0&&(i="{"+s.map(l=>kh(l,t)).sort().join(",")+"}",n.set(s,i)),i},o="";for(let s=0;s<e.text.length;s++){let i=e.atomAt.get(s);o+=(i?"["+Va(i.el,t)+"]":e.text[s])+r(e.stackAt[s])}return e.text.length===0&&e.placeholder&&(o+="[br]"),o}function Wr(e,t,n,r=o=>o.key){let o=[],s=e.text,i=0,l=a=>{if(a<=i)return;let c=s.slice(i,a);if(n)for(let m of c.split(/(?<=\n)/))o.push({k:m,raw:m,len:m.length});else for(let m of un(c,t))o.push(m)};for(let a of e.atoms)l(a.i),o.push({k:"\0"+r(a),raw:zn,len:1,atom:!0}),i=a.i+1;return l(s.length),o}function ws(e){if(!e.atoms.length)return e.text;let t="",n=0;for(let r of e.atoms)t+=e.text.slice(n,r.i),n=r.i+1;return t+e.text.slice(n)}var Gr=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n].len;return t};function vs(e,t,n,r){let o=Gr(t),s=Gr(n),i=[],l=0,a=0;for(let m of r.hunks){a+=m.bs-l;let u=a+m.toks.length;i.push({bs:o[m.bs],be:o[m.be],ss:s[a],se:s[u],text:e.text.slice(s[a],s[u]),toks:m.toks,lead:!!m.lead}),a=u,l=m.be}let c=new Map;for(let m of r.cosmetic)c.set(m.bi,m.tok.raw);return{hunks:i,respell:c}}function Da(e,t,n){let r=i=>i===Ot||/\s/.test(i),o=i=>i.replace(/[\u001E\s]/g,""),s=[];for(let i of e){let l=t.slice(i.bs,i.be),a=n.slice(i.ss,i.se);if(!l.includes(Ot)&&!a.includes(Ot)||l.includes(zn)||a.includes(zn)||o(l)!==o(a)){s.push(i);continue}let c=0,m=0;for(;;){let u=c,f=m;for(;u<l.length&&r(l[u]);)u++;for(;f<a.length&&r(a[f]);)f++;let p=c,h=m;for(;p<u&&h<f&&l[p]===a[h];)p++,h++;let v=u,g=f;for(;v>p&&g>h&&l[v-1]===a[g-1];)v--,g--;if(v>p||g>h){let d=a.slice(h,g);s.push({bs:i.bs+p,be:i.bs+v,ss:i.ss+h,se:i.ss+g,text:d,toks:[...d].map(k=>({k,raw:k,len:1})),lead:i.lead})}if(u>=l.length)break;c=u+1,m=f+1}}return s}function Fa(e,t,n){let r=new Int32Array(t+1).fill(-1),o=new Int32Array(n+1).fill(-1),s=0,i=0,l=a=>{for(;s<a;)r[s]=i,o[i]=s,s++,i++};for(let a of e)l(a.bs),s=a.be,i=a.se;return l(t),r[t]=i,o[i]=t,{bTo:r,toB:o}}function Ba(e,t,n){let r=[],o=0,s=0,i=(l,a)=>{if(o===l&&s===a)return;let c=t.text.slice(s,a);r.push({bs:o,be:l,ss:s,se:a,text:c,toks:un(c,xn(c)),lead:!1})};for(let l of n.runs)i(l.from,l.target),o=l.to,s=l.target+l.to-l.from;return i(e.text.length,t.text.length),{hunks:r,respell:new Map}}function $a(e,t,n,r){let o=Gr(t),s=Gr(n),i=(a,c)=>{let m=0,u=a.length;for(;m<u;){let f=m+u>>>1;a[f]<c?m=f+1:u=f}return a[m]===c?m:-1};for(let a of e.hunks)if(i(o,a.bs)<0||i(o,a.be)<0)return null;if(e.hunks.some(a=>i(s,a.ss)<0||i(s,a.se)<0)){if(!r)return null;let a=[];for(let f of e.hunks)a.push(f.ss,f.se);let c=[],m=0,u=0;for(let f of n){let p=u+f.len;for(;m<a.length&&a[m]<=u;)m++;let h=u;for(;m<a.length&&a[m]<p;){let v=a[m++];if(v>h){let g=f.raw.slice(h-u,v-u);c.push(...un(g,xn(g))),h=v}}if(h===u)c.push(f);else{let v=f.raw.slice(h-u);c.push(...un(v,xn(v)))}u=p}n=c,s=Gr(n)}let l=[];for(let a of e.hunks){let c=i(o,a.bs),m=i(o,a.be),u=i(s,a.ss),f=i(s,a.se);if(c<0||m<0||u<0||f<0)return null;l.push({bs:c,be:m,toks:n.slice(u,f),gap:[],group:l.length})}return{parts:l,cosmeticEq:[],tokens:n}}function Xi(e,t,n,r={},o=null){return Wa(e,t,n,r.base,r.local,r.remote,o,{})}function Wa(e,t,n,r,o,s,i,l){let a=xn(ws(e),ws(t),ws(n)),c=Wr(e,a,!1,r),m=Wr(t,a,!1,o),u=Wr(n,a,!1,s),f=c.length>2e4||m.length>2e4||u.length>2e4;f&&(c=Wr(e,a,!0,r),m=Wr(t,a,!0,o),u=Wr(n,a,!0,s));let p=i?.local?Ba(e,t,i.local):null,h=i?.remote?Ba(e,n,i.remote):null,v=p?$a(p,c,m,!f):Xn(c,m),g=h?$a(h,c,u,!f):Xn(c,u);p&&v&&(m=v.tokens),h&&g&&(u=g.tokens);let d,k;if(v&&g){let S=zi(v,g,c);d=vs(t,c,m,{hunks:S.lh,cosmetic:S.cosL}),k=vs(n,c,u,{hunks:S.rh,cosmetic:S.cosR})}else d=p||vs(t,c,m,v),k=h||vs(n,c,u,g);return d.hunks=Da(d.hunks,e.text,t.text),k.hunks=Da(k.hunks,e.text,n.text),l.base=e,l.local=t,l.remote=n,l.lines=f,l.baseTokens=c,l.localEdits=d,l.remoteEdits=k,l.localMap=Fa(d.hunks,e.text.length,t.text.length),l.remoteMap=Fa(k.hunks,e.text.length,n.text.length),l.full=null,l}function Ua(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Yr=/\s/;function xs(e,t,n){for(let r=t;r<n;r++)if(!Yr.test(e[r]))return!1;return!0}function yh(e,t,n){let r=e.cache[n]||(e.cache[n]=new Map);if(r.has(t))return r.get(t);let o=n===0?"local":"remote",s=n===0?"remote":"local",i=t.baseMark,l=t[s+"Mark"],a=!t.block&&!t[o]&&!!l&&i.to>i.from;if(a){let c=n===0?e.ML:e.MR,m=n===0?e.MR:e.ML,u=n===0?e.fr:e.fl,f=!1;for(let p=i.from;p<i.to;p++){if(c.bTo[p]>=0){a=!1;break}m.bTo[p]<0&&!Yr.test(e.fb.text[p])&&(f=!0)}if(a&&!f){for(let p=l.from;p<l.to;p++)if(m.toB[p]<0&&!Yr.test(u.text[p])){f=!0;break}}a&&=f}return r.set(t,a),a}function Ha(e,t,n,r,o,s,i,l,a){let c=l===0?e.fl:e.fr,m=null;for(let u=n;u<r;u++){let f=t[u];if(!xs(c.text,f.ss,f.se))return null;if(xs(e.fb.text,f.bs,f.be)){if(f.bs<f.be&&f.ss<f.se||Yr.test(e.fb.text[f.bs-1]||"")||Yr.test(e.fb.text[f.be]||""))continue;return null}let p=!1;for(let h=f.bs;h<f.be;h++){if(Yr.test(e.fb.text[h]))continue;let v=null;for(let g of e.fb.stackAt[h]){let d=e.byEl.get(g.el);if(d&&yh(e,d,l)){v=d;break}}if(!v)return null;(m||(m=new Set)).add(v),p=!0}if(!p)return null}if(!m){if((l===0?"local":"remote")!==a)return null;let u=l===0?e.fr:e.fl,f=!1;for(let p=s;p<i;p++){let h=o[p];if(!xs(e.fb.text,h.bs,h.be))return null;xs(u.text,h.ss,h.se)||(f=!0)}if(!f)return null}return m||0}function Ss(e){let{out:t,policy:n="remote",L:r,R:o}=e,s=e.provenance||new WeakMap,i=e.textMappers||new WeakMap,l=e.conflicts||[],a=e.decisions||[],c=l.length,m=e.conflict||(b=>l.push(b)),u={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},f=[],p=!!(r&&r.reverse&&r.map&&o&&o.reverse&&o.map),h={base:null,local:null,remote:null};if(!e.prepared&&p&&e.moveIn){let b=ye=>Le=>ye.some(pe=>pe===Le||pe.nodeType===1&&pe.contains(Le)),_=b(e.local),I=b(e.remote),j=b(e.base),G=new Set,oe=ye=>{if(!wn.has(ye.tagName))return;let Le=r.map.get(ye),pe=o.map.get(ye);(Le&&!_(Le)||pe&&!I(pe))&&G.add(ye);for(let Ie of ye.children)oe(Ie)};for(let ye of e.base)ye.nodeType===1&&oe(ye);let be=ye=>Le=>{if(!wn.has(Le.tagName))return!1;let pe=ye.reverse.get(Le);return!!pe&&(G.has(pe)||!j(pe))};G.size&&(h.base=ye=>G.has(ye)),h.local=be(r),h.remote=be(o)}let v={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&p&&e.moveIn){let b=j=>G=>j.some(oe=>oe===G||oe.nodeType===1&&oe.contains(G)),_=b(e.local),I=b(e.remote);for(let j of Qt(e.base,{...e,atomize:h.base}).atoms){let G=r.map.get(j.el),oe=o.map.get(j.el),be=!!G&&!_(G),ye=!!oe&&!I(oe);!be&&!ye||(be&&e.movePlanned?.(j.el,"local",G,null),ye&&e.movePlanned?.(j.el,"remote",oe,null),v.base.add(j.el),G&&!be&&v.local.add(G),oe&&!ye&&v.remote.add(oe),_(j.el)&&v.local.add(j.el),I(j.el)&&v.remote.add(j.el))}}let g=e.prepared?.base||Qt(e.base,{...e,atomize:h.base,skip:v.base}),d=e.prepared?.local||Qt(e.local,{...e,atomize:h.local,skip:v.local}),k=e.prepared?.remote||Qt(e.remote,{...e,atomize:h.remote,skip:v.remote}),S=new Map(g.atoms.map(b=>[b.el,b])),x={},w=b=>e.prepared?e.prepared.full?.(b)||null:v[b].size?(x[b]||(x[b]=Qt(e[b],{...e,atomize:h[b]})),x[b]):null,T=(b,_,I)=>{_.namespaceURI?b.setAttributeNS(_.namespaceURI,_.name,I):b.setAttribute(_.name,I)},N=(b,_,I,j)=>{if(!_&&(!I||!j)){for(let oe of(I||j).attributes)T(b,oe,oe.value);return}let G=new Map;for(let oe of[_,I,j])if(oe)for(let be of oe.attributes)G.set(be.name,be);for(let[oe,be]of G){let ye=_?_.getAttribute(oe):null,Le=I?I.getAttribute(oe):ye,pe=j?j.getAttribute(oe):ye,Ie;Le===pe?Ie=Le:Le===ye?(Ie=pe,a.push({kind:"attr",el:b,name:oe,source:"remote"})):pe===ye?(Ie=Le,a.push({kind:"attr",el:b,name:oe,source:"local"})):(Ie=n==="local"?Le:pe,m({kind:"attr",el:b,name:oe,base:ye,local:Le,remote:pe,resolved:Ie},{el:b,sample:be}),a.push({kind:"attr",el:b,name:oe,source:"both"})),Ie!=null&&T(b,be,Ie)}},C=(b,_,I,j)=>b&&e.mergeAttrs?e.mergeAttrs(b,_,I,j):N(j,b,_,I),L=e.mergeElement||((b,_,I)=>{let j=t.createElement(b.tagName);C(b,_,I,j);let G=_||b,oe=I||b,be=n==="local"?G.isEqualNode(b)?oe:G:oe.isEqualNode(b)?G:oe;for(let ye of be.childNodes)j.appendChild(t.importNode(ye,!0));return s.set(j,{base:b,local:_,remote:I}),j}),q=e.cloneUnit||((b,_)=>{let I=t.importNode(b,!0);return s.set(I,{base:null,local:_==="local"?b:null,remote:_==="remote"?b:null}),I}),V=e.atomKey||(b=>Va(b,()=>!1)),U=(b,_)=>{let I=new Map;for(let j of b.atoms)if(e.remoteWins&&e.remoteWins(j.el)&&wn.has(j.el.tagName))I.set(j,"w"+j.el.tagName+"#"+(j.el.id||""));else if(!p)I.set(j,j.key);else if(b===g)I.set(j,"="+V(j.el));else{let G=_.reverse.get(j.el),oe=G?S.get(G):null;oe?I.set(j,"="+V(oe.el)):G?I.set(j,"m"+V(j.el)):I.set(j,"="+V(j.el))}return j=>I.get(j)},F=U(g,null),A=U(d,r),E=U(k,o),X=e.certifiedOrigins?e.certifiedOrigins(g,d,k,F,A,E):null;if(X?.fallback)return null;if(!X&&!e.prepared&&e.blocks){let b=Gt(),_=Wi({base:g,side:d,baseOf:j=>r?.reverse?.get(j)||null,budget:b}),I=Wi({base:g,side:k,baseOf:j=>o?.reverse?.get(j)||null,budget:b});(_.status==="ready"||I.status==="ready")&&(X={local:_.status==="ready"?_:null,remote:I.status==="ready"?I:null})}let B=e.prepared||Wa(g,d,k,F,A,E,X,u),z=B.lines,Ce=B.baseTokens,Me=B.localEdits,Be=B.remoteEdits,me=B.localMap,Te=B.remoteMap,Xe=g.text.length,_e=b=>new Map(b.atoms.map(_=>[_.el,_])),O=_e(d),K=_e(k),fe=(b,_,I)=>{let j=new Set;if(!p)return j;for(let G of b.atoms){let oe=S.get(_.reverse.get(G.el));oe&&I.bTo[oe.i]<0&&j.add(oe)}return j},ae=fe(d,r,me),qe=fe(k,o,Te),ze=b=>!Vn(b,{...e,remoteWins:null}),Ee=new Set;if(p)for(let b of g.atoms){if(!ze(b.el))continue;let _=r.map.get(b.el)||null,I=o.map.get(b.el)||null,j=_&&!I?_:I&&!_?I:null;j&&(O.has(j)||K.has(j))&&!j.isEqualNode(b.el)&&Ee.add(b)}let ot=1,rt=(b,_)=>({id:ot++,tag:b,base:null,local:null,remote:null,rank:_}),xt=new Map,nt=[];for(let b of g.marks){let _=rt(b.tag,b.depth);_.block=!!b.block,_.base=b.el,_.baseMark=b,xt.set(b.el,_),nt.push(_)}let te=(b,_)=>{let I=-1,j=-1;for(let G=b.from;G<b.to;G++){let oe=_[G];oe>=0&&(I<0&&(I=oe),j=oe+1)}return I<0?null:[I,j]},Ae=(b,_,I,j)=>{for(let G of b.marks){let oe=I?I.reverse.get(G.el):null;oe&&I.identical.has(oe)&&I.pairIdenticalChildren&&I.pairIdenticalChildren(oe);let be=oe?xt.get(oe):null;if(be&&be[_]&&(be=null),!be){let ye=te(G,j),Le=0;if(ye)for(let pe of nt){if(pe.tag!==G.tag||pe[_]||!!pe.block!=!!G.block)continue;let Ie=Math.min(ye[1],pe.baseMark.to)-Math.max(ye[0],pe.baseMark.from);(Ie>Le||Ie===Le&&Ie>0&&Math.abs(pe.rank-G.depth)<Math.abs(be.rank-G.depth))&&(be=pe,Le=Ie)}}be||(be=rt(G.tag,G.depth),be.block=!!G.block,be.new=_),be[_]=G.el,be[_+"Mark"]=G,xt.set(G.el,be)}};Ae(d,"local",r,me.toB),Ae(k,"remote",o,Te.toB);let je=b=>b.merged||b,Fe=b=>{let _=new Set;for(let I of b)I.block||_.add(xt.get(I.el));return _},He=new Map,et=b=>{let _=He.get(b);return _||(_=Fe(b),He.set(b,_)),_},bt=(b,_)=>{let I=[],j=null;for(let G=0;G<Xe;G++){let oe=_[G];if(oe<0){j&&I.push(j),j=null;continue}let be=et(g.stackAt[G]),ye=et(b.stackAt[oe]),Le=new Set,pe=new Set;for(let Ie of ye)be.has(Ie)||Le.add(Ie);for(let Ie of be)ye.has(Ie)||pe.add(Ie);if(!Le.size&&!pe.size){j&&I.push(j),j=null;continue}if(j&&Ua(j.added,Le)&&Ua(j.removed,pe)){j.be=G+1;continue}j&&I.push(j),j={bs:G,be:G+1,added:Le,removed:pe}}return j&&I.push(j),I},Ft=bt(d,me.bTo),yt=bt(k,Te.bTo),It=b=>b.be>b.bs?[b.bs,b.be-1]:[b.bs-1,b.bs],en=(b,_)=>{if(Xe===0)return null;let[I,j]=It(b);for(let G of _){if(G.be<=I)continue;if(G.bs>j)break;let oe=G.bs<=I&&j<G.be;return oe&&b.text===""&&G.bs===b.bs&&G.be===b.be?"straddle":oe?G:b.be>b.bs?"straddle":null}return null},Ge=b=>b.bs===b.be,Ct=(b,_,I=null)=>{let j=!1;for(let G=b.bs;G<b.be;G++){let oe=g.text[G];if(oe===Ot)j=!0;else if(!/\s/.test(oe))return!1}for(let G=b.ss;G<b.se;G++){let oe=_.text[G];if(oe===Ot)j=!0;else if(!/\s/.test(oe)){let be=I&&e.scopeUnits&&Ge(b)&&_.atomAt.get(G);if(!be||!ze(be.el)||I.ss!==I.se||I.bs>=I.be)return!1;for(let Le=I.bs;Le<I.be;Le++)if(!/\s/.test(g.text[Le]))return!1;let ye=_===d?1:2;if(!e.scopeUnits[ye].includes(be.el)||(ye===1?r:o)?.reverse.has(be.el))return!1;j=!0}}return j},Tt=(b,_)=>b.bs<_.be&&_.bs<b.be,Jt=(b,_)=>b.bs<=_.be&&_.bs<=b.be&&Ge(b)!==Ge(_),Y=(b,_)=>g.text.slice(b.bs,b.be).includes(Ot)||_.text.slice(b.ss,b.se).includes(Ot),y=b=>{if(Ge(b))return!1;let _=b.bs,I=b.be;for(;_>0&&/\s/.test(g.text[_-1]);)_--;for(;I<g.text.length&&/\s/.test(g.text[I]);)I++;return(_===0||g.text[_-1]===Ot)&&(I===g.text.length||g.text[I]===Ot)},M=(b,_)=>!Y(b,_)&&!y(b),P=(b,_)=>Tt(b,_)||Jt(b,_)&&!(b.transferIn||b.transferOut||_.transferIn||_.transferOut)&&!(Ct(b,d,_)&&M(_,k))&&!(Ct(_,k,b)&&M(b,d)),H=(b,_)=>{if(b.bs!==_.bs||b.be!==_.be||b.toks.length!==_.toks.length)return!1;let I=b.ss,j=_.ss;for(let G=0;G<b.toks.length;G++){let oe=b.toks[G],be=_.toks[G];if(oe.k!==be.k||oe.atom&&!d.atomAt.get(I).el.isEqualNode(k.atomAt.get(j).el))return!1;I+=oe.len,j+=be.len}return!0},Q=(b,_,I,j)=>{for(let G of g.atoms){if(G.i<b.bs||G.i>=b.be||j.has(G)||Ee.has(G))continue;let oe=_.bTo[G.i],be=oe>=0?I.atomAt.get(oe):null;if(be&&!be.el.isEqualNode(G.el))return!0}return!1},D=[],ge=null,xe=null,de=Me.hunks,Oe=Be.hunks,$=0,Z=0,ke=0,we=0,ve=0,ne=b=>{b>ke&&(D.push({src:"base",from:ke,to:b,dL:we,dR:ve}),ke=b)};for(;$<de.length||Z<Oe.length;){let b=de[$],_=Oe[Z],I=!!b&&(!_||b.bs<_.bs||b.bs===_.bs&&b.be<=_.be&&!_.lead);if(b&&_&&b.bs===_.bs&&Ge(b)&&Ge(_)){let zt=Ct(b,d),Ro=Ct(_,k);zt!==Ro&&(I=Ro)}let j=I?b:_,G=I?_:b,oe=!!G&&H(b,_),be=!!G&&(I?!!de[$+1]&&H(de[$+1],_):!!Oe[Z+1]&&H(b,Oe[Z+1])),ye=!!G&&!oe&&!be&&(Xe===0||P(b,_)),Le=ye,pe=en(j,I?yt:Ft);if(pe==="straddle"&&(Le=!0),!Le&&j.be>j.bs&&(Le=Q(j,I?Te:me,I?k:d,I?ae:qe)),!Le&&oe){ne(j.bs),D.push({src:"both",lfrom:b.ss,rfrom:_.ss,len:j.text.length,owner:b.owner||_.owner||null,transfer:b.transferIn||_.transferIn||null}),ke=j.be,we+=j.text.length-(j.be-j.bs),ve+=j.text.length-(j.be-j.bs),$++,Z++;continue}if(!Le){ne(j.bs),D.push({src:I?"local":"remote",from:j.ss,to:j.se,inherit:pe&&pe!=="straddle"?pe:null,owner:j.owner||null,transfer:j.transferIn||null}),ke=j.be,I?(we+=j.text.length-(j.be-j.bs),$++):(ve+=j.text.length-(j.be-j.bs),Z++);continue}let Ie=j.bs,st=j.be,ct=$,gt=Z,$t=zt=>zt.bs<st&&zt.be>Ie||Ge(zt)&&(zt.bs===Ie||zt.bs===st);I?ct++:gt++,ye&&(Ie=Math.min(Ie,G.bs),st=Math.max(st,G.be),I?gt++:ct++);let Dt=!0;for(;Dt;){for(Dt=!1;ct<de.length&&$t(de[ct]);)Ie=Math.min(Ie,de[ct].bs),st=Math.max(st,de[ct].be),ct++,Dt=!0;for(;gt<Oe.length&&$t(Oe[gt]);)Ie=Math.min(Ie,Oe[gt].bs),st=Math.max(st,Oe[gt].be),gt++,Dt=!0}let pn=Ie+we,cn=Ie+ve,yn=st-Ie,An=st-Ie;for(let zt=$;zt<ct;zt++)yn+=de[zt].text.length-(de[zt].be-de[zt].bs);for(let zt=Z;zt<gt;zt++)An+=Oe[zt].text.length-(Oe[zt].be-Oe[zt].bs);let $n=pn+yn,Un=cn+An;if(ne(Ie),$<ct&&Z<gt&&!X&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!d.atoms.length&&!k.atoms.length&&!g.pins.length&&!d.pins.length&&!k.pins.length){ge||={fb:g,fl:d,fr:k,ML:me,MR:Te,byEl:xt,cache:[null,null]};let zt=Ha(ge,de,$,ct,Oe,Z,gt,0,n),Ro=Ha(ge,Oe,Z,gt,de,$,ct,1,n);if(zt===null!=(Ro===null)){let Ei=zt!==null,wa=Ei?zt:Ro;if(wa){xe||=new Map;for(let qd of wa)xe.set(qd,Ei?"local":"remote")}D.push(Ei?{src:"remote",from:cn,to:Un}:{src:"local",from:pn,to:$n}),ke=st,we+=yn-(st-Ie),ve+=An-(st-Ie),$=ct,Z=gt;continue}}let Yt={kind:"text",node:e.node||null,base:Kr(g,Ie,st),local:Kr(d,pn,$n),remote:Kr(k,cn,Un),resolved:null,range:null,bs:Ie,be:st,lss:pn,lse:$n,rss:cn,rse:Un},wr=e.sourceRetentions?ja(e.sourceRetentions,e.scope?.base,g,d,k,n,Yt):n;Yt.resolved=wr==="local"?Yt.local:wr==="remote"?Yt.remote:Yt.local+Yt.remote,wr!=="remote"&&D.push({src:"local",from:pn,to:$n,conflict:Yt}),wr!=="local"&&D.push({src:"remote",from:cn,to:Un,conflict:Yt});let Sr={site:"inline",policy:wr,fb:g,fl:d,fr:k,scope:e.scope||null,synthetic:!!e.synthetic,full:w,merged:u};f.push(Sr),m(Yt,Sr),ke=st,we+=yn-(st-Ie),ve+=An-(st-Ie),$=ct,Z=gt}ne(Xe);let se=g.text,W=[];if(Me.respell.size||Be.respell.size){let b=Gr(Ce),_=[];for(let I=0;I<Ce.length;I++){let j=Ce[I].raw,G=Me.respell.get(I)??j,oe=Be.respell.get(I)??j;(G!==j||oe!==j)&&W.push([b[I],G!==j&&oe!==j?"both":G!==j?"local":"remote"]),_.push(G===oe?G:G===j?oe:oe===j||n==="local"?G:oe)}se=_.join("")}let ce="",Ne=[],Pe=[],De=[],Se=[];for(let b of D){let _=ce.length;if(b.src==="base"){for(let I=b.from;I<b.to;I++)Ne.push(I),Pe.push(e.nativeTransfers?me.bTo[I]:I+b.dL),De.push(e.nativeTransfers?Te.bTo[I]:I+b.dR),Se.push(b);ce+=se.slice(b.from,b.to)}else if(b.src==="both"){for(let I=0;I<b.len;I++){let j=b.transfer&&(b.transfer.side==="remote"?b.rfrom+I:b.lfrom+I);Ne.push(b.transfer&&j>=b.transfer.ss&&j<b.transfer.se?b.transfer.bs+j-b.transfer.ss:-1),Pe.push(b.lfrom+I),De.push(b.rfrom+I),Se.push(b)}ce+=d.text.slice(b.lfrom,b.lfrom+b.len)}else{let I=b.src==="local"?d:k,j=b.transfer&&e.nativeTransfers.byOrigin[b.src==="local"?"remote":"local"].get(b.transfer.key);for(let G=b.from;G<b.to;G++){let oe=b.transfer&&G>=b.transfer.ss&&G<b.transfer.se?b.transfer.bs+G-b.transfer.ss:-1,be=oe>=0&&(!j||j.destination===b.owner)?(b.src==="local"?Te:me).bTo[oe]:-1;Ne.push(oe),Pe.push(b.src==="local"?G:be),De.push(b.src==="remote"?G:be),Se.push(b)}ce+=I.text.slice(b.from,b.to)}b.ms=_,b.me=ce.length,b.conflict&&(b.conflict.range||(b.conflict.range=[_,_]),b.conflict.range[1]=ce.length)}let tt=ce.length,lt=new Int32Array(Xe+1).fill(-1),it=new Int32Array(d.text.length+1).fill(-1),Ht=new Int32Array(k.text.length+1).fill(-1);for(let b=0;b<tt;b++)Ne[b]>=0&&(lt[Ne[b]]=b),Pe[b]>=0&&(it[Pe[b]]=b),De[b]>=0&&(Ht[De[b]]=b);let Lt=(b,_)=>{let I=-1,j=-1;for(let G=b.from;G<b.to;G++){let oe=_[G];oe>=0&&(I<0&&(I=oe),j=oe+1)}return I<0?null:[I,j]},Zt=[],Bt=[];for(let b of new Set(xt.values()))b.new==="local"?Zt.push(b):b.new==="remote"&&Bt.push(b);let Wt=(b,_)=>{b.remote=_.remote,b.remoteMark=_.remoteMark,b.new="both",_.merged=b,xt.set(_.remote,b)};if(Zt.length&&Bt.length){let b=e.idOf;for(let _ of Zt){let I=b?b.local(_.local):null;if(!I)continue;let j=Bt.find(G=>!G.merged&&G.tag===_.tag&&!!G.block==!!_.block&&b.remote(G.remote)===I);j&&Wt(_,j)}for(let _ of Zt){if(_.remote)continue;let I=Lt(_.localMark,it);if(I)for(let j of Bt){if(j.merged||j.tag!==_.tag||!!j.block!=!!_.block)continue;let G=Lt(j.remoteMark,Ht);if(G&&Math.min(I[1],G[1])-Math.max(I[0],G[0])>0){Wt(_,j);break}}}}He.clear();let R=b=>{for(let _ of b)if(_.block)return je(xt.get(_.el));return null},J=g.marks.some(b=>b.block)||d.marks.some(b=>b.block)||k.marks.some(b=>b.block),ue=new Array(tt).fill(null),he=new Set;if(e.nativeTransfers)for(let b=0;b<tt;b++){let _=Se[b].owner;ue[b]=_?je(xt.get(_)):Ne[b]>=0?R(g.stackAt[Ne[b]]):null}else if(J){let b=(pe,Ie,st)=>{let ct=new Set([pe,Ie,st]);ct.delete(null);let gt=[];for(let Dt of ct){let pn=Dt===pe,cn=Dt===Ie,yn=Dt===st;(cn===yn?cn:cn===pn?yn:cn)&&gt.push(Dt)}if(gt.length<=1)return gt[0]||null;let $t=n==="local"?Ie:st;return gt.includes($t)?$t:gt[0]},_=(pe,Ie)=>Ie>=0?R(pe.stackAt[Ie]):null,I=new Map;for(let pe=0;pe<tt;pe++){if(ce[pe]!==Ot)continue;let Ie=Ne[pe]>=0?_(g,Ne[pe]):null,st=_(d,Pe[pe]),ct=_(k,De[pe]);I.set(pe,[Ie,Ne[pe]>=0?b(Ie,st,ct):st||ct])}let j=new Set([...I.values()].map(pe=>pe[1])),G=pe=>pe!==Ot&&pe!==zn&&!/\s/.test(pe),oe=(pe,Ie)=>{let st=pe;for(;st<Ie&&!G(ce[st]);)st++;return st<Ie&&Ne[st]>=0?_(g,Ne[st]):null},be=new Map,ye=0;for(let pe=0;pe<tt;pe++){if(ce[pe]!==Ot)continue;let[Ie,st]=I.get(pe),ct=oe(ye,pe),gt=st,$t=be.get(gt)===gt&&ct===gt;gt&&be.has(gt)&&!$t&&Ie&&!be.has(Ie)&&!j.has(Ie)&&(gt=Ie),gt&&!be.has(gt)&&be.set(gt,ct);for(let Dt=ye;Dt<=pe;Dt++)ue[Dt]=gt;ye=pe+1}let Le=pe=>{for(let Ie=0;Ie<pe.text.length;Ie++)if(G(pe.text[Ie])&&!_(pe,Ie))return!0;return!1};if(!Le(g)&&!Le(d)&&!Le(k)){let pe=[],Ie=0;for(let ct=0;ct<tt;ct++)(ce[ct]===Ot||ct===tt-1)&&(pe.push([Ie,ct]),Ie=ct+1);let st=new Set(ue);for(let ct=0;ct<pe.length;ct++){let[gt,$t]=pe[ct];if(ue[$t])continue;let Dt=gt;for(;Dt<=$t&&!G(ce[Dt]);)Dt++;if(Dt>$t)continue;let pn=_(g,Ne[Dt]),cn=_(d,Pe[Dt]),yn=_(k,De[Dt]),An=b(pn,cn,yn)||cn||yn||pn;if(An&&!st.has(An)){st.add(An);for(let Yt=gt;Yt<=$t;Yt++)ue[Yt]=An;continue}let $n=ct>0&&ue[pe[ct-1][1]],Un=ct+1<pe.length&&ue[pe[ct+1][1]];if($n)he.add(pe[ct-1][1]);else if(Un&&ce[$t]===Ot)he.add($t);else continue;for(let Yt=gt;Yt<=$t;Yt++)ue[Yt]=$n||Un}}}let le=new Map,ee=b=>{let _=le.get(b);if(_)return _;_=[1/0,-1/0];for(let[I,j]of[[b.baseMark,lt],[b.localMark,it],[b.remoteMark,Ht]]){let G=I&&Lt(I,j);G&&(_[0]=Math.min(_[0],G[0]),_[1]=Math.max(_[1],G[1]))}return le.set(b,_),_},ie=(b,_,I)=>{let j=-1,G=-1;for(let oe=0;oe<b.length;oe++){let be=xt.get(b[oe].el);be===_&&(j=oe),be===I&&(G=oe)}return j>=0&&G>=0?j-G:0},Re=(b,_)=>[...b].sort((I,j)=>{for(let be of _){let ye=ie(be,I,j);if(ye)return ye}let G=ee(I),oe=ee(j);return G[0]-oe[0]||oe[1]-G[1]||I.rank-j.rank||I.id-j.id}),We=new Map,Je=new Map,at=e.nativeTransfers?[]:null,dt=b=>{if(at)return at;let _=Ne[b],I=Pe[b],j=De[b],G=Se[b];if(_>=0){let ct=g.stackAt[_],gt=d.stackAt[I],$t=k.stackAt[j],Dt=We.get(ct);Dt||We.set(ct,Dt=new Map);let pn=Dt.get(gt);pn||Dt.set(gt,pn=new Map);let cn=pn.get($t);if(cn)return cn;let yn=et(ct),An=et(gt),$n=et($t),Un=new Set;for(let Yt of new Set([...yn,...An,...$n])){let wr=yn.has(Yt),Sr=An.has(Yt),zt=$n.has(Yt);(Sr===zt?Sr:Sr===wr?zt:Sr)&&Un.add(Yt)}return cn=Re(Un,[gt,$t,ct]),pn.set($t,cn),cn}if(G.src==="both"){let ct=d.stackAt[I],gt=k.stackAt[j];return Re(new Set([...et(ct),...et(gt)]),[ct,gt])}let be=(G.src==="local"?d:k).stackAt[G.src==="local"?I:j];if(!G.inherit)return Re(et(be),[be]);let ye=Je.get(G);ye||Je.set(G,ye=new Map);let Le=ye.get(be);if(Le)return Le;let pe=new Set(et(be));for(let ct of G.inherit.added)pe.add(je(ct));for(let ct of G.inherit.removed)pe.delete(je(ct));let Ie=G.src==="local"?k:d,st=(G.src==="local"?Te.bTo:me.bTo)[G.inherit.bs];return Le=Re(pe,[be,Ie.stackAt[st]]),ye.set(be,Le),Le},ht=new Int32Array(d.text.length+1);ht[d.text.length]=tt;for(let b=d.text.length-1;b>=0;b--)ht[b]=it[b]>=0?it[b]:ht[b+1];mh.caret+=d.text.length;let ft=b=>b<=0?0:(b>d.text.length&&(b=d.text.length),it[b-1]>=0?it[b-1]+1:ht[b]),Mt=[],_t=[],Pt=null,Ye=[],St="",Rt=-1,Ut=b=>{Pt?Pt.appendChild(b):Mt.push(b)},jt=b=>{if(!St)return;let _=t.createTextNode(St);Ut(_),_t.push({node:_,ms:Rt,me:b,local:[],u:Ye.length?Ye[Ye.length-1].u:null}),St=""},_n=new Set,an=new Map,or=new Set,kn=b=>{let _=t.createElement(b.tag);if(b.block&&$e.add(_),!an.has(b)){an.set(b,_),C(b.base,b.local,b.remote,_),s.set(_,{base:b.base,local:b.local,remote:b.remote});let j=(be,ye)=>p&&b[ye]&&be.reverse.get(b[ye])?ye:null,G=!b.base&&(j(r,"local")||j(o,"remote"));if(G){let be=G==="local"?r.reverse.get(b.local):o.reverse.get(b.remote),ye=s.get(_);ye.local=ye.local||r.map.get(be)||null,ye.remote=ye.remote||o.map.get(be)||null,a.push({kind:"move",el:_,source:G}),e.moveBuilt?.(be,G,b[G],_)}else b.base||a.push({kind:"insert",el:_,source:b.local&&b.remote?"both":b.local?"local":"remote"});let oe=s.get(_);oe.local&&(or.has(oe.local)?oe.local=null:or.add(oe.local))}else{let j=an.get(b);for(let G of j.attributes)G.name!=="id"&&G.name!=="data-id"&&T(_,G,G.value);s.set(_,{base:null,local:null,remote:null})}Ut(_),Ye.push({u:b,el:_}),Pt=_},yr=new Set,Mn=new Map;for(let b of d.pins){let _=ft(b.i);Mn.has(_)||Mn.set(_,[]),Mn.get(_).push(b)}let Fr=b=>{let _=Mn.get(b);if(_){jt(b);for(let I of _){let j=I.el.namespaceURI&&I.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(I.el.namespaceURI,I.el.tagName):t.createElement(I.el.tagName);s.set(j,{base:null,local:I.el,remote:null,pinned:!0}),yr.add(j),Ut(j)}}},Oo=g.atoms.length||d.atoms.length||k.atoms.length,tn=b=>{if(!Oo)return null;let _=Ne[b]>=0?g.atomAt.get(Ne[b]):null,I=Pe[b]>=0?d.atomAt.get(Pe[b]):null,j=De[b]>=0?k.atomAt.get(De[b]):null;return _||I||j?{ab:_,al:I,ar:j}:null},Gn=(b,_,I)=>{let j=e.idOf;if(!j||!j.base)return!1;let G=j.base(b.el);return G!=null&&G===j[I](_.el)},No=(b,_,I,j,G)=>{if(!b||!p)return null;let oe=S.get(_.reverse.get(b.el))||null;return!oe||oe===j||(j?oe.el.isEqualNode(j.el)&&!Gn(oe,b,G):I.bTo[oe.i]>=0)?null:oe},Br=(b,_)=>{if(!b||!p||!e.moveIn)return null;let I=_.reverse.get(b.el);return I&&!S.has(I)?I:null},vr=(b,_)=>{let I=new Map;for(let j of b.atoms)I.set(_(j),(I.get(_(j))||0)+1);return I},Dn=vr(g,F),ds=vr(d,A),hs=vr(k,E),ms=b=>{let _=F(b);return Dn.get(_)===1&&(ds.get(_)||0)<=1&&(hs.get(_)||0)<=1},Yn=new Map,sr=new Set,xr=new Set,Co=new Set,$r=null;for(let b=0;b<tt;b++){let _=tn(b);if(!_)continue;let{ab:I,al:j,ar:G}=_,oe=No(G,o,Te,I,"remote"),be=No(j,r,me,I,"local"),ye=I,Le=null;if(oe?(ye=oe,Le="remote"):be&&(ye=be,Le="local"),ye){I&&ye!==I&&($r||=new Map).set(I,Le),sr.has(ye)?Yn.set(b,{dup:ye.el}):(sr.add(ye),Yn.set(b,{bk:ye,from:Le,al:j,ar:G}));continue}let pe=Br(G,o),Ie=Br(j,r),st=pe||Ie;if(st){xr.has(st)?Yn.set(b,{dup:st}):(xr.add(st),Yn.set(b,{moveIn:st,side:pe?"remote":"local",sideEl:pe?G.el:j.el}));continue}let ct=($t,Dt)=>$t&&p&&S.get(Dt.reverse.get($t.el))||null,gt=ct(G,o)||ct(j,r);if(gt&&(Co.add(gt),Se[b].conflict&&(ms(gt)||G&&(G.el===gt.el||o.identityPaired?.has(gt.el))&&Gn(gt,G,"remote")||j&&(j.el===gt.el||r.identityPaired?.has(gt.el))&&Gn(gt,j,"local")))){if(sr.has(gt)){Yn.set(b,{dup:gt.el});continue}sr.add(gt)}Yn.set(b,{al:j,ar:G})}let Fn=new Map,_o,Mo,ps=(b,_)=>{if(b[_]>=0)return b[_];for(let I=_-1;I>=0;I--)if(b[I]>=0)return b[I]+1;return 0};if(p)for(let b of g.atoms){if(sr.has(b)||Co.has(b))continue;let _=r.map.get(b.el)||null,I=o.map.get(b.el)||null,j=_&&O.get(_),G=I&&K.get(I);if(_&&!j||I&&!G)continue;let oe=!(j&&G)&&Ee.has(b);if(!oe&&!(j&&G&&(ms(b)||$r?.has(b)||(j.el===b.el||r.identityPaired?.has(b.el))&&(G.el===b.el||o.identityPaired?.has(b.el))&&Gn(b,j,"local")&&Gn(b,G,"remote"))))continue;let be=$r?.get(b),ye=n;if(be){let ct=be==="local"?k:d,gt=be==="local"?o:r,$t=be==="local"?Mo:_o;if($t===void 0){$t=ct.atoms.length===g.atoms.length;for(let Dt=0;$t&&Dt<g.atoms.length;Dt++)$t=gt.reverse.get(ct.atoms[Dt].el)===g.atoms[Dt].el;be==="local"?Mo=$t:_o=$t}$t&&(ye=be)}let Le=ye==="local"?[[j,it],[G,Ht]]:[[G,Ht],[j,it]],[pe,Ie]=Le.find(([ct])=>ct),st=ps(Ie,pe.i);Fn.has(st)||Fn.set(st,[]),Fn.get(st).push({a:b,lt:_,rt:I,edited:oe}),sr.add(b)}if(p&&e.moveIn){let b=[[d,r,it,"local"],[k,o,Ht,"remote"]];n!=="local"&&b.reverse();for(let[_,I,j,G]of b)for(let oe of _.atoms){let be=Br(oe,I);if(!be||xr.has(be))continue;xr.add(be);let ye=ps(j,oe.i);Fn.has(ye)||Fn.set(ye,[]),Fn.get(ye).push({move:be,side:G,sideEl:oe.el})}}let re=b=>{let _=Fn.get(b);if(_){if(jt(b),_.some(I=>ze(I.move?I.sideEl:I.a.el)))for(;Ye.length;)Ye.pop(),Pt=Ye.length?Ye[Ye.length-1].el:null;for(let{a:I,lt:j,rt:G,edited:oe,move:be,side:ye,sideEl:Le}of _){if(be){let Ie=e.moveIn(be,ye,Le);Ie&&Ut(Ie);continue}_n.add(I);let pe=L(I.el,j,G);oe&&(m({kind:"structure",el:pe,detail:"edit-beats-delete",base:I.el},{subject:I.el,deleted:j?"remote":"local"}),a.push({kind:"insert",el:pe,source:j?"local":"remote"})),Ut(pe)}}},$e=new Set,Ue=l.length>c;for(let b=0;b<tt;b++){let _=tn(b),I=e.scopeUnits&&_&&(_.ab?.stack.some(be=>be.block)||_.al?.stack.some(be=>be.block)||_.ar?.stack.some(be=>be.block)),G=!!_&&ze((_.ab||_.al||_.ar).el)&&!I?[]:ue[b]?[ue[b],...dt(b)]:dt(b),oe=0;for(;oe<Ye.length&&oe<G.length&&Ye[oe].u===G[oe];)oe++;if(oe<Ye.length)for(jt(b);Ye.length>oe;)Ye.pop(),Pt=Ye.length?Ye[Ye.length-1].el:null;if(Fr(b),re(b),G.length>Ye.length)for(jt(b);Ye.length<G.length;)kn(G[Ye.length]);if(ce[b]===Ot){if(he.has(b))continue;jt(b);let be=Ye.length;for(;be>0&&!Ye[be-1].u.block;)be--;if(be>0)for(Ue&&u.breakOut.set(b,Ye[be-1].el);Ye.length>=be;)Ye.pop(),Pt=Ye.length?Ye[Ye.length-1].el:null;continue}if(_){jt(b);let be=Yn.get(b),ye;if(be.dup){m({kind:"structure",el:null,detail:"both-moved",base:be.dup},{subject:be.dup});continue}if(be.moveIn){if(ye=e.moveIn(be.moveIn,be.side,be.sideEl),!ye)continue}else if(be.bk){let Le=be.bk;if(_n.add(Le),Le===_.ab)ye=L(Le.el,be.al.el,be.ar.el);else{let pe=r.map.get(Le.el)||null,Ie=o.map.get(Le.el)||null;ye=L(Le.el,pe,Ie),(!pe||!Ie)&&m({kind:"structure",el:null,detail:"move-beats-delete",base:Le.el},{subject:Le.el,deleted:pe?"remote":"local"}),a.push({kind:"move",el:ye,source:be.from})}}else be.al?(ye=q(be.al.el,"local"),be.ar&&(s.get(ye).remote=be.ar.el),a.push({kind:"insert",el:ye,source:be.ar?"both":"local"})):(ye=q(be.ar.el,"remote"),a.push({kind:"insert",el:ye,source:"remote"}));Ue&&u.atomOut.set(b,ye),Ut(ye);continue}St||(Rt=b),St+=ce[b]}if(jt(tt),(Mn.has(tt)||Fn.has(tt))&&(Ye.length=0,Pt=null,Fr(tt),re(tt)),tt===0&&(d.placeholder||k.placeholder||g.placeholder)){let b=t.createElement("br");s.set(b,{base:g.placeholder,local:d.placeholder,remote:k.placeholder}),Mt.push(b)}let Ze=0,wt=b=>{for(;Ze>0&&_t[Ze-1].me>=b;)Ze--;for(;Ze<_t.length&&_t[Ze].me<b;)Ze++;let _=_t[Ze];if(!_)return _t[_t.length-1]||null;let I=_t[Ze+1];return _.me===b&&I&&I.ms===b?I:_},Ke=new Map,Ve={},mt=(b,_,I)=>{let j=wt(b)||(I?Ve:null);if(!j)return;let G=Ke.get(j)||{l:!1,r:!1};_!=="remote"&&(G.l=!0),_!=="local"&&(G.r=!0),Ke.set(j,G)},Qe=b=>{if(b.conflict)return!0;let _=b.src==="local"?d.text:b.src==="remote"?k.text:"";for(let I=b.from;I<b.to;I++)if(_[I]!==zn&&_[I]!==Ot)return!0;return!1};for(let b of D)b.src!=="base"&&mt(b.ms,b.conflict?"both":b.src,Qe(b));for(let[b,_]of W)lt[b]>=0&&mt(lt[b],_);for(let b of _t.length?_t:[Ve]){let _=Ke.get(b);_&&a.push({kind:"text",node:b.node||null,source:_.l&&_.r?"both":_.l?"local":"remote"})}for(let b of nt){if(an.has(b))continue;let _=!b.local&&!(p&&r.map.get(b.base)),I=!b.remote&&!(p&&o.map.get(b.base));!_&&!I||a.push({kind:"remove",source:_&&I?"both":_?"local":"remote",base:b.base})}if(xe)for(let[b,_]of xe)an.has(b)&&m({kind:"structure",el:an.get(b),detail:"edit-beats-delete",base:b.base},{subject:b.base,deleted:_});let pt=(b,_,I)=>{if(_<=b)return!1;for(let j=b;j<_;j++)if(I[j]>=0)return!1;return!0};for(let b of nt)for(let _ of["local","remote"]){let I=b[_+"Mark"],j=b.baseMark;if(!I)continue;let G=_==="local"?me:Te;if(!pt(j.from,j.to,G.bTo)||!pt(I.from,I.to,G.toB))continue;let oe=(_==="local"?de:Oe).find(be=>be.ss<=I.from&&I.from<be.se);oe&&(oe.be<=j.from||oe.bs>=j.to)&&a.push({kind:"move",el:an.get(b)||null,source:_})}let kt=b=>{let _=xt.get(b.node.parentNode);return _?je(_):null};for(let b of d.nodes){let _=-1;for(let j=b.s;j<b.e;j++)if(it[j]>=0){_=it[j];break}let I;if(_>=0)I=wt(_);else{let j=ft(b.s),G=kt(b);I=_t.find(oe=>oe.u===G&&oe.me>=j)||_t.filter(oe=>oe.u===G).pop()}I&&I.local.push(b)}let Et=new Map,At=_t[_t.length-1]||null,qt=0;for(let b of d.nodes){let _=null;for(let I=b.s;I<=b.e;I++){let j=ft(I);for(;qt>0&&_t[qt-1].me>=j;)qt--;for(;qt<_t.length&&_t[qt].me<j;)qt++;let G=be=>be&&j>=be.ms&&j<=be.me&&(j<be.me||I===b.e||be===_),oe=G(_t[qt])?_t[qt]:G(_t[qt+1])?_t[qt+1]:_t[qt]||At;if(!oe)break;if(_===oe){let be=Et.get(oe);be[be.length-1].to=I-b.s;continue}_=oe,Et.has(oe)||Et.set(oe,[]),Et.get(oe).push({node:b.node,from:I-b.s,to:I-b.s,flatStart:b.s})}}for(let b of _t){let _=b.local,I=!1;for(let be of _)for(let ye=be.s;ye<be.e&&!I;ye++)(it[ye]<b.ms||it[ye]>=b.me)&&(I=!0);s.set(b.node,{base:null,local:_.map(be=>be.node),remote:null,caret:Et.get(b)||[],partial:I});let j=b.ms,G=b.me-b.ms,oe=be=>{let ye=0,Le=-1;for(let pe of _){let Ie=pe.e-pe.s;if(be<=ye+Ie){Le=pe.s+(be-ye);break}ye+=Ie}return Le<0&&(Le=_.length?_[_.length-1].e:0),Math.max(0,Math.min(ft(Le)-j,G))};oe.flat=be=>Math.max(0,Math.min(ft(be)-j,G)),i.set(b.node,oe)}function Bn(){if(!d.text.includes(Ot))return[{flatLocal:d.text,localNodes:d.nodes,textNodes:_t,lToM:it,mapLocal:ft}];let b=[],_=0,I=0;for(let j=0;j<=d.text.length;j++){if(j<d.text.length&&d.text[j]!==Ot)continue;let G=_,oe=j;if(oe>G){let be=[];for(;I<d.nodes.length&&d.nodes[I].e<=G;)I++;for(let ye=I;ye<d.nodes.length&&d.nodes[ye].s<oe;ye++){let Le=d.nodes[ye],pe=Math.max(Le.s,G),Ie=Math.min(Le.e,oe);pe<Ie&&be.push({node:Le.node,s:pe-G,e:Ie-G})}b.push({flatLocal:d.text.slice(G,oe),localNodes:be,textNodes:_t,lToM:it.subarray?it.subarray(G,oe+1):it.slice(G,oe+1),mapLocal:ye=>ft(G+Math.max(0,Math.min(ye,oe-G)))})}_=j+1}return b}let ir={...e,blocks:$e,ignored:b=>yr.has(b)||(e.ignored?e.ignored(b):!1)},Ur=e.ignoreAttribute||(()=>!1),Ti=qa(Qt(Mt,ir),Ur)!==qa(k,Ur);if(f.length){let b=_=>{let I=s.get(_);return I&&I.unchanged?I.remote:null};u.text=ce,u.textNodes=_t,u.out=Qt(Mt,{...ir,via:b})}let vt=null;if(e.scopeUnits){vt=new Map;let b=new Set(Mt),_=ye=>{for(;ye&&!b.has(ye);)ye=ye.parentNode;return ye},I=e.scopeUnits.map(ye=>{let Le=new Map;for(let pe of ye)if(pe.nodeType===1)Le.set(pe,pe);else for(let Ie of pe.nodes)Le.set(Ie,pe);return Le}),j=(ye,Le)=>{for(;ye&&!Le.has(ye);)ye=ye.parentNode;return ye?Le.get(ye):null},G=[g,d,k].map((ye,Le)=>{let pe=new Array(ye.text.length);for(let Ie of ye.nodes){let st=j(Ie.node,I[Le]);st&&pe.fill(st,Ie.s,Ie.e)}for(let Ie of ye.atoms)pe[Ie.i]=j(Ie.el,I[Le]);return pe}),oe=(ye,Le)=>{if(!ye||!Le)return;let pe=vt.get(ye);pe||vt.set(ye,pe=new Set),pe.add(Le)};for(let ye of Mt){let Le=s.get(ye);Le&&(oe(j(Le.base,I[0]),ye),oe(j(Le.local,I[1]),ye),oe(j(Le.remote,I[2]),ye))}for(let ye of _t){let Le=_(ye.node);for(let pe=ye.ms;pe<ye.me;pe++)oe(G[0][Ne[pe]],Le),oe(G[1][Pe[pe]],Le),oe(G[2][De[pe]],Le)}let be=new Map(Mt.map((ye,Le)=>[ye,Le]));for(let[ye,Le]of vt)vt.set(ye,Array.from(Le).sort((pe,Ie)=>be.get(pe)-be.get(Ie)))}return{unitOutputs:vt,nodes:Mt,text:ce,textNodes:_t,localDiverged:Ti,mapLocal:ft,conflicts:l.slice(c),granularity:z?"line":"word",segments:Bn(),localHunks:de,remoteHunks:Oe,lToM:it}}var Ji=Symbol("lost");function Ga(){return{links:new Map,removed:new Set,consumed:new Set,link(e,t){this.links.set(e,t)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let t of e.nodes)this.removed.add(t)},consume(e){for(let t of e)this.consumed.add(t)}}}var Ka=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function Ya({locals:e,rec:t,root:n,provenance:r,segments:o,ignored:s}){let i=new Map,l=(x,w)=>{let T=i.get(x);T||i.set(x,T=new Set),T.add(w)},a=new Set,c=new Set;for(let x of o){let w=x.textNodes;for(let T of w)a.add(T.node);for(let T of x.localNodes){c.add(T.node);let N=0,C=null;for(let L=T.s;L<T.e;L++){let q=x.lToM[L];if(q<0)continue;for((!w[N]||q<w[N].ms)&&(N=0);N<w.length&&w[N].me<=q;)N++;let V=w[N]&&w[N].ms<=q?w[N].node:Ji;V!==C&&l(T.node,V),C=V}}}let m=new Set,u=new Map,f=new Set;(function x(w){m.add(w);let T=r.get(w);if(w.nodeType===1)T&&T.local&&T.local.nodeType===1&&(l(T.local,w),T.unchanged&&f.add(T.local)),w.tagName==="TEMPLATE"&&w.content&&u.set(w.content,w);else if(T&&Array.isArray(T.local)&&!a.has(w))for(let N of T.local)l(N,w);for(let N=Ka(w).firstChild;N;N=N.nextSibling)x(N)})(n);let p=new Set;for(let[x,w]of t.links)l(x,w),p.add(x);let h=x=>{let w=x.parentNode;return w&&w.nodeType===11?u.get(w)||null:w},v=(x,w)=>{for(let T=x;T;T=h(T))if(T===w)return!0;return!1},g=x=>t.removed.has(x)||t.consumed.has(x),d=x=>{for(let w=x.parentNode;w&&w.nodeType===1;w=w.parentNode){if(f.has(w))return"kept";if(g(w))return"decided";if(i.has(w))return null}return null},k=new Map;for(let x of e)k.set(x,S(x));return k;function S(x){let w=i.get(x);if(w&&(w.size!==1||w.has(Ji)))return{kind:"unknown",reason:"several-outputs"};let T=w?w.values().next().value:null;if(T&&(T.nodeType!==1||!m.has(T)))return{kind:"unknown",reason:"output-not-placed"};if(!T){let q=g(x)?"decided":d(x);if(q==="kept")return{kind:"untouched"};if(q!=="decided")return{kind:"unknown",reason:"unmapped"}}let N=[],C=L(x,!!T&&(f.has(x)||p.has(x)),!T||g(x));if(C)return{kind:"unknown",reason:C};return T?{kind:"single",output:T,owned:N,carried:p.has(x)}:{kind:"removed"};function L(q,V,U){for(let F=Ka(q).firstChild;F;F=F.nextSibling){if(F.nodeType===1?s(F):F.nodeType!==3&&F.nodeType!==8)continue;let A=i.get(F);if(A)for(let E of A){if(E===Ji||!m.has(E))return"output-not-placed";if(!T)return"survives-elsewhere";if(!v(E,T))return"escaped";N.push(E)}else if(!V&&!U&&!g(F)&&!c.has(F))return"unmapped";if(F.nodeType===1){let E=L(F,V||f.has(F)||p.has(F),U||g(F));if(E)return E}}return null}}}function Xa(e,t){if(!t)return!1;let n=t.nodeType===1&&t.tagName==="TEMPLATE"?[t,...t.querySelectorAll("template")]:[...t.querySelectorAll("template")];for(let r of n)if(r.content.contains(e)||Xa(e,r.content))return!0;return!1}function Ja(e,t){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let n=[],r=new Set;for(let o of Array.from(e.elements)){if(!o||o.nodeType!==1||o.ownerDocument!==t&&!Xa(o,t.documentElement))throw new TypeError("lineage.elements must be elements of the live document");r.has(o)||(r.add(o),n.push(o))}return n}var Za=new WeakMap;function Qa(e){let t=new Map;for(let n of e){let r=[],o=!1;(function s(i){i.nodeType===1&&i.namespaceURI==="http://www.w3.org/1999/xhtml"&&i.localName==="template"&&(o=!0);for(let l=i.firstChild;l;l=l.nextSibling)r.push(l),l.nodeType===1&&s(l)})(n),t.set(n,{nodes:r,opaque:o})}return t}function Zi(e,t,n){if(e.lineage===void 0)return n(e);if(!t||t.nodeType!==1)throw new TypeError("lineage requires an element root");let r=e.lineage,o=Ja(r,t.ownerDocument),s=!1,i={...e,lineage:{elements:o,onResult(l,a){if(!s)return s=!0,r.onResult(l,a)}}};try{return Za.set(i.lineage,Qa(o)),n(i)}catch(l){if(!s){s=!0;try{r.onResult({version:1,root:t,status:"incomplete",entries:o.map(Tn)},null)}catch{}}throw l}}function Qi(e,{liveRoot:t,localRoot:n,toLive:r}){let o=Ja(e,t.ownerDocument),s=c=>c===t||t.contains(c),i=new Map,l=new Set(o.filter(s));if(l.size&&n===t)for(let c of l)i.set(c,c);else l.size&&(function c(m){let u=r(m);l.delete(u)&&i.set(u,m);for(let f=m.firstElementChild;f&&l.size;f=f.nextElementSibling)c(f)})(n);return{spec:e,watched:o,root:t,locals:Array.from(new Set(i.values())),before:Za.get(e)||Qa(o),delivered:!1,result:null,finish(c,m){return this.resolve=m,this.plans=c,this.result={version:1,root:this.root,status:"complete",entries:o.map(u=>vh(u,i.get(u),c,m,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(c,m){this.root=m;let u=this.resolve,f=h=>{let v=u(h);return v===c?m:v};return this.finish(this.plans,f)},deliver(c){this.delivered||(this.delivered=!0,e.onResult(this.result,c))}}}var Tn=e=>({from:e,to:[],kind:"unknown",complete:!1});function vh(e,t,n,r,o){let s=o.root,i=f=>!!f&&(f===s||s.contains(f)),l=t&&n?n.get(t):null;if(!l||l.kind==="unknown")return Tn(e);let a=o.before.get(e);if(!a||a.opaque)return Tn(e);let c=a.nodes,m=f=>i(f)||!!(f&&f.ownerDocument===s.ownerDocument&&s.ownerDocument.documentElement?.contains(f));if(l.kind==="untouched"){if(!i(e))return Tn(e);for(let f of c)if(m(f)&&!e.contains(f))return Tn(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(l.kind==="removed")return m(e)||c.some(m)?Tn(e):{from:e,to:[],kind:"removed",complete:!0};let u=r(l.output);if(!u||u.nodeType!==1||!i(u)||u!==e&&m(e))return Tn(e);for(let f of c)if(m(f)&&!u.contains(f))return Tn(e);for(let f of l.owned){let p=r(f),h=Array.isArray(p)?p:[p];for(let v of h)if(!v||!i(v)||!u.contains(v))return Tn(e)}return l.carried&&!ec(u,l.output,r)?Tn(e):{from:e,to:[u],kind:u===e?"retained":"replaced",complete:!0}}function ec(e,t,n){for(let r=t.firstChild;r;r=r.nextSibling){let o=n(r),s=Array.isArray(o)?o:[o];for(let i of s)if(!i||!e.contains(i))return!1;if(r.nodeType===1&&!ec(e,r,n))return!1}return!0}function qo(e,t,n){let r=Qi(e,{liveRoot:t,localRoot:t,toLive:o=>o});return r.result={version:1,root:t,status:"complete",entries:r.watched.map(o=>Tn(o))},n.lineage=r.result,r}function tc(e,t,n,r,o){if(!o(e.length*8+1))return null;let s=0,i=t===0,l=!1;for(let a of un(e,r)){if(!o(1))return null;if(s+=a.len,s===t&&(i=!0),s===n&&(l=!0),s>=n)break}return i&&l}function xh(e,t,n,r,o,s,i){if(!i(t.length*2))return!1;let l=new Map,a=new Map,c=new Set;for(let m of t){let u=m.bs<m.be,f=u?n[m.ownerIndex].text.base:n[m.ownerIndex].text[e],p=u?m.bs:m.ss,h=u?m.be:m.se;if(!i((h-p)*4+1))return!1;for(;p<h&&/\s/.test(f[p]);)p++;for(;h>p&&/\s/.test(f[h-1]);)h--;if(p===h)continue;let v=f.slice(p,h),g=u?l:a;u&&m.text&&c.add(v),g.has(v)?g.set(v,null):g.set(v,{h:m,from:p,to:h})}for(let m of r){if(!i(1))return!1;if(m.side!==e)continue;let u=m.deletion,f=n[u.ownerIndex].text.base;if(!i((u.be-u.bs)*3)||c.has(f.slice(u.bs,u.be).trim()))return!1}for(let[m,u]of l){if(!i(m.length+1))return!1;let f=a.get(m);if(!u||!f)continue;let p=u.h,h=f.h;if(!p.text||p.transferOut||h.transferIn||p.owner===h.owner)continue;let v=n[p.ownerIndex],g=n[h.ownerIndex];if(!i(v.text.base.length))return!1;if(!/\S/.test(v.text.base.slice(0,p.bs)+v.text.base.slice(p.be)))continue;let d=tc(v.text.base,u.from,u.to,s,i),k=tc(g.text[e],f.from,f.to,s,i);if(d===null||k===null)return!1;if(!d||!k)continue;let S=`${v.index}:${u.from}:${u.to}`,x={key:S,side:e,source:p.owner,destination:h.owner,deletion:p,insertion:h,sourceOffset:u.from-p.bs,targetOffset:f.from-h.ss,length:u.to-u.from};p.transferOut=x,h.transferIn=x,o[e].set(S,x),r.push(x)}return!0}function nc({base:e,local:t,remote:n,localTwin:r,remoteTwin:o,eligible:s,nodes:i,budget:l=Gt(2e4*32)}){let a=C=>C>l.remaining?!1:(l.remaining-=C,l.nativeSteps=(l.nativeSteps||0)+C,!0);if(e.length<2||t.length!==e.length||n.length!==e.length||!a(e.length*12))return null;for(let[C,L]of[["base",e],["local",t],["remote",n]]){let q=i[C];if(q.length!==L.length||q.some((V,U)=>V!==L[U]))return null}let c=[],m=0;for(let C=0;C<e.length;C++){let L=e[C],q=t[C],V=n[C];if(r(L)!==q||o(L)!==V)return null;let U={};for(let[F,A]of[["base",L],["local",q],["remote",V]]){if(!s(A)||A.tagName!==L.tagName||A.namespaceURI!==L.namespaceURI||!a(A.childNodes.length+1))return null;let E="";for(let X of A.childNodes){if(X.nodeType!==3||!a(X.data.length*4+1))return null;E+=X.data}if(E.includes(Ot)||(m+=E.length+1,m>2e4))return null;U[F]=E}c.push({base:L,local:q,remote:V,index:C,text:U})}let u=c.every(C=>xn(C.text.base,C.text.local,C.text.remote)),f={local:[],remote:[]};for(let C of c){C.hunks={local:[],remote:[]};for(let L of["local","remote"]){let q=C.text.base,V=C.text[L];if(q===V)continue;let U=q.length+V.length+4,F=U*8;if(!a(F))return null;let A=Math.floor(l.remaining/8),E=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(U*U+A)-U)/2)));if(E<1||!a(4*(E+1)*(U+E+1)))return null;let X=0;for(let B of Ar(q,V,E)){if(!a(B.text.length+1))return null;let z=B.bs+X,Ce={...B,ss:z,se:z+B.text.length,toks:un(B.text,u),owner:C.base,ownerIndex:C.index};C.hunks[L].push(Ce),f[L].push(Ce),X+=B.text.length-(B.be-B.bs)}}}let p=[],h={local:new Map,remote:new Map};for(let C of["local","remote"]){let L=new Map,q=new Map,V=!1,U=(F,A,E)=>{F.has(A)?F.set(A,null):F.set(A,E)};for(let F of f[C]){if(!a(1))return null;let A=c[F.ownerIndex].text.base;if(F.bs<F.be&&F.text===""){let E=A.slice(F.bs,F.be);if(!a(E.length*2))return null;/\S/.test(E)&&U(L,E,F)}else if(F.bs===F.be&&/\S/.test(F.text)){if(!a(F.text.length*2))return null;U(q,F.text,F)}else F.bs<F.be&&(V=!0)}for(let[F,A]of L){if(!a(F.length+1))return null;let E=q.get(F);if(!A||!E||A.owner===E.owner)continue;let X=c[A.ownerIndex];if(!a(X.text.base.length))return null;if(!/\S/.test(X.text.base.slice(0,A.bs)+X.text.base.slice(A.be)))continue;let B=`${X.index}:${A.bs}:${A.be}`,z={key:B,side:C,source:A.owner,destination:E.owner,deletion:A,insertion:E};A.transferOut=z,E.transferIn=z,h[C].set(B,z),p.push(z)}if(V&&q.size&&!xh(C,f[C],c,p,h,u,a))return null}if(!p.length)return null;let v=(C,L)=>C.bs<L.be&&L.bs<C.be,g=C=>C.bs===C.be,d=(C,L)=>C.bs<=L.be&&L.bs<=C.be&&g(C)!==g(L),k=(C,L)=>C.bs===L.bs&&C.be===L.be&&C.text===L.text,S=(C,L)=>!!(C.transferIn||C.transferOut&&(!C.text||L.bs===C.be&&/\s/.test(L.text[0])||L.bs===C.bs&&/\s/.test(L.text[L.text.length-1])));for(let C of p){let L=C.side==="local"?"remote":"local",q=c[C.deletion.ownerIndex];for(let V of q.hunks[L])if(!a(1)||v(C.deletion,V)&&V.transferOut?.key!==C.key)return null}for(let C of c)for(let L of C.hunks.local)for(let q of C.hunks.remote){if(!a(1))return null;if(k(L,q)){if(L.transferIn?.key!==q.transferIn?.key)return null;continue}if(v(L,q)||d(L,q)&&!S(L,q)&&!S(q,L))return null}if(!a(m*8))return null;let x=new Set([...e,...t,...n]),w={base:Qt(e,{blocks:x}),local:Qt(t,{blocks:x}),remote:Qt(n,{blocks:x})},T={};for(let C of["base","local","remote"]){let L=w[C];if(L.atoms.length||L.pins.length)return null;T[C]=new Map(L.marks.filter(q=>q.block).map(q=>[q.el,q.from]))}for(let C of c){let L=T.base.get(C.base);if(L===void 0)return null;for(let q of["local","remote"]){let V=T[q].get(C[q]);if(V===void 0)return null;for(let U of C.hunks[q])U.bs+=L,U.be+=L,U.ss+=V,U.se+=V}}for(let C of p)C.bs=C.deletion.bs+(C.sourceOffset||0),C.be=C.length===void 0?C.deletion.be:C.bs+C.length,C.ss=C.insertion.ss+(C.targetOffset||0),C.se=C.length===void 0?C.insertion.se:C.ss+C.length;let N={};for(let C of["local","remote"]){let L=0,q=0,V=[];for(let F of f[C]){if(!a(1))return null;F.bs>L&&V.push({from:L,to:F.bs,target:q}),L=F.be,q=F.se}L<w.base.text.length&&V.push({from:L,to:w.base.text.length,target:q});let U=p.filter(F=>F.side===C).map(F=>({from:F.bs,to:F.be,target:F.ss,destination:F.destination}));if(N[C]=Hn({base:w.base,side:w[C],retained:V,transfers:U,budget:l}),N[C].status!=="ready")return null}return a(w.base.text.length)?{owners:c,blocks:x,transfers:p,byOrigin:h,budget:l,prepared:{base:w.base,local:w.local,remote:w.remote,lines:!1,baseTokens:un(w.base.text,u),localEdits:{hunks:f.local,respell:new Map},remoteEdits:{hunks:f.remote,respell:new Map},localMap:N.local,remoteMap:N.remote,full:null}}:null}var el=/\S/;function rc({certificates:e,scopes:t,views:n,eligible:r,baseId:o,limit:s=2e4*32}){let i=Gt(s),l=Symbol(),a=[],c=u=>{if(u>i.remaining)throw l;i.remaining-=u},m=(u,f=null)=>{if(c(1),!u||u.nodeType!==1||u.parentNode?.nodeType!==1||!r(u))return null;for(let v=u.parentNode;v;v=v.parentNode)if(c(1),v.nodeType===11)return null;let p="",h=0;for(let v of u.childNodes){if(c(1),v.nodeType!==3)return null;if(c(v.data.length*4+1),f){let g=f.flat.nodes[h++];if(!g||g.node!==v||g.s!==p.length||g.e!==p.length+v.data.length)return null}p+=v.data}return c(p.length*3+1),f&&(f.flat.atoms.length||f.flat.pins?.length||h!==f.flat.nodes.length||f.flat.text!==p)?null:el.test(p)?p:null};try{c(t[0].length+t[1].length+t[2].length+e.length);let u=t.map(p=>new Set(p)),f=new Map;for(let p of e){c(1);let h=f.get(p.source);h||f.set(p.source,h=[]),h.push(p)}for(let p of f.values()){let h=[null,null],v=[];for(let g of p){c(1);let{source:d,target:k,side:S,models:x,runs:w}=g;if(S!==0&&S!==1||!u[0].has(d)||!u[S+1].has(k))continue;let{V:T,A:N,idOf:C}=n[S],L=n[1-S],q=T.twin(d),V=L.V.twin(d),U=T.baseOf(k);if(!q||!V||!U||U===d||!u[0].has(U)||!u[S+1].has(q)||!u[2-S].has(V)||N.map.get(d)!==q||N.reverse.get(q)!==d||L.A.map.get(d)!==V||L.A.reverse.get(V)!==d||N.map.get(U)!==k||N.reverse.get(k)!==U||k.parentNode!==q.parentNode||U.parentNode!==d.parentNode||d.tagName!==q.tagName||d.tagName!==V.tagName||o(d)!==C(q)||o(d)!==L.idOf(V)||o(U)!==C(k))continue;let F=x.get(d),A=x.get(k);if(!F||!A)continue;let E=m(d,F),X=m(k,A),B=m(q),z=m(V);if(c((E?.length||0)+(z?.length||0)),E===null||X===null||B===null||z===null||z===E)continue;let Ce=w.length>0,Me=!1;for(let me of w){if(c(1),me.source!==d||me.target!==k||!Number.isInteger(me.from)||!Number.isInteger(me.to)||!Number.isInteger(me.targetFrom)||me.from<0||me.to<=me.from||me.to>E.length||me.targetFrom<0||me.targetFrom+me.to-me.from>X.length){Ce=!1;break}c((me.to-me.from)*3);for(let Te=me.from;Te<me.to;Te++){if(E[Te]!==X[me.targetFrom+Te-me.from]){Ce=!1;break}el.test(E[Te])&&(Me=!0)}if(!Ce)break}if(!Ce||!Me)continue;let Be=h[S];Be||(c(E.length),Be=h[S]={source:d,side:S,flat:F.flat,before:E,covered:new Uint8Array(E.length)});for(let me of w)c(me.to-me.from),Be.covered.fill(1,me.from,me.to)}for(let g of h){if(!g)continue;let{source:d,side:k,flat:S,before:x,covered:w}=g;c(x.length*3+1);let T=-1,N=-1;for(let C=0;C<=x.length;C++)C<x.length&&w[C]?(T<0&&(T=C),N=C+1):(C===x.length||el.test(x[C]))&&T>=0&&(v.push({source:d,side:k,flat:S,from:T,to:N}),T=N=-1)}c(v.length),a.push(...v)}}catch(u){if(u!==l)throw u}return{records:a,budget:i}}var wh="http://www.w3.org/1999/xhtml";function Sh(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function mn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===wh}function Ah(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Ts(e,t){let n=e.getAttribute("src"),r=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(n){let o=n;try{let s=new URL(n,t);o=s.origin+s.pathname+s.search}catch{}return"script|src|"+r+"|"+o}return"script|inline|"+r+"|"+Sh(e.textContent.trim())}var Th={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function Xr(e,t=[],n=!1){if(!mn(e)||e.hasAttribute("src"))return null;let r=[Th,...t];for(let o=0;o<r.length;o++){let s=r[o];if(!s.match(e))continue;if(!Ah(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let i=s.identity(e);return i==null||i===""?null:{key:o+":"+i,raw:i,recognizer:s}}return null}function oc(e,t,n){let r=new Set,o=s=>{mn(s)&&!t(s)&&r.add(Ts(s,n))};o(e);for(let s of e.querySelectorAll("script"))o(s);return r}function Do(e,t){let n=t.createElement("div");n.innerHTML="<script><\/script>";let r=n.firstChild;for(let o of e.attributes)r.setAttribute(o.name,o.value);return r.textContent=e.textContent,r}function sc(e,t,n){let r=[],o=[],s=new Map,i=n.trackRecovery?new Set:null,l=Array.from(e.querySelectorAll("script"));mn(e)&&l.unshift(e);for(let a of l){if(!mn(a)||n.ignored(a)||n.skip.has(a)||t.has(Ts(a,n.baseURI)))continue;let c=a.ownerDocument.createElement("script");for(let m of a.attributes)c.setAttribute(m.name,m.value);if(c.textContent=a.textContent,n.beforeNodeAdded(c)===!1){i?.add(a);continue}c.hasAttribute("src")&&o.push(new Promise(m=>{c.addEventListener("load",()=>m()),c.addEventListener("error",()=>m())})),a.replaceWith(c),s.set(a,c),n.afterNodeAdded(c),r.push(c)}return{executed:r,loads:o,swapped:s,vetoed:i}}function Eh(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function Oh(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function ic(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Ts(e,t);if(n==="LINK"){let r=e.getAttribute("href");return r?"link|"+(e.getAttribute("rel")||"")+"|"+Oh(r,t):e.outerHTML}if(n==="META"){for(let r of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(r))return"meta|"+r+"="+e.getAttribute(r);return e.outerHTML}return n==="STYLE"?"style|"+Eh(e.textContent):e.outerHTML}function tl(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
4
+ `;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);if(n===-1)return e.length;t=n+2;continue}return t}}function Nh(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var Ch=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,_h=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function nl(e){try{return JSON.parse(e)}catch{return JSON.parse(Mh(e))}}function Mh(e){let t="",n=0,r=(o,s)=>{throw new Error(`Invalid relaxed JSON: ${o} at position ${s}`)};for(;n<e.length&&(n=tl(e,n),!(n>=e.length));){let o=e[n];if("{}[]:".includes(o)){t+=o,n++;continue}if(o===","){let l=tl(e,n+1);if(e[l]==="}"||e[l]==="]"){n++;continue}t+=o,n++;continue}if(o==='"'||o==="'"){let l=n+1;for(;l<e.length&&e[l]!==o;)e[l]==="\\"&&l++,l++;l>=e.length&&r("unterminated string",n);let a=e.slice(n+1,l);o==="'"&&(a=Nh(a)),t+='"'+a+'"',n=l+1;continue}let s=n;for(;s<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[s]);)s++;s===n&&r("unexpected character "+JSON.stringify(o),n);let i=e.slice(n,s);if(i==="true"||i==="false"||i==="null"||Ch.test(i)){t+=i,n=s;continue}if(_h.test(i)){if(e[tl(e,s)]===":"){t+='"'+i+'"',n=s;continue}r("unquoted value "+JSON.stringify(i),n)}r("invalid token "+JSON.stringify(i),n)}return t}var Vt=Symbol("hyper-morph-json-merge:missing"),Rh=["id","_id","uuid","key","slug","code","name"];function Jr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Fo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ih(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}var Lh=/^[A-Za-z_$][\w$]*$/;function Ph(e,t){return Lh.test(t)?e===""?t:e+"."+t:e+"["+JSON.stringify(t)+"]"}function jh(e,t){return e===""?t:e+"."+t}function Es(e,t,n,r,o,s){if(e.onConflict){let i=l=>l===Vt?void 0:l;e.onConflict({path:t,base:i(n),local:i(r),remote:i(o),resolved:i(s)})}return s}function Jn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Jn(e[n],t[n]))return!1;return!0}if(Jr(e)&&Jr(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Fo(t,r)||!Jn(e[r],t[r]))return!1;return!0}return!1}function rl(e,t,n,r,o,s){return Jn(t,n)?t:Jn(t,e)?n:Jn(n,e)?t:Jr(t)&&Jr(n)?qh(Jr(e)?e:{},t,n,r,o,s):Array.isArray(t)&&Array.isArray(n)?$h(e,t,n,r,o,s):Es(r,o,e,t,n,n)}function lc(e,t,n,r,o,s){return t===Vt&&n===Vt?Vt:t===Vt?e===Vt?n:Jn(n,e)?Vt:Es(r,o,e,t,n,n):n===Vt?e===Vt?t:Jn(t,e)?Vt:Es(r,o,e,t,n,Vt):rl(e,t,n,r,o,s)}function qh(e,t,n,r,o,s){let i={},l=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let a of l){let c=lc(Fo(e,a)?e[a]:Vt,Fo(t,a)?t[a]:Vt,Fo(n,a)?n[a]:Vt,r,Ph(o,a),jh(s,a));c!==Vt&&Ih(i,a,c)}return i}function Dh(e){return e===null||typeof e!="object"}function Os(e){return typeof e+":"+String(e)}function Fh(e,t){for(let n of t){let r=new Set;for(let o of n){if(!Fo(o,e))return!1;let s=o[e];if(typeof s!="string"&&typeof s!="number")return!1;let i=Os(s);if(r.has(i))return!1;r.add(i)}}return!0}function Bh(e,t,n,r,o){let s=[e,t,n],i=!0;for(let l of s)for(let a of l)Jr(a)||(i=!1);if(i){let l=r.keyPaths.get(o),a=l!==void 0?[l]:r.keyCandidates;for(let c of a)if(Fh(c,s))return{kind:"keyed",field:c};return null}for(let l of s){let a=new Set;for(let c of l){if(!Dh(c))return null;let m=Os(c);if(a.has(m))return null;a.add(m)}}return{kind:"self"}}function $h(e,t,n,r,o,s){let i=Array.isArray(e)?e:[],l=Bh(i,t,n,r,s),a=Array.isArray(e)&&e.length===t.length&&e.length===n.length;if(!l||l.kind==="self"&&a)return a?t.map((S,x)=>rl(e[x],S,n[x],r,o+"["+x+"]",s)):Es(r,o,e,t,n,n);let c=l.kind==="self"?Os:S=>Os(S[l.field]),m=S=>l.kind==="self"?o+"["+JSON.stringify(S)+"]":o+"["+l.field+"="+JSON.stringify(S[l.field])+"]",u=new Map,f=S=>{let x=new Map;for(let w of S){let T=c(w);x.set(T,w),u.has(T)||u.set(T,m(w))}return x},p=f(i),h=f(t),v=f(n),g=new Map,d=new Set([...p.keys(),...h.keys(),...v.keys()]);for(let S of d){let x=lc(p.has(S)?p.get(S):Vt,h.has(S)?h.get(S):Vt,v.has(S)?v.get(S):Vt,r,u.get(S),s);x!==Vt&&g.set(S,x)}let k=[];for(let S of n){let x=c(S);g.has(x)&&k.push(x)}for(let S=0;S<t.length;S++){let x=c(t[S]);if(!g.has(x)||k.includes(x))continue;let w=0;for(let T=S-1;T>=0;T--){let N=k.indexOf(c(t[T]));if(N!==-1){w=N+1;break}}k.splice(w,0,x)}return k.map(S=>g.get(S))}function Uh(e){let t=new Map,n=[];for(let r of e.keyCandidates||[]){let o=r.lastIndexOf(":");o>=0?t.set(r.slice(0,o),r.slice(o+1)):n.push(r)}return{keyCandidates:[...n,...Rh],keyPaths:t,onConflict:e.onConflict||null}}function ac(e,t,n,r={}){return rl(e===void 0?Vt:e,t,n,Uh(r),"","")}function Hh(e,t){let n=/^\s*/.exec(t)[0],r=/\s*$/.exec(t.slice(n.length))[0],o=t.slice(n.length,t.length-r.length),s=n.slice(n.lastIndexOf(`
5
5
  `)+1),i=/\n([ \t]+)\S/.exec(o),l;if(!i)l=JSON.stringify(e);else{let a=i[1],c=a.length>s.length&&a.startsWith(s)?a.slice(s.length):" ";l=JSON.stringify(e,null,c).replace(/\n/g,`
6
- `+s)}return n+l.replace(/</g,"\\u003c")+r}function il(e,t,n,r={}){let o=r.parse||ol,s=[],i=[],l=(f,h)=>{if(typeof f!="string")return Vt;try{return o(f)}catch(d){return s.push(`${h} side is not valid JSON (${d.message})`),Vt}},a=l(t,"local"),c=l(n,"remote");if(a===Vt)return{text:n,warnings:s,conflicts:i};if(c===Vt)return{text:t,warnings:s,conflicts:i};let p=l(e,"base"),u=mc(p===Vt?void 0:p,a,c,{...r,onConflict:f=>{i.push(f),r.onConflict?.(f)}});return Zn(u,c)?{text:n,warnings:s,conflicts:i}:Zn(u,a)?{text:t,warnings:s,conflicts:i}:{text:om(u,n),warnings:s,conflicts:i}}var pc=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Nr(e){if(!e)return!1;let{startContainer:t,startOffset:n,endContainer:r,endOffset:o}=e;if(!t||!r||!Number.isInteger(n)||!Number.isInteger(o)||n<0||o<0||n>pc(t)||o>pc(r)||t.getRootNode()!==r.getRootNode())return!1;let s=t.ownerDocument.createRange();return s.setStart(t,n),s.setEnd(r,o),s.startContainer===t&&s.startOffset===n}function ur(e,t,n={}){if(!Nr(e))return null;let{startContainer:r,startOffset:o,endContainer:s,endOffset:i}=e;if(r===s&&(r.nodeType===3||r.nodeType===8))return r.nodeValue.slice(o,i);if(r===s&&o===i)return"";let l=new Set;for(let g=r;g;g=g.parentNode)l.add(g);let a=s;for(;!l.has(a);)a=a.parentNode;let c=(g,m)=>{let k=a.ownerDocument.createRange(),S=a.ownerDocument.createRange();return k.setStart(g[0],g[1]),k.collapse(!0),S.setStart(m[0],m[1]),S.collapse(!0),k.compareBoundaryPoints(0,S)},p=(g,m=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(m)],u=[],f;if(t==="plain"){f="";let g=m=>{if(m.nodeType===3||m.nodeType===8){let k=f.length;f+=m.nodeValue,u.push({s:k,e:f.length,a:[m,0],b:[m,m.nodeValue.length],node:m})}else for(let k of m.childNodes)g(k)};g(a)}else{let g=n.blocks;if(!g){g=new Set;let k=S=>{S!==a&&S.nodeType===1&&Ji.has(S.tagName)&&g.add(S);for(let x of S.childNodes)k(x)};k(a)}let m=Qt(Array.from(a.childNodes),{blocks:g,atomize:k=>!!n.atoms?.has(k),ignored:n.ignored});f=m.text;for(let k of m.nodes)u.push({s:k.s,e:k.e,a:[k.node,0],b:[k.node,k.e-k.s],node:k.node});for(let k of m.atoms)u.push({s:k.i,e:k.i+1,a:p(k.el),b:p(k.el,!0)});for(let k=0;k<m.text.length;k++){if(m.text[k]!==Nt)continue;let S=m.marks.find(w=>w.block&&w.to===k+1),x=m.marks.find(w=>w.block&&w.from===k+1);if(S)u.push({s:k,e:k+1,a:[S.el,S.el.childNodes.length],b:p(S.el,!0)});else if(x)u.push({s:k,e:k+1,a:p(x.el),b:[x.el,0]});else return null}}u.sort((g,m)=>g.s-m.s);let h=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let k=u.find(S=>S.node===g[0]);return k?k.s+g[1]:null}let m=0;for(let k of u){if(c(g,k.a)<=0)return k.s;if(c(g,k.b)<0)return null;m=k.e}return m},d=h([r,o]),v=h([s,i]);return d!==null&&v!==null&&d<=v?f.slice(d,v):null}function Or(e,t){let n=e;for(let r of t.path)if(n=r==="content"?n?.content:n?.childNodes[r],!n)return null;return[n,t.offset]}function gc(e,t){if(!e||!t)return null;let n=Or(e,t.start),r=Or(e,t.end);return n&&r?{startContainer:n[0],startOffset:n[1],endContainer:r[0],endOffset:r[1]}:null}var bc=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function kc(e,t,n){if(!t)return;let r=new Map,o=new Map,s=l=>{if(!l)return null;if(o.has(l))return o.get(l);let c=l.local.map(p=>Or(t.localRoot,{path:p,offset:0})?.[0]).map(p=>p&&n(p)).filter(Boolean).map(p=>({node:p,parent:p.parentNode,previous:p.previousSibling,next:p.nextSibling,fragment:bc(p)}));return o.set(l,c),c},i=l=>{let a=gc(t.localRoot,l);if(!a)return null;let c=n(a.startContainer),p=n(a.endContainer);if(!c||!p)return null;let u={...a,startContainer:c,endContainer:p};return Nr(u)?u:null};for(let l of e){let a=l.recovery;if(!a||r.has(a))continue;let c={subject:s(a.subject),span:null,scope:null,touched:new Set};if(a.text){c.span=i(a.text.local.span),c.scope=i(a.text.local.scope);let p=c.span;if(p){let u=p.startContainer.ownerDocument.createRange();u.setStart(p.startContainer,p.startOffset),u.setEnd(p.endContainer,p.endOffset);let f=h=>{if(u.intersectsNode(h)){c.touched.add(h);for(let d of h.childNodes)f(d)}};f(u.commonAncestorContainer)}}if(a.structure){for(let p of[a.structure.localPlacement])p&&(s(p.parent),p.before.forEach(s),p.after.forEach(s));for(let p of a.structure.localOrder||[])s(p)}r.set(a,c)}t.localState={states:r,refs:o}}function yc(e,t,n,r){let o=n.localState?.states.get(e);if(!o)return!1;let s=l=>{let a=l.node;if(!r(a)||a.parentNode!==l.parent)return!1;let c=p=>Array.prototype.indexOf.call(a.parentNode.childNodes,p);return!(l.previous&&r(l.previous)&&l.previous.parentNode===a.parentNode&&c(l.previous)>=c(a)||l.next&&r(l.next)&&l.next.parentNode===a.parentNode&&c(l.next)<=c(a))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!o.subject.length||!o.subject.every(s))return!1;if(e.text){let l=e.text.local,a=c=>c&&r(c.startContainer)&&r(c.endContainer);return a(o.span)&&a(o.scope)&&ur(o.scope,e.text.encoding)===l.text&&ur(o.span,e.text.encoding)===l.text.slice(l.start,l.end)}if(e.attribute){let l=e.attribute,a=o.subject[0].node;return(l.namespaceURI?a.getAttributeNS(l.namespaceURI,l.localName):a.getAttribute(l.qualifiedName))===t.local}let i=e.structure;if(i.localOrder){let l=-1,a=null;for(let c of i.localOrder){let p=n.localState.refs.get(c)?.[0]?.node;if(!p||!r(p)||a&&p.parentNode!==a)return!1;let u=Array.prototype.indexOf.call(p.parentNode.childNodes,p);if(u<=l)return!1;a=p.parentNode,l=u}return!0}return i.localAction==="moved"||o.subject.every(l=>bc(l.node)===l.fragment)}var sm=1,dn=e=>!!e&&e.nodeType===1,_s=e=>dn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function Cr(e,t=null,n=null){let r=new Map,o=new Map,s=p=>{if(!t){t=new WeakMap;let u=[e];for(;u.length;){let f=u.pop();_s(f)&&(t.set(f.content,f),u.push(f.content));for(let h=f.firstChild;h;h=h.nextSibling)h.nodeType===1&&u.push(h)}}return t.get(p)||null},i=(p,u)=>{let f=o.get(p);if(!f){f=new Map;let h=0;for(let d=p.firstChild;d;d=d.nextSibling)f.set(d,h++);o.set(p,f)}return f.get(u)},l=p=>{if(!p)return null;if(n&&n.has(p))return l(n.get(p));if(p===e)return[];let u=r.get(p);if(u!==void 0)return u;let f=p.parentNode,h=null;if(f&&f.nodeType===11){let d=s(f),v=d?l(d):null;v&&(h=v.concat(["content",i(f,p)]))}else if(f){let d=l(f);d&&(h=d.concat([i(f,p)]))}return r.set(p,h),h};return{root:e,pathOf:l,logicalParent:p=>{let u=p.parentNode;return u&&u.nodeType===11?s(u):u},indexIn:i,containerPath:p=>{if(p.nodeType===11){let f=s(p),h=l(f);return h?h.concat(["content"]):null}let u=l(p);return u&&_s(p)?u.concat(["content"]):u},ownerOf:s}}var In=e=>_s(e)?e.content:e;function vc(e){let{L:t,R:n,unitsOf:r,provenance:o,policy:s}=e,i=[];return{note:(p,u)=>{i.push([p,u])},finish:p=>i.length?c(p):null};function c(p){let u={base:Cr(e.roots.base),local:Cr(e.roots.local),remote:Cr(e.roots.remote)},f=Y=>Y==="local"?t:n,h=(Y,y)=>{if(!y)return null;if(Y.map.has(y))return Y.map.get(y);let M=[],P=dn(y)?u.base.logicalParent(y):y.parent;for(;P&&!Y.map.has(P);P=u.base.logicalParent(P))M.push(P);if(!P||!Y.identical.has(P))return null;let H=Y.map.get(P);for(let Q=M.length-1;Q>=0&&H;Q--)H=In(H).childNodes[u.base.indexIn(M[Q].parentNode,M[Q])];return H?dn(y)?In(H).childNodes[u.base.indexIn(y.parentNode,y)]||null:r(H)[r(y.parent).indexOf(y)]||null:null},d=new Map,v=new Map,g=new WeakMap,m=0,k=(Y,y)=>{let M=d.get(Y);M||d.set(Y,M=[]),M.push(y)};(function Y(y){v.set(y,m++);let M=o.get(y);if(M&&!M.pinned){for(let P of[M.base,M.local,M.remote])if(P)if(Array.isArray(P))for(let H of P)k(H,y);else k(P,y)}if(_s(y)){g.set(y.content,y);for(let P=y.content.firstChild;P;P=P.nextSibling)Y(P)}for(let P=y.firstChild;P;P=P.nextSibling)Y(P)})(p);let S=new Map;u.out=Cr(p,g,S);let x={refs:new Map,spans:new Map,anchors:new Map,via:S,outOwners:g,outRoot:p,localRoot:e.roots.local},w=Y=>dn(Y)?[Y]:Y.nodes,T=(Y,y)=>{let M=u[y].logicalParent(Y);if(!M)return null;for(let P of r(M))if(!dn(P)&&P.nodes.includes(Y))return P;return null},N=(Y,y)=>Y==null?null:Array.isArray(Y)?Y.length?T(Y[0],y):null:Y,C=Y=>{let y=new Set,M=[];for(let P of Y)for(let H of d.get(P)||[])y.has(H)||(y.add(H),M.push(H));return M.sort((P,H)=>v.get(P)-v.get(H))},I=new Map,q=Y=>{let y=Y.b||Y.l||Y.r,M=I.get(y);if(M)return M;let P=[];for(let H of[Y.b,Y.l,Y.r])H&&P.push(...w(H));return M=C(P),I.set(y,M),M},V=Y=>({b:Y,l:h(t,Y),r:h(n,Y)}),U=(Y,y)=>{let M=f(y).reverse.get(Y);if(M)return V(M);for(let P of C(w(Y))){let H=o.get(P);if(H&&!H.base&&H.local&&H.remote)return{b:null,l:N(H.local,"local"),r:N(H.remote,"remote")}}return y==="local"?{b:null,l:Y,r:null}:{b:null,l:null,r:Y}},F=new Map,A=Y=>{let y=o.get(Y);if(!y||y.pinned)return null;let M=N(y.base,"base");if(M)return V(M);let P=N(y.local,"local"),H=N(y.remote,"remote");if(P){let Q=t.reverse.get(P);if(Q)return V(Q)}if(H){let Q=n.reverse.get(H);if(Q)return V(Q)}return P||H?{b:null,l:P,r:H}:null},E=Y=>(F.has(Y)||F.set(Y,A(Y)),F.get(Y)),X=(Y,y)=>dn(Y)?u[y].logicalParent(Y):Y.parent,B=new Map,z=new Map,Ce=(Y,y)=>(dn(Y)?[u[y].pathOf(Y)]:Y.nodes.map(M=>u[y].pathOf(M))).filter(Boolean),Me=Y=>{let y=Y.b||Y.l||Y.r,M=Y.b?"base":Y.l?"local":"remote",P=z.get(y);if(P)return P;let H=!dn(y),Q=Ce(y,M)[0],D=`${M[0]}:${JSON.stringify(Q===void 0?null:Q)}${H?":run":""}`,ge=B.get(D);if(ge)return z.set(y,ge),ge;let xe=q(Y);return ge={key:D,nodeType:dn(y)?1:y.kind==="comment"?8:3,base:Y.b?Ce(Y.b,"base"):[],local:Y.l?Ce(Y.l,"local"):[],remote:Y.r?Ce(Y.r,"remote"):[],merged:xe.map(de=>u.out.pathOf(de)).filter(Boolean),live:[]},B.set(D,ge),z.set(y,ge),x.refs.set(ge,xe),ge},Be={base:new Map,local:new Map,remote:new Map},me=new Map,Te=(Y,y)=>{let M=X(Y,y);if(!M||M.nodeType!==1)return null;let P=Be[y].get(M);if(!P){let Q=r(M),D=ge=>Me(y==="base"?V(ge):U(ge,y));P={parent:D(M),refs:Q.map(D),index:new Map(Q.map((ge,xe)=>[ge,xe]))},Be[y].set(M,P)}let H=P.index.get(Y)??-1;return{parent:P.parent,before:P.refs.slice(H+1),after:P.refs.slice(0,Math.max(0,H)).reverse()}},Xe=Y=>{let y=Y.parentNode;if(!y)return null;let M=me.get(y);if(!M){let H=y.nodeType===11?g.get(y):y,Q=H&&H.nodeType===1?E(H):null;if(!Q)return null;let D=[],ge=[],xe=new Map;for(let Oe of y.childNodes){let $=E(Oe),Z=$&&Me($),ke=D.length,we=D.length-1;Z&&Z!==D[we]&&(D.push(Z),we++);let ve={ref:Z,group:we,after:ke};ge.push(ve),xe.set(Oe,ve)}let de=D.length;for(let Oe=ge.length-1;Oe>=0;Oe--){let $=ge[Oe];$.before=de,$.ref&&(de=$.group)}M={parent:Me(Q),refs:D,index:xe},me.set(y,M)}let P=M.index.get(Y);return{parent:M.parent,before:M.refs.slice(P.before),after:M.refs.slice(0,P.after).reverse()}},_e=Y=>dn(Y)?Y.outerHTML:Y.value,O=Y=>dn(Y)?"element":Y.kind==="comment"?"comment":"text",K=(Y,y)=>({path:Y,offset:y}),fe=(Y,y,M)=>{if(!Y)return null;let P=u[M],H=0;if(y){let Q=dn(y)?y:y.nodes[y.nodes.length-1];Q.parentNode&&(H=P.indexIn(Q.parentNode,Q)+1)}return K(P.containerPath(Y),H)},ae=(Y,y)=>{let M=X(Y,"base"),P=M?h(f(y),M):null;if(!dn(P))return null;let H=r(M),Q=null;for(let D=H.indexOf(Y)-1;D>=0&&!Q;D--){let ge=h(f(y),H[D]);ge&&X(ge,y)===P&&(Q=ge)}return fe(P,Q,y)},qe=(Y,y,M,P)=>{let H=u[P],Q=0;for(let D=0;D<Y.nodes.length;D++){let ge=Y.nodes[D],xe=ge.nodeValue.length,de=D===Y.nodes.length-1;if((M==="start"?y<Q+xe:y<=Q+xe)||de)return K(H.pathOf(ge),Math.max(0,Math.min(y-Q,xe)));Q+=xe}return null},ze=(Y,y)=>{let M=u[y],P=Y.firstChild,H=Y.lastChild;return P&&P.nodeType===3&&H.nodeType===3?{start:K(M.pathOf(P),0),end:K(M.pathOf(H),H.nodeValue.length)}:{start:K(M.pathOf(Y),0),end:K(M.pathOf(Y),Y.childNodes.length)}},Ee=(Y,y,M)=>{for(let D of Y.nodes)if(M==="start"?D.s<=y&&y<D.e:D.s<y&&y<=D.e)return{kind:"text",node:D.node,offset:y-D.s};let P=M==="start"?y:y-1,H=()=>{for(let D of Y.nodes)if(D.s===y||D.e===y)return{kind:"text",node:D.node,offset:y-D.s};return null},Q=Y.atomAt.get(P);if(Q)return{kind:M==="start"?"before":"after",node:Q.el};if(Y.text[P]===Nt){let D=Y.marks.find(xe=>xe.block&&xe.to===P+1);if(D)return M==="start"?{kind:"end",node:D.el}:{kind:"after",node:D.el};let ge=Y.marks.find(xe=>xe.block&&xe.from===P+1);if(ge)return M==="start"?{kind:"before",node:ge.el}:{kind:"startOf",node:ge.el}}return H()},ot=(Y,y)=>Ee(Y,y,"end")||Ee(Y,y,"start"),rt=(Y,y)=>{switch(y.kind){case"text":return K(Y.pathOf(y.node),y.offset);case"end":return K(Y.containerPath(y.node),In(y.node).childNodes.length);case"startOf":return K(Y.containerPath(y.node),0);default:{let M=y.node.parentNode;return K(Y.containerPath(M),Y.indexIn(M,y.node)+(y.kind==="after"?1:0))}}},xt=(Y,y,M,P,H)=>{let Q=Ee(Y,y,M);return Q?rt(u[P],Q):H()},nt=(Y,y,M,P)=>{let H=Y.textNodes.map(de=>({s:de.ms,e:de.me,start:{kind:"text",node:de.node,offset:0},end:{kind:"text",node:de.node,offset:de.me-de.ms}}));for(let[de,Oe]of Y.atomOut)H.push({s:de,e:de+1,start:{kind:"before",node:Oe},end:{kind:"after",node:Oe}});for(let[de,Oe]of Y.breakOut)H.push({s:de,e:de+1,start:{kind:"end",node:Oe},end:{kind:"after",node:Oe}});for(let de of H)if(de.start.kind==="text"&&de.s<y&&y<de.e)return{kind:"text",node:de.start.node,offset:y-de.s};if(M!=="empty"){let de=H.find(Oe=>M==="start"?Oe.s===y:Oe.e===y);if(de)return M==="start"?de.start:de.end}let Q=H.find(de=>de.e===y);if(Q)return Q.end;let D=H.find(de=>de.s===y);if(D)return D.start;let ge=null,xe=null;for(let de of H)de.e<=y&&(!ge||de.e>ge.e)&&(ge=de),de.s>=y&&(!xe||de.s<xe.s)&&(xe=de);return ge?ge.end:xe?xe.start:P()},te=(Y,y)=>{if(!y)return null;if(y.kind==="text"){let H=Y.nodes.find(Q=>Q.node===y.node);return H?H.s+Math.min(y.offset,H.e-H.s):null}let M=Y.atoms.find(H=>H.el===y.node);if(M)return y.kind==="after"?M.i+1:M.i;let P=Y.marks.find(H=>H.el===y.node);return P?y.kind==="before"&&P.block&&Y.text[P.from-1]===Nt&&!Y.marks.some(H=>H.block&&H.to===P.from)?P.from-1:y.kind==="startOf"||y.kind==="before"?P.from:y.kind==="end"&&P.block?P.to-1:P.to:null},Ae=(Y,y,M,P)=>{for(let ge of Y.nodes)if(M==="start"?ge.s<=y&&y<ge.e:ge.s<y&&y<=ge.e)return{kind:"text",node:ge.node,offset:y-ge.s};let H=M==="start"?y:y-1;if(!Y.atomAt.has(H)&&Y.text[H]!==Nt){for(let ge of Y.nodes)if(ge.s===y||ge.e===y)return{kind:"text",node:ge.node,offset:y-ge.s}}let Q=Y.atomAt.get(H);if(Q)return{kind:M==="start"?"before":"after",node:Q.el};if(Y.text[H]===Nt){let ge=Y.marks.find(de=>de.block&&de.to===H+1);if(ge)return M==="start"?{kind:"end",node:ge.el}:{kind:"after",node:ge.el};let xe=Y.marks.find(de=>de.block&&de.from===H+1);if(xe)return M==="start"?{kind:"before",node:xe.el}:{kind:"startOf",node:xe.el}}let D=Y.marks.find(ge=>ge.block&&ge.from===y);return D?{kind:"startOf",node:D.el}:P?{kind:M==="start"?"startOf":"end",node:P}:null},je=Y=>{if(!Y)return null;if(Y.kind==="wholeStart"||Y.kind==="wholeEnd"){let y=Fe(Y.node);return Y.kind==="wholeStart"?y.start:y.end}return rt(u.out,Y)},Fe=Y=>{let y=Y.firstChild,M=Y.lastChild;return y&&y.nodeType===3&&M.nodeType===3?{start:K(u.out.pathOf(y),0),end:K(u.out.pathOf(M),M.nodeValue.length)}:{start:K(u.out.pathOf(Y),0),end:K(u.out.pathOf(Y),Y.childNodes.length)}},He=Y=>{let y=X(Y,"base"),M=y?q(V(y))[0]:null;if(!M)return null;let P=In(M),H=r(y);for(let Q=H.indexOf(Y)-1;Q>=0;Q--){let D=q(V(H[Q])).filter(ge=>ge.parentNode===P);if(D.length)return{kind:"after",node:D[D.length-1]}}return{kind:"startOf",node:M}},et=(Y,y,M,P,H,Q)=>({text:Y,start:y,end:M,fragment:P,span:H,scope:Q}),bt=(Y,y,M,P,H)=>et(Y,y,M,Y.slice(y,M),P,H),Ft=(Y,y,M,P,H)=>(x.spans.set(Y,{start:y,end:M,scopeStart:P,scopeEnd:H}),Y),yt=new Map,Lt=new Map,en=(Y,y,M)=>{let P=`text:${Y.key}:${y}:${M}`,H=Lt.get(P)||0;return Lt.set(P,H+1),`${P}:${H}`},Ge=(Y,y)=>{let M,P,H,Q="plain",D,ge,xe,de,Oe,$=(we,ve,ne,se,W)=>{if(!we){let ce=ae(W,se);return bt("",0,0,{start:ce,end:ce},{start:ce,end:ce})}return bt(we.value,ve,ne,{start:qe(we,ve,ve===ne?"end":"start",se),end:qe(we,ne,"end",se)},{start:qe(we,0,"start",se),end:qe(we,we.value.length,"end",se)})};if(y.site==="run"){let{bRun:we,lRun:ve,rRun:ne,node:se,c:W}=y;M=V(we),P=W.bs,H=W.be,D=$(we,W.bs,W.be,"base",we),ge=$(ve,W.ls,W.le,"local",we),xe=$(ne,W.rs,W.re,"remote",we);let ce=se?se.nodeValue:"",Ne=Pe=>se?{kind:"text",node:se,offset:Pe}:He(we);de=Ft(bt(ce,W.ms,W.me,{start:je(Ne(W.ms)),end:je(Ne(W.me))},{start:je(Ne(0)),end:je(Ne(ce.length))}),Ne(W.ms),Ne(W.me),Ne(0),Ne(ce.length)),Oe=se||(He(we)||{}).node||null}else if(y.site==="whole"){let we=y.el,ve=o.get(we);M=V(ve.base),P=0,H=Y.base.length;let ne=(W,ce,Ne)=>{let Pe=ze(ce,Ne);return bt(W,0,W.length,Pe,Pe)};D=ne(Y.base,ve.base,"base"),ge=ne(Y.local,ve.local,"local"),xe=ne(Y.remote,ve.remote,"remote");let se=Fe(we);de=Ft(bt(Y.resolved,0,Y.resolved.length,se,se),{kind:"wholeStart",node:we},{kind:"wholeEnd",node:we},{kind:"wholeStart",node:we},{kind:"wholeEnd",node:we}),Oe=we}else if(y.site==="comment"){let{bRun:we,lRun:ve,rRun:ne,node:se}=y;M=V(we),P=0,H=Y.base.length;let W=(De,Se)=>{if(!De){let it=ae(we,Se);return bt("",0,0,{start:it,end:it},{start:it,end:it})}let tt=De.nodes[0],lt={start:K(u[Se].pathOf(tt),0),end:K(u[Se].pathOf(tt),De.value.length)};return bt(De.value,0,De.value.length,lt,lt)};D=W(we,"base"),ge=W(ve,"local"),xe=W(ne,"remote");let ce=Y.resolved,Ne=De=>se?{kind:"text",node:se,offset:De}:He(we),Pe={start:je(Ne(0)),end:je(Ne(ce.length))};de=Ft(bt(ce,0,ce.length,Pe,Pe),Ne(0),Ne(ce.length),Ne(0),Ne(ce.length)),Oe=se||(He(we)||{}).node||null}else{let{fb:we,fl:ve,fr:ne,scope:se}=y,W=y.merged;Q="html",M=se.base?V(se.base):U(se.local,"local"),P=Y.bs,H=Y.be;let ce=he=>{let le=se[he];for(let ee=se.at-1;ee>=0;ee--){let ie=se.units[ee],Re=he==="base"?ie:h(f(he),ie);if(Re&&X(Re,he)===le)return Re}return null},Ne=he=>()=>fe(se[he],ce(he),he),Pe=(he,le,ee,ie,Re)=>{let We=Rt=>Rt?rt(u[Re],Rt):Ne(Re)(),Je=le===ee?ot(he,le):Ee(he,le,"start"),at=le===ee?ot(he,le):Ee(he,ee,"end"),dt=We(Je),ht={start:dt,end:le===ee?dt:We(at)},ft=y.full?y.full(Re):null;if(!ft)return et(he.text,le,ee,ie,ht,{start:We(Ee(he,0,"start")),end:We(Ee(he,he.text.length,"end"))});let Mt=Je?te(ft,Je):null,_t=at?te(ft,at):null,Pt=Mt===null?0:Mt,Ye=Math.max(Pt,_t===null?ft.text.length:_t),St=We(Ee(ft,0,"start"));return et(ft.text,Pt,Ye,Yr(ft,Pt,Ye),ht,{start:St,end:ft.text.length?We(Ee(ft,ft.text.length,"end")):St})};D=y.synthetic?null:Pe(we,Y.bs,Y.be,Y.base,"base"),ge=Pe(ve,Y.lss,Y.lse,Y.local,"local"),xe=Pe(ne,Y.rss,Y.rse,Y.remote,"remote");let[De,Se]=Y.range||[0,0],tt=W.out,lt=()=>{let he=In(W.node);for(let le=se.at-1;le>=0;le--){let ee=q(V(se.units[le])).filter(ie=>ie.parentNode===he);if(ee.length)return{kind:"after",node:ee[ee.length-1]}}for(let le=se.at;le<se.units.length;le++){let ee=q(V(se.units[le])).filter(ie=>ie.parentNode===he);if(ee.length)return{kind:"before",node:ee[0]}}return{kind:"startOf",node:W.node}};if(tt.via)for(let[he,le]of tt.via)S.set(he,le);let it=nt(W,De,De===Se?"empty":"start",lt),Ht=De===Se?it:nt(W,Se,"end",lt),It=tt.text.length?Ae(tt,0,"start",W.node):lt(),Zt=tt.text.length?Ae(tt,tt.text.length,"end",W.node):It,Bt=te(tt,it),Wt=te(tt,Ht),R=Bt===null?0:Bt,J=Math.max(R,Wt===null?tt.text.length:Wt);de=Ft(et(tt.text,R,J,Yr(tt,R,J),{start:je(it),end:je(Ht)},{start:je(It),end:je(Zt)}),it,Ht,It,Zt);let ue=x.spans.get(de);if(ue.flat=tt,!tt.text.length){let he=je(It),le=Or(p,he),ee=le[0],ie=le[1];ue.empty={parent:ee.nodeType===11?g.get(ee):ee,previous:ee.childNodes[ie-1]||null,next:ee.childNodes[ie]||null}}Oe=it?it.node:W.node}let Z=Me(M),ke=(y.site==="whole"||y.site==="comment"||(y.policy||s)!=="both")&&Y.resolved!==Y.local;return{key:y.site==="comment"&&yt.get(M.b||M.l||M.r)||en(Z,P,H),subject:Z,localLost:ke,anchor:Oe,text:{encoding:Q,base:D,local:ge,remote:xe,merged:de,liveSpan:null,liveScope:null}}},Ct=(Y,y)=>{let M=E(y.el),P=Me(M),H=y.sample;return{key:`attr:${P.key}:${H.namespaceURI||""}:${H.localName}`,subject:P,localLost:Y.resolved!==Y.local,anchor:y.el,attribute:{namespaceURI:H.namespaceURI||null,localName:H.localName,qualifiedName:H.name}}},Et=(Y,y)=>{let M=Y.detail,P=y.unit||V(y.subject),H=Me(P),Q=x.refs.get(H),D=P.l?Te(P.l,"local"):null,ge=P.r?Te(P.r,"remote"):null,xe=Q.length?Xe(Q[0]):null,de,Oe,$,Z=null,ke=null,we=y.deleted;switch(M){case"both-reordered":{de=Oe="reordered";let ve=new Set(y.rKept),ne=y.lKept.filter(Pe=>ve.has(Pe)&&q(V(Pe)).length),se=Pe=>v.get(q(V(Pe))[0]);Z=ne.map(Pe=>Me(V(Pe))),ke=ne.slice().sort((Pe,De)=>se(Pe)-se(De)).map(Pe=>Me(V(Pe)));let W=Pe=>!dn(Pe)&&Pe.kind!=="comment"&&Pe.nodes.every(De=>!/[^\t\n\f\r ]/.test(De.data)),ce=ne.filter(Pe=>!W(Pe)),Ne=ce.slice().sort((Pe,De)=>se(Pe)-se(De));$=ce.some((Pe,De)=>Pe!==Ne[De]);break}case"both-moved":de=Oe="moved",$=!D||!Q.some(ve=>{let ne=ve===Q[0]?xe:Xe(ve);return ne&&ne.parent===D.parent});break;case"edit-beats-delete":de=we==="local"?"deleted":"edited",Oe=we==="remote"?"deleted":"edited",$=we==="local";break;case"move-beats-delete":de=we==="local"?"deleted":"moved",Oe=we==="remote"?"deleted":"moved",$=we==="local";break;case"remote-wins":de="edited",Oe="edited",$=!0;break;default:de=Oe="inserted",$=y.localLost}return{key:`structure:${H.key}:${M}`,subject:H,localLost:$,anchor:Q[0]||null,structure:{localAction:de,remoteAction:Oe,localPlacement:D,remotePlacement:ge,mergedPlacement:xe,localOrder:Z,mergedOrder:ke,localFragment:M==="both-reordered"||!P.l?null:_e(P.l),fragmentKind:O(P.b||P.l||P.r)}}};for(let[Y,y]of i){if(Y.kind!=="structure")continue;let M=y.unit||V(y.subject),P=M.b||M.l||M.r;!dn(P)&&P.kind==="comment"&&yt.set(P,`structure:${Me(M).key}:${Y.detail}`)}let Jt=new Map;for(let[Y,y]of i){if(Y.kind==="structure"){let Q=Me(y.unit||V(y.subject)),D=`structure:${Q.key}:${Y.detail}`,ge=Jt.get(D);if(ge&&ge.structure){Y.recovery=ge;let xe=x.refs.get(Q);Y.el==null&&xe.length&&(Y.el=dn(xe[0])?xe[0]:u.out.logicalParent(xe[0]));continue}}let M=Y.kind==="text"?Ge(Y,y):Y.kind==="attr"?Ct(Y,y):Et(Y,y),P=Jt.get(M.key);P||(P={version:sm,key:M.key,localLost:M.localLost,subject:M.subject,applied:!1,unavailable:null},Jt.set(M.key,P),x.anchors.set(P,M.anchor)),M.text&&(P.text=M.text),M.attribute&&(P.attribute=M.attribute),M.structure&&(P.structure=M.structure),M.text&&(P.localLost=M.localLost),Y.recovery=P;let H=x.refs.get(M.subject);Y.kind==="structure"&&Y.el==null&&H.length&&(Y.el=dn(H[0])?H[0]:u.out.logicalParent(H[0])),Y.kind==="text"&&Y.node==null&&H.length&&M.subject.nodeType===8&&(Y.node=H[0])}return x}}function xc(e,t,n){if(!t)return;let{lookup:r,vetoed:o,vetoedAttrs:s,liveAttr:i}=n,l=n.ignored||(()=>!1),a=Cr(n.liveRoot),c=A=>!!A&&a.containerPath(A)!==null,p=A=>{let E=A.parentNode;return E&&E.nodeType===11?t.outOwners.get(E)||null:E},u=A=>{for(let E=A;E;E=p(E))if(t.via.has(E)&&(E=t.via.get(E)),o.has(E)||n.vetoedLive?.has(m(E)))return!0;return!1},f=A=>Array.from(In(A).children).filter(E=>!l(E)),h=(A,E)=>f(A)[f(E.parentNode).indexOf(E)],d=(A,E)=>{let X=null,B=null,z=0;for(let me=E.previousSibling;me;me=me.previousSibling){if(me.nodeType===1&&!l(me)){X=me;break}me.nodeType===3&&(z+=me.nodeValue.length)}for(let me=E.nextSibling;me&&!B;me=me.nextSibling)me.nodeType===1&&!l(me)&&(B=me);let Ce=X?h(A,X):null,Me=B?h(A,B):null;if(X&&!Ce||B&&!Me)return null;let Be=[];for(let me=Ce?Ce.nextSibling:In(A).firstChild;me&&me!==Me;me=me.nextSibling)me.nodeType===3&&Be.push(me);return Be.length?{nodes:Be,lead:z}:null},v=A=>{let E=[],X=A;for(;X&&!t.via.has(X);X=X.parentNode)E.push(X);if(!X||!E.length)return null;let B=m(t.via.get(X));for(let Me=E.length-1;Me>0&&B;Me--)B=h(B,E[Me]);if(!B)return null;let z=E[0];if(z.nodeType===3)return d(B,z);let Ce=z.nodeType===1?h(B,z):null;return Ce?{nodes:[Ce],lead:0}:null},g=A=>{let E=r(A),X=E?{nodes:Array.isArray(E)?E:[E],lead:0}:t.via.size?v(A):null;if(!X)return null;let B=X.nodes.filter(c);return B.length?{nodes:B,lead:X.lead}:null},m=A=>{let E=g(A);return E?E.nodes[0]:null},k=A=>{if(!A)return null;if(A.kind==="text"){let z=g(A.node);if(!z)return null;let Ce=z.nodes,Me=A.offset+z.lead,Be=0;for(let me=0;me<Ce.length;me++){let Te=Ce[me].nodeValue.length;if(Me<=Be+Te||me===Ce.length-1)return Me>=Be&&Me<=Be+Te?[Ce[me],Me-Be]:null;Be+=Te}return null}let E=m(A.node);if(!E)return null;if(A.kind==="end")return[In(E),In(E).childNodes.length];if(A.kind==="startOf")return[In(E),0];if(A.kind==="wholeStart")return E.firstChild?[E.firstChild,0]:[E,0];if(A.kind==="wholeEnd")return E.lastChild?[E.lastChild,E.lastChild.nodeValue.length]:[E,E.childNodes.length];let X=E.parentNode;if(!X)return null;let B=Array.prototype.indexOf.call(X.childNodes,E);return[X,A.kind==="after"?B+1:B]},S=A=>({blocks:new Set((A.flat?.marks||[]).filter(E=>E.block).map(E=>m(E.el)).filter(Boolean)),atoms:new Set((A.flat?.atoms||[]).map(E=>m(E.el)).filter(Boolean)),ignored:l}),x=(A,E,X,B)=>{if(!A||!E||!Nr(A)||!Nr(E))return!1;for(let Me of[A,E])if(!c(Me.startContainer)||!c(Me.endContainer))return!1;let z=X.merged;if(z.start===z.end&&(A.startContainer!==A.endContainer||A.startOffset!==A.endOffset))return!1;let Ce=S(B);return ur(E,X.encoding,Ce)===z.text&&ur(A,X.encoding,Ce)===z.text.slice(z.start,z.end)},w=new Map,T=A=>{let E=A.parentNode;return E?(w.has(E)||w.set(E,new Map(Array.from(E.childNodes,(X,B)=>[X,B]))),w.get(E).get(A)):-1},N=(A,E)=>{if(!E)return!1;let X=a.logicalParent(A);if(!E.parent.live.includes(X))return!1;let B=T(A);for(let[z,Ce]of[["before",1],["after",-1]]){let Me=B;for(let Be of E[z]){if(Be.live.includes(A))continue;let me=Be.live.filter(Xe=>Xe!==A&&Xe.parentNode===A.parentNode);if(!me.length)continue;let Te=Ce===1?Math.min(...me.map(T)):Math.max(...me.map(T));if(Ce*(Te-Me)<=0)return!1;Me=Te}}return!0},C=A=>{let E=A.structure;if(E.mergedOrder){let X=new Set(A.subject.live.map(In)),B=null,z=-1;for(let Ce of E.mergedOrder){let Me=Ce.live.find(Be=>X.has(Be.parentNode));if(!Me||B&&Me.parentNode!==B||T(Me)<=z)return!1;B=Me.parentNode,z=T(Me)}return A.subject.live.length>0}return A.subject.live.some(X=>N(X,E.mergedPlacement))},I=(A,E)=>{let X=k(A),B=k(E);return X&&B?{startContainer:X[0],startOffset:X[1],endContainer:B[0],endOffset:B[1]}:null},q=new Set,V=A=>{if(!A||q.has(A))return;q.add(A);let E=[];for(let X of t.refs.get(A)||[]){let B=g(X);if(B)for(let z of B.nodes)E.includes(z)||E.push(z)}A.live=E},U=A=>{A&&(V(A.parent),A.before.forEach(V),A.after.forEach(V))},F=new Set;for(let A of e){let E=A.recovery;if(!E||F.has(E))continue;F.add(E),V(E.subject),E.structure&&(U(E.structure.localPlacement),U(E.structure.remotePlacement),U(E.structure.mergedPlacement),(E.structure.localOrder||[]).forEach(V),(E.structure.mergedOrder||[]).forEach(V));let X=t.anchors.get(E),B=X?m(X):null,z=!!B;if(E.text){let K=t.spans.get(E.text.merged),fe=K?I(K.start,K.end):null,ae=K?I(K.scopeStart,K.scopeEnd):null;if(K?.empty){let qe=K.empty,ze=qe.previous?{kind:"after",node:qe.previous}:{kind:"startOf",node:qe.parent},Ee=qe.next?{kind:"before",node:qe.next}:{kind:"end",node:qe.parent},ot=I(ze,Ee);!ot||ot.startContainer!==ot.endContainer||ot.startOffset!==ot.endOffset?fe=null:fe=ae=ot}x(fe,ae,E.text,K)||(fe=ae=null),E.text.liveSpan=fe,E.text.liveScope=fe?ae:null,fe||(z=!1)}E.structure&&z&&(z=C(E)),E.attribute&&z&&(z=i(B,E.attribute,A.resolved));let Ce=K=>K?.tagName==="TEXTAREA"?K:K?.parentNode?.tagName==="TEXTAREA"?K.parentNode:null,Me=(!!E.attribute||!!E.text&&!!(Ce(B)||Ce(X)))&&!!s&&[X,B,Ce(B),Ce(X)].some(K=>s.get(K)?.has(E.attribute?E.attribute.qualifiedName:"value")),Be=t.localState?.states.get(E),me=!!E.text&&[...n.removedVetoes||[]].some(K=>Be?.touched.has(K)),Te=E.structure?.localAction==="inserted"&&[...o].some(K=>K===X||X?.contains(K)),Xe=X&&u(X)||Me||me||Te,_e=Xe&&yc(E,A,t,c);_e&&(me||Te&&E.localLost)&&(z=!1);let O=!z&&_e&&Xe;E.applied=z,E.unavailable=z?null:O?"hook-veto":"missing-output",O&&(E.localLost=!1),!z&&E.text&&(E.text.liveSpan=E.text.liveScope=null)}}function Ms(e,t,n){let r=Cr(t),o=Cr(n),s=u=>!!u&&o.containerPath(u)!==null,i=u=>{if(u===t)return n;let f=r.pathOf(u);if(f&&t!==n){let h=Or(n,{path:f,offset:0});if(h&&h[0].nodeType===u.nodeType)return h[0]}return u},l=new Set,a=u=>{!u||l.has(u)||(l.add(u),u.live=u.live.map(i).filter(s))},c=u=>{u&&(u.startContainer=i(u.startContainer),u.endContainer=i(u.endContainer))},p=new Set;for(let u of e){u.node===t&&n.tagName==="SCRIPT"&&(u.node=n),u.el===t&&u.kind==="structure"&&(u.el=n);let f=u.recovery;if(!f||p.has(f))continue;if(p.add(f),a(f.subject),f.text){c(f.text.liveSpan),c(f.text.liveScope);let d=f.text.liveSpan,v=f.text.liveScope,g=f.text.merged,m=k=>!!k&&Nr(k)&&s(k.startContainer)&&s(k.endContainer);(!m(d)||!m(v)||ur(v,f.text.encoding)!==g.text||ur(d,f.text.encoding)!==g.text.slice(g.start,g.end))&&(f.text.liveSpan=null,f.text.liveScope=null,f.applied=!1,f.unavailable="missing-output")}let h=f.structure;if(h){for(let d of[h.localPlacement,h.remotePlacement,h.mergedPlacement])d&&(a(d.parent),d.before.forEach(a),d.after.forEach(a));(h.localOrder||[]).forEach(a),(h.mergedOrder||[]).forEach(a),f.subject.live.length||(f.applied=!1,f.unavailable="missing-output")}}}var eo=e=>e?.nodeType===1,Uo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function im({provenance:e,parentOf:t,twins:n,baseOf:r,build:o,ignored:s,remoteWins:i,discarded:l}){let a=new Map,c=new WeakMap;function p(h,d,v,g=!1){if(!eo(h)||!eo(v))return null;let m=a.get(h);if(m)(g||!m.selected&&d==="remote")&&(m.parent=t(v),m.port=v,m.sourceSide=d,m.selected=g);else{let k=c.get(h)||null;m={owner:h,parent:t(v),port:v,sourceSide:d,originalParent:t(h),originalPort:h,selected:g,state:k?"built":"planned",output:k,disposition:null},a.set(h,m)}return m}function u(h,d){if(!eo(h)||!eo(d))return;c.has(h)||c.set(h,d);let v=a.get(h);v&&v.state!=="attached"&&!v.output&&(v.output=d,v.state="built")}function f(h){if(!a.size)return;let d=new Map,v=new WeakMap,g=new WeakMap,m=new WeakSet,k=new Set,S=(U,F)=>{if(!U)return;if(Array.isArray(U)){for(let E of U)S(E,F);return}let A=d.get(U);A||d.set(U,A=[]),A.push(F)},x=(U,F)=>{if(!U)return;let A=[U];for(;A.length;){let E=A.pop();S(E,F);for(let X of Uo(E).childNodes)A.push(X)}};function w(U,F=null,A=!1){if(m.has(U))return;m.add(U),v.set(U,F);let E=e.get(U),X=A||!!(E&&i(E.remote||E.base));g.set(U,X);let B={node:U,kind:"node",authority:X};if(E?.pinned)x(E.local,{...B,kind:"ignored"});else if(E?.unchanged)for(let z of[E.base,E.local,E.remote])x(z,{...B,kind:"unchanged"});else if(E){for(let z of[E.base,E.local,E.remote])S(z,B);if(eo(E.local))for(let z of Uo(E.local).children)s(z)&&x(z,{...B,kind:"ignored"})}for(let z of Uo(U).childNodes)w(z,U,X)}let T=U=>{if(U.output&&m.has(U.output))return U.state="attached",U.disposition="node",!0;let{local:F,remote:A}=n(U.owner);for(let E of[U.owner,F,A]){let X=d.get(E);if(X?.length){let B=X.find(z=>z.kind==="node")||X[0];return U.output=B.node,U.state="attached",U.disposition=B.kind,!0}}return!1},N=(U,F)=>(d.get(U)||[]).find(E=>E.kind==="node"&&eo(E.node)&&(!E.authority||F.sourceSide==="remote"))?.node,C=(U,F,A)=>{let E=d.get(U)||[],X=A?[...E].reverse():E;for(let B of X){if(B.kind!=="node")continue;let z=B.node;for(;z&&v.get(z)!==F;)z=v.get(z);if(z)return z}return null},I=(U,F,A)=>{let E=Uo(F);for(let X=A?.previousSibling;X;X=X.previousSibling){let B=C(X,F,!0);if(B){E.insertBefore(U,B.nextSibling);return}}for(let X=A?.nextSibling;X;X=X.nextSibling){let B=C(X,F,!1);if(B){E.insertBefore(U,B);return}}E.appendChild(U)};function q(U,F,A){let E=F==="base"?U:r(U,F),X=a.get(E);X&&X!==A&&V(X)}function V(U){if(U.state==="attached"||U.disposition==="remote-wins"||k.has(U)||T(U))return;k.add(U);let{local:F,remote:A}=n(U.owner);if(i(A||U.owner)){if(!A){U.disposition="remote-wins",l(U.owner,F),k.delete(U);return}U.parent=t(A),U.port=A,U.sourceSide="remote"}if(q(U.parent,U.sourceSide,U),T(U)){k.delete(U);return}let E=N(U.parent,U),X=U.port;if(!E){if(q(U.originalParent,"base",U),T(U)){k.delete(U);return}let z=U.originalParent;for(X=U.originalPort;z&&!E;)E=N(z,U),E||(X=z,z=t(z))}if(!E)throw new Error("A planned move has no allowed surviving parent");let B=U.output||o(U.owner);U.output=B,U.state="built",I(B,E,X),w(B,E,g.get(E)||!1),T(U),k.delete(U)}w(h);for(let U of a.values())V(U)}return{planned:a,has:h=>a.has(h),plan:p,produced:u,drain:f}}function to(e,t,n,r,o,s,i,l,a,c,p,u,f){let h=null;return im({provenance:e,parentOf:g=>{if(!g)return null;let m=t(g);if(m||g.parentNode?.nodeType!==11)return m;if(!h){h=new WeakMap;let k=[u,f];for(;k.length;){let S=k.pop(),x=Uo(S);x!==S&&h.set(x,S);for(let w of x.children)k.push(w)}}return h.get(g.parentNode)||null},twins:g=>({local:o(n,g),remote:o(r,g)}),baseOf:(g,m)=>g&&(m==="local"?n:r).reverse.get(g)||null,build:g=>s(g,o(n,g),o(r,g),!1),ignored:i,remoteWins:l,discarded:(g,m)=>{m&&p(g,m,n)&&!a.some(k=>k.detail==="remote-wins"&&k.base===g)&&c({kind:"structure",el:null,detail:"remote-wins",base:g,local:m,remote:null},{subject:g})}})}function lm({parent:e,base:t,views:n,eligible:r,ignored:o,remoteWins:s,budget:i=Gt(2e4*32),maxUnits:l=256,maxCharacters:a=2e4}){let c=(m,k=null)=>({status:m,reason:k,parent:e,records:[]});if(n.some(({V:m})=>m.asBase)||o(e)||s(e)||n.some(({V:m})=>!m.el||o(m.el)||s(m.el)))return c("none");let p=t.length+n[0].V.units.length+n[1].V.units.length;if(p>l)return c("fallback","unit-limit");let u=Symbol(),f=m=>{if(m>i.remaining)throw u;i.remaining-=m,i.crossParentSteps=(i.crossParentSteps||0)+m},h=new Map,d=0,v=m=>{if(f(1),h.has(m))return h.get(m);let k=m.nodeType===1?m.childNodes:m.nodes;f(k.length*4+1);let S=m.nodeType===1?Array.from(k):k,x=0;for(let N=0;N<S.length;N++){let C=S[N];if(C.nodeType!==3||N&&S[N-1].nextSibling!==C)return h.set(m,null),null;x+=C.data.length}if(x>a-d)throw u;f(x*8+1),d+=x;let w=Qt(S);if(w.text.includes(Nt))return h.set(m,null),null;let T={unit:m,nodes:S,flat:w};return h.set(m,T),T},g=[];try{f(p*8+1);for(let m=0;m<2;m++){let k=n[m].V,S=n[1-m].V,x=[],w=new Map;for(let T=0;T<t.length;T++){f(1);let N=t[T];if(N.kind!=="text"||k.twin(N))continue;let C=S.twin(N);if(!C||C.kind!=="text"||!S.here(C))continue;let I=v(N),q=v(C);if(!I||!q||!/\S/.test(I.flat.text))continue;f(I.flat.text.length*2+1);let V=I.flat.text;w.set(V,(w.get(V)||0)+1),x.push({source:N,opposite:C,sourceModel:I,oppositeModel:q,index:T})}for(let T of x){let{source:N,opposite:C,sourceModel:I,oppositeModel:q,index:V}=T,U=[];for(let K of[-1,1]){f(1);let fe=t[V+K];if(!fe||fe.nodeType!==1||!r(fe)||o(fe)||s(fe))continue;let ae=I.nodes[0],qe=I.nodes.at(-1);if(K===-1?ae?.previousSibling!==fe:qe?.nextSibling!==fe)continue;let ze=k.twin(fe),Ee=S.twin(fe);if(!ze||!Ee||!k.here(ze)||S.here(Ee)||k.baseOf(ze)!==fe||S.baseOf(Ee)!==fe||!r(ze)||!r(Ee)||o(ze)||o(Ee)||s(ze)||s(Ee)||ze.tagName!==fe.tagName||Ee.tagName!==fe.tagName||ze.namespaceURI!==fe.namespaceURI||Ee.namespaceURI!==fe.namespaceURI)continue;let ot=v(fe),rt=v(ze),xt=v(Ee);if(!ot||!rt||!xt||!/\S/.test(ot.flat.text))continue;let nt=ot.flat.text,te=I.flat.text,Ae=rt.flat.text;if(f((nt.length+te.length+Ae.length)*3+1),Ae.length!==nt.length+te.length)continue;let je=K===-1;(je?!Ae.startsWith(nt)||!Ae.endsWith(te):!Ae.startsWith(te)||!Ae.endsWith(nt))||U.push({owner:fe,target:ze,moved:Ee,ownerBase:ot,joined:rt,ownerOther:xt,targetFrom:je?nt.length:0,retainedFrom:je?0:te.length})}if(!U.length)continue;if(U.length!==1||w.get(I.flat.text)!==1)return c("fallback","ambiguous-origin");let F=U[0],{owner:A,target:E,moved:X,ownerBase:B,joined:z,ownerOther:Ce,targetFrom:Me,retainedFrom:Be}=F;if(f(g.length+1),g.some(K=>K.owner===A))return c("fallback","ambiguous-owner");let me={source:N,target:E,from:0,to:I.flat.text.length,targetFrom:Me},Te=zn({base:I.flat,side:z.flat,retained:[],transfers:[{from:me.from,to:me.to,target:Me,destination:A}],budget:i});if(Te.status!=="ready"||Te.covers(me.from,me.to)!==!0)return c("fallback",Te.reason||"work-limit");let Xe=[{unit:N,model:I,from:0,to:I.flat.text.length},null,null];Xe[m+1]={unit:E,model:z,from:Me,to:Me+I.flat.text.length},Xe[2-m]={unit:C,model:q,from:0,to:q.flat.text.length};let _e=[B,null,null];_e[m+1]=z,_e[2-m]=Ce;let O=[A,null,null];O[m+1]=E,O[2-m]=X,g.push({side:m,parent:e,source:N,target:E,owner:A,owners:O,ownerModels:_e,native:Xe,models:h,runs:[me],proof:Te,retained:[{source:A,target:E,from:0,to:B.flat.text.length,targetFrom:Be}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:c("none")}catch(m){if(m!==u)throw m;return c("fallback","work-limit")}}function wc({describe:e,parentOf:t,...n}){let r=new WeakMap,o=new WeakMap,s=n.budget||Gt(2e4*32),i=l=>{if(!l)return null;if(r.has(l))return r.get(l);r.set(l,{status:"planning",parent:l,records:[]});let a=e(l),c=a?lm({...n,...a,parent:l,budget:s}):{status:"none",reason:null,parent:l,records:[]};if(r.set(l,c),c.status==="ready")for(let p of c.records)o.set(p.owner,[p]);return c};return{get:i,forOwner(l){return i(t(l))?.status==="ready"&&o.get(l)||null}}}function am(e,t){if(e.side!==0)return null;let n=e.native[0].model,r=e.ownerModels[0],o=e.native[1].from!==0,s=(S,x)=>o?[...S.nodes,...x.nodes]:[...x.nodes,...S.nodes],i=e.ownerModels.reduce((S,x)=>S+x.flat.text.length,0)+n.flat.text.length+e.native[2].model.flat.text.length;if(i*8>t.remaining)return null;t.remaining-=i*8;let l={base:s(r,n),local:e.ownerModels[1].nodes,remote:s(e.ownerModels[2],e.native[2].model)},a=Qt(l.base),c=e.ownerModels[1].flat,p=Qt(l.remote),u=o?r.flat.text.length:0,f=o?0:n.flat.text.length,h=zn({base:a,side:c,retained:e.retained.map(S=>({from:f+S.from,to:f+S.to,target:S.targetFrom})),transfers:e.runs.map(S=>({from:u+S.from,to:u+S.to,target:S.targetFrom,destination:e.owner})),budget:t});if(h.status!=="ready"||h.covers(0,a.text.length)!==!0)return null;let d=e.ownerModels[2].flat,v=e.native[2].model.flat,g=[];for(let[S,x,w,T]of[[r.flat,d,f,o?0:v.text.length],[n.flat,v,u,o?d.text.length:0]]){let N=Zi(S,S,x).remoteMap.bTo,C=-1;for(let I=0;I<S.text.length;I++){if(N[I]<0){C=-1;continue}let q=g.at(-1);C>=0&&q.to===w+I&&q.target+q.to-q.from===T+N[I]?q.to++:(g.push({from:w+I,to:w+I+1,target:T+N[I]}),C=I)}}let m=zn({base:a,side:p,retained:g,transfers:[],budget:t});if(m.status!=="ready")return null;let k=Zi(a,c,p,{},{local:h,remote:m});return k.localEdits.hunks.length?null:(k.localMap=h,k.remoteMap=m,{nodes:l,prepared:k})}function Sc({L:e,R:t,twinIn:n,unitsOf:r,view:o,parentOf:s,ignored:i,remoteWins:l,eligible:a,build:c,out:p,policy:u,provenance:f,textMappers:h,segments:d,conflicts:v,conflict:g,decisions:m}){let k=Gt(2e4*32),S=U=>{let F=0;for(let A=U;A;A=s(A))if(++F>64||A.nodeType===1&&(i(A)||l(A)))return!1;return!0},x=wc({parentOf:s,eligible:a,ignored:i,remoteWins:l,budget:k,describe(U){let F=n(e,U),A=n(t,U);return!F||!A||!S(U)||!S(F)||!S(A)?null:{base:r(U),views:[{A:e,V:o(e,F,U,!1)},{A:t,V:o(t,A,U,!1)}]}}}),w=new WeakSet,T=new WeakMap,N=new WeakSet,C=[];function I(U){if(!U||w.has(U))return;w.add(U);let F=x.get(U);if(F?.status==="ready")for(let A of F.records){if((U.tagName==="TEMPLATE"&&U.content?U.content:U).childNodes.length!==A.native[0].model.nodes.length+1||!A.owners.every(S))continue;let X=am(A,k);if(!X)continue;let B={record:A,payload:X,state:"planned",output:null,result:null};T.set(A.owner,B),N.add(A.source),N.add(A.native[2].unit),C.push(B)}}function q(U,F){let A=T.get(U);if(!A)return!1;if(!A.result){if(A.result=Ts({...A.payload.nodes,prepared:A.payload.prepared,out:p,policy:u,provenance:f,textMappers:h,conflicts:v,conflict:g,decisions:m,node:F}),A.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");d.push(...A.result.segments),A.decision={kind:"text",node:F,source:"local"},m.push(A.decision)}return A.decision.node=F,F.replaceChildren(...A.result.nodes),A.output=F,A.state="built",!0}function V(U){if(!C.length)return;let F=new WeakSet,A=new WeakMap,E=new WeakMap,X=new WeakMap,B=Te=>Te.tagName==="TEMPLATE"&&Te.content?Te.content:Te,z=(Te,Xe)=>{if(!Te)return;if(Array.isArray(Te)){for(let O of Te)z(O,Xe);return}let _e=X.get(Te);_e||X.set(Te,_e=[]),_e.push(Xe)},Ce=(Te,Xe=null,_e=!1)=>{F.add(Te),A.set(Te,Xe);let O=f.get(Te),K=_e||!!(O&&l(O.remote||O.base));if(E.set(Te,K),O)for(let fe of[O.base,O.local,O.remote])z(fe,Te);if(!(O?.pinned||O?.unchanged))for(let fe of B(Te).childNodes)Ce(fe,Te,K)},Me=Te=>(X.get(Te)||[]).find(Xe=>Xe.nodeType===1&&!E.get(Xe)&&!f.get(Xe)?.pinned&&!f.get(Xe)?.unchanged),Be=(Te,Xe)=>{for(let _e of X.get(Te)||[]){let O=_e;for(;O&&A.get(O)!==Xe;)O=A.get(O);if(O)return O}return null},me=(Te,Xe,_e)=>{let O=B(Xe);for(let K=_e.nextSibling;K;K=K.nextSibling){let fe=Be(K,Xe);if(fe){O.insertBefore(Te,fe);return}}for(let K=_e.previousSibling;K;K=K.previousSibling){let fe=Be(K,Xe);if(fe){O.insertBefore(Te,fe.nextSibling);return}}O.appendChild(Te)};Ce(U);for(let Te of C){let{record:Xe}=Te,_e=Me(Xe.owner)||Me(Xe.owners[1])||Me(Xe.owners[2]);if(_e)(!Te.result||Te.output!==_e||Te.result.nodes.some(O=>!F.has(O)||A.get(O)!==_e)||_e.textContent!==Te.result.text)&&(q(Xe.owner,_e),Ce(_e,A.get(_e),E.get(_e)));else{let O=Xe.parent,K=Xe.owner,fe=null;for(;O&&!fe;)fe=Me(O),fe||(K=O,O=s(O));if(!fe)throw new Error("A cross-parent payload has no allowed surviving parent");_e=Te.output||c(Xe.owner,Xe.owners[1],Xe.owners[2],!1),Te.result||q(Xe.owner,_e),me(_e,fe,K),Ce(_e,fe,E.get(fe))}Te.state="attached"}}return{ensureParent:I,ensureOwner(U){I(s(U))},consumes(U){return N.has(U)},render:q,drain:V}}var On=/\S/,Ac=/[\p{L}\p{N}]/u;function _r(e,t,n,r){if(e?.nodeType!==1||!t(e))return!1;for(let o=e.firstChild;o;o=o.nextSibling)if(r(n,1),o.nodeType!==3)return!1;return!!e.firstChild}function ll(e,t,n){for(let r=e.parentNode;r;r=r.parentNode)if(n(t,1),r.nodeType===11)return!1;return!0}function Tc(e,t,n,r,o){let s=n(e,r),i=n(t,r),l=null,a=null,c=null,p=null;o(r,s.length+i.length);for(let u of s)Ac.test(u.raw)&&(l||=u,a=u);for(let u of i)Ac.test(u.raw)&&(c||=u,p=u);return!!(l&&c&&(l.raw===c.raw||a.raw===p.raw))}function cm({base:e,V:t,A:n,source:r,original:o,current:s,edited:i,destination:l,at:a,ownLength:c,eligible:p,model:u,tokensOf:f,budget:h,charge:d}){let v=o.flat.text,g=s.flat.text,m=i.flat.text,k=l.flat.text;if(d(h,v.length+g.length+k.length),v.startsWith(g)||v.endsWith(g))return!1;let S=On.test(k.slice(0,a)),x=On.test(k.slice(a+c));if(S===x)return!1;let w=S?0:a+c,T=S?a:k.length;for(;w<T&&!On.test(k[w]);)w++;for(;T>w&&!On.test(k[T-1]);)T--;let N=k.slice(w,T);if(Ln(N,k,f(l,h),h,d,!0)!==w)return!1;let C=Ln(N,v,f(o,h),h,d,!0);if(C<0)return!1;let I=C+N.length,q=!On.test(v.slice(0,C)),V=!On.test(v.slice(I));if(q===V||Ln(N,g,f(s,h),h,d,!1)>=0)return!1;let U=q?v.slice(I):v.slice(0,C),F=q?m.length-U.length:0;if(d(h,v.length+m.length),F<0||!On.test(U)||Ln(U,m,f(i,h),h,d,!0)!==F||!On.test(q?m.slice(0,F):m.slice(U.length)))return!1;for(let A of e){if(d(h,1),A===r||!_r(A,p,h,d))continue;let E=u(A,null,h);if(Ln(N,E.flat.text,f(E,h),h,d,!1)>=0)return!1}for(let A of t.units){if(d(h,1),A===s.unit||A===l.unit||!_r(A,p,h,d))continue;let E=u(A,n,h);if(Ln(N,E.flat.text,f(E,h),h,d,!1)>=0)return!1}return!0}function Ec({base:e,views:t,side:n,attempt:r,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,charge:c,exhausted:p,limit:u}){if(u<=0)return null;let f=Gt(u),{V:h,A:d,idOf:v}=t[n],g=t[1-n],[m,k,S,x]=r,w=null;try{for(let T=m;T<=k;T++){c(f,1);let N=e[T];if(N.parentNode?.nodeType!==1||s.has(N)||d.identical.has(N)||g.A.identical.has(N)||!_r(N,o,f,c)||i(N))continue;let C=h.twin(N),I=g.V.twin(N);if(!C||!I||!h.here(C)||!g.V.here(I)||d.map.get(N)!==C||d.reverse.get(C)!==N||g.A.map.get(N)!==I||g.A.reverse.get(I)!==N||v(C)||g.idOf(I)||C.tagName!==N.tagName||I.tagName!==N.tagName||!_r(C,o,f,c)||!_r(I,o,f,c)||!ll(N,f,c)||!ll(C,f,c)||!ll(I,f,c))continue;let q=l(N,null,f),V=l(C,d,f),U=l(I,g.A,f),F=q.flat.text,A=V.flat.text,E=U.flat.text;if(c(f,F.length+A.length+E.length),!On.test(F)||!On.test(A)||!On.test(E)||F===A||F===E||A===E||!Tc(q,V,a,f,c)||!Tc(q,U,a,f,c))continue;let X=null,B=!1;for(let Me=S;Me<=x;Me++){c(f,1);let Be=h.units[Me],me=h.baseOf(Be);if(!me||me===N||s.has(me)||me.parentNode!==N.parentNode||Be.parentNode!==C.parentNode||me.tagName!==N.tagName||Be.tagName!==N.tagName||d.map.get(me)!==Be||d.reverse.get(Be)!==me||i(me)!==v(Be)||!_r(me,o,f,c)||!_r(Be,o,f,c))continue;let Te=l(me,null,f),Xe=l(Be,d,f),_e=Te.flat.text,O=Xe.flat.text;if(c(f,_e.length),!On.test(_e)||O.length<=_e.length)continue;let K=a(Xe,f),fe=Ln(_e,O,K,f,c,!0);if(!(fe<0||Ln(F,O,K,f,c,!0,fe,fe+_e.length)<0&&!cm({base:e,V:h,A:d,source:N,original:q,current:V,edited:U,destination:Xe,at:fe,ownLength:_e.length,eligible:o,model:l,tokensOf:a,budget:f,charge:c}))){if(X){B=!0;break}X=Be}}if(!X||B)continue;let z=n===0?C:I,Ce=n===0?I:C;(w||=[]).push({source:N,local:z,remote:Ce,models:[q,n===0?V:U,n===0?U:V]})}}catch(T){if(T!==p)throw T}return w}var Kn=/\S/,gn=/\s/,um=/[\s\u001e]/g,al=/[^\s\p{P}\u001e\ufffc]/u;function fm(e,t,n,r,o,s,i){let l=0;for(let a of e)i(s,1),a.nodeType===1&&!r.baseOf(a)&&l++;if(l<2)return!1;for(let a of e){if(a.nodeType!==1||r.baseOf(a))continue;let c=o.get(a).flat;if(c.atoms.length||c.pins?.length)continue;i(s,c.text.length*2+t.length+n.length);let p=new Uint8Array(c.text.length);for(let u of n)u.target===a&&p.fill(1,u.targetFrom,u.targetFrom+u.to-u.from);for(let u of t)u.target===a&&p.fill(1,u.targetFrom,u.targetFrom+u.to-u.from);for(let u=0;u<c.text.length;u++)if(!p[u]&&Kn.test(c.text[u]))return!0}return!1}function dm(e,t,n){let{source:r,models:o,retained:s,runs:i}=e,l=o.get(r).flat.text;n(t,l.length*2+s.length+i.length);let a=new Uint8Array(l.length);for(let c of s)c.source===r&&(n(t,c.to-c.from),a.fill(1,c.from,c.to));for(let c of i)n(t,c.to-c.from),a.fill(1,c.from,c.to);for(let c=0;c<l.length;c++)if(!a[c]&&Kn.test(l[c]))return!1;return!0}function hm(e,t,n,r,o,s,i,l,a,c){let p=s.get(e),u=s.get(t),f=p.flat.text,h=i.get(e);a(c,f.length*2+n.length);let d=f.length,v=0;for(let k=0;k<f.length;k++)!gn.test(f[k])&&!h[k]&&(d=Math.min(d,k),v=k+1);if(d>=v)return null;for(let k=d;k<v;k++)if(!gn.test(f[k])&&h[k])return null;let g=-1;for(let k of n)if(k.target===t&&k.from<=d&&k.to>d){g=k.targetFrom+d-k.from;break}if(g<0)return null;let m=f.slice(d,v);if(a(c,m.length*(n.length+2)),u.flat.text.slice(g,g+m.length)!==m)return null;for(let k=d;k<v;k++){if(gn.test(f[k]))continue;let S=!1;for(let x of n)if(x.target===t&&x.from<=k&&x.to>k&&x.targetFrom+k-x.from===g+k-d){S=!0;break}if(!S)return null}if(p.flat.atoms.length||u.flat.atoms.length){a(c,p.flat.atoms.length+u.flat.atoms.length);let k=0,S=u.flat.atoms;for(;k<S.length&&S[k].i<g;)k++;for(let x of p.flat.atoms){if(x.i<d||x.i>=v)continue;let w=S[k++];if(!w||w.i!==g+x.i-d||u.alignment?.reverse.get(w.el)!==x.el)return null}if(k<S.length&&S[k].i<g+v-d)return null}for(let[k,S,x]of[[r,e,d],[o,t,g]]){let w=!1;for(let T of k){let N=s.get(T),C=i.get(T),I=l(N,c);for(let q=0;q<I.length;q++){let V=I[q].from,U=V+m.length;if(a(c,m.length*2+1),N.flat.text.slice(V,U)!==m)continue;let F=q;for(;F<I.length&&I[F].to<U;)a(c,1),F++;if(F===I.length||I[F].to!==U)continue;let A=!0;for(let E=V;E<U;E++)if(!gn.test(N.flat.text[E])&&C[E]){A=!1;break}if(A){if(w||T!==S||V!==x)return null;w=!0}}}if(!w)return null}return m}function mm(e,t,n,r,o,s,i,l){if(i(l,o.length+s.length+(r.length+1)*n.length*2),!n)return!1;let a=r.indexOf(n);return a<0||r.lastIndexOf(n)!==a||!s.some(c=>c.from===a)||!s.some(c=>c.to===a+n.length)?!1:o.some(c=>c.source===e&&c.target===t&&c.from===0&&c.to===n.length&&c.targetFrom===a)}function Oc({base:e,views:t,eligible:n,baseId:r,ignored:o,remoteWins:s,atomKey:i,limit:l=2e4*8}){if(l<=0)return null;let a=Symbol(),c=(x,w)=>{if(w>x.remaining)throw a;x.remaining-=w},p=[new Map,new Map];for(let x=0;x<2;x++)for(let w=0;w<t[x].V.units.length;w++)p[x].set(t[x].V.units[w],w);let u=new Int32Array(e.length),f=new Int32Array(e.length),h=x=>t.every(({V:w},T)=>{let N=w.twin(x);return N&&p[T].has(N)}),d=-1;for(let x=0;x<e.length;x++)u[x]=d,h(e[x])&&(d=x);d=e.length;for(let x=e.length-1;x>=0;x--)f[x]=d,h(e[x])&&(d=x);let v=new Map,g=(x,w)=>{if(c(w,1),v.has(x))return v.get(x);let T=x.firstChild,N=1;for(;T;){if(c(w,N*8+8),T.nodeType===3&&c(w,T.data.length*8),T.nodeType===1&&wn.has(T.tagName)&&!o(T)&&!s(T)&&T.firstChild){T=T.firstChild,N++;continue}for(;T&&T!==x&&!T.nextSibling;)T=T.parentNode,N--;T=!T||T===x?null:T.nextSibling}let C=Qt(Array.from(x.childNodes),{ignored:o,remoteWins:s});return v.set(x,C),C},m=(x,w,T,N,C,I)=>{for(let q of x.atoms){c(I,1);let V=w.atomAt.get(q.i+T);if(!V)return!1;let U=N?.reverse.get(q.el)||i(q.el),F=C?.reverse.get(V.el)||i(V.el);if(U!==F)return!1}return!0},k=(x,w,T,N,C)=>{let I=x.text.length<=w.text.length?x:w,q=I===x?w:x;if(c(C,I.text.length+q.text.length),!I.text||!Kn.test(I.text.replaceAll(Vn,"")))return!1;let V;if(I.text===q.text)V=0;else{let U=q.text.length-I.text.length;if(c(C,(U+1)*I.text.length*2),q.text.startsWith(I.text))V=0;else if(q.text.endsWith(I.text))V=U;else return!1;if(q.text.indexOf(I.text)!==V||q.text.lastIndexOf(I.text)!==V)return!1;c(C,q.text.length*2);let F=0,A=V===0,E=!1;for(let X of fn(q.text,xn(q.text)))F+=X.len,F===V&&(A=!0),F===V+I.text.length&&(E=!0);if(!A||!E)return!1}return I===x?m(I,q,V,T,N,C):m(I,q,V,N,T,C)},S=null;for(let x=0;x<2;x++){let{V:w,A:T,idOf:N}=t[x],C=t[1-x];if(!w.asBase)for(let I=0;I<e.length;I++){let q=e[I];if(w.twin(q)||!n(q))continue;let V=C.V.twin(q);if(!V||!p[1-x].has(V)||!n(V))continue;let U={remaining:l};try{let F=u[I],A=f[I],E=0;for(let Ce=F+1;Ce<A;Ce++)c(U,1),!w.twin(e[Ce])&&C.V.twin(e[Ce])&&n(e[Ce])&&E++;if(E!==1||g(q,U).text===g(V,U).text)continue;let X=F<0?-1:p[x].get(w.twin(e[F])),B=A===e.length?w.units.length:p[x].get(w.twin(e[A]));if(X===void 0||B===void 0||X>=B)continue;let z=null;for(let Ce=X+1;Ce<B;Ce++){c(U,1);let Me=w.units[Ce];if(w.baseOf(Me)||!n(Me)||Me.tagName!==q.tagName||Me.namespaceURI!==q.namespaceURI)continue;let Be=r(q),me=C.idOf(V),Te=N(Me);if(!(Be&&me&&Be!==me||Be&&Te&&Be!==Te||me&&Te&&me!==Te)&&k(g(V,U),g(Me,U),C.A,T,U)){if(z){z=null;break}z=Me}}if(!z)continue;S||(S=[new Map,new Map]),S[x].set(q,z)}catch(F){if(F!==a)throw F}}}return S?t.map(({V:x},w)=>{let T=S[w];if(!T.size)return x;let N=new Map;for(let[C,I]of T)N.set(I,C);return{...x,twin:C=>T.get(C)||x.twin(C),baseOf:C=>N.get(C)||x.baseOf(C)}}):null}function Nc({onUncertainSource:e,onUncertainOwner:t,base:n,views:r,eligible:o,ignored:s,remoteWins:i,baseId:l,atomKey:a,limit:c=2e4*32}){if(c<=0)return null;let p=new Set(n),u=new Map(n.map((F,A)=>[F,A])),f=new Map,h=[],d=null,v=null,g=null,m=new Set;for(let F of n)for(let{V:A}of r){let E=A.twin(F);E&&!A.asBase&&!A.here(E)&&m.add(F)}let k=new Set,S=Symbol(),x=(F,A)=>{if(A>F.remaining)throw S;F.remaining-=A},w=(F,A,E)=>{x(E,1);let X=f.get(F);if(X)return X;if(F.nodeType===1){let Ce=F.firstChild,Me=1;for(;Ce;){if(x(E,Me*8+8),Ce.nodeType===3&&x(E,Ce.data.length*8),Ce.nodeType===1&&wn.has(Ce.tagName)&&!s(Ce)&&!i(Ce)&&Ce.firstChild){Ce=Ce.firstChild,Me++;continue}for(;Ce&&Ce!==F&&!Ce.nextSibling;)Ce=Ce.parentNode,Me--;Ce=!Ce||Ce===F?null:Ce.nextSibling}}else x(E,F.value.length*8+F.nodes.length);let B=F.nodeType===1?Array.from(F.childNodes):F.nodes,z=B.length===1&&B[0].nodeType===3?{text:B[0].data,nodes:[{node:B[0],s:0,e:B[0].data.length}],atoms:[]}:Qt(B,{ignored:s,remoteWins:i});return X={unit:F,flat:z,alignment:A,tokens:null},f.set(F,X),X},T=(F,A)=>{if(F.tokens)return F.tokens;x(A,F.flat.text.length*8);let{unit:E,flat:X,alignment:B}=F,z=[],Ce=xn(X.text),Me=0,Be=me=>{for(let Te of fn(X.text.slice(Me,me),Ce))Te.from=Me,Te.to=Me+Te.len,Te.unit=E,z.push(Te),Me+=Te.len};for(let me of X.atoms){Be(me.i);let Te=i(me.el)&&me.el.nodeType===1?"w"+me.el.tagName+"#"+(me.el.id||""):a(B?.reverse.get(me.el)||me.el);z.push({k:Te,raw:Vn,len:1,from:Me,to:Me+1,unit:E,atom:!0}),Me++}return Be(X.text.length),F.tokens=z,z},N=(F,A,E,X,B)=>{if(!F.flat.atoms.length&&!A.flat.atoms.length)return!0;let z=T(F,B),Ce=T(A,B);x(B,z.length+Ce.length);let Me=0;for(let Be of Ce){if(!Be.atom||Be.from<E||Be.from>=E+X)continue;for(;Me<z.length&&!z[Me].atom;)Me++;let me=z[Me++];if(!me||me.from!==Be.from-E||me.k!==Be.k)return!1}for(;Me<z.length;)if(z[Me++].atom)return!1;return!0},C=(F,A,E)=>{let X=F.length+A.length+4;if(X*8>E.remaining)return null;E.remaining-=X*8;let B=Math.floor(E.remaining/8),z=Math.min(F.length+A.length,4e3,Math.floor((Math.sqrt(X*X+B)-X)/2)),Ce=4*(z+1)*(X+z+1);if(z<1||Ce>E.remaining)return null;E.remaining-=Ce;let Me=Jn(F,A,z),Be=[],me=0,Te=0;for(let Xe of Me.hunks){for(;me<Xe.bs;)F[me].raw===A[Te].raw&&Be.push([F[me],A[Te]]),me++,Te++;me=Xe.be,Te+=Xe.toks.length}for(;me<F.length&&Te<A.length;)F[me].raw===A[Te].raw&&Be.push([F[me],A[Te]]),me++,Te++;return Be},I=(F,A,E,X,B,z,Ce)=>{if(B<=X)return;let Me=F[F.length-1];if(Me&&Me.source===A&&Me.target===E&&Me.to<=X&&Me.targetFrom-Me.from===z-X){x(Ce,(X-Me.to)*3);let Be=f.get(A).flat.text,me=f.get(E).flat.text,Te=!0;for(let Xe=Me.to;Xe<X;Xe++)if(!gn.test(Be[Xe])||Be[Xe]!==me[z+Xe-X]){Te=!1;break}if(Te){Me.to=B;return}}F.push({source:A,target:E,from:X,to:B,targetFrom:z})},q=F=>F.replace(um,"");for(let F=0;F<r.length;F++){let{V:A,A:E,idOf:X}=r[F];if(A.asBase)continue;let B=new Map(A.units.map((O,K)=>[O,K])),z=O=>{let K=A.twin(O);return K&&B.has(K)?K:null},Ce=(O,K)=>{let fe=new Int32Array(O.length),ae=new Int32Array(O.length),qe=-1;for(let ze=0;ze<O.length;ze++)fe[ze]=qe,K(O[ze])&&(qe=ze);qe=O.length;for(let ze=O.length-1;ze>=0;ze--)ae[ze]=qe,K(O[ze])&&(qe=ze);return{prev:fe,next:ae}},Me=Ce(n,O=>(O.nodeType===1||O.kind==="text"&&Kn.test(O.value))&&z(O)),Be=Ce(A.units,O=>(O.nodeType===1||O.kind==="text"&&Kn.test(O.value))&&p.has(A.baseOf(O))),me=new Map,Te=(O,K,fe,ae)=>{if(O>K||fe>ae)return;let qe=`${O}:${K}:${fe}:${ae}`;me.set(qe,[O,K,fe,ae])};for(let O=0;O<A.units.length;O++){let K=A.units[O];if(A.baseOf(K)||!o(K))continue;let fe=Be.prev[O],ae=Be.next[O],qe=fe<0?0:u.get(A.baseOf(A.units[fe])),ze=ae===A.units.length?n.length-1:u.get(A.baseOf(A.units[ae]));Te(qe,ze,Math.max(0,fe),Math.min(A.units.length-1,ae))}for(let O=0;O<n.length;O++){let K=n[O];if(m.has(K)||!o(K))continue;if(!A.twin(K)){let ot=Me.prev[O],rt=Me.next[O],xt=ot<0?0:B.get(z(n[ot])),nt=rt===n.length?A.units.length-1:B.get(z(n[rt]));Te(Math.max(0,ot),Math.min(n.length-1,rt),xt,nt)}let fe=z(K);if(!fe||E.identical.has(K)||!o(fe))continue;let ae=O+1;for(;ae<n.length&&n[ae].kind==="text"&&!n[ae].value.trim();)ae++;if(ae>=n.length||!o(n[ae]))continue;let qe=z(n[ae]);if(!qe||E.identical.has(n[ae])||!o(qe))continue;let ze=B.get(fe),Ee=B.get(qe);ze<Ee&&Te(O,ae,ze,Ee)}let Xe=Array.from(me.values()),_e=new Set;if(Xe.length>1){let O=Gt(c);try{x(O,Xe.length*4);let K=Xe.slice().sort((qe,ze)=>(x(O,1),qe[0]-ze[0]||qe[2]-ze[2])),fe=[],ae=null;for(let qe of K)x(O,1),ae&&qe[0]<=ae[1]&&qe[2]<=ae[3]&&qe[3]>=ae[2]?(ae[1]=Math.max(ae[1],qe[1]),ae[2]=Math.min(ae[2],qe[2]),ae[3]=Math.max(ae[3],qe[3]),ae[4].push(qe)):(ae?.[4].length>1&&fe.push(ae),ae=[qe[0],qe[1],qe[2],qe[3],[qe]]);ae?.[4].length>1&&fe.push(ae),Xe=fe.concat(Xe)}catch(K){if(K!==S)throw K}}for(let O of Xe){if(_e.has(O))continue;let[K,fe,ae,qe,ze]=O,Ee=Gt(c),ot=[],rt=new Set,xt=!1;try{x(Ee,(fe-K+qe-ae+2)*4);let nt=n.slice(K,fe+1).filter(D=>!E.identical.has(D)&&o(D)&&!m.has(D)),te=A.units.slice(ae,qe+1).filter(D=>o(D)&&(!A.baseOf(D)||p.has(A.baseOf(D)))&&!E.identical.has(A.baseOf(D))&&!m.has(A.baseOf(D))),Ae=new Set(te),je=!1,Fe="",He="",et=0;for(let D of nt){let ge=w(D,null,Ee);Fe+=ge.flat.text,et+=ge.flat.text.length}for(let D of te){let ge=w(D,E,Ee);He+=ge.flat.text,et+=ge.flat.text.length}x(Ee,et);let bt=q(Fe),Ft=q(He),yt=bt===Ft;if(xt=yt,ze&&!yt)continue;let Lt=yt?null:new Map;if(Lt)for(let D of nt.concat(te)){let ge=f.get(D).flat.text.length;x(Ee,ge*16),Lt.set(D,new Uint8Array(ge))}let en=D=>{let ge=[];for(let xe of D){let de=f.get(xe);de.flat.atoms.length?ge.push(...T(de,Ee)):ge.push({unit:xe,raw:de.flat.text,from:0})}return ge},Ge=[];for(let D of yt?[]:nt){let ge=z(D);if(!Ae.has(ge))continue;let xe=w(D,null,Ee),de=w(ge,E,Ee);x(Ee,xe.flat.text.length+de.flat.text.length);let Oe=xe.flat.text&&de.flat.text.startsWith(xe.flat.text)?0:xe.flat.text&&de.flat.text.endsWith(xe.flat.text)?de.flat.text.length-xe.flat.text.length:-1;if(Oe>=0&&N(xe,de,Oe,xe.flat.text.length,Ee)){Lt.get(D).fill(1),Lt.get(ge).fill(1,Oe,Oe+xe.flat.text.length),I(Ge,D,ge,0,xe.flat.text.length,Oe,Ee);continue}let $=C(T(xe,Ee),T(de,Ee),Ee);if(!$){je=!0;break}for(let[Z,ke]of $)Lt.get(D).fill(1,Z.from,Z.to),Lt.get(ge).fill(1,ke.from,ke.to),I(Ge,D,ge,Z.from,Z.to,ke.from,Ee)}if(je)continue;let Ct=null,Et=null;if(!yt)for(let D of nt){let ge=z(D),xe=f.get(D);if(!ge||xe.flat.atoms.length||!Ae.has(ge))continue;let de=xe.flat.text,Oe=Lt.get(D);x(Ee,de.length*3+te.length);let $=-1,Z=-1,ke=!1;for(let De=0;De<de.length;De++)gn.test(de[De])||(Oe[De]?ke=!0:($<0&&($=De),Z=De+1));if(!ke||$<0)continue;let we=!0;for(let De=$;De<Z;De++)if(Oe[De]&&!gn.test(de[De])){we=!1;break}if(!we)continue;let ve=q(de.slice($,Z)),ne=null,se=!1;for(let De of te){if(A.baseOf(De))continue;let Se=f.get(De);if(!Se.flat.atoms.length&&(x(Ee,Se.flat.text.length),q(Se.flat.text)===ve)){if(ne){se=!0;break}ne=De}}if(se){(Et||=new Set).add(D);continue}if(!ne||Et?.has(D))continue;let W=!1;for(let De of nt){if(De===D||!Ae.has(z(De)))continue;let Se=f.get(De);if(Se.flat.atoms.length)continue;let tt=Lt.get(De);x(Ee,Se.flat.text.length*3);let lt="",it=!1;for(let Ht=0;Ht<Se.flat.text.length;Ht++)gn.test(Se.flat.text[Ht])||(tt[Ht]?it=!0:lt+=Se.flat.text[Ht]);it&&lt===ve&&(Et||=new Set,Et.add(D),Et.add(De),W=!0)}if(W)continue;let ce=f.get(ne).flat.text;x(Ee,Z-$+ce.length);let Ne=$,Pe=0;for(;Ne<Z&&Pe<ce.length;){for(;Ne<Z&&gn.test(de[Ne]);)Ne++;for(;Pe<ce.length&&gn.test(ce[Pe]);)Pe++;if(Ne>=Z||Pe>=ce.length)break;I(Ct||=[],D,ne,Ne,Ne+1,Pe,Ee),Ne++,Pe++}Oe.fill(1,$,Z),Lt.get(ne).fill(1)}let Jt=D=>{let ge=[];for(let xe of D){let de=w(xe,p.has(xe)?null:E,Ee),Oe=Lt.get(xe);for(let $ of T(de,Ee)){let Z=$.from;for(;Z<$.to;){for(;Z<$.to&&Oe[Z];)Z++;let ke=Z;for(;Z<$.to&&!Oe[Z];)Z++;if(Z>ke){let we=de.flat.text.slice(ke,Z);Kn.test(we)&&ge.push({...$,raw:we,len:Z-ke,k:$.atom?$.k:we,from:ke,to:Z})}}}}return ge},Y=yt?en(nt):Jt(nt),y=yt?en(te):Jt(te),M=yt?bt:Y.map(D=>q(D.raw)).join(""),P=yt?Ft:y.map(D=>q(D.raw)).join("");if((!M||!P)&&!Ct)continue;let H=Ct||[];if(M&&P&&M===P){let D=0,ge=0,xe=0,de=0;for(;D<Y.length&&ge<y.length;){let Oe=Y[D],$=y[ge];for(;xe<Oe.raw.length&&gn.test(Oe.raw[xe]);)xe++;for(;de<$.raw.length&&gn.test($.raw[de]);)de++;if(xe===Oe.raw.length){D++,xe=0;continue}if(de===$.raw.length){ge++,de=0;continue}if((Oe.atom||$.atom)&&Oe.k!==$.k){je=!0;break}I(H,Oe.unit,$.unit,Oe.from+xe,Oe.from+xe+1,$.from+de,Ee),xe++,de++}}else if(M&&P){let D=C(Y,y,Ee);if(!D)continue;for(let[ge,xe]of D)I(H,ge.unit,xe.unit,ge.from,ge.to,xe.from,Ee)}if(je)continue;let Q=new Map;for(let D of H)if(!Et?.has(D.source)){if(z(D.source)===D.target){yt&&Ge.push(D);continue}Q.has(D.source)||Q.set(D.source,[]),Q.get(D.source).push(D)}for(let[D,ge]of Q){let xe=w(D,null,Ee),de=z(D),Oe=xe.flat.text,$=[],Z=new Set,ke=r[1-F],we=ke.V.twin(D),ve=we&&ke.V.here(we)?w(we,ke.A,Ee):null,ne=(Se,tt)=>{let lt=T(Se,Ee),it=T(tt,Ee);return x(Ee,Se.flat.text.length+tt.flat.text.length+lt.length+it.length),Se.flat.text===tt.flat.text&&lt.length===it.length&&lt.every((Ht,It)=>Ht.k===it[It].k)},se=de&&ve&&ve.flat.text!==Oe&&ne(w(de,E,Ee),ve);for(let Se of new Set(ge.map(tt=>tt.target))){if(D.nodeType!==1&&Se.nodeType!==1)continue;let tt=w(Se,E,Ee),lt=A.baseOf(Se);if(D.nodeType!==1&&lt||(x(Ee,Oe.length*2+tt.flat.text.length*3+Ge.length*2),de&&q(Oe)===q(tt.flat.text)&&w(de,E,Ee).flat.text.trim()))continue;if(!de&&!lt&&D.nodeType===1&&Se.nodeType===1){let Bt=l(D),Wt=X(Se);if(Bt&&Wt&&Bt!==Wt)continue}let it=tt.flat.text,Ht=Oe&&(it.startsWith(Oe)||it.endsWith(Oe)),It=!1;if(!de&&ve&&lt&&ve.flat.text!==Oe){let Bt=w(lt,null,Ee).flat.text,Wt=u.get(D)<u.get(lt)?ve.flat.text:Bt,R=u.get(D)<u.get(lt)?Bt:ve.flat.text;x(Ee,Wt.length+R.length+it.length),It=!!Wt&&!!R&&Wt.length+R.length<=it.length&&it.startsWith(Wt)&&it.endsWith(R)&&!it.slice(Wt.length,it.length-R.length).trim()}let Zt=!xe.flat.atoms.length&&!ve?.flat.atoms.length&&!tt.flat.atoms.length&&(se&&Ht||It);if(de&&lt){let Bt=w(de,E,Ee).flat.text,Wt=Oe.startsWith(Bt)||Oe.endsWith(Bt),R=w(lt,null,Ee).flat.text,J=tt.flat.text,ue=J.startsWith(R)||J.endsWith(R),he=!r[1-F].V.twin(lt)&&!Ge.some(le=>le.source===lt&&Kn.test(R.slice(le.from,le.to)));if(!yt&&(!Wt&&!Zt||!ue&&!he)){let le=hm(D,Se,ge,nt,te,f,Lt,T,x,Ee);if(!le)continue;let ee=E.weak?.has(D)&&!E.identityPaired?.has(D)&&Oe.trim()===le;if(!Wt&&!Zt&&!ee)continue;let ie=E.weak?.has(lt)&&!E.identityPaired?.has(lt)&&it.trim()===le&&!f.get(lt).flat.atoms.length&&!Ge.some(Re=>Re.source===lt&&Kn.test(R.slice(Re.from,Re.to)));if(!ue&&!he&&!ie&&!mm(lt,Se,R,it,Ge,T(tt,Ee),x,Ee))continue;ee&&Z.add(Se)}}Zt&&Z.add(Se),x(Ee,ge.length),$.push(...ge.filter(Bt=>Bt.target===Se))}if(!$.length)continue;let W=new Uint8Array(Oe.length);x(Ee,Oe.length*4+Ge.length);for(let Se of $)W.fill(1,Se.from,Se.to);let ce=[];for(let Se=0;Se<Oe.length;Se++)gn.test(Oe[Se])||ce.push(Se);if(!ce.length)continue;let Ne=new Set($.map(Se=>Se.target));if(!yt&&de&&Ne.size>1&&fm(Ne,H,Ge,A,f,Ee,x)){if(g||=new Map,g.set(D,(g.get(D)||0)|1<<F),e){let Se=Xi({source:D,side:F,views:r,eligible:o,blocked:m,baseId:l,model:w,tokensOf:T,budget:Ee,charge:x});if(Se){x(Ee,Se.to-Se.from);let tt=!0;for(let lt=Se.from;lt<Se.to;lt++)if(Kn.test(Oe[lt])&&!W[lt]){tt=!1;break}tt&&(d||=[]).push(Se)}}continue}let Pe=ce.filter(Se=>al.test(Oe[Se]));if(!$.some(Se=>al.test(Oe.slice(Se.from,Se.to)))&&!ce.every(Se=>W[Se]))continue;if(!de&&!Array.from(Ne).some(Se=>Z.has(Se))&&!ce.every(Se=>W[Se])&&!(Pe.length&&W[Pe[0]]&&W[Pe[Pe.length-1]]&&Ne.size===1)){let Se=null,tt=0,lt=0,it=null,Ht=null;if(!de&&ve&&D.nodeType===1&&!xe.flat.atoms.length){let It=T(xe,Ee).filter(Zt=>al.test(Zt.raw));x(Ee,te.length+Oe.length);for(let Zt of te){let Bt=A.baseOf(Zt);if(!Bt||Bt===D||Bt.nodeType!==1||Zt.nodeType!==1||Bt.tagName!==D.tagName||Zt.tagName!==Bt.tagName)continue;let Wt=u.get(D),R=u.get(Bt),J=!0;for(let Je=Math.min(Wt,R)+1;Je<Math.max(Wt,R);Je++){let at=n[Je];if(x(Ee,at.nodeType===1?1:at.value.length+1),at.nodeType===1||at.value.trim()){J=!1;break}}if(!J)continue;let ue=w(Bt,null,Ee),he=w(Zt,E,Ee);if(ue.flat.atoms.length||he.flat.atoms.length)continue;let le=ue.flat.text,ee=he.flat.text;if(x(Ee,le.length+ee.length+Oe.length),!le||!It.length)continue;let ie=0,Re=ee.length;if(Wt<R&&ee.endsWith(le))Re-=le.length;else if(Wt>R&&ee.startsWith(le))ie=le.length;else continue;for(;ie<Re&&gn.test(ee[ie]);)ie++;for(;Re>ie&&gn.test(ee[Re-1]);)Re--;let We=ee.slice(ie,Re);if(!(!We||!(We.startsWith(It[0].raw)||We.endsWith(It[It.length-1].raw)))){if(Se){Se=null;break}Se=Zt,tt=ie,lt=Re,it=It[0],Ht=It[It.length-1]}}}if(x(Ee,$.length),!Se||!Ne.has(Se)||!$.some(It=>It.target===Se&&(It.from<=it.from&&It.to>=it.to&&It.targetFrom+it.from-It.from===tt||It.from<=Ht.from&&It.to>=Ht.to&&It.targetFrom+Ht.to-It.from===lt)))continue}if(de&&!(ce.every(Se=>W[Se])&&(yt||Array.from(Ne).some(Se=>Z.has(Se))))&&!Ge.some(Se=>Se.source===D&&Kn.test(Oe.slice(Se.from,Se.to))))continue;let De=!1;if(yt){x(Ee,Ge.length+ce.length);for(let Se of Ge)Se.source===D&&(x(Ee,Se.to-Se.from),W.fill(1,Se.from,Se.to));De=!0;for(let Se of ce)if(!W[Se]){De=!1;break}}for(let Se of Ne){x(Ee,$.length);let tt=$.filter(it=>it.target===Se);ot.push({side:F,source:D,target:Se,runs:tt,models:f,retained:Ge,conservedSource:De}),D.nodeType===1&&rt.add(D),Se.nodeType===1&&rt.add(Se);let lt=A.baseOf(Se);lt?.nodeType===1&&rt.add(lt)}}if(h.push(...ot),ze&&ot.length)for(let D of ze)_e.add(D);for(let D of rt)k.add(D)}catch(nt){if(nt!==S)throw nt}finally{if(t&&!ze&&!xt){let nt=Ec({base:n,views:r,side:F,attempt:O,eligible:o,blocked:m,baseId:l,model:w,tokensOf:T,charge:x,exhausted:S,limit:c});nt&&(v||=[]).push(...nt)}if(e&&!ze&&!xt){let nt=$a({base:n,views:r,side:F,attempt:O,eligible:o,blocked:m,baseId:l,model:w,tokensOf:T,certificates:h,charge:x,exhausted:S,limit:c});nt&&(d||=[]).push(...nt)}}}}let V=h.length?new Map:null;for(let F of h){let A=V.get(F.source);A||V.set(F.source,A=[]),A.push(F)}let U=null;if(V){let F=null;for(let[A,E]of V){let X=g?.get(A)||0;if(E.length<2&&!X)continue;let B=0;for(let z of E)z.conservedSource&&(B|=1<<z.side);for(let z of E){if(z.conservedSource)continue;let Ce=1<<z.side,Me=!0;if(B&Ce)Me=!1;else if(X&Ce){Me=!1;try{Me=dm(z,F||=Gt(c),x)}catch(Be){if(Be!==S)throw Be}}Me||(U||=new Set).add(z)}}}if(U){let F=0;for(let A of h)U.has(A)||(h[F++]=A);h.length=F;for(let[A,E]of V){F=0;for(let X of E)U.has(X)||(E[F++]=X);E.length=F,F||V.delete(A)}k.clear();for(let A of h){let{source:E,target:X,side:B}=A;E.nodeType===1&&k.add(E),X.nodeType===1&&k.add(X);let z=r[B].V.baseOf(X);z?.nodeType===1&&k.add(z)}}if(d){let F=Gt(c),A=!1;for(let E of d){let X=!1,B=V?.get(E.source);if(B&&!A)try{X=Yi(E,B,F,x)}catch(z){if(z!==S)throw z;A=!0}X||e(E)}}if(v){let F=new Set,A=Gt(c);try{for(let E of v){if(x(A,1),F.has(E.source))continue;F.add(E.source);let X=!1;for(let B of h)if(x(A,1),B.source===E.source||B.target===E.local||B.target===E.remote){X=!0;break}X||t(E)}}catch(E){if(E!==S)throw E}}for(let F of n)if(k.has(F))for(let{V:A}of r){let E=A.twin(F);E&&A.here(E)&&k.add(E)}return h.length?{blocks:k,certificates:h,certificatesBySource:V,models:f}:null}function Cc({certificates:e,scopes:t,flats:n,keys:r,limit:o=2e4*32}){let s=Symbol(),i=Gt(o),l=g=>{if(g>i.remaining)throw s;i.remaining-=g},a=t.map(g=>new Set(g)),c=new Map,p=new Map,u=(g,m)=>{let k=c.get(g);if(k||c.set(g,k=new Map),k.has(m))return k.get(m);l(g.text.length);let S=p.get(m);if(!S){l(m.nodes.length+m.atoms.length),S={nodes:new Map,atoms:new Map};for(let N of m.nodes)S.nodes.set(N.node,N);for(let N of m.atoms)S.atoms.set(N.el,N.i);p.set(m,S)}let{nodes:x,atoms:w}=S,T=new Int32Array(g.text.length).fill(-1);for(let N of g.nodes){let C=x.get(N.node);if(!(!C||N.e-N.s!==C.e-C.s)){l(N.e-N.s);for(let I=N.s;I<N.e;I++)T[I]=C.s+I-N.s}}for(let N of g.atoms){let C=w.get(N.el);C!==void 0&&(T[N.i]=C)}return k.set(m,T),T},f=(g,m,k,S,x)=>{let w=g[g.length-1];w&&w.to===m&&w.target+w.to-w.from===S&&w.kind===x?w.to=k:g.push({from:m,to:k,target:S,kind:x})},h=(g,m,k,S)=>{l((S-k)*4);let x=[],w=k,T=I=>{let q=g.text.slice(w,I);for(let V of fn(q,xn(q)))V.from=w,V.to=w+V.len,x.push(V),w+=V.len},N=0,C=g.atoms.length;for(;N<C;){l(1);let I=N+C>>>1;g.atoms[I].i<k?N=I+1:C=I}for(let I=N;I<g.atoms.length&&g.atoms[I].i<S;I++){l(1);let q=g.atoms[I];T(q.i),x.push({k:m(q),raw:Vn,len:1,from:w,to:w+1}),w++}return T(S),x},d=(g,m,k,S,x,w)=>{if(k===S||x===w)return;if(S-k===w-x){l((S-k)*4);let A=!0;for(let E=k,X=x;E<S;E++,X++){if(n[0].text[E]!==n[m].text[X]){A=!1;break}let B=n[0].atomAt.get(E),z=n[m].atomAt.get(X);if(!!B!=!!z||B&&r[0](B)!==r[m](z)){A=!1;break}}if(A){f(g,k,S,x,"retained");return}}let T=h(n[0],r[0],k,S),N=h(n[m],r[m],x,w),C=T.length+N.length+4,I=Math.min(T.length+N.length,4e3,Math.floor((Math.sqrt(C*C+i.remaining/2)-C)/2));if(I<1)throw s;l(4*(I+1)*(C+I+1));let q=Jn(T,N,I),V=0,U=0,F=()=>{let A=T[V++],E=N[U++];l(A.len),A.raw===E.raw&&f(g,A.from,A.to,E.from,"retained")};for(let A of q.hunks){for(;V<A.bs;)F();V=A.be,U+=A.toks.length}for(;V<T.length&&U<N.length;)F()},v=g=>{let m=e.filter(q=>q.side===g-1&&a[0].has(q.source)&&a[g].has(q.target));if(!m.length)return null;let k=[],S=(q,V,U)=>{if(!a[0].has(q.source)||!a[g].has(q.target))return;let F=u(V.get(q.source).flat,n[0]),A=u(V.get(q.target).flat,n[g]);l(q.to-q.from);for(let E=0;E<q.to-q.from;E++){let X=F[q.from+E],B=A[q.targetFrom+E];if(X<0||B<0)throw s;f(k,X,X+1,B,U)}},x=new Set;for(let q of m){if(!x.has(q.retained)){x.add(q.retained);for(let V of q.retained)S(V,q.models,"retained")}for(let V of q.runs)S(V,q.models,"transfer")}k.sort((q,V)=>(l(1),q.from-V.from||q.target-V.target));let w=[];for(let q of k){l(1);let V=w[w.length-1];if(V&&q.from<V.to){if(q.target-q.from!==V.target-V.from)throw s;V.to=Math.max(V.to,q.to),q.kind==="transfer"&&(V.kind="transfer")}else w.push(q)}let T=[],N=0,C=0;for(let q of w){if(q.target<C)throw s;d(T,g,N,q.from,C,q.target),T.push(q),N=q.to,C=q.target+q.to-q.from}d(T,g,N,n[0].text.length,C,n[g].text.length);let I=zn({base:n[0],side:n[g],retained:T.filter(q=>q.kind==="retained"),transfers:T.filter(q=>q.kind==="transfer"),baseAtomKey:r[0],sideAtomKey:r[g],budget:i});if(I.status!=="ready"||!I.monotone)throw s;return I};try{let g=v(1),m=v(2);return g||m?{local:g,remote:m}:{fallback:!0}}catch(g){if(g!==s)throw g;return{fallback:!0}}}function cl(e,t,n=!1){let r=-1,o=-1;for(let i=0;i<e.list.length;i++){let l=e.list[i];l.bLo<t.lo||l.bLo>t.hi||(r<0&&(r=i),o=i)}let s=[];for(let i=r;i>=0&&i<=o;i++){let l=e.list[i],a=!n&&i===r?l.inlineStart<0?l.to:l.inlineStart:l.from,c=!n&&i===o?l.inlineEnd<0?l.from:l.inlineEnd:l.to;for(let p=a;p<c;p++)s.push(e.units[p]);i<o&&s.push(e.units[l.next])}return s}var ut=e=>!!e&&e.nodeType===1,Rs=e=>ut(e)?e.getAttribute("data-id")||e.textContent||"":e.value!==void 0?e.value:e.nodeValue||"",Pn=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function ul(e){for(let t of e)if(Pn.has(t.tagName))return!0;return!1}function pm(e,t,n){let r=null;for(let o of t.childNodes)if(!(!ut(o)||!n(o)||!o.isEqualNode(e))){if(r)return null;r=o}if(!r)return null;for(let o of e.parentNode.childNodes)if(o!==e&&o.isEqualNode(e))return null;return r}var Ho="[id],[data-id],script,head>*";function dl(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let r=Zr(n,e);if(r)return"merge:"+r.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?dc(n,t):null}}function Ls(e,t,n,r){let o=r.ignored,s=r.stats||ar(),i=ja({ignored:o,ignoreAttribute:r.ignoreAttribute,stats:s}),{unitsOf:l,meta:a}=i,c=r.baseURI,p=r.mergeTags!==null,u=dl(r.mergeTags,c),f=R=>J=>{let ue=u(J);return ue!==null?ue:R(J)},h=f(r.identity.base),d=f(r.identity.local),v=f(r.identity.remote),g=r.authored||r.identity,m=R=>R&&R.nodeType===9?R.documentElement:R,k=m(e),S=m(t),x=m(n),w=globalThis.__hyperMorphProfile,T=w?performance.now():0,N=R=>R===vn?Ho:null,C=r.scope||null,I=C?C.baseDropped:new Set,q=new Set,V=C?C.remoteDropped:new Set,U=C?C.baseIndex:vs(k,h,o,N(r.identity.base),I),F=r.localIsBase||k===S?null:vs(S,d,o,N(r.identity.local),q),A=C?C.remoteIndex:vs(x,v,o,N(r.identity.remote),V),E=R=>{let J=ut(R)&&d(R);return J&&F?.get(J)===R&&!U.has(J)?J:null},X=R=>{let J=ut(R)&&v(R);return J&&A.get(J)===R&&!U.has(J)?J:null},B=F?Bi(k,S,{analyzer:i,baseIndex:U,sideIndex:F,baseId:g.base,sideId:g.local,baseKey:h,sideKey:d,baseDropped:I,sideDropped:q,stats:s}):Rc(),z=Bi(k,x,{analyzer:i,baseIndex:U,sideIndex:A,baseId:g.base,sideId:g.remote,baseKey:h,sideKey:v,baseDropped:I,sideDropped:V,stats:s,scope:C,comparisons:r.comparisons});if(C){if(!C.held(z))return null;for(let R of C.dropped)Di(R)}let Ce=null;function Me(R){if(!Ce){Ce=new WeakMap;let J=[k];for(;J.length;){let ue=J.pop();ue.tagName==="TEMPLATE"&&ue.content&&Ce.set(ue.content,ue);for(let he of i.childrenOf(ue))he.nodeType===1&&J.push(he)}}return Ce.get(R)||null}let Be=R=>{let J=ut(R)||R.nodeType?R.parentNode:R.parent;return J&&J.nodeType===11?Me(J):J};if(z.moved.size){let R=!1;for(let J of Array.from(z.moved))!ut(J)||z.identityPaired.has(J)||!g.base(J)||y(z,Be(J))||(z.unpair(J),R=!0);R&&z.rematch()}Jt(),Y(B,z),Y(z,B);for(let R of[B,z])if(R.refused)for(let J of R.refused)R.moved.has(J)||s.ambiguousMoves++;w&&(w.alignTotal=(w.alignTotal||0)+(performance.now()-T),T=performance.now());let me=k.ownerDocument.implementation.createHTMLDocument(""),Te=new WeakMap,Xe=new WeakMap,_e=[],O=[],K=new Set,fe=[],ae=new Set,qe=new Set,ze=new Set,Ee=new WeakMap,ot=null,rt=r.lineage?.locals.length?ec():null,xt=R=>{let J=Ts(R);return J&&rt&&rt.consume(R.local),J},nt=r.conflicts||"remote",te=R=>_e.push(R),Ae=R=>_e.push(R),je=vc({roots:{base:k,local:S,remote:x},L:B,R:z,unitsOf:l,provenance:Te,policy:nt}),Fe=(R,J)=>{O.push(R),J&&je.note(R,J)},He=null,et=null,bt=Ct(),Ft=null,yt=D(k,B.map.get(k),z.map.get(k),!!r.localIsBase,!!r.childrenOnly);yt.tagName==="HTML"?me.replaceChild(yt,me.documentElement):me.body.appendChild(yt),He?.drain(yt),et?.drain(yt),w&&(w.build=(w.build||0)+(performance.now()-T));let Lt=r.childrenOnly?!lt(Se(yt),Se(x)):!Ne(yt,x),en=je.finish(yt),Ge=rt?tc({locals:r.lineage.locals,rec:rt,root:yt,provenance:Te,segments:fe,ignored:o}):null;return{doc:me,root:yt,provenance:Te,textMappers:Xe,decisions:_e,conflicts:O,recoveryLinks:en,localDiverged:Lt,mergedScripts:K,segments:fe,remoteIdOf:r.identity.remote,customIdentity:r.identity.remote!==vn,L:B,R:z,stats:s,lineage:Ge};function Ct(){let R=new Map,J=new Set;if(r.localIsBase||!B.insertedByHash)return{partner:R,drop:J};let ue=B.insertedByHash(),he=z.insertedByHash();if(!ue.size||!he.size)return{partner:R,drop:J};let le={ignored:o,remoteWins:r.remoteWins,inlineCache:Ee},ee=Ye=>{let St=0;for(let Rt=Ye.parentNode;Rt;Rt=Rt.parentNode)St++;return St},ie=[],Re=Ye=>{let St=Ye.textContent.trim();return St.split(/\s+/).length>=3||St.replace(/\s/g,"").length>=12},We=Ye=>{let St=y(B,Ye),Rt=y(z,Ye);return St&&B.reverse.get(St.parentNode)!==Ye.parentNode||Rt&&z.reverse.get(Rt.parentNode)!==Ye.parentNode},Je=(Ye,St,Rt)=>{for(let jt of Rt.parentNode.children){let Mn=jt!==Rt&&Ye.reverse.get(jt);if(Mn&&We(Mn))return!0}let Ut=Ye.reverse.get(Rt.parentNode);if(Ut){for(let jt of Ut.children)if(!y(St,jt)&&!o(jt))return!0}return!1},at=new Map([[B,new Map],[z,new Map]]),dt=(Ye,St)=>{let Rt=at.get(Ye),Ut=Rt.get(St);if(Ut===void 0){Ut=!1;for(let jt of St.children)if(Ye.reverse.has(jt)||dt(Ye,jt)){Ut=!0;break}Rt.set(St,Ut)}return Ut},ht=new Map;for(let Ye of he.values())for(let St of Ye){let Rt=X(St);Rt&&ht.set(Rt,St)}for(let Ye of ue.values())for(let St of Ye){let Rt=E(St),Ut=Rt?ht.get(Rt):null;Ut&&Ut.tagName===St.tagName&&!Wn(St,le)&&!Wn(Ut,le)&&!r.remoteWins(St)&&!r.remoteWins(Ut)&&ie.push([St,[Ut],ee(St),!0,!0])}for(let[Ye,St]of ue){let Rt=he.get(Ye);if(!Rt)continue;let Ut=St.length===1&&Rt.length===1;for(let jt of St)!Wn(jt,le)&&!E(jt)&&ie.push([jt,Rt,ee(jt),Ut&&(Re(jt)||Je(B,z,jt)||Je(z,B,Rt[0]))])}if(!ie.length)return{partner:R,drop:J};ie.sort((Ye,St)=>Ye[2]-St[2]);let ft=new Set,Mt=new Set,_t=Ye=>{for(let St of Ye.querySelectorAll("*"))ft.add(St)},Pt=(Ye,St)=>Ye.reverse.get(St.parentNode)||null;for(let[Ye,St,,Rt,Ut]of ie){if(ft.has(Ye)||Mt.has(Ye)||Ut&&(dt(B,Ye)||dt(z,St[0])))continue;let jt=Pt(B,Ye),Mn=kn=>!Mt.has(kn)&&!ft.has(kn)&&(Ut||kn.tagName===Ye.tagName&&!X(kn)&&i.equalUnits(Ye,kn)),an=St.find(kn=>jt&&Pt(z,kn)===jt&&Mn(kn))||(Rt?St.find(Mn):null);if(!an)continue;Mt.add(Ye),Mt.add(an);let sr=jt&&Pt(z,an)===jt;(!Ut||!sr||i.equalUnits(Ye,an))&&(_t(Ye),_t(an)),!sr&&(R.set(Ye,an),R.set(an,Ye),J.add(nt==="local"?an:Ye))}return{partner:R,drop:J}}function Et(R,J,ue){if(ae.add(R),bt.drop.has(R))return null;ae.add(ue);let he=J==="local"?R:ue,le=J==="local"?ue:R,ee;return i.equalUnits(he,le)?(ee=W(he,"local",!0),Te.get(ee).remote=le):ee=se(he,le),Fe({kind:"structure",el:ee,detail:"both-moved",base:null,local:he,remote:le},{unit:{b:null,l:he,r:le}}),te({kind:"insert",el:ee,source:"both"}),ee}function Jt(){if(!B.weak||!z.weak||!B.weak.size||!z.weak.size||!B.unpair)return;let R=new Map;for(let ue of B.weak){let he=y(B,ue);ut(ue)&&ut(he)&&R.set(i.unitHash(he),ue)}let J=!1;for(let ue of Array.from(z.weak)){let he=y(z,ue);if(!ut(ue)||!ut(he))continue;let le=R.get(i.unitHash(he));if(!le||le===ue||!B.weak.has(le)||y(B,ue)&&y(z,le))continue;let ee=y(B,le);ee.tagName===he.tagName&&i.equalUnits(ee,he)&&(B.unpair(le),z.unpair(ue),J=!0)}J&&(B.rematch(),z.rematch())}function Y(R,J){if(!R.weak||!R.weak.size||!J.insertedByHash)return;let ue=J.insertedByHash();if(!ue.size)return;let he=!1;for(let le of Array.from(R.weak)){let ee=y(R,le);if(!ee)continue;let ie=R===B?E(ee):X(ee);if(ie){let We=(R===B?A:F)?.get(ie);We&&We.tagName===ee.tagName&&!J.reverse.has(We)&&(R.unpair(le),he=!0);continue}let Re=ue.get(i.unitHash(ee));Re&&Re.some(We=>We.tagName===ee.tagName&&i.equalUnits(We,ee))&&(R.unpair(le),he=!0)}he&&R.rematch()}function y(R,J){if(!J)return null;if(R.map.has(J))return R.map.get(J);let ue=[],he=Be(J);for(;he&&!R.map.has(he);he=Be(he))ue.push(he);let le=he;if(!le||!R.identical.has(le))return null;R.pairIdenticalChildren(le);for(let ie=ue.length-1;ie>=0;ie--)R.pairIdenticalChildren(ue[ie]);let ee=R.map.get(J)||null;return ee&&s.lazyTwins++,ee}function M(R,J,ue,he){if(ut(R)&&Pn.has(R.tagName)&&!B.identical.has(R)&&(R.previousSibling?.nodeType===3||R.nextSibling?.nodeType===3)){let Re=Be(R),We=y(B,R),Je=y(z,R);We&&Je&&Bt(We,y(B,Re),B)&&!Bt(Je,y(z,Re),z)&&(et||=Sc({L:B,R:z,twinIn:y,unitsOf:l,view:P,parentOf:Be,ignored:o,remoteWins:r.remoteWins,eligible:at=>ut(at)&&Pn.has(at.tagName),build:D,out:me,policy:nt,provenance:Te,textMappers:Xe,segments:fe,conflicts:O,conflict:Fe,decisions:_e}),et.ensureOwner(R))}if(J===null)return null;if(he!==void 0)return He||=to(Te,Be,B,z,y,D,o,r.remoteWins,O,Fe,H,S,x),He.plan(R,J,ue,!!he),he&&(He.produced(R,he),qe.add(R)),he;if(qe.has(R)||ze.has(R))return Fe({kind:"structure",el:null,detail:"both-moved",base:R},{subject:R}),qe.has(R)?null:W(ue,J);He||=to(Te,Be,B,z,y,D,o,r.remoteWins,O,Fe,H,S,x),He.plan(R,J,ue,!0);let le=y(B,R),ee=y(z,R);(!le||!ee)&&Fe({kind:"structure",el:null,detail:"move-beats-delete",base:R},{subject:R,deleted:le?"remote":"local"});let ie=D(R,le,ee,!1);return(J==="local"?te:Ae)({kind:"move",el:ie,source:J}),ie}function P(R,J,ue,he){return he||!J||J===ue?{el:ue,asBase:!0,twin:le=>le,baseOf:le=>le,units:l(ue),here:()=>!0,parentOfTwin:()=>ue}:{el:J,asBase:!1,twin:le=>y(R,le),baseOf:le=>R.reverse.get(le),units:l(J),here:le=>ut(le)?le.parentNode===J||J.tagName==="TEMPLATE"&&le.parentNode===J.content:le.parent===J||J.tagName==="TEMPLATE"&&le.parent===J.content}}function H(R,J,ue){return!J||ue&&ue.identical.has(R)?!1:ut(R)?!i.equalUnits(R,J)||!Q(R,J,ue):R.value!==J.value}function Q(R,J,ue){if(!ue||R===J)return!0;let he=[[R,J]];for(;he.length;){let[le,ee]=he.pop(),ie=l(le),Re=l(ee);for(let We=0;We<ie.length&&We<Re.length;We++){let Je=ie[We],at=Re[We];if(!ut(Je)||!ut(at))continue;let dt=ue.map.get(Je);if(dt!==void 0&&dt!==at)return!1;let ht=ue.reverse.get(at);if(ht!==void 0&&ht!==Je)return!1;he.push([Je,at])}}return!0}function D(R,J,ue,he,le=!1){let ee=he||(ue?r.remoteWins(ue):r.remoteWins(R)),ie=R.namespaceURI&&R.namespaceURI!=="http://www.w3.org/1999/xhtml"?me.createElementNS(R.namespaceURI,R.tagName):me.createElement(R.tagName),Re={base:R,local:J||null,remote:ue||null};if(Te.set(ie,Re),ee&&!he&&J&&H(R,J,B)&&(!ue||!i.equalUnits(J,ue))&&Fe({kind:"structure",el:ie,detail:"remote-wins",base:R,local:J,remote:ue||null},{subject:R}),ae.add(R),qe.add(R),J&&ae.add(J),ue&&ae.add(ue),r.skipUnchanged&&!le&&(r.localIsBase||B.identical.has(R))&&ue&&z.identical.has(R)&&!r.remoteWins(R)){Re.unchanged=!0;for(let Je of R.attributes)Je.namespaceURI?ie.setAttributeNS(Je.namespaceURI,Je.name,Je.value):ie.setAttribute(Je.name,Je.value);return He?.produced(R,ie),ie}ze.add(R),le||Oe(R,ee?R:J,ue,ie);let We=R.tagName;if(mn(R))de(R,ee?R:J,ue,ie);else if(We==="TEXTAREA"){let Je=ee?R:J,at=R.textContent,dt=Je?Je.textContent:at,ht=ue?ue.textContent:at,ft=ge(R);if(ft&&dt!==at&&ht!==at){let Mt=we(ft,ge(Je),ge(ue),ee);Mt&&ie.appendChild(Mt)}else ie.textContent=xe(at,dt,ht,ie,"text")}else if(!et?.render(R,ie)){let Je=ce(R,J,ue,ee,ie),at=We==="TEMPLATE"&&ie.content?ie.content:ie;for(let dt of Je)at.appendChild(dt)}return ze.delete(R),He?.produced(R,ie),ie}function ge(R){if(!R)return null;let J=l(R)[0];return J&&!ut(J)&&J.kind==="text"?J:null}function xe(R,J,ue,he,le){if(J===ue)return J;if(J===R)return ue!==R&&Ae({kind:le,node:he,source:"remote"}),ue;if(ue===R)return te({kind:le,node:he,source:"local"}),J;let ee=nt==="local"?J:ue;return Fe({kind:le,node:he,base:R,local:J,remote:ue,resolved:ee},{site:"whole",el:he}),_e.push({kind:le,node:he,source:"both"}),ee}function de(R,J,ue,he){let le=R.textContent,ee=J?J.textContent:le,ie=ue?ue.textContent:le,Re=p?Zr(R,r.mergeTags,!0):null;if(Re&&ee!==ie){let We=ue&&ue.getAttribute("merge-key")||R.getAttribute("merge-key"),{text:Je,warnings:at,conflicts:dt}=il(r.localIsBase?void 0:le,ee,ie,{parse:Re.recognizer.parse,keyCandidates:We?We.split(/[\s,]+/).filter(Boolean):void 0});for(let ht of at)console.warn(`[hyper-morph] merge "${Re.raw}": ${ht}`);for(let ht of r.localIsBase?[]:dt)Fe({kind:"json",node:he,name:Re.raw,path:ht.path,base:ht.base,local:ht.local,remote:ht.remote,resolved:ht.resolved});he.textContent=Je,K.add(he),Je!==ie?te({kind:"text",node:he,source:Je===ee?"local":"both"}):Je!==le&&Ae({kind:"text",node:he,source:"remote"});return}he.textContent=xe(le,ee,ie,he,"text")}function Oe(R,J,ue,he){let le=new Map;for(let ee of[R,J,ue])if(ee)for(let ie of ee.attributes)r.ignoreAttribute(ee,ie.name)||le.set(ie.name,ie);for(let[ee,ie]of le){let Re=R?R.getAttribute(ee):null,We=J?J.getAttribute(ee):Re,Je=ue?ue.getAttribute(ee):Re,at;We===Je?at=We:We===Re?(at=Je,Ae({kind:"attr",el:he,name:ee,source:"remote"})):Je===Re?(at=We,te({kind:"attr",el:he,name:ee,source:"local"})):(at=ke(ee,Re,We,Je)??$(ee,[R,J,ue],Re,We,Je),at===void 0&&(at=nt==="local"?We:Je,Fe({kind:"attr",el:he,name:ee,base:Re,local:We,remote:Je,resolved:at},{el:he,sample:ie})),_e.push({kind:"attr",el:he,name:ee,source:"both"})),at!=null&&(ie.namespaceURI?he.setAttributeNS(ie.namespaceURI,ie.name,at):he.setAttribute(ee,at))}}function $(R,J,ue,he,le){let ee=r.attributeMerge;if(typeof ee!="function")return;let ie=J.filter(Boolean).map(Re=>ee(Re,R));if(!(!ie.length||ie.some(Re=>Re!==ie[0]))){if(ie[0]==="tokens")return Z(ue,he,le);if(ie[0]==="max"){let Re=Number(he),We=Number(le);return Number.isFinite(Re)&&Number.isFinite(We)&&he!==""&&le!==""?String(Math.max(Re,We)):void 0}}}function Z(R,J,ue){let he=ht=>[...new Set((ht||"").split(/\s+/).filter(Boolean))],le=he(R),ee=new Set(le),ie=new Set(he(J)),Re=new Set(he(ue)),We=ht=>ie.has(ht)===Re.has(ht)?ie.has(ht):ie.has(ht)===ee.has(ht)?Re.has(ht):ie.has(ht),Je=le.filter(We),at=[...new Set([...ie,...Re])].filter(ht=>!ee.has(ht)&&We(ht)).sort(),dt=[...Je,...at];return dt.length?dt.join(" "):null}function ke(R,J,ue,he){if(R==="class"){let le=Je=>new Set((Je||"").split(/\s+/).filter(Boolean)),ee=le(J),ie=le(ue),Re=le(he),We=new Set;for(let Je of new Set([...ee,...ie,...Re])){let at=ee.has(Je),dt=ie.has(Je),ht=Re.has(Je);(dt===ht?dt:dt===at?ht:dt)&&We.add(Je)}return[...We].join(" ")}if(R==="style"){let le=at=>{let dt=new Map;if(!at)return dt;let ht=0,ft=null,Mt="",_t=()=>{let Pt=Mt.indexOf(":");Pt>0&&dt.set(Mt.slice(0,Pt).trim(),Mt.slice(Pt+1).trim()),Mt=""};for(let Pt of at){if(ft){Mt+=Pt,Pt===ft&&(ft=null);continue}if(Pt==='"'||Pt==="'"){ft=Pt,Mt+=Pt;continue}if(Pt==="("?ht++:Pt===")"&&ht--,Pt===";"&&ht===0){_t();continue}Mt+=Pt}return Mt.trim()&&_t(),dt},ee=le(J),ie=le(ue),Re=le(he),We=new Map,Je=!1;for(let at of new Set([...ee.keys(),...ie.keys(),...Re.keys()])){let dt=ee.get(at)??null,ht=ie.get(at)??null,ft=Re.get(at)??null,Mt;ht===ft?Mt=ht:ht===dt?Mt=ft:ft===dt?Mt=ht:(Mt=nt==="local"?ht:ft,Je=!0),Mt!=null&&We.set(at,Mt)}return Je?void 0:[...We].map(([at,dt])=>`${at}: ${dt}`).join("; ")}}function we(R,J,ue,he){let le=R.value,ee=he?le:J?J.value:"",ie=ue?ue.value:"";ae.add(R),J&&ae.add(J),ue&&ae.add(ue);let Re=qo(le,ee,ie,nt),We=Re.text===""?null:me.createTextNode(Re.text);We&&(Te.set(We,{base:R.nodes,local:J?J.nodes:null,remote:ue?ue.nodes:null}),Xe.set(We,Re.mapLocalOffset)),ee!==le&&ie!==le?_e.push({kind:"text",node:We,source:"both"}):ee!==le?te({kind:"text",node:We,source:"local"}):ie!==le&&Ae({kind:"text",node:We,source:"remote"});for(let Je of Re.conflicts)Fe({kind:"text",node:We,base:le.slice(Je.bs,Je.be),local:Je.local,remote:Je.remote,resolved:Je.resolved},{site:"run",bRun:R,lRun:J,rRun:ue,node:We,c:Je});return We}function ve(R,J){return Er(R,J).every(ue=>ue.bs===ue.be)}function ne(R,J){let ue=R?R.value:"",he=J?J.value:"",le;if(ue===he||!he?le=ue:ue?ve(ue,he)?le=he:ve(he,ue)?le=ue:(le=nt==="local"?ue:nt==="both"?ue+he:he,Fe({kind:"structure",el:null,detail:"insert-collision",local:ue,remote:he,resolved:le},{unit:{b:null,l:R,r:J},localLost:nt==="remote"})):le=he,R&&ae.add(R),J&&ae.add(J),le==="")return null;let ee=me.createTextNode(le);return Te.set(ee,{base:null,local:R?R.nodes:null,remote:J?J.nodes:null}),ue?te({kind:"insert",el:ee,source:he&&ue===he?"both":"local"}):Ae({kind:"insert",el:ee,source:"remote"}),ee}function se(R,J){let ue={ignored:o,remoteWins:r.remoteWins,inlineCache:Ee},he=Re=>l(Re).every(We=>ut(We)?Wn(We,ue):We.kind==="text"),le=null;if(he(R)&&he(J)){let Re=R.textContent,We=J.textContent;Re===We||ve(We,Re)?le=J:ve(Re,We)&&(le=R)}if(!le){let Re=nt==="local",We=W(Re?R:J,Re?"local":"remote",!0),Je=Te.get(We);return Re?Je.remote=J:Je.local=R,Fe({kind:"structure",el:We,detail:"insert-collision",local:R,remote:J,resolved:Re?R:J},{unit:{b:null,l:R,r:J},localLost:!Re}),We}let ee=R.namespaceURI&&R.namespaceURI!=="http://www.w3.org/1999/xhtml"?me.createElementNS(R.namespaceURI,R.tagName):me.createElement(R.tagName);Oe(null,R,J,ee),Te.set(ee,{base:null,local:R,remote:J}),ae.add(R),ae.add(J);let ie=xt({base:Array.from(le.childNodes),local:Array.from(R.childNodes),remote:Array.from(J.childNodes),out:me,policy:nt,idOf:{local:d,remote:v},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,provenance:Te,textMappers:Xe,conflicts:O,conflict:Fe,scope:{base:null,local:R,remote:J,units:[],at:0},synthetic:!0,decisions:_e,node:ee});fe.push(...ie.segments);for(let Re of ie.nodes)ee.appendChild(Re);return ee}function W(R,J,ue=!1){if(!ue&&ut(R)){let ie=bt.partner.get(R);if(ie)return Et(R,J,ie)}if(!ut(R)){if(R.value==="")return null;let ie=R.kind==="comment"?me.createComment(R.value):me.createTextNode(R.value);return Te.set(ie,{base:null,local:J==="local"?R.nodes:null,remote:J==="remote"?R.nodes:null}),ae.add(R),ie}let he=R.namespaceURI&&R.namespaceURI!=="http://www.w3.org/1999/xhtml"?me.createElementNS(R.namespaceURI,R.tagName):me.createElement(R.tagName);for(let ie of R.attributes)ie.namespaceURI?he.setAttributeNS(ie.namespaceURI,ie.name,ie.value):he.setAttribute(ie.name,ie.value);Te.set(he,{base:null,local:J==="local"?R:null,remote:J==="remote"?R:null}),ae.add(R);let le=R.tagName==="TEMPLATE"&&he.content?he.content:he,ee=J==="local"?B:z;for(let ie of l(R)){let Re=ut(ie)?ee.reverse.get(ie):null;if(Re&&M(Re,null,null),Re&&qe.has(Re)){Fe({kind:"structure",el:null,detail:"both-moved",base:Re},{subject:Re});continue}if(Re&&!ze.has(Re)){let Je=y(B,Re)||null,at=y(z,Re)||null;if(Je||at){He||=to(Te,Be,B,z,y,D,o,r.remoteWins,O,Fe,H,S,x),He.plan(Re,J,ie,!0);let dt=D(Re,Je,at,!1);J==="local"?te({kind:"move",el:dt,source:"local"}):Ae({kind:"move",el:dt,source:"remote"}),le.appendChild(dt);continue}}let We=W(ie,J);We&&le.appendChild(We)}if(!ue&&bt.drop.size&&R.tagName==="DIV"&&!le.firstChild&&!R.attributes.length&&!(J==="local"?d(R):v(R))&&!ee.reverse.has(R)&&!o(R)&&!r.remoteWins(R)){let ie=R.firstChild;if(ie&&ie===R.lastChild&&ut(ie)&&(bt.drop.has(ie)||Ft?.has(ie)))return(Ft||=new WeakSet).add(R),null}return he}function ce(R,J,ue,he,le){J&&B.identical.has(R)&&B.pairIdenticalChildren(R),ue&&z.identical.has(R)&&z.pairIdenticalChildren(R);let ee=P(B,J,R,he),ie=P(z,ue,R,!1),Re=l(R),We=new Set(Re),Je=new Map;for(let re=0;re<Re.length;re++)Je.set(Re[re],re);let at=re=>!ut(re)&&re.kind==="text"&&!/[^\t\n\f\r ]/.test(re.value),dt=[],ht=new Set,ft=new Map,Mt=new Set,_t=rt&&[],Pt=rt&&[],Ye=new Set,St=[],Rt=null,Ut=new Map;if(!ee.asBase&&!ie.asBase&&!B.identical.has(R)&&!z.identical.has(R))for(let re of Re){if(!ut(re)||!Pn.has(re.tagName))continue;let $e=ee.twin(re),Ue=ie.twin(re);$e&&Ue&&(!ee.here($e)||!ie.here(Ue))&&M(re,null,null)}let jt=(re,$e=!1)=>{let Ue=[];for(let Ze of re.units){if(Ye.has(Ze)||!$e&&at(Ze))continue;let wt=re.baseOf(Ze);wt&&We.has(wt)&&Ue.push(wt)}return Ue},Mn=re=>jt(re).map($e=>Je.get($e)),an=re=>re.every(($e,Ue)=>Ue===0||$e>=re[Ue-1]),sr=()=>{let re=!ee.asBase&&!an(Mn(ee)),$e=!ie.asBase&&!an(Mn(ie)),Ue=null;if(re&&$e){let Ze=jt(ee),wt=jt(ie);if(Ue=bm(Re.filter(Ke=>!Ye.has(Ke)&&!at(Ke)),Je,Ze,wt),Ue){let Ke=fl(Ze.map(mt=>Je.get(mt))),Ve=fl(wt.map(mt=>Je.get(mt)));for(let mt of Ke)Ve.has(mt)&&(Ue=null)}}return{lRe:re,rRe:$e,settled:Ue}},kn=sr();bs(kn.lRe&&kn.rRe);let{lRe:xr,rRe:Rn,settled:$r}=sr(),Co=xr&&Rn;Co&&!$r&&Fe({kind:"structure",el:le,detail:"both-reordered",base:R},{subject:R,lKept:jt(ee,!0),rKept:jt(ie,!0)});let tn=Rn||!xr?{V:ie,A:z,side:"remote",other:ee,otherA:B,otherSide:"local"}:{V:ee,A:B,side:"local",other:ie,otherA:z,otherSide:"remote"},Yn=null,_o=null;if(Co){Yn=Hr(tn.V.units),_o=tn.V.units,$r&&(tn.V=km(tn.V,$r));for(let re of Re)at(re)&&ae.add(re);for(let re of[ee,ie])for(let $e of re.units)at($e)&&ae.add($e)}xr?te({kind:"move",el:null,source:Rn?"both":"local",base:R}):Rn&&Ae({kind:"move",el:null,source:"remote",base:R});let Ur=ee.asBase?[]:ee.units.filter(re=>!ee.baseOf(re)&&!Ye.has(re)&&!bt.partner.has(re)),wr=ie.asBase?[]:ie.units.filter(re=>!ie.baseOf(re)&&!Ye.has(re)&&!bt.partner.has(re)),Fn=new Map;if(Ur.length&&wr.length){let re=new Map,$e=new Map;for(let Ke of wr){if(ut(Ke)){let mt=v(Ke);mt&&re.set(mt,Ke)}let Ve=i.unitHash(Ke);$e.has(Ve)||$e.set(Ve,[]),$e.get(Ve).push(Ke)}let Ue=(Ke,Ve)=>{let mt=Ke.units.indexOf(Ve);for(let Qe=mt-1;Qe>=0;Qe--){let pt=Ke.baseOf(Ke.units[Qe]);if(pt)return pt}return"start"},Ze=new Map,wt=new Map;for(let Ke of wr){let Ve=Ue(ie,Ke);ut(Ke)?(wt.has(Ve)||wt.set(Ve,[]),wt.get(Ve).push(Ke)):Ke.kind==="text"&&!Ze.has(Ve)&&Ze.set(Ve,Ke)}for(let Ke of Ur){let Ve=null;if(ut(Ke)){let Qe=d(Ke);Qe&&re.has(Qe)&&!Fn.has(re.get(Qe))&&(Ve=re.get(Qe))}else if(Ke.kind==="text"){let Qe=Ze.get(Ue(ee,Ke));Qe&&!Fn.has(Qe)&&(Ve=Qe)}let mt=!!E(Ke);if(!Ve&&!mt){let Qe=$e.get(i.unitHash(Ke));Qe&&(Ve=Qe.find(pt=>!Fn.has(pt)&&ut(pt)===ut(Ke)&&(ut(pt)?pt.tagName===Ke.tagName&&!X(pt):pt.kind===Ke.kind)&&i.equalUnits(Ke,pt))||null)}if(!Ve&&ut(Ke)&&!mt){let Qe=g.local(Ke),pt=(wt.get(Ue(ee,Ke))||[]).filter(kt=>{let Ot=g.remote(kt);return!Fn.has(kt)&&kt.tagName===Ke.tagName&&!X(kt)&&!(Qe&&Ot&&Qe!==Ot)&&i.similar(Ke,kt)});pt.length===1&&(Ve=pt[0])}Ve&&(Fn.set(Ve,Ke),Fn.set(Ke,Ve))}}let ms=re=>{if(et?.consumes(re))return null;if(ae.has(re)||He?.has(re))return ft.get(re)||null;let $e=ee.twin(re),Ue=ie.twin(re),Ze=$e&&!ee.asBase&&!ee.here($e),wt=Ue&&!ie.asBase&&!ie.here(Ue);if(Ze||wt){if((!$e||!Ue)&&Fe({kind:"structure",el:null,detail:"move-beats-delete",base:re},{subject:re,deleted:$e?"remote":"local"}),!Zt(re))return ut(re)?(He||=to(Te,Be,B,z,y,D,o,r.remoteWins,O,Fe,H,S,x),Ze&&He.plan(re,"local",$e),wt&&He.plan(re,"remote",Ue)):ae.add(re),null;Fe({kind:"structure",el:null,detail:"both-moved",base:re},{subject:re})}if($e&&!Ue&&!ee.asBase&&!ie.asBase&&ut(re)&&Pn.has(re.tagName)&&!r.remoteWins(re)&&!r.remoteWins($e)&&H(re,$e,B)&&pm(re,Se(ie.el),o)){let pt={ignored:o,remoteWins:r.remoteWins,inlineCache:Ee},kt=Ot=>ut(Ot)?Wn(Ot,pt):Ot.kind==="text";if(l(re).every(kt)&&l($e).every(kt)){let Ot=xt({base:[re],local:[$e],remote:[],blocks:new Set([re,$e]),out:me,policy:nt,L:B,R:z,idOf:{base:h,local:d,remote:v},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(qt,$n,lr)=>D(qt,$n,lr,!1),cloneUnit:W,mergeAttrs:Oe,atomKey:i.exactUnitKey,moveIn:M,moveBuilt:M,movePlanned:M,provenance:Te,textMappers:Xe,conflicts:O,conflict:Fe,scope:{base:R,local:ee.el,remote:ie.el,units:Re,at:Je.get(re)},decisions:_e,node:le});fe.push(...Ot.segments),ae.add(re),ae.add($e);let At=me.createDocumentFragment();for(let qt of Ot.nodes)At.appendChild(qt);return ft.set(re,At),ft.set($e,At),At}}if(!$e&&!Ue)return ae.add(re),Ae({kind:"remove",source:"both",base:re}),null;if(!$e&&!H(re,Ue,z))return ae.add(re),te({kind:"remove",source:"local",base:re}),null;if(!Ue&&!H(re,$e,B))return ae.add(re),Ae({kind:"remove",source:"remote",base:re}),rt&&(rt.remove($e),_t.push({bk:re,lk:$e})),null;let Ke=!$e||!Ue,Ve=ee.asBase?y(B,re)||null:$e,mt=ie.asBase&&ut(re)&&(z.identityPaired.has(re)||!g.base(re))&&y(z,re)||Ue,Qe;return ut(re)?Qe=D(re,Ve,mt,ee.asBase):re.kind==="comment"?Qe=Ht(re,Ve,Ue,ee.asBase):Qe=we(re,Ve,Ue,ee.asBase),ae.add(re),Qe&&(ft.set(re,Qe),$e&&ft.set($e,Qe),Ue&&ft.set(Ue,Qe),Ke&&(Fe({kind:"structure",el:Qe,detail:"edit-beats-delete",base:re},{subject:re,deleted:$e?"remote":"local"}),$e?te({kind:"insert",el:Qe,source:"local"}):Ae({kind:"insert",el:Qe,source:"remote"}))),Qe},ps=(re,$e,Ue,Ze)=>{if(et?.consumes(re))return null;if(ae.has(re))return ft.get(re)||null;let wt=$e.baseOf(re);if(wt&&We.has(wt))return Ye.has(wt)&&!Ye.has(re)?gs(wt,re,Ze):ms(wt);if(wt)return Xn(wt,re,Ze);let Ke=Fn.get(re);if(Ke){let mt=Ze==="local"?re:Ke,Qe=Ze==="local"?Ke:re,pt;return ut(mt)?i.equalUnits(mt,Qe)?(pt=W(mt,"local"),pt&&(Te.get(pt).remote=Qe)):pt=se(mt,Qe):pt=ne(mt,Qe),ae.add(mt),ae.add(Qe),pt&&(ft.set(mt,pt),ft.set(Qe,pt),ut(mt)&&te({kind:"insert",el:pt,source:"both"})),pt}let Ve=W(re,Ze);return Ve&&(ft.set(re,Ve),Ze==="local"?te({kind:"insert",el:Ve,source:"local"}):(Ae({kind:"insert",el:Ve,source:"remote"}),rt&&ut(re)&&!bt.partner.has(re)&&Pt.push({su:re,node:Ve}))),Ve},gs=(re,$e,Ue)=>{let Ze;return ut(re)?(Ze=M(re,Ue,$e),Ze&&ae.add($e)):(Ze=W($e,Ue),ae.add($e),Ze&&(Ue==="local"?te:Ae)({kind:"insert",el:Ze,source:Ue})),Ze&&ft.set($e,Ze),Ze},Xn=(re,$e,Ue)=>{M(re,null,null);let wt=y(Ue==="local"?z:B,re),Ke=$e,Ve=wt?Bt(wt,Ue==="local"?ue:J,Ue==="local"?z:B):!1,mt=wt&&!Ve&&!Wt(re,wt);if(mt&&Ue===tn.otherSide)return Fe({kind:"structure",el:null,detail:"both-moved",base:re},{subject:re}),null;if(mt&&Fe({kind:"structure",el:null,detail:"both-moved",base:re},{subject:re}),wt||Fe({kind:"structure",el:null,detail:"move-beats-delete",base:re},{subject:re,deleted:Ue==="local"?"remote":"local"}),ze.has(re)){Fe({kind:"structure",el:null,detail:"both-moved",base:re},{subject:re});let pt=W(Ke,Ue);return pt&&ft.set($e,pt),pt}ut(re)&&(He||=to(Te,Be,B,z,y,D,o,r.remoteWins,O,Fe,H,S,x),He.plan(re,Ue,Ke,!0));let Qe=ut(re)?D(re,Ue==="local"?Ke:y(B,re)||null,Ue==="remote"?Ke:y(z,re)||null,!1):null;return Qe&&(ft.set(re,Qe),ft.set($e,Qe),wt&&ft.set(wt,Qe),Ue==="local"?te({kind:"move",el:Qe,source:"local"}):Ae({kind:"move",el:Qe,source:"remote"})),Qe};for(let re of tn.V.units){if(Ye.has(re)){if(Rt?.has(re)){for(let Ze of Rt.get(re))ht.has(Ze)||(dt.push(Ze),ht.add(Ze));continue}let Ue=ft.get(re);ht.has(Ue)||(dt.push(Ue),ht.add(Ue));continue}if(ae.has(re)&&!(ft.get(re)&&ht.has(ft.get(re)))){let Ue=tn.V.baseOf(re);Ue&&!We.has(Ue)&&Fe({kind:"structure",el:null,detail:"both-moved",base:Ue},{subject:Ue});continue}let $e=ps(re,tn.V,tn.A,tn.side);$e&&!ht.has($e)&&(dt.push($e),ht.add($e),!tn.V.baseOf(re)&&!Fn.has(re)&&!Ye.has(re)&&Mt.add($e))}for(let re of St)ht.has(re.frag)||(dt.splice(re.previous&&ht.has(re.previous)?dt.indexOf(re.previous)+1:Lo(re.at),0,re.frag),ht.add(re.frag));if(!tn.other.asBase){let re=tn.other,$e=tn.otherSide,Ue=tn.otherA,Ze=null,wt=0,Ke=null;for(let Ve of re.units){let mt=Ut.get(Ve)||ft.get(Ve);if(mt&&ht.has(mt)){Ze=mt,Ke=null;continue}if(ae.has(Ve)){let At=re.baseOf(Ve);At&&!We.has(At)&&Fe({kind:"structure",el:null,detail:"both-moved",base:At},{subject:At});continue}let Qe=ps(Ve,re,Ue,$e);if(!Qe)continue;let pt=!re.baseOf(Ve)&&!Ye.has(Ve),kt=!Ze&&!Ke,Ot=Ke?dt.indexOf(Ke)+1:Ze?dt.indexOf(Ze)+1:wt;if(pt&&ut(Qe)){let At=Rs(Qe);for(;Ot<dt.length&&Mt.has(dt[Ot])&&ut(dt[Ot])&&Rs(dt[Ot])<At;)Ot++}else if(Ze&&!Ke&&$e==="remote")for(;Ot<dt.length&&Mt.has(dt[Ot]);)Ot++;dt.splice(Ot,0,Qe),ht.add(Qe),pt&&Mt.add(Qe),kt&&(wt=Ot+1),Ke=Qe}}for(let re=0;re<Re.length;re++){let $e=Re[re];if(ae.has($e))continue;let Ue=ms($e);Ue&&dt.splice(Lo(re),0,Ue)}return rt&&_t.length&&Pt.length&&ir(),Co?Bn(dt):dt;function ir(){if(xr||Rn)return;let re=new Set(dt),$e=kt=>kt&&We.has(kt)&&re.has(ft.get(kt))?kt:null,Ue=(kt,Ot)=>{let At=[{prev:null,units:[]}];for(let qt of kt){let $n=$e(Ot(qt));$n?At.push({prev:$n,units:[]}):At[At.length-1].units.push(qt)}return At},Ze=Ue(Re,kt=>kt),wt=Ue(ie.units,ie.baseOf),Ke=ee.asBase?null:Ue(ee.units,ee.baseOf),Ve=kt=>kt.length===Ze.length&&kt.every((Ot,At)=>Ot.prev===Ze[At].prev);if(!Ve(wt)||Ke&&!Ve(Ke))return;let mt=new Map(_t.map(kt=>[kt.bk,kt])),Qe=new Map(Pt.map(kt=>[kt.su,kt])),pt=kt=>kt?dt.indexOf(ft.get(kt)):-1;for(let kt=0;kt<Ze.length;kt++){if(Ze[kt].units.length!==1||wt[kt].units.length!==1)continue;let Ot=mt.get(Ze[kt].units[0]),At=Qe.get(wt[kt].units[0]);if(!Ot||!At||Ke&&(Ke[kt].units.length!==1||Ke[kt].units[0]!==Ot.lk))continue;let qt=pt(Ze[kt].prev);(kt+1<Ze.length?pt(Ze[kt+1].prev):dt.length)-qt!==2||dt[qt+1]!==At.node||Mo(Ot.bk,Ot.lk,At.su)&&rt.link(Ot.lk,At.node)}}function Sr(re,$e,Ue,Ze){let wt=At=>{let qt=At.filter(ut);return qt.length===1?qt[0]:null},Ke=wt(re),Ve=wt($e),mt=wt(Ue);if(!Ke||!Ve||!mt)return;let Qe=re.indexOf(Ke);if($e.indexOf(Ve)!==Qe||Ue.indexOf(mt)!==Qe||re.length!==$e.length||re.length!==Ue.length)return;for(let At=0;At<re.length;At++)if(At!==Qe&&(re[At].value!==$e[At].value||re[At].value!==Ue[At].value))return;if((ee.asBase?Ke:ee.twin(Ke))!==Ve||ie.twin(Ke)||z.reverse.get(mt)||Ve!==Ke&&H(Ke,Ve,B))return;let pt=Ze.filter(At=>At.nodeType===1);if(pt.length!==1||Te.get(pt[0])?.remote!==mt)return;let kt=At=>At.map(qt=>ut(qt)?"":qt.value??qt.nodeValue).join(""),Ot=Ze.indexOf(pt[0]);kt(Ze.slice(0,Ot))!==kt(re.slice(0,Qe))||kt(Ze.slice(Ot+1))!==kt(re.slice(Qe+1))||Mo(Ke,Ve,mt)&&rt.link(Ve,pt[0])}function Mo(re,$e,Ue){if(!ut($e)||!ut(Ue)||!ut(re)||$e.namespaceURI!==Ue.namespaceURI||$e.localName===Ue.localName)return!1;for(let Ve of[$e,Ue])if(Ve.tagName==="TEMPLATE"||mn(Ve)||Ve.querySelector("template"))return!1;if(r.remoteWins(re)||r.remoteWins(Ue)||o(Ue)||$e.attributes.length!==Ue.attributes.length)return!1;for(let Ve of $e.attributes)if(Ue.getAttributeNS(Ve.namespaceURI,Ve.localName)!==Ve.value)return!1;let Ze=$e.childNodes,wt=Ue.childNodes;if(Ze.length!==wt.length)return!1;for(let Ve=0;Ve<Ze.length;Ve++)if(!Ze[Ve].isEqualNode(wt[Ve]))return!1;let Ke=[[re,Ue]];for(;Ke.length;){let[Ve,mt]=Ke.pop();if(Ve.children.length!==mt.children.length)return!1;for(let Qe=0;Qe<mt.children.length;Qe++){let pt=z.reverse.get(mt.children[Qe]);if(pt!==void 0&&pt!==Ve.children[Qe])return!1;Ke.push([Ve.children[Qe],mt.children[Qe]])}}return!0}function Hr(re){let $e=[[]];for(let Ue of re)at(Ue)?$e[$e.length-1].push(Ue):$e.push([]);return $e}function Bn(re){let $e=Hr(Re),Ue=(Qe,pt)=>{let kt=new Map,Ot=Qe.filter(At=>!at(At));for(let At=0;At<Ot.length;At++)kt.set(Ot[At],pt[At+1]);return kt},Ze=Ue(Re,$e),wt=Ue(_o,Yn),Ke=new Map;for(let[Qe,pt]of ft){if(!pt||Ke.has(pt))continue;let kt=Ze.get(Qe),Ot=wt.get(Qe);(kt||Ot)&&Ke.set(pt,[kt,Ot])}let Ve=[],mt=Ro($e[0],Yn[0]);mt&&Ve.push(mt);for(let Qe of re){Ve.push(Qe);let pt=Ke.get(Qe),kt=pt?Ro(pt[0],pt[1]):null;kt&&Ve.push(kt)}return Ve}function Ro(re,$e){let Ue=!!re&&re.length>0,Ze=Ue?re:$e||[],wt=Ze.map(mt=>mt.value).join("");if(wt==="")return null;let Ke=me.createTextNode(wt),Ve=mt=>{let Qe=[];for(let pt of mt||[])pt&&Qe.push(...pt.nodes);return Qe.length?Qe:null};return Te.set(Ke,Ue?{base:Ve(re),local:Ve(re.map(mt=>ee.asBase?null:ee.twin(mt))),remote:Ve(re.map(mt=>ie.asBase?null:ie.twin(mt)))}:{base:null,local:tn.side==="local"?Ve(Ze):null,remote:tn.side==="remote"?Ve(Ze):null}),Ke}function Lo(re){for(let $e=re-1;$e>=0;$e--){let Ue=ft.get(Re[$e]);if(Ue){let Ze=dt.indexOf(Ue);if(Ze>=0)return Ze+1}}return 0}function bs(re){if((ee.asBase||B.identical.has(R))&&(ie.asBase||z.identical.has(R)))return;let $e={ignored:o,remoteWins:r.remoteWins,inlineCache:Ee},Ue=vt=>ut(vt)?Wn(vt,$e):vt.kind==="text";if(!ee.asBase&&!ie.asBase)for(let vt of Re){if(!ut(vt)||!Pn.has(vt.tagName))continue;let b=ee.twin(vt),_=ie.twin(vt);if(!b&&_||b&&!_){let L=Oc({base:Re,views:[{V:ee,A:B,idOf:g.local},{V:ie,A:z,idOf:g.remote}],eligible:j=>ut(j)&&Pn.has(j.tagName)&&!o(j)&&!r.remoteWins(j),baseId:g.base,ignored:o,remoteWins:r.remoteWins,atomKey:i.exactUnitKey});L&&(ee=L[0],ie=L[1]);break}}let Ze=!ee.asBase&&!ie.asBase&&Re.length>=2&&Pn.has(Re[0].tagName)&&ee.units.length===Re.length&&ie.units.length===Re.length?ac({base:Re,local:ee.units,remote:ie.units,localTwin:ee.twin,remoteTwin:ie.twin,eligible:vt=>ut(vt)&&Pn.has(vt.tagName)&&!o(vt)&&!r.remoteWins(vt),nodes:{base:Array.from(Se(R).childNodes),local:Array.from(Se(ee.el).childNodes),remote:Array.from(Se(ie.el).childNodes)}}):null,wt=null,Ke=null;if(!Ze&&!ee.asBase&&!ie.asBase&&(ul(Re)||ul(ee.units)||ul(ie.units))){let vt={ignored:o,remoteWins:()=>!1},b=L=>Ue(L)||ut(L)&&r.remoteWins(L)&&wn.has(L.tagName)&&Wn(L,vt),_=L=>ut(L)?Pn.has(L.tagName)&&!o(L)&&!r.remoteWins(L)&&l(L).every(b):L.kind==="text";wt=Nc({onUncertainOwner:L=>{let j=r.identity.local(L.local);j&&j===r.identity.remote(L.remote)||(Ke||=[]).push(L)},onUncertainSource:L=>{ot||(ot=new Map);let j=ot.get(L.source);j||ot.set(L.source,j=[]);for(let G of j)if(G.side===L.side&&G.from===L.from&&G.to===L.to)return;j.push(L)},base:Re,views:[{V:ee,A:B,idOf:g.local},{V:ie,A:z,idOf:g.remote}],eligible:_,ignored:o,remoteWins:r.remoteWins,baseId:g.base,atomKey:i.exactUnitKey})}if(Ke){Rt||=new Map;for(let vt of Ke){let{source:b,local:_,remote:L}=vt,j={map:new Map,reverse:new Map,identical:new Set},G=xt({base:[b],local:[_],remote:[L],out:me,policy:"both",L:j,R:j,ignored:o,remoteWins:r.remoteWins,atomKey:i.exactUnitKey,cloneUnit:W,provenance:Te,textMappers:Xe,conflicts:O,decisions:_e,conflict:(oe,be)=>Fe(oe,{...be,policy:"both"}),scope:{base:R,local:ee.el,remote:ie.el,units:Re,at:Je.get(b)},node:le});fe.push(...G.segments);for(let oe of[b,_,L])ae.add(oe),Ye.add(oe),Rt.set(oe,G.nodes),ft.set(oe,G.nodes[G.nodes.length-1]);for(let oe=0;oe<G.nodes.length;oe++)St.push({frag:G.nodes[oe],at:Je.get(b),previous:oe?G.nodes[oe-1]:null})}}let Ve=Ze?Ze.blocks:null;if(wt){Ve=new Set;for(let vt of wt.blocks)Ve.add(vt)}let mt=vt=>!et?.consumes(vt)&&(Ve&&Ve.has(vt)||Ue(vt)),Qe=Re.map(mt);if(!Qe.includes(!0))return;let pt=vt=>{let b=vt.units,_=new Map;for(let ye=0;ye<b.length;ye++)_.set(b[ye],ye);let L=[],j=-1;for(let ye=0;ye<Re.length;ye++){if(Qe[ye])continue;let Ie=vt.twin(Re[ye]),pe=Ie?_.get(Ie):void 0;pe===void 0||pe<=j||mt(Ie)||(L.push([ye,pe]),j=pe)}let G=[],oe=-1,be=-1;for(let ye=0;ye<=L.length;ye++){let[Ie,pe]=ye<L.length?L[ye]:[Re.length,b.length],Le={bLo:-1,bHi:-1,from:be+1,to:pe,inlineStart:-1,inlineEnd:-1,next:pe};for(let st=oe+1;st<Ie;st++)Qe[st]&&(Le.bLo<0&&(Le.bLo=st),Le.bHi=st);for(let st=be+1;st<pe;st++){let ct=b[st];mt(ct)&&(Le.inlineStart<0&&(Le.inlineStart=st),Le.inlineEnd=st+1)}G.push(Le),oe=Ie,be=pe}return{units:b,list:G}},kt=pt(ee),Ot=pt(ie),At=[];for(let vt of[kt,Ot])for(let b of vt.list)b.bLo>=0&&At.push([b.bLo,b.bHi]);At.sort((vt,b)=>vt[0]-b[0]);let qt=[];for(let[vt,b]of At){let _=qt[qt.length-1];_&&vt<=_.hi?_.hi=Math.max(_.hi,b):qt.push({lo:vt,hi:b})}let $n=(vt,b)=>vt.length===b.length&&vt.every((_,L)=>i.equalUnits(_,b[L])),lr=vt=>!ut(vt)&&vt.kind==="comment",zr=vt=>{if(!vt.length)return[];let b=(oe,be)=>ut(oe)?oe:oe.nodes[be?oe.nodes.length-1:0],_=b(vt[0]),L=b(vt[vt.length-1],!0),j=oe=>oe&&ut(oe)&&o(oe);for(;j(_.previousSibling);)_=_.previousSibling;for(;j(L.nextSibling);)L=L.nextSibling;let G=[];for(let oe=_;oe&&(G.push(oe),oe!==L);oe=oe.nextSibling);return G},Oi=vt=>vt.some(b=>ut(b)&&o(b));for(let vt of qt){let b=Re.slice(vt.lo,vt.hi+1);if(re&&!b.some(Ie=>mt(Ie)&&!at(Ie)))continue;let _=null;if(wt)for(let Ie of b){let pe=wt.certificatesBySource.get(Ie);pe&&(_||=[]).push(...pe)}let L=ee.asBase?null:cl(kt,vt),j=ie.asBase?null:cl(Ot,vt);if(_){let Ie=[new Set(L||b),new Set(j||b)],pe=_.some(Le=>!Ie[Le.side].has(Le.target));for(let Le of b)if(Ve.has(Le))for(let[st,ct]of[[0,ee],[1,ie]]){let gt=ct.twin(Le);gt&&ct.here(gt)&&!Ie[st].has(gt)&&(pe=!0)}if(pe)continue}if(b.some(lr)||L&&L.some(lr)||j&&j.some(lr))continue;let G=zr(L||b),oe=zr(j||b);if((!L||$n(b,L))&&(!j||$n(b,j))&&!(L&&Oi(G)))continue;let be=xt({base:zr(b),sourceRetentions:ot?.get(R),local:G,remote:oe,out:me,policy:nt,blocks:Ve,scopeUnits:_?[b,L||b,j||b]:null,certifiedOrigins:_?(Ie,pe,Le,st,ct,gt)=>Cc({certificates:_,scopes:[b,L||b,j||b],flats:[Ie,pe,Le],keys:[st,ct,gt]}):null,prepared:Ze?Ze.prepared:null,nativeTransfers:Ze,L:L?B:_c(B,R),R:j?z:_c(z,R),idOf:{base:h,local:d,remote:v},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(Ie,pe,Le)=>D(Ie,pe,Le,!1),cloneUnit:W,mergeAttrs:Oe,atomKey:i.exactUnitKey,moveIn:M,moveBuilt:M,movePlanned:M,provenance:Te,textMappers:Xe,conflicts:O,conflict:Fe,scope:{base:R,local:ee.asBase?null:ee.el,remote:ie.asBase?null:ie.el,units:Re,at:vt.lo},decisions:_e,node:le});if(!be){if(_){let Ie=cc({certificates:_,scopes:[b,L||b,j||b],views:[{V:ee,A:B,idOf:g.local},{V:ie,A:z,idOf:g.remote}],eligible:pe=>ut(pe)&&Pn.has(pe.tagName)&&!o(pe)&&!r.remoteWins(pe),baseId:g.base});for(let pe of Ie.records){ot||=new Map;let Le=ot.get(pe.source);Le||ot.set(pe.source,Le=[]),Le.push(pe)}}continue}if(fe.push(...be.segments),Ze){let Ie=new Map;for(let pe of be.nodes){let Le=Te.get(pe)?.base;if(!Le||Ie.has(Le))throw new Error("Invalid native transfer owner output");Ie.set(Le,pe)}if(Ie.size!==Ze.owners.length)throw new Error("Incomplete native transfer owner output");for(let pe of Ze.owners){let Le=Ie.get(pe.base);if(!Le)throw new Error("Missing native transfer owner output");for(let st of[pe.base,pe.local,pe.remote])ae.add(st),Ye.add(st),ft.set(st,Le);St.push({frag:Le,at:Je.get(pe.base)})}continue}if(rt&&Sr(b,L||b,j||b,be.nodes),be.unitOutputs){Rt||=new Map;for(let pe of[...b,...L||[],...j||[]]){let Le=be.unitOutputs.get(pe)||[];ae.add(pe),Ye.add(pe),Rt.set(pe,Le),Le.length&&ft.set(pe,Le[Le.length-1])}let Ie=be.nodes[be.nodes.length-1];if(Ie)for(let pe of[L||b,j||b]){let Le=pe[pe.length-1];Le&&Ut.set(Le,Ie)}for(let pe=0;pe<be.nodes.length;pe++)St.push({frag:be.nodes[pe],at:vt.lo,previous:pe>0?be.nodes[pe-1]:null});continue}rt&&Sr(b,L||b,j||b,be.nodes);let ye=me.createDocumentFragment();for(let Ie of be.nodes)ye.appendChild(Ie);for(let Ie of[...b,...L||[],...j||[]])ae.add(Ie),Ye.add(Ie),ft.set(Ie,ye);St.push({frag:ye,at:vt.lo})}}}function Ne(R,J){let ue=Te.get(R);return ue&&ue.unchanged?!ue.remote||ue.remote===J?!0:Pe(ue.remote,J):R.tagName!==J.tagName||!tt(R,J)?!1:lt(Se(R),Se(J))}function Pe(R,J){return R===J?!0:R.tagName!==J.tagName||R.namespaceURI!==J.namespaceURI||!tt(R,J)?!1:De(Se(R),Se(J))}function De(R,J){let ue=it(R,o),he=it(J,o);if(ue.length!==he.length)return!1;for(let le=0;le<ue.length;le++){let ee=ue[le],ie=he[le];if(typeof ee=="string"||typeof ie=="string"){if(ee!==ie)return!1}else{if(ee.nodeType!==ie.nodeType)return!1;if(ee.nodeType===1){if(!Pe(ee,ie))return!1}else if(ee.nodeValue!==ie.nodeValue)return!1}}return!0}function Se(R){return R.tagName==="TEMPLATE"&&R.content?R.content:R}function tt(R,J){let ue=0;for(let he of R.attributes)if(!r.ignoreAttribute(R,he.name)&&(ue++,J.getAttribute(he.name)!==he.value))return!1;for(let he of J.attributes)r.ignoreAttribute(J,he.name)||ue--;return ue===0}function lt(R,J){let ue=it(R,le=>{let ee=Te.get(le);return!!(ee&&ee.pinned)}),he=it(J,o);if(ue.length!==he.length)return!1;for(let le=0;le<ue.length;le++){let ee=ue[le],ie=he[le];if(typeof ee=="string"||typeof ie=="string"){if(ee!==ie)return!1}else{if(ee.nodeType!==ie.nodeType)return!1;if(ee.nodeType===1){if(!Ne(ee,ie))return!1}else if(ee.nodeValue!==ie.nodeValue)return!1}}return!0}function it(R,J){let ue=[],he=null;for(let le=R.firstChild;le;le=le.nextSibling){if(le.nodeType===3){he=he===null?le.nodeValue:he+le.nodeValue;continue}le.nodeType===1&&J(le)||(he!==null&&(he!==""&&ue.push(he),he=null),ue.push(le))}return he!==null&&he!==""&&ue.push(he),ue}function Ht(R,J,ue,he){let le=R.value,ee=he?le:J?J.value:"",ie=ue?ue.value:"";ae.add(R),J&&ae.add(J),ue&&ae.add(ue);let Re=ee===ie?ee:ee===le?ie:ie===le||nt==="local"?ee:ie,We={site:"comment",bRun:R,lRun:J,rRun:ue,node:null};if(ee!==le&&ie!==le&&ee!==ie&&Fe({kind:"text",node:null,base:le,local:ee,remote:ie,resolved:Re},We),!J&&!ue)return null;let Je=me.createComment(Re);return We.node=Je,Te.set(Je,{base:R.nodes,local:J?J.nodes:null,remote:ue?ue.nodes:null}),Je}function It(R,J){let ue=y(J,R);if(!ue)return null;let he=ut(ue)?ue.parentNode:ue.parent,le=ut(R)?R.parentNode:R.parent;return y(J,le)===he?null:J.reverse.get(he)||null}function Zt(R){let J=new Set([R]),ue=R;for(let he=0;he<64;he++){let le=It(ue,B)||It(ue,z);if(!le)return!1;if(le===R||ut(R)&&ut(le)&&R.contains(le)||J.has(le))return!0;J.add(le),ue=le}return!0}function Bt(R,J,ue){if(!J)return!1;let he=ut(R)?R.parentNode:R.parent;return he===J||J.tagName==="TEMPLATE"&&he===J.content}function Wt(R,J){let ue=Be(R),he=y(B,ue);if(he&&Bt(J,he,B))return!0;let le=y(z,ue);return!!(le&&Bt(J,le,z))}}function _c(e,t){return e.map.get(t)?Rc():{map:{get:r=>r&&r.nodeType===1&&e.map.get(r)||r,has:()=>!0},reverse:{get:r=>e.reverse.get(r)||r,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Rc(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function gm(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let s=0;s<e.length;s++){let i=0,l=t.length;for(;i<l;){let a=i+l>>1;t[a]<e[s]?i=a+1:l=a}t[i]=e[s],n[i]=s,r[s]=i>0?n[i-1]:-1}let o=new Set;for(let s=n[t.length-1];s!==void 0&&s>=0;s=r[s])o.add(s);return o}function Mc(e){let t=[],n=new Array(e.length);for(let r=0;r<e.length;r++){let o=0,s=t.length;for(;o<s;){let i=o+s>>1;t[i]<e[r]?o=i+1:s=i}t[o]=e[r],n[r]=o+1}return n}function fl(e){let t=Mc(e),n=Mc(e.map(i=>-i).reverse()).reverse(),r=0;for(let i=0;i<t.length;i++)t[i]>r&&(r=t[i]);let o=new Map;for(let i=0;i<e.length;i++)t[i]+n[i]-1===r&&o.set(t[i],(o.get(t[i])||0)+1);let s=new Set;for(let i=0;i<e.length;i++)(!(t[i]+n[i]-1===r)||o.get(t[i])>1)&&s.add(e[i]);return s}function bm(e,t,n,r){let o=g=>{let m=gm(g.map(k=>t.get(k)));return new Set(g.filter((k,S)=>!m.has(S)))},s=o(n),i=o(r);for(let g of s)if(i.has(g))return null;let l=new Set(n),a=new Set(r),c=e.filter(g=>l.has(g)&&a.has(g)&&!s.has(g)&&!i.has(g)),p=new Set(c),u=(g,m)=>{let k=new Map,S=null;for(let x of g){if(p.has(x)){S=x;continue}m.has(x)&&(k.has(S)||k.set(S,[]),k.get(S).push(x))}return k},f=(g,m)=>fl(g.map(k=>t.get(k))).size>m.size,h=[{at:u(r,i),ambiguous:f(r,i)},{at:u(n,s),ambiguous:f(n,s)}],d=g=>h.map(m=>{let k=m.at.get(g);return k?{group:k,ambiguous:m.ambiguous}:null}).filter(Boolean).sort((m,k)=>m.ambiguous-k.ambiguous||t.get(m.group[0])-t.get(k.group[0])).flatMap(m=>m.group),v=d(null);for(let g of c)v.push(g,...d(g));return new Map(v.map((g,m)=>[g,m]))}function km(e,t){let n=[],r=new Map,o=null;for(let l of e.units){let a=e.baseOf(l);if(a&&t.has(a)){o=l,r.set(l,[]);continue}(o?r.get(o):n).push(l)}let s=[...r.keys()].sort((l,a)=>t.get(e.baseOf(l))-t.get(e.baseOf(a))),i=l=>{let a=[],c=[],p=()=>{c.length&&a.push(...c.sort((u,f)=>Rs(u)<Rs(f)?-1:1)),c=[]};for(let u of l){if(e.baseOf(u)){p(),a.push(u);continue}c.push(u)}return p(),a};return{...e,units:[...i(n),...s.flatMap(l=>[l,...i(r.get(l))])]}}var Lc=new Set(["INPUT","OPTION","TEXTAREA"]),hl=/[\t\n\f\r ]+/;function Ic(e,t,n,r){let o=e.ownerDocument,{provenance:s,textMappers:i}=n,l=r.hooks,a=[],c=[],p=[],u=new Set,f=[],h=[],d=new Map,v=new Set,g=new Map,m=n.conflicts.length>0||r.trackInserted===!0,k=new Map,S=new Set,x=new Map,w=(y,M)=>{let P=x.get(y);P||x.set(y,P=new Set),P.add(M)},T=m?new Set:null,N=(y,M,P)=>{let H=l.beforeAttributeUpdated(y,M,P);return m&&H===!1&&w(M,y),H},C=y=>!!y&&(y===e||e.contains(y)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(y)),I=new Map,q=new Map,V=new Map,U=new Set,F=new Map;(function y(M){let P=s.get(M);if(P){if(M.nodeType===1){let Q=P.local?r.toLive(P.local):null;Q&&C(Q)&&Q.nodeType===1&&(I.set(M,Q),q.set(Q,M))}else if(Array.isArray(P.local)){let Q=z(P.local,P.local.map(D=>r.toLive(D)).filter(D=>D&&C(D)&&D.nodeType===M.nodeType));if(Q.length&&(I.set(M,Q[0]),q.set(Q[0],M),V.set(M,Q)),Array.isArray(P.caret))for(let D of P.caret){let ge=r.toLive(D.node);if(!ge||!C(ge)||ge.nodeType!==3)continue;let xe=F.get(ge);Array.isArray(xe)||F.set(ge,xe=[]),xe.push({merged:M,from:D.from,to:D.to,flatStart:D.flatStart})}else{let D=0;for(let ge of Q)F.set(ge,{merged:M,shift:D}),D+=ge.nodeValue.length}}}let H=M.nodeType===1&&M.tagName==="TEMPLATE"&&M.content?M.content.childNodes:M.childNodes;for(let Q of H)y(Q)})(t);let A=new Set;for(let y of I.values())A.add(y);for(let y of V.values())for(let M of y)A.add(M);let E=r.localRoot&&r.localRoot!==e?new Set:null;if(E){for(let y=r.localRoot.firstElementChild;y;y=y.nextElementSibling)if(y.tagName==="HEAD")for(let M=y.firstElementChild;M;M=M.nextElementSibling){let P=r.toLive(M);P&&E.add(P)}}for(let y of n.segments||[])Ce(y);let X=r.restoreFocus===!1?null:ym(o,F);r.childrenOnly?Te(Me(e),Me(t)):Be(e,t);for(let{node:y,parent:M}of f)u.has(y)||!y.parentNode||y.nodeType===1&&(r.ignored(y)||Xe(y))||ot(y,M);return vm(o,X,F,i,V,g,U),{applied:a,moved:c,replaced:p,identities:h,mergedScriptsLive:v,liveOf:I,heldBy:g,runOf:V,keptRuns:U,insertedLive:k,vetoed:S,vetoedAttrs:x,removedVetoes:T};function B(y,M){let P=y.slice(M.bs,M.be),H=0;for(;H<P.length&&H<M.text.length&&P[H]===M.text[H];)H++;let Q=0;for(;Q<P.length-H&&Q<M.text.length-H&&P[P.length-1-Q]===M.text[M.text.length-1-Q];)Q++;return{bs:M.bs+H,be:M.be-Q,text:M.text.slice(H,M.text.length-Q)}}function z(y,M){if(!M.length)return M;let P=[];for(let D of y){let ge=D.parentNode;if(!ge)continue;let xe=d.get(ge);if(!xe){xe=new Set;for(let de=ge.firstChild;de;de=de.nextSibling)de.nodeType===3&&xe.add(r.toLive(de));d.set(ge,xe)}P.includes(xe)||P.push(xe)}let H={has:D=>P.some(ge=>ge.has(D))},Q=[];for(let D of M){Q.push(D);for(let ge=D.nextSibling;ge&&ge.nodeType===3&&!H.has(ge)&&!Q.includes(ge);ge=ge.nextSibling)Q.push(ge)}return Q}function Ce(y){let M=[];for(let ne of y.localNodes){let se=r.toLive(ne.node);if(!se||!C(se)||se.nodeType!==3)return;M.push(se)}let P=z(y.localNodes.map(ne=>ne.node),M);if(!P.length)return;let H=P.map(ne=>ne.nodeValue).join(""),{flatLocal:Q,lToM:D,mapLocal:ge}=y;if(H===Q)return;let xe=y.textNodes.map(ne=>({node:ne.node,ms:ne.ms,me:ne.me})),de=[],Oe=0;for(let ne of P)de.push(Oe),Oe+=ne.nodeValue.length;let $=(ne,se)=>P.find((W,ce)=>de[ce]<=ne&&ne+se<=de[ce]+W.nodeValue.length)||null,Z=[],ke=0;for(let ne of Er(Q,H).map(se=>B(Q,se))){let se=ne.bs+ke;ke+=ne.text.length-(ne.be-ne.bs);let W,ce;if(ne.be>ne.bs){W=D[ne.bs];let Ne=W>=0;for(let Pe=ne.bs;Ne&&Pe<ne.be;Pe++)D[Pe]!==W+(Pe-ne.bs)&&(Ne=!1);if(!Ne)continue;ce=W+(ne.be-ne.bs)}else{let Ne=ne.bs>0?D[ne.bs-1]:0,Pe=ne.bs<Q.length?D[ne.bs]:0;if(Ne<0||Pe<0)continue;W=ce=ge(ne.bs)}Z.push({ms:W,me:ce,text:ne.text,live:ce===W?$(se,ne.text.length):null})}Z.sort((ne,se)=>se.ms-ne.ms);let we=(ne,se)=>(V.get(ne.node)||[I.get(ne.node)]).includes(se),ve=ne=>!!ne&&ne.nodeType===1&&wn.has(ne.tagName);for(let ne of Z){let se=xe.find(ce=>ce.ms<=ne.ms&&ne.me<=ce.me&&ne.ms<ce.me);if(se&&ne.live&&se.ms===ne.ms&&!we(se,ne.live)){let ce=xe.find(Ne=>Ne.me===ne.ms&&we(Ne,ne.live));ce&&(se=ce)}if(!se&&ne.me===ne.ms){let ce=xe.find(Se=>Se.me===ne.ms),Ne=xe.find(Se=>Se.ms===ne.ms),Pe=ce||Ne;if(!Pe)continue;let De=Pe.node;for(;ve(De.parentNode)&&(ce?De.parentNode.lastChild:De.parentNode.firstChild)===De;)De=De.parentNode;if(De===Pe.node)se=Pe;else{let Se=De.ownerDocument.createTextNode(ne.text);De.parentNode.insertBefore(Se,ce?De.nextSibling:De);continue}}if(!se)continue;let W=se.node.nodeValue;se.node.nodeValue=W.slice(0,ne.ms-se.ms)+ne.text+W.slice(ne.me-se.ms),se.me+=ne.text.length-(ne.me-ne.ms)}}function Me(y){return y.nodeType===1&&y.tagName==="TEMPLATE"&&y.content?y.content:y}function Be(y,M){u.add(y);let P=s.get(M);if(P&&P.remote&&n.remoteIdOf){let Q=n.remoteIdOf(P.remote);Q&&h.push([y,Q])}if(P&&P.unchanged){r.opaque&&r.opaque(y)||(n.customIdentity&&P.remote&&fe(y,P.remote),P.remote&&K(y,P.remote));return}if(l.beforeNodeMorphed(y,M)===!1){S.add(M);return}je(y,M,r.keepLiveOnly&&P&&P.local&&P.local.nodeType===1&&P.local!==y?P.local:null);let H=y.tagName;if(mn(y))y.textContent!==M.textContent&&(a.push({kind:"text",node:y,before:y.textContent,after:M.textContent}),y.textContent=M.textContent),n.mergedScripts.has(M)&&v.add(y);else if(H==="TEXTAREA")Y(y,M,P);else{Et(y,M,P);let Q=H==="TEMPLATE"&&y.content?y.content:y,D=H==="TEMPLATE"&&M.content?M.content:M;r.opaque&&r.opaque(y)||r.protectFocusedValue==="subtree"&&He(y)&&y!==o.body?me(Q):Te(Q,D)}l.afterNodeMorphed(y,M)}function me(y){for(let M=y.firstChild;M;M=M.nextSibling){let P=q.get(M);P&&I.get(P.parentNode)!==y||(u.add(M),M.nodeType===1&&me(M))}}function Te(y,M){let P=ze(y.firstChild),H=new Set;for(let Q of Array.from(M.childNodes)){let D=I.get(Q);D&&u.has(D)&&!H.has(D)&&(D=null);let ge=s.get(Q);if(ge&&ge.pinned){D&&D.nodeType===1&&((D.parentNode!==y||ze(D.nextSibling)!==P)&&Ee(y,D,P),u.add(D),H.add(D));continue}if(D&&D.nodeType===1){if(D!==P){let Oe=D.parentNode;if(Oe===y&&P&&et(D)){let $=D.nextSibling;for(let Z=P;Z&&Z!==D;){let ke=Z.nextSibling;Ee(y,Z,$),Z=ke}}else Ee(y,D,P),Oe!==y&&(c.push(D),a.push({kind:"move",el:D,from:Oe,to:y}))}H.add(D),Be(D,Q),P=ze(D.nextSibling);continue}if(D&&D.nodeType!==1){let Oe=V.get(Q)||[D],$=Oe.map(ke=>ke.nodeValue).join(""),Z=Q.nodeValue;if(Q.nodeType===3){let ke=_e(Q);ke!=null&&$!==ke&&(Z=qo(ke,$,Q.nodeValue).text)}if(Oe.length>1&&$===Z&&!Oe.includes(P,1)&&Oe.every((ke,we)=>ke.parentNode===y&&(we===0||Oe[we-1].nextSibling===ke))){if(D!==P)for(let ke of Oe)Ee(y,ke,P);l.beforeNodeMorphed(D,Q)!==!1?l.afterNodeMorphed(D,Q):m&&S.add(Q);for(let ke of Oe)u.add(ke),H.add(ke);g.set(Q,D),U.add(Q),P=ze(Oe[Oe.length-1].nextSibling);continue}D!==P&&Ee(y,D,P),l.beforeNodeMorphed(D,Q)!==!1?(D.nodeValue!==Z&&(a.push({kind:"text",node:D,before:D.nodeValue,after:Z}),D.nodeValue=Z),l.afterNodeMorphed(D,Q)):S.add(Q),u.add(D),H.add(D),g.set(Q,D),P=ze(D.nextSibling);continue}if(Q.nodeType===3&&P&&P.nodeType===3&&!u.has(P)&&!F.has(P)){P.nodeValue!==Q.nodeValue&&(a.push({kind:"text",node:P,before:P.nodeValue,after:Q.nodeValue}),P.nodeValue=Q.nodeValue),u.add(P),g.set(Q,P),P=ze(P.nextSibling);continue}let xe=s.get(Q),de=rt(xe&&xe.unchanged&&xe.remote?xe.remote:Q);if(l.beforeNodeAdded(de)===!1){S.add(Q);continue}y.insertBefore(de,P),u.add(de),m&&k.set(Q,de),de.nodeType===3&&g.set(Q,de),de.nodeType===1&&(p.push(de),qe(de,Q),n.customIdentity&&xe&&xe.unchanged&&xe.remote&&fe(de,xe.remote),mn(de)||xt(de,Q),r.formState==="property"&&Ct(xe)&&K(de,xe.remote)),P=ze(de.nextSibling),a.push({kind:"insert",node:de,parent:y}),l.afterNodeAdded(de)}for(let Q of Array.from(y.childNodes))u.has(Q)||H.has(Q)||Q.nodeType===1&&(r.ignored(Q)||Xe(Q))||(A.has(Q)?f.push({node:Q,parent:y}):ot(Q,y))}function Xe(y){return y.parentNode&&y.parentNode.nodeType===1&&y.parentNode.tagName==="HEAD"&&(E&&!E.has(y)||r.preserve&&r.preserve(y)===!0)}function _e(y){let M=s.get(y);return!M||!Array.isArray(M.local)?null:M.local.map(P=>P.nodeValue).join("")}function O(y){return s.get(y)}function K(y,M){if(!Lc.has(y.tagName)&&!y.querySelector("input,option,textarea"))return;let P=(H,Q)=>{if(H.tagName!==Q.tagName||(H.tagName==="TEXTAREA"?Y(H,Q,{remote:Q}):Lc.has(H.tagName)&&Et(H,Q,{remote:Q}),r.opaque&&r.opaque(H)))return;let D=ae(H),ge=ae(Q);if(D.length===ge.length)for(let xe=0;xe<D.length;xe++)P(D[xe],ge[xe])};P(y,M)}function fe(y,M){if(r.opaque&&r.opaque(y))return;let P=ae(y),H=ae(M);if(P.length===H.length)for(let Q=0;Q<P.length;Q++){let D=n.remoteIdOf(H[Q]);D&&h.push([P[Q],D]),fe(P[Q],H[Q])}}function ae(y){let M=y.tagName==="TEMPLATE"&&y.content?y.content:y;return Array.from(M.children).filter(P=>!r.ignored(P))}function qe(y,M){if(!n.remoteIdOf)return;let P=(H,Q)=>{let D=s.get(Q);if(D&&D.remote&&Q.nodeType===1){let de=n.remoteIdOf(D.remote);de&&h.push([H,de])}let ge=H.childNodes,xe=Q.childNodes;for(let de=0;de<ge.length&&de<xe.length;de++)P(ge[de],xe[de])};P(y,M)}function ze(y){for(;y&&y.nodeType===1&&r.ignored(y);)y=y.nextSibling;return y}function Ee(y,M,P){if(typeof y.moveBefore=="function"&&M.ownerDocument===y.ownerDocument)try{y.moveBefore(M,P);return}catch{}y.insertBefore(M,P)}function ot(y,M){if(l.beforeNodeRemoved(y)===!1){m&&T.add(y);return}y.parentNode.removeChild(y),a.push({kind:"remove",node:y,parent:M}),l.afterNodeRemoved(y)}function rt(y){if(mn(y))return Bo(y,o);let M=o.importNode(y,!0);if(M.nodeType===1)for(let P of Array.from(M.querySelectorAll("script")))mn(P)&&P.replaceWith(Bo(P,o));return M}function xt(y,M){let P=y.tagName==="TEMPLATE"&&y.content?y.content:y,H=M.tagName==="TEMPLATE"&&M.content?M.content:M,Q=Array.from(P.childNodes),D=Array.from(H.childNodes);for(let ge=0;ge<D.length&&ge<Q.length;ge++){let xe=D[ge],de=Q[ge],Oe=I.get(xe);Oe&&u.has(Oe)&&(Oe=null);let $=s.get(xe);if($&&$.pinned){if(Oe&&Oe.nodeType===1){let Z=Oe.parentNode;Ee(P,Oe,de),Z!==P&&(c.push(Oe),a.push({kind:"move",el:Oe,from:Z,to:P})),u.add(Oe)}de.remove();continue}if(Oe){let Z=Oe.parentNode;Ee(P,Oe,de),de.remove(),Oe.nodeType===1?(Z!==P&&(c.push(Oe),a.push({kind:"move",el:Oe,from:Z,to:P})),Be(Oe,xe)):(u.add(Oe),g.set(xe,Oe),Oe.nodeValue!==xe.nodeValue&&(a.push({kind:"text",node:Oe,before:Oe.nodeValue,after:xe.nodeValue}),Oe.nodeValue=xe.nodeValue));continue}u.add(de),m&&k.set(xe,de),de.nodeType===3&&g.set(xe,de),$&&$.unchanged&&$.remote?(nt(de,$.remote),n.customIdentity&&fe(de,$.remote)):xe.nodeType===1&&!mn(xe)&&xt(de,xe)}}function nt(y,M){let P=y.tagName==="TEMPLATE"&&y.content?y.content:y,H=M.tagName==="TEMPLATE"&&M.content?M.content:M;for(let Q of Array.from(H.childNodes))P.appendChild(rt(Q))}function te(y,M){return M.namespaceURI?y.getAttributeNS(M.namespaceURI,M.localName):y.getAttribute(M.name)}function Ae(y,M){let P=new Set((M||"").split(hl).filter(Boolean));return(y||"").split(hl).filter(H=>H&&!P.has(H))}function je(y,M,P){for(let H of Array.from(M.attributes)){if(Fe(y,H.name)||r.ignoreAttribute(y,H.name,M))continue;let Q=te(y,H);if(Q===H.value||P&&te(P,H)===H.value)continue;let D=H.value;if(P&&H.name==="class"&&!H.namespaceURI){let ge=H.value.split(hl).filter(Boolean),xe=Ae(Q,P.getAttribute("class")).filter(de=>!ge.includes(de));xe.length&&(D=[...ge,...xe].join(" "))}if(Q!==D){if(l.beforeAttributeUpdated(H.name,y,"update")===!1){m&&w(M,H.name);continue}H.namespaceURI?y.setAttributeNS(H.namespaceURI,H.name,D):y.setAttribute(H.name,D),a.push({kind:"attr",el:y,name:H.name,before:Q,after:D})}}for(let H of Array.from(y.attributes)){if(Fe(y,H.name)||r.ignoreAttribute(y,H.name,M)||(H.namespaceURI?M.hasAttributeNS(H.namespaceURI,H.localName):M.hasAttribute(H.name)))continue;if(P&&H.name==="class"&&!H.namespaceURI){let ge=Ae(H.value,P.getAttribute("class"));if(ge.length){let xe=ge.join(" ");if(xe===H.value)continue;if(l.beforeAttributeUpdated("class",y,"update")===!1){m&&w(M,"class");continue}y.setAttribute("class",xe),a.push({kind:"attr",el:y,name:"class",before:H.value,after:xe});continue}}if(P&&te(P,H)===null&&!r.ignoreAttribute(P,H.name))continue;if(l.beforeAttributeUpdated(H.name,y,"remove")===!1){m&&w(M,H.name);continue}let D=H.value;H.namespaceURI?y.removeAttributeNS(H.namespaceURI,H.localName):y.removeAttribute(H.name),a.push({kind:"attr",el:y,name:H.name,before:D,after:null})}}function Fe(y,M){let P=y.tagName;return P==="INPUT"?M==="value"||M==="checked"||M==="disabled":P==="OPTION"?M==="selected":!1}function He(y){return y===o.activeElement}function et(y){let M=o.activeElement;return!!M&&M!==o.body&&y.contains(M)}function bt(y,M){let P=M&&M.local&&M.local.nodeType===1&&M.local!==y?M.local:null;if(!P)return!0;let H=y.tagName==="TEXTAREA"?P.textContent:P.getAttribute("value")??"";return y.value!==H}function Ft(y,M){return!!r.protectFocusedValue&&He(y)&&bt(y,M)}function yt(y,M,P){let H=Math.min(y.length,M.length),Q=0;for(;Q<H&&y[Q]===M[Q];)Q++;if(P<=Q)return P;let D=0;for(;D<H-Q&&y[y.length-1-D]===M[M.length-1-D];)D++;return P>=y.length-D?P+M.length-y.length:M.length-D}function Lt(y){try{return y.selectionStart==null?null:[y.selectionStart,y.selectionEnd,y.selectionDirection]}catch{return null}}function en(y,M,P,H){try{y.setSelectionRange(yt(M,P,H[0]),yt(M,P,H[1]),H[2]||"none")}catch{}}function Ge(y,M){let P=y.value,H=Lt(y);y.value=M,H&&en(y,P,M,H)}function Ct(y){let M=y&&y.remote;return M&&M.nodeType===1?M:null}function Et(y,M,P){let H=y.tagName,Q=Ct(P),D=r.formState==="property"&&Q?Q:M;if(H==="INPUT"){let ge=Ft(y,P),xe=(y.getAttribute("type")||"").toLowerCase(),de=xe!=="file"&&xe!=="checkbox"&&xe!=="radio",Oe=Q&&Q.hasAttribute("value")&&Q.value!==Q.getAttribute("value")?Q.value:null;if(de&&!ge)if(r.formState==="property"){let $=M.getAttribute("value"),Z=y.getAttribute("value");(Z!==$||y.value!==D.value)&&N("value",y,$==null?"remove":"update")!==!1&&(Z!==$&&($==null?y.removeAttribute("value"):y.setAttribute("value",$),a.push({kind:"attr",el:y,name:"value",before:Z,after:$})),y.value!==D.value&&(He(y)?Ge(y,D.value):y.value=D.value))}else if(M.hasAttribute("value")||Oe!=null){let $=Oe??M.getAttribute("value");y.getAttribute("value")!==$&&N("value",y,"update")!==!1?(y.setAttribute("value",$),y.value!==$&&(He(y)?Ge(y,$):y.value=$),a.push({kind:"attr",el:y,name:"value",before:null,after:$})):y.value!==$&&y.getAttribute("value")===$&&(He(y)?Ge(y,$):y.value=$)}else(y.hasAttribute("value")||y.value!=="")&&N("value",y,"remove")!==!1&&(y.removeAttribute("value"),y.value="",a.push({kind:"attr",el:y,name:"value",before:"",after:null}));if(!de&&xe!=="file"){let $=M.getAttribute("value");$==null?y.hasAttribute("value")&&N("value",y,"remove")!==!1&&y.removeAttribute("value"):y.getAttribute("value")!==$&&N("value",y,"update")!==!1&&y.setAttribute("value",$)}r.protectFocusedValue&&He(y)||(Jt(y,D,"checked"),r.formState==="property"&&y.indeterminate!==D.indeterminate&&(y.indeterminate=D.indeterminate)),Jt(y,D,"disabled")}else if(H==="OPTION"){let ge=y.parentNode&&y.closest("select");r.protectFocusedValue&&ge&&He(ge)||Jt(y,D,"selected")}}function Jt(y,M,P){if(r.ignoreAttribute(y,P,M))return;let H=r.formState==="property"?!!M[P]:M.hasAttribute(P);if(r.formState!=="property"){let Q=y.hasAttribute(P);if(Q!==H){if(N(P,y,H?"update":"remove")===!1)return;H?y.setAttribute(P,""):y.removeAttribute(P),a.push({kind:"attr",el:y,name:P,before:Q?"":null,after:H?"":null})}}y[P]!==H&&(y[P]=H)}function Y(y,M,P){if(Ft(y,P)||N("value",y,"update")===!1)return;let H=Ct(P),Q=M.textContent,D=H&&H.value!==H.defaultValue?H.value:Q,ge=He(y)?Lt(y):null,xe=y.value;if(r.formState!=="property"&&y.textContent!==Q){a.push({kind:"text",node:y,before:y.textContent,after:Q});let de=y.firstChild;de&&de.nodeType===3&&!de.nextSibling?de.data=Q:y.textContent=Q}y.value!==D&&(y.value=D),ge&&y.value!==xe&&en(y,xe,y.value,ge)}}function ym(e,t){let n=e.activeElement;if(!n||n===e.body||n===e.documentElement)return null;let r={el:n,id:n.getAttribute&&n.getAttribute("id"),scrollTop:n.scrollTop,scrollLeft:n.scrollLeft};if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"){try{r.selection=[n.selectionStart,n.selectionEnd,n.selectionDirection]}catch{}return r}let o=e.getSelection&&e.getSelection();if(o&&o.rangeCount){let s=o.getRangeAt(0);r.range={sc:s.startContainer,so:s.startOffset,ec:s.endContainer,eo:s.endOffset}}return r}function vm(e,t,n,r,o,s,i){if(!t)return;let l=t.el;if(!l.isConnected&&t.id&&(l=e.getElementById(t.id)),!l||!l.isConnected)return;if(e.activeElement!==l)try{l.focus({preventScroll:!0})}catch{}try{l.scrollTop=t.scrollTop,l.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{l.setSelectionRange&&!l.selectionEnd&&t.selection[1]!=null&&l.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let a=(u,f)=>{let h=n.get(u);if(Array.isArray(h)){let d=h.find(k=>f>=k.from&&f<k.to)||h.find(k=>f===k.to)||h[h.length-1],v=s.get(d.merged);if(!v||!v.isConnected)return null;let g=r.get(d.merged),m=g&&g.flat?g.flat(d.flatStart+f):f;return[v,Math.max(0,Math.min(m,v.nodeValue.length))]}if(h&&!i.has(h.merged)){let d=(o.get(h.merged)||[u])[0];if(!d.isConnected)return null;let v=r.get(h.merged),g=h.shift+f,m=v?v(g):g;return[d,Math.max(0,Math.min(m,d.nodeValue.length))]}return u.isConnected?[u,Math.min(f,u.nodeType===3?u.nodeValue.length:u.childNodes.length)]:null},c=a(t.range.sc,t.range.so),p=a(t.range.ec,t.range.eo);if(!(!c||!p))try{let u=e.createRange();u.setStart(c[0],c[1]),u.setEnd(p[0],p[1]);let f=e.getSelection();f.removeAllRanges(),f.addRange(u)}catch{}}var xm={compared:0},wm=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Sm(e,t,n,r){let o=(i,l)=>t.getAttribute(l)!==null&&typeof r=="function"&&!!r(i,l),s=0;for(let i of e.attributes)if(!(n(e,i.name)||o(e,i.name))&&(s++,t.getAttribute(i.name)!==i.value))return!1;for(let i of t.attributes)!n(t,i.name)&&!o(t,i.name)&&s--;return s===0}function ml(e,t){if(e.namespaceURI!==t.namespaceURI||e.prefix!==t.prefix||e.localName!==t.localName)return!1;let n=e.attributes;if(n.length!==t.attributes.length)return!1;for(let r of n)if(t.getAttributeNS(r.namespaceURI,r.localName)!==r.value)return!1;return!0}function Pc(e,t,n,r,o,s,i,l){let a=new Map,c=new Set,p=u=>{if(r(u))return;let f=n(u);f&&(s.add(f),o.has(f)||a.has(f)?c.add(f):a.set(f,u))};for(let u of e)p(u);p(t);for(let u of i||t.querySelectorAll("*"))p(u);for(let u of c)a.delete(u),l.add(u);return a}function jc(e,t,n,r,o,s){let i=!1;for(let p of o)p.startsWith("merge:")&&(i=!0);if(!i)return[...r];let l=new Map,a=[],c=s===vn?Ho:"*";for(let p of[e,...e.querySelectorAll(c)]){if(n(p))continue;let u=t(p);if(!u||!(r.has(u)||o.has(u)))continue;let f=(l.get(u)||0)+1;l.set(u,f),f===2&&a.push(u)}return a}function qc({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:r,o,identity:s,baseURI:i}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!Sm(e,t,o.ignoreAttribute,o.attributeMerge))return{bail:"root-attrs"};let{ignored:l,remoteWins:a}=o,c=dl(o.scripts.merge===!1?null:o.scripts.mergeTags,i),p=_e=>{let O=c(_e);return O!==null?O:s.base(_e)||null},u=_e=>{let O=c(_e);return O!==null?O:s.remote(_e)||null},f=[],h=[],d=new Map,v=new Map,g={same:d,differ:v},m=_e=>({bail:_e,comparisons:g}),k=(_e,O,K=!0)=>{if(d.get(_e)===O)return!0;if(v.get(_e)===O)return!1;if(xm.compared++,K&&_e.isEqualNode(O))return d.set(_e,O),!0;let fe=_e.nodeType===O.nodeType;if(fe&&_e.nodeType===1){if(fe=ml(_e,O),fe){let ae=_e.firstChild,qe=O.firstChild;for(;ae&&qe;ae=ae.nextSibling,qe=qe.nextSibling)if(!k(ae,qe,!1)){fe=!1;break}(ae||qe)&&(fe=!1)}}else fe&&(fe=_e.isEqualNode(O));return(fe?d:v).set(_e,O),fe},S=e,x=t,w=!1,T=()=>{d.set(S,x);for(let _e=0;_e<f.length;_e++)d.set(f[_e],h[_e]);return m("equal")};for(;;){let _e=S.childNodes,O=x.childNodes;if(_e.length!==O.length)break;let K=rt=>k(_e[rt],O[rt])?(d.set(_e[rt],O[rt]),!1):!0,fe=-1,ae=-1;for(let rt=0;rt<_e.length;rt++){if(_e[rt].nodeType!==1)continue;let xt=0;for(let nt=_e[rt].firstElementChild;nt;nt=nt.nextElementSibling)xt++;xt>=ae&&(ae=xt,fe=rt)}let qe=[],ze=!1;for(let rt=0;rt<_e.length&&qe.length<2;rt++)rt!==fe&&K(rt)&&qe.push(rt);if(fe>=0&&qe.length<2&&(qe.length===0&&ml(S,x)?(qe.push(fe),ze=!0):K(fe)&&qe.push(fe)),qe.length!==1){if(!w&&qe.length===0&&ml(S,x))return T();break}let Ee=_e[qe[0]],ot=O[qe[0]];if(w=w||!ze,w&&v.set(Ee,ot),Ee.nodeType!==1||ot.nodeType!==1||Ee.tagName!==ot.tagName)break;if(p(Ee)!==u(ot)){if(!w&&k(Ee,ot))return T();break}f.push(S),h.push(x),S=Ee,x=ot}v.set(S,x);for(let _e=0;_e<f.length;_e++)v.set(f[_e],h[_e]);if(S===e||S.tagName==="HEAD"||S.tagName==="BODY")return m("root-level");if(f.length<2||f[1].tagName!=="BODY")return m("not-in-body");if(l(S)||l(x))return m("ignored-ancestor");if(a(S)||a(x))return m("remote-wins-ancestor");for(let _e of f)if(wm.has(_e.tagName))return m("form-ancestor");if(S.tagName==="SCRIPT"||S.getElementsByTagName("script").length||x.getElementsByTagName("script").length)return m("script-or-template");let N=r(S);if(!N||N.nodeType!==1||N.tagName!==S.tagName)return m("no-live-twin");if(!n.contains(N))return m("live-detached");for(let _e of f){let O=r(_e);if(!O||O.nodeType!==1)return m("ancestor-live")}let C=s.base===vn&&s.remote===vn&&l===Pi,I=new Set,q=new Set,V=[],U=null,F=_e=>{_e&&(I.has(_e)?q.add(_e):I.add(_e))},A=(_e,O)=>{let K=c(_e),fe=K!==null?K:s.base(_e)||null;return fe!==(K!==null?K:s.remote(O)||null)?!1:(F(fe),!0)},E=(_e,O)=>{for(let K=_e.firstElementChild,fe=O.firstElementChild;K;K=K.nextElementSibling,fe=fe.nextElementSibling){let ae=l(K);if(ae!==l(fe))return!1;if(!ae&&(!A(K,fe)||!E(K,fe)))return!1}return!0},X=_e=>{let O=_e+1<f.length?f[_e+1]:S;for(let K=f[_e].firstElementChild,fe=h[_e].firstElementChild;K;K=K.nextElementSibling,fe=fe.nextElementSibling){if(K===O){let ze=_e+1<f.length?X(_e+1):null;if(ze)return ze;continue}let ae=l(K);if(ae!==l(fe))return"outside-id-changed";if(ae)continue;let qe=r(K);if(!qe||qe.nodeType!==1)return"sibling-live";if(V.push([K,fe]),!C&&(!A(K,fe)||!E(K,fe)))return"outside-id-changed";_e===0&&K.tagName==="HEAD"&&p(K)&&(U=[K,fe])}return null},B=X(0);if(B)return m(B);let z=new Set(f),Ce=null;if(s.base===vn){Ce=[];for(let _e of e.querySelectorAll(Ho))_e===S||z.has(_e)||(S.contains(_e)?Ce.push(_e):C&&F(p(_e)))}let Me=new Set,Be=new Set,me=new Set,Te=Pc(f,S,p,l,I,Me,Ce,Be),Xe=Pc(h,x,u,l,I,Me,s.remote===vn&&x.querySelectorAll(Ho),me);return U&&(q.has(p(U[0]))||Me.has(p(U[0])))&&(U=null),{scope:{chain:f,root:S,onChain:z,baseIndex:Te,remoteIndex:Xe,baseDropped:Be,remoteDropped:me,head:U,same:d,differ:v,dropped:[...jc(e,p,l,q,Be,s.base),...jc(t,u,l,q,me,s.remote)],held:_e=>{for(let O=1;O<f.length;O++)if(_e.map.get(f[O])!==h[O])return!1;for(let[O,K]of V)if(_e.map.get(O)!==K)return!1;return!0}}}}var yy=Symbol("hyper-morph-duplicate-key");var Am='[editor-ui],[clay~="editor-ui"],[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]',Tm='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Em='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Om(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let t=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(t)}function Nm(e,t,n,r){if(t==null)return;if(typeof t=="string")return t;let o=t;if(o.nodeType===9){let s=e.getAttribute("id");o=s&&o.getElementById(s)||(e.tagName==="BODY"?o.body:e.tagName==="HTML"?o.documentElement:o.body&&o.body.firstElementChild)}if((!o||o.nodeType!==1||o.tagName!==e.tagName)&&(o=Cm(e,t,r)),!!o)return n?Array.from(o.childNodes):o}function Cm(e,t,n){let r=t.nodeType===9?t.documentElement:t;if(!r||r.nodeType!==1)return null;let o=new Map,s=[r,...r.querySelectorAll("script")];for(let a of s){let c=Zr(a,n);c&&!o.has(c.key)&&o.set(c.key,a.textContent)}if(!o.size)return null;let i=e.cloneNode(!0),l=!1;for(let a of[i,...i.querySelectorAll("script")]){let c=Zr(a,n);c&&o.has(c.key)&&(a.textContent=o.get(c.key),l=!0)}return l?i:null}function Dc(e,t){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let n=t.implementation.createHTMLDocument(""),r=e.nodeType===1&&e.tagName==="HTML"?e:null;if(r)return n.replaceChild(n.adoptNode(r),n.documentElement),n;let o=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let s of o)n.body.appendChild(n.adoptNode(s));return n}function fr(e,t,n={}){let r=n||{};if(!r.head?.block)return Fc(e,t,r);try{return Fc(e,t,r)}catch(o){return Promise.reject(o)}}function Fc(e,t,n){let r=n.policy||"sync",o=r==="raw"?void 0:(a,c)=>Om(a)||(r==="history"?!(c&&a.matches(Em))&&a.matches(Tm):a.matches(Am)),s=n.callbacks||{},i={ignore:o,hooks:s,protectFocusedValue:n.ignoreActiveValue===!0?"subtree":!1,restoreFocus:n.restoreFocus!==!1,formState:n.formStateSync||"attribute",scripts:{execute:n.scripts?.handle!==!1,merge:n.scripts?.merge!==!1,mergeTags:n.scripts?.mergeTags||[]},head:{awaitLoads:!!n.head?.block,preserve:n.head?.shouldPreserve||(()=>!1)}};if(typeof n.key=="function"&&(i.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return zo(Object.assign({},i,{live:e,base:n.scripts?.mergeBase||null,remote:Dc(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let a=Object.assign({},i,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:Dc(t,e.ownerDocument)});return zo(a)}n.morphStyle==="innerHTML"&&(i.children=!0);let l=Nm(e,n.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return l!==void 0&&(i.base=l),pl(e,t,i)}var _m=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","attributeMerge","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),Nn=()=>{};function Vo(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!_m.has(l))throw new TypeError(`unknown option "${l}"`);let n=Object.assign({beforeNodeAdded:Nn,afterNodeAdded:Nn,beforeNodeRemoved:Nn,afterNodeRemoved:Nn,beforeNodeMorphed:Nn,afterNodeMorphed:Nn,beforeAttributeUpdated:Nn},e.hooks||{}),r=e.conflicts||"remote";if(!["remote","local","both"].includes(r))throw new TypeError("conflicts must be remote, local or both");let o=e.formState||"attribute";if(!["attribute","property"].includes(o))throw new TypeError("formState must be attribute or property");let s=e.protectFocusedValue;if(s!==void 0&&typeof s!="boolean"&&s!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");if(e.attributeMerge!==void 0&&typeof e.attributeMerge!="function")throw new TypeError("attributeMerge must be a function");let i=e.lineage;if(i!==void 0&&(!i||typeof i!="object"||typeof i.onResult!="function"||!i.elements||typeof i.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:ji(e.ignore,t),remoteWins:ji(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,attributeMerge:typeof e.attributeMerge=="function"?e.attributeMerge:()=>null,opaque:typeof e.opaque=="function"?e.opaque:()=>!1,conflicts:r,protectFocusedValue:s===void 0?!0:s,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:o,hooks:n,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:i||null}}function no(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return vn}function ro(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=qi(t,e.map),r=typeof e.then=="function"?e.then:vn;if(typeof e.first=="function"){let o=e.first;return s=>o(s)||n.get(s)||r(s)}return o=>n.get(o)||r(o)}return vn}function Mm(e,t,n,r={}){let o=h=>h&&h.nodeType===9?h.documentElement:h,s=o(t),i=o(n),l=o(e)||s;if(r.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let a=Object.assign({},r);delete a.live,delete a.base,delete a.remote;let c=Vo(a,[l,s,i].filter(Boolean)),p=r.identity||{},u=ar(),f=Ls(l,s,i,{identity:{base:ro(p.base,l),local:ro(p.local,s),remote:ro(p.remote,i)},authored:{base:no(p.base),local:no(p.local),remote:no(p.remote)},skipUnchanged:c.hooks.beforeNodeMorphed===Nn&&c.hooks.afterNodeMorphed===Nn,ignored:c.ignored,remoteWins:c.remoteWins,ignoreAttribute:c.ignoreAttribute,attributeMerge:c.attributeMerge,conflicts:c.conflicts,mergeTags:c.scripts.merge===!1?null:c.scripts.mergeTags,baseURI:s.ownerDocument&&s.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:c.children,stats:u});return delete f.recoveryLinks,delete f.lineage,f}function gl({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:r,toLive:o,options:s,identity:i,childrenOnly:l,isDocument:a}){let c=Vo(s,[e,t,n,r].filter(Boolean));if(c.ignored(e)){let A=bl(),E=c.lineage?Fo(c.lineage,e,A):null;return{report:A,loads:[],lineage:E}}let p=e.ownerDocument,u=c.lineage?tl(c.lineage,{liveRoot:e,localRoot:n,toLive:o}):null,f=c.scripts.execute?uc(e,c.ignored,p.baseURI):null,h=ar(),d=c.hooks.beforeNodeMorphed===Nn&&c.hooks.afterNodeMorphed===Nn,v={identity:{base:ro(i.base,t||n),local:ro(i.local,n),remote:ro(i.remote,r)},authored:{base:no(i.base),local:no(i.local),remote:no(i.remote)},ignored:c.ignored,remoteWins:c.remoteWins,ignoreAttribute:c.ignoreAttribute,attributeMerge:c.attributeMerge,conflicts:c.conflicts,mergeTags:c.scripts.merge===!1?null:c.scripts.mergeTags,baseURI:p.baseURI,localIsBase:!t,childrenOnly:l,skipUnchanged:d,lineage:u?{locals:u.locals}:null},g=c.fastPath&&a&&!l&&d&&t===n,m=null,k=null;if(g){let A=qc({baseRoot:t,remoteRoot:r,liveRoot:e,toLive:o,o:c,identity:v.identity,baseURI:p.baseURI});v.comparisons=A.comparisons||A.scope,A.bail?k=A.bail:(m=Ls(t,n,r,Object.assign({},v,{stats:h,scope:A.scope})),m||(k="chain-unpaired",h=ar()))}m||(m=Ls(t||n,n,r,Object.assign({},v,{stats:h}))),g&&(h.fastPathAttempted=1,h.fastPathTaken=k?0:1,h.fastPathFallback=k),m.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(A=>c.hooks[A]!==Nn)&&kc(m.conflicts,m.recoveryLinks,o),c.beforeApply&&c.beforeApply(m.doc);let S=globalThis.__hyperMorphProfile,x=S?performance.now():0,w=Ic(e,m.root,m,{toLive:o,localRoot:n,ignored:c.ignored,ignoreAttribute:c.ignoreAttribute,opaque:c.opaque,formState:c.formState,protectFocusedValue:c.protectFocusedValue,restoreFocus:c.restoreFocus,preserve:c.head.preserve,hooks:c.hooks,childrenOnly:l,keepLiveOnly:c.keepLiveOnly,trackInserted:!!u});S&&(S.apply=(S.apply||0)+(performance.now()-x));let T=[];if(c.head.awaitLoads)for(let A of w.applied){if(A.kind!=="insert"||A.node.nodeType!==1)continue;let E=A.node;E.tagName==="LINK"&&/\bstylesheet\b/i.test(E.getAttribute("rel")||"")&&E.getAttribute("href")&&E.closest("head")&&T.push(new Promise(B=>{E.addEventListener("load",()=>B()),E.addEventListener("error",()=>B())}))}let N=null,C=null;if(f){let A=fc(e,f,{ignored:c.ignored,skip:w.mergedScriptsLive,baseURI:p.baseURI,beforeNodeAdded:c.hooks.beforeNodeAdded,afterNodeAdded:c.hooks.afterNodeAdded,trackRecovery:!!m.recoveryLinks});T.push(...A.loads),N=A.swapped,C=A.vetoed}let I=A=>N&&N.get(A)||A,q=A=>{if(w.keptRuns.has(A))return w.runOf.get(A);let E=w.liveOf.get(A)||w.heldBy.get(A)||w.insertedLive.get(A);return E?I(E):null},V=A=>{let E=A&&w.liveOf.get(A);return E?I(E):null},U=A=>{let E=A&&q(A);return Array.isArray(E)?E[0]:E};if(m.recoveryLinks){let A=(E,X,B)=>(X.namespaceURI?E.getAttributeNS(X.namespaceURI,X.localName):E.getAttribute(X.qualifiedName))===B;xc(m.conflicts,m.recoveryLinks,{lookup:q,vetoed:w.vetoed,vetoedAttrs:w.vetoedAttrs,removedVetoes:w.removedVetoes,vetoedLive:C,liveAttr:A,ignored:c.ignored,liveRoot:e})}let F={applied:w.applied,decisions:m.decisions.map(A=>Object.assign({},A,{node:A.node?V(A.node):null,el:A.el?V(A.el):null,applied:!!(A.node?V(A.node):A.el&&V(A.el))})),conflicts:m.conflicts.map(A=>Object.assign({},A,{node:A.node?A.kind==="text"&&A.recovery.subject.nodeType===8?U(A.node):V(A.node):A.node,el:A.el?A.kind==="structure"?U(A.el):V(A.el):A.el})),localDiverged:m.localDiverged,identities:w.identities,moved:w.moved,replaced:w.replaced,stats:h};return u&&(F.lineage=u.finish(m.lineage,q)),{report:F,loads:T,lineage:u}}var Bc=new WeakMap;function bl(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:ar()}}function zo(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");return t.lineage===void 0?$c(t):el(t,t.live.documentElement,r=>$c(r))}function $c(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let r=Bc.get(n);r||(r=Ii(n),Bc.set(n,r));let o=r("remote",t.remote),s=typeof t.base=="string"&&t.base===""?null:t.base,i=s?r("base",s):null,l=t.local?t.local.root:n.documentElement,a=t.local?t.local.toLive:f=>f;Ra(n,o);let{report:c,loads:p,lineage:u}=gl({liveRoot:n.documentElement,baseRoot:i?i.documentElement:null,localRoot:l,remoteRoot:o.documentElement,toLive:a,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return u?.deliver(c),Promise.all(p).then(()=>c)}function Rm(e,t,n={}){return zo(Object.assign({},n,{live:e,base:null,remote:t}))}function Uc(e,t){if(e==null)return{root:t.createElement("template"),first:null};if(typeof e=="string"){let r=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(r){let s=ys(e,t),i=r[1].toLowerCase()==="html"?s.documentElement:s.body;return{root:i,first:i}}let o=t.createElement("template");return o.innerHTML=e,{root:o,first:o.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let r=t.createElement("template"),o=e.isConnected;return r.content.appendChild(o?t.importNode(e,!0):e),{root:r,first:e}}if(e.nodeType===11){let r=t.createElement("template");return r.content.appendChild(e),{root:r,first:r.content.firstElementChild}}let n=t.createElement("template");for(let r of Array.from(e))n.content.appendChild(r.parentNode?t.importNode(r,!0):r);return{root:n,first:n.content.firstElementChild}}function pl(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return n.lineage===void 0?Hc(e,t,n):el(n,e,r=>Hc(e,t,r))}function Hc(e,t,n={}){let r=e.ownerDocument,{base:o,...s}=n,i=!!s.children,l=Vo(s,[e]);if(l.ignored(e)){let v=bl();return l.lineage&&Fo(l.lineage,e,v).deliver(v),Promise.resolve(v)}let a=Uc(t,r),c=o!=null?Uc(o,r):null,p,u=null;if(i)p=a.root,u=c?c.root:null;else{if(p=a.first,u=c?c.first:null,!p){let v=Vo(s),g=v.lineage?Fo(v.lineage,e,{}):null;v.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),v.hooks.afterNodeRemoved(e));let m={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:ar()};return g&&(m.lineage=g.result,g.deliver(m)),Promise.resolve(m)}if(p.tagName!==e.tagName){let v=Vo(s,[e,p]);if(v.hooks.beforeNodeMorphed(e,p)===!1){let k=bl();return v.lineage&&Fo(v.lineage,e,k).deliver(k),Promise.resolve(k)}let g=gl({liveRoot:e,baseRoot:u&&u.tagName===e.tagName?u:null,localRoot:e,remoteRoot:p,toLive:k=>k,options:s,identity:s.identity||{},childrenOnly:!0,isDocument:!1}),m=mn(p)?Bo(p,r):r.importNode(p,!1);if(!mn(m))for(;e.firstChild;)m.appendChild(e.firstChild);return v.hooks.beforeNodeAdded(m)===!1?(Ms(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):v.hooks.beforeNodeRemoved(e)===!1?(Ms(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(m),Ms(g.report.conflicts,e,m),v.hooks.afterNodeRemoved(e),v.hooks.afterNodeAdded(m),v.hooks.afterNodeMorphed(e,p),g.report.replaced.push(m),g.report.applied.push({kind:"insert",node:m,parent:m.parentNode},{kind:"remove",node:e,parent:m.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,m),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:f,loads:h,lineage:d}=gl({liveRoot:e,baseRoot:u,localRoot:e,remoteRoot:p,toLive:v=>v,options:s,identity:s.identity||{},childrenOnly:i,isDocument:!1});return d?.deliver(f),Promise.all(h).then(()=>f)}var kl={mergeDocument:zo,morphDocument:Rm,morphElement:pl,merge3:Mm,morph:fr};var js={};_i(js,{EmptyListInsert:()=>dr,MAX_RULE_DEPTH:()=>io,MaxRuleDepthExceeded:()=>Mr,NoRulesTag:()=>yl,RuleTargetReadOnly:()=>Ko,RulesParseError:()=>oo,ShapeMismatch:()=>Wo,UnknownRulesVersion:()=>so,WriteNotRoundTripped:()=>Ps,WriteRefused:()=>Is,WriteRejected:()=>vl});var oo=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},so=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},io=20,Mr=class extends Error{constructor(t){super(`rule depth exceeded ${io} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},Wo=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},dr=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},Ko=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},Is=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function qm(e){return e.reduce((n,r)=>typeof r=="number"?`${n}[${r}]`:n?`${n}.${r}`:String(r),"")||"(root)"}var Ps=class extends Error{constructor(t){super(`write did not round-trip at "${qm(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},yl=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},vl=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};var Dm=/^--[A-Za-z0-9_-]+$/;function Rr(e){return typeof e=="string"&&Dm.test(e)}function zc(e){let t=[],n=[],r=null,o=0;for(let s=0;s<e.length;s++){let i=e[s];if(r){i==="\\"?s++:i===r&&(r=null);continue}if(i==="/"&&e[s+1]==="*"){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+1;continue}i==='"'||i==="'"?r=i:i==="("?n.push(")"):i==="["?n.push("]"):i==="{"?n.push("}"):(i===")"||i==="]"||i==="}")&&n[n.length-1]===i?n.pop():i===";"&&n.length===0&&(t.push(e.slice(o,s)),o=s+1)}return t.push(e.slice(o)),t}function Fm(e){let t="",n=null;for(let r=0;r<e.length;r++){let o=e[r];if(n){t+=o,o==="\\"&&r+1<e.length?t+=e[++r]:o===n&&(n=null);continue}if(o==="/"&&e[r+1]==="*"){let s=e.indexOf("*/",r+2);r=s===-1?e.length:s+1,t+=" ";continue}(o==='"'||o==="'")&&(n=o),t+=o}return t}function Vc(e){e=Fm(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),r=e.slice(t+1).trim(),o=/!\s*important\s*$/i.exec(r);return o&&(r=r.slice(0,o.index).trim()),{name:n,value:r,important:!!o}}function Go(e,t){if(e==null)return null;let n=null;for(let r of zc(String(e))){let o=Vc(r);!o||o.name!==t||(!n||o.important||!n.important)&&(n=o)}return n?n.value:null}function Wc(e,t,n){let r=e==null?"":String(e),o=n==null||n==="",s=zc(r),i=s.map(Vc),l=i.some(u=>u&&u.name===t&&u.important),a=[],c=!1;s.forEach((u,f)=>{let h=i[f];if(!h||h.name!==t){a.push(u);return}if(o||c)return;let d=/^\s*/.exec(u)[0];a.push(`${d}${t}: ${n}${l?" !important":""}`),c=!0});let p=a.join(";");if(!o&&!c){let u=p.trimEnd();p=u===""?`${t}: ${n}`:`${u}${u.endsWith(";")?" ":"; "}${t}: ${n}`}return p.trim()===""?null:p}function xl(e,t,n,r){let o=e.attr(t,"style");if((Go(o,n)??"")===r)return;let s=Wc(o,n,r);s==null?e.removeAttr(t,"style"):e.attr(t,"style",s)}function hr(e,t,n,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return wl(e,t,n,{depth:0,path:[]},r)}function wl(e,t,n,r,o){if(r.depth>io)throw new Mr(r.path);if(typeof n=="string")return Bm(e,t,n,r,o);if(Array.isArray(n)){let[s,i]=n,l=e.find(t,s,o);return Gc(o,r,l),l.map((a,c)=>wl(e,a,i,{depth:r.depth+1,path:[...r.path,c]},o))}if(typeof n=="object"&&n!==null){let s={};for(let[i,l]of Object.entries(n))s[i]=wl(e,t,l,{depth:r.depth+1,path:[...r.path,i]},o);return s}return null}function Bm(e,t,n,r,o){if(n.endsWith("[]")){let l=n.slice(0,-2),a=e.find(t,l,o);return Gc(o,r,a),a.map(c=>e.text(c))}if(n.startsWith("@"))return Kc(e,t,n.slice(1));let s=Kt(n);if(s!==-1){let l=n.slice(0,s),a=n.slice(s+1),c=l?e.find(t,l,o):[t];return c.length===0?null:Kc(e,c[0],a)}if(n===".")return e.text(t);let i=e.find(t,n,o);return i.length===0?null:e.text(i[0])}function Gc(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(r){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,r)}}function Kc(e,t,n){if(Rr(n))return Go(e.attr(t,"style"),n);if(Po.has(n)){let o=e.prop(t,n);return o==null?null:String(o)}let r=e.attr(t,n);return r??null}var qs=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),$m=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Yc=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function Yo(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function Sl(e,t){if(Yo(e,t))return!0;for(let[n,r]of Object.entries($m))if(r.includes(t)&&Yo(e,n))return!0;return!1}function Xo(e){let t=qs[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Um(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=qs[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>Sl(n,o))||r.bundles.some(o=>Yo(n,o)))return n;n=n.parentElement}return null}function Xc(e,t){return!!Um(e,t)}var Hm=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function zm(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Jc(e,t,n,r){if(r)return!!e.closest?.(t);let o=e;for(;o?.nodeType===1;){if(o.matches(t))return!0;if(o===n)break;o=o.parentElement}return!1}function Zc(e,t,n,r,o,s){return(s?Xc(e,t):Jc(e,n,o,!1))||!!(r&&(s&&e!==o?e.matches(r):Jc(e,r,o,s)))}function Vm(e,t){let n=qs[t];return n.tokens.some(r=>Sl(e,r))||n.bundles.some(r=>Yo(e,r))}var Wm=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Qc(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let o=e,s=t;if(e.nodeType===1){if(Wm.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);o=e.content,s=t.content,n.cloneToLive.set(s,o),n.liveToClone.set(o,s)}}else if(e.nodeType!==11)return;let i=s.firstChild;for(let l=o.firstChild;l&&i;l=l.nextSibling)Qc(l,i,n,r),i=i.nextSibling}function Jo(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:o=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=s.implementation.createHTMLDocument(""),l=o||new WeakMap,a=new WeakMap,c=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let p=Xo(t),u=r?d=>Vm(d,t)||!!(n&&d.matches(n)):d=>Zc(d,t,p,n,c,!1),f=null;if(c.nodeType!==1||!Zc(c,t,p,n,c,r)){f=i.importNode(c,!0);let d={cloneToLive:l,liveToClone:a,dropped:[],controls:[]};Qc(c,f,d,u);for(let v of d.dropped)v.remove();for(let v=0;v<d.controls.length;v+=2)zm(d.controls[v],d.controls[v+1])}e.nodeType===9&&f&&(i.replaceChild(f,i.documentElement),a.set(e,i),l.set(i,e));let h=d=>{if(Hm.test(d))throw new Error(`Filtered content queries do not support stateful selector: ${d}`)};return{root:f,document:i,capability:t,selector:Xo(t),cloneToLive:l,liveToClone:a,original(d){return l.get(d)||null},cloneOf(d){return a.get(d)||null},query(d,v=f){return h(d),Array.from(v.querySelectorAll(d),g=>l.get(g)||g)},text(d=f){return(d===f?f:a.get(d))?.textContent||""},html(d=f){return(d===f?f:a.get(d))?.innerHTML??""},clone(d=f){let v=d===f?f:a.get(d);return v?i.importNode(v,!0):null}}}function tu(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Km(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function eu(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function nu(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function ru(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let r=n.type;r!=="file"&&r!=="checkbox"&&r!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var rn={semanticExclude:!0,find(e,t,n={}){let r=Km(e);if(!r||!r.querySelectorAll)return[];let o=Array.from(r.querySelectorAll(t));n.includeRulesTag||(o=o.filter(l=>!tu(l)));let s=[];n.skip&&s.push(n.skip);let i=n.templateAttr===null?null:n.templateAttr||"cms-template";if(i&&s.push("["+i+"]"),s.length){let l=s.join(", ");o=o.filter(a=>!a.closest||!a.closest(l))}return o},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,nu(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),eu(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),eu(e,t,null)},prop(e,t,n){if(n===void 0){let r=e?e[t]:void 0;return r!==void 0?r:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return ru(t),t},insertAt(e,t,n){let r=e.children[n]||null;e.insertBefore(t,r)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let o=r.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Qn(e,t={}){if(t.exclude===null)return rn;let n=[Xo("data"),t.exclude].filter(Boolean).join(", "),r=e.nodeType===9?e:e.ownerDocument||e,o=e.nodeType===9?e.documentElement:e;if(!t._write&&!o?.matches?.(n)&&!o?.querySelector?.(n)&&!r?.querySelector?.(n))return rn;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,i=e.nodeType===9?e:e.ownerDocument,l=null,a=()=>l||(l=Jo(s,{capability:"data",exclude:t.exclude||null})),c=d=>{let v=a();return d===e?v.cloneOf(e):v.cloneOf(d)||d},p=d=>l?.original(d)||d,u=(d,v)=>{a().liveToClone.set(d,v),a().cloneToLive.set(v,d);let g=d.childNodes||[],m=v.childNodes||[];for(let k=0;k<Math.min(g.length,m.length);k++)u(g[k],m[k])},f=(d,v,g,m)=>{let k=Array.from(d.childNodes).filter(N=>l.cloneOf(N)),x=k[0];for(;x&&k.includes(x);)x=x.nextSibling;for(let N of k)N.remove();if(g==="innerHTML"){let N=i.createElement("template");N.innerHTML=m;for(let C of Array.from(N.content.childNodes))d.insertBefore(C,x||null)}else d.insertBefore(i.createTextNode(m),x||null),nu(d,m);let w=Jo(d,{capability:"data",exclude:t.exclude||null});v.replaceChildren(...Array.from(w.root?.childNodes||[]));let T=N=>{let C=w.original(N);C&&(l.liveToClone.set(C,N),l.cloneToLive.set(N,C));for(let I of Array.from(N.childNodes||[]))T(I)};for(let N of Array.from(v.childNodes))T(N)},h={...rn,find(d,v,g={}){let m=c(d);if(!m?.querySelectorAll)return[];let k=a().query(v,m);g.includeRulesTag||(k=k.filter(w=>!tu(w)));let S=[];g.skip&&S.push(g.skip);let x=g.templateAttr===null?null:g.templateAttr||"cms-template";if(x&&S.push(`[${x}]`),S.length){let w=S.join(", ");k=k.filter(T=>!T.closest?.(w))}return k},parent(d){let v=c(d)?.parentElement;return v?p(v):null},children(d){return Array.from(c(d)?.children||[],p)},text(d,v){if(v===void 0){let k=p(d);return!k?.matches?.(n)&&!k?.querySelector?.(n)?rn.text(k):(c(d)?.textContent||"").trim()}let g=p(d);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){rn.text(g,v);return}let m=a().cloneOf(g);m?f(g,m,"textContent",v):rn.text(g,v)},attr(d,v,g){let m=p(d);if(g===void 0)return rn.attr(m,v);rn.attr(m,v,g);let k=l?.cloneOf(m);k&&(rn.attr(k,v,g),Jo(m,{capability:"data",exclude:t.exclude||null}).root===null&&(k.remove(),l.liveToClone.delete(m),l.cloneToLive.delete(k)))},removeAttr(d,v){let g=p(d);rn.removeAttr(g,v);let m=l?.cloneOf(g);m&&rn.removeAttr(m,v)},prop(d,v,g){let m=p(d);if(g===void 0)return v==="innerHTML"||v==="outerHTML"||v==="textContent"||v==="innerText"?rn.prop(c(m),v):rn.prop(m,v);let k=v==="innerHTML"||v==="textContent"||v==="innerText",S=k?a().cloneOf(m):l?.cloneOf(m);S&&k?f(m,S,v,g):(rn.prop(m,v,g),S&&rn.prop(S,v,g))},clone(d){let v=c(d);if(v===d)return rn.clone(d);let g=i.importNode(v,!0);return ru(g),g},insertAt(d,v,g){let m=p(d),S=h.children(m)[g]||(()=>{for(let T=m.children.length-1;T>=0;T--){let N=m.children[T];if(a().cloneOf(N))return N.nextElementSibling}return m.firstElementChild})(),x=p(v);m.insertBefore(x,S||null);let w=a().cloneOf(m);if(w){let T=a().cloneOf(x);T||(T=i.importNode(x,!0),u(x,T));let N=Array.from(w.children);w.insertBefore(T,N[g]||null)}},insertBefore(d,v){let g=p(d),m=p(v);g.parentNode.insertBefore(m,g);let k=a().cloneOf(g.parentNode);if(k){let S=a().cloneOf(m);S||(S=i.importNode(m,!0),u(m,S));let x=a().cloneOf(g);x?x.before(S):k.appendChild(S)}},insertAfter(d,v){let g=p(d),m=p(v);g.parentNode.insertBefore(m,g.nextSibling);let k=a().cloneOf(g.parentNode);if(k){let S=a().cloneOf(m);S||(S=i.importNode(m,!0),u(m,S));let x=a().cloneOf(g);x?x.after(S):k.appendChild(S)}},identity(d){return p(d)||null},remove(d){let v=p(d),g=a().cloneOf(v);rn.remove(v),g&&rn.remove(g)},replaceWith(d,v){let g=p(d),m=a().cloneOf(g),k=rn.replaceWith(g,v);if(m){let S=Jo(k,{capability:"data",exclude:t.exclude||null});if(!S.root)m.remove();else{m.replaceWith(S.root);let x=w=>{let T=S.original(w);T&&(l.liveToClone.set(T,w),l.cloneToLive.set(w,T));for(let N of Array.from(w.childNodes||[]))x(N)};x(S.root)}}return k}};return h}var lo=rn;function Al(e){try{return JSON.parse(e)}catch(t){throw new oo(`Invalid strict JSON: ${t.message}`,t)}}function ao(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(o){let s=[],i=0;for(;i<o.length;){let l=o[i];if(/\s/.test(l)){i++;continue}if("{}".includes(l)){s.push({type:l,value:l}),i++;continue}if(l==="["){let u=!1,f=i+1;for(;f<o.length&&/\s/.test(o[f]);)f++;if(f<o.length&&/[a-zA-Z_]/.test(o[f])&&(u=!0),!u){s.push({type:l,value:l}),i++;continue}}if(l==="]"){s.push({type:l,value:l}),i++;continue}if(l===":"){s.push({type:t.COLON,value:l}),i++;continue}if(l===","){s.push({type:t.COMMA,value:l}),i++;continue}if(l==='"'||l==="'"){let u=l,f=i+1;for(;f<o.length&&o[f]!==u;)o[f]==="\\"&&f++,f++;s.push({type:t.STRING,value:o.substring(i+1,f),quoted:!0,sourceQuote:u}),i=f+1;continue}let a=i,c;for(;a<o.length&&!/[{},]/.test(o[a]);)if(o[a]===":"){let u=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],f=!1;for(let h of u){let d=h.substring(1);if(o.substring(a+1,a+1+d.length)===d){f=!0,a+=d.length;break}}if(!f)break}else if(o[a]==="["){for(a++;a<o.length&&o[a]!=="]";){if(o[a]==='"'||o[a]==="'"){let u=o[a];for(a++;a<o.length&&o[a]!==u;)o[a]==="\\"&&a++,a++}a++}a<o.length&&o[a]==="]"&&a++}else a++;c=o.substring(i,a);let p=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?p=t.NUMBER:c==="true"||c==="false"||c==="null"?p=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(p=t.SELECTOR),s.push({type:p,value:c,quoted:!1}),i=a}return s}function r(o){let s="";for(let i=0;i<o.length;i++){let l=o[i];if("{}".includes(l.type)||"[]".includes(l.type)){s+=l.value;continue}if(l.type===t.COLON){s+=l.value;continue}if(l.type===t.COMMA){let a=o[i+1];if(a&&(a.type==="}"||a.type==="]"))continue;s+=l.value;continue}if(l.type===t.STRING&&l.quoted){let a=l.value;l.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(c,p)=>p.length%2===0?p+'\\"':c)),s+=`"${a}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){s+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){s+=`"${l.value}"`;continue}s+=`"${l.value}"`}return s}try{let o=n(e),s=r(o);return JSON.parse(s)}catch(o){throw new oo("Invalid extraction rules syntax: "+o.message,o)}}var su="1",ou=/^[a-zA-Z0-9_-]+$/;function Zo(e,t,n){let r;if(n===void 0)r="script[data-rules-name]";else{if(typeof n!="string"||!ou.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${ou})`);r=`script[data-rules-name~="${n}"]`}let o=e.find(t,r,{includeRulesTag:!0});if(o.length===0)return null;n!==void 0&&o.length>1&&console.warn(`hyper-html-api: ${o.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=o[0],i=e.attr(s,"data-rules-version");if(i!==su)throw new so(i);return{rules:ao(e.text(s)),tagNode:s}}var _v=new Function("url","return import(url)");function fu(e,t,n,r){let o=e.length,s=t.length,i=new Array(o).fill(-1);if(r){let m=new Set;for(let k=0;k<o;k++){let S=r[k];!(S>=0&&S<s)||m.has(S)||(i[k]=S,m.add(S))}}if(o===0||s===0)return i;let l=e.map(m=>cu(m,n)),a=t.map(m=>cu(m,n)),c=new Array(s).fill(!1);for(let m of i)m>=0&&(c[m]=!0);let p=new Map;a.forEach((m,k)=>{c[k]||p.set(m,p.has(m)?-1:k)});let u=new Map;l.forEach((m,k)=>{i[k]>=0||u.set(m,(u.get(m)||0)+1)}),l.forEach((m,k)=>{if(i[k]>=0||u.get(m)!==1)return;let S=p.get(m);S===void 0||S===-1||c[S]||(i[k]=S,c[S]=!0)});let f=[];for(let m=0;m<o;m++)i[m]<0&&f.push(m);let h=[];for(let m=0;m<s;m++)c[m]||h.push(m);if(f.length===0||h.length===0)return i;let d=o*s+1,v=Ym(e,t,n),g=(m,k)=>v(m,k)*d+Math.abs(m-k);for(let[m,k]of Xm(f,h,g))i[m]=k;return i}var du=e=>typeof e=="object"&&e!==null;function cu(e,t){if(!du(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(r=>{let o=JSON.stringify(e?.[r]);return o===void 0?" undef":o}))}function Ym(e,t,n){if(!du(n))return(l,a)=>e[l]===t[a]?0:1;let r=Object.keys(n),o=l=>r.map(a=>JSON.stringify(l?.[a])),s=e.map(o),i=t.map(o);return(l,a)=>{let c=s[l],p=i[a],u=0;for(let f=0;f<r.length;f++)c[f]!==p[f]&&u++;return u}}function Xm(e,t,n){return e.length<=t.length?uu(e,t,n,!1):uu(t,e,(r,o)=>n(o,r),!0)}function uu(e,t,n,r){let o=e.length,s=t.length,i=[];for(let u=0;u<=o;u++)i.push(new Float64Array(s+1).fill(1/0));let l=[];for(let u=0;u<=o;u++)l.push(new Uint8Array(s+1));for(let u=0;u<=s;u++)i[o][u]=0;for(let u=o-1;u>=0;u--)for(let f=s-1;f>=0;f--){let h=n(e[u],t[f])+i[u+1][f+1],d=i[u][f+1];h<=d?(i[u][f]=h,l[u][f]=1):i[u][f]=d}let a=[],c=0,p=0;for(;c<o&&p<s;)l[c][p]&&(a.push(r?[t[p],e[c]]:[e[c],t[p]]),c++),p++;return a}function El(e,t,n,r,o,s,i,l={}){let a=e.find(t,n,l);if(o.length===0){a.forEach(x=>e.remove(x)),Tl(l,"onRowsApplied",s.path,[]);return}let c=o.length>a.length,p=a[0]||null;if(c&&!p&&(p=ep(e,t,n,l),!p))throw new dr(s.path);let u=a.map(x=>Qm(e,x,r,l)),f=null;if(c&&p){f=e.clone(p),l.templateAttr&&e.removeAttr(f,l.templateAttr);let x=e.stripIds(f);x>0&&console.warn(`[hyper-html-api] stripped ${x} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let h=fu(o,u,r,Jm(e,a,o,s,l)),d=a.length>0?e.parent(a[0]):op(e,t,n,p,s,l),v=a.length>0?bu(e,d,a[0]):0,g=lp(e,a),m=new Set,k=[],S=o.map((x,w)=>{let T=h[w];if(T>=0)return m.add(T),k.push(!1),a[T];k.push(!0);let N=e.clone(f);return e.stripIds(N),N});a.forEach((x,w)=>{m.has(w)||e.remove(x)}),g?ip(e,d,v,S,k):ap(e,S,k,d,v),Zm(e,S,r,o,s,i,l),Tl(l,"onRowsApplied",s.path,S)}function Tl(e,t,n,r){if(typeof e[t]=="function")try{return e[t](n.slice(),r)}catch(o){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,o);return}}function Jm(e,t,n,r,o){let s=Tl(o,"identifyRows",r.path,n);if(!Array.isArray(s))return null;let i=new Array(n.length).fill(-1),l=new Set,a=new Map(t.map((c,p)=>[e.identity(c),p]));for(let c=0;c<n.length;c++){if(!s[c])continue;let p=a.get(e.identity(s[c]));p===void 0||l.has(p)||(i[c]=p,l.add(p))}return i}function Zm(e,t,n,r,o,s,i){t.forEach((l,a)=>{if(n===null){let c=r[a],p=c==null?"":String(c);e.text(l)!==p&&e.text(l,p)}else{let c=s(e,l,n,r[a],{depth:o.depth+1,path:[...o.path,a]},i);c&&c!==l&&(t[a]=c)}})}function Qm(e,t,n,r){return n===null?e.text(t):hr(e,t,n,r.onRowsRead?{...r,onRowsRead:void 0}:r)}function bu(e,t,n){let r=e.children(t);for(let o=0;o<r.length;o++)if(e.sameNode(r[o],n))return o;return-1}function ep(e,t,n,r){if(!r.templateAttr)return null;let o=/^\s*:scope\s*>\s*/.test(n),s=new RegExp(":not\\(\\["+r.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),i=n.replace(/^\s*:scope\s*>\s*/,"").replace(s,""),l=o?tp(i):0,a=Li(i),c=t;for(;c;){let p=e.find(c,i,{includeRulesTag:!1,templateAttr:null});for(let u of p)if(e.attr(u,r.templateAttr)!=null&&!(o&&!rp(e,t,u,l))&&!(a&&!e.matches(e.parent(u),a)))return u;c=e.parent(c)}return null}function tp(e){let t=0,n=null,r=1;for(let o=0;o<e.length;o++){let s=e[o];if(s==="\\")o++;else if(n)s===n&&(n=null);else if(s==='"'||s==="'")n=s;else if(s==="["||s==="(")t++;else if(s==="]"||s===")")t>0&&t--;else if(t===0&&s===">")r++;else{if(t===0&&(s==="+"||s==="~"))return null;if(t===0&&/\s/.test(s)){if(!np(e,o))return null;for(;o+1<e.length&&/\s/.test(e[o+1]);)o++}}}return r}function np(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let r=t>0?e[t-1]:"",o=n<e.length?e[n]:"";return hu(r)||hu(o)}function hu(e){return e===">"||e==="+"||e==="~"}function rp(e,t,n,r){if(r===null)return!0;let o=n;for(let a=0;a<r;a++)if(o=e.parent(o),!o)return!1;let s=e.prop(t,"tagName");if(!s)return!0;let i=e.prop(o,"tagName");if(!i||String(i).toLowerCase()!==String(s).toLowerCase())return!1;let l=new Set(mu(e,o));return mu(e,t).every(a=>l.has(a))}function mu(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function op(e,t,n,r,o,s){let i=e.parent(r);if(i&&sp(e,t,i)&&!gu(e,i,s))return i;let l=Li(n);if(!l)throw new dr(o.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let c=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,s)).filter(p=>!gu(e,p,s));if(c.length===0)throw new dr(o.path,`no container matching "${l}" inside this context to hold the new rows`);if(c.length>1)throw new dr(o.path,`"${l}" matches ${c.length} containers inside this context, so the new rows have no single destination`);return c[0]}function sp(e,t,n){let r=n;for(;r;){if(e.sameNode(r,t))return!0;r=e.parent(r)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(o=>e.sameNode(o,n))}var pu=["no-data","editor-ui"];function gu(e,t,n){let r=t;for(;r;){if(n.templateAttr&&e.attr(r,n.templateAttr)!=null||pu.some(s=>e.attr(r,s)!=null))return!0;let o=e.attr(r,"clay");if(o&&o.split(/\s+/).some(s=>pu.includes(s)))return!0;r=e.parent(r)}return!1}function ip(e,t,n,r,o){let s=e.children(t),i=s.map(a=>e.identity(a)),l=!1;r.forEach((a,c)=>{let p=e.identity(a),u=n+c;if(i[u]===p)return;if(!o[c]){let h=i.indexOf(p);h!==-1&&(i.splice(h,1),s.splice(h,1))}let f=Math.min(u,s.length);f<s.length?e.insertBefore(s[f],a):s.length?l?e.insertAfter(s[s.length-1],a):(e.insertAt(t,a,u),l=!0):e.insertAt(t,a,0),i.splice(f,0,p),s.splice(f,0,a)})}function lp(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let r=new Map(e.children(n).map((s,i)=>[e.identity(s),i])),o=[];for(let s of t){let i=r.get(e.identity(s));if(i===void 0)return!1;o.push(i)}return o.sort((s,i)=>s-i),o[o.length-1]-o[0]===o.length-1}function ap(e,t,n,r,o){let s=null,i=o;for(let l=0;l<t.length;l++){if(!n[l]){s=t[l];continue}let a=s?e.parent(s):r;if(!a)continue;let c=s?bu(e,a,s)+1:i++;e.insertAt(a,t[l],c),s=t[l]}}function co(e,t,n,r,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let s=[];if(Ol(n,r,[],s),s.length)throw new Wo(s);Ds(e,t,n,r,{depth:0,path:[]},o)}function Ds(e,t,n,r,o,s={}){if(o.depth>io)throw new Mr(o.path);if(r===void 0)return t;if(typeof n=="string")return cp(e,t,n,r,o,s);if(Array.isArray(n)){let[i,l]=n;return El(e,t,i,l,r,o,Ds,s),t}if(typeof n=="object"&&n!==null){for(let[i,l]of Object.entries(n)){let a=Ds(e,t,l,r==null?r:r[i],{depth:o.depth+1,path:[...o.path,i]},s);a&&a!==t&&(t=a)}return t}return t}function cp(e,t,n,r,o,s){if(n.endsWith("[]")){let a=n.slice(0,-2);return El(e,t,a,null,r,o,Ds,s),t}if(n.startsWith("@"))return yu(e,t,n.slice(1),r);let i=Kt(n);if(i!==-1){let a=n.slice(0,i),c=n.slice(i+1),p=a?e.find(t,a,s):[t];return p.length===0||yu(e,p[0],c,r),t}if(n===".")return ku(e,t,r),t;let l=e.find(t,n,s);return l.length===0||ku(e,l[0],r),t}function ku(e,t,n){let r=n==null?"":String(n);e.text(t)!==r&&e.text(t,r)}function up(e,t,n,r){if(e.styleVar){e.styleVar(t,n,r);return}xl(e,t,n,r)}function yu(e,t,n,r){if(Rr(n))return up(e,t,n,r==null?"":String(r).trim()),t;if(Vr.has(n)){let o=e.prop(t,n);if(o===r||o!=null&&r!=null&&String(o)===String(r))return t;throw new Ko(n)}if(n==="outerHTML"){let o=r==null?"":String(r);return e.replaceWith(t,o)}if(Mi.has(n)){let o=Ri(n,r);return e.prop(t,n)!==o&&e.prop(t,n,o),t}if(r==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let o=String(r);e.attr(t,n)!==o&&e.attr(t,n,o)}return t}function Ol(e,t,n,r){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((o,s)=>{typeof o=="object"&&o!==null&&r.push({path:es([...n,s]),expected:"scalar",got:Qo(o)})}):r.push({path:es(n),expected:"array",got:Qo(t)});return}t!==null&&typeof t=="object"&&r.push({path:es(n),expected:"scalar",got:Qo(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){r.push({path:es(n),expected:"array",got:Qo(t)});return}let o=e[1];t.forEach((s,i)=>Ol(o,s,[...n,i],r));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){r.push({path:es(n),expected:"object",got:Qo(t)});return}for(let[o,s]of Object.entries(e))Ol(s,t[o],[...n,o],r)}}}function Qo(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function es(e){return e.join(".")}var xu=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...Yc],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function wp(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let r=0;r<e.length;r++){let o=e[r];if(n){o===n&&(n=null);continue}if(o==='"'||o==="'")n=o;else{if(o==="/"&&e[r+1]==="*")return"comments are not allowed in a custom property value";if(o==="(")t.push(")");else if(o==="[")t.push("]");else if((o===")"||o==="]")&&t.pop()!==o)return`"${o}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function Nl(e,t=xu){let n=t.customPropertyValues,r=String(e);if(r.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let o=n.refusedCharacters.find(a=>r.includes(a));if(o)return`${JSON.stringify(o)} is not allowed in a custom property value`;let s=wp(r);if(s)return s;let i=r.toLowerCase(),l=n.refusedFunctions.find(a=>new RegExp(`(^|[^a-z0-9_-])${a.replace(/[-]/g,"\\-")}\\s*\\(`).test(i));return l?`"${l}()" is not allowed in a custom property value`:null}function Cl(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let r=t&&t.ownerDocument?t.ownerDocument:t;return Zo(e,r,n)}return null}var un={extract:(e,t,n={})=>hr(Qn(e,n),e,t,n),apply:(e,t,n,r={})=>co(Qn(e,{...r,_write:!0}),e,t,n,r),findRulesIn:(e,t)=>Zo(lo,e,t),findRules:(e,t)=>Cl(lo,e,t),bind:(e,t,n={})=>{let r=Cl(lo,e,t);if(!r){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}return{...r,get:()=>hr(Qn(e,n),e,r.rules,n),set:o=>co(Qn(e,{...n,_write:!0}),e,r.rules,o,n)}},parseStrict:Al,parseRelaxed:ao,ruleAttrIndex:Kt,splitRule:jo,errors:js,DOM_PROPERTIES:ks};var Ml={};_i(Ml,{fromString:()=>er,getRuleAtPath:()=>tr,getValueAtPath:()=>Op,setAtPath:()=>_l,toString:()=>Ep});function Ep(e){return e.map(String).join(".")}function er(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function tr(e,t){let n=e;for(let r of t){if(n==null)return;if(typeof n=="string"){if(n.endsWith("[]")&&(typeof r=="number"||r==="*")){n=n.slice(0,-2);continue}return}if(Array.isArray(n)){if(typeof r!="number"&&r!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof r=="number"||!(r in n))return;n=n[r];continue}return}return n}function Op(e,t){let n=e;for(let r of t){if(n==null)return;n=n[r]}return n}function _l(e,t,n){if(t.length===0)return n;let[r,...o]=t;if(typeof r=="number"){let s=Array.isArray(e)?[...e]:[];return s[r]=_l(s[r],o,n),s}return{...e&&typeof e=="object"?e:{},[r]:_l((e||{})[r],o,n)}}function ts(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[n,r]of Object.entries(e))t[n]=ts(r);return t}return""}function Fs(e,t,{ignoreActiveValue:n=!0}={}){kl.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:n,restoreFocus:!0,formStateSync:"property",policy:"raw"})}var wu=new WeakMap,Rl=e=>e.map(String).join(".");function Np(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function Su(e,t){if(!e||!e.querySelector)return null;let n=e.querySelector(`[data-hcms-path="${Np(t)}"]`),r=n&&n.querySelector(".hcms-array-items");return r?Array.from(r.children).filter(o=>o.matches&&o.matches("[data-hcms-card], [data-hcms-array-item]")):null}function Au(e,t,n){let r=Su(e,t);!r||r.length!==n.length||r.forEach((o,s)=>{n[s]&&wu.set(o,n[s])})}function Bs(){let e=new Map;return{hooks:{onRowsRead(t,n){e.set(Rl(t),n)}},seed(t){for(let[n,r]of e)Au(t,n,r);e.clear()}}}function Tu(e){return{identifyRows(t,n){let r=Su(e,Rl(t));return!r||r.length!==n.length?null:r.map(o=>wu.get(o)||null)},onRowsApplied(t,n){Au(e,Rl(t),n)}}}function jn(e){return e&&e.nodeType===9?e.body||e.documentElement:e}function $s(e,t){if(!t||t.nodeType!==9)return e;return n(e);function n(r){if(typeof r=="string")return r==="."?"body":r.startsWith("@")?`body${r}`:r;if(Array.isArray(r)||!r||typeof r!="object")return r;let o={};for(let[s,i]of Object.entries(r))o[s]=n(i);return o}}var Eu={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Ll="data-hcms-rollback-ui",Cp=0;function Ou(e,t,n,r={}){return _p(e,t,n,r)}function _p(e,t,n,r){let{shellRoot:o,structural:s,structuralPath:i,formRoot:l}=r,a=l?{...Eu,...Tu(l)}:Eu;if(!s)try{return un.apply(e,t,n,a),{ok:!0}}catch(f){return{ok:!1,error:f}}let c=Mp(e,t,i),p=c?Lp(c):null,u=c?null:Pp(jn(e),o);try{return un.apply(e,t,n,a),{ok:!0}}catch(f){return p?Ip(c,p):u&&jp(jn(e),o,u),{ok:!1,error:f}}}function Mp(e,t,n){if(!n||!e)return null;let r=er(n),o=[],s=t;for(let i of r){if(typeof s=="string"||s==null||Array.isArray(s))break;if(typeof s=="object"&&i in s){if(o.push(i),s=s[i],Array.isArray(s)||typeof s=="string"&&s.endsWith("[]"))break}else return null}return!Array.isArray(s)&&!(typeof s=="string"&&s.endsWith("[]"))?null:Rp(e,t,o)}function Rp(e,t,n){if(n.length===0)return null;let r=e,o=t;for(let s=0;s<n.length;s++){let i=n[s];if(!o||typeof o!="object"||Array.isArray(o))return null;let l=o[i];if(l==null)return null;if(s===n.length-1){if(Array.isArray(l)){let[a]=l;return r.querySelector?.(a)?.parentElement||null}if(typeof l=="string"&&l.endsWith("[]")){let a=l.slice(0,-2);return r.querySelector?.(a)?.parentElement||null}return null}o=l}return null}function Lp(e){let t=[],n=[];for(let r of Array.from(e.childNodes))t.push(Il(r,n));return{nodes:t,retained:n}}function Ip(e,t){let n=e.cloneNode(!1);for(let r of t.nodes)n.appendChild(r);fr(e,Array.from(n.childNodes),Cu()),Nu(e,t.retained)}function Pp(e,t){let n=[],r=[];for(let o of Array.from(e.childNodes))o===t||t&&o.contains?.(t)||n.push(Il(o,r));return{nodes:n,retained:r}}function jp(e,t,n){let r=e.cloneNode(!1);for(let o of n.nodes)r.appendChild(o);fr(e,Array.from(r.childNodes),Cu()),Nu(e,n.retained)}function Il(e,t){let n=e.cloneNode(!1);if(e.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]')){let s=String(++Cp);n.setAttribute(Ll,s),t.push({id:s,node:e})}let r=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,o=n.nodeType===1&&n.tagName==="TEMPLATE"?n.content:n;for(let s of Array.from(r.childNodes||[]))o.appendChild(Il(s,t));return n}function Nu(e,t){for(let{id:n,node:r}of t){let o=e.querySelector(`[${Ll}="${n}"]`);o===r?r.removeAttribute(Ll):r.isConnected?o?.remove():o?.replaceWith(r)}}function Cu(){return{morphStyle:"innerHTML",policy:"raw",restoreFocus:!1,scripts:{handle:!1,merge:!1}}}var qp=/^--font-(size|weight|style|stretch|variant|feature-settings|variation-settings|optical-sizing|kerning|synthesis|smoothing|palette|size-adjust|display)(-|$)/;function Lr(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[-_]/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}var Dp='<div class="hcms-drag-handle mirk-sortable__grip" aria-hidden="true"><div class="mirk-sortable__dots"><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span></div></div>',Us='<svg class="hcms-x" viewBox="0 0 16 16" shape-rendering="crispEdges" aria-hidden="true"><path d="M4 4 L12 12 M12 4 L4 12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square"></path></svg>',Lu={"@scalar":`
6
+ `+s)}return n+l.replace(/</g,"\\u003c")+r}function ol(e,t,n,r={}){let o=r.parse||nl,s=[],i=[],l=(f,p)=>{if(typeof f!="string")return Vt;try{return o(f)}catch(h){return s.push(`${p} side is not valid JSON (${h.message})`),Vt}},a=l(t,"local"),c=l(n,"remote");if(a===Vt)return{text:n,warnings:s,conflicts:i};if(c===Vt)return{text:t,warnings:s,conflicts:i};let m=l(e,"base"),u=ac(m===Vt?void 0:m,a,c,{...r,onConflict:f=>{i.push(f),r.onConflict?.(f)}});return Jn(u,c)?{text:n,warnings:s,conflicts:i}:Jn(u,a)?{text:t,warnings:s,conflicts:i}:{text:Hh(u,n),warnings:s,conflicts:i}}var cc=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Er(e){if(!e)return!1;let{startContainer:t,startOffset:n,endContainer:r,endOffset:o}=e;if(!t||!r||!Number.isInteger(n)||!Number.isInteger(o)||n<0||o<0||n>cc(t)||o>cc(r)||t.getRootNode()!==r.getRootNode())return!1;let s=t.ownerDocument.createRange();return s.setStart(t,n),s.setEnd(r,o),s.startContainer===t&&s.startOffset===n}function cr(e,t,n={}){if(!Er(e))return null;let{startContainer:r,startOffset:o,endContainer:s,endOffset:i}=e;if(r===s&&(r.nodeType===3||r.nodeType===8))return r.nodeValue.slice(o,i);if(r===s&&o===i)return"";let l=new Set;for(let g=r;g;g=g.parentNode)l.add(g);let a=s;for(;!l.has(a);)a=a.parentNode;let c=(g,d)=>{let k=a.ownerDocument.createRange(),S=a.ownerDocument.createRange();return k.setStart(g[0],g[1]),k.collapse(!0),S.setStart(d[0],d[1]),S.collapse(!0),k.compareBoundaryPoints(0,S)},m=(g,d=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(d)],u=[],f;if(t==="plain"){f="";let g=d=>{if(d.nodeType===3||d.nodeType===8){let k=f.length;f+=d.nodeValue,u.push({s:k,e:f.length,a:[d,0],b:[d,d.nodeValue.length],node:d})}else for(let k of d.childNodes)g(k)};g(a)}else{let g=n.blocks;if(!g){g=new Set;let k=S=>{S!==a&&S.nodeType===1&&Yi.has(S.tagName)&&g.add(S);for(let x of S.childNodes)k(x)};k(a)}let d=Qt(Array.from(a.childNodes),{blocks:g,atomize:k=>!!n.atoms?.has(k),ignored:n.ignored});f=d.text;for(let k of d.nodes)u.push({s:k.s,e:k.e,a:[k.node,0],b:[k.node,k.e-k.s],node:k.node});for(let k of d.atoms)u.push({s:k.i,e:k.i+1,a:m(k.el),b:m(k.el,!0)});for(let k=0;k<d.text.length;k++){if(d.text[k]!==Ot)continue;let S=d.marks.find(w=>w.block&&w.to===k+1),x=d.marks.find(w=>w.block&&w.from===k+1);if(S)u.push({s:k,e:k+1,a:[S.el,S.el.childNodes.length],b:m(S.el,!0)});else if(x)u.push({s:k,e:k+1,a:m(x.el),b:[x.el,0]});else return null}}u.sort((g,d)=>g.s-d.s);let p=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let k=u.find(S=>S.node===g[0]);return k?k.s+g[1]:null}let d=0;for(let k of u){if(c(g,k.a)<=0)return k.s;if(c(g,k.b)<0)return null;d=k.e}return d},h=p([r,o]),v=p([s,i]);return h!==null&&v!==null&&h<=v?f.slice(h,v):null}function Tr(e,t){let n=e;for(let r of t.path)if(n=r==="content"?n?.content:n?.childNodes[r],!n)return null;return[n,t.offset]}function uc(e,t){if(!e||!t)return null;let n=Tr(e,t.start),r=Tr(e,t.end);return n&&r?{startContainer:n[0],startOffset:n[1],endContainer:r[0],endOffset:r[1]}:null}var fc=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function dc(e,t,n){if(!t)return;let r=new Map,o=new Map,s=l=>{if(!l)return null;if(o.has(l))return o.get(l);let c=l.local.map(m=>Tr(t.localRoot,{path:m,offset:0})?.[0]).map(m=>m&&n(m)).filter(Boolean).map(m=>({node:m,parent:m.parentNode,previous:m.previousSibling,next:m.nextSibling,fragment:fc(m)}));return o.set(l,c),c},i=l=>{let a=uc(t.localRoot,l);if(!a)return null;let c=n(a.startContainer),m=n(a.endContainer);if(!c||!m)return null;let u={...a,startContainer:c,endContainer:m};return Er(u)?u:null};for(let l of e){let a=l.recovery;if(!a||r.has(a))continue;let c={subject:s(a.subject),span:null,scope:null,touched:new Set};if(a.text){c.span=i(a.text.local.span),c.scope=i(a.text.local.scope);let m=c.span;if(m){let u=m.startContainer.ownerDocument.createRange();u.setStart(m.startContainer,m.startOffset),u.setEnd(m.endContainer,m.endOffset);let f=p=>{if(u.intersectsNode(p)){c.touched.add(p);for(let h of p.childNodes)f(h)}};f(u.commonAncestorContainer)}}if(a.structure){for(let m of[a.structure.localPlacement])m&&(s(m.parent),m.before.forEach(s),m.after.forEach(s));for(let m of a.structure.localOrder||[])s(m)}r.set(a,c)}t.localState={states:r,refs:o}}function hc(e,t,n,r){let o=n.localState?.states.get(e);if(!o)return!1;let s=l=>{let a=l.node;if(!r(a)||a.parentNode!==l.parent)return!1;let c=m=>Array.prototype.indexOf.call(a.parentNode.childNodes,m);return!(l.previous&&r(l.previous)&&l.previous.parentNode===a.parentNode&&c(l.previous)>=c(a)||l.next&&r(l.next)&&l.next.parentNode===a.parentNode&&c(l.next)<=c(a))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!o.subject.length||!o.subject.every(s))return!1;if(e.text){let l=e.text.local,a=c=>c&&r(c.startContainer)&&r(c.endContainer);return a(o.span)&&a(o.scope)&&cr(o.scope,e.text.encoding)===l.text&&cr(o.span,e.text.encoding)===l.text.slice(l.start,l.end)}if(e.attribute){let l=e.attribute,a=o.subject[0].node;return(l.namespaceURI?a.getAttributeNS(l.namespaceURI,l.localName):a.getAttribute(l.qualifiedName))===t.local}let i=e.structure;if(i.localOrder){let l=-1,a=null;for(let c of i.localOrder){let m=n.localState.refs.get(c)?.[0]?.node;if(!m||!r(m)||a&&m.parentNode!==a)return!1;let u=Array.prototype.indexOf.call(m.parentNode.childNodes,m);if(u<=l)return!1;a=m.parentNode,l=u}return!0}return i.localAction==="moved"||o.subject.every(l=>fc(l.node)===l.fragment)}var zh=1,dn=e=>!!e&&e.nodeType===1,Ns=e=>dn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function Or(e,t=null,n=null){let r=new Map,o=new Map,s=m=>{if(!t){t=new WeakMap;let u=[e];for(;u.length;){let f=u.pop();Ns(f)&&(t.set(f.content,f),u.push(f.content));for(let p=f.firstChild;p;p=p.nextSibling)p.nodeType===1&&u.push(p)}}return t.get(m)||null},i=(m,u)=>{let f=o.get(m);if(!f){f=new Map;let p=0;for(let h=m.firstChild;h;h=h.nextSibling)f.set(h,p++);o.set(m,f)}return f.get(u)},l=m=>{if(!m)return null;if(n&&n.has(m))return l(n.get(m));if(m===e)return[];let u=r.get(m);if(u!==void 0)return u;let f=m.parentNode,p=null;if(f&&f.nodeType===11){let h=s(f),v=h?l(h):null;v&&(p=v.concat(["content",i(f,m)]))}else if(f){let h=l(f);h&&(p=h.concat([i(f,m)]))}return r.set(m,p),p};return{root:e,pathOf:l,logicalParent:m=>{let u=m.parentNode;return u&&u.nodeType===11?s(u):u},indexIn:i,containerPath:m=>{if(m.nodeType===11){let f=s(m),p=l(f);return p?p.concat(["content"]):null}let u=l(m);return u&&Ns(m)?u.concat(["content"]):u},ownerOf:s}}var In=e=>Ns(e)?e.content:e;function mc(e){let{L:t,R:n,unitsOf:r,provenance:o,policy:s}=e,i=[];return{note:(m,u)=>{i.push([m,u])},finish:m=>i.length?c(m):null};function c(m){let u={base:Or(e.roots.base),local:Or(e.roots.local),remote:Or(e.roots.remote)},f=Y=>Y==="local"?t:n,p=(Y,y)=>{if(!y)return null;if(Y.map.has(y))return Y.map.get(y);let M=[],P=dn(y)?u.base.logicalParent(y):y.parent;for(;P&&!Y.map.has(P);P=u.base.logicalParent(P))M.push(P);if(!P||!Y.identical.has(P))return null;let H=Y.map.get(P);for(let Q=M.length-1;Q>=0&&H;Q--)H=In(H).childNodes[u.base.indexIn(M[Q].parentNode,M[Q])];return H?dn(y)?In(H).childNodes[u.base.indexIn(y.parentNode,y)]||null:r(H)[r(y.parent).indexOf(y)]||null:null},h=new Map,v=new Map,g=new WeakMap,d=0,k=(Y,y)=>{let M=h.get(Y);M||h.set(Y,M=[]),M.push(y)};(function Y(y){v.set(y,d++);let M=o.get(y);if(M&&!M.pinned){for(let P of[M.base,M.local,M.remote])if(P)if(Array.isArray(P))for(let H of P)k(H,y);else k(P,y)}if(Ns(y)){g.set(y.content,y);for(let P=y.content.firstChild;P;P=P.nextSibling)Y(P)}for(let P=y.firstChild;P;P=P.nextSibling)Y(P)})(m);let S=new Map;u.out=Or(m,g,S);let x={refs:new Map,spans:new Map,anchors:new Map,via:S,outOwners:g,outRoot:m,localRoot:e.roots.local},w=Y=>dn(Y)?[Y]:Y.nodes,T=(Y,y)=>{let M=u[y].logicalParent(Y);if(!M)return null;for(let P of r(M))if(!dn(P)&&P.nodes.includes(Y))return P;return null},N=(Y,y)=>Y==null?null:Array.isArray(Y)?Y.length?T(Y[0],y):null:Y,C=Y=>{let y=new Set,M=[];for(let P of Y)for(let H of h.get(P)||[])y.has(H)||(y.add(H),M.push(H));return M.sort((P,H)=>v.get(P)-v.get(H))},L=new Map,q=Y=>{let y=Y.b||Y.l||Y.r,M=L.get(y);if(M)return M;let P=[];for(let H of[Y.b,Y.l,Y.r])H&&P.push(...w(H));return M=C(P),L.set(y,M),M},V=Y=>({b:Y,l:p(t,Y),r:p(n,Y)}),U=(Y,y)=>{let M=f(y).reverse.get(Y);if(M)return V(M);for(let P of C(w(Y))){let H=o.get(P);if(H&&!H.base&&H.local&&H.remote)return{b:null,l:N(H.local,"local"),r:N(H.remote,"remote")}}return y==="local"?{b:null,l:Y,r:null}:{b:null,l:null,r:Y}},F=new Map,A=Y=>{let y=o.get(Y);if(!y||y.pinned)return null;let M=N(y.base,"base");if(M)return V(M);let P=N(y.local,"local"),H=N(y.remote,"remote");if(P){let Q=t.reverse.get(P);if(Q)return V(Q)}if(H){let Q=n.reverse.get(H);if(Q)return V(Q)}return P||H?{b:null,l:P,r:H}:null},E=Y=>(F.has(Y)||F.set(Y,A(Y)),F.get(Y)),X=(Y,y)=>dn(Y)?u[y].logicalParent(Y):Y.parent,B=new Map,z=new Map,Ce=(Y,y)=>(dn(Y)?[u[y].pathOf(Y)]:Y.nodes.map(M=>u[y].pathOf(M))).filter(Boolean),Me=Y=>{let y=Y.b||Y.l||Y.r,M=Y.b?"base":Y.l?"local":"remote",P=z.get(y);if(P)return P;let H=!dn(y),Q=Ce(y,M)[0],D=`${M[0]}:${JSON.stringify(Q===void 0?null:Q)}${H?":run":""}`,ge=B.get(D);if(ge)return z.set(y,ge),ge;let xe=q(Y);return ge={key:D,nodeType:dn(y)?1:y.kind==="comment"?8:3,base:Y.b?Ce(Y.b,"base"):[],local:Y.l?Ce(Y.l,"local"):[],remote:Y.r?Ce(Y.r,"remote"):[],merged:xe.map(de=>u.out.pathOf(de)).filter(Boolean),live:[]},B.set(D,ge),z.set(y,ge),x.refs.set(ge,xe),ge},Be={base:new Map,local:new Map,remote:new Map},me=new Map,Te=(Y,y)=>{let M=X(Y,y);if(!M||M.nodeType!==1)return null;let P=Be[y].get(M);if(!P){let Q=r(M),D=ge=>Me(y==="base"?V(ge):U(ge,y));P={parent:D(M),refs:Q.map(D),index:new Map(Q.map((ge,xe)=>[ge,xe]))},Be[y].set(M,P)}let H=P.index.get(Y)??-1;return{parent:P.parent,before:P.refs.slice(H+1),after:P.refs.slice(0,Math.max(0,H)).reverse()}},Xe=Y=>{let y=Y.parentNode;if(!y)return null;let M=me.get(y);if(!M){let H=y.nodeType===11?g.get(y):y,Q=H&&H.nodeType===1?E(H):null;if(!Q)return null;let D=[],ge=[],xe=new Map;for(let Oe of y.childNodes){let $=E(Oe),Z=$&&Me($),ke=D.length,we=D.length-1;Z&&Z!==D[we]&&(D.push(Z),we++);let ve={ref:Z,group:we,after:ke};ge.push(ve),xe.set(Oe,ve)}let de=D.length;for(let Oe=ge.length-1;Oe>=0;Oe--){let $=ge[Oe];$.before=de,$.ref&&(de=$.group)}M={parent:Me(Q),refs:D,index:xe},me.set(y,M)}let P=M.index.get(Y);return{parent:M.parent,before:M.refs.slice(P.before),after:M.refs.slice(0,P.after).reverse()}},_e=Y=>dn(Y)?Y.outerHTML:Y.value,O=Y=>dn(Y)?"element":Y.kind==="comment"?"comment":"text",K=(Y,y)=>({path:Y,offset:y}),fe=(Y,y,M)=>{if(!Y)return null;let P=u[M],H=0;if(y){let Q=dn(y)?y:y.nodes[y.nodes.length-1];Q.parentNode&&(H=P.indexIn(Q.parentNode,Q)+1)}return K(P.containerPath(Y),H)},ae=(Y,y)=>{let M=X(Y,"base"),P=M?p(f(y),M):null;if(!dn(P))return null;let H=r(M),Q=null;for(let D=H.indexOf(Y)-1;D>=0&&!Q;D--){let ge=p(f(y),H[D]);ge&&X(ge,y)===P&&(Q=ge)}return fe(P,Q,y)},qe=(Y,y,M,P)=>{let H=u[P],Q=0;for(let D=0;D<Y.nodes.length;D++){let ge=Y.nodes[D],xe=ge.nodeValue.length,de=D===Y.nodes.length-1;if((M==="start"?y<Q+xe:y<=Q+xe)||de)return K(H.pathOf(ge),Math.max(0,Math.min(y-Q,xe)));Q+=xe}return null},ze=(Y,y)=>{let M=u[y],P=Y.firstChild,H=Y.lastChild;return P&&P.nodeType===3&&H.nodeType===3?{start:K(M.pathOf(P),0),end:K(M.pathOf(H),H.nodeValue.length)}:{start:K(M.pathOf(Y),0),end:K(M.pathOf(Y),Y.childNodes.length)}},Ee=(Y,y,M)=>{for(let D of Y.nodes)if(M==="start"?D.s<=y&&y<D.e:D.s<y&&y<=D.e)return{kind:"text",node:D.node,offset:y-D.s};let P=M==="start"?y:y-1,H=()=>{for(let D of Y.nodes)if(D.s===y||D.e===y)return{kind:"text",node:D.node,offset:y-D.s};return null},Q=Y.atomAt.get(P);if(Q)return{kind:M==="start"?"before":"after",node:Q.el};if(Y.text[P]===Ot){let D=Y.marks.find(xe=>xe.block&&xe.to===P+1);if(D)return M==="start"?{kind:"end",node:D.el}:{kind:"after",node:D.el};let ge=Y.marks.find(xe=>xe.block&&xe.from===P+1);if(ge)return M==="start"?{kind:"before",node:ge.el}:{kind:"startOf",node:ge.el}}return H()},ot=(Y,y)=>Ee(Y,y,"end")||Ee(Y,y,"start"),rt=(Y,y)=>{switch(y.kind){case"text":return K(Y.pathOf(y.node),y.offset);case"end":return K(Y.containerPath(y.node),In(y.node).childNodes.length);case"startOf":return K(Y.containerPath(y.node),0);default:{let M=y.node.parentNode;return K(Y.containerPath(M),Y.indexIn(M,y.node)+(y.kind==="after"?1:0))}}},xt=(Y,y,M,P,H)=>{let Q=Ee(Y,y,M);return Q?rt(u[P],Q):H()},nt=(Y,y,M,P)=>{let H=Y.textNodes.map(de=>({s:de.ms,e:de.me,start:{kind:"text",node:de.node,offset:0},end:{kind:"text",node:de.node,offset:de.me-de.ms}}));for(let[de,Oe]of Y.atomOut)H.push({s:de,e:de+1,start:{kind:"before",node:Oe},end:{kind:"after",node:Oe}});for(let[de,Oe]of Y.breakOut)H.push({s:de,e:de+1,start:{kind:"end",node:Oe},end:{kind:"after",node:Oe}});for(let de of H)if(de.start.kind==="text"&&de.s<y&&y<de.e)return{kind:"text",node:de.start.node,offset:y-de.s};if(M!=="empty"){let de=H.find(Oe=>M==="start"?Oe.s===y:Oe.e===y);if(de)return M==="start"?de.start:de.end}let Q=H.find(de=>de.e===y);if(Q)return Q.end;let D=H.find(de=>de.s===y);if(D)return D.start;let ge=null,xe=null;for(let de of H)de.e<=y&&(!ge||de.e>ge.e)&&(ge=de),de.s>=y&&(!xe||de.s<xe.s)&&(xe=de);return ge?ge.end:xe?xe.start:P()},te=(Y,y)=>{if(!y)return null;if(y.kind==="text"){let H=Y.nodes.find(Q=>Q.node===y.node);return H?H.s+Math.min(y.offset,H.e-H.s):null}let M=Y.atoms.find(H=>H.el===y.node);if(M)return y.kind==="after"?M.i+1:M.i;let P=Y.marks.find(H=>H.el===y.node);return P?y.kind==="before"&&P.block&&Y.text[P.from-1]===Ot&&!Y.marks.some(H=>H.block&&H.to===P.from)?P.from-1:y.kind==="startOf"||y.kind==="before"?P.from:y.kind==="end"&&P.block?P.to-1:P.to:null},Ae=(Y,y,M,P)=>{for(let ge of Y.nodes)if(M==="start"?ge.s<=y&&y<ge.e:ge.s<y&&y<=ge.e)return{kind:"text",node:ge.node,offset:y-ge.s};let H=M==="start"?y:y-1;if(!Y.atomAt.has(H)&&Y.text[H]!==Ot){for(let ge of Y.nodes)if(ge.s===y||ge.e===y)return{kind:"text",node:ge.node,offset:y-ge.s}}let Q=Y.atomAt.get(H);if(Q)return{kind:M==="start"?"before":"after",node:Q.el};if(Y.text[H]===Ot){let ge=Y.marks.find(de=>de.block&&de.to===H+1);if(ge)return M==="start"?{kind:"end",node:ge.el}:{kind:"after",node:ge.el};let xe=Y.marks.find(de=>de.block&&de.from===H+1);if(xe)return M==="start"?{kind:"before",node:xe.el}:{kind:"startOf",node:xe.el}}let D=Y.marks.find(ge=>ge.block&&ge.from===y);return D?{kind:"startOf",node:D.el}:P?{kind:M==="start"?"startOf":"end",node:P}:null},je=Y=>{if(!Y)return null;if(Y.kind==="wholeStart"||Y.kind==="wholeEnd"){let y=Fe(Y.node);return Y.kind==="wholeStart"?y.start:y.end}return rt(u.out,Y)},Fe=Y=>{let y=Y.firstChild,M=Y.lastChild;return y&&y.nodeType===3&&M.nodeType===3?{start:K(u.out.pathOf(y),0),end:K(u.out.pathOf(M),M.nodeValue.length)}:{start:K(u.out.pathOf(Y),0),end:K(u.out.pathOf(Y),Y.childNodes.length)}},He=Y=>{let y=X(Y,"base"),M=y?q(V(y))[0]:null;if(!M)return null;let P=In(M),H=r(y);for(let Q=H.indexOf(Y)-1;Q>=0;Q--){let D=q(V(H[Q])).filter(ge=>ge.parentNode===P);if(D.length)return{kind:"after",node:D[D.length-1]}}return{kind:"startOf",node:M}},et=(Y,y,M,P,H,Q)=>({text:Y,start:y,end:M,fragment:P,span:H,scope:Q}),bt=(Y,y,M,P,H)=>et(Y,y,M,Y.slice(y,M),P,H),Ft=(Y,y,M,P,H)=>(x.spans.set(Y,{start:y,end:M,scopeStart:P,scopeEnd:H}),Y),yt=new Map,It=new Map,en=(Y,y,M)=>{let P=`text:${Y.key}:${y}:${M}`,H=It.get(P)||0;return It.set(P,H+1),`${P}:${H}`},Ge=(Y,y)=>{let M,P,H,Q="plain",D,ge,xe,de,Oe,$=(we,ve,ne,se,W)=>{if(!we){let ce=ae(W,se);return bt("",0,0,{start:ce,end:ce},{start:ce,end:ce})}return bt(we.value,ve,ne,{start:qe(we,ve,ve===ne?"end":"start",se),end:qe(we,ne,"end",se)},{start:qe(we,0,"start",se),end:qe(we,we.value.length,"end",se)})};if(y.site==="run"){let{bRun:we,lRun:ve,rRun:ne,node:se,c:W}=y;M=V(we),P=W.bs,H=W.be,D=$(we,W.bs,W.be,"base",we),ge=$(ve,W.ls,W.le,"local",we),xe=$(ne,W.rs,W.re,"remote",we);let ce=se?se.nodeValue:"",Ne=Pe=>se?{kind:"text",node:se,offset:Pe}:He(we);de=Ft(bt(ce,W.ms,W.me,{start:je(Ne(W.ms)),end:je(Ne(W.me))},{start:je(Ne(0)),end:je(Ne(ce.length))}),Ne(W.ms),Ne(W.me),Ne(0),Ne(ce.length)),Oe=se||(He(we)||{}).node||null}else if(y.site==="whole"){let we=y.el,ve=o.get(we);M=V(ve.base),P=0,H=Y.base.length;let ne=(W,ce,Ne)=>{let Pe=ze(ce,Ne);return bt(W,0,W.length,Pe,Pe)};D=ne(Y.base,ve.base,"base"),ge=ne(Y.local,ve.local,"local"),xe=ne(Y.remote,ve.remote,"remote");let se=Fe(we);de=Ft(bt(Y.resolved,0,Y.resolved.length,se,se),{kind:"wholeStart",node:we},{kind:"wholeEnd",node:we},{kind:"wholeStart",node:we},{kind:"wholeEnd",node:we}),Oe=we}else if(y.site==="comment"){let{bRun:we,lRun:ve,rRun:ne,node:se}=y;M=V(we),P=0,H=Y.base.length;let W=(De,Se)=>{if(!De){let it=ae(we,Se);return bt("",0,0,{start:it,end:it},{start:it,end:it})}let tt=De.nodes[0],lt={start:K(u[Se].pathOf(tt),0),end:K(u[Se].pathOf(tt),De.value.length)};return bt(De.value,0,De.value.length,lt,lt)};D=W(we,"base"),ge=W(ve,"local"),xe=W(ne,"remote");let ce=Y.resolved,Ne=De=>se?{kind:"text",node:se,offset:De}:He(we),Pe={start:je(Ne(0)),end:je(Ne(ce.length))};de=Ft(bt(ce,0,ce.length,Pe,Pe),Ne(0),Ne(ce.length),Ne(0),Ne(ce.length)),Oe=se||(He(we)||{}).node||null}else{let{fb:we,fl:ve,fr:ne,scope:se}=y,W=y.merged;Q="html",M=se.base?V(se.base):U(se.local,"local"),P=Y.bs,H=Y.be;let ce=he=>{let le=se[he];for(let ee=se.at-1;ee>=0;ee--){let ie=se.units[ee],Re=he==="base"?ie:p(f(he),ie);if(Re&&X(Re,he)===le)return Re}return null},Ne=he=>()=>fe(se[he],ce(he),he),Pe=(he,le,ee,ie,Re)=>{let We=Rt=>Rt?rt(u[Re],Rt):Ne(Re)(),Je=le===ee?ot(he,le):Ee(he,le,"start"),at=le===ee?ot(he,le):Ee(he,ee,"end"),dt=We(Je),ht={start:dt,end:le===ee?dt:We(at)},ft=y.full?y.full(Re):null;if(!ft)return et(he.text,le,ee,ie,ht,{start:We(Ee(he,0,"start")),end:We(Ee(he,he.text.length,"end"))});let Mt=Je?te(ft,Je):null,_t=at?te(ft,at):null,Pt=Mt===null?0:Mt,Ye=Math.max(Pt,_t===null?ft.text.length:_t),St=We(Ee(ft,0,"start"));return et(ft.text,Pt,Ye,Kr(ft,Pt,Ye),ht,{start:St,end:ft.text.length?We(Ee(ft,ft.text.length,"end")):St})};D=y.synthetic?null:Pe(we,Y.bs,Y.be,Y.base,"base"),ge=Pe(ve,Y.lss,Y.lse,Y.local,"local"),xe=Pe(ne,Y.rss,Y.rse,Y.remote,"remote");let[De,Se]=Y.range||[0,0],tt=W.out,lt=()=>{let he=In(W.node);for(let le=se.at-1;le>=0;le--){let ee=q(V(se.units[le])).filter(ie=>ie.parentNode===he);if(ee.length)return{kind:"after",node:ee[ee.length-1]}}for(let le=se.at;le<se.units.length;le++){let ee=q(V(se.units[le])).filter(ie=>ie.parentNode===he);if(ee.length)return{kind:"before",node:ee[0]}}return{kind:"startOf",node:W.node}};if(tt.via)for(let[he,le]of tt.via)S.set(he,le);let it=nt(W,De,De===Se?"empty":"start",lt),Ht=De===Se?it:nt(W,Se,"end",lt),Lt=tt.text.length?Ae(tt,0,"start",W.node):lt(),Zt=tt.text.length?Ae(tt,tt.text.length,"end",W.node):Lt,Bt=te(tt,it),Wt=te(tt,Ht),R=Bt===null?0:Bt,J=Math.max(R,Wt===null?tt.text.length:Wt);de=Ft(et(tt.text,R,J,Kr(tt,R,J),{start:je(it),end:je(Ht)},{start:je(Lt),end:je(Zt)}),it,Ht,Lt,Zt);let ue=x.spans.get(de);if(ue.flat=tt,!tt.text.length){let he=je(Lt),le=Tr(m,he),ee=le[0],ie=le[1];ue.empty={parent:ee.nodeType===11?g.get(ee):ee,previous:ee.childNodes[ie-1]||null,next:ee.childNodes[ie]||null}}Oe=it?it.node:W.node}let Z=Me(M),ke=(y.site==="whole"||y.site==="comment"||(y.policy||s)!=="both")&&Y.resolved!==Y.local;return{key:y.site==="comment"&&yt.get(M.b||M.l||M.r)||en(Z,P,H),subject:Z,localLost:ke,anchor:Oe,text:{encoding:Q,base:D,local:ge,remote:xe,merged:de,liveSpan:null,liveScope:null}}},Ct=(Y,y)=>{let M=E(y.el),P=Me(M),H=y.sample;return{key:`attr:${P.key}:${H.namespaceURI||""}:${H.localName}`,subject:P,localLost:Y.resolved!==Y.local,anchor:y.el,attribute:{namespaceURI:H.namespaceURI||null,localName:H.localName,qualifiedName:H.name}}},Tt=(Y,y)=>{let M=Y.detail,P=y.unit||V(y.subject),H=Me(P),Q=x.refs.get(H),D=P.l?Te(P.l,"local"):null,ge=P.r?Te(P.r,"remote"):null,xe=Q.length?Xe(Q[0]):null,de,Oe,$,Z=null,ke=null,we=y.deleted;switch(M){case"both-reordered":{de=Oe="reordered";let ve=new Set(y.rKept),ne=y.lKept.filter(Pe=>ve.has(Pe)&&q(V(Pe)).length),se=Pe=>v.get(q(V(Pe))[0]);Z=ne.map(Pe=>Me(V(Pe))),ke=ne.slice().sort((Pe,De)=>se(Pe)-se(De)).map(Pe=>Me(V(Pe)));let W=Pe=>!dn(Pe)&&Pe.kind!=="comment"&&Pe.nodes.every(De=>!/[^\t\n\f\r ]/.test(De.data)),ce=ne.filter(Pe=>!W(Pe)),Ne=ce.slice().sort((Pe,De)=>se(Pe)-se(De));$=ce.some((Pe,De)=>Pe!==Ne[De]);break}case"both-moved":de=Oe="moved",$=!D||!Q.some(ve=>{let ne=ve===Q[0]?xe:Xe(ve);return ne&&ne.parent===D.parent});break;case"edit-beats-delete":de=we==="local"?"deleted":"edited",Oe=we==="remote"?"deleted":"edited",$=we==="local";break;case"move-beats-delete":de=we==="local"?"deleted":"moved",Oe=we==="remote"?"deleted":"moved",$=we==="local";break;case"remote-wins":de="edited",Oe="edited",$=!0;break;default:de=Oe="inserted",$=y.localLost}return{key:`structure:${H.key}:${M}`,subject:H,localLost:$,anchor:Q[0]||null,structure:{localAction:de,remoteAction:Oe,localPlacement:D,remotePlacement:ge,mergedPlacement:xe,localOrder:Z,mergedOrder:ke,localFragment:M==="both-reordered"||!P.l?null:_e(P.l),fragmentKind:O(P.b||P.l||P.r)}}};for(let[Y,y]of i){if(Y.kind!=="structure")continue;let M=y.unit||V(y.subject),P=M.b||M.l||M.r;!dn(P)&&P.kind==="comment"&&yt.set(P,`structure:${Me(M).key}:${Y.detail}`)}let Jt=new Map;for(let[Y,y]of i){if(Y.kind==="structure"){let Q=Me(y.unit||V(y.subject)),D=`structure:${Q.key}:${Y.detail}`,ge=Jt.get(D);if(ge&&ge.structure){Y.recovery=ge;let xe=x.refs.get(Q);Y.el==null&&xe.length&&(Y.el=dn(xe[0])?xe[0]:u.out.logicalParent(xe[0]));continue}}let M=Y.kind==="text"?Ge(Y,y):Y.kind==="attr"?Ct(Y,y):Tt(Y,y),P=Jt.get(M.key);P||(P={version:zh,key:M.key,localLost:M.localLost,subject:M.subject,applied:!1,unavailable:null},Jt.set(M.key,P),x.anchors.set(P,M.anchor)),M.text&&(P.text=M.text),M.attribute&&(P.attribute=M.attribute),M.structure&&(P.structure=M.structure),M.text&&(P.localLost=M.localLost),Y.recovery=P;let H=x.refs.get(M.subject);Y.kind==="structure"&&Y.el==null&&H.length&&(Y.el=dn(H[0])?H[0]:u.out.logicalParent(H[0])),Y.kind==="text"&&Y.node==null&&H.length&&M.subject.nodeType===8&&(Y.node=H[0])}return x}}function pc(e,t,n){if(!t)return;let{lookup:r,vetoed:o,vetoedAttrs:s,liveAttr:i}=n,l=n.ignored||(()=>!1),a=Or(n.liveRoot),c=A=>!!A&&a.containerPath(A)!==null,m=A=>{let E=A.parentNode;return E&&E.nodeType===11?t.outOwners.get(E)||null:E},u=A=>{for(let E=A;E;E=m(E))if(t.via.has(E)&&(E=t.via.get(E)),o.has(E)||n.vetoedLive?.has(d(E)))return!0;return!1},f=A=>Array.from(In(A).children).filter(E=>!l(E)),p=(A,E)=>f(A)[f(E.parentNode).indexOf(E)],h=(A,E)=>{let X=null,B=null,z=0;for(let me=E.previousSibling;me;me=me.previousSibling){if(me.nodeType===1&&!l(me)){X=me;break}me.nodeType===3&&(z+=me.nodeValue.length)}for(let me=E.nextSibling;me&&!B;me=me.nextSibling)me.nodeType===1&&!l(me)&&(B=me);let Ce=X?p(A,X):null,Me=B?p(A,B):null;if(X&&!Ce||B&&!Me)return null;let Be=[];for(let me=Ce?Ce.nextSibling:In(A).firstChild;me&&me!==Me;me=me.nextSibling)me.nodeType===3&&Be.push(me);return Be.length?{nodes:Be,lead:z}:null},v=A=>{let E=[],X=A;for(;X&&!t.via.has(X);X=X.parentNode)E.push(X);if(!X||!E.length)return null;let B=d(t.via.get(X));for(let Me=E.length-1;Me>0&&B;Me--)B=p(B,E[Me]);if(!B)return null;let z=E[0];if(z.nodeType===3)return h(B,z);let Ce=z.nodeType===1?p(B,z):null;return Ce?{nodes:[Ce],lead:0}:null},g=A=>{let E=r(A),X=E?{nodes:Array.isArray(E)?E:[E],lead:0}:t.via.size?v(A):null;if(!X)return null;let B=X.nodes.filter(c);return B.length?{nodes:B,lead:X.lead}:null},d=A=>{let E=g(A);return E?E.nodes[0]:null},k=A=>{if(!A)return null;if(A.kind==="text"){let z=g(A.node);if(!z)return null;let Ce=z.nodes,Me=A.offset+z.lead,Be=0;for(let me=0;me<Ce.length;me++){let Te=Ce[me].nodeValue.length;if(Me<=Be+Te||me===Ce.length-1)return Me>=Be&&Me<=Be+Te?[Ce[me],Me-Be]:null;Be+=Te}return null}let E=d(A.node);if(!E)return null;if(A.kind==="end")return[In(E),In(E).childNodes.length];if(A.kind==="startOf")return[In(E),0];if(A.kind==="wholeStart")return E.firstChild?[E.firstChild,0]:[E,0];if(A.kind==="wholeEnd")return E.lastChild?[E.lastChild,E.lastChild.nodeValue.length]:[E,E.childNodes.length];let X=E.parentNode;if(!X)return null;let B=Array.prototype.indexOf.call(X.childNodes,E);return[X,A.kind==="after"?B+1:B]},S=A=>({blocks:new Set((A.flat?.marks||[]).filter(E=>E.block).map(E=>d(E.el)).filter(Boolean)),atoms:new Set((A.flat?.atoms||[]).map(E=>d(E.el)).filter(Boolean)),ignored:l}),x=(A,E,X,B)=>{if(!A||!E||!Er(A)||!Er(E))return!1;for(let Me of[A,E])if(!c(Me.startContainer)||!c(Me.endContainer))return!1;let z=X.merged;if(z.start===z.end&&(A.startContainer!==A.endContainer||A.startOffset!==A.endOffset))return!1;let Ce=S(B);return cr(E,X.encoding,Ce)===z.text&&cr(A,X.encoding,Ce)===z.text.slice(z.start,z.end)},w=new Map,T=A=>{let E=A.parentNode;return E?(w.has(E)||w.set(E,new Map(Array.from(E.childNodes,(X,B)=>[X,B]))),w.get(E).get(A)):-1},N=(A,E)=>{if(!E)return!1;let X=a.logicalParent(A);if(!E.parent.live.includes(X))return!1;let B=T(A);for(let[z,Ce]of[["before",1],["after",-1]]){let Me=B;for(let Be of E[z]){if(Be.live.includes(A))continue;let me=Be.live.filter(Xe=>Xe!==A&&Xe.parentNode===A.parentNode);if(!me.length)continue;let Te=Ce===1?Math.min(...me.map(T)):Math.max(...me.map(T));if(Ce*(Te-Me)<=0)return!1;Me=Te}}return!0},C=A=>{let E=A.structure;if(E.mergedOrder){let X=new Set(A.subject.live.map(In)),B=null,z=-1;for(let Ce of E.mergedOrder){let Me=Ce.live.find(Be=>X.has(Be.parentNode));if(!Me||B&&Me.parentNode!==B||T(Me)<=z)return!1;B=Me.parentNode,z=T(Me)}return A.subject.live.length>0}return A.subject.live.some(X=>N(X,E.mergedPlacement))},L=(A,E)=>{let X=k(A),B=k(E);return X&&B?{startContainer:X[0],startOffset:X[1],endContainer:B[0],endOffset:B[1]}:null},q=new Set,V=A=>{if(!A||q.has(A))return;q.add(A);let E=[];for(let X of t.refs.get(A)||[]){let B=g(X);if(B)for(let z of B.nodes)E.includes(z)||E.push(z)}A.live=E},U=A=>{A&&(V(A.parent),A.before.forEach(V),A.after.forEach(V))},F=new Set;for(let A of e){let E=A.recovery;if(!E||F.has(E))continue;F.add(E),V(E.subject),E.structure&&(U(E.structure.localPlacement),U(E.structure.remotePlacement),U(E.structure.mergedPlacement),(E.structure.localOrder||[]).forEach(V),(E.structure.mergedOrder||[]).forEach(V));let X=t.anchors.get(E),B=X?d(X):null,z=!!B;if(E.text){let K=t.spans.get(E.text.merged),fe=K?L(K.start,K.end):null,ae=K?L(K.scopeStart,K.scopeEnd):null;if(K?.empty){let qe=K.empty,ze=qe.previous?{kind:"after",node:qe.previous}:{kind:"startOf",node:qe.parent},Ee=qe.next?{kind:"before",node:qe.next}:{kind:"end",node:qe.parent},ot=L(ze,Ee);!ot||ot.startContainer!==ot.endContainer||ot.startOffset!==ot.endOffset?fe=null:fe=ae=ot}x(fe,ae,E.text,K)||(fe=ae=null),E.text.liveSpan=fe,E.text.liveScope=fe?ae:null,fe||(z=!1)}E.structure&&z&&(z=C(E)),E.attribute&&z&&(z=i(B,E.attribute,A.resolved));let Ce=K=>K?.tagName==="TEXTAREA"?K:K?.parentNode?.tagName==="TEXTAREA"?K.parentNode:null,Me=(!!E.attribute||!!E.text&&!!(Ce(B)||Ce(X)))&&!!s&&[X,B,Ce(B),Ce(X)].some(K=>s.get(K)?.has(E.attribute?E.attribute.qualifiedName:"value")),Be=t.localState?.states.get(E),me=!!E.text&&[...n.removedVetoes||[]].some(K=>Be?.touched.has(K)),Te=E.structure?.localAction==="inserted"&&[...o].some(K=>K===X||X?.contains(K)),Xe=X&&u(X)||Me||me||Te,_e=Xe&&hc(E,A,t,c);_e&&(me||Te&&E.localLost)&&(z=!1);let O=!z&&_e&&Xe;E.applied=z,E.unavailable=z?null:O?"hook-veto":"missing-output",O&&(E.localLost=!1),!z&&E.text&&(E.text.liveSpan=E.text.liveScope=null)}}function Cs(e,t,n){let r=Or(t),o=Or(n),s=u=>!!u&&o.containerPath(u)!==null,i=u=>{if(u===t)return n;let f=r.pathOf(u);if(f&&t!==n){let p=Tr(n,{path:f,offset:0});if(p&&p[0].nodeType===u.nodeType)return p[0]}return u},l=new Set,a=u=>{!u||l.has(u)||(l.add(u),u.live=u.live.map(i).filter(s))},c=u=>{u&&(u.startContainer=i(u.startContainer),u.endContainer=i(u.endContainer))},m=new Set;for(let u of e){u.node===t&&n.tagName==="SCRIPT"&&(u.node=n),u.el===t&&u.kind==="structure"&&(u.el=n);let f=u.recovery;if(!f||m.has(f))continue;if(m.add(f),a(f.subject),f.text){c(f.text.liveSpan),c(f.text.liveScope);let h=f.text.liveSpan,v=f.text.liveScope,g=f.text.merged,d=k=>!!k&&Er(k)&&s(k.startContainer)&&s(k.endContainer);(!d(h)||!d(v)||cr(v,f.text.encoding)!==g.text||cr(h,f.text.encoding)!==g.text.slice(g.start,g.end))&&(f.text.liveSpan=null,f.text.liveScope=null,f.applied=!1,f.unavailable="missing-output")}let p=f.structure;if(p){for(let h of[p.localPlacement,p.remotePlacement,p.mergedPlacement])h&&(a(h.parent),h.before.forEach(a),h.after.forEach(a));(p.localOrder||[]).forEach(a),(p.mergedOrder||[]).forEach(a),f.subject.live.length||(f.applied=!1,f.unavailable="missing-output")}}}var Zr=e=>e?.nodeType===1,Bo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function Vh({provenance:e,parentOf:t,twins:n,baseOf:r,build:o,ignored:s,remoteWins:i,discarded:l}){let a=new Map,c=new WeakMap;function m(p,h,v,g=!1){if(!Zr(p)||!Zr(v))return null;let d=a.get(p);if(d)(g||!d.selected&&h==="remote")&&(d.parent=t(v),d.port=v,d.sourceSide=h,d.selected=g);else{let k=c.get(p)||null;d={owner:p,parent:t(v),port:v,sourceSide:h,originalParent:t(p),originalPort:p,selected:g,state:k?"built":"planned",output:k,disposition:null},a.set(p,d)}return d}function u(p,h){if(!Zr(p)||!Zr(h))return;c.has(p)||c.set(p,h);let v=a.get(p);v&&v.state!=="attached"&&!v.output&&(v.output=h,v.state="built")}function f(p){if(!a.size)return;let h=new Map,v=new WeakMap,g=new WeakMap,d=new WeakSet,k=new Set,S=(U,F)=>{if(!U)return;if(Array.isArray(U)){for(let E of U)S(E,F);return}let A=h.get(U);A||h.set(U,A=[]),A.push(F)},x=(U,F)=>{if(!U)return;let A=[U];for(;A.length;){let E=A.pop();S(E,F);for(let X of Bo(E).childNodes)A.push(X)}};function w(U,F=null,A=!1){if(d.has(U))return;d.add(U),v.set(U,F);let E=e.get(U),X=A||!!(E&&i(E.remote||E.base));g.set(U,X);let B={node:U,kind:"node",authority:X};if(E?.pinned)x(E.local,{...B,kind:"ignored"});else if(E?.unchanged)for(let z of[E.base,E.local,E.remote])x(z,{...B,kind:"unchanged"});else if(E){for(let z of[E.base,E.local,E.remote])S(z,B);if(Zr(E.local))for(let z of Bo(E.local).children)s(z)&&x(z,{...B,kind:"ignored"})}for(let z of Bo(U).childNodes)w(z,U,X)}let T=U=>{if(U.output&&d.has(U.output))return U.state="attached",U.disposition="node",!0;let{local:F,remote:A}=n(U.owner);for(let E of[U.owner,F,A]){let X=h.get(E);if(X?.length){let B=X.find(z=>z.kind==="node")||X[0];return U.output=B.node,U.state="attached",U.disposition=B.kind,!0}}return!1},N=(U,F)=>(h.get(U)||[]).find(E=>E.kind==="node"&&Zr(E.node)&&(!E.authority||F.sourceSide==="remote"))?.node,C=(U,F,A)=>{let E=h.get(U)||[],X=A?[...E].reverse():E;for(let B of X){if(B.kind!=="node")continue;let z=B.node;for(;z&&v.get(z)!==F;)z=v.get(z);if(z)return z}return null},L=(U,F,A)=>{let E=Bo(F);for(let X=A?.previousSibling;X;X=X.previousSibling){let B=C(X,F,!0);if(B){E.insertBefore(U,B.nextSibling);return}}for(let X=A?.nextSibling;X;X=X.nextSibling){let B=C(X,F,!1);if(B){E.insertBefore(U,B);return}}E.appendChild(U)};function q(U,F,A){let E=F==="base"?U:r(U,F),X=a.get(E);X&&X!==A&&V(X)}function V(U){if(U.state==="attached"||U.disposition==="remote-wins"||k.has(U)||T(U))return;k.add(U);let{local:F,remote:A}=n(U.owner);if(i(A||U.owner)){if(!A){U.disposition="remote-wins",l(U.owner,F),k.delete(U);return}U.parent=t(A),U.port=A,U.sourceSide="remote"}if(q(U.parent,U.sourceSide,U),T(U)){k.delete(U);return}let E=N(U.parent,U),X=U.port;if(!E){if(q(U.originalParent,"base",U),T(U)){k.delete(U);return}let z=U.originalParent;for(X=U.originalPort;z&&!E;)E=N(z,U),E||(X=z,z=t(z))}if(!E)throw new Error("A planned move has no allowed surviving parent");let B=U.output||o(U.owner);U.output=B,U.state="built",L(B,E,X),w(B,E,g.get(E)||!1),T(U),k.delete(U)}w(p);for(let U of a.values())V(U)}return{planned:a,has:p=>a.has(p),plan:m,produced:u,drain:f}}function Qr(e,t,n,r,o,s,i,l,a,c,m,u,f){let p=null;return Vh({provenance:e,parentOf:g=>{if(!g)return null;let d=t(g);if(d||g.parentNode?.nodeType!==11)return d;if(!p){p=new WeakMap;let k=[u,f];for(;k.length;){let S=k.pop(),x=Bo(S);x!==S&&p.set(x,S);for(let w of x.children)k.push(w)}}return p.get(g.parentNode)||null},twins:g=>({local:o(n,g),remote:o(r,g)}),baseOf:(g,d)=>g&&(d==="local"?n:r).reverse.get(g)||null,build:g=>s(g,o(n,g),o(r,g),!1),ignored:i,remoteWins:l,discarded:(g,d)=>{d&&m(g,d,n)&&!a.some(k=>k.detail==="remote-wins"&&k.base===g)&&c({kind:"structure",el:null,detail:"remote-wins",base:g,local:d,remote:null},{subject:g})}})}function Wh({parent:e,base:t,views:n,eligible:r,ignored:o,remoteWins:s,budget:i=Gt(2e4*32),maxUnits:l=256,maxCharacters:a=2e4}){let c=(d,k=null)=>({status:d,reason:k,parent:e,records:[]});if(n.some(({V:d})=>d.asBase)||o(e)||s(e)||n.some(({V:d})=>!d.el||o(d.el)||s(d.el)))return c("none");let m=t.length+n[0].V.units.length+n[1].V.units.length;if(m>l)return c("fallback","unit-limit");let u=Symbol(),f=d=>{if(d>i.remaining)throw u;i.remaining-=d,i.crossParentSteps=(i.crossParentSteps||0)+d},p=new Map,h=0,v=d=>{if(f(1),p.has(d))return p.get(d);let k=d.nodeType===1?d.childNodes:d.nodes;f(k.length*4+1);let S=d.nodeType===1?Array.from(k):k,x=0;for(let N=0;N<S.length;N++){let C=S[N];if(C.nodeType!==3||N&&S[N-1].nextSibling!==C)return p.set(d,null),null;x+=C.data.length}if(x>a-h)throw u;f(x*8+1),h+=x;let w=Qt(S);if(w.text.includes(Ot))return p.set(d,null),null;let T={unit:d,nodes:S,flat:w};return p.set(d,T),T},g=[];try{f(m*8+1);for(let d=0;d<2;d++){let k=n[d].V,S=n[1-d].V,x=[],w=new Map;for(let T=0;T<t.length;T++){f(1);let N=t[T];if(N.kind!=="text"||k.twin(N))continue;let C=S.twin(N);if(!C||C.kind!=="text"||!S.here(C))continue;let L=v(N),q=v(C);if(!L||!q||!/\S/.test(L.flat.text))continue;f(L.flat.text.length*2+1);let V=L.flat.text;w.set(V,(w.get(V)||0)+1),x.push({source:N,opposite:C,sourceModel:L,oppositeModel:q,index:T})}for(let T of x){let{source:N,opposite:C,sourceModel:L,oppositeModel:q,index:V}=T,U=[];for(let K of[-1,1]){f(1);let fe=t[V+K];if(!fe||fe.nodeType!==1||!r(fe)||o(fe)||s(fe))continue;let ae=L.nodes[0],qe=L.nodes.at(-1);if(K===-1?ae?.previousSibling!==fe:qe?.nextSibling!==fe)continue;let ze=k.twin(fe),Ee=S.twin(fe);if(!ze||!Ee||!k.here(ze)||S.here(Ee)||k.baseOf(ze)!==fe||S.baseOf(Ee)!==fe||!r(ze)||!r(Ee)||o(ze)||o(Ee)||s(ze)||s(Ee)||ze.tagName!==fe.tagName||Ee.tagName!==fe.tagName||ze.namespaceURI!==fe.namespaceURI||Ee.namespaceURI!==fe.namespaceURI)continue;let ot=v(fe),rt=v(ze),xt=v(Ee);if(!ot||!rt||!xt||!/\S/.test(ot.flat.text))continue;let nt=ot.flat.text,te=L.flat.text,Ae=rt.flat.text;if(f((nt.length+te.length+Ae.length)*3+1),Ae.length!==nt.length+te.length)continue;let je=K===-1;(je?!Ae.startsWith(nt)||!Ae.endsWith(te):!Ae.startsWith(te)||!Ae.endsWith(nt))||U.push({owner:fe,target:ze,moved:Ee,ownerBase:ot,joined:rt,ownerOther:xt,targetFrom:je?nt.length:0,retainedFrom:je?0:te.length})}if(!U.length)continue;if(U.length!==1||w.get(L.flat.text)!==1)return c("fallback","ambiguous-origin");let F=U[0],{owner:A,target:E,moved:X,ownerBase:B,joined:z,ownerOther:Ce,targetFrom:Me,retainedFrom:Be}=F;if(f(g.length+1),g.some(K=>K.owner===A))return c("fallback","ambiguous-owner");let me={source:N,target:E,from:0,to:L.flat.text.length,targetFrom:Me},Te=Hn({base:L.flat,side:z.flat,retained:[],transfers:[{from:me.from,to:me.to,target:Me,destination:A}],budget:i});if(Te.status!=="ready"||Te.covers(me.from,me.to)!==!0)return c("fallback",Te.reason||"work-limit");let Xe=[{unit:N,model:L,from:0,to:L.flat.text.length},null,null];Xe[d+1]={unit:E,model:z,from:Me,to:Me+L.flat.text.length},Xe[2-d]={unit:C,model:q,from:0,to:q.flat.text.length};let _e=[B,null,null];_e[d+1]=z,_e[2-d]=Ce;let O=[A,null,null];O[d+1]=E,O[2-d]=X,g.push({side:d,parent:e,source:N,target:E,owner:A,owners:O,ownerModels:_e,native:Xe,models:p,runs:[me],proof:Te,retained:[{source:A,target:E,from:0,to:B.flat.text.length,targetFrom:Be}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:c("none")}catch(d){if(d!==u)throw d;return c("fallback","work-limit")}}function gc({describe:e,parentOf:t,...n}){let r=new WeakMap,o=new WeakMap,s=n.budget||Gt(2e4*32),i=l=>{if(!l)return null;if(r.has(l))return r.get(l);r.set(l,{status:"planning",parent:l,records:[]});let a=e(l),c=a?Wh({...n,...a,parent:l,budget:s}):{status:"none",reason:null,parent:l,records:[]};if(r.set(l,c),c.status==="ready")for(let m of c.records)o.set(m.owner,[m]);return c};return{get:i,forOwner(l){return i(t(l))?.status==="ready"&&o.get(l)||null}}}function Kh(e,t){if(e.side!==0)return null;let n=e.native[0].model,r=e.ownerModels[0],o=e.native[1].from!==0,s=(S,x)=>o?[...S.nodes,...x.nodes]:[...x.nodes,...S.nodes],i=e.ownerModels.reduce((S,x)=>S+x.flat.text.length,0)+n.flat.text.length+e.native[2].model.flat.text.length;if(i*8>t.remaining)return null;t.remaining-=i*8;let l={base:s(r,n),local:e.ownerModels[1].nodes,remote:s(e.ownerModels[2],e.native[2].model)},a=Qt(l.base),c=e.ownerModels[1].flat,m=Qt(l.remote),u=o?r.flat.text.length:0,f=o?0:n.flat.text.length,p=Hn({base:a,side:c,retained:e.retained.map(S=>({from:f+S.from,to:f+S.to,target:S.targetFrom})),transfers:e.runs.map(S=>({from:u+S.from,to:u+S.to,target:S.targetFrom,destination:e.owner})),budget:t});if(p.status!=="ready"||p.covers(0,a.text.length)!==!0)return null;let h=e.ownerModels[2].flat,v=e.native[2].model.flat,g=[];for(let[S,x,w,T]of[[r.flat,h,f,o?0:v.text.length],[n.flat,v,u,o?h.text.length:0]]){let N=Xi(S,S,x).remoteMap.bTo,C=-1;for(let L=0;L<S.text.length;L++){if(N[L]<0){C=-1;continue}let q=g.at(-1);C>=0&&q.to===w+L&&q.target+q.to-q.from===T+N[L]?q.to++:(g.push({from:w+L,to:w+L+1,target:T+N[L]}),C=L)}}let d=Hn({base:a,side:m,retained:g,transfers:[],budget:t});if(d.status!=="ready")return null;let k=Xi(a,c,m,{},{local:p,remote:d});return k.localEdits.hunks.length?null:(k.localMap=p,k.remoteMap=d,{nodes:l,prepared:k})}function bc({L:e,R:t,twinIn:n,unitsOf:r,view:o,parentOf:s,ignored:i,remoteWins:l,eligible:a,build:c,out:m,policy:u,provenance:f,textMappers:p,segments:h,conflicts:v,conflict:g,decisions:d}){let k=Gt(2e4*32),S=U=>{let F=0;for(let A=U;A;A=s(A))if(++F>64||A.nodeType===1&&(i(A)||l(A)))return!1;return!0},x=gc({parentOf:s,eligible:a,ignored:i,remoteWins:l,budget:k,describe(U){let F=n(e,U),A=n(t,U);return!F||!A||!S(U)||!S(F)||!S(A)?null:{base:r(U),views:[{A:e,V:o(e,F,U,!1)},{A:t,V:o(t,A,U,!1)}]}}}),w=new WeakSet,T=new WeakMap,N=new WeakSet,C=[];function L(U){if(!U||w.has(U))return;w.add(U);let F=x.get(U);if(F?.status==="ready")for(let A of F.records){if((U.tagName==="TEMPLATE"&&U.content?U.content:U).childNodes.length!==A.native[0].model.nodes.length+1||!A.owners.every(S))continue;let X=Kh(A,k);if(!X)continue;let B={record:A,payload:X,state:"planned",output:null,result:null};T.set(A.owner,B),N.add(A.source),N.add(A.native[2].unit),C.push(B)}}function q(U,F){let A=T.get(U);if(!A)return!1;if(!A.result){if(A.result=Ss({...A.payload.nodes,prepared:A.payload.prepared,out:m,policy:u,provenance:f,textMappers:p,conflicts:v,conflict:g,decisions:d,node:F}),A.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");h.push(...A.result.segments),A.decision={kind:"text",node:F,source:"local"},d.push(A.decision)}return A.decision.node=F,F.replaceChildren(...A.result.nodes),A.output=F,A.state="built",!0}function V(U){if(!C.length)return;let F=new WeakSet,A=new WeakMap,E=new WeakMap,X=new WeakMap,B=Te=>Te.tagName==="TEMPLATE"&&Te.content?Te.content:Te,z=(Te,Xe)=>{if(!Te)return;if(Array.isArray(Te)){for(let O of Te)z(O,Xe);return}let _e=X.get(Te);_e||X.set(Te,_e=[]),_e.push(Xe)},Ce=(Te,Xe=null,_e=!1)=>{F.add(Te),A.set(Te,Xe);let O=f.get(Te),K=_e||!!(O&&l(O.remote||O.base));if(E.set(Te,K),O)for(let fe of[O.base,O.local,O.remote])z(fe,Te);if(!(O?.pinned||O?.unchanged))for(let fe of B(Te).childNodes)Ce(fe,Te,K)},Me=Te=>(X.get(Te)||[]).find(Xe=>Xe.nodeType===1&&!E.get(Xe)&&!f.get(Xe)?.pinned&&!f.get(Xe)?.unchanged),Be=(Te,Xe)=>{for(let _e of X.get(Te)||[]){let O=_e;for(;O&&A.get(O)!==Xe;)O=A.get(O);if(O)return O}return null},me=(Te,Xe,_e)=>{let O=B(Xe);for(let K=_e.nextSibling;K;K=K.nextSibling){let fe=Be(K,Xe);if(fe){O.insertBefore(Te,fe);return}}for(let K=_e.previousSibling;K;K=K.previousSibling){let fe=Be(K,Xe);if(fe){O.insertBefore(Te,fe.nextSibling);return}}O.appendChild(Te)};Ce(U);for(let Te of C){let{record:Xe}=Te,_e=Me(Xe.owner)||Me(Xe.owners[1])||Me(Xe.owners[2]);if(_e)(!Te.result||Te.output!==_e||Te.result.nodes.some(O=>!F.has(O)||A.get(O)!==_e)||_e.textContent!==Te.result.text)&&(q(Xe.owner,_e),Ce(_e,A.get(_e),E.get(_e)));else{let O=Xe.parent,K=Xe.owner,fe=null;for(;O&&!fe;)fe=Me(O),fe||(K=O,O=s(O));if(!fe)throw new Error("A cross-parent payload has no allowed surviving parent");_e=Te.output||c(Xe.owner,Xe.owners[1],Xe.owners[2],!1),Te.result||q(Xe.owner,_e),me(_e,fe,K),Ce(_e,fe,E.get(fe))}Te.state="attached"}}return{ensureParent:L,ensureOwner(U){L(s(U))},consumes(U){return N.has(U)},render:q,drain:V}}var En=/\S/,kc=/[\p{L}\p{N}]/u;function Nr(e,t,n,r){if(e?.nodeType!==1||!t(e))return!1;for(let o=e.firstChild;o;o=o.nextSibling)if(r(n,1),o.nodeType!==3)return!1;return!!e.firstChild}function sl(e,t,n){for(let r=e.parentNode;r;r=r.parentNode)if(n(t,1),r.nodeType===11)return!1;return!0}function yc(e,t,n,r,o){let s=n(e,r),i=n(t,r),l=null,a=null,c=null,m=null;o(r,s.length+i.length);for(let u of s)kc.test(u.raw)&&(l||=u,a=u);for(let u of i)kc.test(u.raw)&&(c||=u,m=u);return!!(l&&c&&(l.raw===c.raw||a.raw===m.raw))}function Gh({base:e,V:t,A:n,source:r,original:o,current:s,edited:i,destination:l,at:a,ownLength:c,eligible:m,model:u,tokensOf:f,budget:p,charge:h}){let v=o.flat.text,g=s.flat.text,d=i.flat.text,k=l.flat.text;if(h(p,v.length+g.length+k.length),v.startsWith(g)||v.endsWith(g))return!1;let S=En.test(k.slice(0,a)),x=En.test(k.slice(a+c));if(S===x)return!1;let w=S?0:a+c,T=S?a:k.length;for(;w<T&&!En.test(k[w]);)w++;for(;T>w&&!En.test(k[T-1]);)T--;let N=k.slice(w,T);if(Rn(N,k,f(l,p),p,h,!0)!==w)return!1;let C=Rn(N,v,f(o,p),p,h,!0);if(C<0)return!1;let L=C+N.length,q=!En.test(v.slice(0,C)),V=!En.test(v.slice(L));if(q===V||Rn(N,g,f(s,p),p,h,!1)>=0)return!1;let U=q?v.slice(L):v.slice(0,C),F=q?d.length-U.length:0;if(h(p,v.length+d.length),F<0||!En.test(U)||Rn(U,d,f(i,p),p,h,!0)!==F||!En.test(q?d.slice(0,F):d.slice(U.length)))return!1;for(let A of e){if(h(p,1),A===r||!Nr(A,m,p,h))continue;let E=u(A,null,p);if(Rn(N,E.flat.text,f(E,p),p,h,!1)>=0)return!1}for(let A of t.units){if(h(p,1),A===s.unit||A===l.unit||!Nr(A,m,p,h))continue;let E=u(A,n,p);if(Rn(N,E.flat.text,f(E,p),p,h,!1)>=0)return!1}return!0}function vc({base:e,views:t,side:n,attempt:r,eligible:o,blocked:s,baseId:i,model:l,tokensOf:a,charge:c,exhausted:m,limit:u}){if(u<=0)return null;let f=Gt(u),{V:p,A:h,idOf:v}=t[n],g=t[1-n],[d,k,S,x]=r,w=null;try{for(let T=d;T<=k;T++){c(f,1);let N=e[T];if(N.parentNode?.nodeType!==1||s.has(N)||h.identical.has(N)||g.A.identical.has(N)||!Nr(N,o,f,c)||i(N))continue;let C=p.twin(N),L=g.V.twin(N);if(!C||!L||!p.here(C)||!g.V.here(L)||h.map.get(N)!==C||h.reverse.get(C)!==N||g.A.map.get(N)!==L||g.A.reverse.get(L)!==N||v(C)||g.idOf(L)||C.tagName!==N.tagName||L.tagName!==N.tagName||!Nr(C,o,f,c)||!Nr(L,o,f,c)||!sl(N,f,c)||!sl(C,f,c)||!sl(L,f,c))continue;let q=l(N,null,f),V=l(C,h,f),U=l(L,g.A,f),F=q.flat.text,A=V.flat.text,E=U.flat.text;if(c(f,F.length+A.length+E.length),!En.test(F)||!En.test(A)||!En.test(E)||F===A||F===E||A===E||!yc(q,V,a,f,c)||!yc(q,U,a,f,c))continue;let X=null,B=!1;for(let Me=S;Me<=x;Me++){c(f,1);let Be=p.units[Me],me=p.baseOf(Be);if(!me||me===N||s.has(me)||me.parentNode!==N.parentNode||Be.parentNode!==C.parentNode||me.tagName!==N.tagName||Be.tagName!==N.tagName||h.map.get(me)!==Be||h.reverse.get(Be)!==me||i(me)!==v(Be)||!Nr(me,o,f,c)||!Nr(Be,o,f,c))continue;let Te=l(me,null,f),Xe=l(Be,h,f),_e=Te.flat.text,O=Xe.flat.text;if(c(f,_e.length),!En.test(_e)||O.length<=_e.length)continue;let K=a(Xe,f),fe=Rn(_e,O,K,f,c,!0);if(!(fe<0||Rn(F,O,K,f,c,!0,fe,fe+_e.length)<0&&!Gh({base:e,V:p,A:h,source:N,original:q,current:V,edited:U,destination:Xe,at:fe,ownLength:_e.length,eligible:o,model:l,tokensOf:a,budget:f,charge:c}))){if(X){B=!0;break}X=Be}}if(!X||B)continue;let z=n===0?C:L,Ce=n===0?L:C;(w||=[]).push({source:N,local:z,remote:Ce,models:[q,n===0?V:U,n===0?U:V]})}}catch(T){if(T!==m)throw T}return w}var Wn=/\S/,gn=/\s/,Yh=/[\s\u001e]/g,il=/[^\s\p{P}\u001e\ufffc]/u;function Xh(e,t,n,r,o,s,i){let l=0;for(let a of e)i(s,1),a.nodeType===1&&!r.baseOf(a)&&l++;if(l<2)return!1;for(let a of e){if(a.nodeType!==1||r.baseOf(a))continue;let c=o.get(a).flat;if(c.atoms.length||c.pins?.length)continue;i(s,c.text.length*2+t.length+n.length);let m=new Uint8Array(c.text.length);for(let u of n)u.target===a&&m.fill(1,u.targetFrom,u.targetFrom+u.to-u.from);for(let u of t)u.target===a&&m.fill(1,u.targetFrom,u.targetFrom+u.to-u.from);for(let u=0;u<c.text.length;u++)if(!m[u]&&Wn.test(c.text[u]))return!0}return!1}function Jh(e,t,n){let{source:r,models:o,retained:s,runs:i}=e,l=o.get(r).flat.text;n(t,l.length*2+s.length+i.length);let a=new Uint8Array(l.length);for(let c of s)c.source===r&&(n(t,c.to-c.from),a.fill(1,c.from,c.to));for(let c of i)n(t,c.to-c.from),a.fill(1,c.from,c.to);for(let c=0;c<l.length;c++)if(!a[c]&&Wn.test(l[c]))return!1;return!0}function Zh(e,t,n,r,o,s,i,l,a,c){let m=s.get(e),u=s.get(t),f=m.flat.text,p=i.get(e);a(c,f.length*2+n.length);let h=f.length,v=0;for(let k=0;k<f.length;k++)!gn.test(f[k])&&!p[k]&&(h=Math.min(h,k),v=k+1);if(h>=v)return null;for(let k=h;k<v;k++)if(!gn.test(f[k])&&p[k])return null;let g=-1;for(let k of n)if(k.target===t&&k.from<=h&&k.to>h){g=k.targetFrom+h-k.from;break}if(g<0)return null;let d=f.slice(h,v);if(a(c,d.length*(n.length+2)),u.flat.text.slice(g,g+d.length)!==d)return null;for(let k=h;k<v;k++){if(gn.test(f[k]))continue;let S=!1;for(let x of n)if(x.target===t&&x.from<=k&&x.to>k&&x.targetFrom+k-x.from===g+k-h){S=!0;break}if(!S)return null}if(m.flat.atoms.length||u.flat.atoms.length){a(c,m.flat.atoms.length+u.flat.atoms.length);let k=0,S=u.flat.atoms;for(;k<S.length&&S[k].i<g;)k++;for(let x of m.flat.atoms){if(x.i<h||x.i>=v)continue;let w=S[k++];if(!w||w.i!==g+x.i-h||u.alignment?.reverse.get(w.el)!==x.el)return null}if(k<S.length&&S[k].i<g+v-h)return null}for(let[k,S,x]of[[r,e,h],[o,t,g]]){let w=!1;for(let T of k){let N=s.get(T),C=i.get(T),L=l(N,c);for(let q=0;q<L.length;q++){let V=L[q].from,U=V+d.length;if(a(c,d.length*2+1),N.flat.text.slice(V,U)!==d)continue;let F=q;for(;F<L.length&&L[F].to<U;)a(c,1),F++;if(F===L.length||L[F].to!==U)continue;let A=!0;for(let E=V;E<U;E++)if(!gn.test(N.flat.text[E])&&C[E]){A=!1;break}if(A){if(w||T!==S||V!==x)return null;w=!0}}}if(!w)return null}return d}function Qh(e,t,n,r,o,s,i,l){if(i(l,o.length+s.length+(r.length+1)*n.length*2),!n)return!1;let a=r.indexOf(n);return a<0||r.lastIndexOf(n)!==a||!s.some(c=>c.from===a)||!s.some(c=>c.to===a+n.length)?!1:o.some(c=>c.source===e&&c.target===t&&c.from===0&&c.to===n.length&&c.targetFrom===a)}function xc({base:e,views:t,eligible:n,baseId:r,ignored:o,remoteWins:s,atomKey:i,limit:l=2e4*8}){if(l<=0)return null;let a=Symbol(),c=(x,w)=>{if(w>x.remaining)throw a;x.remaining-=w},m=[new Map,new Map];for(let x=0;x<2;x++)for(let w=0;w<t[x].V.units.length;w++)m[x].set(t[x].V.units[w],w);let u=new Int32Array(e.length),f=new Int32Array(e.length),p=x=>t.every(({V:w},T)=>{let N=w.twin(x);return N&&m[T].has(N)}),h=-1;for(let x=0;x<e.length;x++)u[x]=h,p(e[x])&&(h=x);h=e.length;for(let x=e.length-1;x>=0;x--)f[x]=h,p(e[x])&&(h=x);let v=new Map,g=(x,w)=>{if(c(w,1),v.has(x))return v.get(x);let T=x.firstChild,N=1;for(;T;){if(c(w,N*8+8),T.nodeType===3&&c(w,T.data.length*8),T.nodeType===1&&wn.has(T.tagName)&&!o(T)&&!s(T)&&T.firstChild){T=T.firstChild,N++;continue}for(;T&&T!==x&&!T.nextSibling;)T=T.parentNode,N--;T=!T||T===x?null:T.nextSibling}let C=Qt(Array.from(x.childNodes),{ignored:o,remoteWins:s});return v.set(x,C),C},d=(x,w,T,N,C,L)=>{for(let q of x.atoms){c(L,1);let V=w.atomAt.get(q.i+T);if(!V)return!1;let U=N?.reverse.get(q.el)||i(q.el),F=C?.reverse.get(V.el)||i(V.el);if(U!==F)return!1}return!0},k=(x,w,T,N,C)=>{let L=x.text.length<=w.text.length?x:w,q=L===x?w:x;if(c(C,L.text.length+q.text.length),!L.text||!Wn.test(L.text.replaceAll(zn,"")))return!1;let V;if(L.text===q.text)V=0;else{let U=q.text.length-L.text.length;if(c(C,(U+1)*L.text.length*2),q.text.startsWith(L.text))V=0;else if(q.text.endsWith(L.text))V=U;else return!1;if(q.text.indexOf(L.text)!==V||q.text.lastIndexOf(L.text)!==V)return!1;c(C,q.text.length*2);let F=0,A=V===0,E=!1;for(let X of un(q.text,xn(q.text)))F+=X.len,F===V&&(A=!0),F===V+L.text.length&&(E=!0);if(!A||!E)return!1}return L===x?d(L,q,V,T,N,C):d(L,q,V,N,T,C)},S=null;for(let x=0;x<2;x++){let{V:w,A:T,idOf:N}=t[x],C=t[1-x];if(!w.asBase)for(let L=0;L<e.length;L++){let q=e[L];if(w.twin(q)||!n(q))continue;let V=C.V.twin(q);if(!V||!m[1-x].has(V)||!n(V))continue;let U={remaining:l};try{let F=u[L],A=f[L],E=0;for(let Ce=F+1;Ce<A;Ce++)c(U,1),!w.twin(e[Ce])&&C.V.twin(e[Ce])&&n(e[Ce])&&E++;if(E!==1||g(q,U).text===g(V,U).text)continue;let X=F<0?-1:m[x].get(w.twin(e[F])),B=A===e.length?w.units.length:m[x].get(w.twin(e[A]));if(X===void 0||B===void 0||X>=B)continue;let z=null;for(let Ce=X+1;Ce<B;Ce++){c(U,1);let Me=w.units[Ce];if(w.baseOf(Me)||!n(Me)||Me.tagName!==q.tagName||Me.namespaceURI!==q.namespaceURI)continue;let Be=r(q),me=C.idOf(V),Te=N(Me);if(!(Be&&me&&Be!==me||Be&&Te&&Be!==Te||me&&Te&&me!==Te)&&k(g(V,U),g(Me,U),C.A,T,U)){if(z){z=null;break}z=Me}}if(!z)continue;S||(S=[new Map,new Map]),S[x].set(q,z)}catch(F){if(F!==a)throw F}}}return S?t.map(({V:x},w)=>{let T=S[w];if(!T.size)return x;let N=new Map;for(let[C,L]of T)N.set(L,C);return{...x,twin:C=>T.get(C)||x.twin(C),baseOf:C=>N.get(C)||x.baseOf(C)}}):null}function wc({onUncertainSource:e,onUncertainOwner:t,base:n,views:r,eligible:o,ignored:s,remoteWins:i,baseId:l,atomKey:a,limit:c=2e4*32}){if(c<=0)return null;let m=new Set(n),u=new Map(n.map((F,A)=>[F,A])),f=new Map,p=[],h=null,v=null,g=null,d=new Set;for(let F of n)for(let{V:A}of r){let E=A.twin(F);E&&!A.asBase&&!A.here(E)&&d.add(F)}let k=new Set,S=Symbol(),x=(F,A)=>{if(A>F.remaining)throw S;F.remaining-=A},w=(F,A,E)=>{x(E,1);let X=f.get(F);if(X)return X;if(F.nodeType===1){let Ce=F.firstChild,Me=1;for(;Ce;){if(x(E,Me*8+8),Ce.nodeType===3&&x(E,Ce.data.length*8),Ce.nodeType===1&&wn.has(Ce.tagName)&&!s(Ce)&&!i(Ce)&&Ce.firstChild){Ce=Ce.firstChild,Me++;continue}for(;Ce&&Ce!==F&&!Ce.nextSibling;)Ce=Ce.parentNode,Me--;Ce=!Ce||Ce===F?null:Ce.nextSibling}}else x(E,F.value.length*8+F.nodes.length);let B=F.nodeType===1?Array.from(F.childNodes):F.nodes,z=B.length===1&&B[0].nodeType===3?{text:B[0].data,nodes:[{node:B[0],s:0,e:B[0].data.length}],atoms:[]}:Qt(B,{ignored:s,remoteWins:i});return X={unit:F,flat:z,alignment:A,tokens:null},f.set(F,X),X},T=(F,A)=>{if(F.tokens)return F.tokens;x(A,F.flat.text.length*8);let{unit:E,flat:X,alignment:B}=F,z=[],Ce=xn(X.text),Me=0,Be=me=>{for(let Te of un(X.text.slice(Me,me),Ce))Te.from=Me,Te.to=Me+Te.len,Te.unit=E,z.push(Te),Me+=Te.len};for(let me of X.atoms){Be(me.i);let Te=i(me.el)&&me.el.nodeType===1?"w"+me.el.tagName+"#"+(me.el.id||""):a(B?.reverse.get(me.el)||me.el);z.push({k:Te,raw:zn,len:1,from:Me,to:Me+1,unit:E,atom:!0}),Me++}return Be(X.text.length),F.tokens=z,z},N=(F,A,E,X,B)=>{if(!F.flat.atoms.length&&!A.flat.atoms.length)return!0;let z=T(F,B),Ce=T(A,B);x(B,z.length+Ce.length);let Me=0;for(let Be of Ce){if(!Be.atom||Be.from<E||Be.from>=E+X)continue;for(;Me<z.length&&!z[Me].atom;)Me++;let me=z[Me++];if(!me||me.from!==Be.from-E||me.k!==Be.k)return!1}for(;Me<z.length;)if(z[Me++].atom)return!1;return!0},C=(F,A,E)=>{let X=F.length+A.length+4;if(X*8>E.remaining)return null;E.remaining-=X*8;let B=Math.floor(E.remaining/8),z=Math.min(F.length+A.length,4e3,Math.floor((Math.sqrt(X*X+B)-X)/2)),Ce=4*(z+1)*(X+z+1);if(z<1||Ce>E.remaining)return null;E.remaining-=Ce;let Me=Xn(F,A,z),Be=[],me=0,Te=0;for(let Xe of Me.hunks){for(;me<Xe.bs;)F[me].raw===A[Te].raw&&Be.push([F[me],A[Te]]),me++,Te++;me=Xe.be,Te+=Xe.toks.length}for(;me<F.length&&Te<A.length;)F[me].raw===A[Te].raw&&Be.push([F[me],A[Te]]),me++,Te++;return Be},L=(F,A,E,X,B,z,Ce)=>{if(B<=X)return;let Me=F[F.length-1];if(Me&&Me.source===A&&Me.target===E&&Me.to<=X&&Me.targetFrom-Me.from===z-X){x(Ce,(X-Me.to)*3);let Be=f.get(A).flat.text,me=f.get(E).flat.text,Te=!0;for(let Xe=Me.to;Xe<X;Xe++)if(!gn.test(Be[Xe])||Be[Xe]!==me[z+Xe-X]){Te=!1;break}if(Te){Me.to=B;return}}F.push({source:A,target:E,from:X,to:B,targetFrom:z})},q=F=>F.replace(Yh,"");for(let F=0;F<r.length;F++){let{V:A,A:E,idOf:X}=r[F];if(A.asBase)continue;let B=new Map(A.units.map((O,K)=>[O,K])),z=O=>{let K=A.twin(O);return K&&B.has(K)?K:null},Ce=(O,K)=>{let fe=new Int32Array(O.length),ae=new Int32Array(O.length),qe=-1;for(let ze=0;ze<O.length;ze++)fe[ze]=qe,K(O[ze])&&(qe=ze);qe=O.length;for(let ze=O.length-1;ze>=0;ze--)ae[ze]=qe,K(O[ze])&&(qe=ze);return{prev:fe,next:ae}},Me=Ce(n,O=>(O.nodeType===1||O.kind==="text"&&Wn.test(O.value))&&z(O)),Be=Ce(A.units,O=>(O.nodeType===1||O.kind==="text"&&Wn.test(O.value))&&m.has(A.baseOf(O))),me=new Map,Te=(O,K,fe,ae)=>{if(O>K||fe>ae)return;let qe=`${O}:${K}:${fe}:${ae}`;me.set(qe,[O,K,fe,ae])};for(let O=0;O<A.units.length;O++){let K=A.units[O];if(A.baseOf(K)||!o(K))continue;let fe=Be.prev[O],ae=Be.next[O],qe=fe<0?0:u.get(A.baseOf(A.units[fe])),ze=ae===A.units.length?n.length-1:u.get(A.baseOf(A.units[ae]));Te(qe,ze,Math.max(0,fe),Math.min(A.units.length-1,ae))}for(let O=0;O<n.length;O++){let K=n[O];if(d.has(K)||!o(K))continue;if(!A.twin(K)){let ot=Me.prev[O],rt=Me.next[O],xt=ot<0?0:B.get(z(n[ot])),nt=rt===n.length?A.units.length-1:B.get(z(n[rt]));Te(Math.max(0,ot),Math.min(n.length-1,rt),xt,nt)}let fe=z(K);if(!fe||E.identical.has(K)||!o(fe))continue;let ae=O+1;for(;ae<n.length&&n[ae].kind==="text"&&!n[ae].value.trim();)ae++;if(ae>=n.length||!o(n[ae]))continue;let qe=z(n[ae]);if(!qe||E.identical.has(n[ae])||!o(qe))continue;let ze=B.get(fe),Ee=B.get(qe);ze<Ee&&Te(O,ae,ze,Ee)}let Xe=Array.from(me.values()),_e=new Set;if(Xe.length>1){let O=Gt(c);try{x(O,Xe.length*4);let K=Xe.slice().sort((qe,ze)=>(x(O,1),qe[0]-ze[0]||qe[2]-ze[2])),fe=[],ae=null;for(let qe of K)x(O,1),ae&&qe[0]<=ae[1]&&qe[2]<=ae[3]&&qe[3]>=ae[2]?(ae[1]=Math.max(ae[1],qe[1]),ae[2]=Math.min(ae[2],qe[2]),ae[3]=Math.max(ae[3],qe[3]),ae[4].push(qe)):(ae?.[4].length>1&&fe.push(ae),ae=[qe[0],qe[1],qe[2],qe[3],[qe]]);ae?.[4].length>1&&fe.push(ae),Xe=fe.concat(Xe)}catch(K){if(K!==S)throw K}}for(let O of Xe){if(_e.has(O))continue;let[K,fe,ae,qe,ze]=O,Ee=Gt(c),ot=[],rt=new Set,xt=!1;try{x(Ee,(fe-K+qe-ae+2)*4);let nt=n.slice(K,fe+1).filter(D=>!E.identical.has(D)&&o(D)&&!d.has(D)),te=A.units.slice(ae,qe+1).filter(D=>o(D)&&(!A.baseOf(D)||m.has(A.baseOf(D)))&&!E.identical.has(A.baseOf(D))&&!d.has(A.baseOf(D))),Ae=new Set(te),je=!1,Fe="",He="",et=0;for(let D of nt){let ge=w(D,null,Ee);Fe+=ge.flat.text,et+=ge.flat.text.length}for(let D of te){let ge=w(D,E,Ee);He+=ge.flat.text,et+=ge.flat.text.length}x(Ee,et);let bt=q(Fe),Ft=q(He),yt=bt===Ft;if(xt=yt,ze&&!yt)continue;let It=yt?null:new Map;if(It)for(let D of nt.concat(te)){let ge=f.get(D).flat.text.length;x(Ee,ge*16),It.set(D,new Uint8Array(ge))}let en=D=>{let ge=[];for(let xe of D){let de=f.get(xe);de.flat.atoms.length?ge.push(...T(de,Ee)):ge.push({unit:xe,raw:de.flat.text,from:0})}return ge},Ge=[];for(let D of yt?[]:nt){let ge=z(D);if(!Ae.has(ge))continue;let xe=w(D,null,Ee),de=w(ge,E,Ee);x(Ee,xe.flat.text.length+de.flat.text.length);let Oe=xe.flat.text&&de.flat.text.startsWith(xe.flat.text)?0:xe.flat.text&&de.flat.text.endsWith(xe.flat.text)?de.flat.text.length-xe.flat.text.length:-1;if(Oe>=0&&N(xe,de,Oe,xe.flat.text.length,Ee)){It.get(D).fill(1),It.get(ge).fill(1,Oe,Oe+xe.flat.text.length),L(Ge,D,ge,0,xe.flat.text.length,Oe,Ee);continue}let $=C(T(xe,Ee),T(de,Ee),Ee);if(!$){je=!0;break}for(let[Z,ke]of $)It.get(D).fill(1,Z.from,Z.to),It.get(ge).fill(1,ke.from,ke.to),L(Ge,D,ge,Z.from,Z.to,ke.from,Ee)}if(je)continue;let Ct=null,Tt=null;if(!yt)for(let D of nt){let ge=z(D),xe=f.get(D);if(!ge||xe.flat.atoms.length||!Ae.has(ge))continue;let de=xe.flat.text,Oe=It.get(D);x(Ee,de.length*3+te.length);let $=-1,Z=-1,ke=!1;for(let De=0;De<de.length;De++)gn.test(de[De])||(Oe[De]?ke=!0:($<0&&($=De),Z=De+1));if(!ke||$<0)continue;let we=!0;for(let De=$;De<Z;De++)if(Oe[De]&&!gn.test(de[De])){we=!1;break}if(!we)continue;let ve=q(de.slice($,Z)),ne=null,se=!1;for(let De of te){if(A.baseOf(De))continue;let Se=f.get(De);if(!Se.flat.atoms.length&&(x(Ee,Se.flat.text.length),q(Se.flat.text)===ve)){if(ne){se=!0;break}ne=De}}if(se){(Tt||=new Set).add(D);continue}if(!ne||Tt?.has(D))continue;let W=!1;for(let De of nt){if(De===D||!Ae.has(z(De)))continue;let Se=f.get(De);if(Se.flat.atoms.length)continue;let tt=It.get(De);x(Ee,Se.flat.text.length*3);let lt="",it=!1;for(let Ht=0;Ht<Se.flat.text.length;Ht++)gn.test(Se.flat.text[Ht])||(tt[Ht]?it=!0:lt+=Se.flat.text[Ht]);it&&lt===ve&&(Tt||=new Set,Tt.add(D),Tt.add(De),W=!0)}if(W)continue;let ce=f.get(ne).flat.text;x(Ee,Z-$+ce.length);let Ne=$,Pe=0;for(;Ne<Z&&Pe<ce.length;){for(;Ne<Z&&gn.test(de[Ne]);)Ne++;for(;Pe<ce.length&&gn.test(ce[Pe]);)Pe++;if(Ne>=Z||Pe>=ce.length)break;L(Ct||=[],D,ne,Ne,Ne+1,Pe,Ee),Ne++,Pe++}Oe.fill(1,$,Z),It.get(ne).fill(1)}let Jt=D=>{let ge=[];for(let xe of D){let de=w(xe,m.has(xe)?null:E,Ee),Oe=It.get(xe);for(let $ of T(de,Ee)){let Z=$.from;for(;Z<$.to;){for(;Z<$.to&&Oe[Z];)Z++;let ke=Z;for(;Z<$.to&&!Oe[Z];)Z++;if(Z>ke){let we=de.flat.text.slice(ke,Z);Wn.test(we)&&ge.push({...$,raw:we,len:Z-ke,k:$.atom?$.k:we,from:ke,to:Z})}}}}return ge},Y=yt?en(nt):Jt(nt),y=yt?en(te):Jt(te),M=yt?bt:Y.map(D=>q(D.raw)).join(""),P=yt?Ft:y.map(D=>q(D.raw)).join("");if((!M||!P)&&!Ct)continue;let H=Ct||[];if(M&&P&&M===P){let D=0,ge=0,xe=0,de=0;for(;D<Y.length&&ge<y.length;){let Oe=Y[D],$=y[ge];for(;xe<Oe.raw.length&&gn.test(Oe.raw[xe]);)xe++;for(;de<$.raw.length&&gn.test($.raw[de]);)de++;if(xe===Oe.raw.length){D++,xe=0;continue}if(de===$.raw.length){ge++,de=0;continue}if((Oe.atom||$.atom)&&Oe.k!==$.k){je=!0;break}L(H,Oe.unit,$.unit,Oe.from+xe,Oe.from+xe+1,$.from+de,Ee),xe++,de++}}else if(M&&P){let D=C(Y,y,Ee);if(!D)continue;for(let[ge,xe]of D)L(H,ge.unit,xe.unit,ge.from,ge.to,xe.from,Ee)}if(je)continue;let Q=new Map;for(let D of H)if(!Tt?.has(D.source)){if(z(D.source)===D.target){yt&&Ge.push(D);continue}Q.has(D.source)||Q.set(D.source,[]),Q.get(D.source).push(D)}for(let[D,ge]of Q){let xe=w(D,null,Ee),de=z(D),Oe=xe.flat.text,$=[],Z=new Set,ke=r[1-F],we=ke.V.twin(D),ve=we&&ke.V.here(we)?w(we,ke.A,Ee):null,ne=(Se,tt)=>{let lt=T(Se,Ee),it=T(tt,Ee);return x(Ee,Se.flat.text.length+tt.flat.text.length+lt.length+it.length),Se.flat.text===tt.flat.text&&lt.length===it.length&&lt.every((Ht,Lt)=>Ht.k===it[Lt].k)},se=de&&ve&&ve.flat.text!==Oe&&ne(w(de,E,Ee),ve);for(let Se of new Set(ge.map(tt=>tt.target))){if(D.nodeType!==1&&Se.nodeType!==1)continue;let tt=w(Se,E,Ee),lt=A.baseOf(Se);if(D.nodeType!==1&&lt||(x(Ee,Oe.length*2+tt.flat.text.length*3+Ge.length*2),de&&q(Oe)===q(tt.flat.text)&&w(de,E,Ee).flat.text.trim()))continue;if(!de&&!lt&&D.nodeType===1&&Se.nodeType===1){let Bt=l(D),Wt=X(Se);if(Bt&&Wt&&Bt!==Wt)continue}let it=tt.flat.text,Ht=Oe&&(it.startsWith(Oe)||it.endsWith(Oe)),Lt=!1;if(!de&&ve&&lt&&ve.flat.text!==Oe){let Bt=w(lt,null,Ee).flat.text,Wt=u.get(D)<u.get(lt)?ve.flat.text:Bt,R=u.get(D)<u.get(lt)?Bt:ve.flat.text;x(Ee,Wt.length+R.length+it.length),Lt=!!Wt&&!!R&&Wt.length+R.length<=it.length&&it.startsWith(Wt)&&it.endsWith(R)&&!it.slice(Wt.length,it.length-R.length).trim()}let Zt=!xe.flat.atoms.length&&!ve?.flat.atoms.length&&!tt.flat.atoms.length&&(se&&Ht||Lt);if(de&&lt){let Bt=w(de,E,Ee).flat.text,Wt=Oe.startsWith(Bt)||Oe.endsWith(Bt),R=w(lt,null,Ee).flat.text,J=tt.flat.text,ue=J.startsWith(R)||J.endsWith(R),he=!r[1-F].V.twin(lt)&&!Ge.some(le=>le.source===lt&&Wn.test(R.slice(le.from,le.to)));if(!yt&&(!Wt&&!Zt||!ue&&!he)){let le=Zh(D,Se,ge,nt,te,f,It,T,x,Ee);if(!le)continue;let ee=E.weak?.has(D)&&!E.identityPaired?.has(D)&&Oe.trim()===le;if(!Wt&&!Zt&&!ee)continue;let ie=E.weak?.has(lt)&&!E.identityPaired?.has(lt)&&it.trim()===le&&!f.get(lt).flat.atoms.length&&!Ge.some(Re=>Re.source===lt&&Wn.test(R.slice(Re.from,Re.to)));if(!ue&&!he&&!ie&&!Qh(lt,Se,R,it,Ge,T(tt,Ee),x,Ee))continue;ee&&Z.add(Se)}}Zt&&Z.add(Se),x(Ee,ge.length),$.push(...ge.filter(Bt=>Bt.target===Se))}if(!$.length)continue;let W=new Uint8Array(Oe.length);x(Ee,Oe.length*4+Ge.length);for(let Se of $)W.fill(1,Se.from,Se.to);let ce=[];for(let Se=0;Se<Oe.length;Se++)gn.test(Oe[Se])||ce.push(Se);if(!ce.length)continue;let Ne=new Set($.map(Se=>Se.target));if(!yt&&de&&Ne.size>1&&Xh(Ne,H,Ge,A,f,Ee,x)){if(g||=new Map,g.set(D,(g.get(D)||0)|1<<F),e){let Se=Gi({source:D,side:F,views:r,eligible:o,blocked:d,baseId:l,model:w,tokensOf:T,budget:Ee,charge:x});if(Se){x(Ee,Se.to-Se.from);let tt=!0;for(let lt=Se.from;lt<Se.to;lt++)if(Wn.test(Oe[lt])&&!W[lt]){tt=!1;break}tt&&(h||=[]).push(Se)}}continue}let Pe=ce.filter(Se=>il.test(Oe[Se]));if(!$.some(Se=>il.test(Oe.slice(Se.from,Se.to)))&&!ce.every(Se=>W[Se]))continue;if(!de&&!Array.from(Ne).some(Se=>Z.has(Se))&&!ce.every(Se=>W[Se])&&!(Pe.length&&W[Pe[0]]&&W[Pe[Pe.length-1]]&&Ne.size===1)){let Se=null,tt=0,lt=0,it=null,Ht=null;if(!de&&ve&&D.nodeType===1&&!xe.flat.atoms.length){let Lt=T(xe,Ee).filter(Zt=>il.test(Zt.raw));x(Ee,te.length+Oe.length);for(let Zt of te){let Bt=A.baseOf(Zt);if(!Bt||Bt===D||Bt.nodeType!==1||Zt.nodeType!==1||Bt.tagName!==D.tagName||Zt.tagName!==Bt.tagName)continue;let Wt=u.get(D),R=u.get(Bt),J=!0;for(let Je=Math.min(Wt,R)+1;Je<Math.max(Wt,R);Je++){let at=n[Je];if(x(Ee,at.nodeType===1?1:at.value.length+1),at.nodeType===1||at.value.trim()){J=!1;break}}if(!J)continue;let ue=w(Bt,null,Ee),he=w(Zt,E,Ee);if(ue.flat.atoms.length||he.flat.atoms.length)continue;let le=ue.flat.text,ee=he.flat.text;if(x(Ee,le.length+ee.length+Oe.length),!le||!Lt.length)continue;let ie=0,Re=ee.length;if(Wt<R&&ee.endsWith(le))Re-=le.length;else if(Wt>R&&ee.startsWith(le))ie=le.length;else continue;for(;ie<Re&&gn.test(ee[ie]);)ie++;for(;Re>ie&&gn.test(ee[Re-1]);)Re--;let We=ee.slice(ie,Re);if(!(!We||!(We.startsWith(Lt[0].raw)||We.endsWith(Lt[Lt.length-1].raw)))){if(Se){Se=null;break}Se=Zt,tt=ie,lt=Re,it=Lt[0],Ht=Lt[Lt.length-1]}}}if(x(Ee,$.length),!Se||!Ne.has(Se)||!$.some(Lt=>Lt.target===Se&&(Lt.from<=it.from&&Lt.to>=it.to&&Lt.targetFrom+it.from-Lt.from===tt||Lt.from<=Ht.from&&Lt.to>=Ht.to&&Lt.targetFrom+Ht.to-Lt.from===lt)))continue}if(de&&!(ce.every(Se=>W[Se])&&(yt||Array.from(Ne).some(Se=>Z.has(Se))))&&!Ge.some(Se=>Se.source===D&&Wn.test(Oe.slice(Se.from,Se.to))))continue;let De=!1;if(yt){x(Ee,Ge.length+ce.length);for(let Se of Ge)Se.source===D&&(x(Ee,Se.to-Se.from),W.fill(1,Se.from,Se.to));De=!0;for(let Se of ce)if(!W[Se]){De=!1;break}}for(let Se of Ne){x(Ee,$.length);let tt=$.filter(it=>it.target===Se);ot.push({side:F,source:D,target:Se,runs:tt,models:f,retained:Ge,conservedSource:De}),D.nodeType===1&&rt.add(D),Se.nodeType===1&&rt.add(Se);let lt=A.baseOf(Se);lt?.nodeType===1&&rt.add(lt)}}if(p.push(...ot),ze&&ot.length)for(let D of ze)_e.add(D);for(let D of rt)k.add(D)}catch(nt){if(nt!==S)throw nt}finally{if(t&&!ze&&!xt){let nt=vc({base:n,views:r,side:F,attempt:O,eligible:o,blocked:d,baseId:l,model:w,tokensOf:T,charge:x,exhausted:S,limit:c});nt&&(v||=[]).push(...nt)}if(e&&!ze&&!xt){let nt=Pa({base:n,views:r,side:F,attempt:O,eligible:o,blocked:d,baseId:l,model:w,tokensOf:T,certificates:p,charge:x,exhausted:S,limit:c});nt&&(h||=[]).push(...nt)}}}}let V=p.length?new Map:null;for(let F of p){let A=V.get(F.source);A||V.set(F.source,A=[]),A.push(F)}let U=null;if(V){let F=null;for(let[A,E]of V){let X=g?.get(A)||0;if(E.length<2&&!X)continue;let B=0;for(let z of E)z.conservedSource&&(B|=1<<z.side);for(let z of E){if(z.conservedSource)continue;let Ce=1<<z.side,Me=!0;if(B&Ce)Me=!1;else if(X&Ce){Me=!1;try{Me=Jh(z,F||=Gt(c),x)}catch(Be){if(Be!==S)throw Be}}Me||(U||=new Set).add(z)}}}if(U){let F=0;for(let A of p)U.has(A)||(p[F++]=A);p.length=F;for(let[A,E]of V){F=0;for(let X of E)U.has(X)||(E[F++]=X);E.length=F,F||V.delete(A)}k.clear();for(let A of p){let{source:E,target:X,side:B}=A;E.nodeType===1&&k.add(E),X.nodeType===1&&k.add(X);let z=r[B].V.baseOf(X);z?.nodeType===1&&k.add(z)}}if(h){let F=Gt(c),A=!1;for(let E of h){let X=!1,B=V?.get(E.source);if(B&&!A)try{X=Ki(E,B,F,x)}catch(z){if(z!==S)throw z;A=!0}X||e(E)}}if(v){let F=new Set,A=Gt(c);try{for(let E of v){if(x(A,1),F.has(E.source))continue;F.add(E.source);let X=!1;for(let B of p)if(x(A,1),B.source===E.source||B.target===E.local||B.target===E.remote){X=!0;break}X||t(E)}}catch(E){if(E!==S)throw E}}for(let F of n)if(k.has(F))for(let{V:A}of r){let E=A.twin(F);E&&A.here(E)&&k.add(E)}return p.length?{blocks:k,certificates:p,certificatesBySource:V,models:f}:null}function Sc({certificates:e,scopes:t,flats:n,keys:r,limit:o=2e4*32}){let s=Symbol(),i=Gt(o),l=g=>{if(g>i.remaining)throw s;i.remaining-=g},a=t.map(g=>new Set(g)),c=new Map,m=new Map,u=(g,d)=>{let k=c.get(g);if(k||c.set(g,k=new Map),k.has(d))return k.get(d);l(g.text.length);let S=m.get(d);if(!S){l(d.nodes.length+d.atoms.length),S={nodes:new Map,atoms:new Map};for(let N of d.nodes)S.nodes.set(N.node,N);for(let N of d.atoms)S.atoms.set(N.el,N.i);m.set(d,S)}let{nodes:x,atoms:w}=S,T=new Int32Array(g.text.length).fill(-1);for(let N of g.nodes){let C=x.get(N.node);if(!(!C||N.e-N.s!==C.e-C.s)){l(N.e-N.s);for(let L=N.s;L<N.e;L++)T[L]=C.s+L-N.s}}for(let N of g.atoms){let C=w.get(N.el);C!==void 0&&(T[N.i]=C)}return k.set(d,T),T},f=(g,d,k,S,x)=>{let w=g[g.length-1];w&&w.to===d&&w.target+w.to-w.from===S&&w.kind===x?w.to=k:g.push({from:d,to:k,target:S,kind:x})},p=(g,d,k,S)=>{l((S-k)*4);let x=[],w=k,T=L=>{let q=g.text.slice(w,L);for(let V of un(q,xn(q)))V.from=w,V.to=w+V.len,x.push(V),w+=V.len},N=0,C=g.atoms.length;for(;N<C;){l(1);let L=N+C>>>1;g.atoms[L].i<k?N=L+1:C=L}for(let L=N;L<g.atoms.length&&g.atoms[L].i<S;L++){l(1);let q=g.atoms[L];T(q.i),x.push({k:d(q),raw:zn,len:1,from:w,to:w+1}),w++}return T(S),x},h=(g,d,k,S,x,w)=>{if(k===S||x===w)return;if(S-k===w-x){l((S-k)*4);let A=!0;for(let E=k,X=x;E<S;E++,X++){if(n[0].text[E]!==n[d].text[X]){A=!1;break}let B=n[0].atomAt.get(E),z=n[d].atomAt.get(X);if(!!B!=!!z||B&&r[0](B)!==r[d](z)){A=!1;break}}if(A){f(g,k,S,x,"retained");return}}let T=p(n[0],r[0],k,S),N=p(n[d],r[d],x,w),C=T.length+N.length+4,L=Math.min(T.length+N.length,4e3,Math.floor((Math.sqrt(C*C+i.remaining/2)-C)/2));if(L<1)throw s;l(4*(L+1)*(C+L+1));let q=Xn(T,N,L),V=0,U=0,F=()=>{let A=T[V++],E=N[U++];l(A.len),A.raw===E.raw&&f(g,A.from,A.to,E.from,"retained")};for(let A of q.hunks){for(;V<A.bs;)F();V=A.be,U+=A.toks.length}for(;V<T.length&&U<N.length;)F()},v=g=>{let d=e.filter(q=>q.side===g-1&&a[0].has(q.source)&&a[g].has(q.target));if(!d.length)return null;let k=[],S=(q,V,U)=>{if(!a[0].has(q.source)||!a[g].has(q.target))return;let F=u(V.get(q.source).flat,n[0]),A=u(V.get(q.target).flat,n[g]);l(q.to-q.from);for(let E=0;E<q.to-q.from;E++){let X=F[q.from+E],B=A[q.targetFrom+E];if(X<0||B<0)throw s;f(k,X,X+1,B,U)}},x=new Set;for(let q of d){if(!x.has(q.retained)){x.add(q.retained);for(let V of q.retained)S(V,q.models,"retained")}for(let V of q.runs)S(V,q.models,"transfer")}k.sort((q,V)=>(l(1),q.from-V.from||q.target-V.target));let w=[];for(let q of k){l(1);let V=w[w.length-1];if(V&&q.from<V.to){if(q.target-q.from!==V.target-V.from)throw s;V.to=Math.max(V.to,q.to),q.kind==="transfer"&&(V.kind="transfer")}else w.push(q)}let T=[],N=0,C=0;for(let q of w){if(q.target<C)throw s;h(T,g,N,q.from,C,q.target),T.push(q),N=q.to,C=q.target+q.to-q.from}h(T,g,N,n[0].text.length,C,n[g].text.length);let L=Hn({base:n[0],side:n[g],retained:T.filter(q=>q.kind==="retained"),transfers:T.filter(q=>q.kind==="transfer"),baseAtomKey:r[0],sideAtomKey:r[g],budget:i});if(L.status!=="ready"||!L.monotone)throw s;return L};try{let g=v(1),d=v(2);return g||d?{local:g,remote:d}:{fallback:!0}}catch(g){if(g!==s)throw g;return{fallback:!0}}}function ll(e,t,n=!1){let r=-1,o=-1;for(let i=0;i<e.list.length;i++){let l=e.list[i];l.bLo<t.lo||l.bLo>t.hi||(r<0&&(r=i),o=i)}let s=[];for(let i=r;i>=0&&i<=o;i++){let l=e.list[i],a=!n&&i===r?l.inlineStart<0?l.to:l.inlineStart:l.from,c=!n&&i===o?l.inlineEnd<0?l.from:l.inlineEnd:l.to;for(let m=a;m<c;m++)s.push(e.units[m]);i<o&&s.push(e.units[l.next])}return s}var ut=e=>!!e&&e.nodeType===1,_s=e=>ut(e)?e.getAttribute("data-id")||e.textContent||"":e.value!==void 0?e.value:e.nodeValue||"",Ln=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function al(e){for(let t of e)if(Ln.has(t.tagName))return!0;return!1}function em(e,t,n){let r=null;for(let o of t.childNodes)if(!(!ut(o)||!n(o)||!o.isEqualNode(e))){if(r)return null;r=o}if(!r)return null;for(let o of e.parentNode.childNodes)if(o!==e&&o.isEqualNode(e))return null;return r}var $o="[id],[data-id],script,head>*";function ul(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let r=Xr(n,e);if(r)return"merge:"+r.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?ic(n,t):null}}function Ms(e,t,n,r){let o=r.ignored,s=r.stats||lr(),i=_a({ignored:o,ignoreAttribute:r.ignoreAttribute,stats:s}),{unitsOf:l,meta:a}=i,c=r.baseURI,m=r.mergeTags!==null,u=ul(r.mergeTags,c),f=R=>J=>{let ue=u(J);return ue!==null?ue:R(J)},p=f(r.identity.base),h=f(r.identity.local),v=f(r.identity.remote),g=r.authored||r.identity,d=R=>R&&R.nodeType===9?R.documentElement:R,k=d(e),S=d(t),x=d(n),w=globalThis.__hyperMorphProfile,T=w?performance.now():0,N=R=>R===vn?$o:null,C=r.scope||null,L=C?C.baseDropped:new Set,q=new Set,V=C?C.remoteDropped:new Set,U=C?C.baseIndex:ks(k,p,o,N(r.identity.base),L),F=r.localIsBase||k===S?null:ks(S,h,o,N(r.identity.local),q),A=C?C.remoteIndex:ks(x,v,o,N(r.identity.remote),V),E=R=>{let J=ut(R)&&h(R);return J&&F?.get(J)===R&&!U.has(J)?J:null},X=R=>{let J=ut(R)&&v(R);return J&&A.get(J)===R&&!U.has(J)?J:null},B=F?Di(k,S,{analyzer:i,baseIndex:U,sideIndex:F,baseId:g.base,sideId:g.local,baseKey:p,sideKey:h,baseDropped:L,sideDropped:q,stats:s}):Ec(),z=Di(k,x,{analyzer:i,baseIndex:U,sideIndex:A,baseId:g.base,sideId:g.remote,baseKey:p,sideKey:v,baseDropped:L,sideDropped:V,stats:s,scope:C,comparisons:r.comparisons});if(C){if(!C.held(z))return null;for(let R of C.dropped)ji(R)}let Ce=null;function Me(R){if(!Ce){Ce=new WeakMap;let J=[k];for(;J.length;){let ue=J.pop();ue.tagName==="TEMPLATE"&&ue.content&&Ce.set(ue.content,ue);for(let he of i.childrenOf(ue))he.nodeType===1&&J.push(he)}}return Ce.get(R)||null}let Be=R=>{let J=ut(R)||R.nodeType?R.parentNode:R.parent;return J&&J.nodeType===11?Me(J):J};if(z.moved.size){let R=!1;for(let J of Array.from(z.moved))!ut(J)||z.identityPaired.has(J)||!g.base(J)||y(z,Be(J))||(z.unpair(J),R=!0);R&&z.rematch()}Jt(),Y(B,z),Y(z,B);for(let R of[B,z])if(R.refused)for(let J of R.refused)R.moved.has(J)||s.ambiguousMoves++;w&&(w.alignTotal=(w.alignTotal||0)+(performance.now()-T),T=performance.now());let me=k.ownerDocument.implementation.createHTMLDocument(""),Te=new WeakMap,Xe=new WeakMap,_e=[],O=[],K=new Set,fe=[],ae=new Set,qe=new Set,ze=new Set,Ee=new WeakMap,ot=null,rt=r.lineage?.locals.length?Ga():null,xt=R=>{let J=Ss(R);return J&&rt&&rt.consume(R.local),J},nt=r.conflicts||"remote",te=R=>_e.push(R),Ae=R=>_e.push(R),je=mc({roots:{base:k,local:S,remote:x},L:B,R:z,unitsOf:l,provenance:Te,policy:nt}),Fe=(R,J)=>{O.push(R),J&&je.note(R,J)},He=null,et=null,bt=Ct(),Ft=null,yt=D(k,B.map.get(k),z.map.get(k),!!r.localIsBase,!!r.childrenOnly);yt.tagName==="HTML"?me.replaceChild(yt,me.documentElement):me.body.appendChild(yt),He?.drain(yt),et?.drain(yt),w&&(w.build=(w.build||0)+(performance.now()-T));let It=r.childrenOnly?!lt(Se(yt),Se(x)):!Ne(yt,x),en=je.finish(yt),Ge=rt?Ya({locals:r.lineage.locals,rec:rt,root:yt,provenance:Te,segments:fe,ignored:o}):null;return{doc:me,root:yt,provenance:Te,textMappers:Xe,decisions:_e,conflicts:O,recoveryLinks:en,localDiverged:It,mergedScripts:K,segments:fe,remoteIdOf:r.identity.remote,customIdentity:r.identity.remote!==vn,L:B,R:z,stats:s,lineage:Ge};function Ct(){let R=new Map,J=new Set;if(r.localIsBase||!B.insertedByHash)return{partner:R,drop:J};let ue=B.insertedByHash(),he=z.insertedByHash();if(!ue.size||!he.size)return{partner:R,drop:J};let le={ignored:o,remoteWins:r.remoteWins,inlineCache:Ee},ee=Ye=>{let St=0;for(let Rt=Ye.parentNode;Rt;Rt=Rt.parentNode)St++;return St},ie=[],Re=Ye=>{let St=Ye.textContent.trim();return St.split(/\s+/).length>=3||St.replace(/\s/g,"").length>=12},We=Ye=>{let St=y(B,Ye),Rt=y(z,Ye);return St&&B.reverse.get(St.parentNode)!==Ye.parentNode||Rt&&z.reverse.get(Rt.parentNode)!==Ye.parentNode},Je=(Ye,St,Rt)=>{for(let jt of Rt.parentNode.children){let _n=jt!==Rt&&Ye.reverse.get(jt);if(_n&&We(_n))return!0}let Ut=Ye.reverse.get(Rt.parentNode);if(Ut){for(let jt of Ut.children)if(!y(St,jt)&&!o(jt))return!0}return!1},at=new Map([[B,new Map],[z,new Map]]),dt=(Ye,St)=>{let Rt=at.get(Ye),Ut=Rt.get(St);if(Ut===void 0){Ut=!1;for(let jt of St.children)if(Ye.reverse.has(jt)||dt(Ye,jt)){Ut=!0;break}Rt.set(St,Ut)}return Ut},ht=new Map;for(let Ye of he.values())for(let St of Ye){let Rt=X(St);Rt&&ht.set(Rt,St)}for(let Ye of ue.values())for(let St of Ye){let Rt=E(St),Ut=Rt?ht.get(Rt):null;Ut&&Ut.tagName===St.tagName&&!Vn(St,le)&&!Vn(Ut,le)&&!r.remoteWins(St)&&!r.remoteWins(Ut)&&ie.push([St,[Ut],ee(St),!0,!0])}for(let[Ye,St]of ue){let Rt=he.get(Ye);if(!Rt)continue;let Ut=St.length===1&&Rt.length===1;for(let jt of St)!Vn(jt,le)&&!E(jt)&&ie.push([jt,Rt,ee(jt),Ut&&(Re(jt)||Je(B,z,jt)||Je(z,B,Rt[0]))])}if(!ie.length)return{partner:R,drop:J};ie.sort((Ye,St)=>Ye[2]-St[2]);let ft=new Set,Mt=new Set,_t=Ye=>{for(let St of Ye.querySelectorAll("*"))ft.add(St)},Pt=(Ye,St)=>Ye.reverse.get(St.parentNode)||null;for(let[Ye,St,,Rt,Ut]of ie){if(ft.has(Ye)||Mt.has(Ye)||Ut&&(dt(B,Ye)||dt(z,St[0])))continue;let jt=Pt(B,Ye),_n=kn=>!Mt.has(kn)&&!ft.has(kn)&&(Ut||kn.tagName===Ye.tagName&&!X(kn)&&i.equalUnits(Ye,kn)),an=St.find(kn=>jt&&Pt(z,kn)===jt&&_n(kn))||(Rt?St.find(_n):null);if(!an)continue;Mt.add(Ye),Mt.add(an);let or=jt&&Pt(z,an)===jt;(!Ut||!or||i.equalUnits(Ye,an))&&(_t(Ye),_t(an)),!or&&(R.set(Ye,an),R.set(an,Ye),J.add(nt==="local"?an:Ye))}return{partner:R,drop:J}}function Tt(R,J,ue){if(ae.add(R),bt.drop.has(R))return null;ae.add(ue);let he=J==="local"?R:ue,le=J==="local"?ue:R,ee;return i.equalUnits(he,le)?(ee=W(he,"local",!0),Te.get(ee).remote=le):ee=se(he,le),Fe({kind:"structure",el:ee,detail:"both-moved",base:null,local:he,remote:le},{unit:{b:null,l:he,r:le}}),te({kind:"insert",el:ee,source:"both"}),ee}function Jt(){if(!B.weak||!z.weak||!B.weak.size||!z.weak.size||!B.unpair)return;let R=new Map;for(let ue of B.weak){let he=y(B,ue);ut(ue)&&ut(he)&&R.set(i.unitHash(he),ue)}let J=!1;for(let ue of Array.from(z.weak)){let he=y(z,ue);if(!ut(ue)||!ut(he))continue;let le=R.get(i.unitHash(he));if(!le||le===ue||!B.weak.has(le)||y(B,ue)&&y(z,le))continue;let ee=y(B,le);ee.tagName===he.tagName&&i.equalUnits(ee,he)&&(B.unpair(le),z.unpair(ue),J=!0)}J&&(B.rematch(),z.rematch())}function Y(R,J){if(!R.weak||!R.weak.size||!J.insertedByHash)return;let ue=J.insertedByHash();if(!ue.size)return;let he=!1;for(let le of Array.from(R.weak)){let ee=y(R,le);if(!ee)continue;let ie=R===B?E(ee):X(ee);if(ie){let We=(R===B?A:F)?.get(ie);We&&We.tagName===ee.tagName&&!J.reverse.has(We)&&(R.unpair(le),he=!0);continue}let Re=ue.get(i.unitHash(ee));Re&&Re.some(We=>We.tagName===ee.tagName&&i.equalUnits(We,ee))&&(R.unpair(le),he=!0)}he&&R.rematch()}function y(R,J){if(!J)return null;if(R.map.has(J))return R.map.get(J);let ue=[],he=Be(J);for(;he&&!R.map.has(he);he=Be(he))ue.push(he);let le=he;if(!le||!R.identical.has(le))return null;R.pairIdenticalChildren(le);for(let ie=ue.length-1;ie>=0;ie--)R.pairIdenticalChildren(ue[ie]);let ee=R.map.get(J)||null;return ee&&s.lazyTwins++,ee}function M(R,J,ue,he){if(ut(R)&&Ln.has(R.tagName)&&!B.identical.has(R)&&(R.previousSibling?.nodeType===3||R.nextSibling?.nodeType===3)){let Re=Be(R),We=y(B,R),Je=y(z,R);We&&Je&&Bt(We,y(B,Re),B)&&!Bt(Je,y(z,Re),z)&&(et||=bc({L:B,R:z,twinIn:y,unitsOf:l,view:P,parentOf:Be,ignored:o,remoteWins:r.remoteWins,eligible:at=>ut(at)&&Ln.has(at.tagName),build:D,out:me,policy:nt,provenance:Te,textMappers:Xe,segments:fe,conflicts:O,conflict:Fe,decisions:_e}),et.ensureOwner(R))}if(J===null)return null;if(he!==void 0)return He||=Qr(Te,Be,B,z,y,D,o,r.remoteWins,O,Fe,H,S,x),He.plan(R,J,ue,!!he),he&&(He.produced(R,he),qe.add(R)),he;if(qe.has(R)||ze.has(R))return Fe({kind:"structure",el:null,detail:"both-moved",base:R},{subject:R}),qe.has(R)?null:W(ue,J);He||=Qr(Te,Be,B,z,y,D,o,r.remoteWins,O,Fe,H,S,x),He.plan(R,J,ue,!0);let le=y(B,R),ee=y(z,R);(!le||!ee)&&Fe({kind:"structure",el:null,detail:"move-beats-delete",base:R},{subject:R,deleted:le?"remote":"local"});let ie=D(R,le,ee,!1);return(J==="local"?te:Ae)({kind:"move",el:ie,source:J}),ie}function P(R,J,ue,he){return he||!J||J===ue?{el:ue,asBase:!0,twin:le=>le,baseOf:le=>le,units:l(ue),here:()=>!0,parentOfTwin:()=>ue}:{el:J,asBase:!1,twin:le=>y(R,le),baseOf:le=>R.reverse.get(le),units:l(J),here:le=>ut(le)?le.parentNode===J||J.tagName==="TEMPLATE"&&le.parentNode===J.content:le.parent===J||J.tagName==="TEMPLATE"&&le.parent===J.content}}function H(R,J,ue){return!J||ue&&ue.identical.has(R)?!1:ut(R)?!i.equalUnits(R,J)||!Q(R,J,ue):R.value!==J.value}function Q(R,J,ue){if(!ue||R===J)return!0;let he=[[R,J]];for(;he.length;){let[le,ee]=he.pop(),ie=l(le),Re=l(ee);for(let We=0;We<ie.length&&We<Re.length;We++){let Je=ie[We],at=Re[We];if(!ut(Je)||!ut(at))continue;let dt=ue.map.get(Je);if(dt!==void 0&&dt!==at)return!1;let ht=ue.reverse.get(at);if(ht!==void 0&&ht!==Je)return!1;he.push([Je,at])}}return!0}function D(R,J,ue,he,le=!1){let ee=he||(ue?r.remoteWins(ue):r.remoteWins(R)),ie=R.namespaceURI&&R.namespaceURI!=="http://www.w3.org/1999/xhtml"?me.createElementNS(R.namespaceURI,R.tagName):me.createElement(R.tagName),Re={base:R,local:J||null,remote:ue||null};if(Te.set(ie,Re),ee&&!he&&J&&H(R,J,B)&&(!ue||!i.equalUnits(J,ue))&&Fe({kind:"structure",el:ie,detail:"remote-wins",base:R,local:J,remote:ue||null},{subject:R}),ae.add(R),qe.add(R),J&&ae.add(J),ue&&ae.add(ue),r.skipUnchanged&&!le&&(r.localIsBase||B.identical.has(R))&&ue&&z.identical.has(R)&&!r.remoteWins(R)){Re.unchanged=!0;for(let Je of R.attributes)Je.namespaceURI?ie.setAttributeNS(Je.namespaceURI,Je.name,Je.value):ie.setAttribute(Je.name,Je.value);return He?.produced(R,ie),ie}ze.add(R),le||Oe(R,ee?R:J,ue,ie);let We=R.tagName;if(mn(R))de(R,ee?R:J,ue,ie);else if(We==="TEXTAREA"){let Je=ee?R:J,at=R.textContent,dt=Je?Je.textContent:at,ht=ue?ue.textContent:at,ft=ge(R);if(ft&&dt!==at&&ht!==at){let Mt=we(ft,ge(Je),ge(ue),ee);Mt&&ie.appendChild(Mt)}else ie.textContent=xe(at,dt,ht,ie,"text")}else if(!et?.render(R,ie)){let Je=ce(R,J,ue,ee,ie),at=We==="TEMPLATE"&&ie.content?ie.content:ie;for(let dt of Je)at.appendChild(dt)}return ze.delete(R),He?.produced(R,ie),ie}function ge(R){if(!R)return null;let J=l(R)[0];return J&&!ut(J)&&J.kind==="text"?J:null}function xe(R,J,ue,he,le){if(J===ue)return J;if(J===R)return ue!==R&&Ae({kind:le,node:he,source:"remote"}),ue;if(ue===R)return te({kind:le,node:he,source:"local"}),J;let ee=nt==="local"?J:ue;return Fe({kind:le,node:he,base:R,local:J,remote:ue,resolved:ee},{site:"whole",el:he}),_e.push({kind:le,node:he,source:"both"}),ee}function de(R,J,ue,he){let le=R.textContent,ee=J?J.textContent:le,ie=ue?ue.textContent:le,Re=m?Xr(R,r.mergeTags,!0):null;if(Re&&ee!==ie){let We=ue&&ue.getAttribute("merge-key")||R.getAttribute("merge-key"),{text:Je,warnings:at,conflicts:dt}=ol(r.localIsBase?void 0:le,ee,ie,{parse:Re.recognizer.parse,keyCandidates:We?We.split(/[\s,]+/).filter(Boolean):void 0});for(let ht of at)console.warn(`[hyper-morph] merge "${Re.raw}": ${ht}`);for(let ht of r.localIsBase?[]:dt)Fe({kind:"json",node:he,name:Re.raw,path:ht.path,base:ht.base,local:ht.local,remote:ht.remote,resolved:ht.resolved});he.textContent=Je,K.add(he),Je!==ie?te({kind:"text",node:he,source:Je===ee?"local":"both"}):Je!==le&&Ae({kind:"text",node:he,source:"remote"});return}he.textContent=xe(le,ee,ie,he,"text")}function Oe(R,J,ue,he){let le=new Map;for(let ee of[R,J,ue])if(ee)for(let ie of ee.attributes)r.ignoreAttribute(ee,ie.name)||le.set(ie.name,ie);for(let[ee,ie]of le){let Re=R?R.getAttribute(ee):null,We=J?J.getAttribute(ee):Re,Je=ue?ue.getAttribute(ee):Re,at;We===Je?at=We:We===Re?(at=Je,Ae({kind:"attr",el:he,name:ee,source:"remote"})):Je===Re?(at=We,te({kind:"attr",el:he,name:ee,source:"local"})):(at=ke(ee,Re,We,Je)??$(ee,[R,J,ue],Re,We,Je),at===void 0&&(at=nt==="local"?We:Je,Fe({kind:"attr",el:he,name:ee,base:Re,local:We,remote:Je,resolved:at},{el:he,sample:ie})),_e.push({kind:"attr",el:he,name:ee,source:"both"})),at!=null&&(ie.namespaceURI?he.setAttributeNS(ie.namespaceURI,ie.name,at):he.setAttribute(ee,at))}}function $(R,J,ue,he,le){let ee=r.attributeMerge;if(typeof ee!="function")return;let ie=J.filter(Boolean).map(Re=>ee(Re,R));if(!(!ie.length||ie.some(Re=>Re!==ie[0]))){if(ie[0]==="tokens")return Z(ue,he,le);if(ie[0]==="max"){let Re=Number(he),We=Number(le);return Number.isFinite(Re)&&Number.isFinite(We)&&he!==""&&le!==""?String(Math.max(Re,We)):void 0}}}function Z(R,J,ue){let he=ht=>[...new Set((ht||"").split(/\s+/).filter(Boolean))],le=he(R),ee=new Set(le),ie=new Set(he(J)),Re=new Set(he(ue)),We=ht=>ie.has(ht)===Re.has(ht)?ie.has(ht):ie.has(ht)===ee.has(ht)?Re.has(ht):ie.has(ht),Je=le.filter(We),at=[...new Set([...ie,...Re])].filter(ht=>!ee.has(ht)&&We(ht)).sort(),dt=[...Je,...at];return dt.length?dt.join(" "):null}function ke(R,J,ue,he){if(R==="class"){let le=Je=>new Set((Je||"").split(/\s+/).filter(Boolean)),ee=le(J),ie=le(ue),Re=le(he),We=new Set;for(let Je of new Set([...ee,...ie,...Re])){let at=ee.has(Je),dt=ie.has(Je),ht=Re.has(Je);(dt===ht?dt:dt===at?ht:dt)&&We.add(Je)}return[...We].join(" ")}if(R==="style"){let le=at=>{let dt=new Map;if(!at)return dt;let ht=0,ft=null,Mt="",_t=()=>{let Pt=Mt.indexOf(":");Pt>0&&dt.set(Mt.slice(0,Pt).trim(),Mt.slice(Pt+1).trim()),Mt=""};for(let Pt of at){if(ft){Mt+=Pt,Pt===ft&&(ft=null);continue}if(Pt==='"'||Pt==="'"){ft=Pt,Mt+=Pt;continue}if(Pt==="("?ht++:Pt===")"&&ht--,Pt===";"&&ht===0){_t();continue}Mt+=Pt}return Mt.trim()&&_t(),dt},ee=le(J),ie=le(ue),Re=le(he),We=new Map,Je=!1;for(let at of new Set([...ee.keys(),...ie.keys(),...Re.keys()])){let dt=ee.get(at)??null,ht=ie.get(at)??null,ft=Re.get(at)??null,Mt;ht===ft?Mt=ht:ht===dt?Mt=ft:ft===dt?Mt=ht:(Mt=nt==="local"?ht:ft,Je=!0),Mt!=null&&We.set(at,Mt)}return Je?void 0:[...We].map(([at,dt])=>`${at}: ${dt}`).join("; ")}}function we(R,J,ue,he){let le=R.value,ee=he?le:J?J.value:"",ie=ue?ue.value:"";ae.add(R),J&&ae.add(J),ue&&ae.add(ue);let Re=Po(le,ee,ie,nt),We=Re.text===""?null:me.createTextNode(Re.text);We&&(Te.set(We,{base:R.nodes,local:J?J.nodes:null,remote:ue?ue.nodes:null}),Xe.set(We,Re.mapLocalOffset)),ee!==le&&ie!==le?_e.push({kind:"text",node:We,source:"both"}):ee!==le?te({kind:"text",node:We,source:"local"}):ie!==le&&Ae({kind:"text",node:We,source:"remote"});for(let Je of Re.conflicts)Fe({kind:"text",node:We,base:le.slice(Je.bs,Je.be),local:Je.local,remote:Je.remote,resolved:Je.resolved},{site:"run",bRun:R,lRun:J,rRun:ue,node:We,c:Je});return We}function ve(R,J){return Ar(R,J).every(ue=>ue.bs===ue.be)}function ne(R,J){let ue=R?R.value:"",he=J?J.value:"",le;if(ue===he||!he?le=ue:ue?ve(ue,he)?le=he:ve(he,ue)?le=ue:(le=nt==="local"?ue:nt==="both"?ue+he:he,Fe({kind:"structure",el:null,detail:"insert-collision",local:ue,remote:he,resolved:le},{unit:{b:null,l:R,r:J},localLost:nt==="remote"})):le=he,R&&ae.add(R),J&&ae.add(J),le==="")return null;let ee=me.createTextNode(le);return Te.set(ee,{base:null,local:R?R.nodes:null,remote:J?J.nodes:null}),ue?te({kind:"insert",el:ee,source:he&&ue===he?"both":"local"}):Ae({kind:"insert",el:ee,source:"remote"}),ee}function se(R,J){let ue={ignored:o,remoteWins:r.remoteWins,inlineCache:Ee},he=Re=>l(Re).every(We=>ut(We)?Vn(We,ue):We.kind==="text"),le=null;if(he(R)&&he(J)){let Re=R.textContent,We=J.textContent;Re===We||ve(We,Re)?le=J:ve(Re,We)&&(le=R)}if(!le){let Re=nt==="local",We=W(Re?R:J,Re?"local":"remote",!0),Je=Te.get(We);return Re?Je.remote=J:Je.local=R,Fe({kind:"structure",el:We,detail:"insert-collision",local:R,remote:J,resolved:Re?R:J},{unit:{b:null,l:R,r:J},localLost:!Re}),We}let ee=R.namespaceURI&&R.namespaceURI!=="http://www.w3.org/1999/xhtml"?me.createElementNS(R.namespaceURI,R.tagName):me.createElement(R.tagName);Oe(null,R,J,ee),Te.set(ee,{base:null,local:R,remote:J}),ae.add(R),ae.add(J);let ie=xt({base:Array.from(le.childNodes),local:Array.from(R.childNodes),remote:Array.from(J.childNodes),out:me,policy:nt,idOf:{local:h,remote:v},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,provenance:Te,textMappers:Xe,conflicts:O,conflict:Fe,scope:{base:null,local:R,remote:J,units:[],at:0},synthetic:!0,decisions:_e,node:ee});fe.push(...ie.segments);for(let Re of ie.nodes)ee.appendChild(Re);return ee}function W(R,J,ue=!1){if(!ue&&ut(R)){let ie=bt.partner.get(R);if(ie)return Tt(R,J,ie)}if(!ut(R)){if(R.value==="")return null;let ie=R.kind==="comment"?me.createComment(R.value):me.createTextNode(R.value);return Te.set(ie,{base:null,local:J==="local"?R.nodes:null,remote:J==="remote"?R.nodes:null}),ae.add(R),ie}let he=R.namespaceURI&&R.namespaceURI!=="http://www.w3.org/1999/xhtml"?me.createElementNS(R.namespaceURI,R.tagName):me.createElement(R.tagName);for(let ie of R.attributes)ie.namespaceURI?he.setAttributeNS(ie.namespaceURI,ie.name,ie.value):he.setAttribute(ie.name,ie.value);Te.set(he,{base:null,local:J==="local"?R:null,remote:J==="remote"?R:null}),ae.add(R);let le=R.tagName==="TEMPLATE"&&he.content?he.content:he,ee=J==="local"?B:z;for(let ie of l(R)){let Re=ut(ie)?ee.reverse.get(ie):null;if(Re&&M(Re,null,null),Re&&qe.has(Re)){Fe({kind:"structure",el:null,detail:"both-moved",base:Re},{subject:Re});continue}if(Re&&!ze.has(Re)){let Je=y(B,Re)||null,at=y(z,Re)||null;if(Je||at){He||=Qr(Te,Be,B,z,y,D,o,r.remoteWins,O,Fe,H,S,x),He.plan(Re,J,ie,!0);let dt=D(Re,Je,at,!1);J==="local"?te({kind:"move",el:dt,source:"local"}):Ae({kind:"move",el:dt,source:"remote"}),le.appendChild(dt);continue}}let We=W(ie,J);We&&le.appendChild(We)}if(!ue&&bt.drop.size&&R.tagName==="DIV"&&!le.firstChild&&!R.attributes.length&&!(J==="local"?h(R):v(R))&&!ee.reverse.has(R)&&!o(R)&&!r.remoteWins(R)){let ie=R.firstChild;if(ie&&ie===R.lastChild&&ut(ie)&&(bt.drop.has(ie)||Ft?.has(ie)))return(Ft||=new WeakSet).add(R),null}return he}function ce(R,J,ue,he,le){J&&B.identical.has(R)&&B.pairIdenticalChildren(R),ue&&z.identical.has(R)&&z.pairIdenticalChildren(R);let ee=P(B,J,R,he),ie=P(z,ue,R,!1),Re=l(R),We=new Set(Re),Je=new Map;for(let re=0;re<Re.length;re++)Je.set(Re[re],re);let at=re=>!ut(re)&&re.kind==="text"&&!/[^\t\n\f\r ]/.test(re.value),dt=[],ht=new Set,ft=new Map,Mt=new Set,_t=rt&&[],Pt=rt&&[],Ye=new Set,St=[],Rt=null,Ut=new Map;if(!ee.asBase&&!ie.asBase&&!B.identical.has(R)&&!z.identical.has(R))for(let re of Re){if(!ut(re)||!Ln.has(re.tagName))continue;let $e=ee.twin(re),Ue=ie.twin(re);$e&&Ue&&(!ee.here($e)||!ie.here(Ue))&&M(re,null,null)}let jt=(re,$e=!1)=>{let Ue=[];for(let Ze of re.units){if(Ye.has(Ze)||!$e&&at(Ze))continue;let wt=re.baseOf(Ze);wt&&We.has(wt)&&Ue.push(wt)}return Ue},_n=re=>jt(re).map($e=>Je.get($e)),an=re=>re.every(($e,Ue)=>Ue===0||$e>=re[Ue-1]),or=()=>{let re=!ee.asBase&&!an(_n(ee)),$e=!ie.asBase&&!an(_n(ie)),Ue=null;if(re&&$e){let Ze=jt(ee),wt=jt(ie);if(Ue=nm(Re.filter(Ke=>!Ye.has(Ke)&&!at(Ke)),Je,Ze,wt),Ue){let Ke=cl(Ze.map(mt=>Je.get(mt))),Ve=cl(wt.map(mt=>Je.get(mt)));for(let mt of Ke)Ve.has(mt)&&(Ue=null)}}return{lRe:re,rRe:$e,settled:Ue}},kn=or();ps(kn.lRe&&kn.rRe);let{lRe:yr,rRe:Mn,settled:Fr}=or(),Oo=yr&&Mn;Oo&&!Fr&&Fe({kind:"structure",el:le,detail:"both-reordered",base:R},{subject:R,lKept:jt(ee,!0),rKept:jt(ie,!0)});let tn=Mn||!yr?{V:ie,A:z,side:"remote",other:ee,otherA:B,otherSide:"local"}:{V:ee,A:B,side:"local",other:ie,otherA:z,otherSide:"remote"},Gn=null,No=null;if(Oo){Gn=$r(tn.V.units),No=tn.V.units,Fr&&(tn.V=rm(tn.V,Fr));for(let re of Re)at(re)&&ae.add(re);for(let re of[ee,ie])for(let $e of re.units)at($e)&&ae.add($e)}yr?te({kind:"move",el:null,source:Mn?"both":"local",base:R}):Mn&&Ae({kind:"move",el:null,source:"remote",base:R});let Br=ee.asBase?[]:ee.units.filter(re=>!ee.baseOf(re)&&!Ye.has(re)&&!bt.partner.has(re)),vr=ie.asBase?[]:ie.units.filter(re=>!ie.baseOf(re)&&!Ye.has(re)&&!bt.partner.has(re)),Dn=new Map;if(Br.length&&vr.length){let re=new Map,$e=new Map;for(let Ke of vr){if(ut(Ke)){let mt=v(Ke);mt&&re.set(mt,Ke)}let Ve=i.unitHash(Ke);$e.has(Ve)||$e.set(Ve,[]),$e.get(Ve).push(Ke)}let Ue=(Ke,Ve)=>{let mt=Ke.units.indexOf(Ve);for(let Qe=mt-1;Qe>=0;Qe--){let pt=Ke.baseOf(Ke.units[Qe]);if(pt)return pt}return"start"},Ze=new Map,wt=new Map;for(let Ke of vr){let Ve=Ue(ie,Ke);ut(Ke)?(wt.has(Ve)||wt.set(Ve,[]),wt.get(Ve).push(Ke)):Ke.kind==="text"&&!Ze.has(Ve)&&Ze.set(Ve,Ke)}for(let Ke of Br){let Ve=null;if(ut(Ke)){let Qe=h(Ke);Qe&&re.has(Qe)&&!Dn.has(re.get(Qe))&&(Ve=re.get(Qe))}else if(Ke.kind==="text"){let Qe=Ze.get(Ue(ee,Ke));Qe&&!Dn.has(Qe)&&(Ve=Qe)}let mt=!!E(Ke);if(!Ve&&!mt){let Qe=$e.get(i.unitHash(Ke));Qe&&(Ve=Qe.find(pt=>!Dn.has(pt)&&ut(pt)===ut(Ke)&&(ut(pt)?pt.tagName===Ke.tagName&&!X(pt):pt.kind===Ke.kind)&&i.equalUnits(Ke,pt))||null)}if(!Ve&&ut(Ke)&&!mt){let Qe=g.local(Ke),pt=(wt.get(Ue(ee,Ke))||[]).filter(kt=>{let Et=g.remote(kt);return!Dn.has(kt)&&kt.tagName===Ke.tagName&&!X(kt)&&!(Qe&&Et&&Qe!==Et)&&i.similar(Ke,kt)});pt.length===1&&(Ve=pt[0])}Ve&&(Dn.set(Ve,Ke),Dn.set(Ke,Ve))}}let ds=re=>{if(et?.consumes(re))return null;if(ae.has(re)||He?.has(re))return ft.get(re)||null;let $e=ee.twin(re),Ue=ie.twin(re),Ze=$e&&!ee.asBase&&!ee.here($e),wt=Ue&&!ie.asBase&&!ie.here(Ue);if(Ze||wt){if((!$e||!Ue)&&Fe({kind:"structure",el:null,detail:"move-beats-delete",base:re},{subject:re,deleted:$e?"remote":"local"}),!Zt(re))return ut(re)?(He||=Qr(Te,Be,B,z,y,D,o,r.remoteWins,O,Fe,H,S,x),Ze&&He.plan(re,"local",$e),wt&&He.plan(re,"remote",Ue)):ae.add(re),null;Fe({kind:"structure",el:null,detail:"both-moved",base:re},{subject:re})}if($e&&!Ue&&!ee.asBase&&!ie.asBase&&ut(re)&&Ln.has(re.tagName)&&!r.remoteWins(re)&&!r.remoteWins($e)&&H(re,$e,B)&&em(re,Se(ie.el),o)){let pt={ignored:o,remoteWins:r.remoteWins,inlineCache:Ee},kt=Et=>ut(Et)?Vn(Et,pt):Et.kind==="text";if(l(re).every(kt)&&l($e).every(kt)){let Et=xt({base:[re],local:[$e],remote:[],blocks:new Set([re,$e]),out:me,policy:nt,L:B,R:z,idOf:{base:p,local:h,remote:v},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(qt,Bn,ir)=>D(qt,Bn,ir,!1),cloneUnit:W,mergeAttrs:Oe,atomKey:i.exactUnitKey,moveIn:M,moveBuilt:M,movePlanned:M,provenance:Te,textMappers:Xe,conflicts:O,conflict:Fe,scope:{base:R,local:ee.el,remote:ie.el,units:Re,at:Je.get(re)},decisions:_e,node:le});fe.push(...Et.segments),ae.add(re),ae.add($e);let At=me.createDocumentFragment();for(let qt of Et.nodes)At.appendChild(qt);return ft.set(re,At),ft.set($e,At),At}}if(!$e&&!Ue)return ae.add(re),Ae({kind:"remove",source:"both",base:re}),null;if(!$e&&!H(re,Ue,z))return ae.add(re),te({kind:"remove",source:"local",base:re}),null;if(!Ue&&!H(re,$e,B))return ae.add(re),Ae({kind:"remove",source:"remote",base:re}),rt&&(rt.remove($e),_t.push({bk:re,lk:$e})),null;let Ke=!$e||!Ue,Ve=ee.asBase?y(B,re)||null:$e,mt=ie.asBase&&ut(re)&&(z.identityPaired.has(re)||!g.base(re))&&y(z,re)||Ue,Qe;return ut(re)?Qe=D(re,Ve,mt,ee.asBase):re.kind==="comment"?Qe=Ht(re,Ve,Ue,ee.asBase):Qe=we(re,Ve,Ue,ee.asBase),ae.add(re),Qe&&(ft.set(re,Qe),$e&&ft.set($e,Qe),Ue&&ft.set(Ue,Qe),Ke&&(Fe({kind:"structure",el:Qe,detail:"edit-beats-delete",base:re},{subject:re,deleted:$e?"remote":"local"}),$e?te({kind:"insert",el:Qe,source:"local"}):Ae({kind:"insert",el:Qe,source:"remote"}))),Qe},hs=(re,$e,Ue,Ze)=>{if(et?.consumes(re))return null;if(ae.has(re))return ft.get(re)||null;let wt=$e.baseOf(re);if(wt&&We.has(wt))return Ye.has(wt)&&!Ye.has(re)?ms(wt,re,Ze):ds(wt);if(wt)return Yn(wt,re,Ze);let Ke=Dn.get(re);if(Ke){let mt=Ze==="local"?re:Ke,Qe=Ze==="local"?Ke:re,pt;return ut(mt)?i.equalUnits(mt,Qe)?(pt=W(mt,"local"),pt&&(Te.get(pt).remote=Qe)):pt=se(mt,Qe):pt=ne(mt,Qe),ae.add(mt),ae.add(Qe),pt&&(ft.set(mt,pt),ft.set(Qe,pt),ut(mt)&&te({kind:"insert",el:pt,source:"both"})),pt}let Ve=W(re,Ze);return Ve&&(ft.set(re,Ve),Ze==="local"?te({kind:"insert",el:Ve,source:"local"}):(Ae({kind:"insert",el:Ve,source:"remote"}),rt&&ut(re)&&!bt.partner.has(re)&&Pt.push({su:re,node:Ve}))),Ve},ms=(re,$e,Ue)=>{let Ze;return ut(re)?(Ze=M(re,Ue,$e),Ze&&ae.add($e)):(Ze=W($e,Ue),ae.add($e),Ze&&(Ue==="local"?te:Ae)({kind:"insert",el:Ze,source:Ue})),Ze&&ft.set($e,Ze),Ze},Yn=(re,$e,Ue)=>{M(re,null,null);let wt=y(Ue==="local"?z:B,re),Ke=$e,Ve=wt?Bt(wt,Ue==="local"?ue:J,Ue==="local"?z:B):!1,mt=wt&&!Ve&&!Wt(re,wt);if(mt&&Ue===tn.otherSide)return Fe({kind:"structure",el:null,detail:"both-moved",base:re},{subject:re}),null;if(mt&&Fe({kind:"structure",el:null,detail:"both-moved",base:re},{subject:re}),wt||Fe({kind:"structure",el:null,detail:"move-beats-delete",base:re},{subject:re,deleted:Ue==="local"?"remote":"local"}),ze.has(re)){Fe({kind:"structure",el:null,detail:"both-moved",base:re},{subject:re});let pt=W(Ke,Ue);return pt&&ft.set($e,pt),pt}ut(re)&&(He||=Qr(Te,Be,B,z,y,D,o,r.remoteWins,O,Fe,H,S,x),He.plan(re,Ue,Ke,!0));let Qe=ut(re)?D(re,Ue==="local"?Ke:y(B,re)||null,Ue==="remote"?Ke:y(z,re)||null,!1):null;return Qe&&(ft.set(re,Qe),ft.set($e,Qe),wt&&ft.set(wt,Qe),Ue==="local"?te({kind:"move",el:Qe,source:"local"}):Ae({kind:"move",el:Qe,source:"remote"})),Qe};for(let re of tn.V.units){if(Ye.has(re)){if(Rt?.has(re)){for(let Ze of Rt.get(re))ht.has(Ze)||(dt.push(Ze),ht.add(Ze));continue}let Ue=ft.get(re);ht.has(Ue)||(dt.push(Ue),ht.add(Ue));continue}if(ae.has(re)&&!(ft.get(re)&&ht.has(ft.get(re)))){let Ue=tn.V.baseOf(re);Ue&&!We.has(Ue)&&Fe({kind:"structure",el:null,detail:"both-moved",base:Ue},{subject:Ue});continue}let $e=hs(re,tn.V,tn.A,tn.side);$e&&!ht.has($e)&&(dt.push($e),ht.add($e),!tn.V.baseOf(re)&&!Dn.has(re)&&!Ye.has(re)&&Mt.add($e))}for(let re of St)ht.has(re.frag)||(dt.splice(re.previous&&ht.has(re.previous)?dt.indexOf(re.previous)+1:Mo(re.at),0,re.frag),ht.add(re.frag));if(!tn.other.asBase){let re=tn.other,$e=tn.otherSide,Ue=tn.otherA,Ze=null,wt=0,Ke=null;for(let Ve of re.units){let mt=Ut.get(Ve)||ft.get(Ve);if(mt&&ht.has(mt)){Ze=mt,Ke=null;continue}if(ae.has(Ve)){let At=re.baseOf(Ve);At&&!We.has(At)&&Fe({kind:"structure",el:null,detail:"both-moved",base:At},{subject:At});continue}let Qe=hs(Ve,re,Ue,$e);if(!Qe)continue;let pt=!re.baseOf(Ve)&&!Ye.has(Ve),kt=!Ze&&!Ke,Et=Ke?dt.indexOf(Ke)+1:Ze?dt.indexOf(Ze)+1:wt;if(pt&&ut(Qe)){let At=_s(Qe);for(;Et<dt.length&&Mt.has(dt[Et])&&ut(dt[Et])&&_s(dt[Et])<At;)Et++}else if(Ze&&!Ke&&$e==="remote")for(;Et<dt.length&&Mt.has(dt[Et]);)Et++;dt.splice(Et,0,Qe),ht.add(Qe),pt&&Mt.add(Qe),kt&&(wt=Et+1),Ke=Qe}}for(let re=0;re<Re.length;re++){let $e=Re[re];if(ae.has($e))continue;let Ue=ds($e);Ue&&dt.splice(Mo(re),0,Ue)}return rt&&_t.length&&Pt.length&&sr(),Oo?Fn(dt):dt;function sr(){if(yr||Mn)return;let re=new Set(dt),$e=kt=>kt&&We.has(kt)&&re.has(ft.get(kt))?kt:null,Ue=(kt,Et)=>{let At=[{prev:null,units:[]}];for(let qt of kt){let Bn=$e(Et(qt));Bn?At.push({prev:Bn,units:[]}):At[At.length-1].units.push(qt)}return At},Ze=Ue(Re,kt=>kt),wt=Ue(ie.units,ie.baseOf),Ke=ee.asBase?null:Ue(ee.units,ee.baseOf),Ve=kt=>kt.length===Ze.length&&kt.every((Et,At)=>Et.prev===Ze[At].prev);if(!Ve(wt)||Ke&&!Ve(Ke))return;let mt=new Map(_t.map(kt=>[kt.bk,kt])),Qe=new Map(Pt.map(kt=>[kt.su,kt])),pt=kt=>kt?dt.indexOf(ft.get(kt)):-1;for(let kt=0;kt<Ze.length;kt++){if(Ze[kt].units.length!==1||wt[kt].units.length!==1)continue;let Et=mt.get(Ze[kt].units[0]),At=Qe.get(wt[kt].units[0]);if(!Et||!At||Ke&&(Ke[kt].units.length!==1||Ke[kt].units[0]!==Et.lk))continue;let qt=pt(Ze[kt].prev);(kt+1<Ze.length?pt(Ze[kt+1].prev):dt.length)-qt!==2||dt[qt+1]!==At.node||Co(Et.bk,Et.lk,At.su)&&rt.link(Et.lk,At.node)}}function xr(re,$e,Ue,Ze){let wt=At=>{let qt=At.filter(ut);return qt.length===1?qt[0]:null},Ke=wt(re),Ve=wt($e),mt=wt(Ue);if(!Ke||!Ve||!mt)return;let Qe=re.indexOf(Ke);if($e.indexOf(Ve)!==Qe||Ue.indexOf(mt)!==Qe||re.length!==$e.length||re.length!==Ue.length)return;for(let At=0;At<re.length;At++)if(At!==Qe&&(re[At].value!==$e[At].value||re[At].value!==Ue[At].value))return;if((ee.asBase?Ke:ee.twin(Ke))!==Ve||ie.twin(Ke)||z.reverse.get(mt)||Ve!==Ke&&H(Ke,Ve,B))return;let pt=Ze.filter(At=>At.nodeType===1);if(pt.length!==1||Te.get(pt[0])?.remote!==mt)return;let kt=At=>At.map(qt=>ut(qt)?"":qt.value??qt.nodeValue).join(""),Et=Ze.indexOf(pt[0]);kt(Ze.slice(0,Et))!==kt(re.slice(0,Qe))||kt(Ze.slice(Et+1))!==kt(re.slice(Qe+1))||Co(Ke,Ve,mt)&&rt.link(Ve,pt[0])}function Co(re,$e,Ue){if(!ut($e)||!ut(Ue)||!ut(re)||$e.namespaceURI!==Ue.namespaceURI||$e.localName===Ue.localName)return!1;for(let Ve of[$e,Ue])if(Ve.tagName==="TEMPLATE"||mn(Ve)||Ve.querySelector("template"))return!1;if(r.remoteWins(re)||r.remoteWins(Ue)||o(Ue)||$e.attributes.length!==Ue.attributes.length)return!1;for(let Ve of $e.attributes)if(Ue.getAttributeNS(Ve.namespaceURI,Ve.localName)!==Ve.value)return!1;let Ze=$e.childNodes,wt=Ue.childNodes;if(Ze.length!==wt.length)return!1;for(let Ve=0;Ve<Ze.length;Ve++)if(!Ze[Ve].isEqualNode(wt[Ve]))return!1;let Ke=[[re,Ue]];for(;Ke.length;){let[Ve,mt]=Ke.pop();if(Ve.children.length!==mt.children.length)return!1;for(let Qe=0;Qe<mt.children.length;Qe++){let pt=z.reverse.get(mt.children[Qe]);if(pt!==void 0&&pt!==Ve.children[Qe])return!1;Ke.push([Ve.children[Qe],mt.children[Qe]])}}return!0}function $r(re){let $e=[[]];for(let Ue of re)at(Ue)?$e[$e.length-1].push(Ue):$e.push([]);return $e}function Fn(re){let $e=$r(Re),Ue=(Qe,pt)=>{let kt=new Map,Et=Qe.filter(At=>!at(At));for(let At=0;At<Et.length;At++)kt.set(Et[At],pt[At+1]);return kt},Ze=Ue(Re,$e),wt=Ue(No,Gn),Ke=new Map;for(let[Qe,pt]of ft){if(!pt||Ke.has(pt))continue;let kt=Ze.get(Qe),Et=wt.get(Qe);(kt||Et)&&Ke.set(pt,[kt,Et])}let Ve=[],mt=_o($e[0],Gn[0]);mt&&Ve.push(mt);for(let Qe of re){Ve.push(Qe);let pt=Ke.get(Qe),kt=pt?_o(pt[0],pt[1]):null;kt&&Ve.push(kt)}return Ve}function _o(re,$e){let Ue=!!re&&re.length>0,Ze=Ue?re:$e||[],wt=Ze.map(mt=>mt.value).join("");if(wt==="")return null;let Ke=me.createTextNode(wt),Ve=mt=>{let Qe=[];for(let pt of mt||[])pt&&Qe.push(...pt.nodes);return Qe.length?Qe:null};return Te.set(Ke,Ue?{base:Ve(re),local:Ve(re.map(mt=>ee.asBase?null:ee.twin(mt))),remote:Ve(re.map(mt=>ie.asBase?null:ie.twin(mt)))}:{base:null,local:tn.side==="local"?Ve(Ze):null,remote:tn.side==="remote"?Ve(Ze):null}),Ke}function Mo(re){for(let $e=re-1;$e>=0;$e--){let Ue=ft.get(Re[$e]);if(Ue){let Ze=dt.indexOf(Ue);if(Ze>=0)return Ze+1}}return 0}function ps(re){if((ee.asBase||B.identical.has(R))&&(ie.asBase||z.identical.has(R)))return;let $e={ignored:o,remoteWins:r.remoteWins,inlineCache:Ee},Ue=vt=>ut(vt)?Vn(vt,$e):vt.kind==="text";if(!ee.asBase&&!ie.asBase)for(let vt of Re){if(!ut(vt)||!Ln.has(vt.tagName))continue;let b=ee.twin(vt),_=ie.twin(vt);if(!b&&_||b&&!_){let I=xc({base:Re,views:[{V:ee,A:B,idOf:g.local},{V:ie,A:z,idOf:g.remote}],eligible:j=>ut(j)&&Ln.has(j.tagName)&&!o(j)&&!r.remoteWins(j),baseId:g.base,ignored:o,remoteWins:r.remoteWins,atomKey:i.exactUnitKey});I&&(ee=I[0],ie=I[1]);break}}let Ze=!ee.asBase&&!ie.asBase&&Re.length>=2&&Ln.has(Re[0].tagName)&&ee.units.length===Re.length&&ie.units.length===Re.length?nc({base:Re,local:ee.units,remote:ie.units,localTwin:ee.twin,remoteTwin:ie.twin,eligible:vt=>ut(vt)&&Ln.has(vt.tagName)&&!o(vt)&&!r.remoteWins(vt),nodes:{base:Array.from(Se(R).childNodes),local:Array.from(Se(ee.el).childNodes),remote:Array.from(Se(ie.el).childNodes)}}):null,wt=null,Ke=null;if(!Ze&&!ee.asBase&&!ie.asBase&&(al(Re)||al(ee.units)||al(ie.units))){let vt={ignored:o,remoteWins:()=>!1},b=I=>Ue(I)||ut(I)&&r.remoteWins(I)&&wn.has(I.tagName)&&Vn(I,vt),_=I=>ut(I)?Ln.has(I.tagName)&&!o(I)&&!r.remoteWins(I)&&l(I).every(b):I.kind==="text";wt=wc({onUncertainOwner:I=>{let j=r.identity.local(I.local);j&&j===r.identity.remote(I.remote)||(Ke||=[]).push(I)},onUncertainSource:I=>{ot||(ot=new Map);let j=ot.get(I.source);j||ot.set(I.source,j=[]);for(let G of j)if(G.side===I.side&&G.from===I.from&&G.to===I.to)return;j.push(I)},base:Re,views:[{V:ee,A:B,idOf:g.local},{V:ie,A:z,idOf:g.remote}],eligible:_,ignored:o,remoteWins:r.remoteWins,baseId:g.base,atomKey:i.exactUnitKey})}if(Ke){Rt||=new Map;for(let vt of Ke){let{source:b,local:_,remote:I}=vt,j={map:new Map,reverse:new Map,identical:new Set},G=xt({base:[b],local:[_],remote:[I],out:me,policy:"both",L:j,R:j,ignored:o,remoteWins:r.remoteWins,atomKey:i.exactUnitKey,cloneUnit:W,provenance:Te,textMappers:Xe,conflicts:O,decisions:_e,conflict:(oe,be)=>Fe(oe,{...be,policy:"both"}),scope:{base:R,local:ee.el,remote:ie.el,units:Re,at:Je.get(b)},node:le});fe.push(...G.segments);for(let oe of[b,_,I])ae.add(oe),Ye.add(oe),Rt.set(oe,G.nodes),ft.set(oe,G.nodes[G.nodes.length-1]);for(let oe=0;oe<G.nodes.length;oe++)St.push({frag:G.nodes[oe],at:Je.get(b),previous:oe?G.nodes[oe-1]:null})}}let Ve=Ze?Ze.blocks:null;if(wt){Ve=new Set;for(let vt of wt.blocks)Ve.add(vt)}let mt=vt=>!et?.consumes(vt)&&(Ve&&Ve.has(vt)||Ue(vt)),Qe=Re.map(mt);if(!Qe.includes(!0))return;let pt=vt=>{let b=vt.units,_=new Map;for(let ye=0;ye<b.length;ye++)_.set(b[ye],ye);let I=[],j=-1;for(let ye=0;ye<Re.length;ye++){if(Qe[ye])continue;let Le=vt.twin(Re[ye]),pe=Le?_.get(Le):void 0;pe===void 0||pe<=j||mt(Le)||(I.push([ye,pe]),j=pe)}let G=[],oe=-1,be=-1;for(let ye=0;ye<=I.length;ye++){let[Le,pe]=ye<I.length?I[ye]:[Re.length,b.length],Ie={bLo:-1,bHi:-1,from:be+1,to:pe,inlineStart:-1,inlineEnd:-1,next:pe};for(let st=oe+1;st<Le;st++)Qe[st]&&(Ie.bLo<0&&(Ie.bLo=st),Ie.bHi=st);for(let st=be+1;st<pe;st++){let ct=b[st];mt(ct)&&(Ie.inlineStart<0&&(Ie.inlineStart=st),Ie.inlineEnd=st+1)}G.push(Ie),oe=Le,be=pe}return{units:b,list:G}},kt=pt(ee),Et=pt(ie),At=[];for(let vt of[kt,Et])for(let b of vt.list)b.bLo>=0&&At.push([b.bLo,b.bHi]);At.sort((vt,b)=>vt[0]-b[0]);let qt=[];for(let[vt,b]of At){let _=qt[qt.length-1];_&&vt<=_.hi?_.hi=Math.max(_.hi,b):qt.push({lo:vt,hi:b})}let Bn=(vt,b)=>vt.length===b.length&&vt.every((_,I)=>i.equalUnits(_,b[I])),ir=vt=>!ut(vt)&&vt.kind==="comment",Ur=vt=>{if(!vt.length)return[];let b=(oe,be)=>ut(oe)?oe:oe.nodes[be?oe.nodes.length-1:0],_=b(vt[0]),I=b(vt[vt.length-1],!0),j=oe=>oe&&ut(oe)&&o(oe);for(;j(_.previousSibling);)_=_.previousSibling;for(;j(I.nextSibling);)I=I.nextSibling;let G=[];for(let oe=_;oe&&(G.push(oe),oe!==I);oe=oe.nextSibling);return G},Ti=vt=>vt.some(b=>ut(b)&&o(b));for(let vt of qt){let b=Re.slice(vt.lo,vt.hi+1);if(re&&!b.some(Le=>mt(Le)&&!at(Le)))continue;let _=null;if(wt)for(let Le of b){let pe=wt.certificatesBySource.get(Le);pe&&(_||=[]).push(...pe)}let I=ee.asBase?null:ll(kt,vt),j=ie.asBase?null:ll(Et,vt);if(_){let Le=[new Set(I||b),new Set(j||b)],pe=_.some(Ie=>!Le[Ie.side].has(Ie.target));for(let Ie of b)if(Ve.has(Ie))for(let[st,ct]of[[0,ee],[1,ie]]){let gt=ct.twin(Ie);gt&&ct.here(gt)&&!Le[st].has(gt)&&(pe=!0)}if(pe)continue}if(b.some(ir)||I&&I.some(ir)||j&&j.some(ir))continue;let G=Ur(I||b),oe=Ur(j||b);if((!I||Bn(b,I))&&(!j||Bn(b,j))&&!(I&&Ti(G)))continue;let be=xt({base:Ur(b),sourceRetentions:ot?.get(R),local:G,remote:oe,out:me,policy:nt,blocks:Ve,scopeUnits:_?[b,I||b,j||b]:null,certifiedOrigins:_?(Le,pe,Ie,st,ct,gt)=>Sc({certificates:_,scopes:[b,I||b,j||b],flats:[Le,pe,Ie],keys:[st,ct,gt]}):null,prepared:Ze?Ze.prepared:null,nativeTransfers:Ze,L:I?B:Ac(B,R),R:j?z:Ac(z,R),idOf:{base:p,local:h,remote:v},ignored:o,ignoreAttribute:r.ignoreAttribute,remoteWins:r.remoteWins,mergeElement:(Le,pe,Ie)=>D(Le,pe,Ie,!1),cloneUnit:W,mergeAttrs:Oe,atomKey:i.exactUnitKey,moveIn:M,moveBuilt:M,movePlanned:M,provenance:Te,textMappers:Xe,conflicts:O,conflict:Fe,scope:{base:R,local:ee.asBase?null:ee.el,remote:ie.asBase?null:ie.el,units:Re,at:vt.lo},decisions:_e,node:le});if(!be){if(_){let Le=rc({certificates:_,scopes:[b,I||b,j||b],views:[{V:ee,A:B,idOf:g.local},{V:ie,A:z,idOf:g.remote}],eligible:pe=>ut(pe)&&Ln.has(pe.tagName)&&!o(pe)&&!r.remoteWins(pe),baseId:g.base});for(let pe of Le.records){ot||=new Map;let Ie=ot.get(pe.source);Ie||ot.set(pe.source,Ie=[]),Ie.push(pe)}}continue}if(fe.push(...be.segments),Ze){let Le=new Map;for(let pe of be.nodes){let Ie=Te.get(pe)?.base;if(!Ie||Le.has(Ie))throw new Error("Invalid native transfer owner output");Le.set(Ie,pe)}if(Le.size!==Ze.owners.length)throw new Error("Incomplete native transfer owner output");for(let pe of Ze.owners){let Ie=Le.get(pe.base);if(!Ie)throw new Error("Missing native transfer owner output");for(let st of[pe.base,pe.local,pe.remote])ae.add(st),Ye.add(st),ft.set(st,Ie);St.push({frag:Ie,at:Je.get(pe.base)})}continue}if(rt&&xr(b,I||b,j||b,be.nodes),be.unitOutputs){Rt||=new Map;for(let pe of[...b,...I||[],...j||[]]){let Ie=be.unitOutputs.get(pe)||[];ae.add(pe),Ye.add(pe),Rt.set(pe,Ie),Ie.length&&ft.set(pe,Ie[Ie.length-1])}let Le=be.nodes[be.nodes.length-1];if(Le)for(let pe of[I||b,j||b]){let Ie=pe[pe.length-1];Ie&&Ut.set(Ie,Le)}for(let pe=0;pe<be.nodes.length;pe++)St.push({frag:be.nodes[pe],at:vt.lo,previous:pe>0?be.nodes[pe-1]:null});continue}rt&&xr(b,I||b,j||b,be.nodes);let ye=me.createDocumentFragment();for(let Le of be.nodes)ye.appendChild(Le);for(let Le of[...b,...I||[],...j||[]])ae.add(Le),Ye.add(Le),ft.set(Le,ye);St.push({frag:ye,at:vt.lo})}}}function Ne(R,J){let ue=Te.get(R);return ue&&ue.unchanged?!ue.remote||ue.remote===J?!0:Pe(ue.remote,J):R.tagName!==J.tagName||!tt(R,J)?!1:lt(Se(R),Se(J))}function Pe(R,J){return R===J?!0:R.tagName!==J.tagName||R.namespaceURI!==J.namespaceURI||!tt(R,J)?!1:De(Se(R),Se(J))}function De(R,J){let ue=it(R,o),he=it(J,o);if(ue.length!==he.length)return!1;for(let le=0;le<ue.length;le++){let ee=ue[le],ie=he[le];if(typeof ee=="string"||typeof ie=="string"){if(ee!==ie)return!1}else{if(ee.nodeType!==ie.nodeType)return!1;if(ee.nodeType===1){if(!Pe(ee,ie))return!1}else if(ee.nodeValue!==ie.nodeValue)return!1}}return!0}function Se(R){return R.tagName==="TEMPLATE"&&R.content?R.content:R}function tt(R,J){let ue=0;for(let he of R.attributes)if(!r.ignoreAttribute(R,he.name)&&(ue++,J.getAttribute(he.name)!==he.value))return!1;for(let he of J.attributes)r.ignoreAttribute(J,he.name)||ue--;return ue===0}function lt(R,J){let ue=it(R,le=>{let ee=Te.get(le);return!!(ee&&ee.pinned)}),he=it(J,o);if(ue.length!==he.length)return!1;for(let le=0;le<ue.length;le++){let ee=ue[le],ie=he[le];if(typeof ee=="string"||typeof ie=="string"){if(ee!==ie)return!1}else{if(ee.nodeType!==ie.nodeType)return!1;if(ee.nodeType===1){if(!Ne(ee,ie))return!1}else if(ee.nodeValue!==ie.nodeValue)return!1}}return!0}function it(R,J){let ue=[],he=null;for(let le=R.firstChild;le;le=le.nextSibling){if(le.nodeType===3){he=he===null?le.nodeValue:he+le.nodeValue;continue}le.nodeType===1&&J(le)||(he!==null&&(he!==""&&ue.push(he),he=null),ue.push(le))}return he!==null&&he!==""&&ue.push(he),ue}function Ht(R,J,ue,he){let le=R.value,ee=he?le:J?J.value:"",ie=ue?ue.value:"";ae.add(R),J&&ae.add(J),ue&&ae.add(ue);let Re=ee===ie?ee:ee===le?ie:ie===le||nt==="local"?ee:ie,We={site:"comment",bRun:R,lRun:J,rRun:ue,node:null};if(ee!==le&&ie!==le&&ee!==ie&&Fe({kind:"text",node:null,base:le,local:ee,remote:ie,resolved:Re},We),!J&&!ue)return null;let Je=me.createComment(Re);return We.node=Je,Te.set(Je,{base:R.nodes,local:J?J.nodes:null,remote:ue?ue.nodes:null}),Je}function Lt(R,J){let ue=y(J,R);if(!ue)return null;let he=ut(ue)?ue.parentNode:ue.parent,le=ut(R)?R.parentNode:R.parent;return y(J,le)===he?null:J.reverse.get(he)||null}function Zt(R){let J=new Set([R]),ue=R;for(let he=0;he<64;he++){let le=Lt(ue,B)||Lt(ue,z);if(!le)return!1;if(le===R||ut(R)&&ut(le)&&R.contains(le)||J.has(le))return!0;J.add(le),ue=le}return!0}function Bt(R,J,ue){if(!J)return!1;let he=ut(R)?R.parentNode:R.parent;return he===J||J.tagName==="TEMPLATE"&&he===J.content}function Wt(R,J){let ue=Be(R),he=y(B,ue);if(he&&Bt(J,he,B))return!0;let le=y(z,ue);return!!(le&&Bt(J,le,z))}}function Ac(e,t){return e.map.get(t)?Ec():{map:{get:r=>r&&r.nodeType===1&&e.map.get(r)||r,has:()=>!0},reverse:{get:r=>e.reverse.get(r)||r,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Ec(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function tm(e){let t=[],n=[],r=new Array(e.length).fill(-1);for(let s=0;s<e.length;s++){let i=0,l=t.length;for(;i<l;){let a=i+l>>1;t[a]<e[s]?i=a+1:l=a}t[i]=e[s],n[i]=s,r[s]=i>0?n[i-1]:-1}let o=new Set;for(let s=n[t.length-1];s!==void 0&&s>=0;s=r[s])o.add(s);return o}function Tc(e){let t=[],n=new Array(e.length);for(let r=0;r<e.length;r++){let o=0,s=t.length;for(;o<s;){let i=o+s>>1;t[i]<e[r]?o=i+1:s=i}t[o]=e[r],n[r]=o+1}return n}function cl(e){let t=Tc(e),n=Tc(e.map(i=>-i).reverse()).reverse(),r=0;for(let i=0;i<t.length;i++)t[i]>r&&(r=t[i]);let o=new Map;for(let i=0;i<e.length;i++)t[i]+n[i]-1===r&&o.set(t[i],(o.get(t[i])||0)+1);let s=new Set;for(let i=0;i<e.length;i++)(!(t[i]+n[i]-1===r)||o.get(t[i])>1)&&s.add(e[i]);return s}function nm(e,t,n,r){let o=g=>{let d=tm(g.map(k=>t.get(k)));return new Set(g.filter((k,S)=>!d.has(S)))},s=o(n),i=o(r);for(let g of s)if(i.has(g))return null;let l=new Set(n),a=new Set(r),c=e.filter(g=>l.has(g)&&a.has(g)&&!s.has(g)&&!i.has(g)),m=new Set(c),u=(g,d)=>{let k=new Map,S=null;for(let x of g){if(m.has(x)){S=x;continue}d.has(x)&&(k.has(S)||k.set(S,[]),k.get(S).push(x))}return k},f=(g,d)=>cl(g.map(k=>t.get(k))).size>d.size,p=[{at:u(r,i),ambiguous:f(r,i)},{at:u(n,s),ambiguous:f(n,s)}],h=g=>p.map(d=>{let k=d.at.get(g);return k?{group:k,ambiguous:d.ambiguous}:null}).filter(Boolean).sort((d,k)=>d.ambiguous-k.ambiguous||t.get(d.group[0])-t.get(k.group[0])).flatMap(d=>d.group),v=h(null);for(let g of c)v.push(g,...h(g));return new Map(v.map((g,d)=>[g,d]))}function rm(e,t){let n=[],r=new Map,o=null;for(let l of e.units){let a=e.baseOf(l);if(a&&t.has(a)){o=l,r.set(l,[]);continue}(o?r.get(o):n).push(l)}let s=[...r.keys()].sort((l,a)=>t.get(e.baseOf(l))-t.get(e.baseOf(a))),i=l=>{let a=[],c=[],m=()=>{c.length&&a.push(...c.sort((u,f)=>_s(u)<_s(f)?-1:1)),c=[]};for(let u of l){if(e.baseOf(u)){m(),a.push(u);continue}c.push(u)}return m(),a};return{...e,units:[...i(n),...s.flatMap(l=>[l,...i(r.get(l))])]}}var Oc=new Set(["INPUT","OPTION","TEXTAREA"]),fl=/[\t\n\f\r ]+/;function Nc(e,t,n,r){let o=e.ownerDocument,{provenance:s,textMappers:i}=n,l=r.hooks,a=[],c=[],m=[],u=new Set,f=[],p=[],h=new Map,v=new Set,g=new Map,d=n.conflicts.length>0||r.trackInserted===!0,k=new Map,S=new Set,x=new Map,w=(y,M)=>{let P=x.get(y);P||x.set(y,P=new Set),P.add(M)},T=d?new Set:null,N=(y,M,P)=>{let H=l.beforeAttributeUpdated(y,M,P);return d&&H===!1&&w(M,y),H},C=y=>!!y&&(y===e||e.contains(y)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(y)),L=new Map,q=new Map,V=new Map,U=new Set,F=new Map;(function y(M){let P=s.get(M);if(P){if(M.nodeType===1){let Q=P.local?r.toLive(P.local):null;Q&&C(Q)&&Q.nodeType===1&&(L.set(M,Q),q.set(Q,M))}else if(Array.isArray(P.local)){let Q=z(P.local,P.local.map(D=>r.toLive(D)).filter(D=>D&&C(D)&&D.nodeType===M.nodeType));if(Q.length&&(L.set(M,Q[0]),q.set(Q[0],M),V.set(M,Q)),Array.isArray(P.caret))for(let D of P.caret){let ge=r.toLive(D.node);if(!ge||!C(ge)||ge.nodeType!==3)continue;let xe=F.get(ge);Array.isArray(xe)||F.set(ge,xe=[]),xe.push({merged:M,from:D.from,to:D.to,flatStart:D.flatStart})}else{let D=0;for(let ge of Q)F.set(ge,{merged:M,shift:D}),D+=ge.nodeValue.length}}}let H=M.nodeType===1&&M.tagName==="TEMPLATE"&&M.content?M.content.childNodes:M.childNodes;for(let Q of H)y(Q)})(t);let A=new Set;for(let y of L.values())A.add(y);for(let y of V.values())for(let M of y)A.add(M);let E=r.localRoot&&r.localRoot!==e?new Set:null;if(E){for(let y=r.localRoot.firstElementChild;y;y=y.nextElementSibling)if(y.tagName==="HEAD")for(let M=y.firstElementChild;M;M=M.nextElementSibling){let P=r.toLive(M);P&&E.add(P)}}for(let y of n.segments||[])Ce(y);let X=r.restoreFocus===!1?null:om(o,F);r.childrenOnly?Te(Me(e),Me(t)):Be(e,t);for(let{node:y,parent:M}of f)u.has(y)||!y.parentNode||y.nodeType===1&&(r.ignored(y)||Xe(y))||ot(y,M);return sm(o,X,F,i,V,g,U),{applied:a,moved:c,replaced:m,identities:p,mergedScriptsLive:v,liveOf:L,heldBy:g,runOf:V,keptRuns:U,insertedLive:k,vetoed:S,vetoedAttrs:x,removedVetoes:T};function B(y,M){let P=y.slice(M.bs,M.be),H=0;for(;H<P.length&&H<M.text.length&&P[H]===M.text[H];)H++;let Q=0;for(;Q<P.length-H&&Q<M.text.length-H&&P[P.length-1-Q]===M.text[M.text.length-1-Q];)Q++;return{bs:M.bs+H,be:M.be-Q,text:M.text.slice(H,M.text.length-Q)}}function z(y,M){if(!M.length)return M;let P=[];for(let D of y){let ge=D.parentNode;if(!ge)continue;let xe=h.get(ge);if(!xe){xe=new Set;for(let de=ge.firstChild;de;de=de.nextSibling)de.nodeType===3&&xe.add(r.toLive(de));h.set(ge,xe)}P.includes(xe)||P.push(xe)}let H={has:D=>P.some(ge=>ge.has(D))},Q=[];for(let D of M){Q.push(D);for(let ge=D.nextSibling;ge&&ge.nodeType===3&&!H.has(ge)&&!Q.includes(ge);ge=ge.nextSibling)Q.push(ge)}return Q}function Ce(y){let M=[];for(let ne of y.localNodes){let se=r.toLive(ne.node);if(!se||!C(se)||se.nodeType!==3)return;M.push(se)}let P=z(y.localNodes.map(ne=>ne.node),M);if(!P.length)return;let H=P.map(ne=>ne.nodeValue).join(""),{flatLocal:Q,lToM:D,mapLocal:ge}=y;if(H===Q)return;let xe=y.textNodes.map(ne=>({node:ne.node,ms:ne.ms,me:ne.me})),de=[],Oe=0;for(let ne of P)de.push(Oe),Oe+=ne.nodeValue.length;let $=(ne,se)=>P.find((W,ce)=>de[ce]<=ne&&ne+se<=de[ce]+W.nodeValue.length)||null,Z=[],ke=0;for(let ne of Ar(Q,H).map(se=>B(Q,se))){let se=ne.bs+ke;ke+=ne.text.length-(ne.be-ne.bs);let W,ce;if(ne.be>ne.bs){W=D[ne.bs];let Ne=W>=0;for(let Pe=ne.bs;Ne&&Pe<ne.be;Pe++)D[Pe]!==W+(Pe-ne.bs)&&(Ne=!1);if(!Ne)continue;ce=W+(ne.be-ne.bs)}else{let Ne=ne.bs>0?D[ne.bs-1]:0,Pe=ne.bs<Q.length?D[ne.bs]:0;if(Ne<0||Pe<0)continue;W=ce=ge(ne.bs)}Z.push({ms:W,me:ce,text:ne.text,live:ce===W?$(se,ne.text.length):null})}Z.sort((ne,se)=>se.ms-ne.ms);let we=(ne,se)=>(V.get(ne.node)||[L.get(ne.node)]).includes(se),ve=ne=>!!ne&&ne.nodeType===1&&wn.has(ne.tagName);for(let ne of Z){let se=xe.find(ce=>ce.ms<=ne.ms&&ne.me<=ce.me&&ne.ms<ce.me);if(se&&ne.live&&se.ms===ne.ms&&!we(se,ne.live)){let ce=xe.find(Ne=>Ne.me===ne.ms&&we(Ne,ne.live));ce&&(se=ce)}if(!se&&ne.me===ne.ms){let ce=xe.find(Se=>Se.me===ne.ms),Ne=xe.find(Se=>Se.ms===ne.ms),Pe=ce||Ne;if(!Pe)continue;let De=Pe.node;for(;ve(De.parentNode)&&(ce?De.parentNode.lastChild:De.parentNode.firstChild)===De;)De=De.parentNode;if(De===Pe.node)se=Pe;else{let Se=De.ownerDocument.createTextNode(ne.text);De.parentNode.insertBefore(Se,ce?De.nextSibling:De);continue}}if(!se)continue;let W=se.node.nodeValue;se.node.nodeValue=W.slice(0,ne.ms-se.ms)+ne.text+W.slice(ne.me-se.ms),se.me+=ne.text.length-(ne.me-ne.ms)}}function Me(y){return y.nodeType===1&&y.tagName==="TEMPLATE"&&y.content?y.content:y}function Be(y,M){u.add(y);let P=s.get(M);if(P&&P.remote&&n.remoteIdOf){let Q=n.remoteIdOf(P.remote);Q&&p.push([y,Q])}if(P&&P.unchanged){r.opaque&&r.opaque(y)||(n.customIdentity&&P.remote&&fe(y,P.remote),P.remote&&K(y,P.remote));return}if(l.beforeNodeMorphed(y,M)===!1){S.add(M);return}je(y,M,r.keepLiveOnly&&P&&P.local&&P.local.nodeType===1&&P.local!==y?P.local:null);let H=y.tagName;if(mn(y))y.textContent!==M.textContent&&(a.push({kind:"text",node:y,before:y.textContent,after:M.textContent}),y.textContent=M.textContent),n.mergedScripts.has(M)&&v.add(y);else if(H==="TEXTAREA")Y(y,M,P);else{Tt(y,M,P);let Q=H==="TEMPLATE"&&y.content?y.content:y,D=H==="TEMPLATE"&&M.content?M.content:M;r.opaque&&r.opaque(y)||r.protectFocusedValue==="subtree"&&He(y)&&y!==o.body?me(Q):Te(Q,D)}l.afterNodeMorphed(y,M)}function me(y){for(let M=y.firstChild;M;M=M.nextSibling){let P=q.get(M);P&&L.get(P.parentNode)!==y||(u.add(M),M.nodeType===1&&me(M))}}function Te(y,M){let P=ze(y.firstChild),H=new Set;for(let Q of Array.from(M.childNodes)){let D=L.get(Q);D&&u.has(D)&&!H.has(D)&&(D=null);let ge=s.get(Q);if(ge&&ge.pinned){D&&D.nodeType===1&&((D.parentNode!==y||ze(D.nextSibling)!==P)&&Ee(y,D,P),u.add(D),H.add(D));continue}if(D&&D.nodeType===1){if(D!==P){let Oe=D.parentNode;if(Oe===y&&P&&et(D)){let $=D.nextSibling;for(let Z=P;Z&&Z!==D;){let ke=Z.nextSibling;Ee(y,Z,$),Z=ke}}else Ee(y,D,P),Oe!==y&&(c.push(D),a.push({kind:"move",el:D,from:Oe,to:y}))}H.add(D),Be(D,Q),P=ze(D.nextSibling);continue}if(D&&D.nodeType!==1){let Oe=V.get(Q)||[D],$=Oe.map(ke=>ke.nodeValue).join(""),Z=Q.nodeValue;if(Q.nodeType===3){let ke=_e(Q);ke!=null&&$!==ke&&(Z=Po(ke,$,Q.nodeValue).text)}if(Oe.length>1&&$===Z&&!Oe.includes(P,1)&&Oe.every((ke,we)=>ke.parentNode===y&&(we===0||Oe[we-1].nextSibling===ke))){if(D!==P)for(let ke of Oe)Ee(y,ke,P);l.beforeNodeMorphed(D,Q)!==!1?l.afterNodeMorphed(D,Q):d&&S.add(Q);for(let ke of Oe)u.add(ke),H.add(ke);g.set(Q,D),U.add(Q),P=ze(Oe[Oe.length-1].nextSibling);continue}D!==P&&Ee(y,D,P),l.beforeNodeMorphed(D,Q)!==!1?(D.nodeValue!==Z&&(a.push({kind:"text",node:D,before:D.nodeValue,after:Z}),D.nodeValue=Z),l.afterNodeMorphed(D,Q)):S.add(Q),u.add(D),H.add(D),g.set(Q,D),P=ze(D.nextSibling);continue}if(Q.nodeType===3&&P&&P.nodeType===3&&!u.has(P)&&!F.has(P)){P.nodeValue!==Q.nodeValue&&(a.push({kind:"text",node:P,before:P.nodeValue,after:Q.nodeValue}),P.nodeValue=Q.nodeValue),u.add(P),g.set(Q,P),P=ze(P.nextSibling);continue}let xe=s.get(Q),de=rt(xe&&xe.unchanged&&xe.remote?xe.remote:Q);if(l.beforeNodeAdded(de)===!1){S.add(Q);continue}y.insertBefore(de,P),u.add(de),d&&k.set(Q,de),de.nodeType===3&&g.set(Q,de),de.nodeType===1&&(m.push(de),qe(de,Q),n.customIdentity&&xe&&xe.unchanged&&xe.remote&&fe(de,xe.remote),mn(de)||xt(de,Q),r.formState==="property"&&Ct(xe)&&K(de,xe.remote)),P=ze(de.nextSibling),a.push({kind:"insert",node:de,parent:y}),l.afterNodeAdded(de)}for(let Q of Array.from(y.childNodes))u.has(Q)||H.has(Q)||Q.nodeType===1&&(r.ignored(Q)||Xe(Q))||(A.has(Q)?f.push({node:Q,parent:y}):ot(Q,y))}function Xe(y){return y.parentNode&&y.parentNode.nodeType===1&&y.parentNode.tagName==="HEAD"&&(E&&!E.has(y)||r.preserve&&r.preserve(y)===!0)}function _e(y){let M=s.get(y);return!M||!Array.isArray(M.local)?null:M.local.map(P=>P.nodeValue).join("")}function O(y){return s.get(y)}function K(y,M){if(!Oc.has(y.tagName)&&!y.querySelector("input,option,textarea"))return;let P=(H,Q)=>{if(H.tagName!==Q.tagName||(H.tagName==="TEXTAREA"?Y(H,Q,{remote:Q}):Oc.has(H.tagName)&&Tt(H,Q,{remote:Q}),r.opaque&&r.opaque(H)))return;let D=ae(H),ge=ae(Q);if(D.length===ge.length)for(let xe=0;xe<D.length;xe++)P(D[xe],ge[xe])};P(y,M)}function fe(y,M){if(r.opaque&&r.opaque(y))return;let P=ae(y),H=ae(M);if(P.length===H.length)for(let Q=0;Q<P.length;Q++){let D=n.remoteIdOf(H[Q]);D&&p.push([P[Q],D]),fe(P[Q],H[Q])}}function ae(y){let M=y.tagName==="TEMPLATE"&&y.content?y.content:y;return Array.from(M.children).filter(P=>!r.ignored(P))}function qe(y,M){if(!n.remoteIdOf)return;let P=(H,Q)=>{let D=s.get(Q);if(D&&D.remote&&Q.nodeType===1){let de=n.remoteIdOf(D.remote);de&&p.push([H,de])}let ge=H.childNodes,xe=Q.childNodes;for(let de=0;de<ge.length&&de<xe.length;de++)P(ge[de],xe[de])};P(y,M)}function ze(y){for(;y&&y.nodeType===1&&r.ignored(y);)y=y.nextSibling;return y}function Ee(y,M,P){if(typeof y.moveBefore=="function"&&M.ownerDocument===y.ownerDocument)try{y.moveBefore(M,P);return}catch{}y.insertBefore(M,P)}function ot(y,M){if(l.beforeNodeRemoved(y)===!1){d&&T.add(y);return}y.parentNode.removeChild(y),a.push({kind:"remove",node:y,parent:M}),l.afterNodeRemoved(y)}function rt(y){if(mn(y))return Do(y,o);let M=o.importNode(y,!0);if(M.nodeType===1)for(let P of Array.from(M.querySelectorAll("script")))mn(P)&&P.replaceWith(Do(P,o));return M}function xt(y,M){let P=y.tagName==="TEMPLATE"&&y.content?y.content:y,H=M.tagName==="TEMPLATE"&&M.content?M.content:M,Q=Array.from(P.childNodes),D=Array.from(H.childNodes);for(let ge=0;ge<D.length&&ge<Q.length;ge++){let xe=D[ge],de=Q[ge],Oe=L.get(xe);Oe&&u.has(Oe)&&(Oe=null);let $=s.get(xe);if($&&$.pinned){if(Oe&&Oe.nodeType===1){let Z=Oe.parentNode;Ee(P,Oe,de),Z!==P&&(c.push(Oe),a.push({kind:"move",el:Oe,from:Z,to:P})),u.add(Oe)}de.remove();continue}if(Oe){let Z=Oe.parentNode;Ee(P,Oe,de),de.remove(),Oe.nodeType===1?(Z!==P&&(c.push(Oe),a.push({kind:"move",el:Oe,from:Z,to:P})),Be(Oe,xe)):(u.add(Oe),g.set(xe,Oe),Oe.nodeValue!==xe.nodeValue&&(a.push({kind:"text",node:Oe,before:Oe.nodeValue,after:xe.nodeValue}),Oe.nodeValue=xe.nodeValue));continue}u.add(de),d&&k.set(xe,de),de.nodeType===3&&g.set(xe,de),$&&$.unchanged&&$.remote?(nt(de,$.remote),n.customIdentity&&fe(de,$.remote)):xe.nodeType===1&&!mn(xe)&&xt(de,xe)}}function nt(y,M){let P=y.tagName==="TEMPLATE"&&y.content?y.content:y,H=M.tagName==="TEMPLATE"&&M.content?M.content:M;for(let Q of Array.from(H.childNodes))P.appendChild(rt(Q))}function te(y,M){return M.namespaceURI?y.getAttributeNS(M.namespaceURI,M.localName):y.getAttribute(M.name)}function Ae(y,M){let P=new Set((M||"").split(fl).filter(Boolean));return(y||"").split(fl).filter(H=>H&&!P.has(H))}function je(y,M,P){for(let H of Array.from(M.attributes)){if(Fe(y,H.name)||r.ignoreAttribute(y,H.name,M))continue;let Q=te(y,H);if(Q===H.value||P&&te(P,H)===H.value)continue;let D=H.value;if(P&&H.name==="class"&&!H.namespaceURI){let ge=H.value.split(fl).filter(Boolean),xe=Ae(Q,P.getAttribute("class")).filter(de=>!ge.includes(de));xe.length&&(D=[...ge,...xe].join(" "))}if(Q!==D){if(l.beforeAttributeUpdated(H.name,y,"update")===!1){d&&w(M,H.name);continue}H.namespaceURI?y.setAttributeNS(H.namespaceURI,H.name,D):y.setAttribute(H.name,D),a.push({kind:"attr",el:y,name:H.name,before:Q,after:D})}}for(let H of Array.from(y.attributes)){if(Fe(y,H.name)||r.ignoreAttribute(y,H.name,M)||(H.namespaceURI?M.hasAttributeNS(H.namespaceURI,H.localName):M.hasAttribute(H.name)))continue;if(P&&H.name==="class"&&!H.namespaceURI){let ge=Ae(H.value,P.getAttribute("class"));if(ge.length){let xe=ge.join(" ");if(xe===H.value)continue;if(l.beforeAttributeUpdated("class",y,"update")===!1){d&&w(M,"class");continue}y.setAttribute("class",xe),a.push({kind:"attr",el:y,name:"class",before:H.value,after:xe});continue}}if(P&&te(P,H)===null&&!r.ignoreAttribute(P,H.name))continue;if(l.beforeAttributeUpdated(H.name,y,"remove")===!1){d&&w(M,H.name);continue}let D=H.value;H.namespaceURI?y.removeAttributeNS(H.namespaceURI,H.localName):y.removeAttribute(H.name),a.push({kind:"attr",el:y,name:H.name,before:D,after:null})}}function Fe(y,M){let P=y.tagName;return P==="INPUT"?M==="value"||M==="checked"||M==="disabled":P==="OPTION"?M==="selected":!1}function He(y){return y===o.activeElement}function et(y){let M=o.activeElement;return!!M&&M!==o.body&&y.contains(M)}function bt(y,M){let P=M&&M.local&&M.local.nodeType===1&&M.local!==y?M.local:null;if(!P)return!0;let H=y.tagName==="TEXTAREA"?P.textContent:P.getAttribute("value")??"";return y.value!==H}function Ft(y,M){return!!r.protectFocusedValue&&He(y)&&bt(y,M)}function yt(y,M,P){let H=Math.min(y.length,M.length),Q=0;for(;Q<H&&y[Q]===M[Q];)Q++;if(P<=Q)return P;let D=0;for(;D<H-Q&&y[y.length-1-D]===M[M.length-1-D];)D++;return P>=y.length-D?P+M.length-y.length:M.length-D}function It(y){try{return y.selectionStart==null?null:[y.selectionStart,y.selectionEnd,y.selectionDirection]}catch{return null}}function en(y,M,P,H){try{y.setSelectionRange(yt(M,P,H[0]),yt(M,P,H[1]),H[2]||"none")}catch{}}function Ge(y,M){let P=y.value,H=It(y);y.value=M,H&&en(y,P,M,H)}function Ct(y){let M=y&&y.remote;return M&&M.nodeType===1?M:null}function Tt(y,M,P){let H=y.tagName,Q=Ct(P),D=r.formState==="property"&&Q?Q:M;if(H==="INPUT"){let ge=Ft(y,P),xe=(y.getAttribute("type")||"").toLowerCase(),de=xe!=="file"&&xe!=="checkbox"&&xe!=="radio",Oe=Q&&Q.hasAttribute("value")&&Q.value!==Q.getAttribute("value")?Q.value:null;if(de&&!ge)if(r.formState==="property"){let $=M.getAttribute("value"),Z=y.getAttribute("value");(Z!==$||y.value!==D.value)&&N("value",y,$==null?"remove":"update")!==!1&&(Z!==$&&($==null?y.removeAttribute("value"):y.setAttribute("value",$),a.push({kind:"attr",el:y,name:"value",before:Z,after:$})),y.value!==D.value&&(He(y)?Ge(y,D.value):y.value=D.value))}else if(M.hasAttribute("value")||Oe!=null){let $=Oe??M.getAttribute("value");y.getAttribute("value")!==$&&N("value",y,"update")!==!1?(y.setAttribute("value",$),y.value!==$&&(He(y)?Ge(y,$):y.value=$),a.push({kind:"attr",el:y,name:"value",before:null,after:$})):y.value!==$&&y.getAttribute("value")===$&&(He(y)?Ge(y,$):y.value=$)}else(y.hasAttribute("value")||y.value!=="")&&N("value",y,"remove")!==!1&&(y.removeAttribute("value"),y.value="",a.push({kind:"attr",el:y,name:"value",before:"",after:null}));if(!de&&xe!=="file"){let $=M.getAttribute("value");$==null?y.hasAttribute("value")&&N("value",y,"remove")!==!1&&y.removeAttribute("value"):y.getAttribute("value")!==$&&N("value",y,"update")!==!1&&y.setAttribute("value",$)}r.protectFocusedValue&&He(y)||(Jt(y,D,"checked"),r.formState==="property"&&y.indeterminate!==D.indeterminate&&(y.indeterminate=D.indeterminate)),Jt(y,D,"disabled")}else if(H==="OPTION"){let ge=y.parentNode&&y.closest("select");r.protectFocusedValue&&ge&&He(ge)||Jt(y,D,"selected")}}function Jt(y,M,P){if(r.ignoreAttribute(y,P,M))return;let H=r.formState==="property"?!!M[P]:M.hasAttribute(P);if(r.formState!=="property"){let Q=y.hasAttribute(P);if(Q!==H){if(N(P,y,H?"update":"remove")===!1)return;H?y.setAttribute(P,""):y.removeAttribute(P),a.push({kind:"attr",el:y,name:P,before:Q?"":null,after:H?"":null})}}y[P]!==H&&(y[P]=H)}function Y(y,M,P){if(Ft(y,P)||N("value",y,"update")===!1)return;let H=Ct(P),Q=M.textContent,D=H&&H.value!==H.defaultValue?H.value:Q,ge=He(y)?It(y):null,xe=y.value;if(r.formState!=="property"&&y.textContent!==Q){a.push({kind:"text",node:y,before:y.textContent,after:Q});let de=y.firstChild;de&&de.nodeType===3&&!de.nextSibling?de.data=Q:y.textContent=Q}y.value!==D&&(y.value=D),ge&&y.value!==xe&&en(y,xe,y.value,ge)}}function om(e,t){let n=e.activeElement;if(!n||n===e.body||n===e.documentElement)return null;let r={el:n,id:n.getAttribute&&n.getAttribute("id"),scrollTop:n.scrollTop,scrollLeft:n.scrollLeft};if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"){try{r.selection=[n.selectionStart,n.selectionEnd,n.selectionDirection]}catch{}return r}let o=e.getSelection&&e.getSelection();if(o&&o.rangeCount){let s=o.getRangeAt(0);r.range={sc:s.startContainer,so:s.startOffset,ec:s.endContainer,eo:s.endOffset}}return r}function sm(e,t,n,r,o,s,i){if(!t)return;let l=t.el;if(!l.isConnected&&t.id&&(l=e.getElementById(t.id)),!l||!l.isConnected)return;if(e.activeElement!==l)try{l.focus({preventScroll:!0})}catch{}try{l.scrollTop=t.scrollTop,l.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{l.setSelectionRange&&!l.selectionEnd&&t.selection[1]!=null&&l.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let a=(u,f)=>{let p=n.get(u);if(Array.isArray(p)){let h=p.find(k=>f>=k.from&&f<k.to)||p.find(k=>f===k.to)||p[p.length-1],v=s.get(h.merged);if(!v||!v.isConnected)return null;let g=r.get(h.merged),d=g&&g.flat?g.flat(h.flatStart+f):f;return[v,Math.max(0,Math.min(d,v.nodeValue.length))]}if(p&&!i.has(p.merged)){let h=(o.get(p.merged)||[u])[0];if(!h.isConnected)return null;let v=r.get(p.merged),g=p.shift+f,d=v?v(g):g;return[h,Math.max(0,Math.min(d,h.nodeValue.length))]}return u.isConnected?[u,Math.min(f,u.nodeType===3?u.nodeValue.length:u.childNodes.length)]:null},c=a(t.range.sc,t.range.so),m=a(t.range.ec,t.range.eo);if(!(!c||!m))try{let u=e.createRange();u.setStart(c[0],c[1]),u.setEnd(m[0],m[1]);let f=e.getSelection();f.removeAllRanges(),f.addRange(u)}catch{}}var im={compared:0},lm=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function am(e,t,n,r){let o=(i,l)=>t.getAttribute(l)!==null&&typeof r=="function"&&!!r(i,l),s=0;for(let i of e.attributes)if(!(n(e,i.name)||o(e,i.name))&&(s++,t.getAttribute(i.name)!==i.value))return!1;for(let i of t.attributes)!n(t,i.name)&&!o(t,i.name)&&s--;return s===0}function dl(e,t){if(e.namespaceURI!==t.namespaceURI||e.prefix!==t.prefix||e.localName!==t.localName)return!1;let n=e.attributes;if(n.length!==t.attributes.length)return!1;for(let r of n)if(t.getAttributeNS(r.namespaceURI,r.localName)!==r.value)return!1;return!0}function Cc(e,t,n,r,o,s,i,l){let a=new Map,c=new Set,m=u=>{if(r(u))return;let f=n(u);f&&(s.add(f),o.has(f)||a.has(f)?c.add(f):a.set(f,u))};for(let u of e)m(u);m(t);for(let u of i||t.querySelectorAll("*"))m(u);for(let u of c)a.delete(u),l.add(u);return a}function _c(e,t,n,r,o,s){let i=!1;for(let m of o)m.startsWith("merge:")&&(i=!0);if(!i)return[...r];let l=new Map,a=[],c=s===vn?$o:"*";for(let m of[e,...e.querySelectorAll(c)]){if(n(m))continue;let u=t(m);if(!u||!(r.has(u)||o.has(u)))continue;let f=(l.get(u)||0)+1;l.set(u,f),f===2&&a.push(u)}return a}function Mc({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:r,o,identity:s,baseURI:i}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!am(e,t,o.ignoreAttribute,o.attributeMerge))return{bail:"root-attrs"};let{ignored:l,remoteWins:a}=o,c=ul(o.scripts.merge===!1?null:o.scripts.mergeTags,i),m=_e=>{let O=c(_e);return O!==null?O:s.base(_e)||null},u=_e=>{let O=c(_e);return O!==null?O:s.remote(_e)||null},f=[],p=[],h=new Map,v=new Map,g={same:h,differ:v},d=_e=>({bail:_e,comparisons:g}),k=(_e,O,K=!0)=>{if(h.get(_e)===O)return!0;if(v.get(_e)===O)return!1;if(im.compared++,K&&_e.isEqualNode(O))return h.set(_e,O),!0;let fe=_e.nodeType===O.nodeType;if(fe&&_e.nodeType===1){if(fe=dl(_e,O),fe){let ae=_e.firstChild,qe=O.firstChild;for(;ae&&qe;ae=ae.nextSibling,qe=qe.nextSibling)if(!k(ae,qe,!1)){fe=!1;break}(ae||qe)&&(fe=!1)}}else fe&&(fe=_e.isEqualNode(O));return(fe?h:v).set(_e,O),fe},S=e,x=t,w=!1,T=()=>{h.set(S,x);for(let _e=0;_e<f.length;_e++)h.set(f[_e],p[_e]);return d("equal")};for(;;){let _e=S.childNodes,O=x.childNodes;if(_e.length!==O.length)break;let K=rt=>k(_e[rt],O[rt])?(h.set(_e[rt],O[rt]),!1):!0,fe=-1,ae=-1;for(let rt=0;rt<_e.length;rt++){if(_e[rt].nodeType!==1)continue;let xt=0;for(let nt=_e[rt].firstElementChild;nt;nt=nt.nextElementSibling)xt++;xt>=ae&&(ae=xt,fe=rt)}let qe=[],ze=!1;for(let rt=0;rt<_e.length&&qe.length<2;rt++)rt!==fe&&K(rt)&&qe.push(rt);if(fe>=0&&qe.length<2&&(qe.length===0&&dl(S,x)?(qe.push(fe),ze=!0):K(fe)&&qe.push(fe)),qe.length!==1){if(!w&&qe.length===0&&dl(S,x))return T();break}let Ee=_e[qe[0]],ot=O[qe[0]];if(w=w||!ze,w&&v.set(Ee,ot),Ee.nodeType!==1||ot.nodeType!==1||Ee.tagName!==ot.tagName)break;if(m(Ee)!==u(ot)){if(!w&&k(Ee,ot))return T();break}f.push(S),p.push(x),S=Ee,x=ot}v.set(S,x);for(let _e=0;_e<f.length;_e++)v.set(f[_e],p[_e]);if(S===e||S.tagName==="HEAD"||S.tagName==="BODY")return d("root-level");if(f.length<2||f[1].tagName!=="BODY")return d("not-in-body");if(l(S)||l(x))return d("ignored-ancestor");if(a(S)||a(x))return d("remote-wins-ancestor");for(let _e of f)if(lm.has(_e.tagName))return d("form-ancestor");if(S.tagName==="SCRIPT"||S.getElementsByTagName("script").length||x.getElementsByTagName("script").length)return d("script-or-template");let N=r(S);if(!N||N.nodeType!==1||N.tagName!==S.tagName)return d("no-live-twin");if(!n.contains(N))return d("live-detached");for(let _e of f){let O=r(_e);if(!O||O.nodeType!==1)return d("ancestor-live")}let C=s.base===vn&&s.remote===vn&&l===Ii,L=new Set,q=new Set,V=[],U=null,F=_e=>{_e&&(L.has(_e)?q.add(_e):L.add(_e))},A=(_e,O)=>{let K=c(_e),fe=K!==null?K:s.base(_e)||null;return fe!==(K!==null?K:s.remote(O)||null)?!1:(F(fe),!0)},E=(_e,O)=>{for(let K=_e.firstElementChild,fe=O.firstElementChild;K;K=K.nextElementSibling,fe=fe.nextElementSibling){let ae=l(K);if(ae!==l(fe))return!1;if(!ae&&(!A(K,fe)||!E(K,fe)))return!1}return!0},X=_e=>{let O=_e+1<f.length?f[_e+1]:S;for(let K=f[_e].firstElementChild,fe=p[_e].firstElementChild;K;K=K.nextElementSibling,fe=fe.nextElementSibling){if(K===O){let ze=_e+1<f.length?X(_e+1):null;if(ze)return ze;continue}let ae=l(K);if(ae!==l(fe))return"outside-id-changed";if(ae)continue;let qe=r(K);if(!qe||qe.nodeType!==1)return"sibling-live";if(V.push([K,fe]),!C&&(!A(K,fe)||!E(K,fe)))return"outside-id-changed";_e===0&&K.tagName==="HEAD"&&m(K)&&(U=[K,fe])}return null},B=X(0);if(B)return d(B);let z=new Set(f),Ce=null;if(s.base===vn){Ce=[];for(let _e of e.querySelectorAll($o))_e===S||z.has(_e)||(S.contains(_e)?Ce.push(_e):C&&F(m(_e)))}let Me=new Set,Be=new Set,me=new Set,Te=Cc(f,S,m,l,L,Me,Ce,Be),Xe=Cc(p,x,u,l,L,Me,s.remote===vn&&x.querySelectorAll($o),me);return U&&(q.has(m(U[0]))||Me.has(m(U[0])))&&(U=null),{scope:{chain:f,root:S,onChain:z,baseIndex:Te,remoteIndex:Xe,baseDropped:Be,remoteDropped:me,head:U,same:h,differ:v,dropped:[..._c(e,m,l,q,Be,s.base),..._c(t,u,l,q,me,s.remote)],held:_e=>{for(let O=1;O<f.length;O++)if(_e.map.get(f[O])!==p[O])return!1;for(let[O,K]of V)if(_e.map.get(O)!==K)return!1;return!0}}}}var Wk=Symbol("hyper-morph-duplicate-key");var cm='[editor-ui],[clay~="editor-ui"],[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]',um='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',fm='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function dm(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let t=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(t)}function hm(e,t,n,r){if(t==null)return;if(typeof t=="string")return t;let o=t;if(o.nodeType===9){let s=e.getAttribute("id");o=s&&o.getElementById(s)||(e.tagName==="BODY"?o.body:e.tagName==="HTML"?o.documentElement:o.body&&o.body.firstElementChild)}if((!o||o.nodeType!==1||o.tagName!==e.tagName)&&(o=mm(e,t,r)),!!o)return n?Array.from(o.childNodes):o}function mm(e,t,n){let r=t.nodeType===9?t.documentElement:t;if(!r||r.nodeType!==1)return null;let o=new Map,s=[r,...r.querySelectorAll("script")];for(let a of s){let c=Xr(a,n);c&&!o.has(c.key)&&o.set(c.key,a.textContent)}if(!o.size)return null;let i=e.cloneNode(!0),l=!1;for(let a of[i,...i.querySelectorAll("script")]){let c=Xr(a,n);c&&o.has(c.key)&&(a.textContent=o.get(c.key),l=!0)}return l?i:null}function Rc(e,t){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let n=t.implementation.createHTMLDocument(""),r=e.nodeType===1&&e.tagName==="HTML"?e:null;if(r)return n.replaceChild(n.adoptNode(r),n.documentElement),n;let o=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let s of o)n.body.appendChild(n.adoptNode(s));return n}function ur(e,t,n={}){let r=n||{};if(!r.head?.block)return Ic(e,t,r);try{return Ic(e,t,r)}catch(o){return Promise.reject(o)}}function Ic(e,t,n){let r=n.policy||"sync",o=r==="raw"?void 0:(a,c)=>dm(a)||(r==="history"?!(c&&a.matches(fm))&&a.matches(um):a.matches(cm)),s=n.callbacks||{},i={ignore:o,hooks:s,protectFocusedValue:n.ignoreActiveValue===!0?"subtree":!1,restoreFocus:n.restoreFocus!==!1,formState:n.formStateSync||"attribute",scripts:{execute:n.scripts?.handle!==!1,merge:n.scripts?.merge!==!1,mergeTags:n.scripts?.mergeTags||[]},head:{awaitLoads:!!n.head?.block,preserve:n.head?.shouldPreserve||(()=>!1)}};if(typeof n.key=="function"&&(i.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return Uo(Object.assign({},i,{live:e,base:n.scripts?.mergeBase||null,remote:Rc(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let a=Object.assign({},i,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:Rc(t,e.ownerDocument)});return Uo(a)}n.morphStyle==="innerHTML"&&(i.children=!0);let l=hm(e,n.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return l!==void 0&&(i.base=l),hl(e,t,i)}var pm=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","attributeMerge","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),On=()=>{};function Ho(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!pm.has(l))throw new TypeError(`unknown option "${l}"`);let n=Object.assign({beforeNodeAdded:On,afterNodeAdded:On,beforeNodeRemoved:On,afterNodeRemoved:On,beforeNodeMorphed:On,afterNodeMorphed:On,beforeAttributeUpdated:On},e.hooks||{}),r=e.conflicts||"remote";if(!["remote","local","both"].includes(r))throw new TypeError("conflicts must be remote, local or both");let o=e.formState||"attribute";if(!["attribute","property"].includes(o))throw new TypeError("formState must be attribute or property");let s=e.protectFocusedValue;if(s!==void 0&&typeof s!="boolean"&&s!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");if(e.attributeMerge!==void 0&&typeof e.attributeMerge!="function")throw new TypeError("attributeMerge must be a function");let i=e.lineage;if(i!==void 0&&(!i||typeof i!="object"||typeof i.onResult!="function"||!i.elements||typeof i.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:Li(e.ignore,t),remoteWins:Li(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,attributeMerge:typeof e.attributeMerge=="function"?e.attributeMerge:()=>null,opaque:typeof e.opaque=="function"?e.opaque:()=>!1,conflicts:r,protectFocusedValue:s===void 0?!0:s,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:o,hooks:n,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:i||null}}function eo(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return vn}function to(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=Pi(t,e.map),r=typeof e.then=="function"?e.then:vn;if(typeof e.first=="function"){let o=e.first;return s=>o(s)||n.get(s)||r(s)}return o=>n.get(o)||r(o)}return vn}function gm(e,t,n,r={}){let o=p=>p&&p.nodeType===9?p.documentElement:p,s=o(t),i=o(n),l=o(e)||s;if(r.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let a=Object.assign({},r);delete a.live,delete a.base,delete a.remote;let c=Ho(a,[l,s,i].filter(Boolean)),m=r.identity||{},u=lr(),f=Ms(l,s,i,{identity:{base:to(m.base,l),local:to(m.local,s),remote:to(m.remote,i)},authored:{base:eo(m.base),local:eo(m.local),remote:eo(m.remote)},skipUnchanged:c.hooks.beforeNodeMorphed===On&&c.hooks.afterNodeMorphed===On,ignored:c.ignored,remoteWins:c.remoteWins,ignoreAttribute:c.ignoreAttribute,attributeMerge:c.attributeMerge,conflicts:c.conflicts,mergeTags:c.scripts.merge===!1?null:c.scripts.mergeTags,baseURI:s.ownerDocument&&s.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:c.children,stats:u});return delete f.recoveryLinks,delete f.lineage,f}function ml({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:r,toLive:o,options:s,identity:i,childrenOnly:l,isDocument:a}){let c=Ho(s,[e,t,n,r].filter(Boolean));if(c.ignored(e)){let A=pl(),E=c.lineage?qo(c.lineage,e,A):null;return{report:A,loads:[],lineage:E}}let m=e.ownerDocument,u=c.lineage?Qi(c.lineage,{liveRoot:e,localRoot:n,toLive:o}):null,f=c.scripts.execute?oc(e,c.ignored,m.baseURI):null,p=lr(),h=c.hooks.beforeNodeMorphed===On&&c.hooks.afterNodeMorphed===On,v={identity:{base:to(i.base,t||n),local:to(i.local,n),remote:to(i.remote,r)},authored:{base:eo(i.base),local:eo(i.local),remote:eo(i.remote)},ignored:c.ignored,remoteWins:c.remoteWins,ignoreAttribute:c.ignoreAttribute,attributeMerge:c.attributeMerge,conflicts:c.conflicts,mergeTags:c.scripts.merge===!1?null:c.scripts.mergeTags,baseURI:m.baseURI,localIsBase:!t,childrenOnly:l,skipUnchanged:h,lineage:u?{locals:u.locals}:null},g=c.fastPath&&a&&!l&&h&&t===n,d=null,k=null;if(g){let A=Mc({baseRoot:t,remoteRoot:r,liveRoot:e,toLive:o,o:c,identity:v.identity,baseURI:m.baseURI});v.comparisons=A.comparisons||A.scope,A.bail?k=A.bail:(d=Ms(t,n,r,Object.assign({},v,{stats:p,scope:A.scope})),d||(k="chain-unpaired",p=lr()))}d||(d=Ms(t||n,n,r,Object.assign({},v,{stats:p}))),g&&(p.fastPathAttempted=1,p.fastPathTaken=k?0:1,p.fastPathFallback=k),d.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(A=>c.hooks[A]!==On)&&dc(d.conflicts,d.recoveryLinks,o),c.beforeApply&&c.beforeApply(d.doc);let S=globalThis.__hyperMorphProfile,x=S?performance.now():0,w=Nc(e,d.root,d,{toLive:o,localRoot:n,ignored:c.ignored,ignoreAttribute:c.ignoreAttribute,opaque:c.opaque,formState:c.formState,protectFocusedValue:c.protectFocusedValue,restoreFocus:c.restoreFocus,preserve:c.head.preserve,hooks:c.hooks,childrenOnly:l,keepLiveOnly:c.keepLiveOnly,trackInserted:!!u});S&&(S.apply=(S.apply||0)+(performance.now()-x));let T=[];if(c.head.awaitLoads)for(let A of w.applied){if(A.kind!=="insert"||A.node.nodeType!==1)continue;let E=A.node;E.tagName==="LINK"&&/\bstylesheet\b/i.test(E.getAttribute("rel")||"")&&E.getAttribute("href")&&E.closest("head")&&T.push(new Promise(B=>{E.addEventListener("load",()=>B()),E.addEventListener("error",()=>B())}))}let N=null,C=null;if(f){let A=sc(e,f,{ignored:c.ignored,skip:w.mergedScriptsLive,baseURI:m.baseURI,beforeNodeAdded:c.hooks.beforeNodeAdded,afterNodeAdded:c.hooks.afterNodeAdded,trackRecovery:!!d.recoveryLinks});T.push(...A.loads),N=A.swapped,C=A.vetoed}let L=A=>N&&N.get(A)||A,q=A=>{if(w.keptRuns.has(A))return w.runOf.get(A);let E=w.liveOf.get(A)||w.heldBy.get(A)||w.insertedLive.get(A);return E?L(E):null},V=A=>{let E=A&&w.liveOf.get(A);return E?L(E):null},U=A=>{let E=A&&q(A);return Array.isArray(E)?E[0]:E};if(d.recoveryLinks){let A=(E,X,B)=>(X.namespaceURI?E.getAttributeNS(X.namespaceURI,X.localName):E.getAttribute(X.qualifiedName))===B;pc(d.conflicts,d.recoveryLinks,{lookup:q,vetoed:w.vetoed,vetoedAttrs:w.vetoedAttrs,removedVetoes:w.removedVetoes,vetoedLive:C,liveAttr:A,ignored:c.ignored,liveRoot:e})}let F={applied:w.applied,decisions:d.decisions.map(A=>Object.assign({},A,{node:A.node?V(A.node):null,el:A.el?V(A.el):null,applied:!!(A.node?V(A.node):A.el&&V(A.el))})),conflicts:d.conflicts.map(A=>Object.assign({},A,{node:A.node?A.kind==="text"&&A.recovery.subject.nodeType===8?U(A.node):V(A.node):A.node,el:A.el?A.kind==="structure"?U(A.el):V(A.el):A.el})),localDiverged:d.localDiverged,identities:w.identities,moved:w.moved,replaced:w.replaced,stats:p};return u&&(F.lineage=u.finish(d.lineage,q)),{report:F,loads:T,lineage:u}}var Lc=new WeakMap;function pl(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:lr()}}function Uo(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");return t.lineage===void 0?Pc(t):Zi(t,t.live.documentElement,r=>Pc(r))}function Pc(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let r=Lc.get(n);r||(r=Ri(n),Lc.set(n,r));let o=r("remote",t.remote),s=typeof t.base=="string"&&t.base===""?null:t.base,i=s?r("base",s):null,l=t.local?t.local.root:n.documentElement,a=t.local?t.local.toLive:f=>f;Ea(n,o);let{report:c,loads:m,lineage:u}=ml({liveRoot:n.documentElement,baseRoot:i?i.documentElement:null,localRoot:l,remoteRoot:o.documentElement,toLive:a,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return u?.deliver(c),Promise.all(m).then(()=>c)}function bm(e,t,n={}){return Uo(Object.assign({},n,{live:e,base:null,remote:t}))}function jc(e,t){if(e==null)return{root:t.createElement("template"),first:null};if(typeof e=="string"){let r=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(r){let s=bs(e,t),i=r[1].toLowerCase()==="html"?s.documentElement:s.body;return{root:i,first:i}}let o=t.createElement("template");return o.innerHTML=e,{root:o,first:o.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let r=t.createElement("template"),o=e.isConnected;return r.content.appendChild(o?t.importNode(e,!0):e),{root:r,first:e}}if(e.nodeType===11){let r=t.createElement("template");return r.content.appendChild(e),{root:r,first:r.content.firstElementChild}}let n=t.createElement("template");for(let r of Array.from(e))n.content.appendChild(r.parentNode?t.importNode(r,!0):r);return{root:n,first:n.content.firstElementChild}}function hl(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return n.lineage===void 0?qc(e,t,n):Zi(n,e,r=>qc(e,t,r))}function qc(e,t,n={}){let r=e.ownerDocument,{base:o,...s}=n,i=!!s.children,l=Ho(s,[e]);if(l.ignored(e)){let v=pl();return l.lineage&&qo(l.lineage,e,v).deliver(v),Promise.resolve(v)}let a=jc(t,r),c=o!=null?jc(o,r):null,m,u=null;if(i)m=a.root,u=c?c.root:null;else{if(m=a.first,u=c?c.first:null,!m){let v=Ho(s),g=v.lineage?qo(v.lineage,e,{}):null;v.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),v.hooks.afterNodeRemoved(e));let d={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:lr()};return g&&(d.lineage=g.result,g.deliver(d)),Promise.resolve(d)}if(m.tagName!==e.tagName){let v=Ho(s,[e,m]);if(v.hooks.beforeNodeMorphed(e,m)===!1){let k=pl();return v.lineage&&qo(v.lineage,e,k).deliver(k),Promise.resolve(k)}let g=ml({liveRoot:e,baseRoot:u&&u.tagName===e.tagName?u:null,localRoot:e,remoteRoot:m,toLive:k=>k,options:s,identity:s.identity||{},childrenOnly:!0,isDocument:!1}),d=mn(m)?Do(m,r):r.importNode(m,!1);if(!mn(d))for(;e.firstChild;)d.appendChild(e.firstChild);return v.hooks.beforeNodeAdded(d)===!1?(Cs(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):v.hooks.beforeNodeRemoved(e)===!1?(Cs(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(d),Cs(g.report.conflicts,e,d),v.hooks.afterNodeRemoved(e),v.hooks.afterNodeAdded(d),v.hooks.afterNodeMorphed(e,m),g.report.replaced.push(d),g.report.applied.push({kind:"insert",node:d,parent:d.parentNode},{kind:"remove",node:e,parent:d.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,d),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:f,loads:p,lineage:h}=ml({liveRoot:e,baseRoot:u,localRoot:e,remoteRoot:m,toLive:v=>v,options:s,identity:s.identity||{},childrenOnly:i,isDocument:!1});return h?.deliver(f),Promise.all(p).then(()=>f)}var gl={mergeDocument:Uo,morphDocument:bm,morphElement:hl,merge3:gm,morph:ur};var Ls={};Ni(Ls,{EmptyListInsert:()=>fr,MAX_RULE_DEPTH:()=>oo,MaxRuleDepthExceeded:()=>Cr,NoRulesTag:()=>bl,RuleTargetReadOnly:()=>Vo,RulesParseError:()=>no,ShapeMismatch:()=>zo,UnknownRulesVersion:()=>ro,WriteNotRoundTripped:()=>Is,WriteRefused:()=>Rs,WriteRejected:()=>kl});var no=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},ro=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},oo=20,Cr=class extends Error{constructor(t){super(`rule depth exceeded ${oo} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},zo=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},fr=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},Vo=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},Rs=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function wm(e){return e.reduce((n,r)=>typeof r=="number"?`${n}[${r}]`:n?`${n}.${r}`:String(r),"")||"(root)"}var Is=class extends Error{constructor(t){super(`write did not round-trip at "${wm(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},bl=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},kl=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};var Sm=/^--[A-Za-z0-9_-]+$/;function _r(e){return typeof e=="string"&&Sm.test(e)}function Dc(e){let t=[],n=[],r=null,o=0;for(let s=0;s<e.length;s++){let i=e[s];if(r){i==="\\"?s++:i===r&&(r=null);continue}if(i==="/"&&e[s+1]==="*"){let l=e.indexOf("*/",s+2);s=l===-1?e.length:l+1;continue}i==='"'||i==="'"?r=i:i==="("?n.push(")"):i==="["?n.push("]"):i==="{"?n.push("}"):(i===")"||i==="]"||i==="}")&&n[n.length-1]===i?n.pop():i===";"&&n.length===0&&(t.push(e.slice(o,s)),o=s+1)}return t.push(e.slice(o)),t}function Am(e){let t="",n=null;for(let r=0;r<e.length;r++){let o=e[r];if(n){t+=o,o==="\\"&&r+1<e.length?t+=e[++r]:o===n&&(n=null);continue}if(o==="/"&&e[r+1]==="*"){let s=e.indexOf("*/",r+2);r=s===-1?e.length:s+1,t+=" ";continue}(o==='"'||o==="'")&&(n=o),t+=o}return t}function Fc(e){e=Am(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),r=e.slice(t+1).trim(),o=/!\s*important\s*$/i.exec(r);return o&&(r=r.slice(0,o.index).trim()),{name:n,value:r,important:!!o}}function Wo(e,t){if(e==null)return null;let n=null;for(let r of Dc(String(e))){let o=Fc(r);!o||o.name!==t||(!n||o.important||!n.important)&&(n=o)}return n?n.value:null}function Bc(e,t,n){let r=e==null?"":String(e),o=n==null||n==="",s=Dc(r),i=s.map(Fc),l=i.some(u=>u&&u.name===t&&u.important),a=[],c=!1;s.forEach((u,f)=>{let p=i[f];if(!p||p.name!==t){a.push(u);return}if(o||c)return;let h=/^\s*/.exec(u)[0];a.push(`${h}${t}: ${n}${l?" !important":""}`),c=!0});let m=a.join(";");if(!o&&!c){let u=m.trimEnd();m=u===""?`${t}: ${n}`:`${u}${u.endsWith(";")?" ":"; "}${t}: ${n}`}return m.trim()===""?null:m}function yl(e,t,n,r){let o=e.attr(t,"style");if((Wo(o,n)??"")===r)return;let s=Bc(o,n,r);s==null?e.removeAttr(t,"style"):e.attr(t,"style",s)}function dr(e,t,n,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return vl(e,t,n,{depth:0,path:[]},r)}function vl(e,t,n,r,o){if(r.depth>oo)throw new Cr(r.path);if(typeof n=="string")return Tm(e,t,n,r,o);if(Array.isArray(n)){let[s,i]=n,l=e.find(t,s,o);return Uc(o,r,l),l.map((a,c)=>vl(e,a,i,{depth:r.depth+1,path:[...r.path,c]},o))}if(typeof n=="object"&&n!==null){let s={};for(let[i,l]of Object.entries(n))s[i]=vl(e,t,l,{depth:r.depth+1,path:[...r.path,i]},o);return s}return null}function Tm(e,t,n,r,o){if(n.endsWith("[]")){let l=n.slice(0,-2),a=e.find(t,l,o);return Uc(o,r,a),a.map(c=>e.text(c))}if(n.startsWith("@"))return $c(e,t,n.slice(1));let s=Kt(n);if(s!==-1){let l=n.slice(0,s),a=n.slice(s+1),c=l?e.find(t,l,o):[t];return c.length===0?null:$c(e,c[0],a)}if(n===".")return e.text(t);let i=e.find(t,n,o);return i.length===0?null:e.text(i[0])}function Uc(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(r){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,r)}}function $c(e,t,n){if(_r(n))return Wo(e.attr(t,"style"),n);if(Io.has(n)){let o=e.prop(t,n);return o==null?null:String(o)}let r=e.attr(t,n);return r??null}var Ps=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),Em=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Hc=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function Ko(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function xl(e,t){if(Ko(e,t))return!0;for(let[n,r]of Object.entries(Em))if(r.includes(t)&&Ko(e,n))return!0;return!1}function Go(e){let t=Ps[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Om(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=Ps[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>xl(n,o))||r.bundles.some(o=>Ko(n,o)))return n;n=n.parentElement}return null}function zc(e,t){return!!Om(e,t)}var Nm=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Cm(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function Vc(e,t,n,r){if(r)return!!e.closest?.(t);let o=e;for(;o?.nodeType===1;){if(o.matches(t))return!0;if(o===n)break;o=o.parentElement}return!1}function Wc(e,t,n,r,o,s){return(s?zc(e,t):Vc(e,n,o,!1))||!!(r&&(s&&e!==o?e.matches(r):Vc(e,r,o,s)))}function _m(e,t){let n=Ps[t];return n.tokens.some(r=>xl(e,r))||n.bundles.some(r=>Ko(e,r))}var Mm=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Kc(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let o=e,s=t;if(e.nodeType===1){if(Mm.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);o=e.content,s=t.content,n.cloneToLive.set(s,o),n.liveToClone.set(o,s)}}else if(e.nodeType!==11)return;let i=s.firstChild;for(let l=o.firstChild;l&&i;l=l.nextSibling)Kc(l,i,n,r),i=i.nextSibling}function Yo(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:o=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=s.implementation.createHTMLDocument(""),l=o||new WeakMap,a=new WeakMap,c=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let m=Go(t),u=r?h=>_m(h,t)||!!(n&&h.matches(n)):h=>Wc(h,t,m,n,c,!1),f=null;if(c.nodeType!==1||!Wc(c,t,m,n,c,r)){f=i.importNode(c,!0);let h={cloneToLive:l,liveToClone:a,dropped:[],controls:[]};Kc(c,f,h,u);for(let v of h.dropped)v.remove();for(let v=0;v<h.controls.length;v+=2)Cm(h.controls[v],h.controls[v+1])}e.nodeType===9&&f&&(i.replaceChild(f,i.documentElement),a.set(e,i),l.set(i,e));let p=h=>{if(Nm.test(h))throw new Error(`Filtered content queries do not support stateful selector: ${h}`)};return{root:f,document:i,capability:t,selector:Go(t),cloneToLive:l,liveToClone:a,original(h){return l.get(h)||null},cloneOf(h){return a.get(h)||null},query(h,v=f){return p(h),Array.from(v.querySelectorAll(h),g=>l.get(g)||g)},text(h=f){return(h===f?f:a.get(h))?.textContent||""},html(h=f){return(h===f?f:a.get(h))?.innerHTML??""},clone(h=f){let v=h===f?f:a.get(h);return v?i.importNode(v,!0):null}}}function Yc(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Rm(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Gc(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function Xc(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Jc(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let r=n.type;r!=="file"&&r!=="checkbox"&&r!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var rn={semanticExclude:!0,find(e,t,n={}){let r=Rm(e);if(!r||!r.querySelectorAll)return[];let o=Array.from(r.querySelectorAll(t));n.includeRulesTag||(o=o.filter(l=>!Yc(l)));let s=[];n.skip&&s.push(n.skip);let i=n.templateAttr===null?null:n.templateAttr||"cms-template";if(i&&s.push("["+i+"]"),s.length){let l=s.join(", ");o=o.filter(a=>!a.closest||!a.closest(l))}return o},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Xc(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Gc(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Gc(e,t,null)},prop(e,t,n){if(n===void 0){let r=e?e[t]:void 0;return r!==void 0?r:null}e[t]=n},clone(e){let t=e.cloneNode(!0);return Jc(t),t},insertAt(e,t,n){let r=e.children[n]||null;e.insertBefore(t,r)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let r=e.ownerDocument.createElement("template");r.innerHTML=t;let o=r.content.firstElementChild;if(!o)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(o,e),o},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(r=>{r.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Zn(e,t={}){if(t.exclude===null)return rn;let n=[Go("data"),t.exclude].filter(Boolean).join(", "),r=e.nodeType===9?e:e.ownerDocument||e,o=e.nodeType===9?e.documentElement:e;if(!t._write&&!o?.matches?.(n)&&!o?.querySelector?.(n)&&!r?.querySelector?.(n))return rn;let s=e.nodeType===9||!e.isConnected?e:e.ownerDocument,i=e.nodeType===9?e:e.ownerDocument,l=null,a=()=>l||(l=Yo(s,{capability:"data",exclude:t.exclude||null})),c=h=>{let v=a();return h===e?v.cloneOf(e):v.cloneOf(h)||h},m=h=>l?.original(h)||h,u=(h,v)=>{a().liveToClone.set(h,v),a().cloneToLive.set(v,h);let g=h.childNodes||[],d=v.childNodes||[];for(let k=0;k<Math.min(g.length,d.length);k++)u(g[k],d[k])},f=(h,v,g,d)=>{let k=Array.from(h.childNodes).filter(N=>l.cloneOf(N)),x=k[0];for(;x&&k.includes(x);)x=x.nextSibling;for(let N of k)N.remove();if(g==="innerHTML"){let N=i.createElement("template");N.innerHTML=d;for(let C of Array.from(N.content.childNodes))h.insertBefore(C,x||null)}else h.insertBefore(i.createTextNode(d),x||null),Xc(h,d);let w=Yo(h,{capability:"data",exclude:t.exclude||null});v.replaceChildren(...Array.from(w.root?.childNodes||[]));let T=N=>{let C=w.original(N);C&&(l.liveToClone.set(C,N),l.cloneToLive.set(N,C));for(let L of Array.from(N.childNodes||[]))T(L)};for(let N of Array.from(v.childNodes))T(N)},p={...rn,find(h,v,g={}){let d=c(h);if(!d?.querySelectorAll)return[];let k=a().query(v,d);g.includeRulesTag||(k=k.filter(w=>!Yc(w)));let S=[];g.skip&&S.push(g.skip);let x=g.templateAttr===null?null:g.templateAttr||"cms-template";if(x&&S.push(`[${x}]`),S.length){let w=S.join(", ");k=k.filter(T=>!T.closest?.(w))}return k},parent(h){let v=c(h)?.parentElement;return v?m(v):null},children(h){return Array.from(c(h)?.children||[],m)},text(h,v){if(v===void 0){let k=m(h);return!k?.matches?.(n)&&!k?.querySelector?.(n)?rn.text(k):(c(h)?.textContent||"").trim()}let g=m(h);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){rn.text(g,v);return}let d=a().cloneOf(g);d?f(g,d,"textContent",v):rn.text(g,v)},attr(h,v,g){let d=m(h);if(g===void 0)return rn.attr(d,v);rn.attr(d,v,g);let k=l?.cloneOf(d);k&&(rn.attr(k,v,g),Yo(d,{capability:"data",exclude:t.exclude||null}).root===null&&(k.remove(),l.liveToClone.delete(d),l.cloneToLive.delete(k)))},removeAttr(h,v){let g=m(h);rn.removeAttr(g,v);let d=l?.cloneOf(g);d&&rn.removeAttr(d,v)},prop(h,v,g){let d=m(h);if(g===void 0)return v==="innerHTML"||v==="outerHTML"||v==="textContent"||v==="innerText"?rn.prop(c(d),v):rn.prop(d,v);let k=v==="innerHTML"||v==="textContent"||v==="innerText",S=k?a().cloneOf(d):l?.cloneOf(d);S&&k?f(d,S,v,g):(rn.prop(d,v,g),S&&rn.prop(S,v,g))},clone(h){let v=c(h);if(v===h)return rn.clone(h);let g=i.importNode(v,!0);return Jc(g),g},insertAt(h,v,g){let d=m(h),S=p.children(d)[g]||(()=>{for(let T=d.children.length-1;T>=0;T--){let N=d.children[T];if(a().cloneOf(N))return N.nextElementSibling}return d.firstElementChild})(),x=m(v);d.insertBefore(x,S||null);let w=a().cloneOf(d);if(w){let T=a().cloneOf(x);T||(T=i.importNode(x,!0),u(x,T));let N=Array.from(w.children);w.insertBefore(T,N[g]||null)}},insertBefore(h,v){let g=m(h),d=m(v);g.parentNode.insertBefore(d,g);let k=a().cloneOf(g.parentNode);if(k){let S=a().cloneOf(d);S||(S=i.importNode(d,!0),u(d,S));let x=a().cloneOf(g);x?x.before(S):k.appendChild(S)}},insertAfter(h,v){let g=m(h),d=m(v);g.parentNode.insertBefore(d,g.nextSibling);let k=a().cloneOf(g.parentNode);if(k){let S=a().cloneOf(d);S||(S=i.importNode(d,!0),u(d,S));let x=a().cloneOf(g);x?x.after(S):k.appendChild(S)}},identity(h){return m(h)||null},remove(h){let v=m(h),g=a().cloneOf(v);rn.remove(v),g&&rn.remove(g)},replaceWith(h,v){let g=m(h),d=a().cloneOf(g),k=rn.replaceWith(g,v);if(d){let S=Yo(k,{capability:"data",exclude:t.exclude||null});if(!S.root)d.remove();else{d.replaceWith(S.root);let x=w=>{let T=S.original(w);T&&(l.liveToClone.set(T,w),l.cloneToLive.set(w,T));for(let N of Array.from(w.childNodes||[]))x(N)};x(S.root)}}return k}};return p}var so=rn;function wl(e){try{return JSON.parse(e)}catch(t){throw new no(`Invalid strict JSON: ${t.message}`,t)}}function io(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(o){let s=[],i=0;for(;i<o.length;){let l=o[i];if(/\s/.test(l)){i++;continue}if("{}".includes(l)){s.push({type:l,value:l}),i++;continue}if(l==="["){let u=!1,f=i+1;for(;f<o.length&&/\s/.test(o[f]);)f++;if(f<o.length&&/[a-zA-Z_]/.test(o[f])&&(u=!0),!u){s.push({type:l,value:l}),i++;continue}}if(l==="]"){s.push({type:l,value:l}),i++;continue}if(l===":"){s.push({type:t.COLON,value:l}),i++;continue}if(l===","){s.push({type:t.COMMA,value:l}),i++;continue}if(l==='"'||l==="'"){let u=l,f=i+1;for(;f<o.length&&o[f]!==u;)o[f]==="\\"&&f++,f++;s.push({type:t.STRING,value:o.substring(i+1,f),quoted:!0,sourceQuote:u}),i=f+1;continue}let a=i,c;for(;a<o.length&&!/[{},]/.test(o[a]);)if(o[a]===":"){let u=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],f=!1;for(let p of u){let h=p.substring(1);if(o.substring(a+1,a+1+h.length)===h){f=!0,a+=h.length;break}}if(!f)break}else if(o[a]==="["){for(a++;a<o.length&&o[a]!=="]";){if(o[a]==='"'||o[a]==="'"){let u=o[a];for(a++;a<o.length&&o[a]!==u;)o[a]==="\\"&&a++,a++}a++}a<o.length&&o[a]==="]"&&a++}else a++;c=o.substring(i,a);let m=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(c)?m=t.NUMBER:c==="true"||c==="false"||c==="null"?m=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(c)&&(m=t.SELECTOR),s.push({type:m,value:c,quoted:!1}),i=a}return s}function r(o){let s="";for(let i=0;i<o.length;i++){let l=o[i];if("{}".includes(l.type)||"[]".includes(l.type)){s+=l.value;continue}if(l.type===t.COLON){s+=l.value;continue}if(l.type===t.COMMA){let a=o[i+1];if(a&&(a.type==="}"||a.type==="]"))continue;s+=l.value;continue}if(l.type===t.STRING&&l.quoted){let a=l.value;l.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(c,m)=>m.length%2===0?m+'\\"':c)),s+=`"${a}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){s+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){s+=`"${l.value}"`;continue}s+=`"${l.value}"`}return s}try{let o=n(e),s=r(o);return JSON.parse(s)}catch(o){throw new no("Invalid extraction rules syntax: "+o.message,o)}}var Qc="1",Zc=/^[a-zA-Z0-9_-]+$/;function Xo(e,t,n){let r;if(n===void 0)r="script[data-rules-name]";else{if(typeof n!="string"||!Zc.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Zc})`);r=`script[data-rules-name~="${n}"]`}let o=e.find(t,r,{includeRulesTag:!0});if(o.length===0)return null;n!==void 0&&o.length>1&&console.warn(`hyper-html-api: ${o.length} rules tags match data-rules-name~="${n}"; using the first.`);let s=o[0],i=e.attr(s,"data-rules-version");if(i!==Qc)throw new ro(i);return{rules:io(e.text(s)),tagNode:s}}var rv=new Function("url","return import(url)");function su(e,t,n,r){let o=e.length,s=t.length,i=new Array(o).fill(-1);if(r){let d=new Set;for(let k=0;k<o;k++){let S=r[k];!(S>=0&&S<s)||d.has(S)||(i[k]=S,d.add(S))}}if(o===0||s===0)return i;let l=e.map(d=>ru(d,n)),a=t.map(d=>ru(d,n)),c=new Array(s).fill(!1);for(let d of i)d>=0&&(c[d]=!0);let m=new Map;a.forEach((d,k)=>{c[k]||m.set(d,m.has(d)?-1:k)});let u=new Map;l.forEach((d,k)=>{i[k]>=0||u.set(d,(u.get(d)||0)+1)}),l.forEach((d,k)=>{if(i[k]>=0||u.get(d)!==1)return;let S=m.get(d);S===void 0||S===-1||c[S]||(i[k]=S,c[S]=!0)});let f=[];for(let d=0;d<o;d++)i[d]<0&&f.push(d);let p=[];for(let d=0;d<s;d++)c[d]||p.push(d);if(f.length===0||p.length===0)return i;let h=o*s+1,v=Lm(e,t,n),g=(d,k)=>v(d,k)*h+Math.abs(d-k);for(let[d,k]of Pm(f,p,g))i[d]=k;return i}var iu=e=>typeof e=="object"&&e!==null;function ru(e,t){if(!iu(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(r=>{let o=JSON.stringify(e?.[r]);return o===void 0?" undef":o}))}function Lm(e,t,n){if(!iu(n))return(l,a)=>e[l]===t[a]?0:1;let r=Object.keys(n),o=l=>r.map(a=>JSON.stringify(l?.[a])),s=e.map(o),i=t.map(o);return(l,a)=>{let c=s[l],m=i[a],u=0;for(let f=0;f<r.length;f++)c[f]!==m[f]&&u++;return u}}function Pm(e,t,n){return e.length<=t.length?ou(e,t,n,!1):ou(t,e,(r,o)=>n(o,r),!0)}function ou(e,t,n,r){let o=e.length,s=t.length,i=[];for(let u=0;u<=o;u++)i.push(new Float64Array(s+1).fill(1/0));let l=[];for(let u=0;u<=o;u++)l.push(new Uint8Array(s+1));for(let u=0;u<=s;u++)i[o][u]=0;for(let u=o-1;u>=0;u--)for(let f=s-1;f>=0;f--){let p=n(e[u],t[f])+i[u+1][f+1],h=i[u][f+1];p<=h?(i[u][f]=p,l[u][f]=1):i[u][f]=h}let a=[],c=0,m=0;for(;c<o&&m<s;)l[c][m]&&(a.push(r?[t[m],e[c]]:[e[c],t[m]]),c++),m++;return a}function Al(e,t,n,r,o,s,i,l={}){let a=e.find(t,n,l);if(o.length===0){a.forEach(x=>e.remove(x)),Sl(l,"onRowsApplied",s.path,[]);return}let c=o.length>a.length,m=a[0]||null;if(c&&!m&&(m=Fm(e,t,n,l),!m))throw new fr(s.path);let u=a.map(x=>Dm(e,x,r,l)),f=null;if(c&&m){f=e.clone(m),l.templateAttr&&e.removeAttr(f,l.templateAttr);let x=e.stripIds(f);x>0&&console.warn(`[hyper-html-api] stripped ${x} id attribute(s) from cloned template at "${s.path.join(".")||"(root)"}"`)}let p=su(o,u,r,jm(e,a,o,s,l)),h=a.length>0?e.parent(a[0]):Hm(e,t,n,m,s,l),v=a.length>0?fu(e,h,a[0]):0,g=Wm(e,a),d=new Set,k=[],S=o.map((x,w)=>{let T=p[w];if(T>=0)return d.add(T),k.push(!1),a[T];k.push(!0);let N=e.clone(f);return e.stripIds(N),N});a.forEach((x,w)=>{d.has(w)||e.remove(x)}),g?Vm(e,h,v,S,k):Km(e,S,k,h,v),qm(e,S,r,o,s,i,l),Sl(l,"onRowsApplied",s.path,S)}function Sl(e,t,n,r){if(typeof e[t]=="function")try{return e[t](n.slice(),r)}catch(o){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,o);return}}function jm(e,t,n,r,o){let s=Sl(o,"identifyRows",r.path,n);if(!Array.isArray(s))return null;let i=new Array(n.length).fill(-1),l=new Set,a=new Map(t.map((c,m)=>[e.identity(c),m]));for(let c=0;c<n.length;c++){if(!s[c])continue;let m=a.get(e.identity(s[c]));m===void 0||l.has(m)||(i[c]=m,l.add(m))}return i}function qm(e,t,n,r,o,s,i){t.forEach((l,a)=>{if(n===null){let c=r[a],m=c==null?"":String(c);e.text(l)!==m&&e.text(l,m)}else{let c=s(e,l,n,r[a],{depth:o.depth+1,path:[...o.path,a]},i);c&&c!==l&&(t[a]=c)}})}function Dm(e,t,n,r){return n===null?e.text(t):dr(e,t,n,r.onRowsRead?{...r,onRowsRead:void 0}:r)}function fu(e,t,n){let r=e.children(t);for(let o=0;o<r.length;o++)if(e.sameNode(r[o],n))return o;return-1}function Fm(e,t,n,r){if(!r.templateAttr)return null;let o=/^\s*:scope\s*>\s*/.test(n),s=new RegExp(":not\\(\\["+r.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),i=n.replace(/^\s*:scope\s*>\s*/,"").replace(s,""),l=o?Bm(i):0,a=Mi(i),c=t;for(;c;){let m=e.find(c,i,{includeRulesTag:!1,templateAttr:null});for(let u of m)if(e.attr(u,r.templateAttr)!=null&&!(o&&!Um(e,t,u,l))&&!(a&&!e.matches(e.parent(u),a)))return u;c=e.parent(c)}return null}function Bm(e){let t=0,n=null,r=1;for(let o=0;o<e.length;o++){let s=e[o];if(s==="\\")o++;else if(n)s===n&&(n=null);else if(s==='"'||s==="'")n=s;else if(s==="["||s==="(")t++;else if(s==="]"||s===")")t>0&&t--;else if(t===0&&s===">")r++;else{if(t===0&&(s==="+"||s==="~"))return null;if(t===0&&/\s/.test(s)){if(!$m(e,o))return null;for(;o+1<e.length&&/\s/.test(e[o+1]);)o++}}}return r}function $m(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let r=t>0?e[t-1]:"",o=n<e.length?e[n]:"";return lu(r)||lu(o)}function lu(e){return e===">"||e==="+"||e==="~"}function Um(e,t,n,r){if(r===null)return!0;let o=n;for(let a=0;a<r;a++)if(o=e.parent(o),!o)return!1;let s=e.prop(t,"tagName");if(!s)return!0;let i=e.prop(o,"tagName");if(!i||String(i).toLowerCase()!==String(s).toLowerCase())return!1;let l=new Set(au(e,o));return au(e,t).every(a=>l.has(a))}function au(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Hm(e,t,n,r,o,s){let i=e.parent(r);if(i&&zm(e,t,i)&&!uu(e,i,s))return i;let l=Mi(n);if(!l)throw new fr(o.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let c=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,s)).filter(m=>!uu(e,m,s));if(c.length===0)throw new fr(o.path,`no container matching "${l}" inside this context to hold the new rows`);if(c.length>1)throw new fr(o.path,`"${l}" matches ${c.length} containers inside this context, so the new rows have no single destination`);return c[0]}function zm(e,t,n){let r=n;for(;r;){if(e.sameNode(r,t))return!0;r=e.parent(r)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(o=>e.sameNode(o,n))}var cu=["no-data","editor-ui"];function uu(e,t,n){let r=t;for(;r;){if(n.templateAttr&&e.attr(r,n.templateAttr)!=null||cu.some(s=>e.attr(r,s)!=null))return!0;let o=e.attr(r,"clay");if(o&&o.split(/\s+/).some(s=>cu.includes(s)))return!0;r=e.parent(r)}return!1}function Vm(e,t,n,r,o){let s=e.children(t),i=s.map(a=>e.identity(a)),l=!1;r.forEach((a,c)=>{let m=e.identity(a),u=n+c;if(i[u]===m)return;if(!o[c]){let p=i.indexOf(m);p!==-1&&(i.splice(p,1),s.splice(p,1))}let f=Math.min(u,s.length);f<s.length?e.insertBefore(s[f],a):s.length?l?e.insertAfter(s[s.length-1],a):(e.insertAt(t,a,u),l=!0):e.insertAt(t,a,0),i.splice(f,0,m),s.splice(f,0,a)})}function Wm(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let r=new Map(e.children(n).map((s,i)=>[e.identity(s),i])),o=[];for(let s of t){let i=r.get(e.identity(s));if(i===void 0)return!1;o.push(i)}return o.sort((s,i)=>s-i),o[o.length-1]-o[0]===o.length-1}function Km(e,t,n,r,o){let s=null,i=o;for(let l=0;l<t.length;l++){if(!n[l]){s=t[l];continue}let a=s?e.parent(s):r;if(!a)continue;let c=s?fu(e,a,s)+1:i++;e.insertAt(a,t[l],c),s=t[l]}}function lo(e,t,n,r,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let s=[];if(Tl(n,r,[],s),s.length)throw new zo(s);js(e,t,n,r,{depth:0,path:[]},o)}function js(e,t,n,r,o,s={}){if(o.depth>oo)throw new Cr(o.path);if(r===void 0)return t;if(typeof n=="string")return Gm(e,t,n,r,o,s);if(Array.isArray(n)){let[i,l]=n;return Al(e,t,i,l,r,o,js,s),t}if(typeof n=="object"&&n!==null){for(let[i,l]of Object.entries(n)){let a=js(e,t,l,r==null?r:r[i],{depth:o.depth+1,path:[...o.path,i]},s);a&&a!==t&&(t=a)}return t}return t}function Gm(e,t,n,r,o,s){if(n.endsWith("[]")){let a=n.slice(0,-2);return Al(e,t,a,null,r,o,js,s),t}if(n.startsWith("@"))return hu(e,t,n.slice(1),r);let i=Kt(n);if(i!==-1){let a=n.slice(0,i),c=n.slice(i+1),m=a?e.find(t,a,s):[t];return m.length===0||hu(e,m[0],c,r),t}if(n===".")return du(e,t,r),t;let l=e.find(t,n,s);return l.length===0||du(e,l[0],r),t}function du(e,t,n){let r=n==null?"":String(n);e.text(t)!==r&&e.text(t,r)}function Ym(e,t,n,r){if(e.styleVar){e.styleVar(t,n,r);return}yl(e,t,n,r)}function hu(e,t,n,r){if(_r(n))return Ym(e,t,n,r==null?"":String(r).trim()),t;if(Hr.has(n)){let o=e.prop(t,n);if(o===r||o!=null&&r!=null&&String(o)===String(r))return t;throw new Vo(n)}if(n==="outerHTML"){let o=r==null?"":String(r);return e.replaceWith(t,o)}if(Ci.has(n)){let o=_i(n,r);return e.prop(t,n)!==o&&e.prop(t,n,o),t}if(r==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let o=String(r);e.attr(t,n)!==o&&e.attr(t,n,o)}return t}function Tl(e,t,n,r){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((o,s)=>{typeof o=="object"&&o!==null&&r.push({path:Zo([...n,s]),expected:"scalar",got:Jo(o)})}):r.push({path:Zo(n),expected:"array",got:Jo(t)});return}t!==null&&typeof t=="object"&&r.push({path:Zo(n),expected:"scalar",got:Jo(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){r.push({path:Zo(n),expected:"array",got:Jo(t)});return}let o=e[1];t.forEach((s,i)=>Tl(o,s,[...n,i],r));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){r.push({path:Zo(n),expected:"object",got:Jo(t)});return}for(let[o,s]of Object.entries(e))Tl(s,t[o],[...n,o],r)}}}function Jo(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Zo(e){return e.join(".")}var pu=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...Hc],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})});function lp(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let r=0;r<e.length;r++){let o=e[r];if(n){o===n&&(n=null);continue}if(o==='"'||o==="'")n=o;else{if(o==="/"&&e[r+1]==="*")return"comments are not allowed in a custom property value";if(o==="(")t.push(")");else if(o==="[")t.push("]");else if((o===")"||o==="]")&&t.pop()!==o)return`"${o}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function El(e,t=pu){let n=t.customPropertyValues,r=String(e);if(r.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let o=n.refusedCharacters.find(a=>r.includes(a));if(o)return`${JSON.stringify(o)} is not allowed in a custom property value`;let s=lp(r);if(s)return s;let i=r.toLowerCase(),l=n.refusedFunctions.find(a=>new RegExp(`(^|[^a-z0-9_-])${a.replace(/[-]/g,"\\-")}\\s*\\(`).test(i));return l?`"${l}()" is not allowed in a custom property value`:null}function Ol(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let r=t&&t.ownerDocument?t.ownerDocument:t;return Xo(e,r,n)}return null}var fn={extract:(e,t,n={})=>dr(Zn(e,n),e,t,n),apply:(e,t,n,r={})=>lo(Zn(e,{...r,_write:!0}),e,t,n,r),findRulesIn:(e,t)=>Xo(so,e,t),findRules:(e,t)=>Ol(so,e,t),bind:(e,t,n={})=>{let r=Ol(so,e,t);if(!r){let o=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${o}`)}return{...r,get:()=>dr(Zn(e,n),e,r.rules,n),set:o=>lo(Zn(e,{...n,_write:!0}),e,r.rules,o,n)}},parseStrict:wl,parseRelaxed:io,ruleAttrIndex:Kt,splitRule:Lo,errors:Ls,DOM_PROPERTIES:gs};var Cl={};Ni(Cl,{fromString:()=>Qn,getRuleAtPath:()=>er,getValueAtPath:()=>dp,setAtPath:()=>Nl,toString:()=>fp});function fp(e){return e.map(String).join(".")}function Qn(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function er(e,t){let n=e;for(let r of t){if(n==null)return;if(typeof n=="string"){if(n.endsWith("[]")&&(typeof r=="number"||r==="*")){n=n.slice(0,-2);continue}return}if(Array.isArray(n)){if(typeof r!="number"&&r!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof r=="number"||!(r in n))return;n=n[r];continue}return}return n}function dp(e,t){let n=e;for(let r of t){if(n==null)return;n=n[r]}return n}function Nl(e,t,n){if(t.length===0)return n;let[r,...o]=t;if(typeof r=="number"){let s=Array.isArray(e)?[...e]:[];return s[r]=Nl(s[r],o,n),s}return{...e&&typeof e=="object"?e:{},[r]:Nl((e||{})[r],o,n)}}function Qo(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[n,r]of Object.entries(e))t[n]=Qo(r);return t}return""}function qs(e,t,{ignoreActiveValue:n=!0}={}){gl.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:n,restoreFocus:!0,formStateSync:"property",policy:"raw"})}var gu=new WeakMap,_l=e=>e.map(String).join(".");function hp(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function bu(e,t){if(!e||!e.querySelector)return null;let n=e.querySelector(`[data-hcms-path="${hp(t)}"]`),r=n&&n.querySelector(".hcms-array-items");return r?Array.from(r.children).filter(o=>o.matches&&o.matches("[data-hcms-card], [data-hcms-array-item]")):null}function ku(e,t,n){let r=bu(e,t);!r||r.length!==n.length||r.forEach((o,s)=>{n[s]&&gu.set(o,n[s])})}function Ds(){let e=new Map;return{hooks:{onRowsRead(t,n){e.set(_l(t),n)}},seed(t){for(let[n,r]of e)ku(t,n,r);e.clear()}}}function yu(e){return{identifyRows(t,n){let r=bu(e,_l(t));return!r||r.length!==n.length?null:r.map(o=>gu.get(o)||null)},onRowsApplied(t,n){ku(e,_l(t),n)}}}function Pn(e){return e&&e.nodeType===9?e.body||e.documentElement:e}function Fs(e,t){if(!t||t.nodeType!==9)return e;return n(e);function n(r){if(typeof r=="string")return r==="."?"body":r.startsWith("@")?`body${r}`:r;if(Array.isArray(r)||!r||typeof r!="object")return r;let o={};for(let[s,i]of Object.entries(r))o[s]=n(i);return o}}var vu={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Ml="data-hcms-rollback-ui",mp=0;function xu(e,t,n,r={}){return pp(e,t,n,r)}function pp(e,t,n,r){let{shellRoot:o,structural:s,structuralPath:i,formRoot:l}=r,a=l?{...vu,...yu(l)}:vu;if(!s)try{return fn.apply(e,t,n,a),{ok:!0}}catch(f){return{ok:!1,error:f}}let c=gp(e,t,i),m=c?kp(c):null,u=c?null:vp(Pn(e),o);try{return fn.apply(e,t,n,a),{ok:!0}}catch(f){return m?yp(c,m):u&&xp(Pn(e),o,u),{ok:!1,error:f}}}function gp(e,t,n){if(!n||!e)return null;let r=Qn(n),o=[],s=t;for(let i of r){if(typeof s=="string"||s==null||Array.isArray(s))break;if(typeof s=="object"&&i in s){if(o.push(i),s=s[i],Array.isArray(s)||typeof s=="string"&&s.endsWith("[]"))break}else return null}return!Array.isArray(s)&&!(typeof s=="string"&&s.endsWith("[]"))?null:bp(e,t,o)}function bp(e,t,n){if(n.length===0)return null;let r=e,o=t;for(let s=0;s<n.length;s++){let i=n[s];if(!o||typeof o!="object"||Array.isArray(o))return null;let l=o[i];if(l==null)return null;if(s===n.length-1){if(Array.isArray(l)){let[a]=l;return r.querySelector?.(a)?.parentElement||null}if(typeof l=="string"&&l.endsWith("[]")){let a=l.slice(0,-2);return r.querySelector?.(a)?.parentElement||null}return null}o=l}return null}function kp(e){let t=[],n=[];for(let r of Array.from(e.childNodes))t.push(Rl(r,n));return{nodes:t,retained:n}}function yp(e,t){let n=e.cloneNode(!1);for(let r of t.nodes)n.appendChild(r);ur(e,Array.from(n.childNodes),Su()),wu(e,t.retained)}function vp(e,t){let n=[],r=[];for(let o of Array.from(e.childNodes))o===t||t&&o.contains?.(t)||n.push(Rl(o,r));return{nodes:n,retained:r}}function xp(e,t,n){let r=e.cloneNode(!1);for(let o of n.nodes)r.appendChild(o);ur(e,Array.from(r.childNodes),Su()),wu(e,n.retained)}function Rl(e,t){let n=e.cloneNode(!1);if(e.nodeType===1&&e.matches('[editor-ui],[clay~="editor-ui"]')){let s=String(++mp);n.setAttribute(Ml,s),t.push({id:s,node:e})}let r=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,o=n.nodeType===1&&n.tagName==="TEMPLATE"?n.content:n;for(let s of Array.from(r.childNodes||[]))o.appendChild(Rl(s,t));return n}function wu(e,t){for(let{id:n,node:r}of t){let o=e.querySelector(`[${Ml}="${n}"]`);o===r?r.removeAttribute(Ml):r.isConnected?o?.remove():o?.replaceWith(r)}}function Su(){return{morphStyle:"innerHTML",policy:"raw",restoreFocus:!1,scripts:{handle:!1,merge:!1}}}var wp=/^--font-(size|weight|style|stretch|variant|feature-settings|variation-settings|optical-sizing|kerning|synthesis|smoothing|palette|size-adjust|display)(-|$)/;function Mr(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/[-_]/g," ").replace(/\s+/g," ").trim().replace(/^./,t=>t.toUpperCase())}var Sp='<div class="hcms-drag-handle mirk-sortable__grip" aria-hidden="true"><div class="mirk-sortable__dots"><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span><span class="mirk-sortable__dot"></span></div></div>',Bs='<svg class="hcms-x" viewBox="0 0 16 16" shape-rendering="crispEdges" aria-hidden="true"><path d="M4 4 L12 12 M12 4 L4 12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="square"></path></svg>',Ou={"@scalar":`
7
7
  <label class="hcms-field" data-hcms-shape="scalar">
8
8
  <span class="hcms-label" data-hcms-label></span>
9
9
  <textarea class="mirk-textarea" rows="1" data-hcms-field></textarea>
@@ -43,13 +43,13 @@ var hypercms=(()=>{var Ci=Object.defineProperty;var Qd=Object.getOwnPropertyDesc
43
43
  </section>
44
44
  `,"@object-array-item":`
45
45
  <article class="hcms-card mirk-sortable__item" draggable="true">
46
- ${Dp}
46
+ ${Sp}
47
47
  <div class="hcms-card-body mirk-sortable__body">
48
48
  <div class="hcms-card-fields"></div>
49
49
  <div class="hcms-card-controls">
50
50
  <button type="button" class="hcms-move hcms-move-up hcms-sr-only" data-hcms-action="move-up" aria-label="Move up">\u2191</button>
51
51
  <button type="button" class="hcms-move hcms-move-down hcms-sr-only" data-hcms-action="move-down" aria-label="Move down">\u2193</button>
52
- <button type="button" class="hcms-remove hcms-remove--card" data-hcms-action="remove" aria-label="Remove">${Us}</button>
52
+ <button type="button" class="hcms-remove hcms-remove--card" data-hcms-action="remove" aria-label="Remove">${Bs}</button>
53
53
  </div>
54
54
  </div>
55
55
  <div class="hcms-error" hidden></div>
@@ -63,7 +63,7 @@ var hypercms=(()=>{var Ci=Object.defineProperty;var Qd=Object.getOwnPropertyDesc
63
63
  <span class="mirk-button__label">Choose</span>
64
64
  </label>
65
65
  <a class="mirk-file__name" data-hcms-field></a>
66
- <button type="button" class="hcms-upload-clear" data-hcms-action="clear-upload" aria-label="Remove file">${Us}</button>
66
+ <button type="button" class="hcms-upload-clear" data-hcms-action="clear-upload" aria-label="Remove file">${Bs}</button>
67
67
  </div>
68
68
  <div class="hcms-error" hidden></div>
69
69
  </div>
@@ -77,7 +77,7 @@ var hypercms=(()=>{var Ci=Object.defineProperty;var Qd=Object.getOwnPropertyDesc
77
77
  </label>
78
78
  <figure class="mirk-image__thumb">
79
79
  <span class="mirk-image__frame"><img class="mirk-image__preview" data-hcms-field alt="" /></span>
80
- <button type="button" class="hcms-upload-clear hcms-upload-clear--badge" data-hcms-action="clear-upload" aria-label="Remove image">${Us}</button>
80
+ <button type="button" class="hcms-upload-clear hcms-upload-clear--badge" data-hcms-action="clear-upload" aria-label="Remove image">${Bs}</button>
81
81
  </figure>
82
82
  </div>
83
83
  <div class="hcms-error" hidden></div>
@@ -148,7 +148,7 @@ var hypercms=(()=>{var Ci=Object.defineProperty;var Qd=Object.getOwnPropertyDesc
148
148
  <span class="hcms-color-chip"></span>
149
149
  <span class="hcms-color-name"></span>
150
150
  </button>
151
- <button type="button" class="hcms-color-clear" data-hcms-action="color-clear" aria-label="Clear color">${Us}</button>
151
+ <button type="button" class="hcms-color-clear" data-hcms-action="color-clear" aria-label="Clear color">${Bs}</button>
152
152
  </div>
153
153
  <div class="hcms-color-panel" hidden>
154
154
  <div class="hcms-color-grid"></div>
@@ -196,9 +196,9 @@ var hypercms=(()=>{var Ci=Object.defineProperty;var Qd=Object.getOwnPropertyDesc
196
196
  <input class="hcms-chip-field" data-hcms-field aria-label="Item" placeholder="\u2026" />
197
197
  <button type="button" class="hcms-remove" data-hcms-action="remove" aria-label="Remove">\xD7</button>
198
198
  </span>
199
- `},Fp=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function zs(e){let t=e.head||e.documentElement;if(t)for(let n of Fp)Du(e,t,n)}function Pl(e,t){if(!Lu[t])return null;let n=e&&(e.head||e.documentElement);return n?Du(e,n,t):null}var _u={src:"@image",checked:"@checkbox",innerHTML:"@richtext"},Hs={image:"@image",file:"@file",checkbox:"@checkbox",toggle:"@toggle",select:"@select",radio:"@radio",textarea:"@textarea",number:"@number",richtext:"@richtext",color:"@color",font:"@font",variant:"@variant"},Bp=new Set([...Object.values(Hs),"@chips","@chips-item"]);function mr(e,t,n,r){if(typeof e!="string")return"@scalar";let o=Kt(e),s=qu(e,o,n,r),i=Ks(e,o,n,r,t,"data-hcms-component");if(i&&Hs[i]){let l=Hs[i],a=Array.isArray(n)&&n.some(c=>c==="*"||typeof c=="number");return l==="@number"&&!Mu(e,o,t,a,s).every(zp)||(l==="@checkbox"||l==="@toggle")&&(o<0||e.slice(o+1)!=="checked")&&!Mu(e,o,t,a,s).every(Vp)?"@scalar":l}if(o>=0){let l=e.slice(o+1);if(_u[l])return _u[l];if(/^--color(-|$)/.test(l)&&l!=="--color-scheme")return"@color";if(/^--font(-|$)/.test(l)&&!qp.test(l))return"@font"}return"@scalar"}function Iu(e,t,n,r){if(typeof e!="string")return null;let o=Kt(e),s=Ks(e,o,n,r,t,"data-hcms-component");return s&&Hs[s]||null}var $p=new Set(["@color","@font","@variant"]),Up=new Set(["html","body",":root"]);function ns(e,t,n,r){if(typeof e!="string"||e.endsWith("[]")||!$p.has(mr(e,t,n,r)))return null;let o=Array.isArray(n)&&n.some(i=>i==="*"||typeof i=="number"),s=ju(e,Kt(e)).trim();return!o&&Up.has(s)?"page":"section"}var Hp=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function zp(e){return e==null||e===""?!0:Hp.test(String(e))}function Vp(e){return e==null||e===""||e==="true"||e==="false"}function Mu(e,t,n,r,o){if(!n||!n.querySelectorAll)return[];if(!o||o===".")return[];let s=null;try{s=n.querySelectorAll(o)}catch{return[]}let i=t>=0?e.slice(t+1):null,l=[];for(let a of s)if(!(a.closest&&a.closest("[cms-template], [data-hcms-shell]"))&&(i?i==="value"&&"value"in a?l.push(a.value):l.push(a.getAttribute?a.getAttribute(i):null):l.push((a.textContent||"").trim()),!r))break;return l}function Vs(e,t){if(typeof e!="string"||!e.endsWith("[]")||!t||!t.querySelector)return null;let n=e.slice(0,-2).trim();if(!n)return null;let r=null;try{r=t.querySelector(n)}catch{return null}let o=r&&r.closest?r.closest("[data-hcms-component]"):null;return(o&&o.getAttribute?o.getAttribute("data-hcms-component"):null)==="chips"?{array:"@chips",item:"@chips-item"}:null}function Ir(e,t,n){let r=e.join("."),o=e.map(s=>typeof s=="number"?"*":s).join(".");return r&&Cn(n,r)||o&&o!==r&&Cn(n,o)||Cn(n,t)}function Ws(e,t,n){let r=Vs(e,n);if(!r)return null;let o=Ir(t,r.array,n);return o&&o.getAttribute("data-hcms-tpl")===r.array?r:null}function rs(e,t,n,r){if(typeof e!="string")return null;let o=Kt(e),s=Ks(e,o,n,r,t,"data-hcms-options");if(s==null)return null;let i=s.trim().split(/\s+/).filter(Boolean);return i.length?i:null}function Pu(e,t,n,r){if(typeof e!="string")return null;let o=Kt(e);return Ks(e,o,n,r,t,"data-hcms-crop")}function ju(e,t){return t>=0?e.slice(0,t):e}function qu(e,t,n,r){let o=ju(e,t);return o&&o!=="."?o:Wp(r,n)}function Wp(e,t){if(e==null||!Array.isArray(t))return"";let n=[],r=e;for(let o of t){if(r==null||typeof r=="string")break;if(Array.isArray(r)){if(typeof r[0]!="string"||o!=="*"&&typeof o!="number")return"";n.push(r[0]),r=r[1];continue}if(typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,o))return"";r=r[o]}return n.join(" ")}function Ru(e,t,n){if(!t||!t.querySelector||!e||e===".")return null;let r=null;try{r=t.querySelector(e)}catch{return null}return r&&r.getAttribute?r.getAttribute(n):null}function Ks(e,t,n,r,o,s){let i=qu(e,t,n,r),l=t>=0?e.slice(t+1):null;if(l){let a=Ru(i,o,`${s}:${l}`);if(a!=null)return a;if(l.startsWith("--"))return null}return Ru(i,o,s)}function Gs(e,t){if(!e||t==null)return;n(t,[]);function n(r,o){let s=pr(r);if(s==="scalar"){let i=mr(r,e,o,t);Bp.has(i)&&Pl(e,i);return}if(s==="scalar-array"){let i=Vs(r,e);i&&(Pl(e,i.array),Pl(e,i.item));return}if(s==="object"){for(let[i,l]of Object.entries(r))n(l,[...o,i]);return}if(s==="object-array"){let i=r[1],l=[...o,"*"];if(i&&typeof i=="object"&&!Array.isArray(i))for(let[a,c]of Object.entries(i))n(c,[...l,a]);else n(i,l)}}}function Du(e,t,n){let r=Cn(e,n);if(r)return r;let o=e.createElement("template");return o.setAttribute("data-hcms-tpl",n),o.setAttribute("save-remove",""),o.innerHTML=Lu[n].trim(),t.appendChild(o),o}function Cn(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${Kp(t)}"]`)}function Kp(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function pr(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function uo(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var Fu={IMG:"src",A:"href"};function Ys(e){return e.map(t=>typeof t=="number"||/^[0-9]+$/.test(String(t))?"*":String(t)).join(".")}function Xs(e){if(!e)return"value";let t=(e.tagName||"").toUpperCase();return t==="INPUT"?(e.getAttribute("type")||"text").toLowerCase()==="checkbox"?"checked":"value":t==="TEXTAREA"||t==="SELECT"?"value":Fu[t]?Fu[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function Bu(e,t){let n=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),o=Xs(e),i=`${Uu(n,r)}[data-hcms-field="${Pr(t)}"]`;return n==="INPUT"&&r==="radio"?`${i}:checked@value`:o?`${i}@${o}`:i}function Gp(e){let t=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),r=Xs(e),s=`${Uu(t,n)}[data-hcms-field]`;return t==="INPUT"&&n==="radio"?`${s}:checked@value`:r?`${s}@${r}`:s}function Uu(e,t){return e==="INPUT"?t?`input[type="${t}"]`:"input":e==="TEXTAREA"?"textarea":e==="SELECT"?"select":e==="IMG"?"img":e==="A"?"a":':not([data-hcms-shape="scalar"]):not([data-hcms-shape="object"]):not([data-hcms-shape="object-array"]):not([data-hcms-shape="scalar-array"])'}function Pr(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var $u=new Set(["__proto__","constructor","prototype"]);function Yp(e){let t=new Map;return n(e,null),t;function n(r,o){if(typeof r=="string"){typeof o=="string"&&!r.endsWith("[]")&&t.set(o,(t.get(o)||0)+1);return}if(Array.isArray(r)){n(r[1],null);return}if(r&&typeof r=="object")for(let[s,i]of Object.entries(r))n(i,s)}}function Js(e,t){let n=Yp(e);return r(e,[]);function r(u,f){let h=pr(u);if(h==="scalar")return o(u,f);if(h==="scalar-array")return i(u,f);if(h==="object-array")return l(u,f);if(h==="object"){let d=Object.create(null);for(let[v,g]of Object.entries(u)){if($u.has(v))throw new Error(`hypercms: rule key "${v}" is forbidden at "${f.join(".")||"<root>"}"`);d[v]=r(g,[...f,v])}return d}return null}function o(u,f){let h=f.length?f[f.length-1]:null,d=typeof h=="string"?h:"__value",v=p(f,d);if(v)return s(f,d,Bu(v,d));let g=c(mr(u,t,f,e),d);return g?s(f,d,Bu(g,d)):s(f,d,`input[data-hcms-field="${Pr(d)}"]@value`)}function s(u,f,h){if((n.get(f)||0)<2)return h;let d=`[data-hcms-path-shape="${Pr(Ys(u))}"]`,v=h.lastIndexOf("@"),g=v===-1?h:h.slice(0,v),m=v===-1?"":h.slice(v);return`${d} ${g}, ${g}${d}${m}`}function i(u,f){let h=Ws(u,f,t),d=h&&c(h.item,null)||c("@scalar-array-item",null),v=d?Gp(d):"input[data-hcms-field]@value";return[a(f,"[data-hcms-array-item]"),v]}function l(u,f){let[,h]=u,d=[...f,"*"],v=a(f,"[data-hcms-card]");if(h&&typeof h=="object"&&!Array.isArray(h)){let g=Object.create(null);for(let[m,k]of Object.entries(h)){if($u.has(m))throw new Error(`hypercms: rule key "${m}" is forbidden at "${d.join(".")}"`);g[m]=r(k,[...d,m])}return[v,g]}return[v,r(h,[...d,0])]}function a(u,f){let h=u.length?u[u.length-1]:"",d=u.some(m=>m==="*"),v=u.join(".");return`${d?`[data-hcms-field="${Pr(h)}"]`:`[data-hcms-path="${Pr(v)}"]`} > .hcms-array-items > ${f}`}function c(u,f){if(!t)return null;let h=Cn(t,u);if(!h)return null;let d=h.content||h;if(f){let v=d.querySelector(`[data-hcms-field="${Pr(f)}"]`);if(v)return v}return d.querySelector("[data-hcms-field]")}function p(u,f){if(!t)return null;let h=u.map(g=>typeof g=="number"?"*":g).join("."),v=[u.join("."),h];for(let g=u.length-1;g>=0;g--){let m=u.slice(0,g).map(k=>typeof k=="number"?"*":k);pr(tr(e,m))==="object"&&v.push(m.join(".")),m.push("*"),v.push(m.join("."))}for(let g of v){if(!g)continue;let m=Cn(t,g);if(!m||!uo(m))continue;let k=m.content||m,S=k.querySelector(`[data-hcms-field="${Pr(f)}"]`)||k.querySelector("[data-hcms-field]");if(S)return S}return null}}var Hu=["50","100","200","300","400","500","600","700","800","900","950"],zu=["red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose","slate","gray","zinc","neutral","stone","mauve","olive","mist","taupe"],fo=Object.freeze([{id:"red-50",hue:"red",shade:"50",value:"oklch(97.1% 0.013 17.38)"},{id:"red-100",hue:"red",shade:"100",value:"oklch(93.6% 0.032 17.717)"},{id:"red-200",hue:"red",shade:"200",value:"oklch(88.5% 0.062 18.334)"},{id:"red-300",hue:"red",shade:"300",value:"oklch(80.8% 0.114 19.571)"},{id:"red-400",hue:"red",shade:"400",value:"oklch(70.4% 0.191 22.216)"},{id:"red-500",hue:"red",shade:"500",value:"oklch(63.7% 0.237 25.331)"},{id:"red-600",hue:"red",shade:"600",value:"oklch(57.7% 0.245 27.325)"},{id:"red-700",hue:"red",shade:"700",value:"oklch(50.5% 0.213 27.518)"},{id:"red-800",hue:"red",shade:"800",value:"oklch(44.4% 0.177 26.899)"},{id:"red-900",hue:"red",shade:"900",value:"oklch(39.6% 0.141 25.723)"},{id:"red-950",hue:"red",shade:"950",value:"oklch(25.8% 0.092 26.042)"},{id:"orange-50",hue:"orange",shade:"50",value:"oklch(98% 0.016 73.684)"},{id:"orange-100",hue:"orange",shade:"100",value:"oklch(95.4% 0.038 75.164)"},{id:"orange-200",hue:"orange",shade:"200",value:"oklch(90.1% 0.076 70.697)"},{id:"orange-300",hue:"orange",shade:"300",value:"oklch(83.7% 0.128 66.29)"},{id:"orange-400",hue:"orange",shade:"400",value:"oklch(75% 0.183 55.934)"},{id:"orange-500",hue:"orange",shade:"500",value:"oklch(70.5% 0.213 47.604)"},{id:"orange-600",hue:"orange",shade:"600",value:"oklch(64.6% 0.222 41.116)"},{id:"orange-700",hue:"orange",shade:"700",value:"oklch(55.3% 0.195 38.402)"},{id:"orange-800",hue:"orange",shade:"800",value:"oklch(47% 0.157 37.304)"},{id:"orange-900",hue:"orange",shade:"900",value:"oklch(40.8% 0.123 38.172)"},{id:"orange-950",hue:"orange",shade:"950",value:"oklch(26.6% 0.079 36.259)"},{id:"amber-50",hue:"amber",shade:"50",value:"oklch(98.7% 0.022 95.277)"},{id:"amber-100",hue:"amber",shade:"100",value:"oklch(96.2% 0.059 95.617)"},{id:"amber-200",hue:"amber",shade:"200",value:"oklch(92.4% 0.12 95.746)"},{id:"amber-300",hue:"amber",shade:"300",value:"oklch(87.9% 0.169 91.605)"},{id:"amber-400",hue:"amber",shade:"400",value:"oklch(82.8% 0.189 84.429)"},{id:"amber-500",hue:"amber",shade:"500",value:"oklch(76.9% 0.188 70.08)"},{id:"amber-600",hue:"amber",shade:"600",value:"oklch(66.6% 0.179 58.318)"},{id:"amber-700",hue:"amber",shade:"700",value:"oklch(55.5% 0.163 48.998)"},{id:"amber-800",hue:"amber",shade:"800",value:"oklch(47.3% 0.137 46.201)"},{id:"amber-900",hue:"amber",shade:"900",value:"oklch(41.4% 0.112 45.904)"},{id:"amber-950",hue:"amber",shade:"950",value:"oklch(27.9% 0.077 45.635)"},{id:"yellow-50",hue:"yellow",shade:"50",value:"oklch(98.7% 0.026 102.212)"},{id:"yellow-100",hue:"yellow",shade:"100",value:"oklch(97.3% 0.071 103.193)"},{id:"yellow-200",hue:"yellow",shade:"200",value:"oklch(94.5% 0.129 101.54)"},{id:"yellow-300",hue:"yellow",shade:"300",value:"oklch(90.5% 0.182 98.111)"},{id:"yellow-400",hue:"yellow",shade:"400",value:"oklch(85.2% 0.199 91.936)"},{id:"yellow-500",hue:"yellow",shade:"500",value:"oklch(79.5% 0.184 86.047)"},{id:"yellow-600",hue:"yellow",shade:"600",value:"oklch(68.1% 0.162 75.834)"},{id:"yellow-700",hue:"yellow",shade:"700",value:"oklch(55.4% 0.135 66.442)"},{id:"yellow-800",hue:"yellow",shade:"800",value:"oklch(47.6% 0.114 61.907)"},{id:"yellow-900",hue:"yellow",shade:"900",value:"oklch(42.1% 0.095 57.708)"},{id:"yellow-950",hue:"yellow",shade:"950",value:"oklch(28.6% 0.066 53.813)"},{id:"lime-50",hue:"lime",shade:"50",value:"oklch(98.6% 0.031 120.757)"},{id:"lime-100",hue:"lime",shade:"100",value:"oklch(96.7% 0.067 122.328)"},{id:"lime-200",hue:"lime",shade:"200",value:"oklch(93.8% 0.127 124.321)"},{id:"lime-300",hue:"lime",shade:"300",value:"oklch(89.7% 0.196 126.665)"},{id:"lime-400",hue:"lime",shade:"400",value:"oklch(84.1% 0.238 128.85)"},{id:"lime-500",hue:"lime",shade:"500",value:"oklch(76.8% 0.233 130.85)"},{id:"lime-600",hue:"lime",shade:"600",value:"oklch(64.8% 0.2 131.684)"},{id:"lime-700",hue:"lime",shade:"700",value:"oklch(53.2% 0.157 131.589)"},{id:"lime-800",hue:"lime",shade:"800",value:"oklch(45.3% 0.124 130.933)"},{id:"lime-900",hue:"lime",shade:"900",value:"oklch(40.5% 0.101 131.063)"},{id:"lime-950",hue:"lime",shade:"950",value:"oklch(27.4% 0.072 132.109)"},{id:"green-50",hue:"green",shade:"50",value:"oklch(98.2% 0.018 155.826)"},{id:"green-100",hue:"green",shade:"100",value:"oklch(96.2% 0.044 156.743)"},{id:"green-200",hue:"green",shade:"200",value:"oklch(92.5% 0.084 155.995)"},{id:"green-300",hue:"green",shade:"300",value:"oklch(87.1% 0.15 154.449)"},{id:"green-400",hue:"green",shade:"400",value:"oklch(79.2% 0.209 151.711)"},{id:"green-500",hue:"green",shade:"500",value:"oklch(72.3% 0.219 149.579)"},{id:"green-600",hue:"green",shade:"600",value:"oklch(62.7% 0.194 149.214)"},{id:"green-700",hue:"green",shade:"700",value:"oklch(52.7% 0.154 150.069)"},{id:"green-800",hue:"green",shade:"800",value:"oklch(44.8% 0.119 151.328)"},{id:"green-900",hue:"green",shade:"900",value:"oklch(39.3% 0.095 152.535)"},{id:"green-950",hue:"green",shade:"950",value:"oklch(26.6% 0.065 152.934)"},{id:"emerald-50",hue:"emerald",shade:"50",value:"oklch(97.9% 0.021 166.113)"},{id:"emerald-100",hue:"emerald",shade:"100",value:"oklch(95% 0.052 163.051)"},{id:"emerald-200",hue:"emerald",shade:"200",value:"oklch(90.5% 0.093 164.15)"},{id:"emerald-300",hue:"emerald",shade:"300",value:"oklch(84.5% 0.143 164.978)"},{id:"emerald-400",hue:"emerald",shade:"400",value:"oklch(76.5% 0.177 163.223)"},{id:"emerald-500",hue:"emerald",shade:"500",value:"oklch(69.6% 0.17 162.48)"},{id:"emerald-600",hue:"emerald",shade:"600",value:"oklch(59.6% 0.145 163.225)"},{id:"emerald-700",hue:"emerald",shade:"700",value:"oklch(50.8% 0.118 165.612)"},{id:"emerald-800",hue:"emerald",shade:"800",value:"oklch(43.2% 0.095 166.913)"},{id:"emerald-900",hue:"emerald",shade:"900",value:"oklch(37.8% 0.077 168.94)"},{id:"emerald-950",hue:"emerald",shade:"950",value:"oklch(26.2% 0.051 172.552)"},{id:"teal-50",hue:"teal",shade:"50",value:"oklch(98.4% 0.014 180.72)"},{id:"teal-100",hue:"teal",shade:"100",value:"oklch(95.3% 0.051 180.801)"},{id:"teal-200",hue:"teal",shade:"200",value:"oklch(91% 0.096 180.426)"},{id:"teal-300",hue:"teal",shade:"300",value:"oklch(85.5% 0.138 181.071)"},{id:"teal-400",hue:"teal",shade:"400",value:"oklch(77.7% 0.152 181.912)"},{id:"teal-500",hue:"teal",shade:"500",value:"oklch(70.4% 0.14 182.503)"},{id:"teal-600",hue:"teal",shade:"600",value:"oklch(60% 0.118 184.704)"},{id:"teal-700",hue:"teal",shade:"700",value:"oklch(51.1% 0.096 186.391)"},{id:"teal-800",hue:"teal",shade:"800",value:"oklch(43.7% 0.078 188.216)"},{id:"teal-900",hue:"teal",shade:"900",value:"oklch(38.6% 0.063 188.416)"},{id:"teal-950",hue:"teal",shade:"950",value:"oklch(27.7% 0.046 192.524)"},{id:"cyan-50",hue:"cyan",shade:"50",value:"oklch(98.4% 0.019 200.873)"},{id:"cyan-100",hue:"cyan",shade:"100",value:"oklch(95.6% 0.045 203.388)"},{id:"cyan-200",hue:"cyan",shade:"200",value:"oklch(91.7% 0.08 205.041)"},{id:"cyan-300",hue:"cyan",shade:"300",value:"oklch(86.5% 0.127 207.078)"},{id:"cyan-400",hue:"cyan",shade:"400",value:"oklch(78.9% 0.154 211.53)"},{id:"cyan-500",hue:"cyan",shade:"500",value:"oklch(71.5% 0.143 215.221)"},{id:"cyan-600",hue:"cyan",shade:"600",value:"oklch(60.9% 0.126 221.723)"},{id:"cyan-700",hue:"cyan",shade:"700",value:"oklch(52% 0.105 223.128)"},{id:"cyan-800",hue:"cyan",shade:"800",value:"oklch(45% 0.085 224.283)"},{id:"cyan-900",hue:"cyan",shade:"900",value:"oklch(39.8% 0.07 227.392)"},{id:"cyan-950",hue:"cyan",shade:"950",value:"oklch(30.2% 0.056 229.695)"},{id:"sky-50",hue:"sky",shade:"50",value:"oklch(97.7% 0.013 236.62)"},{id:"sky-100",hue:"sky",shade:"100",value:"oklch(95.1% 0.026 236.824)"},{id:"sky-200",hue:"sky",shade:"200",value:"oklch(90.1% 0.058 230.902)"},{id:"sky-300",hue:"sky",shade:"300",value:"oklch(82.8% 0.111 230.318)"},{id:"sky-400",hue:"sky",shade:"400",value:"oklch(74.6% 0.16 232.661)"},{id:"sky-500",hue:"sky",shade:"500",value:"oklch(68.5% 0.169 237.323)"},{id:"sky-600",hue:"sky",shade:"600",value:"oklch(58.8% 0.158 241.966)"},{id:"sky-700",hue:"sky",shade:"700",value:"oklch(50% 0.134 242.749)"},{id:"sky-800",hue:"sky",shade:"800",value:"oklch(44.3% 0.11 240.79)"},{id:"sky-900",hue:"sky",shade:"900",value:"oklch(39.1% 0.09 240.876)"},{id:"sky-950",hue:"sky",shade:"950",value:"oklch(29.3% 0.066 243.157)"},{id:"blue-50",hue:"blue",shade:"50",value:"oklch(97% 0.014 254.604)"},{id:"blue-100",hue:"blue",shade:"100",value:"oklch(93.2% 0.032 255.585)"},{id:"blue-200",hue:"blue",shade:"200",value:"oklch(88.2% 0.059 254.128)"},{id:"blue-300",hue:"blue",shade:"300",value:"oklch(80.9% 0.105 251.813)"},{id:"blue-400",hue:"blue",shade:"400",value:"oklch(70.7% 0.165 254.624)"},{id:"blue-500",hue:"blue",shade:"500",value:"oklch(62.3% 0.214 259.815)"},{id:"blue-600",hue:"blue",shade:"600",value:"oklch(54.6% 0.245 262.881)"},{id:"blue-700",hue:"blue",shade:"700",value:"oklch(48.8% 0.243 264.376)"},{id:"blue-800",hue:"blue",shade:"800",value:"oklch(42.4% 0.199 265.638)"},{id:"blue-900",hue:"blue",shade:"900",value:"oklch(37.9% 0.146 265.522)"},{id:"blue-950",hue:"blue",shade:"950",value:"oklch(28.2% 0.091 267.935)"},{id:"indigo-50",hue:"indigo",shade:"50",value:"oklch(96.2% 0.018 272.314)"},{id:"indigo-100",hue:"indigo",shade:"100",value:"oklch(93% 0.034 272.788)"},{id:"indigo-200",hue:"indigo",shade:"200",value:"oklch(87% 0.065 274.039)"},{id:"indigo-300",hue:"indigo",shade:"300",value:"oklch(78.5% 0.115 274.713)"},{id:"indigo-400",hue:"indigo",shade:"400",value:"oklch(67.3% 0.182 276.935)"},{id:"indigo-500",hue:"indigo",shade:"500",value:"oklch(58.5% 0.233 277.117)"},{id:"indigo-600",hue:"indigo",shade:"600",value:"oklch(51.1% 0.262 276.966)"},{id:"indigo-700",hue:"indigo",shade:"700",value:"oklch(45.7% 0.24 277.023)"},{id:"indigo-800",hue:"indigo",shade:"800",value:"oklch(39.8% 0.195 277.366)"},{id:"indigo-900",hue:"indigo",shade:"900",value:"oklch(35.9% 0.144 278.697)"},{id:"indigo-950",hue:"indigo",shade:"950",value:"oklch(25.7% 0.09 281.288)"},{id:"violet-50",hue:"violet",shade:"50",value:"oklch(96.9% 0.016 293.756)"},{id:"violet-100",hue:"violet",shade:"100",value:"oklch(94.3% 0.029 294.588)"},{id:"violet-200",hue:"violet",shade:"200",value:"oklch(89.4% 0.057 293.283)"},{id:"violet-300",hue:"violet",shade:"300",value:"oklch(81.1% 0.111 293.571)"},{id:"violet-400",hue:"violet",shade:"400",value:"oklch(70.2% 0.183 293.541)"},{id:"violet-500",hue:"violet",shade:"500",value:"oklch(60.6% 0.25 292.717)"},{id:"violet-600",hue:"violet",shade:"600",value:"oklch(54.1% 0.281 293.009)"},{id:"violet-700",hue:"violet",shade:"700",value:"oklch(49.1% 0.27 292.581)"},{id:"violet-800",hue:"violet",shade:"800",value:"oklch(43.2% 0.232 292.759)"},{id:"violet-900",hue:"violet",shade:"900",value:"oklch(38% 0.189 293.745)"},{id:"violet-950",hue:"violet",shade:"950",value:"oklch(28.3% 0.141 291.089)"},{id:"purple-50",hue:"purple",shade:"50",value:"oklch(97.7% 0.014 308.299)"},{id:"purple-100",hue:"purple",shade:"100",value:"oklch(94.6% 0.033 307.174)"},{id:"purple-200",hue:"purple",shade:"200",value:"oklch(90.2% 0.063 306.703)"},{id:"purple-300",hue:"purple",shade:"300",value:"oklch(82.7% 0.119 306.383)"},{id:"purple-400",hue:"purple",shade:"400",value:"oklch(71.4% 0.203 305.504)"},{id:"purple-500",hue:"purple",shade:"500",value:"oklch(62.7% 0.265 303.9)"},{id:"purple-600",hue:"purple",shade:"600",value:"oklch(55.8% 0.288 302.321)"},{id:"purple-700",hue:"purple",shade:"700",value:"oklch(49.6% 0.265 301.924)"},{id:"purple-800",hue:"purple",shade:"800",value:"oklch(43.8% 0.218 303.724)"},{id:"purple-900",hue:"purple",shade:"900",value:"oklch(38.1% 0.176 304.987)"},{id:"purple-950",hue:"purple",shade:"950",value:"oklch(29.1% 0.149 302.717)"},{id:"fuchsia-50",hue:"fuchsia",shade:"50",value:"oklch(97.7% 0.017 320.058)"},{id:"fuchsia-100",hue:"fuchsia",shade:"100",value:"oklch(95.2% 0.037 318.852)"},{id:"fuchsia-200",hue:"fuchsia",shade:"200",value:"oklch(90.3% 0.076 319.62)"},{id:"fuchsia-300",hue:"fuchsia",shade:"300",value:"oklch(83.3% 0.145 321.434)"},{id:"fuchsia-400",hue:"fuchsia",shade:"400",value:"oklch(74% 0.238 322.16)"},{id:"fuchsia-500",hue:"fuchsia",shade:"500",value:"oklch(66.7% 0.295 322.15)"},{id:"fuchsia-600",hue:"fuchsia",shade:"600",value:"oklch(59.1% 0.293 322.896)"},{id:"fuchsia-700",hue:"fuchsia",shade:"700",value:"oklch(51.8% 0.253 323.949)"},{id:"fuchsia-800",hue:"fuchsia",shade:"800",value:"oklch(45.2% 0.211 324.591)"},{id:"fuchsia-900",hue:"fuchsia",shade:"900",value:"oklch(40.1% 0.17 325.612)"},{id:"fuchsia-950",hue:"fuchsia",shade:"950",value:"oklch(29.3% 0.136 325.661)"},{id:"pink-50",hue:"pink",shade:"50",value:"oklch(97.1% 0.014 343.198)"},{id:"pink-100",hue:"pink",shade:"100",value:"oklch(94.8% 0.028 342.258)"},{id:"pink-200",hue:"pink",shade:"200",value:"oklch(89.9% 0.061 343.231)"},{id:"pink-300",hue:"pink",shade:"300",value:"oklch(82.3% 0.12 346.018)"},{id:"pink-400",hue:"pink",shade:"400",value:"oklch(71.8% 0.202 349.761)"},{id:"pink-500",hue:"pink",shade:"500",value:"oklch(65.6% 0.241 354.308)"},{id:"pink-600",hue:"pink",shade:"600",value:"oklch(59.2% 0.249 0.584)"},{id:"pink-700",hue:"pink",shade:"700",value:"oklch(52.5% 0.223 3.958)"},{id:"pink-800",hue:"pink",shade:"800",value:"oklch(45.9% 0.187 3.815)"},{id:"pink-900",hue:"pink",shade:"900",value:"oklch(40.8% 0.153 2.432)"},{id:"pink-950",hue:"pink",shade:"950",value:"oklch(28.4% 0.109 3.907)"},{id:"rose-50",hue:"rose",shade:"50",value:"oklch(96.9% 0.015 12.422)"},{id:"rose-100",hue:"rose",shade:"100",value:"oklch(94.1% 0.03 12.58)"},{id:"rose-200",hue:"rose",shade:"200",value:"oklch(89.2% 0.058 10.001)"},{id:"rose-300",hue:"rose",shade:"300",value:"oklch(81% 0.117 11.638)"},{id:"rose-400",hue:"rose",shade:"400",value:"oklch(71.2% 0.194 13.428)"},{id:"rose-500",hue:"rose",shade:"500",value:"oklch(64.5% 0.246 16.439)"},{id:"rose-600",hue:"rose",shade:"600",value:"oklch(58.6% 0.253 17.585)"},{id:"rose-700",hue:"rose",shade:"700",value:"oklch(51.4% 0.222 16.935)"},{id:"rose-800",hue:"rose",shade:"800",value:"oklch(45.5% 0.188 13.697)"},{id:"rose-900",hue:"rose",shade:"900",value:"oklch(41% 0.159 10.272)"},{id:"rose-950",hue:"rose",shade:"950",value:"oklch(27.1% 0.105 12.094)"},{id:"slate-50",hue:"slate",shade:"50",value:"oklch(98.4% 0.003 247.858)"},{id:"slate-100",hue:"slate",shade:"100",value:"oklch(96.8% 0.007 247.896)"},{id:"slate-200",hue:"slate",shade:"200",value:"oklch(92.9% 0.013 255.508)"},{id:"slate-300",hue:"slate",shade:"300",value:"oklch(86.9% 0.022 252.894)"},{id:"slate-400",hue:"slate",shade:"400",value:"oklch(70.4% 0.04 256.788)"},{id:"slate-500",hue:"slate",shade:"500",value:"oklch(55.4% 0.046 257.417)"},{id:"slate-600",hue:"slate",shade:"600",value:"oklch(44.6% 0.043 257.281)"},{id:"slate-700",hue:"slate",shade:"700",value:"oklch(37.2% 0.044 257.287)"},{id:"slate-800",hue:"slate",shade:"800",value:"oklch(27.9% 0.041 260.031)"},{id:"slate-900",hue:"slate",shade:"900",value:"oklch(20.8% 0.042 265.755)"},{id:"slate-950",hue:"slate",shade:"950",value:"oklch(12.9% 0.042 264.695)"},{id:"gray-50",hue:"gray",shade:"50",value:"oklch(98.5% 0.002 247.839)"},{id:"gray-100",hue:"gray",shade:"100",value:"oklch(96.7% 0.003 264.542)"},{id:"gray-200",hue:"gray",shade:"200",value:"oklch(92.8% 0.006 264.531)"},{id:"gray-300",hue:"gray",shade:"300",value:"oklch(87.2% 0.01 258.338)"},{id:"gray-400",hue:"gray",shade:"400",value:"oklch(70.7% 0.022 261.325)"},{id:"gray-500",hue:"gray",shade:"500",value:"oklch(55.1% 0.027 264.364)"},{id:"gray-600",hue:"gray",shade:"600",value:"oklch(44.6% 0.03 256.802)"},{id:"gray-700",hue:"gray",shade:"700",value:"oklch(37.3% 0.034 259.733)"},{id:"gray-800",hue:"gray",shade:"800",value:"oklch(27.8% 0.033 256.848)"},{id:"gray-900",hue:"gray",shade:"900",value:"oklch(21% 0.034 264.665)"},{id:"gray-950",hue:"gray",shade:"950",value:"oklch(13% 0.028 261.692)"},{id:"zinc-50",hue:"zinc",shade:"50",value:"oklch(98.5% 0 none)"},{id:"zinc-100",hue:"zinc",shade:"100",value:"oklch(96.7% 0.001 286.375)"},{id:"zinc-200",hue:"zinc",shade:"200",value:"oklch(92% 0.004 286.32)"},{id:"zinc-300",hue:"zinc",shade:"300",value:"oklch(87.1% 0.006 286.286)"},{id:"zinc-400",hue:"zinc",shade:"400",value:"oklch(70.5% 0.015 286.067)"},{id:"zinc-500",hue:"zinc",shade:"500",value:"oklch(55.2% 0.016 285.938)"},{id:"zinc-600",hue:"zinc",shade:"600",value:"oklch(44.2% 0.017 285.786)"},{id:"zinc-700",hue:"zinc",shade:"700",value:"oklch(37% 0.013 285.805)"},{id:"zinc-800",hue:"zinc",shade:"800",value:"oklch(27.4% 0.006 286.033)"},{id:"zinc-900",hue:"zinc",shade:"900",value:"oklch(21% 0.006 285.885)"},{id:"zinc-950",hue:"zinc",shade:"950",value:"oklch(14.1% 0.005 285.823)"},{id:"neutral-50",hue:"neutral",shade:"50",value:"oklch(98.5% 0 none)"},{id:"neutral-100",hue:"neutral",shade:"100",value:"oklch(97% 0 none)"},{id:"neutral-200",hue:"neutral",shade:"200",value:"oklch(92.2% 0 none)"},{id:"neutral-300",hue:"neutral",shade:"300",value:"oklch(87% 0 none)"},{id:"neutral-400",hue:"neutral",shade:"400",value:"oklch(70.8% 0 none)"},{id:"neutral-500",hue:"neutral",shade:"500",value:"oklch(55.6% 0 none)"},{id:"neutral-600",hue:"neutral",shade:"600",value:"oklch(43.9% 0 none)"},{id:"neutral-700",hue:"neutral",shade:"700",value:"oklch(37.1% 0 none)"},{id:"neutral-800",hue:"neutral",shade:"800",value:"oklch(26.9% 0 none)"},{id:"neutral-900",hue:"neutral",shade:"900",value:"oklch(20.5% 0 none)"},{id:"neutral-950",hue:"neutral",shade:"950",value:"oklch(14.5% 0 none)"},{id:"stone-50",hue:"stone",shade:"50",value:"oklch(98.5% 0.001 106.423)"},{id:"stone-100",hue:"stone",shade:"100",value:"oklch(97% 0.001 106.424)"},{id:"stone-200",hue:"stone",shade:"200",value:"oklch(92.3% 0.003 48.717)"},{id:"stone-300",hue:"stone",shade:"300",value:"oklch(86.9% 0.005 56.366)"},{id:"stone-400",hue:"stone",shade:"400",value:"oklch(70.9% 0.01 56.259)"},{id:"stone-500",hue:"stone",shade:"500",value:"oklch(55.3% 0.013 58.071)"},{id:"stone-600",hue:"stone",shade:"600",value:"oklch(44.4% 0.011 73.639)"},{id:"stone-700",hue:"stone",shade:"700",value:"oklch(37.4% 0.01 67.558)"},{id:"stone-800",hue:"stone",shade:"800",value:"oklch(26.8% 0.007 34.298)"},{id:"stone-900",hue:"stone",shade:"900",value:"oklch(21.6% 0.006 56.043)"},{id:"stone-950",hue:"stone",shade:"950",value:"oklch(14.7% 0.004 49.25)"},{id:"mauve-50",hue:"mauve",shade:"50",value:"oklch(98.5% 0 none)"},{id:"mauve-100",hue:"mauve",shade:"100",value:"oklch(96% 0.003 325.6)"},{id:"mauve-200",hue:"mauve",shade:"200",value:"oklch(92.2% 0.005 325.62)"},{id:"mauve-300",hue:"mauve",shade:"300",value:"oklch(86.5% 0.012 325.68)"},{id:"mauve-400",hue:"mauve",shade:"400",value:"oklch(71.1% 0.019 323.02)"},{id:"mauve-500",hue:"mauve",shade:"500",value:"oklch(54.2% 0.034 322.5)"},{id:"mauve-600",hue:"mauve",shade:"600",value:"oklch(43.5% 0.029 321.78)"},{id:"mauve-700",hue:"mauve",shade:"700",value:"oklch(36.4% 0.029 323.89)"},{id:"mauve-800",hue:"mauve",shade:"800",value:"oklch(26.3% 0.024 320.12)"},{id:"mauve-900",hue:"mauve",shade:"900",value:"oklch(21.2% 0.019 322.12)"},{id:"mauve-950",hue:"mauve",shade:"950",value:"oklch(14.5% 0.008 326)"},{id:"olive-50",hue:"olive",shade:"50",value:"oklch(98.8% 0.003 106.5)"},{id:"olive-100",hue:"olive",shade:"100",value:"oklch(96.6% 0.005 106.5)"},{id:"olive-200",hue:"olive",shade:"200",value:"oklch(93% 0.007 106.5)"},{id:"olive-300",hue:"olive",shade:"300",value:"oklch(88% 0.011 106.6)"},{id:"olive-400",hue:"olive",shade:"400",value:"oklch(73.7% 0.021 106.9)"},{id:"olive-500",hue:"olive",shade:"500",value:"oklch(58% 0.031 107.3)"},{id:"olive-600",hue:"olive",shade:"600",value:"oklch(46.6% 0.025 107.3)"},{id:"olive-700",hue:"olive",shade:"700",value:"oklch(39.4% 0.023 107.4)"},{id:"olive-800",hue:"olive",shade:"800",value:"oklch(28.6% 0.016 107.4)"},{id:"olive-900",hue:"olive",shade:"900",value:"oklch(22.8% 0.013 107.4)"},{id:"olive-950",hue:"olive",shade:"950",value:"oklch(15.3% 0.006 107.1)"},{id:"mist-50",hue:"mist",shade:"50",value:"oklch(98.7% 0.002 197.1)"},{id:"mist-100",hue:"mist",shade:"100",value:"oklch(96.3% 0.002 197.1)"},{id:"mist-200",hue:"mist",shade:"200",value:"oklch(92.5% 0.005 214.3)"},{id:"mist-300",hue:"mist",shade:"300",value:"oklch(87.2% 0.007 219.6)"},{id:"mist-400",hue:"mist",shade:"400",value:"oklch(72.3% 0.014 214.4)"},{id:"mist-500",hue:"mist",shade:"500",value:"oklch(56% 0.021 213.5)"},{id:"mist-600",hue:"mist",shade:"600",value:"oklch(45% 0.017 213.2)"},{id:"mist-700",hue:"mist",shade:"700",value:"oklch(37.8% 0.015 216)"},{id:"mist-800",hue:"mist",shade:"800",value:"oklch(27.5% 0.011 216.9)"},{id:"mist-900",hue:"mist",shade:"900",value:"oklch(21.8% 0.008 223.9)"},{id:"mist-950",hue:"mist",shade:"950",value:"oklch(14.8% 0.004 228.8)"},{id:"taupe-50",hue:"taupe",shade:"50",value:"oklch(98.6% 0.002 67.8)"},{id:"taupe-100",hue:"taupe",shade:"100",value:"oklch(96% 0.002 17.2)"},{id:"taupe-200",hue:"taupe",shade:"200",value:"oklch(92.2% 0.005 34.3)"},{id:"taupe-300",hue:"taupe",shade:"300",value:"oklch(86.8% 0.007 39.5)"},{id:"taupe-400",hue:"taupe",shade:"400",value:"oklch(71.4% 0.014 41.2)"},{id:"taupe-500",hue:"taupe",shade:"500",value:"oklch(54.7% 0.021 43.1)"},{id:"taupe-600",hue:"taupe",shade:"600",value:"oklch(43.8% 0.017 39.3)"},{id:"taupe-700",hue:"taupe",shade:"700",value:"oklch(36.7% 0.016 35.7)"},{id:"taupe-800",hue:"taupe",shade:"800",value:"oklch(26.8% 0.011 36.5)"},{id:"taupe-900",hue:"taupe",shade:"900",value:"oklch(21.4% 0.009 43.1)"},{id:"taupe-950",hue:"taupe",shade:"950",value:"oklch(14.7% 0.004 49.3)"}]);var Xp=12,Vu=new Map(fo.map(e=>[e.id,e])),Jp=new Map(fo.map(e=>[e.value,e])),Zp=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Qp=/^(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix|light-dark)\(.*\)$/i,eg=/[;{}<>\\]|url\s*\(/i,Wu=new WeakMap;function jl(e){let t=Wu.get(e);return t||Wu.set(e,t=new Set),t}function Ku(e,t){let n=String(e??"").trim();if(!n||eg.test(n)||Nl(n))return!1;let r=t?.defaultView?.CSS;return r&&typeof r.supports=="function"?r.supports("color",n):Zp.test(n)||Qp.test(n)||/^[a-z]+$/i.test(n)}function Gu(e){return`${e.hue[0].toUpperCase()}${e.hue.slice(1)} ${e.shade}`}function Zs(e){return{id:e.id,label:Gu(e),value:e.value}}function Yu(e){let t=String(e??"").trim(),n=Jp.get(t);return n?Gu(n):t}function tg(e,t){if(!e||e.length===0)return{swatches:fo.map(Zs),custom:!0,full:!0};let n=[],r=new Set,o=!1,s=i=>{r.has(i.value)||(r.add(i.value),n.push(i))};for(let i of e)i==="custom"?o=!0:Vu.has(i)?s(Zs(Vu.get(i))):zu.includes(i)?fo.filter(l=>l.hue===i).forEach(l=>s(Zs(l))):Hu.includes(i)?fo.filter(l=>l.shade===i).forEach(l=>s(Zs(l))):Ku(i,t)?s({id:null,label:i,value:i}):console.warn(`[hypercms] color option "${i}" is not a Tailwind color, hue, shade, CSS color or "custom"; ignoring it`);return{swatches:n,custom:o,full:!1}}function Xu(e,{value:t,tokens:n,path:r,doc:o}){let{swatches:s,custom:i,full:l}=tg(n,o),a=t==null?"":String(t).trim();a&&!s.some(f=>f.value===a)&&s.unshift({id:null,label:Yu(a),value:a});let c=s.length<=Xp;e.setAttribute("data-hcms-color-path",r),e.classList.toggle("hcms-color--inline",c);let p=e.querySelector(".hcms-color-grid");if(p){p.classList.toggle("hcms-color-grid--full",l);for(let f of s){let h=o.createElement("button");h.type="button",h.className="hcms-color-swatch",h.setAttribute("data-hcms-action","color-pick"),h.setAttribute("data-hcms-color",f.value),h.setAttribute("aria-label",f.label),h.setAttribute("title",f.id||f.label),h.setAttribute("style",`--hcms-swatch: ${f.value}`),p.appendChild(h)}}i||e.querySelector(".hcms-color-custom")?.remove();let u=e.querySelector(".hcms-color-current");c&&u&&(u.removeAttribute("data-hcms-action"),u.removeAttribute("aria-expanded")),ql(e,c||jl(o).has(r)),Ju(e,a)}function Ju(e,t){let n=t==null?"":String(t).trim();e.toggleAttribute("data-hcms-color-empty",n==="");let r=e.querySelector(".hcms-color-chip");r&&(n?r.setAttribute("style",`--hcms-swatch: ${n}`):r.removeAttribute("style"));let o=e.querySelector(".hcms-color-name");o&&(o.textContent=n?Yu(n):"Not set"),e.querySelectorAll(".hcms-color-swatch").forEach(l=>{l.setAttribute("aria-pressed",String(l.getAttribute("data-hcms-color")===n))});let s=e.querySelector('[data-hcms-color-input="text"]');s&&s.ownerDocument?.activeElement!==s&&(s.value=n);let i=e.querySelector('[data-hcms-color-input="native"]');i&&/^#[0-9a-f]{6}$/i.test(n)&&(i.value=n.toLowerCase())}function ql(e,t){let n=e.querySelector(".hcms-color-panel");n&&(n.hidden=!t);let r=e.querySelector(".hcms-color-current[data-hcms-action]");r&&r.setAttribute("aria-expanded",String(t))}function Qs(e){return e?.closest?e.closest("[data-hcms-color-path]"):null}function ng(e){return e.querySelector('input[type="hidden"][data-hcms-field]')}function Zu(e,t){let n=e.querySelector(":scope > .hcms-error");n&&(n.textContent=t||"",n.hidden=!t)}function Dl(e,t){let n=ng(e);return!n||(Zu(e,null),Ju(e,t),n.value===t)?null:(n.value=t,n)}function Qu(e){let t=Qs(e);return t?(t.classList.contains("hcms-color--inline")||(jl(t.ownerDocument).delete(t.getAttribute("data-hcms-color-path")),ql(t,!1)),Dl(t,e.getAttribute("data-hcms-color")||"")):null}function ef(e){let t=Qs(e);return t?Dl(t,""):null}function tf(e){let t=Qs(e);if(!t)return;let n=t.getAttribute("data-hcms-color-path"),r=jl(t.ownerDocument),o=!r.has(n);o?r.add(n):r.delete(n),ql(t,o)}function nf(e){let t=Qs(e);if(!t)return null;let n=String(e.value||"").trim();return n!==""&&!Ku(n,t.ownerDocument)?(Zu(t,`"${n}" is not a CSS color`),null):Dl(t,n)}var Bl=["sans","serif","display","mono"],Xt="ui-sans-serif, system-ui, sans-serif",qn="ui-serif, Georgia, serif",ho="ui-monospace, SFMono-Regular, Menlo, monospace",Gn=Object.freeze([{slug:"inter",family:"Inter",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"roboto",family:"Roboto",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"open-sans",family:"Open Sans",group:"sans",fallback:Xt,request:"ital,wght@0,300..800;1,300..800"},{slug:"lato",family:"Lato",group:"sans",fallback:Xt,request:"ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900"},{slug:"montserrat",family:"Montserrat",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"poppins",family:"Poppins",group:"sans",fallback:Xt,request:"ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900"},{slug:"nunito",family:"Nunito",group:"sans",fallback:Xt,request:"ital,wght@0,200..1000;1,200..1000"},{slug:"raleway",family:"Raleway",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"dm-sans",family:"DM Sans",group:"sans",fallback:Xt,request:"ital,wght@0,100..1000;1,100..1000"},{slug:"work-sans",family:"Work Sans",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"source-sans-3",family:"Source Sans 3",group:"sans",fallback:Xt,request:"ital,wght@0,200..900;1,200..900"},{slug:"noto-sans",family:"Noto Sans",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"plus-jakarta-sans",family:"Plus Jakarta Sans",group:"sans",fallback:Xt,request:"ital,wght@0,200..800;1,200..800"},{slug:"manrope",family:"Manrope",group:"sans",fallback:Xt,request:"wght@200..800"},{slug:"outfit",family:"Outfit",group:"sans",fallback:Xt,request:"wght@100..900"},{slug:"space-grotesk",family:"Space Grotesk",group:"sans",fallback:Xt,request:"wght@300..700"},{slug:"rubik",family:"Rubik",group:"sans",fallback:Xt,request:"ital,wght@0,300..900;1,300..900"},{slug:"ubuntu",family:"Ubuntu",group:"sans",fallback:Xt,request:"ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700"},{slug:"merriweather",family:"Merriweather",group:"serif",fallback:qn,request:"ital,wght@0,300..900;1,300..900"},{slug:"lora",family:"Lora",group:"serif",fallback:qn,request:"ital,wght@0,400..700;1,400..700"},{slug:"playfair-display",family:"Playfair Display",group:"serif",fallback:qn,request:"ital,wght@0,400..900;1,400..900"},{slug:"libre-baskerville",family:"Libre Baskerville",group:"serif",fallback:qn,request:"ital,wght@0,400..700;1,400..700"},{slug:"source-serif-4",family:"Source Serif 4",group:"serif",fallback:qn,request:"ital,wght@0,200..900;1,200..900"},{slug:"pt-serif",family:"PT Serif",group:"serif",fallback:qn,request:"ital,wght@0,400;0,700;1,400;1,700"},{slug:"noto-serif",family:"Noto Serif",group:"serif",fallback:qn,request:"ital,wght@0,100..900;1,100..900"},{slug:"crimson-pro",family:"Crimson Pro",group:"serif",fallback:qn,request:"ital,wght@0,200..900;1,200..900"},{slug:"eb-garamond",family:"EB Garamond",group:"serif",fallback:qn,request:"ital,wght@0,400..800;1,400..800"},{slug:"cormorant-garamond",family:"Cormorant Garamond",group:"serif",fallback:qn,request:"ital,wght@0,300..700;1,300..700"},{slug:"bebas-neue",family:"Bebas Neue",group:"display",fallback:Xt,request:"wght@400"},{slug:"oswald",family:"Oswald",group:"display",fallback:Xt,request:"wght@200..700"},{slug:"anton",family:"Anton",group:"display",fallback:Xt,request:"wght@400"},{slug:"abril-fatface",family:"Abril Fatface",group:"display",fallback:qn,request:"wght@400"},{slug:"lobster",family:"Lobster",group:"display",fallback:"cursive",request:"wght@400"},{slug:"bungee",family:"Bungee",group:"display",fallback:Xt,request:"wght@400"},{slug:"roboto-mono",family:"Roboto Mono",group:"mono",fallback:ho,request:"ital,wght@0,100..700;1,100..700"},{slug:"jetbrains-mono",family:"JetBrains Mono",group:"mono",fallback:ho,request:"ital,wght@0,100..800;1,100..800"},{slug:"fira-code",family:"Fira Code",group:"mono",fallback:ho,request:"wght@300..700"},{slug:"source-code-pro",family:"Source Code Pro",group:"mono",fallback:ho,request:"ital,wght@0,200..900;1,200..900"},{slug:"ibm-plex-mono",family:"IBM Plex Mono",group:"mono",fallback:ho,request:"ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700"},{slug:"space-mono",family:"Space Mono",group:"mono",fallback:ho,request:"ital,wght@0,400;0,700;1,400;1,700"}]),mo=Object.freeze({slug:"system",family:null,group:"sans",fallback:"system-ui, sans-serif"}),rg=new Map(Gn.map(e=>[e.family.toLowerCase(),e])),yw=new Map(Gn.map(e=>[e.slug,e]));function os(e){return!e||e.slug==="system"?mo.fallback:`'${e.family}', ${e.fallback}`}function rf(e){return e==null?null:String(e).split(",")[0].trim().replace(/^['"]|['"]$/g,"")||null}function Fl(e){let t=new Map;if(!e)return t;let n=String(e).split("?")[1]||"";for(let r of n.split("&")){if(!r.startsWith("family="))continue;let o=decodeURIComponent(r.slice(7).split(":")[0].replace(/\+/g," ")).trim();o&&t.set(o.toLowerCase(),r)}return t}function of(e,t){let n=Fl(e),r=Fl(t);return n.size===r.size&&[...n.keys()].every(o=>r.has(o))}function $l(e){let t=rf(e);return t&&rg.get(t.toLowerCase())||null}function ei(e,t=null){let n=Fl(t),r=new Map;for(let s of e||[]){let i=$l(s);if(i){r.set(i.family.toLowerCase(),`family=${i.family.replace(/ /g,"+")}:${i.request}`);continue}let l=rf(s),a=l&&n.get(l.toLowerCase());a&&r.set(l.toLowerCase(),a)}return r.size===0?null:`https://fonts.googleapis.com/css2?${[...r.entries()].sort(([s],[i])=>s.localeCompare(i)).map(([,s])=>s).join("&")}&display=swap`}var og={sans:"Sans",serif:"Serif",display:"Display",mono:"Mono"},sg="link[data-hcms-font-preview]",sf=new WeakMap;function Hl(e){let t=sf.get(e);return t||sf.set(e,t=new Set),t}function ig(e){return String(e??"").trim()===mo.fallback}function lf(e){let t=String(e??"").trim();if(!t)return"Not set";if(ig(t))return"System";let n=$l(t);return n?n.family:"Current font"}function lg(e){if(!e||e.length===0)return{system:!0,fonts:[...Gn]};let t=!1,n=new Set;for(let r of e)r==="system"?t=!0:Bl.includes(r)?Gn.filter(o=>o.group===r).forEach(o=>n.add(o)):Gn.some(o=>o.slug===r)?n.add(Gn.find(o=>o.slug===r)):console.warn(`[hypercms] font option "${r}" is not a catalog font, a group or "system"; ignoring it`);return{system:t,fonts:Gn.filter(r=>n.has(r))}}function Ul(e,{value:t,label:n,family:r}){let o=e.createElement("button");return o.type="button",o.className="hcms-font-option",o.setAttribute("role","option"),o.setAttribute("data-hcms-action","font-pick"),o.setAttribute("data-hcms-font",t),o.setAttribute("style",`font-family: ${r}`),o.textContent=n,o}function af(e,{value:t,tokens:n,path:r,doc:o}){let{system:s,fonts:i}=lg(n),l=t==null?"":String(t).trim();e.setAttribute("data-hcms-font-path",r);let a=e.querySelector(".hcms-font-list");if(a){let c=new Set([...s?[mo.fallback]:[],...i.map(os)]);l&&!c.has(l)&&a.appendChild(Ul(o,{value:l,label:lf(l),family:l})),s&&a.appendChild(Ul(o,{value:mo.fallback,label:"System",family:mo.fallback}));for(let p of Bl){let u=i.filter(h=>h.group===p);if(!u.length)continue;let f=o.createElement("div");f.className="hcms-font-group",f.textContent=og[p],a.appendChild(f);for(let h of u)a.appendChild(Ul(o,{value:os(h),label:h.family,family:os(h)}))}}zl(e,Hl(o).has(r)),cf(e,l)}function cf(e,t){let n=t==null?"":String(t).trim(),r=e.querySelector(".hcms-font-name");r&&(r.textContent=lf(n),n?r.setAttribute("style",`font-family: ${n}`):r.removeAttribute("style")),e.querySelectorAll(".hcms-font-option").forEach(o=>{o.setAttribute("aria-selected",String(o.getAttribute("data-hcms-font")===n))})}function zl(e,t){let n=e.querySelector(".hcms-font-panel");n&&(n.hidden=!t),e.querySelector(".hcms-font-current")?.setAttribute("aria-expanded",String(t)),t&&ag(e.ownerDocument)}function ag(e){let t=e?.head;if(!t||t.querySelector(sg))return;let n=ei(Gn.map(os)),r=[...new Set(Gn.map(s=>s.family).join(""))].join(""),o=e.createElement("link");o.rel="stylesheet",o.href=`${n}&text=${encodeURIComponent(r)}`,o.setAttribute("data-hcms-font-preview","");for(let s of["editor-ui","no-save","save-remove","snapshot-remove"])o.setAttribute(s,"");t.appendChild(o)}function uf(e){return e?.closest?e.closest("[data-hcms-font-path]"):null}function ff(e){let t=uf(e);if(!t)return;let n=t.getAttribute("data-hcms-font-path"),r=Hl(t.ownerDocument),o=!r.has(n);o?r.add(n):r.delete(n),zl(t,o)}function df(e){let t=uf(e);if(!t)return null;let n=t.querySelector('input[type="hidden"][data-hcms-field]');if(!n)return null;Hl(t.ownerDocument).delete(t.getAttribute("data-hcms-font-path")),zl(t,!1);let r=e.getAttribute("data-hcms-font")||"";return cf(t,r),n.value===r?null:(n.value=r,n)}var _n=e=>`<svg viewBox="0 0 32 20" width="32" height="20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true">${e}</svg>`,on=(e,t,n,r,o="")=>`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="1"${o}/>`,hn=(e,t,n)=>`<path d="M${e} ${t}H${n}"/>`,Vl=' fill="currentColor" fill-opacity="0.3"',hf=Object.freeze({"cols-1":{label:"One column",svg:_n(on(2,2,28,16))},"cols-2":{label:"Two columns",svg:_n(on(2,2,13,16)+on(17,2,13,16))},"cols-3":{label:"Three columns",svg:_n(on(2,2,8,16)+on(12,2,8,16)+on(22,2,8,16))},"cols-4":{label:"Four columns",svg:_n(on(2,2,5.5,16)+on(9.5,2,5.5,16)+on(17,2,5.5,16)+on(24.5,2,5.5,16))},"media-left":{label:"Image left",svg:_n(on(2,3,12,14,Vl)+hn(18,6,30)+hn(18,10,30)+hn(18,14,26))},"media-right":{label:"Image right",svg:_n(on(18,3,12,14,Vl)+hn(2,6,14)+hn(2,10,14)+hn(2,14,10))},"media-top":{label:"Image on top",svg:_n(on(2,2,28,8,Vl)+hn(2,14,30)+hn(2,17,22))},list:{label:"List",svg:_n(hn(3,5,4)+hn(8,5,29)+hn(3,10,4)+hn(8,10,29)+hn(3,15,4)+hn(8,15,29))},cards:{label:"Cards",svg:_n(on(2,2,13,7)+on(17,2,13,7)+on(2,11,13,7)+on(17,11,13,7))},centered:{label:"Centered",svg:_n(hn(6,5,26)+hn(9,10,23)+hn(11,15,21))},"card-flat":{label:"Flat",svg:_n(on(5,3,22,14))},"card-raised":{label:"Raised",svg:_n(on(7,5,22,14,' stroke-opacity="0.35"')+on(4,2,22,14,' fill="var(--mirk-bg, transparent)"'))}});function cg(e){return(e||[]).map(t=>{let n=t.indexOf(":"),r=n===-1?t:t.slice(0,n),o=n===-1?t:t.slice(n+1),s=hf[o]||null;return{value:r,icon:s,label:s?s.label:Lr(r)}})}function mf(e,{tokens:t,value:n,name:r,doc:o}){let s=cg(t),i=n==null?"":String(n);i!==""&&!s.some(a=>a.value===i)&&s.unshift({value:i,icon:null,label:Lr(i)});let l=e.querySelector(".hcms-variant-option");if(!l||!l.parentNode)return s.length;for(let a of s){let c=l.cloneNode(!0),p=c.querySelector('input[type="radio"]');p&&(p.value=a.value,p.name=r);let u=c.querySelector(".hcms-variant-icon");u&&(a.icon?u.innerHTML=a.icon.svg:u.remove());let f=c.querySelector(".hcms-variant-label");f&&(f.textContent=a.label),c.setAttribute("title",a.label),l.parentNode.insertBefore(c,l)}return l.remove(),s.length}function Wl(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],n=t.split("/").pop()||t;try{return decodeURIComponent(n)}catch{return n}}function po({pageRules:e,formRules:t,data:n,doc:r}){let o=r.createDocumentFragment(),s=ug(e,n,r);s&&o.appendChild(s);let i=ti(e,[],n,r,e);return i&&o.appendChild(i),o}function ug(e,t,n){let r=[];if(a(e,t,[]),!r.length)return null;let o=Cn(n,"@object");if(!o)return null;let s=jr(o,n);s.setAttribute("data-hcms-page-style","");let i=s.querySelector("[data-hcms-label]");i&&(i.textContent="Page style");let l=s.querySelector(".hcms-object-fields")||s;for(let[c,p,u]of r){let f=ti(c,p,u,n,e);f&&l.appendChild(f)}return s;function a(c,p,u){if(typeof c=="string"){u.length&&ns(c,n,u,e)==="page"&&r.push([c,u,p]);return}if(!(!c||typeof c!="object"||Array.isArray(c))){if(u.length){let f=Ir(u,"@object",n);if(f&&uo(f))return}for(let[f,h]of Object.entries(c))a(h,p==null?null:p[f],[...u,f])}}}function gf(e,t,n,r){let o=[],s=[];for(let[i,l]of Object.entries(e)){let a=ns(l,n,[...t,i],r);a!=="page"&&(a?o:s).push([i,l])}return[...o,...s]}function bf({shape:e,itemShape:t,pathArr:n,data:r,doc:o,itemKey:s,pageRules:i}){if(e==="object-array-item")return vf(t,n,r,o,i);if(e==="scalar-array-item")return xf(n,r,o,s||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function ti(e,t,n,r,o){let s=pr(e);return s==="scalar"?fg(e,t,n,r,o):s==="object"?mg(e,t,n,r,o):s==="object-array"?pg(e,t,n,r,o):s==="scalar-array"?gg(e,t,n,r):null}function fg(e,t,n,r,o){let s=mr(e,r,t,o),i=Ir(t,s,r);if(!i)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let l=Iu(e,r,t,o);l==="@number"&&s==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "@number" but its value isn't a plain number; rendering a text input so the value is preserved`),(l==="@checkbox"||l==="@toggle")&&s==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "${l}" but its value isn't true/false; rendering a text input so the value is preserved`),kf(i,l===s?l:null,t);let a=jr(i,r);go(a,t);let c=i.getAttribute?.("data-hcms-tpl");if((s==="@select"||s==="@radio")&&c===s&&dg(a,e,t,n,r,s,o),s==="@variant"&&c==="@variant"){let p=rs(e,r,t,o);p||yf(a,"data-hcms-options required (value:icon tokens)"),mf(a,{tokens:p,value:n,name:ni(t.join(".")),doc:r})===0&&a.querySelector(".hcms-variant-option")?.remove()}if(s==="@image"&&c==="@image"){let p=Pu(e,r,t,o);p!=null&&!a.hasAttribute("data-hcms-crop")&&a.setAttribute("data-hcms-crop",p)}return bg(a,nr(t)),ri(a,nr(t)),oi(a,nr(t)),Ef(a,n),s==="@color"&&c==="@color"&&Xu(a,{value:n,tokens:rs(e,r,t,o),path:t.join("."),doc:r}),s==="@font"&&c==="@font"&&af(a,{value:n,tokens:rs(e,r,t,o),path:t.join("."),doc:r}),s==="@file"&&hg(a),a}function kf(e,t,n){if(!t)return;let r=e.getAttribute?.("data-hcms-tpl");r&&r!==t&&console.info(`[hypercms] field "${n.join(".")}" declares component "${t}" but custom template "${r}" wins`)}function dg(e,t,n,r,o,s,i){let l=rs(t,o,n,i),a=l?[...l]:[],c=r==null?"":String(r);if(c!==""&&!a.includes(c)&&a.unshift(c),!l&&(yf(e,"data-hcms-options required (space-separated values)"),a.length===0)){e.querySelector(".mirk-radio")?.remove();return}if(s==="@select"){let f=e.querySelector("select[data-hcms-field]");if(!f)return;for(let h of a){let d=o.createElement("option");d.value=h,d.textContent=Lr(h),f.appendChild(d)}return}let p=e.querySelector(".mirk-radio");if(!p||!p.parentNode)return;let u=ni(n.join("."));for(let f of a){let h=p.cloneNode(!0),d=h.querySelector('input[type="radio"]');d&&(d.value=f,d.name=u);let v=h.querySelector(".mirk-radio__label");v&&(v.textContent=Lr(f)),p.parentNode.insertBefore(h,p)}p.remove()}function ni(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function yf(e,t){let n=e.querySelector?e.querySelector(".hcms-error"):null;n&&(n.textContent=t,n.hidden=!1)}function hg(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=Wl(t.getAttribute("href")))}function mg(e,t,n,r,o){let s=Ir(t,"@object",r);if(!s)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let i=jr(s,r);if(go(i,t),ri(i,nr(t)),oi(i,nr(t)),uo(s))return Nf(i,e,t),Of(i,e,n),i;let l=si(i,".hcms-object-fields",s,t);for(let[a,c]of gf(e,t,r,o)){let p=n==null?null:n[a],u=ti(c,[...t,a],p,r,o);u&&l.appendChild(u)}return t.length&&!l.children.length&&Object.keys(e).length?null:i}function pg(e,t,n,r,o){let s=Ir(t,"@object-array",r);if(!s)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let i=jr(s,r);go(i,t),ri(i,nr(t)),oi(i,nr(t)),Sf(i,s),Tf(i,s,t);let l=si(i,".hcms-array-items",s,t),[,a]=e;return(Array.isArray(n)?n:[]).forEach((p,u)=>{let f=vf(a,[...t,u],p,r,o);f&&l.appendChild(f)}),Af(i),i}function vf(e,t,n,r,o){let s=wf(t,"object-array-item",r);if(!s)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let i=jr(s,r);if(i.setAttribute("data-hcms-card",""),i.classList.contains("hcms-card")||i.classList.add("hcms-card"),go(i,t),uo(s))return e&&typeof e=="object"&&!Array.isArray(e)&&(Nf(i,e,t),Of(i,e,n)),i;let l=si(i,".hcms-card-fields",s,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[a,c]of gf(e,t,r,o)){let p=n==null?null:n[a],u=ti(c,[...t,a],p,r,o);u&&l.appendChild(u)}return i}function gg(e,t,n,r){let o=Vs(e,r),s=Ws(e,t,r),i=o?o.array:"@scalar-array",l=Ir(t,i,r);if(!l)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);kf(l,o?o.array:null,t);let a=jr(l,r);go(a,t),ri(a,nr(t)),oi(a,nr(t)),Sf(a,l),Tf(a,l,t),s&&a.setAttribute("data-hcms-item-tpl",s.item);let c=si(a,".hcms-array-items",l,t);return(Array.isArray(n)?n:[]).forEach((u,f)=>{let h=xf([...t,f],u,r,s?s.item:null);h&&c.appendChild(h)}),Af(a),a}function xf(e,t,n,r){let o=wf(e,"scalar-array-item",n,r);if(!o)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let s=jr(o,n);return s.setAttribute("data-hcms-array-item",""),s.classList.contains("hcms-array-item")||s.classList.add("hcms-array-item"),go(s,e),Ef(s,t),s}function wf(e,t,n,r){let o=e.map(s=>typeof s=="number"?"*":s).join(".");return Cn(n,o)||r&&Cn(n,r)||Cn(n,"@"+t)}function jr(e,t){let n=e.content||e,r=t.createElement("div");return r.appendChild(n.cloneNode(!0)),r.firstElementChild||r}function go(e,t){e.setAttribute("data-hcms-path",t.join(".")),e.setAttribute("data-hcms-path-shape",Ys(t))}function bg(e,t){let n=t==null?"":String(t);if(e.matches&&e.matches("[data-hcms-field]")){e.getAttribute("data-hcms-field")||e.setAttribute("data-hcms-field",n);return}(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(o=>{o.getAttribute("data-hcms-field")||o.setAttribute("data-hcms-field",n)})}function ri(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function oi(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(r=>{(r.textContent||"").trim()===""&&(r.textContent=Lr(String(t)))})}function Sf(e,t){["data-hcms-no-add","data-hcms-no-remove","data-hcms-no-reorder"].forEach(n=>{t.hasAttribute(n)&&e.setAttribute(n,"")}),["data-hcms-min-items","data-hcms-max-items"].forEach(n=>{t.hasAttribute(n)&&e.setAttribute(n,t.getAttribute(n))})}function Af(e){let t=e.querySelector?e.querySelector(".hcms-array-items"):null;if(!t)return;let n=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),r=n.length,o=pf(e,"data-hcms-max-items"),s=pf(e,"data-hcms-min-items"),i=e.hasAttribute("data-hcms-no-add"),l=e.hasAttribute("data-hcms-no-remove"),a=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector('[data-hcms-action="add"]');c&&(c.hidden=i||o!=null&&r>=o),n.forEach((p,u)=>{let f=p.querySelector('[data-hcms-action="remove"]');f&&(f.hidden=l||s!=null&&r<=s);let h=p.querySelector('[data-hcms-action="move-up"]');h&&(h.hidden=a||u===0);let d=p.querySelector('[data-hcms-action="move-down"]');d&&(d.hidden=a||u===r-1)})}function pf(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function Tf(e,t,n){if(e.hasAttribute("data-hcms-no-reorder")||t.hasAttribute("data-hcms-no-reorder"))return;let r=e.querySelector(".hcms-array-items");if(!r)return;let o="hcms-"+n.join(".");r.setAttribute("sortable",o),r.setAttribute("onsorted","hypercmsCommit && hypercmsCommit()")}function nr(e){return e.length?e[e.length-1]:null}function Ef(e,t){let n=kg(e);if(n.length!==0)for(let r of n)Cf(r,t)}function kg(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&yg(e)&&t.push(e),(e.querySelectorAll?e.querySelectorAll("input[data-hcms-field], textarea[data-hcms-field], select[data-hcms-field], img[data-hcms-field], a[data-hcms-field], [contenteditable][data-hcms-field]"):[]).forEach(r=>t.push(r)),t}function yg(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function Of(e,t,n){(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(o=>{let s=o.getAttribute("data-hcms-field");if(!s)return;if(!t||typeof t!="object"||!(s in t)){console.warn(`[hypercms] inline template field "${s}" is not in the rule shape; ignoring`);return}let i=n==null?null:n[s];Cf(o,i)})}function Nf(e,t,n){if(!e.querySelectorAll)return;e.querySelectorAll("[data-hcms-field]").forEach(o=>{let s=o.getAttribute("data-hcms-field");if(!s||t&&typeof t=="object"&&!(s in t))return;let i=[...n,s].join(".");o.setAttribute("data-hcms-path",i),o.setAttribute("data-hcms-path-shape",Ys([...n,s]))})}function si(e,t,n,r){if(!e.querySelector)return e;let o=e.querySelector(t);if(o)return o;let s=n?.getAttribute?.("data-hcms-tpl")||r.join(".");throw new Error(`hypercms: template "${s}" is in slotted mode but has no ${t} element`)}function Cf(e,t){let n=Xs(e),r=(e.tagName||"").toUpperCase(),o=(e.getAttribute("type")||"").toLowerCase();if(r==="INPUT"&&o==="radio"){e.checked=e.value!=null&&String(e.value)===String(t??"");return}if(n==="checked"){e.checked=t===!0||t==="true";return}if(n){e[n]=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var vg={Mutation:(e,t)=>e?.Mutation??t?.Mutation,undo:(e,t)=>e?.undo??t?.undo,onPrepareForSave:(e,t)=>e?.addDocumentTransform??t?.onPrepareForSave,onSnapshot:(e,t)=>e?.onSnapshot??t?.onSnapshot,consent:(e,t)=>e?.confirm??t?.consent,RichClay:(e,t)=>e?.RichClay??t?.RichClay,quickcrop:(e,t)=>e?.quickcrop??t?.quickcrop,upload:(e,t)=>e?.upload??(t?.uploadFileBasic?wg(t.uploadFileBasic):null)},xg={402:"payment-required",413:"too-large",415:"unsupported-type",401:"unauthorized",403:"forbidden",404:"not-found"},Kl=()=>({ok:!1,msg:"Upload cancelled",msgType:"skipped",code:"aborted",uploads:[]});function wg(e){return async function(n,{onProgress:r,signal:o}={}){if(o?.aborted)return Kl();try{let s=await e(n,{onProgress:l=>{r?.({loaded:null,total:null,percent:l})}});if(o?.aborted)return Kl();let i=s&&s.uploads||[];return typeof i[0]?.url!="string"?{ok:!1,msg:"The host accepted the file but did not say where it put it",msgType:"error",code:"bad-response",uploads:[]}:{ok:!0,msg:s.msg||"Uploaded",msgType:s.msgType||"success",code:s.code||null,uploads:i}}catch(s){if(o?.aborted)return Kl();let i={};try{i=JSON.parse(s?.response||"{}")}catch{i={}}let l=i.code||xg[s?.status]||"error";return{ok:!1,msg:s&&s.message||"Upload failed",msgType:"error",code:l,uploads:[]}}}}function sn(e,t){let n=vg[e];if(!n)throw new Error(`hypercms: unknown platform capability "${e}"`);let r=t||(typeof window<"u"?window:null);return r&&n(r.clay,r.hyperclay)||null}var _f=["clay:mutation-ready","hyperclay:mutation-ready"],Mf=["clay:sync-applied","hyperclay:livesync-applied"],Rf=["clay:ready","hyperclay:ready"];function bo(e,t,n){let r=null,o=s=>{r!==null&&r!==s.type||(r=s.type,queueMicrotask(()=>{r=null}),n(s))};for(let s of t)e.addEventListener(s,o);return()=>{for(let s of t)e.removeEventListener(s,o)}}var Dn="data-hcms-bound",gr="data-hcms-bound-id",Gl=new Map;function Lf(e,t){Gl.set(e,t)}function If(e){Gl.delete(e)}function Pf(e){let t=e.getAttribute(gr);if(!t)return null;let n=Gl.get(t);return!n||!n.restorable()?null:n.originalHTML}var qr="data-hcms-owns-richclay";function ko(e){return e&&e.richclay&&e.richclay.RichClay||sn("RichClay",e)||(e&&typeof e.RichClay=="function"?e.RichClay:null)}function jf(e,t,n){!e||typeof e.setAttribute!="function"||(e.setAttribute(Dn,t?"rich":"plain"),n&&e.setAttribute(qr,"true"))}function qf(e,t){if(!e||typeof e.querySelectorAll!="function")return;let n=e.querySelectorAll(`[${Dn}]`);if(!n.length)return;let r=ko(t);if(r&&typeof r.stripFromClone=="function")try{r.stripFromClone(e)}catch(o){console.warn("[hypercms] richclay strip failed; editor state may reach the save",o)}for(let o of n)o.getAttribute(qr)==="true"&&o.removeAttribute("data-richclay"),o.removeAttribute(qr),o.removeAttribute(Dn)}function Df(e,t){if(!e||typeof e.removeAttribute!="function")return;let n=ko(t);if(n&&typeof n.stripElement=="function")try{n.stripElement(e)}catch(r){console.warn("[hypercms] richclay element strip failed; the clone stays editable",r)}else e.removeAttribute("contenteditable"),e.removeAttribute("no-undo");e.getAttribute(qr)==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute(qr),e.removeAttribute(Dn),e.removeAttribute(gr)}function Ff(e,t){if(!t||e==null)return e;return n(e);function n(r){if(typeof r=="string"){if(r.endsWith("[]")||Kt(r)!==-1)return r;let o=null;try{o=t.querySelector(r)}catch{return r}return o&&o.children.length>0?r+"@innerHTML":r}if(Array.isArray(r))return r;if(r&&typeof r=="object"){let o=Object.create(null);for(let[s,i]of Object.entries(r))o[s]=n(i);return o}return r}}function Bf(e,t){if(!t||e==null)return e;return n(e,[t]);function n(r,o){if(typeof r=="string")return r.endsWith("[]")||Kt(r)!==-1?r:o.some(s=>Sg(s,r))?r+"@innerHTML":r;if(Array.isArray(r)){let[s,i]=r;if(typeof s!="string"||!s)return r;let l=Ag(t,s);return l.length?[s,n(i,l)]:r}if(r&&typeof r=="object"){let s=Object.create(null);for(let[i,l]of Object.entries(r))s[i]=n(l,o);return s}return r}}function Sg(e,t){let n=null;try{n=e.querySelector(t)}catch{return!1}return n?n.hasAttribute(Dn)?n.getAttribute(Dn)==="rich":n.children.length>0:!1}function Ag(e,t){try{return[...e.querySelectorAll(t)]}catch{return[]}}function yo(e){if(!e||e.tagName!=="TEXTAREA")return;let t=e.ownerDocument.defaultView||(typeof window<"u"?window:null);t&&t.CSS&&t.CSS.supports&&t.CSS.supports("field-sizing: content")||(e.style.height="auto",e.style.height=e.scrollHeight+"px")}function br(e,t,n=!0){if(!e||!e.querySelectorAll||(e.querySelectorAll("textarea[data-hcms-field]").forEach(yo),n===!1))return;let r=t&&t.defaultView||(typeof window<"u"?window:null),o=ko(r);o&&e.querySelectorAll("[contenteditable][data-hcms-field]").forEach(s=>{if(s.__hcmsRichclay)return;let i;try{i=new o(s,{inline:!0,hyperclay:!1,toolbar:["bold","italic","link","undo","redo"]})}catch(a){console.warn("[hypercms] richclay activation failed; field stays plain contenteditable",a);return}s.__hcmsRichclay=i;let l=i&&i.squire;l&&typeof l.addEventListener=="function"&&l.addEventListener("input",()=>{let a=r&&r.Event||Event;s.dispatchEvent(new a("input",{bubbles:!0}))})})}var $f="link[data-hcms-fonts]",Tg="link[data-hcms-fonts-preconnect]";function Eg(e,t,n){let r=[],o=!1;return s(e,t,[]),{stacks:r,found:o};function s(i,l,a){if(typeof i=="string"){if(i.endsWith("[]")||mr(i,n,a,e)!=="@font")return;o=!0,l!=null&&l!==""&&r.push(String(l));return}if(Array.isArray(i)){let c=Array.isArray(l)?l:[];c.forEach(p=>s(i[1],p,[...a,"*"])),c.length||s(i[1],void 0,[...a,"*"]);return}if(i&&typeof i=="object")for(let[c,p]of Object.entries(i))s(p,l?.[c],[...a,c])}}function Og(e,t){let n=e?.head;if(!n)return;let r=n.querySelector($f),o=n.querySelector(Tg);if(!t){r?.remove(),o?.remove();return}o||(o=e.createElement("link"),o.setAttribute("rel","preconnect"),o.setAttribute("href","https://fonts.gstatic.com"),o.setAttribute("crossorigin",""),o.setAttribute("data-hcms-fonts-preconnect",""),o.setAttribute("no-undo",""),n.appendChild(o)),r||(r=e.createElement("link"),r.setAttribute("rel","stylesheet"),r.setAttribute("data-hcms-fonts",""),r.setAttribute("no-undo",""),o.after(r)),r.hasAttribute("no-undo")||r.setAttribute("no-undo",""),o.hasAttribute("no-undo")||o.setAttribute("no-undo",""),r.getAttribute("href")!==t&&r.setAttribute("href",t)}function vo(e,t){if(!e?.doc||e.pageRules==null)return;let{stacks:n,found:r}=Eg(e.pageRules,t,e.doc);if(!r)return;let o=e.doc.head?.querySelector($f)?.getAttribute("href")||null,s=ei(n,o);s&&o&&of(o,s)||Og(e.doc,s)}var Yl=new WeakSet;function Dr(e,t){let n=sn("undo");if(!n)return t();n.pause();try{let r=t();return r&&r.ok?n.commitCaptured(e):n.discardCaptured(),r}finally{n.resume()}}function or(e){let t=sn("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function ai(e){let{formRoot:t}=e;if(!t||Yl.has(t))return;Yl.add(t);let n=i=>{let l=i.target;!l||!l.closest||l.closest("[data-hcms-form-root]")&&(l.matches("[data-hcms-color-input]")||l.matches("input, textarea, select, [contenteditable][data-hcms-field]")&&(l.tagName==="TEXTAREA"&&yo(l),!l.matches('input[type="file"]')&&(!l.closest("[data-hcms-field]")&&!l.hasAttribute?.("data-hcms-field")||ss(l,e))))},r=i=>{let l=i.target;if(!(!l||!l.closest)&&l.closest("[data-hcms-form-root]")){if(l.matches("[data-hcms-color-input]")){let a=nf(l);a&&ss(a,e);return}if(l.matches('input[type="file"][data-hcms-upload]')){Pg(l,e);return}l.matches('input[type="checkbox"], input[type="radio"], select')&&ss(l,e)}},o=i=>{let l=i.target;if(!l||!l.closest)return;let a=l.closest("[data-hcms-action]");if(!a)return;let c=a.getAttribute("data-hcms-action");if(c==="add"||c==="remove"||c==="move-up"||c==="move-down"||c==="clear-upload"||c==="color-pick"||c==="color-clear"||c==="color-panel"||c==="font-pick"||c==="font-panel"){if(!a.closest("[data-hcms-form-root]"))return}else if(c==="close"&&!a.closest("[data-hcms-shell]"))return;if(c==="add"){let p=a.closest("[data-hcms-path]");if(!p)return;let u=p.getAttribute("data-hcms-path");is(u,e)}else if(c==="remove"){let p=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!p)return;Zl(p,e)}else if(c==="move-up"||c==="move-down"){let p=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!p)return;Jl(p,c==="move-up"?-1:1,e)}else if(c==="clear-upload")Fg(a,e);else if(c==="color-pick"||c==="color-clear"){let p=c==="color-pick"?Qu(a):ef(a);p&&ss(p,e)}else if(c==="color-panel")tf(a);else if(c==="font-pick"){let p=df(a);p&&ss(p,e)}else c==="font-panel"?ff(a):c==="close"&&e.onCloseRequested?.()},s=t.ownerDocument;s.addEventListener("input",n,!0),s.addEventListener("change",r,!0),s.addEventListener("click",o,!0),e.detachEvents=()=>{s.removeEventListener("input",n,!0),s.removeEventListener("change",r,!0),s.removeEventListener("click",o,!0),Yl.delete(t)}}var Ng=new Set(["value","checked"]);function Cg(e,t){if(!t)return null;let n=er(t);if(n.some(a=>typeof a=="number"||a==="*"))return null;let r=tr(e.pageRules,n);if(typeof r!="string")return null;let o=un.ruleAttrIndex(r);if(o===-1)return null;let s=r.slice(o+1);if(!Ng.has(s))return null;let i=r.slice(0,o),l=i?e.pageRoot.querySelector(i):jn(e.pageRoot);return l?{el:l,prop:s,oldValue:l[s]}:null}function ss(e,t){let r=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",o=Cg(t,r);if(Sn(bn(t),{path:r,structural:!1},t),o){let s=sn("undo");s&&typeof s.recordValue=="function"&&s.recordValue(o.el,{prop:o.prop,oldValue:o.oldValue,newValue:o.el[o.prop]})}}var _g={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function Mg(e,t){let n=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(n==null)return{file:e};let r=sn("quickcrop");if(typeof r!="function")return{file:e};try{let o=typeof window<"u"&&(window.clay?.modal??window.themodal)||"auto",s=await r(e,{aspect:Rg(n),modal:o,..._g});return s===null?null:{file:Lg(s.blob,e.name),dataURL:s.dataURL}}catch(o){return wo(t,o&&o.message||"Crop failed"),null}}function Rg(e){let t=String(e??"").trim().toLowerCase();if(t===""||t==="free")return null;let n=t.match(/^(\d+(?:\.\d+)?)\s*[:/]\s*(\d+(?:\.\d+)?)$/);if(!n)return null;let r=parseFloat(n[1]),o=parseFloat(n[2]);return!r||!o?null:r/o}function Lg(e,t){let n=e.type==="image/webp"?".webp":e.type==="image/jpeg"?".jpg":".png",r=String(t||"image").replace(/\.[^.]+$/,"");try{return new File([e],r+n,{type:e.type})}catch{return e}}var Ig=new Set(["unsupported","payment-required"]);async function Pg(e,t){let n=e.files&&e.files[0];if(!n)return;let r=e.closest("[data-hcms-path]");if(!r)return;let o=r.getAttribute("data-hcms-path")||"";wo(r,null);let s=await Mg(n,r);if(!s||t.closed){kr(e);return}let i=s.file,l=s.dataURL||null,a=sn("upload");if(typeof a!="function")return Xl(e,r,t,o,await Uf(i,l,r),i);Wf(r,l),Hf(r,0);let c=qg(t),p;try{p=await a(i,{signal:c?.signal,onProgress:({percent:f})=>Hf(r,f)})}finally{Dg(t,c),$g(r)}if(t.closed){kr(e);return}if(p.code==="aborted"){kr(e);return}if(p.ok)return Xl(e,r,t,o,p.uploads[0].url,i);if(!Ig.has(p.code)){wo(r,p.msg||"Upload failed"),t.dispatch?.("hcms:error",{error:new Error(p.msg||"Upload failed"),code:p.code,path:o}),kr(e);return}let u=p.code==="payment-required"?"This file is stored in the page. Add a paid plan to upload files.":null;return Xl(e,r,t,o,await Uf(i,l,r),i,u)}function Xl(e,t,n,r,o,s,i=null){if(n.closed){kr(e);return}if(Wf(t,null),wo(t,null),!o){kr(e);return}Vf(t,o,s.name),Sn(bn(n),{path:r,structural:!1},n),i&&wo(t,i,"info"),kr(e)}async function Uf(e,t,n){return t||await jg(e,n)}function jg(e,t){let n=t?.ownerDocument?.defaultView?.FileReader||globalThis.FileReader;return n?new Promise(r=>{let o=new n;o.onload=()=>r(typeof o.result=="string"?o.result:""),o.onerror=()=>r("");try{o.readAsDataURL(e)}catch{r("")}}):Promise.resolve("")}function qg(e){if(typeof AbortController!="function")return null;let t=new AbortController;return(e.uploads||(e.uploads=new Set)).add(t),t}function Dg(e,t){t&&e.uploads?.delete(t)}function Fg(e,t){let n=e.closest("[data-hcms-path]");if(!n)return;let r=n.getAttribute("data-hcms-path")||"";Vf(n,"","");let o=n.querySelector('input[type="file"][data-hcms-upload]');o&&kr(o),wo(n,null),Sn(bn(t),{path:r,structural:!1},t)}function Bg(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function Vf(e,t,n){let r=Bg(e);if(!r)return;let o=(r.tagName||"").toUpperCase();o==="IMG"?r.src=t||"":o==="A"&&(r.href=t||"",r.textContent=t?n||Wl(t):"")}function kr(e){try{e.value=""}catch{}}function Wf(e,t){let n=e.querySelector?e.querySelector(".mirk-image__frame"):null;n&&(t?n.style.backgroundImage=`url("${t.replace(/"/g,"%22")}")`:n.style.removeProperty("background-image"))}function Hf(e,t){let n=Math.max(0,Math.min(100,Number(t)||0));e.setAttribute("data-hcms-uploading",""),e.style?.setProperty?.("--hcms-upload-progress",`${n}%`)}function $g(e){e.removeAttribute("data-hcms-uploading"),e.style?.removeProperty?.("--hcms-upload-progress")}function wo(e,t,n="error"){let r=e.querySelector?e.querySelector(":scope > .hcms-error"):null;r&&(r.classList.toggle("hcms-error--info",!!t&&n==="info"),t?(r.textContent=t,r.hidden=!1):(r.textContent="",r.hidden=!0))}function is(e,t){let{formRoot:n,pageRules:r}=t,o=n.querySelector(`[data-hcms-path="${Fr(e)}"]`);if(!o)throw new Error(`hypercms: no element at path "${e}"`);let s=o.querySelector(".hcms-array-items");if(!s)throw new Error(`hypercms: array container missing .hcms-array-items at "${e}"`);let i=er(e),l=Wg(r,i),a=Array.isArray(l),c=typeof l=="string"&&l.endsWith("[]");if(!a&&!c)throw new Error(`hypercms: path "${e}" is not an array`);let p=li(o,"data-hcms-max-items"),u=s.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(o.hasAttribute("data-hcms-no-add")||p!=null&&u.length>=p)return;let f=u.length,h=a?l[1]:l.replace(/\[\]$/,""),d=ts(a?h:"string"),v=bf({shape:a?"object-array-item":"scalar-array-item",itemShape:h,pathArr:[...i,f],data:d,doc:t.doc,itemKey:o.getAttribute("data-hcms-item-tpl")||null,pageRules:r});return s.appendChild(v),br(v,t.doc,t.view?.enhanceFormRichText!==!1),ea(o),Dr(`Add ${e}`,()=>Sn(bn(t),{path:e,structural:!0},t))}function Jl(e,t,n){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!r||r.hasAttribute("data-hcms-no-reorder"))return;let o=r.querySelector(".hcms-array-items");if(!o)return;let s=Array.from(o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),i=s.indexOf(e);if(i<0)return;let l=i+t;if(l<0||l>=s.length)return;let a=e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`);return t<0?o.insertBefore(e,s[l]):o.insertBefore(e,s[l].nextSibling),ta(o),ea(r),a&&typeof a.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),Dr(`Reorder ${r.getAttribute("data-hcms-path")||""}`,()=>Sn(bn(n),{path:r.getAttribute("data-hcms-path")||"",structural:!0},n))}var ii="Delete this item?";function Ug(e,t){let n=e&&e.getAttribute("data-hcms-confirm-remove");if(n!=null)return/^(off|false|no|0)$/i.test(n.trim())?null:n||ii;let r=t&&t.confirmRemove;return r===!1?null:typeof r=="string"?r||ii:r===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?ii:null}function Zl(e,t){let n=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),r=Ug(n,t);if(r==null)return xo(e,t);let o=sn("consent")||typeof window<"u"&&window.consent;typeof o=="function"?Promise.resolve(o(r)).then(()=>{t.closed||xo(e,t)},()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(r)&&xo(e,t):xo(e,t)}function xo(e,t){let n=e.getAttribute("data-hcms-path")||"",r=e.parentElement,o=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!o?.hasAttribute("data-hcms-no-remove")){if(o){let s=li(o,"data-hcms-min-items"),i=o.querySelector(".hcms-array-items"),l=i?i.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]").length:0;if(s!=null&&l<=s)return}return e.remove(),r&&ta(r),o&&ea(o),Dr(`Remove ${n}`,()=>Sn(bn(t),{path:n,structural:!0},t))}}function Sn(e,t,n){if(n.closed)return{ok:!1,skipped:!0,closed:!0};let r=ls(e);if(!t.structural&&r===n.lastFingerprint)return{ok:!0,skipped:!0};let o=Object.hasOwn(n,"writeRules")?n.writeRules:n.pageRules,s=Ou(n.pageRoot,o,e,{shellRoot:n.shellRoot,structural:!!t.structural,structuralPath:t.path||null,formRoot:n.formRoot});return s.ok?(n.lastFingerprint=r,n.lastData=e,vo(n,e),zf(n,null),n.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),n.onChange?.(e,t)):(zf(n,Vg(s.error,t.path)),n.dispatch?.("hcms:error",{error:s.error,attemptedData:e}),n.onError?.(s.error)),s}function ci(e,t){let n=Fr(t),r=`[data-hcms-path="${n}"] input[data-hcms-field], [data-hcms-path="${n}"] textarea[data-hcms-field], [data-hcms-path="${n}"] select[data-hcms-field], [data-hcms-path="${n}"] img[data-hcms-field], [data-hcms-path="${n}"] a[data-hcms-field], [data-hcms-path="${n}"] [contenteditable][data-hcms-field], input[data-hcms-path="${n}"][data-hcms-field], textarea[data-hcms-path="${n}"][data-hcms-field], select[data-hcms-path="${n}"][data-hcms-field], img[data-hcms-path="${n}"][data-hcms-field], a[data-hcms-path="${n}"][data-hcms-field], [contenteditable][data-hcms-path="${n}"][data-hcms-field]`;return e.querySelector(r)}function ui(e,t,n,r){let o=(e.tagName||"").toUpperCase(),s=(e.getAttribute("type")||"").toLowerCase();if(o==="INPUT"&&s==="checkbox"){e.checked=t===!0||t==="true";return}if(o==="INPUT"&&s==="radio"){let i=Fr(r),l=n.querySelectorAll(`[data-hcms-path="${i}"][data-hcms-field][type="radio"], [data-hcms-path="${i}"] [data-hcms-field][type="radio"]`);l.length?l.forEach(a=>{a.checked=String(a.value)===String(t??"")}):e.checked=String(e.value)===String(t??"");return}if(o==="IMG"){e.src=t==null?"":String(t);return}if(o==="A"){e.href=t==null?"":String(t);return}if(e.hasAttribute&&e.hasAttribute("contenteditable")){e.innerHTML=t==null?"":String(t);return}if("value"in e){e.value=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}function bn(e){let t=un.extract(e.formRoot,e.formRules,{exclude:null});return rr(t,e.formRules)}function rr(e,t){if(t==null||e==null)return e;if(typeof t=="string")return t.endsWith("@checked")?e===!0||e==="true":e;if(Array.isArray(t)){if(!Array.isArray(e))return e;let[,n]=t;return e.map(r=>rr(r,n))}if(typeof t=="object"){if(typeof e!="object"||Array.isArray(e))return e;let n={};for(let[r,o]of Object.entries(t))n[r]=rr(e[r],o);return n}return e}function zf(e,t){e.lastErrors=t&&t.length?t:null,Ql(e)}function Ql(e){if(Hg(e),e.errorEl&&(e.errorEl.textContent="",e.errorEl.hidden=!0),!e.lastErrors)return;let t=[];for(let{message:n,path:r}of e.lastErrors){if(r!=null&&r!==""){let o=zg(e.formRoot,r);if(o){o.textContent=o.textContent?`${o.textContent}
199
+ `},Ap=["@scalar","@object","@scalar-array","@scalar-array-item","@object-array","@object-array-item"];function Us(e){let t=e.head||e.documentElement;if(t)for(let n of Ap)Ru(e,t,n)}function Il(e,t){if(!Ou[t])return null;let n=e&&(e.head||e.documentElement);return n?Ru(e,n,t):null}var Au={src:"@image",checked:"@checkbox",innerHTML:"@richtext"},$s={image:"@image",file:"@file",checkbox:"@checkbox",toggle:"@toggle",select:"@select",radio:"@radio",textarea:"@textarea",number:"@number",richtext:"@richtext",color:"@color",font:"@font",variant:"@variant"},Tp=new Set([...Object.values($s),"@chips","@chips-item"]);function hr(e,t,n,r){if(typeof e!="string")return"@scalar";let o=Kt(e),s=Mu(e,o,n,r),i=Vs(e,o,n,r,t,"data-hcms-component");if(i&&$s[i]){let l=$s[i],a=Array.isArray(n)&&n.some(c=>c==="*"||typeof c=="number");return l==="@number"&&!Tu(e,o,t,a,s).every(Cp)||(l==="@checkbox"||l==="@toggle")&&(o<0||e.slice(o+1)!=="checked")&&!Tu(e,o,t,a,s).every(_p)?"@scalar":l}if(o>=0){let l=e.slice(o+1);if(Au[l])return Au[l];if(/^--color(-|$)/.test(l)&&l!=="--color-scheme")return"@color";if(/^--font(-|$)/.test(l)&&!wp.test(l))return"@font"}return"@scalar"}function Nu(e,t,n,r){if(typeof e!="string")return null;let o=Kt(e),s=Vs(e,o,n,r,t,"data-hcms-component");return s&&$s[s]||null}var Ep=new Set(["@color","@font","@variant"]),Op=new Set(["html","body",":root"]);function es(e,t,n,r){if(typeof e!="string"||e.endsWith("[]")||!Ep.has(hr(e,t,n,r)))return null;let o=Array.isArray(n)&&n.some(i=>i==="*"||typeof i=="number"),s=_u(e,Kt(e)).trim();return!o&&Op.has(s)?"page":"section"}var Np=/^-?\d+(\.\d+)?([eE][+-]?\d+)?$/;function Cp(e){return e==null||e===""?!0:Np.test(String(e))}function _p(e){return e==null||e===""||e==="true"||e==="false"}function Tu(e,t,n,r,o){if(!n||!n.querySelectorAll)return[];if(!o||o===".")return[];let s=null;try{s=n.querySelectorAll(o)}catch{return[]}let i=t>=0?e.slice(t+1):null,l=[];for(let a of s)if(!(a.closest&&a.closest("[cms-template], [data-hcms-shell]"))&&(i?i==="value"&&"value"in a?l.push(a.value):l.push(a.getAttribute?a.getAttribute(i):null):l.push((a.textContent||"").trim()),!r))break;return l}function Hs(e,t){if(typeof e!="string"||!e.endsWith("[]")||!t||!t.querySelector)return null;let n=e.slice(0,-2).trim();if(!n)return null;let r=null;try{r=t.querySelector(n)}catch{return null}let o=r&&r.closest?r.closest("[data-hcms-component]"):null;return(o&&o.getAttribute?o.getAttribute("data-hcms-component"):null)==="chips"?{array:"@chips",item:"@chips-item"}:null}function Rr(e,t,n){let r=e.join("."),o=e.map(s=>typeof s=="number"?"*":s).join(".");return r&&Nn(n,r)||o&&o!==r&&Nn(n,o)||Nn(n,t)}function zs(e,t,n){let r=Hs(e,n);if(!r)return null;let o=Rr(t,r.array,n);return o&&o.getAttribute("data-hcms-tpl")===r.array?r:null}function ts(e,t,n,r){if(typeof e!="string")return null;let o=Kt(e),s=Vs(e,o,n,r,t,"data-hcms-options");if(s==null)return null;let i=s.trim().split(/\s+/).filter(Boolean);return i.length?i:null}function Cu(e,t,n,r){if(typeof e!="string")return null;let o=Kt(e);return Vs(e,o,n,r,t,"data-hcms-crop")}function _u(e,t){return t>=0?e.slice(0,t):e}function Mu(e,t,n,r){let o=_u(e,t);return o&&o!=="."?o:Mp(r,n)}function Mp(e,t){if(e==null||!Array.isArray(t))return"";let n=[],r=e;for(let o of t){if(r==null||typeof r=="string")break;if(Array.isArray(r)){if(typeof r[0]!="string"||o!=="*"&&typeof o!="number")return"";n.push(r[0]),r=r[1];continue}if(typeof r!="object"||!Object.prototype.hasOwnProperty.call(r,o))return"";r=r[o]}return n.join(" ")}function Eu(e,t,n){if(!t||!t.querySelector||!e||e===".")return null;let r=null;try{r=t.querySelector(e)}catch{return null}return r&&r.getAttribute?r.getAttribute(n):null}function Vs(e,t,n,r,o,s){let i=Mu(e,t,n,r),l=t>=0?e.slice(t+1):null;if(l){let a=Eu(i,o,`${s}:${l}`);if(a!=null)return a;if(l.startsWith("--"))return null}return Eu(i,o,s)}function Ws(e,t){if(!e||t==null)return;n(t,[]);function n(r,o){let s=mr(r);if(s==="scalar"){let i=hr(r,e,o,t);Tp.has(i)&&Il(e,i);return}if(s==="scalar-array"){let i=Hs(r,e);i&&(Il(e,i.array),Il(e,i.item));return}if(s==="object"){for(let[i,l]of Object.entries(r))n(l,[...o,i]);return}if(s==="object-array"){let i=r[1],l=[...o,"*"];if(i&&typeof i=="object"&&!Array.isArray(i))for(let[a,c]of Object.entries(i))n(c,[...l,a]);else n(i,l)}}}function Ru(e,t,n){let r=Nn(e,n);if(r)return r;let o=e.createElement("template");return o.setAttribute("data-hcms-tpl",n),o.setAttribute("save-remove",""),o.innerHTML=Ou[n].trim(),t.appendChild(o),o}function Nn(e,t){return!e||!e.querySelector?null:e.querySelector(`template[data-hcms-tpl="${Rp(t)}"]`)}function Rp(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}function mr(e){return typeof e=="string"?e.endsWith("[]")?"scalar-array":"scalar":Array.isArray(e)?"object-array":typeof e=="object"&&e!==null?"object":"scalar"}function ao(e){return e?!!(e.content||e).querySelector("[data-hcms-field]"):!1}var Iu={IMG:"src",A:"href"};function Ks(e){return e.map(t=>typeof t=="number"||/^[0-9]+$/.test(String(t))?"*":String(t)).join(".")}function Gs(e){if(!e)return"value";let t=(e.tagName||"").toUpperCase();return t==="INPUT"?(e.getAttribute("type")||"text").toLowerCase()==="checkbox"?"checked":"value":t==="TEXTAREA"||t==="SELECT"?"value":Iu[t]?Iu[t]:e.hasAttribute&&e.hasAttribute("contenteditable")?"innerHTML":null}function Lu(e,t){let n=(e.tagName||"").toUpperCase(),r=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),o=Gs(e),i=`${ju(n,r)}[data-hcms-field="${Ir(t)}"]`;return n==="INPUT"&&r==="radio"?`${i}:checked@value`:o?`${i}@${o}`:i}function Ip(e){let t=(e.tagName||"").toUpperCase(),n=(e.getAttribute&&e.getAttribute("type")||"").toLowerCase(),r=Gs(e),s=`${ju(t,n)}[data-hcms-field]`;return t==="INPUT"&&n==="radio"?`${s}:checked@value`:r?`${s}@${r}`:s}function ju(e,t){return e==="INPUT"?t?`input[type="${t}"]`:"input":e==="TEXTAREA"?"textarea":e==="SELECT"?"select":e==="IMG"?"img":e==="A"?"a":':not([data-hcms-shape="scalar"]):not([data-hcms-shape="object"]):not([data-hcms-shape="object-array"]):not([data-hcms-shape="scalar-array"])'}function Ir(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Pu=new Set(["__proto__","constructor","prototype"]);function Lp(e){let t=new Map;return n(e,null),t;function n(r,o){if(typeof r=="string"){typeof o=="string"&&!r.endsWith("[]")&&t.set(o,(t.get(o)||0)+1);return}if(Array.isArray(r)){n(r[1],null);return}if(r&&typeof r=="object")for(let[s,i]of Object.entries(r))n(i,s)}}function Ys(e,t){let n=Lp(e);return r(e,[]);function r(u,f){let p=mr(u);if(p==="scalar")return o(u,f);if(p==="scalar-array")return i(u,f);if(p==="object-array")return l(u,f);if(p==="object"){let h=Object.create(null);for(let[v,g]of Object.entries(u)){if(Pu.has(v))throw new Error(`hypercms: rule key "${v}" is forbidden at "${f.join(".")||"<root>"}"`);h[v]=r(g,[...f,v])}return h}return null}function o(u,f){let p=f.length?f[f.length-1]:null,h=typeof p=="string"?p:"__value",v=m(f,h);if(v)return s(f,h,Lu(v,h));let g=c(hr(u,t,f,e),h);return g?s(f,h,Lu(g,h)):s(f,h,`input[data-hcms-field="${Ir(h)}"]@value`)}function s(u,f,p){if((n.get(f)||0)<2)return p;let h=`[data-hcms-path-shape="${Ir(Ks(u))}"]`,v=p.lastIndexOf("@"),g=v===-1?p:p.slice(0,v),d=v===-1?"":p.slice(v);return`${h} ${g}, ${g}${h}${d}`}function i(u,f){let p=zs(u,f,t),h=p&&c(p.item,null)||c("@scalar-array-item",null),v=h?Ip(h):"input[data-hcms-field]@value";return[a(f,"[data-hcms-array-item]"),v]}function l(u,f){let[,p]=u,h=[...f,"*"],v=a(f,"[data-hcms-card]");if(p&&typeof p=="object"&&!Array.isArray(p)){let g=Object.create(null);for(let[d,k]of Object.entries(p)){if(Pu.has(d))throw new Error(`hypercms: rule key "${d}" is forbidden at "${h.join(".")}"`);g[d]=r(k,[...h,d])}return[v,g]}return[v,r(p,[...h,0])]}function a(u,f){let p=u.length?u[u.length-1]:"",h=u.some(d=>d==="*"),v=u.join(".");return`${h?`[data-hcms-field="${Ir(p)}"]`:`[data-hcms-path="${Ir(v)}"]`} > .hcms-array-items > ${f}`}function c(u,f){if(!t)return null;let p=Nn(t,u);if(!p)return null;let h=p.content||p;if(f){let v=h.querySelector(`[data-hcms-field="${Ir(f)}"]`);if(v)return v}return h.querySelector("[data-hcms-field]")}function m(u,f){if(!t)return null;let p=u.map(g=>typeof g=="number"?"*":g).join("."),v=[u.join("."),p];for(let g=u.length-1;g>=0;g--){let d=u.slice(0,g).map(k=>typeof k=="number"?"*":k);mr(er(e,d))==="object"&&v.push(d.join(".")),d.push("*"),v.push(d.join("."))}for(let g of v){if(!g)continue;let d=Nn(t,g);if(!d||!ao(d))continue;let k=d.content||d,S=k.querySelector(`[data-hcms-field="${Ir(f)}"]`)||k.querySelector("[data-hcms-field]");if(S)return S}return null}}var qu=["50","100","200","300","400","500","600","700","800","900","950"],Du=["red","orange","amber","yellow","lime","green","emerald","teal","cyan","sky","blue","indigo","violet","purple","fuchsia","pink","rose","slate","gray","zinc","neutral","stone","mauve","olive","mist","taupe"],co=Object.freeze([{id:"red-50",hue:"red",shade:"50",value:"oklch(97.1% 0.013 17.38)"},{id:"red-100",hue:"red",shade:"100",value:"oklch(93.6% 0.032 17.717)"},{id:"red-200",hue:"red",shade:"200",value:"oklch(88.5% 0.062 18.334)"},{id:"red-300",hue:"red",shade:"300",value:"oklch(80.8% 0.114 19.571)"},{id:"red-400",hue:"red",shade:"400",value:"oklch(70.4% 0.191 22.216)"},{id:"red-500",hue:"red",shade:"500",value:"oklch(63.7% 0.237 25.331)"},{id:"red-600",hue:"red",shade:"600",value:"oklch(57.7% 0.245 27.325)"},{id:"red-700",hue:"red",shade:"700",value:"oklch(50.5% 0.213 27.518)"},{id:"red-800",hue:"red",shade:"800",value:"oklch(44.4% 0.177 26.899)"},{id:"red-900",hue:"red",shade:"900",value:"oklch(39.6% 0.141 25.723)"},{id:"red-950",hue:"red",shade:"950",value:"oklch(25.8% 0.092 26.042)"},{id:"orange-50",hue:"orange",shade:"50",value:"oklch(98% 0.016 73.684)"},{id:"orange-100",hue:"orange",shade:"100",value:"oklch(95.4% 0.038 75.164)"},{id:"orange-200",hue:"orange",shade:"200",value:"oklch(90.1% 0.076 70.697)"},{id:"orange-300",hue:"orange",shade:"300",value:"oklch(83.7% 0.128 66.29)"},{id:"orange-400",hue:"orange",shade:"400",value:"oklch(75% 0.183 55.934)"},{id:"orange-500",hue:"orange",shade:"500",value:"oklch(70.5% 0.213 47.604)"},{id:"orange-600",hue:"orange",shade:"600",value:"oklch(64.6% 0.222 41.116)"},{id:"orange-700",hue:"orange",shade:"700",value:"oklch(55.3% 0.195 38.402)"},{id:"orange-800",hue:"orange",shade:"800",value:"oklch(47% 0.157 37.304)"},{id:"orange-900",hue:"orange",shade:"900",value:"oklch(40.8% 0.123 38.172)"},{id:"orange-950",hue:"orange",shade:"950",value:"oklch(26.6% 0.079 36.259)"},{id:"amber-50",hue:"amber",shade:"50",value:"oklch(98.7% 0.022 95.277)"},{id:"amber-100",hue:"amber",shade:"100",value:"oklch(96.2% 0.059 95.617)"},{id:"amber-200",hue:"amber",shade:"200",value:"oklch(92.4% 0.12 95.746)"},{id:"amber-300",hue:"amber",shade:"300",value:"oklch(87.9% 0.169 91.605)"},{id:"amber-400",hue:"amber",shade:"400",value:"oklch(82.8% 0.189 84.429)"},{id:"amber-500",hue:"amber",shade:"500",value:"oklch(76.9% 0.188 70.08)"},{id:"amber-600",hue:"amber",shade:"600",value:"oklch(66.6% 0.179 58.318)"},{id:"amber-700",hue:"amber",shade:"700",value:"oklch(55.5% 0.163 48.998)"},{id:"amber-800",hue:"amber",shade:"800",value:"oklch(47.3% 0.137 46.201)"},{id:"amber-900",hue:"amber",shade:"900",value:"oklch(41.4% 0.112 45.904)"},{id:"amber-950",hue:"amber",shade:"950",value:"oklch(27.9% 0.077 45.635)"},{id:"yellow-50",hue:"yellow",shade:"50",value:"oklch(98.7% 0.026 102.212)"},{id:"yellow-100",hue:"yellow",shade:"100",value:"oklch(97.3% 0.071 103.193)"},{id:"yellow-200",hue:"yellow",shade:"200",value:"oklch(94.5% 0.129 101.54)"},{id:"yellow-300",hue:"yellow",shade:"300",value:"oklch(90.5% 0.182 98.111)"},{id:"yellow-400",hue:"yellow",shade:"400",value:"oklch(85.2% 0.199 91.936)"},{id:"yellow-500",hue:"yellow",shade:"500",value:"oklch(79.5% 0.184 86.047)"},{id:"yellow-600",hue:"yellow",shade:"600",value:"oklch(68.1% 0.162 75.834)"},{id:"yellow-700",hue:"yellow",shade:"700",value:"oklch(55.4% 0.135 66.442)"},{id:"yellow-800",hue:"yellow",shade:"800",value:"oklch(47.6% 0.114 61.907)"},{id:"yellow-900",hue:"yellow",shade:"900",value:"oklch(42.1% 0.095 57.708)"},{id:"yellow-950",hue:"yellow",shade:"950",value:"oklch(28.6% 0.066 53.813)"},{id:"lime-50",hue:"lime",shade:"50",value:"oklch(98.6% 0.031 120.757)"},{id:"lime-100",hue:"lime",shade:"100",value:"oklch(96.7% 0.067 122.328)"},{id:"lime-200",hue:"lime",shade:"200",value:"oklch(93.8% 0.127 124.321)"},{id:"lime-300",hue:"lime",shade:"300",value:"oklch(89.7% 0.196 126.665)"},{id:"lime-400",hue:"lime",shade:"400",value:"oklch(84.1% 0.238 128.85)"},{id:"lime-500",hue:"lime",shade:"500",value:"oklch(76.8% 0.233 130.85)"},{id:"lime-600",hue:"lime",shade:"600",value:"oklch(64.8% 0.2 131.684)"},{id:"lime-700",hue:"lime",shade:"700",value:"oklch(53.2% 0.157 131.589)"},{id:"lime-800",hue:"lime",shade:"800",value:"oklch(45.3% 0.124 130.933)"},{id:"lime-900",hue:"lime",shade:"900",value:"oklch(40.5% 0.101 131.063)"},{id:"lime-950",hue:"lime",shade:"950",value:"oklch(27.4% 0.072 132.109)"},{id:"green-50",hue:"green",shade:"50",value:"oklch(98.2% 0.018 155.826)"},{id:"green-100",hue:"green",shade:"100",value:"oklch(96.2% 0.044 156.743)"},{id:"green-200",hue:"green",shade:"200",value:"oklch(92.5% 0.084 155.995)"},{id:"green-300",hue:"green",shade:"300",value:"oklch(87.1% 0.15 154.449)"},{id:"green-400",hue:"green",shade:"400",value:"oklch(79.2% 0.209 151.711)"},{id:"green-500",hue:"green",shade:"500",value:"oklch(72.3% 0.219 149.579)"},{id:"green-600",hue:"green",shade:"600",value:"oklch(62.7% 0.194 149.214)"},{id:"green-700",hue:"green",shade:"700",value:"oklch(52.7% 0.154 150.069)"},{id:"green-800",hue:"green",shade:"800",value:"oklch(44.8% 0.119 151.328)"},{id:"green-900",hue:"green",shade:"900",value:"oklch(39.3% 0.095 152.535)"},{id:"green-950",hue:"green",shade:"950",value:"oklch(26.6% 0.065 152.934)"},{id:"emerald-50",hue:"emerald",shade:"50",value:"oklch(97.9% 0.021 166.113)"},{id:"emerald-100",hue:"emerald",shade:"100",value:"oklch(95% 0.052 163.051)"},{id:"emerald-200",hue:"emerald",shade:"200",value:"oklch(90.5% 0.093 164.15)"},{id:"emerald-300",hue:"emerald",shade:"300",value:"oklch(84.5% 0.143 164.978)"},{id:"emerald-400",hue:"emerald",shade:"400",value:"oklch(76.5% 0.177 163.223)"},{id:"emerald-500",hue:"emerald",shade:"500",value:"oklch(69.6% 0.17 162.48)"},{id:"emerald-600",hue:"emerald",shade:"600",value:"oklch(59.6% 0.145 163.225)"},{id:"emerald-700",hue:"emerald",shade:"700",value:"oklch(50.8% 0.118 165.612)"},{id:"emerald-800",hue:"emerald",shade:"800",value:"oklch(43.2% 0.095 166.913)"},{id:"emerald-900",hue:"emerald",shade:"900",value:"oklch(37.8% 0.077 168.94)"},{id:"emerald-950",hue:"emerald",shade:"950",value:"oklch(26.2% 0.051 172.552)"},{id:"teal-50",hue:"teal",shade:"50",value:"oklch(98.4% 0.014 180.72)"},{id:"teal-100",hue:"teal",shade:"100",value:"oklch(95.3% 0.051 180.801)"},{id:"teal-200",hue:"teal",shade:"200",value:"oklch(91% 0.096 180.426)"},{id:"teal-300",hue:"teal",shade:"300",value:"oklch(85.5% 0.138 181.071)"},{id:"teal-400",hue:"teal",shade:"400",value:"oklch(77.7% 0.152 181.912)"},{id:"teal-500",hue:"teal",shade:"500",value:"oklch(70.4% 0.14 182.503)"},{id:"teal-600",hue:"teal",shade:"600",value:"oklch(60% 0.118 184.704)"},{id:"teal-700",hue:"teal",shade:"700",value:"oklch(51.1% 0.096 186.391)"},{id:"teal-800",hue:"teal",shade:"800",value:"oklch(43.7% 0.078 188.216)"},{id:"teal-900",hue:"teal",shade:"900",value:"oklch(38.6% 0.063 188.416)"},{id:"teal-950",hue:"teal",shade:"950",value:"oklch(27.7% 0.046 192.524)"},{id:"cyan-50",hue:"cyan",shade:"50",value:"oklch(98.4% 0.019 200.873)"},{id:"cyan-100",hue:"cyan",shade:"100",value:"oklch(95.6% 0.045 203.388)"},{id:"cyan-200",hue:"cyan",shade:"200",value:"oklch(91.7% 0.08 205.041)"},{id:"cyan-300",hue:"cyan",shade:"300",value:"oklch(86.5% 0.127 207.078)"},{id:"cyan-400",hue:"cyan",shade:"400",value:"oklch(78.9% 0.154 211.53)"},{id:"cyan-500",hue:"cyan",shade:"500",value:"oklch(71.5% 0.143 215.221)"},{id:"cyan-600",hue:"cyan",shade:"600",value:"oklch(60.9% 0.126 221.723)"},{id:"cyan-700",hue:"cyan",shade:"700",value:"oklch(52% 0.105 223.128)"},{id:"cyan-800",hue:"cyan",shade:"800",value:"oklch(45% 0.085 224.283)"},{id:"cyan-900",hue:"cyan",shade:"900",value:"oklch(39.8% 0.07 227.392)"},{id:"cyan-950",hue:"cyan",shade:"950",value:"oklch(30.2% 0.056 229.695)"},{id:"sky-50",hue:"sky",shade:"50",value:"oklch(97.7% 0.013 236.62)"},{id:"sky-100",hue:"sky",shade:"100",value:"oklch(95.1% 0.026 236.824)"},{id:"sky-200",hue:"sky",shade:"200",value:"oklch(90.1% 0.058 230.902)"},{id:"sky-300",hue:"sky",shade:"300",value:"oklch(82.8% 0.111 230.318)"},{id:"sky-400",hue:"sky",shade:"400",value:"oklch(74.6% 0.16 232.661)"},{id:"sky-500",hue:"sky",shade:"500",value:"oklch(68.5% 0.169 237.323)"},{id:"sky-600",hue:"sky",shade:"600",value:"oklch(58.8% 0.158 241.966)"},{id:"sky-700",hue:"sky",shade:"700",value:"oklch(50% 0.134 242.749)"},{id:"sky-800",hue:"sky",shade:"800",value:"oklch(44.3% 0.11 240.79)"},{id:"sky-900",hue:"sky",shade:"900",value:"oklch(39.1% 0.09 240.876)"},{id:"sky-950",hue:"sky",shade:"950",value:"oklch(29.3% 0.066 243.157)"},{id:"blue-50",hue:"blue",shade:"50",value:"oklch(97% 0.014 254.604)"},{id:"blue-100",hue:"blue",shade:"100",value:"oklch(93.2% 0.032 255.585)"},{id:"blue-200",hue:"blue",shade:"200",value:"oklch(88.2% 0.059 254.128)"},{id:"blue-300",hue:"blue",shade:"300",value:"oklch(80.9% 0.105 251.813)"},{id:"blue-400",hue:"blue",shade:"400",value:"oklch(70.7% 0.165 254.624)"},{id:"blue-500",hue:"blue",shade:"500",value:"oklch(62.3% 0.214 259.815)"},{id:"blue-600",hue:"blue",shade:"600",value:"oklch(54.6% 0.245 262.881)"},{id:"blue-700",hue:"blue",shade:"700",value:"oklch(48.8% 0.243 264.376)"},{id:"blue-800",hue:"blue",shade:"800",value:"oklch(42.4% 0.199 265.638)"},{id:"blue-900",hue:"blue",shade:"900",value:"oklch(37.9% 0.146 265.522)"},{id:"blue-950",hue:"blue",shade:"950",value:"oklch(28.2% 0.091 267.935)"},{id:"indigo-50",hue:"indigo",shade:"50",value:"oklch(96.2% 0.018 272.314)"},{id:"indigo-100",hue:"indigo",shade:"100",value:"oklch(93% 0.034 272.788)"},{id:"indigo-200",hue:"indigo",shade:"200",value:"oklch(87% 0.065 274.039)"},{id:"indigo-300",hue:"indigo",shade:"300",value:"oklch(78.5% 0.115 274.713)"},{id:"indigo-400",hue:"indigo",shade:"400",value:"oklch(67.3% 0.182 276.935)"},{id:"indigo-500",hue:"indigo",shade:"500",value:"oklch(58.5% 0.233 277.117)"},{id:"indigo-600",hue:"indigo",shade:"600",value:"oklch(51.1% 0.262 276.966)"},{id:"indigo-700",hue:"indigo",shade:"700",value:"oklch(45.7% 0.24 277.023)"},{id:"indigo-800",hue:"indigo",shade:"800",value:"oklch(39.8% 0.195 277.366)"},{id:"indigo-900",hue:"indigo",shade:"900",value:"oklch(35.9% 0.144 278.697)"},{id:"indigo-950",hue:"indigo",shade:"950",value:"oklch(25.7% 0.09 281.288)"},{id:"violet-50",hue:"violet",shade:"50",value:"oklch(96.9% 0.016 293.756)"},{id:"violet-100",hue:"violet",shade:"100",value:"oklch(94.3% 0.029 294.588)"},{id:"violet-200",hue:"violet",shade:"200",value:"oklch(89.4% 0.057 293.283)"},{id:"violet-300",hue:"violet",shade:"300",value:"oklch(81.1% 0.111 293.571)"},{id:"violet-400",hue:"violet",shade:"400",value:"oklch(70.2% 0.183 293.541)"},{id:"violet-500",hue:"violet",shade:"500",value:"oklch(60.6% 0.25 292.717)"},{id:"violet-600",hue:"violet",shade:"600",value:"oklch(54.1% 0.281 293.009)"},{id:"violet-700",hue:"violet",shade:"700",value:"oklch(49.1% 0.27 292.581)"},{id:"violet-800",hue:"violet",shade:"800",value:"oklch(43.2% 0.232 292.759)"},{id:"violet-900",hue:"violet",shade:"900",value:"oklch(38% 0.189 293.745)"},{id:"violet-950",hue:"violet",shade:"950",value:"oklch(28.3% 0.141 291.089)"},{id:"purple-50",hue:"purple",shade:"50",value:"oklch(97.7% 0.014 308.299)"},{id:"purple-100",hue:"purple",shade:"100",value:"oklch(94.6% 0.033 307.174)"},{id:"purple-200",hue:"purple",shade:"200",value:"oklch(90.2% 0.063 306.703)"},{id:"purple-300",hue:"purple",shade:"300",value:"oklch(82.7% 0.119 306.383)"},{id:"purple-400",hue:"purple",shade:"400",value:"oklch(71.4% 0.203 305.504)"},{id:"purple-500",hue:"purple",shade:"500",value:"oklch(62.7% 0.265 303.9)"},{id:"purple-600",hue:"purple",shade:"600",value:"oklch(55.8% 0.288 302.321)"},{id:"purple-700",hue:"purple",shade:"700",value:"oklch(49.6% 0.265 301.924)"},{id:"purple-800",hue:"purple",shade:"800",value:"oklch(43.8% 0.218 303.724)"},{id:"purple-900",hue:"purple",shade:"900",value:"oklch(38.1% 0.176 304.987)"},{id:"purple-950",hue:"purple",shade:"950",value:"oklch(29.1% 0.149 302.717)"},{id:"fuchsia-50",hue:"fuchsia",shade:"50",value:"oklch(97.7% 0.017 320.058)"},{id:"fuchsia-100",hue:"fuchsia",shade:"100",value:"oklch(95.2% 0.037 318.852)"},{id:"fuchsia-200",hue:"fuchsia",shade:"200",value:"oklch(90.3% 0.076 319.62)"},{id:"fuchsia-300",hue:"fuchsia",shade:"300",value:"oklch(83.3% 0.145 321.434)"},{id:"fuchsia-400",hue:"fuchsia",shade:"400",value:"oklch(74% 0.238 322.16)"},{id:"fuchsia-500",hue:"fuchsia",shade:"500",value:"oklch(66.7% 0.295 322.15)"},{id:"fuchsia-600",hue:"fuchsia",shade:"600",value:"oklch(59.1% 0.293 322.896)"},{id:"fuchsia-700",hue:"fuchsia",shade:"700",value:"oklch(51.8% 0.253 323.949)"},{id:"fuchsia-800",hue:"fuchsia",shade:"800",value:"oklch(45.2% 0.211 324.591)"},{id:"fuchsia-900",hue:"fuchsia",shade:"900",value:"oklch(40.1% 0.17 325.612)"},{id:"fuchsia-950",hue:"fuchsia",shade:"950",value:"oklch(29.3% 0.136 325.661)"},{id:"pink-50",hue:"pink",shade:"50",value:"oklch(97.1% 0.014 343.198)"},{id:"pink-100",hue:"pink",shade:"100",value:"oklch(94.8% 0.028 342.258)"},{id:"pink-200",hue:"pink",shade:"200",value:"oklch(89.9% 0.061 343.231)"},{id:"pink-300",hue:"pink",shade:"300",value:"oklch(82.3% 0.12 346.018)"},{id:"pink-400",hue:"pink",shade:"400",value:"oklch(71.8% 0.202 349.761)"},{id:"pink-500",hue:"pink",shade:"500",value:"oklch(65.6% 0.241 354.308)"},{id:"pink-600",hue:"pink",shade:"600",value:"oklch(59.2% 0.249 0.584)"},{id:"pink-700",hue:"pink",shade:"700",value:"oklch(52.5% 0.223 3.958)"},{id:"pink-800",hue:"pink",shade:"800",value:"oklch(45.9% 0.187 3.815)"},{id:"pink-900",hue:"pink",shade:"900",value:"oklch(40.8% 0.153 2.432)"},{id:"pink-950",hue:"pink",shade:"950",value:"oklch(28.4% 0.109 3.907)"},{id:"rose-50",hue:"rose",shade:"50",value:"oklch(96.9% 0.015 12.422)"},{id:"rose-100",hue:"rose",shade:"100",value:"oklch(94.1% 0.03 12.58)"},{id:"rose-200",hue:"rose",shade:"200",value:"oklch(89.2% 0.058 10.001)"},{id:"rose-300",hue:"rose",shade:"300",value:"oklch(81% 0.117 11.638)"},{id:"rose-400",hue:"rose",shade:"400",value:"oklch(71.2% 0.194 13.428)"},{id:"rose-500",hue:"rose",shade:"500",value:"oklch(64.5% 0.246 16.439)"},{id:"rose-600",hue:"rose",shade:"600",value:"oklch(58.6% 0.253 17.585)"},{id:"rose-700",hue:"rose",shade:"700",value:"oklch(51.4% 0.222 16.935)"},{id:"rose-800",hue:"rose",shade:"800",value:"oklch(45.5% 0.188 13.697)"},{id:"rose-900",hue:"rose",shade:"900",value:"oklch(41% 0.159 10.272)"},{id:"rose-950",hue:"rose",shade:"950",value:"oklch(27.1% 0.105 12.094)"},{id:"slate-50",hue:"slate",shade:"50",value:"oklch(98.4% 0.003 247.858)"},{id:"slate-100",hue:"slate",shade:"100",value:"oklch(96.8% 0.007 247.896)"},{id:"slate-200",hue:"slate",shade:"200",value:"oklch(92.9% 0.013 255.508)"},{id:"slate-300",hue:"slate",shade:"300",value:"oklch(86.9% 0.022 252.894)"},{id:"slate-400",hue:"slate",shade:"400",value:"oklch(70.4% 0.04 256.788)"},{id:"slate-500",hue:"slate",shade:"500",value:"oklch(55.4% 0.046 257.417)"},{id:"slate-600",hue:"slate",shade:"600",value:"oklch(44.6% 0.043 257.281)"},{id:"slate-700",hue:"slate",shade:"700",value:"oklch(37.2% 0.044 257.287)"},{id:"slate-800",hue:"slate",shade:"800",value:"oklch(27.9% 0.041 260.031)"},{id:"slate-900",hue:"slate",shade:"900",value:"oklch(20.8% 0.042 265.755)"},{id:"slate-950",hue:"slate",shade:"950",value:"oklch(12.9% 0.042 264.695)"},{id:"gray-50",hue:"gray",shade:"50",value:"oklch(98.5% 0.002 247.839)"},{id:"gray-100",hue:"gray",shade:"100",value:"oklch(96.7% 0.003 264.542)"},{id:"gray-200",hue:"gray",shade:"200",value:"oklch(92.8% 0.006 264.531)"},{id:"gray-300",hue:"gray",shade:"300",value:"oklch(87.2% 0.01 258.338)"},{id:"gray-400",hue:"gray",shade:"400",value:"oklch(70.7% 0.022 261.325)"},{id:"gray-500",hue:"gray",shade:"500",value:"oklch(55.1% 0.027 264.364)"},{id:"gray-600",hue:"gray",shade:"600",value:"oklch(44.6% 0.03 256.802)"},{id:"gray-700",hue:"gray",shade:"700",value:"oklch(37.3% 0.034 259.733)"},{id:"gray-800",hue:"gray",shade:"800",value:"oklch(27.8% 0.033 256.848)"},{id:"gray-900",hue:"gray",shade:"900",value:"oklch(21% 0.034 264.665)"},{id:"gray-950",hue:"gray",shade:"950",value:"oklch(13% 0.028 261.692)"},{id:"zinc-50",hue:"zinc",shade:"50",value:"oklch(98.5% 0 none)"},{id:"zinc-100",hue:"zinc",shade:"100",value:"oklch(96.7% 0.001 286.375)"},{id:"zinc-200",hue:"zinc",shade:"200",value:"oklch(92% 0.004 286.32)"},{id:"zinc-300",hue:"zinc",shade:"300",value:"oklch(87.1% 0.006 286.286)"},{id:"zinc-400",hue:"zinc",shade:"400",value:"oklch(70.5% 0.015 286.067)"},{id:"zinc-500",hue:"zinc",shade:"500",value:"oklch(55.2% 0.016 285.938)"},{id:"zinc-600",hue:"zinc",shade:"600",value:"oklch(44.2% 0.017 285.786)"},{id:"zinc-700",hue:"zinc",shade:"700",value:"oklch(37% 0.013 285.805)"},{id:"zinc-800",hue:"zinc",shade:"800",value:"oklch(27.4% 0.006 286.033)"},{id:"zinc-900",hue:"zinc",shade:"900",value:"oklch(21% 0.006 285.885)"},{id:"zinc-950",hue:"zinc",shade:"950",value:"oklch(14.1% 0.005 285.823)"},{id:"neutral-50",hue:"neutral",shade:"50",value:"oklch(98.5% 0 none)"},{id:"neutral-100",hue:"neutral",shade:"100",value:"oklch(97% 0 none)"},{id:"neutral-200",hue:"neutral",shade:"200",value:"oklch(92.2% 0 none)"},{id:"neutral-300",hue:"neutral",shade:"300",value:"oklch(87% 0 none)"},{id:"neutral-400",hue:"neutral",shade:"400",value:"oklch(70.8% 0 none)"},{id:"neutral-500",hue:"neutral",shade:"500",value:"oklch(55.6% 0 none)"},{id:"neutral-600",hue:"neutral",shade:"600",value:"oklch(43.9% 0 none)"},{id:"neutral-700",hue:"neutral",shade:"700",value:"oklch(37.1% 0 none)"},{id:"neutral-800",hue:"neutral",shade:"800",value:"oklch(26.9% 0 none)"},{id:"neutral-900",hue:"neutral",shade:"900",value:"oklch(20.5% 0 none)"},{id:"neutral-950",hue:"neutral",shade:"950",value:"oklch(14.5% 0 none)"},{id:"stone-50",hue:"stone",shade:"50",value:"oklch(98.5% 0.001 106.423)"},{id:"stone-100",hue:"stone",shade:"100",value:"oklch(97% 0.001 106.424)"},{id:"stone-200",hue:"stone",shade:"200",value:"oklch(92.3% 0.003 48.717)"},{id:"stone-300",hue:"stone",shade:"300",value:"oklch(86.9% 0.005 56.366)"},{id:"stone-400",hue:"stone",shade:"400",value:"oklch(70.9% 0.01 56.259)"},{id:"stone-500",hue:"stone",shade:"500",value:"oklch(55.3% 0.013 58.071)"},{id:"stone-600",hue:"stone",shade:"600",value:"oklch(44.4% 0.011 73.639)"},{id:"stone-700",hue:"stone",shade:"700",value:"oklch(37.4% 0.01 67.558)"},{id:"stone-800",hue:"stone",shade:"800",value:"oklch(26.8% 0.007 34.298)"},{id:"stone-900",hue:"stone",shade:"900",value:"oklch(21.6% 0.006 56.043)"},{id:"stone-950",hue:"stone",shade:"950",value:"oklch(14.7% 0.004 49.25)"},{id:"mauve-50",hue:"mauve",shade:"50",value:"oklch(98.5% 0 none)"},{id:"mauve-100",hue:"mauve",shade:"100",value:"oklch(96% 0.003 325.6)"},{id:"mauve-200",hue:"mauve",shade:"200",value:"oklch(92.2% 0.005 325.62)"},{id:"mauve-300",hue:"mauve",shade:"300",value:"oklch(86.5% 0.012 325.68)"},{id:"mauve-400",hue:"mauve",shade:"400",value:"oklch(71.1% 0.019 323.02)"},{id:"mauve-500",hue:"mauve",shade:"500",value:"oklch(54.2% 0.034 322.5)"},{id:"mauve-600",hue:"mauve",shade:"600",value:"oklch(43.5% 0.029 321.78)"},{id:"mauve-700",hue:"mauve",shade:"700",value:"oklch(36.4% 0.029 323.89)"},{id:"mauve-800",hue:"mauve",shade:"800",value:"oklch(26.3% 0.024 320.12)"},{id:"mauve-900",hue:"mauve",shade:"900",value:"oklch(21.2% 0.019 322.12)"},{id:"mauve-950",hue:"mauve",shade:"950",value:"oklch(14.5% 0.008 326)"},{id:"olive-50",hue:"olive",shade:"50",value:"oklch(98.8% 0.003 106.5)"},{id:"olive-100",hue:"olive",shade:"100",value:"oklch(96.6% 0.005 106.5)"},{id:"olive-200",hue:"olive",shade:"200",value:"oklch(93% 0.007 106.5)"},{id:"olive-300",hue:"olive",shade:"300",value:"oklch(88% 0.011 106.6)"},{id:"olive-400",hue:"olive",shade:"400",value:"oklch(73.7% 0.021 106.9)"},{id:"olive-500",hue:"olive",shade:"500",value:"oklch(58% 0.031 107.3)"},{id:"olive-600",hue:"olive",shade:"600",value:"oklch(46.6% 0.025 107.3)"},{id:"olive-700",hue:"olive",shade:"700",value:"oklch(39.4% 0.023 107.4)"},{id:"olive-800",hue:"olive",shade:"800",value:"oklch(28.6% 0.016 107.4)"},{id:"olive-900",hue:"olive",shade:"900",value:"oklch(22.8% 0.013 107.4)"},{id:"olive-950",hue:"olive",shade:"950",value:"oklch(15.3% 0.006 107.1)"},{id:"mist-50",hue:"mist",shade:"50",value:"oklch(98.7% 0.002 197.1)"},{id:"mist-100",hue:"mist",shade:"100",value:"oklch(96.3% 0.002 197.1)"},{id:"mist-200",hue:"mist",shade:"200",value:"oklch(92.5% 0.005 214.3)"},{id:"mist-300",hue:"mist",shade:"300",value:"oklch(87.2% 0.007 219.6)"},{id:"mist-400",hue:"mist",shade:"400",value:"oklch(72.3% 0.014 214.4)"},{id:"mist-500",hue:"mist",shade:"500",value:"oklch(56% 0.021 213.5)"},{id:"mist-600",hue:"mist",shade:"600",value:"oklch(45% 0.017 213.2)"},{id:"mist-700",hue:"mist",shade:"700",value:"oklch(37.8% 0.015 216)"},{id:"mist-800",hue:"mist",shade:"800",value:"oklch(27.5% 0.011 216.9)"},{id:"mist-900",hue:"mist",shade:"900",value:"oklch(21.8% 0.008 223.9)"},{id:"mist-950",hue:"mist",shade:"950",value:"oklch(14.8% 0.004 228.8)"},{id:"taupe-50",hue:"taupe",shade:"50",value:"oklch(98.6% 0.002 67.8)"},{id:"taupe-100",hue:"taupe",shade:"100",value:"oklch(96% 0.002 17.2)"},{id:"taupe-200",hue:"taupe",shade:"200",value:"oklch(92.2% 0.005 34.3)"},{id:"taupe-300",hue:"taupe",shade:"300",value:"oklch(86.8% 0.007 39.5)"},{id:"taupe-400",hue:"taupe",shade:"400",value:"oklch(71.4% 0.014 41.2)"},{id:"taupe-500",hue:"taupe",shade:"500",value:"oklch(54.7% 0.021 43.1)"},{id:"taupe-600",hue:"taupe",shade:"600",value:"oklch(43.8% 0.017 39.3)"},{id:"taupe-700",hue:"taupe",shade:"700",value:"oklch(36.7% 0.016 35.7)"},{id:"taupe-800",hue:"taupe",shade:"800",value:"oklch(26.8% 0.011 36.5)"},{id:"taupe-900",hue:"taupe",shade:"900",value:"oklch(21.4% 0.009 43.1)"},{id:"taupe-950",hue:"taupe",shade:"950",value:"oklch(14.7% 0.004 49.3)"}]);var Pp=12,Fu=new Map(co.map(e=>[e.id,e])),jp=new Map(co.map(e=>[e.value,e])),qp=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Dp=/^(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color|color-mix|light-dark)\(.*\)$/i,Fp=/[;{}<>\\]|url\s*\(/i,Bu=new WeakMap;function Ll(e){let t=Bu.get(e);return t||Bu.set(e,t=new Set),t}function $u(e,t){let n=String(e??"").trim();if(!n||Fp.test(n)||El(n))return!1;let r=t?.defaultView?.CSS;return r&&typeof r.supports=="function"?r.supports("color",n):qp.test(n)||Dp.test(n)||/^[a-z]+$/i.test(n)}function Uu(e){return`${e.hue[0].toUpperCase()}${e.hue.slice(1)} ${e.shade}`}function Xs(e){return{id:e.id,label:Uu(e),value:e.value}}function Hu(e){let t=String(e??"").trim(),n=jp.get(t);return n?Uu(n):t}function Bp(e,t){if(!e||e.length===0)return{swatches:co.map(Xs),custom:!0,full:!0};let n=[],r=new Set,o=!1,s=i=>{r.has(i.value)||(r.add(i.value),n.push(i))};for(let i of e)i==="custom"?o=!0:Fu.has(i)?s(Xs(Fu.get(i))):Du.includes(i)?co.filter(l=>l.hue===i).forEach(l=>s(Xs(l))):qu.includes(i)?co.filter(l=>l.shade===i).forEach(l=>s(Xs(l))):$u(i,t)?s({id:null,label:i,value:i}):console.warn(`[hypercms] color option "${i}" is not a Tailwind color, hue, shade, CSS color or "custom"; ignoring it`);return{swatches:n,custom:o,full:!1}}function zu(e,{value:t,tokens:n,path:r,doc:o}){let{swatches:s,custom:i,full:l}=Bp(n,o),a=t==null?"":String(t).trim();a&&!s.some(f=>f.value===a)&&s.unshift({id:null,label:Hu(a),value:a});let c=s.length<=Pp;e.setAttribute("data-hcms-color-path",r),e.classList.toggle("hcms-color--inline",c);let m=e.querySelector(".hcms-color-grid");if(m){m.classList.toggle("hcms-color-grid--full",l);for(let f of s){let p=o.createElement("button");p.type="button",p.className="hcms-color-swatch",p.setAttribute("data-hcms-action","color-pick"),p.setAttribute("data-hcms-color",f.value),p.setAttribute("aria-label",f.label),p.setAttribute("title",f.id||f.label),p.setAttribute("style",`--hcms-swatch: ${f.value}`),m.appendChild(p)}}i||e.querySelector(".hcms-color-custom")?.remove();let u=e.querySelector(".hcms-color-current");c&&u&&(u.removeAttribute("data-hcms-action"),u.removeAttribute("aria-expanded")),Pl(e,c||Ll(o).has(r)),Vu(e,a)}function Vu(e,t){let n=t==null?"":String(t).trim();e.toggleAttribute("data-hcms-color-empty",n==="");let r=e.querySelector(".hcms-color-chip");r&&(n?r.setAttribute("style",`--hcms-swatch: ${n}`):r.removeAttribute("style"));let o=e.querySelector(".hcms-color-name");o&&(o.textContent=n?Hu(n):"Not set"),e.querySelectorAll(".hcms-color-swatch").forEach(l=>{l.setAttribute("aria-pressed",String(l.getAttribute("data-hcms-color")===n))});let s=e.querySelector('[data-hcms-color-input="text"]');s&&s.ownerDocument?.activeElement!==s&&(s.value=n);let i=e.querySelector('[data-hcms-color-input="native"]');i&&/^#[0-9a-f]{6}$/i.test(n)&&(i.value=n.toLowerCase())}function Pl(e,t){let n=e.querySelector(".hcms-color-panel");n&&(n.hidden=!t);let r=e.querySelector(".hcms-color-current[data-hcms-action]");r&&r.setAttribute("aria-expanded",String(t))}function Js(e){return e?.closest?e.closest("[data-hcms-color-path]"):null}function $p(e){return e.querySelector('input[type="hidden"][data-hcms-field]')}function Wu(e,t){let n=e.querySelector(":scope > .hcms-error");n&&(n.textContent=t||"",n.hidden=!t)}function jl(e,t){let n=$p(e);return!n||(Wu(e,null),Vu(e,t),n.value===t)?null:(n.value=t,n)}function Ku(e){let t=Js(e);return t?(t.classList.contains("hcms-color--inline")||(Ll(t.ownerDocument).delete(t.getAttribute("data-hcms-color-path")),Pl(t,!1)),jl(t,e.getAttribute("data-hcms-color")||"")):null}function Gu(e){let t=Js(e);return t?jl(t,""):null}function Yu(e){let t=Js(e);if(!t)return;let n=t.getAttribute("data-hcms-color-path"),r=Ll(t.ownerDocument),o=!r.has(n);o?r.add(n):r.delete(n),Pl(t,o)}function Xu(e){let t=Js(e);if(!t)return null;let n=String(e.value||"").trim();return n!==""&&!$u(n,t.ownerDocument)?(Wu(t,`"${n}" is not a CSS color`),null):jl(t,n)}var Dl=["sans","serif","display","mono"],Xt="ui-sans-serif, system-ui, sans-serif",jn="ui-serif, Georgia, serif",uo="ui-monospace, SFMono-Regular, Menlo, monospace",Kn=Object.freeze([{slug:"inter",family:"Inter",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"roboto",family:"Roboto",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"open-sans",family:"Open Sans",group:"sans",fallback:Xt,request:"ital,wght@0,300..800;1,300..800"},{slug:"lato",family:"Lato",group:"sans",fallback:Xt,request:"ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900"},{slug:"montserrat",family:"Montserrat",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"poppins",family:"Poppins",group:"sans",fallback:Xt,request:"ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900"},{slug:"nunito",family:"Nunito",group:"sans",fallback:Xt,request:"ital,wght@0,200..1000;1,200..1000"},{slug:"raleway",family:"Raleway",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"dm-sans",family:"DM Sans",group:"sans",fallback:Xt,request:"ital,wght@0,100..1000;1,100..1000"},{slug:"work-sans",family:"Work Sans",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"source-sans-3",family:"Source Sans 3",group:"sans",fallback:Xt,request:"ital,wght@0,200..900;1,200..900"},{slug:"noto-sans",family:"Noto Sans",group:"sans",fallback:Xt,request:"ital,wght@0,100..900;1,100..900"},{slug:"plus-jakarta-sans",family:"Plus Jakarta Sans",group:"sans",fallback:Xt,request:"ital,wght@0,200..800;1,200..800"},{slug:"manrope",family:"Manrope",group:"sans",fallback:Xt,request:"wght@200..800"},{slug:"outfit",family:"Outfit",group:"sans",fallback:Xt,request:"wght@100..900"},{slug:"space-grotesk",family:"Space Grotesk",group:"sans",fallback:Xt,request:"wght@300..700"},{slug:"rubik",family:"Rubik",group:"sans",fallback:Xt,request:"ital,wght@0,300..900;1,300..900"},{slug:"ubuntu",family:"Ubuntu",group:"sans",fallback:Xt,request:"ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700"},{slug:"merriweather",family:"Merriweather",group:"serif",fallback:jn,request:"ital,wght@0,300..900;1,300..900"},{slug:"lora",family:"Lora",group:"serif",fallback:jn,request:"ital,wght@0,400..700;1,400..700"},{slug:"playfair-display",family:"Playfair Display",group:"serif",fallback:jn,request:"ital,wght@0,400..900;1,400..900"},{slug:"libre-baskerville",family:"Libre Baskerville",group:"serif",fallback:jn,request:"ital,wght@0,400..700;1,400..700"},{slug:"source-serif-4",family:"Source Serif 4",group:"serif",fallback:jn,request:"ital,wght@0,200..900;1,200..900"},{slug:"pt-serif",family:"PT Serif",group:"serif",fallback:jn,request:"ital,wght@0,400;0,700;1,400;1,700"},{slug:"noto-serif",family:"Noto Serif",group:"serif",fallback:jn,request:"ital,wght@0,100..900;1,100..900"},{slug:"crimson-pro",family:"Crimson Pro",group:"serif",fallback:jn,request:"ital,wght@0,200..900;1,200..900"},{slug:"eb-garamond",family:"EB Garamond",group:"serif",fallback:jn,request:"ital,wght@0,400..800;1,400..800"},{slug:"cormorant-garamond",family:"Cormorant Garamond",group:"serif",fallback:jn,request:"ital,wght@0,300..700;1,300..700"},{slug:"bebas-neue",family:"Bebas Neue",group:"display",fallback:Xt,request:"wght@400"},{slug:"oswald",family:"Oswald",group:"display",fallback:Xt,request:"wght@200..700"},{slug:"anton",family:"Anton",group:"display",fallback:Xt,request:"wght@400"},{slug:"abril-fatface",family:"Abril Fatface",group:"display",fallback:jn,request:"wght@400"},{slug:"lobster",family:"Lobster",group:"display",fallback:"cursive",request:"wght@400"},{slug:"bungee",family:"Bungee",group:"display",fallback:Xt,request:"wght@400"},{slug:"roboto-mono",family:"Roboto Mono",group:"mono",fallback:uo,request:"ital,wght@0,100..700;1,100..700"},{slug:"jetbrains-mono",family:"JetBrains Mono",group:"mono",fallback:uo,request:"ital,wght@0,100..800;1,100..800"},{slug:"fira-code",family:"Fira Code",group:"mono",fallback:uo,request:"wght@300..700"},{slug:"source-code-pro",family:"Source Code Pro",group:"mono",fallback:uo,request:"ital,wght@0,200..900;1,200..900"},{slug:"ibm-plex-mono",family:"IBM Plex Mono",group:"mono",fallback:uo,request:"ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700"},{slug:"space-mono",family:"Space Mono",group:"mono",fallback:uo,request:"ital,wght@0,400;0,700;1,400;1,700"}]),fo=Object.freeze({slug:"system",family:null,group:"sans",fallback:"system-ui, sans-serif"}),Up=new Map(Kn.map(e=>[e.family.toLowerCase(),e])),Wx=new Map(Kn.map(e=>[e.slug,e]));function ns(e){return!e||e.slug==="system"?fo.fallback:`'${e.family}', ${e.fallback}`}function Ju(e){return e==null?null:String(e).split(",")[0].trim().replace(/^['"]|['"]$/g,"")||null}function ql(e){let t=new Map;if(!e)return t;let n=String(e).split("?")[1]||"";for(let r of n.split("&")){if(!r.startsWith("family="))continue;let o=decodeURIComponent(r.slice(7).split(":")[0].replace(/\+/g," ")).trim();o&&t.set(o.toLowerCase(),r)}return t}function Zu(e,t){let n=ql(e),r=ql(t);return n.size===r.size&&[...n.keys()].every(o=>r.has(o))}function Fl(e){let t=Ju(e);return t&&Up.get(t.toLowerCase())||null}function Zs(e,t=null){let n=ql(t),r=new Map;for(let s of e||[]){let i=Fl(s);if(i){r.set(i.family.toLowerCase(),`family=${i.family.replace(/ /g,"+")}:${i.request}`);continue}let l=Ju(s),a=l&&n.get(l.toLowerCase());a&&r.set(l.toLowerCase(),a)}return r.size===0?null:`https://fonts.googleapis.com/css2?${[...r.entries()].sort(([s],[i])=>s.localeCompare(i)).map(([,s])=>s).join("&")}&display=swap`}var Hp={sans:"Sans",serif:"Serif",display:"Display",mono:"Mono"},zp="link[data-hcms-font-preview]",Qu=new WeakMap;function $l(e){let t=Qu.get(e);return t||Qu.set(e,t=new Set),t}function Vp(e){return String(e??"").trim()===fo.fallback}function ef(e){let t=String(e??"").trim();if(!t)return"Not set";if(Vp(t))return"System";let n=Fl(t);return n?n.family:"Current font"}function Wp(e){if(!e||e.length===0)return{system:!0,fonts:[...Kn]};let t=!1,n=new Set;for(let r of e)r==="system"?t=!0:Dl.includes(r)?Kn.filter(o=>o.group===r).forEach(o=>n.add(o)):Kn.some(o=>o.slug===r)?n.add(Kn.find(o=>o.slug===r)):console.warn(`[hypercms] font option "${r}" is not a catalog font, a group or "system"; ignoring it`);return{system:t,fonts:Kn.filter(r=>n.has(r))}}function Bl(e,{value:t,label:n,family:r}){let o=e.createElement("button");return o.type="button",o.className="hcms-font-option",o.setAttribute("role","option"),o.setAttribute("data-hcms-action","font-pick"),o.setAttribute("data-hcms-font",t),o.setAttribute("style",`font-family: ${r}`),o.textContent=n,o}function tf(e,{value:t,tokens:n,path:r,doc:o}){let{system:s,fonts:i}=Wp(n),l=t==null?"":String(t).trim();e.setAttribute("data-hcms-font-path",r);let a=e.querySelector(".hcms-font-list");if(a){let c=new Set([...s?[fo.fallback]:[],...i.map(ns)]);l&&!c.has(l)&&a.appendChild(Bl(o,{value:l,label:ef(l),family:l})),s&&a.appendChild(Bl(o,{value:fo.fallback,label:"System",family:fo.fallback}));for(let m of Dl){let u=i.filter(p=>p.group===m);if(!u.length)continue;let f=o.createElement("div");f.className="hcms-font-group",f.textContent=Hp[m],a.appendChild(f);for(let p of u)a.appendChild(Bl(o,{value:ns(p),label:p.family,family:ns(p)}))}}Ul(e,$l(o).has(r)),nf(e,l)}function nf(e,t){let n=t==null?"":String(t).trim(),r=e.querySelector(".hcms-font-name");r&&(r.textContent=ef(n),n?r.setAttribute("style",`font-family: ${n}`):r.removeAttribute("style")),e.querySelectorAll(".hcms-font-option").forEach(o=>{o.setAttribute("aria-selected",String(o.getAttribute("data-hcms-font")===n))})}function Ul(e,t){let n=e.querySelector(".hcms-font-panel");n&&(n.hidden=!t),e.querySelector(".hcms-font-current")?.setAttribute("aria-expanded",String(t)),t&&Kp(e.ownerDocument)}function Kp(e){let t=e?.head;if(!t||t.querySelector(zp))return;let n=Zs(Kn.map(ns)),r=[...new Set(Kn.map(s=>s.family).join(""))].join(""),o=e.createElement("link");o.rel="stylesheet",o.href=`${n}&text=${encodeURIComponent(r)}`,o.setAttribute("data-hcms-font-preview","");for(let s of["editor-ui","no-save","save-remove","snapshot-remove"])o.setAttribute(s,"");t.appendChild(o)}function rf(e){return e?.closest?e.closest("[data-hcms-font-path]"):null}function of(e){let t=rf(e);if(!t)return;let n=t.getAttribute("data-hcms-font-path"),r=$l(t.ownerDocument),o=!r.has(n);o?r.add(n):r.delete(n),Ul(t,o)}function sf(e){let t=rf(e);if(!t)return null;let n=t.querySelector('input[type="hidden"][data-hcms-field]');if(!n)return null;$l(t.ownerDocument).delete(t.getAttribute("data-hcms-font-path")),Ul(t,!1);let r=e.getAttribute("data-hcms-font")||"";return nf(t,r),n.value===r?null:(n.value=r,n)}var Cn=e=>`<svg viewBox="0 0 32 20" width="32" height="20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true">${e}</svg>`,on=(e,t,n,r,o="")=>`<rect x="${e}" y="${t}" width="${n}" height="${r}" rx="1"${o}/>`,hn=(e,t,n)=>`<path d="M${e} ${t}H${n}"/>`,Hl=' fill="currentColor" fill-opacity="0.3"',lf=Object.freeze({"cols-1":{label:"One column",svg:Cn(on(2,2,28,16))},"cols-2":{label:"Two columns",svg:Cn(on(2,2,13,16)+on(17,2,13,16))},"cols-3":{label:"Three columns",svg:Cn(on(2,2,8,16)+on(12,2,8,16)+on(22,2,8,16))},"cols-4":{label:"Four columns",svg:Cn(on(2,2,5.5,16)+on(9.5,2,5.5,16)+on(17,2,5.5,16)+on(24.5,2,5.5,16))},"media-left":{label:"Image left",svg:Cn(on(2,3,12,14,Hl)+hn(18,6,30)+hn(18,10,30)+hn(18,14,26))},"media-right":{label:"Image right",svg:Cn(on(18,3,12,14,Hl)+hn(2,6,14)+hn(2,10,14)+hn(2,14,10))},"media-top":{label:"Image on top",svg:Cn(on(2,2,28,8,Hl)+hn(2,14,30)+hn(2,17,22))},list:{label:"List",svg:Cn(hn(3,5,4)+hn(8,5,29)+hn(3,10,4)+hn(8,10,29)+hn(3,15,4)+hn(8,15,29))},cards:{label:"Cards",svg:Cn(on(2,2,13,7)+on(17,2,13,7)+on(2,11,13,7)+on(17,11,13,7))},centered:{label:"Centered",svg:Cn(hn(6,5,26)+hn(9,10,23)+hn(11,15,21))},"card-flat":{label:"Flat",svg:Cn(on(5,3,22,14))},"card-raised":{label:"Raised",svg:Cn(on(7,5,22,14,' stroke-opacity="0.35"')+on(4,2,22,14,' fill="var(--mirk-bg, transparent)"'))}});function Gp(e){return(e||[]).map(t=>{let n=t.indexOf(":"),r=n===-1?t:t.slice(0,n),o=n===-1?t:t.slice(n+1),s=lf[o]||null;return{value:r,icon:s,label:s?s.label:Mr(r)}})}function af(e,{tokens:t,value:n,name:r,doc:o}){let s=Gp(t),i=n==null?"":String(n);i!==""&&!s.some(a=>a.value===i)&&s.unshift({value:i,icon:null,label:Mr(i)});let l=e.querySelector(".hcms-variant-option");if(!l||!l.parentNode)return s.length;for(let a of s){let c=l.cloneNode(!0),m=c.querySelector('input[type="radio"]');m&&(m.value=a.value,m.name=r);let u=c.querySelector(".hcms-variant-icon");u&&(a.icon?u.innerHTML=a.icon.svg:u.remove());let f=c.querySelector(".hcms-variant-label");f&&(f.textContent=a.label),c.setAttribute("title",a.label),l.parentNode.insertBefore(c,l)}return l.remove(),s.length}function zl(e){if(!e)return"";let t=String(e).split(/[?#]/)[0],n=t.split("/").pop()||t;try{return decodeURIComponent(n)}catch{return n}}function ho({pageRules:e,formRules:t,data:n,doc:r}){let o=r.createDocumentFragment(),s=Yp(e,n,r);s&&o.appendChild(s);let i=Qs(e,[],n,r,e);return i&&o.appendChild(i),o}function Yp(e,t,n){let r=[];if(a(e,t,[]),!r.length)return null;let o=Nn(n,"@object");if(!o)return null;let s=Lr(o,n);s.setAttribute("data-hcms-page-style","");let i=s.querySelector("[data-hcms-label]");i&&(i.textContent="Page style");let l=s.querySelector(".hcms-object-fields")||s;for(let[c,m,u]of r){let f=Qs(c,m,u,n,e);f&&l.appendChild(f)}return s;function a(c,m,u){if(typeof c=="string"){u.length&&es(c,n,u,e)==="page"&&r.push([c,u,m]);return}if(!(!c||typeof c!="object"||Array.isArray(c))){if(u.length){let f=Rr(u,"@object",n);if(f&&ao(f))return}for(let[f,p]of Object.entries(c))a(p,m==null?null:m[f],[...u,f])}}}function uf(e,t,n,r){let o=[],s=[];for(let[i,l]of Object.entries(e)){let a=es(l,n,[...t,i],r);a!=="page"&&(a?o:s).push([i,l])}return[...o,...s]}function ff({shape:e,itemShape:t,pathArr:n,data:r,doc:o,itemKey:s,pageRules:i}){if(e==="object-array-item")return mf(t,n,r,o,i);if(e==="scalar-array-item")return pf(n,r,o,s||null);throw new Error(`hypercms: buildItem called with unknown shape "${e}"`)}function Qs(e,t,n,r,o){let s=mr(e);return s==="scalar"?Xp(e,t,n,r,o):s==="object"?Qp(e,t,n,r,o):s==="object-array"?eg(e,t,n,r,o):s==="scalar-array"?tg(e,t,n,r):null}function Xp(e,t,n,r,o){let s=hr(e,r,t,o),i=Rr(t,s,r);if(!i)throw new Error(`hypercms: missing template for scalar at "${t.join(".")}"`);let l=Nu(e,r,t,o);l==="@number"&&s==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "@number" but its value isn't a plain number; rendering a text input so the value is preserved`),(l==="@checkbox"||l==="@toggle")&&s==="@scalar"&&console.info(`[hypercms] field "${t.join(".")}" declares component "${l}" but its value isn't true/false; rendering a text input so the value is preserved`),df(i,l===s?l:null,t);let a=Lr(i,r);mo(a,t);let c=i.getAttribute?.("data-hcms-tpl");if((s==="@select"||s==="@radio")&&c===s&&Jp(a,e,t,n,r,s,o),s==="@variant"&&c==="@variant"){let m=ts(e,r,t,o);m||hf(a,"data-hcms-options required (value:icon tokens)"),af(a,{tokens:m,value:n,name:ei(t.join(".")),doc:r})===0&&a.querySelector(".hcms-variant-option")?.remove()}if(s==="@image"&&c==="@image"){let m=Cu(e,r,t,o);m!=null&&!a.hasAttribute("data-hcms-crop")&&a.setAttribute("data-hcms-crop",m)}return ng(a,tr(t)),ti(a,tr(t)),ni(a,tr(t)),vf(a,n),s==="@color"&&c==="@color"&&zu(a,{value:n,tokens:ts(e,r,t,o),path:t.join("."),doc:r}),s==="@font"&&c==="@font"&&tf(a,{value:n,tokens:ts(e,r,t,o),path:t.join("."),doc:r}),s==="@file"&&Zp(a),a}function df(e,t,n){if(!t)return;let r=e.getAttribute?.("data-hcms-tpl");r&&r!==t&&console.info(`[hypercms] field "${n.join(".")}" declares component "${t}" but custom template "${r}" wins`)}function Jp(e,t,n,r,o,s,i){let l=ts(t,o,n,i),a=l?[...l]:[],c=r==null?"":String(r);if(c!==""&&!a.includes(c)&&a.unshift(c),!l&&(hf(e,"data-hcms-options required (space-separated values)"),a.length===0)){e.querySelector(".mirk-radio")?.remove();return}if(s==="@select"){let f=e.querySelector("select[data-hcms-field]");if(!f)return;for(let p of a){let h=o.createElement("option");h.value=p,h.textContent=Mr(p),f.appendChild(h)}return}let m=e.querySelector(".mirk-radio");if(!m||!m.parentNode)return;let u=ei(n.join("."));for(let f of a){let p=m.cloneNode(!0),h=p.querySelector('input[type="radio"]');h&&(h.value=f,h.name=u);let v=p.querySelector(".mirk-radio__label");v&&(v.textContent=Mr(f)),m.parentNode.insertBefore(p,m)}m.remove()}function ei(e){return"hcms-"+String(e).replace(/[^A-Za-z0-9_-]/g,"-")}function hf(e,t){let n=e.querySelector?e.querySelector(".hcms-error"):null;n&&(n.textContent=t,n.hidden=!1)}function Zp(e){let t=e.querySelector?e.querySelector("a.mirk-file__name[data-hcms-field]"):null;t&&(t.textContent=zl(t.getAttribute("href")))}function Qp(e,t,n,r,o){let s=Rr(t,"@object",r);if(!s)throw new Error(`hypercms: missing template for object at "${t.join(".")}"`);let i=Lr(s,r);if(mo(i,t),ti(i,tr(t)),ni(i,tr(t)),ao(s))return wf(i,e,t),xf(i,e,n),i;let l=ri(i,".hcms-object-fields",s,t);for(let[a,c]of uf(e,t,r,o)){let m=n==null?null:n[a],u=Qs(c,[...t,a],m,r,o);u&&l.appendChild(u)}return t.length&&!l.children.length&&Object.keys(e).length?null:i}function eg(e,t,n,r,o){let s=Rr(t,"@object-array",r);if(!s)throw new Error(`hypercms: missing template for object-array at "${t.join(".")}"`);let i=Lr(s,r);mo(i,t),ti(i,tr(t)),ni(i,tr(t)),bf(i,s),yf(i,s,t);let l=ri(i,".hcms-array-items",s,t),[,a]=e;return(Array.isArray(n)?n:[]).forEach((m,u)=>{let f=mf(a,[...t,u],m,r,o);f&&l.appendChild(f)}),kf(i),i}function mf(e,t,n,r,o){let s=gf(t,"object-array-item",r);if(!s)throw new Error(`hypercms: missing item template for "${t.join(".")}"`);let i=Lr(s,r);if(i.setAttribute("data-hcms-card",""),i.classList.contains("hcms-card")||i.classList.add("hcms-card"),mo(i,t),ao(s))return e&&typeof e=="object"&&!Array.isArray(e)&&(wf(i,e,t),xf(i,e,n)),i;let l=ri(i,".hcms-card-fields",s,t);if(e&&typeof e=="object"&&!Array.isArray(e))for(let[a,c]of uf(e,t,r,o)){let m=n==null?null:n[a],u=Qs(c,[...t,a],m,r,o);u&&l.appendChild(u)}return i}function tg(e,t,n,r){let o=Hs(e,r),s=zs(e,t,r),i=o?o.array:"@scalar-array",l=Rr(t,i,r);if(!l)throw new Error(`hypercms: missing template for scalar-array at "${t.join(".")}"`);df(l,o?o.array:null,t);let a=Lr(l,r);mo(a,t),ti(a,tr(t)),ni(a,tr(t)),bf(a,l),yf(a,l,t),s&&a.setAttribute("data-hcms-item-tpl",s.item);let c=ri(a,".hcms-array-items",l,t);return(Array.isArray(n)?n:[]).forEach((u,f)=>{let p=pf([...t,f],u,r,s?s.item:null);p&&c.appendChild(p)}),kf(a),a}function pf(e,t,n,r){let o=gf(e,"scalar-array-item",n,r);if(!o)throw new Error(`hypercms: missing item template for "${e.join(".")}"`);let s=Lr(o,n);return s.setAttribute("data-hcms-array-item",""),s.classList.contains("hcms-array-item")||s.classList.add("hcms-array-item"),mo(s,e),vf(s,t),s}function gf(e,t,n,r){let o=e.map(s=>typeof s=="number"?"*":s).join(".");return Nn(n,o)||r&&Nn(n,r)||Nn(n,"@"+t)}function Lr(e,t){let n=e.content||e,r=t.createElement("div");return r.appendChild(n.cloneNode(!0)),r.firstElementChild||r}function mo(e,t){e.setAttribute("data-hcms-path",t.join(".")),e.setAttribute("data-hcms-path-shape",Ks(t))}function ng(e,t){let n=t==null?"":String(t);if(e.matches&&e.matches("[data-hcms-field]")){e.getAttribute("data-hcms-field")||e.setAttribute("data-hcms-field",n);return}(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(o=>{o.getAttribute("data-hcms-field")||o.setAttribute("data-hcms-field",n)})}function ti(e,t){t==null||t===""||!e.setAttribute||e.hasAttribute?.("data-hcms-field")||e.setAttribute("data-hcms-field",String(t))}function ni(e,t){if(t==null||t==="")return;(e.querySelectorAll?e.querySelectorAll("[data-hcms-label]"):[]).forEach(r=>{(r.textContent||"").trim()===""&&(r.textContent=Mr(String(t)))})}function bf(e,t){["data-hcms-no-add","data-hcms-no-remove","data-hcms-no-reorder"].forEach(n=>{t.hasAttribute(n)&&e.setAttribute(n,"")}),["data-hcms-min-items","data-hcms-max-items"].forEach(n=>{t.hasAttribute(n)&&e.setAttribute(n,t.getAttribute(n))})}function kf(e){let t=e.querySelector?e.querySelector(".hcms-array-items"):null;if(!t)return;let n=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),r=n.length,o=cf(e,"data-hcms-max-items"),s=cf(e,"data-hcms-min-items"),i=e.hasAttribute("data-hcms-no-add"),l=e.hasAttribute("data-hcms-no-remove"),a=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector('[data-hcms-action="add"]');c&&(c.hidden=i||o!=null&&r>=o),n.forEach((m,u)=>{let f=m.querySelector('[data-hcms-action="remove"]');f&&(f.hidden=l||s!=null&&r<=s);let p=m.querySelector('[data-hcms-action="move-up"]');p&&(p.hidden=a||u===0);let h=m.querySelector('[data-hcms-action="move-down"]');h&&(h.hidden=a||u===r-1)})}function cf(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function yf(e,t,n){if(e.hasAttribute("data-hcms-no-reorder")||t.hasAttribute("data-hcms-no-reorder"))return;let r=e.querySelector(".hcms-array-items");if(!r)return;let o="hcms-"+n.join(".");r.setAttribute("sortable",o),r.setAttribute("onsorted","hypercmsCommit && hypercmsCommit()")}function tr(e){return e.length?e[e.length-1]:null}function vf(e,t){let n=rg(e);if(n.length!==0)for(let r of n)Sf(r,t)}function rg(e){if(!e)return[];let t=[];return e.matches?.("[data-hcms-field]")&&og(e)&&t.push(e),(e.querySelectorAll?e.querySelectorAll("input[data-hcms-field], textarea[data-hcms-field], select[data-hcms-field], img[data-hcms-field], a[data-hcms-field], [contenteditable][data-hcms-field]"):[]).forEach(r=>t.push(r)),t}function og(e){let t=(e.tagName||"").toUpperCase();return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="IMG"||t==="A"||e.hasAttribute?.("contenteditable"))}function xf(e,t,n){(e.querySelectorAll?e.querySelectorAll("[data-hcms-field]"):[]).forEach(o=>{let s=o.getAttribute("data-hcms-field");if(!s)return;if(!t||typeof t!="object"||!(s in t)){console.warn(`[hypercms] inline template field "${s}" is not in the rule shape; ignoring`);return}let i=n==null?null:n[s];Sf(o,i)})}function wf(e,t,n){if(!e.querySelectorAll)return;e.querySelectorAll("[data-hcms-field]").forEach(o=>{let s=o.getAttribute("data-hcms-field");if(!s||t&&typeof t=="object"&&!(s in t))return;let i=[...n,s].join(".");o.setAttribute("data-hcms-path",i),o.setAttribute("data-hcms-path-shape",Ks([...n,s]))})}function ri(e,t,n,r){if(!e.querySelector)return e;let o=e.querySelector(t);if(o)return o;let s=n?.getAttribute?.("data-hcms-tpl")||r.join(".");throw new Error(`hypercms: template "${s}" is in slotted mode but has no ${t} element`)}function Sf(e,t){let n=Gs(e),r=(e.tagName||"").toUpperCase(),o=(e.getAttribute("type")||"").toLowerCase();if(r==="INPUT"&&o==="radio"){e.checked=e.value!=null&&String(e.value)===String(t??"");return}if(n==="checked"){e.checked=t===!0||t==="true";return}if(n){e[n]=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}var sg={Mutation:(e,t)=>e?.Mutation??t?.Mutation,undo:(e,t)=>e?.undo??t?.undo,onPrepareForSave:(e,t)=>e?.addDocumentTransform??t?.onPrepareForSave,onSnapshot:(e,t)=>e?.onSnapshot??t?.onSnapshot,consent:(e,t)=>e?.confirm??t?.consent,RichClay:(e,t)=>e?.RichClay??t?.RichClay,quickcrop:(e,t)=>e?.quickcrop??t?.quickcrop,upload:(e,t)=>e?.upload??(t?.uploadFileBasic?lg(t.uploadFileBasic):null)},ig={402:"payment-required",413:"too-large",415:"unsupported-type",401:"unauthorized",403:"forbidden",404:"not-found"},Vl=()=>({ok:!1,msg:"Upload cancelled",msgType:"skipped",code:"aborted",uploads:[]});function lg(e){return async function(n,{onProgress:r,signal:o}={}){if(o?.aborted)return Vl();try{let s=await e(n,{onProgress:l=>{r?.({loaded:null,total:null,percent:l})}});if(o?.aborted)return Vl();let i=s&&s.uploads||[];return typeof i[0]?.url!="string"?{ok:!1,msg:"The host accepted the file but did not say where it put it",msgType:"error",code:"bad-response",uploads:[]}:{ok:!0,msg:s.msg||"Uploaded",msgType:s.msgType||"success",code:s.code||null,uploads:i}}catch(s){if(o?.aborted)return Vl();let i={};try{i=JSON.parse(s?.response||"{}")}catch{i={}}let l=i.code||ig[s?.status]||"error";return{ok:!1,msg:s&&s.message||"Upload failed",msgType:"error",code:l,uploads:[]}}}}function sn(e,t){let n=sg[e];if(!n)throw new Error(`hypercms: unknown platform capability "${e}"`);let r=t||(typeof window<"u"?window:null);return r&&n(r.clay,r.hyperclay)||null}var Af=["clay:mutation-ready","hyperclay:mutation-ready"],Tf=["clay:sync-applied","hyperclay:livesync-applied"],Ef=["clay:ready","hyperclay:ready"];function po(e,t,n){let r=null,o=s=>{r!==null&&r!==s.type||(r=s.type,queueMicrotask(()=>{r=null}),n(s))};for(let s of t)e.addEventListener(s,o);return()=>{for(let s of t)e.removeEventListener(s,o)}}var qn="data-hcms-bound",pr="data-hcms-bound-id",Wl=new Map;function Of(e,t){Wl.set(e,t)}function Nf(e){Wl.delete(e)}function Cf(e){let t=e.getAttribute(pr);if(!t)return null;let n=Wl.get(t);return!n||!n.restorable()?null:n.originalHTML}var Pr="data-hcms-owns-richclay";function go(e){return e&&e.richclay&&e.richclay.RichClay||sn("RichClay",e)||(e&&typeof e.RichClay=="function"?e.RichClay:null)}function _f(e,t,n){!e||typeof e.setAttribute!="function"||(e.setAttribute(qn,t?"rich":"plain"),n&&e.setAttribute(Pr,"true"))}function Mf(e,t){if(!e||typeof e.querySelectorAll!="function")return;let n=e.querySelectorAll(`[${qn}]`);if(!n.length)return;let r=go(t);if(r&&typeof r.stripFromClone=="function")try{r.stripFromClone(e)}catch(o){console.warn("[hypercms] richclay strip failed; editor state may reach the save",o)}for(let o of n)o.getAttribute(Pr)==="true"&&o.removeAttribute("data-richclay"),o.removeAttribute(Pr),o.removeAttribute(qn)}function Rf(e,t){if(!e||typeof e.removeAttribute!="function")return;let n=go(t);if(n&&typeof n.stripElement=="function")try{n.stripElement(e)}catch(r){console.warn("[hypercms] richclay element strip failed; the clone stays editable",r)}else e.removeAttribute("contenteditable"),e.removeAttribute("no-undo");e.getAttribute(Pr)==="true"&&e.removeAttribute("data-richclay"),e.removeAttribute(Pr),e.removeAttribute(qn),e.removeAttribute(pr)}function If(e,t){if(!t||e==null)return e;return n(e);function n(r){if(typeof r=="string"){if(r.endsWith("[]")||Kt(r)!==-1)return r;let o=null;try{o=t.querySelector(r)}catch{return r}return o&&o.children.length>0?r+"@innerHTML":r}if(Array.isArray(r))return r;if(r&&typeof r=="object"){let o=Object.create(null);for(let[s,i]of Object.entries(r))o[s]=n(i);return o}return r}}function Lf(e,t){if(!t||e==null)return e;return n(e,[t]);function n(r,o){if(typeof r=="string")return r.endsWith("[]")||Kt(r)!==-1?r:o.some(s=>ag(s,r))?r+"@innerHTML":r;if(Array.isArray(r)){let[s,i]=r;if(typeof s!="string"||!s)return r;let l=cg(t,s);return l.length?[s,n(i,l)]:r}if(r&&typeof r=="object"){let s=Object.create(null);for(let[i,l]of Object.entries(r))s[i]=n(l,o);return s}return r}}function ag(e,t){let n=null;try{n=e.querySelector(t)}catch{return!1}return n?n.hasAttribute(qn)?n.getAttribute(qn)==="rich":n.children.length>0:!1}function cg(e,t){try{return[...e.querySelectorAll(t)]}catch{return[]}}function bo(e){if(!e||e.tagName!=="TEXTAREA")return;let t=e.ownerDocument.defaultView||(typeof window<"u"?window:null);t&&t.CSS&&t.CSS.supports&&t.CSS.supports("field-sizing: content")||(e.style.height="auto",e.style.height=e.scrollHeight+"px")}function gr(e,t,n=!0){if(!e||!e.querySelectorAll||(e.querySelectorAll("textarea[data-hcms-field]").forEach(bo),n===!1))return;let r=t&&t.defaultView||(typeof window<"u"?window:null),o=go(r);o&&e.querySelectorAll("[contenteditable][data-hcms-field]").forEach(s=>{if(s.__hcmsRichclay)return;let i;try{i=new o(s,{inline:!0,hyperclay:!1,toolbar:["bold","italic","link","undo","redo"]})}catch(a){console.warn("[hypercms] richclay activation failed; field stays plain contenteditable",a);return}s.__hcmsRichclay=i;let l=i&&i.squire;l&&typeof l.addEventListener=="function"&&l.addEventListener("input",()=>{let a=r&&r.Event||Event;s.dispatchEvent(new a("input",{bubbles:!0}))})})}var Pf="link[data-hcms-fonts]",ug="link[data-hcms-fonts-preconnect]";function fg(e,t,n){let r=[],o=!1;return s(e,t,[]),{stacks:r,found:o};function s(i,l,a){if(typeof i=="string"){if(i.endsWith("[]")||hr(i,n,a,e)!=="@font")return;o=!0,l!=null&&l!==""&&r.push(String(l));return}if(Array.isArray(i)){let c=Array.isArray(l)?l:[];c.forEach(m=>s(i[1],m,[...a,"*"])),c.length||s(i[1],void 0,[...a,"*"]);return}if(i&&typeof i=="object")for(let[c,m]of Object.entries(i))s(m,l?.[c],[...a,c])}}function dg(e,t){let n=e?.head;if(!n)return;let r=n.querySelector(Pf),o=n.querySelector(ug);if(!t){r?.remove(),o?.remove();return}o||(o=e.createElement("link"),o.setAttribute("rel","preconnect"),o.setAttribute("href","https://fonts.gstatic.com"),o.setAttribute("crossorigin",""),o.setAttribute("data-hcms-fonts-preconnect",""),o.setAttribute("no-undo",""),n.appendChild(o)),r||(r=e.createElement("link"),r.setAttribute("rel","stylesheet"),r.setAttribute("data-hcms-fonts",""),r.setAttribute("no-undo",""),o.after(r)),r.hasAttribute("no-undo")||r.setAttribute("no-undo",""),o.hasAttribute("no-undo")||o.setAttribute("no-undo",""),r.getAttribute("href")!==t&&r.setAttribute("href",t)}function ko(e,t){if(!e?.doc||e.pageRules==null)return;let{stacks:n,found:r}=fg(e.pageRules,t,e.doc);if(!r)return;let o=e.doc.head?.querySelector(Pf)?.getAttribute("href")||null,s=Zs(n,o);s&&o&&Zu(o,s)||dg(e.doc,s)}var Kl=new WeakSet;function jr(e,t){let n=sn("undo");if(!n)return t();n.pause();try{let r=t();return r&&r.ok?n.commitCaptured(e):n.discardCaptured(),r}finally{n.resume()}}function rr(e){let t=sn("undo");if(!t)return e();t.pause();try{return e()}finally{t.discardCaptured(),t.resume()}}function ii(e){let{formRoot:t}=e;if(!t||Kl.has(t))return;Kl.add(t);let n=i=>{let l=i.target;!l||!l.closest||l.closest("[data-hcms-form-root]")&&(l.matches("[data-hcms-color-input]")||l.matches("input, textarea, select, [contenteditable][data-hcms-field]")&&(l.tagName==="TEXTAREA"&&bo(l),!l.matches('input[type="file"]')&&(!l.closest("[data-hcms-field]")&&!l.hasAttribute?.("data-hcms-field")||rs(l,e))))},r=i=>{let l=i.target;if(!(!l||!l.closest)&&l.closest("[data-hcms-form-root]")){if(l.matches("[data-hcms-color-input]")){let a=Xu(l);a&&rs(a,e);return}if(l.matches('input[type="file"][data-hcms-upload]')){vg(l,e);return}l.matches('input[type="checkbox"], input[type="radio"], select')&&rs(l,e)}},o=i=>{let l=i.target;if(!l||!l.closest)return;let a=l.closest("[data-hcms-action]");if(!a)return;let c=a.getAttribute("data-hcms-action");if(c==="add"||c==="remove"||c==="move-up"||c==="move-down"||c==="clear-upload"||c==="color-pick"||c==="color-clear"||c==="color-panel"||c==="font-pick"||c==="font-panel"){if(!a.closest("[data-hcms-form-root]"))return}else if(c==="close"&&!a.closest("[data-hcms-shell]"))return;if(c==="add"){let m=a.closest("[data-hcms-path]");if(!m)return;let u=m.getAttribute("data-hcms-path");os(u,e)}else if(c==="remove"){let m=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!m)return;Xl(m,e)}else if(c==="move-up"||c==="move-down"){let m=a.closest("[data-hcms-card], [data-hcms-array-item]");if(!m)return;Yl(m,c==="move-up"?-1:1,e)}else if(c==="clear-upload")Ag(a,e);else if(c==="color-pick"||c==="color-clear"){let m=c==="color-pick"?Ku(a):Gu(a);m&&rs(m,e)}else if(c==="color-panel")Yu(a);else if(c==="font-pick"){let m=sf(a);m&&rs(m,e)}else c==="font-panel"?of(a):c==="close"&&e.onCloseRequested?.()},s=t.ownerDocument;s.addEventListener("input",n,!0),s.addEventListener("change",r,!0),s.addEventListener("click",o,!0),e.detachEvents=()=>{s.removeEventListener("input",n,!0),s.removeEventListener("change",r,!0),s.removeEventListener("click",o,!0),Kl.delete(t)}}var hg=new Set(["value","checked"]);function mg(e,t){if(!t)return null;let n=Qn(t);if(n.some(a=>typeof a=="number"||a==="*"))return null;let r=er(e.pageRules,n);if(typeof r!="string")return null;let o=fn.ruleAttrIndex(r);if(o===-1)return null;let s=r.slice(o+1);if(!hg.has(s))return null;let i=r.slice(0,o),l=i?e.pageRoot.querySelector(i):Pn(e.pageRoot);return l?{el:l,prop:s,oldValue:l[s]}:null}function rs(e,t){let r=(e.closest("[data-hcms-field]")||e).closest("[data-hcms-path]")?.getAttribute("data-hcms-path")||"",o=mg(t,r);if(Sn(bn(t),{path:r,structural:!1},t),o){let s=sn("undo");s&&typeof s.recordValue=="function"&&s.recordValue(o.el,{prop:o.prop,oldValue:o.oldValue,newValue:o.el[o.prop]})}}var pg={type:"image/webp",quality:.85,maxWidth:2048,maxHeight:2048};async function gg(e,t){let n=t&&t.getAttribute?t.getAttribute("data-hcms-crop"):null;if(n==null)return{file:e};let r=sn("quickcrop");if(typeof r!="function")return{file:e};try{let o=typeof window<"u"&&(window.clay?.modal??window.themodal)||"auto",s=await r(e,{aspect:bg(n),modal:o,...pg});return s===null?null:{file:kg(s.blob,e.name),dataURL:s.dataURL}}catch(o){return vo(t,o&&o.message||"Crop failed"),null}}function bg(e){let t=String(e??"").trim().toLowerCase();if(t===""||t==="free")return null;let n=t.match(/^(\d+(?:\.\d+)?)\s*[:/]\s*(\d+(?:\.\d+)?)$/);if(!n)return null;let r=parseFloat(n[1]),o=parseFloat(n[2]);return!r||!o?null:r/o}function kg(e,t){let n=e.type==="image/webp"?".webp":e.type==="image/jpeg"?".jpg":".png",r=String(t||"image").replace(/\.[^.]+$/,"");try{return new File([e],r+n,{type:e.type})}catch{return e}}var yg=new Set(["unsupported","payment-required"]);async function vg(e,t){let n=e.files&&e.files[0];if(!n)return;let r=e.closest("[data-hcms-path]");if(!r)return;let o=r.getAttribute("data-hcms-path")||"";vo(r,null);let s=await gg(n,r);if(!s||t.closed){br(e);return}let i=s.file,l=s.dataURL||null,a=sn("upload");if(typeof a!="function")return Gl(e,r,t,o,await jf(i,l,r),i);Bf(r,l),qf(r,0);let c=wg(t),m;try{m=await a(i,{signal:c?.signal,onProgress:({percent:f})=>qf(r,f)})}finally{Sg(t,c),Eg(r)}if(t.closed){br(e);return}if(m.code==="aborted"){br(e);return}if(m.ok)return Gl(e,r,t,o,m.uploads[0].url,i);if(!yg.has(m.code)){vo(r,m.msg||"Upload failed"),t.dispatch?.("hcms:error",{error:new Error(m.msg||"Upload failed"),code:m.code,path:o}),br(e);return}let u=m.code==="payment-required"?"This file is stored in the page. Add a paid plan to upload files.":null;return Gl(e,r,t,o,await jf(i,l,r),i,u)}function Gl(e,t,n,r,o,s,i=null){if(n.closed){br(e);return}if(Bf(t,null),vo(t,null),!o){br(e);return}Ff(t,o,s.name),Sn(bn(n),{path:r,structural:!1},n),i&&vo(t,i,"info"),br(e)}async function jf(e,t,n){return t||await xg(e,n)}function xg(e,t){let n=t?.ownerDocument?.defaultView?.FileReader||globalThis.FileReader;return n?new Promise(r=>{let o=new n;o.onload=()=>r(typeof o.result=="string"?o.result:""),o.onerror=()=>r("");try{o.readAsDataURL(e)}catch{r("")}}):Promise.resolve("")}function wg(e){if(typeof AbortController!="function")return null;let t=new AbortController;return(e.uploads||(e.uploads=new Set)).add(t),t}function Sg(e,t){t&&e.uploads?.delete(t)}function Ag(e,t){let n=e.closest("[data-hcms-path]");if(!n)return;let r=n.getAttribute("data-hcms-path")||"";Ff(n,"","");let o=n.querySelector('input[type="file"][data-hcms-upload]');o&&br(o),vo(n,null),Sn(bn(t),{path:r,structural:!1},t)}function Tg(e){return e.querySelector?e.querySelector("img[data-hcms-field], a[data-hcms-field]"):null}function Ff(e,t,n){let r=Tg(e);if(!r)return;let o=(r.tagName||"").toUpperCase();o==="IMG"?r.src=t||"":o==="A"&&(r.href=t||"",r.textContent=t?n||zl(t):"")}function br(e){try{e.value=""}catch{}}function Bf(e,t){let n=e.querySelector?e.querySelector(".mirk-image__frame"):null;n&&(t?n.style.backgroundImage=`url("${t.replace(/"/g,"%22")}")`:n.style.removeProperty("background-image"))}function qf(e,t){let n=Math.max(0,Math.min(100,Number(t)||0));e.setAttribute("data-hcms-uploading",""),e.style?.setProperty?.("--hcms-upload-progress",`${n}%`)}function Eg(e){e.removeAttribute("data-hcms-uploading"),e.style?.removeProperty?.("--hcms-upload-progress")}function vo(e,t,n="error"){let r=e.querySelector?e.querySelector(":scope > .hcms-error"):null;r&&(r.classList.toggle("hcms-error--info",!!t&&n==="info"),t?(r.textContent=t,r.hidden=!1):(r.textContent="",r.hidden=!0))}function os(e,t){let{formRoot:n,pageRules:r}=t,o=n.querySelector(`[data-hcms-path="${qr(e)}"]`);if(!o)throw new Error(`hypercms: no element at path "${e}"`);let s=o.querySelector(".hcms-array-items");if(!s)throw new Error(`hypercms: array container missing .hcms-array-items at "${e}"`);let i=Qn(e),l=Mg(r,i),a=Array.isArray(l),c=typeof l=="string"&&l.endsWith("[]");if(!a&&!c)throw new Error(`hypercms: path "${e}" is not an array`);let m=si(o,"data-hcms-max-items"),u=s.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]");if(o.hasAttribute("data-hcms-no-add")||m!=null&&u.length>=m)return;let f=u.length,p=a?l[1]:l.replace(/\[\]$/,""),h=Qo(a?p:"string"),v=ff({shape:a?"object-array-item":"scalar-array-item",itemShape:p,pathArr:[...i,f],data:h,doc:t.doc,itemKey:o.getAttribute("data-hcms-item-tpl")||null,pageRules:r});return s.appendChild(v),gr(v,t.doc,t.view?.enhanceFormRichText!==!1),Zl(o),jr(`Add ${e}`,()=>Sn(bn(t),{path:e,structural:!0},t))}function Yl(e,t,n){let r=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!r||r.hasAttribute("data-hcms-no-reorder"))return;let o=r.querySelector(".hcms-array-items");if(!o)return;let s=Array.from(o.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),i=s.indexOf(e);if(i<0)return;let l=i+t;if(l<0||l>=s.length)return;let a=e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`);return t<0?o.insertBefore(e,s[l]):o.insertBefore(e,s[l].nextSibling),Ql(o),Zl(r),a&&typeof a.focus=="function"&&e.querySelector(`[data-hcms-action="${t<0?"move-up":"move-down"}"]`)?.focus?.(),jr(`Reorder ${r.getAttribute("data-hcms-path")||""}`,()=>Sn(bn(n),{path:r.getAttribute("data-hcms-path")||"",structural:!0},n))}var oi="Delete this item?";function Og(e,t){let n=e&&e.getAttribute("data-hcms-confirm-remove");if(n!=null)return/^(off|false|no|0)$/i.test(n.trim())?null:n||oi;let r=t&&t.confirmRemove;return r===!1?null:typeof r=="string"?r||oi:r===!0||e&&e.getAttribute("data-hcms-shape")==="object-array"?oi:null}function Xl(e,t){let n=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]'),r=Og(n,t);if(r==null)return yo(e,t);let o=sn("consent")||typeof window<"u"&&window.consent;typeof o=="function"?Promise.resolve(o(r)).then(()=>{t.closed||yo(e,t)},()=>{}):typeof window<"u"&&typeof window.confirm=="function"?window.confirm(r)&&yo(e,t):yo(e,t)}function yo(e,t){let n=e.getAttribute("data-hcms-path")||"",r=e.parentElement,o=e.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]');if(!o?.hasAttribute("data-hcms-no-remove")){if(o){let s=si(o,"data-hcms-min-items"),i=o.querySelector(".hcms-array-items"),l=i?i.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]").length:0;if(s!=null&&l<=s)return}return e.remove(),r&&Ql(r),o&&Zl(o),jr(`Remove ${n}`,()=>Sn(bn(t),{path:n,structural:!0},t))}}function Sn(e,t,n){if(n.closed)return{ok:!1,skipped:!0,closed:!0};let r=ss(e);if(!t.structural&&r===n.lastFingerprint)return{ok:!0,skipped:!0};let o=Object.hasOwn(n,"writeRules")?n.writeRules:n.pageRules,s=xu(n.pageRoot,o,e,{shellRoot:n.shellRoot,structural:!!t.structural,structuralPath:t.path||null,formRoot:n.formRoot});return s.ok?(n.lastFingerprint=r,n.lastData=e,ko(n,e),Df(n,null),n.dispatch?.("hcms:change",{data:e,path:t.path,structural:!!t.structural}),n.onChange?.(e,t)):(Df(n,_g(s.error,t.path)),n.dispatch?.("hcms:error",{error:s.error,attemptedData:e}),n.onError?.(s.error)),s}function li(e,t){let n=qr(t),r=`[data-hcms-path="${n}"] input[data-hcms-field], [data-hcms-path="${n}"] textarea[data-hcms-field], [data-hcms-path="${n}"] select[data-hcms-field], [data-hcms-path="${n}"] img[data-hcms-field], [data-hcms-path="${n}"] a[data-hcms-field], [data-hcms-path="${n}"] [contenteditable][data-hcms-field], input[data-hcms-path="${n}"][data-hcms-field], textarea[data-hcms-path="${n}"][data-hcms-field], select[data-hcms-path="${n}"][data-hcms-field], img[data-hcms-path="${n}"][data-hcms-field], a[data-hcms-path="${n}"][data-hcms-field], [contenteditable][data-hcms-path="${n}"][data-hcms-field]`;return e.querySelector(r)}function ai(e,t,n,r){let o=(e.tagName||"").toUpperCase(),s=(e.getAttribute("type")||"").toLowerCase();if(o==="INPUT"&&s==="checkbox"){e.checked=t===!0||t==="true";return}if(o==="INPUT"&&s==="radio"){let i=qr(r),l=n.querySelectorAll(`[data-hcms-path="${i}"][data-hcms-field][type="radio"], [data-hcms-path="${i}"] [data-hcms-field][type="radio"]`);l.length?l.forEach(a=>{a.checked=String(a.value)===String(t??"")}):e.checked=String(e.value)===String(t??"");return}if(o==="IMG"){e.src=t==null?"":String(t);return}if(o==="A"){e.href=t==null?"":String(t);return}if(e.hasAttribute&&e.hasAttribute("contenteditable")){e.innerHTML=t==null?"":String(t);return}if("value"in e){e.value=t==null?"":String(t);return}e.textContent=t==null?"":String(t)}function bn(e){let t=fn.extract(e.formRoot,e.formRules,{exclude:null});return nr(t,e.formRules)}function nr(e,t){if(t==null||e==null)return e;if(typeof t=="string")return t.endsWith("@checked")?e===!0||e==="true":e;if(Array.isArray(t)){if(!Array.isArray(e))return e;let[,n]=t;return e.map(r=>nr(r,n))}if(typeof t=="object"){if(typeof e!="object"||Array.isArray(e))return e;let n={};for(let[r,o]of Object.entries(t))n[r]=nr(e[r],o);return n}return e}function Df(e,t){e.lastErrors=t&&t.length?t:null,Jl(e)}function Jl(e){if(Ng(e),e.errorEl&&(e.errorEl.textContent="",e.errorEl.hidden=!0),!e.lastErrors)return;let t=[];for(let{message:n,path:r}of e.lastErrors){if(r!=null&&r!==""){let o=Cg(e.formRoot,r);if(o){o.textContent=o.textContent?`${o.textContent}
200
200
  ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textContent=t.join(`
201
- `),e.errorEl.hidden=!1)}function Hg(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function zg(e,t){if(!e)return null;let n=t.split(".");for(;n.length>0;){let r=n.join("."),o=typeof CSS<"u"&&CSS.escape?CSS.escape(r):r.replace(/[^a-zA-Z0-9_\-.*]/g,i=>"\\"+i),s=e.querySelector(`[data-hcms-path="${o}"]`);if(s){for(let i of s.children)if(i.classList&&i.classList.contains("hcms-error"))return i}n.pop()}return null}function Vg(e,t){return e?e.name==="EmptyListInsert"?[{message:"Add a seed item in HTML first.",path:t}]:e.name==="ShapeMismatch"&&Array.isArray(e.mismatches)&&e.mismatches.length?e.mismatches.map(n=>({message:`Shape mismatch: expected ${n.expected}, got ${n.got}`,path:n.path})):[{message:e.message||String(e),path:t}]:[{message:"unknown error",path:t}]}function Wg(e,t){let n=e;for(let r of t){if(n==null||typeof n=="string")return;if(Array.isArray(n)){if(typeof r!="number"&&r!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof r=="number"||!(r in n))return;n=n[r];continue}return}return n}function li(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function ea(e){if(!e)return;let t=e.querySelector(".hcms-array-items");if(!t)return;let n=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),r=n.length,o=li(e,"data-hcms-max-items"),s=li(e,"data-hcms-min-items"),i=e.hasAttribute("data-hcms-no-add"),l=e.hasAttribute("data-hcms-no-remove"),a=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');c&&(c.hidden=i||o!=null&&r>=o),n.forEach((p,u)=>{let f=p.querySelector('[data-hcms-action="remove"]');f&&(f.hidden=l||s!=null&&r<=s);let h=p.querySelector('[data-hcms-action="move-up"]');h&&(h.hidden=a||u===0);let d=p.querySelector('[data-hcms-action="move-down"]');d&&(d.hidden=a||u===r-1)})}function fi(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>ta(t))}function ta(e){let t=e.querySelectorAll?Array.from(e.querySelectorAll('input[type="radio"][data-hcms-field]'),r=>[r,r.checked]):[],n=0;for(let r of e.children){if(!r.matches?.("[data-hcms-card], [data-hcms-array-item]"))continue;let o=r.getAttribute("data-hcms-path");if(!o)continue;let s=o.split(".");s[s.length-1]=String(n);let i=s.join(".");i!==o&&Kg(r,o,i),n++}for(let[r,o]of t)r.checked!==o&&(r.checked=o)}function Kg(e,t,n){let r=e.querySelectorAll("[data-hcms-path]");e.setAttribute("data-hcms-path",n);for(let o of r){let s=o.getAttribute("data-hcms-path");s===t?o.setAttribute("data-hcms-path",n):s&&s.startsWith(t+".")&&o.setAttribute("data-hcms-path",n+s.slice(t.length))}Gg(e)}function Gg(e){for(let t of e.querySelectorAll('input[type="radio"][data-hcms-field]')){if(!t.name||!t.name.startsWith("hcms-"))continue;let n=t.closest("[data-hcms-path]");n&&(t.name=ni(n.getAttribute("data-hcms-path")))}}function ls(e){return JSON.stringify(e,(t,n)=>{if(n&&typeof n=="object"&&!Array.isArray(n)){let r=Object.create(null);for(let o of Object.keys(n).sort())r[o]=n[o];return r}return n})}function Fr(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var eb={},di="hcms-shell-styles",Yg="hcms-bundled-styles-installed",hi="hcms-session-open",Xg='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',So=new WeakSet,na="";function Gf(e){na=e}function as(e){e?.body?.classList.add(hi)}function ra(e){e?.body?.classList.remove(hi)}var Jg=0;function Kf(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}function Yf({mountTo:e,side:t="right",overlay:n=!1,showSaveButton:r=!1,title:o="Page content",eyebrow:s="Edit",theme:i=null,doc:l}){Xf(l);let a=`hcms-shell-title-${++Jg}`,c=l.createElement("div");c.setAttribute("data-hcms-shell",""),c.setAttribute("editor-ui",""),c.setAttribute("save-remove",""),c.setAttribute("save-ignore",""),c.setAttribute("tabindex","-1"),c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby",a);let p=i==="dark"?" dark":i==="light"?" light":"";c.className="hcms-shell pixel-quiet hcms-panel hcms-side-"+t+(n?" hcms-overlay":"")+p;let u=Kf(o),f=Kf(s);c.innerHTML=`
201
+ `),e.errorEl.hidden=!1)}function Ng(e){if(e.formRoot)for(let t of e.formRoot.querySelectorAll(".hcms-error"))t.textContent="",t.hidden=!0}function Cg(e,t){if(!e)return null;let n=t.split(".");for(;n.length>0;){let r=n.join("."),o=typeof CSS<"u"&&CSS.escape?CSS.escape(r):r.replace(/[^a-zA-Z0-9_\-.*]/g,i=>"\\"+i),s=e.querySelector(`[data-hcms-path="${o}"]`);if(s){for(let i of s.children)if(i.classList&&i.classList.contains("hcms-error"))return i}n.pop()}return null}function _g(e,t){return e?e.name==="EmptyListInsert"?[{message:"Add a seed item in HTML first.",path:t}]:e.name==="ShapeMismatch"&&Array.isArray(e.mismatches)&&e.mismatches.length?e.mismatches.map(n=>({message:`Shape mismatch: expected ${n.expected}, got ${n.got}`,path:n.path})):[{message:e.message||String(e),path:t}]:[{message:"unknown error",path:t}]}function Mg(e,t){let n=e;for(let r of t){if(n==null||typeof n=="string")return;if(Array.isArray(n)){if(typeof r!="number"&&r!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof r=="number"||!(r in n))return;n=n[r];continue}return}return n}function si(e,t){if(!e||!e.hasAttribute(t))return null;let n=parseInt(e.getAttribute(t),10);return Number.isFinite(n)?n:null}function Zl(e){if(!e)return;let t=e.querySelector(".hcms-array-items");if(!t)return;let n=Array.from(t.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")),r=n.length,o=si(e,"data-hcms-max-items"),s=si(e,"data-hcms-min-items"),i=e.hasAttribute("data-hcms-no-add"),l=e.hasAttribute("data-hcms-no-remove"),a=e.hasAttribute("data-hcms-no-reorder"),c=e.querySelector(':scope > .hcms-add, :scope > * > .hcms-add, :scope > [data-hcms-action="add"]');c&&(c.hidden=i||o!=null&&r>=o),n.forEach((m,u)=>{let f=m.querySelector('[data-hcms-action="remove"]');f&&(f.hidden=l||s!=null&&r<=s);let p=m.querySelector('[data-hcms-action="move-up"]');p&&(p.hidden=a||u===0);let h=m.querySelector('[data-hcms-action="move-down"]');h&&(h.hidden=a||u===r-1)})}function ci(e){!e||!e.querySelectorAll||e.querySelectorAll(".hcms-array-items").forEach(t=>Ql(t))}function Ql(e){let t=e.querySelectorAll?Array.from(e.querySelectorAll('input[type="radio"][data-hcms-field]'),r=>[r,r.checked]):[],n=0;for(let r of e.children){if(!r.matches?.("[data-hcms-card], [data-hcms-array-item]"))continue;let o=r.getAttribute("data-hcms-path");if(!o)continue;let s=o.split(".");s[s.length-1]=String(n);let i=s.join(".");i!==o&&Rg(r,o,i),n++}for(let[r,o]of t)r.checked!==o&&(r.checked=o)}function Rg(e,t,n){let r=e.querySelectorAll("[data-hcms-path]");e.setAttribute("data-hcms-path",n);for(let o of r){let s=o.getAttribute("data-hcms-path");s===t?o.setAttribute("data-hcms-path",n):s&&s.startsWith(t+".")&&o.setAttribute("data-hcms-path",n+s.slice(t.length))}Ig(e)}function Ig(e){for(let t of e.querySelectorAll('input[type="radio"][data-hcms-field]')){if(!t.name||!t.name.startsWith("hcms-"))continue;let n=t.closest("[data-hcms-path]");n&&(t.name=ei(n.getAttribute("data-hcms-path")))}}function ss(e){return JSON.stringify(e,(t,n)=>{if(n&&typeof n=="object"&&!Array.isArray(n)){let r=Object.create(null);for(let o of Object.keys(n).sort())r[o]=n[o];return r}return n})}function qr(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Fg={},ui="hcms-shell-styles",Lg="hcms-bundled-styles-installed",fi="hcms-session-open",Pg='a[href], area[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',xo=new WeakSet,ea="";function Uf(e){ea=e}function is(e){e?.body?.classList.add(fi)}function ta(e){e?.body?.classList.remove(fi)}var jg=0;function $f(e){return String(e).replace(/[&<>"]/g,t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"})[t])}function Hf({mountTo:e,side:t="right",overlay:n=!1,showSaveButton:r=!1,title:o="Page content",eyebrow:s="Edit",theme:i=null,doc:l}){zf(l);let a=`hcms-shell-title-${++jg}`,c=l.createElement("div");c.setAttribute("data-hcms-shell",""),c.setAttribute("editor-ui",""),c.setAttribute("save-remove",""),c.setAttribute("save-ignore",""),c.setAttribute("tabindex","-1"),c.setAttribute("role","dialog"),c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby",a);let m=i==="dark"?" dark":i==="light"?" light":"";c.className="hcms-shell pixel-quiet hcms-panel hcms-side-"+t+(n?" hcms-overlay":"")+m;let u=$f(o),f=$f(s);c.innerHTML=`
202
202
  <div class="hcms-shell-minibar" aria-hidden="true">
203
203
  <span class="hcms-shell-minibar-title">${u}</span>
204
204
  <button type="button" class="hcms-shell-close mirk-button mirk-button--small" data-hcms-action="close" aria-label="Close">
@@ -224,8 +224,8 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
224
224
  </button>
225
225
  </footer>
226
226
  </div>
227
- `,(e||l.body).appendChild(c);let d=l.body;d.classList.add("hcms-open"),as(l),n&&d.classList.add("hcms-overlay"),t==="left"&&d.classList.add("hcms-side-left");let v=Qg(c,l),g=Zg(c);return{root:c,formRoot:c.querySelector("[data-hcms-form-root]"),noticeEl:c.querySelector(".hcms-shell-notice"),errorEl:c.querySelector(".hcms-shell-error"),saveButton:c.querySelector(".hcms-shell-save"),destroy(){v.detach(),g.detach(),c.remove(),d.classList.remove("hcms-open","hcms-overlay","hcms-side-left"),ra(l)},restoreChrome(){yr(l),d.classList.add("hcms-open"),as(l),n&&d.classList.add("hcms-overlay"),t==="left"&&d.classList.add("hcms-side-left")}}}function yr(e){e&&(e.getElementById(di)||e.querySelector("style[data-hcms-bundled-styles]")||(So.delete(e),Xf(e)))}function Xf(e){if(e&&!So.has(e)){if(e[Yg]){So.add(e);return}if(e.getElementById(di)||e.querySelector("style[data-hcms-bundled-styles]")){So.add(e);return}if(na){let t=e.createElement("style");t.id=di,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=na,(e.head||e.documentElement).appendChild(t),So.add(e);return}try{let t=new URL("./theme.generated.css",eb.url).href,n=e.createElement("link");n.rel="stylesheet",n.id=di,n.setAttribute("save-remove",""),n.setAttribute("save-ignore",""),n.href=t,(e.head||e.documentElement).appendChild(n),So.add(e)}catch{let n=()=>{link.isConnected&&console.warn("hypercms: shell stylesheet not applied \u2014 cssText is empty and the co-located theme fallback is unavailable. Call installStyles(themeText) before opening the CMS.")};e.defaultView?.queueMicrotask?e.defaultView.queueMicrotask(n):n()}}}function Zg(e){let t=e.querySelector(".hcms-shell-body"),n=e.querySelector(".hcms-shell-header");if(!t||!n||typeof t.addEventListener!="function")return{detach(){}};let r=()=>{let o=(n.offsetHeight||0)-12;e.classList.toggle("is-condensed",t.scrollTop>o)};return t.addEventListener("scroll",r,{passive:!0}),r(),{detach(){t.removeEventListener("scroll",r)}}}function Qg(e,t){function n(r){if(r.key!=="Tab"||!e.contains(t.activeElement))return;let o=Array.from(e.querySelectorAll(Xg));if(o.length===0)return;let s=o[0],i=o[o.length-1];r.shiftKey&&t.activeElement===s?(r.preventDefault(),i.focus()):!r.shiftKey&&t.activeElement===i&&(r.preventDefault(),s.focus())}return t.addEventListener("keydown",n),{detach:()=>t.removeEventListener("keydown",n)}}var tb="[hypercms]",Jf={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Zf={skip:"[data-hcms-shell]",templateAttr:null},oa=class extends Error{constructor(t,n,r){super(`hypercms: rule at "${t}" has an invalid CSS selector: "${n}"`),this.name="InvalidRuleSelector",this.path=t,this.selector=n,this.cause=r}};function pi(e,t){let n=[],r=[],o=[];return ia(Qn(e),e,t,[],n,r,o),{missing:Qf(n),twins:ib(r),readOnly:Qf(o)}}function gi(e){return sa(e)}function sa(e){if(typeof e=="string")return ed(e)?void 0:e;if(Array.isArray(e)){let[t,n]=e;return[t,sa(n)]}if(e&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e)){let o=sa(r);o!==void 0&&(t[n]=o)}return t}return e}function ia(e,t,n,r,o,s,i){if(typeof n=="string"){let l=nb(n),a=l?mi(e,t,l,Jf,r):[];if(ed(n)){i.push(Ao(r));return}if(!l)return;if(n.endsWith("[]")){a.length===0&&mi(e,t,l,Zf,r).length===0&&o.push(Ao(r));return}a.length===0?o.push(Ao(r)):a.length>1&&s.push({path:Ao(r),count:a.length});return}if(Array.isArray(n)){let[l,a]=n;if(typeof l!="string"||!l)return;let c=mi(e,t,l,Jf,r);if(c.length===0){mi(e,t,l,Zf,r).length===0&&o.push(Ao(r));return}for(let p of c)ia(e,p,a,[...r,"*"],o,s,i);return}if(n&&typeof n=="object")for(let[l,a]of Object.entries(n))ia(e,t,a,[...r,l],o,s,i)}function mi(e,t,n,r,o){try{return e.find(t,n,r)}catch(s){throw new oa(Ao(o),n,s)}}function nb(e){if(e==="."||e.startsWith("@"))return null;if(e.endsWith("[]"))return e.slice(0,-2)||null;let t=Kt(e);return(t===-1?e:e.slice(0,t))||null}function rb(e){if(e.endsWith("[]"))return null;let t=Kt(e);return t===-1?null:e.slice(t+1)||null}function ed(e){let t=rb(e);return t!=null&&Vr.has(t)}function To(e){ob(e),sb(e)}function ob(e){let t=e.noticeEl;if(!t)return;let n=e.unresolved&&e.unresolved.missing||[],r=e.unresolved&&e.unresolved.readOnly||[];if(n.length===0&&r.length===0){t.textContent="",t.hidden=!0;return}let o=[];if(n.length){let s=n.length===1?"1 field no longer matches this page":`${n.length} fields no longer match this page`;o.push(`${s}: ${n.join(", ")}`)}if(r.length){let s=r.length===1?"1 field reads a property the browser will not let anything write":`${r.length} fields read properties the browser will not let anything write`;o.push(`${s}: ${r.join(", ")}`)}t.textContent=o.join(`
228
- `),t.hidden=!1}function sb(e){let t=e.unresolved&&e.unresolved.twins||[],n=t.map(r=>`${r.path}:${r.count}`).join("|");if(n!==e.lastTwinSignature){e.lastTwinSignature=n;for(let{path:r,count:o}of t)console.warn(`${tb} "${r}" matches ${o} elements; edits go to the first one.`)}}function Qf(e){return[...new Set(e)]}function ib(e){let t=new Map;for(let n of e){let r=t.get(n.path);(!r||n.count>r.count)&&t.set(n.path,n)}return[...t.values()]}function Ao(e){return e.length?e.join("."):"(whole page)"}var lb={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function vr(e,{ignoreActiveValue:t}={}){return ab(e,{ignoreActiveValue:t})}function ab(e,{ignoreActiveValue:t}){let n=un.findRules(e.doc,e.rulesSource||"cms");n&&(e.pageRules=e.view.prepareRules($s(n.rules,e.pageRoot)),e.rulesTagNode=n.tagNode),zs(e.doc),Gs(e.doc,e.pageRules),e.formRules=Js(e.pageRules,e.doc),e.writeRules=gi(e.pageRules),e.unresolved=pi(e.pageRoot,e.pageRules);let r=Bs(),o=rr(un.extract(e.pageRoot,e.pageRules,{...lb,...r.hooks}),e.pageRules),s=po({pageRules:e.pageRules,formRules:e.formRules,data:o,doc:e.doc});Fs(e.formRoot,s,{ignoreActiveValue:t}),vo(e,o),r.seed(e.formRoot),br(e.formRoot,e.doc,e.view?.enhanceFormRichText!==!1),Ql(e),To(e),e.updateFingerprint&&e.updateFingerprint()}function td({debounce:e=100,onRefresh:t}){let n=sn("Mutation");if(!n||typeof n.onAnyChange!="function")throw new Error("hypercms: a mutation hub is required (clay.Mutation or hyperclay.Mutation). Load clayjs or hyperclayjs, or just the mutation utility, before initializing hypercms.");let r=n.onAnyChange({debounce:e},o=>{t(o)});return{unsubscribe:typeof r=="function"?r:()=>{}}}var cb='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])';function nd({doc:e,pageRoot:t,opts:n={}}){let r=n.richText!==!1,o=null;return{name:"sidebar",richText:r,enhanceFormRichText:!0,ctx:null,root:null,formRoot:null,errorEl:null,noticeEl:null,prepareRules(s){return r?Ff(s,t):s},mount(s){let i=this.ctx;o=or(()=>Yf({mountTo:n.mountTo||e.body,side:n.side||"right",overlay:!!n.overlay,showSaveButton:!!n.showSaveButton,title:n.title,eyebrow:n.eyebrow,theme:n.theme,doc:e})),this.root=o.root,this.formRoot=o.formRoot,this.errorEl=o.errorEl,this.noticeEl=o.noticeEl;let l=po({pageRules:i.pageRules,formRules:i.formRules,data:s,doc:e});o.formRoot.appendChild(l),i.seeder.seed(o.formRoot),br(o.formRoot,e),To(i),ai(i)},refresh(s){if(s==="livesync"){o?.restoreChrome?.(),vr(this.ctx,{ignoreActiveValue:!0});return}if(s==="undo"){vr(this.ctx,{ignoreActiveValue:!1});return}vr(this.ctx)},focusOnOpen(){let s=this.root&&this.root.querySelector(cb);s&&typeof s.focus=="function"&&s.focus()},destroy(){o?.destroy(),o=null}}}var ub="[cms-template], [data-hcms-shell]";function Eo(e){if(!e||typeof e.getBoundingClientRect!="function"||typeof e.closest=="function"&&e.closest(ub))return!1;let t=e.getBoundingClientRect();return t.width>=8&&t.height>=8}var fb={skip:"[data-hcms-shell]",templateAttr:"cms-template"},db={skip:"[data-hcms-shell]",templateAttr:null},hb="text",mb="native",rd="handle",pb=new Set(["INPUT","TEXTAREA","SELECT"]),id=new Set(["IMG","INPUT","TEXTAREA","SELECT","OPTION","BR","HR","VIDEO","AUDIO","IFRAME","EMBED","OBJECT","CANVAS","SOURCE","TRACK","AREA","COL","PARAM","BUTTON","STYLE","SCRIPT","LINK","META"]);function aa(e,t,n=null){let r=[],o=[],s=Qn(e);return la(s,e,t,[],r,o,n?(l,a)=>ns(l,n,a,t):()=>null),{targets:r,lists:o}}function la(e,t,n,r,o,s,i){if(typeof n=="string"){if(n.endsWith("[]")){let u=n.slice(0,-2);if(!u)return;let f=bi(e,t,u);f.forEach((h,d)=>{o.push(sd([...r,d],h,n,null))}),s.push(od(e,t,r,u,f,!0));return}let l=Kt(n),a=l===-1?null:n.slice(l+1),c=l===-1?n:n.slice(0,l),p=!c||c==="."?t:bi(e,t,c)[0];p&&o.push(sd(r,p,n,a,i(n,r)));return}if(Array.isArray(n)){let[l,a]=n;if(typeof l!="string"||!l)return;let c=bi(e,t,l);c.forEach((p,u)=>la(e,p,a,[...r,u],o,s,i)),s.push(od(e,t,r,l,c,typeof a=="string"));return}if(n&&typeof n=="object")for(let[l,a]of Object.entries(n))la(e,t,a,[...r,l],o,s,i)}function od(e,t,n,r,o,s){let i=o[0]?o[0].parentElement:null;if(!i){let l=bi(e,t,r,db)[0];i=l?l.parentElement:null}return{path:n,items:o,container:i,scalar:s}}function sd(e,t,n,r,o=null){return{path:e,el:t,rule:n,attr:r,kind:gb(t,r),icon:kb(t,r),style:o}}function gb(e,t){let n=(e.tagName||"").toUpperCase();return!t||t==="innerHTML"?id.has(n)?rd:hb:t==="value"&&pb.has(n)&&!e.readOnly&&!bb(e)?mb:rd}function bb(e){return e.disabled?!0:typeof e.matches=="function"&&e.matches(":disabled")}function kb(e,t){let n=(e.tagName||"").toUpperCase();return(!t||t==="innerHTML")&&!id.has(n)?null:n==="IMG"||t==="srcset"?"camera":n==="A"&&t==="href"?"paperclip":"pencil"}function bi(e,t,n,r=fb){try{return e.find(t,n,r)}catch{return[]}}function ld(e,t){let n=[],r=new Map,o=null;for(let s of e){if(!s.style)continue;let i=s.path.join(".");if(s.style==="page"){o||(o={scope:"page",el:s.el,list:null,paths:[]},n.push(o)),o.paths.push(i);continue}let l=yb(s.path,t),a=l?l.row:s.el,c=r.get(a);c||(c={scope:l?"row":"section",el:a,list:l?l.list:null,paths:[]},r.set(a,c),n.push(c)),c.paths.push(i)}return n}function yb(e,t){for(let n=e.length-1;n>=0;n--){if(typeof e[n]!="number")continue;let r=e.slice(0,n).join("."),o=t.find(i=>i.path.join(".")===r),s=o&&o.items[e[n]];if(s)return{list:o,row:s}}return null}var ki=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),vb=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),C1=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function cs(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function ca(e,t){if(cs(e,t))return!0;for(let[n,r]of Object.entries(vb))if(r.includes(t)&&cs(e,n))return!0;return!1}function us(e){let t=ki[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function xb(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=ki[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>ca(n,o))||r.bundles.some(o=>cs(n,o)))return n;n=n.parentElement}return null}function ad(e,t){return!!xb(e,t)}var wb=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function Sb(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function cd(e,t,n,r){if(r)return!!e.closest?.(t);let o=e;for(;o?.nodeType===1;){if(o.matches(t))return!0;if(o===n)break;o=o.parentElement}return!1}function ud(e,t,n,r,o,s){return(s?ad(e,t):cd(e,n,o,!1))||!!(r&&(s&&e!==o?e.matches(r):cd(e,r,o,s)))}function Ab(e,t){let n=ki[t];return n.tokens.some(r=>ca(e,r))||n.bundles.some(r=>cs(e,r))}var Tb=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function fd(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let o=e,s=t;if(e.nodeType===1){if(Tb.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);o=e.content,s=t.content,n.cloneToLive.set(s,o),n.liveToClone.set(o,s)}}else if(e.nodeType!==11)return;let i=s.firstChild;for(let l=o.firstChild;l&&i;l=l.nextSibling)fd(l,i,n,r),i=i.nextSibling}function ua(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:o=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=s.implementation.createHTMLDocument(""),l=o||new WeakMap,a=new WeakMap,c=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let p=us(t),u=r?d=>Ab(d,t)||!!(n&&d.matches(n)):d=>ud(d,t,p,n,c,!1),f=null;if(c.nodeType!==1||!ud(c,t,p,n,c,r)){f=i.importNode(c,!0);let d={cloneToLive:l,liveToClone:a,dropped:[],controls:[]};fd(c,f,d,u);for(let v of d.dropped)v.remove();for(let v=0;v<d.controls.length;v+=2)Sb(d.controls[v],d.controls[v+1])}e.nodeType===9&&f&&(i.replaceChild(f,i.documentElement),a.set(e,i),l.set(i,e));let h=d=>{if(wb.test(d))throw new Error(`Filtered content queries do not support stateful selector: ${d}`)};return{root:f,document:i,capability:t,selector:us(t),cloneToLive:l,liveToClone:a,original(d){return l.get(d)||null},cloneOf(d){return a.get(d)||null},query(d,v=f){return h(d),Array.from(v.querySelectorAll(d),g=>l.get(g)||g)},text(d=f){return(d===f?f:a.get(d))?.textContent||""},html(d=f){return(d===f?f:a.get(d))?.innerHTML??""},clone(d=f){let v=d===f?f:a.get(d);return v?i.importNode(v,!0):null}}}var Eb=[16,8,0],ln=8,Ob=4;function dd({anchor:e,bar:t,rail:n=t,viewport:r,current:o=null}){let s=f=>o===f?Ob:0;if(e.bottom<=0||e.top>=r.height||e.right<=0||e.left>=r.width)return{mode:"hidden",x:0,y:0};let i=f=>Math.max(ln,Math.min(e.left,r.width-f-ln)),l=e.top-16-t.height;if(l>=ln-s("above"))return{mode:"above",x:i(t.width),y:l};let a=e.bottom+16;if(a+t.height<=r.height-ln+s("below"))return{mode:"below",x:i(t.width),y:a};let c=r.width-e.right-ln,p=e.left-ln,u=c>=p?[["rail-right",c],["rail-left",p]]:[["rail-left",p],["rail-right",c]];for(let[f,h]of u)for(let d of Eb){if(n.width+d>h+s(f))continue;let v=f==="rail-right"?Math.min(e.right+d,r.width-n.width-ln):Math.max(e.left-d-n.width,ln),g=Math.min(e.bottom,r.height-ln)-n.height,m=Math.max(ln,Math.min(Math.max(e.top,ln),g));return{mode:f,x:v,y:m,gap:d}}return{mode:"pinned",x:i(t.width),y:ln}}function fa({anchor:e,handle:t,viewport:n,inset:r=6,prefer:o="auto"}){let s=e.height>=t.height*1.5&&e.width>=t.width*2;if(o==="corner"||s){let f=Math.max(ln,Math.min(e.right-t.width+r,n.width-t.width-ln)),h=Math.max(ln,Math.min(e.top-r,n.height-t.height-ln));return{x:f,y:h,mode:"over"}}let i=4,l=e.right+i+t.width<=n.width-ln,a=l?e.right+i:e.left-i-t.width,c=Math.max(ln,a),p=e.top+e.height/2-t.height/2,u=Math.max(ln,Math.min(p,n.height-t.height-ln));return{x:c,y:u,mode:l?"beside-right":"beside-left"}}var vi=!1;function hd(){if(vi)return;let e=sn("onPrepareForSave");typeof e=="function"&&(e(t=>{pd(t),md(t)}),vi=!0)}function md(e){let t=e&&e.querySelector&&e.querySelector("body");t&&t.classList.remove("hcms-open","hcms-overlay","hcms-side-left",hi)}function pd(e){if(!(!e||typeof e.querySelectorAll!="function"))for(let t of e.querySelectorAll(`[${gr}]`)){let n=Pf(t);n!==null&&(t.innerHTML=n),t.removeAttribute(gr)}}var xi=!1;function wi(){if(xi)return;let e=sn("onSnapshot");typeof e=="function"&&(e(t=>{pd(t),qf(t,typeof window<"u"?window:null),md(t)}),xi=!0)}function gd(){hd(),wi(),(!vi||!xi)&&Nb()}var yi=null;function Nb(){if(yi||typeof document>"u")return;yi=bo(document,Rf,()=>{hd(),wi(),vi&&xi&&(yi?.(),yi=null)})}var Cb={edit:"M8 10h2v6H8zm2 4h4v2h-4zm0-6h2v2h-2zm2-2h2v2h-2zm2-2h2v2h-2zm2-2h2v2h-2zm2 2h2v2h-2zm2 2h2v2h-2zm-2 2h2v2h-2zm-2 2h2v2h-2zm-2 2h2v2h-2zm-4 0h2v2h-2z","move-up":"M11 4h2v2h2v2h2v2h2v2h-4v-2h-2v10h-2V10H9v2H5v-2h2V8h2V6h2z","move-down":"M11 4h2v10h2v-2h4v2h-2v2h-2v2h-2v2h-2v-2H9v-2H7v-2H5v-2h4v2h2z",remove:"M5 5h3v3h3v3h2V8h3V5h3v3h-3v3h-3v2h3v3h3v3h-3v-3h-3v-3h-2v3H8v3H5v-3h3v-3h3v-2H8V8H5z",add:"M10 4h4v6h6v4h-6v6h-4v-6H4v-4h6z"};function Br(e){let t=e==="edit"?"6 0 18 18":"0 0 24 24",n=e==="settings"?'<circle cx="6" cy="12" r="1.5"/><circle cx="12" cy="12" r="1.5"/><circle cx="18" cy="12" r="1.5"/>':`<path d="${Cb[e]}"/>`;return`<svg class="hcms-inline-icon" xmlns="http://www.w3.org/2000/svg" viewBox="${t}" width="24" height="24" fill="currentColor" aria-hidden="true" focusable="false">${n}</svg>`}var bd="data-hcms-ghost",_b=us("history");function Mb(e){let t=e.container,n=null;for(;t&&(t.namespaceURI!=="http://www.w3.org/1999/xhtml"||["SELECT","OPTGROUP","DATALIST"].includes(t.tagName));)n=t,t=t.parentElement;return{parent:t,anchor:n}}function kd({doc:e,themeRoot:t,onAdd:n,onResize:r}){let o=e.defaultView,s=[],i=!1,l=null,a=new Map;function c(h,d,v){h.style[d]!==v&&(h.style[d]=v)}function p(){let h=new Set(s.map(d=>d.node.parentElement));for(let[d,v]of a)h.has(d)&&o?.Sortable?.get(d)===v.instance||(v.instance.option("draggable")===v.selector&&v.instance.option("draggable",v.original),a.delete(d));for(let d of h){let v=o?.Sortable?.get(d);if(!v)continue;let g=v.option("draggable");if(a.get(d)?.selector===g)continue;let m=g,S=`${m.trim().startsWith(">")?"> ":""}:is(${m.trim().replace(/^>\s*/,"")}):not(${_b})`;v.option("draggable",S),a.set(d,{instance:v,original:m,selector:S})}}function u(){for(let h of s){let{node:d,slot:v,list:g}=h,m=g.items.filter(k=>k.isConnected).map(k=>k.getBoundingClientRect()).filter(k=>k.width>0&&k.height>0);m.length&&(h.width=m.reduce((k,S)=>k+S.width,0)/m.length,h.height=m.reduce((k,S)=>k+S.height,0)/m.length),c(d,"width",h.width?`${Math.round(h.width)}px`:"100%"),c(v,"height",`${Math.max(48,Math.round(h.height||64))}px`),v!==d&&(v.colSpan=Math.max(1,...g.items.map(k=>[...k.children].reduce((S,x)=>S+(x.colSpan||1),0)))),d.hidden!==i&&(d.hidden=i)}p()}function f(h,d){let v=d.tagName,g=["TBODY","THEAD","TFOOT","TABLE"].includes(v),m=e.createElement(g?"tr":["UL","OL","MENU"].includes(v)?"li":"div");for(let w of[bd,"data-hcms-shell","editor-ui","no-watch","no-save","save-remove","snapshot-remove"])m.setAttribute(w,"");m.setAttribute("draggable","false"),m.setAttribute("contenteditable","false"),m.className="hcms-shell pixel-quiet hcms-inline-ghost";for(let w of["light","dark"])m.classList.toggle(w,!!t?.classList.contains(w));let k=g?e.createElement("td"):m;k!==m&&(k.className="hcms-inline-ghost-cell",m.appendChild(k));let S=e.createElement("button");S.type="button",S.className="hcms-inline-list-button hcms-inline-list-add mirk-button mirk-button--small",S.setAttribute("data-hcms-list-action","add"),S.innerHTML=`<span class="mirk-button__label">${Br("add")}<span>Add</span></span>`,k.appendChild(S);let x={node:m,slot:k,button:S,list:h,width:0,height:0};S.addEventListener("click",w=>{w.preventDefault(),w.stopPropagation(),n(x.list)});for(let w of["pointerdown","mousedown","touchstart","click"])m.addEventListener(w,T=>T.stopPropagation());return m.addEventListener("dragstart",w=>{w.preventDefault(),w.stopPropagation()}),x}return{setLists(h){let d=new Set(s),v=[],g=new Set(s.map(k=>k.node)),m=new Set;for(let k of h||[]){if(!k.container||!k.container.isConnected)continue;let{parent:S,anchor:x}=Mb(k);if(!S)continue;if(!m.has(S)){for(let N of S.querySelectorAll(`:scope > [${bd}]`))g.has(N)||N.remove();m.add(S)}let w=s.find(N=>d.has(N)&&N.list.container===k.container&&N.list.path.join(".")===k.path.join("."))||f(k,S);d.delete(w),w.list=k,w.button.setAttribute("data-hcms-list",k.path.join(".")),w.button.setAttribute("aria-label",`Add to ${k.path.join(".")||"the list"}`);let T=x||k.items.filter(N=>N.parentElement===S).at(-1);T?T.nextSibling!==w.node&&T.after(w.node):w.node.parentElement!==S&&S.appendChild(w.node),v.push(w)}for(let k of d)k.node.remove();s=v,l?.disconnect(),!l&&typeof o?.ResizeObserver=="function"&&(l=new o.ResizeObserver(()=>{u(),r?.()}));for(let k of s)for(let S of k.list.items)l?.observe(S);u()},update:u,setHidden(h){i=!!h,u()},destroy(){l?.disconnect();for(let h of s)h.node.remove();s=[],p()}}}var yd=[["move-up","Move up"],["move-down","Move down"]],Rb={prefer:"corner",inset:0};function Lb(e,t){return t.width<=e.width&&t.height<=e.height}function vd({doc:e,layerEl:t,onActivate:n,onListAction:r,onStyle:o}){let s=e.defaultView,i=[],l=new Map,a=0,c=new Map,p=null,u=new Set,f=0,h=!1,d=null,v=null,g=null,m=null,k=new Map,S=!1,x=null,w=kd({doc:e,themeRoot:t.closest("[data-hcms-shell]"),onResize:N,onAdd:te=>r?.({action:"add",list:te,index:te.items.length})}),T=e.createElement("div");T.className="hcms-inline-highlight",T.hidden=!0,T.setAttribute("aria-hidden","true"),t.appendChild(T);function N(){if(!(f||!s)){if(typeof s.requestAnimationFrame!="function")return I();f=s.requestAnimationFrame(()=>{f=0,I()})}}let C=()=>g||m;function I(){if(!s)return;w.update();let te={width:s.innerWidth,height:s.innerHeight},Ae=C();for(let je of i){if(!je.visible){je.node.hidden=!0;continue}for(let Ge of je.members)Ge.node.hidden=S&&Ge.kind!=="handle";je.node.hidden=!1;let Fe=je.el.getBoundingClientRect(),He=je.node.getBoundingClientRect(),et=He.width,bt=je.kind==="row"&&!Lb(Fe,He);if(bt&&je.el!==Ae){for(let Ge of je.members)Ge.kind==="row"&&(Ge.node.hidden=!0);He=je.node.getBoundingClientRect()}if(je.members.every(Ge=>Ge.node.hidden)){je.node.hidden=!0;continue}if(je.kind==="style"){let Ge=Math.max(8,Math.min(Fe.left,te.width-He.width-8)),Ct=Math.max(8,Math.min(Fe.top,te.height-He.height-8));je.node.style.transform=`translate(${Math.round(Ge)}px, ${Math.round(Ct)}px)`;continue}let Ft=je.kind==="handle"?null:Rb,{x:yt,y:Lt}=fa({anchor:Fe,handle:He,viewport:te,...Ft}),en=je.members.find(Ge=>Ge.kind==="handle");if(bt&&en){let Ge=en.node.getBoundingClientRect(),Ct=fa({anchor:Fe,handle:Ge,viewport:te}),Et=je.members.slice(je.members.indexOf(en)+1).filter(Jt=>!Jt.node.hidden).reduce((Jt,Y)=>Jt+Y.node.getBoundingClientRect().width+2,0);yt=Math.max(8+et,Math.min(te.width-8,Ct.x+Ge.width+Et))-He.width,Lt=Ct.y}je.node.style.transform=`translate(${Math.round(yt)}px, ${Math.round(Lt)}px)`}if(x)if(!x.node.isConnected||x.node.closest("[hidden]"))O();else{let je=x.button.getBoundingClientRect(),Fe=x.menu.getBoundingClientRect();x.menu.style.left=`${Math.max(8,je.right-Fe.width)-je.left}px`,x.menu.style.right="auto",x.menu.style.top=je.bottom+6+Fe.height>te.height-8?"auto":"calc(100% + 6px)",x.menu.style.bottom=je.bottom+6+Fe.height>te.height-8?"calc(100% + 6px)":"auto"}F(),d?.()}function q(te){if(te?.closest?.("[data-hcms-ghost]"))return null;for(let Ae=te;Ae&&Ae.nodeType===1;Ae=Ae.parentElement){let je=k.get(Ae);if(je)return je}return null}function V(te){x&&!x.node.contains(te.target)&&O();let Ae=C();m=q(te.target),m&&t.contains(te.target)&&(g=null),C()!==Ae&&N()}function U(te){if(te.relatedTarget||!m)return;let Ae=C();m=null,C()!==Ae&&N()}function F(){if(!v||T.hidden)return;let te=v.getBoundingClientRect();T.style.width=`${Math.round(te.width)}px`,T.style.height=`${Math.round(te.height)}px`,T.style.transform=`translate(${Math.round(te.left)}px, ${Math.round(te.top)}px)`}function A(){if(!s||typeof s.IntersectionObserver!="function"){for(let Ae of i)Ae.visible=!0;return}p||(p=new s.IntersectionObserver(Ae=>{let je=!1;for(let Fe of Ae)for(let He of l.get(Fe.target)||[])He.visible!==Fe.isIntersecting&&(He.visible=Fe.isIntersecting,je=!0);je&&N()},{threshold:0}));let te=new Set(l.keys());for(let Ae of u)te.has(Ae)||p.unobserve(Ae);for(let Ae of te)u.has(Ae)||p.observe(Ae);u=te}function E(){h||!s||(s.addEventListener("scroll",N,{passive:!0,capture:!0}),s.addEventListener("resize",N,{passive:!0}),e.addEventListener("focusin",V),e.addEventListener("focusout",U),e.addEventListener("pointerdown",K,!0),e.addEventListener("keydown",fe,!0),h=!0)}function X(){!h||!s||(s.removeEventListener("scroll",N,{capture:!0}),s.removeEventListener("resize",N),e.removeEventListener("focusin",V),e.removeEventListener("focusout",U),e.removeEventListener("pointerdown",K,!0),e.removeEventListener("keydown",fe,!0),h=!1)}function B(te){return`${te.kind}\0${te.attr||""}`}function z(te,Ae){return te.container===Ae.container&&te.scalar===Ae.scalar}function Ce(te,Ae){return te.kind!==Ae.kind?!1:te.kind==="style"?!0:te.kind==="handle"?B(te.target)===B(Ae.target):te.kind==="row"?te.row===Ae.row&&z(te.list,Ae.list):z(te.list,Ae.list)}function Me(te,Ae){te.target=Ae;let je=Ae.path.join(".");te.node.setAttribute("data-hcms-target",je),Ae.icon?te.node.setAttribute("data-hcms-icon",Ae.icon):te.node.removeAttribute("data-hcms-icon"),te.node.setAttribute("aria-label",`Edit ${je}`)}function Be(te){let Ae=e.createElement("button");Ae.type="button",Ae.className="hcms-inline-handle mirk-button mirk-button--small",Ae.innerHTML=`<span class="mirk-button__label">${Br("edit")}</span>`;let je={node:Ae,kind:"handle",target:te};return Me(je,te),Ae.addEventListener("click",Fe=>{Fe.preventDefault(),Fe.stopPropagation(),n?.(je.target,Ae)}),je}function me(te){let Ae=e.createElement("button");Ae.type="button",Ae.className="hcms-inline-style-chip mirk-button mirk-button--small",Ae.setAttribute("aria-label","Edit style"),Ae.innerHTML='<span class="mirk-button__label">Style</span>';let je={node:Ae,kind:"style",group:te.group};return Ae.addEventListener("click",Fe=>{Fe.preventDefault(),Fe.stopPropagation(),o?.(je.group,Ae)}),je}function Te(te,Ae){let je=e.createElement("button");return je.type="button",je.className="hcms-inline-list-button mirk-button mirk-button--small",je.setAttribute("data-hcms-list-action",te),je.setAttribute("aria-label",Ae),je.innerHTML=`<span class="mirk-button__label">${Br(te)}${te==="add"?"<span>Add</span>":""}</span>`,je}function Xe(te,{list:Ae,row:je,rowIndex:Fe,count:He}){let et=Ae.path.join(".");te.list=Ae,te.row=je,te.index=Fe,te.count=He,te.node.setAttribute("data-hcms-list",et),te.node.setAttribute("data-hcms-row",String(Fe));for(let bt of te.node.querySelectorAll("[data-hcms-list-action]")){let Ft=bt.getAttribute("data-hcms-list-action"),yt=yd.find(([Lt])=>Lt===Ft)?.[1]||Ft;bt.setAttribute("aria-label",`${yt} ${et}.${Fe}`),bt.disabled=Ft==="move-up"&&Fe===0||Ft==="move-down"&&Fe===He-1}}function _e(te,Ae,je,Fe){let He=e.createElement("div");He.className="hcms-inline-row-controls";let et={node:He,kind:"row",list:te,row:Ae,index:je,count:Fe};for(let[bt,Ft]of yd){let yt=Te(bt,Ft);yt.addEventListener("click",Lt=>{Lt.preventDefault(),Lt.stopPropagation(),!yt.disabled&&r?.({action:bt,list:et.list,index:et.index,row:et.row})}),He.appendChild(yt)}return Xe(et,{list:te,row:Ae,rowIndex:je,count:Fe}),et}function O(te=!1){if(!x)return;let Ae=x;x=null,Ae.menu.hidden=!0,Ae.button.setAttribute("aria-expanded","false"),Ae.node.parentElement?.classList.remove("has-open-settings"),te&&Ae.button.isConnected&&Ae.button.focus({preventScroll:!0})}function K(te){x&&!x.node.contains(te.target)&&O()}function fe(te){if(x){if(te.key==="Escape")te.preventDefault(),te.stopPropagation(),O(!0);else if(te.key==="Tab")O(!0);else if(["ArrowDown","ArrowUp","Home","End"].includes(te.key)&&x.menu.contains(te.target)){te.preventDefault();let Ae=[...x.menu.querySelectorAll('[role="menuitem"]')],je=Ae.indexOf(te.target),Fe=te.key==="Home"?0:te.key==="End"?Ae.length-1:je===-1?0:(je+(te.key==="ArrowDown"?1:-1)+Ae.length)%Ae.length;Ae[Fe]?.focus({preventScroll:!0})}}}function ae(te,{list:Ae,row:je,rowIndex:Fe,style:He=null}){Object.assign(te,{list:Ae,row:je,index:Fe,style:He}),te.node.setAttribute("data-hcms-list",Ae.path.join(".")),te.node.setAttribute("data-hcms-row",String(Fe)),te.button.setAttribute("aria-label",`Settings ${Ae.path.join(".")}.${Fe}`),He&&!te.styleItem.isConnected?te.menu.insertBefore(te.styleItem,te.menu.firstChild):He||te.styleItem.remove()}function qe(te){let Ae=e.createElement("div");Ae.className="hcms-inline-settings";let je=Te("settings","Settings");je.setAttribute("aria-haspopup","menu"),je.setAttribute("aria-expanded","false");let Fe=e.createElement("div");Fe.className="hcms-inline-settings-menu",Fe.setAttribute("role","menu"),Fe.setAttribute("aria-label","Item settings"),Fe.hidden=!0;let He=e.createElement("button");He.type="button",He.setAttribute("role","menuitem"),He.setAttribute("data-hcms-style-action",""),He.textContent="Style";let et=e.createElement("button");et.type="button",et.setAttribute("role","menuitem"),et.setAttribute("data-hcms-list-action","remove"),et.textContent="Delete",Fe.appendChild(et),Ae.append(je,Fe);let bt={node:Ae,button:je,menu:Fe,styleItem:He,kind:"settings"};ae(bt,te);let Ft=()=>{O(),x=bt,Fe.hidden=!1,je.setAttribute("aria-expanded","true"),Ae.parentElement.classList.add("has-open-settings"),Fe.querySelector('[role="menuitem"]').focus({preventScroll:!0}),N()};return je.addEventListener("click",yt=>{yt.preventDefault(),yt.stopPropagation(),x===bt?O(!0):Ft()}),je.addEventListener("keydown",yt=>{(yt.key==="ArrowDown"||yt.key==="ArrowUp")&&(yt.preventDefault(),Ft())}),et.addEventListener("click",yt=>{yt.preventDefault(),yt.stopPropagation(),O(!0),r?.({action:"remove",list:bt.list,index:bt.index,row:bt.row})}),He.addEventListener("click",yt=>{yt.preventDefault(),yt.stopPropagation(),O(),o?.(bt.style,bt.button)}),bt}function ze(te,Ae){te.kind==="handle"?Me(te,Ae.target):te.kind==="row"?Xe(te,Ae):te.kind==="settings"?ae(te,Ae):te.kind==="style"&&(te.group=Ae.group)}function Ee(te,Ae,je,Fe,He){let et=Ae.get(je)?.find(bt=>bt.category===He);if(!et){et={el:je,category:He,members:[]},te.push(et);let bt=Ae.get(je);bt?bt.push(et):Ae.set(je,[et])}et.members.push(Fe)}function ot(te,Ae,je,Fe){let He=je.items||[];He.forEach((et,bt)=>{Eo(et)&&(Ee(te,Ae,et,{kind:"row",list:je,row:et,rowIndex:bt,count:He.length},"item"),Ee(te,Ae,et,{kind:"settings",list:je,row:et,rowIndex:bt,style:Fe.get(et)||null},"item"))})}function rt(te,Ae){let je=new Set(te.members),Fe=[];for(let He of Ae){let et=te.members.find(bt=>je.has(bt)&&Ce(bt,He))||(He.kind==="handle"?Be(He.target):He.kind==="row"?_e(He.list,He.row,He.rowIndex,He.count):He.kind==="style"?me(He):qe(He));je.delete(et),ze(et,He),S&&et.kind!=="handle"&&(et.node.hidden=!0),Fe.push(et)}for(let He of je)He===x&&O(),He.node.remove();Fe.sort((He,et)=>["row","handle","settings"].indexOf(He.kind)-["row","handle","settings"].indexOf(et.kind)),Fe.forEach((He,et)=>{te.node.children[et]!==He.node&&te.node.insertBefore(He.node,te.node.children[et]||null)}),te.members=Fe}function xt(te,Ae,je){let Fe=[],He=new Map,et=new Map,bt=0;for(let Ge of te||[])Ge.style||(et.has(Ge.el)||et.set(Ge.el,Ge),!(Ge.kind!=="handle"||!Eo(Ge.el))&&(Ee(Fe,He,Ge.el,{kind:"handle",target:Ge},"item"),bt++));let Ft=new Map;for(let Ge of je||[])Ge.scope==="row"?Ft.set(Ge.el,Ge):Ge.scope==="section"&&Eo(Ge.el)&&Ee(Fe,He,Ge.el,{kind:"style",group:Ge},"style");for(let Ge of Ae||[])ot(Fe,He,Ge,Ft);let yt=new Set(i),Lt=new Map;for(let Ge of i)Lt.has(Ge.el)||Lt.set(Ge.el,Ge.visible);let en=[];for(let Ge of Fe){let Ct=i.find(Et=>yt.has(Et)&&Et.el===Ge.el&&Et.category===Ge.category);if(!Ct){let Et=e.createElement("div");Et.className="hcms-inline-item-controls",Et.setAttribute("role","group"),Ct={el:Ge.el,node:Et,category:Ge.category,kind:Ge.category==="add"?"add":"handle",members:[],visible:Lt.get(Ge.el)??!1},t.appendChild(Et)}yt.delete(Ct),Ct.el=Ge.el,Ct.category=Ge.category,rt(Ct,Ge.members),Ct.kind=Ct.members.some(Et=>Et.kind==="row")?"row":Ct.members.some(Et=>Et.kind==="handle")?"handle":Ct.members.some(Et=>Et.kind==="style")?"style":"add",Ct.node.setAttribute("aria-label",Ct.category==="add"?"List controls":Ct.category==="style"?"Style controls":"Item controls"),en.push(Ct)}for(let Ge of yt)Ge.node.remove();i=en,l=new Map,k=new Map;for(let Ge of i){let Ct=l.get(Ge.el);Ct?Ct.push(Ge):l.set(Ge.el,[Ge]);for(let Et of Ge.members)Et.kind!=="row"&&Et.kind!=="settings"||(k.set(Et.row,Et.row),k.set(Et.node,Et.row),k.set(Ge.node,Et.row))}g&&!k.has(g)&&(g=null),m&&!k.has(m)&&(m=null),c=et,a=bt}function nt(){O(),p?.disconnect(),p=null,u=new Set;for(let te of i)te.node.remove();i=[],l=new Map,c=new Map,k=new Map,a=0}return{setTargets(te,Ae,je=[]){xt(te,Ae,je),w.setLists(Ae),A(),E(),N()},refresh:N,get count(){return a},get controlsHidden(){return S},setControlsHidden(te){if(S=!!te,w.setHidden(S),S){O();for(let Ae of i){for(let je of Ae.members)je.kind!=="handle"&&(je.node.hidden=!0);Ae.members.every(je=>je.node.hidden)&&(Ae.node.hidden=!0)}}N()},elementToTarget(te){if(te?.closest?.("[data-hcms-ghost]"))return null;for(let Ae=te;Ae&&Ae.nodeType===1;Ae=Ae.parentElement){let je=c.get(Ae);if(je)return je}return null},setHoveredRow(te){let Ae=C();g=te?q(te):null,C()!==Ae&&N()},showHighlight(te){te&&(v=te,T.hidden=!1,F())},hideHighlight(){v=null,T.hidden=!0},setFollower(te){d=typeof te=="function"?te:null},destroy(){w.destroy(),f&&s&&s.cancelAnimationFrame(f),f=0,d=null,v=null,g=null,m=null,T.remove(),X(),nt()}}}var Ib="hypercms-inline",Oo="is-hcms-inline-active",ha="is-hcms-inline-onpath",xd='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])',Pb=["bold","italic","link","undo","redo"],jb=/^H[1-6]$/,qb=0;function Td({doc:e,pageRoot:t,opts:n={}}){let r=n.richText!==!1,o=null,s=null,i=null,l=new Map,a=null,c=null,p=[],u=null;function f(h,d,v,g,m){let k=ko(e.defaultView);if(typeof k!="function")return null;let S=m||{},x=S.originalHTML??ua(d,{capability:"history"}).html(),w=S.richClayIsOurs??!d.hasAttribute("data-richclay"),T=S.adopted??d.getAttribute("data-richclay-active")==="true",N=fs(d,g,"history"),C=Db(h,k,d,g,w);if(!C)return null;jf(d,g==="innerHTML",w);let I=String(++qb);d.setAttribute(gr,I),wi();let q={el:d,editor:C,path:v,prop:g,boundId:I,originalHTML:x,oldValue:N,richClayIsOurs:w,adopted:T,dirty:!1,written:!1,restorable(){return!this.adopted&&!this.dirty&&!this.written},lastEdited:void 0};l.set(d,q),Lf(I,q);let V=C.squire;if(V&&typeof V.addEventListener=="function"){let F=()=>{q.dirty=!0,q.lastEdited=fs(d,q.prop,"history"),Fb(h,q)};V.addEventListener("input",F),q.detachInput=()=>V.removeEventListener?.("input",F)}let U=()=>Ed(q);return d.addEventListener("blur",U),q.detachBlur=()=>d.removeEventListener("blur",U),q}return{name:"inline",richText:r,ctx:null,root:null,formRoot:null,errorEl:null,noticeEl:null,handoffEl:null,handoffCountEl:null,popEl:null,enhanceFormRichText:!1,prepareRules(h){return r?Bf(h,t):h},bindText(h,d,v,g){return f(this.ctx,h,d,v,g)},mount(h){let d=this.ctx;o=Hb(e,n.theme),this.root=o.root,this.formRoot=o.formRoot,this.errorEl=o.errorEl,this.noticeEl=o.noticeEl,this.handoffEl=o.handoffEl,this.handoffCountEl=o.handoffCountEl,this.popEl=o.popEl,or(()=>as(e));let v=po({pageRules:d.pageRules,formRules:d.formRules,data:h,doc:e});o.formRoot.appendChild(v),d.seeder.seed(o.formRoot),br(o.formRoot,e,this.enhanceFormRichText),To(d),ai(d),s=vd({doc:e,layerEl:o.layerEl,onActivate:(g,m)=>this.activate(g,m),onListAction:g=>this.listAction(g),onStyle:(g,m)=>this.openStyle(g,m)}),s.setFollower(()=>this.placePopover()),o.closeEl.addEventListener("click",()=>this.deactivate()),o.toggleEl.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this.toggleControls()}),o.pageStyleEl.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation();let m=p.find(k=>k.scope==="page");m&&this.openStyle(m,o.pageStyleEl)}),o.handoffEl.querySelector("[data-hcms-open-view]").addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),d.onViewRequested?.("sidebar")}),this.bindPage(),this.syncTargets()},listAction({action:h,list:d,index:v,row:g}){let m=this.ctx,k=d.path.join("."),S=m.formRoot.querySelector(`[data-hcms-path="${Fr(k)}"]`);if(!S)return;if(h==="add"){is(k,m);return}let x=g?Vb(m,k,g):v;if(x===-1)return;let w=zb(S,x);if(w){if(h==="remove"){Zl(w,m),this.syncTargets();return}Jl(w,h==="move-up"?-1:1,m),this.syncTargets()}},toggleControls(){if(!s||!o)return;let h=!s.controlsHidden;s.setControlsHidden(h),o.toggleEl.setAttribute("aria-pressed",String(h));let d=o.toggleEl.querySelector(".mirk-button__label");d&&(d.textContent=h?"Show controls":"Hide controls")},bindPage(){let h=jn(this.ctx.pageRoot),d=o.root,v=w=>{let T=s&&s.elementToTarget(w.target);T?s.showHighlight(T.el):s?.hideHighlight(),s?.setHoveredRow(w.target)},g=()=>{s?.hideHighlight(),s?.setHoveredRow(null)},m=w=>{if(d.contains(w.target))return;let T=s&&s.elementToTarget(w.target);!T||T.kind!=="text"||l.has(T.el)||f(this.ctx,T.el,T.path.join("."),Ai(T))},k=w=>{if(d.contains(w.target))return;let T=s&&s.elementToTarget(w.target);if(!T){this.deactivate();return}(typeof w.target.closest=="function"&&w.target.closest("a[href]")||T.kind!=="text")&&w.preventDefault(),this.activate(T)},S=w=>{w.key==="Escape"&&this.deactivate()},x=w=>{let T=w.detail;if(!(!T||T.pageRoot!==jn(this.ctx.pageRoot)||!T.path))for(let N of l.values())N.path===T.path&&(N.written=!0)};h.addEventListener("pointerover",v),h.addEventListener("pointerleave",g),h.addEventListener("pointerdown",m),h.addEventListener("click",k),d.addEventListener("keydown",S),e.addEventListener("hcms:change",x),i=()=>{h.removeEventListener("pointerover",v),h.removeEventListener("pointerleave",g),h.removeEventListener("pointerdown",m),h.removeEventListener("click",k),d.removeEventListener("keydown",S),e.removeEventListener("hcms:change",x)}},activate(h,d){if(!h||!o||h.kind==="text"&&this.activateText(h))return;let v=wd(this,o,h.path.join("."));if(!v){this.deactivate();return}a=h,c=d||null,u=null,o.popTitleEl.textContent="Edit content",o.popEl.hidden=!1,o.formRoot.querySelectorAll(`.${Oo}`).forEach(da),this.placePopover(),Ad(v)},openStyle(h,d){if(!h||!o)return;let v=Sd(this,o,h.paths);if(!v){this.deactivate();return}a={kind:"style",scope:h.scope,el:h.scope==="page"?o.pageStyleEl:h.el,path:h.paths[0].split("."),paths:h.paths},c=d||null,u=null,o.popTitleEl.textContent=h.scope==="page"?"Page style":"Style",o.popEl.hidden=!1,o.formRoot.querySelectorAll(`.${Oo}`).forEach(da),this.placePopover(),Ad(v)},activateText(h){let d=h.el,v=l.get(d);if(v)return Si(v),!0;let g=f(this.ctx,d,h.path.join("."),Ai(h));return g?(Si(g),!0):!1},placePopover(){if(!o||!a||o.popEl.hidden)return;let h=e.defaultView;if(!h)return;let d={width:h.innerWidth,height:h.innerHeight},v=a.el.getBoundingClientRect(),g=o.popEl.getBoundingClientRect(),{mode:m,x:k,y:S}=dd({anchor:v,bar:g,viewport:d,current:u});u=m,o.popEl.style.transform=`translate(${Math.round(k)}px, ${Math.round(S)}px)`},deactivate(){if(!o||!a&&o.popEl.hidden)return;o.popEl.hidden=!0,ma(o.root);let h=c;if(a=null,c=null,u=null,h&&e.contains(h)&&typeof h.focus=="function")try{h.focus({preventScroll:!0})}catch{h.focus()}},syncTargets(){if(!s)return;let h=this.ctx,d=aa(h.pageRoot,h.pageRules,e),v=d.lists,g=d.targets.filter(S=>!S.style);p=ld(d.targets,v),o.pageStyleEl.hidden=!p.some(S=>S.scope==="page"),s.setTargets(d.targets,v,p);let m=Bb(this,l,g,e);if(a?.kind==="style"){let S=a.scope==="page"?p.find(x=>x.scope==="page"):p.find(x=>x.el===a.el);S?a={...a,paths:S.paths,path:S.paths[0].split(".")}:this.deactivate()}else if(a){let S=m.get(a.el)||[],x=S.find(w=>$b(w,a))||S.find(w=>w.path.join(".")===a.path.join("."))||(S.length===1?S[0]:null);x?a=x:this.deactivate()}Ub(this.ctx,l,e);let k=g.reduce((S,x)=>S+(Eo(x.el)?0:1),0);this.handoffEl&&(this.handoffCountEl.textContent=k===0?"":`${k} ${k===1?"field isn't":"fields aren't"} visible right now.`,this.handoffEl.hidden=k===0)},refresh(h,d){h==="livesync"?(yr(e),as(e),vr(this.ctx,{ignoreActiveValue:!0})):h==="undo"?vr(this.ctx,{ignoreActiveValue:!1}):vr(this.ctx),this.syncTargets(),(h==="livesync"||h==="undo")&&this.rebindText(h),this.restoreActive()},rebindText(h){let d=h!=="undo";for(let[v,g]of[...l]){if(!e.contains(v)){ds(this.ctx,g,{restore:!1,record:d}),l.delete(v);continue}if(v.hasAttribute(Dn)){let S=fs(v,g.prop);S!==g.lastEdited&&(g.oldValue=S,g.lastEdited=void 0);continue}let m=e.activeElement===v;ds(this.ctx,g,{restore:!1,record:d}),l.delete(v);let k=f(this.ctx,v,g.path,g.prop,{richClayIsOurs:g.richClayIsOurs,adopted:g.adopted});k&&m&&Si(k)}},restoreActive(){if(!o||!a||o.popEl.hidden)return;if(!e.contains(a.el)){this.deactivate();return}if(!(a.kind==="style"?Sd(this,o,a.paths):wd(this,o,a.path.join(".")))){this.deactivate();return}o.formRoot.querySelectorAll(`.${Oo}`).forEach(da),this.placePopover()},focusOnOpen(){if(this.root&&typeof this.root.focus=="function")try{this.root.focus({preventScroll:!0})}catch{this.root.focus()}},destroy(){c=null,this.deactivate();for(let h of l.values())ds(this.ctx,h);l.clear(),i?.(),i=null,s?.destroy(),s=null,o?.destroy(),o=null,ra(e),this.popEl=null,this.handoffEl=null,this.handoffCountEl=null}}}function Db(e,t,n,r,o){return or(()=>{let s=null;try{s=new t(n,{inline:!0,hyperclay:!1,toolbar:r==="innerHTML"?Pb:!1,...jb.test(n.tagName)?{singleLine:!0}:null})}catch(i){return console.warn("[hypercms] richclay activation failed; the field falls back to the popover",i),null}if(s.unsupported||!s.active){if(o)try{s.destroy()}catch{}return null}return typeof s.reattach=="function"&&s.reattach(),s})}function Fb(e,{path:t,el:n,prop:r}){let o=ci(e.formRoot,t);o&&(ui(o,fs(n,r),e.formRoot,t),Sn(bn(e),{path:t,structural:!1},e))}function fs(e,t,n="data"){let r=ua(e,{capability:n});return t==="innerHTML"?r.html():r.text().trim()}function Ed(e){let{el:t,prop:n,oldValue:r,lastEdited:o}=e,s=o;if(s===void 0||s===r)return;e.oldValue=s;let i=sn("undo");if(!i||typeof i.recordValue!="function")return;let l={prop:n,oldValue:r,newValue:s,read:a=>fs(a,n,"history"),write:(a,c)=>Od(a,n,c)};i.isPaused?queueMicrotask(()=>{t.isConnected&&i.recordValue(t,l)}):i.recordValue(t,l)}function Od(e,t,n){let r=e.cloneNode(!1);t==="innerHTML"?r.innerHTML=n:r.textContent=n,fr(e,Array.from(r.childNodes),{morphStyle:"innerHTML",policy:"history",restoreFocus:!1,scripts:{handle:!1,merge:!1}})}function ds(e,t,{restore:n=!0,record:r=!0}={}){r&&Ed(t),t.detachInput?.(),t.detachBlur?.(),or(()=>{if(!t.adopted){try{t.editor.destroy()}catch(o){console.warn("[hypercms] richclay teardown failed; editor state may reach the save",o)}t.richClayIsOurs&&t.el.removeAttribute("data-richclay")}t.el.removeAttribute(Dn),t.el.removeAttribute(qr),t.el.removeAttribute(gr),If(t.boundId),n&&t.restorable()&&Od(t.el,"innerHTML",t.originalHTML)})}function Si(e){let{editor:t,el:n}=e;if(n.ownerDocument.activeElement!==n)try{typeof t.focus=="function"?t.focus():n.focus()}catch{}}function Bb(e,t,n,r){let o=new Map;for(let s of n){let i=o.get(s.el);i?i.push(s):o.set(s.el,[s])}for(let[s,i]of[...t]){let l=o.get(s)||[],a=l.find(f=>Ai(f)===i.prop)||l[0];if(!a){ds(e.ctx,i,{restore:!0}),t.delete(s);continue}i.path=a.path.join(".");let c=Ai(a);if(c===i.prop)continue;let p=r.activeElement===s;ds(e.ctx,i,{restore:!1}),t.delete(s);let u=e.bindText(s,i.path,c,{richClayIsOurs:i.richClayIsOurs,adopted:i.adopted,originalHTML:i.originalHTML});u&&p&&Si(u)}return o}function $b(e,t){return e.el===t.el&&e.kind===t.kind&&e.attr===t.attr}function Ai(e){return e.attr==="innerHTML"?"innerHTML":"textContent"}function Ub(e,t,n){for(let r of e.pageRoot.querySelectorAll(`[${Dn}]`))t.has(r)||or(()=>Df(r,n.defaultView))}function wd(e,t,n){let r=e.formRoot&&e.formRoot.querySelector(`[data-hcms-path="${Fr(n)}"]`);if(ma(t.root),!r)return null;let o=r.closest("[data-hcms-card]"),s=o?[...o.querySelectorAll('[data-hcms-shape="scalar"][data-hcms-path]')].filter(i=>i.closest("[data-hcms-card]")===o&&i.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]')===o.parentElement.closest('[data-hcms-shape="object-array"]')):[r];s.includes(r)||s.push(r);for(let i of s)Nd(e,i);return r}function Sd(e,t,n){ma(t.root);let r=null;for(let o of n){let s=e.formRoot&&e.formRoot.querySelector(`[data-hcms-path="${Fr(o)}"]`);s&&(r=r||s,Nd(e,s))}return r}function Nd(e,t){t.classList.add(Oo),t.removeAttribute("draggable");for(let n=t.parentElement;n&&(n.classList.add(ha),n.removeAttribute("draggable"),n!==e.formRoot);n=n.parentElement);}function ma(e){if(e)for(let t of e.querySelectorAll(`.${Oo}, .${ha}`))t.classList.remove(Oo,ha)}function da(e){e.tagName==="TEXTAREA"&&yo(e),e.querySelectorAll?.("textarea").forEach(yo)}function Ad(e){let t=e.matches?.(xd)?e:e.querySelector?.(xd);if(!(!t||typeof t.focus!="function"))try{t.focus({preventScroll:!0})}catch{t.focus()}}function Hb(e,t){yr(e);let n=e.createElement(Ib),r=t==="dark"?" dark":t==="light"?" light":"";return n.className="hcms-shell pixel-quiet hcms-inline"+r,n.setAttribute("data-hcms-shell",""),n.setAttribute("editor-ui",""),n.setAttribute("no-save",""),n.setAttribute("save-remove",""),n.setAttribute("snapshot-remove",""),n.setAttribute("no-watch",""),n.setAttribute("tabindex","-1"),n.innerHTML=`
227
+ `,(e||l.body).appendChild(c);let h=l.body;h.classList.add("hcms-open"),is(l),n&&h.classList.add("hcms-overlay"),t==="left"&&h.classList.add("hcms-side-left");let v=Dg(c,l),g=qg(c);return{root:c,formRoot:c.querySelector("[data-hcms-form-root]"),noticeEl:c.querySelector(".hcms-shell-notice"),errorEl:c.querySelector(".hcms-shell-error"),saveButton:c.querySelector(".hcms-shell-save"),destroy(){v.detach(),g.detach(),c.remove(),h.classList.remove("hcms-open","hcms-overlay","hcms-side-left"),ta(l)},restoreChrome(){wo(l),h.classList.add("hcms-open"),is(l),n&&h.classList.add("hcms-overlay"),t==="left"&&h.classList.add("hcms-side-left")}}}function wo(e){e&&(e.getElementById(ui)||e.querySelector("style[data-hcms-bundled-styles]")||(xo.delete(e),zf(e)))}function zf(e){if(e&&!xo.has(e)){if(e[Lg]){xo.add(e);return}if(e.getElementById(ui)||e.querySelector("style[data-hcms-bundled-styles]")){xo.add(e);return}if(ea){let t=e.createElement("style");t.id=ui,t.setAttribute("save-remove",""),t.setAttribute("save-ignore",""),t.textContent=ea,(e.head||e.documentElement).appendChild(t),xo.add(e);return}try{let t=new URL("./theme.generated.css",Fg.url).href,n=e.createElement("link");n.rel="stylesheet",n.id=ui,n.setAttribute("save-remove",""),n.setAttribute("save-ignore",""),n.href=t,(e.head||e.documentElement).appendChild(n),xo.add(e)}catch{let n=()=>{link.isConnected&&console.warn("hypercms: shell stylesheet not applied \u2014 cssText is empty and the co-located theme fallback is unavailable. Call installStyles(themeText) before opening the CMS.")};e.defaultView?.queueMicrotask?e.defaultView.queueMicrotask(n):n()}}}function qg(e){let t=e.querySelector(".hcms-shell-body"),n=e.querySelector(".hcms-shell-header");if(!t||!n||typeof t.addEventListener!="function")return{detach(){}};let r=()=>{let o=(n.offsetHeight||0)-12;e.classList.toggle("is-condensed",t.scrollTop>o)};return t.addEventListener("scroll",r,{passive:!0}),r(),{detach(){t.removeEventListener("scroll",r)}}}function Dg(e,t){function n(r){if(r.key!=="Tab"||!e.contains(t.activeElement))return;let o=Array.from(e.querySelectorAll(Pg));if(o.length===0)return;let s=o[0],i=o[o.length-1];r.shiftKey&&t.activeElement===s?(r.preventDefault(),i.focus()):!r.shiftKey&&t.activeElement===i&&(r.preventDefault(),s.focus())}return t.addEventListener("keydown",n),{detach:()=>t.removeEventListener("keydown",n)}}var Bg="[hypercms]",Vf={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Wf={skip:"[data-hcms-shell]",templateAttr:null},na=class extends Error{constructor(t,n,r){super(`hypercms: rule at "${t}" has an invalid CSS selector: "${n}"`),this.name="InvalidRuleSelector",this.path=t,this.selector=n,this.cause=r}};function hi(e,t){let n=[],r=[],o=[];return oa(Zn(e),e,t,[],n,r,o),{missing:Kf(n),twins:Vg(r),readOnly:Kf(o)}}function mi(e){return ra(e)}function ra(e){if(typeof e=="string")return Gf(e)?void 0:e;if(Array.isArray(e)){let[t,n]=e;return[t,ra(n)]}if(e&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e)){let o=ra(r);o!==void 0&&(t[n]=o)}return t}return e}function oa(e,t,n,r,o,s,i){if(typeof n=="string"){let l=$g(n),a=l?di(e,t,l,Vf,r):[];if(Gf(n)){i.push(So(r));return}if(!l)return;if(n.endsWith("[]")){a.length===0&&di(e,t,l,Wf,r).length===0&&o.push(So(r));return}a.length===0?o.push(So(r)):a.length>1&&s.push({path:So(r),count:a.length});return}if(Array.isArray(n)){let[l,a]=n;if(typeof l!="string"||!l)return;let c=di(e,t,l,Vf,r);if(c.length===0){di(e,t,l,Wf,r).length===0&&o.push(So(r));return}for(let m of c)oa(e,m,a,[...r,"*"],o,s,i);return}if(n&&typeof n=="object")for(let[l,a]of Object.entries(n))oa(e,t,a,[...r,l],o,s,i)}function di(e,t,n,r,o){try{return e.find(t,n,r)}catch(s){throw new na(So(o),n,s)}}function $g(e){if(e==="."||e.startsWith("@"))return null;if(e.endsWith("[]"))return e.slice(0,-2)||null;let t=Kt(e);return(t===-1?e:e.slice(0,t))||null}function Ug(e){if(e.endsWith("[]"))return null;let t=Kt(e);return t===-1?null:e.slice(t+1)||null}function Gf(e){let t=Ug(e);return t!=null&&Hr.has(t)}function Ao(e){Hg(e),zg(e)}function Hg(e){let t=e.noticeEl;if(!t)return;let n=e.unresolved&&e.unresolved.missing||[],r=e.unresolved&&e.unresolved.readOnly||[];if(n.length===0&&r.length===0){t.textContent="",t.hidden=!0;return}let o=[];if(n.length){let s=n.length===1?"1 field no longer matches this page":`${n.length} fields no longer match this page`;o.push(`${s}: ${n.join(", ")}`)}if(r.length){let s=r.length===1?"1 field reads a property the browser will not let anything write":`${r.length} fields read properties the browser will not let anything write`;o.push(`${s}: ${r.join(", ")}`)}t.textContent=o.join(`
228
+ `),t.hidden=!1}function zg(e){let t=e.unresolved&&e.unresolved.twins||[],n=t.map(r=>`${r.path}:${r.count}`).join("|");if(n!==e.lastTwinSignature){e.lastTwinSignature=n;for(let{path:r,count:o}of t)console.warn(`${Bg} "${r}" matches ${o} elements; edits go to the first one.`)}}function Kf(e){return[...new Set(e)]}function Vg(e){let t=new Map;for(let n of e){let r=t.get(n.path);(!r||n.count>r.count)&&t.set(n.path,n)}return[...t.values()]}function So(e){return e.length?e.join("."):"(whole page)"}var Wg={skip:"[data-hcms-shell]",templateAttr:"cms-template"};function kr(e,{ignoreActiveValue:t}={}){return Kg(e,{ignoreActiveValue:t})}function Kg(e,{ignoreActiveValue:t}){let n=fn.findRules(e.doc,e.rulesSource||"cms");n&&(e.pageRules=e.view.prepareRules(Fs(n.rules,e.pageRoot)),e.rulesTagNode=n.tagNode),Us(e.doc),Ws(e.doc,e.pageRules),e.formRules=Ys(e.pageRules,e.doc),e.writeRules=mi(e.pageRules),e.unresolved=hi(e.pageRoot,e.pageRules);let r=Ds(),o=nr(fn.extract(e.pageRoot,e.pageRules,{...Wg,...r.hooks}),e.pageRules),s=ho({pageRules:e.pageRules,formRules:e.formRules,data:o,doc:e.doc});qs(e.formRoot,s,{ignoreActiveValue:t}),ko(e,o),r.seed(e.formRoot),gr(e.formRoot,e.doc,e.view?.enhanceFormRichText!==!1),Jl(e),Ao(e),e.updateFingerprint&&e.updateFingerprint()}function Yf({debounce:e=100,onRefresh:t}){let n=sn("Mutation");if(!n||typeof n.onAnyChange!="function")throw new Error("hypercms: a mutation hub is required (clay.Mutation or hyperclay.Mutation). Load clayjs or hyperclayjs, or just the mutation utility, before initializing hypercms.");let r=n.onAnyChange({debounce:e},o=>{t(o)});return{unsubscribe:typeof r=="function"?r:()=>{}}}var Gg='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])';function Xf({doc:e,pageRoot:t,opts:n={}}){let r=n.richText!==!1,o=null;return{name:"sidebar",richText:r,enhanceFormRichText:!0,ctx:null,root:null,formRoot:null,errorEl:null,noticeEl:null,prepareRules(s){return r?If(s,t):s},mount(s){let i=this.ctx;o=rr(()=>Hf({mountTo:n.mountTo||e.body,side:n.side||"right",overlay:!!n.overlay,showSaveButton:!!n.showSaveButton,title:n.title,eyebrow:n.eyebrow,theme:n.theme,doc:e})),this.root=o.root,this.formRoot=o.formRoot,this.errorEl=o.errorEl,this.noticeEl=o.noticeEl;let l=ho({pageRules:i.pageRules,formRules:i.formRules,data:s,doc:e});o.formRoot.appendChild(l),i.seeder.seed(o.formRoot),gr(o.formRoot,e),Ao(i),ii(i)},refresh(s){if(s==="livesync"){o?.restoreChrome?.(),kr(this.ctx,{ignoreActiveValue:!0});return}if(s==="undo"){kr(this.ctx,{ignoreActiveValue:!1});return}kr(this.ctx)},focusOnOpen(){let s=this.root&&this.root.querySelector(Gg);s&&typeof s.focus=="function"&&s.focus()},destroy(){o?.destroy(),o=null}}}var Yg="[cms-template], [data-hcms-shell]";function To(e){if(!e||typeof e.getBoundingClientRect!="function"||typeof e.closest=="function"&&e.closest(Yg))return!1;let t=e.getBoundingClientRect();return t.width>=8&&t.height>=8}var Xg={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Jg={skip:"[data-hcms-shell]",templateAttr:null},Zg="text",Qg="native",Jf="handle",eb=new Set(["INPUT","TEXTAREA","SELECT"]),ed=new Set(["IMG","INPUT","TEXTAREA","SELECT","OPTION","BR","HR","VIDEO","AUDIO","IFRAME","EMBED","OBJECT","CANVAS","SOURCE","TRACK","AREA","COL","PARAM","BUTTON","STYLE","SCRIPT","LINK","META"]);function ia(e,t,n=null){let r=[],o=[],s=Zn(e);return sa(s,e,t,[],r,o,n?(l,a)=>es(l,n,a,t):()=>null),{targets:r,lists:o}}function sa(e,t,n,r,o,s,i){if(typeof n=="string"){if(n.endsWith("[]")){let u=n.slice(0,-2);if(!u)return;let f=pi(e,t,u);f.forEach((p,h)=>{o.push(Qf([...r,h],p,n,null))}),s.push(Zf(e,t,r,u,f,!0));return}let l=Kt(n),a=l===-1?null:n.slice(l+1),c=l===-1?n:n.slice(0,l),m=!c||c==="."?t:pi(e,t,c)[0];m&&o.push(Qf(r,m,n,a,i(n,r)));return}if(Array.isArray(n)){let[l,a]=n;if(typeof l!="string"||!l)return;let c=pi(e,t,l);c.forEach((m,u)=>sa(e,m,a,[...r,u],o,s,i)),s.push(Zf(e,t,r,l,c,typeof a=="string"));return}if(n&&typeof n=="object")for(let[l,a]of Object.entries(n))sa(e,t,a,[...r,l],o,s,i)}function Zf(e,t,n,r,o,s){let i=o[0]?o[0].parentElement:null;if(!i){let l=pi(e,t,r,Jg)[0];i=l?l.parentElement:null}return{path:n,items:o,container:i,scalar:s}}function Qf(e,t,n,r,o=null){return{path:e,el:t,rule:n,attr:r,kind:tb(t,r),icon:rb(t,r),style:o}}function tb(e,t){let n=(e.tagName||"").toUpperCase();return!t||t==="innerHTML"?ed.has(n)?Jf:Zg:t==="value"&&eb.has(n)&&!e.readOnly&&!nb(e)?Qg:Jf}function nb(e){return e.disabled?!0:typeof e.matches=="function"&&e.matches(":disabled")}function rb(e,t){let n=(e.tagName||"").toUpperCase();return(!t||t==="innerHTML")&&!ed.has(n)?null:n==="IMG"||t==="srcset"?"camera":n==="A"&&t==="href"?"paperclip":"pencil"}function pi(e,t,n,r=Xg){try{return e.find(t,n,r)}catch{return[]}}function td(e,t){let n=[],r=new Map,o=null;for(let s of e){if(!s.style)continue;let i=s.path.join(".");if(s.style==="page"){o||(o={scope:"page",el:s.el,list:null,paths:[]},n.push(o)),o.paths.push(i);continue}let l=ob(s.path,t),a=l?l.row:s.el,c=r.get(a);c||(c={scope:l?"row":"section",el:a,list:l?l.list:null,paths:[]},r.set(a,c),n.push(c)),c.paths.push(i)}return n}function ob(e,t){for(let n=e.length-1;n>=0;n--){if(typeof e[n]!="number")continue;let r=e.slice(0,n).join("."),o=t.find(i=>i.path.join(".")===r),s=o&&o.items[e[n]];if(s)return{list:o,row:s}}return null}var gi=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),sb=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),n1=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function ls(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function la(e,t){if(ls(e,t))return!0;for(let[n,r]of Object.entries(sb))if(r.includes(t)&&ls(e,n))return!0;return!1}function as(e){let t=gi[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function ib(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let r=gi[t];if(!r)throw new Error(`Unknown region capability: ${t}`);if(r.tokens.some(o=>la(n,o))||r.bundles.some(o=>ls(n,o)))return n;n=n.parentElement}return null}function nd(e,t){return!!ib(e,t)}var lb=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function ab(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function rd(e,t,n,r){if(r)return!!e.closest?.(t);let o=e;for(;o?.nodeType===1;){if(o.matches(t))return!0;if(o===n)break;o=o.parentElement}return!1}function od(e,t,n,r,o,s){return(s?nd(e,t):rd(e,n,o,!1))||!!(r&&(s&&e!==o?e.matches(r):rd(e,r,o,s)))}function cb(e,t){let n=gi[t];return n.tokens.some(r=>la(e,r))||n.bundles.some(r=>ls(e,r))}var ub=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function sd(e,t,n,r){if(e.nodeType===1&&r(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let o=e,s=t;if(e.nodeType===1){if(ub.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);o=e.content,s=t.content,n.cloneToLive.set(s,o),n.liveToClone.set(o,s)}}else if(e.nodeType!==11)return;let i=s.firstChild;for(let l=o.firstChild;l&&i;l=l.nextSibling)sd(l,i,n,r),i=i.nextSibling}function aa(e,{capability:t="data",exclude:n=null,inherit:r=!0,provenance:o=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let s=e.nodeType===9?e:e.ownerDocument;if(!s?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=s.implementation.createHTMLDocument(""),l=o||new WeakMap,a=new WeakMap,c=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let m=as(t),u=r?h=>cb(h,t)||!!(n&&h.matches(n)):h=>od(h,t,m,n,c,!1),f=null;if(c.nodeType!==1||!od(c,t,m,n,c,r)){f=i.importNode(c,!0);let h={cloneToLive:l,liveToClone:a,dropped:[],controls:[]};sd(c,f,h,u);for(let v of h.dropped)v.remove();for(let v=0;v<h.controls.length;v+=2)ab(h.controls[v],h.controls[v+1])}e.nodeType===9&&f&&(i.replaceChild(f,i.documentElement),a.set(e,i),l.set(i,e));let p=h=>{if(lb.test(h))throw new Error(`Filtered content queries do not support stateful selector: ${h}`)};return{root:f,document:i,capability:t,selector:as(t),cloneToLive:l,liveToClone:a,original(h){return l.get(h)||null},cloneOf(h){return a.get(h)||null},query(h,v=f){return p(h),Array.from(v.querySelectorAll(h),g=>l.get(g)||g)},text(h=f){return(h===f?f:a.get(h))?.textContent||""},html(h=f){return(h===f?f:a.get(h))?.innerHTML??""},clone(h=f){let v=h===f?f:a.get(h);return v?i.importNode(v,!0):null}}}var fb=[16,8,0],ln=8,db=4;function id({anchor:e,bar:t,rail:n=t,viewport:r,current:o=null}){let s=f=>o===f?db:0;if(e.bottom<=0||e.top>=r.height||e.right<=0||e.left>=r.width)return{mode:"hidden",x:0,y:0};let i=f=>Math.max(ln,Math.min(e.left,r.width-f-ln)),l=e.top-16-t.height;if(l>=ln-s("above"))return{mode:"above",x:i(t.width),y:l};let a=e.bottom+16;if(a+t.height<=r.height-ln+s("below"))return{mode:"below",x:i(t.width),y:a};let c=r.width-e.right-ln,m=e.left-ln,u=c>=m?[["rail-right",c],["rail-left",m]]:[["rail-left",m],["rail-right",c]];for(let[f,p]of u)for(let h of fb){if(n.width+h>p+s(f))continue;let v=f==="rail-right"?Math.min(e.right+h,r.width-n.width-ln):Math.max(e.left-h-n.width,ln),g=Math.min(e.bottom,r.height-ln)-n.height,d=Math.max(ln,Math.min(Math.max(e.top,ln),g));return{mode:f,x:v,y:d,gap:h}}return{mode:"pinned",x:i(t.width),y:ln}}function ca({anchor:e,handle:t,viewport:n,inset:r=6,prefer:o="auto"}){let s=e.height>=t.height*1.5&&e.width>=t.width*2;if(o==="corner"||s){let f=Math.max(ln,Math.min(e.right-t.width+r,n.width-t.width-ln)),p=Math.max(ln,Math.min(e.top-r,n.height-t.height-ln));return{x:f,y:p,mode:"over"}}let i=4,l=e.right+i+t.width<=n.width-ln,a=l?e.right+i:e.left-i-t.width,c=Math.max(ln,a),m=e.top+e.height/2-t.height/2,u=Math.max(ln,Math.min(m,n.height-t.height-ln));return{x:c,y:u,mode:l?"beside-right":"beside-left"}}var ki=!1;function ld(){if(ki)return;let e=sn("onPrepareForSave");typeof e=="function"&&(e(t=>{cd(t),ad(t)}),ki=!0)}function ad(e){let t=e&&e.querySelector&&e.querySelector("body");t&&t.classList.remove("hcms-open","hcms-overlay","hcms-side-left",fi)}function cd(e){if(!(!e||typeof e.querySelectorAll!="function"))for(let t of e.querySelectorAll(`[${pr}]`)){let n=Cf(t);n!==null&&(t.innerHTML=n),t.removeAttribute(pr)}}var yi=!1;function vi(){if(yi)return;let e=sn("onSnapshot");typeof e=="function"&&(e(t=>{cd(t),Mf(t,typeof window<"u"?window:null),ad(t)}),yi=!0)}function ud(){ld(),vi(),(!ki||!yi)&&hb()}var bi=null;function hb(){if(bi||typeof document>"u")return;bi=po(document,Ef,()=>{ld(),vi(),ki&&yi&&(bi?.(),bi=null)})}var mb={edit:"M8 10h2v6H8zm2 4h4v2h-4zm0-6h2v2h-2zm2-2h2v2h-2zm2-2h2v2h-2zm2-2h2v2h-2zm2 2h2v2h-2zm2 2h2v2h-2zm-2 2h2v2h-2zm-2 2h2v2h-2zm-2 2h2v2h-2zm-4 0h2v2h-2z","move-up":"M11 4h2v2h2v2h2v2h2v2h-4v-2h-2v10h-2V10H9v2H5v-2h2V8h2V6h2z","move-down":"M11 4h2v10h2v-2h4v2h-2v2h-2v2h-2v2h-2v-2H9v-2H7v-2H5v-2h4v2h2z",remove:"M5 5h3v3h3v3h2V8h3V5h3v3h-3v3h-3v2h3v3h3v3h-3v-3h-3v-3h-2v3H8v3H5v-3h3v-3h3v-2H8V8H5z",add:"M10 4h4v6h6v4h-6v6h-4v-6H4v-4h6z"};function Dr(e){let t=e==="edit"?"6 0 18 18":"0 0 24 24",n=e==="settings"?'<circle cx="6" cy="12" r="1.5"/><circle cx="12" cy="12" r="1.5"/><circle cx="18" cy="12" r="1.5"/>':`<path d="${mb[e]}"/>`;return`<svg class="hcms-inline-icon" xmlns="http://www.w3.org/2000/svg" viewBox="${t}" width="24" height="24" fill="currentColor" aria-hidden="true" focusable="false">${n}</svg>`}var fd="data-hcms-ghost",pb=as("history");function gb(e){let t=e.container,n=null;for(;t&&(t.namespaceURI!=="http://www.w3.org/1999/xhtml"||["SELECT","OPTGROUP","DATALIST"].includes(t.tagName));)n=t,t=t.parentElement;return{parent:t,anchor:n}}function dd({doc:e,themeRoot:t,onAdd:n,onResize:r}){let o=e.defaultView,s=[],i=!1,l=null,a=new Map;function c(p,h,v){p.style[h]!==v&&(p.style[h]=v)}function m(){let p=new Set(s.map(h=>h.node.parentElement));for(let[h,v]of a)p.has(h)&&o?.Sortable?.get(h)===v.instance||(v.instance.option("draggable")===v.selector&&v.instance.option("draggable",v.original),a.delete(h));for(let h of p){let v=o?.Sortable?.get(h);if(!v)continue;let g=v.option("draggable");if(a.get(h)?.selector===g)continue;let d=g,S=`${d.trim().startsWith(">")?"> ":""}:is(${d.trim().replace(/^>\s*/,"")}):not(${pb})`;v.option("draggable",S),a.set(h,{instance:v,original:d,selector:S})}}function u(){for(let p of s){let{node:h,slot:v,list:g}=p,d=g.items.filter(k=>k.isConnected).map(k=>k.getBoundingClientRect()).filter(k=>k.width>0&&k.height>0);d.length&&(p.width=d.reduce((k,S)=>k+S.width,0)/d.length,p.height=d.reduce((k,S)=>k+S.height,0)/d.length),c(h,"width",p.width?`${Math.round(p.width)}px`:"100%"),c(v,"height",`${Math.max(48,Math.round(p.height||64))}px`),v!==h&&(v.colSpan=Math.max(1,...g.items.map(k=>[...k.children].reduce((S,x)=>S+(x.colSpan||1),0)))),h.hidden!==i&&(h.hidden=i)}m()}function f(p,h){let v=h.tagName,g=["TBODY","THEAD","TFOOT","TABLE"].includes(v),d=e.createElement(g?"tr":["UL","OL","MENU"].includes(v)?"li":"div");for(let w of[fd,"data-hcms-shell","editor-ui","no-watch","no-save","save-remove","snapshot-remove"])d.setAttribute(w,"");d.setAttribute("draggable","false"),d.setAttribute("contenteditable","false"),d.className="hcms-shell pixel-quiet hcms-inline-ghost";for(let w of["light","dark"])d.classList.toggle(w,!!t?.classList.contains(w));let k=g?e.createElement("td"):d;k!==d&&(k.className="hcms-inline-ghost-cell",d.appendChild(k));let S=e.createElement("button");S.type="button",S.className="hcms-inline-list-button hcms-inline-list-add mirk-button mirk-button--small",S.setAttribute("data-hcms-list-action","add"),S.innerHTML=`<span class="mirk-button__label">${Dr("add")}<span>Add</span></span>`,k.appendChild(S);let x={node:d,slot:k,button:S,list:p,width:0,height:0};S.addEventListener("click",w=>{w.preventDefault(),w.stopPropagation(),n(x.list)});for(let w of["pointerdown","mousedown","touchstart","click"])d.addEventListener(w,T=>T.stopPropagation());return d.addEventListener("dragstart",w=>{w.preventDefault(),w.stopPropagation()}),x}return{setLists(p){let h=new Set(s),v=[],g=new Set(s.map(k=>k.node)),d=new Set;for(let k of p||[]){if(!k.container||!k.container.isConnected)continue;let{parent:S,anchor:x}=gb(k);if(!S)continue;if(!d.has(S)){for(let N of S.querySelectorAll(`:scope > [${fd}]`))g.has(N)||N.remove();d.add(S)}let w=s.find(N=>h.has(N)&&N.list.container===k.container&&N.list.path.join(".")===k.path.join("."))||f(k,S);h.delete(w),w.list=k,w.button.setAttribute("data-hcms-list",k.path.join(".")),w.button.setAttribute("aria-label",`Add to ${k.path.join(".")||"the list"}`);let T=x||k.items.filter(N=>N.parentElement===S).at(-1);T?T.nextSibling!==w.node&&T.after(w.node):w.node.parentElement!==S&&S.appendChild(w.node),v.push(w)}for(let k of h)k.node.remove();s=v,l?.disconnect(),!l&&typeof o?.ResizeObserver=="function"&&(l=new o.ResizeObserver(()=>{u(),r?.()}));for(let k of s)for(let S of k.list.items)l?.observe(S);u()},update:u,setHidden(p){i=!!p,u()},destroy(){l?.disconnect();for(let p of s)p.node.remove();s=[],m()}}}var hd=[["move-up","Move up"],["move-down","Move down"]],bb={prefer:"corner",inset:0};function kb(e,t){return t.width<=e.width&&t.height<=e.height}function md({doc:e,layerEl:t,onActivate:n,onListAction:r,onStyle:o}){let s=e.defaultView,i=[],l=new Map,a=0,c=new Map,m=null,u=new Set,f=0,p=!1,h=null,v=null,g=null,d=null,k=new Map,S=!1,x=null,w=dd({doc:e,themeRoot:t.closest("[data-hcms-shell]"),onResize:N,onAdd:te=>r?.({action:"add",list:te,index:te.items.length})}),T=e.createElement("div");T.className="hcms-inline-highlight",T.hidden=!0,T.setAttribute("aria-hidden","true"),t.appendChild(T);function N(){if(!(f||!s)){if(typeof s.requestAnimationFrame!="function")return L();f=s.requestAnimationFrame(()=>{f=0,L()})}}let C=()=>g||d;function L(){if(!s)return;w.update();let te={width:s.innerWidth,height:s.innerHeight},Ae=C();for(let je of i){if(!je.visible){je.node.hidden=!0;continue}for(let Ge of je.members)Ge.node.hidden=S&&Ge.kind!=="handle";je.node.hidden=!1;let Fe=je.el.getBoundingClientRect(),He=je.node.getBoundingClientRect(),et=He.width,bt=je.kind==="row"&&!kb(Fe,He);if(bt&&je.el!==Ae){for(let Ge of je.members)Ge.kind==="row"&&(Ge.node.hidden=!0);He=je.node.getBoundingClientRect()}if(je.members.every(Ge=>Ge.node.hidden)){je.node.hidden=!0;continue}if(je.kind==="style"){let Ge=Math.max(8,Math.min(Fe.left,te.width-He.width-8)),Ct=Math.max(8,Math.min(Fe.top,te.height-He.height-8));je.node.style.transform=`translate(${Math.round(Ge)}px, ${Math.round(Ct)}px)`;continue}let Ft=je.kind==="handle"?null:bb,{x:yt,y:It}=ca({anchor:Fe,handle:He,viewport:te,...Ft}),en=je.members.find(Ge=>Ge.kind==="handle");if(bt&&en){let Ge=en.node.getBoundingClientRect(),Ct=ca({anchor:Fe,handle:Ge,viewport:te}),Tt=je.members.slice(je.members.indexOf(en)+1).filter(Jt=>!Jt.node.hidden).reduce((Jt,Y)=>Jt+Y.node.getBoundingClientRect().width+2,0);yt=Math.max(8+et,Math.min(te.width-8,Ct.x+Ge.width+Tt))-He.width,It=Ct.y}je.node.style.transform=`translate(${Math.round(yt)}px, ${Math.round(It)}px)`}if(x)if(!x.node.isConnected||x.node.closest("[hidden]"))O();else{let je=x.button.getBoundingClientRect(),Fe=x.menu.getBoundingClientRect();x.menu.style.left=`${Math.max(8,je.right-Fe.width)-je.left}px`,x.menu.style.right="auto",x.menu.style.top=je.bottom+6+Fe.height>te.height-8?"auto":"calc(100% + 6px)",x.menu.style.bottom=je.bottom+6+Fe.height>te.height-8?"calc(100% + 6px)":"auto"}F(),h?.()}function q(te){if(te?.closest?.("[data-hcms-ghost]"))return null;for(let Ae=te;Ae&&Ae.nodeType===1;Ae=Ae.parentElement){let je=k.get(Ae);if(je)return je}return null}function V(te){x&&!x.node.contains(te.target)&&O();let Ae=C();d=q(te.target),d&&t.contains(te.target)&&(g=null),C()!==Ae&&N()}function U(te){if(te.relatedTarget||!d)return;let Ae=C();d=null,C()!==Ae&&N()}function F(){if(!v||T.hidden)return;let te=v.getBoundingClientRect();T.style.width=`${Math.round(te.width)}px`,T.style.height=`${Math.round(te.height)}px`,T.style.transform=`translate(${Math.round(te.left)}px, ${Math.round(te.top)}px)`}function A(){if(!s||typeof s.IntersectionObserver!="function"){for(let Ae of i)Ae.visible=!0;return}m||(m=new s.IntersectionObserver(Ae=>{let je=!1;for(let Fe of Ae)for(let He of l.get(Fe.target)||[])He.visible!==Fe.isIntersecting&&(He.visible=Fe.isIntersecting,je=!0);je&&N()},{threshold:0}));let te=new Set(l.keys());for(let Ae of u)te.has(Ae)||m.unobserve(Ae);for(let Ae of te)u.has(Ae)||m.observe(Ae);u=te}function E(){p||!s||(s.addEventListener("scroll",N,{passive:!0,capture:!0}),s.addEventListener("resize",N,{passive:!0}),e.addEventListener("focusin",V),e.addEventListener("focusout",U),e.addEventListener("pointerdown",K,!0),e.addEventListener("keydown",fe,!0),p=!0)}function X(){!p||!s||(s.removeEventListener("scroll",N,{capture:!0}),s.removeEventListener("resize",N),e.removeEventListener("focusin",V),e.removeEventListener("focusout",U),e.removeEventListener("pointerdown",K,!0),e.removeEventListener("keydown",fe,!0),p=!1)}function B(te){return`${te.kind}\0${te.attr||""}`}function z(te,Ae){return te.container===Ae.container&&te.scalar===Ae.scalar}function Ce(te,Ae){return te.kind!==Ae.kind?!1:te.kind==="style"?!0:te.kind==="handle"?B(te.target)===B(Ae.target):te.kind==="row"?te.row===Ae.row&&z(te.list,Ae.list):z(te.list,Ae.list)}function Me(te,Ae){te.target=Ae;let je=Ae.path.join(".");te.node.setAttribute("data-hcms-target",je),Ae.icon?te.node.setAttribute("data-hcms-icon",Ae.icon):te.node.removeAttribute("data-hcms-icon"),te.node.setAttribute("aria-label",`Edit ${je}`)}function Be(te){let Ae=e.createElement("button");Ae.type="button",Ae.className="hcms-inline-handle mirk-button mirk-button--small",Ae.innerHTML=`<span class="mirk-button__label">${Dr("edit")}</span>`;let je={node:Ae,kind:"handle",target:te};return Me(je,te),Ae.addEventListener("click",Fe=>{Fe.preventDefault(),Fe.stopPropagation(),n?.(je.target,Ae)}),je}function me(te){let Ae=e.createElement("button");Ae.type="button",Ae.className="hcms-inline-style-chip mirk-button mirk-button--small",Ae.setAttribute("aria-label","Edit style"),Ae.innerHTML='<span class="mirk-button__label">Style</span>';let je={node:Ae,kind:"style",group:te.group};return Ae.addEventListener("click",Fe=>{Fe.preventDefault(),Fe.stopPropagation(),o?.(je.group,Ae)}),je}function Te(te,Ae){let je=e.createElement("button");return je.type="button",je.className="hcms-inline-list-button mirk-button mirk-button--small",je.setAttribute("data-hcms-list-action",te),je.setAttribute("aria-label",Ae),je.innerHTML=`<span class="mirk-button__label">${Dr(te)}${te==="add"?"<span>Add</span>":""}</span>`,je}function Xe(te,{list:Ae,row:je,rowIndex:Fe,count:He}){let et=Ae.path.join(".");te.list=Ae,te.row=je,te.index=Fe,te.count=He,te.node.setAttribute("data-hcms-list",et),te.node.setAttribute("data-hcms-row",String(Fe));for(let bt of te.node.querySelectorAll("[data-hcms-list-action]")){let Ft=bt.getAttribute("data-hcms-list-action"),yt=hd.find(([It])=>It===Ft)?.[1]||Ft;bt.setAttribute("aria-label",`${yt} ${et}.${Fe}`),bt.disabled=Ft==="move-up"&&Fe===0||Ft==="move-down"&&Fe===He-1}}function _e(te,Ae,je,Fe){let He=e.createElement("div");He.className="hcms-inline-row-controls";let et={node:He,kind:"row",list:te,row:Ae,index:je,count:Fe};for(let[bt,Ft]of hd){let yt=Te(bt,Ft);yt.addEventListener("click",It=>{It.preventDefault(),It.stopPropagation(),!yt.disabled&&r?.({action:bt,list:et.list,index:et.index,row:et.row})}),He.appendChild(yt)}return Xe(et,{list:te,row:Ae,rowIndex:je,count:Fe}),et}function O(te=!1){if(!x)return;let Ae=x;x=null,Ae.menu.hidden=!0,Ae.button.setAttribute("aria-expanded","false"),Ae.node.parentElement?.classList.remove("has-open-settings"),te&&Ae.button.isConnected&&Ae.button.focus({preventScroll:!0})}function K(te){x&&!x.node.contains(te.target)&&O()}function fe(te){if(x){if(te.key==="Escape")te.preventDefault(),te.stopPropagation(),O(!0);else if(te.key==="Tab")O(!0);else if(["ArrowDown","ArrowUp","Home","End"].includes(te.key)&&x.menu.contains(te.target)){te.preventDefault();let Ae=[...x.menu.querySelectorAll('[role="menuitem"]')],je=Ae.indexOf(te.target),Fe=te.key==="Home"?0:te.key==="End"?Ae.length-1:je===-1?0:(je+(te.key==="ArrowDown"?1:-1)+Ae.length)%Ae.length;Ae[Fe]?.focus({preventScroll:!0})}}}function ae(te,{list:Ae,row:je,rowIndex:Fe,style:He=null}){Object.assign(te,{list:Ae,row:je,index:Fe,style:He}),te.node.setAttribute("data-hcms-list",Ae.path.join(".")),te.node.setAttribute("data-hcms-row",String(Fe)),te.button.setAttribute("aria-label",`Settings ${Ae.path.join(".")}.${Fe}`),He&&!te.styleItem.isConnected?te.menu.insertBefore(te.styleItem,te.menu.firstChild):He||te.styleItem.remove()}function qe(te){let Ae=e.createElement("div");Ae.className="hcms-inline-settings";let je=Te("settings","Settings");je.setAttribute("aria-haspopup","menu"),je.setAttribute("aria-expanded","false");let Fe=e.createElement("div");Fe.className="hcms-inline-settings-menu",Fe.setAttribute("role","menu"),Fe.setAttribute("aria-label","Item settings"),Fe.hidden=!0;let He=e.createElement("button");He.type="button",He.setAttribute("role","menuitem"),He.setAttribute("data-hcms-style-action",""),He.textContent="Style";let et=e.createElement("button");et.type="button",et.setAttribute("role","menuitem"),et.setAttribute("data-hcms-list-action","remove"),et.textContent="Delete",Fe.appendChild(et),Ae.append(je,Fe);let bt={node:Ae,button:je,menu:Fe,styleItem:He,kind:"settings"};ae(bt,te);let Ft=()=>{O(),x=bt,Fe.hidden=!1,je.setAttribute("aria-expanded","true"),Ae.parentElement.classList.add("has-open-settings"),Fe.querySelector('[role="menuitem"]').focus({preventScroll:!0}),N()};return je.addEventListener("click",yt=>{yt.preventDefault(),yt.stopPropagation(),x===bt?O(!0):Ft()}),je.addEventListener("keydown",yt=>{(yt.key==="ArrowDown"||yt.key==="ArrowUp")&&(yt.preventDefault(),Ft())}),et.addEventListener("click",yt=>{yt.preventDefault(),yt.stopPropagation(),O(!0),r?.({action:"remove",list:bt.list,index:bt.index,row:bt.row})}),He.addEventListener("click",yt=>{yt.preventDefault(),yt.stopPropagation(),O(),o?.(bt.style,bt.button)}),bt}function ze(te,Ae){te.kind==="handle"?Me(te,Ae.target):te.kind==="row"?Xe(te,Ae):te.kind==="settings"?ae(te,Ae):te.kind==="style"&&(te.group=Ae.group)}function Ee(te,Ae,je,Fe,He){let et=Ae.get(je)?.find(bt=>bt.category===He);if(!et){et={el:je,category:He,members:[]},te.push(et);let bt=Ae.get(je);bt?bt.push(et):Ae.set(je,[et])}et.members.push(Fe)}function ot(te,Ae,je,Fe){let He=je.items||[];He.forEach((et,bt)=>{To(et)&&(Ee(te,Ae,et,{kind:"row",list:je,row:et,rowIndex:bt,count:He.length},"item"),Ee(te,Ae,et,{kind:"settings",list:je,row:et,rowIndex:bt,style:Fe.get(et)||null},"item"))})}function rt(te,Ae){let je=new Set(te.members),Fe=[];for(let He of Ae){let et=te.members.find(bt=>je.has(bt)&&Ce(bt,He))||(He.kind==="handle"?Be(He.target):He.kind==="row"?_e(He.list,He.row,He.rowIndex,He.count):He.kind==="style"?me(He):qe(He));je.delete(et),ze(et,He),S&&et.kind!=="handle"&&(et.node.hidden=!0),Fe.push(et)}for(let He of je)He===x&&O(),He.node.remove();Fe.sort((He,et)=>["row","handle","settings"].indexOf(He.kind)-["row","handle","settings"].indexOf(et.kind)),Fe.forEach((He,et)=>{te.node.children[et]!==He.node&&te.node.insertBefore(He.node,te.node.children[et]||null)}),te.members=Fe}function xt(te,Ae,je){let Fe=[],He=new Map,et=new Map,bt=0;for(let Ge of te||[])Ge.style||(et.has(Ge.el)||et.set(Ge.el,Ge),!(Ge.kind!=="handle"||!To(Ge.el))&&(Ee(Fe,He,Ge.el,{kind:"handle",target:Ge},"item"),bt++));let Ft=new Map;for(let Ge of je||[])Ge.scope==="row"?Ft.set(Ge.el,Ge):Ge.scope==="section"&&To(Ge.el)&&Ee(Fe,He,Ge.el,{kind:"style",group:Ge},"style");for(let Ge of Ae||[])ot(Fe,He,Ge,Ft);let yt=new Set(i),It=new Map;for(let Ge of i)It.has(Ge.el)||It.set(Ge.el,Ge.visible);let en=[];for(let Ge of Fe){let Ct=i.find(Tt=>yt.has(Tt)&&Tt.el===Ge.el&&Tt.category===Ge.category);if(!Ct){let Tt=e.createElement("div");Tt.className="hcms-inline-item-controls",Tt.setAttribute("role","group"),Ct={el:Ge.el,node:Tt,category:Ge.category,kind:Ge.category==="add"?"add":"handle",members:[],visible:It.get(Ge.el)??!1},t.appendChild(Tt)}yt.delete(Ct),Ct.el=Ge.el,Ct.category=Ge.category,rt(Ct,Ge.members),Ct.kind=Ct.members.some(Tt=>Tt.kind==="row")?"row":Ct.members.some(Tt=>Tt.kind==="handle")?"handle":Ct.members.some(Tt=>Tt.kind==="style")?"style":"add",Ct.node.setAttribute("aria-label",Ct.category==="add"?"List controls":Ct.category==="style"?"Style controls":"Item controls"),en.push(Ct)}for(let Ge of yt)Ge.node.remove();i=en,l=new Map,k=new Map;for(let Ge of i){let Ct=l.get(Ge.el);Ct?Ct.push(Ge):l.set(Ge.el,[Ge]);for(let Tt of Ge.members)Tt.kind!=="row"&&Tt.kind!=="settings"||(k.set(Tt.row,Tt.row),k.set(Tt.node,Tt.row),k.set(Ge.node,Tt.row))}g&&!k.has(g)&&(g=null),d&&!k.has(d)&&(d=null),c=et,a=bt}function nt(){O(),m?.disconnect(),m=null,u=new Set;for(let te of i)te.node.remove();i=[],l=new Map,c=new Map,k=new Map,a=0}return{setTargets(te,Ae,je=[]){xt(te,Ae,je),w.setLists(Ae),A(),E(),N()},refresh:N,get count(){return a},get controlsHidden(){return S},setControlsHidden(te){if(S=!!te,w.setHidden(S),S){O();for(let Ae of i){for(let je of Ae.members)je.kind!=="handle"&&(je.node.hidden=!0);Ae.members.every(je=>je.node.hidden)&&(Ae.node.hidden=!0)}}N()},elementToTarget(te){if(te?.closest?.("[data-hcms-ghost]"))return null;for(let Ae=te;Ae&&Ae.nodeType===1;Ae=Ae.parentElement){let je=c.get(Ae);if(je)return je}return null},setHoveredRow(te){let Ae=C();g=te?q(te):null,C()!==Ae&&N()},showHighlight(te){te&&(v=te,T.hidden=!1,F())},hideHighlight(){v=null,T.hidden=!0},setFollower(te){h=typeof te=="function"?te:null},destroy(){w.destroy(),f&&s&&s.cancelAnimationFrame(f),f=0,h=null,v=null,g=null,d=null,T.remove(),X(),nt()}}}var yb="hypercms-inline",Eo="is-hcms-inline-active",fa="is-hcms-inline-onpath",pd='input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex]:not([tabindex="-1"])',vb=["bold","italic","link","undo","redo"],xb=/^H[1-6]$/,wb=0;function yd({doc:e,pageRoot:t,opts:n={}}){let r=n.richText!==!1,o=null,s=null,i=null,l=new Map,a=null,c=null,m=[],u=null;function f(p,h,v,g,d){let k=go(e.defaultView);if(typeof k!="function")return null;let S=d||{},x=S.originalHTML??aa(h,{capability:"history"}).html(),w=S.richClayIsOurs??!h.hasAttribute("data-richclay"),T=S.adopted??h.getAttribute("data-richclay-active")==="true",N=cs(h,g,"history"),C=Sb(p,k,h,g,w);if(!C)return null;_f(h,g==="innerHTML",w);let L=String(++wb);h.setAttribute(pr,L),vi();let q={el:h,editor:C,path:v,prop:g,boundId:L,originalHTML:x,oldValue:N,richClayIsOurs:w,adopted:T,dirty:!1,written:!1,restorable(){return!this.adopted&&!this.dirty&&!this.written},lastEdited:void 0};l.set(h,q),Of(L,q);let V=C.squire;if(V&&typeof V.addEventListener=="function"){let F=()=>{q.dirty=!0,q.lastEdited=cs(h,q.prop,"history"),Ab(p,q)};V.addEventListener("input",F),q.detachInput=()=>V.removeEventListener?.("input",F)}let U=()=>vd(q);return h.addEventListener("blur",U),q.detachBlur=()=>h.removeEventListener("blur",U),q}return{name:"inline",richText:r,ctx:null,root:null,formRoot:null,errorEl:null,noticeEl:null,handoffEl:null,handoffCountEl:null,popEl:null,enhanceFormRichText:!1,prepareRules(p){return r?Lf(p,t):p},bindText(p,h,v,g){return f(this.ctx,p,h,v,g)},mount(p){let h=this.ctx;o=Nb(e,n.theme),this.root=o.root,this.formRoot=o.formRoot,this.errorEl=o.errorEl,this.noticeEl=o.noticeEl,this.handoffEl=o.handoffEl,this.handoffCountEl=o.handoffCountEl,this.popEl=o.popEl,rr(()=>is(e));let v=ho({pageRules:h.pageRules,formRules:h.formRules,data:p,doc:e});o.formRoot.appendChild(v),h.seeder.seed(o.formRoot),gr(o.formRoot,e,this.enhanceFormRichText),Ao(h),ii(h),s=md({doc:e,layerEl:o.layerEl,onActivate:(g,d)=>this.activate(g,d),onListAction:g=>this.listAction(g),onStyle:(g,d)=>this.openStyle(g,d)}),s.setFollower(()=>this.placePopover()),o.closeEl.addEventListener("click",()=>this.deactivate()),o.toggleEl.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),this.toggleControls()}),o.pageStyleEl.addEventListener("click",g=>{g.preventDefault(),g.stopPropagation();let d=m.find(k=>k.scope==="page");d&&this.openStyle(d,o.pageStyleEl)}),o.handoffEl.querySelector("[data-hcms-open-view]").addEventListener("click",g=>{g.preventDefault(),g.stopPropagation(),h.onViewRequested?.("sidebar")}),this.bindPage(),this.syncTargets()},listAction({action:p,list:h,index:v,row:g}){let d=this.ctx,k=h.path.join("."),S=d.formRoot.querySelector(`[data-hcms-path="${qr(k)}"]`);if(!S)return;if(p==="add"){os(k,d);return}let x=g?_b(d,k,g):v;if(x===-1)return;let w=Cb(S,x);if(w){if(p==="remove"){Xl(w,d),this.syncTargets();return}Yl(w,p==="move-up"?-1:1,d),this.syncTargets()}},toggleControls(){if(!s||!o)return;let p=!s.controlsHidden;s.setControlsHidden(p),o.toggleEl.setAttribute("aria-pressed",String(p));let h=o.toggleEl.querySelector(".mirk-button__label");h&&(h.textContent=p?"Show controls":"Hide controls")},bindPage(){let p=Pn(this.ctx.pageRoot),h=o.root,v=w=>{let T=s&&s.elementToTarget(w.target);T?s.showHighlight(T.el):s?.hideHighlight(),s?.setHoveredRow(w.target)},g=()=>{s?.hideHighlight(),s?.setHoveredRow(null)},d=w=>{if(h.contains(w.target))return;let T=s&&s.elementToTarget(w.target);!T||T.kind!=="text"||l.has(T.el)||f(this.ctx,T.el,T.path.join("."),wi(T))},k=w=>{if(h.contains(w.target))return;let T=s&&s.elementToTarget(w.target);if(!T){this.deactivate();return}(typeof w.target.closest=="function"&&w.target.closest("a[href]")||T.kind!=="text")&&w.preventDefault(),this.activate(T)},S=w=>{w.key==="Escape"&&this.deactivate()},x=w=>{let T=w.detail;if(!(!T||T.pageRoot!==Pn(this.ctx.pageRoot)||!T.path))for(let N of l.values())N.path===T.path&&(N.written=!0)};p.addEventListener("pointerover",v),p.addEventListener("pointerleave",g),p.addEventListener("pointerdown",d),p.addEventListener("click",k),h.addEventListener("keydown",S),e.addEventListener("hcms:change",x),i=()=>{p.removeEventListener("pointerover",v),p.removeEventListener("pointerleave",g),p.removeEventListener("pointerdown",d),p.removeEventListener("click",k),h.removeEventListener("keydown",S),e.removeEventListener("hcms:change",x)}},activate(p,h){if(!p||!o||p.kind==="text"&&this.activateText(p))return;let v=gd(this,o,p.path.join("."));if(!v){this.deactivate();return}a=p,c=h||null,u=null,o.popTitleEl.textContent="Edit content",o.popEl.hidden=!1,o.formRoot.querySelectorAll(`.${Eo}`).forEach(ua),this.placePopover(),kd(v)},openStyle(p,h){if(!p||!o)return;let v=bd(this,o,p.paths);if(!v){this.deactivate();return}a={kind:"style",scope:p.scope,el:p.scope==="page"?o.pageStyleEl:p.el,path:p.paths[0].split("."),paths:p.paths},c=h||null,u=null,o.popTitleEl.textContent=p.scope==="page"?"Page style":"Style",o.popEl.hidden=!1,o.formRoot.querySelectorAll(`.${Eo}`).forEach(ua),this.placePopover(),kd(v)},activateText(p){let h=p.el,v=l.get(h);if(v)return xi(v),!0;let g=f(this.ctx,h,p.path.join("."),wi(p));return g?(xi(g),!0):!1},placePopover(){if(!o||!a||o.popEl.hidden)return;let p=e.defaultView;if(!p)return;let h={width:p.innerWidth,height:p.innerHeight},v=a.el.getBoundingClientRect(),g=o.popEl.getBoundingClientRect(),{mode:d,x:k,y:S}=id({anchor:v,bar:g,viewport:h,current:u});u=d,o.popEl.style.transform=`translate(${Math.round(k)}px, ${Math.round(S)}px)`},deactivate(){if(!o||!a&&o.popEl.hidden)return;o.popEl.hidden=!0,da(o.root);let p=c;if(a=null,c=null,u=null,p&&e.contains(p)&&typeof p.focus=="function")try{p.focus({preventScroll:!0})}catch{p.focus()}},syncTargets(){if(!s)return;let p=this.ctx,h=ia(p.pageRoot,p.pageRules,e),v=h.lists,g=h.targets.filter(S=>!S.style);m=td(h.targets,v),o.pageStyleEl.hidden=!m.some(S=>S.scope==="page"),s.setTargets(h.targets,v,m);let d=Tb(this,l,g,e);if(a?.kind==="style"){let S=a.scope==="page"?m.find(x=>x.scope==="page"):m.find(x=>x.el===a.el);S?a={...a,paths:S.paths,path:S.paths[0].split(".")}:this.deactivate()}else if(a){let S=d.get(a.el)||[],x=S.find(w=>Eb(w,a))||S.find(w=>w.path.join(".")===a.path.join("."))||(S.length===1?S[0]:null);x?a=x:this.deactivate()}Ob(this.ctx,l,e);let k=g.reduce((S,x)=>S+(To(x.el)?0:1),0);this.handoffEl&&(this.handoffCountEl.textContent=k===0?"":`${k} ${k===1?"field isn't":"fields aren't"} visible right now.`,this.handoffEl.hidden=k===0)},refresh(p,h){p==="livesync"?(wo(e),is(e),kr(this.ctx,{ignoreActiveValue:!0})):p==="undo"?kr(this.ctx,{ignoreActiveValue:!1}):kr(this.ctx),this.syncTargets(),(p==="livesync"||p==="undo")&&this.rebindText(p),this.restoreActive()},rebindText(p){let h=p!=="undo";for(let[v,g]of[...l]){if(!e.contains(v)){us(this.ctx,g,{restore:!1,record:h}),l.delete(v);continue}if(v.hasAttribute(qn)){let S=cs(v,g.prop);S!==g.lastEdited&&(g.oldValue=S,g.lastEdited=void 0);continue}let d=e.activeElement===v;us(this.ctx,g,{restore:!1,record:h}),l.delete(v);let k=f(this.ctx,v,g.path,g.prop,{richClayIsOurs:g.richClayIsOurs,adopted:g.adopted});k&&d&&xi(k)}},restoreActive(){if(!o||!a||o.popEl.hidden)return;if(!e.contains(a.el)){this.deactivate();return}if(!(a.kind==="style"?bd(this,o,a.paths):gd(this,o,a.path.join(".")))){this.deactivate();return}o.formRoot.querySelectorAll(`.${Eo}`).forEach(ua),this.placePopover()},focusOnOpen(){if(this.root&&typeof this.root.focus=="function")try{this.root.focus({preventScroll:!0})}catch{this.root.focus()}},destroy(){c=null,this.deactivate();for(let p of l.values())us(this.ctx,p);l.clear(),i?.(),i=null,s?.destroy(),s=null,o?.destroy(),o=null,ta(e),this.popEl=null,this.handoffEl=null,this.handoffCountEl=null}}}function Sb(e,t,n,r,o){return rr(()=>{let s=null;try{s=new t(n,{inline:!0,hyperclay:!1,toolbar:r==="innerHTML"?vb:!1,...xb.test(n.tagName)?{singleLine:!0}:null})}catch(i){return console.warn("[hypercms] richclay activation failed; the field falls back to the popover",i),null}if(s.unsupported||!s.active){if(o)try{s.destroy()}catch{}return null}return typeof s.reattach=="function"&&s.reattach(),s})}function Ab(e,{path:t,el:n,prop:r}){let o=li(e.formRoot,t);o&&(ai(o,cs(n,r),e.formRoot,t),Sn(bn(e),{path:t,structural:!1},e))}function cs(e,t,n="data"){let r=aa(e,{capability:n});return t==="innerHTML"?r.html():r.text().trim()}function vd(e){let{el:t,prop:n,oldValue:r,lastEdited:o}=e,s=o;if(s===void 0||s===r)return;e.oldValue=s;let i=sn("undo");if(!i||typeof i.recordValue!="function")return;let l={prop:n,oldValue:r,newValue:s,read:a=>cs(a,n,"history"),write:(a,c)=>xd(a,n,c)};i.isPaused?queueMicrotask(()=>{t.isConnected&&i.recordValue(t,l)}):i.recordValue(t,l)}function xd(e,t,n){let r=e.cloneNode(!1);t==="innerHTML"?r.innerHTML=n:r.textContent=n,ur(e,Array.from(r.childNodes),{morphStyle:"innerHTML",policy:"history",restoreFocus:!1,scripts:{handle:!1,merge:!1}})}function us(e,t,{restore:n=!0,record:r=!0}={}){r&&vd(t),t.detachInput?.(),t.detachBlur?.(),rr(()=>{if(!t.adopted){try{t.editor.destroy()}catch(o){console.warn("[hypercms] richclay teardown failed; editor state may reach the save",o)}t.richClayIsOurs&&t.el.removeAttribute("data-richclay")}t.el.removeAttribute(qn),t.el.removeAttribute(Pr),t.el.removeAttribute(pr),Nf(t.boundId),n&&t.restorable()&&xd(t.el,"innerHTML",t.originalHTML)})}function xi(e){let{editor:t,el:n}=e;if(n.ownerDocument.activeElement!==n)try{typeof t.focus=="function"?t.focus():n.focus()}catch{}}function Tb(e,t,n,r){let o=new Map;for(let s of n){let i=o.get(s.el);i?i.push(s):o.set(s.el,[s])}for(let[s,i]of[...t]){let l=o.get(s)||[],a=l.find(f=>wi(f)===i.prop)||l[0];if(!a){us(e.ctx,i,{restore:!0}),t.delete(s);continue}i.path=a.path.join(".");let c=wi(a);if(c===i.prop)continue;let m=r.activeElement===s;us(e.ctx,i,{restore:!1}),t.delete(s);let u=e.bindText(s,i.path,c,{richClayIsOurs:i.richClayIsOurs,adopted:i.adopted,originalHTML:i.originalHTML});u&&m&&xi(u)}return o}function Eb(e,t){return e.el===t.el&&e.kind===t.kind&&e.attr===t.attr}function wi(e){return e.attr==="innerHTML"?"innerHTML":"textContent"}function Ob(e,t,n){for(let r of e.pageRoot.querySelectorAll(`[${qn}]`))t.has(r)||rr(()=>Rf(r,n.defaultView))}function gd(e,t,n){let r=e.formRoot&&e.formRoot.querySelector(`[data-hcms-path="${qr(n)}"]`);if(da(t.root),!r)return null;let o=r.closest("[data-hcms-card]"),s=o?[...o.querySelectorAll('[data-hcms-shape="scalar"][data-hcms-path]')].filter(i=>i.closest("[data-hcms-card]")===o&&i.closest('[data-hcms-shape="object-array"], [data-hcms-shape="scalar-array"]')===o.parentElement.closest('[data-hcms-shape="object-array"]')):[r];s.includes(r)||s.push(r);for(let i of s)wd(e,i);return r}function bd(e,t,n){da(t.root);let r=null;for(let o of n){let s=e.formRoot&&e.formRoot.querySelector(`[data-hcms-path="${qr(o)}"]`);s&&(r=r||s,wd(e,s))}return r}function wd(e,t){t.classList.add(Eo),t.removeAttribute("draggable");for(let n=t.parentElement;n&&(n.classList.add(fa),n.removeAttribute("draggable"),n!==e.formRoot);n=n.parentElement);}function da(e){if(e)for(let t of e.querySelectorAll(`.${Eo}, .${fa}`))t.classList.remove(Eo,fa)}function ua(e){e.tagName==="TEXTAREA"&&bo(e),e.querySelectorAll?.("textarea").forEach(bo)}function kd(e){let t=e.matches?.(pd)?e:e.querySelector?.(pd);if(!(!t||typeof t.focus!="function"))try{t.focus({preventScroll:!0})}catch{t.focus()}}function Nb(e,t){wo(e);let n=e.createElement(yb),r=t==="dark"?" dark":t==="light"?" light":"";return n.className="hcms-shell pixel-quiet hcms-inline"+r,n.setAttribute("data-hcms-shell",""),n.setAttribute("editor-ui",""),n.setAttribute("no-save",""),n.setAttribute("save-remove",""),n.setAttribute("snapshot-remove",""),n.setAttribute("no-watch",""),n.setAttribute("tabindex","-1"),n.innerHTML=`
229
229
  <div class="hcms-inline-bar">
230
230
  <div class="hcms-inline-handoff" hidden>
231
231
  <span class="hcms-inline-handoff-count"></span>
@@ -247,59 +247,12 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
247
247
  <div class="hcms-inline-pop-header">
248
248
  <span class="hcms-inline-pop-title">Edit content</span>
249
249
  <button type="button" class="hcms-inline-pop-close mirk-button mirk-button--small" aria-label="Close field editor">
250
- <span class="mirk-button__label">${Br("remove")}</span>
250
+ <span class="mirk-button__label">${Dr("remove")}</span>
251
251
  </button>
252
252
  </div>
253
253
  <div data-hcms-form-root class="hcms-form"></div>
254
254
  </div>
255
- `,e.body.appendChild(n),{root:n,formRoot:n.querySelector("[data-hcms-form-root]"),noticeEl:n.querySelector(".hcms-inline-notice"),errorEl:n.querySelector(".hcms-inline-error"),handoffEl:n.querySelector(".hcms-inline-handoff"),handoffCountEl:n.querySelector(".hcms-inline-handoff-count"),layerEl:n.querySelector(".hcms-inline-layer"),popEl:n.querySelector(".hcms-inline-pop"),closeEl:n.querySelector(".hcms-inline-pop-close"),toggleEl:n.querySelector("[data-hcms-controls-toggle]"),pageStyleEl:n.querySelector("[data-hcms-page-style-open]"),popTitleEl:n.querySelector(".hcms-inline-pop-title"),destroy(){n.remove()}}}function zb(e,t){let n=e.querySelector(".hcms-array-items");return n&&n.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")[t]||null}function Vb(e,t,n){let{lists:r}=aa(e.pageRoot,e.pageRules),o=r.find(s=>s.path.join(".")===t);return o?o.items.indexOf(n):-1}var Wb="[hypercms]";function Cd(e,t){if(!e||!e.querySelectorAll||!t)return;let n=Kb(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(o=>{let s=o.getAttribute("data-hcms-tpl");s&&(s.startsWith("@")||n.has(s)||console.warn(`${Wb} template "${s}" doesn't match any rule path; ignored`))})}function Kb(e){let t=new Set;return n([],e),t;function n(r,o){let s=r.join("."),i=r.map(a=>typeof a=="number"?"*":a).join(".");s&&t.add(s),i&&t.add(i);let l=pr(o);if(l==="object")for(let[a,c]of Object.entries(o))n([...r,a],c);else if(l==="object-array"||l==="scalar-array"){let a=[...r,"*"],c=a.map(p=>typeof p=="number"?"*":p).join(".");if(t.add(c),l==="object-array"){let p=o[1];if(p&&typeof p=="object"&&!Array.isArray(p))for(let[u,f]of Object.entries(p))n([...a,u],f)}}}}var pa={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Tt={isOpen:!1,ctx:null,opts:null};function Md({view:e,doc:t,pageRoot:n,opts:r={},onCloseRequested:o,onViewRequested:s}){let i=r.rules!==void 0?r.rules:"cms",l=un.findRules(t,i);if(!l){let g=typeof i=="string"?`data-rules-name~="${i}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${g}`)}let a=e.prepareRules($s(l.rules,n)),c=l.tagNode;zs(t),Gs(t,a),Cd(t,a);let p=Js(a,t),u=gi(a),f=pi(n,a),h=Bs(),d=rr(un.extract(n,a,{...pa,...h.hooks}),a),v={doc:t,pageRoot:n,pageRules:a,writeRules:u,formRules:p,rulesTagNode:c,rulesSource:i,richText:e.richText,view:e,seeder:h,initialData:d,get formRoot(){return e.formRoot},get shellRoot(){return e.root},get errorEl(){return e.errorEl},get noticeEl(){return e.noticeEl},unresolved:f,lastTwinSignature:null,lastFingerprint:null,lastData:null,observerHandle:null,undoUnsub:null,livesyncUnsub:null,onChange:r.onChange,onError:r.onError,confirmRemove:r.confirmRemove,previouslyFocused:t.activeElement,quiesced:!1,dispatch(g,m){let k=t.defaultView&&t.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!k)return;let S={...m||{},pageRoot:jn(n),view:e.name},x=new k(g,{bubbles:!0,cancelable:g==="hcms:change",detail:S});(e.root&&e.root.isConnected!==!1?e.root:jn(n)).dispatchEvent(x)},onCloseRequested:o,onViewRequested:s};return v.updateFingerprint=()=>{v.lastFingerprint=ls(bn(v))},e.ctx=v,v}function Rd(e){e.updateFingerprint(),vo(e,rr(un.extract(e.pageRoot,e.pageRules,pa),e.pageRules)),e.observerHandle=td({onRefresh:r=>e.view.refresh("observer",r)});let t=sn("undo");if(t&&typeof t.on=="function"){let r=()=>{if(Tt.ctx!==e)return;_d(e,"undo");let o=rr(un.extract(e.pageRoot,e.pageRules,pa),e.pageRules);ls(o)!==ls(e.lastData)&&(e.lastData=o,e.onChange?.(o,{path:"",structural:!1}))};t.on("undo",r),t.on("redo",r),e.undoUnsub=()=>{t.off("undo",r),t.off("redo",r)}}let n=()=>_d(e,"livesync");e.livesyncUnsub=bo(e.doc,Mf,n),ka.ctx=e,Xb(e.doc)}function _d(e,t){Tt.ctx===e&&e.view.refresh(t)}function hs(e,{dispatch:t=!0,restoreFocus:n=!0,updateUrl:r=!0,reason:o="close"}={}){if(!e||e.closed)return;e.closed=!0;for(let i of e.uploads||[])try{i.abort()}catch{}e.uploads?.clear();let s=e.previouslyFocused;if(t&&e.dispatch("hcms:close",{reason:o}),r&&Jb(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),or(()=>e.view.destroy()),Gb(),n&&typeof s?.focus=="function")try{s.focus()}catch{}}function Gb(){Tt.isOpen=!1,Tt.ctx=null,Tt.opts=null,ka.ctx=null}function No(e){let t=e||(typeof window<"u"?window:null),n=t&&t.clay?t.clay.modeLifecycle:null;return n&&typeof n.canWrite=="function"?n:null}function Ti(e){let t=No(e);if(!t)return!0;try{return t.canWrite()!==!1}catch{return!1}}var Yb="[data-hcms-uploading]";function ba(e){if(!e)return[];let t=[];return e.uploads&&e.uploads.size>0&&t.push("upload"),e.pageRoot&&typeof e.pageRoot.querySelector=="function"&&e.pageRoot.querySelector(Yb)&&t.push("preview"),t}function Ld(e){if(!e||e.closed)return{ok:!0};let t=ba(e);return t.length?{ok:!1,code:"pending-input",pending:t}:(e.quiesced=!0,{ok:!0})}function Id(e){!e||e.closed||(e.quiesced=!1)}var ka={ctx:null};function Xb(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let n=function(){let o=ka.ctx;if(o)return fi(o.formRoot),Dr("Reorder",()=>Sn(bn(o),{path:"",structural:!0},o))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=n),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=n)}var ga="cms";function Pd(e){let t=typeof e=="string"?e:"",n=t.indexOf("?"),r=n===-1?t:t.slice(n+1);if(!r)return t;let o=new URLSearchParams(r);return o.get(ga)!=="true"?t:(o.set(ga,"false"),"?"+o.toString())}function jd(e){let t=typeof e=="string"?e:"",n=t.indexOf("?"),r=n===-1?t:t.slice(n+1);return r?new URLSearchParams(r).get(ga)==="true":!1}function Jb(){if(typeof window>"u"||!window.location||!window.history||typeof window.history.replaceState!="function")return;let e=window.location.search,t=Pd(e);t!==e&&window.history.replaceState(window.history.state,"",t+window.location.hash)}var qd="hcms-toggle",An="data-hcms-toggle-host",Dd="hcms-toggle-style",Fd="data-hcms-toggle-style",Ei="data-hcms-session",Zb="var(--hcms-toggle-bg, var(--hcms-toggle-_surface))",Qb="#fafafa",e0="#0a0a0a",t0=`
256
- [${An}] {
257
- all: unset;
258
- box-sizing: border-box;
259
- display: var(--hcms-toggle-display, inline-flex);
260
- font-family: 'Departure Mono', ui-monospace, Menlo, monospace;
261
- --hcms-toggle-_surface: ${Qb};
262
- }
263
- [${An}][data-hcms-surface="dark"] {
264
- --hcms-toggle-_surface: ${e0};
265
- }
266
- [${An}] .hcms-toggle__main {
267
- all: unset;
268
- box-sizing: border-box;
269
- display: inline-flex;
270
- align-items: center;
271
- gap: 7px;
272
- padding: 0 14px;
273
- min-height: 40px;
274
- font-family: inherit;
275
- font-weight: 400;
276
- line-height: 1.5;
277
- font-size: 14px;
278
- color: var(--hcms-toggle-color, currentColor);
279
- border: 2px solid;
280
- border-color: var(--mirk-bevel-tl, #F0E7D8) var(--mirk-bevel-br, #E2D4BF) var(--mirk-bevel-br, #E2D4BF) var(--mirk-bevel-tl, #F0E7D8);
281
- border-radius: 0;
282
- cursor: pointer;
283
- box-shadow: none;
284
- }
285
- [${An}] .hcms-toggle__main:hover {
286
- border-color: var(--mirk-focus-color, #C7AE93);
287
- box-shadow: none;
288
- }
289
- [${An}] .hcms-toggle__main:active {
290
- border-color: var(--mirk-bevel-br, #E2D4BF) var(--mirk-bevel-tl, #F0E7D8) var(--mirk-bevel-tl, #F0E7D8) var(--mirk-bevel-br, #E2D4BF);
291
- }
292
- [${An}] .hcms-toggle__main:focus-visible {
293
- outline: 2px solid currentColor;
294
- outline-offset: -5px;
295
- }
296
- [${An}] .hcms-toggle__close { display: none; }
297
- [${An}][${Ei}="open"] .hcms-toggle__open { display: none; }
298
- [${An}][${Ei}="open"] .hcms-toggle__close { display: inline; }
299
- @media (pointer: coarse) {
300
- [${An}] .hcms-toggle__main { min-height: 44px; }
301
- }
302
- `;function n0({search:e="",cookie:t="",forced:n=null}={}){let r=typeof e=="string"?e:"",o=r.indexOf("?"),s=o===-1?r:r.slice(o+1),i=new URLSearchParams(s).get("editmode");return i?i==="true":n!=null?!!n:/(?:^|;\s*)isAdminOfCurrentResource=[^;]/.test(t)}var ya=new WeakMap;function Wd(e,t){try{e.globalCompositeOperation="copy",e.fillStyle=t,e.fillRect(0,0,1,1);let n=e.getImageData(0,0,1,1).data;return{r:n[0],g:n[1],b:n[2],a:n[3]/255}}catch{return null}}function r0(e){if(ya.has(e))return ya.get(e);let t=null;try{let n=e.createElement("canvas");if(n.width=n.height=1,t=n.getContext?n.getContext("2d",{willReadFrequently:!0}):null,t){let r=Wd(t,"rgb(1, 2, 3)");(!r||r.r!==1||r.g!==2||r.b!==3||r.a!==1)&&(t=null)}}catch{t=null}return ya.set(e,t),t}function o0(e,t){let n=String(e??"").trim();if(!n)return null;let r=s0(n);if(r)return r;let o=t&&t.defaultView;if(!o||!o.CSS||typeof o.CSS.supports!="function"||!o.CSS.supports("color",n))return null;let s=r0(t);return s?Wd(s,n):null}function s0(e){let t=/rgba?\(([^)]+)\)/.exec(String(e??""));if(!t)return null;let n=t[1].split(/[\s,/]+/).filter(Boolean);if(n.length<3)return null;let r=n.slice(0,3).map(Number);if(r.some(Number.isNaN))return null;let o=n[3],s=o===void 0?1:o.endsWith("%")?Number(o.slice(0,-1))/100:Number(o);return{r:r[0],g:r[1],b:r[2],a:Number.isNaN(s)?1:s}}function Bd({r:e,g:t,b:n}){let r=o=>{let s=o/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4};return .2126*r(e)+.7152*r(t)+.0722*r(n)}function $d(e,t){let n=Bd(e),r=Bd(t);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}var Ud={r:10,g:10,b:10},Hd={r:250,g:250,b:250};function zd(e,t){let n=e.a==null?1:e.a;return{r:e.r*n+t.r*(1-n),g:e.g*n+t.g*(1-n),b:e.b*n+t.b*(1-n)}}function i0(e){if(!e)return"light";let t=$d(zd(e,Ud),Ud),n=$d(zd(e,Hd),Hd);return t>n?"dark":"light"}function Vd(e,t){for(let[n,r]of Object.entries(t))e.style.setProperty(n,r,"important")}function va(e){let t=e.ownerDocument&&e.ownerDocument.defaultView,n=e.querySelector(".hcms-toggle__main");if(!t||!n||typeof t.getComputedStyle!="function")return;let r=o0(t.getComputedStyle(n).color,e.ownerDocument);e.setAttribute("data-hcms-surface",i0(r))}function l0(e){va(e);let t=e.ownerDocument,n=t&&t.defaultView;if(!n)return;let r=0,o=()=>{if(!r){if(typeof n.requestAnimationFrame!="function")return e.isConnected?va(e):l();r=n.requestAnimationFrame(()=>{if(r=0,!e.isConnected)return l();va(e)})}};typeof n.requestAnimationFrame=="function"&&o(),t.readyState!=="complete"&&n.addEventListener("load",o,{once:!0});let s=typeof n.MutationObserver=="function"?new n.MutationObserver(o):null;s&&(s.observe(t.documentElement,{attributes:!0}),t.body&&s.observe(t.body,{attributes:!0}));let i=typeof n.matchMedia=="function"?n.matchMedia("(prefers-color-scheme: dark)"):null;i&&typeof i.addEventListener=="function"&&i.addEventListener("change",o);function l(){s&&s.disconnect(),i&&typeof i.removeEventListener=="function"&&i.removeEventListener("change",o)}}function a0({open:e,close:t,isOpen:n,getTheme:r=()=>null},o=document){let s=o.querySelector(`[${An}]`);if(s)return s;if(!o.querySelector(`[${Fd}]`)){let h=o.createElement("style");h.setAttribute(Fd,""),h.setAttribute("editor-ui",""),o.getElementById(Dd)||(h.id=Dd),h.setAttribute("no-save",""),h.setAttribute("snapshot-remove",""),h.setAttribute("save-ignore",""),h.textContent=t0,o.head.insertBefore(h,o.head.firstChild)}let i=o.createElement("hypercms-toggle");i.className="hcms-shell pixel-quiet",o.getElementById(qd)||(i.id=qd),i.setAttribute(An,""),i.setAttribute("editor-ui",""),i.setAttribute("no-save",""),i.setAttribute("snapshot-remove",""),i.setAttribute("save-ignore",""),i.innerHTML='<button type="button" class="hcms-toggle__main mirk-button"><span class="hcms-toggle__open">Edit content</span><span class="hcms-toggle__close">Close editor</span></button>';let l=i.querySelector(".hcms-toggle__main");Vd(i,{position:"fixed",right:"calc(var(--hcms-toggle-offset, 16px) + var(--hcms-toggle-shift, 0px))",bottom:"calc(var(--hcms-toggle-offset, 16px) + env(safe-area-inset-bottom, 0px))","z-index":"var(--hcms-toggle-z, 2147482900)"}),Vd(l,{background:Zb});function a(h){let d=o.defaultView;if(!No(d))return null;let v=d.clay&&d.clay.setMode;return typeof v!="function"?null:v.call(d.clay,h)}function c(){let h=o.defaultView;return h&&h.clay?h.clay.mode:null}async function p(){if(n()){let v=a("view");if(v)return v;t();return}if(c()==="edit")return e();let h=a("edit");if(!h)return e();let d=await h;if(!(d&&d.ok===!1))return e()}async function u(h){try{await h()}catch(d){console.warn("hypercms: toggle failed to open the CMS",d)}}i.addEventListener("click",async()=>{await u(p)});let f=h=>{let d=r();i.classList.toggle("light",d==="light"),i.classList.toggle("dark",d==="dark"),h?i.setAttribute(Ei,"open"):i.removeAttribute(Ei)};return f(n()),o.addEventListener("hcms:open",()=>f(!0)),o.addEventListener("hcms:close",()=>f(!1)),o.body.appendChild(i),yr(o),l0(i),i}function Kd(e){if(typeof window>"u"||typeof document>"u")return;let t=window.clay,n=!!t&&typeof t.setMode=="function",r=()=>{document.body&&e.hasRules(document)&&a0(e)},o=i=>{document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i,{once:!0}):i()};if(n){let i=!1,l=()=>{let c=window.clay&&window.clay.plugins;return!i&&Array.isArray(c)&&c.includes("menu")},a=()=>{if(window.clay&&window.clay.canEdit===!0&&!l()){r();return}let c=document.querySelector(`[${An}]`);c&&c.remove()};o(a),document.addEventListener("clay:capabilitychange",a),document.addEventListener("clay:plugin-failed",c=>{!c.detail||c.detail.plugin!=="menu"||(i=!0,a())});return}let s=window.__hyperclayEditMode!=null?window.__hyperclayEditMode:null;n0({search:window.location.search,cookie:document.cookie,forced:s})&&o(r)}function Gd(e){if(Gf(e),typeof document<"u"){let t=document.getElementById("hcms-shell-styles");t?.tagName==="LINK"&&t.remove(),yr(document)}}var Sa={sidebar:nd,inline:Td};function c0(e,t){let n=t!==void 0?t:"cms";if(typeof n!="string")return"sidebar";let r=un.findRules(e,n)?.tagNode?.getAttribute?.("data-cms-view");return!r||r==="sidebar"?"sidebar":Sa[r]?r:(console.warn(`hypercms: unknown data-cms-view "${r}" on the rules tag, opening the sidebar`),"sidebar")}function Aa(e={}){return Ta(e)}function u0(e){let t=e&&e.defaultView;if(!No(t))return null;let n=t.clay&&t.clay.setMode;return typeof n!="function"?null:n.call(t.clay,"view")}function Ta(e={},t=!1){let n=Tt.isOpen?{...Tt.opts,...e}:e,r=n.pageRoot||(typeof document<"u"?document:null);if(!r)throw new Error("hypercms: no pageRoot available");let o=(r.nodeType===9?r:r.ownerDocument)||(typeof document<"u"?document:null);if(!o)throw new Error("hypercms: no document available");if(!t&&!Ti(o.defaultView))return{ok:!1,code:"not-allowed"};let s=e.view||(Tt.isOpen?Tt.ctx.view.name:c0(o,n.rules)),i=Sa[s];if(!i)throw new Error(`hypercms: unknown view "${s}" (expected ${Object.keys(Sa).join(" or ")})`);let l=Tt.isOpen?{...n,view:s}:e,a=null,c=null;if(Tt.isOpen){if(Tt.ctx.view.name===s)return{ok:!0,view:s};a=Tt.ctx.previouslyFocused,c=Tt.ctx.view.name,hs(Tt.ctx,{restoreFocus:!1,updateUrl:!1,reason:"switch"})}gd();let p=i({doc:o,pageRoot:r,opts:l}),u=Md({view:p,doc:o,pageRoot:r,opts:l,onCloseRequested:()=>u0(o)||Ea(),onViewRequested:f=>Ta({view:f},!0)});a&&(u.previouslyFocused=a);try{p.mount(u.initialData),Rd(u),p.focusOnOpen(),Tt.isOpen=!0,Tt.ctx=u,Tt.opts=l,u.dispatch("hcms:open",{pageRoot:r,previous:c})}catch(f){throw hs(u,{dispatch:!1,restoreFocus:!!a,updateUrl:!1}),f}return{ok:!0,view:s}}function Ea(){if(!Tt.isOpen)return{ok:!1,code:"no-session"};let e=Tt.ctx.doc;if(No(e&&e.defaultView)){let t=ba(Tt.ctx);if(t.length)return{ok:!1,code:"pending-input",pending:t};if(!Ti(e&&e.defaultView))return{ok:!1,code:"busy"}}return hs(Tt.ctx),{ok:!0}}function Yd(){Tt.isOpen&&Tt.ctx.view.refresh("api")}function f0(){return Tt.isOpen}function d0(){return Tt.isOpen&&Tt.ctx?Tt.ctx.view.name:null}function Xd({doc:e,pageRoot:t,opts:n={}}={}){let r=null,o=!1;return{ready:Promise.resolve(),enable(){if(o)return;let s={...n};t&&(s.pageRoot=t),s.pageRoot||(s.pageRoot=e&&e.body||e||null),Ta(s,!0),r=Tt.ctx},quiesce(){return o||!r||Tt.ctx!==r?{ok:!0}:Ld(r)},resume(){o||!r||Tt.ctx!==r||Id(r)},dispose(){o||(o=!0,r&&Tt.ctx===r&&hs(r),r=null)}}}function h0(e={}){return{id:"hypercms",order:1e3,prepare(){return Xd(e)}}}function xa(){if(!Tt.isOpen)throw new Error("hypercms: cms is not open");if(Tt.ctx.quiesced)throw new Error("hypercms: the CMS is not admitting new changes")}var m0={getData(){return Tt.isOpen?bn(Tt.ctx):null},setValue(e,t){xa();let n=Tt.ctx,r=er(e),o=tr(n.pageRules,r);if(o===void 0)throw new Error(`hypercms: no rule at path "${e}"`);if(typeof o!="string"||o.endsWith("[]"))throw new Error(`hypercms: setValue requires a leaf scalar path; "${e}" is not a leaf`);let s=ci(n.formRoot,e);if(!s)throw new Error(`hypercms: no field element at path "${e}"`);ui(s,t,n.formRoot,e),Sn(bn(n),{path:e,structural:!1},n)},addItem(e){xa(),is(e,Tt.ctx)},removeItem(e){xa();let t=Tt.ctx,n=er(e);if(typeof n[n.length-1]!="number")throw new Error(`hypercms: removeItem requires an item path; "${e}" is not an array index`);let o=tr(t.pageRules,n.slice(0,-1));if(!(Array.isArray(o)||typeof o=="string"&&o.endsWith("[]")))throw new Error(`hypercms: removeItem requires an item path; parent of "${e}" is not an array`);let i=t.formRoot.querySelector(`[data-hcms-path="${y0(e)}"]`);if(!i)throw new Error(`hypercms: no element at path "${e}"`);xo(i,t)},refresh:Yd,_commit(){if(!Tt.isOpen||Tt.ctx.quiesced)return;let e=Tt.ctx;return fi(e.formRoot),Dr("Update",()=>Sn(bn(e),{path:"",structural:!0},e))}},p0=250,g0=1e4;function b0(){typeof window>"u"||typeof document>"u"||jd(window.location?window.location.search:"")&&(Tt.isOpen||k0(()=>{if(!Tt.isOpen&&Ti())try{Aa()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function wa(){return!!document.body&&!!sn("Mutation")}function k0(e){if(wa()){queueMicrotask(e);return}let t=Date.now()+g0,n=!1,r=null,o=null,s=()=>{n||(n=!0,r!==null&&clearInterval(r),o&&o())};function i(){if(Tt.isOpen){s();return}wa()&&(s(),e())}o=bo(document,_f,i),r=setInterval(()=>{if(Tt.isOpen){s();return}if(wa()){s(),e();return}Date.now()>=t&&(s(),console.warn("hypercms: ?cms=true auto-open gave up \u2014 no mutation hub appeared. Load clayjs or hyperclayjs (or just the mutation utility) so the CMS can initialize."))},p0)}b0();Kd({open:Aa,close:Ea,isOpen:f0,getTheme:()=>Tt.opts?.theme,hasRules:e=>!!un.findRules(e,"cms")});var Oa={open:Aa,close:Ea,refresh:Yd,api:m0,hasRules:(e=document)=>!!un.findRules(e,"cms"),prepareModeLease:Xd,modeParticipant:h0,get isOpen(){return Tt.isOpen},currentView:d0,path:Ml,scaffold:ts,morphForm:Fs};function y0(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var Jd=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
255
+ `,e.body.appendChild(n),{root:n,formRoot:n.querySelector("[data-hcms-form-root]"),noticeEl:n.querySelector(".hcms-inline-notice"),errorEl:n.querySelector(".hcms-inline-error"),handoffEl:n.querySelector(".hcms-inline-handoff"),handoffCountEl:n.querySelector(".hcms-inline-handoff-count"),layerEl:n.querySelector(".hcms-inline-layer"),popEl:n.querySelector(".hcms-inline-pop"),closeEl:n.querySelector(".hcms-inline-pop-close"),toggleEl:n.querySelector("[data-hcms-controls-toggle]"),pageStyleEl:n.querySelector("[data-hcms-page-style-open]"),popTitleEl:n.querySelector(".hcms-inline-pop-title"),destroy(){n.remove()}}}function Cb(e,t){let n=e.querySelector(".hcms-array-items");return n&&n.querySelectorAll(":scope > [data-hcms-card], :scope > [data-hcms-array-item]")[t]||null}function _b(e,t,n){let{lists:r}=ia(e.pageRoot,e.pageRules),o=r.find(s=>s.path.join(".")===t);return o?o.items.indexOf(n):-1}var Mb="[hypercms]";function Sd(e,t){if(!e||!e.querySelectorAll||!t)return;let n=Rb(t);e.querySelectorAll("template[data-hcms-tpl]").forEach(o=>{let s=o.getAttribute("data-hcms-tpl");s&&(s.startsWith("@")||n.has(s)||console.warn(`${Mb} template "${s}" doesn't match any rule path; ignored`))})}function Rb(e){let t=new Set;return n([],e),t;function n(r,o){let s=r.join("."),i=r.map(a=>typeof a=="number"?"*":a).join(".");s&&t.add(s),i&&t.add(i);let l=mr(o);if(l==="object")for(let[a,c]of Object.entries(o))n([...r,a],c);else if(l==="object-array"||l==="scalar-array"){let a=[...r,"*"],c=a.map(m=>typeof m=="number"?"*":m).join(".");if(t.add(c),l==="object-array"){let m=o[1];if(m&&typeof m=="object"&&!Array.isArray(m))for(let[u,f]of Object.entries(m))n([...a,u],f)}}}}var ha={skip:"[data-hcms-shell]",templateAttr:"cms-template"},Nt={isOpen:!1,ctx:null,opts:null};function Td({view:e,doc:t,pageRoot:n,opts:r={},onCloseRequested:o,onViewRequested:s}){let i=r.rules!==void 0?r.rules:"cms",l=fn.findRules(t,i);if(!l){let g=typeof i=="string"?`data-rules-name~="${i}"`:"the provided rules object";throw new Error(`hypercms: no rules found for ${g}`)}let a=e.prepareRules(Fs(l.rules,n)),c=l.tagNode;Us(t),Ws(t,a),Sd(t,a);let m=Ys(a,t),u=mi(a),f=hi(n,a),p=Ds(),h=nr(fn.extract(n,a,{...ha,...p.hooks}),a),v={doc:t,pageRoot:n,pageRules:a,writeRules:u,formRules:m,rulesTagNode:c,rulesSource:i,richText:e.richText,view:e,seeder:p,initialData:h,get formRoot(){return e.formRoot},get shellRoot(){return e.root},get errorEl(){return e.errorEl},get noticeEl(){return e.noticeEl},unresolved:f,lastTwinSignature:null,lastFingerprint:null,lastData:null,observerHandle:null,undoUnsub:null,livesyncUnsub:null,onChange:r.onChange,onError:r.onError,confirmRemove:r.confirmRemove,previouslyFocused:t.activeElement,quiesced:!1,dispatch(g,d){let k=t.defaultView&&t.defaultView.CustomEvent||(typeof CustomEvent<"u"?CustomEvent:null);if(!k)return;let S={...d||{},pageRoot:Pn(n),view:e.name},x=new k(g,{bubbles:!0,cancelable:g==="hcms:change",detail:S});(e.root&&e.root.isConnected!==!1?e.root:Pn(n)).dispatchEvent(x)},onCloseRequested:o,onViewRequested:s};return v.updateFingerprint=()=>{v.lastFingerprint=ss(bn(v))},e.ctx=v,v}function Ed(e){e.updateFingerprint(),ko(e,nr(fn.extract(e.pageRoot,e.pageRules,ha),e.pageRules)),e.observerHandle=Yf({onRefresh:r=>e.view.refresh("observer",r)});let t=sn("undo");if(t&&typeof t.on=="function"){let r=()=>{if(Nt.ctx!==e)return;Ad(e,"undo");let o=nr(fn.extract(e.pageRoot,e.pageRules,ha),e.pageRules);ss(o)!==ss(e.lastData)&&(e.lastData=o,e.onChange?.(o,{path:"",structural:!1}))};t.on("undo",r),t.on("redo",r),e.undoUnsub=()=>{t.off("undo",r),t.off("redo",r)}}let n=()=>Ad(e,"livesync");e.livesyncUnsub=po(e.doc,Tf,n),ga.ctx=e,Pb(e.doc)}function Ad(e,t){Nt.ctx===e&&e.view.refresh(t)}function fs(e,{dispatch:t=!0,restoreFocus:n=!0,updateUrl:r=!0,reason:o="close"}={}){if(!e||e.closed)return;e.closed=!0;for(let i of e.uploads||[])try{i.abort()}catch{}e.uploads?.clear();let s=e.previouslyFocused;if(t&&e.dispatch("hcms:close",{reason:o}),r&&jb(),e.observerHandle?.unsubscribe?.(),e.undoUnsub?.(),e.livesyncUnsub?.(),e.detachEvents?.(),rr(()=>e.view.destroy()),Ib(),n&&typeof s?.focus=="function")try{s.focus()}catch{}}function Ib(){Nt.isOpen=!1,Nt.ctx=null,Nt.opts=null,ga.ctx=null}function Si(e){let t=e||(typeof window<"u"?window:null),n=t&&t.clay?t.clay.modeLifecycle:null;return n&&typeof n.canWrite=="function"?n:null}function Ai(e){let t=Si(e);if(!t)return!0;try{return t.canWrite()!==!1}catch{return!1}}var Lb="[data-hcms-uploading]";function pa(e){if(!e)return[];let t=[];return e.uploads&&e.uploads.size>0&&t.push("upload"),e.pageRoot&&typeof e.pageRoot.querySelector=="function"&&e.pageRoot.querySelector(Lb)&&t.push("preview"),t}function Od(e){if(!e||e.closed)return{ok:!0};let t=pa(e);return t.length?{ok:!1,code:"pending-input",pending:t}:(e.quiesced=!0,{ok:!0})}function Nd(e){!e||e.closed||(e.quiesced=!1)}var ga={ctx:null};function Pb(e){let t=e.defaultView||(typeof globalThis<"u"?globalThis:null);if(!t)return;let n=function(){let o=ga.ctx;if(o)return ci(o.formRoot),jr("Reorder",()=>Sn(bn(o),{path:"",structural:!0},o))};typeof t.hypercmsCommit!="function"&&(t.hypercmsCommit=n),typeof globalThis<"u"&&typeof globalThis.hypercmsCommit!="function"&&(globalThis.hypercmsCommit=n)}var ma="cms";function Cd(e){let t=typeof e=="string"?e:"",n=t.indexOf("?"),r=n===-1?t:t.slice(n+1);if(!r)return t;let o=new URLSearchParams(r);return o.get(ma)!=="true"?t:(o.set(ma,"false"),"?"+o.toString())}function _d(e){let t=typeof e=="string"?e:"",n=t.indexOf("?"),r=n===-1?t:t.slice(n+1);return r?new URLSearchParams(r).get(ma)==="true":!1}function jb(){if(typeof window>"u"||!window.location||!window.history||typeof window.history.replaceState!="function")return;let e=window.location.search,t=Cd(e);t!==e&&window.history.replaceState(window.history.state,"",t+window.location.hash)}function Md(e){if(Uf(e),typeof document<"u"){let t=document.getElementById("hcms-shell-styles");t?.tagName==="LINK"&&t.remove(),wo(document)}}var ya={sidebar:Xf,inline:yd};function qb(e,t){let n=t!==void 0?t:"cms";if(typeof n!="string")return"sidebar";let r=fn.findRules(e,n)?.tagNode?.getAttribute?.("data-cms-view");return!r||r==="sidebar"?"sidebar":ya[r]?r:(console.warn(`hypercms: unknown data-cms-view "${r}" on the rules tag, opening the sidebar`),"sidebar")}function Rd(e={}){return va(e)}function Db(e){let t=e&&e.defaultView;if(!Si(t))return null;let n=t.clay&&t.clay.setMode;return typeof n!="function"?null:n.call(t.clay,"view")}function va(e={},t=!1){let n=Nt.isOpen?{...Nt.opts,...e}:e,r=n.pageRoot||(typeof document<"u"?document:null);if(!r)throw new Error("hypercms: no pageRoot available");let o=(r.nodeType===9?r:r.ownerDocument)||(typeof document<"u"?document:null);if(!o)throw new Error("hypercms: no document available");if(!t&&!Ai(o.defaultView))return{ok:!1,code:"not-allowed"};let s=e.view||(Nt.isOpen?Nt.ctx.view.name:qb(o,n.rules)),i=ya[s];if(!i)throw new Error(`hypercms: unknown view "${s}" (expected ${Object.keys(ya).join(" or ")})`);let l=Nt.isOpen?{...n,view:s}:e,a=null,c=null;if(Nt.isOpen){if(Nt.ctx.view.name===s)return{ok:!0,view:s};a=Nt.ctx.previouslyFocused,c=Nt.ctx.view.name,fs(Nt.ctx,{restoreFocus:!1,updateUrl:!1,reason:"switch"})}ud();let m=i({doc:o,pageRoot:r,opts:l}),u=Td({view:m,doc:o,pageRoot:r,opts:l,onCloseRequested:()=>Db(o)||Id(),onViewRequested:f=>va({view:f},!0)});a&&(u.previouslyFocused=a);try{m.mount(u.initialData),Ed(u),m.focusOnOpen(),Nt.isOpen=!0,Nt.ctx=u,Nt.opts=l,u.dispatch("hcms:open",{pageRoot:r,previous:c})}catch(f){throw fs(u,{dispatch:!1,restoreFocus:!!a,updateUrl:!1}),f}return{ok:!0,view:s}}function Id(){if(!Nt.isOpen)return{ok:!1,code:"no-session"};let e=Nt.ctx.doc;if(Si(e&&e.defaultView)){let t=pa(Nt.ctx);if(t.length)return{ok:!1,code:"pending-input",pending:t};if(!Ai(e&&e.defaultView))return{ok:!1,code:"busy"}}return fs(Nt.ctx),{ok:!0}}function Ld(){Nt.isOpen&&Nt.ctx.view.refresh("api")}function Fb(){return Nt.isOpen&&Nt.ctx?Nt.ctx.view.name:null}function Pd({doc:e,pageRoot:t,opts:n={}}={}){let r=null,o=!1;return{ready:Promise.resolve(),enable(){if(o)return;let s={...n};t&&(s.pageRoot=t),s.pageRoot||(s.pageRoot=e&&e.body||e||null),va(s,!0),r=Nt.ctx},quiesce(){return o||!r||Nt.ctx!==r?{ok:!0}:Od(r)},resume(){o||!r||Nt.ctx!==r||Nd(r)},dispose(){o||(o=!0,r&&Nt.ctx===r&&fs(r),r=null)}}}function Bb(e={}){return{id:"hypercms",order:1e3,prepare(){return Pd(e)}}}function ba(){if(!Nt.isOpen)throw new Error("hypercms: cms is not open");if(Nt.ctx.quiesced)throw new Error("hypercms: the CMS is not admitting new changes")}var $b={getData(){return Nt.isOpen?bn(Nt.ctx):null},setValue(e,t){ba();let n=Nt.ctx,r=Qn(e),o=er(n.pageRules,r);if(o===void 0)throw new Error(`hypercms: no rule at path "${e}"`);if(typeof o!="string"||o.endsWith("[]"))throw new Error(`hypercms: setValue requires a leaf scalar path; "${e}" is not a leaf`);let s=li(n.formRoot,e);if(!s)throw new Error(`hypercms: no field element at path "${e}"`);ai(s,t,n.formRoot,e),Sn(bn(n),{path:e,structural:!1},n)},addItem(e){ba(),os(e,Nt.ctx)},removeItem(e){ba();let t=Nt.ctx,n=Qn(e);if(typeof n[n.length-1]!="number")throw new Error(`hypercms: removeItem requires an item path; "${e}" is not an array index`);let o=er(t.pageRules,n.slice(0,-1));if(!(Array.isArray(o)||typeof o=="string"&&o.endsWith("[]")))throw new Error(`hypercms: removeItem requires an item path; parent of "${e}" is not an array`);let i=t.formRoot.querySelector(`[data-hcms-path="${Wb(e)}"]`);if(!i)throw new Error(`hypercms: no element at path "${e}"`);yo(i,t)},refresh:Ld,_commit(){if(!Nt.isOpen||Nt.ctx.quiesced)return;let e=Nt.ctx;return ci(e.formRoot),jr("Update",()=>Sn(bn(e),{path:"",structural:!0},e))}},Ub=250,Hb=1e4;function zb(){typeof window>"u"||typeof document>"u"||_d(window.location?window.location.search:"")&&(Nt.isOpen||Vb(()=>{if(!Nt.isOpen&&Ai())try{Rd()}catch(e){console.warn("hypercms: auto-open failed",e)}}))}function ka(){return!!document.body&&!!sn("Mutation")}function Vb(e){if(ka()){queueMicrotask(e);return}let t=Date.now()+Hb,n=!1,r=null,o=null,s=()=>{n||(n=!0,r!==null&&clearInterval(r),o&&o())};function i(){if(Nt.isOpen){s();return}ka()&&(s(),e())}o=po(document,Af,i),r=setInterval(()=>{if(Nt.isOpen){s();return}if(ka()){s(),e();return}Date.now()>=t&&(s(),console.warn("hypercms: ?cms=true auto-open gave up \u2014 no mutation hub appeared. Load clayjs or hyperclayjs (or just the mutation utility) so the CMS can initialize."))},Ub)}zb();var xa={open:Rd,close:Id,refresh:Ld,api:$b,hasRules:(e=document)=>!!fn.findRules(e,"cms"),prepareModeLease:Pd,modeParticipant:Bb,get isOpen(){return Nt.isOpen},currentView:Fb,path:Cl,scaffold:Qo,morphForm:qs};function Wb(e){return typeof CSS<"u"&&CSS.escape?CSS.escape(e):String(e).replace(/[^a-zA-Z0-9_\-.*]/g,t=>"\\"+t)}var jd=`/* GENERATED by scripts/build-theme.js from mirk-interface/mirk.css \u2014 DO NOT EDIT.
303
256
  Source of truth: mirk-interface/mirk.css + src/theme/pixel-quiet.overrides.css.
304
257
  Regenerate with: npm run build:theme */
305
258
 
@@ -1452,20 +1405,14 @@ ${n}`:n,o.hidden=!1;continue}}t.push(n)}t.length&&e.errorEl&&(e.errorEl.textCont
1452
1405
  box-shadow: 16px 0 48px -28px rgba(43, 36, 27, 0.45);
1453
1406
  }
1454
1407
 
1455
- /* Push the page over so docked content is never hidden underneath, and publish
1456
- the geometry the floating toggle has to compose with. --hcms-toggle-shift is
1457
- the distance the toggle moves left, which is the shell width only while the
1458
- shell is docked on the right; docked left, as an overlay, or full-viewport it
1459
- is zero. */
1408
+ /* Push the page over so docked content is never hidden underneath. */
1460
1409
  body.hcms-open { --hcms-shell-width: 380px; }
1461
1410
  body.hcms-open:not(.hcms-overlay) { padding-right: var(--hcms-shell-width); }
1462
- body.hcms-open:not(.hcms-overlay):not(.hcms-side-left) { --hcms-toggle-shift: var(--hcms-shell-width); }
1463
1411
  body.hcms-open.hcms-side-left:not(.hcms-overlay) { padding-right: 0; padding-left: var(--hcms-shell-width); }
1464
- body.hcms-open.hcms-overlay { overflow: hidden; --hcms-toggle-display: none; }
1412
+ body.hcms-open.hcms-overlay { overflow: hidden; }
1465
1413
 
1466
1414
  @media (max-width: 799px) {
1467
1415
  body.hcms-open { --hcms-shell-width: 100vw; }
1468
- body.hcms-open:not(.hcms-overlay):not(.hcms-side-left) { --hcms-toggle-shift: 0px; }
1469
1416
  body.hcms-open:not(.hcms-overlay),
1470
1417
  body.hcms-open.hcms-side-left:not(.hcms-overlay) { padding-right: 0; padding-left: 0; }
1471
1418
  body.hcms-open { overflow: hidden; }
@@ -2286,4 +2233,4 @@ tr.hcms-shell.hcms-inline-ghost { display: table-row; }
2286
2233
  will-change: transform;
2287
2234
  }
2288
2235
  .hcms-inline-highlight[hidden] { display: none; }
2289
- `;typeof window<"u"&&typeof document<"u"&&(function(){if(window.__mirk)return;window.__mirk=!0;let e='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4 12 12M12 4 4 12" stroke="currentColor" stroke-width="2" stroke-linecap="square" fill="none"/></svg>';document.addEventListener("click",n=>{let r=n.target.closest(".mirk-number__step");if(!r)return;let o=r.closest(".mirk-number").querySelector("input[type=number]");o&&(r.dataset.step==="up"?o.stepUp():o.stepDown(),o.dispatchEvent(new Event("change",{bubbles:!0})))}),document.addEventListener("input",n=>{let r=n.target.closest(".mirk-slider__input");r&&r.closest(".mirk-slider").style.setProperty("--mirk-value",`${r.value}%`)}),document.addEventListener("change",n=>{let r=n.target.closest(".mirk-file__input");if(!r||!r.files.length)return;let o=r.closest(".mirk-file"),s=o.querySelector(".mirk-file__name");if(!s)return;let i=r.files[0],l=document.createElement("a");if(l.className="mirk-file__name",l.dataset.filled="",l.href=URL.createObjectURL(i),l.target="_blank",l.rel="noopener",l.textContent=i.name,s.replaceWith(l),!o.querySelector(".mirk-file__remove")){let a=document.createElement("button");a.type="button",a.className="mirk-file__remove",a.setAttribute("aria-label","Remove file"),a.innerHTML=e,l.after(a)}}),document.addEventListener("change",n=>{let r=n.target.closest(".mirk-image__input");if(!r||!r.files.length)return;let o=r.closest(".mirk-image"),s=o.querySelector(".mirk-image__preview");if(!s)return;let i=o.querySelector(".mirk-image__placeholder"),l=new FileReader;l.onload=a=>{s.src=a.target.result,s.removeAttribute("hidden"),i&&i.setAttribute("hidden",""),o.querySelector(".mirk-image__thumb")?.removeAttribute("hidden"),o.querySelector(".mirk-image__upload")?.setAttribute("hidden","")},l.readAsDataURL(r.files[0])}),document.addEventListener("click",n=>{let r=n.target.closest(".mirk-file__remove");if(r){let s=r.closest(".mirk-file"),i=s?.querySelector(".mirk-file__input"),l=s?.querySelector(".mirk-file__name");if(i&&(i.value=""),l){let a=document.createElement("span");a.className="mirk-file__name",a.textContent="No file chosen",l.replaceWith(a)}r.remove();return}let o=n.target.closest(".mirk-image__remove");if(o){let s=o.closest(".mirk-image"),i=s?.querySelector(".mirk-image__input"),l=s?.querySelector(".mirk-image__preview");i&&(i.value=""),l&&(l.removeAttribute("src"),l.setAttribute("hidden","")),s?.querySelector(".mirk-image__thumb")?.setAttribute("hidden",""),s?.querySelector(".mirk-image__upload")?.removeAttribute("hidden")}});function t(n,r){let o=document.createElement("span");o.textContent=n;let s=document.createElement("input");s.type="hidden",s.name="tags[]",s.value=n;let i=document.createElement("button");i.type="button",i.className="mirk-tags__remove",i.textContent="\xD7";let l=document.createElement("span");if(l.className="mirk-tags__chip",r){let a=document.createElement("span");a.className="mirk-tags__chip-inner",a.append(o,s,i),l.append(a)}else l.append(o,s,i);return l}document.addEventListener("keydown",n=>{let r=n.target.closest(".mirk-tags__input");if(!r)return;let o=r.closest(".mirk-tags");if(n.key==="Enter"||n.key===","){let s=r.value.trim();if(!s)return;n.preventDefault(),r.before(t(s,o.classList.contains("mirk-tags--round"))),r.value=""}else if(n.key==="Backspace"&&!r.value){let s=o.querySelectorAll(".mirk-tags__chip");s[s.length-1]?.remove()}}),document.addEventListener("click",n=>{let r=n.target.closest(".mirk-tags__remove");if(r){r.closest(".mirk-tags__chip").remove();return}let o=n.target.closest(".mirk-tags");o&&n.target===o&&o.querySelector(".mirk-tags__input")?.focus()}),document.addEventListener("click",n=>{let r=n.target.closest("[data-mirk-chip]");if(!r)return;let o=r.getAttribute("data-mirk-chip");if(o==="open")r.closest(".mirk-chip")?.classList.add("mirk-chip--open");else if(o==="collapse")r.closest(".mirk-chip")?.classList.remove("mirk-chip--open");else if(o==="changes"){let s=r.closest(".mirk-chip__panel")?.classList.toggle("is-changes");r.textContent=s?"(hide changes)":"(view changes)"}}),document.addEventListener("click",n=>{let r=n.target.closest("[data-copy-btn]");if(!r)return;let o=r.closest("[data-copy]");if(!o)return;let s=o.cloneNode(!0);s.querySelectorAll("[data-copy-btn]").forEach(a=>a.remove());let l=o.getAttribute("data-copy")==="text"?s.textContent.replace(/^\s+|\s+$/g,""):s.innerHTML.replace(/\s+data-copy(="[^"]*")?/g,"").replace(/^\s*\n/gm,"").trim();navigator.clipboard.writeText(l).then(()=>{let a=r.textContent;r.textContent="copied",r.dataset.copied="",setTimeout(()=>{r.textContent=a,delete r.dataset.copied},1200)}).catch(()=>{r.textContent="error",setTimeout(()=>{r.textContent="copy"},1200)})})})();Gd(Jd);var w0=Oa,S0={cms:Oa};return rh(A0);})();
2236
+ `;typeof window<"u"&&typeof document<"u"&&(function(){if(window.__mirk)return;window.__mirk=!0;let e='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4 12 12M12 4 4 12" stroke="currentColor" stroke-width="2" stroke-linecap="square" fill="none"/></svg>';document.addEventListener("click",n=>{let r=n.target.closest(".mirk-number__step");if(!r)return;let o=r.closest(".mirk-number").querySelector("input[type=number]");o&&(r.dataset.step==="up"?o.stepUp():o.stepDown(),o.dispatchEvent(new Event("change",{bubbles:!0})))}),document.addEventListener("input",n=>{let r=n.target.closest(".mirk-slider__input");r&&r.closest(".mirk-slider").style.setProperty("--mirk-value",`${r.value}%`)}),document.addEventListener("change",n=>{let r=n.target.closest(".mirk-file__input");if(!r||!r.files.length)return;let o=r.closest(".mirk-file"),s=o.querySelector(".mirk-file__name");if(!s)return;let i=r.files[0],l=document.createElement("a");if(l.className="mirk-file__name",l.dataset.filled="",l.href=URL.createObjectURL(i),l.target="_blank",l.rel="noopener",l.textContent=i.name,s.replaceWith(l),!o.querySelector(".mirk-file__remove")){let a=document.createElement("button");a.type="button",a.className="mirk-file__remove",a.setAttribute("aria-label","Remove file"),a.innerHTML=e,l.after(a)}}),document.addEventListener("change",n=>{let r=n.target.closest(".mirk-image__input");if(!r||!r.files.length)return;let o=r.closest(".mirk-image"),s=o.querySelector(".mirk-image__preview");if(!s)return;let i=o.querySelector(".mirk-image__placeholder"),l=new FileReader;l.onload=a=>{s.src=a.target.result,s.removeAttribute("hidden"),i&&i.setAttribute("hidden",""),o.querySelector(".mirk-image__thumb")?.removeAttribute("hidden"),o.querySelector(".mirk-image__upload")?.setAttribute("hidden","")},l.readAsDataURL(r.files[0])}),document.addEventListener("click",n=>{let r=n.target.closest(".mirk-file__remove");if(r){let s=r.closest(".mirk-file"),i=s?.querySelector(".mirk-file__input"),l=s?.querySelector(".mirk-file__name");if(i&&(i.value=""),l){let a=document.createElement("span");a.className="mirk-file__name",a.textContent="No file chosen",l.replaceWith(a)}r.remove();return}let o=n.target.closest(".mirk-image__remove");if(o){let s=o.closest(".mirk-image"),i=s?.querySelector(".mirk-image__input"),l=s?.querySelector(".mirk-image__preview");i&&(i.value=""),l&&(l.removeAttribute("src"),l.setAttribute("hidden","")),s?.querySelector(".mirk-image__thumb")?.setAttribute("hidden",""),s?.querySelector(".mirk-image__upload")?.removeAttribute("hidden")}});function t(n,r){let o=document.createElement("span");o.textContent=n;let s=document.createElement("input");s.type="hidden",s.name="tags[]",s.value=n;let i=document.createElement("button");i.type="button",i.className="mirk-tags__remove",i.textContent="\xD7";let l=document.createElement("span");if(l.className="mirk-tags__chip",r){let a=document.createElement("span");a.className="mirk-tags__chip-inner",a.append(o,s,i),l.append(a)}else l.append(o,s,i);return l}document.addEventListener("keydown",n=>{let r=n.target.closest(".mirk-tags__input");if(!r)return;let o=r.closest(".mirk-tags");if(n.key==="Enter"||n.key===","){let s=r.value.trim();if(!s)return;n.preventDefault(),r.before(t(s,o.classList.contains("mirk-tags--round"))),r.value=""}else if(n.key==="Backspace"&&!r.value){let s=o.querySelectorAll(".mirk-tags__chip");s[s.length-1]?.remove()}}),document.addEventListener("click",n=>{let r=n.target.closest(".mirk-tags__remove");if(r){r.closest(".mirk-tags__chip").remove();return}let o=n.target.closest(".mirk-tags");o&&n.target===o&&o.querySelector(".mirk-tags__input")?.focus()}),document.addEventListener("click",n=>{let r=n.target.closest("[data-mirk-chip]");if(!r)return;let o=r.getAttribute("data-mirk-chip");if(o==="open")r.closest(".mirk-chip")?.classList.add("mirk-chip--open");else if(o==="collapse")r.closest(".mirk-chip")?.classList.remove("mirk-chip--open");else if(o==="changes"){let s=r.closest(".mirk-chip__panel")?.classList.toggle("is-changes");r.textContent=s?"(hide changes)":"(view changes)"}}),document.addEventListener("click",n=>{let r=n.target.closest("[data-copy-btn]");if(!r)return;let o=r.closest("[data-copy]");if(!o)return;let s=o.cloneNode(!0);s.querySelectorAll("[data-copy-btn]").forEach(a=>a.remove());let l=o.getAttribute("data-copy")==="text"?s.textContent.replace(/^\s+|\s+$/g,""):s.innerHTML.replace(/\s+data-copy(="[^"]*")?/g,"").replace(/^\s*\n/gm,"").trim();navigator.clipboard.writeText(l).then(()=>{let a=r.textContent;r.textContent="copied",r.dataset.copied="",setTimeout(()=>{r.textContent=a,delete r.dataset.copied},1200)}).catch(()=>{r.textContent="error",setTimeout(()=>{r.textContent="copy"},1200)})})})();Md(jd);var Yb=xa,Xb={cms:xa};return Ud(Jb);})();