@panphora/clayjs 1.9.1 → 1.10.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 ns=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var ii=Object.getOwnPropertyNames;var li=Object.prototype.hasOwnProperty;var ai=(e,o)=>{for(var t in o)ns(e,t,{get:o[t],enumerable:!0})},ci=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of ii(o))!li.call(e,s)&&s!==t&&ns(e,s,{get:()=>o[s],enumerable:!(n=ri(o,s))||n.enumerable});return e};var fi=e=>ci(ns({},"__esModule",{value:!0}),e);var Ml={};ai(Ml,{createIdentityStore:()=>Us,createParseCache:()=>Do,default:()=>Al,diff:()=>Gn,findChangedRoots:()=>Gr,importMap:()=>jo,merge3:()=>ni,merge3Text:()=>lo,mergeDocument:()=>wo,mergeJson:()=>As,mergeScriptText:()=>Go,morph:()=>Qo,morphDocument:()=>oi,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 zn(){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 ui=new Set(["href","src","name","type","role"]),Hs=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function ro(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 di=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(" "):ui.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"+ro(A.nodeValue),hint:Vs(A.nodeValue).slice(0,64),sig:null,tok:null};else if(A.nodeType===8)E={hash:"C"+ro(A.nodeValue),hint:"",sig:null,tok:null};else if(A.nodeType===1){let S=d(A),N=ro(A.tagName+""+S.all),C="";for(let j of u(A))if(j.nodeType===1){let D=r(j);N=ro(D.hash,N),C.length<64&&(C+=" "+D.hint)}else N=ro(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")+ro(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 di}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,hi=2e3,pi=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=hi,$=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},le=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},tt=(H,X)=>{let de=Te(H);if(!de)return!0;let pe=it(X);return!pe||de===pe},bt=globalThis.__hyperMorphProfile,Ze=bt?performance.now():0;bt&&!t.scope&&(n(e),n(o),bt.meta=(bt.meta||0)+(performance.now()-Ze),Ze=performance.now()),V(e,o);let ct=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),ct.add(X))}if(ct.size){let H=[];if(t.scope)for(let se of t.scope.chain)ct.has(se)&&H.push(se);let X=[t.scope?t.scope.root:e];for(;X.length;){let se=X.pop();ct.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)&&Lt(se,pe)}t.scope&&t.scope.head&&Le(t.scope.head[0],t.scope.head[1]);function Lt(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 Dt(),Bt(),bt&&(bt.align=(bt.align||0)+(performance.now()-Ze)),{map:T,reverse:x,moved:S,identical:N,pairIdenticalChildren:z,weak:A,unpair:St,rematch:Bt,insertedByHash:Pt,refused:P,identityPaired:ct};function Bt(){be(),Dt();for(let H=0;H<B.length;){let X=B.length;Rt(H,X),H=X,Dt(),be(),Dt()}}function St(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||ct.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 Pt(){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 Dt(){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 Rt(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((Xe,nt)=>Se[nt].tagName===Xe.tagName&&Ke(Xe,Se[nt])&&!_(Xe,Se[nt])))for(let Xe=0;Xe<He.length;Xe++)Jt(He[Xe],Se[Xe])}}}function Jt(H,X){V(H,X),A.add(H),w.push([H,X]),Dt()}function F(H,X){let de=io(H,d),pe=io(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 Xe=fe[Se];if(ke.getAttributeNS(Xe.namespaceURI,Xe.localName)!==Xe.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&&ct.has(fe)||ue!==void 0&&ue!==fe&&ct.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=io(H,de),se=io(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<pi;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=io(de,G=>G.tagName),ke=io(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)||le(G))continue;let ue=H.get(n(G).hash),Ie=ue&&ue.find(Pe=>A.has(Pe)&&!_(Pe,G)&&Ke(Pe,G)&&tt(Pe,G)&&u(Pe,G)&&ge(Pe,G));Ie&&(St(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!le(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),St(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&&St(G),ke(nt)},Pe=X.get(n(G).hash);if(Pe){let nt=Pe.find(st=>st!==ue&&se(st,G)&&!_(G,st)&&tt(G,st)&&u(G,st)&&ge(G,st));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,Xe=0;for(let nt of He)if(!(nt===ue||!se(nt,G)||!Ke(G,nt)||!tt(G,nt)||_(G,nt))&&(y--<=0||i(G,nt)&&(Xe++,Se=nt,Xe>1)))break;Xe>1&&P&&P.add(G),Xe===1&&(Ie(Se),V(G,Se),xe(G,Se),S.add(G),w.push([G,Se]))}}}function io(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 mi={diff:0},Fs=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,gi=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,bi=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,wi=/\P{M}\p{M}*/gu;function yi(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(bi))if(gi.test(t))for(let n of t.match(wi))o.push(n);else o.push(t);return o}var ki=/^[  ]+$/,xi=e=>ki.test(e)?" ".repeat(e.length):e,$n=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),Nt="",cs=e=>e.every(o=>$n(o)||o.k===Nt),vi=/^[\x00-\x7f\u00A0]*$/,Ti=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Si(e){return e===""?[]:e.match(Ti)}function fn(e,o=!1){return(o?Si(e):yi(e)).map(t=>({k:xi(t),raw:t,len:t.length}))}var xn=(...e)=>e.every(o=>vi.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(mi.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 Ni(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 Wn(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=Ci(i,r)?null:Ni(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&&$n(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(),Ai(u,e);let m=ds(u);return{hunks:m.hunks,cosmetic:n.concat(m.cosmetic),parts:u,cosmeticEq:n}}function Ai(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 Mi=(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=>Mi(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?Oi(s.hunks,d.hunks,t,i,r):[s.hunks,d.hunks];return{lh:l,rh:u,cosL:i,cosR:r}}function Oi(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(!$n(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=>!$n(Ae)),j=U=>U.some(V=>!$n(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=>!$n(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 Ii=48,Ei=.3;function Ci(e,o){let t=e.filter(i=>!$n(i)),n=o.filter(i=>!$n(i));if(Math.min(t.length,n.length)<Ii)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)<Ei}var Li=(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=Wn(e,o),d=Wn(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=>Li({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 tt=Math.max(Te.bs,k.bs);tt<Math.min(Te.be,Z);tt++)Be[tt-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,tt)=>it.bs-tt.bs),Te=k.filter(it=>it.side!=="L").map(it=>it.r).sort((it,tt)=>it.bs-tt.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=bt=>bt.length&&bt.every(Ze=>Ze.kind==="open"),tt=bt=>bt.length&&bt.every(Ze=>Ze.kind==="close");if(it(Ke)&&it(Te)){let bt=Math.max(...Ke.map(ct=>B(y(k),ct.k))),Ze=Math.max(...Te.map(ct=>B(y(_),ct.k)));if(bt!==Ze)return Ze-bt}if(tt(Ke)&&tt(Te)){let bt=Math.min(...Ke.map(ct=>w(y(k),ct.k))),Ze=Math.min(...Te.map(ct=>w(y(_),ct.k)));return bt!==Ze?Ze-bt:$(_)-$(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,tt)=>{let bt=0;for(let Ze of it)Ze.be<=k.bs&&!tt.includes(Ze)&&(bt+=Ze.toks.length-(Ze.be-Ze.bs));return bt},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])),le=[];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)le.push({..._,src:k.source})}return{tokens:le,segments:U,conflicts:V,localHunks:i,remoteHunks:r,collapsedDelta:g,samePoint:P,mapLocalOffset:Ri(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 Ri(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 lo(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 Gn(e,o,t=4e3){if(e===o)return[];let n=xn(e,o),s=fn(e,n),d=fn(o,n),i=Wn(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 jn({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?jn({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 In(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 No(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(!No(c)||!No(g)||!No(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(!No(U)||!No(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=In(Ne,Ae,De,p,b,!0);if(!(oe<0)&&!(In(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 Un="\uFFFC";var Pi={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 Vn(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(!Vn(s,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Bi(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function rn(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)&&Bi(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+=Un;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 Di(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function ji(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,"&quot;")}"`;return o+">"}function co(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+=ji(u.el),s.push(u)}let l=e.atomAt.get(d);n+=l?l.el.outerHTML:e.text[d]===Nt?"":Di(e.text[d])}for(;s.length;)n+=`</${s.pop().tag.toLowerCase()}>`;return n}function Ui(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=>Ui(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 ao(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:Un,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 fo=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=fo(o),d=fo(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(Un)||l.includes(Un)||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=fo(o),d=fo(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=fo(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=ao(e,l,!1,n),b=ao(o,l,!1,s),a=ao(t,l,!1,d),h=u.length>2e4||b.length>2e4||a.length>2e4;h&&(u=ao(e,l,!0,n),b=ao(o,l,!0,s),a=ao(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):Wn(u,b),m=v?Qs(v,u,a,!h):Wn(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 uo=/\s/;function Wo(e,o,t){for(let n=o;n<t;n++)if(!uo.test(e[n]))return!1;return!0}function Vi(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&&!uo.test(e.fb.text[p])&&(h=!0)}if(l&&!h){for(let p=r.from;p<r.to;p++)if(b.toB[p]<0&&!uo.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||uo.test(e.fb.text[h.bs-1]||"")||uo.test(e.fb.text[h.be]||""))continue;return null}let p=!1;for(let v=h.bs;v<h.be;v++){if(uo.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&&Vi(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 rn(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||rn(e.base,{...e,atomize:v.base,skip:O.base}),c=e.prepared?.local||rn(e.local,{...e,atomize:v.local,skip:O.local}),g=e.prepared?.remote||rn(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]=rn(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,le=f=>new Map(f.atoms.map(L=>[L.el,L])),k=le(c),_=le(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=>!Vn(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,tt=(f,L)=>({id:it++,tag:f,base:null,local:null,remote:null,rank:L}),bt=new Map,Ze=[];for(let f of m.marks){let L=tt(f.tag,f.depth);L.block=!!f.block,L.base=f.el,L.baseMark=f,bt.set(f.el,L),Ze.push(L)}let ct=(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]},Lt=(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?bt.get(he):null;if(ye&&ye[L]&&(ye=null),!ye){let ve=ct(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=tt(Y.tag,Y.depth),ye.block=!!Y.block,ye.new=L),ye[L]=Y.el,ye[L+"Mark"]=Y,bt.set(Y.el,ye)}};Lt(c,"local",n,oe.toB),Lt(g,"remote",s,xe.toB);let Bt=f=>f.merged||f,St=f=>{let L=new Set;for(let W of f)W.block||L.add(bt.get(W.el));return L},Pt=new Map,Dt=f=>{let L=Pt.get(f);return L||(L=St(f),Pt.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=Dt(m.stackAt[Y]),ve=Dt(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),Rt=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 Yt=ge(f,c),So=ge(L,g);Yt!==So&&(W=So)}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?Rt: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,dt=H,gt=X,Ft=Yt=>Yt.bs<xt&&Yt.be>Fe||ce(Yt)&&(Yt.bs===Fe||Yt.bs===xt);W?dt++:gt++,ve&&(Fe=Math.min(Fe,Y.bs),xt=Math.max(xt,Y.be),W?gt++:dt++);let Ht=!0;for(;Ht;){for(Ht=!1;dt<Ce.length&&Ft(Ce[dt]);)Fe=Math.min(Fe,Ce[dt].bs),xt=Math.max(xt,Ce[dt].be),dt++,Ht=!0;for(;gt<be.length&&Ft(be[gt]);)Fe=Math.min(Fe,be[gt].bs),xt=Math.max(xt,be[gt].be),gt++,Ht=!0}let gn=Fe+pe,cn=Fe+se,yn=xt-Fe,Nn=xt-Fe;for(let Yt=H;Yt<dt;Yt++)yn+=Ce[Yt].text.length-(Ce[Yt].be-Ce[Yt].bs);for(let Yt=X;Yt<gt;Yt++)Nn+=be[Yt].text.length-(be[Yt].be-be[Yt].bs);let Bn=gn+yn,Dn=cn+Nn;if(ke(Fe),H<dt&&X<gt&&!$&&!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:bt,cache:[null,null]};let Yt=er(Oe,Ce,H,dt,be,X,gt,0,t),So=er(Oe,be,X,gt,Ce,H,dt,1,t);if(Yt===null!=(So===null)){let ts=Yt!==null,Ds=ts?Yt:So;if(Ds){Ve||=new Map;for(let si of Ds)Ve.set(si,ts?"local":"remote")}Q.push(ts?{src:"remote",from:cn,to:Dn}:{src:"local",from:gn,to:Bn}),de=xt,pe+=yn-(xt-Fe),se+=Nn-(xt-Fe),H=dt,X=gt;continue}}let on={kind:"text",node:e.node||null,base:co(m,Fe,xt),local:co(c,gn,Bn),remote:co(g,cn,Dn),resolved:null,range:null,bs:Fe,be:xt,lss:gn,lse:Bn,rss:cn,rse:Dn},Jn=e.sourceRetentions?$s(e.sourceRetentions,e.scope?.base,m,c,g,t,on):t;on.resolved=Jn==="local"?on.local:Jn==="remote"?on.remote:on.local+on.remote,Jn!=="remote"&&Q.push({src:"local",from:gn,to:Bn,conflict:on}),Jn!=="local"&&Q.push({src:"remote",from:cn,to:Dn,conflict:on});let Qn={site:"inline",policy:Jn,fb:m,fl:c,fr:g,scope:e.scope||null,synthetic:!!e.synthetic,full:x,merged:a};h.push(Qn),b(on,Qn),de=xt,pe+=yn-(xt-Fe),se+=Nn-(xt-Fe),H=dt,X=gt}ke($e);let fe=m.text,G=[];if(Ae.respell.size||De.respell.size){let f=fo(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 Xe=ue.length,nt=new Int32Array($e+1).fill(-1),st=new Int32Array(c.text.length+1).fill(-1),Kt=new Int32Array(g.text.length+1).fill(-1);for(let f=0;f<Xe;f++)Ie[f]>=0&&(nt[Ie[f]]=f),Pe[f]>=0&&(st[Pe[f]]=f),He[f]>=0&&(Kt[He[f]]=f);let Vt=(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(bt.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,bt.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=Vt(L.localMark,st);if(W)for(let K of q){if(K.merged||K.tag!==L.tag||!!K.block!=!!L.block)continue;let Y=Vt(K.remoteMark,Kt);if(Y&&Math.min(W[1],Y[1])-Math.max(W[0],Y[0])>0){te(L,K);break}}}}Pt.clear();let me=f=>{for(let L of f)if(L.block)return Bt(bt.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(Xe).fill(null),ee=new Set;if(e.nativeTransfers)for(let f=0;f<Xe;f++){let L=Se[f].owner;ie[f]=L?Bt(bt.get(L)):Ie[f]>=0?me(m.stackAt[Ie[f]]):null}else if(we){let f=(Re,Fe,xt)=>{let dt=new Set([Re,Fe,xt]);dt.delete(null);let gt=[];for(let Ht of dt){let gn=Ht===Re,cn=Ht===Fe,yn=Ht===xt;(cn===yn?cn:cn===gn?yn:cn)&&gt.push(Ht)}if(gt.length<=1)return gt[0]||null;let Ft=t==="local"?Fe:xt;return gt.includes(Ft)?Ft:gt[0]},L=(Re,Fe)=>Fe>=0?me(Re.stackAt[Fe]):null,W=new Map;for(let Re=0;Re<Xe;Re++){if(ue[Re]!==Nt)continue;let Fe=Ie[Re]>=0?L(m,Ie[Re]):null,xt=L(c,Pe[Re]),dt=L(g,He[Re]);W.set(Re,[Fe,Ie[Re]>=0?f(Fe,xt,dt):xt||dt])}let K=new Set([...W.values()].map(Re=>Re[1])),Y=Re=>Re!==Nt&&Re!==Un&&!/\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<Xe;Re++){if(ue[Re]!==Nt)continue;let[Fe,xt]=W.get(Re),dt=he(ve,Re),gt=xt,Ft=ye.get(gt)===gt&&dt===gt;gt&&ye.has(gt)&&!Ft&&Fe&&!ye.has(Fe)&&!K.has(Fe)&&(gt=Fe),gt&&!ye.has(gt)&&ye.set(gt,dt);for(let Ht=ve;Ht<=Re;Ht++)ie[Ht]=gt;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 dt=0;dt<Xe;dt++)(ue[dt]===Nt||dt===Xe-1)&&(Re.push([Fe,dt]),Fe=dt+1);let xt=new Set(ie);for(let dt=0;dt<Re.length;dt++){let[gt,Ft]=Re[dt];if(ie[Ft])continue;let Ht=gt;for(;Ht<=Ft&&!Y(ue[Ht]);)Ht++;if(Ht>Ft)continue;let gn=L(m,Ie[Ht]),cn=L(c,Pe[Ht]),yn=L(g,He[Ht]),Nn=f(gn,cn,yn)||cn||yn||gn;if(Nn&&!xt.has(Nn)){xt.add(Nn);for(let on=gt;on<=Ft;on++)ie[on]=Nn;continue}let Bn=dt>0&&ie[Re[dt-1][1]],Dn=dt+1<Re.length&&ie[Re[dt+1][1]];if(Bn)ee.add(Re[dt-1][1]);else if(Dn&&ue[Ft]===Nt)ee.add(Ft);else continue;for(let on=gt;on<=Ft;on++)ie[on]=Bn||Dn}}}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,st],[f.remoteMark,Kt]]){let Y=W&&Vt(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=bt.get(f[he].el);ye===L&&(K=he),ye===W&&(Y=he)}return K>=0&&Y>=0?K-Y:0},Ge=(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,wt=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 dt=m.stackAt[L],gt=c.stackAt[W],Ft=g.stackAt[K],Ht=yt.get(dt);Ht||yt.set(dt,Ht=new Map);let gn=Ht.get(gt);gn||Ht.set(gt,gn=new Map);let cn=gn.get(Ft);if(cn)return cn;let yn=Dt(dt),Nn=Dt(gt),Bn=Dt(Ft),Dn=new Set;for(let on of new Set([...yn,...Nn,...Bn])){let Jn=yn.has(on),Qn=Nn.has(on),Yt=Bn.has(on);(Qn===Yt?Qn:Qn===Jn?Yt:Qn)&&Dn.add(on)}return cn=Ge(Dn,[gt,Ft,dt]),gn.set(Ft,cn),cn}if(Y.src==="both"){let dt=c.stackAt[W],gt=g.stackAt[K];return Ge(new Set([...Dt(dt),...Dt(gt)]),[dt,gt])}let ye=(Y.src==="local"?c:g).stackAt[Y.src==="local"?W:K];if(!Y.inherit)return Ge(Dt(ye),[ye]);let ve=wt.get(Y);ve||wt.set(Y,ve=new Map);let We=ve.get(ye);if(We)return We;let Re=new Set(Dt(ye));for(let dt of Y.inherit.added)Re.add(Bt(dt));for(let dt of Y.inherit.removed)Re.delete(Bt(dt));let Fe=Y.src==="local"?g:c,xt=(Y.src==="local"?xe.bTo:oe.bTo)[Y.inherit.bs];return We=Ge(Re,[ye,Fe.stackAt[xt]]),ve.set(ye,We),We},dn=new Int32Array(c.text.length+1);dn[c.text.length]=Xe;for(let f=c.text.length-1;f>=0;f--)dn[f]=st[f]>=0?st[f]:dn[f+1];Pi.caret+=c.text.length;let vt=f=>f<=0?0:(f>c.text.length&&(f=c.text.length),st[f-1]>=0?st[f-1]+1:dn[f]),ut=[],Qe=[],Ot=null,ht=[],Wt="",wn=-1,ln=f=>{Ot?Ot.appendChild(f):ut.push(f)},pn=f=>{if(!Wt)return;let L=o.createTextNode(Wt);ln(L),Qe.push({node:L,ms:wn,me:f,local:[],u:ht.length?ht[ht.length-1].u:null}),Wt=""},Qt=new Set,Ln=new Map,oo=new Set,Rn=f=>{let L=o.createElement(f.tag);if(f.block&&Tn.add(L),!Ln.has(f)){Ln.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&&(oo.has(he.local)?he.local=null:oo.add(he.local))}else{let K=Ln.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})}ln(L),ht.push({u:f,el:L}),Ot=L},xo=new Set,Kn=new Map;for(let f of c.pins){let L=vt(f.i);Kn.has(L)||Kn.set(L,[]),Kn.get(L).push(f)}let Ro=f=>{let L=Kn.get(f);if(L){pn(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}),xo.add(K),ln(K)}}},es=m.atoms.length||c.atoms.length||g.atoms.length,Po=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},Fn=(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)},vo=(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)&&!Fn(he,f,Y):W.bTo[he.i]>=0)?null:he},so=(f,L)=>{if(!f||!p||!e.moveIn)return null;let W=L.reverse.get(f.el);return W&&!P.has(W)?W:null},To=(f,L)=>{let W=new Map;for(let K of f.atoms)W.set(L(K),(W.get(L(K))||0)+1);return W},ae=To(m,B),ze=To(c,w),qe=To(g,y),rt=f=>{let L=B(f);return ae.get(L)===1&&(ze.get(L)||0)<=1&&(qe.get(L)||0)<=1},Tt=new Map,Ye=new Set,Je=new Set,At=new Set,et=null;for(let f=0;f<Xe;f++){let L=Po(f);if(!L)continue;let{ab:W,al:K,ar:Y}=L,he=vo(Y,s,xe,W,"remote"),ye=vo(K,n,oe,W,"local"),ve=W,We=null;if(he?(ve=he,We="remote"):ye&&(ve=ye,We="local"),ve){W&&ve!==W&&(et||=new Map).set(W,We),Ye.has(ve)?Tt.set(f,{dup:ve.el}):(Ye.add(ve),Tt.set(f,{bk:ve,from:We,al:K,ar:Y}));continue}let Re=so(Y,s),Fe=so(K,n),xt=Re||Fe;if(xt){Je.has(xt)?Tt.set(f,{dup:xt}):(Je.add(xt),Tt.set(f,{moveIn:xt,side:Re?"remote":"local",sideEl:Re?Y.el:K.el}));continue}let dt=(Ft,Ht)=>Ft&&p&&P.get(Ht.reverse.get(Ft.el))||null,gt=dt(Y,s)||dt(K,n);if(gt&&(At.add(gt),Se[f].conflict&&(rt(gt)||Y&&(Y.el===gt.el||s.identityPaired?.has(gt.el))&&Fn(gt,Y,"remote")||K&&(K.el===gt.el||n.identityPaired?.has(gt.el))&&Fn(gt,K,"local")))){if(Ye.has(gt)){Tt.set(f,{dup:gt.el});continue}Ye.add(gt)}Tt.set(f,{al:K,ar:Y})}let at=new Map,pt,zt,Ct=(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(Ye.has(f)||At.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&&(rt(f)||et?.has(f)||(K.el===f.el||n.identityPaired?.has(f.el))&&(Y.el===f.el||s.identityPaired?.has(f.el))&&Fn(f,K,"local")&&Fn(f,Y,"remote"))))continue;let ye=et?.get(f),ve=t;if(ye){let dt=ye==="local"?g:c,gt=ye==="local"?s:n,Ft=ye==="local"?zt:pt;if(Ft===void 0){Ft=dt.atoms.length===m.atoms.length;for(let Ht=0;Ft&&Ht<m.atoms.length;Ht++)Ft=gt.reverse.get(dt.atoms[Ht].el)===m.atoms[Ht].el;ye==="local"?zt=Ft:pt=Ft}Ft&&(ve=ye)}let We=ve==="local"?[[K,st],[Y,Kt]]:[[Y,Kt],[K,st]],[Re,Fe]=We.find(([dt])=>dt),xt=Ct(Fe,Re.i);at.has(xt)||at.set(xt,[]),at.get(xt).push({a:f,lt:L,rt:W,edited:he}),Ye.add(f)}if(p&&e.moveIn){let f=[[c,n,st,"local"],[g,s,Kt,"remote"]];t!=="local"&&f.reverse();for(let[L,W,K,Y]of f)for(let he of L.atoms){let ye=so(he,W);if(!ye||Je.has(ye))continue;Je.add(ye);let ve=Ct(K,he.i);at.has(ve)||at.set(ve,[]),at.get(ve).push({move:ye,side:Y,sideEl:he.el})}}let tn=f=>{let L=at.get(f);if(L){if(pn(f),L.some(W=>Ke(W.move?W.sideEl:W.a.el)))for(;ht.length;)ht.pop(),Ot=ht.length?ht[ht.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&&ln(Fe);continue}Qt.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"})),ln(Re)}}},Tn=new Set,qn=r.length>u;for(let f=0;f<Xe;f++){let L=Po(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<ht.length&&he<Y.length&&ht[he].u===Y[he];)he++;if(he<ht.length)for(pn(f);ht.length>he;)ht.pop(),Ot=ht.length?ht[ht.length-1].el:null;if(Ro(f),tn(f),Y.length>ht.length)for(pn(f);ht.length<Y.length;)Rn(Y[ht.length]);if(ue[f]===Nt){if(ee.has(f))continue;pn(f);let ye=ht.length;for(;ye>0&&!ht[ye-1].u.block;)ye--;if(ye>0)for(qn&&a.breakOut.set(f,ht[ye-1].el);ht.length>=ye;)ht.pop(),Ot=ht.length?ht[ht.length-1].el:null;continue}if(L){pn(f);let ye=Tt.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(Qt.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"}));qn&&a.atomOut.set(f,ve),ln(ve);continue}Wt||(wn=f),Wt+=ue[f]}if(pn(Xe),(Kn.has(Xe)||at.has(Xe))&&(ht.length=0,Ot=null,Ro(Xe),tn(Xe)),Xe===0&&(c.placeholder||g.placeholder||m.placeholder)){let f=o.createElement("br");d.set(f,{base:m.placeholder,local:c.placeholder,remote:g.placeholder}),ut.push(f)}let Pn=0,mt=f=>{for(;Pn>0&&Qe[Pn-1].me>=f;)Pn--;for(;Pn<Qe.length&&Qe[Pn].me<f;)Pn++;let L=Qe[Pn];if(!L)return Qe[Qe.length-1]||null;let W=Qe[Pn+1];return L.me===f&&W&&W.ms===f?W:L},ot=new Map,jt={},lt=(f,L,W)=>{let K=mt(f)||(W?jt:null);if(!K)return;let Y=ot.get(K)||{l:!1,r:!1};L!=="remote"&&(Y.l=!0),L!=="local"&&(Y.r=!0),ot.set(K,Y)},Et=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]!==Un&&L[W]!==Nt)return!0;return!1};for(let f of Q)f.src!=="base"&&lt(f.ms,f.conflict?"both":f.src,Et(f));for(let[f,L]of G)nt[f]>=0&&lt(nt[f],L);for(let f of Qe.length?Qe:[jt]){let L=ot.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(Ln.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)Ln.has(f)&&b({kind:"structure",el:Ln.get(f),detail:"edit-beats-delete",base:f.base},{subject:f.base,deleted:L});let Zt=(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(!Zt(K.from,K.to,Y.bTo)||!Zt(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:Ln.get(f)||null,source:L})}let Ut=f=>{let L=bt.get(f.node.parentNode);return L?Bt(L):null};for(let f of c.nodes){let L=-1;for(let K=f.s;K<f.e;K++)if(st[K]>=0){L=st[K];break}let W;if(L>=0)W=mt(L);else{let K=vt(f.s),Y=Ut(f);W=Qe.find(he=>he.u===Y&&he.me>=K)||Qe.filter(he=>he.u===Y).pop()}W&&W.local.push(f)}let Gt=new Map,sn=Qe[Qe.length-1]||null,Mt=0;for(let f of c.nodes){let L=null;for(let W=f.s;W<=f.e;W++){let K=vt(W);for(;Mt>0&&Qe[Mt-1].me>=K;)Mt--;for(;Mt<Qe.length&&Qe[Mt].me<K;)Mt++;let Y=ye=>ye&&K>=ye.ms&&K<=ye.me&&(K<ye.me||W===f.e||ye===L),he=Y(Qe[Mt])?Qe[Mt]:Y(Qe[Mt+1])?Qe[Mt+1]:Qe[Mt]||sn;if(!he)break;if(L===he){let ye=Gt.get(he);ye[ye.length-1].to=W-f.s;continue}L=he,Gt.has(he)||Gt.set(he,[]),Gt.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++)(st[ve]<f.ms||st[ve]>=f.me)&&(W=!0);d.set(f.node,{base:null,local:L.map(ye=>ye.node),remote:null,caret:Gt.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:st,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:st.subarray?st.subarray(Y,he+1):st.slice(Y,he+1),mapLocal:ve=>vt(Y+Math.max(0,Math.min(ve,he-Y)))})}L=K+1}return f}let It={...e,blocks:Tn,ignored:f=>xo.has(f)||(e.ignored?e.ignored(f):!1)},nn=e.ignoreAttribute||(()=>!1),_n=Gs(rn(ut,It),nn)!==Gs(g,nn);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=rn(ut,{...It,via:f})}let Sn=null;if(e.scopeUnits){Sn=new Map;let f=new Set(ut),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=Sn.get(ve);Re||Sn.set(ve,Re=new Set),Re.add(We)};for(let ve of ut){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(ut.map((ve,We)=>[ve,We]));for(let[ve,We]of Sn)Sn.set(ve,Array.from(We).sort((Re,Fe)=>ye.get(Re)-ye.get(Fe)))}return{unitOutputs:Sn,nodes:ut,text:ue,textNodes:Qe,localDiverged:_n,mapLocal:vt,conflicts:r.slice(u),granularity:V?"line":"word",segments:kt(),localHunks:Ce,remoteHunks:be,lToM:st}}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(An)},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=>Hi(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 An=e=>({from:e,to:[],kind:"unknown",complete:!1});function Hi(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 An(e);let l=s.before.get(e);if(!l||l.opaque)return An(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 An(e);for(let h of u)if(b(h)&&!e.contains(h))return An(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(r.kind==="removed")return b(e)||u.some(b)?An(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 An(e);for(let h of u)if(b(h)&&!a.contains(h))return An(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 An(e)}return r.carried&&!ur(a,r.output,n)?An(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 Ao(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=>An(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 Wi(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 Gn(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&&!Wi(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:rn(e,{blocks:T}),local:rn(o,{blocks:T}),remote:rn(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]=jn({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 Ki="http://www.w3.org/1999/xhtml";function Fi(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===Ki}function qi(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+"|"+Fi(e.textContent.trim())}var _i={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function ho(e,o=[],t=!1){if(!mn(e)||e.hasAttribute("src"))return null;let n=[_i,...o];for(let s=0;s<n.length;s++){let d=n[s];if(!d.match(e))continue;if(!qi(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 Mo(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 zi(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|"+zi(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 Gi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Yi=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function zo(e){try{return JSON.parse(e)}catch{return JSON.parse(Xi(e))}}function Xi(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"||Gi.test(i)){o+=i,t=d;continue}if(Yi.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 en=Symbol("hyper-morph-json-merge:missing"),kr=["id","_id","uuid","key","slug","code","name"];function po(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Oo(e,o){return Object.prototype.hasOwnProperty.call(e,o)}function Ji(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Yn(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(!Yn(e[t],o[t]))return!1;return!0}if(po(e)&&po(o)){let t=Object.keys(e);if(t.length!==Object.keys(o).length)return!1;for(let n of t)if(!Oo(o,n)||!Yn(e[n],o[n]))return!1;return!0}return!1}function xr(e,o,t,n){return Yn(o,t)?o:Yn(o,e)?t:Yn(t,e)?o:po(o)&&po(t)?Qi(po(e)?e:{},o,t,n):Array.isArray(o)&&Array.isArray(t)?nl(Array.isArray(e)?e:[],o,t,n):t}function vr(e,o,t,n){return o===en&&t===en?en:o===en?e===en?t:Yn(t,e)?en:t:t===en?e===en?o:en:xr(e,o,t,n)}function Qi(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(Oo(e,i)?e[i]:en,Oo(o,i)?o[i]:en,Oo(t,i)?t[i]:en,n);r!==en&&Ji(s,i,r)}return s}function Zi(e){return e===null||typeof e!="object"}function $o(e){return typeof e+":"+String(e)}function el(e,o){for(let t of o){let n=new Set;for(let s of t){if(!Oo(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 tl(e,o,t,n){let s=[e,o,t],d=!0;for(let i of s)for(let r of i)po(r)||(d=!1);if(d){for(let i of n.keyCandidates)if(el(i,s))return{kind:"keyed",field:i};return null}for(let i of s){let r=new Set;for(let l of i){if(!Zi(l))return null;let u=$o(l);if(r.has(u))return null;r.add(u)}}return{kind:"self"}}function nl(e,o,t,n){let s=tl(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):en,l.has(p)?l.get(p):en,u.has(p)?u.get(p):en,n);v!==en&&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?en: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 en;try{return s(a)}catch(p){return d.push(`${h} side is not valid JSON (${p.message})`),en}},r=i(o,"local"),l=i(t,"remote");if(r===en)return{text:t,warnings:d};if(l===en)return{text:o,warnings:d};let u=i(e,"base"),b=As(u===en?void 0:u,r,l,n);return Yn(b,l)?{text:t,warnings:d}:Yn(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 eo(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 Xn(e,o,t={}){if(!eo(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=rn(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 Zn(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=Zn(e,o.start),n=Zn(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=>Zn(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 eo(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)&&Xn(s.scope,e.text.encoding)===r.text&&Xn(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 ol=1,hn=e=>!!e&&e.nodeType===1,Yo=e=>hn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function to(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 En=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:to(e.roots.base),local:to(e.roots.local),remote:to(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=En(ne).childNodes[a.base.indexIn(z[je].parentNode,z[je])];return ne?hn(R)?En(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=to(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()}},le=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"),tt=(M,R)=>{switch(R.kind){case"text":return _(M.pathOf(R.node),R.offset);case"end":return _(M.containerPath(R.node),En(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))}}},bt=(M,R,z,J,ne)=>{let je=Te(M,R,z);return je?tt(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()},ct=(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},Lt=(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},Bt=M=>{if(!M)return null;if(M.kind==="wholeStart"||M.kind==="wholeEnd"){let R=St(M.node);return M.kind==="wholeStart"?R.start:R.end}return tt(a.out,M)},St=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)}},Pt=M=>{let R=$(M,"base"),z=R?C(j(R))[0]:null;if(!z)return null;let J=En(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}},Dt=(M,R,z,J,ne,je)=>({text:M,start:R,end:z,fragment:J,span:ne,scope:je}),qt=(M,R,z,J,ne)=>Dt(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),Rt=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}:Pt(pe);Ce=un(qt(ue,G.ms,G.me,{start:Bt(Ie(G.ms)),end:Bt(Ie(G.me))},{start:Bt(Ie(0)),end:Bt(Ie(ue.length))}),Ie(G.ms),Ie(G.me),Ie(0),Ie(ue.length)),be=fe||(Pt(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=St(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 st=Z(pe,Se);return qt("",0,0,{start:st,end:st},{start:st,end:st})}let Xe=He.nodes[0],nt={start:_(a[Se].pathOf(Xe),0),end:_(a[Se].pathOf(Xe),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}:Pt(pe),Pe={start:Bt(Ie(0)),end:Bt(Ie(ue.length))};Ce=un(qt(ue,0,ue.length,Pe,Pe),Ie(0),Ie(ue.length),Ie(0),Ie(ue.length)),be=fe||(Pt(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],Ge=ee==="base"?_e:p(h(ee),_e);if(Ge&&$(Ge,ee)===Ee)return Ge}return null},Ie=ee=>()=>re(fe[ee],ue(ee),ee),Pe=(ee,Ee,Ue,_e,Ge)=>{let yt=wn=>wn?tt(a[Ge],wn):Ie(Ge)(),wt=Ee===Ue?it(ee,Ee):Te(ee,Ee,"start"),$t=Ee===Ue?it(ee,Ee):Te(ee,Ue,"end"),_t=yt(wt),dn={start:_t,end:Ee===Ue?_t:yt($t)},vt=R.full?R.full(Ge):null;if(!vt)return Dt(ee.text,Ee,Ue,_e,dn,{start:yt(Te(ee,0,"start")),end:yt(Te(ee,ee.text.length,"end"))});let ut=wt?ct(vt,wt):null,Qe=$t?ct(vt,$t):null,Ot=ut===null?0:ut,ht=Math.max(Ot,Qe===null?vt.text.length:Qe),Wt=yt(Te(vt,0,"start"));return Dt(vt.text,Ot,ht,co(vt,Ot,ht),dn,{start:Wt,end:vt.text.length?yt(Te(vt,vt.text.length,"end")):Wt})};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],Xe=G.out,nt=()=>{let ee=En(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(Xe.via)for(let[ee,Ee]of Xe.via)P.set(ee,Ee);let st=Ze(G,He,He===Se?"empty":"start",nt),Kt=He===Se?st:Ze(G,Se,"end",nt),Vt=Xe.text.length?Lt(Xe,0,"start",G.node):nt(),I=Xe.text.length?Lt(Xe,Xe.text.length,"end",G.node):Vt,q=ct(Xe,st),te=ct(Xe,Kt),me=q===null?0:q,we=Math.max(me,te===null?Xe.text.length:te);Ce=un(Dt(Xe.text,me,we,co(Xe,me,we),{start:Bt(st),end:Bt(Kt)},{start:Bt(Vt),end:Bt(I)}),st,Kt,Vt,I);let ie=T.spans.get(Ce);if(ie.flat=Xe,!Xe.text.length){let ee=Bt(Vt),Ee=Zn(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=st?st.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"&&Rt.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:le(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"&&Rt.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:ol,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=to(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(En(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:En(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[En(y),En(y).childNodes.length];if(w.kind==="startOf")return[En(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||!eo(w)||!eo(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 Xn(y,$.encoding,Ne)===V.text&&Xn(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(En)),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 le=!V&&$e&&xe;y.applied=V,y.unavailable=V?null:le?"hook-veto":"missing-output",le&&(y.localLost=!1),!V&&y.text&&(y.text.liveSpan=y.text.liveScope=null)}}function Xo(e,o,t){let n=to(o),s=to(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=Zn(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&&eo(g)&&d(g.startContainer)&&d(g.endContainer);(!c(v)||!c(O)||Xn(O,h.text.encoding)!==m.text||Xn(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 mo=e=>e?.nodeType===1,Io=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function sl({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(!mo(p)||!mo(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(!mo(p)||!mo(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 Io(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(mo(y.local))for(let V of Io(y.local).children)d(V)&&T(V,{...U,kind:"ignored"})}for(let V of Io(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"&&mo(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=Io(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 go(e,o,t,n,s,d,i,r,l,u,b,a,h){let p=null;return sl({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=Io(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 rl({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=rn(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),tt=O(Ke),bt=O(Te);if(!it||!tt||!bt||!/\S/.test(it.flat.text))continue;let Ze=it.flat.text,ct=N.flat.text,Lt=tt.flat.text;if(h((Ze.length+ct.length+Lt.length)*3+1),Lt.length!==Ze.length+ct.length)continue;let Bt=_===-1;(Bt?!Lt.startsWith(Ze)||!Lt.endsWith(ct):!Lt.startsWith(ct)||!Lt.endsWith(Ze))||D.push({owner:re,target:Ke,moved:Te,ownerBase:it,joined:tt,ownerOther:bt,targetFrom:Bt?Ze.length:0,retainedFrom:Bt?0:ct.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=jn({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 le=[U,null,null];le[c+1]=V,le[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:le,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?rl({...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 il(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=rn(r.base),u=e.ownerModels[1].flat,b=rn(r.remote),a=s?n.flat.text.length:0,h=s?0:t.flat.text.length,p=jn({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=jn({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 $=il(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 le=$.get(xe);le||$.set(xe,le=[]),le.push($e)},Ne=(xe,$e=null,le=!1)=>{B.add(xe),w.set(xe,$e);let k=h.get(xe),_=le||!!(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 le of $.get(xe)||[]){let k=le;for(;k&&w.get(k)!==$e;)k=w.get(k);if(k)return k}return null},oe=(xe,$e,le)=>{let k=U($e);for(let _=le.nextSibling;_;_=_.nextSibling){let re=De(_,$e);if(re){k.insertBefore(xe,re);return}}for(let _=le.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,le=Ae($e.owner)||Ae($e.owners[1])||Ae($e.owners[2]);if(le)(!xe.result||xe.output!==le||xe.result.nodes.some(k=>!B.has(k)||w.get(k)!==le)||le.textContent!==xe.result.text)&&(C($e.owner,le),Ne(le,w.get(le),y.get(le)));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");le=xe.output||u($e.owner,$e.owners[1],$e.owners[2],!1),xe.result||C($e.owner,le),oe(le,re,_),Ne(le,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 Mn=/\S/,Lr=/[\p{L}\p{N}]/u;function no(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 ll({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=Mn.test(g.slice(0,l)),T=Mn.test(g.slice(l+u));if(P===T)return!1;let x=P?0:l+u,A=P?l:g.length;for(;x<A&&!Mn.test(g[x]);)x++;for(;A>x&&!Mn.test(g[A-1]);)A--;let E=g.slice(x,A);if(In(E,g,h(r,p),p,v,!0)!==x)return!1;let S=In(E,O,h(s,p),p,v,!0);if(S<0)return!1;let N=S+E.length,C=!Mn.test(O.slice(0,S)),j=!Mn.test(O.slice(N));if(C===j||In(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||!Mn.test(D)||In(D,c,h(i,p),p,v,!0)!==B||!Mn.test(C?c.slice(0,B):c.slice(D.length)))return!1;for(let w of e){if(v(p,1),w===n||!no(w,b,p,v))continue;let y=a(w,null,p);if(In(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||!no(w,b,p,v))continue;let y=a(w,t,p);if(In(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)||!no(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||!no(S,s,h,u)||!no(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),!Mn.test(B)||!Mn.test(w)||!Mn.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)||!no(oe,s,h,u)||!no(De,s,h,u))continue;let xe=r(oe,null,h),$e=r(De,v,h),le=xe.flat.text,k=$e.flat.text;if(u(h,le.length),!Mn.test(le)||k.length<=le.length)continue;let _=l($e,h),re=In(le,k,_,h,u,!0);if(!(re<0||In(B,k,_,h,u,!0,re,re+le.length)<0&&!ll({base:e,V:p,A:v,source:E,original:C,current:j,edited:D,destination:$e,at:re,ownLength:le.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 Hn=/\S/,bn=/\s/,al=/[\s\u001e]/g,Os=/[^\s\p{P}\u001e\ufffc]/u;function cl(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]&&Hn.test(u.text[a]))return!0}return!1}function fl(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]&&Hn.test(r[u]))return!1;return!0}function ul(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 dl(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=rn(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||!Hn.test(N.text.replaceAll(Un,"")))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:[]}:rn(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:Un,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=Wn(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(al,"");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"&&Hn.test(k.value))&&V(k)),De=Ne(w.units,k=>(k.nodeType===1||k.kind==="text"&&Hn.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],tt=Ae.next[k],bt=it<0?0:U.get(V(t[it])),Ze=tt===t.length?w.units.length-1:U.get(V(t[tt]));xe(Math.max(0,it),Math.min(t.length-1,tt),bt,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()),le=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(le.has(k))continue;let[_,re,Z,Be,Ke]=k,Te=Xt(u),it=[],tt=new Set,bt=!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)),ct=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))),Lt=new Set(ct),Bt=!1,St="",Pt="",Dt=0;for(let Q of Ze){let Oe=x(Q,null,Te);St+=Oe.flat.text,Dt+=Oe.flat.text.length}for(let Q of ct){let Oe=x(Q,y,Te);Pt+=Oe.flat.text,Dt+=Oe.flat.text.length}T(Te,Dt);let qt=C(St),un=C(Pt),Rt=qt===un;if(bt=Rt,Ke&&!Rt)continue;let Jt=Rt?null:new Map;if(Jt)for(let Q of Ze.concat(ct)){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 Rt?[]:Ze){let Oe=V(Q);if(!Lt.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){Bt=!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(Bt)continue;let ge=null,Le=null;if(!Rt)for(let Q of Ze){let Oe=V(Q),Ve=h.get(Q);if(!Oe||Ve.flat.atoms.length||!Lt.has(Oe))continue;let Ce=Ve.flat.text,be=Jt.get(Q);T(Te,Ce.length*3+ct.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 ct){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||!Lt.has(V(He)))continue;let Se=h.get(He);if(Se.flat.atoms.length)continue;let Xe=Jt.get(He);T(Te,Se.flat.text.length*3);let nt="",st=!1;for(let Kt=0;Kt<Se.flat.text.length;Kt++)bn.test(Se.flat.text[Kt])||(Xe[Kt]?st=!0:nt+=Se.flat.text[Kt]);st&&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);Hn.test(pe)&&Oe.push({...H,raw:pe,len:X-de,k:H.atom?H.k:pe,from:de,to:X})}}}}return Oe},M=Rt?F(Ze):Me(Ze),R=Rt?F(ct):Me(ct),z=Rt?qt:M.map(Q=>C(Q.raw)).join(""),J=Rt?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){Bt=!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(Bt)continue;let je=new Map;for(let Q of ne)if(!Le?.has(Q.source)){if(V(Q.source)===Q.target){Rt&&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,Xe)=>{let nt=A(Se,Te),st=A(Xe,Te);return T(Te,Se.flat.text.length+Xe.flat.text.length+nt.length+st.length),Se.flat.text===Xe.flat.text&&nt.length===st.length&&nt.every((Kt,Vt)=>Kt.k===st[Vt].k)},fe=Ce&&se&&se.flat.text!==be&&ke(x(Ce,y,Te),se);for(let Se of new Set(Oe.map(Xe=>Xe.target))){if(Q.nodeType!==1&&Se.nodeType!==1)continue;let Xe=x(Se,y,Te),nt=w.baseOf(Se);if(Q.nodeType!==1&&nt||(T(Te,be.length*2+Xe.flat.text.length*3+ce.length*2),Ce&&C(be)===C(Xe.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 st=Xe.flat.text,Kt=be&&(st.startsWith(be)||st.endsWith(be)),Vt=!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+st.length),Vt=!!te&&!!me&&te.length+me.length<=st.length&&st.startsWith(te)&&st.endsWith(me)&&!st.slice(te.length,st.length-me.length).trim()}let I=!Ve.flat.atoms.length&&!se?.flat.atoms.length&&!Xe.flat.atoms.length&&(fe&&Kt||Vt);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=Xe.flat.text,ie=we.startsWith(me)||we.endsWith(me),ee=!n[1-B].V.twin(nt)&&!ce.some(Ee=>Ee.source===nt&&Hn.test(me.slice(Ee.from,Ee.to)));if(!Rt&&(!te&&!I||!ie&&!ee)){let Ee=ul(Q,Se,Oe,Ze,ct,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)&&st.trim()===Ee&&!h.get(nt).flat.atoms.length&&!ce.some(Ge=>Ge.source===nt&&Hn.test(me.slice(Ge.from,Ge.to)));if(!ie&&!ee&&!_e&&!dl(nt,Se,me,st,ce,A(Xe,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(!Rt&&Ce&&Ie.size>1&&cl(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 Xe=!0;for(let nt=Se.from;nt<Se.to;nt++)if(Hn.test(be[nt])&&!G[nt]){Xe=!1;break}Xe&&(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,Xe=0,nt=0,st=null,Kt=null;if(!Ce&&se&&Q.nodeType===1&&!Ve.flat.atoms.length){let Vt=A(Ve,Te).filter(I=>Os.test(I.raw));T(Te,ct.length+be.length);for(let I of ct){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 wt=Math.min(te,me)+1;wt<Math.max(te,me);wt++){let $t=t[wt];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||!Vt.length)continue;let _e=0,Ge=Ue.length;if(te<me&&Ue.endsWith(Ee))Ge-=Ee.length;else if(te>me&&Ue.startsWith(Ee))_e=Ee.length;else continue;for(;_e<Ge&&bn.test(Ue[_e]);)_e++;for(;Ge>_e&&bn.test(Ue[Ge-1]);)Ge--;let yt=Ue.slice(_e,Ge);if(!(!yt||!(yt.startsWith(Vt[0].raw)||yt.endsWith(Vt[Vt.length-1].raw)))){if(Se){Se=null;break}Se=I,Xe=_e,nt=Ge,st=Vt[0],Kt=Vt[Vt.length-1]}}}if(T(Te,H.length),!Se||!Ie.has(Se)||!H.some(Vt=>Vt.target===Se&&(Vt.from<=st.from&&Vt.to>=st.to&&Vt.targetFrom+st.from-Vt.from===Xe||Vt.from<=Kt.from&&Vt.to>=Kt.to&&Vt.targetFrom+Kt.to-Vt.from===nt)))continue}if(Ce&&!(ue.every(Se=>G[Se])&&(Rt||Array.from(Ie).some(Se=>X.has(Se))))&&!ce.some(Se=>Se.source===Q&&Hn.test(be.slice(Se.from,Se.to))))continue;let He=!1;if(Rt){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 Xe=H.filter(st=>st.target===Se);it.push({side:B,source:Q,target:Se,runs:Xe,models:h,retained:ce,conservedSource:He}),Q.nodeType===1&&tt.add(Q),Se.nodeType===1&&tt.add(Se);let nt=w.baseOf(Se);nt?.nodeType===1&&tt.add(nt)}}if(p.push(...it),Ke&&it.length)for(let Q of Ke)le.add(Q);for(let Q of tt)g.add(Q)}catch(Ze){if(Ze!==P)throw Ze}finally{if(o&&!Ke&&!bt){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&&!bt){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=fl(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:Un,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=Wn(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=jn({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 ft=e=>!!e&&e.nodeType===1,Cn=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(Cn.has(o.tagName))return!0;return!1}function hl(e,o,t){let n=null;for(let s of o.childNodes)if(!(!ft(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 Eo="[id],[data-id],script,head>*";function Cs(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=ho(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||zn(),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?Eo: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=ft(I)&&v(I);return q&&B?.get(q)===I&&!D.has(q)?q:null},$=I=>{let q=ft(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=ft(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))!ft(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,le=[],k=[],_=new Set,re=[],Z=new Set,Be=new Set,Ke=new Set,Te=new WeakMap,it=null,tt=n.lineage?.locals.length?rr():null,bt=I=>{let q=Fo(I);return q&&tt&&tt.consume(I.local),q},Ze=n.conflicts||"remote",ct=I=>le.push(I),Lt=I=>le.push(I),Bt=Or({roots:{base:g,local:P,remote:T},L:U,R:V,unitsOf:r,provenance:xe,policy:Ze}),St=(I,q)=>{k.push(I),q&&Bt.note(I,q)},Pt=null,Dt=null,qt=ge(),un=null,Rt=Q(g,U.map.get(g),V.map.get(g),!!n.localIsBase,!!n.childrenOnly);Rt.tagName==="HTML"?oe.replaceChild(Rt,oe.documentElement):oe.body.appendChild(Rt),Pt?.drain(Rt),Dt?.drain(Rt),x&&(x.build=(x.build||0)+(performance.now()-A));let Jt=n.childrenOnly?!He(Ie(Rt),Ie(T)):!fe(Rt,T),F=Bt.finish(Rt),ce=tt?ir({locals:n.lineage.locals,rec:tt,root:Rt,provenance:xe,segments:re,ignored:s}):null;return{doc:oe,root:Rt,provenance:xe,textMappers:$e,decisions:le,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=ut=>{let Qe=0;for(let Ot=ut.parentNode;Ot;Ot=Ot.parentNode)Qe++;return Qe},ee=[],Ee=ut=>{let Qe=ut.textContent.trim();return Qe.split(/\s+/).length>=3||Qe.replace(/\s/g,"").length>=12},Ue=ut=>{let Qe=R(U,ut),Ot=R(V,ut);return Qe&&U.reverse.get(Qe.parentNode)!==ut.parentNode||Ot&&V.reverse.get(Ot.parentNode)!==ut.parentNode},_e=(ut,Qe,Ot)=>{for(let Wt of Ot.parentNode.children){let wn=Wt!==Ot&&ut.reverse.get(Wt);if(wn&&Ue(wn))return!0}let ht=ut.reverse.get(Ot.parentNode);if(ht){for(let Wt of ht.children)if(!R(Qe,Wt)&&!s(Wt))return!0}return!1},Ge=new Map([[U,new Map],[V,new Map]]),yt=(ut,Qe)=>{let Ot=Ge.get(ut),ht=Ot.get(Qe);if(ht===void 0){ht=!1;for(let Wt of Qe.children)if(ut.reverse.has(Wt)||yt(ut,Wt)){ht=!0;break}Ot.set(Qe,ht)}return ht},wt=new Map;for(let ut of me.values())for(let Qe of ut){let Ot=$(Qe);Ot&&wt.set(Ot,Qe)}for(let ut of te.values())for(let Qe of ut){let Ot=y(Qe),ht=Ot?wt.get(Ot):null;ht&&ht.tagName===Qe.tagName&&!Vn(Qe,we)&&!Vn(ht,we)&&!n.remoteWins(Qe)&&!n.remoteWins(ht)&&ee.push([Qe,[ht],ie(Qe),!0,!0])}for(let[ut,Qe]of te){let Ot=me.get(ut);if(!Ot)continue;let ht=Qe.length===1&&Ot.length===1;for(let Wt of Qe)!Vn(Wt,we)&&!y(Wt)&&ee.push([Wt,Ot,ie(Wt),ht&&(Ee(Wt)||_e(U,V,Wt)||_e(V,U,Ot[0]))])}if(!ee.length)return{partner:I,drop:q};ee.sort((ut,Qe)=>ut[2]-Qe[2]);let $t=new Set,_t=new Set,dn=ut=>{for(let Qe of ut.querySelectorAll("*"))$t.add(Qe)},vt=(ut,Qe)=>ut.reverse.get(Qe.parentNode)||null;for(let[ut,Qe,,Ot,ht]of ee){if($t.has(ut)||_t.has(ut)||ht&&(yt(U,ut)||yt(V,Qe[0])))continue;let Wt=vt(U,ut),wn=Qt=>!_t.has(Qt)&&!$t.has(Qt)&&(ht||Qt.tagName===ut.tagName&&!$(Qt)&&i.equalUnits(ut,Qt)),ln=Qe.find(Qt=>Wt&&vt(V,Qt)===Wt&&wn(Qt))||(Ot?Qe.find(wn):null);if(!ln)continue;_t.add(ut),_t.add(ln);let pn=Wt&&vt(V,ln)===Wt;(!ht||!pn||i.equalUnits(ut,ln))&&(dn(ut),dn(ln)),!pn&&(I.set(ut,ln),I.set(ln,ut),q.add(Ze==="local"?ln:ut))}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),St({kind:"structure",el:ie,detail:"both-moved",base:null,local:me,remote:we},{unit:{b:null,l:me,r:we}}),ct({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);ft(te)&&ft(me)&&I.set(i.unitHash(me),te)}let q=!1;for(let te of Array.from(V.weak)){let me=R(V,te);if(!ft(te)||!ft(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(ft(I)&&Cn.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&&Kt(Ue,R(U,Ee),U)&&!Kt(_e,R(V,Ee),V)&&(Dt||=Cr({L:U,R:V,twinIn:R,unitsOf:r,view:J,parentOf:De,ignored:s,remoteWins:n.remoteWins,eligible:Ge=>ft(Ge)&&Cn.has(Ge.tagName),build:Q,out:oe,policy:Ze,provenance:xe,textMappers:$e,segments:re,conflicts:k,conflict:St,decisions:le}),Dt.ensureOwner(I))}if(q===null)return null;if(me!==void 0)return Pt||=go(xe,De,U,V,R,Q,s,n.remoteWins,k,St,ne,P,T),Pt.plan(I,q,te,!!me),me&&(Pt.produced(I,me),Be.add(I)),me;if(Be.has(I)||Ke.has(I))return St({kind:"structure",el:null,detail:"both-moved",base:I},{subject:I}),Be.has(I)?null:se(te,q);Pt||=go(xe,De,U,V,R,Q,s,n.remoteWins,k,St,ne,P,T),Pt.plan(I,q,te,!0);let we=R(U,I),ie=R(V,I);(!we||!ie)&&St({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"?ct:Lt)({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=>ft(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:ft(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],Ge=Ee[Ue];if(!ft(_e)||!ft(Ge))continue;let yt=te.map.get(_e);if(yt!==void 0&&yt!==Ge)return!1;let wt=te.reverse.get(Ge);if(wt!==void 0&&wt!==_e)return!1;me.push([_e,Ge])}}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))&&St({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 Pt?.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(!Dt?.render(I,ee)){let _e=ke(I,q,te,ie,ee),Ge=Ue==="TEMPLATE"&&ee.content?ee.content:ee;for(let yt of _e)Ge.appendChild(yt)}return Ke.delete(I),Pt?.produced(I,ee),ee}function Oe(I,q,te,me,we){if(q===te)return q;if(q===I)return te!==I&&Lt({kind:we,node:me,source:"remote"}),te;if(te===I)return ct({kind:we,node:me,source:"local"}),q;let ie=Ze==="local"?q:te;return St({kind:we,node:me,base:I,local:q,remote:te,resolved:ie},{site:"whole",el:me}),le.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?ho(I,n.mergeTags,!0):null;if(Ee&&ie!==ee){let Ue=te&&te.getAttribute("merge-key")||I.getAttribute("merge-key"),{text:_e,warnings:Ge}=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 Ge)console.warn(`[hyper-morph] merge "${Ee.raw}": ${yt}`);me.textContent=_e,_.add(me),_e!==ee?ct({kind:"text",node:me,source:_e===ie?"local":"both"}):_e!==we&&Lt({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,Ge;Ue===_e?Ge=Ue:Ue===Ee?(Ge=_e,Lt({kind:"attr",el:me,name:ie,source:"remote"})):_e===Ee?(Ge=Ue,ct({kind:"attr",el:me,name:ie,source:"local"})):(Ge=be(ie,Ee,Ue,_e),Ge===void 0&&(Ge=Ze==="local"?Ue:_e,St({kind:"attr",el:me,name:ie,base:Ee,local:Ue,remote:_e,resolved:Ge},{el:me,sample:ee})),le.push({kind:"attr",el:me,name:ie,source:"both"})),Ge!=null&&(ee.namespaceURI?me.setAttributeNS(ee.namespaceURI,ee.name,Ge):me.setAttribute(ie,Ge))}}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 Ge=ie.has(_e),yt=ee.has(_e),wt=Ee.has(_e);(yt===wt?yt:yt===Ge?wt:yt)&&Ue.add(_e)}return[...Ue].join(" ")}if(I==="style"){let we=Ge=>{let yt=new Map;if(!Ge)return yt;let wt=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 Ge){if($t){_t+=vt,vt===$t&&($t=null);continue}if(vt==='"'||vt==="'"){$t=vt,_t+=vt;continue}if(vt==="("?wt++:vt===")"&&wt--,vt===";"&&wt===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 Ge of new Set([...ie.keys(),...ee.keys(),...Ee.keys()])){let yt=ie.get(Ge)??null,wt=ee.get(Ge)??null,$t=Ee.get(Ge)??null,_t;wt===$t?_t=wt:wt===yt?_t=$t:$t===yt?_t=wt:(_t=Ze==="local"?wt:$t,_e=!0),_t!=null&&Ue.set(Ge,_t)}return _e?void 0:[...Ue].map(([Ge,yt])=>`${Ge}: ${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=lo(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?le.push({kind:"text",node:Ue,source:"both"}):ie!==we?ct({kind:"text",node:Ue,source:"local"}):ee!==we&&Lt({kind:"text",node:Ue,source:"remote"});for(let _e of Ee.conflicts)St({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 Gn(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,St({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?ct({kind:"insert",el:ie,source:me&&te===me?"both":"local"}):Lt({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=>ft(Ue)?Vn(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,St({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=bt({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:St,scope:{base:null,local:I,remote:q,units:[],at:0},synthetic:!0,decisions:le,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&&ft(I)){let ee=qt.partner.get(I);if(ee)return Le(I,q,ee)}if(!ft(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=ft(ee)?ie.reverse.get(ee):null;if(Ee&&z(Ee,null,null),Ee&&Be.has(Ee)){St({kind:"structure",el:null,detail:"both-moved",base:Ee},{subject:Ee});continue}if(Ee&&!Ke.has(Ee)){let _e=R(U,Ee)||null,Ge=R(V,Ee)||null;if(_e||Ge){Pt||=go(xe,De,U,V,R,Q,s,n.remoteWins,k,St,ne,P,T),Pt.plan(Ee,q,ee,!0);let yt=Q(Ee,_e,Ge,!1);q==="local"?ct({kind:"move",el:yt,source:"local"}):Lt({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&&ft(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 ae=0;ae<Ee.length;ae++)_e.set(Ee[ae],ae);let Ge=[],yt=new Set,wt=new Map,$t=new Set,_t=tt&&[],dn=tt&&[],vt=new Set,ut=[],Qe=null,Ot=new Map;if(!ie.asBase&&!ee.asBase&&!U.identical.has(I)&&!V.identical.has(I))for(let ae of Ee){if(!ft(ae)||!Cn.has(ae.tagName))continue;let ze=ie.twin(ae),qe=ee.twin(ae);ze&&qe&&(!ie.here(ze)||!ee.here(qe))&&z(ae,null,null)}To();let ht=ae=>{let ze=[];for(let qe of ae.units){if(vt.has(qe))continue;let rt=ae.baseOf(qe);rt&&Ue.has(rt)&&ze.push(rt)}return ze},Wt=ae=>ht(ae).map(ze=>_e.get(ze)),wn=ae=>ae.every((ze,qe)=>qe===0||ze>=ae[qe-1]),ln=!ie.asBase&&!wn(Wt(ie)),pn=!ee.asBase&&!wn(Wt(ee));ln&&pn&&St({kind:"structure",el:we,detail:"both-reordered",base:I},{subject:I,lKept:ht(ie),rKept:ht(ee)});let Qt=pn||!ln?{V:ee,A:V,side:"remote",other:ie,otherA:U,otherSide:"local"}:{V:ie,A:U,side:"local",other:ee,otherA:V,otherSide:"remote"};ln?ct({kind:"move",el:null,source:pn?"both":"local",base:I}):pn&&Lt({kind:"move",el:null,source:"remote",base:I});let Ln=ie.asBase?[]:ie.units.filter(ae=>!ie.baseOf(ae)&&!vt.has(ae)&&!qt.partner.has(ae)),oo=ee.asBase?[]:ee.units.filter(ae=>!ee.baseOf(ae)&&!vt.has(ae)&&!qt.partner.has(ae)),Rn=new Map;if(Ln.length&&oo.length){let ae=new Map,ze=new Map;for(let Ye of oo){if(ft(Ye)){let At=O(Ye);At&&ae.set(At,Ye)}let Je=i.unitHash(Ye);ze.has(Je)||ze.set(Je,[]),ze.get(Je).push(Ye)}let qe=(Ye,Je)=>{let At=Ye.units.indexOf(Je);for(let et=At-1;et>=0;et--){let at=Ye.baseOf(Ye.units[et]);if(at)return at}return"start"},rt=new Map,Tt=new Map;for(let Ye of oo){let Je=qe(ee,Ye);ft(Ye)?(Tt.has(Je)||Tt.set(Je,[]),Tt.get(Je).push(Ye)):Ye.kind==="text"&&!rt.has(Je)&&rt.set(Je,Ye)}for(let Ye of Ln){let Je=null;if(ft(Ye)){let et=v(Ye);et&&ae.has(et)&&!Rn.has(ae.get(et))&&(Je=ae.get(et))}else if(Ye.kind==="text"){let et=rt.get(qe(ie,Ye));et&&!Rn.has(et)&&(Je=et)}let At=!!y(Ye);if(!Je&&!At){let et=ze.get(i.unitHash(Ye));et&&(Je=et.find(at=>!Rn.has(at)&&ft(at)===ft(Ye)&&(ft(at)?at.tagName===Ye.tagName&&!$(at):at.kind===Ye.kind)&&i.equalUnits(Ye,at))||null)}if(!Je&&ft(Ye)&&!At){let et=m.local(Ye),at=(Tt.get(qe(ie,Ye))||[]).filter(pt=>{let zt=m.remote(pt);return!Rn.has(pt)&&pt.tagName===Ye.tagName&&!$(pt)&&!(et&&zt&&et!==zt)&&i.similar(Ye,pt)});at.length===1&&(Je=at[0])}Je&&(Rn.set(Je,Ye),Rn.set(Ye,Je))}}let xo=ae=>{if(Dt?.consumes(ae))return null;if(Z.has(ae)||Pt?.has(ae))return wt.get(ae)||null;let ze=ie.twin(ae),qe=ee.twin(ae),rt=ze&&!ie.asBase&&!ie.here(ze),Tt=qe&&!ee.asBase&&!ee.here(qe);if(rt||Tt){if((!ze||!qe)&&St({kind:"structure",el:null,detail:"move-beats-delete",base:ae},{subject:ae,deleted:ze?"remote":"local"}),!st(ae))return ft(ae)?(Pt||=go(xe,De,U,V,R,Q,s,n.remoteWins,k,St,ne,P,T),rt&&Pt.plan(ae,"local",ze),Tt&&Pt.plan(ae,"remote",qe)):Z.add(ae),null;St({kind:"structure",el:null,detail:"both-moved",base:ae},{subject:ae})}if(ze&&!qe&&!ie.asBase&&!ee.asBase&&ft(ae)&&Cn.has(ae.tagName)&&!n.remoteWins(ae)&&!n.remoteWins(ze)&&ne(ae,ze,U)&&hl(ae,Ie(ee.el),s)){let at={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},pt=zt=>ft(zt)?Vn(zt,at):zt.kind==="text";if(r(ae).every(pt)&&r(ze).every(pt)){let zt=bt({base:[ae],local:[ze],remote:[],blocks:new Set([ae,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:(tn,Tn,qn)=>Q(tn,Tn,qn,!1),cloneUnit:se,mergeAttrs:Ce,atomKey:i.exactUnitKey,moveIn:z,moveBuilt:z,movePlanned:z,provenance:xe,textMappers:$e,conflicts:k,conflict:St,scope:{base:I,local:ie.el,remote:ee.el,units:Ee,at:_e.get(ae)},decisions:le,node:we});re.push(...zt.segments),Z.add(ae),Z.add(ze);let Ct=oe.createDocumentFragment();for(let tn of zt.nodes)Ct.appendChild(tn);return wt.set(ae,Ct),wt.set(ze,Ct),Ct}}if(!ze&&!qe)return Z.add(ae),Lt({kind:"remove",source:"both",base:ae}),null;if(!ze&&!ne(ae,qe,V))return Z.add(ae),ct({kind:"remove",source:"local",base:ae}),null;if(!qe&&!ne(ae,ze,U))return Z.add(ae),Lt({kind:"remove",source:"remote",base:ae}),tt&&(tt.remove(ze),_t.push({bk:ae,lk:ze})),null;let Ye=!ze||!qe,Je=ie.asBase?R(U,ae)||null:ze,At=ee.asBase&&ft(ae)&&(V.identityPaired.has(ae)||!m.base(ae))&&R(V,ae)||qe,et;return ft(ae)?et=Q(ae,Je,At,ie.asBase):ae.kind==="comment"?et=Xe(ae,Je,qe,ie.asBase):et=H(ae,Je,qe,ie.asBase),Z.add(ae),et&&(wt.set(ae,et),ze&&wt.set(ze,et),qe&&wt.set(qe,et),Ye&&(St({kind:"structure",el:et,detail:"edit-beats-delete",base:ae},{subject:ae,deleted:ze?"remote":"local"}),ze?ct({kind:"insert",el:et,source:"local"}):Lt({kind:"insert",el:et,source:"remote"}))),et},Kn=(ae,ze,qe,rt)=>{if(Dt?.consumes(ae))return null;if(Z.has(ae))return wt.get(ae)||null;let Tt=ze.baseOf(ae);if(Tt&&Ue.has(Tt))return vt.has(Tt)&&!vt.has(ae)?Ro(Tt,ae,rt):xo(Tt);if(Tt)return es(Tt,ae,rt);let Ye=Rn.get(ae);if(Ye){let At=rt==="local"?ae:Ye,et=rt==="local"?Ye:ae,at;return ft(At)?i.equalUnits(At,et)?(at=se(At,"local"),at&&(xe.get(at).remote=et)):at=pe(At,et):at=de(At,et),Z.add(At),Z.add(et),at&&(wt.set(At,at),wt.set(et,at),ft(At)&&ct({kind:"insert",el:at,source:"both"})),at}let Je=se(ae,rt);return Je&&(wt.set(ae,Je),rt==="local"?ct({kind:"insert",el:Je,source:"local"}):(Lt({kind:"insert",el:Je,source:"remote"}),tt&&ft(ae)&&!qt.partner.has(ae)&&dn.push({su:ae,node:Je}))),Je},Ro=(ae,ze,qe)=>{let rt;return ft(ae)?(rt=z(ae,qe,ze),rt&&Z.add(ze)):(rt=se(ze,qe),Z.add(ze),rt&&(qe==="local"?ct:Lt)({kind:"insert",el:rt,source:qe})),rt&&wt.set(ze,rt),rt},es=(ae,ze,qe)=>{z(ae,null,null);let Tt=R(qe==="local"?V:U,ae),Ye=ze,Je=Tt?Kt(Tt,qe==="local"?te:q,qe==="local"?V:U):!1,At=Tt&&!Je&&!Vt(ae,Tt);if(At&&qe===Qt.otherSide)return St({kind:"structure",el:null,detail:"both-moved",base:ae},{subject:ae}),null;if(At&&St({kind:"structure",el:null,detail:"both-moved",base:ae},{subject:ae}),Tt||St({kind:"structure",el:null,detail:"move-beats-delete",base:ae},{subject:ae,deleted:qe==="local"?"remote":"local"}),Ke.has(ae)){St({kind:"structure",el:null,detail:"both-moved",base:ae},{subject:ae});let at=se(Ye,qe);return at&&wt.set(ze,at),at}ft(ae)&&(Pt||=go(xe,De,U,V,R,Q,s,n.remoteWins,k,St,ne,P,T),Pt.plan(ae,qe,Ye,!0));let et=ft(ae)?Q(ae,qe==="local"?Ye:R(U,ae)||null,qe==="remote"?Ye:R(V,ae)||null,!1):null;return et&&(wt.set(ae,et),wt.set(ze,et),Tt&&wt.set(Tt,et),qe==="local"?ct({kind:"move",el:et,source:"local"}):Lt({kind:"move",el:et,source:"remote"})),et};for(let ae of Qt.V.units){if(vt.has(ae)){if(Qe?.has(ae)){for(let rt of Qe.get(ae))yt.has(rt)||(Ge.push(rt),yt.add(rt));continue}let qe=wt.get(ae);yt.has(qe)||(Ge.push(qe),yt.add(qe));continue}if(Z.has(ae)&&!(wt.get(ae)&&yt.has(wt.get(ae)))){let qe=Qt.V.baseOf(ae);qe&&!Ue.has(qe)&&St({kind:"structure",el:null,detail:"both-moved",base:qe},{subject:qe});continue}let ze=Kn(ae,Qt.V,Qt.A,Qt.side);ze&&!yt.has(ze)&&(Ge.push(ze),yt.add(ze),!Qt.V.baseOf(ae)&&!Rn.has(ae)&&!vt.has(ae)&&$t.add(ze))}for(let ae of ut)yt.has(ae.frag)||(Ge.splice(ae.previous&&yt.has(ae.previous)?Ge.indexOf(ae.previous)+1:so(ae.at),0,ae.frag),yt.add(ae.frag));if(!Qt.other.asBase){let ae=Qt.other,ze=Qt.otherSide,qe=Qt.otherA,rt=null,Tt=0,Ye=null;for(let Je of ae.units){let At=Ot.get(Je)||wt.get(Je);if(At&&yt.has(At)){rt=At,Ye=null;continue}if(Z.has(Je)){let pt=ae.baseOf(Je);pt&&!Ue.has(pt)&&St({kind:"structure",el:null,detail:"both-moved",base:pt},{subject:pt});continue}let et=Kn(Je,ae,qe,ze);if(!et)continue;let at;if(Ye)at=Ge.indexOf(Ye)+1;else if(rt){if(at=Ge.indexOf(rt)+1,ze==="remote")for(;at<Ge.length&&$t.has(Ge[at]);)at++}else at=Tt++;Ge.splice(at,0,et),yt.add(et),Ye=et}}for(let ae=0;ae<Ee.length;ae++){let ze=Ee[ae];if(Z.has(ze))continue;let qe=xo(ze);qe&&Ge.splice(so(ae),0,qe)}return tt&&_t.length&&dn.length&&Po(),Ge;function Po(){if(ln||pn)return;let ae=new Set(Ge),ze=pt=>pt&&Ue.has(pt)&&ae.has(wt.get(pt))?pt:null,qe=(pt,zt)=>{let Ct=[{prev:null,units:[]}];for(let tn of pt){let Tn=ze(zt(tn));Tn?Ct.push({prev:Tn,units:[]}):Ct[Ct.length-1].units.push(tn)}return Ct},rt=qe(Ee,pt=>pt),Tt=qe(ee.units,ee.baseOf),Ye=ie.asBase?null:qe(ie.units,ie.baseOf),Je=pt=>pt.length===rt.length&&pt.every((zt,Ct)=>zt.prev===rt[Ct].prev);if(!Je(Tt)||Ye&&!Je(Ye))return;let At=new Map(_t.map(pt=>[pt.bk,pt])),et=new Map(dn.map(pt=>[pt.su,pt])),at=pt=>pt?Ge.indexOf(wt.get(pt)):-1;for(let pt=0;pt<rt.length;pt++){if(rt[pt].units.length!==1||Tt[pt].units.length!==1)continue;let zt=At.get(rt[pt].units[0]),Ct=et.get(Tt[pt].units[0]);if(!zt||!Ct||Ye&&(Ye[pt].units.length!==1||Ye[pt].units[0]!==zt.lk))continue;let tn=at(rt[pt].prev);(pt+1<rt.length?at(rt[pt+1].prev):Ge.length)-tn!==2||Ge[tn+1]!==Ct.node||vo(zt.bk,zt.lk,Ct.su)&&tt.link(zt.lk,Ct.node)}}function Fn(ae,ze,qe,rt){let Tt=Ct=>{let tn=Ct.filter(ft);return tn.length===1?tn[0]:null},Ye=Tt(ae),Je=Tt(ze),At=Tt(qe);if(!Ye||!Je||!At)return;let et=ae.indexOf(Ye);if(ze.indexOf(Je)!==et||qe.indexOf(At)!==et||ae.length!==ze.length||ae.length!==qe.length)return;for(let Ct=0;Ct<ae.length;Ct++)if(Ct!==et&&(ae[Ct].value!==ze[Ct].value||ae[Ct].value!==qe[Ct].value))return;if((ie.asBase?Ye:ie.twin(Ye))!==Je||ee.twin(Ye)||V.reverse.get(At)||Je!==Ye&&ne(Ye,Je,U))return;let at=rt.filter(Ct=>Ct.nodeType===1);if(at.length!==1||xe.get(at[0])?.remote!==At)return;let pt=Ct=>Ct.map(tn=>ft(tn)?"":tn.value??tn.nodeValue).join(""),zt=rt.indexOf(at[0]);pt(rt.slice(0,zt))!==pt(ae.slice(0,et))||pt(rt.slice(zt+1))!==pt(ae.slice(et+1))||vo(Ye,Je,At)&&tt.link(Je,at[0])}function vo(ae,ze,qe){if(!ft(ze)||!ft(qe)||!ft(ae)||ze.namespaceURI!==qe.namespaceURI||ze.localName===qe.localName)return!1;for(let Je of[ze,qe])if(Je.tagName==="TEMPLATE"||mn(Je)||Je.querySelector("template"))return!1;if(n.remoteWins(ae)||n.remoteWins(qe)||s(qe)||ze.attributes.length!==qe.attributes.length)return!1;for(let Je of ze.attributes)if(qe.getAttributeNS(Je.namespaceURI,Je.localName)!==Je.value)return!1;let rt=ze.childNodes,Tt=qe.childNodes;if(rt.length!==Tt.length)return!1;for(let Je=0;Je<rt.length;Je++)if(!rt[Je].isEqualNode(Tt[Je]))return!1;let Ye=[[ae,qe]];for(;Ye.length;){let[Je,At]=Ye.pop();if(Je.children.length!==At.children.length)return!1;for(let et=0;et<At.children.length;et++){let at=V.reverse.get(At.children[et]);if(at!==void 0&&at!==Je.children[et])return!1;Ye.push([Je.children[et],At.children[et]])}}return!0}function so(ae){for(let ze=ae-1;ze>=0;ze--){let qe=wt.get(Ee[ze]);if(qe){let rt=Ge.indexOf(qe);if(rt>=0)return rt+1}}return 0}function To(){if((ie.asBase||U.identical.has(I))&&(ee.asBase||V.identical.has(I)))return;let ae={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},ze=mt=>ft(mt)?Vn(mt,ae):mt.kind==="text";if(!ie.asBase&&!ee.asBase)for(let mt of Ee){if(!ft(mt)||!Cn.has(mt.tagName))continue;let ot=ie.twin(mt),jt=ee.twin(mt);if(!ot&&jt||ot&&!jt){let lt=Br({base:Ee,views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:Et=>ft(Et)&&Cn.has(Et.tagName)&&!s(Et)&&!n.remoteWins(Et),baseId:m.base,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey});lt&&(ie=lt[0],ee=lt[1]);break}}let qe=!ie.asBase&&!ee.asBase&&Ee.length>=2&&Cn.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:mt=>ft(mt)&&Cn.has(mt.tagName)&&!s(mt)&&!n.remoteWins(mt),nodes:{base:Array.from(Ie(I).childNodes),local:Array.from(Ie(ie.el).childNodes),remote:Array.from(Ie(ee.el).childNodes)}}):null,rt=null,Tt=null;if(!qe&&!ie.asBase&&!ee.asBase&&(Es(Ee)||Es(ie.units)||Es(ee.units))){let mt={ignored:s,remoteWins:()=>!1},ot=lt=>ze(lt)||ft(lt)&&n.remoteWins(lt)&&vn.has(lt.tagName)&&Vn(lt,mt),jt=lt=>ft(lt)?Cn.has(lt.tagName)&&!s(lt)&&!n.remoteWins(lt)&&r(lt).every(ot):lt.kind==="text";rt=Dr({onUncertainOwner:lt=>{let Et=n.identity.local(lt.local);Et&&Et===n.identity.remote(lt.remote)||(Tt||=[]).push(lt)},onUncertainSource:lt=>{it||(it=new Map);let Et=it.get(lt.source);Et||it.set(lt.source,Et=[]);for(let Zt of Et)if(Zt.side===lt.side&&Zt.from===lt.from&&Zt.to===lt.to)return;Et.push(lt)},base:Ee,views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:jt,ignored:s,remoteWins:n.remoteWins,baseId:m.base,atomKey:i.exactUnitKey})}if(Tt){Qe||=new Map;for(let mt of Tt){let{source:ot,local:jt,remote:lt}=mt,Et={map:new Map,reverse:new Map,identical:new Set},Zt=bt({base:[ot],local:[jt],remote:[lt],out:oe,policy:"both",L:Et,R:Et,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey,cloneUnit:se,provenance:xe,textMappers:$e,conflicts:k,decisions:le,conflict:(Ut,Gt)=>St(Ut,{...Gt,policy:"both"}),scope:{base:I,local:ie.el,remote:ee.el,units:Ee,at:_e.get(ot)},node:we});re.push(...Zt.segments);for(let Ut of[ot,jt,lt])Z.add(Ut),vt.add(Ut),Qe.set(Ut,Zt.nodes),wt.set(Ut,Zt.nodes[Zt.nodes.length-1]);for(let Ut=0;Ut<Zt.nodes.length;Ut++)ut.push({frag:Zt.nodes[Ut],at:_e.get(ot),previous:Ut?Zt.nodes[Ut-1]:null})}}let Ye=qe?qe.blocks:null;if(rt){Ye=new Set;for(let mt of rt.blocks)Ye.add(mt)}let Je=mt=>!Dt?.consumes(mt)&&(Ye&&Ye.has(mt)||ze(mt)),At=Ee.map(Je);if(!At.includes(!0))return;let et=mt=>{let ot=mt.units,jt=new Map;for(let sn=0;sn<ot.length;sn++)jt.set(ot[sn],sn);let lt=[],Et=-1;for(let sn=0;sn<Ee.length;sn++){if(At[sn])continue;let Mt=mt.twin(Ee[sn]),kt=Mt?jt.get(Mt):void 0;kt===void 0||kt<=Et||Je(Mt)||(lt.push([sn,kt]),Et=kt)}let Zt=[],Ut=-1,Gt=-1;for(let sn=0;sn<=lt.length;sn++){let[Mt,kt]=sn<lt.length?lt[sn]:[Ee.length,ot.length],It={bLo:-1,bHi:-1,from:Gt+1,to:kt,inlineStart:-1,inlineEnd:-1,next:kt};for(let nn=Ut+1;nn<Mt;nn++)At[nn]&&(It.bLo<0&&(It.bLo=nn),It.bHi=nn);for(let nn=Gt+1;nn<kt;nn++){let _n=ot[nn];Je(_n)&&(It.inlineStart<0&&(It.inlineStart=nn),It.inlineEnd=nn+1)}Zt.push(It),Ut=Mt,Gt=kt}return{units:ot,list:Zt}},at=et(ie),pt=et(ee),zt=[];for(let mt of[at,pt])for(let ot of mt.list)ot.bLo>=0&&zt.push([ot.bLo,ot.bHi]);zt.sort((mt,ot)=>mt[0]-ot[0]);let Ct=[];for(let[mt,ot]of zt){let jt=Ct[Ct.length-1];jt&&mt<=jt.hi?jt.hi=Math.max(jt.hi,ot):Ct.push({lo:mt,hi:ot})}let tn=(mt,ot)=>mt.length===ot.length&&mt.every((jt,lt)=>i.equalUnits(jt,ot[lt])),Tn=mt=>!ft(mt)&&mt.kind==="comment",qn=mt=>{if(!mt.length)return[];let ot=(Ut,Gt)=>ft(Ut)?Ut:Ut.nodes[Gt?Ut.nodes.length-1:0],jt=ot(mt[0]),lt=ot(mt[mt.length-1],!0),Et=Ut=>Ut&&ft(Ut)&&s(Ut);for(;Et(jt.previousSibling);)jt=jt.previousSibling;for(;Et(lt.nextSibling);)lt=lt.nextSibling;let Zt=[];for(let Ut=jt;Ut&&(Zt.push(Ut),Ut!==lt);Ut=Ut.nextSibling);return Zt},Pn=mt=>mt.some(ot=>ft(ot)&&s(ot));for(let mt of Ct){let ot=Ee.slice(mt.lo,mt.hi+1),jt=null;if(rt)for(let Mt of ot){let kt=rt.certificatesBySource.get(Mt);kt&&(jt||=[]).push(...kt)}let lt=ie.asBase?null:Is(at,mt),Et=ee.asBase?null:Is(pt,mt);if(jt){let Mt=[new Set(lt||ot),new Set(Et||ot)],kt=jt.some(It=>!Mt[It.side].has(It.target));for(let It of ot)if(Ye.has(It))for(let[nn,_n]of[[0,ie],[1,ee]]){let Sn=_n.twin(It);Sn&&_n.here(Sn)&&!Mt[nn].has(Sn)&&(kt=!0)}if(kt)continue}if(ot.some(Tn)||lt&&lt.some(Tn)||Et&&Et.some(Tn))continue;let Zt=qn(lt||ot),Ut=qn(Et||ot);if((!lt||tn(ot,lt))&&(!Et||tn(ot,Et))&&!(lt&&Pn(Zt)))continue;let Gt=bt({base:qn(ot),sourceRetentions:it?.get(I),local:Zt,remote:Ut,out:oe,policy:Ze,blocks:Ye,scopeUnits:jt?[ot,lt||ot,Et||ot]:null,certifiedOrigins:jt?(Mt,kt,It,nn,_n,Sn)=>jr({certificates:jt,scopes:[ot,lt||ot,Et||ot],flats:[Mt,kt,It],keys:[nn,_n,Sn]}):null,prepared:qe?qe.prepared:null,nativeTransfers:qe,L:lt?U:Ur(U,I),R:Et?V:Ur(V,I),idOf:{base:p,local:v,remote:O},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Mt,kt,It)=>Q(Mt,kt,It,!1),cloneUnit:se,mergeAttrs:Ce,atomKey:i.exactUnitKey,moveIn:z,moveBuilt:z,movePlanned:z,provenance:xe,textMappers:$e,conflicts:k,conflict:St,scope:{base:I,local:ie.asBase?null:ie.el,remote:ee.asBase?null:ee.el,units:Ee,at:mt.lo},decisions:le,node:we});if(!Gt){if(jt){let Mt=pr({certificates:jt,scopes:[ot,lt||ot,Et||ot],views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:kt=>ft(kt)&&Cn.has(kt.tagName)&&!s(kt)&&!n.remoteWins(kt),baseId:m.base});for(let kt of Mt.records){it||=new Map;let It=it.get(kt.source);It||it.set(kt.source,It=[]),It.push(kt)}}continue}if(re.push(...Gt.segments),qe){let Mt=new Map;for(let kt of Gt.nodes){let It=xe.get(kt)?.base;if(!It||Mt.has(It))throw new Error("Invalid native transfer owner output");Mt.set(It,kt)}if(Mt.size!==qe.owners.length)throw new Error("Incomplete native transfer owner output");for(let kt of qe.owners){let It=Mt.get(kt.base);if(!It)throw new Error("Missing native transfer owner output");for(let nn of[kt.base,kt.local,kt.remote])Z.add(nn),vt.add(nn),wt.set(nn,It);ut.push({frag:It,at:_e.get(kt.base)})}continue}if(tt&&Fn(ot,lt||ot,Et||ot,Gt.nodes),Gt.unitOutputs){Qe||=new Map;for(let kt of[...ot,...lt||[],...Et||[]]){let It=Gt.unitOutputs.get(kt)||[];Z.add(kt),vt.add(kt),Qe.set(kt,It),It.length&&wt.set(kt,It[It.length-1])}let Mt=Gt.nodes[Gt.nodes.length-1];if(Mt)for(let kt of[lt||ot,Et||ot]){let It=kt[kt.length-1];It&&Ot.set(It,Mt)}for(let kt=0;kt<Gt.nodes.length;kt++)ut.push({frag:Gt.nodes[kt],at:mt.lo,previous:kt>0?Gt.nodes[kt-1]:null});continue}tt&&Fn(ot,lt||ot,Et||ot,Gt.nodes);let sn=oe.createDocumentFragment();for(let Mt of Gt.nodes)sn.appendChild(Mt);for(let Mt of[...ot,...lt||[],...Et||[]])Z.add(Mt),vt.add(Mt),wt.set(Mt,sn);ut.push({frag:sn,at:mt.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 Xe(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&&St({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=ft(te)?te.parentNode:te.parent,we=ft(I)?I.parentNode:I.parent;return R(q,we)===me?null:q.reverse.get(me)||null}function st(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||ft(I)&&ft(we)&&I.contains(we)||q.has(we))return!0;q.add(we),te=we}return!0}function Kt(I,q,te){if(!q)return!1;let me=ft(I)?I.parentNode:I.parent;return me===q||q.tagName==="TEMPLATE"&&me===q.content}function Vt(I,q){let te=De(I),me=R(U,te);if(me&&Kt(q,me,U))return!0;let we=R(V,te);return!!(we&&Kt(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:pl(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 ml(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 Gn(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}Bt(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"&&Pt(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&&Dt(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=le(Me);Oe!=null&&je!==Oe&&(Q=lo(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=tt(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)||bt(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 le(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 tt(F){if(mn(F))return Mo(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(Mo(ge,s));return ce}function bt(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)&&bt(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(tt(Me))}function ct(F,ce){return ce.namespaceURI?F.getAttributeNS(ce.namespaceURI,ce.localName):F.getAttribute(ce.name)}function Lt(F,ce){let ge=new Set((ce||"").split(Ls).filter(Boolean));return(F||"").split(Ls).filter(Le=>Le&&!ge.has(Le))}function Bt(F,ce,ge){for(let Le of Array.from(ce.attributes)){if(St(F,Le.name)||n.ignoreAttribute(F,Le.name))continue;let Me=ct(F,Le);if(Me===Le.value||ge&&ct(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=Lt(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(St(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=Lt(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&&ct(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 St(F,ce){let ge=F.tagName;return ge==="INPUT"?ce==="value"||ce==="checked"||ce==="disabled":ge==="OPTION"?ce==="selected":!1}function Pt(F){return F===s.activeElement}function Dt(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&&Pt(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||(Rt(F,M,"checked"),n.formState==="property"&&F.indeterminate!==M.indeterminate&&(F.indeterminate=M.indeterminate)),Rt(F,M,"disabled")}else if(Le==="OPTION"){let R=F.parentNode&&F.closest("select");n.protectFocusedValue&&R&&Pt(R)||Rt(F,M,"selected")}}function Rt(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&&Pt(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 pl(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 ml(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 gl={compared:0},bl=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function wl(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?Eo:"*";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(!wl(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=le=>{let k=u(le);return k!==null?k:d.base(le)||null},a=le=>{let k=u(le);return k!==null?k:d.remote(le)||null},h=[],p=[],v=new Map,O=new Map,m={same:v,differ:O},c=le=>({bail:le,comparisons:m}),g=(le,k,_=!0)=>{if(v.get(le)===k)return!0;if(O.get(le)===k)return!1;if(gl.compared++,_&&le.isEqualNode(k))return v.set(le,k),!0;let re=le.nodeType===k.nodeType;if(re&&le.nodeType===1){if(re=Rs(le,k),re){let Z=le.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=le.isEqualNode(k));return(re?v:O).set(le,k),re},P=e,T=o,x=!1,A=()=>{v.set(P,T);for(let le=0;le<h.length;le++)v.set(h[le],p[le]);return c("equal")};for(;;){let le=P.childNodes,k=T.childNodes;if(le.length!==k.length)break;let _=tt=>g(le[tt],k[tt])?(v.set(le[tt],k[tt]),!1):!0,re=-1,Z=-1;for(let tt=0;tt<le.length;tt++){if(le[tt].nodeType!==1)continue;let bt=0;for(let Ze=le[tt].firstElementChild;Ze;Ze=Ze.nextElementSibling)bt++;bt>=Z&&(Z=bt,re=tt)}let Be=[],Ke=!1;for(let tt=0;tt<le.length&&Be.length<2;tt++)tt!==re&&_(tt)&&Be.push(tt);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=le[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 le=0;le<h.length;le++)O.set(h[le],p[le]);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 le of h)if(bl.has(le.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 le of h){let k=n(le);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=le=>{le&&(N.has(le)?C.add(le):N.add(le))},w=(le,k)=>{let _=u(le),re=_!==null?_:d.base(le)||null;return re!==(_!==null?_:d.remote(k)||null)?!1:(B(re),!0)},y=(le,k)=>{for(let _=le.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},$=le=>{let k=le+1<h.length?h[le+1]:P;for(let _=h[le].firstElementChild,re=p[le].firstElementChild;_;_=_.nextElementSibling,re=re.nextElementSibling){if(_===k){let Ke=le+1<h.length?$(le+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";le===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 le of e.querySelectorAll(Eo))le===P||V.has(le)||(P.contains(le)?Ne.push(le):S&&B(b(le)))}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(Eo),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:le=>{for(let k=1;k<h.length;k++)if(le.map.get(h[k])!==p[k])return!1;for(let[k,_]of j)if(le.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 Co(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 bo(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=Co([e,...e.querySelectorAll("*")],d)),i}let l=null;function u(){return l||(l=Co([o,...o.querySelectorAll("*")],d)),l}function b(N){return!N.parentElement||!N.parentElement.parentElement}function a(N,C,j){return b(N)||bo(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 le=!0;for(let k=0;k<D.length;k++)if(!v(D[k],B[k])){le=!1;break}if(le){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(le=>le.nodeType===1),y=B.filter(le=>le.nodeType===1);if(O(D)!==O(B))return!0;let $=Co(w,d),U=Co(y,d),V=[],Ne=new Set,Ae=[];for(let le of w){let k=$r(le,$,U,d);k&&!Ne.has(k)?(V.push([le,k]),Ne.add(k)):Ae.push(le)}let De=[];for(let le of Ae)bo(le,$,d)?j.push({type:"subtree",el:le,base:null}):De.push(le);let oe=[];for(let le of y)Ne.has(le)||(bo(le,U,d)?j.push({type:"deletion",el:le}):oe.push(le));if(De.length!==oe.length)return!0;for(let le=0;le<De.length;le++)if(!v(De[le],oe[le]))return!0;let xe=new Map(V);for(let le=0;le<De.length;le++)xe.set(De[le],oe[le]);let $e=-1;for(let le of w){let k=xe.get(le);if(!k)continue;let _=y.indexOf(k);if(_<$e)return!0;$e=_}for(let le=0;le<De.length;le++)if(c(De[le],oe[le],j))return!0;for(let[le,k]of V)if(c(le,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)&&!bo(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 Co(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&&!bo(c.base,a(c.base),n)||!bo(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 yl='[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"]',kl='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',xl='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function vl(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 Tl(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=Sl(e,o,n)),!!s)return t?Array.from(s.childNodes):s}function Sl(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=ho(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=ho(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)=>vl(l)||(n==="history"?!(u&&l.matches(xl))&&l.matches(kl):l.matches(yl)),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 wo(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 wo(l)}t.morphStyle==="innerHTML"&&(i.children=!0);let r=Tl(e,t.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return r!==void 0&&(i.base=r),Zo(e,o,i)}var Nl=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),On=()=>{};function Lo(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let r of Object.keys(e))if(!Nl.has(r))throw new TypeError(`unknown option "${r}"`);let t=Object.assign({beforeNodeAdded:On,afterNodeAdded:On,beforeNodeRemoved:On,afterNodeRemoved:On,beforeNodeMorphed:On,afterNodeMorphed:On,beforeAttributeUpdated:On},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 yo(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 ko(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 ni(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=Lo(l,[r,d,i].filter(Boolean)),b=n.identity||{},a=zn(),h=Jo(r,d,i,{identity:{base:ko(b.base,r),local:ko(b.local,d),remote:ko(b.remote,i)},authored:{base:yo(b.base),local:yo(b.local),remote:yo(b.remote)},skipUnchanged:u.hooks.beforeNodeMorphed===On&&u.hooks.afterNodeMorphed===On,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=Lo(d,[e,o,t,n].filter(Boolean));if(u.ignored(e)){let w=Bs(),y=u.lineage?Ao(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=zn(),v=u.hooks.beforeNodeMorphed===On&&u.hooks.afterNodeMorphed===On,O={identity:{base:ko(i.base,o||t),local:ko(i.local,t),remote:ko(i.remote,n)},authored:{base:yo(i.base),local:yo(i.local),remote:yo(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=zn()))}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]!==On)&&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:zn()}}function wo(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");return o.lineage===void 0?Zr(o):vs(o,o.live.documentElement,n=>Zr(n))}function Zr(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 oi(e,o,t={}){return wo(Object.assign({},t,{live:e,base:null,remote:o}))}function ei(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 t.lineage===void 0?ti(e,o,t):vs(t,e,n=>ti(e,o,n))}function ti(e,o,t={}){let n=e.ownerDocument,{base:s,...d}=t,i=!!d.children,r=Lo(d,[e]);if(r.ignored(e)){let O=Bs();return r.lineage&&Ao(r.lineage,e,O).deliver(O),Promise.resolve(O)}let l=ei(o,n),u=s!=null?ei(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=Lo(d),m=O.lineage?Ao(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:zn()};return m&&(c.lineage=m.result,m.deliver(c)),Promise.resolve(c)}if(b.tagName!==e.tagName){let O=Lo(d,[e,b]);if(O.hooks.beforeNodeMorphed(e,b)===!1){let g=Bs();return O.lineage&&Ao(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)?Mo(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:wo,morphDocument:oi,morphElement:Zo,merge3:ni,morph:Qo};return fi(Ml);})();
1
+ var HyperMorph=(()=>{var ns=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var ii=Object.getOwnPropertyNames;var li=Object.prototype.hasOwnProperty;var ai=(e,o)=>{for(var t in o)ns(e,t,{get:o[t],enumerable:!0})},ci=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of ii(o))!li.call(e,s)&&s!==t&&ns(e,s,{get:()=>o[s],enumerable:!(n=ri(o,s))||n.enumerable});return e};var fi=e=>ci(ns({},"__esModule",{value:!0}),e);var Ml={};ai(Ml,{createIdentityStore:()=>Us,createParseCache:()=>Do,default:()=>Al,diff:()=>Gn,findChangedRoots:()=>Gr,importMap:()=>jo,merge3:()=>ni,merge3Text:()=>lo,mergeDocument:()=>wo,mergeJson:()=>As,mergeScriptText:()=>Go,morph:()=>Qo,morphDocument:()=>oi,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 h=Bo(n,e);return o.set(t,{text:n,doc:h}),h}}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 h=t.get(s);if(h!==void 0)return h;let i=[],r=s,a=!1;for(;r&&r.nodeType===1;){let d=t.get(r);if(d!==void 0){a=d;break}if(i.push(r),e(r,n.has(r))){a=!0;break}if(n.has(r))break;r=r.parentElement}for(let d of i)t.set(d,a);return a}}var Ll=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 zn(){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 a=o.get(r);return a||(a=`${e}:${++t}`,o.set(r,a)),a};return{idOf:n,ensure:s,adopt:(r,a)=>{r&&typeof a=="string"&&a&&o.set(r,a)},exportMap:(r,a)=>{let d={},w=[],c=[],p=(m,v)=>{let I=a(m);I&&(d[v]=s(I));let g=m.children;w.push(g.length),c.push(m.tagName.toLowerCase());for(let f=0;f<g.length;f++)p(g[f],v===""?String(f):`${v}.${f}`)};return p(r,""),d["~"]=w.join(","),d["^"]=c.join(","),d}}}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,h=s&&typeof o["^"]=="string"?o["^"].split(","):null,i=c=>Number.isInteger(c)&&c>=0,r=0,a=!1,d=c=>{let p=c;for(;p>0;){let m=s[r++];if(r>s.length||!i(m))return!1;p+=m-1}return!0},w=(c,p)=>{if(a)return;if(s){let I=r++,g=s[I];if(I>=s.length||!i(g)){a=!0;return}let f=!h||h[I]===c.tagName.toLowerCase();if(!f||g!==c.children.length){let b=f&&o[p];typeof b=="string"&&b&&t.set(c,b),d(g)||(a=!0);return}}let m=o[p];typeof m=="string"&&m&&t.set(c,m);let v=c.children;for(let I=0;I<v.length;I++)w(v[I],p===""?String(I):`${p}.${I}`)};return w(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 h=new Map,i=new Set,r=a=>{if(t(a))return;let d=o(a);d&&(h.has(d)?i.add(d):h.set(d,a))};if(n){let a=d=>{for(let w of d.querySelectorAll(n))r(w);for(let w of d.querySelectorAll("template"))w.content&&a(w.content)};r(e),a(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let a=d=>{r(d);let w=d.tagName==="TEMPLATE"&&d.content?d.content.children:d.children;for(let c=0;c<w.length;c++)a(w[c])};a(e)}for(let a of i)h.delete(a),s&&s.add(a),is(a);return h}function is(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var ui=new Set(["href","src","name","type","role"]),Hs=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function ro(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 di=0;function Ws({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,s=new WeakMap;function h(M){let L=M.attributes,N=L.length;if(N===0)return{all:"",sig:M.tagName+"|"};let A=[],E="",V=[];for(let j=0;j<N;j++){let D=L[j],y=D.name;o(M,y)||A.push(y+"="+D.value),y==="class"?E=D.value.indexOf(" ")<0?D.value:D.value.split(/\s+/).filter(Boolean).sort().join(" "):ui.has(y)&&V.push(y+"="+D.value)}return A.length>1&&A.sort(),V.length>1&&V.sort(),{all:A.join(""),sig:M.tagName+"|"+E+(V.length?"|"+V.join("|"):"")}}function i(M){return M.nodeType===1&&M.tagName==="TEMPLATE"&&M.content?M.content.childNodes:M.childNodes}function r(M){let L=n.get(M);if(L)return L;if(M.nodeType===3)L={hash:"T"+ro(M.nodeValue),hint:Vs(M.nodeValue).slice(0,64),sig:null,tok:null};else if(M.nodeType===8)L={hash:"C"+ro(M.nodeValue),hint:"",sig:null,tok:null};else if(M.nodeType===1){let N=h(M),A=ro(M.tagName+""+N.all),E="";for(let V of d(M))if(V.nodeType===1){let j=r(V);A=ro(j.hash,A),E.length<64&&(E+=" "+j.hint)}else A=ro(w(V),A),V.kind==="text"&&E.length<64&&(E+=V.value.slice(0,64));L={hash:"E"+A,hint:Vs(E).trim().slice(0,64),sig:N.sig,tok:null}}else L={hash:"N"+M.nodeType,hint:"",sig:null,tok:null};return n.set(M,L),L}function a(M){if(!M.tok){M.tok=new Set;for(let L of M.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))L&&M.tok.add(L)}return M.tok}function d(M){let L=s.get(M);if(L)return L;L=[];let N=null,A=()=>{N&&(N.value=N.nodes.map(E=>E.nodeValue).join(""),L.push(N),N=null)};for(let E of i(M)){if(E.nodeType===3){N||(N={kind:"text",nodes:[],value:"",parent:M,hash:void 0}),N.nodes.push(E);continue}A(),E.nodeType===8?L.push({kind:"comment",nodes:[E],value:E.nodeValue,parent:M,hash:void 0}):E.nodeType===1&&!e(E)&&L.push(E)}return A(),s.set(M,L),L}function w(M){return M.nodeType===1?r(M).hash:(M.hash===void 0&&(M.hash=(M.kind==="text"?"T":"C")+ro(M.value)),M.hash)}function c(M,L){let N=a(r(M)),A=a(r(L));if(N.size===0&&A.size===0)return{coef:1,share:1};if(N.size===0||A.size===0)return null;let E=0;for(let V of N)A.has(V)&&E++;return{coef:E/Math.min(N.size,A.size),share:E/Math.max(N.size,A.size)}}function p(M,L){let N=c(M,L);return!!N&&N.coef>=.5}let m=new WeakMap;function v(M){let L=m.get(M);if(L)return L;L=[];for(let N of M.attributes)o(M,N.name)||L.push([N.namespaceURI||"",N.localName,N.value]);return L.sort((N,A)=>N[0]<A[0]?-1:N[0]>A[0]?1:N[1]<A[1]?-1:N[1]>A[1]?1:0),m.set(M,L),L}let I=new WeakMap;function g(M,L){if(M===L)return!0;if(w(M)!==w(L))return!1;let N=I.get(M);if(N&&N.has(L))return N.get(L);let A=I.get(L);if(A&&A.has(M))return A.get(M);let E=f(M,L),V=E===!0;return E===!1&&t&&t.hashRejected++,N||I.set(M,N=new WeakMap),N.set(L,V),V}function f(M,L){if(M.nodeType===1){if(L.nodeType!==1||M.tagName!==L.tagName||M.namespaceURI!==L.namespaceURI)return!1;let N=v(M),A=v(L);if(N.length!==A.length)return!1;for(let j=0;j<N.length;j++)if(N[j][0]!==A[j][0]||N[j][1]!==A[j][1]||N[j][2]!==A[j][2])return!1;let E=d(M),V=d(L);if(E.length!==V.length)return!1;for(let j=0;j<E.length;j++){if(w(E[j])!==w(V[j]))return!1;if(!g(E[j],V[j]))return di}return!0}return L.nodeType===1?!1:M.kind===L.kind&&M.value===L.value}let b=new WeakMap,B=new Map,S=0;function T(M){let L=b.get(M);if(L)return L;let N=w(M),A=B.get(N);A||B.set(N,A=[]);let E=A.find(V=>g(V.unit,M));return L=E?E.key:"K"+S++,E||A.push({unit:M,key:L}),b.set(M,L),L}return{meta:r,unitsOf:d,unitHash:w,similar:p,score:c,childrenOf:i,equalUnits:g,exactUnitKey:T,ignored:e}}var qs=16,hi=2e3,pi=3,ls={align:0,certifyVisited:0,certifyScheduled:0};function as(e,o,t){let{meta:n,unitsOf:s,unitHash:h,similar:i,score:r,childrenOf:a,equalUnits:d,ignored:w}=t.analyzer,c=t.baseId||(()=>null),p=t.sideId||(()=>null),m=t.baseKey||(()=>null),v=t.sideKey||(()=>null),I=t.baseDropped||new Set,g=t.sideDropped||new Set,f=t.stats||null,b=f?new Set:null,B=f?new Set:null,S=new Map,T=new Map,M=new Set,L=new Map,N=new Set,A=new Set,E=new Set,V=[],j=[],D=[],y=[],k=hi,J=new Map,H=new Map,q=(W,X)=>{S.set(W,X),T.set(X,W)},Me=new Set,Oe=new Set,Re=null,ie=W=>{let X=W.nodeType?W.parentNode:W.parent;if(!X||X.nodeType!==11)return X;if(!Re){Re=new WeakMap;let pe=be=>{for(let he of be.querySelectorAll("template"))he.content&&(Re.set(he.content,he),pe(he.content))};for(let be of[e,o])pe(be.tagName==="TEMPLATE"&&be.content?be.content:be)}return Re.get(X)||null},xe=(W,X)=>{for(let pe=ie(W);pe&&!Me.has(pe);pe=ie(pe))Me.add(pe);for(let pe=ie(X);pe&&!Oe.has(pe);pe=ie(pe))Oe.add(pe)},qe=W=>{for(let X=ie(W);X;X=ie(X))if(S.has(X))return A.has(X);return!1},fe=W=>{for(let X=ie(W);X;X=ie(X)){let pe=T.get(X);if(pe!==void 0)return A.has(pe)}return!1},x=W=>!!W&&W.nodeType===1,Y=(W,X)=>{let pe=L.get(W);return!!pe&&pe.has(X)},ae=W=>Hs.has(W.tagName),oe=t.comparisons||t.scope,Ee=(W,X)=>{if(oe){if(oe.same.get(W)===X)return!0;if(oe.differ.get(W)===X)return!1}if(!W.isEqualNode(X))return!1;if(W.tagName==="TEMPLATE")return d(W,X);let pe=W.getElementsByTagName("template");if(pe.length===0)return!0;let be=X.getElementsByTagName("template");if(pe.length!==be.length)return!1;for(let he=0;he<pe.length;he++)if(!d(pe[he],be[he]))return!1;return!0},je=(W,X)=>{let pe=c(W);if(!pe)return!0;let be=p(X);return!be||pe===be},Ne=W=>{let X=m(W);return X&&t.baseIndex.get(X)===W&&!g.has(X)?X:null},tt=W=>{let X=v(W);return X&&t.sideIndex.get(X)===W&&!I.has(X)?X:null},Xe=(W,X)=>{let pe=Ne(W);if(!pe)return!0;let be=tt(X);return!be||pe===be},dt=globalThis.__hyperMorphProfile,Ge=dt?performance.now():0;dt&&!t.scope&&(n(e),n(o),dt.meta=(dt.meta||0)+(performance.now()-Ge),Ge=performance.now()),q(e,o);let st=new Set;for(let[W,X]of t.baseIndex){let pe=t.sideIndex.get(W);pe&&pe.tagName===X.tagName&&!S.has(X)&&!T.has(pe)&&(q(X,pe),xe(X,pe),st.add(X))}if(st.size){let W=[];if(t.scope)for(let he of t.scope.chain)st.has(he)&&W.push(he);let X=[t.scope?t.scope.root:e];for(;X.length;){let he=X.pop();st.has(he)&&W.push(he);let ee=a(he);for(let te=ee.length-1;te>=0;te--)ee[te].nodeType===1&&X.push(ee[te])}let pe=new Set;for(let he=W.length-1;he>=0;he--){let ee=W[he];t.scope&&t.scope.onChain.has(ee)?pe.add(ee):jt(ee,S.get(ee),pe)?(A.add(ee),E.add(ee),f&&f.certificationPairs++):pe.add(ee)}let be=new Set;for(let he of W)A.has(he)&&!be.has(he)&&Ot(he,be)}t.scope&&t.scope.head&&Gt(t.scope.head[0],t.scope.head[1]);function Ot(W,X){let pe=[W];for(;pe.length;){let be=pe.pop();if(!X.has(be)){X.add(be),O(be);for(let he of s(be))x(he)&&S.has(he)&&pe.push(he)}}}y.push([e,o]);for(let[W,X]of S)x(W)&&W!==e&&y.push([W,X]);return Lt(),Ct(),dt&&(dt.align=(dt.align||0)+(performance.now()-Ge)),{map:S,reverse:T,moved:N,identical:A,pairIdenticalChildren:O,weak:M,unpair:yt,rematch:Ct,insertedByHash:Nt,refused:B,identityPaired:st};function Ct(){Ae(),Lt();for(let W=0;W<D.length;){let X=D.length;It(W,X),W=X,Lt(),Ae(),Lt()}}function yt(W){let X=S.get(W);if(!X)return;L.has(W)||L.set(W,new Set),L.get(W).add(X);let pe=(he,ee)=>{S.delete(he),T.delete(ee),N.delete(he),A.delete(he),M.delete(he),E.delete(he)},be=(he,ee)=>{for(let te of s(he)){let z=S.get(te);!z||st.has(te)||!(x(z)?ee.contains(z):ee.contains(z.nodes[0]))||(pe(te,z),x(te)&&be(te,z))}};pe(W,X),x(W)&&be(W,X),V.push(W),j.push(X)}function Nt(){let W=new Map;for(let X of new Set(j)){if(T.has(X))continue;let pe=n(X).hash;W.has(pe)||W.set(pe,[]),W.get(pe).push(X)}return W}function Lt(){for(;y.length;){let[W,X]=y.shift();S.get(W)!==X||E.has(W)||A.has(W)||cn(W,X)}}function qt(W,X){if(!ae(W))for(let pe of s(W))x(pe)&&(X.push(pe),qt(pe,X))}function cn(W,X){E.add(W);let pe=s(W),be=s(X);ls.align+=pe.length+be.length,J=new Map,H=new Map;for(let ne=0;ne<pe.length;ne++)J.set(pe[ne],ne);for(let ne=0;ne<be.length;ne++)H.set(be[ne],ne);if(W.tagName==="HTML")for(let ne of["HEAD","BODY"]){let Te=pe.find(Pe=>x(Pe)&&Pe.tagName===ne),Ce=be.find(Pe=>x(Pe)&&Pe.tagName===ne);Te&&Ce&&!S.has(Te)&&!T.has(Ce)&&q(Te,Ce)}for(let ne=0;ne<pe.length&&ne<be.length;ne++){let Te=pe[ne],Ce=be[ne];S.has(Te)||T.has(Ce)||(x(Te)?x(Ce)&&Te.tagName===Ce.tagName&&Ee(Te,Ce)&&Gt(Te,Ce):!x(Ce)&&Te.kind===Ce.kind&&Te.value===Ce.value&&Gt(Te,Ce))}le(pe,be);let he=pe.filter(ne=>!S.has(ne)),ee=be.filter(ne=>!T.has(ne));he.length&&ee.length&&(wn(he,ee),R(he,ee),K(he,ee,pe,be),de(pe,be));let te=!1,z=!1;for(let ne of pe){if(!S.has(ne)){x(ne)&&(V.push(ne),qt(ne,V),te=!0);continue}x(ne)&&!A.has(ne)&&y.push([ne,S.get(ne)])}for(let ne of be)!T.has(ne)&&x(ne)&&(j.push(ne),qt(ne,j),z=!0);te&&z&&D.push([W,X])}function It(W,X){for(let pe=W;pe<X;pe++){let[be,he]=D[pe];if(S.get(be)!==he)continue;let ee=s(be),te=s(he),z=new Map,ne=new Map,Te=null;for(let Ce of ee)x(Ce)&&(S.has(Ce)?Te=Ce:(z.has(Te)||z.set(Te,[]),z.get(Te).push(Ce)));Te=null;for(let Ce of te)x(Ce)&&(T.has(Ce)?Te=T.get(Ce):(ne.has(Te)||ne.set(Te,[]),ne.get(Te).push(Ce)));for(let[Ce,Pe]of z){let ve=ne.get(Ce);if(!(!ve||Pe.length!==ve.length)&&Pe.every((_e,Je)=>ve[Je].tagName===_e.tagName&&je(_e,ve[Je])&&!Y(_e,ve[Je])))for(let _e=0;_e<Pe.length;_e++)$t(Pe[_e],ve[_e])}}}function $t(W,X){q(W,X),M.add(W),y.push([W,X]),Lt()}function wn(W,X){let pe=io(W,h),be=io(X,h),he=new Map;for(let ee of X){let te=h(ee);be.get(te)===1&&he.set(te,ee)}for(let ee of W){if(S.has(ee))continue;let te=h(ee);if(pe.get(te)!==1)continue;let z=he.get(te);z&&!T.has(z)&&d(ee,z)&&Gt(ee,z)}}function jt(W,X,pe){let be=[[W,X]];for(;be.length;){let[he,ee]=be.pop();if(ls.certifyVisited++,f&&f.certificationVisited++,he.nodeType!==ee.nodeType)return!1;if(he.nodeType===3||he.nodeType===8){if(he.nodeValue!==ee.nodeValue)return!1;continue}if(he.nodeType!==1){if(!he.isEqualNode(ee))return!1;continue}if(he.tagName!==ee.tagName||he.namespaceURI!==ee.namespaceURI||w(he)!==w(ee))return!1;let te=he.attributes,z=ee.attributes;if(te.length!==z.length)return!1;for(let ve=0;ve<te.length;ve++){let _e=te[ve];if(ee.getAttributeNS(_e.namespaceURI,_e.localName)!==_e.value)return!1}let ne=S.get(he);if(ne!==void 0&&ne!==ee)return!1;let Te=T.get(ee);if(Te!==void 0&&Te!==he)return!1;if(he!==W){if(A.has(he))continue;if(pe.has(he))return!1}let Ce=a(he),Pe=a(ee);if(Ce.length!==Pe.length)return!1;ls.certifyScheduled+=Ce.length;for(let ve=Ce.length-1;ve>=0;ve--)be.push([Ce[ve],Pe[ve]])}return!0}function rn(W,X){return!x(W)||!(Me.has(W)||Oe.has(X))?!0:!!$(W,X)||!(Ne(W)||tt(X))}function Gt(W,X){if(x(W)&&(Me.has(W)||Oe.has(X))){let pe=$(W,X);if(!pe){if(Ne(W)||tt(X))return;q(W,X),y.push([W,X]);return}for(let be=0;be<pe.length;be+=2){let he=pe[be],ee=pe[be+1],te=S.get(he);te!==void 0&&te!==ee&&fn(he,te);let z=T.get(ee);z!==void 0&&z!==he&&fn(z,ee),S.get(he)===ee&&(N.delete(he),M.delete(he),A.add(he),E.add(he))}}l(W,X)}function fn(W,X){S.delete(W),T.delete(X),N.delete(W),A.delete(W),M.delete(W),E.delete(W)}function $(W,X){let pe=[W,X,!1],be=[];for(;pe.length;){let he=pe.pop(),ee=pe.pop(),te=pe.pop(),z=S.get(te),ne=T.get(ee);if(te!==W&&(z!==void 0&&z!==ee&&st.has(te)||ne!==void 0&&ne!==te&&st.has(ne)))return null;if(!(z===ee&&A.has(te))&&((z!==void 0||ne!==void 0)&&be.push(te,ee),!!x(te))){if(he||z!==void 0&&z!==ee||ne!==void 0&&ne!==te){let Te=s(te),Ce=s(ee);for(let Pe=0;Pe<Te.length&&Pe<Ce.length;Pe++)pe.push(Te[Pe],Ce[Pe],!0)}else if(Me.has(te)||Oe.has(ee)){let Te=te.tagName==="TEMPLATE"?te.content:te,Ce=ee.tagName==="TEMPLATE"?ee.content:ee;for(let Pe=Te.firstElementChild,ve=Ce.firstElementChild;Pe&&ve;){if(w(Pe)){Pe=Pe.nextElementSibling;continue}if(w(ve)){ve=ve.nextElementSibling;continue}(S.has(Pe)||T.has(ve)||Me.has(Pe)||Oe.has(ve))&&pe.push(Pe,ve,!1),Pe=Pe.nextElementSibling,ve=ve.nextElementSibling}}}}return be}function l(W,X){q(W,X),A.add(W),x(W)&&E.add(W)}function O(W){let X=S.get(W);if(!X||!x(W))return;let pe=s(W),be=s(X);for(let he=0;he<pe.length&&he<be.length;he++)S.has(pe[he])||l(pe[he],be[he])}function R(W,X){let pe=te=>x(te)&&!ae(te)?n(te).sig+""+n(te).hint:null,be=io(W,pe),he=io(X,pe),ee=new Map;for(let te of X){let z=pe(te);z!=null&&he.get(z)===1&&ee.set(z,te)}for(let te of W){if(S.has(te))continue;let z=pe(te);if(z==null||be.get(z)!==1)continue;let ne=ee.get(z);ne&&!T.has(ne)&&je(te,ne)&&q(te,ne)}}function K(W,X,pe,be){let he=new Map;for(let te of X){if(!x(te)||T.has(te)||ae(te))continue;let z=n(te).sig;he.has(z)||he.set(z,[]),he.get(z).push({el:te,index:H.get(te)})}let ee=[];for(let te of W){if(S.has(te)||!x(te)||ae(te))continue;let z=he.get(n(te).sig);if(!z||!z.length)continue;let ne=J.get(te),Te=z.filter(Ce=>!T.has(Ce.el)).map(Ce=>({c:Ce,d:Math.abs(Ce.index-ne)}));Te.sort((Ce,Pe)=>Ce.d-Pe.d),Te.length>qs&&(Te=Te.slice(0,qs));for(let{c:Ce,d:Pe}of Te){if(!je(te,Ce.el))continue;let ve=r(te,Ce.el);ve&&ve.coef>=.5&&ee.push({b:te,s:Ce.el,coef:ve.coef,share:ve.share,d:Pe,bi:ne})}}if(ee.sort((te,z)=>z.coef-te.coef||z.share-te.share||te.d-z.d||te.bi-z.bi),f&&ee.length>1){let te=new Map;for(let z of ee){let ne=te.get(z.b);ne?ne.coef===z.coef&&(ne.share===z.share?ne.strict++:ne.loose++):te.set(z.b,{coef:z.coef,share:z.share,strict:0,loose:0})}for(let[z,ne]of te)b.has(z)||!(ne.strict||ne.loose)||(b.add(z),ne.strict?f.similarTiesStrict++:f.similarTiesLoose++)}for(let te of ee)!S.has(te.b)&&!T.has(te.s)&&q(te.b,te.s)}function Z(W,X){return x(W)!==x(X)?!1:x(W)?W.tagName!==X.tagName||!je(W,X)?!1:ae(W)||n(W).hint===""||n(X).hint===""?!0:i(W,X):W.kind===X.kind}function U(W,X){let pe=(he,ee)=>{let te=ee===null?-1:he===X?H.get(ee):J.get(ee),z=he[te+1];return z&&!x(z)?z:null},be=null;for(let he of W){if(x(he)){be=he;continue}if(S.has(he))continue;let ee=be===null?null:S.get(be);if(be!==null&&!ee)continue;let te=pe(X,ee);te&&!T.has(te)&&te.kind===he.kind&&q(he,te)}}function de(W,X){U(W,X);let pe=we(W,X),be=(ee,te)=>x(ee)&&n(ee).hint!==""&&n(te).hint===""&&!!te.querySelector("br")&&!pe(ee,te),he=0;for(let ee of W){if(S.has(ee)){let z=H.get(S.get(ee));z!==void 0&&z>=he&&(he=z+1);continue}let te=0;for(let z=he;z<X.length&&te<pi;z++){let ne=X[z];if(!T.has(ne)&&(te++,Z(ee,ne)&&!Y(ee,ne)&&!be(ee,ne))){q(ee,ne),x(ee)&&(n(ee).hint===""||n(ne).hint==="")&&M.add(ee),he=z+1;break}}}le(W,X)}function we(W,X){let pe=(be,he,ee)=>{for(let te=he-1;te>=0;te--)if(x(be[te])&&ee(be[te]))return be[te];return null};return(be,he)=>{let ee=J.get(be),te=H.get(he);if(ee===te)return!0;let z=pe(W,ee,Te=>S.has(Te)),ne=pe(X,te,Te=>T.has(Te));return z?S.get(z)===ne:!ne}}function le(W,X){let pe=W.filter(z=>x(z)&&!S.has(z)),be=X.filter(z=>x(z)&&!T.has(z));if(!pe.length||!be.length)return;let he=io(pe,z=>z.tagName),ee=io(be,z=>z.tagName),te=we(W,X);for(let z of pe){let ne=z.tagName;if(he.get(ne)!==1||ee.get(ne)!==1)continue;let Te=be.find(Ce=>Ce.tagName===ne);Te&&!T.has(Te)&&te(z,Te)&&je(z,Te)&&!Y(z,Te)&&(d(z,Te)?Gt(z,Te):(q(z,Te),M.add(z)))}}function Ae(){let W=new Map;for(let z of M)if(x(z)&&x(S.get(z))){let ne=n(z).hash;W.has(ne)||W.set(ne,[]),W.get(ne).push(z)}if(W.size)for(let z of j){if(T.has(z)||!x(z)||fe(z))continue;let ne=W.get(n(z).hash),Te=ne&&ne.find(Ce=>M.has(Ce)&&!Y(Ce,z)&&je(Ce,z)&&Xe(Ce,z)&&d(Ce,z)&&rn(Ce,z));Te&&(yt(Te),Gt(Te,z),xe(Te,z),N.add(Te))}let X=new Map,pe=new Map,be=new Map;for(let z of M){let ne=S.get(z);x(z)&&x(ne)&&be.set(ne,z)}let he=(z,ne)=>{if(!T.has(z))return!fe(z);let Te=be.get(z);return Te===T.get(z)&&Te!==ne&&!Te.contains(ne)},ee=z=>{if(T.has(z)){let ne=be.get(z);be.delete(z),yt(ne)}};for(let z of[...j,...be.keys()]){if(T.has(z)&&!be.has(z))continue;let ne=n(z).hash;if(X.has(ne)||X.set(ne,[]),X.get(ne).push(z),ae(z))continue;let Te=n(z).sig;pe.has(Te)||pe.set(Te,[]),pe.get(Te).push(z)}let te=new Set;for(let z of M){let ne=S.get(z);!x(z)||!x(ne)||ae(z)||n(z).hint===""||n(ne).hint===""||i(z,ne)||te.add(z)}for(let z of[...V,...te]){let ne=S.get(z);if(ne?!(M.has(z)&&te.has(z)):qe(z))continue;let Te=Je=>{ne&&yt(z),ee(Je)},Ce=X.get(n(z).hash);if(Ce){let Je=Ce.find(Ze=>Ze!==ne&&he(Ze,z)&&!Y(z,Ze)&&Xe(z,Ze)&&d(z,Ze)&&rn(z,Ze));if(Je){Te(Je),Gt(z,Je),xe(z,Je),N.add(z);continue}}if(ae(z)||k<=0)continue;let Pe=pe.get(n(z).sig);if(!Pe)continue;let ve=null,_e=0;for(let Je of Pe)if(!(Je===ne||!he(Je,z)||!je(z,Je)||!Xe(z,Je)||Y(z,Je))&&(k--<=0||i(z,Je)&&(_e++,ve=Je,_e>1)))break;_e>1&&B&&B.add(z),_e===1&&(Te(ve),q(z,ve),xe(z,ve),N.add(z),y.push([z,ve]))}}}function io(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 mi={diff:0},Ks=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,gi=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,bi=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,wi=/\P{M}\p{M}*/gu;function yi(e){if(e==="")return[];if(Ks){let t=[];for(let n of Ks.segment(e))t.push(n.segment);return t}let o=[];for(let t of e.match(bi))if(gi.test(t))for(let n of t.match(wi))o.push(n);else o.push(t);return o}var ki=/^[  ]+$/,xi=e=>ki.test(e)?" ".repeat(e.length):e,$n=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),kt="",cs=e=>e.every(o=>$n(o)||o.k===kt),Ti=/^[\x00-\x7f\u00A0]*$/,vi=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Si(e){return e===""?[]:e.match(vi)}function an(e,o=!1){return(o?Si(e):yi(e)).map(t=>({k:xi(t),raw:t,len:t.length}))}var xn=(...e)=>e.every(o=>Ti.test(o));function fs(e,o,t){let n=e.length,s=o.length,h=Math.min(n+s,t),i=h+1,r=new Int32Array(2*h+3),a=[],d=n===0&&s===0;for(let m=0;m<=h&&!d;m++){a.push(r.slice(i-m,i+m+1));for(let v=-m;v<=m;v+=2){let I;v===-m||v!==m&&r[i+v-1]<r[i+v+1]?I=r[i+v+1]:I=r[i+v-1]+1;let g=I-v,f=I;for(;I<n&&g<s&&e[I].k===o[g].k;)I++,g++;if(mi.diff+=1+I-f,r[i+v]=I,I>=n&&g>=s){d=!0;break}}}if(!d)return null;let w=[],c=n,p=s;for(let m=a.length-1;m>0;m--){let v=a[m],I=c-p,g=I+m,f=I===-m||I!==m&&v[g-1]<v[g+1]?I+1:I-1,b=v[f+m],B=b-f;for(;c>b&&p>B;)w.push([0,c-1,p-1]),c--,p--;c===b?(w.push([1,c,p-1]),p--):(w.push([-1,c-1,p]),c--)}for(;c>0&&p>0;)w.push([0,c-1,p-1]),c--,p--;return w.reverse(),w}function Ni(e,o,t){let n=c=>c.k===kt;if(!e.some(n)&&!o.some(n))return fs(e,o,t);let s=[],h=[];for(let c=0;c<e.length;c++)n(e[c])||s.push(c);for(let c=0;c<o.length;c++)n(o[c])||h.push(c);let i=fs(s.map(c=>e[c]),h.map(c=>o[c]),t);if(!i)return null;let r=[],a=0,d=0,w=(c,p)=>{for(;a<c&&d<p&&e[a].k===o[d].k;)r.push([0,a++,d++]);let m=fs(e.slice(a,c),o.slice(d,p),t);if(!m)return!1;for(let[v,I,g]of m)r.push([v,I+a,g+d]);return a=c,d=p,!0};for(let[c,p,m]of i)if(c===0){if(!w(s[p],h[m]))return null;r.push([0,a,d]),a++,d++}return w(e.length,o.length)?r:null}function Wn(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 h=0;for(;h<e.length-s&&h<o.length-s&&e[e.length-1-h].k===o[o.length-1-h].k;)e[e.length-1-h].raw!==o[o.length-1-h].raw&&n.push({bi:e.length-1-h,tok:o[o.length-1-h]}),h++;let i=e.slice(s,e.length-h),r=o.slice(s,o.length-h),a=Li(i,r)?null:Ni(i,r,t);if(!a){let f=i.length||r.length?[{bs:s,be:s+i.length,toks:r}]:[];return{hunks:f,cosmetic:n,coarse:!0,parts:f.map(b=>({...b,gap:[],group:0})),cosmeticEq:n}}let d=[],w=(f,b)=>{i[f].raw!==r[b].raw&&n.push({bi:s+f,tok:r[b]})},c=null,p=[],m=0,v=0,I=()=>{c&&d.push(c),c=null;for(let[f,b]of p)w(f,b);p=[],m++};for(let[f,b,B]of a){if(f===0){c&&$n(i[b])&&!i[b].k.includes(`
2
+ `)?p.push([b,B]):(I(),w(b,B)),v=b+1;continue}(!c||p.length)&&(c&&d.push(c),c={bs:s+v,be:s+v,toks:[],gap:p.map(([S,T])=>({bi:s+S,tok:r[T]})),group:m},p=[]),f===-1?(c.be=s+v+1,v=b+1):c.toks.push(r[B])}I(),Ai(d,e);let g=ds(d);return{hunks:g.hunks,cosmetic:n.concat(g.cosmetic),parts:d,cosmeticEq:n}}function Ai(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===kt&&o[n.bs].k===kt;)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===kt&&o[n.be].k===kt;)n.bs++,n.be++}}function ds(e,o=()=>!1){let t=[],n=[],s=null,h=-1;for(let i of e){let r=o(i);if(s&&!s.alone&&!r&&i.group===h){s.be=i.be;for(let a of i.gap)s.toks.push(a.tok);for(let a of i.toks)s.toks.push(a);continue}s&&t.push({bs:s.bs,be:s.be,toks:s.toks});for(let a of i.gap)n.push(a);s={bs:i.bs,be:i.be,toks:i.toks.slice(),alone:r},h=i.group}return s&&t.push({bs:s.bs,be:s.be,toks:s.toks}),{hunks:t,cosmetic:n}}var Mi=(e,o)=>e.bs===o.bs&&e.be===o.be&&ms(e.toks,o.toks);function ps(e,o,t){let n=w=>c=>w.some(p=>Mi(c,p)),s=ds(e.parts,n(o.parts)),h=ds(o.parts,n(e.parts)),i=e.cosmeticEq.concat(s.cosmetic),r=o.cosmeticEq.concat(h.cosmetic),[a,d]=t?Oi(s.hunks,h.hunks,t,i,r):[s.hunks,h.hunks];return{lh:a,rh:d,cosL:i,cosR:r}}function Oi(e,o,t,n,s){let h=(v,I)=>v.k===I.k&&v.raw===I.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,a=(v,I,g,f)=>{let b=v.list[I];if(!r(b))return f(b)===g?b.toks:null;let B=I?v.list[I-1].be:0,S=I+1<v.list.length?v.list[I+1].bs:t.length;if(g<B||g>S)return null;let T=b.toks,M=b.bs;for(;M>g;){let L=T[T.length-1];if(!h(L,t[M-1])||v.resp.has(M-1))return null;T=[L,...T.slice(0,-1)],M--}for(;M<g;){if(!h(T[0],t[M])||v.resp.has(M))return null;T=[...T.slice(1),T[0]],M++}return T},d=(v,I,g,f,b,B)=>{let S=v.list[I],T=b?g.slice(g.length-f):g.slice(0,f),M=b?g.slice(0,g.length-f):g.slice(f),L={bs:B,be:B,toks:T};if(r(S)){if(!M.length){v.list[I]=L;return}let A={bs:B,be:B,toks:M};b&&(A.lead=!0),v.list.splice(I,1,...b?[A,L]:[L,A]);return}let N={bs:S.bs,be:S.be,toks:M};v.list.splice(I,1,...b?[N,L]:[L,N])},w=(v,I,g,f,b)=>{let B=v.list[I],S=b?g.slice(g.length-f):g.slice(0,f),T=b?g.slice(0,g.length-f):g.slice(f),M={bs:B.bs,be:B.be,toks:S};if(!T.length){v.list[I]=M;return}let L=b?{bs:B.bs,be:B.bs,toks:T,lead:!0}:{bs:B.be,be:B.be,toks:T};v.list.splice(I,1,...b?[L,M]:[M,L])},c=(v,I,g,f)=>{let b=v.list[I],B=g.list[f],S=b.be,T=B.bs;if(S>=T||I+1<v.list.length&&v.list[I+1].bs<=B.be||f>0&&g.list[f-1].be>=b.bs)return!1;for(let H=S;H<T;H++)if(!$n(t[H])||t[H].k.includes(`
3
+ `))return!1;let M=H=>t.slice(S,T).map((q,Me)=>H.raw.get(S+Me)||q),L=[...b.toks,...M(v)],N=[...M(g),...B.toks],A=(H,q,Me)=>q>=0&&q+Me.length<=H.length&&Me.every((Oe,Re)=>H[q+Re].k===Oe.k),E=(H,q,Me)=>cs(H)&&t.slice(q,Me).some(Oe=>!$n(Oe)),V=H=>H.some(q=>!$n(q)),j,D,y,k;if(r(b)&&V(b.toks)&&A(N,0,b.toks)){let H=N.slice(b.toks.length);E(H,S,B.be)||(j=S,D=b.toks,y=N.slice(0,b.toks.length),k=[null,{bs:S,be:B.be,toks:H}])}if(j===void 0&&r(B)&&V(B.toks)){let H=L.length-B.toks.length,q=L.slice(0,H);A(L,H,B.toks)&&!E(q,b.bs,T)&&(j=T,D=L.slice(H),y=B.toks,k=[{bs:b.bs,be:T,toks:q},null])}if(j===void 0)return!1;let J=H=>H&&(H.bs<H.be||H.toks.length);return v.list.splice(I,1,...[k[0],{bs:j,be:j,toks:D}].filter(J)),g.list.splice(f,1,...[{bs:j,be:j,toks:y},k[1]].filter(J)),!0},p=i[0],m=i[1];for(let v=0;v<64;v++){let I=!1;e:for(let g=0;g<p.list.length;g++)for(let f=0;f<m.list.length;f++){let b=p.list[g],B=m.list[f];if(!(b.bs===B.bs&&b.be===B.be&&ms(b.toks,B.toks))){for(let S of[!0,!1]){let T=L=>S?L.be:L.bs,M=r(b)?[T(B),b.bs]:[T(b)];for(let L of M){let N=a(p,g,L,T),A=N&&a(m,f,L,T);if(!A)continue;let E=(k,J)=>S?k[k.length-1-J]:k[J],V=0;for(;V<N.length&&V<A.length&&E(N,V).k===E(A,V).k;)V++;if(!V)continue;let j=S?N.slice(0,N.length-V):N.slice(V),D=S?A.slice(0,A.length-V):A.slice(V);if(!(V<N.length&&V<A.length&&!cs(j)&&!cs(D)&&(r(b)&&r(B)||b.bs===B.bs&&b.be===B.be)||!(S?N.slice(N.length-V):N.slice(0,V)).some(k=>!$n(k)))){if(V===N.length&&V===A.length&&r(b)&&r(B)){if(b.bs===L&&B.bs===L)continue;p.list[g]={bs:L,be:L,toks:N},m.list[f]={bs:L,be:L,toks:A}}else!r(b)&&b.bs===B.bs&&b.be===B.be?(w(p,g,N,V,S),w(m,f,A,V,S)):(d(p,g,N,V,S,L),d(m,f,A,V,S,L));I=!0;break e}}}if(c(p,g,m,f)||c(m,f,p,g)){I=!0;break e}}}if(!I)break}return[p.list,m.list]}var Ii=48,Ci=.3;function Li(e,o){let t=e.filter(i=>!$n(i)),n=o.filter(i=>!$n(i));if(Math.min(t.length,n.length)<Ii)return!1;let s=new Map;for(let i of t)s.set(i.k,(s.get(i.k)||0)+1);let h=0;for(let i of n){let r=s.get(i.k);r>0&&(h++,s.set(i.k,r-1))}return h/Math.min(t.length,n.length)<Ci}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 Fs(e,o,t,n="remote"){let s=Wn(e,o),h=Wn(e,t),{lh:i,rh:r,cosL:a,cosR:d}=ps(s,h,e),w=x=>x.bs===x.be,c=x=>x.toks.some(Y=>typeof Y.k=="string"),p=x=>w(x)&&!c(x),m=(x,Y)=>Y.bs<x.be&&x.bs<Y.be,v=(x,Y)=>!m(x,Y)&&Y.bs<=x.be&&x.bs<=Y.be&&(w(x)&&c(x)||w(Y)&&c(Y))&&!(w(x)&&w(Y)),I=(x,Y)=>x.bs===Y.bs&&x.be===Y.be&&ms(x.toks,Y.toks),g=[],f=new Set;for(let x of i){let Y=r.find(ae=>!f.has(ae)&&I(x,ae));Y?(f.add(Y),g.push({bs:x.bs,be:x.be,side:"both",l:x,r:Y,toks:x.toks})):g.push({bs:x.bs,be:x.be,side:"L",l:x,toks:x.toks,lead:!!x.lead})}for(let x of r)f.has(x)||g.push({bs:x.bs,be:x.be,side:"R",r:x,toks:x.toks,lead:!!x.lead});g.sort((x,Y)=>x.bs-Y.bs||x.be-Y.be||Y.lead-x.lead);let b=0,B=0;for(let x of g)x.side==="both"&&(b+=x.toks.length-(x.be-x.bs));let S=g.map((x,Y)=>Y),T=x=>S[x]===x?x:S[x]=T(S[x]),M=(x,Y)=>(x=T(x),Y=T(Y),x===Y?!1:(S[x]=Y,!0)),L=g.map(x=>Ei({bs:x.bs,be:x.be,toks:x.toks},e)),N={L:new Map,R:new Map};g.forEach((x,Y)=>{let ae=x.side==="both"?["L","R"]:[x.side];for(let oe of ae)for(let Ee of L[Y])N[oe].has(Ee)||N[oe].set(Ee,[]),N[oe].get(Ee).push(Y)});for(let x of[N.L,N.R])for(let Y of x.values())for(let ae=1;ae<Y.length;ae++)M(Y[0],Y[ae]);for(let x=0;x<g.length;x++)for(let Y=x+1;Y<g.length;Y++){let ae=g[x],oe=g[Y];ae.side===oe.side&&ae.side!=="both"||ae.bs>oe.be||(m(ae,oe)||v(ae,oe)?M(x,Y):ae.bs===oe.bs&&w(ae)&&w(oe)&&B++)}let A=(x,Y)=>{let ae=x==="L"?i:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="close"&&Ee.k.el===Y.el))return oe.bs;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return-1};g.forEach((x,Y)=>{if(!(!p(x)||x.side==="both"))for(let ae of x.toks){if(ae.kind!=="open")continue;let oe=A(x.side,ae.k);if(oe<=x.bs)continue;let Ee=new Uint8Array(oe-x.bs),je=[];if(g.forEach((Ne,tt)=>{if(!(Ne.side===x.side||w(Ne))&&Ne.bs<oe&&Ne.be>x.bs){je.push(tt);for(let Xe=Math.max(Ne.bs,x.bs);Xe<Math.min(Ne.be,oe);Xe++)Ee[Xe-x.bs]=1}}),je.length&&Ee.every(Ne=>Ne===1))for(let Ne of je)M(Y,Ne)}});let E=!0;for(;E;){E=!1;let x=new Map;g.forEach((Y,ae)=>{let oe=T(ae),Ee=x.get(oe)||{bs:Y.bs,be:Y.be,L:!1,R:!1};Ee.bs=Math.min(Ee.bs,Y.bs),Ee.be=Math.max(Ee.be,Y.be),Y.side!=="R"&&(Ee.L=!0),Y.side!=="L"&&(Ee.R=!0),x.set(oe,Ee)}),g.forEach((Y,ae)=>{for(let[oe,Ee]of x){if(T(ae)===T(oe)||!(Ee.L&&Ee.R))continue;let je=Y.bs<Ee.be&&Y.be>Ee.bs,Ne=w(Y)&&c(Y)&&(Y.bs===Ee.be||Y.bs===Ee.bs);(je||Ne)&&M(ae,oe)&&(E=!0)}})}let V=new Map;g.forEach((x,Y)=>{let ae=T(Y);V.has(ae)||V.set(ae,[]),V.get(ae).push(x)});let j=[];for(let x of V.values()){let Y=x.some(oe=>oe.side==="L"),ae=x.some(oe=>oe.side==="R");if(Y&&ae){let oe=Math.min(...x.map(tt=>tt.bs)),Ee=Math.max(...x.map(tt=>tt.be)),je=x.filter(tt=>tt.side!=="R").map(tt=>tt.l).sort((tt,Xe)=>tt.bs-Xe.bs),Ne=x.filter(tt=>tt.side!=="L").map(tt=>tt.r).sort((tt,Xe)=>tt.bs-Xe.bs);j.push({bs:oe,be:Ee,kind:"conflict",localHunks:je,remoteHunks:Ne})}else for(let oe of x)j.push({bs:oe.bs,be:oe.be,kind:oe.side,u:oe})}let D=(x,Y)=>{let ae=x==="L"?i:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="close"&&Ee.k.el===Y.el))return oe.bs+.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return 1/0},y=(x,Y)=>{let ae=x==="L"?i:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="open"&&Ee.k.el===Y.el))return oe.bs-.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="open"&&e[oe].k.el===Y.el)return oe;return-1/0},k=x=>x.kind==="R"?"R":"L",J=x=>x.kind==="R"?1:0;j.sort((x,Y)=>{if(x.bs!==Y.bs)return x.bs-Y.bs;let ae=x.bs===x.be,oe=Y.bs===Y.be;if(ae!==oe)return ae?-1:1;if(ae&&oe&&x.kind!=="conflict"&&Y.kind!=="conflict"){let je=x.u.toks,Ne=Y.u.toks,tt=dt=>dt.length&&dt.every(Ge=>Ge.kind==="open"),Xe=dt=>dt.length&&dt.every(Ge=>Ge.kind==="close");if(tt(je)&&tt(Ne)){let dt=Math.max(...je.map(st=>D(k(x),st.k))),Ge=Math.max(...Ne.map(st=>D(k(Y),st.k)));if(dt!==Ge)return Ge-dt}if(Xe(je)&&Xe(Ne)){let dt=Math.min(...je.map(st=>y(k(x),st.k))),Ge=Math.min(...Ne.map(st=>y(k(Y),st.k)));return dt!==Ge?Ge-dt:J(Y)-J(x)}}let Ee=je=>je.u&&je.u.lead?1:0;return Ee(Y)-Ee(x)||J(x)-J(Y)||x.be-Y.be});let H=[],q=[],Me=0,Oe=x=>{x>Me&&(H.push({bs:Me,be:x,toks:e.slice(Me,x),source:"base"}),Me=x)};for(let x of j){if(Oe(x.bs),x.kind==="conflict"){let Y=hs(e,x.localHunks,x.bs,x.be),ae=hs(e,x.remoteHunks,x.bs,x.be),oe=n==="local"?Y:n==="both"?Y.concat(ae):ae,Ee=(tt,Xe)=>{let dt=0;for(let Ge of tt)Ge.be<=x.bs&&!Xe.includes(Ge)&&(dt+=Ge.toks.length-(Ge.be-Ge.bs));return dt},je=x.bs+Ee(i,x.localHunks),Ne=x.bs+Ee(r,x.remoteHunks);q.push({bs:x.bs,be:x.be,ls:je,le:je+Y.length,rs:Ne,re:Ne+ae.length,ms:0,me:0,base:e.slice(x.bs,x.be),local:Y,remote:ae,resolved:oe}),H.push({bs:x.bs,be:x.be,toks:oe,source:"conflict",localHunks:x.localHunks,localToks:Y,keepsLocal:n!=="remote"})}else H.push({bs:x.bs,be:x.be,toks:x.u.toks,source:x.kind==="R"?"remote":"local",localHunks:x.kind==="R"?[]:[x.u.l]});Me=Math.max(Me,x.be)}Oe(e.length);let Re=0,ie=0;for(let x of H)x.source==="conflict"&&(q[ie].ms=Re,q[ie].me=Re+x.toks.length,ie++),Re+=x.toks.length;let xe=new Map(a.map(x=>[x.bi,x.tok])),qe=new Map(d.map(x=>[x.bi,x.tok])),fe=[];for(let x of H){x.source==="base"&&(x.toks=x.toks.map((Y,ae)=>{let oe=x.bs+ae,Ee=xe.get(oe),je=qe.get(oe),Ne=Ee&&je?n==="remote"?je:Ee:Ee||je||Y;return Ne===Y?Y:{...Ne,cosmetic:!0}}));for(let Y of x.toks)fe.push({...Y,src:x.source})}return{tokens:fe,segments:H,conflicts:q,localHunks:i,remoteHunks:r,collapsedDelta:b,samePoint:B,mapLocalOffset:Ri(e,i,H)}}function hs(e,o,t,n){let s=[],h=t;for(let i of o)s=s.concat(e.slice(h,i.bs),i.toks),h=i.be;return s.concat(e.slice(h,n))}var us=e=>e.reduce((o,t)=>o+t.len,0);function Ri(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})),h=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,a=null,d=0,w=0,c=0;for(let m of s){let v=m.bs-c;if(i<=w+v){r=c+(i-w);break}if(w+=v,c=m.bs,i<=w+m.text.length){a=m,d=i-w,r=m.bs;break}w+=m.text.length,c=m.be}r===null&&(r=c+(i-w));let p=0;for(let m of h){if(!a&&r<=m.bs)return p;if(!(a?m.localHunks.includes(a.ref):r<m.be)){p+=m.len;continue}if(m.source==="base")return p+(r-m.bs);if(m.source==="remote")return p+m.len;if(m.source==="local")return p+Math.min(d,m.len);if(!m.keepsLocal||!a)return p+m.len;let I=m.localHunks.indexOf(a.ref),g=us(hs(e,m.localHunks.slice(0,I),m.ref.bs,a.ref.bs));return p+Math.min(g+d,m.localLen)}return p}}function lo(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:f=>Math.min(f,o.length),granularity:"word"};let s=xn(e,o,t),h=an(e,s),i=an(o,s),r=an(t,s),a=h.length<=2e4&&i.length<=2e4&&r.length<=2e4?Fs(h,i,r,n):null,d="word",w=h;if(!a){let f=b=>b.split(/(?<=\n)/).map(B=>({k:B,raw:B,len:B.length}));w=f(e),a=Fs(w,f(o),f(t),n),d="line"}let c=f=>f.map(b=>b.raw).join(""),p=f=>{let b=[0];for(let B of f)b.push(b[b.length-1]+B.len);return b},m=p(w),v=null,I=null,g=null;if(a.conflicts.length){let f=b=>b.split(/(?<=\n)/).map(B=>({k:B,raw:B,len:B.length}));v=p(d==="line"?f(o):i),I=p(d==="line"?f(t):r),g=p(a.tokens)}return{text:c(a.tokens),conflicts:a.conflicts.map(f=>({bs:m[f.bs],be:m[f.be],ls:v[f.ls],le:v[f.le],rs:I[f.rs],re:I[f.re],ms:g[f.ms],me:g[f.me],base:c(f.base),local:c(f.local),remote:c(f.remote),resolved:c(f.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:d}}function Gn(e,o,t=4e3){if(e===o)return[];let n=xn(e,o),s=an(e,n),h=an(o,n),i=Wn(s,h,t),r=[0];for(let a of s)r.push(r[r.length-1]+a.len);return i.hunks.map(a=>({bs:r[a.bs],be:r[a.be],text:a.toks.map(d=>d.raw).join("")}))}function zt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function jn({base:e,side:o,retained:t,transfers:n,baseAtomKey:s=r=>r.el,sideAtomKey:h=r=>r.el,budget:i=zt()}){let r=[],a=T=>({status:"fallback",reason:T}),d=T=>T>i.remaining?!1:(i.remaining-=T,!0);if(!d((t.length+n.length)*3))return a("work-limit");for(let[T,M]of[["retained",t],["transfer",n]])for(let L of M){let{from:N,to:A,target:E}=L;if(!Number.isInteger(N)||!Number.isInteger(A)||!Number.isInteger(E)||N<0||A<=N||A>e.text.length||E<0||E+A-N>o.text.length)return a("invalid-range");r.push({...L,kind:T})}let w=Symbol(),c=T=>(M,L)=>{if(!d(1))throw w;return i.sortComparisons++,T(M,L)},p,m;try{p=r.slice().sort(c((T,M)=>T.from-M.from||T.to-M.to)),m=r.slice().sort(c((T,M)=>T.target-M.target||T.to-T.from-(M.to-M.from)))}catch(T){if(T===w)return a("work-limit");throw T}if(!d(r.length*2))return a("work-limit");for(let T=1;T<p.length;T++)if(p[T].from<p[T-1].to)return a("source-overlap");for(let T=1;T<m.length;T++)if(m[T].target<m[T-1].target+m[T-1].to-m[T-1].from)return a("target-overlap");for(let T of p){let M=T.to-T.from;if(!d(M))return a("work-limit");for(let L=0;L<M;L++){let N=T.from+L,A=T.target+L;if(i.comparisons++,e.text[N]!==o.text[A])return a("unequal-occurrence");let E=e.atomAt.get(N),V=o.atomAt.get(A);if(!!E!=!!V||E&&s(E)!==h(V))return a("different-atom")}}let v=e.text.length+o.text.length+2,I=r.reduce((T,M)=>T+(M.to-M.from)*2,2);if(!d(v+I+r.length))return a("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),f=new Int32Array(o.text.length+1).fill(-1);i.mapCells+=v,i.mapWrites+=I;let b=-1,B=!0;for(let T of p){T.target<b&&(B=!1),b=T.target+T.to-T.from;for(let M=0;M<T.to-T.from;M++)g[T.from+M]=T.target+M,f[T.target+M]=T.from+M}return g[e.text.length]=o.text.length,f[o.text.length]=e.text.length,{status:"ready",runs:p,bTo:g,toB:f,monotone:B,covers:(T,M)=>{if(!d(M-T))return null;i.coverageChecks+=M-T;for(let L=T;L<M;L++)if(e.text[L]!==kt&&!/\s/.test(e.text[L])&&g[L]<0)return!1;return!0}}}function gs({base:e,side:o,baseOf:t=()=>null,budget:n=zt()}){if(e.text===o.text||!e.text.includes(kt)&&!o.text.includes(kt))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 h=(v,I)=>I<v.length&&(v[I]===kt||/\s/.test(v[I])),i=new Map,r=Symbol(),a=(v,I)=>{let g=v.stackAt[I]||[];if(!i.has(g)){if(g.length>n.remaining)throw r;n.remaining-=g.length,n.boundarySteps+=g.length,i.set(g,g.find(f=>f.block)?.el||null)}return i.get(g)},d=[],w=(v,I)=>{let g=a(e,v),f=a(o,I),b=g&&f&&t(f)!==g?"transfer":"retained",B=d[d.length-1];B&&B.to===v&&B.target+B.to-B.from===I&&B.kind===b&&B.destination===f?B.to++:d.push({from:v,to:v+1,target:I,destination:f,kind:b})},c=0,p=0,m=!1;try{for(;c<e.text.length||p<o.text.length;){if(c<e.text.length&&p<o.text.length&&e.text[c]===o.text[p]){let B=e.atomAt.get(c),S=o.atomAt.get(p);if(!!B!=!!S||B&&t(S.el)!==B.el)return{status:"none"};w(c++,p++);continue}if(!h(e.text,c)&&!h(o.text,p))return{status:"none"};let v=c,I=p;for(;h(e.text,c);)c++;for(;h(o.text,p);)p++;let g=e.text.slice(v,c),f=o.text.slice(I,p);(g.includes(kt)||f.includes(kt))&&(m=!0);let b=0;for(;b<c-v&&b<p-I&&e.text[c-b-1]===o.text[p-b-1];)b++;for(let B=b;B>0;B--)w(c-B,p-B)}}catch(v){if(v===r)return{status:"fallback",reason:"work-limit"};throw v}return m?jn({base:e,side:o,retained:d.filter(v=>v.kind==="retained"),transfers:d.filter(v=>v.kind==="transfer"),sideAtomKey:v=>t(v.el)||v.el,budget:n}):{status:"none"}}var _s=/\s/,Vo=/\S/;function In(e,o,t,n,s,h,i=-1,r=-1){if(!e.length)return-1;s(n,e.length);let a=new Int32Array(e.length),d=0;for(let m=1;m<e.length;m++){for(s(n,1);d&&(s(n,1),e[d]!==e[m]);)d=a[d-1];s(n,1),e[d]===e[m]&&d++,a[m]=d}let w=-1,c=0,p=0;d=0;for(let m=0;m<o.length;m++){for(s(n,1);d&&(s(n,1),e[d]!==o[m]);)d=a[d-1];if(s(n,1),e[d]===o[m]&&d++,d!==e.length)continue;let v=m+1-e.length,I=m+1;for(d=a[d-1];c<t.length&&t[c].from<v;)s(n,1),c++;for(;p<t.length&&t[p].to<I;)s(n,1),p++;if(s(n,6),!(c===t.length||p===t.length||t[c].from!==v||t[p].to!==I||i>=0&&v<r&&I>i)){if(!h)return v;if(w>=0)return-1;w=v}}return w}function No(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 a=Math.max(e.from,r.from),d=Math.min(e.to,r.to);a>=d||(s||(n(t,e.to-e.from),s=new Uint8Array(e.to-e.from)),n(t,d-a),s.fill(1,a-e.from,d-e.from))}if(!s)return!1;n(t,e.to-e.from);let h=!1;for(let i=e.from;i<e.to;i++)if(Vo.test(e.flat.text[i])){if(!s[i-e.from])return!1;h=!0}return h}function ws({source:e,side:o,views:t,eligible:n,blocked:s,baseId:h,model:i,tokensOf:r,budget:a,charge:d}){let{V:w,A:c,idOf:p}=t[o],m=t[1-o];if(e.nodeType!==1||c.identical.has(e)||m.A.identical.has(e)||s.has(e)||!n(e))return null;let v=w.twin(e),I=m.V.twin(e);if(!v||!I||c.map.get(e)!==v||c.reverse.get(v)!==e||m.A.map.get(e)!==I||m.A.reverse.get(I)!==e||!w.here(v)||!m.V.here(I)||!n(v)||!n(I))return null;let g=h(e);if(g!==p(v)||g!==m.idOf(I))return null;let f=i(e,null,a),b=i(v,c,a),B=i(I,m.A,a);if(!No(f)||!No(b)||!No(B))return null;let S=f.flat.text,T=b.flat.text;if(d(a,S.length+T.length*3),!Vo.test(T)||T.length>=S.length)return null;let M=S.startsWith(T),L=S.endsWith(T);if(M===L)return null;let N=M?T.length:0,A=M?S.length:S.length-T.length,E=N,V=A;for(;E<V&&(d(a,1),!!_s.test(S[E]));)E++;for(;V>E&&(d(a,1),!!_s.test(S[V-1]));)V--;if(E===V)return null;let j=r(f,a),D=!1,y=!1;for(let k of j)d(a,1),k.from===E&&(D=!0),k.to===V&&(y=!0);return!D||!y?null:{source:e,side:o,flat:f.flat,from:N,to:A}}function zs({base:e,views:o,side:t,attempt:n,eligible:s,blocked:h,baseId:i,model:r,tokensOf:a,certificates:d,charge:w,exhausted:c,limit:p}){if(p<=0)return null;let m=zt(p),{V:v,A:I,idOf:g}=o[t],f=o[1-t],[b,B,S,T]=n,M=null;try{for(let L=b;L<=B;L++){w(m,1);let N=e[L];if(N.nodeType!==1||I.identical.has(N)||f.A.identical.has(N)||h.has(N)||!s(N))continue;let A=ws({source:N,side:t,views:o,eligible:s,blocked:h,baseId:i,model:r,tokensOf:a,budget:m,charge:w});if(!A||bs(A,d,m,w))continue;let{flat:E,from:V,to:j}=A;w(m,(j-V)*2);let D=E.text.slice(V,j).trim();for(let y=S;y<=T;y++){w(m,1);let k=v.units[y],J=v.baseOf(k);if(!J||J===N||J.nodeType!==1||k.nodeType!==1||J.parentNode!==N.parentNode||k.parentNode!==I.map.get(N).parentNode||I.map.get(J)!==k||I.reverse.get(k)!==J||h.has(J)||!s(J)||!s(k)||i(J)!==g(k))continue;let H=r(J,null,m),q=r(k,I,m);if(!No(H)||!No(q))continue;let Me=H.flat.text,Oe=q.flat.text;if(w(m,Me.length),!Vo.test(Me)||Oe.length<=Me.length)continue;let Re=a(q,m),ie=In(Me,Oe,Re,m,w,!0);if(!(ie<0)&&!(In(D,Oe,Re,m,w,!1,ie,ie+Me.length)<0)){(M||=[]).push(A);break}}}}catch(L){if(L!==c)throw L}return M}function $s(e,o,t,n,s,h,i){if(h==="both"||t.atoms.length||n.atoms.length||s.atoms.length)return h;let r=h==="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 h;for(let a of e){if(a.source!==o||a.side!==(r?1:0)||a.flat.text!==t.text||a.flat.nodes.length!==t.nodes.length||i.be<=a.from||i.bs>=a.to)continue;let d=!0;for(let c=0;c<t.nodes.length;c++){let p=a.flat.nodes[c],m=t.nodes[c];if(p.node!==m.node||p.s!==m.s||p.e!==m.e){d=!1;break}}if(!d)continue;let w=!1;for(let c=i.bs;c<i.be;c++)if(Vo.test(t.text[c])){if(c<a.from||c>=a.to){d=!1;break}w=!0}if(d&&w)return r?"local":"remote"}return h}var Un="\uFFFC";var Pi={caret:0},Tn=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 Vn(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(!Tn.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(!Vn(s,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Bi(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=(s,h)=>{for(let i of s){if(i.nodeType===3){let c=i.nodeValue;if(!c)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+c.length}),t.text+=c;for(let p=0;p<c.length;p++)t.stackAt.push(h);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 a=i.tagName;if(o.blocks&&o.blocks.has(i)){t.text.length&&t.text[t.text.length-1]!==kt&&(t.stackAt.push(h),t.text+=kt);let c={el:i,tag:a,from:t.text.length,to:-1,depth:h.length,block:!0};t.marks.push(c);let p=h.concat([c]);n(r.childNodes,p),t.stackAt.push(p),t.text+=kt,c.to=t.text.length;continue}let d=Tn.has(a)&&Bi(r);if(tr.has(a)||!Tn.has(a)||o.remoteWins&&o.remoteWins(i)||o.atomize&&o.atomize(i)||d){t.atoms.push({i:t.text.length,el:i,key:d?a+":empty":a,stack:h}),t.stackAt.push(h),t.text+=Un;continue}let w={el:i,tag:a,from:t.text.length,to:-1,depth:h.length};t.marks.push(w),n(r.childNodes,h.concat([w])),w.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&qo(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 h of t.nodes)h.s>s.i&&(h.s--,h.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(s=>[s.i,s])),t}function Di(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function ji(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,"&quot;")}"`;return o+">"}function co(e,o,t){let n="",s=[];for(let h=o;h<t;h++){let i=e.stackAt[h],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 d=i[s.length];n+=ji(d.el),s.push(d)}let a=e.atomAt.get(h);n+=a?a.el.outerHTML:e.text[h]===kt?"":Di(e.text[h])}for(;s.length;)n+=`</${s.pop().tag.toLowerCase()}>`;return n}function Ui(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=h=>{let i=t.get(h);return i===void 0&&(i="{"+h.map(r=>Ui(r,o)).sort().join(",")+"}",t.set(h,i)),i},s="";for(let h=0;h<e.text.length;h++){let i=e.atomAt.get(h);s+=(i?"["+nr(i.el,o)+"]":e.text[h])+n(e.stackAt[h])}return e.text.length===0&&e.placeholder&&(s+="[br]"),s}function ao(e,o,t,n=s=>s.key){let s=[],h=e.text,i=0,r=a=>{if(a<=i)return;let d=h.slice(i,a);if(t)for(let w of d.split(/(?<=\n)/))s.push({k:w,raw:w,len:w.length});else for(let w of an(d,o))s.push(w)};for(let a of e.atoms)r(a.i),s.push({k:"\0"+n(a),raw:Un,len:1,atom:!0}),i=a.i+1;return r(h.length),s}function qo(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 fo=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=fo(o),h=fo(t),i=[],r=0,a=0;for(let w of n.hunks){a+=w.bs-r;let c=a+w.toks.length;i.push({bs:s[w.bs],be:s[w.be],ss:h[a],se:h[c],text:e.text.slice(h[a],h[c]),toks:w.toks,lead:!!w.lead}),a=c,r=w.be}let d=new Map;for(let w of n.cosmetic)d.set(w.bi,w.tok.raw);return{hunks:i,respell:d}}function Ys(e,o,t){let n=i=>i===kt||/\s/.test(i),s=i=>i.replace(/[\u001E\s]/g,""),h=[];for(let i of e){let r=o.slice(i.bs,i.be),a=t.slice(i.ss,i.se);if(!r.includes(kt)&&!a.includes(kt)||r.includes(Un)||a.includes(Un)||s(r)!==s(a)){h.push(i);continue}let d=0,w=0;for(;;){let c=d,p=w;for(;c<r.length&&n(r[c]);)c++;for(;p<a.length&&n(a[p]);)p++;let m=d,v=w;for(;m<c&&v<p&&r[m]===a[v];)m++,v++;let I=c,g=p;for(;I>m&&g>v&&r[I-1]===a[g-1];)I--,g--;if(I>m||g>v){let f=a.slice(v,g);h.push({bs:i.bs+m,be:i.bs+I,ss:i.ss+v,se:i.ss+g,text:f,toks:[...f].map(b=>({k:b,raw:b,len:1})),lead:i.lead})}if(c>=r.length)break;d=c+1,w=p+1}}return h}function Xs(e,o,t){let n=new Int32Array(o+1).fill(-1),s=new Int32Array(t+1).fill(-1),h=0,i=0,r=a=>{for(;h<a;)n[h]=i,s[i]=h,h++,i++};for(let a of e)r(a.bs),h=a.be,i=a.se;return r(o),n[o]=i,s[i]=o,{bTo:n,toB:s}}function Js(e,o,t){let n=[],s=0,h=0,i=(r,a)=>{if(s===r&&h===a)return;let d=o.text.slice(h,a);n.push({bs:s,be:r,ss:h,se:a,text:d,toks:an(d,xn(d)),lead:!1})};for(let r of t.runs)i(r.from,r.target),s=r.to,h=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=fo(o),h=fo(t),i=(a,d)=>{let w=0,c=a.length;for(;w<c;){let p=w+c>>>1;a[p]<d?w=p+1:c=p}return a[w]===d?w:-1};for(let a of e.hunks)if(i(s,a.bs)<0||i(s,a.be)<0)return null;if(e.hunks.some(a=>i(h,a.ss)<0||i(h,a.se)<0)){if(!n)return null;let a=[];for(let p of e.hunks)a.push(p.ss,p.se);let d=[],w=0,c=0;for(let p of t){let m=c+p.len;for(;w<a.length&&a[w]<=c;)w++;let v=c;for(;w<a.length&&a[w]<m;){let I=a[w++];if(I>v){let g=p.raw.slice(v-c,I-c);d.push(...an(g,xn(g))),v=I}}if(v===c)d.push(p);else{let I=p.raw.slice(v-c);d.push(...an(I,xn(I)))}c=m}t=d,h=fo(t)}let r=[];for(let a of e.hunks){let d=i(s,a.bs),w=i(s,a.be),c=i(h,a.ss),p=i(h,a.se);if(d<0||w<0||c<0||p<0)return null;r.push({bs:d,be:w,toks:t.slice(c,p),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,h,i,r){let a=xn(qo(e),qo(o),qo(t)),d=ao(e,a,!1,n),w=ao(o,a,!1,s),c=ao(t,a,!1,h),p=d.length>2e4||w.length>2e4||c.length>2e4;p&&(d=ao(e,a,!0,n),w=ao(o,a,!0,s),c=ao(t,a,!0,h));let m=i?.local?Js(e,o,i.local):null,v=i?.remote?Js(e,t,i.remote):null,I=m?Qs(m,d,w,!p):Wn(d,w),g=v?Qs(v,d,c,!p):Wn(d,c);m&&I&&(w=I.tokens),v&&g&&(c=g.tokens);let f,b;if(I&&g){let B=ps(I,g,d);f=Ho(o,d,w,{hunks:B.lh,cosmetic:B.cosL}),b=Ho(t,d,c,{hunks:B.rh,cosmetic:B.cosR})}else f=m||Ho(o,d,w,I),b=v||Ho(t,d,c,g);return f.hunks=Ys(f.hunks,e.text,o.text),b.hunks=Ys(b.hunks,e.text,t.text),r.base=e,r.local=o,r.remote=t,r.lines=p,r.baseTokens=d,r.localEdits=f,r.remoteEdits=b,r.localMap=Xs(f.hunks,e.text.length,o.text.length),r.remoteMap=Xs(b.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 uo=/\s/;function Wo(e,o,t){for(let n=o;n<t;n++)if(!uo.test(e[n]))return!1;return!0}function Vi(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",h=t===0?"remote":"local",i=o.baseMark,r=o[h+"Mark"],a=!o.block&&!o[s]&&!!r&&i.to>i.from;if(a){let d=t===0?e.ML:e.MR,w=t===0?e.MR:e.ML,c=t===0?e.fr:e.fl,p=!1;for(let m=i.from;m<i.to;m++){if(d.bTo[m]>=0){a=!1;break}w.bTo[m]<0&&!uo.test(e.fb.text[m])&&(p=!0)}if(a&&!p){for(let m=r.from;m<r.to;m++)if(w.toB[m]<0&&!uo.test(c.text[m])){p=!0;break}}a&&=p}return n.set(o,a),a}function er(e,o,t,n,s,h,i,r,a){let d=r===0?e.fl:e.fr,w=null;for(let c=t;c<n;c++){let p=o[c];if(!Wo(d.text,p.ss,p.se))return null;if(Wo(e.fb.text,p.bs,p.be)){if(p.bs<p.be&&p.ss<p.se||uo.test(e.fb.text[p.bs-1]||"")||uo.test(e.fb.text[p.be]||""))continue;return null}let m=!1;for(let v=p.bs;v<p.be;v++){if(uo.test(e.fb.text[v]))continue;let I=null;for(let g of e.fb.stackAt[v]){let f=e.byEl.get(g.el);if(f&&Vi(e,f,r)){I=f;break}}if(!I)return null;(w||(w=new Set)).add(I),m=!0}if(!m)return null}if(!w){if((r===0?"local":"remote")!==a)return null;let c=r===0?e.fr:e.fl,p=!1;for(let m=h;m<i;m++){let v=s[m];if(!Wo(e.fb.text,v.bs,v.be))return null;Wo(c.text,v.ss,v.se)||(p=!0)}if(!p)return null}return w||0}function Ko(e){let{out:o,policy:t="remote",L:n,R:s}=e,h=e.provenance||new WeakMap,i=e.textMappers||new WeakMap,r=e.conflicts||[],a=e.decisions||[],d=r.length,w=e.conflict||(u=>r.push(u)),c={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},p=[],m=!!(n&&n.reverse&&n.map&&s&&s.reverse&&s.map),v={base:null,local:null,remote:null};if(!e.prepared&&m&&e.moveIn){let u=Se=>De=>Se.some(Le=>Le===De||Le.nodeType===1&&Le.contains(De)),P=u(e.local),F=u(e.remote),_=u(e.base),Q=new Set,me=Se=>{if(!Tn.has(Se.tagName))return;let De=n.map.get(Se),Le=s.map.get(Se);(De&&!P(De)||Le&&!F(Le))&&Q.add(Se);for(let Ue of Se.children)me(Ue)};for(let Se of e.base)Se.nodeType===1&&me(Se);let ke=Se=>De=>{if(!Tn.has(De.tagName))return!1;let Le=Se.reverse.get(De);return!!Le&&(Q.has(Le)||!_(Le))};Q.size&&(v.base=Se=>Q.has(Se)),v.local=ke(n),v.remote=ke(s)}let I={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&m&&e.moveIn){let u=_=>Q=>_.some(me=>me===Q||me.nodeType===1&&me.contains(Q)),P=u(e.local),F=u(e.remote);for(let _ of nn(e.base,{...e,atomize:v.base}).atoms){let Q=n.map.get(_.el),me=s.map.get(_.el),ke=!!Q&&!P(Q),Se=!!me&&!F(me);!ke&&!Se||(ke&&e.movePlanned?.(_.el,"local",Q,null),Se&&e.movePlanned?.(_.el,"remote",me,null),I.base.add(_.el),Q&&!ke&&I.local.add(Q),me&&!Se&&I.remote.add(me),P(_.el)&&I.local.add(_.el),F(_.el)&&I.remote.add(_.el))}}let g=e.prepared?.base||nn(e.base,{...e,atomize:v.base,skip:I.base}),f=e.prepared?.local||nn(e.local,{...e,atomize:v.local,skip:I.local}),b=e.prepared?.remote||nn(e.remote,{...e,atomize:v.remote,skip:I.remote}),B=new Map(g.atoms.map(u=>[u.el,u])),S={},T=u=>e.prepared?e.prepared.full?.(u)||null:I[u].size?(S[u]||(S[u]=nn(e[u],{...e,atomize:v[u]})),S[u]):null,M=(u,P,F)=>{P.namespaceURI?u.setAttributeNS(P.namespaceURI,P.name,F):u.setAttribute(P.name,F)},L=(u,P,F,_)=>{if(!P&&(!F||!_)){for(let me of(F||_).attributes)M(u,me,me.value);return}let Q=new Map;for(let me of[P,F,_])if(me)for(let ke of me.attributes)Q.set(ke.name,ke);for(let[me,ke]of Q){let Se=P?P.getAttribute(me):null,De=F?F.getAttribute(me):Se,Le=_?_.getAttribute(me):Se,Ue;De===Le?Ue=De:De===Se?(Ue=Le,a.push({kind:"attr",el:u,name:me,source:"remote"})):Le===Se?(Ue=De,a.push({kind:"attr",el:u,name:me,source:"local"})):(Ue=t==="local"?De:Le,w({kind:"attr",el:u,name:me,base:Se,local:De,remote:Le,resolved:Ue},{el:u,sample:ke}),a.push({kind:"attr",el:u,name:me,source:"both"})),Ue!=null&&M(u,ke,Ue)}},N=(u,P,F,_)=>u&&e.mergeAttrs?e.mergeAttrs(u,P,F,_):L(_,u,P,F),A=e.mergeElement||((u,P,F)=>{let _=o.createElement(u.tagName);N(u,P,F,_);let Q=P||u,me=F||u,ke=t==="local"?Q.isEqualNode(u)?me:Q:me.isEqualNode(u)?Q:me;for(let Se of ke.childNodes)_.appendChild(o.importNode(Se,!0));return h.set(_,{base:u,local:P,remote:F}),_}),E=e.cloneUnit||((u,P)=>{let F=o.importNode(u,!0);return h.set(F,{base:null,local:P==="local"?u:null,remote:P==="remote"?u:null}),F}),V=e.atomKey||(u=>nr(u,()=>!1)),j=(u,P)=>{let F=new Map;for(let _ of u.atoms)if(e.remoteWins&&e.remoteWins(_.el)&&Tn.has(_.el.tagName))F.set(_,"w"+_.el.tagName+"#"+(_.el.id||""));else if(!m)F.set(_,_.key);else if(u===g)F.set(_,"="+V(_.el));else{let Q=P.reverse.get(_.el),me=Q?B.get(Q):null;me?F.set(_,"="+V(me.el)):Q?F.set(_,"m"+V(_.el)):F.set(_,"="+V(_.el))}return _=>F.get(_)},D=j(g,null),y=j(f,n),k=j(b,s),J=e.certifiedOrigins?e.certifiedOrigins(g,f,b,D,y,k):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let u=zt(),P=gs({base:g,side:f,baseOf:_=>n?.reverse?.get(_)||null,budget:u}),F=gs({base:g,side:b,baseOf:_=>s?.reverse?.get(_)||null,budget:u});(P.status==="ready"||F.status==="ready")&&(J={local:P.status==="ready"?P:null,remote:F.status==="ready"?F:null})}let H=e.prepared||or(g,f,b,D,y,k,J,c),q=H.lines,Me=H.baseTokens,Oe=H.localEdits,Re=H.remoteEdits,ie=H.localMap,xe=H.remoteMap,qe=g.text.length,fe=u=>new Map(u.atoms.map(P=>[P.el,P])),x=fe(f),Y=fe(b),ae=(u,P,F)=>{let _=new Set;if(!m)return _;for(let Q of u.atoms){let me=B.get(P.reverse.get(Q.el));me&&F.bTo[me.i]<0&&_.add(me)}return _},oe=ae(f,n,ie),Ee=ae(b,s,xe),je=u=>!Vn(u,{...e,remoteWins:null}),Ne=new Set;if(m)for(let u of g.atoms){if(!je(u.el))continue;let P=n.map.get(u.el)||null,F=s.map.get(u.el)||null,_=P&&!F?P:F&&!P?F:null;_&&(x.has(_)||Y.has(_))&&!_.isEqualNode(u.el)&&Ne.add(u)}let tt=1,Xe=(u,P)=>({id:tt++,tag:u,base:null,local:null,remote:null,rank:P}),dt=new Map,Ge=[];for(let u of g.marks){let P=Xe(u.tag,u.depth);P.block=!!u.block,P.base=u.el,P.baseMark=u,dt.set(u.el,P),Ge.push(P)}let st=(u,P)=>{let F=-1,_=-1;for(let Q=u.from;Q<u.to;Q++){let me=P[Q];me>=0&&(F<0&&(F=me),_=me+1)}return F<0?null:[F,_]},Ot=(u,P,F,_)=>{for(let Q of u.marks){let me=F?F.reverse.get(Q.el):null;me&&F.identical.has(me)&&F.pairIdenticalChildren&&F.pairIdenticalChildren(me);let ke=me?dt.get(me):null;if(ke&&ke[P]&&(ke=null),!ke){let Se=st(Q,_),De=0;if(Se)for(let Le of Ge){if(Le.tag!==Q.tag||Le[P]||!!Le.block!=!!Q.block)continue;let Ue=Math.min(Se[1],Le.baseMark.to)-Math.max(Se[0],Le.baseMark.from);(Ue>De||Ue===De&&Ue>0&&Math.abs(Le.rank-Q.depth)<Math.abs(ke.rank-Q.depth))&&(ke=Le,De=Ue)}}ke||(ke=Xe(Q.tag,Q.depth),ke.block=!!Q.block,ke.new=P),ke[P]=Q.el,ke[P+"Mark"]=Q,dt.set(Q.el,ke)}};Ot(f,"local",n,ie.toB),Ot(b,"remote",s,xe.toB);let Ct=u=>u.merged||u,yt=u=>{let P=new Set;for(let F of u)F.block||P.add(dt.get(F.el));return P},Nt=new Map,Lt=u=>{let P=Nt.get(u);return P||(P=yt(u),Nt.set(u,P)),P},qt=(u,P)=>{let F=[],_=null;for(let Q=0;Q<qe;Q++){let me=P[Q];if(me<0){_&&F.push(_),_=null;continue}let ke=Lt(g.stackAt[Q]),Se=Lt(u.stackAt[me]),De=new Set,Le=new Set;for(let Ue of Se)ke.has(Ue)||De.add(Ue);for(let Ue of ke)Se.has(Ue)||Le.add(Ue);if(!De.size&&!Le.size){_&&F.push(_),_=null;continue}if(_&&Zs(_.added,De)&&Zs(_.removed,Le)){_.be=Q+1;continue}_&&F.push(_),_={bs:Q,be:Q+1,added:De,removed:Le}}return _&&F.push(_),F},cn=qt(f,ie.bTo),It=qt(b,xe.bTo),$t=u=>u.be>u.bs?[u.bs,u.be-1]:[u.bs-1,u.bs],wn=(u,P)=>{if(qe===0)return null;let[F,_]=$t(u);for(let Q of P){if(Q.be<=F)continue;if(Q.bs>_)break;let me=Q.bs<=F&&_<Q.be;return me&&u.text===""&&Q.bs===u.bs&&Q.be===u.be?"straddle":me?Q:u.be>u.bs?"straddle":null}return null},jt=u=>u.bs===u.be,rn=(u,P,F=null)=>{let _=!1;for(let Q=u.bs;Q<u.be;Q++){let me=g.text[Q];if(me===kt)_=!0;else if(!/\s/.test(me))return!1}for(let Q=u.ss;Q<u.se;Q++){let me=P.text[Q];if(me===kt)_=!0;else if(!/\s/.test(me)){let ke=F&&e.scopeUnits&&jt(u)&&P.atomAt.get(Q);if(!ke||!je(ke.el)||F.ss!==F.se||F.bs>=F.be)return!1;for(let De=F.bs;De<F.be;De++)if(!/\s/.test(g.text[De]))return!1;let Se=P===f?1:2;if(!e.scopeUnits[Se].includes(ke.el)||(Se===1?n:s)?.reverse.has(ke.el))return!1;_=!0}}return _},Gt=(u,P)=>u.bs<P.be&&P.bs<u.be,fn=(u,P)=>u.bs<=P.be&&P.bs<=u.be&&jt(u)!==jt(P),$=(u,P)=>g.text.slice(u.bs,u.be).includes(kt)||P.text.slice(u.ss,u.se).includes(kt),l=u=>{if(jt(u))return!1;let P=u.bs,F=u.be;for(;P>0&&/\s/.test(g.text[P-1]);)P--;for(;F<g.text.length&&/\s/.test(g.text[F]);)F++;return(P===0||g.text[P-1]===kt)&&(F===g.text.length||g.text[F]===kt)},O=(u,P)=>!$(u,P)&&!l(u),R=(u,P)=>Gt(u,P)||fn(u,P)&&!(u.transferIn||u.transferOut||P.transferIn||P.transferOut)&&!(rn(u,f,P)&&O(P,b))&&!(rn(P,b,u)&&O(u,f)),K=(u,P)=>{if(u.bs!==P.bs||u.be!==P.be||u.toks.length!==P.toks.length)return!1;let F=u.ss,_=P.ss;for(let Q=0;Q<u.toks.length;Q++){let me=u.toks[Q],ke=P.toks[Q];if(me.k!==ke.k||me.atom&&!f.atomAt.get(F).el.isEqualNode(b.atomAt.get(_).el))return!1;F+=me.len,_+=ke.len}return!0},Z=(u,P,F,_)=>{for(let Q of g.atoms){if(Q.i<u.bs||Q.i>=u.be||_.has(Q)||Ne.has(Q))continue;let me=P.bTo[Q.i],ke=me>=0?F.atomAt.get(me):null;if(ke&&!ke.el.isEqualNode(Q.el))return!0}return!1},U=[],de=null,we=null,le=Oe.hunks,Ae=Re.hunks,W=0,X=0,pe=0,be=0,he=0,ee=u=>{u>pe&&(U.push({src:"base",from:pe,to:u,dL:be,dR:he}),pe=u)};for(;W<le.length||X<Ae.length;){let u=le[W],P=Ae[X],F=!!u&&(!P||u.bs<P.bs||u.bs===P.bs&&u.be<=P.be&&!P.lead);if(u&&P&&u.bs===P.bs&&jt(u)&&jt(P)){let _t=rn(u,f),So=rn(P,b);_t!==So&&(F=So)}let _=F?u:P,Q=F?P:u,me=!!Q&&K(u,P),ke=!!Q&&(F?!!le[W+1]&&K(le[W+1],P):!!Ae[X+1]&&K(u,Ae[X+1])),Se=!!Q&&!me&&!ke&&(qe===0||R(u,P)),De=Se,Le=wn(_,F?It:cn);if(Le==="straddle"&&(De=!0),!De&&_.be>_.bs&&(De=Z(_,F?xe:ie,F?b:f,F?oe:Ee)),!De&&me){ee(_.bs),U.push({src:"both",lfrom:u.ss,rfrom:P.ss,len:_.text.length,owner:u.owner||P.owner||null,transfer:u.transferIn||P.transferIn||null}),pe=_.be,be+=_.text.length-(_.be-_.bs),he+=_.text.length-(_.be-_.bs),W++,X++;continue}if(!De){ee(_.bs),U.push({src:F?"local":"remote",from:_.ss,to:_.se,inherit:Le&&Le!=="straddle"?Le:null,owner:_.owner||null,transfer:_.transferIn||null}),pe=_.be,F?(be+=_.text.length-(_.be-_.bs),W++):(he+=_.text.length-(_.be-_.bs),X++);continue}let Ue=_.bs,gt=_.be,lt=W,ut=X,Vt=_t=>_t.bs<gt&&_t.be>Ue||jt(_t)&&(_t.bs===Ue||_t.bs===gt);F?lt++:ut++,Se&&(Ue=Math.min(Ue,Q.bs),gt=Math.max(gt,Q.be),F?ut++:lt++);let Bt=!0;for(;Bt;){for(Bt=!1;lt<le.length&&Vt(le[lt]);)Ue=Math.min(Ue,le[lt].bs),gt=Math.max(gt,le[lt].be),lt++,Bt=!0;for(;ut<Ae.length&&Vt(Ae[ut]);)Ue=Math.min(Ue,Ae[ut].bs),gt=Math.max(gt,Ae[ut].be),ut++,Bt=!0}let mn=Ue+be,ln=Ue+he,yn=gt-Ue,Nn=gt-Ue;for(let _t=W;_t<lt;_t++)yn+=le[_t].text.length-(le[_t].be-le[_t].bs);for(let _t=X;_t<ut;_t++)Nn+=Ae[_t].text.length-(Ae[_t].be-Ae[_t].bs);let Bn=mn+yn,Dn=ln+Nn;if(ee(Ue),W<lt&&X<ut&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!f.atoms.length&&!b.atoms.length&&!g.pins.length&&!f.pins.length&&!b.pins.length){de||={fb:g,fl:f,fr:b,ML:ie,MR:xe,byEl:dt,cache:[null,null]};let _t=er(de,le,W,lt,Ae,X,ut,0,t),So=er(de,Ae,X,ut,le,W,lt,1,t);if(_t===null!=(So===null)){let ts=_t!==null,Ds=ts?_t:So;if(Ds){we||=new Map;for(let si of Ds)we.set(si,ts?"local":"remote")}U.push(ts?{src:"remote",from:ln,to:Dn}:{src:"local",from:mn,to:Bn}),pe=gt,be+=yn-(gt-Ue),he+=Nn-(gt-Ue),W=lt,X=ut;continue}}let en={kind:"text",node:e.node||null,base:co(g,Ue,gt),local:co(f,mn,Bn),remote:co(b,ln,Dn),resolved:null,range:null,bs:Ue,be:gt,lss:mn,lse:Bn,rss:ln,rse:Dn},Jn=e.sourceRetentions?$s(e.sourceRetentions,e.scope?.base,g,f,b,t,en):t;en.resolved=Jn==="local"?en.local:Jn==="remote"?en.remote:en.local+en.remote,Jn!=="remote"&&U.push({src:"local",from:mn,to:Bn,conflict:en}),Jn!=="local"&&U.push({src:"remote",from:ln,to:Dn,conflict:en});let Qn={site:"inline",policy:Jn,fb:g,fl:f,fr:b,scope:e.scope||null,synthetic:!!e.synthetic,full:T,merged:c};p.push(Qn),w(en,Qn),pe=gt,be+=yn-(gt-Ue),he+=Nn-(gt-Ue),W=lt,X=ut}ee(qe);let te=g.text,z=[];if(Oe.respell.size||Re.respell.size){let u=fo(Me),P=[];for(let F=0;F<Me.length;F++){let _=Me[F].raw,Q=Oe.respell.get(F)??_,me=Re.respell.get(F)??_;(Q!==_||me!==_)&&z.push([u[F],Q!==_&&me!==_?"both":Q!==_?"local":"remote"]),P.push(Q===me?Q:Q===_?me:me===_||t==="local"?Q:me)}te=P.join("")}let ne="",Te=[],Ce=[],Pe=[],ve=[];for(let u of U){let P=ne.length;if(u.src==="base"){for(let F=u.from;F<u.to;F++)Te.push(F),Ce.push(e.nativeTransfers?ie.bTo[F]:F+u.dL),Pe.push(e.nativeTransfers?xe.bTo[F]:F+u.dR),ve.push(u);ne+=te.slice(u.from,u.to)}else if(u.src==="both"){for(let F=0;F<u.len;F++){let _=u.transfer&&(u.transfer.side==="remote"?u.rfrom+F:u.lfrom+F);Te.push(u.transfer&&_>=u.transfer.ss&&_<u.transfer.se?u.transfer.bs+_-u.transfer.ss:-1),Ce.push(u.lfrom+F),Pe.push(u.rfrom+F),ve.push(u)}ne+=f.text.slice(u.lfrom,u.lfrom+u.len)}else{let F=u.src==="local"?f:b,_=u.transfer&&e.nativeTransfers.byOrigin[u.src==="local"?"remote":"local"].get(u.transfer.key);for(let Q=u.from;Q<u.to;Q++){let me=u.transfer&&Q>=u.transfer.ss&&Q<u.transfer.se?u.transfer.bs+Q-u.transfer.ss:-1,ke=me>=0&&(!_||_.destination===u.owner)?(u.src==="local"?xe:ie).bTo[me]:-1;Te.push(me),Ce.push(u.src==="local"?Q:ke),Pe.push(u.src==="remote"?Q:ke),ve.push(u)}ne+=F.text.slice(u.from,u.to)}u.ms=P,u.me=ne.length,u.conflict&&(u.conflict.range||(u.conflict.range=[P,P]),u.conflict.range[1]=ne.length)}let _e=ne.length,Je=new Int32Array(qe+1).fill(-1),Ze=new Int32Array(f.text.length+1).fill(-1),Ut=new Int32Array(b.text.length+1).fill(-1);for(let u=0;u<_e;u++)Te[u]>=0&&(Je[Te[u]]=u),Ce[u]>=0&&(Ze[Ce[u]]=u),Pe[u]>=0&&(Ut[Pe[u]]=u);let Pt=(u,P)=>{let F=-1,_=-1;for(let Q=u.from;Q<u.to;Q++){let me=P[Q];me>=0&&(F<0&&(F=me),_=me+1)}return F<0?null:[F,_]},C=[],G=[];for(let u of new Set(dt.values()))u.new==="local"?C.push(u):u.new==="remote"&&G.push(u);let re=(u,P)=>{u.remote=P.remote,u.remoteMark=P.remoteMark,u.new="both",P.merged=u,dt.set(P.remote,u)};if(C.length&&G.length){let u=e.idOf;for(let P of C){let F=u?u.local(P.local):null;if(!F)continue;let _=G.find(Q=>!Q.merged&&Q.tag===P.tag&&!!Q.block==!!P.block&&u.remote(Q.remote)===F);_&&re(P,_)}for(let P of C){if(P.remote)continue;let F=Pt(P.localMark,Ze);if(F)for(let _ of G){if(_.merged||_.tag!==P.tag||!!_.block!=!!P.block)continue;let Q=Pt(_.remoteMark,Ut);if(Q&&Math.min(F[1],Q[1])-Math.max(F[0],Q[0])>0){re(P,_);break}}}}Nt.clear();let ge=u=>{for(let P of u)if(P.block)return Ct(dt.get(P.el));return null},ye=g.marks.some(u=>u.block)||f.marks.some(u=>u.block)||b.marks.some(u=>u.block),ce=new Array(_e).fill(null),se=new Set;if(e.nativeTransfers)for(let u=0;u<_e;u++){let P=ve[u].owner;ce[u]=P?Ct(dt.get(P)):Te[u]>=0?ge(g.stackAt[Te[u]]):null}else if(ye){let u=(Le,Ue,gt)=>{let lt=new Set([Le,Ue,gt]);lt.delete(null);let ut=[];for(let Bt of lt){let mn=Bt===Le,ln=Bt===Ue,yn=Bt===gt;(ln===yn?ln:ln===mn?yn:ln)&&ut.push(Bt)}if(ut.length<=1)return ut[0]||null;let Vt=t==="local"?Ue:gt;return ut.includes(Vt)?Vt:ut[0]},P=(Le,Ue)=>Ue>=0?ge(Le.stackAt[Ue]):null,F=new Map;for(let Le=0;Le<_e;Le++){if(ne[Le]!==kt)continue;let Ue=Te[Le]>=0?P(g,Te[Le]):null,gt=P(f,Ce[Le]),lt=P(b,Pe[Le]);F.set(Le,[Ue,Te[Le]>=0?u(Ue,gt,lt):gt||lt])}let _=new Set([...F.values()].map(Le=>Le[1])),Q=Le=>Le!==kt&&Le!==Un&&!/\s/.test(Le),me=(Le,Ue)=>{let gt=Le;for(;gt<Ue&&!Q(ne[gt]);)gt++;return gt<Ue&&Te[gt]>=0?P(g,Te[gt]):null},ke=new Map,Se=0;for(let Le=0;Le<_e;Le++){if(ne[Le]!==kt)continue;let[Ue,gt]=F.get(Le),lt=me(Se,Le),ut=gt,Vt=ke.get(ut)===ut&&lt===ut;ut&&ke.has(ut)&&!Vt&&Ue&&!ke.has(Ue)&&!_.has(Ue)&&(ut=Ue),ut&&!ke.has(ut)&&ke.set(ut,lt);for(let Bt=Se;Bt<=Le;Bt++)ce[Bt]=ut;Se=Le+1}let De=Le=>{for(let Ue=0;Ue<Le.text.length;Ue++)if(Q(Le.text[Ue])&&!P(Le,Ue))return!0;return!1};if(!De(g)&&!De(f)&&!De(b)){let Le=[],Ue=0;for(let lt=0;lt<_e;lt++)(ne[lt]===kt||lt===_e-1)&&(Le.push([Ue,lt]),Ue=lt+1);let gt=new Set(ce);for(let lt=0;lt<Le.length;lt++){let[ut,Vt]=Le[lt];if(ce[Vt])continue;let Bt=ut;for(;Bt<=Vt&&!Q(ne[Bt]);)Bt++;if(Bt>Vt)continue;let mn=P(g,Te[Bt]),ln=P(f,Ce[Bt]),yn=P(b,Pe[Bt]),Nn=u(mn,ln,yn)||ln||yn||mn;if(Nn&&!gt.has(Nn)){gt.add(Nn);for(let en=ut;en<=Vt;en++)ce[en]=Nn;continue}let Bn=lt>0&&ce[Le[lt-1][1]],Dn=lt+1<Le.length&&ce[Le[lt+1][1]];if(Bn)se.add(Le[lt-1][1]);else if(Dn&&ne[Vt]===kt)se.add(Vt);else continue;for(let en=ut;en<=Vt;en++)ce[en]=Bn||Dn}}}let Ie=new Map,Be=u=>{let P=Ie.get(u);if(P)return P;P=[1/0,-1/0];for(let[F,_]of[[u.baseMark,Je],[u.localMark,Ze],[u.remoteMark,Ut]]){let Q=F&&Pt(F,_);Q&&(P[0]=Math.min(P[0],Q[0]),P[1]=Math.max(P[1],Q[1]))}return Ie.set(u,P),P},He=(u,P,F)=>{let _=-1,Q=-1;for(let me=0;me<u.length;me++){let ke=dt.get(u[me].el);ke===P&&(_=me),ke===F&&(Q=me)}return _>=0&&Q>=0?_-Q:0},Ke=(u,P)=>[...u].sort((F,_)=>{for(let ke of P){let Se=He(ke,F,_);if(Se)return Se}let Q=Be(F),me=Be(_);return Q[0]-me[0]||me[1]-Q[1]||F.rank-_.rank||F.id-_.id}),pt=new Map,ht=new Map,Kt=e.nativeTransfers?[]:null,Ht=u=>{if(Kt)return Kt;let P=Te[u],F=Ce[u],_=Pe[u],Q=ve[u];if(P>=0){let lt=g.stackAt[P],ut=f.stackAt[F],Vt=b.stackAt[_],Bt=pt.get(lt);Bt||pt.set(lt,Bt=new Map);let mn=Bt.get(ut);mn||Bt.set(ut,mn=new Map);let ln=mn.get(Vt);if(ln)return ln;let yn=Lt(lt),Nn=Lt(ut),Bn=Lt(Vt),Dn=new Set;for(let en of new Set([...yn,...Nn,...Bn])){let Jn=yn.has(en),Qn=Nn.has(en),_t=Bn.has(en);(Qn===_t?Qn:Qn===Jn?_t:Qn)&&Dn.add(en)}return ln=Ke(Dn,[ut,Vt,lt]),mn.set(Vt,ln),ln}if(Q.src==="both"){let lt=f.stackAt[F],ut=b.stackAt[_];return Ke(new Set([...Lt(lt),...Lt(ut)]),[lt,ut])}let ke=(Q.src==="local"?f:b).stackAt[Q.src==="local"?F:_];if(!Q.inherit)return Ke(Lt(ke),[ke]);let Se=ht.get(Q);Se||ht.set(Q,Se=new Map);let De=Se.get(ke);if(De)return De;let Le=new Set(Lt(ke));for(let lt of Q.inherit.added)Le.add(Ct(lt));for(let lt of Q.inherit.removed)Le.delete(Ct(lt));let Ue=Q.src==="local"?b:f,gt=(Q.src==="local"?xe.bTo:ie.bTo)[Q.inherit.bs];return De=Ke(Le,[ke,Ue.stackAt[gt]]),Se.set(ke,De),De},un=new Int32Array(f.text.length+1);un[f.text.length]=_e;for(let u=f.text.length-1;u>=0;u--)un[u]=Ze[u]>=0?Ze[u]:un[u+1];Pi.caret+=f.text.length;let bt=u=>u<=0?0:(u>f.text.length&&(u=f.text.length),Ze[u-1]>=0?Ze[u-1]+1:un[u]),it=[],$e=[],vt=null,at=[],Dt="",bn=-1,on=u=>{vt?vt.appendChild(u):it.push(u)},hn=u=>{if(!Dt)return;let P=o.createTextNode(Dt);on(P),$e.push({node:P,ms:bn,me:u,local:[],u:at.length?at[at.length-1].u:null}),Dt=""},Yt=new Set,En=new Map,oo=new Set,Rn=u=>{let P=o.createElement(u.tag);if(u.block&&vn.add(P),!En.has(u)){En.set(u,P),N(u.base,u.local,u.remote,P),h.set(P,{base:u.base,local:u.local,remote:u.remote});let _=(ke,Se)=>m&&u[Se]&&ke.reverse.get(u[Se])?Se:null,Q=!u.base&&(_(n,"local")||_(s,"remote"));if(Q){let ke=Q==="local"?n.reverse.get(u.local):s.reverse.get(u.remote),Se=h.get(P);Se.local=Se.local||n.map.get(ke)||null,Se.remote=Se.remote||s.map.get(ke)||null,a.push({kind:"move",el:P,source:Q}),e.moveBuilt?.(ke,Q,u[Q],P)}else u.base||a.push({kind:"insert",el:P,source:u.local&&u.remote?"both":u.local?"local":"remote"});let me=h.get(P);me.local&&(oo.has(me.local)?me.local=null:oo.add(me.local))}else{let _=En.get(u);for(let Q of _.attributes)Q.name!=="id"&&Q.name!=="data-id"&&M(P,Q,Q.value);h.set(P,{base:null,local:null,remote:null})}on(P),at.push({u,el:P}),vt=P},xo=new Set,qn=new Map;for(let u of f.pins){let P=bt(u.i);qn.has(P)||qn.set(P,[]),qn.get(P).push(u)}let Ro=u=>{let P=qn.get(u);if(P){hn(u);for(let F of P){let _=F.el.namespaceURI&&F.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(F.el.namespaceURI,F.el.tagName):o.createElement(F.el.tagName);h.set(_,{base:null,local:F.el,remote:null,pinned:!0}),xo.add(_),on(_)}}},es=g.atoms.length||f.atoms.length||b.atoms.length,Po=u=>{if(!es)return null;let P=Te[u]>=0?g.atomAt.get(Te[u]):null,F=Ce[u]>=0?f.atomAt.get(Ce[u]):null,_=Pe[u]>=0?b.atomAt.get(Pe[u]):null;return P||F||_?{ab:P,al:F,ar:_}:null},Kn=(u,P,F)=>{let _=e.idOf;if(!_||!_.base)return!1;let Q=_.base(u.el);return Q!=null&&Q===_[F](P.el)},To=(u,P,F,_,Q)=>{if(!u||!m)return null;let me=B.get(P.reverse.get(u.el))||null;return!me||me===_||(_?me.el.isEqualNode(_.el)&&!Kn(me,u,Q):F.bTo[me.i]>=0)?null:me},so=(u,P)=>{if(!u||!m||!e.moveIn)return null;let F=P.reverse.get(u.el);return F&&!B.has(F)?F:null},vo=(u,P)=>{let F=new Map;for(let _ of u.atoms)F.set(P(_),(F.get(P(_))||0)+1);return F},ue=vo(g,D),We=vo(f,y),Ve=vo(b,k),et=u=>{let P=D(u);return ue.get(P)===1&&(We.get(P)||0)<=1&&(Ve.get(P)||0)<=1},wt=new Map,Fe=new Set,ze=new Set,xt=new Set,Ye=null;for(let u=0;u<_e;u++){let P=Po(u);if(!P)continue;let{ab:F,al:_,ar:Q}=P,me=To(Q,s,xe,F,"remote"),ke=To(_,n,ie,F,"local"),Se=F,De=null;if(me?(Se=me,De="remote"):ke&&(Se=ke,De="local"),Se){F&&Se!==F&&(Ye||=new Map).set(F,De),Fe.has(Se)?wt.set(u,{dup:Se.el}):(Fe.add(Se),wt.set(u,{bk:Se,from:De,al:_,ar:Q}));continue}let Le=so(Q,s),Ue=so(_,n),gt=Le||Ue;if(gt){ze.has(gt)?wt.set(u,{dup:gt}):(ze.add(gt),wt.set(u,{moveIn:gt,side:Le?"remote":"local",sideEl:Le?Q.el:_.el}));continue}let lt=(Vt,Bt)=>Vt&&m&&B.get(Bt.reverse.get(Vt.el))||null,ut=lt(Q,s)||lt(_,n);if(ut&&(xt.add(ut),ve[u].conflict&&(et(ut)||Q&&(Q.el===ut.el||s.identityPaired?.has(ut.el))&&Kn(ut,Q,"remote")||_&&(_.el===ut.el||n.identityPaired?.has(ut.el))&&Kn(ut,_,"local")))){if(Fe.has(ut)){wt.set(u,{dup:ut.el});continue}Fe.add(ut)}wt.set(u,{al:_,ar:Q})}let ot=new Map,ct,Wt,Mt=(u,P)=>{if(u[P]>=0)return u[P];for(let F=P-1;F>=0;F--)if(u[F]>=0)return u[F]+1;return 0};if(m)for(let u of g.atoms){if(Fe.has(u)||xt.has(u))continue;let P=n.map.get(u.el)||null,F=s.map.get(u.el)||null,_=P&&x.get(P),Q=F&&Y.get(F);if(P&&!_||F&&!Q)continue;let me=!(_&&Q)&&Ne.has(u);if(!me&&!(_&&Q&&(et(u)||Ye?.has(u)||(_.el===u.el||n.identityPaired?.has(u.el))&&(Q.el===u.el||s.identityPaired?.has(u.el))&&Kn(u,_,"local")&&Kn(u,Q,"remote"))))continue;let ke=Ye?.get(u),Se=t;if(ke){let lt=ke==="local"?b:f,ut=ke==="local"?s:n,Vt=ke==="local"?Wt:ct;if(Vt===void 0){Vt=lt.atoms.length===g.atoms.length;for(let Bt=0;Vt&&Bt<g.atoms.length;Bt++)Vt=ut.reverse.get(lt.atoms[Bt].el)===g.atoms[Bt].el;ke==="local"?Wt=Vt:ct=Vt}Vt&&(Se=ke)}let De=Se==="local"?[[_,Ze],[Q,Ut]]:[[Q,Ut],[_,Ze]],[Le,Ue]=De.find(([lt])=>lt),gt=Mt(Ue,Le.i);ot.has(gt)||ot.set(gt,[]),ot.get(gt).push({a:u,lt:P,rt:F,edited:me}),Fe.add(u)}if(m&&e.moveIn){let u=[[f,n,Ze,"local"],[b,s,Ut,"remote"]];t!=="local"&&u.reverse();for(let[P,F,_,Q]of u)for(let me of P.atoms){let ke=so(me,F);if(!ke||ze.has(ke))continue;ze.add(ke);let Se=Mt(_,me.i);ot.has(Se)||ot.set(Se,[]),ot.get(Se).push({move:ke,side:Q,sideEl:me.el})}}let Qt=u=>{let P=ot.get(u);if(P){if(hn(u),P.some(F=>je(F.move?F.sideEl:F.a.el)))for(;at.length;)at.pop(),vt=at.length?at[at.length-1].el:null;for(let{a:F,lt:_,rt:Q,edited:me,move:ke,side:Se,sideEl:De}of P){if(ke){let Ue=e.moveIn(ke,Se,De);Ue&&on(Ue);continue}Yt.add(F);let Le=A(F.el,_,Q);me&&(w({kind:"structure",el:Le,detail:"edit-beats-delete",base:F.el},{subject:F.el,deleted:_?"remote":"local"}),a.push({kind:"insert",el:Le,source:_?"local":"remote"})),on(Le)}}},vn=new Set,Fn=r.length>d;for(let u=0;u<_e;u++){let P=Po(u),F=e.scopeUnits&&P&&(P.ab?.stack.some(ke=>ke.block)||P.al?.stack.some(ke=>ke.block)||P.ar?.stack.some(ke=>ke.block)),Q=!!P&&je((P.ab||P.al||P.ar).el)&&!F?[]:ce[u]?[ce[u],...Ht(u)]:Ht(u),me=0;for(;me<at.length&&me<Q.length&&at[me].u===Q[me];)me++;if(me<at.length)for(hn(u);at.length>me;)at.pop(),vt=at.length?at[at.length-1].el:null;if(Ro(u),Qt(u),Q.length>at.length)for(hn(u);at.length<Q.length;)Rn(Q[at.length]);if(ne[u]===kt){if(se.has(u))continue;hn(u);let ke=at.length;for(;ke>0&&!at[ke-1].u.block;)ke--;if(ke>0)for(Fn&&c.breakOut.set(u,at[ke-1].el);at.length>=ke;)at.pop(),vt=at.length?at[at.length-1].el:null;continue}if(P){hn(u);let ke=wt.get(u),Se;if(ke.dup){w({kind:"structure",el:null,detail:"both-moved",base:ke.dup},{subject:ke.dup});continue}if(ke.moveIn){if(Se=e.moveIn(ke.moveIn,ke.side,ke.sideEl),!Se)continue}else if(ke.bk){let De=ke.bk;if(Yt.add(De),De===P.ab)Se=A(De.el,ke.al.el,ke.ar.el);else{let Le=n.map.get(De.el)||null,Ue=s.map.get(De.el)||null;Se=A(De.el,Le,Ue),(!Le||!Ue)&&w({kind:"structure",el:null,detail:"move-beats-delete",base:De.el},{subject:De.el,deleted:Le?"remote":"local"}),a.push({kind:"move",el:Se,source:ke.from})}}else ke.al?(Se=E(ke.al.el,"local"),ke.ar&&(h.get(Se).remote=ke.ar.el),a.push({kind:"insert",el:Se,source:ke.ar?"both":"local"})):(Se=E(ke.ar.el,"remote"),a.push({kind:"insert",el:Se,source:"remote"}));Fn&&c.atomOut.set(u,Se),on(Se);continue}Dt||(bn=u),Dt+=ne[u]}if(hn(_e),(qn.has(_e)||ot.has(_e))&&(at.length=0,vt=null,Ro(_e),Qt(_e)),_e===0&&(f.placeholder||b.placeholder||g.placeholder)){let u=o.createElement("br");h.set(u,{base:g.placeholder,local:f.placeholder,remote:b.placeholder}),it.push(u)}let Pn=0,ft=u=>{for(;Pn>0&&$e[Pn-1].me>=u;)Pn--;for(;Pn<$e.length&&$e[Pn].me<u;)Pn++;let P=$e[Pn];if(!P)return $e[$e.length-1]||null;let F=$e[Pn+1];return P.me===u&&F&&F.ms===u?F:P},Qe=new Map,Et={},nt=(u,P,F)=>{let _=ft(u)||(F?Et:null);if(!_)return;let Q=Qe.get(_)||{l:!1,r:!1};P!=="remote"&&(Q.l=!0),P!=="local"&&(Q.r=!0),Qe.set(_,Q)},At=u=>{if(u.conflict)return!0;let P=u.src==="local"?f.text:u.src==="remote"?b.text:"";for(let F=u.from;F<u.to;F++)if(P[F]!==Un&&P[F]!==kt)return!0;return!1};for(let u of U)u.src!=="base"&&nt(u.ms,u.conflict?"both":u.src,At(u));for(let[u,P]of z)Je[u]>=0&&nt(Je[u],P);for(let u of $e.length?$e:[Et]){let P=Qe.get(u);P&&a.push({kind:"text",node:u.node||null,source:P.l&&P.r?"both":P.l?"local":"remote"})}for(let u of Ge){if(En.has(u))continue;let P=!u.local&&!(m&&n.map.get(u.base)),F=!u.remote&&!(m&&s.map.get(u.base));!P&&!F||a.push({kind:"remove",source:P&&F?"both":P?"local":"remote",base:u.base})}if(we)for(let[u,P]of we)En.has(u)&&w({kind:"structure",el:En.get(u),detail:"edit-beats-delete",base:u.base},{subject:u.base,deleted:P});let Xt=(u,P,F)=>{if(P<=u)return!1;for(let _=u;_<P;_++)if(F[_]>=0)return!1;return!0};for(let u of Ge)for(let P of["local","remote"]){let F=u[P+"Mark"],_=u.baseMark;if(!F)continue;let Q=P==="local"?ie:xe;if(!Xt(_.from,_.to,Q.bTo)||!Xt(F.from,F.to,Q.toB))continue;let me=(P==="local"?le:Ae).find(ke=>ke.ss<=F.from&&F.from<ke.se);me&&(me.be<=_.from||me.bs>=_.to)&&a.push({kind:"move",el:En.get(u)||null,source:P})}let Rt=u=>{let P=dt.get(u.node.parentNode);return P?Ct(P):null};for(let u of f.nodes){let P=-1;for(let _=u.s;_<u.e;_++)if(Ze[_]>=0){P=Ze[_];break}let F;if(P>=0)F=ft(P);else{let _=bt(u.s),Q=Rt(u);F=$e.find(me=>me.u===Q&&me.me>=_)||$e.filter(me=>me.u===Q).pop()}F&&F.local.push(u)}let Ft=new Map,tn=$e[$e.length-1]||null,Tt=0;for(let u of f.nodes){let P=null;for(let F=u.s;F<=u.e;F++){let _=bt(F);for(;Tt>0&&$e[Tt-1].me>=_;)Tt--;for(;Tt<$e.length&&$e[Tt].me<_;)Tt++;let Q=ke=>ke&&_>=ke.ms&&_<=ke.me&&(_<ke.me||F===u.e||ke===P),me=Q($e[Tt])?$e[Tt]:Q($e[Tt+1])?$e[Tt+1]:$e[Tt]||tn;if(!me)break;if(P===me){let ke=Ft.get(me);ke[ke.length-1].to=F-u.s;continue}P=me,Ft.has(me)||Ft.set(me,[]),Ft.get(me).push({node:u.node,from:F-u.s,to:F-u.s,flatStart:u.s})}}for(let u of $e){let P=u.local,F=!1;for(let ke of P)for(let Se=ke.s;Se<ke.e&&!F;Se++)(Ze[Se]<u.ms||Ze[Se]>=u.me)&&(F=!0);h.set(u.node,{base:null,local:P.map(ke=>ke.node),remote:null,caret:Ft.get(u)||[],partial:F});let _=u.ms,Q=u.me-u.ms,me=ke=>{let Se=0,De=-1;for(let Le of P){let Ue=Le.e-Le.s;if(ke<=Se+Ue){De=Le.s+(ke-Se);break}Se+=Ue}return De<0&&(De=P.length?P[P.length-1].e:0),Math.max(0,Math.min(bt(De)-_,Q))};me.flat=ke=>Math.max(0,Math.min(bt(ke)-_,Q)),i.set(u.node,me)}function mt(){if(!f.text.includes(kt))return[{flatLocal:f.text,localNodes:f.nodes,textNodes:$e,lToM:Ze,mapLocal:bt}];let u=[],P=0,F=0;for(let _=0;_<=f.text.length;_++){if(_<f.text.length&&f.text[_]!==kt)continue;let Q=P,me=_;if(me>Q){let ke=[];for(;F<f.nodes.length&&f.nodes[F].e<=Q;)F++;for(let Se=F;Se<f.nodes.length&&f.nodes[Se].s<me;Se++){let De=f.nodes[Se],Le=Math.max(De.s,Q),Ue=Math.min(De.e,me);Le<Ue&&ke.push({node:De.node,s:Le-Q,e:Ue-Q})}u.push({flatLocal:f.text.slice(Q,me),localNodes:ke,textNodes:$e,lToM:Ze.subarray?Ze.subarray(Q,me+1):Ze.slice(Q,me+1),mapLocal:Se=>bt(Q+Math.max(0,Math.min(Se,me-Q)))})}P=_+1}return u}let St={...e,blocks:vn,ignored:u=>xo.has(u)||(e.ignored?e.ignored(u):!1)},Zt=e.ignoreAttribute||(()=>!1),_n=Gs(nn(it,St),Zt)!==Gs(b,Zt);if(p.length){let u=P=>{let F=h.get(P);return F&&F.unchanged?F.remote:null};c.text=ne,c.textNodes=$e,c.out=nn(it,{...St,via:u})}let Sn=null;if(e.scopeUnits){Sn=new Map;let u=new Set(it),P=Se=>{for(;Se&&!u.has(Se);)Se=Se.parentNode;return Se},F=e.scopeUnits.map(Se=>{let De=new Map;for(let Le of Se)if(Le.nodeType===1)De.set(Le,Le);else for(let Ue of Le.nodes)De.set(Ue,Le);return De}),_=(Se,De)=>{for(;Se&&!De.has(Se);)Se=Se.parentNode;return Se?De.get(Se):null},Q=[g,f,b].map((Se,De)=>{let Le=new Array(Se.text.length);for(let Ue of Se.nodes){let gt=_(Ue.node,F[De]);gt&&Le.fill(gt,Ue.s,Ue.e)}for(let Ue of Se.atoms)Le[Ue.i]=_(Ue.el,F[De]);return Le}),me=(Se,De)=>{if(!Se||!De)return;let Le=Sn.get(Se);Le||Sn.set(Se,Le=new Set),Le.add(De)};for(let Se of it){let De=h.get(Se);De&&(me(_(De.base,F[0]),Se),me(_(De.local,F[1]),Se),me(_(De.remote,F[2]),Se))}for(let Se of $e){let De=P(Se.node);for(let Le=Se.ms;Le<Se.me;Le++)me(Q[0][Te[Le]],De),me(Q[1][Ce[Le]],De),me(Q[2][Pe[Le]],De)}let ke=new Map(it.map((Se,De)=>[Se,De]));for(let[Se,De]of Sn)Sn.set(Se,Array.from(De).sort((Le,Ue)=>ke.get(Le)-ke.get(Ue)))}return{unitOutputs:Sn,nodes:it,text:ne,textNodes:$e,localDiverged:_n,mapLocal:bt,conflicts:r.slice(d),granularity:q?"line":"word",segments:mt(),localHunks:le,remoteHunks:Ae,lToM:Ze}}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:h}){let i=new Map,r=(S,T)=>{let M=i.get(S);M||i.set(S,M=new Set),M.add(T)},a=new Set,d=new Set;for(let S of s){let T=S.textNodes;for(let M of T)a.add(M.node);for(let M of S.localNodes){d.add(M.node);let L=0,N=null;for(let A=M.s;A<M.e;A++){let E=S.lToM[A];if(E<0)continue;for((!T[L]||E<T[L].ms)&&(L=0);L<T.length&&T[L].me<=E;)L++;let V=T[L]&&T[L].ms<=E?T[L].node:xs;V!==N&&r(M.node,V),N=V}}}let w=new Set,c=new Map,p=new Set;(function S(T){w.add(T);let M=n.get(T);if(T.nodeType===1)M&&M.local&&M.local.nodeType===1&&(r(M.local,T),M.unchanged&&p.add(M.local)),T.tagName==="TEMPLATE"&&T.content&&c.set(T.content,T);else if(M&&Array.isArray(M.local)&&!a.has(T))for(let L of M.local)r(L,T);for(let L=sr(T).firstChild;L;L=L.nextSibling)S(L)})(t);let m=new Set;for(let[S,T]of o.links)r(S,T),m.add(S);let v=S=>{let T=S.parentNode;return T&&T.nodeType===11?c.get(T)||null:T},I=(S,T)=>{for(let M=S;M;M=v(M))if(M===T)return!0;return!1},g=S=>o.removed.has(S)||o.consumed.has(S),f=S=>{for(let T=S.parentNode;T&&T.nodeType===1;T=T.parentNode){if(p.has(T))return"kept";if(g(T))return"decided";if(i.has(T))return null}return null},b=new Map;for(let S of e)b.set(S,B(S));return b;function B(S){let T=i.get(S);if(T&&(T.size!==1||T.has(xs)))return{kind:"unknown",reason:"several-outputs"};let M=T?T.values().next().value:null;if(M&&(M.nodeType!==1||!w.has(M)))return{kind:"unknown",reason:"output-not-placed"};if(!M){let E=g(S)?"decided":f(S);if(E==="kept")return{kind:"untouched"};if(E!=="decided")return{kind:"unknown",reason:"unmapped"}}let L=[],N=A(S,!!M&&(p.has(S)||m.has(S)),!M||g(S));if(N)return{kind:"unknown",reason:N};return M?{kind:"single",output:M,owned:L,carried:m.has(S)}:{kind:"removed"};function A(E,V,j){for(let D=sr(E).firstChild;D;D=D.nextSibling){if(D.nodeType===1?h(D):D.nodeType!==3&&D.nodeType!==8)continue;let y=i.get(D);if(y)for(let k of y){if(k===xs||!w.has(k))return"output-not-placed";if(!M)return"survives-elsewhere";if(!I(k,M))return"escaped";L.push(k)}else if(!V&&!j&&!g(D)&&!d.has(D))return"unmapped";if(D.nodeType===1){let k=A(D,V||p.has(D)||m.has(D),j||g(D));if(k)return k}}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 h(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&&h(r)})(t),o.set(t,{nodes:n,opaque:s})}return o}function Ts(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),h=!1,i={...e,lineage:{elements:s,onResult(r,a){if(!h)return h=!0,n.onResult(r,a)}}};try{return cr.set(i.lineage,fr(s)),t(i)}catch(r){if(!h){h=!0;try{n.onResult({version:1,root:o,status:"incomplete",entries:s.map(An)},null)}catch{}}throw r}}function vs(e,{liveRoot:o,localRoot:t,toLive:n}){let s=ar(e,o.ownerDocument),h=d=>d===o||o.contains(d),i=new Map,r=new Set(s.filter(h));if(r.size&&t===o)for(let d of r)i.set(d,d);else r.size&&(function d(w){let c=n(w);r.delete(c)&&i.set(c,w);for(let p=w.firstElementChild;p&&r.size;p=p.nextElementSibling)d(p)})(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(d,w){return this.resolve=w,this.plans=d,this.result={version:1,root:this.root,status:"complete",entries:s.map(c=>Hi(c,i.get(c),d,w,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(d,w){this.root=w;let c=this.resolve,p=v=>{let I=c(v);return I===d?w:I};return this.finish(this.plans,p)},deliver(d){this.delivered||(this.delivered=!0,e.onResult(this.result,d))}}}var An=e=>({from:e,to:[],kind:"unknown",complete:!1});function Hi(e,o,t,n,s){let h=s.root,i=p=>!!p&&(p===h||h.contains(p)),r=o&&t?t.get(o):null;if(!r||r.kind==="unknown")return An(e);let a=s.before.get(e);if(!a||a.opaque)return An(e);let d=a.nodes,w=p=>i(p)||!!(p&&p.ownerDocument===h.ownerDocument&&h.ownerDocument.documentElement?.contains(p));if(r.kind==="untouched"){if(!i(e))return An(e);for(let p of d)if(w(p)&&!e.contains(p))return An(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(r.kind==="removed")return w(e)||d.some(w)?An(e):{from:e,to:[],kind:"removed",complete:!0};let c=n(r.output);if(!c||c.nodeType!==1||!i(c)||c!==e&&w(e))return An(e);for(let p of d)if(w(p)&&!c.contains(p))return An(e);for(let p of r.owned){let m=n(p),v=Array.isArray(m)?m:[m];for(let I of v)if(!I||!i(I)||!c.contains(I))return An(e)}return r.carried&&!ur(c,r.output,n)?An(e):{from:e,to:[c],kind:c===e?"retained":"replaced",complete:!0}}function ur(e,o,t){for(let n=o.firstChild;n;n=n.nextSibling){let s=t(n),h=Array.isArray(s)?s:[s];for(let i of h)if(!i||!e.contains(i))return!1;if(n.nodeType===1&&!ur(e,n,t))return!1}return!0}function Ao(e,o,t){let n=vs(e,{liveRoot:o,localRoot:o,toLive:s=>s});return n.result={version:1,root:o,status:"complete",entries:n.watched.map(s=>An(s))},t.lineage=n.result,n}function dr(e,o,t,n,s){if(!s(e.length*8+1))return null;let h=0,i=o===0,r=!1;for(let a of an(e,n)){if(!s(1))return null;if(h+=a.len,h===o&&(i=!0),h===t&&(r=!0),h>=t)break}return i&&r}function Wi(e,o,t,n,s,h,i){if(!i(o.length*2))return!1;let r=new Map,a=new Map,d=new Set;for(let w of o){let c=w.bs<w.be,p=c?t[w.ownerIndex].text.base:t[w.ownerIndex].text[e],m=c?w.bs:w.ss,v=c?w.be:w.se;if(!i((v-m)*4+1))return!1;for(;m<v&&/\s/.test(p[m]);)m++;for(;v>m&&/\s/.test(p[v-1]);)v--;if(m===v)continue;let I=p.slice(m,v),g=c?r:a;c&&w.text&&d.add(I),g.has(I)?g.set(I,null):g.set(I,{h:w,from:m,to:v})}for(let w of n){if(!i(1))return!1;if(w.side!==e)continue;let c=w.deletion,p=t[c.ownerIndex].text.base;if(!i((c.be-c.bs)*3)||d.has(p.slice(c.bs,c.be).trim()))return!1}for(let[w,c]of r){if(!i(w.length+1))return!1;let p=a.get(w);if(!c||!p)continue;let m=c.h,v=p.h;if(!m.text||m.transferOut||v.transferIn||m.owner===v.owner)continue;let I=t[m.ownerIndex],g=t[v.ownerIndex];if(!i(I.text.base.length))return!1;if(!/\S/.test(I.text.base.slice(0,m.bs)+I.text.base.slice(m.be)))continue;let f=dr(I.text.base,c.from,c.to,h,i),b=dr(g.text[e],p.from,p.to,h,i);if(f===null||b===null)return!1;if(!f||!b)continue;let B=`${I.index}:${c.from}:${c.to}`,S={key:B,side:e,source:m.owner,destination:v.owner,deletion:m,insertion:v,sourceOffset:c.from-m.bs,targetOffset:p.from-v.ss,length:c.to-c.from};m.transferOut=S,v.transferIn=S,s[e].set(B,S),n.push(S)}return!0}function hr({base:e,local:o,remote:t,localTwin:n,remoteTwin:s,eligible:h,nodes:i,budget:r=zt(2e4*32)}){let a=N=>N>r.remaining?!1:(r.remaining-=N,r.nativeSteps=(r.nativeSteps||0)+N,!0);if(e.length<2||o.length!==e.length||t.length!==e.length||!a(e.length*12))return null;for(let[N,A]of[["base",e],["local",o],["remote",t]]){let E=i[N];if(E.length!==A.length||E.some((V,j)=>V!==A[j]))return null}let d=[],w=0;for(let N=0;N<e.length;N++){let A=e[N],E=o[N],V=t[N];if(n(A)!==E||s(A)!==V)return null;let j={};for(let[D,y]of[["base",A],["local",E],["remote",V]]){if(!h(y)||y.tagName!==A.tagName||y.namespaceURI!==A.namespaceURI||!a(y.childNodes.length+1))return null;let k="";for(let J of y.childNodes){if(J.nodeType!==3||!a(J.data.length*4+1))return null;k+=J.data}if(k.includes(kt)||(w+=k.length+1,w>2e4))return null;j[D]=k}d.push({base:A,local:E,remote:V,index:N,text:j})}let c=d.every(N=>xn(N.text.base,N.text.local,N.text.remote)),p={local:[],remote:[]};for(let N of d){N.hunks={local:[],remote:[]};for(let A of["local","remote"]){let E=N.text.base,V=N.text[A];if(E===V)continue;let j=E.length+V.length+4,D=j*8;if(!a(D))return null;let y=Math.floor(r.remaining/8),k=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(j*j+y)-j)/2)));if(k<1||!a(4*(k+1)*(j+k+1)))return null;let J=0;for(let H of Gn(E,V,k)){if(!a(H.text.length+1))return null;let q=H.bs+J,Me={...H,ss:q,se:q+H.text.length,toks:an(H.text,c),owner:N.base,ownerIndex:N.index};N.hunks[A].push(Me),p[A].push(Me),J+=H.text.length-(H.be-H.bs)}}}let m=[],v={local:new Map,remote:new Map};for(let N of["local","remote"]){let A=new Map,E=new Map,V=!1,j=(D,y,k)=>{D.has(y)?D.set(y,null):D.set(y,k)};for(let D of p[N]){if(!a(1))return null;let y=d[D.ownerIndex].text.base;if(D.bs<D.be&&D.text===""){let k=y.slice(D.bs,D.be);if(!a(k.length*2))return null;/\S/.test(k)&&j(A,k,D)}else if(D.bs===D.be&&/\S/.test(D.text)){if(!a(D.text.length*2))return null;j(E,D.text,D)}else D.bs<D.be&&(V=!0)}for(let[D,y]of A){if(!a(D.length+1))return null;let k=E.get(D);if(!y||!k||y.owner===k.owner)continue;let J=d[y.ownerIndex];if(!a(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,y.bs)+J.text.base.slice(y.be)))continue;let H=`${J.index}:${y.bs}:${y.be}`,q={key:H,side:N,source:y.owner,destination:k.owner,deletion:y,insertion:k};y.transferOut=q,k.transferIn=q,v[N].set(H,q),m.push(q)}if(V&&E.size&&!Wi(N,p[N],d,m,v,c,a))return null}if(!m.length)return null;let I=(N,A)=>N.bs<A.be&&A.bs<N.be,g=N=>N.bs===N.be,f=(N,A)=>N.bs<=A.be&&A.bs<=N.be&&g(N)!==g(A),b=(N,A)=>N.bs===A.bs&&N.be===A.be&&N.text===A.text,B=(N,A)=>!!(N.transferIn||N.transferOut&&(!N.text||A.bs===N.be&&/\s/.test(A.text[0])||A.bs===N.bs&&/\s/.test(A.text[A.text.length-1])));for(let N of m){let A=N.side==="local"?"remote":"local",E=d[N.deletion.ownerIndex];for(let V of E.hunks[A])if(!a(1)||I(N.deletion,V)&&V.transferOut?.key!==N.key)return null}for(let N of d)for(let A of N.hunks.local)for(let E of N.hunks.remote){if(!a(1))return null;if(b(A,E)){if(A.transferIn?.key!==E.transferIn?.key)return null;continue}if(I(A,E)||f(A,E)&&!B(A,E)&&!B(E,A))return null}if(!a(w*8))return null;let S=new Set([...e,...o,...t]),T={base:nn(e,{blocks:S}),local:nn(o,{blocks:S}),remote:nn(t,{blocks:S})},M={};for(let N of["base","local","remote"]){let A=T[N];if(A.atoms.length||A.pins.length)return null;M[N]=new Map(A.marks.filter(E=>E.block).map(E=>[E.el,E.from]))}for(let N of d){let A=M.base.get(N.base);if(A===void 0)return null;for(let E of["local","remote"]){let V=M[E].get(N[E]);if(V===void 0)return null;for(let j of N.hunks[E])j.bs+=A,j.be+=A,j.ss+=V,j.se+=V}}for(let N of m)N.bs=N.deletion.bs+(N.sourceOffset||0),N.be=N.length===void 0?N.deletion.be:N.bs+N.length,N.ss=N.insertion.ss+(N.targetOffset||0),N.se=N.length===void 0?N.insertion.se:N.ss+N.length;let L={};for(let N of["local","remote"]){let A=0,E=0,V=[];for(let D of p[N]){if(!a(1))return null;D.bs>A&&V.push({from:A,to:D.bs,target:E}),A=D.be,E=D.se}A<T.base.text.length&&V.push({from:A,to:T.base.text.length,target:E});let j=m.filter(D=>D.side===N).map(D=>({from:D.bs,to:D.be,target:D.ss,destination:D.destination}));if(L[N]=jn({base:T.base,side:T[N],retained:V,transfers:j,budget:r}),L[N].status!=="ready")return null}return a(T.base.text.length)?{owners:d,blocks:S,transfers:m,byOrigin:v,budget:r,prepared:{base:T.base,local:T.local,remote:T.remote,lines:!1,baseTokens:an(T.base.text,c),localEdits:{hunks:p.local,respell:new Map},remoteEdits:{hunks:p.remote,respell:new Map},localMap:L.local,remoteMap:L.remote,full:null}}:null}var Ss=/\S/;function pr({certificates:e,scopes:o,views:t,eligible:n,baseId:s,limit:h=2e4*32}){let i=zt(h),r=Symbol(),a=[],d=c=>{if(c>i.remaining)throw r;i.remaining-=c},w=(c,p=null)=>{if(d(1),!c||c.nodeType!==1||c.parentNode?.nodeType!==1||!n(c))return null;for(let I=c.parentNode;I;I=I.parentNode)if(d(1),I.nodeType===11)return null;let m="",v=0;for(let I of c.childNodes){if(d(1),I.nodeType!==3)return null;if(d(I.data.length*4+1),p){let g=p.flat.nodes[v++];if(!g||g.node!==I||g.s!==m.length||g.e!==m.length+I.data.length)return null}m+=I.data}return d(m.length*3+1),p&&(p.flat.atoms.length||p.flat.pins?.length||v!==p.flat.nodes.length||p.flat.text!==m)?null:Ss.test(m)?m:null};try{d(o[0].length+o[1].length+o[2].length+e.length);let c=o.map(m=>new Set(m)),p=new Map;for(let m of e){d(1);let v=p.get(m.source);v||p.set(m.source,v=[]),v.push(m)}for(let m of p.values()){let v=[null,null],I=[];for(let g of m){d(1);let{source:f,target:b,side:B,models:S,runs:T}=g;if(B!==0&&B!==1||!c[0].has(f)||!c[B+1].has(b))continue;let{V:M,A:L,idOf:N}=t[B],A=t[1-B],E=M.twin(f),V=A.V.twin(f),j=M.baseOf(b);if(!E||!V||!j||j===f||!c[0].has(j)||!c[B+1].has(E)||!c[2-B].has(V)||L.map.get(f)!==E||L.reverse.get(E)!==f||A.A.map.get(f)!==V||A.A.reverse.get(V)!==f||L.map.get(j)!==b||L.reverse.get(b)!==j||b.parentNode!==E.parentNode||j.parentNode!==f.parentNode||f.tagName!==E.tagName||f.tagName!==V.tagName||s(f)!==N(E)||s(f)!==A.idOf(V)||s(j)!==N(b))continue;let D=S.get(f),y=S.get(b);if(!D||!y)continue;let k=w(f,D),J=w(b,y),H=w(E),q=w(V);if(d((k?.length||0)+(q?.length||0)),k===null||J===null||H===null||q===null||q===k)continue;let Me=T.length>0,Oe=!1;for(let ie of T){if(d(1),ie.source!==f||ie.target!==b||!Number.isInteger(ie.from)||!Number.isInteger(ie.to)||!Number.isInteger(ie.targetFrom)||ie.from<0||ie.to<=ie.from||ie.to>k.length||ie.targetFrom<0||ie.targetFrom+ie.to-ie.from>J.length){Me=!1;break}d((ie.to-ie.from)*3);for(let xe=ie.from;xe<ie.to;xe++){if(k[xe]!==J[ie.targetFrom+xe-ie.from]){Me=!1;break}Ss.test(k[xe])&&(Oe=!0)}if(!Me)break}if(!Me||!Oe)continue;let Re=v[B];Re||(d(k.length),Re=v[B]={source:f,side:B,flat:D.flat,before:k,covered:new Uint8Array(k.length)});for(let ie of T)d(ie.to-ie.from),Re.covered.fill(1,ie.from,ie.to)}for(let g of v){if(!g)continue;let{source:f,side:b,flat:B,before:S,covered:T}=g;d(S.length*3+1);let M=-1,L=-1;for(let N=0;N<=S.length;N++)N<S.length&&T[N]?(M<0&&(M=N),L=N+1):(N===S.length||Ss.test(S[N]))&&M>=0&&(I.push({source:f,side:b,flat:B,from:M,to:L}),M=L=-1)}d(I.length),a.push(...I)}}catch(c){if(c!==r)throw c}return{records:a,budget:i}}var qi="http://www.w3.org/1999/xhtml";function Ki(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 pn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===qi}function Fi(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 h=new URL(t,o);s=h.origin+h.pathname+h.search}catch{}return"script|src|"+n+"|"+s}return"script|inline|"+n+"|"+Ki(e.textContent.trim())}var _i={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function ho(e,o=[],t=!1){if(!pn(e)||e.hasAttribute("src"))return null;let n=[_i,...o];for(let s=0;s<n.length;s++){let h=n[s];if(!h.match(e))continue;if(!Fi(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let i=h.identity(e);return i==null||i===""?null:{key:s+":"+i,raw:i,recognizer:h}}return null}function mr(e,o,t){let n=new Set,s=h=>{pn(h)&&!o(h)&&n.add(_o(h,t))};s(e);for(let h of e.querySelectorAll("script"))s(h);return n}function Mo(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=[],h=new Map,i=t.trackRecovery?new Set:null,r=Array.from(e.querySelectorAll("script"));pn(e)&&r.unshift(e);for(let a of r){if(!pn(a)||t.ignored(a)||t.skip.has(a)||o.has(_o(a,t.baseURI)))continue;let d=a.ownerDocument.createElement("script");for(let w of a.attributes)d.setAttribute(w.name,w.value);if(d.textContent=a.textContent,t.beforeNodeAdded(d)===!1){i?.add(a);continue}d.hasAttribute("src")&&s.push(new Promise(w=>{d.addEventListener("load",()=>w()),d.addEventListener("error",()=>w())})),a.replaceWith(d),h.set(a,d),t.afterNodeAdded(d),n.push(d)}return{executed:n,loads:s,swapped:h,vetoed:i}}function zi(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|"+zi(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 Gi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Yi=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function zo(e){try{return JSON.parse(e)}catch{return JSON.parse(Xi(e))}}function Xi(e){let o="",t=0,n=(s,h)=>{throw new Error(`Invalid relaxed JSON: ${s} at position ${h}`)};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 a=e.slice(t+1,r);s==="'"&&(a=wr(a)),o+='"'+a+'"',t=r+1;continue}let h=t;for(;h<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[h]);)h++;h===t&&n("unexpected character "+JSON.stringify(s),t);let i=e.slice(t,h);if(i==="true"||i==="false"||i==="null"||Gi.test(i)){o+=i,t=h;continue}if(Yi.test(i)){if(e[Ns(e,h)]===":"){o+='"'+i+'"',t=h;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 h=[],i=0;for(;i<s.length;){let r=s[i];if(/\s/.test(r)){i++;continue}if("{}".includes(r)){h.push({type:r,value:r}),i++;continue}if(r==="["){let c=!1,p=i+1;for(;p<s.length&&/\s/.test(s[p]);)p++;if(p<s.length&&/[a-zA-Z_]/.test(s[p])&&(c=!0),!c){h.push({type:r,value:r}),i++;continue}}if(r==="]"){h.push({type:r,value:r}),i++;continue}if(r===":"){h.push({type:o.COLON,value:r}),i++;continue}if(r===","){h.push({type:o.COMMA,value:r}),i++;continue}if(r==='"'||r==="'"){let c=r,p=i+1;for(;p<s.length&&s[p]!==c;)s[p]==="\\"&&p++,p++;h.push({type:o.STRING,value:s.substring(i+1,p),quoted:!0,sourceQuote:c}),i=p+1;continue}let a=i,d;for(;a<s.length&&!/[{},]/.test(s[a]);)if(s[a]===":"){let c=[":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"],p=!1;for(let m of c){let v=m.substring(1);if(s.substring(a+1,a+1+v.length)===v){p=!0,a+=v.length;break}}if(!p)break}else if(s[a]==="["){for(a++;a<s.length&&s[a]!=="]";){if(s[a]==='"'||s[a]==="'"){let c=s[a];for(a++;a<s.length&&s[a]!==c;)s[a]==="\\"&&a++,a++}a++}a<s.length&&s[a]==="]"&&a++}else a++;d=s.substring(i,a);let w=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(d)?w=o.NUMBER:d==="true"||d==="false"||d==="null"?w=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(d)&&(w=o.SELECTOR),h.push({type:w,value:d,quoted:!1}),i=a}return h}function n(s){let h="";for(let i=0;i<s.length;i++){let r=s[i];if("{}".includes(r.type)||"[]".includes(r.type)){h+=r.value;continue}if(r.type===o.COLON){h+=r.value;continue}if(r.type===o.COMMA){let a=s[i+1];if(a&&(a.type==="}"||a.type==="]"))continue;h+=r.value;continue}if(r.type===o.STRING){let a=r.value;r.sourceQuote==="'"&&(a=wr(a)),h+=`"${a}"`;continue}if(r.type===o.NUMBER||r.type===o.BOOLEAN){h+=r.value;continue}h+=`"${r.value}"`}return h}try{let s=t(e),h=n(s);return JSON.parse(h)}catch(s){throw new Error("Invalid extraction rules syntax: "+s.message)}}var Jt=Symbol("hyper-morph-json-merge:missing"),kr=["id","_id","uuid","key","slug","code","name"];function po(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Oo(e,o){return Object.prototype.hasOwnProperty.call(e,o)}function Ji(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Yn(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(!Yn(e[t],o[t]))return!1;return!0}if(po(e)&&po(o)){let t=Object.keys(e);if(t.length!==Object.keys(o).length)return!1;for(let n of t)if(!Oo(o,n)||!Yn(e[n],o[n]))return!1;return!0}return!1}function xr(e,o,t,n){return Yn(o,t)?o:Yn(o,e)?t:Yn(t,e)?o:po(o)&&po(t)?Qi(po(e)?e:{},o,t,n):Array.isArray(o)&&Array.isArray(t)?nl(Array.isArray(e)?e:[],o,t,n):t}function Tr(e,o,t,n){return o===Jt&&t===Jt?Jt:o===Jt?e===Jt?t:Yn(t,e)?Jt:t:t===Jt?e===Jt?o:Jt:xr(e,o,t,n)}function Qi(e,o,t,n){let s={},h=new Set([...Object.keys(e),...Object.keys(o),...Object.keys(t)]);for(let i of h){let r=Tr(Oo(e,i)?e[i]:Jt,Oo(o,i)?o[i]:Jt,Oo(t,i)?t[i]:Jt,n);r!==Jt&&Ji(s,i,r)}return s}function Zi(e){return e===null||typeof e!="object"}function $o(e){return typeof e+":"+String(e)}function el(e,o){for(let t of o){let n=new Set;for(let s of t){if(!Oo(s,e))return!1;let h=s[e];if(typeof h!="string"&&typeof h!="number")return!1;let i=$o(h);if(n.has(i))return!1;n.add(i)}}return!0}function tl(e,o,t,n){let s=[e,o,t],h=!0;for(let i of s)for(let r of i)po(r)||(h=!1);if(h){for(let i of n.keyCandidates)if(el(i,s))return{kind:"keyed",field:i};return null}for(let i of s){let r=new Set;for(let a of i){if(!Zi(a))return null;let d=$o(a);if(r.has(d))return null;r.add(d)}}return{kind:"self"}}function nl(e,o,t,n){let s=tl(e,o,t,n);if(!s)return t;let h=s.kind==="self"?$o:m=>$o(m[s.field]),i=m=>{let v=new Map;for(let I of m)v.set(h(I),I);return v},r=i(e),a=i(o),d=i(t),w=new Map,c=new Set([...r.keys(),...a.keys(),...d.keys()]);for(let m of c){let v=Tr(r.has(m)?r.get(m):Jt,a.has(m)?a.get(m):Jt,d.has(m)?d.get(m):Jt,n);v!==Jt&&w.set(m,v)}let p=[];for(let m of t){let v=h(m);w.has(v)&&p.push(v)}for(let m=0;m<o.length;m++){let v=h(o[m]);if(!w.has(v)||p.includes(v))continue;let I=0;for(let g=m-1;g>=0;g--){let f=p.indexOf(h(o[g]));if(f!==-1){I=f+1;break}}p.splice(I,0,v)}return p.map(m=>w.get(m))}function As(e,o,t,n={}){let s=n.keyCandidates?[...n.keyCandidates,...kr]:kr;return xr(e===void 0?Jt:e,o,t,{keyCandidates:s})}function Go(e,o,t,n={}){let s=n.parse||zo,h=[],i=(c,p)=>{if(typeof c!="string")return Jt;try{return s(c)}catch(m){return h.push(`${p} side is not valid JSON (${m.message})`),Jt}},r=i(o,"local"),a=i(t,"remote");if(r===Jt)return{text:t,warnings:h};if(a===Jt)return{text:o,warnings:h};let d=i(e,"base"),w=As(d===Jt?void 0:d,r,a,n);return Yn(w,a)?{text:t,warnings:h}:Yn(w,r)?{text:o,warnings:h}:{text:JSON.stringify(w,null,2),warnings:h}}var vr=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function eo(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>vr(o)||s>vr(n)||o.getRootNode()!==n.getRootNode())return!1;let h=o.ownerDocument.createRange();return h.setStart(o,t),h.setEnd(n,s),h.startContainer===o&&h.startOffset===t}function Xn(e,o,t={}){if(!eo(e))return null;let{startContainer:n,startOffset:s,endContainer:h,endOffset:i}=e;if(n===h&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(s,i);if(n===h&&s===i)return"";let r=new Set;for(let g=n;g;g=g.parentNode)r.add(g);let a=h;for(;!r.has(a);)a=a.parentNode;let d=(g,f)=>{let b=a.ownerDocument.createRange(),B=a.ownerDocument.createRange();return b.setStart(g[0],g[1]),b.collapse(!0),B.setStart(f[0],f[1]),B.collapse(!0),b.compareBoundaryPoints(0,B)},w=(g,f=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(f)],c=[],p;if(o==="plain"){p="";let g=f=>{if(f.nodeType===3||f.nodeType===8){let b=p.length;p+=f.nodeValue,c.push({s:b,e:p.length,a:[f,0],b:[f,f.nodeValue.length],node:f})}else for(let b of f.childNodes)g(b)};g(a)}else{let g=t.blocks;if(!g){g=new Set;let b=B=>{B!==a&&B.nodeType===1&&ys.has(B.tagName)&&g.add(B);for(let S of B.childNodes)b(S)};b(a)}let f=nn(Array.from(a.childNodes),{blocks:g,atomize:b=>!!t.atoms?.has(b),ignored:t.ignored});p=f.text;for(let b of f.nodes)c.push({s:b.s,e:b.e,a:[b.node,0],b:[b.node,b.e-b.s],node:b.node});for(let b of f.atoms)c.push({s:b.i,e:b.i+1,a:w(b.el),b:w(b.el,!0)});for(let b=0;b<f.text.length;b++){if(f.text[b]!==kt)continue;let B=f.marks.find(T=>T.block&&T.to===b+1),S=f.marks.find(T=>T.block&&T.from===b+1);if(B)c.push({s:b,e:b+1,a:[B.el,B.el.childNodes.length],b:w(B.el,!0)});else if(S)c.push({s:b,e:b+1,a:w(S.el),b:[S.el,0]});else return null}}c.sort((g,f)=>g.s-f.s);let m=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let b=c.find(B=>B.node===g[0]);return b?b.s+g[1]:null}let f=0;for(let b of c){if(d(g,b.a)<=0)return b.s;if(d(g,b.b)<0)return null;f=b.e}return f},v=m([n,s]),I=m([h,i]);return v!==null&&I!==null&&v<=I?p.slice(v,I):null}function Zn(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=Zn(e,o.start),n=Zn(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,h=r=>{if(!r)return null;if(s.has(r))return s.get(r);let d=r.local.map(w=>Zn(o.localRoot,{path:w,offset:0})?.[0]).map(w=>w&&t(w)).filter(Boolean).map(w=>({node:w,parent:w.parentNode,previous:w.previousSibling,next:w.nextSibling,fragment:Nr(w)}));return s.set(r,d),d},i=r=>{let a=Sr(o.localRoot,r);if(!a)return null;let d=t(a.startContainer),w=t(a.endContainer);if(!d||!w)return null;let c={...a,startContainer:d,endContainer:w};return eo(c)?c:null};for(let r of e){let a=r.recovery;if(!a||n.has(a))continue;let d={subject:h(a.subject),span:null,scope:null,touched:new Set};if(a.text){d.span=i(a.text.local.span),d.scope=i(a.text.local.scope);let w=d.span;if(w){let c=w.startContainer.ownerDocument.createRange();c.setStart(w.startContainer,w.startOffset),c.setEnd(w.endContainer,w.endOffset);let p=m=>{if(c.intersectsNode(m)){d.touched.add(m);for(let v of m.childNodes)p(v)}};p(c.commonAncestorContainer)}}if(a.structure){for(let w of[a.structure.localPlacement])w&&(h(w.parent),w.before.forEach(h),w.after.forEach(h));for(let w of a.structure.localOrder||[])h(w)}n.set(a,d)}o.localState={states:n,refs:s}}function Mr(e,o,t,n){let s=t.localState?.states.get(e);if(!s)return!1;let h=r=>{let a=r.node;if(!n(a)||a.parentNode!==r.parent)return!1;let d=w=>Array.prototype.indexOf.call(a.parentNode.childNodes,w);return!(r.previous&&n(r.previous)&&r.previous.parentNode===a.parentNode&&d(r.previous)>=d(a)||r.next&&n(r.next)&&r.next.parentNode===a.parentNode&&d(r.next)<=d(a))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!s.subject.length||!s.subject.every(h))return!1;if(e.text){let r=e.text.local,a=d=>d&&n(d.startContainer)&&n(d.endContainer);return a(s.span)&&a(s.scope)&&Xn(s.scope,e.text.encoding)===r.text&&Xn(s.span,e.text.encoding)===r.text.slice(r.start,r.end)}if(e.attribute){let r=e.attribute,a=s.subject[0].node;return(r.namespaceURI?a.getAttributeNS(r.namespaceURI,r.localName):a.getAttribute(r.qualifiedName))===o.local}let i=e.structure;if(i.localOrder){let r=-1,a=null;for(let d of i.localOrder){let w=t.localState.refs.get(d)?.[0]?.node;if(!w||!n(w)||a&&w.parentNode!==a)return!1;let c=Array.prototype.indexOf.call(w.parentNode.childNodes,w);if(c<=r)return!1;a=w.parentNode,r=c}return!0}return i.localAction==="moved"||s.subject.every(r=>Nr(r.node)===r.fragment)}var ol=1,dn=e=>!!e&&e.nodeType===1,Yo=e=>dn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function to(e,o=null,t=null){let n=new Map,s=new Map,h=w=>{if(!o){o=new WeakMap;let c=[e];for(;c.length;){let p=c.pop();Yo(p)&&(o.set(p.content,p),c.push(p.content));for(let m=p.firstChild;m;m=m.nextSibling)m.nodeType===1&&c.push(m)}}return o.get(w)||null},i=(w,c)=>{let p=s.get(w);if(!p){p=new Map;let m=0;for(let v=w.firstChild;v;v=v.nextSibling)p.set(v,m++);s.set(w,p)}return p.get(c)},r=w=>{if(!w)return null;if(t&&t.has(w))return r(t.get(w));if(w===e)return[];let c=n.get(w);if(c!==void 0)return c;let p=w.parentNode,m=null;if(p&&p.nodeType===11){let v=h(p),I=v?r(v):null;I&&(m=I.concat(["content",i(p,w)]))}else if(p){let v=r(p);v&&(m=v.concat([i(p,w)]))}return n.set(w,m),m};return{root:e,pathOf:r,logicalParent:w=>{let c=w.parentNode;return c&&c.nodeType===11?h(c):c},indexIn:i,containerPath:w=>{if(w.nodeType===11){let p=h(w),m=r(p);return m?m.concat(["content"]):null}let c=r(w);return c&&Yo(w)?c.concat(["content"]):c},ownerOf:h}}var Cn=e=>Yo(e)?e.content:e;function Or(e){let{L:o,R:t,unitsOf:n,provenance:s,policy:h}=e,i=[];return{note:(w,c)=>{i.push([w,c])},finish:w=>i.length?d(w):null};function d(w){let c={base:to(e.roots.base),local:to(e.roots.local),remote:to(e.roots.remote)},p=$=>$==="local"?o:t,m=($,l)=>{if(!l)return null;if($.map.has(l))return $.map.get(l);let O=[],R=dn(l)?c.base.logicalParent(l):l.parent;for(;R&&!$.map.has(R);R=c.base.logicalParent(R))O.push(R);if(!R||!$.identical.has(R))return null;let K=$.map.get(R);for(let Z=O.length-1;Z>=0&&K;Z--)K=Cn(K).childNodes[c.base.indexIn(O[Z].parentNode,O[Z])];return K?dn(l)?Cn(K).childNodes[c.base.indexIn(l.parentNode,l)]||null:n(K)[n(l.parent).indexOf(l)]||null:null},v=new Map,I=new Map,g=new WeakMap,f=0,b=($,l)=>{let O=v.get($);O||v.set($,O=[]),O.push(l)};(function $(l){I.set(l,f++);let O=s.get(l);if(O&&!O.pinned){for(let R of[O.base,O.local,O.remote])if(R)if(Array.isArray(R))for(let K of R)b(K,l);else b(R,l)}if(Yo(l)){g.set(l.content,l);for(let R=l.content.firstChild;R;R=R.nextSibling)$(R)}for(let R=l.firstChild;R;R=R.nextSibling)$(R)})(w);let B=new Map;c.out=to(w,g,B);let S={refs:new Map,spans:new Map,anchors:new Map,via:B,outOwners:g,outRoot:w,localRoot:e.roots.local},T=$=>dn($)?[$]:$.nodes,M=($,l)=>{let O=c[l].logicalParent($);if(!O)return null;for(let R of n(O))if(!dn(R)&&R.nodes.includes($))return R;return null},L=($,l)=>$==null?null:Array.isArray($)?$.length?M($[0],l):null:$,N=$=>{let l=new Set,O=[];for(let R of $)for(let K of v.get(R)||[])l.has(K)||(l.add(K),O.push(K));return O.sort((R,K)=>I.get(R)-I.get(K))},A=new Map,E=$=>{let l=$.b||$.l||$.r,O=A.get(l);if(O)return O;let R=[];for(let K of[$.b,$.l,$.r])K&&R.push(...T(K));return O=N(R),A.set(l,O),O},V=$=>({b:$,l:m(o,$),r:m(t,$)}),j=($,l)=>{let O=p(l).reverse.get($);if(O)return V(O);for(let R of N(T($))){let K=s.get(R);if(K&&!K.base&&K.local&&K.remote)return{b:null,l:L(K.local,"local"),r:L(K.remote,"remote")}}return l==="local"?{b:null,l:$,r:null}:{b:null,l:null,r:$}},D=new Map,y=$=>{let l=s.get($);if(!l||l.pinned)return null;let O=L(l.base,"base");if(O)return V(O);let R=L(l.local,"local"),K=L(l.remote,"remote");if(R){let Z=o.reverse.get(R);if(Z)return V(Z)}if(K){let Z=t.reverse.get(K);if(Z)return V(Z)}return R||K?{b:null,l:R,r:K}:null},k=$=>(D.has($)||D.set($,y($)),D.get($)),J=($,l)=>dn($)?c[l].logicalParent($):$.parent,H=new Map,q=new Map,Me=($,l)=>(dn($)?[c[l].pathOf($)]:$.nodes.map(O=>c[l].pathOf(O))).filter(Boolean),Oe=$=>{let l=$.b||$.l||$.r,O=$.b?"base":$.l?"local":"remote",R=q.get(l);if(R)return R;let K=!dn(l),Z=Me(l,O)[0],U=`${O[0]}:${JSON.stringify(Z===void 0?null:Z)}${K?":run":""}`,de=H.get(U);if(de)return q.set(l,de),de;let we=E($);return de={key:U,nodeType:dn(l)?1:l.kind==="comment"?8:3,base:$.b?Me($.b,"base"):[],local:$.l?Me($.l,"local"):[],remote:$.r?Me($.r,"remote"):[],merged:we.map(le=>c.out.pathOf(le)).filter(Boolean),live:[]},H.set(U,de),q.set(l,de),S.refs.set(de,we),de},Re={base:new Map,local:new Map,remote:new Map},ie=new Map,xe=($,l)=>{let O=J($,l);if(!O||O.nodeType!==1)return null;let R=Re[l].get(O);if(!R){let Z=n(O),U=de=>Oe(l==="base"?V(de):j(de,l));R={parent:U(O),refs:Z.map(U),index:new Map(Z.map((de,we)=>[de,we]))},Re[l].set(O,R)}let K=R.index.get($)??-1;return{parent:R.parent,before:R.refs.slice(K+1),after:R.refs.slice(0,Math.max(0,K)).reverse()}},qe=$=>{let l=$.parentNode;if(!l)return null;let O=ie.get(l);if(!O){let K=l.nodeType===11?g.get(l):l,Z=K&&K.nodeType===1?k(K):null;if(!Z)return null;let U=[],de=[],we=new Map;for(let Ae of l.childNodes){let W=k(Ae),X=W&&Oe(W),pe=U.length,be=U.length-1;X&&X!==U[be]&&(U.push(X),be++);let he={ref:X,group:be,after:pe};de.push(he),we.set(Ae,he)}let le=U.length;for(let Ae=de.length-1;Ae>=0;Ae--){let W=de[Ae];W.before=le,W.ref&&(le=W.group)}O={parent:Oe(Z),refs:U,index:we},ie.set(l,O)}let R=O.index.get($);return{parent:O.parent,before:O.refs.slice(R.before),after:O.refs.slice(0,R.after).reverse()}},fe=$=>dn($)?$.outerHTML:$.value,x=$=>dn($)?"element":$.kind==="comment"?"comment":"text",Y=($,l)=>({path:$,offset:l}),ae=($,l,O)=>{if(!$)return null;let R=c[O],K=0;if(l){let Z=dn(l)?l:l.nodes[l.nodes.length-1];Z.parentNode&&(K=R.indexIn(Z.parentNode,Z)+1)}return Y(R.containerPath($),K)},oe=($,l)=>{let O=J($,"base"),R=O?m(p(l),O):null;if(!dn(R))return null;let K=n(O),Z=null;for(let U=K.indexOf($)-1;U>=0&&!Z;U--){let de=m(p(l),K[U]);de&&J(de,l)===R&&(Z=de)}return ae(R,Z,l)},Ee=($,l,O,R)=>{let K=c[R],Z=0;for(let U=0;U<$.nodes.length;U++){let de=$.nodes[U],we=de.nodeValue.length,le=U===$.nodes.length-1;if((O==="start"?l<Z+we:l<=Z+we)||le)return Y(K.pathOf(de),Math.max(0,Math.min(l-Z,we)));Z+=we}return null},je=($,l)=>{let O=c[l],R=$.firstChild,K=$.lastChild;return R&&R.nodeType===3&&K.nodeType===3?{start:Y(O.pathOf(R),0),end:Y(O.pathOf(K),K.nodeValue.length)}:{start:Y(O.pathOf($),0),end:Y(O.pathOf($),$.childNodes.length)}},Ne=($,l,O)=>{for(let U of $.nodes)if(O==="start"?U.s<=l&&l<U.e:U.s<l&&l<=U.e)return{kind:"text",node:U.node,offset:l-U.s};let R=O==="start"?l:l-1,K=()=>{for(let U of $.nodes)if(U.s===l||U.e===l)return{kind:"text",node:U.node,offset:l-U.s};return null},Z=$.atomAt.get(R);if(Z)return{kind:O==="start"?"before":"after",node:Z.el};if($.text[R]===kt){let U=$.marks.find(we=>we.block&&we.to===R+1);if(U)return O==="start"?{kind:"end",node:U.el}:{kind:"after",node:U.el};let de=$.marks.find(we=>we.block&&we.from===R+1);if(de)return O==="start"?{kind:"before",node:de.el}:{kind:"startOf",node:de.el}}return K()},tt=($,l)=>Ne($,l,"end")||Ne($,l,"start"),Xe=($,l)=>{switch(l.kind){case"text":return Y($.pathOf(l.node),l.offset);case"end":return Y($.containerPath(l.node),Cn(l.node).childNodes.length);case"startOf":return Y($.containerPath(l.node),0);default:{let O=l.node.parentNode;return Y($.containerPath(O),$.indexIn(O,l.node)+(l.kind==="after"?1:0))}}},dt=($,l,O,R,K)=>{let Z=Ne($,l,O);return Z?Xe(c[R],Z):K()},Ge=($,l,O,R)=>{let K=$.textNodes.map(le=>({s:le.ms,e:le.me,start:{kind:"text",node:le.node,offset:0},end:{kind:"text",node:le.node,offset:le.me-le.ms}}));for(let[le,Ae]of $.atomOut)K.push({s:le,e:le+1,start:{kind:"before",node:Ae},end:{kind:"after",node:Ae}});for(let[le,Ae]of $.breakOut)K.push({s:le,e:le+1,start:{kind:"end",node:Ae},end:{kind:"after",node:Ae}});for(let le of K)if(le.start.kind==="text"&&le.s<l&&l<le.e)return{kind:"text",node:le.start.node,offset:l-le.s};if(O!=="empty"){let le=K.find(Ae=>O==="start"?Ae.s===l:Ae.e===l);if(le)return O==="start"?le.start:le.end}let Z=K.find(le=>le.e===l);if(Z)return Z.end;let U=K.find(le=>le.s===l);if(U)return U.start;let de=null,we=null;for(let le of K)le.e<=l&&(!de||le.e>de.e)&&(de=le),le.s>=l&&(!we||le.s<we.s)&&(we=le);return de?de.end:we?we.start:R()},st=($,l)=>{if(!l)return null;if(l.kind==="text"){let K=$.nodes.find(Z=>Z.node===l.node);return K?K.s+Math.min(l.offset,K.e-K.s):null}let O=$.atoms.find(K=>K.el===l.node);if(O)return l.kind==="after"?O.i+1:O.i;let R=$.marks.find(K=>K.el===l.node);return R?l.kind==="before"&&R.block&&$.text[R.from-1]===kt&&!$.marks.some(K=>K.block&&K.to===R.from)?R.from-1:l.kind==="startOf"||l.kind==="before"?R.from:l.kind==="end"&&R.block?R.to-1:R.to:null},Ot=($,l,O,R)=>{for(let de of $.nodes)if(O==="start"?de.s<=l&&l<de.e:de.s<l&&l<=de.e)return{kind:"text",node:de.node,offset:l-de.s};let K=O==="start"?l:l-1;if(!$.atomAt.has(K)&&$.text[K]!==kt){for(let de of $.nodes)if(de.s===l||de.e===l)return{kind:"text",node:de.node,offset:l-de.s}}let Z=$.atomAt.get(K);if(Z)return{kind:O==="start"?"before":"after",node:Z.el};if($.text[K]===kt){let de=$.marks.find(le=>le.block&&le.to===K+1);if(de)return O==="start"?{kind:"end",node:de.el}:{kind:"after",node:de.el};let we=$.marks.find(le=>le.block&&le.from===K+1);if(we)return O==="start"?{kind:"before",node:we.el}:{kind:"startOf",node:we.el}}let U=$.marks.find(de=>de.block&&de.from===l);return U?{kind:"startOf",node:U.el}:R?{kind:O==="start"?"startOf":"end",node:R}:null},Ct=$=>{if(!$)return null;if($.kind==="wholeStart"||$.kind==="wholeEnd"){let l=yt($.node);return $.kind==="wholeStart"?l.start:l.end}return Xe(c.out,$)},yt=$=>{let l=$.firstChild,O=$.lastChild;return l&&l.nodeType===3&&O.nodeType===3?{start:Y(c.out.pathOf(l),0),end:Y(c.out.pathOf(O),O.nodeValue.length)}:{start:Y(c.out.pathOf($),0),end:Y(c.out.pathOf($),$.childNodes.length)}},Nt=$=>{let l=J($,"base"),O=l?E(V(l))[0]:null;if(!O)return null;let R=Cn(O),K=n(l);for(let Z=K.indexOf($)-1;Z>=0;Z--){let U=E(V(K[Z])).filter(de=>de.parentNode===R);if(U.length)return{kind:"after",node:U[U.length-1]}}return{kind:"startOf",node:O}},Lt=($,l,O,R,K,Z)=>({text:$,start:l,end:O,fragment:R,span:K,scope:Z}),qt=($,l,O,R,K)=>Lt($,l,O,$.slice(l,O),R,K),cn=($,l,O,R,K)=>(S.spans.set($,{start:l,end:O,scopeStart:R,scopeEnd:K}),$),It=new Map,$t=new Map,wn=($,l,O)=>{let R=`text:${$.key}:${l}:${O}`,K=$t.get(R)||0;return $t.set(R,K+1),`${R}:${K}`},jt=($,l)=>{let O,R,K,Z="plain",U,de,we,le,Ae,W=(be,he,ee,te,z)=>{if(!be){let ne=oe(z,te);return qt("",0,0,{start:ne,end:ne},{start:ne,end:ne})}return qt(be.value,he,ee,{start:Ee(be,he,he===ee?"end":"start",te),end:Ee(be,ee,"end",te)},{start:Ee(be,0,"start",te),end:Ee(be,be.value.length,"end",te)})};if(l.site==="run"){let{bRun:be,lRun:he,rRun:ee,node:te,c:z}=l;O=V(be),R=z.bs,K=z.be,U=W(be,z.bs,z.be,"base",be),de=W(he,z.ls,z.le,"local",be),we=W(ee,z.rs,z.re,"remote",be);let ne=te?te.nodeValue:"",Te=Ce=>te?{kind:"text",node:te,offset:Ce}:Nt(be);le=cn(qt(ne,z.ms,z.me,{start:Ct(Te(z.ms)),end:Ct(Te(z.me))},{start:Ct(Te(0)),end:Ct(Te(ne.length))}),Te(z.ms),Te(z.me),Te(0),Te(ne.length)),Ae=te||(Nt(be)||{}).node||null}else if(l.site==="whole"){let be=l.el,he=s.get(be);O=V(he.base),R=0,K=$.base.length;let ee=(z,ne,Te)=>{let Ce=je(ne,Te);return qt(z,0,z.length,Ce,Ce)};U=ee($.base,he.base,"base"),de=ee($.local,he.local,"local"),we=ee($.remote,he.remote,"remote");let te=yt(be);le=cn(qt($.resolved,0,$.resolved.length,te,te),{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be},{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be}),Ae=be}else if(l.site==="comment"){let{bRun:be,lRun:he,rRun:ee,node:te}=l;O=V(be),R=0,K=$.base.length;let z=(Pe,ve)=>{if(!Pe){let Ze=oe(be,ve);return qt("",0,0,{start:Ze,end:Ze},{start:Ze,end:Ze})}let _e=Pe.nodes[0],Je={start:Y(c[ve].pathOf(_e),0),end:Y(c[ve].pathOf(_e),Pe.value.length)};return qt(Pe.value,0,Pe.value.length,Je,Je)};U=z(be,"base"),de=z(he,"local"),we=z(ee,"remote");let ne=$.resolved,Te=Pe=>te?{kind:"text",node:te,offset:Pe}:Nt(be),Ce={start:Ct(Te(0)),end:Ct(Te(ne.length))};le=cn(qt(ne,0,ne.length,Ce,Ce),Te(0),Te(ne.length),Te(0),Te(ne.length)),Ae=te||(Nt(be)||{}).node||null}else{let{fb:be,fl:he,fr:ee,scope:te}=l,z=l.merged;Z="html",O=te.base?V(te.base):j(te.local,"local"),R=$.bs,K=$.be;let ne=se=>{let Ie=te[se];for(let Be=te.at-1;Be>=0;Be--){let He=te.units[Be],Ke=se==="base"?He:m(p(se),He);if(Ke&&J(Ke,se)===Ie)return Ke}return null},Te=se=>()=>ae(te[se],ne(se),se),Ce=(se,Ie,Be,He,Ke)=>{let pt=bn=>bn?Xe(c[Ke],bn):Te(Ke)(),ht=Ie===Be?tt(se,Ie):Ne(se,Ie,"start"),Kt=Ie===Be?tt(se,Ie):Ne(se,Be,"end"),Ht=pt(ht),un={start:Ht,end:Ie===Be?Ht:pt(Kt)},bt=l.full?l.full(Ke):null;if(!bt)return Lt(se.text,Ie,Be,He,un,{start:pt(Ne(se,0,"start")),end:pt(Ne(se,se.text.length,"end"))});let it=ht?st(bt,ht):null,$e=Kt?st(bt,Kt):null,vt=it===null?0:it,at=Math.max(vt,$e===null?bt.text.length:$e),Dt=pt(Ne(bt,0,"start"));return Lt(bt.text,vt,at,co(bt,vt,at),un,{start:Dt,end:bt.text.length?pt(Ne(bt,bt.text.length,"end")):Dt})};U=l.synthetic?null:Ce(be,$.bs,$.be,$.base,"base"),de=Ce(he,$.lss,$.lse,$.local,"local"),we=Ce(ee,$.rss,$.rse,$.remote,"remote");let[Pe,ve]=$.range||[0,0],_e=z.out,Je=()=>{let se=Cn(z.node);for(let Ie=te.at-1;Ie>=0;Ie--){let Be=E(V(te.units[Ie])).filter(He=>He.parentNode===se);if(Be.length)return{kind:"after",node:Be[Be.length-1]}}for(let Ie=te.at;Ie<te.units.length;Ie++){let Be=E(V(te.units[Ie])).filter(He=>He.parentNode===se);if(Be.length)return{kind:"before",node:Be[0]}}return{kind:"startOf",node:z.node}};if(_e.via)for(let[se,Ie]of _e.via)B.set(se,Ie);let Ze=Ge(z,Pe,Pe===ve?"empty":"start",Je),Ut=Pe===ve?Ze:Ge(z,ve,"end",Je),Pt=_e.text.length?Ot(_e,0,"start",z.node):Je(),C=_e.text.length?Ot(_e,_e.text.length,"end",z.node):Pt,G=st(_e,Ze),re=st(_e,Ut),ge=G===null?0:G,ye=Math.max(ge,re===null?_e.text.length:re);le=cn(Lt(_e.text,ge,ye,co(_e,ge,ye),{start:Ct(Ze),end:Ct(Ut)},{start:Ct(Pt),end:Ct(C)}),Ze,Ut,Pt,C);let ce=S.spans.get(le);if(ce.flat=_e,!_e.text.length){let se=Ct(Pt),Ie=Zn(w,se),Be=Ie[0],He=Ie[1];ce.empty={parent:Be.nodeType===11?g.get(Be):Be,previous:Be.childNodes[He-1]||null,next:Be.childNodes[He]||null}}Ae=Ze?Ze.node:z.node}let X=Oe(O),pe=(l.site==="whole"||l.site==="comment"||(l.policy||h)!=="both")&&$.resolved!==$.local;return{key:l.site==="comment"&&It.get(O.b||O.l||O.r)||wn(X,R,K),subject:X,localLost:pe,anchor:Ae,text:{encoding:Z,base:U,local:de,remote:we,merged:le,liveSpan:null,liveScope:null}}},rn=($,l)=>{let O=k(l.el),R=Oe(O),K=l.sample;return{key:`attr:${R.key}:${K.namespaceURI||""}:${K.localName}`,subject:R,localLost:$.resolved!==$.local,anchor:l.el,attribute:{namespaceURI:K.namespaceURI||null,localName:K.localName,qualifiedName:K.name}}},Gt=($,l)=>{let O=$.detail,R=l.unit||V(l.subject),K=Oe(R),Z=S.refs.get(K),U=R.l?xe(R.l,"local"):null,de=R.r?xe(R.r,"remote"):null,we=Z.length?qe(Z[0]):null,le,Ae,W,X=null,pe=null,be=l.deleted;switch(O){case"both-reordered":{le=Ae="reordered";let he=new Set(l.rKept),ee=l.lKept.filter(Ce=>he.has(Ce)&&E(V(Ce)).length),te=Ce=>I.get(E(V(Ce))[0]);X=ee.map(Ce=>Oe(V(Ce))),pe=ee.slice().sort((Ce,Pe)=>te(Ce)-te(Pe)).map(Ce=>Oe(V(Ce)));let z=Ce=>!dn(Ce)&&Ce.kind!=="comment"&&Ce.nodes.every(Pe=>!/[^\t\n\f\r ]/.test(Pe.data)),ne=ee.filter(Ce=>!z(Ce)),Te=ne.slice().sort((Ce,Pe)=>te(Ce)-te(Pe));W=ne.some((Ce,Pe)=>Ce!==Te[Pe]);break}case"both-moved":le=Ae="moved",W=!U||!Z.some(he=>{let ee=he===Z[0]?we:qe(he);return ee&&ee.parent===U.parent});break;case"edit-beats-delete":le=be==="local"?"deleted":"edited",Ae=be==="remote"?"deleted":"edited",W=be==="local";break;case"move-beats-delete":le=be==="local"?"deleted":"moved",Ae=be==="remote"?"deleted":"moved",W=be==="local";break;case"remote-wins":le="edited",Ae="edited",W=!0;break;default:le=Ae="inserted",W=l.localLost}return{key:`structure:${K.key}:${O}`,subject:K,localLost:W,anchor:Z[0]||null,structure:{localAction:le,remoteAction:Ae,localPlacement:U,remotePlacement:de,mergedPlacement:we,localOrder:X,mergedOrder:pe,localFragment:O==="both-reordered"||!R.l?null:fe(R.l),fragmentKind:x(R.b||R.l||R.r)}}};for(let[$,l]of i){if($.kind!=="structure")continue;let O=l.unit||V(l.subject),R=O.b||O.l||O.r;!dn(R)&&R.kind==="comment"&&It.set(R,`structure:${Oe(O).key}:${$.detail}`)}let fn=new Map;for(let[$,l]of i){if($.kind==="structure"){let Z=Oe(l.unit||V(l.subject)),U=`structure:${Z.key}:${$.detail}`,de=fn.get(U);if(de&&de.structure){$.recovery=de;let we=S.refs.get(Z);$.el==null&&we.length&&($.el=dn(we[0])?we[0]:c.out.logicalParent(we[0]));continue}}let O=$.kind==="text"?jt($,l):$.kind==="attr"?rn($,l):Gt($,l),R=fn.get(O.key);R||(R={version:ol,key:O.key,localLost:O.localLost,subject:O.subject,applied:!1,unavailable:null},fn.set(O.key,R),S.anchors.set(R,O.anchor)),O.text&&(R.text=O.text),O.attribute&&(R.attribute=O.attribute),O.structure&&(R.structure=O.structure),O.text&&(R.localLost=O.localLost),$.recovery=R;let K=S.refs.get(O.subject);$.kind==="structure"&&$.el==null&&K.length&&($.el=dn(K[0])?K[0]:c.out.logicalParent(K[0])),$.kind==="text"&&$.node==null&&K.length&&O.subject.nodeType===8&&($.node=K[0])}return S}}function Ir(e,o,t){if(!o)return;let{lookup:n,vetoed:s,vetoedAttrs:h,liveAttr:i}=t,r=t.ignored||(()=>!1),a=to(t.liveRoot),d=y=>!!y&&a.containerPath(y)!==null,w=y=>{let k=y.parentNode;return k&&k.nodeType===11?o.outOwners.get(k)||null:k},c=y=>{for(let k=y;k;k=w(k))if(o.via.has(k)&&(k=o.via.get(k)),s.has(k)||t.vetoedLive?.has(f(k)))return!0;return!1},p=y=>Array.from(Cn(y).children).filter(k=>!r(k)),m=(y,k)=>p(y)[p(k.parentNode).indexOf(k)],v=(y,k)=>{let J=null,H=null,q=0;for(let ie=k.previousSibling;ie;ie=ie.previousSibling){if(ie.nodeType===1&&!r(ie)){J=ie;break}ie.nodeType===3&&(q+=ie.nodeValue.length)}for(let ie=k.nextSibling;ie&&!H;ie=ie.nextSibling)ie.nodeType===1&&!r(ie)&&(H=ie);let Me=J?m(y,J):null,Oe=H?m(y,H):null;if(J&&!Me||H&&!Oe)return null;let Re=[];for(let ie=Me?Me.nextSibling:Cn(y).firstChild;ie&&ie!==Oe;ie=ie.nextSibling)ie.nodeType===3&&Re.push(ie);return Re.length?{nodes:Re,lead:q}:null},I=y=>{let k=[],J=y;for(;J&&!o.via.has(J);J=J.parentNode)k.push(J);if(!J||!k.length)return null;let H=f(o.via.get(J));for(let Oe=k.length-1;Oe>0&&H;Oe--)H=m(H,k[Oe]);if(!H)return null;let q=k[0];if(q.nodeType===3)return v(H,q);let Me=q.nodeType===1?m(H,q):null;return Me?{nodes:[Me],lead:0}:null},g=y=>{let k=n(y),J=k?{nodes:Array.isArray(k)?k:[k],lead:0}:o.via.size?I(y):null;if(!J)return null;let H=J.nodes.filter(d);return H.length?{nodes:H,lead:J.lead}:null},f=y=>{let k=g(y);return k?k.nodes[0]:null},b=y=>{if(!y)return null;if(y.kind==="text"){let q=g(y.node);if(!q)return null;let Me=q.nodes,Oe=y.offset+q.lead,Re=0;for(let ie=0;ie<Me.length;ie++){let xe=Me[ie].nodeValue.length;if(Oe<=Re+xe||ie===Me.length-1)return Oe>=Re&&Oe<=Re+xe?[Me[ie],Oe-Re]:null;Re+=xe}return null}let k=f(y.node);if(!k)return null;if(y.kind==="end")return[Cn(k),Cn(k).childNodes.length];if(y.kind==="startOf")return[Cn(k),0];if(y.kind==="wholeStart")return k.firstChild?[k.firstChild,0]:[k,0];if(y.kind==="wholeEnd")return k.lastChild?[k.lastChild,k.lastChild.nodeValue.length]:[k,k.childNodes.length];let J=k.parentNode;if(!J)return null;let H=Array.prototype.indexOf.call(J.childNodes,k);return[J,y.kind==="after"?H+1:H]},B=y=>({blocks:new Set((y.flat?.marks||[]).filter(k=>k.block).map(k=>f(k.el)).filter(Boolean)),atoms:new Set((y.flat?.atoms||[]).map(k=>f(k.el)).filter(Boolean)),ignored:r}),S=(y,k,J,H)=>{if(!y||!k||!eo(y)||!eo(k))return!1;for(let Oe of[y,k])if(!d(Oe.startContainer)||!d(Oe.endContainer))return!1;let q=J.merged;if(q.start===q.end&&(y.startContainer!==y.endContainer||y.startOffset!==y.endOffset))return!1;let Me=B(H);return Xn(k,J.encoding,Me)===q.text&&Xn(y,J.encoding,Me)===q.text.slice(q.start,q.end)},T=new Map,M=y=>{let k=y.parentNode;return k?(T.has(k)||T.set(k,new Map(Array.from(k.childNodes,(J,H)=>[J,H]))),T.get(k).get(y)):-1},L=(y,k)=>{if(!k)return!1;let J=a.logicalParent(y);if(!k.parent.live.includes(J))return!1;let H=M(y);for(let[q,Me]of[["before",1],["after",-1]]){let Oe=H;for(let Re of k[q]){if(Re.live.includes(y))continue;let ie=Re.live.filter(qe=>qe!==y&&qe.parentNode===y.parentNode);if(!ie.length)continue;let xe=Me===1?Math.min(...ie.map(M)):Math.max(...ie.map(M));if(Me*(xe-Oe)<=0)return!1;Oe=xe}}return!0},N=y=>{let k=y.structure;if(k.mergedOrder){let J=new Set(y.subject.live.map(Cn)),H=null,q=-1;for(let Me of k.mergedOrder){let Oe=Me.live.find(Re=>J.has(Re.parentNode));if(!Oe||H&&Oe.parentNode!==H||M(Oe)<=q)return!1;H=Oe.parentNode,q=M(Oe)}return y.subject.live.length>0}return y.subject.live.some(J=>L(J,k.mergedPlacement))},A=(y,k)=>{let J=b(y),H=b(k);return J&&H?{startContainer:J[0],startOffset:J[1],endContainer:H[0],endOffset:H[1]}:null},E=new Set,V=y=>{if(!y||E.has(y))return;E.add(y);let k=[];for(let J of o.refs.get(y)||[]){let H=g(J);if(H)for(let q of H.nodes)k.includes(q)||k.push(q)}y.live=k},j=y=>{y&&(V(y.parent),y.before.forEach(V),y.after.forEach(V))},D=new Set;for(let y of e){let k=y.recovery;if(!k||D.has(k))continue;D.add(k),V(k.subject),k.structure&&(j(k.structure.localPlacement),j(k.structure.remotePlacement),j(k.structure.mergedPlacement),(k.structure.localOrder||[]).forEach(V),(k.structure.mergedOrder||[]).forEach(V));let J=o.anchors.get(k),H=J?f(J):null,q=!!H;if(k.text){let x=o.spans.get(k.text.merged),Y=x?A(x.start,x.end):null,ae=x?A(x.scopeStart,x.scopeEnd):null;if(x?.empty){let oe=x.empty,Ee=oe.previous?{kind:"after",node:oe.previous}:{kind:"startOf",node:oe.parent},je=oe.next?{kind:"before",node:oe.next}:{kind:"end",node:oe.parent},Ne=A(Ee,je);!Ne||Ne.startContainer!==Ne.endContainer||Ne.startOffset!==Ne.endOffset?Y=null:Y=ae=Ne}S(Y,ae,k.text,x)||(Y=ae=null),k.text.liveSpan=Y,k.text.liveScope=Y?ae:null,Y||(q=!1)}k.structure&&q&&(q=N(k)),k.attribute&&q&&(q=i(H,k.attribute,y.resolved));let Me=(!!k.attribute||!!k.text&&H?.tagName==="TEXTAREA")&&!!h&&[J,H].some(x=>h.get(x)?.has(k.attribute?k.attribute.qualifiedName:"value")),Oe=o.localState?.states.get(k),Re=!!k.text&&[...t.removedVetoes||[]].some(x=>Oe?.touched.has(x)),ie=k.structure?.localAction==="inserted"&&[...s].some(x=>x===J||J?.contains(x)),xe=J&&c(J)||Me||Re||ie,qe=xe&&Mr(k,y,o,d);qe&&(Re||ie&&k.localLost)&&(q=!1);let fe=!q&&qe&&xe;k.applied=q,k.unavailable=q?null:fe?"hook-veto":"missing-output",fe&&(k.localLost=!1),!q&&k.text&&(k.text.liveSpan=k.text.liveScope=null)}}function Xo(e,o,t){let n=to(o),s=to(t),h=c=>!!c&&s.containerPath(c)!==null,i=c=>{if(c===o)return t;let p=n.pathOf(c);if(p&&o!==t){let m=Zn(t,{path:p,offset:0});if(m&&m[0].nodeType===c.nodeType)return m[0]}return c},r=new Set,a=c=>{!c||r.has(c)||(r.add(c),c.live=c.live.map(i).filter(h))},d=c=>{c&&(c.startContainer=i(c.startContainer),c.endContainer=i(c.endContainer))},w=new Set;for(let c of e){c.node===o&&t.tagName==="SCRIPT"&&(c.node=t),c.el===o&&c.kind==="structure"&&(c.el=t);let p=c.recovery;if(!p||w.has(p))continue;if(w.add(p),a(p.subject),p.text){d(p.text.liveSpan),d(p.text.liveScope);let v=p.text.liveSpan,I=p.text.liveScope,g=p.text.merged,f=b=>!!b&&eo(b)&&h(b.startContainer)&&h(b.endContainer);(!f(v)||!f(I)||Xn(I,p.text.encoding)!==g.text||Xn(v,p.text.encoding)!==g.text.slice(g.start,g.end))&&(p.text.liveSpan=null,p.text.liveScope=null,p.applied=!1,p.unavailable="missing-output")}let m=p.structure;if(m){for(let v of[m.localPlacement,m.remotePlacement,m.mergedPlacement])v&&(a(v.parent),v.before.forEach(a),v.after.forEach(a));(m.localOrder||[]).forEach(a),(m.mergedOrder||[]).forEach(a),p.subject.live.length||(p.applied=!1,p.unavailable="missing-output")}}}var mo=e=>e?.nodeType===1,Io=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function sl({provenance:e,parentOf:o,twins:t,baseOf:n,build:s,ignored:h,remoteWins:i,discarded:r}){let a=new Map,d=new WeakMap;function w(m,v,I,g=!1){if(!mo(m)||!mo(I))return null;let f=a.get(m);if(f)(g||!f.selected&&v==="remote")&&(f.parent=o(I),f.port=I,f.sourceSide=v,f.selected=g);else{let b=d.get(m)||null;f={owner:m,parent:o(I),port:I,sourceSide:v,originalParent:o(m),originalPort:m,selected:g,state:b?"built":"planned",output:b,disposition:null},a.set(m,f)}return f}function c(m,v){if(!mo(m)||!mo(v))return;d.has(m)||d.set(m,v);let I=a.get(m);I&&I.state!=="attached"&&!I.output&&(I.output=v,I.state="built")}function p(m){if(!a.size)return;let v=new Map,I=new WeakMap,g=new WeakMap,f=new WeakSet,b=new Set,B=(j,D)=>{if(!j)return;if(Array.isArray(j)){for(let k of j)B(k,D);return}let y=v.get(j);y||v.set(j,y=[]),y.push(D)},S=(j,D)=>{if(!j)return;let y=[j];for(;y.length;){let k=y.pop();B(k,D);for(let J of Io(k).childNodes)y.push(J)}};function T(j,D=null,y=!1){if(f.has(j))return;f.add(j),I.set(j,D);let k=e.get(j),J=y||!!(k&&i(k.remote||k.base));g.set(j,J);let H={node:j,kind:"node",authority:J};if(k?.pinned)S(k.local,{...H,kind:"ignored"});else if(k?.unchanged)for(let q of[k.base,k.local,k.remote])S(q,{...H,kind:"unchanged"});else if(k){for(let q of[k.base,k.local,k.remote])B(q,H);if(mo(k.local))for(let q of Io(k.local).children)h(q)&&S(q,{...H,kind:"ignored"})}for(let q of Io(j).childNodes)T(q,j,J)}let M=j=>{if(j.output&&f.has(j.output))return j.state="attached",j.disposition="node",!0;let{local:D,remote:y}=t(j.owner);for(let k of[j.owner,D,y]){let J=v.get(k);if(J?.length){let H=J.find(q=>q.kind==="node")||J[0];return j.output=H.node,j.state="attached",j.disposition=H.kind,!0}}return!1},L=(j,D)=>(v.get(j)||[]).find(k=>k.kind==="node"&&mo(k.node)&&(!k.authority||D.sourceSide==="remote"))?.node,N=(j,D,y)=>{let k=v.get(j)||[],J=y?[...k].reverse():k;for(let H of J){if(H.kind!=="node")continue;let q=H.node;for(;q&&I.get(q)!==D;)q=I.get(q);if(q)return q}return null},A=(j,D,y)=>{let k=Io(D);for(let J=y?.previousSibling;J;J=J.previousSibling){let H=N(J,D,!0);if(H){k.insertBefore(j,H.nextSibling);return}}for(let J=y?.nextSibling;J;J=J.nextSibling){let H=N(J,D,!1);if(H){k.insertBefore(j,H);return}}k.appendChild(j)};function E(j,D,y){let k=D==="base"?j:n(j,D),J=a.get(k);J&&J!==y&&V(J)}function V(j){if(j.state==="attached"||j.disposition==="remote-wins"||b.has(j)||M(j))return;b.add(j);let{local:D,remote:y}=t(j.owner);if(i(y||j.owner)){if(!y){j.disposition="remote-wins",r(j.owner,D),b.delete(j);return}j.parent=o(y),j.port=y,j.sourceSide="remote"}if(E(j.parent,j.sourceSide,j),M(j)){b.delete(j);return}let k=L(j.parent,j),J=j.port;if(!k){if(E(j.originalParent,"base",j),M(j)){b.delete(j);return}let q=j.originalParent;for(J=j.originalPort;q&&!k;)k=L(q,j),k||(J=q,q=o(q))}if(!k)throw new Error("A planned move has no allowed surviving parent");let H=j.output||s(j.owner);j.output=H,j.state="built",A(H,k,J),T(H,k,g.get(k)||!1),M(j),b.delete(j)}T(m);for(let j of a.values())V(j)}return{planned:a,has:m=>a.has(m),plan:w,produced:c,drain:p}}function go(e,o,t,n,s,h,i,r,a,d,w,c,p){let m=null;return sl({provenance:e,parentOf:g=>{if(!g)return null;let f=o(g);if(f||g.parentNode?.nodeType!==11)return f;if(!m){m=new WeakMap;let b=[c,p];for(;b.length;){let B=b.pop(),S=Io(B);S!==B&&m.set(S,B);for(let T of S.children)b.push(T)}}return m.get(g.parentNode)||null},twins:g=>({local:s(t,g),remote:s(n,g)}),baseOf:(g,f)=>g&&(f==="local"?t:n).reverse.get(g)||null,build:g=>h(g,s(t,g),s(n,g),!1),ignored:i,remoteWins:r,discarded:(g,f)=>{f&&w(g,f,t)&&!a.some(b=>b.detail==="remote-wins"&&b.base===g)&&d({kind:"structure",el:null,detail:"remote-wins",base:g,local:f,remote:null},{subject:g})}})}function rl({parent:e,base:o,views:t,eligible:n,ignored:s,remoteWins:h,budget:i=zt(2e4*32),maxUnits:r=256,maxCharacters:a=2e4}){let d=(f,b=null)=>({status:f,reason:b,parent:e,records:[]});if(t.some(({V:f})=>f.asBase)||s(e)||h(e)||t.some(({V:f})=>!f.el||s(f.el)||h(f.el)))return d("none");let w=o.length+t[0].V.units.length+t[1].V.units.length;if(w>r)return d("fallback","unit-limit");let c=Symbol(),p=f=>{if(f>i.remaining)throw c;i.remaining-=f,i.crossParentSteps=(i.crossParentSteps||0)+f},m=new Map,v=0,I=f=>{if(p(1),m.has(f))return m.get(f);let b=f.nodeType===1?f.childNodes:f.nodes;p(b.length*4+1);let B=f.nodeType===1?Array.from(b):b,S=0;for(let L=0;L<B.length;L++){let N=B[L];if(N.nodeType!==3||L&&B[L-1].nextSibling!==N)return m.set(f,null),null;S+=N.data.length}if(S>a-v)throw c;p(S*8+1),v+=S;let T=nn(B);if(T.text.includes(kt))return m.set(f,null),null;let M={unit:f,nodes:B,flat:T};return m.set(f,M),M},g=[];try{p(w*8+1);for(let f=0;f<2;f++){let b=t[f].V,B=t[1-f].V,S=[],T=new Map;for(let M=0;M<o.length;M++){p(1);let L=o[M];if(L.kind!=="text"||b.twin(L))continue;let N=B.twin(L);if(!N||N.kind!=="text"||!B.here(N))continue;let A=I(L),E=I(N);if(!A||!E||!/\S/.test(A.flat.text))continue;p(A.flat.text.length*2+1);let V=A.flat.text;T.set(V,(T.get(V)||0)+1),S.push({source:L,opposite:N,sourceModel:A,oppositeModel:E,index:M})}for(let M of S){let{source:L,opposite:N,sourceModel:A,oppositeModel:E,index:V}=M,j=[];for(let Y of[-1,1]){p(1);let ae=o[V+Y];if(!ae||ae.nodeType!==1||!n(ae)||s(ae)||h(ae))continue;let oe=A.nodes[0],Ee=A.nodes.at(-1);if(Y===-1?oe?.previousSibling!==ae:Ee?.nextSibling!==ae)continue;let je=b.twin(ae),Ne=B.twin(ae);if(!je||!Ne||!b.here(je)||B.here(Ne)||b.baseOf(je)!==ae||B.baseOf(Ne)!==ae||!n(je)||!n(Ne)||s(je)||s(Ne)||h(je)||h(Ne)||je.tagName!==ae.tagName||Ne.tagName!==ae.tagName||je.namespaceURI!==ae.namespaceURI||Ne.namespaceURI!==ae.namespaceURI)continue;let tt=I(ae),Xe=I(je),dt=I(Ne);if(!tt||!Xe||!dt||!/\S/.test(tt.flat.text))continue;let Ge=tt.flat.text,st=A.flat.text,Ot=Xe.flat.text;if(p((Ge.length+st.length+Ot.length)*3+1),Ot.length!==Ge.length+st.length)continue;let Ct=Y===-1;(Ct?!Ot.startsWith(Ge)||!Ot.endsWith(st):!Ot.startsWith(st)||!Ot.endsWith(Ge))||j.push({owner:ae,target:je,moved:Ne,ownerBase:tt,joined:Xe,ownerOther:dt,targetFrom:Ct?Ge.length:0,retainedFrom:Ct?0:st.length})}if(!j.length)continue;if(j.length!==1||T.get(A.flat.text)!==1)return d("fallback","ambiguous-origin");let D=j[0],{owner:y,target:k,moved:J,ownerBase:H,joined:q,ownerOther:Me,targetFrom:Oe,retainedFrom:Re}=D;if(p(g.length+1),g.some(Y=>Y.owner===y))return d("fallback","ambiguous-owner");let ie={source:L,target:k,from:0,to:A.flat.text.length,targetFrom:Oe},xe=jn({base:A.flat,side:q.flat,retained:[],transfers:[{from:ie.from,to:ie.to,target:Oe,destination:y}],budget:i});if(xe.status!=="ready"||xe.covers(ie.from,ie.to)!==!0)return d("fallback",xe.reason||"work-limit");let qe=[{unit:L,model:A,from:0,to:A.flat.text.length},null,null];qe[f+1]={unit:k,model:q,from:Oe,to:Oe+A.flat.text.length},qe[2-f]={unit:N,model:E,from:0,to:E.flat.text.length};let fe=[H,null,null];fe[f+1]=q,fe[2-f]=Me;let x=[y,null,null];x[f+1]=k,x[2-f]=J,g.push({side:f,parent:e,source:L,target:k,owner:y,owners:x,ownerModels:fe,native:qe,models:m,runs:[ie],proof:xe,retained:[{source:y,target:k,from:0,to:H.flat.text.length,targetFrom:Re}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:d("none")}catch(f){if(f!==c)throw f;return d("fallback","work-limit")}}function Cr({describe:e,parentOf:o,...t}){let n=new WeakMap,s=new WeakMap,h=t.budget||zt(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 a=e(r),d=a?rl({...t,...a,parent:r,budget:h}):{status:"none",reason:null,parent:r,records:[]};if(n.set(r,d),d.status==="ready")for(let w of d.records)s.set(w.owner,[w]);return d};return{get:i,forOwner(r){return i(o(r))?.status==="ready"&&s.get(r)||null}}}function il(e,o){if(e.side!==0)return null;let t=e.native[0].model,n=e.ownerModels[0],s=e.native[1].from!==0,h=(B,S)=>s?[...B.nodes,...S.nodes]:[...S.nodes,...B.nodes],i=e.ownerModels.reduce((B,S)=>B+S.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:h(n,t),local:e.ownerModels[1].nodes,remote:h(e.ownerModels[2],e.native[2].model)},a=nn(r.base),d=e.ownerModels[1].flat,w=nn(r.remote),c=s?n.flat.text.length:0,p=s?0:t.flat.text.length,m=jn({base:a,side:d,retained:e.retained.map(B=>({from:p+B.from,to:p+B.to,target:B.targetFrom})),transfers:e.runs.map(B=>({from:c+B.from,to:c+B.to,target:B.targetFrom,destination:e.owner})),budget:o});if(m.status!=="ready"||m.covers(0,a.text.length)!==!0)return null;let v=e.ownerModels[2].flat,I=e.native[2].model.flat,g=[];for(let[B,S,T,M]of[[n.flat,v,p,s?0:I.text.length],[t.flat,I,c,s?v.text.length:0]]){let L=ks(B,B,S).remoteMap.bTo,N=-1;for(let A=0;A<B.text.length;A++){if(L[A]<0){N=-1;continue}let E=g.at(-1);N>=0&&E.to===T+A&&E.target+E.to-E.from===M+L[A]?E.to++:(g.push({from:T+A,to:T+A+1,target:M+L[A]}),N=A)}}let f=jn({base:a,side:w,retained:g,transfers:[],budget:o});if(f.status!=="ready")return null;let b=ks(a,d,w,{},{local:m,remote:f});return b.localEdits.hunks.length?null:(b.localMap=m,b.remoteMap=f,{nodes:r,prepared:b})}function Lr({L:e,R:o,twinIn:t,unitsOf:n,view:s,parentOf:h,ignored:i,remoteWins:r,eligible:a,build:d,out:w,policy:c,provenance:p,textMappers:m,segments:v,conflicts:I,conflict:g,decisions:f}){let b=zt(2e4*32),B=j=>{let D=0;for(let y=j;y;y=h(y))if(++D>64||y.nodeType===1&&(i(y)||r(y)))return!1;return!0},S=Cr({parentOf:h,eligible:a,ignored:i,remoteWins:r,budget:b,describe(j){let D=t(e,j),y=t(o,j);return!D||!y||!B(j)||!B(D)||!B(y)?null:{base:n(j),views:[{A:e,V:s(e,D,j,!1)},{A:o,V:s(o,y,j,!1)}]}}}),T=new WeakSet,M=new WeakMap,L=new WeakSet,N=[];function A(j){if(!j||T.has(j))return;T.add(j);let D=S.get(j);if(D?.status==="ready")for(let y of D.records){if((j.tagName==="TEMPLATE"&&j.content?j.content:j).childNodes.length!==y.native[0].model.nodes.length+1||!y.owners.every(B))continue;let J=il(y,b);if(!J)continue;let H={record:y,payload:J,state:"planned",output:null,result:null};M.set(y.owner,H),L.add(y.source),L.add(y.native[2].unit),N.push(H)}}function E(j,D){let y=M.get(j);if(!y)return!1;if(!y.result){if(y.result=Ko({...y.payload.nodes,prepared:y.payload.prepared,out:w,policy:c,provenance:p,textMappers:m,conflicts:I,conflict:g,decisions:f,node:D}),y.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");v.push(...y.result.segments),y.decision={kind:"text",node:D,source:"local"},f.push(y.decision)}return y.decision.node=D,D.replaceChildren(...y.result.nodes),y.output=D,y.state="built",!0}function V(j){if(!N.length)return;let D=new WeakSet,y=new WeakMap,k=new WeakMap,J=new WeakMap,H=xe=>xe.tagName==="TEMPLATE"&&xe.content?xe.content:xe,q=(xe,qe)=>{if(!xe)return;if(Array.isArray(xe)){for(let x of xe)q(x,qe);return}let fe=J.get(xe);fe||J.set(xe,fe=[]),fe.push(qe)},Me=(xe,qe=null,fe=!1)=>{D.add(xe),y.set(xe,qe);let x=p.get(xe),Y=fe||!!(x&&r(x.remote||x.base));if(k.set(xe,Y),x)for(let ae of[x.base,x.local,x.remote])q(ae,xe);if(!(x?.pinned||x?.unchanged))for(let ae of H(xe).childNodes)Me(ae,xe,Y)},Oe=xe=>(J.get(xe)||[]).find(qe=>qe.nodeType===1&&!k.get(qe)&&!p.get(qe)?.pinned&&!p.get(qe)?.unchanged),Re=(xe,qe)=>{for(let fe of J.get(xe)||[]){let x=fe;for(;x&&y.get(x)!==qe;)x=y.get(x);if(x)return x}return null},ie=(xe,qe,fe)=>{let x=H(qe);for(let Y=fe.nextSibling;Y;Y=Y.nextSibling){let ae=Re(Y,qe);if(ae){x.insertBefore(xe,ae);return}}for(let Y=fe.previousSibling;Y;Y=Y.previousSibling){let ae=Re(Y,qe);if(ae){x.insertBefore(xe,ae.nextSibling);return}}x.appendChild(xe)};Me(j);for(let xe of N){let{record:qe}=xe,fe=Oe(qe.owner)||Oe(qe.owners[1])||Oe(qe.owners[2]);if(fe)(!xe.result||xe.output!==fe||xe.result.nodes.some(x=>!D.has(x)||y.get(x)!==fe)||fe.textContent!==xe.result.text)&&(E(qe.owner,fe),Me(fe,y.get(fe),k.get(fe)));else{let x=qe.parent,Y=qe.owner,ae=null;for(;x&&!ae;)ae=Oe(x),ae||(Y=x,x=h(x));if(!ae)throw new Error("A cross-parent payload has no allowed surviving parent");fe=xe.output||d(qe.owner,qe.owners[1],qe.owners[2],!1),xe.result||E(qe.owner,fe),ie(fe,ae,Y),Me(fe,ae,k.get(ae))}xe.state="attached"}}return{ensureParent:A,ensureOwner(j){A(h(j))},consumes(j){return L.has(j)},render:E,drain:V}}var Mn=/\S/,Er=/[\p{L}\p{N}]/u;function no(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 h=t(e,n),i=t(o,n),r=null,a=null,d=null,w=null;s(n,h.length+i.length);for(let c of h)Er.test(c.raw)&&(r||=c,a=c);for(let c of i)Er.test(c.raw)&&(d||=c,w=c);return!!(r&&d&&(r.raw===d.raw||a.raw===w.raw))}function ll({base:e,V:o,A:t,source:n,original:s,current:h,edited:i,destination:r,at:a,ownLength:d,eligible:w,model:c,tokensOf:p,budget:m,charge:v}){let I=s.flat.text,g=h.flat.text,f=i.flat.text,b=r.flat.text;if(v(m,I.length+g.length+b.length),I.startsWith(g)||I.endsWith(g))return!1;let B=Mn.test(b.slice(0,a)),S=Mn.test(b.slice(a+d));if(B===S)return!1;let T=B?0:a+d,M=B?a:b.length;for(;T<M&&!Mn.test(b[T]);)T++;for(;M>T&&!Mn.test(b[M-1]);)M--;let L=b.slice(T,M);if(In(L,b,p(r,m),m,v,!0)!==T)return!1;let N=In(L,I,p(s,m),m,v,!0);if(N<0)return!1;let A=N+L.length,E=!Mn.test(I.slice(0,N)),V=!Mn.test(I.slice(A));if(E===V||In(L,g,p(h,m),m,v,!1)>=0)return!1;let j=E?I.slice(A):I.slice(0,N),D=E?f.length-j.length:0;if(v(m,I.length+f.length),D<0||!Mn.test(j)||In(j,f,p(i,m),m,v,!0)!==D||!Mn.test(E?f.slice(0,D):f.slice(j.length)))return!1;for(let y of e){if(v(m,1),y===n||!no(y,w,m,v))continue;let k=c(y,null,m);if(In(L,k.flat.text,p(k,m),m,v,!1)>=0)return!1}for(let y of o.units){if(v(m,1),y===h.unit||y===r.unit||!no(y,w,m,v))continue;let k=c(y,t,m);if(In(L,k.flat.text,p(k,m),m,v,!1)>=0)return!1}return!0}function Pr({base:e,views:o,side:t,attempt:n,eligible:s,blocked:h,baseId:i,model:r,tokensOf:a,charge:d,exhausted:w,limit:c}){if(c<=0)return null;let p=zt(c),{V:m,A:v,idOf:I}=o[t],g=o[1-t],[f,b,B,S]=n,T=null;try{for(let M=f;M<=b;M++){d(p,1);let L=e[M];if(L.parentNode?.nodeType!==1||h.has(L)||v.identical.has(L)||g.A.identical.has(L)||!no(L,s,p,d)||i(L))continue;let N=m.twin(L),A=g.V.twin(L);if(!N||!A||!m.here(N)||!g.V.here(A)||v.map.get(L)!==N||v.reverse.get(N)!==L||g.A.map.get(L)!==A||g.A.reverse.get(A)!==L||I(N)||g.idOf(A)||N.tagName!==L.tagName||A.tagName!==L.tagName||!no(N,s,p,d)||!no(A,s,p,d)||!Ms(L,p,d)||!Ms(N,p,d)||!Ms(A,p,d))continue;let E=r(L,null,p),V=r(N,v,p),j=r(A,g.A,p),D=E.flat.text,y=V.flat.text,k=j.flat.text;if(d(p,D.length+y.length+k.length),!Mn.test(D)||!Mn.test(y)||!Mn.test(k)||D===y||D===k||y===k||!Rr(E,V,a,p,d)||!Rr(E,j,a,p,d))continue;let J=null,H=!1;for(let Oe=B;Oe<=S;Oe++){d(p,1);let Re=m.units[Oe],ie=m.baseOf(Re);if(!ie||ie===L||h.has(ie)||ie.parentNode!==L.parentNode||Re.parentNode!==N.parentNode||ie.tagName!==L.tagName||Re.tagName!==L.tagName||v.map.get(ie)!==Re||v.reverse.get(Re)!==ie||i(ie)!==I(Re)||!no(ie,s,p,d)||!no(Re,s,p,d))continue;let xe=r(ie,null,p),qe=r(Re,v,p),fe=xe.flat.text,x=qe.flat.text;if(d(p,fe.length),!Mn.test(fe)||x.length<=fe.length)continue;let Y=a(qe,p),ae=In(fe,x,Y,p,d,!0);if(!(ae<0||In(D,x,Y,p,d,!0,ae,ae+fe.length)<0&&!ll({base:e,V:m,A:v,source:L,original:E,current:V,edited:j,destination:qe,at:ae,ownLength:fe.length,eligible:s,model:r,tokensOf:a,budget:p,charge:d}))){if(J){H=!0;break}J=Re}}if(!J||H)continue;let q=t===0?N:A,Me=t===0?A:N;(T||=[]).push({source:L,local:q,remote:Me,models:[E,t===0?V:j,t===0?j:V]})}}catch(M){if(M!==w)throw M}return T}var Hn=/\S/,gn=/\s/,al=/[\s\u001e]/g,Os=/[^\s\p{P}\u001e\ufffc]/u;function cl(e,o,t,n,s,h,i){let r=0;for(let a of e)i(h,1),a.nodeType===1&&!n.baseOf(a)&&r++;if(r<2)return!1;for(let a of e){if(a.nodeType!==1||n.baseOf(a))continue;let d=s.get(a).flat;if(d.atoms.length||d.pins?.length)continue;i(h,d.text.length*2+o.length+t.length);let w=new Uint8Array(d.text.length);for(let c of t)c.target===a&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c of o)c.target===a&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c=0;c<d.text.length;c++)if(!w[c]&&Hn.test(d.text[c]))return!0}return!1}function fl(e,o,t){let{source:n,models:s,retained:h,runs:i}=e,r=s.get(n).flat.text;t(o,r.length*2+h.length+i.length);let a=new Uint8Array(r.length);for(let d of h)d.source===n&&(t(o,d.to-d.from),a.fill(1,d.from,d.to));for(let d of i)t(o,d.to-d.from),a.fill(1,d.from,d.to);for(let d=0;d<r.length;d++)if(!a[d]&&Hn.test(r[d]))return!1;return!0}function ul(e,o,t,n,s,h,i,r,a,d){let w=h.get(e),c=h.get(o),p=w.flat.text,m=i.get(e);a(d,p.length*2+t.length);let v=p.length,I=0;for(let b=0;b<p.length;b++)!gn.test(p[b])&&!m[b]&&(v=Math.min(v,b),I=b+1);if(v>=I)return null;for(let b=v;b<I;b++)if(!gn.test(p[b])&&m[b])return null;let g=-1;for(let b of t)if(b.target===o&&b.from<=v&&b.to>v){g=b.targetFrom+v-b.from;break}if(g<0)return null;let f=p.slice(v,I);if(a(d,f.length*(t.length+2)),c.flat.text.slice(g,g+f.length)!==f)return null;for(let b=v;b<I;b++){if(gn.test(p[b]))continue;let B=!1;for(let S of t)if(S.target===o&&S.from<=b&&S.to>b&&S.targetFrom+b-S.from===g+b-v){B=!0;break}if(!B)return null}if(w.flat.atoms.length||c.flat.atoms.length){a(d,w.flat.atoms.length+c.flat.atoms.length);let b=0,B=c.flat.atoms;for(;b<B.length&&B[b].i<g;)b++;for(let S of w.flat.atoms){if(S.i<v||S.i>=I)continue;let T=B[b++];if(!T||T.i!==g+S.i-v||c.alignment?.reverse.get(T.el)!==S.el)return null}if(b<B.length&&B[b].i<g+I-v)return null}for(let[b,B,S]of[[n,e,v],[s,o,g]]){let T=!1;for(let M of b){let L=h.get(M),N=i.get(M),A=r(L,d);for(let E=0;E<A.length;E++){let V=A[E].from,j=V+f.length;if(a(d,f.length*2+1),L.flat.text.slice(V,j)!==f)continue;let D=E;for(;D<A.length&&A[D].to<j;)a(d,1),D++;if(D===A.length||A[D].to!==j)continue;let y=!0;for(let k=V;k<j;k++)if(!gn.test(L.flat.text[k])&&N[k]){y=!1;break}if(y){if(T||M!==B||V!==S)return null;T=!0}}}if(!T)return null}return f}function dl(e,o,t,n,s,h,i,r){if(i(r,s.length+h.length+(n.length+1)*t.length*2),!t)return!1;let a=n.indexOf(t);return a<0||n.lastIndexOf(t)!==a||!h.some(d=>d.from===a)||!h.some(d=>d.to===a+t.length)?!1:s.some(d=>d.source===e&&d.target===o&&d.from===0&&d.to===t.length&&d.targetFrom===a)}function Br({base:e,views:o,eligible:t,baseId:n,ignored:s,remoteWins:h,atomKey:i,limit:r=2e4*8}){if(r<=0)return null;let a=Symbol(),d=(S,T)=>{if(T>S.remaining)throw a;S.remaining-=T},w=[new Map,new Map];for(let S=0;S<2;S++)for(let T=0;T<o[S].V.units.length;T++)w[S].set(o[S].V.units[T],T);let c=new Int32Array(e.length),p=new Int32Array(e.length),m=S=>o.every(({V:T},M)=>{let L=T.twin(S);return L&&w[M].has(L)}),v=-1;for(let S=0;S<e.length;S++)c[S]=v,m(e[S])&&(v=S);v=e.length;for(let S=e.length-1;S>=0;S--)p[S]=v,m(e[S])&&(v=S);let I=new Map,g=(S,T)=>{if(d(T,1),I.has(S))return I.get(S);let M=S.firstChild,L=1;for(;M;){if(d(T,L*8+8),M.nodeType===3&&d(T,M.data.length*8),M.nodeType===1&&Tn.has(M.tagName)&&!s(M)&&!h(M)&&M.firstChild){M=M.firstChild,L++;continue}for(;M&&M!==S&&!M.nextSibling;)M=M.parentNode,L--;M=!M||M===S?null:M.nextSibling}let N=nn(Array.from(S.childNodes),{ignored:s,remoteWins:h});return I.set(S,N),N},f=(S,T,M,L,N,A)=>{for(let E of S.atoms){d(A,1);let V=T.atomAt.get(E.i+M);if(!V)return!1;let j=L?.reverse.get(E.el)||i(E.el),D=N?.reverse.get(V.el)||i(V.el);if(j!==D)return!1}return!0},b=(S,T,M,L,N)=>{let A=S.text.length<=T.text.length?S:T,E=A===S?T:S;if(d(N,A.text.length+E.text.length),!A.text||!Hn.test(A.text.replaceAll(Un,"")))return!1;let V;if(A.text===E.text)V=0;else{let j=E.text.length-A.text.length;if(d(N,(j+1)*A.text.length*2),E.text.startsWith(A.text))V=0;else if(E.text.endsWith(A.text))V=j;else return!1;if(E.text.indexOf(A.text)!==V||E.text.lastIndexOf(A.text)!==V)return!1;d(N,E.text.length*2);let D=0,y=V===0,k=!1;for(let J of an(E.text,xn(E.text)))D+=J.len,D===V&&(y=!0),D===V+A.text.length&&(k=!0);if(!y||!k)return!1}return A===S?f(A,E,V,M,L,N):f(A,E,V,L,M,N)},B=null;for(let S=0;S<2;S++){let{V:T,A:M,idOf:L}=o[S],N=o[1-S];if(!T.asBase)for(let A=0;A<e.length;A++){let E=e[A];if(T.twin(E)||!t(E))continue;let V=N.V.twin(E);if(!V||!w[1-S].has(V)||!t(V))continue;let j={remaining:r};try{let D=c[A],y=p[A],k=0;for(let Me=D+1;Me<y;Me++)d(j,1),!T.twin(e[Me])&&N.V.twin(e[Me])&&t(e[Me])&&k++;if(k!==1||g(E,j).text===g(V,j).text)continue;let J=D<0?-1:w[S].get(T.twin(e[D])),H=y===e.length?T.units.length:w[S].get(T.twin(e[y]));if(J===void 0||H===void 0||J>=H)continue;let q=null;for(let Me=J+1;Me<H;Me++){d(j,1);let Oe=T.units[Me];if(T.baseOf(Oe)||!t(Oe)||Oe.tagName!==E.tagName||Oe.namespaceURI!==E.namespaceURI)continue;let Re=n(E),ie=N.idOf(V),xe=L(Oe);if(!(Re&&ie&&Re!==ie||Re&&xe&&Re!==xe||ie&&xe&&ie!==xe)&&b(g(V,j),g(Oe,j),N.A,M,j)){if(q){q=null;break}q=Oe}}if(!q)continue;B||(B=[new Map,new Map]),B[S].set(E,q)}catch(D){if(D!==a)throw D}}}return B?o.map(({V:S},T)=>{let M=B[T];if(!M.size)return S;let L=new Map;for(let[N,A]of M)L.set(A,N);return{...S,twin:N=>M.get(N)||S.twin(N),baseOf:N=>L.get(N)||S.baseOf(N)}}):null}function Dr({onUncertainSource:e,onUncertainOwner:o,base:t,views:n,eligible:s,ignored:h,remoteWins:i,baseId:r,atomKey:a,limit:d=2e4*32}){if(d<=0)return null;let w=new Set(t),c=new Map(t.map((D,y)=>[D,y])),p=new Map,m=[],v=null,I=null,g=null,f=new Set;for(let D of t)for(let{V:y}of n){let k=y.twin(D);k&&!y.asBase&&!y.here(k)&&f.add(D)}let b=new Set,B=Symbol(),S=(D,y)=>{if(y>D.remaining)throw B;D.remaining-=y},T=(D,y,k)=>{S(k,1);let J=p.get(D);if(J)return J;if(D.nodeType===1){let Me=D.firstChild,Oe=1;for(;Me;){if(S(k,Oe*8+8),Me.nodeType===3&&S(k,Me.data.length*8),Me.nodeType===1&&Tn.has(Me.tagName)&&!h(Me)&&!i(Me)&&Me.firstChild){Me=Me.firstChild,Oe++;continue}for(;Me&&Me!==D&&!Me.nextSibling;)Me=Me.parentNode,Oe--;Me=!Me||Me===D?null:Me.nextSibling}}else S(k,D.value.length*8+D.nodes.length);let H=D.nodeType===1?Array.from(D.childNodes):D.nodes,q=H.length===1&&H[0].nodeType===3?{text:H[0].data,nodes:[{node:H[0],s:0,e:H[0].data.length}],atoms:[]}:nn(H,{ignored:h,remoteWins:i});return J={unit:D,flat:q,alignment:y,tokens:null},p.set(D,J),J},M=(D,y)=>{if(D.tokens)return D.tokens;S(y,D.flat.text.length*8);let{unit:k,flat:J,alignment:H}=D,q=[],Me=xn(J.text),Oe=0,Re=ie=>{for(let xe of an(J.text.slice(Oe,ie),Me))xe.from=Oe,xe.to=Oe+xe.len,xe.unit=k,q.push(xe),Oe+=xe.len};for(let ie of J.atoms){Re(ie.i);let xe=i(ie.el)&&ie.el.nodeType===1?"w"+ie.el.tagName+"#"+(ie.el.id||""):a(H?.reverse.get(ie.el)||ie.el);q.push({k:xe,raw:Un,len:1,from:Oe,to:Oe+1,unit:k,atom:!0}),Oe++}return Re(J.text.length),D.tokens=q,q},L=(D,y,k,J,H)=>{if(!D.flat.atoms.length&&!y.flat.atoms.length)return!0;let q=M(D,H),Me=M(y,H);S(H,q.length+Me.length);let Oe=0;for(let Re of Me){if(!Re.atom||Re.from<k||Re.from>=k+J)continue;for(;Oe<q.length&&!q[Oe].atom;)Oe++;let ie=q[Oe++];if(!ie||ie.from!==Re.from-k||ie.k!==Re.k)return!1}for(;Oe<q.length;)if(q[Oe++].atom)return!1;return!0},N=(D,y,k)=>{let J=D.length+y.length+4;if(J*8>k.remaining)return null;k.remaining-=J*8;let H=Math.floor(k.remaining/8),q=Math.min(D.length+y.length,4e3,Math.floor((Math.sqrt(J*J+H)-J)/2)),Me=4*(q+1)*(J+q+1);if(q<1||Me>k.remaining)return null;k.remaining-=Me;let Oe=Wn(D,y,q),Re=[],ie=0,xe=0;for(let qe of Oe.hunks){for(;ie<qe.bs;)D[ie].raw===y[xe].raw&&Re.push([D[ie],y[xe]]),ie++,xe++;ie=qe.be,xe+=qe.toks.length}for(;ie<D.length&&xe<y.length;)D[ie].raw===y[xe].raw&&Re.push([D[ie],y[xe]]),ie++,xe++;return Re},A=(D,y,k,J,H,q,Me)=>{if(H<=J)return;let Oe=D[D.length-1];if(Oe&&Oe.source===y&&Oe.target===k&&Oe.to<=J&&Oe.targetFrom-Oe.from===q-J){S(Me,(J-Oe.to)*3);let Re=p.get(y).flat.text,ie=p.get(k).flat.text,xe=!0;for(let qe=Oe.to;qe<J;qe++)if(!gn.test(Re[qe])||Re[qe]!==ie[q+qe-J]){xe=!1;break}if(xe){Oe.to=H;return}}D.push({source:y,target:k,from:J,to:H,targetFrom:q})},E=D=>D.replace(al,"");for(let D=0;D<n.length;D++){let{V:y,A:k,idOf:J}=n[D];if(y.asBase)continue;let H=new Map(y.units.map((x,Y)=>[x,Y])),q=x=>{let Y=y.twin(x);return Y&&H.has(Y)?Y:null},Me=(x,Y)=>{let ae=new Int32Array(x.length),oe=new Int32Array(x.length),Ee=-1;for(let je=0;je<x.length;je++)ae[je]=Ee,Y(x[je])&&(Ee=je);Ee=x.length;for(let je=x.length-1;je>=0;je--)oe[je]=Ee,Y(x[je])&&(Ee=je);return{prev:ae,next:oe}},Oe=Me(t,x=>(x.nodeType===1||x.kind==="text"&&Hn.test(x.value))&&q(x)),Re=Me(y.units,x=>(x.nodeType===1||x.kind==="text"&&Hn.test(x.value))&&w.has(y.baseOf(x))),ie=new Map,xe=(x,Y,ae,oe)=>{if(x>Y||ae>oe)return;let Ee=`${x}:${Y}:${ae}:${oe}`;ie.set(Ee,[x,Y,ae,oe])};for(let x=0;x<y.units.length;x++){let Y=y.units[x];if(y.baseOf(Y)||!s(Y))continue;let ae=Re.prev[x],oe=Re.next[x],Ee=ae<0?0:c.get(y.baseOf(y.units[ae])),je=oe===y.units.length?t.length-1:c.get(y.baseOf(y.units[oe]));xe(Ee,je,Math.max(0,ae),Math.min(y.units.length-1,oe))}for(let x=0;x<t.length;x++){let Y=t[x];if(f.has(Y)||!s(Y))continue;if(!y.twin(Y)){let tt=Oe.prev[x],Xe=Oe.next[x],dt=tt<0?0:H.get(q(t[tt])),Ge=Xe===t.length?y.units.length-1:H.get(q(t[Xe]));xe(Math.max(0,tt),Math.min(t.length-1,Xe),dt,Ge)}let ae=q(Y);if(!ae||k.identical.has(Y)||!s(ae))continue;let oe=x+1;for(;oe<t.length&&t[oe].kind==="text"&&!t[oe].value.trim();)oe++;if(oe>=t.length||!s(t[oe]))continue;let Ee=q(t[oe]);if(!Ee||k.identical.has(t[oe])||!s(Ee))continue;let je=H.get(ae),Ne=H.get(Ee);je<Ne&&xe(x,oe,je,Ne)}let qe=Array.from(ie.values()),fe=new Set;if(qe.length>1){let x=zt(d);try{S(x,qe.length*4);let Y=qe.slice().sort((Ee,je)=>(S(x,1),Ee[0]-je[0]||Ee[2]-je[2])),ae=[],oe=null;for(let Ee of Y)S(x,1),oe&&Ee[0]<=oe[1]&&Ee[2]<=oe[3]&&Ee[3]>=oe[2]?(oe[1]=Math.max(oe[1],Ee[1]),oe[2]=Math.min(oe[2],Ee[2]),oe[3]=Math.max(oe[3],Ee[3]),oe[4].push(Ee)):(oe?.[4].length>1&&ae.push(oe),oe=[Ee[0],Ee[1],Ee[2],Ee[3],[Ee]]);oe?.[4].length>1&&ae.push(oe),qe=ae.concat(qe)}catch(Y){if(Y!==B)throw Y}}for(let x of qe){if(fe.has(x))continue;let[Y,ae,oe,Ee,je]=x,Ne=zt(d),tt=[],Xe=new Set,dt=!1;try{S(Ne,(ae-Y+Ee-oe+2)*4);let Ge=t.slice(Y,ae+1).filter(U=>!k.identical.has(U)&&s(U)&&!f.has(U)),st=y.units.slice(oe,Ee+1).filter(U=>s(U)&&(!y.baseOf(U)||w.has(y.baseOf(U)))&&!k.identical.has(y.baseOf(U))&&!f.has(y.baseOf(U))),Ot=new Set(st),Ct=!1,yt="",Nt="",Lt=0;for(let U of Ge){let de=T(U,null,Ne);yt+=de.flat.text,Lt+=de.flat.text.length}for(let U of st){let de=T(U,k,Ne);Nt+=de.flat.text,Lt+=de.flat.text.length}S(Ne,Lt);let qt=E(yt),cn=E(Nt),It=qt===cn;if(dt=It,je&&!It)continue;let $t=It?null:new Map;if($t)for(let U of Ge.concat(st)){let de=p.get(U).flat.text.length;S(Ne,de*16),$t.set(U,new Uint8Array(de))}let wn=U=>{let de=[];for(let we of U){let le=p.get(we);le.flat.atoms.length?de.push(...M(le,Ne)):de.push({unit:we,raw:le.flat.text,from:0})}return de},jt=[];for(let U of It?[]:Ge){let de=q(U);if(!Ot.has(de))continue;let we=T(U,null,Ne),le=T(de,k,Ne);S(Ne,we.flat.text.length+le.flat.text.length);let Ae=we.flat.text&&le.flat.text.startsWith(we.flat.text)?0:we.flat.text&&le.flat.text.endsWith(we.flat.text)?le.flat.text.length-we.flat.text.length:-1;if(Ae>=0&&L(we,le,Ae,we.flat.text.length,Ne)){$t.get(U).fill(1),$t.get(de).fill(1,Ae,Ae+we.flat.text.length),A(jt,U,de,0,we.flat.text.length,Ae,Ne);continue}let W=N(M(we,Ne),M(le,Ne),Ne);if(!W){Ct=!0;break}for(let[X,pe]of W)$t.get(U).fill(1,X.from,X.to),$t.get(de).fill(1,pe.from,pe.to),A(jt,U,de,X.from,X.to,pe.from,Ne)}if(Ct)continue;let rn=null,Gt=null;if(!It)for(let U of Ge){let de=q(U),we=p.get(U);if(!de||we.flat.atoms.length||!Ot.has(de))continue;let le=we.flat.text,Ae=$t.get(U);S(Ne,le.length*3+st.length);let W=-1,X=-1,pe=!1;for(let Pe=0;Pe<le.length;Pe++)gn.test(le[Pe])||(Ae[Pe]?pe=!0:(W<0&&(W=Pe),X=Pe+1));if(!pe||W<0)continue;let be=!0;for(let Pe=W;Pe<X;Pe++)if(Ae[Pe]&&!gn.test(le[Pe])){be=!1;break}if(!be)continue;let he=E(le.slice(W,X)),ee=null,te=!1;for(let Pe of st){if(y.baseOf(Pe))continue;let ve=p.get(Pe);if(!ve.flat.atoms.length&&(S(Ne,ve.flat.text.length),E(ve.flat.text)===he)){if(ee){te=!0;break}ee=Pe}}if(te){(Gt||=new Set).add(U);continue}if(!ee||Gt?.has(U))continue;let z=!1;for(let Pe of Ge){if(Pe===U||!Ot.has(q(Pe)))continue;let ve=p.get(Pe);if(ve.flat.atoms.length)continue;let _e=$t.get(Pe);S(Ne,ve.flat.text.length*3);let Je="",Ze=!1;for(let Ut=0;Ut<ve.flat.text.length;Ut++)gn.test(ve.flat.text[Ut])||(_e[Ut]?Ze=!0:Je+=ve.flat.text[Ut]);Ze&&Je===he&&(Gt||=new Set,Gt.add(U),Gt.add(Pe),z=!0)}if(z)continue;let ne=p.get(ee).flat.text;S(Ne,X-W+ne.length);let Te=W,Ce=0;for(;Te<X&&Ce<ne.length;){for(;Te<X&&gn.test(le[Te]);)Te++;for(;Ce<ne.length&&gn.test(ne[Ce]);)Ce++;if(Te>=X||Ce>=ne.length)break;A(rn||=[],U,ee,Te,Te+1,Ce,Ne),Te++,Ce++}Ae.fill(1,W,X),$t.get(ee).fill(1)}let fn=U=>{let de=[];for(let we of U){let le=T(we,w.has(we)?null:k,Ne),Ae=$t.get(we);for(let W of M(le,Ne)){let X=W.from;for(;X<W.to;){for(;X<W.to&&Ae[X];)X++;let pe=X;for(;X<W.to&&!Ae[X];)X++;if(X>pe){let be=le.flat.text.slice(pe,X);Hn.test(be)&&de.push({...W,raw:be,len:X-pe,k:W.atom?W.k:be,from:pe,to:X})}}}}return de},$=It?wn(Ge):fn(Ge),l=It?wn(st):fn(st),O=It?qt:$.map(U=>E(U.raw)).join(""),R=It?cn:l.map(U=>E(U.raw)).join("");if((!O||!R)&&!rn)continue;let K=rn||[];if(O&&R&&O===R){let U=0,de=0,we=0,le=0;for(;U<$.length&&de<l.length;){let Ae=$[U],W=l[de];for(;we<Ae.raw.length&&gn.test(Ae.raw[we]);)we++;for(;le<W.raw.length&&gn.test(W.raw[le]);)le++;if(we===Ae.raw.length){U++,we=0;continue}if(le===W.raw.length){de++,le=0;continue}if((Ae.atom||W.atom)&&Ae.k!==W.k){Ct=!0;break}A(K,Ae.unit,W.unit,Ae.from+we,Ae.from+we+1,W.from+le,Ne),we++,le++}}else if(O&&R){let U=N($,l,Ne);if(!U)continue;for(let[de,we]of U)A(K,de.unit,we.unit,de.from,de.to,we.from,Ne)}if(Ct)continue;let Z=new Map;for(let U of K)if(!Gt?.has(U.source)){if(q(U.source)===U.target){It&&jt.push(U);continue}Z.has(U.source)||Z.set(U.source,[]),Z.get(U.source).push(U)}for(let[U,de]of Z){let we=T(U,null,Ne),le=q(U),Ae=we.flat.text,W=[],X=new Set,pe=n[1-D],be=pe.V.twin(U),he=be&&pe.V.here(be)?T(be,pe.A,Ne):null,ee=(ve,_e)=>{let Je=M(ve,Ne),Ze=M(_e,Ne);return S(Ne,ve.flat.text.length+_e.flat.text.length+Je.length+Ze.length),ve.flat.text===_e.flat.text&&Je.length===Ze.length&&Je.every((Ut,Pt)=>Ut.k===Ze[Pt].k)},te=le&&he&&he.flat.text!==Ae&&ee(T(le,k,Ne),he);for(let ve of new Set(de.map(_e=>_e.target))){if(U.nodeType!==1&&ve.nodeType!==1)continue;let _e=T(ve,k,Ne),Je=y.baseOf(ve);if(U.nodeType!==1&&Je||(S(Ne,Ae.length*2+_e.flat.text.length*3+jt.length*2),le&&E(Ae)===E(_e.flat.text)&&T(le,k,Ne).flat.text.trim()))continue;if(!le&&!Je&&U.nodeType===1&&ve.nodeType===1){let G=r(U),re=J(ve);if(G&&re&&G!==re)continue}let Ze=_e.flat.text,Ut=Ae&&(Ze.startsWith(Ae)||Ze.endsWith(Ae)),Pt=!1;if(!le&&he&&Je&&he.flat.text!==Ae){let G=T(Je,null,Ne).flat.text,re=c.get(U)<c.get(Je)?he.flat.text:G,ge=c.get(U)<c.get(Je)?G:he.flat.text;S(Ne,re.length+ge.length+Ze.length),Pt=!!re&&!!ge&&re.length+ge.length<=Ze.length&&Ze.startsWith(re)&&Ze.endsWith(ge)&&!Ze.slice(re.length,Ze.length-ge.length).trim()}let C=!we.flat.atoms.length&&!he?.flat.atoms.length&&!_e.flat.atoms.length&&(te&&Ut||Pt);if(le&&Je){let G=T(le,k,Ne).flat.text,re=Ae.startsWith(G)||Ae.endsWith(G),ge=T(Je,null,Ne).flat.text,ye=_e.flat.text,ce=ye.startsWith(ge)||ye.endsWith(ge),se=!n[1-D].V.twin(Je)&&!jt.some(Ie=>Ie.source===Je&&Hn.test(ge.slice(Ie.from,Ie.to)));if(!It&&(!re&&!C||!ce&&!se)){let Ie=ul(U,ve,de,Ge,st,p,$t,M,S,Ne);if(!Ie)continue;let Be=k.weak?.has(U)&&!k.identityPaired?.has(U)&&Ae.trim()===Ie;if(!re&&!C&&!Be)continue;let He=k.weak?.has(Je)&&!k.identityPaired?.has(Je)&&Ze.trim()===Ie&&!p.get(Je).flat.atoms.length&&!jt.some(Ke=>Ke.source===Je&&Hn.test(ge.slice(Ke.from,Ke.to)));if(!ce&&!se&&!He&&!dl(Je,ve,ge,Ze,jt,M(_e,Ne),S,Ne))continue;Be&&X.add(ve)}}C&&X.add(ve),S(Ne,de.length),W.push(...de.filter(G=>G.target===ve))}if(!W.length)continue;let z=new Uint8Array(Ae.length);S(Ne,Ae.length*4+jt.length);for(let ve of W)z.fill(1,ve.from,ve.to);let ne=[];for(let ve=0;ve<Ae.length;ve++)gn.test(Ae[ve])||ne.push(ve);if(!ne.length)continue;let Te=new Set(W.map(ve=>ve.target));if(!It&&le&&Te.size>1&&cl(Te,K,jt,y,p,Ne,S)){if(g||=new Map,g.set(U,(g.get(U)||0)|1<<D),e){let ve=ws({source:U,side:D,views:n,eligible:s,blocked:f,baseId:r,model:T,tokensOf:M,budget:Ne,charge:S});if(ve){S(Ne,ve.to-ve.from);let _e=!0;for(let Je=ve.from;Je<ve.to;Je++)if(Hn.test(Ae[Je])&&!z[Je]){_e=!1;break}_e&&(v||=[]).push(ve)}}continue}let Ce=ne.filter(ve=>Os.test(Ae[ve]));if(!W.some(ve=>Os.test(Ae.slice(ve.from,ve.to)))&&!ne.every(ve=>z[ve]))continue;if(!le&&!Array.from(Te).some(ve=>X.has(ve))&&!ne.every(ve=>z[ve])&&!(Ce.length&&z[Ce[0]]&&z[Ce[Ce.length-1]]&&Te.size===1)){let ve=null,_e=0,Je=0,Ze=null,Ut=null;if(!le&&he&&U.nodeType===1&&!we.flat.atoms.length){let Pt=M(we,Ne).filter(C=>Os.test(C.raw));S(Ne,st.length+Ae.length);for(let C of st){let G=y.baseOf(C);if(!G||G===U||G.nodeType!==1||C.nodeType!==1||G.tagName!==U.tagName||C.tagName!==G.tagName)continue;let re=c.get(U),ge=c.get(G),ye=!0;for(let ht=Math.min(re,ge)+1;ht<Math.max(re,ge);ht++){let Kt=t[ht];if(S(Ne,Kt.nodeType===1?1:Kt.value.length+1),Kt.nodeType===1||Kt.value.trim()){ye=!1;break}}if(!ye)continue;let ce=T(G,null,Ne),se=T(C,k,Ne);if(ce.flat.atoms.length||se.flat.atoms.length)continue;let Ie=ce.flat.text,Be=se.flat.text;if(S(Ne,Ie.length+Be.length+Ae.length),!Ie||!Pt.length)continue;let He=0,Ke=Be.length;if(re<ge&&Be.endsWith(Ie))Ke-=Ie.length;else if(re>ge&&Be.startsWith(Ie))He=Ie.length;else continue;for(;He<Ke&&gn.test(Be[He]);)He++;for(;Ke>He&&gn.test(Be[Ke-1]);)Ke--;let pt=Be.slice(He,Ke);if(!(!pt||!(pt.startsWith(Pt[0].raw)||pt.endsWith(Pt[Pt.length-1].raw)))){if(ve){ve=null;break}ve=C,_e=He,Je=Ke,Ze=Pt[0],Ut=Pt[Pt.length-1]}}}if(S(Ne,W.length),!ve||!Te.has(ve)||!W.some(Pt=>Pt.target===ve&&(Pt.from<=Ze.from&&Pt.to>=Ze.to&&Pt.targetFrom+Ze.from-Pt.from===_e||Pt.from<=Ut.from&&Pt.to>=Ut.to&&Pt.targetFrom+Ut.to-Pt.from===Je)))continue}if(le&&!(ne.every(ve=>z[ve])&&(It||Array.from(Te).some(ve=>X.has(ve))))&&!jt.some(ve=>ve.source===U&&Hn.test(Ae.slice(ve.from,ve.to))))continue;let Pe=!1;if(It){S(Ne,jt.length+ne.length);for(let ve of jt)ve.source===U&&(S(Ne,ve.to-ve.from),z.fill(1,ve.from,ve.to));Pe=!0;for(let ve of ne)if(!z[ve]){Pe=!1;break}}for(let ve of Te){S(Ne,W.length);let _e=W.filter(Ze=>Ze.target===ve);tt.push({side:D,source:U,target:ve,runs:_e,models:p,retained:jt,conservedSource:Pe}),U.nodeType===1&&Xe.add(U),ve.nodeType===1&&Xe.add(ve);let Je=y.baseOf(ve);Je?.nodeType===1&&Xe.add(Je)}}if(m.push(...tt),je&&tt.length)for(let U of je)fe.add(U);for(let U of Xe)b.add(U)}catch(Ge){if(Ge!==B)throw Ge}finally{if(o&&!je&&!dt){let Ge=Pr({base:t,views:n,side:D,attempt:x,eligible:s,blocked:f,baseId:r,model:T,tokensOf:M,charge:S,exhausted:B,limit:d});Ge&&(I||=[]).push(...Ge)}if(e&&!je&&!dt){let Ge=zs({base:t,views:n,side:D,attempt:x,eligible:s,blocked:f,baseId:r,model:T,tokensOf:M,certificates:m,charge:S,exhausted:B,limit:d});Ge&&(v||=[]).push(...Ge)}}}}let V=m.length?new Map:null;for(let D of m){let y=V.get(D.source);y||V.set(D.source,y=[]),y.push(D)}let j=null;if(V){let D=null;for(let[y,k]of V){let J=g?.get(y)||0;if(k.length<2&&!J)continue;let H=0;for(let q of k)q.conservedSource&&(H|=1<<q.side);for(let q of k){if(q.conservedSource)continue;let Me=1<<q.side,Oe=!0;if(H&Me)Oe=!1;else if(J&Me){Oe=!1;try{Oe=fl(q,D||=zt(d),S)}catch(Re){if(Re!==B)throw Re}}Oe||(j||=new Set).add(q)}}}if(j){let D=0;for(let y of m)j.has(y)||(m[D++]=y);m.length=D;for(let[y,k]of V){D=0;for(let J of k)j.has(J)||(k[D++]=J);k.length=D,D||V.delete(y)}b.clear();for(let y of m){let{source:k,target:J,side:H}=y;k.nodeType===1&&b.add(k),J.nodeType===1&&b.add(J);let q=n[H].V.baseOf(J);q?.nodeType===1&&b.add(q)}}if(v){let D=zt(d),y=!1;for(let k of v){let J=!1,H=V?.get(k.source);if(H&&!y)try{J=bs(k,H,D,S)}catch(q){if(q!==B)throw q;y=!0}J||e(k)}}if(I){let D=new Set,y=zt(d);try{for(let k of I){if(S(y,1),D.has(k.source))continue;D.add(k.source);let J=!1;for(let H of m)if(S(y,1),H.source===k.source||H.target===k.local||H.target===k.remote){J=!0;break}J||o(k)}}catch(k){if(k!==B)throw k}}for(let D of t)if(b.has(D))for(let{V:y}of n){let k=y.twin(D);k&&y.here(k)&&b.add(k)}return m.length?{blocks:b,certificates:m,certificatesBySource:V,models:p}:null}function jr({certificates:e,scopes:o,flats:t,keys:n,limit:s=2e4*32}){let h=Symbol(),i=zt(s),r=g=>{if(g>i.remaining)throw h;i.remaining-=g},a=o.map(g=>new Set(g)),d=new Map,w=new Map,c=(g,f)=>{let b=d.get(g);if(b||d.set(g,b=new Map),b.has(f))return b.get(f);r(g.text.length);let B=w.get(f);if(!B){r(f.nodes.length+f.atoms.length),B={nodes:new Map,atoms:new Map};for(let L of f.nodes)B.nodes.set(L.node,L);for(let L of f.atoms)B.atoms.set(L.el,L.i);w.set(f,B)}let{nodes:S,atoms:T}=B,M=new Int32Array(g.text.length).fill(-1);for(let L of g.nodes){let N=S.get(L.node);if(!(!N||L.e-L.s!==N.e-N.s)){r(L.e-L.s);for(let A=L.s;A<L.e;A++)M[A]=N.s+A-L.s}}for(let L of g.atoms){let N=T.get(L.el);N!==void 0&&(M[L.i]=N)}return b.set(f,M),M},p=(g,f,b,B,S)=>{let T=g[g.length-1];T&&T.to===f&&T.target+T.to-T.from===B&&T.kind===S?T.to=b:g.push({from:f,to:b,target:B,kind:S})},m=(g,f,b,B)=>{r((B-b)*4);let S=[],T=b,M=A=>{let E=g.text.slice(T,A);for(let V of an(E,xn(E)))V.from=T,V.to=T+V.len,S.push(V),T+=V.len},L=0,N=g.atoms.length;for(;L<N;){r(1);let A=L+N>>>1;g.atoms[A].i<b?L=A+1:N=A}for(let A=L;A<g.atoms.length&&g.atoms[A].i<B;A++){r(1);let E=g.atoms[A];M(E.i),S.push({k:f(E),raw:Un,len:1,from:T,to:T+1}),T++}return M(B),S},v=(g,f,b,B,S,T)=>{if(b===B||S===T)return;if(B-b===T-S){r((B-b)*4);let y=!0;for(let k=b,J=S;k<B;k++,J++){if(t[0].text[k]!==t[f].text[J]){y=!1;break}let H=t[0].atomAt.get(k),q=t[f].atomAt.get(J);if(!!H!=!!q||H&&n[0](H)!==n[f](q)){y=!1;break}}if(y){p(g,b,B,S,"retained");return}}let M=m(t[0],n[0],b,B),L=m(t[f],n[f],S,T),N=M.length+L.length+4,A=Math.min(M.length+L.length,4e3,Math.floor((Math.sqrt(N*N+i.remaining/2)-N)/2));if(A<1)throw h;r(4*(A+1)*(N+A+1));let E=Wn(M,L,A),V=0,j=0,D=()=>{let y=M[V++],k=L[j++];r(y.len),y.raw===k.raw&&p(g,y.from,y.to,k.from,"retained")};for(let y of E.hunks){for(;V<y.bs;)D();V=y.be,j+=y.toks.length}for(;V<M.length&&j<L.length;)D()},I=g=>{let f=e.filter(E=>E.side===g-1&&a[0].has(E.source)&&a[g].has(E.target));if(!f.length)return null;let b=[],B=(E,V,j)=>{if(!a[0].has(E.source)||!a[g].has(E.target))return;let D=c(V.get(E.source).flat,t[0]),y=c(V.get(E.target).flat,t[g]);r(E.to-E.from);for(let k=0;k<E.to-E.from;k++){let J=D[E.from+k],H=y[E.targetFrom+k];if(J<0||H<0)throw h;p(b,J,J+1,H,j)}},S=new Set;for(let E of f){if(!S.has(E.retained)){S.add(E.retained);for(let V of E.retained)B(V,E.models,"retained")}for(let V of E.runs)B(V,E.models,"transfer")}b.sort((E,V)=>(r(1),E.from-V.from||E.target-V.target));let T=[];for(let E of b){r(1);let V=T[T.length-1];if(V&&E.from<V.to){if(E.target-E.from!==V.target-V.from)throw h;V.to=Math.max(V.to,E.to),E.kind==="transfer"&&(V.kind="transfer")}else T.push(E)}let M=[],L=0,N=0;for(let E of T){if(E.target<N)throw h;v(M,g,L,E.from,N,E.target),M.push(E),L=E.to,N=E.target+E.to-E.from}v(M,g,L,t[0].text.length,N,t[g].text.length);let A=jn({base:t[0],side:t[g],retained:M.filter(E=>E.kind==="retained"),transfers:M.filter(E=>E.kind==="transfer"),baseAtomKey:n[0],sideAtomKey:n[g],budget:i});if(A.status!=="ready"||!A.monotone)throw h;return A};try{let g=I(1),f=I(2);return g||f?{local:g,remote:f}:{fallback:!0}}catch(g){if(g!==h)throw g;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 h=[];for(let i=n;i>=0&&i<=s;i++){let r=e.list[i],a=!t&&i===n?r.inlineStart<0?r.to:r.inlineStart:r.from,d=!t&&i===s?r.inlineEnd<0?r.from:r.inlineEnd:r.to;for(let w=a;w<d;w++)h.push(e.units[w]);i<s&&h.push(e.units[r.next])}return h}var rt=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 Cs(e){for(let o of e)if(Ln.has(o.tagName))return!0;return!1}function hl(e,o,t){let n=null;for(let s of o.childNodes)if(!(!rt(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 Co="[id],[data-id],script,head>*";function Ls(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=ho(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,h=n.stats||zn(),i=Ws({ignored:s,ignoreAttribute:n.ignoreAttribute,stats:h}),{unitsOf:r,meta:a}=i,d=n.baseURI,w=n.mergeTags!==null,c=Ls(n.mergeTags,d),p=C=>G=>{let re=c(G);return re!==null?re:C(G)},m=p(n.identity.base),v=p(n.identity.local),I=p(n.identity.remote),g=n.authored||n.identity,f=C=>C&&C.nodeType===9?C.documentElement:C,b=f(e),B=f(o),S=f(t),T=globalThis.__hyperMorphProfile,M=T?performance.now():0,L=C=>C===kn?Co:null,N=n.scope||null,A=N?N.baseDropped:new Set,E=new Set,V=N?N.remoteDropped:new Set,j=N?N.baseIndex:Uo(b,m,s,L(n.identity.base),A),D=n.localIsBase||b===B?null:Uo(B,v,s,L(n.identity.local),E),y=N?N.remoteIndex:Uo(S,I,s,L(n.identity.remote),V),k=C=>{let G=rt(C)&&v(C);return G&&D?.get(G)===C&&!j.has(G)?G:null},J=C=>{let G=rt(C)&&I(C);return G&&y.get(G)===C&&!j.has(G)?G:null},H=D?as(b,B,{analyzer:i,baseIndex:j,sideIndex:D,baseId:g.base,sideId:g.local,baseKey:m,sideKey:v,baseDropped:A,sideDropped:E,stats:h}):Vr(),q=as(b,S,{analyzer:i,baseIndex:j,sideIndex:y,baseId:g.base,sideId:g.remote,baseKey:m,sideKey:I,baseDropped:A,sideDropped:V,stats:h,scope:N,comparisons:n.comparisons});if(N){if(!N.held(q))return null;for(let C of N.dropped)is(C)}let Me=null;function Oe(C){if(!Me){Me=new WeakMap;let G=[b];for(;G.length;){let re=G.pop();re.tagName==="TEMPLATE"&&re.content&&Me.set(re.content,re);for(let ge of i.childrenOf(re))ge.nodeType===1&&G.push(ge)}}return Me.get(C)||null}let Re=C=>{let G=rt(C)||C.nodeType?C.parentNode:C.parent;return G&&G.nodeType===11?Oe(G):G};if(q.moved.size){let C=!1;for(let G of Array.from(q.moved))!rt(G)||q.identityPaired.has(G)||!g.base(G)||l(q,Re(G))||(q.unpair(G),C=!0);C&&q.rematch()}fn(),$(H,q),$(q,H);for(let C of[H,q])if(C.refused)for(let G of C.refused)C.moved.has(G)||h.ambiguousMoves++;T&&(T.alignTotal=(T.alignTotal||0)+(performance.now()-M),M=performance.now());let ie=b.ownerDocument.implementation.createHTMLDocument(""),xe=new WeakMap,qe=new WeakMap,fe=[],x=[],Y=new Set,ae=[],oe=new Set,Ee=new Set,je=new Set,Ne=new WeakMap,tt=null,Xe=n.lineage?.locals.length?rr():null,dt=C=>{let G=Ko(C);return G&&Xe&&Xe.consume(C.local),G},Ge=n.conflicts||"remote",st=C=>fe.push(C),Ot=C=>fe.push(C),Ct=Or({roots:{base:b,local:B,remote:S},L:H,R:q,unitsOf:r,provenance:xe,policy:Ge}),yt=(C,G)=>{x.push(C),G&&Ct.note(C,G)},Nt=null,Lt=null,qt=rn(),cn=null,It=U(b,H.map.get(b),q.map.get(b),!!n.localIsBase,!!n.childrenOnly);It.tagName==="HTML"?ie.replaceChild(It,ie.documentElement):ie.body.appendChild(It),Nt?.drain(It),Lt?.drain(It),T&&(T.build=(T.build||0)+(performance.now()-M));let $t=n.childrenOnly?!Pe(Te(It),Te(S)):!te(It,S),wn=Ct.finish(It),jt=Xe?ir({locals:n.lineage.locals,rec:Xe,root:It,provenance:xe,segments:ae,ignored:s}):null;return{doc:ie,root:It,provenance:xe,textMappers:qe,decisions:fe,conflicts:x,recoveryLinks:wn,localDiverged:$t,mergedScripts:Y,segments:ae,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==kn,L:H,R:q,stats:h,lineage:jt};function rn(){let C=new Map,G=new Set;if(n.localIsBase||!H.insertedByHash)return{partner:C,drop:G};let re=H.insertedByHash(),ge=q.insertedByHash();if(!re.size||!ge.size)return{partner:C,drop:G};let ye={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ce=it=>{let $e=0;for(let vt=it.parentNode;vt;vt=vt.parentNode)$e++;return $e},se=[],Ie=it=>{let $e=it.textContent.trim();return $e.split(/\s+/).length>=3||$e.replace(/\s/g,"").length>=12},Be=it=>{let $e=l(H,it),vt=l(q,it);return $e&&H.reverse.get($e.parentNode)!==it.parentNode||vt&&q.reverse.get(vt.parentNode)!==it.parentNode},He=(it,$e,vt)=>{for(let Dt of vt.parentNode.children){let bn=Dt!==vt&&it.reverse.get(Dt);if(bn&&Be(bn))return!0}let at=it.reverse.get(vt.parentNode);if(at){for(let Dt of at.children)if(!l($e,Dt)&&!s(Dt))return!0}return!1},Ke=new Map([[H,new Map],[q,new Map]]),pt=(it,$e)=>{let vt=Ke.get(it),at=vt.get($e);if(at===void 0){at=!1;for(let Dt of $e.children)if(it.reverse.has(Dt)||pt(it,Dt)){at=!0;break}vt.set($e,at)}return at},ht=new Map;for(let it of ge.values())for(let $e of it){let vt=J($e);vt&&ht.set(vt,$e)}for(let it of re.values())for(let $e of it){let vt=k($e),at=vt?ht.get(vt):null;at&&at.tagName===$e.tagName&&!Vn($e,ye)&&!Vn(at,ye)&&!n.remoteWins($e)&&!n.remoteWins(at)&&se.push([$e,[at],ce($e),!0,!0])}for(let[it,$e]of re){let vt=ge.get(it);if(!vt)continue;let at=$e.length===1&&vt.length===1;for(let Dt of $e)!Vn(Dt,ye)&&!k(Dt)&&se.push([Dt,vt,ce(Dt),at&&(Ie(Dt)||He(H,q,Dt)||He(q,H,vt[0]))])}if(!se.length)return{partner:C,drop:G};se.sort((it,$e)=>it[2]-$e[2]);let Kt=new Set,Ht=new Set,un=it=>{for(let $e of it.querySelectorAll("*"))Kt.add($e)},bt=(it,$e)=>it.reverse.get($e.parentNode)||null;for(let[it,$e,,vt,at]of se){if(Kt.has(it)||Ht.has(it)||at&&(pt(H,it)||pt(q,$e[0])))continue;let Dt=bt(H,it),bn=Yt=>!Ht.has(Yt)&&!Kt.has(Yt)&&(at||Yt.tagName===it.tagName&&!J(Yt)&&i.equalUnits(it,Yt)),on=$e.find(Yt=>Dt&&bt(q,Yt)===Dt&&bn(Yt))||(vt?$e.find(bn):null);if(!on)continue;Ht.add(it),Ht.add(on);let hn=Dt&&bt(q,on)===Dt;(!at||!hn||i.equalUnits(it,on))&&(un(it),un(on)),!hn&&(C.set(it,on),C.set(on,it),G.add(Ge==="local"?on:it))}return{partner:C,drop:G}}function Gt(C,G,re){if(oe.add(C),qt.drop.has(C))return null;oe.add(re);let ge=G==="local"?C:re,ye=G==="local"?re:C,ce;return i.equalUnits(ge,ye)?(ce=he(ge,"local",!0),xe.get(ce).remote=ye):ce=be(ge,ye),yt({kind:"structure",el:ce,detail:"both-moved",base:null,local:ge,remote:ye},{unit:{b:null,l:ge,r:ye}}),st({kind:"insert",el:ce,source:"both"}),ce}function fn(){if(!H.weak||!q.weak||!H.weak.size||!q.weak.size||!H.unpair)return;let C=new Map;for(let re of H.weak){let ge=l(H,re);rt(re)&&rt(ge)&&C.set(i.unitHash(ge),re)}let G=!1;for(let re of Array.from(q.weak)){let ge=l(q,re);if(!rt(re)||!rt(ge))continue;let ye=C.get(i.unitHash(ge));if(!ye||ye===re||!H.weak.has(ye)||l(H,re)&&l(q,ye))continue;let ce=l(H,ye);ce.tagName===ge.tagName&&i.equalUnits(ce,ge)&&(H.unpair(ye),q.unpair(re),G=!0)}G&&(H.rematch(),q.rematch())}function $(C,G){if(!C.weak||!C.weak.size||!G.insertedByHash)return;let re=G.insertedByHash();if(!re.size)return;let ge=!1;for(let ye of Array.from(C.weak)){let ce=l(C,ye);if(!ce)continue;let se=C===H?k(ce):J(ce);if(se){let Be=(C===H?y:D)?.get(se);Be&&Be.tagName===ce.tagName&&!G.reverse.has(Be)&&(C.unpair(ye),ge=!0);continue}let Ie=re.get(i.unitHash(ce));Ie&&Ie.some(Be=>Be.tagName===ce.tagName&&i.equalUnits(Be,ce))&&(C.unpair(ye),ge=!0)}ge&&C.rematch()}function l(C,G){if(!G)return null;if(C.map.has(G))return C.map.get(G);let re=[],ge=Re(G);for(;ge&&!C.map.has(ge);ge=Re(ge))re.push(ge);let ye=ge;if(!ye||!C.identical.has(ye))return null;C.pairIdenticalChildren(ye);for(let se=re.length-1;se>=0;se--)C.pairIdenticalChildren(re[se]);let ce=C.map.get(G)||null;return ce&&h.lazyTwins++,ce}function O(C,G,re,ge){if(rt(C)&&Ln.has(C.tagName)&&!H.identical.has(C)&&(C.previousSibling?.nodeType===3||C.nextSibling?.nodeType===3)){let Ie=Re(C),Be=l(H,C),He=l(q,C);Be&&He&&Ut(Be,l(H,Ie),H)&&!Ut(He,l(q,Ie),q)&&(Lt||=Lr({L:H,R:q,twinIn:l,unitsOf:r,view:R,parentOf:Re,ignored:s,remoteWins:n.remoteWins,eligible:Ke=>rt(Ke)&&Ln.has(Ke.tagName),build:U,out:ie,policy:Ge,provenance:xe,textMappers:qe,segments:ae,conflicts:x,conflict:yt,decisions:fe}),Lt.ensureOwner(C))}if(G===null)return null;if(ge!==void 0)return Nt||=go(xe,Re,H,q,l,U,s,n.remoteWins,x,yt,K,B,S),Nt.plan(C,G,re,!!ge),ge&&(Nt.produced(C,ge),Ee.add(C)),ge;if(Ee.has(C)||je.has(C))return yt({kind:"structure",el:null,detail:"both-moved",base:C},{subject:C}),Ee.has(C)?null:he(re,G);Nt||=go(xe,Re,H,q,l,U,s,n.remoteWins,x,yt,K,B,S),Nt.plan(C,G,re,!0);let ye=l(H,C),ce=l(q,C);(!ye||!ce)&&yt({kind:"structure",el:null,detail:"move-beats-delete",base:C},{subject:C,deleted:ye?"remote":"local"});let se=U(C,ye,ce,!1);return(G==="local"?st:Ot)({kind:"move",el:se,source:G}),se}function R(C,G,re,ge){return ge||!G||G===re?{el:re,asBase:!0,twin:ye=>ye,baseOf:ye=>ye,units:r(re),here:()=>!0,parentOfTwin:()=>re}:{el:G,asBase:!1,twin:ye=>l(C,ye),baseOf:ye=>C.reverse.get(ye),units:r(G),here:ye=>rt(ye)?ye.parentNode===G||G.tagName==="TEMPLATE"&&ye.parentNode===G.content:ye.parent===G||G.tagName==="TEMPLATE"&&ye.parent===G.content}}function K(C,G,re){return!G||re&&re.identical.has(C)?!1:rt(C)?!i.equalUnits(C,G)||!Z(C,G,re):C.value!==G.value}function Z(C,G,re){if(!re||C===G)return!0;let ge=[[C,G]];for(;ge.length;){let[ye,ce]=ge.pop(),se=r(ye),Ie=r(ce);for(let Be=0;Be<se.length&&Be<Ie.length;Be++){let He=se[Be],Ke=Ie[Be];if(!rt(He)||!rt(Ke))continue;let pt=re.map.get(He);if(pt!==void 0&&pt!==Ke)return!1;let ht=re.reverse.get(Ke);if(ht!==void 0&&ht!==He)return!1;ge.push([He,Ke])}}return!0}function U(C,G,re,ge,ye=!1){let ce=ge||(re?n.remoteWins(re):n.remoteWins(C)),se=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(C.namespaceURI,C.tagName):ie.createElement(C.tagName),Ie={base:C,local:G||null,remote:re||null};if(xe.set(se,Ie),ce&&!ge&&G&&K(C,G,H)&&(!re||!i.equalUnits(G,re))&&yt({kind:"structure",el:se,detail:"remote-wins",base:C,local:G,remote:re||null},{subject:C}),oe.add(C),Ee.add(C),G&&oe.add(G),re&&oe.add(re),n.skipUnchanged&&!ye&&(n.localIsBase||H.identical.has(C))&&re&&q.identical.has(C)&&!n.remoteWins(C)){Ie.unchanged=!0;for(let He of C.attributes)He.namespaceURI?se.setAttributeNS(He.namespaceURI,He.name,He.value):se.setAttribute(He.name,He.value);return Nt?.produced(C,se),se}je.add(C),ye||le(C,ce?C:G,re,se);let Be=C.tagName;if(pn(C))we(C,ce?C:G,re,se);else if(Be==="TEXTAREA")se.textContent=de(C.textContent,(ce?C:G)?(ce?C:G).textContent:C.textContent,re?re.textContent:C.textContent,se,"text");else if(!Lt?.render(C,se)){let He=ee(C,G,re,ce,se),Ke=Be==="TEMPLATE"&&se.content?se.content:se;for(let pt of He)Ke.appendChild(pt)}return je.delete(C),Nt?.produced(C,se),se}function de(C,G,re,ge,ye){if(G===re)return G;if(G===C)return re!==C&&Ot({kind:ye,node:ge,source:"remote"}),re;if(re===C)return st({kind:ye,node:ge,source:"local"}),G;let ce=Ge==="local"?G:re;return yt({kind:ye,node:ge,base:C,local:G,remote:re,resolved:ce},{site:"whole",el:ge}),fe.push({kind:ye,node:ge,source:"both"}),ce}function we(C,G,re,ge){let ye=C.textContent,ce=G?G.textContent:ye,se=re?re.textContent:ye,Ie=w?ho(C,n.mergeTags,!0):null;if(Ie&&ce!==se){let Be=re&&re.getAttribute("merge-key")||C.getAttribute("merge-key"),{text:He,warnings:Ke}=Go(n.localIsBase?void 0:ye,ce,se,{parse:Ie.recognizer.parse,keyCandidates:Be?Be.split(/[\s,]+/).filter(Boolean):void 0});for(let pt of Ke)console.warn(`[hyper-morph] merge "${Ie.raw}": ${pt}`);ge.textContent=He,Y.add(ge),He!==se?st({kind:"text",node:ge,source:He===ce?"local":"both"}):He!==ye&&Ot({kind:"text",node:ge,source:"remote"});return}ge.textContent=de(ye,ce,se,ge,"text")}function le(C,G,re,ge){let ye=new Map;for(let ce of[C,G,re])if(ce)for(let se of ce.attributes)n.ignoreAttribute(ce,se.name)||ye.set(se.name,se);for(let[ce,se]of ye){let Ie=C?C.getAttribute(ce):null,Be=G?G.getAttribute(ce):Ie,He=re?re.getAttribute(ce):Ie,Ke;Be===He?Ke=Be:Be===Ie?(Ke=He,Ot({kind:"attr",el:ge,name:ce,source:"remote"})):He===Ie?(Ke=Be,st({kind:"attr",el:ge,name:ce,source:"local"})):(Ke=Ae(ce,Ie,Be,He),Ke===void 0&&(Ke=Ge==="local"?Be:He,yt({kind:"attr",el:ge,name:ce,base:Ie,local:Be,remote:He,resolved:Ke},{el:ge,sample:se})),fe.push({kind:"attr",el:ge,name:ce,source:"both"})),Ke!=null&&(se.namespaceURI?ge.setAttributeNS(se.namespaceURI,se.name,Ke):ge.setAttribute(ce,Ke))}}function Ae(C,G,re,ge){if(C==="class"){let ye=He=>new Set((He||"").split(/\s+/).filter(Boolean)),ce=ye(G),se=ye(re),Ie=ye(ge),Be=new Set;for(let He of new Set([...ce,...se,...Ie])){let Ke=ce.has(He),pt=se.has(He),ht=Ie.has(He);(pt===ht?pt:pt===Ke?ht:pt)&&Be.add(He)}return[...Be].join(" ")}if(C==="style"){let ye=Ke=>{let pt=new Map;if(!Ke)return pt;let ht=0,Kt=null,Ht="",un=()=>{let bt=Ht.indexOf(":");bt>0&&pt.set(Ht.slice(0,bt).trim(),Ht.slice(bt+1).trim()),Ht=""};for(let bt of Ke){if(Kt){Ht+=bt,bt===Kt&&(Kt=null);continue}if(bt==='"'||bt==="'"){Kt=bt,Ht+=bt;continue}if(bt==="("?ht++:bt===")"&&ht--,bt===";"&&ht===0){un();continue}Ht+=bt}return Ht.trim()&&un(),pt},ce=ye(G),se=ye(re),Ie=ye(ge),Be=new Map,He=!1;for(let Ke of new Set([...ce.keys(),...se.keys(),...Ie.keys()])){let pt=ce.get(Ke)??null,ht=se.get(Ke)??null,Kt=Ie.get(Ke)??null,Ht;ht===Kt?Ht=ht:ht===pt?Ht=Kt:Kt===pt?Ht=ht:(Ht=Ge==="local"?ht:Kt,He=!0),Ht!=null&&Be.set(Ke,Ht)}return He?void 0:[...Be].map(([Ke,pt])=>`${Ke}: ${pt}`).join("; ")}}function W(C,G,re,ge){let ye=C.value,ce=ge?ye:G?G.value:"",se=re?re.value:"";oe.add(C),G&&oe.add(G),re&&oe.add(re);let Ie=lo(ye,ce,se,Ge),Be=Ie.text===""?null:ie.createTextNode(Ie.text);Be&&(xe.set(Be,{base:C.nodes,local:G?G.nodes:null,remote:re?re.nodes:null}),qe.set(Be,Ie.mapLocalOffset)),ce!==ye&&se!==ye?fe.push({kind:"text",node:Be,source:"both"}):ce!==ye?st({kind:"text",node:Be,source:"local"}):se!==ye&&Ot({kind:"text",node:Be,source:"remote"});for(let He of Ie.conflicts)yt({kind:"text",node:Be,base:ye.slice(He.bs,He.be),local:He.local,remote:He.remote,resolved:He.resolved},{site:"run",bRun:C,lRun:G,rRun:re,node:Be,c:He});return Be}function X(C,G){return Gn(C,G).every(re=>re.bs===re.be)}function pe(C,G){let re=C?C.value:"",ge=G?G.value:"",ye;if(re===ge||!ge?ye=re:re?X(re,ge)?ye=ge:X(ge,re)?ye=re:(ye=Ge==="local"?re:Ge==="both"?re+ge:ge,yt({kind:"structure",el:null,detail:"insert-collision",local:re,remote:ge,resolved:ye},{unit:{b:null,l:C,r:G},localLost:Ge==="remote"})):ye=ge,C&&oe.add(C),G&&oe.add(G),ye==="")return null;let ce=ie.createTextNode(ye);return xe.set(ce,{base:null,local:C?C.nodes:null,remote:G?G.nodes:null}),re?st({kind:"insert",el:ce,source:ge&&re===ge?"both":"local"}):Ot({kind:"insert",el:ce,source:"remote"}),ce}function be(C,G){let re={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ge=Ie=>r(Ie).every(Be=>rt(Be)?Vn(Be,re):Be.kind==="text"),ye=null;if(ge(C)&&ge(G)){let Ie=C.textContent,Be=G.textContent;Ie===Be||X(Be,Ie)?ye=G:X(Ie,Be)&&(ye=C)}if(!ye){let Ie=Ge==="local",Be=he(Ie?C:G,Ie?"local":"remote",!0),He=xe.get(Be);return Ie?He.remote=G:He.local=C,yt({kind:"structure",el:Be,detail:"insert-collision",local:C,remote:G,resolved:Ie?C:G},{unit:{b:null,l:C,r:G},localLost:!Ie}),Be}let ce=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(C.namespaceURI,C.tagName):ie.createElement(C.tagName);le(null,C,G,ce),xe.set(ce,{base:null,local:C,remote:G}),oe.add(C),oe.add(G);let se=dt({base:Array.from(ye.childNodes),local:Array.from(C.childNodes),remote:Array.from(G.childNodes),out:ie,policy:Ge,idOf:{local:v,remote:I},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:xe,textMappers:qe,conflicts:x,conflict:yt,scope:{base:null,local:C,remote:G,units:[],at:0},synthetic:!0,decisions:fe,node:ce});ae.push(...se.segments);for(let Ie of se.nodes)ce.appendChild(Ie);return ce}function he(C,G,re=!1){if(!re&&rt(C)){let se=qt.partner.get(C);if(se)return Gt(C,G,se)}if(!rt(C)){if(C.value==="")return null;let se=C.kind==="comment"?ie.createComment(C.value):ie.createTextNode(C.value);return xe.set(se,{base:null,local:G==="local"?C.nodes:null,remote:G==="remote"?C.nodes:null}),oe.add(C),se}let ge=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(C.namespaceURI,C.tagName):ie.createElement(C.tagName);for(let se of C.attributes)se.namespaceURI?ge.setAttributeNS(se.namespaceURI,se.name,se.value):ge.setAttribute(se.name,se.value);xe.set(ge,{base:null,local:G==="local"?C:null,remote:G==="remote"?C:null}),oe.add(C);let ye=C.tagName==="TEMPLATE"&&ge.content?ge.content:ge,ce=G==="local"?H:q;for(let se of r(C)){let Ie=rt(se)?ce.reverse.get(se):null;if(Ie&&O(Ie,null,null),Ie&&Ee.has(Ie)){yt({kind:"structure",el:null,detail:"both-moved",base:Ie},{subject:Ie});continue}if(Ie&&!je.has(Ie)){let He=l(H,Ie)||null,Ke=l(q,Ie)||null;if(He||Ke){Nt||=go(xe,Re,H,q,l,U,s,n.remoteWins,x,yt,K,B,S),Nt.plan(Ie,G,se,!0);let pt=U(Ie,He,Ke,!1);G==="local"?st({kind:"move",el:pt,source:"local"}):Ot({kind:"move",el:pt,source:"remote"}),ye.appendChild(pt);continue}}let Be=he(se,G);Be&&ye.appendChild(Be)}if(!re&&qt.drop.size&&C.tagName==="DIV"&&!ye.firstChild&&!C.attributes.length&&!(G==="local"?v(C):I(C))&&!ce.reverse.has(C)&&!s(C)&&!n.remoteWins(C)){let se=C.firstChild;if(se&&se===C.lastChild&&rt(se)&&(qt.drop.has(se)||cn?.has(se)))return(cn||=new WeakSet).add(C),null}return ge}function ee(C,G,re,ge,ye){G&&H.identical.has(C)&&H.pairIdenticalChildren(C),re&&q.identical.has(C)&&q.pairIdenticalChildren(C);let ce=R(H,G,C,ge),se=R(q,re,C,!1),Ie=r(C),Be=new Set(Ie),He=new Map;for(let ue=0;ue<Ie.length;ue++)He.set(Ie[ue],ue);let Ke=[],pt=new Set,ht=new Map,Kt=new Set,Ht=Xe&&[],un=Xe&&[],bt=new Set,it=[],$e=null,vt=new Map;if(!ce.asBase&&!se.asBase&&!H.identical.has(C)&&!q.identical.has(C))for(let ue of Ie){if(!rt(ue)||!Ln.has(ue.tagName))continue;let We=ce.twin(ue),Ve=se.twin(ue);We&&Ve&&(!ce.here(We)||!se.here(Ve))&&O(ue,null,null)}vo();let at=ue=>{let We=[];for(let Ve of ue.units){if(bt.has(Ve))continue;let et=ue.baseOf(Ve);et&&Be.has(et)&&We.push(et)}return We},Dt=ue=>at(ue).map(We=>He.get(We)),bn=ue=>ue.every((We,Ve)=>Ve===0||We>=ue[Ve-1]),on=!ce.asBase&&!bn(Dt(ce)),hn=!se.asBase&&!bn(Dt(se));on&&hn&&yt({kind:"structure",el:ye,detail:"both-reordered",base:C},{subject:C,lKept:at(ce),rKept:at(se)});let Yt=hn||!on?{V:se,A:q,side:"remote",other:ce,otherA:H,otherSide:"local"}:{V:ce,A:H,side:"local",other:se,otherA:q,otherSide:"remote"};on?st({kind:"move",el:null,source:hn?"both":"local",base:C}):hn&&Ot({kind:"move",el:null,source:"remote",base:C});let En=ce.asBase?[]:ce.units.filter(ue=>!ce.baseOf(ue)&&!bt.has(ue)&&!qt.partner.has(ue)),oo=se.asBase?[]:se.units.filter(ue=>!se.baseOf(ue)&&!bt.has(ue)&&!qt.partner.has(ue)),Rn=new Map;if(En.length&&oo.length){let ue=new Map,We=new Map;for(let Fe of oo){if(rt(Fe)){let xt=I(Fe);xt&&ue.set(xt,Fe)}let ze=i.unitHash(Fe);We.has(ze)||We.set(ze,[]),We.get(ze).push(Fe)}let Ve=(Fe,ze)=>{let xt=Fe.units.indexOf(ze);for(let Ye=xt-1;Ye>=0;Ye--){let ot=Fe.baseOf(Fe.units[Ye]);if(ot)return ot}return"start"},et=new Map,wt=new Map;for(let Fe of oo){let ze=Ve(se,Fe);rt(Fe)?(wt.has(ze)||wt.set(ze,[]),wt.get(ze).push(Fe)):Fe.kind==="text"&&!et.has(ze)&&et.set(ze,Fe)}for(let Fe of En){let ze=null;if(rt(Fe)){let Ye=v(Fe);Ye&&ue.has(Ye)&&!Rn.has(ue.get(Ye))&&(ze=ue.get(Ye))}else if(Fe.kind==="text"){let Ye=et.get(Ve(ce,Fe));Ye&&!Rn.has(Ye)&&(ze=Ye)}let xt=!!k(Fe);if(!ze&&!xt){let Ye=We.get(i.unitHash(Fe));Ye&&(ze=Ye.find(ot=>!Rn.has(ot)&&rt(ot)===rt(Fe)&&(rt(ot)?ot.tagName===Fe.tagName&&!J(ot):ot.kind===Fe.kind)&&i.equalUnits(Fe,ot))||null)}if(!ze&&rt(Fe)&&!xt){let Ye=g.local(Fe),ot=(wt.get(Ve(ce,Fe))||[]).filter(ct=>{let Wt=g.remote(ct);return!Rn.has(ct)&&ct.tagName===Fe.tagName&&!J(ct)&&!(Ye&&Wt&&Ye!==Wt)&&i.similar(Fe,ct)});ot.length===1&&(ze=ot[0])}ze&&(Rn.set(ze,Fe),Rn.set(Fe,ze))}}let xo=ue=>{if(Lt?.consumes(ue))return null;if(oe.has(ue)||Nt?.has(ue))return ht.get(ue)||null;let We=ce.twin(ue),Ve=se.twin(ue),et=We&&!ce.asBase&&!ce.here(We),wt=Ve&&!se.asBase&&!se.here(Ve);if(et||wt){if((!We||!Ve)&&yt({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:We?"remote":"local"}),!Ze(ue))return rt(ue)?(Nt||=go(xe,Re,H,q,l,U,s,n.remoteWins,x,yt,K,B,S),et&&Nt.plan(ue,"local",We),wt&&Nt.plan(ue,"remote",Ve)):oe.add(ue),null;yt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue})}if(We&&!Ve&&!ce.asBase&&!se.asBase&&rt(ue)&&Ln.has(ue.tagName)&&!n.remoteWins(ue)&&!n.remoteWins(We)&&K(ue,We,H)&&hl(ue,Te(se.el),s)){let ot={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ct=Wt=>rt(Wt)?Vn(Wt,ot):Wt.kind==="text";if(r(ue).every(ct)&&r(We).every(ct)){let Wt=dt({base:[ue],local:[We],remote:[],blocks:new Set([ue,We]),out:ie,policy:Ge,L:H,R:q,idOf:{base:m,local:v,remote:I},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Qt,vn,Fn)=>U(Qt,vn,Fn,!1),cloneUnit:he,mergeAttrs:le,atomKey:i.exactUnitKey,moveIn:O,moveBuilt:O,movePlanned:O,provenance:xe,textMappers:qe,conflicts:x,conflict:yt,scope:{base:C,local:ce.el,remote:se.el,units:Ie,at:He.get(ue)},decisions:fe,node:ye});ae.push(...Wt.segments),oe.add(ue),oe.add(We);let Mt=ie.createDocumentFragment();for(let Qt of Wt.nodes)Mt.appendChild(Qt);return ht.set(ue,Mt),ht.set(We,Mt),Mt}}if(!We&&!Ve)return oe.add(ue),Ot({kind:"remove",source:"both",base:ue}),null;if(!We&&!K(ue,Ve,q))return oe.add(ue),st({kind:"remove",source:"local",base:ue}),null;if(!Ve&&!K(ue,We,H))return oe.add(ue),Ot({kind:"remove",source:"remote",base:ue}),Xe&&(Xe.remove(We),Ht.push({bk:ue,lk:We})),null;let Fe=!We||!Ve,ze=ce.asBase?l(H,ue)||null:We,xt=se.asBase&&rt(ue)&&(q.identityPaired.has(ue)||!g.base(ue))&&l(q,ue)||Ve,Ye;return rt(ue)?Ye=U(ue,ze,xt,ce.asBase):ue.kind==="comment"?Ye=_e(ue,ze,Ve,ce.asBase):Ye=W(ue,ze,Ve,ce.asBase),oe.add(ue),Ye&&(ht.set(ue,Ye),We&&ht.set(We,Ye),Ve&&ht.set(Ve,Ye),Fe&&(yt({kind:"structure",el:Ye,detail:"edit-beats-delete",base:ue},{subject:ue,deleted:We?"remote":"local"}),We?st({kind:"insert",el:Ye,source:"local"}):Ot({kind:"insert",el:Ye,source:"remote"}))),Ye},qn=(ue,We,Ve,et)=>{if(Lt?.consumes(ue))return null;if(oe.has(ue))return ht.get(ue)||null;let wt=We.baseOf(ue);if(wt&&Be.has(wt))return bt.has(wt)&&!bt.has(ue)?Ro(wt,ue,et):xo(wt);if(wt)return es(wt,ue,et);let Fe=Rn.get(ue);if(Fe){let xt=et==="local"?ue:Fe,Ye=et==="local"?Fe:ue,ot;return rt(xt)?i.equalUnits(xt,Ye)?(ot=he(xt,"local"),ot&&(xe.get(ot).remote=Ye)):ot=be(xt,Ye):ot=pe(xt,Ye),oe.add(xt),oe.add(Ye),ot&&(ht.set(xt,ot),ht.set(Ye,ot),rt(xt)&&st({kind:"insert",el:ot,source:"both"})),ot}let ze=he(ue,et);return ze&&(ht.set(ue,ze),et==="local"?st({kind:"insert",el:ze,source:"local"}):(Ot({kind:"insert",el:ze,source:"remote"}),Xe&&rt(ue)&&!qt.partner.has(ue)&&un.push({su:ue,node:ze}))),ze},Ro=(ue,We,Ve)=>{let et;return rt(ue)?(et=O(ue,Ve,We),et&&oe.add(We)):(et=he(We,Ve),oe.add(We),et&&(Ve==="local"?st:Ot)({kind:"insert",el:et,source:Ve})),et&&ht.set(We,et),et},es=(ue,We,Ve)=>{O(ue,null,null);let wt=l(Ve==="local"?q:H,ue),Fe=We,ze=wt?Ut(wt,Ve==="local"?re:G,Ve==="local"?q:H):!1,xt=wt&&!ze&&!Pt(ue,wt);if(xt&&Ve===Yt.otherSide)return yt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),null;if(xt&&yt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),wt||yt({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:Ve==="local"?"remote":"local"}),je.has(ue)){yt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue});let ot=he(Fe,Ve);return ot&&ht.set(We,ot),ot}rt(ue)&&(Nt||=go(xe,Re,H,q,l,U,s,n.remoteWins,x,yt,K,B,S),Nt.plan(ue,Ve,Fe,!0));let Ye=rt(ue)?U(ue,Ve==="local"?Fe:l(H,ue)||null,Ve==="remote"?Fe:l(q,ue)||null,!1):null;return Ye&&(ht.set(ue,Ye),ht.set(We,Ye),wt&&ht.set(wt,Ye),Ve==="local"?st({kind:"move",el:Ye,source:"local"}):Ot({kind:"move",el:Ye,source:"remote"})),Ye};for(let ue of Yt.V.units){if(bt.has(ue)){if($e?.has(ue)){for(let et of $e.get(ue))pt.has(et)||(Ke.push(et),pt.add(et));continue}let Ve=ht.get(ue);pt.has(Ve)||(Ke.push(Ve),pt.add(Ve));continue}if(oe.has(ue)&&!(ht.get(ue)&&pt.has(ht.get(ue)))){let Ve=Yt.V.baseOf(ue);Ve&&!Be.has(Ve)&&yt({kind:"structure",el:null,detail:"both-moved",base:Ve},{subject:Ve});continue}let We=qn(ue,Yt.V,Yt.A,Yt.side);We&&!pt.has(We)&&(Ke.push(We),pt.add(We),!Yt.V.baseOf(ue)&&!Rn.has(ue)&&!bt.has(ue)&&Kt.add(We))}for(let ue of it)pt.has(ue.frag)||(Ke.splice(ue.previous&&pt.has(ue.previous)?Ke.indexOf(ue.previous)+1:so(ue.at),0,ue.frag),pt.add(ue.frag));if(!Yt.other.asBase){let ue=Yt.other,We=Yt.otherSide,Ve=Yt.otherA,et=null,wt=0,Fe=null;for(let ze of ue.units){let xt=vt.get(ze)||ht.get(ze);if(xt&&pt.has(xt)){et=xt,Fe=null;continue}if(oe.has(ze)){let ct=ue.baseOf(ze);ct&&!Be.has(ct)&&yt({kind:"structure",el:null,detail:"both-moved",base:ct},{subject:ct});continue}let Ye=qn(ze,ue,Ve,We);if(!Ye)continue;let ot;if(Fe)ot=Ke.indexOf(Fe)+1;else if(et){if(ot=Ke.indexOf(et)+1,We==="remote")for(;ot<Ke.length&&Kt.has(Ke[ot]);)ot++}else ot=wt++;Ke.splice(ot,0,Ye),pt.add(Ye),Fe=Ye}}for(let ue=0;ue<Ie.length;ue++){let We=Ie[ue];if(oe.has(We))continue;let Ve=xo(We);Ve&&Ke.splice(so(ue),0,Ve)}return Xe&&Ht.length&&un.length&&Po(),Ke;function Po(){if(on||hn)return;let ue=new Set(Ke),We=ct=>ct&&Be.has(ct)&&ue.has(ht.get(ct))?ct:null,Ve=(ct,Wt)=>{let Mt=[{prev:null,units:[]}];for(let Qt of ct){let vn=We(Wt(Qt));vn?Mt.push({prev:vn,units:[]}):Mt[Mt.length-1].units.push(Qt)}return Mt},et=Ve(Ie,ct=>ct),wt=Ve(se.units,se.baseOf),Fe=ce.asBase?null:Ve(ce.units,ce.baseOf),ze=ct=>ct.length===et.length&&ct.every((Wt,Mt)=>Wt.prev===et[Mt].prev);if(!ze(wt)||Fe&&!ze(Fe))return;let xt=new Map(Ht.map(ct=>[ct.bk,ct])),Ye=new Map(un.map(ct=>[ct.su,ct])),ot=ct=>ct?Ke.indexOf(ht.get(ct)):-1;for(let ct=0;ct<et.length;ct++){if(et[ct].units.length!==1||wt[ct].units.length!==1)continue;let Wt=xt.get(et[ct].units[0]),Mt=Ye.get(wt[ct].units[0]);if(!Wt||!Mt||Fe&&(Fe[ct].units.length!==1||Fe[ct].units[0]!==Wt.lk))continue;let Qt=ot(et[ct].prev);(ct+1<et.length?ot(et[ct+1].prev):Ke.length)-Qt!==2||Ke[Qt+1]!==Mt.node||To(Wt.bk,Wt.lk,Mt.su)&&Xe.link(Wt.lk,Mt.node)}}function Kn(ue,We,Ve,et){let wt=Mt=>{let Qt=Mt.filter(rt);return Qt.length===1?Qt[0]:null},Fe=wt(ue),ze=wt(We),xt=wt(Ve);if(!Fe||!ze||!xt)return;let Ye=ue.indexOf(Fe);if(We.indexOf(ze)!==Ye||Ve.indexOf(xt)!==Ye||ue.length!==We.length||ue.length!==Ve.length)return;for(let Mt=0;Mt<ue.length;Mt++)if(Mt!==Ye&&(ue[Mt].value!==We[Mt].value||ue[Mt].value!==Ve[Mt].value))return;if((ce.asBase?Fe:ce.twin(Fe))!==ze||se.twin(Fe)||q.reverse.get(xt)||ze!==Fe&&K(Fe,ze,H))return;let ot=et.filter(Mt=>Mt.nodeType===1);if(ot.length!==1||xe.get(ot[0])?.remote!==xt)return;let ct=Mt=>Mt.map(Qt=>rt(Qt)?"":Qt.value??Qt.nodeValue).join(""),Wt=et.indexOf(ot[0]);ct(et.slice(0,Wt))!==ct(ue.slice(0,Ye))||ct(et.slice(Wt+1))!==ct(ue.slice(Ye+1))||To(Fe,ze,xt)&&Xe.link(ze,ot[0])}function To(ue,We,Ve){if(!rt(We)||!rt(Ve)||!rt(ue)||We.namespaceURI!==Ve.namespaceURI||We.localName===Ve.localName)return!1;for(let ze of[We,Ve])if(ze.tagName==="TEMPLATE"||pn(ze)||ze.querySelector("template"))return!1;if(n.remoteWins(ue)||n.remoteWins(Ve)||s(Ve)||We.attributes.length!==Ve.attributes.length)return!1;for(let ze of We.attributes)if(Ve.getAttributeNS(ze.namespaceURI,ze.localName)!==ze.value)return!1;let et=We.childNodes,wt=Ve.childNodes;if(et.length!==wt.length)return!1;for(let ze=0;ze<et.length;ze++)if(!et[ze].isEqualNode(wt[ze]))return!1;let Fe=[[ue,Ve]];for(;Fe.length;){let[ze,xt]=Fe.pop();if(ze.children.length!==xt.children.length)return!1;for(let Ye=0;Ye<xt.children.length;Ye++){let ot=q.reverse.get(xt.children[Ye]);if(ot!==void 0&&ot!==ze.children[Ye])return!1;Fe.push([ze.children[Ye],xt.children[Ye]])}}return!0}function so(ue){for(let We=ue-1;We>=0;We--){let Ve=ht.get(Ie[We]);if(Ve){let et=Ke.indexOf(Ve);if(et>=0)return et+1}}return 0}function vo(){if((ce.asBase||H.identical.has(C))&&(se.asBase||q.identical.has(C)))return;let ue={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},We=ft=>rt(ft)?Vn(ft,ue):ft.kind==="text";if(!ce.asBase&&!se.asBase)for(let ft of Ie){if(!rt(ft)||!Ln.has(ft.tagName))continue;let Qe=ce.twin(ft),Et=se.twin(ft);if(!Qe&&Et||Qe&&!Et){let nt=Br({base:Ie,views:[{V:ce,A:H,idOf:g.local},{V:se,A:q,idOf:g.remote}],eligible:At=>rt(At)&&Ln.has(At.tagName)&&!s(At)&&!n.remoteWins(At),baseId:g.base,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey});nt&&(ce=nt[0],se=nt[1]);break}}let Ve=!ce.asBase&&!se.asBase&&Ie.length>=2&&Ln.has(Ie[0].tagName)&&ce.units.length===Ie.length&&se.units.length===Ie.length?hr({base:Ie,local:ce.units,remote:se.units,localTwin:ce.twin,remoteTwin:se.twin,eligible:ft=>rt(ft)&&Ln.has(ft.tagName)&&!s(ft)&&!n.remoteWins(ft),nodes:{base:Array.from(Te(C).childNodes),local:Array.from(Te(ce.el).childNodes),remote:Array.from(Te(se.el).childNodes)}}):null,et=null,wt=null;if(!Ve&&!ce.asBase&&!se.asBase&&(Cs(Ie)||Cs(ce.units)||Cs(se.units))){let ft={ignored:s,remoteWins:()=>!1},Qe=nt=>We(nt)||rt(nt)&&n.remoteWins(nt)&&Tn.has(nt.tagName)&&Vn(nt,ft),Et=nt=>rt(nt)?Ln.has(nt.tagName)&&!s(nt)&&!n.remoteWins(nt)&&r(nt).every(Qe):nt.kind==="text";et=Dr({onUncertainOwner:nt=>{let At=n.identity.local(nt.local);At&&At===n.identity.remote(nt.remote)||(wt||=[]).push(nt)},onUncertainSource:nt=>{tt||(tt=new Map);let At=tt.get(nt.source);At||tt.set(nt.source,At=[]);for(let Xt of At)if(Xt.side===nt.side&&Xt.from===nt.from&&Xt.to===nt.to)return;At.push(nt)},base:Ie,views:[{V:ce,A:H,idOf:g.local},{V:se,A:q,idOf:g.remote}],eligible:Et,ignored:s,remoteWins:n.remoteWins,baseId:g.base,atomKey:i.exactUnitKey})}if(wt){$e||=new Map;for(let ft of wt){let{source:Qe,local:Et,remote:nt}=ft,At={map:new Map,reverse:new Map,identical:new Set},Xt=dt({base:[Qe],local:[Et],remote:[nt],out:ie,policy:"both",L:At,R:At,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey,cloneUnit:he,provenance:xe,textMappers:qe,conflicts:x,decisions:fe,conflict:(Rt,Ft)=>yt(Rt,{...Ft,policy:"both"}),scope:{base:C,local:ce.el,remote:se.el,units:Ie,at:He.get(Qe)},node:ye});ae.push(...Xt.segments);for(let Rt of[Qe,Et,nt])oe.add(Rt),bt.add(Rt),$e.set(Rt,Xt.nodes),ht.set(Rt,Xt.nodes[Xt.nodes.length-1]);for(let Rt=0;Rt<Xt.nodes.length;Rt++)it.push({frag:Xt.nodes[Rt],at:He.get(Qe),previous:Rt?Xt.nodes[Rt-1]:null})}}let Fe=Ve?Ve.blocks:null;if(et){Fe=new Set;for(let ft of et.blocks)Fe.add(ft)}let ze=ft=>!Lt?.consumes(ft)&&(Fe&&Fe.has(ft)||We(ft)),xt=Ie.map(ze);if(!xt.includes(!0))return;let Ye=ft=>{let Qe=ft.units,Et=new Map;for(let tn=0;tn<Qe.length;tn++)Et.set(Qe[tn],tn);let nt=[],At=-1;for(let tn=0;tn<Ie.length;tn++){if(xt[tn])continue;let Tt=ft.twin(Ie[tn]),mt=Tt?Et.get(Tt):void 0;mt===void 0||mt<=At||ze(Tt)||(nt.push([tn,mt]),At=mt)}let Xt=[],Rt=-1,Ft=-1;for(let tn=0;tn<=nt.length;tn++){let[Tt,mt]=tn<nt.length?nt[tn]:[Ie.length,Qe.length],St={bLo:-1,bHi:-1,from:Ft+1,to:mt,inlineStart:-1,inlineEnd:-1,next:mt};for(let Zt=Rt+1;Zt<Tt;Zt++)xt[Zt]&&(St.bLo<0&&(St.bLo=Zt),St.bHi=Zt);for(let Zt=Ft+1;Zt<mt;Zt++){let _n=Qe[Zt];ze(_n)&&(St.inlineStart<0&&(St.inlineStart=Zt),St.inlineEnd=Zt+1)}Xt.push(St),Rt=Tt,Ft=mt}return{units:Qe,list:Xt}},ot=Ye(ce),ct=Ye(se),Wt=[];for(let ft of[ot,ct])for(let Qe of ft.list)Qe.bLo>=0&&Wt.push([Qe.bLo,Qe.bHi]);Wt.sort((ft,Qe)=>ft[0]-Qe[0]);let Mt=[];for(let[ft,Qe]of Wt){let Et=Mt[Mt.length-1];Et&&ft<=Et.hi?Et.hi=Math.max(Et.hi,Qe):Mt.push({lo:ft,hi:Qe})}let Qt=(ft,Qe)=>ft.length===Qe.length&&ft.every((Et,nt)=>i.equalUnits(Et,Qe[nt])),vn=ft=>!rt(ft)&&ft.kind==="comment",Fn=ft=>{if(!ft.length)return[];let Qe=(Rt,Ft)=>rt(Rt)?Rt:Rt.nodes[Ft?Rt.nodes.length-1:0],Et=Qe(ft[0]),nt=Qe(ft[ft.length-1],!0),At=Rt=>Rt&&rt(Rt)&&s(Rt);for(;At(Et.previousSibling);)Et=Et.previousSibling;for(;At(nt.nextSibling);)nt=nt.nextSibling;let Xt=[];for(let Rt=Et;Rt&&(Xt.push(Rt),Rt!==nt);Rt=Rt.nextSibling);return Xt},Pn=ft=>ft.some(Qe=>rt(Qe)&&s(Qe));for(let ft of Mt){let Qe=Ie.slice(ft.lo,ft.hi+1),Et=null;if(et)for(let Tt of Qe){let mt=et.certificatesBySource.get(Tt);mt&&(Et||=[]).push(...mt)}let nt=ce.asBase?null:Is(ot,ft),At=se.asBase?null:Is(ct,ft);if(Et){let Tt=[new Set(nt||Qe),new Set(At||Qe)],mt=Et.some(St=>!Tt[St.side].has(St.target));for(let St of Qe)if(Fe.has(St))for(let[Zt,_n]of[[0,ce],[1,se]]){let Sn=_n.twin(St);Sn&&_n.here(Sn)&&!Tt[Zt].has(Sn)&&(mt=!0)}if(mt)continue}if(Qe.some(vn)||nt&&nt.some(vn)||At&&At.some(vn))continue;let Xt=Fn(nt||Qe),Rt=Fn(At||Qe);if((!nt||Qt(Qe,nt))&&(!At||Qt(Qe,At))&&!(nt&&Pn(Xt)))continue;let Ft=dt({base:Fn(Qe),sourceRetentions:tt?.get(C),local:Xt,remote:Rt,out:ie,policy:Ge,blocks:Fe,scopeUnits:Et?[Qe,nt||Qe,At||Qe]:null,certifiedOrigins:Et?(Tt,mt,St,Zt,_n,Sn)=>jr({certificates:Et,scopes:[Qe,nt||Qe,At||Qe],flats:[Tt,mt,St],keys:[Zt,_n,Sn]}):null,prepared:Ve?Ve.prepared:null,nativeTransfers:Ve,L:nt?H:Ur(H,C),R:At?q:Ur(q,C),idOf:{base:m,local:v,remote:I},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Tt,mt,St)=>U(Tt,mt,St,!1),cloneUnit:he,mergeAttrs:le,atomKey:i.exactUnitKey,moveIn:O,moveBuilt:O,movePlanned:O,provenance:xe,textMappers:qe,conflicts:x,conflict:yt,scope:{base:C,local:ce.asBase?null:ce.el,remote:se.asBase?null:se.el,units:Ie,at:ft.lo},decisions:fe,node:ye});if(!Ft){if(Et){let Tt=pr({certificates:Et,scopes:[Qe,nt||Qe,At||Qe],views:[{V:ce,A:H,idOf:g.local},{V:se,A:q,idOf:g.remote}],eligible:mt=>rt(mt)&&Ln.has(mt.tagName)&&!s(mt)&&!n.remoteWins(mt),baseId:g.base});for(let mt of Tt.records){tt||=new Map;let St=tt.get(mt.source);St||tt.set(mt.source,St=[]),St.push(mt)}}continue}if(ae.push(...Ft.segments),Ve){let Tt=new Map;for(let mt of Ft.nodes){let St=xe.get(mt)?.base;if(!St||Tt.has(St))throw new Error("Invalid native transfer owner output");Tt.set(St,mt)}if(Tt.size!==Ve.owners.length)throw new Error("Incomplete native transfer owner output");for(let mt of Ve.owners){let St=Tt.get(mt.base);if(!St)throw new Error("Missing native transfer owner output");for(let Zt of[mt.base,mt.local,mt.remote])oe.add(Zt),bt.add(Zt),ht.set(Zt,St);it.push({frag:St,at:He.get(mt.base)})}continue}if(Xe&&Kn(Qe,nt||Qe,At||Qe,Ft.nodes),Ft.unitOutputs){$e||=new Map;for(let mt of[...Qe,...nt||[],...At||[]]){let St=Ft.unitOutputs.get(mt)||[];oe.add(mt),bt.add(mt),$e.set(mt,St),St.length&&ht.set(mt,St[St.length-1])}let Tt=Ft.nodes[Ft.nodes.length-1];if(Tt)for(let mt of[nt||Qe,At||Qe]){let St=mt[mt.length-1];St&&vt.set(St,Tt)}for(let mt=0;mt<Ft.nodes.length;mt++)it.push({frag:Ft.nodes[mt],at:ft.lo,previous:mt>0?Ft.nodes[mt-1]:null});continue}Xe&&Kn(Qe,nt||Qe,At||Qe,Ft.nodes);let tn=ie.createDocumentFragment();for(let Tt of Ft.nodes)tn.appendChild(Tt);for(let Tt of[...Qe,...nt||[],...At||[]])oe.add(Tt),bt.add(Tt),ht.set(Tt,tn);it.push({frag:tn,at:ft.lo})}}}function te(C,G){let re=xe.get(C);return re&&re.unchanged?!re.remote||re.remote===G?!0:z(re.remote,G):C.tagName!==G.tagName||!Ce(C,G)?!1:Pe(Te(C),Te(G))}function z(C,G){return C===G?!0:C.tagName!==G.tagName||C.namespaceURI!==G.namespaceURI||!Ce(C,G)?!1:ne(Te(C),Te(G))}function ne(C,G){let re=ve(C,s),ge=ve(G,s);if(re.length!==ge.length)return!1;for(let ye=0;ye<re.length;ye++){let ce=re[ye],se=ge[ye];if(typeof ce=="string"||typeof se=="string"){if(ce!==se)return!1}else{if(ce.nodeType!==se.nodeType)return!1;if(ce.nodeType===1){if(!z(ce,se))return!1}else if(ce.nodeValue!==se.nodeValue)return!1}}return!0}function Te(C){return C.tagName==="TEMPLATE"&&C.content?C.content:C}function Ce(C,G){let re=0;for(let ge of C.attributes)if(!n.ignoreAttribute(C,ge.name)&&(re++,G.getAttribute(ge.name)!==ge.value))return!1;for(let ge of G.attributes)n.ignoreAttribute(G,ge.name)||re--;return re===0}function Pe(C,G){let re=ve(C,ye=>{let ce=xe.get(ye);return!!(ce&&ce.pinned)}),ge=ve(G,s);if(re.length!==ge.length)return!1;for(let ye=0;ye<re.length;ye++){let ce=re[ye],se=ge[ye];if(typeof ce=="string"||typeof se=="string"){if(ce!==se)return!1}else{if(ce.nodeType!==se.nodeType)return!1;if(ce.nodeType===1){if(!te(ce,se))return!1}else if(ce.nodeValue!==se.nodeValue)return!1}}return!0}function ve(C,G){let re=[],ge=null;for(let ye=C.firstChild;ye;ye=ye.nextSibling){if(ye.nodeType===3){ge=ge===null?ye.nodeValue:ge+ye.nodeValue;continue}ye.nodeType===1&&G(ye)||(ge!==null&&(ge!==""&&re.push(ge),ge=null),re.push(ye))}return ge!==null&&ge!==""&&re.push(ge),re}function _e(C,G,re,ge){let ye=C.value,ce=ge?ye:G?G.value:"",se=re?re.value:"";oe.add(C),G&&oe.add(G),re&&oe.add(re);let Ie=ce===se?ce:ce===ye?se:se===ye||Ge==="local"?ce:se,Be={site:"comment",bRun:C,lRun:G,rRun:re,node:null};if(ce!==ye&&se!==ye&&ce!==se&&yt({kind:"text",node:null,base:ye,local:ce,remote:se,resolved:Ie},Be),!G&&!re)return null;let He=ie.createComment(Ie);return Be.node=He,xe.set(He,{base:C.nodes,local:G?G.nodes:null,remote:re?re.nodes:null}),He}function Je(C,G){let re=l(G,C);if(!re)return null;let ge=rt(re)?re.parentNode:re.parent,ye=rt(C)?C.parentNode:C.parent;return l(G,ye)===ge?null:G.reverse.get(ge)||null}function Ze(C){let G=new Set([C]),re=C;for(let ge=0;ge<64;ge++){let ye=Je(re,H)||Je(re,q);if(!ye)return!1;if(ye===C||rt(C)&&rt(ye)&&C.contains(ye)||G.has(ye))return!0;G.add(ye),re=ye}return!0}function Ut(C,G,re){if(!G)return!1;let ge=rt(C)?C.parentNode:C.parent;return ge===G||G.tagName==="TEMPLATE"&&ge===G.content}function Pt(C,G){let re=Re(C),ge=l(H,re);if(ge&&Ut(G,ge,H))return!0;let ye=l(q,re);return!!(ye&&Ut(G,ye,q))}}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"]),Es=/[\t\n\f\r ]+/;function Wr(e,o,t,n){let s=e.ownerDocument,{provenance:h,textMappers:i}=t,r=n.hooks,a=[],d=[],w=[],c=new Set,p=[],m=[],v=new Map,I=new Set,g=new Map,f=t.conflicts.length>0||n.trackInserted===!0,b=new Map,B=new Set,S=new Map,T=(l,O)=>{let R=S.get(l);R||S.set(l,R=new Set),R.add(O)},M=f?new Set:null,L=(l,O,R)=>{let K=r.beforeAttributeUpdated(l,O,R);return f&&K===!1&&T(O,l),K},N=l=>!!l&&(l===e||e.contains(l)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(l)),A=new Map,E=new Map,V=new Map,j=new Set,D=new Map;(function l(O){let R=h.get(O);if(R){if(O.nodeType===1){let Z=R.local?n.toLive(R.local):null;Z&&N(Z)&&Z.nodeType===1&&(A.set(O,Z),E.set(Z,O))}else if(Array.isArray(R.local)){let Z=q(R.local,R.local.map(U=>n.toLive(U)).filter(U=>U&&N(U)&&U.nodeType===O.nodeType));if(Z.length&&(A.set(O,Z[0]),E.set(Z[0],O),V.set(O,Z)),Array.isArray(R.caret))for(let U of R.caret){let de=n.toLive(U.node);if(!de||!N(de)||de.nodeType!==3)continue;let we=D.get(de);Array.isArray(we)||D.set(de,we=[]),we.push({merged:O,from:U.from,to:U.to,flatStart:U.flatStart})}else{let U=0;for(let de of Z)D.set(de,{merged:O,shift:U}),U+=de.nodeValue.length}}}let K=O.nodeType===1&&O.tagName==="TEMPLATE"&&O.content?O.content.childNodes:O.childNodes;for(let Z of K)l(Z)})(o);let y=new Set;for(let l of A.values())y.add(l);for(let l of V.values())for(let O of l)y.add(O);let k=n.localRoot&&n.localRoot!==e?new Set:null;if(k){for(let l=n.localRoot.firstElementChild;l;l=l.nextElementSibling)if(l.tagName==="HEAD")for(let O=l.firstElementChild;O;O=O.nextElementSibling){let R=n.toLive(O);R&&k.add(R)}}for(let l of t.segments||[])Me(l);let J=n.restoreFocus===!1?null:pl(s,D);n.childrenOnly?xe(Oe(e),Oe(o)):Re(e,o);for(let{node:l,parent:O}of p)c.has(l)||!l.parentNode||l.nodeType===1&&(n.ignored(l)||qe(l))||tt(l,O);return ml(s,J,D,i,V,g,j),{applied:a,moved:d,replaced:w,identities:m,mergedScriptsLive:I,liveOf:A,heldBy:g,runOf:V,keptRuns:j,insertedLive:b,vetoed:B,vetoedAttrs:S,removedVetoes:M};function H(l,O){let R=l.slice(O.bs,O.be),K=0;for(;K<R.length&&K<O.text.length&&R[K]===O.text[K];)K++;let Z=0;for(;Z<R.length-K&&Z<O.text.length-K&&R[R.length-1-Z]===O.text[O.text.length-1-Z];)Z++;return{bs:O.bs+K,be:O.be-Z,text:O.text.slice(K,O.text.length-Z)}}function q(l,O){if(!O.length)return O;let R=[];for(let U of l){let de=U.parentNode;if(!de)continue;let we=v.get(de);if(!we){we=new Set;for(let le=de.firstChild;le;le=le.nextSibling)le.nodeType===3&&we.add(n.toLive(le));v.set(de,we)}R.includes(we)||R.push(we)}let K={has:U=>R.some(de=>de.has(U))},Z=[];for(let U of O){Z.push(U);for(let de=U.nextSibling;de&&de.nodeType===3&&!K.has(de)&&!Z.includes(de);de=de.nextSibling)Z.push(de)}return Z}function Me(l){let O=[];for(let ee of l.localNodes){let te=n.toLive(ee.node);if(!te||!N(te)||te.nodeType!==3)return;O.push(te)}let R=q(l.localNodes.map(ee=>ee.node),O);if(!R.length)return;let K=R.map(ee=>ee.nodeValue).join(""),{flatLocal:Z,lToM:U,mapLocal:de}=l;if(K===Z)return;let we=l.textNodes.map(ee=>({node:ee.node,ms:ee.ms,me:ee.me})),le=[],Ae=0;for(let ee of R)le.push(Ae),Ae+=ee.nodeValue.length;let W=(ee,te)=>R.find((z,ne)=>le[ne]<=ee&&ee+te<=le[ne]+z.nodeValue.length)||null,X=[],pe=0;for(let ee of Gn(Z,K).map(te=>H(Z,te))){let te=ee.bs+pe;pe+=ee.text.length-(ee.be-ee.bs);let z,ne;if(ee.be>ee.bs){z=U[ee.bs];let Te=z>=0;for(let Ce=ee.bs;Te&&Ce<ee.be;Ce++)U[Ce]!==z+(Ce-ee.bs)&&(Te=!1);if(!Te)continue;ne=z+(ee.be-ee.bs)}else{let Te=ee.bs>0?U[ee.bs-1]:0,Ce=ee.bs<Z.length?U[ee.bs]:0;if(Te<0||Ce<0)continue;z=ne=de(ee.bs)}X.push({ms:z,me:ne,text:ee.text,live:ne===z?W(te,ee.text.length):null})}X.sort((ee,te)=>te.ms-ee.ms);let be=(ee,te)=>(V.get(ee.node)||[A.get(ee.node)]).includes(te),he=ee=>!!ee&&ee.nodeType===1&&Tn.has(ee.tagName);for(let ee of X){let te=we.find(ne=>ne.ms<=ee.ms&&ee.me<=ne.me&&ee.ms<ne.me);if(te&&ee.live&&te.ms===ee.ms&&!be(te,ee.live)){let ne=we.find(Te=>Te.me===ee.ms&&be(Te,ee.live));ne&&(te=ne)}if(!te&&ee.me===ee.ms){let ne=we.find(ve=>ve.me===ee.ms),Te=we.find(ve=>ve.ms===ee.ms),Ce=ne||Te;if(!Ce)continue;let Pe=Ce.node;for(;he(Pe.parentNode)&&(ne?Pe.parentNode.lastChild:Pe.parentNode.firstChild)===Pe;)Pe=Pe.parentNode;if(Pe===Ce.node)te=Ce;else{let ve=Pe.ownerDocument.createTextNode(ee.text);Pe.parentNode.insertBefore(ve,ne?Pe.nextSibling:Pe);continue}}if(!te)continue;let z=te.node.nodeValue;te.node.nodeValue=z.slice(0,ee.ms-te.ms)+ee.text+z.slice(ee.me-te.ms),te.me+=ee.text.length-(ee.me-ee.ms)}}function Oe(l){return l.nodeType===1&&l.tagName==="TEMPLATE"&&l.content?l.content:l}function Re(l,O){c.add(l);let R=h.get(O);if(R&&R.remote&&t.remoteIdOf){let Z=t.remoteIdOf(R.remote);Z&&m.push([l,Z])}if(R&&R.unchanged){n.opaque&&n.opaque(l)||(t.customIdentity&&R.remote&&ae(l,R.remote),R.remote&&Y(l,R.remote));return}if(r.beforeNodeMorphed(l,O)===!1){B.add(O);return}Ct(l,O,n.keepLiveOnly&&R&&R.local&&R.local.nodeType===1&&R.local!==l?R.local:null);let K=l.tagName;if(pn(l))l.textContent!==O.textContent&&(a.push({kind:"text",node:l,before:l.textContent,after:O.textContent}),l.textContent=O.textContent),t.mergedScripts.has(O)&&I.add(l);else if(K==="TEXTAREA")$(l,O,R);else{Gt(l,O,R);let Z=K==="TEMPLATE"&&l.content?l.content:l,U=K==="TEMPLATE"&&O.content?O.content:O;n.opaque&&n.opaque(l)||n.protectFocusedValue==="subtree"&&Nt(l)&&l!==s.body?ie(Z):xe(Z,U)}r.afterNodeMorphed(l,O)}function ie(l){for(let O=l.firstChild;O;O=O.nextSibling){let R=E.get(O);R&&A.get(R.parentNode)!==l||(c.add(O),O.nodeType===1&&ie(O))}}function xe(l,O){let R=je(l.firstChild),K=new Set;for(let Z of Array.from(O.childNodes)){let U=A.get(Z);U&&c.has(U)&&!K.has(U)&&(U=null);let de=h.get(Z);if(de&&de.pinned){U&&U.nodeType===1&&((U.parentNode!==l||je(U.nextSibling)!==R)&&Ne(l,U,R),c.add(U),K.add(U));continue}if(U&&U.nodeType===1){if(U!==R){let Ae=U.parentNode;if(Ae===l&&R&&Lt(U)){let W=U.nextSibling;for(let X=R;X&&X!==U;){let pe=X.nextSibling;Ne(l,X,W),X=pe}}else Ne(l,U,R),Ae!==l&&(d.push(U),a.push({kind:"move",el:U,from:Ae,to:l}))}K.add(U),Re(U,Z),R=je(U.nextSibling);continue}if(U&&U.nodeType!==1){let Ae=V.get(Z)||[U],W=Ae.map(pe=>pe.nodeValue).join(""),X=Z.nodeValue;if(Z.nodeType===3){let pe=fe(Z);pe!=null&&W!==pe&&(X=lo(pe,W,Z.nodeValue).text)}if(Ae.length>1&&W===X&&!Ae.includes(R,1)&&Ae.every((pe,be)=>pe.parentNode===l&&(be===0||Ae[be-1].nextSibling===pe))){if(U!==R)for(let pe of Ae)Ne(l,pe,R);r.beforeNodeMorphed(U,Z)!==!1?r.afterNodeMorphed(U,Z):f&&B.add(Z);for(let pe of Ae)c.add(pe),K.add(pe);g.set(Z,U),j.add(Z),R=je(Ae[Ae.length-1].nextSibling);continue}U!==R&&Ne(l,U,R),r.beforeNodeMorphed(U,Z)!==!1?(U.nodeValue!==X&&(a.push({kind:"text",node:U,before:U.nodeValue,after:X}),U.nodeValue=X),r.afterNodeMorphed(U,Z)):B.add(Z),c.add(U),K.add(U),g.set(Z,U),R=je(U.nextSibling);continue}if(Z.nodeType===3&&R&&R.nodeType===3&&!c.has(R)&&!D.has(R)){R.nodeValue!==Z.nodeValue&&(a.push({kind:"text",node:R,before:R.nodeValue,after:Z.nodeValue}),R.nodeValue=Z.nodeValue),c.add(R),g.set(Z,R),R=je(R.nextSibling);continue}let we=h.get(Z),le=Xe(we&&we.unchanged&&we.remote?we.remote:Z);if(r.beforeNodeAdded(le)===!1){B.add(Z);continue}l.insertBefore(le,R),c.add(le),f&&b.set(Z,le),le.nodeType===3&&g.set(Z,le),le.nodeType===1&&(w.push(le),Ee(le,Z),t.customIdentity&&we&&we.unchanged&&we.remote&&ae(le,we.remote),pn(le)||dt(le,Z),n.formState==="property"&&rn(we)&&Y(le,we.remote)),R=je(le.nextSibling),a.push({kind:"insert",node:le,parent:l}),r.afterNodeAdded(le)}for(let Z of Array.from(l.childNodes))c.has(Z)||K.has(Z)||Z.nodeType===1&&(n.ignored(Z)||qe(Z))||(y.has(Z)?p.push({node:Z,parent:l}):tt(Z,l))}function qe(l){return l.parentNode&&l.parentNode.nodeType===1&&l.parentNode.tagName==="HEAD"&&(k&&!k.has(l)||n.preserve&&n.preserve(l)===!0)}function fe(l){let O=h.get(l);return!O||!Array.isArray(O.local)?null:O.local.map(R=>R.nodeValue).join("")}function x(l){return h.get(l)}function Y(l,O){if(!Hr.has(l.tagName)&&!l.querySelector("input,option,textarea"))return;let R=(K,Z)=>{if(K.tagName!==Z.tagName||(K.tagName==="TEXTAREA"?$(K,Z,{remote:Z}):Hr.has(K.tagName)&&Gt(K,Z,{remote:Z}),n.opaque&&n.opaque(K)))return;let U=oe(K),de=oe(Z);if(U.length===de.length)for(let we=0;we<U.length;we++)R(U[we],de[we])};R(l,O)}function ae(l,O){if(n.opaque&&n.opaque(l))return;let R=oe(l),K=oe(O);if(R.length===K.length)for(let Z=0;Z<R.length;Z++){let U=t.remoteIdOf(K[Z]);U&&m.push([R[Z],U]),ae(R[Z],K[Z])}}function oe(l){let O=l.tagName==="TEMPLATE"&&l.content?l.content:l;return Array.from(O.children).filter(R=>!n.ignored(R))}function Ee(l,O){if(!t.remoteIdOf)return;let R=(K,Z)=>{let U=h.get(Z);if(U&&U.remote&&Z.nodeType===1){let le=t.remoteIdOf(U.remote);le&&m.push([K,le])}let de=K.childNodes,we=Z.childNodes;for(let le=0;le<de.length&&le<we.length;le++)R(de[le],we[le])};R(l,O)}function je(l){for(;l&&l.nodeType===1&&n.ignored(l);)l=l.nextSibling;return l}function Ne(l,O,R){if(typeof l.moveBefore=="function"&&O.ownerDocument===l.ownerDocument)try{l.moveBefore(O,R);return}catch{}l.insertBefore(O,R)}function tt(l,O){if(r.beforeNodeRemoved(l)===!1){f&&M.add(l);return}l.parentNode.removeChild(l),a.push({kind:"remove",node:l,parent:O}),r.afterNodeRemoved(l)}function Xe(l){if(pn(l))return Mo(l,s);let O=s.importNode(l,!0);if(O.nodeType===1)for(let R of Array.from(O.querySelectorAll("script")))pn(R)&&R.replaceWith(Mo(R,s));return O}function dt(l,O){let R=l.tagName==="TEMPLATE"&&l.content?l.content:l,K=O.tagName==="TEMPLATE"&&O.content?O.content:O,Z=Array.from(R.childNodes),U=Array.from(K.childNodes);for(let de=0;de<U.length&&de<Z.length;de++){let we=U[de],le=Z[de],Ae=A.get(we);Ae&&c.has(Ae)&&(Ae=null);let W=h.get(we);if(W&&W.pinned){if(Ae&&Ae.nodeType===1){let X=Ae.parentNode;Ne(R,Ae,le),X!==R&&(d.push(Ae),a.push({kind:"move",el:Ae,from:X,to:R})),c.add(Ae)}le.remove();continue}if(Ae){let X=Ae.parentNode;Ne(R,Ae,le),le.remove(),Ae.nodeType===1?(X!==R&&(d.push(Ae),a.push({kind:"move",el:Ae,from:X,to:R})),Re(Ae,we)):(c.add(Ae),g.set(we,Ae),Ae.nodeValue!==we.nodeValue&&(a.push({kind:"text",node:Ae,before:Ae.nodeValue,after:we.nodeValue}),Ae.nodeValue=we.nodeValue));continue}c.add(le),f&&b.set(we,le),le.nodeType===3&&g.set(we,le),W&&W.unchanged&&W.remote?(Ge(le,W.remote),t.customIdentity&&ae(le,W.remote)):we.nodeType===1&&!pn(we)&&dt(le,we)}}function Ge(l,O){let R=l.tagName==="TEMPLATE"&&l.content?l.content:l,K=O.tagName==="TEMPLATE"&&O.content?O.content:O;for(let Z of Array.from(K.childNodes))R.appendChild(Xe(Z))}function st(l,O){return O.namespaceURI?l.getAttributeNS(O.namespaceURI,O.localName):l.getAttribute(O.name)}function Ot(l,O){let R=new Set((O||"").split(Es).filter(Boolean));return(l||"").split(Es).filter(K=>K&&!R.has(K))}function Ct(l,O,R){for(let K of Array.from(O.attributes)){if(yt(l,K.name)||n.ignoreAttribute(l,K.name))continue;let Z=st(l,K);if(Z===K.value||R&&st(R,K)===K.value)continue;let U=K.value;if(R&&K.name==="class"&&!K.namespaceURI){let de=K.value.split(Es).filter(Boolean),we=Ot(Z,R.getAttribute("class")).filter(le=>!de.includes(le));we.length&&(U=[...de,...we].join(" "))}if(Z!==U){if(r.beforeAttributeUpdated(K.name,l,"update")===!1){f&&T(O,K.name);continue}K.namespaceURI?l.setAttributeNS(K.namespaceURI,K.name,U):l.setAttribute(K.name,U),a.push({kind:"attr",el:l,name:K.name,before:Z,after:U})}}for(let K of Array.from(l.attributes)){if(yt(l,K.name)||n.ignoreAttribute(l,K.name)||(K.namespaceURI?O.hasAttributeNS(K.namespaceURI,K.localName):O.hasAttribute(K.name)))continue;if(R&&K.name==="class"&&!K.namespaceURI){let de=Ot(K.value,R.getAttribute("class"));if(de.length){let we=de.join(" ");if(we===K.value)continue;if(r.beforeAttributeUpdated("class",l,"update")===!1){f&&T(O,"class");continue}l.setAttribute("class",we),a.push({kind:"attr",el:l,name:"class",before:K.value,after:we});continue}}if(R&&st(R,K)===null)continue;if(r.beforeAttributeUpdated(K.name,l,"remove")===!1){f&&T(O,K.name);continue}let U=K.value;K.namespaceURI?l.removeAttributeNS(K.namespaceURI,K.localName):l.removeAttribute(K.name),a.push({kind:"attr",el:l,name:K.name,before:U,after:null})}}function yt(l,O){let R=l.tagName;return R==="INPUT"?O==="value"||O==="checked"||O==="disabled":R==="OPTION"?O==="selected":!1}function Nt(l){return l===s.activeElement}function Lt(l){let O=s.activeElement;return!!O&&O!==s.body&&l.contains(O)}function qt(l,O){let R=O&&O.local&&O.local.nodeType===1&&O.local!==l?O.local:null;if(!R)return!0;let K=l.tagName==="TEXTAREA"?R.textContent:R.getAttribute("value")??"";return l.value!==K}function cn(l,O){return!!n.protectFocusedValue&&Nt(l)&&qt(l,O)}function It(l,O,R){let K=Math.min(l.length,O.length),Z=0;for(;Z<K&&l[Z]===O[Z];)Z++;if(R<=Z)return R;let U=0;for(;U<K-Z&&l[l.length-1-U]===O[O.length-1-U];)U++;return R>=l.length-U?R+O.length-l.length:O.length-U}function $t(l){try{return l.selectionStart==null?null:[l.selectionStart,l.selectionEnd,l.selectionDirection]}catch{return null}}function wn(l,O,R,K){try{l.setSelectionRange(It(O,R,K[0]),It(O,R,K[1]),K[2]||"none")}catch{}}function jt(l,O){let R=l.value,K=$t(l);l.value=O,K&&wn(l,R,O,K)}function rn(l){let O=l&&l.remote;return O&&O.nodeType===1?O:null}function Gt(l,O,R){let K=l.tagName,Z=rn(R),U=n.formState==="property"&&Z?Z:O;if(K==="INPUT"){let de=cn(l,R),we=(l.getAttribute("type")||"").toLowerCase(),le=we!=="file"&&we!=="checkbox"&&we!=="radio",Ae=Z&&Z.hasAttribute("value")&&Z.value!==Z.getAttribute("value")?Z.value:null;if(le&&!de)if(n.formState==="property"){let W=O.getAttribute("value"),X=l.getAttribute("value");(X!==W||l.value!==U.value)&&L("value",l,W==null?"remove":"update")!==!1&&(X!==W&&(W==null?l.removeAttribute("value"):l.setAttribute("value",W),a.push({kind:"attr",el:l,name:"value",before:X,after:W})),l.value!==U.value&&(Nt(l)?jt(l,U.value):l.value=U.value))}else if(O.hasAttribute("value")||Ae!=null){let W=Ae??O.getAttribute("value");l.getAttribute("value")!==W&&L("value",l,"update")!==!1?(l.setAttribute("value",W),l.value!==W&&(Nt(l)?jt(l,W):l.value=W),a.push({kind:"attr",el:l,name:"value",before:null,after:W})):l.value!==W&&l.getAttribute("value")===W&&(Nt(l)?jt(l,W):l.value=W)}else(l.hasAttribute("value")||l.value!=="")&&L("value",l,"remove")!==!1&&(l.removeAttribute("value"),l.value="",a.push({kind:"attr",el:l,name:"value",before:"",after:null}));if(!le&&we!=="file"){let W=O.getAttribute("value");W==null?l.hasAttribute("value")&&L("value",l,"remove")!==!1&&l.removeAttribute("value"):l.getAttribute("value")!==W&&L("value",l,"update")!==!1&&l.setAttribute("value",W)}n.protectFocusedValue&&Nt(l)||(fn(l,U,"checked"),n.formState==="property"&&l.indeterminate!==U.indeterminate&&(l.indeterminate=U.indeterminate)),fn(l,U,"disabled")}else if(K==="OPTION"){let de=l.parentNode&&l.closest("select");n.protectFocusedValue&&de&&Nt(de)||fn(l,U,"selected")}}function fn(l,O,R){let K=n.formState==="property"?!!O[R]:O.hasAttribute(R);if(n.formState!=="property"){let Z=l.hasAttribute(R);if(Z!==K){if(L(R,l,K?"update":"remove")===!1)return;K?l.setAttribute(R,""):l.removeAttribute(R),a.push({kind:"attr",el:l,name:R,before:Z?"":null,after:K?"":null})}}l[R]!==K&&(l[R]=K)}function $(l,O,R){if(cn(l,R)||L("value",l,"update")===!1)return;let K=rn(R),Z=O.textContent,U=K&&K.value!==K.defaultValue?K.value:Z,de=Nt(l)?$t(l):null,we=l.value;n.formState!=="property"&&l.textContent!==Z&&(a.push({kind:"text",node:l,before:l.textContent,after:Z}),l.textContent=Z),l.value!==U&&(l.value=U),de&&l.value!==we&&wn(l,we,l.value,de)}}function pl(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 h=s.getRangeAt(0);n.range={sc:h.startContainer,so:h.startOffset,ec:h.endContainer,eo:h.endOffset}}return n}function ml(e,o,t,n,s,h,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 a=(c,p)=>{let m=t.get(c);if(Array.isArray(m)){let v=m.find(b=>p>=b.from&&p<b.to)||m.find(b=>p===b.to)||m[m.length-1],I=h.get(v.merged);if(!I||!I.isConnected)return null;let g=n.get(v.merged),f=g&&g.flat?g.flat(v.flatStart+p):p;return[I,Math.max(0,Math.min(f,I.nodeValue.length))]}if(m&&!i.has(m.merged)){let v=(s.get(m.merged)||[c])[0];if(!v.isConnected)return null;let I=n.get(m.merged),g=m.shift+p,f=I?I(g):g;return[v,Math.max(0,Math.min(f,v.nodeValue.length))]}return c.isConnected?[c,Math.min(p,c.nodeType===3?c.nodeValue.length:c.childNodes.length)]:null},d=a(o.range.sc,o.range.so),w=a(o.range.ec,o.range.eo);if(!(!d||!w))try{let c=e.createRange();c.setStart(d[0],d[1]),c.setEnd(w[0],w[1]);let p=e.getSelection();p.removeAllRanges(),p.addRange(c)}catch{}}var gl={compared:0},bl=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function wl(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 qr(e,o,t,n,s,h,i,r){let a=new Map,d=new Set,w=c=>{if(n(c))return;let p=t(c);p&&(h.add(p),s.has(p)||a.has(p)?d.add(p):a.set(p,c))};for(let c of e)w(c);w(o);for(let c of i||o.querySelectorAll("*"))w(c);for(let c of d)a.delete(c),r.add(c);return a}function Kr(e,o,t,n,s,h){let i=!1;for(let w of s)w.startsWith("merge:")&&(i=!0);if(!i)return[...n];let r=new Map,a=[],d=h===kn?Co:"*";for(let w of[e,...e.querySelectorAll(d)]){if(t(w))continue;let c=o(w);if(!c||!(n.has(c)||s.has(c)))continue;let p=(r.get(c)||0)+1;r.set(c,p),p===2&&a.push(c)}return a}function Fr({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:s,identity:h,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(!wl(e,o,s.ignoreAttribute))return{bail:"root-attrs"};let{ignored:r,remoteWins:a}=s,d=Ls(s.scripts.merge===!1?null:s.scripts.mergeTags,i),w=fe=>{let x=d(fe);return x!==null?x:h.base(fe)||null},c=fe=>{let x=d(fe);return x!==null?x:h.remote(fe)||null},p=[],m=[],v=new Map,I=new Map,g={same:v,differ:I},f=fe=>({bail:fe,comparisons:g}),b=(fe,x,Y=!0)=>{if(v.get(fe)===x)return!0;if(I.get(fe)===x)return!1;if(gl.compared++,Y&&fe.isEqualNode(x))return v.set(fe,x),!0;let ae=fe.nodeType===x.nodeType;if(ae&&fe.nodeType===1){if(ae=Rs(fe,x),ae){let oe=fe.firstChild,Ee=x.firstChild;for(;oe&&Ee;oe=oe.nextSibling,Ee=Ee.nextSibling)if(!b(oe,Ee,!1)){ae=!1;break}(oe||Ee)&&(ae=!1)}}else ae&&(ae=fe.isEqualNode(x));return(ae?v:I).set(fe,x),ae},B=e,S=o,T=!1,M=()=>{v.set(B,S);for(let fe=0;fe<p.length;fe++)v.set(p[fe],m[fe]);return f("equal")};for(;;){let fe=B.childNodes,x=S.childNodes;if(fe.length!==x.length)break;let Y=Xe=>b(fe[Xe],x[Xe])?(v.set(fe[Xe],x[Xe]),!1):!0,ae=-1,oe=-1;for(let Xe=0;Xe<fe.length;Xe++){if(fe[Xe].nodeType!==1)continue;let dt=0;for(let Ge=fe[Xe].firstElementChild;Ge;Ge=Ge.nextElementSibling)dt++;dt>=oe&&(oe=dt,ae=Xe)}let Ee=[],je=!1;for(let Xe=0;Xe<fe.length&&Ee.length<2;Xe++)Xe!==ae&&Y(Xe)&&Ee.push(Xe);if(ae>=0&&Ee.length<2&&(Ee.length===0&&Rs(B,S)?(Ee.push(ae),je=!0):Y(ae)&&Ee.push(ae)),Ee.length!==1){if(!T&&Ee.length===0&&Rs(B,S))return M();break}let Ne=fe[Ee[0]],tt=x[Ee[0]];if(T=T||!je,T&&I.set(Ne,tt),Ne.nodeType!==1||tt.nodeType!==1||Ne.tagName!==tt.tagName)break;if(w(Ne)!==c(tt)){if(!T&&b(Ne,tt))return M();break}p.push(B),m.push(S),B=Ne,S=tt}I.set(B,S);for(let fe=0;fe<p.length;fe++)I.set(p[fe],m[fe]);if(B===e||B.tagName==="HEAD"||B.tagName==="BODY")return f("root-level");if(p.length<2||p[1].tagName!=="BODY")return f("not-in-body");if(r(B)||r(S))return f("ignored-ancestor");if(a(B)||a(S))return f("remote-wins-ancestor");for(let fe of p)if(bl.has(fe.tagName))return f("form-ancestor");if(B.tagName==="SCRIPT"||B.getElementsByTagName("script").length||S.getElementsByTagName("script").length)return f("script-or-template");let L=n(B);if(!L||L.nodeType!==1||L.tagName!==B.tagName)return f("no-live-twin");if(!t.contains(L))return f("live-detached");for(let fe of p){let x=n(fe);if(!x||x.nodeType!==1)return f("ancestor-live")}let N=h.base===kn&&h.remote===kn&&r===os,A=new Set,E=new Set,V=[],j=null,D=fe=>{fe&&(A.has(fe)?E.add(fe):A.add(fe))},y=(fe,x)=>{let Y=d(fe),ae=Y!==null?Y:h.base(fe)||null;return ae!==(Y!==null?Y:h.remote(x)||null)?!1:(D(ae),!0)},k=(fe,x)=>{for(let Y=fe.firstElementChild,ae=x.firstElementChild;Y;Y=Y.nextElementSibling,ae=ae.nextElementSibling){let oe=r(Y);if(oe!==r(ae))return!1;if(!oe&&(!y(Y,ae)||!k(Y,ae)))return!1}return!0},J=fe=>{let x=fe+1<p.length?p[fe+1]:B;for(let Y=p[fe].firstElementChild,ae=m[fe].firstElementChild;Y;Y=Y.nextElementSibling,ae=ae.nextElementSibling){if(Y===x){let je=fe+1<p.length?J(fe+1):null;if(je)return je;continue}let oe=r(Y);if(oe!==r(ae))return"outside-id-changed";if(oe)continue;let Ee=n(Y);if(!Ee||Ee.nodeType!==1)return"sibling-live";if(V.push([Y,ae]),!N&&(!y(Y,ae)||!k(Y,ae)))return"outside-id-changed";fe===0&&Y.tagName==="HEAD"&&w(Y)&&(j=[Y,ae])}return null},H=J(0);if(H)return f(H);let q=new Set(p),Me=null;if(h.base===kn){Me=[];for(let fe of e.querySelectorAll(Co))fe===B||q.has(fe)||(B.contains(fe)?Me.push(fe):N&&D(w(fe)))}let Oe=new Set,Re=new Set,ie=new Set,xe=qr(p,B,w,r,A,Oe,Me,Re),qe=qr(m,S,c,r,A,Oe,h.remote===kn&&S.querySelectorAll(Co),ie);return j&&(E.has(w(j[0]))||Oe.has(w(j[0])))&&(j=null),{scope:{chain:p,root:B,onChain:q,baseIndex:xe,remoteIndex:qe,baseDropped:Re,remoteDropped:ie,head:j,same:v,differ:I,dropped:[...Kr(e,w,r,E,Re,h.base),...Kr(o,c,r,E,ie,h.remote)],held:fe=>{for(let x=1;x<p.length;x++)if(fe.map.get(p[x])!==m[x])return!1;for(let[x,Y]of V)if(fe.map.get(x)!==Y)return!1;return!0}}}}var _r=Symbol("hyper-morph-duplicate-key"),zr=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function Lo(e,o){return o.map(t=>{let n=new Map;for(let s of e){if(s.nodeType!==1)continue;let h=t(s);h==null||h===""||n.set(h,n.has(h)?_r:s)}return n})}function $r(e,o,t,n){for(let s=0;s<n.length;s++){let h=n[s](e);if(h==null||h===""||o[s].get(h)!==e)continue;let i=t[s].get(h);if(!(!i||i===_r)&&i.tagName===e.tagName)return i}return null}function bo(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),h=t.tiers&&t.tiers.length?t.tiers:zr,i=null;function r(){return i||(i=Lo([e,...e.querySelectorAll("*")],h)),i}let a=null;function d(){return a||(a=Lo([o,...o.querySelectorAll("*")],h)),a}function w(A){return!A.parentElement||!A.parentElement.parentElement}function c(A,E,V){return w(A)||bo(A,r(),h)?(V.push({type:"subtree",el:A,base:E}),!1):!0}function p(A,E){let V=[];for(let j of A.attributes)s(A,j.name)||E.getAttribute(j.name)!==j.value&&V.push(j.name);for(let j of E.attributes)s(A,j.name)||A.hasAttribute(j.name)||V.push(j.name);return V}function m(A){let E=[],V=null,j=()=>{V!==null&&(E.push({nodeType:3,nodeValue:V}),V=null)};for(let D of A.childNodes){if(D.nodeType===3){V=(V===null?"":V)+D.nodeValue;continue}D.nodeType===1&&n(D)||(j(),(D.nodeType===1||D.nodeType===8)&&E.push(D))}return j(),E}function v(A,E){if(A.nodeType!==E.nodeType)return!1;if(A.nodeType!==1)return!0;if(A.tagName!==E.tagName)return!1;for(let V of h){let j=V(A),D=V(E);if(j!=null&&j!==""&&D!=null&&D!==""&&j!==D)return!1}return!0}function I(A){let E="";for(let V of A)V.nodeType===3&&V.nodeValue.trim()!==""?E+="\0"+V.nodeValue:V.nodeType===8&&(E+=""+V.nodeValue);return E}function g(A,E,V){let j=m(A),D=m(E);if(j.length===D.length){let fe=!0;for(let x=0;x<j.length;x++)if(!v(j[x],D[x])){fe=!1;break}if(fe){for(let x=0;x<j.length;x++){let Y=j[x];if(Y.nodeType===1){if(f(Y,D[x],V))return!0}else if(Y.nodeValue!==D[x].nodeValue)return!0}return!1}}let y=j.filter(fe=>fe.nodeType===1),k=D.filter(fe=>fe.nodeType===1);if(I(j)!==I(D))return!0;let J=Lo(y,h),H=Lo(k,h),q=[],Me=new Set,Oe=[];for(let fe of y){let x=$r(fe,J,H,h);x&&!Me.has(x)?(q.push([fe,x]),Me.add(x)):Oe.push(fe)}let Re=[];for(let fe of Oe)bo(fe,J,h)?V.push({type:"subtree",el:fe,base:null}):Re.push(fe);let ie=[];for(let fe of k)Me.has(fe)||(bo(fe,H,h)?V.push({type:"deletion",el:fe}):ie.push(fe));if(Re.length!==ie.length)return!0;for(let fe=0;fe<Re.length;fe++)if(!v(Re[fe],ie[fe]))return!0;let xe=new Map(q);for(let fe=0;fe<Re.length;fe++)xe.set(Re[fe],ie[fe]);let qe=-1;for(let fe of y){let x=xe.get(fe);if(!x)continue;let Y=k.indexOf(x);if(Y<qe)return!0;qe=Y}for(let fe=0;fe<Re.length;fe++)if(f(Re[fe],ie[fe],V))return!0;for(let[fe,x]of q)if(f(fe,x,V))return!0;return!1}function f(A,E,V){if(A.tagName!==E.tagName)return c(A,E,V);let j=p(A,E),D=[];if(g(A,E,D))return c(A,E,V);if(j.length){if(!w(A)&&!bo(E,d(),h))return!0;V.push({type:"attrs",el:A,names:j,base:E})}return V.push(...D),!1}let b=[],B=p(e,o);B.length&&b.push({type:"attrs",el:e,names:B});let S=(A,E)=>Array.from(A.children).find(V=>V.tagName===E)||null,T=S(e,"HEAD"),M=S(o,"HEAD");if(T&&M){let A=[];f(T,M,A),A.length&&b.push({type:"head",el:T})}else(T||M)&&T&&b.push({type:"head",el:T});let L=S(e,"BODY"),N=S(o,"BODY");return L&&N?f(L,N,b):L&&b.push({type:"subtree",el:L,base:null}),{entries:b}}function Yr(e,o,t={}){let n=t.tiers&&t.tiers.length?t.tiers:zr,s=e.documentElement,h=[],i=0,r=f=>({ok:!1,placed:h,held:f,skippedAttrs:i});if(!s)return r(null);function a(f){let b=[f,...f.querySelectorAll("*")];return Lo(b,n)}let d=a(s),w=new Map,c=f=>{let b=f.getRootNode(),B=w.get(b);if(!B){let S=b.nodeType===9?b.documentElement:b;B=a(S),w.set(b,B)}return B};function p(f){if(!f.parentElement&&f.tagName==="HTML")return s;if(f.parentElement&&!f.parentElement.parentElement&&f.parentElement.tagName==="HTML"){if(f.tagName==="BODY")return e.body||null;if(f.tagName==="HEAD")return e.head||null}return null}function m(f){let b=p(f);return b||$r(f,c(f),d,n)}function v(f){if(!f)return null;let b=m(f);return b&&b.isConnected?b:null}function I(f){for(let b=0;b<n.length;b++){let B=n[b](f);B!=null&&B!==""&&d[b].set(B,f)}}for(let f of o){if(f.type!=="deletion")continue;let b=m(f.el);b&&b!==s&&b.remove()}let g=o.filter(f=>f.type!=="deletion").sort((f,b)=>f.el===b.el?0:f.el.compareDocumentPosition(b.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let f of g){if(f.type==="head"){let N=e.importNode(f.el,!0);e.head?e.head.replaceWith(N):s.insertBefore(N,s.firstChild),h.push({entry:f,imported:N});continue}if(f.type==="attrs"){let N=v(f.el)||v(f.base);if(!N){i++;continue}for(let A of f.names)f.el.hasAttribute(A)?N.setAttribute(A,f.el.getAttribute(A)):N.removeAttribute(A);continue}let b=f.el;if(p(b))return r(f);let B=v(b)||v(f.base);if(B){let N=e.importNode(b,!0);B.replaceWith(N),I(N),h.push({entry:f,imported:N});continue}if(f.base!=null&&!bo(f.base,c(f.base),n)||!bo(b,c(b),n))return r(f);let S=b.parentElement;if(!S)return r(f);let T=v(S);if(!T)return r(f);let M=null;for(let N=b.previousElementSibling;N;N=N.previousElementSibling){let A=v(N);if(A&&A.parentNode===T){M=A;break}}let L=e.importNode(b,!0);if(M)T.insertBefore(L,M.nextSibling);else{let N=Array.prototype.indexOf.call(S.children,b);T.insertBefore(L,T.children[N]||null)}I(L),h.push({entry:f,imported:L})}return{ok:!0,placed:h,held:null,skippedAttrs:i}}var yl='[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"]',kl='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',xl='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Tl(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 vl(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let s=o;if(s.nodeType===9){let h=e.getAttribute("id");s=h&&s.getElementById(h)||(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=Sl(e,o,n)),!!s)return t?Array.from(s.childNodes):s}function Sl(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let s=new Map,h=[n,...n.querySelectorAll("script")];for(let a of h){let d=ho(a,t);d&&!s.has(d.key)&&s.set(d.key,a.textContent)}if(!s.size)return null;let i=e.cloneNode(!0),r=!1;for(let a of[i,...i.querySelectorAll("script")]){let d=ho(a,t);d&&s.has(d.key)&&(a.textContent=s.get(d.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 h of s)t.body.appendChild(t.adoptNode(h));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:(a,d)=>Tl(a)||(n==="history"?!(d&&a.matches(xl))&&a.matches(kl):a.matches(yl)),h=t.callbacks||{},i={ignore:s,hooks:h,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 wo(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 a=Object.assign({},i,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Xr(o,e.ownerDocument)});return wo(a)}t.morphStyle==="innerHTML"&&(i.children=!0);let r=vl(e,t.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return r!==void 0&&(i.base=r),Zo(e,o,i)}var Nl=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),On=()=>{};function Eo(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let r of Object.keys(e))if(!Nl.has(r))throw new TypeError(`unknown option "${r}"`);let t=Object.assign({beforeNodeAdded:On,afterNodeAdded:On,beforeNodeRemoved:On,afterNodeRemoved:On,beforeNodeMorphed:On,afterNodeMorphed:On,beforeAttributeUpdated:On},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 h=e.protectFocusedValue;if(h!==void 0&&typeof h!="boolean"&&h!=="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,opaque:typeof e.opaque=="function"?e.opaque:()=>!1,conflicts:n,protectFocusedValue:h===void 0?!0:h,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 yo(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 ko(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 h=>s(h)||t.get(h)||n(h)}return s=>t.get(s)||n(s)}return kn}function ni(e,o,t,n={}){let s=m=>m&&m.nodeType===9?m.documentElement:m,h=s(o),i=s(t),r=s(e)||h;if(n.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let a=Object.assign({},n);delete a.live,delete a.base,delete a.remote;let d=Eo(a,[r,h,i].filter(Boolean)),w=n.identity||{},c=zn(),p=Jo(r,h,i,{identity:{base:ko(w.base,r),local:ko(w.local,h),remote:ko(w.remote,i)},authored:{base:yo(w.base),local:yo(w.local),remote:yo(w.remote)},skipUnchanged:d.hooks.beforeNodeMorphed===On&&d.hooks.afterNodeMorphed===On,ignored:d.ignored,remoteWins:d.remoteWins,ignoreAttribute:d.ignoreAttribute,conflicts:d.conflicts,mergeTags:d.scripts.merge===!1?null:d.scripts.mergeTags,baseURI:h.ownerDocument&&h.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:d.children,stats:c});return delete p.recoveryLinks,delete p.lineage,p}function Ps({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:s,options:h,identity:i,childrenOnly:r,isDocument:a}){let d=Eo(h,[e,o,t,n].filter(Boolean));if(d.ignored(e)){let y=Bs(),k=d.lineage?Ao(d.lineage,e,y):null;return{report:y,loads:[],lineage:k}}let w=e.ownerDocument,c=d.lineage?vs(d.lineage,{liveRoot:e,localRoot:t,toLive:s}):null,p=d.scripts.execute?mr(e,d.ignored,w.baseURI):null,m=zn(),v=d.hooks.beforeNodeMorphed===On&&d.hooks.afterNodeMorphed===On,I={identity:{base:ko(i.base,o||t),local:ko(i.local,t),remote:ko(i.remote,n)},authored:{base:yo(i.base),local:yo(i.local),remote:yo(i.remote)},ignored:d.ignored,remoteWins:d.remoteWins,ignoreAttribute:d.ignoreAttribute,conflicts:d.conflicts,mergeTags:d.scripts.merge===!1?null:d.scripts.mergeTags,baseURI:w.baseURI,localIsBase:!o,childrenOnly:r,skipUnchanged:v,lineage:c?{locals:c.locals}:null},g=d.fastPath&&a&&!r&&v&&o===t,f=null,b=null;if(g){let y=Fr({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:s,o:d,identity:I.identity,baseURI:w.baseURI});I.comparisons=y.comparisons||y.scope,y.bail?b=y.bail:(f=Jo(o,t,n,Object.assign({},I,{stats:m,scope:y.scope})),f||(b="chain-unpaired",m=zn()))}f||(f=Jo(o||t,t,n,Object.assign({},I,{stats:m}))),g&&(m.fastPathAttempted=1,m.fastPathTaken=b?0:1,m.fastPathFallback=b),f.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(y=>d.hooks[y]!==On)&&Ar(f.conflicts,f.recoveryLinks,s),d.beforeApply&&d.beforeApply(f.doc);let B=globalThis.__hyperMorphProfile,S=B?performance.now():0,T=Wr(e,f.root,f,{toLive:s,localRoot:t,ignored:d.ignored,ignoreAttribute:d.ignoreAttribute,opaque:d.opaque,formState:d.formState,protectFocusedValue:d.protectFocusedValue,restoreFocus:d.restoreFocus,preserve:d.head.preserve,hooks:d.hooks,childrenOnly:r,keepLiveOnly:d.keepLiveOnly,trackInserted:!!c});B&&(B.apply=(B.apply||0)+(performance.now()-S));let M=[];if(d.head.awaitLoads)for(let y of T.applied){if(y.kind!=="insert"||y.node.nodeType!==1)continue;let k=y.node;k.tagName==="LINK"&&/\bstylesheet\b/i.test(k.getAttribute("rel")||"")&&k.getAttribute("href")&&k.closest("head")&&M.push(new Promise(H=>{k.addEventListener("load",()=>H()),k.addEventListener("error",()=>H())}))}let L=null,N=null;if(p){let y=gr(e,p,{ignored:d.ignored,skip:T.mergedScriptsLive,baseURI:w.baseURI,beforeNodeAdded:d.hooks.beforeNodeAdded,afterNodeAdded:d.hooks.afterNodeAdded,trackRecovery:!!f.recoveryLinks});M.push(...y.loads),L=y.swapped,N=y.vetoed}let A=y=>L&&L.get(y)||y,E=y=>{if(T.keptRuns.has(y))return T.runOf.get(y);let k=T.liveOf.get(y)||T.heldBy.get(y)||T.insertedLive.get(y);return k?A(k):null},V=y=>{let k=y&&T.liveOf.get(y);return k?A(k):null},j=y=>{let k=y&&E(y);return Array.isArray(k)?k[0]:k};if(f.recoveryLinks){let y=(k,J,H)=>(J.namespaceURI?k.getAttributeNS(J.namespaceURI,J.localName):k.getAttribute(J.qualifiedName))===H;Ir(f.conflicts,f.recoveryLinks,{lookup:E,vetoed:T.vetoed,vetoedAttrs:T.vetoedAttrs,removedVetoes:T.removedVetoes,vetoedLive:N,liveAttr:y,ignored:d.ignored,liveRoot:e})}let D={applied:T.applied,decisions:f.decisions.map(y=>Object.assign({},y,{node:y.node?V(y.node):null,el:y.el?V(y.el):null,applied:!!(y.node?V(y.node):y.el&&V(y.el))})),conflicts:f.conflicts.map(y=>Object.assign({},y,{node:y.node?y.kind==="text"&&y.recovery.subject.nodeType===8?j(y.node):V(y.node):y.node,el:y.el?y.kind==="structure"?j(y.el):V(y.el):y.el})),localDiverged:f.localDiverged,identities:T.identities,moved:T.moved,replaced:T.replaced,stats:m};return c&&(D.lineage=c.finish(f.lineage,E)),{report:D,loads:M,lineage:c}}var Qr=new WeakMap;function Bs(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:zn()}}function wo(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");return o.lineage===void 0?Zr(o):Ts(o,o.live.documentElement,n=>Zr(n))}function Zr(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),h=typeof o.base=="string"&&o.base===""?null:o.base,i=h?n("base",h):null,r=o.local?o.local.root:t.documentElement,a=o.local?o.local.toLive:p=>p;js(t,s);let{report:d,loads:w,lineage:c}=Ps({liveRoot:t.documentElement,baseRoot:i?i.documentElement:null,localRoot:r,remoteRoot:s.documentElement,toLive:a,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return c?.deliver(d),Promise.all(w).then(()=>d)}function oi(e,o,t={}){return wo(Object.assign({},t,{live:e,base:null,remote:o}))}function ei(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 h=Bo(e,o),i=n[1].toLowerCase()==="html"?h.documentElement:h.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 t.lineage===void 0?ti(e,o,t):Ts(t,e,n=>ti(e,o,n))}function ti(e,o,t={}){let n=e.ownerDocument,{base:s,...h}=t,i=!!h.children,r=Eo(h,[e]);if(r.ignored(e)){let I=Bs();return r.lineage&&Ao(r.lineage,e,I).deliver(I),Promise.resolve(I)}let a=ei(o,n),d=s!=null?ei(s,n):null,w,c=null;if(i)w=a.root,c=d?d.root:null;else{if(w=a.first,c=d?d.first:null,!w){let I=Eo(h),g=I.lineage?Ao(I.lineage,e,{}):null;I.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),I.hooks.afterNodeRemoved(e));let f={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:zn()};return g&&(f.lineage=g.result,g.deliver(f)),Promise.resolve(f)}if(w.tagName!==e.tagName){let I=Eo(h,[e,w]);if(I.hooks.beforeNodeMorphed(e,w)===!1){let b=Bs();return I.lineage&&Ao(I.lineage,e,b).deliver(b),Promise.resolve(b)}let g=Ps({liveRoot:e,baseRoot:c&&c.tagName===e.tagName?c:null,localRoot:e,remoteRoot:w,toLive:b=>b,options:h,identity:h.identity||{},childrenOnly:!0,isDocument:!1}),f=pn(w)?Mo(w,n):n.importNode(w,!1);if(!pn(f))for(;e.firstChild;)f.appendChild(e.firstChild);return I.hooks.beforeNodeAdded(f)===!1?(Xo(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):I.hooks.beforeNodeRemoved(e)===!1?(Xo(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(f),Xo(g.report.conflicts,e,f),I.hooks.afterNodeRemoved(e),I.hooks.afterNodeAdded(f),I.hooks.afterNodeMorphed(e,w),g.report.replaced.push(f),g.report.applied.push({kind:"insert",node:f,parent:f.parentNode},{kind:"remove",node:e,parent:f.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,f),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:p,loads:m,lineage:v}=Ps({liveRoot:e,baseRoot:c,localRoot:e,remoteRoot:w,toLive:I=>I,options:h,identity:h.identity||{},childrenOnly:i,isDocument:!1});return v?.deliver(p),Promise.all(m).then(()=>p)}var Al={mergeDocument:wo,morphDocument:oi,morphElement:Zo,merge3:ni,morph:Qo};return fi(Ml);})();
5
5
 
6
6
  var morph = HyperMorph.morph;
7
7