@panphora/clayjs 1.8.1 → 1.9.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.
- package/dist/clay.standalone.js +2477 -1549
- package/package.json +8 -4
- package/src/core/host-attrs.js +11 -0
- package/src/core/host-meta.js +47 -12
- package/src/core/is-edit-mode.js +5 -2
- package/src/events/onpagemutation.js +4 -2
- package/src/lib/root-attrs.js +6 -1
- package/src/loader-logic.js +4 -1
- package/src/loader.js +11 -3
- package/src/plugins/people.js +424 -0
- package/src/plugins/sortable.js +68 -0
- package/src/plugins/upload.js +6 -0
- package/src/ui/bevel-controls.js +70 -10
- package/src/ui/bevel-dialog.js +70 -21
- package/src/ui/dialogs.js +16 -8
- package/src/ui/index.js +3 -0
- package/src/ui/modal.js +18 -3
- package/src/ui/theme-parts.js +122 -0
- package/src/ui/theme.js +277 -0
- package/src/vendor/hyper-morph.vendor.js +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var HyperMorph=(()=>{var ns=Object.defineProperty;var oi=Object.getOwnPropertyDescriptor;var si=Object.getOwnPropertyNames;var ri=Object.prototype.hasOwnProperty;var ii=(e,o)=>{for(var t in o)ns(e,t,{get:o[t],enumerable:!0})},li=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of si(o))!ri.call(e,s)&&s!==t&&ns(e,s,{get:()=>o[s],enumerable:!(n=oi(o,s))||n.enumerable});return e};var ai=e=>li(ns({},"__esModule",{value:!0}),e);var Ml={};ii(Ml,{createIdentityStore:()=>Us,createParseCache:()=>Do,default:()=>Al,diff:()=>_n,findChangedRoots:()=>Gr,importMap:()=>jo,merge3:()=>ei,merge3Text:()=>ro,mergeDocument:()=>go,mergeJson:()=>As,mergeScriptText:()=>Go,morph:()=>Qo,morphDocument:()=>ti,morphElement:()=>Zo,parseJsonRelaxed:()=>zo,parseRulesRelaxed:()=>yr,spliceProtected:()=>Yr,tieredIdentity:()=>rs});function Bo(e,o){if(typeof e=="string"){let t=o&&o.defaultView,n=t&&t.DOMParser||globalThis.DOMParser;return new n().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Do(e){let o=new Map;return(t,n)=>{if(typeof n!="string")return Bo(n,e);let s=o.get(t);if(s&&s.text===n)return s.doc;let d=Bo(n,e);return o.set(t,{text:n,doc:d}),d}}function js(e,o){let t=o.doctype;if(!t)return!1;let n=e.doctype;if(n&&n.name===t.name&&n.publicId===t.publicId&&n.systemId===t.systemId)return!1;let s=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return n?e.replaceChild(s,n):e.insertBefore(s,e.documentElement),!0}var os=()=>!1;function ss(e,o=[]){if(typeof e!="function")return os;let t=new WeakMap,n=new Set(o);return s=>{if(!s||s.nodeType!==1)return!1;let d=t.get(s);if(d!==void 0)return d;let i=[],r=s,l=!1;for(;r&&r.nodeType===1;){let u=t.get(r);if(u!==void 0){l=u;break}if(i.push(r),e(r,n.has(r))){l=!0;break}if(n.has(r))break;r=r.parentElement}for(let u of i)t.set(u,l);return l}}var Cl=Object.freeze(["root-tag","equal","root-attrs","root-level","not-in-body","ignored-ancestor","remote-wins-ancestor","form-ancestor","script-or-template","no-live-twin","live-detached","ancestor-live","sibling-live","outside-id-changed","chain-unpaired"]);function Fn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Us(e){let o=new WeakMap,t=0,n=r=>o.get(r)||null,s=r=>{let l=o.get(r);return l||(l=`${e}:${++t}`,o.set(r,l)),l};return{idOf:n,ensure:s,adopt:(r,l)=>{r&&typeof l=="string"&&l&&o.set(r,l)},exportMap:(r,l)=>{let u={},b=[],a=[],h=(p,v)=>{let O=l(p);O&&(u[v]=s(O));let m=p.children;b.push(m.length),a.push(p.tagName.toLowerCase());for(let c=0;c<m.length;c++)h(m[c],v===""?String(c):`${v}.${c}`)};return h(r,""),u["~"]=b.join(","),u["^"]=a.join(","),u}}}function jo(e,o){let t=new WeakMap;if(!e||!o||typeof o!="object"||Array.isArray(o))return t;let n=o["~"],s=typeof n=="string"?n.split(",").map(Number):null,d=s&&typeof o["^"]=="string"?o["^"].split(","):null,i=a=>Number.isInteger(a)&&a>=0,r=0,l=!1,u=a=>{let h=a;for(;h>0;){let p=s[r++];if(r>s.length||!i(p))return!1;h+=p-1}return!0},b=(a,h)=>{if(l)return;if(s){let O=r++,m=s[O];if(O>=s.length||!i(m)){l=!0;return}let c=!d||d[O]===a.tagName.toLowerCase();if(!c||m!==a.children.length){let g=c&&o[h];typeof g=="string"&&g&&t.set(a,g),u(m)||(l=!0);return}}let p=o[h];typeof p=="string"&&p&&t.set(a,p);let v=a.children;for(let O=0;O<v.length;O++)b(v[O],h===""?String(O):`${h}.${O}`)};return b(e,""),t}function rs(e){return o=>{for(let t of e){let n=t(o);if(typeof n=="string"&&n!=="")return n}return null}}var kn=rs([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Uo(e,o,t,n=null,s=null){let d=new Map,i=new Set,r=l=>{if(t(l))return;let u=o(l);u&&(d.has(u)?i.add(u):d.set(u,l))};if(n){let l=u=>{for(let b of u.querySelectorAll(n))r(b);for(let b of u.querySelectorAll("template"))b.content&&l(b.content)};r(e),l(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let l=u=>{r(u);let b=u.tagName==="TEMPLATE"&&u.content?u.content.children:u.children;for(let a=0;a<b.length;a++)l(b[a])};l(e)}for(let l of i)d.delete(l),s&&s.add(l),is(l);return d}function is(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var ci=new Set(["href","src","name","type","role"]),Hs=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function oo(e,o=5381){let t=o;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return t>>>0}function Vs(e){return e.replace(/\s+/g," ")}var fi=0;function Ws({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,s=new WeakMap;function d(A){let E=A.attributes,S=E.length;if(S===0)return{all:"",sig:A.tagName+"|"};let N=[],C="",j=[];for(let D=0;D<S;D++){let B=E[D],w=B.name;o(A,w)||N.push(w+"="+B.value),w==="class"?C=B.value.indexOf(" ")<0?B.value:B.value.split(/\s+/).filter(Boolean).sort().join(" "):ci.has(w)&&j.push(w+"="+B.value)}return N.length>1&&N.sort(),j.length>1&&j.sort(),{all:N.join(""),sig:A.tagName+"|"+C+(j.length?"|"+j.join("|"):"")}}function i(A){return A.nodeType===1&&A.tagName==="TEMPLATE"&&A.content?A.content.childNodes:A.childNodes}function r(A){let E=n.get(A);if(E)return E;if(A.nodeType===3)E={hash:"T"+oo(A.nodeValue),hint:Vs(A.nodeValue).slice(0,64),sig:null,tok:null};else if(A.nodeType===8)E={hash:"C"+oo(A.nodeValue),hint:"",sig:null,tok:null};else if(A.nodeType===1){let S=d(A),N=oo(A.tagName+""+S.all),C="";for(let j of u(A))if(j.nodeType===1){let D=r(j);N=oo(D.hash,N),C.length<64&&(C+=" "+D.hint)}else N=oo(b(j),N),j.kind==="text"&&C.length<64&&(C+=j.value.slice(0,64));E={hash:"E"+N,hint:Vs(C).trim().slice(0,64),sig:S.sig,tok:null}}else E={hash:"N"+A.nodeType,hint:"",sig:null,tok:null};return n.set(A,E),E}function l(A){if(!A.tok){A.tok=new Set;for(let E of A.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))E&&A.tok.add(E)}return A.tok}function u(A){let E=s.get(A);if(E)return E;E=[];let S=null,N=()=>{S&&(S.value=S.nodes.map(C=>C.nodeValue).join(""),E.push(S),S=null)};for(let C of i(A)){if(C.nodeType===3){S||(S={kind:"text",nodes:[],value:"",parent:A,hash:void 0}),S.nodes.push(C);continue}N(),C.nodeType===8?E.push({kind:"comment",nodes:[C],value:C.nodeValue,parent:A,hash:void 0}):C.nodeType===1&&!e(C)&&E.push(C)}return N(),s.set(A,E),E}function b(A){return A.nodeType===1?r(A).hash:(A.hash===void 0&&(A.hash=(A.kind==="text"?"T":"C")+oo(A.value)),A.hash)}function a(A,E){let S=l(r(A)),N=l(r(E));if(S.size===0&&N.size===0)return{coef:1,share:1};if(S.size===0||N.size===0)return null;let C=0;for(let j of S)N.has(j)&&C++;return{coef:C/Math.min(S.size,N.size),share:C/Math.max(S.size,N.size)}}function h(A,E){let S=a(A,E);return!!S&&S.coef>=.5}let p=new WeakMap;function v(A){let E=p.get(A);if(E)return E;E=[];for(let S of A.attributes)o(A,S.name)||E.push([S.namespaceURI||"",S.localName,S.value]);return E.sort((S,N)=>S[0]<N[0]?-1:S[0]>N[0]?1:S[1]<N[1]?-1:S[1]>N[1]?1:0),p.set(A,E),E}let O=new WeakMap;function m(A,E){if(A===E)return!0;if(b(A)!==b(E))return!1;let S=O.get(A);if(S&&S.has(E))return S.get(E);let N=O.get(E);if(N&&N.has(A))return N.get(A);let C=c(A,E),j=C===!0;return C===!1&&t&&t.hashRejected++,S||O.set(A,S=new WeakMap),S.set(E,j),j}function c(A,E){if(A.nodeType===1){if(E.nodeType!==1||A.tagName!==E.tagName||A.namespaceURI!==E.namespaceURI)return!1;let S=v(A),N=v(E);if(S.length!==N.length)return!1;for(let D=0;D<S.length;D++)if(S[D][0]!==N[D][0]||S[D][1]!==N[D][1]||S[D][2]!==N[D][2])return!1;let C=u(A),j=u(E);if(C.length!==j.length)return!1;for(let D=0;D<C.length;D++){if(b(C[D])!==b(j[D]))return!1;if(!m(C[D],j[D]))return fi}return!0}return E.nodeType===1?!1:A.kind===E.kind&&A.value===E.value}let g=new WeakMap,P=new Map,T=0;function x(A){let E=g.get(A);if(E)return E;let S=b(A),N=P.get(S);N||P.set(S,N=[]);let C=N.find(j=>m(j.unit,A));return E=C?C.key:"K"+T++,C||N.push({unit:A,key:E}),g.set(A,E),E}return{meta:r,unitsOf:u,unitHash:b,similar:h,score:a,childrenOf:i,equalUnits:m,exactUnitKey:x,ignored:e}}var Ks=16,ui=2e3,di=3,ls={align:0,certifyVisited:0,certifyScheduled:0};function as(e,o,t){let{meta:n,unitsOf:s,unitHash:d,similar:i,score:r,childrenOf:l,equalUnits:u,ignored:b}=t.analyzer,a=t.baseId||(()=>null),h=t.sideId||(()=>null),p=t.baseKey||(()=>null),v=t.sideKey||(()=>null),O=t.baseDropped||new Set,m=t.sideDropped||new Set,c=t.stats||null,g=c?new Set:null,P=c?new Set:null,T=new Map,x=new Map,A=new Set,E=new Map,S=new Set,N=new Set,C=new Set,j=[],D=[],B=[],w=[],y=ui,$=new Map,U=new Map,V=(H,X)=>{T.set(H,X),x.set(X,H)},Ne=new Set,Ae=new Set,De=null,oe=H=>{let X=H.nodeType?H.parentNode:H.parent;if(!X||X.nodeType!==11)return X;if(!De){De=new WeakMap;let de=pe=>{for(let se of pe.querySelectorAll("template"))se.content&&(De.set(se.content,se),de(se.content))};for(let pe of[e,o])de(pe.tagName==="TEMPLATE"&&pe.content?pe.content:pe)}return De.get(X)||null},xe=(H,X)=>{for(let de=oe(H);de&&!Ne.has(de);de=oe(de))Ne.add(de);for(let de=oe(X);de&&!Ae.has(de);de=oe(de))Ae.add(de)},$e=H=>{for(let X=oe(H);X;X=oe(X))if(T.has(X))return N.has(X);return!1},ae=H=>{for(let X=oe(H);X;X=oe(X)){let de=x.get(X);if(de!==void 0)return N.has(de)}return!1},k=H=>!!H&&H.nodeType===1,_=(H,X)=>{let de=E.get(H);return!!de&&de.has(X)},re=H=>Hs.has(H.tagName),Z=t.comparisons||t.scope,Be=(H,X)=>{if(Z){if(Z.same.get(H)===X)return!0;if(Z.differ.get(H)===X)return!1}if(!H.isEqualNode(X))return!1;if(H.tagName==="TEMPLATE")return u(H,X);let de=H.getElementsByTagName("template");if(de.length===0)return!0;let pe=X.getElementsByTagName("template");if(de.length!==pe.length)return!1;for(let se=0;se<de.length;se++)if(!u(de[se],pe[se]))return!1;return!0},Ke=(H,X)=>{let de=a(H);if(!de)return!0;let pe=h(X);return!pe||de===pe},Te=H=>{let X=p(H);return X&&t.baseIndex.get(X)===H&&!m.has(X)?X:null},it=H=>{let X=v(H);return X&&t.sideIndex.get(X)===H&&!O.has(X)?X:null},et=(H,X)=>{let de=Te(H);if(!de)return!0;let pe=it(X);return!pe||de===pe},mt=globalThis.__hyperMorphProfile,Ze=mt?performance.now():0;mt&&!t.scope&&(n(e),n(o),mt.meta=(mt.meta||0)+(performance.now()-Ze),Ze=performance.now()),V(e,o);let ft=new Set;for(let[H,X]of t.baseIndex){let de=t.sideIndex.get(H);de&&de.tagName===X.tagName&&!T.has(X)&&!x.has(de)&&(V(X,de),xe(X,de),ft.add(X))}if(ft.size){let H=[];if(t.scope)for(let se of t.scope.chain)ft.has(se)&&H.push(se);let X=[t.scope?t.scope.root:e];for(;X.length;){let se=X.pop();ft.has(se)&&H.push(se);let ke=l(se);for(let fe=ke.length-1;fe>=0;fe--)ke[fe].nodeType===1&&X.push(ke[fe])}let de=new Set;for(let se=H.length-1;se>=0;se--){let ke=H[se];t.scope&&t.scope.onChain.has(ke)?de.add(ke):ce(ke,T.get(ke),de)?(N.add(ke),C.add(ke),c&&c.certificationPairs++):de.add(ke)}let pe=new Set;for(let se of H)N.has(se)&&!pe.has(se)&&Ct(se,pe)}t.scope&&t.scope.head&&Le(t.scope.head[0],t.scope.head[1]);function Ct(H,X){let de=[H];for(;de.length;){let pe=de.pop();if(!X.has(pe)){X.add(pe),z(pe);for(let se of s(pe))k(se)&&T.has(se)&&de.push(se)}}}w.push([e,o]);for(let[H,X]of T)k(H)&&H!==e&&w.push([H,X]);return jt(),Dt(),mt&&(mt.align=(mt.align||0)+(performance.now()-Ze)),{map:T,reverse:x,moved:S,identical:N,pairIdenticalChildren:z,weak:A,unpair:Tt,rematch:Dt,insertedByHash:Rt,refused:P,identityPaired:ft};function Dt(){be(),jt();for(let H=0;H<B.length;){let X=B.length;Lt(H,X),H=X,jt(),be(),jt()}}function Tt(H){let X=T.get(H);if(!X)return;E.has(H)||E.set(H,new Set),E.get(H).add(X);let de=(se,ke)=>{T.delete(se),x.delete(ke),S.delete(se),N.delete(se),A.delete(se),C.delete(se)},pe=(se,ke)=>{for(let fe of s(se)){let G=T.get(fe);!G||ft.has(fe)||!(k(G)?ke.contains(G):ke.contains(G.nodes[0]))||(de(fe,G),k(fe)&&pe(fe,G))}};de(H,X),k(H)&&pe(H,X),j.push(H),D.push(X)}function Rt(){let H=new Map;for(let X of new Set(D)){if(x.has(X))continue;let de=n(X).hash;H.has(de)||H.set(de,[]),H.get(de).push(X)}return H}function jt(){for(;w.length;){let[H,X]=w.shift();T.get(H)!==X||C.has(H)||N.has(H)||un(H,X)}}function qt(H,X){if(!re(H))for(let de of s(H))k(de)&&(X.push(de),qt(de,X))}function un(H,X){C.add(H);let de=s(H),pe=s(X);ls.align+=de.length+pe.length,$=new Map,U=new Map;for(let ue=0;ue<de.length;ue++)$.set(de[ue],ue);for(let ue=0;ue<pe.length;ue++)U.set(pe[ue],ue);if(H.tagName==="HTML")for(let ue of["HEAD","BODY"]){let Ie=de.find(He=>k(He)&&He.tagName===ue),Pe=pe.find(He=>k(He)&&He.tagName===ue);Ie&&Pe&&!T.has(Ie)&&!x.has(Pe)&&V(Ie,Pe)}for(let ue=0;ue<de.length&&ue<pe.length;ue++){let Ie=de[ue],Pe=pe[ue];T.has(Ie)||x.has(Pe)||(k(Ie)?k(Pe)&&Ie.tagName===Pe.tagName&&Be(Ie,Pe)&&Le(Ie,Pe):!k(Pe)&&Ie.kind===Pe.kind&&Ie.value===Pe.value&&Le(Ie,Pe))}Ce(de,pe);let se=de.filter(ue=>!T.has(ue)),ke=pe.filter(ue=>!x.has(ue));se.length&&ke.length&&(F(se,ke),J(se,ke),ne(se,ke,de,pe),Oe(de,pe));let fe=!1,G=!1;for(let ue of de){if(!T.has(ue)){k(ue)&&(j.push(ue),qt(ue,j),fe=!0);continue}k(ue)&&!N.has(ue)&&w.push([ue,T.get(ue)])}for(let ue of pe)!x.has(ue)&&k(ue)&&(D.push(ue),qt(ue,D),G=!0);fe&&G&&B.push([H,X])}function Lt(H,X){for(let de=H;de<X;de++){let[pe,se]=B[de];if(T.get(pe)!==se)continue;let ke=s(pe),fe=s(se),G=new Map,ue=new Map,Ie=null;for(let Pe of ke)k(Pe)&&(T.has(Pe)?Ie=Pe:(G.has(Ie)||G.set(Ie,[]),G.get(Ie).push(Pe)));Ie=null;for(let Pe of fe)k(Pe)&&(x.has(Pe)?Ie=x.get(Pe):(ue.has(Ie)||ue.set(Ie,[]),ue.get(Ie).push(Pe)));for(let[Pe,He]of G){let Se=ue.get(Pe);if(!(!Se||He.length!==Se.length)&&He.every((Je,nt)=>Se[nt].tagName===Je.tagName&&Ke(Je,Se[nt])&&!_(Je,Se[nt])))for(let Je=0;Je<He.length;Je++)Jt(He[Je],Se[Je])}}}function Jt(H,X){V(H,X),A.add(H),w.push([H,X]),jt()}function F(H,X){let de=so(H,d),pe=so(X,d),se=new Map;for(let ke of X){let fe=d(ke);pe.get(fe)===1&&se.set(fe,ke)}for(let ke of H){if(T.has(ke))continue;let fe=d(ke);if(de.get(fe)!==1)continue;let G=se.get(fe);G&&!x.has(G)&&u(ke,G)&&Le(ke,G)}}function ce(H,X,de){let pe=[[H,X]];for(;pe.length;){let[se,ke]=pe.pop();if(ls.certifyVisited++,c&&c.certificationVisited++,se.nodeType!==ke.nodeType)return!1;if(se.nodeType===3||se.nodeType===8){if(se.nodeValue!==ke.nodeValue)return!1;continue}if(se.nodeType!==1){if(!se.isEqualNode(ke))return!1;continue}if(se.tagName!==ke.tagName||se.namespaceURI!==ke.namespaceURI||b(se)!==b(ke))return!1;let fe=se.attributes,G=ke.attributes;if(fe.length!==G.length)return!1;for(let Se=0;Se<fe.length;Se++){let Je=fe[Se];if(ke.getAttributeNS(Je.namespaceURI,Je.localName)!==Je.value)return!1}let ue=T.get(se);if(ue!==void 0&&ue!==ke)return!1;let Ie=x.get(ke);if(Ie!==void 0&&Ie!==se)return!1;if(se!==H){if(N.has(se))continue;if(de.has(se))return!1}let Pe=l(se),He=l(ke);if(Pe.length!==He.length)return!1;ls.certifyScheduled+=Pe.length;for(let Se=Pe.length-1;Se>=0;Se--)pe.push([Pe[Se],He[Se]])}return!0}function ge(H,X){return!k(H)||!(Ne.has(H)||Ae.has(X))?!0:!!M(H,X)||!(Te(H)||it(X))}function Le(H,X){if(k(H)&&(Ne.has(H)||Ae.has(X))){let de=M(H,X);if(!de){if(Te(H)||it(X))return;V(H,X),w.push([H,X]);return}for(let pe=0;pe<de.length;pe+=2){let se=de[pe],ke=de[pe+1],fe=T.get(se);fe!==void 0&&fe!==ke&&Me(se,fe);let G=x.get(ke);G!==void 0&&G!==se&&Me(G,ke),T.get(se)===ke&&(S.delete(se),A.delete(se),N.add(se),C.add(se))}}R(H,X)}function Me(H,X){T.delete(H),x.delete(X),S.delete(H),N.delete(H),A.delete(H),C.delete(H)}function M(H,X){let de=[H,X,!1],pe=[];for(;de.length;){let se=de.pop(),ke=de.pop(),fe=de.pop(),G=T.get(fe),ue=x.get(ke);if(fe!==H&&(G!==void 0&&G!==ke&&ft.has(fe)||ue!==void 0&&ue!==fe&&ft.has(ue)))return null;if(!(G===ke&&N.has(fe))&&((G!==void 0||ue!==void 0)&&pe.push(fe,ke),!!k(fe))){if(se||G!==void 0&&G!==ke||ue!==void 0&&ue!==fe){let Ie=s(fe),Pe=s(ke);for(let He=0;He<Ie.length&&He<Pe.length;He++)de.push(Ie[He],Pe[He],!0)}else if(Ne.has(fe)||Ae.has(ke)){let Ie=fe.tagName==="TEMPLATE"?fe.content:fe,Pe=ke.tagName==="TEMPLATE"?ke.content:ke;for(let He=Ie.firstElementChild,Se=Pe.firstElementChild;He&&Se;){if(b(He)){He=He.nextElementSibling;continue}if(b(Se)){Se=Se.nextElementSibling;continue}(T.has(He)||x.has(Se)||Ne.has(He)||Ae.has(Se))&&de.push(He,Se,!1),He=He.nextElementSibling,Se=Se.nextElementSibling}}}}return pe}function R(H,X){V(H,X),N.add(H),k(H)&&C.add(H)}function z(H){let X=T.get(H);if(!X||!k(H))return;let de=s(H),pe=s(X);for(let se=0;se<de.length&&se<pe.length;se++)T.has(de[se])||R(de[se],pe[se])}function J(H,X){let de=fe=>k(fe)&&!re(fe)?n(fe).sig+""+n(fe).hint:null,pe=so(H,de),se=so(X,de),ke=new Map;for(let fe of X){let G=de(fe);G!=null&&se.get(G)===1&&ke.set(G,fe)}for(let fe of H){if(T.has(fe))continue;let G=de(fe);if(G==null||pe.get(G)!==1)continue;let ue=ke.get(G);ue&&!x.has(ue)&&Ke(fe,ue)&&V(fe,ue)}}function ne(H,X,de,pe){let se=new Map;for(let fe of X){if(!k(fe)||x.has(fe)||re(fe))continue;let G=n(fe).sig;se.has(G)||se.set(G,[]),se.get(G).push({el:fe,index:U.get(fe)})}let ke=[];for(let fe of H){if(T.has(fe)||!k(fe)||re(fe))continue;let G=se.get(n(fe).sig);if(!G||!G.length)continue;let ue=$.get(fe),Ie=G.filter(Pe=>!x.has(Pe.el)).map(Pe=>({c:Pe,d:Math.abs(Pe.index-ue)}));Ie.sort((Pe,He)=>Pe.d-He.d),Ie.length>Ks&&(Ie=Ie.slice(0,Ks));for(let{c:Pe,d:He}of Ie){if(!Ke(fe,Pe.el))continue;let Se=r(fe,Pe.el);Se&&Se.coef>=.5&&ke.push({b:fe,s:Pe.el,coef:Se.coef,share:Se.share,d:He,bi:ue})}}if(ke.sort((fe,G)=>G.coef-fe.coef||G.share-fe.share||fe.d-G.d||fe.bi-G.bi),c&&ke.length>1){let fe=new Map;for(let G of ke){let ue=fe.get(G.b);ue?ue.coef===G.coef&&(ue.share===G.share?ue.strict++:ue.loose++):fe.set(G.b,{coef:G.coef,share:G.share,strict:0,loose:0})}for(let[G,ue]of fe)g.has(G)||!(ue.strict||ue.loose)||(g.add(G),ue.strict?c.similarTiesStrict++:c.similarTiesLoose++)}for(let fe of ke)!T.has(fe.b)&&!x.has(fe.s)&&V(fe.b,fe.s)}function je(H,X){return k(H)!==k(X)?!1:k(H)?H.tagName!==X.tagName||!Ke(H,X)?!1:re(H)||n(H).hint===""||n(X).hint===""?!0:i(H,X):H.kind===X.kind}function Q(H,X){let de=(se,ke)=>{let fe=ke===null?-1:se===X?U.get(ke):$.get(ke),G=se[fe+1];return G&&!k(G)?G:null},pe=null;for(let se of H){if(k(se)){pe=se;continue}if(T.has(se))continue;let ke=pe===null?null:T.get(pe);if(pe!==null&&!ke)continue;let fe=de(X,ke);fe&&!x.has(fe)&&fe.kind===se.kind&&V(se,fe)}}function Oe(H,X){Q(H,X);let de=Ve(H,X),pe=(ke,fe)=>k(ke)&&n(ke).hint!==""&&n(fe).hint===""&&!!fe.querySelector("br")&&!de(ke,fe),se=0;for(let ke of H){if(T.has(ke)){let G=U.get(T.get(ke));G!==void 0&&G>=se&&(se=G+1);continue}let fe=0;for(let G=se;G<X.length&&fe<di;G++){let ue=X[G];if(!x.has(ue)&&(fe++,je(ke,ue)&&!_(ke,ue)&&!pe(ke,ue))){V(ke,ue),k(ke)&&(n(ke).hint===""||n(ue).hint==="")&&A.add(ke),se=G+1;break}}}Ce(H,X)}function Ve(H,X){let de=(pe,se,ke)=>{for(let fe=se-1;fe>=0;fe--)if(k(pe[fe])&&ke(pe[fe]))return pe[fe];return null};return(pe,se)=>{let ke=$.get(pe),fe=U.get(se);if(ke===fe)return!0;let G=de(H,ke,Ie=>T.has(Ie)),ue=de(X,fe,Ie=>x.has(Ie));return G?T.get(G)===ue:!ue}}function Ce(H,X){let de=H.filter(G=>k(G)&&!T.has(G)),pe=X.filter(G=>k(G)&&!x.has(G));if(!de.length||!pe.length)return;let se=so(de,G=>G.tagName),ke=so(pe,G=>G.tagName),fe=Ve(H,X);for(let G of de){let ue=G.tagName;if(se.get(ue)!==1||ke.get(ue)!==1)continue;let Ie=pe.find(Pe=>Pe.tagName===ue);Ie&&!x.has(Ie)&&fe(G,Ie)&&Ke(G,Ie)&&!_(G,Ie)&&(u(G,Ie)?Le(G,Ie):(V(G,Ie),A.add(G)))}}function be(){let H=new Map;for(let G of A)if(k(G)&&k(T.get(G))){let ue=n(G).hash;H.has(ue)||H.set(ue,[]),H.get(ue).push(G)}if(H.size)for(let G of D){if(x.has(G)||!k(G)||ae(G))continue;let ue=H.get(n(G).hash),Ie=ue&&ue.find(Pe=>A.has(Pe)&&!_(Pe,G)&&Ke(Pe,G)&&et(Pe,G)&&u(Pe,G)&&ge(Pe,G));Ie&&(Tt(Ie),Le(Ie,G),xe(Ie,G),S.add(Ie))}let X=new Map,de=new Map,pe=new Map;for(let G of A){let ue=T.get(G);k(G)&&k(ue)&&pe.set(ue,G)}let se=(G,ue)=>{if(!x.has(G))return!ae(G);let Ie=pe.get(G);return Ie===x.get(G)&&Ie!==ue&&!Ie.contains(ue)},ke=G=>{if(x.has(G)){let ue=pe.get(G);pe.delete(G),Tt(ue)}};for(let G of[...D,...pe.keys()]){if(x.has(G)&&!pe.has(G))continue;let ue=n(G).hash;if(X.has(ue)||X.set(ue,[]),X.get(ue).push(G),re(G))continue;let Ie=n(G).sig;de.has(Ie)||de.set(Ie,[]),de.get(Ie).push(G)}let fe=new Set;for(let G of A){let ue=T.get(G);!k(G)||!k(ue)||re(G)||n(G).hint===""||n(ue).hint===""||i(G,ue)||fe.add(G)}for(let G of[...j,...fe]){let ue=T.get(G);if(ue?!(A.has(G)&&fe.has(G)):$e(G))continue;let Ie=nt=>{ue&&Tt(G),ke(nt)},Pe=X.get(n(G).hash);if(Pe){let nt=Pe.find(ot=>ot!==ue&&se(ot,G)&&!_(G,ot)&&et(G,ot)&&u(G,ot)&&ge(G,ot));if(nt){Ie(nt),Le(G,nt),xe(G,nt),S.add(G);continue}}if(re(G)||y<=0)continue;let He=de.get(n(G).sig);if(!He)continue;let Se=null,Je=0;for(let nt of He)if(!(nt===ue||!se(nt,G)||!Ke(G,nt)||!et(G,nt)||_(G,nt))&&(y--<=0||i(G,nt)&&(Je++,Se=nt,Je>1)))break;Je>1&&P&&P.add(G),Je===1&&(Ie(Se),V(G,Se),xe(G,Se),S.add(G),w.push([G,Se]))}}}function so(e,o){let t=new Map;for(let n of e){let s=o(n);s!=null&&t.set(s,(t.get(s)||0)+1)}return t}var hi={diff:0},Fs=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,pi=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,mi=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,gi=/\P{M}\p{M}*/gu;function bi(e){if(e==="")return[];if(Fs){let t=[];for(let n of Fs.segment(e))t.push(n.segment);return t}let o=[];for(let t of e.match(mi))if(pi.test(t))for(let n of t.match(gi))o.push(n);else o.push(t);return o}var wi=/^[ ]+$/,yi=e=>wi.test(e)?" ".repeat(e.length):e,qn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),Nt="",cs=e=>e.every(o=>qn(o)||o.k===Nt),ki=/^[\x00-\x7f\u00A0]*$/,xi=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function vi(e){return e===""?[]:e.match(xi)}function fn(e,o=!1){return(o?vi(e):bi(e)).map(t=>({k:yi(t),raw:t,len:t.length}))}var xn=(...e)=>e.every(o=>ki.test(o));function fs(e,o,t){let n=e.length,s=o.length,d=Math.min(n+s,t),i=d+1,r=new Int32Array(2*d+3),l=[],u=n===0&&s===0;for(let p=0;p<=d&&!u;p++){l.push(r.slice(i-p,i+p+1));for(let v=-p;v<=p;v+=2){let O;v===-p||v!==p&&r[i+v-1]<r[i+v+1]?O=r[i+v+1]:O=r[i+v-1]+1;let m=O-v,c=O;for(;O<n&&m<s&&e[O].k===o[m].k;)O++,m++;if(hi.diff+=1+O-c,r[i+v]=O,O>=n&&m>=s){u=!0;break}}}if(!u)return null;let b=[],a=n,h=s;for(let p=l.length-1;p>0;p--){let v=l[p],O=a-h,m=O+p,c=O===-p||O!==p&&v[m-1]<v[m+1]?O+1:O-1,g=v[c+p],P=g-c;for(;a>g&&h>P;)b.push([0,a-1,h-1]),a--,h--;a===g?(b.push([1,a,h-1]),h--):(b.push([-1,a-1,h]),a--)}for(;a>0&&h>0;)b.push([0,a-1,h-1]),a--,h--;return b.reverse(),b}function Ti(e,o,t){let n=a=>a.k===Nt;if(!e.some(n)&&!o.some(n))return fs(e,o,t);let s=[],d=[];for(let a=0;a<e.length;a++)n(e[a])||s.push(a);for(let a=0;a<o.length;a++)n(o[a])||d.push(a);let i=fs(s.map(a=>e[a]),d.map(a=>o[a]),t);if(!i)return null;let r=[],l=0,u=0,b=(a,h)=>{for(;l<a&&u<h&&e[l].k===o[u].k;)r.push([0,l++,u++]);let p=fs(e.slice(l,a),o.slice(u,h),t);if(!p)return!1;for(let[v,O,m]of p)r.push([v,O+l,m+u]);return l=a,u=h,!0};for(let[a,h,p]of i)if(a===0){if(!b(s[h],d[p]))return null;r.push([0,l,u]),l++,u++}return b(e.length,o.length)?r:null}function Hn(e,o,t=4e3){let n=[],s=0;for(;s<e.length&&s<o.length&&e[s].k===o[s].k;)e[s].raw!==o[s].raw&&n.push({bi:s,tok:o[s]}),s++;let d=0;for(;d<e.length-s&&d<o.length-s&&e[e.length-1-d].k===o[o.length-1-d].k;)e[e.length-1-d].raw!==o[o.length-1-d].raw&&n.push({bi:e.length-1-d,tok:o[o.length-1-d]}),d++;let i=e.slice(s,e.length-d),r=o.slice(s,o.length-d),l=Ii(i,r)?null:Ti(i,r,t);if(!l){let c=i.length||r.length?[{bs:s,be:s+i.length,toks:r}]:[];return{hunks:c,cosmetic:n,coarse:!0,parts:c.map(g=>({...g,gap:[],group:0})),cosmeticEq:n}}let u=[],b=(c,g)=>{i[c].raw!==r[g].raw&&n.push({bi:s+c,tok:r[g]})},a=null,h=[],p=0,v=0,O=()=>{a&&u.push(a),a=null;for(let[c,g]of h)b(c,g);h=[],p++};for(let[c,g,P]of l){if(c===0){a&&qn(i[g])&&!i[g].k.includes(`
|
|
2
|
-
`)?h.push([g,P]):(O(),b(g,P)),v=g+1;continue}(!a||h.length)&&(a&&u.push(a),a={bs:s+v,be:s+v,toks:[],gap:h.map(([T,x])=>({bi:s+T,tok:r[x]})),group:p},h=[]),c===-1?(a.be=s+v+1,v=g+1):a.toks.push(r[P])}O(),
|
|
3
|
-
`))return!1;let A=U=>t.slice(T,x).map((V,Ne)=>U.raw.get(T+Ne)||V),E=[...g.toks,...A(v)],S=[...A(m),...P.toks],N=(U,V,Ne)=>V>=0&&V+Ne.length<=U.length&&Ne.every((Ae,De)=>U[V+De].k===Ae.k),C=(U,V,Ne)=>cs(U)&&t.slice(V,Ne).some(Ae=>!qn(Ae)),j=U=>U.some(V=>!qn(V)),D,B,w,y;if(r(g)&&j(g.toks)&&N(S,0,g.toks)){let U=S.slice(g.toks.length);C(U,T,P.be)||(D=T,B=g.toks,w=S.slice(0,g.toks.length),y=[null,{bs:T,be:P.be,toks:U}])}if(D===void 0&&r(P)&&j(P.toks)){let U=E.length-P.toks.length,V=E.slice(0,U);N(E,U,P.toks)&&!C(V,g.bs,x)&&(D=x,B=E.slice(U),w=P.toks,y=[{bs:g.bs,be:x,toks:V},null])}if(D===void 0)return!1;let $=U=>U&&(U.bs<U.be||U.toks.length);return v.list.splice(O,1,...[y[0],{bs:D,be:D,toks:B}].filter($)),m.list.splice(c,1,...[{bs:D,be:D,toks:w},y[1]].filter($)),!0},h=i[0],p=i[1];for(let v=0;v<64;v++){let O=!1;e:for(let m=0;m<h.list.length;m++)for(let c=0;c<p.list.length;c++){let g=h.list[m],P=p.list[c];if(!(g.bs===P.bs&&g.be===P.be&&ms(g.toks,P.toks))){for(let T of[!0,!1]){let x=E=>T?E.be:E.bs,A=r(g)?[x(P),g.bs]:[x(g)];for(let E of A){let S=l(h,m,E,x),N=S&&l(p,c,E,x);if(!N)continue;let C=(y,$)=>T?y[y.length-1-$]:y[$],j=0;for(;j<S.length&&j<N.length&&C(S,j).k===C(N,j).k;)j++;if(!j)continue;let D=T?S.slice(0,S.length-j):S.slice(j),B=T?N.slice(0,N.length-j):N.slice(j);if(!(j<S.length&&j<N.length&&!cs(D)&&!cs(B)&&(r(g)&&r(P)||g.bs===P.bs&&g.be===P.be)||!(T?S.slice(S.length-j):S.slice(0,j)).some(y=>!qn(y)))){if(j===S.length&&j===N.length&&r(g)&&r(P)){if(g.bs===E&&P.bs===E)continue;h.list[m]={bs:E,be:E,toks:S},p.list[c]={bs:E,be:E,toks:N}}else!r(g)&&g.bs===P.bs&&g.be===P.be?(b(h,m,S,j,T),b(p,c,N,j,T)):(u(h,m,S,j,T,E),u(p,c,N,j,T,E));O=!0;break e}}}if(a(h,m,p,c)||a(p,c,h,m)){O=!0;break e}}}if(!O)break}return[h.list,p.list]}var Mi=48,Oi=.3;function Ii(e,o){let t=e.filter(i=>!qn(i)),n=o.filter(i=>!qn(i));if(Math.min(t.length,n.length)<Mi)return!1;let s=new Map;for(let i of t)s.set(i.k,(s.get(i.k)||0)+1);let d=0;for(let i of n){let r=s.get(i.k);r>0&&(d++,s.set(i.k,r-1))}return d/Math.min(t.length,n.length)<Oi}var Ei=(e,o)=>{let t=new Set;for(let n of e.toks)typeof n.k!="string"&&t.add(n.k.el);for(let n=e.bs;n<e.be;n++)typeof o[n].k!="string"&&t.add(o[n].k.el);return t},ms=(e,o)=>e.length===o.length&&e.every((t,n)=>t.k===o[n].k);function qs(e,o,t,n="remote"){let s=Hn(e,o),d=Hn(e,t),{lh:i,rh:r,cosL:l,cosR:u}=ps(s,d,e),b=k=>k.bs===k.be,a=k=>k.toks.some(_=>typeof _.k=="string"),h=k=>b(k)&&!a(k),p=(k,_)=>_.bs<k.be&&k.bs<_.be,v=(k,_)=>!p(k,_)&&_.bs<=k.be&&k.bs<=_.be&&(b(k)&&a(k)||b(_)&&a(_))&&!(b(k)&&b(_)),O=(k,_)=>k.bs===_.bs&&k.be===_.be&&ms(k.toks,_.toks),m=[],c=new Set;for(let k of i){let _=r.find(re=>!c.has(re)&&O(k,re));_?(c.add(_),m.push({bs:k.bs,be:k.be,side:"both",l:k,r:_,toks:k.toks})):m.push({bs:k.bs,be:k.be,side:"L",l:k,toks:k.toks,lead:!!k.lead})}for(let k of r)c.has(k)||m.push({bs:k.bs,be:k.be,side:"R",r:k,toks:k.toks,lead:!!k.lead});m.sort((k,_)=>k.bs-_.bs||k.be-_.be||_.lead-k.lead);let g=0,P=0;for(let k of m)k.side==="both"&&(g+=k.toks.length-(k.be-k.bs));let T=m.map((k,_)=>_),x=k=>T[k]===k?k:T[k]=x(T[k]),A=(k,_)=>(k=x(k),_=x(_),k===_?!1:(T[k]=_,!0)),E=m.map(k=>Ei({bs:k.bs,be:k.be,toks:k.toks},e)),S={L:new Map,R:new Map};m.forEach((k,_)=>{let re=k.side==="both"?["L","R"]:[k.side];for(let Z of re)for(let Be of E[_])S[Z].has(Be)||S[Z].set(Be,[]),S[Z].get(Be).push(_)});for(let k of[S.L,S.R])for(let _ of k.values())for(let re=1;re<_.length;re++)A(_[0],_[re]);for(let k=0;k<m.length;k++)for(let _=k+1;_<m.length;_++){let re=m[k],Z=m[_];re.side===Z.side&&re.side!=="both"||re.bs>Z.be||(p(re,Z)||v(re,Z)?A(k,_):re.bs===Z.bs&&b(re)&&b(Z)&&P++)}let N=(k,_)=>{let re=k==="L"?i:r;for(let Z of re)if(Z.toks.some(Be=>Be.kind==="close"&&Be.k.el===_.el))return Z.bs;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="close"&&e[Z].k.el===_.el)return Z;return-1};m.forEach((k,_)=>{if(!(!h(k)||k.side==="both"))for(let re of k.toks){if(re.kind!=="open")continue;let Z=N(k.side,re.k);if(Z<=k.bs)continue;let Be=new Uint8Array(Z-k.bs),Ke=[];if(m.forEach((Te,it)=>{if(!(Te.side===k.side||b(Te))&&Te.bs<Z&&Te.be>k.bs){Ke.push(it);for(let et=Math.max(Te.bs,k.bs);et<Math.min(Te.be,Z);et++)Be[et-k.bs]=1}}),Ke.length&&Be.every(Te=>Te===1))for(let Te of Ke)A(_,Te)}});let C=!0;for(;C;){C=!1;let k=new Map;m.forEach((_,re)=>{let Z=x(re),Be=k.get(Z)||{bs:_.bs,be:_.be,L:!1,R:!1};Be.bs=Math.min(Be.bs,_.bs),Be.be=Math.max(Be.be,_.be),_.side!=="R"&&(Be.L=!0),_.side!=="L"&&(Be.R=!0),k.set(Z,Be)}),m.forEach((_,re)=>{for(let[Z,Be]of k){if(x(re)===x(Z)||!(Be.L&&Be.R))continue;let Ke=_.bs<Be.be&&_.be>Be.bs,Te=b(_)&&a(_)&&(_.bs===Be.be||_.bs===Be.bs);(Ke||Te)&&A(re,Z)&&(C=!0)}})}let j=new Map;m.forEach((k,_)=>{let re=x(_);j.has(re)||j.set(re,[]),j.get(re).push(k)});let D=[];for(let k of j.values()){let _=k.some(Z=>Z.side==="L"),re=k.some(Z=>Z.side==="R");if(_&&re){let Z=Math.min(...k.map(it=>it.bs)),Be=Math.max(...k.map(it=>it.be)),Ke=k.filter(it=>it.side!=="R").map(it=>it.l).sort((it,et)=>it.bs-et.bs),Te=k.filter(it=>it.side!=="L").map(it=>it.r).sort((it,et)=>it.bs-et.bs);D.push({bs:Z,be:Be,kind:"conflict",localHunks:Ke,remoteHunks:Te})}else for(let Z of k)D.push({bs:Z.bs,be:Z.be,kind:Z.side,u:Z})}let B=(k,_)=>{let re=k==="L"?i:r;for(let Z of re)if(Z.toks.some(Be=>Be.kind==="close"&&Be.k.el===_.el))return Z.bs+.5;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="close"&&e[Z].k.el===_.el)return Z;return 1/0},w=(k,_)=>{let re=k==="L"?i:r;for(let Z of re)if(Z.toks.some(Be=>Be.kind==="open"&&Be.k.el===_.el))return Z.bs-.5;for(let Z=0;Z<e.length;Z++)if(e[Z].kind==="open"&&e[Z].k.el===_.el)return Z;return-1/0},y=k=>k.kind==="R"?"R":"L",$=k=>k.kind==="R"?1:0;D.sort((k,_)=>{if(k.bs!==_.bs)return k.bs-_.bs;let re=k.bs===k.be,Z=_.bs===_.be;if(re!==Z)return re?-1:1;if(re&&Z&&k.kind!=="conflict"&&_.kind!=="conflict"){let Ke=k.u.toks,Te=_.u.toks,it=mt=>mt.length&&mt.every(Ze=>Ze.kind==="open"),et=mt=>mt.length&&mt.every(Ze=>Ze.kind==="close");if(it(Ke)&&it(Te)){let mt=Math.max(...Ke.map(ft=>B(y(k),ft.k))),Ze=Math.max(...Te.map(ft=>B(y(_),ft.k)));if(mt!==Ze)return Ze-mt}if(et(Ke)&&et(Te)){let mt=Math.min(...Ke.map(ft=>w(y(k),ft.k))),Ze=Math.min(...Te.map(ft=>w(y(_),ft.k)));return mt!==Ze?Ze-mt:$(_)-$(k)}}let Be=Ke=>Ke.u&&Ke.u.lead?1:0;return Be(_)-Be(k)||$(k)-$(_)||k.be-_.be});let U=[],V=[],Ne=0,Ae=k=>{k>Ne&&(U.push({bs:Ne,be:k,toks:e.slice(Ne,k),source:"base"}),Ne=k)};for(let k of D){if(Ae(k.bs),k.kind==="conflict"){let _=hs(e,k.localHunks,k.bs,k.be),re=hs(e,k.remoteHunks,k.bs,k.be),Z=n==="local"?_:n==="both"?_.concat(re):re,Be=(it,et)=>{let mt=0;for(let Ze of it)Ze.be<=k.bs&&!et.includes(Ze)&&(mt+=Ze.toks.length-(Ze.be-Ze.bs));return mt},Ke=k.bs+Be(i,k.localHunks),Te=k.bs+Be(r,k.remoteHunks);V.push({bs:k.bs,be:k.be,ls:Ke,le:Ke+_.length,rs:Te,re:Te+re.length,ms:0,me:0,base:e.slice(k.bs,k.be),local:_,remote:re,resolved:Z}),U.push({bs:k.bs,be:k.be,toks:Z,source:"conflict",localHunks:k.localHunks,localToks:_,keepsLocal:n!=="remote"})}else U.push({bs:k.bs,be:k.be,toks:k.u.toks,source:k.kind==="R"?"remote":"local",localHunks:k.kind==="R"?[]:[k.u.l]});Ne=Math.max(Ne,k.be)}Ae(e.length);let De=0,oe=0;for(let k of U)k.source==="conflict"&&(V[oe].ms=De,V[oe].me=De+k.toks.length,oe++),De+=k.toks.length;let xe=new Map(l.map(k=>[k.bi,k.tok])),$e=new Map(u.map(k=>[k.bi,k.tok])),ae=[];for(let k of U){k.source==="base"&&(k.toks=k.toks.map((_,re)=>{let Z=k.bs+re,Be=xe.get(Z),Ke=$e.get(Z),Te=Be&&Ke?n==="remote"?Ke:Be:Be||Ke||_;return Te===_?_:{...Te,cosmetic:!0}}));for(let _ of k.toks)ae.push({..._,src:k.source})}return{tokens:ae,segments:U,conflicts:V,localHunks:i,remoteHunks:r,collapsedDelta:g,samePoint:P,mapLocalOffset:Ci(e,i,U)}}function hs(e,o,t,n){let s=[],d=t;for(let i of o)s=s.concat(e.slice(d,i.bs),i.toks),d=i.be;return s.concat(e.slice(d,n))}var us=e=>e.reduce((o,t)=>o+t.len,0);function Ci(e,o,t){let n=new Int32Array(e.length+1);for(let i=0;i<e.length;i++)n[i+1]=n[i]+e[i].len;let s=o.map(i=>({bs:n[i.bs],be:n[i.be],text:i.toks.map(r=>r.raw).join(""),ref:i})),d=t.map(i=>({bs:n[i.bs],be:n[i.be],len:us(i.toks),source:i.source,localHunks:i.localHunks||[],localLen:i.localToks?us(i.localToks):0,keepsLocal:i.keepsLocal,ref:i}));return i=>{let r=null,l=null,u=0,b=0,a=0;for(let p of s){let v=p.bs-a;if(i<=b+v){r=a+(i-b);break}if(b+=v,a=p.bs,i<=b+p.text.length){l=p,u=i-b,r=p.bs;break}b+=p.text.length,a=p.be}r===null&&(r=a+(i-b));let h=0;for(let p of d){if(!l&&r<=p.bs)return h;if(!(l?p.localHunks.includes(l.ref):r<p.be)){h+=p.len;continue}if(p.source==="base")return h+(r-p.bs);if(p.source==="remote")return h+p.len;if(p.source==="local")return h+Math.min(u,p.len);if(!p.keepsLocal||!l)return h+p.len;let O=p.localHunks.indexOf(l.ref),m=us(hs(e,p.localHunks.slice(0,O),p.ref.bs,l.ref.bs));return h+Math.min(m+u,p.localLen)}return h}}function ro(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:c=>Math.min(c,o.length),granularity:"word"};let s=xn(e,o,t),d=fn(e,s),i=fn(o,s),r=fn(t,s),l=d.length<=2e4&&i.length<=2e4&&r.length<=2e4?qs(d,i,r,n):null,u="word",b=d;if(!l){let c=g=>g.split(/(?<=\n)/).map(P=>({k:P,raw:P,len:P.length}));b=c(e),l=qs(b,c(o),c(t),n),u="line"}let a=c=>c.map(g=>g.raw).join(""),h=c=>{let g=[0];for(let P of c)g.push(g[g.length-1]+P.len);return g},p=h(b),v=null,O=null,m=null;if(l.conflicts.length){let c=g=>g.split(/(?<=\n)/).map(P=>({k:P,raw:P,len:P.length}));v=h(u==="line"?c(o):i),O=h(u==="line"?c(t):r),m=h(l.tokens)}return{text:a(l.tokens),conflicts:l.conflicts.map(c=>({bs:p[c.bs],be:p[c.be],ls:v[c.ls],le:v[c.le],rs:O[c.rs],re:O[c.re],ms:m[c.ms],me:m[c.me],base:a(c.base),local:a(c.local),remote:a(c.remote),resolved:a(c.resolved)})),mapLocalOffset:l.mapLocalOffset,granularity:u}}function _n(e,o,t=4e3){if(e===o)return[];let n=xn(e,o),s=fn(e,n),d=fn(o,n),i=Hn(s,d,t),r=[0];for(let l of s)r.push(r[r.length-1]+l.len);return i.hunks.map(l=>({bs:r[l.bs],be:r[l.be],text:l.toks.map(u=>u.raw).join("")}))}function Xt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Bn({base:e,side:o,retained:t,transfers:n,baseAtomKey:s=r=>r.el,sideAtomKey:d=r=>r.el,budget:i=Xt()}){let r=[],l=x=>({status:"fallback",reason:x}),u=x=>x>i.remaining?!1:(i.remaining-=x,!0);if(!u((t.length+n.length)*3))return l("work-limit");for(let[x,A]of[["retained",t],["transfer",n]])for(let E of A){let{from:S,to:N,target:C}=E;if(!Number.isInteger(S)||!Number.isInteger(N)||!Number.isInteger(C)||S<0||N<=S||N>e.text.length||C<0||C+N-S>o.text.length)return l("invalid-range");r.push({...E,kind:x})}let b=Symbol(),a=x=>(A,E)=>{if(!u(1))throw b;return i.sortComparisons++,x(A,E)},h,p;try{h=r.slice().sort(a((x,A)=>x.from-A.from||x.to-A.to)),p=r.slice().sort(a((x,A)=>x.target-A.target||x.to-x.from-(A.to-A.from)))}catch(x){if(x===b)return l("work-limit");throw x}if(!u(r.length*2))return l("work-limit");for(let x=1;x<h.length;x++)if(h[x].from<h[x-1].to)return l("source-overlap");for(let x=1;x<p.length;x++)if(p[x].target<p[x-1].target+p[x-1].to-p[x-1].from)return l("target-overlap");for(let x of h){let A=x.to-x.from;if(!u(A))return l("work-limit");for(let E=0;E<A;E++){let S=x.from+E,N=x.target+E;if(i.comparisons++,e.text[S]!==o.text[N])return l("unequal-occurrence");let C=e.atomAt.get(S),j=o.atomAt.get(N);if(!!C!=!!j||C&&s(C)!==d(j))return l("different-atom")}}let v=e.text.length+o.text.length+2,O=r.reduce((x,A)=>x+(A.to-A.from)*2,2);if(!u(v+O+r.length))return l("work-limit");let m=new Int32Array(e.text.length+1).fill(-1),c=new Int32Array(o.text.length+1).fill(-1);i.mapCells+=v,i.mapWrites+=O;let g=-1,P=!0;for(let x of h){x.target<g&&(P=!1),g=x.target+x.to-x.from;for(let A=0;A<x.to-x.from;A++)m[x.from+A]=x.target+A,c[x.target+A]=x.from+A}return m[e.text.length]=o.text.length,c[o.text.length]=e.text.length,{status:"ready",runs:h,bTo:m,toB:c,monotone:P,covers:(x,A)=>{if(!u(A-x))return null;i.coverageChecks+=A-x;for(let E=x;E<A;E++)if(e.text[E]!==Nt&&!/\s/.test(e.text[E])&&m[E]<0)return!1;return!0}}}function gs({base:e,side:o,baseOf:t=()=>null,budget:n=Xt()}){if(e.text===o.text||!e.text.includes(Nt)&&!o.text.includes(Nt))return{status:"none"};let s=(e.text.length+o.text.length)*8;if(s>n.remaining)return{status:"fallback",reason:"work-limit"};n.remaining-=s,n.boundarySteps=(n.boundarySteps||0)+s;let d=(v,O)=>O<v.length&&(v[O]===Nt||/\s/.test(v[O])),i=new Map,r=Symbol(),l=(v,O)=>{let m=v.stackAt[O]||[];if(!i.has(m)){if(m.length>n.remaining)throw r;n.remaining-=m.length,n.boundarySteps+=m.length,i.set(m,m.find(c=>c.block)?.el||null)}return i.get(m)},u=[],b=(v,O)=>{let m=l(e,v),c=l(o,O),g=m&&c&&t(c)!==m?"transfer":"retained",P=u[u.length-1];P&&P.to===v&&P.target+P.to-P.from===O&&P.kind===g&&P.destination===c?P.to++:u.push({from:v,to:v+1,target:O,destination:c,kind:g})},a=0,h=0,p=!1;try{for(;a<e.text.length||h<o.text.length;){if(a<e.text.length&&h<o.text.length&&e.text[a]===o.text[h]){let P=e.atomAt.get(a),T=o.atomAt.get(h);if(!!P!=!!T||P&&t(T.el)!==P.el)return{status:"none"};b(a++,h++);continue}if(!d(e.text,a)&&!d(o.text,h))return{status:"none"};let v=a,O=h;for(;d(e.text,a);)a++;for(;d(o.text,h);)h++;let m=e.text.slice(v,a),c=o.text.slice(O,h);(m.includes(Nt)||c.includes(Nt))&&(p=!0);let g=0;for(;g<a-v&&g<h-O&&e.text[a-g-1]===o.text[h-g-1];)g++;for(let P=g;P>0;P--)b(a-P,h-P)}}catch(v){if(v===r)return{status:"fallback",reason:"work-limit"};throw v}return p?Bn({base:e,side:o,retained:u.filter(v=>v.kind==="retained"),transfers:u.filter(v=>v.kind==="transfer"),sideAtomKey:v=>t(v.el)||v.el,budget:n}):{status:"none"}}var _s=/\s/,Vo=/\S/;function En(e,o,t,n,s,d,i=-1,r=-1){if(!e.length)return-1;s(n,e.length);let l=new Int32Array(e.length),u=0;for(let p=1;p<e.length;p++){for(s(n,1);u&&(s(n,1),e[u]!==e[p]);)u=l[u-1];s(n,1),e[u]===e[p]&&u++,l[p]=u}let b=-1,a=0,h=0;u=0;for(let p=0;p<o.length;p++){for(s(n,1);u&&(s(n,1),e[u]!==o[p]);)u=l[u-1];if(s(n,1),e[u]===o[p]&&u++,u!==e.length)continue;let v=p+1-e.length,O=p+1;for(u=l[u-1];a<t.length&&t[a].from<v;)s(n,1),a++;for(;h<t.length&&t[h].to<O;)s(n,1),h++;if(s(n,6),!(a===t.length||h===t.length||t[a].from!==v||t[h].to!==O||i>=0&&v<r&&O>i)){if(!d)return v;if(b>=0)return-1;b=v}}return b}function So(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function bs(e,o,t,n){let s=null;for(let i of o)if(n(t,1),!(i.source!==e.source||i.side!==e.side))for(let r of i.runs){if(n(t,1),r.source!==e.source)continue;let l=Math.max(e.from,r.from),u=Math.min(e.to,r.to);l>=u||(s||(n(t,e.to-e.from),s=new Uint8Array(e.to-e.from)),n(t,u-l),s.fill(1,l-e.from,u-e.from))}if(!s)return!1;n(t,e.to-e.from);let d=!1;for(let i=e.from;i<e.to;i++)if(Vo.test(e.flat.text[i])){if(!s[i-e.from])return!1;d=!0}return d}function ws({source:e,side:o,views:t,eligible:n,blocked:s,baseId:d,model:i,tokensOf:r,budget:l,charge:u}){let{V:b,A:a,idOf:h}=t[o],p=t[1-o];if(e.nodeType!==1||a.identical.has(e)||p.A.identical.has(e)||s.has(e)||!n(e))return null;let v=b.twin(e),O=p.V.twin(e);if(!v||!O||a.map.get(e)!==v||a.reverse.get(v)!==e||p.A.map.get(e)!==O||p.A.reverse.get(O)!==e||!b.here(v)||!p.V.here(O)||!n(v)||!n(O))return null;let m=d(e);if(m!==h(v)||m!==p.idOf(O))return null;let c=i(e,null,l),g=i(v,a,l),P=i(O,p.A,l);if(!So(c)||!So(g)||!So(P))return null;let T=c.flat.text,x=g.flat.text;if(u(l,T.length+x.length*3),!Vo.test(x)||x.length>=T.length)return null;let A=T.startsWith(x),E=T.endsWith(x);if(A===E)return null;let S=A?x.length:0,N=A?T.length:T.length-x.length,C=S,j=N;for(;C<j&&(u(l,1),!!_s.test(T[C]));)C++;for(;j>C&&(u(l,1),!!_s.test(T[j-1]));)j--;if(C===j)return null;let D=r(c,l),B=!1,w=!1;for(let y of D)u(l,1),y.from===C&&(B=!0),y.to===j&&(w=!0);return!B||!w?null:{source:e,side:o,flat:c.flat,from:S,to:N}}function zs({base:e,views:o,side:t,attempt:n,eligible:s,blocked:d,baseId:i,model:r,tokensOf:l,certificates:u,charge:b,exhausted:a,limit:h}){if(h<=0)return null;let p=Xt(h),{V:v,A:O,idOf:m}=o[t],c=o[1-t],[g,P,T,x]=n,A=null;try{for(let E=g;E<=P;E++){b(p,1);let S=e[E];if(S.nodeType!==1||O.identical.has(S)||c.A.identical.has(S)||d.has(S)||!s(S))continue;let N=ws({source:S,side:t,views:o,eligible:s,blocked:d,baseId:i,model:r,tokensOf:l,budget:p,charge:b});if(!N||bs(N,u,p,b))continue;let{flat:C,from:j,to:D}=N;b(p,(D-j)*2);let B=C.text.slice(j,D).trim();for(let w=T;w<=x;w++){b(p,1);let y=v.units[w],$=v.baseOf(y);if(!$||$===S||$.nodeType!==1||y.nodeType!==1||$.parentNode!==S.parentNode||y.parentNode!==O.map.get(S).parentNode||O.map.get($)!==y||O.reverse.get(y)!==$||d.has($)||!s($)||!s(y)||i($)!==m(y))continue;let U=r($,null,p),V=r(y,O,p);if(!So(U)||!So(V))continue;let Ne=U.flat.text,Ae=V.flat.text;if(b(p,Ne.length),!Vo.test(Ne)||Ae.length<=Ne.length)continue;let De=l(V,p),oe=En(Ne,Ae,De,p,b,!0);if(!(oe<0)&&!(En(B,Ae,De,p,b,!1,oe,oe+Ne.length)<0)){(A||=[]).push(N);break}}}}catch(E){if(E!==a)throw E}return A}function $s(e,o,t,n,s,d,i){if(d==="both"||t.atoms.length||n.atoms.length||s.atoms.length)return d;let r=d==="remote";if(r?i.rss!==i.rse||i.lss===i.lse||i.local===i.base:i.lss!==i.lse||i.rss===i.rse||i.remote===i.base)return d;for(let l of e){if(l.source!==o||l.side!==(r?1:0)||l.flat.text!==t.text||l.flat.nodes.length!==t.nodes.length||i.be<=l.from||i.bs>=l.to)continue;let u=!0;for(let a=0;a<t.nodes.length;a++){let h=l.flat.nodes[a],p=t.nodes[a];if(h.node!==p.node||h.s!==p.s||h.e!==p.e){u=!1;break}}if(!u)continue;let b=!1;for(let a=i.bs;a<i.be;a++)if(Vo.test(t.text[a])){if(a<l.from||a>=l.to){u=!1;break}b=!0}if(u&&b)return r?"local":"remote"}return d}var Dn="\uFFFC";var Li={caret:0},vn=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),tr=new Set(["BR","WBR","IMG"]),ys=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function jn(e,o={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(o.ignored&&o.ignored(e)||tr.has(e.tagName))return!0;if(!vn.has(e.tagName))return!ys.has(e.tagName);if(o.remoteWins&&o.remoteWins(e))return!1;let t=o.inlineCache&&o.inlineCache.get(e);if(t!==void 0)return t;let n=!0;for(let s of e.childNodes)if(!jn(s,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Ri(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function ln(e,o={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},n=(s,d)=>{for(let i of s){if(i.nodeType===3){let a=i.nodeValue;if(!a)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+a.length}),t.text+=a;for(let h=0;h<a.length;h++)t.stackAt.push(d);continue}if(i.nodeType!==1)continue;if(o.ignored&&o.ignored(i)){t.pins.push({el:i,i:t.text.length});continue}if(o.skip&&o.skip.has(i))continue;let r=o.via&&o.via(i)||i;r!==i&&(t.via||(t.via=new Map)).set(r,i);let l=i.tagName;if(o.blocks&&o.blocks.has(i)){t.text.length&&t.text[t.text.length-1]!==Nt&&(t.stackAt.push(d),t.text+=Nt);let a={el:i,tag:l,from:t.text.length,to:-1,depth:d.length,block:!0};t.marks.push(a);let h=d.concat([a]);n(r.childNodes,h),t.stackAt.push(h),t.text+=Nt,a.to=t.text.length;continue}let u=vn.has(l)&&Ri(r);if(tr.has(l)||!vn.has(l)||o.remoteWins&&o.remoteWins(i)||o.atomize&&o.atomize(i)||u){t.atoms.push({i:t.text.length,el:i,key:u?l+":empty":l,stack:d}),t.stackAt.push(d),t.text+=Dn;continue}let b={el:i,tag:l,from:t.text.length,to:-1,depth:d.length};t.marks.push(b),n(r.childNodes,d.concat([b])),b.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&Ko(t).trim()===""){let s=t.atoms[0];t.placeholder=s.el,t.text=t.text.slice(0,s.i)+t.text.slice(s.i+1),t.stackAt.splice(s.i,1);for(let d of t.nodes)d.s>s.i&&(d.s--,d.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(s=>[s.i,s])),t}function Pi(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function Bi(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,""")}"`;return o+">"}function lo(e,o,t){let n="",s=[];for(let d=o;d<t;d++){let i=e.stackAt[d],r=0;for(;r<s.length&&r<i.length&&s[r]===i[r];)r++;for(;s.length>r;)n+=`</${s.pop().tag.toLowerCase()}>`;for(;s.length<i.length;){let u=i[s.length];n+=Bi(u.el),s.push(u)}let l=e.atomAt.get(d);n+=l?l.el.outerHTML:e.text[d]===Nt?"":Pi(e.text[d])}for(;s.length;)n+=`</${s.pop().tag.toLowerCase()}>`;return n}function Di(e,o){let t=[...e.el.attributes].filter(n=>!o(e.el,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tag+"|"+t}function nr(e,o){let t=[...e.attributes].filter(n=>!o(e,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function Gs(e,o=()=>!1){let t=new Map,n=d=>{let i=t.get(d);return i===void 0&&(i="{"+d.map(r=>Di(r,o)).sort().join(",")+"}",t.set(d,i)),i},s="";for(let d=0;d<e.text.length;d++){let i=e.atomAt.get(d);s+=(i?"["+nr(i.el,o)+"]":e.text[d])+n(e.stackAt[d])}return e.text.length===0&&e.placeholder&&(s+="[br]"),s}function io(e,o,t,n=s=>s.key){let s=[],d=e.text,i=0,r=l=>{if(l<=i)return;let u=d.slice(i,l);if(t)for(let b of u.split(/(?<=\n)/))s.push({k:b,raw:b,len:b.length});else for(let b of fn(u,o))s.push(b)};for(let l of e.atoms)r(l.i),s.push({k:"\0"+n(l),raw:Dn,len:1,atom:!0}),i=l.i+1;return r(d.length),s}function Ko(e){if(!e.atoms.length)return e.text;let o="",t=0;for(let n of e.atoms)o+=e.text.slice(t,n.i),t=n.i+1;return o+e.text.slice(t)}var ao=e=>{let o=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)o[t+1]=o[t]+e[t].len;return o};function Ho(e,o,t,n){let s=ao(o),d=ao(t),i=[],r=0,l=0;for(let b of n.hunks){l+=b.bs-r;let a=l+b.toks.length;i.push({bs:s[b.bs],be:s[b.be],ss:d[l],se:d[a],text:e.text.slice(d[l],d[a]),toks:b.toks,lead:!!b.lead}),l=a,r=b.be}let u=new Map;for(let b of n.cosmetic)u.set(b.bi,b.tok.raw);return{hunks:i,respell:u}}function Ys(e,o,t){let n=i=>i===Nt||/\s/.test(i),s=i=>i.replace(/[\u001E\s]/g,""),d=[];for(let i of e){let r=o.slice(i.bs,i.be),l=t.slice(i.ss,i.se);if(!r.includes(Nt)&&!l.includes(Nt)||r.includes(Dn)||l.includes(Dn)||s(r)!==s(l)){d.push(i);continue}let u=0,b=0;for(;;){let a=u,h=b;for(;a<r.length&&n(r[a]);)a++;for(;h<l.length&&n(l[h]);)h++;let p=u,v=b;for(;p<a&&v<h&&r[p]===l[v];)p++,v++;let O=a,m=h;for(;O>p&&m>v&&r[O-1]===l[m-1];)O--,m--;if(O>p||m>v){let c=l.slice(v,m);d.push({bs:i.bs+p,be:i.bs+O,ss:i.ss+v,se:i.ss+m,text:c,toks:[...c].map(g=>({k:g,raw:g,len:1})),lead:i.lead})}if(a>=r.length)break;u=a+1,b=h+1}}return d}function Xs(e,o,t){let n=new Int32Array(o+1).fill(-1),s=new Int32Array(t+1).fill(-1),d=0,i=0,r=l=>{for(;d<l;)n[d]=i,s[i]=d,d++,i++};for(let l of e)r(l.bs),d=l.be,i=l.se;return r(o),n[o]=i,s[i]=o,{bTo:n,toB:s}}function Js(e,o,t){let n=[],s=0,d=0,i=(r,l)=>{if(s===r&&d===l)return;let u=o.text.slice(d,l);n.push({bs:s,be:r,ss:d,se:l,text:u,toks:fn(u,xn(u)),lead:!1})};for(let r of t.runs)i(r.from,r.target),s=r.to,d=r.target+r.to-r.from;return i(e.text.length,o.text.length),{hunks:n,respell:new Map}}function Qs(e,o,t,n){let s=ao(o),d=ao(t),i=(l,u)=>{let b=0,a=l.length;for(;b<a;){let h=b+a>>>1;l[h]<u?b=h+1:a=h}return l[b]===u?b:-1};for(let l of e.hunks)if(i(s,l.bs)<0||i(s,l.be)<0)return null;if(e.hunks.some(l=>i(d,l.ss)<0||i(d,l.se)<0)){if(!n)return null;let l=[];for(let h of e.hunks)l.push(h.ss,h.se);let u=[],b=0,a=0;for(let h of t){let p=a+h.len;for(;b<l.length&&l[b]<=a;)b++;let v=a;for(;b<l.length&&l[b]<p;){let O=l[b++];if(O>v){let m=h.raw.slice(v-a,O-a);u.push(...fn(m,xn(m))),v=O}}if(v===a)u.push(h);else{let O=h.raw.slice(v-a);u.push(...fn(O,xn(O)))}a=p}t=u,d=ao(t)}let r=[];for(let l of e.hunks){let u=i(s,l.bs),b=i(s,l.be),a=i(d,l.ss),h=i(d,l.se);if(u<0||b<0||a<0||h<0)return null;r.push({bs:u,be:b,toks:t.slice(a,h),gap:[],group:r.length})}return{parts:r,cosmeticEq:[],tokens:t}}function ks(e,o,t,n={},s=null){return or(e,o,t,n.base,n.local,n.remote,s,{})}function or(e,o,t,n,s,d,i,r){let l=xn(Ko(e),Ko(o),Ko(t)),u=io(e,l,!1,n),b=io(o,l,!1,s),a=io(t,l,!1,d),h=u.length>2e4||b.length>2e4||a.length>2e4;h&&(u=io(e,l,!0,n),b=io(o,l,!0,s),a=io(t,l,!0,d));let p=i?.local?Js(e,o,i.local):null,v=i?.remote?Js(e,t,i.remote):null,O=p?Qs(p,u,b,!h):Hn(u,b),m=v?Qs(v,u,a,!h):Hn(u,a);p&&O&&(b=O.tokens),v&&m&&(a=m.tokens);let c,g;if(O&&m){let P=ps(O,m,u);c=Ho(o,u,b,{hunks:P.lh,cosmetic:P.cosL}),g=Ho(t,u,a,{hunks:P.rh,cosmetic:P.cosR})}else c=p||Ho(o,u,b,O),g=v||Ho(t,u,a,m);return c.hunks=Ys(c.hunks,e.text,o.text),g.hunks=Ys(g.hunks,e.text,t.text),r.base=e,r.local=o,r.remote=t,r.lines=h,r.baseTokens=u,r.localEdits=c,r.remoteEdits=g,r.localMap=Xs(c.hunks,e.text.length,o.text.length),r.remoteMap=Xs(g.hunks,e.text.length,t.text.length),r.full=null,r}function Zs(e,o){if(e.size!==o.size)return!1;for(let t of e)if(!o.has(t))return!1;return!0}var co=/\s/;function Wo(e,o,t){for(let n=o;n<t;n++)if(!co.test(e[n]))return!1;return!0}function ji(e,o,t){let n=e.cache[t]||(e.cache[t]=new Map);if(n.has(o))return n.get(o);let s=t===0?"local":"remote",d=t===0?"remote":"local",i=o.baseMark,r=o[d+"Mark"],l=!o.block&&!o[s]&&!!r&&i.to>i.from;if(l){let u=t===0?e.ML:e.MR,b=t===0?e.MR:e.ML,a=t===0?e.fr:e.fl,h=!1;for(let p=i.from;p<i.to;p++){if(u.bTo[p]>=0){l=!1;break}b.bTo[p]<0&&!co.test(e.fb.text[p])&&(h=!0)}if(l&&!h){for(let p=r.from;p<r.to;p++)if(b.toB[p]<0&&!co.test(a.text[p])){h=!0;break}}l&&=h}return n.set(o,l),l}function er(e,o,t,n,s,d,i,r,l){let u=r===0?e.fl:e.fr,b=null;for(let a=t;a<n;a++){let h=o[a];if(!Wo(u.text,h.ss,h.se))return null;if(Wo(e.fb.text,h.bs,h.be)){if(h.bs<h.be&&h.ss<h.se||co.test(e.fb.text[h.bs-1]||"")||co.test(e.fb.text[h.be]||""))continue;return null}let p=!1;for(let v=h.bs;v<h.be;v++){if(co.test(e.fb.text[v]))continue;let O=null;for(let m of e.fb.stackAt[v]){let c=e.byEl.get(m.el);if(c&&ji(e,c,r)){O=c;break}}if(!O)return null;(b||(b=new Set)).add(O),p=!0}if(!p)return null}if(!b){if((r===0?"local":"remote")!==l)return null;let a=r===0?e.fr:e.fl,h=!1;for(let p=d;p<i;p++){let v=s[p];if(!Wo(e.fb.text,v.bs,v.be))return null;Wo(a.text,v.ss,v.se)||(h=!0)}if(!h)return null}return b||0}function Fo(e){let{out:o,policy:t="remote",L:n,R:s}=e,d=e.provenance||new WeakMap,i=e.textMappers||new WeakMap,r=e.conflicts||[],l=e.decisions||[],u=r.length,b=e.conflict||(f=>r.push(f)),a={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},h=[],p=!!(n&&n.reverse&&n.map&&s&&s.reverse&&s.map),v={base:null,local:null,remote:null};if(!e.prepared&&p&&e.moveIn){let f=ve=>We=>ve.some(Re=>Re===We||Re.nodeType===1&&Re.contains(We)),L=f(e.local),W=f(e.remote),K=f(e.base),Y=new Set,he=ve=>{if(!vn.has(ve.tagName))return;let We=n.map.get(ve),Re=s.map.get(ve);(We&&!L(We)||Re&&!W(Re))&&Y.add(ve);for(let Fe of ve.children)he(Fe)};for(let ve of e.base)ve.nodeType===1&&he(ve);let ye=ve=>We=>{if(!vn.has(We.tagName))return!1;let Re=ve.reverse.get(We);return!!Re&&(Y.has(Re)||!K(Re))};Y.size&&(v.base=ve=>Y.has(ve)),v.local=ye(n),v.remote=ye(s)}let O={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&p&&e.moveIn){let f=K=>Y=>K.some(he=>he===Y||he.nodeType===1&&he.contains(Y)),L=f(e.local),W=f(e.remote);for(let K of ln(e.base,{...e,atomize:v.base}).atoms){let Y=n.map.get(K.el),he=s.map.get(K.el),ye=!!Y&&!L(Y),ve=!!he&&!W(he);!ye&&!ve||(ye&&e.movePlanned?.(K.el,"local",Y,null),ve&&e.movePlanned?.(K.el,"remote",he,null),O.base.add(K.el),Y&&!ye&&O.local.add(Y),he&&!ve&&O.remote.add(he),L(K.el)&&O.local.add(K.el),W(K.el)&&O.remote.add(K.el))}}let m=e.prepared?.base||ln(e.base,{...e,atomize:v.base,skip:O.base}),c=e.prepared?.local||ln(e.local,{...e,atomize:v.local,skip:O.local}),g=e.prepared?.remote||ln(e.remote,{...e,atomize:v.remote,skip:O.remote}),P=new Map(m.atoms.map(f=>[f.el,f])),T={},x=f=>e.prepared?e.prepared.full?.(f)||null:O[f].size?(T[f]||(T[f]=ln(e[f],{...e,atomize:v[f]})),T[f]):null,A=(f,L,W)=>{L.namespaceURI?f.setAttributeNS(L.namespaceURI,L.name,W):f.setAttribute(L.name,W)},E=(f,L,W,K)=>{if(!L&&(!W||!K)){for(let he of(W||K).attributes)A(f,he,he.value);return}let Y=new Map;for(let he of[L,W,K])if(he)for(let ye of he.attributes)Y.set(ye.name,ye);for(let[he,ye]of Y){let ve=L?L.getAttribute(he):null,We=W?W.getAttribute(he):ve,Re=K?K.getAttribute(he):ve,Fe;We===Re?Fe=We:We===ve?(Fe=Re,l.push({kind:"attr",el:f,name:he,source:"remote"})):Re===ve?(Fe=We,l.push({kind:"attr",el:f,name:he,source:"local"})):(Fe=t==="local"?We:Re,b({kind:"attr",el:f,name:he,base:ve,local:We,remote:Re,resolved:Fe},{el:f,sample:ye}),l.push({kind:"attr",el:f,name:he,source:"both"})),Fe!=null&&A(f,ye,Fe)}},S=(f,L,W,K)=>f&&e.mergeAttrs?e.mergeAttrs(f,L,W,K):E(K,f,L,W),N=e.mergeElement||((f,L,W)=>{let K=o.createElement(f.tagName);S(f,L,W,K);let Y=L||f,he=W||f,ye=t==="local"?Y.isEqualNode(f)?he:Y:he.isEqualNode(f)?Y:he;for(let ve of ye.childNodes)K.appendChild(o.importNode(ve,!0));return d.set(K,{base:f,local:L,remote:W}),K}),C=e.cloneUnit||((f,L)=>{let W=o.importNode(f,!0);return d.set(W,{base:null,local:L==="local"?f:null,remote:L==="remote"?f:null}),W}),j=e.atomKey||(f=>nr(f,()=>!1)),D=(f,L)=>{let W=new Map;for(let K of f.atoms)if(e.remoteWins&&e.remoteWins(K.el)&&vn.has(K.el.tagName))W.set(K,"w"+K.el.tagName+"#"+(K.el.id||""));else if(!p)W.set(K,K.key);else if(f===m)W.set(K,"="+j(K.el));else{let Y=L.reverse.get(K.el),he=Y?P.get(Y):null;he?W.set(K,"="+j(he.el)):Y?W.set(K,"m"+j(K.el)):W.set(K,"="+j(K.el))}return K=>W.get(K)},B=D(m,null),w=D(c,n),y=D(g,s),$=e.certifiedOrigins?e.certifiedOrigins(m,c,g,B,w,y):null;if($?.fallback)return null;if(!$&&!e.prepared&&e.blocks){let f=Xt(),L=gs({base:m,side:c,baseOf:K=>n?.reverse?.get(K)||null,budget:f}),W=gs({base:m,side:g,baseOf:K=>s?.reverse?.get(K)||null,budget:f});(L.status==="ready"||W.status==="ready")&&($={local:L.status==="ready"?L:null,remote:W.status==="ready"?W:null})}let U=e.prepared||or(m,c,g,B,w,y,$,a),V=U.lines,Ne=U.baseTokens,Ae=U.localEdits,De=U.remoteEdits,oe=U.localMap,xe=U.remoteMap,$e=m.text.length,ae=f=>new Map(f.atoms.map(L=>[L.el,L])),k=ae(c),_=ae(g),re=(f,L,W)=>{let K=new Set;if(!p)return K;for(let Y of f.atoms){let he=P.get(L.reverse.get(Y.el));he&&W.bTo[he.i]<0&&K.add(he)}return K},Z=re(c,n,oe),Be=re(g,s,xe),Ke=f=>!jn(f,{...e,remoteWins:null}),Te=new Set;if(p)for(let f of m.atoms){if(!Ke(f.el))continue;let L=n.map.get(f.el)||null,W=s.map.get(f.el)||null,K=L&&!W?L:W&&!L?W:null;K&&(k.has(K)||_.has(K))&&!K.isEqualNode(f.el)&&Te.add(f)}let it=1,et=(f,L)=>({id:it++,tag:f,base:null,local:null,remote:null,rank:L}),mt=new Map,Ze=[];for(let f of m.marks){let L=et(f.tag,f.depth);L.block=!!f.block,L.base=f.el,L.baseMark=f,mt.set(f.el,L),Ze.push(L)}let ft=(f,L)=>{let W=-1,K=-1;for(let Y=f.from;Y<f.to;Y++){let he=L[Y];he>=0&&(W<0&&(W=he),K=he+1)}return W<0?null:[W,K]},Ct=(f,L,W,K)=>{for(let Y of f.marks){let he=W?W.reverse.get(Y.el):null;he&&W.identical.has(he)&&W.pairIdenticalChildren&&W.pairIdenticalChildren(he);let ye=he?mt.get(he):null;if(ye&&ye[L]&&(ye=null),!ye){let ve=ft(Y,K),We=0;if(ve)for(let Re of Ze){if(Re.tag!==Y.tag||Re[L]||!!Re.block!=!!Y.block)continue;let Fe=Math.min(ve[1],Re.baseMark.to)-Math.max(ve[0],Re.baseMark.from);(Fe>We||Fe===We&&Fe>0&&Math.abs(Re.rank-Y.depth)<Math.abs(ye.rank-Y.depth))&&(ye=Re,We=Fe)}}ye||(ye=et(Y.tag,Y.depth),ye.block=!!Y.block,ye.new=L),ye[L]=Y.el,ye[L+"Mark"]=Y,mt.set(Y.el,ye)}};Ct(c,"local",n,oe.toB),Ct(g,"remote",s,xe.toB);let Dt=f=>f.merged||f,Tt=f=>{let L=new Set;for(let W of f)W.block||L.add(mt.get(W.el));return L},Rt=new Map,jt=f=>{let L=Rt.get(f);return L||(L=Tt(f),Rt.set(f,L)),L},qt=(f,L)=>{let W=[],K=null;for(let Y=0;Y<$e;Y++){let he=L[Y];if(he<0){K&&W.push(K),K=null;continue}let ye=jt(m.stackAt[Y]),ve=jt(f.stackAt[he]),We=new Set,Re=new Set;for(let Fe of ve)ye.has(Fe)||We.add(Fe);for(let Fe of ye)ve.has(Fe)||Re.add(Fe);if(!We.size&&!Re.size){K&&W.push(K),K=null;continue}if(K&&Zs(K.added,We)&&Zs(K.removed,Re)){K.be=Y+1;continue}K&&W.push(K),K={bs:Y,be:Y+1,added:We,removed:Re}}return K&&W.push(K),W},un=qt(c,oe.bTo),Lt=qt(g,xe.bTo),Jt=f=>f.be>f.bs?[f.bs,f.be-1]:[f.bs-1,f.bs],F=(f,L)=>{if($e===0)return null;let[W,K]=Jt(f);for(let Y of L){if(Y.be<=W)continue;if(Y.bs>K)break;let he=Y.bs<=W&&K<Y.be;return he&&f.text===""&&Y.bs===f.bs&&Y.be===f.be?"straddle":he?Y:f.be>f.bs?"straddle":null}return null},ce=f=>f.bs===f.be,ge=(f,L,W=null)=>{let K=!1;for(let Y=f.bs;Y<f.be;Y++){let he=m.text[Y];if(he===Nt)K=!0;else if(!/\s/.test(he))return!1}for(let Y=f.ss;Y<f.se;Y++){let he=L.text[Y];if(he===Nt)K=!0;else if(!/\s/.test(he)){let ye=W&&e.scopeUnits&&ce(f)&&L.atomAt.get(Y);if(!ye||!Ke(ye.el)||W.ss!==W.se||W.bs>=W.be)return!1;for(let We=W.bs;We<W.be;We++)if(!/\s/.test(m.text[We]))return!1;let ve=L===c?1:2;if(!e.scopeUnits[ve].includes(ye.el)||(ve===1?n:s)?.reverse.has(ye.el))return!1;K=!0}}return K},Le=(f,L)=>f.bs<L.be&&L.bs<f.be,Me=(f,L)=>f.bs<=L.be&&L.bs<=f.be&&ce(f)!==ce(L),M=(f,L)=>m.text.slice(f.bs,f.be).includes(Nt)||L.text.slice(f.ss,f.se).includes(Nt),R=f=>{if(ce(f))return!1;let L=f.bs,W=f.be;for(;L>0&&/\s/.test(m.text[L-1]);)L--;for(;W<m.text.length&&/\s/.test(m.text[W]);)W++;return(L===0||m.text[L-1]===Nt)&&(W===m.text.length||m.text[W]===Nt)},z=(f,L)=>!M(f,L)&&!R(f),J=(f,L)=>Le(f,L)||Me(f,L)&&!(f.transferIn||f.transferOut||L.transferIn||L.transferOut)&&!(ge(f,c,L)&&z(L,g))&&!(ge(L,g,f)&&z(f,c)),ne=(f,L)=>{if(f.bs!==L.bs||f.be!==L.be||f.toks.length!==L.toks.length)return!1;let W=f.ss,K=L.ss;for(let Y=0;Y<f.toks.length;Y++){let he=f.toks[Y],ye=L.toks[Y];if(he.k!==ye.k||he.atom&&!c.atomAt.get(W).el.isEqualNode(g.atomAt.get(K).el))return!1;W+=he.len,K+=ye.len}return!0},je=(f,L,W,K)=>{for(let Y of m.atoms){if(Y.i<f.bs||Y.i>=f.be||K.has(Y)||Te.has(Y))continue;let he=L.bTo[Y.i],ye=he>=0?W.atomAt.get(he):null;if(ye&&!ye.el.isEqualNode(Y.el))return!0}return!1},Q=[],Oe=null,Ve=null,Ce=Ae.hunks,be=De.hunks,H=0,X=0,de=0,pe=0,se=0,ke=f=>{f>de&&(Q.push({src:"base",from:de,to:f,dL:pe,dR:se}),de=f)};for(;H<Ce.length||X<be.length;){let f=Ce[H],L=be[X],W=!!f&&(!L||f.bs<L.bs||f.bs===L.bs&&f.be<=L.be&&!L.lead);if(f&&L&&f.bs===L.bs&&ce(f)&&ce(L)){let Gt=ge(f,c),To=ge(L,g);Gt!==To&&(W=To)}let K=W?f:L,Y=W?L:f,he=!!Y&&ne(f,L),ye=!!Y&&(W?!!Ce[H+1]&&ne(Ce[H+1],L):!!be[X+1]&&ne(f,be[X+1])),ve=!!Y&&!he&&!ye&&($e===0||J(f,L)),We=ve,Re=F(K,W?Lt:un);if(Re==="straddle"&&(We=!0),!We&&K.be>K.bs&&(We=je(K,W?xe:oe,W?g:c,W?Z:Be)),!We&&he){ke(K.bs),Q.push({src:"both",lfrom:f.ss,rfrom:L.ss,len:K.text.length,owner:f.owner||L.owner||null,transfer:f.transferIn||L.transferIn||null}),de=K.be,pe+=K.text.length-(K.be-K.bs),se+=K.text.length-(K.be-K.bs),H++,X++;continue}if(!We){ke(K.bs),Q.push({src:W?"local":"remote",from:K.ss,to:K.se,inherit:Re&&Re!=="straddle"?Re:null,owner:K.owner||null,transfer:K.transferIn||null}),de=K.be,W?(pe+=K.text.length-(K.be-K.bs),H++):(se+=K.text.length-(K.be-K.bs),X++);continue}let Fe=K.bs,xt=K.be,ht=H,pt=X,Ft=Gt=>Gt.bs<xt&&Gt.be>Fe||ce(Gt)&&(Gt.bs===Fe||Gt.bs===xt);W?ht++:pt++,ve&&(Fe=Math.min(Fe,Y.bs),xt=Math.max(xt,Y.be),W?pt++:ht++);let Vt=!0;for(;Vt;){for(Vt=!1;ht<Ce.length&&Ft(Ce[ht]);)Fe=Math.min(Fe,Ce[ht].bs),xt=Math.max(xt,Ce[ht].be),ht++,Vt=!0;for(;pt<be.length&&Ft(be[pt]);)Fe=Math.min(Fe,be[pt].bs),xt=Math.max(xt,be[pt].be),pt++,Vt=!0}let gn=Fe+pe,cn=Fe+se,yn=xt-Fe,Sn=xt-Fe;for(let Gt=H;Gt<ht;Gt++)yn+=Ce[Gt].text.length-(Ce[Gt].be-Ce[Gt].bs);for(let Gt=X;Gt<pt;Gt++)Sn+=be[Gt].text.length-(be[Gt].be-be[Gt].bs);let Rn=gn+yn,Pn=cn+Sn;if(ke(Fe),H<ht&&X<pt&&!$&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!m.atoms.length&&!c.atoms.length&&!g.atoms.length&&!m.pins.length&&!c.pins.length&&!g.pins.length){Oe||={fb:m,fl:c,fr:g,ML:oe,MR:xe,byEl:mt,cache:[null,null]};let Gt=er(Oe,Ce,H,ht,be,X,pt,0,t),To=er(Oe,be,X,pt,Ce,H,ht,1,t);if(Gt===null!=(To===null)){let ts=Gt!==null,Ds=ts?Gt:To;if(Ds){Ve||=new Map;for(let ni of Ds)Ve.set(ni,ts?"local":"remote")}Q.push(ts?{src:"remote",from:cn,to:Pn}:{src:"local",from:gn,to:Rn}),de=xt,pe+=yn-(xt-Fe),se+=Sn-(xt-Fe),H=ht,X=pt;continue}}let on={kind:"text",node:e.node||null,base:lo(m,Fe,xt),local:lo(c,gn,Rn),remote:lo(g,cn,Pn),resolved:null,range:null,bs:Fe,be:xt,lss:gn,lse:Rn,rss:cn,rse:Pn},Xn=e.sourceRetentions?$s(e.sourceRetentions,e.scope?.base,m,c,g,t,on):t;on.resolved=Xn==="local"?on.local:Xn==="remote"?on.remote:on.local+on.remote,Xn!=="remote"&&Q.push({src:"local",from:gn,to:Rn,conflict:on}),Xn!=="local"&&Q.push({src:"remote",from:cn,to:Pn,conflict:on});let Jn={site:"inline",policy:Xn,fb:m,fl:c,fr:g,scope:e.scope||null,synthetic:!!e.synthetic,full:x,merged:a};h.push(Jn),b(on,Jn),de=xt,pe+=yn-(xt-Fe),se+=Sn-(xt-Fe),H=ht,X=pt}ke($e);let fe=m.text,G=[];if(Ae.respell.size||De.respell.size){let f=ao(Ne),L=[];for(let W=0;W<Ne.length;W++){let K=Ne[W].raw,Y=Ae.respell.get(W)??K,he=De.respell.get(W)??K;(Y!==K||he!==K)&&G.push([f[W],Y!==K&&he!==K?"both":Y!==K?"local":"remote"]),L.push(Y===he?Y:Y===K?he:he===K||t==="local"?Y:he)}fe=L.join("")}let ue="",Ie=[],Pe=[],He=[],Se=[];for(let f of Q){let L=ue.length;if(f.src==="base"){for(let W=f.from;W<f.to;W++)Ie.push(W),Pe.push(e.nativeTransfers?oe.bTo[W]:W+f.dL),He.push(e.nativeTransfers?xe.bTo[W]:W+f.dR),Se.push(f);ue+=fe.slice(f.from,f.to)}else if(f.src==="both"){for(let W=0;W<f.len;W++){let K=f.transfer&&(f.transfer.side==="remote"?f.rfrom+W:f.lfrom+W);Ie.push(f.transfer&&K>=f.transfer.ss&&K<f.transfer.se?f.transfer.bs+K-f.transfer.ss:-1),Pe.push(f.lfrom+W),He.push(f.rfrom+W),Se.push(f)}ue+=c.text.slice(f.lfrom,f.lfrom+f.len)}else{let W=f.src==="local"?c:g,K=f.transfer&&e.nativeTransfers.byOrigin[f.src==="local"?"remote":"local"].get(f.transfer.key);for(let Y=f.from;Y<f.to;Y++){let he=f.transfer&&Y>=f.transfer.ss&&Y<f.transfer.se?f.transfer.bs+Y-f.transfer.ss:-1,ye=he>=0&&(!K||K.destination===f.owner)?(f.src==="local"?xe:oe).bTo[he]:-1;Ie.push(he),Pe.push(f.src==="local"?Y:ye),He.push(f.src==="remote"?Y:ye),Se.push(f)}ue+=W.text.slice(f.from,f.to)}f.ms=L,f.me=ue.length,f.conflict&&(f.conflict.range||(f.conflict.range=[L,L]),f.conflict.range[1]=ue.length)}let Je=ue.length,nt=new Int32Array($e+1).fill(-1),ot=new Int32Array(c.text.length+1).fill(-1),Wt=new Int32Array(g.text.length+1).fill(-1);for(let f=0;f<Je;f++)Ie[f]>=0&&(nt[Ie[f]]=f),Pe[f]>=0&&(ot[Pe[f]]=f),He[f]>=0&&(Wt[He[f]]=f);let Ut=(f,L)=>{let W=-1,K=-1;for(let Y=f.from;Y<f.to;Y++){let he=L[Y];he>=0&&(W<0&&(W=he),K=he+1)}return W<0?null:[W,K]},I=[],q=[];for(let f of new Set(mt.values()))f.new==="local"?I.push(f):f.new==="remote"&&q.push(f);let te=(f,L)=>{f.remote=L.remote,f.remoteMark=L.remoteMark,f.new="both",L.merged=f,mt.set(L.remote,f)};if(I.length&&q.length){let f=e.idOf;for(let L of I){let W=f?f.local(L.local):null;if(!W)continue;let K=q.find(Y=>!Y.merged&&Y.tag===L.tag&&!!Y.block==!!L.block&&f.remote(Y.remote)===W);K&&te(L,K)}for(let L of I){if(L.remote)continue;let W=Ut(L.localMark,ot);if(W)for(let K of q){if(K.merged||K.tag!==L.tag||!!K.block!=!!L.block)continue;let Y=Ut(K.remoteMark,Wt);if(Y&&Math.min(W[1],Y[1])-Math.max(W[0],Y[0])>0){te(L,K);break}}}}Rt.clear();let me=f=>{for(let L of f)if(L.block)return Dt(mt.get(L.el));return null},we=m.marks.some(f=>f.block)||c.marks.some(f=>f.block)||g.marks.some(f=>f.block),ie=new Array(Je).fill(null),ee=new Set;if(e.nativeTransfers)for(let f=0;f<Je;f++){let L=Se[f].owner;ie[f]=L?Dt(mt.get(L)):Ie[f]>=0?me(m.stackAt[Ie[f]]):null}else if(we){let f=(Re,Fe,xt)=>{let ht=new Set([Re,Fe,xt]);ht.delete(null);let pt=[];for(let Vt of ht){let gn=Vt===Re,cn=Vt===Fe,yn=Vt===xt;(cn===yn?cn:cn===gn?yn:cn)&&pt.push(Vt)}if(pt.length<=1)return pt[0]||null;let Ft=t==="local"?Fe:xt;return pt.includes(Ft)?Ft:pt[0]},L=(Re,Fe)=>Fe>=0?me(Re.stackAt[Fe]):null,W=new Map;for(let Re=0;Re<Je;Re++){if(ue[Re]!==Nt)continue;let Fe=Ie[Re]>=0?L(m,Ie[Re]):null,xt=L(c,Pe[Re]),ht=L(g,He[Re]);W.set(Re,[Fe,Ie[Re]>=0?f(Fe,xt,ht):xt||ht])}let K=new Set([...W.values()].map(Re=>Re[1])),Y=Re=>Re!==Nt&&Re!==Dn&&!/\s/.test(Re),he=(Re,Fe)=>{let xt=Re;for(;xt<Fe&&!Y(ue[xt]);)xt++;return xt<Fe&&Ie[xt]>=0?L(m,Ie[xt]):null},ye=new Map,ve=0;for(let Re=0;Re<Je;Re++){if(ue[Re]!==Nt)continue;let[Fe,xt]=W.get(Re),ht=he(ve,Re),pt=xt,Ft=ye.get(pt)===pt&&ht===pt;pt&&ye.has(pt)&&!Ft&&Fe&&!ye.has(Fe)&&!K.has(Fe)&&(pt=Fe),pt&&!ye.has(pt)&&ye.set(pt,ht);for(let Vt=ve;Vt<=Re;Vt++)ie[Vt]=pt;ve=Re+1}let We=Re=>{for(let Fe=0;Fe<Re.text.length;Fe++)if(Y(Re.text[Fe])&&!L(Re,Fe))return!0;return!1};if(!We(m)&&!We(c)&&!We(g)){let Re=[],Fe=0;for(let ht=0;ht<Je;ht++)(ue[ht]===Nt||ht===Je-1)&&(Re.push([Fe,ht]),Fe=ht+1);let xt=new Set(ie);for(let ht=0;ht<Re.length;ht++){let[pt,Ft]=Re[ht];if(ie[Ft])continue;let Vt=pt;for(;Vt<=Ft&&!Y(ue[Vt]);)Vt++;if(Vt>Ft)continue;let gn=L(m,Ie[Vt]),cn=L(c,Pe[Vt]),yn=L(g,He[Vt]),Sn=f(gn,cn,yn)||cn||yn||gn;if(Sn&&!xt.has(Sn)){xt.add(Sn);for(let on=pt;on<=Ft;on++)ie[on]=Sn;continue}let Rn=ht>0&&ie[Re[ht-1][1]],Pn=ht+1<Re.length&&ie[Re[ht+1][1]];if(Rn)ee.add(Re[ht-1][1]);else if(Pn&&ue[Ft]===Nt)ee.add(Ft);else continue;for(let on=pt;on<=Ft;on++)ie[on]=Rn||Pn}}}let Ee=new Map,Ue=f=>{let L=Ee.get(f);if(L)return L;L=[1/0,-1/0];for(let[W,K]of[[f.baseMark,nt],[f.localMark,ot],[f.remoteMark,Wt]]){let Y=W&&Ut(W,K);Y&&(L[0]=Math.min(L[0],Y[0]),L[1]=Math.max(L[1],Y[1]))}return Ee.set(f,L),L},_e=(f,L,W)=>{let K=-1,Y=-1;for(let he=0;he<f.length;he++){let ye=mt.get(f[he].el);ye===L&&(K=he),ye===W&&(Y=he)}return K>=0&&Y>=0?K-Y:0},Ye=(f,L)=>[...f].sort((W,K)=>{for(let ye of L){let ve=_e(ye,W,K);if(ve)return ve}let Y=Ue(W),he=Ue(K);return Y[0]-he[0]||he[1]-Y[1]||W.rank-K.rank||W.id-K.id}),yt=new Map,gt=new Map,$t=e.nativeTransfers?[]:null,_t=f=>{if($t)return $t;let L=Ie[f],W=Pe[f],K=He[f],Y=Se[f];if(L>=0){let ht=m.stackAt[L],pt=c.stackAt[W],Ft=g.stackAt[K],Vt=yt.get(ht);Vt||yt.set(ht,Vt=new Map);let gn=Vt.get(pt);gn||Vt.set(pt,gn=new Map);let cn=gn.get(Ft);if(cn)return cn;let yn=jt(ht),Sn=jt(pt),Rn=jt(Ft),Pn=new Set;for(let on of new Set([...yn,...Sn,...Rn])){let Xn=yn.has(on),Jn=Sn.has(on),Gt=Rn.has(on);(Jn===Gt?Jn:Jn===Xn?Gt:Jn)&&Pn.add(on)}return cn=Ye(Pn,[pt,Ft,ht]),gn.set(Ft,cn),cn}if(Y.src==="both"){let ht=c.stackAt[W],pt=g.stackAt[K];return Ye(new Set([...jt(ht),...jt(pt)]),[ht,pt])}let ye=(Y.src==="local"?c:g).stackAt[Y.src==="local"?W:K];if(!Y.inherit)return Ye(jt(ye),[ye]);let ve=gt.get(Y);ve||gt.set(Y,ve=new Map);let We=ve.get(ye);if(We)return We;let Re=new Set(jt(ye));for(let ht of Y.inherit.added)Re.add(Dt(ht));for(let ht of Y.inherit.removed)Re.delete(Dt(ht));let Fe=Y.src==="local"?g:c,xt=(Y.src==="local"?xe.bTo:oe.bTo)[Y.inherit.bs];return We=Ye(Re,[ye,Fe.stackAt[xt]]),ve.set(ye,We),We},dn=new Int32Array(c.text.length+1);dn[c.text.length]=Je;for(let f=c.text.length-1;f>=0;f--)dn[f]=ot[f]>=0?ot[f]:dn[f+1];Li.caret+=c.text.length;let vt=f=>f<=0?0:(f>c.text.length&&(f=c.text.length),ot[f-1]>=0?ot[f-1]+1:dn[f]),dt=[],Qe=[],Mt=null,bt=[],Ht="",pn=-1,sn=f=>{Mt?Mt.appendChild(f):dt.push(f)},Zt=f=>{if(!Ht)return;let L=o.createTextNode(Ht);sn(L),Qe.push({node:L,ms:pn,me:f,local:[],u:bt.length?bt[bt.length-1].u:null}),Ht=""},wn=new Set,On=new Map,In=new Set,Lo=f=>{let L=o.createElement(f.tag);if(f.block&&Kn.add(L),!On.has(f)){On.set(f,L),S(f.base,f.local,f.remote,L),d.set(L,{base:f.base,local:f.local,remote:f.remote});let K=(ye,ve)=>p&&f[ve]&&ye.reverse.get(f[ve])?ve:null,Y=!f.base&&(K(n,"local")||K(s,"remote"));if(Y){let ye=Y==="local"?n.reverse.get(f.local):s.reverse.get(f.remote),ve=d.get(L);ve.local=ve.local||n.map.get(ye)||null,ve.remote=ve.remote||s.map.get(ye)||null,l.push({kind:"move",el:L,source:Y}),e.moveBuilt?.(ye,Y,f[Y],L)}else f.base||l.push({kind:"insert",el:L,source:f.local&&f.remote?"both":f.local?"local":"remote"});let he=d.get(L);he.local&&(In.has(he.local)?he.local=null:In.add(he.local))}else{let K=On.get(f);for(let Y of K.attributes)Y.name!=="id"&&Y.name!=="data-id"&&A(L,Y,Y.value);d.set(L,{base:null,local:null,remote:null})}sn(L),bt.push({u:f,el:L}),Mt=L},yo=new Set,Gn=new Map;for(let f of c.pins){let L=vt(f.i);Gn.has(L)||Gn.set(L,[]),Gn.get(L).push(f)}let Ro=f=>{let L=Gn.get(f);if(L){Zt(f);for(let W of L){let K=W.el.namespaceURI&&W.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(W.el.namespaceURI,W.el.tagName):o.createElement(W.el.tagName);d.set(K,{base:null,local:W.el,remote:null,pinned:!0}),yo.add(K),sn(K)}}},es=m.atoms.length||c.atoms.length||g.atoms.length,ko=f=>{if(!es)return null;let L=Ie[f]>=0?m.atomAt.get(Ie[f]):null,W=Pe[f]>=0?c.atomAt.get(Pe[f]):null,K=He[f]>=0?g.atomAt.get(He[f]):null;return L||W||K?{ab:L,al:W,ar:K}:null},Wn=(f,L,W)=>{let K=e.idOf;if(!K||!K.base)return!1;let Y=K.base(f.el);return Y!=null&&Y===K[W](L.el)},xo=(f,L,W,K,Y)=>{if(!f||!p)return null;let he=P.get(L.reverse.get(f.el))||null;return!he||he===K||(K?he.el.isEqualNode(K.el)&&!Wn(he,f,Y):W.bTo[he.i]>=0)?null:he},vo=(f,L)=>{if(!f||!p||!e.moveIn)return null;let W=L.reverse.get(f.el);return W&&!P.has(W)?W:null},le=(f,L)=>{let W=new Map;for(let K of f.atoms)W.set(L(K),(W.get(L(K))||0)+1);return W},ze=le(m,B),qe=le(c,w),st=le(g,y),At=f=>{let L=B(f);return ze.get(L)===1&&(qe.get(L)||0)<=1&&(st.get(L)||0)<=1},Ge=new Map,Xe=new Set,St=new Set,tt=new Set,wt=null;for(let f=0;f<Je;f++){let L=ko(f);if(!L)continue;let{ab:W,al:K,ar:Y}=L,he=xo(Y,s,xe,W,"remote"),ye=xo(K,n,oe,W,"local"),ve=W,We=null;if(he?(ve=he,We="remote"):ye&&(ve=ye,We="local"),ve){W&&ve!==W&&(wt||=new Map).set(W,We),Xe.has(ve)?Ge.set(f,{dup:ve.el}):(Xe.add(ve),Ge.set(f,{bk:ve,from:We,al:K,ar:Y}));continue}let Re=vo(Y,s),Fe=vo(K,n),xt=Re||Fe;if(xt){St.has(xt)?Ge.set(f,{dup:xt}):(St.add(xt),Ge.set(f,{moveIn:xt,side:Re?"remote":"local",sideEl:Re?Y.el:K.el}));continue}let ht=(Ft,Vt)=>Ft&&p&&P.get(Vt.reverse.get(Ft.el))||null,pt=ht(Y,s)||ht(K,n);if(pt&&(tt.add(pt),Se[f].conflict&&(At(pt)||Y&&(Y.el===pt.el||s.identityPaired?.has(pt.el))&&Wn(pt,Y,"remote")||K&&(K.el===pt.el||n.identityPaired?.has(pt.el))&&Wn(pt,K,"local")))){if(Xe.has(pt)){Ge.set(f,{dup:pt.el});continue}Xe.add(pt)}Ge.set(f,{al:K,ar:Y})}let lt=new Map,zt,Et,en=(f,L)=>{if(f[L]>=0)return f[L];for(let W=L-1;W>=0;W--)if(f[W]>=0)return f[W]+1;return 0};if(p)for(let f of m.atoms){if(Xe.has(f)||tt.has(f))continue;let L=n.map.get(f.el)||null,W=s.map.get(f.el)||null,K=L&&k.get(L),Y=W&&_.get(W);if(L&&!K||W&&!Y)continue;let he=!(K&&Y)&&Te.has(f);if(!he&&!(K&&Y&&(At(f)||wt?.has(f)||(K.el===f.el||n.identityPaired?.has(f.el))&&(Y.el===f.el||s.identityPaired?.has(f.el))&&Wn(f,K,"local")&&Wn(f,Y,"remote"))))continue;let ye=wt?.get(f),ve=t;if(ye){let ht=ye==="local"?g:c,pt=ye==="local"?s:n,Ft=ye==="local"?Et:zt;if(Ft===void 0){Ft=ht.atoms.length===m.atoms.length;for(let Vt=0;Ft&&Vt<m.atoms.length;Vt++)Ft=pt.reverse.get(ht.atoms[Vt].el)===m.atoms[Vt].el;ye==="local"?Et=Ft:zt=Ft}Ft&&(ve=ye)}let We=ve==="local"?[[K,ot],[Y,Wt]]:[[Y,Wt],[K,ot]],[Re,Fe]=We.find(([ht])=>ht),xt=en(Fe,Re.i);lt.has(xt)||lt.set(xt,[]),lt.get(xt).push({a:f,lt:L,rt:W,edited:he}),Xe.add(f)}if(p&&e.moveIn){let f=[[c,n,ot,"local"],[g,s,Wt,"remote"]];t!=="local"&&f.reverse();for(let[L,W,K,Y]of f)for(let he of L.atoms){let ye=vo(he,W);if(!ye||St.has(ye))continue;St.add(ye);let ve=en(K,he.i);lt.has(ve)||lt.set(ve,[]),lt.get(ve).push({move:ye,side:Y,sideEl:he.el})}}let Tn=f=>{let L=lt.get(f);if(L){if(Zt(f),L.some(W=>Ke(W.move?W.sideEl:W.a.el)))for(;bt.length;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;for(let{a:W,lt:K,rt:Y,edited:he,move:ye,side:ve,sideEl:We}of L){if(ye){let Fe=e.moveIn(ye,ve,We);Fe&&sn(Fe);continue}wn.add(W);let Re=N(W.el,K,Y);he&&(b({kind:"structure",el:Re,detail:"edit-beats-delete",base:W.el},{subject:W.el,deleted:K?"remote":"local"}),l.push({kind:"insert",el:Re,source:K?"local":"remote"})),sn(Re)}}},Kn=new Set,Po=r.length>u;for(let f=0;f<Je;f++){let L=ko(f),W=e.scopeUnits&&L&&(L.ab?.stack.some(ye=>ye.block)||L.al?.stack.some(ye=>ye.block)||L.ar?.stack.some(ye=>ye.block)),Y=!!L&&Ke((L.ab||L.al||L.ar).el)&&!W?[]:ie[f]?[ie[f],..._t(f)]:_t(f),he=0;for(;he<bt.length&&he<Y.length&&bt[he].u===Y[he];)he++;if(he<bt.length)for(Zt(f);bt.length>he;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;if(Ro(f),Tn(f),Y.length>bt.length)for(Zt(f);bt.length<Y.length;)Lo(Y[bt.length]);if(ue[f]===Nt){if(ee.has(f))continue;Zt(f);let ye=bt.length;for(;ye>0&&!bt[ye-1].u.block;)ye--;if(ye>0)for(Po&&a.breakOut.set(f,bt[ye-1].el);bt.length>=ye;)bt.pop(),Mt=bt.length?bt[bt.length-1].el:null;continue}if(L){Zt(f);let ye=Ge.get(f),ve;if(ye.dup){b({kind:"structure",el:null,detail:"both-moved",base:ye.dup},{subject:ye.dup});continue}if(ye.moveIn){if(ve=e.moveIn(ye.moveIn,ye.side,ye.sideEl),!ve)continue}else if(ye.bk){let We=ye.bk;if(wn.add(We),We===L.ab)ve=N(We.el,ye.al.el,ye.ar.el);else{let Re=n.map.get(We.el)||null,Fe=s.map.get(We.el)||null;ve=N(We.el,Re,Fe),(!Re||!Fe)&&b({kind:"structure",el:null,detail:"move-beats-delete",base:We.el},{subject:We.el,deleted:Re?"remote":"local"}),l.push({kind:"move",el:ve,source:ye.from})}}else ye.al?(ve=C(ye.al.el,"local"),ye.ar&&(d.get(ve).remote=ye.ar.el),l.push({kind:"insert",el:ve,source:ye.ar?"both":"local"})):(ve=C(ye.ar.el,"remote"),l.push({kind:"insert",el:ve,source:"remote"}));Po&&a.atomOut.set(f,ve),sn(ve);continue}Ht||(pn=f),Ht+=ue[f]}if(Zt(Je),(Gn.has(Je)||lt.has(Je))&&(bt.length=0,Mt=null,Ro(Je),Tn(Je)),Je===0&&(c.placeholder||g.placeholder||m.placeholder)){let f=o.createElement("br");d.set(f,{base:m.placeholder,local:c.placeholder,remote:g.placeholder}),dt.push(f)}let at=0,rt=f=>{for(;at>0&&Qe[at-1].me>=f;)at--;for(;at<Qe.length&&Qe[at].me<f;)at++;let L=Qe[at];if(!L)return Qe[Qe.length-1]||null;let W=Qe[at+1];return L.me===f&&W&&W.ms===f?W:L},Pt=new Map,ct={},It=(f,L,W)=>{let K=rt(f)||(W?ct:null);if(!K)return;let Y=Pt.get(K)||{l:!1,r:!1};L!=="remote"&&(Y.l=!0),L!=="local"&&(Y.r=!0),Pt.set(K,Y)},tn=f=>{if(f.conflict)return!0;let L=f.src==="local"?c.text:f.src==="remote"?g.text:"";for(let W=f.from;W<f.to;W++)if(L[W]!==Dn&&L[W]!==Nt)return!0;return!1};for(let f of Q)f.src!=="base"&&It(f.ms,f.conflict?"both":f.src,tn(f));for(let[f,L]of G)nt[f]>=0&&It(nt[f],L);for(let f of Qe.length?Qe:[ct]){let L=Pt.get(f);L&&l.push({kind:"text",node:f.node||null,source:L.l&&L.r?"both":L.l?"local":"remote"})}for(let f of Ze){if(On.has(f))continue;let L=!f.local&&!(p&&n.map.get(f.base)),W=!f.remote&&!(p&&s.map.get(f.base));!L&&!W||l.push({kind:"remove",source:L&&W?"both":L?"local":"remote",base:f.base})}if(Ve)for(let[f,L]of Ve)On.has(f)&&b({kind:"structure",el:On.get(f),detail:"edit-beats-delete",base:f.base},{subject:f.base,deleted:L});let Bt=(f,L,W)=>{if(L<=f)return!1;for(let K=f;K<L;K++)if(W[K]>=0)return!1;return!0};for(let f of Ze)for(let L of["local","remote"]){let W=f[L+"Mark"],K=f.baseMark;if(!W)continue;let Y=L==="local"?oe:xe;if(!Bt(K.from,K.to,Y.bTo)||!Bt(W.from,W.to,Y.toB))continue;let he=(L==="local"?Ce:be).find(ye=>ye.ss<=W.from&&W.from<ye.se);he&&(he.be<=K.from||he.bs>=K.to)&&l.push({kind:"move",el:On.get(f)||null,source:L})}let rn=f=>{let L=mt.get(f.node.parentNode);return L?Dt(L):null};for(let f of c.nodes){let L=-1;for(let K=f.s;K<f.e;K++)if(ot[K]>=0){L=ot[K];break}let W;if(L>=0)W=rt(L);else{let K=vt(f.s),Y=rn(f);W=Qe.find(he=>he.u===Y&&he.me>=K)||Qe.filter(he=>he.u===Y).pop()}W&&W.local.push(f)}let Yt=new Map,Ot=Qe[Qe.length-1]||null,kt=0;for(let f of c.nodes){let L=null;for(let W=f.s;W<=f.e;W++){let K=vt(W);for(;kt>0&&Qe[kt-1].me>=K;)kt--;for(;kt<Qe.length&&Qe[kt].me<K;)kt++;let Y=ye=>ye&&K>=ye.ms&&K<=ye.me&&(K<ye.me||W===f.e||ye===L),he=Y(Qe[kt])?Qe[kt]:Y(Qe[kt+1])?Qe[kt+1]:Qe[kt]||Ot;if(!he)break;if(L===he){let ye=Yt.get(he);ye[ye.length-1].to=W-f.s;continue}L=he,Yt.has(he)||Yt.set(he,[]),Yt.get(he).push({node:f.node,from:W-f.s,to:W-f.s,flatStart:f.s})}}for(let f of Qe){let L=f.local,W=!1;for(let ye of L)for(let ve=ye.s;ve<ye.e&&!W;ve++)(ot[ve]<f.ms||ot[ve]>=f.me)&&(W=!0);d.set(f.node,{base:null,local:L.map(ye=>ye.node),remote:null,caret:Yt.get(f)||[],partial:W});let K=f.ms,Y=f.me-f.ms,he=ye=>{let ve=0,We=-1;for(let Re of L){let Fe=Re.e-Re.s;if(ye<=ve+Fe){We=Re.s+(ye-ve);break}ve+=Fe}return We<0&&(We=L.length?L[L.length-1].e:0),Math.max(0,Math.min(vt(We)-K,Y))};he.flat=ye=>Math.max(0,Math.min(vt(ye)-K,Y)),i.set(f.node,he)}function Kt(){if(!c.text.includes(Nt))return[{flatLocal:c.text,localNodes:c.nodes,textNodes:Qe,lToM:ot,mapLocal:vt}];let f=[],L=0,W=0;for(let K=0;K<=c.text.length;K++){if(K<c.text.length&&c.text[K]!==Nt)continue;let Y=L,he=K;if(he>Y){let ye=[];for(;W<c.nodes.length&&c.nodes[W].e<=Y;)W++;for(let ve=W;ve<c.nodes.length&&c.nodes[ve].s<he;ve++){let We=c.nodes[ve],Re=Math.max(We.s,Y),Fe=Math.min(We.e,he);Re<Fe&&ye.push({node:We.node,s:Re-Y,e:Fe-Y})}f.push({flatLocal:c.text.slice(Y,he),localNodes:ye,textNodes:Qe,lToM:ot.subarray?ot.subarray(Y,he+1):ot.slice(Y,he+1),mapLocal:ve=>vt(Y+Math.max(0,Math.min(ve,he-Y)))})}L=K+1}return f}let nn={...e,blocks:Kn,ignored:f=>yo.has(f)||(e.ignored?e.ignored(f):!1)},Vn=e.ignoreAttribute||(()=>!1),Yn=Gs(ln(dt,nn),Vn)!==Gs(g,Vn);if(h.length){let f=L=>{let W=d.get(L);return W&&W.unchanged?W.remote:null};a.text=ue,a.textNodes=Qe,a.out=ln(dt,{...nn,via:f})}let no=null;if(e.scopeUnits){no=new Map;let f=new Set(dt),L=ve=>{for(;ve&&!f.has(ve);)ve=ve.parentNode;return ve},W=e.scopeUnits.map(ve=>{let We=new Map;for(let Re of ve)if(Re.nodeType===1)We.set(Re,Re);else for(let Fe of Re.nodes)We.set(Fe,Re);return We}),K=(ve,We)=>{for(;ve&&!We.has(ve);)ve=ve.parentNode;return ve?We.get(ve):null},Y=[m,c,g].map((ve,We)=>{let Re=new Array(ve.text.length);for(let Fe of ve.nodes){let xt=K(Fe.node,W[We]);xt&&Re.fill(xt,Fe.s,Fe.e)}for(let Fe of ve.atoms)Re[Fe.i]=K(Fe.el,W[We]);return Re}),he=(ve,We)=>{if(!ve||!We)return;let Re=no.get(ve);Re||no.set(ve,Re=new Set),Re.add(We)};for(let ve of dt){let We=d.get(ve);We&&(he(K(We.base,W[0]),ve),he(K(We.local,W[1]),ve),he(K(We.remote,W[2]),ve))}for(let ve of Qe){let We=L(ve.node);for(let Re=ve.ms;Re<ve.me;Re++)he(Y[0][Ie[Re]],We),he(Y[1][Pe[Re]],We),he(Y[2][He[Re]],We)}let ye=new Map(dt.map((ve,We)=>[ve,We]));for(let[ve,We]of no)no.set(ve,Array.from(We).sort((Re,Fe)=>ye.get(Re)-ye.get(Fe)))}return{unitOutputs:no,nodes:dt,text:ue,textNodes:Qe,localDiverged:Yn,mapLocal:vt,conflicts:r.slice(u),granularity:V?"line":"word",segments:Kt(),localHunks:Ce,remoteHunks:be,lToM:ot}}var xs=Symbol("lost");function rr(){return{links:new Map,removed:new Set,consumed:new Set,link(e,o){this.links.set(e,o)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let o of e.nodes)this.removed.add(o)},consume(e){for(let o of e)this.consumed.add(o)}}}var sr=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function ir({locals:e,rec:o,root:t,provenance:n,segments:s,ignored:d}){let i=new Map,r=(T,x)=>{let A=i.get(T);A||i.set(T,A=new Set),A.add(x)},l=new Set,u=new Set;for(let T of s){let x=T.textNodes;for(let A of x)l.add(A.node);for(let A of T.localNodes){u.add(A.node);let E=0,S=null;for(let N=A.s;N<A.e;N++){let C=T.lToM[N];if(C<0)continue;for((!x[E]||C<x[E].ms)&&(E=0);E<x.length&&x[E].me<=C;)E++;let j=x[E]&&x[E].ms<=C?x[E].node:xs;j!==S&&r(A.node,j),S=j}}}let b=new Set,a=new Map,h=new Set;(function T(x){b.add(x);let A=n.get(x);if(x.nodeType===1)A&&A.local&&A.local.nodeType===1&&(r(A.local,x),A.unchanged&&h.add(A.local)),x.tagName==="TEMPLATE"&&x.content&&a.set(x.content,x);else if(A&&Array.isArray(A.local)&&!l.has(x))for(let E of A.local)r(E,x);for(let E=sr(x).firstChild;E;E=E.nextSibling)T(E)})(t);let p=new Set;for(let[T,x]of o.links)r(T,x),p.add(T);let v=T=>{let x=T.parentNode;return x&&x.nodeType===11?a.get(x)||null:x},O=(T,x)=>{for(let A=T;A;A=v(A))if(A===x)return!0;return!1},m=T=>o.removed.has(T)||o.consumed.has(T),c=T=>{for(let x=T.parentNode;x&&x.nodeType===1;x=x.parentNode){if(h.has(x))return"kept";if(m(x))return"decided";if(i.has(x))return null}return null},g=new Map;for(let T of e)g.set(T,P(T));return g;function P(T){let x=i.get(T);if(x&&(x.size!==1||x.has(xs)))return{kind:"unknown",reason:"several-outputs"};let A=x?x.values().next().value:null;if(A&&(A.nodeType!==1||!b.has(A)))return{kind:"unknown",reason:"output-not-placed"};if(!A){let C=m(T)?"decided":c(T);if(C==="kept")return{kind:"untouched"};if(C!=="decided")return{kind:"unknown",reason:"unmapped"}}let E=[],S=N(T,!!A&&(h.has(T)||p.has(T)),!A||m(T));if(S)return{kind:"unknown",reason:S};return A?{kind:"single",output:A,owned:E,carried:p.has(T)}:{kind:"removed"};function N(C,j,D){for(let B=sr(C).firstChild;B;B=B.nextSibling){if(B.nodeType===1?d(B):B.nodeType!==3&&B.nodeType!==8)continue;let w=i.get(B);if(w)for(let y of w){if(y===xs||!b.has(y))return"output-not-placed";if(!A)return"survives-elsewhere";if(!O(y,A))return"escaped";E.push(y)}else if(!j&&!D&&!m(B)&&!u.has(B))return"unmapped";if(B.nodeType===1){let y=N(B,j||h.has(B)||p.has(B),D||m(B));if(y)return y}}return null}}}function lr(e,o){if(!o)return!1;let t=o.nodeType===1&&o.tagName==="TEMPLATE"?[o,...o.querySelectorAll("template")]:[...o.querySelectorAll("template")];for(let n of t)if(n.content.contains(e)||lr(e,n.content))return!0;return!1}function ar(e,o){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let t=[],n=new Set;for(let s of Array.from(e.elements)){if(!s||s.nodeType!==1||s.ownerDocument!==o&&!lr(s,o.documentElement))throw new TypeError("lineage.elements must be elements of the live document");n.has(s)||(n.add(s),t.push(s))}return t}var cr=new WeakMap;function fr(e){let o=new Map;for(let t of e){let n=[],s=!1;(function d(i){i.nodeType===1&&i.namespaceURI==="http://www.w3.org/1999/xhtml"&&i.localName==="template"&&(s=!0);for(let r=i.firstChild;r;r=r.nextSibling)n.push(r),r.nodeType===1&&d(r)})(t),o.set(t,{nodes:n,opaque:s})}return o}function vs(e,o,t){if(e.lineage===void 0)return t(e);if(!o||o.nodeType!==1)throw new TypeError("lineage requires an element root");let n=e.lineage,s=ar(n,o.ownerDocument),d=!1,i={...e,lineage:{elements:s,onResult(r,l){if(!d)return d=!0,n.onResult(r,l)}}};try{return cr.set(i.lineage,fr(s)),t(i)}catch(r){if(!d){d=!0;try{n.onResult({version:1,root:o,status:"incomplete",entries:s.map(Nn)},null)}catch{}}throw r}}function Ts(e,{liveRoot:o,localRoot:t,toLive:n}){let s=ar(e,o.ownerDocument),d=u=>u===o||o.contains(u),i=new Map,r=new Set(s.filter(d));if(r.size&&t===o)for(let u of r)i.set(u,u);else r.size&&(function u(b){let a=n(b);r.delete(a)&&i.set(a,b);for(let h=b.firstElementChild;h&&r.size;h=h.nextElementSibling)u(h)})(t);return{spec:e,watched:s,root:o,locals:Array.from(new Set(i.values())),before:cr.get(e)||fr(s),delivered:!1,result:null,finish(u,b){return this.resolve=b,this.plans=u,this.result={version:1,root:this.root,status:"complete",entries:s.map(a=>Ui(a,i.get(a),u,b,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(u,b){this.root=b;let a=this.resolve,h=v=>{let O=a(v);return O===u?b:O};return this.finish(this.plans,h)},deliver(u){this.delivered||(this.delivered=!0,e.onResult(this.result,u))}}}var Nn=e=>({from:e,to:[],kind:"unknown",complete:!1});function Ui(e,o,t,n,s){let d=s.root,i=h=>!!h&&(h===d||d.contains(h)),r=o&&t?t.get(o):null;if(!r||r.kind==="unknown")return Nn(e);let l=s.before.get(e);if(!l||l.opaque)return Nn(e);let u=l.nodes,b=h=>i(h)||!!(h&&h.ownerDocument===d.ownerDocument&&d.ownerDocument.documentElement?.contains(h));if(r.kind==="untouched"){if(!i(e))return Nn(e);for(let h of u)if(b(h)&&!e.contains(h))return Nn(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(r.kind==="removed")return b(e)||u.some(b)?Nn(e):{from:e,to:[],kind:"removed",complete:!0};let a=n(r.output);if(!a||a.nodeType!==1||!i(a)||a!==e&&b(e))return Nn(e);for(let h of u)if(b(h)&&!a.contains(h))return Nn(e);for(let h of r.owned){let p=n(h),v=Array.isArray(p)?p:[p];for(let O of v)if(!O||!i(O)||!a.contains(O))return Nn(e)}return r.carried&&!ur(a,r.output,n)?Nn(e):{from:e,to:[a],kind:a===e?"retained":"replaced",complete:!0}}function ur(e,o,t){for(let n=o.firstChild;n;n=n.nextSibling){let s=t(n),d=Array.isArray(s)?s:[s];for(let i of d)if(!i||!e.contains(i))return!1;if(n.nodeType===1&&!ur(e,n,t))return!1}return!0}function No(e,o,t){let n=Ts(e,{liveRoot:o,localRoot:o,toLive:s=>s});return n.result={version:1,root:o,status:"complete",entries:n.watched.map(s=>Nn(s))},t.lineage=n.result,n}function dr(e,o,t,n,s){if(!s(e.length*8+1))return null;let d=0,i=o===0,r=!1;for(let l of fn(e,n)){if(!s(1))return null;if(d+=l.len,d===o&&(i=!0),d===t&&(r=!0),d>=t)break}return i&&r}function Vi(e,o,t,n,s,d,i){if(!i(o.length*2))return!1;let r=new Map,l=new Map,u=new Set;for(let b of o){let a=b.bs<b.be,h=a?t[b.ownerIndex].text.base:t[b.ownerIndex].text[e],p=a?b.bs:b.ss,v=a?b.be:b.se;if(!i((v-p)*4+1))return!1;for(;p<v&&/\s/.test(h[p]);)p++;for(;v>p&&/\s/.test(h[v-1]);)v--;if(p===v)continue;let O=h.slice(p,v),m=a?r:l;a&&b.text&&u.add(O),m.has(O)?m.set(O,null):m.set(O,{h:b,from:p,to:v})}for(let b of n){if(!i(1))return!1;if(b.side!==e)continue;let a=b.deletion,h=t[a.ownerIndex].text.base;if(!i((a.be-a.bs)*3)||u.has(h.slice(a.bs,a.be).trim()))return!1}for(let[b,a]of r){if(!i(b.length+1))return!1;let h=l.get(b);if(!a||!h)continue;let p=a.h,v=h.h;if(!p.text||p.transferOut||v.transferIn||p.owner===v.owner)continue;let O=t[p.ownerIndex],m=t[v.ownerIndex];if(!i(O.text.base.length))return!1;if(!/\S/.test(O.text.base.slice(0,p.bs)+O.text.base.slice(p.be)))continue;let c=dr(O.text.base,a.from,a.to,d,i),g=dr(m.text[e],h.from,h.to,d,i);if(c===null||g===null)return!1;if(!c||!g)continue;let P=`${O.index}:${a.from}:${a.to}`,T={key:P,side:e,source:p.owner,destination:v.owner,deletion:p,insertion:v,sourceOffset:a.from-p.bs,targetOffset:h.from-v.ss,length:a.to-a.from};p.transferOut=T,v.transferIn=T,s[e].set(P,T),n.push(T)}return!0}function hr({base:e,local:o,remote:t,localTwin:n,remoteTwin:s,eligible:d,nodes:i,budget:r=Xt(2e4*32)}){let l=S=>S>r.remaining?!1:(r.remaining-=S,r.nativeSteps=(r.nativeSteps||0)+S,!0);if(e.length<2||o.length!==e.length||t.length!==e.length||!l(e.length*12))return null;for(let[S,N]of[["base",e],["local",o],["remote",t]]){let C=i[S];if(C.length!==N.length||C.some((j,D)=>j!==N[D]))return null}let u=[],b=0;for(let S=0;S<e.length;S++){let N=e[S],C=o[S],j=t[S];if(n(N)!==C||s(N)!==j)return null;let D={};for(let[B,w]of[["base",N],["local",C],["remote",j]]){if(!d(w)||w.tagName!==N.tagName||w.namespaceURI!==N.namespaceURI||!l(w.childNodes.length+1))return null;let y="";for(let $ of w.childNodes){if($.nodeType!==3||!l($.data.length*4+1))return null;y+=$.data}if(y.includes(Nt)||(b+=y.length+1,b>2e4))return null;D[B]=y}u.push({base:N,local:C,remote:j,index:S,text:D})}let a=u.every(S=>xn(S.text.base,S.text.local,S.text.remote)),h={local:[],remote:[]};for(let S of u){S.hunks={local:[],remote:[]};for(let N of["local","remote"]){let C=S.text.base,j=S.text[N];if(C===j)continue;let D=C.length+j.length+4,B=D*8;if(!l(B))return null;let w=Math.floor(r.remaining/8),y=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(D*D+w)-D)/2)));if(y<1||!l(4*(y+1)*(D+y+1)))return null;let $=0;for(let U of _n(C,j,y)){if(!l(U.text.length+1))return null;let V=U.bs+$,Ne={...U,ss:V,se:V+U.text.length,toks:fn(U.text,a),owner:S.base,ownerIndex:S.index};S.hunks[N].push(Ne),h[N].push(Ne),$+=U.text.length-(U.be-U.bs)}}}let p=[],v={local:new Map,remote:new Map};for(let S of["local","remote"]){let N=new Map,C=new Map,j=!1,D=(B,w,y)=>{B.has(w)?B.set(w,null):B.set(w,y)};for(let B of h[S]){if(!l(1))return null;let w=u[B.ownerIndex].text.base;if(B.bs<B.be&&B.text===""){let y=w.slice(B.bs,B.be);if(!l(y.length*2))return null;/\S/.test(y)&&D(N,y,B)}else if(B.bs===B.be&&/\S/.test(B.text)){if(!l(B.text.length*2))return null;D(C,B.text,B)}else B.bs<B.be&&(j=!0)}for(let[B,w]of N){if(!l(B.length+1))return null;let y=C.get(B);if(!w||!y||w.owner===y.owner)continue;let $=u[w.ownerIndex];if(!l($.text.base.length))return null;if(!/\S/.test($.text.base.slice(0,w.bs)+$.text.base.slice(w.be)))continue;let U=`${$.index}:${w.bs}:${w.be}`,V={key:U,side:S,source:w.owner,destination:y.owner,deletion:w,insertion:y};w.transferOut=V,y.transferIn=V,v[S].set(U,V),p.push(V)}if(j&&C.size&&!Vi(S,h[S],u,p,v,a,l))return null}if(!p.length)return null;let O=(S,N)=>S.bs<N.be&&N.bs<S.be,m=S=>S.bs===S.be,c=(S,N)=>S.bs<=N.be&&N.bs<=S.be&&m(S)!==m(N),g=(S,N)=>S.bs===N.bs&&S.be===N.be&&S.text===N.text,P=(S,N)=>!!(S.transferIn||S.transferOut&&(!S.text||N.bs===S.be&&/\s/.test(N.text[0])||N.bs===S.bs&&/\s/.test(N.text[N.text.length-1])));for(let S of p){let N=S.side==="local"?"remote":"local",C=u[S.deletion.ownerIndex];for(let j of C.hunks[N])if(!l(1)||O(S.deletion,j)&&j.transferOut?.key!==S.key)return null}for(let S of u)for(let N of S.hunks.local)for(let C of S.hunks.remote){if(!l(1))return null;if(g(N,C)){if(N.transferIn?.key!==C.transferIn?.key)return null;continue}if(O(N,C)||c(N,C)&&!P(N,C)&&!P(C,N))return null}if(!l(b*8))return null;let T=new Set([...e,...o,...t]),x={base:ln(e,{blocks:T}),local:ln(o,{blocks:T}),remote:ln(t,{blocks:T})},A={};for(let S of["base","local","remote"]){let N=x[S];if(N.atoms.length||N.pins.length)return null;A[S]=new Map(N.marks.filter(C=>C.block).map(C=>[C.el,C.from]))}for(let S of u){let N=A.base.get(S.base);if(N===void 0)return null;for(let C of["local","remote"]){let j=A[C].get(S[C]);if(j===void 0)return null;for(let D of S.hunks[C])D.bs+=N,D.be+=N,D.ss+=j,D.se+=j}}for(let S of p)S.bs=S.deletion.bs+(S.sourceOffset||0),S.be=S.length===void 0?S.deletion.be:S.bs+S.length,S.ss=S.insertion.ss+(S.targetOffset||0),S.se=S.length===void 0?S.insertion.se:S.ss+S.length;let E={};for(let S of["local","remote"]){let N=0,C=0,j=[];for(let B of h[S]){if(!l(1))return null;B.bs>N&&j.push({from:N,to:B.bs,target:C}),N=B.be,C=B.se}N<x.base.text.length&&j.push({from:N,to:x.base.text.length,target:C});let D=p.filter(B=>B.side===S).map(B=>({from:B.bs,to:B.be,target:B.ss,destination:B.destination}));if(E[S]=Bn({base:x.base,side:x[S],retained:j,transfers:D,budget:r}),E[S].status!=="ready")return null}return l(x.base.text.length)?{owners:u,blocks:T,transfers:p,byOrigin:v,budget:r,prepared:{base:x.base,local:x.local,remote:x.remote,lines:!1,baseTokens:fn(x.base.text,a),localEdits:{hunks:h.local,respell:new Map},remoteEdits:{hunks:h.remote,respell:new Map},localMap:E.local,remoteMap:E.remote,full:null}}:null}var Ss=/\S/;function pr({certificates:e,scopes:o,views:t,eligible:n,baseId:s,limit:d=2e4*32}){let i=Xt(d),r=Symbol(),l=[],u=a=>{if(a>i.remaining)throw r;i.remaining-=a},b=(a,h=null)=>{if(u(1),!a||a.nodeType!==1||a.parentNode?.nodeType!==1||!n(a))return null;for(let O=a.parentNode;O;O=O.parentNode)if(u(1),O.nodeType===11)return null;let p="",v=0;for(let O of a.childNodes){if(u(1),O.nodeType!==3)return null;if(u(O.data.length*4+1),h){let m=h.flat.nodes[v++];if(!m||m.node!==O||m.s!==p.length||m.e!==p.length+O.data.length)return null}p+=O.data}return u(p.length*3+1),h&&(h.flat.atoms.length||h.flat.pins?.length||v!==h.flat.nodes.length||h.flat.text!==p)?null:Ss.test(p)?p:null};try{u(o[0].length+o[1].length+o[2].length+e.length);let a=o.map(p=>new Set(p)),h=new Map;for(let p of e){u(1);let v=h.get(p.source);v||h.set(p.source,v=[]),v.push(p)}for(let p of h.values()){let v=[null,null],O=[];for(let m of p){u(1);let{source:c,target:g,side:P,models:T,runs:x}=m;if(P!==0&&P!==1||!a[0].has(c)||!a[P+1].has(g))continue;let{V:A,A:E,idOf:S}=t[P],N=t[1-P],C=A.twin(c),j=N.V.twin(c),D=A.baseOf(g);if(!C||!j||!D||D===c||!a[0].has(D)||!a[P+1].has(C)||!a[2-P].has(j)||E.map.get(c)!==C||E.reverse.get(C)!==c||N.A.map.get(c)!==j||N.A.reverse.get(j)!==c||E.map.get(D)!==g||E.reverse.get(g)!==D||g.parentNode!==C.parentNode||D.parentNode!==c.parentNode||c.tagName!==C.tagName||c.tagName!==j.tagName||s(c)!==S(C)||s(c)!==N.idOf(j)||s(D)!==S(g))continue;let B=T.get(c),w=T.get(g);if(!B||!w)continue;let y=b(c,B),$=b(g,w),U=b(C),V=b(j);if(u((y?.length||0)+(V?.length||0)),y===null||$===null||U===null||V===null||V===y)continue;let Ne=x.length>0,Ae=!1;for(let oe of x){if(u(1),oe.source!==c||oe.target!==g||!Number.isInteger(oe.from)||!Number.isInteger(oe.to)||!Number.isInteger(oe.targetFrom)||oe.from<0||oe.to<=oe.from||oe.to>y.length||oe.targetFrom<0||oe.targetFrom+oe.to-oe.from>$.length){Ne=!1;break}u((oe.to-oe.from)*3);for(let xe=oe.from;xe<oe.to;xe++){if(y[xe]!==$[oe.targetFrom+xe-oe.from]){Ne=!1;break}Ss.test(y[xe])&&(Ae=!0)}if(!Ne)break}if(!Ne||!Ae)continue;let De=v[P];De||(u(y.length),De=v[P]={source:c,side:P,flat:B.flat,before:y,covered:new Uint8Array(y.length)});for(let oe of x)u(oe.to-oe.from),De.covered.fill(1,oe.from,oe.to)}for(let m of v){if(!m)continue;let{source:c,side:g,flat:P,before:T,covered:x}=m;u(T.length*3+1);let A=-1,E=-1;for(let S=0;S<=T.length;S++)S<T.length&&x[S]?(A<0&&(A=S),E=S+1):(S===T.length||Ss.test(T[S]))&&A>=0&&(O.push({source:c,side:g,flat:P,from:A,to:E}),A=E=-1)}u(O.length),l.push(...O)}}catch(a){if(a!==r)throw a}return{records:l,budget:i}}var Hi="http://www.w3.org/1999/xhtml";function Wi(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function mn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Hi}function Ki(e){let o=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return o==="application/json"||o.endsWith("+json")}function _o(e,o){let t=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let s=t;try{let d=new URL(t,o);s=d.origin+d.pathname+d.search}catch{}return"script|src|"+n+"|"+s}return"script|inline|"+n+"|"+Wi(e.textContent.trim())}var Fi={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function fo(e,o=[],t=!1){if(!mn(e)||e.hasAttribute("src"))return null;let n=[Fi,...o];for(let s=0;s<n.length;s++){let d=n[s];if(!d.match(e))continue;if(!Ki(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let i=d.identity(e);return i==null||i===""?null:{key:s+":"+i,raw:i,recognizer:d}}return null}function mr(e,o,t){let n=new Set,s=d=>{mn(d)&&!o(d)&&n.add(_o(d,t))};s(e);for(let d of e.querySelectorAll("script"))s(d);return n}function Ao(e,o){let t=o.createElement("div");t.innerHTML="<script><\/script>";let n=t.firstChild;for(let s of e.attributes)n.setAttribute(s.name,s.value);return n.textContent=e.textContent,n}function gr(e,o,t){let n=[],s=[],d=new Map,i=t.trackRecovery?new Set:null,r=Array.from(e.querySelectorAll("script"));mn(e)&&r.unshift(e);for(let l of r){if(!mn(l)||t.ignored(l)||t.skip.has(l)||o.has(_o(l,t.baseURI)))continue;let u=l.ownerDocument.createElement("script");for(let b of l.attributes)u.setAttribute(b.name,b.value);if(u.textContent=l.textContent,t.beforeNodeAdded(u)===!1){i?.add(l);continue}u.hasAttribute("src")&&s.push(new Promise(b=>{u.addEventListener("load",()=>b()),u.addEventListener("error",()=>b())})),l.replaceWith(u),d.set(l,u),t.afterNodeAdded(u),n.push(u)}return{executed:n,loads:s,swapped:d,vetoed:i}}function qi(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function _i(e,o){try{let t=new URL(e,o);return t.origin+t.pathname+t.search}catch{return e}}function br(e,o){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return _o(e,o);if(t==="LINK"){let n=e.getAttribute("href");return n?"link|"+(e.getAttribute("rel")||"")+"|"+_i(n,o):e.outerHTML}if(t==="META"){for(let n of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(n))return"meta|"+n+"="+e.getAttribute(n);return e.outerHTML}return t==="STYLE"?"style|"+qi(e.textContent):e.outerHTML}function Ns(e,o){for(;;){for(;o<e.length&&/\s/.test(e[o]);)o++;if(e[o]==="/"&&e[o+1]==="/"){for(;o<e.length&&e[o]!==`
|
|
4
|
-
`;)o++;continue}if(e[o]==="/"&&e[o+1]==="*"){let t=e.indexOf("*/",o+2);if(t===-1)return e.length;o=t+2;continue}return o}}function wr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(o,t)=>t.length%2===0?t+'\\"':o)}var zi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,$i=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function zo(e){try{return JSON.parse(e)}catch{return JSON.parse(Gi(e))}}function Gi(e){let o="",t=0,n=(s,d)=>{throw new Error(`Invalid relaxed JSON: ${s} at position ${d}`)};for(;t<e.length&&(t=Ns(e,t),!(t>=e.length));){let s=e[t];if("{}[]:".includes(s)){o+=s,t++;continue}if(s===","){let r=Ns(e,t+1);if(e[r]==="}"||e[r]==="]"){t++;continue}o+=s,t++;continue}if(s==='"'||s==="'"){let r=t+1;for(;r<e.length&&e[r]!==s;)e[r]==="\\"&&r++,r++;r>=e.length&&n("unterminated string",t);let l=e.slice(t+1,r);s==="'"&&(l=wr(l)),o+='"'+l+'"',t=r+1;continue}let d=t;for(;d<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[d]);)d++;d===t&&n("unexpected character "+JSON.stringify(s),t);let i=e.slice(t,d);if(i==="true"||i==="false"||i==="null"||zi.test(i)){o+=i,t=d;continue}if($i.test(i)){if(e[Ns(e,d)]===":"){o+='"'+i+'"',t=d;continue}n("unquoted value "+JSON.stringify(i),t)}n("invalid token "+JSON.stringify(i),t)}return o}function yr(e){try{return JSON.parse(e)}catch{}let o={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(s){let d=[],i=0;for(;i<s.length;){let r=s[i];if(/\s/.test(r)){i++;continue}if("{}".includes(r)){d.push({type:r,value:r}),i++;continue}if(r==="["){let a=!1,h=i+1;for(;h<s.length&&/\s/.test(s[h]);)h++;if(h<s.length&&/[a-zA-Z_]/.test(s[h])&&(a=!0),!a){d.push({type:r,value:r}),i++;continue}}if(r==="]"){d.push({type:r,value:r}),i++;continue}if(r===":"){d.push({type:o.COLON,value:r}),i++;continue}if(r===","){d.push({type:o.COMMA,value:r}),i++;continue}if(r==='"'||r==="'"){let a=r,h=i+1;for(;h<s.length&&s[h]!==a;)s[h]==="\\"&&h++,h++;d.push({type:o.STRING,value:s.substring(i+1,h),quoted:!0,sourceQuote:a}),i=h+1;continue}let l=i,u;for(;l<s.length&&!/[{},]/.test(s[l]);)if(s[l]===":"){let a=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],h=!1;for(let p of a){let v=p.substring(1);if(s.substring(l+1,l+1+v.length)===v){h=!0,l+=v.length;break}}if(!h)break}else if(s[l]==="["){for(l++;l<s.length&&s[l]!=="]";){if(s[l]==='"'||s[l]==="'"){let a=s[l];for(l++;l<s.length&&s[l]!==a;)s[l]==="\\"&&l++,l++}l++}l<s.length&&s[l]==="]"&&l++}else l++;u=s.substring(i,l);let b=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?b=o.NUMBER:u==="true"||u==="false"||u==="null"?b=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(b=o.SELECTOR),d.push({type:b,value:u,quoted:!1}),i=l}return d}function n(s){let d="";for(let i=0;i<s.length;i++){let r=s[i];if("{}".includes(r.type)||"[]".includes(r.type)){d+=r.value;continue}if(r.type===o.COLON){d+=r.value;continue}if(r.type===o.COMMA){let l=s[i+1];if(l&&(l.type==="}"||l.type==="]"))continue;d+=r.value;continue}if(r.type===o.STRING){let l=r.value;r.sourceQuote==="'"&&(l=wr(l)),d+=`"${l}"`;continue}if(r.type===o.NUMBER||r.type===o.BOOLEAN){d+=r.value;continue}d+=`"${r.value}"`}return d}try{let s=t(e),d=n(s);return JSON.parse(d)}catch(s){throw new Error("Invalid extraction rules syntax: "+s.message)}}var Qt=Symbol("hyper-morph-json-merge:missing"),kr=["id","_id","uuid","key","slug","code","name"];function uo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mo(e,o){return Object.prototype.hasOwnProperty.call(e,o)}function Yi(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}function zn(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o)){if(e.length!==o.length)return!1;for(let t=0;t<e.length;t++)if(!zn(e[t],o[t]))return!1;return!0}if(uo(e)&&uo(o)){let t=Object.keys(e);if(t.length!==Object.keys(o).length)return!1;for(let n of t)if(!Mo(o,n)||!zn(e[n],o[n]))return!1;return!0}return!1}function xr(e,o,t,n){return zn(o,t)?o:zn(o,e)?t:zn(t,e)?o:uo(o)&&uo(t)?Xi(uo(e)?e:{},o,t,n):Array.isArray(o)&&Array.isArray(t)?el(Array.isArray(e)?e:[],o,t,n):t}function vr(e,o,t,n){return o===Qt&&t===Qt?Qt:o===Qt?e===Qt?t:zn(t,e)?Qt:t:t===Qt?e===Qt?o:Qt:xr(e,o,t,n)}function Xi(e,o,t,n){let s={},d=new Set([...Object.keys(e),...Object.keys(o),...Object.keys(t)]);for(let i of d){let r=vr(Mo(e,i)?e[i]:Qt,Mo(o,i)?o[i]:Qt,Mo(t,i)?t[i]:Qt,n);r!==Qt&&Yi(s,i,r)}return s}function Ji(e){return e===null||typeof e!="object"}function $o(e){return typeof e+":"+String(e)}function Qi(e,o){for(let t of o){let n=new Set;for(let s of t){if(!Mo(s,e))return!1;let d=s[e];if(typeof d!="string"&&typeof d!="number")return!1;let i=$o(d);if(n.has(i))return!1;n.add(i)}}return!0}function Zi(e,o,t,n){let s=[e,o,t],d=!0;for(let i of s)for(let r of i)uo(r)||(d=!1);if(d){for(let i of n.keyCandidates)if(Qi(i,s))return{kind:"keyed",field:i};return null}for(let i of s){let r=new Set;for(let l of i){if(!Ji(l))return null;let u=$o(l);if(r.has(u))return null;r.add(u)}}return{kind:"self"}}function el(e,o,t,n){let s=Zi(e,o,t,n);if(!s)return t;let d=s.kind==="self"?$o:p=>$o(p[s.field]),i=p=>{let v=new Map;for(let O of p)v.set(d(O),O);return v},r=i(e),l=i(o),u=i(t),b=new Map,a=new Set([...r.keys(),...l.keys(),...u.keys()]);for(let p of a){let v=vr(r.has(p)?r.get(p):Qt,l.has(p)?l.get(p):Qt,u.has(p)?u.get(p):Qt,n);v!==Qt&&b.set(p,v)}let h=[];for(let p of t){let v=d(p);b.has(v)&&h.push(v)}for(let p=0;p<o.length;p++){let v=d(o[p]);if(!b.has(v)||h.includes(v))continue;let O=0;for(let m=p-1;m>=0;m--){let c=h.indexOf(d(o[m]));if(c!==-1){O=c+1;break}}h.splice(O,0,v)}return h.map(p=>b.get(p))}function As(e,o,t,n={}){let s=n.keyCandidates?[...n.keyCandidates,...kr]:kr;return xr(e===void 0?Qt:e,o,t,{keyCandidates:s})}function Go(e,o,t,n={}){let s=n.parse||zo,d=[],i=(a,h)=>{if(typeof a!="string")return Qt;try{return s(a)}catch(p){return d.push(`${h} side is not valid JSON (${p.message})`),Qt}},r=i(o,"local"),l=i(t,"remote");if(r===Qt)return{text:t,warnings:d};if(l===Qt)return{text:o,warnings:d};let u=i(e,"base"),b=As(u===Qt?void 0:u,r,l,n);return zn(b,l)?{text:t,warnings:d}:zn(b,r)?{text:o,warnings:d}:{text:JSON.stringify(b,null,2),warnings:d}}var Tr=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Zn(e){if(!e)return!1;let{startContainer:o,startOffset:t,endContainer:n,endOffset:s}=e;if(!o||!n||!Number.isInteger(t)||!Number.isInteger(s)||t<0||s<0||t>Tr(o)||s>Tr(n)||o.getRootNode()!==n.getRootNode())return!1;let d=o.ownerDocument.createRange();return d.setStart(o,t),d.setEnd(n,s),d.startContainer===o&&d.startOffset===t}function $n(e,o,t={}){if(!Zn(e))return null;let{startContainer:n,startOffset:s,endContainer:d,endOffset:i}=e;if(n===d&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(s,i);if(n===d&&s===i)return"";let r=new Set;for(let m=n;m;m=m.parentNode)r.add(m);let l=d;for(;!r.has(l);)l=l.parentNode;let u=(m,c)=>{let g=l.ownerDocument.createRange(),P=l.ownerDocument.createRange();return g.setStart(m[0],m[1]),g.collapse(!0),P.setStart(c[0],c[1]),P.collapse(!0),g.compareBoundaryPoints(0,P)},b=(m,c=!1)=>[m.parentNode,Array.prototype.indexOf.call(m.parentNode.childNodes,m)+Number(c)],a=[],h;if(o==="plain"){h="";let m=c=>{if(c.nodeType===3||c.nodeType===8){let g=h.length;h+=c.nodeValue,a.push({s:g,e:h.length,a:[c,0],b:[c,c.nodeValue.length],node:c})}else for(let g of c.childNodes)m(g)};m(l)}else{let m=t.blocks;if(!m){m=new Set;let g=P=>{P!==l&&P.nodeType===1&&ys.has(P.tagName)&&m.add(P);for(let T of P.childNodes)g(T)};g(l)}let c=ln(Array.from(l.childNodes),{blocks:m,atomize:g=>!!t.atoms?.has(g),ignored:t.ignored});h=c.text;for(let g of c.nodes)a.push({s:g.s,e:g.e,a:[g.node,0],b:[g.node,g.e-g.s],node:g.node});for(let g of c.atoms)a.push({s:g.i,e:g.i+1,a:b(g.el),b:b(g.el,!0)});for(let g=0;g<c.text.length;g++){if(c.text[g]!==Nt)continue;let P=c.marks.find(x=>x.block&&x.to===g+1),T=c.marks.find(x=>x.block&&x.from===g+1);if(P)a.push({s:g,e:g+1,a:[P.el,P.el.childNodes.length],b:b(P.el,!0)});else if(T)a.push({s:g,e:g+1,a:b(T.el),b:[T.el,0]});else return null}}a.sort((m,c)=>m.s-c.s);let p=m=>{if(m[0].nodeType===3||m[0].nodeType===8){let g=a.find(P=>P.node===m[0]);return g?g.s+m[1]:null}let c=0;for(let g of a){if(u(m,g.a)<=0)return g.s;if(u(m,g.b)<0)return null;c=g.e}return c},v=p([n,s]),O=p([d,i]);return v!==null&&O!==null&&v<=O?h.slice(v,O):null}function Qn(e,o){let t=e;for(let n of o.path)if(t=n==="content"?t?.content:t?.childNodes[n],!t)return null;return[t,o.offset]}function Sr(e,o){if(!e||!o)return null;let t=Qn(e,o.start),n=Qn(e,o.end);return t&&n?{startContainer:t[0],startOffset:t[1],endContainer:n[0],endOffset:n[1]}:null}var Nr=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ar(e,o,t){if(!o)return;let n=new Map,s=new Map,d=r=>{if(!r)return null;if(s.has(r))return s.get(r);let u=r.local.map(b=>Qn(o.localRoot,{path:b,offset:0})?.[0]).map(b=>b&&t(b)).filter(Boolean).map(b=>({node:b,parent:b.parentNode,previous:b.previousSibling,next:b.nextSibling,fragment:Nr(b)}));return s.set(r,u),u},i=r=>{let l=Sr(o.localRoot,r);if(!l)return null;let u=t(l.startContainer),b=t(l.endContainer);if(!u||!b)return null;let a={...l,startContainer:u,endContainer:b};return Zn(a)?a:null};for(let r of e){let l=r.recovery;if(!l||n.has(l))continue;let u={subject:d(l.subject),span:null,scope:null,touched:new Set};if(l.text){u.span=i(l.text.local.span),u.scope=i(l.text.local.scope);let b=u.span;if(b){let a=b.startContainer.ownerDocument.createRange();a.setStart(b.startContainer,b.startOffset),a.setEnd(b.endContainer,b.endOffset);let h=p=>{if(a.intersectsNode(p)){u.touched.add(p);for(let v of p.childNodes)h(v)}};h(a.commonAncestorContainer)}}if(l.structure){for(let b of[l.structure.localPlacement])b&&(d(b.parent),b.before.forEach(d),b.after.forEach(d));for(let b of l.structure.localOrder||[])d(b)}n.set(l,u)}o.localState={states:n,refs:s}}function Mr(e,o,t,n){let s=t.localState?.states.get(e);if(!s)return!1;let d=r=>{let l=r.node;if(!n(l)||l.parentNode!==r.parent)return!1;let u=b=>Array.prototype.indexOf.call(l.parentNode.childNodes,b);return!(r.previous&&n(r.previous)&&r.previous.parentNode===l.parentNode&&u(r.previous)>=u(l)||r.next&&n(r.next)&&r.next.parentNode===l.parentNode&&u(r.next)<=u(l))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!s.subject.length||!s.subject.every(d))return!1;if(e.text){let r=e.text.local,l=u=>u&&n(u.startContainer)&&n(u.endContainer);return l(s.span)&&l(s.scope)&&$n(s.scope,e.text.encoding)===r.text&&$n(s.span,e.text.encoding)===r.text.slice(r.start,r.end)}if(e.attribute){let r=e.attribute,l=s.subject[0].node;return(r.namespaceURI?l.getAttributeNS(r.namespaceURI,r.localName):l.getAttribute(r.qualifiedName))===o.local}let i=e.structure;if(i.localOrder){let r=-1,l=null;for(let u of i.localOrder){let b=t.localState.refs.get(u)?.[0]?.node;if(!b||!n(b)||l&&b.parentNode!==l)return!1;let a=Array.prototype.indexOf.call(b.parentNode.childNodes,b);if(a<=r)return!1;l=b.parentNode,r=a}return!0}return i.localAction==="moved"||s.subject.every(r=>Nr(r.node)===r.fragment)}var tl=1,hn=e=>!!e&&e.nodeType===1,Yo=e=>hn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function eo(e,o=null,t=null){let n=new Map,s=new Map,d=b=>{if(!o){o=new WeakMap;let a=[e];for(;a.length;){let h=a.pop();Yo(h)&&(o.set(h.content,h),a.push(h.content));for(let p=h.firstChild;p;p=p.nextSibling)p.nodeType===1&&a.push(p)}}return o.get(b)||null},i=(b,a)=>{let h=s.get(b);if(!h){h=new Map;let p=0;for(let v=b.firstChild;v;v=v.nextSibling)h.set(v,p++);s.set(b,h)}return h.get(a)},r=b=>{if(!b)return null;if(t&&t.has(b))return r(t.get(b));if(b===e)return[];let a=n.get(b);if(a!==void 0)return a;let h=b.parentNode,p=null;if(h&&h.nodeType===11){let v=d(h),O=v?r(v):null;O&&(p=O.concat(["content",i(h,b)]))}else if(h){let v=r(h);v&&(p=v.concat([i(h,b)]))}return n.set(b,p),p};return{root:e,pathOf:r,logicalParent:b=>{let a=b.parentNode;return a&&a.nodeType===11?d(a):a},indexIn:i,containerPath:b=>{if(b.nodeType===11){let h=d(b),p=r(h);return p?p.concat(["content"]):null}let a=r(b);return a&&Yo(b)?a.concat(["content"]):a},ownerOf:d}}var Cn=e=>Yo(e)?e.content:e;function Or(e){let{L:o,R:t,unitsOf:n,provenance:s,policy:d}=e,i=[];return{note:(b,a)=>{i.push([b,a])},finish:b=>i.length?u(b):null};function u(b){let a={base:eo(e.roots.base),local:eo(e.roots.local),remote:eo(e.roots.remote)},h=M=>M==="local"?o:t,p=(M,R)=>{if(!R)return null;if(M.map.has(R))return M.map.get(R);let z=[],J=hn(R)?a.base.logicalParent(R):R.parent;for(;J&&!M.map.has(J);J=a.base.logicalParent(J))z.push(J);if(!J||!M.identical.has(J))return null;let ne=M.map.get(J);for(let je=z.length-1;je>=0&≠je--)ne=Cn(ne).childNodes[a.base.indexIn(z[je].parentNode,z[je])];return ne?hn(R)?Cn(ne).childNodes[a.base.indexIn(R.parentNode,R)]||null:n(ne)[n(R.parent).indexOf(R)]||null:null},v=new Map,O=new Map,m=new WeakMap,c=0,g=(M,R)=>{let z=v.get(M);z||v.set(M,z=[]),z.push(R)};(function M(R){O.set(R,c++);let z=s.get(R);if(z&&!z.pinned){for(let J of[z.base,z.local,z.remote])if(J)if(Array.isArray(J))for(let ne of J)g(ne,R);else g(J,R)}if(Yo(R)){m.set(R.content,R);for(let J=R.content.firstChild;J;J=J.nextSibling)M(J)}for(let J=R.firstChild;J;J=J.nextSibling)M(J)})(b);let P=new Map;a.out=eo(b,m,P);let T={refs:new Map,spans:new Map,anchors:new Map,via:P,outOwners:m,outRoot:b,localRoot:e.roots.local},x=M=>hn(M)?[M]:M.nodes,A=(M,R)=>{let z=a[R].logicalParent(M);if(!z)return null;for(let J of n(z))if(!hn(J)&&J.nodes.includes(M))return J;return null},E=(M,R)=>M==null?null:Array.isArray(M)?M.length?A(M[0],R):null:M,S=M=>{let R=new Set,z=[];for(let J of M)for(let ne of v.get(J)||[])R.has(ne)||(R.add(ne),z.push(ne));return z.sort((J,ne)=>O.get(J)-O.get(ne))},N=new Map,C=M=>{let R=M.b||M.l||M.r,z=N.get(R);if(z)return z;let J=[];for(let ne of[M.b,M.l,M.r])ne&&J.push(...x(ne));return z=S(J),N.set(R,z),z},j=M=>({b:M,l:p(o,M),r:p(t,M)}),D=(M,R)=>{let z=h(R).reverse.get(M);if(z)return j(z);for(let J of S(x(M))){let ne=s.get(J);if(ne&&!ne.base&&ne.local&&ne.remote)return{b:null,l:E(ne.local,"local"),r:E(ne.remote,"remote")}}return R==="local"?{b:null,l:M,r:null}:{b:null,l:null,r:M}},B=new Map,w=M=>{let R=s.get(M);if(!R||R.pinned)return null;let z=E(R.base,"base");if(z)return j(z);let J=E(R.local,"local"),ne=E(R.remote,"remote");if(J){let je=o.reverse.get(J);if(je)return j(je)}if(ne){let je=t.reverse.get(ne);if(je)return j(je)}return J||ne?{b:null,l:J,r:ne}:null},y=M=>(B.has(M)||B.set(M,w(M)),B.get(M)),$=(M,R)=>hn(M)?a[R].logicalParent(M):M.parent,U=new Map,V=new Map,Ne=(M,R)=>(hn(M)?[a[R].pathOf(M)]:M.nodes.map(z=>a[R].pathOf(z))).filter(Boolean),Ae=M=>{let R=M.b||M.l||M.r,z=M.b?"base":M.l?"local":"remote",J=V.get(R);if(J)return J;let ne=!hn(R),je=Ne(R,z)[0],Q=`${z[0]}:${JSON.stringify(je===void 0?null:je)}${ne?":run":""}`,Oe=U.get(Q);if(Oe)return V.set(R,Oe),Oe;let Ve=C(M);return Oe={key:Q,nodeType:hn(R)?1:R.kind==="comment"?8:3,base:M.b?Ne(M.b,"base"):[],local:M.l?Ne(M.l,"local"):[],remote:M.r?Ne(M.r,"remote"):[],merged:Ve.map(Ce=>a.out.pathOf(Ce)).filter(Boolean),live:[]},U.set(Q,Oe),V.set(R,Oe),T.refs.set(Oe,Ve),Oe},De={base:new Map,local:new Map,remote:new Map},oe=new Map,xe=(M,R)=>{let z=$(M,R);if(!z||z.nodeType!==1)return null;let J=De[R].get(z);if(!J){let je=n(z),Q=Oe=>Ae(R==="base"?j(Oe):D(Oe,R));J={parent:Q(z),refs:je.map(Q),index:new Map(je.map((Oe,Ve)=>[Oe,Ve]))},De[R].set(z,J)}let ne=J.index.get(M)??-1;return{parent:J.parent,before:J.refs.slice(ne+1),after:J.refs.slice(0,Math.max(0,ne)).reverse()}},$e=M=>{let R=M.parentNode;if(!R)return null;let z=oe.get(R);if(!z){let ne=R.nodeType===11?m.get(R):R,je=ne&&ne.nodeType===1?y(ne):null;if(!je)return null;let Q=[],Oe=[],Ve=new Map;for(let be of R.childNodes){let H=y(be),X=H&&Ae(H),de=Q.length,pe=Q.length-1;X&&X!==Q[pe]&&(Q.push(X),pe++);let se={ref:X,group:pe,after:de};Oe.push(se),Ve.set(be,se)}let Ce=Q.length;for(let be=Oe.length-1;be>=0;be--){let H=Oe[be];H.before=Ce,H.ref&&(Ce=H.group)}z={parent:Ae(je),refs:Q,index:Ve},oe.set(R,z)}let J=z.index.get(M);return{parent:z.parent,before:z.refs.slice(J.before),after:z.refs.slice(0,J.after).reverse()}},ae=M=>hn(M)?M.outerHTML:M.value,k=M=>hn(M)?"element":M.kind==="comment"?"comment":"text",_=(M,R)=>({path:M,offset:R}),re=(M,R,z)=>{if(!M)return null;let J=a[z],ne=0;if(R){let je=hn(R)?R:R.nodes[R.nodes.length-1];je.parentNode&&(ne=J.indexIn(je.parentNode,je)+1)}return _(J.containerPath(M),ne)},Z=(M,R)=>{let z=$(M,"base"),J=z?p(h(R),z):null;if(!hn(J))return null;let ne=n(z),je=null;for(let Q=ne.indexOf(M)-1;Q>=0&&!je;Q--){let Oe=p(h(R),ne[Q]);Oe&&$(Oe,R)===J&&(je=Oe)}return re(J,je,R)},Be=(M,R,z,J)=>{let ne=a[J],je=0;for(let Q=0;Q<M.nodes.length;Q++){let Oe=M.nodes[Q],Ve=Oe.nodeValue.length,Ce=Q===M.nodes.length-1;if((z==="start"?R<je+Ve:R<=je+Ve)||Ce)return _(ne.pathOf(Oe),Math.max(0,Math.min(R-je,Ve)));je+=Ve}return null},Ke=(M,R)=>{let z=a[R],J=M.firstChild,ne=M.lastChild;return J&&J.nodeType===3&&ne.nodeType===3?{start:_(z.pathOf(J),0),end:_(z.pathOf(ne),ne.nodeValue.length)}:{start:_(z.pathOf(M),0),end:_(z.pathOf(M),M.childNodes.length)}},Te=(M,R,z)=>{for(let Q of M.nodes)if(z==="start"?Q.s<=R&&R<Q.e:Q.s<R&&R<=Q.e)return{kind:"text",node:Q.node,offset:R-Q.s};let J=z==="start"?R:R-1,ne=()=>{for(let Q of M.nodes)if(Q.s===R||Q.e===R)return{kind:"text",node:Q.node,offset:R-Q.s};return null},je=M.atomAt.get(J);if(je)return{kind:z==="start"?"before":"after",node:je.el};if(M.text[J]===Nt){let Q=M.marks.find(Ve=>Ve.block&&Ve.to===J+1);if(Q)return z==="start"?{kind:"end",node:Q.el}:{kind:"after",node:Q.el};let Oe=M.marks.find(Ve=>Ve.block&&Ve.from===J+1);if(Oe)return z==="start"?{kind:"before",node:Oe.el}:{kind:"startOf",node:Oe.el}}return ne()},it=(M,R)=>Te(M,R,"end")||Te(M,R,"start"),et=(M,R)=>{switch(R.kind){case"text":return _(M.pathOf(R.node),R.offset);case"end":return _(M.containerPath(R.node),Cn(R.node).childNodes.length);case"startOf":return _(M.containerPath(R.node),0);default:{let z=R.node.parentNode;return _(M.containerPath(z),M.indexIn(z,R.node)+(R.kind==="after"?1:0))}}},mt=(M,R,z,J,ne)=>{let je=Te(M,R,z);return je?et(a[J],je):ne()},Ze=(M,R,z,J)=>{let ne=M.textNodes.map(Ce=>({s:Ce.ms,e:Ce.me,start:{kind:"text",node:Ce.node,offset:0},end:{kind:"text",node:Ce.node,offset:Ce.me-Ce.ms}}));for(let[Ce,be]of M.atomOut)ne.push({s:Ce,e:Ce+1,start:{kind:"before",node:be},end:{kind:"after",node:be}});for(let[Ce,be]of M.breakOut)ne.push({s:Ce,e:Ce+1,start:{kind:"end",node:be},end:{kind:"after",node:be}});for(let Ce of ne)if(Ce.start.kind==="text"&&Ce.s<R&&R<Ce.e)return{kind:"text",node:Ce.start.node,offset:R-Ce.s};if(z!=="empty"){let Ce=ne.find(be=>z==="start"?be.s===R:be.e===R);if(Ce)return z==="start"?Ce.start:Ce.end}let je=ne.find(Ce=>Ce.e===R);if(je)return je.end;let Q=ne.find(Ce=>Ce.s===R);if(Q)return Q.start;let Oe=null,Ve=null;for(let Ce of ne)Ce.e<=R&&(!Oe||Ce.e>Oe.e)&&(Oe=Ce),Ce.s>=R&&(!Ve||Ce.s<Ve.s)&&(Ve=Ce);return Oe?Oe.end:Ve?Ve.start:J()},ft=(M,R)=>{if(!R)return null;if(R.kind==="text"){let ne=M.nodes.find(je=>je.node===R.node);return ne?ne.s+Math.min(R.offset,ne.e-ne.s):null}let z=M.atoms.find(ne=>ne.el===R.node);if(z)return R.kind==="after"?z.i+1:z.i;let J=M.marks.find(ne=>ne.el===R.node);return J?R.kind==="before"&&J.block&&M.text[J.from-1]===Nt&&!M.marks.some(ne=>ne.block&&ne.to===J.from)?J.from-1:R.kind==="startOf"||R.kind==="before"?J.from:R.kind==="end"&&J.block?J.to-1:J.to:null},Ct=(M,R,z,J)=>{for(let Oe of M.nodes)if(z==="start"?Oe.s<=R&&R<Oe.e:Oe.s<R&&R<=Oe.e)return{kind:"text",node:Oe.node,offset:R-Oe.s};let ne=z==="start"?R:R-1;if(!M.atomAt.has(ne)&&M.text[ne]!==Nt){for(let Oe of M.nodes)if(Oe.s===R||Oe.e===R)return{kind:"text",node:Oe.node,offset:R-Oe.s}}let je=M.atomAt.get(ne);if(je)return{kind:z==="start"?"before":"after",node:je.el};if(M.text[ne]===Nt){let Oe=M.marks.find(Ce=>Ce.block&&Ce.to===ne+1);if(Oe)return z==="start"?{kind:"end",node:Oe.el}:{kind:"after",node:Oe.el};let Ve=M.marks.find(Ce=>Ce.block&&Ce.from===ne+1);if(Ve)return z==="start"?{kind:"before",node:Ve.el}:{kind:"startOf",node:Ve.el}}let Q=M.marks.find(Oe=>Oe.block&&Oe.from===R);return Q?{kind:"startOf",node:Q.el}:J?{kind:z==="start"?"startOf":"end",node:J}:null},Dt=M=>{if(!M)return null;if(M.kind==="wholeStart"||M.kind==="wholeEnd"){let R=Tt(M.node);return M.kind==="wholeStart"?R.start:R.end}return et(a.out,M)},Tt=M=>{let R=M.firstChild,z=M.lastChild;return R&&R.nodeType===3&&z.nodeType===3?{start:_(a.out.pathOf(R),0),end:_(a.out.pathOf(z),z.nodeValue.length)}:{start:_(a.out.pathOf(M),0),end:_(a.out.pathOf(M),M.childNodes.length)}},Rt=M=>{let R=$(M,"base"),z=R?C(j(R))[0]:null;if(!z)return null;let J=Cn(z),ne=n(R);for(let je=ne.indexOf(M)-1;je>=0;je--){let Q=C(j(ne[je])).filter(Oe=>Oe.parentNode===J);if(Q.length)return{kind:"after",node:Q[Q.length-1]}}return{kind:"startOf",node:z}},jt=(M,R,z,J,ne,je)=>({text:M,start:R,end:z,fragment:J,span:ne,scope:je}),qt=(M,R,z,J,ne)=>jt(M,R,z,M.slice(R,z),J,ne),un=(M,R,z,J,ne)=>(T.spans.set(M,{start:R,end:z,scopeStart:J,scopeEnd:ne}),M),Lt=new Map,Jt=new Map,F=(M,R,z)=>{let J=`text:${M.key}:${R}:${z}`,ne=Jt.get(J)||0;return Jt.set(J,ne+1),`${J}:${ne}`},ce=(M,R)=>{let z,J,ne,je="plain",Q,Oe,Ve,Ce,be,H=(pe,se,ke,fe,G)=>{if(!pe){let ue=Z(G,fe);return qt("",0,0,{start:ue,end:ue},{start:ue,end:ue})}return qt(pe.value,se,ke,{start:Be(pe,se,se===ke?"end":"start",fe),end:Be(pe,ke,"end",fe)},{start:Be(pe,0,"start",fe),end:Be(pe,pe.value.length,"end",fe)})};if(R.site==="run"){let{bRun:pe,lRun:se,rRun:ke,node:fe,c:G}=R;z=j(pe),J=G.bs,ne=G.be,Q=H(pe,G.bs,G.be,"base",pe),Oe=H(se,G.ls,G.le,"local",pe),Ve=H(ke,G.rs,G.re,"remote",pe);let ue=fe?fe.nodeValue:"",Ie=Pe=>fe?{kind:"text",node:fe,offset:Pe}:Rt(pe);Ce=un(qt(ue,G.ms,G.me,{start:Dt(Ie(G.ms)),end:Dt(Ie(G.me))},{start:Dt(Ie(0)),end:Dt(Ie(ue.length))}),Ie(G.ms),Ie(G.me),Ie(0),Ie(ue.length)),be=fe||(Rt(pe)||{}).node||null}else if(R.site==="whole"){let pe=R.el,se=s.get(pe);z=j(se.base),J=0,ne=M.base.length;let ke=(G,ue,Ie)=>{let Pe=Ke(ue,Ie);return qt(G,0,G.length,Pe,Pe)};Q=ke(M.base,se.base,"base"),Oe=ke(M.local,se.local,"local"),Ve=ke(M.remote,se.remote,"remote");let fe=Tt(pe);Ce=un(qt(M.resolved,0,M.resolved.length,fe,fe),{kind:"wholeStart",node:pe},{kind:"wholeEnd",node:pe},{kind:"wholeStart",node:pe},{kind:"wholeEnd",node:pe}),be=pe}else if(R.site==="comment"){let{bRun:pe,lRun:se,rRun:ke,node:fe}=R;z=j(pe),J=0,ne=M.base.length;let G=(He,Se)=>{if(!He){let ot=Z(pe,Se);return qt("",0,0,{start:ot,end:ot},{start:ot,end:ot})}let Je=He.nodes[0],nt={start:_(a[Se].pathOf(Je),0),end:_(a[Se].pathOf(Je),He.value.length)};return qt(He.value,0,He.value.length,nt,nt)};Q=G(pe,"base"),Oe=G(se,"local"),Ve=G(ke,"remote");let ue=M.resolved,Ie=He=>fe?{kind:"text",node:fe,offset:He}:Rt(pe),Pe={start:Dt(Ie(0)),end:Dt(Ie(ue.length))};Ce=un(qt(ue,0,ue.length,Pe,Pe),Ie(0),Ie(ue.length),Ie(0),Ie(ue.length)),be=fe||(Rt(pe)||{}).node||null}else{let{fb:pe,fl:se,fr:ke,scope:fe}=R,G=R.merged;je="html",z=fe.base?j(fe.base):D(fe.local,"local"),J=M.bs,ne=M.be;let ue=ee=>{let Ee=fe[ee];for(let Ue=fe.at-1;Ue>=0;Ue--){let _e=fe.units[Ue],Ye=ee==="base"?_e:p(h(ee),_e);if(Ye&&$(Ye,ee)===Ee)return Ye}return null},Ie=ee=>()=>re(fe[ee],ue(ee),ee),Pe=(ee,Ee,Ue,_e,Ye)=>{let yt=pn=>pn?et(a[Ye],pn):Ie(Ye)(),gt=Ee===Ue?it(ee,Ee):Te(ee,Ee,"start"),$t=Ee===Ue?it(ee,Ee):Te(ee,Ue,"end"),_t=yt(gt),dn={start:_t,end:Ee===Ue?_t:yt($t)},vt=R.full?R.full(Ye):null;if(!vt)return jt(ee.text,Ee,Ue,_e,dn,{start:yt(Te(ee,0,"start")),end:yt(Te(ee,ee.text.length,"end"))});let dt=gt?ft(vt,gt):null,Qe=$t?ft(vt,$t):null,Mt=dt===null?0:dt,bt=Math.max(Mt,Qe===null?vt.text.length:Qe),Ht=yt(Te(vt,0,"start"));return jt(vt.text,Mt,bt,lo(vt,Mt,bt),dn,{start:Ht,end:vt.text.length?yt(Te(vt,vt.text.length,"end")):Ht})};Q=R.synthetic?null:Pe(pe,M.bs,M.be,M.base,"base"),Oe=Pe(se,M.lss,M.lse,M.local,"local"),Ve=Pe(ke,M.rss,M.rse,M.remote,"remote");let[He,Se]=M.range||[0,0],Je=G.out,nt=()=>{let ee=Cn(G.node);for(let Ee=fe.at-1;Ee>=0;Ee--){let Ue=C(j(fe.units[Ee])).filter(_e=>_e.parentNode===ee);if(Ue.length)return{kind:"after",node:Ue[Ue.length-1]}}for(let Ee=fe.at;Ee<fe.units.length;Ee++){let Ue=C(j(fe.units[Ee])).filter(_e=>_e.parentNode===ee);if(Ue.length)return{kind:"before",node:Ue[0]}}return{kind:"startOf",node:G.node}};if(Je.via)for(let[ee,Ee]of Je.via)P.set(ee,Ee);let ot=Ze(G,He,He===Se?"empty":"start",nt),Wt=He===Se?ot:Ze(G,Se,"end",nt),Ut=Je.text.length?Ct(Je,0,"start",G.node):nt(),I=Je.text.length?Ct(Je,Je.text.length,"end",G.node):Ut,q=ft(Je,ot),te=ft(Je,Wt),me=q===null?0:q,we=Math.max(me,te===null?Je.text.length:te);Ce=un(jt(Je.text,me,we,lo(Je,me,we),{start:Dt(ot),end:Dt(Wt)},{start:Dt(Ut),end:Dt(I)}),ot,Wt,Ut,I);let ie=T.spans.get(Ce);if(ie.flat=Je,!Je.text.length){let ee=Dt(Ut),Ee=Qn(b,ee),Ue=Ee[0],_e=Ee[1];ie.empty={parent:Ue.nodeType===11?m.get(Ue):Ue,previous:Ue.childNodes[_e-1]||null,next:Ue.childNodes[_e]||null}}be=ot?ot.node:G.node}let X=Ae(z),de=(R.site==="whole"||R.site==="comment"||(R.policy||d)!=="both")&&M.resolved!==M.local;return{key:R.site==="comment"&&Lt.get(z.b||z.l||z.r)||F(X,J,ne),subject:X,localLost:de,anchor:be,text:{encoding:je,base:Q,local:Oe,remote:Ve,merged:Ce,liveSpan:null,liveScope:null}}},ge=(M,R)=>{let z=y(R.el),J=Ae(z),ne=R.sample;return{key:`attr:${J.key}:${ne.namespaceURI||""}:${ne.localName}`,subject:J,localLost:M.resolved!==M.local,anchor:R.el,attribute:{namespaceURI:ne.namespaceURI||null,localName:ne.localName,qualifiedName:ne.name}}},Le=(M,R)=>{let z=M.detail,J=R.unit||j(R.subject),ne=Ae(J),je=T.refs.get(ne),Q=J.l?xe(J.l,"local"):null,Oe=J.r?xe(J.r,"remote"):null,Ve=je.length?$e(je[0]):null,Ce,be,H,X=null,de=null,pe=R.deleted;switch(z){case"both-reordered":{Ce=be="reordered";let se=new Set(R.rKept),ke=R.lKept.filter(Pe=>se.has(Pe)&&C(j(Pe)).length),fe=Pe=>O.get(C(j(Pe))[0]);X=ke.map(Pe=>Ae(j(Pe))),de=ke.slice().sort((Pe,He)=>fe(Pe)-fe(He)).map(Pe=>Ae(j(Pe)));let G=Pe=>!hn(Pe)&&Pe.kind!=="comment"&&Pe.nodes.every(He=>!/[^\t\n\f\r ]/.test(He.data)),ue=ke.filter(Pe=>!G(Pe)),Ie=ue.slice().sort((Pe,He)=>fe(Pe)-fe(He));H=ue.some((Pe,He)=>Pe!==Ie[He]);break}case"both-moved":Ce=be="moved",H=!Q||!je.some(se=>{let ke=se===je[0]?Ve:$e(se);return ke&&ke.parent===Q.parent});break;case"edit-beats-delete":Ce=pe==="local"?"deleted":"edited",be=pe==="remote"?"deleted":"edited",H=pe==="local";break;case"move-beats-delete":Ce=pe==="local"?"deleted":"moved",be=pe==="remote"?"deleted":"moved",H=pe==="local";break;case"remote-wins":Ce="edited",be="edited",H=!0;break;default:Ce=be="inserted",H=R.localLost}return{key:`structure:${ne.key}:${z}`,subject:ne,localLost:H,anchor:je[0]||null,structure:{localAction:Ce,remoteAction:be,localPlacement:Q,remotePlacement:Oe,mergedPlacement:Ve,localOrder:X,mergedOrder:de,localFragment:z==="both-reordered"||!J.l?null:ae(J.l),fragmentKind:k(J.b||J.l||J.r)}}};for(let[M,R]of i){if(M.kind!=="structure")continue;let z=R.unit||j(R.subject),J=z.b||z.l||z.r;!hn(J)&&J.kind==="comment"&&Lt.set(J,`structure:${Ae(z).key}:${M.detail}`)}let Me=new Map;for(let[M,R]of i){if(M.kind==="structure"){let je=Ae(R.unit||j(R.subject)),Q=`structure:${je.key}:${M.detail}`,Oe=Me.get(Q);if(Oe&&Oe.structure){M.recovery=Oe;let Ve=T.refs.get(je);M.el==null&&Ve.length&&(M.el=hn(Ve[0])?Ve[0]:a.out.logicalParent(Ve[0]));continue}}let z=M.kind==="text"?ce(M,R):M.kind==="attr"?ge(M,R):Le(M,R),J=Me.get(z.key);J||(J={version:tl,key:z.key,localLost:z.localLost,subject:z.subject,applied:!1,unavailable:null},Me.set(z.key,J),T.anchors.set(J,z.anchor)),z.text&&(J.text=z.text),z.attribute&&(J.attribute=z.attribute),z.structure&&(J.structure=z.structure),z.text&&(J.localLost=z.localLost),M.recovery=J;let ne=T.refs.get(z.subject);M.kind==="structure"&&M.el==null&&ne.length&&(M.el=hn(ne[0])?ne[0]:a.out.logicalParent(ne[0])),M.kind==="text"&&M.node==null&&ne.length&&z.subject.nodeType===8&&(M.node=ne[0])}return T}}function Ir(e,o,t){if(!o)return;let{lookup:n,vetoed:s,vetoedAttrs:d,liveAttr:i}=t,r=t.ignored||(()=>!1),l=eo(t.liveRoot),u=w=>!!w&&l.containerPath(w)!==null,b=w=>{let y=w.parentNode;return y&&y.nodeType===11?o.outOwners.get(y)||null:y},a=w=>{for(let y=w;y;y=b(y))if(o.via.has(y)&&(y=o.via.get(y)),s.has(y)||t.vetoedLive?.has(c(y)))return!0;return!1},h=w=>Array.from(Cn(w).children).filter(y=>!r(y)),p=(w,y)=>h(w)[h(y.parentNode).indexOf(y)],v=(w,y)=>{let $=null,U=null,V=0;for(let oe=y.previousSibling;oe;oe=oe.previousSibling){if(oe.nodeType===1&&!r(oe)){$=oe;break}oe.nodeType===3&&(V+=oe.nodeValue.length)}for(let oe=y.nextSibling;oe&&!U;oe=oe.nextSibling)oe.nodeType===1&&!r(oe)&&(U=oe);let Ne=$?p(w,$):null,Ae=U?p(w,U):null;if($&&!Ne||U&&!Ae)return null;let De=[];for(let oe=Ne?Ne.nextSibling:Cn(w).firstChild;oe&&oe!==Ae;oe=oe.nextSibling)oe.nodeType===3&&De.push(oe);return De.length?{nodes:De,lead:V}:null},O=w=>{let y=[],$=w;for(;$&&!o.via.has($);$=$.parentNode)y.push($);if(!$||!y.length)return null;let U=c(o.via.get($));for(let Ae=y.length-1;Ae>0&&U;Ae--)U=p(U,y[Ae]);if(!U)return null;let V=y[0];if(V.nodeType===3)return v(U,V);let Ne=V.nodeType===1?p(U,V):null;return Ne?{nodes:[Ne],lead:0}:null},m=w=>{let y=n(w),$=y?{nodes:Array.isArray(y)?y:[y],lead:0}:o.via.size?O(w):null;if(!$)return null;let U=$.nodes.filter(u);return U.length?{nodes:U,lead:$.lead}:null},c=w=>{let y=m(w);return y?y.nodes[0]:null},g=w=>{if(!w)return null;if(w.kind==="text"){let V=m(w.node);if(!V)return null;let Ne=V.nodes,Ae=w.offset+V.lead,De=0;for(let oe=0;oe<Ne.length;oe++){let xe=Ne[oe].nodeValue.length;if(Ae<=De+xe||oe===Ne.length-1)return Ae>=De&&Ae<=De+xe?[Ne[oe],Ae-De]:null;De+=xe}return null}let y=c(w.node);if(!y)return null;if(w.kind==="end")return[Cn(y),Cn(y).childNodes.length];if(w.kind==="startOf")return[Cn(y),0];if(w.kind==="wholeStart")return y.firstChild?[y.firstChild,0]:[y,0];if(w.kind==="wholeEnd")return y.lastChild?[y.lastChild,y.lastChild.nodeValue.length]:[y,y.childNodes.length];let $=y.parentNode;if(!$)return null;let U=Array.prototype.indexOf.call($.childNodes,y);return[$,w.kind==="after"?U+1:U]},P=w=>({blocks:new Set((w.flat?.marks||[]).filter(y=>y.block).map(y=>c(y.el)).filter(Boolean)),atoms:new Set((w.flat?.atoms||[]).map(y=>c(y.el)).filter(Boolean)),ignored:r}),T=(w,y,$,U)=>{if(!w||!y||!Zn(w)||!Zn(y))return!1;for(let Ae of[w,y])if(!u(Ae.startContainer)||!u(Ae.endContainer))return!1;let V=$.merged;if(V.start===V.end&&(w.startContainer!==w.endContainer||w.startOffset!==w.endOffset))return!1;let Ne=P(U);return $n(y,$.encoding,Ne)===V.text&&$n(w,$.encoding,Ne)===V.text.slice(V.start,V.end)},x=new Map,A=w=>{let y=w.parentNode;return y?(x.has(y)||x.set(y,new Map(Array.from(y.childNodes,($,U)=>[$,U]))),x.get(y).get(w)):-1},E=(w,y)=>{if(!y)return!1;let $=l.logicalParent(w);if(!y.parent.live.includes($))return!1;let U=A(w);for(let[V,Ne]of[["before",1],["after",-1]]){let Ae=U;for(let De of y[V]){if(De.live.includes(w))continue;let oe=De.live.filter($e=>$e!==w&&$e.parentNode===w.parentNode);if(!oe.length)continue;let xe=Ne===1?Math.min(...oe.map(A)):Math.max(...oe.map(A));if(Ne*(xe-Ae)<=0)return!1;Ae=xe}}return!0},S=w=>{let y=w.structure;if(y.mergedOrder){let $=new Set(w.subject.live.map(Cn)),U=null,V=-1;for(let Ne of y.mergedOrder){let Ae=Ne.live.find(De=>$.has(De.parentNode));if(!Ae||U&&Ae.parentNode!==U||A(Ae)<=V)return!1;U=Ae.parentNode,V=A(Ae)}return w.subject.live.length>0}return w.subject.live.some($=>E($,y.mergedPlacement))},N=(w,y)=>{let $=g(w),U=g(y);return $&&U?{startContainer:$[0],startOffset:$[1],endContainer:U[0],endOffset:U[1]}:null},C=new Set,j=w=>{if(!w||C.has(w))return;C.add(w);let y=[];for(let $ of o.refs.get(w)||[]){let U=m($);if(U)for(let V of U.nodes)y.includes(V)||y.push(V)}w.live=y},D=w=>{w&&(j(w.parent),w.before.forEach(j),w.after.forEach(j))},B=new Set;for(let w of e){let y=w.recovery;if(!y||B.has(y))continue;B.add(y),j(y.subject),y.structure&&(D(y.structure.localPlacement),D(y.structure.remotePlacement),D(y.structure.mergedPlacement),(y.structure.localOrder||[]).forEach(j),(y.structure.mergedOrder||[]).forEach(j));let $=o.anchors.get(y),U=$?c($):null,V=!!U;if(y.text){let k=o.spans.get(y.text.merged),_=k?N(k.start,k.end):null,re=k?N(k.scopeStart,k.scopeEnd):null;if(k?.empty){let Z=k.empty,Be=Z.previous?{kind:"after",node:Z.previous}:{kind:"startOf",node:Z.parent},Ke=Z.next?{kind:"before",node:Z.next}:{kind:"end",node:Z.parent},Te=N(Be,Ke);!Te||Te.startContainer!==Te.endContainer||Te.startOffset!==Te.endOffset?_=null:_=re=Te}T(_,re,y.text,k)||(_=re=null),y.text.liveSpan=_,y.text.liveScope=_?re:null,_||(V=!1)}y.structure&&V&&(V=S(y)),y.attribute&&V&&(V=i(U,y.attribute,w.resolved));let Ne=(!!y.attribute||!!y.text&&U?.tagName==="TEXTAREA")&&!!d&&[$,U].some(k=>d.get(k)?.has(y.attribute?y.attribute.qualifiedName:"value")),Ae=o.localState?.states.get(y),De=!!y.text&&[...t.removedVetoes||[]].some(k=>Ae?.touched.has(k)),oe=y.structure?.localAction==="inserted"&&[...s].some(k=>k===$||$?.contains(k)),xe=$&&a($)||Ne||De||oe,$e=xe&&Mr(y,w,o,u);$e&&(De||oe&&y.localLost)&&(V=!1);let ae=!V&&$e&&xe;y.applied=V,y.unavailable=V?null:ae?"hook-veto":"missing-output",ae&&(y.localLost=!1),!V&&y.text&&(y.text.liveSpan=y.text.liveScope=null)}}function Xo(e,o,t){let n=eo(o),s=eo(t),d=a=>!!a&&s.containerPath(a)!==null,i=a=>{if(a===o)return t;let h=n.pathOf(a);if(h&&o!==t){let p=Qn(t,{path:h,offset:0});if(p&&p[0].nodeType===a.nodeType)return p[0]}return a},r=new Set,l=a=>{!a||r.has(a)||(r.add(a),a.live=a.live.map(i).filter(d))},u=a=>{a&&(a.startContainer=i(a.startContainer),a.endContainer=i(a.endContainer))},b=new Set;for(let a of e){a.node===o&&t.tagName==="SCRIPT"&&(a.node=t),a.el===o&&a.kind==="structure"&&(a.el=t);let h=a.recovery;if(!h||b.has(h))continue;if(b.add(h),l(h.subject),h.text){u(h.text.liveSpan),u(h.text.liveScope);let v=h.text.liveSpan,O=h.text.liveScope,m=h.text.merged,c=g=>!!g&&Zn(g)&&d(g.startContainer)&&d(g.endContainer);(!c(v)||!c(O)||$n(O,h.text.encoding)!==m.text||$n(v,h.text.encoding)!==m.text.slice(m.start,m.end))&&(h.text.liveSpan=null,h.text.liveScope=null,h.applied=!1,h.unavailable="missing-output")}let p=h.structure;if(p){for(let v of[p.localPlacement,p.remotePlacement,p.mergedPlacement])v&&(l(v.parent),v.before.forEach(l),v.after.forEach(l));(p.localOrder||[]).forEach(l),(p.mergedOrder||[]).forEach(l),h.subject.live.length||(h.applied=!1,h.unavailable="missing-output")}}}var ho=e=>e?.nodeType===1,Oo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function nl({provenance:e,parentOf:o,twins:t,baseOf:n,build:s,ignored:d,remoteWins:i,discarded:r}){let l=new Map,u=new WeakMap;function b(p,v,O,m=!1){if(!ho(p)||!ho(O))return null;let c=l.get(p);if(c)(m||!c.selected&&v==="remote")&&(c.parent=o(O),c.port=O,c.sourceSide=v,c.selected=m);else{let g=u.get(p)||null;c={owner:p,parent:o(O),port:O,sourceSide:v,originalParent:o(p),originalPort:p,selected:m,state:g?"built":"planned",output:g,disposition:null},l.set(p,c)}return c}function a(p,v){if(!ho(p)||!ho(v))return;u.has(p)||u.set(p,v);let O=l.get(p);O&&O.state!=="attached"&&!O.output&&(O.output=v,O.state="built")}function h(p){if(!l.size)return;let v=new Map,O=new WeakMap,m=new WeakMap,c=new WeakSet,g=new Set,P=(D,B)=>{if(!D)return;if(Array.isArray(D)){for(let y of D)P(y,B);return}let w=v.get(D);w||v.set(D,w=[]),w.push(B)},T=(D,B)=>{if(!D)return;let w=[D];for(;w.length;){let y=w.pop();P(y,B);for(let $ of Oo(y).childNodes)w.push($)}};function x(D,B=null,w=!1){if(c.has(D))return;c.add(D),O.set(D,B);let y=e.get(D),$=w||!!(y&&i(y.remote||y.base));m.set(D,$);let U={node:D,kind:"node",authority:$};if(y?.pinned)T(y.local,{...U,kind:"ignored"});else if(y?.unchanged)for(let V of[y.base,y.local,y.remote])T(V,{...U,kind:"unchanged"});else if(y){for(let V of[y.base,y.local,y.remote])P(V,U);if(ho(y.local))for(let V of Oo(y.local).children)d(V)&&T(V,{...U,kind:"ignored"})}for(let V of Oo(D).childNodes)x(V,D,$)}let A=D=>{if(D.output&&c.has(D.output))return D.state="attached",D.disposition="node",!0;let{local:B,remote:w}=t(D.owner);for(let y of[D.owner,B,w]){let $=v.get(y);if($?.length){let U=$.find(V=>V.kind==="node")||$[0];return D.output=U.node,D.state="attached",D.disposition=U.kind,!0}}return!1},E=(D,B)=>(v.get(D)||[]).find(y=>y.kind==="node"&&ho(y.node)&&(!y.authority||B.sourceSide==="remote"))?.node,S=(D,B,w)=>{let y=v.get(D)||[],$=w?[...y].reverse():y;for(let U of $){if(U.kind!=="node")continue;let V=U.node;for(;V&&O.get(V)!==B;)V=O.get(V);if(V)return V}return null},N=(D,B,w)=>{let y=Oo(B);for(let $=w?.previousSibling;$;$=$.previousSibling){let U=S($,B,!0);if(U){y.insertBefore(D,U.nextSibling);return}}for(let $=w?.nextSibling;$;$=$.nextSibling){let U=S($,B,!1);if(U){y.insertBefore(D,U);return}}y.appendChild(D)};function C(D,B,w){let y=B==="base"?D:n(D,B),$=l.get(y);$&&$!==w&&j($)}function j(D){if(D.state==="attached"||D.disposition==="remote-wins"||g.has(D)||A(D))return;g.add(D);let{local:B,remote:w}=t(D.owner);if(i(w||D.owner)){if(!w){D.disposition="remote-wins",r(D.owner,B),g.delete(D);return}D.parent=o(w),D.port=w,D.sourceSide="remote"}if(C(D.parent,D.sourceSide,D),A(D)){g.delete(D);return}let y=E(D.parent,D),$=D.port;if(!y){if(C(D.originalParent,"base",D),A(D)){g.delete(D);return}let V=D.originalParent;for($=D.originalPort;V&&!y;)y=E(V,D),y||($=V,V=o(V))}if(!y)throw new Error("A planned move has no allowed surviving parent");let U=D.output||s(D.owner);D.output=U,D.state="built",N(U,y,$),x(U,y,m.get(y)||!1),A(D),g.delete(D)}x(p);for(let D of l.values())j(D)}return{planned:l,has:p=>l.has(p),plan:b,produced:a,drain:h}}function po(e,o,t,n,s,d,i,r,l,u,b,a,h){let p=null;return nl({provenance:e,parentOf:m=>{if(!m)return null;let c=o(m);if(c||m.parentNode?.nodeType!==11)return c;if(!p){p=new WeakMap;let g=[a,h];for(;g.length;){let P=g.pop(),T=Oo(P);T!==P&&p.set(T,P);for(let x of T.children)g.push(x)}}return p.get(m.parentNode)||null},twins:m=>({local:s(t,m),remote:s(n,m)}),baseOf:(m,c)=>m&&(c==="local"?t:n).reverse.get(m)||null,build:m=>d(m,s(t,m),s(n,m),!1),ignored:i,remoteWins:r,discarded:(m,c)=>{c&&b(m,c,t)&&!l.some(g=>g.detail==="remote-wins"&&g.base===m)&&u({kind:"structure",el:null,detail:"remote-wins",base:m,local:c,remote:null},{subject:m})}})}function ol({parent:e,base:o,views:t,eligible:n,ignored:s,remoteWins:d,budget:i=Xt(2e4*32),maxUnits:r=256,maxCharacters:l=2e4}){let u=(c,g=null)=>({status:c,reason:g,parent:e,records:[]});if(t.some(({V:c})=>c.asBase)||s(e)||d(e)||t.some(({V:c})=>!c.el||s(c.el)||d(c.el)))return u("none");let b=o.length+t[0].V.units.length+t[1].V.units.length;if(b>r)return u("fallback","unit-limit");let a=Symbol(),h=c=>{if(c>i.remaining)throw a;i.remaining-=c,i.crossParentSteps=(i.crossParentSteps||0)+c},p=new Map,v=0,O=c=>{if(h(1),p.has(c))return p.get(c);let g=c.nodeType===1?c.childNodes:c.nodes;h(g.length*4+1);let P=c.nodeType===1?Array.from(g):g,T=0;for(let E=0;E<P.length;E++){let S=P[E];if(S.nodeType!==3||E&&P[E-1].nextSibling!==S)return p.set(c,null),null;T+=S.data.length}if(T>l-v)throw a;h(T*8+1),v+=T;let x=ln(P);if(x.text.includes(Nt))return p.set(c,null),null;let A={unit:c,nodes:P,flat:x};return p.set(c,A),A},m=[];try{h(b*8+1);for(let c=0;c<2;c++){let g=t[c].V,P=t[1-c].V,T=[],x=new Map;for(let A=0;A<o.length;A++){h(1);let E=o[A];if(E.kind!=="text"||g.twin(E))continue;let S=P.twin(E);if(!S||S.kind!=="text"||!P.here(S))continue;let N=O(E),C=O(S);if(!N||!C||!/\S/.test(N.flat.text))continue;h(N.flat.text.length*2+1);let j=N.flat.text;x.set(j,(x.get(j)||0)+1),T.push({source:E,opposite:S,sourceModel:N,oppositeModel:C,index:A})}for(let A of T){let{source:E,opposite:S,sourceModel:N,oppositeModel:C,index:j}=A,D=[];for(let _ of[-1,1]){h(1);let re=o[j+_];if(!re||re.nodeType!==1||!n(re)||s(re)||d(re))continue;let Z=N.nodes[0],Be=N.nodes.at(-1);if(_===-1?Z?.previousSibling!==re:Be?.nextSibling!==re)continue;let Ke=g.twin(re),Te=P.twin(re);if(!Ke||!Te||!g.here(Ke)||P.here(Te)||g.baseOf(Ke)!==re||P.baseOf(Te)!==re||!n(Ke)||!n(Te)||s(Ke)||s(Te)||d(Ke)||d(Te)||Ke.tagName!==re.tagName||Te.tagName!==re.tagName||Ke.namespaceURI!==re.namespaceURI||Te.namespaceURI!==re.namespaceURI)continue;let it=O(re),et=O(Ke),mt=O(Te);if(!it||!et||!mt||!/\S/.test(it.flat.text))continue;let Ze=it.flat.text,ft=N.flat.text,Ct=et.flat.text;if(h((Ze.length+ft.length+Ct.length)*3+1),Ct.length!==Ze.length+ft.length)continue;let Dt=_===-1;(Dt?!Ct.startsWith(Ze)||!Ct.endsWith(ft):!Ct.startsWith(ft)||!Ct.endsWith(Ze))||D.push({owner:re,target:Ke,moved:Te,ownerBase:it,joined:et,ownerOther:mt,targetFrom:Dt?Ze.length:0,retainedFrom:Dt?0:ft.length})}if(!D.length)continue;if(D.length!==1||x.get(N.flat.text)!==1)return u("fallback","ambiguous-origin");let B=D[0],{owner:w,target:y,moved:$,ownerBase:U,joined:V,ownerOther:Ne,targetFrom:Ae,retainedFrom:De}=B;if(h(m.length+1),m.some(_=>_.owner===w))return u("fallback","ambiguous-owner");let oe={source:E,target:y,from:0,to:N.flat.text.length,targetFrom:Ae},xe=Bn({base:N.flat,side:V.flat,retained:[],transfers:[{from:oe.from,to:oe.to,target:Ae,destination:w}],budget:i});if(xe.status!=="ready"||xe.covers(oe.from,oe.to)!==!0)return u("fallback",xe.reason||"work-limit");let $e=[{unit:E,model:N,from:0,to:N.flat.text.length},null,null];$e[c+1]={unit:y,model:V,from:Ae,to:Ae+N.flat.text.length},$e[2-c]={unit:S,model:C,from:0,to:C.flat.text.length};let ae=[U,null,null];ae[c+1]=V,ae[2-c]=Ne;let k=[w,null,null];k[c+1]=y,k[2-c]=$,m.push({side:c,parent:e,source:E,target:y,owner:w,owners:k,ownerModels:ae,native:$e,models:p,runs:[oe],proof:xe,retained:[{source:w,target:y,from:0,to:U.flat.text.length,targetFrom:De}]})}}return m.length?{status:"ready",reason:null,parent:e,records:m}:u("none")}catch(c){if(c!==a)throw c;return u("fallback","work-limit")}}function Er({describe:e,parentOf:o,...t}){let n=new WeakMap,s=new WeakMap,d=t.budget||Xt(2e4*32),i=r=>{if(!r)return null;if(n.has(r))return n.get(r);n.set(r,{status:"planning",parent:r,records:[]});let l=e(r),u=l?ol({...t,...l,parent:r,budget:d}):{status:"none",reason:null,parent:r,records:[]};if(n.set(r,u),u.status==="ready")for(let b of u.records)s.set(b.owner,[b]);return u};return{get:i,forOwner(r){return i(o(r))?.status==="ready"&&s.get(r)||null}}}function sl(e,o){if(e.side!==0)return null;let t=e.native[0].model,n=e.ownerModels[0],s=e.native[1].from!==0,d=(P,T)=>s?[...P.nodes,...T.nodes]:[...T.nodes,...P.nodes],i=e.ownerModels.reduce((P,T)=>P+T.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(i*8>o.remaining)return null;o.remaining-=i*8;let r={base:d(n,t),local:e.ownerModels[1].nodes,remote:d(e.ownerModels[2],e.native[2].model)},l=ln(r.base),u=e.ownerModels[1].flat,b=ln(r.remote),a=s?n.flat.text.length:0,h=s?0:t.flat.text.length,p=Bn({base:l,side:u,retained:e.retained.map(P=>({from:h+P.from,to:h+P.to,target:P.targetFrom})),transfers:e.runs.map(P=>({from:a+P.from,to:a+P.to,target:P.targetFrom,destination:e.owner})),budget:o});if(p.status!=="ready"||p.covers(0,l.text.length)!==!0)return null;let v=e.ownerModels[2].flat,O=e.native[2].model.flat,m=[];for(let[P,T,x,A]of[[n.flat,v,h,s?0:O.text.length],[t.flat,O,a,s?v.text.length:0]]){let E=ks(P,P,T).remoteMap.bTo,S=-1;for(let N=0;N<P.text.length;N++){if(E[N]<0){S=-1;continue}let C=m.at(-1);S>=0&&C.to===x+N&&C.target+C.to-C.from===A+E[N]?C.to++:(m.push({from:x+N,to:x+N+1,target:A+E[N]}),S=N)}}let c=Bn({base:l,side:b,retained:m,transfers:[],budget:o});if(c.status!=="ready")return null;let g=ks(l,u,b,{},{local:p,remote:c});return g.localEdits.hunks.length?null:(g.localMap=p,g.remoteMap=c,{nodes:r,prepared:g})}function Cr({L:e,R:o,twinIn:t,unitsOf:n,view:s,parentOf:d,ignored:i,remoteWins:r,eligible:l,build:u,out:b,policy:a,provenance:h,textMappers:p,segments:v,conflicts:O,conflict:m,decisions:c}){let g=Xt(2e4*32),P=D=>{let B=0;for(let w=D;w;w=d(w))if(++B>64||w.nodeType===1&&(i(w)||r(w)))return!1;return!0},T=Er({parentOf:d,eligible:l,ignored:i,remoteWins:r,budget:g,describe(D){let B=t(e,D),w=t(o,D);return!B||!w||!P(D)||!P(B)||!P(w)?null:{base:n(D),views:[{A:e,V:s(e,B,D,!1)},{A:o,V:s(o,w,D,!1)}]}}}),x=new WeakSet,A=new WeakMap,E=new WeakSet,S=[];function N(D){if(!D||x.has(D))return;x.add(D);let B=T.get(D);if(B?.status==="ready")for(let w of B.records){if((D.tagName==="TEMPLATE"&&D.content?D.content:D).childNodes.length!==w.native[0].model.nodes.length+1||!w.owners.every(P))continue;let $=sl(w,g);if(!$)continue;let U={record:w,payload:$,state:"planned",output:null,result:null};A.set(w.owner,U),E.add(w.source),E.add(w.native[2].unit),S.push(U)}}function C(D,B){let w=A.get(D);if(!w)return!1;if(!w.result){if(w.result=Fo({...w.payload.nodes,prepared:w.payload.prepared,out:b,policy:a,provenance:h,textMappers:p,conflicts:O,conflict:m,decisions:c,node:B}),w.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");v.push(...w.result.segments),w.decision={kind:"text",node:B,source:"local"},c.push(w.decision)}return w.decision.node=B,B.replaceChildren(...w.result.nodes),w.output=B,w.state="built",!0}function j(D){if(!S.length)return;let B=new WeakSet,w=new WeakMap,y=new WeakMap,$=new WeakMap,U=xe=>xe.tagName==="TEMPLATE"&&xe.content?xe.content:xe,V=(xe,$e)=>{if(!xe)return;if(Array.isArray(xe)){for(let k of xe)V(k,$e);return}let ae=$.get(xe);ae||$.set(xe,ae=[]),ae.push($e)},Ne=(xe,$e=null,ae=!1)=>{B.add(xe),w.set(xe,$e);let k=h.get(xe),_=ae||!!(k&&r(k.remote||k.base));if(y.set(xe,_),k)for(let re of[k.base,k.local,k.remote])V(re,xe);if(!(k?.pinned||k?.unchanged))for(let re of U(xe).childNodes)Ne(re,xe,_)},Ae=xe=>($.get(xe)||[]).find($e=>$e.nodeType===1&&!y.get($e)&&!h.get($e)?.pinned&&!h.get($e)?.unchanged),De=(xe,$e)=>{for(let ae of $.get(xe)||[]){let k=ae;for(;k&&w.get(k)!==$e;)k=w.get(k);if(k)return k}return null},oe=(xe,$e,ae)=>{let k=U($e);for(let _=ae.nextSibling;_;_=_.nextSibling){let re=De(_,$e);if(re){k.insertBefore(xe,re);return}}for(let _=ae.previousSibling;_;_=_.previousSibling){let re=De(_,$e);if(re){k.insertBefore(xe,re.nextSibling);return}}k.appendChild(xe)};Ne(D);for(let xe of S){let{record:$e}=xe,ae=Ae($e.owner)||Ae($e.owners[1])||Ae($e.owners[2]);if(ae)(!xe.result||xe.output!==ae||xe.result.nodes.some(k=>!B.has(k)||w.get(k)!==ae)||ae.textContent!==xe.result.text)&&(C($e.owner,ae),Ne(ae,w.get(ae),y.get(ae)));else{let k=$e.parent,_=$e.owner,re=null;for(;k&&!re;)re=Ae(k),re||(_=k,k=d(k));if(!re)throw new Error("A cross-parent payload has no allowed surviving parent");ae=xe.output||u($e.owner,$e.owners[1],$e.owners[2],!1),xe.result||C($e.owner,ae),oe(ae,re,_),Ne(ae,re,y.get(re))}xe.state="attached"}}return{ensureParent:N,ensureOwner(D){N(d(D))},consumes(D){return E.has(D)},render:C,drain:j}}var An=/\S/,Lr=/[\p{L}\p{N}]/u;function to(e,o,t,n){if(e?.nodeType!==1||!o(e))return!1;for(let s=e.firstChild;s;s=s.nextSibling)if(n(t,1),s.nodeType!==3)return!1;return!!e.firstChild}function Ms(e,o,t){for(let n=e.parentNode;n;n=n.parentNode)if(t(o,1),n.nodeType===11)return!1;return!0}function Rr(e,o,t,n,s){let d=t(e,n),i=t(o,n),r=null,l=null,u=null,b=null;s(n,d.length+i.length);for(let a of d)Lr.test(a.raw)&&(r||=a,l=a);for(let a of i)Lr.test(a.raw)&&(u||=a,b=a);return!!(r&&u&&(r.raw===u.raw||l.raw===b.raw))}function rl({base:e,V:o,A:t,source:n,original:s,current:d,edited:i,destination:r,at:l,ownLength:u,eligible:b,model:a,tokensOf:h,budget:p,charge:v}){let O=s.flat.text,m=d.flat.text,c=i.flat.text,g=r.flat.text;if(v(p,O.length+m.length+g.length),O.startsWith(m)||O.endsWith(m))return!1;let P=An.test(g.slice(0,l)),T=An.test(g.slice(l+u));if(P===T)return!1;let x=P?0:l+u,A=P?l:g.length;for(;x<A&&!An.test(g[x]);)x++;for(;A>x&&!An.test(g[A-1]);)A--;let E=g.slice(x,A);if(En(E,g,h(r,p),p,v,!0)!==x)return!1;let S=En(E,O,h(s,p),p,v,!0);if(S<0)return!1;let N=S+E.length,C=!An.test(O.slice(0,S)),j=!An.test(O.slice(N));if(C===j||En(E,m,h(d,p),p,v,!1)>=0)return!1;let D=C?O.slice(N):O.slice(0,S),B=C?c.length-D.length:0;if(v(p,O.length+c.length),B<0||!An.test(D)||En(D,c,h(i,p),p,v,!0)!==B||!An.test(C?c.slice(0,B):c.slice(D.length)))return!1;for(let w of e){if(v(p,1),w===n||!to(w,b,p,v))continue;let y=a(w,null,p);if(En(E,y.flat.text,h(y,p),p,v,!1)>=0)return!1}for(let w of o.units){if(v(p,1),w===d.unit||w===r.unit||!to(w,b,p,v))continue;let y=a(w,t,p);if(En(E,y.flat.text,h(y,p),p,v,!1)>=0)return!1}return!0}function Pr({base:e,views:o,side:t,attempt:n,eligible:s,blocked:d,baseId:i,model:r,tokensOf:l,charge:u,exhausted:b,limit:a}){if(a<=0)return null;let h=Xt(a),{V:p,A:v,idOf:O}=o[t],m=o[1-t],[c,g,P,T]=n,x=null;try{for(let A=c;A<=g;A++){u(h,1);let E=e[A];if(E.parentNode?.nodeType!==1||d.has(E)||v.identical.has(E)||m.A.identical.has(E)||!to(E,s,h,u)||i(E))continue;let S=p.twin(E),N=m.V.twin(E);if(!S||!N||!p.here(S)||!m.V.here(N)||v.map.get(E)!==S||v.reverse.get(S)!==E||m.A.map.get(E)!==N||m.A.reverse.get(N)!==E||O(S)||m.idOf(N)||S.tagName!==E.tagName||N.tagName!==E.tagName||!to(S,s,h,u)||!to(N,s,h,u)||!Ms(E,h,u)||!Ms(S,h,u)||!Ms(N,h,u))continue;let C=r(E,null,h),j=r(S,v,h),D=r(N,m.A,h),B=C.flat.text,w=j.flat.text,y=D.flat.text;if(u(h,B.length+w.length+y.length),!An.test(B)||!An.test(w)||!An.test(y)||B===w||B===y||w===y||!Rr(C,j,l,h,u)||!Rr(C,D,l,h,u))continue;let $=null,U=!1;for(let Ae=P;Ae<=T;Ae++){u(h,1);let De=p.units[Ae],oe=p.baseOf(De);if(!oe||oe===E||d.has(oe)||oe.parentNode!==E.parentNode||De.parentNode!==S.parentNode||oe.tagName!==E.tagName||De.tagName!==E.tagName||v.map.get(oe)!==De||v.reverse.get(De)!==oe||i(oe)!==O(De)||!to(oe,s,h,u)||!to(De,s,h,u))continue;let xe=r(oe,null,h),$e=r(De,v,h),ae=xe.flat.text,k=$e.flat.text;if(u(h,ae.length),!An.test(ae)||k.length<=ae.length)continue;let _=l($e,h),re=En(ae,k,_,h,u,!0);if(!(re<0||En(B,k,_,h,u,!0,re,re+ae.length)<0&&!rl({base:e,V:p,A:v,source:E,original:C,current:j,edited:D,destination:$e,at:re,ownLength:ae.length,eligible:s,model:r,tokensOf:l,budget:h,charge:u}))){if($){U=!0;break}$=De}}if(!$||U)continue;let V=t===0?S:N,Ne=t===0?N:S;(x||=[]).push({source:E,local:V,remote:Ne,models:[C,t===0?j:D,t===0?D:j]})}}catch(A){if(A!==b)throw A}return x}var Un=/\S/,bn=/\s/,il=/[\s\u001e]/g,Os=/[^\s\p{P}\u001e\ufffc]/u;function ll(e,o,t,n,s,d,i){let r=0;for(let l of e)i(d,1),l.nodeType===1&&!n.baseOf(l)&&r++;if(r<2)return!1;for(let l of e){if(l.nodeType!==1||n.baseOf(l))continue;let u=s.get(l).flat;if(u.atoms.length||u.pins?.length)continue;i(d,u.text.length*2+o.length+t.length);let b=new Uint8Array(u.text.length);for(let a of t)a.target===l&&b.fill(1,a.targetFrom,a.targetFrom+a.to-a.from);for(let a of o)a.target===l&&b.fill(1,a.targetFrom,a.targetFrom+a.to-a.from);for(let a=0;a<u.text.length;a++)if(!b[a]&&Un.test(u.text[a]))return!0}return!1}function al(e,o,t){let{source:n,models:s,retained:d,runs:i}=e,r=s.get(n).flat.text;t(o,r.length*2+d.length+i.length);let l=new Uint8Array(r.length);for(let u of d)u.source===n&&(t(o,u.to-u.from),l.fill(1,u.from,u.to));for(let u of i)t(o,u.to-u.from),l.fill(1,u.from,u.to);for(let u=0;u<r.length;u++)if(!l[u]&&Un.test(r[u]))return!1;return!0}function cl(e,o,t,n,s,d,i,r,l,u){let b=d.get(e),a=d.get(o),h=b.flat.text,p=i.get(e);l(u,h.length*2+t.length);let v=h.length,O=0;for(let g=0;g<h.length;g++)!bn.test(h[g])&&!p[g]&&(v=Math.min(v,g),O=g+1);if(v>=O)return null;for(let g=v;g<O;g++)if(!bn.test(h[g])&&p[g])return null;let m=-1;for(let g of t)if(g.target===o&&g.from<=v&&g.to>v){m=g.targetFrom+v-g.from;break}if(m<0)return null;let c=h.slice(v,O);if(l(u,c.length*(t.length+2)),a.flat.text.slice(m,m+c.length)!==c)return null;for(let g=v;g<O;g++){if(bn.test(h[g]))continue;let P=!1;for(let T of t)if(T.target===o&&T.from<=g&&T.to>g&&T.targetFrom+g-T.from===m+g-v){P=!0;break}if(!P)return null}if(b.flat.atoms.length||a.flat.atoms.length){l(u,b.flat.atoms.length+a.flat.atoms.length);let g=0,P=a.flat.atoms;for(;g<P.length&&P[g].i<m;)g++;for(let T of b.flat.atoms){if(T.i<v||T.i>=O)continue;let x=P[g++];if(!x||x.i!==m+T.i-v||a.alignment?.reverse.get(x.el)!==T.el)return null}if(g<P.length&&P[g].i<m+O-v)return null}for(let[g,P,T]of[[n,e,v],[s,o,m]]){let x=!1;for(let A of g){let E=d.get(A),S=i.get(A),N=r(E,u);for(let C=0;C<N.length;C++){let j=N[C].from,D=j+c.length;if(l(u,c.length*2+1),E.flat.text.slice(j,D)!==c)continue;let B=C;for(;B<N.length&&N[B].to<D;)l(u,1),B++;if(B===N.length||N[B].to!==D)continue;let w=!0;for(let y=j;y<D;y++)if(!bn.test(E.flat.text[y])&&S[y]){w=!1;break}if(w){if(x||A!==P||j!==T)return null;x=!0}}}if(!x)return null}return c}function fl(e,o,t,n,s,d,i,r){if(i(r,s.length+d.length+(n.length+1)*t.length*2),!t)return!1;let l=n.indexOf(t);return l<0||n.lastIndexOf(t)!==l||!d.some(u=>u.from===l)||!d.some(u=>u.to===l+t.length)?!1:s.some(u=>u.source===e&&u.target===o&&u.from===0&&u.to===t.length&&u.targetFrom===l)}function Br({base:e,views:o,eligible:t,baseId:n,ignored:s,remoteWins:d,atomKey:i,limit:r=2e4*8}){if(r<=0)return null;let l=Symbol(),u=(T,x)=>{if(x>T.remaining)throw l;T.remaining-=x},b=[new Map,new Map];for(let T=0;T<2;T++)for(let x=0;x<o[T].V.units.length;x++)b[T].set(o[T].V.units[x],x);let a=new Int32Array(e.length),h=new Int32Array(e.length),p=T=>o.every(({V:x},A)=>{let E=x.twin(T);return E&&b[A].has(E)}),v=-1;for(let T=0;T<e.length;T++)a[T]=v,p(e[T])&&(v=T);v=e.length;for(let T=e.length-1;T>=0;T--)h[T]=v,p(e[T])&&(v=T);let O=new Map,m=(T,x)=>{if(u(x,1),O.has(T))return O.get(T);let A=T.firstChild,E=1;for(;A;){if(u(x,E*8+8),A.nodeType===3&&u(x,A.data.length*8),A.nodeType===1&&vn.has(A.tagName)&&!s(A)&&!d(A)&&A.firstChild){A=A.firstChild,E++;continue}for(;A&&A!==T&&!A.nextSibling;)A=A.parentNode,E--;A=!A||A===T?null:A.nextSibling}let S=ln(Array.from(T.childNodes),{ignored:s,remoteWins:d});return O.set(T,S),S},c=(T,x,A,E,S,N)=>{for(let C of T.atoms){u(N,1);let j=x.atomAt.get(C.i+A);if(!j)return!1;let D=E?.reverse.get(C.el)||i(C.el),B=S?.reverse.get(j.el)||i(j.el);if(D!==B)return!1}return!0},g=(T,x,A,E,S)=>{let N=T.text.length<=x.text.length?T:x,C=N===T?x:T;if(u(S,N.text.length+C.text.length),!N.text||!Un.test(N.text.replaceAll(Dn,"")))return!1;let j;if(N.text===C.text)j=0;else{let D=C.text.length-N.text.length;if(u(S,(D+1)*N.text.length*2),C.text.startsWith(N.text))j=0;else if(C.text.endsWith(N.text))j=D;else return!1;if(C.text.indexOf(N.text)!==j||C.text.lastIndexOf(N.text)!==j)return!1;u(S,C.text.length*2);let B=0,w=j===0,y=!1;for(let $ of fn(C.text,xn(C.text)))B+=$.len,B===j&&(w=!0),B===j+N.text.length&&(y=!0);if(!w||!y)return!1}return N===T?c(N,C,j,A,E,S):c(N,C,j,E,A,S)},P=null;for(let T=0;T<2;T++){let{V:x,A,idOf:E}=o[T],S=o[1-T];if(!x.asBase)for(let N=0;N<e.length;N++){let C=e[N];if(x.twin(C)||!t(C))continue;let j=S.V.twin(C);if(!j||!b[1-T].has(j)||!t(j))continue;let D={remaining:r};try{let B=a[N],w=h[N],y=0;for(let Ne=B+1;Ne<w;Ne++)u(D,1),!x.twin(e[Ne])&&S.V.twin(e[Ne])&&t(e[Ne])&&y++;if(y!==1||m(C,D).text===m(j,D).text)continue;let $=B<0?-1:b[T].get(x.twin(e[B])),U=w===e.length?x.units.length:b[T].get(x.twin(e[w]));if($===void 0||U===void 0||$>=U)continue;let V=null;for(let Ne=$+1;Ne<U;Ne++){u(D,1);let Ae=x.units[Ne];if(x.baseOf(Ae)||!t(Ae)||Ae.tagName!==C.tagName||Ae.namespaceURI!==C.namespaceURI)continue;let De=n(C),oe=S.idOf(j),xe=E(Ae);if(!(De&&oe&&De!==oe||De&&xe&&De!==xe||oe&&xe&&oe!==xe)&&g(m(j,D),m(Ae,D),S.A,A,D)){if(V){V=null;break}V=Ae}}if(!V)continue;P||(P=[new Map,new Map]),P[T].set(C,V)}catch(B){if(B!==l)throw B}}}return P?o.map(({V:T},x)=>{let A=P[x];if(!A.size)return T;let E=new Map;for(let[S,N]of A)E.set(N,S);return{...T,twin:S=>A.get(S)||T.twin(S),baseOf:S=>E.get(S)||T.baseOf(S)}}):null}function Dr({onUncertainSource:e,onUncertainOwner:o,base:t,views:n,eligible:s,ignored:d,remoteWins:i,baseId:r,atomKey:l,limit:u=2e4*32}){if(u<=0)return null;let b=new Set(t),a=new Map(t.map((B,w)=>[B,w])),h=new Map,p=[],v=null,O=null,m=null,c=new Set;for(let B of t)for(let{V:w}of n){let y=w.twin(B);y&&!w.asBase&&!w.here(y)&&c.add(B)}let g=new Set,P=Symbol(),T=(B,w)=>{if(w>B.remaining)throw P;B.remaining-=w},x=(B,w,y)=>{T(y,1);let $=h.get(B);if($)return $;if(B.nodeType===1){let Ne=B.firstChild,Ae=1;for(;Ne;){if(T(y,Ae*8+8),Ne.nodeType===3&&T(y,Ne.data.length*8),Ne.nodeType===1&&vn.has(Ne.tagName)&&!d(Ne)&&!i(Ne)&&Ne.firstChild){Ne=Ne.firstChild,Ae++;continue}for(;Ne&&Ne!==B&&!Ne.nextSibling;)Ne=Ne.parentNode,Ae--;Ne=!Ne||Ne===B?null:Ne.nextSibling}}else T(y,B.value.length*8+B.nodes.length);let U=B.nodeType===1?Array.from(B.childNodes):B.nodes,V=U.length===1&&U[0].nodeType===3?{text:U[0].data,nodes:[{node:U[0],s:0,e:U[0].data.length}],atoms:[]}:ln(U,{ignored:d,remoteWins:i});return $={unit:B,flat:V,alignment:w,tokens:null},h.set(B,$),$},A=(B,w)=>{if(B.tokens)return B.tokens;T(w,B.flat.text.length*8);let{unit:y,flat:$,alignment:U}=B,V=[],Ne=xn($.text),Ae=0,De=oe=>{for(let xe of fn($.text.slice(Ae,oe),Ne))xe.from=Ae,xe.to=Ae+xe.len,xe.unit=y,V.push(xe),Ae+=xe.len};for(let oe of $.atoms){De(oe.i);let xe=i(oe.el)&&oe.el.nodeType===1?"w"+oe.el.tagName+"#"+(oe.el.id||""):l(U?.reverse.get(oe.el)||oe.el);V.push({k:xe,raw:Dn,len:1,from:Ae,to:Ae+1,unit:y,atom:!0}),Ae++}return De($.text.length),B.tokens=V,V},E=(B,w,y,$,U)=>{if(!B.flat.atoms.length&&!w.flat.atoms.length)return!0;let V=A(B,U),Ne=A(w,U);T(U,V.length+Ne.length);let Ae=0;for(let De of Ne){if(!De.atom||De.from<y||De.from>=y+$)continue;for(;Ae<V.length&&!V[Ae].atom;)Ae++;let oe=V[Ae++];if(!oe||oe.from!==De.from-y||oe.k!==De.k)return!1}for(;Ae<V.length;)if(V[Ae++].atom)return!1;return!0},S=(B,w,y)=>{let $=B.length+w.length+4;if($*8>y.remaining)return null;y.remaining-=$*8;let U=Math.floor(y.remaining/8),V=Math.min(B.length+w.length,4e3,Math.floor((Math.sqrt($*$+U)-$)/2)),Ne=4*(V+1)*($+V+1);if(V<1||Ne>y.remaining)return null;y.remaining-=Ne;let Ae=Hn(B,w,V),De=[],oe=0,xe=0;for(let $e of Ae.hunks){for(;oe<$e.bs;)B[oe].raw===w[xe].raw&&De.push([B[oe],w[xe]]),oe++,xe++;oe=$e.be,xe+=$e.toks.length}for(;oe<B.length&&xe<w.length;)B[oe].raw===w[xe].raw&&De.push([B[oe],w[xe]]),oe++,xe++;return De},N=(B,w,y,$,U,V,Ne)=>{if(U<=$)return;let Ae=B[B.length-1];if(Ae&&Ae.source===w&&Ae.target===y&&Ae.to<=$&&Ae.targetFrom-Ae.from===V-$){T(Ne,($-Ae.to)*3);let De=h.get(w).flat.text,oe=h.get(y).flat.text,xe=!0;for(let $e=Ae.to;$e<$;$e++)if(!bn.test(De[$e])||De[$e]!==oe[V+$e-$]){xe=!1;break}if(xe){Ae.to=U;return}}B.push({source:w,target:y,from:$,to:U,targetFrom:V})},C=B=>B.replace(il,"");for(let B=0;B<n.length;B++){let{V:w,A:y,idOf:$}=n[B];if(w.asBase)continue;let U=new Map(w.units.map((k,_)=>[k,_])),V=k=>{let _=w.twin(k);return _&&U.has(_)?_:null},Ne=(k,_)=>{let re=new Int32Array(k.length),Z=new Int32Array(k.length),Be=-1;for(let Ke=0;Ke<k.length;Ke++)re[Ke]=Be,_(k[Ke])&&(Be=Ke);Be=k.length;for(let Ke=k.length-1;Ke>=0;Ke--)Z[Ke]=Be,_(k[Ke])&&(Be=Ke);return{prev:re,next:Z}},Ae=Ne(t,k=>(k.nodeType===1||k.kind==="text"&&Un.test(k.value))&&V(k)),De=Ne(w.units,k=>(k.nodeType===1||k.kind==="text"&&Un.test(k.value))&&b.has(w.baseOf(k))),oe=new Map,xe=(k,_,re,Z)=>{if(k>_||re>Z)return;let Be=`${k}:${_}:${re}:${Z}`;oe.set(Be,[k,_,re,Z])};for(let k=0;k<w.units.length;k++){let _=w.units[k];if(w.baseOf(_)||!s(_))continue;let re=De.prev[k],Z=De.next[k],Be=re<0?0:a.get(w.baseOf(w.units[re])),Ke=Z===w.units.length?t.length-1:a.get(w.baseOf(w.units[Z]));xe(Be,Ke,Math.max(0,re),Math.min(w.units.length-1,Z))}for(let k=0;k<t.length;k++){let _=t[k];if(c.has(_)||!s(_))continue;if(!w.twin(_)){let it=Ae.prev[k],et=Ae.next[k],mt=it<0?0:U.get(V(t[it])),Ze=et===t.length?w.units.length-1:U.get(V(t[et]));xe(Math.max(0,it),Math.min(t.length-1,et),mt,Ze)}let re=V(_);if(!re||y.identical.has(_)||!s(re))continue;let Z=k+1;for(;Z<t.length&&t[Z].kind==="text"&&!t[Z].value.trim();)Z++;if(Z>=t.length||!s(t[Z]))continue;let Be=V(t[Z]);if(!Be||y.identical.has(t[Z])||!s(Be))continue;let Ke=U.get(re),Te=U.get(Be);Ke<Te&&xe(k,Z,Ke,Te)}let $e=Array.from(oe.values()),ae=new Set;if($e.length>1){let k=Xt(u);try{T(k,$e.length*4);let _=$e.slice().sort((Be,Ke)=>(T(k,1),Be[0]-Ke[0]||Be[2]-Ke[2])),re=[],Z=null;for(let Be of _)T(k,1),Z&&Be[0]<=Z[1]&&Be[2]<=Z[3]&&Be[3]>=Z[2]?(Z[1]=Math.max(Z[1],Be[1]),Z[2]=Math.min(Z[2],Be[2]),Z[3]=Math.max(Z[3],Be[3]),Z[4].push(Be)):(Z?.[4].length>1&&re.push(Z),Z=[Be[0],Be[1],Be[2],Be[3],[Be]]);Z?.[4].length>1&&re.push(Z),$e=re.concat($e)}catch(_){if(_!==P)throw _}}for(let k of $e){if(ae.has(k))continue;let[_,re,Z,Be,Ke]=k,Te=Xt(u),it=[],et=new Set,mt=!1;try{T(Te,(re-_+Be-Z+2)*4);let Ze=t.slice(_,re+1).filter(Q=>!y.identical.has(Q)&&s(Q)&&!c.has(Q)),ft=w.units.slice(Z,Be+1).filter(Q=>s(Q)&&(!w.baseOf(Q)||b.has(w.baseOf(Q)))&&!y.identical.has(w.baseOf(Q))&&!c.has(w.baseOf(Q))),Ct=new Set(ft),Dt=!1,Tt="",Rt="",jt=0;for(let Q of Ze){let Oe=x(Q,null,Te);Tt+=Oe.flat.text,jt+=Oe.flat.text.length}for(let Q of ft){let Oe=x(Q,y,Te);Rt+=Oe.flat.text,jt+=Oe.flat.text.length}T(Te,jt);let qt=C(Tt),un=C(Rt),Lt=qt===un;if(mt=Lt,Ke&&!Lt)continue;let Jt=Lt?null:new Map;if(Jt)for(let Q of Ze.concat(ft)){let Oe=h.get(Q).flat.text.length;T(Te,Oe*16),Jt.set(Q,new Uint8Array(Oe))}let F=Q=>{let Oe=[];for(let Ve of Q){let Ce=h.get(Ve);Ce.flat.atoms.length?Oe.push(...A(Ce,Te)):Oe.push({unit:Ve,raw:Ce.flat.text,from:0})}return Oe},ce=[];for(let Q of Lt?[]:Ze){let Oe=V(Q);if(!Ct.has(Oe))continue;let Ve=x(Q,null,Te),Ce=x(Oe,y,Te);T(Te,Ve.flat.text.length+Ce.flat.text.length);let be=Ve.flat.text&&Ce.flat.text.startsWith(Ve.flat.text)?0:Ve.flat.text&&Ce.flat.text.endsWith(Ve.flat.text)?Ce.flat.text.length-Ve.flat.text.length:-1;if(be>=0&&E(Ve,Ce,be,Ve.flat.text.length,Te)){Jt.get(Q).fill(1),Jt.get(Oe).fill(1,be,be+Ve.flat.text.length),N(ce,Q,Oe,0,Ve.flat.text.length,be,Te);continue}let H=S(A(Ve,Te),A(Ce,Te),Te);if(!H){Dt=!0;break}for(let[X,de]of H)Jt.get(Q).fill(1,X.from,X.to),Jt.get(Oe).fill(1,de.from,de.to),N(ce,Q,Oe,X.from,X.to,de.from,Te)}if(Dt)continue;let ge=null,Le=null;if(!Lt)for(let Q of Ze){let Oe=V(Q),Ve=h.get(Q);if(!Oe||Ve.flat.atoms.length||!Ct.has(Oe))continue;let Ce=Ve.flat.text,be=Jt.get(Q);T(Te,Ce.length*3+ft.length);let H=-1,X=-1,de=!1;for(let He=0;He<Ce.length;He++)bn.test(Ce[He])||(be[He]?de=!0:(H<0&&(H=He),X=He+1));if(!de||H<0)continue;let pe=!0;for(let He=H;He<X;He++)if(be[He]&&!bn.test(Ce[He])){pe=!1;break}if(!pe)continue;let se=C(Ce.slice(H,X)),ke=null,fe=!1;for(let He of ft){if(w.baseOf(He))continue;let Se=h.get(He);if(!Se.flat.atoms.length&&(T(Te,Se.flat.text.length),C(Se.flat.text)===se)){if(ke){fe=!0;break}ke=He}}if(fe){(Le||=new Set).add(Q);continue}if(!ke||Le?.has(Q))continue;let G=!1;for(let He of Ze){if(He===Q||!Ct.has(V(He)))continue;let Se=h.get(He);if(Se.flat.atoms.length)continue;let Je=Jt.get(He);T(Te,Se.flat.text.length*3);let nt="",ot=!1;for(let Wt=0;Wt<Se.flat.text.length;Wt++)bn.test(Se.flat.text[Wt])||(Je[Wt]?ot=!0:nt+=Se.flat.text[Wt]);ot&&nt===se&&(Le||=new Set,Le.add(Q),Le.add(He),G=!0)}if(G)continue;let ue=h.get(ke).flat.text;T(Te,X-H+ue.length);let Ie=H,Pe=0;for(;Ie<X&&Pe<ue.length;){for(;Ie<X&&bn.test(Ce[Ie]);)Ie++;for(;Pe<ue.length&&bn.test(ue[Pe]);)Pe++;if(Ie>=X||Pe>=ue.length)break;N(ge||=[],Q,ke,Ie,Ie+1,Pe,Te),Ie++,Pe++}be.fill(1,H,X),Jt.get(ke).fill(1)}let Me=Q=>{let Oe=[];for(let Ve of Q){let Ce=x(Ve,b.has(Ve)?null:y,Te),be=Jt.get(Ve);for(let H of A(Ce,Te)){let X=H.from;for(;X<H.to;){for(;X<H.to&&be[X];)X++;let de=X;for(;X<H.to&&!be[X];)X++;if(X>de){let pe=Ce.flat.text.slice(de,X);Un.test(pe)&&Oe.push({...H,raw:pe,len:X-de,k:H.atom?H.k:pe,from:de,to:X})}}}}return Oe},M=Lt?F(Ze):Me(Ze),R=Lt?F(ft):Me(ft),z=Lt?qt:M.map(Q=>C(Q.raw)).join(""),J=Lt?un:R.map(Q=>C(Q.raw)).join("");if((!z||!J)&&!ge)continue;let ne=ge||[];if(z&&J&&z===J){let Q=0,Oe=0,Ve=0,Ce=0;for(;Q<M.length&&Oe<R.length;){let be=M[Q],H=R[Oe];for(;Ve<be.raw.length&&bn.test(be.raw[Ve]);)Ve++;for(;Ce<H.raw.length&&bn.test(H.raw[Ce]);)Ce++;if(Ve===be.raw.length){Q++,Ve=0;continue}if(Ce===H.raw.length){Oe++,Ce=0;continue}if((be.atom||H.atom)&&be.k!==H.k){Dt=!0;break}N(ne,be.unit,H.unit,be.from+Ve,be.from+Ve+1,H.from+Ce,Te),Ve++,Ce++}}else if(z&&J){let Q=S(M,R,Te);if(!Q)continue;for(let[Oe,Ve]of Q)N(ne,Oe.unit,Ve.unit,Oe.from,Oe.to,Ve.from,Te)}if(Dt)continue;let je=new Map;for(let Q of ne)if(!Le?.has(Q.source)){if(V(Q.source)===Q.target){Lt&&ce.push(Q);continue}je.has(Q.source)||je.set(Q.source,[]),je.get(Q.source).push(Q)}for(let[Q,Oe]of je){let Ve=x(Q,null,Te),Ce=V(Q),be=Ve.flat.text,H=[],X=new Set,de=n[1-B],pe=de.V.twin(Q),se=pe&&de.V.here(pe)?x(pe,de.A,Te):null,ke=(Se,Je)=>{let nt=A(Se,Te),ot=A(Je,Te);return T(Te,Se.flat.text.length+Je.flat.text.length+nt.length+ot.length),Se.flat.text===Je.flat.text&&nt.length===ot.length&&nt.every((Wt,Ut)=>Wt.k===ot[Ut].k)},fe=Ce&&se&&se.flat.text!==be&&ke(x(Ce,y,Te),se);for(let Se of new Set(Oe.map(Je=>Je.target))){if(Q.nodeType!==1&&Se.nodeType!==1)continue;let Je=x(Se,y,Te),nt=w.baseOf(Se);if(Q.nodeType!==1&&nt||(T(Te,be.length*2+Je.flat.text.length*3+ce.length*2),Ce&&C(be)===C(Je.flat.text)&&x(Ce,y,Te).flat.text.trim()))continue;if(!Ce&&!nt&&Q.nodeType===1&&Se.nodeType===1){let q=r(Q),te=$(Se);if(q&&te&&q!==te)continue}let ot=Je.flat.text,Wt=be&&(ot.startsWith(be)||ot.endsWith(be)),Ut=!1;if(!Ce&&se&&nt&&se.flat.text!==be){let q=x(nt,null,Te).flat.text,te=a.get(Q)<a.get(nt)?se.flat.text:q,me=a.get(Q)<a.get(nt)?q:se.flat.text;T(Te,te.length+me.length+ot.length),Ut=!!te&&!!me&&te.length+me.length<=ot.length&&ot.startsWith(te)&&ot.endsWith(me)&&!ot.slice(te.length,ot.length-me.length).trim()}let I=!Ve.flat.atoms.length&&!se?.flat.atoms.length&&!Je.flat.atoms.length&&(fe&&Wt||Ut);if(Ce&&nt){let q=x(Ce,y,Te).flat.text,te=be.startsWith(q)||be.endsWith(q),me=x(nt,null,Te).flat.text,we=Je.flat.text,ie=we.startsWith(me)||we.endsWith(me),ee=!n[1-B].V.twin(nt)&&!ce.some(Ee=>Ee.source===nt&&Un.test(me.slice(Ee.from,Ee.to)));if(!Lt&&(!te&&!I||!ie&&!ee)){let Ee=cl(Q,Se,Oe,Ze,ft,h,Jt,A,T,Te);if(!Ee)continue;let Ue=y.weak?.has(Q)&&!y.identityPaired?.has(Q)&&be.trim()===Ee;if(!te&&!I&&!Ue)continue;let _e=y.weak?.has(nt)&&!y.identityPaired?.has(nt)&&ot.trim()===Ee&&!h.get(nt).flat.atoms.length&&!ce.some(Ye=>Ye.source===nt&&Un.test(me.slice(Ye.from,Ye.to)));if(!ie&&!ee&&!_e&&!fl(nt,Se,me,ot,ce,A(Je,Te),T,Te))continue;Ue&&X.add(Se)}}I&&X.add(Se),T(Te,Oe.length),H.push(...Oe.filter(q=>q.target===Se))}if(!H.length)continue;let G=new Uint8Array(be.length);T(Te,be.length*4+ce.length);for(let Se of H)G.fill(1,Se.from,Se.to);let ue=[];for(let Se=0;Se<be.length;Se++)bn.test(be[Se])||ue.push(Se);if(!ue.length)continue;let Ie=new Set(H.map(Se=>Se.target));if(!Lt&&Ce&&Ie.size>1&&ll(Ie,ne,ce,w,h,Te,T)){if(m||=new Map,m.set(Q,(m.get(Q)||0)|1<<B),e){let Se=ws({source:Q,side:B,views:n,eligible:s,blocked:c,baseId:r,model:x,tokensOf:A,budget:Te,charge:T});if(Se){T(Te,Se.to-Se.from);let Je=!0;for(let nt=Se.from;nt<Se.to;nt++)if(Un.test(be[nt])&&!G[nt]){Je=!1;break}Je&&(v||=[]).push(Se)}}continue}let Pe=ue.filter(Se=>Os.test(be[Se]));if(!H.some(Se=>Os.test(be.slice(Se.from,Se.to)))&&!ue.every(Se=>G[Se]))continue;if(!Ce&&!Array.from(Ie).some(Se=>X.has(Se))&&!ue.every(Se=>G[Se])&&!(Pe.length&&G[Pe[0]]&&G[Pe[Pe.length-1]]&&Ie.size===1)){let Se=null,Je=0,nt=0,ot=null,Wt=null;if(!Ce&&se&&Q.nodeType===1&&!Ve.flat.atoms.length){let Ut=A(Ve,Te).filter(I=>Os.test(I.raw));T(Te,ft.length+be.length);for(let I of ft){let q=w.baseOf(I);if(!q||q===Q||q.nodeType!==1||I.nodeType!==1||q.tagName!==Q.tagName||I.tagName!==q.tagName)continue;let te=a.get(Q),me=a.get(q),we=!0;for(let gt=Math.min(te,me)+1;gt<Math.max(te,me);gt++){let $t=t[gt];if(T(Te,$t.nodeType===1?1:$t.value.length+1),$t.nodeType===1||$t.value.trim()){we=!1;break}}if(!we)continue;let ie=x(q,null,Te),ee=x(I,y,Te);if(ie.flat.atoms.length||ee.flat.atoms.length)continue;let Ee=ie.flat.text,Ue=ee.flat.text;if(T(Te,Ee.length+Ue.length+be.length),!Ee||!Ut.length)continue;let _e=0,Ye=Ue.length;if(te<me&&Ue.endsWith(Ee))Ye-=Ee.length;else if(te>me&&Ue.startsWith(Ee))_e=Ee.length;else continue;for(;_e<Ye&&bn.test(Ue[_e]);)_e++;for(;Ye>_e&&bn.test(Ue[Ye-1]);)Ye--;let yt=Ue.slice(_e,Ye);if(!(!yt||!(yt.startsWith(Ut[0].raw)||yt.endsWith(Ut[Ut.length-1].raw)))){if(Se){Se=null;break}Se=I,Je=_e,nt=Ye,ot=Ut[0],Wt=Ut[Ut.length-1]}}}if(T(Te,H.length),!Se||!Ie.has(Se)||!H.some(Ut=>Ut.target===Se&&(Ut.from<=ot.from&&Ut.to>=ot.to&&Ut.targetFrom+ot.from-Ut.from===Je||Ut.from<=Wt.from&&Ut.to>=Wt.to&&Ut.targetFrom+Wt.to-Ut.from===nt)))continue}if(Ce&&!(ue.every(Se=>G[Se])&&(Lt||Array.from(Ie).some(Se=>X.has(Se))))&&!ce.some(Se=>Se.source===Q&&Un.test(be.slice(Se.from,Se.to))))continue;let He=!1;if(Lt){T(Te,ce.length+ue.length);for(let Se of ce)Se.source===Q&&(T(Te,Se.to-Se.from),G.fill(1,Se.from,Se.to));He=!0;for(let Se of ue)if(!G[Se]){He=!1;break}}for(let Se of Ie){T(Te,H.length);let Je=H.filter(ot=>ot.target===Se);it.push({side:B,source:Q,target:Se,runs:Je,models:h,retained:ce,conservedSource:He}),Q.nodeType===1&&et.add(Q),Se.nodeType===1&&et.add(Se);let nt=w.baseOf(Se);nt?.nodeType===1&&et.add(nt)}}if(p.push(...it),Ke&&it.length)for(let Q of Ke)ae.add(Q);for(let Q of et)g.add(Q)}catch(Ze){if(Ze!==P)throw Ze}finally{if(o&&!Ke&&!mt){let Ze=Pr({base:t,views:n,side:B,attempt:k,eligible:s,blocked:c,baseId:r,model:x,tokensOf:A,charge:T,exhausted:P,limit:u});Ze&&(O||=[]).push(...Ze)}if(e&&!Ke&&!mt){let Ze=zs({base:t,views:n,side:B,attempt:k,eligible:s,blocked:c,baseId:r,model:x,tokensOf:A,certificates:p,charge:T,exhausted:P,limit:u});Ze&&(v||=[]).push(...Ze)}}}}let j=p.length?new Map:null;for(let B of p){let w=j.get(B.source);w||j.set(B.source,w=[]),w.push(B)}let D=null;if(j){let B=null;for(let[w,y]of j){let $=m?.get(w)||0;if(y.length<2&&!$)continue;let U=0;for(let V of y)V.conservedSource&&(U|=1<<V.side);for(let V of y){if(V.conservedSource)continue;let Ne=1<<V.side,Ae=!0;if(U&Ne)Ae=!1;else if($&Ne){Ae=!1;try{Ae=al(V,B||=Xt(u),T)}catch(De){if(De!==P)throw De}}Ae||(D||=new Set).add(V)}}}if(D){let B=0;for(let w of p)D.has(w)||(p[B++]=w);p.length=B;for(let[w,y]of j){B=0;for(let $ of y)D.has($)||(y[B++]=$);y.length=B,B||j.delete(w)}g.clear();for(let w of p){let{source:y,target:$,side:U}=w;y.nodeType===1&&g.add(y),$.nodeType===1&&g.add($);let V=n[U].V.baseOf($);V?.nodeType===1&&g.add(V)}}if(v){let B=Xt(u),w=!1;for(let y of v){let $=!1,U=j?.get(y.source);if(U&&!w)try{$=bs(y,U,B,T)}catch(V){if(V!==P)throw V;w=!0}$||e(y)}}if(O){let B=new Set,w=Xt(u);try{for(let y of O){if(T(w,1),B.has(y.source))continue;B.add(y.source);let $=!1;for(let U of p)if(T(w,1),U.source===y.source||U.target===y.local||U.target===y.remote){$=!0;break}$||o(y)}}catch(y){if(y!==P)throw y}}for(let B of t)if(g.has(B))for(let{V:w}of n){let y=w.twin(B);y&&w.here(y)&&g.add(y)}return p.length?{blocks:g,certificates:p,certificatesBySource:j,models:h}:null}function jr({certificates:e,scopes:o,flats:t,keys:n,limit:s=2e4*32}){let d=Symbol(),i=Xt(s),r=m=>{if(m>i.remaining)throw d;i.remaining-=m},l=o.map(m=>new Set(m)),u=new Map,b=new Map,a=(m,c)=>{let g=u.get(m);if(g||u.set(m,g=new Map),g.has(c))return g.get(c);r(m.text.length);let P=b.get(c);if(!P){r(c.nodes.length+c.atoms.length),P={nodes:new Map,atoms:new Map};for(let E of c.nodes)P.nodes.set(E.node,E);for(let E of c.atoms)P.atoms.set(E.el,E.i);b.set(c,P)}let{nodes:T,atoms:x}=P,A=new Int32Array(m.text.length).fill(-1);for(let E of m.nodes){let S=T.get(E.node);if(!(!S||E.e-E.s!==S.e-S.s)){r(E.e-E.s);for(let N=E.s;N<E.e;N++)A[N]=S.s+N-E.s}}for(let E of m.atoms){let S=x.get(E.el);S!==void 0&&(A[E.i]=S)}return g.set(c,A),A},h=(m,c,g,P,T)=>{let x=m[m.length-1];x&&x.to===c&&x.target+x.to-x.from===P&&x.kind===T?x.to=g:m.push({from:c,to:g,target:P,kind:T})},p=(m,c,g,P)=>{r((P-g)*4);let T=[],x=g,A=N=>{let C=m.text.slice(x,N);for(let j of fn(C,xn(C)))j.from=x,j.to=x+j.len,T.push(j),x+=j.len},E=0,S=m.atoms.length;for(;E<S;){r(1);let N=E+S>>>1;m.atoms[N].i<g?E=N+1:S=N}for(let N=E;N<m.atoms.length&&m.atoms[N].i<P;N++){r(1);let C=m.atoms[N];A(C.i),T.push({k:c(C),raw:Dn,len:1,from:x,to:x+1}),x++}return A(P),T},v=(m,c,g,P,T,x)=>{if(g===P||T===x)return;if(P-g===x-T){r((P-g)*4);let w=!0;for(let y=g,$=T;y<P;y++,$++){if(t[0].text[y]!==t[c].text[$]){w=!1;break}let U=t[0].atomAt.get(y),V=t[c].atomAt.get($);if(!!U!=!!V||U&&n[0](U)!==n[c](V)){w=!1;break}}if(w){h(m,g,P,T,"retained");return}}let A=p(t[0],n[0],g,P),E=p(t[c],n[c],T,x),S=A.length+E.length+4,N=Math.min(A.length+E.length,4e3,Math.floor((Math.sqrt(S*S+i.remaining/2)-S)/2));if(N<1)throw d;r(4*(N+1)*(S+N+1));let C=Hn(A,E,N),j=0,D=0,B=()=>{let w=A[j++],y=E[D++];r(w.len),w.raw===y.raw&&h(m,w.from,w.to,y.from,"retained")};for(let w of C.hunks){for(;j<w.bs;)B();j=w.be,D+=w.toks.length}for(;j<A.length&&D<E.length;)B()},O=m=>{let c=e.filter(C=>C.side===m-1&&l[0].has(C.source)&&l[m].has(C.target));if(!c.length)return null;let g=[],P=(C,j,D)=>{if(!l[0].has(C.source)||!l[m].has(C.target))return;let B=a(j.get(C.source).flat,t[0]),w=a(j.get(C.target).flat,t[m]);r(C.to-C.from);for(let y=0;y<C.to-C.from;y++){let $=B[C.from+y],U=w[C.targetFrom+y];if($<0||U<0)throw d;h(g,$,$+1,U,D)}},T=new Set;for(let C of c){if(!T.has(C.retained)){T.add(C.retained);for(let j of C.retained)P(j,C.models,"retained")}for(let j of C.runs)P(j,C.models,"transfer")}g.sort((C,j)=>(r(1),C.from-j.from||C.target-j.target));let x=[];for(let C of g){r(1);let j=x[x.length-1];if(j&&C.from<j.to){if(C.target-C.from!==j.target-j.from)throw d;j.to=Math.max(j.to,C.to),C.kind==="transfer"&&(j.kind="transfer")}else x.push(C)}let A=[],E=0,S=0;for(let C of x){if(C.target<S)throw d;v(A,m,E,C.from,S,C.target),A.push(C),E=C.to,S=C.target+C.to-C.from}v(A,m,E,t[0].text.length,S,t[m].text.length);let N=Bn({base:t[0],side:t[m],retained:A.filter(C=>C.kind==="retained"),transfers:A.filter(C=>C.kind==="transfer"),baseAtomKey:n[0],sideAtomKey:n[m],budget:i});if(N.status!=="ready"||!N.monotone)throw d;return N};try{let m=O(1),c=O(2);return m||c?{local:m,remote:c}:{fallback:!0}}catch(m){if(m!==d)throw m;return{fallback:!0}}}function Is(e,o,t=!1){let n=-1,s=-1;for(let i=0;i<e.list.length;i++){let r=e.list[i];r.bLo<o.lo||r.bLo>o.hi||(n<0&&(n=i),s=i)}let d=[];for(let i=n;i>=0&&i<=s;i++){let r=e.list[i],l=!t&&i===n?r.inlineStart<0?r.to:r.inlineStart:r.from,u=!t&&i===s?r.inlineEnd<0?r.from:r.inlineEnd:r.to;for(let b=l;b<u;b++)d.push(e.units[b]);i<s&&d.push(e.units[r.next])}return d}var ut=e=>!!e&&e.nodeType===1,Ln=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function Es(e){for(let o of e)if(Ln.has(o.tagName))return!0;return!1}function ul(e,o,t){let n=null;for(let s of o.childNodes)if(!(!ut(s)||!t(s)||!s.isEqualNode(e))){if(n)return null;n=s}if(!n)return null;for(let s of e.parentNode.childNodes)if(s!==e&&s.isEqualNode(e))return null;return n}var Io="[id],[data-id],script,head>*";function Cs(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=fo(t,e);if(n)return"merge:"+n.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?br(t,o):null}}function Jo(e,o,t,n){let s=n.ignored,d=n.stats||Fn(),i=Ws({ignored:s,ignoreAttribute:n.ignoreAttribute,stats:d}),{unitsOf:r,meta:l}=i,u=n.baseURI,b=n.mergeTags!==null,a=Cs(n.mergeTags,u),h=I=>q=>{let te=a(q);return te!==null?te:I(q)},p=h(n.identity.base),v=h(n.identity.local),O=h(n.identity.remote),m=n.authored||n.identity,c=I=>I&&I.nodeType===9?I.documentElement:I,g=c(e),P=c(o),T=c(t),x=globalThis.__hyperMorphProfile,A=x?performance.now():0,E=I=>I===kn?Io:null,S=n.scope||null,N=S?S.baseDropped:new Set,C=new Set,j=S?S.remoteDropped:new Set,D=S?S.baseIndex:Uo(g,p,s,E(n.identity.base),N),B=n.localIsBase||g===P?null:Uo(P,v,s,E(n.identity.local),C),w=S?S.remoteIndex:Uo(T,O,s,E(n.identity.remote),j),y=I=>{let q=ut(I)&&v(I);return q&&B?.get(q)===I&&!D.has(q)?q:null},$=I=>{let q=ut(I)&&O(I);return q&&w.get(q)===I&&!D.has(q)?q:null},U=B?as(g,P,{analyzer:i,baseIndex:D,sideIndex:B,baseId:m.base,sideId:m.local,baseKey:p,sideKey:v,baseDropped:N,sideDropped:C,stats:d}):Vr(),V=as(g,T,{analyzer:i,baseIndex:D,sideIndex:w,baseId:m.base,sideId:m.remote,baseKey:p,sideKey:O,baseDropped:N,sideDropped:j,stats:d,scope:S,comparisons:n.comparisons});if(S){if(!S.held(V))return null;for(let I of S.dropped)is(I)}let Ne=null;function Ae(I){if(!Ne){Ne=new WeakMap;let q=[g];for(;q.length;){let te=q.pop();te.tagName==="TEMPLATE"&&te.content&&Ne.set(te.content,te);for(let me of i.childrenOf(te))me.nodeType===1&&q.push(me)}}return Ne.get(I)||null}let De=I=>{let q=ut(I)||I.nodeType?I.parentNode:I.parent;return q&&q.nodeType===11?Ae(q):q};if(V.moved.size){let I=!1;for(let q of Array.from(V.moved))!ut(q)||V.identityPaired.has(q)||!m.base(q)||R(V,De(q))||(V.unpair(q),I=!0);I&&V.rematch()}Me(),M(U,V),M(V,U);for(let I of[U,V])if(I.refused)for(let q of I.refused)I.moved.has(q)||d.ambiguousMoves++;x&&(x.alignTotal=(x.alignTotal||0)+(performance.now()-A),A=performance.now());let oe=g.ownerDocument.implementation.createHTMLDocument(""),xe=new WeakMap,$e=new WeakMap,ae=[],k=[],_=new Set,re=[],Z=new Set,Be=new Set,Ke=new Set,Te=new WeakMap,it=null,et=n.lineage?.locals.length?rr():null,mt=I=>{let q=Fo(I);return q&&et&&et.consume(I.local),q},Ze=n.conflicts||"remote",ft=I=>ae.push(I),Ct=I=>ae.push(I),Dt=Or({roots:{base:g,local:P,remote:T},L:U,R:V,unitsOf:r,provenance:xe,policy:Ze}),Tt=(I,q)=>{k.push(I),q&&Dt.note(I,q)},Rt=null,jt=null,qt=ge(),un=null,Lt=Q(g,U.map.get(g),V.map.get(g),!!n.localIsBase,!!n.childrenOnly);Lt.tagName==="HTML"?oe.replaceChild(Lt,oe.documentElement):oe.body.appendChild(Lt),Rt?.drain(Lt),jt?.drain(Lt),x&&(x.build=(x.build||0)+(performance.now()-A));let Jt=n.childrenOnly?!He(Ie(Lt),Ie(T)):!fe(Lt,T),F=Dt.finish(Lt),ce=et?ir({locals:n.lineage.locals,rec:et,root:Lt,provenance:xe,segments:re,ignored:s}):null;return{doc:oe,root:Lt,provenance:xe,textMappers:$e,decisions:ae,conflicts:k,recoveryLinks:F,localDiverged:Jt,mergedScripts:_,segments:re,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==kn,L:U,R:V,stats:d,lineage:ce};function ge(){let I=new Map,q=new Set;if(n.localIsBase||!U.insertedByHash)return{partner:I,drop:q};let te=U.insertedByHash(),me=V.insertedByHash();if(!te.size||!me.size)return{partner:I,drop:q};let we={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},ie=dt=>{let Qe=0;for(let Mt=dt.parentNode;Mt;Mt=Mt.parentNode)Qe++;return Qe},ee=[],Ee=dt=>{let Qe=dt.textContent.trim();return Qe.split(/\s+/).length>=3||Qe.replace(/\s/g,"").length>=12},Ue=dt=>{let Qe=R(U,dt),Mt=R(V,dt);return Qe&&U.reverse.get(Qe.parentNode)!==dt.parentNode||Mt&&V.reverse.get(Mt.parentNode)!==dt.parentNode},_e=(dt,Qe,Mt)=>{for(let Ht of Mt.parentNode.children){let pn=Ht!==Mt&&dt.reverse.get(Ht);if(pn&&Ue(pn))return!0}let bt=dt.reverse.get(Mt.parentNode);if(bt){for(let Ht of bt.children)if(!R(Qe,Ht)&&!s(Ht))return!0}return!1},Ye=new Map([[U,new Map],[V,new Map]]),yt=(dt,Qe)=>{let Mt=Ye.get(dt),bt=Mt.get(Qe);if(bt===void 0){bt=!1;for(let Ht of Qe.children)if(dt.reverse.has(Ht)||yt(dt,Ht)){bt=!0;break}Mt.set(Qe,bt)}return bt},gt=new Map;for(let dt of me.values())for(let Qe of dt){let Mt=$(Qe);Mt&>.set(Mt,Qe)}for(let dt of te.values())for(let Qe of dt){let Mt=y(Qe),bt=Mt?gt.get(Mt):null;bt&&bt.tagName===Qe.tagName&&!jn(Qe,we)&&!jn(bt,we)&&!n.remoteWins(Qe)&&!n.remoteWins(bt)&&ee.push([Qe,[bt],ie(Qe),!0,!0])}for(let[dt,Qe]of te){let Mt=me.get(dt);if(!Mt)continue;let bt=Qe.length===1&&Mt.length===1;for(let Ht of Qe)!jn(Ht,we)&&!y(Ht)&&ee.push([Ht,Mt,ie(Ht),bt&&(Ee(Ht)||_e(U,V,Ht)||_e(V,U,Mt[0]))])}if(!ee.length)return{partner:I,drop:q};ee.sort((dt,Qe)=>dt[2]-Qe[2]);let $t=new Set,_t=new Set,dn=dt=>{for(let Qe of dt.querySelectorAll("*"))$t.add(Qe)},vt=(dt,Qe)=>dt.reverse.get(Qe.parentNode)||null;for(let[dt,Qe,,Mt,bt]of ee){if($t.has(dt)||_t.has(dt)||bt&&(yt(U,dt)||yt(V,Qe[0])))continue;let Ht=vt(U,dt),pn=wn=>!_t.has(wn)&&!$t.has(wn)&&(bt||wn.tagName===dt.tagName&&!$(wn)&&i.equalUnits(dt,wn)),sn=Qe.find(wn=>Ht&&vt(V,wn)===Ht&&pn(wn))||(Mt?Qe.find(pn):null);if(!sn)continue;_t.add(dt),_t.add(sn);let Zt=Ht&&vt(V,sn)===Ht;(!bt||!Zt||i.equalUnits(dt,sn))&&(dn(dt),dn(sn)),!Zt&&(I.set(dt,sn),I.set(sn,dt),q.add(Ze==="local"?sn:dt))}return{partner:I,drop:q}}function Le(I,q,te){if(Z.add(I),qt.drop.has(I))return null;Z.add(te);let me=q==="local"?I:te,we=q==="local"?te:I,ie;return i.equalUnits(me,we)?(ie=se(me,"local",!0),xe.get(ie).remote=we):ie=pe(me,we),Tt({kind:"structure",el:ie,detail:"both-moved",base:null,local:me,remote:we},{unit:{b:null,l:me,r:we}}),ft({kind:"insert",el:ie,source:"both"}),ie}function Me(){if(!U.weak||!V.weak||!U.weak.size||!V.weak.size||!U.unpair)return;let I=new Map;for(let te of U.weak){let me=R(U,te);ut(te)&&ut(me)&&I.set(i.unitHash(me),te)}let q=!1;for(let te of Array.from(V.weak)){let me=R(V,te);if(!ut(te)||!ut(me))continue;let we=I.get(i.unitHash(me));if(!we||we===te||!U.weak.has(we)||R(U,te)&&R(V,we))continue;let ie=R(U,we);ie.tagName===me.tagName&&i.equalUnits(ie,me)&&(U.unpair(we),V.unpair(te),q=!0)}q&&(U.rematch(),V.rematch())}function M(I,q){if(!I.weak||!I.weak.size||!q.insertedByHash)return;let te=q.insertedByHash();if(!te.size)return;let me=!1;for(let we of Array.from(I.weak)){let ie=R(I,we);if(!ie)continue;let ee=I===U?y(ie):$(ie);if(ee){let Ue=(I===U?w:B)?.get(ee);Ue&&Ue.tagName===ie.tagName&&!q.reverse.has(Ue)&&(I.unpair(we),me=!0);continue}let Ee=te.get(i.unitHash(ie));Ee&&Ee.some(Ue=>Ue.tagName===ie.tagName&&i.equalUnits(Ue,ie))&&(I.unpair(we),me=!0)}me&&I.rematch()}function R(I,q){if(!q)return null;if(I.map.has(q))return I.map.get(q);let te=[],me=De(q);for(;me&&!I.map.has(me);me=De(me))te.push(me);let we=me;if(!we||!I.identical.has(we))return null;I.pairIdenticalChildren(we);for(let ee=te.length-1;ee>=0;ee--)I.pairIdenticalChildren(te[ee]);let ie=I.map.get(q)||null;return ie&&d.lazyTwins++,ie}function z(I,q,te,me){if(ut(I)&&Ln.has(I.tagName)&&!U.identical.has(I)&&(I.previousSibling?.nodeType===3||I.nextSibling?.nodeType===3)){let Ee=De(I),Ue=R(U,I),_e=R(V,I);Ue&&_e&&Wt(Ue,R(U,Ee),U)&&!Wt(_e,R(V,Ee),V)&&(jt||=Cr({L:U,R:V,twinIn:R,unitsOf:r,view:J,parentOf:De,ignored:s,remoteWins:n.remoteWins,eligible:Ye=>ut(Ye)&&Ln.has(Ye.tagName),build:Q,out:oe,policy:Ze,provenance:xe,textMappers:$e,segments:re,conflicts:k,conflict:Tt,decisions:ae}),jt.ensureOwner(I))}if(q===null)return null;if(me!==void 0)return Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(I,q,te,!!me),me&&(Rt.produced(I,me),Be.add(I)),me;if(Be.has(I)||Ke.has(I))return Tt({kind:"structure",el:null,detail:"both-moved",base:I},{subject:I}),Be.has(I)?null:se(te,q);Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(I,q,te,!0);let we=R(U,I),ie=R(V,I);(!we||!ie)&&Tt({kind:"structure",el:null,detail:"move-beats-delete",base:I},{subject:I,deleted:we?"remote":"local"});let ee=Q(I,we,ie,!1);return(q==="local"?ft:Ct)({kind:"move",el:ee,source:q}),ee}function J(I,q,te,me){return me||!q||q===te?{el:te,asBase:!0,twin:we=>we,baseOf:we=>we,units:r(te),here:()=>!0,parentOfTwin:()=>te}:{el:q,asBase:!1,twin:we=>R(I,we),baseOf:we=>I.reverse.get(we),units:r(q),here:we=>ut(we)?we.parentNode===q||q.tagName==="TEMPLATE"&&we.parentNode===q.content:we.parent===q||q.tagName==="TEMPLATE"&&we.parent===q.content}}function ne(I,q,te){return!q||te&&te.identical.has(I)?!1:ut(I)?!i.equalUnits(I,q)||!je(I,q,te):I.value!==q.value}function je(I,q,te){if(!te||I===q)return!0;let me=[[I,q]];for(;me.length;){let[we,ie]=me.pop(),ee=r(we),Ee=r(ie);for(let Ue=0;Ue<ee.length&&Ue<Ee.length;Ue++){let _e=ee[Ue],Ye=Ee[Ue];if(!ut(_e)||!ut(Ye))continue;let yt=te.map.get(_e);if(yt!==void 0&&yt!==Ye)return!1;let gt=te.reverse.get(Ye);if(gt!==void 0&>!==_e)return!1;me.push([_e,Ye])}}return!0}function Q(I,q,te,me,we=!1){let ie=me||(te?n.remoteWins(te):n.remoteWins(I)),ee=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?oe.createElementNS(I.namespaceURI,I.tagName):oe.createElement(I.tagName),Ee={base:I,local:q||null,remote:te||null};if(xe.set(ee,Ee),ie&&!me&&q&&ne(I,q,U)&&(!te||!i.equalUnits(q,te))&&Tt({kind:"structure",el:ee,detail:"remote-wins",base:I,local:q,remote:te||null},{subject:I}),Z.add(I),Be.add(I),q&&Z.add(q),te&&Z.add(te),n.skipUnchanged&&!we&&(n.localIsBase||U.identical.has(I))&&te&&V.identical.has(I)&&!n.remoteWins(I)){Ee.unchanged=!0;for(let _e of I.attributes)_e.namespaceURI?ee.setAttributeNS(_e.namespaceURI,_e.name,_e.value):ee.setAttribute(_e.name,_e.value);return Rt?.produced(I,ee),ee}Ke.add(I),we||Ce(I,ie?I:q,te,ee);let Ue=I.tagName;if(mn(I))Ve(I,ie?I:q,te,ee);else if(Ue==="TEXTAREA")ee.textContent=Oe(I.textContent,(ie?I:q)?(ie?I:q).textContent:I.textContent,te?te.textContent:I.textContent,ee,"text");else if(!jt?.render(I,ee)){let _e=ke(I,q,te,ie,ee),Ye=Ue==="TEMPLATE"&&ee.content?ee.content:ee;for(let yt of _e)Ye.appendChild(yt)}return Ke.delete(I),Rt?.produced(I,ee),ee}function Oe(I,q,te,me,we){if(q===te)return q;if(q===I)return te!==I&&Ct({kind:we,node:me,source:"remote"}),te;if(te===I)return ft({kind:we,node:me,source:"local"}),q;let ie=Ze==="local"?q:te;return Tt({kind:we,node:me,base:I,local:q,remote:te,resolved:ie},{site:"whole",el:me}),ae.push({kind:we,node:me,source:"both"}),ie}function Ve(I,q,te,me){let we=I.textContent,ie=q?q.textContent:we,ee=te?te.textContent:we,Ee=b?fo(I,n.mergeTags,!0):null;if(Ee&&ie!==ee){let Ue=te&&te.getAttribute("merge-key")||I.getAttribute("merge-key"),{text:_e,warnings:Ye}=Go(n.localIsBase?void 0:we,ie,ee,{parse:Ee.recognizer.parse,keyCandidates:Ue?Ue.split(/[\s,]+/).filter(Boolean):void 0});for(let yt of Ye)console.warn(`[hyper-morph] merge "${Ee.raw}": ${yt}`);me.textContent=_e,_.add(me),_e!==ee?ft({kind:"text",node:me,source:_e===ie?"local":"both"}):_e!==we&&Ct({kind:"text",node:me,source:"remote"});return}me.textContent=Oe(we,ie,ee,me,"text")}function Ce(I,q,te,me){let we=new Map;for(let ie of[I,q,te])if(ie)for(let ee of ie.attributes)n.ignoreAttribute(ie,ee.name)||we.set(ee.name,ee);for(let[ie,ee]of we){let Ee=I?I.getAttribute(ie):null,Ue=q?q.getAttribute(ie):Ee,_e=te?te.getAttribute(ie):Ee,Ye;Ue===_e?Ye=Ue:Ue===Ee?(Ye=_e,Ct({kind:"attr",el:me,name:ie,source:"remote"})):_e===Ee?(Ye=Ue,ft({kind:"attr",el:me,name:ie,source:"local"})):(Ye=be(ie,Ee,Ue,_e),Ye===void 0&&(Ye=Ze==="local"?Ue:_e,Tt({kind:"attr",el:me,name:ie,base:Ee,local:Ue,remote:_e,resolved:Ye},{el:me,sample:ee})),ae.push({kind:"attr",el:me,name:ie,source:"both"})),Ye!=null&&(ee.namespaceURI?me.setAttributeNS(ee.namespaceURI,ee.name,Ye):me.setAttribute(ie,Ye))}}function be(I,q,te,me){if(I==="class"){let we=_e=>new Set((_e||"").split(/\s+/).filter(Boolean)),ie=we(q),ee=we(te),Ee=we(me),Ue=new Set;for(let _e of new Set([...ie,...ee,...Ee])){let Ye=ie.has(_e),yt=ee.has(_e),gt=Ee.has(_e);(yt===gt?yt:yt===Ye?gt:yt)&&Ue.add(_e)}return[...Ue].join(" ")}if(I==="style"){let we=Ye=>{let yt=new Map;if(!Ye)return yt;let gt=0,$t=null,_t="",dn=()=>{let vt=_t.indexOf(":");vt>0&&yt.set(_t.slice(0,vt).trim(),_t.slice(vt+1).trim()),_t=""};for(let vt of Ye){if($t){_t+=vt,vt===$t&&($t=null);continue}if(vt==='"'||vt==="'"){$t=vt,_t+=vt;continue}if(vt==="("?gt++:vt===")"&>--,vt===";"&>===0){dn();continue}_t+=vt}return _t.trim()&&dn(),yt},ie=we(q),ee=we(te),Ee=we(me),Ue=new Map,_e=!1;for(let Ye of new Set([...ie.keys(),...ee.keys(),...Ee.keys()])){let yt=ie.get(Ye)??null,gt=ee.get(Ye)??null,$t=Ee.get(Ye)??null,_t;gt===$t?_t=gt:gt===yt?_t=$t:$t===yt?_t=gt:(_t=Ze==="local"?gt:$t,_e=!0),_t!=null&&Ue.set(Ye,_t)}return _e?void 0:[...Ue].map(([Ye,yt])=>`${Ye}: ${yt}`).join("; ")}}function H(I,q,te,me){let we=I.value,ie=me?we:q?q.value:"",ee=te?te.value:"";Z.add(I),q&&Z.add(q),te&&Z.add(te);let Ee=ro(we,ie,ee,Ze),Ue=Ee.text===""?null:oe.createTextNode(Ee.text);Ue&&(xe.set(Ue,{base:I.nodes,local:q?q.nodes:null,remote:te?te.nodes:null}),$e.set(Ue,Ee.mapLocalOffset)),ie!==we&&ee!==we?ae.push({kind:"text",node:Ue,source:"both"}):ie!==we?ft({kind:"text",node:Ue,source:"local"}):ee!==we&&Ct({kind:"text",node:Ue,source:"remote"});for(let _e of Ee.conflicts)Tt({kind:"text",node:Ue,base:we.slice(_e.bs,_e.be),local:_e.local,remote:_e.remote,resolved:_e.resolved},{site:"run",bRun:I,lRun:q,rRun:te,node:Ue,c:_e});return Ue}function X(I,q){return _n(I,q).every(te=>te.bs===te.be)}function de(I,q){let te=I?I.value:"",me=q?q.value:"",we;if(te===me||!me?we=te:te?X(te,me)?we=me:X(me,te)?we=te:(we=Ze==="local"?te:Ze==="both"?te+me:me,Tt({kind:"structure",el:null,detail:"insert-collision",local:te,remote:me,resolved:we},{unit:{b:null,l:I,r:q},localLost:Ze==="remote"})):we=me,I&&Z.add(I),q&&Z.add(q),we==="")return null;let ie=oe.createTextNode(we);return xe.set(ie,{base:null,local:I?I.nodes:null,remote:q?q.nodes:null}),te?ft({kind:"insert",el:ie,source:me&&te===me?"both":"local"}):Ct({kind:"insert",el:ie,source:"remote"}),ie}function pe(I,q){let te={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},me=Ee=>r(Ee).every(Ue=>ut(Ue)?jn(Ue,te):Ue.kind==="text"),we=null;if(me(I)&&me(q)){let Ee=I.textContent,Ue=q.textContent;Ee===Ue||X(Ue,Ee)?we=q:X(Ee,Ue)&&(we=I)}if(!we){let Ee=Ze==="local",Ue=se(Ee?I:q,Ee?"local":"remote",!0),_e=xe.get(Ue);return Ee?_e.remote=q:_e.local=I,Tt({kind:"structure",el:Ue,detail:"insert-collision",local:I,remote:q,resolved:Ee?I:q},{unit:{b:null,l:I,r:q},localLost:!Ee}),Ue}let ie=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?oe.createElementNS(I.namespaceURI,I.tagName):oe.createElement(I.tagName);Ce(null,I,q,ie),xe.set(ie,{base:null,local:I,remote:q}),Z.add(I),Z.add(q);let ee=mt({base:Array.from(we.childNodes),local:Array.from(I.childNodes),remote:Array.from(q.childNodes),out:oe,policy:Ze,idOf:{local:v,remote:O},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:xe,textMappers:$e,conflicts:k,conflict:Tt,scope:{base:null,local:I,remote:q,units:[],at:0},synthetic:!0,decisions:ae,node:ie});re.push(...ee.segments);for(let Ee of ee.nodes)ie.appendChild(Ee);return ie}function se(I,q,te=!1){if(!te&&ut(I)){let ee=qt.partner.get(I);if(ee)return Le(I,q,ee)}if(!ut(I)){if(I.value==="")return null;let ee=I.kind==="comment"?oe.createComment(I.value):oe.createTextNode(I.value);return xe.set(ee,{base:null,local:q==="local"?I.nodes:null,remote:q==="remote"?I.nodes:null}),Z.add(I),ee}let me=I.namespaceURI&&I.namespaceURI!=="http://www.w3.org/1999/xhtml"?oe.createElementNS(I.namespaceURI,I.tagName):oe.createElement(I.tagName);for(let ee of I.attributes)ee.namespaceURI?me.setAttributeNS(ee.namespaceURI,ee.name,ee.value):me.setAttribute(ee.name,ee.value);xe.set(me,{base:null,local:q==="local"?I:null,remote:q==="remote"?I:null}),Z.add(I);let we=I.tagName==="TEMPLATE"&&me.content?me.content:me,ie=q==="local"?U:V;for(let ee of r(I)){let Ee=ut(ee)?ie.reverse.get(ee):null;if(Ee&&z(Ee,null,null),Ee&&Be.has(Ee)){Tt({kind:"structure",el:null,detail:"both-moved",base:Ee},{subject:Ee});continue}if(Ee&&!Ke.has(Ee)){let _e=R(U,Ee)||null,Ye=R(V,Ee)||null;if(_e||Ye){Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(Ee,q,ee,!0);let yt=Q(Ee,_e,Ye,!1);q==="local"?ft({kind:"move",el:yt,source:"local"}):Ct({kind:"move",el:yt,source:"remote"}),we.appendChild(yt);continue}}let Ue=se(ee,q);Ue&&we.appendChild(Ue)}if(!te&&qt.drop.size&&I.tagName==="DIV"&&!we.firstChild&&!I.attributes.length&&!(q==="local"?v(I):O(I))&&!ie.reverse.has(I)&&!s(I)&&!n.remoteWins(I)){let ee=I.firstChild;if(ee&&ee===I.lastChild&&ut(ee)&&(qt.drop.has(ee)||un?.has(ee)))return(un||=new WeakSet).add(I),null}return me}function ke(I,q,te,me,we){q&&U.identical.has(I)&&U.pairIdenticalChildren(I),te&&V.identical.has(I)&&V.pairIdenticalChildren(I);let ie=J(U,q,I,me),ee=J(V,te,I,!1),Ee=r(I),Ue=new Set(Ee),_e=new Map;for(let le=0;le<Ee.length;le++)_e.set(Ee[le],le);let Ye=[],yt=new Set,gt=new Map,$t=new Set,_t=et&&[],dn=et&&[],vt=new Set,dt=[],Qe=null;if(!ie.asBase&&!ee.asBase&&!U.identical.has(I)&&!V.identical.has(I))for(let le of Ee){if(!ut(le)||!Ln.has(le.tagName))continue;let ze=ie.twin(le),qe=ee.twin(le);ze&&qe&&(!ie.here(ze)||!ee.here(qe))&&z(le,null,null)}vo();let Mt=le=>{let ze=[];for(let qe of le.units){if(vt.has(qe))continue;let st=le.baseOf(qe);st&&Ue.has(st)&&ze.push(st)}return ze},bt=le=>Mt(le).map(ze=>_e.get(ze)),Ht=le=>le.every((ze,qe)=>qe===0||ze>=le[qe-1]),pn=!ie.asBase&&!Ht(bt(ie)),sn=!ee.asBase&&!Ht(bt(ee));pn&&sn&&Tt({kind:"structure",el:we,detail:"both-reordered",base:I},{subject:I,lKept:Mt(ie),rKept:Mt(ee)});let Zt=sn||!pn?{V:ee,A:V,side:"remote",other:ie,otherA:U,otherSide:"local"}:{V:ie,A:U,side:"local",other:ee,otherA:V,otherSide:"remote"};pn?ft({kind:"move",el:null,source:sn?"both":"local",base:I}):sn&&Ct({kind:"move",el:null,source:"remote",base:I});let wn=ie.asBase?[]:ie.units.filter(le=>!ie.baseOf(le)&&!vt.has(le)&&!qt.partner.has(le)),On=ee.asBase?[]:ee.units.filter(le=>!ee.baseOf(le)&&!vt.has(le)&&!qt.partner.has(le)),In=new Map;if(wn.length&&On.length){let le=new Map,ze=new Map;for(let Ge of On){if(ut(Ge)){let St=O(Ge);St&&le.set(St,Ge)}let Xe=i.unitHash(Ge);ze.has(Xe)||ze.set(Xe,[]),ze.get(Xe).push(Ge)}let qe=(Ge,Xe)=>{let St=Ge.units.indexOf(Xe);for(let tt=St-1;tt>=0;tt--){let wt=Ge.baseOf(Ge.units[tt]);if(wt)return wt}return"start"},st=new Map,At=new Map;for(let Ge of On){let Xe=qe(ee,Ge);ut(Ge)?(At.has(Xe)||At.set(Xe,[]),At.get(Xe).push(Ge)):Ge.kind==="text"&&!st.has(Xe)&&st.set(Xe,Ge)}for(let Ge of wn){let Xe=null;if(ut(Ge)){let tt=v(Ge);tt&&le.has(tt)&&!In.has(le.get(tt))&&(Xe=le.get(tt))}else if(Ge.kind==="text"){let tt=st.get(qe(ie,Ge));tt&&!In.has(tt)&&(Xe=tt)}let St=!!y(Ge);if(!Xe&&!St){let tt=ze.get(i.unitHash(Ge));tt&&(Xe=tt.find(wt=>!In.has(wt)&&ut(wt)===ut(Ge)&&(ut(wt)?wt.tagName===Ge.tagName&&!$(wt):wt.kind===Ge.kind)&&i.equalUnits(Ge,wt))||null)}if(!Xe&&ut(Ge)&&!St){let tt=m.local(Ge),wt=(At.get(qe(ie,Ge))||[]).filter(lt=>{let zt=m.remote(lt);return!In.has(lt)&<.tagName===Ge.tagName&&!$(lt)&&!(tt&&zt&&tt!==zt)&&i.similar(Ge,lt)});wt.length===1&&(Xe=wt[0])}Xe&&(In.set(Xe,Ge),In.set(Ge,Xe))}}let Lo=le=>{if(jt?.consumes(le))return null;if(Z.has(le)||Rt?.has(le))return gt.get(le)||null;let ze=ie.twin(le),qe=ee.twin(le),st=ze&&!ie.asBase&&!ie.here(ze),At=qe&&!ee.asBase&&!ee.here(qe);if(st||At){if((!ze||!qe)&&Tt({kind:"structure",el:null,detail:"move-beats-delete",base:le},{subject:le,deleted:ze?"remote":"local"}),!ot(le))return ut(le)?(Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),st&&Rt.plan(le,"local",ze),At&&Rt.plan(le,"remote",qe)):Z.add(le),null;Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le})}if(ze&&!qe&&!ie.asBase&&!ee.asBase&&ut(le)&&Ln.has(le.tagName)&&!n.remoteWins(le)&&!n.remoteWins(ze)&&ne(le,ze,U)&&ul(le,Ie(ee.el),s)){let wt={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},lt=zt=>ut(zt)?jn(zt,wt):zt.kind==="text";if(r(le).every(lt)&&r(ze).every(lt)){let zt=mt({base:[le],local:[ze],remote:[],blocks:new Set([le,ze]),out:oe,policy:Ze,L:U,R:V,idOf:{base:p,local:v,remote:O},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(en,Tn,Kn)=>Q(en,Tn,Kn,!1),cloneUnit:se,mergeAttrs:Ce,atomKey:i.exactUnitKey,moveIn:z,moveBuilt:z,movePlanned:z,provenance:xe,textMappers:$e,conflicts:k,conflict:Tt,scope:{base:I,local:ie.el,remote:ee.el,units:Ee,at:_e.get(le)},decisions:ae,node:we});re.push(...zt.segments),Z.add(le),Z.add(ze);let Et=oe.createDocumentFragment();for(let en of zt.nodes)Et.appendChild(en);return gt.set(le,Et),gt.set(ze,Et),Et}}if(!ze&&!qe)return Z.add(le),Ct({kind:"remove",source:"both",base:le}),null;if(!ze&&!ne(le,qe,V))return Z.add(le),ft({kind:"remove",source:"local",base:le}),null;if(!qe&&!ne(le,ze,U))return Z.add(le),Ct({kind:"remove",source:"remote",base:le}),et&&(et.remove(ze),_t.push({bk:le,lk:ze})),null;let Ge=!ze||!qe,Xe=ie.asBase?R(U,le)||null:ze,St=ee.asBase&&ut(le)&&(V.identityPaired.has(le)||!m.base(le))&&R(V,le)||qe,tt;return ut(le)?tt=Q(le,Xe,St,ie.asBase):le.kind==="comment"?tt=Je(le,Xe,qe,ie.asBase):tt=H(le,Xe,qe,ie.asBase),Z.add(le),tt&&(gt.set(le,tt),ze&>.set(ze,tt),qe&>.set(qe,tt),Ge&&(Tt({kind:"structure",el:tt,detail:"edit-beats-delete",base:le},{subject:le,deleted:ze?"remote":"local"}),ze?ft({kind:"insert",el:tt,source:"local"}):Ct({kind:"insert",el:tt,source:"remote"}))),tt},yo=(le,ze,qe,st)=>{if(jt?.consumes(le))return null;if(Z.has(le))return gt.get(le)||null;let At=ze.baseOf(le);if(At&&Ue.has(At))return vt.has(At)&&!vt.has(le)?Gn(At,le,st):Lo(At);if(At)return Ro(At,le,st);let Ge=In.get(le);if(Ge){let St=st==="local"?le:Ge,tt=st==="local"?Ge:le,wt;return ut(St)?i.equalUnits(St,tt)?(wt=se(St,"local"),wt&&(xe.get(wt).remote=tt)):wt=pe(St,tt):wt=de(St,tt),Z.add(St),Z.add(tt),wt&&(gt.set(St,wt),gt.set(tt,wt),ut(St)&&ft({kind:"insert",el:wt,source:"both"})),wt}let Xe=se(le,st);return Xe&&(gt.set(le,Xe),st==="local"?ft({kind:"insert",el:Xe,source:"local"}):(Ct({kind:"insert",el:Xe,source:"remote"}),et&&ut(le)&&!qt.partner.has(le)&&dn.push({su:le,node:Xe}))),Xe},Gn=(le,ze,qe)=>{let st;return ut(le)?(st=z(le,qe,ze),st&&Z.add(ze)):(st=se(ze,qe),Z.add(ze),st&&(qe==="local"?ft:Ct)({kind:"insert",el:st,source:qe})),st&>.set(ze,st),st},Ro=(le,ze,qe)=>{z(le,null,null);let At=R(qe==="local"?V:U,le),Ge=ze,Xe=At?Wt(At,qe==="local"?te:q,qe==="local"?V:U):!1,St=At&&!Xe&&!Ut(le,At);if(St&&qe===Zt.otherSide)return Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le}),null;if(St&&Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le}),At||Tt({kind:"structure",el:null,detail:"move-beats-delete",base:le},{subject:le,deleted:qe==="local"?"remote":"local"}),Ke.has(le)){Tt({kind:"structure",el:null,detail:"both-moved",base:le},{subject:le});let wt=se(Ge,qe);return wt&>.set(ze,wt),wt}ut(le)&&(Rt||=po(xe,De,U,V,R,Q,s,n.remoteWins,k,Tt,ne,P,T),Rt.plan(le,qe,Ge,!0));let tt=ut(le)?Q(le,qe==="local"?Ge:R(U,le)||null,qe==="remote"?Ge:R(V,le)||null,!1):null;return tt&&(gt.set(le,tt),gt.set(ze,tt),At&>.set(At,tt),qe==="local"?ft({kind:"move",el:tt,source:"local"}):Ct({kind:"move",el:tt,source:"remote"})),tt};for(let le of Zt.V.units){if(vt.has(le)){if(Qe?.has(le)){for(let st of Qe.get(le))yt.has(st)||(Ye.push(st),yt.add(st));continue}let qe=gt.get(le);yt.has(qe)||(Ye.push(qe),yt.add(qe));continue}if(Z.has(le)&&!(gt.get(le)&&yt.has(gt.get(le)))){let qe=Zt.V.baseOf(le);qe&&!Ue.has(qe)&&Tt({kind:"structure",el:null,detail:"both-moved",base:qe},{subject:qe});continue}let ze=yo(le,Zt.V,Zt.A,Zt.side);ze&&!yt.has(ze)&&(Ye.push(ze),yt.add(ze),!Zt.V.baseOf(le)&&!In.has(le)&&!vt.has(le)&&$t.add(ze))}for(let le of dt)yt.has(le.frag)||(Ye.splice(le.previous&&yt.has(le.previous)?Ye.indexOf(le.previous)+1:xo(le.at),0,le.frag),yt.add(le.frag));if(!Zt.other.asBase){let le=Zt.other,ze=Zt.otherSide,qe=Zt.otherA,st=null,At=0,Ge=null;for(let Xe of le.units){let St=gt.get(Xe);if(St&&yt.has(St)){st=St,Ge=null;continue}if(Z.has(Xe)){let lt=le.baseOf(Xe);lt&&!Ue.has(lt)&&Tt({kind:"structure",el:null,detail:"both-moved",base:lt},{subject:lt});continue}let tt=yo(Xe,le,qe,ze);if(!tt)continue;let wt;if(Ge)wt=Ye.indexOf(Ge)+1;else if(st){if(wt=Ye.indexOf(st)+1,ze==="remote")for(;wt<Ye.length&&$t.has(Ye[wt]);)wt++}else wt=At++;Ye.splice(wt,0,tt),yt.add(tt),Ge=tt}}for(let le=0;le<Ee.length;le++){let ze=Ee[le];if(Z.has(ze))continue;let qe=Lo(ze);qe&&Ye.splice(xo(le),0,qe)}return et&&_t.length&&dn.length&&es(),Ye;function es(){if(pn||sn)return;let le=new Set(Ye),ze=lt=>lt&&Ue.has(lt)&&le.has(gt.get(lt))?lt:null,qe=(lt,zt)=>{let Et=[{prev:null,units:[]}];for(let en of lt){let Tn=ze(zt(en));Tn?Et.push({prev:Tn,units:[]}):Et[Et.length-1].units.push(en)}return Et},st=qe(Ee,lt=>lt),At=qe(ee.units,ee.baseOf),Ge=ie.asBase?null:qe(ie.units,ie.baseOf),Xe=lt=>lt.length===st.length&<.every((zt,Et)=>zt.prev===st[Et].prev);if(!Xe(At)||Ge&&!Xe(Ge))return;let St=new Map(_t.map(lt=>[lt.bk,lt])),tt=new Map(dn.map(lt=>[lt.su,lt])),wt=lt=>lt?Ye.indexOf(gt.get(lt)):-1;for(let lt=0;lt<st.length;lt++){if(st[lt].units.length!==1||At[lt].units.length!==1)continue;let zt=St.get(st[lt].units[0]),Et=tt.get(At[lt].units[0]);if(!zt||!Et||Ge&&(Ge[lt].units.length!==1||Ge[lt].units[0]!==zt.lk))continue;let en=wt(st[lt].prev);(lt+1<st.length?wt(st[lt+1].prev):Ye.length)-en!==2||Ye[en+1]!==Et.node||Wn(zt.bk,zt.lk,Et.su)&&et.link(zt.lk,Et.node)}}function ko(le,ze,qe,st){let At=Et=>{let en=Et.filter(ut);return en.length===1?en[0]:null},Ge=At(le),Xe=At(ze),St=At(qe);if(!Ge||!Xe||!St)return;let tt=le.indexOf(Ge);if(ze.indexOf(Xe)!==tt||qe.indexOf(St)!==tt||le.length!==ze.length||le.length!==qe.length)return;for(let Et=0;Et<le.length;Et++)if(Et!==tt&&(le[Et].value!==ze[Et].value||le[Et].value!==qe[Et].value))return;if((ie.asBase?Ge:ie.twin(Ge))!==Xe||ee.twin(Ge)||V.reverse.get(St)||Xe!==Ge&&ne(Ge,Xe,U))return;let wt=st.filter(Et=>Et.nodeType===1);if(wt.length!==1||xe.get(wt[0])?.remote!==St)return;let lt=Et=>Et.map(en=>ut(en)?"":en.value??en.nodeValue).join(""),zt=st.indexOf(wt[0]);lt(st.slice(0,zt))!==lt(le.slice(0,tt))||lt(st.slice(zt+1))!==lt(le.slice(tt+1))||Wn(Ge,Xe,St)&&et.link(Xe,wt[0])}function Wn(le,ze,qe){if(!ut(ze)||!ut(qe)||!ut(le)||ze.namespaceURI!==qe.namespaceURI||ze.localName===qe.localName)return!1;for(let Xe of[ze,qe])if(Xe.tagName==="TEMPLATE"||mn(Xe)||Xe.querySelector("template"))return!1;if(n.remoteWins(le)||n.remoteWins(qe)||s(qe)||ze.attributes.length!==qe.attributes.length)return!1;for(let Xe of ze.attributes)if(qe.getAttributeNS(Xe.namespaceURI,Xe.localName)!==Xe.value)return!1;let st=ze.childNodes,At=qe.childNodes;if(st.length!==At.length)return!1;for(let Xe=0;Xe<st.length;Xe++)if(!st[Xe].isEqualNode(At[Xe]))return!1;let Ge=[[le,qe]];for(;Ge.length;){let[Xe,St]=Ge.pop();if(Xe.children.length!==St.children.length)return!1;for(let tt=0;tt<St.children.length;tt++){let wt=V.reverse.get(St.children[tt]);if(wt!==void 0&&wt!==Xe.children[tt])return!1;Ge.push([Xe.children[tt],St.children[tt]])}}return!0}function xo(le){for(let ze=le-1;ze>=0;ze--){let qe=gt.get(Ee[ze]);if(qe){let st=Ye.indexOf(qe);if(st>=0)return st+1}}return 0}function vo(){if((ie.asBase||U.identical.has(I))&&(ee.asBase||V.identical.has(I)))return;let le={ignored:s,remoteWins:n.remoteWins,inlineCache:Te},ze=at=>ut(at)?jn(at,le):at.kind==="text";if(!ie.asBase&&!ee.asBase)for(let at of Ee){if(!ut(at)||!Ln.has(at.tagName))continue;let rt=ie.twin(at),Pt=ee.twin(at);if(!rt&&Pt||rt&&!Pt){let ct=Br({base:Ee,views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:It=>ut(It)&&Ln.has(It.tagName)&&!s(It)&&!n.remoteWins(It),baseId:m.base,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey});ct&&(ie=ct[0],ee=ct[1]);break}}let qe=!ie.asBase&&!ee.asBase&&Ee.length>=2&&Ln.has(Ee[0].tagName)&&ie.units.length===Ee.length&&ee.units.length===Ee.length?hr({base:Ee,local:ie.units,remote:ee.units,localTwin:ie.twin,remoteTwin:ee.twin,eligible:at=>ut(at)&&Ln.has(at.tagName)&&!s(at)&&!n.remoteWins(at),nodes:{base:Array.from(Ie(I).childNodes),local:Array.from(Ie(ie.el).childNodes),remote:Array.from(Ie(ee.el).childNodes)}}):null,st=null,At=null;if(!qe&&!ie.asBase&&!ee.asBase&&(Es(Ee)||Es(ie.units)||Es(ee.units))){let at={ignored:s,remoteWins:()=>!1},rt=ct=>ze(ct)||ut(ct)&&n.remoteWins(ct)&&vn.has(ct.tagName)&&jn(ct,at),Pt=ct=>ut(ct)?Ln.has(ct.tagName)&&!s(ct)&&!n.remoteWins(ct)&&r(ct).every(rt):ct.kind==="text";st=Dr({onUncertainOwner:ct=>{let It=n.identity.local(ct.local);It&&It===n.identity.remote(ct.remote)||(At||=[]).push(ct)},onUncertainSource:ct=>{it||(it=new Map);let It=it.get(ct.source);It||it.set(ct.source,It=[]);for(let tn of It)if(tn.side===ct.side&&tn.from===ct.from&&tn.to===ct.to)return;It.push(ct)},base:Ee,views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:Pt,ignored:s,remoteWins:n.remoteWins,baseId:m.base,atomKey:i.exactUnitKey})}if(At){Qe||=new Map;for(let at of At){let{source:rt,local:Pt,remote:ct}=at,It={map:new Map,reverse:new Map,identical:new Set},tn=mt({base:[rt],local:[Pt],remote:[ct],out:oe,policy:"both",L:It,R:It,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey,cloneUnit:se,provenance:xe,textMappers:$e,conflicts:k,decisions:ae,conflict:(Bt,rn)=>Tt(Bt,{...rn,policy:"both"}),scope:{base:I,local:ie.el,remote:ee.el,units:Ee,at:_e.get(rt)},node:we});re.push(...tn.segments);for(let Bt of[rt,Pt,ct])Z.add(Bt),vt.add(Bt),Qe.set(Bt,tn.nodes),gt.set(Bt,tn.nodes[tn.nodes.length-1]);for(let Bt=0;Bt<tn.nodes.length;Bt++)dt.push({frag:tn.nodes[Bt],at:_e.get(rt),previous:Bt?tn.nodes[Bt-1]:null})}}let Ge=qe?qe.blocks:null;if(st){Ge=new Set;for(let at of st.blocks)Ge.add(at)}let Xe=at=>!jt?.consumes(at)&&(Ge&&Ge.has(at)||ze(at)),St=Ee.map(Xe);if(!St.includes(!0))return;let tt=at=>{let rt=at.units,Pt=new Map;for(let Yt=0;Yt<rt.length;Yt++)Pt.set(rt[Yt],Yt);let ct=[],It=-1;for(let Yt=0;Yt<Ee.length;Yt++){if(St[Yt])continue;let Ot=at.twin(Ee[Yt]),kt=Ot?Pt.get(Ot):void 0;kt===void 0||kt<=It||Xe(Ot)||(ct.push([Yt,kt]),It=kt)}let tn=[],Bt=-1,rn=-1;for(let Yt=0;Yt<=ct.length;Yt++){let[Ot,kt]=Yt<ct.length?ct[Yt]:[Ee.length,rt.length],Kt={bLo:-1,bHi:-1,from:rn+1,to:kt,inlineStart:-1,inlineEnd:-1,next:kt};for(let nn=Bt+1;nn<Ot;nn++)St[nn]&&(Kt.bLo<0&&(Kt.bLo=nn),Kt.bHi=nn);for(let nn=rn+1;nn<kt;nn++){let Vn=rt[nn];Xe(Vn)&&(Kt.inlineStart<0&&(Kt.inlineStart=nn),Kt.inlineEnd=nn+1)}tn.push(Kt),Bt=Ot,rn=kt}return{units:rt,list:tn}},wt=tt(ie),lt=tt(ee),zt=[];for(let at of[wt,lt])for(let rt of at.list)rt.bLo>=0&&zt.push([rt.bLo,rt.bHi]);zt.sort((at,rt)=>at[0]-rt[0]);let Et=[];for(let[at,rt]of zt){let Pt=Et[Et.length-1];Pt&&at<=Pt.hi?Pt.hi=Math.max(Pt.hi,rt):Et.push({lo:at,hi:rt})}let en=(at,rt)=>at.length===rt.length&&at.every((Pt,ct)=>i.equalUnits(Pt,rt[ct])),Tn=at=>!ut(at)&&at.kind==="comment",Kn=at=>{if(!at.length)return[];let rt=(Bt,rn)=>ut(Bt)?Bt:Bt.nodes[rn?Bt.nodes.length-1:0],Pt=rt(at[0]),ct=rt(at[at.length-1],!0),It=Bt=>Bt&&ut(Bt)&&s(Bt);for(;It(Pt.previousSibling);)Pt=Pt.previousSibling;for(;It(ct.nextSibling);)ct=ct.nextSibling;let tn=[];for(let Bt=Pt;Bt&&(tn.push(Bt),Bt!==ct);Bt=Bt.nextSibling);return tn},Po=at=>at.some(rt=>ut(rt)&&s(rt));for(let at of Et){let rt=Ee.slice(at.lo,at.hi+1),Pt=null;if(st)for(let Ot of rt){let kt=st.certificatesBySource.get(Ot);kt&&(Pt||=[]).push(...kt)}let ct=ie.asBase?null:Is(wt,at),It=ee.asBase?null:Is(lt,at);if(Pt){let Ot=[new Set(ct||rt),new Set(It||rt)],kt=Pt.some(Kt=>!Ot[Kt.side].has(Kt.target));for(let Kt of rt)if(Ge.has(Kt))for(let[nn,Vn]of[[0,ie],[1,ee]]){let Yn=Vn.twin(Kt);Yn&&Vn.here(Yn)&&!Ot[nn].has(Yn)&&(kt=!0)}if(kt)continue}if(rt.some(Tn)||ct&&ct.some(Tn)||It&&It.some(Tn))continue;let tn=Kn(ct||rt),Bt=Kn(It||rt);if((!ct||en(rt,ct))&&(!It||en(rt,It))&&!(ct&&Po(tn)))continue;let rn=mt({base:Kn(rt),sourceRetentions:it?.get(I),local:tn,remote:Bt,out:oe,policy:Ze,blocks:Ge,scopeUnits:Pt?[rt,ct||rt,It||rt]:null,certifiedOrigins:Pt?(Ot,kt,Kt,nn,Vn,Yn)=>jr({certificates:Pt,scopes:[rt,ct||rt,It||rt],flats:[Ot,kt,Kt],keys:[nn,Vn,Yn]}):null,prepared:qe?qe.prepared:null,nativeTransfers:qe,L:ct?U:Ur(U,I),R:It?V:Ur(V,I),idOf:{base:p,local:v,remote:O},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Ot,kt,Kt)=>Q(Ot,kt,Kt,!1),cloneUnit:se,mergeAttrs:Ce,atomKey:i.exactUnitKey,moveIn:z,moveBuilt:z,movePlanned:z,provenance:xe,textMappers:$e,conflicts:k,conflict:Tt,scope:{base:I,local:ie.asBase?null:ie.el,remote:ee.asBase?null:ee.el,units:Ee,at:at.lo},decisions:ae,node:we});if(!rn){if(Pt){let Ot=pr({certificates:Pt,scopes:[rt,ct||rt,It||rt],views:[{V:ie,A:U,idOf:m.local},{V:ee,A:V,idOf:m.remote}],eligible:kt=>ut(kt)&&Ln.has(kt.tagName)&&!s(kt)&&!n.remoteWins(kt),baseId:m.base});for(let kt of Ot.records){it||=new Map;let Kt=it.get(kt.source);Kt||it.set(kt.source,Kt=[]),Kt.push(kt)}}continue}if(re.push(...rn.segments),qe){let Ot=new Map;for(let kt of rn.nodes){let Kt=xe.get(kt)?.base;if(!Kt||Ot.has(Kt))throw new Error("Invalid native transfer owner output");Ot.set(Kt,kt)}if(Ot.size!==qe.owners.length)throw new Error("Incomplete native transfer owner output");for(let kt of qe.owners){let Kt=Ot.get(kt.base);if(!Kt)throw new Error("Missing native transfer owner output");for(let nn of[kt.base,kt.local,kt.remote])Z.add(nn),vt.add(nn),gt.set(nn,Kt);dt.push({frag:Kt,at:_e.get(kt.base)})}continue}if(et&&ko(rt,ct||rt,It||rt,rn.nodes),rn.unitOutputs){Qe||=new Map;for(let Ot of[...rt,...ct||[],...It||[]]){let kt=rn.unitOutputs.get(Ot)||[];Z.add(Ot),vt.add(Ot),Qe.set(Ot,kt),kt.length&>.set(Ot,kt[kt.length-1])}for(let Ot=0;Ot<rn.nodes.length;Ot++)dt.push({frag:rn.nodes[Ot],at:at.lo,previous:Ot>0?rn.nodes[Ot-1]:null});continue}et&&ko(rt,ct||rt,It||rt,rn.nodes);let Yt=oe.createDocumentFragment();for(let Ot of rn.nodes)Yt.appendChild(Ot);for(let Ot of[...rt,...ct||[],...It||[]])Z.add(Ot),vt.add(Ot),gt.set(Ot,Yt);dt.push({frag:Yt,at:at.lo})}}}function fe(I,q){let te=xe.get(I);return te&&te.unchanged?!te.remote||te.remote===q?!0:G(te.remote,q):I.tagName!==q.tagName||!Pe(I,q)?!1:He(Ie(I),Ie(q))}function G(I,q){return I===q?!0:I.tagName!==q.tagName||I.namespaceURI!==q.namespaceURI||!Pe(I,q)?!1:ue(Ie(I),Ie(q))}function ue(I,q){let te=Se(I,s),me=Se(q,s);if(te.length!==me.length)return!1;for(let we=0;we<te.length;we++){let ie=te[we],ee=me[we];if(typeof ie=="string"||typeof ee=="string"){if(ie!==ee)return!1}else{if(ie.nodeType!==ee.nodeType)return!1;if(ie.nodeType===1){if(!G(ie,ee))return!1}else if(ie.nodeValue!==ee.nodeValue)return!1}}return!0}function Ie(I){return I.tagName==="TEMPLATE"&&I.content?I.content:I}function Pe(I,q){let te=0;for(let me of I.attributes)if(!n.ignoreAttribute(I,me.name)&&(te++,q.getAttribute(me.name)!==me.value))return!1;for(let me of q.attributes)n.ignoreAttribute(q,me.name)||te--;return te===0}function He(I,q){let te=Se(I,we=>{let ie=xe.get(we);return!!(ie&&ie.pinned)}),me=Se(q,s);if(te.length!==me.length)return!1;for(let we=0;we<te.length;we++){let ie=te[we],ee=me[we];if(typeof ie=="string"||typeof ee=="string"){if(ie!==ee)return!1}else{if(ie.nodeType!==ee.nodeType)return!1;if(ie.nodeType===1){if(!fe(ie,ee))return!1}else if(ie.nodeValue!==ee.nodeValue)return!1}}return!0}function Se(I,q){let te=[],me=null;for(let we=I.firstChild;we;we=we.nextSibling){if(we.nodeType===3){me=me===null?we.nodeValue:me+we.nodeValue;continue}we.nodeType===1&&q(we)||(me!==null&&(me!==""&&te.push(me),me=null),te.push(we))}return me!==null&&me!==""&&te.push(me),te}function Je(I,q,te,me){let we=I.value,ie=me?we:q?q.value:"",ee=te?te.value:"";Z.add(I),q&&Z.add(q),te&&Z.add(te);let Ee=ie===ee?ie:ie===we?ee:ee===we||Ze==="local"?ie:ee,Ue={site:"comment",bRun:I,lRun:q,rRun:te,node:null};if(ie!==we&&ee!==we&&ie!==ee&&Tt({kind:"text",node:null,base:we,local:ie,remote:ee,resolved:Ee},Ue),!q&&!te)return null;let _e=oe.createComment(Ee);return Ue.node=_e,xe.set(_e,{base:I.nodes,local:q?q.nodes:null,remote:te?te.nodes:null}),_e}function nt(I,q){let te=R(q,I);if(!te)return null;let me=ut(te)?te.parentNode:te.parent,we=ut(I)?I.parentNode:I.parent;return R(q,we)===me?null:q.reverse.get(me)||null}function ot(I){let q=new Set([I]),te=I;for(let me=0;me<64;me++){let we=nt(te,U)||nt(te,V);if(!we)return!1;if(we===I||ut(I)&&ut(we)&&I.contains(we)||q.has(we))return!0;q.add(we),te=we}return!0}function Wt(I,q,te){if(!q)return!1;let me=ut(I)?I.parentNode:I.parent;return me===q||q.tagName==="TEMPLATE"&&me===q.content}function Ut(I,q){let te=De(I),me=R(U,te);if(me&&Wt(q,me,U))return!0;let we=R(V,te);return!!(we&&Wt(q,we,V))}}function Ur(e,o){return e.map.get(o)?Vr():{map:{get:n=>n&&n.nodeType===1&&e.map.get(n)||n,has:()=>!0},reverse:{get:n=>e.reverse.get(n)||n,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Vr(){let e={get:o=>o,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Hr=new Set(["INPUT","OPTION","TEXTAREA"]),Ls=/[\t\n\f\r ]+/;function Wr(e,o,t,n){let s=e.ownerDocument,{provenance:d,textMappers:i}=t,r=n.hooks,l=[],u=[],b=[],a=new Set,h=[],p=[],v=new Map,O=new Set,m=new Map,c=t.conflicts.length>0||n.trackInserted===!0,g=new Map,P=new Set,T=new Map,x=(F,ce)=>{let ge=T.get(F);ge||T.set(F,ge=new Set),ge.add(ce)},A=c?new Set:null,E=(F,ce,ge)=>{let Le=r.beforeAttributeUpdated(F,ce,ge);return c&&Le===!1&&x(ce,F),Le},S=F=>!!F&&(F===e||e.contains(F)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(F)),N=new Map,C=new Map,j=new Map,D=new Set,B=new Map;(function F(ce){let ge=d.get(ce);if(ge){if(ce.nodeType===1){let Me=ge.local?n.toLive(ge.local):null;Me&&S(Me)&&Me.nodeType===1&&(N.set(ce,Me),C.set(Me,ce))}else if(Array.isArray(ge.local)){let Me=V(ge.local,ge.local.map(M=>n.toLive(M)).filter(M=>M&&S(M)&&M.nodeType===ce.nodeType));if(Me.length&&(N.set(ce,Me[0]),C.set(Me[0],ce),j.set(ce,Me)),Array.isArray(ge.caret))for(let M of ge.caret){let R=n.toLive(M.node);if(!R||!S(R)||R.nodeType!==3)continue;let z=B.get(R);Array.isArray(z)||B.set(R,z=[]),z.push({merged:ce,from:M.from,to:M.to,flatStart:M.flatStart})}else{let M=0;for(let R of Me)B.set(R,{merged:ce,shift:M}),M+=R.nodeValue.length}}}let Le=ce.nodeType===1&&ce.tagName==="TEMPLATE"&&ce.content?ce.content.childNodes:ce.childNodes;for(let Me of Le)F(Me)})(o);let w=new Set;for(let F of N.values())w.add(F);for(let F of j.values())for(let ce of F)w.add(ce);let y=n.localRoot&&n.localRoot!==e?new Set:null;if(y){for(let F=n.localRoot.firstElementChild;F;F=F.nextElementSibling)if(F.tagName==="HEAD")for(let ce=F.firstElementChild;ce;ce=ce.nextElementSibling){let ge=n.toLive(ce);ge&&y.add(ge)}}for(let F of t.segments||[])Ne(F);let $=n.restoreFocus===!1?null:dl(s,B);n.childrenOnly?xe(Ae(e),Ae(o)):De(e,o);for(let{node:F,parent:ce}of h)a.has(F)||!F.parentNode||F.nodeType===1&&(n.ignored(F)||$e(F))||it(F,ce);return hl(s,$,B,i,j,m,D),{applied:l,moved:u,replaced:b,identities:p,mergedScriptsLive:O,liveOf:N,heldBy:m,runOf:j,keptRuns:D,insertedLive:g,vetoed:P,vetoedAttrs:T,removedVetoes:A};function U(F,ce){let ge=F.slice(ce.bs,ce.be),Le=0;for(;Le<ge.length&&Le<ce.text.length&&ge[Le]===ce.text[Le];)Le++;let Me=0;for(;Me<ge.length-Le&&Me<ce.text.length-Le&&ge[ge.length-1-Me]===ce.text[ce.text.length-1-Me];)Me++;return{bs:ce.bs+Le,be:ce.be-Me,text:ce.text.slice(Le,ce.text.length-Me)}}function V(F,ce){if(!ce.length)return ce;let ge=[];for(let M of F){let R=M.parentNode;if(!R)continue;let z=v.get(R);if(!z){z=new Set;for(let J=R.firstChild;J;J=J.nextSibling)J.nodeType===3&&z.add(n.toLive(J));v.set(R,z)}ge.includes(z)||ge.push(z)}let Le={has:M=>ge.some(R=>R.has(M))},Me=[];for(let M of ce){Me.push(M);for(let R=M.nextSibling;R&&R.nodeType===3&&!Le.has(R)&&!Me.includes(R);R=R.nextSibling)Me.push(R)}return Me}function Ne(F){let ce=[];for(let be of F.localNodes){let H=n.toLive(be.node);if(!H||!S(H)||H.nodeType!==3)return;ce.push(H)}let ge=V(F.localNodes.map(be=>be.node),ce);if(!ge.length)return;let Le=ge.map(be=>be.nodeValue).join(""),{flatLocal:Me,lToM:M,mapLocal:R}=F;if(Le===Me)return;let z=F.textNodes.map(be=>({node:be.node,ms:be.ms,me:be.me})),J=[],ne=0;for(let be of ge)J.push(ne),ne+=be.nodeValue.length;let je=(be,H)=>ge.find((X,de)=>J[de]<=be&&be+H<=J[de]+X.nodeValue.length)||null,Q=[],Oe=0;for(let be of _n(Me,Le).map(H=>U(Me,H))){let H=be.bs+Oe;Oe+=be.text.length-(be.be-be.bs);let X,de;if(be.be>be.bs){X=M[be.bs];let pe=X>=0;for(let se=be.bs;pe&&se<be.be;se++)M[se]!==X+(se-be.bs)&&(pe=!1);if(!pe)continue;de=X+(be.be-be.bs)}else{let pe=be.bs>0?M[be.bs-1]:0,se=be.bs<Me.length?M[be.bs]:0;if(pe<0||se<0)continue;X=de=R(be.bs)}Q.push({ms:X,me:de,text:be.text,live:de===X?je(H,be.text.length):null})}Q.sort((be,H)=>H.ms-be.ms);let Ve=(be,H)=>(j.get(be.node)||[N.get(be.node)]).includes(H),Ce=be=>!!be&&be.nodeType===1&&vn.has(be.tagName);for(let be of Q){let H=z.find(de=>de.ms<=be.ms&&be.me<=de.me&&be.ms<de.me);if(H&&be.live&&H.ms===be.ms&&!Ve(H,be.live)){let de=z.find(pe=>pe.me===be.ms&&Ve(pe,be.live));de&&(H=de)}if(!H&&be.me===be.ms){let de=z.find(fe=>fe.me===be.ms),pe=z.find(fe=>fe.ms===be.ms),se=de||pe;if(!se)continue;let ke=se.node;for(;Ce(ke.parentNode)&&(de?ke.parentNode.lastChild:ke.parentNode.firstChild)===ke;)ke=ke.parentNode;if(ke===se.node)H=se;else{let fe=ke.ownerDocument.createTextNode(be.text);ke.parentNode.insertBefore(fe,de?ke.nextSibling:ke);continue}}if(!H)continue;let X=H.node.nodeValue;H.node.nodeValue=X.slice(0,be.ms-H.ms)+be.text+X.slice(be.me-H.ms),H.me+=be.text.length-(be.me-be.ms)}}function Ae(F){return F.nodeType===1&&F.tagName==="TEMPLATE"&&F.content?F.content:F}function De(F,ce){a.add(F);let ge=d.get(ce);if(ge&&ge.remote&&t.remoteIdOf){let Me=t.remoteIdOf(ge.remote);Me&&p.push([F,Me])}if(ge&&ge.unchanged){t.customIdentity&&ge.remote&&re(F,ge.remote),ge.remote&&_(F,ge.remote);return}if(r.beforeNodeMorphed(F,ce)===!1){P.add(ce);return}Dt(F,ce,n.keepLiveOnly&&ge&&ge.local&&ge.local.nodeType===1&&ge.local!==F?ge.local:null);let Le=F.tagName;if(mn(F))F.textContent!==ce.textContent&&(l.push({kind:"text",node:F,before:F.textContent,after:ce.textContent}),F.textContent=ce.textContent),t.mergedScripts.has(ce)&&O.add(F);else if(Le==="TEXTAREA")Jt(F,ce,ge);else{un(F,ce,ge);let Me=Le==="TEMPLATE"&&F.content?F.content:F,M=Le==="TEMPLATE"&&ce.content?ce.content:ce;n.protectFocusedValue==="subtree"&&Rt(F)&&F!==s.body?oe(Me):xe(Me,M)}r.afterNodeMorphed(F,ce)}function oe(F){for(let ce=F.firstChild;ce;ce=ce.nextSibling){let ge=C.get(ce);ge&&N.get(ge.parentNode)!==F||(a.add(ce),ce.nodeType===1&&oe(ce))}}function xe(F,ce){let ge=Ke(F.firstChild),Le=new Set;for(let Me of Array.from(ce.childNodes)){let M=N.get(Me);M&&a.has(M)&&!Le.has(M)&&(M=null);let R=d.get(Me);if(R&&R.pinned){M&&M.nodeType===1&&((M.parentNode!==F||Ke(M.nextSibling)!==ge)&&Te(F,M,ge),a.add(M),Le.add(M));continue}if(M&&M.nodeType===1){if(M!==ge){let ne=M.parentNode;if(ne===F&&ge&&jt(M)){let je=M.nextSibling;for(let Q=ge;Q&&Q!==M;){let Oe=Q.nextSibling;Te(F,Q,je),Q=Oe}}else Te(F,M,ge),ne!==F&&(u.push(M),l.push({kind:"move",el:M,from:ne,to:F}))}Le.add(M),De(M,Me),ge=Ke(M.nextSibling);continue}if(M&&M.nodeType!==1){let ne=j.get(Me)||[M],je=ne.map(Oe=>Oe.nodeValue).join(""),Q=Me.nodeValue;if(Me.nodeType===3){let Oe=ae(Me);Oe!=null&&je!==Oe&&(Q=ro(Oe,je,Me.nodeValue).text)}if(ne.length>1&&je===Q&&!ne.includes(ge,1)&&ne.every((Oe,Ve)=>Oe.parentNode===F&&(Ve===0||ne[Ve-1].nextSibling===Oe))){if(M!==ge)for(let Oe of ne)Te(F,Oe,ge);r.beforeNodeMorphed(M,Me)!==!1?r.afterNodeMorphed(M,Me):c&&P.add(Me);for(let Oe of ne)a.add(Oe),Le.add(Oe);m.set(Me,M),D.add(Me),ge=Ke(ne[ne.length-1].nextSibling);continue}M!==ge&&Te(F,M,ge),r.beforeNodeMorphed(M,Me)!==!1?(M.nodeValue!==Q&&(l.push({kind:"text",node:M,before:M.nodeValue,after:Q}),M.nodeValue=Q),r.afterNodeMorphed(M,Me)):P.add(Me),a.add(M),Le.add(M),m.set(Me,M),ge=Ke(M.nextSibling);continue}if(Me.nodeType===3&&ge&&ge.nodeType===3&&!a.has(ge)&&!B.has(ge)){ge.nodeValue!==Me.nodeValue&&(l.push({kind:"text",node:ge,before:ge.nodeValue,after:Me.nodeValue}),ge.nodeValue=Me.nodeValue),a.add(ge),m.set(Me,ge),ge=Ke(ge.nextSibling);continue}let z=d.get(Me),J=et(z&&z.unchanged&&z.remote?z.remote:Me);if(r.beforeNodeAdded(J)===!1){P.add(Me);continue}F.insertBefore(J,ge),a.add(J),c&&g.set(Me,J),J.nodeType===3&&m.set(Me,J),J.nodeType===1&&(b.push(J),Be(J,Me),t.customIdentity&&z&&z.unchanged&&z.remote&&re(J,z.remote),mn(J)||mt(J,Me),n.formState==="property"&&qt(z)&&_(J,z.remote)),ge=Ke(J.nextSibling),l.push({kind:"insert",node:J,parent:F}),r.afterNodeAdded(J)}for(let Me of Array.from(F.childNodes))a.has(Me)||Le.has(Me)||Me.nodeType===1&&(n.ignored(Me)||$e(Me))||(w.has(Me)?h.push({node:Me,parent:F}):it(Me,F))}function $e(F){return F.parentNode&&F.parentNode.nodeType===1&&F.parentNode.tagName==="HEAD"&&(y&&!y.has(F)||n.preserve&&n.preserve(F)===!0)}function ae(F){let ce=d.get(F);return!ce||!Array.isArray(ce.local)?null:ce.local.map(ge=>ge.nodeValue).join("")}function k(F){return d.get(F)}function _(F,ce){if(!Hr.has(F.tagName)&&!F.querySelector("input,option,textarea"))return;let ge=(Le,Me)=>{if(Le.tagName!==Me.tagName)return;Le.tagName==="TEXTAREA"?Jt(Le,Me,{remote:Me}):Hr.has(Le.tagName)&&un(Le,Me,{remote:Me});let M=Z(Le),R=Z(Me);if(M.length===R.length)for(let z=0;z<M.length;z++)ge(M[z],R[z])};ge(F,ce)}function re(F,ce){let ge=Z(F),Le=Z(ce);if(ge.length===Le.length)for(let Me=0;Me<ge.length;Me++){let M=t.remoteIdOf(Le[Me]);M&&p.push([ge[Me],M]),re(ge[Me],Le[Me])}}function Z(F){let ce=F.tagName==="TEMPLATE"&&F.content?F.content:F;return Array.from(ce.children).filter(ge=>!n.ignored(ge))}function Be(F,ce){if(!t.remoteIdOf)return;let ge=(Le,Me)=>{let M=d.get(Me);if(M&&M.remote&&Me.nodeType===1){let J=t.remoteIdOf(M.remote);J&&p.push([Le,J])}let R=Le.childNodes,z=Me.childNodes;for(let J=0;J<R.length&&J<z.length;J++)ge(R[J],z[J])};ge(F,ce)}function Ke(F){for(;F&&F.nodeType===1&&n.ignored(F);)F=F.nextSibling;return F}function Te(F,ce,ge){if(typeof F.moveBefore=="function"&&ce.ownerDocument===F.ownerDocument)try{F.moveBefore(ce,ge);return}catch{}F.insertBefore(ce,ge)}function it(F,ce){if(r.beforeNodeRemoved(F)===!1){c&&A.add(F);return}F.parentNode.removeChild(F),l.push({kind:"remove",node:F,parent:ce}),r.afterNodeRemoved(F)}function et(F){if(mn(F))return Ao(F,s);let ce=s.importNode(F,!0);if(ce.nodeType===1)for(let ge of Array.from(ce.querySelectorAll("script")))mn(ge)&&ge.replaceWith(Ao(ge,s));return ce}function mt(F,ce){let ge=F.tagName==="TEMPLATE"&&F.content?F.content:F,Le=ce.tagName==="TEMPLATE"&&ce.content?ce.content:ce,Me=Array.from(ge.childNodes),M=Array.from(Le.childNodes);for(let R=0;R<M.length&&R<Me.length;R++){let z=M[R],J=Me[R],ne=N.get(z);ne&&a.has(ne)&&(ne=null);let je=d.get(z);if(je&&je.pinned){if(ne&&ne.nodeType===1){let Q=ne.parentNode;Te(ge,ne,J),Q!==ge&&(u.push(ne),l.push({kind:"move",el:ne,from:Q,to:ge})),a.add(ne)}J.remove();continue}if(ne){let Q=ne.parentNode;Te(ge,ne,J),J.remove(),ne.nodeType===1?(Q!==ge&&(u.push(ne),l.push({kind:"move",el:ne,from:Q,to:ge})),De(ne,z)):(a.add(ne),m.set(z,ne),ne.nodeValue!==z.nodeValue&&(l.push({kind:"text",node:ne,before:ne.nodeValue,after:z.nodeValue}),ne.nodeValue=z.nodeValue));continue}a.add(J),c&&g.set(z,J),J.nodeType===3&&m.set(z,J),je&&je.unchanged&&je.remote?(Ze(J,je.remote),t.customIdentity&&re(J,je.remote)):z.nodeType===1&&!mn(z)&&mt(J,z)}}function Ze(F,ce){let ge=F.tagName==="TEMPLATE"&&F.content?F.content:F,Le=ce.tagName==="TEMPLATE"&&ce.content?ce.content:ce;for(let Me of Array.from(Le.childNodes))ge.appendChild(et(Me))}function ft(F,ce){return ce.namespaceURI?F.getAttributeNS(ce.namespaceURI,ce.localName):F.getAttribute(ce.name)}function Ct(F,ce){let ge=new Set((ce||"").split(Ls).filter(Boolean));return(F||"").split(Ls).filter(Le=>Le&&!ge.has(Le))}function Dt(F,ce,ge){for(let Le of Array.from(ce.attributes)){if(Tt(F,Le.name)||n.ignoreAttribute(F,Le.name))continue;let Me=ft(F,Le);if(Me===Le.value||ge&&ft(ge,Le)===Le.value)continue;let M=Le.value;if(ge&&Le.name==="class"&&!Le.namespaceURI){let R=Le.value.split(Ls).filter(Boolean),z=Ct(Me,ge.getAttribute("class")).filter(J=>!R.includes(J));z.length&&(M=[...R,...z].join(" "))}if(Me!==M){if(r.beforeAttributeUpdated(Le.name,F,"update")===!1){c&&x(ce,Le.name);continue}Le.namespaceURI?F.setAttributeNS(Le.namespaceURI,Le.name,M):F.setAttribute(Le.name,M),l.push({kind:"attr",el:F,name:Le.name,before:Me,after:M})}}for(let Le of Array.from(F.attributes)){if(Tt(F,Le.name)||n.ignoreAttribute(F,Le.name)||(Le.namespaceURI?ce.hasAttributeNS(Le.namespaceURI,Le.localName):ce.hasAttribute(Le.name)))continue;if(ge&&Le.name==="class"&&!Le.namespaceURI){let R=Ct(Le.value,ge.getAttribute("class"));if(R.length){let z=R.join(" ");if(z===Le.value)continue;if(r.beforeAttributeUpdated("class",F,"update")===!1){c&&x(ce,"class");continue}F.setAttribute("class",z),l.push({kind:"attr",el:F,name:"class",before:Le.value,after:z});continue}}if(ge&&ft(ge,Le)===null)continue;if(r.beforeAttributeUpdated(Le.name,F,"remove")===!1){c&&x(ce,Le.name);continue}let M=Le.value;Le.namespaceURI?F.removeAttributeNS(Le.namespaceURI,Le.localName):F.removeAttribute(Le.name),l.push({kind:"attr",el:F,name:Le.name,before:M,after:null})}}function Tt(F,ce){let ge=F.tagName;return ge==="INPUT"?ce==="value"||ce==="checked"||ce==="disabled":ge==="OPTION"?ce==="selected":!1}function Rt(F){return F===s.activeElement}function jt(F){let ce=s.activeElement;return!!ce&&ce!==s.body&&F.contains(ce)}function qt(F){let ce=F&&F.remote;return ce&&ce.nodeType===1?ce:null}function un(F,ce,ge){let Le=F.tagName,Me=qt(ge),M=n.formState==="property"&&Me?Me:ce;if(Le==="INPUT"){let R=n.protectFocusedValue&&Rt(F),z=(F.getAttribute("type")||"").toLowerCase(),J=z!=="file"&&z!=="checkbox"&&z!=="radio",ne=Me&&Me.hasAttribute("value")&&Me.value!==Me.getAttribute("value")?Me.value:null;if(J&&!R)if(n.formState==="property"){let je=ce.getAttribute("value"),Q=F.getAttribute("value");(Q!==je||F.value!==M.value)&&E("value",F,je==null?"remove":"update")!==!1&&(Q!==je&&(je==null?F.removeAttribute("value"):F.setAttribute("value",je),l.push({kind:"attr",el:F,name:"value",before:Q,after:je})),F.value!==M.value&&(F.value=M.value))}else if(ce.hasAttribute("value")||ne!=null){let je=ne??ce.getAttribute("value");F.getAttribute("value")!==je&&E("value",F,"update")!==!1?(F.setAttribute("value",je),F.value!==je&&(F.value=je),l.push({kind:"attr",el:F,name:"value",before:null,after:je})):F.value!==je&&F.getAttribute("value")===je&&(F.value=je)}else(F.hasAttribute("value")||F.value!=="")&&E("value",F,"remove")!==!1&&(F.removeAttribute("value"),F.value="",l.push({kind:"attr",el:F,name:"value",before:"",after:null}));if(!J&&z!=="file"){let je=ce.getAttribute("value");je==null?F.hasAttribute("value")&&E("value",F,"remove")!==!1&&F.removeAttribute("value"):F.getAttribute("value")!==je&&E("value",F,"update")!==!1&&F.setAttribute("value",je)}R||(Lt(F,M,"checked"),n.formState==="property"&&F.indeterminate!==M.indeterminate&&(F.indeterminate=M.indeterminate)),Lt(F,M,"disabled")}else if(Le==="OPTION"){let R=F.parentNode&&F.closest("select");n.protectFocusedValue&&R&&Rt(R)||Lt(F,M,"selected")}}function Lt(F,ce,ge){let Le=n.formState==="property"?!!ce[ge]:ce.hasAttribute(ge);if(n.formState!=="property"){let Me=F.hasAttribute(ge);if(Me!==Le){if(E(ge,F,Le?"update":"remove")===!1)return;Le?F.setAttribute(ge,""):F.removeAttribute(ge),l.push({kind:"attr",el:F,name:ge,before:Me?"":null,after:Le?"":null})}}F[ge]!==Le&&(F[ge]=Le)}function Jt(F,ce,ge){if(n.protectFocusedValue&&Rt(F)||E("value",F,"update")===!1)return;let Le=qt(ge),Me=ce.textContent,M=Le&&Le.value!==Le.defaultValue?Le.value:Me;n.formState!=="property"&&F.textContent!==Me&&(l.push({kind:"text",node:F,before:F.textContent,after:Me}),F.textContent=Me),F.value!==M&&(F.value=M)}}function dl(e,o){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let n={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{n.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return n}let s=e.getSelection&&e.getSelection();if(s&&s.rangeCount){let d=s.getRangeAt(0);n.range={sc:d.startContainer,so:d.startOffset,ec:d.endContainer,eo:d.endOffset}}return n}function hl(e,o,t,n,s,d,i){if(!o)return;let r=o.el;if(!r.isConnected&&o.id&&(r=e.getElementById(o.id)),!r||!r.isConnected)return;if(e.activeElement!==r)try{r.focus({preventScroll:!0})}catch{}try{r.scrollTop=o.scrollTop,r.scrollLeft=o.scrollLeft}catch{}if(o.selection){try{r.setSelectionRange&&!r.selectionEnd&&o.selection[1]!=null&&r.setSelectionRange(o.selection[0],o.selection[1],o.selection[2]||"none")}catch{}return}if(!o.range)return;let l=(a,h)=>{let p=t.get(a);if(Array.isArray(p)){let v=p.find(g=>h>=g.from&&h<g.to)||p.find(g=>h===g.to)||p[p.length-1],O=d.get(v.merged);if(!O||!O.isConnected)return null;let m=n.get(v.merged),c=m&&m.flat?m.flat(v.flatStart+h):h;return[O,Math.max(0,Math.min(c,O.nodeValue.length))]}if(p&&!i.has(p.merged)){let v=(s.get(p.merged)||[a])[0];if(!v.isConnected)return null;let O=n.get(p.merged),m=p.shift+h,c=O?O(m):m;return[v,Math.max(0,Math.min(c,v.nodeValue.length))]}return a.isConnected?[a,Math.min(h,a.nodeType===3?a.nodeValue.length:a.childNodes.length)]:null},u=l(o.range.sc,o.range.so),b=l(o.range.ec,o.range.eo);if(!(!u||!b))try{let a=e.createRange();a.setStart(u[0],u[1]),a.setEnd(b[0],b[1]);let h=e.getSelection();h.removeAllRanges(),h.addRange(a)}catch{}}var pl={compared:0},ml=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function gl(e,o,t){let n=0;for(let s of e.attributes)if(!t(e,s.name)&&(n++,o.getAttribute(s.name)!==s.value))return!1;for(let s of o.attributes)t(o,s.name)||n--;return n===0}function Rs(e,o){if(e.namespaceURI!==o.namespaceURI||e.prefix!==o.prefix||e.localName!==o.localName)return!1;let t=e.attributes;if(t.length!==o.attributes.length)return!1;for(let n of t)if(o.getAttributeNS(n.namespaceURI,n.localName)!==n.value)return!1;return!0}function Kr(e,o,t,n,s,d,i,r){let l=new Map,u=new Set,b=a=>{if(n(a))return;let h=t(a);h&&(d.add(h),s.has(h)||l.has(h)?u.add(h):l.set(h,a))};for(let a of e)b(a);b(o);for(let a of i||o.querySelectorAll("*"))b(a);for(let a of u)l.delete(a),r.add(a);return l}function Fr(e,o,t,n,s,d){let i=!1;for(let b of s)b.startsWith("merge:")&&(i=!0);if(!i)return[...n];let r=new Map,l=[],u=d===kn?Io:"*";for(let b of[e,...e.querySelectorAll(u)]){if(t(b))continue;let a=o(b);if(!a||!(n.has(a)||s.has(a)))continue;let h=(r.get(a)||0)+1;r.set(a,h),h===2&&l.push(a)}return l}function qr({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:s,identity:d,baseURI:i}){if(e.tagName!==o.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||o.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!gl(e,o,s.ignoreAttribute))return{bail:"root-attrs"};let{ignored:r,remoteWins:l}=s,u=Cs(s.scripts.merge===!1?null:s.scripts.mergeTags,i),b=ae=>{let k=u(ae);return k!==null?k:d.base(ae)||null},a=ae=>{let k=u(ae);return k!==null?k:d.remote(ae)||null},h=[],p=[],v=new Map,O=new Map,m={same:v,differ:O},c=ae=>({bail:ae,comparisons:m}),g=(ae,k,_=!0)=>{if(v.get(ae)===k)return!0;if(O.get(ae)===k)return!1;if(pl.compared++,_&&ae.isEqualNode(k))return v.set(ae,k),!0;let re=ae.nodeType===k.nodeType;if(re&&ae.nodeType===1){if(re=Rs(ae,k),re){let Z=ae.firstChild,Be=k.firstChild;for(;Z&&Be;Z=Z.nextSibling,Be=Be.nextSibling)if(!g(Z,Be,!1)){re=!1;break}(Z||Be)&&(re=!1)}}else re&&(re=ae.isEqualNode(k));return(re?v:O).set(ae,k),re},P=e,T=o,x=!1,A=()=>{v.set(P,T);for(let ae=0;ae<h.length;ae++)v.set(h[ae],p[ae]);return c("equal")};for(;;){let ae=P.childNodes,k=T.childNodes;if(ae.length!==k.length)break;let _=et=>g(ae[et],k[et])?(v.set(ae[et],k[et]),!1):!0,re=-1,Z=-1;for(let et=0;et<ae.length;et++){if(ae[et].nodeType!==1)continue;let mt=0;for(let Ze=ae[et].firstElementChild;Ze;Ze=Ze.nextElementSibling)mt++;mt>=Z&&(Z=mt,re=et)}let Be=[],Ke=!1;for(let et=0;et<ae.length&&Be.length<2;et++)et!==re&&_(et)&&Be.push(et);if(re>=0&&Be.length<2&&(Be.length===0&&Rs(P,T)?(Be.push(re),Ke=!0):_(re)&&Be.push(re)),Be.length!==1){if(!x&&Be.length===0&&Rs(P,T))return A();break}let Te=ae[Be[0]],it=k[Be[0]];if(x=x||!Ke,x&&O.set(Te,it),Te.nodeType!==1||it.nodeType!==1||Te.tagName!==it.tagName)break;if(b(Te)!==a(it)){if(!x&&g(Te,it))return A();break}h.push(P),p.push(T),P=Te,T=it}O.set(P,T);for(let ae=0;ae<h.length;ae++)O.set(h[ae],p[ae]);if(P===e||P.tagName==="HEAD"||P.tagName==="BODY")return c("root-level");if(h.length<2||h[1].tagName!=="BODY")return c("not-in-body");if(r(P)||r(T))return c("ignored-ancestor");if(l(P)||l(T))return c("remote-wins-ancestor");for(let ae of h)if(ml.has(ae.tagName))return c("form-ancestor");if(P.tagName==="SCRIPT"||P.getElementsByTagName("script").length||T.getElementsByTagName("script").length)return c("script-or-template");let E=n(P);if(!E||E.nodeType!==1||E.tagName!==P.tagName)return c("no-live-twin");if(!t.contains(E))return c("live-detached");for(let ae of h){let k=n(ae);if(!k||k.nodeType!==1)return c("ancestor-live")}let S=d.base===kn&&d.remote===kn&&r===os,N=new Set,C=new Set,j=[],D=null,B=ae=>{ae&&(N.has(ae)?C.add(ae):N.add(ae))},w=(ae,k)=>{let _=u(ae),re=_!==null?_:d.base(ae)||null;return re!==(_!==null?_:d.remote(k)||null)?!1:(B(re),!0)},y=(ae,k)=>{for(let _=ae.firstElementChild,re=k.firstElementChild;_;_=_.nextElementSibling,re=re.nextElementSibling){let Z=r(_);if(Z!==r(re))return!1;if(!Z&&(!w(_,re)||!y(_,re)))return!1}return!0},$=ae=>{let k=ae+1<h.length?h[ae+1]:P;for(let _=h[ae].firstElementChild,re=p[ae].firstElementChild;_;_=_.nextElementSibling,re=re.nextElementSibling){if(_===k){let Ke=ae+1<h.length?$(ae+1):null;if(Ke)return Ke;continue}let Z=r(_);if(Z!==r(re))return"outside-id-changed";if(Z)continue;let Be=n(_);if(!Be||Be.nodeType!==1)return"sibling-live";if(j.push([_,re]),!S&&(!w(_,re)||!y(_,re)))return"outside-id-changed";ae===0&&_.tagName==="HEAD"&&b(_)&&(D=[_,re])}return null},U=$(0);if(U)return c(U);let V=new Set(h),Ne=null;if(d.base===kn){Ne=[];for(let ae of e.querySelectorAll(Io))ae===P||V.has(ae)||(P.contains(ae)?Ne.push(ae):S&&B(b(ae)))}let Ae=new Set,De=new Set,oe=new Set,xe=Kr(h,P,b,r,N,Ae,Ne,De),$e=Kr(p,T,a,r,N,Ae,d.remote===kn&&T.querySelectorAll(Io),oe);return D&&(C.has(b(D[0]))||Ae.has(b(D[0])))&&(D=null),{scope:{chain:h,root:P,onChain:V,baseIndex:xe,remoteIndex:$e,baseDropped:De,remoteDropped:oe,head:D,same:v,differ:O,dropped:[...Fr(e,b,r,C,De,d.base),...Fr(o,a,r,C,oe,d.remote)],held:ae=>{for(let k=1;k<h.length;k++)if(ae.map.get(h[k])!==p[k])return!1;for(let[k,_]of j)if(ae.map.get(k)!==_)return!1;return!0}}}}var _r=Symbol("hyper-morph-duplicate-key"),zr=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function Eo(e,o){return o.map(t=>{let n=new Map;for(let s of e){if(s.nodeType!==1)continue;let d=t(s);d==null||d===""||n.set(d,n.has(d)?_r:s)}return n})}function $r(e,o,t,n){for(let s=0;s<n.length;s++){let d=n[s](e);if(d==null||d===""||o[s].get(d)!==e)continue;let i=t[s].get(d);if(!(!i||i===_r)&&i.tagName===e.tagName)return i}return null}function mo(e,o,t){for(let n=0;n<t.length;n++){let s=t[n](e);if(!(s==null||s==="")&&o[n].get(s)===e)return!0}return!1}function Gr(e,o,t={}){let n=t.skip||(()=>!1),s=t.ignoreAttr||(()=>!1),d=t.tiers&&t.tiers.length?t.tiers:zr,i=null;function r(){return i||(i=Eo([e,...e.querySelectorAll("*")],d)),i}let l=null;function u(){return l||(l=Eo([o,...o.querySelectorAll("*")],d)),l}function b(N){return!N.parentElement||!N.parentElement.parentElement}function a(N,C,j){return b(N)||mo(N,r(),d)?(j.push({type:"subtree",el:N,base:C}),!1):!0}function h(N,C){let j=[];for(let D of N.attributes)s(N,D.name)||C.getAttribute(D.name)!==D.value&&j.push(D.name);for(let D of C.attributes)s(N,D.name)||N.hasAttribute(D.name)||j.push(D.name);return j}function p(N){let C=[],j=null,D=()=>{j!==null&&(C.push({nodeType:3,nodeValue:j}),j=null)};for(let B of N.childNodes){if(B.nodeType===3){j=(j===null?"":j)+B.nodeValue;continue}B.nodeType===1&&n(B)||(D(),(B.nodeType===1||B.nodeType===8)&&C.push(B))}return D(),C}function v(N,C){if(N.nodeType!==C.nodeType)return!1;if(N.nodeType!==1)return!0;if(N.tagName!==C.tagName)return!1;for(let j of d){let D=j(N),B=j(C);if(D!=null&&D!==""&&B!=null&&B!==""&&D!==B)return!1}return!0}function O(N){let C="";for(let j of N)j.nodeType===3&&j.nodeValue.trim()!==""?C+="\0"+j.nodeValue:j.nodeType===8&&(C+=""+j.nodeValue);return C}function m(N,C,j){let D=p(N),B=p(C);if(D.length===B.length){let ae=!0;for(let k=0;k<D.length;k++)if(!v(D[k],B[k])){ae=!1;break}if(ae){for(let k=0;k<D.length;k++){let _=D[k];if(_.nodeType===1){if(c(_,B[k],j))return!0}else if(_.nodeValue!==B[k].nodeValue)return!0}return!1}}let w=D.filter(ae=>ae.nodeType===1),y=B.filter(ae=>ae.nodeType===1);if(O(D)!==O(B))return!0;let $=Eo(w,d),U=Eo(y,d),V=[],Ne=new Set,Ae=[];for(let ae of w){let k=$r(ae,$,U,d);k&&!Ne.has(k)?(V.push([ae,k]),Ne.add(k)):Ae.push(ae)}let De=[];for(let ae of Ae)mo(ae,$,d)?j.push({type:"subtree",el:ae,base:null}):De.push(ae);let oe=[];for(let ae of y)Ne.has(ae)||(mo(ae,U,d)?j.push({type:"deletion",el:ae}):oe.push(ae));if(De.length!==oe.length)return!0;for(let ae=0;ae<De.length;ae++)if(!v(De[ae],oe[ae]))return!0;let xe=new Map(V);for(let ae=0;ae<De.length;ae++)xe.set(De[ae],oe[ae]);let $e=-1;for(let ae of w){let k=xe.get(ae);if(!k)continue;let _=y.indexOf(k);if(_<$e)return!0;$e=_}for(let ae=0;ae<De.length;ae++)if(c(De[ae],oe[ae],j))return!0;for(let[ae,k]of V)if(c(ae,k,j))return!0;return!1}function c(N,C,j){if(N.tagName!==C.tagName)return a(N,C,j);let D=h(N,C),B=[];if(m(N,C,B))return a(N,C,j);if(D.length){if(!b(N)&&!mo(C,u(),d))return!0;j.push({type:"attrs",el:N,names:D,base:C})}return j.push(...B),!1}let g=[],P=h(e,o);P.length&&g.push({type:"attrs",el:e,names:P});let T=(N,C)=>Array.from(N.children).find(j=>j.tagName===C)||null,x=T(e,"HEAD"),A=T(o,"HEAD");if(x&&A){let N=[];c(x,A,N),N.length&&g.push({type:"head",el:x})}else(x||A)&&x&&g.push({type:"head",el:x});let E=T(e,"BODY"),S=T(o,"BODY");return E&&S?c(E,S,g):E&&g.push({type:"subtree",el:E,base:null}),{entries:g}}function Yr(e,o,t={}){let n=t.tiers&&t.tiers.length?t.tiers:zr,s=e.documentElement,d=[],i=0,r=c=>({ok:!1,placed:d,held:c,skippedAttrs:i});if(!s)return r(null);function l(c){let g=[c,...c.querySelectorAll("*")];return Eo(g,n)}let u=l(s),b=new Map,a=c=>{let g=c.getRootNode(),P=b.get(g);if(!P){let T=g.nodeType===9?g.documentElement:g;P=l(T),b.set(g,P)}return P};function h(c){if(!c.parentElement&&c.tagName==="HTML")return s;if(c.parentElement&&!c.parentElement.parentElement&&c.parentElement.tagName==="HTML"){if(c.tagName==="BODY")return e.body||null;if(c.tagName==="HEAD")return e.head||null}return null}function p(c){let g=h(c);return g||$r(c,a(c),u,n)}function v(c){if(!c)return null;let g=p(c);return g&&g.isConnected?g:null}function O(c){for(let g=0;g<n.length;g++){let P=n[g](c);P!=null&&P!==""&&u[g].set(P,c)}}for(let c of o){if(c.type!=="deletion")continue;let g=p(c.el);g&&g!==s&&g.remove()}let m=o.filter(c=>c.type!=="deletion").sort((c,g)=>c.el===g.el?0:c.el.compareDocumentPosition(g.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let c of m){if(c.type==="head"){let S=e.importNode(c.el,!0);e.head?e.head.replaceWith(S):s.insertBefore(S,s.firstChild),d.push({entry:c,imported:S});continue}if(c.type==="attrs"){let S=v(c.el)||v(c.base);if(!S){i++;continue}for(let N of c.names)c.el.hasAttribute(N)?S.setAttribute(N,c.el.getAttribute(N)):S.removeAttribute(N);continue}let g=c.el;if(h(g))return r(c);let P=v(g)||v(c.base);if(P){let S=e.importNode(g,!0);P.replaceWith(S),O(S),d.push({entry:c,imported:S});continue}if(c.base!=null&&!mo(c.base,a(c.base),n)||!mo(g,a(g),n))return r(c);let T=g.parentElement;if(!T)return r(c);let x=v(T);if(!x)return r(c);let A=null;for(let S=g.previousElementSibling;S;S=S.previousElementSibling){let N=v(S);if(N&&N.parentNode===x){A=N;break}}let E=e.importNode(g,!0);if(A)x.insertBefore(E,A.nextSibling);else{let S=Array.prototype.indexOf.call(T.children,g);x.insertBefore(E,x.children[S]||null)}O(E),d.push({entry:c,imported:E})}return{ok:!0,placed:d,held:null,skippedAttrs:i}}var bl='[editor-ui],[clay~="editor-ui"],[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]',wl='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',yl='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function kl(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let o=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(o)}function xl(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let s=o;if(s.nodeType===9){let d=e.getAttribute("id");s=d&&s.getElementById(d)||(e.tagName==="BODY"?s.body:e.tagName==="HTML"?s.documentElement:s.body&&s.body.firstElementChild)}if((!s||s.nodeType!==1||s.tagName!==e.tagName)&&(s=vl(e,o,n)),!!s)return t?Array.from(s.childNodes):s}function vl(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let s=new Map,d=[n,...n.querySelectorAll("script")];for(let l of d){let u=fo(l,t);u&&!s.has(u.key)&&s.set(u.key,l.textContent)}if(!s.size)return null;let i=e.cloneNode(!0),r=!1;for(let l of[i,...i.querySelectorAll("script")]){let u=fo(l,t);u&&s.has(u.key)&&(l.textContent=s.get(u.key),r=!0)}return r?i:null}function Xr(e,o){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=o.implementation.createHTMLDocument(""),n=e.nodeType===1&&e.tagName==="HTML"?e:null;if(n)return t.replaceChild(t.adoptNode(n),t.documentElement),t;let s=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let d of s)t.body.appendChild(t.adoptNode(d));return t}function Qo(e,o,t={}){let n=t||{};if(!n.head?.block)return Jr(e,o,n);try{return Jr(e,o,n)}catch(s){return Promise.reject(s)}}function Jr(e,o,t){let n=t.policy||"sync",s=n==="raw"?void 0:(l,u)=>kl(l)||(n==="history"?!(u&&l.matches(yl))&&l.matches(wl):l.matches(bl)),d=t.callbacks||{},i={ignore:s,hooks:d,protectFocusedValue:t.ignoreActiveValue===!0?"subtree":!1,restoreFocus:t.restoreFocus!==!1,formState:t.formStateSync||"attribute",scripts:{execute:t.scripts?.handle!==!1,merge:t.scripts?.merge!==!1,mergeTags:t.scripts?.mergeTags||[]},head:{awaitLoads:!!t.head?.block,preserve:t.head?.shouldPreserve||(()=>!1)}};if(typeof t.key=="function"&&(i.identity={base:t.key,local:t.key,remote:t.key}),e&&e.nodeType===9)return go(Object.assign({},i,{live:e,base:t.scripts?.mergeBase||null,remote:Xr(o,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let l=Object.assign({},i,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Xr(o,e.ownerDocument)});return go(l)}t.morphStyle==="innerHTML"&&(i.children=!0);let r=xl(e,t.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return r!==void 0&&(i.base=r),Zo(e,o,i)}var Tl=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),Mn=()=>{};function Co(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let r of Object.keys(e))if(!Tl.has(r))throw new TypeError(`unknown option "${r}"`);let t=Object.assign({beforeNodeAdded:Mn,afterNodeAdded:Mn,beforeNodeRemoved:Mn,afterNodeRemoved:Mn,beforeNodeMorphed:Mn,afterNodeMorphed:Mn,beforeAttributeUpdated:Mn},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let s=e.formState||"attribute";if(!["attribute","property"].includes(s))throw new TypeError("formState must be attribute or property");let d=e.protectFocusedValue;if(d!==void 0&&typeof d!="boolean"&&d!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");let i=e.lineage;if(i!==void 0&&(!i||typeof i!="object"||typeof i.onResult!="function"||!i.elements||typeof i.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:ss(e.ignore,o),remoteWins:ss(e.remoteWins,o),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:n,protectFocusedValue:d===void 0?!0:d,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:s,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:i||null}}function bo(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return kn}function wo(e,o){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=jo(o,e.map),n=typeof e.then=="function"?e.then:kn;if(typeof e.first=="function"){let s=e.first;return d=>s(d)||t.get(d)||n(d)}return s=>t.get(s)||n(s)}return kn}function ei(e,o,t,n={}){let s=p=>p&&p.nodeType===9?p.documentElement:p,d=s(o),i=s(t),r=s(e)||d;if(n.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let l=Object.assign({},n);delete l.live,delete l.base,delete l.remote;let u=Co(l,[r,d,i].filter(Boolean)),b=n.identity||{},a=Fn(),h=Jo(r,d,i,{identity:{base:wo(b.base,r),local:wo(b.local,d),remote:wo(b.remote,i)},authored:{base:bo(b.base),local:bo(b.local),remote:bo(b.remote)},skipUnchanged:u.hooks.beforeNodeMorphed===Mn&&u.hooks.afterNodeMorphed===Mn,ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:d.ownerDocument&&d.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:u.children,stats:a});return delete h.recoveryLinks,delete h.lineage,h}function Ps({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:s,options:d,identity:i,childrenOnly:r,isDocument:l}){let u=Co(d,[e,o,t,n].filter(Boolean));if(u.ignored(e)){let w=Bs(),y=u.lineage?No(u.lineage,e,w):null;return{report:w,loads:[],lineage:y}}let b=e.ownerDocument,a=u.lineage?Ts(u.lineage,{liveRoot:e,localRoot:t,toLive:s}):null,h=u.scripts.execute?mr(e,u.ignored,b.baseURI):null,p=Fn(),v=u.hooks.beforeNodeMorphed===Mn&&u.hooks.afterNodeMorphed===Mn,O={identity:{base:wo(i.base,o||t),local:wo(i.local,t),remote:wo(i.remote,n)},authored:{base:bo(i.base),local:bo(i.local),remote:bo(i.remote)},ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:b.baseURI,localIsBase:!o,childrenOnly:r,skipUnchanged:v,lineage:a?{locals:a.locals}:null},m=u.fastPath&&l&&!r&&v&&o===t,c=null,g=null;if(m){let w=qr({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:s,o:u,identity:O.identity,baseURI:b.baseURI});O.comparisons=w.comparisons||w.scope,w.bail?g=w.bail:(c=Jo(o,t,n,Object.assign({},O,{stats:p,scope:w.scope})),c||(g="chain-unpaired",p=Fn()))}c||(c=Jo(o||t,t,n,Object.assign({},O,{stats:p}))),m&&(p.fastPathAttempted=1,p.fastPathTaken=g?0:1,p.fastPathFallback=g),c.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(w=>u.hooks[w]!==Mn)&&Ar(c.conflicts,c.recoveryLinks,s),u.beforeApply&&u.beforeApply(c.doc);let P=globalThis.__hyperMorphProfile,T=P?performance.now():0,x=Wr(e,c.root,c,{toLive:s,localRoot:t,ignored:u.ignored,ignoreAttribute:u.ignoreAttribute,formState:u.formState,protectFocusedValue:u.protectFocusedValue,restoreFocus:u.restoreFocus,preserve:u.head.preserve,hooks:u.hooks,childrenOnly:r,keepLiveOnly:u.keepLiveOnly,trackInserted:!!a});P&&(P.apply=(P.apply||0)+(performance.now()-T));let A=[];if(u.head.awaitLoads)for(let w of x.applied){if(w.kind!=="insert"||w.node.nodeType!==1)continue;let y=w.node;y.tagName==="LINK"&&/\bstylesheet\b/i.test(y.getAttribute("rel")||"")&&y.getAttribute("href")&&y.closest("head")&&A.push(new Promise(U=>{y.addEventListener("load",()=>U()),y.addEventListener("error",()=>U())}))}let E=null,S=null;if(h){let w=gr(e,h,{ignored:u.ignored,skip:x.mergedScriptsLive,baseURI:b.baseURI,beforeNodeAdded:u.hooks.beforeNodeAdded,afterNodeAdded:u.hooks.afterNodeAdded,trackRecovery:!!c.recoveryLinks});A.push(...w.loads),E=w.swapped,S=w.vetoed}let N=w=>E&&E.get(w)||w,C=w=>{if(x.keptRuns.has(w))return x.runOf.get(w);let y=x.liveOf.get(w)||x.heldBy.get(w)||x.insertedLive.get(w);return y?N(y):null},j=w=>{let y=w&&x.liveOf.get(w);return y?N(y):null},D=w=>{let y=w&&C(w);return Array.isArray(y)?y[0]:y};if(c.recoveryLinks){let w=(y,$,U)=>($.namespaceURI?y.getAttributeNS($.namespaceURI,$.localName):y.getAttribute($.qualifiedName))===U;Ir(c.conflicts,c.recoveryLinks,{lookup:C,vetoed:x.vetoed,vetoedAttrs:x.vetoedAttrs,removedVetoes:x.removedVetoes,vetoedLive:S,liveAttr:w,ignored:u.ignored,liveRoot:e})}let B={applied:x.applied,decisions:c.decisions.map(w=>Object.assign({},w,{node:w.node?j(w.node):null,el:w.el?j(w.el):null,applied:!!(w.node?j(w.node):w.el&&j(w.el))})),conflicts:c.conflicts.map(w=>Object.assign({},w,{node:w.node?w.kind==="text"&&w.recovery.subject.nodeType===8?D(w.node):j(w.node):w.node,el:w.el?w.kind==="structure"?D(w.el):j(w.el):w.el})),localDiverged:c.localDiverged,identities:x.identities,moved:x.moved,replaced:x.replaced,stats:p};return a&&(B.lineage=a.finish(c.lineage,C)),{report:B,loads:A,lineage:a}}var Qr=new WeakMap;function Bs(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Fn()}}function go(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");return vs(o,o.live.documentElement,n=>Sl(n))}function Sl(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let n=Qr.get(t);n||(n=Do(t),Qr.set(t,n));let s=n("remote",o.remote),d=typeof o.base=="string"&&o.base===""?null:o.base,i=d?n("base",d):null,r=o.local?o.local.root:t.documentElement,l=o.local?o.local.toLive:h=>h;js(t,s);let{report:u,loads:b,lineage:a}=Ps({liveRoot:t.documentElement,baseRoot:i?i.documentElement:null,localRoot:r,remoteRoot:s.documentElement,toLive:l,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return a?.deliver(u),Promise.all(b).then(()=>u)}function ti(e,o,t={}){return go(Object.assign({},t,{live:e,base:null,remote:o}))}function Zr(e,o){if(e==null)return{root:o.createElement("template"),first:null};if(typeof e=="string"){let n=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(n){let d=Bo(e,o),i=n[1].toLowerCase()==="html"?d.documentElement:d.body;return{root:i,first:i}}let s=o.createElement("template");return s.innerHTML=e,{root:s,first:s.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let n=o.createElement("template"),s=e.isConnected;return n.content.appendChild(s?o.importNode(e,!0):e),{root:n,first:e}}if(e.nodeType===11){let n=o.createElement("template");return n.content.appendChild(e),{root:n,first:n.content.firstElementChild}}let t=o.createElement("template");for(let n of Array.from(e))t.content.appendChild(n.parentNode?o.importNode(n,!0):n);return{root:t,first:t.content.firstElementChild}}function Zo(e,o,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return vs(t,e,n=>Nl(e,o,n))}function Nl(e,o,t={}){let n=e.ownerDocument,{base:s,...d}=t,i=!!d.children,r=Co(d,[e]);if(r.ignored(e)){let O=Bs();return r.lineage&&No(r.lineage,e,O).deliver(O),Promise.resolve(O)}let l=Zr(o,n),u=s!=null?Zr(s,n):null,b,a=null;if(i)b=l.root,a=u?u.root:null;else{if(b=l.first,a=u?u.first:null,!b){let O=Co(d),m=O.lineage?No(O.lineage,e,{}):null;O.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),O.hooks.afterNodeRemoved(e));let c={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Fn()};return m&&(c.lineage=m.result,m.deliver(c)),Promise.resolve(c)}if(b.tagName!==e.tagName){let O=Co(d,[e,b]);if(O.hooks.beforeNodeMorphed(e,b)===!1){let g=Bs();return O.lineage&&No(O.lineage,e,g).deliver(g),Promise.resolve(g)}let m=Ps({liveRoot:e,baseRoot:a&&a.tagName===e.tagName?a:null,localRoot:e,remoteRoot:b,toLive:g=>g,options:d,identity:d.identity||{},childrenOnly:!0,isDocument:!1}),c=mn(b)?Ao(b,n):n.importNode(b,!1);if(!mn(c))for(;e.firstChild;)c.appendChild(e.firstChild);return O.hooks.beforeNodeAdded(c)===!1?(Xo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):O.hooks.beforeNodeRemoved(e)===!1?(Xo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):(e.replaceWith(c),Xo(m.report.conflicts,e,c),O.hooks.afterNodeRemoved(e),O.hooks.afterNodeAdded(c),O.hooks.afterNodeMorphed(e,b),m.report.replaced.push(c),m.report.applied.push({kind:"insert",node:c,parent:c.parentNode},{kind:"remove",node:e,parent:c.parentNode}),m.lineage&&(m.report.lineage=m.lineage.remapRoot(e,c),m.lineage.deliver(m.report)),Promise.all(m.loads).then(()=>m.report))}}let{report:h,loads:p,lineage:v}=Ps({liveRoot:e,baseRoot:a,localRoot:e,remoteRoot:b,toLive:O=>O,options:d,identity:d.identity||{},childrenOnly:i,isDocument:!1});return v?.deliver(h),Promise.all(p).then(()=>h)}var Al={mergeDocument:go,morphDocument:ti,morphElement:Zo,merge3:ei,morph:Qo};return ai(Ml);})();
|
|
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,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function ji(e){let o="<"+e.tagName.toLowerCase();for(let t of e.attributes)o+=` ${t.name}="${t.value.replace(/"/g,""")}"`;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)&>.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"&<(f.ms,f.conflict?"both":f.src,Et(f));for(let[f,L]of G)nt[f]>=0&<(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&≠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&<.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);})();
|
|
5
5
|
|
|
6
6
|
var morph = HyperMorph.morph;
|
|
7
7
|
|