@panphora/clayjs 1.6.1 → 1.8.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,7 +1,7 @@
1
- var HyperMorph=(()=>{var So=Object.defineProperty;var $s=Object.getOwnPropertyDescriptor;var Gs=Object.getOwnPropertyNames;var Ys=Object.prototype.hasOwnProperty;var Js=(e,o)=>{for(var t in o)So(e,t,{get:o[t],enumerable:!0})},Xs=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of Gs(o))!Ys.call(e,r)&&r!==t&&So(e,r,{get:()=>o[r],enumerable:!(n=$s(o,r))||n.enumerable});return e};var Qs=e=>Xs(So({},"__esModule",{value:!0}),e);var ni={};Js(ni,{createIdentityStore:()=>Zo,createParseCache:()=>uo,default:()=>ti,diff:()=>Wn,findChangedRoots:()=>Us,importMap:()=>ho,merge3:()=>Fs,merge3Text:()=>Kn,mergeDocument:()=>Xn,mergeJson:()=>zo,mergeScriptText:()=>wo,morph:()=>Ao,morphDocument:()=>zs,morphElement:()=>vo,parseJsonRelaxed:()=>ko,parseRulesRelaxed:()=>bs,spliceProtected:()=>Vs,tieredIdentity:()=>Io});function fo(e,o){if(typeof e=="string"){let t=o&&o.defaultView,n=t&&t.DOMParser||globalThis.DOMParser;return new n().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function uo(e){let o=new Map;return(t,n)=>{if(typeof n!="string")return fo(n,e);let r=o.get(t);if(r&&r.text===n)return r.doc;let a=fo(n,e);return o.set(t,{text:n,doc:a}),a}}function Qo(e,o){let t=o.doctype;if(!t)return!1;let n=e.doctype;if(n&&n.name===t.name&&n.publicId===t.publicId&&n.systemId===t.systemId)return!1;let r=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return n?e.replaceChild(r,n):e.insertBefore(r,e.documentElement),!0}var Oo=()=>!1;function Mo(e,o=[]){if(typeof e!="function")return Oo;let t=new WeakMap,n=new Set(o);return r=>{if(!r||r.nodeType!==1)return!1;let a=t.get(r);if(a!==void 0)return a;let l=[],i=r,u=!1;for(;i&&i.nodeType===1;){let A=t.get(i);if(A!==void 0){u=A;break}if(l.push(i),e(i,n.has(i))){u=!0;break}if(n.has(i))break;i=i.parentElement}for(let A of l)t.set(A,u);return u}}var ii=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 Mn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Zo(e){let o=new WeakMap,t=0,n=i=>o.get(i)||null,r=i=>{let u=o.get(i);return u||(u=`${e}:${++t}`,o.set(i,u)),u};return{idOf:n,ensure:r,adopt:(i,u)=>{i&&typeof u=="string"&&u&&o.set(i,u)},exportMap:(i,u)=>{let A={},N=[],h=[],M=(L,R)=>{let F=u(L);F&&(A[R]=r(F));let k=L.children;N.push(k.length),h.push(L.tagName.toLowerCase());for(let d=0;d<k.length;d++)M(k[d],R===""?String(d):`${R}.${d}`)};return M(i,""),A["~"]=N.join(","),A["^"]=h.join(","),A}}}function ho(e,o){let t=new WeakMap;if(!e||!o||typeof o!="object"||Array.isArray(o))return t;let n=o["~"],r=typeof n=="string"?n.split(",").map(Number):null,a=r&&typeof o["^"]=="string"?o["^"].split(","):null,l=h=>Number.isInteger(h)&&h>=0,i=0,u=!1,A=h=>{let M=h;for(;M>0;){let L=r[i++];if(i>r.length||!l(L))return!1;M+=L-1}return!0},N=(h,M)=>{if(u)return;if(r){let F=i++,k=r[F];if(F>=r.length||!l(k)){u=!0;return}let d=!a||a[F]===h.tagName.toLowerCase();if(!d||k!==h.children.length){let w=d&&o[M];typeof w=="string"&&w&&t.set(h,w),A(k)||(u=!0);return}}let L=o[M];typeof L=="string"&&L&&t.set(h,L);let R=h.children;for(let F=0;F<R.length;F++)N(R[F],M===""?String(F):`${M}.${F}`)};return N(e,""),t}function Io(e){return o=>{for(let t of e){let n=t(o);if(typeof n=="string"&&n!=="")return n}return null}}var an=Io([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function po(e,o,t,n=null){let r=new Map,a=new Set,l=i=>{if(t(i))return;let u=o(i);u&&(r.has(u)?a.add(u):r.set(u,i))};if(n){let i=u=>{for(let A of u.querySelectorAll(n))l(A);for(let A of u.querySelectorAll("template"))A.content&&i(A.content)};l(e),i(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let i=u=>{l(u);let A=u.tagName==="TEMPLATE"&&u.content?u.content.children:u.children;for(let N=0;N<A.length;N++)i(A[N])};i(e)}for(let i of a)r.delete(i),Lo(i);return r}function Lo(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var Zs=new Set(["href","src","name","type","role"]),ts=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function Vn(e,o=5381){let t=o;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return t>>>0}function es(e){return e.replace(/\s+/g," ")}var er=0;function ns({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,r=new WeakMap;function a(ee){let oe=ee.attributes,re=oe.length;if(re===0)return{all:"",sig:ee.tagName+"|"};let ne=[],K="",D=[];for(let Ne=0;Ne<re;Ne++){let ae=oe[Ne],te=ae.name;o(ee,te)||ne.push(te+"="+ae.value),te==="class"?K=ae.value.indexOf(" ")<0?ae.value:ae.value.split(/\s+/).filter(Boolean).sort().join(" "):Zs.has(te)&&D.push(te+"="+ae.value)}return ne.length>1&&ne.sort(),D.length>1&&D.sort(),{all:ne.join(""),sig:ee.tagName+"|"+K+(D.length?"|"+D.join("|"):"")}}function l(ee){return ee.nodeType===1&&ee.tagName==="TEMPLATE"&&ee.content?ee.content.childNodes:ee.childNodes}function i(ee){let oe=n.get(ee);if(oe)return oe;if(ee.nodeType===3)oe={hash:"T"+Vn(ee.nodeValue),hint:es(ee.nodeValue).slice(0,64),sig:null,tok:null};else if(ee.nodeType===8)oe={hash:"C"+Vn(ee.nodeValue),hint:"",sig:null,tok:null};else if(ee.nodeType===1){let re=a(ee),ne=Vn(ee.tagName+""+re.all),K="";for(let D of A(ee))if(D.nodeType===1){let Ne=i(D);ne=Vn(Ne.hash,ne),K.length<64&&(K+=" "+Ne.hint)}else ne=Vn(N(D),ne),D.kind==="text"&&K.length<64&&(K+=D.value.slice(0,64));oe={hash:"E"+ne,hint:es(K).trim().slice(0,64),sig:re.sig,tok:null}}else oe={hash:"N"+ee.nodeType,hint:"",sig:null,tok:null};return n.set(ee,oe),oe}function u(ee){if(!ee.tok){ee.tok=new Set;for(let oe of ee.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))oe&&ee.tok.add(oe)}return ee.tok}function A(ee){let oe=r.get(ee);if(oe)return oe;oe=[];let re=null,ne=()=>{re&&(re.value=re.nodes.map(K=>K.nodeValue).join(""),oe.push(re),re=null)};for(let K of l(ee)){if(K.nodeType===3){re||(re={kind:"text",nodes:[],value:"",parent:ee,hash:void 0}),re.nodes.push(K);continue}ne(),K.nodeType===8?oe.push({kind:"comment",nodes:[K],value:K.nodeValue,parent:ee,hash:void 0}):K.nodeType===1&&!e(K)&&oe.push(K)}return ne(),r.set(ee,oe),oe}function N(ee){return ee.nodeType===1?i(ee).hash:(ee.hash===void 0&&(ee.hash=(ee.kind==="text"?"T":"C")+Vn(ee.value)),ee.hash)}function h(ee,oe){let re=u(i(ee)),ne=u(i(oe));if(re.size===0&&ne.size===0)return{coef:1,share:1};if(re.size===0||ne.size===0)return null;let K=0;for(let D of re)ne.has(D)&&K++;return{coef:K/Math.min(re.size,ne.size),share:K/Math.max(re.size,ne.size)}}function M(ee,oe){let re=h(ee,oe);return!!re&&re.coef>=.5}let L=new WeakMap;function R(ee){let oe=L.get(ee);if(oe)return oe;oe=[];for(let re of ee.attributes)o(ee,re.name)||oe.push([re.namespaceURI||"",re.localName,re.value]);return oe.sort((re,ne)=>re[0]<ne[0]?-1:re[0]>ne[0]?1:re[1]<ne[1]?-1:re[1]>ne[1]?1:0),L.set(ee,oe),oe}let F=new WeakMap;function k(ee,oe){if(ee===oe)return!0;if(N(ee)!==N(oe))return!1;let re=F.get(ee);if(re&&re.has(oe))return re.get(oe);let ne=F.get(oe);if(ne&&ne.has(ee))return ne.get(ee);let K=d(ee,oe),D=K===!0;return K===!1&&t&&t.hashRejected++,re||F.set(ee,re=new WeakMap),re.set(oe,D),D}function d(ee,oe){if(ee.nodeType===1){if(oe.nodeType!==1||ee.tagName!==oe.tagName||ee.namespaceURI!==oe.namespaceURI)return!1;let re=R(ee),ne=R(oe);if(re.length!==ne.length)return!1;for(let Ne=0;Ne<re.length;Ne++)if(re[Ne][0]!==ne[Ne][0]||re[Ne][1]!==ne[Ne][1]||re[Ne][2]!==ne[Ne][2])return!1;let K=A(ee),D=A(oe);if(K.length!==D.length)return!1;for(let Ne=0;Ne<K.length;Ne++){if(N(K[Ne])!==N(D[Ne]))return!1;if(!k(K[Ne],D[Ne]))return er}return!0}return oe.nodeType===1?!1:ee.kind===oe.kind&&ee.value===oe.value}let w=new WeakMap,Z=new Map,he=0;function xe(ee){let oe=w.get(ee);if(oe)return oe;let re=N(ee),ne=Z.get(re);ne||Z.set(re,ne=[]);let K=ne.find(D=>k(D.unit,ee));return oe=K?K.key:"K"+he++,K||ne.push({unit:ee,key:oe}),w.set(ee,oe),oe}return{meta:i,unitsOf:A,unitHash:N,similar:M,score:h,childrenOf:l,equalUnits:k,exactUnitKey:xe,ignored:e}}var os=16,tr=2e3,nr=3,Co={align:0,certifyVisited:0,certifyScheduled:0};function Eo(e,o,t){let{meta:n,unitsOf:r,unitHash:a,similar:l,score:i,childrenOf:u,equalUnits:A,ignored:N}=t.analyzer,h=t.baseId||(()=>null),M=t.sideId||(()=>null),L=t.stats||null,R=L?new Set:null,F=L?new Set:null,k=new Map,d=new Map,w=new Set,Z=new Map,he=new Set,xe=new Set,ee=new Set,oe=[],re=[],ne=[],K=[],D=tr,Ne=new Map,ae=new Map,te=(f,m)=>{k.set(f,m),d.set(m,f)},V=new Set,ye=new Set,be=null,Oe=f=>{let m=f.nodeType?f.parentNode:f.parent;if(!m||m.nodeType!==11)return m;if(!be){be=new WeakMap;let C=W=>{for(let j of W.querySelectorAll("template"))j.content&&(be.set(j.content,j),C(j.content))};for(let W of[e,o])C(W.tagName==="TEMPLATE"&&W.content?W.content:W)}return be.get(m)||null},He=(f,m)=>{for(let C=Oe(f);C&&!V.has(C);C=Oe(C))V.add(C);for(let C=Oe(m);C&&!ye.has(C);C=Oe(C))ye.add(C)},Ue=f=>{for(let m=Oe(f);m;m=Oe(m))if(k.has(m))return xe.has(m);return!1},ze=f=>{for(let m=Oe(f);m;m=Oe(m)){let C=d.get(m);if(C!==void 0)return xe.has(C)}return!1},se=f=>!!f&&f.nodeType===1,at=(f,m)=>{let C=Z.get(f);return!!C&&C.has(m)},ft=f=>ts.has(f.tagName),le=t.comparisons||t.scope,b=(f,m)=>{if(le){if(le.same.get(f)===m)return!0;if(le.differ.get(f)===m)return!1}if(!f.isEqualNode(m))return!1;if(f.tagName==="TEMPLATE")return A(f,m);let C=f.getElementsByTagName("template");if(C.length===0)return!0;let W=m.getElementsByTagName("template");if(C.length!==W.length)return!1;for(let j=0;j<C.length;j++)if(!A(C[j],W[j]))return!1;return!0},H=(f,m)=>{let C=h(f);if(!C)return!0;let W=M(m);return!W||C===W},fe=globalThis.__hyperMorphProfile,we=fe?performance.now():0;fe&&!t.scope&&(n(e),n(o),fe.meta=(fe.meta||0)+(performance.now()-we),we=performance.now()),te(e,o);let pe=new Set;for(let[f,m]of t.baseIndex){let C=t.sideIndex.get(f);C&&C.tagName===m.tagName&&!k.has(m)&&!d.has(C)&&(te(m,C),He(m,C),pe.add(m))}if(pe.size){let f=[];if(t.scope)for(let j of t.scope.chain)pe.has(j)&&f.push(j);let m=[t.scope?t.scope.root:e];for(;m.length;){let j=m.pop();pe.has(j)&&f.push(j);let z=u(j);for(let x=z.length-1;x>=0;x--)z[x].nodeType===1&&m.push(z[x])}let C=new Set;for(let j=f.length-1;j>=0;j--){let z=f[j];t.scope&&t.scope.onChain.has(z)?C.add(z):Jt(z,k.get(z),C)?(xe.add(z),ee.add(z),L&&L.certificationPairs++):C.add(z)}let W=new Set;for(let j of f)xe.has(j)&&!W.has(j)&&Ge(j,W)}t.scope&&t.scope.head&&Dt(t.scope.head[0],t.scope.head[1]);function Ge(f,m){let C=[f];for(;C.length;){let W=C.pop();if(!m.has(W)){m.add(W),v(W);for(let j of r(W))se(j)&&k.has(j)&&C.push(j)}}}K.push([e,o]);for(let[f,m]of k)se(f)&&f!==e&&K.push([f,m]);return wt(),je(),fe&&(fe.align=(fe.align||0)+(performance.now()-we)),{map:k,reverse:d,moved:he,identical:xe,pairIdenticalChildren:v,weak:w,unpair:Ze,rematch:je,insertedByHash:rt,refused:F,identityPaired:pe};function je(){E(),wt();for(let f=0;f<ne.length;){let m=ne.length;tn(f,m),f=m,wt(),E(),wt()}}function Ze(f){let m=k.get(f);if(!m)return;Z.has(f)||Z.set(f,new Set),Z.get(f).add(m);let C=(j,z)=>{k.delete(j),d.delete(z),he.delete(j),xe.delete(j),w.delete(j),ee.delete(j)},W=(j,z)=>{for(let x of r(j)){let S=k.get(x);!S||pe.has(x)||!(se(S)?z.contains(S):z.contains(S.nodes[0]))||(C(x,S),se(x)&&W(x,S))}};C(f,m),se(f)&&W(f,m),oe.push(f),re.push(m)}function rt(){let f=new Map;for(let m of new Set(re)){if(d.has(m))continue;let C=n(m).hash;f.has(C)||f.set(C,[]),f.get(C).push(m)}return f}function wt(){for(;K.length;){let[f,m]=K.shift();k.get(f)!==m||ee.has(f)||xe.has(f)||Tt(f,m)}}function bt(f,m){if(!ft(f))for(let C of r(f))se(C)&&(m.push(C),bt(C,m))}function Tt(f,m){ee.add(f);let C=r(f),W=r(m);Co.align+=C.length+W.length,Ne=new Map,ae=new Map;for(let G=0;G<C.length;G++)Ne.set(C[G],G);for(let G=0;G<W.length;G++)ae.set(W[G],G);if(f.tagName==="HTML")for(let G of["HEAD","BODY"]){let ge=C.find(c=>se(c)&&c.tagName===G),Me=W.find(c=>se(c)&&c.tagName===G);ge&&Me&&!k.has(ge)&&!d.has(Me)&&te(ge,Me)}for(let G=0;G<C.length&&G<W.length;G++){let ge=C[G],Me=W[G];k.has(ge)||d.has(Me)||(se(ge)?se(Me)&&ge.tagName===Me.tagName&&b(ge,Me)&&Dt(ge,Me):!se(Me)&&ge.kind===Me.kind&&ge.value===Me.value&&Dt(ge,Me))}y(C,W);let j=C.filter(G=>!k.has(G)),z=W.filter(G=>!d.has(G));j.length&&z.length&&(Xt(j,z),X(j,z),Q(j,z,C,W),ue(C,W));let x=!1,S=!1;for(let G of C){if(!k.has(G)){se(G)&&(oe.push(G),bt(G,oe),x=!0);continue}se(G)&&!xe.has(G)&&K.push([G,k.get(G)])}for(let G of W)!d.has(G)&&se(G)&&(re.push(G),bt(G,re),S=!0);x&&S&&ne.push([f,m])}function tn(f,m){for(let C=f;C<m;C++){let[W,j]=ne[C];if(k.get(W)!==j)continue;let z=r(W),x=r(j),S=new Map,G=new Map,ge=null;for(let Me of z)se(Me)&&(k.has(Me)?ge=Me:(S.has(ge)||S.set(ge,[]),S.get(ge).push(Me)));ge=null;for(let Me of x)se(Me)&&(d.has(Me)?ge=d.get(Me):(G.has(ge)||G.set(ge,[]),G.get(ge).push(Me)));for(let[Me,c]of S){let T=G.get(Me);if(!(!T||c.length!==T.length)&&c.every((P,U)=>T[U].tagName===P.tagName&&H(P,T[U])&&!at(P,T[U])))for(let P=0;P<c.length;P++)Fe(c[P],T[P])}}}function Fe(f,m){te(f,m),w.add(f),K.push([f,m]),wt()}function Xt(f,m){let C=_n(f,a),W=_n(m,a),j=new Map;for(let z of m){let x=a(z);W.get(x)===1&&j.set(x,z)}for(let z of f){if(k.has(z))continue;let x=a(z);if(C.get(x)!==1)continue;let S=j.get(x);S&&!d.has(S)&&A(z,S)&&Dt(z,S)}}function Jt(f,m,C){let W=[[f,m]];for(;W.length;){let[j,z]=W.pop();if(Co.certifyVisited++,L&&L.certificationVisited++,j.nodeType!==z.nodeType)return!1;if(j.nodeType===3||j.nodeType===8){if(j.nodeValue!==z.nodeValue)return!1;continue}if(j.nodeType!==1){if(!j.isEqualNode(z))return!1;continue}if(j.tagName!==z.tagName||j.namespaceURI!==z.namespaceURI||N(j)!==N(z))return!1;let x=j.attributes,S=z.attributes;if(x.length!==S.length)return!1;for(let T=0;T<x.length;T++){let P=x[T];if(z.getAttributeNS(P.namespaceURI,P.localName)!==P.value)return!1}let G=k.get(j);if(G!==void 0&&G!==z)return!1;let ge=d.get(z);if(ge!==void 0&&ge!==j)return!1;if(j!==f){if(xe.has(j))continue;if(C.has(j))return!1}let Me=u(j),c=u(z);if(Me.length!==c.length)return!1;Co.certifyScheduled+=Me.length;for(let T=Me.length-1;T>=0;T--)W.push([Me[T],c[T]])}return!0}function Dt(f,m){if(se(f)&&(V.has(f)||ye.has(m))){let C=Et(f,m);if(!C){te(f,m),K.push([f,m]);return}for(let W=0;W<C.length;W+=2){let j=C[W],z=C[W+1],x=k.get(j);x!==void 0&&x!==z&&It(j,x);let S=d.get(z);S!==void 0&&S!==j&&It(S,z),k.get(j)===z&&(he.delete(j),w.delete(j),xe.add(j),ee.add(j))}}sn(f,m)}function It(f,m){k.delete(f),d.delete(m),he.delete(f),xe.delete(f),w.delete(f),ee.delete(f)}function Et(f,m){let C=[f,m,!1],W=[];for(;C.length;){let j=C.pop(),z=C.pop(),x=C.pop(),S=k.get(x),G=d.get(z);if(x!==f&&(S!==void 0&&S!==z&&pe.has(x)||G!==void 0&&G!==x&&pe.has(G)))return null;if(!(S===z&&xe.has(x))&&((S!==void 0||G!==void 0)&&W.push(x,z),!!se(x))){if(j||S!==void 0&&S!==z||G!==void 0&&G!==x){let ge=r(x),Me=r(z);for(let c=0;c<ge.length&&c<Me.length;c++)C.push(ge[c],Me[c],!0)}else if(V.has(x)||ye.has(z)){let ge=x.tagName==="TEMPLATE"?x.content:x,Me=z.tagName==="TEMPLATE"?z.content:z;for(let c=ge.firstElementChild,T=Me.firstElementChild;c&&T;){if(N(c)){c=c.nextElementSibling;continue}if(N(T)){T=T.nextElementSibling;continue}(k.has(c)||d.has(T)||V.has(c)||ye.has(T))&&C.push(c,T,!1),c=c.nextElementSibling,T=T.nextElementSibling}}}}return W}function sn(f,m){te(f,m),xe.add(f),se(f)&&ee.add(f)}function v(f){let m=k.get(f);if(!m||!se(f))return;let C=r(f),W=r(m);for(let j=0;j<C.length&&j<W.length;j++)k.has(C[j])||sn(C[j],W[j])}function X(f,m){let C=x=>se(x)&&!ft(x)?n(x).sig+""+n(x).hint:null,W=_n(f,C),j=_n(m,C),z=new Map;for(let x of m){let S=C(x);S!=null&&j.get(S)===1&&z.set(S,x)}for(let x of f){if(k.has(x))continue;let S=C(x);if(S==null||W.get(S)!==1)continue;let G=z.get(S);G&&!d.has(G)&&H(x,G)&&te(x,G)}}function Q(f,m,C,W){let j=new Map;for(let x of m){if(!se(x)||d.has(x)||ft(x))continue;let S=n(x).sig;j.has(S)||j.set(S,[]),j.get(S).push({el:x,index:ae.get(x)})}let z=[];for(let x of f){if(k.has(x)||!se(x)||ft(x))continue;let S=j.get(n(x).sig);if(!S||!S.length)continue;let G=Ne.get(x),ge=S.filter(Me=>!d.has(Me.el)).map(Me=>({c:Me,d:Math.abs(Me.index-G)}));ge.sort((Me,c)=>Me.d-c.d),ge.length>os&&(ge=ge.slice(0,os));for(let{c:Me,d:c}of ge){if(!H(x,Me.el))continue;let T=i(x,Me.el);T&&T.coef>=.5&&z.push({b:x,s:Me.el,coef:T.coef,share:T.share,d:c,bi:G})}}if(z.sort((x,S)=>S.coef-x.coef||S.share-x.share||x.d-S.d||x.bi-S.bi),L&&z.length>1){let x=new Map;for(let S of z){let G=x.get(S.b);G?G.coef===S.coef&&(G.share===S.share?G.strict++:G.loose++):x.set(S.b,{coef:S.coef,share:S.share,strict:0,loose:0})}for(let[S,G]of x)R.has(S)||!(G.strict||G.loose)||(R.add(S),G.strict?L.similarTiesStrict++:L.similarTiesLoose++)}for(let x of z)!k.has(x.b)&&!d.has(x.s)&&te(x.b,x.s)}function de(f,m){return se(f)!==se(m)?!1:se(f)?f.tagName!==m.tagName||!H(f,m)?!1:ft(f)||n(f).hint===""||n(m).hint===""?!0:l(f,m):f.kind===m.kind}function ie(f,m){let C=(j,z)=>{let x=z===null?-1:j===m?ae.get(z):Ne.get(z),S=j[x+1];return S&&!se(S)?S:null},W=null;for(let j of f){if(se(j)){W=j;continue}if(k.has(j))continue;let z=W===null?null:k.get(W);if(W!==null&&!z)continue;let x=C(m,z);x&&!d.has(x)&&x.kind===j.kind&&te(j,x)}}function ue(f,m){ie(f,m);let C=p(f,m),W=(z,x)=>se(z)&&n(z).hint!==""&&n(x).hint===""&&!!x.querySelector("br")&&!C(z,x),j=0;for(let z of f){if(k.has(z)){let S=ae.get(k.get(z));S!==void 0&&S>=j&&(j=S+1);continue}let x=0;for(let S=j;S<m.length&&x<nr;S++){let G=m[S];if(!d.has(G)&&(x++,de(z,G)&&!at(z,G)&&!W(z,G))){te(z,G),se(z)&&(n(z).hint===""||n(G).hint==="")&&w.add(z),j=S+1;break}}}y(f,m)}function p(f,m){let C=(W,j,z)=>{for(let x=j-1;x>=0;x--)if(se(W[x])&&z(W[x]))return W[x];return null};return(W,j)=>{let z=Ne.get(W),x=ae.get(j);if(z===x)return!0;let S=C(f,z,ge=>k.has(ge)),G=C(m,x,ge=>d.has(ge));return S?k.get(S)===G:!G}}function y(f,m){let C=f.filter(S=>se(S)&&!k.has(S)),W=m.filter(S=>se(S)&&!d.has(S));if(!C.length||!W.length)return;let j=_n(C,S=>S.tagName),z=_n(W,S=>S.tagName),x=p(f,m);for(let S of C){let G=S.tagName;if(j.get(G)!==1||z.get(G)!==1)continue;let ge=W.find(Me=>Me.tagName===G);ge&&!d.has(ge)&&x(S,ge)&&H(S,ge)&&!at(S,ge)&&(A(S,ge)?Dt(S,ge):(te(S,ge),w.add(S)))}}function E(){let f=new Map;for(let S of w)if(se(S)&&se(k.get(S))){let G=n(S).hash;f.has(G)||f.set(G,[]),f.get(G).push(S)}if(f.size)for(let S of re){if(d.has(S)||!se(S)||ze(S))continue;let G=f.get(n(S).hash),ge=G&&G.find(Me=>w.has(Me)&&!at(Me,S)&&H(Me,S)&&A(Me,S));ge&&(Ze(ge),Dt(ge,S),He(ge,S),he.add(ge))}let m=new Map,C=new Map,W=new Map;for(let S of w){let G=k.get(S);se(S)&&se(G)&&W.set(G,S)}let j=(S,G)=>{if(!d.has(S))return!ze(S);let ge=W.get(S);return ge===d.get(S)&&ge!==G&&!ge.contains(G)},z=S=>{if(d.has(S)){let G=W.get(S);W.delete(S),Ze(G)}};for(let S of[...re,...W.keys()]){if(d.has(S)&&!W.has(S))continue;let G=n(S).hash;if(m.has(G)||m.set(G,[]),m.get(G).push(S),ft(S))continue;let ge=n(S).sig;C.has(ge)||C.set(ge,[]),C.get(ge).push(S)}let x=new Set;for(let S of w){let G=k.get(S);!se(S)||!se(G)||ft(S)||n(S).hint===""||n(G).hint===""||l(S,G)||x.add(S)}for(let S of[...oe,...x]){let G=k.get(S);if(G?!(w.has(S)&&x.has(S)):Ue(S))continue;let ge=U=>{G&&Ze(S),z(U)},Me=m.get(n(S).hash);if(Me){let U=Me.find(_=>_!==G&&j(_,S)&&!at(S,_)&&A(S,_));if(U){ge(U),Dt(S,U),He(S,U),he.add(S);continue}}if(ft(S)||D<=0)continue;let c=C.get(n(S).sig);if(!c)continue;let T=null,P=0;for(let U of c)if(!(U===G||!j(U,S)||!H(S,U)||at(S,U))&&(D--<=0||l(S,U)&&(P++,T=U,P>1)))break;P>1&&F&&F.add(S),P===1&&(ge(T),te(S,T),He(S,T),he.add(S),K.push([S,T]))}}}function _n(e,o){let t=new Map;for(let n of e){let r=o(n);r!=null&&t.set(r,(t.get(r)||0)+1)}return t}var or={diff:0},ss=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,sr=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,rr=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,ir=/\P{M}\p{M}*/gu;function Do(e){if(e==="")return[];if(ss){let t=[];for(let n of ss.segment(e))t.push(n.segment);return t}let o=[];for(let t of e.match(rr))if(sr.test(t))for(let n of t.match(ir))o.push(n);else o.push(t);return o}var lr=/^[  ]+$/,cr=e=>lr.test(e)?" ".repeat(e.length):e,In=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),gt="",Ro=e=>e.every(o=>In(o)||o.k===gt),ar=/^[\x00-\x7f\u00A0]*$/,fr=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function ur(e){return e===""?[]:e.match(fr)}function Pn(e,o=!1){return(o?ur(e):Do(e)).map(t=>({k:cr(t),raw:t,len:t.length}))}var mo=(...e)=>e.every(o=>ar.test(o));function Po(e,o,t){let n=e.length,r=o.length,a=Math.min(n+r,t),l=a+1,i=new Int32Array(2*a+3),u=[],A=n===0&&r===0;for(let L=0;L<=a&&!A;L++){u.push(i.slice(l-L,l+L+1));for(let R=-L;R<=L;R+=2){let F;R===-L||R!==L&&i[l+R-1]<i[l+R+1]?F=i[l+R+1]:F=i[l+R-1]+1;let k=F-R,d=F;for(;F<n&&k<r&&e[F].k===o[k].k;)F++,k++;if(or.diff+=1+F-d,i[l+R]=F,F>=n&&k>=r){A=!0;break}}}if(!A)return null;let N=[],h=n,M=r;for(let L=u.length-1;L>0;L--){let R=u[L],F=h-M,k=F+L,d=F===-L||F!==L&&R[k-1]<R[k+1]?F+1:F-1,w=R[d+L],Z=w-d;for(;h>w&&M>Z;)N.push([0,h-1,M-1]),h--,M--;h===w?(N.push([1,h,M-1]),M--):(N.push([-1,h-1,M]),h--)}for(;h>0&&M>0;)N.push([0,h-1,M-1]),h--,M--;return N.reverse(),N}function dr(e,o,t){let n=h=>h.k===gt;if(!e.some(n)&&!o.some(n))return Po(e,o,t);let r=[],a=[];for(let h=0;h<e.length;h++)n(e[h])||r.push(h);for(let h=0;h<o.length;h++)n(o[h])||a.push(h);let l=Po(r.map(h=>e[h]),a.map(h=>o[h]),t);if(!l)return null;let i=[],u=0,A=0,N=(h,M)=>{for(;u<h&&A<M&&e[u].k===o[A].k;)i.push([0,u++,A++]);let L=Po(e.slice(u,h),o.slice(A,M),t);if(!L)return!1;for(let[R,F,k]of L)i.push([R,F+u,k+A]);return u=h,A=M,!0};for(let[h,M,L]of l)if(h===0){if(!N(r[M],a[L]))return null;i.push([0,u,A]),u++,A++}return N(e.length,o.length)?i:null}function qn(e,o,t=4e3){let n=[],r=0;for(;r<e.length&&r<o.length&&e[r].k===o[r].k;)e[r].raw!==o[r].raw&&n.push({bi:r,tok:o[r]}),r++;let a=0;for(;a<e.length-r&&a<o.length-r&&e[e.length-1-a].k===o[o.length-1-a].k;)e[e.length-1-a].raw!==o[o.length-1-a].raw&&n.push({bi:e.length-1-a,tok:o[o.length-1-a]}),a++;let l=e.slice(r,e.length-a),i=o.slice(r,o.length-a),u=kr(l,i)?null:dr(l,i,t);if(!u){let d=l.length||i.length?[{bs:r,be:r+l.length,toks:i}]:[];return{hunks:d,cosmetic:n,coarse:!0,parts:d.map(w=>({...w,gap:[],group:0})),cosmeticEq:n}}let A=[],N=(d,w)=>{l[d].raw!==i[w].raw&&n.push({bi:r+d,tok:i[w]})},h=null,M=[],L=0,R=0,F=()=>{h&&A.push(h),h=null;for(let[d,w]of M)N(d,w);M=[],L++};for(let[d,w,Z]of u){if(d===0){h&&In(l[w])&&!l[w].k.includes(`
2
- `)?M.push([w,Z]):(F(),N(w,Z)),R=w+1;continue}(!h||M.length)&&(h&&A.push(h),h={bs:r+R,be:r+R,toks:[],gap:M.map(([he,xe])=>({bi:r+he,tok:i[xe]})),group:L},M=[]),d===-1?(h.be=r+R+1,R=w+1):h.toks.push(i[Z])}F(),hr(A,e);let k=Ho(A);return{hunks:k.hunks,cosmetic:n.concat(k.cosmetic),parts:A,cosmeticEq:n}}function hr(e,o){for(let t=0;t<e.length;t++){let n=e[t];if(n.gap.length)continue;let r=t+1<e.length?e[t+1].bs:1/0;if(n.toks.length){if(n.bs===n.be)for(;n.bs+1<r&&n.bs<o.length&&n.toks[0].k===gt&&o[n.bs].k===gt;)n.toks=[...n.toks.slice(1),n.toks[0]],n.bs++,n.be++}else for(;n.be+1<r&&n.be<o.length&&o[n.bs].k===gt&&o[n.be].k===gt;)n.bs++,n.be++}}function Ho(e,o=()=>!1){let t=[],n=[],r=null,a=-1;for(let l of e){let i=o(l);if(r&&!r.alone&&!i&&l.group===a){r.be=l.be;for(let u of l.gap)r.toks.push(u.tok);for(let u of l.toks)r.toks.push(u);continue}r&&t.push({bs:r.bs,be:r.be,toks:r.toks});for(let u of l.gap)n.push(u);r={bs:l.bs,be:l.be,toks:l.toks.slice(),alone:i},a=l.group}return r&&t.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:t,cosmetic:n}}var pr=(e,o)=>e.bs===o.bs&&e.be===o.be&&Vo(e.toks,o.toks);function Uo(e,o,t){let n=N=>h=>N.some(M=>pr(h,M)),r=Ho(e.parts,n(o.parts)),a=Ho(o.parts,n(e.parts)),l=e.cosmeticEq.concat(r.cosmetic),i=o.cosmeticEq.concat(a.cosmetic),[u,A]=t?mr(r.hunks,a.hunks,t,l,i):[r.hunks,a.hunks];return{lh:u,rh:A,cosL:l,cosR:i}}function mr(e,o,t,n,r){let a=(R,F)=>R.k===F.k&&R.raw===F.raw,l=[{list:e.map(R=>({...R})),resp:new Set(n.map(R=>R.bi)),raw:new Map(n.map(R=>[R.bi,R.tok]))},{list:o.map(R=>({...R})),resp:new Set(r.map(R=>R.bi)),raw:new Map(r.map(R=>[R.bi,R.tok]))}],i=R=>R.bs===R.be,u=(R,F,k,d)=>{let w=R.list[F];if(!i(w))return d(w)===k?w.toks:null;let Z=F?R.list[F-1].be:0,he=F+1<R.list.length?R.list[F+1].bs:t.length;if(k<Z||k>he)return null;let xe=w.toks,ee=w.bs;for(;ee>k;){let oe=xe[xe.length-1];if(!a(oe,t[ee-1])||R.resp.has(ee-1))return null;xe=[oe,...xe.slice(0,-1)],ee--}for(;ee<k;){if(!a(xe[0],t[ee])||R.resp.has(ee))return null;xe=[...xe.slice(1),xe[0]],ee++}return xe},A=(R,F,k,d,w,Z)=>{let he=R.list[F],xe=w?k.slice(k.length-d):k.slice(0,d),ee=w?k.slice(0,k.length-d):k.slice(d),oe={bs:Z,be:Z,toks:xe};if(i(he)){if(!ee.length){R.list[F]=oe;return}let ne={bs:Z,be:Z,toks:ee};w&&(ne.lead=!0),R.list.splice(F,1,...w?[ne,oe]:[oe,ne]);return}let re={bs:he.bs,be:he.be,toks:ee};R.list.splice(F,1,...w?[re,oe]:[oe,re])},N=(R,F,k,d,w)=>{let Z=R.list[F],he=w?k.slice(k.length-d):k.slice(0,d),xe=w?k.slice(0,k.length-d):k.slice(d),ee={bs:Z.bs,be:Z.be,toks:he};if(!xe.length){R.list[F]=ee;return}let oe=w?{bs:Z.bs,be:Z.bs,toks:xe,lead:!0}:{bs:Z.be,be:Z.be,toks:xe};R.list.splice(F,1,...w?[oe,ee]:[ee,oe])},h=(R,F,k,d)=>{let w=R.list[F],Z=k.list[d],he=w.be,xe=Z.bs;if(he>=xe||F+1<R.list.length&&R.list[F+1].bs<=Z.be||d>0&&k.list[d-1].be>=w.bs)return!1;for(let be=he;be<xe;be++)if(!In(t[be])||t[be].k.includes(`
3
- `))return!1;let ee=be=>t.slice(he,xe).map((Oe,He)=>be.raw.get(he+He)||Oe),oe=[...w.toks,...ee(R)],re=[...ee(k),...Z.toks],ne=(be,Oe,He)=>Oe>=0&&Oe+He.length<=be.length&&He.every((Ue,ze)=>be[Oe+ze].k===Ue.k),K=(be,Oe,He)=>Ro(be)&&t.slice(Oe,He).some(Ue=>!In(Ue)),D=be=>be.some(Oe=>!In(Oe)),Ne,ae,te,V;if(i(w)&&D(w.toks)&&ne(re,0,w.toks)){let be=re.slice(w.toks.length);K(be,he,Z.be)||(Ne=he,ae=w.toks,te=re.slice(0,w.toks.length),V=[null,{bs:he,be:Z.be,toks:be}])}if(Ne===void 0&&i(Z)&&D(Z.toks)){let be=oe.length-Z.toks.length,Oe=oe.slice(0,be);ne(oe,be,Z.toks)&&!K(Oe,w.bs,xe)&&(Ne=xe,ae=oe.slice(be),te=Z.toks,V=[{bs:w.bs,be:xe,toks:Oe},null])}if(Ne===void 0)return!1;let ye=be=>be&&(be.bs<be.be||be.toks.length);return R.list.splice(F,1,...[V[0],{bs:Ne,be:Ne,toks:ae}].filter(ye)),k.list.splice(d,1,...[{bs:Ne,be:Ne,toks:te},V[1]].filter(ye)),!0},M=l[0],L=l[1];for(let R=0;R<64;R++){let F=!1;e:for(let k=0;k<M.list.length;k++)for(let d=0;d<L.list.length;d++){let w=M.list[k],Z=L.list[d];if(!(w.bs===Z.bs&&w.be===Z.be&&Vo(w.toks,Z.toks))){for(let he of[!0,!1]){let xe=oe=>he?oe.be:oe.bs,ee=i(w)?[xe(Z),w.bs]:[xe(w)];for(let oe of ee){let re=u(M,k,oe,xe),ne=re&&u(L,d,oe,xe);if(!ne)continue;let K=(V,ye)=>he?V[V.length-1-ye]:V[ye],D=0;for(;D<re.length&&D<ne.length&&K(re,D).k===K(ne,D).k;)D++;if(!D)continue;let Ne=he?re.slice(0,re.length-D):re.slice(D),ae=he?ne.slice(0,ne.length-D):ne.slice(D);if(!(D<re.length&&D<ne.length&&!Ro(Ne)&&!Ro(ae)&&(i(w)&&i(Z)||w.bs===Z.bs&&w.be===Z.be)||!(he?re.slice(re.length-D):re.slice(0,D)).some(V=>!In(V)))){if(D===re.length&&D===ne.length&&i(w)&&i(Z)){if(w.bs===oe&&Z.bs===oe)continue;M.list[k]={bs:oe,be:oe,toks:re},L.list[d]={bs:oe,be:oe,toks:ne}}else!i(w)&&w.bs===Z.bs&&w.be===Z.be?(N(M,k,re,D,he),N(L,d,ne,D,he)):(A(M,k,re,D,he,oe),A(L,d,ne,D,he,oe));F=!0;break e}}}if(h(M,k,L,d)||h(L,d,M,k)){F=!0;break e}}}if(!F)break}return[M.list,L.list]}var gr=48,br=.3;function kr(e,o){let t=e.filter(l=>!In(l)),n=o.filter(l=>!In(l));if(Math.min(t.length,n.length)<gr)return!1;let r=new Map;for(let l of t)r.set(l.k,(r.get(l.k)||0)+1);let a=0;for(let l of n){let i=r.get(l.k);i>0&&(a++,r.set(l.k,i-1))}return a/Math.min(t.length,n.length)<br}var yr=(e,o)=>{let t=new Set;for(let n of e.toks)typeof n.k!="string"&&t.add(n.k.el);for(let n=e.bs;n<e.be;n++)typeof o[n].k!="string"&&t.add(o[n].k.el);return t},Vo=(e,o)=>e.length===o.length&&e.every((t,n)=>t.k===o[n].k);function rs(e,o,t,n="remote"){let r=qn(e,o),a=qn(e,t),{lh:l,rh:i,cosL:u,cosR:A}=Uo(r,a,e),N=b=>b.bs===b.be,h=b=>b.toks.some(H=>typeof H.k=="string"),M=b=>N(b)&&!h(b),L=(b,H)=>H.bs<b.be&&b.bs<H.be,R=(b,H)=>!L(b,H)&&H.bs<=b.be&&b.bs<=H.be&&(N(b)&&h(b)||N(H)&&h(H))&&!(N(b)&&N(H)),F=(b,H)=>b.bs===H.bs&&b.be===H.be&&Vo(b.toks,H.toks),k=[],d=new Set;for(let b of l){let H=i.find(fe=>!d.has(fe)&&F(b,fe));H?(d.add(H),k.push({bs:b.bs,be:b.be,side:"both",l:b,r:H,toks:b.toks})):k.push({bs:b.bs,be:b.be,side:"L",l:b,toks:b.toks,lead:!!b.lead})}for(let b of i)d.has(b)||k.push({bs:b.bs,be:b.be,side:"R",r:b,toks:b.toks,lead:!!b.lead});k.sort((b,H)=>b.bs-H.bs||b.be-H.be||H.lead-b.lead);let w=0,Z=0;for(let b of k)b.side==="both"&&(w+=b.toks.length-(b.be-b.bs));let he=k.map((b,H)=>H),xe=b=>he[b]===b?b:he[b]=xe(he[b]),ee=(b,H)=>(b=xe(b),H=xe(H),b===H?!1:(he[b]=H,!0)),oe=k.map(b=>yr({bs:b.bs,be:b.be,toks:b.toks},e)),re={L:new Map,R:new Map};k.forEach((b,H)=>{let fe=b.side==="both"?["L","R"]:[b.side];for(let we of fe)for(let pe of oe[H])re[we].has(pe)||re[we].set(pe,[]),re[we].get(pe).push(H)});for(let b of[re.L,re.R])for(let H of b.values())for(let fe=1;fe<H.length;fe++)ee(H[0],H[fe]);for(let b=0;b<k.length;b++)for(let H=b+1;H<k.length;H++){let fe=k[b],we=k[H];fe.side===we.side&&fe.side!=="both"||fe.bs>we.be||(L(fe,we)||R(fe,we)?ee(b,H):fe.bs===we.bs&&N(fe)&&N(we)&&Z++)}let ne=(b,H)=>{let fe=b==="L"?l:i;for(let we of fe)if(we.toks.some(pe=>pe.kind==="close"&&pe.k.el===H.el))return we.bs;for(let we=0;we<e.length;we++)if(e[we].kind==="close"&&e[we].k.el===H.el)return we;return-1};k.forEach((b,H)=>{if(!(!M(b)||b.side==="both"))for(let fe of b.toks){if(fe.kind!=="open")continue;let we=ne(b.side,fe.k);if(we<=b.bs)continue;let pe=new Uint8Array(we-b.bs),Ge=[];if(k.forEach((je,Ze)=>{if(!(je.side===b.side||N(je))&&je.bs<we&&je.be>b.bs){Ge.push(Ze);for(let rt=Math.max(je.bs,b.bs);rt<Math.min(je.be,we);rt++)pe[rt-b.bs]=1}}),Ge.length&&pe.every(je=>je===1))for(let je of Ge)ee(H,je)}});let K=!0;for(;K;){K=!1;let b=new Map;k.forEach((H,fe)=>{let we=xe(fe),pe=b.get(we)||{bs:H.bs,be:H.be,L:!1,R:!1};pe.bs=Math.min(pe.bs,H.bs),pe.be=Math.max(pe.be,H.be),H.side!=="R"&&(pe.L=!0),H.side!=="L"&&(pe.R=!0),b.set(we,pe)}),k.forEach((H,fe)=>{for(let[we,pe]of b){if(xe(fe)===xe(we)||!(pe.L&&pe.R))continue;let Ge=H.bs<pe.be&&H.be>pe.bs,je=N(H)&&h(H)&&(H.bs===pe.be||H.bs===pe.bs);(Ge||je)&&ee(fe,we)&&(K=!0)}})}let D=new Map;k.forEach((b,H)=>{let fe=xe(H);D.has(fe)||D.set(fe,[]),D.get(fe).push(b)});let Ne=[];for(let b of D.values()){let H=b.some(we=>we.side==="L"),fe=b.some(we=>we.side==="R");if(H&&fe){let we=Math.min(...b.map(Ze=>Ze.bs)),pe=Math.max(...b.map(Ze=>Ze.be)),Ge=b.filter(Ze=>Ze.side!=="R").map(Ze=>Ze.l).sort((Ze,rt)=>Ze.bs-rt.bs),je=b.filter(Ze=>Ze.side!=="L").map(Ze=>Ze.r).sort((Ze,rt)=>Ze.bs-rt.bs);Ne.push({bs:we,be:pe,kind:"conflict",localHunks:Ge,remoteHunks:je})}else for(let we of b)Ne.push({bs:we.bs,be:we.be,kind:we.side,u:we})}let ae=(b,H)=>{let fe=b==="L"?l:i;for(let we of fe)if(we.toks.some(pe=>pe.kind==="close"&&pe.k.el===H.el))return we.bs+.5;for(let we=0;we<e.length;we++)if(e[we].kind==="close"&&e[we].k.el===H.el)return we;return 1/0},te=(b,H)=>{let fe=b==="L"?l:i;for(let we of fe)if(we.toks.some(pe=>pe.kind==="open"&&pe.k.el===H.el))return we.bs-.5;for(let we=0;we<e.length;we++)if(e[we].kind==="open"&&e[we].k.el===H.el)return we;return-1/0},V=b=>b.kind==="R"?"R":"L",ye=b=>b.kind==="R"?1:0;Ne.sort((b,H)=>{if(b.bs!==H.bs)return b.bs-H.bs;let fe=b.bs===b.be,we=H.bs===H.be;if(fe!==we)return fe?-1:1;if(fe&&we&&b.kind!=="conflict"&&H.kind!=="conflict"){let Ge=b.u.toks,je=H.u.toks,Ze=wt=>wt.length&&wt.every(bt=>bt.kind==="open"),rt=wt=>wt.length&&wt.every(bt=>bt.kind==="close");if(Ze(Ge)&&Ze(je)){let wt=Math.max(...Ge.map(Tt=>ae(V(b),Tt.k))),bt=Math.max(...je.map(Tt=>ae(V(H),Tt.k)));if(wt!==bt)return bt-wt}if(rt(Ge)&&rt(je)){let wt=Math.min(...Ge.map(Tt=>te(V(b),Tt.k))),bt=Math.min(...je.map(Tt=>te(V(H),Tt.k)));return wt!==bt?bt-wt:ye(H)-ye(b)}}let pe=Ge=>Ge.u&&Ge.u.lead?1:0;return pe(H)-pe(b)||ye(b)-ye(H)||b.be-H.be});let be=[],Oe=[],He=0,Ue=b=>{b>He&&(be.push({bs:He,be:b,toks:e.slice(He,b),source:"base"}),He=b)};for(let b of Ne){if(Ue(b.bs),b.kind==="conflict"){let H=jo(e,b.localHunks,b.bs,b.be),fe=jo(e,b.remoteHunks,b.bs,b.be),we=n==="local"?H:n==="both"?H.concat(fe):fe,pe=(Ze,rt)=>{let wt=0;for(let bt of Ze)bt.be<=b.bs&&!rt.includes(bt)&&(wt+=bt.toks.length-(bt.be-bt.bs));return wt},Ge=b.bs+pe(l,b.localHunks),je=b.bs+pe(i,b.remoteHunks);Oe.push({bs:b.bs,be:b.be,ls:Ge,le:Ge+H.length,rs:je,re:je+fe.length,ms:0,me:0,base:e.slice(b.bs,b.be),local:H,remote:fe,resolved:we}),be.push({bs:b.bs,be:b.be,toks:we,source:"conflict",localHunks:b.localHunks,localToks:H,keepsLocal:n!=="remote"})}else be.push({bs:b.bs,be:b.be,toks:b.u.toks,source:b.kind==="R"?"remote":"local",localHunks:b.kind==="R"?[]:[b.u.l]});He=Math.max(He,b.be)}Ue(e.length);let ze=0,se=0;for(let b of be)b.source==="conflict"&&(Oe[se].ms=ze,Oe[se].me=ze+b.toks.length,se++),ze+=b.toks.length;let at=new Map(u.map(b=>[b.bi,b.tok])),ft=new Map(A.map(b=>[b.bi,b.tok])),le=[];for(let b of be){b.source==="base"&&(b.toks=b.toks.map((H,fe)=>{let we=b.bs+fe,pe=at.get(we),Ge=ft.get(we),je=pe&&Ge?n==="remote"?Ge:pe:pe||Ge||H;return je===H?H:{...je,cosmetic:!0}}));for(let H of b.toks)le.push({...H,src:b.source})}return{tokens:le,segments:be,conflicts:Oe,localHunks:l,remoteHunks:i,collapsedDelta:w,samePoint:Z,mapLocalOffset:wr(e,l,be)}}function jo(e,o,t,n){let r=[],a=t;for(let l of o)r=r.concat(e.slice(a,l.bs),l.toks),a=l.be;return r.concat(e.slice(a,n))}var Bo=e=>e.reduce((o,t)=>o+t.len,0);function wr(e,o,t){let n=new Int32Array(e.length+1);for(let l=0;l<e.length;l++)n[l+1]=n[l]+e[l].len;let r=o.map(l=>({bs:n[l.bs],be:n[l.be],text:l.toks.map(i=>i.raw).join(""),ref:l})),a=t.map(l=>({bs:n[l.bs],be:n[l.be],len:Bo(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?Bo(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let i=null,u=null,A=0,N=0,h=0;for(let L of r){let R=L.bs-h;if(l<=N+R){i=h+(l-N);break}if(N+=R,h=L.bs,l<=N+L.text.length){u=L,A=l-N,i=L.bs;break}N+=L.text.length,h=L.be}i===null&&(i=h+(l-N));let M=0;for(let L of a){if(!u&&i<=L.bs)return M;if(!(u?L.localHunks.includes(u.ref):i<L.be)){M+=L.len;continue}if(L.source==="base")return M+(i-L.bs);if(L.source==="remote")return M+L.len;if(L.source==="local")return M+Math.min(A,L.len);if(!L.keepsLocal||!u)return M+L.len;let F=L.localHunks.indexOf(u.ref),k=Bo(jo(e,L.localHunks.slice(0,F),L.ref.bs,u.ref.bs));return M+Math.min(k+A,L.localLen)}return M}}function Kn(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:d=>Math.min(d,o.length),granularity:"word"};let r=mo(e,o,t),a=Pn(e,r),l=Pn(o,r),i=Pn(t,r),u=a.length<=2e4&&l.length<=2e4&&i.length<=2e4?rs(a,l,i,n):null,A="word",N=a;if(!u){let d=w=>w.split(/(?<=\n)/).map(Z=>({k:Z,raw:Z,len:Z.length}));N=d(e),u=rs(N,d(o),d(t),n),A="line"}let h=d=>d.map(w=>w.raw).join(""),M=d=>{let w=[0];for(let Z of d)w.push(w[w.length-1]+Z.len);return w},L=M(N),R=null,F=null,k=null;if(u.conflicts.length){let d=w=>w.split(/(?<=\n)/).map(Z=>({k:Z,raw:Z,len:Z.length}));R=M(A==="line"?d(o):l),F=M(A==="line"?d(t):i),k=M(u.tokens)}return{text:h(u.tokens),conflicts:u.conflicts.map(d=>({bs:L[d.bs],be:L[d.be],ls:R[d.ls],le:R[d.le],rs:F[d.rs],re:F[d.re],ms:k[d.ms],me:k[d.me],base:h(d.base),local:h(d.local),remote:h(d.remote),resolved:h(d.resolved)})),mapLocalOffset:u.mapLocalOffset,granularity:A}}function Wn(e,o,t=4e3){if(e===o)return[];let n=mo(e,o),r=Pn(e,n),a=Pn(o,n),l=qn(r,a,t),i=[0];for(let u of r)i.push(i[i.length-1]+u.len);return l.hunks.map(u=>({bs:i[u.bs],be:i[u.be],text:u.toks.map(A=>A.raw).join("")}))}var $n="\uFFFC";var xr={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(" ")),us=new Set(["BR","WBR","IMG"]),Ko=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 Bn(e,o={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(o.ignored&&o.ignored(e)||us.has(e.tagName))return!0;if(!wn.has(e.tagName))return!Ko.has(e.tagName);if(o.remoteWins&&o.remoteWins(e))return!1;let t=o.inlineCache&&o.inlineCache.get(e);if(t!==void 0)return t;let n=!0;for(let r of e.childNodes)if(!Bn(r,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Tr(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function Nn(e,o={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},n=(r,a)=>{for(let l of r){if(l.nodeType===3){let h=l.nodeValue;if(!h)continue;t.nodes.push({node:l,s:t.text.length,e:t.text.length+h.length}),t.text+=h;for(let M=0;M<h.length;M++)t.stackAt.push(a);continue}if(l.nodeType!==1)continue;if(o.ignored&&o.ignored(l)){t.pins.push({el:l,i:t.text.length});continue}if(o.skip&&o.skip.has(l))continue;let i=o.via&&o.via(l)||l;i!==l&&(t.via||(t.via=new Map)).set(i,l);let u=l.tagName;if(o.blocks&&o.blocks.has(l)){t.text.length&&t.text[t.text.length-1]!==gt&&(t.stackAt.push(a),t.text+=gt);let h={el:l,tag:u,from:t.text.length,to:-1,depth:a.length,block:!0};t.marks.push(h);let M=a.concat([h]);n(i.childNodes,M),t.stackAt.push(M),t.text+=gt,h.to=t.text.length;continue}let A=wn.has(u)&&Tr(i);if(us.has(u)||!wn.has(u)||o.remoteWins&&o.remoteWins(l)||o.atomize&&o.atomize(l)||A){t.atoms.push({i:t.text.length,el:l,key:A?u+":empty":u,stack:a}),t.stackAt.push(a),t.text+=$n;continue}let N={el:l,tag:u,from:t.text.length,to:-1,depth:a.length};t.marks.push(N),n(i.childNodes,a.concat([N])),N.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&go(t).trim()===""){let r=t.atoms[0];t.placeholder=r.el,t.text=t.text.slice(0,r.i)+t.text.slice(r.i+1),t.stackAt.splice(r.i,1);for(let a of t.nodes)a.s>r.i&&(a.s--,a.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(r=>[r.i,r])),t}function Nr(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Ar(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,"&quot;")}"`;return o+">"}function zn(e,o,t){let n="",r=[];for(let a=o;a<t;a++){let l=e.stackAt[a],i=0;for(;i<r.length&&i<l.length&&r[i]===l[i];)i++;for(;r.length>i;)n+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<l.length;){let A=l[r.length];n+=Ar(A.el),r.push(A)}let u=e.atomAt.get(a);n+=u?u.el.outerHTML:e.text[a]===gt?"":Nr(e.text[a])}for(;r.length;)n+=`</${r.pop().tag.toLowerCase()}>`;return n}function vr(e,o){let t=[...e.el.attributes].filter(n=>!o(e.el,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tag+"|"+t}function ds(e,o){let t=[...e.attributes].filter(n=>!o(e,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function is(e,o=()=>!1){let t=new Map,n=a=>{let l=t.get(a);return l===void 0&&(l="{"+a.map(i=>vr(i,o)).sort().join(",")+"}",t.set(a,l)),l},r="";for(let a=0;a<e.text.length;a++){let l=e.atomAt.get(a);r+=(l?"["+ds(l.el,o)+"]":e.text[a])+n(e.stackAt[a])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function Fn(e,o,t,n=r=>r.key){let r=[],a=e.text,l=0,i=u=>{if(u<=l)return;let A=a.slice(l,u);if(t)for(let N of A.split(/(?<=\n)/))r.push({k:N,raw:N,len:N.length});else for(let N of Pn(A,o))r.push(N)};for(let u of e.atoms)i(u.i),r.push({k:"\0"+n(u),raw:$n,len:1,atom:!0}),l=u.i+1;return i(a.length),r}function go(e){if(!e.atoms.length)return e.text;let o="",t=0;for(let n of e.atoms)o+=e.text.slice(t,n.i),t=n.i+1;return o+e.text.slice(t)}var qo=e=>{let o=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)o[t+1]=o[t]+e[t].len;return o};function ls(e,o,t,n){let r=qo(o),a=qo(t),l=[],i=0,u=0;for(let N of n.hunks){u+=N.bs-i;let h=u+N.toks.length;l.push({bs:r[N.bs],be:r[N.be],ss:a[u],se:a[h],text:e.text.slice(a[u],a[h]),toks:N.toks,lead:!!N.lead}),u=h,i=N.be}let A=new Map;for(let N of n.cosmetic)A.set(N.bi,N.tok.raw);return{hunks:l,respell:A}}function cs(e,o,t){let n=l=>l===gt||/\s/.test(l),r=l=>l.replace(/[\u001E\s]/g,""),a=[];for(let l of e){let i=o.slice(l.bs,l.be),u=t.slice(l.ss,l.se);if(!i.includes(gt)&&!u.includes(gt)||i.includes($n)||u.includes($n)||r(i)!==r(u)){a.push(l);continue}let A=0,N=0;for(;;){let h=A,M=N;for(;h<i.length&&n(i[h]);)h++;for(;M<u.length&&n(u[M]);)M++;let L=A,R=N;for(;L<h&&R<M&&i[L]===u[R];)L++,R++;let F=h,k=M;for(;F>L&&k>R&&i[F-1]===u[k-1];)F--,k--;if(F>L||k>R){let d=u.slice(R,k);a.push({bs:l.bs+L,be:l.bs+F,ss:l.ss+R,se:l.ss+k,text:d,toks:[...d].map(w=>({k:w,raw:w,len:1})),lead:l.lead})}if(h>=i.length)break;A=h+1,N=M+1}}return a}function as(e,o,t){let n=new Int32Array(o+1).fill(-1),r=new Int32Array(t+1).fill(-1),a=0,l=0,i=u=>{for(;a<u;)n[a]=l,r[l]=a,a++,l++};for(let u of e)i(u.bs),a=u.be,l=u.se;return i(o),n[o]=l,r[l]=o,{bTo:n,toB:r}}function fs(e,o){if(e.size!==o.size)return!1;for(let t of e)if(!o.has(t))return!1;return!0}function Wo(e){let{out:o,policy:t="remote",L:n,R:r}=e,a=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,i=e.conflicts||[],u=e.decisions||[],A=i.length,N=e.conflict||(s=>i.push(s)),h={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},M=[],L=!!(n&&n.reverse&&n.map&&r&&r.reverse&&r.map),R={base:null,local:null,remote:null};if(L&&e.moveIn){let s=Ae=>qe=>Ae.some(Te=>Te===qe||Te.nodeType===1&&Te.contains(qe)),g=s(e.local),I=s(e.remote),O=s(e.base),B=new Set,$=Ae=>{if(!wn.has(Ae.tagName))return;let qe=n.map.get(Ae),Te=r.map.get(Ae);(qe&&!g(qe)||Te&&!I(Te))&&B.add(Ae);for(let Le of Ae.children)$(Le)};for(let Ae of e.base)Ae.nodeType===1&&$(Ae);let me=Ae=>qe=>{if(!wn.has(qe.tagName))return!1;let Te=Ae.reverse.get(qe);return!!Te&&(B.has(Te)||!O(Te))};B.size&&(R.base=Ae=>B.has(Ae)),R.local=me(n),R.remote=me(r)}let F={base:new Set,local:new Set,remote:new Set};if(L&&e.moveIn){let s=O=>B=>O.some($=>$===B||$.nodeType===1&&$.contains(B)),g=s(e.local),I=s(e.remote);for(let O of Nn(e.base,{...e,atomize:R.base}).atoms){let B=n.map.get(O.el),$=r.map.get(O.el),me=!!B&&!g(B),Ae=!!$&&!I($);!me&&!Ae||(F.base.add(O.el),B&&!me&&F.local.add(B),$&&!Ae&&F.remote.add($),g(O.el)&&F.local.add(O.el),I(O.el)&&F.remote.add(O.el))}}let k=Nn(e.base,{...e,atomize:R.base,skip:F.base}),d=Nn(e.local,{...e,atomize:R.local,skip:F.local}),w=Nn(e.remote,{...e,atomize:R.remote,skip:F.remote}),Z=new Map(k.atoms.map(s=>[s.el,s])),he={},xe=s=>F[s].size?(he[s]||(he[s]=Nn(e[s],{...e,atomize:R[s]})),he[s]):null,ee=(s,g,I)=>{g.namespaceURI?s.setAttributeNS(g.namespaceURI,g.name,I):s.setAttribute(g.name,I)},oe=(s,g,I,O)=>{if(!g&&(!I||!O)){for(let $ of(I||O).attributes)ee(s,$,$.value);return}let B=new Map;for(let $ of[g,I,O])if($)for(let me of $.attributes)B.set(me.name,me);for(let[$,me]of B){let Ae=g?g.getAttribute($):null,qe=I?I.getAttribute($):Ae,Te=O?O.getAttribute($):Ae,Le;qe===Te?Le=qe:qe===Ae?(Le=Te,u.push({kind:"attr",el:s,name:$,source:"remote"})):Te===Ae?(Le=qe,u.push({kind:"attr",el:s,name:$,source:"local"})):(Le=t==="local"?qe:Te,N({kind:"attr",el:s,name:$,base:Ae,local:qe,remote:Te,resolved:Le},{el:s,sample:me}),u.push({kind:"attr",el:s,name:$,source:"both"})),Le!=null&&ee(s,me,Le)}},re=(s,g,I,O)=>s&&e.mergeAttrs?e.mergeAttrs(s,g,I,O):oe(O,s,g,I),ne=e.mergeElement||((s,g,I)=>{let O=o.createElement(s.tagName);re(s,g,I,O);let B=g||s,$=I||s,me=t==="local"?B.isEqualNode(s)?$:B:$.isEqualNode(s)?B:$;for(let Ae of me.childNodes)O.appendChild(o.importNode(Ae,!0));return a.set(O,{base:s,local:g,remote:I}),O}),K=e.cloneUnit||((s,g)=>{let I=o.importNode(s,!0);return a.set(I,{base:null,local:g==="local"?s:null,remote:g==="remote"?s:null}),I}),D=e.atomKey||(s=>ds(s,()=>!1)),Ne=(s,g)=>{let I=new Map;for(let O of s.atoms)if(e.remoteWins&&e.remoteWins(O.el)&&wn.has(O.el.tagName))I.set(O,"w"+O.el.tagName+"#"+(O.el.id||""));else if(!L)I.set(O,O.key);else if(s===k)I.set(O,"="+D(O.el));else{let B=g.reverse.get(O.el),$=B?Z.get(B):null;$?I.set(O,"="+D($.el)):B?I.set(O,"m"+D(O.el)):I.set(O,"="+D(O.el))}return O=>I.get(O)},ae=Ne(k,null),te=Ne(d,n),V=Ne(w,r),ye=mo(go(k),go(d),go(w)),be=Fn(k,ye,!1,ae),Oe=Fn(d,ye,!1,te),He=Fn(w,ye,!1,V),Ue=be.length>2e4||Oe.length>2e4||He.length>2e4;Ue&&(be=Fn(k,ye,!0,ae),Oe=Fn(d,ye,!0,te),He=Fn(w,ye,!0,V));let ze=Uo(qn(be,Oe),qn(be,He),be),se=ls(d,be,Oe,{hunks:ze.lh,cosmetic:ze.cosL}),at=ls(w,be,He,{hunks:ze.rh,cosmetic:ze.cosR});se.hunks=cs(se.hunks,k.text,d.text),at.hunks=cs(at.hunks,k.text,w.text);let ft=as(se.hunks,k.text.length,d.text.length),le=as(at.hunks,k.text.length,w.text.length),b=k.text.length,H=s=>new Map(s.atoms.map(g=>[g.el,g])),fe=H(d),we=H(w),pe=(s,g,I)=>{let O=new Set;if(!L)return O;for(let B of s.atoms){let $=Z.get(g.reverse.get(B.el));$&&I.bTo[$.i]<0&&O.add($)}return O},Ge=pe(d,n,ft),je=pe(w,r,le),Ze=s=>!Bn(s,{...e,remoteWins:null}),rt=new Set;if(L)for(let s of k.atoms){if(!Ze(s.el))continue;let g=n.map.get(s.el)||null,I=r.map.get(s.el)||null,O=g&&!I?g:I&&!g?I:null;O&&(fe.has(O)||we.has(O))&&!O.isEqualNode(s.el)&&rt.add(s)}let wt=1,bt=(s,g)=>({id:wt++,tag:s,base:null,local:null,remote:null,rank:g}),Tt=new Map,tn=[];for(let s of k.marks){let g=bt(s.tag,s.depth);g.block=!!s.block,g.base=s.el,g.baseMark=s,Tt.set(s.el,g),tn.push(g)}let Fe=(s,g)=>{let I=-1,O=-1;for(let B=s.from;B<s.to;B++){let $=g[B];$>=0&&(I<0&&(I=$),O=$+1)}return I<0?null:[I,O]},Xt=(s,g,I,O)=>{for(let B of s.marks){let $=I?I.reverse.get(B.el):null;$&&I.identical.has($)&&I.pairIdenticalChildren&&I.pairIdenticalChildren($);let me=$?Tt.get($):null;if(me&&me[g]&&(me=null),!me){let Ae=Fe(B,O),qe=0;if(Ae)for(let Te of tn){if(Te.tag!==B.tag||Te[g]||!!Te.block!=!!B.block)continue;let Le=Math.min(Ae[1],Te.baseMark.to)-Math.max(Ae[0],Te.baseMark.from);(Le>qe||Le===qe&&Le>0&&Math.abs(Te.rank-B.depth)<Math.abs(me.rank-B.depth))&&(me=Te,qe=Le)}}me||(me=bt(B.tag,B.depth),me.block=!!B.block,me.new=g),me[g]=B.el,me[g+"Mark"]=B,Tt.set(B.el,me)}};Xt(d,"local",n,ft.toB),Xt(w,"remote",r,le.toB);let Jt=s=>s.merged||s,Dt=s=>{let g=new Set;for(let I of s)I.block||g.add(Tt.get(I.el));return g},It=new Map,Et=s=>{let g=It.get(s);return g||(g=Dt(s),It.set(s,g)),g},sn=(s,g)=>{let I=[],O=null;for(let B=0;B<b;B++){let $=g[B];if($<0){O&&I.push(O),O=null;continue}let me=Et(k.stackAt[B]),Ae=Et(s.stackAt[$]),qe=new Set,Te=new Set;for(let Le of Ae)me.has(Le)||qe.add(Le);for(let Le of me)Ae.has(Le)||Te.add(Le);if(!qe.size&&!Te.size){O&&I.push(O),O=null;continue}if(O&&fs(O.added,qe)&&fs(O.removed,Te)){O.be=B+1;continue}O&&I.push(O),O={bs:B,be:B+1,added:qe,removed:Te}}return O&&I.push(O),I},v=sn(d,ft.bTo),X=sn(w,le.bTo),Q=s=>s.be>s.bs?[s.bs,s.be-1]:[s.bs-1,s.bs],de=(s,g)=>{if(b===0)return null;let[I,O]=Q(s);for(let B of g){if(B.be<=I)continue;if(B.bs>O)break;let $=B.bs<=I&&O<B.be;return $&&s.text===""&&B.bs===s.bs&&B.be===s.be?"straddle":$?B:s.be>s.bs?"straddle":null}return null},ie=s=>s.bs===s.be,ue=(s,g)=>{let I=!1;for(let O=s.bs;O<s.be;O++){let B=k.text[O];if(B===gt)I=!0;else if(!/\s/.test(B))return!1}for(let O=s.ss;O<s.se;O++){let B=g.text[O];if(B===gt)I=!0;else if(!/\s/.test(B))return!1}return I},p=(s,g)=>s.bs<g.be&&g.bs<s.be,y=(s,g)=>s.bs<=g.be&&g.bs<=s.be&&ie(s)!==ie(g),E=(s,g)=>k.text.slice(s.bs,s.be).includes(gt)||g.text.slice(s.ss,s.se).includes(gt),f=s=>{if(ie(s))return!1;let g=s.bs,I=s.be;for(;g>0&&/\s/.test(k.text[g-1]);)g--;for(;I<k.text.length&&/\s/.test(k.text[I]);)I++;return(g===0||k.text[g-1]===gt)&&(I===k.text.length||k.text[I]===gt)},m=(s,g)=>!E(s,g)&&!f(s),C=(s,g)=>p(s,g)||y(s,g)&&!(ue(s,d)&&m(g,w))&&!(ue(g,w)&&m(s,d)),W=(s,g)=>{if(s.bs!==g.bs||s.be!==g.be||s.toks.length!==g.toks.length)return!1;let I=s.ss,O=g.ss;for(let B=0;B<s.toks.length;B++){let $=s.toks[B],me=g.toks[B];if($.k!==me.k||$.atom&&!d.atomAt.get(I).el.isEqualNode(w.atomAt.get(O).el))return!1;I+=$.len,O+=me.len}return!0},j=(s,g,I,O)=>{for(let B of k.atoms){if(B.i<s.bs||B.i>=s.be||O.has(B)||rt.has(B))continue;let $=g.bTo[B.i],me=$>=0?I.atomAt.get($):null;if(me&&!me.el.isEqualNode(B.el))return!0}return!1},z=[],x=se.hunks,S=at.hunks,G=0,ge=0,Me=0,c=0,T=0,P=s=>{s>Me&&(z.push({src:"base",from:Me,to:s,dL:c,dR:T}),Me=s)};for(;G<x.length||ge<S.length;){let s=x[G],g=S[ge],I=!!s&&(!g||s.bs<g.bs||s.bs===g.bs&&s.be<=g.be&&!g.lead);if(s&&g&&s.bs===g.bs&&ie(s)&&ie(g)){let Ct=ue(s,d),to=ue(g,w);Ct!==to&&(I=to)}let O=I?s:g,B=I?g:s,$=!!B&&W(s,g),me=!!B&&(I?!!x[G+1]&&W(x[G+1],g):!!S[ge+1]&&W(s,S[ge+1])),Ae=!!B&&!$&&!me&&(b===0||C(s,g)),qe=Ae,Te=de(O,I?X:v);if(Te==="straddle"&&(qe=!0),!qe&&O.be>O.bs&&(qe=j(O,I?le:ft,I?w:d,I?Ge:je)),!qe&&$){P(O.bs),z.push({src:"both",lfrom:s.ss,rfrom:g.ss,len:O.text.length}),Me=O.be,c+=O.text.length-(O.be-O.bs),T+=O.text.length-(O.be-O.bs),G++,ge++;continue}if(!qe){P(O.bs),z.push({src:I?"local":"remote",from:O.ss,to:O.se,inherit:Te&&Te!=="straddle"?Te:null}),Me=O.be,I?(c+=O.text.length-(O.be-O.bs),G++):(T+=O.text.length-(O.be-O.bs),ge++);continue}let Le=O.bs,ct=O.be,Je=G,st=ge,Bt=Ct=>Ct.bs<ct&&Ct.be>Le||ie(Ct)&&(Ct.bs===Le||Ct.bs===ct);I?Je++:st++,Ae&&(Le=Math.min(Le,B.bs),ct=Math.max(ct,B.be),I?st++:Je++);let vt=!0;for(;vt;){for(vt=!1;Je<x.length&&Bt(x[Je]);)Le=Math.min(Le,x[Je].bs),ct=Math.max(ct,x[Je].be),Je++,vt=!0;for(;st<S.length&&Bt(S[st]);)Le=Math.min(Le,S[st].bs),ct=Math.max(ct,S[st].be),st++,vt=!0}let on=Le+c,Gt=Le+T,dn=ct-Le,gn=ct-Le;for(let Ct=G;Ct<Je;Ct++)dn+=x[Ct].text.length-(x[Ct].be-x[Ct].bs);for(let Ct=ge;Ct<st;Ct++)gn+=S[Ct].text.length-(S[Ct].be-S[Ct].bs);let xn=on+dn,Tn=Gt+gn;P(Le);let qt={kind:"text",node:e.node||null,base:zn(k,Le,ct),local:zn(d,on,xn),remote:zn(w,Gt,Tn),resolved:null,range:null,bs:Le,be:ct,lss:on,lse:xn,rss:Gt,rse:Tn};qt.resolved=t==="local"?qt.local:t==="remote"?qt.remote:qt.local+qt.remote,t!=="remote"&&z.push({src:"local",from:on,to:xn,conflict:qt}),t!=="local"&&z.push({src:"remote",from:Gt,to:Tn,conflict:qt});let ao={site:"inline",fb:k,fl:d,fr:w,scope:e.scope||null,synthetic:!!e.synthetic,full:xe,merged:h};M.push(ao),N(qt,ao),Me=ct,c+=dn-(ct-Le),T+=gn-(ct-Le),G=Je,ge=st}P(b);let U=k.text,_=[];if(se.respell.size||at.respell.size){let s=qo(be),g=[];for(let I=0;I<be.length;I++){let O=be[I].raw,B=se.respell.get(I)??O,$=at.respell.get(I)??O;(B!==O||$!==O)&&_.push([s[I],B!==O&&$!==O?"both":B!==O?"local":"remote"]),g.push(B===$?B:B===O?$:$===O||t==="local"?B:$)}U=g.join("")}let q="",Y=[],ce=[],Se=[],Ee=[];for(let s of z){let g=q.length;if(s.src==="base"){for(let I=s.from;I<s.to;I++)Y.push(I),ce.push(I+s.dL),Se.push(I+s.dR),Ee.push(s);q+=U.slice(s.from,s.to)}else if(s.src==="both"){for(let I=0;I<s.len;I++)Y.push(-1),ce.push(s.lfrom+I),Se.push(s.rfrom+I),Ee.push(s);q+=d.text.slice(s.lfrom,s.lfrom+s.len)}else{let I=s.src==="local"?d:w;for(let O=s.from;O<s.to;O++)Y.push(-1),ce.push(s.src==="local"?O:-1),Se.push(s.src==="remote"?O:-1),Ee.push(s);q+=I.text.slice(s.from,s.to)}s.ms=g,s.me=q.length,s.conflict&&(s.conflict.range||(s.conflict.range=[g,g]),s.conflict.range[1]=q.length)}let Ie=q.length,et=new Int32Array(b+1).fill(-1),Be=new Int32Array(d.text.length+1).fill(-1),St=new Int32Array(w.text.length+1).fill(-1);for(let s=0;s<Ie;s++)Y[s]>=0&&(et[Y[s]]=s),ce[s]>=0&&(Be[ce[s]]=s),Se[s]>=0&&(St[Se[s]]=s);let Ve=(s,g)=>{let I=-1,O=-1;for(let B=s.from;B<s.to;B++){let $=g[B];$>=0&&(I<0&&(I=$),O=$+1)}return I<0?null:[I,O]},pt=[],it=[];for(let s of new Set(Tt.values()))s.new==="local"?pt.push(s):s.new==="remote"&&it.push(s);let Ft=(s,g)=>{s.remote=g.remote,s.remoteMark=g.remoteMark,s.new="both",g.merged=s,Tt.set(g.remote,s)};if(pt.length&&it.length){let s=e.idOf;for(let g of pt){let I=s?s.local(g.local):null;if(!I)continue;let O=it.find(B=>!B.merged&&B.tag===g.tag&&!!B.block==!!g.block&&s.remote(B.remote)===I);O&&Ft(g,O)}for(let g of pt){if(g.remote)continue;let I=Ve(g.localMark,Be);if(I)for(let O of it){if(O.merged||O.tag!==g.tag||!!O.block!=!!g.block)continue;let B=Ve(O.remoteMark,St);if(B&&Math.min(I[1],B[1])-Math.max(I[0],B[0])>0){Ft(g,O);break}}}}It.clear();let Rt=s=>{for(let g of s)if(g.block)return Jt(Tt.get(g.el));return null},Kt=k.marks.some(s=>s.block)||d.marks.some(s=>s.block)||w.marks.some(s=>s.block),Lt=new Array(Ie).fill(null),ut=new Set;if(Kt){let s=(Te,Le,ct)=>{let Je=new Set([Te,Le,ct]);Je.delete(null);let st=[];for(let vt of Je){let on=vt===Te,Gt=vt===Le,dn=vt===ct;(Gt===dn?Gt:Gt===on?dn:Gt)&&st.push(vt)}if(st.length<=1)return st[0]||null;let Bt=t==="local"?Le:ct;return st.includes(Bt)?Bt:st[0]},g=(Te,Le)=>Le>=0?Rt(Te.stackAt[Le]):null,I=new Map;for(let Te=0;Te<Ie;Te++){if(q[Te]!==gt)continue;let Le=Y[Te]>=0?g(k,Y[Te]):null,ct=g(d,ce[Te]),Je=g(w,Se[Te]);I.set(Te,[Le,Y[Te]>=0?s(Le,ct,Je):ct||Je])}let O=new Set([...I.values()].map(Te=>Te[1])),B=Te=>Te!==gt&&Te!==$n&&!/\s/.test(Te),$=(Te,Le)=>{let ct=Te;for(;ct<Le&&!B(q[ct]);)ct++;return ct<Le&&Y[ct]>=0?g(k,Y[ct]):null},me=new Map,Ae=0;for(let Te=0;Te<Ie;Te++){if(q[Te]!==gt)continue;let[Le,ct]=I.get(Te),Je=$(Ae,Te),st=ct,Bt=me.get(st)===st&&Je===st;st&&me.has(st)&&!Bt&&Le&&!me.has(Le)&&!O.has(Le)&&(st=Le),st&&!me.has(st)&&me.set(st,Je);for(let vt=Ae;vt<=Te;vt++)Lt[vt]=st;Ae=Te+1}let qe=Te=>{for(let Le=0;Le<Te.text.length;Le++)if(B(Te.text[Le])&&!g(Te,Le))return!0;return!1};if(!qe(k)&&!qe(d)&&!qe(w)){let Te=[],Le=0;for(let Je=0;Je<Ie;Je++)(q[Je]===gt||Je===Ie-1)&&(Te.push([Le,Je]),Le=Je+1);let ct=new Set(Lt);for(let Je=0;Je<Te.length;Je++){let[st,Bt]=Te[Je];if(Lt[Bt])continue;let vt=st;for(;vt<=Bt&&!B(q[vt]);)vt++;if(vt>Bt)continue;let on=g(k,Y[vt]),Gt=g(d,ce[vt]),dn=g(w,Se[vt]),gn=s(on,Gt,dn)||Gt||dn||on;if(gn&&!ct.has(gn)){ct.add(gn);for(let qt=st;qt<=Bt;qt++)Lt[qt]=gn;continue}let xn=Je>0&&Lt[Te[Je-1][1]],Tn=Je+1<Te.length&&Lt[Te[Je+1][1]];if(xn)ut.add(Te[Je-1][1]);else if(Tn&&q[Bt]===gt)ut.add(Bt);else continue;for(let qt=st;qt<=Bt;qt++)Lt[qt]=xn||Tn}}}let At=new Map,Nt=s=>{let g=At.get(s);if(g)return g;g=[1/0,-1/0];for(let[I,O]of[[s.baseMark,et],[s.localMark,Be],[s.remoteMark,St]]){let B=I&&Ve(I,O);B&&(g[0]=Math.min(g[0],B[0]),g[1]=Math.max(g[1],B[1]))}return At.set(s,g),g},jt=(s,g,I)=>{let O=-1,B=-1;for(let $=0;$<s.length;$++){let me=Tt.get(s[$].el);me===g&&(O=$),me===I&&(B=$)}return O>=0&&B>=0?O-B:0},Qt=(s,g)=>[...s].sort((I,O)=>{for(let me of g){let Ae=jt(me,I,O);if(Ae)return Ae}let B=Nt(I),$=Nt(O);return B[0]-$[0]||$[1]-B[1]||I.rank-O.rank||I.id-O.id}),fn=new Map,An=new Map,vn=s=>{let g=Y[s],I=ce[s],O=Se[s],B=Ee[s];if(g>=0){let Je=k.stackAt[g],st=d.stackAt[I],Bt=w.stackAt[O],vt=fn.get(Je);vt||fn.set(Je,vt=new Map);let on=vt.get(st);on||vt.set(st,on=new Map);let Gt=on.get(Bt);if(Gt)return Gt;let dn=Et(Je),gn=Et(st),xn=Et(Bt),Tn=new Set;for(let qt of new Set([...dn,...gn,...xn])){let ao=dn.has(qt),Ct=gn.has(qt),to=xn.has(qt);(Ct===to?Ct:Ct===ao?to:Ct)&&Tn.add(qt)}return Gt=Qt(Tn,[st,Bt,Je]),on.set(Bt,Gt),Gt}if(B.src==="both"){let Je=d.stackAt[I],st=w.stackAt[O];return Qt(new Set([...Et(Je),...Et(st)]),[Je,st])}let me=(B.src==="local"?d:w).stackAt[B.src==="local"?I:O];if(!B.inherit)return Qt(Et(me),[me]);let Ae=An.get(B);Ae||An.set(B,Ae=new Map);let qe=Ae.get(me);if(qe)return qe;let Te=new Set(Et(me));for(let Je of B.inherit.added)Te.add(Jt(Je));for(let Je of B.inherit.removed)Te.delete(Jt(Je));let Le=B.src==="local"?w:d,ct=(B.src==="local"?le.bTo:ft.bTo)[B.inherit.bs];return qe=Qt(Te,[me,Le.stackAt[ct]]),Ae.set(me,qe),qe},kn=new Int32Array(d.text.length+1);kn[d.text.length]=Ie;for(let s=d.text.length-1;s>=0;s--)kn[s]=Be[s]>=0?Be[s]:kn[s+1];xr.caret+=d.text.length;let rn=s=>s<=0?0:(s>d.text.length&&(s=d.text.length),Be[s-1]>=0?Be[s-1]+1:kn[s]),zt=[],J=[],Re=null,ve=[],Ye="",lt=-1,De=s=>{Re?Re.appendChild(s):zt.push(s)},Ke=s=>{if(!Ye)return;let g=o.createTextNode(Ye);De(g),J.push({node:g,ms:lt,me:s,local:[],u:ve.length?ve[ve.length-1].u:null}),Ye=""},tt=new Set,_e=new Map,ot=new Set,Zt=s=>{let g=o.createElement(s.tag);if(s.block&&Vt.add(g),!_e.has(s)){_e.set(s,g),re(s.base,s.local,s.remote,g),a.set(g,{base:s.base,local:s.local,remote:s.remote});let O=(me,Ae)=>L&&s[Ae]&&me.reverse.get(s[Ae])?Ae:null,B=!s.base&&(O(n,"local")||O(r,"remote"));if(B){let me=B==="local"?n.reverse.get(s.local):r.reverse.get(s.remote),Ae=a.get(g);Ae.local=Ae.local||n.map.get(me)||null,Ae.remote=Ae.remote||r.map.get(me)||null,u.push({kind:"move",el:g,source:B})}else s.base||u.push({kind:"insert",el:g,source:s.local&&s.remote?"both":s.local?"local":"remote"});let $=a.get(g);$.local&&(ot.has($.local)?$.local=null:ot.add($.local))}else{let O=_e.get(s);for(let B of O.attributes)B.name!=="id"&&B.name!=="data-id"&&ee(g,B,B.value);a.set(g,{base:null,local:null,remote:null})}De(g),ve.push({u:s,el:g}),Re=g},En=new Set,un=new Map;for(let s of d.pins){let g=rn(s.i);un.has(g)||un.set(g,[]),un.get(g).push(s)}let ln=s=>{let g=un.get(s);if(g){Ke(s);for(let I of g){let O=I.el.namespaceURI&&I.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(I.el.namespaceURI,I.el.tagName):o.createElement(I.el.tagName);a.set(O,{base:null,local:I.el,remote:null,pinned:!0}),En.add(O),De(O)}}},Rn=k.atoms.length||d.atoms.length||w.atoms.length,Xe=s=>{if(!Rn)return null;let g=Y[s]>=0?k.atomAt.get(Y[s]):null,I=ce[s]>=0?d.atomAt.get(ce[s]):null,O=Se[s]>=0?w.atomAt.get(Se[s]):null;return g||I||O?{ab:g,al:I,ar:O}:null},dt=(s,g,I,O)=>{if(!s||!L)return null;let B=Z.get(g.reverse.get(s.el))||null;return!B||B===O||(O?B.el.isEqualNode(O.el):I.bTo[B.i]>=0)?null:B},ke=(s,g)=>{if(!s||!L||!e.moveIn)return null;let I=g.reverse.get(s.el);return I&&!Z.has(I)?I:null},Ce=(s,g)=>{let I=new Map;for(let O of s.atoms)I.set(g(O),(I.get(g(O))||0)+1);return I},We=Ce(k,ae),nt=Ce(d,te),$e=Ce(w,V),yt=s=>{let g=ae(s);return We.get(g)===1&&(nt.get(g)||0)<=1&&($e.get(g)||0)<=1},kt=new Map,Pt=new Set,Wt=new Set,nn=new Set;for(let s=0;s<Ie;s++){let g=Xe(s);if(!g)continue;let{ab:I,al:O,ar:B}=g,$=dt(B,r,le,I),me=dt(O,n,ft,I),Ae=I,qe=null;if($?(Ae=$,qe="remote"):me&&(Ae=me,qe="local"),Ae){Pt.has(Ae)?kt.set(s,{dup:Ae.el}):(Pt.add(Ae),kt.set(s,{bk:Ae,from:qe,al:O,ar:B}));continue}let Te=ke(B,r),Le=ke(O,n),ct=Te||Le;if(ct){Wt.has(ct)?kt.set(s,{dup:ct}):(Wt.add(ct),kt.set(s,{moveIn:ct,side:Te?"remote":"local",sideEl:Te?B.el:O.el}));continue}let Je=(Bt,vt)=>Bt&&L&&Z.get(vt.reverse.get(Bt.el))||null,st=Je(B,r)||Je(O,n);if(st&&(nn.add(st),Ee[s].conflict&&yt(st))){if(Pt.has(st)){kt.set(s,{dup:st.el});continue}Pt.add(st)}kt.set(s,{al:O,ar:B})}let Ot=new Map,Sn=(s,g)=>{if(s[g]>=0)return s[g];for(let I=g-1;I>=0;I--)if(s[I]>=0)return s[I]+1;return 0};if(L)for(let s of k.atoms){if(Pt.has(s)||nn.has(s))continue;let g=n.map.get(s.el)||null,I=r.map.get(s.el)||null,O=g&&fe.get(g),B=I&&we.get(I);if(g&&!O||I&&!B)continue;let $=!(O&&B)&&rt.has(s);if(!$&&!(O&&B&&yt(s)))continue;let me=t==="local"?[[O,Be],[B,St]]:[[B,St],[O,Be]],[Ae,qe]=me.find(([Le])=>Le),Te=Sn(qe,Ae.i);Ot.has(Te)||Ot.set(Te,[]),Ot.get(Te).push({a:s,lt:g,rt:I,edited:$}),Pt.add(s)}if(L&&e.moveIn){let s=[[d,n,Be,"local"],[w,r,St,"remote"]];t!=="local"&&s.reverse();for(let[g,I,O,B]of s)for(let $ of g.atoms){let me=ke($,I);if(!me||Wt.has(me))continue;Wt.add(me);let Ae=Sn(O,$.i);Ot.has(Ae)||Ot.set(Ae,[]),Ot.get(Ae).push({move:me,side:B,sideEl:$.el})}}let Ut=s=>{let g=Ot.get(s);if(g){if(Ke(s),g.some(I=>Ze(I.move?I.sideEl:I.a.el)))for(;ve.length;)ve.pop(),Re=ve.length?ve[ve.length-1].el:null;for(let{a:I,lt:O,rt:B,edited:$,move:me,side:Ae,sideEl:qe}of g){if(me){let Le=e.moveIn(me,Ae,qe);Le&&De(Le);continue}tt.add(I);let Te=ne(I.el,O,B);$&&(N({kind:"structure",el:Te,detail:"edit-beats-delete",base:I.el},{subject:I.el,deleted:O?"remote":"local"}),u.push({kind:"insert",el:Te,source:O?"local":"remote"})),De(Te)}}},Vt=new Set,cn=i.length>A;for(let s=0;s<Ie;s++){let g=Xe(s),O=!!g&&Ze((g.ab||g.al||g.ar).el)?[]:Lt[s]?[Lt[s],...vn(s)]:vn(s),B=0;for(;B<ve.length&&B<O.length&&ve[B].u===O[B];)B++;if(B<ve.length)for(Ke(s);ve.length>B;)ve.pop(),Re=ve.length?ve[ve.length-1].el:null;if(ln(s),Ut(s),O.length>ve.length)for(Ke(s);ve.length<O.length;)Zt(O[ve.length]);if(q[s]===gt){if(ut.has(s))continue;Ke(s);let $=ve.length;for(;$>0&&!ve[$-1].u.block;)$--;if($>0)for(cn&&h.breakOut.set(s,ve[$-1].el);ve.length>=$;)ve.pop(),Re=ve.length?ve[ve.length-1].el:null;continue}if(g){Ke(s);let $=kt.get(s),me;if($.dup){N({kind:"structure",el:null,detail:"both-moved",base:$.dup},{subject:$.dup});continue}if($.moveIn){if(me=e.moveIn($.moveIn,$.side,$.sideEl),!me)continue}else if($.bk){let Ae=$.bk;if(tt.add(Ae),Ae===g.ab)me=ne(Ae.el,$.al.el,$.ar.el);else{let qe=n.map.get(Ae.el)||null,Te=r.map.get(Ae.el)||null;me=ne(Ae.el,qe,Te),(!qe||!Te)&&N({kind:"structure",el:null,detail:"move-beats-delete",base:Ae.el},{subject:Ae.el,deleted:qe?"remote":"local"}),u.push({kind:"move",el:me,source:$.from})}}else $.al?(me=K($.al.el,"local"),$.ar&&(a.get(me).remote=$.ar.el),u.push({kind:"insert",el:me,source:$.ar?"both":"local"})):(me=K($.ar.el,"remote"),u.push({kind:"insert",el:me,source:"remote"}));cn&&h.atomOut.set(s,me),De(me);continue}Ye||(lt=s),Ye+=q[s]}if(Ke(Ie),(un.has(Ie)||Ot.has(Ie))&&(ve.length=0,Re=null,ln(Ie),Ut(Ie)),Ie===0&&(d.placeholder||w.placeholder||k.placeholder)){let s=o.createElement("br");a.set(s,{base:k.placeholder,local:d.placeholder,remote:w.placeholder}),zt.push(s)}let pn=0,lo=s=>{for(;pn>0&&J[pn-1].me>=s;)pn--;for(;pn<J.length&&J[pn].me<s;)pn++;let g=J[pn];if(!g)return J[J.length-1]||null;let I=J[pn+1];return g.me===s&&I&&I.ms===s?I:g},Un=new Map,eo={},Pe=(s,g,I)=>{let O=lo(s)||(I?eo:null);if(!O)return;let B=Un.get(O)||{l:!1,r:!1};g!=="remote"&&(B.l=!0),g!=="local"&&(B.r=!0),Un.set(O,B)},ht=s=>{if(s.conflict)return!0;let g=s.src==="local"?d.text:s.src==="remote"?w.text:"";for(let I=s.from;I<s.to;I++)if(g[I]!==$n&&g[I]!==gt)return!0;return!1};for(let s of z)s.src!=="base"&&Pe(s.ms,s.conflict?"both":s.src,ht(s));for(let[s,g]of _)et[s]>=0&&Pe(et[s],g);for(let s of J.length?J:[eo]){let g=Un.get(s);g&&u.push({kind:"text",node:s.node||null,source:g.l&&g.r?"both":g.l?"local":"remote"})}for(let s of tn){if(_e.has(s))continue;let g=!s.local&&!(L&&n.map.get(s.base)),I=!s.remote&&!(L&&r.map.get(s.base));!g&&!I||u.push({kind:"remove",source:g&&I?"both":g?"local":"remote",base:s.base})}let Mt=(s,g,I)=>{if(g<=s)return!1;for(let O=s;O<g;O++)if(I[O]>=0)return!1;return!0};for(let s of tn)for(let g of["local","remote"]){let I=s[g+"Mark"],O=s.baseMark;if(!I)continue;let B=g==="local"?ft:le;if(!Mt(O.from,O.to,B.bTo)||!Mt(I.from,I.to,B.toB))continue;let $=(g==="local"?x:S).find(me=>me.ss<=I.from&&I.from<me.se);$&&($.be<=O.from||$.bs>=O.to)&&u.push({kind:"move",el:_e.get(s)||null,source:g})}let xt=s=>{let g=Tt.get(s.node.parentNode);return g?Jt(g):null};for(let s of d.nodes){let g=-1;for(let O=s.s;O<s.e;O++)if(Be[O]>=0){g=Be[O];break}let I;if(g>=0)I=lo(g);else{let O=rn(s.s),B=xt(s);I=J.find($=>$.u===B&&$.me>=O)||J.filter($=>$.u===B).pop()}I&&I.local.push(s)}let mt=new Map,mn=J[J.length-1]||null,_t=0;for(let s of d.nodes){let g=null;for(let I=s.s;I<=s.e;I++){let O=rn(I);for(;_t>0&&J[_t-1].me>=O;)_t--;for(;_t<J.length&&J[_t].me<O;)_t++;let B=me=>me&&O>=me.ms&&O<=me.me&&(O<me.me||I===s.e||me===g),$=B(J[_t])?J[_t]:B(J[_t+1])?J[_t+1]:J[_t]||mn;if(!$)break;if(g===$){let me=mt.get($);me[me.length-1].to=I-s.s;continue}g=$,mt.has($)||mt.set($,[]),mt.get($).push({node:s.node,from:I-s.s,to:I-s.s,flatStart:s.s})}}for(let s of J){let g=s.local,I=!1;for(let me of g)for(let Ae=me.s;Ae<me.e&&!I;Ae++)(Be[Ae]<s.ms||Be[Ae]>=s.me)&&(I=!0);a.set(s.node,{base:null,local:g.map(me=>me.node),remote:null,caret:mt.get(s)||[],partial:I});let O=s.ms,B=s.me-s.ms,$=me=>{let Ae=0,qe=-1;for(let Te of g){let Le=Te.e-Te.s;if(me<=Ae+Le){qe=Te.s+(me-Ae);break}Ae+=Le}return qe<0&&(qe=g.length?g[g.length-1].e:0),Math.max(0,Math.min(rn(qe)-O,B))};$.flat=me=>Math.max(0,Math.min(rn(me)-O,B)),l.set(s.node,$)}function On(){if(!d.text.includes(gt))return[{flatLocal:d.text,localNodes:d.nodes,textNodes:J,lToM:Be,mapLocal:rn}];let s=[],g=0,I=0;for(let O=0;O<=d.text.length;O++){if(O<d.text.length&&d.text[O]!==gt)continue;let B=g,$=O;if($>B){let me=[];for(;I<d.nodes.length&&d.nodes[I].e<=B;)I++;for(let Ae=I;Ae<d.nodes.length&&d.nodes[Ae].s<$;Ae++){let qe=d.nodes[Ae],Te=Math.max(qe.s,B),Le=Math.min(qe.e,$);Te<Le&&me.push({node:qe.node,s:Te-B,e:Le-B})}s.push({flatLocal:d.text.slice(B,$),localNodes:me,textNodes:J,lToM:Be.subarray?Be.subarray(B,$+1):Be.slice(B,$+1),mapLocal:Ae=>rn(B+Math.max(0,Math.min(Ae,$-B)))})}g=O+1}return s}let yn={...e,blocks:Vt,ignored:s=>En.has(s)||(e.ignored?e.ignored(s):!1)},$t=e.ignoreAttribute||(()=>!1),co=is(Nn(zt,yn),$t)!==is(w,$t);if(M.length){let s=g=>{let I=a.get(g);return I&&I.unchanged?I.remote:null};h.text=q,h.textNodes=J,h.out=Nn(zt,{...yn,via:s})}return{nodes:zt,text:q,textNodes:J,localDiverged:co,mapLocal:rn,conflicts:i.slice(A),granularity:Ue?"line":"word",segments:On(),localHunks:x,remoteHunks:S,lToM:Be}}var Sr="http://www.w3.org/1999/xhtml";function Or(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function en(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Sr}function Mr(e){let o=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return o==="application/json"||o.endsWith("+json")}function bo(e,o){let t=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let r=t;try{let a=new URL(t,o);r=a.origin+a.pathname+a.search}catch{}return"script|src|"+n+"|"+r}return"script|inline|"+n+"|"+Or(e.textContent.trim())}var Ir={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function Gn(e,o=[],t=!1){if(!en(e)||e.hasAttribute("src"))return null;let n=[Ir,...o];for(let r=0;r<n.length;r++){let a=n[r];if(!a.match(e))continue;if(!Mr(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=a.identity(e);return l==null||l===""?null:{key:r+":"+l,raw:l,recognizer:a}}return null}function hs(e,o,t){let n=new Set,r=a=>{en(a)&&!o(a)&&n.add(bo(a,t))};r(e);for(let a of e.querySelectorAll("script"))r(a);return n}function no(e,o){let t=o.createElement("div");t.innerHTML="<script><\/script>";let n=t.firstChild;for(let r of e.attributes)n.setAttribute(r.name,r.value);return n.textContent=e.textContent,n}function ps(e,o,t){let n=[],r=[],a=new Map,l=t.trackRecovery?new Set:null,i=Array.from(e.querySelectorAll("script"));en(e)&&i.unshift(e);for(let u of i){if(!en(u)||t.ignored(u)||t.skip.has(u)||o.has(bo(u,t.baseURI)))continue;let A=u.ownerDocument.createElement("script");for(let N of u.attributes)A.setAttribute(N.name,N.value);if(A.textContent=u.textContent,t.beforeNodeAdded(A)===!1){l?.add(u);continue}A.hasAttribute("src")&&r.push(new Promise(N=>{A.addEventListener("load",()=>N()),A.addEventListener("error",()=>N())})),u.replaceWith(A),a.set(u,A),t.afterNodeAdded(A),n.push(A)}return{executed:n,loads:r,swapped:a,vetoed:l}}function Lr(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function Cr(e,o){try{let t=new URL(e,o);return t.origin+t.pathname+t.search}catch{return e}}function ms(e,o){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return bo(e,o);if(t==="LINK"){let n=e.getAttribute("href");return n?"link|"+(e.getAttribute("rel")||"")+"|"+Cr(n,o):e.outerHTML}if(t==="META"){for(let n of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(n))return"meta|"+n+"="+e.getAttribute(n);return e.outerHTML}return t==="STYLE"?"style|"+Lr(e.textContent):e.outerHTML}function Fo(e,o){for(;;){for(;o<e.length&&/\s/.test(e[o]);)o++;if(e[o]==="/"&&e[o+1]==="/"){for(;o<e.length&&e[o]!==`
4
- `;)o++;continue}if(e[o]==="/"&&e[o+1]==="*"){let t=e.indexOf("*/",o+2);if(t===-1)return e.length;o=t+2;continue}return o}}function gs(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(o,t)=>t.length%2===0?t+'\\"':o)}var Er=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Rr=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ko(e){try{return JSON.parse(e)}catch{return JSON.parse(Pr(e))}}function Pr(e){let o="",t=0,n=(r,a)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${a}`)};for(;t<e.length&&(t=Fo(e,t),!(t>=e.length));){let r=e[t];if("{}[]:".includes(r)){o+=r,t++;continue}if(r===","){let i=Fo(e,t+1);if(e[i]==="}"||e[i]==="]"){t++;continue}o+=r,t++;continue}if(r==='"'||r==="'"){let i=t+1;for(;i<e.length&&e[i]!==r;)e[i]==="\\"&&i++,i++;i>=e.length&&n("unterminated string",t);let u=e.slice(t+1,i);r==="'"&&(u=gs(u)),o+='"'+u+'"',t=i+1;continue}let a=t;for(;a<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[a]);)a++;a===t&&n("unexpected character "+JSON.stringify(r),t);let l=e.slice(t,a);if(l==="true"||l==="false"||l==="null"||Er.test(l)){o+=l,t=a;continue}if(Rr.test(l)){if(e[Fo(e,a)]===":"){o+='"'+l+'"',t=a;continue}n("unquoted value "+JSON.stringify(l),t)}n("invalid token "+JSON.stringify(l),t)}return o}function bs(e){try{return JSON.parse(e)}catch{}let o={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(r){let a=[],l=0;for(;l<r.length;){let i=r[l];if(/\s/.test(i)){l++;continue}if("{}".includes(i)){a.push({type:i,value:i}),l++;continue}if(i==="["){let h=!1,M=l+1;for(;M<r.length&&/\s/.test(r[M]);)M++;if(M<r.length&&/[a-zA-Z_]/.test(r[M])&&(h=!0),!h){a.push({type:i,value:i}),l++;continue}}if(i==="]"){a.push({type:i,value:i}),l++;continue}if(i===":"){a.push({type:o.COLON,value:i}),l++;continue}if(i===","){a.push({type:o.COMMA,value:i}),l++;continue}if(i==='"'||i==="'"){let h=i,M=l+1;for(;M<r.length&&r[M]!==h;)r[M]==="\\"&&M++,M++;a.push({type:o.STRING,value:r.substring(l+1,M),quoted:!0,sourceQuote:h}),l=M+1;continue}let u=l,A;for(;u<r.length&&!/[{},]/.test(r[u]);)if(r[u]===":"){let h=[":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"],M=!1;for(let L of h){let R=L.substring(1);if(r.substring(u+1,u+1+R.length)===R){M=!0,u+=R.length;break}}if(!M)break}else if(r[u]==="["){for(u++;u<r.length&&r[u]!=="]";){if(r[u]==='"'||r[u]==="'"){let h=r[u];for(u++;u<r.length&&r[u]!==h;)r[u]==="\\"&&u++,u++}u++}u<r.length&&r[u]==="]"&&u++}else u++;A=r.substring(l,u);let N=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(A)?N=o.NUMBER:A==="true"||A==="false"||A==="null"?N=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(A)&&(N=o.SELECTOR),a.push({type:N,value:A,quoted:!1}),l=u}return a}function n(r){let a="";for(let l=0;l<r.length;l++){let i=r[l];if("{}".includes(i.type)||"[]".includes(i.type)){a+=i.value;continue}if(i.type===o.COLON){a+=i.value;continue}if(i.type===o.COMMA){let u=r[l+1];if(u&&(u.type==="}"||u.type==="]"))continue;a+=i.value;continue}if(i.type===o.STRING){let u=i.value;i.sourceQuote==="'"&&(u=gs(u)),a+=`"${u}"`;continue}if(i.type===o.NUMBER||i.type===o.BOOLEAN){a+=i.value;continue}a+=`"${i.value}"`}return a}try{let r=t(e),a=n(r);return JSON.parse(a)}catch(r){throw new Error("Invalid extraction rules syntax: "+r.message)}}var Ht=Symbol("hyper-morph-json-merge:missing"),ks=["id","_id","uuid","key","slug","code","name"];function Yn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function oo(e,o){return Object.prototype.hasOwnProperty.call(e,o)}function Br(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Ln(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o)){if(e.length!==o.length)return!1;for(let t=0;t<e.length;t++)if(!Ln(e[t],o[t]))return!1;return!0}if(Yn(e)&&Yn(o)){let t=Object.keys(e);if(t.length!==Object.keys(o).length)return!1;for(let n of t)if(!oo(o,n)||!Ln(e[n],o[n]))return!1;return!0}return!1}function ys(e,o,t,n){return Ln(o,t)?o:Ln(o,e)?t:Ln(t,e)?o:Yn(o)&&Yn(t)?Hr(Yn(e)?e:{},o,t,n):Array.isArray(o)&&Array.isArray(t)?Vr(Array.isArray(e)?e:[],o,t,n):t}function ws(e,o,t,n){return o===Ht&&t===Ht?Ht:o===Ht?e===Ht?t:Ln(t,e)?Ht:t:t===Ht?e===Ht?o:Ht:ys(e,o,t,n)}function Hr(e,o,t,n){let r={},a=new Set([...Object.keys(e),...Object.keys(o),...Object.keys(t)]);for(let l of a){let i=ws(oo(e,l)?e[l]:Ht,oo(o,l)?o[l]:Ht,oo(t,l)?t[l]:Ht,n);i!==Ht&&Br(r,l,i)}return r}function jr(e){return e===null||typeof e!="object"}function yo(e){return typeof e+":"+String(e)}function Dr(e,o){for(let t of o){let n=new Set;for(let r of t){if(!oo(r,e))return!1;let a=r[e];if(typeof a!="string"&&typeof a!="number")return!1;let l=yo(a);if(n.has(l))return!1;n.add(l)}}return!0}function Ur(e,o,t,n){let r=[e,o,t],a=!0;for(let l of r)for(let i of l)Yn(i)||(a=!1);if(a){for(let l of n.keyCandidates)if(Dr(l,r))return{kind:"keyed",field:l};return null}for(let l of r){let i=new Set;for(let u of l){if(!jr(u))return null;let A=yo(u);if(i.has(A))return null;i.add(A)}}return{kind:"self"}}function Vr(e,o,t,n){let r=Ur(e,o,t,n);if(!r)return t;let a=r.kind==="self"?yo:L=>yo(L[r.field]),l=L=>{let R=new Map;for(let F of L)R.set(a(F),F);return R},i=l(e),u=l(o),A=l(t),N=new Map,h=new Set([...i.keys(),...u.keys(),...A.keys()]);for(let L of h){let R=ws(i.has(L)?i.get(L):Ht,u.has(L)?u.get(L):Ht,A.has(L)?A.get(L):Ht,n);R!==Ht&&N.set(L,R)}let M=[];for(let L of t){let R=a(L);N.has(R)&&M.push(R)}for(let L=0;L<o.length;L++){let R=a(o[L]);if(!N.has(R)||M.includes(R))continue;let F=0;for(let k=L-1;k>=0;k--){let d=M.indexOf(a(o[k]));if(d!==-1){F=d+1;break}}M.splice(F,0,R)}return M.map(L=>N.get(L))}function zo(e,o,t,n={}){let r=n.keyCandidates?[...n.keyCandidates,...ks]:ks;return ys(e===void 0?Ht:e,o,t,{keyCandidates:r})}function wo(e,o,t,n={}){let r=n.parse||ko,a=[],l=(h,M)=>{if(typeof h!="string")return Ht;try{return r(h)}catch(L){return a.push(`${M} side is not valid JSON (${L.message})`),Ht}},i=l(o,"local"),u=l(t,"remote");if(i===Ht)return{text:t,warnings:a};if(u===Ht)return{text:o,warnings:a};let A=l(e,"base"),N=zo(A===Ht?void 0:A,i,u,n);return Ln(N,u)?{text:t,warnings:a}:Ln(N,i)?{text:o,warnings:a}:{text:JSON.stringify(N,null,2),warnings:a}}var xs=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function jn(e){if(!e)return!1;let{startContainer:o,startOffset:t,endContainer:n,endOffset:r}=e;if(!o||!n||!Number.isInteger(t)||!Number.isInteger(r)||t<0||r<0||t>xs(o)||r>xs(n)||o.getRootNode()!==n.getRootNode())return!1;let a=o.ownerDocument.createRange();return a.setStart(o,t),a.setEnd(n,r),a.startContainer===o&&a.startOffset===t}function Cn(e,o,t={}){if(!jn(e))return null;let{startContainer:n,startOffset:r,endContainer:a,endOffset:l}=e;if(n===a&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(r,l);if(n===a&&r===l)return"";let i=new Set;for(let k=n;k;k=k.parentNode)i.add(k);let u=a;for(;!i.has(u);)u=u.parentNode;let A=(k,d)=>{let w=u.ownerDocument.createRange(),Z=u.ownerDocument.createRange();return w.setStart(k[0],k[1]),w.collapse(!0),Z.setStart(d[0],d[1]),Z.collapse(!0),w.compareBoundaryPoints(0,Z)},N=(k,d=!1)=>[k.parentNode,Array.prototype.indexOf.call(k.parentNode.childNodes,k)+Number(d)],h=[],M;if(o==="plain"){M="";let k=d=>{if(d.nodeType===3||d.nodeType===8){let w=M.length;M+=d.nodeValue,h.push({s:w,e:M.length,a:[d,0],b:[d,d.nodeValue.length],node:d})}else for(let w of d.childNodes)k(w)};k(u)}else{let k=t.blocks;if(!k){k=new Set;let w=Z=>{Z!==u&&Z.nodeType===1&&Ko.has(Z.tagName)&&k.add(Z);for(let he of Z.childNodes)w(he)};w(u)}let d=Nn(Array.from(u.childNodes),{blocks:k,atomize:w=>!!t.atoms?.has(w),ignored:t.ignored});M=d.text;for(let w of d.nodes)h.push({s:w.s,e:w.e,a:[w.node,0],b:[w.node,w.e-w.s],node:w.node});for(let w of d.atoms)h.push({s:w.i,e:w.i+1,a:N(w.el),b:N(w.el,!0)});for(let w=0;w<d.text.length;w++){if(d.text[w]!==gt)continue;let Z=d.marks.find(xe=>xe.block&&xe.to===w+1),he=d.marks.find(xe=>xe.block&&xe.from===w+1);if(Z)h.push({s:w,e:w+1,a:[Z.el,Z.el.childNodes.length],b:N(Z.el,!0)});else if(he)h.push({s:w,e:w+1,a:N(he.el),b:[he.el,0]});else return null}}h.sort((k,d)=>k.s-d.s);let L=k=>{if(k[0].nodeType===3||k[0].nodeType===8){let w=h.find(Z=>Z.node===k[0]);return w?w.s+k[1]:null}let d=0;for(let w of h){if(A(k,w.a)<=0)return w.s;if(A(k,w.b)<0)return null;d=w.e}return d},R=L([n,r]),F=L([a,l]);return R!==null&&F!==null&&R<=F?M.slice(R,F):null}function Hn(e,o){let t=e;for(let n of o.path)if(t=n==="content"?t?.content:t?.childNodes[n],!t)return null;return[t,o.offset]}function Ts(e,o){if(!e||!o)return null;let t=Hn(e,o.start),n=Hn(e,o.end);return t&&n?{startContainer:t[0],startOffset:t[1],endContainer:n[0],endOffset:n[1]}:null}var Ns=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function As(e,o,t){if(!o)return;let n=new Map,r=new Map,a=i=>{if(!i)return null;if(r.has(i))return r.get(i);let A=i.local.map(N=>Hn(o.localRoot,{path:N,offset:0})?.[0]).map(N=>N&&t(N)).filter(Boolean).map(N=>({node:N,parent:N.parentNode,previous:N.previousSibling,next:N.nextSibling,fragment:Ns(N)}));return r.set(i,A),A},l=i=>{let u=Ts(o.localRoot,i);if(!u)return null;let A=t(u.startContainer),N=t(u.endContainer);if(!A||!N)return null;let h={...u,startContainer:A,endContainer:N};return jn(h)?h:null};for(let i of e){let u=i.recovery;if(n.has(u))continue;let A={subject:a(u.subject),span:null,scope:null,touched:new Set};if(u.text){A.span=l(u.text.local.span),A.scope=l(u.text.local.scope);let N=A.span;if(N){let h=N.startContainer.ownerDocument.createRange();h.setStart(N.startContainer,N.startOffset),h.setEnd(N.endContainer,N.endOffset);let M=L=>{if(h.intersectsNode(L)){A.touched.add(L);for(let R of L.childNodes)M(R)}};M(h.commonAncestorContainer)}}if(u.structure){for(let N of[u.structure.localPlacement])N&&(a(N.parent),N.before.forEach(a),N.after.forEach(a));for(let N of u.structure.localOrder||[])a(N)}n.set(u,A)}o.localState={states:n,refs:r}}function vs(e,o,t,n){let r=t.localState?.states.get(e);if(!r)return!1;let a=i=>{let u=i.node;if(!n(u)||u.parentNode!==i.parent)return!1;let A=N=>Array.prototype.indexOf.call(u.parentNode.childNodes,N);return!(i.previous&&n(i.previous)&&i.previous.parentNode===u.parentNode&&A(i.previous)>=A(u)||i.next&&n(i.next)&&i.next.parentNode===u.parentNode&&A(i.next)<=A(u))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!r.subject.length||!r.subject.every(a))return!1;if(e.text){let i=e.text.local,u=A=>A&&n(A.startContainer)&&n(A.endContainer);return u(r.span)&&u(r.scope)&&Cn(r.scope,e.text.encoding)===i.text&&Cn(r.span,e.text.encoding)===i.text.slice(i.start,i.end)}if(e.attribute){let i=e.attribute,u=r.subject[0].node;return(i.namespaceURI?u.getAttributeNS(i.namespaceURI,i.localName):u.getAttribute(i.qualifiedName))===o.local}let l=e.structure;if(l.localOrder){let i=-1,u=null;for(let A of l.localOrder){let N=t.localState.refs.get(A)?.[0]?.node;if(!N||!n(N)||u&&N.parentNode!==u)return!1;let h=Array.prototype.indexOf.call(N.parentNode.childNodes,N);if(h<=i)return!1;u=N.parentNode,i=h}return!0}return l.localAction==="moved"||r.subject.every(i=>Ns(i.node)===i.fragment)}var _r=1,Yt=e=>!!e&&e.nodeType===1,xo=e=>Yt(e)&&e.tagName==="TEMPLATE"&&!!e.content;function Dn(e,o=null,t=null){let n=new Map,r=new Map,a=N=>{if(!o){o=new WeakMap;let h=[e];for(;h.length;){let M=h.pop();xo(M)&&(o.set(M.content,M),h.push(M.content));for(let L=M.firstChild;L;L=L.nextSibling)L.nodeType===1&&h.push(L)}}return o.get(N)||null},l=(N,h)=>{let M=r.get(N);if(!M){M=new Map;let L=0;for(let R=N.firstChild;R;R=R.nextSibling)M.set(R,L++);r.set(N,M)}return M.get(h)},i=N=>{if(!N)return null;if(t&&t.has(N))return i(t.get(N));if(N===e)return[];let h=n.get(N);if(h!==void 0)return h;let M=N.parentNode,L=null;if(M&&M.nodeType===11){let R=a(M),F=R?i(R):null;F&&(L=F.concat(["content",l(M,N)]))}else if(M){let R=i(M);R&&(L=R.concat([l(M,N)]))}return n.set(N,L),L};return{root:e,pathOf:i,logicalParent:N=>{let h=N.parentNode;return h&&h.nodeType===11?a(h):h},indexIn:l,containerPath:N=>{if(N.nodeType===11){let M=a(N),L=i(M);return L?L.concat(["content"]):null}let h=i(N);return h&&xo(N)?h.concat(["content"]):h},ownerOf:a}}var bn=e=>xo(e)?e.content:e;function Ss(e){let{L:o,R:t,unitsOf:n,provenance:r,policy:a}=e,l=[];return{note:(N,h)=>{l.push([N,h])},finish:N=>l.length?A(N):null};function A(N){let h={base:Dn(e.roots.base),local:Dn(e.roots.local),remote:Dn(e.roots.remote)},M=p=>p==="local"?o:t,L=(p,y)=>{if(!y)return null;if(p.map.has(y))return p.map.get(y);let E=[],f=Yt(y)?h.base.logicalParent(y):y.parent;for(;f&&!p.map.has(f);f=h.base.logicalParent(f))E.push(f);if(!f||!p.identical.has(f))return null;let m=p.map.get(f);for(let C=E.length-1;C>=0&&m;C--)m=bn(m).childNodes[h.base.indexIn(E[C].parentNode,E[C])];return m?Yt(y)?bn(m).childNodes[h.base.indexIn(y.parentNode,y)]||null:n(m)[n(y.parent).indexOf(y)]||null:null},R=new Map,F=new Map,k=new WeakMap,d=0,w=(p,y)=>{let E=R.get(p);E||R.set(p,E=[]),E.push(y)};(function p(y){F.set(y,d++);let E=r.get(y);if(E&&!E.pinned){for(let f of[E.base,E.local,E.remote])if(f)if(Array.isArray(f))for(let m of f)w(m,y);else w(f,y)}if(xo(y)){k.set(y.content,y);for(let f=y.content.firstChild;f;f=f.nextSibling)p(f)}for(let f=y.firstChild;f;f=f.nextSibling)p(f)})(N);let Z=new Map;h.out=Dn(N,k,Z);let he={refs:new Map,spans:new Map,anchors:new Map,via:Z,outOwners:k,outRoot:N,localRoot:e.roots.local},xe=p=>Yt(p)?[p]:p.nodes,ee=(p,y)=>{let E=h[y].logicalParent(p);if(!E)return null;for(let f of n(E))if(!Yt(f)&&f.nodes.includes(p))return f;return null},oe=(p,y)=>p==null?null:Array.isArray(p)?p.length?ee(p[0],y):null:p,re=p=>{let y=new Set,E=[];for(let f of p)for(let m of R.get(f)||[])y.has(m)||(y.add(m),E.push(m));return E.sort((f,m)=>F.get(f)-F.get(m))},ne=new Map,K=p=>{let y=p.b||p.l||p.r,E=ne.get(y);if(E)return E;let f=[];for(let m of[p.b,p.l,p.r])m&&f.push(...xe(m));return E=re(f),ne.set(y,E),E},D=p=>({b:p,l:L(o,p),r:L(t,p)}),Ne=(p,y)=>{let E=M(y).reverse.get(p);if(E)return D(E);for(let f of re(xe(p))){let m=r.get(f);if(m&&!m.base&&m.local&&m.remote)return{b:null,l:oe(m.local,"local"),r:oe(m.remote,"remote")}}return y==="local"?{b:null,l:p,r:null}:{b:null,l:null,r:p}},ae=new Map,te=p=>{let y=r.get(p);if(!y||y.pinned)return null;let E=oe(y.base,"base");if(E)return D(E);let f=oe(y.local,"local"),m=oe(y.remote,"remote");if(f){let C=o.reverse.get(f);if(C)return D(C)}if(m){let C=t.reverse.get(m);if(C)return D(C)}return f||m?{b:null,l:f,r:m}:null},V=p=>(ae.has(p)||ae.set(p,te(p)),ae.get(p)),ye=(p,y)=>Yt(p)?h[y].logicalParent(p):p.parent,be=new Map,Oe=new Map,He=(p,y)=>(Yt(p)?[h[y].pathOf(p)]:p.nodes.map(E=>h[y].pathOf(E))).filter(Boolean),Ue=p=>{let y=p.b||p.l||p.r,E=p.b?"base":p.l?"local":"remote",f=Oe.get(y);if(f)return f;let m=!Yt(y),C=He(y,E)[0],W=`${E[0]}:${JSON.stringify(C===void 0?null:C)}${m?":run":""}`,j=be.get(W);if(j)return Oe.set(y,j),j;let z=K(p);return j={key:W,nodeType:Yt(y)?1:y.kind==="comment"?8:3,base:p.b?He(p.b,"base"):[],local:p.l?He(p.l,"local"):[],remote:p.r?He(p.r,"remote"):[],merged:z.map(x=>h.out.pathOf(x)).filter(Boolean),live:[]},be.set(W,j),Oe.set(y,j),he.refs.set(j,z),j},ze={base:new Map,local:new Map,remote:new Map},se=new Map,at=(p,y)=>{let E=ye(p,y);if(!E||E.nodeType!==1)return null;let f=ze[y].get(E);if(!f){let C=n(E),W=j=>Ue(y==="base"?D(j):Ne(j,y));f={parent:W(E),refs:C.map(W),index:new Map(C.map((j,z)=>[j,z]))},ze[y].set(E,f)}let m=f.index.get(p)??-1;return{parent:f.parent,before:f.refs.slice(m+1),after:f.refs.slice(0,Math.max(0,m)).reverse()}},ft=p=>{let y=p.parentNode;if(!y)return null;let E=se.get(y);if(!E){let m=y.nodeType===11?k.get(y):y,C=m&&m.nodeType===1?V(m):null;if(!C)return null;let W=[],j=[],z=new Map;for(let S of y.childNodes){let G=V(S),ge=G&&Ue(G),Me=W.length,c=W.length-1;ge&&ge!==W[c]&&(W.push(ge),c++);let T={ref:ge,group:c,after:Me};j.push(T),z.set(S,T)}let x=W.length;for(let S=j.length-1;S>=0;S--){let G=j[S];G.before=x,G.ref&&(x=G.group)}E={parent:Ue(C),refs:W,index:z},se.set(y,E)}let f=E.index.get(p);return{parent:E.parent,before:E.refs.slice(f.before),after:E.refs.slice(0,f.after).reverse()}},le=p=>Yt(p)?p.outerHTML:p.value,b=p=>Yt(p)?"element":p.kind==="comment"?"comment":"text",H=(p,y)=>({path:p,offset:y}),fe=(p,y,E)=>{if(!p)return null;let f=h[E],m=0;if(y){let C=Yt(y)?y:y.nodes[y.nodes.length-1];C.parentNode&&(m=f.indexIn(C.parentNode,C)+1)}return H(f.containerPath(p),m)},we=(p,y)=>{let E=ye(p,"base"),f=E?L(M(y),E):null;if(!Yt(f))return null;let m=n(E),C=null;for(let W=m.indexOf(p)-1;W>=0&&!C;W--){let j=L(M(y),m[W]);j&&ye(j,y)===f&&(C=j)}return fe(f,C,y)},pe=(p,y,E,f)=>{let m=h[f],C=0;for(let W=0;W<p.nodes.length;W++){let j=p.nodes[W],z=j.nodeValue.length,x=W===p.nodes.length-1;if((E==="start"?y<C+z:y<=C+z)||x)return H(m.pathOf(j),Math.max(0,Math.min(y-C,z)));C+=z}return null},Ge=(p,y)=>{let E=h[y],f=p.firstChild,m=p.lastChild;return f&&f.nodeType===3&&m.nodeType===3?{start:H(E.pathOf(f),0),end:H(E.pathOf(m),m.nodeValue.length)}:{start:H(E.pathOf(p),0),end:H(E.pathOf(p),p.childNodes.length)}},je=(p,y,E)=>{for(let W of p.nodes)if(E==="start"?W.s<=y&&y<W.e:W.s<y&&y<=W.e)return{kind:"text",node:W.node,offset:y-W.s};let f=E==="start"?y:y-1,m=()=>{for(let W of p.nodes)if(W.s===y||W.e===y)return{kind:"text",node:W.node,offset:y-W.s};return null},C=p.atomAt.get(f);if(C)return{kind:E==="start"?"before":"after",node:C.el};if(p.text[f]===gt){let W=p.marks.find(z=>z.block&&z.to===f+1);if(W)return E==="start"?{kind:"end",node:W.el}:{kind:"after",node:W.el};let j=p.marks.find(z=>z.block&&z.from===f+1);if(j)return E==="start"?{kind:"before",node:j.el}:{kind:"startOf",node:j.el}}return m()},Ze=(p,y)=>je(p,y,"end")||je(p,y,"start"),rt=(p,y)=>{switch(y.kind){case"text":return H(p.pathOf(y.node),y.offset);case"end":return H(p.containerPath(y.node),bn(y.node).childNodes.length);case"startOf":return H(p.containerPath(y.node),0);default:{let E=y.node.parentNode;return H(p.containerPath(E),p.indexIn(E,y.node)+(y.kind==="after"?1:0))}}},wt=(p,y,E,f,m)=>{let C=je(p,y,E);return C?rt(h[f],C):m()},bt=(p,y,E,f)=>{let m=p.textNodes.map(x=>({s:x.ms,e:x.me,start:{kind:"text",node:x.node,offset:0},end:{kind:"text",node:x.node,offset:x.me-x.ms}}));for(let[x,S]of p.atomOut)m.push({s:x,e:x+1,start:{kind:"before",node:S},end:{kind:"after",node:S}});for(let[x,S]of p.breakOut)m.push({s:x,e:x+1,start:{kind:"end",node:S},end:{kind:"after",node:S}});for(let x of m)if(x.start.kind==="text"&&x.s<y&&y<x.e)return{kind:"text",node:x.start.node,offset:y-x.s};if(E!=="empty"){let x=m.find(S=>E==="start"?S.s===y:S.e===y);if(x)return E==="start"?x.start:x.end}let C=m.find(x=>x.e===y);if(C)return C.end;let W=m.find(x=>x.s===y);if(W)return W.start;let j=null,z=null;for(let x of m)x.e<=y&&(!j||x.e>j.e)&&(j=x),x.s>=y&&(!z||x.s<z.s)&&(z=x);return j?j.end:z?z.start:f()},Tt=(p,y)=>{if(!y)return null;if(y.kind==="text"){let m=p.nodes.find(C=>C.node===y.node);return m?m.s+Math.min(y.offset,m.e-m.s):null}let E=p.atoms.find(m=>m.el===y.node);if(E)return y.kind==="after"?E.i+1:E.i;let f=p.marks.find(m=>m.el===y.node);return f?y.kind==="before"&&f.block&&p.text[f.from-1]===gt&&!p.marks.some(m=>m.block&&m.to===f.from)?f.from-1:y.kind==="startOf"||y.kind==="before"?f.from:y.kind==="end"&&f.block?f.to-1:f.to:null},tn=(p,y,E,f)=>{for(let j of p.nodes)if(E==="start"?j.s<=y&&y<j.e:j.s<y&&y<=j.e)return{kind:"text",node:j.node,offset:y-j.s};let m=E==="start"?y:y-1;if(!p.atomAt.has(m)&&p.text[m]!==gt){for(let j of p.nodes)if(j.s===y||j.e===y)return{kind:"text",node:j.node,offset:y-j.s}}let C=p.atomAt.get(m);if(C)return{kind:E==="start"?"before":"after",node:C.el};if(p.text[m]===gt){let j=p.marks.find(x=>x.block&&x.to===m+1);if(j)return E==="start"?{kind:"end",node:j.el}:{kind:"after",node:j.el};let z=p.marks.find(x=>x.block&&x.from===m+1);if(z)return E==="start"?{kind:"before",node:z.el}:{kind:"startOf",node:z.el}}let W=p.marks.find(j=>j.block&&j.from===y);return W?{kind:"startOf",node:W.el}:f?{kind:E==="start"?"startOf":"end",node:f}:null},Fe=p=>{if(!p)return null;if(p.kind==="wholeStart"||p.kind==="wholeEnd"){let y=Xt(p.node);return p.kind==="wholeStart"?y.start:y.end}return rt(h.out,p)},Xt=p=>{let y=p.firstChild,E=p.lastChild;return y&&y.nodeType===3&&E.nodeType===3?{start:H(h.out.pathOf(y),0),end:H(h.out.pathOf(E),E.nodeValue.length)}:{start:H(h.out.pathOf(p),0),end:H(h.out.pathOf(p),p.childNodes.length)}},Jt=p=>{let y=ye(p,"base"),E=y?K(D(y))[0]:null;if(!E)return null;let f=bn(E),m=n(y);for(let C=m.indexOf(p)-1;C>=0;C--){let W=K(D(m[C])).filter(j=>j.parentNode===f);if(W.length)return{kind:"after",node:W[W.length-1]}}return{kind:"startOf",node:E}},Dt=(p,y,E,f,m,C)=>({text:p,start:y,end:E,fragment:f,span:m,scope:C}),It=(p,y,E,f,m)=>Dt(p,y,E,p.slice(y,E),f,m),Et=(p,y,E,f,m)=>(he.spans.set(p,{start:y,end:E,scopeStart:f,scopeEnd:m}),p),sn=new Map,v=new Map,X=(p,y,E)=>{let f=`text:${p.key}:${y}:${E}`,m=v.get(f)||0;return v.set(f,m+1),`${f}:${m}`},Q=(p,y)=>{let E,f,m,C="plain",W,j,z,x,S,G=(c,T,P,U,_)=>{if(!c){let q=we(_,U);return It("",0,0,{start:q,end:q},{start:q,end:q})}return It(c.value,T,P,{start:pe(c,T,T===P?"end":"start",U),end:pe(c,P,"end",U)},{start:pe(c,0,"start",U),end:pe(c,c.value.length,"end",U)})};if(y.site==="run"){let{bRun:c,lRun:T,rRun:P,node:U,c:_}=y;E=D(c),f=_.bs,m=_.be,W=G(c,_.bs,_.be,"base",c),j=G(T,_.ls,_.le,"local",c),z=G(P,_.rs,_.re,"remote",c);let q=U?U.nodeValue:"",Y=ce=>U?{kind:"text",node:U,offset:ce}:Jt(c);x=Et(It(q,_.ms,_.me,{start:Fe(Y(_.ms)),end:Fe(Y(_.me))},{start:Fe(Y(0)),end:Fe(Y(q.length))}),Y(_.ms),Y(_.me),Y(0),Y(q.length)),S=U||(Jt(c)||{}).node||null}else if(y.site==="whole"){let c=y.el,T=r.get(c);E=D(T.base),f=0,m=p.base.length;let P=(_,q,Y)=>{let ce=Ge(q,Y);return It(_,0,_.length,ce,ce)};W=P(p.base,T.base,"base"),j=P(p.local,T.local,"local"),z=P(p.remote,T.remote,"remote");let U=Xt(c);x=Et(It(p.resolved,0,p.resolved.length,U,U),{kind:"wholeStart",node:c},{kind:"wholeEnd",node:c},{kind:"wholeStart",node:c},{kind:"wholeEnd",node:c}),S=c}else if(y.site==="comment"){let{bRun:c,lRun:T,rRun:P,node:U}=y;E=D(c),f=0,m=p.base.length;let _=(Se,Ee)=>{if(!Se){let Be=we(c,Ee);return It("",0,0,{start:Be,end:Be},{start:Be,end:Be})}let Ie=Se.nodes[0],et={start:H(h[Ee].pathOf(Ie),0),end:H(h[Ee].pathOf(Ie),Se.value.length)};return It(Se.value,0,Se.value.length,et,et)};W=_(c,"base"),j=_(T,"local"),z=_(P,"remote");let q=p.resolved,Y=Se=>U?{kind:"text",node:U,offset:Se}:Jt(c),ce={start:Fe(Y(0)),end:Fe(Y(q.length))};x=Et(It(q,0,q.length,ce,ce),Y(0),Y(q.length),Y(0),Y(q.length)),S=U||(Jt(c)||{}).node||null}else{let{fb:c,fl:T,fr:P,scope:U}=y,_=y.merged;C="html",E=U.base?D(U.base):Ne(U.local,"local"),f=p.bs,m=p.be;let q=ut=>{let At=U[ut];for(let Nt=U.at-1;Nt>=0;Nt--){let jt=U.units[Nt],Qt=ut==="base"?jt:L(M(ut),jt);if(Qt&&ye(Qt,ut)===At)return Qt}return null},Y=ut=>()=>fe(U[ut],q(ut),ut),ce=(ut,At,Nt,jt,Qt)=>{let fn=De=>De?rt(h[Qt],De):Y(Qt)(),An=At===Nt?Ze(ut,At):je(ut,At,"start"),vn=At===Nt?Ze(ut,At):je(ut,Nt,"end"),kn=fn(An),rn={start:kn,end:At===Nt?kn:fn(vn)},zt=y.full?y.full(Qt):null;if(!zt)return Dt(ut.text,At,Nt,jt,rn,{start:fn(je(ut,0,"start")),end:fn(je(ut,ut.text.length,"end"))});let J=An?Tt(zt,An):null,Re=vn?Tt(zt,vn):null,ve=J===null?0:J,Ye=Math.max(ve,Re===null?zt.text.length:Re),lt=fn(je(zt,0,"start"));return Dt(zt.text,ve,Ye,zn(zt,ve,Ye),rn,{start:lt,end:zt.text.length?fn(je(zt,zt.text.length,"end")):lt})};W=y.synthetic?null:ce(c,p.bs,p.be,p.base,"base"),j=ce(T,p.lss,p.lse,p.local,"local"),z=ce(P,p.rss,p.rse,p.remote,"remote");let[Se,Ee]=p.range||[0,0],Ie=_.out,et=()=>{let ut=bn(_.node);for(let At=U.at-1;At>=0;At--){let Nt=K(D(U.units[At])).filter(jt=>jt.parentNode===ut);if(Nt.length)return{kind:"after",node:Nt[Nt.length-1]}}for(let At=U.at;At<U.units.length;At++){let Nt=K(D(U.units[At])).filter(jt=>jt.parentNode===ut);if(Nt.length)return{kind:"before",node:Nt[0]}}return{kind:"startOf",node:_.node}};if(Ie.via)for(let[ut,At]of Ie.via)Z.set(ut,At);let Be=bt(_,Se,Se===Ee?"empty":"start",et),St=Se===Ee?Be:bt(_,Ee,"end",et),Ve=Ie.text.length?tn(Ie,0,"start",_.node):et(),pt=Ie.text.length?tn(Ie,Ie.text.length,"end",_.node):Ve,it=Tt(Ie,Be),Ft=Tt(Ie,St),Rt=it===null?0:it,Kt=Math.max(Rt,Ft===null?Ie.text.length:Ft);x=Et(Dt(Ie.text,Rt,Kt,zn(Ie,Rt,Kt),{start:Fe(Be),end:Fe(St)},{start:Fe(Ve),end:Fe(pt)}),Be,St,Ve,pt);let Lt=he.spans.get(x);if(Lt.flat=Ie,!Ie.text.length){let ut=Fe(Ve),At=Hn(N,ut),Nt=At[0],jt=At[1];Lt.empty={parent:Nt.nodeType===11?k.get(Nt):Nt,previous:Nt.childNodes[jt-1]||null,next:Nt.childNodes[jt]||null}}S=Be?Be.node:_.node}let ge=Ue(E),Me=(y.site==="whole"||y.site==="comment"||a!=="both")&&p.resolved!==p.local;return{key:y.site==="comment"&&sn.get(E.b||E.l||E.r)||X(ge,f,m),subject:ge,localLost:Me,anchor:S,text:{encoding:C,base:W,local:j,remote:z,merged:x,liveSpan:null,liveScope:null}}},de=(p,y)=>{let E=V(y.el),f=Ue(E),m=y.sample;return{key:`attr:${f.key}:${m.namespaceURI||""}:${m.localName}`,subject:f,localLost:p.resolved!==p.local,anchor:y.el,attribute:{namespaceURI:m.namespaceURI||null,localName:m.localName,qualifiedName:m.name}}},ie=(p,y)=>{let E=p.detail,f=y.unit||D(y.subject),m=Ue(f),C=he.refs.get(m),W=f.l?at(f.l,"local"):null,j=f.r?at(f.r,"remote"):null,z=C.length?ft(C[0]):null,x,S,G,ge=null,Me=null,c=y.deleted;switch(E){case"both-reordered":{x=S="reordered";let T=new Set(y.rKept),P=y.lKept.filter(ce=>T.has(ce)&&K(D(ce)).length),U=ce=>F.get(K(D(ce))[0]);ge=P.map(ce=>Ue(D(ce))),Me=P.slice().sort((ce,Se)=>U(ce)-U(Se)).map(ce=>Ue(D(ce)));let _=ce=>!Yt(ce)&&ce.kind!=="comment"&&ce.nodes.every(Se=>!/[^\t\n\f\r ]/.test(Se.data)),q=P.filter(ce=>!_(ce)),Y=q.slice().sort((ce,Se)=>U(ce)-U(Se));G=q.some((ce,Se)=>ce!==Y[Se]);break}case"both-moved":x=S="moved",G=!W||!C.some(T=>{let P=T===C[0]?z:ft(T);return P&&P.parent===W.parent});break;case"edit-beats-delete":x=c==="local"?"deleted":"edited",S=c==="remote"?"deleted":"edited",G=c==="local";break;case"move-beats-delete":x=c==="local"?"deleted":"moved",S=c==="remote"?"deleted":"moved",G=c==="local";break;default:x=S="inserted",G=y.localLost}return{key:`structure:${m.key}:${E}`,subject:m,localLost:G,anchor:C[0]||null,structure:{localAction:x,remoteAction:S,localPlacement:W,remotePlacement:j,mergedPlacement:z,localOrder:ge,mergedOrder:Me,localFragment:E==="both-reordered"||!f.l?null:le(f.l),fragmentKind:b(f.b||f.l||f.r)}}};for(let[p,y]of l){if(p.kind!=="structure")continue;let E=y.unit||D(y.subject),f=E.b||E.l||E.r;!Yt(f)&&f.kind==="comment"&&sn.set(f,`structure:${Ue(E).key}:${p.detail}`)}let ue=new Map;for(let[p,y]of l){if(p.kind==="structure"){let C=Ue(y.unit||D(y.subject)),W=`structure:${C.key}:${p.detail}`,j=ue.get(W);if(j&&j.structure){p.recovery=j;let z=he.refs.get(C);p.el==null&&z.length&&(p.el=Yt(z[0])?z[0]:h.out.logicalParent(z[0]));continue}}let E=p.kind==="text"?Q(p,y):p.kind==="attr"?de(p,y):ie(p,y),f=ue.get(E.key);f||(f={version:_r,key:E.key,localLost:E.localLost,subject:E.subject,applied:!1,unavailable:null},ue.set(E.key,f),he.anchors.set(f,E.anchor)),E.text&&(f.text=E.text),E.attribute&&(f.attribute=E.attribute),E.structure&&(f.structure=E.structure),E.text&&(f.localLost=E.localLost),p.recovery=f;let m=he.refs.get(E.subject);p.kind==="structure"&&p.el==null&&m.length&&(p.el=Yt(m[0])?m[0]:h.out.logicalParent(m[0])),p.kind==="text"&&p.node==null&&m.length&&E.subject.nodeType===8&&(p.node=m[0])}return he}}function Os(e,o,t){if(!o)return;let{lookup:n,vetoed:r,vetoedAttrs:a,liveAttr:l}=t,i=t.ignored||(()=>!1),u=Dn(t.liveRoot),A=te=>!!te&&u.containerPath(te)!==null,N=te=>{let V=te.parentNode;return V&&V.nodeType===11?o.outOwners.get(V)||null:V},h=te=>{for(let V=te;V;V=N(V))if(o.via.has(V)&&(V=o.via.get(V)),r.has(V)||t.vetoedLive?.has(d(V)))return!0;return!1},M=te=>Array.from(bn(te).children).filter(V=>!i(V)),L=(te,V)=>M(te)[M(V.parentNode).indexOf(V)],R=(te,V)=>{let ye=null,be=null,Oe=0;for(let se=V.previousSibling;se;se=se.previousSibling){if(se.nodeType===1&&!i(se)){ye=se;break}se.nodeType===3&&(Oe+=se.nodeValue.length)}for(let se=V.nextSibling;se&&!be;se=se.nextSibling)se.nodeType===1&&!i(se)&&(be=se);let He=ye?L(te,ye):null,Ue=be?L(te,be):null;if(ye&&!He||be&&!Ue)return null;let ze=[];for(let se=He?He.nextSibling:bn(te).firstChild;se&&se!==Ue;se=se.nextSibling)se.nodeType===3&&ze.push(se);return ze.length?{nodes:ze,lead:Oe}:null},F=te=>{let V=[],ye=te;for(;ye&&!o.via.has(ye);ye=ye.parentNode)V.push(ye);if(!ye||!V.length)return null;let be=d(o.via.get(ye));for(let Ue=V.length-1;Ue>0&&be;Ue--)be=L(be,V[Ue]);if(!be)return null;let Oe=V[0];if(Oe.nodeType===3)return R(be,Oe);let He=Oe.nodeType===1?L(be,Oe):null;return He?{nodes:[He],lead:0}:null},k=te=>{let V=n(te),ye=V?{nodes:Array.isArray(V)?V:[V],lead:0}:o.via.size?F(te):null;if(!ye)return null;let be=ye.nodes.filter(A);return be.length?{nodes:be,lead:ye.lead}:null},d=te=>{let V=k(te);return V?V.nodes[0]:null},w=te=>{if(!te)return null;if(te.kind==="text"){let Oe=k(te.node);if(!Oe)return null;let He=Oe.nodes,Ue=te.offset+Oe.lead,ze=0;for(let se=0;se<He.length;se++){let at=He[se].nodeValue.length;if(Ue<=ze+at||se===He.length-1)return Ue>=ze&&Ue<=ze+at?[He[se],Ue-ze]:null;ze+=at}return null}let V=d(te.node);if(!V)return null;if(te.kind==="end")return[bn(V),bn(V).childNodes.length];if(te.kind==="startOf")return[bn(V),0];if(te.kind==="wholeStart")return V.firstChild?[V.firstChild,0]:[V,0];if(te.kind==="wholeEnd")return V.lastChild?[V.lastChild,V.lastChild.nodeValue.length]:[V,V.childNodes.length];let ye=V.parentNode;if(!ye)return null;let be=Array.prototype.indexOf.call(ye.childNodes,V);return[ye,te.kind==="after"?be+1:be]},Z=te=>({blocks:new Set((te.flat?.marks||[]).filter(V=>V.block).map(V=>d(V.el)).filter(Boolean)),atoms:new Set((te.flat?.atoms||[]).map(V=>d(V.el)).filter(Boolean)),ignored:i}),he=(te,V,ye,be)=>{if(!te||!V||!jn(te)||!jn(V))return!1;for(let Ue of[te,V])if(!A(Ue.startContainer)||!A(Ue.endContainer))return!1;let Oe=ye.merged;if(Oe.start===Oe.end&&(te.startContainer!==te.endContainer||te.startOffset!==te.endOffset))return!1;let He=Z(be);return Cn(V,ye.encoding,He)===Oe.text&&Cn(te,ye.encoding,He)===Oe.text.slice(Oe.start,Oe.end)},xe=new Map,ee=te=>{let V=te.parentNode;return V?(xe.has(V)||xe.set(V,new Map(Array.from(V.childNodes,(ye,be)=>[ye,be]))),xe.get(V).get(te)):-1},oe=(te,V)=>{if(!V)return!1;let ye=u.logicalParent(te);if(!V.parent.live.includes(ye))return!1;let be=ee(te);for(let[Oe,He]of[["before",1],["after",-1]]){let Ue=be;for(let ze of V[Oe]){if(ze.live.includes(te))continue;let se=ze.live.filter(ft=>ft!==te&&ft.parentNode===te.parentNode);if(!se.length)continue;let at=He===1?Math.min(...se.map(ee)):Math.max(...se.map(ee));if(He*(at-Ue)<=0)return!1;Ue=at}}return!0},re=te=>{let V=te.structure;if(V.mergedOrder){let ye=new Set(te.subject.live.map(bn)),be=null,Oe=-1;for(let He of V.mergedOrder){let Ue=He.live.find(ze=>ye.has(ze.parentNode));if(!Ue||be&&Ue.parentNode!==be||ee(Ue)<=Oe)return!1;be=Ue.parentNode,Oe=ee(Ue)}return te.subject.live.length>0}return te.subject.live.some(ye=>oe(ye,V.mergedPlacement))},ne=(te,V)=>{let ye=w(te),be=w(V);return ye&&be?{startContainer:ye[0],startOffset:ye[1],endContainer:be[0],endOffset:be[1]}:null},K=new Set,D=te=>{if(!te||K.has(te))return;K.add(te);let V=[];for(let ye of o.refs.get(te)||[]){let be=k(ye);if(be)for(let Oe of be.nodes)V.includes(Oe)||V.push(Oe)}te.live=V},Ne=te=>{te&&(D(te.parent),te.before.forEach(D),te.after.forEach(D))},ae=new Set;for(let te of e){let V=te.recovery;if(!V||ae.has(V))continue;ae.add(V),D(V.subject),V.structure&&(Ne(V.structure.localPlacement),Ne(V.structure.remotePlacement),Ne(V.structure.mergedPlacement),(V.structure.localOrder||[]).forEach(D),(V.structure.mergedOrder||[]).forEach(D));let ye=o.anchors.get(V),be=ye?d(ye):null,Oe=!!be;if(V.text){let b=o.spans.get(V.text.merged),H=b?ne(b.start,b.end):null,fe=b?ne(b.scopeStart,b.scopeEnd):null;if(b?.empty){let we=b.empty,pe=we.previous?{kind:"after",node:we.previous}:{kind:"startOf",node:we.parent},Ge=we.next?{kind:"before",node:we.next}:{kind:"end",node:we.parent},je=ne(pe,Ge);!je||je.startContainer!==je.endContainer||je.startOffset!==je.endOffset?H=null:H=fe=je}he(H,fe,V.text,b)||(H=fe=null),V.text.liveSpan=H,V.text.liveScope=H?fe:null,H||(Oe=!1)}V.structure&&Oe&&(Oe=re(V)),V.attribute&&Oe&&(Oe=l(be,V.attribute,te.resolved));let He=(!!V.attribute||!!V.text&&be?.tagName==="TEXTAREA")&&!!a&&[ye,be].some(b=>a.get(b)?.has(V.attribute?V.attribute.qualifiedName:"value")),Ue=o.localState?.states.get(V),ze=!!V.text&&[...t.removedVetoes||[]].some(b=>Ue?.touched.has(b)),se=V.structure?.localAction==="inserted"&&[...r].some(b=>b===ye||ye?.contains(b)),at=ye&&h(ye)||He||ze||se,ft=at&&vs(V,te,o,A);ft&&(ze||se&&V.localLost)&&(Oe=!1);let le=!Oe&&ft&&at;V.applied=Oe,V.unavailable=Oe?null:le?"hook-veto":"missing-output",le&&(V.localLost=!1),!Oe&&V.text&&(V.text.liveSpan=V.text.liveScope=null)}}function To(e,o,t){let n=Dn(o),r=Dn(t),a=h=>!!h&&r.containerPath(h)!==null,l=h=>{if(h===o)return t;let M=n.pathOf(h);if(M&&o!==t){let L=Hn(t,{path:M,offset:0});if(L&&L[0].nodeType===h.nodeType)return L[0]}return h},i=new Set,u=h=>{!h||i.has(h)||(i.add(h),h.live=h.live.map(l).filter(a))},A=h=>{h&&(h.startContainer=l(h.startContainer),h.endContainer=l(h.endContainer))},N=new Set;for(let h of e){h.node===o&&t.tagName==="SCRIPT"&&(h.node=t),h.el===o&&h.kind==="structure"&&(h.el=t);let M=h.recovery;if(!M||N.has(M))continue;if(N.add(M),u(M.subject),M.text){A(M.text.liveSpan),A(M.text.liveScope);let R=M.text.liveSpan,F=M.text.liveScope,k=M.text.merged,d=w=>!!w&&jn(w)&&a(w.startContainer)&&a(w.endContainer);(!d(R)||!d(F)||Cn(F,M.text.encoding)!==k.text||Cn(R,M.text.encoding)!==k.text.slice(k.start,k.end))&&(M.text.liveSpan=null,M.text.liveScope=null,M.applied=!1,M.unavailable="missing-output")}let L=M.structure;if(L){for(let R of[L.localPlacement,L.remotePlacement,L.mergedPlacement])R&&(u(R.parent),R.before.forEach(u),R.after.forEach(u));(L.localOrder||[]).forEach(u),(L.mergedOrder||[]).forEach(u),M.subject.live.length||(M.applied=!1,M.unavailable="missing-output")}}}var Qe=e=>!!e&&e.nodeType===1,qr=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),Ms=5e4,so="[id],[data-id],script,head>*";function $o(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=Gn(t,e);if(n)return"merge:"+n.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?ms(t,o):null}}function No(e,o,t,n){let r=n.ignored,a=n.stats||Mn(),l=ns({ignored:r,ignoreAttribute:n.ignoreAttribute,stats:a}),{unitsOf:i,meta:u}=l,A=n.baseURI,N=n.mergeTags!==null,h=$o(n.mergeTags,A),M=c=>T=>{let P=h(T);return P!==null?P:c(T)},L=M(n.identity.base),R=M(n.identity.local),F=M(n.identity.remote),k=n.authored||n.identity,d=c=>c&&c.nodeType===9?c.documentElement:c,w=d(e),Z=d(o),he=d(t),xe=globalThis.__hyperMorphProfile,ee=xe?performance.now():0,oe=c=>c===an?so:null,re=n.scope||null,ne=re?re.baseIndex:po(w,L,r,oe(n.identity.base)),K=n.localIsBase||w===Z?Ls():Eo(w,Z,{analyzer:l,baseIndex:ne,sideIndex:po(Z,R,r,oe(n.identity.local)),baseId:k.base,sideId:k.local,stats:a}),D=Eo(w,he,{analyzer:l,baseIndex:ne,sideIndex:re?re.remoteIndex:po(he,F,r,oe(n.identity.remote)),baseId:k.base,sideId:k.remote,stats:a,scope:re,comparisons:n.comparisons});if(re){if(!re.held(D))return null;for(let c of re.dropped)Lo(c)}let Ne=null;function ae(c){if(!Ne){Ne=new WeakMap;let T=[w];for(;T.length;){let P=T.pop();P.tagName==="TEMPLATE"&&P.content&&Ne.set(P.content,P);for(let U of l.childrenOf(P))U.nodeType===1&&T.push(U)}}return Ne.get(c)||null}let te=c=>{let T=Qe(c)||c.nodeType?c.parentNode:c.parent;return T&&T.nodeType===11?ae(T):T};Tt(),tn(K,D),tn(D,K);for(let c of[K,D])if(c.refused)for(let T of c.refused)c.moved.has(T)||a.ambiguousMoves++;xe&&(xe.alignTotal=(xe.alignTotal||0)+(performance.now()-ee),ee=performance.now());let V=w.ownerDocument.implementation.createHTMLDocument(""),ye=new WeakMap,be=new WeakMap,Oe=[],He=[],Ue=new Set,ze=[],se=new Set,at=new Set,ft=new Set,le=new WeakMap,b=n.conflicts||"remote",H=c=>Oe.push(c),fe=c=>Oe.push(c),we=Ss({roots:{base:w,local:Z,remote:he},L:K,R:D,unitsOf:i,provenance:ye,policy:b}),pe=(c,T)=>{He.push(c),T&&we.note(c,T)},Ge=wt(),je=It(w,K.map.get(w),D.map.get(w),!!n.localIsBase,!!n.childrenOnly);je.tagName==="HTML"?V.replaceChild(je,V.documentElement):V.body.appendChild(je),xe&&(xe.build=(xe.build||0)+(performance.now()-ee));let Ze=n.childrenOnly?!j(C(je),C(he)):!E(je,he),rt=we.finish(je);return{doc:V,root:je,provenance:ye,textMappers:be,decisions:Oe,conflicts:He,recoveryLinks:rt,localDiverged:Ze,mergedScripts:Ue,segments:ze,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==an,L:K,R:D,stats:a};function wt(){let c=new Map,T=new Set;if(n.localIsBase||!K.insertedByHash)return{partner:c,drop:T};let P=K.insertedByHash(),U=D.insertedByHash();if(!P.size||!U.size)return{partner:c,drop:T};let _={ignored:r,remoteWins:n.remoteWins,inlineCache:le},q=Ve=>{let pt=0;for(let it=Ve.parentNode;it;it=it.parentNode)pt++;return pt},Y=[],ce=Ve=>{let pt=Ve.textContent.trim();return pt.split(/\s+/).length>=3||pt.replace(/\s/g,"").length>=12},Se=Ve=>{let pt=Fe(K,Ve),it=Fe(D,Ve);return pt&&K.reverse.get(pt.parentNode)!==Ve.parentNode||it&&D.reverse.get(it.parentNode)!==Ve.parentNode},Ee=(Ve,pt,it)=>{for(let Rt of it.parentNode.children){let Kt=Rt!==it&&Ve.reverse.get(Rt);if(Kt&&Se(Kt))return!0}let Ft=Ve.reverse.get(it.parentNode);if(Ft){for(let Rt of Ft.children)if(!Fe(pt,Rt)&&!r(Rt))return!0}return!1};for(let[Ve,pt]of P){let it=U.get(Ve);if(!it)continue;let Ft=pt.length===1&&it.length===1;for(let Rt of pt)Bn(Rt,_)||Y.push([Rt,it,q(Rt),Ft&&(ce(Rt)||Ee(K,D,Rt)||Ee(D,K,it[0]))])}if(!Y.length)return{partner:c,drop:T};Y.sort((Ve,pt)=>Ve[2]-pt[2]);let Ie=new Set,et=new Set,Be=Ve=>{for(let pt of Ve.querySelectorAll("*"))Ie.add(pt)},St=(Ve,pt)=>Ve.reverse.get(pt.parentNode)||null;for(let[Ve,pt,,it]of Y){if(Ie.has(Ve))continue;let Ft=St(K,Ve),Rt=Lt=>!et.has(Lt)&&!Ie.has(Lt)&&Lt.tagName===Ve.tagName&&l.equalUnits(Ve,Lt),Kt=pt.find(Lt=>Ft&&St(D,Lt)===Ft&&Rt(Lt))||(it?pt.find(Rt):null);Kt&&(et.add(Kt),Be(Ve),Be(Kt),!(Ft&&St(D,Kt)===Ft)&&(c.set(Ve,Kt),c.set(Kt,Ve),T.add(b==="local"?Kt:Ve)))}return{partner:c,drop:T}}function bt(c,T,P){if(se.add(c),Ge.drop.has(c))return null;se.add(P);let U=T==="local"?c:P,_=T==="local"?P:c,q;return l.equalUnits(U,_)?(q=p(U,"local",!0),ye.get(q).remote=_):q=ue(U,_),pe({kind:"structure",el:q,detail:"both-moved",base:null,local:U,remote:_},{unit:{b:null,l:U,r:_}}),H({kind:"insert",el:q,source:"both"}),q}function Tt(){if(!K.weak||!D.weak||!K.weak.size||!D.weak.size||!K.unpair)return;let c=new Map;for(let P of K.weak){let U=Fe(K,P);Qe(P)&&Qe(U)&&c.set(l.unitHash(U),P)}let T=!1;for(let P of Array.from(D.weak)){let U=Fe(D,P);if(!Qe(P)||!Qe(U))continue;let _=c.get(l.unitHash(U));if(!_||_===P||!K.weak.has(_)||Fe(K,P)&&Fe(D,_))continue;let q=Fe(K,_);q.tagName===U.tagName&&l.equalUnits(q,U)&&(K.unpair(_),D.unpair(P),T=!0)}T&&(K.rematch(),D.rematch())}function tn(c,T){if(!c.weak||!c.weak.size||!T.insertedByHash)return;let P=T.insertedByHash();if(!P.size)return;let U=!1;for(let _ of Array.from(c.weak)){let q=Fe(c,_);if(!q)continue;let Y=P.get(l.unitHash(q));Y&&Y.some(ce=>ce.tagName===q.tagName&&l.equalUnits(ce,q))&&(c.unpair(_),U=!0)}U&&c.rematch()}function Fe(c,T){if(!T)return null;if(c.map.has(T))return c.map.get(T);let P=[],U=te(T);for(;U&&!c.map.has(U);U=te(U))P.push(U);let _=U;if(!_||!c.identical.has(_))return null;c.pairIdenticalChildren(_);for(let Y=P.length-1;Y>=0;Y--)c.pairIdenticalChildren(P[Y]);let q=c.map.get(T)||null;return q&&a.lazyTwins++,q}function Xt(c,T,P){if(at.has(c)||ft.has(c))return pe({kind:"structure",el:null,detail:"both-moved",base:c},{subject:c}),at.has(c)?null:p(P,T);let U=Fe(K,c),_=Fe(D,c);(!U||!_)&&pe({kind:"structure",el:null,detail:"move-beats-delete",base:c},{subject:c,deleted:U?"remote":"local"});let q=It(c,U,_,!1);return(T==="local"?H:fe)({kind:"move",el:q,source:T}),q}function Jt(c,T,P,U){return U||!T||T===P?{el:P,asBase:!0,twin:_=>_,baseOf:_=>_,units:i(P),here:()=>!0,parentOfTwin:()=>P}:{el:T,asBase:!1,twin:_=>Fe(c,_),baseOf:_=>c.reverse.get(_),units:i(T),here:_=>Qe(_)?_.parentNode===T||T.tagName==="TEMPLATE"&&_.parentNode===T.content:_.parent===T||T.tagName==="TEMPLATE"&&_.parent===T.content}}function Dt(c,T,P){return!T||P&&P.identical.has(c)?!1:Qe(c)?!l.equalUnits(c,T):c.value!==T.value}function It(c,T,P,U,_=!1){let q=U||n.remoteWins(c),Y=c.namespaceURI&&c.namespaceURI!=="http://www.w3.org/1999/xhtml"?V.createElementNS(c.namespaceURI,c.tagName):V.createElement(c.tagName),ce={base:c,local:T||null,remote:P||null};if(ye.set(Y,ce),se.add(c),at.add(c),T&&se.add(T),P&&se.add(P),n.skipUnchanged&&!_&&(n.localIsBase||K.identical.has(c))&&P&&D.identical.has(c)&&!n.remoteWins(c)){ce.unchanged=!0;for(let Ee of c.attributes)Ee.namespaceURI?Y.setAttributeNS(Ee.namespaceURI,Ee.name,Ee.value):Y.setAttribute(Ee.name,Ee.value);return Y}ft.add(c),_||v(c,q?c:T,P,Y);let Se=c.tagName;if(en(c))sn(c,q?c:T,P,Y);else if(Se==="TEXTAREA")Y.textContent=Et(c.textContent,(q?c:T)?(q?c:T).textContent:c.textContent,P?P.textContent:c.textContent,Y,"text");else{let Ee=y(c,T,P,q,Y),Ie=Se==="TEMPLATE"&&Y.content?Y.content:Y;for(let et of Ee)Ie.appendChild(et)}return ft.delete(c),Y}function Et(c,T,P,U,_){if(T===P)return T;if(T===c)return P!==c&&fe({kind:_,node:U,source:"remote"}),P;if(P===c)return H({kind:_,node:U,source:"local"}),T;let q=b==="local"?T:P;return pe({kind:_,node:U,base:c,local:T,remote:P,resolved:q},{site:"whole",el:U}),Oe.push({kind:_,node:U,source:"both"}),q}function sn(c,T,P,U){let _=c.textContent,q=T?T.textContent:_,Y=P?P.textContent:_,ce=N?Gn(c,n.mergeTags,!0):null;if(ce&&q!==Y){let Se=P&&P.getAttribute("merge-key")||c.getAttribute("merge-key"),{text:Ee,warnings:Ie}=wo(n.localIsBase?void 0:_,q,Y,{parse:ce.recognizer.parse,keyCandidates:Se?Se.split(/[\s,]+/).filter(Boolean):void 0});for(let et of Ie)console.warn(`[hyper-morph] merge "${ce.raw}": ${et}`);U.textContent=Ee,Ue.add(U),Ee!==Y?H({kind:"text",node:U,source:Ee===q?"local":"both"}):Ee!==_&&fe({kind:"text",node:U,source:"remote"});return}U.textContent=Et(_,q,Y,U,"text")}function v(c,T,P,U){let _=new Map;for(let q of[c,T,P])if(q)for(let Y of q.attributes)n.ignoreAttribute(q,Y.name)||_.set(Y.name,Y);for(let[q,Y]of _){let ce=c?c.getAttribute(q):null,Se=T?T.getAttribute(q):ce,Ee=P?P.getAttribute(q):ce,Ie;Se===Ee?Ie=Se:Se===ce?(Ie=Ee,fe({kind:"attr",el:U,name:q,source:"remote"})):Ee===ce?(Ie=Se,H({kind:"attr",el:U,name:q,source:"local"})):(Ie=X(q,ce,Se,Ee),Ie===void 0&&(Ie=b==="local"?Se:Ee,pe({kind:"attr",el:U,name:q,base:ce,local:Se,remote:Ee,resolved:Ie},{el:U,sample:Y})),Oe.push({kind:"attr",el:U,name:q,source:"both"})),Ie!=null&&(Y.namespaceURI?U.setAttributeNS(Y.namespaceURI,Y.name,Ie):U.setAttribute(q,Ie))}}function X(c,T,P,U){if(c==="class"){let _=Ee=>new Set((Ee||"").split(/\s+/).filter(Boolean)),q=_(T),Y=_(P),ce=_(U),Se=new Set;for(let Ee of new Set([...q,...Y,...ce])){let Ie=q.has(Ee),et=Y.has(Ee),Be=ce.has(Ee);(et===Be?et:et===Ie?Be:et)&&Se.add(Ee)}return[...Se].join(" ")}if(c==="style"){let _=Ie=>{let et=new Map;if(!Ie)return et;let Be=0,St=null,Ve="",pt=()=>{let it=Ve.indexOf(":");it>0&&et.set(Ve.slice(0,it).trim(),Ve.slice(it+1).trim()),Ve=""};for(let it of Ie){if(St){Ve+=it,it===St&&(St=null);continue}if(it==='"'||it==="'"){St=it,Ve+=it;continue}if(it==="("?Be++:it===")"&&Be--,it===";"&&Be===0){pt();continue}Ve+=it}return Ve.trim()&&pt(),et},q=_(T),Y=_(P),ce=_(U),Se=new Map,Ee=!1;for(let Ie of new Set([...q.keys(),...Y.keys(),...ce.keys()])){let et=q.get(Ie)??null,Be=Y.get(Ie)??null,St=ce.get(Ie)??null,Ve;Be===St?Ve=Be:Be===et?Ve=St:St===et?Ve=Be:(Ve=b==="local"?Be:St,Ee=!0),Ve!=null&&Se.set(Ie,Ve)}return Ee?void 0:[...Se].map(([Ie,et])=>`${Ie}: ${et}`).join("; ")}}function Q(c,T,P,U){let _=c.value,q=U?_:T?T.value:"",Y=P?P.value:"";se.add(c),T&&se.add(T),P&&se.add(P);let ce=Kn(_,q,Y,b),Se=ce.text===""?null:V.createTextNode(ce.text);Se&&(ye.set(Se,{base:c.nodes,local:T?T.nodes:null,remote:P?P.nodes:null}),be.set(Se,ce.mapLocalOffset)),q!==_&&Y!==_?Oe.push({kind:"text",node:Se,source:"both"}):q!==_?H({kind:"text",node:Se,source:"local"}):Y!==_&&fe({kind:"text",node:Se,source:"remote"});for(let Ee of ce.conflicts)pe({kind:"text",node:Se,base:_.slice(Ee.bs,Ee.be),local:Ee.local,remote:Ee.remote,resolved:Ee.resolved},{site:"run",bRun:c,lRun:T,rRun:P,node:Se,c:Ee});return Se}function de(c,T){return Wn(c,T).every(P=>P.bs===P.be)}function ie(c,T){let P=c?c.value:"",U=T?T.value:"",_;if(P===U||!U?_=P:P?de(P,U)?_=U:de(U,P)?_=P:(_=b==="local"?P:b==="both"?P+U:U,pe({kind:"structure",el:null,detail:"insert-collision",local:P,remote:U,resolved:_},{unit:{b:null,l:c,r:T},localLost:b==="remote"})):_=U,c&&se.add(c),T&&se.add(T),_==="")return null;let q=V.createTextNode(_);return ye.set(q,{base:null,local:c?c.nodes:null,remote:T?T.nodes:null}),P?H({kind:"insert",el:q,source:U&&P===U?"both":"local"}):fe({kind:"insert",el:q,source:"remote"}),q}function ue(c,T){let P={ignored:r,remoteWins:n.remoteWins,inlineCache:le},U=ce=>i(ce).every(Se=>Qe(Se)?Bn(Se,P):Se.kind==="text"),_=null;if(U(c)&&U(T)){let ce=c.textContent,Se=T.textContent;ce===Se||de(Se,ce)?_=T:de(ce,Se)&&(_=c)}if(!_){let ce=b==="local",Se=p(ce?c:T,ce?"local":"remote",!0),Ee=ye.get(Se);return ce?Ee.remote=T:Ee.local=c,pe({kind:"structure",el:Se,detail:"insert-collision",local:c,remote:T,resolved:ce?c:T},{unit:{b:null,l:c,r:T},localLost:!ce}),Se}let q=c.namespaceURI&&c.namespaceURI!=="http://www.w3.org/1999/xhtml"?V.createElementNS(c.namespaceURI,c.tagName):V.createElement(c.tagName);v(null,c,T,q),ye.set(q,{base:null,local:c,remote:T}),se.add(c),se.add(T);let Y=Wo({base:Array.from(_.childNodes),local:Array.from(c.childNodes),remote:Array.from(T.childNodes),out:V,policy:b,idOf:{local:R,remote:F},ignored:r,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:ye,textMappers:be,conflicts:He,conflict:pe,scope:{base:null,local:c,remote:T,units:[],at:0},synthetic:!0,decisions:Oe,node:q});ze.push(...Y.segments);for(let ce of Y.nodes)q.appendChild(ce);return q}function p(c,T,P=!1){if(!P&&Qe(c)){let Y=Ge.partner.get(c);if(Y)return bt(c,T,Y)}if(!Qe(c)){if(c.value==="")return null;let Y=c.kind==="comment"?V.createComment(c.value):V.createTextNode(c.value);return ye.set(Y,{base:null,local:T==="local"?c.nodes:null,remote:T==="remote"?c.nodes:null}),se.add(c),Y}let U=c.namespaceURI&&c.namespaceURI!=="http://www.w3.org/1999/xhtml"?V.createElementNS(c.namespaceURI,c.tagName):V.createElement(c.tagName);for(let Y of c.attributes)Y.namespaceURI?U.setAttributeNS(Y.namespaceURI,Y.name,Y.value):U.setAttribute(Y.name,Y.value);ye.set(U,{base:null,local:T==="local"?c:null,remote:T==="remote"?c:null}),se.add(c);let _=c.tagName==="TEMPLATE"&&U.content?U.content:U,q=T==="local"?K:D;for(let Y of i(c)){let ce=Qe(Y)?q.reverse.get(Y):null;if(ce&&at.has(ce)){pe({kind:"structure",el:null,detail:"both-moved",base:ce},{subject:ce});continue}if(ce&&!ft.has(ce)){let Ee=Fe(K,ce)||null,Ie=Fe(D,ce)||null;if(Ee||Ie){let et=It(ce,Ee,Ie,!1);T==="local"?H({kind:"move",el:et,source:"local"}):fe({kind:"move",el:et,source:"remote"}),_.appendChild(et);continue}}let Se=p(Y,T);Se&&_.appendChild(Se)}return U}function y(c,T,P,U,_){T&&K.identical.has(c)&&K.pairIdenticalChildren(c),P&&D.identical.has(c)&&D.pairIdenticalChildren(c);let q=Jt(K,T,c,U),Y=Jt(D,P,c,!1),ce=i(c),Se=new Set(ce),Ee=new Map;for(let J=0;J<ce.length;J++)Ee.set(ce[J],J);let Ie=[],et=new Set,Be=new Map,St=new Set,Ve=new Set,pt=[];zt();let it=J=>{let Re=[];for(let ve of J.units){if(Ve.has(ve))continue;let Ye=J.baseOf(ve);Ye&&Se.has(Ye)&&Re.push(Ye)}return Re},Ft=J=>it(J).map(Re=>Ee.get(Re)),Rt=J=>J.every((Re,ve)=>ve===0||Re>=J[ve-1]),Kt=!q.asBase&&!Rt(Ft(q)),Lt=!Y.asBase&&!Rt(Ft(Y));Kt&&Lt&&pe({kind:"structure",el:_,detail:"both-reordered",base:c},{subject:c,lKept:it(q),rKept:it(Y)});let ut=Lt||!Kt?{V:Y,A:D,side:"remote",other:q,otherA:K,otherSide:"local"}:{V:q,A:K,side:"local",other:Y,otherA:D,otherSide:"remote"};Kt?H({kind:"move",el:null,source:Lt?"both":"local",base:c}):Lt&&fe({kind:"move",el:null,source:"remote",base:c});let At=q.asBase?[]:q.units.filter(J=>!q.baseOf(J)&&!Ve.has(J)&&!Ge.partner.has(J)),Nt=Y.asBase?[]:Y.units.filter(J=>!Y.baseOf(J)&&!Ve.has(J)&&!Ge.partner.has(J)),jt=new Map;if(At.length&&Nt.length){let J=new Map,Re=new Map;for(let De of Nt){if(Qe(De)){let tt=F(De);tt&&J.set(tt,De)}let Ke=l.unitHash(De);Re.has(Ke)||Re.set(Ke,[]),Re.get(Ke).push(De)}let ve=(De,Ke)=>{let tt=De.units.indexOf(Ke);for(let _e=tt-1;_e>=0;_e--){let ot=De.baseOf(De.units[_e]);if(ot)return ot}return"start"},Ye=new Map,lt=new Map;for(let De of Nt){let Ke=ve(Y,De);Qe(De)?(lt.has(Ke)||lt.set(Ke,[]),lt.get(Ke).push(De)):De.kind==="text"&&!Ye.has(Ke)&&Ye.set(Ke,De)}for(let De of At){let Ke=null;if(Qe(De)){let tt=R(De);tt&&J.has(tt)&&!jt.has(J.get(tt))&&(Ke=J.get(tt))}else if(De.kind==="text"){let tt=Ye.get(ve(q,De));tt&&!jt.has(tt)&&(Ke=tt)}if(!Ke){let tt=Re.get(l.unitHash(De));tt&&(Ke=tt.find(_e=>!jt.has(_e)&&Qe(_e)===Qe(De)&&(Qe(_e)?_e.tagName===De.tagName:_e.kind===De.kind)&&l.equalUnits(De,_e))||null)}if(!Ke&&Qe(De)){let tt=k.local(De),_e=(lt.get(ve(q,De))||[]).filter(ot=>{let Zt=k.remote(ot);return!jt.has(ot)&&ot.tagName===De.tagName&&!(tt&&Zt&&tt!==Zt)&&l.similar(De,ot)});_e.length===1&&(Ke=_e[0])}Ke&&(jt.set(Ke,De),jt.set(De,Ke))}}let Qt=J=>{if(se.has(J))return Be.get(J)||null;let Re=q.twin(J),ve=Y.twin(J),Ye=Re&&!q.asBase&&!q.here(Re),lt=ve&&!Y.asBase&&!Y.here(ve);if(Ye||lt){if((!Re||!ve)&&pe({kind:"structure",el:null,detail:"move-beats-delete",base:J},{subject:J,deleted:Re?"remote":"local"}),!G(J))return se.add(J),null;pe({kind:"structure",el:null,detail:"both-moved",base:J},{subject:J})}if(!Re&&!ve)return se.add(J),fe({kind:"remove",source:"both",base:J}),null;if(!Re&&!Dt(J,ve,D))return se.add(J),H({kind:"remove",source:"local",base:J}),null;if(!ve&&!Dt(J,Re,K))return se.add(J),fe({kind:"remove",source:"remote",base:J}),null;let De=!Re||!ve,Ke=q.asBase?Fe(K,J)||null:Re,tt=Y.asBase&&Qe(J)&&(D.identityPaired.has(J)||!k.base(J))&&Fe(D,J)||ve,_e;return Qe(J)?_e=It(J,Ke,tt,q.asBase):J.kind==="comment"?_e=x(J,Ke,ve,q.asBase):_e=Q(J,Ke,ve,q.asBase),se.add(J),_e&&(Be.set(J,_e),Re&&Be.set(Re,_e),ve&&Be.set(ve,_e),De&&(pe({kind:"structure",el:_e,detail:"edit-beats-delete",base:J},{subject:J,deleted:Re?"remote":"local"}),Re?H({kind:"insert",el:_e,source:"local"}):fe({kind:"insert",el:_e,source:"remote"}))),_e},fn=(J,Re,ve,Ye)=>{if(se.has(J))return Be.get(J)||null;let lt=Re.baseOf(J);if(lt&&Se.has(lt))return Ve.has(lt)&&!Ve.has(J)?An(lt,J,Ye):Qt(lt);if(lt)return vn(lt,J,Ye);let De=jt.get(J);if(De){let tt=Ye==="local"?J:De,_e=Ye==="local"?De:J,ot;return Qe(tt)?l.equalUnits(tt,_e)?(ot=p(tt,"local"),ye.get(ot).remote=_e):ot=ue(tt,_e):ot=ie(tt,_e),se.add(tt),se.add(_e),ot&&(Be.set(tt,ot),Be.set(_e,ot),Qe(tt)&&H({kind:"insert",el:ot,source:"both"})),ot}let Ke=p(J,Ye);return Ke&&(Be.set(J,Ke),Ye==="local"?H({kind:"insert",el:Ke,source:"local"}):fe({kind:"insert",el:Ke,source:"remote"})),Ke},An=(J,Re,ve)=>{let Ye;return Qe(J)?(Ye=Xt(J,ve,Re),Ye&&se.add(Re)):(Ye=p(Re,ve),se.add(Re),Ye&&(ve==="local"?H:fe)({kind:"insert",el:Ye,source:ve})),Ye&&Be.set(Re,Ye),Ye},vn=(J,Re,ve)=>{let lt=Fe(ve==="local"?D:K,J),De=Re,Ke=lt?ge(lt,ve==="local"?P:T,ve==="local"?D:K):!1,tt=lt&&!Ke&&!Me(J,lt);if(tt&&ve===ut.otherSide)return pe({kind:"structure",el:null,detail:"both-moved",base:J},{subject:J}),null;if(tt&&pe({kind:"structure",el:null,detail:"both-moved",base:J},{subject:J}),lt||pe({kind:"structure",el:null,detail:"move-beats-delete",base:J},{subject:J,deleted:ve==="local"?"remote":"local"}),ft.has(J)){pe({kind:"structure",el:null,detail:"both-moved",base:J},{subject:J});let ot=p(De,ve);return ot&&Be.set(Re,ot),ot}let _e=Qe(J)?It(J,ve==="local"?De:Fe(K,J)||null,ve==="remote"?De:Fe(D,J)||null,!1):null;return _e&&(Be.set(J,_e),Be.set(Re,_e),lt&&Be.set(lt,_e),ve==="local"?H({kind:"move",el:_e,source:"local"}):fe({kind:"move",el:_e,source:"remote"})),_e};for(let J of ut.V.units){if(Ve.has(J)){let ve=Be.get(J);et.has(ve)||(Ie.push(ve),et.add(ve));continue}if(se.has(J)&&!(Be.get(J)&&et.has(Be.get(J)))){let ve=ut.V.baseOf(J);ve&&!Se.has(ve)&&pe({kind:"structure",el:null,detail:"both-moved",base:ve},{subject:ve});continue}let Re=fn(J,ut.V,ut.A,ut.side);Re&&!et.has(Re)&&(Ie.push(Re),et.add(Re),!ut.V.baseOf(J)&&!jt.has(J)&&!Ve.has(J)&&St.add(Re))}for(let J of pt)et.has(J.frag)||(Ie.splice(kn(J.at),0,J.frag),et.add(J.frag));if(!ut.other.asBase){let J=ut.other,Re=ut.otherSide,ve=ut.otherA,Ye=null,lt=0,De=null;for(let Ke of J.units){let tt=Be.get(Ke);if(tt&&et.has(tt)){Ye=tt,De=null;continue}if(se.has(Ke)){let Zt=J.baseOf(Ke);Zt&&!Se.has(Zt)&&pe({kind:"structure",el:null,detail:"both-moved",base:Zt},{subject:Zt});continue}let _e=fn(Ke,J,ve,Re);if(!_e)continue;let ot;if(De)ot=Ie.indexOf(De)+1;else if(Ye){if(ot=Ie.indexOf(Ye)+1,Re==="remote")for(;ot<Ie.length&&St.has(Ie[ot]);)ot++}else ot=lt++;Ie.splice(ot,0,_e),et.add(_e),De=_e}}for(let J=0;J<ce.length;J++){let Re=ce[J];if(se.has(Re))continue;let ve=Qt(Re);ve&&Ie.splice(kn(J),0,ve)}return Ie;function kn(J){for(let Re=J-1;Re>=0;Re--){let ve=Be.get(ce[Re]);if(ve){let Ye=Ie.indexOf(ve);if(Ye>=0)return Ye+1}}return 0}function rn(J){let Re={ignored:r,remoteWins:()=>!1},ve=ke=>J(ke)||Qe(ke)&&n.remoteWins(ke)&&wn.has(ke.tagName)&&Bn(ke,Re),Ye=new Map,lt=ke=>{if(!Qe(ke)||!qr.has(ke.tagName))return!1;let Ce=Ye.get(ke);return Ce===void 0&&(Ce=!r(ke)&&!n.remoteWins(ke)&&i(ke).every(ve),Ye.set(ke,Ce)),Ce},De=ke=>!Qe(ke)&&ke.kind==="text",Ke=null,tt=new Map,_e=ke=>{let Ce=tt.get(ke);if(Ce)return Ce;let We=Qe(ke)?ke.textContent:ke.value;Ce=new Set;let nt=We.toLowerCase();if(!(We.length>Ms))if(/^[\x00-\x7f]*$/.test(nt))for(let $e of nt.split(/[^\p{L}\p{N}]+/u))$e&&Ce.add($e);else for(let $e of Do(nt))/^[\s\p{P}]+$/u.test($e)||Ce.add($e);return tt.set(ke,Ce),Ce},ot=ke=>(Qe(ke)?ke.textContent:ke.value).toLowerCase().replace(/\s+/g," ").trim(),Zt=new Map,En=ke=>{let Ce=Zt.get(ke);if(Ce)return Ce;Ce=new Set(_e(ke));let We=$e=>{if($e)for(let yt of _e($e))Ce.add(yt)},nt=Se.has(ke)?ke:!q.asBase&&q.baseOf(ke)||!Y.asBase&&Y.baseOf(ke);return nt&&(We(nt),We(Fe(K,nt)),We(Fe(D,nt))),Zt.set(ke,Ce),Ce},un=(ke,Ce)=>{let We=ot(Ce),nt=Se.has(ke)?ke:!q.asBase&&q.baseOf(ke)||!Y.asBase&&Y.baseOf(ke),$e=Ut=>We?Ut.split(We).length-1:0;if(nt&&Qe(Ce)&&!Se.has(Ce)){let Ut=$e(ot(nt));for(let Vt of[Fe(K,nt),Fe(D,nt)]){if(!Vt||Vt===Ce||Vt.ownerDocument!==Ce.ownerDocument)continue;let cn=ot(Vt);if(cn.length>We.length&&$e(cn)>=Ut&&(cn.startsWith(We)||cn.endsWith(We)))return!1}}let yt=_e(Ce),kt=En(ke),Pt=0;for(let Ut of yt)kt.has(Ut)&&Pt++;if(yt.size&&Pt*2>=yt.size)return!0;if(!We||We.length>Ms)return!1;let Wt=nt?[ke,nt,Fe(K,nt),Fe(D,nt)]:[ke],nn=(Ut,Vt)=>Ut!==Vt&&(Ut.startsWith(Vt)||Ut.endsWith(Vt));if(Wt.some(Ut=>Ut&&nn(ot(Ut),We)))return!0;if(!Se.has(Ce)||!nt)return!1;let Ot=ot(ke),Sn=ot(nt);return[Fe(K,Ce),Fe(D,Ce)].some(Ut=>{let Vt=Ut&&ot(Ut);return!!Vt&&Ot!==Vt&&(Ot.startsWith(Vt)&&!Sn.startsWith(Vt)||Ot.endsWith(Vt)&&!Sn.endsWith(Vt))})},ln=ke=>{Ke||(Ke=new Set),Ke.add(ke)},Rn=ke=>{ln(ke);for(let[Ce,We]of[[K,q],[D,Y]]){if(We.asBase)continue;let nt=Fe(Ce,ke);nt&&We.here(nt)&&ln(nt)}},Xe=(ke,Ce)=>ke.asBase||ce.every(We=>!Qe(We)||Ce.identical.has(We)&&ke.here(Fe(Ce,We)))&&ke.units.every(We=>!Qe(We)||ke.baseOf(We));if(Xe(q,K)&&Xe(Y,D))return null;let dt=ke=>{if(ke.asBase)return!1;let Ce=-1;for(let We of ke.units){let nt=Qe(We)?ke.baseOf(We):null;if(!nt||!Se.has(nt))continue;let $e=Ee.get(nt);if($e<Ce)return!0;Ce=$e}return!1};if(dt(q)||dt(Y))return null;for(let[ke,Ce]of[[q,K],[Y,D]]){if(ke.asBase||Xe(ke,Ce))continue;let We=ke.units,nt=Ce===K?k.local:k.remote,$e=(Pe,ht)=>{let Mt=Qe(Pe)&&k.base(Pe),xt=Qe(ht)&&nt(ht);return!Mt||!xt||Mt===xt},yt=new Map;for(let Pe=0;Pe<We.length;Pe++)yt.set(We[Pe],Pe);let kt=Pe=>!!Pe&&(Qe(Pe)?ke.here(Pe):yt.has(Pe)),Pt=Pe=>{let ht=ke.twin(Pe);return kt(ht)?ht:null},Wt=ce.filter(Pe=>!ke.twin(Pe)&&lt(Pe)),nn=We.filter(Pe=>!ke.baseOf(Pe)&&lt(Pe)),Ot=(Pe,ht)=>ht===ce?!!Pt(Pe):Se.has(ke.baseOf(Pe)),Sn=Pe=>{let ht=new Int32Array(Pe.length),Mt=new Int32Array(Pe.length),xt=-1;for(let mt=0;mt<Pe.length;mt++)ht[mt]=xt,Ot(Pe[mt],Pe)&&(xt=mt);xt=Pe.length;for(let mt=Pe.length-1;mt>=0;mt--)Mt[mt]=xt,Ot(Pe[mt],Pe)&&(xt=mt);return{prev:ht,next:Mt}},Ut=Sn(We),Vt=Sn(ce),cn=(Pe,ht)=>{Rn(Pe),ln(ht)};for(let Pe of nn){let ht=yt.get(Pe),Mt=Ut.prev[ht],xt=Ut.next[ht],mt=Mt>=0?ke.baseOf(We[Mt]):null,mn=xt<We.length?ke.baseOf(We[xt]):null,_t=mt?Ee.get(mt):-1,On=mn?Ee.get(mn):ce.length;for(let yn=Math.max(0,_t);yn<=Math.min(On,ce.length-1);yn++){let $t=ce[yn];(lt($t)||De($t))&&(!$e($t,Pe)||!un($t,Pe)||(De($t)?ln(Pe):cn($t,Pe)))}}let pn=(Pe,ht,Mt)=>{for(let xt=ht+Mt;xt>=0&&xt<Pe.length;xt+=Mt){let mt=Pe[xt];if(lt(mt))return mt;if(Qe(mt)||mt.value.trim())return null}return null},lo=Pe=>{let ht=new Set;for(let Mt of i(Pe))if(!Qe(Mt)&&Mt.kind==="text")for(let xt of _e(Mt))ht.add(xt);return ht},Un=(Pe,ht)=>{let Mt=_e(ht),xt=new Set;for(let mt of lo(Pe))Mt.has(mt)||xt.add(mt);return xt},eo=(Pe,ht)=>{if(!Pe.size)return!1;let Mt=_e(ht),xt=0;for(let mt of Pe)Mt.has(mt)&&xt++;return xt*2>=Pe.size};for(let Pe of ce){if(Ce.identical.has(Pe)||!lt(Pe))continue;let ht=Pt(Pe);if(!ht||!lt(ht))continue;let Mt=Un(ht,Pe),xt=Un(Pe,ht);for(let mt of[-1,1]){let mn=pn(ce,Ee.get(Pe),mt);mn&&eo(Mt,mn)&&(cn(Pe,ht),Rn(mn));let _t=pn(We,yt.get(ht)??-1,mt);if(_t&&eo(xt,_t)){cn(Pe,ht);let On=ke.baseOf(_t);On?cn(On,_t):ln(_t)}}}for(let Pe of Wt){let ht=Ee.get(Pe),Mt=Vt.prev[ht],xt=Vt.next[ht],mt=Mt>=0?Pt(ce[Mt]):null,mn=xt<ce.length?Pt(ce[xt]):null,_t=mt?yt.get(mt)??-1:-1,On=mn?yt.get(mn)??-1:We.length;for(let yn=Math.max(0,_t);yn<=Math.min(On,We.length-1);yn++){let $t=We[yn];if((lt($t)||De($t))&&!(!$e(Pe,$t)||!un($t,Pe))&&(Rn(Pe),!De($t))){let co=ke.baseOf($t);co?cn(co,$t):ln($t)}}}}if(!Ke)return null;for(let ke of Array.from(Ke))if(Se.has(ke))for(let Ce of[K,D]){let We=Fe(Ce,ke);We&&!ge(We,Ce===K?T:P,Ce)&&!(Ce===K?q:Y).asBase&&(Ke.delete(ke),Ke.delete(Fe(K,ke)),Ke.delete(Fe(D,ke)))}return Ke.size?Ke:null}function zt(){if((q.asBase||K.identical.has(c))&&(Y.asBase||D.identical.has(c)))return;let J={ignored:r,remoteWins:n.remoteWins,inlineCache:le},Re=Xe=>Qe(Xe)?Bn(Xe,J):Xe.kind==="text",ve=rn(Re),Ye=Xe=>ve&&ve.has(Xe)||Re(Xe),lt=ce.map(Ye);if(!lt.includes(!0))return;let De=Xe=>{let dt=Xe.units,ke=new Map;for(let kt=0;kt<dt.length;kt++)ke.set(dt[kt],kt);let Ce=[],We=-1;for(let kt=0;kt<ce.length;kt++){if(lt[kt])continue;let Pt=Xe.twin(ce[kt]),Wt=Pt?ke.get(Pt):void 0;Wt===void 0||Wt<=We||Ye(Pt)||(Ce.push([kt,Wt]),We=Wt)}let nt=[],$e=-1,yt=-1;for(let kt=0;kt<=Ce.length;kt++){let[Pt,Wt]=kt<Ce.length?Ce[kt]:[ce.length,dt.length],nn={bLo:-1,bHi:-1,sLo:-1,sHi:-1,next:Wt};for(let Ot=$e+1;Ot<Pt;Ot++)lt[Ot]&&(nn.bLo<0&&(nn.bLo=Ot),nn.bHi=Ot);for(let Ot=yt+1;Ot<Wt;Ot++)Ye(dt[Ot])&&(nn.sLo<0&&(nn.sLo=Ot),nn.sHi=Ot);nt.push(nn),$e=Pt,yt=Wt}return{units:dt,list:nt}},Ke=De(q),tt=De(Y),_e=[];for(let Xe of[Ke,tt])for(let dt of Xe.list)dt.bLo>=0&&_e.push([dt.bLo,dt.bHi]);_e.sort((Xe,dt)=>Xe[0]-dt[0]);let ot=[];for(let[Xe,dt]of _e){let ke=ot[ot.length-1];ke&&Xe<=ke.hi?ke.hi=Math.max(ke.hi,dt):ot.push({lo:Xe,hi:dt})}let Zt=(Xe,dt)=>{let ke=-1,Ce=-1;for(let $e=0;$e<Xe.list.length;$e++){let yt=Xe.list[$e];yt.bLo<dt.lo||yt.bLo>dt.hi||(ke<0&&(ke=$e),Ce=$e)}let We=1/0,nt=-1;for(let $e=ke;$e>=0&&$e<=Ce;$e++){let yt=Xe.list[$e];yt.sLo>=0&&(We=Math.min(We,yt.sLo),nt=Math.max(nt,yt.sHi)),$e<Ce&&(We=Math.min(We,yt.next),nt=Math.max(nt,yt.next))}return nt<0?[]:Xe.units.slice(We,nt+1)},En=(Xe,dt)=>Xe.length===dt.length&&Xe.every((ke,Ce)=>l.equalUnits(ke,dt[Ce])),un=Xe=>!Qe(Xe)&&Xe.kind==="comment",ln=Xe=>{if(!Xe.length)return[];let dt=($e,yt)=>Qe($e)?$e:$e.nodes[yt?$e.nodes.length-1:0],ke=dt(Xe[0]),Ce=dt(Xe[Xe.length-1],!0),We=$e=>$e&&Qe($e)&&r($e);for(;We(ke.previousSibling);)ke=ke.previousSibling;for(;We(Ce.nextSibling);)Ce=Ce.nextSibling;let nt=[];for(let $e=ke;$e&&(nt.push($e),$e!==Ce);$e=$e.nextSibling);return nt},Rn=Xe=>Xe.some(dt=>Qe(dt)&&r(dt));for(let Xe of ot){let dt=ce.slice(Xe.lo,Xe.hi+1),ke=q.asBase?null:Zt(Ke,Xe),Ce=Y.asBase?null:Zt(tt,Xe);if(dt.some(un)||ke&&ke.some(un)||Ce&&Ce.some(un))continue;let We=ln(ke||dt),nt=ln(Ce||dt);if((!ke||En(dt,ke))&&(!Ce||En(dt,Ce))&&!(ke&&Rn(We)))continue;let $e=Wo({base:ln(dt),local:We,remote:nt,out:V,policy:b,blocks:ve,L:ke?K:Is(K,c),R:Ce?D:Is(D,c),idOf:{local:R,remote:F},ignored:r,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(kt,Pt,Wt)=>It(kt,Pt,Wt,!1),cloneUnit:p,mergeAttrs:v,atomKey:l.exactUnitKey,moveIn:Xt,provenance:ye,textMappers:be,conflicts:He,conflict:pe,scope:{base:c,local:q.asBase?null:q.el,remote:Y.asBase?null:Y.el,units:ce,at:Xe.lo},decisions:Oe,node:_});ze.push(...$e.segments);let yt=V.createDocumentFragment();for(let kt of $e.nodes)yt.appendChild(kt);for(let kt of[...dt,...ke||[],...Ce||[]])se.add(kt),Ve.add(kt),Be.set(kt,yt);pt.push({frag:yt,at:Xe.lo})}}}function E(c,T){let P=ye.get(c);return P&&P.unchanged?!P.remote||P.remote===T?!0:f(P.remote,T):c.tagName!==T.tagName||!W(c,T)?!1:j(C(c),C(T))}function f(c,T){return c===T?!0:c.tagName!==T.tagName||c.namespaceURI!==T.namespaceURI||!W(c,T)?!1:m(C(c),C(T))}function m(c,T){let P=z(c,r),U=z(T,r);if(P.length!==U.length)return!1;for(let _=0;_<P.length;_++){let q=P[_],Y=U[_];if(typeof q=="string"||typeof Y=="string"){if(q!==Y)return!1}else{if(q.nodeType!==Y.nodeType)return!1;if(q.nodeType===1){if(!f(q,Y))return!1}else if(q.nodeValue!==Y.nodeValue)return!1}}return!0}function C(c){return c.tagName==="TEMPLATE"&&c.content?c.content:c}function W(c,T){let P=0;for(let U of c.attributes)if(!n.ignoreAttribute(c,U.name)&&(P++,T.getAttribute(U.name)!==U.value))return!1;for(let U of T.attributes)n.ignoreAttribute(T,U.name)||P--;return P===0}function j(c,T){let P=z(c,_=>{let q=ye.get(_);return!!(q&&q.pinned)}),U=z(T,r);if(P.length!==U.length)return!1;for(let _=0;_<P.length;_++){let q=P[_],Y=U[_];if(typeof q=="string"||typeof Y=="string"){if(q!==Y)return!1}else{if(q.nodeType!==Y.nodeType)return!1;if(q.nodeType===1){if(!E(q,Y))return!1}else if(q.nodeValue!==Y.nodeValue)return!1}}return!0}function z(c,T){let P=[],U=null;for(let _=c.firstChild;_;_=_.nextSibling){if(_.nodeType===3){U=U===null?_.nodeValue:U+_.nodeValue;continue}_.nodeType===1&&T(_)||(U!==null&&(U!==""&&P.push(U),U=null),P.push(_))}return U!==null&&U!==""&&P.push(U),P}function x(c,T,P,U){let _=c.value,q=U?_:T?T.value:"",Y=P?P.value:"";se.add(c),T&&se.add(T),P&&se.add(P);let ce=q===Y?q:q===_?Y:Y===_||b==="local"?q:Y,Se={site:"comment",bRun:c,lRun:T,rRun:P,node:null};if(q!==_&&Y!==_&&q!==Y&&pe({kind:"text",node:null,base:_,local:q,remote:Y,resolved:ce},Se),!T&&!P)return null;let Ee=V.createComment(ce);return Se.node=Ee,ye.set(Ee,{base:c.nodes,local:T?T.nodes:null,remote:P?P.nodes:null}),Ee}function S(c,T){let P=Fe(T,c);if(!P)return null;let U=Qe(P)?P.parentNode:P.parent,_=Qe(c)?c.parentNode:c.parent;return Fe(T,_)===U?null:T.reverse.get(U)||null}function G(c){let T=new Set([c]),P=c;for(let U=0;U<64;U++){let _=S(P,K)||S(P,D);if(!_)return!1;if(_===c||Qe(c)&&Qe(_)&&c.contains(_)||T.has(_))return!0;T.add(_),P=_}return!0}function ge(c,T,P){if(!T)return!1;let U=Qe(c)?c.parentNode:c.parent;return U===T||T.tagName==="TEMPLATE"&&U===T.content}function Me(c,T){let P=te(c),U=Fe(K,P);if(U&&ge(T,U,K))return!0;let _=Fe(D,P);return!!(_&&ge(T,_,D))}}function Is(e,o){return e.map.get(o)?Ls():{map:{get:n=>n&&n.nodeType===1&&e.map.get(n)||n,has:()=>!0},reverse:{get:n=>e.reverse.get(n)||n,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Ls(){let e={get:o=>o,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Cs=new Set(["INPUT","OPTION","TEXTAREA"]),Go=/[\t\n\f\r ]+/;function Es(e,o,t,n){let r=e.ownerDocument,{provenance:a,textMappers:l}=t,i=n.hooks,u=[],A=[],N=[],h=new Set,M=[],L=[],R=new Map,F=new Set,k=new Map,d=t.conflicts.length>0,w=new Map,Z=new Set,he=new Map,xe=(v,X)=>{let Q=he.get(v);Q||he.set(v,Q=new Set),Q.add(X)},ee=d?new Set:null,oe=(v,X,Q)=>{let de=i.beforeAttributeUpdated(v,X,Q);return d&&de===!1&&xe(X,v),de},re=v=>!!v&&(v===e||e.contains(v)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(v)),ne=new Map,K=new Map,D=new Map,Ne=new Set,ae=new Map;(function v(X){let Q=a.get(X);if(Q){if(X.nodeType===1){let ie=Q.local?n.toLive(Q.local):null;ie&&re(ie)&&ie.nodeType===1&&(ne.set(X,ie),K.set(ie,X))}else if(Array.isArray(Q.local)){let ie=be(Q.local,Q.local.map(ue=>n.toLive(ue)).filter(ue=>ue&&re(ue)&&ue.nodeType===X.nodeType));if(ie.length&&(ne.set(X,ie[0]),K.set(ie[0],X),D.set(X,ie)),Array.isArray(Q.caret))for(let ue of Q.caret){let p=n.toLive(ue.node);if(!p||!re(p)||p.nodeType!==3)continue;let y=ae.get(p);Array.isArray(y)||ae.set(p,y=[]),y.push({merged:X,from:ue.from,to:ue.to,flatStart:ue.flatStart})}else{let ue=0;for(let p of ie)ae.set(p,{merged:X,shift:ue}),ue+=p.nodeValue.length}}}let de=X.nodeType===1&&X.tagName==="TEMPLATE"&&X.content?X.content.childNodes:X.childNodes;for(let ie of de)v(ie)})(o);let te=new Set;for(let v of ne.values())te.add(v);for(let v of D.values())for(let X of v)te.add(X);for(let v of t.segments||[])Oe(v);let V=n.restoreFocus===!1?null:Kr(r,ae);n.childrenOnly?se(He(e),He(o)):Ue(e,o);for(let{node:v,parent:X}of M)h.has(v)||!v.parentNode||v.nodeType===1&&(n.ignored(v)||at(v))||je(v,X);return Wr(r,V,ae,l,D,k,Ne),{applied:u,moved:A,replaced:N,identities:L,mergedScriptsLive:F,liveOf:ne,heldBy:k,runOf:D,keptRuns:Ne,insertedLive:w,vetoed:Z,vetoedAttrs:he,removedVetoes:ee};function ye(v,X){let Q=v.slice(X.bs,X.be),de=0;for(;de<Q.length&&de<X.text.length&&Q[de]===X.text[de];)de++;let ie=0;for(;ie<Q.length-de&&ie<X.text.length-de&&Q[Q.length-1-ie]===X.text[X.text.length-1-ie];)ie++;return{bs:X.bs+de,be:X.be-ie,text:X.text.slice(de,X.text.length-ie)}}function be(v,X){if(!X.length)return X;let Q=[];for(let ue of v){let p=ue.parentNode;if(!p)continue;let y=R.get(p);if(!y){y=new Set;for(let E=p.firstChild;E;E=E.nextSibling)E.nodeType===3&&y.add(n.toLive(E));R.set(p,y)}Q.includes(y)||Q.push(y)}let de={has:ue=>Q.some(p=>p.has(ue))},ie=[];for(let ue of X){ie.push(ue);for(let p=ue.nextSibling;p&&p.nodeType===3&&!de.has(p)&&!ie.includes(p);p=p.nextSibling)ie.push(p)}return ie}function Oe(v){let X=[];for(let x of v.localNodes){let S=n.toLive(x.node);if(!S||!re(S)||S.nodeType!==3)return;X.push(S)}let Q=be(v.localNodes.map(x=>x.node),X);if(!Q.length)return;let de=Q.map(x=>x.nodeValue).join(""),{flatLocal:ie,lToM:ue,mapLocal:p}=v;if(de===ie)return;let y=v.textNodes.map(x=>({node:x.node,ms:x.ms,me:x.me})),E=[],f=0;for(let x of Q)E.push(f),f+=x.nodeValue.length;let m=(x,S)=>Q.find((G,ge)=>E[ge]<=x&&x+S<=E[ge]+G.nodeValue.length)||null,C=[],W=0;for(let x of Wn(ie,de).map(S=>ye(ie,S))){let S=x.bs+W;W+=x.text.length-(x.be-x.bs);let G,ge;if(x.be>x.bs){G=ue[x.bs];let Me=G>=0;for(let c=x.bs;Me&&c<x.be;c++)ue[c]!==G+(c-x.bs)&&(Me=!1);if(!Me)continue;ge=G+(x.be-x.bs)}else{let Me=x.bs>0?ue[x.bs-1]:0,c=x.bs<ie.length?ue[x.bs]:0;if(Me<0||c<0)continue;G=ge=p(x.bs)}C.push({ms:G,me:ge,text:x.text,live:ge===G?m(S,x.text.length):null})}C.sort((x,S)=>S.ms-x.ms);let j=(x,S)=>(D.get(x.node)||[ne.get(x.node)]).includes(S),z=x=>!!x&&x.nodeType===1&&wn.has(x.tagName);for(let x of C){let S=y.find(ge=>ge.ms<=x.ms&&x.me<=ge.me&&x.ms<ge.me);if(S&&x.live&&S.ms===x.ms&&!j(S,x.live)){let ge=y.find(Me=>Me.me===x.ms&&j(Me,x.live));ge&&(S=ge)}if(!S&&x.me===x.ms){let ge=y.find(P=>P.me===x.ms),Me=y.find(P=>P.ms===x.ms),c=ge||Me;if(!c)continue;let T=c.node;for(;z(T.parentNode)&&(ge?T.parentNode.lastChild:T.parentNode.firstChild)===T;)T=T.parentNode;if(T===c.node)S=c;else{let P=T.ownerDocument.createTextNode(x.text);T.parentNode.insertBefore(P,ge?T.nextSibling:T);continue}}if(!S)continue;let G=S.node.nodeValue;S.node.nodeValue=G.slice(0,x.ms-S.ms)+x.text+G.slice(x.me-S.ms),S.me+=x.text.length-(x.me-x.ms)}}function He(v){return v.nodeType===1&&v.tagName==="TEMPLATE"&&v.content?v.content:v}function Ue(v,X){h.add(v);let Q=a.get(X);if(Q&&Q.remote&&t.remoteIdOf){let ie=t.remoteIdOf(Q.remote);ie&&L.push([v,ie])}if(Q&&Q.unchanged){t.customIdentity&&Q.remote&&H(v,Q.remote),Q.remote&&b(v,Q.remote);return}if(i.beforeNodeMorphed(v,X)===!1){Z.add(X);return}tn(v,X,n.keepLiveOnly&&Q&&Q.local&&Q.local.nodeType===1&&Q.local!==v?Q.local:null);let de=v.tagName;if(en(v))v.textContent!==X.textContent&&(u.push({kind:"text",node:v,before:v.textContent,after:X.textContent}),v.textContent=X.textContent),t.mergedScripts.has(X)&&F.add(v);else if(de==="TEXTAREA")sn(v,X,Q);else{It(v,X,Q);let ie=de==="TEMPLATE"&&v.content?v.content:v,ue=de==="TEMPLATE"&&X.content?X.content:X;n.protectFocusedValue==="subtree"&&Xt(v)&&v!==r.body?ze(ie):se(ie,ue)}i.afterNodeMorphed(v,X)}function ze(v){for(let X=v.firstChild;X;X=X.nextSibling){let Q=K.get(X);Q&&ne.get(Q.parentNode)!==v||(h.add(X),X.nodeType===1&&ze(X))}}function se(v,X){let Q=pe(v.firstChild),de=new Set;for(let ie of Array.from(X.childNodes)){let ue=ne.get(ie);ue&&h.has(ue)&&!de.has(ue)&&(ue=null);let p=a.get(ie);if(p&&p.pinned){ue&&ue.nodeType===1&&((ue.parentNode!==v||pe(ue.nextSibling)!==Q)&&Ge(v,ue,Q),h.add(ue),de.add(ue));continue}if(ue&&ue.nodeType===1){if(ue!==Q){let f=ue.parentNode;if(f===v&&Q&&Jt(ue)){let m=ue.nextSibling;for(let C=Q;C&&C!==ue;){let W=C.nextSibling;Ge(v,C,m),C=W}}else Ge(v,ue,Q),f!==v&&(A.push(ue),u.push({kind:"move",el:ue,from:f,to:v}))}de.add(ue),Ue(ue,ie),Q=pe(ue.nextSibling);continue}if(ue&&ue.nodeType!==1){let f=D.get(ie)||[ue],m=f.map(W=>W.nodeValue).join(""),C=ie.nodeValue;if(ie.nodeType===3){let W=ft(ie);W!=null&&m!==W&&(C=Kn(W,m,ie.nodeValue).text)}if(f.length>1&&m===C&&!f.includes(Q,1)&&f.every((W,j)=>W.parentNode===v&&(j===0||f[j-1].nextSibling===W))){if(ue!==Q)for(let W of f)Ge(v,W,Q);i.beforeNodeMorphed(ue,ie)!==!1?i.afterNodeMorphed(ue,ie):d&&Z.add(ie);for(let W of f)h.add(W),de.add(W);k.set(ie,ue),Ne.add(ie),Q=pe(f[f.length-1].nextSibling);continue}ue!==Q&&Ge(v,ue,Q),i.beforeNodeMorphed(ue,ie)!==!1?(ue.nodeValue!==C&&(u.push({kind:"text",node:ue,before:ue.nodeValue,after:C}),ue.nodeValue=C),i.afterNodeMorphed(ue,ie)):Z.add(ie),h.add(ue),de.add(ue),k.set(ie,ue),Q=pe(ue.nextSibling);continue}if(ie.nodeType===3&&Q&&Q.nodeType===3&&!h.has(Q)&&!ae.has(Q)){Q.nodeValue!==ie.nodeValue&&(u.push({kind:"text",node:Q,before:Q.nodeValue,after:ie.nodeValue}),Q.nodeValue=ie.nodeValue),h.add(Q),k.set(ie,Q),Q=pe(Q.nextSibling);continue}let y=a.get(ie),E=Ze(y&&y.unchanged&&y.remote?y.remote:ie);if(i.beforeNodeAdded(E)===!1){Z.add(ie);continue}v.insertBefore(E,Q),h.add(E),d&&w.set(ie,E),E.nodeType===3&&k.set(ie,E),E.nodeType===1&&(N.push(E),we(E,ie),t.customIdentity&&y&&y.unchanged&&y.remote&&H(E,y.remote),en(E)||rt(E,ie),n.formState==="property"&&Dt(y)&&b(E,y.remote)),Q=pe(E.nextSibling),u.push({kind:"insert",node:E,parent:v}),i.afterNodeAdded(E)}for(let ie of Array.from(v.childNodes))h.has(ie)||de.has(ie)||ie.nodeType===1&&(n.ignored(ie)||at(ie))||(te.has(ie)?M.push({node:ie,parent:v}):je(ie,v))}function at(v){return n.preserve&&v.parentNode&&v.parentNode.nodeType===1&&v.parentNode.tagName==="HEAD"&&n.preserve(v)===!0}function ft(v){let X=a.get(v);return!X||!Array.isArray(X.local)?null:X.local.map(Q=>Q.nodeValue).join("")}function le(v){return a.get(v)}function b(v,X){if(!Cs.has(v.tagName)&&!v.querySelector("input,option,textarea"))return;let Q=(de,ie)=>{if(de.tagName!==ie.tagName)return;de.tagName==="TEXTAREA"?sn(de,ie,{remote:ie}):Cs.has(de.tagName)&&It(de,ie,{remote:ie});let ue=fe(de),p=fe(ie);if(ue.length===p.length)for(let y=0;y<ue.length;y++)Q(ue[y],p[y])};Q(v,X)}function H(v,X){let Q=fe(v),de=fe(X);if(Q.length===de.length)for(let ie=0;ie<Q.length;ie++){let ue=t.remoteIdOf(de[ie]);ue&&L.push([Q[ie],ue]),H(Q[ie],de[ie])}}function fe(v){let X=v.tagName==="TEMPLATE"&&v.content?v.content:v;return Array.from(X.children).filter(Q=>!n.ignored(Q))}function we(v,X){if(!t.remoteIdOf)return;let Q=(de,ie)=>{let ue=a.get(ie);if(ue&&ue.remote&&ie.nodeType===1){let E=t.remoteIdOf(ue.remote);E&&L.push([de,E])}let p=de.childNodes,y=ie.childNodes;for(let E=0;E<p.length&&E<y.length;E++)Q(p[E],y[E])};Q(v,X)}function pe(v){for(;v&&v.nodeType===1&&n.ignored(v);)v=v.nextSibling;return v}function Ge(v,X,Q){if(typeof v.moveBefore=="function"&&X.ownerDocument===v.ownerDocument)try{v.moveBefore(X,Q);return}catch{}v.insertBefore(X,Q)}function je(v,X){if(i.beforeNodeRemoved(v)===!1){d&&ee.add(v);return}v.parentNode.removeChild(v),u.push({kind:"remove",node:v,parent:X}),i.afterNodeRemoved(v)}function Ze(v){if(en(v))return no(v,r);let X=r.importNode(v,!0);if(X.nodeType===1)for(let Q of Array.from(X.querySelectorAll("script")))en(Q)&&Q.replaceWith(no(Q,r));return X}function rt(v,X){let Q=v.tagName==="TEMPLATE"&&v.content?v.content:v,de=X.tagName==="TEMPLATE"&&X.content?X.content:X,ie=Array.from(Q.childNodes),ue=Array.from(de.childNodes);for(let p=0;p<ue.length&&p<ie.length;p++){let y=ue[p],E=ie[p],f=ne.get(y);f&&h.has(f)&&(f=null);let m=a.get(y);if(m&&m.pinned){if(f&&f.nodeType===1){let C=f.parentNode;Ge(Q,f,E),C!==Q&&(A.push(f),u.push({kind:"move",el:f,from:C,to:Q})),h.add(f)}E.remove();continue}if(f){let C=f.parentNode;Ge(Q,f,E),E.remove(),f.nodeType===1?(C!==Q&&(A.push(f),u.push({kind:"move",el:f,from:C,to:Q})),Ue(f,y)):(h.add(f),k.set(y,f),f.nodeValue!==y.nodeValue&&(u.push({kind:"text",node:f,before:f.nodeValue,after:y.nodeValue}),f.nodeValue=y.nodeValue));continue}h.add(E),d&&w.set(y,E),E.nodeType===3&&k.set(y,E),m&&m.unchanged&&m.remote?(wt(E,m.remote),t.customIdentity&&H(E,m.remote)):y.nodeType===1&&!en(y)&&rt(E,y)}}function wt(v,X){let Q=v.tagName==="TEMPLATE"&&v.content?v.content:v,de=X.tagName==="TEMPLATE"&&X.content?X.content:X;for(let ie of Array.from(de.childNodes))Q.appendChild(Ze(ie))}function bt(v,X){return X.namespaceURI?v.getAttributeNS(X.namespaceURI,X.localName):v.getAttribute(X.name)}function Tt(v,X){let Q=new Set((X||"").split(Go).filter(Boolean));return(v||"").split(Go).filter(de=>de&&!Q.has(de))}function tn(v,X,Q){for(let de of Array.from(X.attributes)){if(Fe(v,de.name)||n.ignoreAttribute(v,de.name))continue;let ie=bt(v,de);if(ie===de.value||Q&&bt(Q,de)===de.value)continue;let ue=de.value;if(Q&&de.name==="class"&&!de.namespaceURI){let p=de.value.split(Go).filter(Boolean),y=Tt(ie,Q.getAttribute("class")).filter(E=>!p.includes(E));y.length&&(ue=[...p,...y].join(" "))}if(ie!==ue){if(i.beforeAttributeUpdated(de.name,v,"update")===!1){d&&xe(X,de.name);continue}de.namespaceURI?v.setAttributeNS(de.namespaceURI,de.name,ue):v.setAttribute(de.name,ue),u.push({kind:"attr",el:v,name:de.name,before:ie,after:ue})}}for(let de of Array.from(v.attributes)){if(Fe(v,de.name)||n.ignoreAttribute(v,de.name)||(de.namespaceURI?X.hasAttributeNS(de.namespaceURI,de.localName):X.hasAttribute(de.name)))continue;if(Q&&de.name==="class"&&!de.namespaceURI){let p=Tt(de.value,Q.getAttribute("class"));if(p.length){let y=p.join(" ");if(y===de.value)continue;if(i.beforeAttributeUpdated("class",v,"update")===!1){d&&xe(X,"class");continue}v.setAttribute("class",y),u.push({kind:"attr",el:v,name:"class",before:de.value,after:y});continue}}if(Q&&bt(Q,de)===null)continue;if(i.beforeAttributeUpdated(de.name,v,"remove")===!1){d&&xe(X,de.name);continue}let ue=de.value;de.namespaceURI?v.removeAttributeNS(de.namespaceURI,de.localName):v.removeAttribute(de.name),u.push({kind:"attr",el:v,name:de.name,before:ue,after:null})}}function Fe(v,X){let Q=v.tagName;return Q==="INPUT"?X==="value"||X==="checked"||X==="disabled":Q==="OPTION"?X==="selected":!1}function Xt(v){return v===r.activeElement}function Jt(v){let X=r.activeElement;return!!X&&X!==r.body&&v.contains(X)}function Dt(v){let X=v&&v.remote;return X&&X.nodeType===1?X:null}function It(v,X,Q){let de=v.tagName,ie=Dt(Q),ue=n.formState==="property"&&ie?ie:X;if(de==="INPUT"){let p=n.protectFocusedValue&&Xt(v),y=(v.getAttribute("type")||"").toLowerCase(),E=y!=="file"&&y!=="checkbox"&&y!=="radio",f=ie&&ie.hasAttribute("value")&&ie.value!==ie.getAttribute("value")?ie.value:null;if(E&&!p)if(n.formState==="property"){let m=X.getAttribute("value"),C=v.getAttribute("value");(C!==m||v.value!==ue.value)&&oe("value",v,m==null?"remove":"update")!==!1&&(C!==m&&(m==null?v.removeAttribute("value"):v.setAttribute("value",m),u.push({kind:"attr",el:v,name:"value",before:C,after:m})),v.value!==ue.value&&(v.value=ue.value))}else if(X.hasAttribute("value")||f!=null){let m=f??X.getAttribute("value");v.getAttribute("value")!==m&&oe("value",v,"update")!==!1?(v.setAttribute("value",m),v.value!==m&&(v.value=m),u.push({kind:"attr",el:v,name:"value",before:null,after:m})):v.value!==m&&v.getAttribute("value")===m&&(v.value=m)}else(v.hasAttribute("value")||v.value!=="")&&oe("value",v,"remove")!==!1&&(v.removeAttribute("value"),v.value="",u.push({kind:"attr",el:v,name:"value",before:"",after:null}));if(!E&&y!=="file"){let m=X.getAttribute("value");m==null?v.hasAttribute("value")&&oe("value",v,"remove")!==!1&&v.removeAttribute("value"):v.getAttribute("value")!==m&&oe("value",v,"update")!==!1&&v.setAttribute("value",m)}p||(Et(v,ue,"checked"),n.formState==="property"&&v.indeterminate!==ue.indeterminate&&(v.indeterminate=ue.indeterminate)),Et(v,ue,"disabled")}else if(de==="OPTION"){let p=v.parentNode&&v.closest("select");n.protectFocusedValue&&p&&Xt(p)||Et(v,ue,"selected")}}function Et(v,X,Q){let de=n.formState==="property"?!!X[Q]:X.hasAttribute(Q);if(n.formState!=="property"){let ie=v.hasAttribute(Q);if(ie!==de){if(oe(Q,v,de?"update":"remove")===!1)return;de?v.setAttribute(Q,""):v.removeAttribute(Q),u.push({kind:"attr",el:v,name:Q,before:ie?"":null,after:de?"":null})}}v[Q]!==de&&(v[Q]=de)}function sn(v,X,Q){if(n.protectFocusedValue&&Xt(v)||oe("value",v,"update")===!1)return;let de=Dt(Q),ie=X.textContent,ue=de&&de.value!==de.defaultValue?de.value:ie;n.formState!=="property"&&v.textContent!==ie&&(u.push({kind:"text",node:v,before:v.textContent,after:ie}),v.textContent=ie),v.value!==ue&&(v.value=ue)}}function Kr(e,o){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let n={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{n.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return n}let r=e.getSelection&&e.getSelection();if(r&&r.rangeCount){let a=r.getRangeAt(0);n.range={sc:a.startContainer,so:a.startOffset,ec:a.endContainer,eo:a.endOffset}}return n}function Wr(e,o,t,n,r,a,l){if(!o)return;let i=o.el;if(!i.isConnected&&o.id&&(i=e.getElementById(o.id)),!i||!i.isConnected)return;if(e.activeElement!==i)try{i.focus({preventScroll:!0})}catch{}try{i.scrollTop=o.scrollTop,i.scrollLeft=o.scrollLeft}catch{}if(o.selection){try{i.setSelectionRange&&!i.selectionEnd&&o.selection[1]!=null&&i.setSelectionRange(o.selection[0],o.selection[1],o.selection[2]||"none")}catch{}return}if(!o.range)return;let u=(h,M)=>{let L=t.get(h);if(Array.isArray(L)){let R=L.find(w=>M>=w.from&&M<w.to)||L.find(w=>M===w.to)||L[L.length-1],F=a.get(R.merged);if(!F||!F.isConnected)return null;let k=n.get(R.merged),d=k&&k.flat?k.flat(R.flatStart+M):M;return[F,Math.max(0,Math.min(d,F.nodeValue.length))]}if(L&&!l.has(L.merged)){let R=(r.get(L.merged)||[h])[0];if(!R.isConnected)return null;let F=n.get(L.merged),k=L.shift+M,d=F?F(k):k;return[R,Math.max(0,Math.min(d,R.nodeValue.length))]}return h.isConnected?[h,Math.min(M,h.nodeType===3?h.nodeValue.length:h.childNodes.length)]:null},A=u(o.range.sc,o.range.so),N=u(o.range.ec,o.range.eo);if(!(!A||!N))try{let h=e.createRange();h.setStart(A[0],A[1]),h.setEnd(N[0],N[1]);let M=e.getSelection();M.removeAllRanges(),M.addRange(h)}catch{}}var Fr={compared:0},zr=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function $r(e,o,t){let n=0;for(let r of e.attributes)if(!t(e,r.name)&&(n++,o.getAttribute(r.name)!==r.value))return!1;for(let r of o.attributes)t(o,r.name)||n--;return n===0}function Yo(e,o){if(e.namespaceURI!==o.namespaceURI||e.prefix!==o.prefix||e.localName!==o.localName)return!1;let t=e.attributes;if(t.length!==o.attributes.length)return!1;for(let n of t)if(o.getAttributeNS(n.namespaceURI,n.localName)!==n.value)return!1;return!0}function Rs(e,o,t,n,r,a,l,i){let u=new Map,A=new Set,N=h=>{if(n(h))return;let M=t(h);M&&(a.add(M),r.has(M)||u.has(M)?A.add(M):u.set(M,h))};for(let h of e)N(h);N(o);for(let h of l||o.querySelectorAll("*"))N(h);for(let h of A)u.delete(h),i.add(h);return u}function Ps(e,o,t,n,r,a){let l=!1;for(let N of r)N.startsWith("merge:")&&(l=!0);if(!l)return[...n];let i=new Map,u=[],A=a===an?so:"*";for(let N of[e,...e.querySelectorAll(A)]){if(t(N))continue;let h=o(N);if(!h||!(n.has(h)||r.has(h)))continue;let M=(i.get(h)||0)+1;i.set(h,M),M===2&&u.push(h)}return u}function Bs({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:r,identity:a,baseURI:l}){if(e.tagName!==o.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||o.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!$r(e,o,r.ignoreAttribute))return{bail:"root-attrs"};let{ignored:i,remoteWins:u}=r,A=$o(r.scripts.merge===!1?null:r.scripts.mergeTags,l),N=le=>{let b=A(le);return b!==null?b:a.base(le)||null},h=le=>{let b=A(le);return b!==null?b:a.remote(le)||null},M=[],L=[],R=new Map,F=new Map,k={same:R,differ:F},d=le=>({bail:le,comparisons:k}),w=(le,b,H=!0)=>{if(R.get(le)===b)return!0;if(F.get(le)===b)return!1;if(Fr.compared++,H&&le.isEqualNode(b))return R.set(le,b),!0;let fe=le.nodeType===b.nodeType;if(fe&&le.nodeType===1){if(fe=Yo(le,b),fe){let we=le.firstChild,pe=b.firstChild;for(;we&&pe;we=we.nextSibling,pe=pe.nextSibling)if(!w(we,pe,!1)){fe=!1;break}(we||pe)&&(fe=!1)}}else fe&&(fe=le.isEqualNode(b));return(fe?R:F).set(le,b),fe},Z=e,he=o,xe=!1,ee=()=>{R.set(Z,he);for(let le=0;le<M.length;le++)R.set(M[le],L[le]);return d("equal")};for(;;){let le=Z.childNodes,b=he.childNodes;if(le.length!==b.length)break;let H=rt=>w(le[rt],b[rt])?(R.set(le[rt],b[rt]),!1):!0,fe=-1,we=-1;for(let rt=0;rt<le.length;rt++){if(le[rt].nodeType!==1)continue;let wt=0;for(let bt=le[rt].firstElementChild;bt;bt=bt.nextElementSibling)wt++;wt>=we&&(we=wt,fe=rt)}let pe=[],Ge=!1;for(let rt=0;rt<le.length&&pe.length<2;rt++)rt!==fe&&H(rt)&&pe.push(rt);if(fe>=0&&pe.length<2&&(pe.length===0&&Yo(Z,he)?(pe.push(fe),Ge=!0):H(fe)&&pe.push(fe)),pe.length!==1){if(!xe&&pe.length===0&&Yo(Z,he))return ee();break}let je=le[pe[0]],Ze=b[pe[0]];if(xe=xe||!Ge,xe&&F.set(je,Ze),je.nodeType!==1||Ze.nodeType!==1||je.tagName!==Ze.tagName)break;if(N(je)!==h(Ze)){if(!xe&&w(je,Ze))return ee();break}M.push(Z),L.push(he),Z=je,he=Ze}F.set(Z,he);for(let le=0;le<M.length;le++)F.set(M[le],L[le]);if(Z===e||Z.tagName==="HEAD"||Z.tagName==="BODY")return d("root-level");if(M.length<2||M[1].tagName!=="BODY")return d("not-in-body");if(i(Z)||i(he))return d("ignored-ancestor");if(u(Z)||u(he))return d("remote-wins-ancestor");for(let le of M)if(zr.has(le.tagName))return d("form-ancestor");if(Z.tagName==="SCRIPT"||Z.getElementsByTagName("script").length||he.getElementsByTagName("script").length)return d("script-or-template");let oe=n(Z);if(!oe||oe.nodeType!==1||oe.tagName!==Z.tagName)return d("no-live-twin");if(!t.contains(oe))return d("live-detached");for(let le of M){let b=n(le);if(!b||b.nodeType!==1)return d("ancestor-live")}let re=a.base===an&&a.remote===an&&i===Oo,ne=new Set,K=new Set,D=[],Ne=null,ae=le=>{le&&(ne.has(le)?K.add(le):ne.add(le))},te=(le,b)=>{let H=A(le),fe=H!==null?H:a.base(le)||null;return fe!==(H!==null?H:a.remote(b)||null)?!1:(ae(fe),!0)},V=(le,b)=>{for(let H=le.firstElementChild,fe=b.firstElementChild;H;H=H.nextElementSibling,fe=fe.nextElementSibling){let we=i(H);if(we!==i(fe))return!1;if(!we&&(!te(H,fe)||!V(H,fe)))return!1}return!0},ye=le=>{let b=le+1<M.length?M[le+1]:Z;for(let H=M[le].firstElementChild,fe=L[le].firstElementChild;H;H=H.nextElementSibling,fe=fe.nextElementSibling){if(H===b){let Ge=le+1<M.length?ye(le+1):null;if(Ge)return Ge;continue}let we=i(H);if(we!==i(fe))return"outside-id-changed";if(we)continue;let pe=n(H);if(!pe||pe.nodeType!==1)return"sibling-live";if(D.push([H,fe]),!re&&(!te(H,fe)||!V(H,fe)))return"outside-id-changed";le===0&&H.tagName==="HEAD"&&N(H)&&(Ne=[H,fe])}return null},be=ye(0);if(be)return d(be);let Oe=new Set(M),He=null;if(a.base===an){He=[];for(let le of e.querySelectorAll(so))le===Z||Oe.has(le)||(Z.contains(le)?He.push(le):re&&ae(N(le)))}let Ue=new Set,ze=new Set,se=new Set,at=Rs(M,Z,N,i,ne,Ue,He,ze),ft=Rs(L,he,h,i,ne,Ue,a.remote===an&&he.querySelectorAll(so),se);return Ne&&(K.has(N(Ne[0]))||Ue.has(N(Ne[0])))&&(Ne=null),{scope:{chain:M,root:Z,onChain:Oe,baseIndex:at,remoteIndex:ft,head:Ne,same:R,differ:F,dropped:[...Ps(e,N,i,K,ze,a.base),...Ps(o,h,i,K,se,a.remote)],held:le=>{for(let b=1;b<M.length;b++)if(le.map.get(M[b])!==L[b])return!1;for(let[b,H]of D)if(le.map.get(b)!==H)return!1;return!0}}}}var Hs=Symbol("hyper-morph-duplicate-key"),js=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function ro(e,o){return o.map(t=>{let n=new Map;for(let r of e){if(r.nodeType!==1)continue;let a=t(r);a==null||a===""||n.set(a,n.has(a)?Hs:r)}return n})}function Ds(e,o,t,n){for(let r=0;r<n.length;r++){let a=n[r](e);if(a==null||a===""||o[r].get(a)!==e)continue;let l=t[r].get(a);if(!(!l||l===Hs)&&l.tagName===e.tagName)return l}return null}function Jn(e,o,t){for(let n=0;n<t.length;n++){let r=t[n](e);if(!(r==null||r==="")&&o[n].get(r)===e)return!0}return!1}function Us(e,o,t={}){let n=t.skip||(()=>!1),r=t.ignoreAttr||(()=>!1),a=t.tiers&&t.tiers.length?t.tiers:js,l=null;function i(){return l||(l=ro([e,...e.querySelectorAll("*")],a)),l}let u=null;function A(){return u||(u=ro([o,...o.querySelectorAll("*")],a)),u}function N(ne){return!ne.parentElement||!ne.parentElement.parentElement}function h(ne,K,D){return N(ne)||Jn(ne,i(),a)?(D.push({type:"subtree",el:ne,base:K}),!1):!0}function M(ne,K){let D=[];for(let Ne of ne.attributes)r(ne,Ne.name)||K.getAttribute(Ne.name)!==Ne.value&&D.push(Ne.name);for(let Ne of K.attributes)r(ne,Ne.name)||ne.hasAttribute(Ne.name)||D.push(Ne.name);return D}function L(ne){let K=[],D=null,Ne=()=>{D!==null&&(K.push({nodeType:3,nodeValue:D}),D=null)};for(let ae of ne.childNodes){if(ae.nodeType===3){D=(D===null?"":D)+ae.nodeValue;continue}ae.nodeType===1&&n(ae)||(Ne(),(ae.nodeType===1||ae.nodeType===8)&&K.push(ae))}return Ne(),K}function R(ne,K){if(ne.nodeType!==K.nodeType)return!1;if(ne.nodeType!==1)return!0;if(ne.tagName!==K.tagName)return!1;for(let D of a){let Ne=D(ne),ae=D(K);if(Ne!=null&&Ne!==""&&ae!=null&&ae!==""&&Ne!==ae)return!1}return!0}function F(ne){let K="";for(let D of ne)D.nodeType===3&&D.nodeValue.trim()!==""?K+="\0"+D.nodeValue:D.nodeType===8&&(K+=""+D.nodeValue);return K}function k(ne,K,D){let Ne=L(ne),ae=L(K);if(Ne.length===ae.length){let le=!0;for(let b=0;b<Ne.length;b++)if(!R(Ne[b],ae[b])){le=!1;break}if(le){for(let b=0;b<Ne.length;b++){let H=Ne[b];if(H.nodeType===1){if(d(H,ae[b],D))return!0}else if(H.nodeValue!==ae[b].nodeValue)return!0}return!1}}let te=Ne.filter(le=>le.nodeType===1),V=ae.filter(le=>le.nodeType===1);if(F(Ne)!==F(ae))return!0;let ye=ro(te,a),be=ro(V,a),Oe=[],He=new Set,Ue=[];for(let le of te){let b=Ds(le,ye,be,a);b&&!He.has(b)?(Oe.push([le,b]),He.add(b)):Ue.push(le)}let ze=[];for(let le of Ue)Jn(le,ye,a)?D.push({type:"subtree",el:le,base:null}):ze.push(le);let se=[];for(let le of V)He.has(le)||(Jn(le,be,a)?D.push({type:"deletion",el:le}):se.push(le));if(ze.length!==se.length)return!0;for(let le=0;le<ze.length;le++)if(!R(ze[le],se[le]))return!0;let at=new Map(Oe);for(let le=0;le<ze.length;le++)at.set(ze[le],se[le]);let ft=-1;for(let le of te){let b=at.get(le);if(!b)continue;let H=V.indexOf(b);if(H<ft)return!0;ft=H}for(let le=0;le<ze.length;le++)if(d(ze[le],se[le],D))return!0;for(let[le,b]of Oe)if(d(le,b,D))return!0;return!1}function d(ne,K,D){if(ne.tagName!==K.tagName)return h(ne,K,D);let Ne=M(ne,K),ae=[];if(k(ne,K,ae))return h(ne,K,D);if(Ne.length){if(!N(ne)&&!Jn(K,A(),a))return!0;D.push({type:"attrs",el:ne,names:Ne,base:K})}return D.push(...ae),!1}let w=[],Z=M(e,o);Z.length&&w.push({type:"attrs",el:e,names:Z});let he=(ne,K)=>Array.from(ne.children).find(D=>D.tagName===K)||null,xe=he(e,"HEAD"),ee=he(o,"HEAD");if(xe&&ee){let ne=[];d(xe,ee,ne),ne.length&&w.push({type:"head",el:xe})}else(xe||ee)&&xe&&w.push({type:"head",el:xe});let oe=he(e,"BODY"),re=he(o,"BODY");return oe&&re?d(oe,re,w):oe&&w.push({type:"subtree",el:oe,base:null}),{entries:w}}function Vs(e,o,t={}){let n=t.tiers&&t.tiers.length?t.tiers:js,r=e.documentElement,a=[],l=0,i=d=>({ok:!1,placed:a,held:d,skippedAttrs:l});if(!r)return i(null);function u(d){let w=[d,...d.querySelectorAll("*")];return ro(w,n)}let A=u(r),N=new Map,h=d=>{let w=d.getRootNode(),Z=N.get(w);if(!Z){let he=w.nodeType===9?w.documentElement:w;Z=u(he),N.set(w,Z)}return Z};function M(d){if(!d.parentElement&&d.tagName==="HTML")return r;if(d.parentElement&&!d.parentElement.parentElement&&d.parentElement.tagName==="HTML"){if(d.tagName==="BODY")return e.body||null;if(d.tagName==="HEAD")return e.head||null}return null}function L(d){let w=M(d);return w||Ds(d,h(d),A,n)}function R(d){if(!d)return null;let w=L(d);return w&&w.isConnected?w:null}function F(d){for(let w=0;w<n.length;w++){let Z=n[w](d);Z!=null&&Z!==""&&A[w].set(Z,d)}}for(let d of o){if(d.type!=="deletion")continue;let w=L(d.el);w&&w!==r&&w.remove()}let k=o.filter(d=>d.type!=="deletion").sort((d,w)=>d.el===w.el?0:d.el.compareDocumentPosition(w.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let d of k){if(d.type==="head"){let re=e.importNode(d.el,!0);e.head?e.head.replaceWith(re):r.insertBefore(re,r.firstChild),a.push({entry:d,imported:re});continue}if(d.type==="attrs"){let re=R(d.el)||R(d.base);if(!re){l++;continue}for(let ne of d.names)d.el.hasAttribute(ne)?re.setAttribute(ne,d.el.getAttribute(ne)):re.removeAttribute(ne);continue}let w=d.el;if(M(w))return i(d);let Z=R(w)||R(d.base);if(Z){let re=e.importNode(w,!0);Z.replaceWith(re),F(re),a.push({entry:d,imported:re});continue}if(d.base!=null&&!Jn(d.base,h(d.base),n)||!Jn(w,h(w),n))return i(d);let he=w.parentElement;if(!he)return i(d);let xe=R(he);if(!xe)return i(d);let ee=null;for(let re=w.previousElementSibling;re;re=re.previousElementSibling){let ne=R(re);if(ne&&ne.parentNode===xe){ee=ne;break}}let oe=e.importNode(w,!0);if(ee)xe.insertBefore(oe,ee.nextSibling);else{let re=Array.prototype.indexOf.call(he.children,w);xe.insertBefore(oe,xe.children[re]||null)}F(oe),a.push({entry:d,imported:oe})}return{ok:!0,placed:a,held:null,skippedAttrs:l}}var Gr='[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"]',Yr='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Jr='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Xr(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let o=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(o)}function Qr(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let r=o;if(r.nodeType===9){let a=e.getAttribute("id");r=a&&r.getElementById(a)||(e.tagName==="BODY"?r.body:e.tagName==="HTML"?r.documentElement:r.body&&r.body.firstElementChild)}if((!r||r.nodeType!==1||r.tagName!==e.tagName)&&(r=Zr(e,o,n)),!!r)return t?Array.from(r.childNodes):r}function Zr(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let r=new Map,a=[n,...n.querySelectorAll("script")];for(let u of a){let A=Gn(u,t);A&&!r.has(A.key)&&r.set(A.key,u.textContent)}if(!r.size)return null;let l=e.cloneNode(!0),i=!1;for(let u of[l,...l.querySelectorAll("script")]){let A=Gn(u,t);A&&r.has(A.key)&&(u.textContent=r.get(A.key),i=!0)}return i?l:null}function _s(e,o){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=o.implementation.createHTMLDocument(""),n=e.nodeType===1&&e.tagName==="HTML"?e:null;if(n)return t.replaceChild(t.adoptNode(n),t.documentElement),t;let r=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let a of r)t.body.appendChild(t.adoptNode(a));return t}function Ao(e,o,t={}){let n=t||{};if(!n.head?.block)return qs(e,o,n);try{return qs(e,o,n)}catch(r){return Promise.reject(r)}}function qs(e,o,t){let n=t.policy||"sync",r=n==="raw"?void 0:(u,A)=>Xr(u)||(n==="history"?!(A&&u.matches(Jr))&&u.matches(Yr):u.matches(Gr)),a=t.callbacks||{},l={ignore:r,hooks:a,protectFocusedValue:t.ignoreActiveValue===!0?"subtree":!1,restoreFocus:t.restoreFocus!==!1,formState:t.formStateSync||"attribute",scripts:{execute:t.scripts?.handle!==!1,merge:t.scripts?.merge!==!1,mergeTags:t.scripts?.mergeTags||[]},head:{awaitLoads:!!t.head?.block,preserve:t.head?.shouldPreserve||(()=>!1)}};if(typeof t.key=="function"&&(l.identity={base:t.key,local:t.key,remote:t.key}),e&&e.nodeType===9)return Xn(Object.assign({},l,{live:e,base:t.scripts?.mergeBase||null,remote:_s(o,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let u=Object.assign({},l,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:_s(o,e.ownerDocument)});return Xn(u)}t.morphStyle==="innerHTML"&&(l.children=!0);let i=Qr(e,t.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return i!==void 0&&(l.base=i),vo(e,o,l)}var ei=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),hn=()=>{};function io(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!ei.has(l))throw new TypeError(`unknown option "${l}"`);let t=Object.assign({beforeNodeAdded:hn,afterNodeAdded:hn,beforeNodeRemoved:hn,afterNodeRemoved:hn,beforeNodeMorphed:hn,afterNodeMorphed:hn,beforeAttributeUpdated:hn},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let r=e.formState||"attribute";if(!["attribute","property"].includes(r))throw new TypeError("formState must be attribute or property");let a=e.protectFocusedValue;if(a!==void 0&&typeof a!="boolean"&&a!=="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");return{ignored:Mo(e.ignore,o),remoteWins:Mo(e.remoteWins,o),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:n,protectFocusedValue:a===void 0?!0:a,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:r,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0}}function Qn(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 an}function Zn(e,o){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=ho(o,e.map),n=typeof e.then=="function"?e.then:an;if(typeof e.first=="function"){let r=e.first;return a=>r(a)||t.get(a)||n(a)}return r=>t.get(r)||n(r)}return an}function Fs(e,o,t,n={}){let r=L=>L&&L.nodeType===9?L.documentElement:L,a=r(o),l=r(t),i=r(e)||a,u=Object.assign({},n);delete u.live,delete u.base,delete u.remote;let A=io(u,[i,a,l].filter(Boolean)),N=n.identity||{},h=Mn(),M=No(i,a,l,{identity:{base:Zn(N.base,i),local:Zn(N.local,a),remote:Zn(N.remote,l)},authored:{base:Qn(N.base),local:Qn(N.local),remote:Qn(N.remote)},skipUnchanged:A.hooks.beforeNodeMorphed===hn&&A.hooks.afterNodeMorphed===hn,ignored:A.ignored,remoteWins:A.remoteWins,ignoreAttribute:A.ignoreAttribute,conflicts:A.conflicts,mergeTags:A.scripts.merge===!1?null:A.scripts.mergeTags,baseURI:a.ownerDocument&&a.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:A.children,stats:h});return delete M.recoveryLinks,M}function Jo({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:r,options:a,identity:l,childrenOnly:i,isDocument:u}){let A=io(a,[e,o,t,n].filter(Boolean));if(A.ignored(e))return{report:Xo(),loads:[]};let N=e.ownerDocument,h=A.scripts.execute?hs(e,A.ignored,N.baseURI):null,M=Mn(),L=A.hooks.beforeNodeMorphed===hn&&A.hooks.afterNodeMorphed===hn,R={identity:{base:Zn(l.base,o||t),local:Zn(l.local,t),remote:Zn(l.remote,n)},authored:{base:Qn(l.base),local:Qn(l.local),remote:Qn(l.remote)},ignored:A.ignored,remoteWins:A.remoteWins,ignoreAttribute:A.ignoreAttribute,conflicts:A.conflicts,mergeTags:A.scripts.merge===!1?null:A.scripts.mergeTags,baseURI:N.baseURI,localIsBase:!o,childrenOnly:i,skipUnchanged:L},F=A.fastPath&&u&&!i&&L&&o===t,k=null,d=null;if(F){let ae=Bs({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:r,o:A,identity:R.identity,baseURI:N.baseURI});R.comparisons=ae.comparisons||ae.scope,ae.bail?d=ae.bail:(k=No(o,t,n,Object.assign({},R,{stats:M,scope:ae.scope})),k||(d="chain-unpaired",M=Mn()))}k||(k=No(o||t,t,n,Object.assign({},R,{stats:M}))),F&&(M.fastPathAttempted=1,M.fastPathTaken=d?0:1,M.fastPathFallback=d),k.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(ae=>A.hooks[ae]!==hn)&&As(k.conflicts,k.recoveryLinks,r),A.beforeApply&&A.beforeApply(k.doc);let w=globalThis.__hyperMorphProfile,Z=w?performance.now():0,he=Es(e,k.root,k,{toLive:r,ignored:A.ignored,ignoreAttribute:A.ignoreAttribute,formState:A.formState,protectFocusedValue:A.protectFocusedValue,restoreFocus:A.restoreFocus,preserve:A.head.preserve,hooks:A.hooks,childrenOnly:i,keepLiveOnly:A.keepLiveOnly});w&&(w.apply=(w.apply||0)+(performance.now()-Z));let xe=[];if(A.head.awaitLoads)for(let ae of he.applied){if(ae.kind!=="insert"||ae.node.nodeType!==1)continue;let te=ae.node;te.tagName==="LINK"&&/\bstylesheet\b/i.test(te.getAttribute("rel")||"")&&te.getAttribute("href")&&te.closest("head")&&xe.push(new Promise(ye=>{te.addEventListener("load",()=>ye()),te.addEventListener("error",()=>ye())}))}let ee=null,oe=null;if(h){let ae=ps(e,h,{ignored:A.ignored,skip:he.mergedScriptsLive,baseURI:N.baseURI,beforeNodeAdded:A.hooks.beforeNodeAdded,afterNodeAdded:A.hooks.afterNodeAdded,trackRecovery:!!k.recoveryLinks});xe.push(...ae.loads),ee=ae.swapped,oe=ae.vetoed}let re=ae=>ee&&ee.get(ae)||ae,ne=ae=>{if(he.keptRuns.has(ae))return he.runOf.get(ae);let te=he.liveOf.get(ae)||he.heldBy.get(ae)||he.insertedLive.get(ae);return te?re(te):null},K=ae=>{let te=ae&&he.liveOf.get(ae);return te?re(te):null},D=ae=>{let te=ae&&ne(ae);return Array.isArray(te)?te[0]:te};if(k.recoveryLinks){let ae=(te,V,ye)=>(V.namespaceURI?te.getAttributeNS(V.namespaceURI,V.localName):te.getAttribute(V.qualifiedName))===ye;Os(k.conflicts,k.recoveryLinks,{lookup:ne,vetoed:he.vetoed,vetoedAttrs:he.vetoedAttrs,removedVetoes:he.removedVetoes,vetoedLive:oe,liveAttr:ae,ignored:A.ignored,liveRoot:e})}return{report:{applied:he.applied,decisions:k.decisions.map(ae=>Object.assign({},ae,{node:ae.node?K(ae.node):null,el:ae.el?K(ae.el):null,applied:!!(ae.node?K(ae.node):ae.el&&K(ae.el))})),conflicts:k.conflicts.map(ae=>Object.assign({},ae,{node:ae.node?ae.kind==="text"&&ae.recovery.subject.nodeType===8?D(ae.node):K(ae.node):ae.node,el:ae.el?ae.kind==="structure"?D(ae.el):K(ae.el):ae.el})),localDiverged:k.localDiverged,identities:he.identities,moved:he.moved,replaced:he.replaced,stats:M},loads:xe}}var Ks=new WeakMap;function Xo(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Mn()}}function Xn(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let n=Ks.get(t);n||(n=uo(t),Ks.set(t,n));let r=n("remote",o.remote),a=typeof o.base=="string"&&o.base===""?null:o.base,l=a?n("base",a):null,i=o.local?o.local.root:t.documentElement,u=o.local?o.local.toLive:h=>h;Qo(t,r);let{report:A,loads:N}=Jo({liveRoot:t.documentElement,baseRoot:l?l.documentElement:null,localRoot:i,remoteRoot:r.documentElement,toLive:u,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(N).then(()=>A)}function zs(e,o,t={}){return Xn(Object.assign({},t,{live:e,base:null,remote:o}))}function Ws(e,o){if(e==null)return{root:o.createElement("template"),first:null};if(typeof e=="string"){let n=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(n){let a=fo(e,o),l=n[1].toLowerCase()==="html"?a.documentElement:a.body;return{root:l,first:l}}let r=o.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let n=o.createElement("template"),r=e.isConnected;return n.content.appendChild(r?o.importNode(e,!0):e),{root:n,first:e}}if(e.nodeType===11){let n=o.createElement("template");return n.content.appendChild(e),{root:n,first:n.content.firstElementChild}}let t=o.createElement("template");for(let n of Array.from(e))t.content.appendChild(n.parentNode?o.importNode(n,!0):n);return{root:t,first:t.content.firstElementChild}}function vo(e,o,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let n=e.ownerDocument,{base:r,...a}=t,l=!!a.children;if(io(a,[e]).ignored(e))return Promise.resolve(Xo());let i=Ws(o,n),u=r!=null?Ws(r,n):null,A,N=null;if(l)A=i.root,N=u?u.root:null;else{if(A=i.first,N=u?u.first:null,!A){let L=io(a);return L.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),L.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Mn()})}if(A.tagName!==e.tagName){let L=io(a,[e,A]);if(L.hooks.beforeNodeMorphed(e,A)===!1)return Promise.resolve(Xo());let R=Jo({liveRoot:e,baseRoot:N&&N.tagName===e.tagName?N:null,localRoot:e,remoteRoot:A,toLive:k=>k,options:a,identity:a.identity||{},childrenOnly:!0,isDocument:!1}),F=en(A)?no(A,n):n.importNode(A,!1);if(!en(F))for(;e.firstChild;)F.appendChild(e.firstChild);return L.hooks.beforeNodeAdded(F)===!1?(To(R.report.conflicts,e,e),Promise.resolve(R.report)):L.hooks.beforeNodeRemoved(e)===!1?(To(R.report.conflicts,e,e),Promise.resolve(R.report)):(e.replaceWith(F),To(R.report.conflicts,e,F),L.hooks.afterNodeRemoved(e),L.hooks.afterNodeAdded(F),L.hooks.afterNodeMorphed(e,A),R.report.replaced.push(F),R.report.applied.push({kind:"insert",node:F,parent:F.parentNode},{kind:"remove",node:e,parent:F.parentNode}),Promise.all(R.loads).then(()=>R.report))}}let{report:h,loads:M}=Jo({liveRoot:e,baseRoot:N,localRoot:e,remoteRoot:A,toLive:L=>L,options:a,identity:a.identity||{},childrenOnly:l,isDocument:!1});return Promise.all(M).then(()=>h)}var ti={mergeDocument:Xn,morphDocument:zs,morphElement:vo,merge3:Fs,morph:Ao};return Qs(ni);})();
1
+ var HyperMorph=(()=>{var ns=Object.defineProperty;var oi=Object.getOwnPropertyDescriptor;var si=Object.getOwnPropertyNames;var ri=Object.prototype.hasOwnProperty;var ii=(e,o)=>{for(var t in o)ns(e,t,{get:o[t],enumerable:!0})},li=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of si(o))!ri.call(e,s)&&s!==t&&ns(e,s,{get:()=>o[s],enumerable:!(n=oi(o,s))||n.enumerable});return e};var ai=e=>li(ns({},"__esModule",{value:!0}),e);var Ml={};ii(Ml,{createIdentityStore:()=>Us,createParseCache:()=>Do,default:()=>Al,diff:()=>_n,findChangedRoots:()=>Gr,importMap:()=>jo,merge3:()=>ei,merge3Text:()=>ro,mergeDocument:()=>go,mergeJson:()=>As,mergeScriptText:()=>Go,morph:()=>Qo,morphDocument:()=>ti,morphElement:()=>Zo,parseJsonRelaxed:()=>zo,parseRulesRelaxed:()=>yr,spliceProtected:()=>Yr,tieredIdentity:()=>rs});function Bo(e,o){if(typeof e=="string"){let t=o&&o.defaultView,n=t&&t.DOMParser||globalThis.DOMParser;return new n().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Do(e){let o=new Map;return(t,n)=>{if(typeof n!="string")return Bo(n,e);let s=o.get(t);if(s&&s.text===n)return s.doc;let d=Bo(n,e);return o.set(t,{text:n,doc:d}),d}}function js(e,o){let t=o.doctype;if(!t)return!1;let n=e.doctype;if(n&&n.name===t.name&&n.publicId===t.publicId&&n.systemId===t.systemId)return!1;let s=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return n?e.replaceChild(s,n):e.insertBefore(s,e.documentElement),!0}var os=()=>!1;function ss(e,o=[]){if(typeof e!="function")return os;let t=new WeakMap,n=new Set(o);return s=>{if(!s||s.nodeType!==1)return!1;let d=t.get(s);if(d!==void 0)return d;let i=[],r=s,l=!1;for(;r&&r.nodeType===1;){let u=t.get(r);if(u!==void 0){l=u;break}if(i.push(r),e(r,n.has(r))){l=!0;break}if(n.has(r))break;r=r.parentElement}for(let u of i)t.set(u,l);return l}}var Cl=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 Fn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Us(e){let o=new WeakMap,t=0,n=r=>o.get(r)||null,s=r=>{let l=o.get(r);return l||(l=`${e}:${++t}`,o.set(r,l)),l};return{idOf:n,ensure:s,adopt:(r,l)=>{r&&typeof l=="string"&&l&&o.set(r,l)},exportMap:(r,l)=>{let u={},b=[],a=[],h=(p,v)=>{let O=l(p);O&&(u[v]=s(O));let m=p.children;b.push(m.length),a.push(p.tagName.toLowerCase());for(let c=0;c<m.length;c++)h(m[c],v===""?String(c):`${v}.${c}`)};return h(r,""),u["~"]=b.join(","),u["^"]=a.join(","),u}}}function jo(e,o){let t=new WeakMap;if(!e||!o||typeof o!="object"||Array.isArray(o))return t;let n=o["~"],s=typeof n=="string"?n.split(",").map(Number):null,d=s&&typeof o["^"]=="string"?o["^"].split(","):null,i=a=>Number.isInteger(a)&&a>=0,r=0,l=!1,u=a=>{let h=a;for(;h>0;){let p=s[r++];if(r>s.length||!i(p))return!1;h+=p-1}return!0},b=(a,h)=>{if(l)return;if(s){let O=r++,m=s[O];if(O>=s.length||!i(m)){l=!0;return}let c=!d||d[O]===a.tagName.toLowerCase();if(!c||m!==a.children.length){let g=c&&o[h];typeof g=="string"&&g&&t.set(a,g),u(m)||(l=!0);return}}let p=o[h];typeof p=="string"&&p&&t.set(a,p);let v=a.children;for(let O=0;O<v.length;O++)b(v[O],h===""?String(O):`${h}.${O}`)};return b(e,""),t}function rs(e){return o=>{for(let t of e){let n=t(o);if(typeof n=="string"&&n!=="")return n}return null}}var kn=rs([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Uo(e,o,t,n=null,s=null){let d=new Map,i=new Set,r=l=>{if(t(l))return;let u=o(l);u&&(d.has(u)?i.add(u):d.set(u,l))};if(n){let l=u=>{for(let b of u.querySelectorAll(n))r(b);for(let b of u.querySelectorAll("template"))b.content&&l(b.content)};r(e),l(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let l=u=>{r(u);let b=u.tagName==="TEMPLATE"&&u.content?u.content.children:u.children;for(let a=0;a<b.length;a++)l(b[a])};l(e)}for(let l of i)d.delete(l),s&&s.add(l),is(l);return d}function is(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var ci=new Set(["href","src","name","type","role"]),Hs=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function oo(e,o=5381){let t=o;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return t>>>0}function Vs(e){return e.replace(/\s+/g," ")}var fi=0;function Ws({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,s=new WeakMap;function d(A){let E=A.attributes,S=E.length;if(S===0)return{all:"",sig:A.tagName+"|"};let N=[],C="",j=[];for(let D=0;D<S;D++){let B=E[D],w=B.name;o(A,w)||N.push(w+"="+B.value),w==="class"?C=B.value.indexOf(" ")<0?B.value:B.value.split(/\s+/).filter(Boolean).sort().join(" "):ci.has(w)&&j.push(w+"="+B.value)}return N.length>1&&N.sort(),j.length>1&&j.sort(),{all:N.join(""),sig:A.tagName+"|"+C+(j.length?"|"+j.join("|"):"")}}function i(A){return A.nodeType===1&&A.tagName==="TEMPLATE"&&A.content?A.content.childNodes:A.childNodes}function r(A){let E=n.get(A);if(E)return E;if(A.nodeType===3)E={hash:"T"+oo(A.nodeValue),hint:Vs(A.nodeValue).slice(0,64),sig:null,tok:null};else if(A.nodeType===8)E={hash:"C"+oo(A.nodeValue),hint:"",sig:null,tok:null};else if(A.nodeType===1){let S=d(A),N=oo(A.tagName+""+S.all),C="";for(let j of u(A))if(j.nodeType===1){let D=r(j);N=oo(D.hash,N),C.length<64&&(C+=" "+D.hint)}else N=oo(b(j),N),j.kind==="text"&&C.length<64&&(C+=j.value.slice(0,64));E={hash:"E"+N,hint:Vs(C).trim().slice(0,64),sig:S.sig,tok:null}}else E={hash:"N"+A.nodeType,hint:"",sig:null,tok:null};return n.set(A,E),E}function l(A){if(!A.tok){A.tok=new Set;for(let E of A.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))E&&A.tok.add(E)}return A.tok}function u(A){let E=s.get(A);if(E)return E;E=[];let S=null,N=()=>{S&&(S.value=S.nodes.map(C=>C.nodeValue).join(""),E.push(S),S=null)};for(let C of i(A)){if(C.nodeType===3){S||(S={kind:"text",nodes:[],value:"",parent:A,hash:void 0}),S.nodes.push(C);continue}N(),C.nodeType===8?E.push({kind:"comment",nodes:[C],value:C.nodeValue,parent:A,hash:void 0}):C.nodeType===1&&!e(C)&&E.push(C)}return N(),s.set(A,E),E}function b(A){return A.nodeType===1?r(A).hash:(A.hash===void 0&&(A.hash=(A.kind==="text"?"T":"C")+oo(A.value)),A.hash)}function a(A,E){let S=l(r(A)),N=l(r(E));if(S.size===0&&N.size===0)return{coef:1,share:1};if(S.size===0||N.size===0)return null;let C=0;for(let j of S)N.has(j)&&C++;return{coef:C/Math.min(S.size,N.size),share:C/Math.max(S.size,N.size)}}function h(A,E){let S=a(A,E);return!!S&&S.coef>=.5}let p=new WeakMap;function v(A){let E=p.get(A);if(E)return E;E=[];for(let S of A.attributes)o(A,S.name)||E.push([S.namespaceURI||"",S.localName,S.value]);return E.sort((S,N)=>S[0]<N[0]?-1:S[0]>N[0]?1:S[1]<N[1]?-1:S[1]>N[1]?1:0),p.set(A,E),E}let O=new WeakMap;function m(A,E){if(A===E)return!0;if(b(A)!==b(E))return!1;let S=O.get(A);if(S&&S.has(E))return S.get(E);let N=O.get(E);if(N&&N.has(A))return N.get(A);let C=c(A,E),j=C===!0;return C===!1&&t&&t.hashRejected++,S||O.set(A,S=new WeakMap),S.set(E,j),j}function c(A,E){if(A.nodeType===1){if(E.nodeType!==1||A.tagName!==E.tagName||A.namespaceURI!==E.namespaceURI)return!1;let S=v(A),N=v(E);if(S.length!==N.length)return!1;for(let D=0;D<S.length;D++)if(S[D][0]!==N[D][0]||S[D][1]!==N[D][1]||S[D][2]!==N[D][2])return!1;let C=u(A),j=u(E);if(C.length!==j.length)return!1;for(let D=0;D<C.length;D++){if(b(C[D])!==b(j[D]))return!1;if(!m(C[D],j[D]))return fi}return!0}return E.nodeType===1?!1:A.kind===E.kind&&A.value===E.value}let g=new WeakMap,P=new Map,T=0;function x(A){let E=g.get(A);if(E)return E;let S=b(A),N=P.get(S);N||P.set(S,N=[]);let C=N.find(j=>m(j.unit,A));return E=C?C.key:"K"+T++,C||N.push({unit:A,key:E}),g.set(A,E),E}return{meta:r,unitsOf:u,unitHash:b,similar:h,score:a,childrenOf:i,equalUnits:m,exactUnitKey:x,ignored:e}}var Ks=16,ui=2e3,di=3,ls={align:0,certifyVisited:0,certifyScheduled:0};function as(e,o,t){let{meta:n,unitsOf:s,unitHash:d,similar:i,score:r,childrenOf:l,equalUnits:u,ignored:b}=t.analyzer,a=t.baseId||(()=>null),h=t.sideId||(()=>null),p=t.baseKey||(()=>null),v=t.sideKey||(()=>null),O=t.baseDropped||new Set,m=t.sideDropped||new Set,c=t.stats||null,g=c?new Set:null,P=c?new Set:null,T=new Map,x=new Map,A=new Set,E=new Map,S=new Set,N=new Set,C=new Set,j=[],D=[],B=[],w=[],y=ui,$=new Map,U=new Map,V=(H,X)=>{T.set(H,X),x.set(X,H)},Ne=new Set,Ae=new Set,De=null,oe=H=>{let X=H.nodeType?H.parentNode:H.parent;if(!X||X.nodeType!==11)return X;if(!De){De=new WeakMap;let de=pe=>{for(let se of pe.querySelectorAll("template"))se.content&&(De.set(se.content,se),de(se.content))};for(let pe of[e,o])de(pe.tagName==="TEMPLATE"&&pe.content?pe.content:pe)}return De.get(X)||null},xe=(H,X)=>{for(let de=oe(H);de&&!Ne.has(de);de=oe(de))Ne.add(de);for(let de=oe(X);de&&!Ae.has(de);de=oe(de))Ae.add(de)},$e=H=>{for(let X=oe(H);X;X=oe(X))if(T.has(X))return N.has(X);return!1},ae=H=>{for(let X=oe(H);X;X=oe(X)){let de=x.get(X);if(de!==void 0)return N.has(de)}return!1},k=H=>!!H&&H.nodeType===1,_=(H,X)=>{let de=E.get(H);return!!de&&de.has(X)},re=H=>Hs.has(H.tagName),Z=t.comparisons||t.scope,Be=(H,X)=>{if(Z){if(Z.same.get(H)===X)return!0;if(Z.differ.get(H)===X)return!1}if(!H.isEqualNode(X))return!1;if(H.tagName==="TEMPLATE")return u(H,X);let de=H.getElementsByTagName("template");if(de.length===0)return!0;let pe=X.getElementsByTagName("template");if(de.length!==pe.length)return!1;for(let se=0;se<de.length;se++)if(!u(de[se],pe[se]))return!1;return!0},Ke=(H,X)=>{let de=a(H);if(!de)return!0;let pe=h(X);return!pe||de===pe},Te=H=>{let X=p(H);return X&&t.baseIndex.get(X)===H&&!m.has(X)?X:null},it=H=>{let X=v(H);return X&&t.sideIndex.get(X)===H&&!O.has(X)?X:null},et=(H,X)=>{let de=Te(H);if(!de)return!0;let pe=it(X);return!pe||de===pe},mt=globalThis.__hyperMorphProfile,Ze=mt?performance.now():0;mt&&!t.scope&&(n(e),n(o),mt.meta=(mt.meta||0)+(performance.now()-Ze),Ze=performance.now()),V(e,o);let ft=new Set;for(let[H,X]of t.baseIndex){let de=t.sideIndex.get(H);de&&de.tagName===X.tagName&&!T.has(X)&&!x.has(de)&&(V(X,de),xe(X,de),ft.add(X))}if(ft.size){let H=[];if(t.scope)for(let se of t.scope.chain)ft.has(se)&&H.push(se);let X=[t.scope?t.scope.root:e];for(;X.length;){let se=X.pop();ft.has(se)&&H.push(se);let ke=l(se);for(let fe=ke.length-1;fe>=0;fe--)ke[fe].nodeType===1&&X.push(ke[fe])}let de=new Set;for(let se=H.length-1;se>=0;se--){let ke=H[se];t.scope&&t.scope.onChain.has(ke)?de.add(ke):ce(ke,T.get(ke),de)?(N.add(ke),C.add(ke),c&&c.certificationPairs++):de.add(ke)}let pe=new Set;for(let se of H)N.has(se)&&!pe.has(se)&&Ct(se,pe)}t.scope&&t.scope.head&&Le(t.scope.head[0],t.scope.head[1]);function Ct(H,X){let de=[H];for(;de.length;){let pe=de.pop();if(!X.has(pe)){X.add(pe),z(pe);for(let se of s(pe))k(se)&&T.has(se)&&de.push(se)}}}w.push([e,o]);for(let[H,X]of T)k(H)&&H!==e&&w.push([H,X]);return jt(),Dt(),mt&&(mt.align=(mt.align||0)+(performance.now()-Ze)),{map:T,reverse:x,moved:S,identical:N,pairIdenticalChildren:z,weak:A,unpair:Tt,rematch:Dt,insertedByHash:Rt,refused:P,identityPaired:ft};function Dt(){be(),jt();for(let H=0;H<B.length;){let X=B.length;Lt(H,X),H=X,jt(),be(),jt()}}function Tt(H){let X=T.get(H);if(!X)return;E.has(H)||E.set(H,new Set),E.get(H).add(X);let de=(se,ke)=>{T.delete(se),x.delete(ke),S.delete(se),N.delete(se),A.delete(se),C.delete(se)},pe=(se,ke)=>{for(let fe of s(se)){let G=T.get(fe);!G||ft.has(fe)||!(k(G)?ke.contains(G):ke.contains(G.nodes[0]))||(de(fe,G),k(fe)&&pe(fe,G))}};de(H,X),k(H)&&pe(H,X),j.push(H),D.push(X)}function Rt(){let H=new Map;for(let X of new Set(D)){if(x.has(X))continue;let de=n(X).hash;H.has(de)||H.set(de,[]),H.get(de).push(X)}return H}function jt(){for(;w.length;){let[H,X]=w.shift();T.get(H)!==X||C.has(H)||N.has(H)||un(H,X)}}function qt(H,X){if(!re(H))for(let de of s(H))k(de)&&(X.push(de),qt(de,X))}function un(H,X){C.add(H);let de=s(H),pe=s(X);ls.align+=de.length+pe.length,$=new Map,U=new Map;for(let ue=0;ue<de.length;ue++)$.set(de[ue],ue);for(let ue=0;ue<pe.length;ue++)U.set(pe[ue],ue);if(H.tagName==="HTML")for(let ue of["HEAD","BODY"]){let Ie=de.find(He=>k(He)&&He.tagName===ue),Pe=pe.find(He=>k(He)&&He.tagName===ue);Ie&&Pe&&!T.has(Ie)&&!x.has(Pe)&&V(Ie,Pe)}for(let ue=0;ue<de.length&&ue<pe.length;ue++){let Ie=de[ue],Pe=pe[ue];T.has(Ie)||x.has(Pe)||(k(Ie)?k(Pe)&&Ie.tagName===Pe.tagName&&Be(Ie,Pe)&&Le(Ie,Pe):!k(Pe)&&Ie.kind===Pe.kind&&Ie.value===Pe.value&&Le(Ie,Pe))}Ce(de,pe);let se=de.filter(ue=>!T.has(ue)),ke=pe.filter(ue=>!x.has(ue));se.length&&ke.length&&(F(se,ke),J(se,ke),ne(se,ke,de,pe),Oe(de,pe));let fe=!1,G=!1;for(let ue of de){if(!T.has(ue)){k(ue)&&(j.push(ue),qt(ue,j),fe=!0);continue}k(ue)&&!N.has(ue)&&w.push([ue,T.get(ue)])}for(let ue of pe)!x.has(ue)&&k(ue)&&(D.push(ue),qt(ue,D),G=!0);fe&&G&&B.push([H,X])}function Lt(H,X){for(let de=H;de<X;de++){let[pe,se]=B[de];if(T.get(pe)!==se)continue;let ke=s(pe),fe=s(se),G=new Map,ue=new Map,Ie=null;for(let Pe of ke)k(Pe)&&(T.has(Pe)?Ie=Pe:(G.has(Ie)||G.set(Ie,[]),G.get(Ie).push(Pe)));Ie=null;for(let Pe of fe)k(Pe)&&(x.has(Pe)?Ie=x.get(Pe):(ue.has(Ie)||ue.set(Ie,[]),ue.get(Ie).push(Pe)));for(let[Pe,He]of G){let Se=ue.get(Pe);if(!(!Se||He.length!==Se.length)&&He.every((Je,nt)=>Se[nt].tagName===Je.tagName&&Ke(Je,Se[nt])&&!_(Je,Se[nt])))for(let Je=0;Je<He.length;Je++)Jt(He[Je],Se[Je])}}}function Jt(H,X){V(H,X),A.add(H),w.push([H,X]),jt()}function F(H,X){let de=so(H,d),pe=so(X,d),se=new Map;for(let ke of X){let fe=d(ke);pe.get(fe)===1&&se.set(fe,ke)}for(let ke of H){if(T.has(ke))continue;let fe=d(ke);if(de.get(fe)!==1)continue;let G=se.get(fe);G&&!x.has(G)&&u(ke,G)&&Le(ke,G)}}function ce(H,X,de){let pe=[[H,X]];for(;pe.length;){let[se,ke]=pe.pop();if(ls.certifyVisited++,c&&c.certificationVisited++,se.nodeType!==ke.nodeType)return!1;if(se.nodeType===3||se.nodeType===8){if(se.nodeValue!==ke.nodeValue)return!1;continue}if(se.nodeType!==1){if(!se.isEqualNode(ke))return!1;continue}if(se.tagName!==ke.tagName||se.namespaceURI!==ke.namespaceURI||b(se)!==b(ke))return!1;let fe=se.attributes,G=ke.attributes;if(fe.length!==G.length)return!1;for(let Se=0;Se<fe.length;Se++){let Je=fe[Se];if(ke.getAttributeNS(Je.namespaceURI,Je.localName)!==Je.value)return!1}let ue=T.get(se);if(ue!==void 0&&ue!==ke)return!1;let Ie=x.get(ke);if(Ie!==void 0&&Ie!==se)return!1;if(se!==H){if(N.has(se))continue;if(de.has(se))return!1}let Pe=l(se),He=l(ke);if(Pe.length!==He.length)return!1;ls.certifyScheduled+=Pe.length;for(let Se=Pe.length-1;Se>=0;Se--)pe.push([Pe[Se],He[Se]])}return!0}function ge(H,X){return!k(H)||!(Ne.has(H)||Ae.has(X))?!0:!!M(H,X)||!(Te(H)||it(X))}function Le(H,X){if(k(H)&&(Ne.has(H)||Ae.has(X))){let de=M(H,X);if(!de){if(Te(H)||it(X))return;V(H,X),w.push([H,X]);return}for(let pe=0;pe<de.length;pe+=2){let se=de[pe],ke=de[pe+1],fe=T.get(se);fe!==void 0&&fe!==ke&&Me(se,fe);let G=x.get(ke);G!==void 0&&G!==se&&Me(G,ke),T.get(se)===ke&&(S.delete(se),A.delete(se),N.add(se),C.add(se))}}R(H,X)}function Me(H,X){T.delete(H),x.delete(X),S.delete(H),N.delete(H),A.delete(H),C.delete(H)}function M(H,X){let de=[H,X,!1],pe=[];for(;de.length;){let se=de.pop(),ke=de.pop(),fe=de.pop(),G=T.get(fe),ue=x.get(ke);if(fe!==H&&(G!==void 0&&G!==ke&&ft.has(fe)||ue!==void 0&&ue!==fe&&ft.has(ue)))return null;if(!(G===ke&&N.has(fe))&&((G!==void 0||ue!==void 0)&&pe.push(fe,ke),!!k(fe))){if(se||G!==void 0&&G!==ke||ue!==void 0&&ue!==fe){let Ie=s(fe),Pe=s(ke);for(let He=0;He<Ie.length&&He<Pe.length;He++)de.push(Ie[He],Pe[He],!0)}else if(Ne.has(fe)||Ae.has(ke)){let Ie=fe.tagName==="TEMPLATE"?fe.content:fe,Pe=ke.tagName==="TEMPLATE"?ke.content:ke;for(let He=Ie.firstElementChild,Se=Pe.firstElementChild;He&&Se;){if(b(He)){He=He.nextElementSibling;continue}if(b(Se)){Se=Se.nextElementSibling;continue}(T.has(He)||x.has(Se)||Ne.has(He)||Ae.has(Se))&&de.push(He,Se,!1),He=He.nextElementSibling,Se=Se.nextElementSibling}}}}return pe}function R(H,X){V(H,X),N.add(H),k(H)&&C.add(H)}function z(H){let X=T.get(H);if(!X||!k(H))return;let de=s(H),pe=s(X);for(let se=0;se<de.length&&se<pe.length;se++)T.has(de[se])||R(de[se],pe[se])}function J(H,X){let de=fe=>k(fe)&&!re(fe)?n(fe).sig+""+n(fe).hint:null,pe=so(H,de),se=so(X,de),ke=new Map;for(let fe of X){let G=de(fe);G!=null&&se.get(G)===1&&ke.set(G,fe)}for(let fe of H){if(T.has(fe))continue;let G=de(fe);if(G==null||pe.get(G)!==1)continue;let ue=ke.get(G);ue&&!x.has(ue)&&Ke(fe,ue)&&V(fe,ue)}}function ne(H,X,de,pe){let se=new Map;for(let fe of X){if(!k(fe)||x.has(fe)||re(fe))continue;let G=n(fe).sig;se.has(G)||se.set(G,[]),se.get(G).push({el:fe,index:U.get(fe)})}let ke=[];for(let fe of H){if(T.has(fe)||!k(fe)||re(fe))continue;let G=se.get(n(fe).sig);if(!G||!G.length)continue;let ue=$.get(fe),Ie=G.filter(Pe=>!x.has(Pe.el)).map(Pe=>({c:Pe,d:Math.abs(Pe.index-ue)}));Ie.sort((Pe,He)=>Pe.d-He.d),Ie.length>Ks&&(Ie=Ie.slice(0,Ks));for(let{c:Pe,d:He}of Ie){if(!Ke(fe,Pe.el))continue;let Se=r(fe,Pe.el);Se&&Se.coef>=.5&&ke.push({b:fe,s:Pe.el,coef:Se.coef,share:Se.share,d:He,bi:ue})}}if(ke.sort((fe,G)=>G.coef-fe.coef||G.share-fe.share||fe.d-G.d||fe.bi-G.bi),c&&ke.length>1){let fe=new Map;for(let G of ke){let ue=fe.get(G.b);ue?ue.coef===G.coef&&(ue.share===G.share?ue.strict++:ue.loose++):fe.set(G.b,{coef:G.coef,share:G.share,strict:0,loose:0})}for(let[G,ue]of fe)g.has(G)||!(ue.strict||ue.loose)||(g.add(G),ue.strict?c.similarTiesStrict++:c.similarTiesLoose++)}for(let fe of ke)!T.has(fe.b)&&!x.has(fe.s)&&V(fe.b,fe.s)}function je(H,X){return k(H)!==k(X)?!1:k(H)?H.tagName!==X.tagName||!Ke(H,X)?!1:re(H)||n(H).hint===""||n(X).hint===""?!0:i(H,X):H.kind===X.kind}function Q(H,X){let de=(se,ke)=>{let fe=ke===null?-1:se===X?U.get(ke):$.get(ke),G=se[fe+1];return G&&!k(G)?G:null},pe=null;for(let se of H){if(k(se)){pe=se;continue}if(T.has(se))continue;let ke=pe===null?null:T.get(pe);if(pe!==null&&!ke)continue;let fe=de(X,ke);fe&&!x.has(fe)&&fe.kind===se.kind&&V(se,fe)}}function Oe(H,X){Q(H,X);let de=Ve(H,X),pe=(ke,fe)=>k(ke)&&n(ke).hint!==""&&n(fe).hint===""&&!!fe.querySelector("br")&&!de(ke,fe),se=0;for(let ke of H){if(T.has(ke)){let G=U.get(T.get(ke));G!==void 0&&G>=se&&(se=G+1);continue}let fe=0;for(let G=se;G<X.length&&fe<di;G++){let ue=X[G];if(!x.has(ue)&&(fe++,je(ke,ue)&&!_(ke,ue)&&!pe(ke,ue))){V(ke,ue),k(ke)&&(n(ke).hint===""||n(ue).hint==="")&&A.add(ke),se=G+1;break}}}Ce(H,X)}function Ve(H,X){let de=(pe,se,ke)=>{for(let fe=se-1;fe>=0;fe--)if(k(pe[fe])&&ke(pe[fe]))return pe[fe];return null};return(pe,se)=>{let ke=$.get(pe),fe=U.get(se);if(ke===fe)return!0;let G=de(H,ke,Ie=>T.has(Ie)),ue=de(X,fe,Ie=>x.has(Ie));return G?T.get(G)===ue:!ue}}function Ce(H,X){let de=H.filter(G=>k(G)&&!T.has(G)),pe=X.filter(G=>k(G)&&!x.has(G));if(!de.length||!pe.length)return;let se=so(de,G=>G.tagName),ke=so(pe,G=>G.tagName),fe=Ve(H,X);for(let G of de){let ue=G.tagName;if(se.get(ue)!==1||ke.get(ue)!==1)continue;let Ie=pe.find(Pe=>Pe.tagName===ue);Ie&&!x.has(Ie)&&fe(G,Ie)&&Ke(G,Ie)&&!_(G,Ie)&&(u(G,Ie)?Le(G,Ie):(V(G,Ie),A.add(G)))}}function be(){let H=new Map;for(let G of A)if(k(G)&&k(T.get(G))){let ue=n(G).hash;H.has(ue)||H.set(ue,[]),H.get(ue).push(G)}if(H.size)for(let G of D){if(x.has(G)||!k(G)||ae(G))continue;let ue=H.get(n(G).hash),Ie=ue&&ue.find(Pe=>A.has(Pe)&&!_(Pe,G)&&Ke(Pe,G)&&et(Pe,G)&&u(Pe,G)&&ge(Pe,G));Ie&&(Tt(Ie),Le(Ie,G),xe(Ie,G),S.add(Ie))}let X=new Map,de=new Map,pe=new Map;for(let G of A){let ue=T.get(G);k(G)&&k(ue)&&pe.set(ue,G)}let se=(G,ue)=>{if(!x.has(G))return!ae(G);let Ie=pe.get(G);return Ie===x.get(G)&&Ie!==ue&&!Ie.contains(ue)},ke=G=>{if(x.has(G)){let ue=pe.get(G);pe.delete(G),Tt(ue)}};for(let G of[...D,...pe.keys()]){if(x.has(G)&&!pe.has(G))continue;let ue=n(G).hash;if(X.has(ue)||X.set(ue,[]),X.get(ue).push(G),re(G))continue;let Ie=n(G).sig;de.has(Ie)||de.set(Ie,[]),de.get(Ie).push(G)}let fe=new Set;for(let G of A){let ue=T.get(G);!k(G)||!k(ue)||re(G)||n(G).hint===""||n(ue).hint===""||i(G,ue)||fe.add(G)}for(let G of[...j,...fe]){let ue=T.get(G);if(ue?!(A.has(G)&&fe.has(G)):$e(G))continue;let Ie=nt=>{ue&&Tt(G),ke(nt)},Pe=X.get(n(G).hash);if(Pe){let nt=Pe.find(ot=>ot!==ue&&se(ot,G)&&!_(G,ot)&&et(G,ot)&&u(G,ot)&&ge(G,ot));if(nt){Ie(nt),Le(G,nt),xe(G,nt),S.add(G);continue}}if(re(G)||y<=0)continue;let He=de.get(n(G).sig);if(!He)continue;let Se=null,Je=0;for(let nt of He)if(!(nt===ue||!se(nt,G)||!Ke(G,nt)||!et(G,nt)||_(G,nt))&&(y--<=0||i(G,nt)&&(Je++,Se=nt,Je>1)))break;Je>1&&P&&P.add(G),Je===1&&(Ie(Se),V(G,Se),xe(G,Se),S.add(G),w.push([G,Se]))}}}function so(e,o){let t=new Map;for(let n of e){let s=o(n);s!=null&&t.set(s,(t.get(s)||0)+1)}return t}var hi={diff:0},Fs=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,pi=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,mi=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,gi=/\P{M}\p{M}*/gu;function bi(e){if(e==="")return[];if(Fs){let t=[];for(let n of Fs.segment(e))t.push(n.segment);return t}let o=[];for(let t of e.match(mi))if(pi.test(t))for(let n of t.match(gi))o.push(n);else o.push(t);return o}var wi=/^[  ]+$/,yi=e=>wi.test(e)?" ".repeat(e.length):e,qn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),Nt="",cs=e=>e.every(o=>qn(o)||o.k===Nt),ki=/^[\x00-\x7f\u00A0]*$/,xi=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function vi(e){return e===""?[]:e.match(xi)}function fn(e,o=!1){return(o?vi(e):bi(e)).map(t=>({k:yi(t),raw:t,len:t.length}))}var xn=(...e)=>e.every(o=>ki.test(o));function fs(e,o,t){let n=e.length,s=o.length,d=Math.min(n+s,t),i=d+1,r=new Int32Array(2*d+3),l=[],u=n===0&&s===0;for(let p=0;p<=d&&!u;p++){l.push(r.slice(i-p,i+p+1));for(let v=-p;v<=p;v+=2){let O;v===-p||v!==p&&r[i+v-1]<r[i+v+1]?O=r[i+v+1]:O=r[i+v-1]+1;let m=O-v,c=O;for(;O<n&&m<s&&e[O].k===o[m].k;)O++,m++;if(hi.diff+=1+O-c,r[i+v]=O,O>=n&&m>=s){u=!0;break}}}if(!u)return null;let b=[],a=n,h=s;for(let p=l.length-1;p>0;p--){let v=l[p],O=a-h,m=O+p,c=O===-p||O!==p&&v[m-1]<v[m+1]?O+1:O-1,g=v[c+p],P=g-c;for(;a>g&&h>P;)b.push([0,a-1,h-1]),a--,h--;a===g?(b.push([1,a,h-1]),h--):(b.push([-1,a-1,h]),a--)}for(;a>0&&h>0;)b.push([0,a-1,h-1]),a--,h--;return b.reverse(),b}function Ti(e,o,t){let n=a=>a.k===Nt;if(!e.some(n)&&!o.some(n))return fs(e,o,t);let s=[],d=[];for(let a=0;a<e.length;a++)n(e[a])||s.push(a);for(let a=0;a<o.length;a++)n(o[a])||d.push(a);let i=fs(s.map(a=>e[a]),d.map(a=>o[a]),t);if(!i)return null;let r=[],l=0,u=0,b=(a,h)=>{for(;l<a&&u<h&&e[l].k===o[u].k;)r.push([0,l++,u++]);let p=fs(e.slice(l,a),o.slice(u,h),t);if(!p)return!1;for(let[v,O,m]of p)r.push([v,O+l,m+u]);return l=a,u=h,!0};for(let[a,h,p]of i)if(a===0){if(!b(s[h],d[p]))return null;r.push([0,l,u]),l++,u++}return b(e.length,o.length)?r:null}function Hn(e,o,t=4e3){let n=[],s=0;for(;s<e.length&&s<o.length&&e[s].k===o[s].k;)e[s].raw!==o[s].raw&&n.push({bi:s,tok:o[s]}),s++;let d=0;for(;d<e.length-s&&d<o.length-s&&e[e.length-1-d].k===o[o.length-1-d].k;)e[e.length-1-d].raw!==o[o.length-1-d].raw&&n.push({bi:e.length-1-d,tok:o[o.length-1-d]}),d++;let i=e.slice(s,e.length-d),r=o.slice(s,o.length-d),l=Ii(i,r)?null:Ti(i,r,t);if(!l){let c=i.length||r.length?[{bs:s,be:s+i.length,toks:r}]:[];return{hunks:c,cosmetic:n,coarse:!0,parts:c.map(g=>({...g,gap:[],group:0})),cosmeticEq:n}}let u=[],b=(c,g)=>{i[c].raw!==r[g].raw&&n.push({bi:s+c,tok:r[g]})},a=null,h=[],p=0,v=0,O=()=>{a&&u.push(a),a=null;for(let[c,g]of h)b(c,g);h=[],p++};for(let[c,g,P]of l){if(c===0){a&&qn(i[g])&&!i[g].k.includes(`
2
+ `)?h.push([g,P]):(O(),b(g,P)),v=g+1;continue}(!a||h.length)&&(a&&u.push(a),a={bs:s+v,be:s+v,toks:[],gap:h.map(([T,x])=>({bi:s+T,tok:r[x]})),group:p},h=[]),c===-1?(a.be=s+v+1,v=g+1):a.toks.push(r[P])}O(),Si(u,e);let m=ds(u);return{hunks:m.hunks,cosmetic:n.concat(m.cosmetic),parts:u,cosmeticEq:n}}function Si(e,o){for(let t=0;t<e.length;t++){let n=e[t];if(n.gap.length)continue;let s=t+1<e.length?e[t+1].bs:1/0;if(n.toks.length){if(n.bs===n.be)for(;n.bs+1<s&&n.bs<o.length&&n.toks[0].k===Nt&&o[n.bs].k===Nt;)n.toks=[...n.toks.slice(1),n.toks[0]],n.bs++,n.be++}else for(;n.be+1<s&&n.be<o.length&&o[n.bs].k===Nt&&o[n.be].k===Nt;)n.bs++,n.be++}}function ds(e,o=()=>!1){let t=[],n=[],s=null,d=-1;for(let i of e){let r=o(i);if(s&&!s.alone&&!r&&i.group===d){s.be=i.be;for(let l of i.gap)s.toks.push(l.tok);for(let l of i.toks)s.toks.push(l);continue}s&&t.push({bs:s.bs,be:s.be,toks:s.toks});for(let l of i.gap)n.push(l);s={bs:i.bs,be:i.be,toks:i.toks.slice(),alone:r},d=i.group}return s&&t.push({bs:s.bs,be:s.be,toks:s.toks}),{hunks:t,cosmetic:n}}var Ni=(e,o)=>e.bs===o.bs&&e.be===o.be&&ms(e.toks,o.toks);function ps(e,o,t){let n=b=>a=>b.some(h=>Ni(a,h)),s=ds(e.parts,n(o.parts)),d=ds(o.parts,n(e.parts)),i=e.cosmeticEq.concat(s.cosmetic),r=o.cosmeticEq.concat(d.cosmetic),[l,u]=t?Ai(s.hunks,d.hunks,t,i,r):[s.hunks,d.hunks];return{lh:l,rh:u,cosL:i,cosR:r}}function Ai(e,o,t,n,s){let d=(v,O)=>v.k===O.k&&v.raw===O.raw,i=[{list:e.map(v=>({...v})),resp:new Set(n.map(v=>v.bi)),raw:new Map(n.map(v=>[v.bi,v.tok]))},{list:o.map(v=>({...v})),resp:new Set(s.map(v=>v.bi)),raw:new Map(s.map(v=>[v.bi,v.tok]))}],r=v=>v.bs===v.be,l=(v,O,m,c)=>{let g=v.list[O];if(!r(g))return c(g)===m?g.toks:null;let P=O?v.list[O-1].be:0,T=O+1<v.list.length?v.list[O+1].bs:t.length;if(m<P||m>T)return null;let x=g.toks,A=g.bs;for(;A>m;){let E=x[x.length-1];if(!d(E,t[A-1])||v.resp.has(A-1))return null;x=[E,...x.slice(0,-1)],A--}for(;A<m;){if(!d(x[0],t[A])||v.resp.has(A))return null;x=[...x.slice(1),x[0]],A++}return x},u=(v,O,m,c,g,P)=>{let T=v.list[O],x=g?m.slice(m.length-c):m.slice(0,c),A=g?m.slice(0,m.length-c):m.slice(c),E={bs:P,be:P,toks:x};if(r(T)){if(!A.length){v.list[O]=E;return}let N={bs:P,be:P,toks:A};g&&(N.lead=!0),v.list.splice(O,1,...g?[N,E]:[E,N]);return}let S={bs:T.bs,be:T.be,toks:A};v.list.splice(O,1,...g?[S,E]:[E,S])},b=(v,O,m,c,g)=>{let P=v.list[O],T=g?m.slice(m.length-c):m.slice(0,c),x=g?m.slice(0,m.length-c):m.slice(c),A={bs:P.bs,be:P.be,toks:T};if(!x.length){v.list[O]=A;return}let E=g?{bs:P.bs,be:P.bs,toks:x,lead:!0}:{bs:P.be,be:P.be,toks:x};v.list.splice(O,1,...g?[E,A]:[A,E])},a=(v,O,m,c)=>{let g=v.list[O],P=m.list[c],T=g.be,x=P.bs;if(T>=x||O+1<v.list.length&&v.list[O+1].bs<=P.be||c>0&&m.list[c-1].be>=g.bs)return!1;for(let U=T;U<x;U++)if(!qn(t[U])||t[U].k.includes(`
3
+ `))return!1;let A=U=>t.slice(T,x).map((V,Ne)=>U.raw.get(T+Ne)||V),E=[...g.toks,...A(v)],S=[...A(m),...P.toks],N=(U,V,Ne)=>V>=0&&V+Ne.length<=U.length&&Ne.every((Ae,De)=>U[V+De].k===Ae.k),C=(U,V,Ne)=>cs(U)&&t.slice(V,Ne).some(Ae=>!qn(Ae)),j=U=>U.some(V=>!qn(V)),D,B,w,y;if(r(g)&&j(g.toks)&&N(S,0,g.toks)){let U=S.slice(g.toks.length);C(U,T,P.be)||(D=T,B=g.toks,w=S.slice(0,g.toks.length),y=[null,{bs:T,be:P.be,toks:U}])}if(D===void 0&&r(P)&&j(P.toks)){let U=E.length-P.toks.length,V=E.slice(0,U);N(E,U,P.toks)&&!C(V,g.bs,x)&&(D=x,B=E.slice(U),w=P.toks,y=[{bs:g.bs,be:x,toks:V},null])}if(D===void 0)return!1;let $=U=>U&&(U.bs<U.be||U.toks.length);return v.list.splice(O,1,...[y[0],{bs:D,be:D,toks:B}].filter($)),m.list.splice(c,1,...[{bs:D,be:D,toks:w},y[1]].filter($)),!0},h=i[0],p=i[1];for(let v=0;v<64;v++){let O=!1;e:for(let m=0;m<h.list.length;m++)for(let c=0;c<p.list.length;c++){let g=h.list[m],P=p.list[c];if(!(g.bs===P.bs&&g.be===P.be&&ms(g.toks,P.toks))){for(let T of[!0,!1]){let x=E=>T?E.be:E.bs,A=r(g)?[x(P),g.bs]:[x(g)];for(let E of A){let S=l(h,m,E,x),N=S&&l(p,c,E,x);if(!N)continue;let C=(y,$)=>T?y[y.length-1-$]:y[$],j=0;for(;j<S.length&&j<N.length&&C(S,j).k===C(N,j).k;)j++;if(!j)continue;let D=T?S.slice(0,S.length-j):S.slice(j),B=T?N.slice(0,N.length-j):N.slice(j);if(!(j<S.length&&j<N.length&&!cs(D)&&!cs(B)&&(r(g)&&r(P)||g.bs===P.bs&&g.be===P.be)||!(T?S.slice(S.length-j):S.slice(0,j)).some(y=>!qn(y)))){if(j===S.length&&j===N.length&&r(g)&&r(P)){if(g.bs===E&&P.bs===E)continue;h.list[m]={bs:E,be:E,toks:S},p.list[c]={bs:E,be:E,toks:N}}else!r(g)&&g.bs===P.bs&&g.be===P.be?(b(h,m,S,j,T),b(p,c,N,j,T)):(u(h,m,S,j,T,E),u(p,c,N,j,T,E));O=!0;break e}}}if(a(h,m,p,c)||a(p,c,h,m)){O=!0;break e}}}if(!O)break}return[h.list,p.list]}var Mi=48,Oi=.3;function Ii(e,o){let t=e.filter(i=>!qn(i)),n=o.filter(i=>!qn(i));if(Math.min(t.length,n.length)<Mi)return!1;let s=new Map;for(let i of t)s.set(i.k,(s.get(i.k)||0)+1);let d=0;for(let i of n){let r=s.get(i.k);r>0&&(d++,s.set(i.k,r-1))}return d/Math.min(t.length,n.length)<Oi}var Ei=(e,o)=>{let t=new Set;for(let n of e.toks)typeof n.k!="string"&&t.add(n.k.el);for(let n=e.bs;n<e.be;n++)typeof o[n].k!="string"&&t.add(o[n].k.el);return t},ms=(e,o)=>e.length===o.length&&e.every((t,n)=>t.k===o[n].k);function qs(e,o,t,n="remote"){let s=Hn(e,o),d=Hn(e,t),{lh:i,rh:r,cosL:l,cosR:u}=ps(s,d,e),b=k=>k.bs===k.be,a=k=>k.toks.some(_=>typeof _.k=="string"),h=k=>b(k)&&!a(k),p=(k,_)=>_.bs<k.be&&k.bs<_.be,v=(k,_)=>!p(k,_)&&_.bs<=k.be&&k.bs<=_.be&&(b(k)&&a(k)||b(_)&&a(_))&&!(b(k)&&b(_)),O=(k,_)=>k.bs===_.bs&&k.be===_.be&&ms(k.toks,_.toks),m=[],c=new Set;for(let k of i){let _=r.find(re=>!c.has(re)&&O(k,re));_?(c.add(_),m.push({bs:k.bs,be:k.be,side:"both",l:k,r:_,toks:k.toks})):m.push({bs:k.bs,be:k.be,side:"L",l:k,toks:k.toks,lead:!!k.lead})}for(let k of r)c.has(k)||m.push({bs:k.bs,be:k.be,side:"R",r:k,toks:k.toks,lead:!!k.lead});m.sort((k,_)=>k.bs-_.bs||k.be-_.be||_.lead-k.lead);let g=0,P=0;for(let k of m)k.side==="both"&&(g+=k.toks.length-(k.be-k.bs));let T=m.map((k,_)=>_),x=k=>T[k]===k?k:T[k]=x(T[k]),A=(k,_)=>(k=x(k),_=x(_),k===_?!1:(T[k]=_,!0)),E=m.map(k=>Ei({bs:k.bs,be:k.be,toks:k.toks},e)),S={L:new Map,R:new Map};m.forEach((k,_)=>{let re=k.side==="both"?["L","R"]:[k.side];for(let Z of re)for(let Be of E[_])S[Z].has(Be)||S[Z].set(Be,[]),S[Z].get(Be).push(_)});for(let k of[S.L,S.R])for(let _ of k.values())for(let re=1;re<_.length;re++)A(_[0],_[re]);for(let k=0;k<m.length;k++)for(let _=k+1;_<m.length;_++){let re=m[k],Z=m[_];re.side===Z.side&&re.side!=="both"||re.bs>Z.be||(p(re,Z)||v(re,Z)?A(k,_):re.bs===Z.bs&&b(re)&&b(Z)&&P++)}let N=(k,_)=>{let re=k==="L"?i:r;for(let Z of re)if(Z.toks.some(Be=>Be.kind==="close"&&Be.k.el===_.el))return Z.bs;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="close"&&e[Z].k.el===_.el)return Z;return-1};m.forEach((k,_)=>{if(!(!h(k)||k.side==="both"))for(let re of k.toks){if(re.kind!=="open")continue;let Z=N(k.side,re.k);if(Z<=k.bs)continue;let Be=new Uint8Array(Z-k.bs),Ke=[];if(m.forEach((Te,it)=>{if(!(Te.side===k.side||b(Te))&&Te.bs<Z&&Te.be>k.bs){Ke.push(it);for(let et=Math.max(Te.bs,k.bs);et<Math.min(Te.be,Z);et++)Be[et-k.bs]=1}}),Ke.length&&Be.every(Te=>Te===1))for(let Te of Ke)A(_,Te)}});let C=!0;for(;C;){C=!1;let k=new Map;m.forEach((_,re)=>{let Z=x(re),Be=k.get(Z)||{bs:_.bs,be:_.be,L:!1,R:!1};Be.bs=Math.min(Be.bs,_.bs),Be.be=Math.max(Be.be,_.be),_.side!=="R"&&(Be.L=!0),_.side!=="L"&&(Be.R=!0),k.set(Z,Be)}),m.forEach((_,re)=>{for(let[Z,Be]of k){if(x(re)===x(Z)||!(Be.L&&Be.R))continue;let Ke=_.bs<Be.be&&_.be>Be.bs,Te=b(_)&&a(_)&&(_.bs===Be.be||_.bs===Be.bs);(Ke||Te)&&A(re,Z)&&(C=!0)}})}let j=new Map;m.forEach((k,_)=>{let re=x(_);j.has(re)||j.set(re,[]),j.get(re).push(k)});let D=[];for(let k of j.values()){let _=k.some(Z=>Z.side==="L"),re=k.some(Z=>Z.side==="R");if(_&&re){let Z=Math.min(...k.map(it=>it.bs)),Be=Math.max(...k.map(it=>it.be)),Ke=k.filter(it=>it.side!=="R").map(it=>it.l).sort((it,et)=>it.bs-et.bs),Te=k.filter(it=>it.side!=="L").map(it=>it.r).sort((it,et)=>it.bs-et.bs);D.push({bs:Z,be:Be,kind:"conflict",localHunks:Ke,remoteHunks:Te})}else for(let Z of k)D.push({bs:Z.bs,be:Z.be,kind:Z.side,u:Z})}let B=(k,_)=>{let re=k==="L"?i:r;for(let Z of re)if(Z.toks.some(Be=>Be.kind==="close"&&Be.k.el===_.el))return Z.bs+.5;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="close"&&e[Z].k.el===_.el)return Z;return 1/0},w=(k,_)=>{let re=k==="L"?i:r;for(let Z of re)if(Z.toks.some(Be=>Be.kind==="open"&&Be.k.el===_.el))return Z.bs-.5;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="open"&&e[Z].k.el===_.el)return Z;return-1/0},y=k=>k.kind==="R"?"R":"L",$=k=>k.kind==="R"?1:0;D.sort((k,_)=>{if(k.bs!==_.bs)return k.bs-_.bs;let re=k.bs===k.be,Z=_.bs===_.be;if(re!==Z)return re?-1:1;if(re&&Z&&k.kind!=="conflict"&&_.kind!=="conflict"){let Ke=k.u.toks,Te=_.u.toks,it=mt=>mt.length&&mt.every(Ze=>Ze.kind==="open"),et=mt=>mt.length&&mt.every(Ze=>Ze.kind==="close");if(it(Ke)&&it(Te)){let mt=Math.max(...Ke.map(ft=>B(y(k),ft.k))),Ze=Math.max(...Te.map(ft=>B(y(_),ft.k)));if(mt!==Ze)return Ze-mt}if(et(Ke)&&et(Te)){let mt=Math.min(...Ke.map(ft=>w(y(k),ft.k))),Ze=Math.min(...Te.map(ft=>w(y(_),ft.k)));return mt!==Ze?Ze-mt:$(_)-$(k)}}let Be=Ke=>Ke.u&&Ke.u.lead?1:0;return Be(_)-Be(k)||$(k)-$(_)||k.be-_.be});let U=[],V=[],Ne=0,Ae=k=>{k>Ne&&(U.push({bs:Ne,be:k,toks:e.slice(Ne,k),source:"base"}),Ne=k)};for(let k of D){if(Ae(k.bs),k.kind==="conflict"){let _=hs(e,k.localHunks,k.bs,k.be),re=hs(e,k.remoteHunks,k.bs,k.be),Z=n==="local"?_:n==="both"?_.concat(re):re,Be=(it,et)=>{let mt=0;for(let Ze of it)Ze.be<=k.bs&&!et.includes(Ze)&&(mt+=Ze.toks.length-(Ze.be-Ze.bs));return mt},Ke=k.bs+Be(i,k.localHunks),Te=k.bs+Be(r,k.remoteHunks);V.push({bs:k.bs,be:k.be,ls:Ke,le:Ke+_.length,rs:Te,re:Te+re.length,ms:0,me:0,base:e.slice(k.bs,k.be),local:_,remote:re,resolved:Z}),U.push({bs:k.bs,be:k.be,toks:Z,source:"conflict",localHunks:k.localHunks,localToks:_,keepsLocal:n!=="remote"})}else U.push({bs:k.bs,be:k.be,toks:k.u.toks,source:k.kind==="R"?"remote":"local",localHunks:k.kind==="R"?[]:[k.u.l]});Ne=Math.max(Ne,k.be)}Ae(e.length);let De=0,oe=0;for(let k of U)k.source==="conflict"&&(V[oe].ms=De,V[oe].me=De+k.toks.length,oe++),De+=k.toks.length;let xe=new Map(l.map(k=>[k.bi,k.tok])),$e=new Map(u.map(k=>[k.bi,k.tok])),ae=[];for(let k of U){k.source==="base"&&(k.toks=k.toks.map((_,re)=>{let Z=k.bs+re,Be=xe.get(Z),Ke=$e.get(Z),Te=Be&&Ke?n==="remote"?Ke:Be:Be||Ke||_;return Te===_?_:{...Te,cosmetic:!0}}));for(let _ of k.toks)ae.push({..._,src:k.source})}return{tokens:ae,segments:U,conflicts:V,localHunks:i,remoteHunks:r,collapsedDelta:g,samePoint:P,mapLocalOffset:Ci(e,i,U)}}function hs(e,o,t,n){let s=[],d=t;for(let i of o)s=s.concat(e.slice(d,i.bs),i.toks),d=i.be;return s.concat(e.slice(d,n))}var us=e=>e.reduce((o,t)=>o+t.len,0);function Ci(e,o,t){let n=new Int32Array(e.length+1);for(let i=0;i<e.length;i++)n[i+1]=n[i]+e[i].len;let s=o.map(i=>({bs:n[i.bs],be:n[i.be],text:i.toks.map(r=>r.raw).join(""),ref:i})),d=t.map(i=>({bs:n[i.bs],be:n[i.be],len:us(i.toks),source:i.source,localHunks:i.localHunks||[],localLen:i.localToks?us(i.localToks):0,keepsLocal:i.keepsLocal,ref:i}));return i=>{let r=null,l=null,u=0,b=0,a=0;for(let p of s){let v=p.bs-a;if(i<=b+v){r=a+(i-b);break}if(b+=v,a=p.bs,i<=b+p.text.length){l=p,u=i-b,r=p.bs;break}b+=p.text.length,a=p.be}r===null&&(r=a+(i-b));let h=0;for(let p of d){if(!l&&r<=p.bs)return h;if(!(l?p.localHunks.includes(l.ref):r<p.be)){h+=p.len;continue}if(p.source==="base")return h+(r-p.bs);if(p.source==="remote")return h+p.len;if(p.source==="local")return h+Math.min(u,p.len);if(!p.keepsLocal||!l)return h+p.len;let O=p.localHunks.indexOf(l.ref),m=us(hs(e,p.localHunks.slice(0,O),p.ref.bs,l.ref.bs));return h+Math.min(m+u,p.localLen)}return h}}function ro(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:c=>Math.min(c,o.length),granularity:"word"};let s=xn(e,o,t),d=fn(e,s),i=fn(o,s),r=fn(t,s),l=d.length<=2e4&&i.length<=2e4&&r.length<=2e4?qs(d,i,r,n):null,u="word",b=d;if(!l){let c=g=>g.split(/(?<=\n)/).map(P=>({k:P,raw:P,len:P.length}));b=c(e),l=qs(b,c(o),c(t),n),u="line"}let a=c=>c.map(g=>g.raw).join(""),h=c=>{let g=[0];for(let P of c)g.push(g[g.length-1]+P.len);return g},p=h(b),v=null,O=null,m=null;if(l.conflicts.length){let c=g=>g.split(/(?<=\n)/).map(P=>({k:P,raw:P,len:P.length}));v=h(u==="line"?c(o):i),O=h(u==="line"?c(t):r),m=h(l.tokens)}return{text:a(l.tokens),conflicts:l.conflicts.map(c=>({bs:p[c.bs],be:p[c.be],ls:v[c.ls],le:v[c.le],rs:O[c.rs],re:O[c.re],ms:m[c.ms],me:m[c.me],base:a(c.base),local:a(c.local),remote:a(c.remote),resolved:a(c.resolved)})),mapLocalOffset:l.mapLocalOffset,granularity:u}}function _n(e,o,t=4e3){if(e===o)return[];let n=xn(e,o),s=fn(e,n),d=fn(o,n),i=Hn(s,d,t),r=[0];for(let l of s)r.push(r[r.length-1]+l.len);return i.hunks.map(l=>({bs:r[l.bs],be:r[l.be],text:l.toks.map(u=>u.raw).join("")}))}function Xt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Bn({base:e,side:o,retained:t,transfers:n,baseAtomKey:s=r=>r.el,sideAtomKey:d=r=>r.el,budget:i=Xt()}){let r=[],l=x=>({status:"fallback",reason:x}),u=x=>x>i.remaining?!1:(i.remaining-=x,!0);if(!u((t.length+n.length)*3))return l("work-limit");for(let[x,A]of[["retained",t],["transfer",n]])for(let E of A){let{from:S,to:N,target:C}=E;if(!Number.isInteger(S)||!Number.isInteger(N)||!Number.isInteger(C)||S<0||N<=S||N>e.text.length||C<0||C+N-S>o.text.length)return l("invalid-range");r.push({...E,kind:x})}let b=Symbol(),a=x=>(A,E)=>{if(!u(1))throw b;return i.sortComparisons++,x(A,E)},h,p;try{h=r.slice().sort(a((x,A)=>x.from-A.from||x.to-A.to)),p=r.slice().sort(a((x,A)=>x.target-A.target||x.to-x.from-(A.to-A.from)))}catch(x){if(x===b)return l("work-limit");throw x}if(!u(r.length*2))return l("work-limit");for(let x=1;x<h.length;x++)if(h[x].from<h[x-1].to)return l("source-overlap");for(let x=1;x<p.length;x++)if(p[x].target<p[x-1].target+p[x-1].to-p[x-1].from)return l("target-overlap");for(let x of h){let A=x.to-x.from;if(!u(A))return l("work-limit");for(let E=0;E<A;E++){let S=x.from+E,N=x.target+E;if(i.comparisons++,e.text[S]!==o.text[N])return l("unequal-occurrence");let C=e.atomAt.get(S),j=o.atomAt.get(N);if(!!C!=!!j||C&&s(C)!==d(j))return l("different-atom")}}let v=e.text.length+o.text.length+2,O=r.reduce((x,A)=>x+(A.to-A.from)*2,2);if(!u(v+O+r.length))return l("work-limit");let m=new Int32Array(e.text.length+1).fill(-1),c=new Int32Array(o.text.length+1).fill(-1);i.mapCells+=v,i.mapWrites+=O;let g=-1,P=!0;for(let x of h){x.target<g&&(P=!1),g=x.target+x.to-x.from;for(let A=0;A<x.to-x.from;A++)m[x.from+A]=x.target+A,c[x.target+A]=x.from+A}return m[e.text.length]=o.text.length,c[o.text.length]=e.text.length,{status:"ready",runs:h,bTo:m,toB:c,monotone:P,covers:(x,A)=>{if(!u(A-x))return null;i.coverageChecks+=A-x;for(let E=x;E<A;E++)if(e.text[E]!==Nt&&!/\s/.test(e.text[E])&&m[E]<0)return!1;return!0}}}function gs({base:e,side:o,baseOf:t=()=>null,budget:n=Xt()}){if(e.text===o.text||!e.text.includes(Nt)&&!o.text.includes(Nt))return{status:"none"};let s=(e.text.length+o.text.length)*8;if(s>n.remaining)return{status:"fallback",reason:"work-limit"};n.remaining-=s,n.boundarySteps=(n.boundarySteps||0)+s;let d=(v,O)=>O<v.length&&(v[O]===Nt||/\s/.test(v[O])),i=new Map,r=Symbol(),l=(v,O)=>{let m=v.stackAt[O]||[];if(!i.has(m)){if(m.length>n.remaining)throw r;n.remaining-=m.length,n.boundarySteps+=m.length,i.set(m,m.find(c=>c.block)?.el||null)}return i.get(m)},u=[],b=(v,O)=>{let m=l(e,v),c=l(o,O),g=m&&c&&t(c)!==m?"transfer":"retained",P=u[u.length-1];P&&P.to===v&&P.target+P.to-P.from===O&&P.kind===g&&P.destination===c?P.to++:u.push({from:v,to:v+1,target:O,destination:c,kind:g})},a=0,h=0,p=!1;try{for(;a<e.text.length||h<o.text.length;){if(a<e.text.length&&h<o.text.length&&e.text[a]===o.text[h]){let P=e.atomAt.get(a),T=o.atomAt.get(h);if(!!P!=!!T||P&&t(T.el)!==P.el)return{status:"none"};b(a++,h++);continue}if(!d(e.text,a)&&!d(o.text,h))return{status:"none"};let v=a,O=h;for(;d(e.text,a);)a++;for(;d(o.text,h);)h++;let m=e.text.slice(v,a),c=o.text.slice(O,h);(m.includes(Nt)||c.includes(Nt))&&(p=!0);let g=0;for(;g<a-v&&g<h-O&&e.text[a-g-1]===o.text[h-g-1];)g++;for(let P=g;P>0;P--)b(a-P,h-P)}}catch(v){if(v===r)return{status:"fallback",reason:"work-limit"};throw v}return p?Bn({base:e,side:o,retained:u.filter(v=>v.kind==="retained"),transfers:u.filter(v=>v.kind==="transfer"),sideAtomKey:v=>t(v.el)||v.el,budget:n}):{status:"none"}}var _s=/\s/,Vo=/\S/;function En(e,o,t,n,s,d,i=-1,r=-1){if(!e.length)return-1;s(n,e.length);let l=new Int32Array(e.length),u=0;for(let p=1;p<e.length;p++){for(s(n,1);u&&(s(n,1),e[u]!==e[p]);)u=l[u-1];s(n,1),e[u]===e[p]&&u++,l[p]=u}let b=-1,a=0,h=0;u=0;for(let p=0;p<o.length;p++){for(s(n,1);u&&(s(n,1),e[u]!==o[p]);)u=l[u-1];if(s(n,1),e[u]===o[p]&&u++,u!==e.length)continue;let v=p+1-e.length,O=p+1;for(u=l[u-1];a<t.length&&t[a].from<v;)s(n,1),a++;for(;h<t.length&&t[h].to<O;)s(n,1),h++;if(s(n,6),!(a===t.length||h===t.length||t[a].from!==v||t[h].to!==O||i>=0&&v<r&&O>i)){if(!d)return v;if(b>=0)return-1;b=v}}return b}function So(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function bs(e,o,t,n){let s=null;for(let i of o)if(n(t,1),!(i.source!==e.source||i.side!==e.side))for(let r of i.runs){if(n(t,1),r.source!==e.source)continue;let l=Math.max(e.from,r.from),u=Math.min(e.to,r.to);l>=u||(s||(n(t,e.to-e.from),s=new Uint8Array(e.to-e.from)),n(t,u-l),s.fill(1,l-e.from,u-e.from))}if(!s)return!1;n(t,e.to-e.from);let d=!1;for(let i=e.from;i<e.to;i++)if(Vo.test(e.flat.text[i])){if(!s[i-e.from])return!1;d=!0}return d}function ws({source:e,side:o,views:t,eligible:n,blocked:s,baseId:d,model:i,tokensOf:r,budget:l,charge:u}){let{V:b,A:a,idOf:h}=t[o],p=t[1-o];if(e.nodeType!==1||a.identical.has(e)||p.A.identical.has(e)||s.has(e)||!n(e))return null;let v=b.twin(e),O=p.V.twin(e);if(!v||!O||a.map.get(e)!==v||a.reverse.get(v)!==e||p.A.map.get(e)!==O||p.A.reverse.get(O)!==e||!b.here(v)||!p.V.here(O)||!n(v)||!n(O))return null;let m=d(e);if(m!==h(v)||m!==p.idOf(O))return null;let c=i(e,null,l),g=i(v,a,l),P=i(O,p.A,l);if(!So(c)||!So(g)||!So(P))return null;let T=c.flat.text,x=g.flat.text;if(u(l,T.length+x.length*3),!Vo.test(x)||x.length>=T.length)return null;let A=T.startsWith(x),E=T.endsWith(x);if(A===E)return null;let S=A?x.length:0,N=A?T.length:T.length-x.length,C=S,j=N;for(;C<j&&(u(l,1),!!_s.test(T[C]));)C++;for(;j>C&&(u(l,1),!!_s.test(T[j-1]));)j--;if(C===j)return null;let D=r(c,l),B=!1,w=!1;for(let y of D)u(l,1),y.from===C&&(B=!0),y.to===j&&(w=!0);return!B||!w?null:{source:e,side:o,flat:c.flat,from:S,to:N}}function zs({base:e,views:o,side:t,attempt:n,eligible:s,blocked:d,baseId:i,model:r,tokensOf:l,certificates:u,charge:b,exhausted:a,limit:h}){if(h<=0)return null;let p=Xt(h),{V:v,A:O,idOf:m}=o[t],c=o[1-t],[g,P,T,x]=n,A=null;try{for(let E=g;E<=P;E++){b(p,1);let S=e[E];if(S.nodeType!==1||O.identical.has(S)||c.A.identical.has(S)||d.has(S)||!s(S))continue;let N=ws({source:S,side:t,views:o,eligible:s,blocked:d,baseId:i,model:r,tokensOf:l,budget:p,charge:b});if(!N||bs(N,u,p,b))continue;let{flat:C,from:j,to:D}=N;b(p,(D-j)*2);let B=C.text.slice(j,D).trim();for(let w=T;w<=x;w++){b(p,1);let y=v.units[w],$=v.baseOf(y);if(!$||$===S||$.nodeType!==1||y.nodeType!==1||$.parentNode!==S.parentNode||y.parentNode!==O.map.get(S).parentNode||O.map.get($)!==y||O.reverse.get(y)!==$||d.has($)||!s($)||!s(y)||i($)!==m(y))continue;let U=r($,null,p),V=r(y,O,p);if(!So(U)||!So(V))continue;let Ne=U.flat.text,Ae=V.flat.text;if(b(p,Ne.length),!Vo.test(Ne)||Ae.length<=Ne.length)continue;let De=l(V,p),oe=En(Ne,Ae,De,p,b,!0);if(!(oe<0)&&!(En(B,Ae,De,p,b,!1,oe,oe+Ne.length)<0)){(A||=[]).push(N);break}}}}catch(E){if(E!==a)throw E}return A}function $s(e,o,t,n,s,d,i){if(d==="both"||t.atoms.length||n.atoms.length||s.atoms.length)return d;let r=d==="remote";if(r?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 d;for(let l of e){if(l.source!==o||l.side!==(r?1:0)||l.flat.text!==t.text||l.flat.nodes.length!==t.nodes.length||i.be<=l.from||i.bs>=l.to)continue;let u=!0;for(let a=0;a<t.nodes.length;a++){let h=l.flat.nodes[a],p=t.nodes[a];if(h.node!==p.node||h.s!==p.s||h.e!==p.e){u=!1;break}}if(!u)continue;let b=!1;for(let a=i.bs;a<i.be;a++)if(Vo.test(t.text[a])){if(a<l.from||a>=l.to){u=!1;break}b=!0}if(u&&b)return r?"local":"remote"}return d}var Dn="\uFFFC";var Li={caret:0},vn=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(" ")),tr=new Set(["BR","WBR","IMG"]),ys=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 jn(e,o={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(o.ignored&&o.ignored(e)||tr.has(e.tagName))return!0;if(!vn.has(e.tagName))return!ys.has(e.tagName);if(o.remoteWins&&o.remoteWins(e))return!1;let t=o.inlineCache&&o.inlineCache.get(e);if(t!==void 0)return t;let n=!0;for(let s of e.childNodes)if(!jn(s,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Ri(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ln(e,o={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},n=(s,d)=>{for(let i of s){if(i.nodeType===3){let a=i.nodeValue;if(!a)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+a.length}),t.text+=a;for(let h=0;h<a.length;h++)t.stackAt.push(d);continue}if(i.nodeType!==1)continue;if(o.ignored&&o.ignored(i)){t.pins.push({el:i,i:t.text.length});continue}if(o.skip&&o.skip.has(i))continue;let r=o.via&&o.via(i)||i;r!==i&&(t.via||(t.via=new Map)).set(r,i);let l=i.tagName;if(o.blocks&&o.blocks.has(i)){t.text.length&&t.text[t.text.length-1]!==Nt&&(t.stackAt.push(d),t.text+=Nt);let a={el:i,tag:l,from:t.text.length,to:-1,depth:d.length,block:!0};t.marks.push(a);let h=d.concat([a]);n(r.childNodes,h),t.stackAt.push(h),t.text+=Nt,a.to=t.text.length;continue}let u=vn.has(l)&&Ri(r);if(tr.has(l)||!vn.has(l)||o.remoteWins&&o.remoteWins(i)||o.atomize&&o.atomize(i)||u){t.atoms.push({i:t.text.length,el:i,key:u?l+":empty":l,stack:d}),t.stackAt.push(d),t.text+=Dn;continue}let b={el:i,tag:l,from:t.text.length,to:-1,depth:d.length};t.marks.push(b),n(r.childNodes,d.concat([b])),b.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&Ko(t).trim()===""){let s=t.atoms[0];t.placeholder=s.el,t.text=t.text.slice(0,s.i)+t.text.slice(s.i+1),t.stackAt.splice(s.i,1);for(let d of t.nodes)d.s>s.i&&(d.s--,d.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(s=>[s.i,s])),t}function Pi(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Bi(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,"&quot;")}"`;return o+">"}function lo(e,o,t){let n="",s=[];for(let d=o;d<t;d++){let i=e.stackAt[d],r=0;for(;r<s.length&&r<i.length&&s[r]===i[r];)r++;for(;s.length>r;)n+=`</${s.pop().tag.toLowerCase()}>`;for(;s.length<i.length;){let u=i[s.length];n+=Bi(u.el),s.push(u)}let l=e.atomAt.get(d);n+=l?l.el.outerHTML:e.text[d]===Nt?"":Pi(e.text[d])}for(;s.length;)n+=`</${s.pop().tag.toLowerCase()}>`;return n}function Di(e,o){let t=[...e.el.attributes].filter(n=>!o(e.el,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tag+"|"+t}function nr(e,o){let t=[...e.attributes].filter(n=>!o(e,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function Gs(e,o=()=>!1){let t=new Map,n=d=>{let i=t.get(d);return i===void 0&&(i="{"+d.map(r=>Di(r,o)).sort().join(",")+"}",t.set(d,i)),i},s="";for(let d=0;d<e.text.length;d++){let i=e.atomAt.get(d);s+=(i?"["+nr(i.el,o)+"]":e.text[d])+n(e.stackAt[d])}return e.text.length===0&&e.placeholder&&(s+="[br]"),s}function io(e,o,t,n=s=>s.key){let s=[],d=e.text,i=0,r=l=>{if(l<=i)return;let u=d.slice(i,l);if(t)for(let b of u.split(/(?<=\n)/))s.push({k:b,raw:b,len:b.length});else for(let b of fn(u,o))s.push(b)};for(let l of e.atoms)r(l.i),s.push({k:"\0"+n(l),raw:Dn,len:1,atom:!0}),i=l.i+1;return r(d.length),s}function Ko(e){if(!e.atoms.length)return e.text;let o="",t=0;for(let n of e.atoms)o+=e.text.slice(t,n.i),t=n.i+1;return o+e.text.slice(t)}var ao=e=>{let o=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)o[t+1]=o[t]+e[t].len;return o};function Ho(e,o,t,n){let s=ao(o),d=ao(t),i=[],r=0,l=0;for(let b of n.hunks){l+=b.bs-r;let a=l+b.toks.length;i.push({bs:s[b.bs],be:s[b.be],ss:d[l],se:d[a],text:e.text.slice(d[l],d[a]),toks:b.toks,lead:!!b.lead}),l=a,r=b.be}let u=new Map;for(let b of n.cosmetic)u.set(b.bi,b.tok.raw);return{hunks:i,respell:u}}function Ys(e,o,t){let n=i=>i===Nt||/\s/.test(i),s=i=>i.replace(/[\u001E\s]/g,""),d=[];for(let i of e){let r=o.slice(i.bs,i.be),l=t.slice(i.ss,i.se);if(!r.includes(Nt)&&!l.includes(Nt)||r.includes(Dn)||l.includes(Dn)||s(r)!==s(l)){d.push(i);continue}let u=0,b=0;for(;;){let a=u,h=b;for(;a<r.length&&n(r[a]);)a++;for(;h<l.length&&n(l[h]);)h++;let p=u,v=b;for(;p<a&&v<h&&r[p]===l[v];)p++,v++;let O=a,m=h;for(;O>p&&m>v&&r[O-1]===l[m-1];)O--,m--;if(O>p||m>v){let c=l.slice(v,m);d.push({bs:i.bs+p,be:i.bs+O,ss:i.ss+v,se:i.ss+m,text:c,toks:[...c].map(g=>({k:g,raw:g,len:1})),lead:i.lead})}if(a>=r.length)break;u=a+1,b=h+1}}return d}function Xs(e,o,t){let n=new Int32Array(o+1).fill(-1),s=new Int32Array(t+1).fill(-1),d=0,i=0,r=l=>{for(;d<l;)n[d]=i,s[i]=d,d++,i++};for(let l of e)r(l.bs),d=l.be,i=l.se;return r(o),n[o]=i,s[i]=o,{bTo:n,toB:s}}function Js(e,o,t){let n=[],s=0,d=0,i=(r,l)=>{if(s===r&&d===l)return;let u=o.text.slice(d,l);n.push({bs:s,be:r,ss:d,se:l,text:u,toks:fn(u,xn(u)),lead:!1})};for(let r of t.runs)i(r.from,r.target),s=r.to,d=r.target+r.to-r.from;return i(e.text.length,o.text.length),{hunks:n,respell:new Map}}function Qs(e,o,t,n){let s=ao(o),d=ao(t),i=(l,u)=>{let b=0,a=l.length;for(;b<a;){let h=b+a>>>1;l[h]<u?b=h+1:a=h}return l[b]===u?b:-1};for(let l of e.hunks)if(i(s,l.bs)<0||i(s,l.be)<0)return null;if(e.hunks.some(l=>i(d,l.ss)<0||i(d,l.se)<0)){if(!n)return null;let l=[];for(let h of e.hunks)l.push(h.ss,h.se);let u=[],b=0,a=0;for(let h of t){let p=a+h.len;for(;b<l.length&&l[b]<=a;)b++;let v=a;for(;b<l.length&&l[b]<p;){let O=l[b++];if(O>v){let m=h.raw.slice(v-a,O-a);u.push(...fn(m,xn(m))),v=O}}if(v===a)u.push(h);else{let O=h.raw.slice(v-a);u.push(...fn(O,xn(O)))}a=p}t=u,d=ao(t)}let r=[];for(let l of e.hunks){let u=i(s,l.bs),b=i(s,l.be),a=i(d,l.ss),h=i(d,l.se);if(u<0||b<0||a<0||h<0)return null;r.push({bs:u,be:b,toks:t.slice(a,h),gap:[],group:r.length})}return{parts:r,cosmeticEq:[],tokens:t}}function ks(e,o,t,n={},s=null){return or(e,o,t,n.base,n.local,n.remote,s,{})}function or(e,o,t,n,s,d,i,r){let l=xn(Ko(e),Ko(o),Ko(t)),u=io(e,l,!1,n),b=io(o,l,!1,s),a=io(t,l,!1,d),h=u.length>2e4||b.length>2e4||a.length>2e4;h&&(u=io(e,l,!0,n),b=io(o,l,!0,s),a=io(t,l,!0,d));let p=i?.local?Js(e,o,i.local):null,v=i?.remote?Js(e,t,i.remote):null,O=p?Qs(p,u,b,!h):Hn(u,b),m=v?Qs(v,u,a,!h):Hn(u,a);p&&O&&(b=O.tokens),v&&m&&(a=m.tokens);let c,g;if(O&&m){let P=ps(O,m,u);c=Ho(o,u,b,{hunks:P.lh,cosmetic:P.cosL}),g=Ho(t,u,a,{hunks:P.rh,cosmetic:P.cosR})}else c=p||Ho(o,u,b,O),g=v||Ho(t,u,a,m);return c.hunks=Ys(c.hunks,e.text,o.text),g.hunks=Ys(g.hunks,e.text,t.text),r.base=e,r.local=o,r.remote=t,r.lines=h,r.baseTokens=u,r.localEdits=c,r.remoteEdits=g,r.localMap=Xs(c.hunks,e.text.length,o.text.length),r.remoteMap=Xs(g.hunks,e.text.length,t.text.length),r.full=null,r}function Zs(e,o){if(e.size!==o.size)return!1;for(let t of e)if(!o.has(t))return!1;return!0}var co=/\s/;function Wo(e,o,t){for(let n=o;n<t;n++)if(!co.test(e[n]))return!1;return!0}function ji(e,o,t){let n=e.cache[t]||(e.cache[t]=new Map);if(n.has(o))return n.get(o);let s=t===0?"local":"remote",d=t===0?"remote":"local",i=o.baseMark,r=o[d+"Mark"],l=!o.block&&!o[s]&&!!r&&i.to>i.from;if(l){let u=t===0?e.ML:e.MR,b=t===0?e.MR:e.ML,a=t===0?e.fr:e.fl,h=!1;for(let p=i.from;p<i.to;p++){if(u.bTo[p]>=0){l=!1;break}b.bTo[p]<0&&!co.test(e.fb.text[p])&&(h=!0)}if(l&&!h){for(let p=r.from;p<r.to;p++)if(b.toB[p]<0&&!co.test(a.text[p])){h=!0;break}}l&&=h}return n.set(o,l),l}function er(e,o,t,n,s,d,i,r,l){let u=r===0?e.fl:e.fr,b=null;for(let a=t;a<n;a++){let h=o[a];if(!Wo(u.text,h.ss,h.se))return null;if(Wo(e.fb.text,h.bs,h.be)){if(h.bs<h.be&&h.ss<h.se||co.test(e.fb.text[h.bs-1]||"")||co.test(e.fb.text[h.be]||""))continue;return null}let p=!1;for(let v=h.bs;v<h.be;v++){if(co.test(e.fb.text[v]))continue;let O=null;for(let m of e.fb.stackAt[v]){let c=e.byEl.get(m.el);if(c&&ji(e,c,r)){O=c;break}}if(!O)return null;(b||(b=new Set)).add(O),p=!0}if(!p)return null}if(!b){if((r===0?"local":"remote")!==l)return null;let a=r===0?e.fr:e.fl,h=!1;for(let p=d;p<i;p++){let v=s[p];if(!Wo(e.fb.text,v.bs,v.be))return null;Wo(a.text,v.ss,v.se)||(h=!0)}if(!h)return null}return b||0}function Fo(e){let{out:o,policy:t="remote",L:n,R:s}=e,d=e.provenance||new WeakMap,i=e.textMappers||new WeakMap,r=e.conflicts||[],l=e.decisions||[],u=r.length,b=e.conflict||(f=>r.push(f)),a={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},h=[],p=!!(n&&n.reverse&&n.map&&s&&s.reverse&&s.map),v={base:null,local:null,remote:null};if(!e.prepared&&p&&e.moveIn){let f=ve=>We=>ve.some(Re=>Re===We||Re.nodeType===1&&Re.contains(We)),L=f(e.local),W=f(e.remote),K=f(e.base),Y=new Set,he=ve=>{if(!vn.has(ve.tagName))return;let We=n.map.get(ve),Re=s.map.get(ve);(We&&!L(We)||Re&&!W(Re))&&Y.add(ve);for(let Fe of ve.children)he(Fe)};for(let ve of e.base)ve.nodeType===1&&he(ve);let ye=ve=>We=>{if(!vn.has(We.tagName))return!1;let Re=ve.reverse.get(We);return!!Re&&(Y.has(Re)||!K(Re))};Y.size&&(v.base=ve=>Y.has(ve)),v.local=ye(n),v.remote=ye(s)}let O={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&p&&e.moveIn){let f=K=>Y=>K.some(he=>he===Y||he.nodeType===1&&he.contains(Y)),L=f(e.local),W=f(e.remote);for(let K of ln(e.base,{...e,atomize:v.base}).atoms){let Y=n.map.get(K.el),he=s.map.get(K.el),ye=!!Y&&!L(Y),ve=!!he&&!W(he);!ye&&!ve||(ye&&e.movePlanned?.(K.el,"local",Y,null),ve&&e.movePlanned?.(K.el,"remote",he,null),O.base.add(K.el),Y&&!ye&&O.local.add(Y),he&&!ve&&O.remote.add(he),L(K.el)&&O.local.add(K.el),W(K.el)&&O.remote.add(K.el))}}let m=e.prepared?.base||ln(e.base,{...e,atomize:v.base,skip:O.base}),c=e.prepared?.local||ln(e.local,{...e,atomize:v.local,skip:O.local}),g=e.prepared?.remote||ln(e.remote,{...e,atomize:v.remote,skip:O.remote}),P=new Map(m.atoms.map(f=>[f.el,f])),T={},x=f=>e.prepared?e.prepared.full?.(f)||null:O[f].size?(T[f]||(T[f]=ln(e[f],{...e,atomize:v[f]})),T[f]):null,A=(f,L,W)=>{L.namespaceURI?f.setAttributeNS(L.namespaceURI,L.name,W):f.setAttribute(L.name,W)},E=(f,L,W,K)=>{if(!L&&(!W||!K)){for(let he of(W||K).attributes)A(f,he,he.value);return}let Y=new Map;for(let he of[L,W,K])if(he)for(let ye of he.attributes)Y.set(ye.name,ye);for(let[he,ye]of Y){let ve=L?L.getAttribute(he):null,We=W?W.getAttribute(he):ve,Re=K?K.getAttribute(he):ve,Fe;We===Re?Fe=We:We===ve?(Fe=Re,l.push({kind:"attr",el:f,name:he,source:"remote"})):Re===ve?(Fe=We,l.push({kind:"attr",el:f,name:he,source:"local"})):(Fe=t==="local"?We:Re,b({kind:"attr",el:f,name:he,base:ve,local:We,remote:Re,resolved:Fe},{el:f,sample:ye}),l.push({kind:"attr",el:f,name:he,source:"both"})),Fe!=null&&A(f,ye,Fe)}},S=(f,L,W,K)=>f&&e.mergeAttrs?e.mergeAttrs(f,L,W,K):E(K,f,L,W),N=e.mergeElement||((f,L,W)=>{let K=o.createElement(f.tagName);S(f,L,W,K);let Y=L||f,he=W||f,ye=t==="local"?Y.isEqualNode(f)?he:Y:he.isEqualNode(f)?Y:he;for(let ve of ye.childNodes)K.appendChild(o.importNode(ve,!0));return d.set(K,{base:f,local:L,remote:W}),K}),C=e.cloneUnit||((f,L)=>{let W=o.importNode(f,!0);return d.set(W,{base:null,local:L==="local"?f:null,remote:L==="remote"?f:null}),W}),j=e.atomKey||(f=>nr(f,()=>!1)),D=(f,L)=>{let W=new Map;for(let K of f.atoms)if(e.remoteWins&&e.remoteWins(K.el)&&vn.has(K.el.tagName))W.set(K,"w"+K.el.tagName+"#"+(K.el.id||""));else if(!p)W.set(K,K.key);else if(f===m)W.set(K,"="+j(K.el));else{let Y=L.reverse.get(K.el),he=Y?P.get(Y):null;he?W.set(K,"="+j(he.el)):Y?W.set(K,"m"+j(K.el)):W.set(K,"="+j(K.el))}return K=>W.get(K)},B=D(m,null),w=D(c,n),y=D(g,s),$=e.certifiedOrigins?e.certifiedOrigins(m,c,g,B,w,y):null;if($?.fallback)return null;if(!$&&!e.prepared&&e.blocks){let f=Xt(),L=gs({base:m,side:c,baseOf:K=>n?.reverse?.get(K)||null,budget:f}),W=gs({base:m,side:g,baseOf:K=>s?.reverse?.get(K)||null,budget:f});(L.status==="ready"||W.status==="ready")&&($={local:L.status==="ready"?L:null,remote:W.status==="ready"?W:null})}let U=e.prepared||or(m,c,g,B,w,y,$,a),V=U.lines,Ne=U.baseTokens,Ae=U.localEdits,De=U.remoteEdits,oe=U.localMap,xe=U.remoteMap,$e=m.text.length,ae=f=>new Map(f.atoms.map(L=>[L.el,L])),k=ae(c),_=ae(g),re=(f,L,W)=>{let K=new Set;if(!p)return K;for(let Y of f.atoms){let he=P.get(L.reverse.get(Y.el));he&&W.bTo[he.i]<0&&K.add(he)}return K},Z=re(c,n,oe),Be=re(g,s,xe),Ke=f=>!jn(f,{...e,remoteWins:null}),Te=new Set;if(p)for(let f of m.atoms){if(!Ke(f.el))continue;let L=n.map.get(f.el)||null,W=s.map.get(f.el)||null,K=L&&!W?L:W&&!L?W:null;K&&(k.has(K)||_.has(K))&&!K.isEqualNode(f.el)&&Te.add(f)}let it=1,et=(f,L)=>({id:it++,tag:f,base:null,local:null,remote:null,rank:L}),mt=new Map,Ze=[];for(let f of m.marks){let L=et(f.tag,f.depth);L.block=!!f.block,L.base=f.el,L.baseMark=f,mt.set(f.el,L),Ze.push(L)}let ft=(f,L)=>{let W=-1,K=-1;for(let Y=f.from;Y<f.to;Y++){let he=L[Y];he>=0&&(W<0&&(W=he),K=he+1)}return W<0?null:[W,K]},Ct=(f,L,W,K)=>{for(let Y of f.marks){let he=W?W.reverse.get(Y.el):null;he&&W.identical.has(he)&&W.pairIdenticalChildren&&W.pairIdenticalChildren(he);let ye=he?mt.get(he):null;if(ye&&ye[L]&&(ye=null),!ye){let ve=ft(Y,K),We=0;if(ve)for(let Re of Ze){if(Re.tag!==Y.tag||Re[L]||!!Re.block!=!!Y.block)continue;let Fe=Math.min(ve[1],Re.baseMark.to)-Math.max(ve[0],Re.baseMark.from);(Fe>We||Fe===We&&Fe>0&&Math.abs(Re.rank-Y.depth)<Math.abs(ye.rank-Y.depth))&&(ye=Re,We=Fe)}}ye||(ye=et(Y.tag,Y.depth),ye.block=!!Y.block,ye.new=L),ye[L]=Y.el,ye[L+"Mark"]=Y,mt.set(Y.el,ye)}};Ct(c,"local",n,oe.toB),Ct(g,"remote",s,xe.toB);let Dt=f=>f.merged||f,Tt=f=>{let L=new Set;for(let W of f)W.block||L.add(mt.get(W.el));return L},Rt=new Map,jt=f=>{let L=Rt.get(f);return L||(L=Tt(f),Rt.set(f,L)),L},qt=(f,L)=>{let W=[],K=null;for(let Y=0;Y<$e;Y++){let he=L[Y];if(he<0){K&&W.push(K),K=null;continue}let ye=jt(m.stackAt[Y]),ve=jt(f.stackAt[he]),We=new Set,Re=new Set;for(let Fe of ve)ye.has(Fe)||We.add(Fe);for(let Fe of ye)ve.has(Fe)||Re.add(Fe);if(!We.size&&!Re.size){K&&W.push(K),K=null;continue}if(K&&Zs(K.added,We)&&Zs(K.removed,Re)){K.be=Y+1;continue}K&&W.push(K),K={bs:Y,be:Y+1,added:We,removed:Re}}return K&&W.push(K),W},un=qt(c,oe.bTo),Lt=qt(g,xe.bTo),Jt=f=>f.be>f.bs?[f.bs,f.be-1]:[f.bs-1,f.bs],F=(f,L)=>{if($e===0)return null;let[W,K]=Jt(f);for(let Y of L){if(Y.be<=W)continue;if(Y.bs>K)break;let he=Y.bs<=W&&K<Y.be;return he&&f.text===""&&Y.bs===f.bs&&Y.be===f.be?"straddle":he?Y:f.be>f.bs?"straddle":null}return null},ce=f=>f.bs===f.be,ge=(f,L,W=null)=>{let K=!1;for(let Y=f.bs;Y<f.be;Y++){let he=m.text[Y];if(he===Nt)K=!0;else if(!/\s/.test(he))return!1}for(let Y=f.ss;Y<f.se;Y++){let he=L.text[Y];if(he===Nt)K=!0;else if(!/\s/.test(he)){let ye=W&&e.scopeUnits&&ce(f)&&L.atomAt.get(Y);if(!ye||!Ke(ye.el)||W.ss!==W.se||W.bs>=W.be)return!1;for(let We=W.bs;We<W.be;We++)if(!/\s/.test(m.text[We]))return!1;let ve=L===c?1:2;if(!e.scopeUnits[ve].includes(ye.el)||(ve===1?n:s)?.reverse.has(ye.el))return!1;K=!0}}return K},Le=(f,L)=>f.bs<L.be&&L.bs<f.be,Me=(f,L)=>f.bs<=L.be&&L.bs<=f.be&&ce(f)!==ce(L),M=(f,L)=>m.text.slice(f.bs,f.be).includes(Nt)||L.text.slice(f.ss,f.se).includes(Nt),R=f=>{if(ce(f))return!1;let L=f.bs,W=f.be;for(;L>0&&/\s/.test(m.text[L-1]);)L--;for(;W<m.text.length&&/\s/.test(m.text[W]);)W++;return(L===0||m.text[L-1]===Nt)&&(W===m.text.length||m.text[W]===Nt)},z=(f,L)=>!M(f,L)&&!R(f),J=(f,L)=>Le(f,L)||Me(f,L)&&!(f.transferIn||f.transferOut||L.transferIn||L.transferOut)&&!(ge(f,c,L)&&z(L,g))&&!(ge(L,g,f)&&z(f,c)),ne=(f,L)=>{if(f.bs!==L.bs||f.be!==L.be||f.toks.length!==L.toks.length)return!1;let W=f.ss,K=L.ss;for(let Y=0;Y<f.toks.length;Y++){let he=f.toks[Y],ye=L.toks[Y];if(he.k!==ye.k||he.atom&&!c.atomAt.get(W).el.isEqualNode(g.atomAt.get(K).el))return!1;W+=he.len,K+=ye.len}return!0},je=(f,L,W,K)=>{for(let Y of m.atoms){if(Y.i<f.bs||Y.i>=f.be||K.has(Y)||Te.has(Y))continue;let he=L.bTo[Y.i],ye=he>=0?W.atomAt.get(he):null;if(ye&&!ye.el.isEqualNode(Y.el))return!0}return!1},Q=[],Oe=null,Ve=null,Ce=Ae.hunks,be=De.hunks,H=0,X=0,de=0,pe=0,se=0,ke=f=>{f>de&&(Q.push({src:"base",from:de,to:f,dL:pe,dR:se}),de=f)};for(;H<Ce.length||X<be.length;){let f=Ce[H],L=be[X],W=!!f&&(!L||f.bs<L.bs||f.bs===L.bs&&f.be<=L.be&&!L.lead);if(f&&L&&f.bs===L.bs&&ce(f)&&ce(L)){let Gt=ge(f,c),To=ge(L,g);Gt!==To&&(W=To)}let K=W?f:L,Y=W?L:f,he=!!Y&&ne(f,L),ye=!!Y&&(W?!!Ce[H+1]&&ne(Ce[H+1],L):!!be[X+1]&&ne(f,be[X+1])),ve=!!Y&&!he&&!ye&&($e===0||J(f,L)),We=ve,Re=F(K,W?Lt:un);if(Re==="straddle"&&(We=!0),!We&&K.be>K.bs&&(We=je(K,W?xe:oe,W?g:c,W?Z:Be)),!We&&he){ke(K.bs),Q.push({src:"both",lfrom:f.ss,rfrom:L.ss,len:K.text.length,owner:f.owner||L.owner||null,transfer:f.transferIn||L.transferIn||null}),de=K.be,pe+=K.text.length-(K.be-K.bs),se+=K.text.length-(K.be-K.bs),H++,X++;continue}if(!We){ke(K.bs),Q.push({src:W?"local":"remote",from:K.ss,to:K.se,inherit:Re&&Re!=="straddle"?Re:null,owner:K.owner||null,transfer:K.transferIn||null}),de=K.be,W?(pe+=K.text.length-(K.be-K.bs),H++):(se+=K.text.length-(K.be-K.bs),X++);continue}let Fe=K.bs,xt=K.be,ht=H,pt=X,Ft=Gt=>Gt.bs<xt&&Gt.be>Fe||ce(Gt)&&(Gt.bs===Fe||Gt.bs===xt);W?ht++:pt++,ve&&(Fe=Math.min(Fe,Y.bs),xt=Math.max(xt,Y.be),W?pt++:ht++);let Vt=!0;for(;Vt;){for(Vt=!1;ht<Ce.length&&Ft(Ce[ht]);)Fe=Math.min(Fe,Ce[ht].bs),xt=Math.max(xt,Ce[ht].be),ht++,Vt=!0;for(;pt<be.length&&Ft(be[pt]);)Fe=Math.min(Fe,be[pt].bs),xt=Math.max(xt,be[pt].be),pt++,Vt=!0}let gn=Fe+pe,cn=Fe+se,yn=xt-Fe,Sn=xt-Fe;for(let Gt=H;Gt<ht;Gt++)yn+=Ce[Gt].text.length-(Ce[Gt].be-Ce[Gt].bs);for(let Gt=X;Gt<pt;Gt++)Sn+=be[Gt].text.length-(be[Gt].be-be[Gt].bs);let Rn=gn+yn,Pn=cn+Sn;if(ke(Fe),H<ht&&X<pt&&!$&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!m.atoms.length&&!c.atoms.length&&!g.atoms.length&&!m.pins.length&&!c.pins.length&&!g.pins.length){Oe||={fb:m,fl:c,fr:g,ML:oe,MR:xe,byEl:mt,cache:[null,null]};let Gt=er(Oe,Ce,H,ht,be,X,pt,0,t),To=er(Oe,be,X,pt,Ce,H,ht,1,t);if(Gt===null!=(To===null)){let ts=Gt!==null,Ds=ts?Gt:To;if(Ds){Ve||=new Map;for(let ni of Ds)Ve.set(ni,ts?"local":"remote")}Q.push(ts?{src:"remote",from:cn,to:Pn}:{src:"local",from:gn,to:Rn}),de=xt,pe+=yn-(xt-Fe),se+=Sn-(xt-Fe),H=ht,X=pt;continue}}let on={kind:"text",node:e.node||null,base:lo(m,Fe,xt),local:lo(c,gn,Rn),remote:lo(g,cn,Pn),resolved:null,range:null,bs:Fe,be:xt,lss:gn,lse:Rn,rss:cn,rse:Pn},Xn=e.sourceRetentions?$s(e.sourceRetentions,e.scope?.base,m,c,g,t,on):t;on.resolved=Xn==="local"?on.local:Xn==="remote"?on.remote:on.local+on.remote,Xn!=="remote"&&Q.push({src:"local",from:gn,to:Rn,conflict:on}),Xn!=="local"&&Q.push({src:"remote",from:cn,to:Pn,conflict:on});let Jn={site:"inline",policy:Xn,fb:m,fl:c,fr:g,scope:e.scope||null,synthetic:!!e.synthetic,full:x,merged:a};h.push(Jn),b(on,Jn),de=xt,pe+=yn-(xt-Fe),se+=Sn-(xt-Fe),H=ht,X=pt}ke($e);let fe=m.text,G=[];if(Ae.respell.size||De.respell.size){let f=ao(Ne),L=[];for(let W=0;W<Ne.length;W++){let K=Ne[W].raw,Y=Ae.respell.get(W)??K,he=De.respell.get(W)??K;(Y!==K||he!==K)&&G.push([f[W],Y!==K&&he!==K?"both":Y!==K?"local":"remote"]),L.push(Y===he?Y:Y===K?he:he===K||t==="local"?Y:he)}fe=L.join("")}let ue="",Ie=[],Pe=[],He=[],Se=[];for(let f of Q){let L=ue.length;if(f.src==="base"){for(let W=f.from;W<f.to;W++)Ie.push(W),Pe.push(e.nativeTransfers?oe.bTo[W]:W+f.dL),He.push(e.nativeTransfers?xe.bTo[W]:W+f.dR),Se.push(f);ue+=fe.slice(f.from,f.to)}else if(f.src==="both"){for(let W=0;W<f.len;W++){let K=f.transfer&&(f.transfer.side==="remote"?f.rfrom+W:f.lfrom+W);Ie.push(f.transfer&&K>=f.transfer.ss&&K<f.transfer.se?f.transfer.bs+K-f.transfer.ss:-1),Pe.push(f.lfrom+W),He.push(f.rfrom+W),Se.push(f)}ue+=c.text.slice(f.lfrom,f.lfrom+f.len)}else{let W=f.src==="local"?c:g,K=f.transfer&&e.nativeTransfers.byOrigin[f.src==="local"?"remote":"local"].get(f.transfer.key);for(let Y=f.from;Y<f.to;Y++){let he=f.transfer&&Y>=f.transfer.ss&&Y<f.transfer.se?f.transfer.bs+Y-f.transfer.ss:-1,ye=he>=0&&(!K||K.destination===f.owner)?(f.src==="local"?xe:oe).bTo[he]:-1;Ie.push(he),Pe.push(f.src==="local"?Y:ye),He.push(f.src==="remote"?Y:ye),Se.push(f)}ue+=W.text.slice(f.from,f.to)}f.ms=L,f.me=ue.length,f.conflict&&(f.conflict.range||(f.conflict.range=[L,L]),f.conflict.range[1]=ue.length)}let Je=ue.length,nt=new Int32Array($e+1).fill(-1),ot=new Int32Array(c.text.length+1).fill(-1),Wt=new Int32Array(g.text.length+1).fill(-1);for(let f=0;f<Je;f++)Ie[f]>=0&&(nt[Ie[f]]=f),Pe[f]>=0&&(ot[Pe[f]]=f),He[f]>=0&&(Wt[He[f]]=f);let Ut=(f,L)=>{let W=-1,K=-1;for(let Y=f.from;Y<f.to;Y++){let he=L[Y];he>=0&&(W<0&&(W=he),K=he+1)}return W<0?null:[W,K]},I=[],q=[];for(let f of new Set(mt.values()))f.new==="local"?I.push(f):f.new==="remote"&&q.push(f);let te=(f,L)=>{f.remote=L.remote,f.remoteMark=L.remoteMark,f.new="both",L.merged=f,mt.set(L.remote,f)};if(I.length&&q.length){let f=e.idOf;for(let L of I){let W=f?f.local(L.local):null;if(!W)continue;let K=q.find(Y=>!Y.merged&&Y.tag===L.tag&&!!Y.block==!!L.block&&f.remote(Y.remote)===W);K&&te(L,K)}for(let L of I){if(L.remote)continue;let W=Ut(L.localMark,ot);if(W)for(let K of q){if(K.merged||K.tag!==L.tag||!!K.block!=!!L.block)continue;let Y=Ut(K.remoteMark,Wt);if(Y&&Math.min(W[1],Y[1])-Math.max(W[0],Y[0])>0){te(L,K);break}}}}Rt.clear();let me=f=>{for(let L of f)if(L.block)return Dt(mt.get(L.el));return null},we=m.marks.some(f=>f.block)||c.marks.some(f=>f.block)||g.marks.some(f=>f.block),ie=new Array(Je).fill(null),ee=new Set;if(e.nativeTransfers)for(let f=0;f<Je;f++){let L=Se[f].owner;ie[f]=L?Dt(mt.get(L)):Ie[f]>=0?me(m.stackAt[Ie[f]]):null}else if(we){let f=(Re,Fe,xt)=>{let ht=new Set([Re,Fe,xt]);ht.delete(null);let pt=[];for(let Vt of ht){let gn=Vt===Re,cn=Vt===Fe,yn=Vt===xt;(cn===yn?cn:cn===gn?yn:cn)&&pt.push(Vt)}if(pt.length<=1)return pt[0]||null;let Ft=t==="local"?Fe:xt;return pt.includes(Ft)?Ft:pt[0]},L=(Re,Fe)=>Fe>=0?me(Re.stackAt[Fe]):null,W=new Map;for(let Re=0;Re<Je;Re++){if(ue[Re]!==Nt)continue;let Fe=Ie[Re]>=0?L(m,Ie[Re]):null,xt=L(c,Pe[Re]),ht=L(g,He[Re]);W.set(Re,[Fe,Ie[Re]>=0?f(Fe,xt,ht):xt||ht])}let K=new Set([...W.values()].map(Re=>Re[1])),Y=Re=>Re!==Nt&&Re!==Dn&&!/\s/.test(Re),he=(Re,Fe)=>{let xt=Re;for(;xt<Fe&&!Y(ue[xt]);)xt++;return xt<Fe&&Ie[xt]>=0?L(m,Ie[xt]):null},ye=new Map,ve=0;for(let Re=0;Re<Je;Re++){if(ue[Re]!==Nt)continue;let[Fe,xt]=W.get(Re),ht=he(ve,Re),pt=xt,Ft=ye.get(pt)===pt&&ht===pt;pt&&ye.has(pt)&&!Ft&&Fe&&!ye.has(Fe)&&!K.has(Fe)&&(pt=Fe),pt&&!ye.has(pt)&&ye.set(pt,ht);for(let Vt=ve;Vt<=Re;Vt++)ie[Vt]=pt;ve=Re+1}let We=Re=>{for(let Fe=0;Fe<Re.text.length;Fe++)if(Y(Re.text[Fe])&&!L(Re,Fe))return!0;return!1};if(!We(m)&&!We(c)&&!We(g)){let Re=[],Fe=0;for(let ht=0;ht<Je;ht++)(ue[ht]===Nt||ht===Je-1)&&(Re.push([Fe,ht]),Fe=ht+1);let xt=new Set(ie);for(let ht=0;ht<Re.length;ht++){let[pt,Ft]=Re[ht];if(ie[Ft])continue;let Vt=pt;for(;Vt<=Ft&&!Y(ue[Vt]);)Vt++;if(Vt>Ft)continue;let gn=L(m,Ie[Vt]),cn=L(c,Pe[Vt]),yn=L(g,He[Vt]),Sn=f(gn,cn,yn)||cn||yn||gn;if(Sn&&!xt.has(Sn)){xt.add(Sn);for(let on=pt;on<=Ft;on++)ie[on]=Sn;continue}let Rn=ht>0&&ie[Re[ht-1][1]],Pn=ht+1<Re.length&&ie[Re[ht+1][1]];if(Rn)ee.add(Re[ht-1][1]);else if(Pn&&ue[Ft]===Nt)ee.add(Ft);else continue;for(let on=pt;on<=Ft;on++)ie[on]=Rn||Pn}}}let Ee=new Map,Ue=f=>{let L=Ee.get(f);if(L)return L;L=[1/0,-1/0];for(let[W,K]of[[f.baseMark,nt],[f.localMark,ot],[f.remoteMark,Wt]]){let Y=W&&Ut(W,K);Y&&(L[0]=Math.min(L[0],Y[0]),L[1]=Math.max(L[1],Y[1]))}return Ee.set(f,L),L},_e=(f,L,W)=>{let K=-1,Y=-1;for(let he=0;he<f.length;he++){let ye=mt.get(f[he].el);ye===L&&(K=he),ye===W&&(Y=he)}return K>=0&&Y>=0?K-Y:0},Ye=(f,L)=>[...f].sort((W,K)=>{for(let ye of L){let ve=_e(ye,W,K);if(ve)return ve}let Y=Ue(W),he=Ue(K);return Y[0]-he[0]||he[1]-Y[1]||W.rank-K.rank||W.id-K.id}),yt=new Map,gt=new Map,$t=e.nativeTransfers?[]:null,_t=f=>{if($t)return $t;let L=Ie[f],W=Pe[f],K=He[f],Y=Se[f];if(L>=0){let ht=m.stackAt[L],pt=c.stackAt[W],Ft=g.stackAt[K],Vt=yt.get(ht);Vt||yt.set(ht,Vt=new Map);let gn=Vt.get(pt);gn||Vt.set(pt,gn=new Map);let cn=gn.get(Ft);if(cn)return cn;let yn=jt(ht),Sn=jt(pt),Rn=jt(Ft),Pn=new Set;for(let on of new Set([...yn,...Sn,...Rn])){let Xn=yn.has(on),Jn=Sn.has(on),Gt=Rn.has(on);(Jn===Gt?Jn:Jn===Xn?Gt:Jn)&&Pn.add(on)}return cn=Ye(Pn,[pt,Ft,ht]),gn.set(Ft,cn),cn}if(Y.src==="both"){let ht=c.stackAt[W],pt=g.stackAt[K];return Ye(new Set([...jt(ht),...jt(pt)]),[ht,pt])}let ye=(Y.src==="local"?c:g).stackAt[Y.src==="local"?W:K];if(!Y.inherit)return Ye(jt(ye),[ye]);let ve=gt.get(Y);ve||gt.set(Y,ve=new Map);let We=ve.get(ye);if(We)return We;let Re=new Set(jt(ye));for(let ht of Y.inherit.added)Re.add(Dt(ht));for(let ht of Y.inherit.removed)Re.delete(Dt(ht));let Fe=Y.src==="local"?g:c,xt=(Y.src==="local"?xe.bTo:oe.bTo)[Y.inherit.bs];return We=Ye(Re,[ye,Fe.stackAt[xt]]),ve.set(ye,We),We},dn=new Int32Array(c.text.length+1);dn[c.text.length]=Je;for(let f=c.text.length-1;f>=0;f--)dn[f]=ot[f]>=0?ot[f]:dn[f+1];Li.caret+=c.text.length;let vt=f=>f<=0?0:(f>c.text.length&&(f=c.text.length),ot[f-1]>=0?ot[f-1]+1:dn[f]),dt=[],Qe=[],Mt=null,bt=[],Ht="",pn=-1,sn=f=>{Mt?Mt.appendChild(f):dt.push(f)},Zt=f=>{if(!Ht)return;let L=o.createTextNode(Ht);sn(L),Qe.push({node:L,ms:pn,me:f,local:[],u:bt.length?bt[bt.length-1].u:null}),Ht=""},wn=new Set,On=new Map,In=new Set,Lo=f=>{let L=o.createElement(f.tag);if(f.block&&Kn.add(L),!On.has(f)){On.set(f,L),S(f.base,f.local,f.remote,L),d.set(L,{base:f.base,local:f.local,remote:f.remote});let K=(ye,ve)=>p&&f[ve]&&ye.reverse.get(f[ve])?ve:null,Y=!f.base&&(K(n,"local")||K(s,"remote"));if(Y){let ye=Y==="local"?n.reverse.get(f.local):s.reverse.get(f.remote),ve=d.get(L);ve.local=ve.local||n.map.get(ye)||null,ve.remote=ve.remote||s.map.get(ye)||null,l.push({kind:"move",el:L,source:Y}),e.moveBuilt?.(ye,Y,f[Y],L)}else f.base||l.push({kind:"insert",el:L,source:f.local&&f.remote?"both":f.local?"local":"remote"});let he=d.get(L);he.local&&(In.has(he.local)?he.local=null:In.add(he.local))}else{let K=On.get(f);for(let Y of K.attributes)Y.name!=="id"&&Y.name!=="data-id"&&A(L,Y,Y.value);d.set(L,{base:null,local:null,remote:null})}sn(L),bt.push({u:f,el:L}),Mt=L},yo=new Set,Gn=new Map;for(let f of c.pins){let L=vt(f.i);Gn.has(L)||Gn.set(L,[]),Gn.get(L).push(f)}let Ro=f=>{let L=Gn.get(f);if(L){Zt(f);for(let W of L){let K=W.el.namespaceURI&&W.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(W.el.namespaceURI,W.el.tagName):o.createElement(W.el.tagName);d.set(K,{base:null,local:W.el,remote:null,pinned:!0}),yo.add(K),sn(K)}}},es=m.atoms.length||c.atoms.length||g.atoms.length,ko=f=>{if(!es)return null;let L=Ie[f]>=0?m.atomAt.get(Ie[f]):null,W=Pe[f]>=0?c.atomAt.get(Pe[f]):null,K=He[f]>=0?g.atomAt.get(He[f]):null;return L||W||K?{ab:L,al:W,ar:K}:null},Wn=(f,L,W)=>{let K=e.idOf;if(!K||!K.base)return!1;let Y=K.base(f.el);return Y!=null&&Y===K[W](L.el)},xo=(f,L,W,K,Y)=>{if(!f||!p)return null;let he=P.get(L.reverse.get(f.el))||null;return!he||he===K||(K?he.el.isEqualNode(K.el)&&!Wn(he,f,Y):W.bTo[he.i]>=0)?null:he},vo=(f,L)=>{if(!f||!p||!e.moveIn)return null;let W=L.reverse.get(f.el);return W&&!P.has(W)?W:null},le=(f,L)=>{let W=new Map;for(let K of f.atoms)W.set(L(K),(W.get(L(K))||0)+1);return W},ze=le(m,B),qe=le(c,w),st=le(g,y),At=f=>{let L=B(f);return ze.get(L)===1&&(qe.get(L)||0)<=1&&(st.get(L)||0)<=1},Ge=new Map,Xe=new Set,St=new Set,tt=new Set,wt=null;for(let f=0;f<Je;f++){let L=ko(f);if(!L)continue;let{ab:W,al:K,ar:Y}=L,he=xo(Y,s,xe,W,"remote"),ye=xo(K,n,oe,W,"local"),ve=W,We=null;if(he?(ve=he,We="remote"):ye&&(ve=ye,We="local"),ve){W&&ve!==W&&(wt||=new Map).set(W,We),Xe.has(ve)?Ge.set(f,{dup:ve.el}):(Xe.add(ve),Ge.set(f,{bk:ve,from:We,al:K,ar:Y}));continue}let Re=vo(Y,s),Fe=vo(K,n),xt=Re||Fe;if(xt){St.has(xt)?Ge.set(f,{dup:xt}):(St.add(xt),Ge.set(f,{moveIn:xt,side:Re?"remote":"local",sideEl:Re?Y.el:K.el}));continue}let ht=(Ft,Vt)=>Ft&&p&&P.get(Vt.reverse.get(Ft.el))||null,pt=ht(Y,s)||ht(K,n);if(pt&&(tt.add(pt),Se[f].conflict&&(At(pt)||Y&&(Y.el===pt.el||s.identityPaired?.has(pt.el))&&Wn(pt,Y,"remote")||K&&(K.el===pt.el||n.identityPaired?.has(pt.el))&&Wn(pt,K,"local")))){if(Xe.has(pt)){Ge.set(f,{dup:pt.el});continue}Xe.add(pt)}Ge.set(f,{al:K,ar:Y})}let lt=new Map,zt,Et,en=(f,L)=>{if(f[L]>=0)return f[L];for(let W=L-1;W>=0;W--)if(f[W]>=0)return f[W]+1;return 0};if(p)for(let f of m.atoms){if(Xe.has(f)||tt.has(f))continue;let L=n.map.get(f.el)||null,W=s.map.get(f.el)||null,K=L&&k.get(L),Y=W&&_.get(W);if(L&&!K||W&&!Y)continue;let he=!(K&&Y)&&Te.has(f);if(!he&&!(K&&Y&&(At(f)||wt?.has(f)||(K.el===f.el||n.identityPaired?.has(f.el))&&(Y.el===f.el||s.identityPaired?.has(f.el))&&Wn(f,K,"local")&&Wn(f,Y,"remote"))))continue;let ye=wt?.get(f),ve=t;if(ye){let ht=ye==="local"?g:c,pt=ye==="local"?s:n,Ft=ye==="local"?Et:zt;if(Ft===void 0){Ft=ht.atoms.length===m.atoms.length;for(let Vt=0;Ft&&Vt<m.atoms.length;Vt++)Ft=pt.reverse.get(ht.atoms[Vt].el)===m.atoms[Vt].el;ye==="local"?Et=Ft:zt=Ft}Ft&&(ve=ye)}let We=ve==="local"?[[K,ot],[Y,Wt]]:[[Y,Wt],[K,ot]],[Re,Fe]=We.find(([ht])=>ht),xt=en(Fe,Re.i);lt.has(xt)||lt.set(xt,[]),lt.get(xt).push({a:f,lt:L,rt:W,edited:he}),Xe.add(f)}if(p&&e.moveIn){let f=[[c,n,ot,"local"],[g,s,Wt,"remote"]];t!=="local"&&f.reverse();for(let[L,W,K,Y]of f)for(let he of L.atoms){let ye=vo(he,W);if(!ye||St.has(ye))continue;St.add(ye);let ve=en(K,he.i);lt.has(ve)||lt.set(ve,[]),lt.get(ve).push({move:ye,side:Y,sideEl:he.el})}}let Tn=f=>{let L=lt.get(f);if(L){if(Zt(f),L.some(W=>Ke(W.move?W.sideEl:W.a.el)))for(;bt.length;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;for(let{a:W,lt:K,rt:Y,edited:he,move:ye,side:ve,sideEl:We}of L){if(ye){let Fe=e.moveIn(ye,ve,We);Fe&&sn(Fe);continue}wn.add(W);let Re=N(W.el,K,Y);he&&(b({kind:"structure",el:Re,detail:"edit-beats-delete",base:W.el},{subject:W.el,deleted:K?"remote":"local"}),l.push({kind:"insert",el:Re,source:K?"local":"remote"})),sn(Re)}}},Kn=new Set,Po=r.length>u;for(let f=0;f<Je;f++){let L=ko(f),W=e.scopeUnits&&L&&(L.ab?.stack.some(ye=>ye.block)||L.al?.stack.some(ye=>ye.block)||L.ar?.stack.some(ye=>ye.block)),Y=!!L&&Ke((L.ab||L.al||L.ar).el)&&!W?[]:ie[f]?[ie[f],..._t(f)]:_t(f),he=0;for(;he<bt.length&&he<Y.length&&bt[he].u===Y[he];)he++;if(he<bt.length)for(Zt(f);bt.length>he;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;if(Ro(f),Tn(f),Y.length>bt.length)for(Zt(f);bt.length<Y.length;)Lo(Y[bt.length]);if(ue[f]===Nt){if(ee.has(f))continue;Zt(f);let ye=bt.length;for(;ye>0&&!bt[ye-1].u.block;)ye--;if(ye>0)for(Po&&a.breakOut.set(f,bt[ye-1].el);bt.length>=ye;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;continue}if(L){Zt(f);let ye=Ge.get(f),ve;if(ye.dup){b({kind:"structure",el:null,detail:"both-moved",base:ye.dup},{subject:ye.dup});continue}if(ye.moveIn){if(ve=e.moveIn(ye.moveIn,ye.side,ye.sideEl),!ve)continue}else if(ye.bk){let We=ye.bk;if(wn.add(We),We===L.ab)ve=N(We.el,ye.al.el,ye.ar.el);else{let Re=n.map.get(We.el)||null,Fe=s.map.get(We.el)||null;ve=N(We.el,Re,Fe),(!Re||!Fe)&&b({kind:"structure",el:null,detail:"move-beats-delete",base:We.el},{subject:We.el,deleted:Re?"remote":"local"}),l.push({kind:"move",el:ve,source:ye.from})}}else ye.al?(ve=C(ye.al.el,"local"),ye.ar&&(d.get(ve).remote=ye.ar.el),l.push({kind:"insert",el:ve,source:ye.ar?"both":"local"})):(ve=C(ye.ar.el,"remote"),l.push({kind:"insert",el:ve,source:"remote"}));Po&&a.atomOut.set(f,ve),sn(ve);continue}Ht||(pn=f),Ht+=ue[f]}if(Zt(Je),(Gn.has(Je)||lt.has(Je))&&(bt.length=0,Mt=null,Ro(Je),Tn(Je)),Je===0&&(c.placeholder||g.placeholder||m.placeholder)){let f=o.createElement("br");d.set(f,{base:m.placeholder,local:c.placeholder,remote:g.placeholder}),dt.push(f)}let at=0,rt=f=>{for(;at>0&&Qe[at-1].me>=f;)at--;for(;at<Qe.length&&Qe[at].me<f;)at++;let L=Qe[at];if(!L)return Qe[Qe.length-1]||null;let W=Qe[at+1];return L.me===f&&W&&W.ms===f?W:L},Pt=new Map,ct={},It=(f,L,W)=>{let K=rt(f)||(W?ct:null);if(!K)return;let Y=Pt.get(K)||{l:!1,r:!1};L!=="remote"&&(Y.l=!0),L!=="local"&&(Y.r=!0),Pt.set(K,Y)},tn=f=>{if(f.conflict)return!0;let L=f.src==="local"?c.text:f.src==="remote"?g.text:"";for(let W=f.from;W<f.to;W++)if(L[W]!==Dn&&L[W]!==Nt)return!0;return!1};for(let f of Q)f.src!=="base"&&It(f.ms,f.conflict?"both":f.src,tn(f));for(let[f,L]of G)nt[f]>=0&&It(nt[f],L);for(let f of Qe.length?Qe:[ct]){let L=Pt.get(f);L&&l.push({kind:"text",node:f.node||null,source:L.l&&L.r?"both":L.l?"local":"remote"})}for(let f of Ze){if(On.has(f))continue;let L=!f.local&&!(p&&n.map.get(f.base)),W=!f.remote&&!(p&&s.map.get(f.base));!L&&!W||l.push({kind:"remove",source:L&&W?"both":L?"local":"remote",base:f.base})}if(Ve)for(let[f,L]of Ve)On.has(f)&&b({kind:"structure",el:On.get(f),detail:"edit-beats-delete",base:f.base},{subject:f.base,deleted:L});let Bt=(f,L,W)=>{if(L<=f)return!1;for(let K=f;K<L;K++)if(W[K]>=0)return!1;return!0};for(let f of Ze)for(let L of["local","remote"]){let W=f[L+"Mark"],K=f.baseMark;if(!W)continue;let Y=L==="local"?oe:xe;if(!Bt(K.from,K.to,Y.bTo)||!Bt(W.from,W.to,Y.toB))continue;let he=(L==="local"?Ce:be).find(ye=>ye.ss<=W.from&&W.from<ye.se);he&&(he.be<=K.from||he.bs>=K.to)&&l.push({kind:"move",el:On.get(f)||null,source:L})}let rn=f=>{let L=mt.get(f.node.parentNode);return L?Dt(L):null};for(let f of c.nodes){let L=-1;for(let K=f.s;K<f.e;K++)if(ot[K]>=0){L=ot[K];break}let W;if(L>=0)W=rt(L);else{let K=vt(f.s),Y=rn(f);W=Qe.find(he=>he.u===Y&&he.me>=K)||Qe.filter(he=>he.u===Y).pop()}W&&W.local.push(f)}let Yt=new Map,Ot=Qe[Qe.length-1]||null,kt=0;for(let f of c.nodes){let L=null;for(let W=f.s;W<=f.e;W++){let K=vt(W);for(;kt>0&&Qe[kt-1].me>=K;)kt--;for(;kt<Qe.length&&Qe[kt].me<K;)kt++;let Y=ye=>ye&&K>=ye.ms&&K<=ye.me&&(K<ye.me||W===f.e||ye===L),he=Y(Qe[kt])?Qe[kt]:Y(Qe[kt+1])?Qe[kt+1]:Qe[kt]||Ot;if(!he)break;if(L===he){let ye=Yt.get(he);ye[ye.length-1].to=W-f.s;continue}L=he,Yt.has(he)||Yt.set(he,[]),Yt.get(he).push({node:f.node,from:W-f.s,to:W-f.s,flatStart:f.s})}}for(let f of Qe){let L=f.local,W=!1;for(let ye of L)for(let ve=ye.s;ve<ye.e&&!W;ve++)(ot[ve]<f.ms||ot[ve]>=f.me)&&(W=!0);d.set(f.node,{base:null,local:L.map(ye=>ye.node),remote:null,caret:Yt.get(f)||[],partial:W});let K=f.ms,Y=f.me-f.ms,he=ye=>{let ve=0,We=-1;for(let Re of L){let Fe=Re.e-Re.s;if(ye<=ve+Fe){We=Re.s+(ye-ve);break}ve+=Fe}return We<0&&(We=L.length?L[L.length-1].e:0),Math.max(0,Math.min(vt(We)-K,Y))};he.flat=ye=>Math.max(0,Math.min(vt(ye)-K,Y)),i.set(f.node,he)}function Kt(){if(!c.text.includes(Nt))return[{flatLocal:c.text,localNodes:c.nodes,textNodes:Qe,lToM:ot,mapLocal:vt}];let f=[],L=0,W=0;for(let K=0;K<=c.text.length;K++){if(K<c.text.length&&c.text[K]!==Nt)continue;let Y=L,he=K;if(he>Y){let ye=[];for(;W<c.nodes.length&&c.nodes[W].e<=Y;)W++;for(let ve=W;ve<c.nodes.length&&c.nodes[ve].s<he;ve++){let We=c.nodes[ve],Re=Math.max(We.s,Y),Fe=Math.min(We.e,he);Re<Fe&&ye.push({node:We.node,s:Re-Y,e:Fe-Y})}f.push({flatLocal:c.text.slice(Y,he),localNodes:ye,textNodes:Qe,lToM:ot.subarray?ot.subarray(Y,he+1):ot.slice(Y,he+1),mapLocal:ve=>vt(Y+Math.max(0,Math.min(ve,he-Y)))})}L=K+1}return f}let nn={...e,blocks:Kn,ignored:f=>yo.has(f)||(e.ignored?e.ignored(f):!1)},Vn=e.ignoreAttribute||(()=>!1),Yn=Gs(ln(dt,nn),Vn)!==Gs(g,Vn);if(h.length){let f=L=>{let W=d.get(L);return W&&W.unchanged?W.remote:null};a.text=ue,a.textNodes=Qe,a.out=ln(dt,{...nn,via:f})}let no=null;if(e.scopeUnits){no=new Map;let f=new Set(dt),L=ve=>{for(;ve&&!f.has(ve);)ve=ve.parentNode;return ve},W=e.scopeUnits.map(ve=>{let We=new Map;for(let Re of ve)if(Re.nodeType===1)We.set(Re,Re);else for(let Fe of Re.nodes)We.set(Fe,Re);return We}),K=(ve,We)=>{for(;ve&&!We.has(ve);)ve=ve.parentNode;return ve?We.get(ve):null},Y=[m,c,g].map((ve,We)=>{let Re=new Array(ve.text.length);for(let Fe of ve.nodes){let xt=K(Fe.node,W[We]);xt&&Re.fill(xt,Fe.s,Fe.e)}for(let Fe of ve.atoms)Re[Fe.i]=K(Fe.el,W[We]);return Re}),he=(ve,We)=>{if(!ve||!We)return;let Re=no.get(ve);Re||no.set(ve,Re=new Set),Re.add(We)};for(let ve of dt){let We=d.get(ve);We&&(he(K(We.base,W[0]),ve),he(K(We.local,W[1]),ve),he(K(We.remote,W[2]),ve))}for(let ve of Qe){let We=L(ve.node);for(let Re=ve.ms;Re<ve.me;Re++)he(Y[0][Ie[Re]],We),he(Y[1][Pe[Re]],We),he(Y[2][He[Re]],We)}let ye=new Map(dt.map((ve,We)=>[ve,We]));for(let[ve,We]of no)no.set(ve,Array.from(We).sort((Re,Fe)=>ye.get(Re)-ye.get(Fe)))}return{unitOutputs:no,nodes:dt,text:ue,textNodes:Qe,localDiverged:Yn,mapLocal:vt,conflicts:r.slice(u),granularity:V?"line":"word",segments:Kt(),localHunks:Ce,remoteHunks:be,lToM:ot}}var xs=Symbol("lost");function rr(){return{links:new Map,removed:new Set,consumed:new Set,link(e,o){this.links.set(e,o)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let o of e.nodes)this.removed.add(o)},consume(e){for(let o of e)this.consumed.add(o)}}}var sr=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function ir({locals:e,rec:o,root:t,provenance:n,segments:s,ignored:d}){let i=new Map,r=(T,x)=>{let A=i.get(T);A||i.set(T,A=new Set),A.add(x)},l=new Set,u=new Set;for(let T of s){let x=T.textNodes;for(let A of x)l.add(A.node);for(let A of T.localNodes){u.add(A.node);let E=0,S=null;for(let N=A.s;N<A.e;N++){let C=T.lToM[N];if(C<0)continue;for((!x[E]||C<x[E].ms)&&(E=0);E<x.length&&x[E].me<=C;)E++;let j=x[E]&&x[E].ms<=C?x[E].node:xs;j!==S&&r(A.node,j),S=j}}}let b=new Set,a=new Map,h=new Set;(function T(x){b.add(x);let A=n.get(x);if(x.nodeType===1)A&&A.local&&A.local.nodeType===1&&(r(A.local,x),A.unchanged&&h.add(A.local)),x.tagName==="TEMPLATE"&&x.content&&a.set(x.content,x);else if(A&&Array.isArray(A.local)&&!l.has(x))for(let E of A.local)r(E,x);for(let E=sr(x).firstChild;E;E=E.nextSibling)T(E)})(t);let p=new Set;for(let[T,x]of o.links)r(T,x),p.add(T);let v=T=>{let x=T.parentNode;return x&&x.nodeType===11?a.get(x)||null:x},O=(T,x)=>{for(let A=T;A;A=v(A))if(A===x)return!0;return!1},m=T=>o.removed.has(T)||o.consumed.has(T),c=T=>{for(let x=T.parentNode;x&&x.nodeType===1;x=x.parentNode){if(h.has(x))return"kept";if(m(x))return"decided";if(i.has(x))return null}return null},g=new Map;for(let T of e)g.set(T,P(T));return g;function P(T){let x=i.get(T);if(x&&(x.size!==1||x.has(xs)))return{kind:"unknown",reason:"several-outputs"};let A=x?x.values().next().value:null;if(A&&(A.nodeType!==1||!b.has(A)))return{kind:"unknown",reason:"output-not-placed"};if(!A){let C=m(T)?"decided":c(T);if(C==="kept")return{kind:"untouched"};if(C!=="decided")return{kind:"unknown",reason:"unmapped"}}let E=[],S=N(T,!!A&&(h.has(T)||p.has(T)),!A||m(T));if(S)return{kind:"unknown",reason:S};return A?{kind:"single",output:A,owned:E,carried:p.has(T)}:{kind:"removed"};function N(C,j,D){for(let B=sr(C).firstChild;B;B=B.nextSibling){if(B.nodeType===1?d(B):B.nodeType!==3&&B.nodeType!==8)continue;let w=i.get(B);if(w)for(let y of w){if(y===xs||!b.has(y))return"output-not-placed";if(!A)return"survives-elsewhere";if(!O(y,A))return"escaped";E.push(y)}else if(!j&&!D&&!m(B)&&!u.has(B))return"unmapped";if(B.nodeType===1){let y=N(B,j||h.has(B)||p.has(B),D||m(B));if(y)return y}}return null}}}function lr(e,o){if(!o)return!1;let t=o.nodeType===1&&o.tagName==="TEMPLATE"?[o,...o.querySelectorAll("template")]:[...o.querySelectorAll("template")];for(let n of t)if(n.content.contains(e)||lr(e,n.content))return!0;return!1}function ar(e,o){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 t=[],n=new Set;for(let s of Array.from(e.elements)){if(!s||s.nodeType!==1||s.ownerDocument!==o&&!lr(s,o.documentElement))throw new TypeError("lineage.elements must be elements of the live document");n.has(s)||(n.add(s),t.push(s))}return t}var cr=new WeakMap;function fr(e){let o=new Map;for(let t of e){let n=[],s=!1;(function d(i){i.nodeType===1&&i.namespaceURI==="http://www.w3.org/1999/xhtml"&&i.localName==="template"&&(s=!0);for(let r=i.firstChild;r;r=r.nextSibling)n.push(r),r.nodeType===1&&d(r)})(t),o.set(t,{nodes:n,opaque:s})}return o}function vs(e,o,t){if(e.lineage===void 0)return t(e);if(!o||o.nodeType!==1)throw new TypeError("lineage requires an element root");let n=e.lineage,s=ar(n,o.ownerDocument),d=!1,i={...e,lineage:{elements:s,onResult(r,l){if(!d)return d=!0,n.onResult(r,l)}}};try{return cr.set(i.lineage,fr(s)),t(i)}catch(r){if(!d){d=!0;try{n.onResult({version:1,root:o,status:"incomplete",entries:s.map(Nn)},null)}catch{}}throw r}}function Ts(e,{liveRoot:o,localRoot:t,toLive:n}){let s=ar(e,o.ownerDocument),d=u=>u===o||o.contains(u),i=new Map,r=new Set(s.filter(d));if(r.size&&t===o)for(let u of r)i.set(u,u);else r.size&&(function u(b){let a=n(b);r.delete(a)&&i.set(a,b);for(let h=b.firstElementChild;h&&r.size;h=h.nextElementSibling)u(h)})(t);return{spec:e,watched:s,root:o,locals:Array.from(new Set(i.values())),before:cr.get(e)||fr(s),delivered:!1,result:null,finish(u,b){return this.resolve=b,this.plans=u,this.result={version:1,root:this.root,status:"complete",entries:s.map(a=>Ui(a,i.get(a),u,b,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(u,b){this.root=b;let a=this.resolve,h=v=>{let O=a(v);return O===u?b:O};return this.finish(this.plans,h)},deliver(u){this.delivered||(this.delivered=!0,e.onResult(this.result,u))}}}var Nn=e=>({from:e,to:[],kind:"unknown",complete:!1});function Ui(e,o,t,n,s){let d=s.root,i=h=>!!h&&(h===d||d.contains(h)),r=o&&t?t.get(o):null;if(!r||r.kind==="unknown")return Nn(e);let l=s.before.get(e);if(!l||l.opaque)return Nn(e);let u=l.nodes,b=h=>i(h)||!!(h&&h.ownerDocument===d.ownerDocument&&d.ownerDocument.documentElement?.contains(h));if(r.kind==="untouched"){if(!i(e))return Nn(e);for(let h of u)if(b(h)&&!e.contains(h))return Nn(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(r.kind==="removed")return b(e)||u.some(b)?Nn(e):{from:e,to:[],kind:"removed",complete:!0};let a=n(r.output);if(!a||a.nodeType!==1||!i(a)||a!==e&&b(e))return Nn(e);for(let h of u)if(b(h)&&!a.contains(h))return Nn(e);for(let h of r.owned){let p=n(h),v=Array.isArray(p)?p:[p];for(let O of v)if(!O||!i(O)||!a.contains(O))return Nn(e)}return r.carried&&!ur(a,r.output,n)?Nn(e):{from:e,to:[a],kind:a===e?"retained":"replaced",complete:!0}}function ur(e,o,t){for(let n=o.firstChild;n;n=n.nextSibling){let s=t(n),d=Array.isArray(s)?s:[s];for(let i of d)if(!i||!e.contains(i))return!1;if(n.nodeType===1&&!ur(e,n,t))return!1}return!0}function No(e,o,t){let n=Ts(e,{liveRoot:o,localRoot:o,toLive:s=>s});return n.result={version:1,root:o,status:"complete",entries:n.watched.map(s=>Nn(s))},t.lineage=n.result,n}function dr(e,o,t,n,s){if(!s(e.length*8+1))return null;let d=0,i=o===0,r=!1;for(let l of fn(e,n)){if(!s(1))return null;if(d+=l.len,d===o&&(i=!0),d===t&&(r=!0),d>=t)break}return i&&r}function Vi(e,o,t,n,s,d,i){if(!i(o.length*2))return!1;let r=new Map,l=new Map,u=new Set;for(let b of o){let a=b.bs<b.be,h=a?t[b.ownerIndex].text.base:t[b.ownerIndex].text[e],p=a?b.bs:b.ss,v=a?b.be:b.se;if(!i((v-p)*4+1))return!1;for(;p<v&&/\s/.test(h[p]);)p++;for(;v>p&&/\s/.test(h[v-1]);)v--;if(p===v)continue;let O=h.slice(p,v),m=a?r:l;a&&b.text&&u.add(O),m.has(O)?m.set(O,null):m.set(O,{h:b,from:p,to:v})}for(let b of n){if(!i(1))return!1;if(b.side!==e)continue;let a=b.deletion,h=t[a.ownerIndex].text.base;if(!i((a.be-a.bs)*3)||u.has(h.slice(a.bs,a.be).trim()))return!1}for(let[b,a]of r){if(!i(b.length+1))return!1;let h=l.get(b);if(!a||!h)continue;let p=a.h,v=h.h;if(!p.text||p.transferOut||v.transferIn||p.owner===v.owner)continue;let O=t[p.ownerIndex],m=t[v.ownerIndex];if(!i(O.text.base.length))return!1;if(!/\S/.test(O.text.base.slice(0,p.bs)+O.text.base.slice(p.be)))continue;let c=dr(O.text.base,a.from,a.to,d,i),g=dr(m.text[e],h.from,h.to,d,i);if(c===null||g===null)return!1;if(!c||!g)continue;let P=`${O.index}:${a.from}:${a.to}`,T={key:P,side:e,source:p.owner,destination:v.owner,deletion:p,insertion:v,sourceOffset:a.from-p.bs,targetOffset:h.from-v.ss,length:a.to-a.from};p.transferOut=T,v.transferIn=T,s[e].set(P,T),n.push(T)}return!0}function hr({base:e,local:o,remote:t,localTwin:n,remoteTwin:s,eligible:d,nodes:i,budget:r=Xt(2e4*32)}){let l=S=>S>r.remaining?!1:(r.remaining-=S,r.nativeSteps=(r.nativeSteps||0)+S,!0);if(e.length<2||o.length!==e.length||t.length!==e.length||!l(e.length*12))return null;for(let[S,N]of[["base",e],["local",o],["remote",t]]){let C=i[S];if(C.length!==N.length||C.some((j,D)=>j!==N[D]))return null}let u=[],b=0;for(let S=0;S<e.length;S++){let N=e[S],C=o[S],j=t[S];if(n(N)!==C||s(N)!==j)return null;let D={};for(let[B,w]of[["base",N],["local",C],["remote",j]]){if(!d(w)||w.tagName!==N.tagName||w.namespaceURI!==N.namespaceURI||!l(w.childNodes.length+1))return null;let y="";for(let $ of w.childNodes){if($.nodeType!==3||!l($.data.length*4+1))return null;y+=$.data}if(y.includes(Nt)||(b+=y.length+1,b>2e4))return null;D[B]=y}u.push({base:N,local:C,remote:j,index:S,text:D})}let a=u.every(S=>xn(S.text.base,S.text.local,S.text.remote)),h={local:[],remote:[]};for(let S of u){S.hunks={local:[],remote:[]};for(let N of["local","remote"]){let C=S.text.base,j=S.text[N];if(C===j)continue;let D=C.length+j.length+4,B=D*8;if(!l(B))return null;let w=Math.floor(r.remaining/8),y=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(D*D+w)-D)/2)));if(y<1||!l(4*(y+1)*(D+y+1)))return null;let $=0;for(let U of _n(C,j,y)){if(!l(U.text.length+1))return null;let V=U.bs+$,Ne={...U,ss:V,se:V+U.text.length,toks:fn(U.text,a),owner:S.base,ownerIndex:S.index};S.hunks[N].push(Ne),h[N].push(Ne),$+=U.text.length-(U.be-U.bs)}}}let p=[],v={local:new Map,remote:new Map};for(let S of["local","remote"]){let N=new Map,C=new Map,j=!1,D=(B,w,y)=>{B.has(w)?B.set(w,null):B.set(w,y)};for(let B of h[S]){if(!l(1))return null;let w=u[B.ownerIndex].text.base;if(B.bs<B.be&&B.text===""){let y=w.slice(B.bs,B.be);if(!l(y.length*2))return null;/\S/.test(y)&&D(N,y,B)}else if(B.bs===B.be&&/\S/.test(B.text)){if(!l(B.text.length*2))return null;D(C,B.text,B)}else B.bs<B.be&&(j=!0)}for(let[B,w]of N){if(!l(B.length+1))return null;let y=C.get(B);if(!w||!y||w.owner===y.owner)continue;let $=u[w.ownerIndex];if(!l($.text.base.length))return null;if(!/\S/.test($.text.base.slice(0,w.bs)+$.text.base.slice(w.be)))continue;let U=`${$.index}:${w.bs}:${w.be}`,V={key:U,side:S,source:w.owner,destination:y.owner,deletion:w,insertion:y};w.transferOut=V,y.transferIn=V,v[S].set(U,V),p.push(V)}if(j&&C.size&&!Vi(S,h[S],u,p,v,a,l))return null}if(!p.length)return null;let O=(S,N)=>S.bs<N.be&&N.bs<S.be,m=S=>S.bs===S.be,c=(S,N)=>S.bs<=N.be&&N.bs<=S.be&&m(S)!==m(N),g=(S,N)=>S.bs===N.bs&&S.be===N.be&&S.text===N.text,P=(S,N)=>!!(S.transferIn||S.transferOut&&(!S.text||N.bs===S.be&&/\s/.test(N.text[0])||N.bs===S.bs&&/\s/.test(N.text[N.text.length-1])));for(let S of p){let N=S.side==="local"?"remote":"local",C=u[S.deletion.ownerIndex];for(let j of C.hunks[N])if(!l(1)||O(S.deletion,j)&&j.transferOut?.key!==S.key)return null}for(let S of u)for(let N of S.hunks.local)for(let C of S.hunks.remote){if(!l(1))return null;if(g(N,C)){if(N.transferIn?.key!==C.transferIn?.key)return null;continue}if(O(N,C)||c(N,C)&&!P(N,C)&&!P(C,N))return null}if(!l(b*8))return null;let T=new Set([...e,...o,...t]),x={base:ln(e,{blocks:T}),local:ln(o,{blocks:T}),remote:ln(t,{blocks:T})},A={};for(let S of["base","local","remote"]){let N=x[S];if(N.atoms.length||N.pins.length)return null;A[S]=new Map(N.marks.filter(C=>C.block).map(C=>[C.el,C.from]))}for(let S of u){let N=A.base.get(S.base);if(N===void 0)return null;for(let C of["local","remote"]){let j=A[C].get(S[C]);if(j===void 0)return null;for(let D of S.hunks[C])D.bs+=N,D.be+=N,D.ss+=j,D.se+=j}}for(let S of p)S.bs=S.deletion.bs+(S.sourceOffset||0),S.be=S.length===void 0?S.deletion.be:S.bs+S.length,S.ss=S.insertion.ss+(S.targetOffset||0),S.se=S.length===void 0?S.insertion.se:S.ss+S.length;let E={};for(let S of["local","remote"]){let N=0,C=0,j=[];for(let B of h[S]){if(!l(1))return null;B.bs>N&&j.push({from:N,to:B.bs,target:C}),N=B.be,C=B.se}N<x.base.text.length&&j.push({from:N,to:x.base.text.length,target:C});let D=p.filter(B=>B.side===S).map(B=>({from:B.bs,to:B.be,target:B.ss,destination:B.destination}));if(E[S]=Bn({base:x.base,side:x[S],retained:j,transfers:D,budget:r}),E[S].status!=="ready")return null}return l(x.base.text.length)?{owners:u,blocks:T,transfers:p,byOrigin:v,budget:r,prepared:{base:x.base,local:x.local,remote:x.remote,lines:!1,baseTokens:fn(x.base.text,a),localEdits:{hunks:h.local,respell:new Map},remoteEdits:{hunks:h.remote,respell:new Map},localMap:E.local,remoteMap:E.remote,full:null}}:null}var Ss=/\S/;function pr({certificates:e,scopes:o,views:t,eligible:n,baseId:s,limit:d=2e4*32}){let i=Xt(d),r=Symbol(),l=[],u=a=>{if(a>i.remaining)throw r;i.remaining-=a},b=(a,h=null)=>{if(u(1),!a||a.nodeType!==1||a.parentNode?.nodeType!==1||!n(a))return null;for(let O=a.parentNode;O;O=O.parentNode)if(u(1),O.nodeType===11)return null;let p="",v=0;for(let O of a.childNodes){if(u(1),O.nodeType!==3)return null;if(u(O.data.length*4+1),h){let m=h.flat.nodes[v++];if(!m||m.node!==O||m.s!==p.length||m.e!==p.length+O.data.length)return null}p+=O.data}return u(p.length*3+1),h&&(h.flat.atoms.length||h.flat.pins?.length||v!==h.flat.nodes.length||h.flat.text!==p)?null:Ss.test(p)?p:null};try{u(o[0].length+o[1].length+o[2].length+e.length);let a=o.map(p=>new Set(p)),h=new Map;for(let p of e){u(1);let v=h.get(p.source);v||h.set(p.source,v=[]),v.push(p)}for(let p of h.values()){let v=[null,null],O=[];for(let m of p){u(1);let{source:c,target:g,side:P,models:T,runs:x}=m;if(P!==0&&P!==1||!a[0].has(c)||!a[P+1].has(g))continue;let{V:A,A:E,idOf:S}=t[P],N=t[1-P],C=A.twin(c),j=N.V.twin(c),D=A.baseOf(g);if(!C||!j||!D||D===c||!a[0].has(D)||!a[P+1].has(C)||!a[2-P].has(j)||E.map.get(c)!==C||E.reverse.get(C)!==c||N.A.map.get(c)!==j||N.A.reverse.get(j)!==c||E.map.get(D)!==g||E.reverse.get(g)!==D||g.parentNode!==C.parentNode||D.parentNode!==c.parentNode||c.tagName!==C.tagName||c.tagName!==j.tagName||s(c)!==S(C)||s(c)!==N.idOf(j)||s(D)!==S(g))continue;let B=T.get(c),w=T.get(g);if(!B||!w)continue;let y=b(c,B),$=b(g,w),U=b(C),V=b(j);if(u((y?.length||0)+(V?.length||0)),y===null||$===null||U===null||V===null||V===y)continue;let Ne=x.length>0,Ae=!1;for(let oe of x){if(u(1),oe.source!==c||oe.target!==g||!Number.isInteger(oe.from)||!Number.isInteger(oe.to)||!Number.isInteger(oe.targetFrom)||oe.from<0||oe.to<=oe.from||oe.to>y.length||oe.targetFrom<0||oe.targetFrom+oe.to-oe.from>$.length){Ne=!1;break}u((oe.to-oe.from)*3);for(let xe=oe.from;xe<oe.to;xe++){if(y[xe]!==$[oe.targetFrom+xe-oe.from]){Ne=!1;break}Ss.test(y[xe])&&(Ae=!0)}if(!Ne)break}if(!Ne||!Ae)continue;let De=v[P];De||(u(y.length),De=v[P]={source:c,side:P,flat:B.flat,before:y,covered:new Uint8Array(y.length)});for(let oe of x)u(oe.to-oe.from),De.covered.fill(1,oe.from,oe.to)}for(let m of v){if(!m)continue;let{source:c,side:g,flat:P,before:T,covered:x}=m;u(T.length*3+1);let A=-1,E=-1;for(let S=0;S<=T.length;S++)S<T.length&&x[S]?(A<0&&(A=S),E=S+1):(S===T.length||Ss.test(T[S]))&&A>=0&&(O.push({source:c,side:g,flat:P,from:A,to:E}),A=E=-1)}u(O.length),l.push(...O)}}catch(a){if(a!==r)throw a}return{records:l,budget:i}}var Hi="http://www.w3.org/1999/xhtml";function Wi(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function mn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Hi}function Ki(e){let o=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return o==="application/json"||o.endsWith("+json")}function _o(e,o){let t=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let s=t;try{let d=new URL(t,o);s=d.origin+d.pathname+d.search}catch{}return"script|src|"+n+"|"+s}return"script|inline|"+n+"|"+Wi(e.textContent.trim())}var Fi={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function fo(e,o=[],t=!1){if(!mn(e)||e.hasAttribute("src"))return null;let n=[Fi,...o];for(let s=0;s<n.length;s++){let d=n[s];if(!d.match(e))continue;if(!Ki(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let i=d.identity(e);return i==null||i===""?null:{key:s+":"+i,raw:i,recognizer:d}}return null}function mr(e,o,t){let n=new Set,s=d=>{mn(d)&&!o(d)&&n.add(_o(d,t))};s(e);for(let d of e.querySelectorAll("script"))s(d);return n}function Ao(e,o){let t=o.createElement("div");t.innerHTML="<script><\/script>";let n=t.firstChild;for(let s of e.attributes)n.setAttribute(s.name,s.value);return n.textContent=e.textContent,n}function gr(e,o,t){let n=[],s=[],d=new Map,i=t.trackRecovery?new Set:null,r=Array.from(e.querySelectorAll("script"));mn(e)&&r.unshift(e);for(let l of r){if(!mn(l)||t.ignored(l)||t.skip.has(l)||o.has(_o(l,t.baseURI)))continue;let u=l.ownerDocument.createElement("script");for(let b of l.attributes)u.setAttribute(b.name,b.value);if(u.textContent=l.textContent,t.beforeNodeAdded(u)===!1){i?.add(l);continue}u.hasAttribute("src")&&s.push(new Promise(b=>{u.addEventListener("load",()=>b()),u.addEventListener("error",()=>b())})),l.replaceWith(u),d.set(l,u),t.afterNodeAdded(u),n.push(u)}return{executed:n,loads:s,swapped:d,vetoed:i}}function qi(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function _i(e,o){try{let t=new URL(e,o);return t.origin+t.pathname+t.search}catch{return e}}function br(e,o){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return _o(e,o);if(t==="LINK"){let n=e.getAttribute("href");return n?"link|"+(e.getAttribute("rel")||"")+"|"+_i(n,o):e.outerHTML}if(t==="META"){for(let n of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(n))return"meta|"+n+"="+e.getAttribute(n);return e.outerHTML}return t==="STYLE"?"style|"+qi(e.textContent):e.outerHTML}function Ns(e,o){for(;;){for(;o<e.length&&/\s/.test(e[o]);)o++;if(e[o]==="/"&&e[o+1]==="/"){for(;o<e.length&&e[o]!==`
4
+ `;)o++;continue}if(e[o]==="/"&&e[o+1]==="*"){let t=e.indexOf("*/",o+2);if(t===-1)return e.length;o=t+2;continue}return o}}function wr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(o,t)=>t.length%2===0?t+'\\"':o)}var zi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,$i=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function zo(e){try{return JSON.parse(e)}catch{return JSON.parse(Gi(e))}}function Gi(e){let o="",t=0,n=(s,d)=>{throw new Error(`Invalid relaxed JSON: ${s} at position ${d}`)};for(;t<e.length&&(t=Ns(e,t),!(t>=e.length));){let s=e[t];if("{}[]:".includes(s)){o+=s,t++;continue}if(s===","){let r=Ns(e,t+1);if(e[r]==="}"||e[r]==="]"){t++;continue}o+=s,t++;continue}if(s==='"'||s==="'"){let r=t+1;for(;r<e.length&&e[r]!==s;)e[r]==="\\"&&r++,r++;r>=e.length&&n("unterminated string",t);let l=e.slice(t+1,r);s==="'"&&(l=wr(l)),o+='"'+l+'"',t=r+1;continue}let d=t;for(;d<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[d]);)d++;d===t&&n("unexpected character "+JSON.stringify(s),t);let i=e.slice(t,d);if(i==="true"||i==="false"||i==="null"||zi.test(i)){o+=i,t=d;continue}if($i.test(i)){if(e[Ns(e,d)]===":"){o+='"'+i+'"',t=d;continue}n("unquoted value "+JSON.stringify(i),t)}n("invalid token "+JSON.stringify(i),t)}return o}function yr(e){try{return JSON.parse(e)}catch{}let o={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(s){let d=[],i=0;for(;i<s.length;){let r=s[i];if(/\s/.test(r)){i++;continue}if("{}".includes(r)){d.push({type:r,value:r}),i++;continue}if(r==="["){let a=!1,h=i+1;for(;h<s.length&&/\s/.test(s[h]);)h++;if(h<s.length&&/[a-zA-Z_]/.test(s[h])&&(a=!0),!a){d.push({type:r,value:r}),i++;continue}}if(r==="]"){d.push({type:r,value:r}),i++;continue}if(r===":"){d.push({type:o.COLON,value:r}),i++;continue}if(r===","){d.push({type:o.COMMA,value:r}),i++;continue}if(r==='"'||r==="'"){let a=r,h=i+1;for(;h<s.length&&s[h]!==a;)s[h]==="\\"&&h++,h++;d.push({type:o.STRING,value:s.substring(i+1,h),quoted:!0,sourceQuote:a}),i=h+1;continue}let l=i,u;for(;l<s.length&&!/[{},]/.test(s[l]);)if(s[l]===":"){let a=[":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"],h=!1;for(let p of a){let v=p.substring(1);if(s.substring(l+1,l+1+v.length)===v){h=!0,l+=v.length;break}}if(!h)break}else if(s[l]==="["){for(l++;l<s.length&&s[l]!=="]";){if(s[l]==='"'||s[l]==="'"){let a=s[l];for(l++;l<s.length&&s[l]!==a;)s[l]==="\\"&&l++,l++}l++}l<s.length&&s[l]==="]"&&l++}else l++;u=s.substring(i,l);let b=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?b=o.NUMBER:u==="true"||u==="false"||u==="null"?b=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(b=o.SELECTOR),d.push({type:b,value:u,quoted:!1}),i=l}return d}function n(s){let d="";for(let i=0;i<s.length;i++){let r=s[i];if("{}".includes(r.type)||"[]".includes(r.type)){d+=r.value;continue}if(r.type===o.COLON){d+=r.value;continue}if(r.type===o.COMMA){let l=s[i+1];if(l&&(l.type==="}"||l.type==="]"))continue;d+=r.value;continue}if(r.type===o.STRING){let l=r.value;r.sourceQuote==="'"&&(l=wr(l)),d+=`"${l}"`;continue}if(r.type===o.NUMBER||r.type===o.BOOLEAN){d+=r.value;continue}d+=`"${r.value}"`}return d}try{let s=t(e),d=n(s);return JSON.parse(d)}catch(s){throw new Error("Invalid extraction rules syntax: "+s.message)}}var Qt=Symbol("hyper-morph-json-merge:missing"),kr=["id","_id","uuid","key","slug","code","name"];function uo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mo(e,o){return Object.prototype.hasOwnProperty.call(e,o)}function Yi(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}function zn(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o)){if(e.length!==o.length)return!1;for(let t=0;t<e.length;t++)if(!zn(e[t],o[t]))return!1;return!0}if(uo(e)&&uo(o)){let t=Object.keys(e);if(t.length!==Object.keys(o).length)return!1;for(let n of t)if(!Mo(o,n)||!zn(e[n],o[n]))return!1;return!0}return!1}function xr(e,o,t,n){return zn(o,t)?o:zn(o,e)?t:zn(t,e)?o:uo(o)&&uo(t)?Xi(uo(e)?e:{},o,t,n):Array.isArray(o)&&Array.isArray(t)?el(Array.isArray(e)?e:[],o,t,n):t}function vr(e,o,t,n){return o===Qt&&t===Qt?Qt:o===Qt?e===Qt?t:zn(t,e)?Qt:t:t===Qt?e===Qt?o:Qt:xr(e,o,t,n)}function Xi(e,o,t,n){let s={},d=new Set([...Object.keys(e),...Object.keys(o),...Object.keys(t)]);for(let i of d){let r=vr(Mo(e,i)?e[i]:Qt,Mo(o,i)?o[i]:Qt,Mo(t,i)?t[i]:Qt,n);r!==Qt&&Yi(s,i,r)}return s}function Ji(e){return e===null||typeof e!="object"}function $o(e){return typeof e+":"+String(e)}function Qi(e,o){for(let t of o){let n=new Set;for(let s of t){if(!Mo(s,e))return!1;let d=s[e];if(typeof d!="string"&&typeof d!="number")return!1;let i=$o(d);if(n.has(i))return!1;n.add(i)}}return!0}function Zi(e,o,t,n){let s=[e,o,t],d=!0;for(let i of s)for(let r of i)uo(r)||(d=!1);if(d){for(let i of n.keyCandidates)if(Qi(i,s))return{kind:"keyed",field:i};return null}for(let i of s){let r=new Set;for(let l of i){if(!Ji(l))return null;let u=$o(l);if(r.has(u))return null;r.add(u)}}return{kind:"self"}}function el(e,o,t,n){let s=Zi(e,o,t,n);if(!s)return t;let d=s.kind==="self"?$o:p=>$o(p[s.field]),i=p=>{let v=new Map;for(let O of p)v.set(d(O),O);return v},r=i(e),l=i(o),u=i(t),b=new Map,a=new Set([...r.keys(),...l.keys(),...u.keys()]);for(let p of a){let v=vr(r.has(p)?r.get(p):Qt,l.has(p)?l.get(p):Qt,u.has(p)?u.get(p):Qt,n);v!==Qt&&b.set(p,v)}let h=[];for(let p of t){let v=d(p);b.has(v)&&h.push(v)}for(let p=0;p<o.length;p++){let v=d(o[p]);if(!b.has(v)||h.includes(v))continue;let O=0;for(let m=p-1;m>=0;m--){let c=h.indexOf(d(o[m]));if(c!==-1){O=c+1;break}}h.splice(O,0,v)}return h.map(p=>b.get(p))}function As(e,o,t,n={}){let s=n.keyCandidates?[...n.keyCandidates,...kr]:kr;return xr(e===void 0?Qt:e,o,t,{keyCandidates:s})}function Go(e,o,t,n={}){let s=n.parse||zo,d=[],i=(a,h)=>{if(typeof a!="string")return Qt;try{return s(a)}catch(p){return d.push(`${h} side is not valid JSON (${p.message})`),Qt}},r=i(o,"local"),l=i(t,"remote");if(r===Qt)return{text:t,warnings:d};if(l===Qt)return{text:o,warnings:d};let u=i(e,"base"),b=As(u===Qt?void 0:u,r,l,n);return zn(b,l)?{text:t,warnings:d}:zn(b,r)?{text:o,warnings:d}:{text:JSON.stringify(b,null,2),warnings:d}}var Tr=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Zn(e){if(!e)return!1;let{startContainer:o,startOffset:t,endContainer:n,endOffset:s}=e;if(!o||!n||!Number.isInteger(t)||!Number.isInteger(s)||t<0||s<0||t>Tr(o)||s>Tr(n)||o.getRootNode()!==n.getRootNode())return!1;let d=o.ownerDocument.createRange();return d.setStart(o,t),d.setEnd(n,s),d.startContainer===o&&d.startOffset===t}function $n(e,o,t={}){if(!Zn(e))return null;let{startContainer:n,startOffset:s,endContainer:d,endOffset:i}=e;if(n===d&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(s,i);if(n===d&&s===i)return"";let r=new Set;for(let m=n;m;m=m.parentNode)r.add(m);let l=d;for(;!r.has(l);)l=l.parentNode;let u=(m,c)=>{let g=l.ownerDocument.createRange(),P=l.ownerDocument.createRange();return g.setStart(m[0],m[1]),g.collapse(!0),P.setStart(c[0],c[1]),P.collapse(!0),g.compareBoundaryPoints(0,P)},b=(m,c=!1)=>[m.parentNode,Array.prototype.indexOf.call(m.parentNode.childNodes,m)+Number(c)],a=[],h;if(o==="plain"){h="";let m=c=>{if(c.nodeType===3||c.nodeType===8){let g=h.length;h+=c.nodeValue,a.push({s:g,e:h.length,a:[c,0],b:[c,c.nodeValue.length],node:c})}else for(let g of c.childNodes)m(g)};m(l)}else{let m=t.blocks;if(!m){m=new Set;let g=P=>{P!==l&&P.nodeType===1&&ys.has(P.tagName)&&m.add(P);for(let T of P.childNodes)g(T)};g(l)}let c=ln(Array.from(l.childNodes),{blocks:m,atomize:g=>!!t.atoms?.has(g),ignored:t.ignored});h=c.text;for(let g of c.nodes)a.push({s:g.s,e:g.e,a:[g.node,0],b:[g.node,g.e-g.s],node:g.node});for(let g of c.atoms)a.push({s:g.i,e:g.i+1,a:b(g.el),b:b(g.el,!0)});for(let g=0;g<c.text.length;g++){if(c.text[g]!==Nt)continue;let P=c.marks.find(x=>x.block&&x.to===g+1),T=c.marks.find(x=>x.block&&x.from===g+1);if(P)a.push({s:g,e:g+1,a:[P.el,P.el.childNodes.length],b:b(P.el,!0)});else if(T)a.push({s:g,e:g+1,a:b(T.el),b:[T.el,0]});else return null}}a.sort((m,c)=>m.s-c.s);let p=m=>{if(m[0].nodeType===3||m[0].nodeType===8){let g=a.find(P=>P.node===m[0]);return g?g.s+m[1]:null}let c=0;for(let g of a){if(u(m,g.a)<=0)return g.s;if(u(m,g.b)<0)return null;c=g.e}return c},v=p([n,s]),O=p([d,i]);return v!==null&&O!==null&&v<=O?h.slice(v,O):null}function Qn(e,o){let t=e;for(let n of o.path)if(t=n==="content"?t?.content:t?.childNodes[n],!t)return null;return[t,o.offset]}function Sr(e,o){if(!e||!o)return null;let t=Qn(e,o.start),n=Qn(e,o.end);return t&&n?{startContainer:t[0],startOffset:t[1],endContainer:n[0],endOffset:n[1]}:null}var Nr=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ar(e,o,t){if(!o)return;let n=new Map,s=new Map,d=r=>{if(!r)return null;if(s.has(r))return s.get(r);let u=r.local.map(b=>Qn(o.localRoot,{path:b,offset:0})?.[0]).map(b=>b&&t(b)).filter(Boolean).map(b=>({node:b,parent:b.parentNode,previous:b.previousSibling,next:b.nextSibling,fragment:Nr(b)}));return s.set(r,u),u},i=r=>{let l=Sr(o.localRoot,r);if(!l)return null;let u=t(l.startContainer),b=t(l.endContainer);if(!u||!b)return null;let a={...l,startContainer:u,endContainer:b};return Zn(a)?a:null};for(let r of e){let l=r.recovery;if(!l||n.has(l))continue;let u={subject:d(l.subject),span:null,scope:null,touched:new Set};if(l.text){u.span=i(l.text.local.span),u.scope=i(l.text.local.scope);let b=u.span;if(b){let a=b.startContainer.ownerDocument.createRange();a.setStart(b.startContainer,b.startOffset),a.setEnd(b.endContainer,b.endOffset);let h=p=>{if(a.intersectsNode(p)){u.touched.add(p);for(let v of p.childNodes)h(v)}};h(a.commonAncestorContainer)}}if(l.structure){for(let b of[l.structure.localPlacement])b&&(d(b.parent),b.before.forEach(d),b.after.forEach(d));for(let b of l.structure.localOrder||[])d(b)}n.set(l,u)}o.localState={states:n,refs:s}}function Mr(e,o,t,n){let s=t.localState?.states.get(e);if(!s)return!1;let d=r=>{let l=r.node;if(!n(l)||l.parentNode!==r.parent)return!1;let u=b=>Array.prototype.indexOf.call(l.parentNode.childNodes,b);return!(r.previous&&n(r.previous)&&r.previous.parentNode===l.parentNode&&u(r.previous)>=u(l)||r.next&&n(r.next)&&r.next.parentNode===l.parentNode&&u(r.next)<=u(l))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!s.subject.length||!s.subject.every(d))return!1;if(e.text){let r=e.text.local,l=u=>u&&n(u.startContainer)&&n(u.endContainer);return l(s.span)&&l(s.scope)&&$n(s.scope,e.text.encoding)===r.text&&$n(s.span,e.text.encoding)===r.text.slice(r.start,r.end)}if(e.attribute){let r=e.attribute,l=s.subject[0].node;return(r.namespaceURI?l.getAttributeNS(r.namespaceURI,r.localName):l.getAttribute(r.qualifiedName))===o.local}let i=e.structure;if(i.localOrder){let r=-1,l=null;for(let u of i.localOrder){let b=t.localState.refs.get(u)?.[0]?.node;if(!b||!n(b)||l&&b.parentNode!==l)return!1;let a=Array.prototype.indexOf.call(b.parentNode.childNodes,b);if(a<=r)return!1;l=b.parentNode,r=a}return!0}return i.localAction==="moved"||s.subject.every(r=>Nr(r.node)===r.fragment)}var tl=1,hn=e=>!!e&&e.nodeType===1,Yo=e=>hn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function eo(e,o=null,t=null){let n=new Map,s=new Map,d=b=>{if(!o){o=new WeakMap;let a=[e];for(;a.length;){let h=a.pop();Yo(h)&&(o.set(h.content,h),a.push(h.content));for(let p=h.firstChild;p;p=p.nextSibling)p.nodeType===1&&a.push(p)}}return o.get(b)||null},i=(b,a)=>{let h=s.get(b);if(!h){h=new Map;let p=0;for(let v=b.firstChild;v;v=v.nextSibling)h.set(v,p++);s.set(b,h)}return h.get(a)},r=b=>{if(!b)return null;if(t&&t.has(b))return r(t.get(b));if(b===e)return[];let a=n.get(b);if(a!==void 0)return a;let h=b.parentNode,p=null;if(h&&h.nodeType===11){let v=d(h),O=v?r(v):null;O&&(p=O.concat(["content",i(h,b)]))}else if(h){let v=r(h);v&&(p=v.concat([i(h,b)]))}return n.set(b,p),p};return{root:e,pathOf:r,logicalParent:b=>{let a=b.parentNode;return a&&a.nodeType===11?d(a):a},indexIn:i,containerPath:b=>{if(b.nodeType===11){let h=d(b),p=r(h);return p?p.concat(["content"]):null}let a=r(b);return a&&Yo(b)?a.concat(["content"]):a},ownerOf:d}}var Cn=e=>Yo(e)?e.content:e;function Or(e){let{L:o,R:t,unitsOf:n,provenance:s,policy:d}=e,i=[];return{note:(b,a)=>{i.push([b,a])},finish:b=>i.length?u(b):null};function u(b){let a={base:eo(e.roots.base),local:eo(e.roots.local),remote:eo(e.roots.remote)},h=M=>M==="local"?o:t,p=(M,R)=>{if(!R)return null;if(M.map.has(R))return M.map.get(R);let z=[],J=hn(R)?a.base.logicalParent(R):R.parent;for(;J&&!M.map.has(J);J=a.base.logicalParent(J))z.push(J);if(!J||!M.identical.has(J))return null;let ne=M.map.get(J);for(let je=z.length-1;je>=0&&ne;je--)ne=Cn(ne).childNodes[a.base.indexIn(z[je].parentNode,z[je])];return ne?hn(R)?Cn(ne).childNodes[a.base.indexIn(R.parentNode,R)]||null:n(ne)[n(R.parent).indexOf(R)]||null:null},v=new Map,O=new Map,m=new WeakMap,c=0,g=(M,R)=>{let z=v.get(M);z||v.set(M,z=[]),z.push(R)};(function M(R){O.set(R,c++);let z=s.get(R);if(z&&!z.pinned){for(let J of[z.base,z.local,z.remote])if(J)if(Array.isArray(J))for(let ne of J)g(ne,R);else g(J,R)}if(Yo(R)){m.set(R.content,R);for(let J=R.content.firstChild;J;J=J.nextSibling)M(J)}for(let J=R.firstChild;J;J=J.nextSibling)M(J)})(b);let P=new Map;a.out=eo(b,m,P);let T={refs:new Map,spans:new Map,anchors:new Map,via:P,outOwners:m,outRoot:b,localRoot:e.roots.local},x=M=>hn(M)?[M]:M.nodes,A=(M,R)=>{let z=a[R].logicalParent(M);if(!z)return null;for(let J of n(z))if(!hn(J)&&J.nodes.includes(M))return J;return null},E=(M,R)=>M==null?null:Array.isArray(M)?M.length?A(M[0],R):null:M,S=M=>{let R=new Set,z=[];for(let J of M)for(let ne of v.get(J)||[])R.has(ne)||(R.add(ne),z.push(ne));return z.sort((J,ne)=>O.get(J)-O.get(ne))},N=new Map,C=M=>{let R=M.b||M.l||M.r,z=N.get(R);if(z)return z;let J=[];for(let ne of[M.b,M.l,M.r])ne&&J.push(...x(ne));return z=S(J),N.set(R,z),z},j=M=>({b:M,l:p(o,M),r:p(t,M)}),D=(M,R)=>{let z=h(R).reverse.get(M);if(z)return j(z);for(let J of S(x(M))){let ne=s.get(J);if(ne&&!ne.base&&ne.local&&ne.remote)return{b:null,l:E(ne.local,"local"),r:E(ne.remote,"remote")}}return R==="local"?{b:null,l:M,r:null}:{b:null,l:null,r:M}},B=new Map,w=M=>{let R=s.get(M);if(!R||R.pinned)return null;let z=E(R.base,"base");if(z)return j(z);let J=E(R.local,"local"),ne=E(R.remote,"remote");if(J){let je=o.reverse.get(J);if(je)return j(je)}if(ne){let je=t.reverse.get(ne);if(je)return j(je)}return J||ne?{b:null,l:J,r:ne}:null},y=M=>(B.has(M)||B.set(M,w(M)),B.get(M)),$=(M,R)=>hn(M)?a[R].logicalParent(M):M.parent,U=new Map,V=new Map,Ne=(M,R)=>(hn(M)?[a[R].pathOf(M)]:M.nodes.map(z=>a[R].pathOf(z))).filter(Boolean),Ae=M=>{let R=M.b||M.l||M.r,z=M.b?"base":M.l?"local":"remote",J=V.get(R);if(J)return J;let ne=!hn(R),je=Ne(R,z)[0],Q=`${z[0]}:${JSON.stringify(je===void 0?null:je)}${ne?":run":""}`,Oe=U.get(Q);if(Oe)return V.set(R,Oe),Oe;let Ve=C(M);return Oe={key:Q,nodeType:hn(R)?1:R.kind==="comment"?8:3,base:M.b?Ne(M.b,"base"):[],local:M.l?Ne(M.l,"local"):[],remote:M.r?Ne(M.r,"remote"):[],merged:Ve.map(Ce=>a.out.pathOf(Ce)).filter(Boolean),live:[]},U.set(Q,Oe),V.set(R,Oe),T.refs.set(Oe,Ve),Oe},De={base:new Map,local:new Map,remote:new Map},oe=new Map,xe=(M,R)=>{let z=$(M,R);if(!z||z.nodeType!==1)return null;let J=De[R].get(z);if(!J){let je=n(z),Q=Oe=>Ae(R==="base"?j(Oe):D(Oe,R));J={parent:Q(z),refs:je.map(Q),index:new Map(je.map((Oe,Ve)=>[Oe,Ve]))},De[R].set(z,J)}let ne=J.index.get(M)??-1;return{parent:J.parent,before:J.refs.slice(ne+1),after:J.refs.slice(0,Math.max(0,ne)).reverse()}},$e=M=>{let R=M.parentNode;if(!R)return null;let z=oe.get(R);if(!z){let ne=R.nodeType===11?m.get(R):R,je=ne&&ne.nodeType===1?y(ne):null;if(!je)return null;let Q=[],Oe=[],Ve=new Map;for(let be of R.childNodes){let H=y(be),X=H&&Ae(H),de=Q.length,pe=Q.length-1;X&&X!==Q[pe]&&(Q.push(X),pe++);let se={ref:X,group:pe,after:de};Oe.push(se),Ve.set(be,se)}let Ce=Q.length;for(let be=Oe.length-1;be>=0;be--){let H=Oe[be];H.before=Ce,H.ref&&(Ce=H.group)}z={parent:Ae(je),refs:Q,index:Ve},oe.set(R,z)}let J=z.index.get(M);return{parent:z.parent,before:z.refs.slice(J.before),after:z.refs.slice(0,J.after).reverse()}},ae=M=>hn(M)?M.outerHTML:M.value,k=M=>hn(M)?"element":M.kind==="comment"?"comment":"text",_=(M,R)=>({path:M,offset:R}),re=(M,R,z)=>{if(!M)return null;let J=a[z],ne=0;if(R){let je=hn(R)?R:R.nodes[R.nodes.length-1];je.parentNode&&(ne=J.indexIn(je.parentNode,je)+1)}return _(J.containerPath(M),ne)},Z=(M,R)=>{let z=$(M,"base"),J=z?p(h(R),z):null;if(!hn(J))return null;let ne=n(z),je=null;for(let Q=ne.indexOf(M)-1;Q>=0&&!je;Q--){let Oe=p(h(R),ne[Q]);Oe&&$(Oe,R)===J&&(je=Oe)}return re(J,je,R)},Be=(M,R,z,J)=>{let ne=a[J],je=0;for(let Q=0;Q<M.nodes.length;Q++){let Oe=M.nodes[Q],Ve=Oe.nodeValue.length,Ce=Q===M.nodes.length-1;if((z==="start"?R<je+Ve:R<=je+Ve)||Ce)return _(ne.pathOf(Oe),Math.max(0,Math.min(R-je,Ve)));je+=Ve}return null},Ke=(M,R)=>{let z=a[R],J=M.firstChild,ne=M.lastChild;return J&&J.nodeType===3&&ne.nodeType===3?{start:_(z.pathOf(J),0),end:_(z.pathOf(ne),ne.nodeValue.length)}:{start:_(z.pathOf(M),0),end:_(z.pathOf(M),M.childNodes.length)}},Te=(M,R,z)=>{for(let Q of M.nodes)if(z==="start"?Q.s<=R&&R<Q.e:Q.s<R&&R<=Q.e)return{kind:"text",node:Q.node,offset:R-Q.s};let J=z==="start"?R:R-1,ne=()=>{for(let Q of M.nodes)if(Q.s===R||Q.e===R)return{kind:"text",node:Q.node,offset:R-Q.s};return null},je=M.atomAt.get(J);if(je)return{kind:z==="start"?"before":"after",node:je.el};if(M.text[J]===Nt){let Q=M.marks.find(Ve=>Ve.block&&Ve.to===J+1);if(Q)return z==="start"?{kind:"end",node:Q.el}:{kind:"after",node:Q.el};let Oe=M.marks.find(Ve=>Ve.block&&Ve.from===J+1);if(Oe)return z==="start"?{kind:"before",node:Oe.el}:{kind:"startOf",node:Oe.el}}return ne()},it=(M,R)=>Te(M,R,"end")||Te(M,R,"start"),et=(M,R)=>{switch(R.kind){case"text":return _(M.pathOf(R.node),R.offset);case"end":return _(M.containerPath(R.node),Cn(R.node).childNodes.length);case"startOf":return _(M.containerPath(R.node),0);default:{let z=R.node.parentNode;return _(M.containerPath(z),M.indexIn(z,R.node)+(R.kind==="after"?1:0))}}},mt=(M,R,z,J,ne)=>{let je=Te(M,R,z);return je?et(a[J],je):ne()},Ze=(M,R,z,J)=>{let ne=M.textNodes.map(Ce=>({s:Ce.ms,e:Ce.me,start:{kind:"text",node:Ce.node,offset:0},end:{kind:"text",node:Ce.node,offset:Ce.me-Ce.ms}}));for(let[Ce,be]of M.atomOut)ne.push({s:Ce,e:Ce+1,start:{kind:"before",node:be},end:{kind:"after",node:be}});for(let[Ce,be]of M.breakOut)ne.push({s:Ce,e:Ce+1,start:{kind:"end",node:be},end:{kind:"after",node:be}});for(let Ce of ne)if(Ce.start.kind==="text"&&Ce.s<R&&R<Ce.e)return{kind:"text",node:Ce.start.node,offset:R-Ce.s};if(z!=="empty"){let Ce=ne.find(be=>z==="start"?be.s===R:be.e===R);if(Ce)return z==="start"?Ce.start:Ce.end}let je=ne.find(Ce=>Ce.e===R);if(je)return je.end;let Q=ne.find(Ce=>Ce.s===R);if(Q)return Q.start;let Oe=null,Ve=null;for(let Ce of ne)Ce.e<=R&&(!Oe||Ce.e>Oe.e)&&(Oe=Ce),Ce.s>=R&&(!Ve||Ce.s<Ve.s)&&(Ve=Ce);return Oe?Oe.end:Ve?Ve.start:J()},ft=(M,R)=>{if(!R)return null;if(R.kind==="text"){let ne=M.nodes.find(je=>je.node===R.node);return ne?ne.s+Math.min(R.offset,ne.e-ne.s):null}let z=M.atoms.find(ne=>ne.el===R.node);if(z)return R.kind==="after"?z.i+1:z.i;let J=M.marks.find(ne=>ne.el===R.node);return J?R.kind==="before"&&J.block&&M.text[J.from-1]===Nt&&!M.marks.some(ne=>ne.block&&ne.to===J.from)?J.from-1:R.kind==="startOf"||R.kind==="before"?J.from:R.kind==="end"&&J.block?J.to-1:J.to:null},Ct=(M,R,z,J)=>{for(let Oe of M.nodes)if(z==="start"?Oe.s<=R&&R<Oe.e:Oe.s<R&&R<=Oe.e)return{kind:"text",node:Oe.node,offset:R-Oe.s};let ne=z==="start"?R:R-1;if(!M.atomAt.has(ne)&&M.text[ne]!==Nt){for(let Oe of M.nodes)if(Oe.s===R||Oe.e===R)return{kind:"text",node:Oe.node,offset:R-Oe.s}}let je=M.atomAt.get(ne);if(je)return{kind:z==="start"?"before":"after",node:je.el};if(M.text[ne]===Nt){let Oe=M.marks.find(Ce=>Ce.block&&Ce.to===ne+1);if(Oe)return z==="start"?{kind:"end",node:Oe.el}:{kind:"after",node:Oe.el};let Ve=M.marks.find(Ce=>Ce.block&&Ce.from===ne+1);if(Ve)return z==="start"?{kind:"before",node:Ve.el}:{kind:"startOf",node:Ve.el}}let Q=M.marks.find(Oe=>Oe.block&&Oe.from===R);return Q?{kind:"startOf",node:Q.el}:J?{kind:z==="start"?"startOf":"end",node:J}:null},Dt=M=>{if(!M)return null;if(M.kind==="wholeStart"||M.kind==="wholeEnd"){let R=Tt(M.node);return M.kind==="wholeStart"?R.start:R.end}return et(a.out,M)},Tt=M=>{let R=M.firstChild,z=M.lastChild;return R&&R.nodeType===3&&z.nodeType===3?{start:_(a.out.pathOf(R),0),end:_(a.out.pathOf(z),z.nodeValue.length)}:{start:_(a.out.pathOf(M),0),end:_(a.out.pathOf(M),M.childNodes.length)}},Rt=M=>{let R=$(M,"base"),z=R?C(j(R))[0]:null;if(!z)return null;let J=Cn(z),ne=n(R);for(let je=ne.indexOf(M)-1;je>=0;je--){let Q=C(j(ne[je])).filter(Oe=>Oe.parentNode===J);if(Q.length)return{kind:"after",node:Q[Q.length-1]}}return{kind:"startOf",node:z}},jt=(M,R,z,J,ne,je)=>({text:M,start:R,end:z,fragment:J,span:ne,scope:je}),qt=(M,R,z,J,ne)=>jt(M,R,z,M.slice(R,z),J,ne),un=(M,R,z,J,ne)=>(T.spans.set(M,{start:R,end:z,scopeStart:J,scopeEnd:ne}),M),Lt=new Map,Jt=new Map,F=(M,R,z)=>{let J=`text:${M.key}:${R}:${z}`,ne=Jt.get(J)||0;return Jt.set(J,ne+1),`${J}:${ne}`},ce=(M,R)=>{let z,J,ne,je="plain",Q,Oe,Ve,Ce,be,H=(pe,se,ke,fe,G)=>{if(!pe){let ue=Z(G,fe);return qt("",0,0,{start:ue,end:ue},{start:ue,end:ue})}return qt(pe.value,se,ke,{start:Be(pe,se,se===ke?"end":"start",fe),end:Be(pe,ke,"end",fe)},{start:Be(pe,0,"start",fe),end:Be(pe,pe.value.length,"end",fe)})};if(R.site==="run"){let{bRun:pe,lRun:se,rRun:ke,node:fe,c:G}=R;z=j(pe),J=G.bs,ne=G.be,Q=H(pe,G.bs,G.be,"base",pe),Oe=H(se,G.ls,G.le,"local",pe),Ve=H(ke,G.rs,G.re,"remote",pe);let ue=fe?fe.nodeValue:"",Ie=Pe=>fe?{kind:"text",node:fe,offset:Pe}:Rt(pe);Ce=un(qt(ue,G.ms,G.me,{start:Dt(Ie(G.ms)),end:Dt(Ie(G.me))},{start:Dt(Ie(0)),end:Dt(Ie(ue.length))}),Ie(G.ms),Ie(G.me),Ie(0),Ie(ue.length)),be=fe||(Rt(pe)||{}).node||null}else if(R.site==="whole"){let pe=R.el,se=s.get(pe);z=j(se.base),J=0,ne=M.base.length;let ke=(G,ue,Ie)=>{let Pe=Ke(ue,Ie);return qt(G,0,G.length,Pe,Pe)};Q=ke(M.base,se.base,"base"),Oe=ke(M.local,se.local,"local"),Ve=ke(M.remote,se.remote,"remote");let fe=Tt(pe);Ce=un(qt(M.resolved,0,M.resolved.length,fe,fe),{kind:"wholeStart",node:pe},{kind:"wholeEnd",node:pe},{kind:"wholeStart",node:pe},{kind:"wholeEnd",node:pe}),be=pe}else if(R.site==="comment"){let{bRun:pe,lRun:se,rRun:ke,node:fe}=R;z=j(pe),J=0,ne=M.base.length;let G=(He,Se)=>{if(!He){let ot=Z(pe,Se);return qt("",0,0,{start:ot,end:ot},{start:ot,end:ot})}let Je=He.nodes[0],nt={start:_(a[Se].pathOf(Je),0),end:_(a[Se].pathOf(Je),He.value.length)};return qt(He.value,0,He.value.length,nt,nt)};Q=G(pe,"base"),Oe=G(se,"local"),Ve=G(ke,"remote");let ue=M.resolved,Ie=He=>fe?{kind:"text",node:fe,offset:He}:Rt(pe),Pe={start:Dt(Ie(0)),end:Dt(Ie(ue.length))};Ce=un(qt(ue,0,ue.length,Pe,Pe),Ie(0),Ie(ue.length),Ie(0),Ie(ue.length)),be=fe||(Rt(pe)||{}).node||null}else{let{fb:pe,fl:se,fr:ke,scope:fe}=R,G=R.merged;je="html",z=fe.base?j(fe.base):D(fe.local,"local"),J=M.bs,ne=M.be;let ue=ee=>{let Ee=fe[ee];for(let Ue=fe.at-1;Ue>=0;Ue--){let _e=fe.units[Ue],Ye=ee==="base"?_e:p(h(ee),_e);if(Ye&&$(Ye,ee)===Ee)return Ye}return null},Ie=ee=>()=>re(fe[ee],ue(ee),ee),Pe=(ee,Ee,Ue,_e,Ye)=>{let yt=pn=>pn?et(a[Ye],pn):Ie(Ye)(),gt=Ee===Ue?it(ee,Ee):Te(ee,Ee,"start"),$t=Ee===Ue?it(ee,Ee):Te(ee,Ue,"end"),_t=yt(gt),dn={start:_t,end:Ee===Ue?_t:yt($t)},vt=R.full?R.full(Ye):null;if(!vt)return jt(ee.text,Ee,Ue,_e,dn,{start:yt(Te(ee,0,"start")),end:yt(Te(ee,ee.text.length,"end"))});let dt=gt?ft(vt,gt):null,Qe=$t?ft(vt,$t):null,Mt=dt===null?0:dt,bt=Math.max(Mt,Qe===null?vt.text.length:Qe),Ht=yt(Te(vt,0,"start"));return jt(vt.text,Mt,bt,lo(vt,Mt,bt),dn,{start:Ht,end:vt.text.length?yt(Te(vt,vt.text.length,"end")):Ht})};Q=R.synthetic?null:Pe(pe,M.bs,M.be,M.base,"base"),Oe=Pe(se,M.lss,M.lse,M.local,"local"),Ve=Pe(ke,M.rss,M.rse,M.remote,"remote");let[He,Se]=M.range||[0,0],Je=G.out,nt=()=>{let ee=Cn(G.node);for(let Ee=fe.at-1;Ee>=0;Ee--){let Ue=C(j(fe.units[Ee])).filter(_e=>_e.parentNode===ee);if(Ue.length)return{kind:"after",node:Ue[Ue.length-1]}}for(let Ee=fe.at;Ee<fe.units.length;Ee++){let Ue=C(j(fe.units[Ee])).filter(_e=>_e.parentNode===ee);if(Ue.length)return{kind:"before",node:Ue[0]}}return{kind:"startOf",node:G.node}};if(Je.via)for(let[ee,Ee]of Je.via)P.set(ee,Ee);let ot=Ze(G,He,He===Se?"empty":"start",nt),Wt=He===Se?ot:Ze(G,Se,"end",nt),Ut=Je.text.length?Ct(Je,0,"start",G.node):nt(),I=Je.text.length?Ct(Je,Je.text.length,"end",G.node):Ut,q=ft(Je,ot),te=ft(Je,Wt),me=q===null?0:q,we=Math.max(me,te===null?Je.text.length:te);Ce=un(jt(Je.text,me,we,lo(Je,me,we),{start:Dt(ot),end:Dt(Wt)},{start:Dt(Ut),end:Dt(I)}),ot,Wt,Ut,I);let ie=T.spans.get(Ce);if(ie.flat=Je,!Je.text.length){let ee=Dt(Ut),Ee=Qn(b,ee),Ue=Ee[0],_e=Ee[1];ie.empty={parent:Ue.nodeType===11?m.get(Ue):Ue,previous:Ue.childNodes[_e-1]||null,next:Ue.childNodes[_e]||null}}be=ot?ot.node:G.node}let X=Ae(z),de=(R.site==="whole"||R.site==="comment"||(R.policy||d)!=="both")&&M.resolved!==M.local;return{key:R.site==="comment"&&Lt.get(z.b||z.l||z.r)||F(X,J,ne),subject:X,localLost:de,anchor:be,text:{encoding:je,base:Q,local:Oe,remote:Ve,merged:Ce,liveSpan:null,liveScope:null}}},ge=(M,R)=>{let z=y(R.el),J=Ae(z),ne=R.sample;return{key:`attr:${J.key}:${ne.namespaceURI||""}:${ne.localName}`,subject:J,localLost:M.resolved!==M.local,anchor:R.el,attribute:{namespaceURI:ne.namespaceURI||null,localName:ne.localName,qualifiedName:ne.name}}},Le=(M,R)=>{let z=M.detail,J=R.unit||j(R.subject),ne=Ae(J),je=T.refs.get(ne),Q=J.l?xe(J.l,"local"):null,Oe=J.r?xe(J.r,"remote"):null,Ve=je.length?$e(je[0]):null,Ce,be,H,X=null,de=null,pe=R.deleted;switch(z){case"both-reordered":{Ce=be="reordered";let se=new Set(R.rKept),ke=R.lKept.filter(Pe=>se.has(Pe)&&C(j(Pe)).length),fe=Pe=>O.get(C(j(Pe))[0]);X=ke.map(Pe=>Ae(j(Pe))),de=ke.slice().sort((Pe,He)=>fe(Pe)-fe(He)).map(Pe=>Ae(j(Pe)));let G=Pe=>!hn(Pe)&&Pe.kind!=="comment"&&Pe.nodes.every(He=>!/[^\t\n\f\r ]/.test(He.data)),ue=ke.filter(Pe=>!G(Pe)),Ie=ue.slice().sort((Pe,He)=>fe(Pe)-fe(He));H=ue.some((Pe,He)=>Pe!==Ie[He]);break}case"both-moved":Ce=be="moved",H=!Q||!je.some(se=>{let ke=se===je[0]?Ve:$e(se);return ke&&ke.parent===Q.parent});break;case"edit-beats-delete":Ce=pe==="local"?"deleted":"edited",be=pe==="remote"?"deleted":"edited",H=pe==="local";break;case"move-beats-delete":Ce=pe==="local"?"deleted":"moved",be=pe==="remote"?"deleted":"moved",H=pe==="local";break;case"remote-wins":Ce="edited",be="edited",H=!0;break;default:Ce=be="inserted",H=R.localLost}return{key:`structure:${ne.key}:${z}`,subject:ne,localLost:H,anchor:je[0]||null,structure:{localAction:Ce,remoteAction:be,localPlacement:Q,remotePlacement:Oe,mergedPlacement:Ve,localOrder:X,mergedOrder:de,localFragment:z==="both-reordered"||!J.l?null:ae(J.l),fragmentKind:k(J.b||J.l||J.r)}}};for(let[M,R]of i){if(M.kind!=="structure")continue;let z=R.unit||j(R.subject),J=z.b||z.l||z.r;!hn(J)&&J.kind==="comment"&&Lt.set(J,`structure:${Ae(z).key}:${M.detail}`)}let Me=new Map;for(let[M,R]of i){if(M.kind==="structure"){let je=Ae(R.unit||j(R.subject)),Q=`structure:${je.key}:${M.detail}`,Oe=Me.get(Q);if(Oe&&Oe.structure){M.recovery=Oe;let Ve=T.refs.get(je);M.el==null&&Ve.length&&(M.el=hn(Ve[0])?Ve[0]:a.out.logicalParent(Ve[0]));continue}}let z=M.kind==="text"?ce(M,R):M.kind==="attr"?ge(M,R):Le(M,R),J=Me.get(z.key);J||(J={version:tl,key:z.key,localLost:z.localLost,subject:z.subject,applied:!1,unavailable:null},Me.set(z.key,J),T.anchors.set(J,z.anchor)),z.text&&(J.text=z.text),z.attribute&&(J.attribute=z.attribute),z.structure&&(J.structure=z.structure),z.text&&(J.localLost=z.localLost),M.recovery=J;let ne=T.refs.get(z.subject);M.kind==="structure"&&M.el==null&&ne.length&&(M.el=hn(ne[0])?ne[0]:a.out.logicalParent(ne[0])),M.kind==="text"&&M.node==null&&ne.length&&z.subject.nodeType===8&&(M.node=ne[0])}return T}}function Ir(e,o,t){if(!o)return;let{lookup:n,vetoed:s,vetoedAttrs:d,liveAttr:i}=t,r=t.ignored||(()=>!1),l=eo(t.liveRoot),u=w=>!!w&&l.containerPath(w)!==null,b=w=>{let y=w.parentNode;return y&&y.nodeType===11?o.outOwners.get(y)||null:y},a=w=>{for(let y=w;y;y=b(y))if(o.via.has(y)&&(y=o.via.get(y)),s.has(y)||t.vetoedLive?.has(c(y)))return!0;return!1},h=w=>Array.from(Cn(w).children).filter(y=>!r(y)),p=(w,y)=>h(w)[h(y.parentNode).indexOf(y)],v=(w,y)=>{let $=null,U=null,V=0;for(let oe=y.previousSibling;oe;oe=oe.previousSibling){if(oe.nodeType===1&&!r(oe)){$=oe;break}oe.nodeType===3&&(V+=oe.nodeValue.length)}for(let oe=y.nextSibling;oe&&!U;oe=oe.nextSibling)oe.nodeType===1&&!r(oe)&&(U=oe);let Ne=$?p(w,$):null,Ae=U?p(w,U):null;if($&&!Ne||U&&!Ae)return null;let De=[];for(let oe=Ne?Ne.nextSibling:Cn(w).firstChild;oe&&oe!==Ae;oe=oe.nextSibling)oe.nodeType===3&&De.push(oe);return De.length?{nodes:De,lead:V}:null},O=w=>{let y=[],$=w;for(;$&&!o.via.has($);$=$.parentNode)y.push($);if(!$||!y.length)return null;let U=c(o.via.get($));for(let Ae=y.length-1;Ae>0&&U;Ae--)U=p(U,y[Ae]);if(!U)return null;let V=y[0];if(V.nodeType===3)return v(U,V);let Ne=V.nodeType===1?p(U,V):null;return Ne?{nodes:[Ne],lead:0}:null},m=w=>{let y=n(w),$=y?{nodes:Array.isArray(y)?y:[y],lead:0}:o.via.size?O(w):null;if(!$)return null;let U=$.nodes.filter(u);return U.length?{nodes:U,lead:$.lead}:null},c=w=>{let y=m(w);return y?y.nodes[0]:null},g=w=>{if(!w)return null;if(w.kind==="text"){let V=m(w.node);if(!V)return null;let Ne=V.nodes,Ae=w.offset+V.lead,De=0;for(let oe=0;oe<Ne.length;oe++){let xe=Ne[oe].nodeValue.length;if(Ae<=De+xe||oe===Ne.length-1)return Ae>=De&&Ae<=De+xe?[Ne[oe],Ae-De]:null;De+=xe}return null}let y=c(w.node);if(!y)return null;if(w.kind==="end")return[Cn(y),Cn(y).childNodes.length];if(w.kind==="startOf")return[Cn(y),0];if(w.kind==="wholeStart")return y.firstChild?[y.firstChild,0]:[y,0];if(w.kind==="wholeEnd")return y.lastChild?[y.lastChild,y.lastChild.nodeValue.length]:[y,y.childNodes.length];let $=y.parentNode;if(!$)return null;let U=Array.prototype.indexOf.call($.childNodes,y);return[$,w.kind==="after"?U+1:U]},P=w=>({blocks:new Set((w.flat?.marks||[]).filter(y=>y.block).map(y=>c(y.el)).filter(Boolean)),atoms:new Set((w.flat?.atoms||[]).map(y=>c(y.el)).filter(Boolean)),ignored:r}),T=(w,y,$,U)=>{if(!w||!y||!Zn(w)||!Zn(y))return!1;for(let Ae of[w,y])if(!u(Ae.startContainer)||!u(Ae.endContainer))return!1;let V=$.merged;if(V.start===V.end&&(w.startContainer!==w.endContainer||w.startOffset!==w.endOffset))return!1;let Ne=P(U);return $n(y,$.encoding,Ne)===V.text&&$n(w,$.encoding,Ne)===V.text.slice(V.start,V.end)},x=new Map,A=w=>{let y=w.parentNode;return y?(x.has(y)||x.set(y,new Map(Array.from(y.childNodes,($,U)=>[$,U]))),x.get(y).get(w)):-1},E=(w,y)=>{if(!y)return!1;let $=l.logicalParent(w);if(!y.parent.live.includes($))return!1;let U=A(w);for(let[V,Ne]of[["before",1],["after",-1]]){let Ae=U;for(let De of y[V]){if(De.live.includes(w))continue;let oe=De.live.filter($e=>$e!==w&&$e.parentNode===w.parentNode);if(!oe.length)continue;let xe=Ne===1?Math.min(...oe.map(A)):Math.max(...oe.map(A));if(Ne*(xe-Ae)<=0)return!1;Ae=xe}}return!0},S=w=>{let y=w.structure;if(y.mergedOrder){let $=new Set(w.subject.live.map(Cn)),U=null,V=-1;for(let Ne of y.mergedOrder){let Ae=Ne.live.find(De=>$.has(De.parentNode));if(!Ae||U&&Ae.parentNode!==U||A(Ae)<=V)return!1;U=Ae.parentNode,V=A(Ae)}return w.subject.live.length>0}return w.subject.live.some($=>E($,y.mergedPlacement))},N=(w,y)=>{let $=g(w),U=g(y);return $&&U?{startContainer:$[0],startOffset:$[1],endContainer:U[0],endOffset:U[1]}:null},C=new Set,j=w=>{if(!w||C.has(w))return;C.add(w);let y=[];for(let $ of o.refs.get(w)||[]){let U=m($);if(U)for(let V of U.nodes)y.includes(V)||y.push(V)}w.live=y},D=w=>{w&&(j(w.parent),w.before.forEach(j),w.after.forEach(j))},B=new Set;for(let w of e){let y=w.recovery;if(!y||B.has(y))continue;B.add(y),j(y.subject),y.structure&&(D(y.structure.localPlacement),D(y.structure.remotePlacement),D(y.structure.mergedPlacement),(y.structure.localOrder||[]).forEach(j),(y.structure.mergedOrder||[]).forEach(j));let $=o.anchors.get(y),U=$?c($):null,V=!!U;if(y.text){let k=o.spans.get(y.text.merged),_=k?N(k.start,k.end):null,re=k?N(k.scopeStart,k.scopeEnd):null;if(k?.empty){let Z=k.empty,Be=Z.previous?{kind:"after",node:Z.previous}:{kind:"startOf",node:Z.parent},Ke=Z.next?{kind:"before",node:Z.next}:{kind:"end",node:Z.parent},Te=N(Be,Ke);!Te||Te.startContainer!==Te.endContainer||Te.startOffset!==Te.endOffset?_=null:_=re=Te}T(_,re,y.text,k)||(_=re=null),y.text.liveSpan=_,y.text.liveScope=_?re:null,_||(V=!1)}y.structure&&V&&(V=S(y)),y.attribute&&V&&(V=i(U,y.attribute,w.resolved));let Ne=(!!y.attribute||!!y.text&&U?.tagName==="TEXTAREA")&&!!d&&[$,U].some(k=>d.get(k)?.has(y.attribute?y.attribute.qualifiedName:"value")),Ae=o.localState?.states.get(y),De=!!y.text&&[...t.removedVetoes||[]].some(k=>Ae?.touched.has(k)),oe=y.structure?.localAction==="inserted"&&[...s].some(k=>k===$||$?.contains(k)),xe=$&&a($)||Ne||De||oe,$e=xe&&Mr(y,w,o,u);$e&&(De||oe&&y.localLost)&&(V=!1);let ae=!V&&$e&&xe;y.applied=V,y.unavailable=V?null:ae?"hook-veto":"missing-output",ae&&(y.localLost=!1),!V&&y.text&&(y.text.liveSpan=y.text.liveScope=null)}}function Xo(e,o,t){let n=eo(o),s=eo(t),d=a=>!!a&&s.containerPath(a)!==null,i=a=>{if(a===o)return t;let h=n.pathOf(a);if(h&&o!==t){let p=Qn(t,{path:h,offset:0});if(p&&p[0].nodeType===a.nodeType)return p[0]}return a},r=new Set,l=a=>{!a||r.has(a)||(r.add(a),a.live=a.live.map(i).filter(d))},u=a=>{a&&(a.startContainer=i(a.startContainer),a.endContainer=i(a.endContainer))},b=new Set;for(let a of e){a.node===o&&t.tagName==="SCRIPT"&&(a.node=t),a.el===o&&a.kind==="structure"&&(a.el=t);let h=a.recovery;if(!h||b.has(h))continue;if(b.add(h),l(h.subject),h.text){u(h.text.liveSpan),u(h.text.liveScope);let v=h.text.liveSpan,O=h.text.liveScope,m=h.text.merged,c=g=>!!g&&Zn(g)&&d(g.startContainer)&&d(g.endContainer);(!c(v)||!c(O)||$n(O,h.text.encoding)!==m.text||$n(v,h.text.encoding)!==m.text.slice(m.start,m.end))&&(h.text.liveSpan=null,h.text.liveScope=null,h.applied=!1,h.unavailable="missing-output")}let p=h.structure;if(p){for(let v of[p.localPlacement,p.remotePlacement,p.mergedPlacement])v&&(l(v.parent),v.before.forEach(l),v.after.forEach(l));(p.localOrder||[]).forEach(l),(p.mergedOrder||[]).forEach(l),h.subject.live.length||(h.applied=!1,h.unavailable="missing-output")}}}var ho=e=>e?.nodeType===1,Oo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function nl({provenance:e,parentOf:o,twins:t,baseOf:n,build:s,ignored:d,remoteWins:i,discarded:r}){let l=new Map,u=new WeakMap;function b(p,v,O,m=!1){if(!ho(p)||!ho(O))return null;let c=l.get(p);if(c)(m||!c.selected&&v==="remote")&&(c.parent=o(O),c.port=O,c.sourceSide=v,c.selected=m);else{let g=u.get(p)||null;c={owner:p,parent:o(O),port:O,sourceSide:v,originalParent:o(p),originalPort:p,selected:m,state:g?"built":"planned",output:g,disposition:null},l.set(p,c)}return c}function a(p,v){if(!ho(p)||!ho(v))return;u.has(p)||u.set(p,v);let O=l.get(p);O&&O.state!=="attached"&&!O.output&&(O.output=v,O.state="built")}function h(p){if(!l.size)return;let v=new Map,O=new WeakMap,m=new WeakMap,c=new WeakSet,g=new Set,P=(D,B)=>{if(!D)return;if(Array.isArray(D)){for(let y of D)P(y,B);return}let w=v.get(D);w||v.set(D,w=[]),w.push(B)},T=(D,B)=>{if(!D)return;let w=[D];for(;w.length;){let y=w.pop();P(y,B);for(let $ of Oo(y).childNodes)w.push($)}};function x(D,B=null,w=!1){if(c.has(D))return;c.add(D),O.set(D,B);let y=e.get(D),$=w||!!(y&&i(y.remote||y.base));m.set(D,$);let U={node:D,kind:"node",authority:$};if(y?.pinned)T(y.local,{...U,kind:"ignored"});else if(y?.unchanged)for(let V of[y.base,y.local,y.remote])T(V,{...U,kind:"unchanged"});else if(y){for(let V of[y.base,y.local,y.remote])P(V,U);if(ho(y.local))for(let V of Oo(y.local).children)d(V)&&T(V,{...U,kind:"ignored"})}for(let V of Oo(D).childNodes)x(V,D,$)}let A=D=>{if(D.output&&c.has(D.output))return D.state="attached",D.disposition="node",!0;let{local:B,remote:w}=t(D.owner);for(let y of[D.owner,B,w]){let $=v.get(y);if($?.length){let U=$.find(V=>V.kind==="node")||$[0];return D.output=U.node,D.state="attached",D.disposition=U.kind,!0}}return!1},E=(D,B)=>(v.get(D)||[]).find(y=>y.kind==="node"&&ho(y.node)&&(!y.authority||B.sourceSide==="remote"))?.node,S=(D,B,w)=>{let y=v.get(D)||[],$=w?[...y].reverse():y;for(let U of $){if(U.kind!=="node")continue;let V=U.node;for(;V&&O.get(V)!==B;)V=O.get(V);if(V)return V}return null},N=(D,B,w)=>{let y=Oo(B);for(let $=w?.previousSibling;$;$=$.previousSibling){let U=S($,B,!0);if(U){y.insertBefore(D,U.nextSibling);return}}for(let $=w?.nextSibling;$;$=$.nextSibling){let U=S($,B,!1);if(U){y.insertBefore(D,U);return}}y.appendChild(D)};function C(D,B,w){let y=B==="base"?D:n(D,B),$=l.get(y);$&&$!==w&&j($)}function j(D){if(D.state==="attached"||D.disposition==="remote-wins"||g.has(D)||A(D))return;g.add(D);let{local:B,remote:w}=t(D.owner);if(i(w||D.owner)){if(!w){D.disposition="remote-wins",r(D.owner,B),g.delete(D);return}D.parent=o(w),D.port=w,D.sourceSide="remote"}if(C(D.parent,D.sourceSide,D),A(D)){g.delete(D);return}let y=E(D.parent,D),$=D.port;if(!y){if(C(D.originalParent,"base",D),A(D)){g.delete(D);return}let V=D.originalParent;for($=D.originalPort;V&&!y;)y=E(V,D),y||($=V,V=o(V))}if(!y)throw new Error("A planned move has no allowed surviving parent");let U=D.output||s(D.owner);D.output=U,D.state="built",N(U,y,$),x(U,y,m.get(y)||!1),A(D),g.delete(D)}x(p);for(let D of l.values())j(D)}return{planned:l,has:p=>l.has(p),plan:b,produced:a,drain:h}}function po(e,o,t,n,s,d,i,r,l,u,b,a,h){let p=null;return nl({provenance:e,parentOf:m=>{if(!m)return null;let c=o(m);if(c||m.parentNode?.nodeType!==11)return c;if(!p){p=new WeakMap;let g=[a,h];for(;g.length;){let P=g.pop(),T=Oo(P);T!==P&&p.set(T,P);for(let x of T.children)g.push(x)}}return p.get(m.parentNode)||null},twins:m=>({local:s(t,m),remote:s(n,m)}),baseOf:(m,c)=>m&&(c==="local"?t:n).reverse.get(m)||null,build:m=>d(m,s(t,m),s(n,m),!1),ignored:i,remoteWins:r,discarded:(m,c)=>{c&&b(m,c,t)&&!l.some(g=>g.detail==="remote-wins"&&g.base===m)&&u({kind:"structure",el:null,detail:"remote-wins",base:m,local:c,remote:null},{subject:m})}})}function ol({parent:e,base:o,views:t,eligible:n,ignored:s,remoteWins:d,budget:i=Xt(2e4*32),maxUnits:r=256,maxCharacters:l=2e4}){let u=(c,g=null)=>({status:c,reason:g,parent:e,records:[]});if(t.some(({V:c})=>c.asBase)||s(e)||d(e)||t.some(({V:c})=>!c.el||s(c.el)||d(c.el)))return u("none");let b=o.length+t[0].V.units.length+t[1].V.units.length;if(b>r)return u("fallback","unit-limit");let a=Symbol(),h=c=>{if(c>i.remaining)throw a;i.remaining-=c,i.crossParentSteps=(i.crossParentSteps||0)+c},p=new Map,v=0,O=c=>{if(h(1),p.has(c))return p.get(c);let g=c.nodeType===1?c.childNodes:c.nodes;h(g.length*4+1);let P=c.nodeType===1?Array.from(g):g,T=0;for(let E=0;E<P.length;E++){let S=P[E];if(S.nodeType!==3||E&&P[E-1].nextSibling!==S)return p.set(c,null),null;T+=S.data.length}if(T>l-v)throw a;h(T*8+1),v+=T;let x=ln(P);if(x.text.includes(Nt))return p.set(c,null),null;let A={unit:c,nodes:P,flat:x};return p.set(c,A),A},m=[];try{h(b*8+1);for(let c=0;c<2;c++){let g=t[c].V,P=t[1-c].V,T=[],x=new Map;for(let A=0;A<o.length;A++){h(1);let E=o[A];if(E.kind!=="text"||g.twin(E))continue;let S=P.twin(E);if(!S||S.kind!=="text"||!P.here(S))continue;let N=O(E),C=O(S);if(!N||!C||!/\S/.test(N.flat.text))continue;h(N.flat.text.length*2+1);let j=N.flat.text;x.set(j,(x.get(j)||0)+1),T.push({source:E,opposite:S,sourceModel:N,oppositeModel:C,index:A})}for(let A of T){let{source:E,opposite:S,sourceModel:N,oppositeModel:C,index:j}=A,D=[];for(let _ of[-1,1]){h(1);let re=o[j+_];if(!re||re.nodeType!==1||!n(re)||s(re)||d(re))continue;let Z=N.nodes[0],Be=N.nodes.at(-1);if(_===-1?Z?.previousSibling!==re:Be?.nextSibling!==re)continue;let Ke=g.twin(re),Te=P.twin(re);if(!Ke||!Te||!g.here(Ke)||P.here(Te)||g.baseOf(Ke)!==re||P.baseOf(Te)!==re||!n(Ke)||!n(Te)||s(Ke)||s(Te)||d(Ke)||d(Te)||Ke.tagName!==re.tagName||Te.tagName!==re.tagName||Ke.namespaceURI!==re.namespaceURI||Te.namespaceURI!==re.namespaceURI)continue;let it=O(re),et=O(Ke),mt=O(Te);if(!it||!et||!mt||!/\S/.test(it.flat.text))continue;let Ze=it.flat.text,ft=N.flat.text,Ct=et.flat.text;if(h((Ze.length+ft.length+Ct.length)*3+1),Ct.length!==Ze.length+ft.length)continue;let Dt=_===-1;(Dt?!Ct.startsWith(Ze)||!Ct.endsWith(ft):!Ct.startsWith(ft)||!Ct.endsWith(Ze))||D.push({owner:re,target:Ke,moved:Te,ownerBase:it,joined:et,ownerOther:mt,targetFrom:Dt?Ze.length:0,retainedFrom:Dt?0:ft.length})}if(!D.length)continue;if(D.length!==1||x.get(N.flat.text)!==1)return u("fallback","ambiguous-origin");let B=D[0],{owner:w,target:y,moved:$,ownerBase:U,joined:V,ownerOther:Ne,targetFrom:Ae,retainedFrom:De}=B;if(h(m.length+1),m.some(_=>_.owner===w))return u("fallback","ambiguous-owner");let oe={source:E,target:y,from:0,to:N.flat.text.length,targetFrom:Ae},xe=Bn({base:N.flat,side:V.flat,retained:[],transfers:[{from:oe.from,to:oe.to,target:Ae,destination:w}],budget:i});if(xe.status!=="ready"||xe.covers(oe.from,oe.to)!==!0)return u("fallback",xe.reason||"work-limit");let $e=[{unit:E,model:N,from:0,to:N.flat.text.length},null,null];$e[c+1]={unit:y,model:V,from:Ae,to:Ae+N.flat.text.length},$e[2-c]={unit:S,model:C,from:0,to:C.flat.text.length};let ae=[U,null,null];ae[c+1]=V,ae[2-c]=Ne;let k=[w,null,null];k[c+1]=y,k[2-c]=$,m.push({side:c,parent:e,source:E,target:y,owner:w,owners:k,ownerModels:ae,native:$e,models:p,runs:[oe],proof:xe,retained:[{source:w,target:y,from:0,to:U.flat.text.length,targetFrom:De}]})}}return m.length?{status:"ready",reason:null,parent:e,records:m}:u("none")}catch(c){if(c!==a)throw c;return u("fallback","work-limit")}}function Er({describe:e,parentOf:o,...t}){let n=new WeakMap,s=new WeakMap,d=t.budget||Xt(2e4*32),i=r=>{if(!r)return null;if(n.has(r))return n.get(r);n.set(r,{status:"planning",parent:r,records:[]});let l=e(r),u=l?ol({...t,...l,parent:r,budget:d}):{status:"none",reason:null,parent:r,records:[]};if(n.set(r,u),u.status==="ready")for(let b of u.records)s.set(b.owner,[b]);return u};return{get:i,forOwner(r){return i(o(r))?.status==="ready"&&s.get(r)||null}}}function sl(e,o){if(e.side!==0)return null;let t=e.native[0].model,n=e.ownerModels[0],s=e.native[1].from!==0,d=(P,T)=>s?[...P.nodes,...T.nodes]:[...T.nodes,...P.nodes],i=e.ownerModels.reduce((P,T)=>P+T.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(i*8>o.remaining)return null;o.remaining-=i*8;let r={base:d(n,t),local:e.ownerModels[1].nodes,remote:d(e.ownerModels[2],e.native[2].model)},l=ln(r.base),u=e.ownerModels[1].flat,b=ln(r.remote),a=s?n.flat.text.length:0,h=s?0:t.flat.text.length,p=Bn({base:l,side:u,retained:e.retained.map(P=>({from:h+P.from,to:h+P.to,target:P.targetFrom})),transfers:e.runs.map(P=>({from:a+P.from,to:a+P.to,target:P.targetFrom,destination:e.owner})),budget:o});if(p.status!=="ready"||p.covers(0,l.text.length)!==!0)return null;let v=e.ownerModels[2].flat,O=e.native[2].model.flat,m=[];for(let[P,T,x,A]of[[n.flat,v,h,s?0:O.text.length],[t.flat,O,a,s?v.text.length:0]]){let E=ks(P,P,T).remoteMap.bTo,S=-1;for(let N=0;N<P.text.length;N++){if(E[N]<0){S=-1;continue}let C=m.at(-1);S>=0&&C.to===x+N&&C.target+C.to-C.from===A+E[N]?C.to++:(m.push({from:x+N,to:x+N+1,target:A+E[N]}),S=N)}}let c=Bn({base:l,side:b,retained:m,transfers:[],budget:o});if(c.status!=="ready")return null;let g=ks(l,u,b,{},{local:p,remote:c});return g.localEdits.hunks.length?null:(g.localMap=p,g.remoteMap=c,{nodes:r,prepared:g})}function Cr({L:e,R:o,twinIn:t,unitsOf:n,view:s,parentOf:d,ignored:i,remoteWins:r,eligible:l,build:u,out:b,policy:a,provenance:h,textMappers:p,segments:v,conflicts:O,conflict:m,decisions:c}){let g=Xt(2e4*32),P=D=>{let B=0;for(let w=D;w;w=d(w))if(++B>64||w.nodeType===1&&(i(w)||r(w)))return!1;return!0},T=Er({parentOf:d,eligible:l,ignored:i,remoteWins:r,budget:g,describe(D){let B=t(e,D),w=t(o,D);return!B||!w||!P(D)||!P(B)||!P(w)?null:{base:n(D),views:[{A:e,V:s(e,B,D,!1)},{A:o,V:s(o,w,D,!1)}]}}}),x=new WeakSet,A=new WeakMap,E=new WeakSet,S=[];function N(D){if(!D||x.has(D))return;x.add(D);let B=T.get(D);if(B?.status==="ready")for(let w of B.records){if((D.tagName==="TEMPLATE"&&D.content?D.content:D).childNodes.length!==w.native[0].model.nodes.length+1||!w.owners.every(P))continue;let $=sl(w,g);if(!$)continue;let U={record:w,payload:$,state:"planned",output:null,result:null};A.set(w.owner,U),E.add(w.source),E.add(w.native[2].unit),S.push(U)}}function C(D,B){let w=A.get(D);if(!w)return!1;if(!w.result){if(w.result=Fo({...w.payload.nodes,prepared:w.payload.prepared,out:b,policy:a,provenance:h,textMappers:p,conflicts:O,conflict:m,decisions:c,node:B}),w.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");v.push(...w.result.segments),w.decision={kind:"text",node:B,source:"local"},c.push(w.decision)}return w.decision.node=B,B.replaceChildren(...w.result.nodes),w.output=B,w.state="built",!0}function j(D){if(!S.length)return;let B=new WeakSet,w=new WeakMap,y=new WeakMap,$=new WeakMap,U=xe=>xe.tagName==="TEMPLATE"&&xe.content?xe.content:xe,V=(xe,$e)=>{if(!xe)return;if(Array.isArray(xe)){for(let k of xe)V(k,$e);return}let ae=$.get(xe);ae||$.set(xe,ae=[]),ae.push($e)},Ne=(xe,$e=null,ae=!1)=>{B.add(xe),w.set(xe,$e);let k=h.get(xe),_=ae||!!(k&&r(k.remote||k.base));if(y.set(xe,_),k)for(let re of[k.base,k.local,k.remote])V(re,xe);if(!(k?.pinned||k?.unchanged))for(let re of U(xe).childNodes)Ne(re,xe,_)},Ae=xe=>($.get(xe)||[]).find($e=>$e.nodeType===1&&!y.get($e)&&!h.get($e)?.pinned&&!h.get($e)?.unchanged),De=(xe,$e)=>{for(let ae of $.get(xe)||[]){let k=ae;for(;k&&w.get(k)!==$e;)k=w.get(k);if(k)return k}return null},oe=(xe,$e,ae)=>{let k=U($e);for(let _=ae.nextSibling;_;_=_.nextSibling){let re=De(_,$e);if(re){k.insertBefore(xe,re);return}}for(let _=ae.previousSibling;_;_=_.previousSibling){let re=De(_,$e);if(re){k.insertBefore(xe,re.nextSibling);return}}k.appendChild(xe)};Ne(D);for(let xe of S){let{record:$e}=xe,ae=Ae($e.owner)||Ae($e.owners[1])||Ae($e.owners[2]);if(ae)(!xe.result||xe.output!==ae||xe.result.nodes.some(k=>!B.has(k)||w.get(k)!==ae)||ae.textContent!==xe.result.text)&&(C($e.owner,ae),Ne(ae,w.get(ae),y.get(ae)));else{let k=$e.parent,_=$e.owner,re=null;for(;k&&!re;)re=Ae(k),re||(_=k,k=d(k));if(!re)throw new Error("A cross-parent payload has no allowed surviving parent");ae=xe.output||u($e.owner,$e.owners[1],$e.owners[2],!1),xe.result||C($e.owner,ae),oe(ae,re,_),Ne(ae,re,y.get(re))}xe.state="attached"}}return{ensureParent:N,ensureOwner(D){N(d(D))},consumes(D){return E.has(D)},render:C,drain:j}}var An=/\S/,Lr=/[\p{L}\p{N}]/u;function to(e,o,t,n){if(e?.nodeType!==1||!o(e))return!1;for(let s=e.firstChild;s;s=s.nextSibling)if(n(t,1),s.nodeType!==3)return!1;return!!e.firstChild}function Ms(e,o,t){for(let n=e.parentNode;n;n=n.parentNode)if(t(o,1),n.nodeType===11)return!1;return!0}function Rr(e,o,t,n,s){let d=t(e,n),i=t(o,n),r=null,l=null,u=null,b=null;s(n,d.length+i.length);for(let a of d)Lr.test(a.raw)&&(r||=a,l=a);for(let a of i)Lr.test(a.raw)&&(u||=a,b=a);return!!(r&&u&&(r.raw===u.raw||l.raw===b.raw))}function rl({base:e,V:o,A:t,source:n,original:s,current:d,edited:i,destination:r,at:l,ownLength:u,eligible:b,model:a,tokensOf:h,budget:p,charge:v}){let O=s.flat.text,m=d.flat.text,c=i.flat.text,g=r.flat.text;if(v(p,O.length+m.length+g.length),O.startsWith(m)||O.endsWith(m))return!1;let P=An.test(g.slice(0,l)),T=An.test(g.slice(l+u));if(P===T)return!1;let x=P?0:l+u,A=P?l:g.length;for(;x<A&&!An.test(g[x]);)x++;for(;A>x&&!An.test(g[A-1]);)A--;let E=g.slice(x,A);if(En(E,g,h(r,p),p,v,!0)!==x)return!1;let S=En(E,O,h(s,p),p,v,!0);if(S<0)return!1;let N=S+E.length,C=!An.test(O.slice(0,S)),j=!An.test(O.slice(N));if(C===j||En(E,m,h(d,p),p,v,!1)>=0)return!1;let D=C?O.slice(N):O.slice(0,S),B=C?c.length-D.length:0;if(v(p,O.length+c.length),B<0||!An.test(D)||En(D,c,h(i,p),p,v,!0)!==B||!An.test(C?c.slice(0,B):c.slice(D.length)))return!1;for(let w of e){if(v(p,1),w===n||!to(w,b,p,v))continue;let y=a(w,null,p);if(En(E,y.flat.text,h(y,p),p,v,!1)>=0)return!1}for(let w of o.units){if(v(p,1),w===d.unit||w===r.unit||!to(w,b,p,v))continue;let y=a(w,t,p);if(En(E,y.flat.text,h(y,p),p,v,!1)>=0)return!1}return!0}function Pr({base:e,views:o,side:t,attempt:n,eligible:s,blocked:d,baseId:i,model:r,tokensOf:l,charge:u,exhausted:b,limit:a}){if(a<=0)return null;let h=Xt(a),{V:p,A:v,idOf:O}=o[t],m=o[1-t],[c,g,P,T]=n,x=null;try{for(let A=c;A<=g;A++){u(h,1);let E=e[A];if(E.parentNode?.nodeType!==1||d.has(E)||v.identical.has(E)||m.A.identical.has(E)||!to(E,s,h,u)||i(E))continue;let S=p.twin(E),N=m.V.twin(E);if(!S||!N||!p.here(S)||!m.V.here(N)||v.map.get(E)!==S||v.reverse.get(S)!==E||m.A.map.get(E)!==N||m.A.reverse.get(N)!==E||O(S)||m.idOf(N)||S.tagName!==E.tagName||N.tagName!==E.tagName||!to(S,s,h,u)||!to(N,s,h,u)||!Ms(E,h,u)||!Ms(S,h,u)||!Ms(N,h,u))continue;let C=r(E,null,h),j=r(S,v,h),D=r(N,m.A,h),B=C.flat.text,w=j.flat.text,y=D.flat.text;if(u(h,B.length+w.length+y.length),!An.test(B)||!An.test(w)||!An.test(y)||B===w||B===y||w===y||!Rr(C,j,l,h,u)||!Rr(C,D,l,h,u))continue;let $=null,U=!1;for(let Ae=P;Ae<=T;Ae++){u(h,1);let De=p.units[Ae],oe=p.baseOf(De);if(!oe||oe===E||d.has(oe)||oe.parentNode!==E.parentNode||De.parentNode!==S.parentNode||oe.tagName!==E.tagName||De.tagName!==E.tagName||v.map.get(oe)!==De||v.reverse.get(De)!==oe||i(oe)!==O(De)||!to(oe,s,h,u)||!to(De,s,h,u))continue;let xe=r(oe,null,h),$e=r(De,v,h),ae=xe.flat.text,k=$e.flat.text;if(u(h,ae.length),!An.test(ae)||k.length<=ae.length)continue;let _=l($e,h),re=En(ae,k,_,h,u,!0);if(!(re<0||En(B,k,_,h,u,!0,re,re+ae.length)<0&&!rl({base:e,V:p,A:v,source:E,original:C,current:j,edited:D,destination:$e,at:re,ownLength:ae.length,eligible:s,model:r,tokensOf:l,budget:h,charge:u}))){if($){U=!0;break}$=De}}if(!$||U)continue;let V=t===0?S:N,Ne=t===0?N:S;(x||=[]).push({source:E,local:V,remote:Ne,models:[C,t===0?j:D,t===0?D:j]})}}catch(A){if(A!==b)throw A}return x}var Un=/\S/,bn=/\s/,il=/[\s\u001e]/g,Os=/[^\s\p{P}\u001e\ufffc]/u;function ll(e,o,t,n,s,d,i){let r=0;for(let l of e)i(d,1),l.nodeType===1&&!n.baseOf(l)&&r++;if(r<2)return!1;for(let l of e){if(l.nodeType!==1||n.baseOf(l))continue;let u=s.get(l).flat;if(u.atoms.length||u.pins?.length)continue;i(d,u.text.length*2+o.length+t.length);let b=new Uint8Array(u.text.length);for(let a of t)a.target===l&&b.fill(1,a.targetFrom,a.targetFrom+a.to-a.from);for(let a of o)a.target===l&&b.fill(1,a.targetFrom,a.targetFrom+a.to-a.from);for(let a=0;a<u.text.length;a++)if(!b[a]&&Un.test(u.text[a]))return!0}return!1}function al(e,o,t){let{source:n,models:s,retained:d,runs:i}=e,r=s.get(n).flat.text;t(o,r.length*2+d.length+i.length);let l=new Uint8Array(r.length);for(let u of d)u.source===n&&(t(o,u.to-u.from),l.fill(1,u.from,u.to));for(let u of i)t(o,u.to-u.from),l.fill(1,u.from,u.to);for(let u=0;u<r.length;u++)if(!l[u]&&Un.test(r[u]))return!1;return!0}function cl(e,o,t,n,s,d,i,r,l,u){let b=d.get(e),a=d.get(o),h=b.flat.text,p=i.get(e);l(u,h.length*2+t.length);let v=h.length,O=0;for(let g=0;g<h.length;g++)!bn.test(h[g])&&!p[g]&&(v=Math.min(v,g),O=g+1);if(v>=O)return null;for(let g=v;g<O;g++)if(!bn.test(h[g])&&p[g])return null;let m=-1;for(let g of t)if(g.target===o&&g.from<=v&&g.to>v){m=g.targetFrom+v-g.from;break}if(m<0)return null;let c=h.slice(v,O);if(l(u,c.length*(t.length+2)),a.flat.text.slice(m,m+c.length)!==c)return null;for(let g=v;g<O;g++){if(bn.test(h[g]))continue;let P=!1;for(let T of t)if(T.target===o&&T.from<=g&&T.to>g&&T.targetFrom+g-T.from===m+g-v){P=!0;break}if(!P)return null}if(b.flat.atoms.length||a.flat.atoms.length){l(u,b.flat.atoms.length+a.flat.atoms.length);let g=0,P=a.flat.atoms;for(;g<P.length&&P[g].i<m;)g++;for(let T of b.flat.atoms){if(T.i<v||T.i>=O)continue;let x=P[g++];if(!x||x.i!==m+T.i-v||a.alignment?.reverse.get(x.el)!==T.el)return null}if(g<P.length&&P[g].i<m+O-v)return null}for(let[g,P,T]of[[n,e,v],[s,o,m]]){let x=!1;for(let A of g){let E=d.get(A),S=i.get(A),N=r(E,u);for(let C=0;C<N.length;C++){let j=N[C].from,D=j+c.length;if(l(u,c.length*2+1),E.flat.text.slice(j,D)!==c)continue;let B=C;for(;B<N.length&&N[B].to<D;)l(u,1),B++;if(B===N.length||N[B].to!==D)continue;let w=!0;for(let y=j;y<D;y++)if(!bn.test(E.flat.text[y])&&S[y]){w=!1;break}if(w){if(x||A!==P||j!==T)return null;x=!0}}}if(!x)return null}return c}function fl(e,o,t,n,s,d,i,r){if(i(r,s.length+d.length+(n.length+1)*t.length*2),!t)return!1;let l=n.indexOf(t);return l<0||n.lastIndexOf(t)!==l||!d.some(u=>u.from===l)||!d.some(u=>u.to===l+t.length)?!1:s.some(u=>u.source===e&&u.target===o&&u.from===0&&u.to===t.length&&u.targetFrom===l)}function Br({base:e,views:o,eligible:t,baseId:n,ignored:s,remoteWins:d,atomKey:i,limit:r=2e4*8}){if(r<=0)return null;let l=Symbol(),u=(T,x)=>{if(x>T.remaining)throw l;T.remaining-=x},b=[new Map,new Map];for(let T=0;T<2;T++)for(let x=0;x<o[T].V.units.length;x++)b[T].set(o[T].V.units[x],x);let a=new Int32Array(e.length),h=new Int32Array(e.length),p=T=>o.every(({V:x},A)=>{let E=x.twin(T);return E&&b[A].has(E)}),v=-1;for(let T=0;T<e.length;T++)a[T]=v,p(e[T])&&(v=T);v=e.length;for(let T=e.length-1;T>=0;T--)h[T]=v,p(e[T])&&(v=T);let O=new Map,m=(T,x)=>{if(u(x,1),O.has(T))return O.get(T);let A=T.firstChild,E=1;for(;A;){if(u(x,E*8+8),A.nodeType===3&&u(x,A.data.length*8),A.nodeType===1&&vn.has(A.tagName)&&!s(A)&&!d(A)&&A.firstChild){A=A.firstChild,E++;continue}for(;A&&A!==T&&!A.nextSibling;)A=A.parentNode,E--;A=!A||A===T?null:A.nextSibling}let S=ln(Array.from(T.childNodes),{ignored:s,remoteWins:d});return O.set(T,S),S},c=(T,x,A,E,S,N)=>{for(let C of T.atoms){u(N,1);let j=x.atomAt.get(C.i+A);if(!j)return!1;let D=E?.reverse.get(C.el)||i(C.el),B=S?.reverse.get(j.el)||i(j.el);if(D!==B)return!1}return!0},g=(T,x,A,E,S)=>{let N=T.text.length<=x.text.length?T:x,C=N===T?x:T;if(u(S,N.text.length+C.text.length),!N.text||!Un.test(N.text.replaceAll(Dn,"")))return!1;let j;if(N.text===C.text)j=0;else{let D=C.text.length-N.text.length;if(u(S,(D+1)*N.text.length*2),C.text.startsWith(N.text))j=0;else if(C.text.endsWith(N.text))j=D;else return!1;if(C.text.indexOf(N.text)!==j||C.text.lastIndexOf(N.text)!==j)return!1;u(S,C.text.length*2);let B=0,w=j===0,y=!1;for(let $ of fn(C.text,xn(C.text)))B+=$.len,B===j&&(w=!0),B===j+N.text.length&&(y=!0);if(!w||!y)return!1}return N===T?c(N,C,j,A,E,S):c(N,C,j,E,A,S)},P=null;for(let T=0;T<2;T++){let{V:x,A,idOf:E}=o[T],S=o[1-T];if(!x.asBase)for(let N=0;N<e.length;N++){let C=e[N];if(x.twin(C)||!t(C))continue;let j=S.V.twin(C);if(!j||!b[1-T].has(j)||!t(j))continue;let D={remaining:r};try{let B=a[N],w=h[N],y=0;for(let Ne=B+1;Ne<w;Ne++)u(D,1),!x.twin(e[Ne])&&S.V.twin(e[Ne])&&t(e[Ne])&&y++;if(y!==1||m(C,D).text===m(j,D).text)continue;let $=B<0?-1:b[T].get(x.twin(e[B])),U=w===e.length?x.units.length:b[T].get(x.twin(e[w]));if($===void 0||U===void 0||$>=U)continue;let V=null;for(let Ne=$+1;Ne<U;Ne++){u(D,1);let Ae=x.units[Ne];if(x.baseOf(Ae)||!t(Ae)||Ae.tagName!==C.tagName||Ae.namespaceURI!==C.namespaceURI)continue;let De=n(C),oe=S.idOf(j),xe=E(Ae);if(!(De&&oe&&De!==oe||De&&xe&&De!==xe||oe&&xe&&oe!==xe)&&g(m(j,D),m(Ae,D),S.A,A,D)){if(V){V=null;break}V=Ae}}if(!V)continue;P||(P=[new Map,new Map]),P[T].set(C,V)}catch(B){if(B!==l)throw B}}}return P?o.map(({V:T},x)=>{let A=P[x];if(!A.size)return T;let E=new Map;for(let[S,N]of A)E.set(N,S);return{...T,twin:S=>A.get(S)||T.twin(S),baseOf:S=>E.get(S)||T.baseOf(S)}}):null}function Dr({onUncertainSource:e,onUncertainOwner:o,base:t,views:n,eligible:s,ignored:d,remoteWins:i,baseId:r,atomKey:l,limit:u=2e4*32}){if(u<=0)return null;let b=new Set(t),a=new Map(t.map((B,w)=>[B,w])),h=new Map,p=[],v=null,O=null,m=null,c=new Set;for(let B of t)for(let{V:w}of n){let y=w.twin(B);y&&!w.asBase&&!w.here(y)&&c.add(B)}let g=new Set,P=Symbol(),T=(B,w)=>{if(w>B.remaining)throw P;B.remaining-=w},x=(B,w,y)=>{T(y,1);let $=h.get(B);if($)return $;if(B.nodeType===1){let Ne=B.firstChild,Ae=1;for(;Ne;){if(T(y,Ae*8+8),Ne.nodeType===3&&T(y,Ne.data.length*8),Ne.nodeType===1&&vn.has(Ne.tagName)&&!d(Ne)&&!i(Ne)&&Ne.firstChild){Ne=Ne.firstChild,Ae++;continue}for(;Ne&&Ne!==B&&!Ne.nextSibling;)Ne=Ne.parentNode,Ae--;Ne=!Ne||Ne===B?null:Ne.nextSibling}}else T(y,B.value.length*8+B.nodes.length);let U=B.nodeType===1?Array.from(B.childNodes):B.nodes,V=U.length===1&&U[0].nodeType===3?{text:U[0].data,nodes:[{node:U[0],s:0,e:U[0].data.length}],atoms:[]}:ln(U,{ignored:d,remoteWins:i});return $={unit:B,flat:V,alignment:w,tokens:null},h.set(B,$),$},A=(B,w)=>{if(B.tokens)return B.tokens;T(w,B.flat.text.length*8);let{unit:y,flat:$,alignment:U}=B,V=[],Ne=xn($.text),Ae=0,De=oe=>{for(let xe of fn($.text.slice(Ae,oe),Ne))xe.from=Ae,xe.to=Ae+xe.len,xe.unit=y,V.push(xe),Ae+=xe.len};for(let oe of $.atoms){De(oe.i);let xe=i(oe.el)&&oe.el.nodeType===1?"w"+oe.el.tagName+"#"+(oe.el.id||""):l(U?.reverse.get(oe.el)||oe.el);V.push({k:xe,raw:Dn,len:1,from:Ae,to:Ae+1,unit:y,atom:!0}),Ae++}return De($.text.length),B.tokens=V,V},E=(B,w,y,$,U)=>{if(!B.flat.atoms.length&&!w.flat.atoms.length)return!0;let V=A(B,U),Ne=A(w,U);T(U,V.length+Ne.length);let Ae=0;for(let De of Ne){if(!De.atom||De.from<y||De.from>=y+$)continue;for(;Ae<V.length&&!V[Ae].atom;)Ae++;let oe=V[Ae++];if(!oe||oe.from!==De.from-y||oe.k!==De.k)return!1}for(;Ae<V.length;)if(V[Ae++].atom)return!1;return!0},S=(B,w,y)=>{let $=B.length+w.length+4;if($*8>y.remaining)return null;y.remaining-=$*8;let U=Math.floor(y.remaining/8),V=Math.min(B.length+w.length,4e3,Math.floor((Math.sqrt($*$+U)-$)/2)),Ne=4*(V+1)*($+V+1);if(V<1||Ne>y.remaining)return null;y.remaining-=Ne;let Ae=Hn(B,w,V),De=[],oe=0,xe=0;for(let $e of Ae.hunks){for(;oe<$e.bs;)B[oe].raw===w[xe].raw&&De.push([B[oe],w[xe]]),oe++,xe++;oe=$e.be,xe+=$e.toks.length}for(;oe<B.length&&xe<w.length;)B[oe].raw===w[xe].raw&&De.push([B[oe],w[xe]]),oe++,xe++;return De},N=(B,w,y,$,U,V,Ne)=>{if(U<=$)return;let Ae=B[B.length-1];if(Ae&&Ae.source===w&&Ae.target===y&&Ae.to<=$&&Ae.targetFrom-Ae.from===V-$){T(Ne,($-Ae.to)*3);let De=h.get(w).flat.text,oe=h.get(y).flat.text,xe=!0;for(let $e=Ae.to;$e<$;$e++)if(!bn.test(De[$e])||De[$e]!==oe[V+$e-$]){xe=!1;break}if(xe){Ae.to=U;return}}B.push({source:w,target:y,from:$,to:U,targetFrom:V})},C=B=>B.replace(il,"");for(let B=0;B<n.length;B++){let{V:w,A:y,idOf:$}=n[B];if(w.asBase)continue;let U=new Map(w.units.map((k,_)=>[k,_])),V=k=>{let _=w.twin(k);return _&&U.has(_)?_:null},Ne=(k,_)=>{let re=new Int32Array(k.length),Z=new Int32Array(k.length),Be=-1;for(let Ke=0;Ke<k.length;Ke++)re[Ke]=Be,_(k[Ke])&&(Be=Ke);Be=k.length;for(let Ke=k.length-1;Ke>=0;Ke--)Z[Ke]=Be,_(k[Ke])&&(Be=Ke);return{prev:re,next:Z}},Ae=Ne(t,k=>(k.nodeType===1||k.kind==="text"&&Un.test(k.value))&&V(k)),De=Ne(w.units,k=>(k.nodeType===1||k.kind==="text"&&Un.test(k.value))&&b.has(w.baseOf(k))),oe=new Map,xe=(k,_,re,Z)=>{if(k>_||re>Z)return;let Be=`${k}:${_}:${re}:${Z}`;oe.set(Be,[k,_,re,Z])};for(let k=0;k<w.units.length;k++){let _=w.units[k];if(w.baseOf(_)||!s(_))continue;let re=De.prev[k],Z=De.next[k],Be=re<0?0:a.get(w.baseOf(w.units[re])),Ke=Z===w.units.length?t.length-1:a.get(w.baseOf(w.units[Z]));xe(Be,Ke,Math.max(0,re),Math.min(w.units.length-1,Z))}for(let k=0;k<t.length;k++){let _=t[k];if(c.has(_)||!s(_))continue;if(!w.twin(_)){let it=Ae.prev[k],et=Ae.next[k],mt=it<0?0:U.get(V(t[it])),Ze=et===t.length?w.units.length-1:U.get(V(t[et]));xe(Math.max(0,it),Math.min(t.length-1,et),mt,Ze)}let re=V(_);if(!re||y.identical.has(_)||!s(re))continue;let Z=k+1;for(;Z<t.length&&t[Z].kind==="text"&&!t[Z].value.trim();)Z++;if(Z>=t.length||!s(t[Z]))continue;let Be=V(t[Z]);if(!Be||y.identical.has(t[Z])||!s(Be))continue;let Ke=U.get(re),Te=U.get(Be);Ke<Te&&xe(k,Z,Ke,Te)}let $e=Array.from(oe.values()),ae=new Set;if($e.length>1){let k=Xt(u);try{T(k,$e.length*4);let _=$e.slice().sort((Be,Ke)=>(T(k,1),Be[0]-Ke[0]||Be[2]-Ke[2])),re=[],Z=null;for(let Be of _)T(k,1),Z&&Be[0]<=Z[1]&&Be[2]<=Z[3]&&Be[3]>=Z[2]?(Z[1]=Math.max(Z[1],Be[1]),Z[2]=Math.min(Z[2],Be[2]),Z[3]=Math.max(Z[3],Be[3]),Z[4].push(Be)):(Z?.[4].length>1&&re.push(Z),Z=[Be[0],Be[1],Be[2],Be[3],[Be]]);Z?.[4].length>1&&re.push(Z),$e=re.concat($e)}catch(_){if(_!==P)throw _}}for(let k of $e){if(ae.has(k))continue;let[_,re,Z,Be,Ke]=k,Te=Xt(u),it=[],et=new Set,mt=!1;try{T(Te,(re-_+Be-Z+2)*4);let Ze=t.slice(_,re+1).filter(Q=>!y.identical.has(Q)&&s(Q)&&!c.has(Q)),ft=w.units.slice(Z,Be+1).filter(Q=>s(Q)&&(!w.baseOf(Q)||b.has(w.baseOf(Q)))&&!y.identical.has(w.baseOf(Q))&&!c.has(w.baseOf(Q))),Ct=new Set(ft),Dt=!1,Tt="",Rt="",jt=0;for(let Q of Ze){let Oe=x(Q,null,Te);Tt+=Oe.flat.text,jt+=Oe.flat.text.length}for(let Q of ft){let Oe=x(Q,y,Te);Rt+=Oe.flat.text,jt+=Oe.flat.text.length}T(Te,jt);let qt=C(Tt),un=C(Rt),Lt=qt===un;if(mt=Lt,Ke&&!Lt)continue;let Jt=Lt?null:new Map;if(Jt)for(let Q of Ze.concat(ft)){let Oe=h.get(Q).flat.text.length;T(Te,Oe*16),Jt.set(Q,new Uint8Array(Oe))}let F=Q=>{let Oe=[];for(let Ve of Q){let Ce=h.get(Ve);Ce.flat.atoms.length?Oe.push(...A(Ce,Te)):Oe.push({unit:Ve,raw:Ce.flat.text,from:0})}return Oe},ce=[];for(let Q of Lt?[]:Ze){let Oe=V(Q);if(!Ct.has(Oe))continue;let Ve=x(Q,null,Te),Ce=x(Oe,y,Te);T(Te,Ve.flat.text.length+Ce.flat.text.length);let be=Ve.flat.text&&Ce.flat.text.startsWith(Ve.flat.text)?0:Ve.flat.text&&Ce.flat.text.endsWith(Ve.flat.text)?Ce.flat.text.length-Ve.flat.text.length:-1;if(be>=0&&E(Ve,Ce,be,Ve.flat.text.length,Te)){Jt.get(Q).fill(1),Jt.get(Oe).fill(1,be,be+Ve.flat.text.length),N(ce,Q,Oe,0,Ve.flat.text.length,be,Te);continue}let H=S(A(Ve,Te),A(Ce,Te),Te);if(!H){Dt=!0;break}for(let[X,de]of H)Jt.get(Q).fill(1,X.from,X.to),Jt.get(Oe).fill(1,de.from,de.to),N(ce,Q,Oe,X.from,X.to,de.from,Te)}if(Dt)continue;let ge=null,Le=null;if(!Lt)for(let Q of Ze){let Oe=V(Q),Ve=h.get(Q);if(!Oe||Ve.flat.atoms.length||!Ct.has(Oe))continue;let Ce=Ve.flat.text,be=Jt.get(Q);T(Te,Ce.length*3+ft.length);let H=-1,X=-1,de=!1;for(let He=0;He<Ce.length;He++)bn.test(Ce[He])||(be[He]?de=!0:(H<0&&(H=He),X=He+1));if(!de||H<0)continue;let pe=!0;for(let He=H;He<X;He++)if(be[He]&&!bn.test(Ce[He])){pe=!1;break}if(!pe)continue;let se=C(Ce.slice(H,X)),ke=null,fe=!1;for(let He of ft){if(w.baseOf(He))continue;let Se=h.get(He);if(!Se.flat.atoms.length&&(T(Te,Se.flat.text.length),C(Se.flat.text)===se)){if(ke){fe=!0;break}ke=He}}if(fe){(Le||=new Set).add(Q);continue}if(!ke||Le?.has(Q))continue;let G=!1;for(let He of Ze){if(He===Q||!Ct.has(V(He)))continue;let Se=h.get(He);if(Se.flat.atoms.length)continue;let Je=Jt.get(He);T(Te,Se.flat.text.length*3);let nt="",ot=!1;for(let Wt=0;Wt<Se.flat.text.length;Wt++)bn.test(Se.flat.text[Wt])||(Je[Wt]?ot=!0:nt+=Se.flat.text[Wt]);ot&&nt===se&&(Le||=new Set,Le.add(Q),Le.add(He),G=!0)}if(G)continue;let ue=h.get(ke).flat.text;T(Te,X-H+ue.length);let Ie=H,Pe=0;for(;Ie<X&&Pe<ue.length;){for(;Ie<X&&bn.test(Ce[Ie]);)Ie++;for(;Pe<ue.length&&bn.test(ue[Pe]);)Pe++;if(Ie>=X||Pe>=ue.length)break;N(ge||=[],Q,ke,Ie,Ie+1,Pe,Te),Ie++,Pe++}be.fill(1,H,X),Jt.get(ke).fill(1)}let Me=Q=>{let Oe=[];for(let Ve of Q){let Ce=x(Ve,b.has(Ve)?null:y,Te),be=Jt.get(Ve);for(let H of A(Ce,Te)){let X=H.from;for(;X<H.to;){for(;X<H.to&&be[X];)X++;let de=X;for(;X<H.to&&!be[X];)X++;if(X>de){let pe=Ce.flat.text.slice(de,X);Un.test(pe)&&Oe.push({...H,raw:pe,len:X-de,k:H.atom?H.k:pe,from:de,to:X})}}}}return Oe},M=Lt?F(Ze):Me(Ze),R=Lt?F(ft):Me(ft),z=Lt?qt:M.map(Q=>C(Q.raw)).join(""),J=Lt?un:R.map(Q=>C(Q.raw)).join("");if((!z||!J)&&!ge)continue;let ne=ge||[];if(z&&J&&z===J){let Q=0,Oe=0,Ve=0,Ce=0;for(;Q<M.length&&Oe<R.length;){let be=M[Q],H=R[Oe];for(;Ve<be.raw.length&&bn.test(be.raw[Ve]);)Ve++;for(;Ce<H.raw.length&&bn.test(H.raw[Ce]);)Ce++;if(Ve===be.raw.length){Q++,Ve=0;continue}if(Ce===H.raw.length){Oe++,Ce=0;continue}if((be.atom||H.atom)&&be.k!==H.k){Dt=!0;break}N(ne,be.unit,H.unit,be.from+Ve,be.from+Ve+1,H.from+Ce,Te),Ve++,Ce++}}else if(z&&J){let Q=S(M,R,Te);if(!Q)continue;for(let[Oe,Ve]of Q)N(ne,Oe.unit,Ve.unit,Oe.from,Oe.to,Ve.from,Te)}if(Dt)continue;let je=new Map;for(let Q of ne)if(!Le?.has(Q.source)){if(V(Q.source)===Q.target){Lt&&ce.push(Q);continue}je.has(Q.source)||je.set(Q.source,[]),je.get(Q.source).push(Q)}for(let[Q,Oe]of je){let Ve=x(Q,null,Te),Ce=V(Q),be=Ve.flat.text,H=[],X=new Set,de=n[1-B],pe=de.V.twin(Q),se=pe&&de.V.here(pe)?x(pe,de.A,Te):null,ke=(Se,Je)=>{let nt=A(Se,Te),ot=A(Je,Te);return T(Te,Se.flat.text.length+Je.flat.text.length+nt.length+ot.length),Se.flat.text===Je.flat.text&&nt.length===ot.length&&nt.every((Wt,Ut)=>Wt.k===ot[Ut].k)},fe=Ce&&se&&se.flat.text!==be&&ke(x(Ce,y,Te),se);for(let Se of new Set(Oe.map(Je=>Je.target))){if(Q.nodeType!==1&&Se.nodeType!==1)continue;let Je=x(Se,y,Te),nt=w.baseOf(Se);if(Q.nodeType!==1&&nt||(T(Te,be.length*2+Je.flat.text.length*3+ce.length*2),Ce&&C(be)===C(Je.flat.text)&&x(Ce,y,Te).flat.text.trim()))continue;if(!Ce&&!nt&&Q.nodeType===1&&Se.nodeType===1){let q=r(Q),te=$(Se);if(q&&te&&q!==te)continue}let ot=Je.flat.text,Wt=be&&(ot.startsWith(be)||ot.endsWith(be)),Ut=!1;if(!Ce&&se&&nt&&se.flat.text!==be){let q=x(nt,null,Te).flat.text,te=a.get(Q)<a.get(nt)?se.flat.text:q,me=a.get(Q)<a.get(nt)?q:se.flat.text;T(Te,te.length+me.length+ot.length),Ut=!!te&&!!me&&te.length+me.length<=ot.length&&ot.startsWith(te)&&ot.endsWith(me)&&!ot.slice(te.length,ot.length-me.length).trim()}let I=!Ve.flat.atoms.length&&!se?.flat.atoms.length&&!Je.flat.atoms.length&&(fe&&Wt||Ut);if(Ce&&nt){let q=x(Ce,y,Te).flat.text,te=be.startsWith(q)||be.endsWith(q),me=x(nt,null,Te).flat.text,we=Je.flat.text,ie=we.startsWith(me)||we.endsWith(me),ee=!n[1-B].V.twin(nt)&&!ce.some(Ee=>Ee.source===nt&&Un.test(me.slice(Ee.from,Ee.to)));if(!Lt&&(!te&&!I||!ie&&!ee)){let Ee=cl(Q,Se,Oe,Ze,ft,h,Jt,A,T,Te);if(!Ee)continue;let Ue=y.weak?.has(Q)&&!y.identityPaired?.has(Q)&&be.trim()===Ee;if(!te&&!I&&!Ue)continue;let _e=y.weak?.has(nt)&&!y.identityPaired?.has(nt)&&ot.trim()===Ee&&!h.get(nt).flat.atoms.length&&!ce.some(Ye=>Ye.source===nt&&Un.test(me.slice(Ye.from,Ye.to)));if(!ie&&!ee&&!_e&&!fl(nt,Se,me,ot,ce,A(Je,Te),T,Te))continue;Ue&&X.add(Se)}}I&&X.add(Se),T(Te,Oe.length),H.push(...Oe.filter(q=>q.target===Se))}if(!H.length)continue;let G=new Uint8Array(be.length);T(Te,be.length*4+ce.length);for(let Se of H)G.fill(1,Se.from,Se.to);let ue=[];for(let Se=0;Se<be.length;Se++)bn.test(be[Se])||ue.push(Se);if(!ue.length)continue;let Ie=new Set(H.map(Se=>Se.target));if(!Lt&&Ce&&Ie.size>1&&ll(Ie,ne,ce,w,h,Te,T)){if(m||=new Map,m.set(Q,(m.get(Q)||0)|1<<B),e){let Se=ws({source:Q,side:B,views:n,eligible:s,blocked:c,baseId:r,model:x,tokensOf:A,budget:Te,charge:T});if(Se){T(Te,Se.to-Se.from);let Je=!0;for(let nt=Se.from;nt<Se.to;nt++)if(Un.test(be[nt])&&!G[nt]){Je=!1;break}Je&&(v||=[]).push(Se)}}continue}let Pe=ue.filter(Se=>Os.test(be[Se]));if(!H.some(Se=>Os.test(be.slice(Se.from,Se.to)))&&!ue.every(Se=>G[Se]))continue;if(!Ce&&!Array.from(Ie).some(Se=>X.has(Se))&&!ue.every(Se=>G[Se])&&!(Pe.length&&G[Pe[0]]&&G[Pe[Pe.length-1]]&&Ie.size===1)){let Se=null,Je=0,nt=0,ot=null,Wt=null;if(!Ce&&se&&Q.nodeType===1&&!Ve.flat.atoms.length){let Ut=A(Ve,Te).filter(I=>Os.test(I.raw));T(Te,ft.length+be.length);for(let I of ft){let q=w.baseOf(I);if(!q||q===Q||q.nodeType!==1||I.nodeType!==1||q.tagName!==Q.tagName||I.tagName!==q.tagName)continue;let te=a.get(Q),me=a.get(q),we=!0;for(let gt=Math.min(te,me)+1;gt<Math.max(te,me);gt++){let $t=t[gt];if(T(Te,$t.nodeType===1?1:$t.value.length+1),$t.nodeType===1||$t.value.trim()){we=!1;break}}if(!we)continue;let ie=x(q,null,Te),ee=x(I,y,Te);if(ie.flat.atoms.length||ee.flat.atoms.length)continue;let Ee=ie.flat.text,Ue=ee.flat.text;if(T(Te,Ee.length+Ue.length+be.length),!Ee||!Ut.length)continue;let _e=0,Ye=Ue.length;if(te<me&&Ue.endsWith(Ee))Ye-=Ee.length;else if(te>me&&Ue.startsWith(Ee))_e=Ee.length;else continue;for(;_e<Ye&&bn.test(Ue[_e]);)_e++;for(;Ye>_e&&bn.test(Ue[Ye-1]);)Ye--;let yt=Ue.slice(_e,Ye);if(!(!yt||!(yt.startsWith(Ut[0].raw)||yt.endsWith(Ut[Ut.length-1].raw)))){if(Se){Se=null;break}Se=I,Je=_e,nt=Ye,ot=Ut[0],Wt=Ut[Ut.length-1]}}}if(T(Te,H.length),!Se||!Ie.has(Se)||!H.some(Ut=>Ut.target===Se&&(Ut.from<=ot.from&&Ut.to>=ot.to&&Ut.targetFrom+ot.from-Ut.from===Je||Ut.from<=Wt.from&&Ut.to>=Wt.to&&Ut.targetFrom+Wt.to-Ut.from===nt)))continue}if(Ce&&!(ue.every(Se=>G[Se])&&(Lt||Array.from(Ie).some(Se=>X.has(Se))))&&!ce.some(Se=>Se.source===Q&&Un.test(be.slice(Se.from,Se.to))))continue;let He=!1;if(Lt){T(Te,ce.length+ue.length);for(let Se of ce)Se.source===Q&&(T(Te,Se.to-Se.from),G.fill(1,Se.from,Se.to));He=!0;for(let Se of ue)if(!G[Se]){He=!1;break}}for(let Se of Ie){T(Te,H.length);let Je=H.filter(ot=>ot.target===Se);it.push({side:B,source:Q,target:Se,runs:Je,models:h,retained:ce,conservedSource:He}),Q.nodeType===1&&et.add(Q),Se.nodeType===1&&et.add(Se);let nt=w.baseOf(Se);nt?.nodeType===1&&et.add(nt)}}if(p.push(...it),Ke&&it.length)for(let Q of Ke)ae.add(Q);for(let Q of et)g.add(Q)}catch(Ze){if(Ze!==P)throw Ze}finally{if(o&&!Ke&&!mt){let Ze=Pr({base:t,views:n,side:B,attempt:k,eligible:s,blocked:c,baseId:r,model:x,tokensOf:A,charge:T,exhausted:P,limit:u});Ze&&(O||=[]).push(...Ze)}if(e&&!Ke&&!mt){let Ze=zs({base:t,views:n,side:B,attempt:k,eligible:s,blocked:c,baseId:r,model:x,tokensOf:A,certificates:p,charge:T,exhausted:P,limit:u});Ze&&(v||=[]).push(...Ze)}}}}let j=p.length?new Map:null;for(let B of p){let w=j.get(B.source);w||j.set(B.source,w=[]),w.push(B)}let D=null;if(j){let B=null;for(let[w,y]of j){let $=m?.get(w)||0;if(y.length<2&&!$)continue;let U=0;for(let V of y)V.conservedSource&&(U|=1<<V.side);for(let V of y){if(V.conservedSource)continue;let Ne=1<<V.side,Ae=!0;if(U&Ne)Ae=!1;else if($&Ne){Ae=!1;try{Ae=al(V,B||=Xt(u),T)}catch(De){if(De!==P)throw De}}Ae||(D||=new Set).add(V)}}}if(D){let B=0;for(let w of p)D.has(w)||(p[B++]=w);p.length=B;for(let[w,y]of j){B=0;for(let $ of y)D.has($)||(y[B++]=$);y.length=B,B||j.delete(w)}g.clear();for(let w of p){let{source:y,target:$,side:U}=w;y.nodeType===1&&g.add(y),$.nodeType===1&&g.add($);let V=n[U].V.baseOf($);V?.nodeType===1&&g.add(V)}}if(v){let B=Xt(u),w=!1;for(let y of v){let $=!1,U=j?.get(y.source);if(U&&!w)try{$=bs(y,U,B,T)}catch(V){if(V!==P)throw V;w=!0}$||e(y)}}if(O){let B=new Set,w=Xt(u);try{for(let y of O){if(T(w,1),B.has(y.source))continue;B.add(y.source);let $=!1;for(let U of p)if(T(w,1),U.source===y.source||U.target===y.local||U.target===y.remote){$=!0;break}$||o(y)}}catch(y){if(y!==P)throw y}}for(let B of t)if(g.has(B))for(let{V:w}of n){let y=w.twin(B);y&&w.here(y)&&g.add(y)}return p.length?{blocks:g,certificates:p,certificatesBySource:j,models:h}:null}function jr({certificates:e,scopes:o,flats:t,keys:n,limit:s=2e4*32}){let d=Symbol(),i=Xt(s),r=m=>{if(m>i.remaining)throw d;i.remaining-=m},l=o.map(m=>new Set(m)),u=new Map,b=new Map,a=(m,c)=>{let g=u.get(m);if(g||u.set(m,g=new Map),g.has(c))return g.get(c);r(m.text.length);let P=b.get(c);if(!P){r(c.nodes.length+c.atoms.length),P={nodes:new Map,atoms:new Map};for(let E of c.nodes)P.nodes.set(E.node,E);for(let E of c.atoms)P.atoms.set(E.el,E.i);b.set(c,P)}let{nodes:T,atoms:x}=P,A=new Int32Array(m.text.length).fill(-1);for(let E of m.nodes){let S=T.get(E.node);if(!(!S||E.e-E.s!==S.e-S.s)){r(E.e-E.s);for(let N=E.s;N<E.e;N++)A[N]=S.s+N-E.s}}for(let E of m.atoms){let S=x.get(E.el);S!==void 0&&(A[E.i]=S)}return g.set(c,A),A},h=(m,c,g,P,T)=>{let x=m[m.length-1];x&&x.to===c&&x.target+x.to-x.from===P&&x.kind===T?x.to=g:m.push({from:c,to:g,target:P,kind:T})},p=(m,c,g,P)=>{r((P-g)*4);let T=[],x=g,A=N=>{let C=m.text.slice(x,N);for(let j of fn(C,xn(C)))j.from=x,j.to=x+j.len,T.push(j),x+=j.len},E=0,S=m.atoms.length;for(;E<S;){r(1);let N=E+S>>>1;m.atoms[N].i<g?E=N+1:S=N}for(let N=E;N<m.atoms.length&&m.atoms[N].i<P;N++){r(1);let C=m.atoms[N];A(C.i),T.push({k:c(C),raw:Dn,len:1,from:x,to:x+1}),x++}return A(P),T},v=(m,c,g,P,T,x)=>{if(g===P||T===x)return;if(P-g===x-T){r((P-g)*4);let w=!0;for(let y=g,$=T;y<P;y++,$++){if(t[0].text[y]!==t[c].text[$]){w=!1;break}let U=t[0].atomAt.get(y),V=t[c].atomAt.get($);if(!!U!=!!V||U&&n[0](U)!==n[c](V)){w=!1;break}}if(w){h(m,g,P,T,"retained");return}}let A=p(t[0],n[0],g,P),E=p(t[c],n[c],T,x),S=A.length+E.length+4,N=Math.min(A.length+E.length,4e3,Math.floor((Math.sqrt(S*S+i.remaining/2)-S)/2));if(N<1)throw d;r(4*(N+1)*(S+N+1));let C=Hn(A,E,N),j=0,D=0,B=()=>{let w=A[j++],y=E[D++];r(w.len),w.raw===y.raw&&h(m,w.from,w.to,y.from,"retained")};for(let w of C.hunks){for(;j<w.bs;)B();j=w.be,D+=w.toks.length}for(;j<A.length&&D<E.length;)B()},O=m=>{let c=e.filter(C=>C.side===m-1&&l[0].has(C.source)&&l[m].has(C.target));if(!c.length)return null;let g=[],P=(C,j,D)=>{if(!l[0].has(C.source)||!l[m].has(C.target))return;let B=a(j.get(C.source).flat,t[0]),w=a(j.get(C.target).flat,t[m]);r(C.to-C.from);for(let y=0;y<C.to-C.from;y++){let $=B[C.from+y],U=w[C.targetFrom+y];if($<0||U<0)throw d;h(g,$,$+1,U,D)}},T=new Set;for(let C of c){if(!T.has(C.retained)){T.add(C.retained);for(let j of C.retained)P(j,C.models,"retained")}for(let j of C.runs)P(j,C.models,"transfer")}g.sort((C,j)=>(r(1),C.from-j.from||C.target-j.target));let x=[];for(let C of g){r(1);let j=x[x.length-1];if(j&&C.from<j.to){if(C.target-C.from!==j.target-j.from)throw d;j.to=Math.max(j.to,C.to),C.kind==="transfer"&&(j.kind="transfer")}else x.push(C)}let A=[],E=0,S=0;for(let C of x){if(C.target<S)throw d;v(A,m,E,C.from,S,C.target),A.push(C),E=C.to,S=C.target+C.to-C.from}v(A,m,E,t[0].text.length,S,t[m].text.length);let N=Bn({base:t[0],side:t[m],retained:A.filter(C=>C.kind==="retained"),transfers:A.filter(C=>C.kind==="transfer"),baseAtomKey:n[0],sideAtomKey:n[m],budget:i});if(N.status!=="ready"||!N.monotone)throw d;return N};try{let m=O(1),c=O(2);return m||c?{local:m,remote:c}:{fallback:!0}}catch(m){if(m!==d)throw m;return{fallback:!0}}}function Is(e,o,t=!1){let n=-1,s=-1;for(let i=0;i<e.list.length;i++){let r=e.list[i];r.bLo<o.lo||r.bLo>o.hi||(n<0&&(n=i),s=i)}let d=[];for(let i=n;i>=0&&i<=s;i++){let r=e.list[i],l=!t&&i===n?r.inlineStart<0?r.to:r.inlineStart:r.from,u=!t&&i===s?r.inlineEnd<0?r.from:r.inlineEnd:r.to;for(let b=l;b<u;b++)d.push(e.units[b]);i<s&&d.push(e.units[r.next])}return d}var ut=e=>!!e&&e.nodeType===1,Ln=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function Es(e){for(let o of e)if(Ln.has(o.tagName))return!0;return!1}function ul(e,o,t){let n=null;for(let s of o.childNodes)if(!(!ut(s)||!t(s)||!s.isEqualNode(e))){if(n)return null;n=s}if(!n)return null;for(let s of e.parentNode.childNodes)if(s!==e&&s.isEqualNode(e))return null;return n}var Io="[id],[data-id],script,head>*";function Cs(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=fo(t,e);if(n)return"merge:"+n.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?br(t,o):null}}function Jo(e,o,t,n){let s=n.ignored,d=n.stats||Fn(),i=Ws({ignored:s,ignoreAttribute:n.ignoreAttribute,stats:d}),{unitsOf:r,meta:l}=i,u=n.baseURI,b=n.mergeTags!==null,a=Cs(n.mergeTags,u),h=I=>q=>{let te=a(q);return te!==null?te:I(q)},p=h(n.identity.base),v=h(n.identity.local),O=h(n.identity.remote),m=n.authored||n.identity,c=I=>I&&I.nodeType===9?I.documentElement:I,g=c(e),P=c(o),T=c(t),x=globalThis.__hyperMorphProfile,A=x?performance.now():0,E=I=>I===kn?Io:null,S=n.scope||null,N=S?S.baseDropped:new Set,C=new Set,j=S?S.remoteDropped:new Set,D=S?S.baseIndex:Uo(g,p,s,E(n.identity.base),N),B=n.localIsBase||g===P?null:Uo(P,v,s,E(n.identity.local),C),w=S?S.remoteIndex:Uo(T,O,s,E(n.identity.remote),j),y=I=>{let q=ut(I)&&v(I);return q&&B?.get(q)===I&&!D.has(q)?q:null},$=I=>{let q=ut(I)&&O(I);return q&&w.get(q)===I&&!D.has(q)?q:null},U=B?as(g,P,{analyzer:i,baseIndex:D,sideIndex:B,baseId:m.base,sideId:m.local,baseKey:p,sideKey:v,baseDropped:N,sideDropped:C,stats:d}):Vr(),V=as(g,T,{analyzer:i,baseIndex:D,sideIndex:w,baseId:m.base,sideId:m.remote,baseKey:p,sideKey:O,baseDropped:N,sideDropped:j,stats:d,scope:S,comparisons:n.comparisons});if(S){if(!S.held(V))return null;for(let I of S.dropped)is(I)}let Ne=null;function Ae(I){if(!Ne){Ne=new WeakMap;let q=[g];for(;q.length;){let te=q.pop();te.tagName==="TEMPLATE"&&te.content&&Ne.set(te.content,te);for(let me of i.childrenOf(te))me.nodeType===1&&q.push(me)}}return Ne.get(I)||null}let De=I=>{let q=ut(I)||I.nodeType?I.parentNode:I.parent;return q&&q.nodeType===11?Ae(q):q};if(V.moved.size){let I=!1;for(let q of Array.from(V.moved))!ut(q)||V.identityPaired.has(q)||!m.base(q)||R(V,De(q))||(V.unpair(q),I=!0);I&&V.rematch()}Me(),M(U,V),M(V,U);for(let I of[U,V])if(I.refused)for(let q of I.refused)I.moved.has(q)||d.ambiguousMoves++;x&&(x.alignTotal=(x.alignTotal||0)+(performance.now()-A),A=performance.now());let oe=g.ownerDocument.implementation.createHTMLDocument(""),xe=new WeakMap,$e=new WeakMap,ae=[],k=[],_=new Set,re=[],Z=new Set,Be=new Set,Ke=new Set,Te=new WeakMap,it=null,et=n.lineage?.locals.length?rr():null,mt=I=>{let q=Fo(I);return q&&et&&et.consume(I.local),q},Ze=n.conflicts||"remote",ft=I=>ae.push(I),Ct=I=>ae.push(I),Dt=Or({roots:{base:g,local:P,remote:T},L:U,R:V,unitsOf:r,provenance:xe,policy:Ze}),Tt=(I,q)=>{k.push(I),q&&Dt.note(I,q)},Rt=null,jt=null,qt=ge(),un=null,Lt=Q(g,U.map.get(g),V.map.get(g),!!n.localIsBase,!!n.childrenOnly);Lt.tagName==="HTML"?oe.replaceChild(Lt,oe.documentElement):oe.body.appendChild(Lt),Rt?.drain(Lt),jt?.drain(Lt),x&&(x.build=(x.build||0)+(performance.now()-A));let Jt=n.childrenOnly?!He(Ie(Lt),Ie(T)):!fe(Lt,T),F=Dt.finish(Lt),ce=et?ir({locals:n.lineage.locals,rec:et,root:Lt,provenance:xe,segments:re,ignored:s}):null;return{doc:oe,root:Lt,provenance:xe,textMappers:$e,decisions:ae,conflicts:k,recoveryLinks:F,localDiverged:Jt,mergedScripts:_,segments:re,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==kn,L:U,R:V,stats:d,lineage:ce};function ge(){let I=new Map,q=new Set;if(n.localIsBase||!U.insertedByHash)return{partner:I,drop:q};let te=U.insertedByHash(),me=V.insertedByHash();if(!te.size||!me.size)return{partner:I,drop:q};let we={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},ie=dt=>{let Qe=0;for(let Mt=dt.parentNode;Mt;Mt=Mt.parentNode)Qe++;return Qe},ee=[],Ee=dt=>{let Qe=dt.textContent.trim();return Qe.split(/\s+/).length>=3||Qe.replace(/\s/g,"").length>=12},Ue=dt=>{let Qe=R(U,dt),Mt=R(V,dt);return Qe&&U.reverse.get(Qe.parentNode)!==dt.parentNode||Mt&&V.reverse.get(Mt.parentNode)!==dt.parentNode},_e=(dt,Qe,Mt)=>{for(let Ht of Mt.parentNode.children){let pn=Ht!==Mt&&dt.reverse.get(Ht);if(pn&&Ue(pn))return!0}let bt=dt.reverse.get(Mt.parentNode);if(bt){for(let Ht of bt.children)if(!R(Qe,Ht)&&!s(Ht))return!0}return!1},Ye=new Map([[U,new Map],[V,new Map]]),yt=(dt,Qe)=>{let Mt=Ye.get(dt),bt=Mt.get(Qe);if(bt===void 0){bt=!1;for(let Ht of Qe.children)if(dt.reverse.has(Ht)||yt(dt,Ht)){bt=!0;break}Mt.set(Qe,bt)}return bt},gt=new Map;for(let dt of me.values())for(let Qe of dt){let Mt=$(Qe);Mt&&gt.set(Mt,Qe)}for(let dt of te.values())for(let Qe of dt){let Mt=y(Qe),bt=Mt?gt.get(Mt):null;bt&&bt.tagName===Qe.tagName&&!jn(Qe,we)&&!jn(bt,we)&&!n.remoteWins(Qe)&&!n.remoteWins(bt)&&ee.push([Qe,[bt],ie(Qe),!0,!0])}for(let[dt,Qe]of te){let Mt=me.get(dt);if(!Mt)continue;let bt=Qe.length===1&&Mt.length===1;for(let Ht of Qe)!jn(Ht,we)&&!y(Ht)&&ee.push([Ht,Mt,ie(Ht),bt&&(Ee(Ht)||_e(U,V,Ht)||_e(V,U,Mt[0]))])}if(!ee.length)return{partner:I,drop:q};ee.sort((dt,Qe)=>dt[2]-Qe[2]);let $t=new Set,_t=new Set,dn=dt=>{for(let Qe of dt.querySelectorAll("*"))$t.add(Qe)},vt=(dt,Qe)=>dt.reverse.get(Qe.parentNode)||null;for(let[dt,Qe,,Mt,bt]of ee){if($t.has(dt)||_t.has(dt)||bt&&(yt(U,dt)||yt(V,Qe[0])))continue;let Ht=vt(U,dt),pn=wn=>!_t.has(wn)&&!$t.has(wn)&&(bt||wn.tagName===dt.tagName&&!$(wn)&&i.equalUnits(dt,wn)),sn=Qe.find(wn=>Ht&&vt(V,wn)===Ht&&pn(wn))||(Mt?Qe.find(pn):null);if(!sn)continue;_t.add(dt),_t.add(sn);let Zt=Ht&&vt(V,sn)===Ht;(!bt||!Zt||i.equalUnits(dt,sn))&&(dn(dt),dn(sn)),!Zt&&(I.set(dt,sn),I.set(sn,dt),q.add(Ze==="local"?sn:dt))}return{partner:I,drop:q}}function Le(I,q,te){if(Z.add(I),qt.drop.has(I))return null;Z.add(te);let me=q==="local"?I:te,we=q==="local"?te:I,ie;return i.equalUnits(me,we)?(ie=se(me,"local",!0),xe.get(ie).remote=we):ie=pe(me,we),Tt({kind:"structure",el:ie,detail:"both-moved",base:null,local:me,remote:we},{unit:{b:null,l:me,r:we}}),ft({kind:"insert",el:ie,source:"both"}),ie}function Me(){if(!U.weak||!V.weak||!U.weak.size||!V.weak.size||!U.unpair)return;let I=new Map;for(let te of U.weak){let me=R(U,te);ut(te)&&ut(me)&&I.set(i.unitHash(me),te)}let q=!1;for(let te of Array.from(V.weak)){let me=R(V,te);if(!ut(te)||!ut(me))continue;let we=I.get(i.unitHash(me));if(!we||we===te||!U.weak.has(we)||R(U,te)&&R(V,we))continue;let ie=R(U,we);ie.tagName===me.tagName&&i.equalUnits(ie,me)&&(U.unpair(we),V.unpair(te),q=!0)}q&&(U.rematch(),V.rematch())}function M(I,q){if(!I.weak||!I.weak.size||!q.insertedByHash)return;let te=q.insertedByHash();if(!te.size)return;let me=!1;for(let we of Array.from(I.weak)){let ie=R(I,we);if(!ie)continue;let ee=I===U?y(ie):$(ie);if(ee){let Ue=(I===U?w:B)?.get(ee);Ue&&Ue.tagName===ie.tagName&&!q.reverse.has(Ue)&&(I.unpair(we),me=!0);continue}let Ee=te.get(i.unitHash(ie));Ee&&Ee.some(Ue=>Ue.tagName===ie.tagName&&i.equalUnits(Ue,ie))&&(I.unpair(we),me=!0)}me&&I.rematch()}function R(I,q){if(!q)return null;if(I.map.has(q))return I.map.get(q);let te=[],me=De(q);for(;me&&!I.map.has(me);me=De(me))te.push(me);let we=me;if(!we||!I.identical.has(we))return null;I.pairIdenticalChildren(we);for(let ee=te.length-1;ee>=0;ee--)I.pairIdenticalChildren(te[ee]);let ie=I.map.get(q)||null;return ie&&d.lazyTwins++,ie}function z(I,q,te,me){if(ut(I)&&Ln.has(I.tagName)&&!U.identical.has(I)&&(I.previousSibling?.nodeType===3||I.nextSibling?.nodeType===3)){let Ee=De(I),Ue=R(U,I),_e=R(V,I);Ue&&_e&&Wt(Ue,R(U,Ee),U)&&!Wt(_e,R(V,Ee),V)&&(jt||=Cr({L:U,R:V,twinIn:R,unitsOf:r,view:J,parentOf:De,ignored:s,remoteWins:n.remoteWins,eligible:Ye=>ut(Ye)&&Ln.has(Ye.tagName),build:Q,out:oe,policy:Ze,provenance:xe,textMappers:$e,segments:re,conflicts:k,conflict:Tt,decisions:ae}),jt.ensureOwner(I))}if(q===null)return null;if(me!==void 0)return Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(I,q,te,!!me),me&&(Rt.produced(I,me),Be.add(I)),me;if(Be.has(I)||Ke.has(I))return Tt({kind:"structure",el:null,detail:"both-moved",base:I},{subject:I}),Be.has(I)?null:se(te,q);Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(I,q,te,!0);let we=R(U,I),ie=R(V,I);(!we||!ie)&&Tt({kind:"structure",el:null,detail:"move-beats-delete",base:I},{subject:I,deleted:we?"remote":"local"});let ee=Q(I,we,ie,!1);return(q==="local"?ft:Ct)({kind:"move",el:ee,source:q}),ee}function J(I,q,te,me){return me||!q||q===te?{el:te,asBase:!0,twin:we=>we,baseOf:we=>we,units:r(te),here:()=>!0,parentOfTwin:()=>te}:{el:q,asBase:!1,twin:we=>R(I,we),baseOf:we=>I.reverse.get(we),units:r(q),here:we=>ut(we)?we.parentNode===q||q.tagName==="TEMPLATE"&&we.parentNode===q.content:we.parent===q||q.tagName==="TEMPLATE"&&we.parent===q.content}}function ne(I,q,te){return!q||te&&te.identical.has(I)?!1:ut(I)?!i.equalUnits(I,q)||!je(I,q,te):I.value!==q.value}function je(I,q,te){if(!te||I===q)return!0;let me=[[I,q]];for(;me.length;){let[we,ie]=me.pop(),ee=r(we),Ee=r(ie);for(let Ue=0;Ue<ee.length&&Ue<Ee.length;Ue++){let _e=ee[Ue],Ye=Ee[Ue];if(!ut(_e)||!ut(Ye))continue;let yt=te.map.get(_e);if(yt!==void 0&&yt!==Ye)return!1;let gt=te.reverse.get(Ye);if(gt!==void 0&&gt!==_e)return!1;me.push([_e,Ye])}}return!0}function Q(I,q,te,me,we=!1){let ie=me||(te?n.remoteWins(te):n.remoteWins(I)),ee=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?oe.createElementNS(I.namespaceURI,I.tagName):oe.createElement(I.tagName),Ee={base:I,local:q||null,remote:te||null};if(xe.set(ee,Ee),ie&&!me&&q&&ne(I,q,U)&&(!te||!i.equalUnits(q,te))&&Tt({kind:"structure",el:ee,detail:"remote-wins",base:I,local:q,remote:te||null},{subject:I}),Z.add(I),Be.add(I),q&&Z.add(q),te&&Z.add(te),n.skipUnchanged&&!we&&(n.localIsBase||U.identical.has(I))&&te&&V.identical.has(I)&&!n.remoteWins(I)){Ee.unchanged=!0;for(let _e of I.attributes)_e.namespaceURI?ee.setAttributeNS(_e.namespaceURI,_e.name,_e.value):ee.setAttribute(_e.name,_e.value);return Rt?.produced(I,ee),ee}Ke.add(I),we||Ce(I,ie?I:q,te,ee);let Ue=I.tagName;if(mn(I))Ve(I,ie?I:q,te,ee);else if(Ue==="TEXTAREA")ee.textContent=Oe(I.textContent,(ie?I:q)?(ie?I:q).textContent:I.textContent,te?te.textContent:I.textContent,ee,"text");else if(!jt?.render(I,ee)){let _e=ke(I,q,te,ie,ee),Ye=Ue==="TEMPLATE"&&ee.content?ee.content:ee;for(let yt of _e)Ye.appendChild(yt)}return Ke.delete(I),Rt?.produced(I,ee),ee}function Oe(I,q,te,me,we){if(q===te)return q;if(q===I)return te!==I&&Ct({kind:we,node:me,source:"remote"}),te;if(te===I)return ft({kind:we,node:me,source:"local"}),q;let ie=Ze==="local"?q:te;return Tt({kind:we,node:me,base:I,local:q,remote:te,resolved:ie},{site:"whole",el:me}),ae.push({kind:we,node:me,source:"both"}),ie}function Ve(I,q,te,me){let we=I.textContent,ie=q?q.textContent:we,ee=te?te.textContent:we,Ee=b?fo(I,n.mergeTags,!0):null;if(Ee&&ie!==ee){let Ue=te&&te.getAttribute("merge-key")||I.getAttribute("merge-key"),{text:_e,warnings:Ye}=Go(n.localIsBase?void 0:we,ie,ee,{parse:Ee.recognizer.parse,keyCandidates:Ue?Ue.split(/[\s,]+/).filter(Boolean):void 0});for(let yt of Ye)console.warn(`[hyper-morph] merge "${Ee.raw}": ${yt}`);me.textContent=_e,_.add(me),_e!==ee?ft({kind:"text",node:me,source:_e===ie?"local":"both"}):_e!==we&&Ct({kind:"text",node:me,source:"remote"});return}me.textContent=Oe(we,ie,ee,me,"text")}function Ce(I,q,te,me){let we=new Map;for(let ie of[I,q,te])if(ie)for(let ee of ie.attributes)n.ignoreAttribute(ie,ee.name)||we.set(ee.name,ee);for(let[ie,ee]of we){let Ee=I?I.getAttribute(ie):null,Ue=q?q.getAttribute(ie):Ee,_e=te?te.getAttribute(ie):Ee,Ye;Ue===_e?Ye=Ue:Ue===Ee?(Ye=_e,Ct({kind:"attr",el:me,name:ie,source:"remote"})):_e===Ee?(Ye=Ue,ft({kind:"attr",el:me,name:ie,source:"local"})):(Ye=be(ie,Ee,Ue,_e),Ye===void 0&&(Ye=Ze==="local"?Ue:_e,Tt({kind:"attr",el:me,name:ie,base:Ee,local:Ue,remote:_e,resolved:Ye},{el:me,sample:ee})),ae.push({kind:"attr",el:me,name:ie,source:"both"})),Ye!=null&&(ee.namespaceURI?me.setAttributeNS(ee.namespaceURI,ee.name,Ye):me.setAttribute(ie,Ye))}}function be(I,q,te,me){if(I==="class"){let we=_e=>new Set((_e||"").split(/\s+/).filter(Boolean)),ie=we(q),ee=we(te),Ee=we(me),Ue=new Set;for(let _e of new Set([...ie,...ee,...Ee])){let Ye=ie.has(_e),yt=ee.has(_e),gt=Ee.has(_e);(yt===gt?yt:yt===Ye?gt:yt)&&Ue.add(_e)}return[...Ue].join(" ")}if(I==="style"){let we=Ye=>{let yt=new Map;if(!Ye)return yt;let gt=0,$t=null,_t="",dn=()=>{let vt=_t.indexOf(":");vt>0&&yt.set(_t.slice(0,vt).trim(),_t.slice(vt+1).trim()),_t=""};for(let vt of Ye){if($t){_t+=vt,vt===$t&&($t=null);continue}if(vt==='"'||vt==="'"){$t=vt,_t+=vt;continue}if(vt==="("?gt++:vt===")"&&gt--,vt===";"&&gt===0){dn();continue}_t+=vt}return _t.trim()&&dn(),yt},ie=we(q),ee=we(te),Ee=we(me),Ue=new Map,_e=!1;for(let Ye of new Set([...ie.keys(),...ee.keys(),...Ee.keys()])){let yt=ie.get(Ye)??null,gt=ee.get(Ye)??null,$t=Ee.get(Ye)??null,_t;gt===$t?_t=gt:gt===yt?_t=$t:$t===yt?_t=gt:(_t=Ze==="local"?gt:$t,_e=!0),_t!=null&&Ue.set(Ye,_t)}return _e?void 0:[...Ue].map(([Ye,yt])=>`${Ye}: ${yt}`).join("; ")}}function H(I,q,te,me){let we=I.value,ie=me?we:q?q.value:"",ee=te?te.value:"";Z.add(I),q&&Z.add(q),te&&Z.add(te);let Ee=ro(we,ie,ee,Ze),Ue=Ee.text===""?null:oe.createTextNode(Ee.text);Ue&&(xe.set(Ue,{base:I.nodes,local:q?q.nodes:null,remote:te?te.nodes:null}),$e.set(Ue,Ee.mapLocalOffset)),ie!==we&&ee!==we?ae.push({kind:"text",node:Ue,source:"both"}):ie!==we?ft({kind:"text",node:Ue,source:"local"}):ee!==we&&Ct({kind:"text",node:Ue,source:"remote"});for(let _e of Ee.conflicts)Tt({kind:"text",node:Ue,base:we.slice(_e.bs,_e.be),local:_e.local,remote:_e.remote,resolved:_e.resolved},{site:"run",bRun:I,lRun:q,rRun:te,node:Ue,c:_e});return Ue}function X(I,q){return _n(I,q).every(te=>te.bs===te.be)}function de(I,q){let te=I?I.value:"",me=q?q.value:"",we;if(te===me||!me?we=te:te?X(te,me)?we=me:X(me,te)?we=te:(we=Ze==="local"?te:Ze==="both"?te+me:me,Tt({kind:"structure",el:null,detail:"insert-collision",local:te,remote:me,resolved:we},{unit:{b:null,l:I,r:q},localLost:Ze==="remote"})):we=me,I&&Z.add(I),q&&Z.add(q),we==="")return null;let ie=oe.createTextNode(we);return xe.set(ie,{base:null,local:I?I.nodes:null,remote:q?q.nodes:null}),te?ft({kind:"insert",el:ie,source:me&&te===me?"both":"local"}):Ct({kind:"insert",el:ie,source:"remote"}),ie}function pe(I,q){let te={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},me=Ee=>r(Ee).every(Ue=>ut(Ue)?jn(Ue,te):Ue.kind==="text"),we=null;if(me(I)&&me(q)){let Ee=I.textContent,Ue=q.textContent;Ee===Ue||X(Ue,Ee)?we=q:X(Ee,Ue)&&(we=I)}if(!we){let Ee=Ze==="local",Ue=se(Ee?I:q,Ee?"local":"remote",!0),_e=xe.get(Ue);return Ee?_e.remote=q:_e.local=I,Tt({kind:"structure",el:Ue,detail:"insert-collision",local:I,remote:q,resolved:Ee?I:q},{unit:{b:null,l:I,r:q},localLost:!Ee}),Ue}let ie=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?oe.createElementNS(I.namespaceURI,I.tagName):oe.createElement(I.tagName);Ce(null,I,q,ie),xe.set(ie,{base:null,local:I,remote:q}),Z.add(I),Z.add(q);let ee=mt({base:Array.from(we.childNodes),local:Array.from(I.childNodes),remote:Array.from(q.childNodes),out:oe,policy:Ze,idOf:{local:v,remote:O},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:xe,textMappers:$e,conflicts:k,conflict:Tt,scope:{base:null,local:I,remote:q,units:[],at:0},synthetic:!0,decisions:ae,node:ie});re.push(...ee.segments);for(let Ee of ee.nodes)ie.appendChild(Ee);return ie}function se(I,q,te=!1){if(!te&&ut(I)){let ee=qt.partner.get(I);if(ee)return Le(I,q,ee)}if(!ut(I)){if(I.value==="")return null;let ee=I.kind==="comment"?oe.createComment(I.value):oe.createTextNode(I.value);return xe.set(ee,{base:null,local:q==="local"?I.nodes:null,remote:q==="remote"?I.nodes:null}),Z.add(I),ee}let me=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?oe.createElementNS(I.namespaceURI,I.tagName):oe.createElement(I.tagName);for(let ee of I.attributes)ee.namespaceURI?me.setAttributeNS(ee.namespaceURI,ee.name,ee.value):me.setAttribute(ee.name,ee.value);xe.set(me,{base:null,local:q==="local"?I:null,remote:q==="remote"?I:null}),Z.add(I);let we=I.tagName==="TEMPLATE"&&me.content?me.content:me,ie=q==="local"?U:V;for(let ee of r(I)){let Ee=ut(ee)?ie.reverse.get(ee):null;if(Ee&&z(Ee,null,null),Ee&&Be.has(Ee)){Tt({kind:"structure",el:null,detail:"both-moved",base:Ee},{subject:Ee});continue}if(Ee&&!Ke.has(Ee)){let _e=R(U,Ee)||null,Ye=R(V,Ee)||null;if(_e||Ye){Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(Ee,q,ee,!0);let yt=Q(Ee,_e,Ye,!1);q==="local"?ft({kind:"move",el:yt,source:"local"}):Ct({kind:"move",el:yt,source:"remote"}),we.appendChild(yt);continue}}let Ue=se(ee,q);Ue&&we.appendChild(Ue)}if(!te&&qt.drop.size&&I.tagName==="DIV"&&!we.firstChild&&!I.attributes.length&&!(q==="local"?v(I):O(I))&&!ie.reverse.has(I)&&!s(I)&&!n.remoteWins(I)){let ee=I.firstChild;if(ee&&ee===I.lastChild&&ut(ee)&&(qt.drop.has(ee)||un?.has(ee)))return(un||=new WeakSet).add(I),null}return me}function ke(I,q,te,me,we){q&&U.identical.has(I)&&U.pairIdenticalChildren(I),te&&V.identical.has(I)&&V.pairIdenticalChildren(I);let ie=J(U,q,I,me),ee=J(V,te,I,!1),Ee=r(I),Ue=new Set(Ee),_e=new Map;for(let le=0;le<Ee.length;le++)_e.set(Ee[le],le);let Ye=[],yt=new Set,gt=new Map,$t=new Set,_t=et&&[],dn=et&&[],vt=new Set,dt=[],Qe=null;if(!ie.asBase&&!ee.asBase&&!U.identical.has(I)&&!V.identical.has(I))for(let le of Ee){if(!ut(le)||!Ln.has(le.tagName))continue;let ze=ie.twin(le),qe=ee.twin(le);ze&&qe&&(!ie.here(ze)||!ee.here(qe))&&z(le,null,null)}vo();let Mt=le=>{let ze=[];for(let qe of le.units){if(vt.has(qe))continue;let st=le.baseOf(qe);st&&Ue.has(st)&&ze.push(st)}return ze},bt=le=>Mt(le).map(ze=>_e.get(ze)),Ht=le=>le.every((ze,qe)=>qe===0||ze>=le[qe-1]),pn=!ie.asBase&&!Ht(bt(ie)),sn=!ee.asBase&&!Ht(bt(ee));pn&&sn&&Tt({kind:"structure",el:we,detail:"both-reordered",base:I},{subject:I,lKept:Mt(ie),rKept:Mt(ee)});let Zt=sn||!pn?{V:ee,A:V,side:"remote",other:ie,otherA:U,otherSide:"local"}:{V:ie,A:U,side:"local",other:ee,otherA:V,otherSide:"remote"};pn?ft({kind:"move",el:null,source:sn?"both":"local",base:I}):sn&&Ct({kind:"move",el:null,source:"remote",base:I});let wn=ie.asBase?[]:ie.units.filter(le=>!ie.baseOf(le)&&!vt.has(le)&&!qt.partner.has(le)),On=ee.asBase?[]:ee.units.filter(le=>!ee.baseOf(le)&&!vt.has(le)&&!qt.partner.has(le)),In=new Map;if(wn.length&&On.length){let le=new Map,ze=new Map;for(let Ge of On){if(ut(Ge)){let St=O(Ge);St&&le.set(St,Ge)}let Xe=i.unitHash(Ge);ze.has(Xe)||ze.set(Xe,[]),ze.get(Xe).push(Ge)}let qe=(Ge,Xe)=>{let St=Ge.units.indexOf(Xe);for(let tt=St-1;tt>=0;tt--){let wt=Ge.baseOf(Ge.units[tt]);if(wt)return wt}return"start"},st=new Map,At=new Map;for(let Ge of On){let Xe=qe(ee,Ge);ut(Ge)?(At.has(Xe)||At.set(Xe,[]),At.get(Xe).push(Ge)):Ge.kind==="text"&&!st.has(Xe)&&st.set(Xe,Ge)}for(let Ge of wn){let Xe=null;if(ut(Ge)){let tt=v(Ge);tt&&le.has(tt)&&!In.has(le.get(tt))&&(Xe=le.get(tt))}else if(Ge.kind==="text"){let tt=st.get(qe(ie,Ge));tt&&!In.has(tt)&&(Xe=tt)}let St=!!y(Ge);if(!Xe&&!St){let tt=ze.get(i.unitHash(Ge));tt&&(Xe=tt.find(wt=>!In.has(wt)&&ut(wt)===ut(Ge)&&(ut(wt)?wt.tagName===Ge.tagName&&!$(wt):wt.kind===Ge.kind)&&i.equalUnits(Ge,wt))||null)}if(!Xe&&ut(Ge)&&!St){let tt=m.local(Ge),wt=(At.get(qe(ie,Ge))||[]).filter(lt=>{let zt=m.remote(lt);return!In.has(lt)&&lt.tagName===Ge.tagName&&!$(lt)&&!(tt&&zt&&tt!==zt)&&i.similar(Ge,lt)});wt.length===1&&(Xe=wt[0])}Xe&&(In.set(Xe,Ge),In.set(Ge,Xe))}}let Lo=le=>{if(jt?.consumes(le))return null;if(Z.has(le)||Rt?.has(le))return gt.get(le)||null;let ze=ie.twin(le),qe=ee.twin(le),st=ze&&!ie.asBase&&!ie.here(ze),At=qe&&!ee.asBase&&!ee.here(qe);if(st||At){if((!ze||!qe)&&Tt({kind:"structure",el:null,detail:"move-beats-delete",base:le},{subject:le,deleted:ze?"remote":"local"}),!ot(le))return ut(le)?(Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),st&&Rt.plan(le,"local",ze),At&&Rt.plan(le,"remote",qe)):Z.add(le),null;Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le})}if(ze&&!qe&&!ie.asBase&&!ee.asBase&&ut(le)&&Ln.has(le.tagName)&&!n.remoteWins(le)&&!n.remoteWins(ze)&&ne(le,ze,U)&&ul(le,Ie(ee.el),s)){let wt={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},lt=zt=>ut(zt)?jn(zt,wt):zt.kind==="text";if(r(le).every(lt)&&r(ze).every(lt)){let zt=mt({base:[le],local:[ze],remote:[],blocks:new Set([le,ze]),out:oe,policy:Ze,L:U,R:V,idOf:{base:p,local:v,remote:O},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(en,Tn,Kn)=>Q(en,Tn,Kn,!1),cloneUnit:se,mergeAttrs:Ce,atomKey:i.exactUnitKey,moveIn:z,moveBuilt:z,movePlanned:z,provenance:xe,textMappers:$e,conflicts:k,conflict:Tt,scope:{base:I,local:ie.el,remote:ee.el,units:Ee,at:_e.get(le)},decisions:ae,node:we});re.push(...zt.segments),Z.add(le),Z.add(ze);let Et=oe.createDocumentFragment();for(let en of zt.nodes)Et.appendChild(en);return gt.set(le,Et),gt.set(ze,Et),Et}}if(!ze&&!qe)return Z.add(le),Ct({kind:"remove",source:"both",base:le}),null;if(!ze&&!ne(le,qe,V))return Z.add(le),ft({kind:"remove",source:"local",base:le}),null;if(!qe&&!ne(le,ze,U))return Z.add(le),Ct({kind:"remove",source:"remote",base:le}),et&&(et.remove(ze),_t.push({bk:le,lk:ze})),null;let Ge=!ze||!qe,Xe=ie.asBase?R(U,le)||null:ze,St=ee.asBase&&ut(le)&&(V.identityPaired.has(le)||!m.base(le))&&R(V,le)||qe,tt;return ut(le)?tt=Q(le,Xe,St,ie.asBase):le.kind==="comment"?tt=Je(le,Xe,qe,ie.asBase):tt=H(le,Xe,qe,ie.asBase),Z.add(le),tt&&(gt.set(le,tt),ze&&gt.set(ze,tt),qe&&gt.set(qe,tt),Ge&&(Tt({kind:"structure",el:tt,detail:"edit-beats-delete",base:le},{subject:le,deleted:ze?"remote":"local"}),ze?ft({kind:"insert",el:tt,source:"local"}):Ct({kind:"insert",el:tt,source:"remote"}))),tt},yo=(le,ze,qe,st)=>{if(jt?.consumes(le))return null;if(Z.has(le))return gt.get(le)||null;let At=ze.baseOf(le);if(At&&Ue.has(At))return vt.has(At)&&!vt.has(le)?Gn(At,le,st):Lo(At);if(At)return Ro(At,le,st);let Ge=In.get(le);if(Ge){let St=st==="local"?le:Ge,tt=st==="local"?Ge:le,wt;return ut(St)?i.equalUnits(St,tt)?(wt=se(St,"local"),wt&&(xe.get(wt).remote=tt)):wt=pe(St,tt):wt=de(St,tt),Z.add(St),Z.add(tt),wt&&(gt.set(St,wt),gt.set(tt,wt),ut(St)&&ft({kind:"insert",el:wt,source:"both"})),wt}let Xe=se(le,st);return Xe&&(gt.set(le,Xe),st==="local"?ft({kind:"insert",el:Xe,source:"local"}):(Ct({kind:"insert",el:Xe,source:"remote"}),et&&ut(le)&&!qt.partner.has(le)&&dn.push({su:le,node:Xe}))),Xe},Gn=(le,ze,qe)=>{let st;return ut(le)?(st=z(le,qe,ze),st&&Z.add(ze)):(st=se(ze,qe),Z.add(ze),st&&(qe==="local"?ft:Ct)({kind:"insert",el:st,source:qe})),st&&gt.set(ze,st),st},Ro=(le,ze,qe)=>{z(le,null,null);let At=R(qe==="local"?V:U,le),Ge=ze,Xe=At?Wt(At,qe==="local"?te:q,qe==="local"?V:U):!1,St=At&&!Xe&&!Ut(le,At);if(St&&qe===Zt.otherSide)return Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le}),null;if(St&&Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le}),At||Tt({kind:"structure",el:null,detail:"move-beats-delete",base:le},{subject:le,deleted:qe==="local"?"remote":"local"}),Ke.has(le)){Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le});let wt=se(Ge,qe);return wt&&gt.set(ze,wt),wt}ut(le)&&(Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(le,qe,Ge,!0));let tt=ut(le)?Q(le,qe==="local"?Ge:R(U,le)||null,qe==="remote"?Ge:R(V,le)||null,!1):null;return tt&&(gt.set(le,tt),gt.set(ze,tt),At&&gt.set(At,tt),qe==="local"?ft({kind:"move",el:tt,source:"local"}):Ct({kind:"move",el:tt,source:"remote"})),tt};for(let le of Zt.V.units){if(vt.has(le)){if(Qe?.has(le)){for(let st of Qe.get(le))yt.has(st)||(Ye.push(st),yt.add(st));continue}let qe=gt.get(le);yt.has(qe)||(Ye.push(qe),yt.add(qe));continue}if(Z.has(le)&&!(gt.get(le)&&yt.has(gt.get(le)))){let qe=Zt.V.baseOf(le);qe&&!Ue.has(qe)&&Tt({kind:"structure",el:null,detail:"both-moved",base:qe},{subject:qe});continue}let ze=yo(le,Zt.V,Zt.A,Zt.side);ze&&!yt.has(ze)&&(Ye.push(ze),yt.add(ze),!Zt.V.baseOf(le)&&!In.has(le)&&!vt.has(le)&&$t.add(ze))}for(let le of dt)yt.has(le.frag)||(Ye.splice(le.previous&&yt.has(le.previous)?Ye.indexOf(le.previous)+1:xo(le.at),0,le.frag),yt.add(le.frag));if(!Zt.other.asBase){let le=Zt.other,ze=Zt.otherSide,qe=Zt.otherA,st=null,At=0,Ge=null;for(let Xe of le.units){let St=gt.get(Xe);if(St&&yt.has(St)){st=St,Ge=null;continue}if(Z.has(Xe)){let lt=le.baseOf(Xe);lt&&!Ue.has(lt)&&Tt({kind:"structure",el:null,detail:"both-moved",base:lt},{subject:lt});continue}let tt=yo(Xe,le,qe,ze);if(!tt)continue;let wt;if(Ge)wt=Ye.indexOf(Ge)+1;else if(st){if(wt=Ye.indexOf(st)+1,ze==="remote")for(;wt<Ye.length&&$t.has(Ye[wt]);)wt++}else wt=At++;Ye.splice(wt,0,tt),yt.add(tt),Ge=tt}}for(let le=0;le<Ee.length;le++){let ze=Ee[le];if(Z.has(ze))continue;let qe=Lo(ze);qe&&Ye.splice(xo(le),0,qe)}return et&&_t.length&&dn.length&&es(),Ye;function es(){if(pn||sn)return;let le=new Set(Ye),ze=lt=>lt&&Ue.has(lt)&&le.has(gt.get(lt))?lt:null,qe=(lt,zt)=>{let Et=[{prev:null,units:[]}];for(let en of lt){let Tn=ze(zt(en));Tn?Et.push({prev:Tn,units:[]}):Et[Et.length-1].units.push(en)}return Et},st=qe(Ee,lt=>lt),At=qe(ee.units,ee.baseOf),Ge=ie.asBase?null:qe(ie.units,ie.baseOf),Xe=lt=>lt.length===st.length&&lt.every((zt,Et)=>zt.prev===st[Et].prev);if(!Xe(At)||Ge&&!Xe(Ge))return;let St=new Map(_t.map(lt=>[lt.bk,lt])),tt=new Map(dn.map(lt=>[lt.su,lt])),wt=lt=>lt?Ye.indexOf(gt.get(lt)):-1;for(let lt=0;lt<st.length;lt++){if(st[lt].units.length!==1||At[lt].units.length!==1)continue;let zt=St.get(st[lt].units[0]),Et=tt.get(At[lt].units[0]);if(!zt||!Et||Ge&&(Ge[lt].units.length!==1||Ge[lt].units[0]!==zt.lk))continue;let en=wt(st[lt].prev);(lt+1<st.length?wt(st[lt+1].prev):Ye.length)-en!==2||Ye[en+1]!==Et.node||Wn(zt.bk,zt.lk,Et.su)&&et.link(zt.lk,Et.node)}}function ko(le,ze,qe,st){let At=Et=>{let en=Et.filter(ut);return en.length===1?en[0]:null},Ge=At(le),Xe=At(ze),St=At(qe);if(!Ge||!Xe||!St)return;let tt=le.indexOf(Ge);if(ze.indexOf(Xe)!==tt||qe.indexOf(St)!==tt||le.length!==ze.length||le.length!==qe.length)return;for(let Et=0;Et<le.length;Et++)if(Et!==tt&&(le[Et].value!==ze[Et].value||le[Et].value!==qe[Et].value))return;if((ie.asBase?Ge:ie.twin(Ge))!==Xe||ee.twin(Ge)||V.reverse.get(St)||Xe!==Ge&&ne(Ge,Xe,U))return;let wt=st.filter(Et=>Et.nodeType===1);if(wt.length!==1||xe.get(wt[0])?.remote!==St)return;let lt=Et=>Et.map(en=>ut(en)?"":en.value??en.nodeValue).join(""),zt=st.indexOf(wt[0]);lt(st.slice(0,zt))!==lt(le.slice(0,tt))||lt(st.slice(zt+1))!==lt(le.slice(tt+1))||Wn(Ge,Xe,St)&&et.link(Xe,wt[0])}function Wn(le,ze,qe){if(!ut(ze)||!ut(qe)||!ut(le)||ze.namespaceURI!==qe.namespaceURI||ze.localName===qe.localName)return!1;for(let Xe of[ze,qe])if(Xe.tagName==="TEMPLATE"||mn(Xe)||Xe.querySelector("template"))return!1;if(n.remoteWins(le)||n.remoteWins(qe)||s(qe)||ze.attributes.length!==qe.attributes.length)return!1;for(let Xe of ze.attributes)if(qe.getAttributeNS(Xe.namespaceURI,Xe.localName)!==Xe.value)return!1;let st=ze.childNodes,At=qe.childNodes;if(st.length!==At.length)return!1;for(let Xe=0;Xe<st.length;Xe++)if(!st[Xe].isEqualNode(At[Xe]))return!1;let Ge=[[le,qe]];for(;Ge.length;){let[Xe,St]=Ge.pop();if(Xe.children.length!==St.children.length)return!1;for(let tt=0;tt<St.children.length;tt++){let wt=V.reverse.get(St.children[tt]);if(wt!==void 0&&wt!==Xe.children[tt])return!1;Ge.push([Xe.children[tt],St.children[tt]])}}return!0}function xo(le){for(let ze=le-1;ze>=0;ze--){let qe=gt.get(Ee[ze]);if(qe){let st=Ye.indexOf(qe);if(st>=0)return st+1}}return 0}function vo(){if((ie.asBase||U.identical.has(I))&&(ee.asBase||V.identical.has(I)))return;let le={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},ze=at=>ut(at)?jn(at,le):at.kind==="text";if(!ie.asBase&&!ee.asBase)for(let at of Ee){if(!ut(at)||!Ln.has(at.tagName))continue;let rt=ie.twin(at),Pt=ee.twin(at);if(!rt&&Pt||rt&&!Pt){let ct=Br({base:Ee,views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:It=>ut(It)&&Ln.has(It.tagName)&&!s(It)&&!n.remoteWins(It),baseId:m.base,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey});ct&&(ie=ct[0],ee=ct[1]);break}}let qe=!ie.asBase&&!ee.asBase&&Ee.length>=2&&Ln.has(Ee[0].tagName)&&ie.units.length===Ee.length&&ee.units.length===Ee.length?hr({base:Ee,local:ie.units,remote:ee.units,localTwin:ie.twin,remoteTwin:ee.twin,eligible:at=>ut(at)&&Ln.has(at.tagName)&&!s(at)&&!n.remoteWins(at),nodes:{base:Array.from(Ie(I).childNodes),local:Array.from(Ie(ie.el).childNodes),remote:Array.from(Ie(ee.el).childNodes)}}):null,st=null,At=null;if(!qe&&!ie.asBase&&!ee.asBase&&(Es(Ee)||Es(ie.units)||Es(ee.units))){let at={ignored:s,remoteWins:()=>!1},rt=ct=>ze(ct)||ut(ct)&&n.remoteWins(ct)&&vn.has(ct.tagName)&&jn(ct,at),Pt=ct=>ut(ct)?Ln.has(ct.tagName)&&!s(ct)&&!n.remoteWins(ct)&&r(ct).every(rt):ct.kind==="text";st=Dr({onUncertainOwner:ct=>{let It=n.identity.local(ct.local);It&&It===n.identity.remote(ct.remote)||(At||=[]).push(ct)},onUncertainSource:ct=>{it||(it=new Map);let It=it.get(ct.source);It||it.set(ct.source,It=[]);for(let tn of It)if(tn.side===ct.side&&tn.from===ct.from&&tn.to===ct.to)return;It.push(ct)},base:Ee,views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:Pt,ignored:s,remoteWins:n.remoteWins,baseId:m.base,atomKey:i.exactUnitKey})}if(At){Qe||=new Map;for(let at of At){let{source:rt,local:Pt,remote:ct}=at,It={map:new Map,reverse:new Map,identical:new Set},tn=mt({base:[rt],local:[Pt],remote:[ct],out:oe,policy:"both",L:It,R:It,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey,cloneUnit:se,provenance:xe,textMappers:$e,conflicts:k,decisions:ae,conflict:(Bt,rn)=>Tt(Bt,{...rn,policy:"both"}),scope:{base:I,local:ie.el,remote:ee.el,units:Ee,at:_e.get(rt)},node:we});re.push(...tn.segments);for(let Bt of[rt,Pt,ct])Z.add(Bt),vt.add(Bt),Qe.set(Bt,tn.nodes),gt.set(Bt,tn.nodes[tn.nodes.length-1]);for(let Bt=0;Bt<tn.nodes.length;Bt++)dt.push({frag:tn.nodes[Bt],at:_e.get(rt),previous:Bt?tn.nodes[Bt-1]:null})}}let Ge=qe?qe.blocks:null;if(st){Ge=new Set;for(let at of st.blocks)Ge.add(at)}let Xe=at=>!jt?.consumes(at)&&(Ge&&Ge.has(at)||ze(at)),St=Ee.map(Xe);if(!St.includes(!0))return;let tt=at=>{let rt=at.units,Pt=new Map;for(let Yt=0;Yt<rt.length;Yt++)Pt.set(rt[Yt],Yt);let ct=[],It=-1;for(let Yt=0;Yt<Ee.length;Yt++){if(St[Yt])continue;let Ot=at.twin(Ee[Yt]),kt=Ot?Pt.get(Ot):void 0;kt===void 0||kt<=It||Xe(Ot)||(ct.push([Yt,kt]),It=kt)}let tn=[],Bt=-1,rn=-1;for(let Yt=0;Yt<=ct.length;Yt++){let[Ot,kt]=Yt<ct.length?ct[Yt]:[Ee.length,rt.length],Kt={bLo:-1,bHi:-1,from:rn+1,to:kt,inlineStart:-1,inlineEnd:-1,next:kt};for(let nn=Bt+1;nn<Ot;nn++)St[nn]&&(Kt.bLo<0&&(Kt.bLo=nn),Kt.bHi=nn);for(let nn=rn+1;nn<kt;nn++){let Vn=rt[nn];Xe(Vn)&&(Kt.inlineStart<0&&(Kt.inlineStart=nn),Kt.inlineEnd=nn+1)}tn.push(Kt),Bt=Ot,rn=kt}return{units:rt,list:tn}},wt=tt(ie),lt=tt(ee),zt=[];for(let at of[wt,lt])for(let rt of at.list)rt.bLo>=0&&zt.push([rt.bLo,rt.bHi]);zt.sort((at,rt)=>at[0]-rt[0]);let Et=[];for(let[at,rt]of zt){let Pt=Et[Et.length-1];Pt&&at<=Pt.hi?Pt.hi=Math.max(Pt.hi,rt):Et.push({lo:at,hi:rt})}let en=(at,rt)=>at.length===rt.length&&at.every((Pt,ct)=>i.equalUnits(Pt,rt[ct])),Tn=at=>!ut(at)&&at.kind==="comment",Kn=at=>{if(!at.length)return[];let rt=(Bt,rn)=>ut(Bt)?Bt:Bt.nodes[rn?Bt.nodes.length-1:0],Pt=rt(at[0]),ct=rt(at[at.length-1],!0),It=Bt=>Bt&&ut(Bt)&&s(Bt);for(;It(Pt.previousSibling);)Pt=Pt.previousSibling;for(;It(ct.nextSibling);)ct=ct.nextSibling;let tn=[];for(let Bt=Pt;Bt&&(tn.push(Bt),Bt!==ct);Bt=Bt.nextSibling);return tn},Po=at=>at.some(rt=>ut(rt)&&s(rt));for(let at of Et){let rt=Ee.slice(at.lo,at.hi+1),Pt=null;if(st)for(let Ot of rt){let kt=st.certificatesBySource.get(Ot);kt&&(Pt||=[]).push(...kt)}let ct=ie.asBase?null:Is(wt,at),It=ee.asBase?null:Is(lt,at);if(Pt){let Ot=[new Set(ct||rt),new Set(It||rt)],kt=Pt.some(Kt=>!Ot[Kt.side].has(Kt.target));for(let Kt of rt)if(Ge.has(Kt))for(let[nn,Vn]of[[0,ie],[1,ee]]){let Yn=Vn.twin(Kt);Yn&&Vn.here(Yn)&&!Ot[nn].has(Yn)&&(kt=!0)}if(kt)continue}if(rt.some(Tn)||ct&&ct.some(Tn)||It&&It.some(Tn))continue;let tn=Kn(ct||rt),Bt=Kn(It||rt);if((!ct||en(rt,ct))&&(!It||en(rt,It))&&!(ct&&Po(tn)))continue;let rn=mt({base:Kn(rt),sourceRetentions:it?.get(I),local:tn,remote:Bt,out:oe,policy:Ze,blocks:Ge,scopeUnits:Pt?[rt,ct||rt,It||rt]:null,certifiedOrigins:Pt?(Ot,kt,Kt,nn,Vn,Yn)=>jr({certificates:Pt,scopes:[rt,ct||rt,It||rt],flats:[Ot,kt,Kt],keys:[nn,Vn,Yn]}):null,prepared:qe?qe.prepared:null,nativeTransfers:qe,L:ct?U:Ur(U,I),R:It?V:Ur(V,I),idOf:{base:p,local:v,remote:O},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Ot,kt,Kt)=>Q(Ot,kt,Kt,!1),cloneUnit:se,mergeAttrs:Ce,atomKey:i.exactUnitKey,moveIn:z,moveBuilt:z,movePlanned:z,provenance:xe,textMappers:$e,conflicts:k,conflict:Tt,scope:{base:I,local:ie.asBase?null:ie.el,remote:ee.asBase?null:ee.el,units:Ee,at:at.lo},decisions:ae,node:we});if(!rn){if(Pt){let Ot=pr({certificates:Pt,scopes:[rt,ct||rt,It||rt],views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:kt=>ut(kt)&&Ln.has(kt.tagName)&&!s(kt)&&!n.remoteWins(kt),baseId:m.base});for(let kt of Ot.records){it||=new Map;let Kt=it.get(kt.source);Kt||it.set(kt.source,Kt=[]),Kt.push(kt)}}continue}if(re.push(...rn.segments),qe){let Ot=new Map;for(let kt of rn.nodes){let Kt=xe.get(kt)?.base;if(!Kt||Ot.has(Kt))throw new Error("Invalid native transfer owner output");Ot.set(Kt,kt)}if(Ot.size!==qe.owners.length)throw new Error("Incomplete native transfer owner output");for(let kt of qe.owners){let Kt=Ot.get(kt.base);if(!Kt)throw new Error("Missing native transfer owner output");for(let nn of[kt.base,kt.local,kt.remote])Z.add(nn),vt.add(nn),gt.set(nn,Kt);dt.push({frag:Kt,at:_e.get(kt.base)})}continue}if(et&&ko(rt,ct||rt,It||rt,rn.nodes),rn.unitOutputs){Qe||=new Map;for(let Ot of[...rt,...ct||[],...It||[]]){let kt=rn.unitOutputs.get(Ot)||[];Z.add(Ot),vt.add(Ot),Qe.set(Ot,kt),kt.length&&gt.set(Ot,kt[kt.length-1])}for(let Ot=0;Ot<rn.nodes.length;Ot++)dt.push({frag:rn.nodes[Ot],at:at.lo,previous:Ot>0?rn.nodes[Ot-1]:null});continue}et&&ko(rt,ct||rt,It||rt,rn.nodes);let Yt=oe.createDocumentFragment();for(let Ot of rn.nodes)Yt.appendChild(Ot);for(let Ot of[...rt,...ct||[],...It||[]])Z.add(Ot),vt.add(Ot),gt.set(Ot,Yt);dt.push({frag:Yt,at:at.lo})}}}function fe(I,q){let te=xe.get(I);return te&&te.unchanged?!te.remote||te.remote===q?!0:G(te.remote,q):I.tagName!==q.tagName||!Pe(I,q)?!1:He(Ie(I),Ie(q))}function G(I,q){return I===q?!0:I.tagName!==q.tagName||I.namespaceURI!==q.namespaceURI||!Pe(I,q)?!1:ue(Ie(I),Ie(q))}function ue(I,q){let te=Se(I,s),me=Se(q,s);if(te.length!==me.length)return!1;for(let we=0;we<te.length;we++){let ie=te[we],ee=me[we];if(typeof ie=="string"||typeof ee=="string"){if(ie!==ee)return!1}else{if(ie.nodeType!==ee.nodeType)return!1;if(ie.nodeType===1){if(!G(ie,ee))return!1}else if(ie.nodeValue!==ee.nodeValue)return!1}}return!0}function Ie(I){return I.tagName==="TEMPLATE"&&I.content?I.content:I}function Pe(I,q){let te=0;for(let me of I.attributes)if(!n.ignoreAttribute(I,me.name)&&(te++,q.getAttribute(me.name)!==me.value))return!1;for(let me of q.attributes)n.ignoreAttribute(q,me.name)||te--;return te===0}function He(I,q){let te=Se(I,we=>{let ie=xe.get(we);return!!(ie&&ie.pinned)}),me=Se(q,s);if(te.length!==me.length)return!1;for(let we=0;we<te.length;we++){let ie=te[we],ee=me[we];if(typeof ie=="string"||typeof ee=="string"){if(ie!==ee)return!1}else{if(ie.nodeType!==ee.nodeType)return!1;if(ie.nodeType===1){if(!fe(ie,ee))return!1}else if(ie.nodeValue!==ee.nodeValue)return!1}}return!0}function Se(I,q){let te=[],me=null;for(let we=I.firstChild;we;we=we.nextSibling){if(we.nodeType===3){me=me===null?we.nodeValue:me+we.nodeValue;continue}we.nodeType===1&&q(we)||(me!==null&&(me!==""&&te.push(me),me=null),te.push(we))}return me!==null&&me!==""&&te.push(me),te}function Je(I,q,te,me){let we=I.value,ie=me?we:q?q.value:"",ee=te?te.value:"";Z.add(I),q&&Z.add(q),te&&Z.add(te);let Ee=ie===ee?ie:ie===we?ee:ee===we||Ze==="local"?ie:ee,Ue={site:"comment",bRun:I,lRun:q,rRun:te,node:null};if(ie!==we&&ee!==we&&ie!==ee&&Tt({kind:"text",node:null,base:we,local:ie,remote:ee,resolved:Ee},Ue),!q&&!te)return null;let _e=oe.createComment(Ee);return Ue.node=_e,xe.set(_e,{base:I.nodes,local:q?q.nodes:null,remote:te?te.nodes:null}),_e}function nt(I,q){let te=R(q,I);if(!te)return null;let me=ut(te)?te.parentNode:te.parent,we=ut(I)?I.parentNode:I.parent;return R(q,we)===me?null:q.reverse.get(me)||null}function ot(I){let q=new Set([I]),te=I;for(let me=0;me<64;me++){let we=nt(te,U)||nt(te,V);if(!we)return!1;if(we===I||ut(I)&&ut(we)&&I.contains(we)||q.has(we))return!0;q.add(we),te=we}return!0}function Wt(I,q,te){if(!q)return!1;let me=ut(I)?I.parentNode:I.parent;return me===q||q.tagName==="TEMPLATE"&&me===q.content}function Ut(I,q){let te=De(I),me=R(U,te);if(me&&Wt(q,me,U))return!0;let we=R(V,te);return!!(we&&Wt(q,we,V))}}function Ur(e,o){return e.map.get(o)?Vr():{map:{get:n=>n&&n.nodeType===1&&e.map.get(n)||n,has:()=>!0},reverse:{get:n=>e.reverse.get(n)||n,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Vr(){let e={get:o=>o,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Hr=new Set(["INPUT","OPTION","TEXTAREA"]),Ls=/[\t\n\f\r ]+/;function Wr(e,o,t,n){let s=e.ownerDocument,{provenance:d,textMappers:i}=t,r=n.hooks,l=[],u=[],b=[],a=new Set,h=[],p=[],v=new Map,O=new Set,m=new Map,c=t.conflicts.length>0||n.trackInserted===!0,g=new Map,P=new Set,T=new Map,x=(F,ce)=>{let ge=T.get(F);ge||T.set(F,ge=new Set),ge.add(ce)},A=c?new Set:null,E=(F,ce,ge)=>{let Le=r.beforeAttributeUpdated(F,ce,ge);return c&&Le===!1&&x(ce,F),Le},S=F=>!!F&&(F===e||e.contains(F)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(F)),N=new Map,C=new Map,j=new Map,D=new Set,B=new Map;(function F(ce){let ge=d.get(ce);if(ge){if(ce.nodeType===1){let Me=ge.local?n.toLive(ge.local):null;Me&&S(Me)&&Me.nodeType===1&&(N.set(ce,Me),C.set(Me,ce))}else if(Array.isArray(ge.local)){let Me=V(ge.local,ge.local.map(M=>n.toLive(M)).filter(M=>M&&S(M)&&M.nodeType===ce.nodeType));if(Me.length&&(N.set(ce,Me[0]),C.set(Me[0],ce),j.set(ce,Me)),Array.isArray(ge.caret))for(let M of ge.caret){let R=n.toLive(M.node);if(!R||!S(R)||R.nodeType!==3)continue;let z=B.get(R);Array.isArray(z)||B.set(R,z=[]),z.push({merged:ce,from:M.from,to:M.to,flatStart:M.flatStart})}else{let M=0;for(let R of Me)B.set(R,{merged:ce,shift:M}),M+=R.nodeValue.length}}}let Le=ce.nodeType===1&&ce.tagName==="TEMPLATE"&&ce.content?ce.content.childNodes:ce.childNodes;for(let Me of Le)F(Me)})(o);let w=new Set;for(let F of N.values())w.add(F);for(let F of j.values())for(let ce of F)w.add(ce);let y=n.localRoot&&n.localRoot!==e?new Set:null;if(y){for(let F=n.localRoot.firstElementChild;F;F=F.nextElementSibling)if(F.tagName==="HEAD")for(let ce=F.firstElementChild;ce;ce=ce.nextElementSibling){let ge=n.toLive(ce);ge&&y.add(ge)}}for(let F of t.segments||[])Ne(F);let $=n.restoreFocus===!1?null:dl(s,B);n.childrenOnly?xe(Ae(e),Ae(o)):De(e,o);for(let{node:F,parent:ce}of h)a.has(F)||!F.parentNode||F.nodeType===1&&(n.ignored(F)||$e(F))||it(F,ce);return hl(s,$,B,i,j,m,D),{applied:l,moved:u,replaced:b,identities:p,mergedScriptsLive:O,liveOf:N,heldBy:m,runOf:j,keptRuns:D,insertedLive:g,vetoed:P,vetoedAttrs:T,removedVetoes:A};function U(F,ce){let ge=F.slice(ce.bs,ce.be),Le=0;for(;Le<ge.length&&Le<ce.text.length&&ge[Le]===ce.text[Le];)Le++;let Me=0;for(;Me<ge.length-Le&&Me<ce.text.length-Le&&ge[ge.length-1-Me]===ce.text[ce.text.length-1-Me];)Me++;return{bs:ce.bs+Le,be:ce.be-Me,text:ce.text.slice(Le,ce.text.length-Me)}}function V(F,ce){if(!ce.length)return ce;let ge=[];for(let M of F){let R=M.parentNode;if(!R)continue;let z=v.get(R);if(!z){z=new Set;for(let J=R.firstChild;J;J=J.nextSibling)J.nodeType===3&&z.add(n.toLive(J));v.set(R,z)}ge.includes(z)||ge.push(z)}let Le={has:M=>ge.some(R=>R.has(M))},Me=[];for(let M of ce){Me.push(M);for(let R=M.nextSibling;R&&R.nodeType===3&&!Le.has(R)&&!Me.includes(R);R=R.nextSibling)Me.push(R)}return Me}function Ne(F){let ce=[];for(let be of F.localNodes){let H=n.toLive(be.node);if(!H||!S(H)||H.nodeType!==3)return;ce.push(H)}let ge=V(F.localNodes.map(be=>be.node),ce);if(!ge.length)return;let Le=ge.map(be=>be.nodeValue).join(""),{flatLocal:Me,lToM:M,mapLocal:R}=F;if(Le===Me)return;let z=F.textNodes.map(be=>({node:be.node,ms:be.ms,me:be.me})),J=[],ne=0;for(let be of ge)J.push(ne),ne+=be.nodeValue.length;let je=(be,H)=>ge.find((X,de)=>J[de]<=be&&be+H<=J[de]+X.nodeValue.length)||null,Q=[],Oe=0;for(let be of _n(Me,Le).map(H=>U(Me,H))){let H=be.bs+Oe;Oe+=be.text.length-(be.be-be.bs);let X,de;if(be.be>be.bs){X=M[be.bs];let pe=X>=0;for(let se=be.bs;pe&&se<be.be;se++)M[se]!==X+(se-be.bs)&&(pe=!1);if(!pe)continue;de=X+(be.be-be.bs)}else{let pe=be.bs>0?M[be.bs-1]:0,se=be.bs<Me.length?M[be.bs]:0;if(pe<0||se<0)continue;X=de=R(be.bs)}Q.push({ms:X,me:de,text:be.text,live:de===X?je(H,be.text.length):null})}Q.sort((be,H)=>H.ms-be.ms);let Ve=(be,H)=>(j.get(be.node)||[N.get(be.node)]).includes(H),Ce=be=>!!be&&be.nodeType===1&&vn.has(be.tagName);for(let be of Q){let H=z.find(de=>de.ms<=be.ms&&be.me<=de.me&&be.ms<de.me);if(H&&be.live&&H.ms===be.ms&&!Ve(H,be.live)){let de=z.find(pe=>pe.me===be.ms&&Ve(pe,be.live));de&&(H=de)}if(!H&&be.me===be.ms){let de=z.find(fe=>fe.me===be.ms),pe=z.find(fe=>fe.ms===be.ms),se=de||pe;if(!se)continue;let ke=se.node;for(;Ce(ke.parentNode)&&(de?ke.parentNode.lastChild:ke.parentNode.firstChild)===ke;)ke=ke.parentNode;if(ke===se.node)H=se;else{let fe=ke.ownerDocument.createTextNode(be.text);ke.parentNode.insertBefore(fe,de?ke.nextSibling:ke);continue}}if(!H)continue;let X=H.node.nodeValue;H.node.nodeValue=X.slice(0,be.ms-H.ms)+be.text+X.slice(be.me-H.ms),H.me+=be.text.length-(be.me-be.ms)}}function Ae(F){return F.nodeType===1&&F.tagName==="TEMPLATE"&&F.content?F.content:F}function De(F,ce){a.add(F);let ge=d.get(ce);if(ge&&ge.remote&&t.remoteIdOf){let Me=t.remoteIdOf(ge.remote);Me&&p.push([F,Me])}if(ge&&ge.unchanged){t.customIdentity&&ge.remote&&re(F,ge.remote),ge.remote&&_(F,ge.remote);return}if(r.beforeNodeMorphed(F,ce)===!1){P.add(ce);return}Dt(F,ce,n.keepLiveOnly&&ge&&ge.local&&ge.local.nodeType===1&&ge.local!==F?ge.local:null);let Le=F.tagName;if(mn(F))F.textContent!==ce.textContent&&(l.push({kind:"text",node:F,before:F.textContent,after:ce.textContent}),F.textContent=ce.textContent),t.mergedScripts.has(ce)&&O.add(F);else if(Le==="TEXTAREA")Jt(F,ce,ge);else{un(F,ce,ge);let Me=Le==="TEMPLATE"&&F.content?F.content:F,M=Le==="TEMPLATE"&&ce.content?ce.content:ce;n.protectFocusedValue==="subtree"&&Rt(F)&&F!==s.body?oe(Me):xe(Me,M)}r.afterNodeMorphed(F,ce)}function oe(F){for(let ce=F.firstChild;ce;ce=ce.nextSibling){let ge=C.get(ce);ge&&N.get(ge.parentNode)!==F||(a.add(ce),ce.nodeType===1&&oe(ce))}}function xe(F,ce){let ge=Ke(F.firstChild),Le=new Set;for(let Me of Array.from(ce.childNodes)){let M=N.get(Me);M&&a.has(M)&&!Le.has(M)&&(M=null);let R=d.get(Me);if(R&&R.pinned){M&&M.nodeType===1&&((M.parentNode!==F||Ke(M.nextSibling)!==ge)&&Te(F,M,ge),a.add(M),Le.add(M));continue}if(M&&M.nodeType===1){if(M!==ge){let ne=M.parentNode;if(ne===F&&ge&&jt(M)){let je=M.nextSibling;for(let Q=ge;Q&&Q!==M;){let Oe=Q.nextSibling;Te(F,Q,je),Q=Oe}}else Te(F,M,ge),ne!==F&&(u.push(M),l.push({kind:"move",el:M,from:ne,to:F}))}Le.add(M),De(M,Me),ge=Ke(M.nextSibling);continue}if(M&&M.nodeType!==1){let ne=j.get(Me)||[M],je=ne.map(Oe=>Oe.nodeValue).join(""),Q=Me.nodeValue;if(Me.nodeType===3){let Oe=ae(Me);Oe!=null&&je!==Oe&&(Q=ro(Oe,je,Me.nodeValue).text)}if(ne.length>1&&je===Q&&!ne.includes(ge,1)&&ne.every((Oe,Ve)=>Oe.parentNode===F&&(Ve===0||ne[Ve-1].nextSibling===Oe))){if(M!==ge)for(let Oe of ne)Te(F,Oe,ge);r.beforeNodeMorphed(M,Me)!==!1?r.afterNodeMorphed(M,Me):c&&P.add(Me);for(let Oe of ne)a.add(Oe),Le.add(Oe);m.set(Me,M),D.add(Me),ge=Ke(ne[ne.length-1].nextSibling);continue}M!==ge&&Te(F,M,ge),r.beforeNodeMorphed(M,Me)!==!1?(M.nodeValue!==Q&&(l.push({kind:"text",node:M,before:M.nodeValue,after:Q}),M.nodeValue=Q),r.afterNodeMorphed(M,Me)):P.add(Me),a.add(M),Le.add(M),m.set(Me,M),ge=Ke(M.nextSibling);continue}if(Me.nodeType===3&&ge&&ge.nodeType===3&&!a.has(ge)&&!B.has(ge)){ge.nodeValue!==Me.nodeValue&&(l.push({kind:"text",node:ge,before:ge.nodeValue,after:Me.nodeValue}),ge.nodeValue=Me.nodeValue),a.add(ge),m.set(Me,ge),ge=Ke(ge.nextSibling);continue}let z=d.get(Me),J=et(z&&z.unchanged&&z.remote?z.remote:Me);if(r.beforeNodeAdded(J)===!1){P.add(Me);continue}F.insertBefore(J,ge),a.add(J),c&&g.set(Me,J),J.nodeType===3&&m.set(Me,J),J.nodeType===1&&(b.push(J),Be(J,Me),t.customIdentity&&z&&z.unchanged&&z.remote&&re(J,z.remote),mn(J)||mt(J,Me),n.formState==="property"&&qt(z)&&_(J,z.remote)),ge=Ke(J.nextSibling),l.push({kind:"insert",node:J,parent:F}),r.afterNodeAdded(J)}for(let Me of Array.from(F.childNodes))a.has(Me)||Le.has(Me)||Me.nodeType===1&&(n.ignored(Me)||$e(Me))||(w.has(Me)?h.push({node:Me,parent:F}):it(Me,F))}function $e(F){return F.parentNode&&F.parentNode.nodeType===1&&F.parentNode.tagName==="HEAD"&&(y&&!y.has(F)||n.preserve&&n.preserve(F)===!0)}function ae(F){let ce=d.get(F);return!ce||!Array.isArray(ce.local)?null:ce.local.map(ge=>ge.nodeValue).join("")}function k(F){return d.get(F)}function _(F,ce){if(!Hr.has(F.tagName)&&!F.querySelector("input,option,textarea"))return;let ge=(Le,Me)=>{if(Le.tagName!==Me.tagName)return;Le.tagName==="TEXTAREA"?Jt(Le,Me,{remote:Me}):Hr.has(Le.tagName)&&un(Le,Me,{remote:Me});let M=Z(Le),R=Z(Me);if(M.length===R.length)for(let z=0;z<M.length;z++)ge(M[z],R[z])};ge(F,ce)}function re(F,ce){let ge=Z(F),Le=Z(ce);if(ge.length===Le.length)for(let Me=0;Me<ge.length;Me++){let M=t.remoteIdOf(Le[Me]);M&&p.push([ge[Me],M]),re(ge[Me],Le[Me])}}function Z(F){let ce=F.tagName==="TEMPLATE"&&F.content?F.content:F;return Array.from(ce.children).filter(ge=>!n.ignored(ge))}function Be(F,ce){if(!t.remoteIdOf)return;let ge=(Le,Me)=>{let M=d.get(Me);if(M&&M.remote&&Me.nodeType===1){let J=t.remoteIdOf(M.remote);J&&p.push([Le,J])}let R=Le.childNodes,z=Me.childNodes;for(let J=0;J<R.length&&J<z.length;J++)ge(R[J],z[J])};ge(F,ce)}function Ke(F){for(;F&&F.nodeType===1&&n.ignored(F);)F=F.nextSibling;return F}function Te(F,ce,ge){if(typeof F.moveBefore=="function"&&ce.ownerDocument===F.ownerDocument)try{F.moveBefore(ce,ge);return}catch{}F.insertBefore(ce,ge)}function it(F,ce){if(r.beforeNodeRemoved(F)===!1){c&&A.add(F);return}F.parentNode.removeChild(F),l.push({kind:"remove",node:F,parent:ce}),r.afterNodeRemoved(F)}function et(F){if(mn(F))return Ao(F,s);let ce=s.importNode(F,!0);if(ce.nodeType===1)for(let ge of Array.from(ce.querySelectorAll("script")))mn(ge)&&ge.replaceWith(Ao(ge,s));return ce}function mt(F,ce){let ge=F.tagName==="TEMPLATE"&&F.content?F.content:F,Le=ce.tagName==="TEMPLATE"&&ce.content?ce.content:ce,Me=Array.from(ge.childNodes),M=Array.from(Le.childNodes);for(let R=0;R<M.length&&R<Me.length;R++){let z=M[R],J=Me[R],ne=N.get(z);ne&&a.has(ne)&&(ne=null);let je=d.get(z);if(je&&je.pinned){if(ne&&ne.nodeType===1){let Q=ne.parentNode;Te(ge,ne,J),Q!==ge&&(u.push(ne),l.push({kind:"move",el:ne,from:Q,to:ge})),a.add(ne)}J.remove();continue}if(ne){let Q=ne.parentNode;Te(ge,ne,J),J.remove(),ne.nodeType===1?(Q!==ge&&(u.push(ne),l.push({kind:"move",el:ne,from:Q,to:ge})),De(ne,z)):(a.add(ne),m.set(z,ne),ne.nodeValue!==z.nodeValue&&(l.push({kind:"text",node:ne,before:ne.nodeValue,after:z.nodeValue}),ne.nodeValue=z.nodeValue));continue}a.add(J),c&&g.set(z,J),J.nodeType===3&&m.set(z,J),je&&je.unchanged&&je.remote?(Ze(J,je.remote),t.customIdentity&&re(J,je.remote)):z.nodeType===1&&!mn(z)&&mt(J,z)}}function Ze(F,ce){let ge=F.tagName==="TEMPLATE"&&F.content?F.content:F,Le=ce.tagName==="TEMPLATE"&&ce.content?ce.content:ce;for(let Me of Array.from(Le.childNodes))ge.appendChild(et(Me))}function ft(F,ce){return ce.namespaceURI?F.getAttributeNS(ce.namespaceURI,ce.localName):F.getAttribute(ce.name)}function Ct(F,ce){let ge=new Set((ce||"").split(Ls).filter(Boolean));return(F||"").split(Ls).filter(Le=>Le&&!ge.has(Le))}function Dt(F,ce,ge){for(let Le of Array.from(ce.attributes)){if(Tt(F,Le.name)||n.ignoreAttribute(F,Le.name))continue;let Me=ft(F,Le);if(Me===Le.value||ge&&ft(ge,Le)===Le.value)continue;let M=Le.value;if(ge&&Le.name==="class"&&!Le.namespaceURI){let R=Le.value.split(Ls).filter(Boolean),z=Ct(Me,ge.getAttribute("class")).filter(J=>!R.includes(J));z.length&&(M=[...R,...z].join(" "))}if(Me!==M){if(r.beforeAttributeUpdated(Le.name,F,"update")===!1){c&&x(ce,Le.name);continue}Le.namespaceURI?F.setAttributeNS(Le.namespaceURI,Le.name,M):F.setAttribute(Le.name,M),l.push({kind:"attr",el:F,name:Le.name,before:Me,after:M})}}for(let Le of Array.from(F.attributes)){if(Tt(F,Le.name)||n.ignoreAttribute(F,Le.name)||(Le.namespaceURI?ce.hasAttributeNS(Le.namespaceURI,Le.localName):ce.hasAttribute(Le.name)))continue;if(ge&&Le.name==="class"&&!Le.namespaceURI){let R=Ct(Le.value,ge.getAttribute("class"));if(R.length){let z=R.join(" ");if(z===Le.value)continue;if(r.beforeAttributeUpdated("class",F,"update")===!1){c&&x(ce,"class");continue}F.setAttribute("class",z),l.push({kind:"attr",el:F,name:"class",before:Le.value,after:z});continue}}if(ge&&ft(ge,Le)===null)continue;if(r.beforeAttributeUpdated(Le.name,F,"remove")===!1){c&&x(ce,Le.name);continue}let M=Le.value;Le.namespaceURI?F.removeAttributeNS(Le.namespaceURI,Le.localName):F.removeAttribute(Le.name),l.push({kind:"attr",el:F,name:Le.name,before:M,after:null})}}function Tt(F,ce){let ge=F.tagName;return ge==="INPUT"?ce==="value"||ce==="checked"||ce==="disabled":ge==="OPTION"?ce==="selected":!1}function Rt(F){return F===s.activeElement}function jt(F){let ce=s.activeElement;return!!ce&&ce!==s.body&&F.contains(ce)}function qt(F){let ce=F&&F.remote;return ce&&ce.nodeType===1?ce:null}function un(F,ce,ge){let Le=F.tagName,Me=qt(ge),M=n.formState==="property"&&Me?Me:ce;if(Le==="INPUT"){let R=n.protectFocusedValue&&Rt(F),z=(F.getAttribute("type")||"").toLowerCase(),J=z!=="file"&&z!=="checkbox"&&z!=="radio",ne=Me&&Me.hasAttribute("value")&&Me.value!==Me.getAttribute("value")?Me.value:null;if(J&&!R)if(n.formState==="property"){let je=ce.getAttribute("value"),Q=F.getAttribute("value");(Q!==je||F.value!==M.value)&&E("value",F,je==null?"remove":"update")!==!1&&(Q!==je&&(je==null?F.removeAttribute("value"):F.setAttribute("value",je),l.push({kind:"attr",el:F,name:"value",before:Q,after:je})),F.value!==M.value&&(F.value=M.value))}else if(ce.hasAttribute("value")||ne!=null){let je=ne??ce.getAttribute("value");F.getAttribute("value")!==je&&E("value",F,"update")!==!1?(F.setAttribute("value",je),F.value!==je&&(F.value=je),l.push({kind:"attr",el:F,name:"value",before:null,after:je})):F.value!==je&&F.getAttribute("value")===je&&(F.value=je)}else(F.hasAttribute("value")||F.value!=="")&&E("value",F,"remove")!==!1&&(F.removeAttribute("value"),F.value="",l.push({kind:"attr",el:F,name:"value",before:"",after:null}));if(!J&&z!=="file"){let je=ce.getAttribute("value");je==null?F.hasAttribute("value")&&E("value",F,"remove")!==!1&&F.removeAttribute("value"):F.getAttribute("value")!==je&&E("value",F,"update")!==!1&&F.setAttribute("value",je)}R||(Lt(F,M,"checked"),n.formState==="property"&&F.indeterminate!==M.indeterminate&&(F.indeterminate=M.indeterminate)),Lt(F,M,"disabled")}else if(Le==="OPTION"){let R=F.parentNode&&F.closest("select");n.protectFocusedValue&&R&&Rt(R)||Lt(F,M,"selected")}}function Lt(F,ce,ge){let Le=n.formState==="property"?!!ce[ge]:ce.hasAttribute(ge);if(n.formState!=="property"){let Me=F.hasAttribute(ge);if(Me!==Le){if(E(ge,F,Le?"update":"remove")===!1)return;Le?F.setAttribute(ge,""):F.removeAttribute(ge),l.push({kind:"attr",el:F,name:ge,before:Me?"":null,after:Le?"":null})}}F[ge]!==Le&&(F[ge]=Le)}function Jt(F,ce,ge){if(n.protectFocusedValue&&Rt(F)||E("value",F,"update")===!1)return;let Le=qt(ge),Me=ce.textContent,M=Le&&Le.value!==Le.defaultValue?Le.value:Me;n.formState!=="property"&&F.textContent!==Me&&(l.push({kind:"text",node:F,before:F.textContent,after:Me}),F.textContent=Me),F.value!==M&&(F.value=M)}}function dl(e,o){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let n={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{n.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return n}let s=e.getSelection&&e.getSelection();if(s&&s.rangeCount){let d=s.getRangeAt(0);n.range={sc:d.startContainer,so:d.startOffset,ec:d.endContainer,eo:d.endOffset}}return n}function hl(e,o,t,n,s,d,i){if(!o)return;let r=o.el;if(!r.isConnected&&o.id&&(r=e.getElementById(o.id)),!r||!r.isConnected)return;if(e.activeElement!==r)try{r.focus({preventScroll:!0})}catch{}try{r.scrollTop=o.scrollTop,r.scrollLeft=o.scrollLeft}catch{}if(o.selection){try{r.setSelectionRange&&!r.selectionEnd&&o.selection[1]!=null&&r.setSelectionRange(o.selection[0],o.selection[1],o.selection[2]||"none")}catch{}return}if(!o.range)return;let l=(a,h)=>{let p=t.get(a);if(Array.isArray(p)){let v=p.find(g=>h>=g.from&&h<g.to)||p.find(g=>h===g.to)||p[p.length-1],O=d.get(v.merged);if(!O||!O.isConnected)return null;let m=n.get(v.merged),c=m&&m.flat?m.flat(v.flatStart+h):h;return[O,Math.max(0,Math.min(c,O.nodeValue.length))]}if(p&&!i.has(p.merged)){let v=(s.get(p.merged)||[a])[0];if(!v.isConnected)return null;let O=n.get(p.merged),m=p.shift+h,c=O?O(m):m;return[v,Math.max(0,Math.min(c,v.nodeValue.length))]}return a.isConnected?[a,Math.min(h,a.nodeType===3?a.nodeValue.length:a.childNodes.length)]:null},u=l(o.range.sc,o.range.so),b=l(o.range.ec,o.range.eo);if(!(!u||!b))try{let a=e.createRange();a.setStart(u[0],u[1]),a.setEnd(b[0],b[1]);let h=e.getSelection();h.removeAllRanges(),h.addRange(a)}catch{}}var pl={compared:0},ml=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function gl(e,o,t){let n=0;for(let s of e.attributes)if(!t(e,s.name)&&(n++,o.getAttribute(s.name)!==s.value))return!1;for(let s of o.attributes)t(o,s.name)||n--;return n===0}function Rs(e,o){if(e.namespaceURI!==o.namespaceURI||e.prefix!==o.prefix||e.localName!==o.localName)return!1;let t=e.attributes;if(t.length!==o.attributes.length)return!1;for(let n of t)if(o.getAttributeNS(n.namespaceURI,n.localName)!==n.value)return!1;return!0}function Kr(e,o,t,n,s,d,i,r){let l=new Map,u=new Set,b=a=>{if(n(a))return;let h=t(a);h&&(d.add(h),s.has(h)||l.has(h)?u.add(h):l.set(h,a))};for(let a of e)b(a);b(o);for(let a of i||o.querySelectorAll("*"))b(a);for(let a of u)l.delete(a),r.add(a);return l}function Fr(e,o,t,n,s,d){let i=!1;for(let b of s)b.startsWith("merge:")&&(i=!0);if(!i)return[...n];let r=new Map,l=[],u=d===kn?Io:"*";for(let b of[e,...e.querySelectorAll(u)]){if(t(b))continue;let a=o(b);if(!a||!(n.has(a)||s.has(a)))continue;let h=(r.get(a)||0)+1;r.set(a,h),h===2&&l.push(a)}return l}function qr({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:s,identity:d,baseURI:i}){if(e.tagName!==o.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||o.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!gl(e,o,s.ignoreAttribute))return{bail:"root-attrs"};let{ignored:r,remoteWins:l}=s,u=Cs(s.scripts.merge===!1?null:s.scripts.mergeTags,i),b=ae=>{let k=u(ae);return k!==null?k:d.base(ae)||null},a=ae=>{let k=u(ae);return k!==null?k:d.remote(ae)||null},h=[],p=[],v=new Map,O=new Map,m={same:v,differ:O},c=ae=>({bail:ae,comparisons:m}),g=(ae,k,_=!0)=>{if(v.get(ae)===k)return!0;if(O.get(ae)===k)return!1;if(pl.compared++,_&&ae.isEqualNode(k))return v.set(ae,k),!0;let re=ae.nodeType===k.nodeType;if(re&&ae.nodeType===1){if(re=Rs(ae,k),re){let Z=ae.firstChild,Be=k.firstChild;for(;Z&&Be;Z=Z.nextSibling,Be=Be.nextSibling)if(!g(Z,Be,!1)){re=!1;break}(Z||Be)&&(re=!1)}}else re&&(re=ae.isEqualNode(k));return(re?v:O).set(ae,k),re},P=e,T=o,x=!1,A=()=>{v.set(P,T);for(let ae=0;ae<h.length;ae++)v.set(h[ae],p[ae]);return c("equal")};for(;;){let ae=P.childNodes,k=T.childNodes;if(ae.length!==k.length)break;let _=et=>g(ae[et],k[et])?(v.set(ae[et],k[et]),!1):!0,re=-1,Z=-1;for(let et=0;et<ae.length;et++){if(ae[et].nodeType!==1)continue;let mt=0;for(let Ze=ae[et].firstElementChild;Ze;Ze=Ze.nextElementSibling)mt++;mt>=Z&&(Z=mt,re=et)}let Be=[],Ke=!1;for(let et=0;et<ae.length&&Be.length<2;et++)et!==re&&_(et)&&Be.push(et);if(re>=0&&Be.length<2&&(Be.length===0&&Rs(P,T)?(Be.push(re),Ke=!0):_(re)&&Be.push(re)),Be.length!==1){if(!x&&Be.length===0&&Rs(P,T))return A();break}let Te=ae[Be[0]],it=k[Be[0]];if(x=x||!Ke,x&&O.set(Te,it),Te.nodeType!==1||it.nodeType!==1||Te.tagName!==it.tagName)break;if(b(Te)!==a(it)){if(!x&&g(Te,it))return A();break}h.push(P),p.push(T),P=Te,T=it}O.set(P,T);for(let ae=0;ae<h.length;ae++)O.set(h[ae],p[ae]);if(P===e||P.tagName==="HEAD"||P.tagName==="BODY")return c("root-level");if(h.length<2||h[1].tagName!=="BODY")return c("not-in-body");if(r(P)||r(T))return c("ignored-ancestor");if(l(P)||l(T))return c("remote-wins-ancestor");for(let ae of h)if(ml.has(ae.tagName))return c("form-ancestor");if(P.tagName==="SCRIPT"||P.getElementsByTagName("script").length||T.getElementsByTagName("script").length)return c("script-or-template");let E=n(P);if(!E||E.nodeType!==1||E.tagName!==P.tagName)return c("no-live-twin");if(!t.contains(E))return c("live-detached");for(let ae of h){let k=n(ae);if(!k||k.nodeType!==1)return c("ancestor-live")}let S=d.base===kn&&d.remote===kn&&r===os,N=new Set,C=new Set,j=[],D=null,B=ae=>{ae&&(N.has(ae)?C.add(ae):N.add(ae))},w=(ae,k)=>{let _=u(ae),re=_!==null?_:d.base(ae)||null;return re!==(_!==null?_:d.remote(k)||null)?!1:(B(re),!0)},y=(ae,k)=>{for(let _=ae.firstElementChild,re=k.firstElementChild;_;_=_.nextElementSibling,re=re.nextElementSibling){let Z=r(_);if(Z!==r(re))return!1;if(!Z&&(!w(_,re)||!y(_,re)))return!1}return!0},$=ae=>{let k=ae+1<h.length?h[ae+1]:P;for(let _=h[ae].firstElementChild,re=p[ae].firstElementChild;_;_=_.nextElementSibling,re=re.nextElementSibling){if(_===k){let Ke=ae+1<h.length?$(ae+1):null;if(Ke)return Ke;continue}let Z=r(_);if(Z!==r(re))return"outside-id-changed";if(Z)continue;let Be=n(_);if(!Be||Be.nodeType!==1)return"sibling-live";if(j.push([_,re]),!S&&(!w(_,re)||!y(_,re)))return"outside-id-changed";ae===0&&_.tagName==="HEAD"&&b(_)&&(D=[_,re])}return null},U=$(0);if(U)return c(U);let V=new Set(h),Ne=null;if(d.base===kn){Ne=[];for(let ae of e.querySelectorAll(Io))ae===P||V.has(ae)||(P.contains(ae)?Ne.push(ae):S&&B(b(ae)))}let Ae=new Set,De=new Set,oe=new Set,xe=Kr(h,P,b,r,N,Ae,Ne,De),$e=Kr(p,T,a,r,N,Ae,d.remote===kn&&T.querySelectorAll(Io),oe);return D&&(C.has(b(D[0]))||Ae.has(b(D[0])))&&(D=null),{scope:{chain:h,root:P,onChain:V,baseIndex:xe,remoteIndex:$e,baseDropped:De,remoteDropped:oe,head:D,same:v,differ:O,dropped:[...Fr(e,b,r,C,De,d.base),...Fr(o,a,r,C,oe,d.remote)],held:ae=>{for(let k=1;k<h.length;k++)if(ae.map.get(h[k])!==p[k])return!1;for(let[k,_]of j)if(ae.map.get(k)!==_)return!1;return!0}}}}var _r=Symbol("hyper-morph-duplicate-key"),zr=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function Eo(e,o){return o.map(t=>{let n=new Map;for(let s of e){if(s.nodeType!==1)continue;let d=t(s);d==null||d===""||n.set(d,n.has(d)?_r:s)}return n})}function $r(e,o,t,n){for(let s=0;s<n.length;s++){let d=n[s](e);if(d==null||d===""||o[s].get(d)!==e)continue;let i=t[s].get(d);if(!(!i||i===_r)&&i.tagName===e.tagName)return i}return null}function mo(e,o,t){for(let n=0;n<t.length;n++){let s=t[n](e);if(!(s==null||s==="")&&o[n].get(s)===e)return!0}return!1}function Gr(e,o,t={}){let n=t.skip||(()=>!1),s=t.ignoreAttr||(()=>!1),d=t.tiers&&t.tiers.length?t.tiers:zr,i=null;function r(){return i||(i=Eo([e,...e.querySelectorAll("*")],d)),i}let l=null;function u(){return l||(l=Eo([o,...o.querySelectorAll("*")],d)),l}function b(N){return!N.parentElement||!N.parentElement.parentElement}function a(N,C,j){return b(N)||mo(N,r(),d)?(j.push({type:"subtree",el:N,base:C}),!1):!0}function h(N,C){let j=[];for(let D of N.attributes)s(N,D.name)||C.getAttribute(D.name)!==D.value&&j.push(D.name);for(let D of C.attributes)s(N,D.name)||N.hasAttribute(D.name)||j.push(D.name);return j}function p(N){let C=[],j=null,D=()=>{j!==null&&(C.push({nodeType:3,nodeValue:j}),j=null)};for(let B of N.childNodes){if(B.nodeType===3){j=(j===null?"":j)+B.nodeValue;continue}B.nodeType===1&&n(B)||(D(),(B.nodeType===1||B.nodeType===8)&&C.push(B))}return D(),C}function v(N,C){if(N.nodeType!==C.nodeType)return!1;if(N.nodeType!==1)return!0;if(N.tagName!==C.tagName)return!1;for(let j of d){let D=j(N),B=j(C);if(D!=null&&D!==""&&B!=null&&B!==""&&D!==B)return!1}return!0}function O(N){let C="";for(let j of N)j.nodeType===3&&j.nodeValue.trim()!==""?C+="\0"+j.nodeValue:j.nodeType===8&&(C+=""+j.nodeValue);return C}function m(N,C,j){let D=p(N),B=p(C);if(D.length===B.length){let ae=!0;for(let k=0;k<D.length;k++)if(!v(D[k],B[k])){ae=!1;break}if(ae){for(let k=0;k<D.length;k++){let _=D[k];if(_.nodeType===1){if(c(_,B[k],j))return!0}else if(_.nodeValue!==B[k].nodeValue)return!0}return!1}}let w=D.filter(ae=>ae.nodeType===1),y=B.filter(ae=>ae.nodeType===1);if(O(D)!==O(B))return!0;let $=Eo(w,d),U=Eo(y,d),V=[],Ne=new Set,Ae=[];for(let ae of w){let k=$r(ae,$,U,d);k&&!Ne.has(k)?(V.push([ae,k]),Ne.add(k)):Ae.push(ae)}let De=[];for(let ae of Ae)mo(ae,$,d)?j.push({type:"subtree",el:ae,base:null}):De.push(ae);let oe=[];for(let ae of y)Ne.has(ae)||(mo(ae,U,d)?j.push({type:"deletion",el:ae}):oe.push(ae));if(De.length!==oe.length)return!0;for(let ae=0;ae<De.length;ae++)if(!v(De[ae],oe[ae]))return!0;let xe=new Map(V);for(let ae=0;ae<De.length;ae++)xe.set(De[ae],oe[ae]);let $e=-1;for(let ae of w){let k=xe.get(ae);if(!k)continue;let _=y.indexOf(k);if(_<$e)return!0;$e=_}for(let ae=0;ae<De.length;ae++)if(c(De[ae],oe[ae],j))return!0;for(let[ae,k]of V)if(c(ae,k,j))return!0;return!1}function c(N,C,j){if(N.tagName!==C.tagName)return a(N,C,j);let D=h(N,C),B=[];if(m(N,C,B))return a(N,C,j);if(D.length){if(!b(N)&&!mo(C,u(),d))return!0;j.push({type:"attrs",el:N,names:D,base:C})}return j.push(...B),!1}let g=[],P=h(e,o);P.length&&g.push({type:"attrs",el:e,names:P});let T=(N,C)=>Array.from(N.children).find(j=>j.tagName===C)||null,x=T(e,"HEAD"),A=T(o,"HEAD");if(x&&A){let N=[];c(x,A,N),N.length&&g.push({type:"head",el:x})}else(x||A)&&x&&g.push({type:"head",el:x});let E=T(e,"BODY"),S=T(o,"BODY");return E&&S?c(E,S,g):E&&g.push({type:"subtree",el:E,base:null}),{entries:g}}function Yr(e,o,t={}){let n=t.tiers&&t.tiers.length?t.tiers:zr,s=e.documentElement,d=[],i=0,r=c=>({ok:!1,placed:d,held:c,skippedAttrs:i});if(!s)return r(null);function l(c){let g=[c,...c.querySelectorAll("*")];return Eo(g,n)}let u=l(s),b=new Map,a=c=>{let g=c.getRootNode(),P=b.get(g);if(!P){let T=g.nodeType===9?g.documentElement:g;P=l(T),b.set(g,P)}return P};function h(c){if(!c.parentElement&&c.tagName==="HTML")return s;if(c.parentElement&&!c.parentElement.parentElement&&c.parentElement.tagName==="HTML"){if(c.tagName==="BODY")return e.body||null;if(c.tagName==="HEAD")return e.head||null}return null}function p(c){let g=h(c);return g||$r(c,a(c),u,n)}function v(c){if(!c)return null;let g=p(c);return g&&g.isConnected?g:null}function O(c){for(let g=0;g<n.length;g++){let P=n[g](c);P!=null&&P!==""&&u[g].set(P,c)}}for(let c of o){if(c.type!=="deletion")continue;let g=p(c.el);g&&g!==s&&g.remove()}let m=o.filter(c=>c.type!=="deletion").sort((c,g)=>c.el===g.el?0:c.el.compareDocumentPosition(g.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let c of m){if(c.type==="head"){let S=e.importNode(c.el,!0);e.head?e.head.replaceWith(S):s.insertBefore(S,s.firstChild),d.push({entry:c,imported:S});continue}if(c.type==="attrs"){let S=v(c.el)||v(c.base);if(!S){i++;continue}for(let N of c.names)c.el.hasAttribute(N)?S.setAttribute(N,c.el.getAttribute(N)):S.removeAttribute(N);continue}let g=c.el;if(h(g))return r(c);let P=v(g)||v(c.base);if(P){let S=e.importNode(g,!0);P.replaceWith(S),O(S),d.push({entry:c,imported:S});continue}if(c.base!=null&&!mo(c.base,a(c.base),n)||!mo(g,a(g),n))return r(c);let T=g.parentElement;if(!T)return r(c);let x=v(T);if(!x)return r(c);let A=null;for(let S=g.previousElementSibling;S;S=S.previousElementSibling){let N=v(S);if(N&&N.parentNode===x){A=N;break}}let E=e.importNode(g,!0);if(A)x.insertBefore(E,A.nextSibling);else{let S=Array.prototype.indexOf.call(T.children,g);x.insertBefore(E,x.children[S]||null)}O(E),d.push({entry:c,imported:E})}return{ok:!0,placed:d,held:null,skippedAttrs:i}}var bl='[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"]',wl='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',yl='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function kl(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let o=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(o)}function xl(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let s=o;if(s.nodeType===9){let d=e.getAttribute("id");s=d&&s.getElementById(d)||(e.tagName==="BODY"?s.body:e.tagName==="HTML"?s.documentElement:s.body&&s.body.firstElementChild)}if((!s||s.nodeType!==1||s.tagName!==e.tagName)&&(s=vl(e,o,n)),!!s)return t?Array.from(s.childNodes):s}function vl(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let s=new Map,d=[n,...n.querySelectorAll("script")];for(let l of d){let u=fo(l,t);u&&!s.has(u.key)&&s.set(u.key,l.textContent)}if(!s.size)return null;let i=e.cloneNode(!0),r=!1;for(let l of[i,...i.querySelectorAll("script")]){let u=fo(l,t);u&&s.has(u.key)&&(l.textContent=s.get(u.key),r=!0)}return r?i:null}function Xr(e,o){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=o.implementation.createHTMLDocument(""),n=e.nodeType===1&&e.tagName==="HTML"?e:null;if(n)return t.replaceChild(t.adoptNode(n),t.documentElement),t;let s=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let d of s)t.body.appendChild(t.adoptNode(d));return t}function Qo(e,o,t={}){let n=t||{};if(!n.head?.block)return Jr(e,o,n);try{return Jr(e,o,n)}catch(s){return Promise.reject(s)}}function Jr(e,o,t){let n=t.policy||"sync",s=n==="raw"?void 0:(l,u)=>kl(l)||(n==="history"?!(u&&l.matches(yl))&&l.matches(wl):l.matches(bl)),d=t.callbacks||{},i={ignore:s,hooks:d,protectFocusedValue:t.ignoreActiveValue===!0?"subtree":!1,restoreFocus:t.restoreFocus!==!1,formState:t.formStateSync||"attribute",scripts:{execute:t.scripts?.handle!==!1,merge:t.scripts?.merge!==!1,mergeTags:t.scripts?.mergeTags||[]},head:{awaitLoads:!!t.head?.block,preserve:t.head?.shouldPreserve||(()=>!1)}};if(typeof t.key=="function"&&(i.identity={base:t.key,local:t.key,remote:t.key}),e&&e.nodeType===9)return go(Object.assign({},i,{live:e,base:t.scripts?.mergeBase||null,remote:Xr(o,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let l=Object.assign({},i,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Xr(o,e.ownerDocument)});return go(l)}t.morphStyle==="innerHTML"&&(i.children=!0);let r=xl(e,t.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return r!==void 0&&(i.base=r),Zo(e,o,i)}var Tl=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),Mn=()=>{};function Co(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let r of Object.keys(e))if(!Tl.has(r))throw new TypeError(`unknown option "${r}"`);let t=Object.assign({beforeNodeAdded:Mn,afterNodeAdded:Mn,beforeNodeRemoved:Mn,afterNodeRemoved:Mn,beforeNodeMorphed:Mn,afterNodeMorphed:Mn,beforeAttributeUpdated:Mn},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let s=e.formState||"attribute";if(!["attribute","property"].includes(s))throw new TypeError("formState must be attribute or property");let d=e.protectFocusedValue;if(d!==void 0&&typeof d!="boolean"&&d!=="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");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:ss(e.ignore,o),remoteWins:ss(e.remoteWins,o),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:n,protectFocusedValue:d===void 0?!0:d,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:s,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:i||null}}function bo(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 kn}function wo(e,o){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=jo(o,e.map),n=typeof e.then=="function"?e.then:kn;if(typeof e.first=="function"){let s=e.first;return d=>s(d)||t.get(d)||n(d)}return s=>t.get(s)||n(s)}return kn}function ei(e,o,t,n={}){let s=p=>p&&p.nodeType===9?p.documentElement:p,d=s(o),i=s(t),r=s(e)||d;if(n.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let l=Object.assign({},n);delete l.live,delete l.base,delete l.remote;let u=Co(l,[r,d,i].filter(Boolean)),b=n.identity||{},a=Fn(),h=Jo(r,d,i,{identity:{base:wo(b.base,r),local:wo(b.local,d),remote:wo(b.remote,i)},authored:{base:bo(b.base),local:bo(b.local),remote:bo(b.remote)},skipUnchanged:u.hooks.beforeNodeMorphed===Mn&&u.hooks.afterNodeMorphed===Mn,ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:d.ownerDocument&&d.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:u.children,stats:a});return delete h.recoveryLinks,delete h.lineage,h}function Ps({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:s,options:d,identity:i,childrenOnly:r,isDocument:l}){let u=Co(d,[e,o,t,n].filter(Boolean));if(u.ignored(e)){let w=Bs(),y=u.lineage?No(u.lineage,e,w):null;return{report:w,loads:[],lineage:y}}let b=e.ownerDocument,a=u.lineage?Ts(u.lineage,{liveRoot:e,localRoot:t,toLive:s}):null,h=u.scripts.execute?mr(e,u.ignored,b.baseURI):null,p=Fn(),v=u.hooks.beforeNodeMorphed===Mn&&u.hooks.afterNodeMorphed===Mn,O={identity:{base:wo(i.base,o||t),local:wo(i.local,t),remote:wo(i.remote,n)},authored:{base:bo(i.base),local:bo(i.local),remote:bo(i.remote)},ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:b.baseURI,localIsBase:!o,childrenOnly:r,skipUnchanged:v,lineage:a?{locals:a.locals}:null},m=u.fastPath&&l&&!r&&v&&o===t,c=null,g=null;if(m){let w=qr({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:s,o:u,identity:O.identity,baseURI:b.baseURI});O.comparisons=w.comparisons||w.scope,w.bail?g=w.bail:(c=Jo(o,t,n,Object.assign({},O,{stats:p,scope:w.scope})),c||(g="chain-unpaired",p=Fn()))}c||(c=Jo(o||t,t,n,Object.assign({},O,{stats:p}))),m&&(p.fastPathAttempted=1,p.fastPathTaken=g?0:1,p.fastPathFallback=g),c.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(w=>u.hooks[w]!==Mn)&&Ar(c.conflicts,c.recoveryLinks,s),u.beforeApply&&u.beforeApply(c.doc);let P=globalThis.__hyperMorphProfile,T=P?performance.now():0,x=Wr(e,c.root,c,{toLive:s,localRoot:t,ignored:u.ignored,ignoreAttribute:u.ignoreAttribute,formState:u.formState,protectFocusedValue:u.protectFocusedValue,restoreFocus:u.restoreFocus,preserve:u.head.preserve,hooks:u.hooks,childrenOnly:r,keepLiveOnly:u.keepLiveOnly,trackInserted:!!a});P&&(P.apply=(P.apply||0)+(performance.now()-T));let A=[];if(u.head.awaitLoads)for(let w of x.applied){if(w.kind!=="insert"||w.node.nodeType!==1)continue;let y=w.node;y.tagName==="LINK"&&/\bstylesheet\b/i.test(y.getAttribute("rel")||"")&&y.getAttribute("href")&&y.closest("head")&&A.push(new Promise(U=>{y.addEventListener("load",()=>U()),y.addEventListener("error",()=>U())}))}let E=null,S=null;if(h){let w=gr(e,h,{ignored:u.ignored,skip:x.mergedScriptsLive,baseURI:b.baseURI,beforeNodeAdded:u.hooks.beforeNodeAdded,afterNodeAdded:u.hooks.afterNodeAdded,trackRecovery:!!c.recoveryLinks});A.push(...w.loads),E=w.swapped,S=w.vetoed}let N=w=>E&&E.get(w)||w,C=w=>{if(x.keptRuns.has(w))return x.runOf.get(w);let y=x.liveOf.get(w)||x.heldBy.get(w)||x.insertedLive.get(w);return y?N(y):null},j=w=>{let y=w&&x.liveOf.get(w);return y?N(y):null},D=w=>{let y=w&&C(w);return Array.isArray(y)?y[0]:y};if(c.recoveryLinks){let w=(y,$,U)=>($.namespaceURI?y.getAttributeNS($.namespaceURI,$.localName):y.getAttribute($.qualifiedName))===U;Ir(c.conflicts,c.recoveryLinks,{lookup:C,vetoed:x.vetoed,vetoedAttrs:x.vetoedAttrs,removedVetoes:x.removedVetoes,vetoedLive:S,liveAttr:w,ignored:u.ignored,liveRoot:e})}let B={applied:x.applied,decisions:c.decisions.map(w=>Object.assign({},w,{node:w.node?j(w.node):null,el:w.el?j(w.el):null,applied:!!(w.node?j(w.node):w.el&&j(w.el))})),conflicts:c.conflicts.map(w=>Object.assign({},w,{node:w.node?w.kind==="text"&&w.recovery.subject.nodeType===8?D(w.node):j(w.node):w.node,el:w.el?w.kind==="structure"?D(w.el):j(w.el):w.el})),localDiverged:c.localDiverged,identities:x.identities,moved:x.moved,replaced:x.replaced,stats:p};return a&&(B.lineage=a.finish(c.lineage,C)),{report:B,loads:A,lineage:a}}var Qr=new WeakMap;function Bs(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Fn()}}function go(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");return vs(o,o.live.documentElement,n=>Sl(n))}function Sl(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let n=Qr.get(t);n||(n=Do(t),Qr.set(t,n));let s=n("remote",o.remote),d=typeof o.base=="string"&&o.base===""?null:o.base,i=d?n("base",d):null,r=o.local?o.local.root:t.documentElement,l=o.local?o.local.toLive:h=>h;js(t,s);let{report:u,loads:b,lineage:a}=Ps({liveRoot:t.documentElement,baseRoot:i?i.documentElement:null,localRoot:r,remoteRoot:s.documentElement,toLive:l,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return a?.deliver(u),Promise.all(b).then(()=>u)}function ti(e,o,t={}){return go(Object.assign({},t,{live:e,base:null,remote:o}))}function Zr(e,o){if(e==null)return{root:o.createElement("template"),first:null};if(typeof e=="string"){let n=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(n){let d=Bo(e,o),i=n[1].toLowerCase()==="html"?d.documentElement:d.body;return{root:i,first:i}}let s=o.createElement("template");return s.innerHTML=e,{root:s,first:s.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let n=o.createElement("template"),s=e.isConnected;return n.content.appendChild(s?o.importNode(e,!0):e),{root:n,first:e}}if(e.nodeType===11){let n=o.createElement("template");return n.content.appendChild(e),{root:n,first:n.content.firstElementChild}}let t=o.createElement("template");for(let n of Array.from(e))t.content.appendChild(n.parentNode?o.importNode(n,!0):n);return{root:t,first:t.content.firstElementChild}}function Zo(e,o,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return vs(t,e,n=>Nl(e,o,n))}function Nl(e,o,t={}){let n=e.ownerDocument,{base:s,...d}=t,i=!!d.children,r=Co(d,[e]);if(r.ignored(e)){let O=Bs();return r.lineage&&No(r.lineage,e,O).deliver(O),Promise.resolve(O)}let l=Zr(o,n),u=s!=null?Zr(s,n):null,b,a=null;if(i)b=l.root,a=u?u.root:null;else{if(b=l.first,a=u?u.first:null,!b){let O=Co(d),m=O.lineage?No(O.lineage,e,{}):null;O.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),O.hooks.afterNodeRemoved(e));let c={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Fn()};return m&&(c.lineage=m.result,m.deliver(c)),Promise.resolve(c)}if(b.tagName!==e.tagName){let O=Co(d,[e,b]);if(O.hooks.beforeNodeMorphed(e,b)===!1){let g=Bs();return O.lineage&&No(O.lineage,e,g).deliver(g),Promise.resolve(g)}let m=Ps({liveRoot:e,baseRoot:a&&a.tagName===e.tagName?a:null,localRoot:e,remoteRoot:b,toLive:g=>g,options:d,identity:d.identity||{},childrenOnly:!0,isDocument:!1}),c=mn(b)?Ao(b,n):n.importNode(b,!1);if(!mn(c))for(;e.firstChild;)c.appendChild(e.firstChild);return O.hooks.beforeNodeAdded(c)===!1?(Xo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):O.hooks.beforeNodeRemoved(e)===!1?(Xo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):(e.replaceWith(c),Xo(m.report.conflicts,e,c),O.hooks.afterNodeRemoved(e),O.hooks.afterNodeAdded(c),O.hooks.afterNodeMorphed(e,b),m.report.replaced.push(c),m.report.applied.push({kind:"insert",node:c,parent:c.parentNode},{kind:"remove",node:e,parent:c.parentNode}),m.lineage&&(m.report.lineage=m.lineage.remapRoot(e,c),m.lineage.deliver(m.report)),Promise.all(m.loads).then(()=>m.report))}}let{report:h,loads:p,lineage:v}=Ps({liveRoot:e,baseRoot:a,localRoot:e,remoteRoot:b,toLive:O=>O,options:d,identity:d.identity||{},childrenOnly:i,isDocument:!1});return v?.deliver(h),Promise.all(p).then(()=>h)}var Al={mergeDocument:go,morphDocument:ti,morphElement:Zo,merge3:ei,morph:Qo};return ai(Ml);})();
5
5
 
6
6
  var morph = HyperMorph.morph;
7
7