hyper-html-api 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +18 -5
  2. package/conformance/MANIFEST.json +2 -2
  3. package/conformance/cases/write-query-attribute.after.html +1 -0
  4. package/conformance/cases/write-query-attribute.after.json +3 -0
  5. package/conformance/cases/write-query-attribute.data.json +1 -0
  6. package/conformance/cases/write-query-attribute.html +1 -0
  7. package/conformance/cases/write-query-attribute.meta +4 -0
  8. package/conformance/cases/write-query-attribute.parsed.json +3 -0
  9. package/conformance/cases/write-query-attribute.rules +1 -0
  10. package/conformance/cases/write-query-attribute.write.json +4 -0
  11. package/conformance/cases/write-query-list.after.html +1 -0
  12. package/conformance/cases/write-query-list.after.json +10 -0
  13. package/conformance/cases/write-query-list.data.json +1 -0
  14. package/conformance/cases/write-query-list.html +1 -0
  15. package/conformance/cases/write-query-list.meta +6 -0
  16. package/conformance/cases/write-query-list.parsed.json +8 -0
  17. package/conformance/cases/write-query-list.rules +1 -0
  18. package/conformance/cases/write-query-list.write.json +4 -0
  19. package/conformance/cases/write-query-noop.after.html +1 -0
  20. package/conformance/cases/write-query-noop.after.json +3 -0
  21. package/conformance/cases/write-query-noop.data.json +1 -0
  22. package/conformance/cases/write-query-noop.html +1 -0
  23. package/conformance/cases/write-query-noop.meta +4 -0
  24. package/conformance/cases/write-query-noop.parsed.json +3 -0
  25. package/conformance/cases/write-query-noop.rules +1 -0
  26. package/conformance/cases/write-query-noop.write.json +4 -0
  27. package/conformance/cases/write-query-override.after.html +1 -0
  28. package/conformance/cases/write-query-override.after.json +3 -0
  29. package/conformance/cases/write-query-override.data.json +1 -0
  30. package/conformance/cases/write-query-override.html +1 -0
  31. package/conformance/cases/write-query-override.meta +4 -0
  32. package/conformance/cases/write-query-override.parsed.json +3 -0
  33. package/conformance/cases/write-query-override.rules +1 -0
  34. package/conformance/cases/write-query-override.write.json +4 -0
  35. package/conformance/cases/write-query-refused.data.json +1 -0
  36. package/conformance/cases/write-query-refused.error.json +11 -0
  37. package/conformance/cases/write-query-refused.html +1 -0
  38. package/conformance/cases/write-query-refused.meta +4 -0
  39. package/conformance/cases/write-query-refused.parsed.json +4 -0
  40. package/conformance/cases/write-query-refused.rules +1 -0
  41. package/conformance/cases/write-query-text.after.html +1 -0
  42. package/conformance/cases/write-query-text.after.json +3 -0
  43. package/conformance/cases/write-query-text.data.json +1 -0
  44. package/conformance/cases/write-query-text.html +1 -0
  45. package/conformance/cases/write-query-text.meta +4 -0
  46. package/conformance/cases/write-query-text.parsed.json +3 -0
  47. package/conformance/cases/write-query-text.rules +1 -0
  48. package/conformance/cases/write-query-text.write.json +4 -0
  49. package/dist/hyper-html-api.engine.min.js +1 -1
  50. package/dist/hyper-html-api.min.js +6 -6
  51. package/dist/hyper-html-api.upgrade.min.js +2 -2
  52. package/package.json +2 -2
  53. package/src/dom-api.js +149 -23
  54. package/src/lib/content-dom.js +3 -3
  55. package/src/write.js +20 -10
@@ -1,6 +1,6 @@
1
- var HyperHtmlApi=(()=>{var ir=Object.defineProperty;var Ii=Object.getOwnPropertyDescriptor;var Ci=Object.getOwnPropertyNames;var Li=Object.prototype.hasOwnProperty;var cr=(e,t)=>{for(var n in t)ir(e,n,{get:t[n],enumerable:!0})},Ri=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ci(t))!Li.call(e,r)&&r!==n&&ir(e,r,{get:()=>t[r],enumerable:!(o=Ii(t,r))||o.enumerable});return e};var Pi=e=>Ri(ir({},"__esModule",{value:!0}),e);var El={};cr(El,{applyData:()=>us,cms:()=>Mi,default:()=>Ml,engine:()=>Bo,extractData:()=>fs,upgrade:()=>Ei});var $o={};cr($o,{fromString:()=>Wo,getRuleAtPath:()=>lr,getValueAtPath:()=>ko,parseConfigKey:()=>Di,setAtPath:()=>Pn,toConfigKey:()=>ji,toString:()=>hn});function hn(e){return e.map(String).join(".")}function ji(e){return e.map(t=>typeof t=="number"?"*":String(t)).join(".")}function Di(e){return e===""?[]:e.split(".")}function Wo(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function lr(e,t){let n=e;for(let o of t){if(n==null||typeof n=="string")return;if(Array.isArray(n)){if(typeof o!="number"&&o!=="*")return;n=n[1];continue}if(typeof n=="object"){if(typeof o=="number"||!(o in n))return;n=n[o];continue}return}return n}function ko(e,t){let n=e;for(let o of t){if(n==null)return;n=n[o]}return n}function Pn(e,t,n){if(t.length===0)return n;let[o,...r]=t;if(typeof o=="number"){let i=Array.isArray(e)?[...e]:[];return i[o]=Pn(i[o],r,n),i}return{...e&&typeof e=="object"?e:{},[o]:Pn((e||{})[o],r,n)}}function eo(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let t={};for(let[n,o]of Object.entries(e))t[n]=eo(o);return t}return""}var qo=new WeakMap;function Mn(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let i=e[r];i==="\\"?r++:n?i===n&&(n=null):i==='"'||i==="'"?n=i:i==="["||i==="("?t++:i==="]"||i===")"?t>0&&t--:i==="@"&&t===0&&(o=r)}return o}function to(e){let t=Mn(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}var Hi=new Set(["checked","selected","disabled","readOnly","paused"]);function ar({rules:e,data:t,appRoot:n,cmsRoot:o}){let r=document.createDocumentFragment(),i={rules:e,appRoot:n,cmsRoot:o};return r.appendChild(ur({rule:e,value:t,path:[],ctx:i})),r}function fr(e,{rules:t,getData:n,onChange:o}){e.setAttribute("data-hha-form-root",""),hs.set(e,{rules:t,getData:n,onChange:o}),Bi()}var hs=new WeakMap,ds=!1;function Bi(){ds||(document.addEventListener("input",ps,!0),document.addEventListener("change",ps,!0),document.addEventListener("click",Ui,!0),ds=!0)}function ms(e){if(!(e instanceof Element))return null;let t=e.closest("[data-hha-form-root]");return t&&hs.get(t)||null}function Ui(e){if(!(e.target instanceof Element))return;let t=e.target.closest("[data-hha-action]");if(!t||e.defaultPrevented)return;let n=ms(t);if(!n)return;let{rules:o,getData:r,onChange:i}=n,c=t.getAttribute("data-hha-action"),s=Wo(t.getAttribute("data-hha-path")||"");if(c==="scalar-array-add"){let a=ko(r(),s)||[];i(Pn(r(),s,[...a,""]),{structural:!0});return}if(c==="object-array-add"){let a=lr(o,s);if(!Array.isArray(a))return;let m=ko(r(),s)||[];i(Pn(r(),s,[...m,eo(a[1])]),{structural:!0});return}if(c==="array-remove"){if(s.length===0)return;let a=s.slice(0,-1),m=s[s.length-1],h=ko(r(),a)||[];if(typeof m!="number")return;let d=h.filter((b,A)=>A!==m);i(Pn(r(),a,d),{structural:!0})}}function ps(e){let t=e.target;if(!t?.matches?.("input, textarea, select"))return;let n=ms(t);if(!n)return;let{getData:o,onChange:r}=n,i=t.closest("[data-hha-path]");if(!i)return;let c=Wo(i.getAttribute("data-hha-path")||""),s=t.type==="checkbox"?t.checked:t.value;r(Pn(o(),c,s),{structural:!1})}function ur({rule:e,value:t,path:n,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?Wi({rule:e,value:t,path:n,ctx:o}):Vi({rule:e,value:t,path:n,ctx:o});if(Array.isArray(e))return $i({rule:e,value:t,path:n,ctx:o});if(typeof e=="object"&&e!==null)return _i({rule:e,value:t,path:n,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function _i({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",hn(n)),n.length>0){let i=document.createElement("div");i.className="form-section-label",i.textContent=Fo(n[n.length-1]),r.appendChild(i)}for(let[i,c]of Object.entries(e)){let s=[...n,i],a=t?.[i];r.appendChild(ur({rule:c,value:a,path:s,ctx:o}))}return r}function Vi({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",hn(n));let i=document.createElement("div");i.className="field-body";let c=document.createElement("label");c.className="field-label",c.textContent=Fo(n[n.length-1]||".")+Gi(e);let s=Fi(e,o.appRoot),a=qi(s,{value:t,rule:e,path:n,appRoot:o.appRoot}),m=a.el;return m.classList.add(s.type==="textarea"?"field-textarea":"field-input"),i.appendChild(c),i.appendChild(m),r.appendChild(i),qo.set(r,a),r}function Wi({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",hn(n));let i=document.createElement("div");i.className="form-section-label",i.textContent=Fo(n[n.length-1]),r.appendChild(i);let c=Array.isArray(t)?t:[],s=document.createElement("div");r.appendChild(s),c.forEach((m,h)=>{let d=[...n,h],b=document.createElement("div");b.className="scalar-array-row",b.setAttribute("data-hha-path",hn(d));let A=document.createElement("input");A.type="text",A.className="field-input",A.value=m==null?"":String(m);let S=document.createElement("button");S.type="button",S.className="array-remove",S.textContent="\xD7",S.title="remove",S.setAttribute("data-hha-action","array-remove"),S.setAttribute("data-hha-path",hn(d)),b.appendChild(A),b.appendChild(S),s.appendChild(b)});let a=document.createElement("button");return a.type="button",a.className="array-add",a.textContent="+ add",a.setAttribute("data-hha-action","scalar-array-add"),a.setAttribute("data-hha-path",hn(n)),r.appendChild(a),r}function $i({rule:e,value:t,path:n,ctx:o}){let[,r]=e,i=Array.isArray(t)?t:[],c=document.createElement("div");c.className="form-section",c.setAttribute("data-hha-path",hn(n));let s=document.createElement("div");s.className="form-section-label",s.textContent=Fo(n[n.length-1]),c.appendChild(s),i.forEach((m,h)=>{let d=[...n,h],b=document.createElement("div");b.className="array-card",b.setAttribute("data-hha-path",hn(d));let A=document.createElement("button");A.type="button",A.className="array-remove",A.textContent="\xD7",A.title="remove item",A.setAttribute("data-hha-action","array-remove"),A.setAttribute("data-hha-path",hn(d)),b.appendChild(A);let S=ur({rule:r,value:m,path:d,ctx:o});S.querySelector(".form-section-label")?.remove(),b.appendChild(S),c.appendChild(b)});let a=document.createElement("button");return a.type="button",a.className="array-add",a.textContent="+ add",a.setAttribute("data-hha-action","object-array-add"),a.setAttribute("data-hha-path",hn(n)),c.appendChild(a),c}function qi(e,t){let n=zi(e);if(e.type==="select"&&e.options)for(let o of e.options){let r=document.createElement("option");r.value=o.value,r.textContent=o.text,String(t.value)===o.value&&(r.selected=!0),n.appendChild(r)}else e.type==="checkbox"?n.checked=t.value===!0||t.value==="true"||t.value==="checked":(e.type,n.value=t.value==null?"":String(t.value));return{el:n,destroy(){},focus(){n.focus()},validate(){}}}function Fi(e,t){let n=null;if(e.startsWith("@")?n=e.slice(1):n=to(e).prop,n&&Hi.has(n))return{type:"checkbox"};if(n==="innerHTML")return{type:"textarea"};let o=Ki(e,t);if(!o)return{type:"text"};let r=(o.tagName||"").toLowerCase();if(r==="textarea")return{type:"textarea"};if(r==="select")return{type:"select",options:Array.from(o.querySelectorAll("option")).map(s=>({value:s.getAttribute("value")||s.textContent,text:s.textContent.trim()||s.getAttribute("value")||""}))};if(r==="input"){let c=(o.getAttribute("type")||"text").toLowerCase();if(c==="checkbox"||c==="radio")return{type:"checkbox"};if(c==="number")return{type:"number"}}let i=(o.textContent||"").trim();return i.length>60||i.includes(`
2
- `)?{type:"textarea"}:{type:"text"}}function Ki(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=to(e).selector;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function zi(e){if(e.type==="textarea")return document.createElement("textarea");if(e.type==="select")return document.createElement("select");let t=document.createElement("input");return t.type=e.type==="checkbox"?"checkbox":e.type==="number"?"number":"text",t}function Fo(e){return typeof e=="number"?`#${e+1}`:String(e).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^\w/,t=>t.toUpperCase())}function Gi(e){return` \xB7 ${e}`}function Ko(e,t){if(typeof e=="string"){let n=t&&t.defaultView,o=n&&n.DOMParser||globalThis.DOMParser;return new o().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function dr(e){let t=new Map;return(n,o)=>{if(typeof o!="string")return Ko(o,e);let r=t.get(n);if(r&&r.text===o)return r.doc;let i=Ko(o,e);return t.set(n,{text:o,doc:i}),i}}function gs(e,t){let n=t.doctype;if(!n)return!1;let o=e.doctype;if(o&&o.name===n.name&&o.publicId===n.publicId&&o.systemId===n.systemId)return!1;let r=e.implementation.createDocumentType(n.name,n.publicId,n.systemId);return o?e.replaceChild(r,o):e.insertBefore(r,e.documentElement),!0}var pr=()=>!1;function hr(e,t=[]){if(typeof e!="function")return pr;let n=new WeakMap,o=new Set(t);return r=>{if(!r||r.nodeType!==1)return!1;let i=n.get(r);if(i!==void 0)return i;let c=[],s=r,a=!1;for(;s&&s.nodeType===1;){let m=n.get(s);if(m!==void 0){a=m;break}if(c.push(s),e(s,o.has(s))){a=!0;break}if(o.has(s))break;s=s.parentElement}for(let m of c)n.set(m,a);return a}}var Vl=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 jn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var Yi="~",bs="^";function mr(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let o=t[Yi],r=typeof o=="string"?o.split(",").map(Number):null,i=r&&typeof t[bs]=="string"?t[bs].split(","):null,c=d=>Number.isInteger(d)&&d>=0,s=0,a=!1,m=d=>{let b=d;for(;b>0;){let A=r[s++];if(s>r.length||!c(A))return!1;b+=A-1}return!0},h=(d,b)=>{if(a)return;if(r){let L=s++,f=r[L];if(L>=r.length||!c(f)){a=!0;return}let g=!i||i[L]===d.tagName.toLowerCase();if(!g||f!==d.children.length){let x=g&&t[b];typeof x=="string"&&x&&n.set(d,x),m(f)||(a=!0);return}}let A=t[b];typeof A=="string"&&A&&n.set(d,A);let S=d.children;for(let L=0;L<S.length;L++)h(S[L],b===""?String(L):`${b}.${L}`)};return h(e,""),n}function ys(e){return t=>{for(let n of e){let o=n(t);if(typeof o=="string"&&o!=="")return o}return null}}var fn=ys([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function zo(e,t,n,o=null){let r=new Map,i=new Set,c=s=>{if(n(s))return;let a=t(s);a&&(r.has(a)?i.add(a):r.set(a,s))};if(o){let s=a=>{for(let m of a.querySelectorAll(o))c(m);for(let m of a.querySelectorAll("template"))m.content&&s(m.content)};c(e),s(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let s=a=>{c(a);let m=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let h=0;h<m.length;h++)s(m[h])};s(e)}for(let s of i)r.delete(s),gr(s);return r}function gr(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var Ji=new Set(["href","src","name","type","role"]),ws=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function no(e,t=5381){let n=t;for(let o=0;o<e.length;o++)n=(n<<5)+n^e.charCodeAt(o);return n>>>0}function ks(e){return e.replace(/\s+/g," ")}var Xi=0;function xs({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let o=new WeakMap,r=new WeakMap;function i(q){let z=q.attributes,ce=z.length;if(ce===0)return{all:"",sig:q.tagName+"|"};let xe=[],te="",J=[];for(let Ce=0;Ce<ce;Ce++){let we=z[Ce],ne=we.name;t(q,ne)||xe.push(ne+"="+we.value),ne==="class"?te=we.value.indexOf(" ")<0?we.value:we.value.split(/\s+/).filter(Boolean).sort().join(" "):Ji.has(ne)&&J.push(ne+"="+we.value)}return xe.length>1&&xe.sort(),J.length>1&&J.sort(),{all:xe.join(""),sig:q.tagName+"|"+te+(J.length?"|"+J.join("|"):"")}}function c(q){return q.nodeType===1&&q.tagName==="TEMPLATE"&&q.content?q.content.childNodes:q.childNodes}function s(q){let z=o.get(q);if(z)return z;if(q.nodeType===3)z={hash:"T"+no(q.nodeValue),hint:ks(q.nodeValue).slice(0,64),sig:null,tok:null};else if(q.nodeType===8)z={hash:"C"+no(q.nodeValue),hint:"",sig:null,tok:null};else if(q.nodeType===1){let ce=i(q),xe=no(q.tagName+""+ce.all),te="";for(let J of m(q))if(J.nodeType===1){let Ce=s(J);xe=no(Ce.hash,xe),te.length<64&&(te+=" "+Ce.hint)}else xe=no(h(J),xe),J.kind==="text"&&te.length<64&&(te+=J.value.slice(0,64));z={hash:"E"+xe,hint:ks(te).trim().slice(0,64),sig:ce.sig,tok:null}}else z={hash:"N"+q.nodeType,hint:"",sig:null,tok:null};return o.set(q,z),z}function a(q){if(!q.tok){q.tok=new Set;for(let z of q.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))z&&q.tok.add(z)}return q.tok}function m(q){let z=r.get(q);if(z)return z;z=[];let ce=null,xe=()=>{ce&&(ce.value=ce.nodes.map(te=>te.nodeValue).join(""),z.push(ce),ce=null)};for(let te of c(q)){if(te.nodeType===3){ce||(ce={kind:"text",nodes:[],value:"",parent:q,hash:void 0}),ce.nodes.push(te);continue}xe(),te.nodeType===8?z.push({kind:"comment",nodes:[te],value:te.nodeValue,parent:q,hash:void 0}):te.nodeType===1&&!e(te)&&z.push(te)}return xe(),r.set(q,z),z}function h(q){return q.nodeType===1?s(q).hash:(q.hash===void 0&&(q.hash=(q.kind==="text"?"T":"C")+no(q.value)),q.hash)}function d(q,z){let ce=a(s(q)),xe=a(s(z));if(ce.size===0&&xe.size===0)return{coef:1,share:1};if(ce.size===0||xe.size===0)return null;let te=0;for(let J of ce)xe.has(J)&&te++;return{coef:te/Math.min(ce.size,xe.size),share:te/Math.max(ce.size,xe.size)}}function b(q,z){let ce=d(q,z);return!!ce&&ce.coef>=.5}let A=new WeakMap;function S(q){let z=A.get(q);if(z)return z;z=[];for(let ce of q.attributes)t(q,ce.name)||z.push([ce.namespaceURI||"",ce.localName,ce.value]);return z.sort((ce,xe)=>ce[0]<xe[0]?-1:ce[0]>xe[0]?1:ce[1]<xe[1]?-1:ce[1]>xe[1]?1:0),A.set(q,z),z}let L=new WeakMap;function f(q,z){if(q===z)return!0;if(h(q)!==h(z))return!1;let ce=L.get(q);if(ce&&ce.has(z))return ce.get(z);let xe=L.get(z);if(xe&&xe.has(q))return xe.get(q);let te=g(q,z),J=te===!0;return te===!1&&n&&n.hashRejected++,ce||L.set(q,ce=new WeakMap),ce.set(z,J),J}function g(q,z){if(q.nodeType===1){if(z.nodeType!==1||q.tagName!==z.tagName||q.namespaceURI!==z.namespaceURI)return!1;let ce=S(q),xe=S(z);if(ce.length!==xe.length)return!1;for(let Ce=0;Ce<ce.length;Ce++)if(ce[Ce][0]!==xe[Ce][0]||ce[Ce][1]!==xe[Ce][1]||ce[Ce][2]!==xe[Ce][2])return!1;let te=m(q),J=m(z);if(te.length!==J.length)return!1;for(let Ce=0;Ce<te.length;Ce++){if(h(te[Ce])!==h(J[Ce]))return!1;if(!f(te[Ce],J[Ce]))return Xi}return!0}return z.nodeType===1?!1:q.kind===z.kind&&q.value===z.value}let x=new WeakMap,Q=new Map,se=0;function le(q){let z=x.get(q);if(z)return z;let ce=h(q),xe=Q.get(ce);xe||Q.set(ce,xe=[]);let te=xe.find(J=>f(J.unit,q));return z=te?te.key:"K"+se++,te||xe.push({unit:q,key:z}),x.set(q,z),z}return{meta:s,unitsOf:m,unitHash:h,similar:b,score:d,childrenOf:c,equalUnits:f,exactUnitKey:le,ignored:e}}var Ts=16,Qi=2e3,Zi=3,br={align:0,certifyVisited:0,certifyScheduled:0};function yr(e,t,n){let{meta:o,unitsOf:r,unitHash:i,similar:c,score:s,childrenOf:a,equalUnits:m,ignored:h}=n.analyzer,d=n.baseId||(()=>null),b=n.sideId||(()=>null),A=n.stats||null,S=A?new Set:null,L=A?new Set:null,f=new Map,g=new Map,x=new Set,Q=new Map,se=new Set,le=new Set,q=new Set,z=[],ce=[],xe=[],te=[],J=Qi,Ce=new Map,we=new Map,ne=(p,k)=>{f.set(p,k),g.set(k,p)},_=new Set,ye=new Set,ge=null,Oe=p=>{let k=p.nodeType?p.parentNode:p.parent;if(!k||k.nodeType!==11)return k;if(!ge){ge=new WeakMap;let R=$=>{for(let H of $.querySelectorAll("template"))H.content&&(ge.set(H.content,H),R(H.content))};for(let $ of[e,t])R($.tagName==="TEMPLATE"&&$.content?$.content:$)}return ge.get(k)||null},Be=(p,k)=>{for(let R=Oe(p);R&&!_.has(R);R=Oe(R))_.add(R);for(let R=Oe(k);R&&!ye.has(R);R=Oe(R))ye.add(R)},We=p=>{for(let k=Oe(p);k;k=Oe(k))if(f.has(k))return le.has(k);return!1},rt=p=>{for(let k=Oe(p);k;k=Oe(k)){let R=g.get(k);if(R!==void 0)return le.has(R)}return!1},re=p=>!!p&&p.nodeType===1,ut=(p,k)=>{let R=Q.get(p);return!!R&&R.has(k)},dt=p=>ws.has(p.tagName),Se=n.comparisons||n.scope,O=(p,k)=>{if(Se){if(Se.same.get(p)===k)return!0;if(Se.differ.get(p)===k)return!1}if(!p.isEqualNode(k))return!1;if(p.tagName==="TEMPLATE")return m(p,k);let R=p.getElementsByTagName("template");if(R.length===0)return!0;let $=k.getElementsByTagName("template");if(R.length!==$.length)return!1;for(let H=0;H<R.length;H++)if(!m(R[H],$[H]))return!1;return!0},B=(p,k)=>{let R=d(p);if(!R)return!0;let $=b(k);return!$||R===$},ae=globalThis.__hyperMorphProfile,be=ae?performance.now():0;ae&&!n.scope&&(o(e),o(t),ae.meta=(ae.meta||0)+(performance.now()-be),be=performance.now()),ne(e,t);let de=new Set;for(let[p,k]of n.baseIndex){let R=n.sideIndex.get(p);R&&R.tagName===k.tagName&&!f.has(k)&&!g.has(R)&&(ne(k,R),Be(k,R),de.add(k))}if(de.size){let p=[];if(n.scope)for(let H of n.scope.chain)de.has(H)&&p.push(H);let k=[n.scope?n.scope.root:e];for(;k.length;){let H=k.pop();de.has(H)&&p.push(H);let F=a(H);for(let N=F.length-1;N>=0;N--)F[N].nodeType===1&&k.push(F[N])}let R=new Set;for(let H=p.length-1;H>=0;H--){let F=p[H];n.scope&&n.scope.onChain.has(F)?R.add(F):Xt(F,f.get(F),R)?(le.add(F),q.add(F),A&&A.certificationPairs++):R.add(F)}let $=new Set;for(let H of p)le.has(H)&&!$.has(H)&&ze(H,$)}n.scope&&n.scope.head&&Bt(n.scope.head[0],n.scope.head[1]);function ze(p,k){let R=[p];for(;R.length;){let $=R.pop();if(!k.has($)){k.add($),M($);for(let H of r($))re(H)&&f.has(H)&&R.push(H)}}}te.push([e,t]);for(let[p,k]of f)re(p)&&p!==e&&te.push([p,k]);return wt(),De(),ae&&(ae.align=(ae.align||0)+(performance.now()-be)),{map:f,reverse:g,moved:se,identical:le,pairIdenticalChildren:M,weak:x,unpair:Qe,rematch:De,insertedByHash:st,refused:L,identityPaired:de};function De(){P(),wt();for(let p=0;p<xe.length;){let k=xe.length;nn(p,k),p=k,wt(),P(),wt()}}function Qe(p){let k=f.get(p);if(!k)return;Q.has(p)||Q.set(p,new Set),Q.get(p).add(k);let R=(H,F)=>{f.delete(H),g.delete(F),se.delete(H),le.delete(H),x.delete(H),q.delete(H)},$=(H,F)=>{for(let N of r(H)){let E=f.get(N);!E||de.has(N)||!(re(E)?F.contains(E):F.contains(E.nodes[0]))||(R(N,E),re(N)&&$(N,E))}};R(p,k),re(p)&&$(p,k),z.push(p),ce.push(k)}function st(){let p=new Map;for(let k of new Set(ce)){if(g.has(k))continue;let R=o(k).hash;p.has(R)||p.set(R,[]),p.get(R).push(k)}return p}function wt(){for(;te.length;){let[p,k]=te.shift();f.get(p)!==k||q.has(p)||le.has(p)||Tt(p,k)}}function bt(p,k){if(!dt(p))for(let R of r(p))re(R)&&(k.push(R),bt(R,k))}function Tt(p,k){q.add(p);let R=r(p),$=r(k);br.align+=R.length+$.length,Ce=new Map,we=new Map;for(let G=0;G<R.length;G++)Ce.set(R[G],G);for(let G=0;G<$.length;G++)we.set($[G],G);if(p.tagName==="HTML")for(let G of["HEAD","BODY"]){let he=R.find(u=>re(u)&&u.tagName===G),ve=$.find(u=>re(u)&&u.tagName===G);he&&ve&&!f.has(he)&&!g.has(ve)&&ne(he,ve)}for(let G=0;G<R.length&&G<$.length;G++){let he=R[G],ve=$[G];f.has(he)||g.has(ve)||(re(he)?re(ve)&&he.tagName===ve.tagName&&O(he,ve)&&Bt(he,ve):!re(ve)&&he.kind===ve.kind&&he.value===ve.value&&Bt(he,ve))}T(R,$);let H=R.filter(G=>!f.has(G)),F=$.filter(G=>!g.has(G));H.length&&F.length&&(Qt(H,F),Z(H,F),ee(H,F,R,$),fe(R,$));let N=!1,E=!1;for(let G of R){if(!f.has(G)){re(G)&&(z.push(G),bt(G,z),N=!0);continue}re(G)&&!le.has(G)&&te.push([G,f.get(G)])}for(let G of $)!g.has(G)&&re(G)&&(ce.push(G),bt(G,ce),E=!0);N&&E&&xe.push([p,k])}function nn(p,k){for(let R=p;R<k;R++){let[$,H]=xe[R];if(f.get($)!==H)continue;let F=r($),N=r(H),E=new Map,G=new Map,he=null;for(let ve of F)re(ve)&&(f.has(ve)?he=ve:(E.has(he)||E.set(he,[]),E.get(he).push(ve)));he=null;for(let ve of N)re(ve)&&(g.has(ve)?he=g.get(ve):(G.has(he)||G.set(he,[]),G.get(he).push(ve)));for(let[ve,u]of E){let v=G.get(ve);if(!(!v||u.length!==v.length)&&u.every((j,U)=>v[U].tagName===j.tagName&&B(j,v[U])&&!ut(j,v[U])))for(let j=0;j<u.length;j++)Fe(u[j],v[j])}}}function Fe(p,k){ne(p,k),x.add(p),te.push([p,k]),wt()}function Qt(p,k){let R=oo(p,i),$=oo(k,i),H=new Map;for(let F of k){let N=i(F);$.get(N)===1&&H.set(N,F)}for(let F of p){if(f.has(F))continue;let N=i(F);if(R.get(N)!==1)continue;let E=H.get(N);E&&!g.has(E)&&m(F,E)&&Bt(F,E)}}function Xt(p,k,R){let $=[[p,k]];for(;$.length;){let[H,F]=$.pop();if(br.certifyVisited++,A&&A.certificationVisited++,H.nodeType!==F.nodeType)return!1;if(H.nodeType===3||H.nodeType===8){if(H.nodeValue!==F.nodeValue)return!1;continue}if(H.nodeType!==1){if(!H.isEqualNode(F))return!1;continue}if(H.tagName!==F.tagName||H.namespaceURI!==F.namespaceURI||h(H)!==h(F))return!1;let N=H.attributes,E=F.attributes;if(N.length!==E.length)return!1;for(let v=0;v<N.length;v++){let j=N[v];if(F.getAttributeNS(j.namespaceURI,j.localName)!==j.value)return!1}let G=f.get(H);if(G!==void 0&&G!==F)return!1;let he=g.get(F);if(he!==void 0&&he!==H)return!1;if(H!==p){if(le.has(H))continue;if(R.has(H))return!1}let ve=a(H),u=a(F);if(ve.length!==u.length)return!1;br.certifyScheduled+=ve.length;for(let v=ve.length-1;v>=0;v--)$.push([ve[v],u[v]])}return!0}function Bt(p,k){if(re(p)&&(_.has(p)||ye.has(k))){let R=Lt(p,k);if(!R){ne(p,k),te.push([p,k]);return}for(let $=0;$<R.length;$+=2){let H=R[$],F=R[$+1],N=f.get(H);N!==void 0&&N!==F&&Et(H,N);let E=g.get(F);E!==void 0&&E!==H&&Et(E,F),f.get(H)===F&&(se.delete(H),x.delete(H),le.add(H),q.add(H))}}sn(p,k)}function Et(p,k){f.delete(p),g.delete(k),se.delete(p),le.delete(p),x.delete(p),q.delete(p)}function Lt(p,k){let R=[p,k,!1],$=[];for(;R.length;){let H=R.pop(),F=R.pop(),N=R.pop(),E=f.get(N),G=g.get(F);if(N!==p&&(E!==void 0&&E!==F&&de.has(N)||G!==void 0&&G!==N&&de.has(G)))return null;if(!(E===F&&le.has(N))&&((E!==void 0||G!==void 0)&&$.push(N,F),!!re(N))){if(H||E!==void 0&&E!==F||G!==void 0&&G!==N){let he=r(N),ve=r(F);for(let u=0;u<he.length&&u<ve.length;u++)R.push(he[u],ve[u],!0)}else if(_.has(N)||ye.has(F)){let he=N.tagName==="TEMPLATE"?N.content:N,ve=F.tagName==="TEMPLATE"?F.content:F;for(let u=he.firstElementChild,v=ve.firstElementChild;u&&v;){if(h(u)){u=u.nextElementSibling;continue}if(h(v)){v=v.nextElementSibling;continue}(f.has(u)||g.has(v)||_.has(u)||ye.has(v))&&R.push(u,v,!1),u=u.nextElementSibling,v=v.nextElementSibling}}}}return $}function sn(p,k){ne(p,k),le.add(p),re(p)&&q.add(p)}function M(p){let k=f.get(p);if(!k||!re(p))return;let R=r(p),$=r(k);for(let H=0;H<R.length&&H<$.length;H++)f.has(R[H])||sn(R[H],$[H])}function Z(p,k){let R=N=>re(N)&&!dt(N)?o(N).sig+""+o(N).hint:null,$=oo(p,R),H=oo(k,R),F=new Map;for(let N of k){let E=R(N);E!=null&&H.get(E)===1&&F.set(E,N)}for(let N of p){if(f.has(N))continue;let E=R(N);if(E==null||$.get(E)!==1)continue;let G=F.get(E);G&&!g.has(G)&&B(N,G)&&ne(N,G)}}function ee(p,k,R,$){let H=new Map;for(let N of k){if(!re(N)||g.has(N)||dt(N))continue;let E=o(N).sig;H.has(E)||H.set(E,[]),H.get(E).push({el:N,index:we.get(N)})}let F=[];for(let N of p){if(f.has(N)||!re(N)||dt(N))continue;let E=H.get(o(N).sig);if(!E||!E.length)continue;let G=Ce.get(N),he=E.filter(ve=>!g.has(ve.el)).map(ve=>({c:ve,d:Math.abs(ve.index-G)}));he.sort((ve,u)=>ve.d-u.d),he.length>Ts&&(he=he.slice(0,Ts));for(let{c:ve,d:u}of he){if(!B(N,ve.el))continue;let v=s(N,ve.el);v&&v.coef>=.5&&F.push({b:N,s:ve.el,coef:v.coef,share:v.share,d:u,bi:G})}}if(F.sort((N,E)=>E.coef-N.coef||E.share-N.share||N.d-E.d||N.bi-E.bi),A&&F.length>1){let N=new Map;for(let E of F){let G=N.get(E.b);G?G.coef===E.coef&&(G.share===E.share?G.strict++:G.loose++):N.set(E.b,{coef:E.coef,share:E.share,strict:0,loose:0})}for(let[E,G]of N)S.has(E)||!(G.strict||G.loose)||(S.add(E),G.strict?A.similarTiesStrict++:A.similarTiesLoose++)}for(let N of F)!f.has(N.b)&&!g.has(N.s)&&ne(N.b,N.s)}function ue(p,k){return re(p)!==re(k)?!1:re(p)?p.tagName!==k.tagName||!B(p,k)?!1:dt(p)||o(p).hint===""||o(k).hint===""?!0:c(p,k):p.kind===k.kind}function oe(p,k){let R=(H,F)=>{let N=F===null?-1:H===k?we.get(F):Ce.get(F),E=H[N+1];return E&&!re(E)?E:null},$=null;for(let H of p){if(re(H)){$=H;continue}if(f.has(H))continue;let F=$===null?null:f.get($);if($!==null&&!F)continue;let N=R(k,F);N&&!g.has(N)&&N.kind===H.kind&&ne(H,N)}}function fe(p,k){oe(p,k);let R=y(p,k),$=(F,N)=>re(F)&&o(F).hint!==""&&o(N).hint===""&&!!N.querySelector("br")&&!R(F,N),H=0;for(let F of p){if(f.has(F)){let E=we.get(f.get(F));E!==void 0&&E>=H&&(H=E+1);continue}let N=0;for(let E=H;E<k.length&&N<Zi;E++){let G=k[E];if(!g.has(G)&&(N++,ue(F,G)&&!ut(F,G)&&!$(F,G))){ne(F,G),re(F)&&(o(F).hint===""||o(G).hint==="")&&x.add(F),H=E+1;break}}}T(p,k)}function y(p,k){let R=($,H,F)=>{for(let N=H-1;N>=0;N--)if(re($[N])&&F($[N]))return $[N];return null};return($,H)=>{let F=Ce.get($),N=we.get(H);if(F===N)return!0;let E=R(p,F,he=>f.has(he)),G=R(k,N,he=>g.has(he));return E?f.get(E)===G:!G}}function T(p,k){let R=p.filter(E=>re(E)&&!f.has(E)),$=k.filter(E=>re(E)&&!g.has(E));if(!R.length||!$.length)return;let H=oo(R,E=>E.tagName),F=oo($,E=>E.tagName),N=y(p,k);for(let E of R){let G=E.tagName;if(H.get(G)!==1||F.get(G)!==1)continue;let he=$.find(ve=>ve.tagName===G);he&&!g.has(he)&&N(E,he)&&B(E,he)&&!ut(E,he)&&(m(E,he)?Bt(E,he):(ne(E,he),x.add(E)))}}function P(){let p=new Map;for(let E of x)if(re(E)&&re(f.get(E))){let G=o(E).hash;p.has(G)||p.set(G,[]),p.get(G).push(E)}if(p.size)for(let E of ce){if(g.has(E)||!re(E)||rt(E))continue;let G=p.get(o(E).hash),he=G&&G.find(ve=>x.has(ve)&&!ut(ve,E)&&B(ve,E)&&m(ve,E));he&&(Qe(he),Bt(he,E),Be(he,E),se.add(he))}let k=new Map,R=new Map,$=new Map;for(let E of x){let G=f.get(E);re(E)&&re(G)&&$.set(G,E)}let H=(E,G)=>{if(!g.has(E))return!rt(E);let he=$.get(E);return he===g.get(E)&&he!==G&&!he.contains(G)},F=E=>{if(g.has(E)){let G=$.get(E);$.delete(E),Qe(G)}};for(let E of[...ce,...$.keys()]){if(g.has(E)&&!$.has(E))continue;let G=o(E).hash;if(k.has(G)||k.set(G,[]),k.get(G).push(E),dt(E))continue;let he=o(E).sig;R.has(he)||R.set(he,[]),R.get(he).push(E)}let N=new Set;for(let E of x){let G=f.get(E);!re(E)||!re(G)||dt(E)||o(E).hint===""||o(G).hint===""||c(E,G)||N.add(E)}for(let E of[...z,...N]){let G=f.get(E);if(G?!(x.has(E)&&N.has(E)):We(E))continue;let he=U=>{G&&Qe(E),F(U)},ve=k.get(o(E).hash);if(ve){let U=ve.find(V=>V!==G&&H(V,E)&&!ut(E,V)&&m(E,V));if(U){he(U),Bt(E,U),Be(E,U),se.add(E);continue}}if(dt(E)||J<=0)continue;let u=R.get(o(E).sig);if(!u)continue;let v=null,j=0;for(let U of u)if(!(U===G||!H(U,E)||!B(E,U)||ut(E,U))&&(J--<=0||c(E,U)&&(j++,v=U,j>1)))break;j>1&&L&&L.add(E),j===1&&(he(v),ne(E,v),Be(E,v),se.add(E),te.push([E,v]))}}}function oo(e,t){let n=new Map;for(let o of e){let r=t(o);r!=null&&n.set(r,(n.get(r)||0)+1)}return n}var ec={diff:0},As=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,tc=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,nc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,oc=/\P{M}\p{M}*/gu;function Sr(e){if(e==="")return[];if(As){let n=[];for(let o of As.segment(e))n.push(o.segment);return n}let t=[];for(let n of e.match(nc))if(tc.test(n))for(let o of n.match(oc))t.push(o);else t.push(n);return t}var rc=/^[  ]+$/,sc=e=>rc.test(e)?" ".repeat(e.length):e,Dn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),gt="",kr=e=>e.every(t=>Dn(t)||t.k===gt),ic=/^[\x00-\x7f\u00A0]*$/,cc=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function lc(e){return e===""?[]:e.match(cc)}function $n(e,t=!1){return(t?lc(e):Sr(e)).map(n=>({k:sc(n),raw:n,len:n.length}))}var Go=(...e)=>e.every(t=>ic.test(t));function wr(e,t,n){let o=e.length,r=t.length,i=Math.min(o+r,n),c=i+1,s=new Int32Array(2*i+3),a=[],m=o===0&&r===0;for(let A=0;A<=i&&!m;A++){a.push(s.slice(c-A,c+A+1));for(let S=-A;S<=A;S+=2){let L;S===-A||S!==A&&s[c+S-1]<s[c+S+1]?L=s[c+S+1]:L=s[c+S-1]+1;let f=L-S,g=L;for(;L<o&&f<r&&e[L].k===t[f].k;)L++,f++;if(ec.diff+=1+L-g,s[c+S]=L,L>=o&&f>=r){m=!0;break}}}if(!m)return null;let h=[],d=o,b=r;for(let A=a.length-1;A>0;A--){let S=a[A],L=d-b,f=L+A,g=L===-A||L!==A&&S[f-1]<S[f+1]?L+1:L-1,x=S[g+A],Q=x-g;for(;d>x&&b>Q;)h.push([0,d-1,b-1]),d--,b--;d===x?(h.push([1,d,b-1]),b--):(h.push([-1,d-1,b]),d--)}for(;d>0&&b>0;)h.push([0,d-1,b-1]),d--,b--;return h.reverse(),h}function ac(e,t,n){let o=d=>d.k===gt;if(!e.some(o)&&!t.some(o))return wr(e,t,n);let r=[],i=[];for(let d=0;d<e.length;d++)o(e[d])||r.push(d);for(let d=0;d<t.length;d++)o(t[d])||i.push(d);let c=wr(r.map(d=>e[d]),i.map(d=>t[d]),n);if(!c)return null;let s=[],a=0,m=0,h=(d,b)=>{for(;a<d&&m<b&&e[a].k===t[m].k;)s.push([0,a++,m++]);let A=wr(e.slice(a,d),t.slice(m,b),n);if(!A)return!1;for(let[S,L,f]of A)s.push([S,L+a,f+m]);return a=d,m=b,!0};for(let[d,b,A]of c)if(d===0){if(!h(r[b],i[A]))return null;s.push([0,a,m]),a++,m++}return h(e.length,t.length)?s:null}function ro(e,t,n=4e3){let o=[],r=0;for(;r<e.length&&r<t.length&&e[r].k===t[r].k;)e[r].raw!==t[r].raw&&o.push({bi:r,tok:t[r]}),r++;let i=0;for(;i<e.length-r&&i<t.length-r&&e[e.length-1-i].k===t[t.length-1-i].k;)e[e.length-1-i].raw!==t[t.length-1-i].raw&&o.push({bi:e.length-1-i,tok:t[t.length-1-i]}),i++;let c=e.slice(r,e.length-i),s=t.slice(r,t.length-i),a=mc(c,s)?null:ac(c,s,n);if(!a){let g=c.length||s.length?[{bs:r,be:r+c.length,toks:s}]:[];return{hunks:g,cosmetic:o,coarse:!0,parts:g.map(x=>({...x,gap:[],group:0})),cosmeticEq:o}}let m=[],h=(g,x)=>{c[g].raw!==s[x].raw&&o.push({bi:r+g,tok:s[x]})},d=null,b=[],A=0,S=0,L=()=>{d&&m.push(d),d=null;for(let[g,x]of b)h(g,x);b=[],A++};for(let[g,x,Q]of a){if(g===0){d&&Dn(c[x])&&!c[x].k.includes(`
3
- `)?b.push([x,Q]):(L(),h(x,Q)),S=x+1;continue}(!d||b.length)&&(d&&m.push(d),d={bs:r+S,be:r+S,toks:[],gap:b.map(([se,le])=>({bi:r+se,tok:s[le]})),group:A},b=[]),g===-1?(d.be=r+S+1,S=x+1):d.toks.push(s[Q])}L(),fc(m,e);let f=Tr(m);return{hunks:f.hunks,cosmetic:o.concat(f.cosmetic),parts:m,cosmeticEq:o}}function fc(e,t){for(let n=0;n<e.length;n++){let o=e[n];if(o.gap.length)continue;let r=n+1<e.length?e[n+1].bs:1/0;if(o.toks.length){if(o.bs===o.be)for(;o.bs+1<r&&o.bs<t.length&&o.toks[0].k===gt&&t[o.bs].k===gt;)o.toks=[...o.toks.slice(1),o.toks[0]],o.bs++,o.be++}else for(;o.be+1<r&&o.be<t.length&&t[o.bs].k===gt&&t[o.be].k===gt;)o.bs++,o.be++}}function Tr(e,t=()=>!1){let n=[],o=[],r=null,i=-1;for(let c of e){let s=t(c);if(r&&!r.alone&&!s&&c.group===i){r.be=c.be;for(let a of c.gap)r.toks.push(a.tok);for(let a of c.toks)r.toks.push(a);continue}r&&n.push({bs:r.bs,be:r.be,toks:r.toks});for(let a of c.gap)o.push(a);r={bs:c.bs,be:c.be,toks:c.toks.slice(),alone:s},i=c.group}return r&&n.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:n,cosmetic:o}}var uc=(e,t)=>e.bs===t.bs&&e.be===t.be&&Or(e.toks,t.toks);function Nr(e,t,n){let o=h=>d=>h.some(b=>uc(d,b)),r=Tr(e.parts,o(t.parts)),i=Tr(t.parts,o(e.parts)),c=e.cosmeticEq.concat(r.cosmetic),s=t.cosmeticEq.concat(i.cosmetic),[a,m]=n?dc(r.hunks,i.hunks,n,c,s):[r.hunks,i.hunks];return{lh:a,rh:m,cosL:c,cosR:s}}function dc(e,t,n,o,r){let i=(S,L)=>S.k===L.k&&S.raw===L.raw,c=[{list:e.map(S=>({...S})),resp:new Set(o.map(S=>S.bi)),raw:new Map(o.map(S=>[S.bi,S.tok]))},{list:t.map(S=>({...S})),resp:new Set(r.map(S=>S.bi)),raw:new Map(r.map(S=>[S.bi,S.tok]))}],s=S=>S.bs===S.be,a=(S,L,f,g)=>{let x=S.list[L];if(!s(x))return g(x)===f?x.toks:null;let Q=L?S.list[L-1].be:0,se=L+1<S.list.length?S.list[L+1].bs:n.length;if(f<Q||f>se)return null;let le=x.toks,q=x.bs;for(;q>f;){let z=le[le.length-1];if(!i(z,n[q-1])||S.resp.has(q-1))return null;le=[z,...le.slice(0,-1)],q--}for(;q<f;){if(!i(le[0],n[q])||S.resp.has(q))return null;le=[...le.slice(1),le[0]],q++}return le},m=(S,L,f,g,x,Q)=>{let se=S.list[L],le=x?f.slice(f.length-g):f.slice(0,g),q=x?f.slice(0,f.length-g):f.slice(g),z={bs:Q,be:Q,toks:le};if(s(se)){if(!q.length){S.list[L]=z;return}let xe={bs:Q,be:Q,toks:q};x&&(xe.lead=!0),S.list.splice(L,1,...x?[xe,z]:[z,xe]);return}let ce={bs:se.bs,be:se.be,toks:q};S.list.splice(L,1,...x?[ce,z]:[z,ce])},h=(S,L,f,g,x)=>{let Q=S.list[L],se=x?f.slice(f.length-g):f.slice(0,g),le=x?f.slice(0,f.length-g):f.slice(g),q={bs:Q.bs,be:Q.be,toks:se};if(!le.length){S.list[L]=q;return}let z=x?{bs:Q.bs,be:Q.bs,toks:le,lead:!0}:{bs:Q.be,be:Q.be,toks:le};S.list.splice(L,1,...x?[z,q]:[q,z])},d=(S,L,f,g)=>{let x=S.list[L],Q=f.list[g],se=x.be,le=Q.bs;if(se>=le||L+1<S.list.length&&S.list[L+1].bs<=Q.be||g>0&&f.list[g-1].be>=x.bs)return!1;for(let ge=se;ge<le;ge++)if(!Dn(n[ge])||n[ge].k.includes(`
4
- `))return!1;let q=ge=>n.slice(se,le).map((Oe,Be)=>ge.raw.get(se+Be)||Oe),z=[...x.toks,...q(S)],ce=[...q(f),...Q.toks],xe=(ge,Oe,Be)=>Oe>=0&&Oe+Be.length<=ge.length&&Be.every((We,rt)=>ge[Oe+rt].k===We.k),te=(ge,Oe,Be)=>kr(ge)&&n.slice(Oe,Be).some(We=>!Dn(We)),J=ge=>ge.some(Oe=>!Dn(Oe)),Ce,we,ne,_;if(s(x)&&J(x.toks)&&xe(ce,0,x.toks)){let ge=ce.slice(x.toks.length);te(ge,se,Q.be)||(Ce=se,we=x.toks,ne=ce.slice(0,x.toks.length),_=[null,{bs:se,be:Q.be,toks:ge}])}if(Ce===void 0&&s(Q)&&J(Q.toks)){let ge=z.length-Q.toks.length,Oe=z.slice(0,ge);xe(z,ge,Q.toks)&&!te(Oe,x.bs,le)&&(Ce=le,we=z.slice(ge),ne=Q.toks,_=[{bs:x.bs,be:le,toks:Oe},null])}if(Ce===void 0)return!1;let ye=ge=>ge&&(ge.bs<ge.be||ge.toks.length);return S.list.splice(L,1,...[_[0],{bs:Ce,be:Ce,toks:we}].filter(ye)),f.list.splice(g,1,...[{bs:Ce,be:Ce,toks:ne},_[1]].filter(ye)),!0},b=c[0],A=c[1];for(let S=0;S<64;S++){let L=!1;e:for(let f=0;f<b.list.length;f++)for(let g=0;g<A.list.length;g++){let x=b.list[f],Q=A.list[g];if(!(x.bs===Q.bs&&x.be===Q.be&&Or(x.toks,Q.toks))){for(let se of[!0,!1]){let le=z=>se?z.be:z.bs,q=s(x)?[le(Q),x.bs]:[le(x)];for(let z of q){let ce=a(b,f,z,le),xe=ce&&a(A,g,z,le);if(!xe)continue;let te=(_,ye)=>se?_[_.length-1-ye]:_[ye],J=0;for(;J<ce.length&&J<xe.length&&te(ce,J).k===te(xe,J).k;)J++;if(!J)continue;let Ce=se?ce.slice(0,ce.length-J):ce.slice(J),we=se?xe.slice(0,xe.length-J):xe.slice(J);if(!(J<ce.length&&J<xe.length&&!kr(Ce)&&!kr(we)&&(s(x)&&s(Q)||x.bs===Q.bs&&x.be===Q.be)||!(se?ce.slice(ce.length-J):ce.slice(0,J)).some(_=>!Dn(_)))){if(J===ce.length&&J===xe.length&&s(x)&&s(Q)){if(x.bs===z&&Q.bs===z)continue;b.list[f]={bs:z,be:z,toks:ce},A.list[g]={bs:z,be:z,toks:xe}}else!s(x)&&x.bs===Q.bs&&x.be===Q.be?(h(b,f,ce,J,se),h(A,g,xe,J,se)):(m(b,f,ce,J,se,z),m(A,g,xe,J,se,z));L=!0;break e}}}if(d(b,f,A,g)||d(A,g,b,f)){L=!0;break e}}}if(!L)break}return[b.list,A.list]}var pc=48,hc=.3;function mc(e,t){let n=e.filter(c=>!Dn(c)),o=t.filter(c=>!Dn(c));if(Math.min(n.length,o.length)<pc)return!1;let r=new Map;for(let c of n)r.set(c.k,(r.get(c.k)||0)+1);let i=0;for(let c of o){let s=r.get(c.k);s>0&&(i++,r.set(c.k,s-1))}return i/Math.min(n.length,o.length)<hc}var gc=(e,t)=>{let n=new Set;for(let o of e.toks)typeof o.k!="string"&&n.add(o.k.el);for(let o=e.bs;o<e.be;o++)typeof t[o].k!="string"&&n.add(t[o].k.el);return n},Or=(e,t)=>e.length===t.length&&e.every((n,o)=>n.k===t[o].k);function Ss(e,t,n,o="remote"){let r=ro(e,t),i=ro(e,n),{lh:c,rh:s,cosL:a,cosR:m}=Nr(r,i,e),h=O=>O.bs===O.be,d=O=>O.toks.some(B=>typeof B.k=="string"),b=O=>h(O)&&!d(O),A=(O,B)=>B.bs<O.be&&O.bs<B.be,S=(O,B)=>!A(O,B)&&B.bs<=O.be&&O.bs<=B.be&&(h(O)&&d(O)||h(B)&&d(B))&&!(h(O)&&h(B)),L=(O,B)=>O.bs===B.bs&&O.be===B.be&&Or(O.toks,B.toks),f=[],g=new Set;for(let O of c){let B=s.find(ae=>!g.has(ae)&&L(O,ae));B?(g.add(B),f.push({bs:O.bs,be:O.be,side:"both",l:O,r:B,toks:O.toks})):f.push({bs:O.bs,be:O.be,side:"L",l:O,toks:O.toks,lead:!!O.lead})}for(let O of s)g.has(O)||f.push({bs:O.bs,be:O.be,side:"R",r:O,toks:O.toks,lead:!!O.lead});f.sort((O,B)=>O.bs-B.bs||O.be-B.be||B.lead-O.lead);let x=0,Q=0;for(let O of f)O.side==="both"&&(x+=O.toks.length-(O.be-O.bs));let se=f.map((O,B)=>B),le=O=>se[O]===O?O:se[O]=le(se[O]),q=(O,B)=>(O=le(O),B=le(B),O===B?!1:(se[O]=B,!0)),z=f.map(O=>gc({bs:O.bs,be:O.be,toks:O.toks},e)),ce={L:new Map,R:new Map};f.forEach((O,B)=>{let ae=O.side==="both"?["L","R"]:[O.side];for(let be of ae)for(let de of z[B])ce[be].has(de)||ce[be].set(de,[]),ce[be].get(de).push(B)});for(let O of[ce.L,ce.R])for(let B of O.values())for(let ae=1;ae<B.length;ae++)q(B[0],B[ae]);for(let O=0;O<f.length;O++)for(let B=O+1;B<f.length;B++){let ae=f[O],be=f[B];ae.side===be.side&&ae.side!=="both"||ae.bs>be.be||(A(ae,be)||S(ae,be)?q(O,B):ae.bs===be.bs&&h(ae)&&h(be)&&Q++)}let xe=(O,B)=>{let ae=O==="L"?c:s;for(let be of ae)if(be.toks.some(de=>de.kind==="close"&&de.k.el===B.el))return be.bs;for(let be=0;be<e.length;be++)if(e[be].kind==="close"&&e[be].k.el===B.el)return be;return-1};f.forEach((O,B)=>{if(!(!b(O)||O.side==="both"))for(let ae of O.toks){if(ae.kind!=="open")continue;let be=xe(O.side,ae.k);if(be<=O.bs)continue;let de=new Uint8Array(be-O.bs),ze=[];if(f.forEach((De,Qe)=>{if(!(De.side===O.side||h(De))&&De.bs<be&&De.be>O.bs){ze.push(Qe);for(let st=Math.max(De.bs,O.bs);st<Math.min(De.be,be);st++)de[st-O.bs]=1}}),ze.length&&de.every(De=>De===1))for(let De of ze)q(B,De)}});let te=!0;for(;te;){te=!1;let O=new Map;f.forEach((B,ae)=>{let be=le(ae),de=O.get(be)||{bs:B.bs,be:B.be,L:!1,R:!1};de.bs=Math.min(de.bs,B.bs),de.be=Math.max(de.be,B.be),B.side!=="R"&&(de.L=!0),B.side!=="L"&&(de.R=!0),O.set(be,de)}),f.forEach((B,ae)=>{for(let[be,de]of O){if(le(ae)===le(be)||!(de.L&&de.R))continue;let ze=B.bs<de.be&&B.be>de.bs,De=h(B)&&d(B)&&(B.bs===de.be||B.bs===de.bs);(ze||De)&&q(ae,be)&&(te=!0)}})}let J=new Map;f.forEach((O,B)=>{let ae=le(B);J.has(ae)||J.set(ae,[]),J.get(ae).push(O)});let Ce=[];for(let O of J.values()){let B=O.some(be=>be.side==="L"),ae=O.some(be=>be.side==="R");if(B&&ae){let be=Math.min(...O.map(Qe=>Qe.bs)),de=Math.max(...O.map(Qe=>Qe.be)),ze=O.filter(Qe=>Qe.side!=="R").map(Qe=>Qe.l).sort((Qe,st)=>Qe.bs-st.bs),De=O.filter(Qe=>Qe.side!=="L").map(Qe=>Qe.r).sort((Qe,st)=>Qe.bs-st.bs);Ce.push({bs:be,be:de,kind:"conflict",localHunks:ze,remoteHunks:De})}else for(let be of O)Ce.push({bs:be.bs,be:be.be,kind:be.side,u:be})}let we=(O,B)=>{let ae=O==="L"?c:s;for(let be of ae)if(be.toks.some(de=>de.kind==="close"&&de.k.el===B.el))return be.bs+.5;for(let be=0;be<e.length;be++)if(e[be].kind==="close"&&e[be].k.el===B.el)return be;return 1/0},ne=(O,B)=>{let ae=O==="L"?c:s;for(let be of ae)if(be.toks.some(de=>de.kind==="open"&&de.k.el===B.el))return be.bs-.5;for(let be=0;be<e.length;be++)if(e[be].kind==="open"&&e[be].k.el===B.el)return be;return-1/0},_=O=>O.kind==="R"?"R":"L",ye=O=>O.kind==="R"?1:0;Ce.sort((O,B)=>{if(O.bs!==B.bs)return O.bs-B.bs;let ae=O.bs===O.be,be=B.bs===B.be;if(ae!==be)return ae?-1:1;if(ae&&be&&O.kind!=="conflict"&&B.kind!=="conflict"){let ze=O.u.toks,De=B.u.toks,Qe=wt=>wt.length&&wt.every(bt=>bt.kind==="open"),st=wt=>wt.length&&wt.every(bt=>bt.kind==="close");if(Qe(ze)&&Qe(De)){let wt=Math.max(...ze.map(Tt=>we(_(O),Tt.k))),bt=Math.max(...De.map(Tt=>we(_(B),Tt.k)));if(wt!==bt)return bt-wt}if(st(ze)&&st(De)){let wt=Math.min(...ze.map(Tt=>ne(_(O),Tt.k))),bt=Math.min(...De.map(Tt=>ne(_(B),Tt.k)));return wt!==bt?bt-wt:ye(B)-ye(O)}}let de=ze=>ze.u&&ze.u.lead?1:0;return de(B)-de(O)||ye(O)-ye(B)||O.be-B.be});let ge=[],Oe=[],Be=0,We=O=>{O>Be&&(ge.push({bs:Be,be:O,toks:e.slice(Be,O),source:"base"}),Be=O)};for(let O of Ce){if(We(O.bs),O.kind==="conflict"){let B=Ar(e,O.localHunks,O.bs,O.be),ae=Ar(e,O.remoteHunks,O.bs,O.be),be=o==="local"?B:o==="both"?B.concat(ae):ae,de=(Qe,st)=>{let wt=0;for(let bt of Qe)bt.be<=O.bs&&!st.includes(bt)&&(wt+=bt.toks.length-(bt.be-bt.bs));return wt},ze=O.bs+de(c,O.localHunks),De=O.bs+de(s,O.remoteHunks);Oe.push({bs:O.bs,be:O.be,ls:ze,le:ze+B.length,rs:De,re:De+ae.length,ms:0,me:0,base:e.slice(O.bs,O.be),local:B,remote:ae,resolved:be}),ge.push({bs:O.bs,be:O.be,toks:be,source:"conflict",localHunks:O.localHunks,localToks:B,keepsLocal:o!=="remote"})}else ge.push({bs:O.bs,be:O.be,toks:O.u.toks,source:O.kind==="R"?"remote":"local",localHunks:O.kind==="R"?[]:[O.u.l]});Be=Math.max(Be,O.be)}We(e.length);let rt=0,re=0;for(let O of ge)O.source==="conflict"&&(Oe[re].ms=rt,Oe[re].me=rt+O.toks.length,re++),rt+=O.toks.length;let ut=new Map(a.map(O=>[O.bi,O.tok])),dt=new Map(m.map(O=>[O.bi,O.tok])),Se=[];for(let O of ge){O.source==="base"&&(O.toks=O.toks.map((B,ae)=>{let be=O.bs+ae,de=ut.get(be),ze=dt.get(be),De=de&&ze?o==="remote"?ze:de:de||ze||B;return De===B?B:{...De,cosmetic:!0}}));for(let B of O.toks)Se.push({...B,src:O.source})}return{tokens:Se,segments:ge,conflicts:Oe,localHunks:c,remoteHunks:s,collapsedDelta:x,samePoint:Q,mapLocalOffset:bc(e,c,ge)}}function Ar(e,t,n,o){let r=[],i=n;for(let c of t)r=r.concat(e.slice(i,c.bs),c.toks),i=c.be;return r.concat(e.slice(i,o))}var xr=e=>e.reduce((t,n)=>t+n.len,0);function bc(e,t,n){let o=new Int32Array(e.length+1);for(let c=0;c<e.length;c++)o[c+1]=o[c]+e[c].len;let r=t.map(c=>({bs:o[c.bs],be:o[c.be],text:c.toks.map(s=>s.raw).join(""),ref:c})),i=n.map(c=>({bs:o[c.bs],be:o[c.be],len:xr(c.toks),source:c.source,localHunks:c.localHunks||[],localLen:c.localToks?xr(c.localToks):0,keepsLocal:c.keepsLocal,ref:c}));return c=>{let s=null,a=null,m=0,h=0,d=0;for(let A of r){let S=A.bs-d;if(c<=h+S){s=d+(c-h);break}if(h+=S,d=A.bs,c<=h+A.text.length){a=A,m=c-h,s=A.bs;break}h+=A.text.length,d=A.be}s===null&&(s=d+(c-h));let b=0;for(let A of i){if(!a&&s<=A.bs)return b;if(!(a?A.localHunks.includes(a.ref):s<A.be)){b+=A.len;continue}if(A.source==="base")return b+(s-A.bs);if(A.source==="remote")return b+A.len;if(A.source==="local")return b+Math.min(m,A.len);if(!A.keepsLocal||!a)return b+A.len;let L=A.localHunks.indexOf(a.ref),f=xr(Ar(e,A.localHunks.slice(0,L),A.ref.bs,a.ref.bs));return b+Math.min(f+m,A.localLen)}return b}}function wo(e,t,n,o="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:g=>Math.min(g,t.length),granularity:"word"};let r=Go(e,t,n),i=$n(e,r),c=$n(t,r),s=$n(n,r),a=i.length<=2e4&&c.length<=2e4&&s.length<=2e4?Ss(i,c,s,o):null,m="word",h=i;if(!a){let g=x=>x.split(/(?<=\n)/).map(Q=>({k:Q,raw:Q,len:Q.length}));h=g(e),a=Ss(h,g(t),g(n),o),m="line"}let d=g=>g.map(x=>x.raw).join(""),b=g=>{let x=[0];for(let Q of g)x.push(x[x.length-1]+Q.len);return x},A=b(h),S=null,L=null,f=null;if(a.conflicts.length){let g=x=>x.split(/(?<=\n)/).map(Q=>({k:Q,raw:Q,len:Q.length}));S=b(m==="line"?g(t):c),L=b(m==="line"?g(n):s),f=b(a.tokens)}return{text:d(a.tokens),conflicts:a.conflicts.map(g=>({bs:A[g.bs],be:A[g.be],ls:S[g.ls],le:S[g.le],rs:L[g.rs],re:L[g.re],ms:f[g.ms],me:f[g.me],base:d(g.base),local:d(g.local),remote:d(g.remote),resolved:d(g.resolved)})),mapLocalOffset:a.mapLocalOffset,granularity:m}}function xo(e,t,n=4e3){if(e===t)return[];let o=Go(e,t),r=$n(e,o),i=$n(t,o),c=ro(r,i,n),s=[0];for(let a of r)s.push(s[s.length-1]+a.len);return c.hunks.map(a=>({bs:s[a.bs],be:s[a.be],text:a.toks.map(m=>m.raw).join("")}))}var co="\uFFFC";var yc={caret:0},An=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(" ")),Is=new Set(["BR","WBR","IMG"]),Er=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 qn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||Is.has(e.tagName))return!0;if(!An.has(e.tagName))return!Er.has(e.tagName);if(t.remoteWins&&t.remoteWins(e))return!1;let n=t.inlineCache&&t.inlineCache.get(e);if(n!==void 0)return n;let o=!0;for(let r of e.childNodes)if(!qn(r,t)){o=!1;break}return t.inlineCache&&t.inlineCache.set(e,o),o}function kc(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function En(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,i)=>{for(let c of r){if(c.nodeType===3){let d=c.nodeValue;if(!d)continue;n.nodes.push({node:c,s:n.text.length,e:n.text.length+d.length}),n.text+=d;for(let b=0;b<d.length;b++)n.stackAt.push(i);continue}if(c.nodeType!==1)continue;if(t.ignored&&t.ignored(c)){n.pins.push({el:c,i:n.text.length});continue}if(t.skip&&t.skip.has(c))continue;let s=t.via&&t.via(c)||c;s!==c&&(n.via||(n.via=new Map)).set(s,c);let a=c.tagName;if(t.blocks&&t.blocks.has(c)){n.text.length&&n.text[n.text.length-1]!==gt&&(n.stackAt.push(i),n.text+=gt);let d={el:c,tag:a,from:n.text.length,to:-1,depth:i.length,block:!0};n.marks.push(d);let b=i.concat([d]);o(s.childNodes,b),n.stackAt.push(b),n.text+=gt,d.to=n.text.length;continue}let m=An.has(a)&&kc(s);if(Is.has(a)||!An.has(a)||t.remoteWins&&t.remoteWins(c)||t.atomize&&t.atomize(c)||m){n.atoms.push({i:n.text.length,el:c,key:m?a+":empty":a,stack:i}),n.stackAt.push(i),n.text+=co;continue}let h={el:c,tag:a,from:n.text.length,to:-1,depth:i.length};n.marks.push(h),o(s.childNodes,i.concat([h])),h.to=n.text.length}};if(o(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&Yo(n).trim()===""){let r=n.atoms[0];n.placeholder=r.el,n.text=n.text.slice(0,r.i)+n.text.slice(r.i+1),n.stackAt.splice(r.i,1);for(let i of n.nodes)i.s>r.i&&(i.s--,i.e--);n.atoms=[]}return n.atomAt=new Map(n.atoms.map(r=>[r.i,r])),n}function wc(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function xc(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,"&quot;")}"`;return t+">"}function io(e,t,n){let o="",r=[];for(let i=t;i<n;i++){let c=e.stackAt[i],s=0;for(;s<r.length&&s<c.length&&r[s]===c[s];)s++;for(;r.length>s;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<c.length;){let m=c[r.length];o+=xc(m.el),r.push(m)}let a=e.atomAt.get(i);o+=a?a.el.outerHTML:e.text[i]===gt?"":wc(e.text[i])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function Tc(e,t){let n=[...e.el.attributes].filter(o=>!t(e.el,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tag+"|"+n}function Cs(e,t){let n=[...e.attributes].filter(o=>!t(e,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tagName+"|"+n+"|"+e.innerHTML}function Ns(e,t=()=>!1){let n=new Map,o=i=>{let c=n.get(i);return c===void 0&&(c="{"+i.map(s=>Tc(s,t)).sort().join(",")+"}",n.set(i,c)),c},r="";for(let i=0;i<e.text.length;i++){let c=e.atomAt.get(i);r+=(c?"["+Cs(c.el,t)+"]":e.text[i])+o(e.stackAt[i])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function so(e,t,n,o=r=>r.key){let r=[],i=e.text,c=0,s=a=>{if(a<=c)return;let m=i.slice(c,a);if(n)for(let h of m.split(/(?<=\n)/))r.push({k:h,raw:h,len:h.length});else for(let h of $n(m,t))r.push(h)};for(let a of e.atoms)s(a.i),r.push({k:"\0"+o(a),raw:co,len:1,atom:!0}),c=a.i+1;return s(i.length),r}function Yo(e){if(!e.atoms.length)return e.text;let t="",n=0;for(let o of e.atoms)t+=e.text.slice(n,o.i),n=o.i+1;return t+e.text.slice(n)}var Mr=e=>{let t=new Int32Array(e.length+1);for(let n=0;n<e.length;n++)t[n+1]=t[n]+e[n].len;return t};function Os(e,t,n,o){let r=Mr(t),i=Mr(n),c=[],s=0,a=0;for(let h of o.hunks){a+=h.bs-s;let d=a+h.toks.length;c.push({bs:r[h.bs],be:r[h.be],ss:i[a],se:i[d],text:e.text.slice(i[a],i[d]),toks:h.toks,lead:!!h.lead}),a=d,s=h.be}let m=new Map;for(let h of o.cosmetic)m.set(h.bi,h.tok.raw);return{hunks:c,respell:m}}function vs(e,t,n){let o=c=>c===gt||/\s/.test(c),r=c=>c.replace(/[\u001E\s]/g,""),i=[];for(let c of e){let s=t.slice(c.bs,c.be),a=n.slice(c.ss,c.se);if(!s.includes(gt)&&!a.includes(gt)||s.includes(co)||a.includes(co)||r(s)!==r(a)){i.push(c);continue}let m=0,h=0;for(;;){let d=m,b=h;for(;d<s.length&&o(s[d]);)d++;for(;b<a.length&&o(a[b]);)b++;let A=m,S=h;for(;A<d&&S<b&&s[A]===a[S];)A++,S++;let L=d,f=b;for(;L>A&&f>S&&s[L-1]===a[f-1];)L--,f--;if(L>A||f>S){let g=a.slice(S,f);i.push({bs:c.bs+A,be:c.bs+L,ss:c.ss+S,se:c.ss+f,text:g,toks:[...g].map(x=>({k:x,raw:x,len:1})),lead:c.lead})}if(d>=s.length)break;m=d+1,h=b+1}}return i}function Ms(e,t,n){let o=new Int32Array(t+1).fill(-1),r=new Int32Array(n+1).fill(-1),i=0,c=0,s=a=>{for(;i<a;)o[i]=c,r[c]=i,i++,c++};for(let a of e)s(a.bs),i=a.be,c=a.se;return s(t),o[t]=c,r[c]=t,{bTo:o,toB:r}}function Es(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ir(e){let{out:t,policy:n="remote",L:o,R:r}=e,i=e.provenance||new WeakMap,c=e.textMappers||new WeakMap,s=e.conflicts||[],a=e.decisions||[],m=s.length,h=e.conflict||(l=>s.push(l)),d={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},b=[],A=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),S={base:null,local:null,remote:null};if(A&&e.moveIn){let l=Te=>Ve=>Te.some(ke=>ke===Ve||ke.nodeType===1&&ke.contains(Ve)),w=l(e.local),C=l(e.remote),I=l(e.base),D=new Set,K=Te=>{if(!An.has(Te.tagName))return;let Ve=o.map.get(Te),ke=r.map.get(Te);(Ve&&!w(Ve)||ke&&!C(ke))&&D.add(Te);for(let Ee of Te.children)K(Ee)};for(let Te of e.base)Te.nodeType===1&&K(Te);let pe=Te=>Ve=>{if(!An.has(Ve.tagName))return!1;let ke=Te.reverse.get(Ve);return!!ke&&(D.has(ke)||!I(ke))};D.size&&(S.base=Te=>D.has(Te)),S.local=pe(o),S.remote=pe(r)}let L={base:new Set,local:new Set,remote:new Set};if(A&&e.moveIn){let l=I=>D=>I.some(K=>K===D||K.nodeType===1&&K.contains(D)),w=l(e.local),C=l(e.remote);for(let I of En(e.base,{...e,atomize:S.base}).atoms){let D=o.map.get(I.el),K=r.map.get(I.el),pe=!!D&&!w(D),Te=!!K&&!C(K);!pe&&!Te||(L.base.add(I.el),D&&!pe&&L.local.add(D),K&&!Te&&L.remote.add(K),w(I.el)&&L.local.add(I.el),C(I.el)&&L.remote.add(I.el))}}let f=En(e.base,{...e,atomize:S.base,skip:L.base}),g=En(e.local,{...e,atomize:S.local,skip:L.local}),x=En(e.remote,{...e,atomize:S.remote,skip:L.remote}),Q=new Map(f.atoms.map(l=>[l.el,l])),se={},le=l=>L[l].size?(se[l]||(se[l]=En(e[l],{...e,atomize:S[l]})),se[l]):null,q=(l,w,C)=>{w.namespaceURI?l.setAttributeNS(w.namespaceURI,w.name,C):l.setAttribute(w.name,C)},z=(l,w,C,I)=>{if(!w&&(!C||!I)){for(let K of(C||I).attributes)q(l,K,K.value);return}let D=new Map;for(let K of[w,C,I])if(K)for(let pe of K.attributes)D.set(pe.name,pe);for(let[K,pe]of D){let Te=w?w.getAttribute(K):null,Ve=C?C.getAttribute(K):Te,ke=I?I.getAttribute(K):Te,Ee;Ve===ke?Ee=Ve:Ve===Te?(Ee=ke,a.push({kind:"attr",el:l,name:K,source:"remote"})):ke===Te?(Ee=Ve,a.push({kind:"attr",el:l,name:K,source:"local"})):(Ee=n==="local"?Ve:ke,h({kind:"attr",el:l,name:K,base:Te,local:Ve,remote:ke,resolved:Ee},{el:l,sample:pe}),a.push({kind:"attr",el:l,name:K,source:"both"})),Ee!=null&&q(l,pe,Ee)}},ce=(l,w,C,I)=>l&&e.mergeAttrs?e.mergeAttrs(l,w,C,I):z(I,l,w,C),xe=e.mergeElement||((l,w,C)=>{let I=t.createElement(l.tagName);ce(l,w,C,I);let D=w||l,K=C||l,pe=n==="local"?D.isEqualNode(l)?K:D:K.isEqualNode(l)?D:K;for(let Te of pe.childNodes)I.appendChild(t.importNode(Te,!0));return i.set(I,{base:l,local:w,remote:C}),I}),te=e.cloneUnit||((l,w)=>{let C=t.importNode(l,!0);return i.set(C,{base:null,local:w==="local"?l:null,remote:w==="remote"?l:null}),C}),J=e.atomKey||(l=>Cs(l,()=>!1)),Ce=(l,w)=>{let C=new Map;for(let I of l.atoms)if(e.remoteWins&&e.remoteWins(I.el)&&An.has(I.el.tagName))C.set(I,"w"+I.el.tagName+"#"+(I.el.id||""));else if(!A)C.set(I,I.key);else if(l===f)C.set(I,"="+J(I.el));else{let D=w.reverse.get(I.el),K=D?Q.get(D):null;K?C.set(I,"="+J(K.el)):D?C.set(I,"m"+J(I.el)):C.set(I,"="+J(I.el))}return I=>C.get(I)},we=Ce(f,null),ne=Ce(g,o),_=Ce(x,r),ye=Go(Yo(f),Yo(g),Yo(x)),ge=so(f,ye,!1,we),Oe=so(g,ye,!1,ne),Be=so(x,ye,!1,_),We=ge.length>2e4||Oe.length>2e4||Be.length>2e4;We&&(ge=so(f,ye,!0,we),Oe=so(g,ye,!0,ne),Be=so(x,ye,!0,_));let rt=Nr(ro(ge,Oe),ro(ge,Be),ge),re=Os(g,ge,Oe,{hunks:rt.lh,cosmetic:rt.cosL}),ut=Os(x,ge,Be,{hunks:rt.rh,cosmetic:rt.cosR});re.hunks=vs(re.hunks,f.text,g.text),ut.hunks=vs(ut.hunks,f.text,x.text);let dt=Ms(re.hunks,f.text.length,g.text.length),Se=Ms(ut.hunks,f.text.length,x.text.length),O=f.text.length,B=l=>new Map(l.atoms.map(w=>[w.el,w])),ae=B(g),be=B(x),de=(l,w,C)=>{let I=new Set;if(!A)return I;for(let D of l.atoms){let K=Q.get(w.reverse.get(D.el));K&&C.bTo[K.i]<0&&I.add(K)}return I},ze=de(g,o,dt),De=de(x,r,Se),Qe=l=>!qn(l,{...e,remoteWins:null}),st=new Set;if(A)for(let l of f.atoms){if(!Qe(l.el))continue;let w=o.map.get(l.el)||null,C=r.map.get(l.el)||null,I=w&&!C?w:C&&!w?C:null;I&&(ae.has(I)||be.has(I))&&!I.isEqualNode(l.el)&&st.add(l)}let wt=1,bt=(l,w)=>({id:wt++,tag:l,base:null,local:null,remote:null,rank:w}),Tt=new Map,nn=[];for(let l of f.marks){let w=bt(l.tag,l.depth);w.block=!!l.block,w.base=l.el,w.baseMark=l,Tt.set(l.el,w),nn.push(w)}let Fe=(l,w)=>{let C=-1,I=-1;for(let D=l.from;D<l.to;D++){let K=w[D];K>=0&&(C<0&&(C=K),I=K+1)}return C<0?null:[C,I]},Qt=(l,w,C,I)=>{for(let D of l.marks){let K=C?C.reverse.get(D.el):null;K&&C.identical.has(K)&&C.pairIdenticalChildren&&C.pairIdenticalChildren(K);let pe=K?Tt.get(K):null;if(pe&&pe[w]&&(pe=null),!pe){let Te=Fe(D,I),Ve=0;if(Te)for(let ke of nn){if(ke.tag!==D.tag||ke[w]||!!ke.block!=!!D.block)continue;let Ee=Math.min(Te[1],ke.baseMark.to)-Math.max(Te[0],ke.baseMark.from);(Ee>Ve||Ee===Ve&&Ee>0&&Math.abs(ke.rank-D.depth)<Math.abs(pe.rank-D.depth))&&(pe=ke,Ve=Ee)}}pe||(pe=bt(D.tag,D.depth),pe.block=!!D.block,pe.new=w),pe[w]=D.el,pe[w+"Mark"]=D,Tt.set(D.el,pe)}};Qt(g,"local",o,dt.toB),Qt(x,"remote",r,Se.toB);let Xt=l=>l.merged||l,Bt=l=>{let w=new Set;for(let C of l)C.block||w.add(Tt.get(C.el));return w},Et=new Map,Lt=l=>{let w=Et.get(l);return w||(w=Bt(l),Et.set(l,w)),w},sn=(l,w)=>{let C=[],I=null;for(let D=0;D<O;D++){let K=w[D];if(K<0){I&&C.push(I),I=null;continue}let pe=Lt(f.stackAt[D]),Te=Lt(l.stackAt[K]),Ve=new Set,ke=new Set;for(let Ee of Te)pe.has(Ee)||Ve.add(Ee);for(let Ee of pe)Te.has(Ee)||ke.add(Ee);if(!Ve.size&&!ke.size){I&&C.push(I),I=null;continue}if(I&&Es(I.added,Ve)&&Es(I.removed,ke)){I.be=D+1;continue}I&&C.push(I),I={bs:D,be:D+1,added:Ve,removed:ke}}return I&&C.push(I),C},M=sn(g,dt.bTo),Z=sn(x,Se.bTo),ee=l=>l.be>l.bs?[l.bs,l.be-1]:[l.bs-1,l.bs],ue=(l,w)=>{if(O===0)return null;let[C,I]=ee(l);for(let D of w){if(D.be<=C)continue;if(D.bs>I)break;let K=D.bs<=C&&I<D.be;return K&&l.text===""&&D.bs===l.bs&&D.be===l.be?"straddle":K?D:l.be>l.bs?"straddle":null}return null},oe=l=>l.bs===l.be,fe=(l,w)=>{let C=!1;for(let I=l.bs;I<l.be;I++){let D=f.text[I];if(D===gt)C=!0;else if(!/\s/.test(D))return!1}for(let I=l.ss;I<l.se;I++){let D=w.text[I];if(D===gt)C=!0;else if(!/\s/.test(D))return!1}return C},y=(l,w)=>l.bs<w.be&&w.bs<l.be,T=(l,w)=>l.bs<=w.be&&w.bs<=l.be&&oe(l)!==oe(w),P=(l,w)=>f.text.slice(l.bs,l.be).includes(gt)||w.text.slice(l.ss,l.se).includes(gt),p=l=>{if(oe(l))return!1;let w=l.bs,C=l.be;for(;w>0&&/\s/.test(f.text[w-1]);)w--;for(;C<f.text.length&&/\s/.test(f.text[C]);)C++;return(w===0||f.text[w-1]===gt)&&(C===f.text.length||f.text[C]===gt)},k=(l,w)=>!P(l,w)&&!p(l),R=(l,w)=>y(l,w)||T(l,w)&&!(fe(l,g)&&k(w,x))&&!(fe(w,x)&&k(l,g)),$=(l,w)=>{if(l.bs!==w.bs||l.be!==w.be||l.toks.length!==w.toks.length)return!1;let C=l.ss,I=w.ss;for(let D=0;D<l.toks.length;D++){let K=l.toks[D],pe=w.toks[D];if(K.k!==pe.k||K.atom&&!g.atomAt.get(C).el.isEqualNode(x.atomAt.get(I).el))return!1;C+=K.len,I+=pe.len}return!0},H=(l,w,C,I)=>{for(let D of f.atoms){if(D.i<l.bs||D.i>=l.be||I.has(D)||st.has(D))continue;let K=w.bTo[D.i],pe=K>=0?C.atomAt.get(K):null;if(pe&&!pe.el.isEqualNode(D.el))return!0}return!1},F=[],N=re.hunks,E=ut.hunks,G=0,he=0,ve=0,u=0,v=0,j=l=>{l>ve&&(F.push({src:"base",from:ve,to:l,dL:u,dR:v}),ve=l)};for(;G<N.length||he<E.length;){let l=N[G],w=E[he],C=!!l&&(!w||l.bs<w.bs||l.bs===w.bs&&l.be<=w.be&&!w.lead);if(l&&w&&l.bs===w.bs&&oe(l)&&oe(w)){let Ct=fe(l,g),yo=fe(w,x);Ct!==yo&&(C=yo)}let I=C?l:w,D=C?w:l,K=!!D&&$(l,w),pe=!!D&&(C?!!N[G+1]&&$(N[G+1],w):!!E[he+1]&&$(l,E[he+1])),Te=!!D&&!K&&!pe&&(O===0||R(l,w)),Ve=Te,ke=ue(I,C?Z:M);if(ke==="straddle"&&(Ve=!0),!Ve&&I.be>I.bs&&(Ve=H(I,C?Se:dt,C?x:g,C?ze:De)),!Ve&&K){j(I.bs),F.push({src:"both",lfrom:l.ss,rfrom:w.ss,len:I.text.length}),ve=I.be,u+=I.text.length-(I.be-I.bs),v+=I.text.length-(I.be-I.bs),G++,he++;continue}if(!Ve){j(I.bs),F.push({src:C?"local":"remote",from:I.ss,to:I.se,inherit:ke&&ke!=="straddle"?ke:null}),ve=I.be,C?(u+=I.text.length-(I.be-I.bs),G++):(v+=I.text.length-(I.be-I.bs),he++);continue}let Ee=I.bs,lt=I.be,Ye=G,ot=he,jt=Ct=>Ct.bs<lt&&Ct.be>Ee||oe(Ct)&&(Ct.bs===Ee||Ct.bs===lt);C?Ye++:ot++,Te&&(Ee=Math.min(Ee,D.bs),lt=Math.max(lt,D.be),C?ot++:Ye++);let Nt=!0;for(;Nt;){for(Nt=!1;Ye<N.length&&jt(N[Ye]);)Ee=Math.min(Ee,N[Ye].bs),lt=Math.max(lt,N[Ye].be),Ye++,Nt=!0;for(;ot<E.length&&jt(E[ot]);)Ee=Math.min(Ee,E[ot].bs),lt=Math.max(lt,E[ot].be),ot++,Nt=!0}let rn=Ee+u,Yt=Ee+v,pn=lt-Ee,kn=lt-Ee;for(let Ct=G;Ct<Ye;Ct++)pn+=N[Ct].text.length-(N[Ct].be-N[Ct].bs);for(let Ct=he;Ct<ot;Ct++)kn+=E[Ct].text.length-(E[Ct].be-E[Ct].bs);let On=rn+pn,vn=Yt+kn;j(Ee);let Wt={kind:"text",node:e.node||null,base:io(f,Ee,lt),local:io(g,rn,On),remote:io(x,Yt,vn),resolved:null,range:null,bs:Ee,be:lt,lss:rn,lse:On,rss:Yt,rse:vn};Wt.resolved=n==="local"?Wt.local:n==="remote"?Wt.remote:Wt.local+Wt.remote,n!=="remote"&&F.push({src:"local",from:rn,to:On,conflict:Wt}),n!=="local"&&F.push({src:"remote",from:Yt,to:vn,conflict:Wt});let Vo={site:"inline",fb:f,fl:g,fr:x,scope:e.scope||null,synthetic:!!e.synthetic,full:le,merged:d};b.push(Vo),h(Wt,Vo),ve=lt,u+=pn-(lt-Ee),v+=kn-(lt-Ee),G=Ye,he=ot}j(O);let U=f.text,V=[];if(re.respell.size||ut.respell.size){let l=Mr(ge),w=[];for(let C=0;C<ge.length;C++){let I=ge[C].raw,D=re.respell.get(C)??I,K=ut.respell.get(C)??I;(D!==I||K!==I)&&V.push([l[C],D!==I&&K!==I?"both":D!==I?"local":"remote"]),w.push(D===K?D:D===I?K:K===I||n==="local"?D:K)}U=w.join("")}let W="",Y=[],ie=[],Ne=[],Le=[];for(let l of F){let w=W.length;if(l.src==="base"){for(let C=l.from;C<l.to;C++)Y.push(C),ie.push(C+l.dL),Ne.push(C+l.dR),Le.push(l);W+=U.slice(l.from,l.to)}else if(l.src==="both"){for(let C=0;C<l.len;C++)Y.push(-1),ie.push(l.lfrom+C),Ne.push(l.rfrom+C),Le.push(l);W+=g.text.slice(l.lfrom,l.lfrom+l.len)}else{let C=l.src==="local"?g:x;for(let I=l.from;I<l.to;I++)Y.push(-1),ie.push(l.src==="local"?I:-1),Ne.push(l.src==="remote"?I:-1),Le.push(l);W+=C.text.slice(l.from,l.to)}l.ms=w,l.me=W.length,l.conflict&&(l.conflict.range||(l.conflict.range=[w,w]),l.conflict.range[1]=W.length)}let Me=W.length,Ze=new Int32Array(O+1).fill(-1),je=new Int32Array(g.text.length+1).fill(-1),Ot=new Int32Array(x.text.length+1).fill(-1);for(let l=0;l<Me;l++)Y[l]>=0&&(Ze[Y[l]]=l),ie[l]>=0&&(je[ie[l]]=l),Ne[l]>=0&&(Ot[Ne[l]]=l);let Ue=(l,w)=>{let C=-1,I=-1;for(let D=l.from;D<l.to;D++){let K=w[D];K>=0&&(C<0&&(C=K),I=K+1)}return C<0?null:[C,I]},ht=[],it=[];for(let l of new Set(Tt.values()))l.new==="local"?ht.push(l):l.new==="remote"&&it.push(l);let Kt=(l,w)=>{l.remote=w.remote,l.remoteMark=w.remoteMark,l.new="both",w.merged=l,Tt.set(w.remote,l)};if(ht.length&&it.length){let l=e.idOf;for(let w of ht){let C=l?l.local(w.local):null;if(!C)continue;let I=it.find(D=>!D.merged&&D.tag===w.tag&&!!D.block==!!w.block&&l.remote(D.remote)===C);I&&Kt(w,I)}for(let w of ht){if(w.remote)continue;let C=Ue(w.localMark,je);if(C)for(let I of it){if(I.merged||I.tag!==w.tag||!!I.block!=!!w.block)continue;let D=Ue(I.remoteMark,Ot);if(D&&Math.min(C[1],D[1])-Math.max(C[0],D[0])>0){Kt(w,I);break}}}}Et.clear();let Rt=l=>{for(let w of l)if(w.block)return Xt(Tt.get(w.el));return null},qt=f.marks.some(l=>l.block)||g.marks.some(l=>l.block)||x.marks.some(l=>l.block),It=new Array(Me).fill(null),at=new Set;if(qt){let l=(ke,Ee,lt)=>{let Ye=new Set([ke,Ee,lt]);Ye.delete(null);let ot=[];for(let Nt of Ye){let rn=Nt===ke,Yt=Nt===Ee,pn=Nt===lt;(Yt===pn?Yt:Yt===rn?pn:Yt)&&ot.push(Nt)}if(ot.length<=1)return ot[0]||null;let jt=n==="local"?Ee:lt;return ot.includes(jt)?jt:ot[0]},w=(ke,Ee)=>Ee>=0?Rt(ke.stackAt[Ee]):null,C=new Map;for(let ke=0;ke<Me;ke++){if(W[ke]!==gt)continue;let Ee=Y[ke]>=0?w(f,Y[ke]):null,lt=w(g,ie[ke]),Ye=w(x,Ne[ke]);C.set(ke,[Ee,Y[ke]>=0?l(Ee,lt,Ye):lt||Ye])}let I=new Set([...C.values()].map(ke=>ke[1])),D=ke=>ke!==gt&&ke!==co&&!/\s/.test(ke),K=(ke,Ee)=>{let lt=ke;for(;lt<Ee&&!D(W[lt]);)lt++;return lt<Ee&&Y[lt]>=0?w(f,Y[lt]):null},pe=new Map,Te=0;for(let ke=0;ke<Me;ke++){if(W[ke]!==gt)continue;let[Ee,lt]=C.get(ke),Ye=K(Te,ke),ot=lt,jt=pe.get(ot)===ot&&Ye===ot;ot&&pe.has(ot)&&!jt&&Ee&&!pe.has(Ee)&&!I.has(Ee)&&(ot=Ee),ot&&!pe.has(ot)&&pe.set(ot,Ye);for(let Nt=Te;Nt<=ke;Nt++)It[Nt]=ot;Te=ke+1}let Ve=ke=>{for(let Ee=0;Ee<ke.text.length;Ee++)if(D(ke.text[Ee])&&!w(ke,Ee))return!0;return!1};if(!Ve(f)&&!Ve(g)&&!Ve(x)){let ke=[],Ee=0;for(let Ye=0;Ye<Me;Ye++)(W[Ye]===gt||Ye===Me-1)&&(ke.push([Ee,Ye]),Ee=Ye+1);let lt=new Set(It);for(let Ye=0;Ye<ke.length;Ye++){let[ot,jt]=ke[Ye];if(It[jt])continue;let Nt=ot;for(;Nt<=jt&&!D(W[Nt]);)Nt++;if(Nt>jt)continue;let rn=w(f,Y[Nt]),Yt=w(g,ie[Nt]),pn=w(x,Ne[Nt]),kn=l(rn,Yt,pn)||Yt||pn||rn;if(kn&&!lt.has(kn)){lt.add(kn);for(let Wt=ot;Wt<=jt;Wt++)It[Wt]=kn;continue}let On=Ye>0&&It[ke[Ye-1][1]],vn=Ye+1<ke.length&&It[ke[Ye+1][1]];if(On)at.add(ke[Ye-1][1]);else if(vn&&W[jt]===gt)at.add(jt);else continue;for(let Wt=ot;Wt<=jt;Wt++)It[Wt]=On||vn}}}let St=new Map,At=l=>{let w=St.get(l);if(w)return w;w=[1/0,-1/0];for(let[C,I]of[[l.baseMark,Ze],[l.localMark,je],[l.remoteMark,Ot]]){let D=C&&Ue(C,I);D&&(w[0]=Math.min(w[0],D[0]),w[1]=Math.max(w[1],D[1]))}return St.set(l,w),w},Ht=(l,w,C)=>{let I=-1,D=-1;for(let K=0;K<l.length;K++){let pe=Tt.get(l[K].el);pe===w&&(I=K),pe===C&&(D=K)}return I>=0&&D>=0?I-D:0},Zt=(l,w)=>[...l].sort((C,I)=>{for(let pe of w){let Te=Ht(pe,C,I);if(Te)return Te}let D=At(C),K=At(I);return D[0]-K[0]||K[1]-D[1]||C.rank-I.rank||C.id-I.id}),un=new Map,In=new Map,Cn=l=>{let w=Y[l],C=ie[l],I=Ne[l],D=Le[l];if(w>=0){let Ye=f.stackAt[w],ot=g.stackAt[C],jt=x.stackAt[I],Nt=un.get(Ye);Nt||un.set(Ye,Nt=new Map);let rn=Nt.get(ot);rn||Nt.set(ot,rn=new Map);let Yt=rn.get(jt);if(Yt)return Yt;let pn=Lt(Ye),kn=Lt(ot),On=Lt(jt),vn=new Set;for(let Wt of new Set([...pn,...kn,...On])){let Vo=pn.has(Wt),Ct=kn.has(Wt),yo=On.has(Wt);(Ct===yo?Ct:Ct===Vo?yo:Ct)&&vn.add(Wt)}return Yt=Zt(vn,[ot,jt,Ye]),rn.set(jt,Yt),Yt}if(D.src==="both"){let Ye=g.stackAt[C],ot=x.stackAt[I];return Zt(new Set([...Lt(Ye),...Lt(ot)]),[Ye,ot])}let pe=(D.src==="local"?g:x).stackAt[D.src==="local"?C:I];if(!D.inherit)return Zt(Lt(pe),[pe]);let Te=In.get(D);Te||In.set(D,Te=new Map);let Ve=Te.get(pe);if(Ve)return Ve;let ke=new Set(Lt(pe));for(let Ye of D.inherit.added)ke.add(Xt(Ye));for(let Ye of D.inherit.removed)ke.delete(Xt(Ye));let Ee=D.src==="local"?x:g,lt=(D.src==="local"?Se.bTo:dt.bTo)[D.inherit.bs];return Ve=Zt(ke,[pe,Ee.stackAt[lt]]),Te.set(pe,Ve),Ve},xn=new Int32Array(g.text.length+1);xn[g.text.length]=Me;for(let l=g.text.length-1;l>=0;l--)xn[l]=je[l]>=0?je[l]:xn[l+1];yc.caret+=g.text.length;let cn=l=>l<=0?0:(l>g.text.length&&(l=g.text.length),je[l-1]>=0?je[l-1]+1:xn[l]),zt=[],X=[],Re=null,Ae=[],Ge="",ct=-1,He=l=>{Re?Re.appendChild(l):zt.push(l)},$e=l=>{if(!Ge)return;let w=t.createTextNode(Ge);He(w),X.push({node:w,ms:ct,me:l,local:[],u:Ae.length?Ae[Ae.length-1].u:null}),Ge=""},et=new Set,_e=new Map,nt=new Set,en=l=>{let w=t.createElement(l.tag);if(l.block&&_t.add(w),!_e.has(l)){_e.set(l,w),ce(l.base,l.local,l.remote,w),i.set(w,{base:l.base,local:l.local,remote:l.remote});let I=(pe,Te)=>A&&l[Te]&&pe.reverse.get(l[Te])?Te:null,D=!l.base&&(I(o,"local")||I(r,"remote"));if(D){let pe=D==="local"?o.reverse.get(l.local):r.reverse.get(l.remote),Te=i.get(w);Te.local=Te.local||o.map.get(pe)||null,Te.remote=Te.remote||r.map.get(pe)||null,a.push({kind:"move",el:w,source:D})}else l.base||a.push({kind:"insert",el:w,source:l.local&&l.remote?"both":l.local?"local":"remote"});let K=i.get(w);K.local&&(nt.has(K.local)?K.local=null:nt.add(K.local))}else{let I=_e.get(l);for(let D of I.attributes)D.name!=="id"&&D.name!=="data-id"&&q(w,D,D.value);i.set(w,{base:null,local:null,remote:null})}He(w),Ae.push({u:l,el:w}),Re=w},Vn=new Set,dn=new Map;for(let l of g.pins){let w=cn(l.i);dn.has(w)||dn.set(w,[]),dn.get(w).push(l)}let ln=l=>{let w=dn.get(l);if(w){$e(l);for(let C of w){let I=C.el.namespaceURI&&C.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(C.el.namespaceURI,C.el.tagName):t.createElement(C.el.tagName);i.set(I,{base:null,local:C.el,remote:null,pinned:!0}),Vn.add(I),He(I)}}},Wn=f.atoms.length||g.atoms.length||x.atoms.length,Je=l=>{if(!Wn)return null;let w=Y[l]>=0?f.atomAt.get(Y[l]):null,C=ie[l]>=0?g.atomAt.get(ie[l]):null,I=Ne[l]>=0?x.atomAt.get(Ne[l]):null;return w||C||I?{ab:w,al:C,ar:I}:null},ft=(l,w,C,I)=>{if(!l||!A)return null;let D=Q.get(w.reverse.get(l.el))||null;return!D||D===I||(I?D.el.isEqualNode(I.el):C.bTo[D.i]>=0)?null:D},me=(l,w)=>{if(!l||!A||!e.moveIn)return null;let C=w.reverse.get(l.el);return C&&!Q.has(C)?C:null},Ie=(l,w)=>{let C=new Map;for(let I of l.atoms)C.set(w(I),(C.get(w(I))||0)+1);return C},qe=Ie(f,we),tt=Ie(g,ne),Ke=Ie(x,_),kt=l=>{let w=we(l);return qe.get(w)===1&&(tt.get(w)||0)<=1&&(Ke.get(w)||0)<=1},yt=new Map,Pt=new Set,Ft=new Set,on=new Set;for(let l=0;l<Me;l++){let w=Je(l);if(!w)continue;let{ab:C,al:I,ar:D}=w,K=ft(D,r,Se,C),pe=ft(I,o,dt,C),Te=C,Ve=null;if(K?(Te=K,Ve="remote"):pe&&(Te=pe,Ve="local"),Te){Pt.has(Te)?yt.set(l,{dup:Te.el}):(Pt.add(Te),yt.set(l,{bk:Te,from:Ve,al:I,ar:D}));continue}let ke=me(D,r),Ee=me(I,o),lt=ke||Ee;if(lt){Ft.has(lt)?yt.set(l,{dup:lt}):(Ft.add(lt),yt.set(l,{moveIn:lt,side:ke?"remote":"local",sideEl:ke?D.el:I.el}));continue}let Ye=(jt,Nt)=>jt&&A&&Q.get(Nt.reverse.get(jt.el))||null,ot=Ye(D,r)||Ye(I,o);if(ot&&(on.add(ot),Le[l].conflict&&kt(ot))){if(Pt.has(ot)){yt.set(l,{dup:ot.el});continue}Pt.add(ot)}yt.set(l,{al:I,ar:D})}let vt=new Map,Ln=(l,w)=>{if(l[w]>=0)return l[w];for(let C=w-1;C>=0;C--)if(l[C]>=0)return l[C]+1;return 0};if(A)for(let l of f.atoms){if(Pt.has(l)||on.has(l))continue;let w=o.map.get(l.el)||null,C=r.map.get(l.el)||null,I=w&&ae.get(w),D=C&&be.get(C);if(w&&!I||C&&!D)continue;let K=!(I&&D)&&st.has(l);if(!K&&!(I&&D&&kt(l)))continue;let pe=n==="local"?[[I,je],[D,Ot]]:[[D,Ot],[I,je]],[Te,Ve]=pe.find(([Ee])=>Ee),ke=Ln(Ve,Te.i);vt.has(ke)||vt.set(ke,[]),vt.get(ke).push({a:l,lt:w,rt:C,edited:K}),Pt.add(l)}if(A&&e.moveIn){let l=[[g,o,je,"local"],[x,r,Ot,"remote"]];n!=="local"&&l.reverse();for(let[w,C,I,D]of l)for(let K of w.atoms){let pe=me(K,C);if(!pe||Ft.has(pe))continue;Ft.add(pe);let Te=Ln(I,K.i);vt.has(Te)||vt.set(Te,[]),vt.get(Te).push({move:pe,side:D,sideEl:K.el})}}let Ut=l=>{let w=vt.get(l);if(w){if($e(l),w.some(C=>Qe(C.move?C.sideEl:C.a.el)))for(;Ae.length;)Ae.pop(),Re=Ae.length?Ae[Ae.length-1].el:null;for(let{a:C,lt:I,rt:D,edited:K,move:pe,side:Te,sideEl:Ve}of w){if(pe){let Ee=e.moveIn(pe,Te,Ve);Ee&&He(Ee);continue}et.add(C);let ke=xe(C.el,I,D);K&&(h({kind:"structure",el:ke,detail:"edit-beats-delete",base:C.el},{subject:C.el,deleted:I?"remote":"local"}),a.push({kind:"insert",el:ke,source:I?"local":"remote"})),He(ke)}}},_t=new Set,an=s.length>m;for(let l=0;l<Me;l++){let w=Je(l),I=!!w&&Qe((w.ab||w.al||w.ar).el)?[]:It[l]?[It[l],...Cn(l)]:Cn(l),D=0;for(;D<Ae.length&&D<I.length&&Ae[D].u===I[D];)D++;if(D<Ae.length)for($e(l);Ae.length>D;)Ae.pop(),Re=Ae.length?Ae[Ae.length-1].el:null;if(ln(l),Ut(l),I.length>Ae.length)for($e(l);Ae.length<I.length;)en(I[Ae.length]);if(W[l]===gt){if(at.has(l))continue;$e(l);let K=Ae.length;for(;K>0&&!Ae[K-1].u.block;)K--;if(K>0)for(an&&d.breakOut.set(l,Ae[K-1].el);Ae.length>=K;)Ae.pop(),Re=Ae.length?Ae[Ae.length-1].el:null;continue}if(w){$e(l);let K=yt.get(l),pe;if(K.dup){h({kind:"structure",el:null,detail:"both-moved",base:K.dup},{subject:K.dup});continue}if(K.moveIn){if(pe=e.moveIn(K.moveIn,K.side,K.sideEl),!pe)continue}else if(K.bk){let Te=K.bk;if(et.add(Te),Te===w.ab)pe=xe(Te.el,K.al.el,K.ar.el);else{let Ve=o.map.get(Te.el)||null,ke=r.map.get(Te.el)||null;pe=xe(Te.el,Ve,ke),(!Ve||!ke)&&h({kind:"structure",el:null,detail:"move-beats-delete",base:Te.el},{subject:Te.el,deleted:Ve?"remote":"local"}),a.push({kind:"move",el:pe,source:K.from})}}else K.al?(pe=te(K.al.el,"local"),K.ar&&(i.get(pe).remote=K.ar.el),a.push({kind:"insert",el:pe,source:K.ar?"both":"local"})):(pe=te(K.ar.el,"remote"),a.push({kind:"insert",el:pe,source:"remote"}));an&&d.atomOut.set(l,pe),He(pe);continue}Ge||(ct=l),Ge+=W[l]}if($e(Me),(dn.has(Me)||vt.has(Me))&&(Ae.length=0,Re=null,ln(Me),Ut(Me)),Me===0&&(g.placeholder||x.placeholder||f.placeholder)){let l=t.createElement("br");i.set(l,{base:f.placeholder,local:g.placeholder,remote:x.placeholder}),zt.push(l)}let bn=0,Uo=l=>{for(;bn>0&&X[bn-1].me>=l;)bn--;for(;bn<X.length&&X[bn].me<l;)bn++;let w=X[bn];if(!w)return X[X.length-1]||null;let C=X[bn+1];return w.me===l&&C&&C.ms===l?C:w},Zn=new Map,bo={},Pe=(l,w,C)=>{let I=Uo(l)||(C?bo:null);if(!I)return;let D=Zn.get(I)||{l:!1,r:!1};w!=="remote"&&(D.l=!0),w!=="local"&&(D.r=!0),Zn.set(I,D)},pt=l=>{if(l.conflict)return!0;let w=l.src==="local"?g.text:l.src==="remote"?x.text:"";for(let C=l.from;C<l.to;C++)if(w[C]!==co&&w[C]!==gt)return!0;return!1};for(let l of F)l.src!=="base"&&Pe(l.ms,l.conflict?"both":l.src,pt(l));for(let[l,w]of V)Ze[l]>=0&&Pe(Ze[l],w);for(let l of X.length?X:[bo]){let w=Zn.get(l);w&&a.push({kind:"text",node:l.node||null,source:w.l&&w.r?"both":w.l?"local":"remote"})}for(let l of nn){if(_e.has(l))continue;let w=!l.local&&!(A&&o.map.get(l.base)),C=!l.remote&&!(A&&r.map.get(l.base));!w&&!C||a.push({kind:"remove",source:w&&C?"both":w?"local":"remote",base:l.base})}let Mt=(l,w,C)=>{if(w<=l)return!1;for(let I=l;I<w;I++)if(C[I]>=0)return!1;return!0};for(let l of nn)for(let w of["local","remote"]){let C=l[w+"Mark"],I=l.baseMark;if(!C)continue;let D=w==="local"?dt:Se;if(!Mt(I.from,I.to,D.bTo)||!Mt(C.from,C.to,D.toB))continue;let K=(w==="local"?N:E).find(pe=>pe.ss<=C.from&&C.from<pe.se);K&&(K.be<=I.from||K.bs>=I.to)&&a.push({kind:"move",el:_e.get(l)||null,source:w})}let xt=l=>{let w=Tt.get(l.node.parentNode);return w?Xt(w):null};for(let l of g.nodes){let w=-1;for(let I=l.s;I<l.e;I++)if(je[I]>=0){w=je[I];break}let C;if(w>=0)C=Uo(w);else{let I=cn(l.s),D=xt(l);C=X.find(K=>K.u===D&&K.me>=I)||X.filter(K=>K.u===D).pop()}C&&C.local.push(l)}let mt=new Map,yn=X[X.length-1]||null,Vt=0;for(let l of g.nodes){let w=null;for(let C=l.s;C<=l.e;C++){let I=cn(C);for(;Vt>0&&X[Vt-1].me>=I;)Vt--;for(;Vt<X.length&&X[Vt].me<I;)Vt++;let D=pe=>pe&&I>=pe.ms&&I<=pe.me&&(I<pe.me||C===l.e||pe===w),K=D(X[Vt])?X[Vt]:D(X[Vt+1])?X[Vt+1]:X[Vt]||yn;if(!K)break;if(w===K){let pe=mt.get(K);pe[pe.length-1].to=C-l.s;continue}w=K,mt.has(K)||mt.set(K,[]),mt.get(K).push({node:l.node,from:C-l.s,to:C-l.s,flatStart:l.s})}}for(let l of X){let w=l.local,C=!1;for(let pe of w)for(let Te=pe.s;Te<pe.e&&!C;Te++)(je[Te]<l.ms||je[Te]>=l.me)&&(C=!0);i.set(l.node,{base:null,local:w.map(pe=>pe.node),remote:null,caret:mt.get(l)||[],partial:C});let I=l.ms,D=l.me-l.ms,K=pe=>{let Te=0,Ve=-1;for(let ke of w){let Ee=ke.e-ke.s;if(pe<=Te+Ee){Ve=ke.s+(pe-Te);break}Te+=Ee}return Ve<0&&(Ve=w.length?w[w.length-1].e:0),Math.max(0,Math.min(cn(Ve)-I,D))};K.flat=pe=>Math.max(0,Math.min(cn(pe)-I,D)),c.set(l.node,K)}function Rn(){if(!g.text.includes(gt))return[{flatLocal:g.text,localNodes:g.nodes,textNodes:X,lToM:je,mapLocal:cn}];let l=[],w=0,C=0;for(let I=0;I<=g.text.length;I++){if(I<g.text.length&&g.text[I]!==gt)continue;let D=w,K=I;if(K>D){let pe=[];for(;C<g.nodes.length&&g.nodes[C].e<=D;)C++;for(let Te=C;Te<g.nodes.length&&g.nodes[Te].s<K;Te++){let Ve=g.nodes[Te],ke=Math.max(Ve.s,D),Ee=Math.min(Ve.e,K);ke<Ee&&pe.push({node:Ve.node,s:ke-D,e:Ee-D})}l.push({flatLocal:g.text.slice(D,K),localNodes:pe,textNodes:X,lToM:je.subarray?je.subarray(D,K+1):je.slice(D,K+1),mapLocal:Te=>cn(D+Math.max(0,Math.min(Te,K-D)))})}w=I+1}return l}let Tn={...e,blocks:_t,ignored:l=>Vn.has(l)||(e.ignored?e.ignored(l):!1)},Gt=e.ignoreAttribute||(()=>!1),_o=Ns(En(zt,Tn),Gt)!==Ns(x,Gt);if(b.length){let l=w=>{let C=i.get(w);return C&&C.unchanged?C.remote:null};d.text=W,d.textNodes=X,d.out=En(zt,{...Tn,via:l})}return{nodes:zt,text:W,textNodes:X,localDiverged:_o,mapLocal:cn,conflicts:s.slice(m),granularity:We?"line":"word",segments:Rn(),localHunks:N,remoteHunks:E,lToM:je}}var Ac="http://www.w3.org/1999/xhtml";function Sc(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function tn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Ac}function Nc(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Jo(e,t){let n=e.getAttribute("src"),o=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(n){let r=n;try{let i=new URL(n,t);r=i.origin+i.pathname+i.search}catch{}return"script|src|"+o+"|"+r}return"script|inline|"+o+"|"+Sc(e.textContent.trim())}var Oc={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function lo(e,t=[],n=!1){if(!tn(e)||e.hasAttribute("src"))return null;let o=[Oc,...t];for(let r=0;r<o.length;r++){let i=o[r];if(!i.match(e))continue;if(!Nc(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let c=i.identity(e);return c==null||c===""?null:{key:r+":"+c,raw:c,recognizer:i}}return null}function Ls(e,t,n){let o=new Set,r=i=>{tn(i)&&!t(i)&&o.add(Jo(i,n))};r(e);for(let i of e.querySelectorAll("script"))r(i);return o}function To(e,t){let n=t.createElement("div");n.innerHTML="<script><\/script>";let o=n.firstChild;for(let r of e.attributes)o.setAttribute(r.name,r.value);return o.textContent=e.textContent,o}function Rs(e,t,n){let o=[],r=[],i=new Map,c=n.trackRecovery?new Set:null,s=Array.from(e.querySelectorAll("script"));tn(e)&&s.unshift(e);for(let a of s){if(!tn(a)||n.ignored(a)||n.skip.has(a)||t.has(Jo(a,n.baseURI)))continue;let m=a.ownerDocument.createElement("script");for(let h of a.attributes)m.setAttribute(h.name,h.value);if(m.textContent=a.textContent,n.beforeNodeAdded(m)===!1){c?.add(a);continue}m.hasAttribute("src")&&r.push(new Promise(h=>{m.addEventListener("load",()=>h()),m.addEventListener("error",()=>h())})),a.replaceWith(m),i.set(a,m),n.afterNodeAdded(m),o.push(m)}return{executed:o,loads:r,swapped:i,vetoed:c}}function vc(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return(t>>>0).toString(36)}function Mc(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function Ps(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Jo(e,t);if(n==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+Mc(o,t):e.outerHTML}if(n==="META"){for(let o of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(o))return"meta|"+o+"="+e.getAttribute(o);return e.outerHTML}return n==="STYLE"?"style|"+vc(e.textContent):e.outerHTML}function Cr(e,t){for(;;){for(;t<e.length&&/\s/.test(e[t]);)t++;if(e[t]==="/"&&e[t+1]==="/"){for(;t<e.length&&e[t]!==`
5
- `;)t++;continue}if(e[t]==="/"&&e[t+1]==="*"){let n=e.indexOf("*/",t+2);if(n===-1)return e.length;t=n+2;continue}return t}}function Ec(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var Ic=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Cc=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Lr(e){try{return JSON.parse(e)}catch{return JSON.parse(Lc(e))}}function Lc(e){let t="",n=0,o=(r,i)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${i}`)};for(;n<e.length&&(n=Cr(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let s=Cr(e,n+1);if(e[s]==="}"||e[s]==="]"){n++;continue}t+=r,n++;continue}if(r==='"'||r==="'"){let s=n+1;for(;s<e.length&&e[s]!==r;)e[s]==="\\"&&s++,s++;s>=e.length&&o("unterminated string",n);let a=e.slice(n+1,s);r==="'"&&(a=Ec(a)),t+='"'+a+'"',n=s+1;continue}let i=n;for(;i<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[i]);)i++;i===n&&o("unexpected character "+JSON.stringify(r),n);let c=e.slice(n,i);if(c==="true"||c==="false"||c==="null"||Ic.test(c)){t+=c,n=i;continue}if(Cc.test(c)){if(e[Cr(e,i)]===":"){t+='"'+c+'"',n=i;continue}o("unquoted value "+JSON.stringify(c),n)}o("invalid token "+JSON.stringify(c),n)}return t}var Dt=Symbol("hyper-morph-json-merge:missing"),js=["id","_id","uuid","key","slug","code","name"];function ao(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ao(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Rc(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}function Hn(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Hn(e[n],t[n]))return!1;return!0}if(ao(e)&&ao(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Ao(t,o)||!Hn(e[o],t[o]))return!1;return!0}return!1}function Ds(e,t,n,o){return Hn(t,n)?t:Hn(t,e)?n:Hn(n,e)?t:ao(t)&&ao(n)?Pc(ao(e)?e:{},t,n,o):Array.isArray(t)&&Array.isArray(n)?Bc(Array.isArray(e)?e:[],t,n,o):n}function Hs(e,t,n,o){return t===Dt&&n===Dt?Dt:t===Dt?e===Dt?n:Hn(n,e)?Dt:n:n===Dt?e===Dt?t:Dt:Ds(e,t,n,o)}function Pc(e,t,n,o){let r={},i=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let c of i){let s=Hs(Ao(e,c)?e[c]:Dt,Ao(t,c)?t[c]:Dt,Ao(n,c)?n[c]:Dt,o);s!==Dt&&Rc(r,c,s)}return r}function jc(e){return e===null||typeof e!="object"}function Xo(e){return typeof e+":"+String(e)}function Dc(e,t){for(let n of t){let o=new Set;for(let r of n){if(!Ao(r,e))return!1;let i=r[e];if(typeof i!="string"&&typeof i!="number")return!1;let c=Xo(i);if(o.has(c))return!1;o.add(c)}}return!0}function Hc(e,t,n,o){let r=[e,t,n],i=!0;for(let c of r)for(let s of c)ao(s)||(i=!1);if(i){for(let c of o.keyCandidates)if(Dc(c,r))return{kind:"keyed",field:c};return null}for(let c of r){let s=new Set;for(let a of c){if(!jc(a))return null;let m=Xo(a);if(s.has(m))return null;s.add(m)}}return{kind:"self"}}function Bc(e,t,n,o){let r=Hc(e,t,n,o);if(!r)return n;let i=r.kind==="self"?Xo:A=>Xo(A[r.field]),c=A=>{let S=new Map;for(let L of A)S.set(i(L),L);return S},s=c(e),a=c(t),m=c(n),h=new Map,d=new Set([...s.keys(),...a.keys(),...m.keys()]);for(let A of d){let S=Hs(s.has(A)?s.get(A):Dt,a.has(A)?a.get(A):Dt,m.has(A)?m.get(A):Dt,o);S!==Dt&&h.set(A,S)}let b=[];for(let A of n){let S=i(A);h.has(S)&&b.push(S)}for(let A=0;A<t.length;A++){let S=i(t[A]);if(!h.has(S)||b.includes(S))continue;let L=0;for(let f=A-1;f>=0;f--){let g=b.indexOf(i(t[f]));if(g!==-1){L=g+1;break}}b.splice(L,0,S)}return b.map(A=>h.get(A))}function Bs(e,t,n,o={}){let r=o.keyCandidates?[...o.keyCandidates,...js]:js;return Ds(e===void 0?Dt:e,t,n,{keyCandidates:r})}function Rr(e,t,n,o={}){let r=o.parse||Lr,i=[],c=(d,b)=>{if(typeof d!="string")return Dt;try{return r(d)}catch(A){return i.push(`${b} side is not valid JSON (${A.message})`),Dt}},s=c(t,"local"),a=c(n,"remote");if(s===Dt)return{text:n,warnings:i};if(a===Dt)return{text:t,warnings:i};let m=c(e,"base"),h=Bs(m===Dt?void 0:m,s,a,o);return Hn(h,a)?{text:n,warnings:i}:Hn(h,s)?{text:t,warnings:i}:{text:JSON.stringify(h,null,2),warnings:i}}var Us=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function Kn(e){if(!e)return!1;let{startContainer:t,startOffset:n,endContainer:o,endOffset:r}=e;if(!t||!o||!Number.isInteger(n)||!Number.isInteger(r)||n<0||r<0||n>Us(t)||r>Us(o)||t.getRootNode()!==o.getRootNode())return!1;let i=t.ownerDocument.createRange();return i.setStart(t,n),i.setEnd(o,r),i.startContainer===t&&i.startOffset===n}function Bn(e,t,n={}){if(!Kn(e))return null;let{startContainer:o,startOffset:r,endContainer:i,endOffset:c}=e;if(o===i&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,c);if(o===i&&r===c)return"";let s=new Set;for(let f=o;f;f=f.parentNode)s.add(f);let a=i;for(;!s.has(a);)a=a.parentNode;let m=(f,g)=>{let x=a.ownerDocument.createRange(),Q=a.ownerDocument.createRange();return x.setStart(f[0],f[1]),x.collapse(!0),Q.setStart(g[0],g[1]),Q.collapse(!0),x.compareBoundaryPoints(0,Q)},h=(f,g=!1)=>[f.parentNode,Array.prototype.indexOf.call(f.parentNode.childNodes,f)+Number(g)],d=[],b;if(t==="plain"){b="";let f=g=>{if(g.nodeType===3||g.nodeType===8){let x=b.length;b+=g.nodeValue,d.push({s:x,e:b.length,a:[g,0],b:[g,g.nodeValue.length],node:g})}else for(let x of g.childNodes)f(x)};f(a)}else{let f=n.blocks;if(!f){f=new Set;let x=Q=>{Q!==a&&Q.nodeType===1&&Er.has(Q.tagName)&&f.add(Q);for(let se of Q.childNodes)x(se)};x(a)}let g=En(Array.from(a.childNodes),{blocks:f,atomize:x=>!!n.atoms?.has(x),ignored:n.ignored});b=g.text;for(let x of g.nodes)d.push({s:x.s,e:x.e,a:[x.node,0],b:[x.node,x.e-x.s],node:x.node});for(let x of g.atoms)d.push({s:x.i,e:x.i+1,a:h(x.el),b:h(x.el,!0)});for(let x=0;x<g.text.length;x++){if(g.text[x]!==gt)continue;let Q=g.marks.find(le=>le.block&&le.to===x+1),se=g.marks.find(le=>le.block&&le.from===x+1);if(Q)d.push({s:x,e:x+1,a:[Q.el,Q.el.childNodes.length],b:h(Q.el,!0)});else if(se)d.push({s:x,e:x+1,a:h(se.el),b:[se.el,0]});else return null}}d.sort((f,g)=>f.s-g.s);let A=f=>{if(f[0].nodeType===3||f[0].nodeType===8){let x=d.find(Q=>Q.node===f[0]);return x?x.s+f[1]:null}let g=0;for(let x of d){if(m(f,x.a)<=0)return x.s;if(m(f,x.b)<0)return null;g=x.e}return g},S=A([o,r]),L=A([i,c]);return S!==null&&L!==null&&S<=L?b.slice(S,L):null}function Fn(e,t){let n=e;for(let o of t.path)if(n=o==="content"?n?.content:n?.childNodes[o],!n)return null;return[n,t.offset]}function _s(e,t){if(!e||!t)return null;let n=Fn(e,t.start),o=Fn(e,t.end);return n&&o?{startContainer:n[0],startOffset:n[1],endContainer:o[0],endOffset:o[1]}:null}var Vs=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Ws(e,t,n){if(!t)return;let o=new Map,r=new Map,i=s=>{if(!s)return null;if(r.has(s))return r.get(s);let m=s.local.map(h=>Fn(t.localRoot,{path:h,offset:0})?.[0]).map(h=>h&&n(h)).filter(Boolean).map(h=>({node:h,parent:h.parentNode,previous:h.previousSibling,next:h.nextSibling,fragment:Vs(h)}));return r.set(s,m),m},c=s=>{let a=_s(t.localRoot,s);if(!a)return null;let m=n(a.startContainer),h=n(a.endContainer);if(!m||!h)return null;let d={...a,startContainer:m,endContainer:h};return Kn(d)?d:null};for(let s of e){let a=s.recovery;if(o.has(a))continue;let m={subject:i(a.subject),span:null,scope:null,touched:new Set};if(a.text){m.span=c(a.text.local.span),m.scope=c(a.text.local.scope);let h=m.span;if(h){let d=h.startContainer.ownerDocument.createRange();d.setStart(h.startContainer,h.startOffset),d.setEnd(h.endContainer,h.endOffset);let b=A=>{if(d.intersectsNode(A)){m.touched.add(A);for(let S of A.childNodes)b(S)}};b(d.commonAncestorContainer)}}if(a.structure){for(let h of[a.structure.localPlacement])h&&(i(h.parent),h.before.forEach(i),h.after.forEach(i));for(let h of a.structure.localOrder||[])i(h)}o.set(a,m)}t.localState={states:o,refs:r}}function $s(e,t,n,o){let r=n.localState?.states.get(e);if(!r)return!1;let i=s=>{let a=s.node;if(!o(a)||a.parentNode!==s.parent)return!1;let m=h=>Array.prototype.indexOf.call(a.parentNode.childNodes,h);return!(s.previous&&o(s.previous)&&s.previous.parentNode===a.parentNode&&m(s.previous)>=m(a)||s.next&&o(s.next)&&s.next.parentNode===a.parentNode&&m(s.next)<=m(a))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!r.subject.length||!r.subject.every(i))return!1;if(e.text){let s=e.text.local,a=m=>m&&o(m.startContainer)&&o(m.endContainer);return a(r.span)&&a(r.scope)&&Bn(r.scope,e.text.encoding)===s.text&&Bn(r.span,e.text.encoding)===s.text.slice(s.start,s.end)}if(e.attribute){let s=e.attribute,a=r.subject[0].node;return(s.namespaceURI?a.getAttributeNS(s.namespaceURI,s.localName):a.getAttribute(s.qualifiedName))===t.local}let c=e.structure;if(c.localOrder){let s=-1,a=null;for(let m of c.localOrder){let h=n.localState.refs.get(m)?.[0]?.node;if(!h||!o(h)||a&&h.parentNode!==a)return!1;let d=Array.prototype.indexOf.call(h.parentNode.childNodes,h);if(d<=s)return!1;a=h.parentNode,s=d}return!0}return c.localAction==="moved"||r.subject.every(s=>Vs(s.node)===s.fragment)}var Uc=1,Jt=e=>!!e&&e.nodeType===1,Qo=e=>Jt(e)&&e.tagName==="TEMPLATE"&&!!e.content;function zn(e,t=null,n=null){let o=new Map,r=new Map,i=h=>{if(!t){t=new WeakMap;let d=[e];for(;d.length;){let b=d.pop();Qo(b)&&(t.set(b.content,b),d.push(b.content));for(let A=b.firstChild;A;A=A.nextSibling)A.nodeType===1&&d.push(A)}}return t.get(h)||null},c=(h,d)=>{let b=r.get(h);if(!b){b=new Map;let A=0;for(let S=h.firstChild;S;S=S.nextSibling)b.set(S,A++);r.set(h,b)}return b.get(d)},s=h=>{if(!h)return null;if(n&&n.has(h))return s(n.get(h));if(h===e)return[];let d=o.get(h);if(d!==void 0)return d;let b=h.parentNode,A=null;if(b&&b.nodeType===11){let S=i(b),L=S?s(S):null;L&&(A=L.concat(["content",c(b,h)]))}else if(b){let S=s(b);S&&(A=S.concat([c(b,h)]))}return o.set(h,A),A};return{root:e,pathOf:s,logicalParent:h=>{let d=h.parentNode;return d&&d.nodeType===11?i(d):d},indexIn:c,containerPath:h=>{if(h.nodeType===11){let b=i(h),A=s(b);return A?A.concat(["content"]):null}let d=s(h);return d&&Qo(h)?d.concat(["content"]):d},ownerOf:i}}var wn=e=>Qo(e)?e.content:e;function qs(e){let{L:t,R:n,unitsOf:o,provenance:r,policy:i}=e,c=[];return{note:(h,d)=>{c.push([h,d])},finish:h=>c.length?m(h):null};function m(h){let d={base:zn(e.roots.base),local:zn(e.roots.local),remote:zn(e.roots.remote)},b=y=>y==="local"?t:n,A=(y,T)=>{if(!T)return null;if(y.map.has(T))return y.map.get(T);let P=[],p=Jt(T)?d.base.logicalParent(T):T.parent;for(;p&&!y.map.has(p);p=d.base.logicalParent(p))P.push(p);if(!p||!y.identical.has(p))return null;let k=y.map.get(p);for(let R=P.length-1;R>=0&&k;R--)k=wn(k).childNodes[d.base.indexIn(P[R].parentNode,P[R])];return k?Jt(T)?wn(k).childNodes[d.base.indexIn(T.parentNode,T)]||null:o(k)[o(T.parent).indexOf(T)]||null:null},S=new Map,L=new Map,f=new WeakMap,g=0,x=(y,T)=>{let P=S.get(y);P||S.set(y,P=[]),P.push(T)};(function y(T){L.set(T,g++);let P=r.get(T);if(P&&!P.pinned){for(let p of[P.base,P.local,P.remote])if(p)if(Array.isArray(p))for(let k of p)x(k,T);else x(p,T)}if(Qo(T)){f.set(T.content,T);for(let p=T.content.firstChild;p;p=p.nextSibling)y(p)}for(let p=T.firstChild;p;p=p.nextSibling)y(p)})(h);let Q=new Map;d.out=zn(h,f,Q);let se={refs:new Map,spans:new Map,anchors:new Map,via:Q,outOwners:f,outRoot:h,localRoot:e.roots.local},le=y=>Jt(y)?[y]:y.nodes,q=(y,T)=>{let P=d[T].logicalParent(y);if(!P)return null;for(let p of o(P))if(!Jt(p)&&p.nodes.includes(y))return p;return null},z=(y,T)=>y==null?null:Array.isArray(y)?y.length?q(y[0],T):null:y,ce=y=>{let T=new Set,P=[];for(let p of y)for(let k of S.get(p)||[])T.has(k)||(T.add(k),P.push(k));return P.sort((p,k)=>L.get(p)-L.get(k))},xe=new Map,te=y=>{let T=y.b||y.l||y.r,P=xe.get(T);if(P)return P;let p=[];for(let k of[y.b,y.l,y.r])k&&p.push(...le(k));return P=ce(p),xe.set(T,P),P},J=y=>({b:y,l:A(t,y),r:A(n,y)}),Ce=(y,T)=>{let P=b(T).reverse.get(y);if(P)return J(P);for(let p of ce(le(y))){let k=r.get(p);if(k&&!k.base&&k.local&&k.remote)return{b:null,l:z(k.local,"local"),r:z(k.remote,"remote")}}return T==="local"?{b:null,l:y,r:null}:{b:null,l:null,r:y}},we=new Map,ne=y=>{let T=r.get(y);if(!T||T.pinned)return null;let P=z(T.base,"base");if(P)return J(P);let p=z(T.local,"local"),k=z(T.remote,"remote");if(p){let R=t.reverse.get(p);if(R)return J(R)}if(k){let R=n.reverse.get(k);if(R)return J(R)}return p||k?{b:null,l:p,r:k}:null},_=y=>(we.has(y)||we.set(y,ne(y)),we.get(y)),ye=(y,T)=>Jt(y)?d[T].logicalParent(y):y.parent,ge=new Map,Oe=new Map,Be=(y,T)=>(Jt(y)?[d[T].pathOf(y)]:y.nodes.map(P=>d[T].pathOf(P))).filter(Boolean),We=y=>{let T=y.b||y.l||y.r,P=y.b?"base":y.l?"local":"remote",p=Oe.get(T);if(p)return p;let k=!Jt(T),R=Be(T,P)[0],$=`${P[0]}:${JSON.stringify(R===void 0?null:R)}${k?":run":""}`,H=ge.get($);if(H)return Oe.set(T,H),H;let F=te(y);return H={key:$,nodeType:Jt(T)?1:T.kind==="comment"?8:3,base:y.b?Be(y.b,"base"):[],local:y.l?Be(y.l,"local"):[],remote:y.r?Be(y.r,"remote"):[],merged:F.map(N=>d.out.pathOf(N)).filter(Boolean),live:[]},ge.set($,H),Oe.set(T,H),se.refs.set(H,F),H},rt={base:new Map,local:new Map,remote:new Map},re=new Map,ut=(y,T)=>{let P=ye(y,T);if(!P||P.nodeType!==1)return null;let p=rt[T].get(P);if(!p){let R=o(P),$=H=>We(T==="base"?J(H):Ce(H,T));p={parent:$(P),refs:R.map($),index:new Map(R.map((H,F)=>[H,F]))},rt[T].set(P,p)}let k=p.index.get(y)??-1;return{parent:p.parent,before:p.refs.slice(k+1),after:p.refs.slice(0,Math.max(0,k)).reverse()}},dt=y=>{let T=y.parentNode;if(!T)return null;let P=re.get(T);if(!P){let k=T.nodeType===11?f.get(T):T,R=k&&k.nodeType===1?_(k):null;if(!R)return null;let $=[],H=[],F=new Map;for(let E of T.childNodes){let G=_(E),he=G&&We(G),ve=$.length,u=$.length-1;he&&he!==$[u]&&($.push(he),u++);let v={ref:he,group:u,after:ve};H.push(v),F.set(E,v)}let N=$.length;for(let E=H.length-1;E>=0;E--){let G=H[E];G.before=N,G.ref&&(N=G.group)}P={parent:We(R),refs:$,index:F},re.set(T,P)}let p=P.index.get(y);return{parent:P.parent,before:P.refs.slice(p.before),after:P.refs.slice(0,p.after).reverse()}},Se=y=>Jt(y)?y.outerHTML:y.value,O=y=>Jt(y)?"element":y.kind==="comment"?"comment":"text",B=(y,T)=>({path:y,offset:T}),ae=(y,T,P)=>{if(!y)return null;let p=d[P],k=0;if(T){let R=Jt(T)?T:T.nodes[T.nodes.length-1];R.parentNode&&(k=p.indexIn(R.parentNode,R)+1)}return B(p.containerPath(y),k)},be=(y,T)=>{let P=ye(y,"base"),p=P?A(b(T),P):null;if(!Jt(p))return null;let k=o(P),R=null;for(let $=k.indexOf(y)-1;$>=0&&!R;$--){let H=A(b(T),k[$]);H&&ye(H,T)===p&&(R=H)}return ae(p,R,T)},de=(y,T,P,p)=>{let k=d[p],R=0;for(let $=0;$<y.nodes.length;$++){let H=y.nodes[$],F=H.nodeValue.length,N=$===y.nodes.length-1;if((P==="start"?T<R+F:T<=R+F)||N)return B(k.pathOf(H),Math.max(0,Math.min(T-R,F)));R+=F}return null},ze=(y,T)=>{let P=d[T],p=y.firstChild,k=y.lastChild;return p&&p.nodeType===3&&k.nodeType===3?{start:B(P.pathOf(p),0),end:B(P.pathOf(k),k.nodeValue.length)}:{start:B(P.pathOf(y),0),end:B(P.pathOf(y),y.childNodes.length)}},De=(y,T,P)=>{for(let $ of y.nodes)if(P==="start"?$.s<=T&&T<$.e:$.s<T&&T<=$.e)return{kind:"text",node:$.node,offset:T-$.s};let p=P==="start"?T:T-1,k=()=>{for(let $ of y.nodes)if($.s===T||$.e===T)return{kind:"text",node:$.node,offset:T-$.s};return null},R=y.atomAt.get(p);if(R)return{kind:P==="start"?"before":"after",node:R.el};if(y.text[p]===gt){let $=y.marks.find(F=>F.block&&F.to===p+1);if($)return P==="start"?{kind:"end",node:$.el}:{kind:"after",node:$.el};let H=y.marks.find(F=>F.block&&F.from===p+1);if(H)return P==="start"?{kind:"before",node:H.el}:{kind:"startOf",node:H.el}}return k()},Qe=(y,T)=>De(y,T,"end")||De(y,T,"start"),st=(y,T)=>{switch(T.kind){case"text":return B(y.pathOf(T.node),T.offset);case"end":return B(y.containerPath(T.node),wn(T.node).childNodes.length);case"startOf":return B(y.containerPath(T.node),0);default:{let P=T.node.parentNode;return B(y.containerPath(P),y.indexIn(P,T.node)+(T.kind==="after"?1:0))}}},wt=(y,T,P,p,k)=>{let R=De(y,T,P);return R?st(d[p],R):k()},bt=(y,T,P,p)=>{let k=y.textNodes.map(N=>({s:N.ms,e:N.me,start:{kind:"text",node:N.node,offset:0},end:{kind:"text",node:N.node,offset:N.me-N.ms}}));for(let[N,E]of y.atomOut)k.push({s:N,e:N+1,start:{kind:"before",node:E},end:{kind:"after",node:E}});for(let[N,E]of y.breakOut)k.push({s:N,e:N+1,start:{kind:"end",node:E},end:{kind:"after",node:E}});for(let N of k)if(N.start.kind==="text"&&N.s<T&&T<N.e)return{kind:"text",node:N.start.node,offset:T-N.s};if(P!=="empty"){let N=k.find(E=>P==="start"?E.s===T:E.e===T);if(N)return P==="start"?N.start:N.end}let R=k.find(N=>N.e===T);if(R)return R.end;let $=k.find(N=>N.s===T);if($)return $.start;let H=null,F=null;for(let N of k)N.e<=T&&(!H||N.e>H.e)&&(H=N),N.s>=T&&(!F||N.s<F.s)&&(F=N);return H?H.end:F?F.start:p()},Tt=(y,T)=>{if(!T)return null;if(T.kind==="text"){let k=y.nodes.find(R=>R.node===T.node);return k?k.s+Math.min(T.offset,k.e-k.s):null}let P=y.atoms.find(k=>k.el===T.node);if(P)return T.kind==="after"?P.i+1:P.i;let p=y.marks.find(k=>k.el===T.node);return p?T.kind==="before"&&p.block&&y.text[p.from-1]===gt&&!y.marks.some(k=>k.block&&k.to===p.from)?p.from-1:T.kind==="startOf"||T.kind==="before"?p.from:T.kind==="end"&&p.block?p.to-1:p.to:null},nn=(y,T,P,p)=>{for(let H of y.nodes)if(P==="start"?H.s<=T&&T<H.e:H.s<T&&T<=H.e)return{kind:"text",node:H.node,offset:T-H.s};let k=P==="start"?T:T-1;if(!y.atomAt.has(k)&&y.text[k]!==gt){for(let H of y.nodes)if(H.s===T||H.e===T)return{kind:"text",node:H.node,offset:T-H.s}}let R=y.atomAt.get(k);if(R)return{kind:P==="start"?"before":"after",node:R.el};if(y.text[k]===gt){let H=y.marks.find(N=>N.block&&N.to===k+1);if(H)return P==="start"?{kind:"end",node:H.el}:{kind:"after",node:H.el};let F=y.marks.find(N=>N.block&&N.from===k+1);if(F)return P==="start"?{kind:"before",node:F.el}:{kind:"startOf",node:F.el}}let $=y.marks.find(H=>H.block&&H.from===T);return $?{kind:"startOf",node:$.el}:p?{kind:P==="start"?"startOf":"end",node:p}:null},Fe=y=>{if(!y)return null;if(y.kind==="wholeStart"||y.kind==="wholeEnd"){let T=Qt(y.node);return y.kind==="wholeStart"?T.start:T.end}return st(d.out,y)},Qt=y=>{let T=y.firstChild,P=y.lastChild;return T&&T.nodeType===3&&P.nodeType===3?{start:B(d.out.pathOf(T),0),end:B(d.out.pathOf(P),P.nodeValue.length)}:{start:B(d.out.pathOf(y),0),end:B(d.out.pathOf(y),y.childNodes.length)}},Xt=y=>{let T=ye(y,"base"),P=T?te(J(T))[0]:null;if(!P)return null;let p=wn(P),k=o(T);for(let R=k.indexOf(y)-1;R>=0;R--){let $=te(J(k[R])).filter(H=>H.parentNode===p);if($.length)return{kind:"after",node:$[$.length-1]}}return{kind:"startOf",node:P}},Bt=(y,T,P,p,k,R)=>({text:y,start:T,end:P,fragment:p,span:k,scope:R}),Et=(y,T,P,p,k)=>Bt(y,T,P,y.slice(T,P),p,k),Lt=(y,T,P,p,k)=>(se.spans.set(y,{start:T,end:P,scopeStart:p,scopeEnd:k}),y),sn=new Map,M=new Map,Z=(y,T,P)=>{let p=`text:${y.key}:${T}:${P}`,k=M.get(p)||0;return M.set(p,k+1),`${p}:${k}`},ee=(y,T)=>{let P,p,k,R="plain",$,H,F,N,E,G=(u,v,j,U,V)=>{if(!u){let W=be(V,U);return Et("",0,0,{start:W,end:W},{start:W,end:W})}return Et(u.value,v,j,{start:de(u,v,v===j?"end":"start",U),end:de(u,j,"end",U)},{start:de(u,0,"start",U),end:de(u,u.value.length,"end",U)})};if(T.site==="run"){let{bRun:u,lRun:v,rRun:j,node:U,c:V}=T;P=J(u),p=V.bs,k=V.be,$=G(u,V.bs,V.be,"base",u),H=G(v,V.ls,V.le,"local",u),F=G(j,V.rs,V.re,"remote",u);let W=U?U.nodeValue:"",Y=ie=>U?{kind:"text",node:U,offset:ie}:Xt(u);N=Lt(Et(W,V.ms,V.me,{start:Fe(Y(V.ms)),end:Fe(Y(V.me))},{start:Fe(Y(0)),end:Fe(Y(W.length))}),Y(V.ms),Y(V.me),Y(0),Y(W.length)),E=U||(Xt(u)||{}).node||null}else if(T.site==="whole"){let u=T.el,v=r.get(u);P=J(v.base),p=0,k=y.base.length;let j=(V,W,Y)=>{let ie=ze(W,Y);return Et(V,0,V.length,ie,ie)};$=j(y.base,v.base,"base"),H=j(y.local,v.local,"local"),F=j(y.remote,v.remote,"remote");let U=Qt(u);N=Lt(Et(y.resolved,0,y.resolved.length,U,U),{kind:"wholeStart",node:u},{kind:"wholeEnd",node:u},{kind:"wholeStart",node:u},{kind:"wholeEnd",node:u}),E=u}else if(T.site==="comment"){let{bRun:u,lRun:v,rRun:j,node:U}=T;P=J(u),p=0,k=y.base.length;let V=(Ne,Le)=>{if(!Ne){let je=be(u,Le);return Et("",0,0,{start:je,end:je},{start:je,end:je})}let Me=Ne.nodes[0],Ze={start:B(d[Le].pathOf(Me),0),end:B(d[Le].pathOf(Me),Ne.value.length)};return Et(Ne.value,0,Ne.value.length,Ze,Ze)};$=V(u,"base"),H=V(v,"local"),F=V(j,"remote");let W=y.resolved,Y=Ne=>U?{kind:"text",node:U,offset:Ne}:Xt(u),ie={start:Fe(Y(0)),end:Fe(Y(W.length))};N=Lt(Et(W,0,W.length,ie,ie),Y(0),Y(W.length),Y(0),Y(W.length)),E=U||(Xt(u)||{}).node||null}else{let{fb:u,fl:v,fr:j,scope:U}=T,V=T.merged;R="html",P=U.base?J(U.base):Ce(U.local,"local"),p=y.bs,k=y.be;let W=at=>{let St=U[at];for(let At=U.at-1;At>=0;At--){let Ht=U.units[At],Zt=at==="base"?Ht:A(b(at),Ht);if(Zt&&ye(Zt,at)===St)return Zt}return null},Y=at=>()=>ae(U[at],W(at),at),ie=(at,St,At,Ht,Zt)=>{let un=He=>He?st(d[Zt],He):Y(Zt)(),In=St===At?Qe(at,St):De(at,St,"start"),Cn=St===At?Qe(at,St):De(at,At,"end"),xn=un(In),cn={start:xn,end:St===At?xn:un(Cn)},zt=T.full?T.full(Zt):null;if(!zt)return Bt(at.text,St,At,Ht,cn,{start:un(De(at,0,"start")),end:un(De(at,at.text.length,"end"))});let X=In?Tt(zt,In):null,Re=Cn?Tt(zt,Cn):null,Ae=X===null?0:X,Ge=Math.max(Ae,Re===null?zt.text.length:Re),ct=un(De(zt,0,"start"));return Bt(zt.text,Ae,Ge,io(zt,Ae,Ge),cn,{start:ct,end:zt.text.length?un(De(zt,zt.text.length,"end")):ct})};$=T.synthetic?null:ie(u,y.bs,y.be,y.base,"base"),H=ie(v,y.lss,y.lse,y.local,"local"),F=ie(j,y.rss,y.rse,y.remote,"remote");let[Ne,Le]=y.range||[0,0],Me=V.out,Ze=()=>{let at=wn(V.node);for(let St=U.at-1;St>=0;St--){let At=te(J(U.units[St])).filter(Ht=>Ht.parentNode===at);if(At.length)return{kind:"after",node:At[At.length-1]}}for(let St=U.at;St<U.units.length;St++){let At=te(J(U.units[St])).filter(Ht=>Ht.parentNode===at);if(At.length)return{kind:"before",node:At[0]}}return{kind:"startOf",node:V.node}};if(Me.via)for(let[at,St]of Me.via)Q.set(at,St);let je=bt(V,Ne,Ne===Le?"empty":"start",Ze),Ot=Ne===Le?je:bt(V,Le,"end",Ze),Ue=Me.text.length?nn(Me,0,"start",V.node):Ze(),ht=Me.text.length?nn(Me,Me.text.length,"end",V.node):Ue,it=Tt(Me,je),Kt=Tt(Me,Ot),Rt=it===null?0:it,qt=Math.max(Rt,Kt===null?Me.text.length:Kt);N=Lt(Bt(Me.text,Rt,qt,io(Me,Rt,qt),{start:Fe(je),end:Fe(Ot)},{start:Fe(Ue),end:Fe(ht)}),je,Ot,Ue,ht);let It=se.spans.get(N);if(It.flat=Me,!Me.text.length){let at=Fe(Ue),St=Fn(h,at),At=St[0],Ht=St[1];It.empty={parent:At.nodeType===11?f.get(At):At,previous:At.childNodes[Ht-1]||null,next:At.childNodes[Ht]||null}}E=je?je.node:V.node}let he=We(P),ve=(T.site==="whole"||T.site==="comment"||i!=="both")&&y.resolved!==y.local;return{key:T.site==="comment"&&sn.get(P.b||P.l||P.r)||Z(he,p,k),subject:he,localLost:ve,anchor:E,text:{encoding:R,base:$,local:H,remote:F,merged:N,liveSpan:null,liveScope:null}}},ue=(y,T)=>{let P=_(T.el),p=We(P),k=T.sample;return{key:`attr:${p.key}:${k.namespaceURI||""}:${k.localName}`,subject:p,localLost:y.resolved!==y.local,anchor:T.el,attribute:{namespaceURI:k.namespaceURI||null,localName:k.localName,qualifiedName:k.name}}},oe=(y,T)=>{let P=y.detail,p=T.unit||J(T.subject),k=We(p),R=se.refs.get(k),$=p.l?ut(p.l,"local"):null,H=p.r?ut(p.r,"remote"):null,F=R.length?dt(R[0]):null,N,E,G,he=null,ve=null,u=T.deleted;switch(P){case"both-reordered":{N=E="reordered";let v=new Set(T.rKept),j=T.lKept.filter(ie=>v.has(ie)&&te(J(ie)).length),U=ie=>L.get(te(J(ie))[0]);he=j.map(ie=>We(J(ie))),ve=j.slice().sort((ie,Ne)=>U(ie)-U(Ne)).map(ie=>We(J(ie)));let V=ie=>!Jt(ie)&&ie.kind!=="comment"&&ie.nodes.every(Ne=>!/[^\t\n\f\r ]/.test(Ne.data)),W=j.filter(ie=>!V(ie)),Y=W.slice().sort((ie,Ne)=>U(ie)-U(Ne));G=W.some((ie,Ne)=>ie!==Y[Ne]);break}case"both-moved":N=E="moved",G=!$||!R.some(v=>{let j=v===R[0]?F:dt(v);return j&&j.parent===$.parent});break;case"edit-beats-delete":N=u==="local"?"deleted":"edited",E=u==="remote"?"deleted":"edited",G=u==="local";break;case"move-beats-delete":N=u==="local"?"deleted":"moved",E=u==="remote"?"deleted":"moved",G=u==="local";break;default:N=E="inserted",G=T.localLost}return{key:`structure:${k.key}:${P}`,subject:k,localLost:G,anchor:R[0]||null,structure:{localAction:N,remoteAction:E,localPlacement:$,remotePlacement:H,mergedPlacement:F,localOrder:he,mergedOrder:ve,localFragment:P==="both-reordered"||!p.l?null:Se(p.l),fragmentKind:O(p.b||p.l||p.r)}}};for(let[y,T]of c){if(y.kind!=="structure")continue;let P=T.unit||J(T.subject),p=P.b||P.l||P.r;!Jt(p)&&p.kind==="comment"&&sn.set(p,`structure:${We(P).key}:${y.detail}`)}let fe=new Map;for(let[y,T]of c){if(y.kind==="structure"){let R=We(T.unit||J(T.subject)),$=`structure:${R.key}:${y.detail}`,H=fe.get($);if(H&&H.structure){y.recovery=H;let F=se.refs.get(R);y.el==null&&F.length&&(y.el=Jt(F[0])?F[0]:d.out.logicalParent(F[0]));continue}}let P=y.kind==="text"?ee(y,T):y.kind==="attr"?ue(y,T):oe(y,T),p=fe.get(P.key);p||(p={version:Uc,key:P.key,localLost:P.localLost,subject:P.subject,applied:!1,unavailable:null},fe.set(P.key,p),se.anchors.set(p,P.anchor)),P.text&&(p.text=P.text),P.attribute&&(p.attribute=P.attribute),P.structure&&(p.structure=P.structure),P.text&&(p.localLost=P.localLost),y.recovery=p;let k=se.refs.get(P.subject);y.kind==="structure"&&y.el==null&&k.length&&(y.el=Jt(k[0])?k[0]:d.out.logicalParent(k[0])),y.kind==="text"&&y.node==null&&k.length&&P.subject.nodeType===8&&(y.node=k[0])}return se}}function Fs(e,t,n){if(!t)return;let{lookup:o,vetoed:r,vetoedAttrs:i,liveAttr:c}=n,s=n.ignored||(()=>!1),a=zn(n.liveRoot),m=ne=>!!ne&&a.containerPath(ne)!==null,h=ne=>{let _=ne.parentNode;return _&&_.nodeType===11?t.outOwners.get(_)||null:_},d=ne=>{for(let _=ne;_;_=h(_))if(t.via.has(_)&&(_=t.via.get(_)),r.has(_)||n.vetoedLive?.has(g(_)))return!0;return!1},b=ne=>Array.from(wn(ne).children).filter(_=>!s(_)),A=(ne,_)=>b(ne)[b(_.parentNode).indexOf(_)],S=(ne,_)=>{let ye=null,ge=null,Oe=0;for(let re=_.previousSibling;re;re=re.previousSibling){if(re.nodeType===1&&!s(re)){ye=re;break}re.nodeType===3&&(Oe+=re.nodeValue.length)}for(let re=_.nextSibling;re&&!ge;re=re.nextSibling)re.nodeType===1&&!s(re)&&(ge=re);let Be=ye?A(ne,ye):null,We=ge?A(ne,ge):null;if(ye&&!Be||ge&&!We)return null;let rt=[];for(let re=Be?Be.nextSibling:wn(ne).firstChild;re&&re!==We;re=re.nextSibling)re.nodeType===3&&rt.push(re);return rt.length?{nodes:rt,lead:Oe}:null},L=ne=>{let _=[],ye=ne;for(;ye&&!t.via.has(ye);ye=ye.parentNode)_.push(ye);if(!ye||!_.length)return null;let ge=g(t.via.get(ye));for(let We=_.length-1;We>0&&ge;We--)ge=A(ge,_[We]);if(!ge)return null;let Oe=_[0];if(Oe.nodeType===3)return S(ge,Oe);let Be=Oe.nodeType===1?A(ge,Oe):null;return Be?{nodes:[Be],lead:0}:null},f=ne=>{let _=o(ne),ye=_?{nodes:Array.isArray(_)?_:[_],lead:0}:t.via.size?L(ne):null;if(!ye)return null;let ge=ye.nodes.filter(m);return ge.length?{nodes:ge,lead:ye.lead}:null},g=ne=>{let _=f(ne);return _?_.nodes[0]:null},x=ne=>{if(!ne)return null;if(ne.kind==="text"){let Oe=f(ne.node);if(!Oe)return null;let Be=Oe.nodes,We=ne.offset+Oe.lead,rt=0;for(let re=0;re<Be.length;re++){let ut=Be[re].nodeValue.length;if(We<=rt+ut||re===Be.length-1)return We>=rt&&We<=rt+ut?[Be[re],We-rt]:null;rt+=ut}return null}let _=g(ne.node);if(!_)return null;if(ne.kind==="end")return[wn(_),wn(_).childNodes.length];if(ne.kind==="startOf")return[wn(_),0];if(ne.kind==="wholeStart")return _.firstChild?[_.firstChild,0]:[_,0];if(ne.kind==="wholeEnd")return _.lastChild?[_.lastChild,_.lastChild.nodeValue.length]:[_,_.childNodes.length];let ye=_.parentNode;if(!ye)return null;let ge=Array.prototype.indexOf.call(ye.childNodes,_);return[ye,ne.kind==="after"?ge+1:ge]},Q=ne=>({blocks:new Set((ne.flat?.marks||[]).filter(_=>_.block).map(_=>g(_.el)).filter(Boolean)),atoms:new Set((ne.flat?.atoms||[]).map(_=>g(_.el)).filter(Boolean)),ignored:s}),se=(ne,_,ye,ge)=>{if(!ne||!_||!Kn(ne)||!Kn(_))return!1;for(let We of[ne,_])if(!m(We.startContainer)||!m(We.endContainer))return!1;let Oe=ye.merged;if(Oe.start===Oe.end&&(ne.startContainer!==ne.endContainer||ne.startOffset!==ne.endOffset))return!1;let Be=Q(ge);return Bn(_,ye.encoding,Be)===Oe.text&&Bn(ne,ye.encoding,Be)===Oe.text.slice(Oe.start,Oe.end)},le=new Map,q=ne=>{let _=ne.parentNode;return _?(le.has(_)||le.set(_,new Map(Array.from(_.childNodes,(ye,ge)=>[ye,ge]))),le.get(_).get(ne)):-1},z=(ne,_)=>{if(!_)return!1;let ye=a.logicalParent(ne);if(!_.parent.live.includes(ye))return!1;let ge=q(ne);for(let[Oe,Be]of[["before",1],["after",-1]]){let We=ge;for(let rt of _[Oe]){if(rt.live.includes(ne))continue;let re=rt.live.filter(dt=>dt!==ne&&dt.parentNode===ne.parentNode);if(!re.length)continue;let ut=Be===1?Math.min(...re.map(q)):Math.max(...re.map(q));if(Be*(ut-We)<=0)return!1;We=ut}}return!0},ce=ne=>{let _=ne.structure;if(_.mergedOrder){let ye=new Set(ne.subject.live.map(wn)),ge=null,Oe=-1;for(let Be of _.mergedOrder){let We=Be.live.find(rt=>ye.has(rt.parentNode));if(!We||ge&&We.parentNode!==ge||q(We)<=Oe)return!1;ge=We.parentNode,Oe=q(We)}return ne.subject.live.length>0}return ne.subject.live.some(ye=>z(ye,_.mergedPlacement))},xe=(ne,_)=>{let ye=x(ne),ge=x(_);return ye&&ge?{startContainer:ye[0],startOffset:ye[1],endContainer:ge[0],endOffset:ge[1]}:null},te=new Set,J=ne=>{if(!ne||te.has(ne))return;te.add(ne);let _=[];for(let ye of t.refs.get(ne)||[]){let ge=f(ye);if(ge)for(let Oe of ge.nodes)_.includes(Oe)||_.push(Oe)}ne.live=_},Ce=ne=>{ne&&(J(ne.parent),ne.before.forEach(J),ne.after.forEach(J))},we=new Set;for(let ne of e){let _=ne.recovery;if(!_||we.has(_))continue;we.add(_),J(_.subject),_.structure&&(Ce(_.structure.localPlacement),Ce(_.structure.remotePlacement),Ce(_.structure.mergedPlacement),(_.structure.localOrder||[]).forEach(J),(_.structure.mergedOrder||[]).forEach(J));let ye=t.anchors.get(_),ge=ye?g(ye):null,Oe=!!ge;if(_.text){let O=t.spans.get(_.text.merged),B=O?xe(O.start,O.end):null,ae=O?xe(O.scopeStart,O.scopeEnd):null;if(O?.empty){let be=O.empty,de=be.previous?{kind:"after",node:be.previous}:{kind:"startOf",node:be.parent},ze=be.next?{kind:"before",node:be.next}:{kind:"end",node:be.parent},De=xe(de,ze);!De||De.startContainer!==De.endContainer||De.startOffset!==De.endOffset?B=null:B=ae=De}se(B,ae,_.text,O)||(B=ae=null),_.text.liveSpan=B,_.text.liveScope=B?ae:null,B||(Oe=!1)}_.structure&&Oe&&(Oe=ce(_)),_.attribute&&Oe&&(Oe=c(ge,_.attribute,ne.resolved));let Be=(!!_.attribute||!!_.text&&ge?.tagName==="TEXTAREA")&&!!i&&[ye,ge].some(O=>i.get(O)?.has(_.attribute?_.attribute.qualifiedName:"value")),We=t.localState?.states.get(_),rt=!!_.text&&[...n.removedVetoes||[]].some(O=>We?.touched.has(O)),re=_.structure?.localAction==="inserted"&&[...r].some(O=>O===ye||ye?.contains(O)),ut=ye&&d(ye)||Be||rt||re,dt=ut&&$s(_,ne,t,m);dt&&(rt||re&&_.localLost)&&(Oe=!1);let Se=!Oe&&dt&&ut;_.applied=Oe,_.unavailable=Oe?null:Se?"hook-veto":"missing-output",Se&&(_.localLost=!1),!Oe&&_.text&&(_.text.liveSpan=_.text.liveScope=null)}}function Zo(e,t,n){let o=zn(t),r=zn(n),i=d=>!!d&&r.containerPath(d)!==null,c=d=>{if(d===t)return n;let b=o.pathOf(d);if(b&&t!==n){let A=Fn(n,{path:b,offset:0});if(A&&A[0].nodeType===d.nodeType)return A[0]}return d},s=new Set,a=d=>{!d||s.has(d)||(s.add(d),d.live=d.live.map(c).filter(i))},m=d=>{d&&(d.startContainer=c(d.startContainer),d.endContainer=c(d.endContainer))},h=new Set;for(let d of e){d.node===t&&n.tagName==="SCRIPT"&&(d.node=n),d.el===t&&d.kind==="structure"&&(d.el=n);let b=d.recovery;if(!b||h.has(b))continue;if(h.add(b),a(b.subject),b.text){m(b.text.liveSpan),m(b.text.liveScope);let S=b.text.liveSpan,L=b.text.liveScope,f=b.text.merged,g=x=>!!x&&Kn(x)&&i(x.startContainer)&&i(x.endContainer);(!g(S)||!g(L)||Bn(L,b.text.encoding)!==f.text||Bn(S,b.text.encoding)!==f.text.slice(f.start,f.end))&&(b.text.liveSpan=null,b.text.liveScope=null,b.applied=!1,b.unavailable="missing-output")}let A=b.structure;if(A){for(let S of[A.localPlacement,A.remotePlacement,A.mergedPlacement])S&&(a(S.parent),S.before.forEach(a),S.after.forEach(a));(A.localOrder||[]).forEach(a),(A.mergedOrder||[]).forEach(a),b.subject.live.length||(b.applied=!1,b.unavailable="missing-output")}}}var Xe=e=>!!e&&e.nodeType===1,_c=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" ")),Ks=5e4,So="[id],[data-id],script,head>*";function Pr(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let o=lo(n,e);if(o)return"merge:"+o.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?Ps(n,t):null}}function er(e,t,n,o){let r=o.ignored,i=o.stats||jn(),c=xs({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:i}),{unitsOf:s,meta:a}=c,m=o.baseURI,h=o.mergeTags!==null,d=Pr(o.mergeTags,m),b=u=>v=>{let j=d(v);return j!==null?j:u(v)},A=b(o.identity.base),S=b(o.identity.local),L=b(o.identity.remote),f=o.authored||o.identity,g=u=>u&&u.nodeType===9?u.documentElement:u,x=g(e),Q=g(t),se=g(n),le=globalThis.__hyperMorphProfile,q=le?performance.now():0,z=u=>u===fn?So:null,ce=o.scope||null,xe=ce?ce.baseIndex:zo(x,A,r,z(o.identity.base)),te=o.localIsBase||x===Q?Gs():yr(x,Q,{analyzer:c,baseIndex:xe,sideIndex:zo(Q,S,r,z(o.identity.local)),baseId:f.base,sideId:f.local,stats:i}),J=yr(x,se,{analyzer:c,baseIndex:xe,sideIndex:ce?ce.remoteIndex:zo(se,L,r,z(o.identity.remote)),baseId:f.base,sideId:f.remote,stats:i,scope:ce,comparisons:o.comparisons});if(ce){if(!ce.held(J))return null;for(let u of ce.dropped)gr(u)}let Ce=null;function we(u){if(!Ce){Ce=new WeakMap;let v=[x];for(;v.length;){let j=v.pop();j.tagName==="TEMPLATE"&&j.content&&Ce.set(j.content,j);for(let U of c.childrenOf(j))U.nodeType===1&&v.push(U)}}return Ce.get(u)||null}let ne=u=>{let v=Xe(u)||u.nodeType?u.parentNode:u.parent;return v&&v.nodeType===11?we(v):v};Tt(),nn(te,J),nn(J,te);for(let u of[te,J])if(u.refused)for(let v of u.refused)u.moved.has(v)||i.ambiguousMoves++;le&&(le.alignTotal=(le.alignTotal||0)+(performance.now()-q),q=performance.now());let _=x.ownerDocument.implementation.createHTMLDocument(""),ye=new WeakMap,ge=new WeakMap,Oe=[],Be=[],We=new Set,rt=[],re=new Set,ut=new Set,dt=new Set,Se=new WeakMap,O=o.conflicts||"remote",B=u=>Oe.push(u),ae=u=>Oe.push(u),be=qs({roots:{base:x,local:Q,remote:se},L:te,R:J,unitsOf:s,provenance:ye,policy:O}),de=(u,v)=>{Be.push(u),v&&be.note(u,v)},ze=wt(),De=Et(x,te.map.get(x),J.map.get(x),!!o.localIsBase,!!o.childrenOnly);De.tagName==="HTML"?_.replaceChild(De,_.documentElement):_.body.appendChild(De),le&&(le.build=(le.build||0)+(performance.now()-q));let Qe=o.childrenOnly?!H(R(De),R(se)):!P(De,se),st=be.finish(De);return{doc:_,root:De,provenance:ye,textMappers:ge,decisions:Oe,conflicts:Be,recoveryLinks:st,localDiverged:Qe,mergedScripts:We,segments:rt,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==fn,L:te,R:J,stats:i};function wt(){let u=new Map,v=new Set;if(o.localIsBase||!te.insertedByHash)return{partner:u,drop:v};let j=te.insertedByHash(),U=J.insertedByHash();if(!j.size||!U.size)return{partner:u,drop:v};let V={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},W=Ue=>{let ht=0;for(let it=Ue.parentNode;it;it=it.parentNode)ht++;return ht},Y=[],ie=Ue=>{let ht=Ue.textContent.trim();return ht.split(/\s+/).length>=3||ht.replace(/\s/g,"").length>=12},Ne=Ue=>{let ht=Fe(te,Ue),it=Fe(J,Ue);return ht&&te.reverse.get(ht.parentNode)!==Ue.parentNode||it&&J.reverse.get(it.parentNode)!==Ue.parentNode},Le=(Ue,ht,it)=>{for(let Rt of it.parentNode.children){let qt=Rt!==it&&Ue.reverse.get(Rt);if(qt&&Ne(qt))return!0}let Kt=Ue.reverse.get(it.parentNode);if(Kt){for(let Rt of Kt.children)if(!Fe(ht,Rt)&&!r(Rt))return!0}return!1};for(let[Ue,ht]of j){let it=U.get(Ue);if(!it)continue;let Kt=ht.length===1&&it.length===1;for(let Rt of ht)qn(Rt,V)||Y.push([Rt,it,W(Rt),Kt&&(ie(Rt)||Le(te,J,Rt)||Le(J,te,it[0]))])}if(!Y.length)return{partner:u,drop:v};Y.sort((Ue,ht)=>Ue[2]-ht[2]);let Me=new Set,Ze=new Set,je=Ue=>{for(let ht of Ue.querySelectorAll("*"))Me.add(ht)},Ot=(Ue,ht)=>Ue.reverse.get(ht.parentNode)||null;for(let[Ue,ht,,it]of Y){if(Me.has(Ue))continue;let Kt=Ot(te,Ue),Rt=It=>!Ze.has(It)&&!Me.has(It)&&It.tagName===Ue.tagName&&c.equalUnits(Ue,It),qt=ht.find(It=>Kt&&Ot(J,It)===Kt&&Rt(It))||(it?ht.find(Rt):null);qt&&(Ze.add(qt),je(Ue),je(qt),!(Kt&&Ot(J,qt)===Kt)&&(u.set(Ue,qt),u.set(qt,Ue),v.add(O==="local"?qt:Ue)))}return{partner:u,drop:v}}function bt(u,v,j){if(re.add(u),ze.drop.has(u))return null;re.add(j);let U=v==="local"?u:j,V=v==="local"?j:u,W;return c.equalUnits(U,V)?(W=y(U,"local",!0),ye.get(W).remote=V):W=fe(U,V),de({kind:"structure",el:W,detail:"both-moved",base:null,local:U,remote:V},{unit:{b:null,l:U,r:V}}),B({kind:"insert",el:W,source:"both"}),W}function Tt(){if(!te.weak||!J.weak||!te.weak.size||!J.weak.size||!te.unpair)return;let u=new Map;for(let j of te.weak){let U=Fe(te,j);Xe(j)&&Xe(U)&&u.set(c.unitHash(U),j)}let v=!1;for(let j of Array.from(J.weak)){let U=Fe(J,j);if(!Xe(j)||!Xe(U))continue;let V=u.get(c.unitHash(U));if(!V||V===j||!te.weak.has(V)||Fe(te,j)&&Fe(J,V))continue;let W=Fe(te,V);W.tagName===U.tagName&&c.equalUnits(W,U)&&(te.unpair(V),J.unpair(j),v=!0)}v&&(te.rematch(),J.rematch())}function nn(u,v){if(!u.weak||!u.weak.size||!v.insertedByHash)return;let j=v.insertedByHash();if(!j.size)return;let U=!1;for(let V of Array.from(u.weak)){let W=Fe(u,V);if(!W)continue;let Y=j.get(c.unitHash(W));Y&&Y.some(ie=>ie.tagName===W.tagName&&c.equalUnits(ie,W))&&(u.unpair(V),U=!0)}U&&u.rematch()}function Fe(u,v){if(!v)return null;if(u.map.has(v))return u.map.get(v);let j=[],U=ne(v);for(;U&&!u.map.has(U);U=ne(U))j.push(U);let V=U;if(!V||!u.identical.has(V))return null;u.pairIdenticalChildren(V);for(let Y=j.length-1;Y>=0;Y--)u.pairIdenticalChildren(j[Y]);let W=u.map.get(v)||null;return W&&i.lazyTwins++,W}function Qt(u,v,j){if(ut.has(u)||dt.has(u))return de({kind:"structure",el:null,detail:"both-moved",base:u},{subject:u}),ut.has(u)?null:y(j,v);let U=Fe(te,u),V=Fe(J,u);(!U||!V)&&de({kind:"structure",el:null,detail:"move-beats-delete",base:u},{subject:u,deleted:U?"remote":"local"});let W=Et(u,U,V,!1);return(v==="local"?B:ae)({kind:"move",el:W,source:v}),W}function Xt(u,v,j,U){return U||!v||v===j?{el:j,asBase:!0,twin:V=>V,baseOf:V=>V,units:s(j),here:()=>!0,parentOfTwin:()=>j}:{el:v,asBase:!1,twin:V=>Fe(u,V),baseOf:V=>u.reverse.get(V),units:s(v),here:V=>Xe(V)?V.parentNode===v||v.tagName==="TEMPLATE"&&V.parentNode===v.content:V.parent===v||v.tagName==="TEMPLATE"&&V.parent===v.content}}function Bt(u,v,j){return!v||j&&j.identical.has(u)?!1:Xe(u)?!c.equalUnits(u,v):u.value!==v.value}function Et(u,v,j,U,V=!1){let W=U||o.remoteWins(u),Y=u.namespaceURI&&u.namespaceURI!=="http://www.w3.org/1999/xhtml"?_.createElementNS(u.namespaceURI,u.tagName):_.createElement(u.tagName),ie={base:u,local:v||null,remote:j||null};if(ye.set(Y,ie),re.add(u),ut.add(u),v&&re.add(v),j&&re.add(j),o.skipUnchanged&&!V&&(o.localIsBase||te.identical.has(u))&&j&&J.identical.has(u)&&!o.remoteWins(u)){ie.unchanged=!0;for(let Le of u.attributes)Le.namespaceURI?Y.setAttributeNS(Le.namespaceURI,Le.name,Le.value):Y.setAttribute(Le.name,Le.value);return Y}dt.add(u),V||M(u,W?u:v,j,Y);let Ne=u.tagName;if(tn(u))sn(u,W?u:v,j,Y);else if(Ne==="TEXTAREA")Y.textContent=Lt(u.textContent,(W?u:v)?(W?u:v).textContent:u.textContent,j?j.textContent:u.textContent,Y,"text");else{let Le=T(u,v,j,W,Y),Me=Ne==="TEMPLATE"&&Y.content?Y.content:Y;for(let Ze of Le)Me.appendChild(Ze)}return dt.delete(u),Y}function Lt(u,v,j,U,V){if(v===j)return v;if(v===u)return j!==u&&ae({kind:V,node:U,source:"remote"}),j;if(j===u)return B({kind:V,node:U,source:"local"}),v;let W=O==="local"?v:j;return de({kind:V,node:U,base:u,local:v,remote:j,resolved:W},{site:"whole",el:U}),Oe.push({kind:V,node:U,source:"both"}),W}function sn(u,v,j,U){let V=u.textContent,W=v?v.textContent:V,Y=j?j.textContent:V,ie=h?lo(u,o.mergeTags,!0):null;if(ie&&W!==Y){let Ne=j&&j.getAttribute("merge-key")||u.getAttribute("merge-key"),{text:Le,warnings:Me}=Rr(o.localIsBase?void 0:V,W,Y,{parse:ie.recognizer.parse,keyCandidates:Ne?Ne.split(/[\s,]+/).filter(Boolean):void 0});for(let Ze of Me)console.warn(`[hyper-morph] merge "${ie.raw}": ${Ze}`);U.textContent=Le,We.add(U),Le!==Y?B({kind:"text",node:U,source:Le===W?"local":"both"}):Le!==V&&ae({kind:"text",node:U,source:"remote"});return}U.textContent=Lt(V,W,Y,U,"text")}function M(u,v,j,U){let V=new Map;for(let W of[u,v,j])if(W)for(let Y of W.attributes)o.ignoreAttribute(W,Y.name)||V.set(Y.name,Y);for(let[W,Y]of V){let ie=u?u.getAttribute(W):null,Ne=v?v.getAttribute(W):ie,Le=j?j.getAttribute(W):ie,Me;Ne===Le?Me=Ne:Ne===ie?(Me=Le,ae({kind:"attr",el:U,name:W,source:"remote"})):Le===ie?(Me=Ne,B({kind:"attr",el:U,name:W,source:"local"})):(Me=Z(W,ie,Ne,Le),Me===void 0&&(Me=O==="local"?Ne:Le,de({kind:"attr",el:U,name:W,base:ie,local:Ne,remote:Le,resolved:Me},{el:U,sample:Y})),Oe.push({kind:"attr",el:U,name:W,source:"both"})),Me!=null&&(Y.namespaceURI?U.setAttributeNS(Y.namespaceURI,Y.name,Me):U.setAttribute(W,Me))}}function Z(u,v,j,U){if(u==="class"){let V=Le=>new Set((Le||"").split(/\s+/).filter(Boolean)),W=V(v),Y=V(j),ie=V(U),Ne=new Set;for(let Le of new Set([...W,...Y,...ie])){let Me=W.has(Le),Ze=Y.has(Le),je=ie.has(Le);(Ze===je?Ze:Ze===Me?je:Ze)&&Ne.add(Le)}return[...Ne].join(" ")}if(u==="style"){let V=Me=>{let Ze=new Map;if(!Me)return Ze;let je=0,Ot=null,Ue="",ht=()=>{let it=Ue.indexOf(":");it>0&&Ze.set(Ue.slice(0,it).trim(),Ue.slice(it+1).trim()),Ue=""};for(let it of Me){if(Ot){Ue+=it,it===Ot&&(Ot=null);continue}if(it==='"'||it==="'"){Ot=it,Ue+=it;continue}if(it==="("?je++:it===")"&&je--,it===";"&&je===0){ht();continue}Ue+=it}return Ue.trim()&&ht(),Ze},W=V(v),Y=V(j),ie=V(U),Ne=new Map,Le=!1;for(let Me of new Set([...W.keys(),...Y.keys(),...ie.keys()])){let Ze=W.get(Me)??null,je=Y.get(Me)??null,Ot=ie.get(Me)??null,Ue;je===Ot?Ue=je:je===Ze?Ue=Ot:Ot===Ze?Ue=je:(Ue=O==="local"?je:Ot,Le=!0),Ue!=null&&Ne.set(Me,Ue)}return Le?void 0:[...Ne].map(([Me,Ze])=>`${Me}: ${Ze}`).join("; ")}}function ee(u,v,j,U){let V=u.value,W=U?V:v?v.value:"",Y=j?j.value:"";re.add(u),v&&re.add(v),j&&re.add(j);let ie=wo(V,W,Y,O),Ne=ie.text===""?null:_.createTextNode(ie.text);Ne&&(ye.set(Ne,{base:u.nodes,local:v?v.nodes:null,remote:j?j.nodes:null}),ge.set(Ne,ie.mapLocalOffset)),W!==V&&Y!==V?Oe.push({kind:"text",node:Ne,source:"both"}):W!==V?B({kind:"text",node:Ne,source:"local"}):Y!==V&&ae({kind:"text",node:Ne,source:"remote"});for(let Le of ie.conflicts)de({kind:"text",node:Ne,base:V.slice(Le.bs,Le.be),local:Le.local,remote:Le.remote,resolved:Le.resolved},{site:"run",bRun:u,lRun:v,rRun:j,node:Ne,c:Le});return Ne}function ue(u,v){return xo(u,v).every(j=>j.bs===j.be)}function oe(u,v){let j=u?u.value:"",U=v?v.value:"",V;if(j===U||!U?V=j:j?ue(j,U)?V=U:ue(U,j)?V=j:(V=O==="local"?j:O==="both"?j+U:U,de({kind:"structure",el:null,detail:"insert-collision",local:j,remote:U,resolved:V},{unit:{b:null,l:u,r:v},localLost:O==="remote"})):V=U,u&&re.add(u),v&&re.add(v),V==="")return null;let W=_.createTextNode(V);return ye.set(W,{base:null,local:u?u.nodes:null,remote:v?v.nodes:null}),j?B({kind:"insert",el:W,source:U&&j===U?"both":"local"}):ae({kind:"insert",el:W,source:"remote"}),W}function fe(u,v){let j={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},U=ie=>s(ie).every(Ne=>Xe(Ne)?qn(Ne,j):Ne.kind==="text"),V=null;if(U(u)&&U(v)){let ie=u.textContent,Ne=v.textContent;ie===Ne||ue(Ne,ie)?V=v:ue(ie,Ne)&&(V=u)}if(!V){let ie=O==="local",Ne=y(ie?u:v,ie?"local":"remote",!0),Le=ye.get(Ne);return ie?Le.remote=v:Le.local=u,de({kind:"structure",el:Ne,detail:"insert-collision",local:u,remote:v,resolved:ie?u:v},{unit:{b:null,l:u,r:v},localLost:!ie}),Ne}let W=u.namespaceURI&&u.namespaceURI!=="http://www.w3.org/1999/xhtml"?_.createElementNS(u.namespaceURI,u.tagName):_.createElement(u.tagName);M(null,u,v,W),ye.set(W,{base:null,local:u,remote:v}),re.add(u),re.add(v);let Y=Ir({base:Array.from(V.childNodes),local:Array.from(u.childNodes),remote:Array.from(v.childNodes),out:_,policy:O,idOf:{local:S,remote:L},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:ye,textMappers:ge,conflicts:Be,conflict:de,scope:{base:null,local:u,remote:v,units:[],at:0},synthetic:!0,decisions:Oe,node:W});rt.push(...Y.segments);for(let ie of Y.nodes)W.appendChild(ie);return W}function y(u,v,j=!1){if(!j&&Xe(u)){let Y=ze.partner.get(u);if(Y)return bt(u,v,Y)}if(!Xe(u)){if(u.value==="")return null;let Y=u.kind==="comment"?_.createComment(u.value):_.createTextNode(u.value);return ye.set(Y,{base:null,local:v==="local"?u.nodes:null,remote:v==="remote"?u.nodes:null}),re.add(u),Y}let U=u.namespaceURI&&u.namespaceURI!=="http://www.w3.org/1999/xhtml"?_.createElementNS(u.namespaceURI,u.tagName):_.createElement(u.tagName);for(let Y of u.attributes)Y.namespaceURI?U.setAttributeNS(Y.namespaceURI,Y.name,Y.value):U.setAttribute(Y.name,Y.value);ye.set(U,{base:null,local:v==="local"?u:null,remote:v==="remote"?u:null}),re.add(u);let V=u.tagName==="TEMPLATE"&&U.content?U.content:U,W=v==="local"?te:J;for(let Y of s(u)){let ie=Xe(Y)?W.reverse.get(Y):null;if(ie&&ut.has(ie)){de({kind:"structure",el:null,detail:"both-moved",base:ie},{subject:ie});continue}if(ie&&!dt.has(ie)){let Le=Fe(te,ie)||null,Me=Fe(J,ie)||null;if(Le||Me){let Ze=Et(ie,Le,Me,!1);v==="local"?B({kind:"move",el:Ze,source:"local"}):ae({kind:"move",el:Ze,source:"remote"}),V.appendChild(Ze);continue}}let Ne=y(Y,v);Ne&&V.appendChild(Ne)}return U}function T(u,v,j,U,V){v&&te.identical.has(u)&&te.pairIdenticalChildren(u),j&&J.identical.has(u)&&J.pairIdenticalChildren(u);let W=Xt(te,v,u,U),Y=Xt(J,j,u,!1),ie=s(u),Ne=new Set(ie),Le=new Map;for(let X=0;X<ie.length;X++)Le.set(ie[X],X);let Me=[],Ze=new Set,je=new Map,Ot=new Set,Ue=new Set,ht=[];zt();let it=X=>{let Re=[];for(let Ae of X.units){if(Ue.has(Ae))continue;let Ge=X.baseOf(Ae);Ge&&Ne.has(Ge)&&Re.push(Ge)}return Re},Kt=X=>it(X).map(Re=>Le.get(Re)),Rt=X=>X.every((Re,Ae)=>Ae===0||Re>=X[Ae-1]),qt=!W.asBase&&!Rt(Kt(W)),It=!Y.asBase&&!Rt(Kt(Y));qt&&It&&de({kind:"structure",el:V,detail:"both-reordered",base:u},{subject:u,lKept:it(W),rKept:it(Y)});let at=It||!qt?{V:Y,A:J,side:"remote",other:W,otherA:te,otherSide:"local"}:{V:W,A:te,side:"local",other:Y,otherA:J,otherSide:"remote"};qt?B({kind:"move",el:null,source:It?"both":"local",base:u}):It&&ae({kind:"move",el:null,source:"remote",base:u});let St=W.asBase?[]:W.units.filter(X=>!W.baseOf(X)&&!Ue.has(X)&&!ze.partner.has(X)),At=Y.asBase?[]:Y.units.filter(X=>!Y.baseOf(X)&&!Ue.has(X)&&!ze.partner.has(X)),Ht=new Map;if(St.length&&At.length){let X=new Map,Re=new Map;for(let He of At){if(Xe(He)){let et=L(He);et&&X.set(et,He)}let $e=c.unitHash(He);Re.has($e)||Re.set($e,[]),Re.get($e).push(He)}let Ae=(He,$e)=>{let et=He.units.indexOf($e);for(let _e=et-1;_e>=0;_e--){let nt=He.baseOf(He.units[_e]);if(nt)return nt}return"start"},Ge=new Map,ct=new Map;for(let He of At){let $e=Ae(Y,He);Xe(He)?(ct.has($e)||ct.set($e,[]),ct.get($e).push(He)):He.kind==="text"&&!Ge.has($e)&&Ge.set($e,He)}for(let He of St){let $e=null;if(Xe(He)){let et=S(He);et&&X.has(et)&&!Ht.has(X.get(et))&&($e=X.get(et))}else if(He.kind==="text"){let et=Ge.get(Ae(W,He));et&&!Ht.has(et)&&($e=et)}if(!$e){let et=Re.get(c.unitHash(He));et&&($e=et.find(_e=>!Ht.has(_e)&&Xe(_e)===Xe(He)&&(Xe(_e)?_e.tagName===He.tagName:_e.kind===He.kind)&&c.equalUnits(He,_e))||null)}if(!$e&&Xe(He)){let et=f.local(He),_e=(ct.get(Ae(W,He))||[]).filter(nt=>{let en=f.remote(nt);return!Ht.has(nt)&&nt.tagName===He.tagName&&!(et&&en&&et!==en)&&c.similar(He,nt)});_e.length===1&&($e=_e[0])}$e&&(Ht.set($e,He),Ht.set(He,$e))}}let Zt=X=>{if(re.has(X))return je.get(X)||null;let Re=W.twin(X),Ae=Y.twin(X),Ge=Re&&!W.asBase&&!W.here(Re),ct=Ae&&!Y.asBase&&!Y.here(Ae);if(Ge||ct){if((!Re||!Ae)&&de({kind:"structure",el:null,detail:"move-beats-delete",base:X},{subject:X,deleted:Re?"remote":"local"}),!G(X))return re.add(X),null;de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X})}if(!Re&&!Ae)return re.add(X),ae({kind:"remove",source:"both",base:X}),null;if(!Re&&!Bt(X,Ae,J))return re.add(X),B({kind:"remove",source:"local",base:X}),null;if(!Ae&&!Bt(X,Re,te))return re.add(X),ae({kind:"remove",source:"remote",base:X}),null;let He=!Re||!Ae,$e=W.asBase?Fe(te,X)||null:Re,et=Y.asBase&&Xe(X)&&(J.identityPaired.has(X)||!f.base(X))&&Fe(J,X)||Ae,_e;return Xe(X)?_e=Et(X,$e,et,W.asBase):X.kind==="comment"?_e=N(X,$e,Ae,W.asBase):_e=ee(X,$e,Ae,W.asBase),re.add(X),_e&&(je.set(X,_e),Re&&je.set(Re,_e),Ae&&je.set(Ae,_e),He&&(de({kind:"structure",el:_e,detail:"edit-beats-delete",base:X},{subject:X,deleted:Re?"remote":"local"}),Re?B({kind:"insert",el:_e,source:"local"}):ae({kind:"insert",el:_e,source:"remote"}))),_e},un=(X,Re,Ae,Ge)=>{if(re.has(X))return je.get(X)||null;let ct=Re.baseOf(X);if(ct&&Ne.has(ct))return Ue.has(ct)&&!Ue.has(X)?In(ct,X,Ge):Zt(ct);if(ct)return Cn(ct,X,Ge);let He=Ht.get(X);if(He){let et=Ge==="local"?X:He,_e=Ge==="local"?He:X,nt;return Xe(et)?c.equalUnits(et,_e)?(nt=y(et,"local"),ye.get(nt).remote=_e):nt=fe(et,_e):nt=oe(et,_e),re.add(et),re.add(_e),nt&&(je.set(et,nt),je.set(_e,nt),Xe(et)&&B({kind:"insert",el:nt,source:"both"})),nt}let $e=y(X,Ge);return $e&&(je.set(X,$e),Ge==="local"?B({kind:"insert",el:$e,source:"local"}):ae({kind:"insert",el:$e,source:"remote"})),$e},In=(X,Re,Ae)=>{let Ge;return Xe(X)?(Ge=Qt(X,Ae,Re),Ge&&re.add(Re)):(Ge=y(Re,Ae),re.add(Re),Ge&&(Ae==="local"?B:ae)({kind:"insert",el:Ge,source:Ae})),Ge&&je.set(Re,Ge),Ge},Cn=(X,Re,Ae)=>{let ct=Fe(Ae==="local"?J:te,X),He=Re,$e=ct?he(ct,Ae==="local"?j:v,Ae==="local"?J:te):!1,et=ct&&!$e&&!ve(X,ct);if(et&&Ae===at.otherSide)return de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X}),null;if(et&&de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X}),ct||de({kind:"structure",el:null,detail:"move-beats-delete",base:X},{subject:X,deleted:Ae==="local"?"remote":"local"}),dt.has(X)){de({kind:"structure",el:null,detail:"both-moved",base:X},{subject:X});let nt=y(He,Ae);return nt&&je.set(Re,nt),nt}let _e=Xe(X)?Et(X,Ae==="local"?He:Fe(te,X)||null,Ae==="remote"?He:Fe(J,X)||null,!1):null;return _e&&(je.set(X,_e),je.set(Re,_e),ct&&je.set(ct,_e),Ae==="local"?B({kind:"move",el:_e,source:"local"}):ae({kind:"move",el:_e,source:"remote"})),_e};for(let X of at.V.units){if(Ue.has(X)){let Ae=je.get(X);Ze.has(Ae)||(Me.push(Ae),Ze.add(Ae));continue}if(re.has(X)&&!(je.get(X)&&Ze.has(je.get(X)))){let Ae=at.V.baseOf(X);Ae&&!Ne.has(Ae)&&de({kind:"structure",el:null,detail:"both-moved",base:Ae},{subject:Ae});continue}let Re=un(X,at.V,at.A,at.side);Re&&!Ze.has(Re)&&(Me.push(Re),Ze.add(Re),!at.V.baseOf(X)&&!Ht.has(X)&&!Ue.has(X)&&Ot.add(Re))}for(let X of ht)Ze.has(X.frag)||(Me.splice(xn(X.at),0,X.frag),Ze.add(X.frag));if(!at.other.asBase){let X=at.other,Re=at.otherSide,Ae=at.otherA,Ge=null,ct=0,He=null;for(let $e of X.units){let et=je.get($e);if(et&&Ze.has(et)){Ge=et,He=null;continue}if(re.has($e)){let en=X.baseOf($e);en&&!Ne.has(en)&&de({kind:"structure",el:null,detail:"both-moved",base:en},{subject:en});continue}let _e=un($e,X,Ae,Re);if(!_e)continue;let nt;if(He)nt=Me.indexOf(He)+1;else if(Ge){if(nt=Me.indexOf(Ge)+1,Re==="remote")for(;nt<Me.length&&Ot.has(Me[nt]);)nt++}else nt=ct++;Me.splice(nt,0,_e),Ze.add(_e),He=_e}}for(let X=0;X<ie.length;X++){let Re=ie[X];if(re.has(Re))continue;let Ae=Zt(Re);Ae&&Me.splice(xn(X),0,Ae)}return Me;function xn(X){for(let Re=X-1;Re>=0;Re--){let Ae=je.get(ie[Re]);if(Ae){let Ge=Me.indexOf(Ae);if(Ge>=0)return Ge+1}}return 0}function cn(X){let Re={ignored:r,remoteWins:()=>!1},Ae=me=>X(me)||Xe(me)&&o.remoteWins(me)&&An.has(me.tagName)&&qn(me,Re),Ge=new Map,ct=me=>{if(!Xe(me)||!_c.has(me.tagName))return!1;let Ie=Ge.get(me);return Ie===void 0&&(Ie=!r(me)&&!o.remoteWins(me)&&s(me).every(Ae),Ge.set(me,Ie)),Ie},He=me=>!Xe(me)&&me.kind==="text",$e=null,et=new Map,_e=me=>{let Ie=et.get(me);if(Ie)return Ie;let qe=Xe(me)?me.textContent:me.value;Ie=new Set;let tt=qe.toLowerCase();if(!(qe.length>Ks))if(/^[\x00-\x7f]*$/.test(tt))for(let Ke of tt.split(/[^\p{L}\p{N}]+/u))Ke&&Ie.add(Ke);else for(let Ke of Sr(tt))/^[\s\p{P}]+$/u.test(Ke)||Ie.add(Ke);return et.set(me,Ie),Ie},nt=me=>(Xe(me)?me.textContent:me.value).toLowerCase().replace(/\s+/g," ").trim(),en=new Map,Vn=me=>{let Ie=en.get(me);if(Ie)return Ie;Ie=new Set(_e(me));let qe=Ke=>{if(Ke)for(let kt of _e(Ke))Ie.add(kt)},tt=Ne.has(me)?me:!W.asBase&&W.baseOf(me)||!Y.asBase&&Y.baseOf(me);return tt&&(qe(tt),qe(Fe(te,tt)),qe(Fe(J,tt))),en.set(me,Ie),Ie},dn=(me,Ie)=>{let qe=nt(Ie),tt=Ne.has(me)?me:!W.asBase&&W.baseOf(me)||!Y.asBase&&Y.baseOf(me),Ke=Ut=>qe?Ut.split(qe).length-1:0;if(tt&&Xe(Ie)&&!Ne.has(Ie)){let Ut=Ke(nt(tt));for(let _t of[Fe(te,tt),Fe(J,tt)]){if(!_t||_t===Ie||_t.ownerDocument!==Ie.ownerDocument)continue;let an=nt(_t);if(an.length>qe.length&&Ke(an)>=Ut&&(an.startsWith(qe)||an.endsWith(qe)))return!1}}let kt=_e(Ie),yt=Vn(me),Pt=0;for(let Ut of kt)yt.has(Ut)&&Pt++;if(kt.size&&Pt*2>=kt.size)return!0;if(!qe||qe.length>Ks)return!1;let Ft=tt?[me,tt,Fe(te,tt),Fe(J,tt)]:[me],on=(Ut,_t)=>Ut!==_t&&(Ut.startsWith(_t)||Ut.endsWith(_t));if(Ft.some(Ut=>Ut&&on(nt(Ut),qe)))return!0;if(!Ne.has(Ie)||!tt)return!1;let vt=nt(me),Ln=nt(tt);return[Fe(te,Ie),Fe(J,Ie)].some(Ut=>{let _t=Ut&&nt(Ut);return!!_t&&vt!==_t&&(vt.startsWith(_t)&&!Ln.startsWith(_t)||vt.endsWith(_t)&&!Ln.endsWith(_t))})},ln=me=>{$e||($e=new Set),$e.add(me)},Wn=me=>{ln(me);for(let[Ie,qe]of[[te,W],[J,Y]]){if(qe.asBase)continue;let tt=Fe(Ie,me);tt&&qe.here(tt)&&ln(tt)}},Je=(me,Ie)=>me.asBase||ie.every(qe=>!Xe(qe)||Ie.identical.has(qe)&&me.here(Fe(Ie,qe)))&&me.units.every(qe=>!Xe(qe)||me.baseOf(qe));if(Je(W,te)&&Je(Y,J))return null;let ft=me=>{if(me.asBase)return!1;let Ie=-1;for(let qe of me.units){let tt=Xe(qe)?me.baseOf(qe):null;if(!tt||!Ne.has(tt))continue;let Ke=Le.get(tt);if(Ke<Ie)return!0;Ie=Ke}return!1};if(ft(W)||ft(Y))return null;for(let[me,Ie]of[[W,te],[Y,J]]){if(me.asBase||Je(me,Ie))continue;let qe=me.units,tt=Ie===te?f.local:f.remote,Ke=(Pe,pt)=>{let Mt=Xe(Pe)&&f.base(Pe),xt=Xe(pt)&&tt(pt);return!Mt||!xt||Mt===xt},kt=new Map;for(let Pe=0;Pe<qe.length;Pe++)kt.set(qe[Pe],Pe);let yt=Pe=>!!Pe&&(Xe(Pe)?me.here(Pe):kt.has(Pe)),Pt=Pe=>{let pt=me.twin(Pe);return yt(pt)?pt:null},Ft=ie.filter(Pe=>!me.twin(Pe)&&ct(Pe)),on=qe.filter(Pe=>!me.baseOf(Pe)&&ct(Pe)),vt=(Pe,pt)=>pt===ie?!!Pt(Pe):Ne.has(me.baseOf(Pe)),Ln=Pe=>{let pt=new Int32Array(Pe.length),Mt=new Int32Array(Pe.length),xt=-1;for(let mt=0;mt<Pe.length;mt++)pt[mt]=xt,vt(Pe[mt],Pe)&&(xt=mt);xt=Pe.length;for(let mt=Pe.length-1;mt>=0;mt--)Mt[mt]=xt,vt(Pe[mt],Pe)&&(xt=mt);return{prev:pt,next:Mt}},Ut=Ln(qe),_t=Ln(ie),an=(Pe,pt)=>{Wn(Pe),ln(pt)};for(let Pe of on){let pt=kt.get(Pe),Mt=Ut.prev[pt],xt=Ut.next[pt],mt=Mt>=0?me.baseOf(qe[Mt]):null,yn=xt<qe.length?me.baseOf(qe[xt]):null,Vt=mt?Le.get(mt):-1,Rn=yn?Le.get(yn):ie.length;for(let Tn=Math.max(0,Vt);Tn<=Math.min(Rn,ie.length-1);Tn++){let Gt=ie[Tn];(ct(Gt)||He(Gt))&&(!Ke(Gt,Pe)||!dn(Gt,Pe)||(He(Gt)?ln(Pe):an(Gt,Pe)))}}let bn=(Pe,pt,Mt)=>{for(let xt=pt+Mt;xt>=0&&xt<Pe.length;xt+=Mt){let mt=Pe[xt];if(ct(mt))return mt;if(Xe(mt)||mt.value.trim())return null}return null},Uo=Pe=>{let pt=new Set;for(let Mt of s(Pe))if(!Xe(Mt)&&Mt.kind==="text")for(let xt of _e(Mt))pt.add(xt);return pt},Zn=(Pe,pt)=>{let Mt=_e(pt),xt=new Set;for(let mt of Uo(Pe))Mt.has(mt)||xt.add(mt);return xt},bo=(Pe,pt)=>{if(!Pe.size)return!1;let Mt=_e(pt),xt=0;for(let mt of Pe)Mt.has(mt)&&xt++;return xt*2>=Pe.size};for(let Pe of ie){if(Ie.identical.has(Pe)||!ct(Pe))continue;let pt=Pt(Pe);if(!pt||!ct(pt))continue;let Mt=Zn(pt,Pe),xt=Zn(Pe,pt);for(let mt of[-1,1]){let yn=bn(ie,Le.get(Pe),mt);yn&&bo(Mt,yn)&&(an(Pe,pt),Wn(yn));let Vt=bn(qe,kt.get(pt)??-1,mt);if(Vt&&bo(xt,Vt)){an(Pe,pt);let Rn=me.baseOf(Vt);Rn?an(Rn,Vt):ln(Vt)}}}for(let Pe of Ft){let pt=Le.get(Pe),Mt=_t.prev[pt],xt=_t.next[pt],mt=Mt>=0?Pt(ie[Mt]):null,yn=xt<ie.length?Pt(ie[xt]):null,Vt=mt?kt.get(mt)??-1:-1,Rn=yn?kt.get(yn)??-1:qe.length;for(let Tn=Math.max(0,Vt);Tn<=Math.min(Rn,qe.length-1);Tn++){let Gt=qe[Tn];if((ct(Gt)||He(Gt))&&!(!Ke(Pe,Gt)||!dn(Gt,Pe))&&(Wn(Pe),!He(Gt))){let _o=me.baseOf(Gt);_o?an(_o,Gt):ln(Gt)}}}}if(!$e)return null;for(let me of Array.from($e))if(Ne.has(me))for(let Ie of[te,J]){let qe=Fe(Ie,me);qe&&!he(qe,Ie===te?v:j,Ie)&&!(Ie===te?W:Y).asBase&&($e.delete(me),$e.delete(Fe(te,me)),$e.delete(Fe(J,me)))}return $e.size?$e:null}function zt(){if((W.asBase||te.identical.has(u))&&(Y.asBase||J.identical.has(u)))return;let X={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},Re=Je=>Xe(Je)?qn(Je,X):Je.kind==="text",Ae=cn(Re),Ge=Je=>Ae&&Ae.has(Je)||Re(Je),ct=ie.map(Ge);if(!ct.includes(!0))return;let He=Je=>{let ft=Je.units,me=new Map;for(let yt=0;yt<ft.length;yt++)me.set(ft[yt],yt);let Ie=[],qe=-1;for(let yt=0;yt<ie.length;yt++){if(ct[yt])continue;let Pt=Je.twin(ie[yt]),Ft=Pt?me.get(Pt):void 0;Ft===void 0||Ft<=qe||Ge(Pt)||(Ie.push([yt,Ft]),qe=Ft)}let tt=[],Ke=-1,kt=-1;for(let yt=0;yt<=Ie.length;yt++){let[Pt,Ft]=yt<Ie.length?Ie[yt]:[ie.length,ft.length],on={bLo:-1,bHi:-1,sLo:-1,sHi:-1,next:Ft};for(let vt=Ke+1;vt<Pt;vt++)ct[vt]&&(on.bLo<0&&(on.bLo=vt),on.bHi=vt);for(let vt=kt+1;vt<Ft;vt++)Ge(ft[vt])&&(on.sLo<0&&(on.sLo=vt),on.sHi=vt);tt.push(on),Ke=Pt,kt=Ft}return{units:ft,list:tt}},$e=He(W),et=He(Y),_e=[];for(let Je of[$e,et])for(let ft of Je.list)ft.bLo>=0&&_e.push([ft.bLo,ft.bHi]);_e.sort((Je,ft)=>Je[0]-ft[0]);let nt=[];for(let[Je,ft]of _e){let me=nt[nt.length-1];me&&Je<=me.hi?me.hi=Math.max(me.hi,ft):nt.push({lo:Je,hi:ft})}let en=(Je,ft)=>{let me=-1,Ie=-1;for(let Ke=0;Ke<Je.list.length;Ke++){let kt=Je.list[Ke];kt.bLo<ft.lo||kt.bLo>ft.hi||(me<0&&(me=Ke),Ie=Ke)}let qe=1/0,tt=-1;for(let Ke=me;Ke>=0&&Ke<=Ie;Ke++){let kt=Je.list[Ke];kt.sLo>=0&&(qe=Math.min(qe,kt.sLo),tt=Math.max(tt,kt.sHi)),Ke<Ie&&(qe=Math.min(qe,kt.next),tt=Math.max(tt,kt.next))}return tt<0?[]:Je.units.slice(qe,tt+1)},Vn=(Je,ft)=>Je.length===ft.length&&Je.every((me,Ie)=>c.equalUnits(me,ft[Ie])),dn=Je=>!Xe(Je)&&Je.kind==="comment",ln=Je=>{if(!Je.length)return[];let ft=(Ke,kt)=>Xe(Ke)?Ke:Ke.nodes[kt?Ke.nodes.length-1:0],me=ft(Je[0]),Ie=ft(Je[Je.length-1],!0),qe=Ke=>Ke&&Xe(Ke)&&r(Ke);for(;qe(me.previousSibling);)me=me.previousSibling;for(;qe(Ie.nextSibling);)Ie=Ie.nextSibling;let tt=[];for(let Ke=me;Ke&&(tt.push(Ke),Ke!==Ie);Ke=Ke.nextSibling);return tt},Wn=Je=>Je.some(ft=>Xe(ft)&&r(ft));for(let Je of nt){let ft=ie.slice(Je.lo,Je.hi+1),me=W.asBase?null:en($e,Je),Ie=Y.asBase?null:en(et,Je);if(ft.some(dn)||me&&me.some(dn)||Ie&&Ie.some(dn))continue;let qe=ln(me||ft),tt=ln(Ie||ft);if((!me||Vn(ft,me))&&(!Ie||Vn(ft,Ie))&&!(me&&Wn(qe)))continue;let Ke=Ir({base:ln(ft),local:qe,remote:tt,out:_,policy:O,blocks:Ae,L:me?te:zs(te,u),R:Ie?J:zs(J,u),idOf:{local:S,remote:L},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(yt,Pt,Ft)=>Et(yt,Pt,Ft,!1),cloneUnit:y,mergeAttrs:M,atomKey:c.exactUnitKey,moveIn:Qt,provenance:ye,textMappers:ge,conflicts:Be,conflict:de,scope:{base:u,local:W.asBase?null:W.el,remote:Y.asBase?null:Y.el,units:ie,at:Je.lo},decisions:Oe,node:V});rt.push(...Ke.segments);let kt=_.createDocumentFragment();for(let yt of Ke.nodes)kt.appendChild(yt);for(let yt of[...ft,...me||[],...Ie||[]])re.add(yt),Ue.add(yt),je.set(yt,kt);ht.push({frag:kt,at:Je.lo})}}}function P(u,v){let j=ye.get(u);return j&&j.unchanged?!j.remote||j.remote===v?!0:p(j.remote,v):u.tagName!==v.tagName||!$(u,v)?!1:H(R(u),R(v))}function p(u,v){return u===v?!0:u.tagName!==v.tagName||u.namespaceURI!==v.namespaceURI||!$(u,v)?!1:k(R(u),R(v))}function k(u,v){let j=F(u,r),U=F(v,r);if(j.length!==U.length)return!1;for(let V=0;V<j.length;V++){let W=j[V],Y=U[V];if(typeof W=="string"||typeof Y=="string"){if(W!==Y)return!1}else{if(W.nodeType!==Y.nodeType)return!1;if(W.nodeType===1){if(!p(W,Y))return!1}else if(W.nodeValue!==Y.nodeValue)return!1}}return!0}function R(u){return u.tagName==="TEMPLATE"&&u.content?u.content:u}function $(u,v){let j=0;for(let U of u.attributes)if(!o.ignoreAttribute(u,U.name)&&(j++,v.getAttribute(U.name)!==U.value))return!1;for(let U of v.attributes)o.ignoreAttribute(v,U.name)||j--;return j===0}function H(u,v){let j=F(u,V=>{let W=ye.get(V);return!!(W&&W.pinned)}),U=F(v,r);if(j.length!==U.length)return!1;for(let V=0;V<j.length;V++){let W=j[V],Y=U[V];if(typeof W=="string"||typeof Y=="string"){if(W!==Y)return!1}else{if(W.nodeType!==Y.nodeType)return!1;if(W.nodeType===1){if(!P(W,Y))return!1}else if(W.nodeValue!==Y.nodeValue)return!1}}return!0}function F(u,v){let j=[],U=null;for(let V=u.firstChild;V;V=V.nextSibling){if(V.nodeType===3){U=U===null?V.nodeValue:U+V.nodeValue;continue}V.nodeType===1&&v(V)||(U!==null&&(U!==""&&j.push(U),U=null),j.push(V))}return U!==null&&U!==""&&j.push(U),j}function N(u,v,j,U){let V=u.value,W=U?V:v?v.value:"",Y=j?j.value:"";re.add(u),v&&re.add(v),j&&re.add(j);let ie=W===Y?W:W===V?Y:Y===V||O==="local"?W:Y,Ne={site:"comment",bRun:u,lRun:v,rRun:j,node:null};if(W!==V&&Y!==V&&W!==Y&&de({kind:"text",node:null,base:V,local:W,remote:Y,resolved:ie},Ne),!v&&!j)return null;let Le=_.createComment(ie);return Ne.node=Le,ye.set(Le,{base:u.nodes,local:v?v.nodes:null,remote:j?j.nodes:null}),Le}function E(u,v){let j=Fe(v,u);if(!j)return null;let U=Xe(j)?j.parentNode:j.parent,V=Xe(u)?u.parentNode:u.parent;return Fe(v,V)===U?null:v.reverse.get(U)||null}function G(u){let v=new Set([u]),j=u;for(let U=0;U<64;U++){let V=E(j,te)||E(j,J);if(!V)return!1;if(V===u||Xe(u)&&Xe(V)&&u.contains(V)||v.has(V))return!0;v.add(V),j=V}return!0}function he(u,v,j){if(!v)return!1;let U=Xe(u)?u.parentNode:u.parent;return U===v||v.tagName==="TEMPLATE"&&U===v.content}function ve(u,v){let j=ne(u),U=Fe(te,j);if(U&&he(v,U,te))return!0;let V=Fe(J,j);return!!(V&&he(v,V,J))}}function zs(e,t){return e.map.get(t)?Gs():{map:{get:o=>o&&o.nodeType===1&&e.map.get(o)||o,has:()=>!0},reverse:{get:o=>e.reverse.get(o)||o,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function Gs(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Ys=new Set(["INPUT","OPTION","TEXTAREA"]),jr=/[\t\n\f\r ]+/;function Js(e,t,n,o){let r=e.ownerDocument,{provenance:i,textMappers:c}=n,s=o.hooks,a=[],m=[],h=[],d=new Set,b=[],A=[],S=new Map,L=new Set,f=new Map,g=n.conflicts.length>0,x=new Map,Q=new Set,se=new Map,le=(M,Z)=>{let ee=se.get(M);ee||se.set(M,ee=new Set),ee.add(Z)},q=g?new Set:null,z=(M,Z,ee)=>{let ue=s.beforeAttributeUpdated(M,Z,ee);return g&&ue===!1&&le(Z,M),ue},ce=M=>!!M&&(M===e||e.contains(M)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(M)),xe=new Map,te=new Map,J=new Map,Ce=new Set,we=new Map;(function M(Z){let ee=i.get(Z);if(ee){if(Z.nodeType===1){let oe=ee.local?o.toLive(ee.local):null;oe&&ce(oe)&&oe.nodeType===1&&(xe.set(Z,oe),te.set(oe,Z))}else if(Array.isArray(ee.local)){let oe=ge(ee.local,ee.local.map(fe=>o.toLive(fe)).filter(fe=>fe&&ce(fe)&&fe.nodeType===Z.nodeType));if(oe.length&&(xe.set(Z,oe[0]),te.set(oe[0],Z),J.set(Z,oe)),Array.isArray(ee.caret))for(let fe of ee.caret){let y=o.toLive(fe.node);if(!y||!ce(y)||y.nodeType!==3)continue;let T=we.get(y);Array.isArray(T)||we.set(y,T=[]),T.push({merged:Z,from:fe.from,to:fe.to,flatStart:fe.flatStart})}else{let fe=0;for(let y of oe)we.set(y,{merged:Z,shift:fe}),fe+=y.nodeValue.length}}}let ue=Z.nodeType===1&&Z.tagName==="TEMPLATE"&&Z.content?Z.content.childNodes:Z.childNodes;for(let oe of ue)M(oe)})(t);let ne=new Set;for(let M of xe.values())ne.add(M);for(let M of J.values())for(let Z of M)ne.add(Z);for(let M of n.segments||[])Oe(M);let _=o.restoreFocus===!1?null:Vc(r,we);o.childrenOnly?re(Be(e),Be(t)):We(e,t);for(let{node:M,parent:Z}of b)d.has(M)||!M.parentNode||M.nodeType===1&&(o.ignored(M)||ut(M))||De(M,Z);return Wc(r,_,we,c,J,f,Ce),{applied:a,moved:m,replaced:h,identities:A,mergedScriptsLive:L,liveOf:xe,heldBy:f,runOf:J,keptRuns:Ce,insertedLive:x,vetoed:Q,vetoedAttrs:se,removedVetoes:q};function ye(M,Z){let ee=M.slice(Z.bs,Z.be),ue=0;for(;ue<ee.length&&ue<Z.text.length&&ee[ue]===Z.text[ue];)ue++;let oe=0;for(;oe<ee.length-ue&&oe<Z.text.length-ue&&ee[ee.length-1-oe]===Z.text[Z.text.length-1-oe];)oe++;return{bs:Z.bs+ue,be:Z.be-oe,text:Z.text.slice(ue,Z.text.length-oe)}}function ge(M,Z){if(!Z.length)return Z;let ee=[];for(let fe of M){let y=fe.parentNode;if(!y)continue;let T=S.get(y);if(!T){T=new Set;for(let P=y.firstChild;P;P=P.nextSibling)P.nodeType===3&&T.add(o.toLive(P));S.set(y,T)}ee.includes(T)||ee.push(T)}let ue={has:fe=>ee.some(y=>y.has(fe))},oe=[];for(let fe of Z){oe.push(fe);for(let y=fe.nextSibling;y&&y.nodeType===3&&!ue.has(y)&&!oe.includes(y);y=y.nextSibling)oe.push(y)}return oe}function Oe(M){let Z=[];for(let N of M.localNodes){let E=o.toLive(N.node);if(!E||!ce(E)||E.nodeType!==3)return;Z.push(E)}let ee=ge(M.localNodes.map(N=>N.node),Z);if(!ee.length)return;let ue=ee.map(N=>N.nodeValue).join(""),{flatLocal:oe,lToM:fe,mapLocal:y}=M;if(ue===oe)return;let T=M.textNodes.map(N=>({node:N.node,ms:N.ms,me:N.me})),P=[],p=0;for(let N of ee)P.push(p),p+=N.nodeValue.length;let k=(N,E)=>ee.find((G,he)=>P[he]<=N&&N+E<=P[he]+G.nodeValue.length)||null,R=[],$=0;for(let N of xo(oe,ue).map(E=>ye(oe,E))){let E=N.bs+$;$+=N.text.length-(N.be-N.bs);let G,he;if(N.be>N.bs){G=fe[N.bs];let ve=G>=0;for(let u=N.bs;ve&&u<N.be;u++)fe[u]!==G+(u-N.bs)&&(ve=!1);if(!ve)continue;he=G+(N.be-N.bs)}else{let ve=N.bs>0?fe[N.bs-1]:0,u=N.bs<oe.length?fe[N.bs]:0;if(ve<0||u<0)continue;G=he=y(N.bs)}R.push({ms:G,me:he,text:N.text,live:he===G?k(E,N.text.length):null})}R.sort((N,E)=>E.ms-N.ms);let H=(N,E)=>(J.get(N.node)||[xe.get(N.node)]).includes(E),F=N=>!!N&&N.nodeType===1&&An.has(N.tagName);for(let N of R){let E=T.find(he=>he.ms<=N.ms&&N.me<=he.me&&N.ms<he.me);if(E&&N.live&&E.ms===N.ms&&!H(E,N.live)){let he=T.find(ve=>ve.me===N.ms&&H(ve,N.live));he&&(E=he)}if(!E&&N.me===N.ms){let he=T.find(j=>j.me===N.ms),ve=T.find(j=>j.ms===N.ms),u=he||ve;if(!u)continue;let v=u.node;for(;F(v.parentNode)&&(he?v.parentNode.lastChild:v.parentNode.firstChild)===v;)v=v.parentNode;if(v===u.node)E=u;else{let j=v.ownerDocument.createTextNode(N.text);v.parentNode.insertBefore(j,he?v.nextSibling:v);continue}}if(!E)continue;let G=E.node.nodeValue;E.node.nodeValue=G.slice(0,N.ms-E.ms)+N.text+G.slice(N.me-E.ms),E.me+=N.text.length-(N.me-N.ms)}}function Be(M){return M.nodeType===1&&M.tagName==="TEMPLATE"&&M.content?M.content:M}function We(M,Z){d.add(M);let ee=i.get(Z);if(ee&&ee.remote&&n.remoteIdOf){let oe=n.remoteIdOf(ee.remote);oe&&A.push([M,oe])}if(ee&&ee.unchanged){n.customIdentity&&ee.remote&&B(M,ee.remote),ee.remote&&O(M,ee.remote);return}if(s.beforeNodeMorphed(M,Z)===!1){Q.add(Z);return}nn(M,Z,o.keepLiveOnly&&ee&&ee.local&&ee.local.nodeType===1&&ee.local!==M?ee.local:null);let ue=M.tagName;if(tn(M))M.textContent!==Z.textContent&&(a.push({kind:"text",node:M,before:M.textContent,after:Z.textContent}),M.textContent=Z.textContent),n.mergedScripts.has(Z)&&L.add(M);else if(ue==="TEXTAREA")sn(M,Z,ee);else{Et(M,Z,ee);let oe=ue==="TEMPLATE"&&M.content?M.content:M,fe=ue==="TEMPLATE"&&Z.content?Z.content:Z;o.protectFocusedValue==="subtree"&&Qt(M)&&M!==r.body?rt(oe):re(oe,fe)}s.afterNodeMorphed(M,Z)}function rt(M){for(let Z=M.firstChild;Z;Z=Z.nextSibling){let ee=te.get(Z);ee&&xe.get(ee.parentNode)!==M||(d.add(Z),Z.nodeType===1&&rt(Z))}}function re(M,Z){let ee=de(M.firstChild),ue=new Set;for(let oe of Array.from(Z.childNodes)){let fe=xe.get(oe);fe&&d.has(fe)&&!ue.has(fe)&&(fe=null);let y=i.get(oe);if(y&&y.pinned){fe&&fe.nodeType===1&&((fe.parentNode!==M||de(fe.nextSibling)!==ee)&&ze(M,fe,ee),d.add(fe),ue.add(fe));continue}if(fe&&fe.nodeType===1){if(fe!==ee){let p=fe.parentNode;if(p===M&&ee&&Xt(fe)){let k=fe.nextSibling;for(let R=ee;R&&R!==fe;){let $=R.nextSibling;ze(M,R,k),R=$}}else ze(M,fe,ee),p!==M&&(m.push(fe),a.push({kind:"move",el:fe,from:p,to:M}))}ue.add(fe),We(fe,oe),ee=de(fe.nextSibling);continue}if(fe&&fe.nodeType!==1){let p=J.get(oe)||[fe],k=p.map($=>$.nodeValue).join(""),R=oe.nodeValue;if(oe.nodeType===3){let $=dt(oe);$!=null&&k!==$&&(R=wo($,k,oe.nodeValue).text)}if(p.length>1&&k===R&&!p.includes(ee,1)&&p.every(($,H)=>$.parentNode===M&&(H===0||p[H-1].nextSibling===$))){if(fe!==ee)for(let $ of p)ze(M,$,ee);s.beforeNodeMorphed(fe,oe)!==!1?s.afterNodeMorphed(fe,oe):g&&Q.add(oe);for(let $ of p)d.add($),ue.add($);f.set(oe,fe),Ce.add(oe),ee=de(p[p.length-1].nextSibling);continue}fe!==ee&&ze(M,fe,ee),s.beforeNodeMorphed(fe,oe)!==!1?(fe.nodeValue!==R&&(a.push({kind:"text",node:fe,before:fe.nodeValue,after:R}),fe.nodeValue=R),s.afterNodeMorphed(fe,oe)):Q.add(oe),d.add(fe),ue.add(fe),f.set(oe,fe),ee=de(fe.nextSibling);continue}if(oe.nodeType===3&&ee&&ee.nodeType===3&&!d.has(ee)&&!we.has(ee)){ee.nodeValue!==oe.nodeValue&&(a.push({kind:"text",node:ee,before:ee.nodeValue,after:oe.nodeValue}),ee.nodeValue=oe.nodeValue),d.add(ee),f.set(oe,ee),ee=de(ee.nextSibling);continue}let T=i.get(oe),P=Qe(T&&T.unchanged&&T.remote?T.remote:oe);if(s.beforeNodeAdded(P)===!1){Q.add(oe);continue}M.insertBefore(P,ee),d.add(P),g&&x.set(oe,P),P.nodeType===3&&f.set(oe,P),P.nodeType===1&&(h.push(P),be(P,oe),n.customIdentity&&T&&T.unchanged&&T.remote&&B(P,T.remote),tn(P)||st(P,oe),o.formState==="property"&&Bt(T)&&O(P,T.remote)),ee=de(P.nextSibling),a.push({kind:"insert",node:P,parent:M}),s.afterNodeAdded(P)}for(let oe of Array.from(M.childNodes))d.has(oe)||ue.has(oe)||oe.nodeType===1&&(o.ignored(oe)||ut(oe))||(ne.has(oe)?b.push({node:oe,parent:M}):De(oe,M))}function ut(M){return o.preserve&&M.parentNode&&M.parentNode.nodeType===1&&M.parentNode.tagName==="HEAD"&&o.preserve(M)===!0}function dt(M){let Z=i.get(M);return!Z||!Array.isArray(Z.local)?null:Z.local.map(ee=>ee.nodeValue).join("")}function Se(M){return i.get(M)}function O(M,Z){if(!Ys.has(M.tagName)&&!M.querySelector("input,option,textarea"))return;let ee=(ue,oe)=>{if(ue.tagName!==oe.tagName)return;ue.tagName==="TEXTAREA"?sn(ue,oe,{remote:oe}):Ys.has(ue.tagName)&&Et(ue,oe,{remote:oe});let fe=ae(ue),y=ae(oe);if(fe.length===y.length)for(let T=0;T<fe.length;T++)ee(fe[T],y[T])};ee(M,Z)}function B(M,Z){let ee=ae(M),ue=ae(Z);if(ee.length===ue.length)for(let oe=0;oe<ee.length;oe++){let fe=n.remoteIdOf(ue[oe]);fe&&A.push([ee[oe],fe]),B(ee[oe],ue[oe])}}function ae(M){let Z=M.tagName==="TEMPLATE"&&M.content?M.content:M;return Array.from(Z.children).filter(ee=>!o.ignored(ee))}function be(M,Z){if(!n.remoteIdOf)return;let ee=(ue,oe)=>{let fe=i.get(oe);if(fe&&fe.remote&&oe.nodeType===1){let P=n.remoteIdOf(fe.remote);P&&A.push([ue,P])}let y=ue.childNodes,T=oe.childNodes;for(let P=0;P<y.length&&P<T.length;P++)ee(y[P],T[P])};ee(M,Z)}function de(M){for(;M&&M.nodeType===1&&o.ignored(M);)M=M.nextSibling;return M}function ze(M,Z,ee){if(typeof M.moveBefore=="function"&&Z.ownerDocument===M.ownerDocument)try{M.moveBefore(Z,ee);return}catch{}M.insertBefore(Z,ee)}function De(M,Z){if(s.beforeNodeRemoved(M)===!1){g&&q.add(M);return}M.parentNode.removeChild(M),a.push({kind:"remove",node:M,parent:Z}),s.afterNodeRemoved(M)}function Qe(M){if(tn(M))return To(M,r);let Z=r.importNode(M,!0);if(Z.nodeType===1)for(let ee of Array.from(Z.querySelectorAll("script")))tn(ee)&&ee.replaceWith(To(ee,r));return Z}function st(M,Z){let ee=M.tagName==="TEMPLATE"&&M.content?M.content:M,ue=Z.tagName==="TEMPLATE"&&Z.content?Z.content:Z,oe=Array.from(ee.childNodes),fe=Array.from(ue.childNodes);for(let y=0;y<fe.length&&y<oe.length;y++){let T=fe[y],P=oe[y],p=xe.get(T);p&&d.has(p)&&(p=null);let k=i.get(T);if(k&&k.pinned){if(p&&p.nodeType===1){let R=p.parentNode;ze(ee,p,P),R!==ee&&(m.push(p),a.push({kind:"move",el:p,from:R,to:ee})),d.add(p)}P.remove();continue}if(p){let R=p.parentNode;ze(ee,p,P),P.remove(),p.nodeType===1?(R!==ee&&(m.push(p),a.push({kind:"move",el:p,from:R,to:ee})),We(p,T)):(d.add(p),f.set(T,p),p.nodeValue!==T.nodeValue&&(a.push({kind:"text",node:p,before:p.nodeValue,after:T.nodeValue}),p.nodeValue=T.nodeValue));continue}d.add(P),g&&x.set(T,P),P.nodeType===3&&f.set(T,P),k&&k.unchanged&&k.remote?(wt(P,k.remote),n.customIdentity&&B(P,k.remote)):T.nodeType===1&&!tn(T)&&st(P,T)}}function wt(M,Z){let ee=M.tagName==="TEMPLATE"&&M.content?M.content:M,ue=Z.tagName==="TEMPLATE"&&Z.content?Z.content:Z;for(let oe of Array.from(ue.childNodes))ee.appendChild(Qe(oe))}function bt(M,Z){return Z.namespaceURI?M.getAttributeNS(Z.namespaceURI,Z.localName):M.getAttribute(Z.name)}function Tt(M,Z){let ee=new Set((Z||"").split(jr).filter(Boolean));return(M||"").split(jr).filter(ue=>ue&&!ee.has(ue))}function nn(M,Z,ee){for(let ue of Array.from(Z.attributes)){if(Fe(M,ue.name)||o.ignoreAttribute(M,ue.name))continue;let oe=bt(M,ue);if(oe===ue.value||ee&&bt(ee,ue)===ue.value)continue;let fe=ue.value;if(ee&&ue.name==="class"&&!ue.namespaceURI){let y=ue.value.split(jr).filter(Boolean),T=Tt(oe,ee.getAttribute("class")).filter(P=>!y.includes(P));T.length&&(fe=[...y,...T].join(" "))}if(oe!==fe){if(s.beforeAttributeUpdated(ue.name,M,"update")===!1){g&&le(Z,ue.name);continue}ue.namespaceURI?M.setAttributeNS(ue.namespaceURI,ue.name,fe):M.setAttribute(ue.name,fe),a.push({kind:"attr",el:M,name:ue.name,before:oe,after:fe})}}for(let ue of Array.from(M.attributes)){if(Fe(M,ue.name)||o.ignoreAttribute(M,ue.name)||(ue.namespaceURI?Z.hasAttributeNS(ue.namespaceURI,ue.localName):Z.hasAttribute(ue.name)))continue;if(ee&&ue.name==="class"&&!ue.namespaceURI){let y=Tt(ue.value,ee.getAttribute("class"));if(y.length){let T=y.join(" ");if(T===ue.value)continue;if(s.beforeAttributeUpdated("class",M,"update")===!1){g&&le(Z,"class");continue}M.setAttribute("class",T),a.push({kind:"attr",el:M,name:"class",before:ue.value,after:T});continue}}if(ee&&bt(ee,ue)===null)continue;if(s.beforeAttributeUpdated(ue.name,M,"remove")===!1){g&&le(Z,ue.name);continue}let fe=ue.value;ue.namespaceURI?M.removeAttributeNS(ue.namespaceURI,ue.localName):M.removeAttribute(ue.name),a.push({kind:"attr",el:M,name:ue.name,before:fe,after:null})}}function Fe(M,Z){let ee=M.tagName;return ee==="INPUT"?Z==="value"||Z==="checked"||Z==="disabled":ee==="OPTION"?Z==="selected":!1}function Qt(M){return M===r.activeElement}function Xt(M){let Z=r.activeElement;return!!Z&&Z!==r.body&&M.contains(Z)}function Bt(M){let Z=M&&M.remote;return Z&&Z.nodeType===1?Z:null}function Et(M,Z,ee){let ue=M.tagName,oe=Bt(ee),fe=o.formState==="property"&&oe?oe:Z;if(ue==="INPUT"){let y=o.protectFocusedValue&&Qt(M),T=(M.getAttribute("type")||"").toLowerCase(),P=T!=="file"&&T!=="checkbox"&&T!=="radio",p=oe&&oe.hasAttribute("value")&&oe.value!==oe.getAttribute("value")?oe.value:null;if(P&&!y)if(o.formState==="property"){let k=Z.getAttribute("value"),R=M.getAttribute("value");(R!==k||M.value!==fe.value)&&z("value",M,k==null?"remove":"update")!==!1&&(R!==k&&(k==null?M.removeAttribute("value"):M.setAttribute("value",k),a.push({kind:"attr",el:M,name:"value",before:R,after:k})),M.value!==fe.value&&(M.value=fe.value))}else if(Z.hasAttribute("value")||p!=null){let k=p??Z.getAttribute("value");M.getAttribute("value")!==k&&z("value",M,"update")!==!1?(M.setAttribute("value",k),M.value!==k&&(M.value=k),a.push({kind:"attr",el:M,name:"value",before:null,after:k})):M.value!==k&&M.getAttribute("value")===k&&(M.value=k)}else(M.hasAttribute("value")||M.value!=="")&&z("value",M,"remove")!==!1&&(M.removeAttribute("value"),M.value="",a.push({kind:"attr",el:M,name:"value",before:"",after:null}));if(!P&&T!=="file"){let k=Z.getAttribute("value");k==null?M.hasAttribute("value")&&z("value",M,"remove")!==!1&&M.removeAttribute("value"):M.getAttribute("value")!==k&&z("value",M,"update")!==!1&&M.setAttribute("value",k)}y||(Lt(M,fe,"checked"),o.formState==="property"&&M.indeterminate!==fe.indeterminate&&(M.indeterminate=fe.indeterminate)),Lt(M,fe,"disabled")}else if(ue==="OPTION"){let y=M.parentNode&&M.closest("select");o.protectFocusedValue&&y&&Qt(y)||Lt(M,fe,"selected")}}function Lt(M,Z,ee){let ue=o.formState==="property"?!!Z[ee]:Z.hasAttribute(ee);if(o.formState!=="property"){let oe=M.hasAttribute(ee);if(oe!==ue){if(z(ee,M,ue?"update":"remove")===!1)return;ue?M.setAttribute(ee,""):M.removeAttribute(ee),a.push({kind:"attr",el:M,name:ee,before:oe?"":null,after:ue?"":null})}}M[ee]!==ue&&(M[ee]=ue)}function sn(M,Z,ee){if(o.protectFocusedValue&&Qt(M)||z("value",M,"update")===!1)return;let ue=Bt(ee),oe=Z.textContent,fe=ue&&ue.value!==ue.defaultValue?ue.value:oe;o.formState!=="property"&&M.textContent!==oe&&(a.push({kind:"text",node:M,before:M.textContent,after:oe}),M.textContent=oe),M.value!==fe&&(M.value=fe)}}function Vc(e,t){let n=e.activeElement;if(!n||n===e.body||n===e.documentElement)return null;let o={el:n,id:n.getAttribute&&n.getAttribute("id"),scrollTop:n.scrollTop,scrollLeft:n.scrollLeft};if(n.tagName==="INPUT"||n.tagName==="TEXTAREA"){try{o.selection=[n.selectionStart,n.selectionEnd,n.selectionDirection]}catch{}return o}let r=e.getSelection&&e.getSelection();if(r&&r.rangeCount){let i=r.getRangeAt(0);o.range={sc:i.startContainer,so:i.startOffset,ec:i.endContainer,eo:i.endOffset}}return o}function Wc(e,t,n,o,r,i,c){if(!t)return;let s=t.el;if(!s.isConnected&&t.id&&(s=e.getElementById(t.id)),!s||!s.isConnected)return;if(e.activeElement!==s)try{s.focus({preventScroll:!0})}catch{}try{s.scrollTop=t.scrollTop,s.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{s.setSelectionRange&&!s.selectionEnd&&t.selection[1]!=null&&s.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let a=(d,b)=>{let A=n.get(d);if(Array.isArray(A)){let S=A.find(x=>b>=x.from&&b<x.to)||A.find(x=>b===x.to)||A[A.length-1],L=i.get(S.merged);if(!L||!L.isConnected)return null;let f=o.get(S.merged),g=f&&f.flat?f.flat(S.flatStart+b):b;return[L,Math.max(0,Math.min(g,L.nodeValue.length))]}if(A&&!c.has(A.merged)){let S=(r.get(A.merged)||[d])[0];if(!S.isConnected)return null;let L=o.get(A.merged),f=A.shift+b,g=L?L(f):f;return[S,Math.max(0,Math.min(g,S.nodeValue.length))]}return d.isConnected?[d,Math.min(b,d.nodeType===3?d.nodeValue.length:d.childNodes.length)]:null},m=a(t.range.sc,t.range.so),h=a(t.range.ec,t.range.eo);if(!(!m||!h))try{let d=e.createRange();d.setStart(m[0],m[1]),d.setEnd(h[0],h[1]);let b=e.getSelection();b.removeAllRanges(),b.addRange(d)}catch{}}var $c={compared:0},qc=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Fc(e,t,n){let o=0;for(let r of e.attributes)if(!n(e,r.name)&&(o++,t.getAttribute(r.name)!==r.value))return!1;for(let r of t.attributes)n(t,r.name)||o--;return o===0}function Dr(e,t){if(e.namespaceURI!==t.namespaceURI||e.prefix!==t.prefix||e.localName!==t.localName)return!1;let n=e.attributes;if(n.length!==t.attributes.length)return!1;for(let o of n)if(t.getAttributeNS(o.namespaceURI,o.localName)!==o.value)return!1;return!0}function Xs(e,t,n,o,r,i,c,s){let a=new Map,m=new Set,h=d=>{if(o(d))return;let b=n(d);b&&(i.add(b),r.has(b)||a.has(b)?m.add(b):a.set(b,d))};for(let d of e)h(d);h(t);for(let d of c||t.querySelectorAll("*"))h(d);for(let d of m)a.delete(d),s.add(d);return a}function Qs(e,t,n,o,r,i){let c=!1;for(let h of r)h.startsWith("merge:")&&(c=!0);if(!c)return[...o];let s=new Map,a=[],m=i===fn?So:"*";for(let h of[e,...e.querySelectorAll(m)]){if(n(h))continue;let d=t(h);if(!d||!(o.has(d)||r.has(d)))continue;let b=(s.get(d)||0)+1;s.set(d,b),b===2&&a.push(d)}return a}function Zs({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:o,o:r,identity:i,baseURI:c}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!Fc(e,t,r.ignoreAttribute))return{bail:"root-attrs"};let{ignored:s,remoteWins:a}=r,m=Pr(r.scripts.merge===!1?null:r.scripts.mergeTags,c),h=Se=>{let O=m(Se);return O!==null?O:i.base(Se)||null},d=Se=>{let O=m(Se);return O!==null?O:i.remote(Se)||null},b=[],A=[],S=new Map,L=new Map,f={same:S,differ:L},g=Se=>({bail:Se,comparisons:f}),x=(Se,O,B=!0)=>{if(S.get(Se)===O)return!0;if(L.get(Se)===O)return!1;if($c.compared++,B&&Se.isEqualNode(O))return S.set(Se,O),!0;let ae=Se.nodeType===O.nodeType;if(ae&&Se.nodeType===1){if(ae=Dr(Se,O),ae){let be=Se.firstChild,de=O.firstChild;for(;be&&de;be=be.nextSibling,de=de.nextSibling)if(!x(be,de,!1)){ae=!1;break}(be||de)&&(ae=!1)}}else ae&&(ae=Se.isEqualNode(O));return(ae?S:L).set(Se,O),ae},Q=e,se=t,le=!1,q=()=>{S.set(Q,se);for(let Se=0;Se<b.length;Se++)S.set(b[Se],A[Se]);return g("equal")};for(;;){let Se=Q.childNodes,O=se.childNodes;if(Se.length!==O.length)break;let B=st=>x(Se[st],O[st])?(S.set(Se[st],O[st]),!1):!0,ae=-1,be=-1;for(let st=0;st<Se.length;st++){if(Se[st].nodeType!==1)continue;let wt=0;for(let bt=Se[st].firstElementChild;bt;bt=bt.nextElementSibling)wt++;wt>=be&&(be=wt,ae=st)}let de=[],ze=!1;for(let st=0;st<Se.length&&de.length<2;st++)st!==ae&&B(st)&&de.push(st);if(ae>=0&&de.length<2&&(de.length===0&&Dr(Q,se)?(de.push(ae),ze=!0):B(ae)&&de.push(ae)),de.length!==1){if(!le&&de.length===0&&Dr(Q,se))return q();break}let De=Se[de[0]],Qe=O[de[0]];if(le=le||!ze,le&&L.set(De,Qe),De.nodeType!==1||Qe.nodeType!==1||De.tagName!==Qe.tagName)break;if(h(De)!==d(Qe)){if(!le&&x(De,Qe))return q();break}b.push(Q),A.push(se),Q=De,se=Qe}L.set(Q,se);for(let Se=0;Se<b.length;Se++)L.set(b[Se],A[Se]);if(Q===e||Q.tagName==="HEAD"||Q.tagName==="BODY")return g("root-level");if(b.length<2||b[1].tagName!=="BODY")return g("not-in-body");if(s(Q)||s(se))return g("ignored-ancestor");if(a(Q)||a(se))return g("remote-wins-ancestor");for(let Se of b)if(qc.has(Se.tagName))return g("form-ancestor");if(Q.tagName==="SCRIPT"||Q.getElementsByTagName("script").length||se.getElementsByTagName("script").length)return g("script-or-template");let z=o(Q);if(!z||z.nodeType!==1||z.tagName!==Q.tagName)return g("no-live-twin");if(!n.contains(z))return g("live-detached");for(let Se of b){let O=o(Se);if(!O||O.nodeType!==1)return g("ancestor-live")}let ce=i.base===fn&&i.remote===fn&&s===pr,xe=new Set,te=new Set,J=[],Ce=null,we=Se=>{Se&&(xe.has(Se)?te.add(Se):xe.add(Se))},ne=(Se,O)=>{let B=m(Se),ae=B!==null?B:i.base(Se)||null;return ae!==(B!==null?B:i.remote(O)||null)?!1:(we(ae),!0)},_=(Se,O)=>{for(let B=Se.firstElementChild,ae=O.firstElementChild;B;B=B.nextElementSibling,ae=ae.nextElementSibling){let be=s(B);if(be!==s(ae))return!1;if(!be&&(!ne(B,ae)||!_(B,ae)))return!1}return!0},ye=Se=>{let O=Se+1<b.length?b[Se+1]:Q;for(let B=b[Se].firstElementChild,ae=A[Se].firstElementChild;B;B=B.nextElementSibling,ae=ae.nextElementSibling){if(B===O){let ze=Se+1<b.length?ye(Se+1):null;if(ze)return ze;continue}let be=s(B);if(be!==s(ae))return"outside-id-changed";if(be)continue;let de=o(B);if(!de||de.nodeType!==1)return"sibling-live";if(J.push([B,ae]),!ce&&(!ne(B,ae)||!_(B,ae)))return"outside-id-changed";Se===0&&B.tagName==="HEAD"&&h(B)&&(Ce=[B,ae])}return null},ge=ye(0);if(ge)return g(ge);let Oe=new Set(b),Be=null;if(i.base===fn){Be=[];for(let Se of e.querySelectorAll(So))Se===Q||Oe.has(Se)||(Q.contains(Se)?Be.push(Se):ce&&we(h(Se)))}let We=new Set,rt=new Set,re=new Set,ut=Xs(b,Q,h,s,xe,We,Be,rt),dt=Xs(A,se,d,s,xe,We,i.remote===fn&&se.querySelectorAll(So),re);return Ce&&(te.has(h(Ce[0]))||We.has(h(Ce[0])))&&(Ce=null),{scope:{chain:b,root:Q,onChain:Oe,baseIndex:ut,remoteIndex:dt,head:Ce,same:S,differ:L,dropped:[...Qs(e,h,s,te,rt,i.base),...Qs(t,d,s,te,re,i.remote)],held:Se=>{for(let O=1;O<b.length;O++)if(Se.map.get(b[O])!==A[O])return!1;for(let[O,B]of J)if(Se.map.get(O)!==B)return!1;return!0}}}}var Ca=Symbol("hyper-morph-duplicate-key");var Kc='[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"]',zc='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Gc='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Yc(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let t=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(t)}function Jc(e,t,n,o){if(t==null)return;if(typeof t=="string")return t;let r=t;if(r.nodeType===9){let i=e.getAttribute("id");r=i&&r.getElementById(i)||(e.tagName==="BODY"?r.body:e.tagName==="HTML"?r.documentElement:r.body&&r.body.firstElementChild)}if((!r||r.nodeType!==1||r.tagName!==e.tagName)&&(r=Xc(e,t,o)),!!r)return n?Array.from(r.childNodes):r}function Xc(e,t,n){let o=t.nodeType===9?t.documentElement:t;if(!o||o.nodeType!==1)return null;let r=new Map,i=[o,...o.querySelectorAll("script")];for(let a of i){let m=lo(a,n);m&&!r.has(m.key)&&r.set(m.key,a.textContent)}if(!r.size)return null;let c=e.cloneNode(!0),s=!1;for(let a of[c,...c.querySelectorAll("script")]){let m=lo(a,n);m&&r.has(m.key)&&(a.textContent=r.get(m.key),s=!0)}return s?c:null}function ei(e,t){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let n=t.implementation.createHTMLDocument(""),o=e.nodeType===1&&e.tagName==="HTML"?e:null;if(o)return n.replaceChild(n.adoptNode(o),n.documentElement),n;let r=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let i of r)n.body.appendChild(n.adoptNode(i));return n}function Hr(e,t,n={}){let o=n||{};if(!o.head?.block)return ti(e,t,o);try{return ti(e,t,o)}catch(r){return Promise.reject(r)}}function ti(e,t,n){let o=n.policy||"sync",r=o==="raw"?void 0:(a,m)=>Yc(a)||(o==="history"?!(m&&a.matches(Gc))&&a.matches(zc):a.matches(Kc)),i=n.callbacks||{},c={ignore:r,hooks:i,protectFocusedValue:n.ignoreActiveValue===!0?"subtree":!1,restoreFocus:n.restoreFocus!==!1,formState:n.formStateSync||"attribute",scripts:{execute:n.scripts?.handle!==!1,merge:n.scripts?.merge!==!1,mergeTags:n.scripts?.mergeTags||[]},head:{awaitLoads:!!n.head?.block,preserve:n.head?.shouldPreserve||(()=>!1)}};if(typeof n.key=="function"&&(c.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return No(Object.assign({},c,{live:e,base:n.scripts?.mergeBase||null,remote:ei(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let a=Object.assign({},c,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:ei(t,e.ownerDocument)});return No(a)}n.morphStyle==="innerHTML"&&(c.children=!0);let s=Jc(e,n.scripts?.mergeBase,!!c.children,c.scripts.mergeTags);return s!==void 0&&(c.base=s),Br(e,t,c)}var Qc=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),mn=()=>{};function Oo(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let c of Object.keys(e))if(!Qc.has(c))throw new TypeError(`unknown option "${c}"`);let n=Object.assign({beforeNodeAdded:mn,afterNodeAdded:mn,beforeNodeRemoved:mn,afterNodeRemoved:mn,beforeNodeMorphed:mn,afterNodeMorphed:mn,beforeAttributeUpdated:mn},e.hooks||{}),o=e.conflicts||"remote";if(!["remote","local","both"].includes(o))throw new TypeError("conflicts must be remote, local or both");let r=e.formState||"attribute";if(!["attribute","property"].includes(r))throw new TypeError("formState must be attribute or property");let i=e.protectFocusedValue;if(i!==void 0&&typeof i!="boolean"&&i!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");return{ignored:hr(e.ignore,t),remoteWins:hr(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:o,protectFocusedValue:i===void 0?!0:i,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:r,hooks:n,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0}}function fo(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 fn}function uo(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=mr(t,e.map),o=typeof e.then=="function"?e.then:fn;if(typeof e.first=="function"){let r=e.first;return i=>r(i)||n.get(i)||o(i)}return r=>n.get(r)||o(r)}return fn}function Zc(e,t,n,o={}){let r=A=>A&&A.nodeType===9?A.documentElement:A,i=r(t),c=r(n),s=r(e)||i,a=Object.assign({},o);delete a.live,delete a.base,delete a.remote;let m=Oo(a,[s,i,c].filter(Boolean)),h=o.identity||{},d=jn(),b=er(s,i,c,{identity:{base:uo(h.base,s),local:uo(h.local,i),remote:uo(h.remote,c)},authored:{base:fo(h.base),local:fo(h.local),remote:fo(h.remote)},skipUnchanged:m.hooks.beforeNodeMorphed===mn&&m.hooks.afterNodeMorphed===mn,ignored:m.ignored,remoteWins:m.remoteWins,ignoreAttribute:m.ignoreAttribute,conflicts:m.conflicts,mergeTags:m.scripts.merge===!1?null:m.scripts.mergeTags,baseURI:i.ownerDocument&&i.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:m.children,stats:d});return delete b.recoveryLinks,b}function Ur({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:o,toLive:r,options:i,identity:c,childrenOnly:s,isDocument:a}){let m=Oo(i,[e,t,n,o].filter(Boolean));if(m.ignored(e))return{report:_r(),loads:[]};let h=e.ownerDocument,d=m.scripts.execute?Ls(e,m.ignored,h.baseURI):null,b=jn(),A=m.hooks.beforeNodeMorphed===mn&&m.hooks.afterNodeMorphed===mn,S={identity:{base:uo(c.base,t||n),local:uo(c.local,n),remote:uo(c.remote,o)},authored:{base:fo(c.base),local:fo(c.local),remote:fo(c.remote)},ignored:m.ignored,remoteWins:m.remoteWins,ignoreAttribute:m.ignoreAttribute,conflicts:m.conflicts,mergeTags:m.scripts.merge===!1?null:m.scripts.mergeTags,baseURI:h.baseURI,localIsBase:!t,childrenOnly:s,skipUnchanged:A},L=m.fastPath&&a&&!s&&A&&t===n,f=null,g=null;if(L){let we=Zs({baseRoot:t,remoteRoot:o,liveRoot:e,toLive:r,o:m,identity:S.identity,baseURI:h.baseURI});S.comparisons=we.comparisons||we.scope,we.bail?g=we.bail:(f=er(t,n,o,Object.assign({},S,{stats:b,scope:we.scope})),f||(g="chain-unpaired",b=jn()))}f||(f=er(t||n,n,o,Object.assign({},S,{stats:b}))),L&&(b.fastPathAttempted=1,b.fastPathTaken=g?0:1,b.fastPathFallback=g),f.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(we=>m.hooks[we]!==mn)&&Ws(f.conflicts,f.recoveryLinks,r),m.beforeApply&&m.beforeApply(f.doc);let x=globalThis.__hyperMorphProfile,Q=x?performance.now():0,se=Js(e,f.root,f,{toLive:r,ignored:m.ignored,ignoreAttribute:m.ignoreAttribute,formState:m.formState,protectFocusedValue:m.protectFocusedValue,restoreFocus:m.restoreFocus,preserve:m.head.preserve,hooks:m.hooks,childrenOnly:s,keepLiveOnly:m.keepLiveOnly});x&&(x.apply=(x.apply||0)+(performance.now()-Q));let le=[];if(m.head.awaitLoads)for(let we of se.applied){if(we.kind!=="insert"||we.node.nodeType!==1)continue;let ne=we.node;ne.tagName==="LINK"&&/\bstylesheet\b/i.test(ne.getAttribute("rel")||"")&&ne.getAttribute("href")&&ne.closest("head")&&le.push(new Promise(ye=>{ne.addEventListener("load",()=>ye()),ne.addEventListener("error",()=>ye())}))}let q=null,z=null;if(d){let we=Rs(e,d,{ignored:m.ignored,skip:se.mergedScriptsLive,baseURI:h.baseURI,beforeNodeAdded:m.hooks.beforeNodeAdded,afterNodeAdded:m.hooks.afterNodeAdded,trackRecovery:!!f.recoveryLinks});le.push(...we.loads),q=we.swapped,z=we.vetoed}let ce=we=>q&&q.get(we)||we,xe=we=>{if(se.keptRuns.has(we))return se.runOf.get(we);let ne=se.liveOf.get(we)||se.heldBy.get(we)||se.insertedLive.get(we);return ne?ce(ne):null},te=we=>{let ne=we&&se.liveOf.get(we);return ne?ce(ne):null},J=we=>{let ne=we&&xe(we);return Array.isArray(ne)?ne[0]:ne};if(f.recoveryLinks){let we=(ne,_,ye)=>(_.namespaceURI?ne.getAttributeNS(_.namespaceURI,_.localName):ne.getAttribute(_.qualifiedName))===ye;Fs(f.conflicts,f.recoveryLinks,{lookup:xe,vetoed:se.vetoed,vetoedAttrs:se.vetoedAttrs,removedVetoes:se.removedVetoes,vetoedLive:z,liveAttr:we,ignored:m.ignored,liveRoot:e})}return{report:{applied:se.applied,decisions:f.decisions.map(we=>Object.assign({},we,{node:we.node?te(we.node):null,el:we.el?te(we.el):null,applied:!!(we.node?te(we.node):we.el&&te(we.el))})),conflicts:f.conflicts.map(we=>Object.assign({},we,{node:we.node?we.kind==="text"&&we.recovery.subject.nodeType===8?J(we.node):te(we.node):we.node,el:we.el?we.kind==="structure"?J(we.el):te(we.el):we.el})),localDiverged:f.localDiverged,identities:se.identities,moved:se.moved,replaced:se.replaced,stats:b},loads:le}}var ni=new WeakMap;function _r(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:jn()}}function No(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let o=ni.get(n);o||(o=dr(n),ni.set(n,o));let r=o("remote",t.remote),i=typeof t.base=="string"&&t.base===""?null:t.base,c=i?o("base",i):null,s=t.local?t.local.root:n.documentElement,a=t.local?t.local.toLive:d=>d;gs(n,r);let{report:m,loads:h}=Ur({liveRoot:n.documentElement,baseRoot:c?c.documentElement:null,localRoot:s,remoteRoot:r.documentElement,toLive:a,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(h).then(()=>m)}function el(e,t,n={}){return No(Object.assign({},n,{live:e,base:null,remote:t}))}function oi(e,t){if(e==null)return{root:t.createElement("template"),first:null};if(typeof e=="string"){let o=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(o){let i=Ko(e,t),c=o[1].toLowerCase()==="html"?i.documentElement:i.body;return{root:c,first:c}}let r=t.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let o=t.createElement("template"),r=e.isConnected;return o.content.appendChild(r?t.importNode(e,!0):e),{root:o,first:e}}if(e.nodeType===11){let o=t.createElement("template");return o.content.appendChild(e),{root:o,first:o.content.firstElementChild}}let n=t.createElement("template");for(let o of Array.from(e))n.content.appendChild(o.parentNode?t.importNode(o,!0):o);return{root:n,first:n.content.firstElementChild}}function Br(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let o=e.ownerDocument,{base:r,...i}=n,c=!!i.children;if(Oo(i,[e]).ignored(e))return Promise.resolve(_r());let s=oi(t,o),a=r!=null?oi(r,o):null,m,h=null;if(c)m=s.root,h=a?a.root:null;else{if(m=s.first,h=a?a.first:null,!m){let A=Oo(i);return A.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),A.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:jn()})}if(m.tagName!==e.tagName){let A=Oo(i,[e,m]);if(A.hooks.beforeNodeMorphed(e,m)===!1)return Promise.resolve(_r());let S=Ur({liveRoot:e,baseRoot:h&&h.tagName===e.tagName?h:null,localRoot:e,remoteRoot:m,toLive:f=>f,options:i,identity:i.identity||{},childrenOnly:!0,isDocument:!1}),L=tn(m)?To(m,o):o.importNode(m,!1);if(!tn(L))for(;e.firstChild;)L.appendChild(e.firstChild);return A.hooks.beforeNodeAdded(L)===!1?(Zo(S.report.conflicts,e,e),Promise.resolve(S.report)):A.hooks.beforeNodeRemoved(e)===!1?(Zo(S.report.conflicts,e,e),Promise.resolve(S.report)):(e.replaceWith(L),Zo(S.report.conflicts,e,L),A.hooks.afterNodeRemoved(e),A.hooks.afterNodeAdded(L),A.hooks.afterNodeMorphed(e,m),S.report.replaced.push(L),S.report.applied.push({kind:"insert",node:L,parent:L.parentNode},{kind:"remove",node:e,parent:L.parentNode}),Promise.all(S.loads).then(()=>S.report))}}let{report:d,loads:b}=Ur({liveRoot:e,baseRoot:h,localRoot:e,remoteRoot:m,toLive:A=>A,options:i,identity:i.identity||{},childrenOnly:c,isDocument:!1});return Promise.all(b).then(()=>d)}var ri={mergeDocument:No,morphDocument:el,morphElement:Br,merge3:Zc,morph:Hr};function Vr(e,t,{onWidgetRemoved:n}={}){ri.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=qo.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var nl="hha:upgrade-check:";function Sn(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function Wr(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function si(e,t){let n=Wr(e),o=Wr(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let c=n[i]||0,s=o[i]||0;if(c!==s)return c>s}return!1}function ol(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function rl(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function $r({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:i=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(b=>fetch(b)),r=r??Date.now(),!t)return null;let c=Sn(t,"hyper-source");if(!c)return null;let s=Sn(t,"hyper-version"),a;try{a=new URL(c,n?n.href:void 0)}catch{return null}if(n&&a.origin===n.origin&&a.pathname===n.pathname)return null;let m=`${nl}${a.href}:${s||"none"}`,h,d=e?null:ol(m);if(d&&typeof d.checkedAt=="number"&&r-d.checkedAt<i)h=d.sourceVersion;else{try{let b=await o(a.href);if(!b.ok)throw new Error(`HTTP ${b.status}`);let A=await b.text(),S=new DOMParser().parseFromString(A,"text/html");h=Sn(S,"hyper-version")}catch{h=null}rl(m,{checkedAt:r,sourceVersion:h})}return h?{available:si(h,s||"0.0.0"),currentVersion:s,sourceVersion:h,sourceUrl:a.href}:null}var tr=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],qr=new Set(tr),ii=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),Fr=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var or={};cr(or,{EmptyListInsert:()=>Mo,MAX_RULE_DEPTH:()=>ho,MaxRuleDepthExceeded:()=>Yn,NoRulesTag:()=>Kr,RuleTargetReadOnly:()=>Eo,RulesParseError:()=>po,ShapeMismatch:()=>vo,UnknownRulesVersion:()=>Gn,WriteRefused:()=>nr,WriteRejected:()=>zr});var po=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},Gn=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},ho=20,Yn=class extends Error{constructor(t){super(`rule depth exceeded ${ho} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},vo=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},Mo=class extends Error{constructor(t){super(`cannot add items to empty list at "${t.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=t}},Eo=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},nr=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}},Kr=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},zr=class extends Error{constructor(t,n){super(`write rejected: ${t.length} unknown key(s), ${n.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=t,this.unmatched=n}};function Nn(e,t,n,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Gr(e,t,n,{depth:0,path:[]},o)}function Gr(e,t,n,o,r){if(o.depth>ho)throw new Yn(o.path);if(typeof n=="string")return sl(e,t,n,o,r);if(Array.isArray(n)){let[i,c]=n,s=e.find(t,i,r);return li(r,o,s),s.map((a,m)=>Gr(e,a,c,{depth:o.depth+1,path:[...o.path,m]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[c,s]of Object.entries(n))i[c]=Gr(e,t,s,{depth:o.depth+1,path:[...o.path,c]},r);return i}return null}function sl(e,t,n,o,r){if(n.endsWith("[]")){let s=n.slice(0,-2),a=e.find(t,s,r);return li(r,o,a),a.map(m=>e.text(m))}if(n.startsWith("@"))return ci(e,t,n.slice(1));let i=Mn(n);if(i!==-1){let s=n.slice(0,i),a=n.slice(i+1),m=s?e.find(t,s,r):[t];return m.length===0?null:ci(e,m[0],a)}if(n===".")return e.text(t);let c=e.find(t,n,r);return c.length===0?null:e.text(c[0])}function li(e,t,n){if(typeof e.onRowsRead=="function")try{e.onRowsRead(t.path.slice(),n)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${t.path.join(".")||"(root)"}"`,o)}}function ci(e,t,n){if(qr.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o||null}var ai=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),il=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),fi=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function Yr(e,t){if(!e||e.nodeType!==1)return!1;let n=e.getAttribute?.("clay");return!!(n&&n.split(/\s+/).includes(t)||e.hasAttribute?.(t))}function cl(e,t){if(Yr(e,t))return!0;for(let[n,o]of Object.entries(il))if(o.includes(t)&&Yr(e,n))return!0;return!1}function Io(e){let t=ai[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function ll(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=ai[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>cl(n,r))||o.bundles.some(r=>Yr(n,r)))return n;n=n.parentElement}return null}function ui(e,t){return!!ll(e,t)}var al=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function di(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&(t.value=e.value),"checked"in e&&"checked"in t&&(t.checked=e.checked),"selected"in e&&"selected"in t&&(t.selected=e.selected),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)t.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function pi(e,t,n,o){if(o)return!!e.closest?.(t);let r=e;for(;r?.nodeType===1;){if(r.matches(t))return!0;if(r===n)break;r=r.parentElement}return!1}function hi(e,t,n,o,r,i,c,s){if(e.nodeType===1&&((c?ui(e,n):pi(e,o,i,!1))||r&&(c&&e!==i?e.matches(r):pi(e,r,i,c))))return null;let a=t.importNode(e,!1);s.cloneToLive.set(a,e),s.liveToClone.set(e,a);let m=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,h=a.nodeType===1&&a.tagName==="TEMPLATE"?a.content:a;m!==e&&(s.cloneToLive.set(h,m),s.liveToClone.set(m,h));for(let d of m.childNodes||[]){let b=hi(d,t,n,o,r,i,c,s);b&&(h.appendChild(b),d.nodeType===1&&di(d,b))}return e.nodeType===1&&di(e,a),a}function Co(e,{capability:t="data",exclude:n=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let i=r.implementation.createHTMLDocument(""),c=new WeakMap,s=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&i.documentElement.matches(n);let m=Io(t),h=hi(a,i,t,m,n,a,o,{cloneToLive:c,liveToClone:s});e.nodeType===9&&h&&(i.replaceChild(h,i.documentElement),s.set(e,i),c.set(i,e));let d=b=>{if(al.test(b))throw new Error(`Filtered content queries do not support stateful selector: ${b}`)};return{root:h,document:i,capability:t,selector:Io(t),cloneToLive:c,liveToClone:s,original(b){return c.get(b)||null},cloneOf(b){return s.get(b)||null},query(b,A=h){return d(b),Array.from(A.querySelectorAll(b),S=>c.get(S)||S)},text(b=h){return(b===h?h:s.get(b))?.textContent||""},html(b=h){return(b===h?h:s.get(b))?.innerHTML??""},clone(b=h){let A=b===h?h:s.get(b);return A?i.importNode(A,!0):null}}}function mi(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function fl(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var $t={semanticExclude:!0,find(e,t,n={}){let o=fl(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(s=>!mi(s)));let i=[];n.skip&&i.push(n.skip);let c=n.templateAttr===null?null:n.templateAttr||"cms-template";if(c&&i.push("["+c+"]"),i.length){let s=i.join(", ");r=r.filter(a=>!a.closest||!a.closest(s))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t)},prop(e,t,n){if(n===void 0){let o=e?e[t]:void 0;return o!==void 0?o:null}e[t]=n},clone(e){return e.cloneNode(!0)},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,t){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=t;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let t=0;return e.id&&(e.removeAttribute("id"),t++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),t++}),t},sameNode(e,t){return e===t}};function Jn(e,t={}){if(t.exclude===null)return $t;let n=[Io("data"),t.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!t._write&&!r?.matches?.(n)&&!r?.querySelector?.(n)&&!o?.querySelector?.(n))return $t;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,c=e.nodeType===9?e:e.ownerDocument,s=null,a=()=>s||(s=Co(i,{capability:"data",exclude:t.exclude||null})),m=S=>{let L=a();return S===e?L.cloneOf(e):L.cloneOf(S)||S},h=S=>s?.original(S)||S,d=(S,L)=>{a().liveToClone.set(S,L),a().cloneToLive.set(L,S);let f=S.childNodes||[],g=L.childNodes||[];for(let x=0;x<Math.min(f.length,g.length);x++)d(f[x],g[x])},b=(S,L,f,g)=>{let x=Array.from(S.childNodes).filter(z=>s.cloneOf(z)),se=x[0];for(;se&&x.includes(se);)se=se.nextSibling;for(let z of x)z.remove();if(f==="innerHTML"){let z=c.createElement("template");z.innerHTML=g;for(let ce of Array.from(z.content.childNodes))S.insertBefore(ce,se||null)}else S.insertBefore(c.createTextNode(g),se||null);let le=Co(S,{capability:"data",exclude:t.exclude||null});L.replaceChildren(...Array.from(le.root?.childNodes||[]));let q=z=>{let ce=le.original(z);ce&&(s.liveToClone.set(ce,z),s.cloneToLive.set(z,ce));for(let xe of Array.from(z.childNodes||[]))q(xe)};for(let z of Array.from(L.childNodes))q(z)},A={...$t,find(S,L,f={}){let g=m(S);if(!g?.querySelectorAll)return[];let x=a().query(L,g);f.includeRulesTag||(x=x.filter(le=>!mi(le)));let Q=[];f.skip&&Q.push(f.skip);let se=f.templateAttr===null?null:f.templateAttr||"cms-template";if(se&&Q.push(`[${se}]`),Q.length){let le=Q.join(", ");x=x.filter(q=>!q.closest?.(le))}return x},parent(S){let L=m(S)?.parentElement;return L?h(L):null},children(S){return Array.from(m(S)?.children||[],h)},text(S,L){if(L===void 0){let x=h(S);return!x?.matches?.(n)&&!x?.querySelector?.(n)?$t.text(x):(m(S)?.textContent||"").trim()}let f=h(S);if(!f?.matches?.(n)&&!f?.querySelector?.(n)&&!s){$t.text(f,L);return}let g=a().cloneOf(f);g?b(f,g,"textContent",L):$t.text(f,L)},attr(S,L,f){let g=h(S);if(f===void 0)return $t.attr(g,L);$t.attr(g,L,f);let x=s?.cloneOf(g);x&&($t.attr(x,L,f),Co(g,{capability:"data",exclude:t.exclude||null}).root===null&&(x.remove(),s.liveToClone.delete(g),s.cloneToLive.delete(x)))},removeAttr(S,L){let f=h(S);$t.removeAttr(f,L);let g=s?.cloneOf(f);g&&$t.removeAttr(g,L)},prop(S,L,f){let g=h(S);if(f===void 0)return L==="innerHTML"||L==="outerHTML"||L==="textContent"||L==="innerText"?$t.prop(m(g),L):$t.prop(g,L);let x=L==="innerHTML"||L==="textContent"||L==="innerText",Q=x?a().cloneOf(g):s?.cloneOf(g);Q&&x?b(g,Q,L,f):($t.prop(g,L,f),Q&&$t.prop(Q,L,f))},clone(S){let L=m(S);return L===S?$t.clone(S):c.importNode(L,!0)},insertAt(S,L,f){let g=h(S),Q=A.children(g)[f]||(()=>{for(let q=g.children.length-1;q>=0;q--){let z=g.children[q];if(a().cloneOf(z))return z.nextElementSibling}return g.firstElementChild})(),se=h(L);g.insertBefore(se,Q||null);let le=a().cloneOf(g);if(le){let q=a().cloneOf(se);q||(q=c.importNode(se,!0),d(se,q));let z=Array.from(le.children);le.insertBefore(q,z[f]||null)}},remove(S){let L=h(S),f=a().cloneOf(L);$t.remove(L),f&&$t.remove(f)},replaceWith(S,L){let f=h(S),g=a().cloneOf(f),x=$t.replaceWith(f,L);if(g){let Q=Co(x,{capability:"data",exclude:t.exclude||null});if(!Q.root)g.remove();else{g.replaceWith(Q.root);let se=le=>{let q=Q.original(le);q&&(s.liveToClone.set(q,le),s.cloneToLive.set(le,q));for(let z of Array.from(le.childNodes||[]))se(z)};se(Q.root)}}return x}};return A}var gn=$t;function Jr(e){try{return JSON.parse(e)}catch(t){throw new po(`Invalid strict JSON: ${t.message}`,t)}}function Xn(e){try{return JSON.parse(e)}catch{}let t={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function n(r){let i=[],c=0;for(;c<r.length;){let s=r[c];if(/\s/.test(s)){c++;continue}if("{}".includes(s)){i.push({type:s,value:s}),c++;continue}if(s==="["){let d=!1,b=c+1;for(;b<r.length&&/\s/.test(r[b]);)b++;if(b<r.length&&/[a-zA-Z_]/.test(r[b])&&(d=!0),!d){i.push({type:s,value:s}),c++;continue}}if(s==="]"){i.push({type:s,value:s}),c++;continue}if(s===":"){i.push({type:t.COLON,value:s}),c++;continue}if(s===","){i.push({type:t.COMMA,value:s}),c++;continue}if(s==='"'||s==="'"){let d=s,b=c+1;for(;b<r.length&&r[b]!==d;)r[b]==="\\"&&b++,b++;i.push({type:t.STRING,value:r.substring(c+1,b),quoted:!0,sourceQuote:d}),c=b+1;continue}let a=c,m;for(;a<r.length&&!/[{},]/.test(r[a]);)if(r[a]===":"){let d=[":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"],b=!1;for(let A of d){let S=A.substring(1);if(r.substring(a+1,a+1+S.length)===S){b=!0,a+=S.length;break}}if(!b)break}else if(r[a]==="["){for(a++;a<r.length&&r[a]!=="]";){if(r[a]==='"'||r[a]==="'"){let d=r[a];for(a++;a<r.length&&r[a]!==d;)r[a]==="\\"&&a++,a++}a++}a<r.length&&r[a]==="]"&&a++}else a++;m=r.substring(c,a);let h=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(m)?h=t.NUMBER:m==="true"||m==="false"||m==="null"?h=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(m)&&(h=t.SELECTOR),i.push({type:h,value:m,quoted:!1}),c=a}return i}function o(r){let i="";for(let c=0;c<r.length;c++){let s=r[c];if("{}".includes(s.type)||"[]".includes(s.type)){i+=s.value;continue}if(s.type===t.COLON){i+=s.value;continue}if(s.type===t.COMMA){let a=r[c+1];if(a&&(a.type==="}"||a.type==="]"))continue;i+=s.value;continue}if(s.type===t.STRING&&s.quoted){let a=s.value;s.sourceQuote==="'"&&(a=a.replace(/\\'/g,"'"),a=a.replace(/(\\*)"/g,(m,h)=>h.length%2===0?h+'\\"':m)),i+=`"${a}"`;continue}if(s.type===t.NUMBER||s.type===t.BOOLEAN){i+=s.value;continue}if(s.type===t.SELECTOR||s.type===t.IDENTIFIER){i+=`"${s.value}"`;continue}i+=`"${s.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new po("Invalid extraction rules syntax: "+r.message,r)}}var Xr="1",gi=/^[a-zA-Z0-9_-]+$/;function mo(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!gi.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${gi})`);o=`script[data-rules-name~="${n}"]`}let r=e.find(t,o,{includeRulesTag:!0});if(r.length===0)return null;n!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${n}"; using the first.`);let i=r[0],c=e.attr(i,"data-rules-version");if(c!==Xr)throw new Gn(c);return{rules:Xn(e.text(i)),tagNode:i}}var ul="script[data-rules-name]";function bi(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function Lo(e,t){let n=e.find(t,ul,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let c=bi(e.attr(i,"data-rules-name"));if(!c)continue;if(o.has(c)){console.warn(`hyper-html-api: duplicate rules tag name "${c}"; using the first.`);continue}let s=e.attr(i,"data-rules-version");if(s!==Xr)throw new Gn(s);o.add(c),r.push({name:c,rules:Xn(e.text(i))})}return r}function rr(e,t){let n={};for(let{name:o,rules:r}of Lo(e,t))n[o]=Nn(e,t,r);return n}function Qr(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:rr(gn,t),version:Sn(n,"hyper-version")}}var go=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},Ro=class extends Error{constructor(t){super(`upgrade source has no rules tags; refusing to drop all existing data: ${t}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=t}},Un=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},Po=class extends Error{constructor(t){super(`found ${t} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=t}};var yi="text/hyper-upgrade";function Zr(e,t){let n=e.find(t,`script[type="${yi}"]`);if(n.length===0)return null;if(n.length>1)throw new Po(n.length);return e.text(n[0])||null}var dl=new Function("url","return import(url)");async function es(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await dl(n)}catch(r){throw new Un(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new Un("transform must `export default` a function");return o.default}function xi(e,t,n,o){let r=e.length,i=t.length,c=new Array(r).fill(-1);if(o){let f=new Set;for(let g=0;g<r;g++){let x=o[g];!(x>=0&&x<i)||f.has(x)||(c[g]=x,f.add(x))}}if(r===0||i===0)return c;let s=e.map(f=>ki(f,n)),a=t.map(f=>ki(f,n)),m=new Array(i).fill(!1);for(let f of c)f>=0&&(m[f]=!0);let h=new Map;a.forEach((f,g)=>{m[g]||h.set(f,h.has(f)?-1:g)});let d=new Map;s.forEach((f,g)=>{c[g]>=0||d.set(f,(d.get(f)||0)+1)}),s.forEach((f,g)=>{if(c[g]>=0||d.get(f)!==1)return;let x=h.get(f);x===void 0||x===-1||m[x]||(c[g]=x,m[x]=!0)});let b=[];for(let f=0;f<r;f++)c[f]<0&&b.push(f);let A=[];for(let f=0;f<i;f++)m[f]||A.push(f);if(b.length===0||A.length===0)return c;let S=r*i+1,L=(f,g)=>pl(e[f],t[g],n)*S+Math.abs(f-g);for(let[f,g]of hl(b,A,L))c[f]=g;return c}var Ti=e=>typeof e=="object"&&e!==null;function ki(e,t){if(!Ti(t))return e==null?" null":String(e);let n=Object.keys(t);return JSON.stringify(n.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function pl(e,t,n){if(!Ti(n))return e===t?0:1;let o=Object.keys(n);if(o.length===0)return 0;let r=0;for(let i of o){let c=JSON.stringify(e?.[i]),s=JSON.stringify(t?.[i]);c!==s&&r++}return r}function hl(e,t,n){return e.length<=t.length?wi(e,t,n,!1):wi(t,e,(o,r)=>n(r,o),!0)}function wi(e,t,n,o){let r=e.length,i=t.length,c=[];for(let d=0;d<=r;d++)c.push(new Float64Array(i+1).fill(1/0));let s=[];for(let d=0;d<=r;d++)s.push(new Uint8Array(i+1));for(let d=0;d<=i;d++)c[r][d]=0;for(let d=r-1;d>=0;d--)for(let b=i-1;b>=0;b--){let A=n(e[d],t[b])+c[d+1][b+1],S=c[d][b+1];A<=S?(c[d][b]=A,s[d][b]=1):c[d][b]=S}let a=[],m=0,h=0;for(;m<r&&h<i;)s[m][h]&&(a.push(o?[t[h],e[m]]:[e[m],t[h]]),m++),h++;return a}function ns(e,t,n,o,r,i,c,s={}){let a=e.find(t,n,s);if(r.length===0){a.forEach(le=>e.remove(le)),ts(s,"onRowsApplied",i.path,[]);return}let m=r.length>a.length,h=a[0]||null;if(m&&!h&&(h=yl(e,t,n,s),!h))throw new Mo(i.path);let d=a.map(le=>bl(e,le,o,s)),b=null;if(m&&h){b=e.clone(h),s.templateAttr&&e.removeAttr(b,s.templateAttr);let le=e.stripIds(b);le>0&&console.warn(`[hyper-html-api] stripped ${le} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let A=xi(r,d,o,ml(e,a,r,i,s)),S=a[0]||h,L=e.parent(S),f=a.length>0?Ai(e,L,S):0,g=kl(e,a),x=new Set,Q=[],se=r.map((le,q)=>{let z=A[q];if(z>=0)return x.add(z),Q.push(!1),a[z];Q.push(!0);let ce=e.clone(b);return e.stripIds(ce),ce});a.forEach((le,q)=>{x.has(q)||e.remove(le)}),g?se.forEach((le,q)=>{let z=f+q;e.children(L).findIndex(te=>e.sameNode(te,le))!==z&&e.insertAt(L,le,z)}):wl(e,se,Q,L,f),gl(e,se,o,r,i,c,s),ts(s,"onRowsApplied",i.path,se)}function ts(e,t,n,o){if(typeof e[t]=="function")try{return e[t](n.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${t} threw at "${n.join(".")||"(root)"}"`,r);return}}function ml(e,t,n,o,r){let i=ts(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let c=new Array(n.length).fill(-1),s=new Set;for(let a=0;a<n.length;a++)if(i[a]){for(let m=0;m<t.length;m++)if(!(s.has(m)||!e.sameNode(t[m],i[a]))){c[a]=m,s.add(m);break}}return c}function gl(e,t,n,o,r,i,c){t.forEach((s,a)=>{if(n===null){let m=o[a],h=m==null?"":String(m);e.text(s)!==h&&e.text(s,h)}else{let m=i(e,s,n,o[a],{depth:r.depth+1,path:[...r.path,a]},c);m&&m!==s&&(t[a]=m)}})}function bl(e,t,n,o){return n===null?e.text(t):Nn(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Ai(e,t,n){let o=e.children(t);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],n))return r;return-1}function yl(e,t,n,o){if(!o.templateAttr)return null;let r=t;for(;r;){let i=e.find(r,n,{includeRulesTag:!1,templateAttr:null});for(let c of i)if(e.attr(c,o.templateAttr)!=null)return c;r=e.parent(r)}return null}function kl(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=e.children(n),r=[];for(let i of t){let c=o.findIndex(s=>e.sameNode(s,i));if(c===-1)return!1;r.push(c)}return r.sort((i,c)=>i-c),r[r.length-1]-r[0]===r.length-1}function wl(e,t,n,o,r){let i=null,c=r;for(let s=0;s<t.length;s++){if(!n[s]){i=t[s];continue}let a=i?e.parent(i):o;if(!a)continue;let m=i?Ai(e,a,i)+1:c++;e.insertAt(a,t[s],m),i=t[s]}}var Si=new Set(["checked","selected","disabled","readOnly","paused"]);function _n(e,t,n,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let i=[];if(os(n,o,[],i),i.length)throw new vo(i);sr(e,t,n,o,{depth:0,path:[]},r)}function sr(e,t,n,o,r,i={}){if(r.depth>ho)throw new Yn(r.path);if(o===void 0)return t;if(typeof n=="string")return xl(e,t,n,o,r,i);if(Array.isArray(n)){let[c,s]=n;return ns(e,t,c,s,o,r,sr,i),t}if(typeof n=="object"&&n!==null){for(let[c,s]of Object.entries(n)){let a=sr(e,t,s,o==null?o:o[c],{depth:r.depth+1,path:[...r.path,c]},i);a&&a!==t&&(t=a)}return t}return t}function xl(e,t,n,o,r,i){if(n.endsWith("[]")){let a=n.slice(0,-2);return ns(e,t,a,null,o,r,sr,i),t}if(n.startsWith("@"))return Oi(e,t,n.slice(1),o);let c=Mn(n);if(c!==-1){let a=n.slice(0,c),m=n.slice(c+1),h=a?e.find(t,a,i):[t];return h.length===0||Oi(e,h[0],m,o),t}if(n===".")return Ni(e,t,o),t;let s=e.find(t,n,i);return s.length===0||Ni(e,s[0],o),t}function Ni(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Oi(e,t,n,o){if(Fr.has(n)){let i=e.prop(t,n);if(i===o||i!=null&&o!=null&&String(i)===String(o))return t;throw new Eo(n)}if(n==="outerHTML"){let i=o==null?"":String(o);return e.replaceWith(t,i)}if(ii.has(n)){let i=Tl(n,o);return e.prop(t,n)!==i&&e.prop(t,n,i),t}let r=o==null?"":String(o);return e.attr(t,n)!==r&&e.attr(t,n,r),t}function Tl(e,t){return t==null?Si.has(e)?!1:"":Si.has(e)?t==="false"?!1:!!t:t}function os(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,i)=>{typeof r=="object"&&r!==null&&o.push({path:Do([...n,i]),expected:"scalar",got:jo(r)})}):o.push({path:Do(n),expected:"array",got:jo(t)});return}t!==null&&typeof t=="object"&&o.push({path:Do(n),expected:"scalar",got:jo(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:Do(n),expected:"array",got:jo(t)});return}let r=e[1];t.forEach((i,c)=>os(r,i,[...n,c],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:Do(n),expected:"object",got:jo(t)});return}for(let[r,i]of Object.entries(e))os(i,t[r],[...n,r],o)}}}function jo(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function Do(e){return e.join(".")}function Ho(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=rs(t,e,n);return ss(t,e,n),{data:o,summary:n}}function rs(e,t,n){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):void 0:t==null||typeof t=="object"?void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,o]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(r=>rs(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,i]of Object.entries(e)){let c=rs(i,t?.[r],n);c!==void 0&&(o[r]=c)}return o}}function ss(e,t,n){if(t!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof t!="object"||Array.isArray(t))return;let o=new Set(Object.keys(e));for(let r of Object.keys(t))o.has(r)?ss(e[r],t[r],n):n.discarded+=Qn(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>ss(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=Qn(t))}}function Qn(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+Qn(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+Qn(n),0):1}function is(e,t,n){let o=Lo(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},c=new Set;for(let{name:s,rules:a}of o){if(c.add(s),!Object.prototype.hasOwnProperty.call(n,s)){i[s]={carriedOver:0,discarded:0,listItems:0};continue}let{data:m,summary:h}=Ho(n[s],a);_n(e,t,a,m),i[s]=h,r.carriedOver+=h.carriedOver,r.discarded+=h.discarded,r.listItems+=h.listItems}for(let s of Object.keys(n))c.has(s)||(r.discarded+=Qn(n[s]));return{totals:r,byName:i,rulesTagCount:o.length}}async function cs({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:i}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),i=i||(g=>fetch(g)),!o)throw new Error("upgrade.run requires a document context");if(e=e||Sn(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let c=new URL(e,r?r.href:void 0);n=n!==void 0?n:Sn(o,"hyper-version"),t=t||rr(gn,o);let s;try{s=await i(c.href)}catch(g){throw new go(c.href,g)}if(!s.ok)throw new go(c.href,new Error(`HTTP ${s.status}`));let a=await s.text(),m=new DOMParser().parseFromString(a,"text/html"),h=Sn(m,"hyper-version"),d=t,b=!1,A=Zr(gn,m);if(A){let x=await(await es(A))(d,{fromVersion:n,toVersion:h});if(!x||typeof x!="object"||Array.isArray(x))throw new Un("transform must return a plain object map of { rulesName: data }");d=x,b=!0}let{totals:S,byName:L,rulesTagCount:f}=is(gn,m,d);if(f===0&&Object.keys(d).length>0)throw new Ro(c.href);return{html:Al(m),fromVersion:n,toVersion:h,summary:{transformApplied:b,totals:S,byName:L}}}function Al(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
6
- `+e.documentElement.outerHTML}var Nl=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...fi],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]});function ls(e,t,n){if(n&&typeof n=="object")return{rules:n,tagNode:null};if(typeof n=="string"){let o=t&&t.ownerDocument?t.ownerDocument:t;return mo(e,o,n)}return null}var Bo={extract:(e,t,n={})=>Nn(Jn(e,n),e,t,n),apply:(e,t,n,o={})=>_n(Jn(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>mo(gn,e,t),findRules:(e,t)=>ls(gn,e,t),bind:(e,t,n={})=>{let o=ls(gn,e,t);if(!o){let r=typeof t=="string"?`data-rules-name~="${t}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>Nn(Jn(e,n),e,o.rules,n),set:r=>_n(Jn(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:Jr,parseRelaxed:Xn,ruleAttrIndex:Mn,splitRule:to,errors:or,DOM_PROPERTIES:tr},as=e=>!!e&&typeof e.nodeType=="number";function vi(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=gn.find(t,"script[data-rules-name]",{includeRulesTag:!0});if(n.length===0)throw new Error('hyper-html-api: no rules tag found. Add <script type="application/json" data-rules-name="\u2026" data-rules-version="1"> or pass rules.');if(n.length>1)throw new Error('hyper-html-api: multiple rules tags found; pass a name, e.g. extractData("api").');return mo(gn,t).rules}function fs(e,t){let n=as(e)?e:document,o=as(e)?t:e;return o===void 0?Nn(Jn(n),n,vi(n)):Bo.bind(n,o).get()}function us(e,t,n){if(!as(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");return n===void 0?_n(Jn(e),e,vi(e),t):Bo.bind(e,n).set(t),e}var Mi={buildForm:ar,bindFormEvents:fr,scaffold:eo,morphForm:Vr,path:$o},Ei={checkForUpdate:$r,run:cs,extractAll:Qr,shapeMatch:Ho};var vl={engine:Bo,cms:Mi,upgrade:Ei,extractData:fs,applyData:us},Ml=vl;return Pi(El);})();
1
+ var HyperHtmlApi=(()=>{var Rr=Object.defineProperty;var Ul=Object.getOwnPropertyDescriptor;var Hl=Object.getOwnPropertyNames;var Wl=Object.prototype.hasOwnProperty;var Lr=(e,n)=>{for(var t in n)Rr(e,t,{get:n[t],enumerable:!0})},Vl=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Hl(n))!Wl.call(e,r)&&r!==t&&Rr(e,r,{get:()=>n[r],enumerable:!(o=Ul(n,r))||o.enumerable});return e};var _l=e=>Vl(Rr({},"__esModule",{value:!0}),e);var lf={};Lr(lf,{applyData:()=>Ks,cms:()=>Cl,default:()=>sf,engine:()=>lr,extractData:()=>$s,upgrade:()=>Rl});var ur={};Lr(ur,{fromString:()=>fr,getRuleAtPath:()=>Pr,getValueAtPath:()=>Uo,parseConfigKey:()=>$l,setAtPath:()=>Yn,toConfigKey:()=>Fl,toString:()=>An});function An(e){return e.map(String).join(".")}function Fl(e){return e.map(n=>typeof n=="number"?"*":String(n)).join(".")}function $l(e){return e===""?[]:e.split(".")}function fr(e){return e===""?[]:e.split(".").map(n=>/^\d+$/.test(n)?Number(n):n)}function Pr(e,n){let t=e;for(let o of n){if(t==null||typeof t=="string")return;if(Array.isArray(t)){if(typeof o!="number"&&o!=="*")return;t=t[1];continue}if(typeof t=="object"){if(typeof o=="number"||!(o in t))return;t=t[o];continue}return}return t}function Uo(e,n){let t=e;for(let o of n){if(t==null)return;t=t[o]}return t}function Yn(e,n,t){if(n.length===0)return t;let[o,...r]=n;if(typeof o=="number"){let c=Array.isArray(e)?[...e]:[];return c[o]=Yn(c[o],r,t),c}return{...e&&typeof e=="object"?e:{},[o]:Yn((e||{})[o],r,t)}}function go(e){if(typeof e=="string")return e.endsWith("[]")?[]:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let n={};for(let[t,o]of Object.entries(e))n[t]=go(o);return n}return""}var dr=new WeakMap;function On(e){let n=0,t=null,o=-1;for(let r=0;r<e.length;r++){let c=e[r];c==="\\"?r++:t?c===t&&(t=null):c==='"'||c==="'"?t=c:c==="["||c==="("?n++:c==="]"||c===")"?n>0&&n--:c==="@"&&n===0&&(o=r)}return o}function bo(e){let n=On(e);return n===-1?{selector:e,prop:null}:{selector:e.slice(0,n),prop:e.slice(n+1)||null}}var Kl=new Set(["checked","selected","disabled","readOnly","paused"]);function jr({rules:e,data:n,appRoot:t,cmsRoot:o}){let r=document.createDocumentFragment(),c={rules:e,appRoot:t,cmsRoot:o};return r.appendChild(Br({rule:e,value:n,path:[],ctx:c})),r}function Dr(e,{rules:n,getData:t,onChange:o}){e.setAttribute("data-hha-form-root",""),Js.set(e,{rules:n,getData:t,onChange:o}),ql()}var Js=new WeakMap,Ys=!1;function ql(){Ys||(document.addEventListener("input",Xs,!0),document.addEventListener("change",Xs,!0),document.addEventListener("click",zl,!0),Ys=!0)}function Qs(e){if(!(e instanceof Element))return null;let n=e.closest("[data-hha-form-root]");return n&&Js.get(n)||null}function zl(e){if(!(e.target instanceof Element))return;let n=e.target.closest("[data-hha-action]");if(!n||e.defaultPrevented)return;let t=Qs(n);if(!t)return;let{rules:o,getData:r,onChange:c}=t,l=n.getAttribute("data-hha-action"),i=fr(n.getAttribute("data-hha-path")||"");if(l==="scalar-array-add"){let s=Uo(r(),i)||[];c(Yn(r(),i,[...s,""]),{structural:!0});return}if(l==="object-array-add"){let s=Pr(o,i);if(!Array.isArray(s))return;let a=Uo(r(),i)||[];c(Yn(r(),i,[...a,go(s[1])]),{structural:!0});return}if(l==="array-remove"){if(i.length===0)return;let s=i.slice(0,-1),a=i[i.length-1],h=Uo(r(),s)||[];if(typeof a!="number")return;let f=h.filter((u,g)=>g!==a);c(Yn(r(),s,f),{structural:!0})}}function Xs(e){let n=e.target;if(!n?.matches?.("input, textarea, select"))return;let t=Qs(n);if(!t)return;let{getData:o,onChange:r}=t,c=n.closest("[data-hha-path]");if(!c)return;let l=fr(c.getAttribute("data-hha-path")||""),i=n.type==="checkbox"?n.checked:n.value;r(Yn(o(),l,i),{structural:!1})}function Br({rule:e,value:n,path:t,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?Xl({rule:e,value:n,path:t,ctx:o}):Yl({rule:e,value:n,path:t,ctx:o});if(Array.isArray(e))return Jl({rule:e,value:n,path:t,ctx:o});if(typeof e=="object"&&e!==null)return Gl({rule:e,value:n,path:t,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function Gl({rule:e,value:n,path:t,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",An(t)),t.length>0){let c=document.createElement("div");c.className="form-section-label",c.textContent=hr(t[t.length-1]),r.appendChild(c)}for(let[c,l]of Object.entries(e)){let i=[...t,c],s=n?.[c];r.appendChild(Br({rule:l,value:s,path:i,ctx:o}))}return r}function Yl({rule:e,value:n,path:t,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",An(t));let c=document.createElement("div");c.className="field-body";let l=document.createElement("label");l.className="field-label",l.textContent=hr(t[t.length-1]||".")+nc(e);let i=Zl(e,o.appRoot),s=Ql(i,{value:n,rule:e,path:t,appRoot:o.appRoot}),a=s.el;return a.classList.add(i.type==="textarea"?"field-textarea":"field-input"),c.appendChild(l),c.appendChild(a),r.appendChild(c),dr.set(r,s),r}function Xl({rule:e,value:n,path:t,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",An(t));let c=document.createElement("div");c.className="form-section-label",c.textContent=hr(t[t.length-1]),r.appendChild(c);let l=Array.isArray(n)?n:[],i=document.createElement("div");r.appendChild(i),l.forEach((a,h)=>{let f=[...t,h],u=document.createElement("div");u.className="scalar-array-row",u.setAttribute("data-hha-path",An(f));let g=document.createElement("input");g.type="text",g.className="field-input",g.value=a==null?"":String(a);let b=document.createElement("button");b.type="button",b.className="array-remove",b.textContent="\xD7",b.title="remove",b.setAttribute("data-hha-action","array-remove"),b.setAttribute("data-hha-path",An(f)),u.appendChild(g),u.appendChild(b),i.appendChild(u)});let s=document.createElement("button");return s.type="button",s.className="array-add",s.textContent="+ add",s.setAttribute("data-hha-action","scalar-array-add"),s.setAttribute("data-hha-path",An(t)),r.appendChild(s),r}function Jl({rule:e,value:n,path:t,ctx:o}){let[,r]=e,c=Array.isArray(n)?n:[],l=document.createElement("div");l.className="form-section",l.setAttribute("data-hha-path",An(t));let i=document.createElement("div");i.className="form-section-label",i.textContent=hr(t[t.length-1]),l.appendChild(i),c.forEach((a,h)=>{let f=[...t,h],u=document.createElement("div");u.className="array-card",u.setAttribute("data-hha-path",An(f));let g=document.createElement("button");g.type="button",g.className="array-remove",g.textContent="\xD7",g.title="remove item",g.setAttribute("data-hha-action","array-remove"),g.setAttribute("data-hha-path",An(f)),u.appendChild(g);let b=Br({rule:r,value:a,path:f,ctx:o});b.querySelector(".form-section-label")?.remove(),u.appendChild(b),l.appendChild(u)});let s=document.createElement("button");return s.type="button",s.className="array-add",s.textContent="+ add",s.setAttribute("data-hha-action","object-array-add"),s.setAttribute("data-hha-path",An(t)),l.appendChild(s),l}function Ql(e,n){let t=tc(e);if(e.type==="select"&&e.options)for(let o of e.options){let r=document.createElement("option");r.value=o.value,r.textContent=o.text,String(n.value)===o.value&&(r.selected=!0),t.appendChild(r)}else e.type==="checkbox"?t.checked=n.value===!0||n.value==="true"||n.value==="checked":(e.type,t.value=n.value==null?"":String(n.value));return{el:t,destroy(){},focus(){t.focus()},validate(){}}}function Zl(e,n){let t=null;if(e.startsWith("@")?t=e.slice(1):t=bo(e).prop,t&&Kl.has(t))return{type:"checkbox"};if(t==="innerHTML")return{type:"textarea"};let o=ec(e,n);if(!o)return{type:"text"};let r=(o.tagName||"").toLowerCase();if(r==="textarea")return{type:"textarea"};if(r==="select")return{type:"select",options:Array.from(o.querySelectorAll("option")).map(i=>({value:i.getAttribute("value")||i.textContent,text:i.textContent.trim()||i.getAttribute("value")||""}))};if(r==="input"){let l=(o.getAttribute("type")||"text").toLowerCase();if(l==="checkbox"||l==="radio")return{type:"checkbox"};if(l==="number")return{type:"number"}}let c=(o.textContent||"").trim();return c.length>60||c.includes(`
2
+ `)?{type:"textarea"}:{type:"text"}}function ec(e,n){if(!n||e==="."||e===""||e.startsWith("@"))return null;let t=bo(e).selector;if(!t)return null;try{return n.querySelector(t)}catch{return null}}function tc(e){if(e.type==="textarea")return document.createElement("textarea");if(e.type==="select")return document.createElement("select");let n=document.createElement("input");return n.type=e.type==="checkbox"?"checkbox":e.type==="number"?"number":"text",n}function hr(e){return typeof e=="number"?`#${e+1}`:String(e).replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/^\w/,n=>n.toUpperCase())}function nc(e){return` \xB7 ${e}`}function pr(e,n){if(typeof e=="string"){let t=n&&n.defaultView,o=t&&t.DOMParser||globalThis.DOMParser;return new o().parseFromString(e,"text/html")}if(e&&e.nodeType===9)return e;throw new TypeError("expected an HTML string or a Document")}function Ur(e){let n=new Map;return(t,o)=>{if(typeof o!="string")return pr(o,e);let r=n.get(t);if(r&&r.text===o)return r.doc;let c=pr(o,e);return n.set(t,{text:o,doc:c}),c}}function Zs(e,n){let t=n.doctype;if(!t)return!1;let o=e.doctype;if(o&&o.name===t.name&&o.publicId===t.publicId&&o.systemId===t.systemId)return!1;let r=e.implementation.createDocumentType(t.name,t.publicId,t.systemId);return o?e.replaceChild(r,o):e.insertBefore(r,e.documentElement),!0}var Hr=()=>!1;function Wr(e,n=[]){if(typeof e!="function")return Hr;let t=new WeakMap,o=new Set(n);return r=>{if(!r||r.nodeType!==1)return!1;let c=t.get(r);if(c!==void 0)return c;let l=[],i=r,s=!1;for(;i&&i.nodeType===1;){let a=t.get(i);if(a!==void 0){s=a;break}if(l.push(i),e(i,o.has(i))){s=!0;break}if(o.has(i))break;i=i.parentElement}for(let a of l)t.set(a,s);return s}}var wf=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 Xn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var oc="~",ei="^";function Vr(e,n){let t=new WeakMap;if(!e||!n||typeof n!="object"||Array.isArray(n))return t;let o=n[oc],r=typeof o=="string"?o.split(",").map(Number):null,c=r&&typeof n[ei]=="string"?n[ei].split(","):null,l=f=>Number.isInteger(f)&&f>=0,i=0,s=!1,a=f=>{let u=f;for(;u>0;){let g=r[i++];if(i>r.length||!l(g))return!1;u+=g-1}return!0},h=(f,u)=>{if(s)return;if(r){let A=i++,p=r[A];if(A>=r.length||!l(p)){s=!0;return}let m=!c||c[A]===f.tagName.toLowerCase();if(!m||p!==f.children.length){let y=m&&n[u];typeof y=="string"&&y&&t.set(f,y),a(p)||(s=!0);return}}let g=n[u];typeof g=="string"&&g&&t.set(f,g);let b=f.children;for(let A=0;A<b.length;A++)h(b[A],u===""?String(A):`${u}.${A}`)};return h(e,""),t}function ti(e){return n=>{for(let t of e){let o=t(n);if(typeof o=="string"&&o!=="")return o}return null}}var bn=ti([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function mr(e,n,t,o=null,r=null){let c=new Map,l=new Set,i=s=>{if(t(s))return;let a=n(s);a&&(c.has(a)?l.add(a):c.set(a,s))};if(o){let s=a=>{for(let h of a.querySelectorAll(o))i(h);for(let h of a.querySelectorAll("template"))h.content&&s(h.content)};i(e),s(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let s=a=>{i(a);let h=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let f=0;f<h.length;f++)s(h[f])};s(e)}for(let s of l)c.delete(s),r&&r.add(s),_r(s);return c}function _r(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var rc=new Set(["href","src","name","type","role"]),oi=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function yo(e,n=5381){let t=n;for(let o=0;o<e.length;o++)t=(t<<5)+t^e.charCodeAt(o);return t>>>0}function ni(e){return e.replace(/\s+/g," ")}var sc=0;function ri({ignored:e=()=>!1,ignoreAttribute:n=()=>!1,stats:t=null}={}){let o=new WeakMap,r=new WeakMap;function c(M){let E=M.attributes,N=E.length;if(N===0)return{all:"",sig:M.tagName+"|"};let L=[],j="",F=[];for(let W=0;W<N;W++){let C=E[W],T=C.name;n(M,T)||L.push(T+"="+C.value),T==="class"?j=C.value.indexOf(" ")<0?C.value:C.value.split(/\s+/).filter(Boolean).sort().join(" "):rc.has(T)&&F.push(T+"="+C.value)}return L.length>1&&L.sort(),F.length>1&&F.sort(),{all:L.join(""),sig:M.tagName+"|"+j+(F.length?"|"+F.join("|"):"")}}function l(M){return M.nodeType===1&&M.tagName==="TEMPLATE"&&M.content?M.content.childNodes:M.childNodes}function i(M){let E=o.get(M);if(E)return E;if(M.nodeType===3)E={hash:"T"+yo(M.nodeValue),hint:ni(M.nodeValue).slice(0,64),sig:null,tok:null};else if(M.nodeType===8)E={hash:"C"+yo(M.nodeValue),hint:"",sig:null,tok:null};else if(M.nodeType===1){let N=c(M),L=yo(M.tagName+""+N.all),j="";for(let F of a(M))if(F.nodeType===1){let W=i(F);L=yo(W.hash,L),j.length<64&&(j+=" "+W.hint)}else L=yo(h(F),L),F.kind==="text"&&j.length<64&&(j+=F.value.slice(0,64));E={hash:"E"+L,hint:ni(j).trim().slice(0,64),sig:N.sig,tok:null}}else E={hash:"N"+M.nodeType,hint:"",sig:null,tok:null};return o.set(M,E),E}function s(M){if(!M.tok){M.tok=new Set;for(let E of M.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))E&&M.tok.add(E)}return M.tok}function a(M){let E=r.get(M);if(E)return E;E=[];let N=null,L=()=>{N&&(N.value=N.nodes.map(j=>j.nodeValue).join(""),E.push(N),N=null)};for(let j of l(M)){if(j.nodeType===3){N||(N={kind:"text",nodes:[],value:"",parent:M,hash:void 0}),N.nodes.push(j);continue}L(),j.nodeType===8?E.push({kind:"comment",nodes:[j],value:j.nodeValue,parent:M,hash:void 0}):j.nodeType===1&&!e(j)&&E.push(j)}return L(),r.set(M,E),E}function h(M){return M.nodeType===1?i(M).hash:(M.hash===void 0&&(M.hash=(M.kind==="text"?"T":"C")+yo(M.value)),M.hash)}function f(M,E){let N=s(i(M)),L=s(i(E));if(N.size===0&&L.size===0)return{coef:1,share:1};if(N.size===0||L.size===0)return null;let j=0;for(let F of N)L.has(F)&&j++;return{coef:j/Math.min(N.size,L.size),share:j/Math.max(N.size,L.size)}}function u(M,E){let N=f(M,E);return!!N&&N.coef>=.5}let g=new WeakMap;function b(M){let E=g.get(M);if(E)return E;E=[];for(let N of M.attributes)n(M,N.name)||E.push([N.namespaceURI||"",N.localName,N.value]);return E.sort((N,L)=>N[0]<L[0]?-1:N[0]>L[0]?1:N[1]<L[1]?-1:N[1]>L[1]?1:0),g.set(M,E),E}let A=new WeakMap;function p(M,E){if(M===E)return!0;if(h(M)!==h(E))return!1;let N=A.get(M);if(N&&N.has(E))return N.get(E);let L=A.get(E);if(L&&L.has(M))return L.get(M);let j=m(M,E),F=j===!0;return j===!1&&t&&t.hashRejected++,N||A.set(M,N=new WeakMap),N.set(E,F),F}function m(M,E){if(M.nodeType===1){if(E.nodeType!==1||M.tagName!==E.tagName||M.namespaceURI!==E.namespaceURI)return!1;let N=b(M),L=b(E);if(N.length!==L.length)return!1;for(let W=0;W<N.length;W++)if(N[W][0]!==L[W][0]||N[W][1]!==L[W][1]||N[W][2]!==L[W][2])return!1;let j=a(M),F=a(E);if(j.length!==F.length)return!1;for(let W=0;W<j.length;W++){if(h(j[W])!==h(F[W]))return!1;if(!p(j[W],F[W]))return sc}return!0}return E.nodeType===1?!1:M.kind===E.kind&&M.value===E.value}let y=new WeakMap,R=new Map,S=0;function O(M){let E=y.get(M);if(E)return E;let N=h(M),L=R.get(N);L||R.set(N,L=[]);let j=L.find(F=>p(F.unit,M));return E=j?j.key:"K"+S++,j||L.push({unit:M,key:E}),y.set(M,E),E}return{meta:i,unitsOf:a,unitHash:h,similar:u,score:f,childrenOf:l,equalUnits:p,exactUnitKey:O,ignored:e}}var si=16,ic=2e3,lc=3,Fr={align:0,certifyVisited:0,certifyScheduled:0};function $r(e,n,t){let{meta:o,unitsOf:r,unitHash:c,similar:l,score:i,childrenOf:s,equalUnits:a,ignored:h}=t.analyzer,f=t.baseId||(()=>null),u=t.sideId||(()=>null),g=t.baseKey||(()=>null),b=t.sideKey||(()=>null),A=t.baseDropped||new Set,p=t.sideDropped||new Set,m=t.stats||null,y=m?new Set:null,R=m?new Set:null,S=new Map,O=new Map,M=new Set,E=new Map,N=new Set,L=new Set,j=new Set,F=[],W=[],C=[],T=[],x=ic,z=new Map,D=new Map,V=(B,G)=>{S.set(B,G),O.set(G,B)},Ee=new Set,Me=new Set,De=null,re=B=>{let G=B.nodeType?B.parentNode:B.parent;if(!G||G.nodeType!==11)return G;if(!De){De=new WeakMap;let ue=he=>{for(let ce of he.querySelectorAll("template"))ce.content&&(De.set(ce.content,ce),ue(ce.content))};for(let he of[e,n])ue(he.tagName==="TEMPLATE"&&he.content?he.content:he)}return De.get(G)||null},Se=(B,G)=>{for(let ue=re(B);ue&&!Ee.has(ue);ue=re(ue))Ee.add(ue);for(let ue=re(G);ue&&!Me.has(ue);ue=re(ue))Me.add(ue)},qe=B=>{for(let G=re(B);G;G=re(G))if(S.has(G))return L.has(G);return!1},ve=B=>{for(let G=re(B);G;G=re(G)){let ue=O.get(G);if(ue!==void 0)return L.has(ue)}return!1},w=B=>!!B&&B.nodeType===1,K=(B,G)=>{let ue=E.get(B);return!!ue&&ue.has(G)},ne=B=>oi.has(B.tagName),ee=t.comparisons||t.scope,Pe=(B,G)=>{if(ee){if(ee.same.get(B)===G)return!0;if(ee.differ.get(B)===G)return!1}if(!B.isEqualNode(G))return!1;if(B.tagName==="TEMPLATE")return a(B,G);let ue=B.getElementsByTagName("template");if(ue.length===0)return!0;let he=G.getElementsByTagName("template");if(ue.length!==he.length)return!1;for(let ce=0;ce<ue.length;ce++)if(!a(ue[ce],he[ce]))return!1;return!0},_e=(B,G)=>{let ue=f(B);if(!ue)return!0;let he=u(G);return!he||ue===he},Ae=B=>{let G=g(B);return G&&t.baseIndex.get(G)===B&&!p.has(G)?G:null},ot=B=>{let G=b(B);return G&&t.sideIndex.get(G)===B&&!A.has(G)?G:null},Qe=(B,G)=>{let ue=Ae(B);if(!ue)return!0;let he=ot(G);return!he||ue===he},Ze=globalThis.__hyperMorphProfile,Xe=Ze?performance.now():0;Ze&&!t.scope&&(o(e),o(n),Ze.meta=(Ze.meta||0)+(performance.now()-Xe),Xe=performance.now()),V(e,n);let yt=new Set;for(let[B,G]of t.baseIndex){let ue=t.sideIndex.get(B);ue&&ue.tagName===G.tagName&&!S.has(G)&&!O.has(ue)&&(V(G,ue),Se(G,ue),yt.add(G))}if(yt.size){let B=[];if(t.scope)for(let ce of t.scope.chain)yt.has(ce)&&B.push(ce);let G=[t.scope?t.scope.root:e];for(;G.length;){let ce=G.pop();yt.has(ce)&&B.push(ce);let xe=s(ce);for(let te=xe.length-1;te>=0;te--)xe[te].nodeType===1&&G.push(xe[te])}let ue=new Set;for(let ce=B.length-1;ce>=0;ce--){let xe=B[ce];t.scope&&t.scope.onChain.has(xe)?ue.add(xe):ie(xe,S.get(xe),ue)?(L.add(xe),j.add(xe),m&&m.certificationPairs++):ue.add(xe)}let he=new Set;for(let ce of B)L.has(ce)&&!he.has(ce)&&dt(ce,he)}t.scope&&t.scope.head&&pe(t.scope.head[0],t.scope.head[1]);function dt(B,G){let ue=[B];for(;ue.length;){let he=ue.pop();if(!G.has(he)){G.add(he),Y(he);for(let ce of r(he))w(ce)&&S.has(ce)&&ue.push(ce)}}}T.push([e,n]);for(let[B,G]of S)w(B)&&B!==e&&T.push([B,G]);return Ht(),gt(),Ze&&(Ze.align=(Ze.align||0)+(performance.now()-Xe)),{map:S,reverse:O,moved:N,identical:L,pairIdenticalChildren:Y,weak:M,unpair:qt,rematch:gt,insertedByHash:$t,refused:R,identityPaired:yt};function gt(){ge(),Ht();for(let B=0;B<C.length;){let G=C.length;_t(B,G),B=G,Ht(),ge(),Ht()}}function qt(B){let G=S.get(B);if(!G)return;E.has(B)||E.set(B,new Set),E.get(B).add(G);let ue=(ce,xe)=>{S.delete(ce),O.delete(xe),N.delete(ce),L.delete(ce),M.delete(ce),j.delete(ce)},he=(ce,xe)=>{for(let te of r(ce)){let q=S.get(te);!q||yt.has(te)||!(w(q)?xe.contains(q):xe.contains(q.nodes[0]))||(ue(te,q),w(te)&&he(te,q))}};ue(B,G),w(B)&&he(B,G),F.push(B),W.push(G)}function $t(){let B=new Map;for(let G of new Set(W)){if(O.has(G))continue;let ue=o(G).hash;B.has(ue)||B.set(ue,[]),B.get(ue).push(G)}return B}function Ht(){for(;T.length;){let[B,G]=T.shift();S.get(B)!==G||j.has(B)||L.has(B)||an(B,G)}}function jt(B,G){if(!ne(B))for(let ue of r(B))w(ue)&&(G.push(ue),jt(ue,G))}function an(B,G){j.add(B);let ue=r(B),he=r(G);Fr.align+=ue.length+he.length,z=new Map,D=new Map;for(let ae=0;ae<ue.length;ae++)z.set(ue[ae],ae);for(let ae=0;ae<he.length;ae++)D.set(he[ae],ae);if(B.tagName==="HTML")for(let ae of["HEAD","BODY"]){let Ce=ue.find(We=>w(We)&&We.tagName===ae),Le=he.find(We=>w(We)&&We.tagName===ae);Ce&&Le&&!S.has(Ce)&&!O.has(Le)&&V(Ce,Le)}for(let ae=0;ae<ue.length&&ae<he.length;ae++){let Ce=ue[ae],Le=he[ae];S.has(Ce)||O.has(Le)||(w(Ce)?w(Le)&&Ce.tagName===Le.tagName&&Pe(Ce,Le)&&pe(Ce,Le):!w(Le)&&Ce.kind===Le.kind&&Ce.value===Le.value&&pe(Ce,Le))}Ie(ue,he);let ce=ue.filter(ae=>!S.has(ae)),xe=he.filter(ae=>!O.has(ae));ce.length&&xe.length&&(_(ce,xe),J(ce,xe),oe(ce,xe,ue,he),Oe(ue,he));let te=!1,q=!1;for(let ae of ue){if(!S.has(ae)){w(ae)&&(F.push(ae),jt(ae,F),te=!0);continue}w(ae)&&!L.has(ae)&&T.push([ae,S.get(ae)])}for(let ae of he)!O.has(ae)&&w(ae)&&(W.push(ae),jt(ae,W),q=!0);te&&q&&C.push([B,G])}function _t(B,G){for(let ue=B;ue<G;ue++){let[he,ce]=C[ue];if(S.get(he)!==ce)continue;let xe=r(he),te=r(ce),q=new Map,ae=new Map,Ce=null;for(let Le of xe)w(Le)&&(S.has(Le)?Ce=Le:(q.has(Ce)||q.set(Ce,[]),q.get(Ce).push(Le)));Ce=null;for(let Le of te)w(Le)&&(O.has(Le)?Ce=O.get(Le):(ae.has(Ce)||ae.set(Ce,[]),ae.get(Ce).push(Le)));for(let[Le,We]of q){let Ne=ae.get(Le);if(!(!Ne||We.length!==Ne.length)&&We.every((ze,tt)=>Ne[tt].tagName===ze.tagName&&_e(ze,Ne[tt])&&!K(ze,Ne[tt])))for(let ze=0;ze<We.length;ze++)zt(We[ze],Ne[ze])}}}function zt(B,G){V(B,G),M.add(B),T.push([B,G]),Ht()}function _(B,G){let ue=wo(B,c),he=wo(G,c),ce=new Map;for(let xe of G){let te=c(xe);he.get(te)===1&&ce.set(te,xe)}for(let xe of B){if(S.has(xe))continue;let te=c(xe);if(ue.get(te)!==1)continue;let q=ce.get(te);q&&!O.has(q)&&a(xe,q)&&pe(xe,q)}}function ie(B,G,ue){let he=[[B,G]];for(;he.length;){let[ce,xe]=he.pop();if(Fr.certifyVisited++,m&&m.certificationVisited++,ce.nodeType!==xe.nodeType)return!1;if(ce.nodeType===3||ce.nodeType===8){if(ce.nodeValue!==xe.nodeValue)return!1;continue}if(ce.nodeType!==1){if(!ce.isEqualNode(xe))return!1;continue}if(ce.tagName!==xe.tagName||ce.namespaceURI!==xe.namespaceURI||h(ce)!==h(xe))return!1;let te=ce.attributes,q=xe.attributes;if(te.length!==q.length)return!1;for(let Ne=0;Ne<te.length;Ne++){let ze=te[Ne];if(xe.getAttributeNS(ze.namespaceURI,ze.localName)!==ze.value)return!1}let ae=S.get(ce);if(ae!==void 0&&ae!==xe)return!1;let Ce=O.get(xe);if(Ce!==void 0&&Ce!==ce)return!1;if(ce!==B){if(L.has(ce))continue;if(ue.has(ce))return!1}let Le=s(ce),We=s(xe);if(Le.length!==We.length)return!1;Fr.certifyScheduled+=Le.length;for(let Ne=Le.length-1;Ne>=0;Ne--)he.push([Le[Ne],We[Ne]])}return!0}function me(B,G){return!w(B)||!(Ee.has(B)||Me.has(G))?!0:!!v(B,G)||!(Ae(B)||ot(G))}function pe(B,G){if(w(B)&&(Ee.has(B)||Me.has(G))){let ue=v(B,G);if(!ue){if(Ae(B)||ot(G))return;V(B,G),T.push([B,G]);return}for(let he=0;he<ue.length;he+=2){let ce=ue[he],xe=ue[he+1],te=S.get(ce);te!==void 0&&te!==xe&&ke(ce,te);let q=O.get(xe);q!==void 0&&q!==ce&&ke(q,xe),S.get(ce)===xe&&(N.delete(ce),M.delete(ce),L.add(ce),j.add(ce))}}P(B,G)}function ke(B,G){S.delete(B),O.delete(G),N.delete(B),L.delete(B),M.delete(B),j.delete(B)}function v(B,G){let ue=[B,G,!1],he=[];for(;ue.length;){let ce=ue.pop(),xe=ue.pop(),te=ue.pop(),q=S.get(te),ae=O.get(xe);if(te!==B&&(q!==void 0&&q!==xe&&yt.has(te)||ae!==void 0&&ae!==te&&yt.has(ae)))return null;if(!(q===xe&&L.has(te))&&((q!==void 0||ae!==void 0)&&he.push(te,xe),!!w(te))){if(ce||q!==void 0&&q!==xe||ae!==void 0&&ae!==te){let Ce=r(te),Le=r(xe);for(let We=0;We<Ce.length&&We<Le.length;We++)ue.push(Ce[We],Le[We],!0)}else if(Ee.has(te)||Me.has(xe)){let Ce=te.tagName==="TEMPLATE"?te.content:te,Le=xe.tagName==="TEMPLATE"?xe.content:xe;for(let We=Ce.firstElementChild,Ne=Le.firstElementChild;We&&Ne;){if(h(We)){We=We.nextElementSibling;continue}if(h(Ne)){Ne=Ne.nextElementSibling;continue}(S.has(We)||O.has(Ne)||Ee.has(We)||Me.has(Ne))&&ue.push(We,Ne,!1),We=We.nextElementSibling,Ne=Ne.nextElementSibling}}}}return he}function P(B,G){V(B,G),L.add(B),w(B)&&j.add(B)}function Y(B){let G=S.get(B);if(!G||!w(B))return;let ue=r(B),he=r(G);for(let ce=0;ce<ue.length&&ce<he.length;ce++)S.has(ue[ce])||P(ue[ce],he[ce])}function J(B,G){let ue=te=>w(te)&&!ne(te)?o(te).sig+""+o(te).hint:null,he=wo(B,ue),ce=wo(G,ue),xe=new Map;for(let te of G){let q=ue(te);q!=null&&ce.get(q)===1&&xe.set(q,te)}for(let te of B){if(S.has(te))continue;let q=ue(te);if(q==null||he.get(q)!==1)continue;let ae=xe.get(q);ae&&!O.has(ae)&&_e(te,ae)&&V(te,ae)}}function oe(B,G,ue,he){let ce=new Map;for(let te of G){if(!w(te)||O.has(te)||ne(te))continue;let q=o(te).sig;ce.has(q)||ce.set(q,[]),ce.get(q).push({el:te,index:D.get(te)})}let xe=[];for(let te of B){if(S.has(te)||!w(te)||ne(te))continue;let q=ce.get(o(te).sig);if(!q||!q.length)continue;let ae=z.get(te),Ce=q.filter(Le=>!O.has(Le.el)).map(Le=>({c:Le,d:Math.abs(Le.index-ae)}));Ce.sort((Le,We)=>Le.d-We.d),Ce.length>si&&(Ce=Ce.slice(0,si));for(let{c:Le,d:We}of Ce){if(!_e(te,Le.el))continue;let Ne=i(te,Le.el);Ne&&Ne.coef>=.5&&xe.push({b:te,s:Le.el,coef:Ne.coef,share:Ne.share,d:We,bi:ae})}}if(xe.sort((te,q)=>q.coef-te.coef||q.share-te.share||te.d-q.d||te.bi-q.bi),m&&xe.length>1){let te=new Map;for(let q of xe){let ae=te.get(q.b);ae?ae.coef===q.coef&&(ae.share===q.share?ae.strict++:ae.loose++):te.set(q.b,{coef:q.coef,share:q.share,strict:0,loose:0})}for(let[q,ae]of te)y.has(q)||!(ae.strict||ae.loose)||(y.add(q),ae.strict?m.similarTiesStrict++:m.similarTiesLoose++)}for(let te of xe)!S.has(te.b)&&!O.has(te.s)&&V(te.b,te.s)}function je(B,G){return w(B)!==w(G)?!1:w(B)?B.tagName!==G.tagName||!_e(B,G)?!1:ne(B)||o(B).hint===""||o(G).hint===""?!0:l(B,G):B.kind===G.kind}function Z(B,G){let ue=(ce,xe)=>{let te=xe===null?-1:ce===G?D.get(xe):z.get(xe),q=ce[te+1];return q&&!w(q)?q:null},he=null;for(let ce of B){if(w(ce)){he=ce;continue}if(S.has(ce))continue;let xe=he===null?null:S.get(he);if(he!==null&&!xe)continue;let te=ue(G,xe);te&&!O.has(te)&&te.kind===ce.kind&&V(ce,te)}}function Oe(B,G){Z(B,G);let ue=He(B,G),he=(xe,te)=>w(xe)&&o(xe).hint!==""&&o(te).hint===""&&!!te.querySelector("br")&&!ue(xe,te),ce=0;for(let xe of B){if(S.has(xe)){let q=D.get(S.get(xe));q!==void 0&&q>=ce&&(ce=q+1);continue}let te=0;for(let q=ce;q<G.length&&te<lc;q++){let ae=G[q];if(!O.has(ae)&&(te++,je(xe,ae)&&!K(xe,ae)&&!he(xe,ae))){V(xe,ae),w(xe)&&(o(xe).hint===""||o(ae).hint==="")&&M.add(xe),ce=q+1;break}}}Ie(B,G)}function He(B,G){let ue=(he,ce,xe)=>{for(let te=ce-1;te>=0;te--)if(w(he[te])&&xe(he[te]))return he[te];return null};return(he,ce)=>{let xe=z.get(he),te=D.get(ce);if(xe===te)return!0;let q=ue(B,xe,Ce=>S.has(Ce)),ae=ue(G,te,Ce=>O.has(Ce));return q?S.get(q)===ae:!ae}}function Ie(B,G){let ue=B.filter(q=>w(q)&&!S.has(q)),he=G.filter(q=>w(q)&&!O.has(q));if(!ue.length||!he.length)return;let ce=wo(ue,q=>q.tagName),xe=wo(he,q=>q.tagName),te=He(B,G);for(let q of ue){let ae=q.tagName;if(ce.get(ae)!==1||xe.get(ae)!==1)continue;let Ce=he.find(Le=>Le.tagName===ae);Ce&&!O.has(Ce)&&te(q,Ce)&&_e(q,Ce)&&!K(q,Ce)&&(a(q,Ce)?pe(q,Ce):(V(q,Ce),M.add(q)))}}function ge(){let B=new Map;for(let q of M)if(w(q)&&w(S.get(q))){let ae=o(q).hash;B.has(ae)||B.set(ae,[]),B.get(ae).push(q)}if(B.size)for(let q of W){if(O.has(q)||!w(q)||ve(q))continue;let ae=B.get(o(q).hash),Ce=ae&&ae.find(Le=>M.has(Le)&&!K(Le,q)&&_e(Le,q)&&Qe(Le,q)&&a(Le,q)&&me(Le,q));Ce&&(qt(Ce),pe(Ce,q),Se(Ce,q),N.add(Ce))}let G=new Map,ue=new Map,he=new Map;for(let q of M){let ae=S.get(q);w(q)&&w(ae)&&he.set(ae,q)}let ce=(q,ae)=>{if(!O.has(q))return!ve(q);let Ce=he.get(q);return Ce===O.get(q)&&Ce!==ae&&!Ce.contains(ae)},xe=q=>{if(O.has(q)){let ae=he.get(q);he.delete(q),qt(ae)}};for(let q of[...W,...he.keys()]){if(O.has(q)&&!he.has(q))continue;let ae=o(q).hash;if(G.has(ae)||G.set(ae,[]),G.get(ae).push(q),ne(q))continue;let Ce=o(q).sig;ue.has(Ce)||ue.set(Ce,[]),ue.get(Ce).push(q)}let te=new Set;for(let q of M){let ae=S.get(q);!w(q)||!w(ae)||ne(q)||o(q).hint===""||o(ae).hint===""||l(q,ae)||te.add(q)}for(let q of[...F,...te]){let ae=S.get(q);if(ae?!(M.has(q)&&te.has(q)):qe(q))continue;let Ce=tt=>{ae&&qt(q),xe(tt)},Le=G.get(o(q).hash);if(Le){let tt=Le.find(k=>k!==ae&&ce(k,q)&&!K(q,k)&&Qe(q,k)&&a(q,k)&&me(q,k));if(tt){Ce(tt),pe(q,tt),Se(q,tt),N.add(q);continue}}if(ne(q)||x<=0)continue;let We=ue.get(o(q).sig);if(!We)continue;let Ne=null,ze=0;for(let tt of We)if(!(tt===ae||!ce(tt,q)||!_e(q,tt)||!Qe(q,tt)||K(q,tt))&&(x--<=0||l(q,tt)&&(ze++,Ne=tt,ze>1)))break;ze>1&&R&&R.add(q),ze===1&&(Ce(Ne),V(q,Ne),Se(q,Ne),N.add(q),T.push([q,Ne]))}}}function wo(e,n){let t=new Map;for(let o of e){let r=n(o);r!=null&&t.set(r,(t.get(r)||0)+1)}return t}var cc={diff:0},ii=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,ac=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,fc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,uc=/\P{M}\p{M}*/gu;function dc(e){if(e==="")return[];if(ii){let t=[];for(let o of ii.segment(e))t.push(o.segment);return t}let n=[];for(let t of e.match(fc))if(ac.test(t))for(let o of t.match(uc))n.push(o);else n.push(t);return n}var hc=/^[  ]+$/,pc=e=>hc.test(e)?" ".repeat(e.length):e,Jn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),wt="",Kr=e=>e.every(n=>Jn(n)||n.k===wt),mc=/^[\x00-\x7f\u00A0]*$/,gc=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function bc(e){return e===""?[]:e.match(gc)}function ln(e,n=!1){return(n?bc(e):dc(e)).map(t=>({k:pc(t),raw:t,len:t.length}))}var yn=(...e)=>e.every(n=>mc.test(n));function qr(e,n,t){let o=e.length,r=n.length,c=Math.min(o+r,t),l=c+1,i=new Int32Array(2*c+3),s=[],a=o===0&&r===0;for(let g=0;g<=c&&!a;g++){s.push(i.slice(l-g,l+g+1));for(let b=-g;b<=g;b+=2){let A;b===-g||b!==g&&i[l+b-1]<i[l+b+1]?A=i[l+b+1]:A=i[l+b-1]+1;let p=A-b,m=A;for(;A<o&&p<r&&e[A].k===n[p].k;)A++,p++;if(cc.diff+=1+A-m,i[l+b]=A,A>=o&&p>=r){a=!0;break}}}if(!a)return null;let h=[],f=o,u=r;for(let g=s.length-1;g>0;g--){let b=s[g],A=f-u,p=A+g,m=A===-g||A!==g&&b[p-1]<b[p+1]?A+1:A-1,y=b[m+g],R=y-m;for(;f>y&&u>R;)h.push([0,f-1,u-1]),f--,u--;f===y?(h.push([1,f,u-1]),u--):(h.push([-1,f-1,u]),f--)}for(;f>0&&u>0;)h.push([0,f-1,u-1]),f--,u--;return h.reverse(),h}function yc(e,n,t){let o=f=>f.k===wt;if(!e.some(o)&&!n.some(o))return qr(e,n,t);let r=[],c=[];for(let f=0;f<e.length;f++)o(e[f])||r.push(f);for(let f=0;f<n.length;f++)o(n[f])||c.push(f);let l=qr(r.map(f=>e[f]),c.map(f=>n[f]),t);if(!l)return null;let i=[],s=0,a=0,h=(f,u)=>{for(;s<f&&a<u&&e[s].k===n[a].k;)i.push([0,s++,a++]);let g=qr(e.slice(s,f),n.slice(a,u),t);if(!g)return!1;for(let[b,A,p]of g)i.push([b,A+s,p+a]);return s=f,a=u,!0};for(let[f,u,g]of l)if(f===0){if(!h(r[u],c[g]))return null;i.push([0,s,a]),s++,a++}return h(e.length,n.length)?i:null}function Kn(e,n,t=4e3){let o=[],r=0;for(;r<e.length&&r<n.length&&e[r].k===n[r].k;)e[r].raw!==n[r].raw&&o.push({bi:r,tok:n[r]}),r++;let c=0;for(;c<e.length-r&&c<n.length-r&&e[e.length-1-c].k===n[n.length-1-c].k;)e[e.length-1-c].raw!==n[n.length-1-c].raw&&o.push({bi:e.length-1-c,tok:n[n.length-1-c]}),c++;let l=e.slice(r,e.length-c),i=n.slice(r,n.length-c),s=Sc(l,i)?null:yc(l,i,t);if(!s){let m=l.length||i.length?[{bs:r,be:r+l.length,toks:i}]:[];return{hunks:m,cosmetic:o,coarse:!0,parts:m.map(y=>({...y,gap:[],group:0})),cosmeticEq:o}}let a=[],h=(m,y)=>{l[m].raw!==i[y].raw&&o.push({bi:r+m,tok:i[y]})},f=null,u=[],g=0,b=0,A=()=>{f&&a.push(f),f=null;for(let[m,y]of u)h(m,y);u=[],g++};for(let[m,y,R]of s){if(m===0){f&&Jn(l[y])&&!l[y].k.includes(`
3
+ `)?u.push([y,R]):(A(),h(y,R)),b=y+1;continue}(!f||u.length)&&(f&&a.push(f),f={bs:r+b,be:r+b,toks:[],gap:u.map(([S,O])=>({bi:r+S,tok:i[O]})),group:g},u=[]),m===-1?(f.be=r+b+1,b=y+1):f.toks.push(i[R])}A(),wc(a,e);let p=Gr(a);return{hunks:p.hunks,cosmetic:o.concat(p.cosmetic),parts:a,cosmeticEq:o}}function wc(e,n){for(let t=0;t<e.length;t++){let o=e[t];if(o.gap.length)continue;let r=t+1<e.length?e[t+1].bs:1/0;if(o.toks.length){if(o.bs===o.be)for(;o.bs+1<r&&o.bs<n.length&&o.toks[0].k===wt&&n[o.bs].k===wt;)o.toks=[...o.toks.slice(1),o.toks[0]],o.bs++,o.be++}else for(;o.be+1<r&&o.be<n.length&&n[o.bs].k===wt&&n[o.be].k===wt;)o.bs++,o.be++}}function Gr(e,n=()=>!1){let t=[],o=[],r=null,c=-1;for(let l of e){let i=n(l);if(r&&!r.alone&&!i&&l.group===c){r.be=l.be;for(let s of l.gap)r.toks.push(s.tok);for(let s of l.toks)r.toks.push(s);continue}r&&t.push({bs:r.bs,be:r.be,toks:r.toks});for(let s of l.gap)o.push(s);r={bs:l.bs,be:l.be,toks:l.toks.slice(),alone:i},c=l.group}return r&&t.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:t,cosmetic:o}}var xc=(e,n)=>e.bs===n.bs&&e.be===n.be&&Jr(e.toks,n.toks);function Xr(e,n,t){let o=h=>f=>h.some(u=>xc(f,u)),r=Gr(e.parts,o(n.parts)),c=Gr(n.parts,o(e.parts)),l=e.cosmeticEq.concat(r.cosmetic),i=n.cosmeticEq.concat(c.cosmetic),[s,a]=t?kc(r.hunks,c.hunks,t,l,i):[r.hunks,c.hunks];return{lh:s,rh:a,cosL:l,cosR:i}}function kc(e,n,t,o,r){let c=(b,A)=>b.k===A.k&&b.raw===A.raw,l=[{list:e.map(b=>({...b})),resp:new Set(o.map(b=>b.bi)),raw:new Map(o.map(b=>[b.bi,b.tok]))},{list:n.map(b=>({...b})),resp:new Set(r.map(b=>b.bi)),raw:new Map(r.map(b=>[b.bi,b.tok]))}],i=b=>b.bs===b.be,s=(b,A,p,m)=>{let y=b.list[A];if(!i(y))return m(y)===p?y.toks:null;let R=A?b.list[A-1].be:0,S=A+1<b.list.length?b.list[A+1].bs:t.length;if(p<R||p>S)return null;let O=y.toks,M=y.bs;for(;M>p;){let E=O[O.length-1];if(!c(E,t[M-1])||b.resp.has(M-1))return null;O=[E,...O.slice(0,-1)],M--}for(;M<p;){if(!c(O[0],t[M])||b.resp.has(M))return null;O=[...O.slice(1),O[0]],M++}return O},a=(b,A,p,m,y,R)=>{let S=b.list[A],O=y?p.slice(p.length-m):p.slice(0,m),M=y?p.slice(0,p.length-m):p.slice(m),E={bs:R,be:R,toks:O};if(i(S)){if(!M.length){b.list[A]=E;return}let L={bs:R,be:R,toks:M};y&&(L.lead=!0),b.list.splice(A,1,...y?[L,E]:[E,L]);return}let N={bs:S.bs,be:S.be,toks:M};b.list.splice(A,1,...y?[N,E]:[E,N])},h=(b,A,p,m,y)=>{let R=b.list[A],S=y?p.slice(p.length-m):p.slice(0,m),O=y?p.slice(0,p.length-m):p.slice(m),M={bs:R.bs,be:R.be,toks:S};if(!O.length){b.list[A]=M;return}let E=y?{bs:R.bs,be:R.bs,toks:O,lead:!0}:{bs:R.be,be:R.be,toks:O};b.list.splice(A,1,...y?[E,M]:[M,E])},f=(b,A,p,m)=>{let y=b.list[A],R=p.list[m],S=y.be,O=R.bs;if(S>=O||A+1<b.list.length&&b.list[A+1].bs<=R.be||m>0&&p.list[m-1].be>=y.bs)return!1;for(let D=S;D<O;D++)if(!Jn(t[D])||t[D].k.includes(`
4
+ `))return!1;let M=D=>t.slice(S,O).map((V,Ee)=>D.raw.get(S+Ee)||V),E=[...y.toks,...M(b)],N=[...M(p),...R.toks],L=(D,V,Ee)=>V>=0&&V+Ee.length<=D.length&&Ee.every((Me,De)=>D[V+De].k===Me.k),j=(D,V,Ee)=>Kr(D)&&t.slice(V,Ee).some(Me=>!Jn(Me)),F=D=>D.some(V=>!Jn(V)),W,C,T,x;if(i(y)&&F(y.toks)&&L(N,0,y.toks)){let D=N.slice(y.toks.length);j(D,S,R.be)||(W=S,C=y.toks,T=N.slice(0,y.toks.length),x=[null,{bs:S,be:R.be,toks:D}])}if(W===void 0&&i(R)&&F(R.toks)){let D=E.length-R.toks.length,V=E.slice(0,D);L(E,D,R.toks)&&!j(V,y.bs,O)&&(W=O,C=E.slice(D),T=R.toks,x=[{bs:y.bs,be:O,toks:V},null])}if(W===void 0)return!1;let z=D=>D&&(D.bs<D.be||D.toks.length);return b.list.splice(A,1,...[x[0],{bs:W,be:W,toks:C}].filter(z)),p.list.splice(m,1,...[{bs:W,be:W,toks:T},x[1]].filter(z)),!0},u=l[0],g=l[1];for(let b=0;b<64;b++){let A=!1;e:for(let p=0;p<u.list.length;p++)for(let m=0;m<g.list.length;m++){let y=u.list[p],R=g.list[m];if(!(y.bs===R.bs&&y.be===R.be&&Jr(y.toks,R.toks))){for(let S of[!0,!1]){let O=E=>S?E.be:E.bs,M=i(y)?[O(R),y.bs]:[O(y)];for(let E of M){let N=s(u,p,E,O),L=N&&s(g,m,E,O);if(!L)continue;let j=(x,z)=>S?x[x.length-1-z]:x[z],F=0;for(;F<N.length&&F<L.length&&j(N,F).k===j(L,F).k;)F++;if(!F)continue;let W=S?N.slice(0,N.length-F):N.slice(F),C=S?L.slice(0,L.length-F):L.slice(F);if(!(F<N.length&&F<L.length&&!Kr(W)&&!Kr(C)&&(i(y)&&i(R)||y.bs===R.bs&&y.be===R.be)||!(S?N.slice(N.length-F):N.slice(0,F)).some(x=>!Jn(x)))){if(F===N.length&&F===L.length&&i(y)&&i(R)){if(y.bs===E&&R.bs===E)continue;u.list[p]={bs:E,be:E,toks:N},g.list[m]={bs:E,be:E,toks:L}}else!i(y)&&y.bs===R.bs&&y.be===R.be?(h(u,p,N,F,S),h(g,m,L,F,S)):(a(u,p,N,F,S,E),a(g,m,L,F,S,E));A=!0;break e}}}if(f(u,p,g,m)||f(g,m,u,p)){A=!0;break e}}}if(!A)break}return[u.list,g.list]}var Tc=48,Ac=.3;function Sc(e,n){let t=e.filter(l=>!Jn(l)),o=n.filter(l=>!Jn(l));if(Math.min(t.length,o.length)<Tc)return!1;let r=new Map;for(let l of t)r.set(l.k,(r.get(l.k)||0)+1);let c=0;for(let l of o){let i=r.get(l.k);i>0&&(c++,r.set(l.k,i-1))}return c/Math.min(t.length,o.length)<Ac}var Nc=(e,n)=>{let t=new Set;for(let o of e.toks)typeof o.k!="string"&&t.add(o.k.el);for(let o=e.bs;o<e.be;o++)typeof n[o].k!="string"&&t.add(n[o].k.el);return t},Jr=(e,n)=>e.length===n.length&&e.every((t,o)=>t.k===n[o].k);function li(e,n,t,o="remote"){let r=Kn(e,n),c=Kn(e,t),{lh:l,rh:i,cosL:s,cosR:a}=Xr(r,c,e),h=w=>w.bs===w.be,f=w=>w.toks.some(K=>typeof K.k=="string"),u=w=>h(w)&&!f(w),g=(w,K)=>K.bs<w.be&&w.bs<K.be,b=(w,K)=>!g(w,K)&&K.bs<=w.be&&w.bs<=K.be&&(h(w)&&f(w)||h(K)&&f(K))&&!(h(w)&&h(K)),A=(w,K)=>w.bs===K.bs&&w.be===K.be&&Jr(w.toks,K.toks),p=[],m=new Set;for(let w of l){let K=i.find(ne=>!m.has(ne)&&A(w,ne));K?(m.add(K),p.push({bs:w.bs,be:w.be,side:"both",l:w,r:K,toks:w.toks})):p.push({bs:w.bs,be:w.be,side:"L",l:w,toks:w.toks,lead:!!w.lead})}for(let w of i)m.has(w)||p.push({bs:w.bs,be:w.be,side:"R",r:w,toks:w.toks,lead:!!w.lead});p.sort((w,K)=>w.bs-K.bs||w.be-K.be||K.lead-w.lead);let y=0,R=0;for(let w of p)w.side==="both"&&(y+=w.toks.length-(w.be-w.bs));let S=p.map((w,K)=>K),O=w=>S[w]===w?w:S[w]=O(S[w]),M=(w,K)=>(w=O(w),K=O(K),w===K?!1:(S[w]=K,!0)),E=p.map(w=>Nc({bs:w.bs,be:w.be,toks:w.toks},e)),N={L:new Map,R:new Map};p.forEach((w,K)=>{let ne=w.side==="both"?["L","R"]:[w.side];for(let ee of ne)for(let Pe of E[K])N[ee].has(Pe)||N[ee].set(Pe,[]),N[ee].get(Pe).push(K)});for(let w of[N.L,N.R])for(let K of w.values())for(let ne=1;ne<K.length;ne++)M(K[0],K[ne]);for(let w=0;w<p.length;w++)for(let K=w+1;K<p.length;K++){let ne=p[w],ee=p[K];ne.side===ee.side&&ne.side!=="both"||ne.bs>ee.be||(g(ne,ee)||b(ne,ee)?M(w,K):ne.bs===ee.bs&&h(ne)&&h(ee)&&R++)}let L=(w,K)=>{let ne=w==="L"?l:i;for(let ee of ne)if(ee.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===K.el))return ee.bs;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="close"&&e[ee].k.el===K.el)return ee;return-1};p.forEach((w,K)=>{if(!(!u(w)||w.side==="both"))for(let ne of w.toks){if(ne.kind!=="open")continue;let ee=L(w.side,ne.k);if(ee<=w.bs)continue;let Pe=new Uint8Array(ee-w.bs),_e=[];if(p.forEach((Ae,ot)=>{if(!(Ae.side===w.side||h(Ae))&&Ae.bs<ee&&Ae.be>w.bs){_e.push(ot);for(let Qe=Math.max(Ae.bs,w.bs);Qe<Math.min(Ae.be,ee);Qe++)Pe[Qe-w.bs]=1}}),_e.length&&Pe.every(Ae=>Ae===1))for(let Ae of _e)M(K,Ae)}});let j=!0;for(;j;){j=!1;let w=new Map;p.forEach((K,ne)=>{let ee=O(ne),Pe=w.get(ee)||{bs:K.bs,be:K.be,L:!1,R:!1};Pe.bs=Math.min(Pe.bs,K.bs),Pe.be=Math.max(Pe.be,K.be),K.side!=="R"&&(Pe.L=!0),K.side!=="L"&&(Pe.R=!0),w.set(ee,Pe)}),p.forEach((K,ne)=>{for(let[ee,Pe]of w){if(O(ne)===O(ee)||!(Pe.L&&Pe.R))continue;let _e=K.bs<Pe.be&&K.be>Pe.bs,Ae=h(K)&&f(K)&&(K.bs===Pe.be||K.bs===Pe.bs);(_e||Ae)&&M(ne,ee)&&(j=!0)}})}let F=new Map;p.forEach((w,K)=>{let ne=O(K);F.has(ne)||F.set(ne,[]),F.get(ne).push(w)});let W=[];for(let w of F.values()){let K=w.some(ee=>ee.side==="L"),ne=w.some(ee=>ee.side==="R");if(K&&ne){let ee=Math.min(...w.map(ot=>ot.bs)),Pe=Math.max(...w.map(ot=>ot.be)),_e=w.filter(ot=>ot.side!=="R").map(ot=>ot.l).sort((ot,Qe)=>ot.bs-Qe.bs),Ae=w.filter(ot=>ot.side!=="L").map(ot=>ot.r).sort((ot,Qe)=>ot.bs-Qe.bs);W.push({bs:ee,be:Pe,kind:"conflict",localHunks:_e,remoteHunks:Ae})}else for(let ee of w)W.push({bs:ee.bs,be:ee.be,kind:ee.side,u:ee})}let C=(w,K)=>{let ne=w==="L"?l:i;for(let ee of ne)if(ee.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===K.el))return ee.bs+.5;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="close"&&e[ee].k.el===K.el)return ee;return 1/0},T=(w,K)=>{let ne=w==="L"?l:i;for(let ee of ne)if(ee.toks.some(Pe=>Pe.kind==="open"&&Pe.k.el===K.el))return ee.bs-.5;for(let ee=0;ee<e.length;ee++)if(e[ee].kind==="open"&&e[ee].k.el===K.el)return ee;return-1/0},x=w=>w.kind==="R"?"R":"L",z=w=>w.kind==="R"?1:0;W.sort((w,K)=>{if(w.bs!==K.bs)return w.bs-K.bs;let ne=w.bs===w.be,ee=K.bs===K.be;if(ne!==ee)return ne?-1:1;if(ne&&ee&&w.kind!=="conflict"&&K.kind!=="conflict"){let _e=w.u.toks,Ae=K.u.toks,ot=Ze=>Ze.length&&Ze.every(Xe=>Xe.kind==="open"),Qe=Ze=>Ze.length&&Ze.every(Xe=>Xe.kind==="close");if(ot(_e)&&ot(Ae)){let Ze=Math.max(..._e.map(yt=>C(x(w),yt.k))),Xe=Math.max(...Ae.map(yt=>C(x(K),yt.k)));if(Ze!==Xe)return Xe-Ze}if(Qe(_e)&&Qe(Ae)){let Ze=Math.min(..._e.map(yt=>T(x(w),yt.k))),Xe=Math.min(...Ae.map(yt=>T(x(K),yt.k)));return Ze!==Xe?Xe-Ze:z(K)-z(w)}}let Pe=_e=>_e.u&&_e.u.lead?1:0;return Pe(K)-Pe(w)||z(w)-z(K)||w.be-K.be});let D=[],V=[],Ee=0,Me=w=>{w>Ee&&(D.push({bs:Ee,be:w,toks:e.slice(Ee,w),source:"base"}),Ee=w)};for(let w of W){if(Me(w.bs),w.kind==="conflict"){let K=Yr(e,w.localHunks,w.bs,w.be),ne=Yr(e,w.remoteHunks,w.bs,w.be),ee=o==="local"?K:o==="both"?K.concat(ne):ne,Pe=(ot,Qe)=>{let Ze=0;for(let Xe of ot)Xe.be<=w.bs&&!Qe.includes(Xe)&&(Ze+=Xe.toks.length-(Xe.be-Xe.bs));return Ze},_e=w.bs+Pe(l,w.localHunks),Ae=w.bs+Pe(i,w.remoteHunks);V.push({bs:w.bs,be:w.be,ls:_e,le:_e+K.length,rs:Ae,re:Ae+ne.length,ms:0,me:0,base:e.slice(w.bs,w.be),local:K,remote:ne,resolved:ee}),D.push({bs:w.bs,be:w.be,toks:ee,source:"conflict",localHunks:w.localHunks,localToks:K,keepsLocal:o!=="remote"})}else D.push({bs:w.bs,be:w.be,toks:w.u.toks,source:w.kind==="R"?"remote":"local",localHunks:w.kind==="R"?[]:[w.u.l]});Ee=Math.max(Ee,w.be)}Me(e.length);let De=0,re=0;for(let w of D)w.source==="conflict"&&(V[re].ms=De,V[re].me=De+w.toks.length,re++),De+=w.toks.length;let Se=new Map(s.map(w=>[w.bi,w.tok])),qe=new Map(a.map(w=>[w.bi,w.tok])),ve=[];for(let w of D){w.source==="base"&&(w.toks=w.toks.map((K,ne)=>{let ee=w.bs+ne,Pe=Se.get(ee),_e=qe.get(ee),Ae=Pe&&_e?o==="remote"?_e:Pe:Pe||_e||K;return Ae===K?K:{...Ae,cosmetic:!0}}));for(let K of w.toks)ve.push({...K,src:w.source})}return{tokens:ve,segments:D,conflicts:V,localHunks:l,remoteHunks:i,collapsedDelta:y,samePoint:R,mapLocalOffset:vc(e,l,D)}}function Yr(e,n,t,o){let r=[],c=t;for(let l of n)r=r.concat(e.slice(c,l.bs),l.toks),c=l.be;return r.concat(e.slice(c,o))}var zr=e=>e.reduce((n,t)=>n+t.len,0);function vc(e,n,t){let o=new Int32Array(e.length+1);for(let l=0;l<e.length;l++)o[l+1]=o[l]+e[l].len;let r=n.map(l=>({bs:o[l.bs],be:o[l.be],text:l.toks.map(i=>i.raw).join(""),ref:l})),c=t.map(l=>({bs:o[l.bs],be:o[l.be],len:zr(l.toks),source:l.source,localHunks:l.localHunks||[],localLen:l.localToks?zr(l.localToks):0,keepsLocal:l.keepsLocal,ref:l}));return l=>{let i=null,s=null,a=0,h=0,f=0;for(let g of r){let b=g.bs-f;if(l<=h+b){i=f+(l-h);break}if(h+=b,f=g.bs,l<=h+g.text.length){s=g,a=l-h,i=g.bs;break}h+=g.text.length,f=g.be}i===null&&(i=f+(l-h));let u=0;for(let g of c){if(!s&&i<=g.bs)return u;if(!(s?g.localHunks.includes(s.ref):i<g.be)){u+=g.len;continue}if(g.source==="base")return u+(i-g.bs);if(g.source==="remote")return u+g.len;if(g.source==="local")return u+Math.min(a,g.len);if(!g.keepsLocal||!s)return u+g.len;let A=g.localHunks.indexOf(s.ref),p=zr(Yr(e,g.localHunks.slice(0,A),g.ref.bs,s.ref.bs));return u+Math.min(p+a,g.localLen)}return u}}function Ho(e,n,t,o="remote"){if(n===t||t===e)return{text:n,conflicts:[],mapLocalOffset:m=>Math.min(m,n.length),granularity:"word"};let r=yn(e,n,t),c=ln(e,r),l=ln(n,r),i=ln(t,r),s=c.length<=2e4&&l.length<=2e4&&i.length<=2e4?li(c,l,i,o):null,a="word",h=c;if(!s){let m=y=>y.split(/(?<=\n)/).map(R=>({k:R,raw:R,len:R.length}));h=m(e),s=li(h,m(n),m(t),o),a="line"}let f=m=>m.map(y=>y.raw).join(""),u=m=>{let y=[0];for(let R of m)y.push(y[y.length-1]+R.len);return y},g=u(h),b=null,A=null,p=null;if(s.conflicts.length){let m=y=>y.split(/(?<=\n)/).map(R=>({k:R,raw:R,len:R.length}));b=u(a==="line"?m(n):l),A=u(a==="line"?m(t):i),p=u(s.tokens)}return{text:f(s.tokens),conflicts:s.conflicts.map(m=>({bs:g[m.bs],be:g[m.be],ls:b[m.ls],le:b[m.le],rs:A[m.rs],re:A[m.re],ms:p[m.ms],me:p[m.me],base:f(m.base),local:f(m.local),remote:f(m.remote),resolved:f(m.resolved)})),mapLocalOffset:s.mapLocalOffset,granularity:a}}function ro(e,n,t=4e3){if(e===n)return[];let o=yn(e,n),r=ln(e,o),c=ln(n,o),l=Kn(r,c,t),i=[0];for(let s of r)i.push(i[i.length-1]+s.len);return l.hunks.map(s=>({bs:i[s.bs],be:i[s.be],text:s.toks.map(a=>a.raw).join("")}))}function Kt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Dn({base:e,side:n,retained:t,transfers:o,baseAtomKey:r=i=>i.el,sideAtomKey:c=i=>i.el,budget:l=Kt()}){let i=[],s=O=>({status:"fallback",reason:O}),a=O=>O>l.remaining?!1:(l.remaining-=O,!0);if(!a((t.length+o.length)*3))return s("work-limit");for(let[O,M]of[["retained",t],["transfer",o]])for(let E of M){let{from:N,to:L,target:j}=E;if(!Number.isInteger(N)||!Number.isInteger(L)||!Number.isInteger(j)||N<0||L<=N||L>e.text.length||j<0||j+L-N>n.text.length)return s("invalid-range");i.push({...E,kind:O})}let h=Symbol(),f=O=>(M,E)=>{if(!a(1))throw h;return l.sortComparisons++,O(M,E)},u,g;try{u=i.slice().sort(f((O,M)=>O.from-M.from||O.to-M.to)),g=i.slice().sort(f((O,M)=>O.target-M.target||O.to-O.from-(M.to-M.from)))}catch(O){if(O===h)return s("work-limit");throw O}if(!a(i.length*2))return s("work-limit");for(let O=1;O<u.length;O++)if(u[O].from<u[O-1].to)return s("source-overlap");for(let O=1;O<g.length;O++)if(g[O].target<g[O-1].target+g[O-1].to-g[O-1].from)return s("target-overlap");for(let O of u){let M=O.to-O.from;if(!a(M))return s("work-limit");for(let E=0;E<M;E++){let N=O.from+E,L=O.target+E;if(l.comparisons++,e.text[N]!==n.text[L])return s("unequal-occurrence");let j=e.atomAt.get(N),F=n.atomAt.get(L);if(!!j!=!!F||j&&r(j)!==c(F))return s("different-atom")}}let b=e.text.length+n.text.length+2,A=i.reduce((O,M)=>O+(M.to-M.from)*2,2);if(!a(b+A+i.length))return s("work-limit");let p=new Int32Array(e.text.length+1).fill(-1),m=new Int32Array(n.text.length+1).fill(-1);l.mapCells+=b,l.mapWrites+=A;let y=-1,R=!0;for(let O of u){O.target<y&&(R=!1),y=O.target+O.to-O.from;for(let M=0;M<O.to-O.from;M++)p[O.from+M]=O.target+M,m[O.target+M]=O.from+M}return p[e.text.length]=n.text.length,m[n.text.length]=e.text.length,{status:"ready",runs:u,bTo:p,toB:m,monotone:R,covers:(O,M)=>{if(!a(M-O))return null;l.coverageChecks+=M-O;for(let E=O;E<M;E++)if(e.text[E]!==wt&&!/\s/.test(e.text[E])&&p[E]<0)return!1;return!0}}}function Qr({base:e,side:n,baseOf:t=()=>null,budget:o=Kt()}){if(e.text===n.text||!e.text.includes(wt)&&!n.text.includes(wt))return{status:"none"};let r=(e.text.length+n.text.length)*8;if(r>o.remaining)return{status:"fallback",reason:"work-limit"};o.remaining-=r,o.boundarySteps=(o.boundarySteps||0)+r;let c=(b,A)=>A<b.length&&(b[A]===wt||/\s/.test(b[A])),l=new Map,i=Symbol(),s=(b,A)=>{let p=b.stackAt[A]||[];if(!l.has(p)){if(p.length>o.remaining)throw i;o.remaining-=p.length,o.boundarySteps+=p.length,l.set(p,p.find(m=>m.block)?.el||null)}return l.get(p)},a=[],h=(b,A)=>{let p=s(e,b),m=s(n,A),y=p&&m&&t(m)!==p?"transfer":"retained",R=a[a.length-1];R&&R.to===b&&R.target+R.to-R.from===A&&R.kind===y&&R.destination===m?R.to++:a.push({from:b,to:b+1,target:A,destination:m,kind:y})},f=0,u=0,g=!1;try{for(;f<e.text.length||u<n.text.length;){if(f<e.text.length&&u<n.text.length&&e.text[f]===n.text[u]){let R=e.atomAt.get(f),S=n.atomAt.get(u);if(!!R!=!!S||R&&t(S.el)!==R.el)return{status:"none"};h(f++,u++);continue}if(!c(e.text,f)&&!c(n.text,u))return{status:"none"};let b=f,A=u;for(;c(e.text,f);)f++;for(;c(n.text,u);)u++;let p=e.text.slice(b,f),m=n.text.slice(A,u);(p.includes(wt)||m.includes(wt))&&(g=!0);let y=0;for(;y<f-b&&y<u-A&&e.text[f-y-1]===n.text[u-y-1];)y++;for(let R=y;R>0;R--)h(f-R,u-R)}}catch(b){if(b===i)return{status:"fallback",reason:"work-limit"};throw b}return g?Dn({base:e,side:n,retained:a.filter(b=>b.kind==="retained"),transfers:a.filter(b=>b.kind==="transfer"),sideAtomKey:b=>t(b.el)||b.el,budget:o}):{status:"none"}}var ci=/\s/,gr=/\S/;function Mn(e,n,t,o,r,c,l=-1,i=-1){if(!e.length)return-1;r(o,e.length);let s=new Int32Array(e.length),a=0;for(let g=1;g<e.length;g++){for(r(o,1);a&&(r(o,1),e[a]!==e[g]);)a=s[a-1];r(o,1),e[a]===e[g]&&a++,s[g]=a}let h=-1,f=0,u=0;a=0;for(let g=0;g<n.length;g++){for(r(o,1);a&&(r(o,1),e[a]!==n[g]);)a=s[a-1];if(r(o,1),e[a]===n[g]&&a++,a!==e.length)continue;let b=g+1-e.length,A=g+1;for(a=s[a-1];f<t.length&&t[f].from<b;)r(o,1),f++;for(;u<t.length&&t[u].to<A;)r(o,1),u++;if(r(o,6),!(f===t.length||u===t.length||t[f].from!==b||t[u].to!==A||l>=0&&b<i&&A>l)){if(!c)return b;if(h>=0)return-1;h=b}}return h}function Wo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function Zr(e,n,t,o){let r=null;for(let l of n)if(o(t,1),!(l.source!==e.source||l.side!==e.side))for(let i of l.runs){if(o(t,1),i.source!==e.source)continue;let s=Math.max(e.from,i.from),a=Math.min(e.to,i.to);s>=a||(r||(o(t,e.to-e.from),r=new Uint8Array(e.to-e.from)),o(t,a-s),r.fill(1,s-e.from,a-e.from))}if(!r)return!1;o(t,e.to-e.from);let c=!1;for(let l=e.from;l<e.to;l++)if(gr.test(e.flat.text[l])){if(!r[l-e.from])return!1;c=!0}return c}function es({source:e,side:n,views:t,eligible:o,blocked:r,baseId:c,model:l,tokensOf:i,budget:s,charge:a}){let{V:h,A:f,idOf:u}=t[n],g=t[1-n];if(e.nodeType!==1||f.identical.has(e)||g.A.identical.has(e)||r.has(e)||!o(e))return null;let b=h.twin(e),A=g.V.twin(e);if(!b||!A||f.map.get(e)!==b||f.reverse.get(b)!==e||g.A.map.get(e)!==A||g.A.reverse.get(A)!==e||!h.here(b)||!g.V.here(A)||!o(b)||!o(A))return null;let p=c(e);if(p!==u(b)||p!==g.idOf(A))return null;let m=l(e,null,s),y=l(b,f,s),R=l(A,g.A,s);if(!Wo(m)||!Wo(y)||!Wo(R))return null;let S=m.flat.text,O=y.flat.text;if(a(s,S.length+O.length*3),!gr.test(O)||O.length>=S.length)return null;let M=S.startsWith(O),E=S.endsWith(O);if(M===E)return null;let N=M?O.length:0,L=M?S.length:S.length-O.length,j=N,F=L;for(;j<F&&(a(s,1),!!ci.test(S[j]));)j++;for(;F>j&&(a(s,1),!!ci.test(S[F-1]));)F--;if(j===F)return null;let W=i(m,s),C=!1,T=!1;for(let x of W)a(s,1),x.from===j&&(C=!0),x.to===F&&(T=!0);return!C||!T?null:{source:e,side:n,flat:m.flat,from:N,to:L}}function ai({base:e,views:n,side:t,attempt:o,eligible:r,blocked:c,baseId:l,model:i,tokensOf:s,certificates:a,charge:h,exhausted:f,limit:u}){if(u<=0)return null;let g=Kt(u),{V:b,A,idOf:p}=n[t],m=n[1-t],[y,R,S,O]=o,M=null;try{for(let E=y;E<=R;E++){h(g,1);let N=e[E];if(N.nodeType!==1||A.identical.has(N)||m.A.identical.has(N)||c.has(N)||!r(N))continue;let L=es({source:N,side:t,views:n,eligible:r,blocked:c,baseId:l,model:i,tokensOf:s,budget:g,charge:h});if(!L||Zr(L,a,g,h))continue;let{flat:j,from:F,to:W}=L;h(g,(W-F)*2);let C=j.text.slice(F,W).trim();for(let T=S;T<=O;T++){h(g,1);let x=b.units[T],z=b.baseOf(x);if(!z||z===N||z.nodeType!==1||x.nodeType!==1||z.parentNode!==N.parentNode||x.parentNode!==A.map.get(N).parentNode||A.map.get(z)!==x||A.reverse.get(x)!==z||c.has(z)||!r(z)||!r(x)||l(z)!==p(x))continue;let D=i(z,null,g),V=i(x,A,g);if(!Wo(D)||!Wo(V))continue;let Ee=D.flat.text,Me=V.flat.text;if(h(g,Ee.length),!gr.test(Ee)||Me.length<=Ee.length)continue;let De=s(V,g),re=Mn(Ee,Me,De,g,h,!0);if(!(re<0)&&!(Mn(C,Me,De,g,h,!1,re,re+Ee.length)<0)){(M||=[]).push(L);break}}}}catch(E){if(E!==f)throw E}return M}function fi(e,n,t,o,r,c,l){if(c==="both"||t.atoms.length||o.atoms.length||r.atoms.length)return c;let i=c==="remote";if(i?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 c;for(let s of e){if(s.source!==n||s.side!==(i?1:0)||s.flat.text!==t.text||s.flat.nodes.length!==t.nodes.length||l.be<=s.from||l.bs>=s.to)continue;let a=!0;for(let f=0;f<t.nodes.length;f++){let u=s.flat.nodes[f],g=t.nodes[f];if(u.node!==g.node||u.s!==g.s||u.e!==g.e){a=!1;break}}if(!a)continue;let h=!1;for(let f=l.bs;f<l.be;f++)if(gr.test(t.text[f])){if(f<s.from||f>=s.to){a=!1;break}h=!0}if(a&&h)return i?"local":"remote"}return c}var Bn="\uFFFC";var Oc={caret:0},wn=new Set("A ABBR B BDI BDO CITE CODE DATA DEL DFN EM FONT I INS KBD MARK Q S SAMP SMALL SPAN STRIKE STRONG SUB SUP TIME TT U VAR".split(" ")),yi=new Set(["BR","WBR","IMG"]),ts=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 Un(e,n={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(n.ignored&&n.ignored(e)||yi.has(e.tagName))return!0;if(!wn.has(e.tagName))return!ts.has(e.tagName);if(n.remoteWins&&n.remoteWins(e))return!1;let t=n.inlineCache&&n.inlineCache.get(e);if(t!==void 0)return t;let o=!0;for(let r of e.childNodes)if(!Un(r,n)){o=!1;break}return n.inlineCache&&n.inlineCache.set(e,o),o}function Mc(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function en(e,n={}){let t={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,c)=>{for(let l of r){if(l.nodeType===3){let f=l.nodeValue;if(!f)continue;t.nodes.push({node:l,s:t.text.length,e:t.text.length+f.length}),t.text+=f;for(let u=0;u<f.length;u++)t.stackAt.push(c);continue}if(l.nodeType!==1)continue;if(n.ignored&&n.ignored(l)){t.pins.push({el:l,i:t.text.length});continue}if(n.skip&&n.skip.has(l))continue;let i=n.via&&n.via(l)||l;i!==l&&(t.via||(t.via=new Map)).set(i,l);let s=l.tagName;if(n.blocks&&n.blocks.has(l)){t.text.length&&t.text[t.text.length-1]!==wt&&(t.stackAt.push(c),t.text+=wt);let f={el:l,tag:s,from:t.text.length,to:-1,depth:c.length,block:!0};t.marks.push(f);let u=c.concat([f]);o(i.childNodes,u),t.stackAt.push(u),t.text+=wt,f.to=t.text.length;continue}let a=wn.has(s)&&Mc(i);if(yi.has(s)||!wn.has(s)||n.remoteWins&&n.remoteWins(l)||n.atomize&&n.atomize(l)||a){t.atoms.push({i:t.text.length,el:l,key:a?s+":empty":s,stack:c}),t.stackAt.push(c),t.text+=Bn;continue}let h={el:l,tag:s,from:t.text.length,to:-1,depth:c.length};t.marks.push(h),o(i.childNodes,c.concat([h])),h.to=t.text.length}};if(o(e,[]),t.atoms.length===1&&t.atoms[0].el.tagName==="BR"&&t.marks.length===0&&wr(t).trim()===""){let r=t.atoms[0];t.placeholder=r.el,t.text=t.text.slice(0,r.i)+t.text.slice(r.i+1),t.stackAt.splice(r.i,1);for(let c of t.nodes)c.s>r.i&&(c.s--,c.e--);t.atoms=[]}return t.atomAt=new Map(t.atoms.map(r=>[r.i,r])),t}function Ec(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function Ic(e){let n="<"+e.tagName.toLowerCase();for(let t of e.attributes)n+=` ${t.name}="${t.value.replace(/"/g,"&quot;")}"`;return n+">"}function ko(e,n,t){let o="",r=[];for(let c=n;c<t;c++){let l=e.stackAt[c],i=0;for(;i<r.length&&i<l.length&&r[i]===l[i];)i++;for(;r.length>i;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<l.length;){let a=l[r.length];o+=Ic(a.el),r.push(a)}let s=e.atomAt.get(c);o+=s?s.el.outerHTML:e.text[c]===wt?"":Ec(e.text[c])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function Cc(e,n){let t=[...e.el.attributes].filter(o=>!n(e.el,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tag+"|"+t}function wi(e,n){let t=[...e.attributes].filter(o=>!n(e,o.name)).map(o=>o.name+"="+o.value).sort().join("");return e.tagName+"|"+t+"|"+e.innerHTML}function ui(e,n=()=>!1){let t=new Map,o=c=>{let l=t.get(c);return l===void 0&&(l="{"+c.map(i=>Cc(i,n)).sort().join(",")+"}",t.set(c,l)),l},r="";for(let c=0;c<e.text.length;c++){let l=e.atomAt.get(c);r+=(l?"["+wi(l.el,n)+"]":e.text[c])+o(e.stackAt[c])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function xo(e,n,t,o=r=>r.key){let r=[],c=e.text,l=0,i=s=>{if(s<=l)return;let a=c.slice(l,s);if(t)for(let h of a.split(/(?<=\n)/))r.push({k:h,raw:h,len:h.length});else for(let h of ln(a,n))r.push(h)};for(let s of e.atoms)i(s.i),r.push({k:"\0"+o(s),raw:Bn,len:1,atom:!0}),l=s.i+1;return i(c.length),r}function wr(e){if(!e.atoms.length)return e.text;let n="",t=0;for(let o of e.atoms)n+=e.text.slice(t,o.i),t=o.i+1;return n+e.text.slice(t)}var To=e=>{let n=new Int32Array(e.length+1);for(let t=0;t<e.length;t++)n[t+1]=n[t]+e[t].len;return n};function br(e,n,t,o){let r=To(n),c=To(t),l=[],i=0,s=0;for(let h of o.hunks){s+=h.bs-i;let f=s+h.toks.length;l.push({bs:r[h.bs],be:r[h.be],ss:c[s],se:c[f],text:e.text.slice(c[s],c[f]),toks:h.toks,lead:!!h.lead}),s=f,i=h.be}let a=new Map;for(let h of o.cosmetic)a.set(h.bi,h.tok.raw);return{hunks:l,respell:a}}function di(e,n,t){let o=l=>l===wt||/\s/.test(l),r=l=>l.replace(/[\u001E\s]/g,""),c=[];for(let l of e){let i=n.slice(l.bs,l.be),s=t.slice(l.ss,l.se);if(!i.includes(wt)&&!s.includes(wt)||i.includes(Bn)||s.includes(Bn)||r(i)!==r(s)){c.push(l);continue}let a=0,h=0;for(;;){let f=a,u=h;for(;f<i.length&&o(i[f]);)f++;for(;u<s.length&&o(s[u]);)u++;let g=a,b=h;for(;g<f&&b<u&&i[g]===s[b];)g++,b++;let A=f,p=u;for(;A>g&&p>b&&i[A-1]===s[p-1];)A--,p--;if(A>g||p>b){let m=s.slice(b,p);c.push({bs:l.bs+g,be:l.bs+A,ss:l.ss+b,se:l.ss+p,text:m,toks:[...m].map(y=>({k:y,raw:y,len:1})),lead:l.lead})}if(f>=i.length)break;a=f+1,h=u+1}}return c}function hi(e,n,t){let o=new Int32Array(n+1).fill(-1),r=new Int32Array(t+1).fill(-1),c=0,l=0,i=s=>{for(;c<s;)o[c]=l,r[l]=c,c++,l++};for(let s of e)i(s.bs),c=s.be,l=s.se;return i(n),o[n]=l,r[l]=n,{bTo:o,toB:r}}function pi(e,n,t){let o=[],r=0,c=0,l=(i,s)=>{if(r===i&&c===s)return;let a=n.text.slice(c,s);o.push({bs:r,be:i,ss:c,se:s,text:a,toks:ln(a,yn(a)),lead:!1})};for(let i of t.runs)l(i.from,i.target),r=i.to,c=i.target+i.to-i.from;return l(e.text.length,n.text.length),{hunks:o,respell:new Map}}function mi(e,n,t,o){let r=To(n),c=To(t),l=(s,a)=>{let h=0,f=s.length;for(;h<f;){let u=h+f>>>1;s[u]<a?h=u+1:f=u}return s[h]===a?h:-1};for(let s of e.hunks)if(l(r,s.bs)<0||l(r,s.be)<0)return null;if(e.hunks.some(s=>l(c,s.ss)<0||l(c,s.se)<0)){if(!o)return null;let s=[];for(let u of e.hunks)s.push(u.ss,u.se);let a=[],h=0,f=0;for(let u of t){let g=f+u.len;for(;h<s.length&&s[h]<=f;)h++;let b=f;for(;h<s.length&&s[h]<g;){let A=s[h++];if(A>b){let p=u.raw.slice(b-f,A-f);a.push(...ln(p,yn(p))),b=A}}if(b===f)a.push(u);else{let A=u.raw.slice(b-f);a.push(...ln(A,yn(A)))}f=g}t=a,c=To(t)}let i=[];for(let s of e.hunks){let a=l(r,s.bs),h=l(r,s.be),f=l(c,s.ss),u=l(c,s.se);if(a<0||h<0||f<0||u<0)return null;i.push({bs:a,be:h,toks:t.slice(f,u),gap:[],group:i.length})}return{parts:i,cosmeticEq:[],tokens:t}}function ns(e,n,t,o={},r=null){return xi(e,n,t,o.base,o.local,o.remote,r,{})}function xi(e,n,t,o,r,c,l,i){let s=yn(wr(e),wr(n),wr(t)),a=xo(e,s,!1,o),h=xo(n,s,!1,r),f=xo(t,s,!1,c),u=a.length>2e4||h.length>2e4||f.length>2e4;u&&(a=xo(e,s,!0,o),h=xo(n,s,!0,r),f=xo(t,s,!0,c));let g=l?.local?pi(e,n,l.local):null,b=l?.remote?pi(e,t,l.remote):null,A=g?mi(g,a,h,!u):Kn(a,h),p=b?mi(b,a,f,!u):Kn(a,f);g&&A&&(h=A.tokens),b&&p&&(f=p.tokens);let m,y;if(A&&p){let R=Xr(A,p,a);m=br(n,a,h,{hunks:R.lh,cosmetic:R.cosL}),y=br(t,a,f,{hunks:R.rh,cosmetic:R.cosR})}else m=g||br(n,a,h,A),y=b||br(t,a,f,p);return m.hunks=di(m.hunks,e.text,n.text),y.hunks=di(y.hunks,e.text,t.text),i.base=e,i.local=n,i.remote=t,i.lines=u,i.baseTokens=a,i.localEdits=m,i.remoteEdits=y,i.localMap=hi(m.hunks,e.text.length,n.text.length),i.remoteMap=hi(y.hunks,e.text.length,t.text.length),i.full=null,i}function gi(e,n){if(e.size!==n.size)return!1;for(let t of e)if(!n.has(t))return!1;return!0}var Ao=/\s/;function yr(e,n,t){for(let o=n;o<t;o++)if(!Ao.test(e[o]))return!1;return!0}function Rc(e,n,t){let o=e.cache[t]||(e.cache[t]=new Map);if(o.has(n))return o.get(n);let r=t===0?"local":"remote",c=t===0?"remote":"local",l=n.baseMark,i=n[c+"Mark"],s=!n.block&&!n[r]&&!!i&&l.to>l.from;if(s){let a=t===0?e.ML:e.MR,h=t===0?e.MR:e.ML,f=t===0?e.fr:e.fl,u=!1;for(let g=l.from;g<l.to;g++){if(a.bTo[g]>=0){s=!1;break}h.bTo[g]<0&&!Ao.test(e.fb.text[g])&&(u=!0)}if(s&&!u){for(let g=i.from;g<i.to;g++)if(h.toB[g]<0&&!Ao.test(f.text[g])){u=!0;break}}s&&=u}return o.set(n,s),s}function bi(e,n,t,o,r,c,l,i,s){let a=i===0?e.fl:e.fr,h=null;for(let f=t;f<o;f++){let u=n[f];if(!yr(a.text,u.ss,u.se))return null;if(yr(e.fb.text,u.bs,u.be)){if(u.bs<u.be&&u.ss<u.se||Ao.test(e.fb.text[u.bs-1]||"")||Ao.test(e.fb.text[u.be]||""))continue;return null}let g=!1;for(let b=u.bs;b<u.be;b++){if(Ao.test(e.fb.text[b]))continue;let A=null;for(let p of e.fb.stackAt[b]){let m=e.byEl.get(p.el);if(m&&Rc(e,m,i)){A=m;break}}if(!A)return null;(h||(h=new Set)).add(A),g=!0}if(!g)return null}if(!h){if((i===0?"local":"remote")!==s)return null;let f=i===0?e.fr:e.fl,u=!1;for(let g=c;g<l;g++){let b=r[g];if(!yr(e.fb.text,b.bs,b.be))return null;yr(f.text,b.ss,b.se)||(u=!0)}if(!u)return null}return h||0}function so(e){let{out:n,policy:t="remote",L:o,R:r}=e,c=e.provenance||new WeakMap,l=e.textMappers||new WeakMap,i=e.conflicts||[],s=e.decisions||[],a=i.length,h=e.conflict||(d=>i.push(d)),f={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},u=[],g=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),b={base:null,local:null,remote:null};if(!e.prepared&&g&&e.moveIn){let d=Te=>Ve=>Te.some(Re=>Re===Ve||Re.nodeType===1&&Re.contains(Ve)),I=d(e.local),U=d(e.remote),H=d(e.base),X=new Set,de=Te=>{if(!wn.has(Te.tagName))return;let Ve=o.map.get(Te),Re=r.map.get(Te);(Ve&&!I(Ve)||Re&&!U(Re))&&X.add(Te);for(let Fe of Te.children)de(Fe)};for(let Te of e.base)Te.nodeType===1&&de(Te);let we=Te=>Ve=>{if(!wn.has(Ve.tagName))return!1;let Re=Te.reverse.get(Ve);return!!Re&&(X.has(Re)||!H(Re))};X.size&&(b.base=Te=>X.has(Te)),b.local=we(o),b.remote=we(r)}let A={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&g&&e.moveIn){let d=H=>X=>H.some(de=>de===X||de.nodeType===1&&de.contains(X)),I=d(e.local),U=d(e.remote);for(let H of en(e.base,{...e,atomize:b.base}).atoms){let X=o.map.get(H.el),de=r.map.get(H.el),we=!!X&&!I(X),Te=!!de&&!U(de);!we&&!Te||(we&&e.movePlanned?.(H.el,"local",X,null),Te&&e.movePlanned?.(H.el,"remote",de,null),A.base.add(H.el),X&&!we&&A.local.add(X),de&&!Te&&A.remote.add(de),I(H.el)&&A.local.add(H.el),U(H.el)&&A.remote.add(H.el))}}let p=e.prepared?.base||en(e.base,{...e,atomize:b.base,skip:A.base}),m=e.prepared?.local||en(e.local,{...e,atomize:b.local,skip:A.local}),y=e.prepared?.remote||en(e.remote,{...e,atomize:b.remote,skip:A.remote}),R=new Map(p.atoms.map(d=>[d.el,d])),S={},O=d=>e.prepared?e.prepared.full?.(d)||null:A[d].size?(S[d]||(S[d]=en(e[d],{...e,atomize:b[d]})),S[d]):null,M=(d,I,U)=>{I.namespaceURI?d.setAttributeNS(I.namespaceURI,I.name,U):d.setAttribute(I.name,U)},E=(d,I,U,H)=>{if(!I&&(!U||!H)){for(let de of(U||H).attributes)M(d,de,de.value);return}let X=new Map;for(let de of[I,U,H])if(de)for(let we of de.attributes)X.set(we.name,we);for(let[de,we]of X){let Te=I?I.getAttribute(de):null,Ve=U?U.getAttribute(de):Te,Re=H?H.getAttribute(de):Te,Fe;Ve===Re?Fe=Ve:Ve===Te?(Fe=Re,s.push({kind:"attr",el:d,name:de,source:"remote"})):Re===Te?(Fe=Ve,s.push({kind:"attr",el:d,name:de,source:"local"})):(Fe=t==="local"?Ve:Re,h({kind:"attr",el:d,name:de,base:Te,local:Ve,remote:Re,resolved:Fe},{el:d,sample:we}),s.push({kind:"attr",el:d,name:de,source:"both"})),Fe!=null&&M(d,we,Fe)}},N=(d,I,U,H)=>d&&e.mergeAttrs?e.mergeAttrs(d,I,U,H):E(H,d,I,U),L=e.mergeElement||((d,I,U)=>{let H=n.createElement(d.tagName);N(d,I,U,H);let X=I||d,de=U||d,we=t==="local"?X.isEqualNode(d)?de:X:de.isEqualNode(d)?X:de;for(let Te of we.childNodes)H.appendChild(n.importNode(Te,!0));return c.set(H,{base:d,local:I,remote:U}),H}),j=e.cloneUnit||((d,I)=>{let U=n.importNode(d,!0);return c.set(U,{base:null,local:I==="local"?d:null,remote:I==="remote"?d:null}),U}),F=e.atomKey||(d=>wi(d,()=>!1)),W=(d,I)=>{let U=new Map;for(let H of d.atoms)if(e.remoteWins&&e.remoteWins(H.el)&&wn.has(H.el.tagName))U.set(H,"w"+H.el.tagName+"#"+(H.el.id||""));else if(!g)U.set(H,H.key);else if(d===p)U.set(H,"="+F(H.el));else{let X=I.reverse.get(H.el),de=X?R.get(X):null;de?U.set(H,"="+F(de.el)):X?U.set(H,"m"+F(H.el)):U.set(H,"="+F(H.el))}return H=>U.get(H)},C=W(p,null),T=W(m,o),x=W(y,r),z=e.certifiedOrigins?e.certifiedOrigins(p,m,y,C,T,x):null;if(z?.fallback)return null;if(!z&&!e.prepared&&e.blocks){let d=Kt(),I=Qr({base:p,side:m,baseOf:H=>o?.reverse?.get(H)||null,budget:d}),U=Qr({base:p,side:y,baseOf:H=>r?.reverse?.get(H)||null,budget:d});(I.status==="ready"||U.status==="ready")&&(z={local:I.status==="ready"?I:null,remote:U.status==="ready"?U:null})}let D=e.prepared||xi(p,m,y,C,T,x,z,f),V=D.lines,Ee=D.baseTokens,Me=D.localEdits,De=D.remoteEdits,re=D.localMap,Se=D.remoteMap,qe=p.text.length,ve=d=>new Map(d.atoms.map(I=>[I.el,I])),w=ve(m),K=ve(y),ne=(d,I,U)=>{let H=new Set;if(!g)return H;for(let X of d.atoms){let de=R.get(I.reverse.get(X.el));de&&U.bTo[de.i]<0&&H.add(de)}return H},ee=ne(m,o,re),Pe=ne(y,r,Se),_e=d=>!Un(d,{...e,remoteWins:null}),Ae=new Set;if(g)for(let d of p.atoms){if(!_e(d.el))continue;let I=o.map.get(d.el)||null,U=r.map.get(d.el)||null,H=I&&!U?I:U&&!I?U:null;H&&(w.has(H)||K.has(H))&&!H.isEqualNode(d.el)&&Ae.add(d)}let ot=1,Qe=(d,I)=>({id:ot++,tag:d,base:null,local:null,remote:null,rank:I}),Ze=new Map,Xe=[];for(let d of p.marks){let I=Qe(d.tag,d.depth);I.block=!!d.block,I.base=d.el,I.baseMark=d,Ze.set(d.el,I),Xe.push(I)}let yt=(d,I)=>{let U=-1,H=-1;for(let X=d.from;X<d.to;X++){let de=I[X];de>=0&&(U<0&&(U=de),H=de+1)}return U<0?null:[U,H]},dt=(d,I,U,H)=>{for(let X of d.marks){let de=U?U.reverse.get(X.el):null;de&&U.identical.has(de)&&U.pairIdenticalChildren&&U.pairIdenticalChildren(de);let we=de?Ze.get(de):null;if(we&&we[I]&&(we=null),!we){let Te=yt(X,H),Ve=0;if(Te)for(let Re of Xe){if(Re.tag!==X.tag||Re[I]||!!Re.block!=!!X.block)continue;let Fe=Math.min(Te[1],Re.baseMark.to)-Math.max(Te[0],Re.baseMark.from);(Fe>Ve||Fe===Ve&&Fe>0&&Math.abs(Re.rank-X.depth)<Math.abs(we.rank-X.depth))&&(we=Re,Ve=Fe)}}we||(we=Qe(X.tag,X.depth),we.block=!!X.block,we.new=I),we[I]=X.el,we[I+"Mark"]=X,Ze.set(X.el,we)}};dt(m,"local",o,re.toB),dt(y,"remote",r,Se.toB);let gt=d=>d.merged||d,qt=d=>{let I=new Set;for(let U of d)U.block||I.add(Ze.get(U.el));return I},$t=new Map,Ht=d=>{let I=$t.get(d);return I||(I=qt(d),$t.set(d,I)),I},jt=(d,I)=>{let U=[],H=null;for(let X=0;X<qe;X++){let de=I[X];if(de<0){H&&U.push(H),H=null;continue}let we=Ht(p.stackAt[X]),Te=Ht(d.stackAt[de]),Ve=new Set,Re=new Set;for(let Fe of Te)we.has(Fe)||Ve.add(Fe);for(let Fe of we)Te.has(Fe)||Re.add(Fe);if(!Ve.size&&!Re.size){H&&U.push(H),H=null;continue}if(H&&gi(H.added,Ve)&&gi(H.removed,Re)){H.be=X+1;continue}H&&U.push(H),H={bs:X,be:X+1,added:Ve,removed:Re}}return H&&U.push(H),U},an=jt(m,re.bTo),_t=jt(y,Se.bTo),zt=d=>d.be>d.bs?[d.bs,d.be-1]:[d.bs-1,d.bs],_=(d,I)=>{if(qe===0)return null;let[U,H]=zt(d);for(let X of I){if(X.be<=U)continue;if(X.bs>H)break;let de=X.bs<=U&&H<X.be;return de&&d.text===""&&X.bs===d.bs&&X.be===d.be?"straddle":de?X:d.be>d.bs?"straddle":null}return null},ie=d=>d.bs===d.be,me=(d,I,U=null)=>{let H=!1;for(let X=d.bs;X<d.be;X++){let de=p.text[X];if(de===wt)H=!0;else if(!/\s/.test(de))return!1}for(let X=d.ss;X<d.se;X++){let de=I.text[X];if(de===wt)H=!0;else if(!/\s/.test(de)){let we=U&&e.scopeUnits&&ie(d)&&I.atomAt.get(X);if(!we||!_e(we.el)||U.ss!==U.se||U.bs>=U.be)return!1;for(let Ve=U.bs;Ve<U.be;Ve++)if(!/\s/.test(p.text[Ve]))return!1;let Te=I===m?1:2;if(!e.scopeUnits[Te].includes(we.el)||(Te===1?o:r)?.reverse.has(we.el))return!1;H=!0}}return H},pe=(d,I)=>d.bs<I.be&&I.bs<d.be,ke=(d,I)=>d.bs<=I.be&&I.bs<=d.be&&ie(d)!==ie(I),v=(d,I)=>p.text.slice(d.bs,d.be).includes(wt)||I.text.slice(d.ss,d.se).includes(wt),P=d=>{if(ie(d))return!1;let I=d.bs,U=d.be;for(;I>0&&/\s/.test(p.text[I-1]);)I--;for(;U<p.text.length&&/\s/.test(p.text[U]);)U++;return(I===0||p.text[I-1]===wt)&&(U===p.text.length||p.text[U]===wt)},Y=(d,I)=>!v(d,I)&&!P(d),J=(d,I)=>pe(d,I)||ke(d,I)&&!(d.transferIn||d.transferOut||I.transferIn||I.transferOut)&&!(me(d,m,I)&&Y(I,y))&&!(me(I,y,d)&&Y(d,m)),oe=(d,I)=>{if(d.bs!==I.bs||d.be!==I.be||d.toks.length!==I.toks.length)return!1;let U=d.ss,H=I.ss;for(let X=0;X<d.toks.length;X++){let de=d.toks[X],we=I.toks[X];if(de.k!==we.k||de.atom&&!m.atomAt.get(U).el.isEqualNode(y.atomAt.get(H).el))return!1;U+=de.len,H+=we.len}return!0},je=(d,I,U,H)=>{for(let X of p.atoms){if(X.i<d.bs||X.i>=d.be||H.has(X)||Ae.has(X))continue;let de=I.bTo[X.i],we=de>=0?U.atomAt.get(de):null;if(we&&!we.el.isEqualNode(X.el))return!0}return!1},Z=[],Oe=null,He=null,Ie=Me.hunks,ge=De.hunks,B=0,G=0,ue=0,he=0,ce=0,xe=d=>{d>ue&&(Z.push({src:"base",from:ue,to:d,dL:he,dR:ce}),ue=d)};for(;B<Ie.length||G<ge.length;){let d=Ie[B],I=ge[G],U=!!d&&(!I||d.bs<I.bs||d.bs===I.bs&&d.be<=I.be&&!I.lead);if(d&&I&&d.bs===I.bs&&ie(d)&&ie(I)){let Ft=me(d,m),Bo=me(I,y);Ft!==Bo&&(U=Bo)}let H=U?d:I,X=U?I:d,de=!!X&&oe(d,I),we=!!X&&(U?!!Ie[B+1]&&oe(Ie[B+1],I):!!ge[G+1]&&oe(d,ge[G+1])),Te=!!X&&!de&&!we&&(qe===0||J(d,I)),Ve=Te,Re=_(H,U?_t:an);if(Re==="straddle"&&(Ve=!0),!Ve&&H.be>H.bs&&(Ve=je(H,U?Se:re,U?y:m,U?ee:Pe)),!Ve&&de){xe(H.bs),Z.push({src:"both",lfrom:d.ss,rfrom:I.ss,len:H.text.length,owner:d.owner||I.owner||null,transfer:d.transferIn||I.transferIn||null}),ue=H.be,he+=H.text.length-(H.be-H.bs),ce+=H.text.length-(H.be-H.bs),B++,G++;continue}if(!Ve){xe(H.bs),Z.push({src:U?"local":"remote",from:H.ss,to:H.se,inherit:Re&&Re!=="straddle"?Re:null,owner:H.owner||null,transfer:H.transferIn||null}),ue=H.be,U?(he+=H.text.length-(H.be-H.bs),B++):(ce+=H.text.length-(H.be-H.bs),G++);continue}let Fe=H.bs,ht=H.be,lt=B,ft=G,Ut=Ft=>Ft.bs<ht&&Ft.be>Fe||ie(Ft)&&(Ft.bs===Fe||Ft.bs===ht);U?lt++:ft++,Te&&(Fe=Math.min(Fe,X.bs),ht=Math.max(ht,X.be),U?ft++:lt++);let Pt=!0;for(;Pt;){for(Pt=!1;lt<Ie.length&&Ut(Ie[lt]);)Fe=Math.min(Fe,Ie[lt].bs),ht=Math.max(ht,Ie[lt].be),lt++,Pt=!0;for(;ft<ge.length&&Ut(ge[ft]);)Fe=Math.min(Fe,ge[ft].bs),ht=Math.max(ht,ge[ft].be),ft++,Pt=!0}let dn=Fe+he,rn=Fe+ce,gn=ht-Fe,Tn=ht-Fe;for(let Ft=B;Ft<lt;Ft++)gn+=Ie[Ft].text.length-(Ie[Ft].be-Ie[Ft].bs);for(let Ft=G;Ft<ft;Ft++)Tn+=ge[Ft].text.length-(ge[Ft].be-ge[Ft].bs);let Pn=dn+gn,jn=rn+Tn;if(xe(Fe),B<lt&&G<ft&&!z&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!p.atoms.length&&!m.atoms.length&&!y.atoms.length&&!p.pins.length&&!m.pins.length&&!y.pins.length){Oe||={fb:p,fl:m,fr:y,ML:re,MR:Se,byEl:Ze,cache:[null,null]};let Ft=bi(Oe,Ie,B,lt,ge,G,ft,0,t),Bo=bi(Oe,ge,G,ft,Ie,B,lt,1,t);if(Ft===null!=(Bo===null)){let Cr=Ft!==null,Gs=Cr?Ft:Bo;if(Gs){He||=new Map;for(let Bl of Gs)He.set(Bl,Cr?"local":"remote")}Z.push(Cr?{src:"remote",from:rn,to:jn}:{src:"local",from:dn,to:Pn}),ue=ht,he+=gn-(ht-Fe),ce+=Tn-(ht-Fe),B=lt,G=ft;continue}}let Zt={kind:"text",node:e.node||null,base:ko(p,Fe,ht),local:ko(m,dn,Pn),remote:ko(y,rn,jn),resolved:null,range:null,bs:Fe,be:ht,lss:dn,lse:Pn,rss:rn,rse:jn},no=e.sourceRetentions?fi(e.sourceRetentions,e.scope?.base,p,m,y,t,Zt):t;Zt.resolved=no==="local"?Zt.local:no==="remote"?Zt.remote:Zt.local+Zt.remote,no!=="remote"&&Z.push({src:"local",from:dn,to:Pn,conflict:Zt}),no!=="local"&&Z.push({src:"remote",from:rn,to:jn,conflict:Zt});let oo={site:"inline",policy:no,fb:p,fl:m,fr:y,scope:e.scope||null,synthetic:!!e.synthetic,full:O,merged:f};u.push(oo),h(Zt,oo),ue=ht,he+=gn-(ht-Fe),ce+=Tn-(ht-Fe),B=lt,G=ft}xe(qe);let te=p.text,q=[];if(Me.respell.size||De.respell.size){let d=To(Ee),I=[];for(let U=0;U<Ee.length;U++){let H=Ee[U].raw,X=Me.respell.get(U)??H,de=De.respell.get(U)??H;(X!==H||de!==H)&&q.push([d[U],X!==H&&de!==H?"both":X!==H?"local":"remote"]),I.push(X===de?X:X===H?de:de===H||t==="local"?X:de)}te=I.join("")}let ae="",Ce=[],Le=[],We=[],Ne=[];for(let d of Z){let I=ae.length;if(d.src==="base"){for(let U=d.from;U<d.to;U++)Ce.push(U),Le.push(e.nativeTransfers?re.bTo[U]:U+d.dL),We.push(e.nativeTransfers?Se.bTo[U]:U+d.dR),Ne.push(d);ae+=te.slice(d.from,d.to)}else if(d.src==="both"){for(let U=0;U<d.len;U++){let H=d.transfer&&(d.transfer.side==="remote"?d.rfrom+U:d.lfrom+U);Ce.push(d.transfer&&H>=d.transfer.ss&&H<d.transfer.se?d.transfer.bs+H-d.transfer.ss:-1),Le.push(d.lfrom+U),We.push(d.rfrom+U),Ne.push(d)}ae+=m.text.slice(d.lfrom,d.lfrom+d.len)}else{let U=d.src==="local"?m:y,H=d.transfer&&e.nativeTransfers.byOrigin[d.src==="local"?"remote":"local"].get(d.transfer.key);for(let X=d.from;X<d.to;X++){let de=d.transfer&&X>=d.transfer.ss&&X<d.transfer.se?d.transfer.bs+X-d.transfer.ss:-1,we=de>=0&&(!H||H.destination===d.owner)?(d.src==="local"?Se:re).bTo[de]:-1;Ce.push(de),Le.push(d.src==="local"?X:we),We.push(d.src==="remote"?X:we),Ne.push(d)}ae+=U.text.slice(d.from,d.to)}d.ms=I,d.me=ae.length,d.conflict&&(d.conflict.range||(d.conflict.range=[I,I]),d.conflict.range[1]=ae.length)}let ze=ae.length,tt=new Int32Array(qe+1).fill(-1),k=new Int32Array(m.text.length+1).fill(-1),$=new Int32Array(y.text.length+1).fill(-1);for(let d=0;d<ze;d++)Ce[d]>=0&&(tt[Ce[d]]=d),Le[d]>=0&&(k[Le[d]]=d),We[d]>=0&&($[We[d]]=d);let Q=(d,I)=>{let U=-1,H=-1;for(let X=d.from;X<d.to;X++){let de=I[X];de>=0&&(U<0&&(U=de),H=de+1)}return U<0?null:[U,H]},be=[],fe=[];for(let d of new Set(Ze.values()))d.new==="local"?be.push(d):d.new==="remote"&&fe.push(d);let se=(d,I)=>{d.remote=I.remote,d.remoteMark=I.remoteMark,d.new="both",I.merged=d,Ze.set(I.remote,d)};if(be.length&&fe.length){let d=e.idOf;for(let I of be){let U=d?d.local(I.local):null;if(!U)continue;let H=fe.find(X=>!X.merged&&X.tag===I.tag&&!!X.block==!!I.block&&d.remote(X.remote)===U);H&&se(I,H)}for(let I of be){if(I.remote)continue;let U=Q(I.localMark,k);if(U)for(let H of fe){if(H.merged||H.tag!==I.tag||!!H.block!=!!I.block)continue;let X=Q(H.remoteMark,$);if(X&&Math.min(U[1],X[1])-Math.max(U[0],X[0])>0){se(I,H);break}}}}$t.clear();let le=d=>{for(let I of d)if(I.block)return gt(Ze.get(I.el));return null},Be=p.marks.some(d=>d.block)||m.marks.some(d=>d.block)||y.marks.some(d=>d.block),Ke=new Array(ze).fill(null),Ue=new Set;if(e.nativeTransfers)for(let d=0;d<ze;d++){let I=Ne[d].owner;Ke[d]=I?gt(Ze.get(I)):Ce[d]>=0?le(p.stackAt[Ce[d]]):null}else if(Be){let d=(Re,Fe,ht)=>{let lt=new Set([Re,Fe,ht]);lt.delete(null);let ft=[];for(let Pt of lt){let dn=Pt===Re,rn=Pt===Fe,gn=Pt===ht;(rn===gn?rn:rn===dn?gn:rn)&&ft.push(Pt)}if(ft.length<=1)return ft[0]||null;let Ut=t==="local"?Fe:ht;return ft.includes(Ut)?Ut:ft[0]},I=(Re,Fe)=>Fe>=0?le(Re.stackAt[Fe]):null,U=new Map;for(let Re=0;Re<ze;Re++){if(ae[Re]!==wt)continue;let Fe=Ce[Re]>=0?I(p,Ce[Re]):null,ht=I(m,Le[Re]),lt=I(y,We[Re]);U.set(Re,[Fe,Ce[Re]>=0?d(Fe,ht,lt):ht||lt])}let H=new Set([...U.values()].map(Re=>Re[1])),X=Re=>Re!==wt&&Re!==Bn&&!/\s/.test(Re),de=(Re,Fe)=>{let ht=Re;for(;ht<Fe&&!X(ae[ht]);)ht++;return ht<Fe&&Ce[ht]>=0?I(p,Ce[ht]):null},we=new Map,Te=0;for(let Re=0;Re<ze;Re++){if(ae[Re]!==wt)continue;let[Fe,ht]=U.get(Re),lt=de(Te,Re),ft=ht,Ut=we.get(ft)===ft&&lt===ft;ft&&we.has(ft)&&!Ut&&Fe&&!we.has(Fe)&&!H.has(Fe)&&(ft=Fe),ft&&!we.has(ft)&&we.set(ft,lt);for(let Pt=Te;Pt<=Re;Pt++)Ke[Pt]=ft;Te=Re+1}let Ve=Re=>{for(let Fe=0;Fe<Re.text.length;Fe++)if(X(Re.text[Fe])&&!I(Re,Fe))return!0;return!1};if(!Ve(p)&&!Ve(m)&&!Ve(y)){let Re=[],Fe=0;for(let lt=0;lt<ze;lt++)(ae[lt]===wt||lt===ze-1)&&(Re.push([Fe,lt]),Fe=lt+1);let ht=new Set(Ke);for(let lt=0;lt<Re.length;lt++){let[ft,Ut]=Re[lt];if(Ke[Ut])continue;let Pt=ft;for(;Pt<=Ut&&!X(ae[Pt]);)Pt++;if(Pt>Ut)continue;let dn=I(p,Ce[Pt]),rn=I(m,Le[Pt]),gn=I(y,We[Pt]),Tn=d(dn,rn,gn)||rn||gn||dn;if(Tn&&!ht.has(Tn)){ht.add(Tn);for(let Zt=ft;Zt<=Ut;Zt++)Ke[Zt]=Tn;continue}let Pn=lt>0&&Ke[Re[lt-1][1]],jn=lt+1<Re.length&&Ke[Re[lt+1][1]];if(Pn)Ue.add(Re[lt-1][1]);else if(jn&&ae[Ut]===wt)Ue.add(Ut);else continue;for(let Zt=ft;Zt<=Ut;Zt++)Ke[Zt]=Pn||jn}}}let $e=new Map,Ge=d=>{let I=$e.get(d);if(I)return I;I=[1/0,-1/0];for(let[U,H]of[[d.baseMark,tt],[d.localMark,k],[d.remoteMark,$]]){let X=U&&Q(U,H);X&&(I[0]=Math.min(I[0],X[0]),I[1]=Math.max(I[1],X[1]))}return $e.set(d,I),I},et=(d,I,U)=>{let H=-1,X=-1;for(let de=0;de<d.length;de++){let we=Ze.get(d[de].el);we===I&&(H=de),we===U&&(X=de)}return H>=0&&X>=0?H-X:0},Ot=(d,I)=>[...d].sort((U,H)=>{for(let we of I){let Te=et(we,U,H);if(Te)return Te}let X=Ge(U),de=Ge(H);return X[0]-de[0]||de[1]-X[1]||U.rank-H.rank||U.id-H.id}),xt=new Map,Jt=new Map,Mt=e.nativeTransfers?[]:null,pt=d=>{if(Mt)return Mt;let I=Ce[d],U=Le[d],H=We[d],X=Ne[d];if(I>=0){let lt=p.stackAt[I],ft=m.stackAt[U],Ut=y.stackAt[H],Pt=xt.get(lt);Pt||xt.set(lt,Pt=new Map);let dn=Pt.get(ft);dn||Pt.set(ft,dn=new Map);let rn=dn.get(Ut);if(rn)return rn;let gn=Ht(lt),Tn=Ht(ft),Pn=Ht(Ut),jn=new Set;for(let Zt of new Set([...gn,...Tn,...Pn])){let no=gn.has(Zt),oo=Tn.has(Zt),Ft=Pn.has(Zt);(oo===Ft?oo:oo===no?Ft:oo)&&jn.add(Zt)}return rn=Ot(jn,[ft,Ut,lt]),dn.set(Ut,rn),rn}if(X.src==="both"){let lt=m.stackAt[U],ft=y.stackAt[H];return Ot(new Set([...Ht(lt),...Ht(ft)]),[lt,ft])}let we=(X.src==="local"?m:y).stackAt[X.src==="local"?U:H];if(!X.inherit)return Ot(Ht(we),[we]);let Te=Jt.get(X);Te||Jt.set(X,Te=new Map);let Ve=Te.get(we);if(Ve)return Ve;let Re=new Set(Ht(we));for(let lt of X.inherit.added)Re.add(gt(lt));for(let lt of X.inherit.removed)Re.delete(gt(lt));let Fe=X.src==="local"?y:m,ht=(X.src==="local"?Se.bTo:re.bTo)[X.inherit.bs];return Ve=Ot(Re,[we,Fe.stackAt[ht]]),Te.set(we,Ve),Ve},bt=new Int32Array(m.text.length+1);bt[m.text.length]=ze;for(let d=m.text.length-1;d>=0;d--)bt[d]=k[d]>=0?k[d]:bt[d+1];Oc.caret+=m.text.length;let mt=d=>d<=0?0:(d>m.text.length&&(d=m.text.length),k[d-1]>=0?k[d-1]+1:bt[d]),It=[],ct=[],Wt=null,St=[],fn="",Gt=-1,Fn=d=>{Wt?Wt.appendChild(d):It.push(d)},Rn=d=>{if(!fn)return;let I=n.createTextNode(fn);Fn(I),ct.push({node:I,ms:Gt,me:d,local:[],u:St.length?St[St.length-1].u:null}),fn=""},cr=new Set,$n=new Map,jo=new Set,Ir=d=>{let I=n.createElement(d.tag);if(d.block&&Ct.add(I),!$n.has(d)){$n.set(d,I),N(d.base,d.local,d.remote,I),c.set(I,{base:d.base,local:d.local,remote:d.remote});let H=(we,Te)=>g&&d[Te]&&we.reverse.get(d[Te])?Te:null,X=!d.base&&(H(o,"local")||H(r,"remote"));if(X){let we=X==="local"?o.reverse.get(d.local):r.reverse.get(d.remote),Te=c.get(I);Te.local=Te.local||o.map.get(we)||null,Te.remote=Te.remote||r.map.get(we)||null,s.push({kind:"move",el:I,source:X}),e.moveBuilt?.(we,X,d[X],I)}else d.base||s.push({kind:"insert",el:I,source:d.local&&d.remote?"both":d.local?"local":"remote"});let de=c.get(I);de.local&&(jo.has(de.local)?de.local=null:jo.add(de.local))}else{let H=$n.get(d);for(let X of H.attributes)X.name!=="id"&&X.name!=="data-id"&&M(I,X,X.value);c.set(I,{base:null,local:null,remote:null})}Fn(I),St.push({u:d,el:I}),Wt=I},ye=new Set,Je=new Map;for(let d of m.pins){let I=mt(d.i);Je.has(I)||Je.set(I,[]),Je.get(I).push(d)}let Ye=d=>{let I=Je.get(d);if(I){Rn(d);for(let U of I){let H=U.el.namespaceURI&&U.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?n.createElementNS(U.el.namespaceURI,U.el.tagName):n.createElement(U.el.tagName);c.set(H,{base:null,local:U.el,remote:null,pinned:!0}),ye.add(H),Fn(H)}}},kt=p.atoms.length||m.atoms.length||y.atoms.length,Dt=d=>{if(!kt)return null;let I=Ce[d]>=0?p.atomAt.get(Ce[d]):null,U=Le[d]>=0?m.atomAt.get(Le[d]):null,H=We[d]>=0?y.atomAt.get(We[d]):null;return I||U||H?{ab:I,al:U,ar:H}:null},rt=(d,I,U)=>{let H=e.idOf;if(!H||!H.base)return!1;let X=H.base(d.el);return X!=null&&X===H[U](I.el)},At=(d,I,U,H,X)=>{if(!d||!g)return null;let de=R.get(I.reverse.get(d.el))||null;return!de||de===H||(H?de.el.isEqualNode(H.el)&&!rt(de,d,X):U.bTo[de.i]>=0)?null:de},Lt=(d,I)=>{if(!d||!g||!e.moveIn)return null;let U=I.reverse.get(d.el);return U&&!R.has(U)?U:null},at=(d,I)=>{let U=new Map;for(let H of d.atoms)U.set(I(H),(U.get(I(H))||0)+1);return U},Nt=at(p,C),sn=at(m,T),un=at(y,x),xn=d=>{let I=C(d);return Nt.get(I)===1&&(sn.get(I)||0)<=1&&(un.get(I)||0)<=1},mn=new Map,kn=new Set,Ln=new Set,ar=new Set,it=null;for(let d=0;d<ze;d++){let I=Dt(d);if(!I)continue;let{ab:U,al:H,ar:X}=I,de=At(X,r,Se,U,"remote"),we=At(H,o,re,U,"local"),Te=U,Ve=null;if(de?(Te=de,Ve="remote"):we&&(Te=we,Ve="local"),Te){U&&Te!==U&&(it||=new Map).set(U,Ve),kn.has(Te)?mn.set(d,{dup:Te.el}):(kn.add(Te),mn.set(d,{bk:Te,from:Ve,al:H,ar:X}));continue}let Re=Lt(X,r),Fe=Lt(H,o),ht=Re||Fe;if(ht){Ln.has(ht)?mn.set(d,{dup:ht}):(Ln.add(ht),mn.set(d,{moveIn:ht,side:Re?"remote":"local",sideEl:Re?X.el:H.el}));continue}let lt=(Ut,Pt)=>Ut&&g&&R.get(Pt.reverse.get(Ut.el))||null,ft=lt(X,r)||lt(H,o);if(ft&&(ar.add(ft),Ne[d].conflict&&(xn(ft)||X&&(X.el===ft.el||r.identityPaired?.has(ft.el))&&rt(ft,X,"remote")||H&&(H.el===ft.el||o.identityPaired?.has(ft.el))&&rt(ft,H,"local")))){if(kn.has(ft)){mn.set(d,{dup:ft.el});continue}kn.add(ft)}mn.set(d,{al:H,ar:X})}let nt=new Map,Rt,st,Et=(d,I)=>{if(d[I]>=0)return d[I];for(let U=I-1;U>=0;U--)if(d[U]>=0)return d[U]+1;return 0};if(g)for(let d of p.atoms){if(kn.has(d)||ar.has(d))continue;let I=o.map.get(d.el)||null,U=r.map.get(d.el)||null,H=I&&w.get(I),X=U&&K.get(U);if(I&&!H||U&&!X)continue;let de=!(H&&X)&&Ae.has(d);if(!de&&!(H&&X&&(xn(d)||it?.has(d)||(H.el===d.el||o.identityPaired?.has(d.el))&&(X.el===d.el||r.identityPaired?.has(d.el))&&rt(d,H,"local")&&rt(d,X,"remote"))))continue;let we=it?.get(d),Te=t;if(we){let lt=we==="local"?y:m,ft=we==="local"?r:o,Ut=we==="local"?st:Rt;if(Ut===void 0){Ut=lt.atoms.length===p.atoms.length;for(let Pt=0;Ut&&Pt<p.atoms.length;Pt++)Ut=ft.reverse.get(lt.atoms[Pt].el)===p.atoms[Pt].el;we==="local"?st=Ut:Rt=Ut}Ut&&(Te=we)}let Ve=Te==="local"?[[H,k],[X,$]]:[[X,$],[H,k]],[Re,Fe]=Ve.find(([lt])=>lt),ht=Et(Fe,Re.i);nt.has(ht)||nt.set(ht,[]),nt.get(ht).push({a:d,lt:I,rt:U,edited:de}),kn.add(d)}if(g&&e.moveIn){let d=[[m,o,k,"local"],[y,r,$,"remote"]];t!=="local"&&d.reverse();for(let[I,U,H,X]of d)for(let de of I.atoms){let we=Lt(de,U);if(!we||Ln.has(we))continue;Ln.add(we);let Te=Et(H,de.i);nt.has(Te)||nt.set(Te,[]),nt.get(Te).push({move:we,side:X,sideEl:de.el})}}let Yt=d=>{let I=nt.get(d);if(I){if(Rn(d),I.some(U=>_e(U.move?U.sideEl:U.a.el)))for(;St.length;)St.pop(),Wt=St.length?St[St.length-1].el:null;for(let{a:U,lt:H,rt:X,edited:de,move:we,side:Te,sideEl:Ve}of I){if(we){let Fe=e.moveIn(we,Te,Ve);Fe&&Fn(Fe);continue}cr.add(U);let Re=L(U.el,H,X);de&&(h({kind:"structure",el:Re,detail:"edit-beats-delete",base:U.el},{subject:U.el,deleted:H?"remote":"local"}),s.push({kind:"insert",el:Re,source:H?"local":"remote"})),Fn(Re)}}},Ct=new Set,tn=i.length>a;for(let d=0;d<ze;d++){let I=Dt(d),U=e.scopeUnits&&I&&(I.ab?.stack.some(we=>we.block)||I.al?.stack.some(we=>we.block)||I.ar?.stack.some(we=>we.block)),X=!!I&&_e((I.ab||I.al||I.ar).el)&&!U?[]:Ke[d]?[Ke[d],...pt(d)]:pt(d),de=0;for(;de<St.length&&de<X.length&&St[de].u===X[de];)de++;if(de<St.length)for(Rn(d);St.length>de;)St.pop(),Wt=St.length?St[St.length-1].el:null;if(Ye(d),Yt(d),X.length>St.length)for(Rn(d);St.length<X.length;)Ir(X[St.length]);if(ae[d]===wt){if(Ue.has(d))continue;Rn(d);let we=St.length;for(;we>0&&!St[we-1].u.block;)we--;if(we>0)for(tn&&f.breakOut.set(d,St[we-1].el);St.length>=we;)St.pop(),Wt=St.length?St[St.length-1].el:null;continue}if(I){Rn(d);let we=mn.get(d),Te;if(we.dup){h({kind:"structure",el:null,detail:"both-moved",base:we.dup},{subject:we.dup});continue}if(we.moveIn){if(Te=e.moveIn(we.moveIn,we.side,we.sideEl),!Te)continue}else if(we.bk){let Ve=we.bk;if(cr.add(Ve),Ve===I.ab)Te=L(Ve.el,we.al.el,we.ar.el);else{let Re=o.map.get(Ve.el)||null,Fe=r.map.get(Ve.el)||null;Te=L(Ve.el,Re,Fe),(!Re||!Fe)&&h({kind:"structure",el:null,detail:"move-beats-delete",base:Ve.el},{subject:Ve.el,deleted:Re?"remote":"local"}),s.push({kind:"move",el:Te,source:we.from})}}else we.al?(Te=j(we.al.el,"local"),we.ar&&(c.get(Te).remote=we.ar.el),s.push({kind:"insert",el:Te,source:we.ar?"both":"local"})):(Te=j(we.ar.el,"remote"),s.push({kind:"insert",el:Te,source:"remote"}));tn&&f.atomOut.set(d,Te),Fn(Te);continue}fn||(Gt=d),fn+=ae[d]}if(Rn(ze),(Je.has(ze)||nt.has(ze))&&(St.length=0,Wt=null,Ye(ze),Yt(ze)),ze===0&&(m.placeholder||y.placeholder||p.placeholder)){let d=n.createElement("br");c.set(d,{base:p.placeholder,local:m.placeholder,remote:y.placeholder}),It.push(d)}let Vt=0,vt=d=>{for(;Vt>0&&ct[Vt-1].me>=d;)Vt--;for(;Vt<ct.length&&ct[Vt].me<d;)Vt++;let I=ct[Vt];if(!I)return ct[ct.length-1]||null;let U=ct[Vt+1];return I.me===d&&U&&U.ms===d?U:I},Tt=new Map,Bt={},Qt=(d,I,U)=>{let H=vt(d)||(U?Bt:null);if(!H)return;let X=Tt.get(H)||{l:!1,r:!1};I!=="remote"&&(X.l=!0),I!=="local"&&(X.r=!0),Tt.set(H,X)},zn=d=>{if(d.conflict)return!0;let I=d.src==="local"?m.text:d.src==="remote"?y.text:"";for(let U=d.from;U<d.to;U++)if(I[U]!==Bn&&I[U]!==wt)return!0;return!1};for(let d of Z)d.src!=="base"&&Qt(d.ms,d.conflict?"both":d.src,zn(d));for(let[d,I]of q)tt[d]>=0&&Qt(tt[d],I);for(let d of ct.length?ct:[Bt]){let I=Tt.get(d);I&&s.push({kind:"text",node:d.node||null,source:I.l&&I.r?"both":I.l?"local":"remote"})}for(let d of Xe){if($n.has(d))continue;let I=!d.local&&!(g&&o.map.get(d.base)),U=!d.remote&&!(g&&r.map.get(d.base));!I&&!U||s.push({kind:"remove",source:I&&U?"both":I?"local":"remote",base:d.base})}if(He)for(let[d,I]of He)$n.has(d)&&h({kind:"structure",el:$n.get(d),detail:"edit-beats-delete",base:d.base},{subject:d.base,deleted:I});let Gn=(d,I,U)=>{if(I<=d)return!1;for(let H=d;H<I;H++)if(U[H]>=0)return!1;return!0};for(let d of Xe)for(let I of["local","remote"]){let U=d[I+"Mark"],H=d.baseMark;if(!U)continue;let X=I==="local"?re:Se;if(!Gn(H.from,H.to,X.bTo)||!Gn(U.from,U.to,X.toB))continue;let de=(I==="local"?Ie:ge).find(we=>we.ss<=U.from&&U.from<we.se);de&&(de.be<=H.from||de.bs>=H.to)&&s.push({kind:"move",el:$n.get(d)||null,source:I})}let Ll=d=>{let I=Ze.get(d.node.parentNode);return I?gt(I):null};for(let d of m.nodes){let I=-1;for(let H=d.s;H<d.e;H++)if(k[H]>=0){I=k[H];break}let U;if(I>=0)U=vt(I);else{let H=mt(d.s),X=Ll(d);U=ct.find(de=>de.u===X&&de.me>=H)||ct.filter(de=>de.u===X).pop()}U&&U.local.push(d)}let Do=new Map,Pl=ct[ct.length-1]||null,vn=0;for(let d of m.nodes){let I=null;for(let U=d.s;U<=d.e;U++){let H=mt(U);for(;vn>0&&ct[vn-1].me>=H;)vn--;for(;vn<ct.length&&ct[vn].me<H;)vn++;let X=we=>we&&H>=we.ms&&H<=we.me&&(H<we.me||U===d.e||we===I),de=X(ct[vn])?ct[vn]:X(ct[vn+1])?ct[vn+1]:ct[vn]||Pl;if(!de)break;if(I===de){let we=Do.get(de);we[we.length-1].to=U-d.s;continue}I=de,Do.has(de)||Do.set(de,[]),Do.get(de).push({node:d.node,from:U-d.s,to:U-d.s,flatStart:d.s})}}for(let d of ct){let I=d.local,U=!1;for(let we of I)for(let Te=we.s;Te<we.e&&!U;Te++)(k[Te]<d.ms||k[Te]>=d.me)&&(U=!0);c.set(d.node,{base:null,local:I.map(we=>we.node),remote:null,caret:Do.get(d)||[],partial:U});let H=d.ms,X=d.me-d.ms,de=we=>{let Te=0,Ve=-1;for(let Re of I){let Fe=Re.e-Re.s;if(we<=Te+Fe){Ve=Re.s+(we-Te);break}Te+=Fe}return Ve<0&&(Ve=I.length?I[I.length-1].e:0),Math.max(0,Math.min(mt(Ve)-H,X))};de.flat=we=>Math.max(0,Math.min(mt(we)-H,X)),l.set(d.node,de)}function jl(){if(!m.text.includes(wt))return[{flatLocal:m.text,localNodes:m.nodes,textNodes:ct,lToM:k,mapLocal:mt}];let d=[],I=0,U=0;for(let H=0;H<=m.text.length;H++){if(H<m.text.length&&m.text[H]!==wt)continue;let X=I,de=H;if(de>X){let we=[];for(;U<m.nodes.length&&m.nodes[U].e<=X;)U++;for(let Te=U;Te<m.nodes.length&&m.nodes[Te].s<de;Te++){let Ve=m.nodes[Te],Re=Math.max(Ve.s,X),Fe=Math.min(Ve.e,de);Re<Fe&&we.push({node:Ve.node,s:Re-X,e:Fe-X})}d.push({flatLocal:m.text.slice(X,de),localNodes:we,textNodes:ct,lToM:k.subarray?k.subarray(X,de+1):k.slice(X,de+1),mapLocal:Te=>mt(X+Math.max(0,Math.min(Te,de-X)))})}I=H+1}return d}let qs={...e,blocks:Ct,ignored:d=>ye.has(d)||(e.ignored?e.ignored(d):!1)},zs=e.ignoreAttribute||(()=>!1),Dl=ui(en(It,qs),zs)!==ui(y,zs);if(u.length){let d=I=>{let U=c.get(I);return U&&U.unchanged?U.remote:null};f.text=ae,f.textNodes=ct,f.out=en(It,{...qs,via:d})}let mo=null;if(e.scopeUnits){mo=new Map;let d=new Set(It),I=Te=>{for(;Te&&!d.has(Te);)Te=Te.parentNode;return Te},U=e.scopeUnits.map(Te=>{let Ve=new Map;for(let Re of Te)if(Re.nodeType===1)Ve.set(Re,Re);else for(let Fe of Re.nodes)Ve.set(Fe,Re);return Ve}),H=(Te,Ve)=>{for(;Te&&!Ve.has(Te);)Te=Te.parentNode;return Te?Ve.get(Te):null},X=[p,m,y].map((Te,Ve)=>{let Re=new Array(Te.text.length);for(let Fe of Te.nodes){let ht=H(Fe.node,U[Ve]);ht&&Re.fill(ht,Fe.s,Fe.e)}for(let Fe of Te.atoms)Re[Fe.i]=H(Fe.el,U[Ve]);return Re}),de=(Te,Ve)=>{if(!Te||!Ve)return;let Re=mo.get(Te);Re||mo.set(Te,Re=new Set),Re.add(Ve)};for(let Te of It){let Ve=c.get(Te);Ve&&(de(H(Ve.base,U[0]),Te),de(H(Ve.local,U[1]),Te),de(H(Ve.remote,U[2]),Te))}for(let Te of ct){let Ve=I(Te.node);for(let Re=Te.ms;Re<Te.me;Re++)de(X[0][Ce[Re]],Ve),de(X[1][Le[Re]],Ve),de(X[2][We[Re]],Ve)}let we=new Map(It.map((Te,Ve)=>[Te,Ve]));for(let[Te,Ve]of mo)mo.set(Te,Array.from(Ve).sort((Re,Fe)=>we.get(Re)-we.get(Fe)))}return{unitOutputs:mo,nodes:It,text:ae,textNodes:ct,localDiverged:Dl,mapLocal:mt,conflicts:i.slice(a),granularity:V?"line":"word",segments:jl(),localHunks:Ie,remoteHunks:ge,lToM:k}}function ki(e,n,t,o,r){if(!r(e.length*8+1))return null;let c=0,l=n===0,i=!1;for(let s of ln(e,o)){if(!r(1))return null;if(c+=s.len,c===n&&(l=!0),c===t&&(i=!0),c>=t)break}return l&&i}function Lc(e,n,t,o,r,c,l){if(!l(n.length*2))return!1;let i=new Map,s=new Map,a=new Set;for(let h of n){let f=h.bs<h.be,u=f?t[h.ownerIndex].text.base:t[h.ownerIndex].text[e],g=f?h.bs:h.ss,b=f?h.be:h.se;if(!l((b-g)*4+1))return!1;for(;g<b&&/\s/.test(u[g]);)g++;for(;b>g&&/\s/.test(u[b-1]);)b--;if(g===b)continue;let A=u.slice(g,b),p=f?i:s;f&&h.text&&a.add(A),p.has(A)?p.set(A,null):p.set(A,{h,from:g,to:b})}for(let h of o){if(!l(1))return!1;if(h.side!==e)continue;let f=h.deletion,u=t[f.ownerIndex].text.base;if(!l((f.be-f.bs)*3)||a.has(u.slice(f.bs,f.be).trim()))return!1}for(let[h,f]of i){if(!l(h.length+1))return!1;let u=s.get(h);if(!f||!u)continue;let g=f.h,b=u.h;if(!g.text||g.transferOut||b.transferIn||g.owner===b.owner)continue;let A=t[g.ownerIndex],p=t[b.ownerIndex];if(!l(A.text.base.length))return!1;if(!/\S/.test(A.text.base.slice(0,g.bs)+A.text.base.slice(g.be)))continue;let m=ki(A.text.base,f.from,f.to,c,l),y=ki(p.text[e],u.from,u.to,c,l);if(m===null||y===null)return!1;if(!m||!y)continue;let R=`${A.index}:${f.from}:${f.to}`,S={key:R,side:e,source:g.owner,destination:b.owner,deletion:g,insertion:b,sourceOffset:f.from-g.bs,targetOffset:u.from-b.ss,length:f.to-f.from};g.transferOut=S,b.transferIn=S,r[e].set(R,S),o.push(S)}return!0}function Ti({base:e,local:n,remote:t,localTwin:o,remoteTwin:r,eligible:c,nodes:l,budget:i=Kt(2e4*32)}){let s=N=>N>i.remaining?!1:(i.remaining-=N,i.nativeSteps=(i.nativeSteps||0)+N,!0);if(e.length<2||n.length!==e.length||t.length!==e.length||!s(e.length*12))return null;for(let[N,L]of[["base",e],["local",n],["remote",t]]){let j=l[N];if(j.length!==L.length||j.some((F,W)=>F!==L[W]))return null}let a=[],h=0;for(let N=0;N<e.length;N++){let L=e[N],j=n[N],F=t[N];if(o(L)!==j||r(L)!==F)return null;let W={};for(let[C,T]of[["base",L],["local",j],["remote",F]]){if(!c(T)||T.tagName!==L.tagName||T.namespaceURI!==L.namespaceURI||!s(T.childNodes.length+1))return null;let x="";for(let z of T.childNodes){if(z.nodeType!==3||!s(z.data.length*4+1))return null;x+=z.data}if(x.includes(wt)||(h+=x.length+1,h>2e4))return null;W[C]=x}a.push({base:L,local:j,remote:F,index:N,text:W})}let f=a.every(N=>yn(N.text.base,N.text.local,N.text.remote)),u={local:[],remote:[]};for(let N of a){N.hunks={local:[],remote:[]};for(let L of["local","remote"]){let j=N.text.base,F=N.text[L];if(j===F)continue;let W=j.length+F.length+4,C=W*8;if(!s(C))return null;let T=Math.floor(i.remaining/8),x=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(W*W+T)-W)/2)));if(x<1||!s(4*(x+1)*(W+x+1)))return null;let z=0;for(let D of ro(j,F,x)){if(!s(D.text.length+1))return null;let V=D.bs+z,Ee={...D,ss:V,se:V+D.text.length,toks:ln(D.text,f),owner:N.base,ownerIndex:N.index};N.hunks[L].push(Ee),u[L].push(Ee),z+=D.text.length-(D.be-D.bs)}}}let g=[],b={local:new Map,remote:new Map};for(let N of["local","remote"]){let L=new Map,j=new Map,F=!1,W=(C,T,x)=>{C.has(T)?C.set(T,null):C.set(T,x)};for(let C of u[N]){if(!s(1))return null;let T=a[C.ownerIndex].text.base;if(C.bs<C.be&&C.text===""){let x=T.slice(C.bs,C.be);if(!s(x.length*2))return null;/\S/.test(x)&&W(L,x,C)}else if(C.bs===C.be&&/\S/.test(C.text)){if(!s(C.text.length*2))return null;W(j,C.text,C)}else C.bs<C.be&&(F=!0)}for(let[C,T]of L){if(!s(C.length+1))return null;let x=j.get(C);if(!T||!x||T.owner===x.owner)continue;let z=a[T.ownerIndex];if(!s(z.text.base.length))return null;if(!/\S/.test(z.text.base.slice(0,T.bs)+z.text.base.slice(T.be)))continue;let D=`${z.index}:${T.bs}:${T.be}`,V={key:D,side:N,source:T.owner,destination:x.owner,deletion:T,insertion:x};T.transferOut=V,x.transferIn=V,b[N].set(D,V),g.push(V)}if(F&&j.size&&!Lc(N,u[N],a,g,b,f,s))return null}if(!g.length)return null;let A=(N,L)=>N.bs<L.be&&L.bs<N.be,p=N=>N.bs===N.be,m=(N,L)=>N.bs<=L.be&&L.bs<=N.be&&p(N)!==p(L),y=(N,L)=>N.bs===L.bs&&N.be===L.be&&N.text===L.text,R=(N,L)=>!!(N.transferIn||N.transferOut&&(!N.text||L.bs===N.be&&/\s/.test(L.text[0])||L.bs===N.bs&&/\s/.test(L.text[L.text.length-1])));for(let N of g){let L=N.side==="local"?"remote":"local",j=a[N.deletion.ownerIndex];for(let F of j.hunks[L])if(!s(1)||A(N.deletion,F)&&F.transferOut?.key!==N.key)return null}for(let N of a)for(let L of N.hunks.local)for(let j of N.hunks.remote){if(!s(1))return null;if(y(L,j)){if(L.transferIn?.key!==j.transferIn?.key)return null;continue}if(A(L,j)||m(L,j)&&!R(L,j)&&!R(j,L))return null}if(!s(h*8))return null;let S=new Set([...e,...n,...t]),O={base:en(e,{blocks:S}),local:en(n,{blocks:S}),remote:en(t,{blocks:S})},M={};for(let N of["base","local","remote"]){let L=O[N];if(L.atoms.length||L.pins.length)return null;M[N]=new Map(L.marks.filter(j=>j.block).map(j=>[j.el,j.from]))}for(let N of a){let L=M.base.get(N.base);if(L===void 0)return null;for(let j of["local","remote"]){let F=M[j].get(N[j]);if(F===void 0)return null;for(let W of N.hunks[j])W.bs+=L,W.be+=L,W.ss+=F,W.se+=F}}for(let N of g)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 L=0,j=0,F=[];for(let C of u[N]){if(!s(1))return null;C.bs>L&&F.push({from:L,to:C.bs,target:j}),L=C.be,j=C.se}L<O.base.text.length&&F.push({from:L,to:O.base.text.length,target:j});let W=g.filter(C=>C.side===N).map(C=>({from:C.bs,to:C.be,target:C.ss,destination:C.destination}));if(E[N]=Dn({base:O.base,side:O[N],retained:F,transfers:W,budget:i}),E[N].status!=="ready")return null}return s(O.base.text.length)?{owners:a,blocks:S,transfers:g,byOrigin:b,budget:i,prepared:{base:O.base,local:O.local,remote:O.remote,lines:!1,baseTokens:ln(O.base.text,f),localEdits:{hunks:u.local,respell:new Map},remoteEdits:{hunks:u.remote,respell:new Map},localMap:E.local,remoteMap:E.remote,full:null}}:null}var os=/\S/;function Ai({certificates:e,scopes:n,views:t,eligible:o,baseId:r,limit:c=2e4*32}){let l=Kt(c),i=Symbol(),s=[],a=f=>{if(f>l.remaining)throw i;l.remaining-=f},h=(f,u=null)=>{if(a(1),!f||f.nodeType!==1||f.parentNode?.nodeType!==1||!o(f))return null;for(let A=f.parentNode;A;A=A.parentNode)if(a(1),A.nodeType===11)return null;let g="",b=0;for(let A of f.childNodes){if(a(1),A.nodeType!==3)return null;if(a(A.data.length*4+1),u){let p=u.flat.nodes[b++];if(!p||p.node!==A||p.s!==g.length||p.e!==g.length+A.data.length)return null}g+=A.data}return a(g.length*3+1),u&&(u.flat.atoms.length||u.flat.pins?.length||b!==u.flat.nodes.length||u.flat.text!==g)?null:os.test(g)?g:null};try{a(n[0].length+n[1].length+n[2].length+e.length);let f=n.map(g=>new Set(g)),u=new Map;for(let g of e){a(1);let b=u.get(g.source);b||u.set(g.source,b=[]),b.push(g)}for(let g of u.values()){let b=[null,null],A=[];for(let p of g){a(1);let{source:m,target:y,side:R,models:S,runs:O}=p;if(R!==0&&R!==1||!f[0].has(m)||!f[R+1].has(y))continue;let{V:M,A:E,idOf:N}=t[R],L=t[1-R],j=M.twin(m),F=L.V.twin(m),W=M.baseOf(y);if(!j||!F||!W||W===m||!f[0].has(W)||!f[R+1].has(j)||!f[2-R].has(F)||E.map.get(m)!==j||E.reverse.get(j)!==m||L.A.map.get(m)!==F||L.A.reverse.get(F)!==m||E.map.get(W)!==y||E.reverse.get(y)!==W||y.parentNode!==j.parentNode||W.parentNode!==m.parentNode||m.tagName!==j.tagName||m.tagName!==F.tagName||r(m)!==N(j)||r(m)!==L.idOf(F)||r(W)!==N(y))continue;let C=S.get(m),T=S.get(y);if(!C||!T)continue;let x=h(m,C),z=h(y,T),D=h(j),V=h(F);if(a((x?.length||0)+(V?.length||0)),x===null||z===null||D===null||V===null||V===x)continue;let Ee=O.length>0,Me=!1;for(let re of O){if(a(1),re.source!==m||re.target!==y||!Number.isInteger(re.from)||!Number.isInteger(re.to)||!Number.isInteger(re.targetFrom)||re.from<0||re.to<=re.from||re.to>x.length||re.targetFrom<0||re.targetFrom+re.to-re.from>z.length){Ee=!1;break}a((re.to-re.from)*3);for(let Se=re.from;Se<re.to;Se++){if(x[Se]!==z[re.targetFrom+Se-re.from]){Ee=!1;break}os.test(x[Se])&&(Me=!0)}if(!Ee)break}if(!Ee||!Me)continue;let De=b[R];De||(a(x.length),De=b[R]={source:m,side:R,flat:C.flat,before:x,covered:new Uint8Array(x.length)});for(let re of O)a(re.to-re.from),De.covered.fill(1,re.from,re.to)}for(let p of b){if(!p)continue;let{source:m,side:y,flat:R,before:S,covered:O}=p;a(S.length*3+1);let M=-1,E=-1;for(let N=0;N<=S.length;N++)N<S.length&&O[N]?(M<0&&(M=N),E=N+1):(N===S.length||os.test(S[N]))&&M>=0&&(A.push({source:m,side:y,flat:R,from:M,to:E}),M=E=-1)}a(A.length),s.push(...A)}}catch(f){if(f!==i)throw f}return{records:s,budget:l}}var Pc="http://www.w3.org/1999/xhtml";function jc(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n^e.charCodeAt(t);return(n>>>0).toString(36)}function hn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Pc}function Dc(e){let n=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return n==="application/json"||n.endsWith("+json")}function kr(e,n){let t=e.getAttribute("src"),o=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(t){let r=t;try{let c=new URL(t,n);r=c.origin+c.pathname+c.search}catch{}return"script|src|"+o+"|"+r}return"script|inline|"+o+"|"+jc(e.textContent.trim())}var Bc={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function So(e,n=[],t=!1){if(!hn(e)||e.hasAttribute("src"))return null;let o=[Bc,...n];for(let r=0;r<o.length;r++){let c=o[r];if(!c.match(e))continue;if(!Dc(e))return t&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let l=c.identity(e);return l==null||l===""?null:{key:r+":"+l,raw:l,recognizer:c}}return null}function Si(e,n,t){let o=new Set,r=c=>{hn(c)&&!n(c)&&o.add(kr(c,t))};r(e);for(let c of e.querySelectorAll("script"))r(c);return o}function Vo(e,n){let t=n.createElement("div");t.innerHTML="<script><\/script>";let o=t.firstChild;for(let r of e.attributes)o.setAttribute(r.name,r.value);return o.textContent=e.textContent,o}function Ni(e,n,t){let o=[],r=[],c=new Map,l=t.trackRecovery?new Set:null,i=Array.from(e.querySelectorAll("script"));hn(e)&&i.unshift(e);for(let s of i){if(!hn(s)||t.ignored(s)||t.skip.has(s)||n.has(kr(s,t.baseURI)))continue;let a=s.ownerDocument.createElement("script");for(let h of s.attributes)a.setAttribute(h.name,h.value);if(a.textContent=s.textContent,t.beforeNodeAdded(a)===!1){l?.add(s);continue}a.hasAttribute("src")&&r.push(new Promise(h=>{a.addEventListener("load",()=>h()),a.addEventListener("error",()=>h())})),s.replaceWith(a),c.set(s,a),t.afterNodeAdded(a),o.push(a)}return{executed:o,loads:r,swapped:c,vetoed:l}}function Uc(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n^e.charCodeAt(t);return(n>>>0).toString(36)}function Hc(e,n){try{let t=new URL(e,n);return t.origin+t.pathname+t.search}catch{return e}}function vi(e,n){let t=e.tagName;if(t==="TITLE"||t==="BASE")return t;if(t==="SCRIPT")return kr(e,n);if(t==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+Hc(o,n):e.outerHTML}if(t==="META"){for(let o of["charset","name","property","http-equiv","itemprop"])if(e.hasAttribute(o))return"meta|"+o+"="+e.getAttribute(o);return e.outerHTML}return t==="STYLE"?"style|"+Uc(e.textContent):e.outerHTML}function rs(e,n){for(;;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(e[n]==="/"&&e[n+1]==="/"){for(;n<e.length&&e[n]!==`
5
+ `;)n++;continue}if(e[n]==="/"&&e[n+1]==="*"){let t=e.indexOf("*/",n+2);if(t===-1)return e.length;n=t+2;continue}return n}}function Wc(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(n,t)=>t.length%2===0?t+'\\"':n)}var Vc=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,_c=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ss(e){try{return JSON.parse(e)}catch{return JSON.parse(Fc(e))}}function Fc(e){let n="",t=0,o=(r,c)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${c}`)};for(;t<e.length&&(t=rs(e,t),!(t>=e.length));){let r=e[t];if("{}[]:".includes(r)){n+=r,t++;continue}if(r===","){let i=rs(e,t+1);if(e[i]==="}"||e[i]==="]"){t++;continue}n+=r,t++;continue}if(r==='"'||r==="'"){let i=t+1;for(;i<e.length&&e[i]!==r;)e[i]==="\\"&&i++,i++;i>=e.length&&o("unterminated string",t);let s=e.slice(t+1,i);r==="'"&&(s=Wc(s)),n+='"'+s+'"',t=i+1;continue}let c=t;for(;c<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[c]);)c++;c===t&&o("unexpected character "+JSON.stringify(r),t);let l=e.slice(t,c);if(l==="true"||l==="false"||l==="null"||Vc.test(l)){n+=l,t=c;continue}if(_c.test(l)){if(e[rs(e,c)]===":"){n+='"'+l+'"',t=c;continue}o("unquoted value "+JSON.stringify(l),t)}o("invalid token "+JSON.stringify(l),t)}return n}var Xt=Symbol("hyper-morph-json-merge:missing"),Oi=["id","_id","uuid","key","slug","code","name"];function No(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _o(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function $c(e,n,t){Object.defineProperty(e,n,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Qn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!Qn(e[t],n[t]))return!1;return!0}if(No(e)&&No(n)){let t=Object.keys(e);if(t.length!==Object.keys(n).length)return!1;for(let o of t)if(!_o(n,o)||!Qn(e[o],n[o]))return!1;return!0}return!1}function Mi(e,n,t,o){return Qn(n,t)?n:Qn(n,e)?t:Qn(t,e)?n:No(n)&&No(t)?Kc(No(e)?e:{},n,t,o):Array.isArray(n)&&Array.isArray(t)?Yc(Array.isArray(e)?e:[],n,t,o):t}function Ei(e,n,t,o){return n===Xt&&t===Xt?Xt:n===Xt?e===Xt?t:Qn(t,e)?Xt:t:t===Xt?e===Xt?n:Xt:Mi(e,n,t,o)}function Kc(e,n,t,o){let r={},c=new Set([...Object.keys(e),...Object.keys(n),...Object.keys(t)]);for(let l of c){let i=Ei(_o(e,l)?e[l]:Xt,_o(n,l)?n[l]:Xt,_o(t,l)?t[l]:Xt,o);i!==Xt&&$c(r,l,i)}return r}function qc(e){return e===null||typeof e!="object"}function Tr(e){return typeof e+":"+String(e)}function zc(e,n){for(let t of n){let o=new Set;for(let r of t){if(!_o(r,e))return!1;let c=r[e];if(typeof c!="string"&&typeof c!="number")return!1;let l=Tr(c);if(o.has(l))return!1;o.add(l)}}return!0}function Gc(e,n,t,o){let r=[e,n,t],c=!0;for(let l of r)for(let i of l)No(i)||(c=!1);if(c){for(let l of o.keyCandidates)if(zc(l,r))return{kind:"keyed",field:l};return null}for(let l of r){let i=new Set;for(let s of l){if(!qc(s))return null;let a=Tr(s);if(i.has(a))return null;i.add(a)}}return{kind:"self"}}function Yc(e,n,t,o){let r=Gc(e,n,t,o);if(!r)return t;let c=r.kind==="self"?Tr:g=>Tr(g[r.field]),l=g=>{let b=new Map;for(let A of g)b.set(c(A),A);return b},i=l(e),s=l(n),a=l(t),h=new Map,f=new Set([...i.keys(),...s.keys(),...a.keys()]);for(let g of f){let b=Ei(i.has(g)?i.get(g):Xt,s.has(g)?s.get(g):Xt,a.has(g)?a.get(g):Xt,o);b!==Xt&&h.set(g,b)}let u=[];for(let g of t){let b=c(g);h.has(b)&&u.push(b)}for(let g=0;g<n.length;g++){let b=c(n[g]);if(!h.has(b)||u.includes(b))continue;let A=0;for(let p=g-1;p>=0;p--){let m=u.indexOf(c(n[p]));if(m!==-1){A=m+1;break}}u.splice(A,0,b)}return u.map(g=>h.get(g))}function Ii(e,n,t,o={}){let r=o.keyCandidates?[...o.keyCandidates,...Oi]:Oi;return Mi(e===void 0?Xt:e,n,t,{keyCandidates:r})}function is(e,n,t,o={}){let r=o.parse||ss,c=[],l=(f,u)=>{if(typeof f!="string")return Xt;try{return r(f)}catch(g){return c.push(`${u} side is not valid JSON (${g.message})`),Xt}},i=l(n,"local"),s=l(t,"remote");if(i===Xt)return{text:t,warnings:c};if(s===Xt)return{text:n,warnings:c};let a=l(e,"base"),h=Ii(a===Xt?void 0:a,i,s,o);return Qn(h,s)?{text:t,warnings:c}:Qn(h,i)?{text:n,warnings:c}:{text:JSON.stringify(h,null,2),warnings:c}}var Ci=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function lo(e){if(!e)return!1;let{startContainer:n,startOffset:t,endContainer:o,endOffset:r}=e;if(!n||!o||!Number.isInteger(t)||!Number.isInteger(r)||t<0||r<0||t>Ci(n)||r>Ci(o)||n.getRootNode()!==o.getRootNode())return!1;let c=n.ownerDocument.createRange();return c.setStart(n,t),c.setEnd(o,r),c.startContainer===n&&c.startOffset===t}function Zn(e,n,t={}){if(!lo(e))return null;let{startContainer:o,startOffset:r,endContainer:c,endOffset:l}=e;if(o===c&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,l);if(o===c&&r===l)return"";let i=new Set;for(let p=o;p;p=p.parentNode)i.add(p);let s=c;for(;!i.has(s);)s=s.parentNode;let a=(p,m)=>{let y=s.ownerDocument.createRange(),R=s.ownerDocument.createRange();return y.setStart(p[0],p[1]),y.collapse(!0),R.setStart(m[0],m[1]),R.collapse(!0),y.compareBoundaryPoints(0,R)},h=(p,m=!1)=>[p.parentNode,Array.prototype.indexOf.call(p.parentNode.childNodes,p)+Number(m)],f=[],u;if(n==="plain"){u="";let p=m=>{if(m.nodeType===3||m.nodeType===8){let y=u.length;u+=m.nodeValue,f.push({s:y,e:u.length,a:[m,0],b:[m,m.nodeValue.length],node:m})}else for(let y of m.childNodes)p(y)};p(s)}else{let p=t.blocks;if(!p){p=new Set;let y=R=>{R!==s&&R.nodeType===1&&ts.has(R.tagName)&&p.add(R);for(let S of R.childNodes)y(S)};y(s)}let m=en(Array.from(s.childNodes),{blocks:p,atomize:y=>!!t.atoms?.has(y),ignored:t.ignored});u=m.text;for(let y of m.nodes)f.push({s:y.s,e:y.e,a:[y.node,0],b:[y.node,y.e-y.s],node:y.node});for(let y of m.atoms)f.push({s:y.i,e:y.i+1,a:h(y.el),b:h(y.el,!0)});for(let y=0;y<m.text.length;y++){if(m.text[y]!==wt)continue;let R=m.marks.find(O=>O.block&&O.to===y+1),S=m.marks.find(O=>O.block&&O.from===y+1);if(R)f.push({s:y,e:y+1,a:[R.el,R.el.childNodes.length],b:h(R.el,!0)});else if(S)f.push({s:y,e:y+1,a:h(S.el),b:[S.el,0]});else return null}}f.sort((p,m)=>p.s-m.s);let g=p=>{if(p[0].nodeType===3||p[0].nodeType===8){let y=f.find(R=>R.node===p[0]);return y?y.s+p[1]:null}let m=0;for(let y of f){if(a(p,y.a)<=0)return y.s;if(a(p,y.b)<0)return null;m=y.e}return m},b=g([o,r]),A=g([c,l]);return b!==null&&A!==null&&b<=A?u.slice(b,A):null}function io(e,n){let t=e;for(let o of n.path)if(t=o==="content"?t?.content:t?.childNodes[o],!t)return null;return[t,n.offset]}function Ri(e,n){if(!e||!n)return null;let t=io(e,n.start),o=io(e,n.end);return t&&o?{startContainer:t[0],startOffset:t[1],endContainer:o[0],endOffset:o[1]}:null}var Li=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function Pi(e,n,t){if(!n)return;let o=new Map,r=new Map,c=i=>{if(!i)return null;if(r.has(i))return r.get(i);let a=i.local.map(h=>io(n.localRoot,{path:h,offset:0})?.[0]).map(h=>h&&t(h)).filter(Boolean).map(h=>({node:h,parent:h.parentNode,previous:h.previousSibling,next:h.nextSibling,fragment:Li(h)}));return r.set(i,a),a},l=i=>{let s=Ri(n.localRoot,i);if(!s)return null;let a=t(s.startContainer),h=t(s.endContainer);if(!a||!h)return null;let f={...s,startContainer:a,endContainer:h};return lo(f)?f:null};for(let i of e){let s=i.recovery;if(!s||o.has(s))continue;let a={subject:c(s.subject),span:null,scope:null,touched:new Set};if(s.text){a.span=l(s.text.local.span),a.scope=l(s.text.local.scope);let h=a.span;if(h){let f=h.startContainer.ownerDocument.createRange();f.setStart(h.startContainer,h.startOffset),f.setEnd(h.endContainer,h.endOffset);let u=g=>{if(f.intersectsNode(g)){a.touched.add(g);for(let b of g.childNodes)u(b)}};u(f.commonAncestorContainer)}}if(s.structure){for(let h of[s.structure.localPlacement])h&&(c(h.parent),h.before.forEach(c),h.after.forEach(c));for(let h of s.structure.localOrder||[])c(h)}o.set(s,a)}n.localState={states:o,refs:r}}function ji(e,n,t,o){let r=t.localState?.states.get(e);if(!r)return!1;let c=i=>{let s=i.node;if(!o(s)||s.parentNode!==i.parent)return!1;let a=h=>Array.prototype.indexOf.call(s.parentNode.childNodes,h);return!(i.previous&&o(i.previous)&&i.previous.parentNode===s.parentNode&&a(i.previous)>=a(s)||i.next&&o(i.next)&&i.next.parentNode===s.parentNode&&a(i.next)<=a(s))};if(e.structure?.localAction==="deleted")return e.subject.live.length===0;if(!r.subject.length||!r.subject.every(c))return!1;if(e.text){let i=e.text.local,s=a=>a&&o(a.startContainer)&&o(a.endContainer);return s(r.span)&&s(r.scope)&&Zn(r.scope,e.text.encoding)===i.text&&Zn(r.span,e.text.encoding)===i.text.slice(i.start,i.end)}if(e.attribute){let i=e.attribute,s=r.subject[0].node;return(i.namespaceURI?s.getAttributeNS(i.namespaceURI,i.localName):s.getAttribute(i.qualifiedName))===n.local}let l=e.structure;if(l.localOrder){let i=-1,s=null;for(let a of l.localOrder){let h=t.localState.refs.get(a)?.[0]?.node;if(!h||!o(h)||s&&h.parentNode!==s)return!1;let f=Array.prototype.indexOf.call(h.parentNode.childNodes,h);if(f<=i)return!1;s=h.parentNode,i=f}return!0}return l.localAction==="moved"||r.subject.every(i=>Li(i.node)===i.fragment)}var Xc=1,cn=e=>!!e&&e.nodeType===1,Ar=e=>cn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function co(e,n=null,t=null){let o=new Map,r=new Map,c=h=>{if(!n){n=new WeakMap;let f=[e];for(;f.length;){let u=f.pop();Ar(u)&&(n.set(u.content,u),f.push(u.content));for(let g=u.firstChild;g;g=g.nextSibling)g.nodeType===1&&f.push(g)}}return n.get(h)||null},l=(h,f)=>{let u=r.get(h);if(!u){u=new Map;let g=0;for(let b=h.firstChild;b;b=b.nextSibling)u.set(b,g++);r.set(h,u)}return u.get(f)},i=h=>{if(!h)return null;if(t&&t.has(h))return i(t.get(h));if(h===e)return[];let f=o.get(h);if(f!==void 0)return f;let u=h.parentNode,g=null;if(u&&u.nodeType===11){let b=c(u),A=b?i(b):null;A&&(g=A.concat(["content",l(u,h)]))}else if(u){let b=i(u);b&&(g=b.concat([l(u,h)]))}return o.set(h,g),g};return{root:e,pathOf:i,logicalParent:h=>{let f=h.parentNode;return f&&f.nodeType===11?c(f):f},indexIn:l,containerPath:h=>{if(h.nodeType===11){let u=c(h),g=i(u);return g?g.concat(["content"]):null}let f=i(h);return f&&Ar(h)?f.concat(["content"]):f},ownerOf:c}}var En=e=>Ar(e)?e.content:e;function Di(e){let{L:n,R:t,unitsOf:o,provenance:r,policy:c}=e,l=[];return{note:(h,f)=>{l.push([h,f])},finish:h=>l.length?a(h):null};function a(h){let f={base:co(e.roots.base),local:co(e.roots.local),remote:co(e.roots.remote)},u=v=>v==="local"?n:t,g=(v,P)=>{if(!P)return null;if(v.map.has(P))return v.map.get(P);let Y=[],J=cn(P)?f.base.logicalParent(P):P.parent;for(;J&&!v.map.has(J);J=f.base.logicalParent(J))Y.push(J);if(!J||!v.identical.has(J))return null;let oe=v.map.get(J);for(let je=Y.length-1;je>=0&&oe;je--)oe=En(oe).childNodes[f.base.indexIn(Y[je].parentNode,Y[je])];return oe?cn(P)?En(oe).childNodes[f.base.indexIn(P.parentNode,P)]||null:o(oe)[o(P.parent).indexOf(P)]||null:null},b=new Map,A=new Map,p=new WeakMap,m=0,y=(v,P)=>{let Y=b.get(v);Y||b.set(v,Y=[]),Y.push(P)};(function v(P){A.set(P,m++);let Y=r.get(P);if(Y&&!Y.pinned){for(let J of[Y.base,Y.local,Y.remote])if(J)if(Array.isArray(J))for(let oe of J)y(oe,P);else y(J,P)}if(Ar(P)){p.set(P.content,P);for(let J=P.content.firstChild;J;J=J.nextSibling)v(J)}for(let J=P.firstChild;J;J=J.nextSibling)v(J)})(h);let R=new Map;f.out=co(h,p,R);let S={refs:new Map,spans:new Map,anchors:new Map,via:R,outOwners:p,outRoot:h,localRoot:e.roots.local},O=v=>cn(v)?[v]:v.nodes,M=(v,P)=>{let Y=f[P].logicalParent(v);if(!Y)return null;for(let J of o(Y))if(!cn(J)&&J.nodes.includes(v))return J;return null},E=(v,P)=>v==null?null:Array.isArray(v)?v.length?M(v[0],P):null:v,N=v=>{let P=new Set,Y=[];for(let J of v)for(let oe of b.get(J)||[])P.has(oe)||(P.add(oe),Y.push(oe));return Y.sort((J,oe)=>A.get(J)-A.get(oe))},L=new Map,j=v=>{let P=v.b||v.l||v.r,Y=L.get(P);if(Y)return Y;let J=[];for(let oe of[v.b,v.l,v.r])oe&&J.push(...O(oe));return Y=N(J),L.set(P,Y),Y},F=v=>({b:v,l:g(n,v),r:g(t,v)}),W=(v,P)=>{let Y=u(P).reverse.get(v);if(Y)return F(Y);for(let J of N(O(v))){let oe=r.get(J);if(oe&&!oe.base&&oe.local&&oe.remote)return{b:null,l:E(oe.local,"local"),r:E(oe.remote,"remote")}}return P==="local"?{b:null,l:v,r:null}:{b:null,l:null,r:v}},C=new Map,T=v=>{let P=r.get(v);if(!P||P.pinned)return null;let Y=E(P.base,"base");if(Y)return F(Y);let J=E(P.local,"local"),oe=E(P.remote,"remote");if(J){let je=n.reverse.get(J);if(je)return F(je)}if(oe){let je=t.reverse.get(oe);if(je)return F(je)}return J||oe?{b:null,l:J,r:oe}:null},x=v=>(C.has(v)||C.set(v,T(v)),C.get(v)),z=(v,P)=>cn(v)?f[P].logicalParent(v):v.parent,D=new Map,V=new Map,Ee=(v,P)=>(cn(v)?[f[P].pathOf(v)]:v.nodes.map(Y=>f[P].pathOf(Y))).filter(Boolean),Me=v=>{let P=v.b||v.l||v.r,Y=v.b?"base":v.l?"local":"remote",J=V.get(P);if(J)return J;let oe=!cn(P),je=Ee(P,Y)[0],Z=`${Y[0]}:${JSON.stringify(je===void 0?null:je)}${oe?":run":""}`,Oe=D.get(Z);if(Oe)return V.set(P,Oe),Oe;let He=j(v);return Oe={key:Z,nodeType:cn(P)?1:P.kind==="comment"?8:3,base:v.b?Ee(v.b,"base"):[],local:v.l?Ee(v.l,"local"):[],remote:v.r?Ee(v.r,"remote"):[],merged:He.map(Ie=>f.out.pathOf(Ie)).filter(Boolean),live:[]},D.set(Z,Oe),V.set(P,Oe),S.refs.set(Oe,He),Oe},De={base:new Map,local:new Map,remote:new Map},re=new Map,Se=(v,P)=>{let Y=z(v,P);if(!Y||Y.nodeType!==1)return null;let J=De[P].get(Y);if(!J){let je=o(Y),Z=Oe=>Me(P==="base"?F(Oe):W(Oe,P));J={parent:Z(Y),refs:je.map(Z),index:new Map(je.map((Oe,He)=>[Oe,He]))},De[P].set(Y,J)}let oe=J.index.get(v)??-1;return{parent:J.parent,before:J.refs.slice(oe+1),after:J.refs.slice(0,Math.max(0,oe)).reverse()}},qe=v=>{let P=v.parentNode;if(!P)return null;let Y=re.get(P);if(!Y){let oe=P.nodeType===11?p.get(P):P,je=oe&&oe.nodeType===1?x(oe):null;if(!je)return null;let Z=[],Oe=[],He=new Map;for(let ge of P.childNodes){let B=x(ge),G=B&&Me(B),ue=Z.length,he=Z.length-1;G&&G!==Z[he]&&(Z.push(G),he++);let ce={ref:G,group:he,after:ue};Oe.push(ce),He.set(ge,ce)}let Ie=Z.length;for(let ge=Oe.length-1;ge>=0;ge--){let B=Oe[ge];B.before=Ie,B.ref&&(Ie=B.group)}Y={parent:Me(je),refs:Z,index:He},re.set(P,Y)}let J=Y.index.get(v);return{parent:Y.parent,before:Y.refs.slice(J.before),after:Y.refs.slice(0,J.after).reverse()}},ve=v=>cn(v)?v.outerHTML:v.value,w=v=>cn(v)?"element":v.kind==="comment"?"comment":"text",K=(v,P)=>({path:v,offset:P}),ne=(v,P,Y)=>{if(!v)return null;let J=f[Y],oe=0;if(P){let je=cn(P)?P:P.nodes[P.nodes.length-1];je.parentNode&&(oe=J.indexIn(je.parentNode,je)+1)}return K(J.containerPath(v),oe)},ee=(v,P)=>{let Y=z(v,"base"),J=Y?g(u(P),Y):null;if(!cn(J))return null;let oe=o(Y),je=null;for(let Z=oe.indexOf(v)-1;Z>=0&&!je;Z--){let Oe=g(u(P),oe[Z]);Oe&&z(Oe,P)===J&&(je=Oe)}return ne(J,je,P)},Pe=(v,P,Y,J)=>{let oe=f[J],je=0;for(let Z=0;Z<v.nodes.length;Z++){let Oe=v.nodes[Z],He=Oe.nodeValue.length,Ie=Z===v.nodes.length-1;if((Y==="start"?P<je+He:P<=je+He)||Ie)return K(oe.pathOf(Oe),Math.max(0,Math.min(P-je,He)));je+=He}return null},_e=(v,P)=>{let Y=f[P],J=v.firstChild,oe=v.lastChild;return J&&J.nodeType===3&&oe.nodeType===3?{start:K(Y.pathOf(J),0),end:K(Y.pathOf(oe),oe.nodeValue.length)}:{start:K(Y.pathOf(v),0),end:K(Y.pathOf(v),v.childNodes.length)}},Ae=(v,P,Y)=>{for(let Z of v.nodes)if(Y==="start"?Z.s<=P&&P<Z.e:Z.s<P&&P<=Z.e)return{kind:"text",node:Z.node,offset:P-Z.s};let J=Y==="start"?P:P-1,oe=()=>{for(let Z of v.nodes)if(Z.s===P||Z.e===P)return{kind:"text",node:Z.node,offset:P-Z.s};return null},je=v.atomAt.get(J);if(je)return{kind:Y==="start"?"before":"after",node:je.el};if(v.text[J]===wt){let Z=v.marks.find(He=>He.block&&He.to===J+1);if(Z)return Y==="start"?{kind:"end",node:Z.el}:{kind:"after",node:Z.el};let Oe=v.marks.find(He=>He.block&&He.from===J+1);if(Oe)return Y==="start"?{kind:"before",node:Oe.el}:{kind:"startOf",node:Oe.el}}return oe()},ot=(v,P)=>Ae(v,P,"end")||Ae(v,P,"start"),Qe=(v,P)=>{switch(P.kind){case"text":return K(v.pathOf(P.node),P.offset);case"end":return K(v.containerPath(P.node),En(P.node).childNodes.length);case"startOf":return K(v.containerPath(P.node),0);default:{let Y=P.node.parentNode;return K(v.containerPath(Y),v.indexIn(Y,P.node)+(P.kind==="after"?1:0))}}},Ze=(v,P,Y,J,oe)=>{let je=Ae(v,P,Y);return je?Qe(f[J],je):oe()},Xe=(v,P,Y,J)=>{let oe=v.textNodes.map(Ie=>({s:Ie.ms,e:Ie.me,start:{kind:"text",node:Ie.node,offset:0},end:{kind:"text",node:Ie.node,offset:Ie.me-Ie.ms}}));for(let[Ie,ge]of v.atomOut)oe.push({s:Ie,e:Ie+1,start:{kind:"before",node:ge},end:{kind:"after",node:ge}});for(let[Ie,ge]of v.breakOut)oe.push({s:Ie,e:Ie+1,start:{kind:"end",node:ge},end:{kind:"after",node:ge}});for(let Ie of oe)if(Ie.start.kind==="text"&&Ie.s<P&&P<Ie.e)return{kind:"text",node:Ie.start.node,offset:P-Ie.s};if(Y!=="empty"){let Ie=oe.find(ge=>Y==="start"?ge.s===P:ge.e===P);if(Ie)return Y==="start"?Ie.start:Ie.end}let je=oe.find(Ie=>Ie.e===P);if(je)return je.end;let Z=oe.find(Ie=>Ie.s===P);if(Z)return Z.start;let Oe=null,He=null;for(let Ie of oe)Ie.e<=P&&(!Oe||Ie.e>Oe.e)&&(Oe=Ie),Ie.s>=P&&(!He||Ie.s<He.s)&&(He=Ie);return Oe?Oe.end:He?He.start:J()},yt=(v,P)=>{if(!P)return null;if(P.kind==="text"){let oe=v.nodes.find(je=>je.node===P.node);return oe?oe.s+Math.min(P.offset,oe.e-oe.s):null}let Y=v.atoms.find(oe=>oe.el===P.node);if(Y)return P.kind==="after"?Y.i+1:Y.i;let J=v.marks.find(oe=>oe.el===P.node);return J?P.kind==="before"&&J.block&&v.text[J.from-1]===wt&&!v.marks.some(oe=>oe.block&&oe.to===J.from)?J.from-1:P.kind==="startOf"||P.kind==="before"?J.from:P.kind==="end"&&J.block?J.to-1:J.to:null},dt=(v,P,Y,J)=>{for(let Oe of v.nodes)if(Y==="start"?Oe.s<=P&&P<Oe.e:Oe.s<P&&P<=Oe.e)return{kind:"text",node:Oe.node,offset:P-Oe.s};let oe=Y==="start"?P:P-1;if(!v.atomAt.has(oe)&&v.text[oe]!==wt){for(let Oe of v.nodes)if(Oe.s===P||Oe.e===P)return{kind:"text",node:Oe.node,offset:P-Oe.s}}let je=v.atomAt.get(oe);if(je)return{kind:Y==="start"?"before":"after",node:je.el};if(v.text[oe]===wt){let Oe=v.marks.find(Ie=>Ie.block&&Ie.to===oe+1);if(Oe)return Y==="start"?{kind:"end",node:Oe.el}:{kind:"after",node:Oe.el};let He=v.marks.find(Ie=>Ie.block&&Ie.from===oe+1);if(He)return Y==="start"?{kind:"before",node:He.el}:{kind:"startOf",node:He.el}}let Z=v.marks.find(Oe=>Oe.block&&Oe.from===P);return Z?{kind:"startOf",node:Z.el}:J?{kind:Y==="start"?"startOf":"end",node:J}:null},gt=v=>{if(!v)return null;if(v.kind==="wholeStart"||v.kind==="wholeEnd"){let P=qt(v.node);return v.kind==="wholeStart"?P.start:P.end}return Qe(f.out,v)},qt=v=>{let P=v.firstChild,Y=v.lastChild;return P&&P.nodeType===3&&Y.nodeType===3?{start:K(f.out.pathOf(P),0),end:K(f.out.pathOf(Y),Y.nodeValue.length)}:{start:K(f.out.pathOf(v),0),end:K(f.out.pathOf(v),v.childNodes.length)}},$t=v=>{let P=z(v,"base"),Y=P?j(F(P))[0]:null;if(!Y)return null;let J=En(Y),oe=o(P);for(let je=oe.indexOf(v)-1;je>=0;je--){let Z=j(F(oe[je])).filter(Oe=>Oe.parentNode===J);if(Z.length)return{kind:"after",node:Z[Z.length-1]}}return{kind:"startOf",node:Y}},Ht=(v,P,Y,J,oe,je)=>({text:v,start:P,end:Y,fragment:J,span:oe,scope:je}),jt=(v,P,Y,J,oe)=>Ht(v,P,Y,v.slice(P,Y),J,oe),an=(v,P,Y,J,oe)=>(S.spans.set(v,{start:P,end:Y,scopeStart:J,scopeEnd:oe}),v),_t=new Map,zt=new Map,_=(v,P,Y)=>{let J=`text:${v.key}:${P}:${Y}`,oe=zt.get(J)||0;return zt.set(J,oe+1),`${J}:${oe}`},ie=(v,P)=>{let Y,J,oe,je="plain",Z,Oe,He,Ie,ge,B=(he,ce,xe,te,q)=>{if(!he){let ae=ee(q,te);return jt("",0,0,{start:ae,end:ae},{start:ae,end:ae})}return jt(he.value,ce,xe,{start:Pe(he,ce,ce===xe?"end":"start",te),end:Pe(he,xe,"end",te)},{start:Pe(he,0,"start",te),end:Pe(he,he.value.length,"end",te)})};if(P.site==="run"){let{bRun:he,lRun:ce,rRun:xe,node:te,c:q}=P;Y=F(he),J=q.bs,oe=q.be,Z=B(he,q.bs,q.be,"base",he),Oe=B(ce,q.ls,q.le,"local",he),He=B(xe,q.rs,q.re,"remote",he);let ae=te?te.nodeValue:"",Ce=Le=>te?{kind:"text",node:te,offset:Le}:$t(he);Ie=an(jt(ae,q.ms,q.me,{start:gt(Ce(q.ms)),end:gt(Ce(q.me))},{start:gt(Ce(0)),end:gt(Ce(ae.length))}),Ce(q.ms),Ce(q.me),Ce(0),Ce(ae.length)),ge=te||($t(he)||{}).node||null}else if(P.site==="whole"){let he=P.el,ce=r.get(he);Y=F(ce.base),J=0,oe=v.base.length;let xe=(q,ae,Ce)=>{let Le=_e(ae,Ce);return jt(q,0,q.length,Le,Le)};Z=xe(v.base,ce.base,"base"),Oe=xe(v.local,ce.local,"local"),He=xe(v.remote,ce.remote,"remote");let te=qt(he);Ie=an(jt(v.resolved,0,v.resolved.length,te,te),{kind:"wholeStart",node:he},{kind:"wholeEnd",node:he},{kind:"wholeStart",node:he},{kind:"wholeEnd",node:he}),ge=he}else if(P.site==="comment"){let{bRun:he,lRun:ce,rRun:xe,node:te}=P;Y=F(he),J=0,oe=v.base.length;let q=(We,Ne)=>{if(!We){let k=ee(he,Ne);return jt("",0,0,{start:k,end:k},{start:k,end:k})}let ze=We.nodes[0],tt={start:K(f[Ne].pathOf(ze),0),end:K(f[Ne].pathOf(ze),We.value.length)};return jt(We.value,0,We.value.length,tt,tt)};Z=q(he,"base"),Oe=q(ce,"local"),He=q(xe,"remote");let ae=v.resolved,Ce=We=>te?{kind:"text",node:te,offset:We}:$t(he),Le={start:gt(Ce(0)),end:gt(Ce(ae.length))};Ie=an(jt(ae,0,ae.length,Le,Le),Ce(0),Ce(ae.length),Ce(0),Ce(ae.length)),ge=te||($t(he)||{}).node||null}else{let{fb:he,fl:ce,fr:xe,scope:te}=P,q=P.merged;je="html",Y=te.base?F(te.base):W(te.local,"local"),J=v.bs,oe=v.be;let ae=Ue=>{let $e=te[Ue];for(let Ge=te.at-1;Ge>=0;Ge--){let et=te.units[Ge],Ot=Ue==="base"?et:g(u(Ue),et);if(Ot&&z(Ot,Ue)===$e)return Ot}return null},Ce=Ue=>()=>ne(te[Ue],ae(Ue),Ue),Le=(Ue,$e,Ge,et,Ot)=>{let xt=Gt=>Gt?Qe(f[Ot],Gt):Ce(Ot)(),Jt=$e===Ge?ot(Ue,$e):Ae(Ue,$e,"start"),Mt=$e===Ge?ot(Ue,$e):Ae(Ue,Ge,"end"),pt=xt(Jt),bt={start:pt,end:$e===Ge?pt:xt(Mt)},mt=P.full?P.full(Ot):null;if(!mt)return Ht(Ue.text,$e,Ge,et,bt,{start:xt(Ae(Ue,0,"start")),end:xt(Ae(Ue,Ue.text.length,"end"))});let It=Jt?yt(mt,Jt):null,ct=Mt?yt(mt,Mt):null,Wt=It===null?0:It,St=Math.max(Wt,ct===null?mt.text.length:ct),fn=xt(Ae(mt,0,"start"));return Ht(mt.text,Wt,St,ko(mt,Wt,St),bt,{start:fn,end:mt.text.length?xt(Ae(mt,mt.text.length,"end")):fn})};Z=P.synthetic?null:Le(he,v.bs,v.be,v.base,"base"),Oe=Le(ce,v.lss,v.lse,v.local,"local"),He=Le(xe,v.rss,v.rse,v.remote,"remote");let[We,Ne]=v.range||[0,0],ze=q.out,tt=()=>{let Ue=En(q.node);for(let $e=te.at-1;$e>=0;$e--){let Ge=j(F(te.units[$e])).filter(et=>et.parentNode===Ue);if(Ge.length)return{kind:"after",node:Ge[Ge.length-1]}}for(let $e=te.at;$e<te.units.length;$e++){let Ge=j(F(te.units[$e])).filter(et=>et.parentNode===Ue);if(Ge.length)return{kind:"before",node:Ge[0]}}return{kind:"startOf",node:q.node}};if(ze.via)for(let[Ue,$e]of ze.via)R.set(Ue,$e);let k=Xe(q,We,We===Ne?"empty":"start",tt),$=We===Ne?k:Xe(q,Ne,"end",tt),Q=ze.text.length?dt(ze,0,"start",q.node):tt(),be=ze.text.length?dt(ze,ze.text.length,"end",q.node):Q,fe=yt(ze,k),se=yt(ze,$),le=fe===null?0:fe,Be=Math.max(le,se===null?ze.text.length:se);Ie=an(Ht(ze.text,le,Be,ko(ze,le,Be),{start:gt(k),end:gt($)},{start:gt(Q),end:gt(be)}),k,$,Q,be);let Ke=S.spans.get(Ie);if(Ke.flat=ze,!ze.text.length){let Ue=gt(Q),$e=io(h,Ue),Ge=$e[0],et=$e[1];Ke.empty={parent:Ge.nodeType===11?p.get(Ge):Ge,previous:Ge.childNodes[et-1]||null,next:Ge.childNodes[et]||null}}ge=k?k.node:q.node}let G=Me(Y),ue=(P.site==="whole"||P.site==="comment"||(P.policy||c)!=="both")&&v.resolved!==v.local;return{key:P.site==="comment"&&_t.get(Y.b||Y.l||Y.r)||_(G,J,oe),subject:G,localLost:ue,anchor:ge,text:{encoding:je,base:Z,local:Oe,remote:He,merged:Ie,liveSpan:null,liveScope:null}}},me=(v,P)=>{let Y=x(P.el),J=Me(Y),oe=P.sample;return{key:`attr:${J.key}:${oe.namespaceURI||""}:${oe.localName}`,subject:J,localLost:v.resolved!==v.local,anchor:P.el,attribute:{namespaceURI:oe.namespaceURI||null,localName:oe.localName,qualifiedName:oe.name}}},pe=(v,P)=>{let Y=v.detail,J=P.unit||F(P.subject),oe=Me(J),je=S.refs.get(oe),Z=J.l?Se(J.l,"local"):null,Oe=J.r?Se(J.r,"remote"):null,He=je.length?qe(je[0]):null,Ie,ge,B,G=null,ue=null,he=P.deleted;switch(Y){case"both-reordered":{Ie=ge="reordered";let ce=new Set(P.rKept),xe=P.lKept.filter(Le=>ce.has(Le)&&j(F(Le)).length),te=Le=>A.get(j(F(Le))[0]);G=xe.map(Le=>Me(F(Le))),ue=xe.slice().sort((Le,We)=>te(Le)-te(We)).map(Le=>Me(F(Le)));let q=Le=>!cn(Le)&&Le.kind!=="comment"&&Le.nodes.every(We=>!/[^\t\n\f\r ]/.test(We.data)),ae=xe.filter(Le=>!q(Le)),Ce=ae.slice().sort((Le,We)=>te(Le)-te(We));B=ae.some((Le,We)=>Le!==Ce[We]);break}case"both-moved":Ie=ge="moved",B=!Z||!je.some(ce=>{let xe=ce===je[0]?He:qe(ce);return xe&&xe.parent===Z.parent});break;case"edit-beats-delete":Ie=he==="local"?"deleted":"edited",ge=he==="remote"?"deleted":"edited",B=he==="local";break;case"move-beats-delete":Ie=he==="local"?"deleted":"moved",ge=he==="remote"?"deleted":"moved",B=he==="local";break;case"remote-wins":Ie="edited",ge="edited",B=!0;break;default:Ie=ge="inserted",B=P.localLost}return{key:`structure:${oe.key}:${Y}`,subject:oe,localLost:B,anchor:je[0]||null,structure:{localAction:Ie,remoteAction:ge,localPlacement:Z,remotePlacement:Oe,mergedPlacement:He,localOrder:G,mergedOrder:ue,localFragment:Y==="both-reordered"||!J.l?null:ve(J.l),fragmentKind:w(J.b||J.l||J.r)}}};for(let[v,P]of l){if(v.kind!=="structure")continue;let Y=P.unit||F(P.subject),J=Y.b||Y.l||Y.r;!cn(J)&&J.kind==="comment"&&_t.set(J,`structure:${Me(Y).key}:${v.detail}`)}let ke=new Map;for(let[v,P]of l){if(v.kind==="structure"){let je=Me(P.unit||F(P.subject)),Z=`structure:${je.key}:${v.detail}`,Oe=ke.get(Z);if(Oe&&Oe.structure){v.recovery=Oe;let He=S.refs.get(je);v.el==null&&He.length&&(v.el=cn(He[0])?He[0]:f.out.logicalParent(He[0]));continue}}let Y=v.kind==="text"?ie(v,P):v.kind==="attr"?me(v,P):pe(v,P),J=ke.get(Y.key);J||(J={version:Xc,key:Y.key,localLost:Y.localLost,subject:Y.subject,applied:!1,unavailable:null},ke.set(Y.key,J),S.anchors.set(J,Y.anchor)),Y.text&&(J.text=Y.text),Y.attribute&&(J.attribute=Y.attribute),Y.structure&&(J.structure=Y.structure),Y.text&&(J.localLost=Y.localLost),v.recovery=J;let oe=S.refs.get(Y.subject);v.kind==="structure"&&v.el==null&&oe.length&&(v.el=cn(oe[0])?oe[0]:f.out.logicalParent(oe[0])),v.kind==="text"&&v.node==null&&oe.length&&Y.subject.nodeType===8&&(v.node=oe[0])}return S}}function Bi(e,n,t){if(!n)return;let{lookup:o,vetoed:r,vetoedAttrs:c,liveAttr:l}=t,i=t.ignored||(()=>!1),s=co(t.liveRoot),a=T=>!!T&&s.containerPath(T)!==null,h=T=>{let x=T.parentNode;return x&&x.nodeType===11?n.outOwners.get(x)||null:x},f=T=>{for(let x=T;x;x=h(x))if(n.via.has(x)&&(x=n.via.get(x)),r.has(x)||t.vetoedLive?.has(m(x)))return!0;return!1},u=T=>Array.from(En(T).children).filter(x=>!i(x)),g=(T,x)=>u(T)[u(x.parentNode).indexOf(x)],b=(T,x)=>{let z=null,D=null,V=0;for(let re=x.previousSibling;re;re=re.previousSibling){if(re.nodeType===1&&!i(re)){z=re;break}re.nodeType===3&&(V+=re.nodeValue.length)}for(let re=x.nextSibling;re&&!D;re=re.nextSibling)re.nodeType===1&&!i(re)&&(D=re);let Ee=z?g(T,z):null,Me=D?g(T,D):null;if(z&&!Ee||D&&!Me)return null;let De=[];for(let re=Ee?Ee.nextSibling:En(T).firstChild;re&&re!==Me;re=re.nextSibling)re.nodeType===3&&De.push(re);return De.length?{nodes:De,lead:V}:null},A=T=>{let x=[],z=T;for(;z&&!n.via.has(z);z=z.parentNode)x.push(z);if(!z||!x.length)return null;let D=m(n.via.get(z));for(let Me=x.length-1;Me>0&&D;Me--)D=g(D,x[Me]);if(!D)return null;let V=x[0];if(V.nodeType===3)return b(D,V);let Ee=V.nodeType===1?g(D,V):null;return Ee?{nodes:[Ee],lead:0}:null},p=T=>{let x=o(T),z=x?{nodes:Array.isArray(x)?x:[x],lead:0}:n.via.size?A(T):null;if(!z)return null;let D=z.nodes.filter(a);return D.length?{nodes:D,lead:z.lead}:null},m=T=>{let x=p(T);return x?x.nodes[0]:null},y=T=>{if(!T)return null;if(T.kind==="text"){let V=p(T.node);if(!V)return null;let Ee=V.nodes,Me=T.offset+V.lead,De=0;for(let re=0;re<Ee.length;re++){let Se=Ee[re].nodeValue.length;if(Me<=De+Se||re===Ee.length-1)return Me>=De&&Me<=De+Se?[Ee[re],Me-De]:null;De+=Se}return null}let x=m(T.node);if(!x)return null;if(T.kind==="end")return[En(x),En(x).childNodes.length];if(T.kind==="startOf")return[En(x),0];if(T.kind==="wholeStart")return x.firstChild?[x.firstChild,0]:[x,0];if(T.kind==="wholeEnd")return x.lastChild?[x.lastChild,x.lastChild.nodeValue.length]:[x,x.childNodes.length];let z=x.parentNode;if(!z)return null;let D=Array.prototype.indexOf.call(z.childNodes,x);return[z,T.kind==="after"?D+1:D]},R=T=>({blocks:new Set((T.flat?.marks||[]).filter(x=>x.block).map(x=>m(x.el)).filter(Boolean)),atoms:new Set((T.flat?.atoms||[]).map(x=>m(x.el)).filter(Boolean)),ignored:i}),S=(T,x,z,D)=>{if(!T||!x||!lo(T)||!lo(x))return!1;for(let Me of[T,x])if(!a(Me.startContainer)||!a(Me.endContainer))return!1;let V=z.merged;if(V.start===V.end&&(T.startContainer!==T.endContainer||T.startOffset!==T.endOffset))return!1;let Ee=R(D);return Zn(x,z.encoding,Ee)===V.text&&Zn(T,z.encoding,Ee)===V.text.slice(V.start,V.end)},O=new Map,M=T=>{let x=T.parentNode;return x?(O.has(x)||O.set(x,new Map(Array.from(x.childNodes,(z,D)=>[z,D]))),O.get(x).get(T)):-1},E=(T,x)=>{if(!x)return!1;let z=s.logicalParent(T);if(!x.parent.live.includes(z))return!1;let D=M(T);for(let[V,Ee]of[["before",1],["after",-1]]){let Me=D;for(let De of x[V]){if(De.live.includes(T))continue;let re=De.live.filter(qe=>qe!==T&&qe.parentNode===T.parentNode);if(!re.length)continue;let Se=Ee===1?Math.min(...re.map(M)):Math.max(...re.map(M));if(Ee*(Se-Me)<=0)return!1;Me=Se}}return!0},N=T=>{let x=T.structure;if(x.mergedOrder){let z=new Set(T.subject.live.map(En)),D=null,V=-1;for(let Ee of x.mergedOrder){let Me=Ee.live.find(De=>z.has(De.parentNode));if(!Me||D&&Me.parentNode!==D||M(Me)<=V)return!1;D=Me.parentNode,V=M(Me)}return T.subject.live.length>0}return T.subject.live.some(z=>E(z,x.mergedPlacement))},L=(T,x)=>{let z=y(T),D=y(x);return z&&D?{startContainer:z[0],startOffset:z[1],endContainer:D[0],endOffset:D[1]}:null},j=new Set,F=T=>{if(!T||j.has(T))return;j.add(T);let x=[];for(let z of n.refs.get(T)||[]){let D=p(z);if(D)for(let V of D.nodes)x.includes(V)||x.push(V)}T.live=x},W=T=>{T&&(F(T.parent),T.before.forEach(F),T.after.forEach(F))},C=new Set;for(let T of e){let x=T.recovery;if(!x||C.has(x))continue;C.add(x),F(x.subject),x.structure&&(W(x.structure.localPlacement),W(x.structure.remotePlacement),W(x.structure.mergedPlacement),(x.structure.localOrder||[]).forEach(F),(x.structure.mergedOrder||[]).forEach(F));let z=n.anchors.get(x),D=z?m(z):null,V=!!D;if(x.text){let w=n.spans.get(x.text.merged),K=w?L(w.start,w.end):null,ne=w?L(w.scopeStart,w.scopeEnd):null;if(w?.empty){let ee=w.empty,Pe=ee.previous?{kind:"after",node:ee.previous}:{kind:"startOf",node:ee.parent},_e=ee.next?{kind:"before",node:ee.next}:{kind:"end",node:ee.parent},Ae=L(Pe,_e);!Ae||Ae.startContainer!==Ae.endContainer||Ae.startOffset!==Ae.endOffset?K=null:K=ne=Ae}S(K,ne,x.text,w)||(K=ne=null),x.text.liveSpan=K,x.text.liveScope=K?ne:null,K||(V=!1)}x.structure&&V&&(V=N(x)),x.attribute&&V&&(V=l(D,x.attribute,T.resolved));let Ee=(!!x.attribute||!!x.text&&D?.tagName==="TEXTAREA")&&!!c&&[z,D].some(w=>c.get(w)?.has(x.attribute?x.attribute.qualifiedName:"value")),Me=n.localState?.states.get(x),De=!!x.text&&[...t.removedVetoes||[]].some(w=>Me?.touched.has(w)),re=x.structure?.localAction==="inserted"&&[...r].some(w=>w===z||z?.contains(w)),Se=z&&f(z)||Ee||De||re,qe=Se&&ji(x,T,n,a);qe&&(De||re&&x.localLost)&&(V=!1);let ve=!V&&qe&&Se;x.applied=V,x.unavailable=V?null:ve?"hook-veto":"missing-output",ve&&(x.localLost=!1),!V&&x.text&&(x.text.liveSpan=x.text.liveScope=null)}}function Sr(e,n,t){let o=co(n),r=co(t),c=f=>!!f&&r.containerPath(f)!==null,l=f=>{if(f===n)return t;let u=o.pathOf(f);if(u&&n!==t){let g=io(t,{path:u,offset:0});if(g&&g[0].nodeType===f.nodeType)return g[0]}return f},i=new Set,s=f=>{!f||i.has(f)||(i.add(f),f.live=f.live.map(l).filter(c))},a=f=>{f&&(f.startContainer=l(f.startContainer),f.endContainer=l(f.endContainer))},h=new Set;for(let f of e){f.node===n&&t.tagName==="SCRIPT"&&(f.node=t),f.el===n&&f.kind==="structure"&&(f.el=t);let u=f.recovery;if(!u||h.has(u))continue;if(h.add(u),s(u.subject),u.text){a(u.text.liveSpan),a(u.text.liveScope);let b=u.text.liveSpan,A=u.text.liveScope,p=u.text.merged,m=y=>!!y&&lo(y)&&c(y.startContainer)&&c(y.endContainer);(!m(b)||!m(A)||Zn(A,u.text.encoding)!==p.text||Zn(b,u.text.encoding)!==p.text.slice(p.start,p.end))&&(u.text.liveSpan=null,u.text.liveScope=null,u.applied=!1,u.unavailable="missing-output")}let g=u.structure;if(g){for(let b of[g.localPlacement,g.remotePlacement,g.mergedPlacement])b&&(s(b.parent),b.before.forEach(s),b.after.forEach(s));(g.localOrder||[]).forEach(s),(g.mergedOrder||[]).forEach(s),u.subject.live.length||(u.applied=!1,u.unavailable="missing-output")}}}var vo=e=>e?.nodeType===1,Fo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function Jc({provenance:e,parentOf:n,twins:t,baseOf:o,build:r,ignored:c,remoteWins:l,discarded:i}){let s=new Map,a=new WeakMap;function h(g,b,A,p=!1){if(!vo(g)||!vo(A))return null;let m=s.get(g);if(m)(p||!m.selected&&b==="remote")&&(m.parent=n(A),m.port=A,m.sourceSide=b,m.selected=p);else{let y=a.get(g)||null;m={owner:g,parent:n(A),port:A,sourceSide:b,originalParent:n(g),originalPort:g,selected:p,state:y?"built":"planned",output:y,disposition:null},s.set(g,m)}return m}function f(g,b){if(!vo(g)||!vo(b))return;a.has(g)||a.set(g,b);let A=s.get(g);A&&A.state!=="attached"&&!A.output&&(A.output=b,A.state="built")}function u(g){if(!s.size)return;let b=new Map,A=new WeakMap,p=new WeakMap,m=new WeakSet,y=new Set,R=(W,C)=>{if(!W)return;if(Array.isArray(W)){for(let x of W)R(x,C);return}let T=b.get(W);T||b.set(W,T=[]),T.push(C)},S=(W,C)=>{if(!W)return;let T=[W];for(;T.length;){let x=T.pop();R(x,C);for(let z of Fo(x).childNodes)T.push(z)}};function O(W,C=null,T=!1){if(m.has(W))return;m.add(W),A.set(W,C);let x=e.get(W),z=T||!!(x&&l(x.remote||x.base));p.set(W,z);let D={node:W,kind:"node",authority:z};if(x?.pinned)S(x.local,{...D,kind:"ignored"});else if(x?.unchanged)for(let V of[x.base,x.local,x.remote])S(V,{...D,kind:"unchanged"});else if(x){for(let V of[x.base,x.local,x.remote])R(V,D);if(vo(x.local))for(let V of Fo(x.local).children)c(V)&&S(V,{...D,kind:"ignored"})}for(let V of Fo(W).childNodes)O(V,W,z)}let M=W=>{if(W.output&&m.has(W.output))return W.state="attached",W.disposition="node",!0;let{local:C,remote:T}=t(W.owner);for(let x of[W.owner,C,T]){let z=b.get(x);if(z?.length){let D=z.find(V=>V.kind==="node")||z[0];return W.output=D.node,W.state="attached",W.disposition=D.kind,!0}}return!1},E=(W,C)=>(b.get(W)||[]).find(x=>x.kind==="node"&&vo(x.node)&&(!x.authority||C.sourceSide==="remote"))?.node,N=(W,C,T)=>{let x=b.get(W)||[],z=T?[...x].reverse():x;for(let D of z){if(D.kind!=="node")continue;let V=D.node;for(;V&&A.get(V)!==C;)V=A.get(V);if(V)return V}return null},L=(W,C,T)=>{let x=Fo(C);for(let z=T?.previousSibling;z;z=z.previousSibling){let D=N(z,C,!0);if(D){x.insertBefore(W,D.nextSibling);return}}for(let z=T?.nextSibling;z;z=z.nextSibling){let D=N(z,C,!1);if(D){x.insertBefore(W,D);return}}x.appendChild(W)};function j(W,C,T){let x=C==="base"?W:o(W,C),z=s.get(x);z&&z!==T&&F(z)}function F(W){if(W.state==="attached"||W.disposition==="remote-wins"||y.has(W)||M(W))return;y.add(W);let{local:C,remote:T}=t(W.owner);if(l(T||W.owner)){if(!T){W.disposition="remote-wins",i(W.owner,C),y.delete(W);return}W.parent=n(T),W.port=T,W.sourceSide="remote"}if(j(W.parent,W.sourceSide,W),M(W)){y.delete(W);return}let x=E(W.parent,W),z=W.port;if(!x){if(j(W.originalParent,"base",W),M(W)){y.delete(W);return}let V=W.originalParent;for(z=W.originalPort;V&&!x;)x=E(V,W),x||(z=V,V=n(V))}if(!x)throw new Error("A planned move has no allowed surviving parent");let D=W.output||r(W.owner);W.output=D,W.state="built",L(D,x,z),O(D,x,p.get(x)||!1),M(W),y.delete(W)}O(g);for(let W of s.values())F(W)}return{planned:s,has:g=>s.has(g),plan:h,produced:f,drain:u}}function Oo(e,n,t,o,r,c,l,i,s,a,h,f,u){let g=null;return Jc({provenance:e,parentOf:p=>{if(!p)return null;let m=n(p);if(m||p.parentNode?.nodeType!==11)return m;if(!g){g=new WeakMap;let y=[f,u];for(;y.length;){let R=y.pop(),S=Fo(R);S!==R&&g.set(S,R);for(let O of S.children)y.push(O)}}return g.get(p.parentNode)||null},twins:p=>({local:r(t,p),remote:r(o,p)}),baseOf:(p,m)=>p&&(m==="local"?t:o).reverse.get(p)||null,build:p=>c(p,r(t,p),r(o,p),!1),ignored:l,remoteWins:i,discarded:(p,m)=>{m&&h(p,m,t)&&!s.some(y=>y.detail==="remote-wins"&&y.base===p)&&a({kind:"structure",el:null,detail:"remote-wins",base:p,local:m,remote:null},{subject:p})}})}function Qc({parent:e,base:n,views:t,eligible:o,ignored:r,remoteWins:c,budget:l=Kt(2e4*32),maxUnits:i=256,maxCharacters:s=2e4}){let a=(m,y=null)=>({status:m,reason:y,parent:e,records:[]});if(t.some(({V:m})=>m.asBase)||r(e)||c(e)||t.some(({V:m})=>!m.el||r(m.el)||c(m.el)))return a("none");let h=n.length+t[0].V.units.length+t[1].V.units.length;if(h>i)return a("fallback","unit-limit");let f=Symbol(),u=m=>{if(m>l.remaining)throw f;l.remaining-=m,l.crossParentSteps=(l.crossParentSteps||0)+m},g=new Map,b=0,A=m=>{if(u(1),g.has(m))return g.get(m);let y=m.nodeType===1?m.childNodes:m.nodes;u(y.length*4+1);let R=m.nodeType===1?Array.from(y):y,S=0;for(let E=0;E<R.length;E++){let N=R[E];if(N.nodeType!==3||E&&R[E-1].nextSibling!==N)return g.set(m,null),null;S+=N.data.length}if(S>s-b)throw f;u(S*8+1),b+=S;let O=en(R);if(O.text.includes(wt))return g.set(m,null),null;let M={unit:m,nodes:R,flat:O};return g.set(m,M),M},p=[];try{u(h*8+1);for(let m=0;m<2;m++){let y=t[m].V,R=t[1-m].V,S=[],O=new Map;for(let M=0;M<n.length;M++){u(1);let E=n[M];if(E.kind!=="text"||y.twin(E))continue;let N=R.twin(E);if(!N||N.kind!=="text"||!R.here(N))continue;let L=A(E),j=A(N);if(!L||!j||!/\S/.test(L.flat.text))continue;u(L.flat.text.length*2+1);let F=L.flat.text;O.set(F,(O.get(F)||0)+1),S.push({source:E,opposite:N,sourceModel:L,oppositeModel:j,index:M})}for(let M of S){let{source:E,opposite:N,sourceModel:L,oppositeModel:j,index:F}=M,W=[];for(let K of[-1,1]){u(1);let ne=n[F+K];if(!ne||ne.nodeType!==1||!o(ne)||r(ne)||c(ne))continue;let ee=L.nodes[0],Pe=L.nodes.at(-1);if(K===-1?ee?.previousSibling!==ne:Pe?.nextSibling!==ne)continue;let _e=y.twin(ne),Ae=R.twin(ne);if(!_e||!Ae||!y.here(_e)||R.here(Ae)||y.baseOf(_e)!==ne||R.baseOf(Ae)!==ne||!o(_e)||!o(Ae)||r(_e)||r(Ae)||c(_e)||c(Ae)||_e.tagName!==ne.tagName||Ae.tagName!==ne.tagName||_e.namespaceURI!==ne.namespaceURI||Ae.namespaceURI!==ne.namespaceURI)continue;let ot=A(ne),Qe=A(_e),Ze=A(Ae);if(!ot||!Qe||!Ze||!/\S/.test(ot.flat.text))continue;let Xe=ot.flat.text,yt=L.flat.text,dt=Qe.flat.text;if(u((Xe.length+yt.length+dt.length)*3+1),dt.length!==Xe.length+yt.length)continue;let gt=K===-1;(gt?!dt.startsWith(Xe)||!dt.endsWith(yt):!dt.startsWith(yt)||!dt.endsWith(Xe))||W.push({owner:ne,target:_e,moved:Ae,ownerBase:ot,joined:Qe,ownerOther:Ze,targetFrom:gt?Xe.length:0,retainedFrom:gt?0:yt.length})}if(!W.length)continue;if(W.length!==1||O.get(L.flat.text)!==1)return a("fallback","ambiguous-origin");let C=W[0],{owner:T,target:x,moved:z,ownerBase:D,joined:V,ownerOther:Ee,targetFrom:Me,retainedFrom:De}=C;if(u(p.length+1),p.some(K=>K.owner===T))return a("fallback","ambiguous-owner");let re={source:E,target:x,from:0,to:L.flat.text.length,targetFrom:Me},Se=Dn({base:L.flat,side:V.flat,retained:[],transfers:[{from:re.from,to:re.to,target:Me,destination:T}],budget:l});if(Se.status!=="ready"||Se.covers(re.from,re.to)!==!0)return a("fallback",Se.reason||"work-limit");let qe=[{unit:E,model:L,from:0,to:L.flat.text.length},null,null];qe[m+1]={unit:x,model:V,from:Me,to:Me+L.flat.text.length},qe[2-m]={unit:N,model:j,from:0,to:j.flat.text.length};let ve=[D,null,null];ve[m+1]=V,ve[2-m]=Ee;let w=[T,null,null];w[m+1]=x,w[2-m]=z,p.push({side:m,parent:e,source:E,target:x,owner:T,owners:w,ownerModels:ve,native:qe,models:g,runs:[re],proof:Se,retained:[{source:T,target:x,from:0,to:D.flat.text.length,targetFrom:De}]})}}return p.length?{status:"ready",reason:null,parent:e,records:p}:a("none")}catch(m){if(m!==f)throw m;return a("fallback","work-limit")}}function Ui({describe:e,parentOf:n,...t}){let o=new WeakMap,r=new WeakMap,c=t.budget||Kt(2e4*32),l=i=>{if(!i)return null;if(o.has(i))return o.get(i);o.set(i,{status:"planning",parent:i,records:[]});let s=e(i),a=s?Qc({...t,...s,parent:i,budget:c}):{status:"none",reason:null,parent:i,records:[]};if(o.set(i,a),a.status==="ready")for(let h of a.records)r.set(h.owner,[h]);return a};return{get:l,forOwner(i){return l(n(i))?.status==="ready"&&r.get(i)||null}}}function Zc(e,n){if(e.side!==0)return null;let t=e.native[0].model,o=e.ownerModels[0],r=e.native[1].from!==0,c=(R,S)=>r?[...R.nodes,...S.nodes]:[...S.nodes,...R.nodes],l=e.ownerModels.reduce((R,S)=>R+S.flat.text.length,0)+t.flat.text.length+e.native[2].model.flat.text.length;if(l*8>n.remaining)return null;n.remaining-=l*8;let i={base:c(o,t),local:e.ownerModels[1].nodes,remote:c(e.ownerModels[2],e.native[2].model)},s=en(i.base),a=e.ownerModels[1].flat,h=en(i.remote),f=r?o.flat.text.length:0,u=r?0:t.flat.text.length,g=Dn({base:s,side:a,retained:e.retained.map(R=>({from:u+R.from,to:u+R.to,target:R.targetFrom})),transfers:e.runs.map(R=>({from:f+R.from,to:f+R.to,target:R.targetFrom,destination:e.owner})),budget:n});if(g.status!=="ready"||g.covers(0,s.text.length)!==!0)return null;let b=e.ownerModels[2].flat,A=e.native[2].model.flat,p=[];for(let[R,S,O,M]of[[o.flat,b,u,r?0:A.text.length],[t.flat,A,f,r?b.text.length:0]]){let E=ns(R,R,S).remoteMap.bTo,N=-1;for(let L=0;L<R.text.length;L++){if(E[L]<0){N=-1;continue}let j=p.at(-1);N>=0&&j.to===O+L&&j.target+j.to-j.from===M+E[L]?j.to++:(p.push({from:O+L,to:O+L+1,target:M+E[L]}),N=L)}}let m=Dn({base:s,side:h,retained:p,transfers:[],budget:n});if(m.status!=="ready")return null;let y=ns(s,a,h,{},{local:g,remote:m});return y.localEdits.hunks.length?null:(y.localMap=g,y.remoteMap=m,{nodes:i,prepared:y})}function Hi({L:e,R:n,twinIn:t,unitsOf:o,view:r,parentOf:c,ignored:l,remoteWins:i,eligible:s,build:a,out:h,policy:f,provenance:u,textMappers:g,segments:b,conflicts:A,conflict:p,decisions:m}){let y=Kt(2e4*32),R=W=>{let C=0;for(let T=W;T;T=c(T))if(++C>64||T.nodeType===1&&(l(T)||i(T)))return!1;return!0},S=Ui({parentOf:c,eligible:s,ignored:l,remoteWins:i,budget:y,describe(W){let C=t(e,W),T=t(n,W);return!C||!T||!R(W)||!R(C)||!R(T)?null:{base:o(W),views:[{A:e,V:r(e,C,W,!1)},{A:n,V:r(n,T,W,!1)}]}}}),O=new WeakSet,M=new WeakMap,E=new WeakSet,N=[];function L(W){if(!W||O.has(W))return;O.add(W);let C=S.get(W);if(C?.status==="ready")for(let T of C.records){if((W.tagName==="TEMPLATE"&&W.content?W.content:W).childNodes.length!==T.native[0].model.nodes.length+1||!T.owners.every(R))continue;let z=Zc(T,y);if(!z)continue;let D={record:T,payload:z,state:"planned",output:null,result:null};M.set(T.owner,D),E.add(T.source),E.add(T.native[2].unit),N.push(D)}}function j(W,C){let T=M.get(W);if(!T)return!1;if(!T.result){if(T.result=so({...T.payload.nodes,prepared:T.payload.prepared,out:h,policy:f,provenance:u,textMappers:g,conflicts:A,conflict:p,decisions:m,node:C}),T.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");b.push(...T.result.segments),T.decision={kind:"text",node:C,source:"local"},m.push(T.decision)}return T.decision.node=C,C.replaceChildren(...T.result.nodes),T.output=C,T.state="built",!0}function F(W){if(!N.length)return;let C=new WeakSet,T=new WeakMap,x=new WeakMap,z=new WeakMap,D=Se=>Se.tagName==="TEMPLATE"&&Se.content?Se.content:Se,V=(Se,qe)=>{if(!Se)return;if(Array.isArray(Se)){for(let w of Se)V(w,qe);return}let ve=z.get(Se);ve||z.set(Se,ve=[]),ve.push(qe)},Ee=(Se,qe=null,ve=!1)=>{C.add(Se),T.set(Se,qe);let w=u.get(Se),K=ve||!!(w&&i(w.remote||w.base));if(x.set(Se,K),w)for(let ne of[w.base,w.local,w.remote])V(ne,Se);if(!(w?.pinned||w?.unchanged))for(let ne of D(Se).childNodes)Ee(ne,Se,K)},Me=Se=>(z.get(Se)||[]).find(qe=>qe.nodeType===1&&!x.get(qe)&&!u.get(qe)?.pinned&&!u.get(qe)?.unchanged),De=(Se,qe)=>{for(let ve of z.get(Se)||[]){let w=ve;for(;w&&T.get(w)!==qe;)w=T.get(w);if(w)return w}return null},re=(Se,qe,ve)=>{let w=D(qe);for(let K=ve.nextSibling;K;K=K.nextSibling){let ne=De(K,qe);if(ne){w.insertBefore(Se,ne);return}}for(let K=ve.previousSibling;K;K=K.previousSibling){let ne=De(K,qe);if(ne){w.insertBefore(Se,ne.nextSibling);return}}w.appendChild(Se)};Ee(W);for(let Se of N){let{record:qe}=Se,ve=Me(qe.owner)||Me(qe.owners[1])||Me(qe.owners[2]);if(ve)(!Se.result||Se.output!==ve||Se.result.nodes.some(w=>!C.has(w)||T.get(w)!==ve)||ve.textContent!==Se.result.text)&&(j(qe.owner,ve),Ee(ve,T.get(ve),x.get(ve)));else{let w=qe.parent,K=qe.owner,ne=null;for(;w&&!ne;)ne=Me(w),ne||(K=w,w=c(w));if(!ne)throw new Error("A cross-parent payload has no allowed surviving parent");ve=Se.output||a(qe.owner,qe.owners[1],qe.owners[2],!1),Se.result||j(qe.owner,ve),re(ve,ne,K),Ee(ve,ne,x.get(ne))}Se.state="attached"}}return{ensureParent:L,ensureOwner(W){L(c(W))},consumes(W){return E.has(W)},render:j,drain:F}}var Sn=/\S/,Wi=/[\p{L}\p{N}]/u;function ao(e,n,t,o){if(e?.nodeType!==1||!n(e))return!1;for(let r=e.firstChild;r;r=r.nextSibling)if(o(t,1),r.nodeType!==3)return!1;return!!e.firstChild}function ls(e,n,t){for(let o=e.parentNode;o;o=o.parentNode)if(t(n,1),o.nodeType===11)return!1;return!0}function Vi(e,n,t,o,r){let c=t(e,o),l=t(n,o),i=null,s=null,a=null,h=null;r(o,c.length+l.length);for(let f of c)Wi.test(f.raw)&&(i||=f,s=f);for(let f of l)Wi.test(f.raw)&&(a||=f,h=f);return!!(i&&a&&(i.raw===a.raw||s.raw===h.raw))}function ea({base:e,V:n,A:t,source:o,original:r,current:c,edited:l,destination:i,at:s,ownLength:a,eligible:h,model:f,tokensOf:u,budget:g,charge:b}){let A=r.flat.text,p=c.flat.text,m=l.flat.text,y=i.flat.text;if(b(g,A.length+p.length+y.length),A.startsWith(p)||A.endsWith(p))return!1;let R=Sn.test(y.slice(0,s)),S=Sn.test(y.slice(s+a));if(R===S)return!1;let O=R?0:s+a,M=R?s:y.length;for(;O<M&&!Sn.test(y[O]);)O++;for(;M>O&&!Sn.test(y[M-1]);)M--;let E=y.slice(O,M);if(Mn(E,y,u(i,g),g,b,!0)!==O)return!1;let N=Mn(E,A,u(r,g),g,b,!0);if(N<0)return!1;let L=N+E.length,j=!Sn.test(A.slice(0,N)),F=!Sn.test(A.slice(L));if(j===F||Mn(E,p,u(c,g),g,b,!1)>=0)return!1;let W=j?A.slice(L):A.slice(0,N),C=j?m.length-W.length:0;if(b(g,A.length+m.length),C<0||!Sn.test(W)||Mn(W,m,u(l,g),g,b,!0)!==C||!Sn.test(j?m.slice(0,C):m.slice(W.length)))return!1;for(let T of e){if(b(g,1),T===o||!ao(T,h,g,b))continue;let x=f(T,null,g);if(Mn(E,x.flat.text,u(x,g),g,b,!1)>=0)return!1}for(let T of n.units){if(b(g,1),T===c.unit||T===i.unit||!ao(T,h,g,b))continue;let x=f(T,t,g);if(Mn(E,x.flat.text,u(x,g),g,b,!1)>=0)return!1}return!0}function _i({base:e,views:n,side:t,attempt:o,eligible:r,blocked:c,baseId:l,model:i,tokensOf:s,charge:a,exhausted:h,limit:f}){if(f<=0)return null;let u=Kt(f),{V:g,A:b,idOf:A}=n[t],p=n[1-t],[m,y,R,S]=o,O=null;try{for(let M=m;M<=y;M++){a(u,1);let E=e[M];if(E.parentNode?.nodeType!==1||c.has(E)||b.identical.has(E)||p.A.identical.has(E)||!ao(E,r,u,a)||l(E))continue;let N=g.twin(E),L=p.V.twin(E);if(!N||!L||!g.here(N)||!p.V.here(L)||b.map.get(E)!==N||b.reverse.get(N)!==E||p.A.map.get(E)!==L||p.A.reverse.get(L)!==E||A(N)||p.idOf(L)||N.tagName!==E.tagName||L.tagName!==E.tagName||!ao(N,r,u,a)||!ao(L,r,u,a)||!ls(E,u,a)||!ls(N,u,a)||!ls(L,u,a))continue;let j=i(E,null,u),F=i(N,b,u),W=i(L,p.A,u),C=j.flat.text,T=F.flat.text,x=W.flat.text;if(a(u,C.length+T.length+x.length),!Sn.test(C)||!Sn.test(T)||!Sn.test(x)||C===T||C===x||T===x||!Vi(j,F,s,u,a)||!Vi(j,W,s,u,a))continue;let z=null,D=!1;for(let Me=R;Me<=S;Me++){a(u,1);let De=g.units[Me],re=g.baseOf(De);if(!re||re===E||c.has(re)||re.parentNode!==E.parentNode||De.parentNode!==N.parentNode||re.tagName!==E.tagName||De.tagName!==E.tagName||b.map.get(re)!==De||b.reverse.get(De)!==re||l(re)!==A(De)||!ao(re,r,u,a)||!ao(De,r,u,a))continue;let Se=i(re,null,u),qe=i(De,b,u),ve=Se.flat.text,w=qe.flat.text;if(a(u,ve.length),!Sn.test(ve)||w.length<=ve.length)continue;let K=s(qe,u),ne=Mn(ve,w,K,u,a,!0);if(!(ne<0||Mn(C,w,K,u,a,!0,ne,ne+ve.length)<0&&!ea({base:e,V:g,A:b,source:E,original:j,current:F,edited:W,destination:qe,at:ne,ownLength:ve.length,eligible:r,model:i,tokensOf:s,budget:u,charge:a}))){if(z){D=!0;break}z=De}}if(!z||D)continue;let V=t===0?N:L,Ee=t===0?L:N;(O||=[]).push({source:E,local:V,remote:Ee,models:[j,t===0?F:W,t===0?W:F]})}}catch(M){if(M!==h)throw M}return O}var Hn=/\S/,pn=/\s/,ta=/[\s\u001e]/g,cs=/[^\s\p{P}\u001e\ufffc]/u;function na(e,n,t,o,r,c,l){let i=0;for(let s of e)l(c,1),s.nodeType===1&&!o.baseOf(s)&&i++;if(i<2)return!1;for(let s of e){if(s.nodeType!==1||o.baseOf(s))continue;let a=r.get(s).flat;if(a.atoms.length||a.pins?.length)continue;l(c,a.text.length*2+n.length+t.length);let h=new Uint8Array(a.text.length);for(let f of t)f.target===s&&h.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f of n)f.target===s&&h.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f=0;f<a.text.length;f++)if(!h[f]&&Hn.test(a.text[f]))return!0}return!1}function oa(e,n,t){let{source:o,models:r,retained:c,runs:l}=e,i=r.get(o).flat.text;t(n,i.length*2+c.length+l.length);let s=new Uint8Array(i.length);for(let a of c)a.source===o&&(t(n,a.to-a.from),s.fill(1,a.from,a.to));for(let a of l)t(n,a.to-a.from),s.fill(1,a.from,a.to);for(let a=0;a<i.length;a++)if(!s[a]&&Hn.test(i[a]))return!1;return!0}function ra(e,n,t,o,r,c,l,i,s,a){let h=c.get(e),f=c.get(n),u=h.flat.text,g=l.get(e);s(a,u.length*2+t.length);let b=u.length,A=0;for(let y=0;y<u.length;y++)!pn.test(u[y])&&!g[y]&&(b=Math.min(b,y),A=y+1);if(b>=A)return null;for(let y=b;y<A;y++)if(!pn.test(u[y])&&g[y])return null;let p=-1;for(let y of t)if(y.target===n&&y.from<=b&&y.to>b){p=y.targetFrom+b-y.from;break}if(p<0)return null;let m=u.slice(b,A);if(s(a,m.length*(t.length+2)),f.flat.text.slice(p,p+m.length)!==m)return null;for(let y=b;y<A;y++){if(pn.test(u[y]))continue;let R=!1;for(let S of t)if(S.target===n&&S.from<=y&&S.to>y&&S.targetFrom+y-S.from===p+y-b){R=!0;break}if(!R)return null}if(h.flat.atoms.length||f.flat.atoms.length){s(a,h.flat.atoms.length+f.flat.atoms.length);let y=0,R=f.flat.atoms;for(;y<R.length&&R[y].i<p;)y++;for(let S of h.flat.atoms){if(S.i<b||S.i>=A)continue;let O=R[y++];if(!O||O.i!==p+S.i-b||f.alignment?.reverse.get(O.el)!==S.el)return null}if(y<R.length&&R[y].i<p+A-b)return null}for(let[y,R,S]of[[o,e,b],[r,n,p]]){let O=!1;for(let M of y){let E=c.get(M),N=l.get(M),L=i(E,a);for(let j=0;j<L.length;j++){let F=L[j].from,W=F+m.length;if(s(a,m.length*2+1),E.flat.text.slice(F,W)!==m)continue;let C=j;for(;C<L.length&&L[C].to<W;)s(a,1),C++;if(C===L.length||L[C].to!==W)continue;let T=!0;for(let x=F;x<W;x++)if(!pn.test(E.flat.text[x])&&N[x]){T=!1;break}if(T){if(O||M!==R||F!==S)return null;O=!0}}}if(!O)return null}return m}function sa(e,n,t,o,r,c,l,i){if(l(i,r.length+c.length+(o.length+1)*t.length*2),!t)return!1;let s=o.indexOf(t);return s<0||o.lastIndexOf(t)!==s||!c.some(a=>a.from===s)||!c.some(a=>a.to===s+t.length)?!1:r.some(a=>a.source===e&&a.target===n&&a.from===0&&a.to===t.length&&a.targetFrom===s)}function Fi({base:e,views:n,eligible:t,baseId:o,ignored:r,remoteWins:c,atomKey:l,limit:i=2e4*8}){if(i<=0)return null;let s=Symbol(),a=(S,O)=>{if(O>S.remaining)throw s;S.remaining-=O},h=[new Map,new Map];for(let S=0;S<2;S++)for(let O=0;O<n[S].V.units.length;O++)h[S].set(n[S].V.units[O],O);let f=new Int32Array(e.length),u=new Int32Array(e.length),g=S=>n.every(({V:O},M)=>{let E=O.twin(S);return E&&h[M].has(E)}),b=-1;for(let S=0;S<e.length;S++)f[S]=b,g(e[S])&&(b=S);b=e.length;for(let S=e.length-1;S>=0;S--)u[S]=b,g(e[S])&&(b=S);let A=new Map,p=(S,O)=>{if(a(O,1),A.has(S))return A.get(S);let M=S.firstChild,E=1;for(;M;){if(a(O,E*8+8),M.nodeType===3&&a(O,M.data.length*8),M.nodeType===1&&wn.has(M.tagName)&&!r(M)&&!c(M)&&M.firstChild){M=M.firstChild,E++;continue}for(;M&&M!==S&&!M.nextSibling;)M=M.parentNode,E--;M=!M||M===S?null:M.nextSibling}let N=en(Array.from(S.childNodes),{ignored:r,remoteWins:c});return A.set(S,N),N},m=(S,O,M,E,N,L)=>{for(let j of S.atoms){a(L,1);let F=O.atomAt.get(j.i+M);if(!F)return!1;let W=E?.reverse.get(j.el)||l(j.el),C=N?.reverse.get(F.el)||l(F.el);if(W!==C)return!1}return!0},y=(S,O,M,E,N)=>{let L=S.text.length<=O.text.length?S:O,j=L===S?O:S;if(a(N,L.text.length+j.text.length),!L.text||!Hn.test(L.text.replaceAll(Bn,"")))return!1;let F;if(L.text===j.text)F=0;else{let W=j.text.length-L.text.length;if(a(N,(W+1)*L.text.length*2),j.text.startsWith(L.text))F=0;else if(j.text.endsWith(L.text))F=W;else return!1;if(j.text.indexOf(L.text)!==F||j.text.lastIndexOf(L.text)!==F)return!1;a(N,j.text.length*2);let C=0,T=F===0,x=!1;for(let z of ln(j.text,yn(j.text)))C+=z.len,C===F&&(T=!0),C===F+L.text.length&&(x=!0);if(!T||!x)return!1}return L===S?m(L,j,F,M,E,N):m(L,j,F,E,M,N)},R=null;for(let S=0;S<2;S++){let{V:O,A:M,idOf:E}=n[S],N=n[1-S];if(!O.asBase)for(let L=0;L<e.length;L++){let j=e[L];if(O.twin(j)||!t(j))continue;let F=N.V.twin(j);if(!F||!h[1-S].has(F)||!t(F))continue;let W={remaining:i};try{let C=f[L],T=u[L],x=0;for(let Ee=C+1;Ee<T;Ee++)a(W,1),!O.twin(e[Ee])&&N.V.twin(e[Ee])&&t(e[Ee])&&x++;if(x!==1||p(j,W).text===p(F,W).text)continue;let z=C<0?-1:h[S].get(O.twin(e[C])),D=T===e.length?O.units.length:h[S].get(O.twin(e[T]));if(z===void 0||D===void 0||z>=D)continue;let V=null;for(let Ee=z+1;Ee<D;Ee++){a(W,1);let Me=O.units[Ee];if(O.baseOf(Me)||!t(Me)||Me.tagName!==j.tagName||Me.namespaceURI!==j.namespaceURI)continue;let De=o(j),re=N.idOf(F),Se=E(Me);if(!(De&&re&&De!==re||De&&Se&&De!==Se||re&&Se&&re!==Se)&&y(p(F,W),p(Me,W),N.A,M,W)){if(V){V=null;break}V=Me}}if(!V)continue;R||(R=[new Map,new Map]),R[S].set(j,V)}catch(C){if(C!==s)throw C}}}return R?n.map(({V:S},O)=>{let M=R[O];if(!M.size)return S;let E=new Map;for(let[N,L]of M)E.set(L,N);return{...S,twin:N=>M.get(N)||S.twin(N),baseOf:N=>E.get(N)||S.baseOf(N)}}):null}function $i({onUncertainSource:e,onUncertainOwner:n,base:t,views:o,eligible:r,ignored:c,remoteWins:l,baseId:i,atomKey:s,limit:a=2e4*32}){if(a<=0)return null;let h=new Set(t),f=new Map(t.map((C,T)=>[C,T])),u=new Map,g=[],b=null,A=null,p=null,m=new Set;for(let C of t)for(let{V:T}of o){let x=T.twin(C);x&&!T.asBase&&!T.here(x)&&m.add(C)}let y=new Set,R=Symbol(),S=(C,T)=>{if(T>C.remaining)throw R;C.remaining-=T},O=(C,T,x)=>{S(x,1);let z=u.get(C);if(z)return z;if(C.nodeType===1){let Ee=C.firstChild,Me=1;for(;Ee;){if(S(x,Me*8+8),Ee.nodeType===3&&S(x,Ee.data.length*8),Ee.nodeType===1&&wn.has(Ee.tagName)&&!c(Ee)&&!l(Ee)&&Ee.firstChild){Ee=Ee.firstChild,Me++;continue}for(;Ee&&Ee!==C&&!Ee.nextSibling;)Ee=Ee.parentNode,Me--;Ee=!Ee||Ee===C?null:Ee.nextSibling}}else S(x,C.value.length*8+C.nodes.length);let D=C.nodeType===1?Array.from(C.childNodes):C.nodes,V=D.length===1&&D[0].nodeType===3?{text:D[0].data,nodes:[{node:D[0],s:0,e:D[0].data.length}],atoms:[]}:en(D,{ignored:c,remoteWins:l});return z={unit:C,flat:V,alignment:T,tokens:null},u.set(C,z),z},M=(C,T)=>{if(C.tokens)return C.tokens;S(T,C.flat.text.length*8);let{unit:x,flat:z,alignment:D}=C,V=[],Ee=yn(z.text),Me=0,De=re=>{for(let Se of ln(z.text.slice(Me,re),Ee))Se.from=Me,Se.to=Me+Se.len,Se.unit=x,V.push(Se),Me+=Se.len};for(let re of z.atoms){De(re.i);let Se=l(re.el)&&re.el.nodeType===1?"w"+re.el.tagName+"#"+(re.el.id||""):s(D?.reverse.get(re.el)||re.el);V.push({k:Se,raw:Bn,len:1,from:Me,to:Me+1,unit:x,atom:!0}),Me++}return De(z.text.length),C.tokens=V,V},E=(C,T,x,z,D)=>{if(!C.flat.atoms.length&&!T.flat.atoms.length)return!0;let V=M(C,D),Ee=M(T,D);S(D,V.length+Ee.length);let Me=0;for(let De of Ee){if(!De.atom||De.from<x||De.from>=x+z)continue;for(;Me<V.length&&!V[Me].atom;)Me++;let re=V[Me++];if(!re||re.from!==De.from-x||re.k!==De.k)return!1}for(;Me<V.length;)if(V[Me++].atom)return!1;return!0},N=(C,T,x)=>{let z=C.length+T.length+4;if(z*8>x.remaining)return null;x.remaining-=z*8;let D=Math.floor(x.remaining/8),V=Math.min(C.length+T.length,4e3,Math.floor((Math.sqrt(z*z+D)-z)/2)),Ee=4*(V+1)*(z+V+1);if(V<1||Ee>x.remaining)return null;x.remaining-=Ee;let Me=Kn(C,T,V),De=[],re=0,Se=0;for(let qe of Me.hunks){for(;re<qe.bs;)C[re].raw===T[Se].raw&&De.push([C[re],T[Se]]),re++,Se++;re=qe.be,Se+=qe.toks.length}for(;re<C.length&&Se<T.length;)C[re].raw===T[Se].raw&&De.push([C[re],T[Se]]),re++,Se++;return De},L=(C,T,x,z,D,V,Ee)=>{if(D<=z)return;let Me=C[C.length-1];if(Me&&Me.source===T&&Me.target===x&&Me.to<=z&&Me.targetFrom-Me.from===V-z){S(Ee,(z-Me.to)*3);let De=u.get(T).flat.text,re=u.get(x).flat.text,Se=!0;for(let qe=Me.to;qe<z;qe++)if(!pn.test(De[qe])||De[qe]!==re[V+qe-z]){Se=!1;break}if(Se){Me.to=D;return}}C.push({source:T,target:x,from:z,to:D,targetFrom:V})},j=C=>C.replace(ta,"");for(let C=0;C<o.length;C++){let{V:T,A:x,idOf:z}=o[C];if(T.asBase)continue;let D=new Map(T.units.map((w,K)=>[w,K])),V=w=>{let K=T.twin(w);return K&&D.has(K)?K:null},Ee=(w,K)=>{let ne=new Int32Array(w.length),ee=new Int32Array(w.length),Pe=-1;for(let _e=0;_e<w.length;_e++)ne[_e]=Pe,K(w[_e])&&(Pe=_e);Pe=w.length;for(let _e=w.length-1;_e>=0;_e--)ee[_e]=Pe,K(w[_e])&&(Pe=_e);return{prev:ne,next:ee}},Me=Ee(t,w=>(w.nodeType===1||w.kind==="text"&&Hn.test(w.value))&&V(w)),De=Ee(T.units,w=>(w.nodeType===1||w.kind==="text"&&Hn.test(w.value))&&h.has(T.baseOf(w))),re=new Map,Se=(w,K,ne,ee)=>{if(w>K||ne>ee)return;let Pe=`${w}:${K}:${ne}:${ee}`;re.set(Pe,[w,K,ne,ee])};for(let w=0;w<T.units.length;w++){let K=T.units[w];if(T.baseOf(K)||!r(K))continue;let ne=De.prev[w],ee=De.next[w],Pe=ne<0?0:f.get(T.baseOf(T.units[ne])),_e=ee===T.units.length?t.length-1:f.get(T.baseOf(T.units[ee]));Se(Pe,_e,Math.max(0,ne),Math.min(T.units.length-1,ee))}for(let w=0;w<t.length;w++){let K=t[w];if(m.has(K)||!r(K))continue;if(!T.twin(K)){let ot=Me.prev[w],Qe=Me.next[w],Ze=ot<0?0:D.get(V(t[ot])),Xe=Qe===t.length?T.units.length-1:D.get(V(t[Qe]));Se(Math.max(0,ot),Math.min(t.length-1,Qe),Ze,Xe)}let ne=V(K);if(!ne||x.identical.has(K)||!r(ne))continue;let ee=w+1;for(;ee<t.length&&t[ee].kind==="text"&&!t[ee].value.trim();)ee++;if(ee>=t.length||!r(t[ee]))continue;let Pe=V(t[ee]);if(!Pe||x.identical.has(t[ee])||!r(Pe))continue;let _e=D.get(ne),Ae=D.get(Pe);_e<Ae&&Se(w,ee,_e,Ae)}let qe=Array.from(re.values()),ve=new Set;if(qe.length>1){let w=Kt(a);try{S(w,qe.length*4);let K=qe.slice().sort((Pe,_e)=>(S(w,1),Pe[0]-_e[0]||Pe[2]-_e[2])),ne=[],ee=null;for(let Pe of K)S(w,1),ee&&Pe[0]<=ee[1]&&Pe[2]<=ee[3]&&Pe[3]>=ee[2]?(ee[1]=Math.max(ee[1],Pe[1]),ee[2]=Math.min(ee[2],Pe[2]),ee[3]=Math.max(ee[3],Pe[3]),ee[4].push(Pe)):(ee?.[4].length>1&&ne.push(ee),ee=[Pe[0],Pe[1],Pe[2],Pe[3],[Pe]]);ee?.[4].length>1&&ne.push(ee),qe=ne.concat(qe)}catch(K){if(K!==R)throw K}}for(let w of qe){if(ve.has(w))continue;let[K,ne,ee,Pe,_e]=w,Ae=Kt(a),ot=[],Qe=new Set,Ze=!1;try{S(Ae,(ne-K+Pe-ee+2)*4);let Xe=t.slice(K,ne+1).filter(Z=>!x.identical.has(Z)&&r(Z)&&!m.has(Z)),yt=T.units.slice(ee,Pe+1).filter(Z=>r(Z)&&(!T.baseOf(Z)||h.has(T.baseOf(Z)))&&!x.identical.has(T.baseOf(Z))&&!m.has(T.baseOf(Z))),dt=new Set(yt),gt=!1,qt="",$t="",Ht=0;for(let Z of Xe){let Oe=O(Z,null,Ae);qt+=Oe.flat.text,Ht+=Oe.flat.text.length}for(let Z of yt){let Oe=O(Z,x,Ae);$t+=Oe.flat.text,Ht+=Oe.flat.text.length}S(Ae,Ht);let jt=j(qt),an=j($t),_t=jt===an;if(Ze=_t,_e&&!_t)continue;let zt=_t?null:new Map;if(zt)for(let Z of Xe.concat(yt)){let Oe=u.get(Z).flat.text.length;S(Ae,Oe*16),zt.set(Z,new Uint8Array(Oe))}let _=Z=>{let Oe=[];for(let He of Z){let Ie=u.get(He);Ie.flat.atoms.length?Oe.push(...M(Ie,Ae)):Oe.push({unit:He,raw:Ie.flat.text,from:0})}return Oe},ie=[];for(let Z of _t?[]:Xe){let Oe=V(Z);if(!dt.has(Oe))continue;let He=O(Z,null,Ae),Ie=O(Oe,x,Ae);S(Ae,He.flat.text.length+Ie.flat.text.length);let ge=He.flat.text&&Ie.flat.text.startsWith(He.flat.text)?0:He.flat.text&&Ie.flat.text.endsWith(He.flat.text)?Ie.flat.text.length-He.flat.text.length:-1;if(ge>=0&&E(He,Ie,ge,He.flat.text.length,Ae)){zt.get(Z).fill(1),zt.get(Oe).fill(1,ge,ge+He.flat.text.length),L(ie,Z,Oe,0,He.flat.text.length,ge,Ae);continue}let B=N(M(He,Ae),M(Ie,Ae),Ae);if(!B){gt=!0;break}for(let[G,ue]of B)zt.get(Z).fill(1,G.from,G.to),zt.get(Oe).fill(1,ue.from,ue.to),L(ie,Z,Oe,G.from,G.to,ue.from,Ae)}if(gt)continue;let me=null,pe=null;if(!_t)for(let Z of Xe){let Oe=V(Z),He=u.get(Z);if(!Oe||He.flat.atoms.length||!dt.has(Oe))continue;let Ie=He.flat.text,ge=zt.get(Z);S(Ae,Ie.length*3+yt.length);let B=-1,G=-1,ue=!1;for(let We=0;We<Ie.length;We++)pn.test(Ie[We])||(ge[We]?ue=!0:(B<0&&(B=We),G=We+1));if(!ue||B<0)continue;let he=!0;for(let We=B;We<G;We++)if(ge[We]&&!pn.test(Ie[We])){he=!1;break}if(!he)continue;let ce=j(Ie.slice(B,G)),xe=null,te=!1;for(let We of yt){if(T.baseOf(We))continue;let Ne=u.get(We);if(!Ne.flat.atoms.length&&(S(Ae,Ne.flat.text.length),j(Ne.flat.text)===ce)){if(xe){te=!0;break}xe=We}}if(te){(pe||=new Set).add(Z);continue}if(!xe||pe?.has(Z))continue;let q=!1;for(let We of Xe){if(We===Z||!dt.has(V(We)))continue;let Ne=u.get(We);if(Ne.flat.atoms.length)continue;let ze=zt.get(We);S(Ae,Ne.flat.text.length*3);let tt="",k=!1;for(let $=0;$<Ne.flat.text.length;$++)pn.test(Ne.flat.text[$])||(ze[$]?k=!0:tt+=Ne.flat.text[$]);k&&tt===ce&&(pe||=new Set,pe.add(Z),pe.add(We),q=!0)}if(q)continue;let ae=u.get(xe).flat.text;S(Ae,G-B+ae.length);let Ce=B,Le=0;for(;Ce<G&&Le<ae.length;){for(;Ce<G&&pn.test(Ie[Ce]);)Ce++;for(;Le<ae.length&&pn.test(ae[Le]);)Le++;if(Ce>=G||Le>=ae.length)break;L(me||=[],Z,xe,Ce,Ce+1,Le,Ae),Ce++,Le++}ge.fill(1,B,G),zt.get(xe).fill(1)}let ke=Z=>{let Oe=[];for(let He of Z){let Ie=O(He,h.has(He)?null:x,Ae),ge=zt.get(He);for(let B of M(Ie,Ae)){let G=B.from;for(;G<B.to;){for(;G<B.to&&ge[G];)G++;let ue=G;for(;G<B.to&&!ge[G];)G++;if(G>ue){let he=Ie.flat.text.slice(ue,G);Hn.test(he)&&Oe.push({...B,raw:he,len:G-ue,k:B.atom?B.k:he,from:ue,to:G})}}}}return Oe},v=_t?_(Xe):ke(Xe),P=_t?_(yt):ke(yt),Y=_t?jt:v.map(Z=>j(Z.raw)).join(""),J=_t?an:P.map(Z=>j(Z.raw)).join("");if((!Y||!J)&&!me)continue;let oe=me||[];if(Y&&J&&Y===J){let Z=0,Oe=0,He=0,Ie=0;for(;Z<v.length&&Oe<P.length;){let ge=v[Z],B=P[Oe];for(;He<ge.raw.length&&pn.test(ge.raw[He]);)He++;for(;Ie<B.raw.length&&pn.test(B.raw[Ie]);)Ie++;if(He===ge.raw.length){Z++,He=0;continue}if(Ie===B.raw.length){Oe++,Ie=0;continue}if((ge.atom||B.atom)&&ge.k!==B.k){gt=!0;break}L(oe,ge.unit,B.unit,ge.from+He,ge.from+He+1,B.from+Ie,Ae),He++,Ie++}}else if(Y&&J){let Z=N(v,P,Ae);if(!Z)continue;for(let[Oe,He]of Z)L(oe,Oe.unit,He.unit,Oe.from,Oe.to,He.from,Ae)}if(gt)continue;let je=new Map;for(let Z of oe)if(!pe?.has(Z.source)){if(V(Z.source)===Z.target){_t&&ie.push(Z);continue}je.has(Z.source)||je.set(Z.source,[]),je.get(Z.source).push(Z)}for(let[Z,Oe]of je){let He=O(Z,null,Ae),Ie=V(Z),ge=He.flat.text,B=[],G=new Set,ue=o[1-C],he=ue.V.twin(Z),ce=he&&ue.V.here(he)?O(he,ue.A,Ae):null,xe=(Ne,ze)=>{let tt=M(Ne,Ae),k=M(ze,Ae);return S(Ae,Ne.flat.text.length+ze.flat.text.length+tt.length+k.length),Ne.flat.text===ze.flat.text&&tt.length===k.length&&tt.every(($,Q)=>$.k===k[Q].k)},te=Ie&&ce&&ce.flat.text!==ge&&xe(O(Ie,x,Ae),ce);for(let Ne of new Set(Oe.map(ze=>ze.target))){if(Z.nodeType!==1&&Ne.nodeType!==1)continue;let ze=O(Ne,x,Ae),tt=T.baseOf(Ne);if(Z.nodeType!==1&&tt||(S(Ae,ge.length*2+ze.flat.text.length*3+ie.length*2),Ie&&j(ge)===j(ze.flat.text)&&O(Ie,x,Ae).flat.text.trim()))continue;if(!Ie&&!tt&&Z.nodeType===1&&Ne.nodeType===1){let fe=i(Z),se=z(Ne);if(fe&&se&&fe!==se)continue}let k=ze.flat.text,$=ge&&(k.startsWith(ge)||k.endsWith(ge)),Q=!1;if(!Ie&&ce&&tt&&ce.flat.text!==ge){let fe=O(tt,null,Ae).flat.text,se=f.get(Z)<f.get(tt)?ce.flat.text:fe,le=f.get(Z)<f.get(tt)?fe:ce.flat.text;S(Ae,se.length+le.length+k.length),Q=!!se&&!!le&&se.length+le.length<=k.length&&k.startsWith(se)&&k.endsWith(le)&&!k.slice(se.length,k.length-le.length).trim()}let be=!He.flat.atoms.length&&!ce?.flat.atoms.length&&!ze.flat.atoms.length&&(te&&$||Q);if(Ie&&tt){let fe=O(Ie,x,Ae).flat.text,se=ge.startsWith(fe)||ge.endsWith(fe),le=O(tt,null,Ae).flat.text,Be=ze.flat.text,Ke=Be.startsWith(le)||Be.endsWith(le),Ue=!o[1-C].V.twin(tt)&&!ie.some($e=>$e.source===tt&&Hn.test(le.slice($e.from,$e.to)));if(!_t&&(!se&&!be||!Ke&&!Ue)){let $e=ra(Z,Ne,Oe,Xe,yt,u,zt,M,S,Ae);if(!$e)continue;let Ge=x.weak?.has(Z)&&!x.identityPaired?.has(Z)&&ge.trim()===$e;if(!se&&!be&&!Ge)continue;let et=x.weak?.has(tt)&&!x.identityPaired?.has(tt)&&k.trim()===$e&&!u.get(tt).flat.atoms.length&&!ie.some(Ot=>Ot.source===tt&&Hn.test(le.slice(Ot.from,Ot.to)));if(!Ke&&!Ue&&!et&&!sa(tt,Ne,le,k,ie,M(ze,Ae),S,Ae))continue;Ge&&G.add(Ne)}}be&&G.add(Ne),S(Ae,Oe.length),B.push(...Oe.filter(fe=>fe.target===Ne))}if(!B.length)continue;let q=new Uint8Array(ge.length);S(Ae,ge.length*4+ie.length);for(let Ne of B)q.fill(1,Ne.from,Ne.to);let ae=[];for(let Ne=0;Ne<ge.length;Ne++)pn.test(ge[Ne])||ae.push(Ne);if(!ae.length)continue;let Ce=new Set(B.map(Ne=>Ne.target));if(!_t&&Ie&&Ce.size>1&&na(Ce,oe,ie,T,u,Ae,S)){if(p||=new Map,p.set(Z,(p.get(Z)||0)|1<<C),e){let Ne=es({source:Z,side:C,views:o,eligible:r,blocked:m,baseId:i,model:O,tokensOf:M,budget:Ae,charge:S});if(Ne){S(Ae,Ne.to-Ne.from);let ze=!0;for(let tt=Ne.from;tt<Ne.to;tt++)if(Hn.test(ge[tt])&&!q[tt]){ze=!1;break}ze&&(b||=[]).push(Ne)}}continue}let Le=ae.filter(Ne=>cs.test(ge[Ne]));if(!B.some(Ne=>cs.test(ge.slice(Ne.from,Ne.to)))&&!ae.every(Ne=>q[Ne]))continue;if(!Ie&&!Array.from(Ce).some(Ne=>G.has(Ne))&&!ae.every(Ne=>q[Ne])&&!(Le.length&&q[Le[0]]&&q[Le[Le.length-1]]&&Ce.size===1)){let Ne=null,ze=0,tt=0,k=null,$=null;if(!Ie&&ce&&Z.nodeType===1&&!He.flat.atoms.length){let Q=M(He,Ae).filter(be=>cs.test(be.raw));S(Ae,yt.length+ge.length);for(let be of yt){let fe=T.baseOf(be);if(!fe||fe===Z||fe.nodeType!==1||be.nodeType!==1||fe.tagName!==Z.tagName||be.tagName!==fe.tagName)continue;let se=f.get(Z),le=f.get(fe),Be=!0;for(let Jt=Math.min(se,le)+1;Jt<Math.max(se,le);Jt++){let Mt=t[Jt];if(S(Ae,Mt.nodeType===1?1:Mt.value.length+1),Mt.nodeType===1||Mt.value.trim()){Be=!1;break}}if(!Be)continue;let Ke=O(fe,null,Ae),Ue=O(be,x,Ae);if(Ke.flat.atoms.length||Ue.flat.atoms.length)continue;let $e=Ke.flat.text,Ge=Ue.flat.text;if(S(Ae,$e.length+Ge.length+ge.length),!$e||!Q.length)continue;let et=0,Ot=Ge.length;if(se<le&&Ge.endsWith($e))Ot-=$e.length;else if(se>le&&Ge.startsWith($e))et=$e.length;else continue;for(;et<Ot&&pn.test(Ge[et]);)et++;for(;Ot>et&&pn.test(Ge[Ot-1]);)Ot--;let xt=Ge.slice(et,Ot);if(!(!xt||!(xt.startsWith(Q[0].raw)||xt.endsWith(Q[Q.length-1].raw)))){if(Ne){Ne=null;break}Ne=be,ze=et,tt=Ot,k=Q[0],$=Q[Q.length-1]}}}if(S(Ae,B.length),!Ne||!Ce.has(Ne)||!B.some(Q=>Q.target===Ne&&(Q.from<=k.from&&Q.to>=k.to&&Q.targetFrom+k.from-Q.from===ze||Q.from<=$.from&&Q.to>=$.to&&Q.targetFrom+$.to-Q.from===tt)))continue}if(Ie&&!(ae.every(Ne=>q[Ne])&&(_t||Array.from(Ce).some(Ne=>G.has(Ne))))&&!ie.some(Ne=>Ne.source===Z&&Hn.test(ge.slice(Ne.from,Ne.to))))continue;let We=!1;if(_t){S(Ae,ie.length+ae.length);for(let Ne of ie)Ne.source===Z&&(S(Ae,Ne.to-Ne.from),q.fill(1,Ne.from,Ne.to));We=!0;for(let Ne of ae)if(!q[Ne]){We=!1;break}}for(let Ne of Ce){S(Ae,B.length);let ze=B.filter(k=>k.target===Ne);ot.push({side:C,source:Z,target:Ne,runs:ze,models:u,retained:ie,conservedSource:We}),Z.nodeType===1&&Qe.add(Z),Ne.nodeType===1&&Qe.add(Ne);let tt=T.baseOf(Ne);tt?.nodeType===1&&Qe.add(tt)}}if(g.push(...ot),_e&&ot.length)for(let Z of _e)ve.add(Z);for(let Z of Qe)y.add(Z)}catch(Xe){if(Xe!==R)throw Xe}finally{if(n&&!_e&&!Ze){let Xe=_i({base:t,views:o,side:C,attempt:w,eligible:r,blocked:m,baseId:i,model:O,tokensOf:M,charge:S,exhausted:R,limit:a});Xe&&(A||=[]).push(...Xe)}if(e&&!_e&&!Ze){let Xe=ai({base:t,views:o,side:C,attempt:w,eligible:r,blocked:m,baseId:i,model:O,tokensOf:M,certificates:g,charge:S,exhausted:R,limit:a});Xe&&(b||=[]).push(...Xe)}}}}let F=g.length?new Map:null;for(let C of g){let T=F.get(C.source);T||F.set(C.source,T=[]),T.push(C)}let W=null;if(F){let C=null;for(let[T,x]of F){let z=p?.get(T)||0;if(x.length<2&&!z)continue;let D=0;for(let V of x)V.conservedSource&&(D|=1<<V.side);for(let V of x){if(V.conservedSource)continue;let Ee=1<<V.side,Me=!0;if(D&Ee)Me=!1;else if(z&Ee){Me=!1;try{Me=oa(V,C||=Kt(a),S)}catch(De){if(De!==R)throw De}}Me||(W||=new Set).add(V)}}}if(W){let C=0;for(let T of g)W.has(T)||(g[C++]=T);g.length=C;for(let[T,x]of F){C=0;for(let z of x)W.has(z)||(x[C++]=z);x.length=C,C||F.delete(T)}y.clear();for(let T of g){let{source:x,target:z,side:D}=T;x.nodeType===1&&y.add(x),z.nodeType===1&&y.add(z);let V=o[D].V.baseOf(z);V?.nodeType===1&&y.add(V)}}if(b){let C=Kt(a),T=!1;for(let x of b){let z=!1,D=F?.get(x.source);if(D&&!T)try{z=Zr(x,D,C,S)}catch(V){if(V!==R)throw V;T=!0}z||e(x)}}if(A){let C=new Set,T=Kt(a);try{for(let x of A){if(S(T,1),C.has(x.source))continue;C.add(x.source);let z=!1;for(let D of g)if(S(T,1),D.source===x.source||D.target===x.local||D.target===x.remote){z=!0;break}z||n(x)}}catch(x){if(x!==R)throw x}}for(let C of t)if(y.has(C))for(let{V:T}of o){let x=T.twin(C);x&&T.here(x)&&y.add(x)}return g.length?{blocks:y,certificates:g,certificatesBySource:F,models:u}:null}function Ki({certificates:e,scopes:n,flats:t,keys:o,limit:r=2e4*32}){let c=Symbol(),l=Kt(r),i=p=>{if(p>l.remaining)throw c;l.remaining-=p},s=n.map(p=>new Set(p)),a=new Map,h=new Map,f=(p,m)=>{let y=a.get(p);if(y||a.set(p,y=new Map),y.has(m))return y.get(m);i(p.text.length);let R=h.get(m);if(!R){i(m.nodes.length+m.atoms.length),R={nodes:new Map,atoms:new Map};for(let E of m.nodes)R.nodes.set(E.node,E);for(let E of m.atoms)R.atoms.set(E.el,E.i);h.set(m,R)}let{nodes:S,atoms:O}=R,M=new Int32Array(p.text.length).fill(-1);for(let E of p.nodes){let N=S.get(E.node);if(!(!N||E.e-E.s!==N.e-N.s)){i(E.e-E.s);for(let L=E.s;L<E.e;L++)M[L]=N.s+L-E.s}}for(let E of p.atoms){let N=O.get(E.el);N!==void 0&&(M[E.i]=N)}return y.set(m,M),M},u=(p,m,y,R,S)=>{let O=p[p.length-1];O&&O.to===m&&O.target+O.to-O.from===R&&O.kind===S?O.to=y:p.push({from:m,to:y,target:R,kind:S})},g=(p,m,y,R)=>{i((R-y)*4);let S=[],O=y,M=L=>{let j=p.text.slice(O,L);for(let F of ln(j,yn(j)))F.from=O,F.to=O+F.len,S.push(F),O+=F.len},E=0,N=p.atoms.length;for(;E<N;){i(1);let L=E+N>>>1;p.atoms[L].i<y?E=L+1:N=L}for(let L=E;L<p.atoms.length&&p.atoms[L].i<R;L++){i(1);let j=p.atoms[L];M(j.i),S.push({k:m(j),raw:Bn,len:1,from:O,to:O+1}),O++}return M(R),S},b=(p,m,y,R,S,O)=>{if(y===R||S===O)return;if(R-y===O-S){i((R-y)*4);let T=!0;for(let x=y,z=S;x<R;x++,z++){if(t[0].text[x]!==t[m].text[z]){T=!1;break}let D=t[0].atomAt.get(x),V=t[m].atomAt.get(z);if(!!D!=!!V||D&&o[0](D)!==o[m](V)){T=!1;break}}if(T){u(p,y,R,S,"retained");return}}let M=g(t[0],o[0],y,R),E=g(t[m],o[m],S,O),N=M.length+E.length+4,L=Math.min(M.length+E.length,4e3,Math.floor((Math.sqrt(N*N+l.remaining/2)-N)/2));if(L<1)throw c;i(4*(L+1)*(N+L+1));let j=Kn(M,E,L),F=0,W=0,C=()=>{let T=M[F++],x=E[W++];i(T.len),T.raw===x.raw&&u(p,T.from,T.to,x.from,"retained")};for(let T of j.hunks){for(;F<T.bs;)C();F=T.be,W+=T.toks.length}for(;F<M.length&&W<E.length;)C()},A=p=>{let m=e.filter(j=>j.side===p-1&&s[0].has(j.source)&&s[p].has(j.target));if(!m.length)return null;let y=[],R=(j,F,W)=>{if(!s[0].has(j.source)||!s[p].has(j.target))return;let C=f(F.get(j.source).flat,t[0]),T=f(F.get(j.target).flat,t[p]);i(j.to-j.from);for(let x=0;x<j.to-j.from;x++){let z=C[j.from+x],D=T[j.targetFrom+x];if(z<0||D<0)throw c;u(y,z,z+1,D,W)}},S=new Set;for(let j of m){if(!S.has(j.retained)){S.add(j.retained);for(let F of j.retained)R(F,j.models,"retained")}for(let F of j.runs)R(F,j.models,"transfer")}y.sort((j,F)=>(i(1),j.from-F.from||j.target-F.target));let O=[];for(let j of y){i(1);let F=O[O.length-1];if(F&&j.from<F.to){if(j.target-j.from!==F.target-F.from)throw c;F.to=Math.max(F.to,j.to),j.kind==="transfer"&&(F.kind="transfer")}else O.push(j)}let M=[],E=0,N=0;for(let j of O){if(j.target<N)throw c;b(M,p,E,j.from,N,j.target),M.push(j),E=j.to,N=j.target+j.to-j.from}b(M,p,E,t[0].text.length,N,t[p].text.length);let L=Dn({base:t[0],side:t[p],retained:M.filter(j=>j.kind==="retained"),transfers:M.filter(j=>j.kind==="transfer"),baseAtomKey:o[0],sideAtomKey:o[p],budget:l});if(L.status!=="ready"||!L.monotone)throw c;return L};try{let p=A(1),m=A(2);return p||m?{local:p,remote:m}:{fallback:!0}}catch(p){if(p!==c)throw p;return{fallback:!0}}}function as(e,n,t=!1){let o=-1,r=-1;for(let l=0;l<e.list.length;l++){let i=e.list[l];i.bLo<n.lo||i.bLo>n.hi||(o<0&&(o=l),r=l)}let c=[];for(let l=o;l>=0&&l<=r;l++){let i=e.list[l],s=!t&&l===o?i.inlineStart<0?i.to:i.inlineStart:i.from,a=!t&&l===r?i.inlineEnd<0?i.from:i.inlineEnd:i.to;for(let h=s;h<a;h++)c.push(e.units[h]);l<r&&c.push(e.units[i.next])}return c}var ut=e=>!!e&&e.nodeType===1,In=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function fs(e){for(let n of e)if(In.has(n.tagName))return!0;return!1}function ia(e,n,t){let o=null;for(let r of n.childNodes)if(!(!ut(r)||!t(r)||!r.isEqualNode(e))){if(o)return null;o=r}if(!o)return null;for(let r of e.parentNode.childNodes)if(r!==e&&r.isEqualNode(e))return null;return o}var $o="[id],[data-id],script,head>*";function us(e,n){return t=>{if(e!==null&&t.tagName==="SCRIPT"){let o=So(t,e);if(o)return"merge:"+o.key}return t.parentElement&&t.parentElement.tagName==="HEAD"?vi(t,n):null}}function Nr(e,n,t,o){let r=o.ignored,c=o.stats||Xn(),l=ri({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:c}),{unitsOf:i,meta:s}=l,a=o.baseURI,h=o.mergeTags!==null,f=us(o.mergeTags,a),u=k=>$=>{let Q=f($);return Q!==null?Q:k($)},g=u(o.identity.base),b=u(o.identity.local),A=u(o.identity.remote),p=o.authored||o.identity,m=k=>k&&k.nodeType===9?k.documentElement:k,y=m(e),R=m(n),S=m(t),O=globalThis.__hyperMorphProfile,M=O?performance.now():0,E=k=>k===bn?$o:null,N=o.scope||null,L=N?N.baseDropped:new Set,j=new Set,F=N?N.remoteDropped:new Set,W=N?N.baseIndex:mr(y,g,r,E(o.identity.base),L),C=o.localIsBase||y===R?null:mr(R,b,r,E(o.identity.local),j),T=N?N.remoteIndex:mr(S,A,r,E(o.identity.remote),F),x=k=>{let $=ut(k)&&b(k);return $&&C?.get($)===k&&!W.has($)?$:null},z=k=>{let $=ut(k)&&A(k);return $&&T.get($)===k&&!W.has($)?$:null},D=C?$r(y,R,{analyzer:l,baseIndex:W,sideIndex:C,baseId:p.base,sideId:p.local,baseKey:g,sideKey:b,baseDropped:L,sideDropped:j,stats:c}):zi(),V=$r(y,S,{analyzer:l,baseIndex:W,sideIndex:T,baseId:p.base,sideId:p.remote,baseKey:g,sideKey:A,baseDropped:L,sideDropped:F,stats:c,scope:N,comparisons:o.comparisons});if(N){if(!N.held(V))return null;for(let k of N.dropped)_r(k)}let Ee=null;function Me(k){if(!Ee){Ee=new WeakMap;let $=[y];for(;$.length;){let Q=$.pop();Q.tagName==="TEMPLATE"&&Q.content&&Ee.set(Q.content,Q);for(let be of l.childrenOf(Q))be.nodeType===1&&$.push(be)}}return Ee.get(k)||null}let De=k=>{let $=ut(k)||k.nodeType?k.parentNode:k.parent;return $&&$.nodeType===11?Me($):$};if(V.moved.size){let k=!1;for(let $ of Array.from(V.moved))!ut($)||V.identityPaired.has($)||!p.base($)||pe(V,De($))||(V.unpair($),k=!0);k&&V.rematch()}ie(),me(D,V),me(V,D);for(let k of[D,V])if(k.refused)for(let $ of k.refused)k.moved.has($)||c.ambiguousMoves++;O&&(O.alignTotal=(O.alignTotal||0)+(performance.now()-M),M=performance.now());let re=y.ownerDocument.implementation.createHTMLDocument(""),Se=new WeakMap,qe=new WeakMap,ve=[],w=[],K=new Set,ne=[],ee=new Set,Pe=new Set,_e=new Set,Ae=new WeakMap,ot=null,Qe=o.conflicts||"remote",Ze=k=>ve.push(k),Xe=k=>ve.push(k),yt=Di({roots:{base:y,local:R,remote:S},L:D,R:V,unitsOf:i,provenance:Se,policy:Qe}),dt=(k,$)=>{w.push(k),$&&yt.note(k,$)},gt=null,qt=null,$t=zt(),Ht=null,jt=J(y,D.map.get(y),V.map.get(y),!!o.localIsBase,!!o.childrenOnly);jt.tagName==="HTML"?re.replaceChild(jt,re.documentElement):re.body.appendChild(jt),gt?.drain(jt),qt?.drain(jt),O&&(O.build=(O.build||0)+(performance.now()-M));let an=o.childrenOnly?!ae(te(jt),te(S)):!he(jt,S),_t=yt.finish(jt);return{doc:re,root:jt,provenance:Se,textMappers:qe,decisions:ve,conflicts:w,recoveryLinks:_t,localDiverged:an,mergedScripts:K,segments:ne,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==bn,L:D,R:V,stats:c};function zt(){let k=new Map,$=new Set;if(o.localIsBase||!D.insertedByHash)return{partner:k,drop:$};let Q=D.insertedByHash(),be=V.insertedByHash();if(!Q.size||!be.size)return{partner:k,drop:$};let fe={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},se=pt=>{let bt=0;for(let mt=pt.parentNode;mt;mt=mt.parentNode)bt++;return bt},le=[],Be=pt=>{let bt=pt.textContent.trim();return bt.split(/\s+/).length>=3||bt.replace(/\s/g,"").length>=12},Ke=pt=>{let bt=pe(D,pt),mt=pe(V,pt);return bt&&D.reverse.get(bt.parentNode)!==pt.parentNode||mt&&V.reverse.get(mt.parentNode)!==pt.parentNode},Ue=(pt,bt,mt)=>{for(let ct of mt.parentNode.children){let Wt=ct!==mt&&pt.reverse.get(ct);if(Wt&&Ke(Wt))return!0}let It=pt.reverse.get(mt.parentNode);if(It){for(let ct of It.children)if(!pe(bt,ct)&&!r(ct))return!0}return!1},$e=new Map([[D,new Map],[V,new Map]]),Ge=(pt,bt)=>{let mt=$e.get(pt),It=mt.get(bt);if(It===void 0){It=!1;for(let ct of bt.children)if(pt.reverse.has(ct)||Ge(pt,ct)){It=!0;break}mt.set(bt,It)}return It},et=new Map;for(let pt of be.values())for(let bt of pt){let mt=z(bt);mt&&et.set(mt,bt)}for(let pt of Q.values())for(let bt of pt){let mt=x(bt),It=mt?et.get(mt):null;It&&It.tagName===bt.tagName&&!Un(bt,fe)&&!Un(It,fe)&&!o.remoteWins(bt)&&!o.remoteWins(It)&&le.push([bt,[It],se(bt),!0,!0])}for(let[pt,bt]of Q){let mt=be.get(pt);if(!mt)continue;let It=bt.length===1&&mt.length===1;for(let ct of bt)!Un(ct,fe)&&!x(ct)&&le.push([ct,mt,se(ct),It&&(Be(ct)||Ue(D,V,ct)||Ue(V,D,mt[0]))])}if(!le.length)return{partner:k,drop:$};le.sort((pt,bt)=>pt[2]-bt[2]);let Ot=new Set,xt=new Set,Jt=pt=>{for(let bt of pt.querySelectorAll("*"))Ot.add(bt)},Mt=(pt,bt)=>pt.reverse.get(bt.parentNode)||null;for(let[pt,bt,,mt,It]of le){if(Ot.has(pt)||xt.has(pt)||It&&(Ge(D,pt)||Ge(V,bt[0])))continue;let ct=Mt(D,pt),Wt=Gt=>!xt.has(Gt)&&!Ot.has(Gt)&&(It||Gt.tagName===pt.tagName&&!z(Gt)&&l.equalUnits(pt,Gt)),St=bt.find(Gt=>ct&&Mt(V,Gt)===ct&&Wt(Gt))||(mt?bt.find(Wt):null);if(!St)continue;xt.add(pt),xt.add(St);let fn=ct&&Mt(V,St)===ct;(!It||!fn||l.equalUnits(pt,St))&&(Jt(pt),Jt(St)),!fn&&(k.set(pt,St),k.set(St,pt),$.add(Qe==="local"?St:pt))}return{partner:k,drop:$}}function _(k,$,Q){if(ee.add(k),$t.drop.has(k))return null;ee.add(Q);let be=$==="local"?k:Q,fe=$==="local"?Q:k,se;return l.equalUnits(be,fe)?(se=G(be,"local",!0),Se.get(se).remote=fe):se=B(be,fe),dt({kind:"structure",el:se,detail:"both-moved",base:null,local:be,remote:fe},{unit:{b:null,l:be,r:fe}}),Ze({kind:"insert",el:se,source:"both"}),se}function ie(){if(!D.weak||!V.weak||!D.weak.size||!V.weak.size||!D.unpair)return;let k=new Map;for(let Q of D.weak){let be=pe(D,Q);ut(Q)&&ut(be)&&k.set(l.unitHash(be),Q)}let $=!1;for(let Q of Array.from(V.weak)){let be=pe(V,Q);if(!ut(Q)||!ut(be))continue;let fe=k.get(l.unitHash(be));if(!fe||fe===Q||!D.weak.has(fe)||pe(D,Q)&&pe(V,fe))continue;let se=pe(D,fe);se.tagName===be.tagName&&l.equalUnits(se,be)&&(D.unpair(fe),V.unpair(Q),$=!0)}$&&(D.rematch(),V.rematch())}function me(k,$){if(!k.weak||!k.weak.size||!$.insertedByHash)return;let Q=$.insertedByHash();if(!Q.size)return;let be=!1;for(let fe of Array.from(k.weak)){let se=pe(k,fe);if(!se)continue;let le=k===D?x(se):z(se);if(le){let Ke=(k===D?T:C)?.get(le);Ke&&Ke.tagName===se.tagName&&!$.reverse.has(Ke)&&(k.unpair(fe),be=!0);continue}let Be=Q.get(l.unitHash(se));Be&&Be.some(Ke=>Ke.tagName===se.tagName&&l.equalUnits(Ke,se))&&(k.unpair(fe),be=!0)}be&&k.rematch()}function pe(k,$){if(!$)return null;if(k.map.has($))return k.map.get($);let Q=[],be=De($);for(;be&&!k.map.has(be);be=De(be))Q.push(be);let fe=be;if(!fe||!k.identical.has(fe))return null;k.pairIdenticalChildren(fe);for(let le=Q.length-1;le>=0;le--)k.pairIdenticalChildren(Q[le]);let se=k.map.get($)||null;return se&&c.lazyTwins++,se}function ke(k,$,Q,be){if(ut(k)&&In.has(k.tagName)&&!D.identical.has(k)&&(k.previousSibling?.nodeType===3||k.nextSibling?.nodeType===3)){let Be=De(k),Ke=pe(D,k),Ue=pe(V,k);Ke&&Ue&&ze(Ke,pe(D,Be),D)&&!ze(Ue,pe(V,Be),V)&&(qt||=Hi({L:D,R:V,twinIn:pe,unitsOf:i,view:v,parentOf:De,ignored:r,remoteWins:o.remoteWins,eligible:$e=>ut($e)&&In.has($e.tagName),build:J,out:re,policy:Qe,provenance:Se,textMappers:qe,segments:ne,conflicts:w,conflict:dt,decisions:ve}),qt.ensureOwner(k))}if($===null)return null;if(be!==void 0)return gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(k,$,Q,!!be),be&&(gt.produced(k,be),Pe.add(k)),be;if(Pe.has(k)||_e.has(k))return dt({kind:"structure",el:null,detail:"both-moved",base:k},{subject:k}),Pe.has(k)?null:G(Q,$);gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(k,$,Q,!0);let fe=pe(D,k),se=pe(V,k);(!fe||!se)&&dt({kind:"structure",el:null,detail:"move-beats-delete",base:k},{subject:k,deleted:fe?"remote":"local"});let le=J(k,fe,se,!1);return($==="local"?Ze:Xe)({kind:"move",el:le,source:$}),le}function v(k,$,Q,be){return be||!$||$===Q?{el:Q,asBase:!0,twin:fe=>fe,baseOf:fe=>fe,units:i(Q),here:()=>!0,parentOfTwin:()=>Q}:{el:$,asBase:!1,twin:fe=>pe(k,fe),baseOf:fe=>k.reverse.get(fe),units:i($),here:fe=>ut(fe)?fe.parentNode===$||$.tagName==="TEMPLATE"&&fe.parentNode===$.content:fe.parent===$||$.tagName==="TEMPLATE"&&fe.parent===$.content}}function P(k,$,Q){return!$||Q&&Q.identical.has(k)?!1:ut(k)?!l.equalUnits(k,$)||!Y(k,$,Q):k.value!==$.value}function Y(k,$,Q){if(!Q||k===$)return!0;let be=[[k,$]];for(;be.length;){let[fe,se]=be.pop(),le=i(fe),Be=i(se);for(let Ke=0;Ke<le.length&&Ke<Be.length;Ke++){let Ue=le[Ke],$e=Be[Ke];if(!ut(Ue)||!ut($e))continue;let Ge=Q.map.get(Ue);if(Ge!==void 0&&Ge!==$e)return!1;let et=Q.reverse.get($e);if(et!==void 0&&et!==Ue)return!1;be.push([Ue,$e])}}return!0}function J(k,$,Q,be,fe=!1){let se=be||(Q?o.remoteWins(Q):o.remoteWins(k)),le=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(k.namespaceURI,k.tagName):re.createElement(k.tagName),Be={base:k,local:$||null,remote:Q||null};if(Se.set(le,Be),se&&!be&&$&&P(k,$,D)&&(!Q||!l.equalUnits($,Q))&&dt({kind:"structure",el:le,detail:"remote-wins",base:k,local:$,remote:Q||null},{subject:k}),ee.add(k),Pe.add(k),$&&ee.add($),Q&&ee.add(Q),o.skipUnchanged&&!fe&&(o.localIsBase||D.identical.has(k))&&Q&&V.identical.has(k)&&!o.remoteWins(k)){Be.unchanged=!0;for(let Ue of k.attributes)Ue.namespaceURI?le.setAttributeNS(Ue.namespaceURI,Ue.name,Ue.value):le.setAttribute(Ue.name,Ue.value);return gt?.produced(k,le),le}_e.add(k),fe||Z(k,se?k:$,Q,le);let Ke=k.tagName;if(hn(k))je(k,se?k:$,Q,le);else if(Ke==="TEXTAREA")le.textContent=oe(k.textContent,(se?k:$)?(se?k:$).textContent:k.textContent,Q?Q.textContent:k.textContent,le,"text");else if(!qt?.render(k,le)){let Ue=ue(k,$,Q,se,le),$e=Ke==="TEMPLATE"&&le.content?le.content:le;for(let Ge of Ue)$e.appendChild(Ge)}return _e.delete(k),gt?.produced(k,le),le}function oe(k,$,Q,be,fe){if($===Q)return $;if($===k)return Q!==k&&Xe({kind:fe,node:be,source:"remote"}),Q;if(Q===k)return Ze({kind:fe,node:be,source:"local"}),$;let se=Qe==="local"?$:Q;return dt({kind:fe,node:be,base:k,local:$,remote:Q,resolved:se},{site:"whole",el:be}),ve.push({kind:fe,node:be,source:"both"}),se}function je(k,$,Q,be){let fe=k.textContent,se=$?$.textContent:fe,le=Q?Q.textContent:fe,Be=h?So(k,o.mergeTags,!0):null;if(Be&&se!==le){let Ke=Q&&Q.getAttribute("merge-key")||k.getAttribute("merge-key"),{text:Ue,warnings:$e}=is(o.localIsBase?void 0:fe,se,le,{parse:Be.recognizer.parse,keyCandidates:Ke?Ke.split(/[\s,]+/).filter(Boolean):void 0});for(let Ge of $e)console.warn(`[hyper-morph] merge "${Be.raw}": ${Ge}`);be.textContent=Ue,K.add(be),Ue!==le?Ze({kind:"text",node:be,source:Ue===se?"local":"both"}):Ue!==fe&&Xe({kind:"text",node:be,source:"remote"});return}be.textContent=oe(fe,se,le,be,"text")}function Z(k,$,Q,be){let fe=new Map;for(let se of[k,$,Q])if(se)for(let le of se.attributes)o.ignoreAttribute(se,le.name)||fe.set(le.name,le);for(let[se,le]of fe){let Be=k?k.getAttribute(se):null,Ke=$?$.getAttribute(se):Be,Ue=Q?Q.getAttribute(se):Be,$e;Ke===Ue?$e=Ke:Ke===Be?($e=Ue,Xe({kind:"attr",el:be,name:se,source:"remote"})):Ue===Be?($e=Ke,Ze({kind:"attr",el:be,name:se,source:"local"})):($e=Oe(se,Be,Ke,Ue),$e===void 0&&($e=Qe==="local"?Ke:Ue,dt({kind:"attr",el:be,name:se,base:Be,local:Ke,remote:Ue,resolved:$e},{el:be,sample:le})),ve.push({kind:"attr",el:be,name:se,source:"both"})),$e!=null&&(le.namespaceURI?be.setAttributeNS(le.namespaceURI,le.name,$e):be.setAttribute(se,$e))}}function Oe(k,$,Q,be){if(k==="class"){let fe=Ue=>new Set((Ue||"").split(/\s+/).filter(Boolean)),se=fe($),le=fe(Q),Be=fe(be),Ke=new Set;for(let Ue of new Set([...se,...le,...Be])){let $e=se.has(Ue),Ge=le.has(Ue),et=Be.has(Ue);(Ge===et?Ge:Ge===$e?et:Ge)&&Ke.add(Ue)}return[...Ke].join(" ")}if(k==="style"){let fe=$e=>{let Ge=new Map;if(!$e)return Ge;let et=0,Ot=null,xt="",Jt=()=>{let Mt=xt.indexOf(":");Mt>0&&Ge.set(xt.slice(0,Mt).trim(),xt.slice(Mt+1).trim()),xt=""};for(let Mt of $e){if(Ot){xt+=Mt,Mt===Ot&&(Ot=null);continue}if(Mt==='"'||Mt==="'"){Ot=Mt,xt+=Mt;continue}if(Mt==="("?et++:Mt===")"&&et--,Mt===";"&&et===0){Jt();continue}xt+=Mt}return xt.trim()&&Jt(),Ge},se=fe($),le=fe(Q),Be=fe(be),Ke=new Map,Ue=!1;for(let $e of new Set([...se.keys(),...le.keys(),...Be.keys()])){let Ge=se.get($e)??null,et=le.get($e)??null,Ot=Be.get($e)??null,xt;et===Ot?xt=et:et===Ge?xt=Ot:Ot===Ge?xt=et:(xt=Qe==="local"?et:Ot,Ue=!0),xt!=null&&Ke.set($e,xt)}return Ue?void 0:[...Ke].map(([$e,Ge])=>`${$e}: ${Ge}`).join("; ")}}function He(k,$,Q,be){let fe=k.value,se=be?fe:$?$.value:"",le=Q?Q.value:"";ee.add(k),$&&ee.add($),Q&&ee.add(Q);let Be=Ho(fe,se,le,Qe),Ke=Be.text===""?null:re.createTextNode(Be.text);Ke&&(Se.set(Ke,{base:k.nodes,local:$?$.nodes:null,remote:Q?Q.nodes:null}),qe.set(Ke,Be.mapLocalOffset)),se!==fe&&le!==fe?ve.push({kind:"text",node:Ke,source:"both"}):se!==fe?Ze({kind:"text",node:Ke,source:"local"}):le!==fe&&Xe({kind:"text",node:Ke,source:"remote"});for(let Ue of Be.conflicts)dt({kind:"text",node:Ke,base:fe.slice(Ue.bs,Ue.be),local:Ue.local,remote:Ue.remote,resolved:Ue.resolved},{site:"run",bRun:k,lRun:$,rRun:Q,node:Ke,c:Ue});return Ke}function Ie(k,$){return ro(k,$).every(Q=>Q.bs===Q.be)}function ge(k,$){let Q=k?k.value:"",be=$?$.value:"",fe;if(Q===be||!be?fe=Q:Q?Ie(Q,be)?fe=be:Ie(be,Q)?fe=Q:(fe=Qe==="local"?Q:Qe==="both"?Q+be:be,dt({kind:"structure",el:null,detail:"insert-collision",local:Q,remote:be,resolved:fe},{unit:{b:null,l:k,r:$},localLost:Qe==="remote"})):fe=be,k&&ee.add(k),$&&ee.add($),fe==="")return null;let se=re.createTextNode(fe);return Se.set(se,{base:null,local:k?k.nodes:null,remote:$?$.nodes:null}),Q?Ze({kind:"insert",el:se,source:be&&Q===be?"both":"local"}):Xe({kind:"insert",el:se,source:"remote"}),se}function B(k,$){let Q={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},be=Be=>i(Be).every(Ke=>ut(Ke)?Un(Ke,Q):Ke.kind==="text"),fe=null;if(be(k)&&be($)){let Be=k.textContent,Ke=$.textContent;Be===Ke||Ie(Ke,Be)?fe=$:Ie(Be,Ke)&&(fe=k)}if(!fe){let Be=Qe==="local",Ke=G(Be?k:$,Be?"local":"remote",!0),Ue=Se.get(Ke);return Be?Ue.remote=$:Ue.local=k,dt({kind:"structure",el:Ke,detail:"insert-collision",local:k,remote:$,resolved:Be?k:$},{unit:{b:null,l:k,r:$},localLost:!Be}),Ke}let se=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(k.namespaceURI,k.tagName):re.createElement(k.tagName);Z(null,k,$,se),Se.set(se,{base:null,local:k,remote:$}),ee.add(k),ee.add($);let le=so({base:Array.from(fe.childNodes),local:Array.from(k.childNodes),remote:Array.from($.childNodes),out:re,policy:Qe,idOf:{local:b,remote:A},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:Se,textMappers:qe,conflicts:w,conflict:dt,scope:{base:null,local:k,remote:$,units:[],at:0},synthetic:!0,decisions:ve,node:se});ne.push(...le.segments);for(let Be of le.nodes)se.appendChild(Be);return se}function G(k,$,Q=!1){if(!Q&&ut(k)){let le=$t.partner.get(k);if(le)return _(k,$,le)}if(!ut(k)){if(k.value==="")return null;let le=k.kind==="comment"?re.createComment(k.value):re.createTextNode(k.value);return Se.set(le,{base:null,local:$==="local"?k.nodes:null,remote:$==="remote"?k.nodes:null}),ee.add(k),le}let be=k.namespaceURI&&k.namespaceURI!=="http://www.w3.org/1999/xhtml"?re.createElementNS(k.namespaceURI,k.tagName):re.createElement(k.tagName);for(let le of k.attributes)le.namespaceURI?be.setAttributeNS(le.namespaceURI,le.name,le.value):be.setAttribute(le.name,le.value);Se.set(be,{base:null,local:$==="local"?k:null,remote:$==="remote"?k:null}),ee.add(k);let fe=k.tagName==="TEMPLATE"&&be.content?be.content:be,se=$==="local"?D:V;for(let le of i(k)){let Be=ut(le)?se.reverse.get(le):null;if(Be&&ke(Be,null,null),Be&&Pe.has(Be)){dt({kind:"structure",el:null,detail:"both-moved",base:Be},{subject:Be});continue}if(Be&&!_e.has(Be)){let Ue=pe(D,Be)||null,$e=pe(V,Be)||null;if(Ue||$e){gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(Be,$,le,!0);let Ge=J(Be,Ue,$e,!1);$==="local"?Ze({kind:"move",el:Ge,source:"local"}):Xe({kind:"move",el:Ge,source:"remote"}),fe.appendChild(Ge);continue}}let Ke=G(le,$);Ke&&fe.appendChild(Ke)}if(!Q&&$t.drop.size&&k.tagName==="DIV"&&!fe.firstChild&&!k.attributes.length&&!($==="local"?b(k):A(k))&&!se.reverse.has(k)&&!r(k)&&!o.remoteWins(k)){let le=k.firstChild;if(le&&le===k.lastChild&&ut(le)&&($t.drop.has(le)||Ht?.has(le)))return(Ht||=new WeakSet).add(k),null}return be}function ue(k,$,Q,be,fe){$&&D.identical.has(k)&&D.pairIdenticalChildren(k),Q&&V.identical.has(k)&&V.pairIdenticalChildren(k);let se=v(D,$,k,be),le=v(V,Q,k,!1),Be=i(k),Ke=new Set(Be),Ue=new Map;for(let ye=0;ye<Be.length;ye++)Ue.set(Be[ye],ye);let $e=[],Ge=new Set,et=new Map,Ot=new Set,xt=new Set,Jt=[],Mt=null;if(!se.asBase&&!le.asBase&&!D.identical.has(k)&&!V.identical.has(k))for(let ye of Be){if(!ut(ye)||!In.has(ye.tagName))continue;let Je=se.twin(ye),Ye=le.twin(ye);Je&&Ye&&(!se.here(Je)||!le.here(Ye))&&ke(ye,null,null)}Ir();let pt=ye=>{let Je=[];for(let Ye of ye.units){if(xt.has(Ye))continue;let kt=ye.baseOf(Ye);kt&&Ke.has(kt)&&Je.push(kt)}return Je},bt=ye=>pt(ye).map(Je=>Ue.get(Je)),mt=ye=>ye.every((Je,Ye)=>Ye===0||Je>=ye[Ye-1]),It=!se.asBase&&!mt(bt(se)),ct=!le.asBase&&!mt(bt(le));It&&ct&&dt({kind:"structure",el:fe,detail:"both-reordered",base:k},{subject:k,lKept:pt(se),rKept:pt(le)});let Wt=ct||!It?{V:le,A:V,side:"remote",other:se,otherA:D,otherSide:"local"}:{V:se,A:D,side:"local",other:le,otherA:V,otherSide:"remote"};It?Ze({kind:"move",el:null,source:ct?"both":"local",base:k}):ct&&Xe({kind:"move",el:null,source:"remote",base:k});let St=se.asBase?[]:se.units.filter(ye=>!se.baseOf(ye)&&!xt.has(ye)&&!$t.partner.has(ye)),fn=le.asBase?[]:le.units.filter(ye=>!le.baseOf(ye)&&!xt.has(ye)&&!$t.partner.has(ye)),Gt=new Map;if(St.length&&fn.length){let ye=new Map,Je=new Map;for(let rt of fn){if(ut(rt)){let Lt=A(rt);Lt&&ye.set(Lt,rt)}let At=l.unitHash(rt);Je.has(At)||Je.set(At,[]),Je.get(At).push(rt)}let Ye=(rt,At)=>{let Lt=rt.units.indexOf(At);for(let at=Lt-1;at>=0;at--){let Nt=rt.baseOf(rt.units[at]);if(Nt)return Nt}return"start"},kt=new Map,Dt=new Map;for(let rt of fn){let At=Ye(le,rt);ut(rt)?(Dt.has(At)||Dt.set(At,[]),Dt.get(At).push(rt)):rt.kind==="text"&&!kt.has(At)&&kt.set(At,rt)}for(let rt of St){let At=null;if(ut(rt)){let at=b(rt);at&&ye.has(at)&&!Gt.has(ye.get(at))&&(At=ye.get(at))}else if(rt.kind==="text"){let at=kt.get(Ye(se,rt));at&&!Gt.has(at)&&(At=at)}let Lt=!!x(rt);if(!At&&!Lt){let at=Je.get(l.unitHash(rt));at&&(At=at.find(Nt=>!Gt.has(Nt)&&ut(Nt)===ut(rt)&&(ut(Nt)?Nt.tagName===rt.tagName&&!z(Nt):Nt.kind===rt.kind)&&l.equalUnits(rt,Nt))||null)}if(!At&&ut(rt)&&!Lt){let at=p.local(rt),Nt=(Dt.get(Ye(se,rt))||[]).filter(sn=>{let un=p.remote(sn);return!Gt.has(sn)&&sn.tagName===rt.tagName&&!z(sn)&&!(at&&un&&at!==un)&&l.similar(rt,sn)});Nt.length===1&&(At=Nt[0])}At&&(Gt.set(At,rt),Gt.set(rt,At))}}let Fn=ye=>{if(qt?.consumes(ye))return null;if(ee.has(ye)||gt?.has(ye))return et.get(ye)||null;let Je=se.twin(ye),Ye=le.twin(ye),kt=Je&&!se.asBase&&!se.here(Je),Dt=Ye&&!le.asBase&&!le.here(Ye);if(kt||Dt){if((!Je||!Ye)&&dt({kind:"structure",el:null,detail:"move-beats-delete",base:ye},{subject:ye,deleted:Je?"remote":"local"}),!Ne(ye))return ut(ye)?(gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),kt&&gt.plan(ye,"local",Je),Dt&&gt.plan(ye,"remote",Ye)):ee.add(ye),null;dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye})}if(Je&&!Ye&&!se.asBase&&!le.asBase&&ut(ye)&&In.has(ye.tagName)&&!o.remoteWins(ye)&&!o.remoteWins(Je)&&P(ye,Je,D)&&ia(ye,te(le.el),r)){let Nt={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},sn=un=>ut(un)?Un(un,Nt):un.kind==="text";if(i(ye).every(sn)&&i(Je).every(sn)){let un=so({base:[ye],local:[Je],remote:[],blocks:new Set([ye,Je]),out:re,policy:Qe,L:D,R:V,idOf:{base:g,local:b,remote:A},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(mn,kn,Ln)=>J(mn,kn,Ln,!1),cloneUnit:G,mergeAttrs:Z,atomKey:l.exactUnitKey,moveIn:ke,moveBuilt:ke,movePlanned:ke,provenance:Se,textMappers:qe,conflicts:w,conflict:dt,scope:{base:k,local:se.el,remote:le.el,units:Be,at:Ue.get(ye)},decisions:ve,node:fe});ne.push(...un.segments),ee.add(ye),ee.add(Je);let xn=re.createDocumentFragment();for(let mn of un.nodes)xn.appendChild(mn);return et.set(ye,xn),et.set(Je,xn),xn}}if(!Je&&!Ye)return ee.add(ye),Xe({kind:"remove",source:"both",base:ye}),null;if(!Je&&!P(ye,Ye,V))return ee.add(ye),Ze({kind:"remove",source:"local",base:ye}),null;if(!Ye&&!P(ye,Je,D))return ee.add(ye),Xe({kind:"remove",source:"remote",base:ye}),null;let rt=!Je||!Ye,At=se.asBase?pe(D,ye)||null:Je,Lt=le.asBase&&ut(ye)&&(V.identityPaired.has(ye)||!p.base(ye))&&pe(V,ye)||Ye,at;return ut(ye)?at=J(ye,At,Lt,se.asBase):ye.kind==="comment"?at=Le(ye,At,Ye,se.asBase):at=He(ye,At,Ye,se.asBase),ee.add(ye),at&&(et.set(ye,at),Je&&et.set(Je,at),Ye&&et.set(Ye,at),rt&&(dt({kind:"structure",el:at,detail:"edit-beats-delete",base:ye},{subject:ye,deleted:Je?"remote":"local"}),Je?Ze({kind:"insert",el:at,source:"local"}):Xe({kind:"insert",el:at,source:"remote"}))),at},Rn=(ye,Je,Ye,kt)=>{if(qt?.consumes(ye))return null;if(ee.has(ye))return et.get(ye)||null;let Dt=Je.baseOf(ye);if(Dt&&Ke.has(Dt))return xt.has(Dt)&&!xt.has(ye)?cr(Dt,ye,kt):Fn(Dt);if(Dt)return $n(Dt,ye,kt);let rt=Gt.get(ye);if(rt){let Lt=kt==="local"?ye:rt,at=kt==="local"?rt:ye,Nt;return ut(Lt)?l.equalUnits(Lt,at)?(Nt=G(Lt,"local"),Nt&&(Se.get(Nt).remote=at)):Nt=B(Lt,at):Nt=ge(Lt,at),ee.add(Lt),ee.add(at),Nt&&(et.set(Lt,Nt),et.set(at,Nt),ut(Lt)&&Ze({kind:"insert",el:Nt,source:"both"})),Nt}let At=G(ye,kt);return At&&(et.set(ye,At),kt==="local"?Ze({kind:"insert",el:At,source:"local"}):Xe({kind:"insert",el:At,source:"remote"})),At},cr=(ye,Je,Ye)=>{let kt;return ut(ye)?(kt=ke(ye,Ye,Je),kt&&ee.add(Je)):(kt=G(Je,Ye),ee.add(Je),kt&&(Ye==="local"?Ze:Xe)({kind:"insert",el:kt,source:Ye})),kt&&et.set(Je,kt),kt},$n=(ye,Je,Ye)=>{ke(ye,null,null);let Dt=pe(Ye==="local"?V:D,ye),rt=Je,At=Dt?ze(Dt,Ye==="local"?Q:$,Ye==="local"?V:D):!1,Lt=Dt&&!At&&!tt(ye,Dt);if(Lt&&Ye===Wt.otherSide)return dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye}),null;if(Lt&&dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye}),Dt||dt({kind:"structure",el:null,detail:"move-beats-delete",base:ye},{subject:ye,deleted:Ye==="local"?"remote":"local"}),_e.has(ye)){dt({kind:"structure",el:null,detail:"both-moved",base:ye},{subject:ye});let Nt=G(rt,Ye);return Nt&&et.set(Je,Nt),Nt}ut(ye)&&(gt||=Oo(Se,De,D,V,pe,J,r,o.remoteWins,w,dt,P,R,S),gt.plan(ye,Ye,rt,!0));let at=ut(ye)?J(ye,Ye==="local"?rt:pe(D,ye)||null,Ye==="remote"?rt:pe(V,ye)||null,!1):null;return at&&(et.set(ye,at),et.set(Je,at),Dt&&et.set(Dt,at),Ye==="local"?Ze({kind:"move",el:at,source:"local"}):Xe({kind:"move",el:at,source:"remote"})),at};for(let ye of Wt.V.units){if(xt.has(ye)){if(Mt?.has(ye)){for(let kt of Mt.get(ye))Ge.has(kt)||($e.push(kt),Ge.add(kt));continue}let Ye=et.get(ye);Ge.has(Ye)||($e.push(Ye),Ge.add(Ye));continue}if(ee.has(ye)&&!(et.get(ye)&&Ge.has(et.get(ye)))){let Ye=Wt.V.baseOf(ye);Ye&&!Ke.has(Ye)&&dt({kind:"structure",el:null,detail:"both-moved",base:Ye},{subject:Ye});continue}let Je=Rn(ye,Wt.V,Wt.A,Wt.side);Je&&!Ge.has(Je)&&($e.push(Je),Ge.add(Je),!Wt.V.baseOf(ye)&&!Gt.has(ye)&&!xt.has(ye)&&Ot.add(Je))}for(let ye of Jt)Ge.has(ye.frag)||($e.splice(ye.previous&&Ge.has(ye.previous)?$e.indexOf(ye.previous)+1:jo(ye.at),0,ye.frag),Ge.add(ye.frag));if(!Wt.other.asBase){let ye=Wt.other,Je=Wt.otherSide,Ye=Wt.otherA,kt=null,Dt=0,rt=null;for(let At of ye.units){let Lt=et.get(At);if(Lt&&Ge.has(Lt)){kt=Lt,rt=null;continue}if(ee.has(At)){let sn=ye.baseOf(At);sn&&!Ke.has(sn)&&dt({kind:"structure",el:null,detail:"both-moved",base:sn},{subject:sn});continue}let at=Rn(At,ye,Ye,Je);if(!at)continue;let Nt;if(rt)Nt=$e.indexOf(rt)+1;else if(kt){if(Nt=$e.indexOf(kt)+1,Je==="remote")for(;Nt<$e.length&&Ot.has($e[Nt]);)Nt++}else Nt=Dt++;$e.splice(Nt,0,at),Ge.add(at),rt=at}}for(let ye=0;ye<Be.length;ye++){let Je=Be[ye];if(ee.has(Je))continue;let Ye=Fn(Je);Ye&&$e.splice(jo(ye),0,Ye)}return $e;function jo(ye){for(let Je=ye-1;Je>=0;Je--){let Ye=et.get(Be[Je]);if(Ye){let kt=$e.indexOf(Ye);if(kt>=0)return kt+1}}return 0}function Ir(){if((se.asBase||D.identical.has(k))&&(le.asBase||V.identical.has(k)))return;let ye={ignored:r,remoteWins:o.remoteWins,inlineCache:Ae},Je=it=>ut(it)?Un(it,ye):it.kind==="text";if(!se.asBase&&!le.asBase)for(let it of Be){if(!ut(it)||!In.has(it.tagName))continue;let nt=se.twin(it),Rt=le.twin(it);if(!nt&&Rt||nt&&!Rt){let st=Fi({base:Be,views:[{V:se,A:D,idOf:p.local},{V:le,A:V,idOf:p.remote}],eligible:Et=>ut(Et)&&In.has(Et.tagName)&&!r(Et)&&!o.remoteWins(Et),baseId:p.base,ignored:r,remoteWins:o.remoteWins,atomKey:l.exactUnitKey});st&&(se=st[0],le=st[1]);break}}let Ye=!se.asBase&&!le.asBase&&Be.length>=2&&In.has(Be[0].tagName)&&se.units.length===Be.length&&le.units.length===Be.length?Ti({base:Be,local:se.units,remote:le.units,localTwin:se.twin,remoteTwin:le.twin,eligible:it=>ut(it)&&In.has(it.tagName)&&!r(it)&&!o.remoteWins(it),nodes:{base:Array.from(te(k).childNodes),local:Array.from(te(se.el).childNodes),remote:Array.from(te(le.el).childNodes)}}):null,kt=null,Dt=null;if(!Ye&&!se.asBase&&!le.asBase&&(fs(Be)||fs(se.units)||fs(le.units))){let it={ignored:r,remoteWins:()=>!1},nt=st=>Je(st)||ut(st)&&o.remoteWins(st)&&wn.has(st.tagName)&&Un(st,it),Rt=st=>ut(st)?In.has(st.tagName)&&!r(st)&&!o.remoteWins(st)&&i(st).every(nt):st.kind==="text";kt=$i({onUncertainOwner:st=>{let Et=o.identity.local(st.local);Et&&Et===o.identity.remote(st.remote)||(Dt||=[]).push(st)},onUncertainSource:st=>{ot||(ot=new Map);let Et=ot.get(st.source);Et||ot.set(st.source,Et=[]);for(let Yt of Et)if(Yt.side===st.side&&Yt.from===st.from&&Yt.to===st.to)return;Et.push(st)},base:Be,views:[{V:se,A:D,idOf:p.local},{V:le,A:V,idOf:p.remote}],eligible:Rt,ignored:r,remoteWins:o.remoteWins,baseId:p.base,atomKey:l.exactUnitKey})}if(Dt){Mt||=new Map;for(let it of Dt){let{source:nt,local:Rt,remote:st}=it,Et={map:new Map,reverse:new Map,identical:new Set},Yt=so({base:[nt],local:[Rt],remote:[st],out:re,policy:"both",L:Et,R:Et,ignored:r,remoteWins:o.remoteWins,atomKey:l.exactUnitKey,cloneUnit:G,provenance:Se,textMappers:qe,conflicts:w,decisions:ve,conflict:(Ct,tn)=>dt(Ct,{...tn,policy:"both"}),scope:{base:k,local:se.el,remote:le.el,units:Be,at:Ue.get(nt)},node:fe});ne.push(...Yt.segments);for(let Ct of[nt,Rt,st])ee.add(Ct),xt.add(Ct),Mt.set(Ct,Yt.nodes),et.set(Ct,Yt.nodes[Yt.nodes.length-1]);for(let Ct=0;Ct<Yt.nodes.length;Ct++)Jt.push({frag:Yt.nodes[Ct],at:Ue.get(nt),previous:Ct?Yt.nodes[Ct-1]:null})}}let rt=Ye?Ye.blocks:null;if(kt){rt=new Set;for(let it of kt.blocks)rt.add(it)}let At=it=>!qt?.consumes(it)&&(rt&&rt.has(it)||Je(it)),Lt=Be.map(At);if(!Lt.includes(!0))return;let at=it=>{let nt=it.units,Rt=new Map;for(let Vt=0;Vt<nt.length;Vt++)Rt.set(nt[Vt],Vt);let st=[],Et=-1;for(let Vt=0;Vt<Be.length;Vt++){if(Lt[Vt])continue;let vt=it.twin(Be[Vt]),Tt=vt?Rt.get(vt):void 0;Tt===void 0||Tt<=Et||At(vt)||(st.push([Vt,Tt]),Et=Tt)}let Yt=[],Ct=-1,tn=-1;for(let Vt=0;Vt<=st.length;Vt++){let[vt,Tt]=Vt<st.length?st[Vt]:[Be.length,nt.length],Bt={bLo:-1,bHi:-1,from:tn+1,to:Tt,inlineStart:-1,inlineEnd:-1,next:Tt};for(let Qt=Ct+1;Qt<vt;Qt++)Lt[Qt]&&(Bt.bLo<0&&(Bt.bLo=Qt),Bt.bHi=Qt);for(let Qt=tn+1;Qt<Tt;Qt++){let zn=nt[Qt];At(zn)&&(Bt.inlineStart<0&&(Bt.inlineStart=Qt),Bt.inlineEnd=Qt+1)}Yt.push(Bt),Ct=vt,tn=Tt}return{units:nt,list:Yt}},Nt=at(se),sn=at(le),un=[];for(let it of[Nt,sn])for(let nt of it.list)nt.bLo>=0&&un.push([nt.bLo,nt.bHi]);un.sort((it,nt)=>it[0]-nt[0]);let xn=[];for(let[it,nt]of un){let Rt=xn[xn.length-1];Rt&&it<=Rt.hi?Rt.hi=Math.max(Rt.hi,nt):xn.push({lo:it,hi:nt})}let mn=(it,nt)=>it.length===nt.length&&it.every((Rt,st)=>l.equalUnits(Rt,nt[st])),kn=it=>!ut(it)&&it.kind==="comment",Ln=it=>{if(!it.length)return[];let nt=(Ct,tn)=>ut(Ct)?Ct:Ct.nodes[tn?Ct.nodes.length-1:0],Rt=nt(it[0]),st=nt(it[it.length-1],!0),Et=Ct=>Ct&&ut(Ct)&&r(Ct);for(;Et(Rt.previousSibling);)Rt=Rt.previousSibling;for(;Et(st.nextSibling);)st=st.nextSibling;let Yt=[];for(let Ct=Rt;Ct&&(Yt.push(Ct),Ct!==st);Ct=Ct.nextSibling);return Yt},ar=it=>it.some(nt=>ut(nt)&&r(nt));for(let it of xn){let nt=Be.slice(it.lo,it.hi+1),Rt=null;if(kt)for(let vt of nt){let Tt=kt.certificatesBySource.get(vt);Tt&&(Rt||=[]).push(...Tt)}let st=se.asBase?null:as(Nt,it),Et=le.asBase?null:as(sn,it);if(Rt){let vt=[new Set(st||nt),new Set(Et||nt)],Tt=Rt.some(Bt=>!vt[Bt.side].has(Bt.target));for(let Bt of nt)if(rt.has(Bt))for(let[Qt,zn]of[[0,se],[1,le]]){let Gn=zn.twin(Bt);Gn&&zn.here(Gn)&&!vt[Qt].has(Gn)&&(Tt=!0)}if(Tt)continue}if(nt.some(kn)||st&&st.some(kn)||Et&&Et.some(kn))continue;let Yt=Ln(st||nt),Ct=Ln(Et||nt);if((!st||mn(nt,st))&&(!Et||mn(nt,Et))&&!(st&&ar(Yt)))continue;let tn=so({base:Ln(nt),sourceRetentions:ot?.get(k),local:Yt,remote:Ct,out:re,policy:Qe,blocks:rt,scopeUnits:Rt?[nt,st||nt,Et||nt]:null,certifiedOrigins:Rt?(vt,Tt,Bt,Qt,zn,Gn)=>Ki({certificates:Rt,scopes:[nt,st||nt,Et||nt],flats:[vt,Tt,Bt],keys:[Qt,zn,Gn]}):null,prepared:Ye?Ye.prepared:null,nativeTransfers:Ye,L:st?D:qi(D,k),R:Et?V:qi(V,k),idOf:{base:g,local:b,remote:A},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(vt,Tt,Bt)=>J(vt,Tt,Bt,!1),cloneUnit:G,mergeAttrs:Z,atomKey:l.exactUnitKey,moveIn:ke,moveBuilt:ke,movePlanned:ke,provenance:Se,textMappers:qe,conflicts:w,conflict:dt,scope:{base:k,local:se.asBase?null:se.el,remote:le.asBase?null:le.el,units:Be,at:it.lo},decisions:ve,node:fe});if(!tn){if(Rt){let vt=Ai({certificates:Rt,scopes:[nt,st||nt,Et||nt],views:[{V:se,A:D,idOf:p.local},{V:le,A:V,idOf:p.remote}],eligible:Tt=>ut(Tt)&&In.has(Tt.tagName)&&!r(Tt)&&!o.remoteWins(Tt),baseId:p.base});for(let Tt of vt.records){ot||=new Map;let Bt=ot.get(Tt.source);Bt||ot.set(Tt.source,Bt=[]),Bt.push(Tt)}}continue}if(ne.push(...tn.segments),Ye){let vt=new Map;for(let Tt of tn.nodes){let Bt=Se.get(Tt)?.base;if(!Bt||vt.has(Bt))throw new Error("Invalid native transfer owner output");vt.set(Bt,Tt)}if(vt.size!==Ye.owners.length)throw new Error("Incomplete native transfer owner output");for(let Tt of Ye.owners){let Bt=vt.get(Tt.base);if(!Bt)throw new Error("Missing native transfer owner output");for(let Qt of[Tt.base,Tt.local,Tt.remote])ee.add(Qt),xt.add(Qt),et.set(Qt,Bt);Jt.push({frag:Bt,at:Ue.get(Tt.base)})}continue}if(tn.unitOutputs){Mt||=new Map;for(let vt of[...nt,...st||[],...Et||[]]){let Tt=tn.unitOutputs.get(vt)||[];ee.add(vt),xt.add(vt),Mt.set(vt,Tt),Tt.length&&et.set(vt,Tt[Tt.length-1])}for(let vt=0;vt<tn.nodes.length;vt++)Jt.push({frag:tn.nodes[vt],at:it.lo,previous:vt>0?tn.nodes[vt-1]:null});continue}let Vt=re.createDocumentFragment();for(let vt of tn.nodes)Vt.appendChild(vt);for(let vt of[...nt,...st||[],...Et||[]])ee.add(vt),xt.add(vt),et.set(vt,Vt);Jt.push({frag:Vt,at:it.lo})}}}function he(k,$){let Q=Se.get(k);return Q&&Q.unchanged?!Q.remote||Q.remote===$?!0:ce(Q.remote,$):k.tagName!==$.tagName||!q(k,$)?!1:ae(te(k),te($))}function ce(k,$){return k===$?!0:k.tagName!==$.tagName||k.namespaceURI!==$.namespaceURI||!q(k,$)?!1:xe(te(k),te($))}function xe(k,$){let Q=Ce(k,r),be=Ce($,r);if(Q.length!==be.length)return!1;for(let fe=0;fe<Q.length;fe++){let se=Q[fe],le=be[fe];if(typeof se=="string"||typeof le=="string"){if(se!==le)return!1}else{if(se.nodeType!==le.nodeType)return!1;if(se.nodeType===1){if(!ce(se,le))return!1}else if(se.nodeValue!==le.nodeValue)return!1}}return!0}function te(k){return k.tagName==="TEMPLATE"&&k.content?k.content:k}function q(k,$){let Q=0;for(let be of k.attributes)if(!o.ignoreAttribute(k,be.name)&&(Q++,$.getAttribute(be.name)!==be.value))return!1;for(let be of $.attributes)o.ignoreAttribute($,be.name)||Q--;return Q===0}function ae(k,$){let Q=Ce(k,fe=>{let se=Se.get(fe);return!!(se&&se.pinned)}),be=Ce($,r);if(Q.length!==be.length)return!1;for(let fe=0;fe<Q.length;fe++){let se=Q[fe],le=be[fe];if(typeof se=="string"||typeof le=="string"){if(se!==le)return!1}else{if(se.nodeType!==le.nodeType)return!1;if(se.nodeType===1){if(!he(se,le))return!1}else if(se.nodeValue!==le.nodeValue)return!1}}return!0}function Ce(k,$){let Q=[],be=null;for(let fe=k.firstChild;fe;fe=fe.nextSibling){if(fe.nodeType===3){be=be===null?fe.nodeValue:be+fe.nodeValue;continue}fe.nodeType===1&&$(fe)||(be!==null&&(be!==""&&Q.push(be),be=null),Q.push(fe))}return be!==null&&be!==""&&Q.push(be),Q}function Le(k,$,Q,be){let fe=k.value,se=be?fe:$?$.value:"",le=Q?Q.value:"";ee.add(k),$&&ee.add($),Q&&ee.add(Q);let Be=se===le?se:se===fe?le:le===fe||Qe==="local"?se:le,Ke={site:"comment",bRun:k,lRun:$,rRun:Q,node:null};if(se!==fe&&le!==fe&&se!==le&&dt({kind:"text",node:null,base:fe,local:se,remote:le,resolved:Be},Ke),!$&&!Q)return null;let Ue=re.createComment(Be);return Ke.node=Ue,Se.set(Ue,{base:k.nodes,local:$?$.nodes:null,remote:Q?Q.nodes:null}),Ue}function We(k,$){let Q=pe($,k);if(!Q)return null;let be=ut(Q)?Q.parentNode:Q.parent,fe=ut(k)?k.parentNode:k.parent;return pe($,fe)===be?null:$.reverse.get(be)||null}function Ne(k){let $=new Set([k]),Q=k;for(let be=0;be<64;be++){let fe=We(Q,D)||We(Q,V);if(!fe)return!1;if(fe===k||ut(k)&&ut(fe)&&k.contains(fe)||$.has(fe))return!0;$.add(fe),Q=fe}return!0}function ze(k,$,Q){if(!$)return!1;let be=ut(k)?k.parentNode:k.parent;return be===$||$.tagName==="TEMPLATE"&&be===$.content}function tt(k,$){let Q=De(k),be=pe(D,Q);if(be&&ze($,be,D))return!0;let fe=pe(V,Q);return!!(fe&&ze($,fe,V))}}function qi(e,n){return e.map.get(n)?zi():{map:{get:o=>o&&o.nodeType===1&&e.map.get(o)||o,has:()=>!0},reverse:{get:o=>e.reverse.get(o)||o,has:()=>!0},moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function zi(){let e={get:n=>n,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var Gi=new Set(["INPUT","OPTION","TEXTAREA"]),ds=/[\t\n\f\r ]+/;function Yi(e,n,t,o){let r=e.ownerDocument,{provenance:c,textMappers:l}=t,i=o.hooks,s=[],a=[],h=[],f=new Set,u=[],g=[],b=new Map,A=new Set,p=new Map,m=t.conflicts.length>0,y=new Map,R=new Set,S=new Map,O=(_,ie)=>{let me=S.get(_);me||S.set(_,me=new Set),me.add(ie)},M=m?new Set:null,E=(_,ie,me)=>{let pe=i.beforeAttributeUpdated(_,ie,me);return m&&pe===!1&&O(ie,_),pe},N=_=>!!_&&(_===e||e.contains(_)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(_)),L=new Map,j=new Map,F=new Map,W=new Set,C=new Map;(function _(ie){let me=c.get(ie);if(me){if(ie.nodeType===1){let ke=me.local?o.toLive(me.local):null;ke&&N(ke)&&ke.nodeType===1&&(L.set(ie,ke),j.set(ke,ie))}else if(Array.isArray(me.local)){let ke=V(me.local,me.local.map(v=>o.toLive(v)).filter(v=>v&&N(v)&&v.nodeType===ie.nodeType));if(ke.length&&(L.set(ie,ke[0]),j.set(ke[0],ie),F.set(ie,ke)),Array.isArray(me.caret))for(let v of me.caret){let P=o.toLive(v.node);if(!P||!N(P)||P.nodeType!==3)continue;let Y=C.get(P);Array.isArray(Y)||C.set(P,Y=[]),Y.push({merged:ie,from:v.from,to:v.to,flatStart:v.flatStart})}else{let v=0;for(let P of ke)C.set(P,{merged:ie,shift:v}),v+=P.nodeValue.length}}}let pe=ie.nodeType===1&&ie.tagName==="TEMPLATE"&&ie.content?ie.content.childNodes:ie.childNodes;for(let ke of pe)_(ke)})(n);let T=new Set;for(let _ of L.values())T.add(_);for(let _ of F.values())for(let ie of _)T.add(ie);let x=o.localRoot&&o.localRoot!==e?new Set:null;if(x){for(let _=o.localRoot.firstElementChild;_;_=_.nextElementSibling)if(_.tagName==="HEAD")for(let ie=_.firstElementChild;ie;ie=ie.nextElementSibling){let me=o.toLive(ie);me&&x.add(me)}}for(let _ of t.segments||[])Ee(_);let z=o.restoreFocus===!1?null:la(r,C);o.childrenOnly?Se(Me(e),Me(n)):De(e,n);for(let{node:_,parent:ie}of u)f.has(_)||!_.parentNode||_.nodeType===1&&(o.ignored(_)||qe(_))||ot(_,ie);return ca(r,z,C,l,F,p,W),{applied:s,moved:a,replaced:h,identities:g,mergedScriptsLive:A,liveOf:L,heldBy:p,runOf:F,keptRuns:W,insertedLive:y,vetoed:R,vetoedAttrs:S,removedVetoes:M};function D(_,ie){let me=_.slice(ie.bs,ie.be),pe=0;for(;pe<me.length&&pe<ie.text.length&&me[pe]===ie.text[pe];)pe++;let ke=0;for(;ke<me.length-pe&&ke<ie.text.length-pe&&me[me.length-1-ke]===ie.text[ie.text.length-1-ke];)ke++;return{bs:ie.bs+pe,be:ie.be-ke,text:ie.text.slice(pe,ie.text.length-ke)}}function V(_,ie){if(!ie.length)return ie;let me=[];for(let v of _){let P=v.parentNode;if(!P)continue;let Y=b.get(P);if(!Y){Y=new Set;for(let J=P.firstChild;J;J=J.nextSibling)J.nodeType===3&&Y.add(o.toLive(J));b.set(P,Y)}me.includes(Y)||me.push(Y)}let pe={has:v=>me.some(P=>P.has(v))},ke=[];for(let v of ie){ke.push(v);for(let P=v.nextSibling;P&&P.nodeType===3&&!pe.has(P)&&!ke.includes(P);P=P.nextSibling)ke.push(P)}return ke}function Ee(_){let ie=[];for(let ge of _.localNodes){let B=o.toLive(ge.node);if(!B||!N(B)||B.nodeType!==3)return;ie.push(B)}let me=V(_.localNodes.map(ge=>ge.node),ie);if(!me.length)return;let pe=me.map(ge=>ge.nodeValue).join(""),{flatLocal:ke,lToM:v,mapLocal:P}=_;if(pe===ke)return;let Y=_.textNodes.map(ge=>({node:ge.node,ms:ge.ms,me:ge.me})),J=[],oe=0;for(let ge of me)J.push(oe),oe+=ge.nodeValue.length;let je=(ge,B)=>me.find((G,ue)=>J[ue]<=ge&&ge+B<=J[ue]+G.nodeValue.length)||null,Z=[],Oe=0;for(let ge of ro(ke,pe).map(B=>D(ke,B))){let B=ge.bs+Oe;Oe+=ge.text.length-(ge.be-ge.bs);let G,ue;if(ge.be>ge.bs){G=v[ge.bs];let he=G>=0;for(let ce=ge.bs;he&&ce<ge.be;ce++)v[ce]!==G+(ce-ge.bs)&&(he=!1);if(!he)continue;ue=G+(ge.be-ge.bs)}else{let he=ge.bs>0?v[ge.bs-1]:0,ce=ge.bs<ke.length?v[ge.bs]:0;if(he<0||ce<0)continue;G=ue=P(ge.bs)}Z.push({ms:G,me:ue,text:ge.text,live:ue===G?je(B,ge.text.length):null})}Z.sort((ge,B)=>B.ms-ge.ms);let He=(ge,B)=>(F.get(ge.node)||[L.get(ge.node)]).includes(B),Ie=ge=>!!ge&&ge.nodeType===1&&wn.has(ge.tagName);for(let ge of Z){let B=Y.find(ue=>ue.ms<=ge.ms&&ge.me<=ue.me&&ge.ms<ue.me);if(B&&ge.live&&B.ms===ge.ms&&!He(B,ge.live)){let ue=Y.find(he=>he.me===ge.ms&&He(he,ge.live));ue&&(B=ue)}if(!B&&ge.me===ge.ms){let ue=Y.find(te=>te.me===ge.ms),he=Y.find(te=>te.ms===ge.ms),ce=ue||he;if(!ce)continue;let xe=ce.node;for(;Ie(xe.parentNode)&&(ue?xe.parentNode.lastChild:xe.parentNode.firstChild)===xe;)xe=xe.parentNode;if(xe===ce.node)B=ce;else{let te=xe.ownerDocument.createTextNode(ge.text);xe.parentNode.insertBefore(te,ue?xe.nextSibling:xe);continue}}if(!B)continue;let G=B.node.nodeValue;B.node.nodeValue=G.slice(0,ge.ms-B.ms)+ge.text+G.slice(ge.me-B.ms),B.me+=ge.text.length-(ge.me-ge.ms)}}function Me(_){return _.nodeType===1&&_.tagName==="TEMPLATE"&&_.content?_.content:_}function De(_,ie){f.add(_);let me=c.get(ie);if(me&&me.remote&&t.remoteIdOf){let ke=t.remoteIdOf(me.remote);ke&&g.push([_,ke])}if(me&&me.unchanged){t.customIdentity&&me.remote&&ne(_,me.remote),me.remote&&K(_,me.remote);return}if(i.beforeNodeMorphed(_,ie)===!1){R.add(ie);return}gt(_,ie,o.keepLiveOnly&&me&&me.local&&me.local.nodeType===1&&me.local!==_?me.local:null);let pe=_.tagName;if(hn(_))_.textContent!==ie.textContent&&(s.push({kind:"text",node:_,before:_.textContent,after:ie.textContent}),_.textContent=ie.textContent),t.mergedScripts.has(ie)&&A.add(_);else if(pe==="TEXTAREA")zt(_,ie,me);else{an(_,ie,me);let ke=pe==="TEMPLATE"&&_.content?_.content:_,v=pe==="TEMPLATE"&&ie.content?ie.content:ie;o.protectFocusedValue==="subtree"&&$t(_)&&_!==r.body?re(ke):Se(ke,v)}i.afterNodeMorphed(_,ie)}function re(_){for(let ie=_.firstChild;ie;ie=ie.nextSibling){let me=j.get(ie);me&&L.get(me.parentNode)!==_||(f.add(ie),ie.nodeType===1&&re(ie))}}function Se(_,ie){let me=_e(_.firstChild),pe=new Set;for(let ke of Array.from(ie.childNodes)){let v=L.get(ke);v&&f.has(v)&&!pe.has(v)&&(v=null);let P=c.get(ke);if(P&&P.pinned){v&&v.nodeType===1&&((v.parentNode!==_||_e(v.nextSibling)!==me)&&Ae(_,v,me),f.add(v),pe.add(v));continue}if(v&&v.nodeType===1){if(v!==me){let oe=v.parentNode;if(oe===_&&me&&Ht(v)){let je=v.nextSibling;for(let Z=me;Z&&Z!==v;){let Oe=Z.nextSibling;Ae(_,Z,je),Z=Oe}}else Ae(_,v,me),oe!==_&&(a.push(v),s.push({kind:"move",el:v,from:oe,to:_}))}pe.add(v),De(v,ke),me=_e(v.nextSibling);continue}if(v&&v.nodeType!==1){let oe=F.get(ke)||[v],je=oe.map(Oe=>Oe.nodeValue).join(""),Z=ke.nodeValue;if(ke.nodeType===3){let Oe=ve(ke);Oe!=null&&je!==Oe&&(Z=Ho(Oe,je,ke.nodeValue).text)}if(oe.length>1&&je===Z&&!oe.includes(me,1)&&oe.every((Oe,He)=>Oe.parentNode===_&&(He===0||oe[He-1].nextSibling===Oe))){if(v!==me)for(let Oe of oe)Ae(_,Oe,me);i.beforeNodeMorphed(v,ke)!==!1?i.afterNodeMorphed(v,ke):m&&R.add(ke);for(let Oe of oe)f.add(Oe),pe.add(Oe);p.set(ke,v),W.add(ke),me=_e(oe[oe.length-1].nextSibling);continue}v!==me&&Ae(_,v,me),i.beforeNodeMorphed(v,ke)!==!1?(v.nodeValue!==Z&&(s.push({kind:"text",node:v,before:v.nodeValue,after:Z}),v.nodeValue=Z),i.afterNodeMorphed(v,ke)):R.add(ke),f.add(v),pe.add(v),p.set(ke,v),me=_e(v.nextSibling);continue}if(ke.nodeType===3&&me&&me.nodeType===3&&!f.has(me)&&!C.has(me)){me.nodeValue!==ke.nodeValue&&(s.push({kind:"text",node:me,before:me.nodeValue,after:ke.nodeValue}),me.nodeValue=ke.nodeValue),f.add(me),p.set(ke,me),me=_e(me.nextSibling);continue}let Y=c.get(ke),J=Qe(Y&&Y.unchanged&&Y.remote?Y.remote:ke);if(i.beforeNodeAdded(J)===!1){R.add(ke);continue}_.insertBefore(J,me),f.add(J),m&&y.set(ke,J),J.nodeType===3&&p.set(ke,J),J.nodeType===1&&(h.push(J),Pe(J,ke),t.customIdentity&&Y&&Y.unchanged&&Y.remote&&ne(J,Y.remote),hn(J)||Ze(J,ke),o.formState==="property"&&jt(Y)&&K(J,Y.remote)),me=_e(J.nextSibling),s.push({kind:"insert",node:J,parent:_}),i.afterNodeAdded(J)}for(let ke of Array.from(_.childNodes))f.has(ke)||pe.has(ke)||ke.nodeType===1&&(o.ignored(ke)||qe(ke))||(T.has(ke)?u.push({node:ke,parent:_}):ot(ke,_))}function qe(_){return _.parentNode&&_.parentNode.nodeType===1&&_.parentNode.tagName==="HEAD"&&(x&&!x.has(_)||o.preserve&&o.preserve(_)===!0)}function ve(_){let ie=c.get(_);return!ie||!Array.isArray(ie.local)?null:ie.local.map(me=>me.nodeValue).join("")}function w(_){return c.get(_)}function K(_,ie){if(!Gi.has(_.tagName)&&!_.querySelector("input,option,textarea"))return;let me=(pe,ke)=>{if(pe.tagName!==ke.tagName)return;pe.tagName==="TEXTAREA"?zt(pe,ke,{remote:ke}):Gi.has(pe.tagName)&&an(pe,ke,{remote:ke});let v=ee(pe),P=ee(ke);if(v.length===P.length)for(let Y=0;Y<v.length;Y++)me(v[Y],P[Y])};me(_,ie)}function ne(_,ie){let me=ee(_),pe=ee(ie);if(me.length===pe.length)for(let ke=0;ke<me.length;ke++){let v=t.remoteIdOf(pe[ke]);v&&g.push([me[ke],v]),ne(me[ke],pe[ke])}}function ee(_){let ie=_.tagName==="TEMPLATE"&&_.content?_.content:_;return Array.from(ie.children).filter(me=>!o.ignored(me))}function Pe(_,ie){if(!t.remoteIdOf)return;let me=(pe,ke)=>{let v=c.get(ke);if(v&&v.remote&&ke.nodeType===1){let J=t.remoteIdOf(v.remote);J&&g.push([pe,J])}let P=pe.childNodes,Y=ke.childNodes;for(let J=0;J<P.length&&J<Y.length;J++)me(P[J],Y[J])};me(_,ie)}function _e(_){for(;_&&_.nodeType===1&&o.ignored(_);)_=_.nextSibling;return _}function Ae(_,ie,me){if(typeof _.moveBefore=="function"&&ie.ownerDocument===_.ownerDocument)try{_.moveBefore(ie,me);return}catch{}_.insertBefore(ie,me)}function ot(_,ie){if(i.beforeNodeRemoved(_)===!1){m&&M.add(_);return}_.parentNode.removeChild(_),s.push({kind:"remove",node:_,parent:ie}),i.afterNodeRemoved(_)}function Qe(_){if(hn(_))return Vo(_,r);let ie=r.importNode(_,!0);if(ie.nodeType===1)for(let me of Array.from(ie.querySelectorAll("script")))hn(me)&&me.replaceWith(Vo(me,r));return ie}function Ze(_,ie){let me=_.tagName==="TEMPLATE"&&_.content?_.content:_,pe=ie.tagName==="TEMPLATE"&&ie.content?ie.content:ie,ke=Array.from(me.childNodes),v=Array.from(pe.childNodes);for(let P=0;P<v.length&&P<ke.length;P++){let Y=v[P],J=ke[P],oe=L.get(Y);oe&&f.has(oe)&&(oe=null);let je=c.get(Y);if(je&&je.pinned){if(oe&&oe.nodeType===1){let Z=oe.parentNode;Ae(me,oe,J),Z!==me&&(a.push(oe),s.push({kind:"move",el:oe,from:Z,to:me})),f.add(oe)}J.remove();continue}if(oe){let Z=oe.parentNode;Ae(me,oe,J),J.remove(),oe.nodeType===1?(Z!==me&&(a.push(oe),s.push({kind:"move",el:oe,from:Z,to:me})),De(oe,Y)):(f.add(oe),p.set(Y,oe),oe.nodeValue!==Y.nodeValue&&(s.push({kind:"text",node:oe,before:oe.nodeValue,after:Y.nodeValue}),oe.nodeValue=Y.nodeValue));continue}f.add(J),m&&y.set(Y,J),J.nodeType===3&&p.set(Y,J),je&&je.unchanged&&je.remote?(Xe(J,je.remote),t.customIdentity&&ne(J,je.remote)):Y.nodeType===1&&!hn(Y)&&Ze(J,Y)}}function Xe(_,ie){let me=_.tagName==="TEMPLATE"&&_.content?_.content:_,pe=ie.tagName==="TEMPLATE"&&ie.content?ie.content:ie;for(let ke of Array.from(pe.childNodes))me.appendChild(Qe(ke))}function yt(_,ie){return ie.namespaceURI?_.getAttributeNS(ie.namespaceURI,ie.localName):_.getAttribute(ie.name)}function dt(_,ie){let me=new Set((ie||"").split(ds).filter(Boolean));return(_||"").split(ds).filter(pe=>pe&&!me.has(pe))}function gt(_,ie,me){for(let pe of Array.from(ie.attributes)){if(qt(_,pe.name)||o.ignoreAttribute(_,pe.name))continue;let ke=yt(_,pe);if(ke===pe.value||me&&yt(me,pe)===pe.value)continue;let v=pe.value;if(me&&pe.name==="class"&&!pe.namespaceURI){let P=pe.value.split(ds).filter(Boolean),Y=dt(ke,me.getAttribute("class")).filter(J=>!P.includes(J));Y.length&&(v=[...P,...Y].join(" "))}if(ke!==v){if(i.beforeAttributeUpdated(pe.name,_,"update")===!1){m&&O(ie,pe.name);continue}pe.namespaceURI?_.setAttributeNS(pe.namespaceURI,pe.name,v):_.setAttribute(pe.name,v),s.push({kind:"attr",el:_,name:pe.name,before:ke,after:v})}}for(let pe of Array.from(_.attributes)){if(qt(_,pe.name)||o.ignoreAttribute(_,pe.name)||(pe.namespaceURI?ie.hasAttributeNS(pe.namespaceURI,pe.localName):ie.hasAttribute(pe.name)))continue;if(me&&pe.name==="class"&&!pe.namespaceURI){let P=dt(pe.value,me.getAttribute("class"));if(P.length){let Y=P.join(" ");if(Y===pe.value)continue;if(i.beforeAttributeUpdated("class",_,"update")===!1){m&&O(ie,"class");continue}_.setAttribute("class",Y),s.push({kind:"attr",el:_,name:"class",before:pe.value,after:Y});continue}}if(me&&yt(me,pe)===null)continue;if(i.beforeAttributeUpdated(pe.name,_,"remove")===!1){m&&O(ie,pe.name);continue}let v=pe.value;pe.namespaceURI?_.removeAttributeNS(pe.namespaceURI,pe.localName):_.removeAttribute(pe.name),s.push({kind:"attr",el:_,name:pe.name,before:v,after:null})}}function qt(_,ie){let me=_.tagName;return me==="INPUT"?ie==="value"||ie==="checked"||ie==="disabled":me==="OPTION"?ie==="selected":!1}function $t(_){return _===r.activeElement}function Ht(_){let ie=r.activeElement;return!!ie&&ie!==r.body&&_.contains(ie)}function jt(_){let ie=_&&_.remote;return ie&&ie.nodeType===1?ie:null}function an(_,ie,me){let pe=_.tagName,ke=jt(me),v=o.formState==="property"&&ke?ke:ie;if(pe==="INPUT"){let P=o.protectFocusedValue&&$t(_),Y=(_.getAttribute("type")||"").toLowerCase(),J=Y!=="file"&&Y!=="checkbox"&&Y!=="radio",oe=ke&&ke.hasAttribute("value")&&ke.value!==ke.getAttribute("value")?ke.value:null;if(J&&!P)if(o.formState==="property"){let je=ie.getAttribute("value"),Z=_.getAttribute("value");(Z!==je||_.value!==v.value)&&E("value",_,je==null?"remove":"update")!==!1&&(Z!==je&&(je==null?_.removeAttribute("value"):_.setAttribute("value",je),s.push({kind:"attr",el:_,name:"value",before:Z,after:je})),_.value!==v.value&&(_.value=v.value))}else if(ie.hasAttribute("value")||oe!=null){let je=oe??ie.getAttribute("value");_.getAttribute("value")!==je&&E("value",_,"update")!==!1?(_.setAttribute("value",je),_.value!==je&&(_.value=je),s.push({kind:"attr",el:_,name:"value",before:null,after:je})):_.value!==je&&_.getAttribute("value")===je&&(_.value=je)}else(_.hasAttribute("value")||_.value!=="")&&E("value",_,"remove")!==!1&&(_.removeAttribute("value"),_.value="",s.push({kind:"attr",el:_,name:"value",before:"",after:null}));if(!J&&Y!=="file"){let je=ie.getAttribute("value");je==null?_.hasAttribute("value")&&E("value",_,"remove")!==!1&&_.removeAttribute("value"):_.getAttribute("value")!==je&&E("value",_,"update")!==!1&&_.setAttribute("value",je)}P||(_t(_,v,"checked"),o.formState==="property"&&_.indeterminate!==v.indeterminate&&(_.indeterminate=v.indeterminate)),_t(_,v,"disabled")}else if(pe==="OPTION"){let P=_.parentNode&&_.closest("select");o.protectFocusedValue&&P&&$t(P)||_t(_,v,"selected")}}function _t(_,ie,me){let pe=o.formState==="property"?!!ie[me]:ie.hasAttribute(me);if(o.formState!=="property"){let ke=_.hasAttribute(me);if(ke!==pe){if(E(me,_,pe?"update":"remove")===!1)return;pe?_.setAttribute(me,""):_.removeAttribute(me),s.push({kind:"attr",el:_,name:me,before:ke?"":null,after:pe?"":null})}}_[me]!==pe&&(_[me]=pe)}function zt(_,ie,me){if(o.protectFocusedValue&&$t(_)||E("value",_,"update")===!1)return;let pe=jt(me),ke=ie.textContent,v=pe&&pe.value!==pe.defaultValue?pe.value:ke;o.formState!=="property"&&_.textContent!==ke&&(s.push({kind:"text",node:_,before:_.textContent,after:ke}),_.textContent=ke),_.value!==v&&(_.value=v)}}function la(e,n){let t=e.activeElement;if(!t||t===e.body||t===e.documentElement)return null;let o={el:t,id:t.getAttribute&&t.getAttribute("id"),scrollTop:t.scrollTop,scrollLeft:t.scrollLeft};if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"){try{o.selection=[t.selectionStart,t.selectionEnd,t.selectionDirection]}catch{}return o}let r=e.getSelection&&e.getSelection();if(r&&r.rangeCount){let c=r.getRangeAt(0);o.range={sc:c.startContainer,so:c.startOffset,ec:c.endContainer,eo:c.endOffset}}return o}function ca(e,n,t,o,r,c,l){if(!n)return;let i=n.el;if(!i.isConnected&&n.id&&(i=e.getElementById(n.id)),!i||!i.isConnected)return;if(e.activeElement!==i)try{i.focus({preventScroll:!0})}catch{}try{i.scrollTop=n.scrollTop,i.scrollLeft=n.scrollLeft}catch{}if(n.selection){try{i.setSelectionRange&&!i.selectionEnd&&n.selection[1]!=null&&i.setSelectionRange(n.selection[0],n.selection[1],n.selection[2]||"none")}catch{}return}if(!n.range)return;let s=(f,u)=>{let g=t.get(f);if(Array.isArray(g)){let b=g.find(y=>u>=y.from&&u<y.to)||g.find(y=>u===y.to)||g[g.length-1],A=c.get(b.merged);if(!A||!A.isConnected)return null;let p=o.get(b.merged),m=p&&p.flat?p.flat(b.flatStart+u):u;return[A,Math.max(0,Math.min(m,A.nodeValue.length))]}if(g&&!l.has(g.merged)){let b=(r.get(g.merged)||[f])[0];if(!b.isConnected)return null;let A=o.get(g.merged),p=g.shift+u,m=A?A(p):p;return[b,Math.max(0,Math.min(m,b.nodeValue.length))]}return f.isConnected?[f,Math.min(u,f.nodeType===3?f.nodeValue.length:f.childNodes.length)]:null},a=s(n.range.sc,n.range.so),h=s(n.range.ec,n.range.eo);if(!(!a||!h))try{let f=e.createRange();f.setStart(a[0],a[1]),f.setEnd(h[0],h[1]);let u=e.getSelection();u.removeAllRanges(),u.addRange(f)}catch{}}var aa={compared:0},fa=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function ua(e,n,t){let o=0;for(let r of e.attributes)if(!t(e,r.name)&&(o++,n.getAttribute(r.name)!==r.value))return!1;for(let r of n.attributes)t(n,r.name)||o--;return o===0}function hs(e,n){if(e.namespaceURI!==n.namespaceURI||e.prefix!==n.prefix||e.localName!==n.localName)return!1;let t=e.attributes;if(t.length!==n.attributes.length)return!1;for(let o of t)if(n.getAttributeNS(o.namespaceURI,o.localName)!==o.value)return!1;return!0}function Xi(e,n,t,o,r,c,l,i){let s=new Map,a=new Set,h=f=>{if(o(f))return;let u=t(f);u&&(c.add(u),r.has(u)||s.has(u)?a.add(u):s.set(u,f))};for(let f of e)h(f);h(n);for(let f of l||n.querySelectorAll("*"))h(f);for(let f of a)s.delete(f),i.add(f);return s}function Ji(e,n,t,o,r,c){let l=!1;for(let h of r)h.startsWith("merge:")&&(l=!0);if(!l)return[...o];let i=new Map,s=[],a=c===bn?$o:"*";for(let h of[e,...e.querySelectorAll(a)]){if(t(h))continue;let f=n(h);if(!f||!(o.has(f)||r.has(f)))continue;let u=(i.get(f)||0)+1;i.set(f,u),u===2&&s.push(f)}return s}function Qi({baseRoot:e,remoteRoot:n,liveRoot:t,toLive:o,o:r,identity:c,baseURI:l}){if(e.tagName!==n.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||n.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!ua(e,n,r.ignoreAttribute))return{bail:"root-attrs"};let{ignored:i,remoteWins:s}=r,a=us(r.scripts.merge===!1?null:r.scripts.mergeTags,l),h=ve=>{let w=a(ve);return w!==null?w:c.base(ve)||null},f=ve=>{let w=a(ve);return w!==null?w:c.remote(ve)||null},u=[],g=[],b=new Map,A=new Map,p={same:b,differ:A},m=ve=>({bail:ve,comparisons:p}),y=(ve,w,K=!0)=>{if(b.get(ve)===w)return!0;if(A.get(ve)===w)return!1;if(aa.compared++,K&&ve.isEqualNode(w))return b.set(ve,w),!0;let ne=ve.nodeType===w.nodeType;if(ne&&ve.nodeType===1){if(ne=hs(ve,w),ne){let ee=ve.firstChild,Pe=w.firstChild;for(;ee&&Pe;ee=ee.nextSibling,Pe=Pe.nextSibling)if(!y(ee,Pe,!1)){ne=!1;break}(ee||Pe)&&(ne=!1)}}else ne&&(ne=ve.isEqualNode(w));return(ne?b:A).set(ve,w),ne},R=e,S=n,O=!1,M=()=>{b.set(R,S);for(let ve=0;ve<u.length;ve++)b.set(u[ve],g[ve]);return m("equal")};for(;;){let ve=R.childNodes,w=S.childNodes;if(ve.length!==w.length)break;let K=Qe=>y(ve[Qe],w[Qe])?(b.set(ve[Qe],w[Qe]),!1):!0,ne=-1,ee=-1;for(let Qe=0;Qe<ve.length;Qe++){if(ve[Qe].nodeType!==1)continue;let Ze=0;for(let Xe=ve[Qe].firstElementChild;Xe;Xe=Xe.nextElementSibling)Ze++;Ze>=ee&&(ee=Ze,ne=Qe)}let Pe=[],_e=!1;for(let Qe=0;Qe<ve.length&&Pe.length<2;Qe++)Qe!==ne&&K(Qe)&&Pe.push(Qe);if(ne>=0&&Pe.length<2&&(Pe.length===0&&hs(R,S)?(Pe.push(ne),_e=!0):K(ne)&&Pe.push(ne)),Pe.length!==1){if(!O&&Pe.length===0&&hs(R,S))return M();break}let Ae=ve[Pe[0]],ot=w[Pe[0]];if(O=O||!_e,O&&A.set(Ae,ot),Ae.nodeType!==1||ot.nodeType!==1||Ae.tagName!==ot.tagName)break;if(h(Ae)!==f(ot)){if(!O&&y(Ae,ot))return M();break}u.push(R),g.push(S),R=Ae,S=ot}A.set(R,S);for(let ve=0;ve<u.length;ve++)A.set(u[ve],g[ve]);if(R===e||R.tagName==="HEAD"||R.tagName==="BODY")return m("root-level");if(u.length<2||u[1].tagName!=="BODY")return m("not-in-body");if(i(R)||i(S))return m("ignored-ancestor");if(s(R)||s(S))return m("remote-wins-ancestor");for(let ve of u)if(fa.has(ve.tagName))return m("form-ancestor");if(R.tagName==="SCRIPT"||R.getElementsByTagName("script").length||S.getElementsByTagName("script").length)return m("script-or-template");let E=o(R);if(!E||E.nodeType!==1||E.tagName!==R.tagName)return m("no-live-twin");if(!t.contains(E))return m("live-detached");for(let ve of u){let w=o(ve);if(!w||w.nodeType!==1)return m("ancestor-live")}let N=c.base===bn&&c.remote===bn&&i===Hr,L=new Set,j=new Set,F=[],W=null,C=ve=>{ve&&(L.has(ve)?j.add(ve):L.add(ve))},T=(ve,w)=>{let K=a(ve),ne=K!==null?K:c.base(ve)||null;return ne!==(K!==null?K:c.remote(w)||null)?!1:(C(ne),!0)},x=(ve,w)=>{for(let K=ve.firstElementChild,ne=w.firstElementChild;K;K=K.nextElementSibling,ne=ne.nextElementSibling){let ee=i(K);if(ee!==i(ne))return!1;if(!ee&&(!T(K,ne)||!x(K,ne)))return!1}return!0},z=ve=>{let w=ve+1<u.length?u[ve+1]:R;for(let K=u[ve].firstElementChild,ne=g[ve].firstElementChild;K;K=K.nextElementSibling,ne=ne.nextElementSibling){if(K===w){let _e=ve+1<u.length?z(ve+1):null;if(_e)return _e;continue}let ee=i(K);if(ee!==i(ne))return"outside-id-changed";if(ee)continue;let Pe=o(K);if(!Pe||Pe.nodeType!==1)return"sibling-live";if(F.push([K,ne]),!N&&(!T(K,ne)||!x(K,ne)))return"outside-id-changed";ve===0&&K.tagName==="HEAD"&&h(K)&&(W=[K,ne])}return null},D=z(0);if(D)return m(D);let V=new Set(u),Ee=null;if(c.base===bn){Ee=[];for(let ve of e.querySelectorAll($o))ve===R||V.has(ve)||(R.contains(ve)?Ee.push(ve):N&&C(h(ve)))}let Me=new Set,De=new Set,re=new Set,Se=Xi(u,R,h,i,L,Me,Ee,De),qe=Xi(g,S,f,i,L,Me,c.remote===bn&&S.querySelectorAll($o),re);return W&&(j.has(h(W[0]))||Me.has(h(W[0])))&&(W=null),{scope:{chain:u,root:R,onChain:V,baseIndex:Se,remoteIndex:qe,baseDropped:De,remoteDropped:re,head:W,same:b,differ:A,dropped:[...Ji(e,h,i,j,De,c.base),...Ji(n,f,i,j,re,c.remote)],held:ve=>{for(let w=1;w<u.length;w++)if(ve.map.get(u[w])!==g[w])return!1;for(let[w,K]of F)if(ve.map.get(w)!==K)return!1;return!0}}}}var qu=Symbol("hyper-morph-duplicate-key");var da='[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"]',ha='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',pa='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function ma(e){if(e.tagName!=="LINK"&&e.tagName!=="SCRIPT")return!1;let n=e.getAttribute("src")||e.getAttribute("href")||"";return/^(chrome|moz|safari-web)-extension:/.test(n)}function ga(e,n,t,o){if(n==null)return;if(typeof n=="string")return n;let r=n;if(r.nodeType===9){let c=e.getAttribute("id");r=c&&r.getElementById(c)||(e.tagName==="BODY"?r.body:e.tagName==="HTML"?r.documentElement:r.body&&r.body.firstElementChild)}if((!r||r.nodeType!==1||r.tagName!==e.tagName)&&(r=ba(e,n,o)),!!r)return t?Array.from(r.childNodes):r}function ba(e,n,t){let o=n.nodeType===9?n.documentElement:n;if(!o||o.nodeType!==1)return null;let r=new Map,c=[o,...o.querySelectorAll("script")];for(let s of c){let a=So(s,t);a&&!r.has(a.key)&&r.set(a.key,s.textContent)}if(!r.size)return null;let l=e.cloneNode(!0),i=!1;for(let s of[l,...l.querySelectorAll("script")]){let a=So(s,t);a&&r.has(a.key)&&(s.textContent=r.get(a.key),i=!0)}return i?l:null}function Zi(e,n){if(typeof e=="string"||e.nodeType===9)return e;if(e.nodeType===1&&e===e.ownerDocument.documentElement)return e.ownerDocument;let t=n.implementation.createHTMLDocument(""),o=e.nodeType===1&&e.tagName==="HTML"?e:null;if(o)return t.replaceChild(t.adoptNode(o),t.documentElement),t;let r=e.nodeType===11?Array.from(e.childNodes):e.nodeType?[e]:Array.from(e);for(let c of r)t.body.appendChild(t.adoptNode(c));return t}function ps(e,n,t={}){let o=t||{};if(!o.head?.block)return el(e,n,o);try{return el(e,n,o)}catch(r){return Promise.reject(r)}}function el(e,n,t){let o=t.policy||"sync",r=o==="raw"?void 0:(s,a)=>ma(s)||(o==="history"?!(a&&s.matches(pa))&&s.matches(ha):s.matches(da)),c=t.callbacks||{},l={ignore:r,hooks:c,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 Ko(Object.assign({},l,{live:e,base:t.scripts?.mergeBase||null,remote:Zi(n,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let s=Object.assign({},l,{live:e.ownerDocument,base:t.scripts?.mergeBase||null,remote:Zi(n,e.ownerDocument)});return Ko(s)}t.morphStyle==="innerHTML"&&(l.children=!0);let i=ga(e,t.scripts?.mergeBase,!!l.children,l.scripts.mergeTags);return i!==void 0&&(l.base=i),ms(e,n,l)}var ya=new Set(["live","base","remote","local","identity","ignore","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly"]),Nn=()=>{};function qo(e,n=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!ya.has(l))throw new TypeError(`unknown option "${l}"`);let t=Object.assign({beforeNodeAdded:Nn,afterNodeAdded:Nn,beforeNodeRemoved:Nn,afterNodeRemoved:Nn,beforeNodeMorphed:Nn,afterNodeMorphed:Nn,beforeAttributeUpdated:Nn},e.hooks||{}),o=e.conflicts||"remote";if(!["remote","local","both"].includes(o))throw new TypeError("conflicts must be remote, local or both");let r=e.formState||"attribute";if(!["attribute","property"].includes(r))throw new TypeError("formState must be attribute or property");let c=e.protectFocusedValue;if(c!==void 0&&typeof c!="boolean"&&c!=="subtree")throw new TypeError('protectFocusedValue must be a boolean or "subtree"');if(e.fastPath!==void 0&&typeof e.fastPath!="boolean")throw new TypeError("fastPath must be a boolean");if(e.keepLiveOnly!==void 0&&typeof e.keepLiveOnly!="boolean")throw new TypeError("keepLiveOnly must be a boolean");return{ignored:Wr(e.ignore,n),remoteWins:Wr(e.remoteWins,n),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,conflicts:o,protectFocusedValue:c===void 0?!0:c,restoreFocus:e.restoreFocus!==!1,head:Object.assign({awaitLoads:!1,preserve:()=>!1},e.head||{}),scripts:Object.assign({execute:!0,merge:!0,mergeTags:[]},e.scripts||{}),formState:r,hooks:t,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0}}function Mo(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 bn}function Eo(e,n){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let t=Vr(n,e.map),o=typeof e.then=="function"?e.then:bn;if(typeof e.first=="function"){let r=e.first;return c=>r(c)||t.get(c)||o(c)}return r=>t.get(r)||o(r)}return bn}function wa(e,n,t,o={}){let r=g=>g&&g.nodeType===9?g.documentElement:g,c=r(n),l=r(t),i=r(e)||c,s=Object.assign({},o);delete s.live,delete s.base,delete s.remote;let a=qo(s,[i,c,l].filter(Boolean)),h=o.identity||{},f=Xn(),u=Nr(i,c,l,{identity:{base:Eo(h.base,i),local:Eo(h.local,c),remote:Eo(h.remote,l)},authored:{base:Mo(h.base),local:Mo(h.local),remote:Mo(h.remote)},skipUnchanged:a.hooks.beforeNodeMorphed===Nn&&a.hooks.afterNodeMorphed===Nn,ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:c.ownerDocument&&c.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===n,childrenOnly:a.children,stats:f});return delete u.recoveryLinks,u}function gs({liveRoot:e,baseRoot:n,localRoot:t,remoteRoot:o,toLive:r,options:c,identity:l,childrenOnly:i,isDocument:s}){let a=qo(c,[e,n,t,o].filter(Boolean));if(a.ignored(e))return{report:bs(),loads:[]};let h=e.ownerDocument,f=a.scripts.execute?Si(e,a.ignored,h.baseURI):null,u=Xn(),g=a.hooks.beforeNodeMorphed===Nn&&a.hooks.afterNodeMorphed===Nn,b={identity:{base:Eo(l.base,n||t),local:Eo(l.local,t),remote:Eo(l.remote,o)},authored:{base:Mo(l.base),local:Mo(l.local),remote:Mo(l.remote)},ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:h.baseURI,localIsBase:!n,childrenOnly:i,skipUnchanged:g},A=a.fastPath&&s&&!i&&g&&n===t,p=null,m=null;if(A){let C=Qi({baseRoot:n,remoteRoot:o,liveRoot:e,toLive:r,o:a,identity:b.identity,baseURI:h.baseURI});b.comparisons=C.comparisons||C.scope,C.bail?m=C.bail:(p=Nr(n,t,o,Object.assign({},b,{stats:u,scope:C.scope})),p||(m="chain-unpaired",u=Xn()))}p||(p=Nr(n||t,t,o,Object.assign({},b,{stats:u}))),A&&(u.fastPathAttempted=1,u.fastPathTaken=m?0:1,u.fastPathFallback=m),p.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(C=>a.hooks[C]!==Nn)&&Pi(p.conflicts,p.recoveryLinks,r),a.beforeApply&&a.beforeApply(p.doc);let y=globalThis.__hyperMorphProfile,R=y?performance.now():0,S=Yi(e,p.root,p,{toLive:r,localRoot:t,ignored:a.ignored,ignoreAttribute:a.ignoreAttribute,formState:a.formState,protectFocusedValue:a.protectFocusedValue,restoreFocus:a.restoreFocus,preserve:a.head.preserve,hooks:a.hooks,childrenOnly:i,keepLiveOnly:a.keepLiveOnly});y&&(y.apply=(y.apply||0)+(performance.now()-R));let O=[];if(a.head.awaitLoads)for(let C of S.applied){if(C.kind!=="insert"||C.node.nodeType!==1)continue;let T=C.node;T.tagName==="LINK"&&/\bstylesheet\b/i.test(T.getAttribute("rel")||"")&&T.getAttribute("href")&&T.closest("head")&&O.push(new Promise(z=>{T.addEventListener("load",()=>z()),T.addEventListener("error",()=>z())}))}let M=null,E=null;if(f){let C=Ni(e,f,{ignored:a.ignored,skip:S.mergedScriptsLive,baseURI:h.baseURI,beforeNodeAdded:a.hooks.beforeNodeAdded,afterNodeAdded:a.hooks.afterNodeAdded,trackRecovery:!!p.recoveryLinks});O.push(...C.loads),M=C.swapped,E=C.vetoed}let N=C=>M&&M.get(C)||C,L=C=>{if(S.keptRuns.has(C))return S.runOf.get(C);let T=S.liveOf.get(C)||S.heldBy.get(C)||S.insertedLive.get(C);return T?N(T):null},j=C=>{let T=C&&S.liveOf.get(C);return T?N(T):null},F=C=>{let T=C&&L(C);return Array.isArray(T)?T[0]:T};if(p.recoveryLinks){let C=(T,x,z)=>(x.namespaceURI?T.getAttributeNS(x.namespaceURI,x.localName):T.getAttribute(x.qualifiedName))===z;Bi(p.conflicts,p.recoveryLinks,{lookup:L,vetoed:S.vetoed,vetoedAttrs:S.vetoedAttrs,removedVetoes:S.removedVetoes,vetoedLive:E,liveAttr:C,ignored:a.ignored,liveRoot:e})}return{report:{applied:S.applied,decisions:p.decisions.map(C=>Object.assign({},C,{node:C.node?j(C.node):null,el:C.el?j(C.el):null,applied:!!(C.node?j(C.node):C.el&&j(C.el))})),conflicts:p.conflicts.map(C=>Object.assign({},C,{node:C.node?C.kind==="text"&&C.recovery.subject.nodeType===8?F(C.node):j(C.node):C.node,el:C.el?C.kind==="structure"?F(C.el):j(C.el):C.el})),localDiverged:p.localDiverged,identities:S.identities,moved:S.moved,replaced:S.replaced,stats:u},loads:O}}var tl=new WeakMap;function bs(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Xn()}}function Ko(e){let n=e||{},t=n.live;if(!t||t.nodeType!==9)throw new TypeError("live must be a Document");let o=tl.get(t);o||(o=Ur(t),tl.set(t,o));let r=o("remote",n.remote),c=typeof n.base=="string"&&n.base===""?null:n.base,l=c?o("base",c):null,i=n.local?n.local.root:t.documentElement,s=n.local?n.local.toLive:f=>f;Zs(t,r);let{report:a,loads:h}=gs({liveRoot:t.documentElement,baseRoot:l?l.documentElement:null,localRoot:i,remoteRoot:r.documentElement,toLive:s,options:n,identity:n.identity||{},childrenOnly:!1,isDocument:!0});return Promise.all(h).then(()=>a)}function xa(e,n,t={}){return Ko(Object.assign({},t,{live:e,base:null,remote:n}))}function nl(e,n){if(e==null)return{root:n.createElement("template"),first:null};if(typeof e=="string"){let o=/^\s*(?:<!--[\s\S]*?-->\s*)*(?:<!doctype[^>]*>\s*)?<(html|body)[\s>]/i.exec(e);if(o){let c=pr(e,n),l=o[1].toLowerCase()==="html"?c.documentElement:c.body;return{root:l,first:l}}let r=n.createElement("template");return r.innerHTML=e,{root:r,first:r.content.firstElementChild}}if(e.nodeType===9)return{root:e.documentElement,first:e.documentElement};if(e.nodeType===1){let o=n.createElement("template"),r=e.isConnected;return o.content.appendChild(r?n.importNode(e,!0):e),{root:o,first:e}}if(e.nodeType===11){let o=n.createElement("template");return o.content.appendChild(e),{root:o,first:o.content.firstElementChild}}let t=n.createElement("template");for(let o of Array.from(e))t.content.appendChild(o.parentNode?n.importNode(o,!0):o);return{root:t,first:t.content.firstElementChild}}function ms(e,n,t={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");let o=e.ownerDocument,{base:r,...c}=t,l=!!c.children;if(qo(c,[e]).ignored(e))return Promise.resolve(bs());let i=nl(n,o),s=r!=null?nl(r,o):null,a,h=null;if(l)a=i.root,h=s?s.root:null;else{if(a=i.first,h=s?s.first:null,!a){let g=qo(c);return g.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),g.hooks.afterNodeRemoved(e)),Promise.resolve({applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Xn()})}if(a.tagName!==e.tagName){let g=qo(c,[e,a]);if(g.hooks.beforeNodeMorphed(e,a)===!1)return Promise.resolve(bs());let b=gs({liveRoot:e,baseRoot:h&&h.tagName===e.tagName?h:null,localRoot:e,remoteRoot:a,toLive:p=>p,options:c,identity:c.identity||{},childrenOnly:!0,isDocument:!1}),A=hn(a)?Vo(a,o):o.importNode(a,!1);if(!hn(A))for(;e.firstChild;)A.appendChild(e.firstChild);return g.hooks.beforeNodeAdded(A)===!1?(Sr(b.report.conflicts,e,e),Promise.resolve(b.report)):g.hooks.beforeNodeRemoved(e)===!1?(Sr(b.report.conflicts,e,e),Promise.resolve(b.report)):(e.replaceWith(A),Sr(b.report.conflicts,e,A),g.hooks.afterNodeRemoved(e),g.hooks.afterNodeAdded(A),g.hooks.afterNodeMorphed(e,a),b.report.replaced.push(A),b.report.applied.push({kind:"insert",node:A,parent:A.parentNode},{kind:"remove",node:e,parent:A.parentNode}),Promise.all(b.loads).then(()=>b.report))}}let{report:f,loads:u}=gs({liveRoot:e,baseRoot:h,localRoot:e,remoteRoot:a,toLive:g=>g,options:c,identity:c.identity||{},childrenOnly:l,isDocument:!1});return Promise.all(u).then(()=>f)}var ol={mergeDocument:Ko,morphDocument:xa,morphElement:ms,merge3:wa,morph:ps};function ys(e,n,{onWidgetRemoved:t}={}){ol.morph(e,n,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=dr.get(o);r?.destroy&&r.destroy(),t?.(o)}}})}var Ta="hha:upgrade-check:";function Wn(e,n){let t=e.querySelector(`meta[name="${n}"]`),o=t?t.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function ws(e){if(typeof e!="string")return null;let n=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(n)?n.split(".").map(Number):null}function rl(e,n){let t=ws(e),o=ws(n);if(!t||!o)return!1;let r=Math.max(t.length,o.length);for(let c=0;c<r;c++){let l=t[c]||0,i=o[c]||0;if(l!==i)return l>i}return!1}function Aa(e){try{let n=globalThis.localStorage.getItem(e);return n?JSON.parse(n):null}catch{return null}}function Sa(e,n){try{globalThis.localStorage.setItem(e,JSON.stringify(n))}catch{}}async function xs({force:e=!1,doc:n,loc:t,fetchFn:o,now:r,ttlMs:c=864e5}={}){if(n=n||(typeof document<"u"?document:null),t=t||(typeof location<"u"?location:null),o=o||(u=>fetch(u)),r=r??Date.now(),!n)return null;let l=Wn(n,"hyper-source");if(!l)return null;let i=Wn(n,"hyper-version"),s;try{s=new URL(l,t?t.href:void 0)}catch{return null}if(t&&s.origin===t.origin&&s.pathname===t.pathname)return null;let a=`${Ta}${s.href}:${i||"none"}`,h,f=e?null:Aa(a);if(f&&typeof f.checkedAt=="number"&&r-f.checkedAt<c)h=f.sourceVersion;else{try{let u=await o(s.href);if(!u.ok)throw new Error(`HTTP ${u.status}`);let g=await u.text(),b=new DOMParser().parseFromString(g,"text/html");h=Wn(b,"hyper-version")}catch{h=null}Sa(a,{checkedAt:r,sourceVersion:h})}return h?{available:rl(h,i||"0.0.0"),currentVersion:i,sourceVersion:h,sourceUrl:s.href}:null}var vr=["textContent","innerText","innerHTML","outerHTML","value","checked","selected","disabled","readOnly","type","tagName","nodeName","nodeType","nodeValue","childElementCount","id","className","classList","baseURI","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","dataset","currentSrc","duration","paused","title","documentURI","contentType"],ks=new Set(vr),sl=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),zo=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]);var Vn={};Lr(Vn,{EmptyListInsert:()=>Yo,MAX_RULE_DEPTH:()=>Co,MaxRuleDepthExceeded:()=>uo,NoRulesTag:()=>Ts,RuleTargetReadOnly:()=>Xo,RulesParseError:()=>Io,ShapeMismatch:()=>Go,UnknownRulesVersion:()=>fo,WriteRefused:()=>Jo,WriteRejected:()=>As});var Io=class extends Error{constructor(n,t){super(n),this.name="RulesParseError",this.cause=t}},fo=class extends Error{constructor(n){super(`unknown rules version: ${n}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=n}},Co=20,uo=class extends Error{constructor(n){super(`rule depth exceeded ${Co} at path: ${n.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=n}},Go=class extends Error{constructor(n){super(`shape mismatch: ${n.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=n}},Yo=class extends Error{constructor(n){super(`cannot add items to empty list at "${n.join(".")}" \u2014 no sibling to clone as template. Seed the list with a hidden item first.`),this.name="EmptyListInsert",this.path=n}},Xo=class extends Error{constructor(n){super(`cannot write to read-only DOM property "${n}"`),this.name="RuleTargetReadOnly",this.target=n}},Jo=class extends Error{constructor(n){super(`write refused: ${n.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=n}},Ts=class extends Error{constructor(n){super(`no <script data-rules-name~="${n}"> rules tag in this document`),this.name="NoRulesTag",this.token=n}},As=class extends Error{constructor(n,t){super(`write rejected: ${n.length} unknown key(s), ${t.length} rule(s) with no matching element`),this.name="WriteRejected",this.unknownKeys=n,this.unmatched=t}};function _n(e,n,t,o={}){if(Object.prototype.hasOwnProperty.call(o,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");return Ss(e,n,t,{depth:0,path:[]},o)}function Ss(e,n,t,o,r){if(o.depth>Co)throw new uo(o.path);if(typeof t=="string")return Na(e,n,t,o,r);if(Array.isArray(t)){let[c,l]=t,i=e.find(n,c,r);return ll(r,o,i),i.map((s,a)=>Ss(e,s,l,{depth:o.depth+1,path:[...o.path,a]},r))}if(typeof t=="object"&&t!==null){let c={};for(let[l,i]of Object.entries(t))c[l]=Ss(e,n,i,{depth:o.depth+1,path:[...o.path,l]},r);return c}return null}function Na(e,n,t,o,r){if(t.endsWith("[]")){let i=t.slice(0,-2),s=e.find(n,i,r);return ll(r,o,s),s.map(a=>e.text(a))}if(t.startsWith("@"))return il(e,n,t.slice(1));let c=On(t);if(c!==-1){let i=t.slice(0,c),s=t.slice(c+1),a=i?e.find(n,i,r):[n];return a.length===0?null:il(e,a[0],s)}if(t===".")return e.text(n);let l=e.find(n,t,r);return l.length===0?null:e.text(l[0])}function ll(e,n,t){if(typeof e.onRowsRead=="function")try{e.onRowsRead(n.path.slice(),t)}catch(o){console.warn(`[hyper-html-api] onRowsRead threw at "${n.path.join(".")||"(root)"}"`,o)}}function il(e,n,t){if(ks.has(t)){let r=e.prop(n,t);return r==null?null:String(r)}let o=e.attr(n,t);return o||null}var cl=Object.freeze({data:Object.freeze({tokens:["no-data"],bundles:["editor-ui"]}),save:Object.freeze({tokens:["no-save"],bundles:["editor-ui"]}),snapshot:Object.freeze({tokens:["no-snapshot"],bundles:["editor-ui"]}),watch:Object.freeze({tokens:["no-watch"],bundles:["editor-ui"]}),undo:Object.freeze({tokens:["no-undo"],bundles:["editor-ui"]}),history:Object.freeze({tokens:[],bundles:["editor-ui"]})}),va=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),al=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui"]);function Ns(e,n){if(!e||e.nodeType!==1)return!1;let t=e.getAttribute?.("clay");return!!(t&&t.split(/\s+/).includes(n)||e.hasAttribute?.(n))}function Oa(e,n){if(Ns(e,n))return!0;for(let[t,o]of Object.entries(va))if(o.includes(n)&&Ns(e,t))return!0;return!1}function Qo(e){let n=cl[e];if(!n)throw new Error(`Unknown region capability: ${e}`);return[...n.tokens,...n.bundles].flatMap(t=>[`[clay~="${t}"]`,`[${t}]`]).join(", ")}function Ma(e,n){let t=e&&e.nodeType===1?e:e?.parentElement;for(;t&&t.nodeType===1;){let o=cl[n];if(!o)throw new Error(`Unknown region capability: ${n}`);if(o.tokens.some(r=>Oa(t,r))||o.bundles.some(r=>Ns(t,r)))return t;t=t.parentElement}return null}function fl(e,n){return!!Ma(e,n)}var Ea=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function ul(e,n){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let t=(e.getAttribute?.("type")||"").toLowerCase();if("value"in e&&"value"in n&&e.tagName!=="OPTION"&&t!=="checkbox"&&t!=="radio"&&t!=="file"&&(n.value=e.value),e.tagName==="INPUT"&&(t==="checkbox"||t==="radio")&&(n.checked=e.checked),e.tagName==="OPTION"&&(n.selected=e.selected),e.tagName==="SELECT")for(let o=0;o<e.options.length;o++)n.options[o].selected=e.options[o].selected;"indeterminate"in e&&"indeterminate"in n&&(n.indeterminate=e.indeterminate)}function dl(e,n,t,o){if(o)return!!e.closest?.(n);let r=e;for(;r?.nodeType===1;){if(r.matches(n))return!0;if(r===t)break;r=r.parentElement}return!1}function hl(e,n,t,o,r,c,l,i){if(e.nodeType===1&&((l?fl(e,t):dl(e,o,c,!1))||r&&(l&&e!==c?e.matches(r):dl(e,r,c,l))))return null;let s=n.importNode(e,!1);i.cloneToLive.set(s,e),i.liveToClone.set(e,s);let a=e.nodeType===1&&e.tagName==="TEMPLATE"?e.content:e,h=s.nodeType===1&&s.tagName==="TEMPLATE"?s.content:s;a!==e&&(i.cloneToLive.set(h,a),i.liveToClone.set(a,h));for(let f of a.childNodes||[]){let u=hl(f,n,t,o,r,c,l,i);u&&(h.appendChild(u),f.nodeType===1&&ul(f,u))}return e.nodeType===1&&ul(e,s),s}function Zo(e,{capability:n="data",exclude:t=null,inherit:o=!0}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let r=e.nodeType===9?e:e.ownerDocument;if(!r?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let c=r.implementation.createHTMLDocument(""),l=new WeakMap,i=new WeakMap,s=e.nodeType===9?e.documentElement:e;t&&c.documentElement.matches(t);let a=Qo(n),h=hl(s,c,n,a,t,s,o,{cloneToLive:l,liveToClone:i});e.nodeType===9&&h&&(c.replaceChild(h,c.documentElement),i.set(e,c),l.set(c,e));let f=u=>{if(Ea.test(u))throw new Error(`Filtered content queries do not support stateful selector: ${u}`)};return{root:h,document:c,capability:n,selector:Qo(n),cloneToLive:l,liveToClone:i,original(u){return l.get(u)||null},cloneOf(u){return i.get(u)||null},query(u,g=h){return f(u),Array.from(g.querySelectorAll(u),b=>l.get(b)||b)},text(u=h){return(u===h?h:i.get(u))?.textContent||""},html(u=h){return(u===h?h:i.get(u))?.innerHTML??""},clone(u=h){let g=u===h?h:i.get(u);return g?c.importNode(g,!0):null}}}function pl(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Ia(e){return e?(e.nodeType===9||e.nodeType===11,e):null}var on={semanticExclude:!0,find(e,n,t={}){let o=Ia(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(n));t.includeRulesTag||(r=r.filter(i=>!pl(i)));let c=[];t.skip&&c.push(t.skip);let l=t.templateAttr===null?null:t.templateAttr||"cms-template";if(l&&c.push("["+l+"]"),c.length){let i=c.join(", ");r=r.filter(s=>!s.closest||!s.closest(i))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},text(e,n){if(n===void 0)return(e.textContent||"").trim();e.textContent=n},attr(e,n,t){if(t===void 0)return e.hasAttribute&&e.hasAttribute(n)?e.getAttribute(n):null;e.setAttribute(n,t)},removeAttr(e,n){e&&e.removeAttribute&&e.removeAttribute(n)},prop(e,n,t){if(t===void 0){let o=e?e[n]:void 0;return o!==void 0?o:null}e[n]=t},clone(e){return e.cloneNode(!0)},insertAt(e,n,t){let o=e.children[t]||null;e.insertBefore(n,o)},remove(e){e&&e.parentNode&&e.parentNode.removeChild(e)},replaceWith(e,n){if(!e||!e.parentNode)throw new Error("dom.replaceWith: node has no parent");let o=e.ownerDocument.createElement("template");o.innerHTML=n;let r=o.content.firstElementChild;if(!r)throw new Error("dom.replaceWith: html did not parse to an element");return e.parentNode.replaceChild(r,e),r},stripIds(e){let n=0;return e.id&&(e.removeAttribute("id"),n++),(e.querySelectorAll?e.querySelectorAll("[id]"):[]).forEach(o=>{o.removeAttribute("id"),n++}),n},sameNode(e,n){return e===n}};function eo(e,n={}){if(n.exclude===null)return on;let t=[Qo("data"),n.exclude].filter(Boolean).join(", "),o=e.nodeType===9?e:e.ownerDocument||e,r=e.nodeType===9?e.documentElement:e;if(!n._write&&!r?.matches?.(t)&&!r?.querySelector?.(t)&&!o?.querySelector?.(t))return on;let c=e.nodeType===9||!e.isConnected?e:e.ownerDocument,l=e.nodeType===9?e:e.ownerDocument,i=null,s=()=>i||(i=Zo(c,{capability:"data",exclude:n.exclude||null})),a=b=>{let A=s();return b===e?A.cloneOf(e):A.cloneOf(b)||b},h=b=>i?.original(b)||b,f=(b,A)=>{s().liveToClone.set(b,A),s().cloneToLive.set(A,b);let p=b.childNodes||[],m=A.childNodes||[];for(let y=0;y<Math.min(p.length,m.length);y++)f(p[y],m[y])},u=(b,A,p,m)=>{let y=Array.from(b.childNodes).filter(E=>i.cloneOf(E)),S=y[0];for(;S&&y.includes(S);)S=S.nextSibling;for(let E of y)E.remove();if(p==="innerHTML"){let E=l.createElement("template");E.innerHTML=m;for(let N of Array.from(E.content.childNodes))b.insertBefore(N,S||null)}else b.insertBefore(l.createTextNode(m),S||null);let O=Zo(b,{capability:"data",exclude:n.exclude||null});A.replaceChildren(...Array.from(O.root?.childNodes||[]));let M=E=>{let N=O.original(E);N&&(i.liveToClone.set(N,E),i.cloneToLive.set(E,N));for(let L of Array.from(E.childNodes||[]))M(L)};for(let E of Array.from(A.childNodes))M(E)},g={...on,find(b,A,p={}){let m=a(b);if(!m?.querySelectorAll)return[];let y=s().query(A,m);p.includeRulesTag||(y=y.filter(O=>!pl(O)));let R=[];p.skip&&R.push(p.skip);let S=p.templateAttr===null?null:p.templateAttr||"cms-template";if(S&&R.push(`[${S}]`),R.length){let O=R.join(", ");y=y.filter(M=>!M.closest?.(O))}return y},parent(b){let A=a(b)?.parentElement;return A?h(A):null},children(b){return Array.from(a(b)?.children||[],h)},text(b,A){if(A===void 0){let y=h(b);return!y?.matches?.(t)&&!y?.querySelector?.(t)?on.text(y):(a(b)?.textContent||"").trim()}let p=h(b);if(!p?.matches?.(t)&&!p?.querySelector?.(t)&&!i){on.text(p,A);return}let m=s().cloneOf(p);m?u(p,m,"textContent",A):on.text(p,A)},attr(b,A,p){let m=h(b);if(p===void 0)return on.attr(m,A);on.attr(m,A,p);let y=i?.cloneOf(m);y&&(on.attr(y,A,p),Zo(m,{capability:"data",exclude:n.exclude||null}).root===null&&(y.remove(),i.liveToClone.delete(m),i.cloneToLive.delete(y)))},removeAttr(b,A){let p=h(b);on.removeAttr(p,A);let m=i?.cloneOf(p);m&&on.removeAttr(m,A)},prop(b,A,p){let m=h(b);if(p===void 0)return A==="innerHTML"||A==="outerHTML"||A==="textContent"||A==="innerText"?on.prop(a(m),A):on.prop(m,A);let y=A==="innerHTML"||A==="textContent"||A==="innerText",R=y?s().cloneOf(m):i?.cloneOf(m);R&&y?u(m,R,A,p):(on.prop(m,A,p),R&&on.prop(R,A,p))},clone(b){let A=a(b);return A===b?on.clone(b):l.importNode(A,!0)},insertAt(b,A,p){let m=h(b),R=g.children(m)[p]||(()=>{for(let M=m.children.length-1;M>=0;M--){let E=m.children[M];if(s().cloneOf(E))return E.nextElementSibling}return m.firstElementChild})(),S=h(A);m.insertBefore(S,R||null);let O=s().cloneOf(m);if(O){let M=s().cloneOf(S);M||(M=l.importNode(S,!0),f(S,M));let E=Array.from(O.children);O.insertBefore(M,E[p]||null)}},remove(b){let A=h(b),p=s().cloneOf(A);on.remove(A),p&&on.remove(p)},replaceWith(b,A){let p=h(b),m=s().cloneOf(p),y=on.replaceWith(p,A);if(m){let R=Zo(y,{capability:"data",exclude:n.exclude||null});if(!R.root)m.remove();else{m.replaceWith(R.root);let S=O=>{let M=R.original(O);M&&(i.liveToClone.set(M,O),i.cloneToLive.set(O,M));for(let E of Array.from(O.childNodes||[]))S(E)};S(R.root)}}return y}};return g}var Cn=on;function vs(e){try{return JSON.parse(e)}catch(n){throw new Io(`Invalid strict JSON: ${n.message}`,n)}}function ho(e){try{return JSON.parse(e)}catch{}let n={BRACE_OPEN:"{",BRACE_CLOSE:"}",BRACKET_OPEN:"[",BRACKET_CLOSE:"]",COLON:":",COMMA:",",STRING:"STRING",SELECTOR:"SELECTOR",IDENTIFIER:"IDENTIFIER",NUMBER:"NUMBER",BOOLEAN:"BOOLEAN"};function t(r){let c=[],l=0;for(;l<r.length;){let i=r[l];if(/\s/.test(i)){l++;continue}if("{}".includes(i)){c.push({type:i,value:i}),l++;continue}if(i==="["){let f=!1,u=l+1;for(;u<r.length&&/\s/.test(r[u]);)u++;if(u<r.length&&/[a-zA-Z_]/.test(r[u])&&(f=!0),!f){c.push({type:i,value:i}),l++;continue}}if(i==="]"){c.push({type:i,value:i}),l++;continue}if(i===":"){c.push({type:n.COLON,value:i}),l++;continue}if(i===","){c.push({type:n.COMMA,value:i}),l++;continue}if(i==='"'||i==="'"){let f=i,u=l+1;for(;u<r.length&&r[u]!==f;)r[u]==="\\"&&u++,u++;c.push({type:n.STRING,value:r.substring(l+1,u),quoted:!0,sourceQuote:f}),l=u+1;continue}let s=l,a;for(;s<r.length&&!/[{},]/.test(r[s]);)if(r[s]===":"){let f=[":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"],u=!1;for(let g of f){let b=g.substring(1);if(r.substring(s+1,s+1+b.length)===b){u=!0,s+=b.length;break}}if(!u)break}else if(r[s]==="["){for(s++;s<r.length&&r[s]!=="]";){if(r[s]==='"'||r[s]==="'"){let f=r[s];for(s++;s<r.length&&r[s]!==f;)r[s]==="\\"&&s++,s++}s++}s<r.length&&r[s]==="]"&&s++}else s++;a=r.substring(l,s);let h=n.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(a)?h=n.NUMBER:a==="true"||a==="false"||a==="null"?h=n.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(a)&&(h=n.SELECTOR),c.push({type:h,value:a,quoted:!1}),l=s}return c}function o(r){let c="";for(let l=0;l<r.length;l++){let i=r[l];if("{}".includes(i.type)||"[]".includes(i.type)){c+=i.value;continue}if(i.type===n.COLON){c+=i.value;continue}if(i.type===n.COMMA){let s=r[l+1];if(s&&(s.type==="}"||s.type==="]"))continue;c+=i.value;continue}if(i.type===n.STRING&&i.quoted){let s=i.value;i.sourceQuote==="'"&&(s=s.replace(/\\'/g,"'"),s=s.replace(/(\\*)"/g,(a,h)=>h.length%2===0?h+'\\"':a)),c+=`"${s}"`;continue}if(i.type===n.NUMBER||i.type===n.BOOLEAN){c+=i.value;continue}if(i.type===n.SELECTOR||i.type===n.IDENTIFIER){c+=`"${i.value}"`;continue}c+=`"${i.value}"`}return c}try{let r=t(e),c=o(r);return JSON.parse(c)}catch(r){throw new Io("Invalid extraction rules syntax: "+r.message,r)}}var Os="1",ml=/^[a-zA-Z0-9_-]+$/;function Ro(e,n,t){let o;if(t===void 0)o="script[data-rules-name]";else{if(typeof t!="string"||!ml.test(t))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(t)} (must match ${ml})`);o=`script[data-rules-name~="${t}"]`}let r=e.find(n,o,{includeRulesTag:!0});if(r.length===0)return null;t!==void 0&&r.length>1&&console.warn(`hyper-html-api: ${r.length} rules tags match data-rules-name~="${t}"; using the first.`);let c=r[0],l=e.attr(c,"data-rules-version");if(l!==Os)throw new fo(l);return{rules:ho(e.text(c)),tagNode:c}}var Ca="script[data-rules-name]";function gl(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function er(e,n){let t=e.find(n,Ca,{includeRulesTag:!0}),o=new Set,r=[];for(let c of t){let l=gl(e.attr(c,"data-rules-name"));if(!l)continue;if(o.has(l)){console.warn(`hyper-html-api: duplicate rules tag name "${l}"; using the first.`);continue}let i=e.attr(c,"data-rules-version");if(i!==Os)throw new fo(i);o.add(l),r.push({name:l,rules:ho(e.text(c))})}return r}function Or(e,n){let t={};for(let{name:o,rules:r}of er(e,n))t[o]=_n(e,n,r);return t}function Ms(e){let n=e||document,t=n.nodeType===9?n:n.ownerDocument||n;return{dataByName:Or(Cn,n),version:Wn(t,"hyper-version")}}var Lo=class extends Error{constructor(n,t){super(`could not fetch upgrade source: ${n}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=n,this.cause=t}},tr=class extends Error{constructor(n){super(`upgrade source has no rules tags; refusing to drop all existing data: ${n}`),this.name="UpgradeSourceHasNoRules",this.sourceUrl=n}},to=class extends Error{constructor(n,t){super(n),this.name="UpgradeTransformInvalid",this.cause=t}},nr=class extends Error{constructor(n){super(`found ${n} script[type="text/hyper-upgrade"] tags; only one is allowed per document.`),this.name="UpgradeMultipleTransforms",this.count=n}};var bl="text/hyper-upgrade";function Es(e,n){let t=e.find(n,`script[type="${bl}"]`);if(t.length===0)return null;if(t.length>1)throw new nr(t.length);return e.text(t[0])||null}var Ra=new Function("url","return import(url)");async function Is(e){let n=new Blob([e],{type:"text/javascript"}),t=URL.createObjectURL(n),o;try{o=await Ra(t)}catch(r){throw new to(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(t)}if(typeof o.default!="function")throw new to("transform must `export default` a function");return o.default}function xl(e,n,t,o){let r=e.length,c=n.length,l=new Array(r).fill(-1);if(o){let p=new Set;for(let m=0;m<r;m++){let y=o[m];!(y>=0&&y<c)||p.has(y)||(l[m]=y,p.add(y))}}if(r===0||c===0)return l;let i=e.map(p=>yl(p,t)),s=n.map(p=>yl(p,t)),a=new Array(c).fill(!1);for(let p of l)p>=0&&(a[p]=!0);let h=new Map;s.forEach((p,m)=>{a[m]||h.set(p,h.has(p)?-1:m)});let f=new Map;i.forEach((p,m)=>{l[m]>=0||f.set(p,(f.get(p)||0)+1)}),i.forEach((p,m)=>{if(l[m]>=0||f.get(p)!==1)return;let y=h.get(p);y===void 0||y===-1||a[y]||(l[m]=y,a[y]=!0)});let u=[];for(let p=0;p<r;p++)l[p]<0&&u.push(p);let g=[];for(let p=0;p<c;p++)a[p]||g.push(p);if(u.length===0||g.length===0)return l;let b=r*c+1,A=(p,m)=>La(e[p],n[m],t)*b+Math.abs(p-m);for(let[p,m]of Pa(u,g,A))l[p]=m;return l}var kl=e=>typeof e=="object"&&e!==null;function yl(e,n){if(!kl(n))return e==null?" null":String(e);let t=Object.keys(n);return JSON.stringify(t.map(o=>{let r=JSON.stringify(e?.[o]);return r===void 0?" undef":r}))}function La(e,n,t){if(!kl(t))return e===n?0:1;let o=Object.keys(t);if(o.length===0)return 0;let r=0;for(let c of o){let l=JSON.stringify(e?.[c]),i=JSON.stringify(n?.[c]);l!==i&&r++}return r}function Pa(e,n,t){return e.length<=n.length?wl(e,n,t,!1):wl(n,e,(o,r)=>t(r,o),!0)}function wl(e,n,t,o){let r=e.length,c=n.length,l=[];for(let f=0;f<=r;f++)l.push(new Float64Array(c+1).fill(1/0));let i=[];for(let f=0;f<=r;f++)i.push(new Uint8Array(c+1));for(let f=0;f<=c;f++)l[r][f]=0;for(let f=r-1;f>=0;f--)for(let u=c-1;u>=0;u--){let g=t(e[f],n[u])+l[f+1][u+1],b=l[f][u+1];g<=b?(l[f][u]=g,i[f][u]=1):l[f][u]=b}let s=[],a=0,h=0;for(;a<r&&h<c;)i[a][h]&&(s.push(o?[n[h],e[a]]:[e[a],n[h]]),a++),h++;return s}function Rs(e,n,t,o,r,c,l,i={}){let s=e.find(n,t,i);if(r.length===0){s.forEach(O=>e.remove(O)),Cs(i,"onRowsApplied",c.path,[]);return}let a=r.length>s.length,h=s[0]||null;if(a&&!h&&(h=Ua(e,n,t,i),!h))throw new Yo(c.path);let f=s.map(O=>Ba(e,O,o,i)),u=null;if(a&&h){u=e.clone(h),i.templateAttr&&e.removeAttr(u,i.templateAttr);let O=e.stripIds(u);O>0&&console.warn(`[hyper-html-api] stripped ${O} id attribute(s) from cloned template at "${c.path.join(".")||"(root)"}"`)}let g=xl(r,f,o,ja(e,s,r,c,i)),b=s[0]||h,A=e.parent(b),p=s.length>0?Tl(e,A,b):0,m=Ha(e,s),y=new Set,R=[],S=r.map((O,M)=>{let E=g[M];if(E>=0)return y.add(E),R.push(!1),s[E];R.push(!0);let N=e.clone(u);return e.stripIds(N),N});s.forEach((O,M)=>{y.has(M)||e.remove(O)}),m?S.forEach((O,M)=>{let E=p+M;e.children(A).findIndex(j=>e.sameNode(j,O))!==E&&e.insertAt(A,O,E)}):Wa(e,S,R,A,p),Da(e,S,o,r,c,l,i),Cs(i,"onRowsApplied",c.path,S)}function Cs(e,n,t,o){if(typeof e[n]=="function")try{return e[n](t.slice(),o)}catch(r){console.warn(`[hyper-html-api] ${n} threw at "${t.join(".")||"(root)"}"`,r);return}}function ja(e,n,t,o,r){let c=Cs(r,"identifyRows",o.path,t);if(!Array.isArray(c))return null;let l=new Array(t.length).fill(-1),i=new Set;for(let s=0;s<t.length;s++)if(c[s]){for(let a=0;a<n.length;a++)if(!(i.has(a)||!e.sameNode(n[a],c[s]))){l[s]=a,i.add(a);break}}return l}function Da(e,n,t,o,r,c,l){n.forEach((i,s)=>{if(t===null){let a=o[s],h=a==null?"":String(a);e.text(i)!==h&&e.text(i,h)}else{let a=c(e,i,t,o[s],{depth:r.depth+1,path:[...r.path,s]},l);a&&a!==i&&(n[s]=a)}})}function Ba(e,n,t,o){return t===null?e.text(n):_n(e,n,t,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Tl(e,n,t){let o=e.children(n);for(let r=0;r<o.length;r++)if(e.sameNode(o[r],t))return r;return-1}function Ua(e,n,t,o){if(!o.templateAttr)return null;let r=n;for(;r;){let c=e.find(r,t,{includeRulesTag:!1,templateAttr:null});for(let l of c)if(e.attr(l,o.templateAttr)!=null)return l;r=e.parent(r)}return null}function Ha(e,n){if(n.length<=1)return!0;let t=e.parent(n[0]);if(!t)return!1;let o=e.children(t),r=[];for(let c of n){let l=o.findIndex(i=>e.sameNode(i,c));if(l===-1)return!1;r.push(l)}return r.sort((c,l)=>c-l),r[r.length-1]-r[0]===r.length-1}function Wa(e,n,t,o,r){let c=null,l=r;for(let i=0;i<n.length;i++){if(!t[i]){c=n[i];continue}let s=c?e.parent(c):o;if(!s)continue;let a=c?Tl(e,s,c)+1:l++;e.insertAt(s,n[i],a),c=n[i]}}var Al=new Set(["checked","selected","disabled","readOnly","paused"]);function qn(e,n,t,o,r={}){if(Object.prototype.hasOwnProperty.call(r,"exclude")&&e.semanticExclude===!1)throw new Error("This adapter does not support semantic exclude queries; omit exclude or use the DOM adapter.");let c=[];if(Ls(t,o,[],c),c.length)throw new Go(c);Mr(e,n,t,o,{depth:0,path:[]},r)}function Mr(e,n,t,o,r,c={}){if(r.depth>Co)throw new uo(r.path);if(o===void 0)return n;if(typeof t=="string")return Va(e,n,t,o,r,c);if(Array.isArray(t)){let[l,i]=t;return Rs(e,n,l,i,o,r,Mr,c),n}if(typeof t=="object"&&t!==null){for(let[l,i]of Object.entries(t)){let s=Mr(e,n,i,o==null?o:o[l],{depth:r.depth+1,path:[...r.path,l]},c);s&&s!==n&&(n=s)}return n}return n}function Va(e,n,t,o,r,c){if(t.endsWith("[]")){let s=t.slice(0,-2);return Rs(e,n,s,null,o,r,Mr,c),n}if(t.startsWith("@"))return Nl(e,n,t.slice(1),o);let l=On(t);if(l!==-1){let s=t.slice(0,l),a=t.slice(l+1),h=s?e.find(n,s,c):[n];return h.length===0||Nl(e,h[0],a,o),n}if(t===".")return Sl(e,n,o),n;let i=e.find(n,t,c);return i.length===0||Sl(e,i[0],o),n}function Sl(e,n,t){let o=t==null?"":String(t);e.text(n)!==o&&e.text(n,o)}function Nl(e,n,t,o){if(zo.has(t)){let c=e.prop(n,t);if(c===o||c!=null&&o!=null&&String(c)===String(o))return n;throw new Xo(t)}if(t==="outerHTML"){let c=o==null?"":String(o);return e.replaceWith(n,c)}if(sl.has(t)){let c=_a(t,o);return e.prop(n,t)!==c&&e.prop(n,t,c),n}let r=o==null?"":String(o);return e.attr(n,t)!==r&&e.attr(n,t,r),n}function _a(e,n){return n==null?Al.has(e)?!1:"":Al.has(e)?n==="false"?!1:!!n:n}function Ls(e,n,t,o){if(n!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(n)?n.forEach((r,c)=>{typeof r=="object"&&r!==null&&o.push({path:rr([...t,c]),expected:"scalar",got:or(r)})}):o.push({path:rr(t),expected:"array",got:or(n)});return}n!==null&&typeof n=="object"&&o.push({path:rr(t),expected:"scalar",got:or(n)});return}if(Array.isArray(e)){if(!Array.isArray(n)){o.push({path:rr(t),expected:"array",got:or(n)});return}let r=e[1];n.forEach((c,l)=>Ls(r,c,[...t,l],o));return}if(typeof e=="object"&&e!==null){if(n===null||Array.isArray(n)||typeof n!="object"){o.push({path:rr(t),expected:"object",got:or(n)});return}for(let[r,c]of Object.entries(e))Ls(c,n[r],[...t,r],o)}}}function or(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function rr(e){return e.join(".")}function sr(e,n){let t={carriedOver:0,discarded:0,listItems:0},o=Ps(n,e,t);return js(n,e,t),{data:o,summary:t}}function Ps(e,n,t){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(n)?(t.listItems+=n.length,t.carriedOver+=n.length,n):void 0:n==null||typeof n=="object"?void 0:(t.carriedOver++,n);if(Array.isArray(e)){let[,o]=e;return Array.isArray(n)?(t.listItems+=n.length,n.map(r=>Ps(o,r,t))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,c]of Object.entries(e)){let l=Ps(c,n?.[r],t);l!==void 0&&(o[r]=l)}return o}}function js(e,n,t){if(n!=null){if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(typeof n!="object"||Array.isArray(n))return;let o=new Set(Object.keys(e));for(let r of Object.keys(n))o.has(r)?js(e[r],n[r],t):t.discarded+=po(n[r]);return}if(Array.isArray(e)&&Array.isArray(n)){let o=e[1];n.forEach(r=>js(o,r,t));return}typeof e=="string"&&!e.endsWith("[]")&&typeof n=="object"&&n!==null&&(t.discarded+=po(n))}}function po(e){return e==null?0:Array.isArray(e)?e.reduce((n,t)=>n+po(t),0):typeof e=="object"?Object.values(e).reduce((n,t)=>n+po(t),0):1}function Ds(e,n,t){let o=er(e,n),r={carriedOver:0,discarded:0,listItems:0},c={},l=new Set;for(let{name:i,rules:s}of o){if(l.add(i),!Object.prototype.hasOwnProperty.call(t,i)){c[i]={carriedOver:0,discarded:0,listItems:0};continue}let{data:a,summary:h}=sr(t[i],s);qn(e,n,s,a),c[i]=h,r.carriedOver+=h.carriedOver,r.discarded+=h.discarded,r.listItems+=h.listItems}for(let i of Object.keys(t))l.has(i)||(r.discarded+=po(t[i]));return{totals:r,byName:c,rulesTagCount:o.length}}async function Bs({sourceUrl:e,dataByName:n,fromVersion:t,doc:o,loc:r,fetchFn:c}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),c=c||(m=>fetch(m)),!o)throw new Error("upgrade.run requires a document context");if(e=e||Wn(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let l=new URL(e,r?r.href:void 0);t=t!==void 0?t:Wn(o,"hyper-version"),n=n||Or(Cn,o);let i;try{i=await c(l.href)}catch(m){throw new Lo(l.href,m)}if(!i.ok)throw new Lo(l.href,new Error(`HTTP ${i.status}`));let s=await i.text(),a=new DOMParser().parseFromString(s,"text/html"),h=Wn(a,"hyper-version"),f=n,u=!1,g=Es(Cn,a);if(g){let y=await(await Is(g))(f,{fromVersion:t,toVersion:h});if(!y||typeof y!="object"||Array.isArray(y))throw new to("transform must return a plain object map of { rulesName: data }");f=y,u=!0}let{totals:b,byName:A,rulesTagCount:p}=Ds(Cn,a,f);if(p===0&&Object.keys(f).length>0)throw new tr(l.href);return{html:Fa(a),fromVersion:t,toVersion:h,summary:{transformApplied:u,totals:b,byName:A}}}function Fa(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
6
+ `+e.documentElement.outerHTML}var Us=Object.freeze({refusedRuleForms:["innerHTML","outerHTML"],refusedTargets:["script","style","template","noscript","iframe","object","embed","xmp","plaintext","noembed","noframes","meta","link","base","animate","set","animatemotion","animatetransform"],refusedAttributes:["style","srcdoc","is","http-equiv","sandbox","allow","nonce","integrity","charset","htmlclaytoken","htmlclayid","data-rules-name","data-rules-version","clay","contenteditable",...al],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]}),Ka=new Set(["textContent","innerText"]);function vl(e){let t=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return t?t[1].toLowerCase():null}var qa=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function Ol(e,n,t=Us){if(!qa.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(t.refusedAttributePrefixes.some(r=>o.startsWith(r)))return`attribute "${o}" can run script`;if(t.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(t.urlAttributes.includes(o)&&n!=null){let r=o==="srcset"?String(n).split(",").map(c=>c.trim().split(/\s+/)[0]).filter(Boolean):[String(n)];for(let c of r){let l=vl(c);if(l&&t.refusedSchemes.includes(l))return`"${l}:" URLs are not allowed in "${o}"`}}return null}function Hs(e,n){let t=e.prop(n,"tagName");return t?String(t).toLowerCase():""}function za(e,n){let t=Hs(e,n)||"node",o=e.attr(n,"id");return o?`<${t}#${o}>`:`<${t}>`}function Ga(e,n,t){let o=n;for(;o;){let r=Hs(e,o);if(r&&t.refusedTargets.includes(r))return r;o=e.parent(o)}return null}function Ml(e,n){return e.find(n,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function Ya(e,n){return Hs(e,n)==="script"&&e.attr(n,"data-rules-name")!=null?!0:Ml(e,n)}function Er(e,n=Us){let t=[],o=(s,a)=>(t.push({target:za(e,s),reason:a}),!1),r=s=>{let a=Ga(e,s,n);return a?o(s,`inside <${a}>, which is not content`):!0},c=s=>r(s)?Ml(e,s)?o(s,"a text write here would delete the data rules tag"):!0:!1,l=(s,a,h)=>{if(!r(s))return!1;let f=Ol(a,h,n);return f?o(s,f):!0};return{...e,text(s,a){if(a===void 0)return e.text(s);c(s)&&e.text(s,a)},attr(s,a,h){if(h===void 0)return e.attr(s,a);l(s,a,h)&&e.attr(s,a,h)},prop(s,a,h){if(h===void 0)return e.prop(s,a);if(n.refusedRuleForms.includes(a))return o(s,`"@${a}" writes HTML, only text is allowed`);if(Ka.has(a)){c(s)&&e.prop(s,a,h);return}l(s,a==="className"?"class":a,h)&&e.prop(s,a,h)},remove(s){if(Ya(e,s)){o(s,"removing this would delete the data rules tag");return}e.remove(s)},replaceWith(s,a){return a===e.prop(s,"outerHTML")||o(s,'"@outerHTML" writes HTML, only text is allowed'),s},refusals:t,assertClean(){if(t.length)throw new Jo(t.slice())}}}function ir(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function El(e){return e.reduce((n,t)=>typeof t=="number"?`${n}[${t}]`:n?`${n}.${t}`:t,"")}function Ws(e,n,t,o,r={}){let c=[],l=[];function i(a,h,f){if(Array.isArray(a)){let[,u]=a;if(!Array.isArray(h)||!ir(u))return;h.forEach((g,b)=>i(u,g,[...f,b]));return}if(!(!ir(a)||!ir(h)))for(let u of Object.keys(h))Object.prototype.hasOwnProperty.call(a,u)?i(a[u],h[u],[...f,u]):c.push(El([...f,u]))}function s(a,h,f,u){if(f!==void 0){if(typeof h=="string"){if(h.endsWith("[]")||h==="."||h.startsWith("@"))return;let g=On(h),b=g===-1?h:h.slice(0,g);if(!b)return;e.find(a,b,r).length===0&&l.push({path:El(u),selector:b});return}if(!Array.isArray(h)&&ir(h)&&ir(f))for(let[g,b]of Object.entries(h))s(a,b,f[g],[...u,g])}}return i(t,o,[]),s(n,t,o,[]),{unknownKeys:c,unmatched:l}}function Vs(e,n,t){if(t&&typeof t=="object")return{rules:t,tagNode:null};if(typeof t=="string"){let o=n&&n.ownerDocument?n.ownerDocument:n;return Ro(e,o,t)}return null}var lr={extract:(e,n,t={})=>_n(eo(e,t),e,n,t),apply:(e,n,t,o={})=>qn(eo(e,{...o,_write:!0}),e,n,t,o),findRulesIn:(e,n)=>Ro(Cn,e,n),findRules:(e,n)=>Vs(Cn,e,n),bind:(e,n,t={})=>{let o=Vs(Cn,e,n);if(!o){let r=typeof n=="string"?`data-rules-name~="${n}"`:"the provided rules object";throw new Error(`hyper-html-api: could not resolve rules for ${r}`)}return{...o,get:()=>_n(eo(e,t),e,o.rules,t),set:r=>qn(eo(e,{...t,_write:!0}),e,o.rules,r,t)}},parseStrict:vs,parseRelaxed:ho,ruleAttrIndex:On,splitRule:bo,errors:Vn,DOM_PROPERTIES:vr},_s=e=>!!e&&typeof e.nodeType=="number";function Il(e){let n=e&&e.ownerDocument?e.ownerDocument:e,t=Ro(Cn,n,"api");if(!t)throw new Vn.NoRulesTag("api");return t.rules}function Ja(e){if(e.nodeType===9)return e;let n=e.ownerDocument?.documentElement;if(n?.contains(e))return n;let t=e;for(;t.parentNode;)t=t.parentNode;return t}function Qa(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let n=e.ownerDocument.createDocumentFragment();for(let t of e.childNodes)n.appendChild(t.cloneNode(!0));return n}function Za(e,n){let t=[];for(;n!==e;){let o=n.parentNode;t.push(Array.prototype.indexOf.call(o.childNodes,n)),n=o}return t.reverse()}function ef(e,n){return n.reduce((t,o)=>t.childNodes[o],e)}function Po(e,n){let t=e.querySelectorAll?Array.from(e.querySelectorAll(n)):[];return e.matches?.(n)&&t.unshift(e),t}function tf(e,n){let t=Po(e,"option"),o=Po(n,"option");t.forEach((s,a)=>o[a].selected=s.selected);let r=Po(e,"input"),c=Po(n,"input");r.forEach((s,a)=>{let h=s.type.toLowerCase();h!=="file"&&(c[a].value=s.value),(h==="checkbox"||h==="radio")&&(c[a].checked=s.checked)});let l=Po(e,"textarea"),i=Po(n,"textarea");l.forEach((s,a)=>i[a].value=s.value)}function Fs(e,n){if(n!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let t=e.startsWith("@")?0:On(e);if(t===-1)return;let o=e.slice(t+1);if(zo.has(o))throw new Vn.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(n))return;n.forEach(t=>Fs(e[1],t));return}if(e&&typeof e=="object"&&n&&typeof n=="object"&&!Array.isArray(n))for(let[t,o]of Object.entries(e))Fs(o,n[t])}}function nf(e,n,t){let o={templateAttr:"cms-template"},r=Ja(e),c=Za(r,e),l=Qa(r);tf(r,l);let i=ef(l,c),s=eo(l,{...o,_write:!0}),a=Ws(s,i,n,t,o);if(a.unknownKeys.length||a.unmatched.length)throw new Vn.WriteRejected(a.unknownKeys,a.unmatched);let h=Er(s);qn(h,i,n,t,o),h.assertClean(),Fs(n,t);let f=Er(eo(r,{...o,_write:!0}));qn(f,e,n,t,o),f.assertClean()}function of(e){if(!(e instanceof Error))return e;let n=e.name||"Error";try{e.code=n}catch{Object.defineProperty(e,"code",{value:n,configurable:!0,enumerable:!0})}return e instanceof Vn.WriteRefused?e.details=e.refusals:e instanceof Vn.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof Vn.ShapeMismatch?e.details=e.mismatches:Array.isArray(e.path)?e.details={path:e.path}:typeof e.target=="string"?e.details={target:e.target}:e.token!==void 0?e.details={token:e.token}:e.version!==void 0?e.details={version:e.version}:e.details={},e}function $s(e,n){let t=_s(e)?e:document,o=_s(e)?n:e;return o===void 0?_n(eo(t),t,Il(t)):lr.bind(t,o).get()}function Ks(e,n,t){try{if(!_s(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=t===void 0?Il(e):lr.bind(e,t).rules;nf(e,o,n)}catch(o){throw of(o)}return e}var Cl={buildForm:jr,bindFormEvents:Dr,scaffold:go,morphForm:ys,path:ur},Rl={checkForUpdate:xs,run:Bs,extractAll:Ms,shapeMatch:sr};var rf={engine:lr,cms:Cl,upgrade:Rl,extractData:$s,applyData:Ks},sf=rf;return _l(lf);})();