@panphora/clayjs 1.10.0 → 1.11.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/README.md +2 -2
- package/dist/clay.standalone.js +6070 -4017
- package/package.json +1 -1
- package/src/attrs/add-from.js +72 -0
- package/src/core/conflict-notice.js +2 -5
- package/src/core/conflict-presentation.js +42 -0
- package/src/core/save-core.js +22 -0
- package/src/core/save.js +11 -2
- package/src/lib/region-capabilities.js +1 -0
- package/src/lib/region-policy.js +10 -3
- package/src/live/checkpoint.js +106 -0
- package/src/live/fast-lane.js +590 -0
- package/src/live/local-lane.js +582 -0
- package/src/live/ops.js +291 -0
- package/src/live/server-lane.js +84 -0
- package/src/live/store.js +291 -0
- package/src/live/stream-bridge.js +60 -0
- package/src/loader-logic.js +7 -2
- package/src/loader.js +2 -0
- package/src/plugins/live.js +446 -0
- package/src/sync/conflict-revert.js +1 -1
- package/src/sync/live-sync.js +21 -5
- package/src/sync/presence.js +4 -10
- package/src/sync/stream.js +2 -1
- package/src/vendor/hyper-morph.vendor.js +6 -4
- package/src/sync/section-notice.js +0 -254
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
var HyperMorph=(()=>{var ns=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var ii=Object.getOwnPropertyNames;var li=Object.prototype.hasOwnProperty;var ai=(e,o)=>{for(var t in o)ns(e,t,{get:o[t],enumerable:!0})},ci=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of ii(o))!li.call(e,s)&&s!==t&&ns(e,s,{get:()=>o[s],enumerable:!(n=ri(o,s))||n.enumerable});return e};var fi=e=>ci(ns({},"__esModule",{value:!0}),e);var Ml={};ai(Ml,{createIdentityStore:()=>Us,createParseCache:()=>Do,default:()=>Al,diff:()=>Gn,findChangedRoots:()=>Gr,importMap:()=>jo,merge3:()=>ni,merge3Text:()=>lo,mergeDocument:()=>wo,mergeJson:()=>As,mergeScriptText:()=>Go,morph:()=>Qo,morphDocument:()=>oi,morphElement:()=>Zo,parseJsonRelaxed:()=>zo,parseRulesRelaxed:()=>yr,spliceProtected:()=>Yr,tieredIdentity:()=>rs});function Bo(e,o){if(typeof e=="string"){let t=o&&o.defaultView,n=t&&t.DOMParser||globalThis.DOMParser;return new n().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Do(e){let o=new Map;return(t,n)=>{if(typeof n!="string")return Bo(n,e);let s=o.get(t);if(s&&s.text===n)return s.doc;let h=Bo(n,e);return o.set(t,{text:n,doc:h}),h}}function js(e,o){let t=o.doctype;if(!t)return!1;let n=e.doctype;if(n&&n.name===t.name&&n.publicId===t.publicId&&n.systemId===t.systemId)return!1;let s=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return n?e.replaceChild(s,n):e.insertBefore(s,e.documentElement),!0}var os=()=>!1;function ss(e,o=[]){if(typeof e!="function")return os;let t=new WeakMap,n=new Set(o);return s=>{if(!s||s.nodeType!==1)return!1;let h=t.get(s);if(h!==void 0)return h;let i=[],r=s,a=!1;for(;r&&r.nodeType===1;){let d=t.get(r);if(d!==void 0){a=d;break}if(i.push(r),e(r,n.has(r))){a=!0;break}if(n.has(r))break;r=r.parentElement}for(let d of i)t.set(d,a);return a}}var Ll=Object.freeze(["root-tag","equal","root-attrs","root-level","not-in-body","ignored-ancestor","remote-wins-ancestor","form-ancestor","script-or-template","no-live-twin","live-detached","ancestor-live","sibling-live","outside-id-changed","chain-unpaired"]);function zn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Us(e){let o=new WeakMap,t=0,n=r=>o.get(r)||null,s=r=>{let a=o.get(r);return a||(a=`${e}:${++t}`,o.set(r,a)),a};return{idOf:n,ensure:s,adopt:(r,a)=>{r&&typeof a=="string"&&a&&o.set(r,a)},exportMap:(r,a)=>{let d={},w=[],c=[],p=(m,v)=>{let I=a(m);I&&(d[v]=s(I));let g=m.children;w.push(g.length),c.push(m.tagName.toLowerCase());for(let f=0;f<g.length;f++)p(g[f],v===""?String(f):`${v}.${f}`)};return p(r,""),d["~"]=w.join(","),d["^"]=c.join(","),d}}}function jo(e,o){let t=new WeakMap;if(!e||!o||typeof o!="object"||Array.isArray(o))return t;let n=o["~"],s=typeof n=="string"?n.split(",").map(Number):null,h=s&&typeof o["^"]=="string"?o["^"].split(","):null,i=c=>Number.isInteger(c)&&c>=0,r=0,a=!1,d=c=>{let p=c;for(;p>0;){let m=s[r++];if(r>s.length||!i(m))return!1;p+=m-1}return!0},w=(c,p)=>{if(a)return;if(s){let I=r++,g=s[I];if(I>=s.length||!i(g)){a=!0;return}let f=!h||h[I]===c.tagName.toLowerCase();if(!f||g!==c.children.length){let b=f&&o[p];typeof b=="string"&&b&&t.set(c,b),d(g)||(a=!0);return}}let m=o[p];typeof m=="string"&&m&&t.set(c,m);let v=c.children;for(let I=0;I<v.length;I++)w(v[I],p===""?String(I):`${p}.${I}`)};return w(e,""),t}function rs(e){return o=>{for(let t of e){let n=t(o);if(typeof n=="string"&&n!=="")return n}return null}}var kn=rs([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Uo(e,o,t,n=null,s=null){let h=new Map,i=new Set,r=a=>{if(t(a))return;let d=o(a);d&&(h.has(d)?i.add(d):h.set(d,a))};if(n){let a=d=>{for(let w of d.querySelectorAll(n))r(w);for(let w of d.querySelectorAll("template"))w.content&&a(w.content)};r(e),a(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let a=d=>{r(d);let w=d.tagName==="TEMPLATE"&&d.content?d.content.children:d.children;for(let c=0;c<w.length;c++)a(w[c])};a(e)}for(let a of i)h.delete(a),s&&s.add(a),is(a);return h}function is(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var ui=new Set(["href","src","name","type","role"]),Hs=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function ro(e,o=5381){let t=o;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return t>>>0}function Vs(e){return e.replace(/\s+/g," ")}var di=0;function Ws({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,s=new WeakMap;function h(M){let L=M.attributes,N=L.length;if(N===0)return{all:"",sig:M.tagName+"|"};let A=[],E="",V=[];for(let j=0;j<N;j++){let D=L[j],y=D.name;o(M,y)||A.push(y+"="+D.value),y==="class"?E=D.value.indexOf(" ")<0?D.value:D.value.split(/\s+/).filter(Boolean).sort().join(" "):ui.has(y)&&V.push(y+"="+D.value)}return A.length>1&&A.sort(),V.length>1&&V.sort(),{all:A.join(""),sig:M.tagName+"|"+E+(V.length?"|"+V.join("|"):"")}}function i(M){return M.nodeType===1&&M.tagName==="TEMPLATE"&&M.content?M.content.childNodes:M.childNodes}function r(M){let L=n.get(M);if(L)return L;if(M.nodeType===3)L={hash:"T"+ro(M.nodeValue),hint:Vs(M.nodeValue).slice(0,64),sig:null,tok:null};else if(M.nodeType===8)L={hash:"C"+ro(M.nodeValue),hint:"",sig:null,tok:null};else if(M.nodeType===1){let N=h(M),A=ro(M.tagName+""+N.all),E="";for(let V of d(M))if(V.nodeType===1){let j=r(V);A=ro(j.hash,A),E.length<64&&(E+=" "+j.hint)}else A=ro(w(V),A),V.kind==="text"&&E.length<64&&(E+=V.value.slice(0,64));L={hash:"E"+A,hint:Vs(E).trim().slice(0,64),sig:N.sig,tok:null}}else L={hash:"N"+M.nodeType,hint:"",sig:null,tok:null};return n.set(M,L),L}function a(M){if(!M.tok){M.tok=new Set;for(let L of M.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))L&&M.tok.add(L)}return M.tok}function d(M){let L=s.get(M);if(L)return L;L=[];let N=null,A=()=>{N&&(N.value=N.nodes.map(E=>E.nodeValue).join(""),L.push(N),N=null)};for(let E of i(M)){if(E.nodeType===3){N||(N={kind:"text",nodes:[],value:"",parent:M,hash:void 0}),N.nodes.push(E);continue}A(),E.nodeType===8?L.push({kind:"comment",nodes:[E],value:E.nodeValue,parent:M,hash:void 0}):E.nodeType===1&&!e(E)&&L.push(E)}return A(),s.set(M,L),L}function w(M){return M.nodeType===1?r(M).hash:(M.hash===void 0&&(M.hash=(M.kind==="text"?"T":"C")+ro(M.value)),M.hash)}function c(M,L){let N=a(r(M)),A=a(r(L));if(N.size===0&&A.size===0)return{coef:1,share:1};if(N.size===0||A.size===0)return null;let E=0;for(let V of N)A.has(V)&&E++;return{coef:E/Math.min(N.size,A.size),share:E/Math.max(N.size,A.size)}}function p(M,L){let N=c(M,L);return!!N&&N.coef>=.5}let m=new WeakMap;function v(M){let L=m.get(M);if(L)return L;L=[];for(let N of M.attributes)o(M,N.name)||L.push([N.namespaceURI||"",N.localName,N.value]);return L.sort((N,A)=>N[0]<A[0]?-1:N[0]>A[0]?1:N[1]<A[1]?-1:N[1]>A[1]?1:0),m.set(M,L),L}let I=new WeakMap;function g(M,L){if(M===L)return!0;if(w(M)!==w(L))return!1;let N=I.get(M);if(N&&N.has(L))return N.get(L);let A=I.get(L);if(A&&A.has(M))return A.get(M);let E=f(M,L),V=E===!0;return E===!1&&t&&t.hashRejected++,N||I.set(M,N=new WeakMap),N.set(L,V),V}function f(M,L){if(M.nodeType===1){if(L.nodeType!==1||M.tagName!==L.tagName||M.namespaceURI!==L.namespaceURI)return!1;let N=v(M),A=v(L);if(N.length!==A.length)return!1;for(let j=0;j<N.length;j++)if(N[j][0]!==A[j][0]||N[j][1]!==A[j][1]||N[j][2]!==A[j][2])return!1;let E=d(M),V=d(L);if(E.length!==V.length)return!1;for(let j=0;j<E.length;j++){if(w(E[j])!==w(V[j]))return!1;if(!g(E[j],V[j]))return di}return!0}return L.nodeType===1?!1:M.kind===L.kind&&M.value===L.value}let b=new WeakMap,B=new Map,S=0;function T(M){let L=b.get(M);if(L)return L;let N=w(M),A=B.get(N);A||B.set(N,A=[]);let E=A.find(V=>g(V.unit,M));return L=E?E.key:"K"+S++,E||A.push({unit:M,key:L}),b.set(M,L),L}return{meta:r,unitsOf:d,unitHash:w,similar:p,score:c,childrenOf:i,equalUnits:g,exactUnitKey:T,ignored:e}}var qs=16,hi=2e3,pi=3,ls={align:0,certifyVisited:0,certifyScheduled:0};function as(e,o,t){let{meta:n,unitsOf:s,unitHash:h,similar:i,score:r,childrenOf:a,equalUnits:d,ignored:w}=t.analyzer,c=t.baseId||(()=>null),p=t.sideId||(()=>null),m=t.baseKey||(()=>null),v=t.sideKey||(()=>null),I=t.baseDropped||new Set,g=t.sideDropped||new Set,f=t.stats||null,b=f?new Set:null,B=f?new Set:null,S=new Map,T=new Map,M=new Set,L=new Map,N=new Set,A=new Set,E=new Set,V=[],j=[],D=[],y=[],k=hi,J=new Map,H=new Map,q=(W,X)=>{S.set(W,X),T.set(X,W)},Me=new Set,Oe=new Set,Re=null,ie=W=>{let X=W.nodeType?W.parentNode:W.parent;if(!X||X.nodeType!==11)return X;if(!Re){Re=new WeakMap;let pe=be=>{for(let he of be.querySelectorAll("template"))he.content&&(Re.set(he.content,he),pe(he.content))};for(let be of[e,o])pe(be.tagName==="TEMPLATE"&&be.content?be.content:be)}return Re.get(X)||null},xe=(W,X)=>{for(let pe=ie(W);pe&&!Me.has(pe);pe=ie(pe))Me.add(pe);for(let pe=ie(X);pe&&!Oe.has(pe);pe=ie(pe))Oe.add(pe)},qe=W=>{for(let X=ie(W);X;X=ie(X))if(S.has(X))return A.has(X);return!1},fe=W=>{for(let X=ie(W);X;X=ie(X)){let pe=T.get(X);if(pe!==void 0)return A.has(pe)}return!1},x=W=>!!W&&W.nodeType===1,Y=(W,X)=>{let pe=L.get(W);return!!pe&&pe.has(X)},ae=W=>Hs.has(W.tagName),oe=t.comparisons||t.scope,Ee=(W,X)=>{if(oe){if(oe.same.get(W)===X)return!0;if(oe.differ.get(W)===X)return!1}if(!W.isEqualNode(X))return!1;if(W.tagName==="TEMPLATE")return d(W,X);let pe=W.getElementsByTagName("template");if(pe.length===0)return!0;let be=X.getElementsByTagName("template");if(pe.length!==be.length)return!1;for(let he=0;he<pe.length;he++)if(!d(pe[he],be[he]))return!1;return!0},je=(W,X)=>{let pe=c(W);if(!pe)return!0;let be=p(X);return!be||pe===be},Ne=W=>{let X=m(W);return X&&t.baseIndex.get(X)===W&&!g.has(X)?X:null},tt=W=>{let X=v(W);return X&&t.sideIndex.get(X)===W&&!I.has(X)?X:null},Xe=(W,X)=>{let pe=Ne(W);if(!pe)return!0;let be=tt(X);return!be||pe===be},dt=globalThis.__hyperMorphProfile,Ge=dt?performance.now():0;dt&&!t.scope&&(n(e),n(o),dt.meta=(dt.meta||0)+(performance.now()-Ge),Ge=performance.now()),q(e,o);let st=new Set;for(let[W,X]of t.baseIndex){let pe=t.sideIndex.get(W);pe&&pe.tagName===X.tagName&&!S.has(X)&&!T.has(pe)&&(q(X,pe),xe(X,pe),st.add(X))}if(st.size){let W=[];if(t.scope)for(let he of t.scope.chain)st.has(he)&&W.push(he);let X=[t.scope?t.scope.root:e];for(;X.length;){let he=X.pop();st.has(he)&&W.push(he);let ee=a(he);for(let te=ee.length-1;te>=0;te--)ee[te].nodeType===1&&X.push(ee[te])}let pe=new Set;for(let he=W.length-1;he>=0;he--){let ee=W[he];t.scope&&t.scope.onChain.has(ee)?pe.add(ee):jt(ee,S.get(ee),pe)?(A.add(ee),E.add(ee),f&&f.certificationPairs++):pe.add(ee)}let be=new Set;for(let he of W)A.has(he)&&!be.has(he)&&Ot(he,be)}t.scope&&t.scope.head&&Gt(t.scope.head[0],t.scope.head[1]);function Ot(W,X){let pe=[W];for(;pe.length;){let be=pe.pop();if(!X.has(be)){X.add(be),O(be);for(let he of s(be))x(he)&&S.has(he)&&pe.push(he)}}}y.push([e,o]);for(let[W,X]of S)x(W)&&W!==e&&y.push([W,X]);return Lt(),Ct(),dt&&(dt.align=(dt.align||0)+(performance.now()-Ge)),{map:S,reverse:T,moved:N,identical:A,pairIdenticalChildren:O,weak:M,unpair:yt,rematch:Ct,insertedByHash:Nt,refused:B,identityPaired:st};function Ct(){Ae(),Lt();for(let W=0;W<D.length;){let X=D.length;It(W,X),W=X,Lt(),Ae(),Lt()}}function yt(W){let X=S.get(W);if(!X)return;L.has(W)||L.set(W,new Set),L.get(W).add(X);let pe=(he,ee)=>{S.delete(he),T.delete(ee),N.delete(he),A.delete(he),M.delete(he),E.delete(he)},be=(he,ee)=>{for(let te of s(he)){let z=S.get(te);!z||st.has(te)||!(x(z)?ee.contains(z):ee.contains(z.nodes[0]))||(pe(te,z),x(te)&&be(te,z))}};pe(W,X),x(W)&&be(W,X),V.push(W),j.push(X)}function Nt(){let W=new Map;for(let X of new Set(j)){if(T.has(X))continue;let pe=n(X).hash;W.has(pe)||W.set(pe,[]),W.get(pe).push(X)}return W}function Lt(){for(;y.length;){let[W,X]=y.shift();S.get(W)!==X||E.has(W)||A.has(W)||cn(W,X)}}function qt(W,X){if(!ae(W))for(let pe of s(W))x(pe)&&(X.push(pe),qt(pe,X))}function cn(W,X){E.add(W);let pe=s(W),be=s(X);ls.align+=pe.length+be.length,J=new Map,H=new Map;for(let ne=0;ne<pe.length;ne++)J.set(pe[ne],ne);for(let ne=0;ne<be.length;ne++)H.set(be[ne],ne);if(W.tagName==="HTML")for(let ne of["HEAD","BODY"]){let Te=pe.find(Pe=>x(Pe)&&Pe.tagName===ne),Ce=be.find(Pe=>x(Pe)&&Pe.tagName===ne);Te&&Ce&&!S.has(Te)&&!T.has(Ce)&&q(Te,Ce)}for(let ne=0;ne<pe.length&&ne<be.length;ne++){let Te=pe[ne],Ce=be[ne];S.has(Te)||T.has(Ce)||(x(Te)?x(Ce)&&Te.tagName===Ce.tagName&&Ee(Te,Ce)&&Gt(Te,Ce):!x(Ce)&&Te.kind===Ce.kind&&Te.value===Ce.value&&Gt(Te,Ce))}le(pe,be);let he=pe.filter(ne=>!S.has(ne)),ee=be.filter(ne=>!T.has(ne));he.length&&ee.length&&(wn(he,ee),R(he,ee),K(he,ee,pe,be),de(pe,be));let te=!1,z=!1;for(let ne of pe){if(!S.has(ne)){x(ne)&&(V.push(ne),qt(ne,V),te=!0);continue}x(ne)&&!A.has(ne)&&y.push([ne,S.get(ne)])}for(let ne of be)!T.has(ne)&&x(ne)&&(j.push(ne),qt(ne,j),z=!0);te&&z&&D.push([W,X])}function It(W,X){for(let pe=W;pe<X;pe++){let[be,he]=D[pe];if(S.get(be)!==he)continue;let ee=s(be),te=s(he),z=new Map,ne=new Map,Te=null;for(let Ce of ee)x(Ce)&&(S.has(Ce)?Te=Ce:(z.has(Te)||z.set(Te,[]),z.get(Te).push(Ce)));Te=null;for(let Ce of te)x(Ce)&&(T.has(Ce)?Te=T.get(Ce):(ne.has(Te)||ne.set(Te,[]),ne.get(Te).push(Ce)));for(let[Ce,Pe]of z){let ve=ne.get(Ce);if(!(!ve||Pe.length!==ve.length)&&Pe.every((_e,Je)=>ve[Je].tagName===_e.tagName&&je(_e,ve[Je])&&!Y(_e,ve[Je])))for(let _e=0;_e<Pe.length;_e++)$t(Pe[_e],ve[_e])}}}function $t(W,X){q(W,X),M.add(W),y.push([W,X]),Lt()}function wn(W,X){let pe=io(W,h),be=io(X,h),he=new Map;for(let ee of X){let te=h(ee);be.get(te)===1&&he.set(te,ee)}for(let ee of W){if(S.has(ee))continue;let te=h(ee);if(pe.get(te)!==1)continue;let z=he.get(te);z&&!T.has(z)&&d(ee,z)&&Gt(ee,z)}}function jt(W,X,pe){let be=[[W,X]];for(;be.length;){let[he,ee]=be.pop();if(ls.certifyVisited++,f&&f.certificationVisited++,he.nodeType!==ee.nodeType)return!1;if(he.nodeType===3||he.nodeType===8){if(he.nodeValue!==ee.nodeValue)return!1;continue}if(he.nodeType!==1){if(!he.isEqualNode(ee))return!1;continue}if(he.tagName!==ee.tagName||he.namespaceURI!==ee.namespaceURI||w(he)!==w(ee))return!1;let te=he.attributes,z=ee.attributes;if(te.length!==z.length)return!1;for(let ve=0;ve<te.length;ve++){let _e=te[ve];if(ee.getAttributeNS(_e.namespaceURI,_e.localName)!==_e.value)return!1}let ne=S.get(he);if(ne!==void 0&&ne!==ee)return!1;let Te=T.get(ee);if(Te!==void 0&&Te!==he)return!1;if(he!==W){if(A.has(he))continue;if(pe.has(he))return!1}let Ce=a(he),Pe=a(ee);if(Ce.length!==Pe.length)return!1;ls.certifyScheduled+=Ce.length;for(let ve=Ce.length-1;ve>=0;ve--)be.push([Ce[ve],Pe[ve]])}return!0}function rn(W,X){return!x(W)||!(Me.has(W)||Oe.has(X))?!0:!!$(W,X)||!(Ne(W)||tt(X))}function Gt(W,X){if(x(W)&&(Me.has(W)||Oe.has(X))){let pe=$(W,X);if(!pe){if(Ne(W)||tt(X))return;q(W,X),y.push([W,X]);return}for(let be=0;be<pe.length;be+=2){let he=pe[be],ee=pe[be+1],te=S.get(he);te!==void 0&&te!==ee&&fn(he,te);let z=T.get(ee);z!==void 0&&z!==he&&fn(z,ee),S.get(he)===ee&&(N.delete(he),M.delete(he),A.add(he),E.add(he))}}l(W,X)}function fn(W,X){S.delete(W),T.delete(X),N.delete(W),A.delete(W),M.delete(W),E.delete(W)}function $(W,X){let pe=[W,X,!1],be=[];for(;pe.length;){let he=pe.pop(),ee=pe.pop(),te=pe.pop(),z=S.get(te),ne=T.get(ee);if(te!==W&&(z!==void 0&&z!==ee&&st.has(te)||ne!==void 0&&ne!==te&&st.has(ne)))return null;if(!(z===ee&&A.has(te))&&((z!==void 0||ne!==void 0)&&be.push(te,ee),!!x(te))){if(he||z!==void 0&&z!==ee||ne!==void 0&&ne!==te){let Te=s(te),Ce=s(ee);for(let Pe=0;Pe<Te.length&&Pe<Ce.length;Pe++)pe.push(Te[Pe],Ce[Pe],!0)}else if(Me.has(te)||Oe.has(ee)){let Te=te.tagName==="TEMPLATE"?te.content:te,Ce=ee.tagName==="TEMPLATE"?ee.content:ee;for(let Pe=Te.firstElementChild,ve=Ce.firstElementChild;Pe&&ve;){if(w(Pe)){Pe=Pe.nextElementSibling;continue}if(w(ve)){ve=ve.nextElementSibling;continue}(S.has(Pe)||T.has(ve)||Me.has(Pe)||Oe.has(ve))&&pe.push(Pe,ve,!1),Pe=Pe.nextElementSibling,ve=ve.nextElementSibling}}}}return be}function l(W,X){q(W,X),A.add(W),x(W)&&E.add(W)}function O(W){let X=S.get(W);if(!X||!x(W))return;let pe=s(W),be=s(X);for(let he=0;he<pe.length&&he<be.length;he++)S.has(pe[he])||l(pe[he],be[he])}function R(W,X){let pe=te=>x(te)&&!ae(te)?n(te).sig+""+n(te).hint:null,be=io(W,pe),he=io(X,pe),ee=new Map;for(let te of X){let z=pe(te);z!=null&&he.get(z)===1&&ee.set(z,te)}for(let te of W){if(S.has(te))continue;let z=pe(te);if(z==null||be.get(z)!==1)continue;let ne=ee.get(z);ne&&!T.has(ne)&&je(te,ne)&&q(te,ne)}}function K(W,X,pe,be){let he=new Map;for(let te of X){if(!x(te)||T.has(te)||ae(te))continue;let z=n(te).sig;he.has(z)||he.set(z,[]),he.get(z).push({el:te,index:H.get(te)})}let ee=[];for(let te of W){if(S.has(te)||!x(te)||ae(te))continue;let z=he.get(n(te).sig);if(!z||!z.length)continue;let ne=J.get(te),Te=z.filter(Ce=>!T.has(Ce.el)).map(Ce=>({c:Ce,d:Math.abs(Ce.index-ne)}));Te.sort((Ce,Pe)=>Ce.d-Pe.d),Te.length>qs&&(Te=Te.slice(0,qs));for(let{c:Ce,d:Pe}of Te){if(!je(te,Ce.el))continue;let ve=r(te,Ce.el);ve&&ve.coef>=.5&&ee.push({b:te,s:Ce.el,coef:ve.coef,share:ve.share,d:Pe,bi:ne})}}if(ee.sort((te,z)=>z.coef-te.coef||z.share-te.share||te.d-z.d||te.bi-z.bi),f&&ee.length>1){let te=new Map;for(let z of ee){let ne=te.get(z.b);ne?ne.coef===z.coef&&(ne.share===z.share?ne.strict++:ne.loose++):te.set(z.b,{coef:z.coef,share:z.share,strict:0,loose:0})}for(let[z,ne]of te)b.has(z)||!(ne.strict||ne.loose)||(b.add(z),ne.strict?f.similarTiesStrict++:f.similarTiesLoose++)}for(let te of ee)!S.has(te.b)&&!T.has(te.s)&&q(te.b,te.s)}function Z(W,X){return x(W)!==x(X)?!1:x(W)?W.tagName!==X.tagName||!je(W,X)?!1:ae(W)||n(W).hint===""||n(X).hint===""?!0:i(W,X):W.kind===X.kind}function U(W,X){let pe=(he,ee)=>{let te=ee===null?-1:he===X?H.get(ee):J.get(ee),z=he[te+1];return z&&!x(z)?z:null},be=null;for(let he of W){if(x(he)){be=he;continue}if(S.has(he))continue;let ee=be===null?null:S.get(be);if(be!==null&&!ee)continue;let te=pe(X,ee);te&&!T.has(te)&&te.kind===he.kind&&q(he,te)}}function de(W,X){U(W,X);let pe=we(W,X),be=(ee,te)=>x(ee)&&n(ee).hint!==""&&n(te).hint===""&&!!te.querySelector("br")&&!pe(ee,te),he=0;for(let ee of W){if(S.has(ee)){let z=H.get(S.get(ee));z!==void 0&&z>=he&&(he=z+1);continue}let te=0;for(let z=he;z<X.length&&te<pi;z++){let ne=X[z];if(!T.has(ne)&&(te++,Z(ee,ne)&&!Y(ee,ne)&&!be(ee,ne))){q(ee,ne),x(ee)&&(n(ee).hint===""||n(ne).hint==="")&&M.add(ee),he=z+1;break}}}le(W,X)}function we(W,X){let pe=(be,he,ee)=>{for(let te=he-1;te>=0;te--)if(x(be[te])&&ee(be[te]))return be[te];return null};return(be,he)=>{let ee=J.get(be),te=H.get(he);if(ee===te)return!0;let z=pe(W,ee,Te=>S.has(Te)),ne=pe(X,te,Te=>T.has(Te));return z?S.get(z)===ne:!ne}}function le(W,X){let pe=W.filter(z=>x(z)&&!S.has(z)),be=X.filter(z=>x(z)&&!T.has(z));if(!pe.length||!be.length)return;let he=io(pe,z=>z.tagName),ee=io(be,z=>z.tagName),te=we(W,X);for(let z of pe){let ne=z.tagName;if(he.get(ne)!==1||ee.get(ne)!==1)continue;let Te=be.find(Ce=>Ce.tagName===ne);Te&&!T.has(Te)&&te(z,Te)&&je(z,Te)&&!Y(z,Te)&&(d(z,Te)?Gt(z,Te):(q(z,Te),M.add(z)))}}function Ae(){let W=new Map;for(let z of M)if(x(z)&&x(S.get(z))){let ne=n(z).hash;W.has(ne)||W.set(ne,[]),W.get(ne).push(z)}if(W.size)for(let z of j){if(T.has(z)||!x(z)||fe(z))continue;let ne=W.get(n(z).hash),Te=ne&&ne.find(Ce=>M.has(Ce)&&!Y(Ce,z)&&je(Ce,z)&&Xe(Ce,z)&&d(Ce,z)&&rn(Ce,z));Te&&(yt(Te),Gt(Te,z),xe(Te,z),N.add(Te))}let X=new Map,pe=new Map,be=new Map;for(let z of M){let ne=S.get(z);x(z)&&x(ne)&&be.set(ne,z)}let he=(z,ne)=>{if(!T.has(z))return!fe(z);let Te=be.get(z);return Te===T.get(z)&&Te!==ne&&!Te.contains(ne)},ee=z=>{if(T.has(z)){let ne=be.get(z);be.delete(z),yt(ne)}};for(let z of[...j,...be.keys()]){if(T.has(z)&&!be.has(z))continue;let ne=n(z).hash;if(X.has(ne)||X.set(ne,[]),X.get(ne).push(z),ae(z))continue;let Te=n(z).sig;pe.has(Te)||pe.set(Te,[]),pe.get(Te).push(z)}let te=new Set;for(let z of M){let ne=S.get(z);!x(z)||!x(ne)||ae(z)||n(z).hint===""||n(ne).hint===""||i(z,ne)||te.add(z)}for(let z of[...V,...te]){let ne=S.get(z);if(ne?!(M.has(z)&&te.has(z)):qe(z))continue;let Te=Je=>{ne&&yt(z),ee(Je)},Ce=X.get(n(z).hash);if(Ce){let Je=Ce.find(Ze=>Ze!==ne&&he(Ze,z)&&!Y(z,Ze)&&Xe(z,Ze)&&d(z,Ze)&&rn(z,Ze));if(Je){Te(Je),Gt(z,Je),xe(z,Je),N.add(z);continue}}if(ae(z)||k<=0)continue;let Pe=pe.get(n(z).sig);if(!Pe)continue;let ve=null,_e=0;for(let Je of Pe)if(!(Je===ne||!he(Je,z)||!je(z,Je)||!Xe(z,Je)||Y(z,Je))&&(k--<=0||i(z,Je)&&(_e++,ve=Je,_e>1)))break;_e>1&&B&&B.add(z),_e===1&&(Te(ve),q(z,ve),xe(z,ve),N.add(z),y.push([z,ve]))}}}function io(e,o){let t=new Map;for(let n of e){let s=o(n);s!=null&&t.set(s,(t.get(s)||0)+1)}return t}var mi={diff:0},Ks=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,gi=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,bi=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,wi=/\P{M}\p{M}*/gu;function yi(e){if(e==="")return[];if(Ks){let t=[];for(let n of Ks.segment(e))t.push(n.segment);return t}let o=[];for(let t of e.match(bi))if(gi.test(t))for(let n of t.match(wi))o.push(n);else o.push(t);return o}var ki=/^[ ]+$/,xi=e=>ki.test(e)?" ".repeat(e.length):e,$n=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),kt="",cs=e=>e.every(o=>$n(o)||o.k===kt),Ti=/^[\x00-\x7f\u00A0]*$/,vi=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Si(e){return e===""?[]:e.match(vi)}function an(e,o=!1){return(o?Si(e):yi(e)).map(t=>({k:xi(t),raw:t,len:t.length}))}var xn=(...e)=>e.every(o=>Ti.test(o));function fs(e,o,t){let n=e.length,s=o.length,h=Math.min(n+s,t),i=h+1,r=new Int32Array(2*h+3),a=[],d=n===0&&s===0;for(let m=0;m<=h&&!d;m++){a.push(r.slice(i-m,i+m+1));for(let v=-m;v<=m;v+=2){let I;v===-m||v!==m&&r[i+v-1]<r[i+v+1]?I=r[i+v+1]:I=r[i+v-1]+1;let g=I-v,f=I;for(;I<n&&g<s&&e[I].k===o[g].k;)I++,g++;if(mi.diff+=1+I-f,r[i+v]=I,I>=n&&g>=s){d=!0;break}}}if(!d)return null;let w=[],c=n,p=s;for(let m=a.length-1;m>0;m--){let v=a[m],I=c-p,g=I+m,f=I===-m||I!==m&&v[g-1]<v[g+1]?I+1:I-1,b=v[f+m],B=b-f;for(;c>b&&p>B;)w.push([0,c-1,p-1]),c--,p--;c===b?(w.push([1,c,p-1]),p--):(w.push([-1,c-1,p]),c--)}for(;c>0&&p>0;)w.push([0,c-1,p-1]),c--,p--;return w.reverse(),w}function Ni(e,o,t){let n=c=>c.k===kt;if(!e.some(n)&&!o.some(n))return fs(e,o,t);let s=[],h=[];for(let c=0;c<e.length;c++)n(e[c])||s.push(c);for(let c=0;c<o.length;c++)n(o[c])||h.push(c);let i=fs(s.map(c=>e[c]),h.map(c=>o[c]),t);if(!i)return null;let r=[],a=0,d=0,w=(c,p)=>{for(;a<c&&d<p&&e[a].k===o[d].k;)r.push([0,a++,d++]);let m=fs(e.slice(a,c),o.slice(d,p),t);if(!m)return!1;for(let[v,I,g]of m)r.push([v,I+a,g+d]);return a=c,d=p,!0};for(let[c,p,m]of i)if(c===0){if(!w(s[p],h[m]))return null;r.push([0,a,d]),a++,d++}return w(e.length,o.length)?r:null}function Wn(e,o,t=4e3){let n=[],s=0;for(;s<e.length&&s<o.length&&e[s].k===o[s].k;)e[s].raw!==o[s].raw&&n.push({bi:s,tok:o[s]}),s++;let h=0;for(;h<e.length-s&&h<o.length-s&&e[e.length-1-h].k===o[o.length-1-h].k;)e[e.length-1-h].raw!==o[o.length-1-h].raw&&n.push({bi:e.length-1-h,tok:o[o.length-1-h]}),h++;let i=e.slice(s,e.length-h),r=o.slice(s,o.length-h),a=Li(i,r)?null:Ni(i,r,t);if(!a){let f=i.length||r.length?[{bs:s,be:s+i.length,toks:r}]:[];return{hunks:f,cosmetic:n,coarse:!0,parts:f.map(b=>({...b,gap:[],group:0})),cosmeticEq:n}}let d=[],w=(f,b)=>{i[f].raw!==r[b].raw&&n.push({bi:s+f,tok:r[b]})},c=null,p=[],m=0,v=0,I=()=>{c&&d.push(c),c=null;for(let[f,b]of p)w(f,b);p=[],m++};for(let[f,b,B]of a){if(f===0){c&&$n(i[b])&&!i[b].k.includes(`
|
|
2
|
-
`)?p.push([
|
|
3
|
-
`))return!1;let M=H=>t.slice(S,T).map((q,Me)=>H.raw.get(S+Me)||q),L=[...b.toks,...M(v)],N=[...M(g),...B.toks],A=(H,q,Me)=>q>=0&&q+Me.length<=H.length&&Me.every((Oe,Re)=>H[q+Re].k===Oe.k),E=(H,q,Me)=>cs(H)&&t.slice(q,Me).some(Oe=>!$n(Oe)),V=H=>H.some(q=>!$n(q)),j,D,y,k;if(r(b)&&V(b.toks)&&A(N,0,b.toks)){let H=N.slice(b.toks.length);E(H,S,B.be)||(j=S,D=b.toks,y=N.slice(0,b.toks.length),k=[null,{bs:S,be:B.be,toks:H}])}if(j===void 0&&r(B)&&V(B.toks)){let H=L.length-B.toks.length,q=L.slice(0,H);A(L,H,B.toks)&&!E(q,b.bs,T)&&(j=T,D=L.slice(H),y=B.toks,k=[{bs:b.bs,be:T,toks:q},null])}if(j===void 0)return!1;let J=H=>H&&(H.bs<H.be||H.toks.length);return v.list.splice(I,1,...[k[0],{bs:j,be:j,toks:D}].filter(J)),g.list.splice(f,1,...[{bs:j,be:j,toks:y},k[1]].filter(J)),!0},p=i[0],m=i[1];for(let v=0;v<64;v++){let I=!1;e:for(let g=0;g<p.list.length;g++)for(let f=0;f<m.list.length;f++){let b=p.list[g],B=m.list[f];if(!(b.bs===B.bs&&b.be===B.be&&ms(b.toks,B.toks))){for(let S of[!0,!1]){let T=L=>S?L.be:L.bs,M=r(b)?[T(B),b.bs]:[T(b)];for(let L of M){let N=a(p,g,L,T),A=N&&a(m,f,L,T);if(!A)continue;let E=(k,J)=>S?k[k.length-1-J]:k[J],V=0;for(;V<N.length&&V<A.length&&E(N,V).k===E(A,V).k;)V++;if(!V)continue;let j=S?N.slice(0,N.length-V):N.slice(V),D=S?A.slice(0,A.length-V):A.slice(V);if(!(V<N.length&&V<A.length&&!cs(j)&&!cs(D)&&(r(b)&&r(B)||b.bs===B.bs&&b.be===B.be)||!(S?N.slice(N.length-V):N.slice(0,V)).some(k=>!$n(k)))){if(V===N.length&&V===A.length&&r(b)&&r(B)){if(b.bs===L&&B.bs===L)continue;p.list[g]={bs:L,be:L,toks:N},m.list[f]={bs:L,be:L,toks:A}}else!r(b)&&b.bs===B.bs&&b.be===B.be?(w(p,g,N,V,S),w(m,f,A,V,S)):(d(p,g,N,V,S,L),d(m,f,A,V,S,L));I=!0;break e}}}if(c(p,g,m,f)||c(m,f,p,g)){I=!0;break e}}}if(!I)break}return[p.list,m.list]}var Ii=48,Ci=.3;function Li(e,o){let t=e.filter(i=>!$n(i)),n=o.filter(i=>!$n(i));if(Math.min(t.length,n.length)<Ii)return!1;let s=new Map;for(let i of t)s.set(i.k,(s.get(i.k)||0)+1);let h=0;for(let i of n){let r=s.get(i.k);r>0&&(h++,s.set(i.k,r-1))}return h/Math.min(t.length,n.length)<Ci}var Ei=(e,o)=>{let t=new Set;for(let n of e.toks)typeof n.k!="string"&&t.add(n.k.el);for(let n=e.bs;n<e.be;n++)typeof o[n].k!="string"&&t.add(o[n].k.el);return t},ms=(e,o)=>e.length===o.length&&e.every((t,n)=>t.k===o[n].k);function Fs(e,o,t,n="remote"){let s=Wn(e,o),h=Wn(e,t),{lh:i,rh:r,cosL:a,cosR:d}=ps(s,h,e),w=x=>x.bs===x.be,c=x=>x.toks.some(Y=>typeof Y.k=="string"),p=x=>w(x)&&!c(x),m=(x,Y)=>Y.bs<x.be&&x.bs<Y.be,v=(x,Y)=>!m(x,Y)&&Y.bs<=x.be&&x.bs<=Y.be&&(w(x)&&c(x)||w(Y)&&c(Y))&&!(w(x)&&w(Y)),I=(x,Y)=>x.bs===Y.bs&&x.be===Y.be&&ms(x.toks,Y.toks),g=[],f=new Set;for(let x of i){let Y=r.find(ae=>!f.has(ae)&&I(x,ae));Y?(f.add(Y),g.push({bs:x.bs,be:x.be,side:"both",l:x,r:Y,toks:x.toks})):g.push({bs:x.bs,be:x.be,side:"L",l:x,toks:x.toks,lead:!!x.lead})}for(let x of r)f.has(x)||g.push({bs:x.bs,be:x.be,side:"R",r:x,toks:x.toks,lead:!!x.lead});g.sort((x,Y)=>x.bs-Y.bs||x.be-Y.be||Y.lead-x.lead);let b=0,B=0;for(let x of g)x.side==="both"&&(b+=x.toks.length-(x.be-x.bs));let S=g.map((x,Y)=>Y),T=x=>S[x]===x?x:S[x]=T(S[x]),M=(x,Y)=>(x=T(x),Y=T(Y),x===Y?!1:(S[x]=Y,!0)),L=g.map(x=>Ei({bs:x.bs,be:x.be,toks:x.toks},e)),N={L:new Map,R:new Map};g.forEach((x,Y)=>{let ae=x.side==="both"?["L","R"]:[x.side];for(let oe of ae)for(let Ee of L[Y])N[oe].has(Ee)||N[oe].set(Ee,[]),N[oe].get(Ee).push(Y)});for(let x of[N.L,N.R])for(let Y of x.values())for(let ae=1;ae<Y.length;ae++)M(Y[0],Y[ae]);for(let x=0;x<g.length;x++)for(let Y=x+1;Y<g.length;Y++){let ae=g[x],oe=g[Y];ae.side===oe.side&&ae.side!=="both"||ae.bs>oe.be||(m(ae,oe)||v(ae,oe)?M(x,Y):ae.bs===oe.bs&&w(ae)&&w(oe)&&B++)}let A=(x,Y)=>{let ae=x==="L"?i:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="close"&&Ee.k.el===Y.el))return oe.bs;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return-1};g.forEach((x,Y)=>{if(!(!p(x)||x.side==="both"))for(let ae of x.toks){if(ae.kind!=="open")continue;let oe=A(x.side,ae.k);if(oe<=x.bs)continue;let Ee=new Uint8Array(oe-x.bs),je=[];if(g.forEach((Ne,tt)=>{if(!(Ne.side===x.side||w(Ne))&&Ne.bs<oe&&Ne.be>x.bs){je.push(tt);for(let Xe=Math.max(Ne.bs,x.bs);Xe<Math.min(Ne.be,oe);Xe++)Ee[Xe-x.bs]=1}}),je.length&&Ee.every(Ne=>Ne===1))for(let Ne of je)M(Y,Ne)}});let E=!0;for(;E;){E=!1;let x=new Map;g.forEach((Y,ae)=>{let oe=T(ae),Ee=x.get(oe)||{bs:Y.bs,be:Y.be,L:!1,R:!1};Ee.bs=Math.min(Ee.bs,Y.bs),Ee.be=Math.max(Ee.be,Y.be),Y.side!=="R"&&(Ee.L=!0),Y.side!=="L"&&(Ee.R=!0),x.set(oe,Ee)}),g.forEach((Y,ae)=>{for(let[oe,Ee]of x){if(T(ae)===T(oe)||!(Ee.L&&Ee.R))continue;let je=Y.bs<Ee.be&&Y.be>Ee.bs,Ne=w(Y)&&c(Y)&&(Y.bs===Ee.be||Y.bs===Ee.bs);(je||Ne)&&M(ae,oe)&&(E=!0)}})}let V=new Map;g.forEach((x,Y)=>{let ae=T(Y);V.has(ae)||V.set(ae,[]),V.get(ae).push(x)});let j=[];for(let x of V.values()){let Y=x.some(oe=>oe.side==="L"),ae=x.some(oe=>oe.side==="R");if(Y&&ae){let oe=Math.min(...x.map(tt=>tt.bs)),Ee=Math.max(...x.map(tt=>tt.be)),je=x.filter(tt=>tt.side!=="R").map(tt=>tt.l).sort((tt,Xe)=>tt.bs-Xe.bs),Ne=x.filter(tt=>tt.side!=="L").map(tt=>tt.r).sort((tt,Xe)=>tt.bs-Xe.bs);j.push({bs:oe,be:Ee,kind:"conflict",localHunks:je,remoteHunks:Ne})}else for(let oe of x)j.push({bs:oe.bs,be:oe.be,kind:oe.side,u:oe})}let D=(x,Y)=>{let ae=x==="L"?i:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="close"&&Ee.k.el===Y.el))return oe.bs+.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return 1/0},y=(x,Y)=>{let ae=x==="L"?i:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="open"&&Ee.k.el===Y.el))return oe.bs-.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="open"&&e[oe].k.el===Y.el)return oe;return-1/0},k=x=>x.kind==="R"?"R":"L",J=x=>x.kind==="R"?1:0;j.sort((x,Y)=>{if(x.bs!==Y.bs)return x.bs-Y.bs;let ae=x.bs===x.be,oe=Y.bs===Y.be;if(ae!==oe)return ae?-1:1;if(ae&&oe&&x.kind!=="conflict"&&Y.kind!=="conflict"){let je=x.u.toks,Ne=Y.u.toks,tt=dt=>dt.length&&dt.every(Ge=>Ge.kind==="open"),Xe=dt=>dt.length&&dt.every(Ge=>Ge.kind==="close");if(tt(je)&&tt(Ne)){let dt=Math.max(...je.map(st=>D(k(x),st.k))),Ge=Math.max(...Ne.map(st=>D(k(Y),st.k)));if(dt!==Ge)return Ge-dt}if(Xe(je)&&Xe(Ne)){let dt=Math.min(...je.map(st=>y(k(x),st.k))),Ge=Math.min(...Ne.map(st=>y(k(Y),st.k)));return dt!==Ge?Ge-dt:J(Y)-J(x)}}let Ee=je=>je.u&&je.u.lead?1:0;return Ee(Y)-Ee(x)||J(x)-J(Y)||x.be-Y.be});let H=[],q=[],Me=0,Oe=x=>{x>Me&&(H.push({bs:Me,be:x,toks:e.slice(Me,x),source:"base"}),Me=x)};for(let x of j){if(Oe(x.bs),x.kind==="conflict"){let Y=hs(e,x.localHunks,x.bs,x.be),ae=hs(e,x.remoteHunks,x.bs,x.be),oe=n==="local"?Y:n==="both"?Y.concat(ae):ae,Ee=(tt,Xe)=>{let dt=0;for(let Ge of tt)Ge.be<=x.bs&&!Xe.includes(Ge)&&(dt+=Ge.toks.length-(Ge.be-Ge.bs));return dt},je=x.bs+Ee(i,x.localHunks),Ne=x.bs+Ee(r,x.remoteHunks);q.push({bs:x.bs,be:x.be,ls:je,le:je+Y.length,rs:Ne,re:Ne+ae.length,ms:0,me:0,base:e.slice(x.bs,x.be),local:Y,remote:ae,resolved:oe}),H.push({bs:x.bs,be:x.be,toks:oe,source:"conflict",localHunks:x.localHunks,localToks:Y,keepsLocal:n!=="remote"})}else H.push({bs:x.bs,be:x.be,toks:x.u.toks,source:x.kind==="R"?"remote":"local",localHunks:x.kind==="R"?[]:[x.u.l]});Me=Math.max(Me,x.be)}Oe(e.length);let Re=0,ie=0;for(let x of H)x.source==="conflict"&&(q[ie].ms=Re,q[ie].me=Re+x.toks.length,ie++),Re+=x.toks.length;let xe=new Map(a.map(x=>[x.bi,x.tok])),qe=new Map(d.map(x=>[x.bi,x.tok])),fe=[];for(let x of H){x.source==="base"&&(x.toks=x.toks.map((Y,ae)=>{let oe=x.bs+ae,Ee=xe.get(oe),je=qe.get(oe),Ne=Ee&&je?n==="remote"?je:Ee:Ee||je||Y;return Ne===Y?Y:{...Ne,cosmetic:!0}}));for(let Y of x.toks)fe.push({...Y,src:x.source})}return{tokens:fe,segments:H,conflicts:q,localHunks:i,remoteHunks:r,collapsedDelta:b,samePoint:B,mapLocalOffset:Ri(e,i,H)}}function hs(e,o,t,n){let s=[],h=t;for(let i of o)s=s.concat(e.slice(h,i.bs),i.toks),h=i.be;return s.concat(e.slice(h,n))}var us=e=>e.reduce((o,t)=>o+t.len,0);function Ri(e,o,t){let n=new Int32Array(e.length+1);for(let i=0;i<e.length;i++)n[i+1]=n[i]+e[i].len;let s=o.map(i=>({bs:n[i.bs],be:n[i.be],text:i.toks.map(r=>r.raw).join(""),ref:i})),h=t.map(i=>({bs:n[i.bs],be:n[i.be],len:us(i.toks),source:i.source,localHunks:i.localHunks||[],localLen:i.localToks?us(i.localToks):0,keepsLocal:i.keepsLocal,ref:i}));return i=>{let r=null,a=null,d=0,w=0,c=0;for(let m of s){let v=m.bs-c;if(i<=w+v){r=c+(i-w);break}if(w+=v,c=m.bs,i<=w+m.text.length){a=m,d=i-w,r=m.bs;break}w+=m.text.length,c=m.be}r===null&&(r=c+(i-w));let p=0;for(let m of h){if(!a&&r<=m.bs)return p;if(!(a?m.localHunks.includes(a.ref):r<m.be)){p+=m.len;continue}if(m.source==="base")return p+(r-m.bs);if(m.source==="remote")return p+m.len;if(m.source==="local")return p+Math.min(d,m.len);if(!m.keepsLocal||!a)return p+m.len;let I=m.localHunks.indexOf(a.ref),g=us(hs(e,m.localHunks.slice(0,I),m.ref.bs,a.ref.bs));return p+Math.min(g+d,m.localLen)}return p}}function lo(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:f=>Math.min(f,o.length),granularity:"word"};let s=xn(e,o,t),h=an(e,s),i=an(o,s),r=an(t,s),a=h.length<=2e4&&i.length<=2e4&&r.length<=2e4?Fs(h,i,r,n):null,d="word",w=h;if(!a){let f=b=>b.split(/(?<=\n)/).map(B=>({k:B,raw:B,len:B.length}));w=f(e),a=Fs(w,f(o),f(t),n),d="line"}let c=f=>f.map(b=>b.raw).join(""),p=f=>{let b=[0];for(let B of f)b.push(b[b.length-1]+B.len);return b},m=p(w),v=null,I=null,g=null;if(a.conflicts.length){let f=b=>b.split(/(?<=\n)/).map(B=>({k:B,raw:B,len:B.length}));v=p(d==="line"?f(o):i),I=p(d==="line"?f(t):r),g=p(a.tokens)}return{text:c(a.tokens),conflicts:a.conflicts.map(f=>({bs:m[f.bs],be:m[f.be],ls:v[f.ls],le:v[f.le],rs:I[f.rs],re:I[f.re],ms:g[f.ms],me:g[f.me],base:c(f.base),local:c(f.local),remote:c(f.remote),resolved:c(f.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:d}}function Gn(e,o,t=4e3){if(e===o)return[];let n=xn(e,o),s=an(e,n),h=an(o,n),i=Wn(s,h,t),r=[0];for(let a of s)r.push(r[r.length-1]+a.len);return i.hunks.map(a=>({bs:r[a.bs],be:r[a.be],text:a.toks.map(d=>d.raw).join("")}))}function zt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function jn({base:e,side:o,retained:t,transfers:n,baseAtomKey:s=r=>r.el,sideAtomKey:h=r=>r.el,budget:i=zt()}){let r=[],a=T=>({status:"fallback",reason:T}),d=T=>T>i.remaining?!1:(i.remaining-=T,!0);if(!d((t.length+n.length)*3))return a("work-limit");for(let[T,M]of[["retained",t],["transfer",n]])for(let L of M){let{from:N,to:A,target:E}=L;if(!Number.isInteger(N)||!Number.isInteger(A)||!Number.isInteger(E)||N<0||A<=N||A>e.text.length||E<0||E+A-N>o.text.length)return a("invalid-range");r.push({...L,kind:T})}let w=Symbol(),c=T=>(M,L)=>{if(!d(1))throw w;return i.sortComparisons++,T(M,L)},p,m;try{p=r.slice().sort(c((T,M)=>T.from-M.from||T.to-M.to)),m=r.slice().sort(c((T,M)=>T.target-M.target||T.to-T.from-(M.to-M.from)))}catch(T){if(T===w)return a("work-limit");throw T}if(!d(r.length*2))return a("work-limit");for(let T=1;T<p.length;T++)if(p[T].from<p[T-1].to)return a("source-overlap");for(let T=1;T<m.length;T++)if(m[T].target<m[T-1].target+m[T-1].to-m[T-1].from)return a("target-overlap");for(let T of p){let M=T.to-T.from;if(!d(M))return a("work-limit");for(let L=0;L<M;L++){let N=T.from+L,A=T.target+L;if(i.comparisons++,e.text[N]!==o.text[A])return a("unequal-occurrence");let E=e.atomAt.get(N),V=o.atomAt.get(A);if(!!E!=!!V||E&&s(E)!==h(V))return a("different-atom")}}let v=e.text.length+o.text.length+2,I=r.reduce((T,M)=>T+(M.to-M.from)*2,2);if(!d(v+I+r.length))return a("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),f=new Int32Array(o.text.length+1).fill(-1);i.mapCells+=v,i.mapWrites+=I;let b=-1,B=!0;for(let T of p){T.target<b&&(B=!1),b=T.target+T.to-T.from;for(let M=0;M<T.to-T.from;M++)g[T.from+M]=T.target+M,f[T.target+M]=T.from+M}return g[e.text.length]=o.text.length,f[o.text.length]=e.text.length,{status:"ready",runs:p,bTo:g,toB:f,monotone:B,covers:(T,M)=>{if(!d(M-T))return null;i.coverageChecks+=M-T;for(let L=T;L<M;L++)if(e.text[L]!==kt&&!/\s/.test(e.text[L])&&g[L]<0)return!1;return!0}}}function gs({base:e,side:o,baseOf:t=()=>null,budget:n=zt()}){if(e.text===o.text||!e.text.includes(kt)&&!o.text.includes(kt))return{status:"none"};let s=(e.text.length+o.text.length)*8;if(s>n.remaining)return{status:"fallback",reason:"work-limit"};n.remaining-=s,n.boundarySteps=(n.boundarySteps||0)+s;let h=(v,I)=>I<v.length&&(v[I]===kt||/\s/.test(v[I])),i=new Map,r=Symbol(),a=(v,I)=>{let g=v.stackAt[I]||[];if(!i.has(g)){if(g.length>n.remaining)throw r;n.remaining-=g.length,n.boundarySteps+=g.length,i.set(g,g.find(f=>f.block)?.el||null)}return i.get(g)},d=[],w=(v,I)=>{let g=a(e,v),f=a(o,I),b=g&&f&&t(f)!==g?"transfer":"retained",B=d[d.length-1];B&&B.to===v&&B.target+B.to-B.from===I&&B.kind===b&&B.destination===f?B.to++:d.push({from:v,to:v+1,target:I,destination:f,kind:b})},c=0,p=0,m=!1;try{for(;c<e.text.length||p<o.text.length;){if(c<e.text.length&&p<o.text.length&&e.text[c]===o.text[p]){let B=e.atomAt.get(c),S=o.atomAt.get(p);if(!!B!=!!S||B&&t(S.el)!==B.el)return{status:"none"};w(c++,p++);continue}if(!h(e.text,c)&&!h(o.text,p))return{status:"none"};let v=c,I=p;for(;h(e.text,c);)c++;for(;h(o.text,p);)p++;let g=e.text.slice(v,c),f=o.text.slice(I,p);(g.includes(kt)||f.includes(kt))&&(m=!0);let b=0;for(;b<c-v&&b<p-I&&e.text[c-b-1]===o.text[p-b-1];)b++;for(let B=b;B>0;B--)w(c-B,p-B)}}catch(v){if(v===r)return{status:"fallback",reason:"work-limit"};throw v}return m?jn({base:e,side:o,retained:d.filter(v=>v.kind==="retained"),transfers:d.filter(v=>v.kind==="transfer"),sideAtomKey:v=>t(v.el)||v.el,budget:n}):{status:"none"}}var _s=/\s/,Vo=/\S/;function In(e,o,t,n,s,h,i=-1,r=-1){if(!e.length)return-1;s(n,e.length);let a=new Int32Array(e.length),d=0;for(let m=1;m<e.length;m++){for(s(n,1);d&&(s(n,1),e[d]!==e[m]);)d=a[d-1];s(n,1),e[d]===e[m]&&d++,a[m]=d}let w=-1,c=0,p=0;d=0;for(let m=0;m<o.length;m++){for(s(n,1);d&&(s(n,1),e[d]!==o[m]);)d=a[d-1];if(s(n,1),e[d]===o[m]&&d++,d!==e.length)continue;let v=m+1-e.length,I=m+1;for(d=a[d-1];c<t.length&&t[c].from<v;)s(n,1),c++;for(;p<t.length&&t[p].to<I;)s(n,1),p++;if(s(n,6),!(c===t.length||p===t.length||t[c].from!==v||t[p].to!==I||i>=0&&v<r&&I>i)){if(!h)return v;if(w>=0)return-1;w=v}}return w}function No(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function bs(e,o,t,n){let s=null;for(let i of o)if(n(t,1),!(i.source!==e.source||i.side!==e.side))for(let r of i.runs){if(n(t,1),r.source!==e.source)continue;let a=Math.max(e.from,r.from),d=Math.min(e.to,r.to);a>=d||(s||(n(t,e.to-e.from),s=new Uint8Array(e.to-e.from)),n(t,d-a),s.fill(1,a-e.from,d-e.from))}if(!s)return!1;n(t,e.to-e.from);let h=!1;for(let i=e.from;i<e.to;i++)if(Vo.test(e.flat.text[i])){if(!s[i-e.from])return!1;h=!0}return h}function ws({source:e,side:o,views:t,eligible:n,blocked:s,baseId:h,model:i,tokensOf:r,budget:a,charge:d}){let{V:w,A:c,idOf:p}=t[o],m=t[1-o];if(e.nodeType!==1||c.identical.has(e)||m.A.identical.has(e)||s.has(e)||!n(e))return null;let v=w.twin(e),I=m.V.twin(e);if(!v||!I||c.map.get(e)!==v||c.reverse.get(v)!==e||m.A.map.get(e)!==I||m.A.reverse.get(I)!==e||!w.here(v)||!m.V.here(I)||!n(v)||!n(I))return null;let g=h(e);if(g!==p(v)||g!==m.idOf(I))return null;let f=i(e,null,a),b=i(v,c,a),B=i(I,m.A,a);if(!No(f)||!No(b)||!No(B))return null;let S=f.flat.text,T=b.flat.text;if(d(a,S.length+T.length*3),!Vo.test(T)||T.length>=S.length)return null;let M=S.startsWith(T),L=S.endsWith(T);if(M===L)return null;let N=M?T.length:0,A=M?S.length:S.length-T.length,E=N,V=A;for(;E<V&&(d(a,1),!!_s.test(S[E]));)E++;for(;V>E&&(d(a,1),!!_s.test(S[V-1]));)V--;if(E===V)return null;let j=r(f,a),D=!1,y=!1;for(let k of j)d(a,1),k.from===E&&(D=!0),k.to===V&&(y=!0);return!D||!y?null:{source:e,side:o,flat:f.flat,from:N,to:A}}function zs({base:e,views:o,side:t,attempt:n,eligible:s,blocked:h,baseId:i,model:r,tokensOf:a,certificates:d,charge:w,exhausted:c,limit:p}){if(p<=0)return null;let m=zt(p),{V:v,A:I,idOf:g}=o[t],f=o[1-t],[b,B,S,T]=n,M=null;try{for(let L=b;L<=B;L++){w(m,1);let N=e[L];if(N.nodeType!==1||I.identical.has(N)||f.A.identical.has(N)||h.has(N)||!s(N))continue;let A=ws({source:N,side:t,views:o,eligible:s,blocked:h,baseId:i,model:r,tokensOf:a,budget:m,charge:w});if(!A||bs(A,d,m,w))continue;let{flat:E,from:V,to:j}=A;w(m,(j-V)*2);let D=E.text.slice(V,j).trim();for(let y=S;y<=T;y++){w(m,1);let k=v.units[y],J=v.baseOf(k);if(!J||J===N||J.nodeType!==1||k.nodeType!==1||J.parentNode!==N.parentNode||k.parentNode!==I.map.get(N).parentNode||I.map.get(J)!==k||I.reverse.get(k)!==J||h.has(J)||!s(J)||!s(k)||i(J)!==g(k))continue;let H=r(J,null,m),q=r(k,I,m);if(!No(H)||!No(q))continue;let Me=H.flat.text,Oe=q.flat.text;if(w(m,Me.length),!Vo.test(Me)||Oe.length<=Me.length)continue;let Re=a(q,m),ie=In(Me,Oe,Re,m,w,!0);if(!(ie<0)&&!(In(D,Oe,Re,m,w,!1,ie,ie+Me.length)<0)){(M||=[]).push(A);break}}}}catch(L){if(L!==c)throw L}return M}function $s(e,o,t,n,s,h,i){if(h==="both"||t.atoms.length||n.atoms.length||s.atoms.length)return h;let r=h==="remote";if(r?i.rss!==i.rse||i.lss===i.lse||i.local===i.base:i.lss!==i.lse||i.rss===i.rse||i.remote===i.base)return h;for(let a of e){if(a.source!==o||a.side!==(r?1:0)||a.flat.text!==t.text||a.flat.nodes.length!==t.nodes.length||i.be<=a.from||i.bs>=a.to)continue;let d=!0;for(let c=0;c<t.nodes.length;c++){let p=a.flat.nodes[c],m=t.nodes[c];if(p.node!==m.node||p.s!==m.s||p.e!==m.e){d=!1;break}}if(!d)continue;let w=!1;for(let c=i.bs;c<i.be;c++)if(Vo.test(t.text[c])){if(c<a.from||c>=a.to){d=!1;break}w=!0}if(d&&w)return r?"local":"remote"}return h}var Un="\uFFFC";var Pi={caret:0},Tn=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),tr=new Set(["BR","WBR","IMG"]),ys=new Set("ADDRESS ARTICLE ASIDE AUDIO BLOCKQUOTE BODY CANVAS CAPTION CENTER COL COLGROUP DD DETAILS DIALOG DIR DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HEADER HGROUP HR HTML IFRAME LEGEND LI MAIN MATH MENU NAV NOSCRIPT OBJECT OL OPTGROUP OPTION P PRE SCRIPT SECTION SELECT STYLE SUMMARY SVG TABLE TBODY TD TEMPLATE TEXTAREA TFOOT TH THEAD TITLE TR UL VIDEO".split(" "));function Vn(e,o={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(o.ignored&&o.ignored(e)||tr.has(e.tagName))return!0;if(!Tn.has(e.tagName))return!ys.has(e.tagName);if(o.remoteWins&&o.remoteWins(e))return!1;let t=o.inlineCache&&o.inlineCache.get(e);if(t!==void 0)return t;let n=!0;for(let s of e.childNodes)if(!Vn(s,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Bi(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function nn(e,o={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},n=(s,h)=>{for(let i of s){if(i.nodeType===3){let c=i.nodeValue;if(!c)continue;t.nodes.push({node:i,s:t.text.length,e:t.text.length+c.length}),t.text+=c;for(let p=0;p<c.length;p++)t.stackAt.push(h);continue}if(i.nodeType!==1)continue;if(o.ignored&&o.ignored(i)){t.pins.push({el:i,i:t.text.length});continue}if(o.skip&&o.skip.has(i))continue;let r=o.via&&o.via(i)||i;r!==i&&(t.via||(t.via=new Map)).set(r,i);let a=i.tagName;if(o.blocks&&o.blocks.has(i)){t.text.length&&t.text[t.text.length-1]!==kt&&(t.stackAt.push(h),t.text+=kt);let c={el:i,tag:a,from:t.text.length,to:-1,depth:h.length,block:!0};t.marks.push(c);let p=h.concat([c]);n(r.childNodes,p),t.stackAt.push(p),t.text+=kt,c.to=t.text.length;continue}let d=Tn.has(a)&&Bi(r);if(tr.has(a)||!Tn.has(a)||o.remoteWins&&o.remoteWins(i)||o.atomize&&o.atomize(i)||d){t.atoms.push({i:t.text.length,el:i,key:d?a+":empty":a,stack:h}),t.stackAt.push(h),t.text+=Un;continue}let w={el:i,tag:a,from:t.text.length,to:-1,depth:h.length};t.marks.push(w),n(r.childNodes,h.concat([w])),w.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&qo(t).trim()===""){let s=t.atoms[0];t.placeholder=s.el,t.text=t.text.slice(0,s.i)+t.text.slice(s.i+1),t.stackAt.splice(s.i,1);for(let h of t.nodes)h.s>s.i&&(h.s--,h.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(s=>[s.i,s])),t}function Di(e){return e.replace(/&/g,"&").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 h=o;h<t;h++){let i=e.stackAt[h],r=0;for(;r<s.length&&r<i.length&&s[r]===i[r];)r++;for(;s.length>r;)n+=`</${s.pop().tag.toLowerCase()}>`;for(;s.length<i.length;){let d=i[s.length];n+=ji(d.el),s.push(d)}let a=e.atomAt.get(h);n+=a?a.el.outerHTML:e.text[h]===kt?"":Di(e.text[h])}for(;s.length;)n+=`</${s.pop().tag.toLowerCase()}>`;return n}function Ui(e,o){let t=[...e.el.attributes].filter(n=>!o(e.el,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tag+"|"+t}function nr(e,o){let t=[...e.attributes].filter(n=>!o(e,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function Gs(e,o=()=>!1){let t=new Map,n=h=>{let i=t.get(h);return i===void 0&&(i="{"+h.map(r=>Ui(r,o)).sort().join(",")+"}",t.set(h,i)),i},s="";for(let h=0;h<e.text.length;h++){let i=e.atomAt.get(h);s+=(i?"["+nr(i.el,o)+"]":e.text[h])+n(e.stackAt[h])}return e.text.length===0&&e.placeholder&&(s+="[br]"),s}function ao(e,o,t,n=s=>s.key){let s=[],h=e.text,i=0,r=a=>{if(a<=i)return;let d=h.slice(i,a);if(t)for(let w of d.split(/(?<=\n)/))s.push({k:w,raw:w,len:w.length});else for(let w of an(d,o))s.push(w)};for(let a of e.atoms)r(a.i),s.push({k:"\0"+n(a),raw:Un,len:1,atom:!0}),i=a.i+1;return r(h.length),s}function qo(e){if(!e.atoms.length)return e.text;let o="",t=0;for(let n of e.atoms)o+=e.text.slice(t,n.i),t=n.i+1;return o+e.text.slice(t)}var fo=e=>{let o=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)o[t+1]=o[t]+e[t].len;return o};function Ho(e,o,t,n){let s=fo(o),h=fo(t),i=[],r=0,a=0;for(let w of n.hunks){a+=w.bs-r;let c=a+w.toks.length;i.push({bs:s[w.bs],be:s[w.be],ss:h[a],se:h[c],text:e.text.slice(h[a],h[c]),toks:w.toks,lead:!!w.lead}),a=c,r=w.be}let d=new Map;for(let w of n.cosmetic)d.set(w.bi,w.tok.raw);return{hunks:i,respell:d}}function Ys(e,o,t){let n=i=>i===kt||/\s/.test(i),s=i=>i.replace(/[\u001E\s]/g,""),h=[];for(let i of e){let r=o.slice(i.bs,i.be),a=t.slice(i.ss,i.se);if(!r.includes(kt)&&!a.includes(kt)||r.includes(Un)||a.includes(Un)||s(r)!==s(a)){h.push(i);continue}let d=0,w=0;for(;;){let c=d,p=w;for(;c<r.length&&n(r[c]);)c++;for(;p<a.length&&n(a[p]);)p++;let m=d,v=w;for(;m<c&&v<p&&r[m]===a[v];)m++,v++;let I=c,g=p;for(;I>m&&g>v&&r[I-1]===a[g-1];)I--,g--;if(I>m||g>v){let f=a.slice(v,g);h.push({bs:i.bs+m,be:i.bs+I,ss:i.ss+v,se:i.ss+g,text:f,toks:[...f].map(b=>({k:b,raw:b,len:1})),lead:i.lead})}if(c>=r.length)break;d=c+1,w=p+1}}return h}function Xs(e,o,t){let n=new Int32Array(o+1).fill(-1),s=new Int32Array(t+1).fill(-1),h=0,i=0,r=a=>{for(;h<a;)n[h]=i,s[i]=h,h++,i++};for(let a of e)r(a.bs),h=a.be,i=a.se;return r(o),n[o]=i,s[i]=o,{bTo:n,toB:s}}function Js(e,o,t){let n=[],s=0,h=0,i=(r,a)=>{if(s===r&&h===a)return;let d=o.text.slice(h,a);n.push({bs:s,be:r,ss:h,se:a,text:d,toks:an(d,xn(d)),lead:!1})};for(let r of t.runs)i(r.from,r.target),s=r.to,h=r.target+r.to-r.from;return i(e.text.length,o.text.length),{hunks:n,respell:new Map}}function Qs(e,o,t,n){let s=fo(o),h=fo(t),i=(a,d)=>{let w=0,c=a.length;for(;w<c;){let p=w+c>>>1;a[p]<d?w=p+1:c=p}return a[w]===d?w:-1};for(let a of e.hunks)if(i(s,a.bs)<0||i(s,a.be)<0)return null;if(e.hunks.some(a=>i(h,a.ss)<0||i(h,a.se)<0)){if(!n)return null;let a=[];for(let p of e.hunks)a.push(p.ss,p.se);let d=[],w=0,c=0;for(let p of t){let m=c+p.len;for(;w<a.length&&a[w]<=c;)w++;let v=c;for(;w<a.length&&a[w]<m;){let I=a[w++];if(I>v){let g=p.raw.slice(v-c,I-c);d.push(...an(g,xn(g))),v=I}}if(v===c)d.push(p);else{let I=p.raw.slice(v-c);d.push(...an(I,xn(I)))}c=m}t=d,h=fo(t)}let r=[];for(let a of e.hunks){let d=i(s,a.bs),w=i(s,a.be),c=i(h,a.ss),p=i(h,a.se);if(d<0||w<0||c<0||p<0)return null;r.push({bs:d,be:w,toks:t.slice(c,p),gap:[],group:r.length})}return{parts:r,cosmeticEq:[],tokens:t}}function ks(e,o,t,n={},s=null){return or(e,o,t,n.base,n.local,n.remote,s,{})}function or(e,o,t,n,s,h,i,r){let a=xn(qo(e),qo(o),qo(t)),d=ao(e,a,!1,n),w=ao(o,a,!1,s),c=ao(t,a,!1,h),p=d.length>2e4||w.length>2e4||c.length>2e4;p&&(d=ao(e,a,!0,n),w=ao(o,a,!0,s),c=ao(t,a,!0,h));let m=i?.local?Js(e,o,i.local):null,v=i?.remote?Js(e,t,i.remote):null,I=m?Qs(m,d,w,!p):Wn(d,w),g=v?Qs(v,d,c,!p):Wn(d,c);m&&I&&(w=I.tokens),v&&g&&(c=g.tokens);let f,b;if(I&&g){let B=ps(I,g,d);f=Ho(o,d,w,{hunks:B.lh,cosmetic:B.cosL}),b=Ho(t,d,c,{hunks:B.rh,cosmetic:B.cosR})}else f=m||Ho(o,d,w,I),b=v||Ho(t,d,c,g);return f.hunks=Ys(f.hunks,e.text,o.text),b.hunks=Ys(b.hunks,e.text,t.text),r.base=e,r.local=o,r.remote=t,r.lines=p,r.baseTokens=d,r.localEdits=f,r.remoteEdits=b,r.localMap=Xs(f.hunks,e.text.length,o.text.length),r.remoteMap=Xs(b.hunks,e.text.length,t.text.length),r.full=null,r}function Zs(e,o){if(e.size!==o.size)return!1;for(let t of e)if(!o.has(t))return!1;return!0}var uo=/\s/;function Wo(e,o,t){for(let n=o;n<t;n++)if(!uo.test(e[n]))return!1;return!0}function Vi(e,o,t){let n=e.cache[t]||(e.cache[t]=new Map);if(n.has(o))return n.get(o);let s=t===0?"local":"remote",h=t===0?"remote":"local",i=o.baseMark,r=o[h+"Mark"],a=!o.block&&!o[s]&&!!r&&i.to>i.from;if(a){let d=t===0?e.ML:e.MR,w=t===0?e.MR:e.ML,c=t===0?e.fr:e.fl,p=!1;for(let m=i.from;m<i.to;m++){if(d.bTo[m]>=0){a=!1;break}w.bTo[m]<0&&!uo.test(e.fb.text[m])&&(p=!0)}if(a&&!p){for(let m=r.from;m<r.to;m++)if(w.toB[m]<0&&!uo.test(c.text[m])){p=!0;break}}a&&=p}return n.set(o,a),a}function er(e,o,t,n,s,h,i,r,a){let d=r===0?e.fl:e.fr,w=null;for(let c=t;c<n;c++){let p=o[c];if(!Wo(d.text,p.ss,p.se))return null;if(Wo(e.fb.text,p.bs,p.be)){if(p.bs<p.be&&p.ss<p.se||uo.test(e.fb.text[p.bs-1]||"")||uo.test(e.fb.text[p.be]||""))continue;return null}let m=!1;for(let v=p.bs;v<p.be;v++){if(uo.test(e.fb.text[v]))continue;let I=null;for(let g of e.fb.stackAt[v]){let f=e.byEl.get(g.el);if(f&&Vi(e,f,r)){I=f;break}}if(!I)return null;(w||(w=new Set)).add(I),m=!0}if(!m)return null}if(!w){if((r===0?"local":"remote")!==a)return null;let c=r===0?e.fr:e.fl,p=!1;for(let m=h;m<i;m++){let v=s[m];if(!Wo(e.fb.text,v.bs,v.be))return null;Wo(c.text,v.ss,v.se)||(p=!0)}if(!p)return null}return w||0}function Ko(e){let{out:o,policy:t="remote",L:n,R:s}=e,h=e.provenance||new WeakMap,i=e.textMappers||new WeakMap,r=e.conflicts||[],a=e.decisions||[],d=r.length,w=e.conflict||(u=>r.push(u)),c={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},p=[],m=!!(n&&n.reverse&&n.map&&s&&s.reverse&&s.map),v={base:null,local:null,remote:null};if(!e.prepared&&m&&e.moveIn){let u=Se=>De=>Se.some(Le=>Le===De||Le.nodeType===1&&Le.contains(De)),P=u(e.local),F=u(e.remote),_=u(e.base),Q=new Set,me=Se=>{if(!Tn.has(Se.tagName))return;let De=n.map.get(Se),Le=s.map.get(Se);(De&&!P(De)||Le&&!F(Le))&&Q.add(Se);for(let Ue of Se.children)me(Ue)};for(let Se of e.base)Se.nodeType===1&&me(Se);let ke=Se=>De=>{if(!Tn.has(De.tagName))return!1;let Le=Se.reverse.get(De);return!!Le&&(Q.has(Le)||!_(Le))};Q.size&&(v.base=Se=>Q.has(Se)),v.local=ke(n),v.remote=ke(s)}let I={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&m&&e.moveIn){let u=_=>Q=>_.some(me=>me===Q||me.nodeType===1&&me.contains(Q)),P=u(e.local),F=u(e.remote);for(let _ of nn(e.base,{...e,atomize:v.base}).atoms){let Q=n.map.get(_.el),me=s.map.get(_.el),ke=!!Q&&!P(Q),Se=!!me&&!F(me);!ke&&!Se||(ke&&e.movePlanned?.(_.el,"local",Q,null),Se&&e.movePlanned?.(_.el,"remote",me,null),I.base.add(_.el),Q&&!ke&&I.local.add(Q),me&&!Se&&I.remote.add(me),P(_.el)&&I.local.add(_.el),F(_.el)&&I.remote.add(_.el))}}let g=e.prepared?.base||nn(e.base,{...e,atomize:v.base,skip:I.base}),f=e.prepared?.local||nn(e.local,{...e,atomize:v.local,skip:I.local}),b=e.prepared?.remote||nn(e.remote,{...e,atomize:v.remote,skip:I.remote}),B=new Map(g.atoms.map(u=>[u.el,u])),S={},T=u=>e.prepared?e.prepared.full?.(u)||null:I[u].size?(S[u]||(S[u]=nn(e[u],{...e,atomize:v[u]})),S[u]):null,M=(u,P,F)=>{P.namespaceURI?u.setAttributeNS(P.namespaceURI,P.name,F):u.setAttribute(P.name,F)},L=(u,P,F,_)=>{if(!P&&(!F||!_)){for(let me of(F||_).attributes)M(u,me,me.value);return}let Q=new Map;for(let me of[P,F,_])if(me)for(let ke of me.attributes)Q.set(ke.name,ke);for(let[me,ke]of Q){let Se=P?P.getAttribute(me):null,De=F?F.getAttribute(me):Se,Le=_?_.getAttribute(me):Se,Ue;De===Le?Ue=De:De===Se?(Ue=Le,a.push({kind:"attr",el:u,name:me,source:"remote"})):Le===Se?(Ue=De,a.push({kind:"attr",el:u,name:me,source:"local"})):(Ue=t==="local"?De:Le,w({kind:"attr",el:u,name:me,base:Se,local:De,remote:Le,resolved:Ue},{el:u,sample:ke}),a.push({kind:"attr",el:u,name:me,source:"both"})),Ue!=null&&M(u,ke,Ue)}},N=(u,P,F,_)=>u&&e.mergeAttrs?e.mergeAttrs(u,P,F,_):L(_,u,P,F),A=e.mergeElement||((u,P,F)=>{let _=o.createElement(u.tagName);N(u,P,F,_);let Q=P||u,me=F||u,ke=t==="local"?Q.isEqualNode(u)?me:Q:me.isEqualNode(u)?Q:me;for(let Se of ke.childNodes)_.appendChild(o.importNode(Se,!0));return h.set(_,{base:u,local:P,remote:F}),_}),E=e.cloneUnit||((u,P)=>{let F=o.importNode(u,!0);return h.set(F,{base:null,local:P==="local"?u:null,remote:P==="remote"?u:null}),F}),V=e.atomKey||(u=>nr(u,()=>!1)),j=(u,P)=>{let F=new Map;for(let _ of u.atoms)if(e.remoteWins&&e.remoteWins(_.el)&&Tn.has(_.el.tagName))F.set(_,"w"+_.el.tagName+"#"+(_.el.id||""));else if(!m)F.set(_,_.key);else if(u===g)F.set(_,"="+V(_.el));else{let Q=P.reverse.get(_.el),me=Q?B.get(Q):null;me?F.set(_,"="+V(me.el)):Q?F.set(_,"m"+V(_.el)):F.set(_,"="+V(_.el))}return _=>F.get(_)},D=j(g,null),y=j(f,n),k=j(b,s),J=e.certifiedOrigins?e.certifiedOrigins(g,f,b,D,y,k):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let u=zt(),P=gs({base:g,side:f,baseOf:_=>n?.reverse?.get(_)||null,budget:u}),F=gs({base:g,side:b,baseOf:_=>s?.reverse?.get(_)||null,budget:u});(P.status==="ready"||F.status==="ready")&&(J={local:P.status==="ready"?P:null,remote:F.status==="ready"?F:null})}let H=e.prepared||or(g,f,b,D,y,k,J,c),q=H.lines,Me=H.baseTokens,Oe=H.localEdits,Re=H.remoteEdits,ie=H.localMap,xe=H.remoteMap,qe=g.text.length,fe=u=>new Map(u.atoms.map(P=>[P.el,P])),x=fe(f),Y=fe(b),ae=(u,P,F)=>{let _=new Set;if(!m)return _;for(let Q of u.atoms){let me=B.get(P.reverse.get(Q.el));me&&F.bTo[me.i]<0&&_.add(me)}return _},oe=ae(f,n,ie),Ee=ae(b,s,xe),je=u=>!Vn(u,{...e,remoteWins:null}),Ne=new Set;if(m)for(let u of g.atoms){if(!je(u.el))continue;let P=n.map.get(u.el)||null,F=s.map.get(u.el)||null,_=P&&!F?P:F&&!P?F:null;_&&(x.has(_)||Y.has(_))&&!_.isEqualNode(u.el)&&Ne.add(u)}let tt=1,Xe=(u,P)=>({id:tt++,tag:u,base:null,local:null,remote:null,rank:P}),dt=new Map,Ge=[];for(let u of g.marks){let P=Xe(u.tag,u.depth);P.block=!!u.block,P.base=u.el,P.baseMark=u,dt.set(u.el,P),Ge.push(P)}let st=(u,P)=>{let F=-1,_=-1;for(let Q=u.from;Q<u.to;Q++){let me=P[Q];me>=0&&(F<0&&(F=me),_=me+1)}return F<0?null:[F,_]},Ot=(u,P,F,_)=>{for(let Q of u.marks){let me=F?F.reverse.get(Q.el):null;me&&F.identical.has(me)&&F.pairIdenticalChildren&&F.pairIdenticalChildren(me);let ke=me?dt.get(me):null;if(ke&&ke[P]&&(ke=null),!ke){let Se=st(Q,_),De=0;if(Se)for(let Le of Ge){if(Le.tag!==Q.tag||Le[P]||!!Le.block!=!!Q.block)continue;let Ue=Math.min(Se[1],Le.baseMark.to)-Math.max(Se[0],Le.baseMark.from);(Ue>De||Ue===De&&Ue>0&&Math.abs(Le.rank-Q.depth)<Math.abs(ke.rank-Q.depth))&&(ke=Le,De=Ue)}}ke||(ke=Xe(Q.tag,Q.depth),ke.block=!!Q.block,ke.new=P),ke[P]=Q.el,ke[P+"Mark"]=Q,dt.set(Q.el,ke)}};Ot(f,"local",n,ie.toB),Ot(b,"remote",s,xe.toB);let Ct=u=>u.merged||u,yt=u=>{let P=new Set;for(let F of u)F.block||P.add(dt.get(F.el));return P},Nt=new Map,Lt=u=>{let P=Nt.get(u);return P||(P=yt(u),Nt.set(u,P)),P},qt=(u,P)=>{let F=[],_=null;for(let Q=0;Q<qe;Q++){let me=P[Q];if(me<0){_&&F.push(_),_=null;continue}let ke=Lt(g.stackAt[Q]),Se=Lt(u.stackAt[me]),De=new Set,Le=new Set;for(let Ue of Se)ke.has(Ue)||De.add(Ue);for(let Ue of ke)Se.has(Ue)||Le.add(Ue);if(!De.size&&!Le.size){_&&F.push(_),_=null;continue}if(_&&Zs(_.added,De)&&Zs(_.removed,Le)){_.be=Q+1;continue}_&&F.push(_),_={bs:Q,be:Q+1,added:De,removed:Le}}return _&&F.push(_),F},cn=qt(f,ie.bTo),It=qt(b,xe.bTo),$t=u=>u.be>u.bs?[u.bs,u.be-1]:[u.bs-1,u.bs],wn=(u,P)=>{if(qe===0)return null;let[F,_]=$t(u);for(let Q of P){if(Q.be<=F)continue;if(Q.bs>_)break;let me=Q.bs<=F&&_<Q.be;return me&&u.text===""&&Q.bs===u.bs&&Q.be===u.be?"straddle":me?Q:u.be>u.bs?"straddle":null}return null},jt=u=>u.bs===u.be,rn=(u,P,F=null)=>{let _=!1;for(let Q=u.bs;Q<u.be;Q++){let me=g.text[Q];if(me===kt)_=!0;else if(!/\s/.test(me))return!1}for(let Q=u.ss;Q<u.se;Q++){let me=P.text[Q];if(me===kt)_=!0;else if(!/\s/.test(me)){let ke=F&&e.scopeUnits&&jt(u)&&P.atomAt.get(Q);if(!ke||!je(ke.el)||F.ss!==F.se||F.bs>=F.be)return!1;for(let De=F.bs;De<F.be;De++)if(!/\s/.test(g.text[De]))return!1;let Se=P===f?1:2;if(!e.scopeUnits[Se].includes(ke.el)||(Se===1?n:s)?.reverse.has(ke.el))return!1;_=!0}}return _},Gt=(u,P)=>u.bs<P.be&&P.bs<u.be,fn=(u,P)=>u.bs<=P.be&&P.bs<=u.be&&jt(u)!==jt(P),$=(u,P)=>g.text.slice(u.bs,u.be).includes(kt)||P.text.slice(u.ss,u.se).includes(kt),l=u=>{if(jt(u))return!1;let P=u.bs,F=u.be;for(;P>0&&/\s/.test(g.text[P-1]);)P--;for(;F<g.text.length&&/\s/.test(g.text[F]);)F++;return(P===0||g.text[P-1]===kt)&&(F===g.text.length||g.text[F]===kt)},O=(u,P)=>!$(u,P)&&!l(u),R=(u,P)=>Gt(u,P)||fn(u,P)&&!(u.transferIn||u.transferOut||P.transferIn||P.transferOut)&&!(rn(u,f,P)&&O(P,b))&&!(rn(P,b,u)&&O(u,f)),K=(u,P)=>{if(u.bs!==P.bs||u.be!==P.be||u.toks.length!==P.toks.length)return!1;let F=u.ss,_=P.ss;for(let Q=0;Q<u.toks.length;Q++){let me=u.toks[Q],ke=P.toks[Q];if(me.k!==ke.k||me.atom&&!f.atomAt.get(F).el.isEqualNode(b.atomAt.get(_).el))return!1;F+=me.len,_+=ke.len}return!0},Z=(u,P,F,_)=>{for(let Q of g.atoms){if(Q.i<u.bs||Q.i>=u.be||_.has(Q)||Ne.has(Q))continue;let me=P.bTo[Q.i],ke=me>=0?F.atomAt.get(me):null;if(ke&&!ke.el.isEqualNode(Q.el))return!0}return!1},U=[],de=null,we=null,le=Oe.hunks,Ae=Re.hunks,W=0,X=0,pe=0,be=0,he=0,ee=u=>{u>pe&&(U.push({src:"base",from:pe,to:u,dL:be,dR:he}),pe=u)};for(;W<le.length||X<Ae.length;){let u=le[W],P=Ae[X],F=!!u&&(!P||u.bs<P.bs||u.bs===P.bs&&u.be<=P.be&&!P.lead);if(u&&P&&u.bs===P.bs&&jt(u)&&jt(P)){let _t=rn(u,f),So=rn(P,b);_t!==So&&(F=So)}let _=F?u:P,Q=F?P:u,me=!!Q&&K(u,P),ke=!!Q&&(F?!!le[W+1]&&K(le[W+1],P):!!Ae[X+1]&&K(u,Ae[X+1])),Se=!!Q&&!me&&!ke&&(qe===0||R(u,P)),De=Se,Le=wn(_,F?It:cn);if(Le==="straddle"&&(De=!0),!De&&_.be>_.bs&&(De=Z(_,F?xe:ie,F?b:f,F?oe:Ee)),!De&&me){ee(_.bs),U.push({src:"both",lfrom:u.ss,rfrom:P.ss,len:_.text.length,owner:u.owner||P.owner||null,transfer:u.transferIn||P.transferIn||null}),pe=_.be,be+=_.text.length-(_.be-_.bs),he+=_.text.length-(_.be-_.bs),W++,X++;continue}if(!De){ee(_.bs),U.push({src:F?"local":"remote",from:_.ss,to:_.se,inherit:Le&&Le!=="straddle"?Le:null,owner:_.owner||null,transfer:_.transferIn||null}),pe=_.be,F?(be+=_.text.length-(_.be-_.bs),W++):(he+=_.text.length-(_.be-_.bs),X++);continue}let Ue=_.bs,gt=_.be,lt=W,ut=X,Vt=_t=>_t.bs<gt&&_t.be>Ue||jt(_t)&&(_t.bs===Ue||_t.bs===gt);F?lt++:ut++,Se&&(Ue=Math.min(Ue,Q.bs),gt=Math.max(gt,Q.be),F?ut++:lt++);let Bt=!0;for(;Bt;){for(Bt=!1;lt<le.length&&Vt(le[lt]);)Ue=Math.min(Ue,le[lt].bs),gt=Math.max(gt,le[lt].be),lt++,Bt=!0;for(;ut<Ae.length&&Vt(Ae[ut]);)Ue=Math.min(Ue,Ae[ut].bs),gt=Math.max(gt,Ae[ut].be),ut++,Bt=!0}let mn=Ue+be,ln=Ue+he,yn=gt-Ue,Nn=gt-Ue;for(let _t=W;_t<lt;_t++)yn+=le[_t].text.length-(le[_t].be-le[_t].bs);for(let _t=X;_t<ut;_t++)Nn+=Ae[_t].text.length-(Ae[_t].be-Ae[_t].bs);let Bn=mn+yn,Dn=ln+Nn;if(ee(Ue),W<lt&&X<ut&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!f.atoms.length&&!b.atoms.length&&!g.pins.length&&!f.pins.length&&!b.pins.length){de||={fb:g,fl:f,fr:b,ML:ie,MR:xe,byEl:dt,cache:[null,null]};let _t=er(de,le,W,lt,Ae,X,ut,0,t),So=er(de,Ae,X,ut,le,W,lt,1,t);if(_t===null!=(So===null)){let ts=_t!==null,Ds=ts?_t:So;if(Ds){we||=new Map;for(let si of Ds)we.set(si,ts?"local":"remote")}U.push(ts?{src:"remote",from:ln,to:Dn}:{src:"local",from:mn,to:Bn}),pe=gt,be+=yn-(gt-Ue),he+=Nn-(gt-Ue),W=lt,X=ut;continue}}let en={kind:"text",node:e.node||null,base:co(g,Ue,gt),local:co(f,mn,Bn),remote:co(b,ln,Dn),resolved:null,range:null,bs:Ue,be:gt,lss:mn,lse:Bn,rss:ln,rse:Dn},Jn=e.sourceRetentions?$s(e.sourceRetentions,e.scope?.base,g,f,b,t,en):t;en.resolved=Jn==="local"?en.local:Jn==="remote"?en.remote:en.local+en.remote,Jn!=="remote"&&U.push({src:"local",from:mn,to:Bn,conflict:en}),Jn!=="local"&&U.push({src:"remote",from:ln,to:Dn,conflict:en});let Qn={site:"inline",policy:Jn,fb:g,fl:f,fr:b,scope:e.scope||null,synthetic:!!e.synthetic,full:T,merged:c};p.push(Qn),w(en,Qn),pe=gt,be+=yn-(gt-Ue),he+=Nn-(gt-Ue),W=lt,X=ut}ee(qe);let te=g.text,z=[];if(Oe.respell.size||Re.respell.size){let u=fo(Me),P=[];for(let F=0;F<Me.length;F++){let _=Me[F].raw,Q=Oe.respell.get(F)??_,me=Re.respell.get(F)??_;(Q!==_||me!==_)&&z.push([u[F],Q!==_&&me!==_?"both":Q!==_?"local":"remote"]),P.push(Q===me?Q:Q===_?me:me===_||t==="local"?Q:me)}te=P.join("")}let ne="",Te=[],Ce=[],Pe=[],ve=[];for(let u of U){let P=ne.length;if(u.src==="base"){for(let F=u.from;F<u.to;F++)Te.push(F),Ce.push(e.nativeTransfers?ie.bTo[F]:F+u.dL),Pe.push(e.nativeTransfers?xe.bTo[F]:F+u.dR),ve.push(u);ne+=te.slice(u.from,u.to)}else if(u.src==="both"){for(let F=0;F<u.len;F++){let _=u.transfer&&(u.transfer.side==="remote"?u.rfrom+F:u.lfrom+F);Te.push(u.transfer&&_>=u.transfer.ss&&_<u.transfer.se?u.transfer.bs+_-u.transfer.ss:-1),Ce.push(u.lfrom+F),Pe.push(u.rfrom+F),ve.push(u)}ne+=f.text.slice(u.lfrom,u.lfrom+u.len)}else{let F=u.src==="local"?f:b,_=u.transfer&&e.nativeTransfers.byOrigin[u.src==="local"?"remote":"local"].get(u.transfer.key);for(let Q=u.from;Q<u.to;Q++){let me=u.transfer&&Q>=u.transfer.ss&&Q<u.transfer.se?u.transfer.bs+Q-u.transfer.ss:-1,ke=me>=0&&(!_||_.destination===u.owner)?(u.src==="local"?xe:ie).bTo[me]:-1;Te.push(me),Ce.push(u.src==="local"?Q:ke),Pe.push(u.src==="remote"?Q:ke),ve.push(u)}ne+=F.text.slice(u.from,u.to)}u.ms=P,u.me=ne.length,u.conflict&&(u.conflict.range||(u.conflict.range=[P,P]),u.conflict.range[1]=ne.length)}let _e=ne.length,Je=new Int32Array(qe+1).fill(-1),Ze=new Int32Array(f.text.length+1).fill(-1),Ut=new Int32Array(b.text.length+1).fill(-1);for(let u=0;u<_e;u++)Te[u]>=0&&(Je[Te[u]]=u),Ce[u]>=0&&(Ze[Ce[u]]=u),Pe[u]>=0&&(Ut[Pe[u]]=u);let Pt=(u,P)=>{let F=-1,_=-1;for(let Q=u.from;Q<u.to;Q++){let me=P[Q];me>=0&&(F<0&&(F=me),_=me+1)}return F<0?null:[F,_]},C=[],G=[];for(let u of new Set(dt.values()))u.new==="local"?C.push(u):u.new==="remote"&&G.push(u);let re=(u,P)=>{u.remote=P.remote,u.remoteMark=P.remoteMark,u.new="both",P.merged=u,dt.set(P.remote,u)};if(C.length&&G.length){let u=e.idOf;for(let P of C){let F=u?u.local(P.local):null;if(!F)continue;let _=G.find(Q=>!Q.merged&&Q.tag===P.tag&&!!Q.block==!!P.block&&u.remote(Q.remote)===F);_&&re(P,_)}for(let P of C){if(P.remote)continue;let F=Pt(P.localMark,Ze);if(F)for(let _ of G){if(_.merged||_.tag!==P.tag||!!_.block!=!!P.block)continue;let Q=Pt(_.remoteMark,Ut);if(Q&&Math.min(F[1],Q[1])-Math.max(F[0],Q[0])>0){re(P,_);break}}}}Nt.clear();let ge=u=>{for(let P of u)if(P.block)return Ct(dt.get(P.el));return null},ye=g.marks.some(u=>u.block)||f.marks.some(u=>u.block)||b.marks.some(u=>u.block),ce=new Array(_e).fill(null),se=new Set;if(e.nativeTransfers)for(let u=0;u<_e;u++){let P=ve[u].owner;ce[u]=P?Ct(dt.get(P)):Te[u]>=0?ge(g.stackAt[Te[u]]):null}else if(ye){let u=(Le,Ue,gt)=>{let lt=new Set([Le,Ue,gt]);lt.delete(null);let ut=[];for(let Bt of lt){let mn=Bt===Le,ln=Bt===Ue,yn=Bt===gt;(ln===yn?ln:ln===mn?yn:ln)&&ut.push(Bt)}if(ut.length<=1)return ut[0]||null;let Vt=t==="local"?Ue:gt;return ut.includes(Vt)?Vt:ut[0]},P=(Le,Ue)=>Ue>=0?ge(Le.stackAt[Ue]):null,F=new Map;for(let Le=0;Le<_e;Le++){if(ne[Le]!==kt)continue;let Ue=Te[Le]>=0?P(g,Te[Le]):null,gt=P(f,Ce[Le]),lt=P(b,Pe[Le]);F.set(Le,[Ue,Te[Le]>=0?u(Ue,gt,lt):gt||lt])}let _=new Set([...F.values()].map(Le=>Le[1])),Q=Le=>Le!==kt&&Le!==Un&&!/\s/.test(Le),me=(Le,Ue)=>{let gt=Le;for(;gt<Ue&&!Q(ne[gt]);)gt++;return gt<Ue&&Te[gt]>=0?P(g,Te[gt]):null},ke=new Map,Se=0;for(let Le=0;Le<_e;Le++){if(ne[Le]!==kt)continue;let[Ue,gt]=F.get(Le),lt=me(Se,Le),ut=gt,Vt=ke.get(ut)===ut&<===ut;ut&&ke.has(ut)&&!Vt&&Ue&&!ke.has(Ue)&&!_.has(Ue)&&(ut=Ue),ut&&!ke.has(ut)&&ke.set(ut,lt);for(let Bt=Se;Bt<=Le;Bt++)ce[Bt]=ut;Se=Le+1}let De=Le=>{for(let Ue=0;Ue<Le.text.length;Ue++)if(Q(Le.text[Ue])&&!P(Le,Ue))return!0;return!1};if(!De(g)&&!De(f)&&!De(b)){let Le=[],Ue=0;for(let lt=0;lt<_e;lt++)(ne[lt]===kt||lt===_e-1)&&(Le.push([Ue,lt]),Ue=lt+1);let gt=new Set(ce);for(let lt=0;lt<Le.length;lt++){let[ut,Vt]=Le[lt];if(ce[Vt])continue;let Bt=ut;for(;Bt<=Vt&&!Q(ne[Bt]);)Bt++;if(Bt>Vt)continue;let mn=P(g,Te[Bt]),ln=P(f,Ce[Bt]),yn=P(b,Pe[Bt]),Nn=u(mn,ln,yn)||ln||yn||mn;if(Nn&&!gt.has(Nn)){gt.add(Nn);for(let en=ut;en<=Vt;en++)ce[en]=Nn;continue}let Bn=lt>0&&ce[Le[lt-1][1]],Dn=lt+1<Le.length&&ce[Le[lt+1][1]];if(Bn)se.add(Le[lt-1][1]);else if(Dn&&ne[Vt]===kt)se.add(Vt);else continue;for(let en=ut;en<=Vt;en++)ce[en]=Bn||Dn}}}let Ie=new Map,Be=u=>{let P=Ie.get(u);if(P)return P;P=[1/0,-1/0];for(let[F,_]of[[u.baseMark,Je],[u.localMark,Ze],[u.remoteMark,Ut]]){let Q=F&&Pt(F,_);Q&&(P[0]=Math.min(P[0],Q[0]),P[1]=Math.max(P[1],Q[1]))}return Ie.set(u,P),P},He=(u,P,F)=>{let _=-1,Q=-1;for(let me=0;me<u.length;me++){let ke=dt.get(u[me].el);ke===P&&(_=me),ke===F&&(Q=me)}return _>=0&&Q>=0?_-Q:0},Ke=(u,P)=>[...u].sort((F,_)=>{for(let ke of P){let Se=He(ke,F,_);if(Se)return Se}let Q=Be(F),me=Be(_);return Q[0]-me[0]||me[1]-Q[1]||F.rank-_.rank||F.id-_.id}),pt=new Map,ht=new Map,Kt=e.nativeTransfers?[]:null,Ht=u=>{if(Kt)return Kt;let P=Te[u],F=Ce[u],_=Pe[u],Q=ve[u];if(P>=0){let lt=g.stackAt[P],ut=f.stackAt[F],Vt=b.stackAt[_],Bt=pt.get(lt);Bt||pt.set(lt,Bt=new Map);let mn=Bt.get(ut);mn||Bt.set(ut,mn=new Map);let ln=mn.get(Vt);if(ln)return ln;let yn=Lt(lt),Nn=Lt(ut),Bn=Lt(Vt),Dn=new Set;for(let en of new Set([...yn,...Nn,...Bn])){let Jn=yn.has(en),Qn=Nn.has(en),_t=Bn.has(en);(Qn===_t?Qn:Qn===Jn?_t:Qn)&&Dn.add(en)}return ln=Ke(Dn,[ut,Vt,lt]),mn.set(Vt,ln),ln}if(Q.src==="both"){let lt=f.stackAt[F],ut=b.stackAt[_];return Ke(new Set([...Lt(lt),...Lt(ut)]),[lt,ut])}let ke=(Q.src==="local"?f:b).stackAt[Q.src==="local"?F:_];if(!Q.inherit)return Ke(Lt(ke),[ke]);let Se=ht.get(Q);Se||ht.set(Q,Se=new Map);let De=Se.get(ke);if(De)return De;let Le=new Set(Lt(ke));for(let lt of Q.inherit.added)Le.add(Ct(lt));for(let lt of Q.inherit.removed)Le.delete(Ct(lt));let Ue=Q.src==="local"?b:f,gt=(Q.src==="local"?xe.bTo:ie.bTo)[Q.inherit.bs];return De=Ke(Le,[ke,Ue.stackAt[gt]]),Se.set(ke,De),De},un=new Int32Array(f.text.length+1);un[f.text.length]=_e;for(let u=f.text.length-1;u>=0;u--)un[u]=Ze[u]>=0?Ze[u]:un[u+1];Pi.caret+=f.text.length;let bt=u=>u<=0?0:(u>f.text.length&&(u=f.text.length),Ze[u-1]>=0?Ze[u-1]+1:un[u]),it=[],$e=[],vt=null,at=[],Dt="",bn=-1,on=u=>{vt?vt.appendChild(u):it.push(u)},hn=u=>{if(!Dt)return;let P=o.createTextNode(Dt);on(P),$e.push({node:P,ms:bn,me:u,local:[],u:at.length?at[at.length-1].u:null}),Dt=""},Yt=new Set,En=new Map,oo=new Set,Rn=u=>{let P=o.createElement(u.tag);if(u.block&&vn.add(P),!En.has(u)){En.set(u,P),N(u.base,u.local,u.remote,P),h.set(P,{base:u.base,local:u.local,remote:u.remote});let _=(ke,Se)=>m&&u[Se]&&ke.reverse.get(u[Se])?Se:null,Q=!u.base&&(_(n,"local")||_(s,"remote"));if(Q){let ke=Q==="local"?n.reverse.get(u.local):s.reverse.get(u.remote),Se=h.get(P);Se.local=Se.local||n.map.get(ke)||null,Se.remote=Se.remote||s.map.get(ke)||null,a.push({kind:"move",el:P,source:Q}),e.moveBuilt?.(ke,Q,u[Q],P)}else u.base||a.push({kind:"insert",el:P,source:u.local&&u.remote?"both":u.local?"local":"remote"});let me=h.get(P);me.local&&(oo.has(me.local)?me.local=null:oo.add(me.local))}else{let _=En.get(u);for(let Q of _.attributes)Q.name!=="id"&&Q.name!=="data-id"&&M(P,Q,Q.value);h.set(P,{base:null,local:null,remote:null})}on(P),at.push({u,el:P}),vt=P},xo=new Set,qn=new Map;for(let u of f.pins){let P=bt(u.i);qn.has(P)||qn.set(P,[]),qn.get(P).push(u)}let Ro=u=>{let P=qn.get(u);if(P){hn(u);for(let F of P){let _=F.el.namespaceURI&&F.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(F.el.namespaceURI,F.el.tagName):o.createElement(F.el.tagName);h.set(_,{base:null,local:F.el,remote:null,pinned:!0}),xo.add(_),on(_)}}},es=g.atoms.length||f.atoms.length||b.atoms.length,Po=u=>{if(!es)return null;let P=Te[u]>=0?g.atomAt.get(Te[u]):null,F=Ce[u]>=0?f.atomAt.get(Ce[u]):null,_=Pe[u]>=0?b.atomAt.get(Pe[u]):null;return P||F||_?{ab:P,al:F,ar:_}:null},Kn=(u,P,F)=>{let _=e.idOf;if(!_||!_.base)return!1;let Q=_.base(u.el);return Q!=null&&Q===_[F](P.el)},To=(u,P,F,_,Q)=>{if(!u||!m)return null;let me=B.get(P.reverse.get(u.el))||null;return!me||me===_||(_?me.el.isEqualNode(_.el)&&!Kn(me,u,Q):F.bTo[me.i]>=0)?null:me},so=(u,P)=>{if(!u||!m||!e.moveIn)return null;let F=P.reverse.get(u.el);return F&&!B.has(F)?F:null},vo=(u,P)=>{let F=new Map;for(let _ of u.atoms)F.set(P(_),(F.get(P(_))||0)+1);return F},ue=vo(g,D),We=vo(f,y),Ve=vo(b,k),et=u=>{let P=D(u);return ue.get(P)===1&&(We.get(P)||0)<=1&&(Ve.get(P)||0)<=1},wt=new Map,Fe=new Set,ze=new Set,xt=new Set,Ye=null;for(let u=0;u<_e;u++){let P=Po(u);if(!P)continue;let{ab:F,al:_,ar:Q}=P,me=To(Q,s,xe,F,"remote"),ke=To(_,n,ie,F,"local"),Se=F,De=null;if(me?(Se=me,De="remote"):ke&&(Se=ke,De="local"),Se){F&&Se!==F&&(Ye||=new Map).set(F,De),Fe.has(Se)?wt.set(u,{dup:Se.el}):(Fe.add(Se),wt.set(u,{bk:Se,from:De,al:_,ar:Q}));continue}let Le=so(Q,s),Ue=so(_,n),gt=Le||Ue;if(gt){ze.has(gt)?wt.set(u,{dup:gt}):(ze.add(gt),wt.set(u,{moveIn:gt,side:Le?"remote":"local",sideEl:Le?Q.el:_.el}));continue}let lt=(Vt,Bt)=>Vt&&m&&B.get(Bt.reverse.get(Vt.el))||null,ut=lt(Q,s)||lt(_,n);if(ut&&(xt.add(ut),ve[u].conflict&&(et(ut)||Q&&(Q.el===ut.el||s.identityPaired?.has(ut.el))&&Kn(ut,Q,"remote")||_&&(_.el===ut.el||n.identityPaired?.has(ut.el))&&Kn(ut,_,"local")))){if(Fe.has(ut)){wt.set(u,{dup:ut.el});continue}Fe.add(ut)}wt.set(u,{al:_,ar:Q})}let ot=new Map,ct,Wt,Mt=(u,P)=>{if(u[P]>=0)return u[P];for(let F=P-1;F>=0;F--)if(u[F]>=0)return u[F]+1;return 0};if(m)for(let u of g.atoms){if(Fe.has(u)||xt.has(u))continue;let P=n.map.get(u.el)||null,F=s.map.get(u.el)||null,_=P&&x.get(P),Q=F&&Y.get(F);if(P&&!_||F&&!Q)continue;let me=!(_&&Q)&&Ne.has(u);if(!me&&!(_&&Q&&(et(u)||Ye?.has(u)||(_.el===u.el||n.identityPaired?.has(u.el))&&(Q.el===u.el||s.identityPaired?.has(u.el))&&Kn(u,_,"local")&&Kn(u,Q,"remote"))))continue;let ke=Ye?.get(u),Se=t;if(ke){let lt=ke==="local"?b:f,ut=ke==="local"?s:n,Vt=ke==="local"?Wt:ct;if(Vt===void 0){Vt=lt.atoms.length===g.atoms.length;for(let Bt=0;Vt&&Bt<g.atoms.length;Bt++)Vt=ut.reverse.get(lt.atoms[Bt].el)===g.atoms[Bt].el;ke==="local"?Wt=Vt:ct=Vt}Vt&&(Se=ke)}let De=Se==="local"?[[_,Ze],[Q,Ut]]:[[Q,Ut],[_,Ze]],[Le,Ue]=De.find(([lt])=>lt),gt=Mt(Ue,Le.i);ot.has(gt)||ot.set(gt,[]),ot.get(gt).push({a:u,lt:P,rt:F,edited:me}),Fe.add(u)}if(m&&e.moveIn){let u=[[f,n,Ze,"local"],[b,s,Ut,"remote"]];t!=="local"&&u.reverse();for(let[P,F,_,Q]of u)for(let me of P.atoms){let ke=so(me,F);if(!ke||ze.has(ke))continue;ze.add(ke);let Se=Mt(_,me.i);ot.has(Se)||ot.set(Se,[]),ot.get(Se).push({move:ke,side:Q,sideEl:me.el})}}let Qt=u=>{let P=ot.get(u);if(P){if(hn(u),P.some(F=>je(F.move?F.sideEl:F.a.el)))for(;at.length;)at.pop(),vt=at.length?at[at.length-1].el:null;for(let{a:F,lt:_,rt:Q,edited:me,move:ke,side:Se,sideEl:De}of P){if(ke){let Ue=e.moveIn(ke,Se,De);Ue&&on(Ue);continue}Yt.add(F);let Le=A(F.el,_,Q);me&&(w({kind:"structure",el:Le,detail:"edit-beats-delete",base:F.el},{subject:F.el,deleted:_?"remote":"local"}),a.push({kind:"insert",el:Le,source:_?"local":"remote"})),on(Le)}}},vn=new Set,Fn=r.length>d;for(let u=0;u<_e;u++){let P=Po(u),F=e.scopeUnits&&P&&(P.ab?.stack.some(ke=>ke.block)||P.al?.stack.some(ke=>ke.block)||P.ar?.stack.some(ke=>ke.block)),Q=!!P&&je((P.ab||P.al||P.ar).el)&&!F?[]:ce[u]?[ce[u],...Ht(u)]:Ht(u),me=0;for(;me<at.length&&me<Q.length&&at[me].u===Q[me];)me++;if(me<at.length)for(hn(u);at.length>me;)at.pop(),vt=at.length?at[at.length-1].el:null;if(Ro(u),Qt(u),Q.length>at.length)for(hn(u);at.length<Q.length;)Rn(Q[at.length]);if(ne[u]===kt){if(se.has(u))continue;hn(u);let ke=at.length;for(;ke>0&&!at[ke-1].u.block;)ke--;if(ke>0)for(Fn&&c.breakOut.set(u,at[ke-1].el);at.length>=ke;)at.pop(),vt=at.length?at[at.length-1].el:null;continue}if(P){hn(u);let ke=wt.get(u),Se;if(ke.dup){w({kind:"structure",el:null,detail:"both-moved",base:ke.dup},{subject:ke.dup});continue}if(ke.moveIn){if(Se=e.moveIn(ke.moveIn,ke.side,ke.sideEl),!Se)continue}else if(ke.bk){let De=ke.bk;if(Yt.add(De),De===P.ab)Se=A(De.el,ke.al.el,ke.ar.el);else{let Le=n.map.get(De.el)||null,Ue=s.map.get(De.el)||null;Se=A(De.el,Le,Ue),(!Le||!Ue)&&w({kind:"structure",el:null,detail:"move-beats-delete",base:De.el},{subject:De.el,deleted:Le?"remote":"local"}),a.push({kind:"move",el:Se,source:ke.from})}}else ke.al?(Se=E(ke.al.el,"local"),ke.ar&&(h.get(Se).remote=ke.ar.el),a.push({kind:"insert",el:Se,source:ke.ar?"both":"local"})):(Se=E(ke.ar.el,"remote"),a.push({kind:"insert",el:Se,source:"remote"}));Fn&&c.atomOut.set(u,Se),on(Se);continue}Dt||(bn=u),Dt+=ne[u]}if(hn(_e),(qn.has(_e)||ot.has(_e))&&(at.length=0,vt=null,Ro(_e),Qt(_e)),_e===0&&(f.placeholder||b.placeholder||g.placeholder)){let u=o.createElement("br");h.set(u,{base:g.placeholder,local:f.placeholder,remote:b.placeholder}),it.push(u)}let Pn=0,ft=u=>{for(;Pn>0&&$e[Pn-1].me>=u;)Pn--;for(;Pn<$e.length&&$e[Pn].me<u;)Pn++;let P=$e[Pn];if(!P)return $e[$e.length-1]||null;let F=$e[Pn+1];return P.me===u&&F&&F.ms===u?F:P},Qe=new Map,Et={},nt=(u,P,F)=>{let _=ft(u)||(F?Et:null);if(!_)return;let Q=Qe.get(_)||{l:!1,r:!1};P!=="remote"&&(Q.l=!0),P!=="local"&&(Q.r=!0),Qe.set(_,Q)},At=u=>{if(u.conflict)return!0;let P=u.src==="local"?f.text:u.src==="remote"?b.text:"";for(let F=u.from;F<u.to;F++)if(P[F]!==Un&&P[F]!==kt)return!0;return!1};for(let u of U)u.src!=="base"&&nt(u.ms,u.conflict?"both":u.src,At(u));for(let[u,P]of z)Je[u]>=0&&nt(Je[u],P);for(let u of $e.length?$e:[Et]){let P=Qe.get(u);P&&a.push({kind:"text",node:u.node||null,source:P.l&&P.r?"both":P.l?"local":"remote"})}for(let u of Ge){if(En.has(u))continue;let P=!u.local&&!(m&&n.map.get(u.base)),F=!u.remote&&!(m&&s.map.get(u.base));!P&&!F||a.push({kind:"remove",source:P&&F?"both":P?"local":"remote",base:u.base})}if(we)for(let[u,P]of we)En.has(u)&&w({kind:"structure",el:En.get(u),detail:"edit-beats-delete",base:u.base},{subject:u.base,deleted:P});let Xt=(u,P,F)=>{if(P<=u)return!1;for(let _=u;_<P;_++)if(F[_]>=0)return!1;return!0};for(let u of Ge)for(let P of["local","remote"]){let F=u[P+"Mark"],_=u.baseMark;if(!F)continue;let Q=P==="local"?ie:xe;if(!Xt(_.from,_.to,Q.bTo)||!Xt(F.from,F.to,Q.toB))continue;let me=(P==="local"?le:Ae).find(ke=>ke.ss<=F.from&&F.from<ke.se);me&&(me.be<=_.from||me.bs>=_.to)&&a.push({kind:"move",el:En.get(u)||null,source:P})}let Rt=u=>{let P=dt.get(u.node.parentNode);return P?Ct(P):null};for(let u of f.nodes){let P=-1;for(let _=u.s;_<u.e;_++)if(Ze[_]>=0){P=Ze[_];break}let F;if(P>=0)F=ft(P);else{let _=bt(u.s),Q=Rt(u);F=$e.find(me=>me.u===Q&&me.me>=_)||$e.filter(me=>me.u===Q).pop()}F&&F.local.push(u)}let Ft=new Map,tn=$e[$e.length-1]||null,Tt=0;for(let u of f.nodes){let P=null;for(let F=u.s;F<=u.e;F++){let _=bt(F);for(;Tt>0&&$e[Tt-1].me>=_;)Tt--;for(;Tt<$e.length&&$e[Tt].me<_;)Tt++;let Q=ke=>ke&&_>=ke.ms&&_<=ke.me&&(_<ke.me||F===u.e||ke===P),me=Q($e[Tt])?$e[Tt]:Q($e[Tt+1])?$e[Tt+1]:$e[Tt]||tn;if(!me)break;if(P===me){let ke=Ft.get(me);ke[ke.length-1].to=F-u.s;continue}P=me,Ft.has(me)||Ft.set(me,[]),Ft.get(me).push({node:u.node,from:F-u.s,to:F-u.s,flatStart:u.s})}}for(let u of $e){let P=u.local,F=!1;for(let ke of P)for(let Se=ke.s;Se<ke.e&&!F;Se++)(Ze[Se]<u.ms||Ze[Se]>=u.me)&&(F=!0);h.set(u.node,{base:null,local:P.map(ke=>ke.node),remote:null,caret:Ft.get(u)||[],partial:F});let _=u.ms,Q=u.me-u.ms,me=ke=>{let Se=0,De=-1;for(let Le of P){let Ue=Le.e-Le.s;if(ke<=Se+Ue){De=Le.s+(ke-Se);break}Se+=Ue}return De<0&&(De=P.length?P[P.length-1].e:0),Math.max(0,Math.min(bt(De)-_,Q))};me.flat=ke=>Math.max(0,Math.min(bt(ke)-_,Q)),i.set(u.node,me)}function mt(){if(!f.text.includes(kt))return[{flatLocal:f.text,localNodes:f.nodes,textNodes:$e,lToM:Ze,mapLocal:bt}];let u=[],P=0,F=0;for(let _=0;_<=f.text.length;_++){if(_<f.text.length&&f.text[_]!==kt)continue;let Q=P,me=_;if(me>Q){let ke=[];for(;F<f.nodes.length&&f.nodes[F].e<=Q;)F++;for(let Se=F;Se<f.nodes.length&&f.nodes[Se].s<me;Se++){let De=f.nodes[Se],Le=Math.max(De.s,Q),Ue=Math.min(De.e,me);Le<Ue&&ke.push({node:De.node,s:Le-Q,e:Ue-Q})}u.push({flatLocal:f.text.slice(Q,me),localNodes:ke,textNodes:$e,lToM:Ze.subarray?Ze.subarray(Q,me+1):Ze.slice(Q,me+1),mapLocal:Se=>bt(Q+Math.max(0,Math.min(Se,me-Q)))})}P=_+1}return u}let St={...e,blocks:vn,ignored:u=>xo.has(u)||(e.ignored?e.ignored(u):!1)},Zt=e.ignoreAttribute||(()=>!1),_n=Gs(nn(it,St),Zt)!==Gs(b,Zt);if(p.length){let u=P=>{let F=h.get(P);return F&&F.unchanged?F.remote:null};c.text=ne,c.textNodes=$e,c.out=nn(it,{...St,via:u})}let Sn=null;if(e.scopeUnits){Sn=new Map;let u=new Set(it),P=Se=>{for(;Se&&!u.has(Se);)Se=Se.parentNode;return Se},F=e.scopeUnits.map(Se=>{let De=new Map;for(let Le of Se)if(Le.nodeType===1)De.set(Le,Le);else for(let Ue of Le.nodes)De.set(Ue,Le);return De}),_=(Se,De)=>{for(;Se&&!De.has(Se);)Se=Se.parentNode;return Se?De.get(Se):null},Q=[g,f,b].map((Se,De)=>{let Le=new Array(Se.text.length);for(let Ue of Se.nodes){let gt=_(Ue.node,F[De]);gt&&Le.fill(gt,Ue.s,Ue.e)}for(let Ue of Se.atoms)Le[Ue.i]=_(Ue.el,F[De]);return Le}),me=(Se,De)=>{if(!Se||!De)return;let Le=Sn.get(Se);Le||Sn.set(Se,Le=new Set),Le.add(De)};for(let Se of it){let De=h.get(Se);De&&(me(_(De.base,F[0]),Se),me(_(De.local,F[1]),Se),me(_(De.remote,F[2]),Se))}for(let Se of $e){let De=P(Se.node);for(let Le=Se.ms;Le<Se.me;Le++)me(Q[0][Te[Le]],De),me(Q[1][Ce[Le]],De),me(Q[2][Pe[Le]],De)}let ke=new Map(it.map((Se,De)=>[Se,De]));for(let[Se,De]of Sn)Sn.set(Se,Array.from(De).sort((Le,Ue)=>ke.get(Le)-ke.get(Ue)))}return{unitOutputs:Sn,nodes:it,text:ne,textNodes:$e,localDiverged:_n,mapLocal:bt,conflicts:r.slice(d),granularity:q?"line":"word",segments:mt(),localHunks:le,remoteHunks:Ae,lToM:Ze}}var xs=Symbol("lost");function rr(){return{links:new Map,removed:new Set,consumed:new Set,link(e,o){this.links.set(e,o)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let o of e.nodes)this.removed.add(o)},consume(e){for(let o of e)this.consumed.add(o)}}}var sr=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function ir({locals:e,rec:o,root:t,provenance:n,segments:s,ignored:h}){let i=new Map,r=(S,T)=>{let M=i.get(S);M||i.set(S,M=new Set),M.add(T)},a=new Set,d=new Set;for(let S of s){let T=S.textNodes;for(let M of T)a.add(M.node);for(let M of S.localNodes){d.add(M.node);let L=0,N=null;for(let A=M.s;A<M.e;A++){let E=S.lToM[A];if(E<0)continue;for((!T[L]||E<T[L].ms)&&(L=0);L<T.length&&T[L].me<=E;)L++;let V=T[L]&&T[L].ms<=E?T[L].node:xs;V!==N&&r(M.node,V),N=V}}}let w=new Set,c=new Map,p=new Set;(function S(T){w.add(T);let M=n.get(T);if(T.nodeType===1)M&&M.local&&M.local.nodeType===1&&(r(M.local,T),M.unchanged&&p.add(M.local)),T.tagName==="TEMPLATE"&&T.content&&c.set(T.content,T);else if(M&&Array.isArray(M.local)&&!a.has(T))for(let L of M.local)r(L,T);for(let L=sr(T).firstChild;L;L=L.nextSibling)S(L)})(t);let m=new Set;for(let[S,T]of o.links)r(S,T),m.add(S);let v=S=>{let T=S.parentNode;return T&&T.nodeType===11?c.get(T)||null:T},I=(S,T)=>{for(let M=S;M;M=v(M))if(M===T)return!0;return!1},g=S=>o.removed.has(S)||o.consumed.has(S),f=S=>{for(let T=S.parentNode;T&&T.nodeType===1;T=T.parentNode){if(p.has(T))return"kept";if(g(T))return"decided";if(i.has(T))return null}return null},b=new Map;for(let S of e)b.set(S,B(S));return b;function B(S){let T=i.get(S);if(T&&(T.size!==1||T.has(xs)))return{kind:"unknown",reason:"several-outputs"};let M=T?T.values().next().value:null;if(M&&(M.nodeType!==1||!w.has(M)))return{kind:"unknown",reason:"output-not-placed"};if(!M){let E=g(S)?"decided":f(S);if(E==="kept")return{kind:"untouched"};if(E!=="decided")return{kind:"unknown",reason:"unmapped"}}let L=[],N=A(S,!!M&&(p.has(S)||m.has(S)),!M||g(S));if(N)return{kind:"unknown",reason:N};return M?{kind:"single",output:M,owned:L,carried:m.has(S)}:{kind:"removed"};function A(E,V,j){for(let D=sr(E).firstChild;D;D=D.nextSibling){if(D.nodeType===1?h(D):D.nodeType!==3&&D.nodeType!==8)continue;let y=i.get(D);if(y)for(let k of y){if(k===xs||!w.has(k))return"output-not-placed";if(!M)return"survives-elsewhere";if(!I(k,M))return"escaped";L.push(k)}else if(!V&&!j&&!g(D)&&!d.has(D))return"unmapped";if(D.nodeType===1){let k=A(D,V||p.has(D)||m.has(D),j||g(D));if(k)return k}}return null}}}function lr(e,o){if(!o)return!1;let t=o.nodeType===1&&o.tagName==="TEMPLATE"?[o,...o.querySelectorAll("template")]:[...o.querySelectorAll("template")];for(let n of t)if(n.content.contains(e)||lr(e,n.content))return!0;return!1}function ar(e,o){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let t=[],n=new Set;for(let s of Array.from(e.elements)){if(!s||s.nodeType!==1||s.ownerDocument!==o&&!lr(s,o.documentElement))throw new TypeError("lineage.elements must be elements of the live document");n.has(s)||(n.add(s),t.push(s))}return t}var cr=new WeakMap;function fr(e){let o=new Map;for(let t of e){let n=[],s=!1;(function h(i){i.nodeType===1&&i.namespaceURI==="http://www.w3.org/1999/xhtml"&&i.localName==="template"&&(s=!0);for(let r=i.firstChild;r;r=r.nextSibling)n.push(r),r.nodeType===1&&h(r)})(t),o.set(t,{nodes:n,opaque:s})}return o}function Ts(e,o,t){if(e.lineage===void 0)return t(e);if(!o||o.nodeType!==1)throw new TypeError("lineage requires an element root");let n=e.lineage,s=ar(n,o.ownerDocument),h=!1,i={...e,lineage:{elements:s,onResult(r,a){if(!h)return h=!0,n.onResult(r,a)}}};try{return cr.set(i.lineage,fr(s)),t(i)}catch(r){if(!h){h=!0;try{n.onResult({version:1,root:o,status:"incomplete",entries:s.map(An)},null)}catch{}}throw r}}function vs(e,{liveRoot:o,localRoot:t,toLive:n}){let s=ar(e,o.ownerDocument),h=d=>d===o||o.contains(d),i=new Map,r=new Set(s.filter(h));if(r.size&&t===o)for(let d of r)i.set(d,d);else r.size&&(function d(w){let c=n(w);r.delete(c)&&i.set(c,w);for(let p=w.firstElementChild;p&&r.size;p=p.nextElementSibling)d(p)})(t);return{spec:e,watched:s,root:o,locals:Array.from(new Set(i.values())),before:cr.get(e)||fr(s),delivered:!1,result:null,finish(d,w){return this.resolve=w,this.plans=d,this.result={version:1,root:this.root,status:"complete",entries:s.map(c=>Hi(c,i.get(c),d,w,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(d,w){this.root=w;let c=this.resolve,p=v=>{let I=c(v);return I===d?w:I};return this.finish(this.plans,p)},deliver(d){this.delivered||(this.delivered=!0,e.onResult(this.result,d))}}}var An=e=>({from:e,to:[],kind:"unknown",complete:!1});function Hi(e,o,t,n,s){let h=s.root,i=p=>!!p&&(p===h||h.contains(p)),r=o&&t?t.get(o):null;if(!r||r.kind==="unknown")return An(e);let a=s.before.get(e);if(!a||a.opaque)return An(e);let d=a.nodes,w=p=>i(p)||!!(p&&p.ownerDocument===h.ownerDocument&&h.ownerDocument.documentElement?.contains(p));if(r.kind==="untouched"){if(!i(e))return An(e);for(let p of d)if(w(p)&&!e.contains(p))return An(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(r.kind==="removed")return w(e)||d.some(w)?An(e):{from:e,to:[],kind:"removed",complete:!0};let c=n(r.output);if(!c||c.nodeType!==1||!i(c)||c!==e&&w(e))return An(e);for(let p of d)if(w(p)&&!c.contains(p))return An(e);for(let p of r.owned){let m=n(p),v=Array.isArray(m)?m:[m];for(let I of v)if(!I||!i(I)||!c.contains(I))return An(e)}return r.carried&&!ur(c,r.output,n)?An(e):{from:e,to:[c],kind:c===e?"retained":"replaced",complete:!0}}function ur(e,o,t){for(let n=o.firstChild;n;n=n.nextSibling){let s=t(n),h=Array.isArray(s)?s:[s];for(let i of h)if(!i||!e.contains(i))return!1;if(n.nodeType===1&&!ur(e,n,t))return!1}return!0}function Ao(e,o,t){let n=vs(e,{liveRoot:o,localRoot:o,toLive:s=>s});return n.result={version:1,root:o,status:"complete",entries:n.watched.map(s=>An(s))},t.lineage=n.result,n}function dr(e,o,t,n,s){if(!s(e.length*8+1))return null;let h=0,i=o===0,r=!1;for(let a of an(e,n)){if(!s(1))return null;if(h+=a.len,h===o&&(i=!0),h===t&&(r=!0),h>=t)break}return i&&r}function Wi(e,o,t,n,s,h,i){if(!i(o.length*2))return!1;let r=new Map,a=new Map,d=new Set;for(let w of o){let c=w.bs<w.be,p=c?t[w.ownerIndex].text.base:t[w.ownerIndex].text[e],m=c?w.bs:w.ss,v=c?w.be:w.se;if(!i((v-m)*4+1))return!1;for(;m<v&&/\s/.test(p[m]);)m++;for(;v>m&&/\s/.test(p[v-1]);)v--;if(m===v)continue;let I=p.slice(m,v),g=c?r:a;c&&w.text&&d.add(I),g.has(I)?g.set(I,null):g.set(I,{h:w,from:m,to:v})}for(let w of n){if(!i(1))return!1;if(w.side!==e)continue;let c=w.deletion,p=t[c.ownerIndex].text.base;if(!i((c.be-c.bs)*3)||d.has(p.slice(c.bs,c.be).trim()))return!1}for(let[w,c]of r){if(!i(w.length+1))return!1;let p=a.get(w);if(!c||!p)continue;let m=c.h,v=p.h;if(!m.text||m.transferOut||v.transferIn||m.owner===v.owner)continue;let I=t[m.ownerIndex],g=t[v.ownerIndex];if(!i(I.text.base.length))return!1;if(!/\S/.test(I.text.base.slice(0,m.bs)+I.text.base.slice(m.be)))continue;let f=dr(I.text.base,c.from,c.to,h,i),b=dr(g.text[e],p.from,p.to,h,i);if(f===null||b===null)return!1;if(!f||!b)continue;let B=`${I.index}:${c.from}:${c.to}`,S={key:B,side:e,source:m.owner,destination:v.owner,deletion:m,insertion:v,sourceOffset:c.from-m.bs,targetOffset:p.from-v.ss,length:c.to-c.from};m.transferOut=S,v.transferIn=S,s[e].set(B,S),n.push(S)}return!0}function hr({base:e,local:o,remote:t,localTwin:n,remoteTwin:s,eligible:h,nodes:i,budget:r=zt(2e4*32)}){let a=N=>N>r.remaining?!1:(r.remaining-=N,r.nativeSteps=(r.nativeSteps||0)+N,!0);if(e.length<2||o.length!==e.length||t.length!==e.length||!a(e.length*12))return null;for(let[N,A]of[["base",e],["local",o],["remote",t]]){let E=i[N];if(E.length!==A.length||E.some((V,j)=>V!==A[j]))return null}let d=[],w=0;for(let N=0;N<e.length;N++){let A=e[N],E=o[N],V=t[N];if(n(A)!==E||s(A)!==V)return null;let j={};for(let[D,y]of[["base",A],["local",E],["remote",V]]){if(!h(y)||y.tagName!==A.tagName||y.namespaceURI!==A.namespaceURI||!a(y.childNodes.length+1))return null;let k="";for(let J of y.childNodes){if(J.nodeType!==3||!a(J.data.length*4+1))return null;k+=J.data}if(k.includes(kt)||(w+=k.length+1,w>2e4))return null;j[D]=k}d.push({base:A,local:E,remote:V,index:N,text:j})}let c=d.every(N=>xn(N.text.base,N.text.local,N.text.remote)),p={local:[],remote:[]};for(let N of d){N.hunks={local:[],remote:[]};for(let A of["local","remote"]){let E=N.text.base,V=N.text[A];if(E===V)continue;let j=E.length+V.length+4,D=j*8;if(!a(D))return null;let y=Math.floor(r.remaining/8),k=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(j*j+y)-j)/2)));if(k<1||!a(4*(k+1)*(j+k+1)))return null;let J=0;for(let H of Gn(E,V,k)){if(!a(H.text.length+1))return null;let q=H.bs+J,Me={...H,ss:q,se:q+H.text.length,toks:an(H.text,c),owner:N.base,ownerIndex:N.index};N.hunks[A].push(Me),p[A].push(Me),J+=H.text.length-(H.be-H.bs)}}}let m=[],v={local:new Map,remote:new Map};for(let N of["local","remote"]){let A=new Map,E=new Map,V=!1,j=(D,y,k)=>{D.has(y)?D.set(y,null):D.set(y,k)};for(let D of p[N]){if(!a(1))return null;let y=d[D.ownerIndex].text.base;if(D.bs<D.be&&D.text===""){let k=y.slice(D.bs,D.be);if(!a(k.length*2))return null;/\S/.test(k)&&j(A,k,D)}else if(D.bs===D.be&&/\S/.test(D.text)){if(!a(D.text.length*2))return null;j(E,D.text,D)}else D.bs<D.be&&(V=!0)}for(let[D,y]of A){if(!a(D.length+1))return null;let k=E.get(D);if(!y||!k||y.owner===k.owner)continue;let J=d[y.ownerIndex];if(!a(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,y.bs)+J.text.base.slice(y.be)))continue;let H=`${J.index}:${y.bs}:${y.be}`,q={key:H,side:N,source:y.owner,destination:k.owner,deletion:y,insertion:k};y.transferOut=q,k.transferIn=q,v[N].set(H,q),m.push(q)}if(V&&E.size&&!Wi(N,p[N],d,m,v,c,a))return null}if(!m.length)return null;let I=(N,A)=>N.bs<A.be&&A.bs<N.be,g=N=>N.bs===N.be,f=(N,A)=>N.bs<=A.be&&A.bs<=N.be&&g(N)!==g(A),b=(N,A)=>N.bs===A.bs&&N.be===A.be&&N.text===A.text,B=(N,A)=>!!(N.transferIn||N.transferOut&&(!N.text||A.bs===N.be&&/\s/.test(A.text[0])||A.bs===N.bs&&/\s/.test(A.text[A.text.length-1])));for(let N of m){let A=N.side==="local"?"remote":"local",E=d[N.deletion.ownerIndex];for(let V of E.hunks[A])if(!a(1)||I(N.deletion,V)&&V.transferOut?.key!==N.key)return null}for(let N of d)for(let A of N.hunks.local)for(let E of N.hunks.remote){if(!a(1))return null;if(b(A,E)){if(A.transferIn?.key!==E.transferIn?.key)return null;continue}if(I(A,E)||f(A,E)&&!B(A,E)&&!B(E,A))return null}if(!a(w*8))return null;let S=new Set([...e,...o,...t]),T={base:nn(e,{blocks:S}),local:nn(o,{blocks:S}),remote:nn(t,{blocks:S})},M={};for(let N of["base","local","remote"]){let A=T[N];if(A.atoms.length||A.pins.length)return null;M[N]=new Map(A.marks.filter(E=>E.block).map(E=>[E.el,E.from]))}for(let N of d){let A=M.base.get(N.base);if(A===void 0)return null;for(let E of["local","remote"]){let V=M[E].get(N[E]);if(V===void 0)return null;for(let j of N.hunks[E])j.bs+=A,j.be+=A,j.ss+=V,j.se+=V}}for(let N of m)N.bs=N.deletion.bs+(N.sourceOffset||0),N.be=N.length===void 0?N.deletion.be:N.bs+N.length,N.ss=N.insertion.ss+(N.targetOffset||0),N.se=N.length===void 0?N.insertion.se:N.ss+N.length;let L={};for(let N of["local","remote"]){let A=0,E=0,V=[];for(let D of p[N]){if(!a(1))return null;D.bs>A&&V.push({from:A,to:D.bs,target:E}),A=D.be,E=D.se}A<T.base.text.length&&V.push({from:A,to:T.base.text.length,target:E});let j=m.filter(D=>D.side===N).map(D=>({from:D.bs,to:D.be,target:D.ss,destination:D.destination}));if(L[N]=jn({base:T.base,side:T[N],retained:V,transfers:j,budget:r}),L[N].status!=="ready")return null}return a(T.base.text.length)?{owners:d,blocks:S,transfers:m,byOrigin:v,budget:r,prepared:{base:T.base,local:T.local,remote:T.remote,lines:!1,baseTokens:an(T.base.text,c),localEdits:{hunks:p.local,respell:new Map},remoteEdits:{hunks:p.remote,respell:new Map},localMap:L.local,remoteMap:L.remote,full:null}}:null}var Ss=/\S/;function pr({certificates:e,scopes:o,views:t,eligible:n,baseId:s,limit:h=2e4*32}){let i=zt(h),r=Symbol(),a=[],d=c=>{if(c>i.remaining)throw r;i.remaining-=c},w=(c,p=null)=>{if(d(1),!c||c.nodeType!==1||c.parentNode?.nodeType!==1||!n(c))return null;for(let I=c.parentNode;I;I=I.parentNode)if(d(1),I.nodeType===11)return null;let m="",v=0;for(let I of c.childNodes){if(d(1),I.nodeType!==3)return null;if(d(I.data.length*4+1),p){let g=p.flat.nodes[v++];if(!g||g.node!==I||g.s!==m.length||g.e!==m.length+I.data.length)return null}m+=I.data}return d(m.length*3+1),p&&(p.flat.atoms.length||p.flat.pins?.length||v!==p.flat.nodes.length||p.flat.text!==m)?null:Ss.test(m)?m:null};try{d(o[0].length+o[1].length+o[2].length+e.length);let c=o.map(m=>new Set(m)),p=new Map;for(let m of e){d(1);let v=p.get(m.source);v||p.set(m.source,v=[]),v.push(m)}for(let m of p.values()){let v=[null,null],I=[];for(let g of m){d(1);let{source:f,target:b,side:B,models:S,runs:T}=g;if(B!==0&&B!==1||!c[0].has(f)||!c[B+1].has(b))continue;let{V:M,A:L,idOf:N}=t[B],A=t[1-B],E=M.twin(f),V=A.V.twin(f),j=M.baseOf(b);if(!E||!V||!j||j===f||!c[0].has(j)||!c[B+1].has(E)||!c[2-B].has(V)||L.map.get(f)!==E||L.reverse.get(E)!==f||A.A.map.get(f)!==V||A.A.reverse.get(V)!==f||L.map.get(j)!==b||L.reverse.get(b)!==j||b.parentNode!==E.parentNode||j.parentNode!==f.parentNode||f.tagName!==E.tagName||f.tagName!==V.tagName||s(f)!==N(E)||s(f)!==A.idOf(V)||s(j)!==N(b))continue;let D=S.get(f),y=S.get(b);if(!D||!y)continue;let k=w(f,D),J=w(b,y),H=w(E),q=w(V);if(d((k?.length||0)+(q?.length||0)),k===null||J===null||H===null||q===null||q===k)continue;let Me=T.length>0,Oe=!1;for(let ie of T){if(d(1),ie.source!==f||ie.target!==b||!Number.isInteger(ie.from)||!Number.isInteger(ie.to)||!Number.isInteger(ie.targetFrom)||ie.from<0||ie.to<=ie.from||ie.to>k.length||ie.targetFrom<0||ie.targetFrom+ie.to-ie.from>J.length){Me=!1;break}d((ie.to-ie.from)*3);for(let xe=ie.from;xe<ie.to;xe++){if(k[xe]!==J[ie.targetFrom+xe-ie.from]){Me=!1;break}Ss.test(k[xe])&&(Oe=!0)}if(!Me)break}if(!Me||!Oe)continue;let Re=v[B];Re||(d(k.length),Re=v[B]={source:f,side:B,flat:D.flat,before:k,covered:new Uint8Array(k.length)});for(let ie of T)d(ie.to-ie.from),Re.covered.fill(1,ie.from,ie.to)}for(let g of v){if(!g)continue;let{source:f,side:b,flat:B,before:S,covered:T}=g;d(S.length*3+1);let M=-1,L=-1;for(let N=0;N<=S.length;N++)N<S.length&&T[N]?(M<0&&(M=N),L=N+1):(N===S.length||Ss.test(S[N]))&&M>=0&&(I.push({source:f,side:b,flat:B,from:M,to:L}),M=L=-1)}d(I.length),a.push(...I)}}catch(c){if(c!==r)throw c}return{records:a,budget:i}}var qi="http://www.w3.org/1999/xhtml";function Ki(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function pn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===qi}function Fi(e){let o=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return o==="application/json"||o.endsWith("+json")}function _o(e,o){let t=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let s=t;try{let h=new URL(t,o);s=h.origin+h.pathname+h.search}catch{}return"script|src|"+n+"|"+s}return"script|inline|"+n+"|"+Ki(e.textContent.trim())}var _i={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function ho(e,o=[],t=!1){if(!pn(e)||e.hasAttribute("src"))return null;let n=[_i,...o];for(let s=0;s<n.length;s++){let h=n[s];if(!h.match(e))continue;if(!Fi(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let i=h.identity(e);return i==null||i===""?null:{key:s+":"+i,raw:i,recognizer:h}}return null}function mr(e,o,t){let n=new Set,s=h=>{pn(h)&&!o(h)&&n.add(_o(h,t))};s(e);for(let h of e.querySelectorAll("script"))s(h);return n}function Mo(e,o){let t=o.createElement("div");t.innerHTML="<script><\/script>";let n=t.firstChild;for(let s of e.attributes)n.setAttribute(s.name,s.value);return n.textContent=e.textContent,n}function gr(e,o,t){let n=[],s=[],h=new Map,i=t.trackRecovery?new Set:null,r=Array.from(e.querySelectorAll("script"));pn(e)&&r.unshift(e);for(let a of r){if(!pn(a)||t.ignored(a)||t.skip.has(a)||o.has(_o(a,t.baseURI)))continue;let d=a.ownerDocument.createElement("script");for(let w of a.attributes)d.setAttribute(w.name,w.value);if(d.textContent=a.textContent,t.beforeNodeAdded(d)===!1){i?.add(a);continue}d.hasAttribute("src")&&s.push(new Promise(w=>{d.addEventListener("load",()=>w()),d.addEventListener("error",()=>w())})),a.replaceWith(d),h.set(a,d),t.afterNodeAdded(d),n.push(d)}return{executed:n,loads:s,swapped:h,vetoed:i}}function zi(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function $i(e,o){try{let t=new URL(e,o);return t.origin+t.pathname+t.search}catch{return e}}function br(e,o){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return _o(e,o);if(t==="LINK"){let n=e.getAttribute("href");return n?"link|"+(e.getAttribute("rel")||"")+"|"+$i(n,o):e.outerHTML}if(t==="META"){for(let n of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(n))return"meta|"+n+"="+e.getAttribute(n);return e.outerHTML}return t==="STYLE"?"style|"+zi(e.textContent):e.outerHTML}function Ns(e,o){for(;;){for(;o<e.length&&/\s/.test(e[o]);)o++;if(e[o]==="/"&&e[o+1]==="/"){for(;o<e.length&&e[o]!==`
|
|
4
|
-
`;)o++;continue}if(e[o]==="/"&&e[o+1]==="*"){let t=e.indexOf("*/",o+2);if(t===-1)return e.length;o=t+2;continue}return o}}function wr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(o,t)=>t.length%2===0?t+'\\"':o)}var Gi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Yi=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function zo(e){try{return JSON.parse(e)}catch{return JSON.parse(Xi(e))}}function Xi(e){let o="",t=0,n=(s,h)=>{throw new Error(`Invalid relaxed JSON: ${s} at position ${h}`)};for(;t<e.length&&(t=Ns(e,t),!(t>=e.length));){let s=e[t];if("{}[]:".includes(s)){o+=s,t++;continue}if(s===","){let r=Ns(e,t+1);if(e[r]==="}"||e[r]==="]"){t++;continue}o+=s,t++;continue}if(s==='"'||s==="'"){let r=t+1;for(;r<e.length&&e[r]!==s;)e[r]==="\\"&&r++,r++;r>=e.length&&n("unterminated string",t);let a=e.slice(t+1,r);s==="'"&&(a=wr(a)),o+='"'+a+'"',t=r+1;continue}let h=t;for(;h<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[h]);)h++;h===t&&n("unexpected character "+JSON.stringify(s),t);let i=e.slice(t,h);if(i==="true"||i==="false"||i==="null"||Gi.test(i)){o+=i,t=h;continue}if(Yi.test(i)){if(e[Ns(e,h)]===":"){o+='"'+i+'"',t=h;continue}n("unquoted value "+JSON.stringify(i),t)}n("invalid token "+JSON.stringify(i),t)}return o}function yr(e){try{return JSON.parse(e)}catch{}let o={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(s){let h=[],i=0;for(;i<s.length;){let r=s[i];if(/\s/.test(r)){i++;continue}if("{}".includes(r)){h.push({type:r,value:r}),i++;continue}if(r==="["){let c=!1,p=i+1;for(;p<s.length&&/\s/.test(s[p]);)p++;if(p<s.length&&/[a-zA-Z_]/.test(s[p])&&(c=!0),!c){h.push({type:r,value:r}),i++;continue}}if(r==="]"){h.push({type:r,value:r}),i++;continue}if(r===":"){h.push({type:o.COLON,value:r}),i++;continue}if(r===","){h.push({type:o.COMMA,value:r}),i++;continue}if(r==='"'||r==="'"){let c=r,p=i+1;for(;p<s.length&&s[p]!==c;)s[p]==="\\"&&p++,p++;h.push({type:o.STRING,value:s.substring(i+1,p),quoted:!0,sourceQuote:c}),i=p+1;continue}let a=i,d;for(;a<s.length&&!/[{},]/.test(s[a]);)if(s[a]===":"){let c=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],p=!1;for(let m of c){let v=m.substring(1);if(s.substring(a+1,a+1+v.length)===v){p=!0,a+=v.length;break}}if(!p)break}else if(s[a]==="["){for(a++;a<s.length&&s[a]!=="]";){if(s[a]==='"'||s[a]==="'"){let c=s[a];for(a++;a<s.length&&s[a]!==c;)s[a]==="\\"&&a++,a++}a++}a<s.length&&s[a]==="]"&&a++}else a++;d=s.substring(i,a);let w=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(d)?w=o.NUMBER:d==="true"||d==="false"||d==="null"?w=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(d)&&(w=o.SELECTOR),h.push({type:w,value:d,quoted:!1}),i=a}return h}function n(s){let h="";for(let i=0;i<s.length;i++){let r=s[i];if("{}".includes(r.type)||"[]".includes(r.type)){h+=r.value;continue}if(r.type===o.COLON){h+=r.value;continue}if(r.type===o.COMMA){let a=s[i+1];if(a&&(a.type==="}"||a.type==="]"))continue;h+=r.value;continue}if(r.type===o.STRING){let a=r.value;r.sourceQuote==="'"&&(a=wr(a)),h+=`"${a}"`;continue}if(r.type===o.NUMBER||r.type===o.BOOLEAN){h+=r.value;continue}h+=`"${r.value}"`}return h}try{let s=t(e),h=n(s);return JSON.parse(h)}catch(s){throw new Error("Invalid extraction rules syntax: "+s.message)}}var Jt=Symbol("hyper-morph-json-merge:missing"),kr=["id","_id","uuid","key","slug","code","name"];function po(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Oo(e,o){return Object.prototype.hasOwnProperty.call(e,o)}function Ji(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Yn(e,o){if(e===o)return!0;if(Array.isArray(e)&&Array.isArray(o)){if(e.length!==o.length)return!1;for(let t=0;t<e.length;t++)if(!Yn(e[t],o[t]))return!1;return!0}if(po(e)&&po(o)){let t=Object.keys(e);if(t.length!==Object.keys(o).length)return!1;for(let n of t)if(!Oo(o,n)||!Yn(e[n],o[n]))return!1;return!0}return!1}function xr(e,o,t,n){return Yn(o,t)?o:Yn(o,e)?t:Yn(t,e)?o:po(o)&&po(t)?Qi(po(e)?e:{},o,t,n):Array.isArray(o)&&Array.isArray(t)?nl(Array.isArray(e)?e:[],o,t,n):t}function Tr(e,o,t,n){return o===Jt&&t===Jt?Jt:o===Jt?e===Jt?t:Yn(t,e)?Jt:t:t===Jt?e===Jt?o:Jt:xr(e,o,t,n)}function Qi(e,o,t,n){let s={},h=new Set([...Object.keys(e),...Object.keys(o),...Object.keys(t)]);for(let i of h){let r=Tr(Oo(e,i)?e[i]:Jt,Oo(o,i)?o[i]:Jt,Oo(t,i)?t[i]:Jt,n);r!==Jt&&Ji(s,i,r)}return s}function Zi(e){return e===null||typeof e!="object"}function $o(e){return typeof e+":"+String(e)}function el(e,o){for(let t of o){let n=new Set;for(let s of t){if(!Oo(s,e))return!1;let h=s[e];if(typeof h!="string"&&typeof h!="number")return!1;let i=$o(h);if(n.has(i))return!1;n.add(i)}}return!0}function tl(e,o,t,n){let s=[e,o,t],h=!0;for(let i of s)for(let r of i)po(r)||(h=!1);if(h){for(let i of n.keyCandidates)if(el(i,s))return{kind:"keyed",field:i};return null}for(let i of s){let r=new Set;for(let a of i){if(!Zi(a))return null;let d=$o(a);if(r.has(d))return null;r.add(d)}}return{kind:"self"}}function nl(e,o,t,n){let s=tl(e,o,t,n);if(!s)return t;let h=s.kind==="self"?$o:m=>$o(m[s.field]),i=m=>{let v=new Map;for(let I of m)v.set(h(I),I);return v},r=i(e),a=i(o),d=i(t),w=new Map,c=new Set([...r.keys(),...a.keys(),...d.keys()]);for(let m of c){let v=Tr(r.has(m)?r.get(m):Jt,a.has(m)?a.get(m):Jt,d.has(m)?d.get(m):Jt,n);v!==Jt&&w.set(m,v)}let p=[];for(let m of t){let v=h(m);w.has(v)&&p.push(v)}for(let m=0;m<o.length;m++){let v=h(o[m]);if(!w.has(v)||p.includes(v))continue;let I=0;for(let g=m-1;g>=0;g--){let f=p.indexOf(h(o[g]));if(f!==-1){I=f+1;break}}p.splice(I,0,v)}return p.map(m=>w.get(m))}function As(e,o,t,n={}){let s=n.keyCandidates?[...n.keyCandidates,...kr]:kr;return xr(e===void 0?Jt:e,o,t,{keyCandidates:s})}function Go(e,o,t,n={}){let s=n.parse||zo,h=[],i=(c,p)=>{if(typeof c!="string")return Jt;try{return s(c)}catch(m){return h.push(`${p} side is not valid JSON (${m.message})`),Jt}},r=i(o,"local"),a=i(t,"remote");if(r===Jt)return{text:t,warnings:h};if(a===Jt)return{text:o,warnings:h};let d=i(e,"base"),w=As(d===Jt?void 0:d,r,a,n);return Yn(w,a)?{text:t,warnings:h}:Yn(w,r)?{text:o,warnings:h}:{text:JSON.stringify(w,null,2),warnings:h}}var vr=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function eo(e){if(!e)return!1;let{startContainer:o,startOffset:t,endContainer:n,endOffset:s}=e;if(!o||!n||!Number.isInteger(t)||!Number.isInteger(s)||t<0||s<0||t>vr(o)||s>vr(n)||o.getRootNode()!==n.getRootNode())return!1;let h=o.ownerDocument.createRange();return h.setStart(o,t),h.setEnd(n,s),h.startContainer===o&&h.startOffset===t}function Xn(e,o,t={}){if(!eo(e))return null;let{startContainer:n,startOffset:s,endContainer:h,endOffset:i}=e;if(n===h&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(s,i);if(n===h&&s===i)return"";let r=new Set;for(let g=n;g;g=g.parentNode)r.add(g);let a=h;for(;!r.has(a);)a=a.parentNode;let d=(g,f)=>{let b=a.ownerDocument.createRange(),B=a.ownerDocument.createRange();return b.setStart(g[0],g[1]),b.collapse(!0),B.setStart(f[0],f[1]),B.collapse(!0),b.compareBoundaryPoints(0,B)},w=(g,f=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(f)],c=[],p;if(o==="plain"){p="";let g=f=>{if(f.nodeType===3||f.nodeType===8){let b=p.length;p+=f.nodeValue,c.push({s:b,e:p.length,a:[f,0],b:[f,f.nodeValue.length],node:f})}else for(let b of f.childNodes)g(b)};g(a)}else{let g=t.blocks;if(!g){g=new Set;let b=B=>{B!==a&&B.nodeType===1&&ys.has(B.tagName)&&g.add(B);for(let S of B.childNodes)b(S)};b(a)}let f=nn(Array.from(a.childNodes),{blocks:g,atomize:b=>!!t.atoms?.has(b),ignored:t.ignored});p=f.text;for(let b of f.nodes)c.push({s:b.s,e:b.e,a:[b.node,0],b:[b.node,b.e-b.s],node:b.node});for(let b of f.atoms)c.push({s:b.i,e:b.i+1,a:w(b.el),b:w(b.el,!0)});for(let b=0;b<f.text.length;b++){if(f.text[b]!==kt)continue;let B=f.marks.find(T=>T.block&&T.to===b+1),S=f.marks.find(T=>T.block&&T.from===b+1);if(B)c.push({s:b,e:b+1,a:[B.el,B.el.childNodes.length],b:w(B.el,!0)});else if(S)c.push({s:b,e:b+1,a:w(S.el),b:[S.el,0]});else return null}}c.sort((g,f)=>g.s-f.s);let m=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let b=c.find(B=>B.node===g[0]);return b?b.s+g[1]:null}let f=0;for(let b of c){if(d(g,b.a)<=0)return b.s;if(d(g,b.b)<0)return null;f=b.e}return f},v=m([n,s]),I=m([h,i]);return v!==null&&I!==null&&v<=I?p.slice(v,I):null}function Zn(e,o){let t=e;for(let n of o.path)if(t=n==="content"?t?.content:t?.childNodes[n],!t)return null;return[t,o.offset]}function Sr(e,o){if(!e||!o)return null;let t=Zn(e,o.start),n=Zn(e,o.end);return t&&n?{startContainer:t[0],startOffset:t[1],endContainer:n[0],endOffset:n[1]}:null}var Nr=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ar(e,o,t){if(!o)return;let n=new Map,s=new Map,h=r=>{if(!r)return null;if(s.has(r))return s.get(r);let d=r.local.map(w=>Zn(o.localRoot,{path:w,offset:0})?.[0]).map(w=>w&&t(w)).filter(Boolean).map(w=>({node:w,parent:w.parentNode,previous:w.previousSibling,next:w.nextSibling,fragment:Nr(w)}));return s.set(r,d),d},i=r=>{let a=Sr(o.localRoot,r);if(!a)return null;let d=t(a.startContainer),w=t(a.endContainer);if(!d||!w)return null;let c={...a,startContainer:d,endContainer:w};return eo(c)?c:null};for(let r of e){let a=r.recovery;if(!a||n.has(a))continue;let d={subject:h(a.subject),span:null,scope:null,touched:new Set};if(a.text){d.span=i(a.text.local.span),d.scope=i(a.text.local.scope);let w=d.span;if(w){let c=w.startContainer.ownerDocument.createRange();c.setStart(w.startContainer,w.startOffset),c.setEnd(w.endContainer,w.endOffset);let p=m=>{if(c.intersectsNode(m)){d.touched.add(m);for(let v of m.childNodes)p(v)}};p(c.commonAncestorContainer)}}if(a.structure){for(let w of[a.structure.localPlacement])w&&(h(w.parent),w.before.forEach(h),w.after.forEach(h));for(let w of a.structure.localOrder||[])h(w)}n.set(a,d)}o.localState={states:n,refs:s}}function Mr(e,o,t,n){let s=t.localState?.states.get(e);if(!s)return!1;let h=r=>{let a=r.node;if(!n(a)||a.parentNode!==r.parent)return!1;let d=w=>Array.prototype.indexOf.call(a.parentNode.childNodes,w);return!(r.previous&&n(r.previous)&&r.previous.parentNode===a.parentNode&&d(r.previous)>=d(a)||r.next&&n(r.next)&&r.next.parentNode===a.parentNode&&d(r.next)<=d(a))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!s.subject.length||!s.subject.every(h))return!1;if(e.text){let r=e.text.local,a=d=>d&&n(d.startContainer)&&n(d.endContainer);return a(s.span)&&a(s.scope)&&Xn(s.scope,e.text.encoding)===r.text&&Xn(s.span,e.text.encoding)===r.text.slice(r.start,r.end)}if(e.attribute){let r=e.attribute,a=s.subject[0].node;return(r.namespaceURI?a.getAttributeNS(r.namespaceURI,r.localName):a.getAttribute(r.qualifiedName))===o.local}let i=e.structure;if(i.localOrder){let r=-1,a=null;for(let d of i.localOrder){let w=t.localState.refs.get(d)?.[0]?.node;if(!w||!n(w)||a&&w.parentNode!==a)return!1;let c=Array.prototype.indexOf.call(w.parentNode.childNodes,w);if(c<=r)return!1;a=w.parentNode,r=c}return!0}return i.localAction==="moved"||s.subject.every(r=>Nr(r.node)===r.fragment)}var ol=1,dn=e=>!!e&&e.nodeType===1,Yo=e=>dn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function to(e,o=null,t=null){let n=new Map,s=new Map,h=w=>{if(!o){o=new WeakMap;let c=[e];for(;c.length;){let p=c.pop();Yo(p)&&(o.set(p.content,p),c.push(p.content));for(let m=p.firstChild;m;m=m.nextSibling)m.nodeType===1&&c.push(m)}}return o.get(w)||null},i=(w,c)=>{let p=s.get(w);if(!p){p=new Map;let m=0;for(let v=w.firstChild;v;v=v.nextSibling)p.set(v,m++);s.set(w,p)}return p.get(c)},r=w=>{if(!w)return null;if(t&&t.has(w))return r(t.get(w));if(w===e)return[];let c=n.get(w);if(c!==void 0)return c;let p=w.parentNode,m=null;if(p&&p.nodeType===11){let v=h(p),I=v?r(v):null;I&&(m=I.concat(["content",i(p,w)]))}else if(p){let v=r(p);v&&(m=v.concat([i(p,w)]))}return n.set(w,m),m};return{root:e,pathOf:r,logicalParent:w=>{let c=w.parentNode;return c&&c.nodeType===11?h(c):c},indexIn:i,containerPath:w=>{if(w.nodeType===11){let p=h(w),m=r(p);return m?m.concat(["content"]):null}let c=r(w);return c&&Yo(w)?c.concat(["content"]):c},ownerOf:h}}var Cn=e=>Yo(e)?e.content:e;function Or(e){let{L:o,R:t,unitsOf:n,provenance:s,policy:h}=e,i=[];return{note:(w,c)=>{i.push([w,c])},finish:w=>i.length?d(w):null};function d(w){let c={base:to(e.roots.base),local:to(e.roots.local),remote:to(e.roots.remote)},p=$=>$==="local"?o:t,m=($,l)=>{if(!l)return null;if($.map.has(l))return $.map.get(l);let O=[],R=dn(l)?c.base.logicalParent(l):l.parent;for(;R&&!$.map.has(R);R=c.base.logicalParent(R))O.push(R);if(!R||!$.identical.has(R))return null;let K=$.map.get(R);for(let Z=O.length-1;Z>=0&&K;Z--)K=Cn(K).childNodes[c.base.indexIn(O[Z].parentNode,O[Z])];return K?dn(l)?Cn(K).childNodes[c.base.indexIn(l.parentNode,l)]||null:n(K)[n(l.parent).indexOf(l)]||null:null},v=new Map,I=new Map,g=new WeakMap,f=0,b=($,l)=>{let O=v.get($);O||v.set($,O=[]),O.push(l)};(function $(l){I.set(l,f++);let O=s.get(l);if(O&&!O.pinned){for(let R of[O.base,O.local,O.remote])if(R)if(Array.isArray(R))for(let K of R)b(K,l);else b(R,l)}if(Yo(l)){g.set(l.content,l);for(let R=l.content.firstChild;R;R=R.nextSibling)$(R)}for(let R=l.firstChild;R;R=R.nextSibling)$(R)})(w);let B=new Map;c.out=to(w,g,B);let S={refs:new Map,spans:new Map,anchors:new Map,via:B,outOwners:g,outRoot:w,localRoot:e.roots.local},T=$=>dn($)?[$]:$.nodes,M=($,l)=>{let O=c[l].logicalParent($);if(!O)return null;for(let R of n(O))if(!dn(R)&&R.nodes.includes($))return R;return null},L=($,l)=>$==null?null:Array.isArray($)?$.length?M($[0],l):null:$,N=$=>{let l=new Set,O=[];for(let R of $)for(let K of v.get(R)||[])l.has(K)||(l.add(K),O.push(K));return O.sort((R,K)=>I.get(R)-I.get(K))},A=new Map,E=$=>{let l=$.b||$.l||$.r,O=A.get(l);if(O)return O;let R=[];for(let K of[$.b,$.l,$.r])K&&R.push(...T(K));return O=N(R),A.set(l,O),O},V=$=>({b:$,l:m(o,$),r:m(t,$)}),j=($,l)=>{let O=p(l).reverse.get($);if(O)return V(O);for(let R of N(T($))){let K=s.get(R);if(K&&!K.base&&K.local&&K.remote)return{b:null,l:L(K.local,"local"),r:L(K.remote,"remote")}}return l==="local"?{b:null,l:$,r:null}:{b:null,l:null,r:$}},D=new Map,y=$=>{let l=s.get($);if(!l||l.pinned)return null;let O=L(l.base,"base");if(O)return V(O);let R=L(l.local,"local"),K=L(l.remote,"remote");if(R){let Z=o.reverse.get(R);if(Z)return V(Z)}if(K){let Z=t.reverse.get(K);if(Z)return V(Z)}return R||K?{b:null,l:R,r:K}:null},k=$=>(D.has($)||D.set($,y($)),D.get($)),J=($,l)=>dn($)?c[l].logicalParent($):$.parent,H=new Map,q=new Map,Me=($,l)=>(dn($)?[c[l].pathOf($)]:$.nodes.map(O=>c[l].pathOf(O))).filter(Boolean),Oe=$=>{let l=$.b||$.l||$.r,O=$.b?"base":$.l?"local":"remote",R=q.get(l);if(R)return R;let K=!dn(l),Z=Me(l,O)[0],U=`${O[0]}:${JSON.stringify(Z===void 0?null:Z)}${K?":run":""}`,de=H.get(U);if(de)return q.set(l,de),de;let we=E($);return de={key:U,nodeType:dn(l)?1:l.kind==="comment"?8:3,base:$.b?Me($.b,"base"):[],local:$.l?Me($.l,"local"):[],remote:$.r?Me($.r,"remote"):[],merged:we.map(le=>c.out.pathOf(le)).filter(Boolean),live:[]},H.set(U,de),q.set(l,de),S.refs.set(de,we),de},Re={base:new Map,local:new Map,remote:new Map},ie=new Map,xe=($,l)=>{let O=J($,l);if(!O||O.nodeType!==1)return null;let R=Re[l].get(O);if(!R){let Z=n(O),U=de=>Oe(l==="base"?V(de):j(de,l));R={parent:U(O),refs:Z.map(U),index:new Map(Z.map((de,we)=>[de,we]))},Re[l].set(O,R)}let K=R.index.get($)??-1;return{parent:R.parent,before:R.refs.slice(K+1),after:R.refs.slice(0,Math.max(0,K)).reverse()}},qe=$=>{let l=$.parentNode;if(!l)return null;let O=ie.get(l);if(!O){let K=l.nodeType===11?g.get(l):l,Z=K&&K.nodeType===1?k(K):null;if(!Z)return null;let U=[],de=[],we=new Map;for(let Ae of l.childNodes){let W=k(Ae),X=W&&Oe(W),pe=U.length,be=U.length-1;X&&X!==U[be]&&(U.push(X),be++);let he={ref:X,group:be,after:pe};de.push(he),we.set(Ae,he)}let le=U.length;for(let Ae=de.length-1;Ae>=0;Ae--){let W=de[Ae];W.before=le,W.ref&&(le=W.group)}O={parent:Oe(Z),refs:U,index:we},ie.set(l,O)}let R=O.index.get($);return{parent:O.parent,before:O.refs.slice(R.before),after:O.refs.slice(0,R.after).reverse()}},fe=$=>dn($)?$.outerHTML:$.value,x=$=>dn($)?"element":$.kind==="comment"?"comment":"text",Y=($,l)=>({path:$,offset:l}),ae=($,l,O)=>{if(!$)return null;let R=c[O],K=0;if(l){let Z=dn(l)?l:l.nodes[l.nodes.length-1];Z.parentNode&&(K=R.indexIn(Z.parentNode,Z)+1)}return Y(R.containerPath($),K)},oe=($,l)=>{let O=J($,"base"),R=O?m(p(l),O):null;if(!dn(R))return null;let K=n(O),Z=null;for(let U=K.indexOf($)-1;U>=0&&!Z;U--){let de=m(p(l),K[U]);de&&J(de,l)===R&&(Z=de)}return ae(R,Z,l)},Ee=($,l,O,R)=>{let K=c[R],Z=0;for(let U=0;U<$.nodes.length;U++){let de=$.nodes[U],we=de.nodeValue.length,le=U===$.nodes.length-1;if((O==="start"?l<Z+we:l<=Z+we)||le)return Y(K.pathOf(de),Math.max(0,Math.min(l-Z,we)));Z+=we}return null},je=($,l)=>{let O=c[l],R=$.firstChild,K=$.lastChild;return R&&R.nodeType===3&&K.nodeType===3?{start:Y(O.pathOf(R),0),end:Y(O.pathOf(K),K.nodeValue.length)}:{start:Y(O.pathOf($),0),end:Y(O.pathOf($),$.childNodes.length)}},Ne=($,l,O)=>{for(let U of $.nodes)if(O==="start"?U.s<=l&&l<U.e:U.s<l&&l<=U.e)return{kind:"text",node:U.node,offset:l-U.s};let R=O==="start"?l:l-1,K=()=>{for(let U of $.nodes)if(U.s===l||U.e===l)return{kind:"text",node:U.node,offset:l-U.s};return null},Z=$.atomAt.get(R);if(Z)return{kind:O==="start"?"before":"after",node:Z.el};if($.text[R]===kt){let U=$.marks.find(we=>we.block&&we.to===R+1);if(U)return O==="start"?{kind:"end",node:U.el}:{kind:"after",node:U.el};let de=$.marks.find(we=>we.block&&we.from===R+1);if(de)return O==="start"?{kind:"before",node:de.el}:{kind:"startOf",node:de.el}}return K()},tt=($,l)=>Ne($,l,"end")||Ne($,l,"start"),Xe=($,l)=>{switch(l.kind){case"text":return Y($.pathOf(l.node),l.offset);case"end":return Y($.containerPath(l.node),Cn(l.node).childNodes.length);case"startOf":return Y($.containerPath(l.node),0);default:{let O=l.node.parentNode;return Y($.containerPath(O),$.indexIn(O,l.node)+(l.kind==="after"?1:0))}}},dt=($,l,O,R,K)=>{let Z=Ne($,l,O);return Z?Xe(c[R],Z):K()},Ge=($,l,O,R)=>{let K=$.textNodes.map(le=>({s:le.ms,e:le.me,start:{kind:"text",node:le.node,offset:0},end:{kind:"text",node:le.node,offset:le.me-le.ms}}));for(let[le,Ae]of $.atomOut)K.push({s:le,e:le+1,start:{kind:"before",node:Ae},end:{kind:"after",node:Ae}});for(let[le,Ae]of $.breakOut)K.push({s:le,e:le+1,start:{kind:"end",node:Ae},end:{kind:"after",node:Ae}});for(let le of K)if(le.start.kind==="text"&&le.s<l&&l<le.e)return{kind:"text",node:le.start.node,offset:l-le.s};if(O!=="empty"){let le=K.find(Ae=>O==="start"?Ae.s===l:Ae.e===l);if(le)return O==="start"?le.start:le.end}let Z=K.find(le=>le.e===l);if(Z)return Z.end;let U=K.find(le=>le.s===l);if(U)return U.start;let de=null,we=null;for(let le of K)le.e<=l&&(!de||le.e>de.e)&&(de=le),le.s>=l&&(!we||le.s<we.s)&&(we=le);return de?de.end:we?we.start:R()},st=($,l)=>{if(!l)return null;if(l.kind==="text"){let K=$.nodes.find(Z=>Z.node===l.node);return K?K.s+Math.min(l.offset,K.e-K.s):null}let O=$.atoms.find(K=>K.el===l.node);if(O)return l.kind==="after"?O.i+1:O.i;let R=$.marks.find(K=>K.el===l.node);return R?l.kind==="before"&&R.block&&$.text[R.from-1]===kt&&!$.marks.some(K=>K.block&&K.to===R.from)?R.from-1:l.kind==="startOf"||l.kind==="before"?R.from:l.kind==="end"&&R.block?R.to-1:R.to:null},Ot=($,l,O,R)=>{for(let de of $.nodes)if(O==="start"?de.s<=l&&l<de.e:de.s<l&&l<=de.e)return{kind:"text",node:de.node,offset:l-de.s};let K=O==="start"?l:l-1;if(!$.atomAt.has(K)&&$.text[K]!==kt){for(let de of $.nodes)if(de.s===l||de.e===l)return{kind:"text",node:de.node,offset:l-de.s}}let Z=$.atomAt.get(K);if(Z)return{kind:O==="start"?"before":"after",node:Z.el};if($.text[K]===kt){let de=$.marks.find(le=>le.block&&le.to===K+1);if(de)return O==="start"?{kind:"end",node:de.el}:{kind:"after",node:de.el};let we=$.marks.find(le=>le.block&&le.from===K+1);if(we)return O==="start"?{kind:"before",node:we.el}:{kind:"startOf",node:we.el}}let U=$.marks.find(de=>de.block&&de.from===l);return U?{kind:"startOf",node:U.el}:R?{kind:O==="start"?"startOf":"end",node:R}:null},Ct=$=>{if(!$)return null;if($.kind==="wholeStart"||$.kind==="wholeEnd"){let l=yt($.node);return $.kind==="wholeStart"?l.start:l.end}return Xe(c.out,$)},yt=$=>{let l=$.firstChild,O=$.lastChild;return l&&l.nodeType===3&&O.nodeType===3?{start:Y(c.out.pathOf(l),0),end:Y(c.out.pathOf(O),O.nodeValue.length)}:{start:Y(c.out.pathOf($),0),end:Y(c.out.pathOf($),$.childNodes.length)}},Nt=$=>{let l=J($,"base"),O=l?E(V(l))[0]:null;if(!O)return null;let R=Cn(O),K=n(l);for(let Z=K.indexOf($)-1;Z>=0;Z--){let U=E(V(K[Z])).filter(de=>de.parentNode===R);if(U.length)return{kind:"after",node:U[U.length-1]}}return{kind:"startOf",node:O}},Lt=($,l,O,R,K,Z)=>({text:$,start:l,end:O,fragment:R,span:K,scope:Z}),qt=($,l,O,R,K)=>Lt($,l,O,$.slice(l,O),R,K),cn=($,l,O,R,K)=>(S.spans.set($,{start:l,end:O,scopeStart:R,scopeEnd:K}),$),It=new Map,$t=new Map,wn=($,l,O)=>{let R=`text:${$.key}:${l}:${O}`,K=$t.get(R)||0;return $t.set(R,K+1),`${R}:${K}`},jt=($,l)=>{let O,R,K,Z="plain",U,de,we,le,Ae,W=(be,he,ee,te,z)=>{if(!be){let ne=oe(z,te);return qt("",0,0,{start:ne,end:ne},{start:ne,end:ne})}return qt(be.value,he,ee,{start:Ee(be,he,he===ee?"end":"start",te),end:Ee(be,ee,"end",te)},{start:Ee(be,0,"start",te),end:Ee(be,be.value.length,"end",te)})};if(l.site==="run"){let{bRun:be,lRun:he,rRun:ee,node:te,c:z}=l;O=V(be),R=z.bs,K=z.be,U=W(be,z.bs,z.be,"base",be),de=W(he,z.ls,z.le,"local",be),we=W(ee,z.rs,z.re,"remote",be);let ne=te?te.nodeValue:"",Te=Ce=>te?{kind:"text",node:te,offset:Ce}:Nt(be);le=cn(qt(ne,z.ms,z.me,{start:Ct(Te(z.ms)),end:Ct(Te(z.me))},{start:Ct(Te(0)),end:Ct(Te(ne.length))}),Te(z.ms),Te(z.me),Te(0),Te(ne.length)),Ae=te||(Nt(be)||{}).node||null}else if(l.site==="whole"){let be=l.el,he=s.get(be);O=V(he.base),R=0,K=$.base.length;let ee=(z,ne,Te)=>{let Ce=je(ne,Te);return qt(z,0,z.length,Ce,Ce)};U=ee($.base,he.base,"base"),de=ee($.local,he.local,"local"),we=ee($.remote,he.remote,"remote");let te=yt(be);le=cn(qt($.resolved,0,$.resolved.length,te,te),{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be},{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be}),Ae=be}else if(l.site==="comment"){let{bRun:be,lRun:he,rRun:ee,node:te}=l;O=V(be),R=0,K=$.base.length;let z=(Pe,ve)=>{if(!Pe){let Ze=oe(be,ve);return qt("",0,0,{start:Ze,end:Ze},{start:Ze,end:Ze})}let _e=Pe.nodes[0],Je={start:Y(c[ve].pathOf(_e),0),end:Y(c[ve].pathOf(_e),Pe.value.length)};return qt(Pe.value,0,Pe.value.length,Je,Je)};U=z(be,"base"),de=z(he,"local"),we=z(ee,"remote");let ne=$.resolved,Te=Pe=>te?{kind:"text",node:te,offset:Pe}:Nt(be),Ce={start:Ct(Te(0)),end:Ct(Te(ne.length))};le=cn(qt(ne,0,ne.length,Ce,Ce),Te(0),Te(ne.length),Te(0),Te(ne.length)),Ae=te||(Nt(be)||{}).node||null}else{let{fb:be,fl:he,fr:ee,scope:te}=l,z=l.merged;Z="html",O=te.base?V(te.base):j(te.local,"local"),R=$.bs,K=$.be;let ne=se=>{let Ie=te[se];for(let Be=te.at-1;Be>=0;Be--){let He=te.units[Be],Ke=se==="base"?He:m(p(se),He);if(Ke&&J(Ke,se)===Ie)return Ke}return null},Te=se=>()=>ae(te[se],ne(se),se),Ce=(se,Ie,Be,He,Ke)=>{let pt=bn=>bn?Xe(c[Ke],bn):Te(Ke)(),ht=Ie===Be?tt(se,Ie):Ne(se,Ie,"start"),Kt=Ie===Be?tt(se,Ie):Ne(se,Be,"end"),Ht=pt(ht),un={start:Ht,end:Ie===Be?Ht:pt(Kt)},bt=l.full?l.full(Ke):null;if(!bt)return Lt(se.text,Ie,Be,He,un,{start:pt(Ne(se,0,"start")),end:pt(Ne(se,se.text.length,"end"))});let it=ht?st(bt,ht):null,$e=Kt?st(bt,Kt):null,vt=it===null?0:it,at=Math.max(vt,$e===null?bt.text.length:$e),Dt=pt(Ne(bt,0,"start"));return Lt(bt.text,vt,at,co(bt,vt,at),un,{start:Dt,end:bt.text.length?pt(Ne(bt,bt.text.length,"end")):Dt})};U=l.synthetic?null:Ce(be,$.bs,$.be,$.base,"base"),de=Ce(he,$.lss,$.lse,$.local,"local"),we=Ce(ee,$.rss,$.rse,$.remote,"remote");let[Pe,ve]=$.range||[0,0],_e=z.out,Je=()=>{let se=Cn(z.node);for(let Ie=te.at-1;Ie>=0;Ie--){let Be=E(V(te.units[Ie])).filter(He=>He.parentNode===se);if(Be.length)return{kind:"after",node:Be[Be.length-1]}}for(let Ie=te.at;Ie<te.units.length;Ie++){let Be=E(V(te.units[Ie])).filter(He=>He.parentNode===se);if(Be.length)return{kind:"before",node:Be[0]}}return{kind:"startOf",node:z.node}};if(_e.via)for(let[se,Ie]of _e.via)B.set(se,Ie);let Ze=Ge(z,Pe,Pe===ve?"empty":"start",Je),Ut=Pe===ve?Ze:Ge(z,ve,"end",Je),Pt=_e.text.length?Ot(_e,0,"start",z.node):Je(),C=_e.text.length?Ot(_e,_e.text.length,"end",z.node):Pt,G=st(_e,Ze),re=st(_e,Ut),ge=G===null?0:G,ye=Math.max(ge,re===null?_e.text.length:re);le=cn(Lt(_e.text,ge,ye,co(_e,ge,ye),{start:Ct(Ze),end:Ct(Ut)},{start:Ct(Pt),end:Ct(C)}),Ze,Ut,Pt,C);let ce=S.spans.get(le);if(ce.flat=_e,!_e.text.length){let se=Ct(Pt),Ie=Zn(w,se),Be=Ie[0],He=Ie[1];ce.empty={parent:Be.nodeType===11?g.get(Be):Be,previous:Be.childNodes[He-1]||null,next:Be.childNodes[He]||null}}Ae=Ze?Ze.node:z.node}let X=Oe(O),pe=(l.site==="whole"||l.site==="comment"||(l.policy||h)!=="both")&&$.resolved!==$.local;return{key:l.site==="comment"&&It.get(O.b||O.l||O.r)||wn(X,R,K),subject:X,localLost:pe,anchor:Ae,text:{encoding:Z,base:U,local:de,remote:we,merged:le,liveSpan:null,liveScope:null}}},rn=($,l)=>{let O=k(l.el),R=Oe(O),K=l.sample;return{key:`attr:${R.key}:${K.namespaceURI||""}:${K.localName}`,subject:R,localLost:$.resolved!==$.local,anchor:l.el,attribute:{namespaceURI:K.namespaceURI||null,localName:K.localName,qualifiedName:K.name}}},Gt=($,l)=>{let O=$.detail,R=l.unit||V(l.subject),K=Oe(R),Z=S.refs.get(K),U=R.l?xe(R.l,"local"):null,de=R.r?xe(R.r,"remote"):null,we=Z.length?qe(Z[0]):null,le,Ae,W,X=null,pe=null,be=l.deleted;switch(O){case"both-reordered":{le=Ae="reordered";let he=new Set(l.rKept),ee=l.lKept.filter(Ce=>he.has(Ce)&&E(V(Ce)).length),te=Ce=>I.get(E(V(Ce))[0]);X=ee.map(Ce=>Oe(V(Ce))),pe=ee.slice().sort((Ce,Pe)=>te(Ce)-te(Pe)).map(Ce=>Oe(V(Ce)));let z=Ce=>!dn(Ce)&&Ce.kind!=="comment"&&Ce.nodes.every(Pe=>!/[^\t\n\f\r ]/.test(Pe.data)),ne=ee.filter(Ce=>!z(Ce)),Te=ne.slice().sort((Ce,Pe)=>te(Ce)-te(Pe));W=ne.some((Ce,Pe)=>Ce!==Te[Pe]);break}case"both-moved":le=Ae="moved",W=!U||!Z.some(he=>{let ee=he===Z[0]?we:qe(he);return ee&&ee.parent===U.parent});break;case"edit-beats-delete":le=be==="local"?"deleted":"edited",Ae=be==="remote"?"deleted":"edited",W=be==="local";break;case"move-beats-delete":le=be==="local"?"deleted":"moved",Ae=be==="remote"?"deleted":"moved",W=be==="local";break;case"remote-wins":le="edited",Ae="edited",W=!0;break;default:le=Ae="inserted",W=l.localLost}return{key:`structure:${K.key}:${O}`,subject:K,localLost:W,anchor:Z[0]||null,structure:{localAction:le,remoteAction:Ae,localPlacement:U,remotePlacement:de,mergedPlacement:we,localOrder:X,mergedOrder:pe,localFragment:O==="both-reordered"||!R.l?null:fe(R.l),fragmentKind:x(R.b||R.l||R.r)}}};for(let[$,l]of i){if($.kind!=="structure")continue;let O=l.unit||V(l.subject),R=O.b||O.l||O.r;!dn(R)&&R.kind==="comment"&&It.set(R,`structure:${Oe(O).key}:${$.detail}`)}let fn=new Map;for(let[$,l]of i){if($.kind==="structure"){let Z=Oe(l.unit||V(l.subject)),U=`structure:${Z.key}:${$.detail}`,de=fn.get(U);if(de&&de.structure){$.recovery=de;let we=S.refs.get(Z);$.el==null&&we.length&&($.el=dn(we[0])?we[0]:c.out.logicalParent(we[0]));continue}}let O=$.kind==="text"?jt($,l):$.kind==="attr"?rn($,l):Gt($,l),R=fn.get(O.key);R||(R={version:ol,key:O.key,localLost:O.localLost,subject:O.subject,applied:!1,unavailable:null},fn.set(O.key,R),S.anchors.set(R,O.anchor)),O.text&&(R.text=O.text),O.attribute&&(R.attribute=O.attribute),O.structure&&(R.structure=O.structure),O.text&&(R.localLost=O.localLost),$.recovery=R;let K=S.refs.get(O.subject);$.kind==="structure"&&$.el==null&&K.length&&($.el=dn(K[0])?K[0]:c.out.logicalParent(K[0])),$.kind==="text"&&$.node==null&&K.length&&O.subject.nodeType===8&&($.node=K[0])}return S}}function Ir(e,o,t){if(!o)return;let{lookup:n,vetoed:s,vetoedAttrs:h,liveAttr:i}=t,r=t.ignored||(()=>!1),a=to(t.liveRoot),d=y=>!!y&&a.containerPath(y)!==null,w=y=>{let k=y.parentNode;return k&&k.nodeType===11?o.outOwners.get(k)||null:k},c=y=>{for(let k=y;k;k=w(k))if(o.via.has(k)&&(k=o.via.get(k)),s.has(k)||t.vetoedLive?.has(f(k)))return!0;return!1},p=y=>Array.from(Cn(y).children).filter(k=>!r(k)),m=(y,k)=>p(y)[p(k.parentNode).indexOf(k)],v=(y,k)=>{let J=null,H=null,q=0;for(let ie=k.previousSibling;ie;ie=ie.previousSibling){if(ie.nodeType===1&&!r(ie)){J=ie;break}ie.nodeType===3&&(q+=ie.nodeValue.length)}for(let ie=k.nextSibling;ie&&!H;ie=ie.nextSibling)ie.nodeType===1&&!r(ie)&&(H=ie);let Me=J?m(y,J):null,Oe=H?m(y,H):null;if(J&&!Me||H&&!Oe)return null;let Re=[];for(let ie=Me?Me.nextSibling:Cn(y).firstChild;ie&&ie!==Oe;ie=ie.nextSibling)ie.nodeType===3&&Re.push(ie);return Re.length?{nodes:Re,lead:q}:null},I=y=>{let k=[],J=y;for(;J&&!o.via.has(J);J=J.parentNode)k.push(J);if(!J||!k.length)return null;let H=f(o.via.get(J));for(let Oe=k.length-1;Oe>0&&H;Oe--)H=m(H,k[Oe]);if(!H)return null;let q=k[0];if(q.nodeType===3)return v(H,q);let Me=q.nodeType===1?m(H,q):null;return Me?{nodes:[Me],lead:0}:null},g=y=>{let k=n(y),J=k?{nodes:Array.isArray(k)?k:[k],lead:0}:o.via.size?I(y):null;if(!J)return null;let H=J.nodes.filter(d);return H.length?{nodes:H,lead:J.lead}:null},f=y=>{let k=g(y);return k?k.nodes[0]:null},b=y=>{if(!y)return null;if(y.kind==="text"){let q=g(y.node);if(!q)return null;let Me=q.nodes,Oe=y.offset+q.lead,Re=0;for(let ie=0;ie<Me.length;ie++){let xe=Me[ie].nodeValue.length;if(Oe<=Re+xe||ie===Me.length-1)return Oe>=Re&&Oe<=Re+xe?[Me[ie],Oe-Re]:null;Re+=xe}return null}let k=f(y.node);if(!k)return null;if(y.kind==="end")return[Cn(k),Cn(k).childNodes.length];if(y.kind==="startOf")return[Cn(k),0];if(y.kind==="wholeStart")return k.firstChild?[k.firstChild,0]:[k,0];if(y.kind==="wholeEnd")return k.lastChild?[k.lastChild,k.lastChild.nodeValue.length]:[k,k.childNodes.length];let J=k.parentNode;if(!J)return null;let H=Array.prototype.indexOf.call(J.childNodes,k);return[J,y.kind==="after"?H+1:H]},B=y=>({blocks:new Set((y.flat?.marks||[]).filter(k=>k.block).map(k=>f(k.el)).filter(Boolean)),atoms:new Set((y.flat?.atoms||[]).map(k=>f(k.el)).filter(Boolean)),ignored:r}),S=(y,k,J,H)=>{if(!y||!k||!eo(y)||!eo(k))return!1;for(let Oe of[y,k])if(!d(Oe.startContainer)||!d(Oe.endContainer))return!1;let q=J.merged;if(q.start===q.end&&(y.startContainer!==y.endContainer||y.startOffset!==y.endOffset))return!1;let Me=B(H);return Xn(k,J.encoding,Me)===q.text&&Xn(y,J.encoding,Me)===q.text.slice(q.start,q.end)},T=new Map,M=y=>{let k=y.parentNode;return k?(T.has(k)||T.set(k,new Map(Array.from(k.childNodes,(J,H)=>[J,H]))),T.get(k).get(y)):-1},L=(y,k)=>{if(!k)return!1;let J=a.logicalParent(y);if(!k.parent.live.includes(J))return!1;let H=M(y);for(let[q,Me]of[["before",1],["after",-1]]){let Oe=H;for(let Re of k[q]){if(Re.live.includes(y))continue;let ie=Re.live.filter(qe=>qe!==y&&qe.parentNode===y.parentNode);if(!ie.length)continue;let xe=Me===1?Math.min(...ie.map(M)):Math.max(...ie.map(M));if(Me*(xe-Oe)<=0)return!1;Oe=xe}}return!0},N=y=>{let k=y.structure;if(k.mergedOrder){let J=new Set(y.subject.live.map(Cn)),H=null,q=-1;for(let Me of k.mergedOrder){let Oe=Me.live.find(Re=>J.has(Re.parentNode));if(!Oe||H&&Oe.parentNode!==H||M(Oe)<=q)return!1;H=Oe.parentNode,q=M(Oe)}return y.subject.live.length>0}return y.subject.live.some(J=>L(J,k.mergedPlacement))},A=(y,k)=>{let J=b(y),H=b(k);return J&&H?{startContainer:J[0],startOffset:J[1],endContainer:H[0],endOffset:H[1]}:null},E=new Set,V=y=>{if(!y||E.has(y))return;E.add(y);let k=[];for(let J of o.refs.get(y)||[]){let H=g(J);if(H)for(let q of H.nodes)k.includes(q)||k.push(q)}y.live=k},j=y=>{y&&(V(y.parent),y.before.forEach(V),y.after.forEach(V))},D=new Set;for(let y of e){let k=y.recovery;if(!k||D.has(k))continue;D.add(k),V(k.subject),k.structure&&(j(k.structure.localPlacement),j(k.structure.remotePlacement),j(k.structure.mergedPlacement),(k.structure.localOrder||[]).forEach(V),(k.structure.mergedOrder||[]).forEach(V));let J=o.anchors.get(k),H=J?f(J):null,q=!!H;if(k.text){let x=o.spans.get(k.text.merged),Y=x?A(x.start,x.end):null,ae=x?A(x.scopeStart,x.scopeEnd):null;if(x?.empty){let oe=x.empty,Ee=oe.previous?{kind:"after",node:oe.previous}:{kind:"startOf",node:oe.parent},je=oe.next?{kind:"before",node:oe.next}:{kind:"end",node:oe.parent},Ne=A(Ee,je);!Ne||Ne.startContainer!==Ne.endContainer||Ne.startOffset!==Ne.endOffset?Y=null:Y=ae=Ne}S(Y,ae,k.text,x)||(Y=ae=null),k.text.liveSpan=Y,k.text.liveScope=Y?ae:null,Y||(q=!1)}k.structure&&q&&(q=N(k)),k.attribute&&q&&(q=i(H,k.attribute,y.resolved));let Me=(!!k.attribute||!!k.text&&H?.tagName==="TEXTAREA")&&!!h&&[J,H].some(x=>h.get(x)?.has(k.attribute?k.attribute.qualifiedName:"value")),Oe=o.localState?.states.get(k),Re=!!k.text&&[...t.removedVetoes||[]].some(x=>Oe?.touched.has(x)),ie=k.structure?.localAction==="inserted"&&[...s].some(x=>x===J||J?.contains(x)),xe=J&&c(J)||Me||Re||ie,qe=xe&&Mr(k,y,o,d);qe&&(Re||ie&&k.localLost)&&(q=!1);let fe=!q&&qe&&xe;k.applied=q,k.unavailable=q?null:fe?"hook-veto":"missing-output",fe&&(k.localLost=!1),!q&&k.text&&(k.text.liveSpan=k.text.liveScope=null)}}function Xo(e,o,t){let n=to(o),s=to(t),h=c=>!!c&&s.containerPath(c)!==null,i=c=>{if(c===o)return t;let p=n.pathOf(c);if(p&&o!==t){let m=Zn(t,{path:p,offset:0});if(m&&m[0].nodeType===c.nodeType)return m[0]}return c},r=new Set,a=c=>{!c||r.has(c)||(r.add(c),c.live=c.live.map(i).filter(h))},d=c=>{c&&(c.startContainer=i(c.startContainer),c.endContainer=i(c.endContainer))},w=new Set;for(let c of e){c.node===o&&t.tagName==="SCRIPT"&&(c.node=t),c.el===o&&c.kind==="structure"&&(c.el=t);let p=c.recovery;if(!p||w.has(p))continue;if(w.add(p),a(p.subject),p.text){d(p.text.liveSpan),d(p.text.liveScope);let v=p.text.liveSpan,I=p.text.liveScope,g=p.text.merged,f=b=>!!b&&eo(b)&&h(b.startContainer)&&h(b.endContainer);(!f(v)||!f(I)||Xn(I,p.text.encoding)!==g.text||Xn(v,p.text.encoding)!==g.text.slice(g.start,g.end))&&(p.text.liveSpan=null,p.text.liveScope=null,p.applied=!1,p.unavailable="missing-output")}let m=p.structure;if(m){for(let v of[m.localPlacement,m.remotePlacement,m.mergedPlacement])v&&(a(v.parent),v.before.forEach(a),v.after.forEach(a));(m.localOrder||[]).forEach(a),(m.mergedOrder||[]).forEach(a),p.subject.live.length||(p.applied=!1,p.unavailable="missing-output")}}}var mo=e=>e?.nodeType===1,Io=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function sl({provenance:e,parentOf:o,twins:t,baseOf:n,build:s,ignored:h,remoteWins:i,discarded:r}){let a=new Map,d=new WeakMap;function w(m,v,I,g=!1){if(!mo(m)||!mo(I))return null;let f=a.get(m);if(f)(g||!f.selected&&v==="remote")&&(f.parent=o(I),f.port=I,f.sourceSide=v,f.selected=g);else{let b=d.get(m)||null;f={owner:m,parent:o(I),port:I,sourceSide:v,originalParent:o(m),originalPort:m,selected:g,state:b?"built":"planned",output:b,disposition:null},a.set(m,f)}return f}function c(m,v){if(!mo(m)||!mo(v))return;d.has(m)||d.set(m,v);let I=a.get(m);I&&I.state!=="attached"&&!I.output&&(I.output=v,I.state="built")}function p(m){if(!a.size)return;let v=new Map,I=new WeakMap,g=new WeakMap,f=new WeakSet,b=new Set,B=(j,D)=>{if(!j)return;if(Array.isArray(j)){for(let k of j)B(k,D);return}let y=v.get(j);y||v.set(j,y=[]),y.push(D)},S=(j,D)=>{if(!j)return;let y=[j];for(;y.length;){let k=y.pop();B(k,D);for(let J of Io(k).childNodes)y.push(J)}};function T(j,D=null,y=!1){if(f.has(j))return;f.add(j),I.set(j,D);let k=e.get(j),J=y||!!(k&&i(k.remote||k.base));g.set(j,J);let H={node:j,kind:"node",authority:J};if(k?.pinned)S(k.local,{...H,kind:"ignored"});else if(k?.unchanged)for(let q of[k.base,k.local,k.remote])S(q,{...H,kind:"unchanged"});else if(k){for(let q of[k.base,k.local,k.remote])B(q,H);if(mo(k.local))for(let q of Io(k.local).children)h(q)&&S(q,{...H,kind:"ignored"})}for(let q of Io(j).childNodes)T(q,j,J)}let M=j=>{if(j.output&&f.has(j.output))return j.state="attached",j.disposition="node",!0;let{local:D,remote:y}=t(j.owner);for(let k of[j.owner,D,y]){let J=v.get(k);if(J?.length){let H=J.find(q=>q.kind==="node")||J[0];return j.output=H.node,j.state="attached",j.disposition=H.kind,!0}}return!1},L=(j,D)=>(v.get(j)||[]).find(k=>k.kind==="node"&&mo(k.node)&&(!k.authority||D.sourceSide==="remote"))?.node,N=(j,D,y)=>{let k=v.get(j)||[],J=y?[...k].reverse():k;for(let H of J){if(H.kind!=="node")continue;let q=H.node;for(;q&&I.get(q)!==D;)q=I.get(q);if(q)return q}return null},A=(j,D,y)=>{let k=Io(D);for(let J=y?.previousSibling;J;J=J.previousSibling){let H=N(J,D,!0);if(H){k.insertBefore(j,H.nextSibling);return}}for(let J=y?.nextSibling;J;J=J.nextSibling){let H=N(J,D,!1);if(H){k.insertBefore(j,H);return}}k.appendChild(j)};function E(j,D,y){let k=D==="base"?j:n(j,D),J=a.get(k);J&&J!==y&&V(J)}function V(j){if(j.state==="attached"||j.disposition==="remote-wins"||b.has(j)||M(j))return;b.add(j);let{local:D,remote:y}=t(j.owner);if(i(y||j.owner)){if(!y){j.disposition="remote-wins",r(j.owner,D),b.delete(j);return}j.parent=o(y),j.port=y,j.sourceSide="remote"}if(E(j.parent,j.sourceSide,j),M(j)){b.delete(j);return}let k=L(j.parent,j),J=j.port;if(!k){if(E(j.originalParent,"base",j),M(j)){b.delete(j);return}let q=j.originalParent;for(J=j.originalPort;q&&!k;)k=L(q,j),k||(J=q,q=o(q))}if(!k)throw new Error("A planned move has no allowed surviving parent");let H=j.output||s(j.owner);j.output=H,j.state="built",A(H,k,J),T(H,k,g.get(k)||!1),M(j),b.delete(j)}T(m);for(let j of a.values())V(j)}return{planned:a,has:m=>a.has(m),plan:w,produced:c,drain:p}}function go(e,o,t,n,s,h,i,r,a,d,w,c,p){let m=null;return sl({provenance:e,parentOf:g=>{if(!g)return null;let f=o(g);if(f||g.parentNode?.nodeType!==11)return f;if(!m){m=new WeakMap;let b=[c,p];for(;b.length;){let B=b.pop(),S=Io(B);S!==B&&m.set(S,B);for(let T of S.children)b.push(T)}}return m.get(g.parentNode)||null},twins:g=>({local:s(t,g),remote:s(n,g)}),baseOf:(g,f)=>g&&(f==="local"?t:n).reverse.get(g)||null,build:g=>h(g,s(t,g),s(n,g),!1),ignored:i,remoteWins:r,discarded:(g,f)=>{f&&w(g,f,t)&&!a.some(b=>b.detail==="remote-wins"&&b.base===g)&&d({kind:"structure",el:null,detail:"remote-wins",base:g,local:f,remote:null},{subject:g})}})}function rl({parent:e,base:o,views:t,eligible:n,ignored:s,remoteWins:h,budget:i=zt(2e4*32),maxUnits:r=256,maxCharacters:a=2e4}){let d=(f,b=null)=>({status:f,reason:b,parent:e,records:[]});if(t.some(({V:f})=>f.asBase)||s(e)||h(e)||t.some(({V:f})=>!f.el||s(f.el)||h(f.el)))return d("none");let w=o.length+t[0].V.units.length+t[1].V.units.length;if(w>r)return d("fallback","unit-limit");let c=Symbol(),p=f=>{if(f>i.remaining)throw c;i.remaining-=f,i.crossParentSteps=(i.crossParentSteps||0)+f},m=new Map,v=0,I=f=>{if(p(1),m.has(f))return m.get(f);let b=f.nodeType===1?f.childNodes:f.nodes;p(b.length*4+1);let B=f.nodeType===1?Array.from(b):b,S=0;for(let L=0;L<B.length;L++){let N=B[L];if(N.nodeType!==3||L&&B[L-1].nextSibling!==N)return m.set(f,null),null;S+=N.data.length}if(S>a-v)throw c;p(S*8+1),v+=S;let T=nn(B);if(T.text.includes(kt))return m.set(f,null),null;let M={unit:f,nodes:B,flat:T};return m.set(f,M),M},g=[];try{p(w*8+1);for(let f=0;f<2;f++){let b=t[f].V,B=t[1-f].V,S=[],T=new Map;for(let M=0;M<o.length;M++){p(1);let L=o[M];if(L.kind!=="text"||b.twin(L))continue;let N=B.twin(L);if(!N||N.kind!=="text"||!B.here(N))continue;let A=I(L),E=I(N);if(!A||!E||!/\S/.test(A.flat.text))continue;p(A.flat.text.length*2+1);let V=A.flat.text;T.set(V,(T.get(V)||0)+1),S.push({source:L,opposite:N,sourceModel:A,oppositeModel:E,index:M})}for(let M of S){let{source:L,opposite:N,sourceModel:A,oppositeModel:E,index:V}=M,j=[];for(let Y of[-1,1]){p(1);let ae=o[V+Y];if(!ae||ae.nodeType!==1||!n(ae)||s(ae)||h(ae))continue;let oe=A.nodes[0],Ee=A.nodes.at(-1);if(Y===-1?oe?.previousSibling!==ae:Ee?.nextSibling!==ae)continue;let je=b.twin(ae),Ne=B.twin(ae);if(!je||!Ne||!b.here(je)||B.here(Ne)||b.baseOf(je)!==ae||B.baseOf(Ne)!==ae||!n(je)||!n(Ne)||s(je)||s(Ne)||h(je)||h(Ne)||je.tagName!==ae.tagName||Ne.tagName!==ae.tagName||je.namespaceURI!==ae.namespaceURI||Ne.namespaceURI!==ae.namespaceURI)continue;let tt=I(ae),Xe=I(je),dt=I(Ne);if(!tt||!Xe||!dt||!/\S/.test(tt.flat.text))continue;let Ge=tt.flat.text,st=A.flat.text,Ot=Xe.flat.text;if(p((Ge.length+st.length+Ot.length)*3+1),Ot.length!==Ge.length+st.length)continue;let Ct=Y===-1;(Ct?!Ot.startsWith(Ge)||!Ot.endsWith(st):!Ot.startsWith(st)||!Ot.endsWith(Ge))||j.push({owner:ae,target:je,moved:Ne,ownerBase:tt,joined:Xe,ownerOther:dt,targetFrom:Ct?Ge.length:0,retainedFrom:Ct?0:st.length})}if(!j.length)continue;if(j.length!==1||T.get(A.flat.text)!==1)return d("fallback","ambiguous-origin");let D=j[0],{owner:y,target:k,moved:J,ownerBase:H,joined:q,ownerOther:Me,targetFrom:Oe,retainedFrom:Re}=D;if(p(g.length+1),g.some(Y=>Y.owner===y))return d("fallback","ambiguous-owner");let ie={source:L,target:k,from:0,to:A.flat.text.length,targetFrom:Oe},xe=jn({base:A.flat,side:q.flat,retained:[],transfers:[{from:ie.from,to:ie.to,target:Oe,destination:y}],budget:i});if(xe.status!=="ready"||xe.covers(ie.from,ie.to)!==!0)return d("fallback",xe.reason||"work-limit");let qe=[{unit:L,model:A,from:0,to:A.flat.text.length},null,null];qe[f+1]={unit:k,model:q,from:Oe,to:Oe+A.flat.text.length},qe[2-f]={unit:N,model:E,from:0,to:E.flat.text.length};let fe=[H,null,null];fe[f+1]=q,fe[2-f]=Me;let x=[y,null,null];x[f+1]=k,x[2-f]=J,g.push({side:f,parent:e,source:L,target:k,owner:y,owners:x,ownerModels:fe,native:qe,models:m,runs:[ie],proof:xe,retained:[{source:y,target:k,from:0,to:H.flat.text.length,targetFrom:Re}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:d("none")}catch(f){if(f!==c)throw f;return d("fallback","work-limit")}}function Cr({describe:e,parentOf:o,...t}){let n=new WeakMap,s=new WeakMap,h=t.budget||zt(2e4*32),i=r=>{if(!r)return null;if(n.has(r))return n.get(r);n.set(r,{status:"planning",parent:r,records:[]});let a=e(r),d=a?rl({...t,...a,parent:r,budget:h}):{status:"none",reason:null,parent:r,records:[]};if(n.set(r,d),d.status==="ready")for(let w of d.records)s.set(w.owner,[w]);return d};return{get:i,forOwner(r){return i(o(r))?.status==="ready"&&s.get(r)||null}}}function il(e,o){if(e.side!==0)return null;let t=e.native[0].model,n=e.ownerModels[0],s=e.native[1].from!==0,h=(B,S)=>s?[...B.nodes,...S.nodes]:[...S.nodes,...B.nodes],i=e.ownerModels.reduce((B,S)=>B+S.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(i*8>o.remaining)return null;o.remaining-=i*8;let r={base:h(n,t),local:e.ownerModels[1].nodes,remote:h(e.ownerModels[2],e.native[2].model)},a=nn(r.base),d=e.ownerModels[1].flat,w=nn(r.remote),c=s?n.flat.text.length:0,p=s?0:t.flat.text.length,m=jn({base:a,side:d,retained:e.retained.map(B=>({from:p+B.from,to:p+B.to,target:B.targetFrom})),transfers:e.runs.map(B=>({from:c+B.from,to:c+B.to,target:B.targetFrom,destination:e.owner})),budget:o});if(m.status!=="ready"||m.covers(0,a.text.length)!==!0)return null;let v=e.ownerModels[2].flat,I=e.native[2].model.flat,g=[];for(let[B,S,T,M]of[[n.flat,v,p,s?0:I.text.length],[t.flat,I,c,s?v.text.length:0]]){let L=ks(B,B,S).remoteMap.bTo,N=-1;for(let A=0;A<B.text.length;A++){if(L[A]<0){N=-1;continue}let E=g.at(-1);N>=0&&E.to===T+A&&E.target+E.to-E.from===M+L[A]?E.to++:(g.push({from:T+A,to:T+A+1,target:M+L[A]}),N=A)}}let f=jn({base:a,side:w,retained:g,transfers:[],budget:o});if(f.status!=="ready")return null;let b=ks(a,d,w,{},{local:m,remote:f});return b.localEdits.hunks.length?null:(b.localMap=m,b.remoteMap=f,{nodes:r,prepared:b})}function Lr({L:e,R:o,twinIn:t,unitsOf:n,view:s,parentOf:h,ignored:i,remoteWins:r,eligible:a,build:d,out:w,policy:c,provenance:p,textMappers:m,segments:v,conflicts:I,conflict:g,decisions:f}){let b=zt(2e4*32),B=j=>{let D=0;for(let y=j;y;y=h(y))if(++D>64||y.nodeType===1&&(i(y)||r(y)))return!1;return!0},S=Cr({parentOf:h,eligible:a,ignored:i,remoteWins:r,budget:b,describe(j){let D=t(e,j),y=t(o,j);return!D||!y||!B(j)||!B(D)||!B(y)?null:{base:n(j),views:[{A:e,V:s(e,D,j,!1)},{A:o,V:s(o,y,j,!1)}]}}}),T=new WeakSet,M=new WeakMap,L=new WeakSet,N=[];function A(j){if(!j||T.has(j))return;T.add(j);let D=S.get(j);if(D?.status==="ready")for(let y of D.records){if((j.tagName==="TEMPLATE"&&j.content?j.content:j).childNodes.length!==y.native[0].model.nodes.length+1||!y.owners.every(B))continue;let J=il(y,b);if(!J)continue;let H={record:y,payload:J,state:"planned",output:null,result:null};M.set(y.owner,H),L.add(y.source),L.add(y.native[2].unit),N.push(H)}}function E(j,D){let y=M.get(j);if(!y)return!1;if(!y.result){if(y.result=Ko({...y.payload.nodes,prepared:y.payload.prepared,out:w,policy:c,provenance:p,textMappers:m,conflicts:I,conflict:g,decisions:f,node:D}),y.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");v.push(...y.result.segments),y.decision={kind:"text",node:D,source:"local"},f.push(y.decision)}return y.decision.node=D,D.replaceChildren(...y.result.nodes),y.output=D,y.state="built",!0}function V(j){if(!N.length)return;let D=new WeakSet,y=new WeakMap,k=new WeakMap,J=new WeakMap,H=xe=>xe.tagName==="TEMPLATE"&&xe.content?xe.content:xe,q=(xe,qe)=>{if(!xe)return;if(Array.isArray(xe)){for(let x of xe)q(x,qe);return}let fe=J.get(xe);fe||J.set(xe,fe=[]),fe.push(qe)},Me=(xe,qe=null,fe=!1)=>{D.add(xe),y.set(xe,qe);let x=p.get(xe),Y=fe||!!(x&&r(x.remote||x.base));if(k.set(xe,Y),x)for(let ae of[x.base,x.local,x.remote])q(ae,xe);if(!(x?.pinned||x?.unchanged))for(let ae of H(xe).childNodes)Me(ae,xe,Y)},Oe=xe=>(J.get(xe)||[]).find(qe=>qe.nodeType===1&&!k.get(qe)&&!p.get(qe)?.pinned&&!p.get(qe)?.unchanged),Re=(xe,qe)=>{for(let fe of J.get(xe)||[]){let x=fe;for(;x&&y.get(x)!==qe;)x=y.get(x);if(x)return x}return null},ie=(xe,qe,fe)=>{let x=H(qe);for(let Y=fe.nextSibling;Y;Y=Y.nextSibling){let ae=Re(Y,qe);if(ae){x.insertBefore(xe,ae);return}}for(let Y=fe.previousSibling;Y;Y=Y.previousSibling){let ae=Re(Y,qe);if(ae){x.insertBefore(xe,ae.nextSibling);return}}x.appendChild(xe)};Me(j);for(let xe of N){let{record:qe}=xe,fe=Oe(qe.owner)||Oe(qe.owners[1])||Oe(qe.owners[2]);if(fe)(!xe.result||xe.output!==fe||xe.result.nodes.some(x=>!D.has(x)||y.get(x)!==fe)||fe.textContent!==xe.result.text)&&(E(qe.owner,fe),Me(fe,y.get(fe),k.get(fe)));else{let x=qe.parent,Y=qe.owner,ae=null;for(;x&&!ae;)ae=Oe(x),ae||(Y=x,x=h(x));if(!ae)throw new Error("A cross-parent payload has no allowed surviving parent");fe=xe.output||d(qe.owner,qe.owners[1],qe.owners[2],!1),xe.result||E(qe.owner,fe),ie(fe,ae,Y),Me(fe,ae,k.get(ae))}xe.state="attached"}}return{ensureParent:A,ensureOwner(j){A(h(j))},consumes(j){return L.has(j)},render:E,drain:V}}var Mn=/\S/,Er=/[\p{L}\p{N}]/u;function no(e,o,t,n){if(e?.nodeType!==1||!o(e))return!1;for(let s=e.firstChild;s;s=s.nextSibling)if(n(t,1),s.nodeType!==3)return!1;return!!e.firstChild}function Ms(e,o,t){for(let n=e.parentNode;n;n=n.parentNode)if(t(o,1),n.nodeType===11)return!1;return!0}function Rr(e,o,t,n,s){let h=t(e,n),i=t(o,n),r=null,a=null,d=null,w=null;s(n,h.length+i.length);for(let c of h)Er.test(c.raw)&&(r||=c,a=c);for(let c of i)Er.test(c.raw)&&(d||=c,w=c);return!!(r&&d&&(r.raw===d.raw||a.raw===w.raw))}function ll({base:e,V:o,A:t,source:n,original:s,current:h,edited:i,destination:r,at:a,ownLength:d,eligible:w,model:c,tokensOf:p,budget:m,charge:v}){let I=s.flat.text,g=h.flat.text,f=i.flat.text,b=r.flat.text;if(v(m,I.length+g.length+b.length),I.startsWith(g)||I.endsWith(g))return!1;let B=Mn.test(b.slice(0,a)),S=Mn.test(b.slice(a+d));if(B===S)return!1;let T=B?0:a+d,M=B?a:b.length;for(;T<M&&!Mn.test(b[T]);)T++;for(;M>T&&!Mn.test(b[M-1]);)M--;let L=b.slice(T,M);if(In(L,b,p(r,m),m,v,!0)!==T)return!1;let N=In(L,I,p(s,m),m,v,!0);if(N<0)return!1;let A=N+L.length,E=!Mn.test(I.slice(0,N)),V=!Mn.test(I.slice(A));if(E===V||In(L,g,p(h,m),m,v,!1)>=0)return!1;let j=E?I.slice(A):I.slice(0,N),D=E?f.length-j.length:0;if(v(m,I.length+f.length),D<0||!Mn.test(j)||In(j,f,p(i,m),m,v,!0)!==D||!Mn.test(E?f.slice(0,D):f.slice(j.length)))return!1;for(let y of e){if(v(m,1),y===n||!no(y,w,m,v))continue;let k=c(y,null,m);if(In(L,k.flat.text,p(k,m),m,v,!1)>=0)return!1}for(let y of o.units){if(v(m,1),y===h.unit||y===r.unit||!no(y,w,m,v))continue;let k=c(y,t,m);if(In(L,k.flat.text,p(k,m),m,v,!1)>=0)return!1}return!0}function Pr({base:e,views:o,side:t,attempt:n,eligible:s,blocked:h,baseId:i,model:r,tokensOf:a,charge:d,exhausted:w,limit:c}){if(c<=0)return null;let p=zt(c),{V:m,A:v,idOf:I}=o[t],g=o[1-t],[f,b,B,S]=n,T=null;try{for(let M=f;M<=b;M++){d(p,1);let L=e[M];if(L.parentNode?.nodeType!==1||h.has(L)||v.identical.has(L)||g.A.identical.has(L)||!no(L,s,p,d)||i(L))continue;let N=m.twin(L),A=g.V.twin(L);if(!N||!A||!m.here(N)||!g.V.here(A)||v.map.get(L)!==N||v.reverse.get(N)!==L||g.A.map.get(L)!==A||g.A.reverse.get(A)!==L||I(N)||g.idOf(A)||N.tagName!==L.tagName||A.tagName!==L.tagName||!no(N,s,p,d)||!no(A,s,p,d)||!Ms(L,p,d)||!Ms(N,p,d)||!Ms(A,p,d))continue;let E=r(L,null,p),V=r(N,v,p),j=r(A,g.A,p),D=E.flat.text,y=V.flat.text,k=j.flat.text;if(d(p,D.length+y.length+k.length),!Mn.test(D)||!Mn.test(y)||!Mn.test(k)||D===y||D===k||y===k||!Rr(E,V,a,p,d)||!Rr(E,j,a,p,d))continue;let J=null,H=!1;for(let Oe=B;Oe<=S;Oe++){d(p,1);let Re=m.units[Oe],ie=m.baseOf(Re);if(!ie||ie===L||h.has(ie)||ie.parentNode!==L.parentNode||Re.parentNode!==N.parentNode||ie.tagName!==L.tagName||Re.tagName!==L.tagName||v.map.get(ie)!==Re||v.reverse.get(Re)!==ie||i(ie)!==I(Re)||!no(ie,s,p,d)||!no(Re,s,p,d))continue;let xe=r(ie,null,p),qe=r(Re,v,p),fe=xe.flat.text,x=qe.flat.text;if(d(p,fe.length),!Mn.test(fe)||x.length<=fe.length)continue;let Y=a(qe,p),ae=In(fe,x,Y,p,d,!0);if(!(ae<0||In(D,x,Y,p,d,!0,ae,ae+fe.length)<0&&!ll({base:e,V:m,A:v,source:L,original:E,current:V,edited:j,destination:qe,at:ae,ownLength:fe.length,eligible:s,model:r,tokensOf:a,budget:p,charge:d}))){if(J){H=!0;break}J=Re}}if(!J||H)continue;let q=t===0?N:A,Me=t===0?A:N;(T||=[]).push({source:L,local:q,remote:Me,models:[E,t===0?V:j,t===0?j:V]})}}catch(M){if(M!==w)throw M}return T}var Hn=/\S/,gn=/\s/,al=/[\s\u001e]/g,Os=/[^\s\p{P}\u001e\ufffc]/u;function cl(e,o,t,n,s,h,i){let r=0;for(let a of e)i(h,1),a.nodeType===1&&!n.baseOf(a)&&r++;if(r<2)return!1;for(let a of e){if(a.nodeType!==1||n.baseOf(a))continue;let d=s.get(a).flat;if(d.atoms.length||d.pins?.length)continue;i(h,d.text.length*2+o.length+t.length);let w=new Uint8Array(d.text.length);for(let c of t)c.target===a&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c of o)c.target===a&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c=0;c<d.text.length;c++)if(!w[c]&&Hn.test(d.text[c]))return!0}return!1}function fl(e,o,t){let{source:n,models:s,retained:h,runs:i}=e,r=s.get(n).flat.text;t(o,r.length*2+h.length+i.length);let a=new Uint8Array(r.length);for(let d of h)d.source===n&&(t(o,d.to-d.from),a.fill(1,d.from,d.to));for(let d of i)t(o,d.to-d.from),a.fill(1,d.from,d.to);for(let d=0;d<r.length;d++)if(!a[d]&&Hn.test(r[d]))return!1;return!0}function ul(e,o,t,n,s,h,i,r,a,d){let w=h.get(e),c=h.get(o),p=w.flat.text,m=i.get(e);a(d,p.length*2+t.length);let v=p.length,I=0;for(let b=0;b<p.length;b++)!gn.test(p[b])&&!m[b]&&(v=Math.min(v,b),I=b+1);if(v>=I)return null;for(let b=v;b<I;b++)if(!gn.test(p[b])&&m[b])return null;let g=-1;for(let b of t)if(b.target===o&&b.from<=v&&b.to>v){g=b.targetFrom+v-b.from;break}if(g<0)return null;let f=p.slice(v,I);if(a(d,f.length*(t.length+2)),c.flat.text.slice(g,g+f.length)!==f)return null;for(let b=v;b<I;b++){if(gn.test(p[b]))continue;let B=!1;for(let S of t)if(S.target===o&&S.from<=b&&S.to>b&&S.targetFrom+b-S.from===g+b-v){B=!0;break}if(!B)return null}if(w.flat.atoms.length||c.flat.atoms.length){a(d,w.flat.atoms.length+c.flat.atoms.length);let b=0,B=c.flat.atoms;for(;b<B.length&&B[b].i<g;)b++;for(let S of w.flat.atoms){if(S.i<v||S.i>=I)continue;let T=B[b++];if(!T||T.i!==g+S.i-v||c.alignment?.reverse.get(T.el)!==S.el)return null}if(b<B.length&&B[b].i<g+I-v)return null}for(let[b,B,S]of[[n,e,v],[s,o,g]]){let T=!1;for(let M of b){let L=h.get(M),N=i.get(M),A=r(L,d);for(let E=0;E<A.length;E++){let V=A[E].from,j=V+f.length;if(a(d,f.length*2+1),L.flat.text.slice(V,j)!==f)continue;let D=E;for(;D<A.length&&A[D].to<j;)a(d,1),D++;if(D===A.length||A[D].to!==j)continue;let y=!0;for(let k=V;k<j;k++)if(!gn.test(L.flat.text[k])&&N[k]){y=!1;break}if(y){if(T||M!==B||V!==S)return null;T=!0}}}if(!T)return null}return f}function dl(e,o,t,n,s,h,i,r){if(i(r,s.length+h.length+(n.length+1)*t.length*2),!t)return!1;let a=n.indexOf(t);return a<0||n.lastIndexOf(t)!==a||!h.some(d=>d.from===a)||!h.some(d=>d.to===a+t.length)?!1:s.some(d=>d.source===e&&d.target===o&&d.from===0&&d.to===t.length&&d.targetFrom===a)}function Br({base:e,views:o,eligible:t,baseId:n,ignored:s,remoteWins:h,atomKey:i,limit:r=2e4*8}){if(r<=0)return null;let a=Symbol(),d=(S,T)=>{if(T>S.remaining)throw a;S.remaining-=T},w=[new Map,new Map];for(let S=0;S<2;S++)for(let T=0;T<o[S].V.units.length;T++)w[S].set(o[S].V.units[T],T);let c=new Int32Array(e.length),p=new Int32Array(e.length),m=S=>o.every(({V:T},M)=>{let L=T.twin(S);return L&&w[M].has(L)}),v=-1;for(let S=0;S<e.length;S++)c[S]=v,m(e[S])&&(v=S);v=e.length;for(let S=e.length-1;S>=0;S--)p[S]=v,m(e[S])&&(v=S);let I=new Map,g=(S,T)=>{if(d(T,1),I.has(S))return I.get(S);let M=S.firstChild,L=1;for(;M;){if(d(T,L*8+8),M.nodeType===3&&d(T,M.data.length*8),M.nodeType===1&&Tn.has(M.tagName)&&!s(M)&&!h(M)&&M.firstChild){M=M.firstChild,L++;continue}for(;M&&M!==S&&!M.nextSibling;)M=M.parentNode,L--;M=!M||M===S?null:M.nextSibling}let N=nn(Array.from(S.childNodes),{ignored:s,remoteWins:h});return I.set(S,N),N},f=(S,T,M,L,N,A)=>{for(let E of S.atoms){d(A,1);let V=T.atomAt.get(E.i+M);if(!V)return!1;let j=L?.reverse.get(E.el)||i(E.el),D=N?.reverse.get(V.el)||i(V.el);if(j!==D)return!1}return!0},b=(S,T,M,L,N)=>{let A=S.text.length<=T.text.length?S:T,E=A===S?T:S;if(d(N,A.text.length+E.text.length),!A.text||!Hn.test(A.text.replaceAll(Un,"")))return!1;let V;if(A.text===E.text)V=0;else{let j=E.text.length-A.text.length;if(d(N,(j+1)*A.text.length*2),E.text.startsWith(A.text))V=0;else if(E.text.endsWith(A.text))V=j;else return!1;if(E.text.indexOf(A.text)!==V||E.text.lastIndexOf(A.text)!==V)return!1;d(N,E.text.length*2);let D=0,y=V===0,k=!1;for(let J of an(E.text,xn(E.text)))D+=J.len,D===V&&(y=!0),D===V+A.text.length&&(k=!0);if(!y||!k)return!1}return A===S?f(A,E,V,M,L,N):f(A,E,V,L,M,N)},B=null;for(let S=0;S<2;S++){let{V:T,A:M,idOf:L}=o[S],N=o[1-S];if(!T.asBase)for(let A=0;A<e.length;A++){let E=e[A];if(T.twin(E)||!t(E))continue;let V=N.V.twin(E);if(!V||!w[1-S].has(V)||!t(V))continue;let j={remaining:r};try{let D=c[A],y=p[A],k=0;for(let Me=D+1;Me<y;Me++)d(j,1),!T.twin(e[Me])&&N.V.twin(e[Me])&&t(e[Me])&&k++;if(k!==1||g(E,j).text===g(V,j).text)continue;let J=D<0?-1:w[S].get(T.twin(e[D])),H=y===e.length?T.units.length:w[S].get(T.twin(e[y]));if(J===void 0||H===void 0||J>=H)continue;let q=null;for(let Me=J+1;Me<H;Me++){d(j,1);let Oe=T.units[Me];if(T.baseOf(Oe)||!t(Oe)||Oe.tagName!==E.tagName||Oe.namespaceURI!==E.namespaceURI)continue;let Re=n(E),ie=N.idOf(V),xe=L(Oe);if(!(Re&&ie&&Re!==ie||Re&&xe&&Re!==xe||ie&&xe&&ie!==xe)&&b(g(V,j),g(Oe,j),N.A,M,j)){if(q){q=null;break}q=Oe}}if(!q)continue;B||(B=[new Map,new Map]),B[S].set(E,q)}catch(D){if(D!==a)throw D}}}return B?o.map(({V:S},T)=>{let M=B[T];if(!M.size)return S;let L=new Map;for(let[N,A]of M)L.set(A,N);return{...S,twin:N=>M.get(N)||S.twin(N),baseOf:N=>L.get(N)||S.baseOf(N)}}):null}function Dr({onUncertainSource:e,onUncertainOwner:o,base:t,views:n,eligible:s,ignored:h,remoteWins:i,baseId:r,atomKey:a,limit:d=2e4*32}){if(d<=0)return null;let w=new Set(t),c=new Map(t.map((D,y)=>[D,y])),p=new Map,m=[],v=null,I=null,g=null,f=new Set;for(let D of t)for(let{V:y}of n){let k=y.twin(D);k&&!y.asBase&&!y.here(k)&&f.add(D)}let b=new Set,B=Symbol(),S=(D,y)=>{if(y>D.remaining)throw B;D.remaining-=y},T=(D,y,k)=>{S(k,1);let J=p.get(D);if(J)return J;if(D.nodeType===1){let Me=D.firstChild,Oe=1;for(;Me;){if(S(k,Oe*8+8),Me.nodeType===3&&S(k,Me.data.length*8),Me.nodeType===1&&Tn.has(Me.tagName)&&!h(Me)&&!i(Me)&&Me.firstChild){Me=Me.firstChild,Oe++;continue}for(;Me&&Me!==D&&!Me.nextSibling;)Me=Me.parentNode,Oe--;Me=!Me||Me===D?null:Me.nextSibling}}else S(k,D.value.length*8+D.nodes.length);let H=D.nodeType===1?Array.from(D.childNodes):D.nodes,q=H.length===1&&H[0].nodeType===3?{text:H[0].data,nodes:[{node:H[0],s:0,e:H[0].data.length}],atoms:[]}:nn(H,{ignored:h,remoteWins:i});return J={unit:D,flat:q,alignment:y,tokens:null},p.set(D,J),J},M=(D,y)=>{if(D.tokens)return D.tokens;S(y,D.flat.text.length*8);let{unit:k,flat:J,alignment:H}=D,q=[],Me=xn(J.text),Oe=0,Re=ie=>{for(let xe of an(J.text.slice(Oe,ie),Me))xe.from=Oe,xe.to=Oe+xe.len,xe.unit=k,q.push(xe),Oe+=xe.len};for(let ie of J.atoms){Re(ie.i);let xe=i(ie.el)&&ie.el.nodeType===1?"w"+ie.el.tagName+"#"+(ie.el.id||""):a(H?.reverse.get(ie.el)||ie.el);q.push({k:xe,raw:Un,len:1,from:Oe,to:Oe+1,unit:k,atom:!0}),Oe++}return Re(J.text.length),D.tokens=q,q},L=(D,y,k,J,H)=>{if(!D.flat.atoms.length&&!y.flat.atoms.length)return!0;let q=M(D,H),Me=M(y,H);S(H,q.length+Me.length);let Oe=0;for(let Re of Me){if(!Re.atom||Re.from<k||Re.from>=k+J)continue;for(;Oe<q.length&&!q[Oe].atom;)Oe++;let ie=q[Oe++];if(!ie||ie.from!==Re.from-k||ie.k!==Re.k)return!1}for(;Oe<q.length;)if(q[Oe++].atom)return!1;return!0},N=(D,y,k)=>{let J=D.length+y.length+4;if(J*8>k.remaining)return null;k.remaining-=J*8;let H=Math.floor(k.remaining/8),q=Math.min(D.length+y.length,4e3,Math.floor((Math.sqrt(J*J+H)-J)/2)),Me=4*(q+1)*(J+q+1);if(q<1||Me>k.remaining)return null;k.remaining-=Me;let Oe=Wn(D,y,q),Re=[],ie=0,xe=0;for(let qe of Oe.hunks){for(;ie<qe.bs;)D[ie].raw===y[xe].raw&&Re.push([D[ie],y[xe]]),ie++,xe++;ie=qe.be,xe+=qe.toks.length}for(;ie<D.length&&xe<y.length;)D[ie].raw===y[xe].raw&&Re.push([D[ie],y[xe]]),ie++,xe++;return Re},A=(D,y,k,J,H,q,Me)=>{if(H<=J)return;let Oe=D[D.length-1];if(Oe&&Oe.source===y&&Oe.target===k&&Oe.to<=J&&Oe.targetFrom-Oe.from===q-J){S(Me,(J-Oe.to)*3);let Re=p.get(y).flat.text,ie=p.get(k).flat.text,xe=!0;for(let qe=Oe.to;qe<J;qe++)if(!gn.test(Re[qe])||Re[qe]!==ie[q+qe-J]){xe=!1;break}if(xe){Oe.to=H;return}}D.push({source:y,target:k,from:J,to:H,targetFrom:q})},E=D=>D.replace(al,"");for(let D=0;D<n.length;D++){let{V:y,A:k,idOf:J}=n[D];if(y.asBase)continue;let H=new Map(y.units.map((x,Y)=>[x,Y])),q=x=>{let Y=y.twin(x);return Y&&H.has(Y)?Y:null},Me=(x,Y)=>{let ae=new Int32Array(x.length),oe=new Int32Array(x.length),Ee=-1;for(let je=0;je<x.length;je++)ae[je]=Ee,Y(x[je])&&(Ee=je);Ee=x.length;for(let je=x.length-1;je>=0;je--)oe[je]=Ee,Y(x[je])&&(Ee=je);return{prev:ae,next:oe}},Oe=Me(t,x=>(x.nodeType===1||x.kind==="text"&&Hn.test(x.value))&&q(x)),Re=Me(y.units,x=>(x.nodeType===1||x.kind==="text"&&Hn.test(x.value))&&w.has(y.baseOf(x))),ie=new Map,xe=(x,Y,ae,oe)=>{if(x>Y||ae>oe)return;let Ee=`${x}:${Y}:${ae}:${oe}`;ie.set(Ee,[x,Y,ae,oe])};for(let x=0;x<y.units.length;x++){let Y=y.units[x];if(y.baseOf(Y)||!s(Y))continue;let ae=Re.prev[x],oe=Re.next[x],Ee=ae<0?0:c.get(y.baseOf(y.units[ae])),je=oe===y.units.length?t.length-1:c.get(y.baseOf(y.units[oe]));xe(Ee,je,Math.max(0,ae),Math.min(y.units.length-1,oe))}for(let x=0;x<t.length;x++){let Y=t[x];if(f.has(Y)||!s(Y))continue;if(!y.twin(Y)){let tt=Oe.prev[x],Xe=Oe.next[x],dt=tt<0?0:H.get(q(t[tt])),Ge=Xe===t.length?y.units.length-1:H.get(q(t[Xe]));xe(Math.max(0,tt),Math.min(t.length-1,Xe),dt,Ge)}let ae=q(Y);if(!ae||k.identical.has(Y)||!s(ae))continue;let oe=x+1;for(;oe<t.length&&t[oe].kind==="text"&&!t[oe].value.trim();)oe++;if(oe>=t.length||!s(t[oe]))continue;let Ee=q(t[oe]);if(!Ee||k.identical.has(t[oe])||!s(Ee))continue;let je=H.get(ae),Ne=H.get(Ee);je<Ne&&xe(x,oe,je,Ne)}let qe=Array.from(ie.values()),fe=new Set;if(qe.length>1){let x=zt(d);try{S(x,qe.length*4);let Y=qe.slice().sort((Ee,je)=>(S(x,1),Ee[0]-je[0]||Ee[2]-je[2])),ae=[],oe=null;for(let Ee of Y)S(x,1),oe&&Ee[0]<=oe[1]&&Ee[2]<=oe[3]&&Ee[3]>=oe[2]?(oe[1]=Math.max(oe[1],Ee[1]),oe[2]=Math.min(oe[2],Ee[2]),oe[3]=Math.max(oe[3],Ee[3]),oe[4].push(Ee)):(oe?.[4].length>1&&ae.push(oe),oe=[Ee[0],Ee[1],Ee[2],Ee[3],[Ee]]);oe?.[4].length>1&&ae.push(oe),qe=ae.concat(qe)}catch(Y){if(Y!==B)throw Y}}for(let x of qe){if(fe.has(x))continue;let[Y,ae,oe,Ee,je]=x,Ne=zt(d),tt=[],Xe=new Set,dt=!1;try{S(Ne,(ae-Y+Ee-oe+2)*4);let Ge=t.slice(Y,ae+1).filter(U=>!k.identical.has(U)&&s(U)&&!f.has(U)),st=y.units.slice(oe,Ee+1).filter(U=>s(U)&&(!y.baseOf(U)||w.has(y.baseOf(U)))&&!k.identical.has(y.baseOf(U))&&!f.has(y.baseOf(U))),Ot=new Set(st),Ct=!1,yt="",Nt="",Lt=0;for(let U of Ge){let de=T(U,null,Ne);yt+=de.flat.text,Lt+=de.flat.text.length}for(let U of st){let de=T(U,k,Ne);Nt+=de.flat.text,Lt+=de.flat.text.length}S(Ne,Lt);let qt=E(yt),cn=E(Nt),It=qt===cn;if(dt=It,je&&!It)continue;let $t=It?null:new Map;if($t)for(let U of Ge.concat(st)){let de=p.get(U).flat.text.length;S(Ne,de*16),$t.set(U,new Uint8Array(de))}let wn=U=>{let de=[];for(let we of U){let le=p.get(we);le.flat.atoms.length?de.push(...M(le,Ne)):de.push({unit:we,raw:le.flat.text,from:0})}return de},jt=[];for(let U of It?[]:Ge){let de=q(U);if(!Ot.has(de))continue;let we=T(U,null,Ne),le=T(de,k,Ne);S(Ne,we.flat.text.length+le.flat.text.length);let Ae=we.flat.text&&le.flat.text.startsWith(we.flat.text)?0:we.flat.text&&le.flat.text.endsWith(we.flat.text)?le.flat.text.length-we.flat.text.length:-1;if(Ae>=0&&L(we,le,Ae,we.flat.text.length,Ne)){$t.get(U).fill(1),$t.get(de).fill(1,Ae,Ae+we.flat.text.length),A(jt,U,de,0,we.flat.text.length,Ae,Ne);continue}let W=N(M(we,Ne),M(le,Ne),Ne);if(!W){Ct=!0;break}for(let[X,pe]of W)$t.get(U).fill(1,X.from,X.to),$t.get(de).fill(1,pe.from,pe.to),A(jt,U,de,X.from,X.to,pe.from,Ne)}if(Ct)continue;let rn=null,Gt=null;if(!It)for(let U of Ge){let de=q(U),we=p.get(U);if(!de||we.flat.atoms.length||!Ot.has(de))continue;let le=we.flat.text,Ae=$t.get(U);S(Ne,le.length*3+st.length);let W=-1,X=-1,pe=!1;for(let Pe=0;Pe<le.length;Pe++)gn.test(le[Pe])||(Ae[Pe]?pe=!0:(W<0&&(W=Pe),X=Pe+1));if(!pe||W<0)continue;let be=!0;for(let Pe=W;Pe<X;Pe++)if(Ae[Pe]&&!gn.test(le[Pe])){be=!1;break}if(!be)continue;let he=E(le.slice(W,X)),ee=null,te=!1;for(let Pe of st){if(y.baseOf(Pe))continue;let ve=p.get(Pe);if(!ve.flat.atoms.length&&(S(Ne,ve.flat.text.length),E(ve.flat.text)===he)){if(ee){te=!0;break}ee=Pe}}if(te){(Gt||=new Set).add(U);continue}if(!ee||Gt?.has(U))continue;let z=!1;for(let Pe of Ge){if(Pe===U||!Ot.has(q(Pe)))continue;let ve=p.get(Pe);if(ve.flat.atoms.length)continue;let _e=$t.get(Pe);S(Ne,ve.flat.text.length*3);let Je="",Ze=!1;for(let Ut=0;Ut<ve.flat.text.length;Ut++)gn.test(ve.flat.text[Ut])||(_e[Ut]?Ze=!0:Je+=ve.flat.text[Ut]);Ze&&Je===he&&(Gt||=new Set,Gt.add(U),Gt.add(Pe),z=!0)}if(z)continue;let ne=p.get(ee).flat.text;S(Ne,X-W+ne.length);let Te=W,Ce=0;for(;Te<X&&Ce<ne.length;){for(;Te<X&&gn.test(le[Te]);)Te++;for(;Ce<ne.length&&gn.test(ne[Ce]);)Ce++;if(Te>=X||Ce>=ne.length)break;A(rn||=[],U,ee,Te,Te+1,Ce,Ne),Te++,Ce++}Ae.fill(1,W,X),$t.get(ee).fill(1)}let fn=U=>{let de=[];for(let we of U){let le=T(we,w.has(we)?null:k,Ne),Ae=$t.get(we);for(let W of M(le,Ne)){let X=W.from;for(;X<W.to;){for(;X<W.to&&Ae[X];)X++;let pe=X;for(;X<W.to&&!Ae[X];)X++;if(X>pe){let be=le.flat.text.slice(pe,X);Hn.test(be)&&de.push({...W,raw:be,len:X-pe,k:W.atom?W.k:be,from:pe,to:X})}}}}return de},$=It?wn(Ge):fn(Ge),l=It?wn(st):fn(st),O=It?qt:$.map(U=>E(U.raw)).join(""),R=It?cn:l.map(U=>E(U.raw)).join("");if((!O||!R)&&!rn)continue;let K=rn||[];if(O&&R&&O===R){let U=0,de=0,we=0,le=0;for(;U<$.length&&de<l.length;){let Ae=$[U],W=l[de];for(;we<Ae.raw.length&&gn.test(Ae.raw[we]);)we++;for(;le<W.raw.length&&gn.test(W.raw[le]);)le++;if(we===Ae.raw.length){U++,we=0;continue}if(le===W.raw.length){de++,le=0;continue}if((Ae.atom||W.atom)&&Ae.k!==W.k){Ct=!0;break}A(K,Ae.unit,W.unit,Ae.from+we,Ae.from+we+1,W.from+le,Ne),we++,le++}}else if(O&&R){let U=N($,l,Ne);if(!U)continue;for(let[de,we]of U)A(K,de.unit,we.unit,de.from,de.to,we.from,Ne)}if(Ct)continue;let Z=new Map;for(let U of K)if(!Gt?.has(U.source)){if(q(U.source)===U.target){It&&jt.push(U);continue}Z.has(U.source)||Z.set(U.source,[]),Z.get(U.source).push(U)}for(let[U,de]of Z){let we=T(U,null,Ne),le=q(U),Ae=we.flat.text,W=[],X=new Set,pe=n[1-D],be=pe.V.twin(U),he=be&&pe.V.here(be)?T(be,pe.A,Ne):null,ee=(ve,_e)=>{let Je=M(ve,Ne),Ze=M(_e,Ne);return S(Ne,ve.flat.text.length+_e.flat.text.length+Je.length+Ze.length),ve.flat.text===_e.flat.text&&Je.length===Ze.length&&Je.every((Ut,Pt)=>Ut.k===Ze[Pt].k)},te=le&&he&&he.flat.text!==Ae&&ee(T(le,k,Ne),he);for(let ve of new Set(de.map(_e=>_e.target))){if(U.nodeType!==1&&ve.nodeType!==1)continue;let _e=T(ve,k,Ne),Je=y.baseOf(ve);if(U.nodeType!==1&&Je||(S(Ne,Ae.length*2+_e.flat.text.length*3+jt.length*2),le&&E(Ae)===E(_e.flat.text)&&T(le,k,Ne).flat.text.trim()))continue;if(!le&&!Je&&U.nodeType===1&&ve.nodeType===1){let G=r(U),re=J(ve);if(G&&re&&G!==re)continue}let Ze=_e.flat.text,Ut=Ae&&(Ze.startsWith(Ae)||Ze.endsWith(Ae)),Pt=!1;if(!le&&he&&Je&&he.flat.text!==Ae){let G=T(Je,null,Ne).flat.text,re=c.get(U)<c.get(Je)?he.flat.text:G,ge=c.get(U)<c.get(Je)?G:he.flat.text;S(Ne,re.length+ge.length+Ze.length),Pt=!!re&&!!ge&&re.length+ge.length<=Ze.length&&Ze.startsWith(re)&&Ze.endsWith(ge)&&!Ze.slice(re.length,Ze.length-ge.length).trim()}let C=!we.flat.atoms.length&&!he?.flat.atoms.length&&!_e.flat.atoms.length&&(te&&Ut||Pt);if(le&&Je){let G=T(le,k,Ne).flat.text,re=Ae.startsWith(G)||Ae.endsWith(G),ge=T(Je,null,Ne).flat.text,ye=_e.flat.text,ce=ye.startsWith(ge)||ye.endsWith(ge),se=!n[1-D].V.twin(Je)&&!jt.some(Ie=>Ie.source===Je&&Hn.test(ge.slice(Ie.from,Ie.to)));if(!It&&(!re&&!C||!ce&&!se)){let Ie=ul(U,ve,de,Ge,st,p,$t,M,S,Ne);if(!Ie)continue;let Be=k.weak?.has(U)&&!k.identityPaired?.has(U)&&Ae.trim()===Ie;if(!re&&!C&&!Be)continue;let He=k.weak?.has(Je)&&!k.identityPaired?.has(Je)&&Ze.trim()===Ie&&!p.get(Je).flat.atoms.length&&!jt.some(Ke=>Ke.source===Je&&Hn.test(ge.slice(Ke.from,Ke.to)));if(!ce&&!se&&!He&&!dl(Je,ve,ge,Ze,jt,M(_e,Ne),S,Ne))continue;Be&&X.add(ve)}}C&&X.add(ve),S(Ne,de.length),W.push(...de.filter(G=>G.target===ve))}if(!W.length)continue;let z=new Uint8Array(Ae.length);S(Ne,Ae.length*4+jt.length);for(let ve of W)z.fill(1,ve.from,ve.to);let ne=[];for(let ve=0;ve<Ae.length;ve++)gn.test(Ae[ve])||ne.push(ve);if(!ne.length)continue;let Te=new Set(W.map(ve=>ve.target));if(!It&&le&&Te.size>1&&cl(Te,K,jt,y,p,Ne,S)){if(g||=new Map,g.set(U,(g.get(U)||0)|1<<D),e){let ve=ws({source:U,side:D,views:n,eligible:s,blocked:f,baseId:r,model:T,tokensOf:M,budget:Ne,charge:S});if(ve){S(Ne,ve.to-ve.from);let _e=!0;for(let Je=ve.from;Je<ve.to;Je++)if(Hn.test(Ae[Je])&&!z[Je]){_e=!1;break}_e&&(v||=[]).push(ve)}}continue}let Ce=ne.filter(ve=>Os.test(Ae[ve]));if(!W.some(ve=>Os.test(Ae.slice(ve.from,ve.to)))&&!ne.every(ve=>z[ve]))continue;if(!le&&!Array.from(Te).some(ve=>X.has(ve))&&!ne.every(ve=>z[ve])&&!(Ce.length&&z[Ce[0]]&&z[Ce[Ce.length-1]]&&Te.size===1)){let ve=null,_e=0,Je=0,Ze=null,Ut=null;if(!le&&he&&U.nodeType===1&&!we.flat.atoms.length){let Pt=M(we,Ne).filter(C=>Os.test(C.raw));S(Ne,st.length+Ae.length);for(let C of st){let G=y.baseOf(C);if(!G||G===U||G.nodeType!==1||C.nodeType!==1||G.tagName!==U.tagName||C.tagName!==G.tagName)continue;let re=c.get(U),ge=c.get(G),ye=!0;for(let ht=Math.min(re,ge)+1;ht<Math.max(re,ge);ht++){let Kt=t[ht];if(S(Ne,Kt.nodeType===1?1:Kt.value.length+1),Kt.nodeType===1||Kt.value.trim()){ye=!1;break}}if(!ye)continue;let ce=T(G,null,Ne),se=T(C,k,Ne);if(ce.flat.atoms.length||se.flat.atoms.length)continue;let Ie=ce.flat.text,Be=se.flat.text;if(S(Ne,Ie.length+Be.length+Ae.length),!Ie||!Pt.length)continue;let He=0,Ke=Be.length;if(re<ge&&Be.endsWith(Ie))Ke-=Ie.length;else if(re>ge&&Be.startsWith(Ie))He=Ie.length;else continue;for(;He<Ke&&gn.test(Be[He]);)He++;for(;Ke>He&&gn.test(Be[Ke-1]);)Ke--;let pt=Be.slice(He,Ke);if(!(!pt||!(pt.startsWith(Pt[0].raw)||pt.endsWith(Pt[Pt.length-1].raw)))){if(ve){ve=null;break}ve=C,_e=He,Je=Ke,Ze=Pt[0],Ut=Pt[Pt.length-1]}}}if(S(Ne,W.length),!ve||!Te.has(ve)||!W.some(Pt=>Pt.target===ve&&(Pt.from<=Ze.from&&Pt.to>=Ze.to&&Pt.targetFrom+Ze.from-Pt.from===_e||Pt.from<=Ut.from&&Pt.to>=Ut.to&&Pt.targetFrom+Ut.to-Pt.from===Je)))continue}if(le&&!(ne.every(ve=>z[ve])&&(It||Array.from(Te).some(ve=>X.has(ve))))&&!jt.some(ve=>ve.source===U&&Hn.test(Ae.slice(ve.from,ve.to))))continue;let Pe=!1;if(It){S(Ne,jt.length+ne.length);for(let ve of jt)ve.source===U&&(S(Ne,ve.to-ve.from),z.fill(1,ve.from,ve.to));Pe=!0;for(let ve of ne)if(!z[ve]){Pe=!1;break}}for(let ve of Te){S(Ne,W.length);let _e=W.filter(Ze=>Ze.target===ve);tt.push({side:D,source:U,target:ve,runs:_e,models:p,retained:jt,conservedSource:Pe}),U.nodeType===1&&Xe.add(U),ve.nodeType===1&&Xe.add(ve);let Je=y.baseOf(ve);Je?.nodeType===1&&Xe.add(Je)}}if(m.push(...tt),je&&tt.length)for(let U of je)fe.add(U);for(let U of Xe)b.add(U)}catch(Ge){if(Ge!==B)throw Ge}finally{if(o&&!je&&!dt){let Ge=Pr({base:t,views:n,side:D,attempt:x,eligible:s,blocked:f,baseId:r,model:T,tokensOf:M,charge:S,exhausted:B,limit:d});Ge&&(I||=[]).push(...Ge)}if(e&&!je&&!dt){let Ge=zs({base:t,views:n,side:D,attempt:x,eligible:s,blocked:f,baseId:r,model:T,tokensOf:M,certificates:m,charge:S,exhausted:B,limit:d});Ge&&(v||=[]).push(...Ge)}}}}let V=m.length?new Map:null;for(let D of m){let y=V.get(D.source);y||V.set(D.source,y=[]),y.push(D)}let j=null;if(V){let D=null;for(let[y,k]of V){let J=g?.get(y)||0;if(k.length<2&&!J)continue;let H=0;for(let q of k)q.conservedSource&&(H|=1<<q.side);for(let q of k){if(q.conservedSource)continue;let Me=1<<q.side,Oe=!0;if(H&Me)Oe=!1;else if(J&Me){Oe=!1;try{Oe=fl(q,D||=zt(d),S)}catch(Re){if(Re!==B)throw Re}}Oe||(j||=new Set).add(q)}}}if(j){let D=0;for(let y of m)j.has(y)||(m[D++]=y);m.length=D;for(let[y,k]of V){D=0;for(let J of k)j.has(J)||(k[D++]=J);k.length=D,D||V.delete(y)}b.clear();for(let y of m){let{source:k,target:J,side:H}=y;k.nodeType===1&&b.add(k),J.nodeType===1&&b.add(J);let q=n[H].V.baseOf(J);q?.nodeType===1&&b.add(q)}}if(v){let D=zt(d),y=!1;for(let k of v){let J=!1,H=V?.get(k.source);if(H&&!y)try{J=bs(k,H,D,S)}catch(q){if(q!==B)throw q;y=!0}J||e(k)}}if(I){let D=new Set,y=zt(d);try{for(let k of I){if(S(y,1),D.has(k.source))continue;D.add(k.source);let J=!1;for(let H of m)if(S(y,1),H.source===k.source||H.target===k.local||H.target===k.remote){J=!0;break}J||o(k)}}catch(k){if(k!==B)throw k}}for(let D of t)if(b.has(D))for(let{V:y}of n){let k=y.twin(D);k&&y.here(k)&&b.add(k)}return m.length?{blocks:b,certificates:m,certificatesBySource:V,models:p}:null}function jr({certificates:e,scopes:o,flats:t,keys:n,limit:s=2e4*32}){let h=Symbol(),i=zt(s),r=g=>{if(g>i.remaining)throw h;i.remaining-=g},a=o.map(g=>new Set(g)),d=new Map,w=new Map,c=(g,f)=>{let b=d.get(g);if(b||d.set(g,b=new Map),b.has(f))return b.get(f);r(g.text.length);let B=w.get(f);if(!B){r(f.nodes.length+f.atoms.length),B={nodes:new Map,atoms:new Map};for(let L of f.nodes)B.nodes.set(L.node,L);for(let L of f.atoms)B.atoms.set(L.el,L.i);w.set(f,B)}let{nodes:S,atoms:T}=B,M=new Int32Array(g.text.length).fill(-1);for(let L of g.nodes){let N=S.get(L.node);if(!(!N||L.e-L.s!==N.e-N.s)){r(L.e-L.s);for(let A=L.s;A<L.e;A++)M[A]=N.s+A-L.s}}for(let L of g.atoms){let N=T.get(L.el);N!==void 0&&(M[L.i]=N)}return b.set(f,M),M},p=(g,f,b,B,S)=>{let T=g[g.length-1];T&&T.to===f&&T.target+T.to-T.from===B&&T.kind===S?T.to=b:g.push({from:f,to:b,target:B,kind:S})},m=(g,f,b,B)=>{r((B-b)*4);let S=[],T=b,M=A=>{let E=g.text.slice(T,A);for(let V of an(E,xn(E)))V.from=T,V.to=T+V.len,S.push(V),T+=V.len},L=0,N=g.atoms.length;for(;L<N;){r(1);let A=L+N>>>1;g.atoms[A].i<b?L=A+1:N=A}for(let A=L;A<g.atoms.length&&g.atoms[A].i<B;A++){r(1);let E=g.atoms[A];M(E.i),S.push({k:f(E),raw:Un,len:1,from:T,to:T+1}),T++}return M(B),S},v=(g,f,b,B,S,T)=>{if(b===B||S===T)return;if(B-b===T-S){r((B-b)*4);let y=!0;for(let k=b,J=S;k<B;k++,J++){if(t[0].text[k]!==t[f].text[J]){y=!1;break}let H=t[0].atomAt.get(k),q=t[f].atomAt.get(J);if(!!H!=!!q||H&&n[0](H)!==n[f](q)){y=!1;break}}if(y){p(g,b,B,S,"retained");return}}let M=m(t[0],n[0],b,B),L=m(t[f],n[f],S,T),N=M.length+L.length+4,A=Math.min(M.length+L.length,4e3,Math.floor((Math.sqrt(N*N+i.remaining/2)-N)/2));if(A<1)throw h;r(4*(A+1)*(N+A+1));let E=Wn(M,L,A),V=0,j=0,D=()=>{let y=M[V++],k=L[j++];r(y.len),y.raw===k.raw&&p(g,y.from,y.to,k.from,"retained")};for(let y of E.hunks){for(;V<y.bs;)D();V=y.be,j+=y.toks.length}for(;V<M.length&&j<L.length;)D()},I=g=>{let f=e.filter(E=>E.side===g-1&&a[0].has(E.source)&&a[g].has(E.target));if(!f.length)return null;let b=[],B=(E,V,j)=>{if(!a[0].has(E.source)||!a[g].has(E.target))return;let D=c(V.get(E.source).flat,t[0]),y=c(V.get(E.target).flat,t[g]);r(E.to-E.from);for(let k=0;k<E.to-E.from;k++){let J=D[E.from+k],H=y[E.targetFrom+k];if(J<0||H<0)throw h;p(b,J,J+1,H,j)}},S=new Set;for(let E of f){if(!S.has(E.retained)){S.add(E.retained);for(let V of E.retained)B(V,E.models,"retained")}for(let V of E.runs)B(V,E.models,"transfer")}b.sort((E,V)=>(r(1),E.from-V.from||E.target-V.target));let T=[];for(let E of b){r(1);let V=T[T.length-1];if(V&&E.from<V.to){if(E.target-E.from!==V.target-V.from)throw h;V.to=Math.max(V.to,E.to),E.kind==="transfer"&&(V.kind="transfer")}else T.push(E)}let M=[],L=0,N=0;for(let E of T){if(E.target<N)throw h;v(M,g,L,E.from,N,E.target),M.push(E),L=E.to,N=E.target+E.to-E.from}v(M,g,L,t[0].text.length,N,t[g].text.length);let A=jn({base:t[0],side:t[g],retained:M.filter(E=>E.kind==="retained"),transfers:M.filter(E=>E.kind==="transfer"),baseAtomKey:n[0],sideAtomKey:n[g],budget:i});if(A.status!=="ready"||!A.monotone)throw h;return A};try{let g=I(1),f=I(2);return g||f?{local:g,remote:f}:{fallback:!0}}catch(g){if(g!==h)throw g;return{fallback:!0}}}function Is(e,o,t=!1){let n=-1,s=-1;for(let i=0;i<e.list.length;i++){let r=e.list[i];r.bLo<o.lo||r.bLo>o.hi||(n<0&&(n=i),s=i)}let h=[];for(let i=n;i>=0&&i<=s;i++){let r=e.list[i],a=!t&&i===n?r.inlineStart<0?r.to:r.inlineStart:r.from,d=!t&&i===s?r.inlineEnd<0?r.from:r.inlineEnd:r.to;for(let w=a;w<d;w++)h.push(e.units[w]);i<s&&h.push(e.units[r.next])}return h}var rt=e=>!!e&&e.nodeType===1,Ln=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function Cs(e){for(let o of e)if(Ln.has(o.tagName))return!0;return!1}function hl(e,o,t){let n=null;for(let s of o.childNodes)if(!(!rt(s)||!t(s)||!s.isEqualNode(e))){if(n)return null;n=s}if(!n)return null;for(let s of e.parentNode.childNodes)if(s!==e&&s.isEqualNode(e))return null;return n}var Co="[id],[data-id],script,head>*";function Ls(e,o){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let n=ho(t,e);if(n)return"merge:"+n.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?br(t,o):null}}function Jo(e,o,t,n){let s=n.ignored,h=n.stats||zn(),i=Ws({ignored:s,ignoreAttribute:n.ignoreAttribute,stats:h}),{unitsOf:r,meta:a}=i,d=n.baseURI,w=n.mergeTags!==null,c=Ls(n.mergeTags,d),p=C=>G=>{let re=c(G);return re!==null?re:C(G)},m=p(n.identity.base),v=p(n.identity.local),I=p(n.identity.remote),g=n.authored||n.identity,f=C=>C&&C.nodeType===9?C.documentElement:C,b=f(e),B=f(o),S=f(t),T=globalThis.__hyperMorphProfile,M=T?performance.now():0,L=C=>C===kn?Co:null,N=n.scope||null,A=N?N.baseDropped:new Set,E=new Set,V=N?N.remoteDropped:new Set,j=N?N.baseIndex:Uo(b,m,s,L(n.identity.base),A),D=n.localIsBase||b===B?null:Uo(B,v,s,L(n.identity.local),E),y=N?N.remoteIndex:Uo(S,I,s,L(n.identity.remote),V),k=C=>{let G=rt(C)&&v(C);return G&&D?.get(G)===C&&!j.has(G)?G:null},J=C=>{let G=rt(C)&&I(C);return G&&y.get(G)===C&&!j.has(G)?G:null},H=D?as(b,B,{analyzer:i,baseIndex:j,sideIndex:D,baseId:g.base,sideId:g.local,baseKey:m,sideKey:v,baseDropped:A,sideDropped:E,stats:h}):Vr(),q=as(b,S,{analyzer:i,baseIndex:j,sideIndex:y,baseId:g.base,sideId:g.remote,baseKey:m,sideKey:I,baseDropped:A,sideDropped:V,stats:h,scope:N,comparisons:n.comparisons});if(N){if(!N.held(q))return null;for(let C of N.dropped)is(C)}let Me=null;function Oe(C){if(!Me){Me=new WeakMap;let G=[b];for(;G.length;){let re=G.pop();re.tagName==="TEMPLATE"&&re.content&&Me.set(re.content,re);for(let ge of i.childrenOf(re))ge.nodeType===1&&G.push(ge)}}return Me.get(C)||null}let Re=C=>{let G=rt(C)||C.nodeType?C.parentNode:C.parent;return G&&G.nodeType===11?Oe(G):G};if(q.moved.size){let C=!1;for(let G of Array.from(q.moved))!rt(G)||q.identityPaired.has(G)||!g.base(G)||l(q,Re(G))||(q.unpair(G),C=!0);C&&q.rematch()}fn(),$(H,q),$(q,H);for(let C of[H,q])if(C.refused)for(let G of C.refused)C.moved.has(G)||h.ambiguousMoves++;T&&(T.alignTotal=(T.alignTotal||0)+(performance.now()-M),M=performance.now());let ie=b.ownerDocument.implementation.createHTMLDocument(""),xe=new WeakMap,qe=new WeakMap,fe=[],x=[],Y=new Set,ae=[],oe=new Set,Ee=new Set,je=new Set,Ne=new WeakMap,tt=null,Xe=n.lineage?.locals.length?rr():null,dt=C=>{let G=Ko(C);return G&&Xe&&Xe.consume(C.local),G},Ge=n.conflicts||"remote",st=C=>fe.push(C),Ot=C=>fe.push(C),Ct=Or({roots:{base:b,local:B,remote:S},L:H,R:q,unitsOf:r,provenance:xe,policy:Ge}),yt=(C,G)=>{x.push(C),G&&Ct.note(C,G)},Nt=null,Lt=null,qt=rn(),cn=null,It=U(b,H.map.get(b),q.map.get(b),!!n.localIsBase,!!n.childrenOnly);It.tagName==="HTML"?ie.replaceChild(It,ie.documentElement):ie.body.appendChild(It),Nt?.drain(It),Lt?.drain(It),T&&(T.build=(T.build||0)+(performance.now()-M));let $t=n.childrenOnly?!Pe(Te(It),Te(S)):!te(It,S),wn=Ct.finish(It),jt=Xe?ir({locals:n.lineage.locals,rec:Xe,root:It,provenance:xe,segments:ae,ignored:s}):null;return{doc:ie,root:It,provenance:xe,textMappers:qe,decisions:fe,conflicts:x,recoveryLinks:wn,localDiverged:$t,mergedScripts:Y,segments:ae,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==kn,L:H,R:q,stats:h,lineage:jt};function rn(){let C=new Map,G=new Set;if(n.localIsBase||!H.insertedByHash)return{partner:C,drop:G};let re=H.insertedByHash(),ge=q.insertedByHash();if(!re.size||!ge.size)return{partner:C,drop:G};let ye={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ce=it=>{let $e=0;for(let vt=it.parentNode;vt;vt=vt.parentNode)$e++;return $e},se=[],Ie=it=>{let $e=it.textContent.trim();return $e.split(/\s+/).length>=3||$e.replace(/\s/g,"").length>=12},Be=it=>{let $e=l(H,it),vt=l(q,it);return $e&&H.reverse.get($e.parentNode)!==it.parentNode||vt&&q.reverse.get(vt.parentNode)!==it.parentNode},He=(it,$e,vt)=>{for(let Dt of vt.parentNode.children){let bn=Dt!==vt&&it.reverse.get(Dt);if(bn&&Be(bn))return!0}let at=it.reverse.get(vt.parentNode);if(at){for(let Dt of at.children)if(!l($e,Dt)&&!s(Dt))return!0}return!1},Ke=new Map([[H,new Map],[q,new Map]]),pt=(it,$e)=>{let vt=Ke.get(it),at=vt.get($e);if(at===void 0){at=!1;for(let Dt of $e.children)if(it.reverse.has(Dt)||pt(it,Dt)){at=!0;break}vt.set($e,at)}return at},ht=new Map;for(let it of ge.values())for(let $e of it){let vt=J($e);vt&&ht.set(vt,$e)}for(let it of re.values())for(let $e of it){let vt=k($e),at=vt?ht.get(vt):null;at&&at.tagName===$e.tagName&&!Vn($e,ye)&&!Vn(at,ye)&&!n.remoteWins($e)&&!n.remoteWins(at)&&se.push([$e,[at],ce($e),!0,!0])}for(let[it,$e]of re){let vt=ge.get(it);if(!vt)continue;let at=$e.length===1&&vt.length===1;for(let Dt of $e)!Vn(Dt,ye)&&!k(Dt)&&se.push([Dt,vt,ce(Dt),at&&(Ie(Dt)||He(H,q,Dt)||He(q,H,vt[0]))])}if(!se.length)return{partner:C,drop:G};se.sort((it,$e)=>it[2]-$e[2]);let Kt=new Set,Ht=new Set,un=it=>{for(let $e of it.querySelectorAll("*"))Kt.add($e)},bt=(it,$e)=>it.reverse.get($e.parentNode)||null;for(let[it,$e,,vt,at]of se){if(Kt.has(it)||Ht.has(it)||at&&(pt(H,it)||pt(q,$e[0])))continue;let Dt=bt(H,it),bn=Yt=>!Ht.has(Yt)&&!Kt.has(Yt)&&(at||Yt.tagName===it.tagName&&!J(Yt)&&i.equalUnits(it,Yt)),on=$e.find(Yt=>Dt&&bt(q,Yt)===Dt&&bn(Yt))||(vt?$e.find(bn):null);if(!on)continue;Ht.add(it),Ht.add(on);let hn=Dt&&bt(q,on)===Dt;(!at||!hn||i.equalUnits(it,on))&&(un(it),un(on)),!hn&&(C.set(it,on),C.set(on,it),G.add(Ge==="local"?on:it))}return{partner:C,drop:G}}function Gt(C,G,re){if(oe.add(C),qt.drop.has(C))return null;oe.add(re);let ge=G==="local"?C:re,ye=G==="local"?re:C,ce;return i.equalUnits(ge,ye)?(ce=he(ge,"local",!0),xe.get(ce).remote=ye):ce=be(ge,ye),yt({kind:"structure",el:ce,detail:"both-moved",base:null,local:ge,remote:ye},{unit:{b:null,l:ge,r:ye}}),st({kind:"insert",el:ce,source:"both"}),ce}function fn(){if(!H.weak||!q.weak||!H.weak.size||!q.weak.size||!H.unpair)return;let C=new Map;for(let re of H.weak){let ge=l(H,re);rt(re)&&rt(ge)&&C.set(i.unitHash(ge),re)}let G=!1;for(let re of Array.from(q.weak)){let ge=l(q,re);if(!rt(re)||!rt(ge))continue;let ye=C.get(i.unitHash(ge));if(!ye||ye===re||!H.weak.has(ye)||l(H,re)&&l(q,ye))continue;let ce=l(H,ye);ce.tagName===ge.tagName&&i.equalUnits(ce,ge)&&(H.unpair(ye),q.unpair(re),G=!0)}G&&(H.rematch(),q.rematch())}function $(C,G){if(!C.weak||!C.weak.size||!G.insertedByHash)return;let re=G.insertedByHash();if(!re.size)return;let ge=!1;for(let ye of Array.from(C.weak)){let ce=l(C,ye);if(!ce)continue;let se=C===H?k(ce):J(ce);if(se){let Be=(C===H?y:D)?.get(se);Be&&Be.tagName===ce.tagName&&!G.reverse.has(Be)&&(C.unpair(ye),ge=!0);continue}let Ie=re.get(i.unitHash(ce));Ie&&Ie.some(Be=>Be.tagName===ce.tagName&&i.equalUnits(Be,ce))&&(C.unpair(ye),ge=!0)}ge&&C.rematch()}function l(C,G){if(!G)return null;if(C.map.has(G))return C.map.get(G);let re=[],ge=Re(G);for(;ge&&!C.map.has(ge);ge=Re(ge))re.push(ge);let ye=ge;if(!ye||!C.identical.has(ye))return null;C.pairIdenticalChildren(ye);for(let se=re.length-1;se>=0;se--)C.pairIdenticalChildren(re[se]);let ce=C.map.get(G)||null;return ce&&h.lazyTwins++,ce}function O(C,G,re,ge){if(rt(C)&&Ln.has(C.tagName)&&!H.identical.has(C)&&(C.previousSibling?.nodeType===3||C.nextSibling?.nodeType===3)){let Ie=Re(C),Be=l(H,C),He=l(q,C);Be&&He&&Ut(Be,l(H,Ie),H)&&!Ut(He,l(q,Ie),q)&&(Lt||=Lr({L:H,R:q,twinIn:l,unitsOf:r,view:R,parentOf:Re,ignored:s,remoteWins:n.remoteWins,eligible:Ke=>rt(Ke)&&Ln.has(Ke.tagName),build:U,out:ie,policy:Ge,provenance:xe,textMappers:qe,segments:ae,conflicts:x,conflict:yt,decisions:fe}),Lt.ensureOwner(C))}if(G===null)return null;if(ge!==void 0)return Nt||=go(xe,Re,H,q,l,U,s,n.remoteWins,x,yt,K,B,S),Nt.plan(C,G,re,!!ge),ge&&(Nt.produced(C,ge),Ee.add(C)),ge;if(Ee.has(C)||je.has(C))return yt({kind:"structure",el:null,detail:"both-moved",base:C},{subject:C}),Ee.has(C)?null:he(re,G);Nt||=go(xe,Re,H,q,l,U,s,n.remoteWins,x,yt,K,B,S),Nt.plan(C,G,re,!0);let ye=l(H,C),ce=l(q,C);(!ye||!ce)&&yt({kind:"structure",el:null,detail:"move-beats-delete",base:C},{subject:C,deleted:ye?"remote":"local"});let se=U(C,ye,ce,!1);return(G==="local"?st:Ot)({kind:"move",el:se,source:G}),se}function R(C,G,re,ge){return ge||!G||G===re?{el:re,asBase:!0,twin:ye=>ye,baseOf:ye=>ye,units:r(re),here:()=>!0,parentOfTwin:()=>re}:{el:G,asBase:!1,twin:ye=>l(C,ye),baseOf:ye=>C.reverse.get(ye),units:r(G),here:ye=>rt(ye)?ye.parentNode===G||G.tagName==="TEMPLATE"&&ye.parentNode===G.content:ye.parent===G||G.tagName==="TEMPLATE"&&ye.parent===G.content}}function K(C,G,re){return!G||re&&re.identical.has(C)?!1:rt(C)?!i.equalUnits(C,G)||!Z(C,G,re):C.value!==G.value}function Z(C,G,re){if(!re||C===G)return!0;let ge=[[C,G]];for(;ge.length;){let[ye,ce]=ge.pop(),se=r(ye),Ie=r(ce);for(let Be=0;Be<se.length&&Be<Ie.length;Be++){let He=se[Be],Ke=Ie[Be];if(!rt(He)||!rt(Ke))continue;let pt=re.map.get(He);if(pt!==void 0&&pt!==Ke)return!1;let ht=re.reverse.get(Ke);if(ht!==void 0&&ht!==He)return!1;ge.push([He,Ke])}}return!0}function U(C,G,re,ge,ye=!1){let ce=ge||(re?n.remoteWins(re):n.remoteWins(C)),se=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(C.namespaceURI,C.tagName):ie.createElement(C.tagName),Ie={base:C,local:G||null,remote:re||null};if(xe.set(se,Ie),ce&&!ge&&G&&K(C,G,H)&&(!re||!i.equalUnits(G,re))&&yt({kind:"structure",el:se,detail:"remote-wins",base:C,local:G,remote:re||null},{subject:C}),oe.add(C),Ee.add(C),G&&oe.add(G),re&&oe.add(re),n.skipUnchanged&&!ye&&(n.localIsBase||H.identical.has(C))&&re&&q.identical.has(C)&&!n.remoteWins(C)){Ie.unchanged=!0;for(let He of C.attributes)He.namespaceURI?se.setAttributeNS(He.namespaceURI,He.name,He.value):se.setAttribute(He.name,He.value);return Nt?.produced(C,se),se}je.add(C),ye||le(C,ce?C:G,re,se);let Be=C.tagName;if(pn(C))we(C,ce?C:G,re,se);else if(Be==="TEXTAREA")se.textContent=de(C.textContent,(ce?C:G)?(ce?C:G).textContent:C.textContent,re?re.textContent:C.textContent,se,"text");else if(!Lt?.render(C,se)){let He=ee(C,G,re,ce,se),Ke=Be==="TEMPLATE"&&se.content?se.content:se;for(let pt of He)Ke.appendChild(pt)}return je.delete(C),Nt?.produced(C,se),se}function de(C,G,re,ge,ye){if(G===re)return G;if(G===C)return re!==C&&Ot({kind:ye,node:ge,source:"remote"}),re;if(re===C)return st({kind:ye,node:ge,source:"local"}),G;let ce=Ge==="local"?G:re;return yt({kind:ye,node:ge,base:C,local:G,remote:re,resolved:ce},{site:"whole",el:ge}),fe.push({kind:ye,node:ge,source:"both"}),ce}function we(C,G,re,ge){let ye=C.textContent,ce=G?G.textContent:ye,se=re?re.textContent:ye,Ie=w?ho(C,n.mergeTags,!0):null;if(Ie&&ce!==se){let Be=re&&re.getAttribute("merge-key")||C.getAttribute("merge-key"),{text:He,warnings:Ke}=Go(n.localIsBase?void 0:ye,ce,se,{parse:Ie.recognizer.parse,keyCandidates:Be?Be.split(/[\s,]+/).filter(Boolean):void 0});for(let pt of Ke)console.warn(`[hyper-morph] merge "${Ie.raw}": ${pt}`);ge.textContent=He,Y.add(ge),He!==se?st({kind:"text",node:ge,source:He===ce?"local":"both"}):He!==ye&&Ot({kind:"text",node:ge,source:"remote"});return}ge.textContent=de(ye,ce,se,ge,"text")}function le(C,G,re,ge){let ye=new Map;for(let ce of[C,G,re])if(ce)for(let se of ce.attributes)n.ignoreAttribute(ce,se.name)||ye.set(se.name,se);for(let[ce,se]of ye){let Ie=C?C.getAttribute(ce):null,Be=G?G.getAttribute(ce):Ie,He=re?re.getAttribute(ce):Ie,Ke;Be===He?Ke=Be:Be===Ie?(Ke=He,Ot({kind:"attr",el:ge,name:ce,source:"remote"})):He===Ie?(Ke=Be,st({kind:"attr",el:ge,name:ce,source:"local"})):(Ke=Ae(ce,Ie,Be,He),Ke===void 0&&(Ke=Ge==="local"?Be:He,yt({kind:"attr",el:ge,name:ce,base:Ie,local:Be,remote:He,resolved:Ke},{el:ge,sample:se})),fe.push({kind:"attr",el:ge,name:ce,source:"both"})),Ke!=null&&(se.namespaceURI?ge.setAttributeNS(se.namespaceURI,se.name,Ke):ge.setAttribute(ce,Ke))}}function Ae(C,G,re,ge){if(C==="class"){let ye=He=>new Set((He||"").split(/\s+/).filter(Boolean)),ce=ye(G),se=ye(re),Ie=ye(ge),Be=new Set;for(let He of new Set([...ce,...se,...Ie])){let Ke=ce.has(He),pt=se.has(He),ht=Ie.has(He);(pt===ht?pt:pt===Ke?ht:pt)&&Be.add(He)}return[...Be].join(" ")}if(C==="style"){let ye=Ke=>{let pt=new Map;if(!Ke)return pt;let ht=0,Kt=null,Ht="",un=()=>{let bt=Ht.indexOf(":");bt>0&&pt.set(Ht.slice(0,bt).trim(),Ht.slice(bt+1).trim()),Ht=""};for(let bt of Ke){if(Kt){Ht+=bt,bt===Kt&&(Kt=null);continue}if(bt==='"'||bt==="'"){Kt=bt,Ht+=bt;continue}if(bt==="("?ht++:bt===")"&&ht--,bt===";"&&ht===0){un();continue}Ht+=bt}return Ht.trim()&&un(),pt},ce=ye(G),se=ye(re),Ie=ye(ge),Be=new Map,He=!1;for(let Ke of new Set([...ce.keys(),...se.keys(),...Ie.keys()])){let pt=ce.get(Ke)??null,ht=se.get(Ke)??null,Kt=Ie.get(Ke)??null,Ht;ht===Kt?Ht=ht:ht===pt?Ht=Kt:Kt===pt?Ht=ht:(Ht=Ge==="local"?ht:Kt,He=!0),Ht!=null&&Be.set(Ke,Ht)}return He?void 0:[...Be].map(([Ke,pt])=>`${Ke}: ${pt}`).join("; ")}}function W(C,G,re,ge){let ye=C.value,ce=ge?ye:G?G.value:"",se=re?re.value:"";oe.add(C),G&&oe.add(G),re&&oe.add(re);let Ie=lo(ye,ce,se,Ge),Be=Ie.text===""?null:ie.createTextNode(Ie.text);Be&&(xe.set(Be,{base:C.nodes,local:G?G.nodes:null,remote:re?re.nodes:null}),qe.set(Be,Ie.mapLocalOffset)),ce!==ye&&se!==ye?fe.push({kind:"text",node:Be,source:"both"}):ce!==ye?st({kind:"text",node:Be,source:"local"}):se!==ye&&Ot({kind:"text",node:Be,source:"remote"});for(let He of Ie.conflicts)yt({kind:"text",node:Be,base:ye.slice(He.bs,He.be),local:He.local,remote:He.remote,resolved:He.resolved},{site:"run",bRun:C,lRun:G,rRun:re,node:Be,c:He});return Be}function X(C,G){return Gn(C,G).every(re=>re.bs===re.be)}function pe(C,G){let re=C?C.value:"",ge=G?G.value:"",ye;if(re===ge||!ge?ye=re:re?X(re,ge)?ye=ge:X(ge,re)?ye=re:(ye=Ge==="local"?re:Ge==="both"?re+ge:ge,yt({kind:"structure",el:null,detail:"insert-collision",local:re,remote:ge,resolved:ye},{unit:{b:null,l:C,r:G},localLost:Ge==="remote"})):ye=ge,C&&oe.add(C),G&&oe.add(G),ye==="")return null;let ce=ie.createTextNode(ye);return xe.set(ce,{base:null,local:C?C.nodes:null,remote:G?G.nodes:null}),re?st({kind:"insert",el:ce,source:ge&&re===ge?"both":"local"}):Ot({kind:"insert",el:ce,source:"remote"}),ce}function be(C,G){let re={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ge=Ie=>r(Ie).every(Be=>rt(Be)?Vn(Be,re):Be.kind==="text"),ye=null;if(ge(C)&&ge(G)){let Ie=C.textContent,Be=G.textContent;Ie===Be||X(Be,Ie)?ye=G:X(Ie,Be)&&(ye=C)}if(!ye){let Ie=Ge==="local",Be=he(Ie?C:G,Ie?"local":"remote",!0),He=xe.get(Be);return Ie?He.remote=G:He.local=C,yt({kind:"structure",el:Be,detail:"insert-collision",local:C,remote:G,resolved:Ie?C:G},{unit:{b:null,l:C,r:G},localLost:!Ie}),Be}let ce=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(C.namespaceURI,C.tagName):ie.createElement(C.tagName);le(null,C,G,ce),xe.set(ce,{base:null,local:C,remote:G}),oe.add(C),oe.add(G);let se=dt({base:Array.from(ye.childNodes),local:Array.from(C.childNodes),remote:Array.from(G.childNodes),out:ie,policy:Ge,idOf:{local:v,remote:I},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:xe,textMappers:qe,conflicts:x,conflict:yt,scope:{base:null,local:C,remote:G,units:[],at:0},synthetic:!0,decisions:fe,node:ce});ae.push(...se.segments);for(let Ie of se.nodes)ce.appendChild(Ie);return ce}function he(C,G,re=!1){if(!re&&rt(C)){let se=qt.partner.get(C);if(se)return Gt(C,G,se)}if(!rt(C)){if(C.value==="")return null;let se=C.kind==="comment"?ie.createComment(C.value):ie.createTextNode(C.value);return xe.set(se,{base:null,local:G==="local"?C.nodes:null,remote:G==="remote"?C.nodes:null}),oe.add(C),se}let ge=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(C.namespaceURI,C.tagName):ie.createElement(C.tagName);for(let se of C.attributes)se.namespaceURI?ge.setAttributeNS(se.namespaceURI,se.name,se.value):ge.setAttribute(se.name,se.value);xe.set(ge,{base:null,local:G==="local"?C:null,remote:G==="remote"?C:null}),oe.add(C);let ye=C.tagName==="TEMPLATE"&&ge.content?ge.content:ge,ce=G==="local"?H:q;for(let se of r(C)){let Ie=rt(se)?ce.reverse.get(se):null;if(Ie&&O(Ie,null,null),Ie&&Ee.has(Ie)){yt({kind:"structure",el:null,detail:"both-moved",base:Ie},{subject:Ie});continue}if(Ie&&!je.has(Ie)){let He=l(H,Ie)||null,Ke=l(q,Ie)||null;if(He||Ke){Nt||=go(xe,Re,H,q,l,U,s,n.remoteWins,x,yt,K,B,S),Nt.plan(Ie,G,se,!0);let pt=U(Ie,He,Ke,!1);G==="local"?st({kind:"move",el:pt,source:"local"}):Ot({kind:"move",el:pt,source:"remote"}),ye.appendChild(pt);continue}}let Be=he(se,G);Be&&ye.appendChild(Be)}if(!re&&qt.drop.size&&C.tagName==="DIV"&&!ye.firstChild&&!C.attributes.length&&!(G==="local"?v(C):I(C))&&!ce.reverse.has(C)&&!s(C)&&!n.remoteWins(C)){let se=C.firstChild;if(se&&se===C.lastChild&&rt(se)&&(qt.drop.has(se)||cn?.has(se)))return(cn||=new WeakSet).add(C),null}return ge}function ee(C,G,re,ge,ye){G&&H.identical.has(C)&&H.pairIdenticalChildren(C),re&&q.identical.has(C)&&q.pairIdenticalChildren(C);let ce=R(H,G,C,ge),se=R(q,re,C,!1),Ie=r(C),Be=new Set(Ie),He=new Map;for(let ue=0;ue<Ie.length;ue++)He.set(Ie[ue],ue);let Ke=[],pt=new Set,ht=new Map,Kt=new Set,Ht=Xe&&[],un=Xe&&[],bt=new Set,it=[],$e=null,vt=new Map;if(!ce.asBase&&!se.asBase&&!H.identical.has(C)&&!q.identical.has(C))for(let ue of Ie){if(!rt(ue)||!Ln.has(ue.tagName))continue;let We=ce.twin(ue),Ve=se.twin(ue);We&&Ve&&(!ce.here(We)||!se.here(Ve))&&O(ue,null,null)}vo();let at=ue=>{let We=[];for(let Ve of ue.units){if(bt.has(Ve))continue;let et=ue.baseOf(Ve);et&&Be.has(et)&&We.push(et)}return We},Dt=ue=>at(ue).map(We=>He.get(We)),bn=ue=>ue.every((We,Ve)=>Ve===0||We>=ue[Ve-1]),on=!ce.asBase&&!bn(Dt(ce)),hn=!se.asBase&&!bn(Dt(se));on&&hn&&yt({kind:"structure",el:ye,detail:"both-reordered",base:C},{subject:C,lKept:at(ce),rKept:at(se)});let Yt=hn||!on?{V:se,A:q,side:"remote",other:ce,otherA:H,otherSide:"local"}:{V:ce,A:H,side:"local",other:se,otherA:q,otherSide:"remote"};on?st({kind:"move",el:null,source:hn?"both":"local",base:C}):hn&&Ot({kind:"move",el:null,source:"remote",base:C});let En=ce.asBase?[]:ce.units.filter(ue=>!ce.baseOf(ue)&&!bt.has(ue)&&!qt.partner.has(ue)),oo=se.asBase?[]:se.units.filter(ue=>!se.baseOf(ue)&&!bt.has(ue)&&!qt.partner.has(ue)),Rn=new Map;if(En.length&&oo.length){let ue=new Map,We=new Map;for(let Fe of oo){if(rt(Fe)){let xt=I(Fe);xt&&ue.set(xt,Fe)}let ze=i.unitHash(Fe);We.has(ze)||We.set(ze,[]),We.get(ze).push(Fe)}let Ve=(Fe,ze)=>{let xt=Fe.units.indexOf(ze);for(let Ye=xt-1;Ye>=0;Ye--){let ot=Fe.baseOf(Fe.units[Ye]);if(ot)return ot}return"start"},et=new Map,wt=new Map;for(let Fe of oo){let ze=Ve(se,Fe);rt(Fe)?(wt.has(ze)||wt.set(ze,[]),wt.get(ze).push(Fe)):Fe.kind==="text"&&!et.has(ze)&&et.set(ze,Fe)}for(let Fe of En){let ze=null;if(rt(Fe)){let Ye=v(Fe);Ye&&ue.has(Ye)&&!Rn.has(ue.get(Ye))&&(ze=ue.get(Ye))}else if(Fe.kind==="text"){let Ye=et.get(Ve(ce,Fe));Ye&&!Rn.has(Ye)&&(ze=Ye)}let xt=!!k(Fe);if(!ze&&!xt){let Ye=We.get(i.unitHash(Fe));Ye&&(ze=Ye.find(ot=>!Rn.has(ot)&&rt(ot)===rt(Fe)&&(rt(ot)?ot.tagName===Fe.tagName&&!J(ot):ot.kind===Fe.kind)&&i.equalUnits(Fe,ot))||null)}if(!ze&&rt(Fe)&&!xt){let Ye=g.local(Fe),ot=(wt.get(Ve(ce,Fe))||[]).filter(ct=>{let Wt=g.remote(ct);return!Rn.has(ct)&&ct.tagName===Fe.tagName&&!J(ct)&&!(Ye&&Wt&&Ye!==Wt)&&i.similar(Fe,ct)});ot.length===1&&(ze=ot[0])}ze&&(Rn.set(ze,Fe),Rn.set(Fe,ze))}}let xo=ue=>{if(Lt?.consumes(ue))return null;if(oe.has(ue)||Nt?.has(ue))return ht.get(ue)||null;let We=ce.twin(ue),Ve=se.twin(ue),et=We&&!ce.asBase&&!ce.here(We),wt=Ve&&!se.asBase&&!se.here(Ve);if(et||wt){if((!We||!Ve)&&yt({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:We?"remote":"local"}),!Ze(ue))return rt(ue)?(Nt||=go(xe,Re,H,q,l,U,s,n.remoteWins,x,yt,K,B,S),et&&Nt.plan(ue,"local",We),wt&&Nt.plan(ue,"remote",Ve)):oe.add(ue),null;yt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue})}if(We&&!Ve&&!ce.asBase&&!se.asBase&&rt(ue)&&Ln.has(ue.tagName)&&!n.remoteWins(ue)&&!n.remoteWins(We)&&K(ue,We,H)&&hl(ue,Te(se.el),s)){let ot={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ct=Wt=>rt(Wt)?Vn(Wt,ot):Wt.kind==="text";if(r(ue).every(ct)&&r(We).every(ct)){let Wt=dt({base:[ue],local:[We],remote:[],blocks:new Set([ue,We]),out:ie,policy:Ge,L:H,R:q,idOf:{base:m,local:v,remote:I},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Qt,vn,Fn)=>U(Qt,vn,Fn,!1),cloneUnit:he,mergeAttrs:le,atomKey:i.exactUnitKey,moveIn:O,moveBuilt:O,movePlanned:O,provenance:xe,textMappers:qe,conflicts:x,conflict:yt,scope:{base:C,local:ce.el,remote:se.el,units:Ie,at:He.get(ue)},decisions:fe,node:ye});ae.push(...Wt.segments),oe.add(ue),oe.add(We);let Mt=ie.createDocumentFragment();for(let Qt of Wt.nodes)Mt.appendChild(Qt);return ht.set(ue,Mt),ht.set(We,Mt),Mt}}if(!We&&!Ve)return oe.add(ue),Ot({kind:"remove",source:"both",base:ue}),null;if(!We&&!K(ue,Ve,q))return oe.add(ue),st({kind:"remove",source:"local",base:ue}),null;if(!Ve&&!K(ue,We,H))return oe.add(ue),Ot({kind:"remove",source:"remote",base:ue}),Xe&&(Xe.remove(We),Ht.push({bk:ue,lk:We})),null;let Fe=!We||!Ve,ze=ce.asBase?l(H,ue)||null:We,xt=se.asBase&&rt(ue)&&(q.identityPaired.has(ue)||!g.base(ue))&&l(q,ue)||Ve,Ye;return rt(ue)?Ye=U(ue,ze,xt,ce.asBase):ue.kind==="comment"?Ye=_e(ue,ze,Ve,ce.asBase):Ye=W(ue,ze,Ve,ce.asBase),oe.add(ue),Ye&&(ht.set(ue,Ye),We&&ht.set(We,Ye),Ve&&ht.set(Ve,Ye),Fe&&(yt({kind:"structure",el:Ye,detail:"edit-beats-delete",base:ue},{subject:ue,deleted:We?"remote":"local"}),We?st({kind:"insert",el:Ye,source:"local"}):Ot({kind:"insert",el:Ye,source:"remote"}))),Ye},qn=(ue,We,Ve,et)=>{if(Lt?.consumes(ue))return null;if(oe.has(ue))return ht.get(ue)||null;let wt=We.baseOf(ue);if(wt&&Be.has(wt))return bt.has(wt)&&!bt.has(ue)?Ro(wt,ue,et):xo(wt);if(wt)return es(wt,ue,et);let Fe=Rn.get(ue);if(Fe){let xt=et==="local"?ue:Fe,Ye=et==="local"?Fe:ue,ot;return rt(xt)?i.equalUnits(xt,Ye)?(ot=he(xt,"local"),ot&&(xe.get(ot).remote=Ye)):ot=be(xt,Ye):ot=pe(xt,Ye),oe.add(xt),oe.add(Ye),ot&&(ht.set(xt,ot),ht.set(Ye,ot),rt(xt)&&st({kind:"insert",el:ot,source:"both"})),ot}let ze=he(ue,et);return ze&&(ht.set(ue,ze),et==="local"?st({kind:"insert",el:ze,source:"local"}):(Ot({kind:"insert",el:ze,source:"remote"}),Xe&&rt(ue)&&!qt.partner.has(ue)&&un.push({su:ue,node:ze}))),ze},Ro=(ue,We,Ve)=>{let et;return rt(ue)?(et=O(ue,Ve,We),et&&oe.add(We)):(et=he(We,Ve),oe.add(We),et&&(Ve==="local"?st:Ot)({kind:"insert",el:et,source:Ve})),et&&ht.set(We,et),et},es=(ue,We,Ve)=>{O(ue,null,null);let wt=l(Ve==="local"?q:H,ue),Fe=We,ze=wt?Ut(wt,Ve==="local"?re:G,Ve==="local"?q:H):!1,xt=wt&&!ze&&!Pt(ue,wt);if(xt&&Ve===Yt.otherSide)return yt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),null;if(xt&&yt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),wt||yt({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:Ve==="local"?"remote":"local"}),je.has(ue)){yt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue});let ot=he(Fe,Ve);return ot&&ht.set(We,ot),ot}rt(ue)&&(Nt||=go(xe,Re,H,q,l,U,s,n.remoteWins,x,yt,K,B,S),Nt.plan(ue,Ve,Fe,!0));let Ye=rt(ue)?U(ue,Ve==="local"?Fe:l(H,ue)||null,Ve==="remote"?Fe:l(q,ue)||null,!1):null;return Ye&&(ht.set(ue,Ye),ht.set(We,Ye),wt&&ht.set(wt,Ye),Ve==="local"?st({kind:"move",el:Ye,source:"local"}):Ot({kind:"move",el:Ye,source:"remote"})),Ye};for(let ue of Yt.V.units){if(bt.has(ue)){if($e?.has(ue)){for(let et of $e.get(ue))pt.has(et)||(Ke.push(et),pt.add(et));continue}let Ve=ht.get(ue);pt.has(Ve)||(Ke.push(Ve),pt.add(Ve));continue}if(oe.has(ue)&&!(ht.get(ue)&&pt.has(ht.get(ue)))){let Ve=Yt.V.baseOf(ue);Ve&&!Be.has(Ve)&&yt({kind:"structure",el:null,detail:"both-moved",base:Ve},{subject:Ve});continue}let We=qn(ue,Yt.V,Yt.A,Yt.side);We&&!pt.has(We)&&(Ke.push(We),pt.add(We),!Yt.V.baseOf(ue)&&!Rn.has(ue)&&!bt.has(ue)&&Kt.add(We))}for(let ue of it)pt.has(ue.frag)||(Ke.splice(ue.previous&&pt.has(ue.previous)?Ke.indexOf(ue.previous)+1:so(ue.at),0,ue.frag),pt.add(ue.frag));if(!Yt.other.asBase){let ue=Yt.other,We=Yt.otherSide,Ve=Yt.otherA,et=null,wt=0,Fe=null;for(let ze of ue.units){let xt=vt.get(ze)||ht.get(ze);if(xt&&pt.has(xt)){et=xt,Fe=null;continue}if(oe.has(ze)){let ct=ue.baseOf(ze);ct&&!Be.has(ct)&&yt({kind:"structure",el:null,detail:"both-moved",base:ct},{subject:ct});continue}let Ye=qn(ze,ue,Ve,We);if(!Ye)continue;let ot;if(Fe)ot=Ke.indexOf(Fe)+1;else if(et){if(ot=Ke.indexOf(et)+1,We==="remote")for(;ot<Ke.length&&Kt.has(Ke[ot]);)ot++}else ot=wt++;Ke.splice(ot,0,Ye),pt.add(Ye),Fe=Ye}}for(let ue=0;ue<Ie.length;ue++){let We=Ie[ue];if(oe.has(We))continue;let Ve=xo(We);Ve&&Ke.splice(so(ue),0,Ve)}return Xe&&Ht.length&&un.length&&Po(),Ke;function Po(){if(on||hn)return;let ue=new Set(Ke),We=ct=>ct&&Be.has(ct)&&ue.has(ht.get(ct))?ct:null,Ve=(ct,Wt)=>{let Mt=[{prev:null,units:[]}];for(let Qt of ct){let vn=We(Wt(Qt));vn?Mt.push({prev:vn,units:[]}):Mt[Mt.length-1].units.push(Qt)}return Mt},et=Ve(Ie,ct=>ct),wt=Ve(se.units,se.baseOf),Fe=ce.asBase?null:Ve(ce.units,ce.baseOf),ze=ct=>ct.length===et.length&&ct.every((Wt,Mt)=>Wt.prev===et[Mt].prev);if(!ze(wt)||Fe&&!ze(Fe))return;let xt=new Map(Ht.map(ct=>[ct.bk,ct])),Ye=new Map(un.map(ct=>[ct.su,ct])),ot=ct=>ct?Ke.indexOf(ht.get(ct)):-1;for(let ct=0;ct<et.length;ct++){if(et[ct].units.length!==1||wt[ct].units.length!==1)continue;let Wt=xt.get(et[ct].units[0]),Mt=Ye.get(wt[ct].units[0]);if(!Wt||!Mt||Fe&&(Fe[ct].units.length!==1||Fe[ct].units[0]!==Wt.lk))continue;let Qt=ot(et[ct].prev);(ct+1<et.length?ot(et[ct+1].prev):Ke.length)-Qt!==2||Ke[Qt+1]!==Mt.node||To(Wt.bk,Wt.lk,Mt.su)&&Xe.link(Wt.lk,Mt.node)}}function Kn(ue,We,Ve,et){let wt=Mt=>{let Qt=Mt.filter(rt);return Qt.length===1?Qt[0]:null},Fe=wt(ue),ze=wt(We),xt=wt(Ve);if(!Fe||!ze||!xt)return;let Ye=ue.indexOf(Fe);if(We.indexOf(ze)!==Ye||Ve.indexOf(xt)!==Ye||ue.length!==We.length||ue.length!==Ve.length)return;for(let Mt=0;Mt<ue.length;Mt++)if(Mt!==Ye&&(ue[Mt].value!==We[Mt].value||ue[Mt].value!==Ve[Mt].value))return;if((ce.asBase?Fe:ce.twin(Fe))!==ze||se.twin(Fe)||q.reverse.get(xt)||ze!==Fe&&K(Fe,ze,H))return;let ot=et.filter(Mt=>Mt.nodeType===1);if(ot.length!==1||xe.get(ot[0])?.remote!==xt)return;let ct=Mt=>Mt.map(Qt=>rt(Qt)?"":Qt.value??Qt.nodeValue).join(""),Wt=et.indexOf(ot[0]);ct(et.slice(0,Wt))!==ct(ue.slice(0,Ye))||ct(et.slice(Wt+1))!==ct(ue.slice(Ye+1))||To(Fe,ze,xt)&&Xe.link(ze,ot[0])}function To(ue,We,Ve){if(!rt(We)||!rt(Ve)||!rt(ue)||We.namespaceURI!==Ve.namespaceURI||We.localName===Ve.localName)return!1;for(let ze of[We,Ve])if(ze.tagName==="TEMPLATE"||pn(ze)||ze.querySelector("template"))return!1;if(n.remoteWins(ue)||n.remoteWins(Ve)||s(Ve)||We.attributes.length!==Ve.attributes.length)return!1;for(let ze of We.attributes)if(Ve.getAttributeNS(ze.namespaceURI,ze.localName)!==ze.value)return!1;let et=We.childNodes,wt=Ve.childNodes;if(et.length!==wt.length)return!1;for(let ze=0;ze<et.length;ze++)if(!et[ze].isEqualNode(wt[ze]))return!1;let Fe=[[ue,Ve]];for(;Fe.length;){let[ze,xt]=Fe.pop();if(ze.children.length!==xt.children.length)return!1;for(let Ye=0;Ye<xt.children.length;Ye++){let ot=q.reverse.get(xt.children[Ye]);if(ot!==void 0&&ot!==ze.children[Ye])return!1;Fe.push([ze.children[Ye],xt.children[Ye]])}}return!0}function so(ue){for(let We=ue-1;We>=0;We--){let Ve=ht.get(Ie[We]);if(Ve){let et=Ke.indexOf(Ve);if(et>=0)return et+1}}return 0}function vo(){if((ce.asBase||H.identical.has(C))&&(se.asBase||q.identical.has(C)))return;let ue={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},We=ft=>rt(ft)?Vn(ft,ue):ft.kind==="text";if(!ce.asBase&&!se.asBase)for(let ft of Ie){if(!rt(ft)||!Ln.has(ft.tagName))continue;let Qe=ce.twin(ft),Et=se.twin(ft);if(!Qe&&Et||Qe&&!Et){let nt=Br({base:Ie,views:[{V:ce,A:H,idOf:g.local},{V:se,A:q,idOf:g.remote}],eligible:At=>rt(At)&&Ln.has(At.tagName)&&!s(At)&&!n.remoteWins(At),baseId:g.base,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey});nt&&(ce=nt[0],se=nt[1]);break}}let Ve=!ce.asBase&&!se.asBase&&Ie.length>=2&&Ln.has(Ie[0].tagName)&&ce.units.length===Ie.length&&se.units.length===Ie.length?hr({base:Ie,local:ce.units,remote:se.units,localTwin:ce.twin,remoteTwin:se.twin,eligible:ft=>rt(ft)&&Ln.has(ft.tagName)&&!s(ft)&&!n.remoteWins(ft),nodes:{base:Array.from(Te(C).childNodes),local:Array.from(Te(ce.el).childNodes),remote:Array.from(Te(se.el).childNodes)}}):null,et=null,wt=null;if(!Ve&&!ce.asBase&&!se.asBase&&(Cs(Ie)||Cs(ce.units)||Cs(se.units))){let ft={ignored:s,remoteWins:()=>!1},Qe=nt=>We(nt)||rt(nt)&&n.remoteWins(nt)&&Tn.has(nt.tagName)&&Vn(nt,ft),Et=nt=>rt(nt)?Ln.has(nt.tagName)&&!s(nt)&&!n.remoteWins(nt)&&r(nt).every(Qe):nt.kind==="text";et=Dr({onUncertainOwner:nt=>{let At=n.identity.local(nt.local);At&&At===n.identity.remote(nt.remote)||(wt||=[]).push(nt)},onUncertainSource:nt=>{tt||(tt=new Map);let At=tt.get(nt.source);At||tt.set(nt.source,At=[]);for(let Xt of At)if(Xt.side===nt.side&&Xt.from===nt.from&&Xt.to===nt.to)return;At.push(nt)},base:Ie,views:[{V:ce,A:H,idOf:g.local},{V:se,A:q,idOf:g.remote}],eligible:Et,ignored:s,remoteWins:n.remoteWins,baseId:g.base,atomKey:i.exactUnitKey})}if(wt){$e||=new Map;for(let ft of wt){let{source:Qe,local:Et,remote:nt}=ft,At={map:new Map,reverse:new Map,identical:new Set},Xt=dt({base:[Qe],local:[Et],remote:[nt],out:ie,policy:"both",L:At,R:At,ignored:s,remoteWins:n.remoteWins,atomKey:i.exactUnitKey,cloneUnit:he,provenance:xe,textMappers:qe,conflicts:x,decisions:fe,conflict:(Rt,Ft)=>yt(Rt,{...Ft,policy:"both"}),scope:{base:C,local:ce.el,remote:se.el,units:Ie,at:He.get(Qe)},node:ye});ae.push(...Xt.segments);for(let Rt of[Qe,Et,nt])oe.add(Rt),bt.add(Rt),$e.set(Rt,Xt.nodes),ht.set(Rt,Xt.nodes[Xt.nodes.length-1]);for(let Rt=0;Rt<Xt.nodes.length;Rt++)it.push({frag:Xt.nodes[Rt],at:He.get(Qe),previous:Rt?Xt.nodes[Rt-1]:null})}}let Fe=Ve?Ve.blocks:null;if(et){Fe=new Set;for(let ft of et.blocks)Fe.add(ft)}let ze=ft=>!Lt?.consumes(ft)&&(Fe&&Fe.has(ft)||We(ft)),xt=Ie.map(ze);if(!xt.includes(!0))return;let Ye=ft=>{let Qe=ft.units,Et=new Map;for(let tn=0;tn<Qe.length;tn++)Et.set(Qe[tn],tn);let nt=[],At=-1;for(let tn=0;tn<Ie.length;tn++){if(xt[tn])continue;let Tt=ft.twin(Ie[tn]),mt=Tt?Et.get(Tt):void 0;mt===void 0||mt<=At||ze(Tt)||(nt.push([tn,mt]),At=mt)}let Xt=[],Rt=-1,Ft=-1;for(let tn=0;tn<=nt.length;tn++){let[Tt,mt]=tn<nt.length?nt[tn]:[Ie.length,Qe.length],St={bLo:-1,bHi:-1,from:Ft+1,to:mt,inlineStart:-1,inlineEnd:-1,next:mt};for(let Zt=Rt+1;Zt<Tt;Zt++)xt[Zt]&&(St.bLo<0&&(St.bLo=Zt),St.bHi=Zt);for(let Zt=Ft+1;Zt<mt;Zt++){let _n=Qe[Zt];ze(_n)&&(St.inlineStart<0&&(St.inlineStart=Zt),St.inlineEnd=Zt+1)}Xt.push(St),Rt=Tt,Ft=mt}return{units:Qe,list:Xt}},ot=Ye(ce),ct=Ye(se),Wt=[];for(let ft of[ot,ct])for(let Qe of ft.list)Qe.bLo>=0&&Wt.push([Qe.bLo,Qe.bHi]);Wt.sort((ft,Qe)=>ft[0]-Qe[0]);let Mt=[];for(let[ft,Qe]of Wt){let Et=Mt[Mt.length-1];Et&&ft<=Et.hi?Et.hi=Math.max(Et.hi,Qe):Mt.push({lo:ft,hi:Qe})}let Qt=(ft,Qe)=>ft.length===Qe.length&&ft.every((Et,nt)=>i.equalUnits(Et,Qe[nt])),vn=ft=>!rt(ft)&&ft.kind==="comment",Fn=ft=>{if(!ft.length)return[];let Qe=(Rt,Ft)=>rt(Rt)?Rt:Rt.nodes[Ft?Rt.nodes.length-1:0],Et=Qe(ft[0]),nt=Qe(ft[ft.length-1],!0),At=Rt=>Rt&&rt(Rt)&&s(Rt);for(;At(Et.previousSibling);)Et=Et.previousSibling;for(;At(nt.nextSibling);)nt=nt.nextSibling;let Xt=[];for(let Rt=Et;Rt&&(Xt.push(Rt),Rt!==nt);Rt=Rt.nextSibling);return Xt},Pn=ft=>ft.some(Qe=>rt(Qe)&&s(Qe));for(let ft of Mt){let Qe=Ie.slice(ft.lo,ft.hi+1),Et=null;if(et)for(let Tt of Qe){let mt=et.certificatesBySource.get(Tt);mt&&(Et||=[]).push(...mt)}let nt=ce.asBase?null:Is(ot,ft),At=se.asBase?null:Is(ct,ft);if(Et){let Tt=[new Set(nt||Qe),new Set(At||Qe)],mt=Et.some(St=>!Tt[St.side].has(St.target));for(let St of Qe)if(Fe.has(St))for(let[Zt,_n]of[[0,ce],[1,se]]){let Sn=_n.twin(St);Sn&&_n.here(Sn)&&!Tt[Zt].has(Sn)&&(mt=!0)}if(mt)continue}if(Qe.some(vn)||nt&&nt.some(vn)||At&&At.some(vn))continue;let Xt=Fn(nt||Qe),Rt=Fn(At||Qe);if((!nt||Qt(Qe,nt))&&(!At||Qt(Qe,At))&&!(nt&&Pn(Xt)))continue;let Ft=dt({base:Fn(Qe),sourceRetentions:tt?.get(C),local:Xt,remote:Rt,out:ie,policy:Ge,blocks:Fe,scopeUnits:Et?[Qe,nt||Qe,At||Qe]:null,certifiedOrigins:Et?(Tt,mt,St,Zt,_n,Sn)=>jr({certificates:Et,scopes:[Qe,nt||Qe,At||Qe],flats:[Tt,mt,St],keys:[Zt,_n,Sn]}):null,prepared:Ve?Ve.prepared:null,nativeTransfers:Ve,L:nt?H:Ur(H,C),R:At?q:Ur(q,C),idOf:{base:m,local:v,remote:I},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Tt,mt,St)=>U(Tt,mt,St,!1),cloneUnit:he,mergeAttrs:le,atomKey:i.exactUnitKey,moveIn:O,moveBuilt:O,movePlanned:O,provenance:xe,textMappers:qe,conflicts:x,conflict:yt,scope:{base:C,local:ce.asBase?null:ce.el,remote:se.asBase?null:se.el,units:Ie,at:ft.lo},decisions:fe,node:ye});if(!Ft){if(Et){let Tt=pr({certificates:Et,scopes:[Qe,nt||Qe,At||Qe],views:[{V:ce,A:H,idOf:g.local},{V:se,A:q,idOf:g.remote}],eligible:mt=>rt(mt)&&Ln.has(mt.tagName)&&!s(mt)&&!n.remoteWins(mt),baseId:g.base});for(let mt of Tt.records){tt||=new Map;let St=tt.get(mt.source);St||tt.set(mt.source,St=[]),St.push(mt)}}continue}if(ae.push(...Ft.segments),Ve){let Tt=new Map;for(let mt of Ft.nodes){let St=xe.get(mt)?.base;if(!St||Tt.has(St))throw new Error("Invalid native transfer owner output");Tt.set(St,mt)}if(Tt.size!==Ve.owners.length)throw new Error("Incomplete native transfer owner output");for(let mt of Ve.owners){let St=Tt.get(mt.base);if(!St)throw new Error("Missing native transfer owner output");for(let Zt of[mt.base,mt.local,mt.remote])oe.add(Zt),bt.add(Zt),ht.set(Zt,St);it.push({frag:St,at:He.get(mt.base)})}continue}if(Xe&&Kn(Qe,nt||Qe,At||Qe,Ft.nodes),Ft.unitOutputs){$e||=new Map;for(let mt of[...Qe,...nt||[],...At||[]]){let St=Ft.unitOutputs.get(mt)||[];oe.add(mt),bt.add(mt),$e.set(mt,St),St.length&&ht.set(mt,St[St.length-1])}let Tt=Ft.nodes[Ft.nodes.length-1];if(Tt)for(let mt of[nt||Qe,At||Qe]){let St=mt[mt.length-1];St&&vt.set(St,Tt)}for(let mt=0;mt<Ft.nodes.length;mt++)it.push({frag:Ft.nodes[mt],at:ft.lo,previous:mt>0?Ft.nodes[mt-1]:null});continue}Xe&&Kn(Qe,nt||Qe,At||Qe,Ft.nodes);let tn=ie.createDocumentFragment();for(let Tt of Ft.nodes)tn.appendChild(Tt);for(let Tt of[...Qe,...nt||[],...At||[]])oe.add(Tt),bt.add(Tt),ht.set(Tt,tn);it.push({frag:tn,at:ft.lo})}}}function te(C,G){let re=xe.get(C);return re&&re.unchanged?!re.remote||re.remote===G?!0:z(re.remote,G):C.tagName!==G.tagName||!Ce(C,G)?!1:Pe(Te(C),Te(G))}function z(C,G){return C===G?!0:C.tagName!==G.tagName||C.namespaceURI!==G.namespaceURI||!Ce(C,G)?!1:ne(Te(C),Te(G))}function ne(C,G){let re=ve(C,s),ge=ve(G,s);if(re.length!==ge.length)return!1;for(let ye=0;ye<re.length;ye++){let ce=re[ye],se=ge[ye];if(typeof ce=="string"||typeof se=="string"){if(ce!==se)return!1}else{if(ce.nodeType!==se.nodeType)return!1;if(ce.nodeType===1){if(!z(ce,se))return!1}else if(ce.nodeValue!==se.nodeValue)return!1}}return!0}function Te(C){return C.tagName==="TEMPLATE"&&C.content?C.content:C}function Ce(C,G){let re=0;for(let ge of C.attributes)if(!n.ignoreAttribute(C,ge.name)&&(re++,G.getAttribute(ge.name)!==ge.value))return!1;for(let ge of G.attributes)n.ignoreAttribute(G,ge.name)||re--;return re===0}function Pe(C,G){let re=ve(C,ye=>{let ce=xe.get(ye);return!!(ce&&ce.pinned)}),ge=ve(G,s);if(re.length!==ge.length)return!1;for(let ye=0;ye<re.length;ye++){let ce=re[ye],se=ge[ye];if(typeof ce=="string"||typeof se=="string"){if(ce!==se)return!1}else{if(ce.nodeType!==se.nodeType)return!1;if(ce.nodeType===1){if(!te(ce,se))return!1}else if(ce.nodeValue!==se.nodeValue)return!1}}return!0}function ve(C,G){let re=[],ge=null;for(let ye=C.firstChild;ye;ye=ye.nextSibling){if(ye.nodeType===3){ge=ge===null?ye.nodeValue:ge+ye.nodeValue;continue}ye.nodeType===1&&G(ye)||(ge!==null&&(ge!==""&&re.push(ge),ge=null),re.push(ye))}return ge!==null&&ge!==""&&re.push(ge),re}function _e(C,G,re,ge){let ye=C.value,ce=ge?ye:G?G.value:"",se=re?re.value:"";oe.add(C),G&&oe.add(G),re&&oe.add(re);let Ie=ce===se?ce:ce===ye?se:se===ye||Ge==="local"?ce:se,Be={site:"comment",bRun:C,lRun:G,rRun:re,node:null};if(ce!==ye&&se!==ye&&ce!==se&&yt({kind:"text",node:null,base:ye,local:ce,remote:se,resolved:Ie},Be),!G&&!re)return null;let He=ie.createComment(Ie);return Be.node=He,xe.set(He,{base:C.nodes,local:G?G.nodes:null,remote:re?re.nodes:null}),He}function Je(C,G){let re=l(G,C);if(!re)return null;let ge=rt(re)?re.parentNode:re.parent,ye=rt(C)?C.parentNode:C.parent;return l(G,ye)===ge?null:G.reverse.get(ge)||null}function Ze(C){let G=new Set([C]),re=C;for(let ge=0;ge<64;ge++){let ye=Je(re,H)||Je(re,q);if(!ye)return!1;if(ye===C||rt(C)&&rt(ye)&&C.contains(ye)||G.has(ye))return!0;G.add(ye),re=ye}return!0}function Ut(C,G,re){if(!G)return!1;let ge=rt(C)?C.parentNode:C.parent;return ge===G||G.tagName==="TEMPLATE"&&ge===G.content}function Pt(C,G){let re=Re(C),ge=l(H,re);if(ge&&Ut(G,ge,H))return!0;let ye=l(q,re);return!!(ye&&Ut(G,ye,q))}}function Ur(e,o){return e.map.get(o)?Vr():{map:{get:n=>n&&n.nodeType===1&&e.map.get(n)||n,has:()=>!0},reverse:{get:n=>e.reverse.get(n)||n,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Vr(){let e={get:o=>o,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Hr=new Set(["INPUT","OPTION","TEXTAREA"]),Es=/[\t\n\f\r ]+/;function Wr(e,o,t,n){let s=e.ownerDocument,{provenance:h,textMappers:i}=t,r=n.hooks,a=[],d=[],w=[],c=new Set,p=[],m=[],v=new Map,I=new Set,g=new Map,f=t.conflicts.length>0||n.trackInserted===!0,b=new Map,B=new Set,S=new Map,T=(l,O)=>{let R=S.get(l);R||S.set(l,R=new Set),R.add(O)},M=f?new Set:null,L=(l,O,R)=>{let K=r.beforeAttributeUpdated(l,O,R);return f&&K===!1&&T(O,l),K},N=l=>!!l&&(l===e||e.contains(l)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(l)),A=new Map,E=new Map,V=new Map,j=new Set,D=new Map;(function l(O){let R=h.get(O);if(R){if(O.nodeType===1){let Z=R.local?n.toLive(R.local):null;Z&&N(Z)&&Z.nodeType===1&&(A.set(O,Z),E.set(Z,O))}else if(Array.isArray(R.local)){let Z=q(R.local,R.local.map(U=>n.toLive(U)).filter(U=>U&&N(U)&&U.nodeType===O.nodeType));if(Z.length&&(A.set(O,Z[0]),E.set(Z[0],O),V.set(O,Z)),Array.isArray(R.caret))for(let U of R.caret){let de=n.toLive(U.node);if(!de||!N(de)||de.nodeType!==3)continue;let we=D.get(de);Array.isArray(we)||D.set(de,we=[]),we.push({merged:O,from:U.from,to:U.to,flatStart:U.flatStart})}else{let U=0;for(let de of Z)D.set(de,{merged:O,shift:U}),U+=de.nodeValue.length}}}let K=O.nodeType===1&&O.tagName==="TEMPLATE"&&O.content?O.content.childNodes:O.childNodes;for(let Z of K)l(Z)})(o);let y=new Set;for(let l of A.values())y.add(l);for(let l of V.values())for(let O of l)y.add(O);let k=n.localRoot&&n.localRoot!==e?new Set:null;if(k){for(let l=n.localRoot.firstElementChild;l;l=l.nextElementSibling)if(l.tagName==="HEAD")for(let O=l.firstElementChild;O;O=O.nextElementSibling){let R=n.toLive(O);R&&k.add(R)}}for(let l of t.segments||[])Me(l);let J=n.restoreFocus===!1?null:pl(s,D);n.childrenOnly?xe(Oe(e),Oe(o)):Re(e,o);for(let{node:l,parent:O}of p)c.has(l)||!l.parentNode||l.nodeType===1&&(n.ignored(l)||qe(l))||tt(l,O);return ml(s,J,D,i,V,g,j),{applied:a,moved:d,replaced:w,identities:m,mergedScriptsLive:I,liveOf:A,heldBy:g,runOf:V,keptRuns:j,insertedLive:b,vetoed:B,vetoedAttrs:S,removedVetoes:M};function H(l,O){let R=l.slice(O.bs,O.be),K=0;for(;K<R.length&&K<O.text.length&&R[K]===O.text[K];)K++;let Z=0;for(;Z<R.length-K&&Z<O.text.length-K&&R[R.length-1-Z]===O.text[O.text.length-1-Z];)Z++;return{bs:O.bs+K,be:O.be-Z,text:O.text.slice(K,O.text.length-Z)}}function q(l,O){if(!O.length)return O;let R=[];for(let U of l){let de=U.parentNode;if(!de)continue;let we=v.get(de);if(!we){we=new Set;for(let le=de.firstChild;le;le=le.nextSibling)le.nodeType===3&&we.add(n.toLive(le));v.set(de,we)}R.includes(we)||R.push(we)}let K={has:U=>R.some(de=>de.has(U))},Z=[];for(let U of O){Z.push(U);for(let de=U.nextSibling;de&&de.nodeType===3&&!K.has(de)&&!Z.includes(de);de=de.nextSibling)Z.push(de)}return Z}function Me(l){let O=[];for(let ee of l.localNodes){let te=n.toLive(ee.node);if(!te||!N(te)||te.nodeType!==3)return;O.push(te)}let R=q(l.localNodes.map(ee=>ee.node),O);if(!R.length)return;let K=R.map(ee=>ee.nodeValue).join(""),{flatLocal:Z,lToM:U,mapLocal:de}=l;if(K===Z)return;let we=l.textNodes.map(ee=>({node:ee.node,ms:ee.ms,me:ee.me})),le=[],Ae=0;for(let ee of R)le.push(Ae),Ae+=ee.nodeValue.length;let W=(ee,te)=>R.find((z,ne)=>le[ne]<=ee&&ee+te<=le[ne]+z.nodeValue.length)||null,X=[],pe=0;for(let ee of Gn(Z,K).map(te=>H(Z,te))){let te=ee.bs+pe;pe+=ee.text.length-(ee.be-ee.bs);let z,ne;if(ee.be>ee.bs){z=U[ee.bs];let Te=z>=0;for(let Ce=ee.bs;Te&&Ce<ee.be;Ce++)U[Ce]!==z+(Ce-ee.bs)&&(Te=!1);if(!Te)continue;ne=z+(ee.be-ee.bs)}else{let Te=ee.bs>0?U[ee.bs-1]:0,Ce=ee.bs<Z.length?U[ee.bs]:0;if(Te<0||Ce<0)continue;z=ne=de(ee.bs)}X.push({ms:z,me:ne,text:ee.text,live:ne===z?W(te,ee.text.length):null})}X.sort((ee,te)=>te.ms-ee.ms);let be=(ee,te)=>(V.get(ee.node)||[A.get(ee.node)]).includes(te),he=ee=>!!ee&&ee.nodeType===1&&Tn.has(ee.tagName);for(let ee of X){let te=we.find(ne=>ne.ms<=ee.ms&&ee.me<=ne.me&&ee.ms<ne.me);if(te&&ee.live&&te.ms===ee.ms&&!be(te,ee.live)){let ne=we.find(Te=>Te.me===ee.ms&&be(Te,ee.live));ne&&(te=ne)}if(!te&&ee.me===ee.ms){let ne=we.find(ve=>ve.me===ee.ms),Te=we.find(ve=>ve.ms===ee.ms),Ce=ne||Te;if(!Ce)continue;let Pe=Ce.node;for(;he(Pe.parentNode)&&(ne?Pe.parentNode.lastChild:Pe.parentNode.firstChild)===Pe;)Pe=Pe.parentNode;if(Pe===Ce.node)te=Ce;else{let ve=Pe.ownerDocument.createTextNode(ee.text);Pe.parentNode.insertBefore(ve,ne?Pe.nextSibling:Pe);continue}}if(!te)continue;let z=te.node.nodeValue;te.node.nodeValue=z.slice(0,ee.ms-te.ms)+ee.text+z.slice(ee.me-te.ms),te.me+=ee.text.length-(ee.me-ee.ms)}}function Oe(l){return l.nodeType===1&&l.tagName==="TEMPLATE"&&l.content?l.content:l}function Re(l,O){c.add(l);let R=h.get(O);if(R&&R.remote&&t.remoteIdOf){let Z=t.remoteIdOf(R.remote);Z&&m.push([l,Z])}if(R&&R.unchanged){n.opaque&&n.opaque(l)||(t.customIdentity&&R.remote&&ae(l,R.remote),R.remote&&Y(l,R.remote));return}if(r.beforeNodeMorphed(l,O)===!1){B.add(O);return}Ct(l,O,n.keepLiveOnly&&R&&R.local&&R.local.nodeType===1&&R.local!==l?R.local:null);let K=l.tagName;if(pn(l))l.textContent!==O.textContent&&(a.push({kind:"text",node:l,before:l.textContent,after:O.textContent}),l.textContent=O.textContent),t.mergedScripts.has(O)&&I.add(l);else if(K==="TEXTAREA")$(l,O,R);else{Gt(l,O,R);let Z=K==="TEMPLATE"&&l.content?l.content:l,U=K==="TEMPLATE"&&O.content?O.content:O;n.opaque&&n.opaque(l)||n.protectFocusedValue==="subtree"&&Nt(l)&&l!==s.body?ie(Z):xe(Z,U)}r.afterNodeMorphed(l,O)}function ie(l){for(let O=l.firstChild;O;O=O.nextSibling){let R=E.get(O);R&&A.get(R.parentNode)!==l||(c.add(O),O.nodeType===1&&ie(O))}}function xe(l,O){let R=je(l.firstChild),K=new Set;for(let Z of Array.from(O.childNodes)){let U=A.get(Z);U&&c.has(U)&&!K.has(U)&&(U=null);let de=h.get(Z);if(de&&de.pinned){U&&U.nodeType===1&&((U.parentNode!==l||je(U.nextSibling)!==R)&&Ne(l,U,R),c.add(U),K.add(U));continue}if(U&&U.nodeType===1){if(U!==R){let Ae=U.parentNode;if(Ae===l&&R&&Lt(U)){let W=U.nextSibling;for(let X=R;X&&X!==U;){let pe=X.nextSibling;Ne(l,X,W),X=pe}}else Ne(l,U,R),Ae!==l&&(d.push(U),a.push({kind:"move",el:U,from:Ae,to:l}))}K.add(U),Re(U,Z),R=je(U.nextSibling);continue}if(U&&U.nodeType!==1){let Ae=V.get(Z)||[U],W=Ae.map(pe=>pe.nodeValue).join(""),X=Z.nodeValue;if(Z.nodeType===3){let pe=fe(Z);pe!=null&&W!==pe&&(X=lo(pe,W,Z.nodeValue).text)}if(Ae.length>1&&W===X&&!Ae.includes(R,1)&&Ae.every((pe,be)=>pe.parentNode===l&&(be===0||Ae[be-1].nextSibling===pe))){if(U!==R)for(let pe of Ae)Ne(l,pe,R);r.beforeNodeMorphed(U,Z)!==!1?r.afterNodeMorphed(U,Z):f&&B.add(Z);for(let pe of Ae)c.add(pe),K.add(pe);g.set(Z,U),j.add(Z),R=je(Ae[Ae.length-1].nextSibling);continue}U!==R&&Ne(l,U,R),r.beforeNodeMorphed(U,Z)!==!1?(U.nodeValue!==X&&(a.push({kind:"text",node:U,before:U.nodeValue,after:X}),U.nodeValue=X),r.afterNodeMorphed(U,Z)):B.add(Z),c.add(U),K.add(U),g.set(Z,U),R=je(U.nextSibling);continue}if(Z.nodeType===3&&R&&R.nodeType===3&&!c.has(R)&&!D.has(R)){R.nodeValue!==Z.nodeValue&&(a.push({kind:"text",node:R,before:R.nodeValue,after:Z.nodeValue}),R.nodeValue=Z.nodeValue),c.add(R),g.set(Z,R),R=je(R.nextSibling);continue}let we=h.get(Z),le=Xe(we&&we.unchanged&&we.remote?we.remote:Z);if(r.beforeNodeAdded(le)===!1){B.add(Z);continue}l.insertBefore(le,R),c.add(le),f&&b.set(Z,le),le.nodeType===3&&g.set(Z,le),le.nodeType===1&&(w.push(le),Ee(le,Z),t.customIdentity&&we&&we.unchanged&&we.remote&&ae(le,we.remote),pn(le)||dt(le,Z),n.formState==="property"&&rn(we)&&Y(le,we.remote)),R=je(le.nextSibling),a.push({kind:"insert",node:le,parent:l}),r.afterNodeAdded(le)}for(let Z of Array.from(l.childNodes))c.has(Z)||K.has(Z)||Z.nodeType===1&&(n.ignored(Z)||qe(Z))||(y.has(Z)?p.push({node:Z,parent:l}):tt(Z,l))}function qe(l){return l.parentNode&&l.parentNode.nodeType===1&&l.parentNode.tagName==="HEAD"&&(k&&!k.has(l)||n.preserve&&n.preserve(l)===!0)}function fe(l){let O=h.get(l);return!O||!Array.isArray(O.local)?null:O.local.map(R=>R.nodeValue).join("")}function x(l){return h.get(l)}function Y(l,O){if(!Hr.has(l.tagName)&&!l.querySelector("input,option,textarea"))return;let R=(K,Z)=>{if(K.tagName!==Z.tagName||(K.tagName==="TEXTAREA"?$(K,Z,{remote:Z}):Hr.has(K.tagName)&&Gt(K,Z,{remote:Z}),n.opaque&&n.opaque(K)))return;let U=oe(K),de=oe(Z);if(U.length===de.length)for(let we=0;we<U.length;we++)R(U[we],de[we])};R(l,O)}function ae(l,O){if(n.opaque&&n.opaque(l))return;let R=oe(l),K=oe(O);if(R.length===K.length)for(let Z=0;Z<R.length;Z++){let U=t.remoteIdOf(K[Z]);U&&m.push([R[Z],U]),ae(R[Z],K[Z])}}function oe(l){let O=l.tagName==="TEMPLATE"&&l.content?l.content:l;return Array.from(O.children).filter(R=>!n.ignored(R))}function Ee(l,O){if(!t.remoteIdOf)return;let R=(K,Z)=>{let U=h.get(Z);if(U&&U.remote&&Z.nodeType===1){let le=t.remoteIdOf(U.remote);le&&m.push([K,le])}let de=K.childNodes,we=Z.childNodes;for(let le=0;le<de.length&&le<we.length;le++)R(de[le],we[le])};R(l,O)}function je(l){for(;l&&l.nodeType===1&&n.ignored(l);)l=l.nextSibling;return l}function Ne(l,O,R){if(typeof l.moveBefore=="function"&&O.ownerDocument===l.ownerDocument)try{l.moveBefore(O,R);return}catch{}l.insertBefore(O,R)}function tt(l,O){if(r.beforeNodeRemoved(l)===!1){f&&M.add(l);return}l.parentNode.removeChild(l),a.push({kind:"remove",node:l,parent:O}),r.afterNodeRemoved(l)}function Xe(l){if(pn(l))return Mo(l,s);let O=s.importNode(l,!0);if(O.nodeType===1)for(let R of Array.from(O.querySelectorAll("script")))pn(R)&&R.replaceWith(Mo(R,s));return O}function dt(l,O){let R=l.tagName==="TEMPLATE"&&l.content?l.content:l,K=O.tagName==="TEMPLATE"&&O.content?O.content:O,Z=Array.from(R.childNodes),U=Array.from(K.childNodes);for(let de=0;de<U.length&&de<Z.length;de++){let we=U[de],le=Z[de],Ae=A.get(we);Ae&&c.has(Ae)&&(Ae=null);let W=h.get(we);if(W&&W.pinned){if(Ae&&Ae.nodeType===1){let X=Ae.parentNode;Ne(R,Ae,le),X!==R&&(d.push(Ae),a.push({kind:"move",el:Ae,from:X,to:R})),c.add(Ae)}le.remove();continue}if(Ae){let X=Ae.parentNode;Ne(R,Ae,le),le.remove(),Ae.nodeType===1?(X!==R&&(d.push(Ae),a.push({kind:"move",el:Ae,from:X,to:R})),Re(Ae,we)):(c.add(Ae),g.set(we,Ae),Ae.nodeValue!==we.nodeValue&&(a.push({kind:"text",node:Ae,before:Ae.nodeValue,after:we.nodeValue}),Ae.nodeValue=we.nodeValue));continue}c.add(le),f&&b.set(we,le),le.nodeType===3&&g.set(we,le),W&&W.unchanged&&W.remote?(Ge(le,W.remote),t.customIdentity&&ae(le,W.remote)):we.nodeType===1&&!pn(we)&&dt(le,we)}}function Ge(l,O){let R=l.tagName==="TEMPLATE"&&l.content?l.content:l,K=O.tagName==="TEMPLATE"&&O.content?O.content:O;for(let Z of Array.from(K.childNodes))R.appendChild(Xe(Z))}function st(l,O){return O.namespaceURI?l.getAttributeNS(O.namespaceURI,O.localName):l.getAttribute(O.name)}function Ot(l,O){let R=new Set((O||"").split(Es).filter(Boolean));return(l||"").split(Es).filter(K=>K&&!R.has(K))}function Ct(l,O,R){for(let K of Array.from(O.attributes)){if(yt(l,K.name)||n.ignoreAttribute(l,K.name))continue;let Z=st(l,K);if(Z===K.value||R&&st(R,K)===K.value)continue;let U=K.value;if(R&&K.name==="class"&&!K.namespaceURI){let de=K.value.split(Es).filter(Boolean),we=Ot(Z,R.getAttribute("class")).filter(le=>!de.includes(le));we.length&&(U=[...de,...we].join(" "))}if(Z!==U){if(r.beforeAttributeUpdated(K.name,l,"update")===!1){f&&T(O,K.name);continue}K.namespaceURI?l.setAttributeNS(K.namespaceURI,K.name,U):l.setAttribute(K.name,U),a.push({kind:"attr",el:l,name:K.name,before:Z,after:U})}}for(let K of Array.from(l.attributes)){if(yt(l,K.name)||n.ignoreAttribute(l,K.name)||(K.namespaceURI?O.hasAttributeNS(K.namespaceURI,K.localName):O.hasAttribute(K.name)))continue;if(R&&K.name==="class"&&!K.namespaceURI){let de=Ot(K.value,R.getAttribute("class"));if(de.length){let we=de.join(" ");if(we===K.value)continue;if(r.beforeAttributeUpdated("class",l,"update")===!1){f&&T(O,"class");continue}l.setAttribute("class",we),a.push({kind:"attr",el:l,name:"class",before:K.value,after:we});continue}}if(R&&st(R,K)===null)continue;if(r.beforeAttributeUpdated(K.name,l,"remove")===!1){f&&T(O,K.name);continue}let U=K.value;K.namespaceURI?l.removeAttributeNS(K.namespaceURI,K.localName):l.removeAttribute(K.name),a.push({kind:"attr",el:l,name:K.name,before:U,after:null})}}function yt(l,O){let R=l.tagName;return R==="INPUT"?O==="value"||O==="checked"||O==="disabled":R==="OPTION"?O==="selected":!1}function Nt(l){return l===s.activeElement}function Lt(l){let O=s.activeElement;return!!O&&O!==s.body&&l.contains(O)}function qt(l,O){let R=O&&O.local&&O.local.nodeType===1&&O.local!==l?O.local:null;if(!R)return!0;let K=l.tagName==="TEXTAREA"?R.textContent:R.getAttribute("value")??"";return l.value!==K}function cn(l,O){return!!n.protectFocusedValue&&Nt(l)&&qt(l,O)}function It(l,O,R){let K=Math.min(l.length,O.length),Z=0;for(;Z<K&&l[Z]===O[Z];)Z++;if(R<=Z)return R;let U=0;for(;U<K-Z&&l[l.length-1-U]===O[O.length-1-U];)U++;return R>=l.length-U?R+O.length-l.length:O.length-U}function $t(l){try{return l.selectionStart==null?null:[l.selectionStart,l.selectionEnd,l.selectionDirection]}catch{return null}}function wn(l,O,R,K){try{l.setSelectionRange(It(O,R,K[0]),It(O,R,K[1]),K[2]||"none")}catch{}}function jt(l,O){let R=l.value,K=$t(l);l.value=O,K&&wn(l,R,O,K)}function rn(l){let O=l&&l.remote;return O&&O.nodeType===1?O:null}function Gt(l,O,R){let K=l.tagName,Z=rn(R),U=n.formState==="property"&&Z?Z:O;if(K==="INPUT"){let de=cn(l,R),we=(l.getAttribute("type")||"").toLowerCase(),le=we!=="file"&&we!=="checkbox"&&we!=="radio",Ae=Z&&Z.hasAttribute("value")&&Z.value!==Z.getAttribute("value")?Z.value:null;if(le&&!de)if(n.formState==="property"){let W=O.getAttribute("value"),X=l.getAttribute("value");(X!==W||l.value!==U.value)&&L("value",l,W==null?"remove":"update")!==!1&&(X!==W&&(W==null?l.removeAttribute("value"):l.setAttribute("value",W),a.push({kind:"attr",el:l,name:"value",before:X,after:W})),l.value!==U.value&&(Nt(l)?jt(l,U.value):l.value=U.value))}else if(O.hasAttribute("value")||Ae!=null){let W=Ae??O.getAttribute("value");l.getAttribute("value")!==W&&L("value",l,"update")!==!1?(l.setAttribute("value",W),l.value!==W&&(Nt(l)?jt(l,W):l.value=W),a.push({kind:"attr",el:l,name:"value",before:null,after:W})):l.value!==W&&l.getAttribute("value")===W&&(Nt(l)?jt(l,W):l.value=W)}else(l.hasAttribute("value")||l.value!=="")&&L("value",l,"remove")!==!1&&(l.removeAttribute("value"),l.value="",a.push({kind:"attr",el:l,name:"value",before:"",after:null}));if(!le&&we!=="file"){let W=O.getAttribute("value");W==null?l.hasAttribute("value")&&L("value",l,"remove")!==!1&&l.removeAttribute("value"):l.getAttribute("value")!==W&&L("value",l,"update")!==!1&&l.setAttribute("value",W)}n.protectFocusedValue&&Nt(l)||(fn(l,U,"checked"),n.formState==="property"&&l.indeterminate!==U.indeterminate&&(l.indeterminate=U.indeterminate)),fn(l,U,"disabled")}else if(K==="OPTION"){let de=l.parentNode&&l.closest("select");n.protectFocusedValue&&de&&Nt(de)||fn(l,U,"selected")}}function fn(l,O,R){let K=n.formState==="property"?!!O[R]:O.hasAttribute(R);if(n.formState!=="property"){let Z=l.hasAttribute(R);if(Z!==K){if(L(R,l,K?"update":"remove")===!1)return;K?l.setAttribute(R,""):l.removeAttribute(R),a.push({kind:"attr",el:l,name:R,before:Z?"":null,after:K?"":null})}}l[R]!==K&&(l[R]=K)}function $(l,O,R){if(cn(l,R)||L("value",l,"update")===!1)return;let K=rn(R),Z=O.textContent,U=K&&K.value!==K.defaultValue?K.value:Z,de=Nt(l)?$t(l):null,we=l.value;n.formState!=="property"&&l.textContent!==Z&&(a.push({kind:"text",node:l,before:l.textContent,after:Z}),l.textContent=Z),l.value!==U&&(l.value=U),de&&l.value!==we&&wn(l,we,l.value,de)}}function pl(e,o){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let n={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{n.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return n}let s=e.getSelection&&e.getSelection();if(s&&s.rangeCount){let h=s.getRangeAt(0);n.range={sc:h.startContainer,so:h.startOffset,ec:h.endContainer,eo:h.endOffset}}return n}function ml(e,o,t,n,s,h,i){if(!o)return;let r=o.el;if(!r.isConnected&&o.id&&(r=e.getElementById(o.id)),!r||!r.isConnected)return;if(e.activeElement!==r)try{r.focus({preventScroll:!0})}catch{}try{r.scrollTop=o.scrollTop,r.scrollLeft=o.scrollLeft}catch{}if(o.selection){try{r.setSelectionRange&&!r.selectionEnd&&o.selection[1]!=null&&r.setSelectionRange(o.selection[0],o.selection[1],o.selection[2]||"none")}catch{}return}if(!o.range)return;let a=(c,p)=>{let m=t.get(c);if(Array.isArray(m)){let v=m.find(b=>p>=b.from&&p<b.to)||m.find(b=>p===b.to)||m[m.length-1],I=h.get(v.merged);if(!I||!I.isConnected)return null;let g=n.get(v.merged),f=g&&g.flat?g.flat(v.flatStart+p):p;return[I,Math.max(0,Math.min(f,I.nodeValue.length))]}if(m&&!i.has(m.merged)){let v=(s.get(m.merged)||[c])[0];if(!v.isConnected)return null;let I=n.get(m.merged),g=m.shift+p,f=I?I(g):g;return[v,Math.max(0,Math.min(f,v.nodeValue.length))]}return c.isConnected?[c,Math.min(p,c.nodeType===3?c.nodeValue.length:c.childNodes.length)]:null},d=a(o.range.sc,o.range.so),w=a(o.range.ec,o.range.eo);if(!(!d||!w))try{let c=e.createRange();c.setStart(d[0],d[1]),c.setEnd(w[0],w[1]);let p=e.getSelection();p.removeAllRanges(),p.addRange(c)}catch{}}var gl={compared:0},bl=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function wl(e,o,t){let n=0;for(let s of e.attributes)if(!t(e,s.name)&&(n++,o.getAttribute(s.name)!==s.value))return!1;for(let s of o.attributes)t(o,s.name)||n--;return n===0}function Rs(e,o){if(e.namespaceURI!==o.namespaceURI||e.prefix!==o.prefix||e.localName!==o.localName)return!1;let t=e.attributes;if(t.length!==o.attributes.length)return!1;for(let n of t)if(o.getAttributeNS(n.namespaceURI,n.localName)!==n.value)return!1;return!0}function qr(e,o,t,n,s,h,i,r){let a=new Map,d=new Set,w=c=>{if(n(c))return;let p=t(c);p&&(h.add(p),s.has(p)||a.has(p)?d.add(p):a.set(p,c))};for(let c of e)w(c);w(o);for(let c of i||o.querySelectorAll("*"))w(c);for(let c of d)a.delete(c),r.add(c);return a}function Kr(e,o,t,n,s,h){let i=!1;for(let w of s)w.startsWith("merge:")&&(i=!0);if(!i)return[...n];let r=new Map,a=[],d=h===kn?Co:"*";for(let w of[e,...e.querySelectorAll(d)]){if(t(w))continue;let c=o(w);if(!c||!(n.has(c)||s.has(c)))continue;let p=(r.get(c)||0)+1;r.set(c,p),p===2&&a.push(c)}return a}function Fr({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:s,identity:h,baseURI:i}){if(e.tagName!==o.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||o.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!wl(e,o,s.ignoreAttribute))return{bail:"root-attrs"};let{ignored:r,remoteWins:a}=s,d=Ls(s.scripts.merge===!1?null:s.scripts.mergeTags,i),w=fe=>{let x=d(fe);return x!==null?x:h.base(fe)||null},c=fe=>{let x=d(fe);return x!==null?x:h.remote(fe)||null},p=[],m=[],v=new Map,I=new Map,g={same:v,differ:I},f=fe=>({bail:fe,comparisons:g}),b=(fe,x,Y=!0)=>{if(v.get(fe)===x)return!0;if(I.get(fe)===x)return!1;if(gl.compared++,Y&&fe.isEqualNode(x))return v.set(fe,x),!0;let ae=fe.nodeType===x.nodeType;if(ae&&fe.nodeType===1){if(ae=Rs(fe,x),ae){let oe=fe.firstChild,Ee=x.firstChild;for(;oe&&Ee;oe=oe.nextSibling,Ee=Ee.nextSibling)if(!b(oe,Ee,!1)){ae=!1;break}(oe||Ee)&&(ae=!1)}}else ae&&(ae=fe.isEqualNode(x));return(ae?v:I).set(fe,x),ae},B=e,S=o,T=!1,M=()=>{v.set(B,S);for(let fe=0;fe<p.length;fe++)v.set(p[fe],m[fe]);return f("equal")};for(;;){let fe=B.childNodes,x=S.childNodes;if(fe.length!==x.length)break;let Y=Xe=>b(fe[Xe],x[Xe])?(v.set(fe[Xe],x[Xe]),!1):!0,ae=-1,oe=-1;for(let Xe=0;Xe<fe.length;Xe++){if(fe[Xe].nodeType!==1)continue;let dt=0;for(let Ge=fe[Xe].firstElementChild;Ge;Ge=Ge.nextElementSibling)dt++;dt>=oe&&(oe=dt,ae=Xe)}let Ee=[],je=!1;for(let Xe=0;Xe<fe.length&&Ee.length<2;Xe++)Xe!==ae&&Y(Xe)&&Ee.push(Xe);if(ae>=0&&Ee.length<2&&(Ee.length===0&&Rs(B,S)?(Ee.push(ae),je=!0):Y(ae)&&Ee.push(ae)),Ee.length!==1){if(!T&&Ee.length===0&&Rs(B,S))return M();break}let Ne=fe[Ee[0]],tt=x[Ee[0]];if(T=T||!je,T&&I.set(Ne,tt),Ne.nodeType!==1||tt.nodeType!==1||Ne.tagName!==tt.tagName)break;if(w(Ne)!==c(tt)){if(!T&&b(Ne,tt))return M();break}p.push(B),m.push(S),B=Ne,S=tt}I.set(B,S);for(let fe=0;fe<p.length;fe++)I.set(p[fe],m[fe]);if(B===e||B.tagName==="HEAD"||B.tagName==="BODY")return f("root-level");if(p.length<2||p[1].tagName!=="BODY")return f("not-in-body");if(r(B)||r(S))return f("ignored-ancestor");if(a(B)||a(S))return f("remote-wins-ancestor");for(let fe of p)if(bl.has(fe.tagName))return f("form-ancestor");if(B.tagName==="SCRIPT"||B.getElementsByTagName("script").length||S.getElementsByTagName("script").length)return f("script-or-template");let L=n(B);if(!L||L.nodeType!==1||L.tagName!==B.tagName)return f("no-live-twin");if(!t.contains(L))return f("live-detached");for(let fe of p){let x=n(fe);if(!x||x.nodeType!==1)return f("ancestor-live")}let N=h.base===kn&&h.remote===kn&&r===os,A=new Set,E=new Set,V=[],j=null,D=fe=>{fe&&(A.has(fe)?E.add(fe):A.add(fe))},y=(fe,x)=>{let Y=d(fe),ae=Y!==null?Y:h.base(fe)||null;return ae!==(Y!==null?Y:h.remote(x)||null)?!1:(D(ae),!0)},k=(fe,x)=>{for(let Y=fe.firstElementChild,ae=x.firstElementChild;Y;Y=Y.nextElementSibling,ae=ae.nextElementSibling){let oe=r(Y);if(oe!==r(ae))return!1;if(!oe&&(!y(Y,ae)||!k(Y,ae)))return!1}return!0},J=fe=>{let x=fe+1<p.length?p[fe+1]:B;for(let Y=p[fe].firstElementChild,ae=m[fe].firstElementChild;Y;Y=Y.nextElementSibling,ae=ae.nextElementSibling){if(Y===x){let je=fe+1<p.length?J(fe+1):null;if(je)return je;continue}let oe=r(Y);if(oe!==r(ae))return"outside-id-changed";if(oe)continue;let Ee=n(Y);if(!Ee||Ee.nodeType!==1)return"sibling-live";if(V.push([Y,ae]),!N&&(!y(Y,ae)||!k(Y,ae)))return"outside-id-changed";fe===0&&Y.tagName==="HEAD"&&w(Y)&&(j=[Y,ae])}return null},H=J(0);if(H)return f(H);let q=new Set(p),Me=null;if(h.base===kn){Me=[];for(let fe of e.querySelectorAll(Co))fe===B||q.has(fe)||(B.contains(fe)?Me.push(fe):N&&D(w(fe)))}let Oe=new Set,Re=new Set,ie=new Set,xe=qr(p,B,w,r,A,Oe,Me,Re),qe=qr(m,S,c,r,A,Oe,h.remote===kn&&S.querySelectorAll(Co),ie);return j&&(E.has(w(j[0]))||Oe.has(w(j[0])))&&(j=null),{scope:{chain:p,root:B,onChain:q,baseIndex:xe,remoteIndex:qe,baseDropped:Re,remoteDropped:ie,head:j,same:v,differ:I,dropped:[...Kr(e,w,r,E,Re,h.base),...Kr(o,c,r,E,ie,h.remote)],held:fe=>{for(let x=1;x<p.length;x++)if(fe.map.get(p[x])!==m[x])return!1;for(let[x,Y]of V)if(fe.map.get(x)!==Y)return!1;return!0}}}}var _r=Symbol("hyper-morph-duplicate-key"),zr=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function Lo(e,o){return o.map(t=>{let n=new Map;for(let s of e){if(s.nodeType!==1)continue;let h=t(s);h==null||h===""||n.set(h,n.has(h)?_r:s)}return n})}function $r(e,o,t,n){for(let s=0;s<n.length;s++){let h=n[s](e);if(h==null||h===""||o[s].get(h)!==e)continue;let i=t[s].get(h);if(!(!i||i===_r)&&i.tagName===e.tagName)return i}return null}function bo(e,o,t){for(let n=0;n<t.length;n++){let s=t[n](e);if(!(s==null||s==="")&&o[n].get(s)===e)return!0}return!1}function Gr(e,o,t={}){let n=t.skip||(()=>!1),s=t.ignoreAttr||(()=>!1),h=t.tiers&&t.tiers.length?t.tiers:zr,i=null;function r(){return i||(i=Lo([e,...e.querySelectorAll("*")],h)),i}let a=null;function d(){return a||(a=Lo([o,...o.querySelectorAll("*")],h)),a}function w(A){return!A.parentElement||!A.parentElement.parentElement}function c(A,E,V){return w(A)||bo(A,r(),h)?(V.push({type:"subtree",el:A,base:E}),!1):!0}function p(A,E){let V=[];for(let j of A.attributes)s(A,j.name)||E.getAttribute(j.name)!==j.value&&V.push(j.name);for(let j of E.attributes)s(A,j.name)||A.hasAttribute(j.name)||V.push(j.name);return V}function m(A){let E=[],V=null,j=()=>{V!==null&&(E.push({nodeType:3,nodeValue:V}),V=null)};for(let D of A.childNodes){if(D.nodeType===3){V=(V===null?"":V)+D.nodeValue;continue}D.nodeType===1&&n(D)||(j(),(D.nodeType===1||D.nodeType===8)&&E.push(D))}return j(),E}function v(A,E){if(A.nodeType!==E.nodeType)return!1;if(A.nodeType!==1)return!0;if(A.tagName!==E.tagName)return!1;for(let V of h){let j=V(A),D=V(E);if(j!=null&&j!==""&&D!=null&&D!==""&&j!==D)return!1}return!0}function I(A){let E="";for(let V of A)V.nodeType===3&&V.nodeValue.trim()!==""?E+="\0"+V.nodeValue:V.nodeType===8&&(E+=""+V.nodeValue);return E}function g(A,E,V){let j=m(A),D=m(E);if(j.length===D.length){let fe=!0;for(let x=0;x<j.length;x++)if(!v(j[x],D[x])){fe=!1;break}if(fe){for(let x=0;x<j.length;x++){let Y=j[x];if(Y.nodeType===1){if(f(Y,D[x],V))return!0}else if(Y.nodeValue!==D[x].nodeValue)return!0}return!1}}let y=j.filter(fe=>fe.nodeType===1),k=D.filter(fe=>fe.nodeType===1);if(I(j)!==I(D))return!0;let J=Lo(y,h),H=Lo(k,h),q=[],Me=new Set,Oe=[];for(let fe of y){let x=$r(fe,J,H,h);x&&!Me.has(x)?(q.push([fe,x]),Me.add(x)):Oe.push(fe)}let Re=[];for(let fe of Oe)bo(fe,J,h)?V.push({type:"subtree",el:fe,base:null}):Re.push(fe);let ie=[];for(let fe of k)Me.has(fe)||(bo(fe,H,h)?V.push({type:"deletion",el:fe}):ie.push(fe));if(Re.length!==ie.length)return!0;for(let fe=0;fe<Re.length;fe++)if(!v(Re[fe],ie[fe]))return!0;let xe=new Map(q);for(let fe=0;fe<Re.length;fe++)xe.set(Re[fe],ie[fe]);let qe=-1;for(let fe of y){let x=xe.get(fe);if(!x)continue;let Y=k.indexOf(x);if(Y<qe)return!0;qe=Y}for(let fe=0;fe<Re.length;fe++)if(f(Re[fe],ie[fe],V))return!0;for(let[fe,x]of q)if(f(fe,x,V))return!0;return!1}function f(A,E,V){if(A.tagName!==E.tagName)return c(A,E,V);let j=p(A,E),D=[];if(g(A,E,D))return c(A,E,V);if(j.length){if(!w(A)&&!bo(E,d(),h))return!0;V.push({type:"attrs",el:A,names:j,base:E})}return V.push(...D),!1}let b=[],B=p(e,o);B.length&&b.push({type:"attrs",el:e,names:B});let S=(A,E)=>Array.from(A.children).find(V=>V.tagName===E)||null,T=S(e,"HEAD"),M=S(o,"HEAD");if(T&&M){let A=[];f(T,M,A),A.length&&b.push({type:"head",el:T})}else(T||M)&&T&&b.push({type:"head",el:T});let L=S(e,"BODY"),N=S(o,"BODY");return L&&N?f(L,N,b):L&&b.push({type:"subtree",el:L,base:null}),{entries:b}}function Yr(e,o,t={}){let n=t.tiers&&t.tiers.length?t.tiers:zr,s=e.documentElement,h=[],i=0,r=f=>({ok:!1,placed:h,held:f,skippedAttrs:i});if(!s)return r(null);function a(f){let b=[f,...f.querySelectorAll("*")];return Lo(b,n)}let d=a(s),w=new Map,c=f=>{let b=f.getRootNode(),B=w.get(b);if(!B){let S=b.nodeType===9?b.documentElement:b;B=a(S),w.set(b,B)}return B};function p(f){if(!f.parentElement&&f.tagName==="HTML")return s;if(f.parentElement&&!f.parentElement.parentElement&&f.parentElement.tagName==="HTML"){if(f.tagName==="BODY")return e.body||null;if(f.tagName==="HEAD")return e.head||null}return null}function m(f){let b=p(f);return b||$r(f,c(f),d,n)}function v(f){if(!f)return null;let b=m(f);return b&&b.isConnected?b:null}function I(f){for(let b=0;b<n.length;b++){let B=n[b](f);B!=null&&B!==""&&d[b].set(B,f)}}for(let f of o){if(f.type!=="deletion")continue;let b=m(f.el);b&&b!==s&&b.remove()}let g=o.filter(f=>f.type!=="deletion").sort((f,b)=>f.el===b.el?0:f.el.compareDocumentPosition(b.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let f of g){if(f.type==="head"){let N=e.importNode(f.el,!0);e.head?e.head.replaceWith(N):s.insertBefore(N,s.firstChild),h.push({entry:f,imported:N});continue}if(f.type==="attrs"){let N=v(f.el)||v(f.base);if(!N){i++;continue}for(let A of f.names)f.el.hasAttribute(A)?N.setAttribute(A,f.el.getAttribute(A)):N.removeAttribute(A);continue}let b=f.el;if(p(b))return r(f);let B=v(b)||v(f.base);if(B){let N=e.importNode(b,!0);B.replaceWith(N),I(N),h.push({entry:f,imported:N});continue}if(f.base!=null&&!bo(f.base,c(f.base),n)||!bo(b,c(b),n))return r(f);let S=b.parentElement;if(!S)return r(f);let T=v(S);if(!T)return r(f);let M=null;for(let N=b.previousElementSibling;N;N=N.previousElementSibling){let A=v(N);if(A&&A.parentNode===T){M=A;break}}let L=e.importNode(b,!0);if(M)T.insertBefore(L,M.nextSibling);else{let N=Array.prototype.indexOf.call(S.children,b);T.insertBefore(L,T.children[N]||null)}I(L),h.push({entry:f,imported:L})}return{ok:!0,placed:h,held:null,skippedAttrs:i}}var yl='[editor-ui],[clay~="editor-ui"],[save-ignore],[snapshot-remove],[no-snapshot],[no-save],[save-remove],[freeze],[save-freeze],[clay~="no-save"],[clay~="no-snapshot"],[clay~="freeze"]',kl='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',xl='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Tl(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let o=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(o)}function vl(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let s=o;if(s.nodeType===9){let h=e.getAttribute("id");s=h&&s.getElementById(h)||(e.tagName==="BODY"?s.body:e.tagName==="HTML"?s.documentElement:s.body&&s.body.firstElementChild)}if((!s||s.nodeType!==1||s.tagName!==e.tagName)&&(s=Sl(e,o,n)),!!s)return t?Array.from(s.childNodes):s}function Sl(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let s=new Map,h=[n,...n.querySelectorAll("script")];for(let a of h){let d=ho(a,t);d&&!s.has(d.key)&&s.set(d.key,a.textContent)}if(!s.size)return null;let i=e.cloneNode(!0),r=!1;for(let a of[i,...i.querySelectorAll("script")]){let d=ho(a,t);d&&s.has(d.key)&&(a.textContent=s.get(d.key),r=!0)}return r?i:null}function Xr(e,o){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=o.implementation.createHTMLDocument(""),n=e.nodeType===1&&e.tagName==="HTML"?e:null;if(n)return t.replaceChild(t.adoptNode(n),t.documentElement),t;let s=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let h of s)t.body.appendChild(t.adoptNode(h));return t}function Qo(e,o,t={}){let n=t||{};if(!n.head?.block)return Jr(e,o,n);try{return Jr(e,o,n)}catch(s){return Promise.reject(s)}}function Jr(e,o,t){let n=t.policy||"sync",s=n==="raw"?void 0:(a,d)=>Tl(a)||(n==="history"?!(d&&a.matches(xl))&&a.matches(kl):a.matches(yl)),h=t.callbacks||{},i={ignore:s,hooks:h,protectFocusedValue:t.ignoreActiveValue===!0?"subtree":!1,restoreFocus:t.restoreFocus!==!1,formState:t.formStateSync||"attribute",scripts:{execute:t.scripts?.handle!==!1,merge:t.scripts?.merge!==!1,mergeTags:t.scripts?.mergeTags||[]},head:{awaitLoads:!!t.head?.block,preserve:t.head?.shouldPreserve||(()=>!1)}};if(typeof t.key=="function"&&(i.identity={base:t.key,local:t.key,remote:t.key}),e&&e.nodeType===9)return wo(Object.assign({},i,{live:e,base:t.scripts?.mergeBase||null,remote:Xr(o,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let a=Object.assign({},i,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Xr(o,e.ownerDocument)});return wo(a)}t.morphStyle==="innerHTML"&&(i.children=!0);let r=vl(e,t.scripts?.mergeBase,!!i.children,i.scripts.mergeTags);return r!==void 0&&(i.base=r),Zo(e,o,i)}var Nl=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),On=()=>{};function Eo(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let r of Object.keys(e))if(!Nl.has(r))throw new TypeError(`unknown option "${r}"`);let t=Object.assign({beforeNodeAdded:On,afterNodeAdded:On,beforeNodeRemoved:On,afterNodeRemoved:On,beforeNodeMorphed:On,afterNodeMorphed:On,beforeAttributeUpdated:On},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let s=e.formState||"attribute";if(!["attribute","property"].includes(s))throw new TypeError("formState must be attribute or property");let h=e.protectFocusedValue;if(h!==void 0&&typeof h!="boolean"&&h!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");let i=e.lineage;if(i!==void 0&&(!i||typeof i!="object"||typeof i.onResult!="function"||!i.elements||typeof i.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:ss(e.ignore,o),remoteWins:ss(e.remoteWins,o),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,opaque:typeof e.opaque=="function"?e.opaque:()=>!1,conflicts:n,protectFocusedValue:h===void 0?!0:h,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:s,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:i||null}}function yo(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return kn}function ko(e,o){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=jo(o,e.map),n=typeof e.then=="function"?e.then:kn;if(typeof e.first=="function"){let s=e.first;return h=>s(h)||t.get(h)||n(h)}return s=>t.get(s)||n(s)}return kn}function ni(e,o,t,n={}){let s=m=>m&&m.nodeType===9?m.documentElement:m,h=s(o),i=s(t),r=s(e)||h;if(n.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let a=Object.assign({},n);delete a.live,delete a.base,delete a.remote;let d=Eo(a,[r,h,i].filter(Boolean)),w=n.identity||{},c=zn(),p=Jo(r,h,i,{identity:{base:ko(w.base,r),local:ko(w.local,h),remote:ko(w.remote,i)},authored:{base:yo(w.base),local:yo(w.local),remote:yo(w.remote)},skipUnchanged:d.hooks.beforeNodeMorphed===On&&d.hooks.afterNodeMorphed===On,ignored:d.ignored,remoteWins:d.remoteWins,ignoreAttribute:d.ignoreAttribute,conflicts:d.conflicts,mergeTags:d.scripts.merge===!1?null:d.scripts.mergeTags,baseURI:h.ownerDocument&&h.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:d.children,stats:c});return delete p.recoveryLinks,delete p.lineage,p}function Ps({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:s,options:h,identity:i,childrenOnly:r,isDocument:a}){let d=Eo(h,[e,o,t,n].filter(Boolean));if(d.ignored(e)){let y=Bs(),k=d.lineage?Ao(d.lineage,e,y):null;return{report:y,loads:[],lineage:k}}let w=e.ownerDocument,c=d.lineage?vs(d.lineage,{liveRoot:e,localRoot:t,toLive:s}):null,p=d.scripts.execute?mr(e,d.ignored,w.baseURI):null,m=zn(),v=d.hooks.beforeNodeMorphed===On&&d.hooks.afterNodeMorphed===On,I={identity:{base:ko(i.base,o||t),local:ko(i.local,t),remote:ko(i.remote,n)},authored:{base:yo(i.base),local:yo(i.local),remote:yo(i.remote)},ignored:d.ignored,remoteWins:d.remoteWins,ignoreAttribute:d.ignoreAttribute,conflicts:d.conflicts,mergeTags:d.scripts.merge===!1?null:d.scripts.mergeTags,baseURI:w.baseURI,localIsBase:!o,childrenOnly:r,skipUnchanged:v,lineage:c?{locals:c.locals}:null},g=d.fastPath&&a&&!r&&v&&o===t,f=null,b=null;if(g){let y=Fr({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:s,o:d,identity:I.identity,baseURI:w.baseURI});I.comparisons=y.comparisons||y.scope,y.bail?b=y.bail:(f=Jo(o,t,n,Object.assign({},I,{stats:m,scope:y.scope})),f||(b="chain-unpaired",m=zn()))}f||(f=Jo(o||t,t,n,Object.assign({},I,{stats:m}))),g&&(m.fastPathAttempted=1,m.fastPathTaken=b?0:1,m.fastPathFallback=b),f.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(y=>d.hooks[y]!==On)&&Ar(f.conflicts,f.recoveryLinks,s),d.beforeApply&&d.beforeApply(f.doc);let B=globalThis.__hyperMorphProfile,S=B?performance.now():0,T=Wr(e,f.root,f,{toLive:s,localRoot:t,ignored:d.ignored,ignoreAttribute:d.ignoreAttribute,opaque:d.opaque,formState:d.formState,protectFocusedValue:d.protectFocusedValue,restoreFocus:d.restoreFocus,preserve:d.head.preserve,hooks:d.hooks,childrenOnly:r,keepLiveOnly:d.keepLiveOnly,trackInserted:!!c});B&&(B.apply=(B.apply||0)+(performance.now()-S));let M=[];if(d.head.awaitLoads)for(let y of T.applied){if(y.kind!=="insert"||y.node.nodeType!==1)continue;let k=y.node;k.tagName==="LINK"&&/\bstylesheet\b/i.test(k.getAttribute("rel")||"")&&k.getAttribute("href")&&k.closest("head")&&M.push(new Promise(H=>{k.addEventListener("load",()=>H()),k.addEventListener("error",()=>H())}))}let L=null,N=null;if(p){let y=gr(e,p,{ignored:d.ignored,skip:T.mergedScriptsLive,baseURI:w.baseURI,beforeNodeAdded:d.hooks.beforeNodeAdded,afterNodeAdded:d.hooks.afterNodeAdded,trackRecovery:!!f.recoveryLinks});M.push(...y.loads),L=y.swapped,N=y.vetoed}let A=y=>L&&L.get(y)||y,E=y=>{if(T.keptRuns.has(y))return T.runOf.get(y);let k=T.liveOf.get(y)||T.heldBy.get(y)||T.insertedLive.get(y);return k?A(k):null},V=y=>{let k=y&&T.liveOf.get(y);return k?A(k):null},j=y=>{let k=y&&E(y);return Array.isArray(k)?k[0]:k};if(f.recoveryLinks){let y=(k,J,H)=>(J.namespaceURI?k.getAttributeNS(J.namespaceURI,J.localName):k.getAttribute(J.qualifiedName))===H;Ir(f.conflicts,f.recoveryLinks,{lookup:E,vetoed:T.vetoed,vetoedAttrs:T.vetoedAttrs,removedVetoes:T.removedVetoes,vetoedLive:N,liveAttr:y,ignored:d.ignored,liveRoot:e})}let D={applied:T.applied,decisions:f.decisions.map(y=>Object.assign({},y,{node:y.node?V(y.node):null,el:y.el?V(y.el):null,applied:!!(y.node?V(y.node):y.el&&V(y.el))})),conflicts:f.conflicts.map(y=>Object.assign({},y,{node:y.node?y.kind==="text"&&y.recovery.subject.nodeType===8?j(y.node):V(y.node):y.node,el:y.el?y.kind==="structure"?j(y.el):V(y.el):y.el})),localDiverged:f.localDiverged,identities:T.identities,moved:T.moved,replaced:T.replaced,stats:m};return c&&(D.lineage=c.finish(f.lineage,E)),{report:D,loads:M,lineage:c}}var Qr=new WeakMap;function Bs(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:zn()}}function wo(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");return o.lineage===void 0?Zr(o):Ts(o,o.live.documentElement,n=>Zr(n))}function Zr(e){let o=e||{},t=o.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let n=Qr.get(t);n||(n=Do(t),Qr.set(t,n));let s=n("remote",o.remote),h=typeof o.base=="string"&&o.base===""?null:o.base,i=h?n("base",h):null,r=o.local?o.local.root:t.documentElement,a=o.local?o.local.toLive:p=>p;js(t,s);let{report:d,loads:w,lineage:c}=Ps({liveRoot:t.documentElement,baseRoot:i?i.documentElement:null,localRoot:r,remoteRoot:s.documentElement,toLive:a,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return c?.deliver(d),Promise.all(w).then(()=>d)}function oi(e,o,t={}){return wo(Object.assign({},t,{live:e,base:null,remote:o}))}function ei(e,o){if(e==null)return{root:o.createElement("template"),first:null};if(typeof e=="string"){let n=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(n){let h=Bo(e,o),i=n[1].toLowerCase()==="html"?h.documentElement:h.body;return{root:i,first:i}}let s=o.createElement("template");return s.innerHTML=e,{root:s,first:s.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let n=o.createElement("template"),s=e.isConnected;return n.content.appendChild(s?o.importNode(e,!0):e),{root:n,first:e}}if(e.nodeType===11){let n=o.createElement("template");return n.content.appendChild(e),{root:n,first:n.content.firstElementChild}}let t=o.createElement("template");for(let n of Array.from(e))t.content.appendChild(n.parentNode?o.importNode(n,!0):n);return{root:t,first:t.content.firstElementChild}}function Zo(e,o,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return t.lineage===void 0?ti(e,o,t):Ts(t,e,n=>ti(e,o,n))}function ti(e,o,t={}){let n=e.ownerDocument,{base:s,...h}=t,i=!!h.children,r=Eo(h,[e]);if(r.ignored(e)){let I=Bs();return r.lineage&&Ao(r.lineage,e,I).deliver(I),Promise.resolve(I)}let a=ei(o,n),d=s!=null?ei(s,n):null,w,c=null;if(i)w=a.root,c=d?d.root:null;else{if(w=a.first,c=d?d.first:null,!w){let I=Eo(h),g=I.lineage?Ao(I.lineage,e,{}):null;I.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),I.hooks.afterNodeRemoved(e));let f={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:zn()};return g&&(f.lineage=g.result,g.deliver(f)),Promise.resolve(f)}if(w.tagName!==e.tagName){let I=Eo(h,[e,w]);if(I.hooks.beforeNodeMorphed(e,w)===!1){let b=Bs();return I.lineage&&Ao(I.lineage,e,b).deliver(b),Promise.resolve(b)}let g=Ps({liveRoot:e,baseRoot:c&&c.tagName===e.tagName?c:null,localRoot:e,remoteRoot:w,toLive:b=>b,options:h,identity:h.identity||{},childrenOnly:!0,isDocument:!1}),f=pn(w)?Mo(w,n):n.importNode(w,!1);if(!pn(f))for(;e.firstChild;)f.appendChild(e.firstChild);return I.hooks.beforeNodeAdded(f)===!1?(Xo(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):I.hooks.beforeNodeRemoved(e)===!1?(Xo(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(f),Xo(g.report.conflicts,e,f),I.hooks.afterNodeRemoved(e),I.hooks.afterNodeAdded(f),I.hooks.afterNodeMorphed(e,w),g.report.replaced.push(f),g.report.applied.push({kind:"insert",node:f,parent:f.parentNode},{kind:"remove",node:e,parent:f.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,f),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:p,loads:m,lineage:v}=Ps({liveRoot:e,baseRoot:c,localRoot:e,remoteRoot:w,toLive:I=>I,options:h,identity:h.identity||{},childrenOnly:i,isDocument:!1});return v?.deliver(p),Promise.all(m).then(()=>p)}var Al={mergeDocument:wo,morphDocument:oi,morphElement:Zo,merge3:ni,morph:Qo};return fi(Ml);})();
|
|
1
|
+
var HyperMorph=(()=>{var os=Object.defineProperty;var ri=Object.getOwnPropertyDescriptor;var ii=Object.getOwnPropertyNames;var li=Object.prototype.hasOwnProperty;var ai=(e,o)=>{for(var t in o)os(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&&os(e,s,{get:()=>o[s],enumerable:!(n=ri(o,s))||n.enumerable});return e};var fi=e=>ci(os({},"__esModule",{value:!0}),e);var Rl={};ai(Rl,{createIdentityStore:()=>Hs,createParseCache:()=>jo,default:()=>El,diff:()=>Yn,findChangedRoots:()=>Gr,importMap:()=>Do,merge3:()=>ni,merge3Text:()=>lo,mergeDocument:()=>wo,mergeJson:()=>Os,mergeScriptText:()=>Yo,morph:()=>Zo,morphDocument:()=>oi,morphElement:()=>es,parseJsonRelaxed:()=>zo,parseRulesRelaxed:()=>xr,spliceProtected:()=>Yr,tieredIdentity:()=>is});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 jo(e){let o=new Map;return(t,n)=>{if(typeof n!="string")return Bo(n,e);let s=o.get(t);if(s&&s.text===n)return s.doc;let h=Bo(n,e);return o.set(t,{text:n,doc:h}),h}}function Vs(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 ss=()=>!1;function rs(e,o=[]){if(typeof e!="function")return ss;let t=new WeakMap,n=new Set(o);return s=>{if(!s||s.nodeType!==1)return!1;let h=t.get(s);if(h!==void 0)return h;let l=[],r=s,i=!1;for(;r&&r.nodeType===1;){let u=t.get(r);if(u!==void 0){i=u;break}if(l.push(r),e(r,n.has(r))){i=!0;break}if(n.has(r))break;r=r.parentElement}for(let u of l)t.set(u,i);return i}}var Dl=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 $n(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}function Hs(e){let o=new WeakMap,t=0,n=r=>o.get(r)||null,s=r=>{let i=o.get(r);return i||(i=`${e}:${++t}`,o.set(r,i)),i};return{idOf:n,ensure:s,adopt:(r,i)=>{r&&typeof i=="string"&&i&&o.set(r,i)},exportMap:(r,i)=>{let u={},w=[],c=[],p=(b,S)=>{let C=i(b);C&&(u[S]=s(C));let m=b.children;w.push(m.length),c.push(b.tagName.toLowerCase());for(let f=0;f<m.length;f++)p(m[f],S===""?String(f):`${S}.${f}`)};return p(r,""),u["~"]=w.join(","),u["^"]=c.join(","),u}}}function Do(e,o){let t=new WeakMap;if(!e||!o||typeof o!="object"||Array.isArray(o))return t;let n=o["~"],s=typeof n=="string"?n.split(",").map(Number):null,h=s&&typeof o["^"]=="string"?o["^"].split(","):null,l=c=>Number.isInteger(c)&&c>=0,r=0,i=!1,u=c=>{let p=c;for(;p>0;){let b=s[r++];if(r>s.length||!l(b))return!1;p+=b-1}return!0},w=(c,p)=>{if(i)return;if(s){let C=r++,m=s[C];if(C>=s.length||!l(m)){i=!0;return}let f=!h||h[C]===c.tagName.toLowerCase();if(!f||m!==c.children.length){let g=f&&o[p];typeof g=="string"&&g&&t.set(c,g),u(m)||(i=!0);return}}let b=o[p];typeof b=="string"&&b&&t.set(c,b);let S=c.children;for(let C=0;C<S.length;C++)w(S[C],p===""?String(C):`${p}.${C}`)};return w(e,""),t}function is(e){return o=>{for(let t of e){let n=t(o);if(typeof n=="string"&&n!=="")return n}return null}}var kn=is([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Uo(e,o,t,n=null,s=null){let h=new Map,l=new Set,r=i=>{if(t(i))return;let u=o(i);u&&(h.has(u)?l.add(u):h.set(u,i))};if(n){let i=u=>{for(let w of u.querySelectorAll(n))r(w);for(let w of u.querySelectorAll("template"))w.content&&i(w.content)};r(e),i(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let i=u=>{r(u);let w=u.tagName==="TEMPLATE"&&u.content?u.content.children:u.children;for(let c=0;c<w.length;c++)i(w[c])};i(e)}for(let i of l)h.delete(i),s&&s.add(i),ls(i);return h}function ls(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"]),qs=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 Ws(e){return e.replace(/\s+/g," ")}var di=0;function Ks({ignored:e=()=>!1,ignoreAttribute:o=()=>!1,stats:t=null}={}){let n=new WeakMap,s=new WeakMap;function h(A){let E=A.attributes,N=E.length;if(N===0)return{all:"",sig:A.tagName+"|"};let M=[],R="",V=[];for(let D=0;D<N;D++){let j=E[D],y=j.name;o(A,y)||M.push(y+"="+j.value),y==="class"?R=j.value.indexOf(" ")<0?j.value:j.value.split(/\s+/).filter(Boolean).sort().join(" "):ui.has(y)&&V.push(y+"="+j.value)}return M.length>1&&M.sort(),V.length>1&&V.sort(),{all:M.join(""),sig:A.tagName+"|"+R+(V.length?"|"+V.join("|"):"")}}function l(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:Ws(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 N=h(A),M=ro(A.tagName+""+N.all),R="";for(let V of u(A))if(V.nodeType===1){let D=r(V);M=ro(D.hash,M),R.length<64&&(R+=" "+D.hint)}else M=ro(w(V),M),V.kind==="text"&&R.length<64&&(R+=V.value.slice(0,64));E={hash:"E"+M,hint:Ws(R).trim().slice(0,64),sig:N.sig,tok:null}}else E={hash:"N"+A.nodeType,hint:"",sig:null,tok:null};return n.set(A,E),E}function i(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 N=null,M=()=>{N&&(N.value=N.nodes.map(R=>R.nodeValue).join(""),E.push(N),N=null)};for(let R of l(A)){if(R.nodeType===3){N||(N={kind:"text",nodes:[],value:"",parent:A,hash:void 0}),N.nodes.push(R);continue}M(),R.nodeType===8?E.push({kind:"comment",nodes:[R],value:R.nodeValue,parent:A,hash:void 0}):R.nodeType===1&&!e(R)&&E.push(R)}return M(),s.set(A,E),E}function w(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 c(A,E){let N=i(r(A)),M=i(r(E));if(N.size===0&&M.size===0)return{coef:1,share:1};if(N.size===0||M.size===0)return null;let R=0;for(let V of N)M.has(V)&&R++;return{coef:R/Math.min(N.size,M.size),share:R/Math.max(N.size,M.size)}}function p(A,E){let N=c(A,E);return!!N&&N.coef>=.5}let b=new WeakMap;function S(A){let E=b.get(A);if(E)return E;E=[];for(let N of A.attributes)o(A,N.name)||E.push([N.namespaceURI||"",N.localName,N.value]);return E.sort((N,M)=>N[0]<M[0]?-1:N[0]>M[0]?1:N[1]<M[1]?-1:N[1]>M[1]?1:0),b.set(A,E),E}let C=new WeakMap;function m(A,E){if(A===E)return!0;if(w(A)!==w(E))return!1;let N=C.get(A);if(N&&N.has(E))return N.get(E);let M=C.get(E);if(M&&M.has(A))return M.get(A);let R=f(A,E),V=R===!0;return R===!1&&t&&t.hashRejected++,N||C.set(A,N=new WeakMap),N.set(E,V),V}function f(A,E){if(A.nodeType===1){if(E.nodeType!==1||A.tagName!==E.tagName||A.namespaceURI!==E.namespaceURI)return!1;let N=S(A),M=S(E);if(N.length!==M.length)return!1;for(let D=0;D<N.length;D++)if(N[D][0]!==M[D][0]||N[D][1]!==M[D][1]||N[D][2]!==M[D][2])return!1;let R=u(A),V=u(E);if(R.length!==V.length)return!1;for(let D=0;D<R.length;D++){if(w(R[D])!==w(V[D]))return!1;if(!m(R[D],V[D]))return di}return!0}return E.nodeType===1?!1:A.kind===E.kind&&A.value===E.value}let g=new WeakMap,I=new Map,v=0;function T(A){let E=g.get(A);if(E)return E;let N=w(A),M=I.get(N);M||I.set(N,M=[]);let R=M.find(V=>m(V.unit,A));return E=R?R.key:"K"+v++,R||M.push({unit:A,key:E}),g.set(A,E),E}return{meta:r,unitsOf:u,unitHash:w,similar:p,score:c,childrenOf:l,equalUnits:m,exactUnitKey:T,ignored:e}}var Fs=16,hi=2e3,pi=3,as={align:0,certifyVisited:0,certifyScheduled:0};function cs(e,o,t){let{meta:n,unitsOf:s,unitHash:h,similar:l,score:r,childrenOf:i,equalUnits:u,ignored:w}=t.analyzer,c=t.baseId||(()=>null),p=t.sideId||(()=>null),b=t.baseKey||(()=>null),S=t.sideKey||(()=>null),C=t.baseDropped||new Set,m=t.sideDropped||new Set,f=t.stats||null,g=f?new Set:null,I=f?new Set:null,v=new Map,T=new Map,A=new Set,E=new Map,N=new Set,M=new Set,R=new Set,V=[],D=[],j=[],y=[],k=hi,J=new Map,H=new Map,q=(W,X)=>{v.set(W,X),T.set(X,W)},Me=new Set,Oe=new Set,Re=null,ie=W=>{let X=W.nodeType?W.parentNode:W.parent;if(!X||X.nodeType!==11)return X;if(!Re){Re=new WeakMap;let pe=be=>{for(let he of be.querySelectorAll("template"))he.content&&(Re.set(he.content,he),pe(he.content))};for(let be of[e,o])pe(be.tagName==="TEMPLATE"&&be.content?be.content:be)}return Re.get(X)||null},xe=(W,X)=>{for(let pe=ie(W);pe&&!Me.has(pe);pe=ie(pe))Me.add(pe);for(let pe=ie(X);pe&&!Oe.has(pe);pe=ie(pe))Oe.add(pe)},qe=W=>{for(let X=ie(W);X;X=ie(X))if(v.has(X))return M.has(X);return!1},fe=W=>{for(let X=ie(W);X;X=ie(X)){let pe=T.get(X);if(pe!==void 0)return M.has(pe)}return!1},x=W=>!!W&&W.nodeType===1,Y=(W,X)=>{let pe=E.get(W);return!!pe&&pe.has(X)},ae=W=>qs.has(W.tagName),oe=t.comparisons||t.scope,Ee=(W,X)=>{if(oe){if(oe.same.get(W)===X)return!0;if(oe.differ.get(W)===X)return!1}if(!W.isEqualNode(X))return!1;if(W.tagName==="TEMPLATE")return u(W,X);let pe=W.getElementsByTagName("template");if(pe.length===0)return!0;let be=X.getElementsByTagName("template");if(pe.length!==be.length)return!1;for(let he=0;he<pe.length;he++)if(!u(pe[he],be[he]))return!1;return!0},De=(W,X)=>{let pe=c(W);if(!pe)return!0;let be=p(X);return!be||pe===be},Ne=W=>{let X=b(W);return X&&t.baseIndex.get(X)===W&&!m.has(X)?X:null},nt=W=>{let X=S(W);return X&&t.sideIndex.get(X)===W&&!C.has(X)?X:null},Xe=(W,X)=>{let pe=Ne(W);if(!pe)return!0;let be=nt(X);return!be||pe===be},ht=globalThis.__hyperMorphProfile,Ge=ht?performance.now():0;ht&&!t.scope&&(n(e),n(o),ht.meta=(ht.meta||0)+(performance.now()-Ge),Ge=performance.now()),q(e,o);let rt=new Set;for(let[W,X]of t.baseIndex){let pe=t.sideIndex.get(W);pe&&pe.tagName===X.tagName&&!v.has(X)&&!T.has(pe)&&(q(X,pe),xe(X,pe),rt.add(X))}if(rt.size){let W=[];if(t.scope)for(let he of t.scope.chain)rt.has(he)&&W.push(he);let X=[t.scope?t.scope.root:e];for(;X.length;){let he=X.pop();rt.has(he)&&W.push(he);let ee=i(he);for(let te=ee.length-1;te>=0;te--)ee[te].nodeType===1&&X.push(ee[te])}let pe=new Set;for(let he=W.length-1;he>=0;he--){let ee=W[he];t.scope&&t.scope.onChain.has(ee)?pe.add(ee):Dt(ee,v.get(ee),pe)?(M.add(ee),R.add(ee),f&&f.certificationPairs++):pe.add(ee)}let be=new Set;for(let he of W)M.has(he)&&!be.has(he)&&Ot(he,be)}t.scope&&t.scope.head&&Yt(t.scope.head[0],t.scope.head[1]);function Ot(W,X){let pe=[W];for(;pe.length;){let be=pe.pop();if(!X.has(be)){X.add(be),O(be);for(let he of s(be))x(he)&&v.has(he)&&pe.push(he)}}}y.push([e,o]);for(let[W,X]of v)x(W)&&W!==e&&y.push([W,X]);return Lt(),Ct(),ht&&(ht.align=(ht.align||0)+(performance.now()-Ge)),{map:v,reverse:T,moved:N,identical:M,pairIdenticalChildren:O,weak:A,unpair:wt,rematch:Ct,insertedByHash:Nt,refused:I,identityPaired:rt};function Ct(){Ae(),Lt();for(let W=0;W<j.length;){let X=j.length;It(W,X),W=X,Lt(),Ae(),Lt()}}function wt(W){let X=v.get(W);if(!X)return;E.has(W)||E.set(W,new Set),E.get(W).add(X);let pe=(he,ee)=>{v.delete(he),T.delete(ee),N.delete(he),M.delete(he),A.delete(he),R.delete(he)},be=(he,ee)=>{for(let te of s(he)){let z=v.get(te);!z||rt.has(te)||!(x(z)?ee.contains(z):ee.contains(z.nodes[0]))||(pe(te,z),x(te)&&be(te,z))}};pe(W,X),x(W)&&be(W,X),V.push(W),D.push(X)}function Nt(){let W=new Map;for(let X of new Set(D)){if(T.has(X))continue;let pe=n(X).hash;W.has(pe)||W.set(pe,[]),W.get(pe).push(X)}return W}function Lt(){for(;y.length;){let[W,X]=y.shift();v.get(W)!==X||R.has(W)||M.has(W)||cn(W,X)}}function qt(W,X){if(!ae(W))for(let pe of s(W))x(pe)&&(X.push(pe),qt(pe,X))}function cn(W,X){R.add(W);let pe=s(W),be=s(X);as.align+=pe.length+be.length,J=new Map,H=new Map;for(let ne=0;ne<pe.length;ne++)J.set(pe[ne],ne);for(let ne=0;ne<be.length;ne++)H.set(be[ne],ne);if(W.tagName==="HTML")for(let ne of["HEAD","BODY"]){let Te=pe.find(Pe=>x(Pe)&&Pe.tagName===ne),Ce=be.find(Pe=>x(Pe)&&Pe.tagName===ne);Te&&Ce&&!v.has(Te)&&!T.has(Ce)&&q(Te,Ce)}for(let ne=0;ne<pe.length&&ne<be.length;ne++){let Te=pe[ne],Ce=be[ne];v.has(Te)||T.has(Ce)||(x(Te)?x(Ce)&&Te.tagName===Ce.tagName&&Ee(Te,Ce)&&Yt(Te,Ce):!x(Ce)&&Te.kind===Ce.kind&&Te.value===Ce.value&&Yt(Te,Ce))}le(pe,be);let he=pe.filter(ne=>!v.has(ne)),ee=be.filter(ne=>!T.has(ne));he.length&&ee.length&&(wn(he,ee),P(he,ee),K(he,ee,pe,be),de(pe,be));let te=!1,z=!1;for(let ne of pe){if(!v.has(ne)){x(ne)&&(V.push(ne),qt(ne,V),te=!0);continue}x(ne)&&!M.has(ne)&&y.push([ne,v.get(ne)])}for(let ne of be)!T.has(ne)&&x(ne)&&(D.push(ne),qt(ne,D),z=!0);te&&z&&j.push([W,X])}function It(W,X){for(let pe=W;pe<X;pe++){let[be,he]=j[pe];if(v.get(be)!==he)continue;let ee=s(be),te=s(he),z=new Map,ne=new Map,Te=null;for(let Ce of ee)x(Ce)&&(v.has(Ce)?Te=Ce:(z.has(Te)||z.set(Te,[]),z.get(Te).push(Ce)));Te=null;for(let Ce of te)x(Ce)&&(T.has(Ce)?Te=T.get(Ce):(ne.has(Te)||ne.set(Te,[]),ne.get(Te).push(Ce)));for(let[Ce,Pe]of z){let ve=ne.get(Ce);if(!(!ve||Pe.length!==ve.length)&&Pe.every((_e,Je)=>ve[Je].tagName===_e.tagName&&De(_e,ve[Je])&&!Y(_e,ve[Je])))for(let _e=0;_e<Pe.length;_e++)Gt(Pe[_e],ve[_e])}}}function Gt(W,X){q(W,X),A.add(W),y.push([W,X]),Lt()}function wn(W,X){let pe=io(W,h),be=io(X,h),he=new Map;for(let ee of X){let te=h(ee);be.get(te)===1&&he.set(te,ee)}for(let ee of W){if(v.has(ee))continue;let te=h(ee);if(pe.get(te)!==1)continue;let z=he.get(te);z&&!T.has(z)&&u(ee,z)&&Yt(ee,z)}}function Dt(W,X,pe){let be=[[W,X]];for(;be.length;){let[he,ee]=be.pop();if(as.certifyVisited++,f&&f.certificationVisited++,he.nodeType!==ee.nodeType)return!1;if(he.nodeType===3||he.nodeType===8){if(he.nodeValue!==ee.nodeValue)return!1;continue}if(he.nodeType!==1){if(!he.isEqualNode(ee))return!1;continue}if(he.tagName!==ee.tagName||he.namespaceURI!==ee.namespaceURI||w(he)!==w(ee))return!1;let te=he.attributes,z=ee.attributes;if(te.length!==z.length)return!1;for(let ve=0;ve<te.length;ve++){let _e=te[ve];if(ee.getAttributeNS(_e.namespaceURI,_e.localName)!==_e.value)return!1}let ne=v.get(he);if(ne!==void 0&&ne!==ee)return!1;let Te=T.get(ee);if(Te!==void 0&&Te!==he)return!1;if(he!==W){if(M.has(he))continue;if(pe.has(he))return!1}let Ce=i(he),Pe=i(ee);if(Ce.length!==Pe.length)return!1;as.certifyScheduled+=Ce.length;for(let ve=Ce.length-1;ve>=0;ve--)be.push([Ce[ve],Pe[ve]])}return!0}function rn(W,X){return!x(W)||!(Me.has(W)||Oe.has(X))?!0:!!$(W,X)||!(Ne(W)||nt(X))}function Yt(W,X){if(x(W)&&(Me.has(W)||Oe.has(X))){let pe=$(W,X);if(!pe){if(Ne(W)||nt(X))return;q(W,X),y.push([W,X]);return}for(let be=0;be<pe.length;be+=2){let he=pe[be],ee=pe[be+1],te=v.get(he);te!==void 0&&te!==ee&&fn(he,te);let z=T.get(ee);z!==void 0&&z!==he&&fn(z,ee),v.get(he)===ee&&(N.delete(he),A.delete(he),M.add(he),R.add(he))}}a(W,X)}function fn(W,X){v.delete(W),T.delete(X),N.delete(W),M.delete(W),A.delete(W),R.delete(W)}function $(W,X){let pe=[W,X,!1],be=[];for(;pe.length;){let he=pe.pop(),ee=pe.pop(),te=pe.pop(),z=v.get(te),ne=T.get(ee);if(te!==W&&(z!==void 0&&z!==ee&&rt.has(te)||ne!==void 0&&ne!==te&&rt.has(ne)))return null;if(!(z===ee&&M.has(te))&&((z!==void 0||ne!==void 0)&&be.push(te,ee),!!x(te))){if(he||z!==void 0&&z!==ee||ne!==void 0&&ne!==te){let Te=s(te),Ce=s(ee);for(let Pe=0;Pe<Te.length&&Pe<Ce.length;Pe++)pe.push(Te[Pe],Ce[Pe],!0)}else if(Me.has(te)||Oe.has(ee)){let Te=te.tagName==="TEMPLATE"?te.content:te,Ce=ee.tagName==="TEMPLATE"?ee.content:ee;for(let Pe=Te.firstElementChild,ve=Ce.firstElementChild;Pe&&ve;){if(w(Pe)){Pe=Pe.nextElementSibling;continue}if(w(ve)){ve=ve.nextElementSibling;continue}(v.has(Pe)||T.has(ve)||Me.has(Pe)||Oe.has(ve))&&pe.push(Pe,ve,!1),Pe=Pe.nextElementSibling,ve=ve.nextElementSibling}}}}return be}function a(W,X){q(W,X),M.add(W),x(W)&&R.add(W)}function O(W){let X=v.get(W);if(!X||!x(W))return;let pe=s(W),be=s(X);for(let he=0;he<pe.length&&he<be.length;he++)v.has(pe[he])||a(pe[he],be[he])}function P(W,X){let pe=te=>x(te)&&!ae(te)?n(te).sig+""+n(te).hint:null,be=io(W,pe),he=io(X,pe),ee=new Map;for(let te of X){let z=pe(te);z!=null&&he.get(z)===1&&ee.set(z,te)}for(let te of W){if(v.has(te))continue;let z=pe(te);if(z==null||be.get(z)!==1)continue;let ne=ee.get(z);ne&&!T.has(ne)&&De(te,ne)&&q(te,ne)}}function K(W,X,pe,be){let he=new Map;for(let te of X){if(!x(te)||T.has(te)||ae(te))continue;let z=n(te).sig;he.has(z)||he.set(z,[]),he.get(z).push({el:te,index:H.get(te)})}let ee=[];for(let te of W){if(v.has(te)||!x(te)||ae(te))continue;let z=he.get(n(te).sig);if(!z||!z.length)continue;let ne=J.get(te),Te=z.filter(Ce=>!T.has(Ce.el)).map(Ce=>({c:Ce,d:Math.abs(Ce.index-ne)}));Te.sort((Ce,Pe)=>Ce.d-Pe.d),Te.length>Fs&&(Te=Te.slice(0,Fs));for(let{c:Ce,d:Pe}of Te){if(!De(te,Ce.el))continue;let ve=r(te,Ce.el);ve&&ve.coef>=.5&&ee.push({b:te,s:Ce.el,coef:ve.coef,share:ve.share,d:Pe,bi:ne})}}if(ee.sort((te,z)=>z.coef-te.coef||z.share-te.share||te.d-z.d||te.bi-z.bi),f&&ee.length>1){let te=new Map;for(let z of ee){let ne=te.get(z.b);ne?ne.coef===z.coef&&(ne.share===z.share?ne.strict++:ne.loose++):te.set(z.b,{coef:z.coef,share:z.share,strict:0,loose:0})}for(let[z,ne]of te)g.has(z)||!(ne.strict||ne.loose)||(g.add(z),ne.strict?f.similarTiesStrict++:f.similarTiesLoose++)}for(let te of ee)!v.has(te.b)&&!T.has(te.s)&&q(te.b,te.s)}function Z(W,X){return x(W)!==x(X)?!1:x(W)?W.tagName!==X.tagName||!De(W,X)?!1:ae(W)||n(W).hint===""||n(X).hint===""?!0:l(W,X):W.kind===X.kind}function U(W,X){let pe=(he,ee)=>{let te=ee===null?-1:he===X?H.get(ee):J.get(ee),z=he[te+1];return z&&!x(z)?z:null},be=null;for(let he of W){if(x(he)){be=he;continue}if(v.has(he))continue;let ee=be===null?null:v.get(be);if(be!==null&&!ee)continue;let te=pe(X,ee);te&&!T.has(te)&&te.kind===he.kind&&q(he,te)}}function de(W,X){U(W,X);let pe=we(W,X),be=(ee,te)=>x(ee)&&n(ee).hint!==""&&n(te).hint===""&&!!te.querySelector("br")&&!pe(ee,te),he=0;for(let ee of W){if(v.has(ee)){let z=H.get(v.get(ee));z!==void 0&&z>=he&&(he=z+1);continue}let te=0;for(let z=he;z<X.length&&te<pi;z++){let ne=X[z];if(!T.has(ne)&&(te++,Z(ee,ne)&&!Y(ee,ne)&&!be(ee,ne))){q(ee,ne),x(ee)&&(n(ee).hint===""||n(ne).hint==="")&&A.add(ee),he=z+1;break}}}le(W,X)}function we(W,X){let pe=(be,he,ee)=>{for(let te=he-1;te>=0;te--)if(x(be[te])&&ee(be[te]))return be[te];return null};return(be,he)=>{let ee=J.get(be),te=H.get(he);if(ee===te)return!0;let z=pe(W,ee,Te=>v.has(Te)),ne=pe(X,te,Te=>T.has(Te));return z?v.get(z)===ne:!ne}}function le(W,X){let pe=W.filter(z=>x(z)&&!v.has(z)),be=X.filter(z=>x(z)&&!T.has(z));if(!pe.length||!be.length)return;let he=io(pe,z=>z.tagName),ee=io(be,z=>z.tagName),te=we(W,X);for(let z of pe){let ne=z.tagName;if(he.get(ne)!==1||ee.get(ne)!==1)continue;let Te=be.find(Ce=>Ce.tagName===ne);Te&&!T.has(Te)&&te(z,Te)&&De(z,Te)&&!Y(z,Te)&&(u(z,Te)?Yt(z,Te):(q(z,Te),A.add(z)))}}function Ae(){let W=new Map;for(let z of A)if(x(z)&&x(v.get(z))){let ne=n(z).hash;W.has(ne)||W.set(ne,[]),W.get(ne).push(z)}if(W.size)for(let z of D){if(T.has(z)||!x(z)||fe(z))continue;let ne=W.get(n(z).hash),Te=ne&&ne.find(Ce=>A.has(Ce)&&!Y(Ce,z)&&De(Ce,z)&&Xe(Ce,z)&&u(Ce,z)&&rn(Ce,z));Te&&(wt(Te),Yt(Te,z),xe(Te,z),N.add(Te))}let X=new Map,pe=new Map,be=new Map;for(let z of A){let ne=v.get(z);x(z)&&x(ne)&&be.set(ne,z)}let he=(z,ne)=>{if(!T.has(z))return!fe(z);let Te=be.get(z);return Te===T.get(z)&&Te!==ne&&!Te.contains(ne)},ee=z=>{if(T.has(z)){let ne=be.get(z);be.delete(z),wt(ne)}};for(let z of[...D,...be.keys()]){if(T.has(z)&&!be.has(z))continue;let ne=n(z).hash;if(X.has(ne)||X.set(ne,[]),X.get(ne).push(z),ae(z))continue;let Te=n(z).sig;pe.has(Te)||pe.set(Te,[]),pe.get(Te).push(z)}let te=new Set;for(let z of A){let ne=v.get(z);!x(z)||!x(ne)||ae(z)||n(z).hint===""||n(ne).hint===""||l(z,ne)||te.add(z)}for(let z of[...V,...te]){let ne=v.get(z);if(ne?!(A.has(z)&&te.has(z)):qe(z))continue;let Te=Je=>{ne&&wt(z),ee(Je)},Ce=X.get(n(z).hash);if(Ce){let Je=Ce.find(Ze=>Ze!==ne&&he(Ze,z)&&!Y(z,Ze)&&Xe(z,Ze)&&u(z,Ze)&&rn(z,Ze));if(Je){Te(Je),Yt(z,Je),xe(z,Je),N.add(z);continue}}if(ae(z)||k<=0)continue;let Pe=pe.get(n(z).sig);if(!Pe)continue;let ve=null,_e=0;for(let Je of Pe)if(!(Je===ne||!he(Je,z)||!De(z,Je)||!Xe(z,Je)||Y(z,Je))&&(k--<=0||l(z,Je)&&(_e++,ve=Je,_e>1)))break;_e>1&&I&&I.add(z),_e===1&&(Te(ve),q(z,ve),xe(z,ve),N.add(z),y.push([z,ve]))}}}function io(e,o){let t=new Map;for(let n of e){let s=o(n);s!=null&&t.set(s,(t.get(s)||0)+1)}return t}var mi={diff:0},_s=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(_s){let t=[];for(let n of _s.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,Gn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),kt="",fs=e=>e.every(o=>Gn(o)||o.k===kt),Ti=/^[\x00-\x7f\u00A0]*$/,vi=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function Si(e){return e===""?[]:e.match(vi)}function an(e,o=!1){return(o?Si(e):yi(e)).map(t=>({k:xi(t),raw:t,len:t.length}))}var xn=(...e)=>e.every(o=>Ti.test(o));function us(e,o,t){let n=e.length,s=o.length,h=Math.min(n+s,t),l=h+1,r=new Int32Array(2*h+3),i=[],u=n===0&&s===0;for(let b=0;b<=h&&!u;b++){i.push(r.slice(l-b,l+b+1));for(let S=-b;S<=b;S+=2){let C;S===-b||S!==b&&r[l+S-1]<r[l+S+1]?C=r[l+S+1]:C=r[l+S-1]+1;let m=C-S,f=C;for(;C<n&&m<s&&e[C].k===o[m].k;)C++,m++;if(mi.diff+=1+C-f,r[l+S]=C,C>=n&&m>=s){u=!0;break}}}if(!u)return null;let w=[],c=n,p=s;for(let b=i.length-1;b>0;b--){let S=i[b],C=c-p,m=C+b,f=C===-b||C!==b&&S[m-1]<S[m+1]?C+1:C-1,g=S[f+b],I=g-f;for(;c>g&&p>I;)w.push([0,c-1,p-1]),c--,p--;c===g?(w.push([1,c,p-1]),p--):(w.push([-1,c-1,p]),c--)}for(;c>0&&p>0;)w.push([0,c-1,p-1]),c--,p--;return w.reverse(),w}function Ni(e,o,t){let n=c=>c.k===kt;if(!e.some(n)&&!o.some(n))return us(e,o,t);let s=[],h=[];for(let c=0;c<e.length;c++)n(e[c])||s.push(c);for(let c=0;c<o.length;c++)n(o[c])||h.push(c);let l=us(s.map(c=>e[c]),h.map(c=>o[c]),t);if(!l)return null;let r=[],i=0,u=0,w=(c,p)=>{for(;i<c&&u<p&&e[i].k===o[u].k;)r.push([0,i++,u++]);let b=us(e.slice(i,c),o.slice(u,p),t);if(!b)return!1;for(let[S,C,m]of b)r.push([S,C+i,m+u]);return i=c,u=p,!0};for(let[c,p,b]of l)if(c===0){if(!w(s[p],h[b]))return null;r.push([0,i,u]),i++,u++}return w(e.length,o.length)?r:null}function Wn(e,o,t=4e3){let n=[],s=0;for(;s<e.length&&s<o.length&&e[s].k===o[s].k;)e[s].raw!==o[s].raw&&n.push({bi:s,tok:o[s]}),s++;let h=0;for(;h<e.length-s&&h<o.length-s&&e[e.length-1-h].k===o[o.length-1-h].k;)e[e.length-1-h].raw!==o[o.length-1-h].raw&&n.push({bi:e.length-1-h,tok:o[o.length-1-h]}),h++;let l=e.slice(s,e.length-h),r=o.slice(s,o.length-h),i=Li(l,r)?null:Ni(l,r,t);if(!i){let f=l.length||r.length?[{bs:s,be:s+l.length,toks:r}]:[];return{hunks:f,cosmetic:n,coarse:!0,parts:f.map(g=>({...g,gap:[],group:0})),cosmeticEq:n}}let u=[],w=(f,g)=>{l[f].raw!==r[g].raw&&n.push({bi:s+f,tok:r[g]})},c=null,p=[],b=0,S=0,C=()=>{c&&u.push(c),c=null;for(let[f,g]of p)w(f,g);p=[],b++};for(let[f,g,I]of i){if(f===0){c&&Gn(l[g])&&!l[g].k.includes(`
|
|
2
|
+
`)?p.push([g,I]):(C(),w(g,I)),S=g+1;continue}(!c||p.length)&&(c&&u.push(c),c={bs:s+S,be:s+S,toks:[],gap:p.map(([v,T])=>({bi:s+v,tok:r[T]})),group:b},p=[]),f===-1?(c.be=s+S+1,S=g+1):c.toks.push(r[I])}C(),Ai(u,e);let m=hs(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===kt&&o[n.bs].k===kt;)n.toks=[...n.toks.slice(1),n.toks[0]],n.bs++,n.be++}else for(;n.be+1<s&&n.be<o.length&&o[n.bs].k===kt&&o[n.be].k===kt;)n.bs++,n.be++}}function hs(e,o=()=>!1){let t=[],n=[],s=null,h=-1;for(let l of e){let r=o(l);if(s&&!s.alone&&!r&&l.group===h){s.be=l.be;for(let i of l.gap)s.toks.push(i.tok);for(let i of l.toks)s.toks.push(i);continue}s&&t.push({bs:s.bs,be:s.be,toks:s.toks});for(let i of l.gap)n.push(i);s={bs:l.bs,be:l.be,toks:l.toks.slice(),alone:r},h=l.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&&gs(e.toks,o.toks);function ms(e,o,t){let n=w=>c=>w.some(p=>Mi(c,p)),s=hs(e.parts,n(o.parts)),h=hs(o.parts,n(e.parts)),l=e.cosmeticEq.concat(s.cosmetic),r=o.cosmeticEq.concat(h.cosmetic),[i,u]=t?Oi(s.hunks,h.hunks,t,l,r):[s.hunks,h.hunks];return{lh:i,rh:u,cosL:l,cosR:r}}function Oi(e,o,t,n,s){let h=(S,C)=>S.k===C.k&&S.raw===C.raw,l=[{list:e.map(S=>({...S})),resp:new Set(n.map(S=>S.bi)),raw:new Map(n.map(S=>[S.bi,S.tok]))},{list:o.map(S=>({...S})),resp:new Set(s.map(S=>S.bi)),raw:new Map(s.map(S=>[S.bi,S.tok]))}],r=S=>S.bs===S.be,i=(S,C,m,f)=>{let g=S.list[C];if(!r(g))return f(g)===m?g.toks:null;let I=C?S.list[C-1].be:0,v=C+1<S.list.length?S.list[C+1].bs:t.length;if(m<I||m>v)return null;let T=g.toks,A=g.bs;for(;A>m;){let E=T[T.length-1];if(!h(E,t[A-1])||S.resp.has(A-1))return null;T=[E,...T.slice(0,-1)],A--}for(;A<m;){if(!h(T[0],t[A])||S.resp.has(A))return null;T=[...T.slice(1),T[0]],A++}return T},u=(S,C,m,f,g,I)=>{let v=S.list[C],T=g?m.slice(m.length-f):m.slice(0,f),A=g?m.slice(0,m.length-f):m.slice(f),E={bs:I,be:I,toks:T};if(r(v)){if(!A.length){S.list[C]=E;return}let M={bs:I,be:I,toks:A};g&&(M.lead=!0),S.list.splice(C,1,...g?[M,E]:[E,M]);return}let N={bs:v.bs,be:v.be,toks:A};S.list.splice(C,1,...g?[N,E]:[E,N])},w=(S,C,m,f,g)=>{let I=S.list[C],v=g?m.slice(m.length-f):m.slice(0,f),T=g?m.slice(0,m.length-f):m.slice(f),A={bs:I.bs,be:I.be,toks:v};if(!T.length){S.list[C]=A;return}let E=g?{bs:I.bs,be:I.bs,toks:T,lead:!0}:{bs:I.be,be:I.be,toks:T};S.list.splice(C,1,...g?[E,A]:[A,E])},c=(S,C,m,f)=>{let g=S.list[C],I=m.list[f],v=g.be,T=I.bs;if(v>=T||C+1<S.list.length&&S.list[C+1].bs<=I.be||f>0&&m.list[f-1].be>=g.bs)return!1;for(let H=v;H<T;H++)if(!Gn(t[H])||t[H].k.includes(`
|
|
3
|
+
`))return!1;let A=H=>t.slice(v,T).map((q,Me)=>H.raw.get(v+Me)||q),E=[...g.toks,...A(S)],N=[...A(m),...I.toks],M=(H,q,Me)=>q>=0&&q+Me.length<=H.length&&Me.every((Oe,Re)=>H[q+Re].k===Oe.k),R=(H,q,Me)=>fs(H)&&t.slice(q,Me).some(Oe=>!Gn(Oe)),V=H=>H.some(q=>!Gn(q)),D,j,y,k;if(r(g)&&V(g.toks)&&M(N,0,g.toks)){let H=N.slice(g.toks.length);R(H,v,I.be)||(D=v,j=g.toks,y=N.slice(0,g.toks.length),k=[null,{bs:v,be:I.be,toks:H}])}if(D===void 0&&r(I)&&V(I.toks)){let H=E.length-I.toks.length,q=E.slice(0,H);M(E,H,I.toks)&&!R(q,g.bs,T)&&(D=T,j=E.slice(H),y=I.toks,k=[{bs:g.bs,be:T,toks:q},null])}if(D===void 0)return!1;let J=H=>H&&(H.bs<H.be||H.toks.length);return S.list.splice(C,1,...[k[0],{bs:D,be:D,toks:j}].filter(J)),m.list.splice(f,1,...[{bs:D,be:D,toks:y},k[1]].filter(J)),!0},p=l[0],b=l[1];for(let S=0;S<64;S++){let C=!1;e:for(let m=0;m<p.list.length;m++)for(let f=0;f<b.list.length;f++){let g=p.list[m],I=b.list[f];if(!(g.bs===I.bs&&g.be===I.be&&gs(g.toks,I.toks))){for(let v of[!0,!1]){let T=E=>v?E.be:E.bs,A=r(g)?[T(I),g.bs]:[T(g)];for(let E of A){let N=i(p,m,E,T),M=N&&i(b,f,E,T);if(!M)continue;let R=(k,J)=>v?k[k.length-1-J]:k[J],V=0;for(;V<N.length&&V<M.length&&R(N,V).k===R(M,V).k;)V++;if(!V)continue;let D=v?N.slice(0,N.length-V):N.slice(V),j=v?M.slice(0,M.length-V):M.slice(V);if(!(V<N.length&&V<M.length&&!fs(D)&&!fs(j)&&(r(g)&&r(I)||g.bs===I.bs&&g.be===I.be)||!(v?N.slice(N.length-V):N.slice(0,V)).some(k=>!Gn(k)))){if(V===N.length&&V===M.length&&r(g)&&r(I)){if(g.bs===E&&I.bs===E)continue;p.list[m]={bs:E,be:E,toks:N},b.list[f]={bs:E,be:E,toks:M}}else!r(g)&&g.bs===I.bs&&g.be===I.be?(w(p,m,N,V,v),w(b,f,M,V,v)):(u(p,m,N,V,v,E),u(b,f,M,V,v,E));C=!0;break e}}}if(c(p,m,b,f)||c(b,f,p,m)){C=!0;break e}}}if(!C)break}return[p.list,b.list]}var Ii=48,Ci=.3;function Li(e,o){let t=e.filter(l=>!Gn(l)),n=o.filter(l=>!Gn(l));if(Math.min(t.length,n.length)<Ii)return!1;let s=new Map;for(let l of t)s.set(l.k,(s.get(l.k)||0)+1);let h=0;for(let l of n){let r=s.get(l.k);r>0&&(h++,s.set(l.k,r-1))}return h/Math.min(t.length,n.length)<Ci}var Ei=(e,o)=>{let t=new Set;for(let n of e.toks)typeof n.k!="string"&&t.add(n.k.el);for(let n=e.bs;n<e.be;n++)typeof o[n].k!="string"&&t.add(o[n].k.el);return t},gs=(e,o)=>e.length===o.length&&e.every((t,n)=>t.k===o[n].k);function zs(e,o,t,n="remote"){let s=Wn(e,o),h=Wn(e,t),{lh:l,rh:r,cosL:i,cosR:u}=ms(s,h,e),w=x=>x.bs===x.be,c=x=>x.toks.some(Y=>typeof Y.k=="string"),p=x=>w(x)&&!c(x),b=(x,Y)=>Y.bs<x.be&&x.bs<Y.be,S=(x,Y)=>!b(x,Y)&&Y.bs<=x.be&&x.bs<=Y.be&&(w(x)&&c(x)||w(Y)&&c(Y))&&!(w(x)&&w(Y)),C=(x,Y)=>x.bs===Y.bs&&x.be===Y.be&&gs(x.toks,Y.toks),m=[],f=new Set;for(let x of l){let Y=r.find(ae=>!f.has(ae)&&C(x,ae));Y?(f.add(Y),m.push({bs:x.bs,be:x.be,side:"both",l:x,r:Y,toks:x.toks})):m.push({bs:x.bs,be:x.be,side:"L",l:x,toks:x.toks,lead:!!x.lead})}for(let x of r)f.has(x)||m.push({bs:x.bs,be:x.be,side:"R",r:x,toks:x.toks,lead:!!x.lead});m.sort((x,Y)=>x.bs-Y.bs||x.be-Y.be||Y.lead-x.lead);let g=0,I=0;for(let x of m)x.side==="both"&&(g+=x.toks.length-(x.be-x.bs));let v=m.map((x,Y)=>Y),T=x=>v[x]===x?x:v[x]=T(v[x]),A=(x,Y)=>(x=T(x),Y=T(Y),x===Y?!1:(v[x]=Y,!0)),E=m.map(x=>Ei({bs:x.bs,be:x.be,toks:x.toks},e)),N={L:new Map,R:new Map};m.forEach((x,Y)=>{let ae=x.side==="both"?["L","R"]:[x.side];for(let oe of ae)for(let Ee of E[Y])N[oe].has(Ee)||N[oe].set(Ee,[]),N[oe].get(Ee).push(Y)});for(let x of[N.L,N.R])for(let Y of x.values())for(let ae=1;ae<Y.length;ae++)A(Y[0],Y[ae]);for(let x=0;x<m.length;x++)for(let Y=x+1;Y<m.length;Y++){let ae=m[x],oe=m[Y];ae.side===oe.side&&ae.side!=="both"||ae.bs>oe.be||(b(ae,oe)||S(ae,oe)?A(x,Y):ae.bs===oe.bs&&w(ae)&&w(oe)&&I++)}let M=(x,Y)=>{let ae=x==="L"?l:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="close"&&Ee.k.el===Y.el))return oe.bs;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return-1};m.forEach((x,Y)=>{if(!(!p(x)||x.side==="both"))for(let ae of x.toks){if(ae.kind!=="open")continue;let oe=M(x.side,ae.k);if(oe<=x.bs)continue;let Ee=new Uint8Array(oe-x.bs),De=[];if(m.forEach((Ne,nt)=>{if(!(Ne.side===x.side||w(Ne))&&Ne.bs<oe&&Ne.be>x.bs){De.push(nt);for(let Xe=Math.max(Ne.bs,x.bs);Xe<Math.min(Ne.be,oe);Xe++)Ee[Xe-x.bs]=1}}),De.length&&Ee.every(Ne=>Ne===1))for(let Ne of De)A(Y,Ne)}});let R=!0;for(;R;){R=!1;let x=new Map;m.forEach((Y,ae)=>{let oe=T(ae),Ee=x.get(oe)||{bs:Y.bs,be:Y.be,L:!1,R:!1};Ee.bs=Math.min(Ee.bs,Y.bs),Ee.be=Math.max(Ee.be,Y.be),Y.side!=="R"&&(Ee.L=!0),Y.side!=="L"&&(Ee.R=!0),x.set(oe,Ee)}),m.forEach((Y,ae)=>{for(let[oe,Ee]of x){if(T(ae)===T(oe)||!(Ee.L&&Ee.R))continue;let De=Y.bs<Ee.be&&Y.be>Ee.bs,Ne=w(Y)&&c(Y)&&(Y.bs===Ee.be||Y.bs===Ee.bs);(De||Ne)&&A(ae,oe)&&(R=!0)}})}let V=new Map;m.forEach((x,Y)=>{let ae=T(Y);V.has(ae)||V.set(ae,[]),V.get(ae).push(x)});let D=[];for(let x of V.values()){let Y=x.some(oe=>oe.side==="L"),ae=x.some(oe=>oe.side==="R");if(Y&&ae){let oe=Math.min(...x.map(nt=>nt.bs)),Ee=Math.max(...x.map(nt=>nt.be)),De=x.filter(nt=>nt.side!=="R").map(nt=>nt.l).sort((nt,Xe)=>nt.bs-Xe.bs),Ne=x.filter(nt=>nt.side!=="L").map(nt=>nt.r).sort((nt,Xe)=>nt.bs-Xe.bs);D.push({bs:oe,be:Ee,kind:"conflict",localHunks:De,remoteHunks:Ne})}else for(let oe of x)D.push({bs:oe.bs,be:oe.be,kind:oe.side,u:oe})}let j=(x,Y)=>{let ae=x==="L"?l:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="close"&&Ee.k.el===Y.el))return oe.bs+.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return 1/0},y=(x,Y)=>{let ae=x==="L"?l:r;for(let oe of ae)if(oe.toks.some(Ee=>Ee.kind==="open"&&Ee.k.el===Y.el))return oe.bs-.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="open"&&e[oe].k.el===Y.el)return oe;return-1/0},k=x=>x.kind==="R"?"R":"L",J=x=>x.kind==="R"?1:0;D.sort((x,Y)=>{if(x.bs!==Y.bs)return x.bs-Y.bs;let ae=x.bs===x.be,oe=Y.bs===Y.be;if(ae!==oe)return ae?-1:1;if(ae&&oe&&x.kind!=="conflict"&&Y.kind!=="conflict"){let De=x.u.toks,Ne=Y.u.toks,nt=ht=>ht.length&&ht.every(Ge=>Ge.kind==="open"),Xe=ht=>ht.length&&ht.every(Ge=>Ge.kind==="close");if(nt(De)&&nt(Ne)){let ht=Math.max(...De.map(rt=>j(k(x),rt.k))),Ge=Math.max(...Ne.map(rt=>j(k(Y),rt.k)));if(ht!==Ge)return Ge-ht}if(Xe(De)&&Xe(Ne)){let ht=Math.min(...De.map(rt=>y(k(x),rt.k))),Ge=Math.min(...Ne.map(rt=>y(k(Y),rt.k)));return ht!==Ge?Ge-ht:J(Y)-J(x)}}let Ee=De=>De.u&&De.u.lead?1:0;return Ee(Y)-Ee(x)||J(x)-J(Y)||x.be-Y.be});let H=[],q=[],Me=0,Oe=x=>{x>Me&&(H.push({bs:Me,be:x,toks:e.slice(Me,x),source:"base"}),Me=x)};for(let x of D){if(Oe(x.bs),x.kind==="conflict"){let Y=ps(e,x.localHunks,x.bs,x.be),ae=ps(e,x.remoteHunks,x.bs,x.be),oe=n==="local"?Y:n==="both"?Y.concat(ae):ae,Ee=(nt,Xe)=>{let ht=0;for(let Ge of nt)Ge.be<=x.bs&&!Xe.includes(Ge)&&(ht+=Ge.toks.length-(Ge.be-Ge.bs));return ht},De=x.bs+Ee(l,x.localHunks),Ne=x.bs+Ee(r,x.remoteHunks);q.push({bs:x.bs,be:x.be,ls:De,le:De+Y.length,rs:Ne,re:Ne+ae.length,ms:0,me:0,base:e.slice(x.bs,x.be),local:Y,remote:ae,resolved:oe}),H.push({bs:x.bs,be:x.be,toks:oe,source:"conflict",localHunks:x.localHunks,localToks:Y,keepsLocal:n!=="remote"})}else H.push({bs:x.bs,be:x.be,toks:x.u.toks,source:x.kind==="R"?"remote":"local",localHunks:x.kind==="R"?[]:[x.u.l]});Me=Math.max(Me,x.be)}Oe(e.length);let Re=0,ie=0;for(let x of H)x.source==="conflict"&&(q[ie].ms=Re,q[ie].me=Re+x.toks.length,ie++),Re+=x.toks.length;let xe=new Map(i.map(x=>[x.bi,x.tok])),qe=new Map(u.map(x=>[x.bi,x.tok])),fe=[];for(let x of H){x.source==="base"&&(x.toks=x.toks.map((Y,ae)=>{let oe=x.bs+ae,Ee=xe.get(oe),De=qe.get(oe),Ne=Ee&&De?n==="remote"?De:Ee:Ee||De||Y;return Ne===Y?Y:{...Ne,cosmetic:!0}}));for(let Y of x.toks)fe.push({...Y,src:x.source})}return{tokens:fe,segments:H,conflicts:q,localHunks:l,remoteHunks:r,collapsedDelta:g,samePoint:I,mapLocalOffset:Ri(e,l,H)}}function ps(e,o,t,n){let s=[],h=t;for(let l of o)s=s.concat(e.slice(h,l.bs),l.toks),h=l.be;return s.concat(e.slice(h,n))}var ds=e=>e.reduce((o,t)=>o+t.len,0);function Ri(e,o,t){let n=new Int32Array(e.length+1);for(let l=0;l<e.length;l++)n[l+1]=n[l]+e[l].len;let s=o.map(l=>({bs:n[l.bs],be:n[l.be],text:l.toks.map(r=>r.raw).join(""),ref:l})),h=t.map(l=>({bs:n[l.bs],be:n[l.be],len:ds(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?ds(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let r=null,i=null,u=0,w=0,c=0;for(let b of s){let S=b.bs-c;if(l<=w+S){r=c+(l-w);break}if(w+=S,c=b.bs,l<=w+b.text.length){i=b,u=l-w,r=b.bs;break}w+=b.text.length,c=b.be}r===null&&(r=c+(l-w));let p=0;for(let b of h){if(!i&&r<=b.bs)return p;if(!(i?b.localHunks.includes(i.ref):r<b.be)){p+=b.len;continue}if(b.source==="base")return p+(r-b.bs);if(b.source==="remote")return p+b.len;if(b.source==="local")return p+Math.min(u,b.len);if(!b.keepsLocal||!i)return p+b.len;let C=b.localHunks.indexOf(i.ref),m=ds(ps(e,b.localHunks.slice(0,C),b.ref.bs,i.ref.bs));return p+Math.min(m+u,b.localLen)}return p}}function lo(e,o,t,n="remote"){if(o===t||t===e)return{text:o,conflicts:[],mapLocalOffset:f=>Math.min(f,o.length),granularity:"word"};let s=xn(e,o,t),h=an(e,s),l=an(o,s),r=an(t,s),i=h.length<=2e4&&l.length<=2e4&&r.length<=2e4?zs(h,l,r,n):null,u="word",w=h;if(!i){let f=g=>g.split(/(?<=\n)/).map(I=>({k:I,raw:I,len:I.length}));w=f(e),i=zs(w,f(o),f(t),n),u="line"}let c=f=>f.map(g=>g.raw).join(""),p=f=>{let g=[0];for(let I of f)g.push(g[g.length-1]+I.len);return g},b=p(w),S=null,C=null,m=null;if(i.conflicts.length){let f=g=>g.split(/(?<=\n)/).map(I=>({k:I,raw:I,len:I.length}));S=p(u==="line"?f(o):l),C=p(u==="line"?f(t):r),m=p(i.tokens)}return{text:c(i.tokens),conflicts:i.conflicts.map(f=>({bs:b[f.bs],be:b[f.be],ls:S[f.ls],le:S[f.le],rs:C[f.rs],re:C[f.re],ms:m[f.ms],me:m[f.me],base:c(f.base),local:c(f.local),remote:c(f.remote),resolved:c(f.resolved)})),mapLocalOffset:i.mapLocalOffset,granularity:u}}function Yn(e,o,t=4e3){if(e===o)return[];let n=xn(e,o),s=an(e,n),h=an(o,n),l=Wn(s,h,t),r=[0];for(let i of s)r.push(r[r.length-1]+i.len);return l.hunks.map(i=>({bs:r[i.bs],be:r[i.be],text:i.toks.map(u=>u.raw).join("")}))}function $t(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Dn({base:e,side:o,retained:t,transfers:n,baseAtomKey:s=r=>r.el,sideAtomKey:h=r=>r.el,budget:l=$t()}){let r=[],i=T=>({status:"fallback",reason:T}),u=T=>T>l.remaining?!1:(l.remaining-=T,!0);if(!u((t.length+n.length)*3))return i("work-limit");for(let[T,A]of[["retained",t],["transfer",n]])for(let E of A){let{from:N,to:M,target:R}=E;if(!Number.isInteger(N)||!Number.isInteger(M)||!Number.isInteger(R)||N<0||M<=N||M>e.text.length||R<0||R+M-N>o.text.length)return i("invalid-range");r.push({...E,kind:T})}let w=Symbol(),c=T=>(A,E)=>{if(!u(1))throw w;return l.sortComparisons++,T(A,E)},p,b;try{p=r.slice().sort(c((T,A)=>T.from-A.from||T.to-A.to)),b=r.slice().sort(c((T,A)=>T.target-A.target||T.to-T.from-(A.to-A.from)))}catch(T){if(T===w)return i("work-limit");throw T}if(!u(r.length*2))return i("work-limit");for(let T=1;T<p.length;T++)if(p[T].from<p[T-1].to)return i("source-overlap");for(let T=1;T<b.length;T++)if(b[T].target<b[T-1].target+b[T-1].to-b[T-1].from)return i("target-overlap");for(let T of p){let A=T.to-T.from;if(!u(A))return i("work-limit");for(let E=0;E<A;E++){let N=T.from+E,M=T.target+E;if(l.comparisons++,e.text[N]!==o.text[M])return i("unequal-occurrence");let R=e.atomAt.get(N),V=o.atomAt.get(M);if(!!R!=!!V||R&&s(R)!==h(V))return i("different-atom")}}let S=e.text.length+o.text.length+2,C=r.reduce((T,A)=>T+(A.to-A.from)*2,2);if(!u(S+C+r.length))return i("work-limit");let m=new Int32Array(e.text.length+1).fill(-1),f=new Int32Array(o.text.length+1).fill(-1);l.mapCells+=S,l.mapWrites+=C;let g=-1,I=!0;for(let T of p){T.target<g&&(I=!1),g=T.target+T.to-T.from;for(let A=0;A<T.to-T.from;A++)m[T.from+A]=T.target+A,f[T.target+A]=T.from+A}return m[e.text.length]=o.text.length,f[o.text.length]=e.text.length,{status:"ready",runs:p,bTo:m,toB:f,monotone:I,covers:(T,A)=>{if(!u(A-T))return null;l.coverageChecks+=A-T;for(let E=T;E<A;E++)if(e.text[E]!==kt&&!/\s/.test(e.text[E])&&m[E]<0)return!1;return!0}}}function bs({base:e,side:o,baseOf:t=()=>null,budget:n=$t()}){if(e.text===o.text||!e.text.includes(kt)&&!o.text.includes(kt))return{status:"none"};let s=(e.text.length+o.text.length)*8;if(s>n.remaining)return{status:"fallback",reason:"work-limit"};n.remaining-=s,n.boundarySteps=(n.boundarySteps||0)+s;let h=(S,C)=>C<S.length&&(S[C]===kt||/\s/.test(S[C])),l=new Map,r=Symbol(),i=(S,C)=>{let m=S.stackAt[C]||[];if(!l.has(m)){if(m.length>n.remaining)throw r;n.remaining-=m.length,n.boundarySteps+=m.length,l.set(m,m.find(f=>f.block)?.el||null)}return l.get(m)},u=[],w=(S,C)=>{let m=i(e,S),f=i(o,C),g=m&&f&&t(f)!==m?"transfer":"retained",I=u[u.length-1];I&&I.to===S&&I.target+I.to-I.from===C&&I.kind===g&&I.destination===f?I.to++:u.push({from:S,to:S+1,target:C,destination:f,kind:g})},c=0,p=0,b=!1;try{for(;c<e.text.length||p<o.text.length;){if(c<e.text.length&&p<o.text.length&&e.text[c]===o.text[p]){let I=e.atomAt.get(c),v=o.atomAt.get(p);if(!!I!=!!v||I&&t(v.el)!==I.el)return{status:"none"};w(c++,p++);continue}if(!h(e.text,c)&&!h(o.text,p))return{status:"none"};let S=c,C=p;for(;h(e.text,c);)c++;for(;h(o.text,p);)p++;let m=e.text.slice(S,c),f=o.text.slice(C,p);(m.includes(kt)||f.includes(kt))&&(b=!0);let g=0;for(;g<c-S&&g<p-C&&e.text[c-g-1]===o.text[p-g-1];)g++;for(let I=g;I>0;I--)w(c-I,p-I)}}catch(S){if(S===r)return{status:"fallback",reason:"work-limit"};throw S}return b?Dn({base:e,side:o,retained:u.filter(S=>S.kind==="retained"),transfers:u.filter(S=>S.kind==="transfer"),sideAtomKey:S=>t(S.el)||S.el,budget:n}):{status:"none"}}var $s=/\s/,Vo=/\S/;function In(e,o,t,n,s,h,l=-1,r=-1){if(!e.length)return-1;s(n,e.length);let i=new Int32Array(e.length),u=0;for(let b=1;b<e.length;b++){for(s(n,1);u&&(s(n,1),e[u]!==e[b]);)u=i[u-1];s(n,1),e[u]===e[b]&&u++,i[b]=u}let w=-1,c=0,p=0;u=0;for(let b=0;b<o.length;b++){for(s(n,1);u&&(s(n,1),e[u]!==o[b]);)u=i[u-1];if(s(n,1),e[u]===o[b]&&u++,u!==e.length)continue;let S=b+1-e.length,C=b+1;for(u=i[u-1];c<t.length&&t[c].from<S;)s(n,1),c++;for(;p<t.length&&t[p].to<C;)s(n,1),p++;if(s(n,6),!(c===t.length||p===t.length||t[c].from!==S||t[p].to!==C||l>=0&&S<r&&C>l)){if(!h)return S;if(w>=0)return-1;w=S}}return w}function No(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function ws(e,o,t,n){let s=null;for(let l of o)if(n(t,1),!(l.source!==e.source||l.side!==e.side))for(let r of l.runs){if(n(t,1),r.source!==e.source)continue;let i=Math.max(e.from,r.from),u=Math.min(e.to,r.to);i>=u||(s||(n(t,e.to-e.from),s=new Uint8Array(e.to-e.from)),n(t,u-i),s.fill(1,i-e.from,u-e.from))}if(!s)return!1;n(t,e.to-e.from);let h=!1;for(let l=e.from;l<e.to;l++)if(Vo.test(e.flat.text[l])){if(!s[l-e.from])return!1;h=!0}return h}function ys({source:e,side:o,views:t,eligible:n,blocked:s,baseId:h,model:l,tokensOf:r,budget:i,charge:u}){let{V:w,A:c,idOf:p}=t[o],b=t[1-o];if(e.nodeType!==1||c.identical.has(e)||b.A.identical.has(e)||s.has(e)||!n(e))return null;let S=w.twin(e),C=b.V.twin(e);if(!S||!C||c.map.get(e)!==S||c.reverse.get(S)!==e||b.A.map.get(e)!==C||b.A.reverse.get(C)!==e||!w.here(S)||!b.V.here(C)||!n(S)||!n(C))return null;let m=h(e);if(m!==p(S)||m!==b.idOf(C))return null;let f=l(e,null,i),g=l(S,c,i),I=l(C,b.A,i);if(!No(f)||!No(g)||!No(I))return null;let v=f.flat.text,T=g.flat.text;if(u(i,v.length+T.length*3),!Vo.test(T)||T.length>=v.length)return null;let A=v.startsWith(T),E=v.endsWith(T);if(A===E)return null;let N=A?T.length:0,M=A?v.length:v.length-T.length,R=N,V=M;for(;R<V&&(u(i,1),!!$s.test(v[R]));)R++;for(;V>R&&(u(i,1),!!$s.test(v[V-1]));)V--;if(R===V)return null;let D=r(f,i),j=!1,y=!1;for(let k of D)u(i,1),k.from===R&&(j=!0),k.to===V&&(y=!0);return!j||!y?null:{source:e,side:o,flat:f.flat,from:N,to:M}}function Gs({base:e,views:o,side:t,attempt:n,eligible:s,blocked:h,baseId:l,model:r,tokensOf:i,certificates:u,charge:w,exhausted:c,limit:p}){if(p<=0)return null;let b=$t(p),{V:S,A:C,idOf:m}=o[t],f=o[1-t],[g,I,v,T]=n,A=null;try{for(let E=g;E<=I;E++){w(b,1);let N=e[E];if(N.nodeType!==1||C.identical.has(N)||f.A.identical.has(N)||h.has(N)||!s(N))continue;let M=ys({source:N,side:t,views:o,eligible:s,blocked:h,baseId:l,model:r,tokensOf:i,budget:b,charge:w});if(!M||ws(M,u,b,w))continue;let{flat:R,from:V,to:D}=M;w(b,(D-V)*2);let j=R.text.slice(V,D).trim();for(let y=v;y<=T;y++){w(b,1);let k=S.units[y],J=S.baseOf(k);if(!J||J===N||J.nodeType!==1||k.nodeType!==1||J.parentNode!==N.parentNode||k.parentNode!==C.map.get(N).parentNode||C.map.get(J)!==k||C.reverse.get(k)!==J||h.has(J)||!s(J)||!s(k)||l(J)!==m(k))continue;let H=r(J,null,b),q=r(k,C,b);if(!No(H)||!No(q))continue;let Me=H.flat.text,Oe=q.flat.text;if(w(b,Me.length),!Vo.test(Me)||Oe.length<=Me.length)continue;let Re=i(q,b),ie=In(Me,Oe,Re,b,w,!0);if(!(ie<0)&&!(In(j,Oe,Re,b,w,!1,ie,ie+Me.length)<0)){(A||=[]).push(M);break}}}}catch(E){if(E!==c)throw E}return A}function Ys(e,o,t,n,s,h,l){if(h==="both"||t.atoms.length||n.atoms.length||s.atoms.length)return h;let r=h==="remote";if(r?l.rss!==l.rse||l.lss===l.lse||l.local===l.base:l.lss!==l.lse||l.rss===l.rse||l.remote===l.base)return h;for(let i of e){if(i.source!==o||i.side!==(r?1:0)||i.flat.text!==t.text||i.flat.nodes.length!==t.nodes.length||l.be<=i.from||l.bs>=i.to)continue;let u=!0;for(let c=0;c<t.nodes.length;c++){let p=i.flat.nodes[c],b=t.nodes[c];if(p.node!==b.node||p.s!==b.s||p.e!==b.e){u=!1;break}}if(!u)continue;let w=!1;for(let c=l.bs;c<l.be;c++)if(Vo.test(t.text[c])){if(c<i.from||c>=i.to){u=!1;break}w=!0}if(u&&w)return r?"local":"remote"}return h}var Un="\uFFFC";var Pi={caret:0},Tn=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),or=new Set(["BR","WBR","IMG"]),ks=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)||or.has(e.tagName))return!0;if(!Tn.has(e.tagName))return!ks.has(e.tagName);if(o.remoteWins&&o.remoteWins(e))return!1;let t=o.inlineCache&&o.inlineCache.get(e);if(t!==void 0)return t;let n=!0;for(let s of e.childNodes)if(!Vn(s,o)){n=!1;break}return o.inlineCache&&o.inlineCache.set(e,n),n}function Bi(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function nn(e,o={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},n=(s,h)=>{for(let l of s){if(l.nodeType===3){let c=l.nodeValue;if(!c)continue;t.nodes.push({node:l,s:t.text.length,e:t.text.length+c.length}),t.text+=c;for(let p=0;p<c.length;p++)t.stackAt.push(h);continue}if(l.nodeType!==1)continue;if(o.ignored&&o.ignored(l)){t.pins.push({el:l,i:t.text.length});continue}if(o.skip&&o.skip.has(l))continue;let r=o.via&&o.via(l)||l;r!==l&&(t.via||(t.via=new Map)).set(r,l);let i=l.tagName;if(o.blocks&&o.blocks.has(l)){t.text.length&&t.text[t.text.length-1]!==kt&&(t.stackAt.push(h),t.text+=kt);let c={el:l,tag:i,from:t.text.length,to:-1,depth:h.length,block:!0};t.marks.push(c);let p=h.concat([c]);n(r.childNodes,p),t.stackAt.push(p),t.text+=kt,c.to=t.text.length;continue}let u=Tn.has(i)&&Bi(r);if(or.has(i)||!Tn.has(i)||o.remoteWins&&o.remoteWins(l)||o.atomize&&o.atomize(l)||u){t.atoms.push({i:t.text.length,el:l,key:u?i+":empty":i,stack:h}),t.stackAt.push(h),t.text+=Un;continue}let w={el:l,tag:i,from:t.text.length,to:-1,depth:h.length};t.marks.push(w),n(r.childNodes,h.concat([w])),w.to=t.text.length}};if(n(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&qo(t).trim()===""){let s=t.atoms[0];t.placeholder=s.el,t.text=t.text.slice(0,s.i)+t.text.slice(s.i+1),t.stackAt.splice(s.i,1);for(let h of t.nodes)h.s>s.i&&(h.s--,h.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(s=>[s.i,s])),t}function ji(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")}function Di(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 h=o;h<t;h++){let l=e.stackAt[h],r=0;for(;r<s.length&&r<l.length&&s[r]===l[r];)r++;for(;s.length>r;)n+=`</${s.pop().tag.toLowerCase()}>`;for(;s.length<l.length;){let u=l[s.length];n+=Di(u.el),s.push(u)}let i=e.atomAt.get(h);n+=i?i.el.outerHTML:e.text[h]===kt?"":ji(e.text[h])}for(;s.length;)n+=`</${s.pop().tag.toLowerCase()}>`;return n}function Ui(e,o){let t=[...e.el.attributes].filter(n=>!o(e.el,n.name)).map(n=>n.name+"="+n.value).sort().join("");return e.tag+"|"+t}function sr(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 Xs(e,o=()=>!1){let t=new Map,n=h=>{let l=t.get(h);return l===void 0&&(l="{"+h.map(r=>Ui(r,o)).sort().join(",")+"}",t.set(h,l)),l},s="";for(let h=0;h<e.text.length;h++){let l=e.atomAt.get(h);s+=(l?"["+sr(l.el,o)+"]":e.text[h])+n(e.stackAt[h])}return e.text.length===0&&e.placeholder&&(s+="[br]"),s}function ao(e,o,t,n=s=>s.key){let s=[],h=e.text,l=0,r=i=>{if(i<=l)return;let u=h.slice(l,i);if(t)for(let w of u.split(/(?<=\n)/))s.push({k:w,raw:w,len:w.length});else for(let w of an(u,o))s.push(w)};for(let i of e.atoms)r(i.i),s.push({k:"\0"+n(i),raw:Un,len:1,atom:!0}),l=i.i+1;return r(h.length),s}function qo(e){if(!e.atoms.length)return e.text;let o="",t=0;for(let n of e.atoms)o+=e.text.slice(t,n.i),t=n.i+1;return o+e.text.slice(t)}var fo=e=>{let o=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)o[t+1]=o[t]+e[t].len;return o};function Ho(e,o,t,n){let s=fo(o),h=fo(t),l=[],r=0,i=0;for(let w of n.hunks){i+=w.bs-r;let c=i+w.toks.length;l.push({bs:s[w.bs],be:s[w.be],ss:h[i],se:h[c],text:e.text.slice(h[i],h[c]),toks:w.toks,lead:!!w.lead}),i=c,r=w.be}let u=new Map;for(let w of n.cosmetic)u.set(w.bi,w.tok.raw);return{hunks:l,respell:u}}function Js(e,o,t){let n=l=>l===kt||/\s/.test(l),s=l=>l.replace(/[\u001E\s]/g,""),h=[];for(let l of e){let r=o.slice(l.bs,l.be),i=t.slice(l.ss,l.se);if(!r.includes(kt)&&!i.includes(kt)||r.includes(Un)||i.includes(Un)||s(r)!==s(i)){h.push(l);continue}let u=0,w=0;for(;;){let c=u,p=w;for(;c<r.length&&n(r[c]);)c++;for(;p<i.length&&n(i[p]);)p++;let b=u,S=w;for(;b<c&&S<p&&r[b]===i[S];)b++,S++;let C=c,m=p;for(;C>b&&m>S&&r[C-1]===i[m-1];)C--,m--;if(C>b||m>S){let f=i.slice(S,m);h.push({bs:l.bs+b,be:l.bs+C,ss:l.ss+S,se:l.ss+m,text:f,toks:[...f].map(g=>({k:g,raw:g,len:1})),lead:l.lead})}if(c>=r.length)break;u=c+1,w=p+1}}return h}function Qs(e,o,t){let n=new Int32Array(o+1).fill(-1),s=new Int32Array(t+1).fill(-1),h=0,l=0,r=i=>{for(;h<i;)n[h]=l,s[l]=h,h++,l++};for(let i of e)r(i.bs),h=i.be,l=i.se;return r(o),n[o]=l,s[l]=o,{bTo:n,toB:s}}function Zs(e,o,t){let n=[],s=0,h=0,l=(r,i)=>{if(s===r&&h===i)return;let u=o.text.slice(h,i);n.push({bs:s,be:r,ss:h,se:i,text:u,toks:an(u,xn(u)),lead:!1})};for(let r of t.runs)l(r.from,r.target),s=r.to,h=r.target+r.to-r.from;return l(e.text.length,o.text.length),{hunks:n,respell:new Map}}function er(e,o,t,n){let s=fo(o),h=fo(t),l=(i,u)=>{let w=0,c=i.length;for(;w<c;){let p=w+c>>>1;i[p]<u?w=p+1:c=p}return i[w]===u?w:-1};for(let i of e.hunks)if(l(s,i.bs)<0||l(s,i.be)<0)return null;if(e.hunks.some(i=>l(h,i.ss)<0||l(h,i.se)<0)){if(!n)return null;let i=[];for(let p of e.hunks)i.push(p.ss,p.se);let u=[],w=0,c=0;for(let p of t){let b=c+p.len;for(;w<i.length&&i[w]<=c;)w++;let S=c;for(;w<i.length&&i[w]<b;){let C=i[w++];if(C>S){let m=p.raw.slice(S-c,C-c);u.push(...an(m,xn(m))),S=C}}if(S===c)u.push(p);else{let C=p.raw.slice(S-c);u.push(...an(C,xn(C)))}c=b}t=u,h=fo(t)}let r=[];for(let i of e.hunks){let u=l(s,i.bs),w=l(s,i.be),c=l(h,i.ss),p=l(h,i.se);if(u<0||w<0||c<0||p<0)return null;r.push({bs:u,be:w,toks:t.slice(c,p),gap:[],group:r.length})}return{parts:r,cosmeticEq:[],tokens:t}}function xs(e,o,t,n={},s=null){return rr(e,o,t,n.base,n.local,n.remote,s,{})}function rr(e,o,t,n,s,h,l,r){let i=xn(qo(e),qo(o),qo(t)),u=ao(e,i,!1,n),w=ao(o,i,!1,s),c=ao(t,i,!1,h),p=u.length>2e4||w.length>2e4||c.length>2e4;p&&(u=ao(e,i,!0,n),w=ao(o,i,!0,s),c=ao(t,i,!0,h));let b=l?.local?Zs(e,o,l.local):null,S=l?.remote?Zs(e,t,l.remote):null,C=b?er(b,u,w,!p):Wn(u,w),m=S?er(S,u,c,!p):Wn(u,c);b&&C&&(w=C.tokens),S&&m&&(c=m.tokens);let f,g;if(C&&m){let I=ms(C,m,u);f=Ho(o,u,w,{hunks:I.lh,cosmetic:I.cosL}),g=Ho(t,u,c,{hunks:I.rh,cosmetic:I.cosR})}else f=b||Ho(o,u,w,C),g=S||Ho(t,u,c,m);return f.hunks=Js(f.hunks,e.text,o.text),g.hunks=Js(g.hunks,e.text,t.text),r.base=e,r.local=o,r.remote=t,r.lines=p,r.baseTokens=u,r.localEdits=f,r.remoteEdits=g,r.localMap=Qs(f.hunks,e.text.length,o.text.length),r.remoteMap=Qs(g.hunks,e.text.length,t.text.length),r.full=null,r}function tr(e,o){if(e.size!==o.size)return!1;for(let t of e)if(!o.has(t))return!1;return!0}var uo=/\s/;function Wo(e,o,t){for(let n=o;n<t;n++)if(!uo.test(e[n]))return!1;return!0}function Vi(e,o,t){let n=e.cache[t]||(e.cache[t]=new Map);if(n.has(o))return n.get(o);let s=t===0?"local":"remote",h=t===0?"remote":"local",l=o.baseMark,r=o[h+"Mark"],i=!o.block&&!o[s]&&!!r&&l.to>l.from;if(i){let u=t===0?e.ML:e.MR,w=t===0?e.MR:e.ML,c=t===0?e.fr:e.fl,p=!1;for(let b=l.from;b<l.to;b++){if(u.bTo[b]>=0){i=!1;break}w.bTo[b]<0&&!uo.test(e.fb.text[b])&&(p=!0)}if(i&&!p){for(let b=r.from;b<r.to;b++)if(w.toB[b]<0&&!uo.test(c.text[b])){p=!0;break}}i&&=p}return n.set(o,i),i}function nr(e,o,t,n,s,h,l,r,i){let u=r===0?e.fl:e.fr,w=null;for(let c=t;c<n;c++){let p=o[c];if(!Wo(u.text,p.ss,p.se))return null;if(Wo(e.fb.text,p.bs,p.be)){if(p.bs<p.be&&p.ss<p.se||uo.test(e.fb.text[p.bs-1]||"")||uo.test(e.fb.text[p.be]||""))continue;return null}let b=!1;for(let S=p.bs;S<p.be;S++){if(uo.test(e.fb.text[S]))continue;let C=null;for(let m of e.fb.stackAt[S]){let f=e.byEl.get(m.el);if(f&&Vi(e,f,r)){C=f;break}}if(!C)return null;(w||(w=new Set)).add(C),b=!0}if(!b)return null}if(!w){if((r===0?"local":"remote")!==i)return null;let c=r===0?e.fr:e.fl,p=!1;for(let b=h;b<l;b++){let S=s[b];if(!Wo(e.fb.text,S.bs,S.be))return null;Wo(c.text,S.ss,S.se)||(p=!0)}if(!p)return null}return w||0}function Ko(e){let{out:o,policy:t="remote",L:n,R:s}=e,h=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,r=e.conflicts||[],i=e.decisions||[],u=r.length,w=e.conflict||(d=>r.push(d)),c={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},p=[],b=!!(n&&n.reverse&&n.map&&s&&s.reverse&&s.map),S={base:null,local:null,remote:null};if(!e.prepared&&b&&e.moveIn){let d=Se=>je=>Se.some(Le=>Le===je||Le.nodeType===1&&Le.contains(je)),B=d(e.local),F=d(e.remote),_=d(e.base),Q=new Set,me=Se=>{if(!Tn.has(Se.tagName))return;let je=n.map.get(Se),Le=s.map.get(Se);(je&&!B(je)||Le&&!F(Le))&&Q.add(Se);for(let Ue of Se.children)me(Ue)};for(let Se of e.base)Se.nodeType===1&&me(Se);let ke=Se=>je=>{if(!Tn.has(je.tagName))return!1;let Le=Se.reverse.get(je);return!!Le&&(Q.has(Le)||!_(Le))};Q.size&&(S.base=Se=>Q.has(Se)),S.local=ke(n),S.remote=ke(s)}let C={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&b&&e.moveIn){let d=_=>Q=>_.some(me=>me===Q||me.nodeType===1&&me.contains(Q)),B=d(e.local),F=d(e.remote);for(let _ of nn(e.base,{...e,atomize:S.base}).atoms){let Q=n.map.get(_.el),me=s.map.get(_.el),ke=!!Q&&!B(Q),Se=!!me&&!F(me);!ke&&!Se||(ke&&e.movePlanned?.(_.el,"local",Q,null),Se&&e.movePlanned?.(_.el,"remote",me,null),C.base.add(_.el),Q&&!ke&&C.local.add(Q),me&&!Se&&C.remote.add(me),B(_.el)&&C.local.add(_.el),F(_.el)&&C.remote.add(_.el))}}let m=e.prepared?.base||nn(e.base,{...e,atomize:S.base,skip:C.base}),f=e.prepared?.local||nn(e.local,{...e,atomize:S.local,skip:C.local}),g=e.prepared?.remote||nn(e.remote,{...e,atomize:S.remote,skip:C.remote}),I=new Map(m.atoms.map(d=>[d.el,d])),v={},T=d=>e.prepared?e.prepared.full?.(d)||null:C[d].size?(v[d]||(v[d]=nn(e[d],{...e,atomize:S[d]})),v[d]):null,A=(d,B,F)=>{B.namespaceURI?d.setAttributeNS(B.namespaceURI,B.name,F):d.setAttribute(B.name,F)},E=(d,B,F,_)=>{if(!B&&(!F||!_)){for(let me of(F||_).attributes)A(d,me,me.value);return}let Q=new Map;for(let me of[B,F,_])if(me)for(let ke of me.attributes)Q.set(ke.name,ke);for(let[me,ke]of Q){let Se=B?B.getAttribute(me):null,je=F?F.getAttribute(me):Se,Le=_?_.getAttribute(me):Se,Ue;je===Le?Ue=je:je===Se?(Ue=Le,i.push({kind:"attr",el:d,name:me,source:"remote"})):Le===Se?(Ue=je,i.push({kind:"attr",el:d,name:me,source:"local"})):(Ue=t==="local"?je:Le,w({kind:"attr",el:d,name:me,base:Se,local:je,remote:Le,resolved:Ue},{el:d,sample:ke}),i.push({kind:"attr",el:d,name:me,source:"both"})),Ue!=null&&A(d,ke,Ue)}},N=(d,B,F,_)=>d&&e.mergeAttrs?e.mergeAttrs(d,B,F,_):E(_,d,B,F),M=e.mergeElement||((d,B,F)=>{let _=o.createElement(d.tagName);N(d,B,F,_);let Q=B||d,me=F||d,ke=t==="local"?Q.isEqualNode(d)?me:Q:me.isEqualNode(d)?Q:me;for(let Se of ke.childNodes)_.appendChild(o.importNode(Se,!0));return h.set(_,{base:d,local:B,remote:F}),_}),R=e.cloneUnit||((d,B)=>{let F=o.importNode(d,!0);return h.set(F,{base:null,local:B==="local"?d:null,remote:B==="remote"?d:null}),F}),V=e.atomKey||(d=>sr(d,()=>!1)),D=(d,B)=>{let F=new Map;for(let _ of d.atoms)if(e.remoteWins&&e.remoteWins(_.el)&&Tn.has(_.el.tagName))F.set(_,"w"+_.el.tagName+"#"+(_.el.id||""));else if(!b)F.set(_,_.key);else if(d===m)F.set(_,"="+V(_.el));else{let Q=B.reverse.get(_.el),me=Q?I.get(Q):null;me?F.set(_,"="+V(me.el)):Q?F.set(_,"m"+V(_.el)):F.set(_,"="+V(_.el))}return _=>F.get(_)},j=D(m,null),y=D(f,n),k=D(g,s),J=e.certifiedOrigins?e.certifiedOrigins(m,f,g,j,y,k):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let d=$t(),B=bs({base:m,side:f,baseOf:_=>n?.reverse?.get(_)||null,budget:d}),F=bs({base:m,side:g,baseOf:_=>s?.reverse?.get(_)||null,budget:d});(B.status==="ready"||F.status==="ready")&&(J={local:B.status==="ready"?B:null,remote:F.status==="ready"?F:null})}let H=e.prepared||rr(m,f,g,j,y,k,J,c),q=H.lines,Me=H.baseTokens,Oe=H.localEdits,Re=H.remoteEdits,ie=H.localMap,xe=H.remoteMap,qe=m.text.length,fe=d=>new Map(d.atoms.map(B=>[B.el,B])),x=fe(f),Y=fe(g),ae=(d,B,F)=>{let _=new Set;if(!b)return _;for(let Q of d.atoms){let me=I.get(B.reverse.get(Q.el));me&&F.bTo[me.i]<0&&_.add(me)}return _},oe=ae(f,n,ie),Ee=ae(g,s,xe),De=d=>!Vn(d,{...e,remoteWins:null}),Ne=new Set;if(b)for(let d of m.atoms){if(!De(d.el))continue;let B=n.map.get(d.el)||null,F=s.map.get(d.el)||null,_=B&&!F?B:F&&!B?F:null;_&&(x.has(_)||Y.has(_))&&!_.isEqualNode(d.el)&&Ne.add(d)}let nt=1,Xe=(d,B)=>({id:nt++,tag:d,base:null,local:null,remote:null,rank:B}),ht=new Map,Ge=[];for(let d of m.marks){let B=Xe(d.tag,d.depth);B.block=!!d.block,B.base=d.el,B.baseMark=d,ht.set(d.el,B),Ge.push(B)}let rt=(d,B)=>{let F=-1,_=-1;for(let Q=d.from;Q<d.to;Q++){let me=B[Q];me>=0&&(F<0&&(F=me),_=me+1)}return F<0?null:[F,_]},Ot=(d,B,F,_)=>{for(let Q of d.marks){let me=F?F.reverse.get(Q.el):null;me&&F.identical.has(me)&&F.pairIdenticalChildren&&F.pairIdenticalChildren(me);let ke=me?ht.get(me):null;if(ke&&ke[B]&&(ke=null),!ke){let Se=rt(Q,_),je=0;if(Se)for(let Le of Ge){if(Le.tag!==Q.tag||Le[B]||!!Le.block!=!!Q.block)continue;let Ue=Math.min(Se[1],Le.baseMark.to)-Math.max(Se[0],Le.baseMark.from);(Ue>je||Ue===je&&Ue>0&&Math.abs(Le.rank-Q.depth)<Math.abs(ke.rank-Q.depth))&&(ke=Le,je=Ue)}}ke||(ke=Xe(Q.tag,Q.depth),ke.block=!!Q.block,ke.new=B),ke[B]=Q.el,ke[B+"Mark"]=Q,ht.set(Q.el,ke)}};Ot(f,"local",n,ie.toB),Ot(g,"remote",s,xe.toB);let Ct=d=>d.merged||d,wt=d=>{let B=new Set;for(let F of d)F.block||B.add(ht.get(F.el));return B},Nt=new Map,Lt=d=>{let B=Nt.get(d);return B||(B=wt(d),Nt.set(d,B)),B},qt=(d,B)=>{let F=[],_=null;for(let Q=0;Q<qe;Q++){let me=B[Q];if(me<0){_&&F.push(_),_=null;continue}let ke=Lt(m.stackAt[Q]),Se=Lt(d.stackAt[me]),je=new Set,Le=new Set;for(let Ue of Se)ke.has(Ue)||je.add(Ue);for(let Ue of ke)Se.has(Ue)||Le.add(Ue);if(!je.size&&!Le.size){_&&F.push(_),_=null;continue}if(_&&tr(_.added,je)&&tr(_.removed,Le)){_.be=Q+1;continue}_&&F.push(_),_={bs:Q,be:Q+1,added:je,removed:Le}}return _&&F.push(_),F},cn=qt(f,ie.bTo),It=qt(g,xe.bTo),Gt=d=>d.be>d.bs?[d.bs,d.be-1]:[d.bs-1,d.bs],wn=(d,B)=>{if(qe===0)return null;let[F,_]=Gt(d);for(let Q of B){if(Q.be<=F)continue;if(Q.bs>_)break;let me=Q.bs<=F&&_<Q.be;return me&&d.text===""&&Q.bs===d.bs&&Q.be===d.be?"straddle":me?Q:d.be>d.bs?"straddle":null}return null},Dt=d=>d.bs===d.be,rn=(d,B,F=null)=>{let _=!1;for(let Q=d.bs;Q<d.be;Q++){let me=m.text[Q];if(me===kt)_=!0;else if(!/\s/.test(me))return!1}for(let Q=d.ss;Q<d.se;Q++){let me=B.text[Q];if(me===kt)_=!0;else if(!/\s/.test(me)){let ke=F&&e.scopeUnits&&Dt(d)&&B.atomAt.get(Q);if(!ke||!De(ke.el)||F.ss!==F.se||F.bs>=F.be)return!1;for(let je=F.bs;je<F.be;je++)if(!/\s/.test(m.text[je]))return!1;let Se=B===f?1:2;if(!e.scopeUnits[Se].includes(ke.el)||(Se===1?n:s)?.reverse.has(ke.el))return!1;_=!0}}return _},Yt=(d,B)=>d.bs<B.be&&B.bs<d.be,fn=(d,B)=>d.bs<=B.be&&B.bs<=d.be&&Dt(d)!==Dt(B),$=(d,B)=>m.text.slice(d.bs,d.be).includes(kt)||B.text.slice(d.ss,d.se).includes(kt),a=d=>{if(Dt(d))return!1;let B=d.bs,F=d.be;for(;B>0&&/\s/.test(m.text[B-1]);)B--;for(;F<m.text.length&&/\s/.test(m.text[F]);)F++;return(B===0||m.text[B-1]===kt)&&(F===m.text.length||m.text[F]===kt)},O=(d,B)=>!$(d,B)&&!a(d),P=(d,B)=>Yt(d,B)||fn(d,B)&&!(d.transferIn||d.transferOut||B.transferIn||B.transferOut)&&!(rn(d,f,B)&&O(B,g))&&!(rn(B,g,d)&&O(d,f)),K=(d,B)=>{if(d.bs!==B.bs||d.be!==B.be||d.toks.length!==B.toks.length)return!1;let F=d.ss,_=B.ss;for(let Q=0;Q<d.toks.length;Q++){let me=d.toks[Q],ke=B.toks[Q];if(me.k!==ke.k||me.atom&&!f.atomAt.get(F).el.isEqualNode(g.atomAt.get(_).el))return!1;F+=me.len,_+=ke.len}return!0},Z=(d,B,F,_)=>{for(let Q of m.atoms){if(Q.i<d.bs||Q.i>=d.be||_.has(Q)||Ne.has(Q))continue;let me=B.bTo[Q.i],ke=me>=0?F.atomAt.get(me):null;if(ke&&!ke.el.isEqualNode(Q.el))return!0}return!1},U=[],de=null,we=null,le=Oe.hunks,Ae=Re.hunks,W=0,X=0,pe=0,be=0,he=0,ee=d=>{d>pe&&(U.push({src:"base",from:pe,to:d,dL:be,dR:he}),pe=d)};for(;W<le.length||X<Ae.length;){let d=le[W],B=Ae[X],F=!!d&&(!B||d.bs<B.bs||d.bs===B.bs&&d.be<=B.be&&!B.lead);if(d&&B&&d.bs===B.bs&&Dt(d)&&Dt(B)){let _t=rn(d,f),So=rn(B,g);_t!==So&&(F=So)}let _=F?d:B,Q=F?B:d,me=!!Q&&K(d,B),ke=!!Q&&(F?!!le[W+1]&&K(le[W+1],B):!!Ae[X+1]&&K(d,Ae[X+1])),Se=!!Q&&!me&&!ke&&(qe===0||P(d,B)),je=Se,Le=wn(_,F?It:cn);if(Le==="straddle"&&(je=!0),!je&&_.be>_.bs&&(je=Z(_,F?xe:ie,F?g:f,F?oe:Ee)),!je&&me){ee(_.bs),U.push({src:"both",lfrom:d.ss,rfrom:B.ss,len:_.text.length,owner:d.owner||B.owner||null,transfer:d.transferIn||B.transferIn||null}),pe=_.be,be+=_.text.length-(_.be-_.bs),he+=_.text.length-(_.be-_.bs),W++,X++;continue}if(!je){ee(_.bs),U.push({src:F?"local":"remote",from:_.ss,to:_.se,inherit:Le&&Le!=="straddle"?Le:null,owner:_.owner||null,transfer:_.transferIn||null}),pe=_.be,F?(be+=_.text.length-(_.be-_.bs),W++):(he+=_.text.length-(_.be-_.bs),X++);continue}let Ue=_.bs,gt=_.be,at=W,dt=X,Vt=_t=>_t.bs<gt&&_t.be>Ue||Dt(_t)&&(_t.bs===Ue||_t.bs===gt);F?at++:dt++,Se&&(Ue=Math.min(Ue,Q.bs),gt=Math.max(gt,Q.be),F?dt++:at++);let Bt=!0;for(;Bt;){for(Bt=!1;at<le.length&&Vt(le[at]);)Ue=Math.min(Ue,le[at].bs),gt=Math.max(gt,le[at].be),at++,Bt=!0;for(;dt<Ae.length&&Vt(Ae[dt]);)Ue=Math.min(Ue,Ae[dt].bs),gt=Math.max(gt,Ae[dt].be),dt++,Bt=!0}let mn=Ue+be,ln=Ue+he,yn=gt-Ue,Nn=gt-Ue;for(let _t=W;_t<at;_t++)yn+=le[_t].text.length-(le[_t].be-le[_t].bs);for(let _t=X;_t<dt;_t++)Nn+=Ae[_t].text.length-(Ae[_t].be-Ae[_t].bs);let Bn=mn+yn,jn=ln+Nn;if(ee(Ue),W<at&&X<dt&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!m.atoms.length&&!f.atoms.length&&!g.atoms.length&&!m.pins.length&&!f.pins.length&&!g.pins.length){de||={fb:m,fl:f,fr:g,ML:ie,MR:xe,byEl:ht,cache:[null,null]};let _t=nr(de,le,W,at,Ae,X,dt,0,t),So=nr(de,Ae,X,dt,le,W,at,1,t);if(_t===null!=(So===null)){let ns=_t!==null,Us=ns?_t:So;if(Us){we||=new Map;for(let si of Us)we.set(si,ns?"local":"remote")}U.push(ns?{src:"remote",from:ln,to:jn}:{src:"local",from:mn,to:Bn}),pe=gt,be+=yn-(gt-Ue),he+=Nn-(gt-Ue),W=at,X=dt;continue}}let en={kind:"text",node:e.node||null,base:co(m,Ue,gt),local:co(f,mn,Bn),remote:co(g,ln,jn),resolved:null,range:null,bs:Ue,be:gt,lss:mn,lse:Bn,rss:ln,rse:jn},Jn=e.sourceRetentions?Ys(e.sourceRetentions,e.scope?.base,m,f,g,t,en):t;en.resolved=Jn==="local"?en.local:Jn==="remote"?en.remote:en.local+en.remote,Jn!=="remote"&&U.push({src:"local",from:mn,to:Bn,conflict:en}),Jn!=="local"&&U.push({src:"remote",from:ln,to:jn,conflict:en});let Qn={site:"inline",policy:Jn,fb:m,fl:f,fr:g,scope:e.scope||null,synthetic:!!e.synthetic,full:T,merged:c};p.push(Qn),w(en,Qn),pe=gt,be+=yn-(gt-Ue),he+=Nn-(gt-Ue),W=at,X=dt}ee(qe);let te=m.text,z=[];if(Oe.respell.size||Re.respell.size){let d=fo(Me),B=[];for(let F=0;F<Me.length;F++){let _=Me[F].raw,Q=Oe.respell.get(F)??_,me=Re.respell.get(F)??_;(Q!==_||me!==_)&&z.push([d[F],Q!==_&&me!==_?"both":Q!==_?"local":"remote"]),B.push(Q===me?Q:Q===_?me:me===_||t==="local"?Q:me)}te=B.join("")}let ne="",Te=[],Ce=[],Pe=[],ve=[];for(let d of U){let B=ne.length;if(d.src==="base"){for(let F=d.from;F<d.to;F++)Te.push(F),Ce.push(e.nativeTransfers?ie.bTo[F]:F+d.dL),Pe.push(e.nativeTransfers?xe.bTo[F]:F+d.dR),ve.push(d);ne+=te.slice(d.from,d.to)}else if(d.src==="both"){for(let F=0;F<d.len;F++){let _=d.transfer&&(d.transfer.side==="remote"?d.rfrom+F:d.lfrom+F);Te.push(d.transfer&&_>=d.transfer.ss&&_<d.transfer.se?d.transfer.bs+_-d.transfer.ss:-1),Ce.push(d.lfrom+F),Pe.push(d.rfrom+F),ve.push(d)}ne+=f.text.slice(d.lfrom,d.lfrom+d.len)}else{let F=d.src==="local"?f:g,_=d.transfer&&e.nativeTransfers.byOrigin[d.src==="local"?"remote":"local"].get(d.transfer.key);for(let Q=d.from;Q<d.to;Q++){let me=d.transfer&&Q>=d.transfer.ss&&Q<d.transfer.se?d.transfer.bs+Q-d.transfer.ss:-1,ke=me>=0&&(!_||_.destination===d.owner)?(d.src==="local"?xe:ie).bTo[me]:-1;Te.push(me),Ce.push(d.src==="local"?Q:ke),Pe.push(d.src==="remote"?Q:ke),ve.push(d)}ne+=F.text.slice(d.from,d.to)}d.ms=B,d.me=ne.length,d.conflict&&(d.conflict.range||(d.conflict.range=[B,B]),d.conflict.range[1]=ne.length)}let _e=ne.length,Je=new Int32Array(qe+1).fill(-1),Ze=new Int32Array(f.text.length+1).fill(-1),Ut=new Int32Array(g.text.length+1).fill(-1);for(let d=0;d<_e;d++)Te[d]>=0&&(Je[Te[d]]=d),Ce[d]>=0&&(Ze[Ce[d]]=d),Pe[d]>=0&&(Ut[Pe[d]]=d);let Pt=(d,B)=>{let F=-1,_=-1;for(let Q=d.from;Q<d.to;Q++){let me=B[Q];me>=0&&(F<0&&(F=me),_=me+1)}return F<0?null:[F,_]},L=[],G=[];for(let d of new Set(ht.values()))d.new==="local"?L.push(d):d.new==="remote"&&G.push(d);let re=(d,B)=>{d.remote=B.remote,d.remoteMark=B.remoteMark,d.new="both",B.merged=d,ht.set(B.remote,d)};if(L.length&&G.length){let d=e.idOf;for(let B of L){let F=d?d.local(B.local):null;if(!F)continue;let _=G.find(Q=>!Q.merged&&Q.tag===B.tag&&!!Q.block==!!B.block&&d.remote(Q.remote)===F);_&&re(B,_)}for(let B of L){if(B.remote)continue;let F=Pt(B.localMark,Ze);if(F)for(let _ of G){if(_.merged||_.tag!==B.tag||!!_.block!=!!B.block)continue;let Q=Pt(_.remoteMark,Ut);if(Q&&Math.min(F[1],Q[1])-Math.max(F[0],Q[0])>0){re(B,_);break}}}}Nt.clear();let ge=d=>{for(let B of d)if(B.block)return Ct(ht.get(B.el));return null},ye=m.marks.some(d=>d.block)||f.marks.some(d=>d.block)||g.marks.some(d=>d.block),ce=new Array(_e).fill(null),se=new Set;if(e.nativeTransfers)for(let d=0;d<_e;d++){let B=ve[d].owner;ce[d]=B?Ct(ht.get(B)):Te[d]>=0?ge(m.stackAt[Te[d]]):null}else if(ye){let d=(Le,Ue,gt)=>{let at=new Set([Le,Ue,gt]);at.delete(null);let dt=[];for(let Bt of at){let mn=Bt===Le,ln=Bt===Ue,yn=Bt===gt;(ln===yn?ln:ln===mn?yn:ln)&&dt.push(Bt)}if(dt.length<=1)return dt[0]||null;let Vt=t==="local"?Ue:gt;return dt.includes(Vt)?Vt:dt[0]},B=(Le,Ue)=>Ue>=0?ge(Le.stackAt[Ue]):null,F=new Map;for(let Le=0;Le<_e;Le++){if(ne[Le]!==kt)continue;let Ue=Te[Le]>=0?B(m,Te[Le]):null,gt=B(f,Ce[Le]),at=B(g,Pe[Le]);F.set(Le,[Ue,Te[Le]>=0?d(Ue,gt,at):gt||at])}let _=new Set([...F.values()].map(Le=>Le[1])),Q=Le=>Le!==kt&&Le!==Un&&!/\s/.test(Le),me=(Le,Ue)=>{let gt=Le;for(;gt<Ue&&!Q(ne[gt]);)gt++;return gt<Ue&&Te[gt]>=0?B(m,Te[gt]):null},ke=new Map,Se=0;for(let Le=0;Le<_e;Le++){if(ne[Le]!==kt)continue;let[Ue,gt]=F.get(Le),at=me(Se,Le),dt=gt,Vt=ke.get(dt)===dt&&at===dt;dt&&ke.has(dt)&&!Vt&&Ue&&!ke.has(Ue)&&!_.has(Ue)&&(dt=Ue),dt&&!ke.has(dt)&&ke.set(dt,at);for(let Bt=Se;Bt<=Le;Bt++)ce[Bt]=dt;Se=Le+1}let je=Le=>{for(let Ue=0;Ue<Le.text.length;Ue++)if(Q(Le.text[Ue])&&!B(Le,Ue))return!0;return!1};if(!je(m)&&!je(f)&&!je(g)){let Le=[],Ue=0;for(let at=0;at<_e;at++)(ne[at]===kt||at===_e-1)&&(Le.push([Ue,at]),Ue=at+1);let gt=new Set(ce);for(let at=0;at<Le.length;at++){let[dt,Vt]=Le[at];if(ce[Vt])continue;let Bt=dt;for(;Bt<=Vt&&!Q(ne[Bt]);)Bt++;if(Bt>Vt)continue;let mn=B(m,Te[Bt]),ln=B(f,Ce[Bt]),yn=B(g,Pe[Bt]),Nn=d(mn,ln,yn)||ln||yn||mn;if(Nn&&!gt.has(Nn)){gt.add(Nn);for(let en=dt;en<=Vt;en++)ce[en]=Nn;continue}let Bn=at>0&&ce[Le[at-1][1]],jn=at+1<Le.length&&ce[Le[at+1][1]];if(Bn)se.add(Le[at-1][1]);else if(jn&&ne[Vt]===kt)se.add(Vt);else continue;for(let en=dt;en<=Vt;en++)ce[en]=Bn||jn}}}let Ie=new Map,Be=d=>{let B=Ie.get(d);if(B)return B;B=[1/0,-1/0];for(let[F,_]of[[d.baseMark,Je],[d.localMark,Ze],[d.remoteMark,Ut]]){let Q=F&&Pt(F,_);Q&&(B[0]=Math.min(B[0],Q[0]),B[1]=Math.max(B[1],Q[1]))}return Ie.set(d,B),B},He=(d,B,F)=>{let _=-1,Q=-1;for(let me=0;me<d.length;me++){let ke=ht.get(d[me].el);ke===B&&(_=me),ke===F&&(Q=me)}return _>=0&&Q>=0?_-Q:0},Ke=(d,B)=>[...d].sort((F,_)=>{for(let ke of B){let Se=He(ke,F,_);if(Se)return Se}let Q=Be(F),me=Be(_);return Q[0]-me[0]||me[1]-Q[1]||F.rank-_.rank||F.id-_.id}),pt=new Map,tt=new Map,Kt=e.nativeTransfers?[]:null,Ht=d=>{if(Kt)return Kt;let B=Te[d],F=Ce[d],_=Pe[d],Q=ve[d];if(B>=0){let at=m.stackAt[B],dt=f.stackAt[F],Vt=g.stackAt[_],Bt=pt.get(at);Bt||pt.set(at,Bt=new Map);let mn=Bt.get(dt);mn||Bt.set(dt,mn=new Map);let ln=mn.get(Vt);if(ln)return ln;let yn=Lt(at),Nn=Lt(dt),Bn=Lt(Vt),jn=new Set;for(let en of new Set([...yn,...Nn,...Bn])){let Jn=yn.has(en),Qn=Nn.has(en),_t=Bn.has(en);(Qn===_t?Qn:Qn===Jn?_t:Qn)&&jn.add(en)}return ln=Ke(jn,[dt,Vt,at]),mn.set(Vt,ln),ln}if(Q.src==="both"){let at=f.stackAt[F],dt=g.stackAt[_];return Ke(new Set([...Lt(at),...Lt(dt)]),[at,dt])}let ke=(Q.src==="local"?f:g).stackAt[Q.src==="local"?F:_];if(!Q.inherit)return Ke(Lt(ke),[ke]);let Se=tt.get(Q);Se||tt.set(Q,Se=new Map);let je=Se.get(ke);if(je)return je;let Le=new Set(Lt(ke));for(let at of Q.inherit.added)Le.add(Ct(at));for(let at of Q.inherit.removed)Le.delete(Ct(at));let Ue=Q.src==="local"?g:f,gt=(Q.src==="local"?xe.bTo:ie.bTo)[Q.inherit.bs];return je=Ke(Le,[ke,Ue.stackAt[gt]]),Se.set(ke,je),je},un=new Int32Array(f.text.length+1);un[f.text.length]=_e;for(let d=f.text.length-1;d>=0;d--)un[d]=Ze[d]>=0?Ze[d]:un[d+1];Pi.caret+=f.text.length;let bt=d=>d<=0?0:(d>f.text.length&&(d=f.text.length),Ze[d-1]>=0?Ze[d-1]+1:un[d]),lt=[],$e=[],vt=null,ct=[],jt="",bn=-1,on=d=>{vt?vt.appendChild(d):lt.push(d)},hn=d=>{if(!jt)return;let B=o.createTextNode(jt);on(B),$e.push({node:B,ms:bn,me:d,local:[],u:ct.length?ct[ct.length-1].u:null}),jt=""},Xt=new Set,En=new Map,oo=new Set,Rn=d=>{let B=o.createElement(d.tag);if(d.block&&vn.add(B),!En.has(d)){En.set(d,B),N(d.base,d.local,d.remote,B),h.set(B,{base:d.base,local:d.local,remote:d.remote});let _=(ke,Se)=>b&&d[Se]&&ke.reverse.get(d[Se])?Se:null,Q=!d.base&&(_(n,"local")||_(s,"remote"));if(Q){let ke=Q==="local"?n.reverse.get(d.local):s.reverse.get(d.remote),Se=h.get(B);Se.local=Se.local||n.map.get(ke)||null,Se.remote=Se.remote||s.map.get(ke)||null,i.push({kind:"move",el:B,source:Q}),e.moveBuilt?.(ke,Q,d[Q],B)}else d.base||i.push({kind:"insert",el:B,source:d.local&&d.remote?"both":d.local?"local":"remote"});let me=h.get(B);me.local&&(oo.has(me.local)?me.local=null:oo.add(me.local))}else{let _=En.get(d);for(let Q of _.attributes)Q.name!=="id"&&Q.name!=="data-id"&&A(B,Q,Q.value);h.set(B,{base:null,local:null,remote:null})}on(B),ct.push({u:d,el:B}),vt=B},xo=new Set,Kn=new Map;for(let d of f.pins){let B=bt(d.i);Kn.has(B)||Kn.set(B,[]),Kn.get(B).push(d)}let Ro=d=>{let B=Kn.get(d);if(B){hn(d);for(let F of B){let _=F.el.namespaceURI&&F.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?o.createElementNS(F.el.namespaceURI,F.el.tagName):o.createElement(F.el.tagName);h.set(_,{base:null,local:F.el,remote:null,pinned:!0}),xo.add(_),on(_)}}},ts=m.atoms.length||f.atoms.length||g.atoms.length,Po=d=>{if(!ts)return null;let B=Te[d]>=0?m.atomAt.get(Te[d]):null,F=Ce[d]>=0?f.atomAt.get(Ce[d]):null,_=Pe[d]>=0?g.atomAt.get(Pe[d]):null;return B||F||_?{ab:B,al:F,ar:_}:null},Fn=(d,B,F)=>{let _=e.idOf;if(!_||!_.base)return!1;let Q=_.base(d.el);return Q!=null&&Q===_[F](B.el)},To=(d,B,F,_,Q)=>{if(!d||!b)return null;let me=I.get(B.reverse.get(d.el))||null;return!me||me===_||(_?me.el.isEqualNode(_.el)&&!Fn(me,d,Q):F.bTo[me.i]>=0)?null:me},so=(d,B)=>{if(!d||!b||!e.moveIn)return null;let F=B.reverse.get(d.el);return F&&!I.has(F)?F:null},vo=(d,B)=>{let F=new Map;for(let _ of d.atoms)F.set(B(_),(F.get(B(_))||0)+1);return F},ue=vo(m,j),We=vo(f,y),Ve=vo(g,k),et=d=>{let B=j(d);return ue.get(B)===1&&(We.get(B)||0)<=1&&(Ve.get(B)||0)<=1},yt=new Map,Fe=new Set,ze=new Set,xt=new Set,Ye=null;for(let d=0;d<_e;d++){let B=Po(d);if(!B)continue;let{ab:F,al:_,ar:Q}=B,me=To(Q,s,xe,F,"remote"),ke=To(_,n,ie,F,"local"),Se=F,je=null;if(me?(Se=me,je="remote"):ke&&(Se=ke,je="local"),Se){F&&Se!==F&&(Ye||=new Map).set(F,je),Fe.has(Se)?yt.set(d,{dup:Se.el}):(Fe.add(Se),yt.set(d,{bk:Se,from:je,al:_,ar:Q}));continue}let Le=so(Q,s),Ue=so(_,n),gt=Le||Ue;if(gt){ze.has(gt)?yt.set(d,{dup:gt}):(ze.add(gt),yt.set(d,{moveIn:gt,side:Le?"remote":"local",sideEl:Le?Q.el:_.el}));continue}let at=(Vt,Bt)=>Vt&&b&&I.get(Bt.reverse.get(Vt.el))||null,dt=at(Q,s)||at(_,n);if(dt&&(xt.add(dt),ve[d].conflict&&(et(dt)||Q&&(Q.el===dt.el||s.identityPaired?.has(dt.el))&&Fn(dt,Q,"remote")||_&&(_.el===dt.el||n.identityPaired?.has(dt.el))&&Fn(dt,_,"local")))){if(Fe.has(dt)){yt.set(d,{dup:dt.el});continue}Fe.add(dt)}yt.set(d,{al:_,ar:Q})}let st=new Map,ft,Wt,Mt=(d,B)=>{if(d[B]>=0)return d[B];for(let F=B-1;F>=0;F--)if(d[F]>=0)return d[F]+1;return 0};if(b)for(let d of m.atoms){if(Fe.has(d)||xt.has(d))continue;let B=n.map.get(d.el)||null,F=s.map.get(d.el)||null,_=B&&x.get(B),Q=F&&Y.get(F);if(B&&!_||F&&!Q)continue;let me=!(_&&Q)&&Ne.has(d);if(!me&&!(_&&Q&&(et(d)||Ye?.has(d)||(_.el===d.el||n.identityPaired?.has(d.el))&&(Q.el===d.el||s.identityPaired?.has(d.el))&&Fn(d,_,"local")&&Fn(d,Q,"remote"))))continue;let ke=Ye?.get(d),Se=t;if(ke){let at=ke==="local"?g:f,dt=ke==="local"?s:n,Vt=ke==="local"?Wt:ft;if(Vt===void 0){Vt=at.atoms.length===m.atoms.length;for(let Bt=0;Vt&&Bt<m.atoms.length;Bt++)Vt=dt.reverse.get(at.atoms[Bt].el)===m.atoms[Bt].el;ke==="local"?Wt=Vt:ft=Vt}Vt&&(Se=ke)}let je=Se==="local"?[[_,Ze],[Q,Ut]]:[[Q,Ut],[_,Ze]],[Le,Ue]=je.find(([at])=>at),gt=Mt(Ue,Le.i);st.has(gt)||st.set(gt,[]),st.get(gt).push({a:d,lt:B,rt:F,edited:me}),Fe.add(d)}if(b&&e.moveIn){let d=[[f,n,Ze,"local"],[g,s,Ut,"remote"]];t!=="local"&&d.reverse();for(let[B,F,_,Q]of d)for(let me of B.atoms){let ke=so(me,F);if(!ke||ze.has(ke))continue;ze.add(ke);let Se=Mt(_,me.i);st.has(Se)||st.set(Se,[]),st.get(Se).push({move:ke,side:Q,sideEl:me.el})}}let Qt=d=>{let B=st.get(d);if(B){if(hn(d),B.some(F=>De(F.move?F.sideEl:F.a.el)))for(;ct.length;)ct.pop(),vt=ct.length?ct[ct.length-1].el:null;for(let{a:F,lt:_,rt:Q,edited:me,move:ke,side:Se,sideEl:je}of B){if(ke){let Ue=e.moveIn(ke,Se,je);Ue&&on(Ue);continue}Xt.add(F);let Le=M(F.el,_,Q);me&&(w({kind:"structure",el:Le,detail:"edit-beats-delete",base:F.el},{subject:F.el,deleted:_?"remote":"local"}),i.push({kind:"insert",el:Le,source:_?"local":"remote"})),on(Le)}}},vn=new Set,_n=r.length>u;for(let d=0;d<_e;d++){let B=Po(d),F=e.scopeUnits&&B&&(B.ab?.stack.some(ke=>ke.block)||B.al?.stack.some(ke=>ke.block)||B.ar?.stack.some(ke=>ke.block)),Q=!!B&&De((B.ab||B.al||B.ar).el)&&!F?[]:ce[d]?[ce[d],...Ht(d)]:Ht(d),me=0;for(;me<ct.length&&me<Q.length&&ct[me].u===Q[me];)me++;if(me<ct.length)for(hn(d);ct.length>me;)ct.pop(),vt=ct.length?ct[ct.length-1].el:null;if(Ro(d),Qt(d),Q.length>ct.length)for(hn(d);ct.length<Q.length;)Rn(Q[ct.length]);if(ne[d]===kt){if(se.has(d))continue;hn(d);let ke=ct.length;for(;ke>0&&!ct[ke-1].u.block;)ke--;if(ke>0)for(_n&&c.breakOut.set(d,ct[ke-1].el);ct.length>=ke;)ct.pop(),vt=ct.length?ct[ct.length-1].el:null;continue}if(B){hn(d);let ke=yt.get(d),Se;if(ke.dup){w({kind:"structure",el:null,detail:"both-moved",base:ke.dup},{subject:ke.dup});continue}if(ke.moveIn){if(Se=e.moveIn(ke.moveIn,ke.side,ke.sideEl),!Se)continue}else if(ke.bk){let je=ke.bk;if(Xt.add(je),je===B.ab)Se=M(je.el,ke.al.el,ke.ar.el);else{let Le=n.map.get(je.el)||null,Ue=s.map.get(je.el)||null;Se=M(je.el,Le,Ue),(!Le||!Ue)&&w({kind:"structure",el:null,detail:"move-beats-delete",base:je.el},{subject:je.el,deleted:Le?"remote":"local"}),i.push({kind:"move",el:Se,source:ke.from})}}else ke.al?(Se=R(ke.al.el,"local"),ke.ar&&(h.get(Se).remote=ke.ar.el),i.push({kind:"insert",el:Se,source:ke.ar?"both":"local"})):(Se=R(ke.ar.el,"remote"),i.push({kind:"insert",el:Se,source:"remote"}));_n&&c.atomOut.set(d,Se),on(Se);continue}jt||(bn=d),jt+=ne[d]}if(hn(_e),(Kn.has(_e)||st.has(_e))&&(ct.length=0,vt=null,Ro(_e),Qt(_e)),_e===0&&(f.placeholder||g.placeholder||m.placeholder)){let d=o.createElement("br");h.set(d,{base:m.placeholder,local:f.placeholder,remote:g.placeholder}),lt.push(d)}let Pn=0,ut=d=>{for(;Pn>0&&$e[Pn-1].me>=d;)Pn--;for(;Pn<$e.length&&$e[Pn].me<d;)Pn++;let B=$e[Pn];if(!B)return $e[$e.length-1]||null;let F=$e[Pn+1];return B.me===d&&F&&F.ms===d?F:B},Qe=new Map,Et={},ot=(d,B,F)=>{let _=ut(d)||(F?Et:null);if(!_)return;let Q=Qe.get(_)||{l:!1,r:!1};B!=="remote"&&(Q.l=!0),B!=="local"&&(Q.r=!0),Qe.set(_,Q)},At=d=>{if(d.conflict)return!0;let B=d.src==="local"?f.text:d.src==="remote"?g.text:"";for(let F=d.from;F<d.to;F++)if(B[F]!==Un&&B[F]!==kt)return!0;return!1};for(let d of U)d.src!=="base"&&ot(d.ms,d.conflict?"both":d.src,At(d));for(let[d,B]of z)Je[d]>=0&&ot(Je[d],B);for(let d of $e.length?$e:[Et]){let B=Qe.get(d);B&&i.push({kind:"text",node:d.node||null,source:B.l&&B.r?"both":B.l?"local":"remote"})}for(let d of Ge){if(En.has(d))continue;let B=!d.local&&!(b&&n.map.get(d.base)),F=!d.remote&&!(b&&s.map.get(d.base));!B&&!F||i.push({kind:"remove",source:B&&F?"both":B?"local":"remote",base:d.base})}if(we)for(let[d,B]of we)En.has(d)&&w({kind:"structure",el:En.get(d),detail:"edit-beats-delete",base:d.base},{subject:d.base,deleted:B});let Jt=(d,B,F)=>{if(B<=d)return!1;for(let _=d;_<B;_++)if(F[_]>=0)return!1;return!0};for(let d of Ge)for(let B of["local","remote"]){let F=d[B+"Mark"],_=d.baseMark;if(!F)continue;let Q=B==="local"?ie:xe;if(!Jt(_.from,_.to,Q.bTo)||!Jt(F.from,F.to,Q.toB))continue;let me=(B==="local"?le:Ae).find(ke=>ke.ss<=F.from&&F.from<ke.se);me&&(me.be<=_.from||me.bs>=_.to)&&i.push({kind:"move",el:En.get(d)||null,source:B})}let Rt=d=>{let B=ht.get(d.node.parentNode);return B?Ct(B):null};for(let d of f.nodes){let B=-1;for(let _=d.s;_<d.e;_++)if(Ze[_]>=0){B=Ze[_];break}let F;if(B>=0)F=ut(B);else{let _=bt(d.s),Q=Rt(d);F=$e.find(me=>me.u===Q&&me.me>=_)||$e.filter(me=>me.u===Q).pop()}F&&F.local.push(d)}let Ft=new Map,tn=$e[$e.length-1]||null,Tt=0;for(let d of f.nodes){let B=null;for(let F=d.s;F<=d.e;F++){let _=bt(F);for(;Tt>0&&$e[Tt-1].me>=_;)Tt--;for(;Tt<$e.length&&$e[Tt].me<_;)Tt++;let Q=ke=>ke&&_>=ke.ms&&_<=ke.me&&(_<ke.me||F===d.e||ke===B),me=Q($e[Tt])?$e[Tt]:Q($e[Tt+1])?$e[Tt+1]:$e[Tt]||tn;if(!me)break;if(B===me){let ke=Ft.get(me);ke[ke.length-1].to=F-d.s;continue}B=me,Ft.has(me)||Ft.set(me,[]),Ft.get(me).push({node:d.node,from:F-d.s,to:F-d.s,flatStart:d.s})}}for(let d of $e){let B=d.local,F=!1;for(let ke of B)for(let Se=ke.s;Se<ke.e&&!F;Se++)(Ze[Se]<d.ms||Ze[Se]>=d.me)&&(F=!0);h.set(d.node,{base:null,local:B.map(ke=>ke.node),remote:null,caret:Ft.get(d)||[],partial:F});let _=d.ms,Q=d.me-d.ms,me=ke=>{let Se=0,je=-1;for(let Le of B){let Ue=Le.e-Le.s;if(ke<=Se+Ue){je=Le.s+(ke-Se);break}Se+=Ue}return je<0&&(je=B.length?B[B.length-1].e:0),Math.max(0,Math.min(bt(je)-_,Q))};me.flat=ke=>Math.max(0,Math.min(bt(ke)-_,Q)),l.set(d.node,me)}function mt(){if(!f.text.includes(kt))return[{flatLocal:f.text,localNodes:f.nodes,textNodes:$e,lToM:Ze,mapLocal:bt}];let d=[],B=0,F=0;for(let _=0;_<=f.text.length;_++){if(_<f.text.length&&f.text[_]!==kt)continue;let Q=B,me=_;if(me>Q){let ke=[];for(;F<f.nodes.length&&f.nodes[F].e<=Q;)F++;for(let Se=F;Se<f.nodes.length&&f.nodes[Se].s<me;Se++){let je=f.nodes[Se],Le=Math.max(je.s,Q),Ue=Math.min(je.e,me);Le<Ue&&ke.push({node:je.node,s:Le-Q,e:Ue-Q})}d.push({flatLocal:f.text.slice(Q,me),localNodes:ke,textNodes:$e,lToM:Ze.subarray?Ze.subarray(Q,me+1):Ze.slice(Q,me+1),mapLocal:Se=>bt(Q+Math.max(0,Math.min(Se,me-Q)))})}B=_+1}return d}let St={...e,blocks:vn,ignored:d=>xo.has(d)||(e.ignored?e.ignored(d):!1)},Zt=e.ignoreAttribute||(()=>!1),zn=Xs(nn(lt,St),Zt)!==Xs(g,Zt);if(p.length){let d=B=>{let F=h.get(B);return F&&F.unchanged?F.remote:null};c.text=ne,c.textNodes=$e,c.out=nn(lt,{...St,via:d})}let Sn=null;if(e.scopeUnits){Sn=new Map;let d=new Set(lt),B=Se=>{for(;Se&&!d.has(Se);)Se=Se.parentNode;return Se},F=e.scopeUnits.map(Se=>{let je=new Map;for(let Le of Se)if(Le.nodeType===1)je.set(Le,Le);else for(let Ue of Le.nodes)je.set(Ue,Le);return je}),_=(Se,je)=>{for(;Se&&!je.has(Se);)Se=Se.parentNode;return Se?je.get(Se):null},Q=[m,f,g].map((Se,je)=>{let Le=new Array(Se.text.length);for(let Ue of Se.nodes){let gt=_(Ue.node,F[je]);gt&&Le.fill(gt,Ue.s,Ue.e)}for(let Ue of Se.atoms)Le[Ue.i]=_(Ue.el,F[je]);return Le}),me=(Se,je)=>{if(!Se||!je)return;let Le=Sn.get(Se);Le||Sn.set(Se,Le=new Set),Le.add(je)};for(let Se of lt){let je=h.get(Se);je&&(me(_(je.base,F[0]),Se),me(_(je.local,F[1]),Se),me(_(je.remote,F[2]),Se))}for(let Se of $e){let je=B(Se.node);for(let Le=Se.ms;Le<Se.me;Le++)me(Q[0][Te[Le]],je),me(Q[1][Ce[Le]],je),me(Q[2][Pe[Le]],je)}let ke=new Map(lt.map((Se,je)=>[Se,je]));for(let[Se,je]of Sn)Sn.set(Se,Array.from(je).sort((Le,Ue)=>ke.get(Le)-ke.get(Ue)))}return{unitOutputs:Sn,nodes:lt,text:ne,textNodes:$e,localDiverged:zn,mapLocal:bt,conflicts:r.slice(u),granularity:q?"line":"word",segments:mt(),localHunks:le,remoteHunks:Ae,lToM:Ze}}var Ts=Symbol("lost");function lr(){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 ir=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function ar({locals:e,rec:o,root:t,provenance:n,segments:s,ignored:h}){let l=new Map,r=(v,T)=>{let A=l.get(v);A||l.set(v,A=new Set),A.add(T)},i=new Set,u=new Set;for(let v of s){let T=v.textNodes;for(let A of T)i.add(A.node);for(let A of v.localNodes){u.add(A.node);let E=0,N=null;for(let M=A.s;M<A.e;M++){let R=v.lToM[M];if(R<0)continue;for((!T[E]||R<T[E].ms)&&(E=0);E<T.length&&T[E].me<=R;)E++;let V=T[E]&&T[E].ms<=R?T[E].node:Ts;V!==N&&r(A.node,V),N=V}}}let w=new Set,c=new Map,p=new Set;(function v(T){w.add(T);let A=n.get(T);if(T.nodeType===1)A&&A.local&&A.local.nodeType===1&&(r(A.local,T),A.unchanged&&p.add(A.local)),T.tagName==="TEMPLATE"&&T.content&&c.set(T.content,T);else if(A&&Array.isArray(A.local)&&!i.has(T))for(let E of A.local)r(E,T);for(let E=ir(T).firstChild;E;E=E.nextSibling)v(E)})(t);let b=new Set;for(let[v,T]of o.links)r(v,T),b.add(v);let S=v=>{let T=v.parentNode;return T&&T.nodeType===11?c.get(T)||null:T},C=(v,T)=>{for(let A=v;A;A=S(A))if(A===T)return!0;return!1},m=v=>o.removed.has(v)||o.consumed.has(v),f=v=>{for(let T=v.parentNode;T&&T.nodeType===1;T=T.parentNode){if(p.has(T))return"kept";if(m(T))return"decided";if(l.has(T))return null}return null},g=new Map;for(let v of e)g.set(v,I(v));return g;function I(v){let T=l.get(v);if(T&&(T.size!==1||T.has(Ts)))return{kind:"unknown",reason:"several-outputs"};let A=T?T.values().next().value:null;if(A&&(A.nodeType!==1||!w.has(A)))return{kind:"unknown",reason:"output-not-placed"};if(!A){let R=m(v)?"decided":f(v);if(R==="kept")return{kind:"untouched"};if(R!=="decided")return{kind:"unknown",reason:"unmapped"}}let E=[],N=M(v,!!A&&(p.has(v)||b.has(v)),!A||m(v));if(N)return{kind:"unknown",reason:N};return A?{kind:"single",output:A,owned:E,carried:b.has(v)}:{kind:"removed"};function M(R,V,D){for(let j=ir(R).firstChild;j;j=j.nextSibling){if(j.nodeType===1?h(j):j.nodeType!==3&&j.nodeType!==8)continue;let y=l.get(j);if(y)for(let k of y){if(k===Ts||!w.has(k))return"output-not-placed";if(!A)return"survives-elsewhere";if(!C(k,A))return"escaped";E.push(k)}else if(!V&&!D&&!m(j)&&!u.has(j))return"unmapped";if(j.nodeType===1){let k=M(j,V||p.has(j)||b.has(j),D||m(j));if(k)return k}}return null}}}function cr(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)||cr(e,n.content))return!0;return!1}function fr(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&&!cr(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 ur=new WeakMap;function dr(e){let o=new Map;for(let t of e){let n=[],s=!1;(function h(l){l.nodeType===1&&l.namespaceURI==="http://www.w3.org/1999/xhtml"&&l.localName==="template"&&(s=!0);for(let r=l.firstChild;r;r=r.nextSibling)n.push(r),r.nodeType===1&&h(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=fr(n,o.ownerDocument),h=!1,l={...e,lineage:{elements:s,onResult(r,i){if(!h)return h=!0,n.onResult(r,i)}}};try{return ur.set(l.lineage,dr(s)),t(l)}catch(r){if(!h){h=!0;try{n.onResult({version:1,root:o,status:"incomplete",entries:s.map(An)},null)}catch{}}throw r}}function Ss(e,{liveRoot:o,localRoot:t,toLive:n}){let s=fr(e,o.ownerDocument),h=u=>u===o||o.contains(u),l=new Map,r=new Set(s.filter(h));if(r.size&&t===o)for(let u of r)l.set(u,u);else r.size&&(function u(w){let c=n(w);r.delete(c)&&l.set(c,w);for(let p=w.firstElementChild;p&&r.size;p=p.nextElementSibling)u(p)})(t);return{spec:e,watched:s,root:o,locals:Array.from(new Set(l.values())),before:ur.get(e)||dr(s),delivered:!1,result:null,finish(u,w){return this.resolve=w,this.plans=u,this.result={version:1,root:this.root,status:"complete",entries:s.map(c=>Hi(c,l.get(c),u,w,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(u,w){this.root=w;let c=this.resolve,p=S=>{let C=c(S);return C===u?w:C};return this.finish(this.plans,p)},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 h=s.root,l=p=>!!p&&(p===h||h.contains(p)),r=o&&t?t.get(o):null;if(!r||r.kind==="unknown")return An(e);let i=s.before.get(e);if(!i||i.opaque)return An(e);let u=i.nodes,w=p=>l(p)||!!(p&&p.ownerDocument===h.ownerDocument&&h.ownerDocument.documentElement?.contains(p));if(r.kind==="untouched"){if(!l(e))return An(e);for(let p of u)if(w(p)&&!e.contains(p))return An(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(r.kind==="removed")return w(e)||u.some(w)?An(e):{from:e,to:[],kind:"removed",complete:!0};let c=n(r.output);if(!c||c.nodeType!==1||!l(c)||c!==e&&w(e))return An(e);for(let p of u)if(w(p)&&!c.contains(p))return An(e);for(let p of r.owned){let b=n(p),S=Array.isArray(b)?b:[b];for(let C of S)if(!C||!l(C)||!c.contains(C))return An(e)}return r.carried&&!hr(c,r.output,n)?An(e):{from:e,to:[c],kind:c===e?"retained":"replaced",complete:!0}}function hr(e,o,t){for(let n=o.firstChild;n;n=n.nextSibling){let s=t(n),h=Array.isArray(s)?s:[s];for(let l of h)if(!l||!e.contains(l))return!1;if(n.nodeType===1&&!hr(e,n,t))return!1}return!0}function Ao(e,o,t){let n=Ss(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 pr(e,o,t,n,s){if(!s(e.length*8+1))return null;let h=0,l=o===0,r=!1;for(let i of an(e,n)){if(!s(1))return null;if(h+=i.len,h===o&&(l=!0),h===t&&(r=!0),h>=t)break}return l&&r}function Wi(e,o,t,n,s,h,l){if(!l(o.length*2))return!1;let r=new Map,i=new Map,u=new Set;for(let w of o){let c=w.bs<w.be,p=c?t[w.ownerIndex].text.base:t[w.ownerIndex].text[e],b=c?w.bs:w.ss,S=c?w.be:w.se;if(!l((S-b)*4+1))return!1;for(;b<S&&/\s/.test(p[b]);)b++;for(;S>b&&/\s/.test(p[S-1]);)S--;if(b===S)continue;let C=p.slice(b,S),m=c?r:i;c&&w.text&&u.add(C),m.has(C)?m.set(C,null):m.set(C,{h:w,from:b,to:S})}for(let w of n){if(!l(1))return!1;if(w.side!==e)continue;let c=w.deletion,p=t[c.ownerIndex].text.base;if(!l((c.be-c.bs)*3)||u.has(p.slice(c.bs,c.be).trim()))return!1}for(let[w,c]of r){if(!l(w.length+1))return!1;let p=i.get(w);if(!c||!p)continue;let b=c.h,S=p.h;if(!b.text||b.transferOut||S.transferIn||b.owner===S.owner)continue;let C=t[b.ownerIndex],m=t[S.ownerIndex];if(!l(C.text.base.length))return!1;if(!/\S/.test(C.text.base.slice(0,b.bs)+C.text.base.slice(b.be)))continue;let f=pr(C.text.base,c.from,c.to,h,l),g=pr(m.text[e],p.from,p.to,h,l);if(f===null||g===null)return!1;if(!f||!g)continue;let I=`${C.index}:${c.from}:${c.to}`,v={key:I,side:e,source:b.owner,destination:S.owner,deletion:b,insertion:S,sourceOffset:c.from-b.bs,targetOffset:p.from-S.ss,length:c.to-c.from};b.transferOut=v,S.transferIn=v,s[e].set(I,v),n.push(v)}return!0}function mr({base:e,local:o,remote:t,localTwin:n,remoteTwin:s,eligible:h,nodes:l,budget:r=$t(2e4*32)}){let i=N=>N>r.remaining?!1:(r.remaining-=N,r.nativeSteps=(r.nativeSteps||0)+N,!0);if(e.length<2||o.length!==e.length||t.length!==e.length||!i(e.length*12))return null;for(let[N,M]of[["base",e],["local",o],["remote",t]]){let R=l[N];if(R.length!==M.length||R.some((V,D)=>V!==M[D]))return null}let u=[],w=0;for(let N=0;N<e.length;N++){let M=e[N],R=o[N],V=t[N];if(n(M)!==R||s(M)!==V)return null;let D={};for(let[j,y]of[["base",M],["local",R],["remote",V]]){if(!h(y)||y.tagName!==M.tagName||y.namespaceURI!==M.namespaceURI||!i(y.childNodes.length+1))return null;let k="";for(let J of y.childNodes){if(J.nodeType!==3||!i(J.data.length*4+1))return null;k+=J.data}if(k.includes(kt)||(w+=k.length+1,w>2e4))return null;D[j]=k}u.push({base:M,local:R,remote:V,index:N,text:D})}let c=u.every(N=>xn(N.text.base,N.text.local,N.text.remote)),p={local:[],remote:[]};for(let N of u){N.hunks={local:[],remote:[]};for(let M of["local","remote"]){let R=N.text.base,V=N.text[M];if(R===V)continue;let D=R.length+V.length+4,j=D*8;if(!i(j))return null;let y=Math.floor(r.remaining/8),k=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(D*D+y)-D)/2)));if(k<1||!i(4*(k+1)*(D+k+1)))return null;let J=0;for(let H of Yn(R,V,k)){if(!i(H.text.length+1))return null;let q=H.bs+J,Me={...H,ss:q,se:q+H.text.length,toks:an(H.text,c),owner:N.base,ownerIndex:N.index};N.hunks[M].push(Me),p[M].push(Me),J+=H.text.length-(H.be-H.bs)}}}let b=[],S={local:new Map,remote:new Map};for(let N of["local","remote"]){let M=new Map,R=new Map,V=!1,D=(j,y,k)=>{j.has(y)?j.set(y,null):j.set(y,k)};for(let j of p[N]){if(!i(1))return null;let y=u[j.ownerIndex].text.base;if(j.bs<j.be&&j.text===""){let k=y.slice(j.bs,j.be);if(!i(k.length*2))return null;/\S/.test(k)&&D(M,k,j)}else if(j.bs===j.be&&/\S/.test(j.text)){if(!i(j.text.length*2))return null;D(R,j.text,j)}else j.bs<j.be&&(V=!0)}for(let[j,y]of M){if(!i(j.length+1))return null;let k=R.get(j);if(!y||!k||y.owner===k.owner)continue;let J=u[y.ownerIndex];if(!i(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,y.bs)+J.text.base.slice(y.be)))continue;let H=`${J.index}:${y.bs}:${y.be}`,q={key:H,side:N,source:y.owner,destination:k.owner,deletion:y,insertion:k};y.transferOut=q,k.transferIn=q,S[N].set(H,q),b.push(q)}if(V&&R.size&&!Wi(N,p[N],u,b,S,c,i))return null}if(!b.length)return null;let C=(N,M)=>N.bs<M.be&&M.bs<N.be,m=N=>N.bs===N.be,f=(N,M)=>N.bs<=M.be&&M.bs<=N.be&&m(N)!==m(M),g=(N,M)=>N.bs===M.bs&&N.be===M.be&&N.text===M.text,I=(N,M)=>!!(N.transferIn||N.transferOut&&(!N.text||M.bs===N.be&&/\s/.test(M.text[0])||M.bs===N.bs&&/\s/.test(M.text[M.text.length-1])));for(let N of b){let M=N.side==="local"?"remote":"local",R=u[N.deletion.ownerIndex];for(let V of R.hunks[M])if(!i(1)||C(N.deletion,V)&&V.transferOut?.key!==N.key)return null}for(let N of u)for(let M of N.hunks.local)for(let R of N.hunks.remote){if(!i(1))return null;if(g(M,R)){if(M.transferIn?.key!==R.transferIn?.key)return null;continue}if(C(M,R)||f(M,R)&&!I(M,R)&&!I(R,M))return null}if(!i(w*8))return null;let v=new Set([...e,...o,...t]),T={base:nn(e,{blocks:v}),local:nn(o,{blocks:v}),remote:nn(t,{blocks:v})},A={};for(let N of["base","local","remote"]){let M=T[N];if(M.atoms.length||M.pins.length)return null;A[N]=new Map(M.marks.filter(R=>R.block).map(R=>[R.el,R.from]))}for(let N of u){let M=A.base.get(N.base);if(M===void 0)return null;for(let R of["local","remote"]){let V=A[R].get(N[R]);if(V===void 0)return null;for(let D of N.hunks[R])D.bs+=M,D.be+=M,D.ss+=V,D.se+=V}}for(let N of b)N.bs=N.deletion.bs+(N.sourceOffset||0),N.be=N.length===void 0?N.deletion.be:N.bs+N.length,N.ss=N.insertion.ss+(N.targetOffset||0),N.se=N.length===void 0?N.insertion.se:N.ss+N.length;let E={};for(let N of["local","remote"]){let M=0,R=0,V=[];for(let j of p[N]){if(!i(1))return null;j.bs>M&&V.push({from:M,to:j.bs,target:R}),M=j.be,R=j.se}M<T.base.text.length&&V.push({from:M,to:T.base.text.length,target:R});let D=b.filter(j=>j.side===N).map(j=>({from:j.bs,to:j.be,target:j.ss,destination:j.destination}));if(E[N]=Dn({base:T.base,side:T[N],retained:V,transfers:D,budget:r}),E[N].status!=="ready")return null}return i(T.base.text.length)?{owners:u,blocks:v,transfers:b,byOrigin:S,budget:r,prepared:{base:T.base,local:T.local,remote:T.remote,lines:!1,baseTokens:an(T.base.text,c),localEdits:{hunks:p.local,respell:new Map},remoteEdits:{hunks:p.remote,respell:new Map},localMap:E.local,remoteMap:E.remote,full:null}}:null}var Ns=/\S/;function gr({certificates:e,scopes:o,views:t,eligible:n,baseId:s,limit:h=2e4*32}){let l=$t(h),r=Symbol(),i=[],u=c=>{if(c>l.remaining)throw r;l.remaining-=c},w=(c,p=null)=>{if(u(1),!c||c.nodeType!==1||c.parentNode?.nodeType!==1||!n(c))return null;for(let C=c.parentNode;C;C=C.parentNode)if(u(1),C.nodeType===11)return null;let b="",S=0;for(let C of c.childNodes){if(u(1),C.nodeType!==3)return null;if(u(C.data.length*4+1),p){let m=p.flat.nodes[S++];if(!m||m.node!==C||m.s!==b.length||m.e!==b.length+C.data.length)return null}b+=C.data}return u(b.length*3+1),p&&(p.flat.atoms.length||p.flat.pins?.length||S!==p.flat.nodes.length||p.flat.text!==b)?null:Ns.test(b)?b:null};try{u(o[0].length+o[1].length+o[2].length+e.length);let c=o.map(b=>new Set(b)),p=new Map;for(let b of e){u(1);let S=p.get(b.source);S||p.set(b.source,S=[]),S.push(b)}for(let b of p.values()){let S=[null,null],C=[];for(let m of b){u(1);let{source:f,target:g,side:I,models:v,runs:T}=m;if(I!==0&&I!==1||!c[0].has(f)||!c[I+1].has(g))continue;let{V:A,A:E,idOf:N}=t[I],M=t[1-I],R=A.twin(f),V=M.V.twin(f),D=A.baseOf(g);if(!R||!V||!D||D===f||!c[0].has(D)||!c[I+1].has(R)||!c[2-I].has(V)||E.map.get(f)!==R||E.reverse.get(R)!==f||M.A.map.get(f)!==V||M.A.reverse.get(V)!==f||E.map.get(D)!==g||E.reverse.get(g)!==D||g.parentNode!==R.parentNode||D.parentNode!==f.parentNode||f.tagName!==R.tagName||f.tagName!==V.tagName||s(f)!==N(R)||s(f)!==M.idOf(V)||s(D)!==N(g))continue;let j=v.get(f),y=v.get(g);if(!j||!y)continue;let k=w(f,j),J=w(g,y),H=w(R),q=w(V);if(u((k?.length||0)+(q?.length||0)),k===null||J===null||H===null||q===null||q===k)continue;let Me=T.length>0,Oe=!1;for(let ie of T){if(u(1),ie.source!==f||ie.target!==g||!Number.isInteger(ie.from)||!Number.isInteger(ie.to)||!Number.isInteger(ie.targetFrom)||ie.from<0||ie.to<=ie.from||ie.to>k.length||ie.targetFrom<0||ie.targetFrom+ie.to-ie.from>J.length){Me=!1;break}u((ie.to-ie.from)*3);for(let xe=ie.from;xe<ie.to;xe++){if(k[xe]!==J[ie.targetFrom+xe-ie.from]){Me=!1;break}Ns.test(k[xe])&&(Oe=!0)}if(!Me)break}if(!Me||!Oe)continue;let Re=S[I];Re||(u(k.length),Re=S[I]={source:f,side:I,flat:j.flat,before:k,covered:new Uint8Array(k.length)});for(let ie of T)u(ie.to-ie.from),Re.covered.fill(1,ie.from,ie.to)}for(let m of S){if(!m)continue;let{source:f,side:g,flat:I,before:v,covered:T}=m;u(v.length*3+1);let A=-1,E=-1;for(let N=0;N<=v.length;N++)N<v.length&&T[N]?(A<0&&(A=N),E=N+1):(N===v.length||Ns.test(v[N]))&&A>=0&&(C.push({source:f,side:g,flat:I,from:A,to:E}),A=E=-1)}u(C.length),i.push(...C)}}catch(c){if(c!==r)throw c}return{records:i,budget:l}}var qi="http://www.w3.org/1999/xhtml";function Ki(e){let o=5381;for(let t=0;t<e.length;t++)o=(o<<5)+o^e.charCodeAt(t);return(o>>>0).toString(36)}function pn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===qi}function Fi(e){let o=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return o==="application/json"||o.endsWith("+json")}function _o(e,o){let t=e.getAttribute("src"),n=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let s=t;try{let h=new URL(t,o);s=h.origin+h.pathname+h.search}catch{}return"script|src|"+n+"|"+s}return"script|inline|"+n+"|"+Ki(e.textContent.trim())}var _i={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function ho(e,o=[],t=!1){if(!pn(e)||e.hasAttribute("src"))return null;let n=[_i,...o];for(let s=0;s<n.length;s++){let h=n[s];if(!h.match(e))continue;if(!Fi(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=h.identity(e);return l==null||l===""?null:{key:s+":"+l,raw:l,recognizer:h}}return null}function br(e,o,t){let n=new Set,s=h=>{pn(h)&&!o(h)&&n.add(_o(h,t))};s(e);for(let h of e.querySelectorAll("script"))s(h);return n}function Mo(e,o){let t=o.createElement("div");t.innerHTML="<script><\/script>";let n=t.firstChild;for(let s of e.attributes)n.setAttribute(s.name,s.value);return n.textContent=e.textContent,n}function wr(e,o,t){let n=[],s=[],h=new Map,l=t.trackRecovery?new Set:null,r=Array.from(e.querySelectorAll("script"));pn(e)&&r.unshift(e);for(let i of r){if(!pn(i)||t.ignored(i)||t.skip.has(i)||o.has(_o(i,t.baseURI)))continue;let u=i.ownerDocument.createElement("script");for(let w of i.attributes)u.setAttribute(w.name,w.value);if(u.textContent=i.textContent,t.beforeNodeAdded(u)===!1){l?.add(i);continue}u.hasAttribute("src")&&s.push(new Promise(w=>{u.addEventListener("load",()=>w()),u.addEventListener("error",()=>w())})),i.replaceWith(u),h.set(i,u),t.afterNodeAdded(u),n.push(u)}return{executed:n,loads:s,swapped:h,vetoed:l}}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 yr(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 As(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 kr(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(o,t)=>t.length%2===0?t+'\\"':o)}var Gi=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Yi=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function zo(e){try{return JSON.parse(e)}catch{return JSON.parse(Xi(e))}}function Xi(e){let o="",t=0,n=(s,h)=>{throw new Error(`Invalid relaxed JSON: ${s} at position ${h}`)};for(;t<e.length&&(t=As(e,t),!(t>=e.length));){let s=e[t];if("{}[]:".includes(s)){o+=s,t++;continue}if(s===","){let r=As(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 i=e.slice(t+1,r);s==="'"&&(i=kr(i)),o+='"'+i+'"',t=r+1;continue}let h=t;for(;h<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[h]);)h++;h===t&&n("unexpected character "+JSON.stringify(s),t);let l=e.slice(t,h);if(l==="true"||l==="false"||l==="null"||Gi.test(l)){o+=l,t=h;continue}if(Yi.test(l)){if(e[As(e,h)]===":"){o+='"'+l+'"',t=h;continue}n("unquoted value "+JSON.stringify(l),t)}n("invalid token "+JSON.stringify(l),t)}return o}function xr(e){try{return JSON.parse(e)}catch{}let o={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(s){let h=[],l=0;for(;l<s.length;){let r=s[l];if(/\s/.test(r)){l++;continue}if("{}".includes(r)){h.push({type:r,value:r}),l++;continue}if(r==="["){let c=!1,p=l+1;for(;p<s.length&&/\s/.test(s[p]);)p++;if(p<s.length&&/[a-zA-Z_]/.test(s[p])&&(c=!0),!c){h.push({type:r,value:r}),l++;continue}}if(r==="]"){h.push({type:r,value:r}),l++;continue}if(r===":"){h.push({type:o.COLON,value:r}),l++;continue}if(r===","){h.push({type:o.COMMA,value:r}),l++;continue}if(r==='"'||r==="'"){let c=r,p=l+1;for(;p<s.length&&s[p]!==c;)s[p]==="\\"&&p++,p++;h.push({type:o.STRING,value:s.substring(l+1,p),quoted:!0,sourceQuote:c}),l=p+1;continue}let i=l,u;for(;i<s.length&&!/[{},]/.test(s[i]);)if(s[i]===":"){let c=[":first",":last",":nth-child",":nth-of-type",":first-child",":last-child",":first-of-type",":last-of-type",":only-child",":only-of-type",":hover",":focus",":active",":visited",":disabled",":enabled",":checked",":empty",":root",":target",":not",":before",":after",":nth-last-child",":nth-last-of-type"],p=!1;for(let b of c){let S=b.substring(1);if(s.substring(i+1,i+1+S.length)===S){p=!0,i+=S.length;break}}if(!p)break}else if(s[i]==="["){for(i++;i<s.length&&s[i]!=="]";){if(s[i]==='"'||s[i]==="'"){let c=s[i];for(i++;i<s.length&&s[i]!==c;)s[i]==="\\"&&i++,i++}i++}i<s.length&&s[i]==="]"&&i++}else i++;u=s.substring(l,i);let w=o.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(u)?w=o.NUMBER:u==="true"||u==="false"||u==="null"?w=o.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(u)&&(w=o.SELECTOR),h.push({type:w,value:u,quoted:!1}),l=i}return h}function n(s){let h="";for(let l=0;l<s.length;l++){let r=s[l];if("{}".includes(r.type)||"[]".includes(r.type)){h+=r.value;continue}if(r.type===o.COLON){h+=r.value;continue}if(r.type===o.COMMA){let i=s[l+1];if(i&&(i.type==="}"||i.type==="]"))continue;h+=r.value;continue}if(r.type===o.STRING){let i=r.value;r.sourceQuote==="'"&&(i=kr(i)),h+=`"${i}"`;continue}if(r.type===o.NUMBER||r.type===o.BOOLEAN){h+=r.value;continue}h+=`"${r.value}"`}return h}try{let s=t(e),h=n(s);return JSON.parse(h)}catch(s){throw new Error("Invalid extraction rules syntax: "+s.message)}}var zt=Symbol("hyper-morph-json-merge:missing"),Ji=["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 Qi(e,o,t){Object.defineProperty(e,o,{value:t,enumerable:!0,writable:!0,configurable:!0})}var Zi=/^[A-Za-z_$][\w$]*$/;function el(e,o){return Zi.test(o)?e===""?o:e+"."+o:e+"["+JSON.stringify(o)+"]"}function tl(e,o){return e===""?o:e+"."+o}function $o(e,o,t,n,s,h){if(e.onConflict){let l=r=>r===zt?void 0:r;e.onConflict({path:o,base:l(t),local:l(n),remote:l(s),resolved:l(h)})}return h}function qn(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(!qn(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)||!qn(e[n],o[n]))return!1;return!0}return!1}function Ms(e,o,t,n,s,h){return qn(o,t)?o:qn(o,e)?t:qn(t,e)?o:po(o)&&po(t)?nl(po(e)?e:{},o,t,n,s,h):Array.isArray(o)&&Array.isArray(t)?il(e,o,t,n,s,h):$o(n,s,e,o,t,t)}function Tr(e,o,t,n,s,h){return o===zt&&t===zt?zt:o===zt?e===zt?t:qn(t,e)?zt:$o(n,s,e,o,t,t):t===zt?e===zt?o:qn(o,e)?zt:$o(n,s,e,o,t,zt):Ms(e,o,t,n,s,h)}function nl(e,o,t,n,s,h){let l={},r=new Set([...Object.keys(e),...Object.keys(o),...Object.keys(t)]);for(let i of r){let u=Tr(Oo(e,i)?e[i]:zt,Oo(o,i)?o[i]:zt,Oo(t,i)?t[i]:zt,n,el(s,i),tl(h,i));u!==zt&&Qi(l,i,u)}return l}function ol(e){return e===null||typeof e!="object"}function Go(e){return typeof e+":"+String(e)}function sl(e,o){for(let t of o){let n=new Set;for(let s of t){if(!Oo(s,e))return!1;let h=s[e];if(typeof h!="string"&&typeof h!="number")return!1;let l=Go(h);if(n.has(l))return!1;n.add(l)}}return!0}function rl(e,o,t,n,s){let h=[e,o,t],l=!0;for(let r of h)for(let i of r)po(i)||(l=!1);if(l){let r=n.keyPaths.get(s),i=r!==void 0?[r]:n.keyCandidates;for(let u of i)if(sl(u,h))return{kind:"keyed",field:u};return null}for(let r of h){let i=new Set;for(let u of r){if(!ol(u))return null;let w=Go(u);if(i.has(w))return null;i.add(w)}}return{kind:"self"}}function il(e,o,t,n,s,h){let l=Array.isArray(e)?e:[],r=rl(l,o,t,n,h),i=Array.isArray(e)&&e.length===o.length&&e.length===t.length;if(!r||r.kind==="self"&&i)return i?o.map((I,v)=>Ms(e[v],I,t[v],n,s+"["+v+"]",h)):$o(n,s,e,o,t,t);let u=r.kind==="self"?Go:I=>Go(I[r.field]),w=I=>r.kind==="self"?s+"["+JSON.stringify(I)+"]":s+"["+r.field+"="+JSON.stringify(I[r.field])+"]",c=new Map,p=I=>{let v=new Map;for(let T of I){let A=u(T);v.set(A,T),c.has(A)||c.set(A,w(T))}return v},b=p(l),S=p(o),C=p(t),m=new Map,f=new Set([...b.keys(),...S.keys(),...C.keys()]);for(let I of f){let v=Tr(b.has(I)?b.get(I):zt,S.has(I)?S.get(I):zt,C.has(I)?C.get(I):zt,n,c.get(I),h);v!==zt&&m.set(I,v)}let g=[];for(let I of t){let v=u(I);m.has(v)&&g.push(v)}for(let I=0;I<o.length;I++){let v=u(o[I]);if(!m.has(v)||g.includes(v))continue;let T=0;for(let A=I-1;A>=0;A--){let E=g.indexOf(u(o[A]));if(E!==-1){T=E+1;break}}g.splice(T,0,v)}return g.map(I=>m.get(I))}function ll(e){let o=new Map,t=[];for(let n of e.keyCandidates||[]){let s=n.lastIndexOf(":");s>=0?o.set(n.slice(0,s),n.slice(s+1)):t.push(n)}return{keyCandidates:[...t,...Ji],keyPaths:o,onConflict:e.onConflict||null}}function Os(e,o,t,n={}){return Ms(e===void 0?zt:e,o,t,ll(n),"","")}function al(e,o){let t=/^\s*/.exec(o)[0],n=/\s*$/.exec(o.slice(t.length))[0],s=o.slice(t.length,o.length-n.length),h=t.slice(t.lastIndexOf(`
|
|
5
|
+
`)+1),l=/\n([ \t]+)\S/.exec(s),r;if(!l)r=JSON.stringify(e);else{let i=l[1],u=i.length>h.length&&i.startsWith(h)?i.slice(h.length):" ";r=JSON.stringify(e,null,u).replace(/\n/g,`
|
|
6
|
+
`+h)}return t+r.replace(/</g,"\\u003c")+n}function Yo(e,o,t,n={}){let s=n.parse||zo,h=[],l=[],r=(p,b)=>{if(typeof p!="string")return zt;try{return s(p)}catch(S){return h.push(`${b} side is not valid JSON (${S.message})`),zt}},i=r(o,"local"),u=r(t,"remote");if(i===zt)return{text:t,warnings:h,conflicts:l};if(u===zt)return{text:o,warnings:h,conflicts:l};let w=r(e,"base"),c=Os(w===zt?void 0:w,i,u,{...n,onConflict:p=>{l.push(p),n.onConflict?.(p)}});return qn(c,u)?{text:t,warnings:h,conflicts:l}:qn(c,i)?{text:o,warnings:h,conflicts:l}:{text:al(c,t),warnings:h,conflicts:l}}var vr=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function eo(e){if(!e)return!1;let{startContainer:o,startOffset:t,endContainer:n,endOffset:s}=e;if(!o||!n||!Number.isInteger(t)||!Number.isInteger(s)||t<0||s<0||t>vr(o)||s>vr(n)||o.getRootNode()!==n.getRootNode())return!1;let h=o.ownerDocument.createRange();return h.setStart(o,t),h.setEnd(n,s),h.startContainer===o&&h.startOffset===t}function Xn(e,o,t={}){if(!eo(e))return null;let{startContainer:n,startOffset:s,endContainer:h,endOffset:l}=e;if(n===h&&(n.nodeType===3||n.nodeType===8))return n.nodeValue.slice(s,l);if(n===h&&s===l)return"";let r=new Set;for(let m=n;m;m=m.parentNode)r.add(m);let i=h;for(;!r.has(i);)i=i.parentNode;let u=(m,f)=>{let g=i.ownerDocument.createRange(),I=i.ownerDocument.createRange();return g.setStart(m[0],m[1]),g.collapse(!0),I.setStart(f[0],f[1]),I.collapse(!0),g.compareBoundaryPoints(0,I)},w=(m,f=!1)=>[m.parentNode,Array.prototype.indexOf.call(m.parentNode.childNodes,m)+Number(f)],c=[],p;if(o==="plain"){p="";let m=f=>{if(f.nodeType===3||f.nodeType===8){let g=p.length;p+=f.nodeValue,c.push({s:g,e:p.length,a:[f,0],b:[f,f.nodeValue.length],node:f})}else for(let g of f.childNodes)m(g)};m(i)}else{let m=t.blocks;if(!m){m=new Set;let g=I=>{I!==i&&I.nodeType===1&&ks.has(I.tagName)&&m.add(I);for(let v of I.childNodes)g(v)};g(i)}let f=nn(Array.from(i.childNodes),{blocks:m,atomize:g=>!!t.atoms?.has(g),ignored:t.ignored});p=f.text;for(let g of f.nodes)c.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 f.atoms)c.push({s:g.i,e:g.i+1,a:w(g.el),b:w(g.el,!0)});for(let g=0;g<f.text.length;g++){if(f.text[g]!==kt)continue;let I=f.marks.find(T=>T.block&&T.to===g+1),v=f.marks.find(T=>T.block&&T.from===g+1);if(I)c.push({s:g,e:g+1,a:[I.el,I.el.childNodes.length],b:w(I.el,!0)});else if(v)c.push({s:g,e:g+1,a:w(v.el),b:[v.el,0]});else return null}}c.sort((m,f)=>m.s-f.s);let b=m=>{if(m[0].nodeType===3||m[0].nodeType===8){let g=c.find(I=>I.node===m[0]);return g?g.s+m[1]:null}let f=0;for(let g of c){if(u(m,g.a)<=0)return g.s;if(u(m,g.b)<0)return null;f=g.e}return f},S=b([n,s]),C=b([h,l]);return S!==null&&C!==null&&S<=C?p.slice(S,C):null}function Zn(e,o){let t=e;for(let n of o.path)if(t=n==="content"?t?.content:t?.childNodes[n],!t)return null;return[t,o.offset]}function Sr(e,o){if(!e||!o)return null;let t=Zn(e,o.start),n=Zn(e,o.end);return t&&n?{startContainer:t[0],startOffset:t[1],endContainer:n[0],endOffset:n[1]}:null}var Nr=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ar(e,o,t){if(!o)return;let n=new Map,s=new Map,h=r=>{if(!r)return null;if(s.has(r))return s.get(r);let u=r.local.map(w=>Zn(o.localRoot,{path:w,offset:0})?.[0]).map(w=>w&&t(w)).filter(Boolean).map(w=>({node:w,parent:w.parentNode,previous:w.previousSibling,next:w.nextSibling,fragment:Nr(w)}));return s.set(r,u),u},l=r=>{let i=Sr(o.localRoot,r);if(!i)return null;let u=t(i.startContainer),w=t(i.endContainer);if(!u||!w)return null;let c={...i,startContainer:u,endContainer:w};return eo(c)?c:null};for(let r of e){let i=r.recovery;if(!i||n.has(i))continue;let u={subject:h(i.subject),span:null,scope:null,touched:new Set};if(i.text){u.span=l(i.text.local.span),u.scope=l(i.text.local.scope);let w=u.span;if(w){let c=w.startContainer.ownerDocument.createRange();c.setStart(w.startContainer,w.startOffset),c.setEnd(w.endContainer,w.endOffset);let p=b=>{if(c.intersectsNode(b)){u.touched.add(b);for(let S of b.childNodes)p(S)}};p(c.commonAncestorContainer)}}if(i.structure){for(let w of[i.structure.localPlacement])w&&(h(w.parent),w.before.forEach(h),w.after.forEach(h));for(let w of i.structure.localOrder||[])h(w)}n.set(i,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 h=r=>{let i=r.node;if(!n(i)||i.parentNode!==r.parent)return!1;let u=w=>Array.prototype.indexOf.call(i.parentNode.childNodes,w);return!(r.previous&&n(r.previous)&&r.previous.parentNode===i.parentNode&&u(r.previous)>=u(i)||r.next&&n(r.next)&&r.next.parentNode===i.parentNode&&u(r.next)<=u(i))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!s.subject.length||!s.subject.every(h))return!1;if(e.text){let r=e.text.local,i=u=>u&&n(u.startContainer)&&n(u.endContainer);return i(s.span)&&i(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,i=s.subject[0].node;return(r.namespaceURI?i.getAttributeNS(r.namespaceURI,r.localName):i.getAttribute(r.qualifiedName))===o.local}let l=e.structure;if(l.localOrder){let r=-1,i=null;for(let u of l.localOrder){let w=t.localState.refs.get(u)?.[0]?.node;if(!w||!n(w)||i&&w.parentNode!==i)return!1;let c=Array.prototype.indexOf.call(w.parentNode.childNodes,w);if(c<=r)return!1;i=w.parentNode,r=c}return!0}return l.localAction==="moved"||s.subject.every(r=>Nr(r.node)===r.fragment)}var cl=1,dn=e=>!!e&&e.nodeType===1,Xo=e=>dn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function to(e,o=null,t=null){let n=new Map,s=new Map,h=w=>{if(!o){o=new WeakMap;let c=[e];for(;c.length;){let p=c.pop();Xo(p)&&(o.set(p.content,p),c.push(p.content));for(let b=p.firstChild;b;b=b.nextSibling)b.nodeType===1&&c.push(b)}}return o.get(w)||null},l=(w,c)=>{let p=s.get(w);if(!p){p=new Map;let b=0;for(let S=w.firstChild;S;S=S.nextSibling)p.set(S,b++);s.set(w,p)}return p.get(c)},r=w=>{if(!w)return null;if(t&&t.has(w))return r(t.get(w));if(w===e)return[];let c=n.get(w);if(c!==void 0)return c;let p=w.parentNode,b=null;if(p&&p.nodeType===11){let S=h(p),C=S?r(S):null;C&&(b=C.concat(["content",l(p,w)]))}else if(p){let S=r(p);S&&(b=S.concat([l(p,w)]))}return n.set(w,b),b};return{root:e,pathOf:r,logicalParent:w=>{let c=w.parentNode;return c&&c.nodeType===11?h(c):c},indexIn:l,containerPath:w=>{if(w.nodeType===11){let p=h(w),b=r(p);return b?b.concat(["content"]):null}let c=r(w);return c&&Xo(w)?c.concat(["content"]):c},ownerOf:h}}var Cn=e=>Xo(e)?e.content:e;function Or(e){let{L:o,R:t,unitsOf:n,provenance:s,policy:h}=e,l=[];return{note:(w,c)=>{l.push([w,c])},finish:w=>l.length?u(w):null};function u(w){let c={base:to(e.roots.base),local:to(e.roots.local),remote:to(e.roots.remote)},p=$=>$==="local"?o:t,b=($,a)=>{if(!a)return null;if($.map.has(a))return $.map.get(a);let O=[],P=dn(a)?c.base.logicalParent(a):a.parent;for(;P&&!$.map.has(P);P=c.base.logicalParent(P))O.push(P);if(!P||!$.identical.has(P))return null;let K=$.map.get(P);for(let Z=O.length-1;Z>=0&&K;Z--)K=Cn(K).childNodes[c.base.indexIn(O[Z].parentNode,O[Z])];return K?dn(a)?Cn(K).childNodes[c.base.indexIn(a.parentNode,a)]||null:n(K)[n(a.parent).indexOf(a)]||null:null},S=new Map,C=new Map,m=new WeakMap,f=0,g=($,a)=>{let O=S.get($);O||S.set($,O=[]),O.push(a)};(function $(a){C.set(a,f++);let O=s.get(a);if(O&&!O.pinned){for(let P of[O.base,O.local,O.remote])if(P)if(Array.isArray(P))for(let K of P)g(K,a);else g(P,a)}if(Xo(a)){m.set(a.content,a);for(let P=a.content.firstChild;P;P=P.nextSibling)$(P)}for(let P=a.firstChild;P;P=P.nextSibling)$(P)})(w);let I=new Map;c.out=to(w,m,I);let v={refs:new Map,spans:new Map,anchors:new Map,via:I,outOwners:m,outRoot:w,localRoot:e.roots.local},T=$=>dn($)?[$]:$.nodes,A=($,a)=>{let O=c[a].logicalParent($);if(!O)return null;for(let P of n(O))if(!dn(P)&&P.nodes.includes($))return P;return null},E=($,a)=>$==null?null:Array.isArray($)?$.length?A($[0],a):null:$,N=$=>{let a=new Set,O=[];for(let P of $)for(let K of S.get(P)||[])a.has(K)||(a.add(K),O.push(K));return O.sort((P,K)=>C.get(P)-C.get(K))},M=new Map,R=$=>{let a=$.b||$.l||$.r,O=M.get(a);if(O)return O;let P=[];for(let K of[$.b,$.l,$.r])K&&P.push(...T(K));return O=N(P),M.set(a,O),O},V=$=>({b:$,l:b(o,$),r:b(t,$)}),D=($,a)=>{let O=p(a).reverse.get($);if(O)return V(O);for(let P of N(T($))){let K=s.get(P);if(K&&!K.base&&K.local&&K.remote)return{b:null,l:E(K.local,"local"),r:E(K.remote,"remote")}}return a==="local"?{b:null,l:$,r:null}:{b:null,l:null,r:$}},j=new Map,y=$=>{let a=s.get($);if(!a||a.pinned)return null;let O=E(a.base,"base");if(O)return V(O);let P=E(a.local,"local"),K=E(a.remote,"remote");if(P){let Z=o.reverse.get(P);if(Z)return V(Z)}if(K){let Z=t.reverse.get(K);if(Z)return V(Z)}return P||K?{b:null,l:P,r:K}:null},k=$=>(j.has($)||j.set($,y($)),j.get($)),J=($,a)=>dn($)?c[a].logicalParent($):$.parent,H=new Map,q=new Map,Me=($,a)=>(dn($)?[c[a].pathOf($)]:$.nodes.map(O=>c[a].pathOf(O))).filter(Boolean),Oe=$=>{let a=$.b||$.l||$.r,O=$.b?"base":$.l?"local":"remote",P=q.get(a);if(P)return P;let K=!dn(a),Z=Me(a,O)[0],U=`${O[0]}:${JSON.stringify(Z===void 0?null:Z)}${K?":run":""}`,de=H.get(U);if(de)return q.set(a,de),de;let we=R($);return de={key:U,nodeType:dn(a)?1:a.kind==="comment"?8:3,base:$.b?Me($.b,"base"):[],local:$.l?Me($.l,"local"):[],remote:$.r?Me($.r,"remote"):[],merged:we.map(le=>c.out.pathOf(le)).filter(Boolean),live:[]},H.set(U,de),q.set(a,de),v.refs.set(de,we),de},Re={base:new Map,local:new Map,remote:new Map},ie=new Map,xe=($,a)=>{let O=J($,a);if(!O||O.nodeType!==1)return null;let P=Re[a].get(O);if(!P){let Z=n(O),U=de=>Oe(a==="base"?V(de):D(de,a));P={parent:U(O),refs:Z.map(U),index:new Map(Z.map((de,we)=>[de,we]))},Re[a].set(O,P)}let K=P.index.get($)??-1;return{parent:P.parent,before:P.refs.slice(K+1),after:P.refs.slice(0,Math.max(0,K)).reverse()}},qe=$=>{let a=$.parentNode;if(!a)return null;let O=ie.get(a);if(!O){let K=a.nodeType===11?m.get(a):a,Z=K&&K.nodeType===1?k(K):null;if(!Z)return null;let U=[],de=[],we=new Map;for(let Ae of a.childNodes){let W=k(Ae),X=W&&Oe(W),pe=U.length,be=U.length-1;X&&X!==U[be]&&(U.push(X),be++);let he={ref:X,group:be,after:pe};de.push(he),we.set(Ae,he)}let le=U.length;for(let Ae=de.length-1;Ae>=0;Ae--){let W=de[Ae];W.before=le,W.ref&&(le=W.group)}O={parent:Oe(Z),refs:U,index:we},ie.set(a,O)}let P=O.index.get($);return{parent:O.parent,before:O.refs.slice(P.before),after:O.refs.slice(0,P.after).reverse()}},fe=$=>dn($)?$.outerHTML:$.value,x=$=>dn($)?"element":$.kind==="comment"?"comment":"text",Y=($,a)=>({path:$,offset:a}),ae=($,a,O)=>{if(!$)return null;let P=c[O],K=0;if(a){let Z=dn(a)?a:a.nodes[a.nodes.length-1];Z.parentNode&&(K=P.indexIn(Z.parentNode,Z)+1)}return Y(P.containerPath($),K)},oe=($,a)=>{let O=J($,"base"),P=O?b(p(a),O):null;if(!dn(P))return null;let K=n(O),Z=null;for(let U=K.indexOf($)-1;U>=0&&!Z;U--){let de=b(p(a),K[U]);de&&J(de,a)===P&&(Z=de)}return ae(P,Z,a)},Ee=($,a,O,P)=>{let K=c[P],Z=0;for(let U=0;U<$.nodes.length;U++){let de=$.nodes[U],we=de.nodeValue.length,le=U===$.nodes.length-1;if((O==="start"?a<Z+we:a<=Z+we)||le)return Y(K.pathOf(de),Math.max(0,Math.min(a-Z,we)));Z+=we}return null},De=($,a)=>{let O=c[a],P=$.firstChild,K=$.lastChild;return P&&P.nodeType===3&&K.nodeType===3?{start:Y(O.pathOf(P),0),end:Y(O.pathOf(K),K.nodeValue.length)}:{start:Y(O.pathOf($),0),end:Y(O.pathOf($),$.childNodes.length)}},Ne=($,a,O)=>{for(let U of $.nodes)if(O==="start"?U.s<=a&&a<U.e:U.s<a&&a<=U.e)return{kind:"text",node:U.node,offset:a-U.s};let P=O==="start"?a:a-1,K=()=>{for(let U of $.nodes)if(U.s===a||U.e===a)return{kind:"text",node:U.node,offset:a-U.s};return null},Z=$.atomAt.get(P);if(Z)return{kind:O==="start"?"before":"after",node:Z.el};if($.text[P]===kt){let U=$.marks.find(we=>we.block&&we.to===P+1);if(U)return O==="start"?{kind:"end",node:U.el}:{kind:"after",node:U.el};let de=$.marks.find(we=>we.block&&we.from===P+1);if(de)return O==="start"?{kind:"before",node:de.el}:{kind:"startOf",node:de.el}}return K()},nt=($,a)=>Ne($,a,"end")||Ne($,a,"start"),Xe=($,a)=>{switch(a.kind){case"text":return Y($.pathOf(a.node),a.offset);case"end":return Y($.containerPath(a.node),Cn(a.node).childNodes.length);case"startOf":return Y($.containerPath(a.node),0);default:{let O=a.node.parentNode;return Y($.containerPath(O),$.indexIn(O,a.node)+(a.kind==="after"?1:0))}}},ht=($,a,O,P,K)=>{let Z=Ne($,a,O);return Z?Xe(c[P],Z):K()},Ge=($,a,O,P)=>{let K=$.textNodes.map(le=>({s:le.ms,e:le.me,start:{kind:"text",node:le.node,offset:0},end:{kind:"text",node:le.node,offset:le.me-le.ms}}));for(let[le,Ae]of $.atomOut)K.push({s:le,e:le+1,start:{kind:"before",node:Ae},end:{kind:"after",node:Ae}});for(let[le,Ae]of $.breakOut)K.push({s:le,e:le+1,start:{kind:"end",node:Ae},end:{kind:"after",node:Ae}});for(let le of K)if(le.start.kind==="text"&&le.s<a&&a<le.e)return{kind:"text",node:le.start.node,offset:a-le.s};if(O!=="empty"){let le=K.find(Ae=>O==="start"?Ae.s===a:Ae.e===a);if(le)return O==="start"?le.start:le.end}let Z=K.find(le=>le.e===a);if(Z)return Z.end;let U=K.find(le=>le.s===a);if(U)return U.start;let de=null,we=null;for(let le of K)le.e<=a&&(!de||le.e>de.e)&&(de=le),le.s>=a&&(!we||le.s<we.s)&&(we=le);return de?de.end:we?we.start:P()},rt=($,a)=>{if(!a)return null;if(a.kind==="text"){let K=$.nodes.find(Z=>Z.node===a.node);return K?K.s+Math.min(a.offset,K.e-K.s):null}let O=$.atoms.find(K=>K.el===a.node);if(O)return a.kind==="after"?O.i+1:O.i;let P=$.marks.find(K=>K.el===a.node);return P?a.kind==="before"&&P.block&&$.text[P.from-1]===kt&&!$.marks.some(K=>K.block&&K.to===P.from)?P.from-1:a.kind==="startOf"||a.kind==="before"?P.from:a.kind==="end"&&P.block?P.to-1:P.to:null},Ot=($,a,O,P)=>{for(let de of $.nodes)if(O==="start"?de.s<=a&&a<de.e:de.s<a&&a<=de.e)return{kind:"text",node:de.node,offset:a-de.s};let K=O==="start"?a:a-1;if(!$.atomAt.has(K)&&$.text[K]!==kt){for(let de of $.nodes)if(de.s===a||de.e===a)return{kind:"text",node:de.node,offset:a-de.s}}let Z=$.atomAt.get(K);if(Z)return{kind:O==="start"?"before":"after",node:Z.el};if($.text[K]===kt){let de=$.marks.find(le=>le.block&&le.to===K+1);if(de)return O==="start"?{kind:"end",node:de.el}:{kind:"after",node:de.el};let we=$.marks.find(le=>le.block&&le.from===K+1);if(we)return O==="start"?{kind:"before",node:we.el}:{kind:"startOf",node:we.el}}let U=$.marks.find(de=>de.block&&de.from===a);return U?{kind:"startOf",node:U.el}:P?{kind:O==="start"?"startOf":"end",node:P}:null},Ct=$=>{if(!$)return null;if($.kind==="wholeStart"||$.kind==="wholeEnd"){let a=wt($.node);return $.kind==="wholeStart"?a.start:a.end}return Xe(c.out,$)},wt=$=>{let a=$.firstChild,O=$.lastChild;return a&&a.nodeType===3&&O.nodeType===3?{start:Y(c.out.pathOf(a),0),end:Y(c.out.pathOf(O),O.nodeValue.length)}:{start:Y(c.out.pathOf($),0),end:Y(c.out.pathOf($),$.childNodes.length)}},Nt=$=>{let a=J($,"base"),O=a?R(V(a))[0]:null;if(!O)return null;let P=Cn(O),K=n(a);for(let Z=K.indexOf($)-1;Z>=0;Z--){let U=R(V(K[Z])).filter(de=>de.parentNode===P);if(U.length)return{kind:"after",node:U[U.length-1]}}return{kind:"startOf",node:O}},Lt=($,a,O,P,K,Z)=>({text:$,start:a,end:O,fragment:P,span:K,scope:Z}),qt=($,a,O,P,K)=>Lt($,a,O,$.slice(a,O),P,K),cn=($,a,O,P,K)=>(v.spans.set($,{start:a,end:O,scopeStart:P,scopeEnd:K}),$),It=new Map,Gt=new Map,wn=($,a,O)=>{let P=`text:${$.key}:${a}:${O}`,K=Gt.get(P)||0;return Gt.set(P,K+1),`${P}:${K}`},Dt=($,a)=>{let O,P,K,Z="plain",U,de,we,le,Ae,W=(be,he,ee,te,z)=>{if(!be){let ne=oe(z,te);return qt("",0,0,{start:ne,end:ne},{start:ne,end:ne})}return qt(be.value,he,ee,{start:Ee(be,he,he===ee?"end":"start",te),end:Ee(be,ee,"end",te)},{start:Ee(be,0,"start",te),end:Ee(be,be.value.length,"end",te)})};if(a.site==="run"){let{bRun:be,lRun:he,rRun:ee,node:te,c:z}=a;O=V(be),P=z.bs,K=z.be,U=W(be,z.bs,z.be,"base",be),de=W(he,z.ls,z.le,"local",be),we=W(ee,z.rs,z.re,"remote",be);let ne=te?te.nodeValue:"",Te=Ce=>te?{kind:"text",node:te,offset:Ce}:Nt(be);le=cn(qt(ne,z.ms,z.me,{start:Ct(Te(z.ms)),end:Ct(Te(z.me))},{start:Ct(Te(0)),end:Ct(Te(ne.length))}),Te(z.ms),Te(z.me),Te(0),Te(ne.length)),Ae=te||(Nt(be)||{}).node||null}else if(a.site==="whole"){let be=a.el,he=s.get(be);O=V(he.base),P=0,K=$.base.length;let ee=(z,ne,Te)=>{let Ce=De(ne,Te);return qt(z,0,z.length,Ce,Ce)};U=ee($.base,he.base,"base"),de=ee($.local,he.local,"local"),we=ee($.remote,he.remote,"remote");let te=wt(be);le=cn(qt($.resolved,0,$.resolved.length,te,te),{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be},{kind:"wholeStart",node:be},{kind:"wholeEnd",node:be}),Ae=be}else if(a.site==="comment"){let{bRun:be,lRun:he,rRun:ee,node:te}=a;O=V(be),P=0,K=$.base.length;let z=(Pe,ve)=>{if(!Pe){let Ze=oe(be,ve);return qt("",0,0,{start:Ze,end:Ze},{start:Ze,end:Ze})}let _e=Pe.nodes[0],Je={start:Y(c[ve].pathOf(_e),0),end:Y(c[ve].pathOf(_e),Pe.value.length)};return qt(Pe.value,0,Pe.value.length,Je,Je)};U=z(be,"base"),de=z(he,"local"),we=z(ee,"remote");let ne=$.resolved,Te=Pe=>te?{kind:"text",node:te,offset:Pe}:Nt(be),Ce={start:Ct(Te(0)),end:Ct(Te(ne.length))};le=cn(qt(ne,0,ne.length,Ce,Ce),Te(0),Te(ne.length),Te(0),Te(ne.length)),Ae=te||(Nt(be)||{}).node||null}else{let{fb:be,fl:he,fr:ee,scope:te}=a,z=a.merged;Z="html",O=te.base?V(te.base):D(te.local,"local"),P=$.bs,K=$.be;let ne=se=>{let Ie=te[se];for(let Be=te.at-1;Be>=0;Be--){let He=te.units[Be],Ke=se==="base"?He:b(p(se),He);if(Ke&&J(Ke,se)===Ie)return Ke}return null},Te=se=>()=>ae(te[se],ne(se),se),Ce=(se,Ie,Be,He,Ke)=>{let pt=bn=>bn?Xe(c[Ke],bn):Te(Ke)(),tt=Ie===Be?nt(se,Ie):Ne(se,Ie,"start"),Kt=Ie===Be?nt(se,Ie):Ne(se,Be,"end"),Ht=pt(tt),un={start:Ht,end:Ie===Be?Ht:pt(Kt)},bt=a.full?a.full(Ke):null;if(!bt)return Lt(se.text,Ie,Be,He,un,{start:pt(Ne(se,0,"start")),end:pt(Ne(se,se.text.length,"end"))});let lt=tt?rt(bt,tt):null,$e=Kt?rt(bt,Kt):null,vt=lt===null?0:lt,ct=Math.max(vt,$e===null?bt.text.length:$e),jt=pt(Ne(bt,0,"start"));return Lt(bt.text,vt,ct,co(bt,vt,ct),un,{start:jt,end:bt.text.length?pt(Ne(bt,bt.text.length,"end")):jt})};U=a.synthetic?null:Ce(be,$.bs,$.be,$.base,"base"),de=Ce(he,$.lss,$.lse,$.local,"local"),we=Ce(ee,$.rss,$.rse,$.remote,"remote");let[Pe,ve]=$.range||[0,0],_e=z.out,Je=()=>{let se=Cn(z.node);for(let Ie=te.at-1;Ie>=0;Ie--){let Be=R(V(te.units[Ie])).filter(He=>He.parentNode===se);if(Be.length)return{kind:"after",node:Be[Be.length-1]}}for(let Ie=te.at;Ie<te.units.length;Ie++){let Be=R(V(te.units[Ie])).filter(He=>He.parentNode===se);if(Be.length)return{kind:"before",node:Be[0]}}return{kind:"startOf",node:z.node}};if(_e.via)for(let[se,Ie]of _e.via)I.set(se,Ie);let Ze=Ge(z,Pe,Pe===ve?"empty":"start",Je),Ut=Pe===ve?Ze:Ge(z,ve,"end",Je),Pt=_e.text.length?Ot(_e,0,"start",z.node):Je(),L=_e.text.length?Ot(_e,_e.text.length,"end",z.node):Pt,G=rt(_e,Ze),re=rt(_e,Ut),ge=G===null?0:G,ye=Math.max(ge,re===null?_e.text.length:re);le=cn(Lt(_e.text,ge,ye,co(_e,ge,ye),{start:Ct(Ze),end:Ct(Ut)},{start:Ct(Pt),end:Ct(L)}),Ze,Ut,Pt,L);let ce=v.spans.get(le);if(ce.flat=_e,!_e.text.length){let se=Ct(Pt),Ie=Zn(w,se),Be=Ie[0],He=Ie[1];ce.empty={parent:Be.nodeType===11?m.get(Be):Be,previous:Be.childNodes[He-1]||null,next:Be.childNodes[He]||null}}Ae=Ze?Ze.node:z.node}let X=Oe(O),pe=(a.site==="whole"||a.site==="comment"||(a.policy||h)!=="both")&&$.resolved!==$.local;return{key:a.site==="comment"&&It.get(O.b||O.l||O.r)||wn(X,P,K),subject:X,localLost:pe,anchor:Ae,text:{encoding:Z,base:U,local:de,remote:we,merged:le,liveSpan:null,liveScope:null}}},rn=($,a)=>{let O=k(a.el),P=Oe(O),K=a.sample;return{key:`attr:${P.key}:${K.namespaceURI||""}:${K.localName}`,subject:P,localLost:$.resolved!==$.local,anchor:a.el,attribute:{namespaceURI:K.namespaceURI||null,localName:K.localName,qualifiedName:K.name}}},Yt=($,a)=>{let O=$.detail,P=a.unit||V(a.subject),K=Oe(P),Z=v.refs.get(K),U=P.l?xe(P.l,"local"):null,de=P.r?xe(P.r,"remote"):null,we=Z.length?qe(Z[0]):null,le,Ae,W,X=null,pe=null,be=a.deleted;switch(O){case"both-reordered":{le=Ae="reordered";let he=new Set(a.rKept),ee=a.lKept.filter(Ce=>he.has(Ce)&&R(V(Ce)).length),te=Ce=>C.get(R(V(Ce))[0]);X=ee.map(Ce=>Oe(V(Ce))),pe=ee.slice().sort((Ce,Pe)=>te(Ce)-te(Pe)).map(Ce=>Oe(V(Ce)));let z=Ce=>!dn(Ce)&&Ce.kind!=="comment"&&Ce.nodes.every(Pe=>!/[^\t\n\f\r ]/.test(Pe.data)),ne=ee.filter(Ce=>!z(Ce)),Te=ne.slice().sort((Ce,Pe)=>te(Ce)-te(Pe));W=ne.some((Ce,Pe)=>Ce!==Te[Pe]);break}case"both-moved":le=Ae="moved",W=!U||!Z.some(he=>{let ee=he===Z[0]?we:qe(he);return ee&&ee.parent===U.parent});break;case"edit-beats-delete":le=be==="local"?"deleted":"edited",Ae=be==="remote"?"deleted":"edited",W=be==="local";break;case"move-beats-delete":le=be==="local"?"deleted":"moved",Ae=be==="remote"?"deleted":"moved",W=be==="local";break;case"remote-wins":le="edited",Ae="edited",W=!0;break;default:le=Ae="inserted",W=a.localLost}return{key:`structure:${K.key}:${O}`,subject:K,localLost:W,anchor:Z[0]||null,structure:{localAction:le,remoteAction:Ae,localPlacement:U,remotePlacement:de,mergedPlacement:we,localOrder:X,mergedOrder:pe,localFragment:O==="both-reordered"||!P.l?null:fe(P.l),fragmentKind:x(P.b||P.l||P.r)}}};for(let[$,a]of l){if($.kind!=="structure")continue;let O=a.unit||V(a.subject),P=O.b||O.l||O.r;!dn(P)&&P.kind==="comment"&&It.set(P,`structure:${Oe(O).key}:${$.detail}`)}let fn=new Map;for(let[$,a]of l){if($.kind==="structure"){let Z=Oe(a.unit||V(a.subject)),U=`structure:${Z.key}:${$.detail}`,de=fn.get(U);if(de&&de.structure){$.recovery=de;let we=v.refs.get(Z);$.el==null&&we.length&&($.el=dn(we[0])?we[0]:c.out.logicalParent(we[0]));continue}}let O=$.kind==="text"?Dt($,a):$.kind==="attr"?rn($,a):Yt($,a),P=fn.get(O.key);P||(P={version:cl,key:O.key,localLost:O.localLost,subject:O.subject,applied:!1,unavailable:null},fn.set(O.key,P),v.anchors.set(P,O.anchor)),O.text&&(P.text=O.text),O.attribute&&(P.attribute=O.attribute),O.structure&&(P.structure=O.structure),O.text&&(P.localLost=O.localLost),$.recovery=P;let K=v.refs.get(O.subject);$.kind==="structure"&&$.el==null&&K.length&&($.el=dn(K[0])?K[0]:c.out.logicalParent(K[0])),$.kind==="text"&&$.node==null&&K.length&&O.subject.nodeType===8&&($.node=K[0])}return v}}function Ir(e,o,t){if(!o)return;let{lookup:n,vetoed:s,vetoedAttrs:h,liveAttr:l}=t,r=t.ignored||(()=>!1),i=to(t.liveRoot),u=y=>!!y&&i.containerPath(y)!==null,w=y=>{let k=y.parentNode;return k&&k.nodeType===11?o.outOwners.get(k)||null:k},c=y=>{for(let k=y;k;k=w(k))if(o.via.has(k)&&(k=o.via.get(k)),s.has(k)||t.vetoedLive?.has(f(k)))return!0;return!1},p=y=>Array.from(Cn(y).children).filter(k=>!r(k)),b=(y,k)=>p(y)[p(k.parentNode).indexOf(k)],S=(y,k)=>{let J=null,H=null,q=0;for(let ie=k.previousSibling;ie;ie=ie.previousSibling){if(ie.nodeType===1&&!r(ie)){J=ie;break}ie.nodeType===3&&(q+=ie.nodeValue.length)}for(let ie=k.nextSibling;ie&&!H;ie=ie.nextSibling)ie.nodeType===1&&!r(ie)&&(H=ie);let Me=J?b(y,J):null,Oe=H?b(y,H):null;if(J&&!Me||H&&!Oe)return null;let Re=[];for(let ie=Me?Me.nextSibling:Cn(y).firstChild;ie&&ie!==Oe;ie=ie.nextSibling)ie.nodeType===3&&Re.push(ie);return Re.length?{nodes:Re,lead:q}:null},C=y=>{let k=[],J=y;for(;J&&!o.via.has(J);J=J.parentNode)k.push(J);if(!J||!k.length)return null;let H=f(o.via.get(J));for(let Oe=k.length-1;Oe>0&&H;Oe--)H=b(H,k[Oe]);if(!H)return null;let q=k[0];if(q.nodeType===3)return S(H,q);let Me=q.nodeType===1?b(H,q):null;return Me?{nodes:[Me],lead:0}:null},m=y=>{let k=n(y),J=k?{nodes:Array.isArray(k)?k:[k],lead:0}:o.via.size?C(y):null;if(!J)return null;let H=J.nodes.filter(u);return H.length?{nodes:H,lead:J.lead}:null},f=y=>{let k=m(y);return k?k.nodes[0]:null},g=y=>{if(!y)return null;if(y.kind==="text"){let q=m(y.node);if(!q)return null;let Me=q.nodes,Oe=y.offset+q.lead,Re=0;for(let ie=0;ie<Me.length;ie++){let xe=Me[ie].nodeValue.length;if(Oe<=Re+xe||ie===Me.length-1)return Oe>=Re&&Oe<=Re+xe?[Me[ie],Oe-Re]:null;Re+=xe}return null}let k=f(y.node);if(!k)return null;if(y.kind==="end")return[Cn(k),Cn(k).childNodes.length];if(y.kind==="startOf")return[Cn(k),0];if(y.kind==="wholeStart")return k.firstChild?[k.firstChild,0]:[k,0];if(y.kind==="wholeEnd")return k.lastChild?[k.lastChild,k.lastChild.nodeValue.length]:[k,k.childNodes.length];let J=k.parentNode;if(!J)return null;let H=Array.prototype.indexOf.call(J.childNodes,k);return[J,y.kind==="after"?H+1:H]},I=y=>({blocks:new Set((y.flat?.marks||[]).filter(k=>k.block).map(k=>f(k.el)).filter(Boolean)),atoms:new Set((y.flat?.atoms||[]).map(k=>f(k.el)).filter(Boolean)),ignored:r}),v=(y,k,J,H)=>{if(!y||!k||!eo(y)||!eo(k))return!1;for(let Oe of[y,k])if(!u(Oe.startContainer)||!u(Oe.endContainer))return!1;let q=J.merged;if(q.start===q.end&&(y.startContainer!==y.endContainer||y.startOffset!==y.endOffset))return!1;let Me=I(H);return Xn(k,J.encoding,Me)===q.text&&Xn(y,J.encoding,Me)===q.text.slice(q.start,q.end)},T=new Map,A=y=>{let k=y.parentNode;return k?(T.has(k)||T.set(k,new Map(Array.from(k.childNodes,(J,H)=>[J,H]))),T.get(k).get(y)):-1},E=(y,k)=>{if(!k)return!1;let J=i.logicalParent(y);if(!k.parent.live.includes(J))return!1;let H=A(y);for(let[q,Me]of[["before",1],["after",-1]]){let Oe=H;for(let Re of k[q]){if(Re.live.includes(y))continue;let ie=Re.live.filter(qe=>qe!==y&&qe.parentNode===y.parentNode);if(!ie.length)continue;let xe=Me===1?Math.min(...ie.map(A)):Math.max(...ie.map(A));if(Me*(xe-Oe)<=0)return!1;Oe=xe}}return!0},N=y=>{let k=y.structure;if(k.mergedOrder){let J=new Set(y.subject.live.map(Cn)),H=null,q=-1;for(let Me of k.mergedOrder){let Oe=Me.live.find(Re=>J.has(Re.parentNode));if(!Oe||H&&Oe.parentNode!==H||A(Oe)<=q)return!1;H=Oe.parentNode,q=A(Oe)}return y.subject.live.length>0}return y.subject.live.some(J=>E(J,k.mergedPlacement))},M=(y,k)=>{let J=g(y),H=g(k);return J&&H?{startContainer:J[0],startOffset:J[1],endContainer:H[0],endOffset:H[1]}:null},R=new Set,V=y=>{if(!y||R.has(y))return;R.add(y);let k=[];for(let J of o.refs.get(y)||[]){let H=m(J);if(H)for(let q of H.nodes)k.includes(q)||k.push(q)}y.live=k},D=y=>{y&&(V(y.parent),y.before.forEach(V),y.after.forEach(V))},j=new Set;for(let y of e){let k=y.recovery;if(!k||j.has(k))continue;j.add(k),V(k.subject),k.structure&&(D(k.structure.localPlacement),D(k.structure.remotePlacement),D(k.structure.mergedPlacement),(k.structure.localOrder||[]).forEach(V),(k.structure.mergedOrder||[]).forEach(V));let J=o.anchors.get(k),H=J?f(J):null,q=!!H;if(k.text){let x=o.spans.get(k.text.merged),Y=x?M(x.start,x.end):null,ae=x?M(x.scopeStart,x.scopeEnd):null;if(x?.empty){let oe=x.empty,Ee=oe.previous?{kind:"after",node:oe.previous}:{kind:"startOf",node:oe.parent},De=oe.next?{kind:"before",node:oe.next}:{kind:"end",node:oe.parent},Ne=M(Ee,De);!Ne||Ne.startContainer!==Ne.endContainer||Ne.startOffset!==Ne.endOffset?Y=null:Y=ae=Ne}v(Y,ae,k.text,x)||(Y=ae=null),k.text.liveSpan=Y,k.text.liveScope=Y?ae:null,Y||(q=!1)}k.structure&&q&&(q=N(k)),k.attribute&&q&&(q=l(H,k.attribute,y.resolved));let Me=(!!k.attribute||!!k.text&&H?.tagName==="TEXTAREA")&&!!h&&[J,H].some(x=>h.get(x)?.has(k.attribute?k.attribute.qualifiedName:"value")),Oe=o.localState?.states.get(k),Re=!!k.text&&[...t.removedVetoes||[]].some(x=>Oe?.touched.has(x)),ie=k.structure?.localAction==="inserted"&&[...s].some(x=>x===J||J?.contains(x)),xe=J&&c(J)||Me||Re||ie,qe=xe&&Mr(k,y,o,u);qe&&(Re||ie&&k.localLost)&&(q=!1);let fe=!q&&qe&&xe;k.applied=q,k.unavailable=q?null:fe?"hook-veto":"missing-output",fe&&(k.localLost=!1),!q&&k.text&&(k.text.liveSpan=k.text.liveScope=null)}}function Jo(e,o,t){let n=to(o),s=to(t),h=c=>!!c&&s.containerPath(c)!==null,l=c=>{if(c===o)return t;let p=n.pathOf(c);if(p&&o!==t){let b=Zn(t,{path:p,offset:0});if(b&&b[0].nodeType===c.nodeType)return b[0]}return c},r=new Set,i=c=>{!c||r.has(c)||(r.add(c),c.live=c.live.map(l).filter(h))},u=c=>{c&&(c.startContainer=l(c.startContainer),c.endContainer=l(c.endContainer))},w=new Set;for(let c of e){c.node===o&&t.tagName==="SCRIPT"&&(c.node=t),c.el===o&&c.kind==="structure"&&(c.el=t);let p=c.recovery;if(!p||w.has(p))continue;if(w.add(p),i(p.subject),p.text){u(p.text.liveSpan),u(p.text.liveScope);let S=p.text.liveSpan,C=p.text.liveScope,m=p.text.merged,f=g=>!!g&&eo(g)&&h(g.startContainer)&&h(g.endContainer);(!f(S)||!f(C)||Xn(C,p.text.encoding)!==m.text||Xn(S,p.text.encoding)!==m.text.slice(m.start,m.end))&&(p.text.liveSpan=null,p.text.liveScope=null,p.applied=!1,p.unavailable="missing-output")}let b=p.structure;if(b){for(let S of[b.localPlacement,b.remotePlacement,b.mergedPlacement])S&&(i(S.parent),S.before.forEach(i),S.after.forEach(i));(b.localOrder||[]).forEach(i),(b.mergedOrder||[]).forEach(i),p.subject.live.length||(p.applied=!1,p.unavailable="missing-output")}}}var mo=e=>e?.nodeType===1,Io=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function fl({provenance:e,parentOf:o,twins:t,baseOf:n,build:s,ignored:h,remoteWins:l,discarded:r}){let i=new Map,u=new WeakMap;function w(b,S,C,m=!1){if(!mo(b)||!mo(C))return null;let f=i.get(b);if(f)(m||!f.selected&&S==="remote")&&(f.parent=o(C),f.port=C,f.sourceSide=S,f.selected=m);else{let g=u.get(b)||null;f={owner:b,parent:o(C),port:C,sourceSide:S,originalParent:o(b),originalPort:b,selected:m,state:g?"built":"planned",output:g,disposition:null},i.set(b,f)}return f}function c(b,S){if(!mo(b)||!mo(S))return;u.has(b)||u.set(b,S);let C=i.get(b);C&&C.state!=="attached"&&!C.output&&(C.output=S,C.state="built")}function p(b){if(!i.size)return;let S=new Map,C=new WeakMap,m=new WeakMap,f=new WeakSet,g=new Set,I=(D,j)=>{if(!D)return;if(Array.isArray(D)){for(let k of D)I(k,j);return}let y=S.get(D);y||S.set(D,y=[]),y.push(j)},v=(D,j)=>{if(!D)return;let y=[D];for(;y.length;){let k=y.pop();I(k,j);for(let J of Io(k).childNodes)y.push(J)}};function T(D,j=null,y=!1){if(f.has(D))return;f.add(D),C.set(D,j);let k=e.get(D),J=y||!!(k&&l(k.remote||k.base));m.set(D,J);let H={node:D,kind:"node",authority:J};if(k?.pinned)v(k.local,{...H,kind:"ignored"});else if(k?.unchanged)for(let q of[k.base,k.local,k.remote])v(q,{...H,kind:"unchanged"});else if(k){for(let q of[k.base,k.local,k.remote])I(q,H);if(mo(k.local))for(let q of Io(k.local).children)h(q)&&v(q,{...H,kind:"ignored"})}for(let q of Io(D).childNodes)T(q,D,J)}let A=D=>{if(D.output&&f.has(D.output))return D.state="attached",D.disposition="node",!0;let{local:j,remote:y}=t(D.owner);for(let k of[D.owner,j,y]){let J=S.get(k);if(J?.length){let H=J.find(q=>q.kind==="node")||J[0];return D.output=H.node,D.state="attached",D.disposition=H.kind,!0}}return!1},E=(D,j)=>(S.get(D)||[]).find(k=>k.kind==="node"&&mo(k.node)&&(!k.authority||j.sourceSide==="remote"))?.node,N=(D,j,y)=>{let k=S.get(D)||[],J=y?[...k].reverse():k;for(let H of J){if(H.kind!=="node")continue;let q=H.node;for(;q&&C.get(q)!==j;)q=C.get(q);if(q)return q}return null},M=(D,j,y)=>{let k=Io(j);for(let J=y?.previousSibling;J;J=J.previousSibling){let H=N(J,j,!0);if(H){k.insertBefore(D,H.nextSibling);return}}for(let J=y?.nextSibling;J;J=J.nextSibling){let H=N(J,j,!1);if(H){k.insertBefore(D,H);return}}k.appendChild(D)};function R(D,j,y){let k=j==="base"?D:n(D,j),J=i.get(k);J&&J!==y&&V(J)}function V(D){if(D.state==="attached"||D.disposition==="remote-wins"||g.has(D)||A(D))return;g.add(D);let{local:j,remote:y}=t(D.owner);if(l(y||D.owner)){if(!y){D.disposition="remote-wins",r(D.owner,j),g.delete(D);return}D.parent=o(y),D.port=y,D.sourceSide="remote"}if(R(D.parent,D.sourceSide,D),A(D)){g.delete(D);return}let k=E(D.parent,D),J=D.port;if(!k){if(R(D.originalParent,"base",D),A(D)){g.delete(D);return}let q=D.originalParent;for(J=D.originalPort;q&&!k;)k=E(q,D),k||(J=q,q=o(q))}if(!k)throw new Error("A planned move has no allowed surviving parent");let H=D.output||s(D.owner);D.output=H,D.state="built",M(H,k,J),T(H,k,m.get(k)||!1),A(D),g.delete(D)}T(b);for(let D of i.values())V(D)}return{planned:i,has:b=>i.has(b),plan:w,produced:c,drain:p}}function go(e,o,t,n,s,h,l,r,i,u,w,c,p){let b=null;return fl({provenance:e,parentOf:m=>{if(!m)return null;let f=o(m);if(f||m.parentNode?.nodeType!==11)return f;if(!b){b=new WeakMap;let g=[c,p];for(;g.length;){let I=g.pop(),v=Io(I);v!==I&&b.set(v,I);for(let T of v.children)g.push(T)}}return b.get(m.parentNode)||null},twins:m=>({local:s(t,m),remote:s(n,m)}),baseOf:(m,f)=>m&&(f==="local"?t:n).reverse.get(m)||null,build:m=>h(m,s(t,m),s(n,m),!1),ignored:l,remoteWins:r,discarded:(m,f)=>{f&&w(m,f,t)&&!i.some(g=>g.detail==="remote-wins"&&g.base===m)&&u({kind:"structure",el:null,detail:"remote-wins",base:m,local:f,remote:null},{subject:m})}})}function ul({parent:e,base:o,views:t,eligible:n,ignored:s,remoteWins:h,budget:l=$t(2e4*32),maxUnits:r=256,maxCharacters:i=2e4}){let u=(f,g=null)=>({status:f,reason:g,parent:e,records:[]});if(t.some(({V:f})=>f.asBase)||s(e)||h(e)||t.some(({V:f})=>!f.el||s(f.el)||h(f.el)))return u("none");let w=o.length+t[0].V.units.length+t[1].V.units.length;if(w>r)return u("fallback","unit-limit");let c=Symbol(),p=f=>{if(f>l.remaining)throw c;l.remaining-=f,l.crossParentSteps=(l.crossParentSteps||0)+f},b=new Map,S=0,C=f=>{if(p(1),b.has(f))return b.get(f);let g=f.nodeType===1?f.childNodes:f.nodes;p(g.length*4+1);let I=f.nodeType===1?Array.from(g):g,v=0;for(let E=0;E<I.length;E++){let N=I[E];if(N.nodeType!==3||E&&I[E-1].nextSibling!==N)return b.set(f,null),null;v+=N.data.length}if(v>i-S)throw c;p(v*8+1),S+=v;let T=nn(I);if(T.text.includes(kt))return b.set(f,null),null;let A={unit:f,nodes:I,flat:T};return b.set(f,A),A},m=[];try{p(w*8+1);for(let f=0;f<2;f++){let g=t[f].V,I=t[1-f].V,v=[],T=new Map;for(let A=0;A<o.length;A++){p(1);let E=o[A];if(E.kind!=="text"||g.twin(E))continue;let N=I.twin(E);if(!N||N.kind!=="text"||!I.here(N))continue;let M=C(E),R=C(N);if(!M||!R||!/\S/.test(M.flat.text))continue;p(M.flat.text.length*2+1);let V=M.flat.text;T.set(V,(T.get(V)||0)+1),v.push({source:E,opposite:N,sourceModel:M,oppositeModel:R,index:A})}for(let A of v){let{source:E,opposite:N,sourceModel:M,oppositeModel:R,index:V}=A,D=[];for(let Y of[-1,1]){p(1);let ae=o[V+Y];if(!ae||ae.nodeType!==1||!n(ae)||s(ae)||h(ae))continue;let oe=M.nodes[0],Ee=M.nodes.at(-1);if(Y===-1?oe?.previousSibling!==ae:Ee?.nextSibling!==ae)continue;let De=g.twin(ae),Ne=I.twin(ae);if(!De||!Ne||!g.here(De)||I.here(Ne)||g.baseOf(De)!==ae||I.baseOf(Ne)!==ae||!n(De)||!n(Ne)||s(De)||s(Ne)||h(De)||h(Ne)||De.tagName!==ae.tagName||Ne.tagName!==ae.tagName||De.namespaceURI!==ae.namespaceURI||Ne.namespaceURI!==ae.namespaceURI)continue;let nt=C(ae),Xe=C(De),ht=C(Ne);if(!nt||!Xe||!ht||!/\S/.test(nt.flat.text))continue;let Ge=nt.flat.text,rt=M.flat.text,Ot=Xe.flat.text;if(p((Ge.length+rt.length+Ot.length)*3+1),Ot.length!==Ge.length+rt.length)continue;let Ct=Y===-1;(Ct?!Ot.startsWith(Ge)||!Ot.endsWith(rt):!Ot.startsWith(rt)||!Ot.endsWith(Ge))||D.push({owner:ae,target:De,moved:Ne,ownerBase:nt,joined:Xe,ownerOther:ht,targetFrom:Ct?Ge.length:0,retainedFrom:Ct?0:rt.length})}if(!D.length)continue;if(D.length!==1||T.get(M.flat.text)!==1)return u("fallback","ambiguous-origin");let j=D[0],{owner:y,target:k,moved:J,ownerBase:H,joined:q,ownerOther:Me,targetFrom:Oe,retainedFrom:Re}=j;if(p(m.length+1),m.some(Y=>Y.owner===y))return u("fallback","ambiguous-owner");let ie={source:E,target:k,from:0,to:M.flat.text.length,targetFrom:Oe},xe=Dn({base:M.flat,side:q.flat,retained:[],transfers:[{from:ie.from,to:ie.to,target:Oe,destination:y}],budget:l});if(xe.status!=="ready"||xe.covers(ie.from,ie.to)!==!0)return u("fallback",xe.reason||"work-limit");let qe=[{unit:E,model:M,from:0,to:M.flat.text.length},null,null];qe[f+1]={unit:k,model:q,from:Oe,to:Oe+M.flat.text.length},qe[2-f]={unit:N,model:R,from:0,to:R.flat.text.length};let fe=[H,null,null];fe[f+1]=q,fe[2-f]=Me;let x=[y,null,null];x[f+1]=k,x[2-f]=J,m.push({side:f,parent:e,source:E,target:k,owner:y,owners:x,ownerModels:fe,native:qe,models:b,runs:[ie],proof:xe,retained:[{source:y,target:k,from:0,to:H.flat.text.length,targetFrom:Re}]})}}return m.length?{status:"ready",reason:null,parent:e,records:m}:u("none")}catch(f){if(f!==c)throw f;return u("fallback","work-limit")}}function Cr({describe:e,parentOf:o,...t}){let n=new WeakMap,s=new WeakMap,h=t.budget||$t(2e4*32),l=r=>{if(!r)return null;if(n.has(r))return n.get(r);n.set(r,{status:"planning",parent:r,records:[]});let i=e(r),u=i?ul({...t,...i,parent:r,budget:h}):{status:"none",reason:null,parent:r,records:[]};if(n.set(r,u),u.status==="ready")for(let w of u.records)s.set(w.owner,[w]);return u};return{get:l,forOwner(r){return l(o(r))?.status==="ready"&&s.get(r)||null}}}function dl(e,o){if(e.side!==0)return null;let t=e.native[0].model,n=e.ownerModels[0],s=e.native[1].from!==0,h=(I,v)=>s?[...I.nodes,...v.nodes]:[...v.nodes,...I.nodes],l=e.ownerModels.reduce((I,v)=>I+v.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(l*8>o.remaining)return null;o.remaining-=l*8;let r={base:h(n,t),local:e.ownerModels[1].nodes,remote:h(e.ownerModels[2],e.native[2].model)},i=nn(r.base),u=e.ownerModels[1].flat,w=nn(r.remote),c=s?n.flat.text.length:0,p=s?0:t.flat.text.length,b=Dn({base:i,side:u,retained:e.retained.map(I=>({from:p+I.from,to:p+I.to,target:I.targetFrom})),transfers:e.runs.map(I=>({from:c+I.from,to:c+I.to,target:I.targetFrom,destination:e.owner})),budget:o});if(b.status!=="ready"||b.covers(0,i.text.length)!==!0)return null;let S=e.ownerModels[2].flat,C=e.native[2].model.flat,m=[];for(let[I,v,T,A]of[[n.flat,S,p,s?0:C.text.length],[t.flat,C,c,s?S.text.length:0]]){let E=xs(I,I,v).remoteMap.bTo,N=-1;for(let M=0;M<I.text.length;M++){if(E[M]<0){N=-1;continue}let R=m.at(-1);N>=0&&R.to===T+M&&R.target+R.to-R.from===A+E[M]?R.to++:(m.push({from:T+M,to:T+M+1,target:A+E[M]}),N=M)}}let f=Dn({base:i,side:w,retained:m,transfers:[],budget:o});if(f.status!=="ready")return null;let g=xs(i,u,w,{},{local:b,remote:f});return g.localEdits.hunks.length?null:(g.localMap=b,g.remoteMap=f,{nodes:r,prepared:g})}function Lr({L:e,R:o,twinIn:t,unitsOf:n,view:s,parentOf:h,ignored:l,remoteWins:r,eligible:i,build:u,out:w,policy:c,provenance:p,textMappers:b,segments:S,conflicts:C,conflict:m,decisions:f}){let g=$t(2e4*32),I=D=>{let j=0;for(let y=D;y;y=h(y))if(++j>64||y.nodeType===1&&(l(y)||r(y)))return!1;return!0},v=Cr({parentOf:h,eligible:i,ignored:l,remoteWins:r,budget:g,describe(D){let j=t(e,D),y=t(o,D);return!j||!y||!I(D)||!I(j)||!I(y)?null:{base:n(D),views:[{A:e,V:s(e,j,D,!1)},{A:o,V:s(o,y,D,!1)}]}}}),T=new WeakSet,A=new WeakMap,E=new WeakSet,N=[];function M(D){if(!D||T.has(D))return;T.add(D);let j=v.get(D);if(j?.status==="ready")for(let y of j.records){if((D.tagName==="TEMPLATE"&&D.content?D.content:D).childNodes.length!==y.native[0].model.nodes.length+1||!y.owners.every(I))continue;let J=dl(y,g);if(!J)continue;let H={record:y,payload:J,state:"planned",output:null,result:null};A.set(y.owner,H),E.add(y.source),E.add(y.native[2].unit),N.push(H)}}function R(D,j){let y=A.get(D);if(!y)return!1;if(!y.result){if(y.result=Ko({...y.payload.nodes,prepared:y.payload.prepared,out:w,policy:c,provenance:p,textMappers:b,conflicts:C,conflict:m,decisions:f,node:j}),y.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");S.push(...y.result.segments),y.decision={kind:"text",node:j,source:"local"},f.push(y.decision)}return y.decision.node=j,j.replaceChildren(...y.result.nodes),y.output=j,y.state="built",!0}function V(D){if(!N.length)return;let j=new WeakSet,y=new WeakMap,k=new WeakMap,J=new WeakMap,H=xe=>xe.tagName==="TEMPLATE"&&xe.content?xe.content:xe,q=(xe,qe)=>{if(!xe)return;if(Array.isArray(xe)){for(let x of xe)q(x,qe);return}let fe=J.get(xe);fe||J.set(xe,fe=[]),fe.push(qe)},Me=(xe,qe=null,fe=!1)=>{j.add(xe),y.set(xe,qe);let x=p.get(xe),Y=fe||!!(x&&r(x.remote||x.base));if(k.set(xe,Y),x)for(let ae of[x.base,x.local,x.remote])q(ae,xe);if(!(x?.pinned||x?.unchanged))for(let ae of H(xe).childNodes)Me(ae,xe,Y)},Oe=xe=>(J.get(xe)||[]).find(qe=>qe.nodeType===1&&!k.get(qe)&&!p.get(qe)?.pinned&&!p.get(qe)?.unchanged),Re=(xe,qe)=>{for(let fe of J.get(xe)||[]){let x=fe;for(;x&&y.get(x)!==qe;)x=y.get(x);if(x)return x}return null},ie=(xe,qe,fe)=>{let x=H(qe);for(let Y=fe.nextSibling;Y;Y=Y.nextSibling){let ae=Re(Y,qe);if(ae){x.insertBefore(xe,ae);return}}for(let Y=fe.previousSibling;Y;Y=Y.previousSibling){let ae=Re(Y,qe);if(ae){x.insertBefore(xe,ae.nextSibling);return}}x.appendChild(xe)};Me(D);for(let xe of N){let{record:qe}=xe,fe=Oe(qe.owner)||Oe(qe.owners[1])||Oe(qe.owners[2]);if(fe)(!xe.result||xe.output!==fe||xe.result.nodes.some(x=>!j.has(x)||y.get(x)!==fe)||fe.textContent!==xe.result.text)&&(R(qe.owner,fe),Me(fe,y.get(fe),k.get(fe)));else{let x=qe.parent,Y=qe.owner,ae=null;for(;x&&!ae;)ae=Oe(x),ae||(Y=x,x=h(x));if(!ae)throw new Error("A cross-parent payload has no allowed surviving parent");fe=xe.output||u(qe.owner,qe.owners[1],qe.owners[2],!1),xe.result||R(qe.owner,fe),ie(fe,ae,Y),Me(fe,ae,k.get(ae))}xe.state="attached"}}return{ensureParent:M,ensureOwner(D){M(h(D))},consumes(D){return E.has(D)},render:R,drain:V}}var Mn=/\S/,Er=/[\p{L}\p{N}]/u;function no(e,o,t,n){if(e?.nodeType!==1||!o(e))return!1;for(let s=e.firstChild;s;s=s.nextSibling)if(n(t,1),s.nodeType!==3)return!1;return!!e.firstChild}function Is(e,o,t){for(let n=e.parentNode;n;n=n.parentNode)if(t(o,1),n.nodeType===11)return!1;return!0}function Rr(e,o,t,n,s){let h=t(e,n),l=t(o,n),r=null,i=null,u=null,w=null;s(n,h.length+l.length);for(let c of h)Er.test(c.raw)&&(r||=c,i=c);for(let c of l)Er.test(c.raw)&&(u||=c,w=c);return!!(r&&u&&(r.raw===u.raw||i.raw===w.raw))}function hl({base:e,V:o,A:t,source:n,original:s,current:h,edited:l,destination:r,at:i,ownLength:u,eligible:w,model:c,tokensOf:p,budget:b,charge:S}){let C=s.flat.text,m=h.flat.text,f=l.flat.text,g=r.flat.text;if(S(b,C.length+m.length+g.length),C.startsWith(m)||C.endsWith(m))return!1;let I=Mn.test(g.slice(0,i)),v=Mn.test(g.slice(i+u));if(I===v)return!1;let T=I?0:i+u,A=I?i:g.length;for(;T<A&&!Mn.test(g[T]);)T++;for(;A>T&&!Mn.test(g[A-1]);)A--;let E=g.slice(T,A);if(In(E,g,p(r,b),b,S,!0)!==T)return!1;let N=In(E,C,p(s,b),b,S,!0);if(N<0)return!1;let M=N+E.length,R=!Mn.test(C.slice(0,N)),V=!Mn.test(C.slice(M));if(R===V||In(E,m,p(h,b),b,S,!1)>=0)return!1;let D=R?C.slice(M):C.slice(0,N),j=R?f.length-D.length:0;if(S(b,C.length+f.length),j<0||!Mn.test(D)||In(D,f,p(l,b),b,S,!0)!==j||!Mn.test(R?f.slice(0,j):f.slice(D.length)))return!1;for(let y of e){if(S(b,1),y===n||!no(y,w,b,S))continue;let k=c(y,null,b);if(In(E,k.flat.text,p(k,b),b,S,!1)>=0)return!1}for(let y of o.units){if(S(b,1),y===h.unit||y===r.unit||!no(y,w,b,S))continue;let k=c(y,t,b);if(In(E,k.flat.text,p(k,b),b,S,!1)>=0)return!1}return!0}function Pr({base:e,views:o,side:t,attempt:n,eligible:s,blocked:h,baseId:l,model:r,tokensOf:i,charge:u,exhausted:w,limit:c}){if(c<=0)return null;let p=$t(c),{V:b,A:S,idOf:C}=o[t],m=o[1-t],[f,g,I,v]=n,T=null;try{for(let A=f;A<=g;A++){u(p,1);let E=e[A];if(E.parentNode?.nodeType!==1||h.has(E)||S.identical.has(E)||m.A.identical.has(E)||!no(E,s,p,u)||l(E))continue;let N=b.twin(E),M=m.V.twin(E);if(!N||!M||!b.here(N)||!m.V.here(M)||S.map.get(E)!==N||S.reverse.get(N)!==E||m.A.map.get(E)!==M||m.A.reverse.get(M)!==E||C(N)||m.idOf(M)||N.tagName!==E.tagName||M.tagName!==E.tagName||!no(N,s,p,u)||!no(M,s,p,u)||!Is(E,p,u)||!Is(N,p,u)||!Is(M,p,u))continue;let R=r(E,null,p),V=r(N,S,p),D=r(M,m.A,p),j=R.flat.text,y=V.flat.text,k=D.flat.text;if(u(p,j.length+y.length+k.length),!Mn.test(j)||!Mn.test(y)||!Mn.test(k)||j===y||j===k||y===k||!Rr(R,V,i,p,u)||!Rr(R,D,i,p,u))continue;let J=null,H=!1;for(let Oe=I;Oe<=v;Oe++){u(p,1);let Re=b.units[Oe],ie=b.baseOf(Re);if(!ie||ie===E||h.has(ie)||ie.parentNode!==E.parentNode||Re.parentNode!==N.parentNode||ie.tagName!==E.tagName||Re.tagName!==E.tagName||S.map.get(ie)!==Re||S.reverse.get(Re)!==ie||l(ie)!==C(Re)||!no(ie,s,p,u)||!no(Re,s,p,u))continue;let xe=r(ie,null,p),qe=r(Re,S,p),fe=xe.flat.text,x=qe.flat.text;if(u(p,fe.length),!Mn.test(fe)||x.length<=fe.length)continue;let Y=i(qe,p),ae=In(fe,x,Y,p,u,!0);if(!(ae<0||In(j,x,Y,p,u,!0,ae,ae+fe.length)<0&&!hl({base:e,V:b,A:S,source:E,original:R,current:V,edited:D,destination:qe,at:ae,ownLength:fe.length,eligible:s,model:r,tokensOf:i,budget:p,charge:u}))){if(J){H=!0;break}J=Re}}if(!J||H)continue;let q=t===0?N:M,Me=t===0?M:N;(T||=[]).push({source:E,local:q,remote:Me,models:[R,t===0?V:D,t===0?D:V]})}}catch(A){if(A!==w)throw A}return T}var Hn=/\S/,gn=/\s/,pl=/[\s\u001e]/g,Cs=/[^\s\p{P}\u001e\ufffc]/u;function ml(e,o,t,n,s,h,l){let r=0;for(let i of e)l(h,1),i.nodeType===1&&!n.baseOf(i)&&r++;if(r<2)return!1;for(let i of e){if(i.nodeType!==1||n.baseOf(i))continue;let u=s.get(i).flat;if(u.atoms.length||u.pins?.length)continue;l(h,u.text.length*2+o.length+t.length);let w=new Uint8Array(u.text.length);for(let c of t)c.target===i&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c of o)c.target===i&&w.fill(1,c.targetFrom,c.targetFrom+c.to-c.from);for(let c=0;c<u.text.length;c++)if(!w[c]&&Hn.test(u.text[c]))return!0}return!1}function gl(e,o,t){let{source:n,models:s,retained:h,runs:l}=e,r=s.get(n).flat.text;t(o,r.length*2+h.length+l.length);let i=new Uint8Array(r.length);for(let u of h)u.source===n&&(t(o,u.to-u.from),i.fill(1,u.from,u.to));for(let u of l)t(o,u.to-u.from),i.fill(1,u.from,u.to);for(let u=0;u<r.length;u++)if(!i[u]&&Hn.test(r[u]))return!1;return!0}function bl(e,o,t,n,s,h,l,r,i,u){let w=h.get(e),c=h.get(o),p=w.flat.text,b=l.get(e);i(u,p.length*2+t.length);let S=p.length,C=0;for(let g=0;g<p.length;g++)!gn.test(p[g])&&!b[g]&&(S=Math.min(S,g),C=g+1);if(S>=C)return null;for(let g=S;g<C;g++)if(!gn.test(p[g])&&b[g])return null;let m=-1;for(let g of t)if(g.target===o&&g.from<=S&&g.to>S){m=g.targetFrom+S-g.from;break}if(m<0)return null;let f=p.slice(S,C);if(i(u,f.length*(t.length+2)),c.flat.text.slice(m,m+f.length)!==f)return null;for(let g=S;g<C;g++){if(gn.test(p[g]))continue;let I=!1;for(let v of t)if(v.target===o&&v.from<=g&&v.to>g&&v.targetFrom+g-v.from===m+g-S){I=!0;break}if(!I)return null}if(w.flat.atoms.length||c.flat.atoms.length){i(u,w.flat.atoms.length+c.flat.atoms.length);let g=0,I=c.flat.atoms;for(;g<I.length&&I[g].i<m;)g++;for(let v of w.flat.atoms){if(v.i<S||v.i>=C)continue;let T=I[g++];if(!T||T.i!==m+v.i-S||c.alignment?.reverse.get(T.el)!==v.el)return null}if(g<I.length&&I[g].i<m+C-S)return null}for(let[g,I,v]of[[n,e,S],[s,o,m]]){let T=!1;for(let A of g){let E=h.get(A),N=l.get(A),M=r(E,u);for(let R=0;R<M.length;R++){let V=M[R].from,D=V+f.length;if(i(u,f.length*2+1),E.flat.text.slice(V,D)!==f)continue;let j=R;for(;j<M.length&&M[j].to<D;)i(u,1),j++;if(j===M.length||M[j].to!==D)continue;let y=!0;for(let k=V;k<D;k++)if(!gn.test(E.flat.text[k])&&N[k]){y=!1;break}if(y){if(T||A!==I||V!==v)return null;T=!0}}}if(!T)return null}return f}function wl(e,o,t,n,s,h,l,r){if(l(r,s.length+h.length+(n.length+1)*t.length*2),!t)return!1;let i=n.indexOf(t);return i<0||n.lastIndexOf(t)!==i||!h.some(u=>u.from===i)||!h.some(u=>u.to===i+t.length)?!1:s.some(u=>u.source===e&&u.target===o&&u.from===0&&u.to===t.length&&u.targetFrom===i)}function Br({base:e,views:o,eligible:t,baseId:n,ignored:s,remoteWins:h,atomKey:l,limit:r=2e4*8}){if(r<=0)return null;let i=Symbol(),u=(v,T)=>{if(T>v.remaining)throw i;v.remaining-=T},w=[new Map,new Map];for(let v=0;v<2;v++)for(let T=0;T<o[v].V.units.length;T++)w[v].set(o[v].V.units[T],T);let c=new Int32Array(e.length),p=new Int32Array(e.length),b=v=>o.every(({V:T},A)=>{let E=T.twin(v);return E&&w[A].has(E)}),S=-1;for(let v=0;v<e.length;v++)c[v]=S,b(e[v])&&(S=v);S=e.length;for(let v=e.length-1;v>=0;v--)p[v]=S,b(e[v])&&(S=v);let C=new Map,m=(v,T)=>{if(u(T,1),C.has(v))return C.get(v);let A=v.firstChild,E=1;for(;A;){if(u(T,E*8+8),A.nodeType===3&&u(T,A.data.length*8),A.nodeType===1&&Tn.has(A.tagName)&&!s(A)&&!h(A)&&A.firstChild){A=A.firstChild,E++;continue}for(;A&&A!==v&&!A.nextSibling;)A=A.parentNode,E--;A=!A||A===v?null:A.nextSibling}let N=nn(Array.from(v.childNodes),{ignored:s,remoteWins:h});return C.set(v,N),N},f=(v,T,A,E,N,M)=>{for(let R of v.atoms){u(M,1);let V=T.atomAt.get(R.i+A);if(!V)return!1;let D=E?.reverse.get(R.el)||l(R.el),j=N?.reverse.get(V.el)||l(V.el);if(D!==j)return!1}return!0},g=(v,T,A,E,N)=>{let M=v.text.length<=T.text.length?v:T,R=M===v?T:v;if(u(N,M.text.length+R.text.length),!M.text||!Hn.test(M.text.replaceAll(Un,"")))return!1;let V;if(M.text===R.text)V=0;else{let D=R.text.length-M.text.length;if(u(N,(D+1)*M.text.length*2),R.text.startsWith(M.text))V=0;else if(R.text.endsWith(M.text))V=D;else return!1;if(R.text.indexOf(M.text)!==V||R.text.lastIndexOf(M.text)!==V)return!1;u(N,R.text.length*2);let j=0,y=V===0,k=!1;for(let J of an(R.text,xn(R.text)))j+=J.len,j===V&&(y=!0),j===V+M.text.length&&(k=!0);if(!y||!k)return!1}return M===v?f(M,R,V,A,E,N):f(M,R,V,E,A,N)},I=null;for(let v=0;v<2;v++){let{V:T,A,idOf:E}=o[v],N=o[1-v];if(!T.asBase)for(let M=0;M<e.length;M++){let R=e[M];if(T.twin(R)||!t(R))continue;let V=N.V.twin(R);if(!V||!w[1-v].has(V)||!t(V))continue;let D={remaining:r};try{let j=c[M],y=p[M],k=0;for(let Me=j+1;Me<y;Me++)u(D,1),!T.twin(e[Me])&&N.V.twin(e[Me])&&t(e[Me])&&k++;if(k!==1||m(R,D).text===m(V,D).text)continue;let J=j<0?-1:w[v].get(T.twin(e[j])),H=y===e.length?T.units.length:w[v].get(T.twin(e[y]));if(J===void 0||H===void 0||J>=H)continue;let q=null;for(let Me=J+1;Me<H;Me++){u(D,1);let Oe=T.units[Me];if(T.baseOf(Oe)||!t(Oe)||Oe.tagName!==R.tagName||Oe.namespaceURI!==R.namespaceURI)continue;let Re=n(R),ie=N.idOf(V),xe=E(Oe);if(!(Re&&ie&&Re!==ie||Re&&xe&&Re!==xe||ie&&xe&&ie!==xe)&&g(m(V,D),m(Oe,D),N.A,A,D)){if(q){q=null;break}q=Oe}}if(!q)continue;I||(I=[new Map,new Map]),I[v].set(R,q)}catch(j){if(j!==i)throw j}}}return I?o.map(({V:v},T)=>{let A=I[T];if(!A.size)return v;let E=new Map;for(let[N,M]of A)E.set(M,N);return{...v,twin:N=>A.get(N)||v.twin(N),baseOf:N=>E.get(N)||v.baseOf(N)}}):null}function jr({onUncertainSource:e,onUncertainOwner:o,base:t,views:n,eligible:s,ignored:h,remoteWins:l,baseId:r,atomKey:i,limit:u=2e4*32}){if(u<=0)return null;let w=new Set(t),c=new Map(t.map((j,y)=>[j,y])),p=new Map,b=[],S=null,C=null,m=null,f=new Set;for(let j of t)for(let{V:y}of n){let k=y.twin(j);k&&!y.asBase&&!y.here(k)&&f.add(j)}let g=new Set,I=Symbol(),v=(j,y)=>{if(y>j.remaining)throw I;j.remaining-=y},T=(j,y,k)=>{v(k,1);let J=p.get(j);if(J)return J;if(j.nodeType===1){let Me=j.firstChild,Oe=1;for(;Me;){if(v(k,Oe*8+8),Me.nodeType===3&&v(k,Me.data.length*8),Me.nodeType===1&&Tn.has(Me.tagName)&&!h(Me)&&!l(Me)&&Me.firstChild){Me=Me.firstChild,Oe++;continue}for(;Me&&Me!==j&&!Me.nextSibling;)Me=Me.parentNode,Oe--;Me=!Me||Me===j?null:Me.nextSibling}}else v(k,j.value.length*8+j.nodes.length);let H=j.nodeType===1?Array.from(j.childNodes):j.nodes,q=H.length===1&&H[0].nodeType===3?{text:H[0].data,nodes:[{node:H[0],s:0,e:H[0].data.length}],atoms:[]}:nn(H,{ignored:h,remoteWins:l});return J={unit:j,flat:q,alignment:y,tokens:null},p.set(j,J),J},A=(j,y)=>{if(j.tokens)return j.tokens;v(y,j.flat.text.length*8);let{unit:k,flat:J,alignment:H}=j,q=[],Me=xn(J.text),Oe=0,Re=ie=>{for(let xe of an(J.text.slice(Oe,ie),Me))xe.from=Oe,xe.to=Oe+xe.len,xe.unit=k,q.push(xe),Oe+=xe.len};for(let ie of J.atoms){Re(ie.i);let xe=l(ie.el)&&ie.el.nodeType===1?"w"+ie.el.tagName+"#"+(ie.el.id||""):i(H?.reverse.get(ie.el)||ie.el);q.push({k:xe,raw:Un,len:1,from:Oe,to:Oe+1,unit:k,atom:!0}),Oe++}return Re(J.text.length),j.tokens=q,q},E=(j,y,k,J,H)=>{if(!j.flat.atoms.length&&!y.flat.atoms.length)return!0;let q=A(j,H),Me=A(y,H);v(H,q.length+Me.length);let Oe=0;for(let Re of Me){if(!Re.atom||Re.from<k||Re.from>=k+J)continue;for(;Oe<q.length&&!q[Oe].atom;)Oe++;let ie=q[Oe++];if(!ie||ie.from!==Re.from-k||ie.k!==Re.k)return!1}for(;Oe<q.length;)if(q[Oe++].atom)return!1;return!0},N=(j,y,k)=>{let J=j.length+y.length+4;if(J*8>k.remaining)return null;k.remaining-=J*8;let H=Math.floor(k.remaining/8),q=Math.min(j.length+y.length,4e3,Math.floor((Math.sqrt(J*J+H)-J)/2)),Me=4*(q+1)*(J+q+1);if(q<1||Me>k.remaining)return null;k.remaining-=Me;let Oe=Wn(j,y,q),Re=[],ie=0,xe=0;for(let qe of Oe.hunks){for(;ie<qe.bs;)j[ie].raw===y[xe].raw&&Re.push([j[ie],y[xe]]),ie++,xe++;ie=qe.be,xe+=qe.toks.length}for(;ie<j.length&&xe<y.length;)j[ie].raw===y[xe].raw&&Re.push([j[ie],y[xe]]),ie++,xe++;return Re},M=(j,y,k,J,H,q,Me)=>{if(H<=J)return;let Oe=j[j.length-1];if(Oe&&Oe.source===y&&Oe.target===k&&Oe.to<=J&&Oe.targetFrom-Oe.from===q-J){v(Me,(J-Oe.to)*3);let Re=p.get(y).flat.text,ie=p.get(k).flat.text,xe=!0;for(let qe=Oe.to;qe<J;qe++)if(!gn.test(Re[qe])||Re[qe]!==ie[q+qe-J]){xe=!1;break}if(xe){Oe.to=H;return}}j.push({source:y,target:k,from:J,to:H,targetFrom:q})},R=j=>j.replace(pl,"");for(let j=0;j<n.length;j++){let{V:y,A:k,idOf:J}=n[j];if(y.asBase)continue;let H=new Map(y.units.map((x,Y)=>[x,Y])),q=x=>{let Y=y.twin(x);return Y&&H.has(Y)?Y:null},Me=(x,Y)=>{let ae=new Int32Array(x.length),oe=new Int32Array(x.length),Ee=-1;for(let De=0;De<x.length;De++)ae[De]=Ee,Y(x[De])&&(Ee=De);Ee=x.length;for(let De=x.length-1;De>=0;De--)oe[De]=Ee,Y(x[De])&&(Ee=De);return{prev:ae,next:oe}},Oe=Me(t,x=>(x.nodeType===1||x.kind==="text"&&Hn.test(x.value))&&q(x)),Re=Me(y.units,x=>(x.nodeType===1||x.kind==="text"&&Hn.test(x.value))&&w.has(y.baseOf(x))),ie=new Map,xe=(x,Y,ae,oe)=>{if(x>Y||ae>oe)return;let Ee=`${x}:${Y}:${ae}:${oe}`;ie.set(Ee,[x,Y,ae,oe])};for(let x=0;x<y.units.length;x++){let Y=y.units[x];if(y.baseOf(Y)||!s(Y))continue;let ae=Re.prev[x],oe=Re.next[x],Ee=ae<0?0:c.get(y.baseOf(y.units[ae])),De=oe===y.units.length?t.length-1:c.get(y.baseOf(y.units[oe]));xe(Ee,De,Math.max(0,ae),Math.min(y.units.length-1,oe))}for(let x=0;x<t.length;x++){let Y=t[x];if(f.has(Y)||!s(Y))continue;if(!y.twin(Y)){let nt=Oe.prev[x],Xe=Oe.next[x],ht=nt<0?0:H.get(q(t[nt])),Ge=Xe===t.length?y.units.length-1:H.get(q(t[Xe]));xe(Math.max(0,nt),Math.min(t.length-1,Xe),ht,Ge)}let ae=q(Y);if(!ae||k.identical.has(Y)||!s(ae))continue;let oe=x+1;for(;oe<t.length&&t[oe].kind==="text"&&!t[oe].value.trim();)oe++;if(oe>=t.length||!s(t[oe]))continue;let Ee=q(t[oe]);if(!Ee||k.identical.has(t[oe])||!s(Ee))continue;let De=H.get(ae),Ne=H.get(Ee);De<Ne&&xe(x,oe,De,Ne)}let qe=Array.from(ie.values()),fe=new Set;if(qe.length>1){let x=$t(u);try{v(x,qe.length*4);let Y=qe.slice().sort((Ee,De)=>(v(x,1),Ee[0]-De[0]||Ee[2]-De[2])),ae=[],oe=null;for(let Ee of Y)v(x,1),oe&&Ee[0]<=oe[1]&&Ee[2]<=oe[3]&&Ee[3]>=oe[2]?(oe[1]=Math.max(oe[1],Ee[1]),oe[2]=Math.min(oe[2],Ee[2]),oe[3]=Math.max(oe[3],Ee[3]),oe[4].push(Ee)):(oe?.[4].length>1&&ae.push(oe),oe=[Ee[0],Ee[1],Ee[2],Ee[3],[Ee]]);oe?.[4].length>1&&ae.push(oe),qe=ae.concat(qe)}catch(Y){if(Y!==I)throw Y}}for(let x of qe){if(fe.has(x))continue;let[Y,ae,oe,Ee,De]=x,Ne=$t(u),nt=[],Xe=new Set,ht=!1;try{v(Ne,(ae-Y+Ee-oe+2)*4);let Ge=t.slice(Y,ae+1).filter(U=>!k.identical.has(U)&&s(U)&&!f.has(U)),rt=y.units.slice(oe,Ee+1).filter(U=>s(U)&&(!y.baseOf(U)||w.has(y.baseOf(U)))&&!k.identical.has(y.baseOf(U))&&!f.has(y.baseOf(U))),Ot=new Set(rt),Ct=!1,wt="",Nt="",Lt=0;for(let U of Ge){let de=T(U,null,Ne);wt+=de.flat.text,Lt+=de.flat.text.length}for(let U of rt){let de=T(U,k,Ne);Nt+=de.flat.text,Lt+=de.flat.text.length}v(Ne,Lt);let qt=R(wt),cn=R(Nt),It=qt===cn;if(ht=It,De&&!It)continue;let Gt=It?null:new Map;if(Gt)for(let U of Ge.concat(rt)){let de=p.get(U).flat.text.length;v(Ne,de*16),Gt.set(U,new Uint8Array(de))}let wn=U=>{let de=[];for(let we of U){let le=p.get(we);le.flat.atoms.length?de.push(...A(le,Ne)):de.push({unit:we,raw:le.flat.text,from:0})}return de},Dt=[];for(let U of It?[]:Ge){let de=q(U);if(!Ot.has(de))continue;let we=T(U,null,Ne),le=T(de,k,Ne);v(Ne,we.flat.text.length+le.flat.text.length);let Ae=we.flat.text&&le.flat.text.startsWith(we.flat.text)?0:we.flat.text&&le.flat.text.endsWith(we.flat.text)?le.flat.text.length-we.flat.text.length:-1;if(Ae>=0&&E(we,le,Ae,we.flat.text.length,Ne)){Gt.get(U).fill(1),Gt.get(de).fill(1,Ae,Ae+we.flat.text.length),M(Dt,U,de,0,we.flat.text.length,Ae,Ne);continue}let W=N(A(we,Ne),A(le,Ne),Ne);if(!W){Ct=!0;break}for(let[X,pe]of W)Gt.get(U).fill(1,X.from,X.to),Gt.get(de).fill(1,pe.from,pe.to),M(Dt,U,de,X.from,X.to,pe.from,Ne)}if(Ct)continue;let rn=null,Yt=null;if(!It)for(let U of Ge){let de=q(U),we=p.get(U);if(!de||we.flat.atoms.length||!Ot.has(de))continue;let le=we.flat.text,Ae=Gt.get(U);v(Ne,le.length*3+rt.length);let W=-1,X=-1,pe=!1;for(let Pe=0;Pe<le.length;Pe++)gn.test(le[Pe])||(Ae[Pe]?pe=!0:(W<0&&(W=Pe),X=Pe+1));if(!pe||W<0)continue;let be=!0;for(let Pe=W;Pe<X;Pe++)if(Ae[Pe]&&!gn.test(le[Pe])){be=!1;break}if(!be)continue;let he=R(le.slice(W,X)),ee=null,te=!1;for(let Pe of rt){if(y.baseOf(Pe))continue;let ve=p.get(Pe);if(!ve.flat.atoms.length&&(v(Ne,ve.flat.text.length),R(ve.flat.text)===he)){if(ee){te=!0;break}ee=Pe}}if(te){(Yt||=new Set).add(U);continue}if(!ee||Yt?.has(U))continue;let z=!1;for(let Pe of Ge){if(Pe===U||!Ot.has(q(Pe)))continue;let ve=p.get(Pe);if(ve.flat.atoms.length)continue;let _e=Gt.get(Pe);v(Ne,ve.flat.text.length*3);let Je="",Ze=!1;for(let Ut=0;Ut<ve.flat.text.length;Ut++)gn.test(ve.flat.text[Ut])||(_e[Ut]?Ze=!0:Je+=ve.flat.text[Ut]);Ze&&Je===he&&(Yt||=new Set,Yt.add(U),Yt.add(Pe),z=!0)}if(z)continue;let ne=p.get(ee).flat.text;v(Ne,X-W+ne.length);let Te=W,Ce=0;for(;Te<X&&Ce<ne.length;){for(;Te<X&&gn.test(le[Te]);)Te++;for(;Ce<ne.length&&gn.test(ne[Ce]);)Ce++;if(Te>=X||Ce>=ne.length)break;M(rn||=[],U,ee,Te,Te+1,Ce,Ne),Te++,Ce++}Ae.fill(1,W,X),Gt.get(ee).fill(1)}let fn=U=>{let de=[];for(let we of U){let le=T(we,w.has(we)?null:k,Ne),Ae=Gt.get(we);for(let W of A(le,Ne)){let X=W.from;for(;X<W.to;){for(;X<W.to&&Ae[X];)X++;let pe=X;for(;X<W.to&&!Ae[X];)X++;if(X>pe){let be=le.flat.text.slice(pe,X);Hn.test(be)&&de.push({...W,raw:be,len:X-pe,k:W.atom?W.k:be,from:pe,to:X})}}}}return de},$=It?wn(Ge):fn(Ge),a=It?wn(rt):fn(rt),O=It?qt:$.map(U=>R(U.raw)).join(""),P=It?cn:a.map(U=>R(U.raw)).join("");if((!O||!P)&&!rn)continue;let K=rn||[];if(O&&P&&O===P){let U=0,de=0,we=0,le=0;for(;U<$.length&&de<a.length;){let Ae=$[U],W=a[de];for(;we<Ae.raw.length&&gn.test(Ae.raw[we]);)we++;for(;le<W.raw.length&&gn.test(W.raw[le]);)le++;if(we===Ae.raw.length){U++,we=0;continue}if(le===W.raw.length){de++,le=0;continue}if((Ae.atom||W.atom)&&Ae.k!==W.k){Ct=!0;break}M(K,Ae.unit,W.unit,Ae.from+we,Ae.from+we+1,W.from+le,Ne),we++,le++}}else if(O&&P){let U=N($,a,Ne);if(!U)continue;for(let[de,we]of U)M(K,de.unit,we.unit,de.from,de.to,we.from,Ne)}if(Ct)continue;let Z=new Map;for(let U of K)if(!Yt?.has(U.source)){if(q(U.source)===U.target){It&&Dt.push(U);continue}Z.has(U.source)||Z.set(U.source,[]),Z.get(U.source).push(U)}for(let[U,de]of Z){let we=T(U,null,Ne),le=q(U),Ae=we.flat.text,W=[],X=new Set,pe=n[1-j],be=pe.V.twin(U),he=be&&pe.V.here(be)?T(be,pe.A,Ne):null,ee=(ve,_e)=>{let Je=A(ve,Ne),Ze=A(_e,Ne);return v(Ne,ve.flat.text.length+_e.flat.text.length+Je.length+Ze.length),ve.flat.text===_e.flat.text&&Je.length===Ze.length&&Je.every((Ut,Pt)=>Ut.k===Ze[Pt].k)},te=le&&he&&he.flat.text!==Ae&&ee(T(le,k,Ne),he);for(let ve of new Set(de.map(_e=>_e.target))){if(U.nodeType!==1&&ve.nodeType!==1)continue;let _e=T(ve,k,Ne),Je=y.baseOf(ve);if(U.nodeType!==1&&Je||(v(Ne,Ae.length*2+_e.flat.text.length*3+Dt.length*2),le&&R(Ae)===R(_e.flat.text)&&T(le,k,Ne).flat.text.trim()))continue;if(!le&&!Je&&U.nodeType===1&&ve.nodeType===1){let G=r(U),re=J(ve);if(G&&re&&G!==re)continue}let Ze=_e.flat.text,Ut=Ae&&(Ze.startsWith(Ae)||Ze.endsWith(Ae)),Pt=!1;if(!le&&he&&Je&&he.flat.text!==Ae){let G=T(Je,null,Ne).flat.text,re=c.get(U)<c.get(Je)?he.flat.text:G,ge=c.get(U)<c.get(Je)?G:he.flat.text;v(Ne,re.length+ge.length+Ze.length),Pt=!!re&&!!ge&&re.length+ge.length<=Ze.length&&Ze.startsWith(re)&&Ze.endsWith(ge)&&!Ze.slice(re.length,Ze.length-ge.length).trim()}let L=!we.flat.atoms.length&&!he?.flat.atoms.length&&!_e.flat.atoms.length&&(te&&Ut||Pt);if(le&&Je){let G=T(le,k,Ne).flat.text,re=Ae.startsWith(G)||Ae.endsWith(G),ge=T(Je,null,Ne).flat.text,ye=_e.flat.text,ce=ye.startsWith(ge)||ye.endsWith(ge),se=!n[1-j].V.twin(Je)&&!Dt.some(Ie=>Ie.source===Je&&Hn.test(ge.slice(Ie.from,Ie.to)));if(!It&&(!re&&!L||!ce&&!se)){let Ie=bl(U,ve,de,Ge,rt,p,Gt,A,v,Ne);if(!Ie)continue;let Be=k.weak?.has(U)&&!k.identityPaired?.has(U)&&Ae.trim()===Ie;if(!re&&!L&&!Be)continue;let He=k.weak?.has(Je)&&!k.identityPaired?.has(Je)&&Ze.trim()===Ie&&!p.get(Je).flat.atoms.length&&!Dt.some(Ke=>Ke.source===Je&&Hn.test(ge.slice(Ke.from,Ke.to)));if(!ce&&!se&&!He&&!wl(Je,ve,ge,Ze,Dt,A(_e,Ne),v,Ne))continue;Be&&X.add(ve)}}L&&X.add(ve),v(Ne,de.length),W.push(...de.filter(G=>G.target===ve))}if(!W.length)continue;let z=new Uint8Array(Ae.length);v(Ne,Ae.length*4+Dt.length);for(let ve of W)z.fill(1,ve.from,ve.to);let ne=[];for(let ve=0;ve<Ae.length;ve++)gn.test(Ae[ve])||ne.push(ve);if(!ne.length)continue;let Te=new Set(W.map(ve=>ve.target));if(!It&&le&&Te.size>1&&ml(Te,K,Dt,y,p,Ne,v)){if(m||=new Map,m.set(U,(m.get(U)||0)|1<<j),e){let ve=ys({source:U,side:j,views:n,eligible:s,blocked:f,baseId:r,model:T,tokensOf:A,budget:Ne,charge:v});if(ve){v(Ne,ve.to-ve.from);let _e=!0;for(let Je=ve.from;Je<ve.to;Je++)if(Hn.test(Ae[Je])&&!z[Je]){_e=!1;break}_e&&(S||=[]).push(ve)}}continue}let Ce=ne.filter(ve=>Cs.test(Ae[ve]));if(!W.some(ve=>Cs.test(Ae.slice(ve.from,ve.to)))&&!ne.every(ve=>z[ve]))continue;if(!le&&!Array.from(Te).some(ve=>X.has(ve))&&!ne.every(ve=>z[ve])&&!(Ce.length&&z[Ce[0]]&&z[Ce[Ce.length-1]]&&Te.size===1)){let ve=null,_e=0,Je=0,Ze=null,Ut=null;if(!le&&he&&U.nodeType===1&&!we.flat.atoms.length){let Pt=A(we,Ne).filter(L=>Cs.test(L.raw));v(Ne,rt.length+Ae.length);for(let L of rt){let G=y.baseOf(L);if(!G||G===U||G.nodeType!==1||L.nodeType!==1||G.tagName!==U.tagName||L.tagName!==G.tagName)continue;let re=c.get(U),ge=c.get(G),ye=!0;for(let tt=Math.min(re,ge)+1;tt<Math.max(re,ge);tt++){let Kt=t[tt];if(v(Ne,Kt.nodeType===1?1:Kt.value.length+1),Kt.nodeType===1||Kt.value.trim()){ye=!1;break}}if(!ye)continue;let ce=T(G,null,Ne),se=T(L,k,Ne);if(ce.flat.atoms.length||se.flat.atoms.length)continue;let Ie=ce.flat.text,Be=se.flat.text;if(v(Ne,Ie.length+Be.length+Ae.length),!Ie||!Pt.length)continue;let He=0,Ke=Be.length;if(re<ge&&Be.endsWith(Ie))Ke-=Ie.length;else if(re>ge&&Be.startsWith(Ie))He=Ie.length;else continue;for(;He<Ke&&gn.test(Be[He]);)He++;for(;Ke>He&&gn.test(Be[Ke-1]);)Ke--;let pt=Be.slice(He,Ke);if(!(!pt||!(pt.startsWith(Pt[0].raw)||pt.endsWith(Pt[Pt.length-1].raw)))){if(ve){ve=null;break}ve=L,_e=He,Je=Ke,Ze=Pt[0],Ut=Pt[Pt.length-1]}}}if(v(Ne,W.length),!ve||!Te.has(ve)||!W.some(Pt=>Pt.target===ve&&(Pt.from<=Ze.from&&Pt.to>=Ze.to&&Pt.targetFrom+Ze.from-Pt.from===_e||Pt.from<=Ut.from&&Pt.to>=Ut.to&&Pt.targetFrom+Ut.to-Pt.from===Je)))continue}if(le&&!(ne.every(ve=>z[ve])&&(It||Array.from(Te).some(ve=>X.has(ve))))&&!Dt.some(ve=>ve.source===U&&Hn.test(Ae.slice(ve.from,ve.to))))continue;let Pe=!1;if(It){v(Ne,Dt.length+ne.length);for(let ve of Dt)ve.source===U&&(v(Ne,ve.to-ve.from),z.fill(1,ve.from,ve.to));Pe=!0;for(let ve of ne)if(!z[ve]){Pe=!1;break}}for(let ve of Te){v(Ne,W.length);let _e=W.filter(Ze=>Ze.target===ve);nt.push({side:j,source:U,target:ve,runs:_e,models:p,retained:Dt,conservedSource:Pe}),U.nodeType===1&&Xe.add(U),ve.nodeType===1&&Xe.add(ve);let Je=y.baseOf(ve);Je?.nodeType===1&&Xe.add(Je)}}if(b.push(...nt),De&&nt.length)for(let U of De)fe.add(U);for(let U of Xe)g.add(U)}catch(Ge){if(Ge!==I)throw Ge}finally{if(o&&!De&&!ht){let Ge=Pr({base:t,views:n,side:j,attempt:x,eligible:s,blocked:f,baseId:r,model:T,tokensOf:A,charge:v,exhausted:I,limit:u});Ge&&(C||=[]).push(...Ge)}if(e&&!De&&!ht){let Ge=Gs({base:t,views:n,side:j,attempt:x,eligible:s,blocked:f,baseId:r,model:T,tokensOf:A,certificates:b,charge:v,exhausted:I,limit:u});Ge&&(S||=[]).push(...Ge)}}}}let V=b.length?new Map:null;for(let j of b){let y=V.get(j.source);y||V.set(j.source,y=[]),y.push(j)}let D=null;if(V){let j=null;for(let[y,k]of V){let J=m?.get(y)||0;if(k.length<2&&!J)continue;let H=0;for(let q of k)q.conservedSource&&(H|=1<<q.side);for(let q of k){if(q.conservedSource)continue;let Me=1<<q.side,Oe=!0;if(H&Me)Oe=!1;else if(J&Me){Oe=!1;try{Oe=gl(q,j||=$t(u),v)}catch(Re){if(Re!==I)throw Re}}Oe||(D||=new Set).add(q)}}}if(D){let j=0;for(let y of b)D.has(y)||(b[j++]=y);b.length=j;for(let[y,k]of V){j=0;for(let J of k)D.has(J)||(k[j++]=J);k.length=j,j||V.delete(y)}g.clear();for(let y of b){let{source:k,target:J,side:H}=y;k.nodeType===1&&g.add(k),J.nodeType===1&&g.add(J);let q=n[H].V.baseOf(J);q?.nodeType===1&&g.add(q)}}if(S){let j=$t(u),y=!1;for(let k of S){let J=!1,H=V?.get(k.source);if(H&&!y)try{J=ws(k,H,j,v)}catch(q){if(q!==I)throw q;y=!0}J||e(k)}}if(C){let j=new Set,y=$t(u);try{for(let k of C){if(v(y,1),j.has(k.source))continue;j.add(k.source);let J=!1;for(let H of b)if(v(y,1),H.source===k.source||H.target===k.local||H.target===k.remote){J=!0;break}J||o(k)}}catch(k){if(k!==I)throw k}}for(let j of t)if(g.has(j))for(let{V:y}of n){let k=y.twin(j);k&&y.here(k)&&g.add(k)}return b.length?{blocks:g,certificates:b,certificatesBySource:V,models:p}:null}function Dr({certificates:e,scopes:o,flats:t,keys:n,limit:s=2e4*32}){let h=Symbol(),l=$t(s),r=m=>{if(m>l.remaining)throw h;l.remaining-=m},i=o.map(m=>new Set(m)),u=new Map,w=new Map,c=(m,f)=>{let g=u.get(m);if(g||u.set(m,g=new Map),g.has(f))return g.get(f);r(m.text.length);let I=w.get(f);if(!I){r(f.nodes.length+f.atoms.length),I={nodes:new Map,atoms:new Map};for(let E of f.nodes)I.nodes.set(E.node,E);for(let E of f.atoms)I.atoms.set(E.el,E.i);w.set(f,I)}let{nodes:v,atoms:T}=I,A=new Int32Array(m.text.length).fill(-1);for(let E of m.nodes){let N=v.get(E.node);if(!(!N||E.e-E.s!==N.e-N.s)){r(E.e-E.s);for(let M=E.s;M<E.e;M++)A[M]=N.s+M-E.s}}for(let E of m.atoms){let N=T.get(E.el);N!==void 0&&(A[E.i]=N)}return g.set(f,A),A},p=(m,f,g,I,v)=>{let T=m[m.length-1];T&&T.to===f&&T.target+T.to-T.from===I&&T.kind===v?T.to=g:m.push({from:f,to:g,target:I,kind:v})},b=(m,f,g,I)=>{r((I-g)*4);let v=[],T=g,A=M=>{let R=m.text.slice(T,M);for(let V of an(R,xn(R)))V.from=T,V.to=T+V.len,v.push(V),T+=V.len},E=0,N=m.atoms.length;for(;E<N;){r(1);let M=E+N>>>1;m.atoms[M].i<g?E=M+1:N=M}for(let M=E;M<m.atoms.length&&m.atoms[M].i<I;M++){r(1);let R=m.atoms[M];A(R.i),v.push({k:f(R),raw:Un,len:1,from:T,to:T+1}),T++}return A(I),v},S=(m,f,g,I,v,T)=>{if(g===I||v===T)return;if(I-g===T-v){r((I-g)*4);let y=!0;for(let k=g,J=v;k<I;k++,J++){if(t[0].text[k]!==t[f].text[J]){y=!1;break}let H=t[0].atomAt.get(k),q=t[f].atomAt.get(J);if(!!H!=!!q||H&&n[0](H)!==n[f](q)){y=!1;break}}if(y){p(m,g,I,v,"retained");return}}let A=b(t[0],n[0],g,I),E=b(t[f],n[f],v,T),N=A.length+E.length+4,M=Math.min(A.length+E.length,4e3,Math.floor((Math.sqrt(N*N+l.remaining/2)-N)/2));if(M<1)throw h;r(4*(M+1)*(N+M+1));let R=Wn(A,E,M),V=0,D=0,j=()=>{let y=A[V++],k=E[D++];r(y.len),y.raw===k.raw&&p(m,y.from,y.to,k.from,"retained")};for(let y of R.hunks){for(;V<y.bs;)j();V=y.be,D+=y.toks.length}for(;V<A.length&&D<E.length;)j()},C=m=>{let f=e.filter(R=>R.side===m-1&&i[0].has(R.source)&&i[m].has(R.target));if(!f.length)return null;let g=[],I=(R,V,D)=>{if(!i[0].has(R.source)||!i[m].has(R.target))return;let j=c(V.get(R.source).flat,t[0]),y=c(V.get(R.target).flat,t[m]);r(R.to-R.from);for(let k=0;k<R.to-R.from;k++){let J=j[R.from+k],H=y[R.targetFrom+k];if(J<0||H<0)throw h;p(g,J,J+1,H,D)}},v=new Set;for(let R of f){if(!v.has(R.retained)){v.add(R.retained);for(let V of R.retained)I(V,R.models,"retained")}for(let V of R.runs)I(V,R.models,"transfer")}g.sort((R,V)=>(r(1),R.from-V.from||R.target-V.target));let T=[];for(let R of g){r(1);let V=T[T.length-1];if(V&&R.from<V.to){if(R.target-R.from!==V.target-V.from)throw h;V.to=Math.max(V.to,R.to),R.kind==="transfer"&&(V.kind="transfer")}else T.push(R)}let A=[],E=0,N=0;for(let R of T){if(R.target<N)throw h;S(A,m,E,R.from,N,R.target),A.push(R),E=R.to,N=R.target+R.to-R.from}S(A,m,E,t[0].text.length,N,t[m].text.length);let M=Dn({base:t[0],side:t[m],retained:A.filter(R=>R.kind==="retained"),transfers:A.filter(R=>R.kind==="transfer"),baseAtomKey:n[0],sideAtomKey:n[m],budget:l});if(M.status!=="ready"||!M.monotone)throw h;return M};try{let m=C(1),f=C(2);return m||f?{local:m,remote:f}:{fallback:!0}}catch(m){if(m!==h)throw m;return{fallback:!0}}}function Ls(e,o,t=!1){let n=-1,s=-1;for(let l=0;l<e.list.length;l++){let r=e.list[l];r.bLo<o.lo||r.bLo>o.hi||(n<0&&(n=l),s=l)}let h=[];for(let l=n;l>=0&&l<=s;l++){let r=e.list[l],i=!t&&l===n?r.inlineStart<0?r.to:r.inlineStart:r.from,u=!t&&l===s?r.inlineEnd<0?r.from:r.inlineEnd:r.to;for(let w=i;w<u;w++)h.push(e.units[w]);l<s&&h.push(e.units[r.next])}return h}var it=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 yl(e,o,t){let n=null;for(let s of o.childNodes)if(!(!it(s)||!t(s)||!s.isEqualNode(e))){if(n)return null;n=s}if(!n)return null;for(let s of e.parentNode.childNodes)if(s!==e&&s.isEqualNode(e))return null;return n}var Co="[id],[data-id],script,head>*";function Rs(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"?yr(t,o):null}}function Qo(e,o,t,n){let s=n.ignored,h=n.stats||$n(),l=Ks({ignored:s,ignoreAttribute:n.ignoreAttribute,stats:h}),{unitsOf:r,meta:i}=l,u=n.baseURI,w=n.mergeTags!==null,c=Rs(n.mergeTags,u),p=L=>G=>{let re=c(G);return re!==null?re:L(G)},b=p(n.identity.base),S=p(n.identity.local),C=p(n.identity.remote),m=n.authored||n.identity,f=L=>L&&L.nodeType===9?L.documentElement:L,g=f(e),I=f(o),v=f(t),T=globalThis.__hyperMorphProfile,A=T?performance.now():0,E=L=>L===kn?Co:null,N=n.scope||null,M=N?N.baseDropped:new Set,R=new Set,V=N?N.remoteDropped:new Set,D=N?N.baseIndex:Uo(g,b,s,E(n.identity.base),M),j=n.localIsBase||g===I?null:Uo(I,S,s,E(n.identity.local),R),y=N?N.remoteIndex:Uo(v,C,s,E(n.identity.remote),V),k=L=>{let G=it(L)&&S(L);return G&&j?.get(G)===L&&!D.has(G)?G:null},J=L=>{let G=it(L)&&C(L);return G&&y.get(G)===L&&!D.has(G)?G:null},H=j?cs(g,I,{analyzer:l,baseIndex:D,sideIndex:j,baseId:m.base,sideId:m.local,baseKey:b,sideKey:S,baseDropped:M,sideDropped:R,stats:h}):Vr(),q=cs(g,v,{analyzer:l,baseIndex:D,sideIndex:y,baseId:m.base,sideId:m.remote,baseKey:b,sideKey:C,baseDropped:M,sideDropped:V,stats:h,scope:N,comparisons:n.comparisons});if(N){if(!N.held(q))return null;for(let L of N.dropped)ls(L)}let Me=null;function Oe(L){if(!Me){Me=new WeakMap;let G=[g];for(;G.length;){let re=G.pop();re.tagName==="TEMPLATE"&&re.content&&Me.set(re.content,re);for(let ge of l.childrenOf(re))ge.nodeType===1&&G.push(ge)}}return Me.get(L)||null}let Re=L=>{let G=it(L)||L.nodeType?L.parentNode:L.parent;return G&&G.nodeType===11?Oe(G):G};if(q.moved.size){let L=!1;for(let G of Array.from(q.moved))!it(G)||q.identityPaired.has(G)||!m.base(G)||a(q,Re(G))||(q.unpair(G),L=!0);L&&q.rematch()}fn(),$(H,q),$(q,H);for(let L of[H,q])if(L.refused)for(let G of L.refused)L.moved.has(G)||h.ambiguousMoves++;T&&(T.alignTotal=(T.alignTotal||0)+(performance.now()-A),A=performance.now());let ie=g.ownerDocument.implementation.createHTMLDocument(""),xe=new WeakMap,qe=new WeakMap,fe=[],x=[],Y=new Set,ae=[],oe=new Set,Ee=new Set,De=new Set,Ne=new WeakMap,nt=null,Xe=n.lineage?.locals.length?lr():null,ht=L=>{let G=Ko(L);return G&&Xe&&Xe.consume(L.local),G},Ge=n.conflicts||"remote",rt=L=>fe.push(L),Ot=L=>fe.push(L),Ct=Or({roots:{base:g,local:I,remote:v},L:H,R:q,unitsOf:r,provenance:xe,policy:Ge}),wt=(L,G)=>{x.push(L),G&&Ct.note(L,G)},Nt=null,Lt=null,qt=rn(),cn=null,It=U(g,H.map.get(g),q.map.get(g),!!n.localIsBase,!!n.childrenOnly);It.tagName==="HTML"?ie.replaceChild(It,ie.documentElement):ie.body.appendChild(It),Nt?.drain(It),Lt?.drain(It),T&&(T.build=(T.build||0)+(performance.now()-A));let Gt=n.childrenOnly?!Pe(Te(It),Te(v)):!te(It,v),wn=Ct.finish(It),Dt=Xe?ar({locals:n.lineage.locals,rec:Xe,root:It,provenance:xe,segments:ae,ignored:s}):null;return{doc:ie,root:It,provenance:xe,textMappers:qe,decisions:fe,conflicts:x,recoveryLinks:wn,localDiverged:Gt,mergedScripts:Y,segments:ae,remoteIdOf:n.identity.remote,customIdentity:n.identity.remote!==kn,L:H,R:q,stats:h,lineage:Dt};function rn(){let L=new Map,G=new Set;if(n.localIsBase||!H.insertedByHash)return{partner:L,drop:G};let re=H.insertedByHash(),ge=q.insertedByHash();if(!re.size||!ge.size)return{partner:L,drop:G};let ye={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ce=lt=>{let $e=0;for(let vt=lt.parentNode;vt;vt=vt.parentNode)$e++;return $e},se=[],Ie=lt=>{let $e=lt.textContent.trim();return $e.split(/\s+/).length>=3||$e.replace(/\s/g,"").length>=12},Be=lt=>{let $e=a(H,lt),vt=a(q,lt);return $e&&H.reverse.get($e.parentNode)!==lt.parentNode||vt&&q.reverse.get(vt.parentNode)!==lt.parentNode},He=(lt,$e,vt)=>{for(let jt of vt.parentNode.children){let bn=jt!==vt&<.reverse.get(jt);if(bn&&Be(bn))return!0}let ct=lt.reverse.get(vt.parentNode);if(ct){for(let jt of ct.children)if(!a($e,jt)&&!s(jt))return!0}return!1},Ke=new Map([[H,new Map],[q,new Map]]),pt=(lt,$e)=>{let vt=Ke.get(lt),ct=vt.get($e);if(ct===void 0){ct=!1;for(let jt of $e.children)if(lt.reverse.has(jt)||pt(lt,jt)){ct=!0;break}vt.set($e,ct)}return ct},tt=new Map;for(let lt of ge.values())for(let $e of lt){let vt=J($e);vt&&tt.set(vt,$e)}for(let lt of re.values())for(let $e of lt){let vt=k($e),ct=vt?tt.get(vt):null;ct&&ct.tagName===$e.tagName&&!Vn($e,ye)&&!Vn(ct,ye)&&!n.remoteWins($e)&&!n.remoteWins(ct)&&se.push([$e,[ct],ce($e),!0,!0])}for(let[lt,$e]of re){let vt=ge.get(lt);if(!vt)continue;let ct=$e.length===1&&vt.length===1;for(let jt of $e)!Vn(jt,ye)&&!k(jt)&&se.push([jt,vt,ce(jt),ct&&(Ie(jt)||He(H,q,jt)||He(q,H,vt[0]))])}if(!se.length)return{partner:L,drop:G};se.sort((lt,$e)=>lt[2]-$e[2]);let Kt=new Set,Ht=new Set,un=lt=>{for(let $e of lt.querySelectorAll("*"))Kt.add($e)},bt=(lt,$e)=>lt.reverse.get($e.parentNode)||null;for(let[lt,$e,,vt,ct]of se){if(Kt.has(lt)||Ht.has(lt)||ct&&(pt(H,lt)||pt(q,$e[0])))continue;let jt=bt(H,lt),bn=Xt=>!Ht.has(Xt)&&!Kt.has(Xt)&&(ct||Xt.tagName===lt.tagName&&!J(Xt)&&l.equalUnits(lt,Xt)),on=$e.find(Xt=>jt&&bt(q,Xt)===jt&&bn(Xt))||(vt?$e.find(bn):null);if(!on)continue;Ht.add(lt),Ht.add(on);let hn=jt&&bt(q,on)===jt;(!ct||!hn||l.equalUnits(lt,on))&&(un(lt),un(on)),!hn&&(L.set(lt,on),L.set(on,lt),G.add(Ge==="local"?on:lt))}return{partner:L,drop:G}}function Yt(L,G,re){if(oe.add(L),qt.drop.has(L))return null;oe.add(re);let ge=G==="local"?L:re,ye=G==="local"?re:L,ce;return l.equalUnits(ge,ye)?(ce=he(ge,"local",!0),xe.get(ce).remote=ye):ce=be(ge,ye),wt({kind:"structure",el:ce,detail:"both-moved",base:null,local:ge,remote:ye},{unit:{b:null,l:ge,r:ye}}),rt({kind:"insert",el:ce,source:"both"}),ce}function fn(){if(!H.weak||!q.weak||!H.weak.size||!q.weak.size||!H.unpair)return;let L=new Map;for(let re of H.weak){let ge=a(H,re);it(re)&&it(ge)&&L.set(l.unitHash(ge),re)}let G=!1;for(let re of Array.from(q.weak)){let ge=a(q,re);if(!it(re)||!it(ge))continue;let ye=L.get(l.unitHash(ge));if(!ye||ye===re||!H.weak.has(ye)||a(H,re)&&a(q,ye))continue;let ce=a(H,ye);ce.tagName===ge.tagName&&l.equalUnits(ce,ge)&&(H.unpair(ye),q.unpair(re),G=!0)}G&&(H.rematch(),q.rematch())}function $(L,G){if(!L.weak||!L.weak.size||!G.insertedByHash)return;let re=G.insertedByHash();if(!re.size)return;let ge=!1;for(let ye of Array.from(L.weak)){let ce=a(L,ye);if(!ce)continue;let se=L===H?k(ce):J(ce);if(se){let Be=(L===H?y:j)?.get(se);Be&&Be.tagName===ce.tagName&&!G.reverse.has(Be)&&(L.unpair(ye),ge=!0);continue}let Ie=re.get(l.unitHash(ce));Ie&&Ie.some(Be=>Be.tagName===ce.tagName&&l.equalUnits(Be,ce))&&(L.unpair(ye),ge=!0)}ge&&L.rematch()}function a(L,G){if(!G)return null;if(L.map.has(G))return L.map.get(G);let re=[],ge=Re(G);for(;ge&&!L.map.has(ge);ge=Re(ge))re.push(ge);let ye=ge;if(!ye||!L.identical.has(ye))return null;L.pairIdenticalChildren(ye);for(let se=re.length-1;se>=0;se--)L.pairIdenticalChildren(re[se]);let ce=L.map.get(G)||null;return ce&&h.lazyTwins++,ce}function O(L,G,re,ge){if(it(L)&&Ln.has(L.tagName)&&!H.identical.has(L)&&(L.previousSibling?.nodeType===3||L.nextSibling?.nodeType===3)){let Ie=Re(L),Be=a(H,L),He=a(q,L);Be&&He&&Ut(Be,a(H,Ie),H)&&!Ut(He,a(q,Ie),q)&&(Lt||=Lr({L:H,R:q,twinIn:a,unitsOf:r,view:P,parentOf:Re,ignored:s,remoteWins:n.remoteWins,eligible:Ke=>it(Ke)&&Ln.has(Ke.tagName),build:U,out:ie,policy:Ge,provenance:xe,textMappers:qe,segments:ae,conflicts:x,conflict:wt,decisions:fe}),Lt.ensureOwner(L))}if(G===null)return null;if(ge!==void 0)return Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(L,G,re,!!ge),ge&&(Nt.produced(L,ge),Ee.add(L)),ge;if(Ee.has(L)||De.has(L))return wt({kind:"structure",el:null,detail:"both-moved",base:L},{subject:L}),Ee.has(L)?null:he(re,G);Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(L,G,re,!0);let ye=a(H,L),ce=a(q,L);(!ye||!ce)&&wt({kind:"structure",el:null,detail:"move-beats-delete",base:L},{subject:L,deleted:ye?"remote":"local"});let se=U(L,ye,ce,!1);return(G==="local"?rt:Ot)({kind:"move",el:se,source:G}),se}function P(L,G,re,ge){return ge||!G||G===re?{el:re,asBase:!0,twin:ye=>ye,baseOf:ye=>ye,units:r(re),here:()=>!0,parentOfTwin:()=>re}:{el:G,asBase:!1,twin:ye=>a(L,ye),baseOf:ye=>L.reverse.get(ye),units:r(G),here:ye=>it(ye)?ye.parentNode===G||G.tagName==="TEMPLATE"&&ye.parentNode===G.content:ye.parent===G||G.tagName==="TEMPLATE"&&ye.parent===G.content}}function K(L,G,re){return!G||re&&re.identical.has(L)?!1:it(L)?!l.equalUnits(L,G)||!Z(L,G,re):L.value!==G.value}function Z(L,G,re){if(!re||L===G)return!0;let ge=[[L,G]];for(;ge.length;){let[ye,ce]=ge.pop(),se=r(ye),Ie=r(ce);for(let Be=0;Be<se.length&&Be<Ie.length;Be++){let He=se[Be],Ke=Ie[Be];if(!it(He)||!it(Ke))continue;let pt=re.map.get(He);if(pt!==void 0&&pt!==Ke)return!1;let tt=re.reverse.get(Ke);if(tt!==void 0&&tt!==He)return!1;ge.push([He,Ke])}}return!0}function U(L,G,re,ge,ye=!1){let ce=ge||(re?n.remoteWins(re):n.remoteWins(L)),se=L.namespaceURI&&L.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(L.namespaceURI,L.tagName):ie.createElement(L.tagName),Ie={base:L,local:G||null,remote:re||null};if(xe.set(se,Ie),ce&&!ge&&G&&K(L,G,H)&&(!re||!l.equalUnits(G,re))&&wt({kind:"structure",el:se,detail:"remote-wins",base:L,local:G,remote:re||null},{subject:L}),oe.add(L),Ee.add(L),G&&oe.add(G),re&&oe.add(re),n.skipUnchanged&&!ye&&(n.localIsBase||H.identical.has(L))&&re&&q.identical.has(L)&&!n.remoteWins(L)){Ie.unchanged=!0;for(let He of L.attributes)He.namespaceURI?se.setAttributeNS(He.namespaceURI,He.name,He.value):se.setAttribute(He.name,He.value);return Nt?.produced(L,se),se}De.add(L),ye||le(L,ce?L:G,re,se);let Be=L.tagName;if(pn(L))we(L,ce?L:G,re,se);else if(Be==="TEXTAREA")se.textContent=de(L.textContent,(ce?L:G)?(ce?L:G).textContent:L.textContent,re?re.textContent:L.textContent,se,"text");else if(!Lt?.render(L,se)){let He=ee(L,G,re,ce,se),Ke=Be==="TEMPLATE"&&se.content?se.content:se;for(let pt of He)Ke.appendChild(pt)}return De.delete(L),Nt?.produced(L,se),se}function de(L,G,re,ge,ye){if(G===re)return G;if(G===L)return re!==L&&Ot({kind:ye,node:ge,source:"remote"}),re;if(re===L)return rt({kind:ye,node:ge,source:"local"}),G;let ce=Ge==="local"?G:re;return wt({kind:ye,node:ge,base:L,local:G,remote:re,resolved:ce},{site:"whole",el:ge}),fe.push({kind:ye,node:ge,source:"both"}),ce}function we(L,G,re,ge){let ye=L.textContent,ce=G?G.textContent:ye,se=re?re.textContent:ye,Ie=w?ho(L,n.mergeTags,!0):null;if(Ie&&ce!==se){let Be=re&&re.getAttribute("merge-key")||L.getAttribute("merge-key"),{text:He,warnings:Ke,conflicts:pt}=Yo(n.localIsBase?void 0:ye,ce,se,{parse:Ie.recognizer.parse,keyCandidates:Be?Be.split(/[\s,]+/).filter(Boolean):void 0});for(let tt of Ke)console.warn(`[hyper-morph] merge "${Ie.raw}": ${tt}`);for(let tt of n.localIsBase?[]:pt)wt({kind:"json",node:ge,name:Ie.raw,path:tt.path,base:tt.base,local:tt.local,remote:tt.remote,resolved:tt.resolved});ge.textContent=He,Y.add(ge),He!==se?rt({kind:"text",node:ge,source:He===ce?"local":"both"}):He!==ye&&Ot({kind:"text",node:ge,source:"remote"});return}ge.textContent=de(ye,ce,se,ge,"text")}function le(L,G,re,ge){let ye=new Map;for(let ce of[L,G,re])if(ce)for(let se of ce.attributes)n.ignoreAttribute(ce,se.name)||ye.set(se.name,se);for(let[ce,se]of ye){let Ie=L?L.getAttribute(ce):null,Be=G?G.getAttribute(ce):Ie,He=re?re.getAttribute(ce):Ie,Ke;Be===He?Ke=Be:Be===Ie?(Ke=He,Ot({kind:"attr",el:ge,name:ce,source:"remote"})):He===Ie?(Ke=Be,rt({kind:"attr",el:ge,name:ce,source:"local"})):(Ke=Ae(ce,Ie,Be,He),Ke===void 0&&(Ke=Ge==="local"?Be:He,wt({kind:"attr",el:ge,name:ce,base:Ie,local:Be,remote:He,resolved:Ke},{el:ge,sample:se})),fe.push({kind:"attr",el:ge,name:ce,source:"both"})),Ke!=null&&(se.namespaceURI?ge.setAttributeNS(se.namespaceURI,se.name,Ke):ge.setAttribute(ce,Ke))}}function Ae(L,G,re,ge){if(L==="class"){let ye=He=>new Set((He||"").split(/\s+/).filter(Boolean)),ce=ye(G),se=ye(re),Ie=ye(ge),Be=new Set;for(let He of new Set([...ce,...se,...Ie])){let Ke=ce.has(He),pt=se.has(He),tt=Ie.has(He);(pt===tt?pt:pt===Ke?tt:pt)&&Be.add(He)}return[...Be].join(" ")}if(L==="style"){let ye=Ke=>{let pt=new Map;if(!Ke)return pt;let tt=0,Kt=null,Ht="",un=()=>{let bt=Ht.indexOf(":");bt>0&&pt.set(Ht.slice(0,bt).trim(),Ht.slice(bt+1).trim()),Ht=""};for(let bt of Ke){if(Kt){Ht+=bt,bt===Kt&&(Kt=null);continue}if(bt==='"'||bt==="'"){Kt=bt,Ht+=bt;continue}if(bt==="("?tt++:bt===")"&&tt--,bt===";"&&tt===0){un();continue}Ht+=bt}return Ht.trim()&&un(),pt},ce=ye(G),se=ye(re),Ie=ye(ge),Be=new Map,He=!1;for(let Ke of new Set([...ce.keys(),...se.keys(),...Ie.keys()])){let pt=ce.get(Ke)??null,tt=se.get(Ke)??null,Kt=Ie.get(Ke)??null,Ht;tt===Kt?Ht=tt:tt===pt?Ht=Kt:Kt===pt?Ht=tt:(Ht=Ge==="local"?tt:Kt,He=!0),Ht!=null&&Be.set(Ke,Ht)}return He?void 0:[...Be].map(([Ke,pt])=>`${Ke}: ${pt}`).join("; ")}}function W(L,G,re,ge){let ye=L.value,ce=ge?ye:G?G.value:"",se=re?re.value:"";oe.add(L),G&&oe.add(G),re&&oe.add(re);let Ie=lo(ye,ce,se,Ge),Be=Ie.text===""?null:ie.createTextNode(Ie.text);Be&&(xe.set(Be,{base:L.nodes,local:G?G.nodes:null,remote:re?re.nodes:null}),qe.set(Be,Ie.mapLocalOffset)),ce!==ye&&se!==ye?fe.push({kind:"text",node:Be,source:"both"}):ce!==ye?rt({kind:"text",node:Be,source:"local"}):se!==ye&&Ot({kind:"text",node:Be,source:"remote"});for(let He of Ie.conflicts)wt({kind:"text",node:Be,base:ye.slice(He.bs,He.be),local:He.local,remote:He.remote,resolved:He.resolved},{site:"run",bRun:L,lRun:G,rRun:re,node:Be,c:He});return Be}function X(L,G){return Yn(L,G).every(re=>re.bs===re.be)}function pe(L,G){let re=L?L.value:"",ge=G?G.value:"",ye;if(re===ge||!ge?ye=re:re?X(re,ge)?ye=ge:X(ge,re)?ye=re:(ye=Ge==="local"?re:Ge==="both"?re+ge:ge,wt({kind:"structure",el:null,detail:"insert-collision",local:re,remote:ge,resolved:ye},{unit:{b:null,l:L,r:G},localLost:Ge==="remote"})):ye=ge,L&&oe.add(L),G&&oe.add(G),ye==="")return null;let ce=ie.createTextNode(ye);return xe.set(ce,{base:null,local:L?L.nodes:null,remote:G?G.nodes:null}),re?rt({kind:"insert",el:ce,source:ge&&re===ge?"both":"local"}):Ot({kind:"insert",el:ce,source:"remote"}),ce}function be(L,G){let re={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ge=Ie=>r(Ie).every(Be=>it(Be)?Vn(Be,re):Be.kind==="text"),ye=null;if(ge(L)&&ge(G)){let Ie=L.textContent,Be=G.textContent;Ie===Be||X(Be,Ie)?ye=G:X(Ie,Be)&&(ye=L)}if(!ye){let Ie=Ge==="local",Be=he(Ie?L:G,Ie?"local":"remote",!0),He=xe.get(Be);return Ie?He.remote=G:He.local=L,wt({kind:"structure",el:Be,detail:"insert-collision",local:L,remote:G,resolved:Ie?L:G},{unit:{b:null,l:L,r:G},localLost:!Ie}),Be}let ce=L.namespaceURI&&L.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(L.namespaceURI,L.tagName):ie.createElement(L.tagName);le(null,L,G,ce),xe.set(ce,{base:null,local:L,remote:G}),oe.add(L),oe.add(G);let se=ht({base:Array.from(ye.childNodes),local:Array.from(L.childNodes),remote:Array.from(G.childNodes),out:ie,policy:Ge,idOf:{local:S,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,provenance:xe,textMappers:qe,conflicts:x,conflict:wt,scope:{base:null,local:L,remote:G,units:[],at:0},synthetic:!0,decisions:fe,node:ce});ae.push(...se.segments);for(let Ie of se.nodes)ce.appendChild(Ie);return ce}function he(L,G,re=!1){if(!re&&it(L)){let se=qt.partner.get(L);if(se)return Yt(L,G,se)}if(!it(L)){if(L.value==="")return null;let se=L.kind==="comment"?ie.createComment(L.value):ie.createTextNode(L.value);return xe.set(se,{base:null,local:G==="local"?L.nodes:null,remote:G==="remote"?L.nodes:null}),oe.add(L),se}let ge=L.namespaceURI&&L.namespaceURI!=="http://www.w3.org/1999/xhtml"?ie.createElementNS(L.namespaceURI,L.tagName):ie.createElement(L.tagName);for(let se of L.attributes)se.namespaceURI?ge.setAttributeNS(se.namespaceURI,se.name,se.value):ge.setAttribute(se.name,se.value);xe.set(ge,{base:null,local:G==="local"?L:null,remote:G==="remote"?L:null}),oe.add(L);let ye=L.tagName==="TEMPLATE"&&ge.content?ge.content:ge,ce=G==="local"?H:q;for(let se of r(L)){let Ie=it(se)?ce.reverse.get(se):null;if(Ie&&O(Ie,null,null),Ie&&Ee.has(Ie)){wt({kind:"structure",el:null,detail:"both-moved",base:Ie},{subject:Ie});continue}if(Ie&&!De.has(Ie)){let He=a(H,Ie)||null,Ke=a(q,Ie)||null;if(He||Ke){Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(Ie,G,se,!0);let pt=U(Ie,He,Ke,!1);G==="local"?rt({kind:"move",el:pt,source:"local"}):Ot({kind:"move",el:pt,source:"remote"}),ye.appendChild(pt);continue}}let Be=he(se,G);Be&&ye.appendChild(Be)}if(!re&&qt.drop.size&&L.tagName==="DIV"&&!ye.firstChild&&!L.attributes.length&&!(G==="local"?S(L):C(L))&&!ce.reverse.has(L)&&!s(L)&&!n.remoteWins(L)){let se=L.firstChild;if(se&&se===L.lastChild&&it(se)&&(qt.drop.has(se)||cn?.has(se)))return(cn||=new WeakSet).add(L),null}return ge}function ee(L,G,re,ge,ye){G&&H.identical.has(L)&&H.pairIdenticalChildren(L),re&&q.identical.has(L)&&q.pairIdenticalChildren(L);let ce=P(H,G,L,ge),se=P(q,re,L,!1),Ie=r(L),Be=new Set(Ie),He=new Map;for(let ue=0;ue<Ie.length;ue++)He.set(Ie[ue],ue);let Ke=[],pt=new Set,tt=new Map,Kt=new Set,Ht=Xe&&[],un=Xe&&[],bt=new Set,lt=[],$e=null,vt=new Map;if(!ce.asBase&&!se.asBase&&!H.identical.has(L)&&!q.identical.has(L))for(let ue of Ie){if(!it(ue)||!Ln.has(ue.tagName))continue;let We=ce.twin(ue),Ve=se.twin(ue);We&&Ve&&(!ce.here(We)||!se.here(Ve))&&O(ue,null,null)}vo();let ct=ue=>{let We=[];for(let Ve of ue.units){if(bt.has(Ve))continue;let et=ue.baseOf(Ve);et&&Be.has(et)&&We.push(et)}return We},jt=ue=>ct(ue).map(We=>He.get(We)),bn=ue=>ue.every((We,Ve)=>Ve===0||We>=ue[Ve-1]),on=!ce.asBase&&!bn(jt(ce)),hn=!se.asBase&&!bn(jt(se));on&&hn&&wt({kind:"structure",el:ye,detail:"both-reordered",base:L},{subject:L,lKept:ct(ce),rKept:ct(se)});let Xt=hn||!on?{V:se,A:q,side:"remote",other:ce,otherA:H,otherSide:"local"}:{V:ce,A:H,side:"local",other:se,otherA:q,otherSide:"remote"};on?rt({kind:"move",el:null,source:hn?"both":"local",base:L}):hn&&Ot({kind:"move",el:null,source:"remote",base:L});let En=ce.asBase?[]:ce.units.filter(ue=>!ce.baseOf(ue)&&!bt.has(ue)&&!qt.partner.has(ue)),oo=se.asBase?[]:se.units.filter(ue=>!se.baseOf(ue)&&!bt.has(ue)&&!qt.partner.has(ue)),Rn=new Map;if(En.length&&oo.length){let ue=new Map,We=new Map;for(let Fe of oo){if(it(Fe)){let xt=C(Fe);xt&&ue.set(xt,Fe)}let ze=l.unitHash(Fe);We.has(ze)||We.set(ze,[]),We.get(ze).push(Fe)}let Ve=(Fe,ze)=>{let xt=Fe.units.indexOf(ze);for(let Ye=xt-1;Ye>=0;Ye--){let st=Fe.baseOf(Fe.units[Ye]);if(st)return st}return"start"},et=new Map,yt=new Map;for(let Fe of oo){let ze=Ve(se,Fe);it(Fe)?(yt.has(ze)||yt.set(ze,[]),yt.get(ze).push(Fe)):Fe.kind==="text"&&!et.has(ze)&&et.set(ze,Fe)}for(let Fe of En){let ze=null;if(it(Fe)){let Ye=S(Fe);Ye&&ue.has(Ye)&&!Rn.has(ue.get(Ye))&&(ze=ue.get(Ye))}else if(Fe.kind==="text"){let Ye=et.get(Ve(ce,Fe));Ye&&!Rn.has(Ye)&&(ze=Ye)}let xt=!!k(Fe);if(!ze&&!xt){let Ye=We.get(l.unitHash(Fe));Ye&&(ze=Ye.find(st=>!Rn.has(st)&&it(st)===it(Fe)&&(it(st)?st.tagName===Fe.tagName&&!J(st):st.kind===Fe.kind)&&l.equalUnits(Fe,st))||null)}if(!ze&&it(Fe)&&!xt){let Ye=m.local(Fe),st=(yt.get(Ve(ce,Fe))||[]).filter(ft=>{let Wt=m.remote(ft);return!Rn.has(ft)&&ft.tagName===Fe.tagName&&!J(ft)&&!(Ye&&Wt&&Ye!==Wt)&&l.similar(Fe,ft)});st.length===1&&(ze=st[0])}ze&&(Rn.set(ze,Fe),Rn.set(Fe,ze))}}let xo=ue=>{if(Lt?.consumes(ue))return null;if(oe.has(ue)||Nt?.has(ue))return tt.get(ue)||null;let We=ce.twin(ue),Ve=se.twin(ue),et=We&&!ce.asBase&&!ce.here(We),yt=Ve&&!se.asBase&&!se.here(Ve);if(et||yt){if((!We||!Ve)&&wt({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:We?"remote":"local"}),!Ze(ue))return it(ue)?(Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),et&&Nt.plan(ue,"local",We),yt&&Nt.plan(ue,"remote",Ve)):oe.add(ue),null;wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue})}if(We&&!Ve&&!ce.asBase&&!se.asBase&&it(ue)&&Ln.has(ue.tagName)&&!n.remoteWins(ue)&&!n.remoteWins(We)&&K(ue,We,H)&&yl(ue,Te(se.el),s)){let st={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},ft=Wt=>it(Wt)?Vn(Wt,st):Wt.kind==="text";if(r(ue).every(ft)&&r(We).every(ft)){let Wt=ht({base:[ue],local:[We],remote:[],blocks:new Set([ue,We]),out:ie,policy:Ge,L:H,R:q,idOf:{base:b,local:S,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Qt,vn,_n)=>U(Qt,vn,_n,!1),cloneUnit:he,mergeAttrs:le,atomKey:l.exactUnitKey,moveIn:O,moveBuilt:O,movePlanned:O,provenance:xe,textMappers:qe,conflicts:x,conflict:wt,scope:{base:L,local:ce.el,remote:se.el,units:Ie,at:He.get(ue)},decisions:fe,node:ye});ae.push(...Wt.segments),oe.add(ue),oe.add(We);let Mt=ie.createDocumentFragment();for(let Qt of Wt.nodes)Mt.appendChild(Qt);return tt.set(ue,Mt),tt.set(We,Mt),Mt}}if(!We&&!Ve)return oe.add(ue),Ot({kind:"remove",source:"both",base:ue}),null;if(!We&&!K(ue,Ve,q))return oe.add(ue),rt({kind:"remove",source:"local",base:ue}),null;if(!Ve&&!K(ue,We,H))return oe.add(ue),Ot({kind:"remove",source:"remote",base:ue}),Xe&&(Xe.remove(We),Ht.push({bk:ue,lk:We})),null;let Fe=!We||!Ve,ze=ce.asBase?a(H,ue)||null:We,xt=se.asBase&&it(ue)&&(q.identityPaired.has(ue)||!m.base(ue))&&a(q,ue)||Ve,Ye;return it(ue)?Ye=U(ue,ze,xt,ce.asBase):ue.kind==="comment"?Ye=_e(ue,ze,Ve,ce.asBase):Ye=W(ue,ze,Ve,ce.asBase),oe.add(ue),Ye&&(tt.set(ue,Ye),We&&tt.set(We,Ye),Ve&&tt.set(Ve,Ye),Fe&&(wt({kind:"structure",el:Ye,detail:"edit-beats-delete",base:ue},{subject:ue,deleted:We?"remote":"local"}),We?rt({kind:"insert",el:Ye,source:"local"}):Ot({kind:"insert",el:Ye,source:"remote"}))),Ye},Kn=(ue,We,Ve,et)=>{if(Lt?.consumes(ue))return null;if(oe.has(ue))return tt.get(ue)||null;let yt=We.baseOf(ue);if(yt&&Be.has(yt))return bt.has(yt)&&!bt.has(ue)?Ro(yt,ue,et):xo(yt);if(yt)return ts(yt,ue,et);let Fe=Rn.get(ue);if(Fe){let xt=et==="local"?ue:Fe,Ye=et==="local"?Fe:ue,st;return it(xt)?l.equalUnits(xt,Ye)?(st=he(xt,"local"),st&&(xe.get(st).remote=Ye)):st=be(xt,Ye):st=pe(xt,Ye),oe.add(xt),oe.add(Ye),st&&(tt.set(xt,st),tt.set(Ye,st),it(xt)&&rt({kind:"insert",el:st,source:"both"})),st}let ze=he(ue,et);return ze&&(tt.set(ue,ze),et==="local"?rt({kind:"insert",el:ze,source:"local"}):(Ot({kind:"insert",el:ze,source:"remote"}),Xe&&it(ue)&&!qt.partner.has(ue)&&un.push({su:ue,node:ze}))),ze},Ro=(ue,We,Ve)=>{let et;return it(ue)?(et=O(ue,Ve,We),et&&oe.add(We)):(et=he(We,Ve),oe.add(We),et&&(Ve==="local"?rt:Ot)({kind:"insert",el:et,source:Ve})),et&&tt.set(We,et),et},ts=(ue,We,Ve)=>{O(ue,null,null);let yt=a(Ve==="local"?q:H,ue),Fe=We,ze=yt?Ut(yt,Ve==="local"?re:G,Ve==="local"?q:H):!1,xt=yt&&!ze&&!Pt(ue,yt);if(xt&&Ve===Xt.otherSide)return wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),null;if(xt&&wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue}),yt||wt({kind:"structure",el:null,detail:"move-beats-delete",base:ue},{subject:ue,deleted:Ve==="local"?"remote":"local"}),De.has(ue)){wt({kind:"structure",el:null,detail:"both-moved",base:ue},{subject:ue});let st=he(Fe,Ve);return st&&tt.set(We,st),st}it(ue)&&(Nt||=go(xe,Re,H,q,a,U,s,n.remoteWins,x,wt,K,I,v),Nt.plan(ue,Ve,Fe,!0));let Ye=it(ue)?U(ue,Ve==="local"?Fe:a(H,ue)||null,Ve==="remote"?Fe:a(q,ue)||null,!1):null;return Ye&&(tt.set(ue,Ye),tt.set(We,Ye),yt&&tt.set(yt,Ye),Ve==="local"?rt({kind:"move",el:Ye,source:"local"}):Ot({kind:"move",el:Ye,source:"remote"})),Ye};for(let ue of Xt.V.units){if(bt.has(ue)){if($e?.has(ue)){for(let et of $e.get(ue))pt.has(et)||(Ke.push(et),pt.add(et));continue}let Ve=tt.get(ue);pt.has(Ve)||(Ke.push(Ve),pt.add(Ve));continue}if(oe.has(ue)&&!(tt.get(ue)&&pt.has(tt.get(ue)))){let Ve=Xt.V.baseOf(ue);Ve&&!Be.has(Ve)&&wt({kind:"structure",el:null,detail:"both-moved",base:Ve},{subject:Ve});continue}let We=Kn(ue,Xt.V,Xt.A,Xt.side);We&&!pt.has(We)&&(Ke.push(We),pt.add(We),!Xt.V.baseOf(ue)&&!Rn.has(ue)&&!bt.has(ue)&&Kt.add(We))}for(let ue of lt)pt.has(ue.frag)||(Ke.splice(ue.previous&&pt.has(ue.previous)?Ke.indexOf(ue.previous)+1:so(ue.at),0,ue.frag),pt.add(ue.frag));if(!Xt.other.asBase){let ue=Xt.other,We=Xt.otherSide,Ve=Xt.otherA,et=null,yt=0,Fe=null;for(let ze of ue.units){let xt=vt.get(ze)||tt.get(ze);if(xt&&pt.has(xt)){et=xt,Fe=null;continue}if(oe.has(ze)){let ft=ue.baseOf(ze);ft&&!Be.has(ft)&&wt({kind:"structure",el:null,detail:"both-moved",base:ft},{subject:ft});continue}let Ye=Kn(ze,ue,Ve,We);if(!Ye)continue;let st;if(Fe)st=Ke.indexOf(Fe)+1;else if(et){if(st=Ke.indexOf(et)+1,We==="remote")for(;st<Ke.length&&Kt.has(Ke[st]);)st++}else st=yt++;Ke.splice(st,0,Ye),pt.add(Ye),Fe=Ye}}for(let ue=0;ue<Ie.length;ue++){let We=Ie[ue];if(oe.has(We))continue;let Ve=xo(We);Ve&&Ke.splice(so(ue),0,Ve)}return Xe&&Ht.length&&un.length&&Po(),Ke;function Po(){if(on||hn)return;let ue=new Set(Ke),We=ft=>ft&&Be.has(ft)&&ue.has(tt.get(ft))?ft:null,Ve=(ft,Wt)=>{let Mt=[{prev:null,units:[]}];for(let Qt of ft){let vn=We(Wt(Qt));vn?Mt.push({prev:vn,units:[]}):Mt[Mt.length-1].units.push(Qt)}return Mt},et=Ve(Ie,ft=>ft),yt=Ve(se.units,se.baseOf),Fe=ce.asBase?null:Ve(ce.units,ce.baseOf),ze=ft=>ft.length===et.length&&ft.every((Wt,Mt)=>Wt.prev===et[Mt].prev);if(!ze(yt)||Fe&&!ze(Fe))return;let xt=new Map(Ht.map(ft=>[ft.bk,ft])),Ye=new Map(un.map(ft=>[ft.su,ft])),st=ft=>ft?Ke.indexOf(tt.get(ft)):-1;for(let ft=0;ft<et.length;ft++){if(et[ft].units.length!==1||yt[ft].units.length!==1)continue;let Wt=xt.get(et[ft].units[0]),Mt=Ye.get(yt[ft].units[0]);if(!Wt||!Mt||Fe&&(Fe[ft].units.length!==1||Fe[ft].units[0]!==Wt.lk))continue;let Qt=st(et[ft].prev);(ft+1<et.length?st(et[ft+1].prev):Ke.length)-Qt!==2||Ke[Qt+1]!==Mt.node||To(Wt.bk,Wt.lk,Mt.su)&&Xe.link(Wt.lk,Mt.node)}}function Fn(ue,We,Ve,et){let yt=Mt=>{let Qt=Mt.filter(it);return Qt.length===1?Qt[0]:null},Fe=yt(ue),ze=yt(We),xt=yt(Ve);if(!Fe||!ze||!xt)return;let Ye=ue.indexOf(Fe);if(We.indexOf(ze)!==Ye||Ve.indexOf(xt)!==Ye||ue.length!==We.length||ue.length!==Ve.length)return;for(let Mt=0;Mt<ue.length;Mt++)if(Mt!==Ye&&(ue[Mt].value!==We[Mt].value||ue[Mt].value!==Ve[Mt].value))return;if((ce.asBase?Fe:ce.twin(Fe))!==ze||se.twin(Fe)||q.reverse.get(xt)||ze!==Fe&&K(Fe,ze,H))return;let st=et.filter(Mt=>Mt.nodeType===1);if(st.length!==1||xe.get(st[0])?.remote!==xt)return;let ft=Mt=>Mt.map(Qt=>it(Qt)?"":Qt.value??Qt.nodeValue).join(""),Wt=et.indexOf(st[0]);ft(et.slice(0,Wt))!==ft(ue.slice(0,Ye))||ft(et.slice(Wt+1))!==ft(ue.slice(Ye+1))||To(Fe,ze,xt)&&Xe.link(ze,st[0])}function To(ue,We,Ve){if(!it(We)||!it(Ve)||!it(ue)||We.namespaceURI!==Ve.namespaceURI||We.localName===Ve.localName)return!1;for(let ze of[We,Ve])if(ze.tagName==="TEMPLATE"||pn(ze)||ze.querySelector("template"))return!1;if(n.remoteWins(ue)||n.remoteWins(Ve)||s(Ve)||We.attributes.length!==Ve.attributes.length)return!1;for(let ze of We.attributes)if(Ve.getAttributeNS(ze.namespaceURI,ze.localName)!==ze.value)return!1;let et=We.childNodes,yt=Ve.childNodes;if(et.length!==yt.length)return!1;for(let ze=0;ze<et.length;ze++)if(!et[ze].isEqualNode(yt[ze]))return!1;let Fe=[[ue,Ve]];for(;Fe.length;){let[ze,xt]=Fe.pop();if(ze.children.length!==xt.children.length)return!1;for(let Ye=0;Ye<xt.children.length;Ye++){let st=q.reverse.get(xt.children[Ye]);if(st!==void 0&&st!==ze.children[Ye])return!1;Fe.push([ze.children[Ye],xt.children[Ye]])}}return!0}function so(ue){for(let We=ue-1;We>=0;We--){let Ve=tt.get(Ie[We]);if(Ve){let et=Ke.indexOf(Ve);if(et>=0)return et+1}}return 0}function vo(){if((ce.asBase||H.identical.has(L))&&(se.asBase||q.identical.has(L)))return;let ue={ignored:s,remoteWins:n.remoteWins,inlineCache:Ne},We=ut=>it(ut)?Vn(ut,ue):ut.kind==="text";if(!ce.asBase&&!se.asBase)for(let ut of Ie){if(!it(ut)||!Ln.has(ut.tagName))continue;let Qe=ce.twin(ut),Et=se.twin(ut);if(!Qe&&Et||Qe&&!Et){let ot=Br({base:Ie,views:[{V:ce,A:H,idOf:m.local},{V:se,A:q,idOf:m.remote}],eligible:At=>it(At)&&Ln.has(At.tagName)&&!s(At)&&!n.remoteWins(At),baseId:m.base,ignored:s,remoteWins:n.remoteWins,atomKey:l.exactUnitKey});ot&&(ce=ot[0],se=ot[1]);break}}let Ve=!ce.asBase&&!se.asBase&&Ie.length>=2&&Ln.has(Ie[0].tagName)&&ce.units.length===Ie.length&&se.units.length===Ie.length?mr({base:Ie,local:ce.units,remote:se.units,localTwin:ce.twin,remoteTwin:se.twin,eligible:ut=>it(ut)&&Ln.has(ut.tagName)&&!s(ut)&&!n.remoteWins(ut),nodes:{base:Array.from(Te(L).childNodes),local:Array.from(Te(ce.el).childNodes),remote:Array.from(Te(se.el).childNodes)}}):null,et=null,yt=null;if(!Ve&&!ce.asBase&&!se.asBase&&(Es(Ie)||Es(ce.units)||Es(se.units))){let ut={ignored:s,remoteWins:()=>!1},Qe=ot=>We(ot)||it(ot)&&n.remoteWins(ot)&&Tn.has(ot.tagName)&&Vn(ot,ut),Et=ot=>it(ot)?Ln.has(ot.tagName)&&!s(ot)&&!n.remoteWins(ot)&&r(ot).every(Qe):ot.kind==="text";et=jr({onUncertainOwner:ot=>{let At=n.identity.local(ot.local);At&&At===n.identity.remote(ot.remote)||(yt||=[]).push(ot)},onUncertainSource:ot=>{nt||(nt=new Map);let At=nt.get(ot.source);At||nt.set(ot.source,At=[]);for(let Jt of At)if(Jt.side===ot.side&&Jt.from===ot.from&&Jt.to===ot.to)return;At.push(ot)},base:Ie,views:[{V:ce,A:H,idOf:m.local},{V:se,A:q,idOf:m.remote}],eligible:Et,ignored:s,remoteWins:n.remoteWins,baseId:m.base,atomKey:l.exactUnitKey})}if(yt){$e||=new Map;for(let ut of yt){let{source:Qe,local:Et,remote:ot}=ut,At={map:new Map,reverse:new Map,identical:new Set},Jt=ht({base:[Qe],local:[Et],remote:[ot],out:ie,policy:"both",L:At,R:At,ignored:s,remoteWins:n.remoteWins,atomKey:l.exactUnitKey,cloneUnit:he,provenance:xe,textMappers:qe,conflicts:x,decisions:fe,conflict:(Rt,Ft)=>wt(Rt,{...Ft,policy:"both"}),scope:{base:L,local:ce.el,remote:se.el,units:Ie,at:He.get(Qe)},node:ye});ae.push(...Jt.segments);for(let Rt of[Qe,Et,ot])oe.add(Rt),bt.add(Rt),$e.set(Rt,Jt.nodes),tt.set(Rt,Jt.nodes[Jt.nodes.length-1]);for(let Rt=0;Rt<Jt.nodes.length;Rt++)lt.push({frag:Jt.nodes[Rt],at:He.get(Qe),previous:Rt?Jt.nodes[Rt-1]:null})}}let Fe=Ve?Ve.blocks:null;if(et){Fe=new Set;for(let ut of et.blocks)Fe.add(ut)}let ze=ut=>!Lt?.consumes(ut)&&(Fe&&Fe.has(ut)||We(ut)),xt=Ie.map(ze);if(!xt.includes(!0))return;let Ye=ut=>{let Qe=ut.units,Et=new Map;for(let tn=0;tn<Qe.length;tn++)Et.set(Qe[tn],tn);let ot=[],At=-1;for(let tn=0;tn<Ie.length;tn++){if(xt[tn])continue;let Tt=ut.twin(Ie[tn]),mt=Tt?Et.get(Tt):void 0;mt===void 0||mt<=At||ze(Tt)||(ot.push([tn,mt]),At=mt)}let Jt=[],Rt=-1,Ft=-1;for(let tn=0;tn<=ot.length;tn++){let[Tt,mt]=tn<ot.length?ot[tn]:[Ie.length,Qe.length],St={bLo:-1,bHi:-1,from:Ft+1,to:mt,inlineStart:-1,inlineEnd:-1,next:mt};for(let Zt=Rt+1;Zt<Tt;Zt++)xt[Zt]&&(St.bLo<0&&(St.bLo=Zt),St.bHi=Zt);for(let Zt=Ft+1;Zt<mt;Zt++){let zn=Qe[Zt];ze(zn)&&(St.inlineStart<0&&(St.inlineStart=Zt),St.inlineEnd=Zt+1)}Jt.push(St),Rt=Tt,Ft=mt}return{units:Qe,list:Jt}},st=Ye(ce),ft=Ye(se),Wt=[];for(let ut of[st,ft])for(let Qe of ut.list)Qe.bLo>=0&&Wt.push([Qe.bLo,Qe.bHi]);Wt.sort((ut,Qe)=>ut[0]-Qe[0]);let Mt=[];for(let[ut,Qe]of Wt){let Et=Mt[Mt.length-1];Et&&ut<=Et.hi?Et.hi=Math.max(Et.hi,Qe):Mt.push({lo:ut,hi:Qe})}let Qt=(ut,Qe)=>ut.length===Qe.length&&ut.every((Et,ot)=>l.equalUnits(Et,Qe[ot])),vn=ut=>!it(ut)&&ut.kind==="comment",_n=ut=>{if(!ut.length)return[];let Qe=(Rt,Ft)=>it(Rt)?Rt:Rt.nodes[Ft?Rt.nodes.length-1:0],Et=Qe(ut[0]),ot=Qe(ut[ut.length-1],!0),At=Rt=>Rt&&it(Rt)&&s(Rt);for(;At(Et.previousSibling);)Et=Et.previousSibling;for(;At(ot.nextSibling);)ot=ot.nextSibling;let Jt=[];for(let Rt=Et;Rt&&(Jt.push(Rt),Rt!==ot);Rt=Rt.nextSibling);return Jt},Pn=ut=>ut.some(Qe=>it(Qe)&&s(Qe));for(let ut of Mt){let Qe=Ie.slice(ut.lo,ut.hi+1),Et=null;if(et)for(let Tt of Qe){let mt=et.certificatesBySource.get(Tt);mt&&(Et||=[]).push(...mt)}let ot=ce.asBase?null:Ls(st,ut),At=se.asBase?null:Ls(ft,ut);if(Et){let Tt=[new Set(ot||Qe),new Set(At||Qe)],mt=Et.some(St=>!Tt[St.side].has(St.target));for(let St of Qe)if(Fe.has(St))for(let[Zt,zn]of[[0,ce],[1,se]]){let Sn=zn.twin(St);Sn&&zn.here(Sn)&&!Tt[Zt].has(Sn)&&(mt=!0)}if(mt)continue}if(Qe.some(vn)||ot&&ot.some(vn)||At&&At.some(vn))continue;let Jt=_n(ot||Qe),Rt=_n(At||Qe);if((!ot||Qt(Qe,ot))&&(!At||Qt(Qe,At))&&!(ot&&Pn(Jt)))continue;let Ft=ht({base:_n(Qe),sourceRetentions:nt?.get(L),local:Jt,remote:Rt,out:ie,policy:Ge,blocks:Fe,scopeUnits:Et?[Qe,ot||Qe,At||Qe]:null,certifiedOrigins:Et?(Tt,mt,St,Zt,zn,Sn)=>Dr({certificates:Et,scopes:[Qe,ot||Qe,At||Qe],flats:[Tt,mt,St],keys:[Zt,zn,Sn]}):null,prepared:Ve?Ve.prepared:null,nativeTransfers:Ve,L:ot?H:Ur(H,L),R:At?q:Ur(q,L),idOf:{base:b,local:S,remote:C},ignored:s,ignoreAttribute:n.ignoreAttribute,remoteWins:n.remoteWins,mergeElement:(Tt,mt,St)=>U(Tt,mt,St,!1),cloneUnit:he,mergeAttrs:le,atomKey:l.exactUnitKey,moveIn:O,moveBuilt:O,movePlanned:O,provenance:xe,textMappers:qe,conflicts:x,conflict:wt,scope:{base:L,local:ce.asBase?null:ce.el,remote:se.asBase?null:se.el,units:Ie,at:ut.lo},decisions:fe,node:ye});if(!Ft){if(Et){let Tt=gr({certificates:Et,scopes:[Qe,ot||Qe,At||Qe],views:[{V:ce,A:H,idOf:m.local},{V:se,A:q,idOf:m.remote}],eligible:mt=>it(mt)&&Ln.has(mt.tagName)&&!s(mt)&&!n.remoteWins(mt),baseId:m.base});for(let mt of Tt.records){nt||=new Map;let St=nt.get(mt.source);St||nt.set(mt.source,St=[]),St.push(mt)}}continue}if(ae.push(...Ft.segments),Ve){let Tt=new Map;for(let mt of Ft.nodes){let St=xe.get(mt)?.base;if(!St||Tt.has(St))throw new Error("Invalid native transfer owner output");Tt.set(St,mt)}if(Tt.size!==Ve.owners.length)throw new Error("Incomplete native transfer owner output");for(let mt of Ve.owners){let St=Tt.get(mt.base);if(!St)throw new Error("Missing native transfer owner output");for(let Zt of[mt.base,mt.local,mt.remote])oe.add(Zt),bt.add(Zt),tt.set(Zt,St);lt.push({frag:St,at:He.get(mt.base)})}continue}if(Xe&&Fn(Qe,ot||Qe,At||Qe,Ft.nodes),Ft.unitOutputs){$e||=new Map;for(let mt of[...Qe,...ot||[],...At||[]]){let St=Ft.unitOutputs.get(mt)||[];oe.add(mt),bt.add(mt),$e.set(mt,St),St.length&&tt.set(mt,St[St.length-1])}let Tt=Ft.nodes[Ft.nodes.length-1];if(Tt)for(let mt of[ot||Qe,At||Qe]){let St=mt[mt.length-1];St&&vt.set(St,Tt)}for(let mt=0;mt<Ft.nodes.length;mt++)lt.push({frag:Ft.nodes[mt],at:ut.lo,previous:mt>0?Ft.nodes[mt-1]:null});continue}Xe&&Fn(Qe,ot||Qe,At||Qe,Ft.nodes);let tn=ie.createDocumentFragment();for(let Tt of Ft.nodes)tn.appendChild(Tt);for(let Tt of[...Qe,...ot||[],...At||[]])oe.add(Tt),bt.add(Tt),tt.set(Tt,tn);lt.push({frag:tn,at:ut.lo})}}}function te(L,G){let re=xe.get(L);return re&&re.unchanged?!re.remote||re.remote===G?!0:z(re.remote,G):L.tagName!==G.tagName||!Ce(L,G)?!1:Pe(Te(L),Te(G))}function z(L,G){return L===G?!0:L.tagName!==G.tagName||L.namespaceURI!==G.namespaceURI||!Ce(L,G)?!1:ne(Te(L),Te(G))}function ne(L,G){let re=ve(L,s),ge=ve(G,s);if(re.length!==ge.length)return!1;for(let ye=0;ye<re.length;ye++){let ce=re[ye],se=ge[ye];if(typeof ce=="string"||typeof se=="string"){if(ce!==se)return!1}else{if(ce.nodeType!==se.nodeType)return!1;if(ce.nodeType===1){if(!z(ce,se))return!1}else if(ce.nodeValue!==se.nodeValue)return!1}}return!0}function Te(L){return L.tagName==="TEMPLATE"&&L.content?L.content:L}function Ce(L,G){let re=0;for(let ge of L.attributes)if(!n.ignoreAttribute(L,ge.name)&&(re++,G.getAttribute(ge.name)!==ge.value))return!1;for(let ge of G.attributes)n.ignoreAttribute(G,ge.name)||re--;return re===0}function Pe(L,G){let re=ve(L,ye=>{let ce=xe.get(ye);return!!(ce&&ce.pinned)}),ge=ve(G,s);if(re.length!==ge.length)return!1;for(let ye=0;ye<re.length;ye++){let ce=re[ye],se=ge[ye];if(typeof ce=="string"||typeof se=="string"){if(ce!==se)return!1}else{if(ce.nodeType!==se.nodeType)return!1;if(ce.nodeType===1){if(!te(ce,se))return!1}else if(ce.nodeValue!==se.nodeValue)return!1}}return!0}function ve(L,G){let re=[],ge=null;for(let ye=L.firstChild;ye;ye=ye.nextSibling){if(ye.nodeType===3){ge=ge===null?ye.nodeValue:ge+ye.nodeValue;continue}ye.nodeType===1&&G(ye)||(ge!==null&&(ge!==""&&re.push(ge),ge=null),re.push(ye))}return ge!==null&&ge!==""&&re.push(ge),re}function _e(L,G,re,ge){let ye=L.value,ce=ge?ye:G?G.value:"",se=re?re.value:"";oe.add(L),G&&oe.add(G),re&&oe.add(re);let Ie=ce===se?ce:ce===ye?se:se===ye||Ge==="local"?ce:se,Be={site:"comment",bRun:L,lRun:G,rRun:re,node:null};if(ce!==ye&&se!==ye&&ce!==se&&wt({kind:"text",node:null,base:ye,local:ce,remote:se,resolved:Ie},Be),!G&&!re)return null;let He=ie.createComment(Ie);return Be.node=He,xe.set(He,{base:L.nodes,local:G?G.nodes:null,remote:re?re.nodes:null}),He}function Je(L,G){let re=a(G,L);if(!re)return null;let ge=it(re)?re.parentNode:re.parent,ye=it(L)?L.parentNode:L.parent;return a(G,ye)===ge?null:G.reverse.get(ge)||null}function Ze(L){let G=new Set([L]),re=L;for(let ge=0;ge<64;ge++){let ye=Je(re,H)||Je(re,q);if(!ye)return!1;if(ye===L||it(L)&&it(ye)&&L.contains(ye)||G.has(ye))return!0;G.add(ye),re=ye}return!0}function Ut(L,G,re){if(!G)return!1;let ge=it(L)?L.parentNode:L.parent;return ge===G||G.tagName==="TEMPLATE"&&ge===G.content}function Pt(L,G){let re=Re(L),ge=a(H,re);if(ge&&Ut(G,ge,H))return!0;let ye=a(q,re);return!!(ye&&Ut(G,ye,q))}}function Ur(e,o){return e.map.get(o)?Vr():{map:{get:n=>n&&n.nodeType===1&&e.map.get(n)||n,has:()=>!0},reverse:{get:n=>e.reverse.get(n)||n,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Vr(){let e={get:o=>o,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Hr=new Set(["INPUT","OPTION","TEXTAREA"]),Ps=/[\t\n\f\r ]+/;function Wr(e,o,t,n){let s=e.ownerDocument,{provenance:h,textMappers:l}=t,r=n.hooks,i=[],u=[],w=[],c=new Set,p=[],b=[],S=new Map,C=new Set,m=new Map,f=t.conflicts.length>0||n.trackInserted===!0,g=new Map,I=new Set,v=new Map,T=(a,O)=>{let P=v.get(a);P||v.set(a,P=new Set),P.add(O)},A=f?new Set:null,E=(a,O,P)=>{let K=r.beforeAttributeUpdated(a,O,P);return f&&K===!1&&T(O,a),K},N=a=>!!a&&(a===e||e.contains(a)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(a)),M=new Map,R=new Map,V=new Map,D=new Set,j=new Map;(function a(O){let P=h.get(O);if(P){if(O.nodeType===1){let Z=P.local?n.toLive(P.local):null;Z&&N(Z)&&Z.nodeType===1&&(M.set(O,Z),R.set(Z,O))}else if(Array.isArray(P.local)){let Z=q(P.local,P.local.map(U=>n.toLive(U)).filter(U=>U&&N(U)&&U.nodeType===O.nodeType));if(Z.length&&(M.set(O,Z[0]),R.set(Z[0],O),V.set(O,Z)),Array.isArray(P.caret))for(let U of P.caret){let de=n.toLive(U.node);if(!de||!N(de)||de.nodeType!==3)continue;let we=j.get(de);Array.isArray(we)||j.set(de,we=[]),we.push({merged:O,from:U.from,to:U.to,flatStart:U.flatStart})}else{let U=0;for(let de of Z)j.set(de,{merged:O,shift:U}),U+=de.nodeValue.length}}}let K=O.nodeType===1&&O.tagName==="TEMPLATE"&&O.content?O.content.childNodes:O.childNodes;for(let Z of K)a(Z)})(o);let y=new Set;for(let a of M.values())y.add(a);for(let a of V.values())for(let O of a)y.add(O);let k=n.localRoot&&n.localRoot!==e?new Set:null;if(k){for(let a=n.localRoot.firstElementChild;a;a=a.nextElementSibling)if(a.tagName==="HEAD")for(let O=a.firstElementChild;O;O=O.nextElementSibling){let P=n.toLive(O);P&&k.add(P)}}for(let a of t.segments||[])Me(a);let J=n.restoreFocus===!1?null:kl(s,j);n.childrenOnly?xe(Oe(e),Oe(o)):Re(e,o);for(let{node:a,parent:O}of p)c.has(a)||!a.parentNode||a.nodeType===1&&(n.ignored(a)||qe(a))||nt(a,O);return xl(s,J,j,l,V,m,D),{applied:i,moved:u,replaced:w,identities:b,mergedScriptsLive:C,liveOf:M,heldBy:m,runOf:V,keptRuns:D,insertedLive:g,vetoed:I,vetoedAttrs:v,removedVetoes:A};function H(a,O){let P=a.slice(O.bs,O.be),K=0;for(;K<P.length&&K<O.text.length&&P[K]===O.text[K];)K++;let Z=0;for(;Z<P.length-K&&Z<O.text.length-K&&P[P.length-1-Z]===O.text[O.text.length-1-Z];)Z++;return{bs:O.bs+K,be:O.be-Z,text:O.text.slice(K,O.text.length-Z)}}function q(a,O){if(!O.length)return O;let P=[];for(let U of a){let de=U.parentNode;if(!de)continue;let we=S.get(de);if(!we){we=new Set;for(let le=de.firstChild;le;le=le.nextSibling)le.nodeType===3&&we.add(n.toLive(le));S.set(de,we)}P.includes(we)||P.push(we)}let K={has:U=>P.some(de=>de.has(U))},Z=[];for(let U of O){Z.push(U);for(let de=U.nextSibling;de&&de.nodeType===3&&!K.has(de)&&!Z.includes(de);de=de.nextSibling)Z.push(de)}return Z}function Me(a){let O=[];for(let ee of a.localNodes){let te=n.toLive(ee.node);if(!te||!N(te)||te.nodeType!==3)return;O.push(te)}let P=q(a.localNodes.map(ee=>ee.node),O);if(!P.length)return;let K=P.map(ee=>ee.nodeValue).join(""),{flatLocal:Z,lToM:U,mapLocal:de}=a;if(K===Z)return;let we=a.textNodes.map(ee=>({node:ee.node,ms:ee.ms,me:ee.me})),le=[],Ae=0;for(let ee of P)le.push(Ae),Ae+=ee.nodeValue.length;let W=(ee,te)=>P.find((z,ne)=>le[ne]<=ee&&ee+te<=le[ne]+z.nodeValue.length)||null,X=[],pe=0;for(let ee of Yn(Z,K).map(te=>H(Z,te))){let te=ee.bs+pe;pe+=ee.text.length-(ee.be-ee.bs);let z,ne;if(ee.be>ee.bs){z=U[ee.bs];let Te=z>=0;for(let Ce=ee.bs;Te&&Ce<ee.be;Ce++)U[Ce]!==z+(Ce-ee.bs)&&(Te=!1);if(!Te)continue;ne=z+(ee.be-ee.bs)}else{let Te=ee.bs>0?U[ee.bs-1]:0,Ce=ee.bs<Z.length?U[ee.bs]:0;if(Te<0||Ce<0)continue;z=ne=de(ee.bs)}X.push({ms:z,me:ne,text:ee.text,live:ne===z?W(te,ee.text.length):null})}X.sort((ee,te)=>te.ms-ee.ms);let be=(ee,te)=>(V.get(ee.node)||[M.get(ee.node)]).includes(te),he=ee=>!!ee&&ee.nodeType===1&&Tn.has(ee.tagName);for(let ee of X){let te=we.find(ne=>ne.ms<=ee.ms&&ee.me<=ne.me&&ee.ms<ne.me);if(te&&ee.live&&te.ms===ee.ms&&!be(te,ee.live)){let ne=we.find(Te=>Te.me===ee.ms&&be(Te,ee.live));ne&&(te=ne)}if(!te&&ee.me===ee.ms){let ne=we.find(ve=>ve.me===ee.ms),Te=we.find(ve=>ve.ms===ee.ms),Ce=ne||Te;if(!Ce)continue;let Pe=Ce.node;for(;he(Pe.parentNode)&&(ne?Pe.parentNode.lastChild:Pe.parentNode.firstChild)===Pe;)Pe=Pe.parentNode;if(Pe===Ce.node)te=Ce;else{let ve=Pe.ownerDocument.createTextNode(ee.text);Pe.parentNode.insertBefore(ve,ne?Pe.nextSibling:Pe);continue}}if(!te)continue;let z=te.node.nodeValue;te.node.nodeValue=z.slice(0,ee.ms-te.ms)+ee.text+z.slice(ee.me-te.ms),te.me+=ee.text.length-(ee.me-ee.ms)}}function Oe(a){return a.nodeType===1&&a.tagName==="TEMPLATE"&&a.content?a.content:a}function Re(a,O){c.add(a);let P=h.get(O);if(P&&P.remote&&t.remoteIdOf){let Z=t.remoteIdOf(P.remote);Z&&b.push([a,Z])}if(P&&P.unchanged){n.opaque&&n.opaque(a)||(t.customIdentity&&P.remote&&ae(a,P.remote),P.remote&&Y(a,P.remote));return}if(r.beforeNodeMorphed(a,O)===!1){I.add(O);return}Ct(a,O,n.keepLiveOnly&&P&&P.local&&P.local.nodeType===1&&P.local!==a?P.local:null);let K=a.tagName;if(pn(a))a.textContent!==O.textContent&&(i.push({kind:"text",node:a,before:a.textContent,after:O.textContent}),a.textContent=O.textContent),t.mergedScripts.has(O)&&C.add(a);else if(K==="TEXTAREA")$(a,O,P);else{Yt(a,O,P);let Z=K==="TEMPLATE"&&a.content?a.content:a,U=K==="TEMPLATE"&&O.content?O.content:O;n.opaque&&n.opaque(a)||n.protectFocusedValue==="subtree"&&Nt(a)&&a!==s.body?ie(Z):xe(Z,U)}r.afterNodeMorphed(a,O)}function ie(a){for(let O=a.firstChild;O;O=O.nextSibling){let P=R.get(O);P&&M.get(P.parentNode)!==a||(c.add(O),O.nodeType===1&&ie(O))}}function xe(a,O){let P=De(a.firstChild),K=new Set;for(let Z of Array.from(O.childNodes)){let U=M.get(Z);U&&c.has(U)&&!K.has(U)&&(U=null);let de=h.get(Z);if(de&&de.pinned){U&&U.nodeType===1&&((U.parentNode!==a||De(U.nextSibling)!==P)&&Ne(a,U,P),c.add(U),K.add(U));continue}if(U&&U.nodeType===1){if(U!==P){let Ae=U.parentNode;if(Ae===a&&P&&Lt(U)){let W=U.nextSibling;for(let X=P;X&&X!==U;){let pe=X.nextSibling;Ne(a,X,W),X=pe}}else Ne(a,U,P),Ae!==a&&(u.push(U),i.push({kind:"move",el:U,from:Ae,to:a}))}K.add(U),Re(U,Z),P=De(U.nextSibling);continue}if(U&&U.nodeType!==1){let Ae=V.get(Z)||[U],W=Ae.map(pe=>pe.nodeValue).join(""),X=Z.nodeValue;if(Z.nodeType===3){let pe=fe(Z);pe!=null&&W!==pe&&(X=lo(pe,W,Z.nodeValue).text)}if(Ae.length>1&&W===X&&!Ae.includes(P,1)&&Ae.every((pe,be)=>pe.parentNode===a&&(be===0||Ae[be-1].nextSibling===pe))){if(U!==P)for(let pe of Ae)Ne(a,pe,P);r.beforeNodeMorphed(U,Z)!==!1?r.afterNodeMorphed(U,Z):f&&I.add(Z);for(let pe of Ae)c.add(pe),K.add(pe);m.set(Z,U),D.add(Z),P=De(Ae[Ae.length-1].nextSibling);continue}U!==P&&Ne(a,U,P),r.beforeNodeMorphed(U,Z)!==!1?(U.nodeValue!==X&&(i.push({kind:"text",node:U,before:U.nodeValue,after:X}),U.nodeValue=X),r.afterNodeMorphed(U,Z)):I.add(Z),c.add(U),K.add(U),m.set(Z,U),P=De(U.nextSibling);continue}if(Z.nodeType===3&&P&&P.nodeType===3&&!c.has(P)&&!j.has(P)){P.nodeValue!==Z.nodeValue&&(i.push({kind:"text",node:P,before:P.nodeValue,after:Z.nodeValue}),P.nodeValue=Z.nodeValue),c.add(P),m.set(Z,P),P=De(P.nextSibling);continue}let we=h.get(Z),le=Xe(we&&we.unchanged&&we.remote?we.remote:Z);if(r.beforeNodeAdded(le)===!1){I.add(Z);continue}a.insertBefore(le,P),c.add(le),f&&g.set(Z,le),le.nodeType===3&&m.set(Z,le),le.nodeType===1&&(w.push(le),Ee(le,Z),t.customIdentity&&we&&we.unchanged&&we.remote&&ae(le,we.remote),pn(le)||ht(le,Z),n.formState==="property"&&rn(we)&&Y(le,we.remote)),P=De(le.nextSibling),i.push({kind:"insert",node:le,parent:a}),r.afterNodeAdded(le)}for(let Z of Array.from(a.childNodes))c.has(Z)||K.has(Z)||Z.nodeType===1&&(n.ignored(Z)||qe(Z))||(y.has(Z)?p.push({node:Z,parent:a}):nt(Z,a))}function qe(a){return a.parentNode&&a.parentNode.nodeType===1&&a.parentNode.tagName==="HEAD"&&(k&&!k.has(a)||n.preserve&&n.preserve(a)===!0)}function fe(a){let O=h.get(a);return!O||!Array.isArray(O.local)?null:O.local.map(P=>P.nodeValue).join("")}function x(a){return h.get(a)}function Y(a,O){if(!Hr.has(a.tagName)&&!a.querySelector("input,option,textarea"))return;let P=(K,Z)=>{if(K.tagName!==Z.tagName||(K.tagName==="TEXTAREA"?$(K,Z,{remote:Z}):Hr.has(K.tagName)&&Yt(K,Z,{remote:Z}),n.opaque&&n.opaque(K)))return;let U=oe(K),de=oe(Z);if(U.length===de.length)for(let we=0;we<U.length;we++)P(U[we],de[we])};P(a,O)}function ae(a,O){if(n.opaque&&n.opaque(a))return;let P=oe(a),K=oe(O);if(P.length===K.length)for(let Z=0;Z<P.length;Z++){let U=t.remoteIdOf(K[Z]);U&&b.push([P[Z],U]),ae(P[Z],K[Z])}}function oe(a){let O=a.tagName==="TEMPLATE"&&a.content?a.content:a;return Array.from(O.children).filter(P=>!n.ignored(P))}function Ee(a,O){if(!t.remoteIdOf)return;let P=(K,Z)=>{let U=h.get(Z);if(U&&U.remote&&Z.nodeType===1){let le=t.remoteIdOf(U.remote);le&&b.push([K,le])}let de=K.childNodes,we=Z.childNodes;for(let le=0;le<de.length&&le<we.length;le++)P(de[le],we[le])};P(a,O)}function De(a){for(;a&&a.nodeType===1&&n.ignored(a);)a=a.nextSibling;return a}function Ne(a,O,P){if(typeof a.moveBefore=="function"&&O.ownerDocument===a.ownerDocument)try{a.moveBefore(O,P);return}catch{}a.insertBefore(O,P)}function nt(a,O){if(r.beforeNodeRemoved(a)===!1){f&&A.add(a);return}a.parentNode.removeChild(a),i.push({kind:"remove",node:a,parent:O}),r.afterNodeRemoved(a)}function Xe(a){if(pn(a))return Mo(a,s);let O=s.importNode(a,!0);if(O.nodeType===1)for(let P of Array.from(O.querySelectorAll("script")))pn(P)&&P.replaceWith(Mo(P,s));return O}function ht(a,O){let P=a.tagName==="TEMPLATE"&&a.content?a.content:a,K=O.tagName==="TEMPLATE"&&O.content?O.content:O,Z=Array.from(P.childNodes),U=Array.from(K.childNodes);for(let de=0;de<U.length&&de<Z.length;de++){let we=U[de],le=Z[de],Ae=M.get(we);Ae&&c.has(Ae)&&(Ae=null);let W=h.get(we);if(W&&W.pinned){if(Ae&&Ae.nodeType===1){let X=Ae.parentNode;Ne(P,Ae,le),X!==P&&(u.push(Ae),i.push({kind:"move",el:Ae,from:X,to:P})),c.add(Ae)}le.remove();continue}if(Ae){let X=Ae.parentNode;Ne(P,Ae,le),le.remove(),Ae.nodeType===1?(X!==P&&(u.push(Ae),i.push({kind:"move",el:Ae,from:X,to:P})),Re(Ae,we)):(c.add(Ae),m.set(we,Ae),Ae.nodeValue!==we.nodeValue&&(i.push({kind:"text",node:Ae,before:Ae.nodeValue,after:we.nodeValue}),Ae.nodeValue=we.nodeValue));continue}c.add(le),f&&g.set(we,le),le.nodeType===3&&m.set(we,le),W&&W.unchanged&&W.remote?(Ge(le,W.remote),t.customIdentity&&ae(le,W.remote)):we.nodeType===1&&!pn(we)&&ht(le,we)}}function Ge(a,O){let P=a.tagName==="TEMPLATE"&&a.content?a.content:a,K=O.tagName==="TEMPLATE"&&O.content?O.content:O;for(let Z of Array.from(K.childNodes))P.appendChild(Xe(Z))}function rt(a,O){return O.namespaceURI?a.getAttributeNS(O.namespaceURI,O.localName):a.getAttribute(O.name)}function Ot(a,O){let P=new Set((O||"").split(Ps).filter(Boolean));return(a||"").split(Ps).filter(K=>K&&!P.has(K))}function Ct(a,O,P){for(let K of Array.from(O.attributes)){if(wt(a,K.name)||n.ignoreAttribute(a,K.name))continue;let Z=rt(a,K);if(Z===K.value||P&&rt(P,K)===K.value)continue;let U=K.value;if(P&&K.name==="class"&&!K.namespaceURI){let de=K.value.split(Ps).filter(Boolean),we=Ot(Z,P.getAttribute("class")).filter(le=>!de.includes(le));we.length&&(U=[...de,...we].join(" "))}if(Z!==U){if(r.beforeAttributeUpdated(K.name,a,"update")===!1){f&&T(O,K.name);continue}K.namespaceURI?a.setAttributeNS(K.namespaceURI,K.name,U):a.setAttribute(K.name,U),i.push({kind:"attr",el:a,name:K.name,before:Z,after:U})}}for(let K of Array.from(a.attributes)){if(wt(a,K.name)||n.ignoreAttribute(a,K.name)||(K.namespaceURI?O.hasAttributeNS(K.namespaceURI,K.localName):O.hasAttribute(K.name)))continue;if(P&&K.name==="class"&&!K.namespaceURI){let de=Ot(K.value,P.getAttribute("class"));if(de.length){let we=de.join(" ");if(we===K.value)continue;if(r.beforeAttributeUpdated("class",a,"update")===!1){f&&T(O,"class");continue}a.setAttribute("class",we),i.push({kind:"attr",el:a,name:"class",before:K.value,after:we});continue}}if(P&&rt(P,K)===null)continue;if(r.beforeAttributeUpdated(K.name,a,"remove")===!1){f&&T(O,K.name);continue}let U=K.value;K.namespaceURI?a.removeAttributeNS(K.namespaceURI,K.localName):a.removeAttribute(K.name),i.push({kind:"attr",el:a,name:K.name,before:U,after:null})}}function wt(a,O){let P=a.tagName;return P==="INPUT"?O==="value"||O==="checked"||O==="disabled":P==="OPTION"?O==="selected":!1}function Nt(a){return a===s.activeElement}function Lt(a){let O=s.activeElement;return!!O&&O!==s.body&&a.contains(O)}function qt(a,O){let P=O&&O.local&&O.local.nodeType===1&&O.local!==a?O.local:null;if(!P)return!0;let K=a.tagName==="TEXTAREA"?P.textContent:P.getAttribute("value")??"";return a.value!==K}function cn(a,O){return!!n.protectFocusedValue&&Nt(a)&&qt(a,O)}function It(a,O,P){let K=Math.min(a.length,O.length),Z=0;for(;Z<K&&a[Z]===O[Z];)Z++;if(P<=Z)return P;let U=0;for(;U<K-Z&&a[a.length-1-U]===O[O.length-1-U];)U++;return P>=a.length-U?P+O.length-a.length:O.length-U}function Gt(a){try{return a.selectionStart==null?null:[a.selectionStart,a.selectionEnd,a.selectionDirection]}catch{return null}}function wn(a,O,P,K){try{a.setSelectionRange(It(O,P,K[0]),It(O,P,K[1]),K[2]||"none")}catch{}}function Dt(a,O){let P=a.value,K=Gt(a);a.value=O,K&&wn(a,P,O,K)}function rn(a){let O=a&&a.remote;return O&&O.nodeType===1?O:null}function Yt(a,O,P){let K=a.tagName,Z=rn(P),U=n.formState==="property"&&Z?Z:O;if(K==="INPUT"){let de=cn(a,P),we=(a.getAttribute("type")||"").toLowerCase(),le=we!=="file"&&we!=="checkbox"&&we!=="radio",Ae=Z&&Z.hasAttribute("value")&&Z.value!==Z.getAttribute("value")?Z.value:null;if(le&&!de)if(n.formState==="property"){let W=O.getAttribute("value"),X=a.getAttribute("value");(X!==W||a.value!==U.value)&&E("value",a,W==null?"remove":"update")!==!1&&(X!==W&&(W==null?a.removeAttribute("value"):a.setAttribute("value",W),i.push({kind:"attr",el:a,name:"value",before:X,after:W})),a.value!==U.value&&(Nt(a)?Dt(a,U.value):a.value=U.value))}else if(O.hasAttribute("value")||Ae!=null){let W=Ae??O.getAttribute("value");a.getAttribute("value")!==W&&E("value",a,"update")!==!1?(a.setAttribute("value",W),a.value!==W&&(Nt(a)?Dt(a,W):a.value=W),i.push({kind:"attr",el:a,name:"value",before:null,after:W})):a.value!==W&&a.getAttribute("value")===W&&(Nt(a)?Dt(a,W):a.value=W)}else(a.hasAttribute("value")||a.value!=="")&&E("value",a,"remove")!==!1&&(a.removeAttribute("value"),a.value="",i.push({kind:"attr",el:a,name:"value",before:"",after:null}));if(!le&&we!=="file"){let W=O.getAttribute("value");W==null?a.hasAttribute("value")&&E("value",a,"remove")!==!1&&a.removeAttribute("value"):a.getAttribute("value")!==W&&E("value",a,"update")!==!1&&a.setAttribute("value",W)}n.protectFocusedValue&&Nt(a)||(fn(a,U,"checked"),n.formState==="property"&&a.indeterminate!==U.indeterminate&&(a.indeterminate=U.indeterminate)),fn(a,U,"disabled")}else if(K==="OPTION"){let de=a.parentNode&&a.closest("select");n.protectFocusedValue&&de&&Nt(de)||fn(a,U,"selected")}}function fn(a,O,P){let K=n.formState==="property"?!!O[P]:O.hasAttribute(P);if(n.formState!=="property"){let Z=a.hasAttribute(P);if(Z!==K){if(E(P,a,K?"update":"remove")===!1)return;K?a.setAttribute(P,""):a.removeAttribute(P),i.push({kind:"attr",el:a,name:P,before:Z?"":null,after:K?"":null})}}a[P]!==K&&(a[P]=K)}function $(a,O,P){if(cn(a,P)||E("value",a,"update")===!1)return;let K=rn(P),Z=O.textContent,U=K&&K.value!==K.defaultValue?K.value:Z,de=Nt(a)?Gt(a):null,we=a.value;n.formState!=="property"&&a.textContent!==Z&&(i.push({kind:"text",node:a,before:a.textContent,after:Z}),a.textContent=Z),a.value!==U&&(a.value=U),de&&a.value!==we&&wn(a,we,a.value,de)}}function kl(e,o){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let n={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{n.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return n}let s=e.getSelection&&e.getSelection();if(s&&s.rangeCount){let h=s.getRangeAt(0);n.range={sc:h.startContainer,so:h.startOffset,ec:h.endContainer,eo:h.endOffset}}return n}function xl(e,o,t,n,s,h,l){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 i=(c,p)=>{let b=t.get(c);if(Array.isArray(b)){let S=b.find(g=>p>=g.from&&p<g.to)||b.find(g=>p===g.to)||b[b.length-1],C=h.get(S.merged);if(!C||!C.isConnected)return null;let m=n.get(S.merged),f=m&&m.flat?m.flat(S.flatStart+p):p;return[C,Math.max(0,Math.min(f,C.nodeValue.length))]}if(b&&!l.has(b.merged)){let S=(s.get(b.merged)||[c])[0];if(!S.isConnected)return null;let C=n.get(b.merged),m=b.shift+p,f=C?C(m):m;return[S,Math.max(0,Math.min(f,S.nodeValue.length))]}return c.isConnected?[c,Math.min(p,c.nodeType===3?c.nodeValue.length:c.childNodes.length)]:null},u=i(o.range.sc,o.range.so),w=i(o.range.ec,o.range.eo);if(!(!u||!w))try{let c=e.createRange();c.setStart(u[0],u[1]),c.setEnd(w[0],w[1]);let p=e.getSelection();p.removeAllRanges(),p.addRange(c)}catch{}}var Tl={compared:0},vl=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Sl(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 Bs(e,o){if(e.namespaceURI!==o.namespaceURI||e.prefix!==o.prefix||e.localName!==o.localName)return!1;let t=e.attributes;if(t.length!==o.attributes.length)return!1;for(let n of t)if(o.getAttributeNS(n.namespaceURI,n.localName)!==n.value)return!1;return!0}function qr(e,o,t,n,s,h,l,r){let i=new Map,u=new Set,w=c=>{if(n(c))return;let p=t(c);p&&(h.add(p),s.has(p)||i.has(p)?u.add(p):i.set(p,c))};for(let c of e)w(c);w(o);for(let c of l||o.querySelectorAll("*"))w(c);for(let c of u)i.delete(c),r.add(c);return i}function Kr(e,o,t,n,s,h){let l=!1;for(let w of s)w.startsWith("merge:")&&(l=!0);if(!l)return[...n];let r=new Map,i=[],u=h===kn?Co:"*";for(let w of[e,...e.querySelectorAll(u)]){if(t(w))continue;let c=o(w);if(!c||!(n.has(c)||s.has(c)))continue;let p=(r.get(c)||0)+1;r.set(c,p),p===2&&i.push(c)}return i}function Fr({baseRoot:e,remoteRoot:o,liveRoot:t,toLive:n,o:s,identity:h,baseURI:l}){if(e.tagName!==o.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||o.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!Sl(e,o,s.ignoreAttribute))return{bail:"root-attrs"};let{ignored:r,remoteWins:i}=s,u=Rs(s.scripts.merge===!1?null:s.scripts.mergeTags,l),w=fe=>{let x=u(fe);return x!==null?x:h.base(fe)||null},c=fe=>{let x=u(fe);return x!==null?x:h.remote(fe)||null},p=[],b=[],S=new Map,C=new Map,m={same:S,differ:C},f=fe=>({bail:fe,comparisons:m}),g=(fe,x,Y=!0)=>{if(S.get(fe)===x)return!0;if(C.get(fe)===x)return!1;if(Tl.compared++,Y&&fe.isEqualNode(x))return S.set(fe,x),!0;let ae=fe.nodeType===x.nodeType;if(ae&&fe.nodeType===1){if(ae=Bs(fe,x),ae){let oe=fe.firstChild,Ee=x.firstChild;for(;oe&&Ee;oe=oe.nextSibling,Ee=Ee.nextSibling)if(!g(oe,Ee,!1)){ae=!1;break}(oe||Ee)&&(ae=!1)}}else ae&&(ae=fe.isEqualNode(x));return(ae?S:C).set(fe,x),ae},I=e,v=o,T=!1,A=()=>{S.set(I,v);for(let fe=0;fe<p.length;fe++)S.set(p[fe],b[fe]);return f("equal")};for(;;){let fe=I.childNodes,x=v.childNodes;if(fe.length!==x.length)break;let Y=Xe=>g(fe[Xe],x[Xe])?(S.set(fe[Xe],x[Xe]),!1):!0,ae=-1,oe=-1;for(let Xe=0;Xe<fe.length;Xe++){if(fe[Xe].nodeType!==1)continue;let ht=0;for(let Ge=fe[Xe].firstElementChild;Ge;Ge=Ge.nextElementSibling)ht++;ht>=oe&&(oe=ht,ae=Xe)}let Ee=[],De=!1;for(let Xe=0;Xe<fe.length&&Ee.length<2;Xe++)Xe!==ae&&Y(Xe)&&Ee.push(Xe);if(ae>=0&&Ee.length<2&&(Ee.length===0&&Bs(I,v)?(Ee.push(ae),De=!0):Y(ae)&&Ee.push(ae)),Ee.length!==1){if(!T&&Ee.length===0&&Bs(I,v))return A();break}let Ne=fe[Ee[0]],nt=x[Ee[0]];if(T=T||!De,T&&C.set(Ne,nt),Ne.nodeType!==1||nt.nodeType!==1||Ne.tagName!==nt.tagName)break;if(w(Ne)!==c(nt)){if(!T&&g(Ne,nt))return A();break}p.push(I),b.push(v),I=Ne,v=nt}C.set(I,v);for(let fe=0;fe<p.length;fe++)C.set(p[fe],b[fe]);if(I===e||I.tagName==="HEAD"||I.tagName==="BODY")return f("root-level");if(p.length<2||p[1].tagName!=="BODY")return f("not-in-body");if(r(I)||r(v))return f("ignored-ancestor");if(i(I)||i(v))return f("remote-wins-ancestor");for(let fe of p)if(vl.has(fe.tagName))return f("form-ancestor");if(I.tagName==="SCRIPT"||I.getElementsByTagName("script").length||v.getElementsByTagName("script").length)return f("script-or-template");let E=n(I);if(!E||E.nodeType!==1||E.tagName!==I.tagName)return f("no-live-twin");if(!t.contains(E))return f("live-detached");for(let fe of p){let x=n(fe);if(!x||x.nodeType!==1)return f("ancestor-live")}let N=h.base===kn&&h.remote===kn&&r===ss,M=new Set,R=new Set,V=[],D=null,j=fe=>{fe&&(M.has(fe)?R.add(fe):M.add(fe))},y=(fe,x)=>{let Y=u(fe),ae=Y!==null?Y:h.base(fe)||null;return ae!==(Y!==null?Y:h.remote(x)||null)?!1:(j(ae),!0)},k=(fe,x)=>{for(let Y=fe.firstElementChild,ae=x.firstElementChild;Y;Y=Y.nextElementSibling,ae=ae.nextElementSibling){let oe=r(Y);if(oe!==r(ae))return!1;if(!oe&&(!y(Y,ae)||!k(Y,ae)))return!1}return!0},J=fe=>{let x=fe+1<p.length?p[fe+1]:I;for(let Y=p[fe].firstElementChild,ae=b[fe].firstElementChild;Y;Y=Y.nextElementSibling,ae=ae.nextElementSibling){if(Y===x){let De=fe+1<p.length?J(fe+1):null;if(De)return De;continue}let oe=r(Y);if(oe!==r(ae))return"outside-id-changed";if(oe)continue;let Ee=n(Y);if(!Ee||Ee.nodeType!==1)return"sibling-live";if(V.push([Y,ae]),!N&&(!y(Y,ae)||!k(Y,ae)))return"outside-id-changed";fe===0&&Y.tagName==="HEAD"&&w(Y)&&(D=[Y,ae])}return null},H=J(0);if(H)return f(H);let q=new Set(p),Me=null;if(h.base===kn){Me=[];for(let fe of e.querySelectorAll(Co))fe===I||q.has(fe)||(I.contains(fe)?Me.push(fe):N&&j(w(fe)))}let Oe=new Set,Re=new Set,ie=new Set,xe=qr(p,I,w,r,M,Oe,Me,Re),qe=qr(b,v,c,r,M,Oe,h.remote===kn&&v.querySelectorAll(Co),ie);return D&&(R.has(w(D[0]))||Oe.has(w(D[0])))&&(D=null),{scope:{chain:p,root:I,onChain:q,baseIndex:xe,remoteIndex:qe,baseDropped:Re,remoteDropped:ie,head:D,same:S,differ:C,dropped:[...Kr(e,w,r,R,Re,h.base),...Kr(o,c,r,R,ie,h.remote)],held:fe=>{for(let x=1;x<p.length;x++)if(fe.map.get(p[x])!==b[x])return!1;for(let[x,Y]of V)if(fe.map.get(x)!==Y)return!1;return!0}}}}var _r=Symbol("hyper-morph-duplicate-key"),zr=[e=>e.getAttribute("data-id"),e=>e.getAttribute("id")];function Lo(e,o){return o.map(t=>{let n=new Map;for(let s of e){if(s.nodeType!==1)continue;let h=t(s);h==null||h===""||n.set(h,n.has(h)?_r:s)}return n})}function $r(e,o,t,n){for(let s=0;s<n.length;s++){let h=n[s](e);if(h==null||h===""||o[s].get(h)!==e)continue;let l=t[s].get(h);if(!(!l||l===_r)&&l.tagName===e.tagName)return l}return null}function bo(e,o,t){for(let n=0;n<t.length;n++){let s=t[n](e);if(!(s==null||s==="")&&o[n].get(s)===e)return!0}return!1}function Gr(e,o,t={}){let n=t.skip||(()=>!1),s=t.ignoreAttr||(()=>!1),h=t.tiers&&t.tiers.length?t.tiers:zr,l=null;function r(){return l||(l=Lo([e,...e.querySelectorAll("*")],h)),l}let i=null;function u(){return i||(i=Lo([o,...o.querySelectorAll("*")],h)),i}function w(M){return!M.parentElement||!M.parentElement.parentElement}function c(M,R,V){return w(M)||bo(M,r(),h)?(V.push({type:"subtree",el:M,base:R}),!1):!0}function p(M,R){let V=[];for(let D of M.attributes)s(M,D.name)||R.getAttribute(D.name)!==D.value&&V.push(D.name);for(let D of R.attributes)s(M,D.name)||M.hasAttribute(D.name)||V.push(D.name);return V}function b(M){let R=[],V=null,D=()=>{V!==null&&(R.push({nodeType:3,nodeValue:V}),V=null)};for(let j of M.childNodes){if(j.nodeType===3){V=(V===null?"":V)+j.nodeValue;continue}j.nodeType===1&&n(j)||(D(),(j.nodeType===1||j.nodeType===8)&&R.push(j))}return D(),R}function S(M,R){if(M.nodeType!==R.nodeType)return!1;if(M.nodeType!==1)return!0;if(M.tagName!==R.tagName)return!1;for(let V of h){let D=V(M),j=V(R);if(D!=null&&D!==""&&j!=null&&j!==""&&D!==j)return!1}return!0}function C(M){let R="";for(let V of M)V.nodeType===3&&V.nodeValue.trim()!==""?R+="\0"+V.nodeValue:V.nodeType===8&&(R+=""+V.nodeValue);return R}function m(M,R,V){let D=b(M),j=b(R);if(D.length===j.length){let fe=!0;for(let x=0;x<D.length;x++)if(!S(D[x],j[x])){fe=!1;break}if(fe){for(let x=0;x<D.length;x++){let Y=D[x];if(Y.nodeType===1){if(f(Y,j[x],V))return!0}else if(Y.nodeValue!==j[x].nodeValue)return!0}return!1}}let y=D.filter(fe=>fe.nodeType===1),k=j.filter(fe=>fe.nodeType===1);if(C(D)!==C(j))return!0;let J=Lo(y,h),H=Lo(k,h),q=[],Me=new Set,Oe=[];for(let fe of y){let x=$r(fe,J,H,h);x&&!Me.has(x)?(q.push([fe,x]),Me.add(x)):Oe.push(fe)}let Re=[];for(let fe of Oe)bo(fe,J,h)?V.push({type:"subtree",el:fe,base:null}):Re.push(fe);let ie=[];for(let fe of k)Me.has(fe)||(bo(fe,H,h)?V.push({type:"deletion",el:fe}):ie.push(fe));if(Re.length!==ie.length)return!0;for(let fe=0;fe<Re.length;fe++)if(!S(Re[fe],ie[fe]))return!0;let xe=new Map(q);for(let fe=0;fe<Re.length;fe++)xe.set(Re[fe],ie[fe]);let qe=-1;for(let fe of y){let x=xe.get(fe);if(!x)continue;let Y=k.indexOf(x);if(Y<qe)return!0;qe=Y}for(let fe=0;fe<Re.length;fe++)if(f(Re[fe],ie[fe],V))return!0;for(let[fe,x]of q)if(f(fe,x,V))return!0;return!1}function f(M,R,V){if(M.tagName!==R.tagName)return c(M,R,V);let D=p(M,R),j=[];if(m(M,R,j))return c(M,R,V);if(D.length){if(!w(M)&&!bo(R,u(),h))return!0;V.push({type:"attrs",el:M,names:D,base:R})}return V.push(...j),!1}let g=[],I=p(e,o);I.length&&g.push({type:"attrs",el:e,names:I});let v=(M,R)=>Array.from(M.children).find(V=>V.tagName===R)||null,T=v(e,"HEAD"),A=v(o,"HEAD");if(T&&A){let M=[];f(T,A,M),M.length&&g.push({type:"head",el:T})}else(T||A)&&T&&g.push({type:"head",el:T});let E=v(e,"BODY"),N=v(o,"BODY");return E&&N?f(E,N,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,h=[],l=0,r=f=>({ok:!1,placed:h,held:f,skippedAttrs:l});if(!s)return r(null);function i(f){let g=[f,...f.querySelectorAll("*")];return Lo(g,n)}let u=i(s),w=new Map,c=f=>{let g=f.getRootNode(),I=w.get(g);if(!I){let v=g.nodeType===9?g.documentElement:g;I=i(v),w.set(g,I)}return I};function p(f){if(!f.parentElement&&f.tagName==="HTML")return s;if(f.parentElement&&!f.parentElement.parentElement&&f.parentElement.tagName==="HTML"){if(f.tagName==="BODY")return e.body||null;if(f.tagName==="HEAD")return e.head||null}return null}function b(f){let g=p(f);return g||$r(f,c(f),u,n)}function S(f){if(!f)return null;let g=b(f);return g&&g.isConnected?g:null}function C(f){for(let g=0;g<n.length;g++){let I=n[g](f);I!=null&&I!==""&&u[g].set(I,f)}}for(let f of o){if(f.type!=="deletion")continue;let g=b(f.el);g&&g!==s&&g.remove()}let m=o.filter(f=>f.type!=="deletion").sort((f,g)=>f.el===g.el?0:f.el.compareDocumentPosition(g.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1);for(let f of m){if(f.type==="head"){let N=e.importNode(f.el,!0);e.head?e.head.replaceWith(N):s.insertBefore(N,s.firstChild),h.push({entry:f,imported:N});continue}if(f.type==="attrs"){let N=S(f.el)||S(f.base);if(!N){l++;continue}for(let M of f.names)f.el.hasAttribute(M)?N.setAttribute(M,f.el.getAttribute(M)):N.removeAttribute(M);continue}let g=f.el;if(p(g))return r(f);let I=S(g)||S(f.base);if(I){let N=e.importNode(g,!0);I.replaceWith(N),C(N),h.push({entry:f,imported:N});continue}if(f.base!=null&&!bo(f.base,c(f.base),n)||!bo(g,c(g),n))return r(f);let v=g.parentElement;if(!v)return r(f);let T=S(v);if(!T)return r(f);let A=null;for(let N=g.previousElementSibling;N;N=N.previousElementSibling){let M=S(N);if(M&&M.parentNode===T){A=M;break}}let E=e.importNode(g,!0);if(A)T.insertBefore(E,A.nextSibling);else{let N=Array.prototype.indexOf.call(v.children,g);T.insertBefore(E,T.children[N]||null)}C(E),h.push({entry:f,imported:E})}return{ok:!0,placed:h,held:null,skippedAttrs:l}}var Nl='[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"]',Al='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Ml='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Ol(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 Il(e,o,t,n){if(o==null)return;if(typeof o=="string")return o;let s=o;if(s.nodeType===9){let h=e.getAttribute("id");s=h&&s.getElementById(h)||(e.tagName==="BODY"?s.body:e.tagName==="HTML"?s.documentElement:s.body&&s.body.firstElementChild)}if((!s||s.nodeType!==1||s.tagName!==e.tagName)&&(s=Cl(e,o,n)),!!s)return t?Array.from(s.childNodes):s}function Cl(e,o,t){let n=o.nodeType===9?o.documentElement:o;if(!n||n.nodeType!==1)return null;let s=new Map,h=[n,...n.querySelectorAll("script")];for(let i of h){let u=ho(i,t);u&&!s.has(u.key)&&s.set(u.key,i.textContent)}if(!s.size)return null;let l=e.cloneNode(!0),r=!1;for(let i of[l,...l.querySelectorAll("script")]){let u=ho(i,t);u&&s.has(u.key)&&(i.textContent=s.get(u.key),r=!0)}return r?l:null}function Xr(e,o){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=o.implementation.createHTMLDocument(""),n=e.nodeType===1&&e.tagName==="HTML"?e:null;if(n)return t.replaceChild(t.adoptNode(n),t.documentElement),t;let s=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let h of s)t.body.appendChild(t.adoptNode(h));return t}function Zo(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:(i,u)=>Ol(i)||(n==="history"?!(u&&i.matches(Ml))&&i.matches(Al):i.matches(Nl)),h=t.callbacks||{},l={ignore:s,hooks:h,protectFocusedValue:t.ignoreActiveValue===!0?"subtree":!1,restoreFocus:t.restoreFocus!==!1,formState:t.formStateSync||"attribute",scripts:{execute:t.scripts?.handle!==!1,merge:t.scripts?.merge!==!1,mergeTags:t.scripts?.mergeTags||[]},head:{awaitLoads:!!t.head?.block,preserve:t.head?.shouldPreserve||(()=>!1)}};if(typeof t.key=="function"&&(l.identity={base:t.key,local:t.key,remote:t.key}),e&&e.nodeType===9)return wo(Object.assign({},l,{live:e,base:t.scripts?.mergeBase||null,remote:Xr(o,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let i=Object.assign({},l,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Xr(o,e.ownerDocument)});return wo(i)}t.morphStyle==="innerHTML"&&(l.children=!0);let r=Il(e,t.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return r!==void 0&&(l.base=r),es(e,o,l)}var Ll=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),On=()=>{};function Eo(e,o=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let r of Object.keys(e))if(!Ll.has(r))throw new TypeError(`unknown option "${r}"`);let t=Object.assign({beforeNodeAdded:On,afterNodeAdded:On,beforeNodeRemoved:On,afterNodeRemoved:On,beforeNodeMorphed:On,afterNodeMorphed:On,beforeAttributeUpdated:On},e.hooks||{}),n=e.conflicts||"remote";if(!["remote","local","both"].includes(n))throw new TypeError("conflicts must be remote, local or both");let s=e.formState||"attribute";if(!["attribute","property"].includes(s))throw new TypeError("formState must be attribute or property");let h=e.protectFocusedValue;if(h!==void 0&&typeof h!="boolean"&&h!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");let l=e.lineage;if(l!==void 0&&(!l||typeof l!="object"||typeof l.onResult!="function"||!l.elements||typeof l.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:rs(e.ignore,o),remoteWins:rs(e.remoteWins,o),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,opaque:typeof e.opaque=="function"?e.opaque:()=>!1,conflicts:n,protectFocusedValue:h===void 0?!0:h,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:s,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:l||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=Do(o,e.map),n=typeof e.then=="function"?e.then:kn;if(typeof e.first=="function"){let s=e.first;return h=>s(h)||t.get(h)||n(h)}return s=>t.get(s)||n(s)}return kn}function ni(e,o,t,n={}){let s=b=>b&&b.nodeType===9?b.documentElement:b,h=s(o),l=s(t),r=s(e)||h;if(n.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let i=Object.assign({},n);delete i.live,delete i.base,delete i.remote;let u=Eo(i,[r,h,l].filter(Boolean)),w=n.identity||{},c=$n(),p=Qo(r,h,l,{identity:{base:ko(w.base,r),local:ko(w.local,h),remote:ko(w.remote,l)},authored:{base:yo(w.base),local:yo(w.local),remote:yo(w.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:h.ownerDocument&&h.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===o,childrenOnly:u.children,stats:c});return delete p.recoveryLinks,delete p.lineage,p}function js({liveRoot:e,baseRoot:o,localRoot:t,remoteRoot:n,toLive:s,options:h,identity:l,childrenOnly:r,isDocument:i}){let u=Eo(h,[e,o,t,n].filter(Boolean));if(u.ignored(e)){let y=Ds(),k=u.lineage?Ao(u.lineage,e,y):null;return{report:y,loads:[],lineage:k}}let w=e.ownerDocument,c=u.lineage?Ss(u.lineage,{liveRoot:e,localRoot:t,toLive:s}):null,p=u.scripts.execute?br(e,u.ignored,w.baseURI):null,b=$n(),S=u.hooks.beforeNodeMorphed===On&&u.hooks.afterNodeMorphed===On,C={identity:{base:ko(l.base,o||t),local:ko(l.local,t),remote:ko(l.remote,n)},authored:{base:yo(l.base),local:yo(l.local),remote:yo(l.remote)},ignored:u.ignored,remoteWins:u.remoteWins,ignoreAttribute:u.ignoreAttribute,conflicts:u.conflicts,mergeTags:u.scripts.merge===!1?null:u.scripts.mergeTags,baseURI:w.baseURI,localIsBase:!o,childrenOnly:r,skipUnchanged:S,lineage:c?{locals:c.locals}:null},m=u.fastPath&&i&&!r&&S&&o===t,f=null,g=null;if(m){let y=Fr({baseRoot:o,remoteRoot:n,liveRoot:e,toLive:s,o:u,identity:C.identity,baseURI:w.baseURI});C.comparisons=y.comparisons||y.scope,y.bail?g=y.bail:(f=Qo(o,t,n,Object.assign({},C,{stats:b,scope:y.scope})),f||(g="chain-unpaired",b=$n()))}f||(f=Qo(o||t,t,n,Object.assign({},C,{stats:b}))),m&&(b.fastPathAttempted=1,b.fastPathTaken=g?0:1,b.fastPathFallback=g),f.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(y=>u.hooks[y]!==On)&&Ar(f.conflicts,f.recoveryLinks,s),u.beforeApply&&u.beforeApply(f.doc);let I=globalThis.__hyperMorphProfile,v=I?performance.now():0,T=Wr(e,f.root,f,{toLive:s,localRoot:t,ignored:u.ignored,ignoreAttribute:u.ignoreAttribute,opaque:u.opaque,formState:u.formState,protectFocusedValue:u.protectFocusedValue,restoreFocus:u.restoreFocus,preserve:u.head.preserve,hooks:u.hooks,childrenOnly:r,keepLiveOnly:u.keepLiveOnly,trackInserted:!!c});I&&(I.apply=(I.apply||0)+(performance.now()-v));let A=[];if(u.head.awaitLoads)for(let y of T.applied){if(y.kind!=="insert"||y.node.nodeType!==1)continue;let k=y.node;k.tagName==="LINK"&&/\bstylesheet\b/i.test(k.getAttribute("rel")||"")&&k.getAttribute("href")&&k.closest("head")&&A.push(new Promise(H=>{k.addEventListener("load",()=>H()),k.addEventListener("error",()=>H())}))}let E=null,N=null;if(p){let y=wr(e,p,{ignored:u.ignored,skip:T.mergedScriptsLive,baseURI:w.baseURI,beforeNodeAdded:u.hooks.beforeNodeAdded,afterNodeAdded:u.hooks.afterNodeAdded,trackRecovery:!!f.recoveryLinks});A.push(...y.loads),E=y.swapped,N=y.vetoed}let M=y=>E&&E.get(y)||y,R=y=>{if(T.keptRuns.has(y))return T.runOf.get(y);let k=T.liveOf.get(y)||T.heldBy.get(y)||T.insertedLive.get(y);return k?M(k):null},V=y=>{let k=y&&T.liveOf.get(y);return k?M(k):null},D=y=>{let k=y&&R(y);return Array.isArray(k)?k[0]:k};if(f.recoveryLinks){let y=(k,J,H)=>(J.namespaceURI?k.getAttributeNS(J.namespaceURI,J.localName):k.getAttribute(J.qualifiedName))===H;Ir(f.conflicts,f.recoveryLinks,{lookup:R,vetoed:T.vetoed,vetoedAttrs:T.vetoedAttrs,removedVetoes:T.removedVetoes,vetoedLive:N,liveAttr:y,ignored:u.ignored,liveRoot:e})}let j={applied:T.applied,decisions:f.decisions.map(y=>Object.assign({},y,{node:y.node?V(y.node):null,el:y.el?V(y.el):null,applied:!!(y.node?V(y.node):y.el&&V(y.el))})),conflicts:f.conflicts.map(y=>Object.assign({},y,{node:y.node?y.kind==="text"&&y.recovery.subject.nodeType===8?D(y.node):V(y.node):y.node,el:y.el?y.kind==="structure"?D(y.el):V(y.el):y.el})),localDiverged:f.localDiverged,identities:T.identities,moved:T.moved,replaced:T.replaced,stats:b};return c&&(j.lineage=c.finish(f.lineage,R)),{report:j,loads:A,lineage:c}}var Qr=new WeakMap;function Ds(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:$n()}}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=jo(t),Qr.set(t,n));let s=n("remote",o.remote),h=typeof o.base=="string"&&o.base===""?null:o.base,l=h?n("base",h):null,r=o.local?o.local.root:t.documentElement,i=o.local?o.local.toLive:p=>p;Vs(t,s);let{report:u,loads:w,lineage:c}=js({liveRoot:t.documentElement,baseRoot:l?l.documentElement:null,localRoot:r,remoteRoot:s.documentElement,toLive:i,options:o,identity:o.identity||{},childrenOnly:!1,isDocument:!0});return c?.deliver(u),Promise.all(w).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 h=Bo(e,o),l=n[1].toLowerCase()==="html"?h.documentElement:h.body;return{root:l,first:l}}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 es(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,...h}=t,l=!!h.children,r=Eo(h,[e]);if(r.ignored(e)){let C=Ds();return r.lineage&&Ao(r.lineage,e,C).deliver(C),Promise.resolve(C)}let i=ei(o,n),u=s!=null?ei(s,n):null,w,c=null;if(l)w=i.root,c=u?u.root:null;else{if(w=i.first,c=u?u.first:null,!w){let C=Eo(h),m=C.lineage?Ao(C.lineage,e,{}):null;C.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),C.hooks.afterNodeRemoved(e));let f={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:$n()};return m&&(f.lineage=m.result,m.deliver(f)),Promise.resolve(f)}if(w.tagName!==e.tagName){let C=Eo(h,[e,w]);if(C.hooks.beforeNodeMorphed(e,w)===!1){let g=Ds();return C.lineage&&Ao(C.lineage,e,g).deliver(g),Promise.resolve(g)}let m=js({liveRoot:e,baseRoot:c&&c.tagName===e.tagName?c:null,localRoot:e,remoteRoot:w,toLive:g=>g,options:h,identity:h.identity||{},childrenOnly:!0,isDocument:!1}),f=pn(w)?Mo(w,n):n.importNode(w,!1);if(!pn(f))for(;e.firstChild;)f.appendChild(e.firstChild);return C.hooks.beforeNodeAdded(f)===!1?(Jo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):C.hooks.beforeNodeRemoved(e)===!1?(Jo(m.report.conflicts,e,e),m.lineage&&(m.report.lineage=m.lineage.recheck(),m.lineage.deliver(m.report)),Promise.resolve(m.report)):(e.replaceWith(f),Jo(m.report.conflicts,e,f),C.hooks.afterNodeRemoved(e),C.hooks.afterNodeAdded(f),C.hooks.afterNodeMorphed(e,w),m.report.replaced.push(f),m.report.applied.push({kind:"insert",node:f,parent:f.parentNode},{kind:"remove",node:e,parent:f.parentNode}),m.lineage&&(m.report.lineage=m.lineage.remapRoot(e,f),m.lineage.deliver(m.report)),Promise.all(m.loads).then(()=>m.report))}}let{report:p,loads:b,lineage:S}=js({liveRoot:e,baseRoot:c,localRoot:e,remoteRoot:w,toLive:C=>C,options:h,identity:h.identity||{},childrenOnly:l,isDocument:!1});return S?.deliver(p),Promise.all(b).then(()=>p)}var El={mergeDocument:wo,morphDocument:oi,morphElement:es,merge3:ni,morph:Zo};return fi(Rl);})();
|
|
5
7
|
|
|
6
8
|
var morph = HyperMorph.morph;
|
|
7
9
|
|