hyper-html-api 0.12.0 → 0.14.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 (83) hide show
  1. package/README.md +4 -1
  2. package/conformance/MANIFEST.json +2 -2
  3. package/conformance/cases/all-matches-read-quoted.expected.json +3 -0
  4. package/conformance/cases/all-matches-read-quoted.html +5 -0
  5. package/conformance/cases/all-matches-read-quoted.meta +7 -0
  6. package/conformance/cases/all-matches-read-quoted.parsed.json +3 -0
  7. package/conformance/cases/all-matches-read.expected.json +3 -0
  8. package/conformance/cases/all-matches-read.html +6 -0
  9. package/conformance/cases/all-matches-read.meta +7 -0
  10. package/conformance/cases/all-matches-read.parsed.json +3 -0
  11. package/conformance/cases/stylevar-read.expected.json +12 -0
  12. package/conformance/cases/stylevar-read.html +7 -0
  13. package/conformance/cases/stylevar-read.meta +6 -0
  14. package/conformance/cases/stylevar-read.parsed.json +12 -0
  15. package/conformance/cases/stylevar-read.rules +1 -0
  16. package/conformance/cases/write-all-matches-attr.after.html +1 -0
  17. package/conformance/cases/write-all-matches-attr.after.json +3 -0
  18. package/conformance/cases/write-all-matches-attr.data.json +1 -0
  19. package/conformance/cases/write-all-matches-attr.html +1 -0
  20. package/conformance/cases/write-all-matches-attr.meta +6 -0
  21. package/conformance/cases/write-all-matches-attr.write.json +4 -0
  22. package/conformance/cases/write-all-matches-group.after.html +1 -0
  23. package/conformance/cases/write-all-matches-group.after.json +3 -0
  24. package/conformance/cases/write-all-matches-group.data.json +1 -0
  25. package/conformance/cases/write-all-matches-group.html +1 -0
  26. package/conformance/cases/write-all-matches-group.meta +6 -0
  27. package/conformance/cases/write-all-matches-group.write.json +4 -0
  28. package/conformance/cases/write-all-matches-text.after.html +1 -0
  29. package/conformance/cases/write-all-matches-text.after.json +3 -0
  30. package/conformance/cases/write-all-matches-text.data.json +1 -0
  31. package/conformance/cases/write-all-matches-text.html +1 -0
  32. package/conformance/cases/write-all-matches-text.meta +6 -0
  33. package/conformance/cases/write-all-matches-text.write.json +4 -0
  34. package/conformance/cases/write-all-matches-unmatched.data.json +1 -0
  35. package/conformance/cases/write-all-matches-unmatched.error.json +14 -0
  36. package/conformance/cases/write-all-matches-unmatched.html +1 -0
  37. package/conformance/cases/write-all-matches-unmatched.meta +6 -0
  38. package/conformance/cases/write-refused-raw-style.data.json +1 -0
  39. package/conformance/cases/write-refused-raw-style.error.json +11 -0
  40. package/conformance/cases/write-refused-raw-style.html +1 -0
  41. package/conformance/cases/write-refused-raw-style.meta +4 -0
  42. package/conformance/cases/write-refused-stylevar-values.data.json +1 -0
  43. package/conformance/cases/write-refused-stylevar-values.error.json +43 -0
  44. package/conformance/cases/write-refused-stylevar-values.html +1 -0
  45. package/conformance/cases/write-refused-stylevar-values.meta +5 -0
  46. package/conformance/cases/write-stylevar-clear.after.html +1 -0
  47. package/conformance/cases/write-stylevar-clear.after.json +4 -0
  48. package/conformance/cases/write-stylevar-clear.data.json +1 -0
  49. package/conformance/cases/write-stylevar-clear.html +1 -0
  50. package/conformance/cases/write-stylevar-clear.meta +5 -0
  51. package/conformance/cases/write-stylevar-clear.write.json +4 -0
  52. package/conformance/cases/write-stylevar-set.after.html +2 -0
  53. package/conformance/cases/write-stylevar-set.after.json +5 -0
  54. package/conformance/cases/write-stylevar-set.data.json +1 -0
  55. package/conformance/cases/write-stylevar-set.html +1 -0
  56. package/conformance/cases/write-stylevar-set.meta +6 -0
  57. package/conformance/cases/write-stylevar-set.write.json +4 -0
  58. package/conformance/cases/write-stylevar-unchanged.after.html +1 -0
  59. package/conformance/cases/write-stylevar-unchanged.after.json +3 -0
  60. package/conformance/cases/write-stylevar-unchanged.data.json +1 -0
  61. package/conformance/cases/write-stylevar-unchanged.html +1 -0
  62. package/conformance/cases/write-stylevar-unchanged.meta +5 -0
  63. package/conformance/cases/write-stylevar-unchanged.write.json +4 -0
  64. package/conformance/write-policy.json +23 -1
  65. package/dist/hyper-html-api.engine.esm.js +1 -1
  66. package/dist/hyper-html-api.engine.min.js +1 -1
  67. package/dist/hyper-html-api.min.js +8 -8
  68. package/dist/hyper-html-api.upgrade.min.js +2 -2
  69. package/package.json +4 -3
  70. package/src/engine/apply.js +22 -7
  71. package/src/engine/extract.js +8 -3
  72. package/src/engine/index.js +2 -1
  73. package/src/engine/round-trip.js +14 -1
  74. package/src/engine/rule-syntax.js +13 -3
  75. package/src/engine/style-vars.js +141 -0
  76. package/src/engine/write-plan.js +2 -3
  77. package/src/engine/write-policy.js +60 -0
  78. package/src/page.js +15 -5
  79. package/src/site.js +164 -0
  80. package/src/upgrade/migrate.js +2 -1
  81. package/src/upgrade/run.js +30 -0
  82. package/src/upgrade/shape-match.js +32 -13
  83. package/src/write.js +1 -1
@@ -1,8 +1,8 @@
1
- var HyperHtmlApi=(()=>{var $r=Object.defineProperty;var fc=Object.getOwnPropertyDescriptor;var uc=Object.getOwnPropertyNames;var dc=Object.prototype.hasOwnProperty;var Kr=(e,t)=>{for(var n in t)$r(e,n,{get:t[n],enumerable:!0})},hc=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of uc(t))!dc.call(e,r)&&r!==n&&$r(e,r,{get:()=>t[r],enumerable:!(o=fc(t,r))||o.enumerable});return e};var pc=e=>hc($r({},"__esModule",{value:!0}),e);var Zf={};Kr(Zf,{applyData:()=>fi,cms:()=>lc,default:()=>Jf,engine:()=>gr,extractData:()=>ai,upgrade:()=>cc});var xr={};Kr(xr,{fromString:()=>wr,getRuleAtPath:()=>zr,getValueAtPath:()=>Ko,parseConfigKey:()=>gc,setAtPath:()=>no,toConfigKey:()=>mc,toString:()=>On});function On(e){return e.map(String).join(".")}function mc(e){return e.map(t=>typeof t=="number"?"*":String(t)).join(".")}function gc(e){return e===""?[]:e.split(".")}function wr(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function zr(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 no(e,t,n){if(t.length===0)return n;let[o,...r]=t;if(typeof o=="number"){let c=Array.isArray(e)?[...e]:[];return c[o]=no(c[o],r,n),c}return{...e&&typeof e=="object"?e:{},[o]:no((e||{})[o],r,n)}}var kr=["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"],Ao=new Set(kr),Gr=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"]),di=new Set(["checked","selected","disabled","readOnly","paused"]);function Xr(e,t){return t==null?di.has(e)?!1:"":di.has(e)?t==="false"?!1:!!t:t}function Mn(e){let t=0,n=null,o=-1;for(let r=0;r<e.length;r++){let c=e[r];c==="\\"?r++:n?c===n&&(n=null):c==='"'||c==="'"?n=c:c==="["||c==="("?t++:c==="]"||c===")"?t>0&&t--:c==="@"&&t===0&&(o=r)}return o}function Gn(e){let t=Mn(e);return t===-1?{selector:e,prop:null}:{selector:e.slice(0,t),prop:e.slice(t+1)||null}}function Yr(e){let t=0,n=null,o=-1,r=!1;for(let c=0;c<e.length;c++){let s=e[c];s==="\\"?c++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=c:t===0&&s===","&&(r=!0)}return r||o===-1||!bc(e,o+1)?null:e.slice(0,o).trim()||null}function bc(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,c=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(c)s===c&&(c=null);else if(s==='"'||s==="'")c=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}function So(e,t){if(typeof e=="string")return e.endsWith("[]")?[]:yc(e)?wc(t,Gn(e).prop)?"":null:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let n={};for(let[o,r]of Object.entries(e))n[o]=So(r,t);return n}return""}function yc(e){let{prop:t}=Gn(e);return t!==null&&!Ao.has(t)}function wc(e,t){if(!e||!t)return!1;let n=xc(e),o=t.toLowerCase();for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]==="["){let c=n.indexOf("]",r);if(c===-1)return!1;let s=/^\s*([^\s\]=~^|*$]+)/.exec(n.slice(r+1,c));if(s&&s[1].toLowerCase()===o)return!0;r=c}return!1}function xc(e){let t=0,n=null,o=0;for(let r=0;r<e.length;r++){let c=e[r];c==="\\"?r++:n?c===n&&(n=null):c==='"'||c==="'"?n=c:c==="["||c==="("?t++:c==="]"||c===")"?t>0&&t--:t===0&&(c===">"||c==="+"||c==="~"||/\s/.test(c))&&(o=r+1)}return e.slice(o)}var Tr=new WeakMap;var kc=new Set(["checked","selected","disabled","readOnly","paused"]);function Jr({rules:e,data:t,appRoot:n,cmsRoot:o}){let r=document.createDocumentFragment(),c={rules:e,appRoot:n,cmsRoot:o};return r.appendChild(Qr({rule:e,value:t,path:[],ctx:c})),r}function Zr(e,{rules:t,getData:n,onChange:o}){e.setAttribute("data-hha-form-root",""),mi.set(e,{rules:t,getData:n,onChange:o}),Tc()}var mi=new WeakMap,hi=!1;function Tc(){hi||(document.addEventListener("input",pi,!0),document.addEventListener("change",pi,!0),document.addEventListener("click",Ac,!0),hi=!0)}function gi(e){if(!(e instanceof Element))return null;let t=e.closest("[data-hha-form-root]");return t&&mi.get(t)||null}function Ac(e){if(!(e.target instanceof Element))return;let t=e.target.closest("[data-hha-action]");if(!t||e.defaultPrevented)return;let n=gi(t);if(!n)return;let{rules:o,getData:r,onChange:c}=n,s=t.getAttribute("data-hha-action"),l=wr(t.getAttribute("data-hha-path")||"");if(s==="scalar-array-add"){let i=Ko(r(),l)||[];c(no(r(),l,[...i,""]),{structural:!0});return}if(s==="object-array-add"){let i=zr(o,l);if(!Array.isArray(i))return;let a=Ko(r(),l)||[];c(no(r(),l,[...a,So(i[1],i[0])]),{structural:!0});return}if(s==="array-remove"){if(l.length===0)return;let i=l.slice(0,-1),a=l[l.length-1],p=Ko(r(),i)||[];if(typeof a!="number")return;let f=p.filter((u,y)=>y!==a);c(no(r(),i,f),{structural:!0})}}function pi(e){let t=e.target;if(!t?.matches?.("input, textarea, select"))return;let n=gi(t);if(!n)return;let{getData:o,onChange:r}=n,c=t.closest("[data-hha-path]");if(!c)return;let s=wr(c.getAttribute("data-hha-path")||""),l=t.type==="checkbox"?t.checked:t.value;r(no(o(),s,l),{structural:!1})}function Qr({rule:e,value:t,path:n,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?vc({rule:e,value:t,path:n,ctx:o}):Nc({rule:e,value:t,path:n,ctx:o});if(Array.isArray(e))return Oc({rule:e,value:t,path:n,ctx:o});if(typeof e=="object"&&e!==null)return Sc({rule:e,value:t,path:n,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function Sc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",On(n)),n.length>0){let c=document.createElement("div");c.className="form-section-label",c.textContent=Ar(n[n.length-1]),r.appendChild(c)}for(let[c,s]of Object.entries(e)){let l=[...n,c],i=t?.[c];r.appendChild(Qr({rule:s,value:i,path:l,ctx:o}))}return r}function Nc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",On(n));let c=document.createElement("div");c.className="field-body";let s=document.createElement("label");s.className="field-label",s.textContent=Ar(n[n.length-1]||".")+Rc(e);let l=Ec(e,o.appRoot),i=Mc(l,{value:t,rule:e,path:n,appRoot:o.appRoot}),a=i.el;return a.classList.add(l.type==="textarea"?"field-textarea":"field-input"),c.appendChild(s),c.appendChild(a),r.appendChild(c),Tr.set(r,i),r}function vc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",On(n));let c=document.createElement("div");c.className="form-section-label",c.textContent=Ar(n[n.length-1]),r.appendChild(c);let s=Array.isArray(t)?t:[],l=document.createElement("div");r.appendChild(l),s.forEach((a,p)=>{let f=[...n,p],u=document.createElement("div");u.className="scalar-array-row",u.setAttribute("data-hha-path",On(f));let y=document.createElement("input");y.type="text",y.className="field-input",y.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",On(f)),u.appendChild(y),u.appendChild(b),l.appendChild(u)});let i=document.createElement("button");return i.type="button",i.className="array-add",i.textContent="+ add",i.setAttribute("data-hha-action","scalar-array-add"),i.setAttribute("data-hha-path",On(n)),r.appendChild(i),r}function Oc({rule:e,value:t,path:n,ctx:o}){let[,r]=e,c=Array.isArray(t)?t:[],s=document.createElement("div");s.className="form-section",s.setAttribute("data-hha-path",On(n));let l=document.createElement("div");l.className="form-section-label",l.textContent=Ar(n[n.length-1]),s.appendChild(l),c.forEach((a,p)=>{let f=[...n,p],u=document.createElement("div");u.className="array-card",u.setAttribute("data-hha-path",On(f));let y=document.createElement("button");y.type="button",y.className="array-remove",y.textContent="\xD7",y.title="remove item",y.setAttribute("data-hha-action","array-remove"),y.setAttribute("data-hha-path",On(f)),u.appendChild(y);let b=Qr({rule:r,value:a,path:f,ctx:o});b.querySelector(".form-section-label")?.remove(),u.appendChild(b),s.appendChild(u)});let i=document.createElement("button");return i.type="button",i.className="array-add",i.textContent="+ add",i.setAttribute("data-hha-action","object-array-add"),i.setAttribute("data-hha-path",On(n)),s.appendChild(i),s}function Mc(e,t){let n=Cc(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 Ec(e,t){let n=null;if(e.startsWith("@")?n=e.slice(1):n=Gn(e).prop,n&&kc.has(n))return{type:"checkbox"};if(n==="innerHTML")return{type:"textarea"};let o=Ic(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(l=>({value:l.getAttribute("value")||l.textContent,text:l.textContent.trim()||l.getAttribute("value")||""}))};if(r==="input"){let s=(o.getAttribute("type")||"text").toLowerCase();if(s==="checkbox"||s==="radio")return{type:"checkbox"};if(s==="number")return{type:"number"}}let c=(o.textContent||"").trim();return c.length>60||c.includes(`
2
- `)?{type:"textarea"}:{type:"text"}}function Ic(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=Gn(e).selector;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function Cc(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 Ar(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 Rc(e){return` \xB7 ${e}`}function Sr(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 es(e){let t=new Map;return(n,o)=>{if(typeof o!="string")return Sr(o,e);let r=t.get(n);if(r&&r.text===o)return r.doc;let c=Sr(o,e);return t.set(n,{text:o,doc:c}),c}}function bi(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 ts=()=>!1;function ns(e,t=[]){if(typeof e!="function")return ts;let n=new WeakMap,o=new Set(t);return r=>{if(!r||r.nodeType!==1)return!1;let c=n.get(r);if(c!==void 0)return c;let s=[],l=r,i=!1;for(;l&&l.nodeType===1;){let a=n.get(l);if(a!==void 0){i=a;break}if(s.push(l),e(l,o.has(l))){i=!0;break}if(o.has(l))break;l=l.parentElement}for(let a of s)n.set(a,i);return i}}var hu=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 oo(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var Lc="~",yi="^";function os(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let o=t[Lc],r=typeof o=="string"?o.split(",").map(Number):null,c=r&&typeof t[yi]=="string"?t[yi].split(","):null,s=f=>Number.isInteger(f)&&f>=0,l=0,i=!1,a=f=>{let u=f;for(;u>0;){let y=r[l++];if(l>r.length||!s(y))return!1;u+=y-1}return!0},p=(f,u)=>{if(i)return;if(r){let S=l++,g=r[S];if(S>=r.length||!s(g)){i=!0;return}let d=!c||c[S]===f.tagName.toLowerCase();if(!d||g!==f.children.length){let w=d&&t[u];typeof w=="string"&&w&&n.set(f,w),a(g)||(i=!0);return}}let y=t[u];typeof y=="string"&&y&&n.set(f,y);let b=f.children;for(let S=0;S<b.length;S++)p(b[S],u===""?String(S):`${u}.${S}`)};return p(e,""),n}function wi(e){return t=>{for(let n of e){let o=n(t);if(typeof o=="string"&&o!=="")return o}return null}}var kn=wi([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Nr(e,t,n,o=null,r=null){let c=new Map,s=new Set,l=i=>{if(n(i))return;let a=t(i);a&&(c.has(a)?s.add(a):c.set(a,i))};if(o){let i=a=>{for(let p of a.querySelectorAll(o))l(p);for(let p of a.querySelectorAll("template"))p.content&&i(p.content)};l(e),i(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let i=a=>{l(a);let p=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let f=0;f<p.length;f++)i(p[f])};i(e)}for(let i of s)c.delete(i),r&&r.add(i),rs(i);return c}function rs(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var Pc=new Set(["href","src","name","type","role"]),ki=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 xi(e){return e.replace(/\s+/g," ")}var jc=0;function Ti({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let o=new WeakMap,r=new WeakMap;function c(v){let I=v.attributes,M=I.length;if(M===0)return{all:"",sig:v.tagName+"|"};let P=[],D="",$=[];for(let W=0;W<M;W++){let B=I[W],k=B.name;t(v,k)||P.push(k+"="+B.value),k==="class"?D=B.value.indexOf(" ")<0?B.value:B.value.split(/\s+/).filter(Boolean).sort().join(" "):Pc.has(k)&&$.push(k+"="+B.value)}return P.length>1&&P.sort(),$.length>1&&$.sort(),{all:P.join(""),sig:v.tagName+"|"+D+($.length?"|"+$.join("|"):"")}}function s(v){return v.nodeType===1&&v.tagName==="TEMPLATE"&&v.content?v.content.childNodes:v.childNodes}function l(v){let I=o.get(v);if(I)return I;if(v.nodeType===3)I={hash:"T"+No(v.nodeValue),hint:xi(v.nodeValue).slice(0,64),sig:null,tok:null};else if(v.nodeType===8)I={hash:"C"+No(v.nodeValue),hint:"",sig:null,tok:null};else if(v.nodeType===1){let M=c(v),P=No(v.tagName+""+M.all),D="";for(let $ of a(v))if($.nodeType===1){let W=l($);P=No(W.hash,P),D.length<64&&(D+=" "+W.hint)}else P=No(p($),P),$.kind==="text"&&D.length<64&&(D+=$.value.slice(0,64));I={hash:"E"+P,hint:xi(D).trim().slice(0,64),sig:M.sig,tok:null}}else I={hash:"N"+v.nodeType,hint:"",sig:null,tok:null};return o.set(v,I),I}function i(v){if(!v.tok){v.tok=new Set;for(let I of v.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))I&&v.tok.add(I)}return v.tok}function a(v){let I=r.get(v);if(I)return I;I=[];let M=null,P=()=>{M&&(M.value=M.nodes.map(D=>D.nodeValue).join(""),I.push(M),M=null)};for(let D of s(v)){if(D.nodeType===3){M||(M={kind:"text",nodes:[],value:"",parent:v,hash:void 0}),M.nodes.push(D);continue}P(),D.nodeType===8?I.push({kind:"comment",nodes:[D],value:D.nodeValue,parent:v,hash:void 0}):D.nodeType===1&&!e(D)&&I.push(D)}return P(),r.set(v,I),I}function p(v){return v.nodeType===1?l(v).hash:(v.hash===void 0&&(v.hash=(v.kind==="text"?"T":"C")+No(v.value)),v.hash)}function f(v,I){let M=i(l(v)),P=i(l(I));if(M.size===0&&P.size===0)return{coef:1,share:1};if(M.size===0||P.size===0)return null;let D=0;for(let $ of M)P.has($)&&D++;return{coef:D/Math.min(M.size,P.size),share:D/Math.max(M.size,P.size)}}function u(v,I){let M=f(v,I);return!!M&&M.coef>=.5}let y=new WeakMap;function b(v){let I=y.get(v);if(I)return I;I=[];for(let M of v.attributes)t(v,M.name)||I.push([M.namespaceURI||"",M.localName,M.value]);return I.sort((M,P)=>M[0]<P[0]?-1:M[0]>P[0]?1:M[1]<P[1]?-1:M[1]>P[1]?1:0),y.set(v,I),I}let S=new WeakMap;function g(v,I){if(v===I)return!0;if(p(v)!==p(I))return!1;let M=S.get(v);if(M&&M.has(I))return M.get(I);let P=S.get(I);if(P&&P.has(v))return P.get(v);let D=d(v,I),$=D===!0;return D===!1&&n&&n.hashRejected++,M||S.set(v,M=new WeakMap),M.set(I,$),$}function d(v,I){if(v.nodeType===1){if(I.nodeType!==1||v.tagName!==I.tagName||v.namespaceURI!==I.namespaceURI)return!1;let M=b(v),P=b(I);if(M.length!==P.length)return!1;for(let W=0;W<M.length;W++)if(M[W][0]!==P[W][0]||M[W][1]!==P[W][1]||M[W][2]!==P[W][2])return!1;let D=a(v),$=a(I);if(D.length!==$.length)return!1;for(let W=0;W<D.length;W++){if(p(D[W])!==p($[W]))return!1;if(!g(D[W],$[W]))return jc}return!0}return I.nodeType===1?!1:v.kind===I.kind&&v.value===I.value}let w=new WeakMap,O=new Map,x=0;function A(v){let I=w.get(v);if(I)return I;let M=p(v),P=O.get(M);P||O.set(M,P=[]);let D=P.find($=>g($.unit,v));return I=D?D.key:"K"+x++,D||P.push({unit:v,key:I}),w.set(v,I),I}return{meta:l,unitsOf:a,unitHash:p,similar:u,score:f,childrenOf:s,equalUnits:g,exactUnitKey:A,ignored:e}}var Ai=16,Dc=2e3,Bc=3,ss={align:0,certifyVisited:0,certifyScheduled:0};function is(e,t,n){let{meta:o,unitsOf:r,unitHash:c,similar:s,score:l,childrenOf:i,equalUnits:a,ignored:p}=n.analyzer,f=n.baseId||(()=>null),u=n.sideId||(()=>null),y=n.baseKey||(()=>null),b=n.sideKey||(()=>null),S=n.baseDropped||new Set,g=n.sideDropped||new Set,d=n.stats||null,w=d?new Set:null,O=d?new Set:null,x=new Map,A=new Map,v=new Set,I=new Map,M=new Set,P=new Set,D=new Set,$=[],W=[],B=[],k=[],T=Dc,J=new Map,H=new Map,F=(U,X)=>{x.set(U,X),A.set(X,U)},Ee=new Set,Me=new Set,je=null,ae=U=>{let X=U.nodeType?U.parentNode:U.parent;if(!X||X.nodeType!==11)return X;if(!je){je=new WeakMap;let he=ge=>{for(let de of ge.querySelectorAll("template"))de.content&&(je.set(de.content,de),he(de.content))};for(let ge of[e,t])he(ge.tagName==="TEMPLATE"&&ge.content?ge.content:ge)}return je.get(X)||null},Ae=(U,X)=>{for(let he=ae(U);he&&!Ee.has(he);he=ae(he))Ee.add(he);for(let he=ae(X);he&&!Me.has(he);he=ae(he))Me.add(he)},Ve=U=>{for(let X=ae(U);X;X=ae(X))if(x.has(X))return P.has(X);return!1},ve=U=>{for(let X=ae(U);X;X=ae(X)){let he=A.get(X);if(he!==void 0)return P.has(he)}return!1},N=U=>!!U&&U.nodeType===1,Y=(U,X)=>{let he=I.get(U);return!!he&&he.has(X)},le=U=>ki.has(U.tagName),oe=n.comparisons||n.scope,Re=(U,X)=>{if(oe){if(oe.same.get(U)===X)return!0;if(oe.differ.get(U)===X)return!1}if(!U.isEqualNode(X))return!1;if(U.tagName==="TEMPLATE")return a(U,X);let he=U.getElementsByTagName("template");if(he.length===0)return!0;let ge=X.getElementsByTagName("template");if(he.length!==ge.length)return!1;for(let de=0;de<he.length;de++)if(!a(he[de],ge[de]))return!1;return!0},Be=(U,X)=>{let he=f(U);if(!he)return!0;let ge=u(X);return!ge||he===ge},Se=U=>{let X=y(U);return X&&n.baseIndex.get(X)===U&&!g.has(X)?X:null},nt=U=>{let X=b(U);return X&&n.sideIndex.get(X)===U&&!S.has(X)?X:null},Ye=(U,X)=>{let he=Se(U);if(!he)return!0;let ge=nt(X);return!ge||he===ge},ht=globalThis.__hyperMorphProfile,Ge=ht?performance.now():0;ht&&!n.scope&&(o(e),o(t),ht.meta=(ht.meta||0)+(performance.now()-Ge),Ge=performance.now()),F(e,t);let st=new Set;for(let[U,X]of n.baseIndex){let he=n.sideIndex.get(U);he&&he.tagName===X.tagName&&!x.has(X)&&!A.has(he)&&(F(X,he),Ae(X,he),st.add(X))}if(st.size){let U=[];if(n.scope)for(let de of n.scope.chain)st.has(de)&&U.push(de);let X=[n.scope?n.scope.root:e];for(;X.length;){let de=X.pop();st.has(de)&&U.push(de);let ee=i(de);for(let te=ee.length-1;te>=0;te--)ee[te].nodeType===1&&X.push(ee[te])}let he=new Set;for(let de=U.length-1;de>=0;de--){let ee=U[de];n.scope&&n.scope.onChain.has(ee)?he.add(ee):Bt(ee,x.get(ee),he)?(P.add(ee),D.add(ee),d&&d.certificationPairs++):he.add(ee)}let ge=new Set;for(let de of U)P.has(de)&&!ge.has(de)&&Mt(de,ge)}n.scope&&n.scope.head&&Xt(n.scope.head[0],n.scope.head[1]);function Mt(U,X){let he=[U];for(;he.length;){let ge=he.pop();if(!X.has(ge)){X.add(ge),E(ge);for(let de of r(ge))N(de)&&x.has(de)&&he.push(de)}}}k.push([e,t]);for(let[U,X]of x)N(U)&&U!==e&&k.push([U,X]);return Ct(),It(),ht&&(ht.align=(ht.align||0)+(performance.now()-Ge)),{map:x,reverse:A,moved:M,identical:P,pairIdenticalChildren:E,weak:v,unpair:yt,rematch:It,insertedByHash:Nt,refused:O,identityPaired:st};function It(){Ne(),Ct();for(let U=0;U<B.length;){let X=B.length;Et(U,X),U=X,Ct(),Ne(),Ct()}}function yt(U){let X=x.get(U);if(!X)return;I.has(U)||I.set(U,new Set),I.get(U).add(X);let he=(de,ee)=>{x.delete(de),A.delete(ee),M.delete(de),P.delete(de),v.delete(de),D.delete(de)},ge=(de,ee)=>{for(let te of r(de)){let K=x.get(te);!K||st.has(te)||!(N(K)?ee.contains(K):ee.contains(K.nodes[0]))||(he(te,K),N(te)&&ge(te,K))}};he(U,X),N(U)&&ge(U,X),$.push(U),W.push(X)}function Nt(){let U=new Map;for(let X of new Set(W)){if(A.has(X))continue;let he=o(X).hash;U.has(he)||U.set(he,[]),U.get(he).push(X)}return U}function Ct(){for(;k.length;){let[U,X]=k.shift();x.get(U)!==X||D.has(U)||P.has(U)||fn(U,X)}}function Vt(U,X){if(!le(U))for(let he of r(U))N(he)&&(X.push(he),Vt(he,X))}function fn(U,X){D.add(U);let he=r(U),ge=r(X);ss.align+=he.length+ge.length,J=new Map,H=new Map;for(let ne=0;ne<he.length;ne++)J.set(he[ne],ne);for(let ne=0;ne<ge.length;ne++)H.set(ge[ne],ne);if(U.tagName==="HTML")for(let ne of["HEAD","BODY"]){let xe=he.find(Le=>N(Le)&&Le.tagName===ne),Ie=ge.find(Le=>N(Le)&&Le.tagName===ne);xe&&Ie&&!x.has(xe)&&!A.has(Ie)&&F(xe,Ie)}for(let ne=0;ne<he.length&&ne<ge.length;ne++){let xe=he[ne],Ie=ge[ne];x.has(xe)||A.has(Ie)||(N(xe)?N(Ie)&&xe.tagName===Ie.tagName&&Re(xe,Ie)&&Xt(xe,Ie):!N(Ie)&&xe.kind===Ie.kind&&xe.value===Ie.value&&Xt(xe,Ie))}ie(he,ge);let de=he.filter(ne=>!x.has(ne)),ee=ge.filter(ne=>!A.has(ne));de.length&&ee.length&&(wn(de,ee),R(de,ee),_(de,ee,he,ge),ue(he,ge));let te=!1,K=!1;for(let ne of he){if(!x.has(ne)){N(ne)&&($.push(ne),Vt(ne,$),te=!0);continue}N(ne)&&!P.has(ne)&&k.push([ne,x.get(ne)])}for(let ne of ge)!A.has(ne)&&N(ne)&&(W.push(ne),Vt(ne,W),K=!0);te&&K&&B.push([U,X])}function Et(U,X){for(let he=U;he<X;he++){let[ge,de]=B[he];if(x.get(ge)!==de)continue;let ee=r(ge),te=r(de),K=new Map,ne=new Map,xe=null;for(let Ie of ee)N(Ie)&&(x.has(Ie)?xe=Ie:(K.has(xe)||K.set(xe,[]),K.get(xe).push(Ie)));xe=null;for(let Ie of te)N(Ie)&&(A.has(Ie)?xe=A.get(Ie):(ne.has(xe)||ne.set(xe,[]),ne.get(xe).push(Ie)));for(let[Ie,Le]of K){let ke=ne.get(Ie);if(!(!ke||Le.length!==ke.length)&&Le.every(($e,Je)=>ke[Je].tagName===$e.tagName&&Be($e,ke[Je])&&!Y($e,ke[Je])))for(let $e=0;$e<Le.length;$e++)Gt(Le[$e],ke[$e])}}}function Gt(U,X){F(U,X),v.add(U),k.push([U,X]),Ct()}function wn(U,X){let he=vo(U,c),ge=vo(X,c),de=new Map;for(let ee of X){let te=c(ee);ge.get(te)===1&&de.set(te,ee)}for(let ee of U){if(x.has(ee))continue;let te=c(ee);if(he.get(te)!==1)continue;let K=de.get(te);K&&!A.has(K)&&a(ee,K)&&Xt(ee,K)}}function Bt(U,X,he){let ge=[[U,X]];for(;ge.length;){let[de,ee]=ge.pop();if(ss.certifyVisited++,d&&d.certificationVisited++,de.nodeType!==ee.nodeType)return!1;if(de.nodeType===3||de.nodeType===8){if(de.nodeValue!==ee.nodeValue)return!1;continue}if(de.nodeType!==1){if(!de.isEqualNode(ee))return!1;continue}if(de.tagName!==ee.tagName||de.namespaceURI!==ee.namespaceURI||p(de)!==p(ee))return!1;let te=de.attributes,K=ee.attributes;if(te.length!==K.length)return!1;for(let ke=0;ke<te.length;ke++){let $e=te[ke];if(ee.getAttributeNS($e.namespaceURI,$e.localName)!==$e.value)return!1}let ne=x.get(de);if(ne!==void 0&&ne!==ee)return!1;let xe=A.get(ee);if(xe!==void 0&&xe!==de)return!1;if(de!==U){if(P.has(de))continue;if(he.has(de))return!1}let Ie=i(de),Le=i(ee);if(Ie.length!==Le.length)return!1;ss.certifyScheduled+=Ie.length;for(let ke=Ie.length-1;ke>=0;ke--)ge.push([Ie[ke],Le[ke]])}return!0}function ln(U,X){return!N(U)||!(Ee.has(U)||Me.has(X))?!0:!!z(U,X)||!(Se(U)||nt(X))}function Xt(U,X){if(N(U)&&(Ee.has(U)||Me.has(X))){let he=z(U,X);if(!he){if(Se(U)||nt(X))return;F(U,X),k.push([U,X]);return}for(let ge=0;ge<he.length;ge+=2){let de=he[ge],ee=he[ge+1],te=x.get(de);te!==void 0&&te!==ee&&un(de,te);let K=A.get(ee);K!==void 0&&K!==de&&un(K,ee),x.get(de)===ee&&(M.delete(de),v.delete(de),P.add(de),D.add(de))}}h(U,X)}function un(U,X){x.delete(U),A.delete(X),M.delete(U),P.delete(U),v.delete(U),D.delete(U)}function z(U,X){let he=[U,X,!1],ge=[];for(;he.length;){let de=he.pop(),ee=he.pop(),te=he.pop(),K=x.get(te),ne=A.get(ee);if(te!==U&&(K!==void 0&&K!==ee&&st.has(te)||ne!==void 0&&ne!==te&&st.has(ne)))return null;if(!(K===ee&&P.has(te))&&((K!==void 0||ne!==void 0)&&ge.push(te,ee),!!N(te))){if(de||K!==void 0&&K!==ee||ne!==void 0&&ne!==te){let xe=r(te),Ie=r(ee);for(let Le=0;Le<xe.length&&Le<Ie.length;Le++)he.push(xe[Le],Ie[Le],!0)}else if(Ee.has(te)||Me.has(ee)){let xe=te.tagName==="TEMPLATE"?te.content:te,Ie=ee.tagName==="TEMPLATE"?ee.content:ee;for(let Le=xe.firstElementChild,ke=Ie.firstElementChild;Le&&ke;){if(p(Le)){Le=Le.nextElementSibling;continue}if(p(ke)){ke=ke.nextElementSibling;continue}(x.has(Le)||A.has(ke)||Ee.has(Le)||Me.has(ke))&&he.push(Le,ke,!1),Le=Le.nextElementSibling,ke=ke.nextElementSibling}}}}return ge}function h(U,X){F(U,X),P.add(U),N(U)&&D.add(U)}function E(U){let X=x.get(U);if(!X||!N(U))return;let he=r(U),ge=r(X);for(let de=0;de<he.length&&de<ge.length;de++)x.has(he[de])||h(he[de],ge[de])}function R(U,X){let he=te=>N(te)&&!le(te)?o(te).sig+""+o(te).hint:null,ge=vo(U,he),de=vo(X,he),ee=new Map;for(let te of X){let K=he(te);K!=null&&de.get(K)===1&&ee.set(K,te)}for(let te of U){if(x.has(te))continue;let K=he(te);if(K==null||ge.get(K)!==1)continue;let ne=ee.get(K);ne&&!A.has(ne)&&Be(te,ne)&&F(te,ne)}}function _(U,X,he,ge){let de=new Map;for(let te of X){if(!N(te)||A.has(te)||le(te))continue;let K=o(te).sig;de.has(K)||de.set(K,[]),de.get(K).push({el:te,index:H.get(te)})}let ee=[];for(let te of U){if(x.has(te)||!N(te)||le(te))continue;let K=de.get(o(te).sig);if(!K||!K.length)continue;let ne=J.get(te),xe=K.filter(Ie=>!A.has(Ie.el)).map(Ie=>({c:Ie,d:Math.abs(Ie.index-ne)}));xe.sort((Ie,Le)=>Ie.d-Le.d),xe.length>Ai&&(xe=xe.slice(0,Ai));for(let{c:Ie,d:Le}of xe){if(!Be(te,Ie.el))continue;let ke=l(te,Ie.el);ke&&ke.coef>=.5&&ee.push({b:te,s:Ie.el,coef:ke.coef,share:ke.share,d:Le,bi:ne})}}if(ee.sort((te,K)=>K.coef-te.coef||K.share-te.share||te.d-K.d||te.bi-K.bi),d&&ee.length>1){let te=new Map;for(let K of ee){let ne=te.get(K.b);ne?ne.coef===K.coef&&(ne.share===K.share?ne.strict++:ne.loose++):te.set(K.b,{coef:K.coef,share:K.share,strict:0,loose:0})}for(let[K,ne]of te)w.has(K)||!(ne.strict||ne.loose)||(w.add(K),ne.strict?d.similarTiesStrict++:d.similarTiesLoose++)}for(let te of ee)!x.has(te.b)&&!A.has(te.s)&&F(te.b,te.s)}function Q(U,X){return N(U)!==N(X)?!1:N(U)?U.tagName!==X.tagName||!Be(U,X)?!1:le(U)||o(U).hint===""||o(X).hint===""?!0:s(U,X):U.kind===X.kind}function j(U,X){let he=(de,ee)=>{let te=ee===null?-1:de===X?H.get(ee):J.get(ee),K=de[te+1];return K&&!N(K)?K:null},ge=null;for(let de of U){if(N(de)){ge=de;continue}if(x.has(de))continue;let ee=ge===null?null:x.get(ge);if(ge!==null&&!ee)continue;let te=he(X,ee);te&&!A.has(te)&&te.kind===de.kind&&F(de,te)}}function ue(U,X){j(U,X);let he=be(U,X),ge=(ee,te)=>N(ee)&&o(ee).hint!==""&&o(te).hint===""&&!!te.querySelector("br")&&!he(ee,te),de=0;for(let ee of U){if(x.has(ee)){let K=H.get(x.get(ee));K!==void 0&&K>=de&&(de=K+1);continue}let te=0;for(let K=de;K<X.length&&te<Bc;K++){let ne=X[K];if(!A.has(ne)&&(te++,Q(ee,ne)&&!Y(ee,ne)&&!ge(ee,ne))){F(ee,ne),N(ee)&&(o(ee).hint===""||o(ne).hint==="")&&v.add(ee),de=K+1;break}}}ie(U,X)}function be(U,X){let he=(ge,de,ee)=>{for(let te=de-1;te>=0;te--)if(N(ge[te])&&ee(ge[te]))return ge[te];return null};return(ge,de)=>{let ee=J.get(ge),te=H.get(de);if(ee===te)return!0;let K=he(U,ee,xe=>x.has(xe)),ne=he(X,te,xe=>A.has(xe));return K?x.get(K)===ne:!ne}}function ie(U,X){let he=U.filter(K=>N(K)&&!x.has(K)),ge=X.filter(K=>N(K)&&!A.has(K));if(!he.length||!ge.length)return;let de=vo(he,K=>K.tagName),ee=vo(ge,K=>K.tagName),te=be(U,X);for(let K of he){let ne=K.tagName;if(de.get(ne)!==1||ee.get(ne)!==1)continue;let xe=ge.find(Ie=>Ie.tagName===ne);xe&&!A.has(xe)&&te(K,xe)&&Be(K,xe)&&!Y(K,xe)&&(a(K,xe)?Xt(K,xe):(F(K,xe),v.add(K)))}}function Ne(){let U=new Map;for(let K of v)if(N(K)&&N(x.get(K))){let ne=o(K).hash;U.has(ne)||U.set(ne,[]),U.get(ne).push(K)}if(U.size)for(let K of W){if(A.has(K)||!N(K)||ve(K))continue;let ne=U.get(o(K).hash),xe=ne&&ne.find(Ie=>v.has(Ie)&&!Y(Ie,K)&&Be(Ie,K)&&Ye(Ie,K)&&a(Ie,K)&&ln(Ie,K));xe&&(yt(xe),Xt(xe,K),Ae(xe,K),M.add(xe))}let X=new Map,he=new Map,ge=new Map;for(let K of v){let ne=x.get(K);N(K)&&N(ne)&&ge.set(ne,K)}let de=(K,ne)=>{if(!A.has(K))return!ve(K);let xe=ge.get(K);return xe===A.get(K)&&xe!==ne&&!xe.contains(ne)},ee=K=>{if(A.has(K)){let ne=ge.get(K);ge.delete(K),yt(ne)}};for(let K of[...W,...ge.keys()]){if(A.has(K)&&!ge.has(K))continue;let ne=o(K).hash;if(X.has(ne)||X.set(ne,[]),X.get(ne).push(K),le(K))continue;let xe=o(K).sig;he.has(xe)||he.set(xe,[]),he.get(xe).push(K)}let te=new Set;for(let K of v){let ne=x.get(K);!N(K)||!N(ne)||le(K)||o(K).hint===""||o(ne).hint===""||s(K,ne)||te.add(K)}for(let K of[...$,...te]){let ne=x.get(K);if(ne?!(v.has(K)&&te.has(K)):Ve(K))continue;let xe=Je=>{ne&&yt(K),ee(Je)},Ie=X.get(o(K).hash);if(Ie){let Je=Ie.find(Qe=>Qe!==ne&&de(Qe,K)&&!Y(K,Qe)&&Ye(K,Qe)&&a(K,Qe)&&ln(K,Qe));if(Je){xe(Je),Xt(K,Je),Ae(K,Je),M.add(K);continue}}if(le(K)||T<=0)continue;let Le=he.get(o(K).sig);if(!Le)continue;let ke=null,$e=0;for(let Je of Le)if(!(Je===ne||!de(Je,K)||!Be(K,Je)||!Ye(K,Je)||Y(K,Je))&&(T--<=0||s(K,Je)&&($e++,ke=Je,$e>1)))break;$e>1&&O&&O.add(K),$e===1&&(xe(ke),F(K,ke),Ae(K,ke),M.add(K),k.push([K,ke]))}}}function vo(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 Uc={diff:0},Si=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,Hc=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,Wc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,_c=/\P{M}\p{M}*/gu;function Vc(e){if(e==="")return[];if(Si){let n=[];for(let o of Si.segment(e))n.push(o.segment);return n}let t=[];for(let n of e.match(Wc))if(Hc.test(n))for(let o of n.match(_c))t.push(o);else t.push(n);return t}var qc=/^[  ]+$/,Fc=e=>qc.test(e)?" ".repeat(e.length):e,ro=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),xt="",ls=e=>e.every(t=>ro(t)||t.k===xt),$c=/^[\x00-\x7f\u00A0]*$/,Kc=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function zc(e){return e===""?[]:e.match(Kc)}function an(e,t=!1){return(t?zc(e):Vc(e)).map(n=>({k:Fc(n),raw:n,len:n.length}))}var Tn=(...e)=>e.every(t=>$c.test(t));function cs(e,t,n){let o=e.length,r=t.length,c=Math.min(o+r,n),s=c+1,l=new Int32Array(2*c+3),i=[],a=o===0&&r===0;for(let y=0;y<=c&&!a;y++){i.push(l.slice(s-y,s+y+1));for(let b=-y;b<=y;b+=2){let S;b===-y||b!==y&&l[s+b-1]<l[s+b+1]?S=l[s+b+1]:S=l[s+b-1]+1;let g=S-b,d=S;for(;S<o&&g<r&&e[S].k===t[g].k;)S++,g++;if(Uc.diff+=1+S-d,l[s+b]=S,S>=o&&g>=r){a=!0;break}}}if(!a)return null;let p=[],f=o,u=r;for(let y=i.length-1;y>0;y--){let b=i[y],S=f-u,g=S+y,d=S===-y||S!==y&&b[g-1]<b[g+1]?S+1:S-1,w=b[d+y],O=w-d;for(;f>w&&u>O;)p.push([0,f-1,u-1]),f--,u--;f===w?(p.push([1,f,u-1]),u--):(p.push([-1,f-1,u]),f--)}for(;f>0&&u>0;)p.push([0,f-1,u-1]),f--,u--;return p.reverse(),p}function Gc(e,t,n){let o=f=>f.k===xt;if(!e.some(o)&&!t.some(o))return cs(e,t,n);let r=[],c=[];for(let f=0;f<e.length;f++)o(e[f])||r.push(f);for(let f=0;f<t.length;f++)o(t[f])||c.push(f);let s=cs(r.map(f=>e[f]),c.map(f=>t[f]),n);if(!s)return null;let l=[],i=0,a=0,p=(f,u)=>{for(;i<f&&a<u&&e[i].k===t[a].k;)l.push([0,i++,a++]);let y=cs(e.slice(i,f),t.slice(a,u),n);if(!y)return!1;for(let[b,S,g]of y)l.push([b,S+i,g+a]);return i=f,a=u,!0};for(let[f,u,y]of s)if(f===0){if(!p(r[u],c[y]))return null;l.push([0,i,a]),i++,a++}return p(e.length,t.length)?l:null}function Xn(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 c=0;for(;c<e.length-r&&c<t.length-r&&e[e.length-1-c].k===t[t.length-1-c].k;)e[e.length-1-c].raw!==t[t.length-1-c].raw&&o.push({bi:e.length-1-c,tok:t[t.length-1-c]}),c++;let s=e.slice(r,e.length-c),l=t.slice(r,t.length-c),i=ea(s,l)?null:Gc(s,l,n);if(!i){let d=s.length||l.length?[{bs:r,be:r+s.length,toks:l}]:[];return{hunks:d,cosmetic:o,coarse:!0,parts:d.map(w=>({...w,gap:[],group:0})),cosmeticEq:o}}let a=[],p=(d,w)=>{s[d].raw!==l[w].raw&&o.push({bi:r+d,tok:l[w]})},f=null,u=[],y=0,b=0,S=()=>{f&&a.push(f),f=null;for(let[d,w]of u)p(d,w);u=[],y++};for(let[d,w,O]of i){if(d===0){f&&ro(s[w])&&!s[w].k.includes(`
3
- `)?u.push([w,O]):(S(),p(w,O)),b=w+1;continue}(!f||u.length)&&(f&&a.push(f),f={bs:r+b,be:r+b,toks:[],gap:u.map(([x,A])=>({bi:r+x,tok:l[A]})),group:y},u=[]),d===-1?(f.be=r+b+1,b=w+1):f.toks.push(l[O])}S(),Xc(a,e);let g=fs(a);return{hunks:g.hunks,cosmetic:o.concat(g.cosmetic),parts:a,cosmeticEq:o}}function Xc(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===xt&&t[o.bs].k===xt;)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===xt&&t[o.be].k===xt;)o.bs++,o.be++}}function fs(e,t=()=>!1){let n=[],o=[],r=null,c=-1;for(let s of e){let l=t(s);if(r&&!r.alone&&!l&&s.group===c){r.be=s.be;for(let i of s.gap)r.toks.push(i.tok);for(let i of s.toks)r.toks.push(i);continue}r&&n.push({bs:r.bs,be:r.be,toks:r.toks});for(let i of s.gap)o.push(i);r={bs:s.bs,be:s.be,toks:s.toks.slice(),alone:l},c=s.group}return r&&n.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:n,cosmetic:o}}var Yc=(e,t)=>e.bs===t.bs&&e.be===t.be&&hs(e.toks,t.toks);function ds(e,t,n){let o=p=>f=>p.some(u=>Yc(f,u)),r=fs(e.parts,o(t.parts)),c=fs(t.parts,o(e.parts)),s=e.cosmeticEq.concat(r.cosmetic),l=t.cosmeticEq.concat(c.cosmetic),[i,a]=n?Jc(r.hunks,c.hunks,n,s,l):[r.hunks,c.hunks];return{lh:i,rh:a,cosL:s,cosR:l}}function Jc(e,t,n,o,r){let c=(b,S)=>b.k===S.k&&b.raw===S.raw,s=[{list:e.map(b=>({...b})),resp:new Set(o.map(b=>b.bi)),raw:new Map(o.map(b=>[b.bi,b.tok]))},{list:t.map(b=>({...b})),resp:new Set(r.map(b=>b.bi)),raw:new Map(r.map(b=>[b.bi,b.tok]))}],l=b=>b.bs===b.be,i=(b,S,g,d)=>{let w=b.list[S];if(!l(w))return d(w)===g?w.toks:null;let O=S?b.list[S-1].be:0,x=S+1<b.list.length?b.list[S+1].bs:n.length;if(g<O||g>x)return null;let A=w.toks,v=w.bs;for(;v>g;){let I=A[A.length-1];if(!c(I,n[v-1])||b.resp.has(v-1))return null;A=[I,...A.slice(0,-1)],v--}for(;v<g;){if(!c(A[0],n[v])||b.resp.has(v))return null;A=[...A.slice(1),A[0]],v++}return A},a=(b,S,g,d,w,O)=>{let x=b.list[S],A=w?g.slice(g.length-d):g.slice(0,d),v=w?g.slice(0,g.length-d):g.slice(d),I={bs:O,be:O,toks:A};if(l(x)){if(!v.length){b.list[S]=I;return}let P={bs:O,be:O,toks:v};w&&(P.lead=!0),b.list.splice(S,1,...w?[P,I]:[I,P]);return}let M={bs:x.bs,be:x.be,toks:v};b.list.splice(S,1,...w?[M,I]:[I,M])},p=(b,S,g,d,w)=>{let O=b.list[S],x=w?g.slice(g.length-d):g.slice(0,d),A=w?g.slice(0,g.length-d):g.slice(d),v={bs:O.bs,be:O.be,toks:x};if(!A.length){b.list[S]=v;return}let I=w?{bs:O.bs,be:O.bs,toks:A,lead:!0}:{bs:O.be,be:O.be,toks:A};b.list.splice(S,1,...w?[I,v]:[v,I])},f=(b,S,g,d)=>{let w=b.list[S],O=g.list[d],x=w.be,A=O.bs;if(x>=A||S+1<b.list.length&&b.list[S+1].bs<=O.be||d>0&&g.list[d-1].be>=w.bs)return!1;for(let H=x;H<A;H++)if(!ro(n[H])||n[H].k.includes(`
4
- `))return!1;let v=H=>n.slice(x,A).map((F,Ee)=>H.raw.get(x+Ee)||F),I=[...w.toks,...v(b)],M=[...v(g),...O.toks],P=(H,F,Ee)=>F>=0&&F+Ee.length<=H.length&&Ee.every((Me,je)=>H[F+je].k===Me.k),D=(H,F,Ee)=>ls(H)&&n.slice(F,Ee).some(Me=>!ro(Me)),$=H=>H.some(F=>!ro(F)),W,B,k,T;if(l(w)&&$(w.toks)&&P(M,0,w.toks)){let H=M.slice(w.toks.length);D(H,x,O.be)||(W=x,B=w.toks,k=M.slice(0,w.toks.length),T=[null,{bs:x,be:O.be,toks:H}])}if(W===void 0&&l(O)&&$(O.toks)){let H=I.length-O.toks.length,F=I.slice(0,H);P(I,H,O.toks)&&!D(F,w.bs,A)&&(W=A,B=I.slice(H),k=O.toks,T=[{bs:w.bs,be:A,toks:F},null])}if(W===void 0)return!1;let J=H=>H&&(H.bs<H.be||H.toks.length);return b.list.splice(S,1,...[T[0],{bs:W,be:W,toks:B}].filter(J)),g.list.splice(d,1,...[{bs:W,be:W,toks:k},T[1]].filter(J)),!0},u=s[0],y=s[1];for(let b=0;b<64;b++){let S=!1;e:for(let g=0;g<u.list.length;g++)for(let d=0;d<y.list.length;d++){let w=u.list[g],O=y.list[d];if(!(w.bs===O.bs&&w.be===O.be&&hs(w.toks,O.toks))){for(let x of[!0,!1]){let A=I=>x?I.be:I.bs,v=l(w)?[A(O),w.bs]:[A(w)];for(let I of v){let M=i(u,g,I,A),P=M&&i(y,d,I,A);if(!P)continue;let D=(T,J)=>x?T[T.length-1-J]:T[J],$=0;for(;$<M.length&&$<P.length&&D(M,$).k===D(P,$).k;)$++;if(!$)continue;let W=x?M.slice(0,M.length-$):M.slice($),B=x?P.slice(0,P.length-$):P.slice($);if(!($<M.length&&$<P.length&&!ls(W)&&!ls(B)&&(l(w)&&l(O)||w.bs===O.bs&&w.be===O.be)||!(x?M.slice(M.length-$):M.slice(0,$)).some(T=>!ro(T)))){if($===M.length&&$===P.length&&l(w)&&l(O)){if(w.bs===I&&O.bs===I)continue;u.list[g]={bs:I,be:I,toks:M},y.list[d]={bs:I,be:I,toks:P}}else!l(w)&&w.bs===O.bs&&w.be===O.be?(p(u,g,M,$,x),p(y,d,P,$,x)):(a(u,g,M,$,x,I),a(y,d,P,$,x,I));S=!0;break e}}}if(f(u,g,y,d)||f(y,d,u,g)){S=!0;break e}}}if(!S)break}return[u.list,y.list]}var Zc=48,Qc=.3;function ea(e,t){let n=e.filter(s=>!ro(s)),o=t.filter(s=>!ro(s));if(Math.min(n.length,o.length)<Zc)return!1;let r=new Map;for(let s of n)r.set(s.k,(r.get(s.k)||0)+1);let c=0;for(let s of o){let l=r.get(s.k);l>0&&(c++,r.set(s.k,l-1))}return c/Math.min(n.length,o.length)<Qc}var ta=(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},hs=(e,t)=>e.length===t.length&&e.every((n,o)=>n.k===t[o].k);function Ni(e,t,n,o="remote"){let r=Xn(e,t),c=Xn(e,n),{lh:s,rh:l,cosL:i,cosR:a}=ds(r,c,e),p=N=>N.bs===N.be,f=N=>N.toks.some(Y=>typeof Y.k=="string"),u=N=>p(N)&&!f(N),y=(N,Y)=>Y.bs<N.be&&N.bs<Y.be,b=(N,Y)=>!y(N,Y)&&Y.bs<=N.be&&N.bs<=Y.be&&(p(N)&&f(N)||p(Y)&&f(Y))&&!(p(N)&&p(Y)),S=(N,Y)=>N.bs===Y.bs&&N.be===Y.be&&hs(N.toks,Y.toks),g=[],d=new Set;for(let N of s){let Y=l.find(le=>!d.has(le)&&S(N,le));Y?(d.add(Y),g.push({bs:N.bs,be:N.be,side:"both",l:N,r:Y,toks:N.toks})):g.push({bs:N.bs,be:N.be,side:"L",l:N,toks:N.toks,lead:!!N.lead})}for(let N of l)d.has(N)||g.push({bs:N.bs,be:N.be,side:"R",r:N,toks:N.toks,lead:!!N.lead});g.sort((N,Y)=>N.bs-Y.bs||N.be-Y.be||Y.lead-N.lead);let w=0,O=0;for(let N of g)N.side==="both"&&(w+=N.toks.length-(N.be-N.bs));let x=g.map((N,Y)=>Y),A=N=>x[N]===N?N:x[N]=A(x[N]),v=(N,Y)=>(N=A(N),Y=A(Y),N===Y?!1:(x[N]=Y,!0)),I=g.map(N=>ta({bs:N.bs,be:N.be,toks:N.toks},e)),M={L:new Map,R:new Map};g.forEach((N,Y)=>{let le=N.side==="both"?["L","R"]:[N.side];for(let oe of le)for(let Re of I[Y])M[oe].has(Re)||M[oe].set(Re,[]),M[oe].get(Re).push(Y)});for(let N of[M.L,M.R])for(let Y of N.values())for(let le=1;le<Y.length;le++)v(Y[0],Y[le]);for(let N=0;N<g.length;N++)for(let Y=N+1;Y<g.length;Y++){let le=g[N],oe=g[Y];le.side===oe.side&&le.side!=="both"||le.bs>oe.be||(y(le,oe)||b(le,oe)?v(N,Y):le.bs===oe.bs&&p(le)&&p(oe)&&O++)}let P=(N,Y)=>{let le=N==="L"?s:l;for(let oe of le)if(oe.toks.some(Re=>Re.kind==="close"&&Re.k.el===Y.el))return oe.bs;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return-1};g.forEach((N,Y)=>{if(!(!u(N)||N.side==="both"))for(let le of N.toks){if(le.kind!=="open")continue;let oe=P(N.side,le.k);if(oe<=N.bs)continue;let Re=new Uint8Array(oe-N.bs),Be=[];if(g.forEach((Se,nt)=>{if(!(Se.side===N.side||p(Se))&&Se.bs<oe&&Se.be>N.bs){Be.push(nt);for(let Ye=Math.max(Se.bs,N.bs);Ye<Math.min(Se.be,oe);Ye++)Re[Ye-N.bs]=1}}),Be.length&&Re.every(Se=>Se===1))for(let Se of Be)v(Y,Se)}});let D=!0;for(;D;){D=!1;let N=new Map;g.forEach((Y,le)=>{let oe=A(le),Re=N.get(oe)||{bs:Y.bs,be:Y.be,L:!1,R:!1};Re.bs=Math.min(Re.bs,Y.bs),Re.be=Math.max(Re.be,Y.be),Y.side!=="R"&&(Re.L=!0),Y.side!=="L"&&(Re.R=!0),N.set(oe,Re)}),g.forEach((Y,le)=>{for(let[oe,Re]of N){if(A(le)===A(oe)||!(Re.L&&Re.R))continue;let Be=Y.bs<Re.be&&Y.be>Re.bs,Se=p(Y)&&f(Y)&&(Y.bs===Re.be||Y.bs===Re.bs);(Be||Se)&&v(le,oe)&&(D=!0)}})}let $=new Map;g.forEach((N,Y)=>{let le=A(Y);$.has(le)||$.set(le,[]),$.get(le).push(N)});let W=[];for(let N of $.values()){let Y=N.some(oe=>oe.side==="L"),le=N.some(oe=>oe.side==="R");if(Y&&le){let oe=Math.min(...N.map(nt=>nt.bs)),Re=Math.max(...N.map(nt=>nt.be)),Be=N.filter(nt=>nt.side!=="R").map(nt=>nt.l).sort((nt,Ye)=>nt.bs-Ye.bs),Se=N.filter(nt=>nt.side!=="L").map(nt=>nt.r).sort((nt,Ye)=>nt.bs-Ye.bs);W.push({bs:oe,be:Re,kind:"conflict",localHunks:Be,remoteHunks:Se})}else for(let oe of N)W.push({bs:oe.bs,be:oe.be,kind:oe.side,u:oe})}let B=(N,Y)=>{let le=N==="L"?s:l;for(let oe of le)if(oe.toks.some(Re=>Re.kind==="close"&&Re.k.el===Y.el))return oe.bs+.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="close"&&e[oe].k.el===Y.el)return oe;return 1/0},k=(N,Y)=>{let le=N==="L"?s:l;for(let oe of le)if(oe.toks.some(Re=>Re.kind==="open"&&Re.k.el===Y.el))return oe.bs-.5;for(let oe=0;oe<e.length;oe++)if(e[oe].kind==="open"&&e[oe].k.el===Y.el)return oe;return-1/0},T=N=>N.kind==="R"?"R":"L",J=N=>N.kind==="R"?1:0;W.sort((N,Y)=>{if(N.bs!==Y.bs)return N.bs-Y.bs;let le=N.bs===N.be,oe=Y.bs===Y.be;if(le!==oe)return le?-1:1;if(le&&oe&&N.kind!=="conflict"&&Y.kind!=="conflict"){let Be=N.u.toks,Se=Y.u.toks,nt=ht=>ht.length&&ht.every(Ge=>Ge.kind==="open"),Ye=ht=>ht.length&&ht.every(Ge=>Ge.kind==="close");if(nt(Be)&&nt(Se)){let ht=Math.max(...Be.map(st=>B(T(N),st.k))),Ge=Math.max(...Se.map(st=>B(T(Y),st.k)));if(ht!==Ge)return Ge-ht}if(Ye(Be)&&Ye(Se)){let ht=Math.min(...Be.map(st=>k(T(N),st.k))),Ge=Math.min(...Se.map(st=>k(T(Y),st.k)));return ht!==Ge?Ge-ht:J(Y)-J(N)}}let Re=Be=>Be.u&&Be.u.lead?1:0;return Re(Y)-Re(N)||J(N)-J(Y)||N.be-Y.be});let H=[],F=[],Ee=0,Me=N=>{N>Ee&&(H.push({bs:Ee,be:N,toks:e.slice(Ee,N),source:"base"}),Ee=N)};for(let N of W){if(Me(N.bs),N.kind==="conflict"){let Y=us(e,N.localHunks,N.bs,N.be),le=us(e,N.remoteHunks,N.bs,N.be),oe=o==="local"?Y:o==="both"?Y.concat(le):le,Re=(nt,Ye)=>{let ht=0;for(let Ge of nt)Ge.be<=N.bs&&!Ye.includes(Ge)&&(ht+=Ge.toks.length-(Ge.be-Ge.bs));return ht},Be=N.bs+Re(s,N.localHunks),Se=N.bs+Re(l,N.remoteHunks);F.push({bs:N.bs,be:N.be,ls:Be,le:Be+Y.length,rs:Se,re:Se+le.length,ms:0,me:0,base:e.slice(N.bs,N.be),local:Y,remote:le,resolved:oe}),H.push({bs:N.bs,be:N.be,toks:oe,source:"conflict",localHunks:N.localHunks,localToks:Y,keepsLocal:o!=="remote"})}else H.push({bs:N.bs,be:N.be,toks:N.u.toks,source:N.kind==="R"?"remote":"local",localHunks:N.kind==="R"?[]:[N.u.l]});Ee=Math.max(Ee,N.be)}Me(e.length);let je=0,ae=0;for(let N of H)N.source==="conflict"&&(F[ae].ms=je,F[ae].me=je+N.toks.length,ae++),je+=N.toks.length;let Ae=new Map(i.map(N=>[N.bi,N.tok])),Ve=new Map(a.map(N=>[N.bi,N.tok])),ve=[];for(let N of H){N.source==="base"&&(N.toks=N.toks.map((Y,le)=>{let oe=N.bs+le,Re=Ae.get(oe),Be=Ve.get(oe),Se=Re&&Be?o==="remote"?Be:Re:Re||Be||Y;return Se===Y?Y:{...Se,cosmetic:!0}}));for(let Y of N.toks)ve.push({...Y,src:N.source})}return{tokens:ve,segments:H,conflicts:F,localHunks:s,remoteHunks:l,collapsedDelta:w,samePoint:O,mapLocalOffset:na(e,s,H)}}function us(e,t,n,o){let r=[],c=n;for(let s of t)r=r.concat(e.slice(c,s.bs),s.toks),c=s.be;return r.concat(e.slice(c,o))}var as=e=>e.reduce((t,n)=>t+n.len,0);function na(e,t,n){let o=new Int32Array(e.length+1);for(let s=0;s<e.length;s++)o[s+1]=o[s]+e[s].len;let r=t.map(s=>({bs:o[s.bs],be:o[s.be],text:s.toks.map(l=>l.raw).join(""),ref:s})),c=n.map(s=>({bs:o[s.bs],be:o[s.be],len:as(s.toks),source:s.source,localHunks:s.localHunks||[],localLen:s.localToks?as(s.localToks):0,keepsLocal:s.keepsLocal,ref:s}));return s=>{let l=null,i=null,a=0,p=0,f=0;for(let y of r){let b=y.bs-f;if(s<=p+b){l=f+(s-p);break}if(p+=b,f=y.bs,s<=p+y.text.length){i=y,a=s-p,l=y.bs;break}p+=y.text.length,f=y.be}l===null&&(l=f+(s-p));let u=0;for(let y of c){if(!i&&l<=y.bs)return u;if(!(i?y.localHunks.includes(i.ref):l<y.be)){u+=y.len;continue}if(y.source==="base")return u+(l-y.bs);if(y.source==="remote")return u+y.len;if(y.source==="local")return u+Math.min(a,y.len);if(!y.keepsLocal||!i)return u+y.len;let S=y.localHunks.indexOf(i.ref),g=as(us(e,y.localHunks.slice(0,S),y.ref.bs,i.ref.bs));return u+Math.min(g+a,y.localLen)}return u}}function Go(e,t,n,o="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:d=>Math.min(d,t.length),granularity:"word"};let r=Tn(e,t,n),c=an(e,r),s=an(t,r),l=an(n,r),i=c.length<=2e4&&s.length<=2e4&&l.length<=2e4?Ni(c,s,l,o):null,a="word",p=c;if(!i){let d=w=>w.split(/(?<=\n)/).map(O=>({k:O,raw:O,len:O.length}));p=d(e),i=Ni(p,d(t),d(n),o),a="line"}let f=d=>d.map(w=>w.raw).join(""),u=d=>{let w=[0];for(let O of d)w.push(w[w.length-1]+O.len);return w},y=u(p),b=null,S=null,g=null;if(i.conflicts.length){let d=w=>w.split(/(?<=\n)/).map(O=>({k:O,raw:O,len:O.length}));b=u(a==="line"?d(t):s),S=u(a==="line"?d(n):l),g=u(i.tokens)}return{text:f(i.tokens),conflicts:i.conflicts.map(d=>({bs:y[d.bs],be:y[d.be],ls:b[d.ls],le:b[d.le],rs:S[d.rs],re:S[d.re],ms:g[d.ms],me:g[d.me],base:f(d.base),local:f(d.local),remote:f(d.remote),resolved:f(d.resolved)})),mapLocalOffset:i.mapLocalOffset,granularity:a}}function uo(e,t,n=4e3){if(e===t)return[];let o=Tn(e,t),r=an(e,o),c=an(t,o),s=Xn(r,c,n),l=[0];for(let i of r)l.push(l[l.length-1]+i.len);return s.hunks.map(i=>({bs:l[i.bs],be:l[i.be],text:i.toks.map(a=>a.raw).join("")}))}function zt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function _n({base:e,side:t,retained:n,transfers:o,baseAtomKey:r=l=>l.el,sideAtomKey:c=l=>l.el,budget:s=zt()}){let l=[],i=A=>({status:"fallback",reason:A}),a=A=>A>s.remaining?!1:(s.remaining-=A,!0);if(!a((n.length+o.length)*3))return i("work-limit");for(let[A,v]of[["retained",n],["transfer",o]])for(let I of v){let{from:M,to:P,target:D}=I;if(!Number.isInteger(M)||!Number.isInteger(P)||!Number.isInteger(D)||M<0||P<=M||P>e.text.length||D<0||D+P-M>t.text.length)return i("invalid-range");l.push({...I,kind:A})}let p=Symbol(),f=A=>(v,I)=>{if(!a(1))throw p;return s.sortComparisons++,A(v,I)},u,y;try{u=l.slice().sort(f((A,v)=>A.from-v.from||A.to-v.to)),y=l.slice().sort(f((A,v)=>A.target-v.target||A.to-A.from-(v.to-v.from)))}catch(A){if(A===p)return i("work-limit");throw A}if(!a(l.length*2))return i("work-limit");for(let A=1;A<u.length;A++)if(u[A].from<u[A-1].to)return i("source-overlap");for(let A=1;A<y.length;A++)if(y[A].target<y[A-1].target+y[A-1].to-y[A-1].from)return i("target-overlap");for(let A of u){let v=A.to-A.from;if(!a(v))return i("work-limit");for(let I=0;I<v;I++){let M=A.from+I,P=A.target+I;if(s.comparisons++,e.text[M]!==t.text[P])return i("unequal-occurrence");let D=e.atomAt.get(M),$=t.atomAt.get(P);if(!!D!=!!$||D&&r(D)!==c($))return i("different-atom")}}let b=e.text.length+t.text.length+2,S=l.reduce((A,v)=>A+(v.to-v.from)*2,2);if(!a(b+S+l.length))return i("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),d=new Int32Array(t.text.length+1).fill(-1);s.mapCells+=b,s.mapWrites+=S;let w=-1,O=!0;for(let A of u){A.target<w&&(O=!1),w=A.target+A.to-A.from;for(let v=0;v<A.to-A.from;v++)g[A.from+v]=A.target+v,d[A.target+v]=A.from+v}return g[e.text.length]=t.text.length,d[t.text.length]=e.text.length,{status:"ready",runs:u,bTo:g,toB:d,monotone:O,covers:(A,v)=>{if(!a(v-A))return null;s.coverageChecks+=v-A;for(let I=A;I<v;I++)if(e.text[I]!==xt&&!/\s/.test(e.text[I])&&g[I]<0)return!1;return!0}}}function ps({base:e,side:t,baseOf:n=()=>null,budget:o=zt()}){if(e.text===t.text||!e.text.includes(xt)&&!t.text.includes(xt))return{status:"none"};let r=(e.text.length+t.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,S)=>S<b.length&&(b[S]===xt||/\s/.test(b[S])),s=new Map,l=Symbol(),i=(b,S)=>{let g=b.stackAt[S]||[];if(!s.has(g)){if(g.length>o.remaining)throw l;o.remaining-=g.length,o.boundarySteps+=g.length,s.set(g,g.find(d=>d.block)?.el||null)}return s.get(g)},a=[],p=(b,S)=>{let g=i(e,b),d=i(t,S),w=g&&d&&n(d)!==g?"transfer":"retained",O=a[a.length-1];O&&O.to===b&&O.target+O.to-O.from===S&&O.kind===w&&O.destination===d?O.to++:a.push({from:b,to:b+1,target:S,destination:d,kind:w})},f=0,u=0,y=!1;try{for(;f<e.text.length||u<t.text.length;){if(f<e.text.length&&u<t.text.length&&e.text[f]===t.text[u]){let O=e.atomAt.get(f),x=t.atomAt.get(u);if(!!O!=!!x||O&&n(x.el)!==O.el)return{status:"none"};p(f++,u++);continue}if(!c(e.text,f)&&!c(t.text,u))return{status:"none"};let b=f,S=u;for(;c(e.text,f);)f++;for(;c(t.text,u);)u++;let g=e.text.slice(b,f),d=t.text.slice(S,u);(g.includes(xt)||d.includes(xt))&&(y=!0);let w=0;for(;w<f-b&&w<u-S&&e.text[f-w-1]===t.text[u-w-1];)w++;for(let O=w;O>0;O--)p(f-O,u-O)}}catch(b){if(b===l)return{status:"fallback",reason:"work-limit"};throw b}return y?_n({base:e,side:t,retained:a.filter(b=>b.kind==="retained"),transfers:a.filter(b=>b.kind==="transfer"),sideAtomKey:b=>n(b.el)||b.el,budget:o}):{status:"none"}}var vi=/\s/,vr=/\S/;function Rn(e,t,n,o,r,c,s=-1,l=-1){if(!e.length)return-1;r(o,e.length);let i=new Int32Array(e.length),a=0;for(let y=1;y<e.length;y++){for(r(o,1);a&&(r(o,1),e[a]!==e[y]);)a=i[a-1];r(o,1),e[a]===e[y]&&a++,i[y]=a}let p=-1,f=0,u=0;a=0;for(let y=0;y<t.length;y++){for(r(o,1);a&&(r(o,1),e[a]!==t[y]);)a=i[a-1];if(r(o,1),e[a]===t[y]&&a++,a!==e.length)continue;let b=y+1-e.length,S=y+1;for(a=i[a-1];f<n.length&&n[f].from<b;)r(o,1),f++;for(;u<n.length&&n[u].to<S;)r(o,1),u++;if(r(o,6),!(f===n.length||u===n.length||n[f].from!==b||n[u].to!==S||s>=0&&b<l&&S>s)){if(!c)return b;if(p>=0)return-1;p=b}}return p}function Xo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function ms(e,t,n,o){let r=null;for(let s of t)if(o(n,1),!(s.source!==e.source||s.side!==e.side))for(let l of s.runs){if(o(n,1),l.source!==e.source)continue;let i=Math.max(e.from,l.from),a=Math.min(e.to,l.to);i>=a||(r||(o(n,e.to-e.from),r=new Uint8Array(e.to-e.from)),o(n,a-i),r.fill(1,i-e.from,a-e.from))}if(!r)return!1;o(n,e.to-e.from);let c=!1;for(let s=e.from;s<e.to;s++)if(vr.test(e.flat.text[s])){if(!r[s-e.from])return!1;c=!0}return c}function gs({source:e,side:t,views:n,eligible:o,blocked:r,baseId:c,model:s,tokensOf:l,budget:i,charge:a}){let{V:p,A:f,idOf:u}=n[t],y=n[1-t];if(e.nodeType!==1||f.identical.has(e)||y.A.identical.has(e)||r.has(e)||!o(e))return null;let b=p.twin(e),S=y.V.twin(e);if(!b||!S||f.map.get(e)!==b||f.reverse.get(b)!==e||y.A.map.get(e)!==S||y.A.reverse.get(S)!==e||!p.here(b)||!y.V.here(S)||!o(b)||!o(S))return null;let g=c(e);if(g!==u(b)||g!==y.idOf(S))return null;let d=s(e,null,i),w=s(b,f,i),O=s(S,y.A,i);if(!Xo(d)||!Xo(w)||!Xo(O))return null;let x=d.flat.text,A=w.flat.text;if(a(i,x.length+A.length*3),!vr.test(A)||A.length>=x.length)return null;let v=x.startsWith(A),I=x.endsWith(A);if(v===I)return null;let M=v?A.length:0,P=v?x.length:x.length-A.length,D=M,$=P;for(;D<$&&(a(i,1),!!vi.test(x[D]));)D++;for(;$>D&&(a(i,1),!!vi.test(x[$-1]));)$--;if(D===$)return null;let W=l(d,i),B=!1,k=!1;for(let T of W)a(i,1),T.from===D&&(B=!0),T.to===$&&(k=!0);return!B||!k?null:{source:e,side:t,flat:d.flat,from:M,to:P}}function Oi({base:e,views:t,side:n,attempt:o,eligible:r,blocked:c,baseId:s,model:l,tokensOf:i,certificates:a,charge:p,exhausted:f,limit:u}){if(u<=0)return null;let y=zt(u),{V:b,A:S,idOf:g}=t[n],d=t[1-n],[w,O,x,A]=o,v=null;try{for(let I=w;I<=O;I++){p(y,1);let M=e[I];if(M.nodeType!==1||S.identical.has(M)||d.A.identical.has(M)||c.has(M)||!r(M))continue;let P=gs({source:M,side:n,views:t,eligible:r,blocked:c,baseId:s,model:l,tokensOf:i,budget:y,charge:p});if(!P||ms(P,a,y,p))continue;let{flat:D,from:$,to:W}=P;p(y,(W-$)*2);let B=D.text.slice($,W).trim();for(let k=x;k<=A;k++){p(y,1);let T=b.units[k],J=b.baseOf(T);if(!J||J===M||J.nodeType!==1||T.nodeType!==1||J.parentNode!==M.parentNode||T.parentNode!==S.map.get(M).parentNode||S.map.get(J)!==T||S.reverse.get(T)!==J||c.has(J)||!r(J)||!r(T)||s(J)!==g(T))continue;let H=l(J,null,y),F=l(T,S,y);if(!Xo(H)||!Xo(F))continue;let Ee=H.flat.text,Me=F.flat.text;if(p(y,Ee.length),!vr.test(Ee)||Me.length<=Ee.length)continue;let je=i(F,y),ae=Rn(Ee,Me,je,y,p,!0);if(!(ae<0)&&!(Rn(B,Me,je,y,p,!1,ae,ae+Ee.length)<0)){(v||=[]).push(P);break}}}}catch(I){if(I!==f)throw I}return v}function Mi(e,t,n,o,r,c,s){if(c==="both"||n.atoms.length||o.atoms.length||r.atoms.length)return c;let l=c==="remote";if(l?s.rss!==s.rse||s.lss===s.lse||s.local===s.base:s.lss!==s.lse||s.rss===s.rse||s.remote===s.base)return c;for(let i of e){if(i.source!==t||i.side!==(l?1:0)||i.flat.text!==n.text||i.flat.nodes.length!==n.nodes.length||s.be<=i.from||s.bs>=i.to)continue;let a=!0;for(let f=0;f<n.nodes.length;f++){let u=i.flat.nodes[f],y=n.nodes[f];if(u.node!==y.node||u.s!==y.s||u.e!==y.e){a=!1;break}}if(!a)continue;let p=!1;for(let f=s.bs;f<s.be;f++)if(vr.test(n.text[f])){if(f<i.from||f>=i.to){a=!1;break}p=!0}if(a&&p)return l?"local":"remote"}return c}var Vn="\uFFFC";var oa={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(" ")),Di=new Set(["BR","WBR","IMG"]),bs=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)||Di.has(e.tagName))return!0;if(!An.has(e.tagName))return!bs.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 ra(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function nn(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,c)=>{for(let s of r){if(s.nodeType===3){let f=s.nodeValue;if(!f)continue;n.nodes.push({node:s,s:n.text.length,e:n.text.length+f.length}),n.text+=f;for(let u=0;u<f.length;u++)n.stackAt.push(c);continue}if(s.nodeType!==1)continue;if(t.ignored&&t.ignored(s)){n.pins.push({el:s,i:n.text.length});continue}if(t.skip&&t.skip.has(s))continue;let l=t.via&&t.via(s)||s;l!==s&&(n.via||(n.via=new Map)).set(l,s);let i=s.tagName;if(t.blocks&&t.blocks.has(s)){n.text.length&&n.text[n.text.length-1]!==xt&&(n.stackAt.push(c),n.text+=xt);let f={el:s,tag:i,from:n.text.length,to:-1,depth:c.length,block:!0};n.marks.push(f);let u=c.concat([f]);o(l.childNodes,u),n.stackAt.push(u),n.text+=xt,f.to=n.text.length;continue}let a=An.has(i)&&ra(l);if(Di.has(i)||!An.has(i)||t.remoteWins&&t.remoteWins(s)||t.atomize&&t.atomize(s)||a){n.atoms.push({i:n.text.length,el:s,key:a?i+":empty":i,stack:c}),n.stackAt.push(c),n.text+=Vn;continue}let p={el:s,tag:i,from:n.text.length,to:-1,depth:c.length};n.marks.push(p),o(l.childNodes,c.concat([p])),p.to=n.text.length}};if(o(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&Er(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 c of n.nodes)c.s>r.i&&(c.s--,c.e--);n.atoms=[]}return n.atomAt=new Map(n.atoms.map(r=>[r.i,r])),n}function sa(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function ia(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,"&quot;")}"`;return t+">"}function Mo(e,t,n){let o="",r=[];for(let c=t;c<n;c++){let s=e.stackAt[c],l=0;for(;l<r.length&&l<s.length&&r[l]===s[l];)l++;for(;r.length>l;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<s.length;){let a=s[r.length];o+=ia(a.el),r.push(a)}let i=e.atomAt.get(c);o+=i?i.el.outerHTML:e.text[c]===xt?"":sa(e.text[c])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function la(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 Bi(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 Ei(e,t=()=>!1){let n=new Map,o=c=>{let s=n.get(c);return s===void 0&&(s="{"+c.map(l=>la(l,t)).sort().join(",")+"}",n.set(c,s)),s},r="";for(let c=0;c<e.text.length;c++){let s=e.atomAt.get(c);r+=(s?"["+Bi(s.el,t)+"]":e.text[c])+o(e.stackAt[c])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function Oo(e,t,n,o=r=>r.key){let r=[],c=e.text,s=0,l=i=>{if(i<=s)return;let a=c.slice(s,i);if(n)for(let p of a.split(/(?<=\n)/))r.push({k:p,raw:p,len:p.length});else for(let p of an(a,t))r.push(p)};for(let i of e.atoms)l(i.i),r.push({k:"\0"+o(i),raw:Vn,len:1,atom:!0}),s=i.i+1;return l(c.length),r}function Er(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 Eo=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 Or(e,t,n,o){let r=Eo(t),c=Eo(n),s=[],l=0,i=0;for(let p of o.hunks){i+=p.bs-l;let f=i+p.toks.length;s.push({bs:r[p.bs],be:r[p.be],ss:c[i],se:c[f],text:e.text.slice(c[i],c[f]),toks:p.toks,lead:!!p.lead}),i=f,l=p.be}let a=new Map;for(let p of o.cosmetic)a.set(p.bi,p.tok.raw);return{hunks:s,respell:a}}function Ii(e,t,n){let o=s=>s===xt||/\s/.test(s),r=s=>s.replace(/[\u001E\s]/g,""),c=[];for(let s of e){let l=t.slice(s.bs,s.be),i=n.slice(s.ss,s.se);if(!l.includes(xt)&&!i.includes(xt)||l.includes(Vn)||i.includes(Vn)||r(l)!==r(i)){c.push(s);continue}let a=0,p=0;for(;;){let f=a,u=p;for(;f<l.length&&o(l[f]);)f++;for(;u<i.length&&o(i[u]);)u++;let y=a,b=p;for(;y<f&&b<u&&l[y]===i[b];)y++,b++;let S=f,g=u;for(;S>y&&g>b&&l[S-1]===i[g-1];)S--,g--;if(S>y||g>b){let d=i.slice(b,g);c.push({bs:s.bs+y,be:s.bs+S,ss:s.ss+b,se:s.ss+g,text:d,toks:[...d].map(w=>({k:w,raw:w,len:1})),lead:s.lead})}if(f>=l.length)break;a=f+1,p=u+1}}return c}function Ci(e,t,n){let o=new Int32Array(t+1).fill(-1),r=new Int32Array(n+1).fill(-1),c=0,s=0,l=i=>{for(;c<i;)o[c]=s,r[s]=c,c++,s++};for(let i of e)l(i.bs),c=i.be,s=i.se;return l(t),o[t]=s,r[s]=t,{bTo:o,toB:r}}function Ri(e,t,n){let o=[],r=0,c=0,s=(l,i)=>{if(r===l&&c===i)return;let a=t.text.slice(c,i);o.push({bs:r,be:l,ss:c,se:i,text:a,toks:an(a,Tn(a)),lead:!1})};for(let l of n.runs)s(l.from,l.target),r=l.to,c=l.target+l.to-l.from;return s(e.text.length,t.text.length),{hunks:o,respell:new Map}}function Li(e,t,n,o){let r=Eo(t),c=Eo(n),s=(i,a)=>{let p=0,f=i.length;for(;p<f;){let u=p+f>>>1;i[u]<a?p=u+1:f=u}return i[p]===a?p:-1};for(let i of e.hunks)if(s(r,i.bs)<0||s(r,i.be)<0)return null;if(e.hunks.some(i=>s(c,i.ss)<0||s(c,i.se)<0)){if(!o)return null;let i=[];for(let u of e.hunks)i.push(u.ss,u.se);let a=[],p=0,f=0;for(let u of n){let y=f+u.len;for(;p<i.length&&i[p]<=f;)p++;let b=f;for(;p<i.length&&i[p]<y;){let S=i[p++];if(S>b){let g=u.raw.slice(b-f,S-f);a.push(...an(g,Tn(g))),b=S}}if(b===f)a.push(u);else{let S=u.raw.slice(b-f);a.push(...an(S,Tn(S)))}f=y}n=a,c=Eo(n)}let l=[];for(let i of e.hunks){let a=s(r,i.bs),p=s(r,i.be),f=s(c,i.ss),u=s(c,i.se);if(a<0||p<0||f<0||u<0)return null;l.push({bs:a,be:p,toks:n.slice(f,u),gap:[],group:l.length})}return{parts:l,cosmeticEq:[],tokens:n}}function ys(e,t,n,o={},r=null){return Ui(e,t,n,o.base,o.local,o.remote,r,{})}function Ui(e,t,n,o,r,c,s,l){let i=Tn(Er(e),Er(t),Er(n)),a=Oo(e,i,!1,o),p=Oo(t,i,!1,r),f=Oo(n,i,!1,c),u=a.length>2e4||p.length>2e4||f.length>2e4;u&&(a=Oo(e,i,!0,o),p=Oo(t,i,!0,r),f=Oo(n,i,!0,c));let y=s?.local?Ri(e,t,s.local):null,b=s?.remote?Ri(e,n,s.remote):null,S=y?Li(y,a,p,!u):Xn(a,p),g=b?Li(b,a,f,!u):Xn(a,f);y&&S&&(p=S.tokens),b&&g&&(f=g.tokens);let d,w;if(S&&g){let O=ds(S,g,a);d=Or(t,a,p,{hunks:O.lh,cosmetic:O.cosL}),w=Or(n,a,f,{hunks:O.rh,cosmetic:O.cosR})}else d=y||Or(t,a,p,S),w=b||Or(n,a,f,g);return d.hunks=Ii(d.hunks,e.text,t.text),w.hunks=Ii(w.hunks,e.text,n.text),l.base=e,l.local=t,l.remote=n,l.lines=u,l.baseTokens=a,l.localEdits=d,l.remoteEdits=w,l.localMap=Ci(d.hunks,e.text.length,t.text.length),l.remoteMap=Ci(w.hunks,e.text.length,n.text.length),l.full=null,l}function Pi(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Io=/\s/;function Mr(e,t,n){for(let o=t;o<n;o++)if(!Io.test(e[o]))return!1;return!0}function ca(e,t,n){let o=e.cache[n]||(e.cache[n]=new Map);if(o.has(t))return o.get(t);let r=n===0?"local":"remote",c=n===0?"remote":"local",s=t.baseMark,l=t[c+"Mark"],i=!t.block&&!t[r]&&!!l&&s.to>s.from;if(i){let a=n===0?e.ML:e.MR,p=n===0?e.MR:e.ML,f=n===0?e.fr:e.fl,u=!1;for(let y=s.from;y<s.to;y++){if(a.bTo[y]>=0){i=!1;break}p.bTo[y]<0&&!Io.test(e.fb.text[y])&&(u=!0)}if(i&&!u){for(let y=l.from;y<l.to;y++)if(p.toB[y]<0&&!Io.test(f.text[y])){u=!0;break}}i&&=u}return o.set(t,i),i}function ji(e,t,n,o,r,c,s,l,i){let a=l===0?e.fl:e.fr,p=null;for(let f=n;f<o;f++){let u=t[f];if(!Mr(a.text,u.ss,u.se))return null;if(Mr(e.fb.text,u.bs,u.be)){if(u.bs<u.be&&u.ss<u.se||Io.test(e.fb.text[u.bs-1]||"")||Io.test(e.fb.text[u.be]||""))continue;return null}let y=!1;for(let b=u.bs;b<u.be;b++){if(Io.test(e.fb.text[b]))continue;let S=null;for(let g of e.fb.stackAt[b]){let d=e.byEl.get(g.el);if(d&&ca(e,d,l)){S=d;break}}if(!S)return null;(p||(p=new Set)).add(S),y=!0}if(!y)return null}if(!p){if((l===0?"local":"remote")!==i)return null;let f=l===0?e.fr:e.fl,u=!1;for(let y=c;y<s;y++){let b=r[y];if(!Mr(e.fb.text,b.bs,b.be))return null;Mr(f.text,b.ss,b.se)||(u=!0)}if(!u)return null}return p||0}function Ir(e){let{out:t,policy:n="remote",L:o,R:r}=e,c=e.provenance||new WeakMap,s=e.textMappers||new WeakMap,l=e.conflicts||[],i=e.decisions||[],a=l.length,p=e.conflict||(m=>l.push(m)),f={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},u=[],y=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),b={base:null,local:null,remote:null};if(!e.prepared&&y&&e.moveIn){let m=Te=>De=>Te.some(Ce=>Ce===De||Ce.nodeType===1&&Ce.contains(De)),L=m(e.local),V=m(e.remote),q=m(e.base),Z=new Set,pe=Te=>{if(!An.has(Te.tagName))return;let De=o.map.get(Te),Ce=r.map.get(Te);(De&&!L(De)||Ce&&!V(Ce))&&Z.add(Te);for(let Ue of Te.children)pe(Ue)};for(let Te of e.base)Te.nodeType===1&&pe(Te);let we=Te=>De=>{if(!An.has(De.tagName))return!1;let Ce=Te.reverse.get(De);return!!Ce&&(Z.has(Ce)||!q(Ce))};Z.size&&(b.base=Te=>Z.has(Te)),b.local=we(o),b.remote=we(r)}let S={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&y&&e.moveIn){let m=q=>Z=>q.some(pe=>pe===Z||pe.nodeType===1&&pe.contains(Z)),L=m(e.local),V=m(e.remote);for(let q of nn(e.base,{...e,atomize:b.base}).atoms){let Z=o.map.get(q.el),pe=r.map.get(q.el),we=!!Z&&!L(Z),Te=!!pe&&!V(pe);!we&&!Te||(we&&e.movePlanned?.(q.el,"local",Z,null),Te&&e.movePlanned?.(q.el,"remote",pe,null),S.base.add(q.el),Z&&!we&&S.local.add(Z),pe&&!Te&&S.remote.add(pe),L(q.el)&&S.local.add(q.el),V(q.el)&&S.remote.add(q.el))}}let g=e.prepared?.base||nn(e.base,{...e,atomize:b.base,skip:S.base}),d=e.prepared?.local||nn(e.local,{...e,atomize:b.local,skip:S.local}),w=e.prepared?.remote||nn(e.remote,{...e,atomize:b.remote,skip:S.remote}),O=new Map(g.atoms.map(m=>[m.el,m])),x={},A=m=>e.prepared?e.prepared.full?.(m)||null:S[m].size?(x[m]||(x[m]=nn(e[m],{...e,atomize:b[m]})),x[m]):null,v=(m,L,V)=>{L.namespaceURI?m.setAttributeNS(L.namespaceURI,L.name,V):m.setAttribute(L.name,V)},I=(m,L,V,q)=>{if(!L&&(!V||!q)){for(let pe of(V||q).attributes)v(m,pe,pe.value);return}let Z=new Map;for(let pe of[L,V,q])if(pe)for(let we of pe.attributes)Z.set(we.name,we);for(let[pe,we]of Z){let Te=L?L.getAttribute(pe):null,De=V?V.getAttribute(pe):Te,Ce=q?q.getAttribute(pe):Te,Ue;De===Ce?Ue=De:De===Te?(Ue=Ce,i.push({kind:"attr",el:m,name:pe,source:"remote"})):Ce===Te?(Ue=De,i.push({kind:"attr",el:m,name:pe,source:"local"})):(Ue=n==="local"?De:Ce,p({kind:"attr",el:m,name:pe,base:Te,local:De,remote:Ce,resolved:Ue},{el:m,sample:we}),i.push({kind:"attr",el:m,name:pe,source:"both"})),Ue!=null&&v(m,we,Ue)}},M=(m,L,V,q)=>m&&e.mergeAttrs?e.mergeAttrs(m,L,V,q):I(q,m,L,V),P=e.mergeElement||((m,L,V)=>{let q=t.createElement(m.tagName);M(m,L,V,q);let Z=L||m,pe=V||m,we=n==="local"?Z.isEqualNode(m)?pe:Z:pe.isEqualNode(m)?Z:pe;for(let Te of we.childNodes)q.appendChild(t.importNode(Te,!0));return c.set(q,{base:m,local:L,remote:V}),q}),D=e.cloneUnit||((m,L)=>{let V=t.importNode(m,!0);return c.set(V,{base:null,local:L==="local"?m:null,remote:L==="remote"?m:null}),V}),$=e.atomKey||(m=>Bi(m,()=>!1)),W=(m,L)=>{let V=new Map;for(let q of m.atoms)if(e.remoteWins&&e.remoteWins(q.el)&&An.has(q.el.tagName))V.set(q,"w"+q.el.tagName+"#"+(q.el.id||""));else if(!y)V.set(q,q.key);else if(m===g)V.set(q,"="+$(q.el));else{let Z=L.reverse.get(q.el),pe=Z?O.get(Z):null;pe?V.set(q,"="+$(pe.el)):Z?V.set(q,"m"+$(q.el)):V.set(q,"="+$(q.el))}return q=>V.get(q)},B=W(g,null),k=W(d,o),T=W(w,r),J=e.certifiedOrigins?e.certifiedOrigins(g,d,w,B,k,T):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let m=zt(),L=ps({base:g,side:d,baseOf:q=>o?.reverse?.get(q)||null,budget:m}),V=ps({base:g,side:w,baseOf:q=>r?.reverse?.get(q)||null,budget:m});(L.status==="ready"||V.status==="ready")&&(J={local:L.status==="ready"?L:null,remote:V.status==="ready"?V:null})}let H=e.prepared||Ui(g,d,w,B,k,T,J,f),F=H.lines,Ee=H.baseTokens,Me=H.localEdits,je=H.remoteEdits,ae=H.localMap,Ae=H.remoteMap,Ve=g.text.length,ve=m=>new Map(m.atoms.map(L=>[L.el,L])),N=ve(d),Y=ve(w),le=(m,L,V)=>{let q=new Set;if(!y)return q;for(let Z of m.atoms){let pe=O.get(L.reverse.get(Z.el));pe&&V.bTo[pe.i]<0&&q.add(pe)}return q},oe=le(d,o,ae),Re=le(w,r,Ae),Be=m=>!qn(m,{...e,remoteWins:null}),Se=new Set;if(y)for(let m of g.atoms){if(!Be(m.el))continue;let L=o.map.get(m.el)||null,V=r.map.get(m.el)||null,q=L&&!V?L:V&&!L?V:null;q&&(N.has(q)||Y.has(q))&&!q.isEqualNode(m.el)&&Se.add(m)}let nt=1,Ye=(m,L)=>({id:nt++,tag:m,base:null,local:null,remote:null,rank:L}),ht=new Map,Ge=[];for(let m of g.marks){let L=Ye(m.tag,m.depth);L.block=!!m.block,L.base=m.el,L.baseMark=m,ht.set(m.el,L),Ge.push(L)}let st=(m,L)=>{let V=-1,q=-1;for(let Z=m.from;Z<m.to;Z++){let pe=L[Z];pe>=0&&(V<0&&(V=pe),q=pe+1)}return V<0?null:[V,q]},Mt=(m,L,V,q)=>{for(let Z of m.marks){let pe=V?V.reverse.get(Z.el):null;pe&&V.identical.has(pe)&&V.pairIdenticalChildren&&V.pairIdenticalChildren(pe);let we=pe?ht.get(pe):null;if(we&&we[L]&&(we=null),!we){let Te=st(Z,q),De=0;if(Te)for(let Ce of Ge){if(Ce.tag!==Z.tag||Ce[L]||!!Ce.block!=!!Z.block)continue;let Ue=Math.min(Te[1],Ce.baseMark.to)-Math.max(Te[0],Ce.baseMark.from);(Ue>De||Ue===De&&Ue>0&&Math.abs(Ce.rank-Z.depth)<Math.abs(we.rank-Z.depth))&&(we=Ce,De=Ue)}}we||(we=Ye(Z.tag,Z.depth),we.block=!!Z.block,we.new=L),we[L]=Z.el,we[L+"Mark"]=Z,ht.set(Z.el,we)}};Mt(d,"local",o,ae.toB),Mt(w,"remote",r,Ae.toB);let It=m=>m.merged||m,yt=m=>{let L=new Set;for(let V of m)V.block||L.add(ht.get(V.el));return L},Nt=new Map,Ct=m=>{let L=Nt.get(m);return L||(L=yt(m),Nt.set(m,L)),L},Vt=(m,L)=>{let V=[],q=null;for(let Z=0;Z<Ve;Z++){let pe=L[Z];if(pe<0){q&&V.push(q),q=null;continue}let we=Ct(g.stackAt[Z]),Te=Ct(m.stackAt[pe]),De=new Set,Ce=new Set;for(let Ue of Te)we.has(Ue)||De.add(Ue);for(let Ue of we)Te.has(Ue)||Ce.add(Ue);if(!De.size&&!Ce.size){q&&V.push(q),q=null;continue}if(q&&Pi(q.added,De)&&Pi(q.removed,Ce)){q.be=Z+1;continue}q&&V.push(q),q={bs:Z,be:Z+1,added:De,removed:Ce}}return q&&V.push(q),V},fn=Vt(d,ae.bTo),Et=Vt(w,Ae.bTo),Gt=m=>m.be>m.bs?[m.bs,m.be-1]:[m.bs-1,m.bs],wn=(m,L)=>{if(Ve===0)return null;let[V,q]=Gt(m);for(let Z of L){if(Z.be<=V)continue;if(Z.bs>q)break;let pe=Z.bs<=V&&q<Z.be;return pe&&m.text===""&&Z.bs===m.bs&&Z.be===m.be?"straddle":pe?Z:m.be>m.bs?"straddle":null}return null},Bt=m=>m.bs===m.be,ln=(m,L,V=null)=>{let q=!1;for(let Z=m.bs;Z<m.be;Z++){let pe=g.text[Z];if(pe===xt)q=!0;else if(!/\s/.test(pe))return!1}for(let Z=m.ss;Z<m.se;Z++){let pe=L.text[Z];if(pe===xt)q=!0;else if(!/\s/.test(pe)){let we=V&&e.scopeUnits&&Bt(m)&&L.atomAt.get(Z);if(!we||!Be(we.el)||V.ss!==V.se||V.bs>=V.be)return!1;for(let De=V.bs;De<V.be;De++)if(!/\s/.test(g.text[De]))return!1;let Te=L===d?1:2;if(!e.scopeUnits[Te].includes(we.el)||(Te===1?o:r)?.reverse.has(we.el))return!1;q=!0}}return q},Xt=(m,L)=>m.bs<L.be&&L.bs<m.be,un=(m,L)=>m.bs<=L.be&&L.bs<=m.be&&Bt(m)!==Bt(L),z=(m,L)=>g.text.slice(m.bs,m.be).includes(xt)||L.text.slice(m.ss,m.se).includes(xt),h=m=>{if(Bt(m))return!1;let L=m.bs,V=m.be;for(;L>0&&/\s/.test(g.text[L-1]);)L--;for(;V<g.text.length&&/\s/.test(g.text[V]);)V++;return(L===0||g.text[L-1]===xt)&&(V===g.text.length||g.text[V]===xt)},E=(m,L)=>!z(m,L)&&!h(m),R=(m,L)=>Xt(m,L)||un(m,L)&&!(m.transferIn||m.transferOut||L.transferIn||L.transferOut)&&!(ln(m,d,L)&&E(L,w))&&!(ln(L,w,m)&&E(m,d)),_=(m,L)=>{if(m.bs!==L.bs||m.be!==L.be||m.toks.length!==L.toks.length)return!1;let V=m.ss,q=L.ss;for(let Z=0;Z<m.toks.length;Z++){let pe=m.toks[Z],we=L.toks[Z];if(pe.k!==we.k||pe.atom&&!d.atomAt.get(V).el.isEqualNode(w.atomAt.get(q).el))return!1;V+=pe.len,q+=we.len}return!0},Q=(m,L,V,q)=>{for(let Z of g.atoms){if(Z.i<m.bs||Z.i>=m.be||q.has(Z)||Se.has(Z))continue;let pe=L.bTo[Z.i],we=pe>=0?V.atomAt.get(pe):null;if(we&&!we.el.isEqualNode(Z.el))return!0}return!1},j=[],ue=null,be=null,ie=Me.hunks,Ne=je.hunks,U=0,X=0,he=0,ge=0,de=0,ee=m=>{m>he&&(j.push({src:"base",from:he,to:m,dL:ge,dR:de}),he=m)};for(;U<ie.length||X<Ne.length;){let m=ie[U],L=Ne[X],V=!!m&&(!L||m.bs<L.bs||m.bs===L.bs&&m.be<=L.be&&!L.lead);if(m&&L&&m.bs===L.bs&&Bt(m)&&Bt(L)){let $t=ln(m,d),$o=ln(L,w);$t!==$o&&(V=$o)}let q=V?m:L,Z=V?L:m,pe=!!Z&&_(m,L),we=!!Z&&(V?!!ie[U+1]&&_(ie[U+1],L):!!Ne[X+1]&&_(m,Ne[X+1])),Te=!!Z&&!pe&&!we&&(Ve===0||R(m,L)),De=Te,Ce=wn(q,V?Et:fn);if(Ce==="straddle"&&(De=!0),!De&&q.be>q.bs&&(De=Q(q,V?Ae:ae,V?w:d,V?oe:Re)),!De&&pe){ee(q.bs),j.push({src:"both",lfrom:m.ss,rfrom:L.ss,len:q.text.length,owner:m.owner||L.owner||null,transfer:m.transferIn||L.transferIn||null}),he=q.be,ge+=q.text.length-(q.be-q.bs),de+=q.text.length-(q.be-q.bs),U++,X++;continue}if(!De){ee(q.bs),j.push({src:V?"local":"remote",from:q.ss,to:q.se,inherit:Ce&&Ce!=="straddle"?Ce:null,owner:q.owner||null,transfer:q.transferIn||null}),he=q.be,V?(ge+=q.text.length-(q.be-q.bs),U++):(de+=q.text.length-(q.be-q.bs),X++);continue}let Ue=q.bs,gt=q.be,ct=U,dt=X,Ht=$t=>$t.bs<gt&&$t.be>Ue||Bt($t)&&($t.bs===Ue||$t.bs===gt);V?ct++:dt++,Te&&(Ue=Math.min(Ue,Z.bs),gt=Math.max(gt,Z.be),V?dt++:ct++);let jt=!0;for(;jt;){for(jt=!1;ct<ie.length&&Ht(ie[ct]);)Ue=Math.min(Ue,ie[ct].bs),gt=Math.max(gt,ie[ct].be),ct++,jt=!0;for(;dt<Ne.length&&Ht(Ne[dt]);)Ue=Math.min(Ue,Ne[dt].bs),gt=Math.max(gt,Ne[dt].be),dt++,jt=!0}let gn=Ue+ge,cn=Ue+de,xn=gt-Ue,vn=gt-Ue;for(let $t=U;$t<ct;$t++)xn+=ie[$t].text.length-(ie[$t].be-ie[$t].bs);for(let $t=X;$t<dt;$t++)vn+=Ne[$t].text.length-(Ne[$t].be-Ne[$t].bs);let Hn=gn+xn,Wn=cn+vn;if(ee(Ue),U<ct&&X<dt&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!d.atoms.length&&!w.atoms.length&&!g.pins.length&&!d.pins.length&&!w.pins.length){ue||={fb:g,fl:d,fr:w,ML:ae,MR:Ae,byEl:ht,cache:[null,null]};let $t=ji(ue,ie,U,ct,Ne,X,dt,0,n),$o=ji(ue,Ne,X,dt,ie,U,ct,1,n);if($t===null!=($o===null)){let Fr=$t!==null,ui=Fr?$t:$o;if(ui){be||=new Map;for(let ac of ui)be.set(ac,Fr?"local":"remote")}j.push(Fr?{src:"remote",from:cn,to:Wn}:{src:"local",from:gn,to:Hn}),he=gt,ge+=xn-(gt-Ue),de+=vn-(gt-Ue),U=ct,X=dt;continue}}let en={kind:"text",node:e.node||null,base:Mo(g,Ue,gt),local:Mo(d,gn,Hn),remote:Mo(w,cn,Wn),resolved:null,range:null,bs:Ue,be:gt,lss:gn,lse:Hn,rss:cn,rse:Wn},ao=e.sourceRetentions?Mi(e.sourceRetentions,e.scope?.base,g,d,w,n,en):n;en.resolved=ao==="local"?en.local:ao==="remote"?en.remote:en.local+en.remote,ao!=="remote"&&j.push({src:"local",from:gn,to:Hn,conflict:en}),ao!=="local"&&j.push({src:"remote",from:cn,to:Wn,conflict:en});let fo={site:"inline",policy:ao,fb:g,fl:d,fr:w,scope:e.scope||null,synthetic:!!e.synthetic,full:A,merged:f};u.push(fo),p(en,fo),he=gt,ge+=xn-(gt-Ue),de+=vn-(gt-Ue),U=ct,X=dt}ee(Ve);let te=g.text,K=[];if(Me.respell.size||je.respell.size){let m=Eo(Ee),L=[];for(let V=0;V<Ee.length;V++){let q=Ee[V].raw,Z=Me.respell.get(V)??q,pe=je.respell.get(V)??q;(Z!==q||pe!==q)&&K.push([m[V],Z!==q&&pe!==q?"both":Z!==q?"local":"remote"]),L.push(Z===pe?Z:Z===q?pe:pe===q||n==="local"?Z:pe)}te=L.join("")}let ne="",xe=[],Ie=[],Le=[],ke=[];for(let m of j){let L=ne.length;if(m.src==="base"){for(let V=m.from;V<m.to;V++)xe.push(V),Ie.push(e.nativeTransfers?ae.bTo[V]:V+m.dL),Le.push(e.nativeTransfers?Ae.bTo[V]:V+m.dR),ke.push(m);ne+=te.slice(m.from,m.to)}else if(m.src==="both"){for(let V=0;V<m.len;V++){let q=m.transfer&&(m.transfer.side==="remote"?m.rfrom+V:m.lfrom+V);xe.push(m.transfer&&q>=m.transfer.ss&&q<m.transfer.se?m.transfer.bs+q-m.transfer.ss:-1),Ie.push(m.lfrom+V),Le.push(m.rfrom+V),ke.push(m)}ne+=d.text.slice(m.lfrom,m.lfrom+m.len)}else{let V=m.src==="local"?d:w,q=m.transfer&&e.nativeTransfers.byOrigin[m.src==="local"?"remote":"local"].get(m.transfer.key);for(let Z=m.from;Z<m.to;Z++){let pe=m.transfer&&Z>=m.transfer.ss&&Z<m.transfer.se?m.transfer.bs+Z-m.transfer.ss:-1,we=pe>=0&&(!q||q.destination===m.owner)?(m.src==="local"?Ae:ae).bTo[pe]:-1;xe.push(pe),Ie.push(m.src==="local"?Z:we),Le.push(m.src==="remote"?Z:we),ke.push(m)}ne+=V.text.slice(m.from,m.to)}m.ms=L,m.me=ne.length,m.conflict&&(m.conflict.range||(m.conflict.range=[L,L]),m.conflict.range[1]=ne.length)}let $e=ne.length,Je=new Int32Array(Ve+1).fill(-1),Qe=new Int32Array(d.text.length+1).fill(-1),Ut=new Int32Array(w.text.length+1).fill(-1);for(let m=0;m<$e;m++)xe[m]>=0&&(Je[xe[m]]=m),Ie[m]>=0&&(Qe[Ie[m]]=m),Le[m]>=0&&(Ut[Le[m]]=m);let Pt=(m,L)=>{let V=-1,q=-1;for(let Z=m.from;Z<m.to;Z++){let pe=L[Z];pe>=0&&(V<0&&(V=pe),q=pe+1)}return V<0?null:[V,q]},C=[],G=[];for(let m of new Set(ht.values()))m.new==="local"?C.push(m):m.new==="remote"&&G.push(m);let se=(m,L)=>{m.remote=L.remote,m.remoteMark=L.remoteMark,m.new="both",L.merged=m,ht.set(L.remote,m)};if(C.length&&G.length){let m=e.idOf;for(let L of C){let V=m?m.local(L.local):null;if(!V)continue;let q=G.find(Z=>!Z.merged&&Z.tag===L.tag&&!!Z.block==!!L.block&&m.remote(Z.remote)===V);q&&se(L,q)}for(let L of C){if(L.remote)continue;let V=Pt(L.localMark,Qe);if(V)for(let q of G){if(q.merged||q.tag!==L.tag||!!q.block!=!!L.block)continue;let Z=Pt(q.remoteMark,Ut);if(Z&&Math.min(V[1],Z[1])-Math.max(V[0],Z[0])>0){se(L,q);break}}}}Nt.clear();let me=m=>{for(let L of m)if(L.block)return It(ht.get(L.el));return null},ye=g.marks.some(m=>m.block)||d.marks.some(m=>m.block)||w.marks.some(m=>m.block),ce=new Array($e).fill(null),re=new Set;if(e.nativeTransfers)for(let m=0;m<$e;m++){let L=ke[m].owner;ce[m]=L?It(ht.get(L)):xe[m]>=0?me(g.stackAt[xe[m]]):null}else if(ye){let m=(Ce,Ue,gt)=>{let ct=new Set([Ce,Ue,gt]);ct.delete(null);let dt=[];for(let jt of ct){let gn=jt===Ce,cn=jt===Ue,xn=jt===gt;(cn===xn?cn:cn===gn?xn:cn)&&dt.push(jt)}if(dt.length<=1)return dt[0]||null;let Ht=n==="local"?Ue:gt;return dt.includes(Ht)?Ht:dt[0]},L=(Ce,Ue)=>Ue>=0?me(Ce.stackAt[Ue]):null,V=new Map;for(let Ce=0;Ce<$e;Ce++){if(ne[Ce]!==xt)continue;let Ue=xe[Ce]>=0?L(g,xe[Ce]):null,gt=L(d,Ie[Ce]),ct=L(w,Le[Ce]);V.set(Ce,[Ue,xe[Ce]>=0?m(Ue,gt,ct):gt||ct])}let q=new Set([...V.values()].map(Ce=>Ce[1])),Z=Ce=>Ce!==xt&&Ce!==Vn&&!/\s/.test(Ce),pe=(Ce,Ue)=>{let gt=Ce;for(;gt<Ue&&!Z(ne[gt]);)gt++;return gt<Ue&&xe[gt]>=0?L(g,xe[gt]):null},we=new Map,Te=0;for(let Ce=0;Ce<$e;Ce++){if(ne[Ce]!==xt)continue;let[Ue,gt]=V.get(Ce),ct=pe(Te,Ce),dt=gt,Ht=we.get(dt)===dt&&ct===dt;dt&&we.has(dt)&&!Ht&&Ue&&!we.has(Ue)&&!q.has(Ue)&&(dt=Ue),dt&&!we.has(dt)&&we.set(dt,ct);for(let jt=Te;jt<=Ce;jt++)ce[jt]=dt;Te=Ce+1}let De=Ce=>{for(let Ue=0;Ue<Ce.text.length;Ue++)if(Z(Ce.text[Ue])&&!L(Ce,Ue))return!0;return!1};if(!De(g)&&!De(d)&&!De(w)){let Ce=[],Ue=0;for(let ct=0;ct<$e;ct++)(ne[ct]===xt||ct===$e-1)&&(Ce.push([Ue,ct]),Ue=ct+1);let gt=new Set(ce);for(let ct=0;ct<Ce.length;ct++){let[dt,Ht]=Ce[ct];if(ce[Ht])continue;let jt=dt;for(;jt<=Ht&&!Z(ne[jt]);)jt++;if(jt>Ht)continue;let gn=L(g,xe[jt]),cn=L(d,Ie[jt]),xn=L(w,Le[jt]),vn=m(gn,cn,xn)||cn||xn||gn;if(vn&&!gt.has(vn)){gt.add(vn);for(let en=dt;en<=Ht;en++)ce[en]=vn;continue}let Hn=ct>0&&ce[Ce[ct-1][1]],Wn=ct+1<Ce.length&&ce[Ce[ct+1][1]];if(Hn)re.add(Ce[ct-1][1]);else if(Wn&&ne[Ht]===xt)re.add(Ht);else continue;for(let en=dt;en<=Ht;en++)ce[en]=Hn||Wn}}}let Oe=new Map,Pe=m=>{let L=Oe.get(m);if(L)return L;L=[1/0,-1/0];for(let[V,q]of[[m.baseMark,Je],[m.localMark,Qe],[m.remoteMark,Ut]]){let Z=V&&Pt(V,q);Z&&(L[0]=Math.min(L[0],Z[0]),L[1]=Math.max(L[1],Z[1]))}return Oe.set(m,L),L},We=(m,L,V)=>{let q=-1,Z=-1;for(let pe=0;pe<m.length;pe++){let we=ht.get(m[pe].el);we===L&&(q=pe),we===V&&(Z=pe)}return q>=0&&Z>=0?q-Z:0},qe=(m,L)=>[...m].sort((V,q)=>{for(let we of L){let Te=We(we,V,q);if(Te)return Te}let Z=Pe(V),pe=Pe(q);return Z[0]-pe[0]||pe[1]-Z[1]||V.rank-q.rank||V.id-q.id}),pt=new Map,tt=new Map,qt=e.nativeTransfers?[]:null,Wt=m=>{if(qt)return qt;let L=xe[m],V=Ie[m],q=Le[m],Z=ke[m];if(L>=0){let ct=g.stackAt[L],dt=d.stackAt[V],Ht=w.stackAt[q],jt=pt.get(ct);jt||pt.set(ct,jt=new Map);let gn=jt.get(dt);gn||jt.set(dt,gn=new Map);let cn=gn.get(Ht);if(cn)return cn;let xn=Ct(ct),vn=Ct(dt),Hn=Ct(Ht),Wn=new Set;for(let en of new Set([...xn,...vn,...Hn])){let ao=xn.has(en),fo=vn.has(en),$t=Hn.has(en);(fo===$t?fo:fo===ao?$t:fo)&&Wn.add(en)}return cn=qe(Wn,[dt,Ht,ct]),gn.set(Ht,cn),cn}if(Z.src==="both"){let ct=d.stackAt[V],dt=w.stackAt[q];return qe(new Set([...Ct(ct),...Ct(dt)]),[ct,dt])}let we=(Z.src==="local"?d:w).stackAt[Z.src==="local"?V:q];if(!Z.inherit)return qe(Ct(we),[we]);let Te=tt.get(Z);Te||tt.set(Z,Te=new Map);let De=Te.get(we);if(De)return De;let Ce=new Set(Ct(we));for(let ct of Z.inherit.added)Ce.add(It(ct));for(let ct of Z.inherit.removed)Ce.delete(It(ct));let Ue=Z.src==="local"?w:d,gt=(Z.src==="local"?Ae.bTo:ae.bTo)[Z.inherit.bs];return De=qe(Ce,[we,Ue.stackAt[gt]]),Te.set(we,De),De},dn=new Int32Array(d.text.length+1);dn[d.text.length]=$e;for(let m=d.text.length-1;m>=0;m--)dn[m]=Qe[m]>=0?Qe[m]:dn[m+1];oa.caret+=d.text.length;let bt=m=>m<=0?0:(m>d.text.length&&(m=d.text.length),Qe[m-1]>=0?Qe[m-1]+1:dn[m]),lt=[],ze=[],At=null,at=[],Dt="",yn=-1,on=m=>{At?At.appendChild(m):lt.push(m)},pn=m=>{if(!Dt)return;let L=t.createTextNode(Dt);on(L),ze.push({node:L,ms:yn,me:m,local:[],u:at.length?at[at.length-1].u:null}),Dt=""},Yt=new Set,Dn=new Map,ko=new Set,Bn=m=>{let L=t.createElement(m.tag);if(m.block&&Sn.add(L),!Dn.has(m)){Dn.set(m,L),M(m.base,m.local,m.remote,L),c.set(L,{base:m.base,local:m.local,remote:m.remote});let q=(we,Te)=>y&&m[Te]&&we.reverse.get(m[Te])?Te:null,Z=!m.base&&(q(o,"local")||q(r,"remote"));if(Z){let we=Z==="local"?o.reverse.get(m.local):r.reverse.get(m.remote),Te=c.get(L);Te.local=Te.local||o.map.get(we)||null,Te.remote=Te.remote||r.map.get(we)||null,i.push({kind:"move",el:L,source:Z}),e.moveBuilt?.(we,Z,m[Z],L)}else m.base||i.push({kind:"insert",el:L,source:m.local&&m.remote?"both":m.local?"local":"remote"});let pe=c.get(L);pe.local&&(ko.has(pe.local)?pe.local=null:ko.add(pe.local))}else{let q=Dn.get(m);for(let Z of q.attributes)Z.name!=="id"&&Z.name!=="data-id"&&v(L,Z,Z.value);c.set(L,{base:null,local:null,remote:null})}on(L),at.push({u:m,el:L}),At=L},Vo=new Set,Zn=new Map;for(let m of d.pins){let L=bt(m.i);Zn.has(L)||Zn.set(L,[]),Zn.get(L).push(m)}let br=m=>{let L=Zn.get(m);if(L){pn(m);for(let V of L){let q=V.el.namespaceURI&&V.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(V.el.namespaceURI,V.el.tagName):t.createElement(V.el.tagName);c.set(q,{base:null,local:V.el,remote:null,pinned:!0}),Vo.add(q),on(q)}}},qr=g.atoms.length||d.atoms.length||w.atoms.length,yr=m=>{if(!qr)return null;let L=xe[m]>=0?g.atomAt.get(xe[m]):null,V=Ie[m]>=0?d.atomAt.get(Ie[m]):null,q=Le[m]>=0?w.atomAt.get(Le[m]):null;return L||V||q?{ab:L,al:V,ar:q}:null},Qn=(m,L,V)=>{let q=e.idOf;if(!q||!q.base)return!1;let Z=q.base(m.el);return Z!=null&&Z===q[V](L.el)},qo=(m,L,V,q,Z)=>{if(!m||!y)return null;let pe=O.get(L.reverse.get(m.el))||null;return!pe||pe===q||(q?pe.el.isEqualNode(q.el)&&!Qn(pe,m,Z):V.bTo[pe.i]>=0)?null:pe},To=(m,L)=>{if(!m||!y||!e.moveIn)return null;let V=L.reverse.get(m.el);return V&&!O.has(V)?V:null},Fo=(m,L)=>{let V=new Map;for(let q of m.atoms)V.set(L(q),(V.get(L(q))||0)+1);return V},fe=Fo(g,B),_e=Fo(d,k),He=Fo(w,T),et=m=>{let L=B(m);return fe.get(L)===1&&(_e.get(L)||0)<=1&&(He.get(L)||0)<=1},wt=new Map,Fe=new Set,Ke=new Set,kt=new Set,Xe=null;for(let m=0;m<$e;m++){let L=yr(m);if(!L)continue;let{ab:V,al:q,ar:Z}=L,pe=qo(Z,r,Ae,V,"remote"),we=qo(q,o,ae,V,"local"),Te=V,De=null;if(pe?(Te=pe,De="remote"):we&&(Te=we,De="local"),Te){V&&Te!==V&&(Xe||=new Map).set(V,De),Fe.has(Te)?wt.set(m,{dup:Te.el}):(Fe.add(Te),wt.set(m,{bk:Te,from:De,al:q,ar:Z}));continue}let Ce=To(Z,r),Ue=To(q,o),gt=Ce||Ue;if(gt){Ke.has(gt)?wt.set(m,{dup:gt}):(Ke.add(gt),wt.set(m,{moveIn:gt,side:Ce?"remote":"local",sideEl:Ce?Z.el:q.el}));continue}let ct=(Ht,jt)=>Ht&&y&&O.get(jt.reverse.get(Ht.el))||null,dt=ct(Z,r)||ct(q,o);if(dt&&(kt.add(dt),ke[m].conflict&&(et(dt)||Z&&(Z.el===dt.el||r.identityPaired?.has(dt.el))&&Qn(dt,Z,"remote")||q&&(q.el===dt.el||o.identityPaired?.has(dt.el))&&Qn(dt,q,"local")))){if(Fe.has(dt)){wt.set(m,{dup:dt.el});continue}Fe.add(dt)}wt.set(m,{al:q,ar:Z})}let rt=new Map,ft,_t,Ot=(m,L)=>{if(m[L]>=0)return m[L];for(let V=L-1;V>=0;V--)if(m[V]>=0)return m[V]+1;return 0};if(y)for(let m of g.atoms){if(Fe.has(m)||kt.has(m))continue;let L=o.map.get(m.el)||null,V=r.map.get(m.el)||null,q=L&&N.get(L),Z=V&&Y.get(V);if(L&&!q||V&&!Z)continue;let pe=!(q&&Z)&&Se.has(m);if(!pe&&!(q&&Z&&(et(m)||Xe?.has(m)||(q.el===m.el||o.identityPaired?.has(m.el))&&(Z.el===m.el||r.identityPaired?.has(m.el))&&Qn(m,q,"local")&&Qn(m,Z,"remote"))))continue;let we=Xe?.get(m),Te=n;if(we){let ct=we==="local"?w:d,dt=we==="local"?r:o,Ht=we==="local"?_t:ft;if(Ht===void 0){Ht=ct.atoms.length===g.atoms.length;for(let jt=0;Ht&&jt<g.atoms.length;jt++)Ht=dt.reverse.get(ct.atoms[jt].el)===g.atoms[jt].el;we==="local"?_t=Ht:ft=Ht}Ht&&(Te=we)}let De=Te==="local"?[[q,Qe],[Z,Ut]]:[[Z,Ut],[q,Qe]],[Ce,Ue]=De.find(([ct])=>ct),gt=Ot(Ue,Ce.i);rt.has(gt)||rt.set(gt,[]),rt.get(gt).push({a:m,lt:L,rt:V,edited:pe}),Fe.add(m)}if(y&&e.moveIn){let m=[[d,o,Qe,"local"],[w,r,Ut,"remote"]];n!=="local"&&m.reverse();for(let[L,V,q,Z]of m)for(let pe of L.atoms){let we=To(pe,V);if(!we||Ke.has(we))continue;Ke.add(we);let Te=Ot(q,pe.i);rt.has(Te)||rt.set(Te,[]),rt.get(Te).push({move:we,side:Z,sideEl:pe.el})}}let Zt=m=>{let L=rt.get(m);if(L){if(pn(m),L.some(V=>Be(V.move?V.sideEl:V.a.el)))for(;at.length;)at.pop(),At=at.length?at[at.length-1].el:null;for(let{a:V,lt:q,rt:Z,edited:pe,move:we,side:Te,sideEl:De}of L){if(we){let Ue=e.moveIn(we,Te,De);Ue&&on(Ue);continue}Yt.add(V);let Ce=P(V.el,q,Z);pe&&(p({kind:"structure",el:Ce,detail:"edit-beats-delete",base:V.el},{subject:V.el,deleted:q?"remote":"local"}),i.push({kind:"insert",el:Ce,source:q?"local":"remote"})),on(Ce)}}},Sn=new Set,eo=l.length>a;for(let m=0;m<$e;m++){let L=yr(m),V=e.scopeUnits&&L&&(L.ab?.stack.some(we=>we.block)||L.al?.stack.some(we=>we.block)||L.ar?.stack.some(we=>we.block)),Z=!!L&&Be((L.ab||L.al||L.ar).el)&&!V?[]:ce[m]?[ce[m],...Wt(m)]:Wt(m),pe=0;for(;pe<at.length&&pe<Z.length&&at[pe].u===Z[pe];)pe++;if(pe<at.length)for(pn(m);at.length>pe;)at.pop(),At=at.length?at[at.length-1].el:null;if(br(m),Zt(m),Z.length>at.length)for(pn(m);at.length<Z.length;)Bn(Z[at.length]);if(ne[m]===xt){if(re.has(m))continue;pn(m);let we=at.length;for(;we>0&&!at[we-1].u.block;)we--;if(we>0)for(eo&&f.breakOut.set(m,at[we-1].el);at.length>=we;)at.pop(),At=at.length?at[at.length-1].el:null;continue}if(L){pn(m);let we=wt.get(m),Te;if(we.dup){p({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 De=we.bk;if(Yt.add(De),De===L.ab)Te=P(De.el,we.al.el,we.ar.el);else{let Ce=o.map.get(De.el)||null,Ue=r.map.get(De.el)||null;Te=P(De.el,Ce,Ue),(!Ce||!Ue)&&p({kind:"structure",el:null,detail:"move-beats-delete",base:De.el},{subject:De.el,deleted:Ce?"remote":"local"}),i.push({kind:"move",el:Te,source:we.from})}}else we.al?(Te=D(we.al.el,"local"),we.ar&&(c.get(Te).remote=we.ar.el),i.push({kind:"insert",el:Te,source:we.ar?"both":"local"})):(Te=D(we.ar.el,"remote"),i.push({kind:"insert",el:Te,source:"remote"}));eo&&f.atomOut.set(m,Te),on(Te);continue}Dt||(yn=m),Dt+=ne[m]}if(pn($e),(Zn.has($e)||rt.has($e))&&(at.length=0,At=null,br($e),Zt($e)),$e===0&&(d.placeholder||w.placeholder||g.placeholder)){let m=t.createElement("br");c.set(m,{base:g.placeholder,local:d.placeholder,remote:w.placeholder}),lt.push(m)}let Un=0,ut=m=>{for(;Un>0&&ze[Un-1].me>=m;)Un--;for(;Un<ze.length&&ze[Un].me<m;)Un++;let L=ze[Un];if(!L)return ze[ze.length-1]||null;let V=ze[Un+1];return L.me===m&&V&&V.ms===m?V:L},Ze=new Map,Rt={},ot=(m,L,V)=>{let q=ut(m)||(V?Rt:null);if(!q)return;let Z=Ze.get(q)||{l:!1,r:!1};L!=="remote"&&(Z.l=!0),L!=="local"&&(Z.r=!0),Ze.set(q,Z)},vt=m=>{if(m.conflict)return!0;let L=m.src==="local"?d.text:m.src==="remote"?w.text:"";for(let V=m.from;V<m.to;V++)if(L[V]!==Vn&&L[V]!==xt)return!0;return!1};for(let m of j)m.src!=="base"&&ot(m.ms,m.conflict?"both":m.src,vt(m));for(let[m,L]of K)Je[m]>=0&&ot(Je[m],L);for(let m of ze.length?ze:[Rt]){let L=Ze.get(m);L&&i.push({kind:"text",node:m.node||null,source:L.l&&L.r?"both":L.l?"local":"remote"})}for(let m of Ge){if(Dn.has(m))continue;let L=!m.local&&!(y&&o.map.get(m.base)),V=!m.remote&&!(y&&r.map.get(m.base));!L&&!V||i.push({kind:"remove",source:L&&V?"both":L?"local":"remote",base:m.base})}if(be)for(let[m,L]of be)Dn.has(m)&&p({kind:"structure",el:Dn.get(m),detail:"edit-beats-delete",base:m.base},{subject:m.base,deleted:L});let Jt=(m,L,V)=>{if(L<=m)return!1;for(let q=m;q<L;q++)if(V[q]>=0)return!1;return!0};for(let m of Ge)for(let L of["local","remote"]){let V=m[L+"Mark"],q=m.baseMark;if(!V)continue;let Z=L==="local"?ae:Ae;if(!Jt(q.from,q.to,Z.bTo)||!Jt(V.from,V.to,Z.toB))continue;let pe=(L==="local"?ie:Ne).find(we=>we.ss<=V.from&&V.from<we.se);pe&&(pe.be<=q.from||pe.bs>=q.to)&&i.push({kind:"move",el:Dn.get(m)||null,source:L})}let Lt=m=>{let L=ht.get(m.node.parentNode);return L?It(L):null};for(let m of d.nodes){let L=-1;for(let q=m.s;q<m.e;q++)if(Qe[q]>=0){L=Qe[q];break}let V;if(L>=0)V=ut(L);else{let q=bt(m.s),Z=Lt(m);V=ze.find(pe=>pe.u===Z&&pe.me>=q)||ze.filter(pe=>pe.u===Z).pop()}V&&V.local.push(m)}let Ft=new Map,tn=ze[ze.length-1]||null,Tt=0;for(let m of d.nodes){let L=null;for(let V=m.s;V<=m.e;V++){let q=bt(V);for(;Tt>0&&ze[Tt-1].me>=q;)Tt--;for(;Tt<ze.length&&ze[Tt].me<q;)Tt++;let Z=we=>we&&q>=we.ms&&q<=we.me&&(q<we.me||V===m.e||we===L),pe=Z(ze[Tt])?ze[Tt]:Z(ze[Tt+1])?ze[Tt+1]:ze[Tt]||tn;if(!pe)break;if(L===pe){let we=Ft.get(pe);we[we.length-1].to=V-m.s;continue}L=pe,Ft.has(pe)||Ft.set(pe,[]),Ft.get(pe).push({node:m.node,from:V-m.s,to:V-m.s,flatStart:m.s})}}for(let m of ze){let L=m.local,V=!1;for(let we of L)for(let Te=we.s;Te<we.e&&!V;Te++)(Qe[Te]<m.ms||Qe[Te]>=m.me)&&(V=!0);c.set(m.node,{base:null,local:L.map(we=>we.node),remote:null,caret:Ft.get(m)||[],partial:V});let q=m.ms,Z=m.me-m.ms,pe=we=>{let Te=0,De=-1;for(let Ce of L){let Ue=Ce.e-Ce.s;if(we<=Te+Ue){De=Ce.s+(we-Te);break}Te+=Ue}return De<0&&(De=L.length?L[L.length-1].e:0),Math.max(0,Math.min(bt(De)-q,Z))};pe.flat=we=>Math.max(0,Math.min(bt(we)-q,Z)),s.set(m.node,pe)}function mt(){if(!d.text.includes(xt))return[{flatLocal:d.text,localNodes:d.nodes,textNodes:ze,lToM:Qe,mapLocal:bt}];let m=[],L=0,V=0;for(let q=0;q<=d.text.length;q++){if(q<d.text.length&&d.text[q]!==xt)continue;let Z=L,pe=q;if(pe>Z){let we=[];for(;V<d.nodes.length&&d.nodes[V].e<=Z;)V++;for(let Te=V;Te<d.nodes.length&&d.nodes[Te].s<pe;Te++){let De=d.nodes[Te],Ce=Math.max(De.s,Z),Ue=Math.min(De.e,pe);Ce<Ue&&we.push({node:De.node,s:Ce-Z,e:Ue-Z})}m.push({flatLocal:d.text.slice(Z,pe),localNodes:we,textNodes:ze,lToM:Qe.subarray?Qe.subarray(Z,pe+1):Qe.slice(Z,pe+1),mapLocal:Te=>bt(Z+Math.max(0,Math.min(Te,pe-Z)))})}L=q+1}return m}let St={...e,blocks:Sn,ignored:m=>Vo.has(m)||(e.ignored?e.ignored(m):!1)},Qt=e.ignoreAttribute||(()=>!1),to=Ei(nn(lt,St),Qt)!==Ei(w,Qt);if(u.length){let m=L=>{let V=c.get(L);return V&&V.unchanged?V.remote:null};f.text=ne,f.textNodes=ze,f.out=nn(lt,{...St,via:m})}let Nn=null;if(e.scopeUnits){Nn=new Map;let m=new Set(lt),L=Te=>{for(;Te&&!m.has(Te);)Te=Te.parentNode;return Te},V=e.scopeUnits.map(Te=>{let De=new Map;for(let Ce of Te)if(Ce.nodeType===1)De.set(Ce,Ce);else for(let Ue of Ce.nodes)De.set(Ue,Ce);return De}),q=(Te,De)=>{for(;Te&&!De.has(Te);)Te=Te.parentNode;return Te?De.get(Te):null},Z=[g,d,w].map((Te,De)=>{let Ce=new Array(Te.text.length);for(let Ue of Te.nodes){let gt=q(Ue.node,V[De]);gt&&Ce.fill(gt,Ue.s,Ue.e)}for(let Ue of Te.atoms)Ce[Ue.i]=q(Ue.el,V[De]);return Ce}),pe=(Te,De)=>{if(!Te||!De)return;let Ce=Nn.get(Te);Ce||Nn.set(Te,Ce=new Set),Ce.add(De)};for(let Te of lt){let De=c.get(Te);De&&(pe(q(De.base,V[0]),Te),pe(q(De.local,V[1]),Te),pe(q(De.remote,V[2]),Te))}for(let Te of ze){let De=L(Te.node);for(let Ce=Te.ms;Ce<Te.me;Ce++)pe(Z[0][xe[Ce]],De),pe(Z[1][Ie[Ce]],De),pe(Z[2][Le[Ce]],De)}let we=new Map(lt.map((Te,De)=>[Te,De]));for(let[Te,De]of Nn)Nn.set(Te,Array.from(De).sort((Ce,Ue)=>we.get(Ce)-we.get(Ue)))}return{unitOutputs:Nn,nodes:lt,text:ne,textNodes:ze,localDiverged:to,mapLocal:bt,conflicts:l.slice(a),granularity:F?"line":"word",segments:mt(),localHunks:ie,remoteHunks:Ne,lToM:Qe}}var ws=Symbol("lost");function Wi(){return{links:new Map,removed:new Set,consumed:new Set,link(e,t){this.links.set(e,t)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let t of e.nodes)this.removed.add(t)},consume(e){for(let t of e)this.consumed.add(t)}}}var Hi=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function _i({locals:e,rec:t,root:n,provenance:o,segments:r,ignored:c}){let s=new Map,l=(x,A)=>{let v=s.get(x);v||s.set(x,v=new Set),v.add(A)},i=new Set,a=new Set;for(let x of r){let A=x.textNodes;for(let v of A)i.add(v.node);for(let v of x.localNodes){a.add(v.node);let I=0,M=null;for(let P=v.s;P<v.e;P++){let D=x.lToM[P];if(D<0)continue;for((!A[I]||D<A[I].ms)&&(I=0);I<A.length&&A[I].me<=D;)I++;let $=A[I]&&A[I].ms<=D?A[I].node:ws;$!==M&&l(v.node,$),M=$}}}let p=new Set,f=new Map,u=new Set;(function x(A){p.add(A);let v=o.get(A);if(A.nodeType===1)v&&v.local&&v.local.nodeType===1&&(l(v.local,A),v.unchanged&&u.add(v.local)),A.tagName==="TEMPLATE"&&A.content&&f.set(A.content,A);else if(v&&Array.isArray(v.local)&&!i.has(A))for(let I of v.local)l(I,A);for(let I=Hi(A).firstChild;I;I=I.nextSibling)x(I)})(n);let y=new Set;for(let[x,A]of t.links)l(x,A),y.add(x);let b=x=>{let A=x.parentNode;return A&&A.nodeType===11?f.get(A)||null:A},S=(x,A)=>{for(let v=x;v;v=b(v))if(v===A)return!0;return!1},g=x=>t.removed.has(x)||t.consumed.has(x),d=x=>{for(let A=x.parentNode;A&&A.nodeType===1;A=A.parentNode){if(u.has(A))return"kept";if(g(A))return"decided";if(s.has(A))return null}return null},w=new Map;for(let x of e)w.set(x,O(x));return w;function O(x){let A=s.get(x);if(A&&(A.size!==1||A.has(ws)))return{kind:"unknown",reason:"several-outputs"};let v=A?A.values().next().value:null;if(v&&(v.nodeType!==1||!p.has(v)))return{kind:"unknown",reason:"output-not-placed"};if(!v){let D=g(x)?"decided":d(x);if(D==="kept")return{kind:"untouched"};if(D!=="decided")return{kind:"unknown",reason:"unmapped"}}let I=[],M=P(x,!!v&&(u.has(x)||y.has(x)),!v||g(x));if(M)return{kind:"unknown",reason:M};return v?{kind:"single",output:v,owned:I,carried:y.has(x)}:{kind:"removed"};function P(D,$,W){for(let B=Hi(D).firstChild;B;B=B.nextSibling){if(B.nodeType===1?c(B):B.nodeType!==3&&B.nodeType!==8)continue;let k=s.get(B);if(k)for(let T of k){if(T===ws||!p.has(T))return"output-not-placed";if(!v)return"survives-elsewhere";if(!S(T,v))return"escaped";I.push(T)}else if(!$&&!W&&!g(B)&&!a.has(B))return"unmapped";if(B.nodeType===1){let T=P(B,$||u.has(B)||y.has(B),W||g(B));if(T)return T}}return null}}}function Vi(e,t){if(!t)return!1;let n=t.nodeType===1&&t.tagName==="TEMPLATE"?[t,...t.querySelectorAll("template")]:[...t.querySelectorAll("template")];for(let o of n)if(o.content.contains(e)||Vi(e,o.content))return!0;return!1}function qi(e,t){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let n=[],o=new Set;for(let r of Array.from(e.elements)){if(!r||r.nodeType!==1||r.ownerDocument!==t&&!Vi(r,t.documentElement))throw new TypeError("lineage.elements must be elements of the live document");o.has(r)||(o.add(r),n.push(r))}return n}var Fi=new WeakMap;function $i(e){let t=new Map;for(let n of e){let o=[],r=!1;(function c(s){s.nodeType===1&&s.namespaceURI==="http://www.w3.org/1999/xhtml"&&s.localName==="template"&&(r=!0);for(let l=s.firstChild;l;l=l.nextSibling)o.push(l),l.nodeType===1&&c(l)})(n),t.set(n,{nodes:o,opaque:r})}return t}function xs(e,t,n){if(e.lineage===void 0)return n(e);if(!t||t.nodeType!==1)throw new TypeError("lineage requires an element root");let o=e.lineage,r=qi(o,t.ownerDocument),c=!1,s={...e,lineage:{elements:r,onResult(l,i){if(!c)return c=!0,o.onResult(l,i)}}};try{return Fi.set(s.lineage,$i(r)),n(s)}catch(l){if(!c){c=!0;try{o.onResult({version:1,root:t,status:"incomplete",entries:r.map(En)},null)}catch{}}throw l}}function ks(e,{liveRoot:t,localRoot:n,toLive:o}){let r=qi(e,t.ownerDocument),c=a=>a===t||t.contains(a),s=new Map,l=new Set(r.filter(c));if(l.size&&n===t)for(let a of l)s.set(a,a);else l.size&&function a(p){let f=o(p);l.delete(f)&&s.set(f,p);for(let u=p.firstElementChild;u&&l.size;u=u.nextElementSibling)a(u)}(n);return{spec:e,watched:r,root:t,locals:Array.from(new Set(s.values())),before:Fi.get(e)||$i(r),delivered:!1,result:null,finish(a,p){return this.resolve=p,this.plans=a,this.result={version:1,root:this.root,status:"complete",entries:r.map(f=>aa(f,s.get(f),a,p,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(a,p){this.root=p;let f=this.resolve,u=b=>{let S=f(b);return S===a?p:S};return this.finish(this.plans,u)},deliver(a){this.delivered||(this.delivered=!0,e.onResult(this.result,a))}}}var En=e=>({from:e,to:[],kind:"unknown",complete:!1});function aa(e,t,n,o,r){let c=r.root,s=u=>!!u&&(u===c||c.contains(u)),l=t&&n?n.get(t):null;if(!l||l.kind==="unknown")return En(e);let i=r.before.get(e);if(!i||i.opaque)return En(e);let a=i.nodes,p=u=>s(u)||!!(u&&u.ownerDocument===c.ownerDocument&&c.ownerDocument.documentElement?.contains(u));if(l.kind==="untouched"){if(!s(e))return En(e);for(let u of a)if(p(u)&&!e.contains(u))return En(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(l.kind==="removed")return p(e)||a.some(p)?En(e):{from:e,to:[],kind:"removed",complete:!0};let f=o(l.output);if(!f||f.nodeType!==1||!s(f)||f!==e&&p(e))return En(e);for(let u of a)if(p(u)&&!f.contains(u))return En(e);for(let u of l.owned){let y=o(u),b=Array.isArray(y)?y:[y];for(let S of b)if(!S||!s(S)||!f.contains(S))return En(e)}return l.carried&&!Ki(f,l.output,o)?En(e):{from:e,to:[f],kind:f===e?"retained":"replaced",complete:!0}}function Ki(e,t,n){for(let o=t.firstChild;o;o=o.nextSibling){let r=n(o),c=Array.isArray(r)?r:[r];for(let s of c)if(!s||!e.contains(s))return!1;if(o.nodeType===1&&!Ki(e,o,n))return!1}return!0}function Yo(e,t,n){let o=ks(e,{liveRoot:t,localRoot:t,toLive:r=>r});return o.result={version:1,root:t,status:"complete",entries:o.watched.map(r=>En(r))},n.lineage=o.result,o}function zi(e,t,n,o,r){if(!r(e.length*8+1))return null;let c=0,s=t===0,l=!1;for(let i of an(e,o)){if(!r(1))return null;if(c+=i.len,c===t&&(s=!0),c===n&&(l=!0),c>=n)break}return s&&l}function fa(e,t,n,o,r,c,s){if(!s(t.length*2))return!1;let l=new Map,i=new Map,a=new Set;for(let p of t){let f=p.bs<p.be,u=f?n[p.ownerIndex].text.base:n[p.ownerIndex].text[e],y=f?p.bs:p.ss,b=f?p.be:p.se;if(!s((b-y)*4+1))return!1;for(;y<b&&/\s/.test(u[y]);)y++;for(;b>y&&/\s/.test(u[b-1]);)b--;if(y===b)continue;let S=u.slice(y,b),g=f?l:i;f&&p.text&&a.add(S),g.has(S)?g.set(S,null):g.set(S,{h:p,from:y,to:b})}for(let p of o){if(!s(1))return!1;if(p.side!==e)continue;let f=p.deletion,u=n[f.ownerIndex].text.base;if(!s((f.be-f.bs)*3)||a.has(u.slice(f.bs,f.be).trim()))return!1}for(let[p,f]of l){if(!s(p.length+1))return!1;let u=i.get(p);if(!f||!u)continue;let y=f.h,b=u.h;if(!y.text||y.transferOut||b.transferIn||y.owner===b.owner)continue;let S=n[y.ownerIndex],g=n[b.ownerIndex];if(!s(S.text.base.length))return!1;if(!/\S/.test(S.text.base.slice(0,y.bs)+S.text.base.slice(y.be)))continue;let d=zi(S.text.base,f.from,f.to,c,s),w=zi(g.text[e],u.from,u.to,c,s);if(d===null||w===null)return!1;if(!d||!w)continue;let O=`${S.index}:${f.from}:${f.to}`,x={key:O,side:e,source:y.owner,destination:b.owner,deletion:y,insertion:b,sourceOffset:f.from-y.bs,targetOffset:u.from-b.ss,length:f.to-f.from};y.transferOut=x,b.transferIn=x,r[e].set(O,x),o.push(x)}return!0}function Gi({base:e,local:t,remote:n,localTwin:o,remoteTwin:r,eligible:c,nodes:s,budget:l=zt(2e4*32)}){let i=M=>M>l.remaining?!1:(l.remaining-=M,l.nativeSteps=(l.nativeSteps||0)+M,!0);if(e.length<2||t.length!==e.length||n.length!==e.length||!i(e.length*12))return null;for(let[M,P]of[["base",e],["local",t],["remote",n]]){let D=s[M];if(D.length!==P.length||D.some(($,W)=>$!==P[W]))return null}let a=[],p=0;for(let M=0;M<e.length;M++){let P=e[M],D=t[M],$=n[M];if(o(P)!==D||r(P)!==$)return null;let W={};for(let[B,k]of[["base",P],["local",D],["remote",$]]){if(!c(k)||k.tagName!==P.tagName||k.namespaceURI!==P.namespaceURI||!i(k.childNodes.length+1))return null;let T="";for(let J of k.childNodes){if(J.nodeType!==3||!i(J.data.length*4+1))return null;T+=J.data}if(T.includes(xt)||(p+=T.length+1,p>2e4))return null;W[B]=T}a.push({base:P,local:D,remote:$,index:M,text:W})}let f=a.every(M=>Tn(M.text.base,M.text.local,M.text.remote)),u={local:[],remote:[]};for(let M of a){M.hunks={local:[],remote:[]};for(let P of["local","remote"]){let D=M.text.base,$=M.text[P];if(D===$)continue;let W=D.length+$.length+4,B=W*8;if(!i(B))return null;let k=Math.floor(l.remaining/8),T=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(W*W+k)-W)/2)));if(T<1||!i(4*(T+1)*(W+T+1)))return null;let J=0;for(let H of uo(D,$,T)){if(!i(H.text.length+1))return null;let F=H.bs+J,Ee={...H,ss:F,se:F+H.text.length,toks:an(H.text,f),owner:M.base,ownerIndex:M.index};M.hunks[P].push(Ee),u[P].push(Ee),J+=H.text.length-(H.be-H.bs)}}}let y=[],b={local:new Map,remote:new Map};for(let M of["local","remote"]){let P=new Map,D=new Map,$=!1,W=(B,k,T)=>{B.has(k)?B.set(k,null):B.set(k,T)};for(let B of u[M]){if(!i(1))return null;let k=a[B.ownerIndex].text.base;if(B.bs<B.be&&B.text===""){let T=k.slice(B.bs,B.be);if(!i(T.length*2))return null;/\S/.test(T)&&W(P,T,B)}else if(B.bs===B.be&&/\S/.test(B.text)){if(!i(B.text.length*2))return null;W(D,B.text,B)}else B.bs<B.be&&($=!0)}for(let[B,k]of P){if(!i(B.length+1))return null;let T=D.get(B);if(!k||!T||k.owner===T.owner)continue;let J=a[k.ownerIndex];if(!i(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,k.bs)+J.text.base.slice(k.be)))continue;let H=`${J.index}:${k.bs}:${k.be}`,F={key:H,side:M,source:k.owner,destination:T.owner,deletion:k,insertion:T};k.transferOut=F,T.transferIn=F,b[M].set(H,F),y.push(F)}if($&&D.size&&!fa(M,u[M],a,y,b,f,i))return null}if(!y.length)return null;let S=(M,P)=>M.bs<P.be&&P.bs<M.be,g=M=>M.bs===M.be,d=(M,P)=>M.bs<=P.be&&P.bs<=M.be&&g(M)!==g(P),w=(M,P)=>M.bs===P.bs&&M.be===P.be&&M.text===P.text,O=(M,P)=>!!(M.transferIn||M.transferOut&&(!M.text||P.bs===M.be&&/\s/.test(P.text[0])||P.bs===M.bs&&/\s/.test(P.text[P.text.length-1])));for(let M of y){let P=M.side==="local"?"remote":"local",D=a[M.deletion.ownerIndex];for(let $ of D.hunks[P])if(!i(1)||S(M.deletion,$)&&$.transferOut?.key!==M.key)return null}for(let M of a)for(let P of M.hunks.local)for(let D of M.hunks.remote){if(!i(1))return null;if(w(P,D)){if(P.transferIn?.key!==D.transferIn?.key)return null;continue}if(S(P,D)||d(P,D)&&!O(P,D)&&!O(D,P))return null}if(!i(p*8))return null;let x=new Set([...e,...t,...n]),A={base:nn(e,{blocks:x}),local:nn(t,{blocks:x}),remote:nn(n,{blocks:x})},v={};for(let M of["base","local","remote"]){let P=A[M];if(P.atoms.length||P.pins.length)return null;v[M]=new Map(P.marks.filter(D=>D.block).map(D=>[D.el,D.from]))}for(let M of a){let P=v.base.get(M.base);if(P===void 0)return null;for(let D of["local","remote"]){let $=v[D].get(M[D]);if($===void 0)return null;for(let W of M.hunks[D])W.bs+=P,W.be+=P,W.ss+=$,W.se+=$}}for(let M of y)M.bs=M.deletion.bs+(M.sourceOffset||0),M.be=M.length===void 0?M.deletion.be:M.bs+M.length,M.ss=M.insertion.ss+(M.targetOffset||0),M.se=M.length===void 0?M.insertion.se:M.ss+M.length;let I={};for(let M of["local","remote"]){let P=0,D=0,$=[];for(let B of u[M]){if(!i(1))return null;B.bs>P&&$.push({from:P,to:B.bs,target:D}),P=B.be,D=B.se}P<A.base.text.length&&$.push({from:P,to:A.base.text.length,target:D});let W=y.filter(B=>B.side===M).map(B=>({from:B.bs,to:B.be,target:B.ss,destination:B.destination}));if(I[M]=_n({base:A.base,side:A[M],retained:$,transfers:W,budget:l}),I[M].status!=="ready")return null}return i(A.base.text.length)?{owners:a,blocks:x,transfers:y,byOrigin:b,budget:l,prepared:{base:A.base,local:A.local,remote:A.remote,lines:!1,baseTokens:an(A.base.text,f),localEdits:{hunks:u.local,respell:new Map},remoteEdits:{hunks:u.remote,respell:new Map},localMap:I.local,remoteMap:I.remote,full:null}}:null}var Ts=/\S/;function Xi({certificates:e,scopes:t,views:n,eligible:o,baseId:r,limit:c=2e4*32}){let s=zt(c),l=Symbol(),i=[],a=f=>{if(f>s.remaining)throw l;s.remaining-=f},p=(f,u=null)=>{if(a(1),!f||f.nodeType!==1||f.parentNode?.nodeType!==1||!o(f))return null;for(let S=f.parentNode;S;S=S.parentNode)if(a(1),S.nodeType===11)return null;let y="",b=0;for(let S of f.childNodes){if(a(1),S.nodeType!==3)return null;if(a(S.data.length*4+1),u){let g=u.flat.nodes[b++];if(!g||g.node!==S||g.s!==y.length||g.e!==y.length+S.data.length)return null}y+=S.data}return a(y.length*3+1),u&&(u.flat.atoms.length||u.flat.pins?.length||b!==u.flat.nodes.length||u.flat.text!==y)?null:Ts.test(y)?y:null};try{a(t[0].length+t[1].length+t[2].length+e.length);let f=t.map(y=>new Set(y)),u=new Map;for(let y of e){a(1);let b=u.get(y.source);b||u.set(y.source,b=[]),b.push(y)}for(let y of u.values()){let b=[null,null],S=[];for(let g of y){a(1);let{source:d,target:w,side:O,models:x,runs:A}=g;if(O!==0&&O!==1||!f[0].has(d)||!f[O+1].has(w))continue;let{V:v,A:I,idOf:M}=n[O],P=n[1-O],D=v.twin(d),$=P.V.twin(d),W=v.baseOf(w);if(!D||!$||!W||W===d||!f[0].has(W)||!f[O+1].has(D)||!f[2-O].has($)||I.map.get(d)!==D||I.reverse.get(D)!==d||P.A.map.get(d)!==$||P.A.reverse.get($)!==d||I.map.get(W)!==w||I.reverse.get(w)!==W||w.parentNode!==D.parentNode||W.parentNode!==d.parentNode||d.tagName!==D.tagName||d.tagName!==$.tagName||r(d)!==M(D)||r(d)!==P.idOf($)||r(W)!==M(w))continue;let B=x.get(d),k=x.get(w);if(!B||!k)continue;let T=p(d,B),J=p(w,k),H=p(D),F=p($);if(a((T?.length||0)+(F?.length||0)),T===null||J===null||H===null||F===null||F===T)continue;let Ee=A.length>0,Me=!1;for(let ae of A){if(a(1),ae.source!==d||ae.target!==w||!Number.isInteger(ae.from)||!Number.isInteger(ae.to)||!Number.isInteger(ae.targetFrom)||ae.from<0||ae.to<=ae.from||ae.to>T.length||ae.targetFrom<0||ae.targetFrom+ae.to-ae.from>J.length){Ee=!1;break}a((ae.to-ae.from)*3);for(let Ae=ae.from;Ae<ae.to;Ae++){if(T[Ae]!==J[ae.targetFrom+Ae-ae.from]){Ee=!1;break}Ts.test(T[Ae])&&(Me=!0)}if(!Ee)break}if(!Ee||!Me)continue;let je=b[O];je||(a(T.length),je=b[O]={source:d,side:O,flat:B.flat,before:T,covered:new Uint8Array(T.length)});for(let ae of A)a(ae.to-ae.from),je.covered.fill(1,ae.from,ae.to)}for(let g of b){if(!g)continue;let{source:d,side:w,flat:O,before:x,covered:A}=g;a(x.length*3+1);let v=-1,I=-1;for(let M=0;M<=x.length;M++)M<x.length&&A[M]?(v<0&&(v=M),I=M+1):(M===x.length||Ts.test(x[M]))&&v>=0&&(S.push({source:d,side:w,flat:O,from:v,to:I}),v=I=-1)}a(S.length),i.push(...S)}}catch(f){if(f!==l)throw f}return{records:i,budget:s}}var ua="http://www.w3.org/1999/xhtml";function da(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 mn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===ua}function ha(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Rr(e,t){let n=e.getAttribute("src"),o=(e.getAttribute("type")||"text/javascript").split(";")[0].trim().toLowerCase();if(n){let r=n;try{let c=new URL(n,t);r=c.origin+c.pathname+c.search}catch{}return"script|src|"+o+"|"+r}return"script|inline|"+o+"|"+da(e.textContent.trim())}var pa={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function Co(e,t=[],n=!1){if(!mn(e)||e.hasAttribute("src"))return null;let o=[pa,...t];for(let r=0;r<o.length;r++){let c=o[r];if(!c.match(e))continue;if(!ha(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let s=c.identity(e);return s==null||s===""?null:{key:r+":"+s,raw:s,recognizer:c}}return null}function Yi(e,t,n){let o=new Set,r=c=>{mn(c)&&!t(c)&&o.add(Rr(c,n))};r(e);for(let c of e.querySelectorAll("script"))r(c);return o}function Jo(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 Ji(e,t,n){let o=[],r=[],c=new Map,s=n.trackRecovery?new Set:null,l=Array.from(e.querySelectorAll("script"));mn(e)&&l.unshift(e);for(let i of l){if(!mn(i)||n.ignored(i)||n.skip.has(i)||t.has(Rr(i,n.baseURI)))continue;let a=i.ownerDocument.createElement("script");for(let p of i.attributes)a.setAttribute(p.name,p.value);if(a.textContent=i.textContent,n.beforeNodeAdded(a)===!1){s?.add(i);continue}a.hasAttribute("src")&&r.push(new Promise(p=>{a.addEventListener("load",()=>p()),a.addEventListener("error",()=>p())})),i.replaceWith(a),c.set(i,a),n.afterNodeAdded(a),o.push(a)}return{executed:o,loads:r,swapped:c,vetoed:s}}function ma(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 ga(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function Zi(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Rr(e,t);if(n==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+ga(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|"+ma(e.textContent):e.outerHTML}function As(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 ba(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var ya=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,wa=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Ss(e){try{return JSON.parse(e)}catch{return JSON.parse(xa(e))}}function xa(e){let t="",n=0,o=(r,c)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${c}`)};for(;n<e.length&&(n=As(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let l=As(e,n+1);if(e[l]==="}"||e[l]==="]"){n++;continue}t+=r,n++;continue}if(r==='"'||r==="'"){let l=n+1;for(;l<e.length&&e[l]!==r;)e[l]==="\\"&&l++,l++;l>=e.length&&o("unterminated string",n);let i=e.slice(n+1,l);r==="'"&&(i=ba(i)),t+='"'+i+'"',n=l+1;continue}let c=n;for(;c<e.length&&/[A-Za-z0-9_$.+\-]/.test(e[c]);)c++;c===n&&o("unexpected character "+JSON.stringify(r),n);let s=e.slice(n,c);if(s==="true"||s==="false"||s==="null"||ya.test(s)){t+=s,n=c;continue}if(wa.test(s)){if(e[As(e,c)]===":"){t+='"'+s+'"',n=c;continue}o("unquoted value "+JSON.stringify(s),n)}o("invalid token "+JSON.stringify(s),n)}return t}var Kt=Symbol("hyper-morph-json-merge:missing"),ka=["id","_id","uuid","key","slug","code","name"];function Ro(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Zo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Ta(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}var Aa=/^[A-Za-z_$][\w$]*$/;function Sa(e,t){return Aa.test(t)?e===""?t:e+"."+t:e+"["+JSON.stringify(t)+"]"}function Na(e,t){return e===""?t:e+"."+t}function Lr(e,t,n,o,r,c){if(e.onConflict){let s=l=>l===Kt?void 0:l;e.onConflict({path:t,base:s(n),local:s(o),remote:s(r),resolved:s(c)})}return c}function Yn(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(!Yn(e[n],t[n]))return!1;return!0}if(Ro(e)&&Ro(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Zo(t,o)||!Yn(e[o],t[o]))return!1;return!0}return!1}function Ns(e,t,n,o,r,c){return Yn(t,n)?t:Yn(t,e)?n:Yn(n,e)?t:Ro(t)&&Ro(n)?va(Ro(e)?e:{},t,n,o,r,c):Array.isArray(t)&&Array.isArray(n)?Ia(e,t,n,o,r,c):Lr(o,r,e,t,n,n)}function Qi(e,t,n,o,r,c){return t===Kt&&n===Kt?Kt:t===Kt?e===Kt?n:Yn(n,e)?Kt:Lr(o,r,e,t,n,n):n===Kt?e===Kt?t:Yn(t,e)?Kt:Lr(o,r,e,t,n,Kt):Ns(e,t,n,o,r,c)}function va(e,t,n,o,r,c){let s={},l=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let i of l){let a=Qi(Zo(e,i)?e[i]:Kt,Zo(t,i)?t[i]:Kt,Zo(n,i)?n[i]:Kt,o,Sa(r,i),Na(c,i));a!==Kt&&Ta(s,i,a)}return s}function Oa(e){return e===null||typeof e!="object"}function Pr(e){return typeof e+":"+String(e)}function Ma(e,t){for(let n of t){let o=new Set;for(let r of n){if(!Zo(r,e))return!1;let c=r[e];if(typeof c!="string"&&typeof c!="number")return!1;let s=Pr(c);if(o.has(s))return!1;o.add(s)}}return!0}function Ea(e,t,n,o,r){let c=[e,t,n],s=!0;for(let l of c)for(let i of l)Ro(i)||(s=!1);if(s){let l=o.keyPaths.get(r),i=l!==void 0?[l]:o.keyCandidates;for(let a of i)if(Ma(a,c))return{kind:"keyed",field:a};return null}for(let l of c){let i=new Set;for(let a of l){if(!Oa(a))return null;let p=Pr(a);if(i.has(p))return null;i.add(p)}}return{kind:"self"}}function Ia(e,t,n,o,r,c){let s=Array.isArray(e)?e:[],l=Ea(s,t,n,o,c),i=Array.isArray(e)&&e.length===t.length&&e.length===n.length;if(!l||l.kind==="self"&&i)return i?t.map((O,x)=>Ns(e[x],O,n[x],o,r+"["+x+"]",c)):Lr(o,r,e,t,n,n);let a=l.kind==="self"?Pr:O=>Pr(O[l.field]),p=O=>l.kind==="self"?r+"["+JSON.stringify(O)+"]":r+"["+l.field+"="+JSON.stringify(O[l.field])+"]",f=new Map,u=O=>{let x=new Map;for(let A of O){let v=a(A);x.set(v,A),f.has(v)||f.set(v,p(A))}return x},y=u(s),b=u(t),S=u(n),g=new Map,d=new Set([...y.keys(),...b.keys(),...S.keys()]);for(let O of d){let x=Qi(y.has(O)?y.get(O):Kt,b.has(O)?b.get(O):Kt,S.has(O)?S.get(O):Kt,o,f.get(O),c);x!==Kt&&g.set(O,x)}let w=[];for(let O of n){let x=a(O);g.has(x)&&w.push(x)}for(let O=0;O<t.length;O++){let x=a(t[O]);if(!g.has(x)||w.includes(x))continue;let A=0;for(let v=O-1;v>=0;v--){let I=w.indexOf(a(t[v]));if(I!==-1){A=I+1;break}}w.splice(A,0,x)}return w.map(O=>g.get(O))}function Ca(e){let t=new Map,n=[];for(let o of e.keyCandidates||[]){let r=o.lastIndexOf(":");r>=0?t.set(o.slice(0,r),o.slice(r+1)):n.push(o)}return{keyCandidates:[...n,...ka],keyPaths:t,onConflict:e.onConflict||null}}function el(e,t,n,o={}){return Ns(e===void 0?Kt:e,t,n,Ca(o),"","")}function Ra(e,t){let n=/^\s*/.exec(t)[0],o=/\s*$/.exec(t.slice(n.length))[0],r=t.slice(n.length,t.length-o.length),c=n.slice(n.lastIndexOf(`
6
- `)+1),s=/\n([ \t]+)\S/.exec(r),l;if(!s)l=JSON.stringify(e);else{let i=s[1],a=i.length>c.length&&i.startsWith(c)?i.slice(c.length):" ";l=JSON.stringify(e,null,a).replace(/\n/g,`
7
- `+c)}return n+l.replace(/</g,"\\u003c")+o}function vs(e,t,n,o={}){let r=o.parse||Ss,c=[],s=[],l=(u,y)=>{if(typeof u!="string")return Kt;try{return r(u)}catch(b){return c.push(`${y} side is not valid JSON (${b.message})`),Kt}},i=l(t,"local"),a=l(n,"remote");if(i===Kt)return{text:n,warnings:c,conflicts:s};if(a===Kt)return{text:t,warnings:c,conflicts:s};let p=l(e,"base"),f=el(p===Kt?void 0:p,i,a,{...o,onConflict:u=>{s.push(u),o.onConflict?.(u)}});return Yn(f,a)?{text:n,warnings:c,conflicts:s}:Yn(f,i)?{text:t,warnings:c,conflicts:s}:{text:Ra(f,n),warnings:c,conflicts:s}}var tl=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function po(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>tl(t)||r>tl(o)||t.getRootNode()!==o.getRootNode())return!1;let c=t.ownerDocument.createRange();return c.setStart(t,n),c.setEnd(o,r),c.startContainer===t&&c.startOffset===n}function so(e,t,n={}){if(!po(e))return null;let{startContainer:o,startOffset:r,endContainer:c,endOffset:s}=e;if(o===c&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,s);if(o===c&&r===s)return"";let l=new Set;for(let g=o;g;g=g.parentNode)l.add(g);let i=c;for(;!l.has(i);)i=i.parentNode;let a=(g,d)=>{let w=i.ownerDocument.createRange(),O=i.ownerDocument.createRange();return w.setStart(g[0],g[1]),w.collapse(!0),O.setStart(d[0],d[1]),O.collapse(!0),w.compareBoundaryPoints(0,O)},p=(g,d=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(d)],f=[],u;if(t==="plain"){u="";let g=d=>{if(d.nodeType===3||d.nodeType===8){let w=u.length;u+=d.nodeValue,f.push({s:w,e:u.length,a:[d,0],b:[d,d.nodeValue.length],node:d})}else for(let w of d.childNodes)g(w)};g(i)}else{let g=n.blocks;if(!g){g=new Set;let w=O=>{O!==i&&O.nodeType===1&&bs.has(O.tagName)&&g.add(O);for(let x of O.childNodes)w(x)};w(i)}let d=nn(Array.from(i.childNodes),{blocks:g,atomize:w=>!!n.atoms?.has(w),ignored:n.ignored});u=d.text;for(let w of d.nodes)f.push({s:w.s,e:w.e,a:[w.node,0],b:[w.node,w.e-w.s],node:w.node});for(let w of d.atoms)f.push({s:w.i,e:w.i+1,a:p(w.el),b:p(w.el,!0)});for(let w=0;w<d.text.length;w++){if(d.text[w]!==xt)continue;let O=d.marks.find(A=>A.block&&A.to===w+1),x=d.marks.find(A=>A.block&&A.from===w+1);if(O)f.push({s:w,e:w+1,a:[O.el,O.el.childNodes.length],b:p(O.el,!0)});else if(x)f.push({s:w,e:w+1,a:p(x.el),b:[x.el,0]});else return null}}f.sort((g,d)=>g.s-d.s);let y=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let w=f.find(O=>O.node===g[0]);return w?w.s+g[1]:null}let d=0;for(let w of f){if(a(g,w.a)<=0)return w.s;if(a(g,w.b)<0)return null;d=w.e}return d},b=y([o,r]),S=y([c,s]);return b!==null&&S!==null&&b<=S?u.slice(b,S):null}function ho(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 nl(e,t){if(!e||!t)return null;let n=ho(e,t.start),o=ho(e,t.end);return n&&o?{startContainer:n[0],startOffset:n[1],endContainer:o[0],endOffset:o[1]}:null}var ol=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function rl(e,t,n){if(!t)return;let o=new Map,r=new Map,c=l=>{if(!l)return null;if(r.has(l))return r.get(l);let a=l.local.map(p=>ho(t.localRoot,{path:p,offset:0})?.[0]).map(p=>p&&n(p)).filter(Boolean).map(p=>({node:p,parent:p.parentNode,previous:p.previousSibling,next:p.nextSibling,fragment:ol(p)}));return r.set(l,a),a},s=l=>{let i=nl(t.localRoot,l);if(!i)return null;let a=n(i.startContainer),p=n(i.endContainer);if(!a||!p)return null;let f={...i,startContainer:a,endContainer:p};return po(f)?f:null};for(let l of e){let i=l.recovery;if(!i||o.has(i))continue;let a={subject:c(i.subject),span:null,scope:null,touched:new Set};if(i.text){a.span=s(i.text.local.span),a.scope=s(i.text.local.scope);let p=a.span;if(p){let f=p.startContainer.ownerDocument.createRange();f.setStart(p.startContainer,p.startOffset),f.setEnd(p.endContainer,p.endOffset);let u=y=>{if(f.intersectsNode(y)){a.touched.add(y);for(let b of y.childNodes)u(b)}};u(f.commonAncestorContainer)}}if(i.structure){for(let p of[i.structure.localPlacement])p&&(c(p.parent),p.before.forEach(c),p.after.forEach(c));for(let p of i.structure.localOrder||[])c(p)}o.set(i,a)}t.localState={states:o,refs:r}}function sl(e,t,n,o){let r=n.localState?.states.get(e);if(!r)return!1;let c=l=>{let i=l.node;if(!o(i)||i.parentNode!==l.parent)return!1;let a=p=>Array.prototype.indexOf.call(i.parentNode.childNodes,p);return!(l.previous&&o(l.previous)&&l.previous.parentNode===i.parentNode&&a(l.previous)>=a(i)||l.next&&o(l.next)&&l.next.parentNode===i.parentNode&&a(l.next)<=a(i))};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 l=e.text.local,i=a=>a&&o(a.startContainer)&&o(a.endContainer);return i(r.span)&&i(r.scope)&&so(r.scope,e.text.encoding)===l.text&&so(r.span,e.text.encoding)===l.text.slice(l.start,l.end)}if(e.attribute){let l=e.attribute,i=r.subject[0].node;return(l.namespaceURI?i.getAttributeNS(l.namespaceURI,l.localName):i.getAttribute(l.qualifiedName))===t.local}let s=e.structure;if(s.localOrder){let l=-1,i=null;for(let a of s.localOrder){let p=n.localState.refs.get(a)?.[0]?.node;if(!p||!o(p)||i&&p.parentNode!==i)return!1;let f=Array.prototype.indexOf.call(p.parentNode.childNodes,p);if(f<=l)return!1;i=p.parentNode,l=f}return!0}return s.localAction==="moved"||r.subject.every(l=>ol(l.node)===l.fragment)}var La=1,hn=e=>!!e&&e.nodeType===1,jr=e=>hn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function mo(e,t=null,n=null){let o=new Map,r=new Map,c=p=>{if(!t){t=new WeakMap;let f=[e];for(;f.length;){let u=f.pop();jr(u)&&(t.set(u.content,u),f.push(u.content));for(let y=u.firstChild;y;y=y.nextSibling)y.nodeType===1&&f.push(y)}}return t.get(p)||null},s=(p,f)=>{let u=r.get(p);if(!u){u=new Map;let y=0;for(let b=p.firstChild;b;b=b.nextSibling)u.set(b,y++);r.set(p,u)}return u.get(f)},l=p=>{if(!p)return null;if(n&&n.has(p))return l(n.get(p));if(p===e)return[];let f=o.get(p);if(f!==void 0)return f;let u=p.parentNode,y=null;if(u&&u.nodeType===11){let b=c(u),S=b?l(b):null;S&&(y=S.concat(["content",s(u,p)]))}else if(u){let b=l(u);b&&(y=b.concat([s(u,p)]))}return o.set(p,y),y};return{root:e,pathOf:l,logicalParent:p=>{let f=p.parentNode;return f&&f.nodeType===11?c(f):f},indexIn:s,containerPath:p=>{if(p.nodeType===11){let u=c(p),y=l(u);return y?y.concat(["content"]):null}let f=l(p);return f&&jr(p)?f.concat(["content"]):f},ownerOf:c}}var Ln=e=>jr(e)?e.content:e;function il(e){let{L:t,R:n,unitsOf:o,provenance:r,policy:c}=e,s=[];return{note:(p,f)=>{s.push([p,f])},finish:p=>s.length?a(p):null};function a(p){let f={base:mo(e.roots.base),local:mo(e.roots.local),remote:mo(e.roots.remote)},u=z=>z==="local"?t:n,y=(z,h)=>{if(!h)return null;if(z.map.has(h))return z.map.get(h);let E=[],R=hn(h)?f.base.logicalParent(h):h.parent;for(;R&&!z.map.has(R);R=f.base.logicalParent(R))E.push(R);if(!R||!z.identical.has(R))return null;let _=z.map.get(R);for(let Q=E.length-1;Q>=0&&_;Q--)_=Ln(_).childNodes[f.base.indexIn(E[Q].parentNode,E[Q])];return _?hn(h)?Ln(_).childNodes[f.base.indexIn(h.parentNode,h)]||null:o(_)[o(h.parent).indexOf(h)]||null:null},b=new Map,S=new Map,g=new WeakMap,d=0,w=(z,h)=>{let E=b.get(z);E||b.set(z,E=[]),E.push(h)};(function z(h){S.set(h,d++);let E=r.get(h);if(E&&!E.pinned){for(let R of[E.base,E.local,E.remote])if(R)if(Array.isArray(R))for(let _ of R)w(_,h);else w(R,h)}if(jr(h)){g.set(h.content,h);for(let R=h.content.firstChild;R;R=R.nextSibling)z(R)}for(let R=h.firstChild;R;R=R.nextSibling)z(R)})(p);let O=new Map;f.out=mo(p,g,O);let x={refs:new Map,spans:new Map,anchors:new Map,via:O,outOwners:g,outRoot:p,localRoot:e.roots.local},A=z=>hn(z)?[z]:z.nodes,v=(z,h)=>{let E=f[h].logicalParent(z);if(!E)return null;for(let R of o(E))if(!hn(R)&&R.nodes.includes(z))return R;return null},I=(z,h)=>z==null?null:Array.isArray(z)?z.length?v(z[0],h):null:z,M=z=>{let h=new Set,E=[];for(let R of z)for(let _ of b.get(R)||[])h.has(_)||(h.add(_),E.push(_));return E.sort((R,_)=>S.get(R)-S.get(_))},P=new Map,D=z=>{let h=z.b||z.l||z.r,E=P.get(h);if(E)return E;let R=[];for(let _ of[z.b,z.l,z.r])_&&R.push(...A(_));return E=M(R),P.set(h,E),E},$=z=>({b:z,l:y(t,z),r:y(n,z)}),W=(z,h)=>{let E=u(h).reverse.get(z);if(E)return $(E);for(let R of M(A(z))){let _=r.get(R);if(_&&!_.base&&_.local&&_.remote)return{b:null,l:I(_.local,"local"),r:I(_.remote,"remote")}}return h==="local"?{b:null,l:z,r:null}:{b:null,l:null,r:z}},B=new Map,k=z=>{let h=r.get(z);if(!h||h.pinned)return null;let E=I(h.base,"base");if(E)return $(E);let R=I(h.local,"local"),_=I(h.remote,"remote");if(R){let Q=t.reverse.get(R);if(Q)return $(Q)}if(_){let Q=n.reverse.get(_);if(Q)return $(Q)}return R||_?{b:null,l:R,r:_}:null},T=z=>(B.has(z)||B.set(z,k(z)),B.get(z)),J=(z,h)=>hn(z)?f[h].logicalParent(z):z.parent,H=new Map,F=new Map,Ee=(z,h)=>(hn(z)?[f[h].pathOf(z)]:z.nodes.map(E=>f[h].pathOf(E))).filter(Boolean),Me=z=>{let h=z.b||z.l||z.r,E=z.b?"base":z.l?"local":"remote",R=F.get(h);if(R)return R;let _=!hn(h),Q=Ee(h,E)[0],j=`${E[0]}:${JSON.stringify(Q===void 0?null:Q)}${_?":run":""}`,ue=H.get(j);if(ue)return F.set(h,ue),ue;let be=D(z);return ue={key:j,nodeType:hn(h)?1:h.kind==="comment"?8:3,base:z.b?Ee(z.b,"base"):[],local:z.l?Ee(z.l,"local"):[],remote:z.r?Ee(z.r,"remote"):[],merged:be.map(ie=>f.out.pathOf(ie)).filter(Boolean),live:[]},H.set(j,ue),F.set(h,ue),x.refs.set(ue,be),ue},je={base:new Map,local:new Map,remote:new Map},ae=new Map,Ae=(z,h)=>{let E=J(z,h);if(!E||E.nodeType!==1)return null;let R=je[h].get(E);if(!R){let Q=o(E),j=ue=>Me(h==="base"?$(ue):W(ue,h));R={parent:j(E),refs:Q.map(j),index:new Map(Q.map((ue,be)=>[ue,be]))},je[h].set(E,R)}let _=R.index.get(z)??-1;return{parent:R.parent,before:R.refs.slice(_+1),after:R.refs.slice(0,Math.max(0,_)).reverse()}},Ve=z=>{let h=z.parentNode;if(!h)return null;let E=ae.get(h);if(!E){let _=h.nodeType===11?g.get(h):h,Q=_&&_.nodeType===1?T(_):null;if(!Q)return null;let j=[],ue=[],be=new Map;for(let Ne of h.childNodes){let U=T(Ne),X=U&&Me(U),he=j.length,ge=j.length-1;X&&X!==j[ge]&&(j.push(X),ge++);let de={ref:X,group:ge,after:he};ue.push(de),be.set(Ne,de)}let ie=j.length;for(let Ne=ue.length-1;Ne>=0;Ne--){let U=ue[Ne];U.before=ie,U.ref&&(ie=U.group)}E={parent:Me(Q),refs:j,index:be},ae.set(h,E)}let R=E.index.get(z);return{parent:E.parent,before:E.refs.slice(R.before),after:E.refs.slice(0,R.after).reverse()}},ve=z=>hn(z)?z.outerHTML:z.value,N=z=>hn(z)?"element":z.kind==="comment"?"comment":"text",Y=(z,h)=>({path:z,offset:h}),le=(z,h,E)=>{if(!z)return null;let R=f[E],_=0;if(h){let Q=hn(h)?h:h.nodes[h.nodes.length-1];Q.parentNode&&(_=R.indexIn(Q.parentNode,Q)+1)}return Y(R.containerPath(z),_)},oe=(z,h)=>{let E=J(z,"base"),R=E?y(u(h),E):null;if(!hn(R))return null;let _=o(E),Q=null;for(let j=_.indexOf(z)-1;j>=0&&!Q;j--){let ue=y(u(h),_[j]);ue&&J(ue,h)===R&&(Q=ue)}return le(R,Q,h)},Re=(z,h,E,R)=>{let _=f[R],Q=0;for(let j=0;j<z.nodes.length;j++){let ue=z.nodes[j],be=ue.nodeValue.length,ie=j===z.nodes.length-1;if((E==="start"?h<Q+be:h<=Q+be)||ie)return Y(_.pathOf(ue),Math.max(0,Math.min(h-Q,be)));Q+=be}return null},Be=(z,h)=>{let E=f[h],R=z.firstChild,_=z.lastChild;return R&&R.nodeType===3&&_.nodeType===3?{start:Y(E.pathOf(R),0),end:Y(E.pathOf(_),_.nodeValue.length)}:{start:Y(E.pathOf(z),0),end:Y(E.pathOf(z),z.childNodes.length)}},Se=(z,h,E)=>{for(let j of z.nodes)if(E==="start"?j.s<=h&&h<j.e:j.s<h&&h<=j.e)return{kind:"text",node:j.node,offset:h-j.s};let R=E==="start"?h:h-1,_=()=>{for(let j of z.nodes)if(j.s===h||j.e===h)return{kind:"text",node:j.node,offset:h-j.s};return null},Q=z.atomAt.get(R);if(Q)return{kind:E==="start"?"before":"after",node:Q.el};if(z.text[R]===xt){let j=z.marks.find(be=>be.block&&be.to===R+1);if(j)return E==="start"?{kind:"end",node:j.el}:{kind:"after",node:j.el};let ue=z.marks.find(be=>be.block&&be.from===R+1);if(ue)return E==="start"?{kind:"before",node:ue.el}:{kind:"startOf",node:ue.el}}return _()},nt=(z,h)=>Se(z,h,"end")||Se(z,h,"start"),Ye=(z,h)=>{switch(h.kind){case"text":return Y(z.pathOf(h.node),h.offset);case"end":return Y(z.containerPath(h.node),Ln(h.node).childNodes.length);case"startOf":return Y(z.containerPath(h.node),0);default:{let E=h.node.parentNode;return Y(z.containerPath(E),z.indexIn(E,h.node)+(h.kind==="after"?1:0))}}},ht=(z,h,E,R,_)=>{let Q=Se(z,h,E);return Q?Ye(f[R],Q):_()},Ge=(z,h,E,R)=>{let _=z.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,Ne]of z.atomOut)_.push({s:ie,e:ie+1,start:{kind:"before",node:Ne},end:{kind:"after",node:Ne}});for(let[ie,Ne]of z.breakOut)_.push({s:ie,e:ie+1,start:{kind:"end",node:Ne},end:{kind:"after",node:Ne}});for(let ie of _)if(ie.start.kind==="text"&&ie.s<h&&h<ie.e)return{kind:"text",node:ie.start.node,offset:h-ie.s};if(E!=="empty"){let ie=_.find(Ne=>E==="start"?Ne.s===h:Ne.e===h);if(ie)return E==="start"?ie.start:ie.end}let Q=_.find(ie=>ie.e===h);if(Q)return Q.end;let j=_.find(ie=>ie.s===h);if(j)return j.start;let ue=null,be=null;for(let ie of _)ie.e<=h&&(!ue||ie.e>ue.e)&&(ue=ie),ie.s>=h&&(!be||ie.s<be.s)&&(be=ie);return ue?ue.end:be?be.start:R()},st=(z,h)=>{if(!h)return null;if(h.kind==="text"){let _=z.nodes.find(Q=>Q.node===h.node);return _?_.s+Math.min(h.offset,_.e-_.s):null}let E=z.atoms.find(_=>_.el===h.node);if(E)return h.kind==="after"?E.i+1:E.i;let R=z.marks.find(_=>_.el===h.node);return R?h.kind==="before"&&R.block&&z.text[R.from-1]===xt&&!z.marks.some(_=>_.block&&_.to===R.from)?R.from-1:h.kind==="startOf"||h.kind==="before"?R.from:h.kind==="end"&&R.block?R.to-1:R.to:null},Mt=(z,h,E,R)=>{for(let ue of z.nodes)if(E==="start"?ue.s<=h&&h<ue.e:ue.s<h&&h<=ue.e)return{kind:"text",node:ue.node,offset:h-ue.s};let _=E==="start"?h:h-1;if(!z.atomAt.has(_)&&z.text[_]!==xt){for(let ue of z.nodes)if(ue.s===h||ue.e===h)return{kind:"text",node:ue.node,offset:h-ue.s}}let Q=z.atomAt.get(_);if(Q)return{kind:E==="start"?"before":"after",node:Q.el};if(z.text[_]===xt){let ue=z.marks.find(ie=>ie.block&&ie.to===_+1);if(ue)return E==="start"?{kind:"end",node:ue.el}:{kind:"after",node:ue.el};let be=z.marks.find(ie=>ie.block&&ie.from===_+1);if(be)return E==="start"?{kind:"before",node:be.el}:{kind:"startOf",node:be.el}}let j=z.marks.find(ue=>ue.block&&ue.from===h);return j?{kind:"startOf",node:j.el}:R?{kind:E==="start"?"startOf":"end",node:R}:null},It=z=>{if(!z)return null;if(z.kind==="wholeStart"||z.kind==="wholeEnd"){let h=yt(z.node);return z.kind==="wholeStart"?h.start:h.end}return Ye(f.out,z)},yt=z=>{let h=z.firstChild,E=z.lastChild;return h&&h.nodeType===3&&E.nodeType===3?{start:Y(f.out.pathOf(h),0),end:Y(f.out.pathOf(E),E.nodeValue.length)}:{start:Y(f.out.pathOf(z),0),end:Y(f.out.pathOf(z),z.childNodes.length)}},Nt=z=>{let h=J(z,"base"),E=h?D($(h))[0]:null;if(!E)return null;let R=Ln(E),_=o(h);for(let Q=_.indexOf(z)-1;Q>=0;Q--){let j=D($(_[Q])).filter(ue=>ue.parentNode===R);if(j.length)return{kind:"after",node:j[j.length-1]}}return{kind:"startOf",node:E}},Ct=(z,h,E,R,_,Q)=>({text:z,start:h,end:E,fragment:R,span:_,scope:Q}),Vt=(z,h,E,R,_)=>Ct(z,h,E,z.slice(h,E),R,_),fn=(z,h,E,R,_)=>(x.spans.set(z,{start:h,end:E,scopeStart:R,scopeEnd:_}),z),Et=new Map,Gt=new Map,wn=(z,h,E)=>{let R=`text:${z.key}:${h}:${E}`,_=Gt.get(R)||0;return Gt.set(R,_+1),`${R}:${_}`},Bt=(z,h)=>{let E,R,_,Q="plain",j,ue,be,ie,Ne,U=(ge,de,ee,te,K)=>{if(!ge){let ne=oe(K,te);return Vt("",0,0,{start:ne,end:ne},{start:ne,end:ne})}return Vt(ge.value,de,ee,{start:Re(ge,de,de===ee?"end":"start",te),end:Re(ge,ee,"end",te)},{start:Re(ge,0,"start",te),end:Re(ge,ge.value.length,"end",te)})};if(h.site==="run"){let{bRun:ge,lRun:de,rRun:ee,node:te,c:K}=h;E=$(ge),R=K.bs,_=K.be,j=U(ge,K.bs,K.be,"base",ge),ue=U(de,K.ls,K.le,"local",ge),be=U(ee,K.rs,K.re,"remote",ge);let ne=te?te.nodeValue:"",xe=Ie=>te?{kind:"text",node:te,offset:Ie}:Nt(ge);ie=fn(Vt(ne,K.ms,K.me,{start:It(xe(K.ms)),end:It(xe(K.me))},{start:It(xe(0)),end:It(xe(ne.length))}),xe(K.ms),xe(K.me),xe(0),xe(ne.length)),Ne=te||(Nt(ge)||{}).node||null}else if(h.site==="whole"){let ge=h.el,de=r.get(ge);E=$(de.base),R=0,_=z.base.length;let ee=(K,ne,xe)=>{let Ie=Be(ne,xe);return Vt(K,0,K.length,Ie,Ie)};j=ee(z.base,de.base,"base"),ue=ee(z.local,de.local,"local"),be=ee(z.remote,de.remote,"remote");let te=yt(ge);ie=fn(Vt(z.resolved,0,z.resolved.length,te,te),{kind:"wholeStart",node:ge},{kind:"wholeEnd",node:ge},{kind:"wholeStart",node:ge},{kind:"wholeEnd",node:ge}),Ne=ge}else if(h.site==="comment"){let{bRun:ge,lRun:de,rRun:ee,node:te}=h;E=$(ge),R=0,_=z.base.length;let K=(Le,ke)=>{if(!Le){let Qe=oe(ge,ke);return Vt("",0,0,{start:Qe,end:Qe},{start:Qe,end:Qe})}let $e=Le.nodes[0],Je={start:Y(f[ke].pathOf($e),0),end:Y(f[ke].pathOf($e),Le.value.length)};return Vt(Le.value,0,Le.value.length,Je,Je)};j=K(ge,"base"),ue=K(de,"local"),be=K(ee,"remote");let ne=z.resolved,xe=Le=>te?{kind:"text",node:te,offset:Le}:Nt(ge),Ie={start:It(xe(0)),end:It(xe(ne.length))};ie=fn(Vt(ne,0,ne.length,Ie,Ie),xe(0),xe(ne.length),xe(0),xe(ne.length)),Ne=te||(Nt(ge)||{}).node||null}else{let{fb:ge,fl:de,fr:ee,scope:te}=h,K=h.merged;Q="html",E=te.base?$(te.base):W(te.local,"local"),R=z.bs,_=z.be;let ne=re=>{let Oe=te[re];for(let Pe=te.at-1;Pe>=0;Pe--){let We=te.units[Pe],qe=re==="base"?We:y(u(re),We);if(qe&&J(qe,re)===Oe)return qe}return null},xe=re=>()=>le(te[re],ne(re),re),Ie=(re,Oe,Pe,We,qe)=>{let pt=yn=>yn?Ye(f[qe],yn):xe(qe)(),tt=Oe===Pe?nt(re,Oe):Se(re,Oe,"start"),qt=Oe===Pe?nt(re,Oe):Se(re,Pe,"end"),Wt=pt(tt),dn={start:Wt,end:Oe===Pe?Wt:pt(qt)},bt=h.full?h.full(qe):null;if(!bt)return Ct(re.text,Oe,Pe,We,dn,{start:pt(Se(re,0,"start")),end:pt(Se(re,re.text.length,"end"))});let lt=tt?st(bt,tt):null,ze=qt?st(bt,qt):null,At=lt===null?0:lt,at=Math.max(At,ze===null?bt.text.length:ze),Dt=pt(Se(bt,0,"start"));return Ct(bt.text,At,at,Mo(bt,At,at),dn,{start:Dt,end:bt.text.length?pt(Se(bt,bt.text.length,"end")):Dt})};j=h.synthetic?null:Ie(ge,z.bs,z.be,z.base,"base"),ue=Ie(de,z.lss,z.lse,z.local,"local"),be=Ie(ee,z.rss,z.rse,z.remote,"remote");let[Le,ke]=z.range||[0,0],$e=K.out,Je=()=>{let re=Ln(K.node);for(let Oe=te.at-1;Oe>=0;Oe--){let Pe=D($(te.units[Oe])).filter(We=>We.parentNode===re);if(Pe.length)return{kind:"after",node:Pe[Pe.length-1]}}for(let Oe=te.at;Oe<te.units.length;Oe++){let Pe=D($(te.units[Oe])).filter(We=>We.parentNode===re);if(Pe.length)return{kind:"before",node:Pe[0]}}return{kind:"startOf",node:K.node}};if($e.via)for(let[re,Oe]of $e.via)O.set(re,Oe);let Qe=Ge(K,Le,Le===ke?"empty":"start",Je),Ut=Le===ke?Qe:Ge(K,ke,"end",Je),Pt=$e.text.length?Mt($e,0,"start",K.node):Je(),C=$e.text.length?Mt($e,$e.text.length,"end",K.node):Pt,G=st($e,Qe),se=st($e,Ut),me=G===null?0:G,ye=Math.max(me,se===null?$e.text.length:se);ie=fn(Ct($e.text,me,ye,Mo($e,me,ye),{start:It(Qe),end:It(Ut)},{start:It(Pt),end:It(C)}),Qe,Ut,Pt,C);let ce=x.spans.get(ie);if(ce.flat=$e,!$e.text.length){let re=It(Pt),Oe=ho(p,re),Pe=Oe[0],We=Oe[1];ce.empty={parent:Pe.nodeType===11?g.get(Pe):Pe,previous:Pe.childNodes[We-1]||null,next:Pe.childNodes[We]||null}}Ne=Qe?Qe.node:K.node}let X=Me(E),he=(h.site==="whole"||h.site==="comment"||(h.policy||c)!=="both")&&z.resolved!==z.local;return{key:h.site==="comment"&&Et.get(E.b||E.l||E.r)||wn(X,R,_),subject:X,localLost:he,anchor:Ne,text:{encoding:Q,base:j,local:ue,remote:be,merged:ie,liveSpan:null,liveScope:null}}},ln=(z,h)=>{let E=T(h.el),R=Me(E),_=h.sample;return{key:`attr:${R.key}:${_.namespaceURI||""}:${_.localName}`,subject:R,localLost:z.resolved!==z.local,anchor:h.el,attribute:{namespaceURI:_.namespaceURI||null,localName:_.localName,qualifiedName:_.name}}},Xt=(z,h)=>{let E=z.detail,R=h.unit||$(h.subject),_=Me(R),Q=x.refs.get(_),j=R.l?Ae(R.l,"local"):null,ue=R.r?Ae(R.r,"remote"):null,be=Q.length?Ve(Q[0]):null,ie,Ne,U,X=null,he=null,ge=h.deleted;switch(E){case"both-reordered":{ie=Ne="reordered";let de=new Set(h.rKept),ee=h.lKept.filter(Ie=>de.has(Ie)&&D($(Ie)).length),te=Ie=>S.get(D($(Ie))[0]);X=ee.map(Ie=>Me($(Ie))),he=ee.slice().sort((Ie,Le)=>te(Ie)-te(Le)).map(Ie=>Me($(Ie)));let K=Ie=>!hn(Ie)&&Ie.kind!=="comment"&&Ie.nodes.every(Le=>!/[^\t\n\f\r ]/.test(Le.data)),ne=ee.filter(Ie=>!K(Ie)),xe=ne.slice().sort((Ie,Le)=>te(Ie)-te(Le));U=ne.some((Ie,Le)=>Ie!==xe[Le]);break}case"both-moved":ie=Ne="moved",U=!j||!Q.some(de=>{let ee=de===Q[0]?be:Ve(de);return ee&&ee.parent===j.parent});break;case"edit-beats-delete":ie=ge==="local"?"deleted":"edited",Ne=ge==="remote"?"deleted":"edited",U=ge==="local";break;case"move-beats-delete":ie=ge==="local"?"deleted":"moved",Ne=ge==="remote"?"deleted":"moved",U=ge==="local";break;case"remote-wins":ie="edited",Ne="edited",U=!0;break;default:ie=Ne="inserted",U=h.localLost}return{key:`structure:${_.key}:${E}`,subject:_,localLost:U,anchor:Q[0]||null,structure:{localAction:ie,remoteAction:Ne,localPlacement:j,remotePlacement:ue,mergedPlacement:be,localOrder:X,mergedOrder:he,localFragment:E==="both-reordered"||!R.l?null:ve(R.l),fragmentKind:N(R.b||R.l||R.r)}}};for(let[z,h]of s){if(z.kind!=="structure")continue;let E=h.unit||$(h.subject),R=E.b||E.l||E.r;!hn(R)&&R.kind==="comment"&&Et.set(R,`structure:${Me(E).key}:${z.detail}`)}let un=new Map;for(let[z,h]of s){if(z.kind==="structure"){let Q=Me(h.unit||$(h.subject)),j=`structure:${Q.key}:${z.detail}`,ue=un.get(j);if(ue&&ue.structure){z.recovery=ue;let be=x.refs.get(Q);z.el==null&&be.length&&(z.el=hn(be[0])?be[0]:f.out.logicalParent(be[0]));continue}}let E=z.kind==="text"?Bt(z,h):z.kind==="attr"?ln(z,h):Xt(z,h),R=un.get(E.key);R||(R={version:La,key:E.key,localLost:E.localLost,subject:E.subject,applied:!1,unavailable:null},un.set(E.key,R),x.anchors.set(R,E.anchor)),E.text&&(R.text=E.text),E.attribute&&(R.attribute=E.attribute),E.structure&&(R.structure=E.structure),E.text&&(R.localLost=E.localLost),z.recovery=R;let _=x.refs.get(E.subject);z.kind==="structure"&&z.el==null&&_.length&&(z.el=hn(_[0])?_[0]:f.out.logicalParent(_[0])),z.kind==="text"&&z.node==null&&_.length&&E.subject.nodeType===8&&(z.node=_[0])}return x}}function ll(e,t,n){if(!t)return;let{lookup:o,vetoed:r,vetoedAttrs:c,liveAttr:s}=n,l=n.ignored||(()=>!1),i=mo(n.liveRoot),a=k=>!!k&&i.containerPath(k)!==null,p=k=>{let T=k.parentNode;return T&&T.nodeType===11?t.outOwners.get(T)||null:T},f=k=>{for(let T=k;T;T=p(T))if(t.via.has(T)&&(T=t.via.get(T)),r.has(T)||n.vetoedLive?.has(d(T)))return!0;return!1},u=k=>Array.from(Ln(k).children).filter(T=>!l(T)),y=(k,T)=>u(k)[u(T.parentNode).indexOf(T)],b=(k,T)=>{let J=null,H=null,F=0;for(let ae=T.previousSibling;ae;ae=ae.previousSibling){if(ae.nodeType===1&&!l(ae)){J=ae;break}ae.nodeType===3&&(F+=ae.nodeValue.length)}for(let ae=T.nextSibling;ae&&!H;ae=ae.nextSibling)ae.nodeType===1&&!l(ae)&&(H=ae);let Ee=J?y(k,J):null,Me=H?y(k,H):null;if(J&&!Ee||H&&!Me)return null;let je=[];for(let ae=Ee?Ee.nextSibling:Ln(k).firstChild;ae&&ae!==Me;ae=ae.nextSibling)ae.nodeType===3&&je.push(ae);return je.length?{nodes:je,lead:F}:null},S=k=>{let T=[],J=k;for(;J&&!t.via.has(J);J=J.parentNode)T.push(J);if(!J||!T.length)return null;let H=d(t.via.get(J));for(let Me=T.length-1;Me>0&&H;Me--)H=y(H,T[Me]);if(!H)return null;let F=T[0];if(F.nodeType===3)return b(H,F);let Ee=F.nodeType===1?y(H,F):null;return Ee?{nodes:[Ee],lead:0}:null},g=k=>{let T=o(k),J=T?{nodes:Array.isArray(T)?T:[T],lead:0}:t.via.size?S(k):null;if(!J)return null;let H=J.nodes.filter(a);return H.length?{nodes:H,lead:J.lead}:null},d=k=>{let T=g(k);return T?T.nodes[0]:null},w=k=>{if(!k)return null;if(k.kind==="text"){let F=g(k.node);if(!F)return null;let Ee=F.nodes,Me=k.offset+F.lead,je=0;for(let ae=0;ae<Ee.length;ae++){let Ae=Ee[ae].nodeValue.length;if(Me<=je+Ae||ae===Ee.length-1)return Me>=je&&Me<=je+Ae?[Ee[ae],Me-je]:null;je+=Ae}return null}let T=d(k.node);if(!T)return null;if(k.kind==="end")return[Ln(T),Ln(T).childNodes.length];if(k.kind==="startOf")return[Ln(T),0];if(k.kind==="wholeStart")return T.firstChild?[T.firstChild,0]:[T,0];if(k.kind==="wholeEnd")return T.lastChild?[T.lastChild,T.lastChild.nodeValue.length]:[T,T.childNodes.length];let J=T.parentNode;if(!J)return null;let H=Array.prototype.indexOf.call(J.childNodes,T);return[J,k.kind==="after"?H+1:H]},O=k=>({blocks:new Set((k.flat?.marks||[]).filter(T=>T.block).map(T=>d(T.el)).filter(Boolean)),atoms:new Set((k.flat?.atoms||[]).map(T=>d(T.el)).filter(Boolean)),ignored:l}),x=(k,T,J,H)=>{if(!k||!T||!po(k)||!po(T))return!1;for(let Me of[k,T])if(!a(Me.startContainer)||!a(Me.endContainer))return!1;let F=J.merged;if(F.start===F.end&&(k.startContainer!==k.endContainer||k.startOffset!==k.endOffset))return!1;let Ee=O(H);return so(T,J.encoding,Ee)===F.text&&so(k,J.encoding,Ee)===F.text.slice(F.start,F.end)},A=new Map,v=k=>{let T=k.parentNode;return T?(A.has(T)||A.set(T,new Map(Array.from(T.childNodes,(J,H)=>[J,H]))),A.get(T).get(k)):-1},I=(k,T)=>{if(!T)return!1;let J=i.logicalParent(k);if(!T.parent.live.includes(J))return!1;let H=v(k);for(let[F,Ee]of[["before",1],["after",-1]]){let Me=H;for(let je of T[F]){if(je.live.includes(k))continue;let ae=je.live.filter(Ve=>Ve!==k&&Ve.parentNode===k.parentNode);if(!ae.length)continue;let Ae=Ee===1?Math.min(...ae.map(v)):Math.max(...ae.map(v));if(Ee*(Ae-Me)<=0)return!1;Me=Ae}}return!0},M=k=>{let T=k.structure;if(T.mergedOrder){let J=new Set(k.subject.live.map(Ln)),H=null,F=-1;for(let Ee of T.mergedOrder){let Me=Ee.live.find(je=>J.has(je.parentNode));if(!Me||H&&Me.parentNode!==H||v(Me)<=F)return!1;H=Me.parentNode,F=v(Me)}return k.subject.live.length>0}return k.subject.live.some(J=>I(J,T.mergedPlacement))},P=(k,T)=>{let J=w(k),H=w(T);return J&&H?{startContainer:J[0],startOffset:J[1],endContainer:H[0],endOffset:H[1]}:null},D=new Set,$=k=>{if(!k||D.has(k))return;D.add(k);let T=[];for(let J of t.refs.get(k)||[]){let H=g(J);if(H)for(let F of H.nodes)T.includes(F)||T.push(F)}k.live=T},W=k=>{k&&($(k.parent),k.before.forEach($),k.after.forEach($))},B=new Set;for(let k of e){let T=k.recovery;if(!T||B.has(T))continue;B.add(T),$(T.subject),T.structure&&(W(T.structure.localPlacement),W(T.structure.remotePlacement),W(T.structure.mergedPlacement),(T.structure.localOrder||[]).forEach($),(T.structure.mergedOrder||[]).forEach($));let J=t.anchors.get(T),H=J?d(J):null,F=!!H;if(T.text){let N=t.spans.get(T.text.merged),Y=N?P(N.start,N.end):null,le=N?P(N.scopeStart,N.scopeEnd):null;if(N?.empty){let oe=N.empty,Re=oe.previous?{kind:"after",node:oe.previous}:{kind:"startOf",node:oe.parent},Be=oe.next?{kind:"before",node:oe.next}:{kind:"end",node:oe.parent},Se=P(Re,Be);!Se||Se.startContainer!==Se.endContainer||Se.startOffset!==Se.endOffset?Y=null:Y=le=Se}x(Y,le,T.text,N)||(Y=le=null),T.text.liveSpan=Y,T.text.liveScope=Y?le:null,Y||(F=!1)}T.structure&&F&&(F=M(T)),T.attribute&&F&&(F=s(H,T.attribute,k.resolved));let Ee=(!!T.attribute||!!T.text&&H?.tagName==="TEXTAREA")&&!!c&&[J,H].some(N=>c.get(N)?.has(T.attribute?T.attribute.qualifiedName:"value")),Me=t.localState?.states.get(T),je=!!T.text&&[...n.removedVetoes||[]].some(N=>Me?.touched.has(N)),ae=T.structure?.localAction==="inserted"&&[...r].some(N=>N===J||J?.contains(N)),Ae=J&&f(J)||Ee||je||ae,Ve=Ae&&sl(T,k,t,a);Ve&&(je||ae&&T.localLost)&&(F=!1);let ve=!F&&Ve&&Ae;T.applied=F,T.unavailable=F?null:ve?"hook-veto":"missing-output",ve&&(T.localLost=!1),!F&&T.text&&(T.text.liveSpan=T.text.liveScope=null)}}function Dr(e,t,n){let o=mo(t),r=mo(n),c=f=>!!f&&r.containerPath(f)!==null,s=f=>{if(f===t)return n;let u=o.pathOf(f);if(u&&t!==n){let y=ho(n,{path:u,offset:0});if(y&&y[0].nodeType===f.nodeType)return y[0]}return f},l=new Set,i=f=>{!f||l.has(f)||(l.add(f),f.live=f.live.map(s).filter(c))},a=f=>{f&&(f.startContainer=s(f.startContainer),f.endContainer=s(f.endContainer))},p=new Set;for(let f of e){f.node===t&&n.tagName==="SCRIPT"&&(f.node=n),f.el===t&&f.kind==="structure"&&(f.el=n);let u=f.recovery;if(!u||p.has(u))continue;if(p.add(u),i(u.subject),u.text){a(u.text.liveSpan),a(u.text.liveScope);let b=u.text.liveSpan,S=u.text.liveScope,g=u.text.merged,d=w=>!!w&&po(w)&&c(w.startContainer)&&c(w.endContainer);(!d(b)||!d(S)||so(S,u.text.encoding)!==g.text||so(b,u.text.encoding)!==g.text.slice(g.start,g.end))&&(u.text.liveSpan=null,u.text.liveScope=null,u.applied=!1,u.unavailable="missing-output")}let y=u.structure;if(y){for(let b of[y.localPlacement,y.remotePlacement,y.mergedPlacement])b&&(i(b.parent),b.before.forEach(i),b.after.forEach(i));(y.localOrder||[]).forEach(i),(y.mergedOrder||[]).forEach(i),u.subject.live.length||(u.applied=!1,u.unavailable="missing-output")}}}var Lo=e=>e?.nodeType===1,Qo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function Pa({provenance:e,parentOf:t,twins:n,baseOf:o,build:r,ignored:c,remoteWins:s,discarded:l}){let i=new Map,a=new WeakMap;function p(y,b,S,g=!1){if(!Lo(y)||!Lo(S))return null;let d=i.get(y);if(d)(g||!d.selected&&b==="remote")&&(d.parent=t(S),d.port=S,d.sourceSide=b,d.selected=g);else{let w=a.get(y)||null;d={owner:y,parent:t(S),port:S,sourceSide:b,originalParent:t(y),originalPort:y,selected:g,state:w?"built":"planned",output:w,disposition:null},i.set(y,d)}return d}function f(y,b){if(!Lo(y)||!Lo(b))return;a.has(y)||a.set(y,b);let S=i.get(y);S&&S.state!=="attached"&&!S.output&&(S.output=b,S.state="built")}function u(y){if(!i.size)return;let b=new Map,S=new WeakMap,g=new WeakMap,d=new WeakSet,w=new Set,O=(W,B)=>{if(!W)return;if(Array.isArray(W)){for(let T of W)O(T,B);return}let k=b.get(W);k||b.set(W,k=[]),k.push(B)},x=(W,B)=>{if(!W)return;let k=[W];for(;k.length;){let T=k.pop();O(T,B);for(let J of Qo(T).childNodes)k.push(J)}};function A(W,B=null,k=!1){if(d.has(W))return;d.add(W),S.set(W,B);let T=e.get(W),J=k||!!(T&&s(T.remote||T.base));g.set(W,J);let H={node:W,kind:"node",authority:J};if(T?.pinned)x(T.local,{...H,kind:"ignored"});else if(T?.unchanged)for(let F of[T.base,T.local,T.remote])x(F,{...H,kind:"unchanged"});else if(T){for(let F of[T.base,T.local,T.remote])O(F,H);if(Lo(T.local))for(let F of Qo(T.local).children)c(F)&&x(F,{...H,kind:"ignored"})}for(let F of Qo(W).childNodes)A(F,W,J)}let v=W=>{if(W.output&&d.has(W.output))return W.state="attached",W.disposition="node",!0;let{local:B,remote:k}=n(W.owner);for(let T of[W.owner,B,k]){let J=b.get(T);if(J?.length){let H=J.find(F=>F.kind==="node")||J[0];return W.output=H.node,W.state="attached",W.disposition=H.kind,!0}}return!1},I=(W,B)=>(b.get(W)||[]).find(T=>T.kind==="node"&&Lo(T.node)&&(!T.authority||B.sourceSide==="remote"))?.node,M=(W,B,k)=>{let T=b.get(W)||[],J=k?[...T].reverse():T;for(let H of J){if(H.kind!=="node")continue;let F=H.node;for(;F&&S.get(F)!==B;)F=S.get(F);if(F)return F}return null},P=(W,B,k)=>{let T=Qo(B);for(let J=k?.previousSibling;J;J=J.previousSibling){let H=M(J,B,!0);if(H){T.insertBefore(W,H.nextSibling);return}}for(let J=k?.nextSibling;J;J=J.nextSibling){let H=M(J,B,!1);if(H){T.insertBefore(W,H);return}}T.appendChild(W)};function D(W,B,k){let T=B==="base"?W:o(W,B),J=i.get(T);J&&J!==k&&$(J)}function $(W){if(W.state==="attached"||W.disposition==="remote-wins"||w.has(W)||v(W))return;w.add(W);let{local:B,remote:k}=n(W.owner);if(s(k||W.owner)){if(!k){W.disposition="remote-wins",l(W.owner,B),w.delete(W);return}W.parent=t(k),W.port=k,W.sourceSide="remote"}if(D(W.parent,W.sourceSide,W),v(W)){w.delete(W);return}let T=I(W.parent,W),J=W.port;if(!T){if(D(W.originalParent,"base",W),v(W)){w.delete(W);return}let F=W.originalParent;for(J=W.originalPort;F&&!T;)T=I(F,W),T||(J=F,F=t(F))}if(!T)throw new Error("A planned move has no allowed surviving parent");let H=W.output||r(W.owner);W.output=H,W.state="built",P(H,T,J),A(H,T,g.get(T)||!1),v(W),w.delete(W)}A(y);for(let W of i.values())$(W)}return{planned:i,has:y=>i.has(y),plan:p,produced:f,drain:u}}function Po(e,t,n,o,r,c,s,l,i,a,p,f,u){let y=null;return Pa({provenance:e,parentOf:g=>{if(!g)return null;let d=t(g);if(d||g.parentNode?.nodeType!==11)return d;if(!y){y=new WeakMap;let w=[f,u];for(;w.length;){let O=w.pop(),x=Qo(O);x!==O&&y.set(x,O);for(let A of x.children)w.push(A)}}return y.get(g.parentNode)||null},twins:g=>({local:r(n,g),remote:r(o,g)}),baseOf:(g,d)=>g&&(d==="local"?n:o).reverse.get(g)||null,build:g=>c(g,r(n,g),r(o,g),!1),ignored:s,remoteWins:l,discarded:(g,d)=>{d&&p(g,d,n)&&!i.some(w=>w.detail==="remote-wins"&&w.base===g)&&a({kind:"structure",el:null,detail:"remote-wins",base:g,local:d,remote:null},{subject:g})}})}function ja({parent:e,base:t,views:n,eligible:o,ignored:r,remoteWins:c,budget:s=zt(2e4*32),maxUnits:l=256,maxCharacters:i=2e4}){let a=(d,w=null)=>({status:d,reason:w,parent:e,records:[]});if(n.some(({V:d})=>d.asBase)||r(e)||c(e)||n.some(({V:d})=>!d.el||r(d.el)||c(d.el)))return a("none");let p=t.length+n[0].V.units.length+n[1].V.units.length;if(p>l)return a("fallback","unit-limit");let f=Symbol(),u=d=>{if(d>s.remaining)throw f;s.remaining-=d,s.crossParentSteps=(s.crossParentSteps||0)+d},y=new Map,b=0,S=d=>{if(u(1),y.has(d))return y.get(d);let w=d.nodeType===1?d.childNodes:d.nodes;u(w.length*4+1);let O=d.nodeType===1?Array.from(w):w,x=0;for(let I=0;I<O.length;I++){let M=O[I];if(M.nodeType!==3||I&&O[I-1].nextSibling!==M)return y.set(d,null),null;x+=M.data.length}if(x>i-b)throw f;u(x*8+1),b+=x;let A=nn(O);if(A.text.includes(xt))return y.set(d,null),null;let v={unit:d,nodes:O,flat:A};return y.set(d,v),v},g=[];try{u(p*8+1);for(let d=0;d<2;d++){let w=n[d].V,O=n[1-d].V,x=[],A=new Map;for(let v=0;v<t.length;v++){u(1);let I=t[v];if(I.kind!=="text"||w.twin(I))continue;let M=O.twin(I);if(!M||M.kind!=="text"||!O.here(M))continue;let P=S(I),D=S(M);if(!P||!D||!/\S/.test(P.flat.text))continue;u(P.flat.text.length*2+1);let $=P.flat.text;A.set($,(A.get($)||0)+1),x.push({source:I,opposite:M,sourceModel:P,oppositeModel:D,index:v})}for(let v of x){let{source:I,opposite:M,sourceModel:P,oppositeModel:D,index:$}=v,W=[];for(let Y of[-1,1]){u(1);let le=t[$+Y];if(!le||le.nodeType!==1||!o(le)||r(le)||c(le))continue;let oe=P.nodes[0],Re=P.nodes.at(-1);if(Y===-1?oe?.previousSibling!==le:Re?.nextSibling!==le)continue;let Be=w.twin(le),Se=O.twin(le);if(!Be||!Se||!w.here(Be)||O.here(Se)||w.baseOf(Be)!==le||O.baseOf(Se)!==le||!o(Be)||!o(Se)||r(Be)||r(Se)||c(Be)||c(Se)||Be.tagName!==le.tagName||Se.tagName!==le.tagName||Be.namespaceURI!==le.namespaceURI||Se.namespaceURI!==le.namespaceURI)continue;let nt=S(le),Ye=S(Be),ht=S(Se);if(!nt||!Ye||!ht||!/\S/.test(nt.flat.text))continue;let Ge=nt.flat.text,st=P.flat.text,Mt=Ye.flat.text;if(u((Ge.length+st.length+Mt.length)*3+1),Mt.length!==Ge.length+st.length)continue;let It=Y===-1;(It?!Mt.startsWith(Ge)||!Mt.endsWith(st):!Mt.startsWith(st)||!Mt.endsWith(Ge))||W.push({owner:le,target:Be,moved:Se,ownerBase:nt,joined:Ye,ownerOther:ht,targetFrom:It?Ge.length:0,retainedFrom:It?0:st.length})}if(!W.length)continue;if(W.length!==1||A.get(P.flat.text)!==1)return a("fallback","ambiguous-origin");let B=W[0],{owner:k,target:T,moved:J,ownerBase:H,joined:F,ownerOther:Ee,targetFrom:Me,retainedFrom:je}=B;if(u(g.length+1),g.some(Y=>Y.owner===k))return a("fallback","ambiguous-owner");let ae={source:I,target:T,from:0,to:P.flat.text.length,targetFrom:Me},Ae=_n({base:P.flat,side:F.flat,retained:[],transfers:[{from:ae.from,to:ae.to,target:Me,destination:k}],budget:s});if(Ae.status!=="ready"||Ae.covers(ae.from,ae.to)!==!0)return a("fallback",Ae.reason||"work-limit");let Ve=[{unit:I,model:P,from:0,to:P.flat.text.length},null,null];Ve[d+1]={unit:T,model:F,from:Me,to:Me+P.flat.text.length},Ve[2-d]={unit:M,model:D,from:0,to:D.flat.text.length};let ve=[H,null,null];ve[d+1]=F,ve[2-d]=Ee;let N=[k,null,null];N[d+1]=T,N[2-d]=J,g.push({side:d,parent:e,source:I,target:T,owner:k,owners:N,ownerModels:ve,native:Ve,models:y,runs:[ae],proof:Ae,retained:[{source:k,target:T,from:0,to:H.flat.text.length,targetFrom:je}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:a("none")}catch(d){if(d!==f)throw d;return a("fallback","work-limit")}}function cl({describe:e,parentOf:t,...n}){let o=new WeakMap,r=new WeakMap,c=n.budget||zt(2e4*32),s=l=>{if(!l)return null;if(o.has(l))return o.get(l);o.set(l,{status:"planning",parent:l,records:[]});let i=e(l),a=i?ja({...n,...i,parent:l,budget:c}):{status:"none",reason:null,parent:l,records:[]};if(o.set(l,a),a.status==="ready")for(let p of a.records)r.set(p.owner,[p]);return a};return{get:s,forOwner(l){return s(t(l))?.status==="ready"&&r.get(l)||null}}}function Da(e,t){if(e.side!==0)return null;let n=e.native[0].model,o=e.ownerModels[0],r=e.native[1].from!==0,c=(O,x)=>r?[...O.nodes,...x.nodes]:[...x.nodes,...O.nodes],s=e.ownerModels.reduce((O,x)=>O+x.flat.text.length,0)+n.flat.text.length+e.native[2].model.flat.text.length;if(s*8>t.remaining)return null;t.remaining-=s*8;let l={base:c(o,n),local:e.ownerModels[1].nodes,remote:c(e.ownerModels[2],e.native[2].model)},i=nn(l.base),a=e.ownerModels[1].flat,p=nn(l.remote),f=r?o.flat.text.length:0,u=r?0:n.flat.text.length,y=_n({base:i,side:a,retained:e.retained.map(O=>({from:u+O.from,to:u+O.to,target:O.targetFrom})),transfers:e.runs.map(O=>({from:f+O.from,to:f+O.to,target:O.targetFrom,destination:e.owner})),budget:t});if(y.status!=="ready"||y.covers(0,i.text.length)!==!0)return null;let b=e.ownerModels[2].flat,S=e.native[2].model.flat,g=[];for(let[O,x,A,v]of[[o.flat,b,u,r?0:S.text.length],[n.flat,S,f,r?b.text.length:0]]){let I=ys(O,O,x).remoteMap.bTo,M=-1;for(let P=0;P<O.text.length;P++){if(I[P]<0){M=-1;continue}let D=g.at(-1);M>=0&&D.to===A+P&&D.target+D.to-D.from===v+I[P]?D.to++:(g.push({from:A+P,to:A+P+1,target:v+I[P]}),M=P)}}let d=_n({base:i,side:p,retained:g,transfers:[],budget:t});if(d.status!=="ready")return null;let w=ys(i,a,p,{},{local:y,remote:d});return w.localEdits.hunks.length?null:(w.localMap=y,w.remoteMap=d,{nodes:l,prepared:w})}function al({L:e,R:t,twinIn:n,unitsOf:o,view:r,parentOf:c,ignored:s,remoteWins:l,eligible:i,build:a,out:p,policy:f,provenance:u,textMappers:y,segments:b,conflicts:S,conflict:g,decisions:d}){let w=zt(2e4*32),O=W=>{let B=0;for(let k=W;k;k=c(k))if(++B>64||k.nodeType===1&&(s(k)||l(k)))return!1;return!0},x=cl({parentOf:c,eligible:i,ignored:s,remoteWins:l,budget:w,describe(W){let B=n(e,W),k=n(t,W);return!B||!k||!O(W)||!O(B)||!O(k)?null:{base:o(W),views:[{A:e,V:r(e,B,W,!1)},{A:t,V:r(t,k,W,!1)}]}}}),A=new WeakSet,v=new WeakMap,I=new WeakSet,M=[];function P(W){if(!W||A.has(W))return;A.add(W);let B=x.get(W);if(B?.status==="ready")for(let k of B.records){if((W.tagName==="TEMPLATE"&&W.content?W.content:W).childNodes.length!==k.native[0].model.nodes.length+1||!k.owners.every(O))continue;let J=Da(k,w);if(!J)continue;let H={record:k,payload:J,state:"planned",output:null,result:null};v.set(k.owner,H),I.add(k.source),I.add(k.native[2].unit),M.push(H)}}function D(W,B){let k=v.get(W);if(!k)return!1;if(!k.result){if(k.result=Ir({...k.payload.nodes,prepared:k.payload.prepared,out:p,policy:f,provenance:u,textMappers:y,conflicts:S,conflict:g,decisions:d,node:B}),k.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");b.push(...k.result.segments),k.decision={kind:"text",node:B,source:"local"},d.push(k.decision)}return k.decision.node=B,B.replaceChildren(...k.result.nodes),k.output=B,k.state="built",!0}function $(W){if(!M.length)return;let B=new WeakSet,k=new WeakMap,T=new WeakMap,J=new WeakMap,H=Ae=>Ae.tagName==="TEMPLATE"&&Ae.content?Ae.content:Ae,F=(Ae,Ve)=>{if(!Ae)return;if(Array.isArray(Ae)){for(let N of Ae)F(N,Ve);return}let ve=J.get(Ae);ve||J.set(Ae,ve=[]),ve.push(Ve)},Ee=(Ae,Ve=null,ve=!1)=>{B.add(Ae),k.set(Ae,Ve);let N=u.get(Ae),Y=ve||!!(N&&l(N.remote||N.base));if(T.set(Ae,Y),N)for(let le of[N.base,N.local,N.remote])F(le,Ae);if(!(N?.pinned||N?.unchanged))for(let le of H(Ae).childNodes)Ee(le,Ae,Y)},Me=Ae=>(J.get(Ae)||[]).find(Ve=>Ve.nodeType===1&&!T.get(Ve)&&!u.get(Ve)?.pinned&&!u.get(Ve)?.unchanged),je=(Ae,Ve)=>{for(let ve of J.get(Ae)||[]){let N=ve;for(;N&&k.get(N)!==Ve;)N=k.get(N);if(N)return N}return null},ae=(Ae,Ve,ve)=>{let N=H(Ve);for(let Y=ve.nextSibling;Y;Y=Y.nextSibling){let le=je(Y,Ve);if(le){N.insertBefore(Ae,le);return}}for(let Y=ve.previousSibling;Y;Y=Y.previousSibling){let le=je(Y,Ve);if(le){N.insertBefore(Ae,le.nextSibling);return}}N.appendChild(Ae)};Ee(W);for(let Ae of M){let{record:Ve}=Ae,ve=Me(Ve.owner)||Me(Ve.owners[1])||Me(Ve.owners[2]);if(ve)(!Ae.result||Ae.output!==ve||Ae.result.nodes.some(N=>!B.has(N)||k.get(N)!==ve)||ve.textContent!==Ae.result.text)&&(D(Ve.owner,ve),Ee(ve,k.get(ve),T.get(ve)));else{let N=Ve.parent,Y=Ve.owner,le=null;for(;N&&!le;)le=Me(N),le||(Y=N,N=c(N));if(!le)throw new Error("A cross-parent payload has no allowed surviving parent");ve=Ae.output||a(Ve.owner,Ve.owners[1],Ve.owners[2],!1),Ae.result||D(Ve.owner,ve),ae(ve,le,Y),Ee(ve,le,T.get(le))}Ae.state="attached"}}return{ensureParent:P,ensureOwner(W){P(c(W))},consumes(W){return I.has(W)},render:D,drain:$}}var In=/\S/,fl=/[\p{L}\p{N}]/u;function go(e,t,n,o){if(e?.nodeType!==1||!t(e))return!1;for(let r=e.firstChild;r;r=r.nextSibling)if(o(n,1),r.nodeType!==3)return!1;return!!e.firstChild}function Os(e,t,n){for(let o=e.parentNode;o;o=o.parentNode)if(n(t,1),o.nodeType===11)return!1;return!0}function ul(e,t,n,o,r){let c=n(e,o),s=n(t,o),l=null,i=null,a=null,p=null;r(o,c.length+s.length);for(let f of c)fl.test(f.raw)&&(l||=f,i=f);for(let f of s)fl.test(f.raw)&&(a||=f,p=f);return!!(l&&a&&(l.raw===a.raw||i.raw===p.raw))}function Ba({base:e,V:t,A:n,source:o,original:r,current:c,edited:s,destination:l,at:i,ownLength:a,eligible:p,model:f,tokensOf:u,budget:y,charge:b}){let S=r.flat.text,g=c.flat.text,d=s.flat.text,w=l.flat.text;if(b(y,S.length+g.length+w.length),S.startsWith(g)||S.endsWith(g))return!1;let O=In.test(w.slice(0,i)),x=In.test(w.slice(i+a));if(O===x)return!1;let A=O?0:i+a,v=O?i:w.length;for(;A<v&&!In.test(w[A]);)A++;for(;v>A&&!In.test(w[v-1]);)v--;let I=w.slice(A,v);if(Rn(I,w,u(l,y),y,b,!0)!==A)return!1;let M=Rn(I,S,u(r,y),y,b,!0);if(M<0)return!1;let P=M+I.length,D=!In.test(S.slice(0,M)),$=!In.test(S.slice(P));if(D===$||Rn(I,g,u(c,y),y,b,!1)>=0)return!1;let W=D?S.slice(P):S.slice(0,M),B=D?d.length-W.length:0;if(b(y,S.length+d.length),B<0||!In.test(W)||Rn(W,d,u(s,y),y,b,!0)!==B||!In.test(D?d.slice(0,B):d.slice(W.length)))return!1;for(let k of e){if(b(y,1),k===o||!go(k,p,y,b))continue;let T=f(k,null,y);if(Rn(I,T.flat.text,u(T,y),y,b,!1)>=0)return!1}for(let k of t.units){if(b(y,1),k===c.unit||k===l.unit||!go(k,p,y,b))continue;let T=f(k,n,y);if(Rn(I,T.flat.text,u(T,y),y,b,!1)>=0)return!1}return!0}function dl({base:e,views:t,side:n,attempt:o,eligible:r,blocked:c,baseId:s,model:l,tokensOf:i,charge:a,exhausted:p,limit:f}){if(f<=0)return null;let u=zt(f),{V:y,A:b,idOf:S}=t[n],g=t[1-n],[d,w,O,x]=o,A=null;try{for(let v=d;v<=w;v++){a(u,1);let I=e[v];if(I.parentNode?.nodeType!==1||c.has(I)||b.identical.has(I)||g.A.identical.has(I)||!go(I,r,u,a)||s(I))continue;let M=y.twin(I),P=g.V.twin(I);if(!M||!P||!y.here(M)||!g.V.here(P)||b.map.get(I)!==M||b.reverse.get(M)!==I||g.A.map.get(I)!==P||g.A.reverse.get(P)!==I||S(M)||g.idOf(P)||M.tagName!==I.tagName||P.tagName!==I.tagName||!go(M,r,u,a)||!go(P,r,u,a)||!Os(I,u,a)||!Os(M,u,a)||!Os(P,u,a))continue;let D=l(I,null,u),$=l(M,b,u),W=l(P,g.A,u),B=D.flat.text,k=$.flat.text,T=W.flat.text;if(a(u,B.length+k.length+T.length),!In.test(B)||!In.test(k)||!In.test(T)||B===k||B===T||k===T||!ul(D,$,i,u,a)||!ul(D,W,i,u,a))continue;let J=null,H=!1;for(let Me=O;Me<=x;Me++){a(u,1);let je=y.units[Me],ae=y.baseOf(je);if(!ae||ae===I||c.has(ae)||ae.parentNode!==I.parentNode||je.parentNode!==M.parentNode||ae.tagName!==I.tagName||je.tagName!==I.tagName||b.map.get(ae)!==je||b.reverse.get(je)!==ae||s(ae)!==S(je)||!go(ae,r,u,a)||!go(je,r,u,a))continue;let Ae=l(ae,null,u),Ve=l(je,b,u),ve=Ae.flat.text,N=Ve.flat.text;if(a(u,ve.length),!In.test(ve)||N.length<=ve.length)continue;let Y=i(Ve,u),le=Rn(ve,N,Y,u,a,!0);if(!(le<0||Rn(B,N,Y,u,a,!0,le,le+ve.length)<0&&!Ba({base:e,V:y,A:b,source:I,original:D,current:$,edited:W,destination:Ve,at:le,ownLength:ve.length,eligible:r,model:l,tokensOf:i,budget:u,charge:a}))){if(J){H=!0;break}J=je}}if(!J||H)continue;let F=n===0?M:P,Ee=n===0?P:M;(A||=[]).push({source:I,local:F,remote:Ee,models:[D,n===0?$:W,n===0?W:$]})}}catch(v){if(v!==p)throw v}return A}var Fn=/\S/,bn=/\s/,Ua=/[\s\u001e]/g,Ms=/[^\s\p{P}\u001e\ufffc]/u;function Ha(e,t,n,o,r,c,s){let l=0;for(let i of e)s(c,1),i.nodeType===1&&!o.baseOf(i)&&l++;if(l<2)return!1;for(let i of e){if(i.nodeType!==1||o.baseOf(i))continue;let a=r.get(i).flat;if(a.atoms.length||a.pins?.length)continue;s(c,a.text.length*2+t.length+n.length);let p=new Uint8Array(a.text.length);for(let f of n)f.target===i&&p.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f of t)f.target===i&&p.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f=0;f<a.text.length;f++)if(!p[f]&&Fn.test(a.text[f]))return!0}return!1}function Wa(e,t,n){let{source:o,models:r,retained:c,runs:s}=e,l=r.get(o).flat.text;n(t,l.length*2+c.length+s.length);let i=new Uint8Array(l.length);for(let a of c)a.source===o&&(n(t,a.to-a.from),i.fill(1,a.from,a.to));for(let a of s)n(t,a.to-a.from),i.fill(1,a.from,a.to);for(let a=0;a<l.length;a++)if(!i[a]&&Fn.test(l[a]))return!1;return!0}function _a(e,t,n,o,r,c,s,l,i,a){let p=c.get(e),f=c.get(t),u=p.flat.text,y=s.get(e);i(a,u.length*2+n.length);let b=u.length,S=0;for(let w=0;w<u.length;w++)!bn.test(u[w])&&!y[w]&&(b=Math.min(b,w),S=w+1);if(b>=S)return null;for(let w=b;w<S;w++)if(!bn.test(u[w])&&y[w])return null;let g=-1;for(let w of n)if(w.target===t&&w.from<=b&&w.to>b){g=w.targetFrom+b-w.from;break}if(g<0)return null;let d=u.slice(b,S);if(i(a,d.length*(n.length+2)),f.flat.text.slice(g,g+d.length)!==d)return null;for(let w=b;w<S;w++){if(bn.test(u[w]))continue;let O=!1;for(let x of n)if(x.target===t&&x.from<=w&&x.to>w&&x.targetFrom+w-x.from===g+w-b){O=!0;break}if(!O)return null}if(p.flat.atoms.length||f.flat.atoms.length){i(a,p.flat.atoms.length+f.flat.atoms.length);let w=0,O=f.flat.atoms;for(;w<O.length&&O[w].i<g;)w++;for(let x of p.flat.atoms){if(x.i<b||x.i>=S)continue;let A=O[w++];if(!A||A.i!==g+x.i-b||f.alignment?.reverse.get(A.el)!==x.el)return null}if(w<O.length&&O[w].i<g+S-b)return null}for(let[w,O,x]of[[o,e,b],[r,t,g]]){let A=!1;for(let v of w){let I=c.get(v),M=s.get(v),P=l(I,a);for(let D=0;D<P.length;D++){let $=P[D].from,W=$+d.length;if(i(a,d.length*2+1),I.flat.text.slice($,W)!==d)continue;let B=D;for(;B<P.length&&P[B].to<W;)i(a,1),B++;if(B===P.length||P[B].to!==W)continue;let k=!0;for(let T=$;T<W;T++)if(!bn.test(I.flat.text[T])&&M[T]){k=!1;break}if(k){if(A||v!==O||$!==x)return null;A=!0}}}if(!A)return null}return d}function Va(e,t,n,o,r,c,s,l){if(s(l,r.length+c.length+(o.length+1)*n.length*2),!n)return!1;let i=o.indexOf(n);return i<0||o.lastIndexOf(n)!==i||!c.some(a=>a.from===i)||!c.some(a=>a.to===i+n.length)?!1:r.some(a=>a.source===e&&a.target===t&&a.from===0&&a.to===n.length&&a.targetFrom===i)}function hl({base:e,views:t,eligible:n,baseId:o,ignored:r,remoteWins:c,atomKey:s,limit:l=2e4*8}){if(l<=0)return null;let i=Symbol(),a=(x,A)=>{if(A>x.remaining)throw i;x.remaining-=A},p=[new Map,new Map];for(let x=0;x<2;x++)for(let A=0;A<t[x].V.units.length;A++)p[x].set(t[x].V.units[A],A);let f=new Int32Array(e.length),u=new Int32Array(e.length),y=x=>t.every(({V:A},v)=>{let I=A.twin(x);return I&&p[v].has(I)}),b=-1;for(let x=0;x<e.length;x++)f[x]=b,y(e[x])&&(b=x);b=e.length;for(let x=e.length-1;x>=0;x--)u[x]=b,y(e[x])&&(b=x);let S=new Map,g=(x,A)=>{if(a(A,1),S.has(x))return S.get(x);let v=x.firstChild,I=1;for(;v;){if(a(A,I*8+8),v.nodeType===3&&a(A,v.data.length*8),v.nodeType===1&&An.has(v.tagName)&&!r(v)&&!c(v)&&v.firstChild){v=v.firstChild,I++;continue}for(;v&&v!==x&&!v.nextSibling;)v=v.parentNode,I--;v=!v||v===x?null:v.nextSibling}let M=nn(Array.from(x.childNodes),{ignored:r,remoteWins:c});return S.set(x,M),M},d=(x,A,v,I,M,P)=>{for(let D of x.atoms){a(P,1);let $=A.atomAt.get(D.i+v);if(!$)return!1;let W=I?.reverse.get(D.el)||s(D.el),B=M?.reverse.get($.el)||s($.el);if(W!==B)return!1}return!0},w=(x,A,v,I,M)=>{let P=x.text.length<=A.text.length?x:A,D=P===x?A:x;if(a(M,P.text.length+D.text.length),!P.text||!Fn.test(P.text.replaceAll(Vn,"")))return!1;let $;if(P.text===D.text)$=0;else{let W=D.text.length-P.text.length;if(a(M,(W+1)*P.text.length*2),D.text.startsWith(P.text))$=0;else if(D.text.endsWith(P.text))$=W;else return!1;if(D.text.indexOf(P.text)!==$||D.text.lastIndexOf(P.text)!==$)return!1;a(M,D.text.length*2);let B=0,k=$===0,T=!1;for(let J of an(D.text,Tn(D.text)))B+=J.len,B===$&&(k=!0),B===$+P.text.length&&(T=!0);if(!k||!T)return!1}return P===x?d(P,D,$,v,I,M):d(P,D,$,I,v,M)},O=null;for(let x=0;x<2;x++){let{V:A,A:v,idOf:I}=t[x],M=t[1-x];if(!A.asBase)for(let P=0;P<e.length;P++){let D=e[P];if(A.twin(D)||!n(D))continue;let $=M.V.twin(D);if(!$||!p[1-x].has($)||!n($))continue;let W={remaining:l};try{let B=f[P],k=u[P],T=0;for(let Ee=B+1;Ee<k;Ee++)a(W,1),!A.twin(e[Ee])&&M.V.twin(e[Ee])&&n(e[Ee])&&T++;if(T!==1||g(D,W).text===g($,W).text)continue;let J=B<0?-1:p[x].get(A.twin(e[B])),H=k===e.length?A.units.length:p[x].get(A.twin(e[k]));if(J===void 0||H===void 0||J>=H)continue;let F=null;for(let Ee=J+1;Ee<H;Ee++){a(W,1);let Me=A.units[Ee];if(A.baseOf(Me)||!n(Me)||Me.tagName!==D.tagName||Me.namespaceURI!==D.namespaceURI)continue;let je=o(D),ae=M.idOf($),Ae=I(Me);if(!(je&&ae&&je!==ae||je&&Ae&&je!==Ae||ae&&Ae&&ae!==Ae)&&w(g($,W),g(Me,W),M.A,v,W)){if(F){F=null;break}F=Me}}if(!F)continue;O||(O=[new Map,new Map]),O[x].set(D,F)}catch(B){if(B!==i)throw B}}}return O?t.map(({V:x},A)=>{let v=O[A];if(!v.size)return x;let I=new Map;for(let[M,P]of v)I.set(P,M);return{...x,twin:M=>v.get(M)||x.twin(M),baseOf:M=>I.get(M)||x.baseOf(M)}}):null}function pl({onUncertainSource:e,onUncertainOwner:t,base:n,views:o,eligible:r,ignored:c,remoteWins:s,baseId:l,atomKey:i,limit:a=2e4*32}){if(a<=0)return null;let p=new Set(n),f=new Map(n.map((B,k)=>[B,k])),u=new Map,y=[],b=null,S=null,g=null,d=new Set;for(let B of n)for(let{V:k}of o){let T=k.twin(B);T&&!k.asBase&&!k.here(T)&&d.add(B)}let w=new Set,O=Symbol(),x=(B,k)=>{if(k>B.remaining)throw O;B.remaining-=k},A=(B,k,T)=>{x(T,1);let J=u.get(B);if(J)return J;if(B.nodeType===1){let Ee=B.firstChild,Me=1;for(;Ee;){if(x(T,Me*8+8),Ee.nodeType===3&&x(T,Ee.data.length*8),Ee.nodeType===1&&An.has(Ee.tagName)&&!c(Ee)&&!s(Ee)&&Ee.firstChild){Ee=Ee.firstChild,Me++;continue}for(;Ee&&Ee!==B&&!Ee.nextSibling;)Ee=Ee.parentNode,Me--;Ee=!Ee||Ee===B?null:Ee.nextSibling}}else x(T,B.value.length*8+B.nodes.length);let H=B.nodeType===1?Array.from(B.childNodes):B.nodes,F=H.length===1&&H[0].nodeType===3?{text:H[0].data,nodes:[{node:H[0],s:0,e:H[0].data.length}],atoms:[]}:nn(H,{ignored:c,remoteWins:s});return J={unit:B,flat:F,alignment:k,tokens:null},u.set(B,J),J},v=(B,k)=>{if(B.tokens)return B.tokens;x(k,B.flat.text.length*8);let{unit:T,flat:J,alignment:H}=B,F=[],Ee=Tn(J.text),Me=0,je=ae=>{for(let Ae of an(J.text.slice(Me,ae),Ee))Ae.from=Me,Ae.to=Me+Ae.len,Ae.unit=T,F.push(Ae),Me+=Ae.len};for(let ae of J.atoms){je(ae.i);let Ae=s(ae.el)&&ae.el.nodeType===1?"w"+ae.el.tagName+"#"+(ae.el.id||""):i(H?.reverse.get(ae.el)||ae.el);F.push({k:Ae,raw:Vn,len:1,from:Me,to:Me+1,unit:T,atom:!0}),Me++}return je(J.text.length),B.tokens=F,F},I=(B,k,T,J,H)=>{if(!B.flat.atoms.length&&!k.flat.atoms.length)return!0;let F=v(B,H),Ee=v(k,H);x(H,F.length+Ee.length);let Me=0;for(let je of Ee){if(!je.atom||je.from<T||je.from>=T+J)continue;for(;Me<F.length&&!F[Me].atom;)Me++;let ae=F[Me++];if(!ae||ae.from!==je.from-T||ae.k!==je.k)return!1}for(;Me<F.length;)if(F[Me++].atom)return!1;return!0},M=(B,k,T)=>{let J=B.length+k.length+4;if(J*8>T.remaining)return null;T.remaining-=J*8;let H=Math.floor(T.remaining/8),F=Math.min(B.length+k.length,4e3,Math.floor((Math.sqrt(J*J+H)-J)/2)),Ee=4*(F+1)*(J+F+1);if(F<1||Ee>T.remaining)return null;T.remaining-=Ee;let Me=Xn(B,k,F),je=[],ae=0,Ae=0;for(let Ve of Me.hunks){for(;ae<Ve.bs;)B[ae].raw===k[Ae].raw&&je.push([B[ae],k[Ae]]),ae++,Ae++;ae=Ve.be,Ae+=Ve.toks.length}for(;ae<B.length&&Ae<k.length;)B[ae].raw===k[Ae].raw&&je.push([B[ae],k[Ae]]),ae++,Ae++;return je},P=(B,k,T,J,H,F,Ee)=>{if(H<=J)return;let Me=B[B.length-1];if(Me&&Me.source===k&&Me.target===T&&Me.to<=J&&Me.targetFrom-Me.from===F-J){x(Ee,(J-Me.to)*3);let je=u.get(k).flat.text,ae=u.get(T).flat.text,Ae=!0;for(let Ve=Me.to;Ve<J;Ve++)if(!bn.test(je[Ve])||je[Ve]!==ae[F+Ve-J]){Ae=!1;break}if(Ae){Me.to=H;return}}B.push({source:k,target:T,from:J,to:H,targetFrom:F})},D=B=>B.replace(Ua,"");for(let B=0;B<o.length;B++){let{V:k,A:T,idOf:J}=o[B];if(k.asBase)continue;let H=new Map(k.units.map((N,Y)=>[N,Y])),F=N=>{let Y=k.twin(N);return Y&&H.has(Y)?Y:null},Ee=(N,Y)=>{let le=new Int32Array(N.length),oe=new Int32Array(N.length),Re=-1;for(let Be=0;Be<N.length;Be++)le[Be]=Re,Y(N[Be])&&(Re=Be);Re=N.length;for(let Be=N.length-1;Be>=0;Be--)oe[Be]=Re,Y(N[Be])&&(Re=Be);return{prev:le,next:oe}},Me=Ee(n,N=>(N.nodeType===1||N.kind==="text"&&Fn.test(N.value))&&F(N)),je=Ee(k.units,N=>(N.nodeType===1||N.kind==="text"&&Fn.test(N.value))&&p.has(k.baseOf(N))),ae=new Map,Ae=(N,Y,le,oe)=>{if(N>Y||le>oe)return;let Re=`${N}:${Y}:${le}:${oe}`;ae.set(Re,[N,Y,le,oe])};for(let N=0;N<k.units.length;N++){let Y=k.units[N];if(k.baseOf(Y)||!r(Y))continue;let le=je.prev[N],oe=je.next[N],Re=le<0?0:f.get(k.baseOf(k.units[le])),Be=oe===k.units.length?n.length-1:f.get(k.baseOf(k.units[oe]));Ae(Re,Be,Math.max(0,le),Math.min(k.units.length-1,oe))}for(let N=0;N<n.length;N++){let Y=n[N];if(d.has(Y)||!r(Y))continue;if(!k.twin(Y)){let nt=Me.prev[N],Ye=Me.next[N],ht=nt<0?0:H.get(F(n[nt])),Ge=Ye===n.length?k.units.length-1:H.get(F(n[Ye]));Ae(Math.max(0,nt),Math.min(n.length-1,Ye),ht,Ge)}let le=F(Y);if(!le||T.identical.has(Y)||!r(le))continue;let oe=N+1;for(;oe<n.length&&n[oe].kind==="text"&&!n[oe].value.trim();)oe++;if(oe>=n.length||!r(n[oe]))continue;let Re=F(n[oe]);if(!Re||T.identical.has(n[oe])||!r(Re))continue;let Be=H.get(le),Se=H.get(Re);Be<Se&&Ae(N,oe,Be,Se)}let Ve=Array.from(ae.values()),ve=new Set;if(Ve.length>1){let N=zt(a);try{x(N,Ve.length*4);let Y=Ve.slice().sort((Re,Be)=>(x(N,1),Re[0]-Be[0]||Re[2]-Be[2])),le=[],oe=null;for(let Re of Y)x(N,1),oe&&Re[0]<=oe[1]&&Re[2]<=oe[3]&&Re[3]>=oe[2]?(oe[1]=Math.max(oe[1],Re[1]),oe[2]=Math.min(oe[2],Re[2]),oe[3]=Math.max(oe[3],Re[3]),oe[4].push(Re)):(oe?.[4].length>1&&le.push(oe),oe=[Re[0],Re[1],Re[2],Re[3],[Re]]);oe?.[4].length>1&&le.push(oe),Ve=le.concat(Ve)}catch(Y){if(Y!==O)throw Y}}for(let N of Ve){if(ve.has(N))continue;let[Y,le,oe,Re,Be]=N,Se=zt(a),nt=[],Ye=new Set,ht=!1;try{x(Se,(le-Y+Re-oe+2)*4);let Ge=n.slice(Y,le+1).filter(j=>!T.identical.has(j)&&r(j)&&!d.has(j)),st=k.units.slice(oe,Re+1).filter(j=>r(j)&&(!k.baseOf(j)||p.has(k.baseOf(j)))&&!T.identical.has(k.baseOf(j))&&!d.has(k.baseOf(j))),Mt=new Set(st),It=!1,yt="",Nt="",Ct=0;for(let j of Ge){let ue=A(j,null,Se);yt+=ue.flat.text,Ct+=ue.flat.text.length}for(let j of st){let ue=A(j,T,Se);Nt+=ue.flat.text,Ct+=ue.flat.text.length}x(Se,Ct);let Vt=D(yt),fn=D(Nt),Et=Vt===fn;if(ht=Et,Be&&!Et)continue;let Gt=Et?null:new Map;if(Gt)for(let j of Ge.concat(st)){let ue=u.get(j).flat.text.length;x(Se,ue*16),Gt.set(j,new Uint8Array(ue))}let wn=j=>{let ue=[];for(let be of j){let ie=u.get(be);ie.flat.atoms.length?ue.push(...v(ie,Se)):ue.push({unit:be,raw:ie.flat.text,from:0})}return ue},Bt=[];for(let j of Et?[]:Ge){let ue=F(j);if(!Mt.has(ue))continue;let be=A(j,null,Se),ie=A(ue,T,Se);x(Se,be.flat.text.length+ie.flat.text.length);let Ne=be.flat.text&&ie.flat.text.startsWith(be.flat.text)?0:be.flat.text&&ie.flat.text.endsWith(be.flat.text)?ie.flat.text.length-be.flat.text.length:-1;if(Ne>=0&&I(be,ie,Ne,be.flat.text.length,Se)){Gt.get(j).fill(1),Gt.get(ue).fill(1,Ne,Ne+be.flat.text.length),P(Bt,j,ue,0,be.flat.text.length,Ne,Se);continue}let U=M(v(be,Se),v(ie,Se),Se);if(!U){It=!0;break}for(let[X,he]of U)Gt.get(j).fill(1,X.from,X.to),Gt.get(ue).fill(1,he.from,he.to),P(Bt,j,ue,X.from,X.to,he.from,Se)}if(It)continue;let ln=null,Xt=null;if(!Et)for(let j of Ge){let ue=F(j),be=u.get(j);if(!ue||be.flat.atoms.length||!Mt.has(ue))continue;let ie=be.flat.text,Ne=Gt.get(j);x(Se,ie.length*3+st.length);let U=-1,X=-1,he=!1;for(let Le=0;Le<ie.length;Le++)bn.test(ie[Le])||(Ne[Le]?he=!0:(U<0&&(U=Le),X=Le+1));if(!he||U<0)continue;let ge=!0;for(let Le=U;Le<X;Le++)if(Ne[Le]&&!bn.test(ie[Le])){ge=!1;break}if(!ge)continue;let de=D(ie.slice(U,X)),ee=null,te=!1;for(let Le of st){if(k.baseOf(Le))continue;let ke=u.get(Le);if(!ke.flat.atoms.length&&(x(Se,ke.flat.text.length),D(ke.flat.text)===de)){if(ee){te=!0;break}ee=Le}}if(te){(Xt||=new Set).add(j);continue}if(!ee||Xt?.has(j))continue;let K=!1;for(let Le of Ge){if(Le===j||!Mt.has(F(Le)))continue;let ke=u.get(Le);if(ke.flat.atoms.length)continue;let $e=Gt.get(Le);x(Se,ke.flat.text.length*3);let Je="",Qe=!1;for(let Ut=0;Ut<ke.flat.text.length;Ut++)bn.test(ke.flat.text[Ut])||($e[Ut]?Qe=!0:Je+=ke.flat.text[Ut]);Qe&&Je===de&&(Xt||=new Set,Xt.add(j),Xt.add(Le),K=!0)}if(K)continue;let ne=u.get(ee).flat.text;x(Se,X-U+ne.length);let xe=U,Ie=0;for(;xe<X&&Ie<ne.length;){for(;xe<X&&bn.test(ie[xe]);)xe++;for(;Ie<ne.length&&bn.test(ne[Ie]);)Ie++;if(xe>=X||Ie>=ne.length)break;P(ln||=[],j,ee,xe,xe+1,Ie,Se),xe++,Ie++}Ne.fill(1,U,X),Gt.get(ee).fill(1)}let un=j=>{let ue=[];for(let be of j){let ie=A(be,p.has(be)?null:T,Se),Ne=Gt.get(be);for(let U of v(ie,Se)){let X=U.from;for(;X<U.to;){for(;X<U.to&&Ne[X];)X++;let he=X;for(;X<U.to&&!Ne[X];)X++;if(X>he){let ge=ie.flat.text.slice(he,X);Fn.test(ge)&&ue.push({...U,raw:ge,len:X-he,k:U.atom?U.k:ge,from:he,to:X})}}}}return ue},z=Et?wn(Ge):un(Ge),h=Et?wn(st):un(st),E=Et?Vt:z.map(j=>D(j.raw)).join(""),R=Et?fn:h.map(j=>D(j.raw)).join("");if((!E||!R)&&!ln)continue;let _=ln||[];if(E&&R&&E===R){let j=0,ue=0,be=0,ie=0;for(;j<z.length&&ue<h.length;){let Ne=z[j],U=h[ue];for(;be<Ne.raw.length&&bn.test(Ne.raw[be]);)be++;for(;ie<U.raw.length&&bn.test(U.raw[ie]);)ie++;if(be===Ne.raw.length){j++,be=0;continue}if(ie===U.raw.length){ue++,ie=0;continue}if((Ne.atom||U.atom)&&Ne.k!==U.k){It=!0;break}P(_,Ne.unit,U.unit,Ne.from+be,Ne.from+be+1,U.from+ie,Se),be++,ie++}}else if(E&&R){let j=M(z,h,Se);if(!j)continue;for(let[ue,be]of j)P(_,ue.unit,be.unit,ue.from,ue.to,be.from,Se)}if(It)continue;let Q=new Map;for(let j of _)if(!Xt?.has(j.source)){if(F(j.source)===j.target){Et&&Bt.push(j);continue}Q.has(j.source)||Q.set(j.source,[]),Q.get(j.source).push(j)}for(let[j,ue]of Q){let be=A(j,null,Se),ie=F(j),Ne=be.flat.text,U=[],X=new Set,he=o[1-B],ge=he.V.twin(j),de=ge&&he.V.here(ge)?A(ge,he.A,Se):null,ee=(ke,$e)=>{let Je=v(ke,Se),Qe=v($e,Se);return x(Se,ke.flat.text.length+$e.flat.text.length+Je.length+Qe.length),ke.flat.text===$e.flat.text&&Je.length===Qe.length&&Je.every((Ut,Pt)=>Ut.k===Qe[Pt].k)},te=ie&&de&&de.flat.text!==Ne&&ee(A(ie,T,Se),de);for(let ke of new Set(ue.map($e=>$e.target))){if(j.nodeType!==1&&ke.nodeType!==1)continue;let $e=A(ke,T,Se),Je=k.baseOf(ke);if(j.nodeType!==1&&Je||(x(Se,Ne.length*2+$e.flat.text.length*3+Bt.length*2),ie&&D(Ne)===D($e.flat.text)&&A(ie,T,Se).flat.text.trim()))continue;if(!ie&&!Je&&j.nodeType===1&&ke.nodeType===1){let G=l(j),se=J(ke);if(G&&se&&G!==se)continue}let Qe=$e.flat.text,Ut=Ne&&(Qe.startsWith(Ne)||Qe.endsWith(Ne)),Pt=!1;if(!ie&&de&&Je&&de.flat.text!==Ne){let G=A(Je,null,Se).flat.text,se=f.get(j)<f.get(Je)?de.flat.text:G,me=f.get(j)<f.get(Je)?G:de.flat.text;x(Se,se.length+me.length+Qe.length),Pt=!!se&&!!me&&se.length+me.length<=Qe.length&&Qe.startsWith(se)&&Qe.endsWith(me)&&!Qe.slice(se.length,Qe.length-me.length).trim()}let C=!be.flat.atoms.length&&!de?.flat.atoms.length&&!$e.flat.atoms.length&&(te&&Ut||Pt);if(ie&&Je){let G=A(ie,T,Se).flat.text,se=Ne.startsWith(G)||Ne.endsWith(G),me=A(Je,null,Se).flat.text,ye=$e.flat.text,ce=ye.startsWith(me)||ye.endsWith(me),re=!o[1-B].V.twin(Je)&&!Bt.some(Oe=>Oe.source===Je&&Fn.test(me.slice(Oe.from,Oe.to)));if(!Et&&(!se&&!C||!ce&&!re)){let Oe=_a(j,ke,ue,Ge,st,u,Gt,v,x,Se);if(!Oe)continue;let Pe=T.weak?.has(j)&&!T.identityPaired?.has(j)&&Ne.trim()===Oe;if(!se&&!C&&!Pe)continue;let We=T.weak?.has(Je)&&!T.identityPaired?.has(Je)&&Qe.trim()===Oe&&!u.get(Je).flat.atoms.length&&!Bt.some(qe=>qe.source===Je&&Fn.test(me.slice(qe.from,qe.to)));if(!ce&&!re&&!We&&!Va(Je,ke,me,Qe,Bt,v($e,Se),x,Se))continue;Pe&&X.add(ke)}}C&&X.add(ke),x(Se,ue.length),U.push(...ue.filter(G=>G.target===ke))}if(!U.length)continue;let K=new Uint8Array(Ne.length);x(Se,Ne.length*4+Bt.length);for(let ke of U)K.fill(1,ke.from,ke.to);let ne=[];for(let ke=0;ke<Ne.length;ke++)bn.test(Ne[ke])||ne.push(ke);if(!ne.length)continue;let xe=new Set(U.map(ke=>ke.target));if(!Et&&ie&&xe.size>1&&Ha(xe,_,Bt,k,u,Se,x)){if(g||=new Map,g.set(j,(g.get(j)||0)|1<<B),e){let ke=gs({source:j,side:B,views:o,eligible:r,blocked:d,baseId:l,model:A,tokensOf:v,budget:Se,charge:x});if(ke){x(Se,ke.to-ke.from);let $e=!0;for(let Je=ke.from;Je<ke.to;Je++)if(Fn.test(Ne[Je])&&!K[Je]){$e=!1;break}$e&&(b||=[]).push(ke)}}continue}let Ie=ne.filter(ke=>Ms.test(Ne[ke]));if(!U.some(ke=>Ms.test(Ne.slice(ke.from,ke.to)))&&!ne.every(ke=>K[ke]))continue;if(!ie&&!Array.from(xe).some(ke=>X.has(ke))&&!ne.every(ke=>K[ke])&&!(Ie.length&&K[Ie[0]]&&K[Ie[Ie.length-1]]&&xe.size===1)){let ke=null,$e=0,Je=0,Qe=null,Ut=null;if(!ie&&de&&j.nodeType===1&&!be.flat.atoms.length){let Pt=v(be,Se).filter(C=>Ms.test(C.raw));x(Se,st.length+Ne.length);for(let C of st){let G=k.baseOf(C);if(!G||G===j||G.nodeType!==1||C.nodeType!==1||G.tagName!==j.tagName||C.tagName!==G.tagName)continue;let se=f.get(j),me=f.get(G),ye=!0;for(let tt=Math.min(se,me)+1;tt<Math.max(se,me);tt++){let qt=n[tt];if(x(Se,qt.nodeType===1?1:qt.value.length+1),qt.nodeType===1||qt.value.trim()){ye=!1;break}}if(!ye)continue;let ce=A(G,null,Se),re=A(C,T,Se);if(ce.flat.atoms.length||re.flat.atoms.length)continue;let Oe=ce.flat.text,Pe=re.flat.text;if(x(Se,Oe.length+Pe.length+Ne.length),!Oe||!Pt.length)continue;let We=0,qe=Pe.length;if(se<me&&Pe.endsWith(Oe))qe-=Oe.length;else if(se>me&&Pe.startsWith(Oe))We=Oe.length;else continue;for(;We<qe&&bn.test(Pe[We]);)We++;for(;qe>We&&bn.test(Pe[qe-1]);)qe--;let pt=Pe.slice(We,qe);if(!(!pt||!(pt.startsWith(Pt[0].raw)||pt.endsWith(Pt[Pt.length-1].raw)))){if(ke){ke=null;break}ke=C,$e=We,Je=qe,Qe=Pt[0],Ut=Pt[Pt.length-1]}}}if(x(Se,U.length),!ke||!xe.has(ke)||!U.some(Pt=>Pt.target===ke&&(Pt.from<=Qe.from&&Pt.to>=Qe.to&&Pt.targetFrom+Qe.from-Pt.from===$e||Pt.from<=Ut.from&&Pt.to>=Ut.to&&Pt.targetFrom+Ut.to-Pt.from===Je)))continue}if(ie&&!(ne.every(ke=>K[ke])&&(Et||Array.from(xe).some(ke=>X.has(ke))))&&!Bt.some(ke=>ke.source===j&&Fn.test(Ne.slice(ke.from,ke.to))))continue;let Le=!1;if(Et){x(Se,Bt.length+ne.length);for(let ke of Bt)ke.source===j&&(x(Se,ke.to-ke.from),K.fill(1,ke.from,ke.to));Le=!0;for(let ke of ne)if(!K[ke]){Le=!1;break}}for(let ke of xe){x(Se,U.length);let $e=U.filter(Qe=>Qe.target===ke);nt.push({side:B,source:j,target:ke,runs:$e,models:u,retained:Bt,conservedSource:Le}),j.nodeType===1&&Ye.add(j),ke.nodeType===1&&Ye.add(ke);let Je=k.baseOf(ke);Je?.nodeType===1&&Ye.add(Je)}}if(y.push(...nt),Be&&nt.length)for(let j of Be)ve.add(j);for(let j of Ye)w.add(j)}catch(Ge){if(Ge!==O)throw Ge}finally{if(t&&!Be&&!ht){let Ge=dl({base:n,views:o,side:B,attempt:N,eligible:r,blocked:d,baseId:l,model:A,tokensOf:v,charge:x,exhausted:O,limit:a});Ge&&(S||=[]).push(...Ge)}if(e&&!Be&&!ht){let Ge=Oi({base:n,views:o,side:B,attempt:N,eligible:r,blocked:d,baseId:l,model:A,tokensOf:v,certificates:y,charge:x,exhausted:O,limit:a});Ge&&(b||=[]).push(...Ge)}}}}let $=y.length?new Map:null;for(let B of y){let k=$.get(B.source);k||$.set(B.source,k=[]),k.push(B)}let W=null;if($){let B=null;for(let[k,T]of $){let J=g?.get(k)||0;if(T.length<2&&!J)continue;let H=0;for(let F of T)F.conservedSource&&(H|=1<<F.side);for(let F of T){if(F.conservedSource)continue;let Ee=1<<F.side,Me=!0;if(H&Ee)Me=!1;else if(J&Ee){Me=!1;try{Me=Wa(F,B||=zt(a),x)}catch(je){if(je!==O)throw je}}Me||(W||=new Set).add(F)}}}if(W){let B=0;for(let k of y)W.has(k)||(y[B++]=k);y.length=B;for(let[k,T]of $){B=0;for(let J of T)W.has(J)||(T[B++]=J);T.length=B,B||$.delete(k)}w.clear();for(let k of y){let{source:T,target:J,side:H}=k;T.nodeType===1&&w.add(T),J.nodeType===1&&w.add(J);let F=o[H].V.baseOf(J);F?.nodeType===1&&w.add(F)}}if(b){let B=zt(a),k=!1;for(let T of b){let J=!1,H=$?.get(T.source);if(H&&!k)try{J=ms(T,H,B,x)}catch(F){if(F!==O)throw F;k=!0}J||e(T)}}if(S){let B=new Set,k=zt(a);try{for(let T of S){if(x(k,1),B.has(T.source))continue;B.add(T.source);let J=!1;for(let H of y)if(x(k,1),H.source===T.source||H.target===T.local||H.target===T.remote){J=!0;break}J||t(T)}}catch(T){if(T!==O)throw T}}for(let B of n)if(w.has(B))for(let{V:k}of o){let T=k.twin(B);T&&k.here(T)&&w.add(T)}return y.length?{blocks:w,certificates:y,certificatesBySource:$,models:u}:null}function ml({certificates:e,scopes:t,flats:n,keys:o,limit:r=2e4*32}){let c=Symbol(),s=zt(r),l=g=>{if(g>s.remaining)throw c;s.remaining-=g},i=t.map(g=>new Set(g)),a=new Map,p=new Map,f=(g,d)=>{let w=a.get(g);if(w||a.set(g,w=new Map),w.has(d))return w.get(d);l(g.text.length);let O=p.get(d);if(!O){l(d.nodes.length+d.atoms.length),O={nodes:new Map,atoms:new Map};for(let I of d.nodes)O.nodes.set(I.node,I);for(let I of d.atoms)O.atoms.set(I.el,I.i);p.set(d,O)}let{nodes:x,atoms:A}=O,v=new Int32Array(g.text.length).fill(-1);for(let I of g.nodes){let M=x.get(I.node);if(!(!M||I.e-I.s!==M.e-M.s)){l(I.e-I.s);for(let P=I.s;P<I.e;P++)v[P]=M.s+P-I.s}}for(let I of g.atoms){let M=A.get(I.el);M!==void 0&&(v[I.i]=M)}return w.set(d,v),v},u=(g,d,w,O,x)=>{let A=g[g.length-1];A&&A.to===d&&A.target+A.to-A.from===O&&A.kind===x?A.to=w:g.push({from:d,to:w,target:O,kind:x})},y=(g,d,w,O)=>{l((O-w)*4);let x=[],A=w,v=P=>{let D=g.text.slice(A,P);for(let $ of an(D,Tn(D)))$.from=A,$.to=A+$.len,x.push($),A+=$.len},I=0,M=g.atoms.length;for(;I<M;){l(1);let P=I+M>>>1;g.atoms[P].i<w?I=P+1:M=P}for(let P=I;P<g.atoms.length&&g.atoms[P].i<O;P++){l(1);let D=g.atoms[P];v(D.i),x.push({k:d(D),raw:Vn,len:1,from:A,to:A+1}),A++}return v(O),x},b=(g,d,w,O,x,A)=>{if(w===O||x===A)return;if(O-w===A-x){l((O-w)*4);let k=!0;for(let T=w,J=x;T<O;T++,J++){if(n[0].text[T]!==n[d].text[J]){k=!1;break}let H=n[0].atomAt.get(T),F=n[d].atomAt.get(J);if(!!H!=!!F||H&&o[0](H)!==o[d](F)){k=!1;break}}if(k){u(g,w,O,x,"retained");return}}let v=y(n[0],o[0],w,O),I=y(n[d],o[d],x,A),M=v.length+I.length+4,P=Math.min(v.length+I.length,4e3,Math.floor((Math.sqrt(M*M+s.remaining/2)-M)/2));if(P<1)throw c;l(4*(P+1)*(M+P+1));let D=Xn(v,I,P),$=0,W=0,B=()=>{let k=v[$++],T=I[W++];l(k.len),k.raw===T.raw&&u(g,k.from,k.to,T.from,"retained")};for(let k of D.hunks){for(;$<k.bs;)B();$=k.be,W+=k.toks.length}for(;$<v.length&&W<I.length;)B()},S=g=>{let d=e.filter(D=>D.side===g-1&&i[0].has(D.source)&&i[g].has(D.target));if(!d.length)return null;let w=[],O=(D,$,W)=>{if(!i[0].has(D.source)||!i[g].has(D.target))return;let B=f($.get(D.source).flat,n[0]),k=f($.get(D.target).flat,n[g]);l(D.to-D.from);for(let T=0;T<D.to-D.from;T++){let J=B[D.from+T],H=k[D.targetFrom+T];if(J<0||H<0)throw c;u(w,J,J+1,H,W)}},x=new Set;for(let D of d){if(!x.has(D.retained)){x.add(D.retained);for(let $ of D.retained)O($,D.models,"retained")}for(let $ of D.runs)O($,D.models,"transfer")}w.sort((D,$)=>(l(1),D.from-$.from||D.target-$.target));let A=[];for(let D of w){l(1);let $=A[A.length-1];if($&&D.from<$.to){if(D.target-D.from!==$.target-$.from)throw c;$.to=Math.max($.to,D.to),D.kind==="transfer"&&($.kind="transfer")}else A.push(D)}let v=[],I=0,M=0;for(let D of A){if(D.target<M)throw c;b(v,g,I,D.from,M,D.target),v.push(D),I=D.to,M=D.target+D.to-D.from}b(v,g,I,n[0].text.length,M,n[g].text.length);let P=_n({base:n[0],side:n[g],retained:v.filter(D=>D.kind==="retained"),transfers:v.filter(D=>D.kind==="transfer"),baseAtomKey:o[0],sideAtomKey:o[g],budget:s});if(P.status!=="ready"||!P.monotone)throw c;return P};try{let g=S(1),d=S(2);return g||d?{local:g,remote:d}:{fallback:!0}}catch(g){if(g!==c)throw g;return{fallback:!0}}}function Es(e,t,n=!1){let o=-1,r=-1;for(let s=0;s<e.list.length;s++){let l=e.list[s];l.bLo<t.lo||l.bLo>t.hi||(o<0&&(o=s),r=s)}let c=[];for(let s=o;s>=0&&s<=r;s++){let l=e.list[s],i=!n&&s===o?l.inlineStart<0?l.to:l.inlineStart:l.from,a=!n&&s===r?l.inlineEnd<0?l.from:l.inlineEnd:l.to;for(let p=i;p<a;p++)c.push(e.units[p]);s<r&&c.push(e.units[l.next])}return c}var it=e=>!!e&&e.nodeType===1,Pn=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function Is(e){for(let t of e)if(Pn.has(t.tagName))return!0;return!1}function qa(e,t,n){let o=null;for(let r of t.childNodes)if(!(!it(r)||!n(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 er="[id],[data-id],script,head>*";function Cs(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let o=Co(n,e);if(o)return"merge:"+o.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?Zi(n,t):null}}function Br(e,t,n,o){let r=o.ignored,c=o.stats||oo(),s=Ti({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:c}),{unitsOf:l,meta:i}=s,a=o.baseURI,p=o.mergeTags!==null,f=Cs(o.mergeTags,a),u=C=>G=>{let se=f(G);return se!==null?se:C(G)},y=u(o.identity.base),b=u(o.identity.local),S=u(o.identity.remote),g=o.authored||o.identity,d=C=>C&&C.nodeType===9?C.documentElement:C,w=d(e),O=d(t),x=d(n),A=globalThis.__hyperMorphProfile,v=A?performance.now():0,I=C=>C===kn?er:null,M=o.scope||null,P=M?M.baseDropped:new Set,D=new Set,$=M?M.remoteDropped:new Set,W=M?M.baseIndex:Nr(w,y,r,I(o.identity.base),P),B=o.localIsBase||w===O?null:Nr(O,b,r,I(o.identity.local),D),k=M?M.remoteIndex:Nr(x,S,r,I(o.identity.remote),$),T=C=>{let G=it(C)&&b(C);return G&&B?.get(G)===C&&!W.has(G)?G:null},J=C=>{let G=it(C)&&S(C);return G&&k.get(G)===C&&!W.has(G)?G:null},H=B?is(w,O,{analyzer:s,baseIndex:W,sideIndex:B,baseId:g.base,sideId:g.local,baseKey:y,sideKey:b,baseDropped:P,sideDropped:D,stats:c}):bl(),F=is(w,x,{analyzer:s,baseIndex:W,sideIndex:k,baseId:g.base,sideId:g.remote,baseKey:y,sideKey:S,baseDropped:P,sideDropped:$,stats:c,scope:M,comparisons:o.comparisons});if(M){if(!M.held(F))return null;for(let C of M.dropped)rs(C)}let Ee=null;function Me(C){if(!Ee){Ee=new WeakMap;let G=[w];for(;G.length;){let se=G.pop();se.tagName==="TEMPLATE"&&se.content&&Ee.set(se.content,se);for(let me of s.childrenOf(se))me.nodeType===1&&G.push(me)}}return Ee.get(C)||null}let je=C=>{let G=it(C)||C.nodeType?C.parentNode:C.parent;return G&&G.nodeType===11?Me(G):G};if(F.moved.size){let C=!1;for(let G of Array.from(F.moved))!it(G)||F.identityPaired.has(G)||!g.base(G)||h(F,je(G))||(F.unpair(G),C=!0);C&&F.rematch()}un(),z(H,F),z(F,H);for(let C of[H,F])if(C.refused)for(let G of C.refused)C.moved.has(G)||c.ambiguousMoves++;A&&(A.alignTotal=(A.alignTotal||0)+(performance.now()-v),v=performance.now());let ae=w.ownerDocument.implementation.createHTMLDocument(""),Ae=new WeakMap,Ve=new WeakMap,ve=[],N=[],Y=new Set,le=[],oe=new Set,Re=new Set,Be=new Set,Se=new WeakMap,nt=null,Ye=o.lineage?.locals.length?Wi():null,ht=C=>{let G=Ir(C);return G&&Ye&&Ye.consume(C.local),G},Ge=o.conflicts||"remote",st=C=>ve.push(C),Mt=C=>ve.push(C),It=il({roots:{base:w,local:O,remote:x},L:H,R:F,unitsOf:l,provenance:Ae,policy:Ge}),yt=(C,G)=>{N.push(C),G&&It.note(C,G)},Nt=null,Ct=null,Vt=ln(),fn=null,Et=j(w,H.map.get(w),F.map.get(w),!!o.localIsBase,!!o.childrenOnly);Et.tagName==="HTML"?ae.replaceChild(Et,ae.documentElement):ae.body.appendChild(Et),Nt?.drain(Et),Ct?.drain(Et),A&&(A.build=(A.build||0)+(performance.now()-v));let Gt=o.childrenOnly?!Le(xe(Et),xe(x)):!te(Et,x),wn=It.finish(Et),Bt=Ye?_i({locals:o.lineage.locals,rec:Ye,root:Et,provenance:Ae,segments:le,ignored:r}):null;return{doc:ae,root:Et,provenance:Ae,textMappers:Ve,decisions:ve,conflicts:N,recoveryLinks:wn,localDiverged:Gt,mergedScripts:Y,segments:le,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==kn,L:H,R:F,stats:c,lineage:Bt};function ln(){let C=new Map,G=new Set;if(o.localIsBase||!H.insertedByHash)return{partner:C,drop:G};let se=H.insertedByHash(),me=F.insertedByHash();if(!se.size||!me.size)return{partner:C,drop:G};let ye={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},ce=lt=>{let ze=0;for(let At=lt.parentNode;At;At=At.parentNode)ze++;return ze},re=[],Oe=lt=>{let ze=lt.textContent.trim();return ze.split(/\s+/).length>=3||ze.replace(/\s/g,"").length>=12},Pe=lt=>{let ze=h(H,lt),At=h(F,lt);return ze&&H.reverse.get(ze.parentNode)!==lt.parentNode||At&&F.reverse.get(At.parentNode)!==lt.parentNode},We=(lt,ze,At)=>{for(let Dt of At.parentNode.children){let yn=Dt!==At&&lt.reverse.get(Dt);if(yn&&Pe(yn))return!0}let at=lt.reverse.get(At.parentNode);if(at){for(let Dt of at.children)if(!h(ze,Dt)&&!r(Dt))return!0}return!1},qe=new Map([[H,new Map],[F,new Map]]),pt=(lt,ze)=>{let At=qe.get(lt),at=At.get(ze);if(at===void 0){at=!1;for(let Dt of ze.children)if(lt.reverse.has(Dt)||pt(lt,Dt)){at=!0;break}At.set(ze,at)}return at},tt=new Map;for(let lt of me.values())for(let ze of lt){let At=J(ze);At&&tt.set(At,ze)}for(let lt of se.values())for(let ze of lt){let At=T(ze),at=At?tt.get(At):null;at&&at.tagName===ze.tagName&&!qn(ze,ye)&&!qn(at,ye)&&!o.remoteWins(ze)&&!o.remoteWins(at)&&re.push([ze,[at],ce(ze),!0,!0])}for(let[lt,ze]of se){let At=me.get(lt);if(!At)continue;let at=ze.length===1&&At.length===1;for(let Dt of ze)!qn(Dt,ye)&&!T(Dt)&&re.push([Dt,At,ce(Dt),at&&(Oe(Dt)||We(H,F,Dt)||We(F,H,At[0]))])}if(!re.length)return{partner:C,drop:G};re.sort((lt,ze)=>lt[2]-ze[2]);let qt=new Set,Wt=new Set,dn=lt=>{for(let ze of lt.querySelectorAll("*"))qt.add(ze)},bt=(lt,ze)=>lt.reverse.get(ze.parentNode)||null;for(let[lt,ze,,At,at]of re){if(qt.has(lt)||Wt.has(lt)||at&&(pt(H,lt)||pt(F,ze[0])))continue;let Dt=bt(H,lt),yn=Yt=>!Wt.has(Yt)&&!qt.has(Yt)&&(at||Yt.tagName===lt.tagName&&!J(Yt)&&s.equalUnits(lt,Yt)),on=ze.find(Yt=>Dt&&bt(F,Yt)===Dt&&yn(Yt))||(At?ze.find(yn):null);if(!on)continue;Wt.add(lt),Wt.add(on);let pn=Dt&&bt(F,on)===Dt;(!at||!pn||s.equalUnits(lt,on))&&(dn(lt),dn(on)),!pn&&(C.set(lt,on),C.set(on,lt),G.add(Ge==="local"?on:lt))}return{partner:C,drop:G}}function Xt(C,G,se){if(oe.add(C),Vt.drop.has(C))return null;oe.add(se);let me=G==="local"?C:se,ye=G==="local"?se:C,ce;return s.equalUnits(me,ye)?(ce=de(me,"local",!0),Ae.get(ce).remote=ye):ce=ge(me,ye),yt({kind:"structure",el:ce,detail:"both-moved",base:null,local:me,remote:ye},{unit:{b:null,l:me,r:ye}}),st({kind:"insert",el:ce,source:"both"}),ce}function un(){if(!H.weak||!F.weak||!H.weak.size||!F.weak.size||!H.unpair)return;let C=new Map;for(let se of H.weak){let me=h(H,se);it(se)&&it(me)&&C.set(s.unitHash(me),se)}let G=!1;for(let se of Array.from(F.weak)){let me=h(F,se);if(!it(se)||!it(me))continue;let ye=C.get(s.unitHash(me));if(!ye||ye===se||!H.weak.has(ye)||h(H,se)&&h(F,ye))continue;let ce=h(H,ye);ce.tagName===me.tagName&&s.equalUnits(ce,me)&&(H.unpair(ye),F.unpair(se),G=!0)}G&&(H.rematch(),F.rematch())}function z(C,G){if(!C.weak||!C.weak.size||!G.insertedByHash)return;let se=G.insertedByHash();if(!se.size)return;let me=!1;for(let ye of Array.from(C.weak)){let ce=h(C,ye);if(!ce)continue;let re=C===H?T(ce):J(ce);if(re){let Pe=(C===H?k:B)?.get(re);Pe&&Pe.tagName===ce.tagName&&!G.reverse.has(Pe)&&(C.unpair(ye),me=!0);continue}let Oe=se.get(s.unitHash(ce));Oe&&Oe.some(Pe=>Pe.tagName===ce.tagName&&s.equalUnits(Pe,ce))&&(C.unpair(ye),me=!0)}me&&C.rematch()}function h(C,G){if(!G)return null;if(C.map.has(G))return C.map.get(G);let se=[],me=je(G);for(;me&&!C.map.has(me);me=je(me))se.push(me);let ye=me;if(!ye||!C.identical.has(ye))return null;C.pairIdenticalChildren(ye);for(let re=se.length-1;re>=0;re--)C.pairIdenticalChildren(se[re]);let ce=C.map.get(G)||null;return ce&&c.lazyTwins++,ce}function E(C,G,se,me){if(it(C)&&Pn.has(C.tagName)&&!H.identical.has(C)&&(C.previousSibling?.nodeType===3||C.nextSibling?.nodeType===3)){let Oe=je(C),Pe=h(H,C),We=h(F,C);Pe&&We&&Ut(Pe,h(H,Oe),H)&&!Ut(We,h(F,Oe),F)&&(Ct||=al({L:H,R:F,twinIn:h,unitsOf:l,view:R,parentOf:je,ignored:r,remoteWins:o.remoteWins,eligible:qe=>it(qe)&&Pn.has(qe.tagName),build:j,out:ae,policy:Ge,provenance:Ae,textMappers:Ve,segments:le,conflicts:N,conflict:yt,decisions:ve}),Ct.ensureOwner(C))}if(G===null)return null;if(me!==void 0)return Nt||=Po(Ae,je,H,F,h,j,r,o.remoteWins,N,yt,_,O,x),Nt.plan(C,G,se,!!me),me&&(Nt.produced(C,me),Re.add(C)),me;if(Re.has(C)||Be.has(C))return yt({kind:"structure",el:null,detail:"both-moved",base:C},{subject:C}),Re.has(C)?null:de(se,G);Nt||=Po(Ae,je,H,F,h,j,r,o.remoteWins,N,yt,_,O,x),Nt.plan(C,G,se,!0);let ye=h(H,C),ce=h(F,C);(!ye||!ce)&&yt({kind:"structure",el:null,detail:"move-beats-delete",base:C},{subject:C,deleted:ye?"remote":"local"});let re=j(C,ye,ce,!1);return(G==="local"?st:Mt)({kind:"move",el:re,source:G}),re}function R(C,G,se,me){return me||!G||G===se?{el:se,asBase:!0,twin:ye=>ye,baseOf:ye=>ye,units:l(se),here:()=>!0,parentOfTwin:()=>se}:{el:G,asBase:!1,twin:ye=>h(C,ye),baseOf:ye=>C.reverse.get(ye),units:l(G),here:ye=>it(ye)?ye.parentNode===G||G.tagName==="TEMPLATE"&&ye.parentNode===G.content:ye.parent===G||G.tagName==="TEMPLATE"&&ye.parent===G.content}}function _(C,G,se){return!G||se&&se.identical.has(C)?!1:it(C)?!s.equalUnits(C,G)||!Q(C,G,se):C.value!==G.value}function Q(C,G,se){if(!se||C===G)return!0;let me=[[C,G]];for(;me.length;){let[ye,ce]=me.pop(),re=l(ye),Oe=l(ce);for(let Pe=0;Pe<re.length&&Pe<Oe.length;Pe++){let We=re[Pe],qe=Oe[Pe];if(!it(We)||!it(qe))continue;let pt=se.map.get(We);if(pt!==void 0&&pt!==qe)return!1;let tt=se.reverse.get(qe);if(tt!==void 0&&tt!==We)return!1;me.push([We,qe])}}return!0}function j(C,G,se,me,ye=!1){let ce=me||(se?o.remoteWins(se):o.remoteWins(C)),re=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ae.createElementNS(C.namespaceURI,C.tagName):ae.createElement(C.tagName),Oe={base:C,local:G||null,remote:se||null};if(Ae.set(re,Oe),ce&&!me&&G&&_(C,G,H)&&(!se||!s.equalUnits(G,se))&&yt({kind:"structure",el:re,detail:"remote-wins",base:C,local:G,remote:se||null},{subject:C}),oe.add(C),Re.add(C),G&&oe.add(G),se&&oe.add(se),o.skipUnchanged&&!ye&&(o.localIsBase||H.identical.has(C))&&se&&F.identical.has(C)&&!o.remoteWins(C)){Oe.unchanged=!0;for(let We of C.attributes)We.namespaceURI?re.setAttributeNS(We.namespaceURI,We.name,We.value):re.setAttribute(We.name,We.value);return Nt?.produced(C,re),re}Be.add(C),ye||ie(C,ce?C:G,se,re);let Pe=C.tagName;if(mn(C))be(C,ce?C:G,se,re);else if(Pe==="TEXTAREA")re.textContent=ue(C.textContent,(ce?C:G)?(ce?C:G).textContent:C.textContent,se?se.textContent:C.textContent,re,"text");else if(!Ct?.render(C,re)){let We=ee(C,G,se,ce,re),qe=Pe==="TEMPLATE"&&re.content?re.content:re;for(let pt of We)qe.appendChild(pt)}return Be.delete(C),Nt?.produced(C,re),re}function ue(C,G,se,me,ye){if(G===se)return G;if(G===C)return se!==C&&Mt({kind:ye,node:me,source:"remote"}),se;if(se===C)return st({kind:ye,node:me,source:"local"}),G;let ce=Ge==="local"?G:se;return yt({kind:ye,node:me,base:C,local:G,remote:se,resolved:ce},{site:"whole",el:me}),ve.push({kind:ye,node:me,source:"both"}),ce}function be(C,G,se,me){let ye=C.textContent,ce=G?G.textContent:ye,re=se?se.textContent:ye,Oe=p?Co(C,o.mergeTags,!0):null;if(Oe&&ce!==re){let Pe=se&&se.getAttribute("merge-key")||C.getAttribute("merge-key"),{text:We,warnings:qe,conflicts:pt}=vs(o.localIsBase?void 0:ye,ce,re,{parse:Oe.recognizer.parse,keyCandidates:Pe?Pe.split(/[\s,]+/).filter(Boolean):void 0});for(let tt of qe)console.warn(`[hyper-morph] merge "${Oe.raw}": ${tt}`);for(let tt of o.localIsBase?[]:pt)yt({kind:"json",node:me,name:Oe.raw,path:tt.path,base:tt.base,local:tt.local,remote:tt.remote,resolved:tt.resolved});me.textContent=We,Y.add(me),We!==re?st({kind:"text",node:me,source:We===ce?"local":"both"}):We!==ye&&Mt({kind:"text",node:me,source:"remote"});return}me.textContent=ue(ye,ce,re,me,"text")}function ie(C,G,se,me){let ye=new Map;for(let ce of[C,G,se])if(ce)for(let re of ce.attributes)o.ignoreAttribute(ce,re.name)||ye.set(re.name,re);for(let[ce,re]of ye){let Oe=C?C.getAttribute(ce):null,Pe=G?G.getAttribute(ce):Oe,We=se?se.getAttribute(ce):Oe,qe;Pe===We?qe=Pe:Pe===Oe?(qe=We,Mt({kind:"attr",el:me,name:ce,source:"remote"})):We===Oe?(qe=Pe,st({kind:"attr",el:me,name:ce,source:"local"})):(qe=Ne(ce,Oe,Pe,We),qe===void 0&&(qe=Ge==="local"?Pe:We,yt({kind:"attr",el:me,name:ce,base:Oe,local:Pe,remote:We,resolved:qe},{el:me,sample:re})),ve.push({kind:"attr",el:me,name:ce,source:"both"})),qe!=null&&(re.namespaceURI?me.setAttributeNS(re.namespaceURI,re.name,qe):me.setAttribute(ce,qe))}}function Ne(C,G,se,me){if(C==="class"){let ye=We=>new Set((We||"").split(/\s+/).filter(Boolean)),ce=ye(G),re=ye(se),Oe=ye(me),Pe=new Set;for(let We of new Set([...ce,...re,...Oe])){let qe=ce.has(We),pt=re.has(We),tt=Oe.has(We);(pt===tt?pt:pt===qe?tt:pt)&&Pe.add(We)}return[...Pe].join(" ")}if(C==="style"){let ye=qe=>{let pt=new Map;if(!qe)return pt;let tt=0,qt=null,Wt="",dn=()=>{let bt=Wt.indexOf(":");bt>0&&pt.set(Wt.slice(0,bt).trim(),Wt.slice(bt+1).trim()),Wt=""};for(let bt of qe){if(qt){Wt+=bt,bt===qt&&(qt=null);continue}if(bt==='"'||bt==="'"){qt=bt,Wt+=bt;continue}if(bt==="("?tt++:bt===")"&&tt--,bt===";"&&tt===0){dn();continue}Wt+=bt}return Wt.trim()&&dn(),pt},ce=ye(G),re=ye(se),Oe=ye(me),Pe=new Map,We=!1;for(let qe of new Set([...ce.keys(),...re.keys(),...Oe.keys()])){let pt=ce.get(qe)??null,tt=re.get(qe)??null,qt=Oe.get(qe)??null,Wt;tt===qt?Wt=tt:tt===pt?Wt=qt:qt===pt?Wt=tt:(Wt=Ge==="local"?tt:qt,We=!0),Wt!=null&&Pe.set(qe,Wt)}return We?void 0:[...Pe].map(([qe,pt])=>`${qe}: ${pt}`).join("; ")}}function U(C,G,se,me){let ye=C.value,ce=me?ye:G?G.value:"",re=se?se.value:"";oe.add(C),G&&oe.add(G),se&&oe.add(se);let Oe=Go(ye,ce,re,Ge),Pe=Oe.text===""?null:ae.createTextNode(Oe.text);Pe&&(Ae.set(Pe,{base:C.nodes,local:G?G.nodes:null,remote:se?se.nodes:null}),Ve.set(Pe,Oe.mapLocalOffset)),ce!==ye&&re!==ye?ve.push({kind:"text",node:Pe,source:"both"}):ce!==ye?st({kind:"text",node:Pe,source:"local"}):re!==ye&&Mt({kind:"text",node:Pe,source:"remote"});for(let We of Oe.conflicts)yt({kind:"text",node:Pe,base:ye.slice(We.bs,We.be),local:We.local,remote:We.remote,resolved:We.resolved},{site:"run",bRun:C,lRun:G,rRun:se,node:Pe,c:We});return Pe}function X(C,G){return uo(C,G).every(se=>se.bs===se.be)}function he(C,G){let se=C?C.value:"",me=G?G.value:"",ye;if(se===me||!me?ye=se:se?X(se,me)?ye=me:X(me,se)?ye=se:(ye=Ge==="local"?se:Ge==="both"?se+me:me,yt({kind:"structure",el:null,detail:"insert-collision",local:se,remote:me,resolved:ye},{unit:{b:null,l:C,r:G},localLost:Ge==="remote"})):ye=me,C&&oe.add(C),G&&oe.add(G),ye==="")return null;let ce=ae.createTextNode(ye);return Ae.set(ce,{base:null,local:C?C.nodes:null,remote:G?G.nodes:null}),se?st({kind:"insert",el:ce,source:me&&se===me?"both":"local"}):Mt({kind:"insert",el:ce,source:"remote"}),ce}function ge(C,G){let se={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},me=Oe=>l(Oe).every(Pe=>it(Pe)?qn(Pe,se):Pe.kind==="text"),ye=null;if(me(C)&&me(G)){let Oe=C.textContent,Pe=G.textContent;Oe===Pe||X(Pe,Oe)?ye=G:X(Oe,Pe)&&(ye=C)}if(!ye){let Oe=Ge==="local",Pe=de(Oe?C:G,Oe?"local":"remote",!0),We=Ae.get(Pe);return Oe?We.remote=G:We.local=C,yt({kind:"structure",el:Pe,detail:"insert-collision",local:C,remote:G,resolved:Oe?C:G},{unit:{b:null,l:C,r:G},localLost:!Oe}),Pe}let ce=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ae.createElementNS(C.namespaceURI,C.tagName):ae.createElement(C.tagName);ie(null,C,G,ce),Ae.set(ce,{base:null,local:C,remote:G}),oe.add(C),oe.add(G);let re=ht({base:Array.from(ye.childNodes),local:Array.from(C.childNodes),remote:Array.from(G.childNodes),out:ae,policy:Ge,idOf:{local:b,remote:S},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:Ae,textMappers:Ve,conflicts:N,conflict:yt,scope:{base:null,local:C,remote:G,units:[],at:0},synthetic:!0,decisions:ve,node:ce});le.push(...re.segments);for(let Oe of re.nodes)ce.appendChild(Oe);return ce}function de(C,G,se=!1){if(!se&&it(C)){let re=Vt.partner.get(C);if(re)return Xt(C,G,re)}if(!it(C)){if(C.value==="")return null;let re=C.kind==="comment"?ae.createComment(C.value):ae.createTextNode(C.value);return Ae.set(re,{base:null,local:G==="local"?C.nodes:null,remote:G==="remote"?C.nodes:null}),oe.add(C),re}let me=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?ae.createElementNS(C.namespaceURI,C.tagName):ae.createElement(C.tagName);for(let re of C.attributes)re.namespaceURI?me.setAttributeNS(re.namespaceURI,re.name,re.value):me.setAttribute(re.name,re.value);Ae.set(me,{base:null,local:G==="local"?C:null,remote:G==="remote"?C:null}),oe.add(C);let ye=C.tagName==="TEMPLATE"&&me.content?me.content:me,ce=G==="local"?H:F;for(let re of l(C)){let Oe=it(re)?ce.reverse.get(re):null;if(Oe&&E(Oe,null,null),Oe&&Re.has(Oe)){yt({kind:"structure",el:null,detail:"both-moved",base:Oe},{subject:Oe});continue}if(Oe&&!Be.has(Oe)){let We=h(H,Oe)||null,qe=h(F,Oe)||null;if(We||qe){Nt||=Po(Ae,je,H,F,h,j,r,o.remoteWins,N,yt,_,O,x),Nt.plan(Oe,G,re,!0);let pt=j(Oe,We,qe,!1);G==="local"?st({kind:"move",el:pt,source:"local"}):Mt({kind:"move",el:pt,source:"remote"}),ye.appendChild(pt);continue}}let Pe=de(re,G);Pe&&ye.appendChild(Pe)}if(!se&&Vt.drop.size&&C.tagName==="DIV"&&!ye.firstChild&&!C.attributes.length&&!(G==="local"?b(C):S(C))&&!ce.reverse.has(C)&&!r(C)&&!o.remoteWins(C)){let re=C.firstChild;if(re&&re===C.lastChild&&it(re)&&(Vt.drop.has(re)||fn?.has(re)))return(fn||=new WeakSet).add(C),null}return me}function ee(C,G,se,me,ye){G&&H.identical.has(C)&&H.pairIdenticalChildren(C),se&&F.identical.has(C)&&F.pairIdenticalChildren(C);let ce=R(H,G,C,me),re=R(F,se,C,!1),Oe=l(C),Pe=new Set(Oe),We=new Map;for(let fe=0;fe<Oe.length;fe++)We.set(Oe[fe],fe);let qe=[],pt=new Set,tt=new Map,qt=new Set,Wt=Ye&&[],dn=Ye&&[],bt=new Set,lt=[],ze=null,At=new Map;if(!ce.asBase&&!re.asBase&&!H.identical.has(C)&&!F.identical.has(C))for(let fe of Oe){if(!it(fe)||!Pn.has(fe.tagName))continue;let _e=ce.twin(fe),He=re.twin(fe);_e&&He&&(!ce.here(_e)||!re.here(He))&&E(fe,null,null)}Fo();let at=fe=>{let _e=[];for(let He of fe.units){if(bt.has(He))continue;let et=fe.baseOf(He);et&&Pe.has(et)&&_e.push(et)}return _e},Dt=fe=>at(fe).map(_e=>We.get(_e)),yn=fe=>fe.every((_e,He)=>He===0||_e>=fe[He-1]),on=!ce.asBase&&!yn(Dt(ce)),pn=!re.asBase&&!yn(Dt(re));on&&pn&&yt({kind:"structure",el:ye,detail:"both-reordered",base:C},{subject:C,lKept:at(ce),rKept:at(re)});let Yt=pn||!on?{V:re,A:F,side:"remote",other:ce,otherA:H,otherSide:"local"}:{V:ce,A:H,side:"local",other:re,otherA:F,otherSide:"remote"};on?st({kind:"move",el:null,source:pn?"both":"local",base:C}):pn&&Mt({kind:"move",el:null,source:"remote",base:C});let Dn=ce.asBase?[]:ce.units.filter(fe=>!ce.baseOf(fe)&&!bt.has(fe)&&!Vt.partner.has(fe)),ko=re.asBase?[]:re.units.filter(fe=>!re.baseOf(fe)&&!bt.has(fe)&&!Vt.partner.has(fe)),Bn=new Map;if(Dn.length&&ko.length){let fe=new Map,_e=new Map;for(let Fe of ko){if(it(Fe)){let kt=S(Fe);kt&&fe.set(kt,Fe)}let Ke=s.unitHash(Fe);_e.has(Ke)||_e.set(Ke,[]),_e.get(Ke).push(Fe)}let He=(Fe,Ke)=>{let kt=Fe.units.indexOf(Ke);for(let Xe=kt-1;Xe>=0;Xe--){let rt=Fe.baseOf(Fe.units[Xe]);if(rt)return rt}return"start"},et=new Map,wt=new Map;for(let Fe of ko){let Ke=He(re,Fe);it(Fe)?(wt.has(Ke)||wt.set(Ke,[]),wt.get(Ke).push(Fe)):Fe.kind==="text"&&!et.has(Ke)&&et.set(Ke,Fe)}for(let Fe of Dn){let Ke=null;if(it(Fe)){let Xe=b(Fe);Xe&&fe.has(Xe)&&!Bn.has(fe.get(Xe))&&(Ke=fe.get(Xe))}else if(Fe.kind==="text"){let Xe=et.get(He(ce,Fe));Xe&&!Bn.has(Xe)&&(Ke=Xe)}let kt=!!T(Fe);if(!Ke&&!kt){let Xe=_e.get(s.unitHash(Fe));Xe&&(Ke=Xe.find(rt=>!Bn.has(rt)&&it(rt)===it(Fe)&&(it(rt)?rt.tagName===Fe.tagName&&!J(rt):rt.kind===Fe.kind)&&s.equalUnits(Fe,rt))||null)}if(!Ke&&it(Fe)&&!kt){let Xe=g.local(Fe),rt=(wt.get(He(ce,Fe))||[]).filter(ft=>{let _t=g.remote(ft);return!Bn.has(ft)&&ft.tagName===Fe.tagName&&!J(ft)&&!(Xe&&_t&&Xe!==_t)&&s.similar(Fe,ft)});rt.length===1&&(Ke=rt[0])}Ke&&(Bn.set(Ke,Fe),Bn.set(Fe,Ke))}}let Vo=fe=>{if(Ct?.consumes(fe))return null;if(oe.has(fe)||Nt?.has(fe))return tt.get(fe)||null;let _e=ce.twin(fe),He=re.twin(fe),et=_e&&!ce.asBase&&!ce.here(_e),wt=He&&!re.asBase&&!re.here(He);if(et||wt){if((!_e||!He)&&yt({kind:"structure",el:null,detail:"move-beats-delete",base:fe},{subject:fe,deleted:_e?"remote":"local"}),!Qe(fe))return it(fe)?(Nt||=Po(Ae,je,H,F,h,j,r,o.remoteWins,N,yt,_,O,x),et&&Nt.plan(fe,"local",_e),wt&&Nt.plan(fe,"remote",He)):oe.add(fe),null;yt({kind:"structure",el:null,detail:"both-moved",base:fe},{subject:fe})}if(_e&&!He&&!ce.asBase&&!re.asBase&&it(fe)&&Pn.has(fe.tagName)&&!o.remoteWins(fe)&&!o.remoteWins(_e)&&_(fe,_e,H)&&qa(fe,xe(re.el),r)){let rt={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},ft=_t=>it(_t)?qn(_t,rt):_t.kind==="text";if(l(fe).every(ft)&&l(_e).every(ft)){let _t=ht({base:[fe],local:[_e],remote:[],blocks:new Set([fe,_e]),out:ae,policy:Ge,L:H,R:F,idOf:{base:y,local:b,remote:S},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Zt,Sn,eo)=>j(Zt,Sn,eo,!1),cloneUnit:de,mergeAttrs:ie,atomKey:s.exactUnitKey,moveIn:E,moveBuilt:E,movePlanned:E,provenance:Ae,textMappers:Ve,conflicts:N,conflict:yt,scope:{base:C,local:ce.el,remote:re.el,units:Oe,at:We.get(fe)},decisions:ve,node:ye});le.push(..._t.segments),oe.add(fe),oe.add(_e);let Ot=ae.createDocumentFragment();for(let Zt of _t.nodes)Ot.appendChild(Zt);return tt.set(fe,Ot),tt.set(_e,Ot),Ot}}if(!_e&&!He)return oe.add(fe),Mt({kind:"remove",source:"both",base:fe}),null;if(!_e&&!_(fe,He,F))return oe.add(fe),st({kind:"remove",source:"local",base:fe}),null;if(!He&&!_(fe,_e,H))return oe.add(fe),Mt({kind:"remove",source:"remote",base:fe}),Ye&&(Ye.remove(_e),Wt.push({bk:fe,lk:_e})),null;let Fe=!_e||!He,Ke=ce.asBase?h(H,fe)||null:_e,kt=re.asBase&&it(fe)&&(F.identityPaired.has(fe)||!g.base(fe))&&h(F,fe)||He,Xe;return it(fe)?Xe=j(fe,Ke,kt,ce.asBase):fe.kind==="comment"?Xe=$e(fe,Ke,He,ce.asBase):Xe=U(fe,Ke,He,ce.asBase),oe.add(fe),Xe&&(tt.set(fe,Xe),_e&&tt.set(_e,Xe),He&&tt.set(He,Xe),Fe&&(yt({kind:"structure",el:Xe,detail:"edit-beats-delete",base:fe},{subject:fe,deleted:_e?"remote":"local"}),_e?st({kind:"insert",el:Xe,source:"local"}):Mt({kind:"insert",el:Xe,source:"remote"}))),Xe},Zn=(fe,_e,He,et)=>{if(Ct?.consumes(fe))return null;if(oe.has(fe))return tt.get(fe)||null;let wt=_e.baseOf(fe);if(wt&&Pe.has(wt))return bt.has(wt)&&!bt.has(fe)?br(wt,fe,et):Vo(wt);if(wt)return qr(wt,fe,et);let Fe=Bn.get(fe);if(Fe){let kt=et==="local"?fe:Fe,Xe=et==="local"?Fe:fe,rt;return it(kt)?s.equalUnits(kt,Xe)?(rt=de(kt,"local"),rt&&(Ae.get(rt).remote=Xe)):rt=ge(kt,Xe):rt=he(kt,Xe),oe.add(kt),oe.add(Xe),rt&&(tt.set(kt,rt),tt.set(Xe,rt),it(kt)&&st({kind:"insert",el:rt,source:"both"})),rt}let Ke=de(fe,et);return Ke&&(tt.set(fe,Ke),et==="local"?st({kind:"insert",el:Ke,source:"local"}):(Mt({kind:"insert",el:Ke,source:"remote"}),Ye&&it(fe)&&!Vt.partner.has(fe)&&dn.push({su:fe,node:Ke}))),Ke},br=(fe,_e,He)=>{let et;return it(fe)?(et=E(fe,He,_e),et&&oe.add(_e)):(et=de(_e,He),oe.add(_e),et&&(He==="local"?st:Mt)({kind:"insert",el:et,source:He})),et&&tt.set(_e,et),et},qr=(fe,_e,He)=>{E(fe,null,null);let wt=h(He==="local"?F:H,fe),Fe=_e,Ke=wt?Ut(wt,He==="local"?se:G,He==="local"?F:H):!1,kt=wt&&!Ke&&!Pt(fe,wt);if(kt&&He===Yt.otherSide)return yt({kind:"structure",el:null,detail:"both-moved",base:fe},{subject:fe}),null;if(kt&&yt({kind:"structure",el:null,detail:"both-moved",base:fe},{subject:fe}),wt||yt({kind:"structure",el:null,detail:"move-beats-delete",base:fe},{subject:fe,deleted:He==="local"?"remote":"local"}),Be.has(fe)){yt({kind:"structure",el:null,detail:"both-moved",base:fe},{subject:fe});let rt=de(Fe,He);return rt&&tt.set(_e,rt),rt}it(fe)&&(Nt||=Po(Ae,je,H,F,h,j,r,o.remoteWins,N,yt,_,O,x),Nt.plan(fe,He,Fe,!0));let Xe=it(fe)?j(fe,He==="local"?Fe:h(H,fe)||null,He==="remote"?Fe:h(F,fe)||null,!1):null;return Xe&&(tt.set(fe,Xe),tt.set(_e,Xe),wt&&tt.set(wt,Xe),He==="local"?st({kind:"move",el:Xe,source:"local"}):Mt({kind:"move",el:Xe,source:"remote"})),Xe};for(let fe of Yt.V.units){if(bt.has(fe)){if(ze?.has(fe)){for(let et of ze.get(fe))pt.has(et)||(qe.push(et),pt.add(et));continue}let He=tt.get(fe);pt.has(He)||(qe.push(He),pt.add(He));continue}if(oe.has(fe)&&!(tt.get(fe)&&pt.has(tt.get(fe)))){let He=Yt.V.baseOf(fe);He&&!Pe.has(He)&&yt({kind:"structure",el:null,detail:"both-moved",base:He},{subject:He});continue}let _e=Zn(fe,Yt.V,Yt.A,Yt.side);_e&&!pt.has(_e)&&(qe.push(_e),pt.add(_e),!Yt.V.baseOf(fe)&&!Bn.has(fe)&&!bt.has(fe)&&qt.add(_e))}for(let fe of lt)pt.has(fe.frag)||(qe.splice(fe.previous&&pt.has(fe.previous)?qe.indexOf(fe.previous)+1:To(fe.at),0,fe.frag),pt.add(fe.frag));if(!Yt.other.asBase){let fe=Yt.other,_e=Yt.otherSide,He=Yt.otherA,et=null,wt=0,Fe=null;for(let Ke of fe.units){let kt=At.get(Ke)||tt.get(Ke);if(kt&&pt.has(kt)){et=kt,Fe=null;continue}if(oe.has(Ke)){let ft=fe.baseOf(Ke);ft&&!Pe.has(ft)&&yt({kind:"structure",el:null,detail:"both-moved",base:ft},{subject:ft});continue}let Xe=Zn(Ke,fe,He,_e);if(!Xe)continue;let rt;if(Fe)rt=qe.indexOf(Fe)+1;else if(et){if(rt=qe.indexOf(et)+1,_e==="remote")for(;rt<qe.length&&qt.has(qe[rt]);)rt++}else rt=wt++;qe.splice(rt,0,Xe),pt.add(Xe),Fe=Xe}}for(let fe=0;fe<Oe.length;fe++){let _e=Oe[fe];if(oe.has(_e))continue;let He=Vo(_e);He&&qe.splice(To(fe),0,He)}return Ye&&Wt.length&&dn.length&&yr(),qe;function yr(){if(on||pn)return;let fe=new Set(qe),_e=ft=>ft&&Pe.has(ft)&&fe.has(tt.get(ft))?ft:null,He=(ft,_t)=>{let Ot=[{prev:null,units:[]}];for(let Zt of ft){let Sn=_e(_t(Zt));Sn?Ot.push({prev:Sn,units:[]}):Ot[Ot.length-1].units.push(Zt)}return Ot},et=He(Oe,ft=>ft),wt=He(re.units,re.baseOf),Fe=ce.asBase?null:He(ce.units,ce.baseOf),Ke=ft=>ft.length===et.length&&ft.every((_t,Ot)=>_t.prev===et[Ot].prev);if(!Ke(wt)||Fe&&!Ke(Fe))return;let kt=new Map(Wt.map(ft=>[ft.bk,ft])),Xe=new Map(dn.map(ft=>[ft.su,ft])),rt=ft=>ft?qe.indexOf(tt.get(ft)):-1;for(let ft=0;ft<et.length;ft++){if(et[ft].units.length!==1||wt[ft].units.length!==1)continue;let _t=kt.get(et[ft].units[0]),Ot=Xe.get(wt[ft].units[0]);if(!_t||!Ot||Fe&&(Fe[ft].units.length!==1||Fe[ft].units[0]!==_t.lk))continue;let Zt=rt(et[ft].prev);(ft+1<et.length?rt(et[ft+1].prev):qe.length)-Zt!==2||qe[Zt+1]!==Ot.node||qo(_t.bk,_t.lk,Ot.su)&&Ye.link(_t.lk,Ot.node)}}function Qn(fe,_e,He,et){let wt=Ot=>{let Zt=Ot.filter(it);return Zt.length===1?Zt[0]:null},Fe=wt(fe),Ke=wt(_e),kt=wt(He);if(!Fe||!Ke||!kt)return;let Xe=fe.indexOf(Fe);if(_e.indexOf(Ke)!==Xe||He.indexOf(kt)!==Xe||fe.length!==_e.length||fe.length!==He.length)return;for(let Ot=0;Ot<fe.length;Ot++)if(Ot!==Xe&&(fe[Ot].value!==_e[Ot].value||fe[Ot].value!==He[Ot].value))return;if((ce.asBase?Fe:ce.twin(Fe))!==Ke||re.twin(Fe)||F.reverse.get(kt)||Ke!==Fe&&_(Fe,Ke,H))return;let rt=et.filter(Ot=>Ot.nodeType===1);if(rt.length!==1||Ae.get(rt[0])?.remote!==kt)return;let ft=Ot=>Ot.map(Zt=>it(Zt)?"":Zt.value??Zt.nodeValue).join(""),_t=et.indexOf(rt[0]);ft(et.slice(0,_t))!==ft(fe.slice(0,Xe))||ft(et.slice(_t+1))!==ft(fe.slice(Xe+1))||qo(Fe,Ke,kt)&&Ye.link(Ke,rt[0])}function qo(fe,_e,He){if(!it(_e)||!it(He)||!it(fe)||_e.namespaceURI!==He.namespaceURI||_e.localName===He.localName)return!1;for(let Ke of[_e,He])if(Ke.tagName==="TEMPLATE"||mn(Ke)||Ke.querySelector("template"))return!1;if(o.remoteWins(fe)||o.remoteWins(He)||r(He)||_e.attributes.length!==He.attributes.length)return!1;for(let Ke of _e.attributes)if(He.getAttributeNS(Ke.namespaceURI,Ke.localName)!==Ke.value)return!1;let et=_e.childNodes,wt=He.childNodes;if(et.length!==wt.length)return!1;for(let Ke=0;Ke<et.length;Ke++)if(!et[Ke].isEqualNode(wt[Ke]))return!1;let Fe=[[fe,He]];for(;Fe.length;){let[Ke,kt]=Fe.pop();if(Ke.children.length!==kt.children.length)return!1;for(let Xe=0;Xe<kt.children.length;Xe++){let rt=F.reverse.get(kt.children[Xe]);if(rt!==void 0&&rt!==Ke.children[Xe])return!1;Fe.push([Ke.children[Xe],kt.children[Xe]])}}return!0}function To(fe){for(let _e=fe-1;_e>=0;_e--){let He=tt.get(Oe[_e]);if(He){let et=qe.indexOf(He);if(et>=0)return et+1}}return 0}function Fo(){if((ce.asBase||H.identical.has(C))&&(re.asBase||F.identical.has(C)))return;let fe={ignored:r,remoteWins:o.remoteWins,inlineCache:Se},_e=ut=>it(ut)?qn(ut,fe):ut.kind==="text";if(!ce.asBase&&!re.asBase)for(let ut of Oe){if(!it(ut)||!Pn.has(ut.tagName))continue;let Ze=ce.twin(ut),Rt=re.twin(ut);if(!Ze&&Rt||Ze&&!Rt){let ot=hl({base:Oe,views:[{V:ce,A:H,idOf:g.local},{V:re,A:F,idOf:g.remote}],eligible:vt=>it(vt)&&Pn.has(vt.tagName)&&!r(vt)&&!o.remoteWins(vt),baseId:g.base,ignored:r,remoteWins:o.remoteWins,atomKey:s.exactUnitKey});ot&&(ce=ot[0],re=ot[1]);break}}let He=!ce.asBase&&!re.asBase&&Oe.length>=2&&Pn.has(Oe[0].tagName)&&ce.units.length===Oe.length&&re.units.length===Oe.length?Gi({base:Oe,local:ce.units,remote:re.units,localTwin:ce.twin,remoteTwin:re.twin,eligible:ut=>it(ut)&&Pn.has(ut.tagName)&&!r(ut)&&!o.remoteWins(ut),nodes:{base:Array.from(xe(C).childNodes),local:Array.from(xe(ce.el).childNodes),remote:Array.from(xe(re.el).childNodes)}}):null,et=null,wt=null;if(!He&&!ce.asBase&&!re.asBase&&(Is(Oe)||Is(ce.units)||Is(re.units))){let ut={ignored:r,remoteWins:()=>!1},Ze=ot=>_e(ot)||it(ot)&&o.remoteWins(ot)&&An.has(ot.tagName)&&qn(ot,ut),Rt=ot=>it(ot)?Pn.has(ot.tagName)&&!r(ot)&&!o.remoteWins(ot)&&l(ot).every(Ze):ot.kind==="text";et=pl({onUncertainOwner:ot=>{let vt=o.identity.local(ot.local);vt&&vt===o.identity.remote(ot.remote)||(wt||=[]).push(ot)},onUncertainSource:ot=>{nt||(nt=new Map);let vt=nt.get(ot.source);vt||nt.set(ot.source,vt=[]);for(let Jt of vt)if(Jt.side===ot.side&&Jt.from===ot.from&&Jt.to===ot.to)return;vt.push(ot)},base:Oe,views:[{V:ce,A:H,idOf:g.local},{V:re,A:F,idOf:g.remote}],eligible:Rt,ignored:r,remoteWins:o.remoteWins,baseId:g.base,atomKey:s.exactUnitKey})}if(wt){ze||=new Map;for(let ut of wt){let{source:Ze,local:Rt,remote:ot}=ut,vt={map:new Map,reverse:new Map,identical:new Set},Jt=ht({base:[Ze],local:[Rt],remote:[ot],out:ae,policy:"both",L:vt,R:vt,ignored:r,remoteWins:o.remoteWins,atomKey:s.exactUnitKey,cloneUnit:de,provenance:Ae,textMappers:Ve,conflicts:N,decisions:ve,conflict:(Lt,Ft)=>yt(Lt,{...Ft,policy:"both"}),scope:{base:C,local:ce.el,remote:re.el,units:Oe,at:We.get(Ze)},node:ye});le.push(...Jt.segments);for(let Lt of[Ze,Rt,ot])oe.add(Lt),bt.add(Lt),ze.set(Lt,Jt.nodes),tt.set(Lt,Jt.nodes[Jt.nodes.length-1]);for(let Lt=0;Lt<Jt.nodes.length;Lt++)lt.push({frag:Jt.nodes[Lt],at:We.get(Ze),previous:Lt?Jt.nodes[Lt-1]:null})}}let Fe=He?He.blocks:null;if(et){Fe=new Set;for(let ut of et.blocks)Fe.add(ut)}let Ke=ut=>!Ct?.consumes(ut)&&(Fe&&Fe.has(ut)||_e(ut)),kt=Oe.map(Ke);if(!kt.includes(!0))return;let Xe=ut=>{let Ze=ut.units,Rt=new Map;for(let tn=0;tn<Ze.length;tn++)Rt.set(Ze[tn],tn);let ot=[],vt=-1;for(let tn=0;tn<Oe.length;tn++){if(kt[tn])continue;let Tt=ut.twin(Oe[tn]),mt=Tt?Rt.get(Tt):void 0;mt===void 0||mt<=vt||Ke(Tt)||(ot.push([tn,mt]),vt=mt)}let Jt=[],Lt=-1,Ft=-1;for(let tn=0;tn<=ot.length;tn++){let[Tt,mt]=tn<ot.length?ot[tn]:[Oe.length,Ze.length],St={bLo:-1,bHi:-1,from:Ft+1,to:mt,inlineStart:-1,inlineEnd:-1,next:mt};for(let Qt=Lt+1;Qt<Tt;Qt++)kt[Qt]&&(St.bLo<0&&(St.bLo=Qt),St.bHi=Qt);for(let Qt=Ft+1;Qt<mt;Qt++){let to=Ze[Qt];Ke(to)&&(St.inlineStart<0&&(St.inlineStart=Qt),St.inlineEnd=Qt+1)}Jt.push(St),Lt=Tt,Ft=mt}return{units:Ze,list:Jt}},rt=Xe(ce),ft=Xe(re),_t=[];for(let ut of[rt,ft])for(let Ze of ut.list)Ze.bLo>=0&&_t.push([Ze.bLo,Ze.bHi]);_t.sort((ut,Ze)=>ut[0]-Ze[0]);let Ot=[];for(let[ut,Ze]of _t){let Rt=Ot[Ot.length-1];Rt&&ut<=Rt.hi?Rt.hi=Math.max(Rt.hi,Ze):Ot.push({lo:ut,hi:Ze})}let Zt=(ut,Ze)=>ut.length===Ze.length&&ut.every((Rt,ot)=>s.equalUnits(Rt,Ze[ot])),Sn=ut=>!it(ut)&&ut.kind==="comment",eo=ut=>{if(!ut.length)return[];let Ze=(Lt,Ft)=>it(Lt)?Lt:Lt.nodes[Ft?Lt.nodes.length-1:0],Rt=Ze(ut[0]),ot=Ze(ut[ut.length-1],!0),vt=Lt=>Lt&&it(Lt)&&r(Lt);for(;vt(Rt.previousSibling);)Rt=Rt.previousSibling;for(;vt(ot.nextSibling);)ot=ot.nextSibling;let Jt=[];for(let Lt=Rt;Lt&&(Jt.push(Lt),Lt!==ot);Lt=Lt.nextSibling);return Jt},Un=ut=>ut.some(Ze=>it(Ze)&&r(Ze));for(let ut of Ot){let Ze=Oe.slice(ut.lo,ut.hi+1),Rt=null;if(et)for(let Tt of Ze){let mt=et.certificatesBySource.get(Tt);mt&&(Rt||=[]).push(...mt)}let ot=ce.asBase?null:Es(rt,ut),vt=re.asBase?null:Es(ft,ut);if(Rt){let Tt=[new Set(ot||Ze),new Set(vt||Ze)],mt=Rt.some(St=>!Tt[St.side].has(St.target));for(let St of Ze)if(Fe.has(St))for(let[Qt,to]of[[0,ce],[1,re]]){let Nn=to.twin(St);Nn&&to.here(Nn)&&!Tt[Qt].has(Nn)&&(mt=!0)}if(mt)continue}if(Ze.some(Sn)||ot&&ot.some(Sn)||vt&&vt.some(Sn))continue;let Jt=eo(ot||Ze),Lt=eo(vt||Ze);if((!ot||Zt(Ze,ot))&&(!vt||Zt(Ze,vt))&&!(ot&&Un(Jt)))continue;let Ft=ht({base:eo(Ze),sourceRetentions:nt?.get(C),local:Jt,remote:Lt,out:ae,policy:Ge,blocks:Fe,scopeUnits:Rt?[Ze,ot||Ze,vt||Ze]:null,certifiedOrigins:Rt?(Tt,mt,St,Qt,to,Nn)=>ml({certificates:Rt,scopes:[Ze,ot||Ze,vt||Ze],flats:[Tt,mt,St],keys:[Qt,to,Nn]}):null,prepared:He?He.prepared:null,nativeTransfers:He,L:ot?H:gl(H,C),R:vt?F:gl(F,C),idOf:{base:y,local:b,remote:S},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Tt,mt,St)=>j(Tt,mt,St,!1),cloneUnit:de,mergeAttrs:ie,atomKey:s.exactUnitKey,moveIn:E,moveBuilt:E,movePlanned:E,provenance:Ae,textMappers:Ve,conflicts:N,conflict:yt,scope:{base:C,local:ce.asBase?null:ce.el,remote:re.asBase?null:re.el,units:Oe,at:ut.lo},decisions:ve,node:ye});if(!Ft){if(Rt){let Tt=Xi({certificates:Rt,scopes:[Ze,ot||Ze,vt||Ze],views:[{V:ce,A:H,idOf:g.local},{V:re,A:F,idOf:g.remote}],eligible:mt=>it(mt)&&Pn.has(mt.tagName)&&!r(mt)&&!o.remoteWins(mt),baseId:g.base});for(let mt of Tt.records){nt||=new Map;let St=nt.get(mt.source);St||nt.set(mt.source,St=[]),St.push(mt)}}continue}if(le.push(...Ft.segments),He){let Tt=new Map;for(let mt of Ft.nodes){let St=Ae.get(mt)?.base;if(!St||Tt.has(St))throw new Error("Invalid native transfer owner output");Tt.set(St,mt)}if(Tt.size!==He.owners.length)throw new Error("Incomplete native transfer owner output");for(let mt of He.owners){let St=Tt.get(mt.base);if(!St)throw new Error("Missing native transfer owner output");for(let Qt of[mt.base,mt.local,mt.remote])oe.add(Qt),bt.add(Qt),tt.set(Qt,St);lt.push({frag:St,at:We.get(mt.base)})}continue}if(Ye&&Qn(Ze,ot||Ze,vt||Ze,Ft.nodes),Ft.unitOutputs){ze||=new Map;for(let mt of[...Ze,...ot||[],...vt||[]]){let St=Ft.unitOutputs.get(mt)||[];oe.add(mt),bt.add(mt),ze.set(mt,St),St.length&&tt.set(mt,St[St.length-1])}let Tt=Ft.nodes[Ft.nodes.length-1];if(Tt)for(let mt of[ot||Ze,vt||Ze]){let St=mt[mt.length-1];St&&At.set(St,Tt)}for(let mt=0;mt<Ft.nodes.length;mt++)lt.push({frag:Ft.nodes[mt],at:ut.lo,previous:mt>0?Ft.nodes[mt-1]:null});continue}Ye&&Qn(Ze,ot||Ze,vt||Ze,Ft.nodes);let tn=ae.createDocumentFragment();for(let Tt of Ft.nodes)tn.appendChild(Tt);for(let Tt of[...Ze,...ot||[],...vt||[]])oe.add(Tt),bt.add(Tt),tt.set(Tt,tn);lt.push({frag:tn,at:ut.lo})}}}function te(C,G){let se=Ae.get(C);return se&&se.unchanged?!se.remote||se.remote===G?!0:K(se.remote,G):C.tagName!==G.tagName||!Ie(C,G)?!1:Le(xe(C),xe(G))}function K(C,G){return C===G?!0:C.tagName!==G.tagName||C.namespaceURI!==G.namespaceURI||!Ie(C,G)?!1:ne(xe(C),xe(G))}function ne(C,G){let se=ke(C,r),me=ke(G,r);if(se.length!==me.length)return!1;for(let ye=0;ye<se.length;ye++){let ce=se[ye],re=me[ye];if(typeof ce=="string"||typeof re=="string"){if(ce!==re)return!1}else{if(ce.nodeType!==re.nodeType)return!1;if(ce.nodeType===1){if(!K(ce,re))return!1}else if(ce.nodeValue!==re.nodeValue)return!1}}return!0}function xe(C){return C.tagName==="TEMPLATE"&&C.content?C.content:C}function Ie(C,G){let se=0;for(let me of C.attributes)if(!o.ignoreAttribute(C,me.name)&&(se++,G.getAttribute(me.name)!==me.value))return!1;for(let me of G.attributes)o.ignoreAttribute(G,me.name)||se--;return se===0}function Le(C,G){let se=ke(C,ye=>{let ce=Ae.get(ye);return!!(ce&&ce.pinned)}),me=ke(G,r);if(se.length!==me.length)return!1;for(let ye=0;ye<se.length;ye++){let ce=se[ye],re=me[ye];if(typeof ce=="string"||typeof re=="string"){if(ce!==re)return!1}else{if(ce.nodeType!==re.nodeType)return!1;if(ce.nodeType===1){if(!te(ce,re))return!1}else if(ce.nodeValue!==re.nodeValue)return!1}}return!0}function ke(C,G){let se=[],me=null;for(let ye=C.firstChild;ye;ye=ye.nextSibling){if(ye.nodeType===3){me=me===null?ye.nodeValue:me+ye.nodeValue;continue}ye.nodeType===1&&G(ye)||(me!==null&&(me!==""&&se.push(me),me=null),se.push(ye))}return me!==null&&me!==""&&se.push(me),se}function $e(C,G,se,me){let ye=C.value,ce=me?ye:G?G.value:"",re=se?se.value:"";oe.add(C),G&&oe.add(G),se&&oe.add(se);let Oe=ce===re?ce:ce===ye?re:re===ye||Ge==="local"?ce:re,Pe={site:"comment",bRun:C,lRun:G,rRun:se,node:null};if(ce!==ye&&re!==ye&&ce!==re&&yt({kind:"text",node:null,base:ye,local:ce,remote:re,resolved:Oe},Pe),!G&&!se)return null;let We=ae.createComment(Oe);return Pe.node=We,Ae.set(We,{base:C.nodes,local:G?G.nodes:null,remote:se?se.nodes:null}),We}function Je(C,G){let se=h(G,C);if(!se)return null;let me=it(se)?se.parentNode:se.parent,ye=it(C)?C.parentNode:C.parent;return h(G,ye)===me?null:G.reverse.get(me)||null}function Qe(C){let G=new Set([C]),se=C;for(let me=0;me<64;me++){let ye=Je(se,H)||Je(se,F);if(!ye)return!1;if(ye===C||it(C)&&it(ye)&&C.contains(ye)||G.has(ye))return!0;G.add(ye),se=ye}return!0}function Ut(C,G,se){if(!G)return!1;let me=it(C)?C.parentNode:C.parent;return me===G||G.tagName==="TEMPLATE"&&me===G.content}function Pt(C,G){let se=je(C),me=h(H,se);if(me&&Ut(G,me,H))return!0;let ye=h(F,se);return!!(ye&&Ut(G,ye,F))}}function gl(e,t){return e.map.get(t)?bl():{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 bl(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}var yl=new Set(["INPUT","OPTION","TEXTAREA"]),Rs=/[\t\n\f\r ]+/;function wl(e,t,n,o){let r=e.ownerDocument,{provenance:c,textMappers:s}=n,l=o.hooks,i=[],a=[],p=[],f=new Set,u=[],y=[],b=new Map,S=new Set,g=new Map,d=n.conflicts.length>0||o.trackInserted===!0,w=new Map,O=new Set,x=new Map,A=(h,E)=>{let R=x.get(h);R||x.set(h,R=new Set),R.add(E)},v=d?new Set:null,I=(h,E,R)=>{let _=l.beforeAttributeUpdated(h,E,R);return d&&_===!1&&A(E,h),_},M=h=>!!h&&(h===e||e.contains(h)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(h)),P=new Map,D=new Map,$=new Map,W=new Set,B=new Map;(function h(E){let R=c.get(E);if(R){if(E.nodeType===1){let Q=R.local?o.toLive(R.local):null;Q&&M(Q)&&Q.nodeType===1&&(P.set(E,Q),D.set(Q,E))}else if(Array.isArray(R.local)){let Q=F(R.local,R.local.map(j=>o.toLive(j)).filter(j=>j&&M(j)&&j.nodeType===E.nodeType));if(Q.length&&(P.set(E,Q[0]),D.set(Q[0],E),$.set(E,Q)),Array.isArray(R.caret))for(let j of R.caret){let ue=o.toLive(j.node);if(!ue||!M(ue)||ue.nodeType!==3)continue;let be=B.get(ue);Array.isArray(be)||B.set(ue,be=[]),be.push({merged:E,from:j.from,to:j.to,flatStart:j.flatStart})}else{let j=0;for(let ue of Q)B.set(ue,{merged:E,shift:j}),j+=ue.nodeValue.length}}}let _=E.nodeType===1&&E.tagName==="TEMPLATE"&&E.content?E.content.childNodes:E.childNodes;for(let Q of _)h(Q)})(t);let k=new Set;for(let h of P.values())k.add(h);for(let h of $.values())for(let E of h)k.add(E);let T=o.localRoot&&o.localRoot!==e?new Set:null;if(T){for(let h=o.localRoot.firstElementChild;h;h=h.nextElementSibling)if(h.tagName==="HEAD")for(let E=h.firstElementChild;E;E=E.nextElementSibling){let R=o.toLive(E);R&&T.add(R)}}for(let h of n.segments||[])Ee(h);let J=o.restoreFocus===!1?null:Fa(r,B);o.childrenOnly?Ae(Me(e),Me(t)):je(e,t);for(let{node:h,parent:E}of u)f.has(h)||!h.parentNode||h.nodeType===1&&(o.ignored(h)||Ve(h))||nt(h,E);return $a(r,J,B,s,$,g,W),{applied:i,moved:a,replaced:p,identities:y,mergedScriptsLive:S,liveOf:P,heldBy:g,runOf:$,keptRuns:W,insertedLive:w,vetoed:O,vetoedAttrs:x,removedVetoes:v};function H(h,E){let R=h.slice(E.bs,E.be),_=0;for(;_<R.length&&_<E.text.length&&R[_]===E.text[_];)_++;let Q=0;for(;Q<R.length-_&&Q<E.text.length-_&&R[R.length-1-Q]===E.text[E.text.length-1-Q];)Q++;return{bs:E.bs+_,be:E.be-Q,text:E.text.slice(_,E.text.length-Q)}}function F(h,E){if(!E.length)return E;let R=[];for(let j of h){let ue=j.parentNode;if(!ue)continue;let be=b.get(ue);if(!be){be=new Set;for(let ie=ue.firstChild;ie;ie=ie.nextSibling)ie.nodeType===3&&be.add(o.toLive(ie));b.set(ue,be)}R.includes(be)||R.push(be)}let _={has:j=>R.some(ue=>ue.has(j))},Q=[];for(let j of E){Q.push(j);for(let ue=j.nextSibling;ue&&ue.nodeType===3&&!_.has(ue)&&!Q.includes(ue);ue=ue.nextSibling)Q.push(ue)}return Q}function Ee(h){let E=[];for(let ee of h.localNodes){let te=o.toLive(ee.node);if(!te||!M(te)||te.nodeType!==3)return;E.push(te)}let R=F(h.localNodes.map(ee=>ee.node),E);if(!R.length)return;let _=R.map(ee=>ee.nodeValue).join(""),{flatLocal:Q,lToM:j,mapLocal:ue}=h;if(_===Q)return;let be=h.textNodes.map(ee=>({node:ee.node,ms:ee.ms,me:ee.me})),ie=[],Ne=0;for(let ee of R)ie.push(Ne),Ne+=ee.nodeValue.length;let U=(ee,te)=>R.find((K,ne)=>ie[ne]<=ee&&ee+te<=ie[ne]+K.nodeValue.length)||null,X=[],he=0;for(let ee of uo(Q,_).map(te=>H(Q,te))){let te=ee.bs+he;he+=ee.text.length-(ee.be-ee.bs);let K,ne;if(ee.be>ee.bs){K=j[ee.bs];let xe=K>=0;for(let Ie=ee.bs;xe&&Ie<ee.be;Ie++)j[Ie]!==K+(Ie-ee.bs)&&(xe=!1);if(!xe)continue;ne=K+(ee.be-ee.bs)}else{let xe=ee.bs>0?j[ee.bs-1]:0,Ie=ee.bs<Q.length?j[ee.bs]:0;if(xe<0||Ie<0)continue;K=ne=ue(ee.bs)}X.push({ms:K,me:ne,text:ee.text,live:ne===K?U(te,ee.text.length):null})}X.sort((ee,te)=>te.ms-ee.ms);let ge=(ee,te)=>($.get(ee.node)||[P.get(ee.node)]).includes(te),de=ee=>!!ee&&ee.nodeType===1&&An.has(ee.tagName);for(let ee of X){let te=be.find(ne=>ne.ms<=ee.ms&&ee.me<=ne.me&&ee.ms<ne.me);if(te&&ee.live&&te.ms===ee.ms&&!ge(te,ee.live)){let ne=be.find(xe=>xe.me===ee.ms&&ge(xe,ee.live));ne&&(te=ne)}if(!te&&ee.me===ee.ms){let ne=be.find(ke=>ke.me===ee.ms),xe=be.find(ke=>ke.ms===ee.ms),Ie=ne||xe;if(!Ie)continue;let Le=Ie.node;for(;de(Le.parentNode)&&(ne?Le.parentNode.lastChild:Le.parentNode.firstChild)===Le;)Le=Le.parentNode;if(Le===Ie.node)te=Ie;else{let ke=Le.ownerDocument.createTextNode(ee.text);Le.parentNode.insertBefore(ke,ne?Le.nextSibling:Le);continue}}if(!te)continue;let K=te.node.nodeValue;te.node.nodeValue=K.slice(0,ee.ms-te.ms)+ee.text+K.slice(ee.me-te.ms),te.me+=ee.text.length-(ee.me-ee.ms)}}function Me(h){return h.nodeType===1&&h.tagName==="TEMPLATE"&&h.content?h.content:h}function je(h,E){f.add(h);let R=c.get(E);if(R&&R.remote&&n.remoteIdOf){let Q=n.remoteIdOf(R.remote);Q&&y.push([h,Q])}if(R&&R.unchanged){o.opaque&&o.opaque(h)||(n.customIdentity&&R.remote&&le(h,R.remote),R.remote&&Y(h,R.remote));return}if(l.beforeNodeMorphed(h,E)===!1){O.add(E);return}It(h,E,o.keepLiveOnly&&R&&R.local&&R.local.nodeType===1&&R.local!==h?R.local:null);let _=h.tagName;if(mn(h))h.textContent!==E.textContent&&(i.push({kind:"text",node:h,before:h.textContent,after:E.textContent}),h.textContent=E.textContent),n.mergedScripts.has(E)&&S.add(h);else if(_==="TEXTAREA")z(h,E,R);else{Xt(h,E,R);let Q=_==="TEMPLATE"&&h.content?h.content:h,j=_==="TEMPLATE"&&E.content?E.content:E;o.opaque&&o.opaque(h)||o.protectFocusedValue==="subtree"&&Nt(h)&&h!==r.body?ae(Q):Ae(Q,j)}l.afterNodeMorphed(h,E)}function ae(h){for(let E=h.firstChild;E;E=E.nextSibling){let R=D.get(E);R&&P.get(R.parentNode)!==h||(f.add(E),E.nodeType===1&&ae(E))}}function Ae(h,E){let R=Be(h.firstChild),_=new Set;for(let Q of Array.from(E.childNodes)){let j=P.get(Q);j&&f.has(j)&&!_.has(j)&&(j=null);let ue=c.get(Q);if(ue&&ue.pinned){j&&j.nodeType===1&&((j.parentNode!==h||Be(j.nextSibling)!==R)&&Se(h,j,R),f.add(j),_.add(j));continue}if(j&&j.nodeType===1){if(j!==R){let Ne=j.parentNode;if(Ne===h&&R&&Ct(j)){let U=j.nextSibling;for(let X=R;X&&X!==j;){let he=X.nextSibling;Se(h,X,U),X=he}}else Se(h,j,R),Ne!==h&&(a.push(j),i.push({kind:"move",el:j,from:Ne,to:h}))}_.add(j),je(j,Q),R=Be(j.nextSibling);continue}if(j&&j.nodeType!==1){let Ne=$.get(Q)||[j],U=Ne.map(he=>he.nodeValue).join(""),X=Q.nodeValue;if(Q.nodeType===3){let he=ve(Q);he!=null&&U!==he&&(X=Go(he,U,Q.nodeValue).text)}if(Ne.length>1&&U===X&&!Ne.includes(R,1)&&Ne.every((he,ge)=>he.parentNode===h&&(ge===0||Ne[ge-1].nextSibling===he))){if(j!==R)for(let he of Ne)Se(h,he,R);l.beforeNodeMorphed(j,Q)!==!1?l.afterNodeMorphed(j,Q):d&&O.add(Q);for(let he of Ne)f.add(he),_.add(he);g.set(Q,j),W.add(Q),R=Be(Ne[Ne.length-1].nextSibling);continue}j!==R&&Se(h,j,R),l.beforeNodeMorphed(j,Q)!==!1?(j.nodeValue!==X&&(i.push({kind:"text",node:j,before:j.nodeValue,after:X}),j.nodeValue=X),l.afterNodeMorphed(j,Q)):O.add(Q),f.add(j),_.add(j),g.set(Q,j),R=Be(j.nextSibling);continue}if(Q.nodeType===3&&R&&R.nodeType===3&&!f.has(R)&&!B.has(R)){R.nodeValue!==Q.nodeValue&&(i.push({kind:"text",node:R,before:R.nodeValue,after:Q.nodeValue}),R.nodeValue=Q.nodeValue),f.add(R),g.set(Q,R),R=Be(R.nextSibling);continue}let be=c.get(Q),ie=Ye(be&&be.unchanged&&be.remote?be.remote:Q);if(l.beforeNodeAdded(ie)===!1){O.add(Q);continue}h.insertBefore(ie,R),f.add(ie),d&&w.set(Q,ie),ie.nodeType===3&&g.set(Q,ie),ie.nodeType===1&&(p.push(ie),Re(ie,Q),n.customIdentity&&be&&be.unchanged&&be.remote&&le(ie,be.remote),mn(ie)||ht(ie,Q),o.formState==="property"&&ln(be)&&Y(ie,be.remote)),R=Be(ie.nextSibling),i.push({kind:"insert",node:ie,parent:h}),l.afterNodeAdded(ie)}for(let Q of Array.from(h.childNodes))f.has(Q)||_.has(Q)||Q.nodeType===1&&(o.ignored(Q)||Ve(Q))||(k.has(Q)?u.push({node:Q,parent:h}):nt(Q,h))}function Ve(h){return h.parentNode&&h.parentNode.nodeType===1&&h.parentNode.tagName==="HEAD"&&(T&&!T.has(h)||o.preserve&&o.preserve(h)===!0)}function ve(h){let E=c.get(h);return!E||!Array.isArray(E.local)?null:E.local.map(R=>R.nodeValue).join("")}function N(h){return c.get(h)}function Y(h,E){if(!yl.has(h.tagName)&&!h.querySelector("input,option,textarea"))return;let R=(_,Q)=>{if(_.tagName!==Q.tagName||(_.tagName==="TEXTAREA"?z(_,Q,{remote:Q}):yl.has(_.tagName)&&Xt(_,Q,{remote:Q}),o.opaque&&o.opaque(_)))return;let j=oe(_),ue=oe(Q);if(j.length===ue.length)for(let be=0;be<j.length;be++)R(j[be],ue[be])};R(h,E)}function le(h,E){if(o.opaque&&o.opaque(h))return;let R=oe(h),_=oe(E);if(R.length===_.length)for(let Q=0;Q<R.length;Q++){let j=n.remoteIdOf(_[Q]);j&&y.push([R[Q],j]),le(R[Q],_[Q])}}function oe(h){let E=h.tagName==="TEMPLATE"&&h.content?h.content:h;return Array.from(E.children).filter(R=>!o.ignored(R))}function Re(h,E){if(!n.remoteIdOf)return;let R=(_,Q)=>{let j=c.get(Q);if(j&&j.remote&&Q.nodeType===1){let ie=n.remoteIdOf(j.remote);ie&&y.push([_,ie])}let ue=_.childNodes,be=Q.childNodes;for(let ie=0;ie<ue.length&&ie<be.length;ie++)R(ue[ie],be[ie])};R(h,E)}function Be(h){for(;h&&h.nodeType===1&&o.ignored(h);)h=h.nextSibling;return h}function Se(h,E,R){if(typeof h.moveBefore=="function"&&E.ownerDocument===h.ownerDocument)try{h.moveBefore(E,R);return}catch{}h.insertBefore(E,R)}function nt(h,E){if(l.beforeNodeRemoved(h)===!1){d&&v.add(h);return}h.parentNode.removeChild(h),i.push({kind:"remove",node:h,parent:E}),l.afterNodeRemoved(h)}function Ye(h){if(mn(h))return Jo(h,r);let E=r.importNode(h,!0);if(E.nodeType===1)for(let R of Array.from(E.querySelectorAll("script")))mn(R)&&R.replaceWith(Jo(R,r));return E}function ht(h,E){let R=h.tagName==="TEMPLATE"&&h.content?h.content:h,_=E.tagName==="TEMPLATE"&&E.content?E.content:E,Q=Array.from(R.childNodes),j=Array.from(_.childNodes);for(let ue=0;ue<j.length&&ue<Q.length;ue++){let be=j[ue],ie=Q[ue],Ne=P.get(be);Ne&&f.has(Ne)&&(Ne=null);let U=c.get(be);if(U&&U.pinned){if(Ne&&Ne.nodeType===1){let X=Ne.parentNode;Se(R,Ne,ie),X!==R&&(a.push(Ne),i.push({kind:"move",el:Ne,from:X,to:R})),f.add(Ne)}ie.remove();continue}if(Ne){let X=Ne.parentNode;Se(R,Ne,ie),ie.remove(),Ne.nodeType===1?(X!==R&&(a.push(Ne),i.push({kind:"move",el:Ne,from:X,to:R})),je(Ne,be)):(f.add(Ne),g.set(be,Ne),Ne.nodeValue!==be.nodeValue&&(i.push({kind:"text",node:Ne,before:Ne.nodeValue,after:be.nodeValue}),Ne.nodeValue=be.nodeValue));continue}f.add(ie),d&&w.set(be,ie),ie.nodeType===3&&g.set(be,ie),U&&U.unchanged&&U.remote?(Ge(ie,U.remote),n.customIdentity&&le(ie,U.remote)):be.nodeType===1&&!mn(be)&&ht(ie,be)}}function Ge(h,E){let R=h.tagName==="TEMPLATE"&&h.content?h.content:h,_=E.tagName==="TEMPLATE"&&E.content?E.content:E;for(let Q of Array.from(_.childNodes))R.appendChild(Ye(Q))}function st(h,E){return E.namespaceURI?h.getAttributeNS(E.namespaceURI,E.localName):h.getAttribute(E.name)}function Mt(h,E){let R=new Set((E||"").split(Rs).filter(Boolean));return(h||"").split(Rs).filter(_=>_&&!R.has(_))}function It(h,E,R){for(let _ of Array.from(E.attributes)){if(yt(h,_.name)||o.ignoreAttribute(h,_.name,E))continue;let Q=st(h,_);if(Q===_.value||R&&st(R,_)===_.value)continue;let j=_.value;if(R&&_.name==="class"&&!_.namespaceURI){let ue=_.value.split(Rs).filter(Boolean),be=Mt(Q,R.getAttribute("class")).filter(ie=>!ue.includes(ie));be.length&&(j=[...ue,...be].join(" "))}if(Q!==j){if(l.beforeAttributeUpdated(_.name,h,"update")===!1){d&&A(E,_.name);continue}_.namespaceURI?h.setAttributeNS(_.namespaceURI,_.name,j):h.setAttribute(_.name,j),i.push({kind:"attr",el:h,name:_.name,before:Q,after:j})}}for(let _ of Array.from(h.attributes)){if(yt(h,_.name)||o.ignoreAttribute(h,_.name,E)||(_.namespaceURI?E.hasAttributeNS(_.namespaceURI,_.localName):E.hasAttribute(_.name)))continue;if(R&&_.name==="class"&&!_.namespaceURI){let ue=Mt(_.value,R.getAttribute("class"));if(ue.length){let be=ue.join(" ");if(be===_.value)continue;if(l.beforeAttributeUpdated("class",h,"update")===!1){d&&A(E,"class");continue}h.setAttribute("class",be),i.push({kind:"attr",el:h,name:"class",before:_.value,after:be});continue}}if(R&&st(R,_)===null&&!o.ignoreAttribute(R,_.name))continue;if(l.beforeAttributeUpdated(_.name,h,"remove")===!1){d&&A(E,_.name);continue}let j=_.value;_.namespaceURI?h.removeAttributeNS(_.namespaceURI,_.localName):h.removeAttribute(_.name),i.push({kind:"attr",el:h,name:_.name,before:j,after:null})}}function yt(h,E){let R=h.tagName;return R==="INPUT"?E==="value"||E==="checked"||E==="disabled":R==="OPTION"?E==="selected":!1}function Nt(h){return h===r.activeElement}function Ct(h){let E=r.activeElement;return!!E&&E!==r.body&&h.contains(E)}function Vt(h,E){let R=E&&E.local&&E.local.nodeType===1&&E.local!==h?E.local:null;if(!R)return!0;let _=h.tagName==="TEXTAREA"?R.textContent:R.getAttribute("value")??"";return h.value!==_}function fn(h,E){return!!o.protectFocusedValue&&Nt(h)&&Vt(h,E)}function Et(h,E,R){let _=Math.min(h.length,E.length),Q=0;for(;Q<_&&h[Q]===E[Q];)Q++;if(R<=Q)return R;let j=0;for(;j<_-Q&&h[h.length-1-j]===E[E.length-1-j];)j++;return R>=h.length-j?R+E.length-h.length:E.length-j}function Gt(h){try{return h.selectionStart==null?null:[h.selectionStart,h.selectionEnd,h.selectionDirection]}catch{return null}}function wn(h,E,R,_){try{h.setSelectionRange(Et(E,R,_[0]),Et(E,R,_[1]),_[2]||"none")}catch{}}function Bt(h,E){let R=h.value,_=Gt(h);h.value=E,_&&wn(h,R,E,_)}function ln(h){let E=h&&h.remote;return E&&E.nodeType===1?E:null}function Xt(h,E,R){let _=h.tagName,Q=ln(R),j=o.formState==="property"&&Q?Q:E;if(_==="INPUT"){let ue=fn(h,R),be=(h.getAttribute("type")||"").toLowerCase(),ie=be!=="file"&&be!=="checkbox"&&be!=="radio",Ne=Q&&Q.hasAttribute("value")&&Q.value!==Q.getAttribute("value")?Q.value:null;if(ie&&!ue)if(o.formState==="property"){let U=E.getAttribute("value"),X=h.getAttribute("value");(X!==U||h.value!==j.value)&&I("value",h,U==null?"remove":"update")!==!1&&(X!==U&&(U==null?h.removeAttribute("value"):h.setAttribute("value",U),i.push({kind:"attr",el:h,name:"value",before:X,after:U})),h.value!==j.value&&(Nt(h)?Bt(h,j.value):h.value=j.value))}else if(E.hasAttribute("value")||Ne!=null){let U=Ne??E.getAttribute("value");h.getAttribute("value")!==U&&I("value",h,"update")!==!1?(h.setAttribute("value",U),h.value!==U&&(Nt(h)?Bt(h,U):h.value=U),i.push({kind:"attr",el:h,name:"value",before:null,after:U})):h.value!==U&&h.getAttribute("value")===U&&(Nt(h)?Bt(h,U):h.value=U)}else(h.hasAttribute("value")||h.value!=="")&&I("value",h,"remove")!==!1&&(h.removeAttribute("value"),h.value="",i.push({kind:"attr",el:h,name:"value",before:"",after:null}));if(!ie&&be!=="file"){let U=E.getAttribute("value");U==null?h.hasAttribute("value")&&I("value",h,"remove")!==!1&&h.removeAttribute("value"):h.getAttribute("value")!==U&&I("value",h,"update")!==!1&&h.setAttribute("value",U)}o.protectFocusedValue&&Nt(h)||(un(h,j,"checked"),o.formState==="property"&&h.indeterminate!==j.indeterminate&&(h.indeterminate=j.indeterminate)),un(h,j,"disabled")}else if(_==="OPTION"){let ue=h.parentNode&&h.closest("select");o.protectFocusedValue&&ue&&Nt(ue)||un(h,j,"selected")}}function un(h,E,R){if(o.ignoreAttribute(h,R,E))return;let _=o.formState==="property"?!!E[R]:E.hasAttribute(R);if(o.formState!=="property"){let Q=h.hasAttribute(R);if(Q!==_){if(I(R,h,_?"update":"remove")===!1)return;_?h.setAttribute(R,""):h.removeAttribute(R),i.push({kind:"attr",el:h,name:R,before:Q?"":null,after:_?"":null})}}h[R]!==_&&(h[R]=_)}function z(h,E,R){if(fn(h,R)||I("value",h,"update")===!1)return;let _=ln(R),Q=E.textContent,j=_&&_.value!==_.defaultValue?_.value:Q,ue=Nt(h)?Gt(h):null,be=h.value;o.formState!=="property"&&h.textContent!==Q&&(i.push({kind:"text",node:h,before:h.textContent,after:Q}),h.textContent=Q),h.value!==j&&(h.value=j),ue&&h.value!==be&&wn(h,be,h.value,ue)}}function Fa(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 c=r.getRangeAt(0);o.range={sc:c.startContainer,so:c.startOffset,ec:c.endContainer,eo:c.endOffset}}return o}function $a(e,t,n,o,r,c,s){if(!t)return;let l=t.el;if(!l.isConnected&&t.id&&(l=e.getElementById(t.id)),!l||!l.isConnected)return;if(e.activeElement!==l)try{l.focus({preventScroll:!0})}catch{}try{l.scrollTop=t.scrollTop,l.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{l.setSelectionRange&&!l.selectionEnd&&t.selection[1]!=null&&l.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let i=(f,u)=>{let y=n.get(f);if(Array.isArray(y)){let b=y.find(w=>u>=w.from&&u<w.to)||y.find(w=>u===w.to)||y[y.length-1],S=c.get(b.merged);if(!S||!S.isConnected)return null;let g=o.get(b.merged),d=g&&g.flat?g.flat(b.flatStart+u):u;return[S,Math.max(0,Math.min(d,S.nodeValue.length))]}if(y&&!s.has(y.merged)){let b=(r.get(y.merged)||[f])[0];if(!b.isConnected)return null;let S=o.get(y.merged),g=y.shift+u,d=S?S(g):g;return[b,Math.max(0,Math.min(d,b.nodeValue.length))]}return f.isConnected?[f,Math.min(u,f.nodeType===3?f.nodeValue.length:f.childNodes.length)]:null},a=i(t.range.sc,t.range.so),p=i(t.range.ec,t.range.eo);if(!(!a||!p))try{let f=e.createRange();f.setStart(a[0],a[1]),f.setEnd(p[0],p[1]);let u=e.getSelection();u.removeAllRanges(),u.addRange(f)}catch{}}var Ka={compared:0},za=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function Ga(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 Ls(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 xl(e,t,n,o,r,c,s,l){let i=new Map,a=new Set,p=f=>{if(o(f))return;let u=n(f);u&&(c.add(u),r.has(u)||i.has(u)?a.add(u):i.set(u,f))};for(let f of e)p(f);p(t);for(let f of s||t.querySelectorAll("*"))p(f);for(let f of a)i.delete(f),l.add(f);return i}function kl(e,t,n,o,r,c){let s=!1;for(let p of r)p.startsWith("merge:")&&(s=!0);if(!s)return[...o];let l=new Map,i=[],a=c===kn?er:"*";for(let p of[e,...e.querySelectorAll(a)]){if(n(p))continue;let f=t(p);if(!f||!(o.has(f)||r.has(f)))continue;let u=(l.get(f)||0)+1;l.set(f,u),u===2&&i.push(f)}return i}function Tl({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:o,o:r,identity:c,baseURI:s}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!Ga(e,t,r.ignoreAttribute))return{bail:"root-attrs"};let{ignored:l,remoteWins:i}=r,a=Cs(r.scripts.merge===!1?null:r.scripts.mergeTags,s),p=ve=>{let N=a(ve);return N!==null?N:c.base(ve)||null},f=ve=>{let N=a(ve);return N!==null?N:c.remote(ve)||null},u=[],y=[],b=new Map,S=new Map,g={same:b,differ:S},d=ve=>({bail:ve,comparisons:g}),w=(ve,N,Y=!0)=>{if(b.get(ve)===N)return!0;if(S.get(ve)===N)return!1;if(Ka.compared++,Y&&ve.isEqualNode(N))return b.set(ve,N),!0;let le=ve.nodeType===N.nodeType;if(le&&ve.nodeType===1){if(le=Ls(ve,N),le){let oe=ve.firstChild,Re=N.firstChild;for(;oe&&Re;oe=oe.nextSibling,Re=Re.nextSibling)if(!w(oe,Re,!1)){le=!1;break}(oe||Re)&&(le=!1)}}else le&&(le=ve.isEqualNode(N));return(le?b:S).set(ve,N),le},O=e,x=t,A=!1,v=()=>{b.set(O,x);for(let ve=0;ve<u.length;ve++)b.set(u[ve],y[ve]);return d("equal")};for(;;){let ve=O.childNodes,N=x.childNodes;if(ve.length!==N.length)break;let Y=Ye=>w(ve[Ye],N[Ye])?(b.set(ve[Ye],N[Ye]),!1):!0,le=-1,oe=-1;for(let Ye=0;Ye<ve.length;Ye++){if(ve[Ye].nodeType!==1)continue;let ht=0;for(let Ge=ve[Ye].firstElementChild;Ge;Ge=Ge.nextElementSibling)ht++;ht>=oe&&(oe=ht,le=Ye)}let Re=[],Be=!1;for(let Ye=0;Ye<ve.length&&Re.length<2;Ye++)Ye!==le&&Y(Ye)&&Re.push(Ye);if(le>=0&&Re.length<2&&(Re.length===0&&Ls(O,x)?(Re.push(le),Be=!0):Y(le)&&Re.push(le)),Re.length!==1){if(!A&&Re.length===0&&Ls(O,x))return v();break}let Se=ve[Re[0]],nt=N[Re[0]];if(A=A||!Be,A&&S.set(Se,nt),Se.nodeType!==1||nt.nodeType!==1||Se.tagName!==nt.tagName)break;if(p(Se)!==f(nt)){if(!A&&w(Se,nt))return v();break}u.push(O),y.push(x),O=Se,x=nt}S.set(O,x);for(let ve=0;ve<u.length;ve++)S.set(u[ve],y[ve]);if(O===e||O.tagName==="HEAD"||O.tagName==="BODY")return d("root-level");if(u.length<2||u[1].tagName!=="BODY")return d("not-in-body");if(l(O)||l(x))return d("ignored-ancestor");if(i(O)||i(x))return d("remote-wins-ancestor");for(let ve of u)if(za.has(ve.tagName))return d("form-ancestor");if(O.tagName==="SCRIPT"||O.getElementsByTagName("script").length||x.getElementsByTagName("script").length)return d("script-or-template");let I=o(O);if(!I||I.nodeType!==1||I.tagName!==O.tagName)return d("no-live-twin");if(!n.contains(I))return d("live-detached");for(let ve of u){let N=o(ve);if(!N||N.nodeType!==1)return d("ancestor-live")}let M=c.base===kn&&c.remote===kn&&l===ts,P=new Set,D=new Set,$=[],W=null,B=ve=>{ve&&(P.has(ve)?D.add(ve):P.add(ve))},k=(ve,N)=>{let Y=a(ve),le=Y!==null?Y:c.base(ve)||null;return le!==(Y!==null?Y:c.remote(N)||null)?!1:(B(le),!0)},T=(ve,N)=>{for(let Y=ve.firstElementChild,le=N.firstElementChild;Y;Y=Y.nextElementSibling,le=le.nextElementSibling){let oe=l(Y);if(oe!==l(le))return!1;if(!oe&&(!k(Y,le)||!T(Y,le)))return!1}return!0},J=ve=>{let N=ve+1<u.length?u[ve+1]:O;for(let Y=u[ve].firstElementChild,le=y[ve].firstElementChild;Y;Y=Y.nextElementSibling,le=le.nextElementSibling){if(Y===N){let Be=ve+1<u.length?J(ve+1):null;if(Be)return Be;continue}let oe=l(Y);if(oe!==l(le))return"outside-id-changed";if(oe)continue;let Re=o(Y);if(!Re||Re.nodeType!==1)return"sibling-live";if($.push([Y,le]),!M&&(!k(Y,le)||!T(Y,le)))return"outside-id-changed";ve===0&&Y.tagName==="HEAD"&&p(Y)&&(W=[Y,le])}return null},H=J(0);if(H)return d(H);let F=new Set(u),Ee=null;if(c.base===kn){Ee=[];for(let ve of e.querySelectorAll(er))ve===O||F.has(ve)||(O.contains(ve)?Ee.push(ve):M&&B(p(ve)))}let Me=new Set,je=new Set,ae=new Set,Ae=xl(u,O,p,l,P,Me,Ee,je),Ve=xl(y,x,f,l,P,Me,c.remote===kn&&x.querySelectorAll(er),ae);return W&&(D.has(p(W[0]))||Me.has(p(W[0])))&&(W=null),{scope:{chain:u,root:O,onChain:F,baseIndex:Ae,remoteIndex:Ve,baseDropped:je,remoteDropped:ae,head:W,same:b,differ:S,dropped:[...kl(e,p,l,D,je,c.base),...kl(t,f,l,D,ae,c.remote)],held:ve=>{for(let N=1;N<u.length;N++)if(ve.map.get(u[N])!==y[N])return!1;for(let[N,Y]of $)if(ve.map.get(N)!==Y)return!1;return!0}}}}var Vd=Symbol("hyper-morph-duplicate-key");var Xa='[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"]',Ya='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',Ja='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function Za(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 Qa(e,t,n,o){if(t==null)return;if(typeof t=="string")return t;let r=t;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=ef(e,t,o)),!!r)return n?Array.from(r.childNodes):r}function ef(e,t,n){let o=t.nodeType===9?t.documentElement:t;if(!o||o.nodeType!==1)return null;let r=new Map,c=[o,...o.querySelectorAll("script")];for(let i of c){let a=Co(i,n);a&&!r.has(a.key)&&r.set(a.key,i.textContent)}if(!r.size)return null;let s=e.cloneNode(!0),l=!1;for(let i of[s,...s.querySelectorAll("script")]){let a=Co(i,n);a&&r.has(a.key)&&(i.textContent=r.get(a.key),l=!0)}return l?s:null}function Al(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 c of r)n.body.appendChild(n.adoptNode(c));return n}function Ps(e,t,n={}){let o=n||{};if(!o.head?.block)return Sl(e,t,o);try{return Sl(e,t,o)}catch(r){return Promise.reject(r)}}function Sl(e,t,n){let o=n.policy||"sync",r=o==="raw"?void 0:(i,a)=>Za(i)||(o==="history"?!(a&&i.matches(Ja))&&i.matches(Ya):i.matches(Xa)),c=n.callbacks||{},s={ignore:r,hooks:c,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"&&(s.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return tr(Object.assign({},s,{live:e,base:n.scripts?.mergeBase||null,remote:Al(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let i=Object.assign({},s,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:Al(t,e.ownerDocument)});return tr(i)}n.morphStyle==="innerHTML"&&(s.children=!0);let l=Qa(e,n.scripts?.mergeBase,!!s.children,s.scripts.mergeTags);return l!==void 0&&(s.base=l),js(e,t,s)}var tf=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),Cn=()=>{};function nr(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!tf.has(l))throw new TypeError(`unknown option "${l}"`);let n=Object.assign({beforeNodeAdded:Cn,afterNodeAdded:Cn,beforeNodeRemoved:Cn,afterNodeRemoved:Cn,beforeNodeMorphed:Cn,afterNodeMorphed:Cn,beforeAttributeUpdated:Cn},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");let s=e.lineage;if(s!==void 0&&(!s||typeof s!="object"||typeof s.onResult!="function"||!s.elements||typeof s.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:ns(e.ignore,t),remoteWins:ns(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,opaque:typeof e.opaque=="function"?e.opaque:()=>!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:n,children:!!e.children,beforeApply:typeof e.beforeApply=="function"?e.beforeApply:null,fastPath:e.fastPath===!0,keepLiveOnly:e.keepLiveOnly===!0,lineage:s||null}}function jo(e){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){if(typeof e.first=="function")return e.first;if(typeof e.then=="function")return e.then}return kn}function Do(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=os(t,e.map),o=typeof e.then=="function"?e.then:kn;if(typeof e.first=="function"){let r=e.first;return c=>r(c)||n.get(c)||o(c)}return r=>n.get(r)||o(r)}return kn}function nf(e,t,n,o={}){let r=y=>y&&y.nodeType===9?y.documentElement:y,c=r(t),s=r(n),l=r(e)||c;if(o.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let i=Object.assign({},o);delete i.live,delete i.base,delete i.remote;let a=nr(i,[l,c,s].filter(Boolean)),p=o.identity||{},f=oo(),u=Br(l,c,s,{identity:{base:Do(p.base,l),local:Do(p.local,c),remote:Do(p.remote,s)},authored:{base:jo(p.base),local:jo(p.local),remote:jo(p.remote)},skipUnchanged:a.hooks.beforeNodeMorphed===Cn&&a.hooks.afterNodeMorphed===Cn,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===t,childrenOnly:a.children,stats:f});return delete u.recoveryLinks,delete u.lineage,u}function Ds({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:o,toLive:r,options:c,identity:s,childrenOnly:l,isDocument:i}){let a=nr(c,[e,t,n,o].filter(Boolean));if(a.ignored(e)){let k=Bs(),T=a.lineage?Yo(a.lineage,e,k):null;return{report:k,loads:[],lineage:T}}let p=e.ownerDocument,f=a.lineage?ks(a.lineage,{liveRoot:e,localRoot:n,toLive:r}):null,u=a.scripts.execute?Yi(e,a.ignored,p.baseURI):null,y=oo(),b=a.hooks.beforeNodeMorphed===Cn&&a.hooks.afterNodeMorphed===Cn,S={identity:{base:Do(s.base,t||n),local:Do(s.local,n),remote:Do(s.remote,o)},authored:{base:jo(s.base),local:jo(s.local),remote:jo(s.remote)},ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:p.baseURI,localIsBase:!t,childrenOnly:l,skipUnchanged:b,lineage:f?{locals:f.locals}:null},g=a.fastPath&&i&&!l&&b&&t===n,d=null,w=null;if(g){let k=Tl({baseRoot:t,remoteRoot:o,liveRoot:e,toLive:r,o:a,identity:S.identity,baseURI:p.baseURI});S.comparisons=k.comparisons||k.scope,k.bail?w=k.bail:(d=Br(t,n,o,Object.assign({},S,{stats:y,scope:k.scope})),d||(w="chain-unpaired",y=oo()))}d||(d=Br(t||n,n,o,Object.assign({},S,{stats:y}))),g&&(y.fastPathAttempted=1,y.fastPathTaken=w?0:1,y.fastPathFallback=w),d.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(k=>a.hooks[k]!==Cn)&&rl(d.conflicts,d.recoveryLinks,r),a.beforeApply&&a.beforeApply(d.doc);let O=globalThis.__hyperMorphProfile,x=O?performance.now():0,A=wl(e,d.root,d,{toLive:r,localRoot:n,ignored:a.ignored,ignoreAttribute:a.ignoreAttribute,opaque:a.opaque,formState:a.formState,protectFocusedValue:a.protectFocusedValue,restoreFocus:a.restoreFocus,preserve:a.head.preserve,hooks:a.hooks,childrenOnly:l,keepLiveOnly:a.keepLiveOnly,trackInserted:!!f});O&&(O.apply=(O.apply||0)+(performance.now()-x));let v=[];if(a.head.awaitLoads)for(let k of A.applied){if(k.kind!=="insert"||k.node.nodeType!==1)continue;let T=k.node;T.tagName==="LINK"&&/\bstylesheet\b/i.test(T.getAttribute("rel")||"")&&T.getAttribute("href")&&T.closest("head")&&v.push(new Promise(H=>{T.addEventListener("load",()=>H()),T.addEventListener("error",()=>H())}))}let I=null,M=null;if(u){let k=Ji(e,u,{ignored:a.ignored,skip:A.mergedScriptsLive,baseURI:p.baseURI,beforeNodeAdded:a.hooks.beforeNodeAdded,afterNodeAdded:a.hooks.afterNodeAdded,trackRecovery:!!d.recoveryLinks});v.push(...k.loads),I=k.swapped,M=k.vetoed}let P=k=>I&&I.get(k)||k,D=k=>{if(A.keptRuns.has(k))return A.runOf.get(k);let T=A.liveOf.get(k)||A.heldBy.get(k)||A.insertedLive.get(k);return T?P(T):null},$=k=>{let T=k&&A.liveOf.get(k);return T?P(T):null},W=k=>{let T=k&&D(k);return Array.isArray(T)?T[0]:T};if(d.recoveryLinks){let k=(T,J,H)=>(J.namespaceURI?T.getAttributeNS(J.namespaceURI,J.localName):T.getAttribute(J.qualifiedName))===H;ll(d.conflicts,d.recoveryLinks,{lookup:D,vetoed:A.vetoed,vetoedAttrs:A.vetoedAttrs,removedVetoes:A.removedVetoes,vetoedLive:M,liveAttr:k,ignored:a.ignored,liveRoot:e})}let B={applied:A.applied,decisions:d.decisions.map(k=>Object.assign({},k,{node:k.node?$(k.node):null,el:k.el?$(k.el):null,applied:!!(k.node?$(k.node):k.el&&$(k.el))})),conflicts:d.conflicts.map(k=>Object.assign({},k,{node:k.node?k.kind==="text"&&k.recovery.subject.nodeType===8?W(k.node):$(k.node):k.node,el:k.el?k.kind==="structure"?W(k.el):$(k.el):k.el})),localDiverged:d.localDiverged,identities:A.identities,moved:A.moved,replaced:A.replaced,stats:y};return f&&(B.lineage=f.finish(d.lineage,D)),{report:B,loads:v,lineage:f}}var Nl=new WeakMap;function Bs(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:oo()}}function tr(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");return t.lineage===void 0?vl(t):xs(t,t.live.documentElement,o=>vl(o))}function vl(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let o=Nl.get(n);o||(o=es(n),Nl.set(n,o));let r=o("remote",t.remote),c=typeof t.base=="string"&&t.base===""?null:t.base,s=c?o("base",c):null,l=t.local?t.local.root:n.documentElement,i=t.local?t.local.toLive:u=>u;bi(n,r);let{report:a,loads:p,lineage:f}=Ds({liveRoot:n.documentElement,baseRoot:s?s.documentElement:null,localRoot:l,remoteRoot:r.documentElement,toLive:i,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return f?.deliver(a),Promise.all(p).then(()=>a)}function of(e,t,n={}){return tr(Object.assign({},n,{live:e,base:null,remote:t}))}function Ol(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 c=Sr(e,t),s=o[1].toLowerCase()==="html"?c.documentElement:c.body;return{root:s,first:s}}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 js(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return n.lineage===void 0?Ml(e,t,n):xs(n,e,o=>Ml(e,t,o))}function Ml(e,t,n={}){let o=e.ownerDocument,{base:r,...c}=n,s=!!c.children,l=nr(c,[e]);if(l.ignored(e)){let S=Bs();return l.lineage&&Yo(l.lineage,e,S).deliver(S),Promise.resolve(S)}let i=Ol(t,o),a=r!=null?Ol(r,o):null,p,f=null;if(s)p=i.root,f=a?a.root:null;else{if(p=i.first,f=a?a.first:null,!p){let S=nr(c),g=S.lineage?Yo(S.lineage,e,{}):null;S.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),S.hooks.afterNodeRemoved(e));let d={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:oo()};return g&&(d.lineage=g.result,g.deliver(d)),Promise.resolve(d)}if(p.tagName!==e.tagName){let S=nr(c,[e,p]);if(S.hooks.beforeNodeMorphed(e,p)===!1){let w=Bs();return S.lineage&&Yo(S.lineage,e,w).deliver(w),Promise.resolve(w)}let g=Ds({liveRoot:e,baseRoot:f&&f.tagName===e.tagName?f:null,localRoot:e,remoteRoot:p,toLive:w=>w,options:c,identity:c.identity||{},childrenOnly:!0,isDocument:!1}),d=mn(p)?Jo(p,o):o.importNode(p,!1);if(!mn(d))for(;e.firstChild;)d.appendChild(e.firstChild);return S.hooks.beforeNodeAdded(d)===!1?(Dr(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):S.hooks.beforeNodeRemoved(e)===!1?(Dr(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(d),Dr(g.report.conflicts,e,d),S.hooks.afterNodeRemoved(e),S.hooks.afterNodeAdded(d),S.hooks.afterNodeMorphed(e,p),g.report.replaced.push(d),g.report.applied.push({kind:"insert",node:d,parent:d.parentNode},{kind:"remove",node:e,parent:d.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,d),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:u,loads:y,lineage:b}=Ds({liveRoot:e,baseRoot:f,localRoot:e,remoteRoot:p,toLive:S=>S,options:c,identity:c.identity||{},childrenOnly:s,isDocument:!1});return b?.deliver(u),Promise.all(y).then(()=>u)}var El={mergeDocument:tr,morphDocument:of,morphElement:js,merge3:nf,morph:Ps};function Us(e,t,{onWidgetRemoved:n}={}){El.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=Tr.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var sf="hha:upgrade-check:";function $n(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function Hs(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Il(e,t){let n=Hs(e),o=Hs(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let c=0;c<r;c++){let s=n[c]||0,l=o[c]||0;if(s!==l)return s>l}return!1}function lf(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function cf(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Ws({force:e=!1,doc:t,loc:n,fetchFn:o,now:r,ttlMs:c=864e5}={}){if(t=t||(typeof document<"u"?document:null),n=n||(typeof location<"u"?location:null),o=o||(u=>fetch(u)),r=r??Date.now(),!t)return null;let s=$n(t,"hyper-source");if(!s)return null;let l=$n(t,"hyper-version"),i;try{i=new URL(s,n?n.href:void 0)}catch{return null}if(n&&i.origin===n.origin&&i.pathname===n.pathname)return null;let a=`${sf}${i.href}:${l||"none"}`,p,f=e?null:lf(a);if(f&&typeof f.checkedAt=="number"&&r-f.checkedAt<c)p=f.sourceVersion;else{try{let u=await o(i.href);if(!u.ok)throw new Error(`HTTP ${u.status}`);let y=await u.text(),b=new DOMParser().parseFromString(y,"text/html");p=$n(b,"hyper-version")}catch{p=null}cf(a,{checkedAt:r,sourceVersion:p})}return p?{available:Il(p,l||"0.0.0"),currentVersion:l,sourceVersion:p,sourceUrl:i.href}:null}var Kn={};Kr(Kn,{EmptyListInsert:()=>io,MAX_RULE_DEPTH:()=>Uo,MaxRuleDepthExceeded:()=>yo,NoRulesTag:()=>_s,RuleTargetReadOnly:()=>rr,RulesParseError:()=>Bo,ShapeMismatch:()=>or,UnknownRulesVersion:()=>bo,WriteNotRoundTripped:()=>Ur,WriteRefused:()=>sr,WriteRejected:()=>Vs});var Bo=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},bo=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},Uo=20,yo=class extends Error{constructor(t){super(`rule depth exceeded ${Uo} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},or=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},io=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`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}},rr=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},sr=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function af(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var Ur=class extends Error{constructor(t){super(`write did not round-trip at "${af(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},_s=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Vs=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 zn(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 qs(e,t,n,{depth:0,path:[]},o)}function qs(e,t,n,o,r){if(o.depth>Uo)throw new yo(o.path);if(typeof n=="string")return ff(e,t,n,o,r);if(Array.isArray(n)){let[c,s]=n,l=e.find(t,c,r);return Rl(r,o,l),l.map((i,a)=>qs(e,i,s,{depth:o.depth+1,path:[...o.path,a]},r))}if(typeof n=="object"&&n!==null){let c={};for(let[s,l]of Object.entries(n))c[s]=qs(e,t,l,{depth:o.depth+1,path:[...o.path,s]},r);return c}return null}function ff(e,t,n,o,r){if(n.endsWith("[]")){let l=n.slice(0,-2),i=e.find(t,l,r);return Rl(r,o,i),i.map(a=>e.text(a))}if(n.startsWith("@"))return Cl(e,t,n.slice(1));let c=Mn(n);if(c!==-1){let l=n.slice(0,c),i=n.slice(c+1),a=l?e.find(t,l,r):[t];return a.length===0?null:Cl(e,a[0],i)}if(n===".")return e.text(t);let s=e.find(t,n,r);return s.length===0?null:e.text(s[0])}function Rl(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 Cl(e,t,n){if(Ao.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}var Hr=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"]})}),uf=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),Ll=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function ir(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 Fs(e,t){if(ir(e,t))return!0;for(let[n,o]of Object.entries(uf))if(o.includes(t)&&ir(e,n))return!0;return!1}function lr(e){let t=Hr[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function df(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=Hr[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Fs(n,r))||o.bundles.some(r=>ir(n,r)))return n;n=n.parentElement}return null}function Pl(e,t){return!!df(e,t)}var hf=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function pf(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function jl(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 Dl(e,t,n,o,r,c){return(c?Pl(e,t):jl(e,n,r,!1))||!!(o&&(c&&e!==r?e.matches(o):jl(e,o,r,c)))}function mf(e,t){let n=Hr[t];return n.tokens.some(o=>Fs(e,o))||n.bundles.some(o=>ir(e,o))}var gf=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function Bl(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,c=t;if(e.nodeType===1){if(gf.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,c=t.content,n.cloneToLive.set(c,r),n.liveToClone.set(r,c)}}else if(e.nodeType!==11)return;let s=c.firstChild;for(let l=r.firstChild;l&&s;l=l.nextSibling)Bl(l,s,n,o),s=s.nextSibling}function cr(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let c=e.nodeType===9?e:e.ownerDocument;if(!c?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=c.implementation.createHTMLDocument(""),l=r||new WeakMap,i=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let p=lr(t),f=o?b=>mf(b,t)||!!(n&&b.matches(n)):b=>Dl(b,t,p,n,a,!1),u=null;if(a.nodeType!==1||!Dl(a,t,p,n,a,o)){u=s.importNode(a,!0);let b={cloneToLive:l,liveToClone:i,dropped:[],controls:[]};Bl(a,u,b,f);for(let S of b.dropped)S.remove();for(let S=0;S<b.controls.length;S+=2)pf(b.controls[S],b.controls[S+1])}e.nodeType===9&&u&&(s.replaceChild(u,s.documentElement),i.set(e,s),l.set(s,e));let y=b=>{if(hf.test(b))throw new Error(`Filtered content queries do not support stateful selector: ${b}`)};return{root:u,document:s,capability:t,selector:lr(t),cloneToLive:l,liveToClone:i,original(b){return l.get(b)||null},cloneOf(b){return i.get(b)||null},query(b,S=u){return y(b),Array.from(S.querySelectorAll(b),g=>l.get(g)||g)},text(b=u){return(b===u?u:i.get(b))?.textContent||""},html(b=u){return(b===u?u:i.get(b))?.innerHTML??""},clone(b=u){let S=b===u?u:i.get(b);return S?s.importNode(S,!0):null}}}function Hl(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function bf(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Ul(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function Wl(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function _l(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var sn={semanticExclude:!0,find(e,t,n={}){let o=bf(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!Hl(l)));let c=[];n.skip&&c.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&c.push("["+s+"]"),c.length){let l=c.join(", ");r=r.filter(i=>!i.closest||!i.closest(l))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Wl(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Ul(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Ul(e,t,null)},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){let t=e.cloneNode(!0);return _l(t),t},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},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 lo(e,t={}){if(t.exclude===null)return sn;let n=[lr("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 sn;let c=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,l=null,i=()=>l||(l=cr(c,{capability:"data",exclude:t.exclude||null})),a=b=>{let S=i();return b===e?S.cloneOf(e):S.cloneOf(b)||b},p=b=>l?.original(b)||b,f=(b,S)=>{i().liveToClone.set(b,S),i().cloneToLive.set(S,b);let g=b.childNodes||[],d=S.childNodes||[];for(let w=0;w<Math.min(g.length,d.length);w++)f(g[w],d[w])},u=(b,S,g,d)=>{let w=Array.from(b.childNodes).filter(I=>l.cloneOf(I)),x=w[0];for(;x&&w.includes(x);)x=x.nextSibling;for(let I of w)I.remove();if(g==="innerHTML"){let I=s.createElement("template");I.innerHTML=d;for(let M of Array.from(I.content.childNodes))b.insertBefore(M,x||null)}else b.insertBefore(s.createTextNode(d),x||null),Wl(b,d);let A=cr(b,{capability:"data",exclude:t.exclude||null});S.replaceChildren(...Array.from(A.root?.childNodes||[]));let v=I=>{let M=A.original(I);M&&(l.liveToClone.set(M,I),l.cloneToLive.set(I,M));for(let P of Array.from(I.childNodes||[]))v(P)};for(let I of Array.from(S.childNodes))v(I)},y={...sn,find(b,S,g={}){let d=a(b);if(!d?.querySelectorAll)return[];let w=i().query(S,d);g.includeRulesTag||(w=w.filter(A=>!Hl(A)));let O=[];g.skip&&O.push(g.skip);let x=g.templateAttr===null?null:g.templateAttr||"cms-template";if(x&&O.push(`[${x}]`),O.length){let A=O.join(", ");w=w.filter(v=>!v.closest?.(A))}return w},parent(b){let S=a(b)?.parentElement;return S?p(S):null},children(b){return Array.from(a(b)?.children||[],p)},text(b,S){if(S===void 0){let w=p(b);return!w?.matches?.(n)&&!w?.querySelector?.(n)?sn.text(w):(a(b)?.textContent||"").trim()}let g=p(b);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){sn.text(g,S);return}let d=i().cloneOf(g);d?u(g,d,"textContent",S):sn.text(g,S)},attr(b,S,g){let d=p(b);if(g===void 0)return sn.attr(d,S);sn.attr(d,S,g);let w=l?.cloneOf(d);w&&(sn.attr(w,S,g),cr(d,{capability:"data",exclude:t.exclude||null}).root===null&&(w.remove(),l.liveToClone.delete(d),l.cloneToLive.delete(w)))},removeAttr(b,S){let g=p(b);sn.removeAttr(g,S);let d=l?.cloneOf(g);d&&sn.removeAttr(d,S)},prop(b,S,g){let d=p(b);if(g===void 0)return S==="innerHTML"||S==="outerHTML"||S==="textContent"||S==="innerText"?sn.prop(a(d),S):sn.prop(d,S);let w=S==="innerHTML"||S==="textContent"||S==="innerText",O=w?i().cloneOf(d):l?.cloneOf(d);O&&w?u(d,O,S,g):(sn.prop(d,S,g),O&&sn.prop(O,S,g))},clone(b){let S=a(b);if(S===b)return sn.clone(b);let g=s.importNode(S,!0);return _l(g),g},insertAt(b,S,g){let d=p(b),O=y.children(d)[g]||(()=>{for(let v=d.children.length-1;v>=0;v--){let I=d.children[v];if(i().cloneOf(I))return I.nextElementSibling}return d.firstElementChild})(),x=p(S);d.insertBefore(x,O||null);let A=i().cloneOf(d);if(A){let v=i().cloneOf(x);v||(v=s.importNode(x,!0),f(x,v));let I=Array.from(A.children);A.insertBefore(v,I[g]||null)}},insertBefore(b,S){let g=p(b),d=p(S);g.parentNode.insertBefore(d,g);let w=i().cloneOf(g.parentNode);if(w){let O=i().cloneOf(d);O||(O=s.importNode(d,!0),f(d,O));let x=i().cloneOf(g);x?x.before(O):w.appendChild(O)}},insertAfter(b,S){let g=p(b),d=p(S);g.parentNode.insertBefore(d,g.nextSibling);let w=i().cloneOf(g.parentNode);if(w){let O=i().cloneOf(d);O||(O=s.importNode(d,!0),f(d,O));let x=i().cloneOf(g);x?x.after(O):w.appendChild(O)}},identity(b){return p(b)||null},remove(b){let S=p(b),g=i().cloneOf(S);sn.remove(S),g&&sn.remove(g)},replaceWith(b,S){let g=p(b),d=i().cloneOf(g),w=sn.replaceWith(g,S);if(d){let O=cr(w,{capability:"data",exclude:t.exclude||null});if(!O.root)d.remove();else{d.replaceWith(O.root);let x=A=>{let v=O.original(A);v&&(l.liveToClone.set(v,A),l.cloneToLive.set(A,v));for(let I of Array.from(A.childNodes||[]))x(I)};x(O.root)}}return w}};return y}var jn=sn;function $s(e){try{return JSON.parse(e)}catch(t){throw new Bo(`Invalid strict JSON: ${t.message}`,t)}}function wo(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 c=[],s=0;for(;s<r.length;){let l=r[s];if(/\s/.test(l)){s++;continue}if("{}".includes(l)){c.push({type:l,value:l}),s++;continue}if(l==="["){let f=!1,u=s+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:l,value:l}),s++;continue}}if(l==="]"){c.push({type:l,value:l}),s++;continue}if(l===":"){c.push({type:t.COLON,value:l}),s++;continue}if(l===","){c.push({type:t.COMMA,value:l}),s++;continue}if(l==='"'||l==="'"){let f=l,u=s+1;for(;u<r.length&&r[u]!==f;)r[u]==="\\"&&u++,u++;c.push({type:t.STRING,value:r.substring(s+1,u),quoted:!0,sourceQuote:f}),s=u+1;continue}let i=s,a;for(;i<r.length&&!/[{},]/.test(r[i]);)if(r[i]===":"){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 y of f){let b=y.substring(1);if(r.substring(i+1,i+1+b.length)===b){u=!0,i+=b.length;break}}if(!u)break}else if(r[i]==="["){for(i++;i<r.length&&r[i]!=="]";){if(r[i]==='"'||r[i]==="'"){let f=r[i];for(i++;i<r.length&&r[i]!==f;)r[i]==="\\"&&i++,i++}i++}i<r.length&&r[i]==="]"&&i++}else i++;a=r.substring(s,i);let p=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(a)?p=t.NUMBER:a==="true"||a==="false"||a==="null"?p=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(a)&&(p=t.SELECTOR),c.push({type:p,value:a,quoted:!1}),s=i}return c}function o(r){let c="";for(let s=0;s<r.length;s++){let l=r[s];if("{}".includes(l.type)||"[]".includes(l.type)){c+=l.value;continue}if(l.type===t.COLON){c+=l.value;continue}if(l.type===t.COMMA){let i=r[s+1];if(i&&(i.type==="}"||i.type==="]"))continue;c+=l.value;continue}if(l.type===t.STRING&&l.quoted){let i=l.value;l.sourceQuote==="'"&&(i=i.replace(/\\'/g,"'"),i=i.replace(/(\\*)"/g,(a,p)=>p.length%2===0?p+'\\"':a)),c+=`"${i}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){c+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){c+=`"${l.value}"`;continue}c+=`"${l.value}"`}return c}try{let r=n(e),c=o(r);return JSON.parse(c)}catch(r){throw new Bo("Invalid extraction rules syntax: "+r.message,r)}}var Ks="1",Vl=/^[a-zA-Z0-9_-]+$/;function Ho(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!Vl.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Vl})`);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 c=r[0],s=e.attr(c,"data-rules-version");if(s!==Ks)throw new bo(s);return{rules:wo(e.text(c)),tagNode:c}}var yf="script[data-rules-name]";function ql(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ar(e,t){let n=e.find(t,yf,{includeRulesTag:!0}),o=new Set,r=[];for(let c of n){let s=ql(e.attr(c,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let l=e.attr(c,"data-rules-version");if(l!==Ks)throw new bo(l);o.add(s),r.push({name:s,rules:wo(e.text(c))})}return r}function Wr(e,t){let n={};for(let{name:o,rules:r}of ar(e,t))n[o]=zn(e,t,r);return n}function zs(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Wr(jn,t),version:$n(n,"hyper-version")}}var Wo=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},fr=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}},co=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},ur=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 Fl="text/hyper-upgrade";function Gs(e,t){let n=e.find(t,`script[type="${Fl}"]`);if(n.length===0)return null;if(n.length>1)throw new ur(n.length);return e.text(n[0])||null}var wf=new Function("url","return import(url)");async function Xs(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await wf(n)}catch(r){throw new co(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new co("transform must `export default` a function");return o.default}function zl(e,t,n,o){let r=e.length,c=t.length,s=new Array(r).fill(-1);if(o){let d=new Set;for(let w=0;w<r;w++){let O=o[w];!(O>=0&&O<c)||d.has(O)||(s[w]=O,d.add(O))}}if(r===0||c===0)return s;let l=e.map(d=>$l(d,n)),i=t.map(d=>$l(d,n)),a=new Array(c).fill(!1);for(let d of s)d>=0&&(a[d]=!0);let p=new Map;i.forEach((d,w)=>{a[w]||p.set(d,p.has(d)?-1:w)});let f=new Map;l.forEach((d,w)=>{s[w]>=0||f.set(d,(f.get(d)||0)+1)}),l.forEach((d,w)=>{if(s[w]>=0||f.get(d)!==1)return;let O=p.get(d);O===void 0||O===-1||a[O]||(s[w]=O,a[O]=!0)});let u=[];for(let d=0;d<r;d++)s[d]<0&&u.push(d);let y=[];for(let d=0;d<c;d++)a[d]||y.push(d);if(u.length===0||y.length===0)return s;let b=r*c+1,S=xf(e,t,n),g=(d,w)=>S(d,w)*b+Math.abs(d-w);for(let[d,w]of kf(u,y,g))s[d]=w;return s}var Gl=e=>typeof e=="object"&&e!==null;function $l(e,t){if(!Gl(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 xf(e,t,n){if(!Gl(n))return(l,i)=>e[l]===t[i]?0:1;let o=Object.keys(n),r=l=>o.map(i=>JSON.stringify(l?.[i])),c=e.map(r),s=t.map(r);return(l,i)=>{let a=c[l],p=s[i],f=0;for(let u=0;u<o.length;u++)a[u]!==p[u]&&f++;return f}}function kf(e,t,n){return e.length<=t.length?Kl(e,t,n,!1):Kl(t,e,(o,r)=>n(r,o),!0)}function Kl(e,t,n,o){let r=e.length,c=t.length,s=[];for(let f=0;f<=r;f++)s.push(new Float64Array(c+1).fill(1/0));let l=[];for(let f=0;f<=r;f++)l.push(new Uint8Array(c+1));for(let f=0;f<=c;f++)s[r][f]=0;for(let f=r-1;f>=0;f--)for(let u=c-1;u>=0;u--){let y=n(e[f],t[u])+s[f+1][u+1],b=s[f][u+1];y<=b?(s[f][u]=y,l[f][u]=1):s[f][u]=b}let i=[],a=0,p=0;for(;a<r&&p<c;)l[a][p]&&(i.push(o?[t[p],e[a]]:[e[a],t[p]]),a++),p++;return i}function Js(e,t,n,o,r,c,s,l={}){let i=e.find(t,n,l);if(r.length===0){i.forEach(x=>e.remove(x)),Ys(l,"onRowsApplied",c.path,[]);return}let a=r.length>i.length,p=i[0]||null;if(a&&!p&&(p=Nf(e,t,n,l),!p))throw new io(c.path);let f=i.map(x=>Sf(e,x,o,l)),u=null;if(a&&p){u=e.clone(p),l.templateAttr&&e.removeAttr(u,l.templateAttr);let x=e.stripIds(u);x>0&&console.warn(`[hyper-html-api] stripped ${x} id attribute(s) from cloned template at "${c.path.join(".")||"(root)"}"`)}let y=zl(r,f,o,Tf(e,i,r,c,l)),b=i.length>0?e.parent(i[0]):Ef(e,t,n,p,c,l),S=i.length>0?Ql(e,b,i[0]):0,g=Rf(e,i),d=new Set,w=[],O=r.map((x,A)=>{let v=y[A];if(v>=0)return d.add(v),w.push(!1),i[v];w.push(!0);let I=e.clone(u);return e.stripIds(I),I});i.forEach((x,A)=>{d.has(A)||e.remove(x)}),g?Cf(e,b,S,O,w):Lf(e,O,w,b,S),Af(e,O,o,r,c,s,l),Ys(l,"onRowsApplied",c.path,O)}function Ys(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 Tf(e,t,n,o,r){let c=Ys(r,"identifyRows",o.path,n);if(!Array.isArray(c))return null;let s=new Array(n.length).fill(-1),l=new Set,i=new Map(t.map((a,p)=>[e.identity(a),p]));for(let a=0;a<n.length;a++){if(!c[a])continue;let p=i.get(e.identity(c[a]));p===void 0||l.has(p)||(s[a]=p,l.add(p))}return s}function Af(e,t,n,o,r,c,s){t.forEach((l,i)=>{if(n===null){let a=o[i],p=a==null?"":String(a);e.text(l)!==p&&e.text(l,p)}else{let a=c(e,l,n,o[i],{depth:r.depth+1,path:[...r.path,i]},s);a&&a!==l&&(t[i]=a)}})}function Sf(e,t,n,o){return n===null?e.text(t):zn(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function Ql(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 Nf(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),c=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(c,""),l=r?vf(s):0,i=Yr(s),a=t;for(;a;){let p=e.find(a,s,{includeRulesTag:!1,templateAttr:null});for(let f of p)if(e.attr(f,o.templateAttr)!=null&&!(r&&!Mf(e,t,f,l))&&!(i&&!e.matches(e.parent(f),i)))return f;a=e.parent(a)}return null}function vf(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let c=e[r];if(c==="\\")r++;else if(n)c===n&&(n=null);else if(c==='"'||c==="'")n=c;else if(c==="["||c==="(")t++;else if(c==="]"||c===")")t>0&&t--;else if(t===0&&c===">")o++;else{if(t===0&&(c==="+"||c==="~"))return null;if(t===0&&/\s/.test(c)){if(!Of(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function Of(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return Xl(o)||Xl(r)}function Xl(e){return e===">"||e==="+"||e==="~"}function Mf(e,t,n,o){if(o===null)return!0;let r=n;for(let i=0;i<o;i++)if(r=e.parent(r),!r)return!1;let c=e.prop(t,"tagName");if(!c)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(c).toLowerCase())return!1;let l=new Set(Yl(e,r));return Yl(e,t).every(i=>l.has(i))}function Yl(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function Ef(e,t,n,o,r,c){let s=e.parent(o);if(s&&If(e,t,s)&&!Zl(e,s,c))return s;let l=Yr(n);if(!l)throw new io(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let a=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,c)).filter(p=>!Zl(e,p,c));if(a.length===0)throw new io(r.path,`no container matching "${l}" inside this context to hold the new rows`);if(a.length>1)throw new io(r.path,`"${l}" matches ${a.length} containers inside this context, so the new rows have no single destination`);return a[0]}function If(e,t,n){let o=n;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var Jl=["no-data","editor-ui"];function Zl(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||Jl.some(c=>e.attr(o,c)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(c=>Jl.includes(c)))return!0;o=e.parent(o)}return!1}function Cf(e,t,n,o,r){let c=e.children(t),s=c.map(i=>e.identity(i)),l=!1;o.forEach((i,a)=>{let p=e.identity(i),f=n+a;if(s[f]===p)return;if(!r[a]){let y=s.indexOf(p);y!==-1&&(s.splice(y,1),c.splice(y,1))}let u=Math.min(f,c.length);u<c.length?e.insertBefore(c[u],i):c.length?l?e.insertAfter(c[c.length-1],i):(e.insertAt(t,i,f),l=!0):e.insertAt(t,i,0),s.splice(u,0,p),c.splice(u,0,i)})}function Rf(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((c,s)=>[e.identity(c),s])),r=[];for(let c of t){let s=o.get(e.identity(c));if(s===void 0)return!1;r.push(s)}return r.sort((c,s)=>c-s),r[r.length-1]-r[0]===r.length-1}function Lf(e,t,n,o,r){let c=null,s=r;for(let l=0;l<t.length;l++){if(!n[l]){c=t[l];continue}let i=c?e.parent(c):o;if(!i)continue;let a=c?Ql(e,i,c)+1:s++;e.insertAt(i,t[l],a),c=t[l]}}function Jn(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 c=[];if(Zs(n,o,[],c),c.length)throw new or(c);_r(e,t,n,o,{depth:0,path:[]},r)}function _r(e,t,n,o,r,c={}){if(r.depth>Uo)throw new yo(r.path);if(o===void 0)return t;if(typeof n=="string")return Pf(e,t,n,o,r,c);if(Array.isArray(n)){let[s,l]=n;return Js(e,t,s,l,o,r,_r,c),t}if(typeof n=="object"&&n!==null){for(let[s,l]of Object.entries(n)){let i=_r(e,t,l,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},c);i&&i!==t&&(t=i)}return t}return t}function Pf(e,t,n,o,r,c){if(n.endsWith("[]")){let i=n.slice(0,-2);return Js(e,t,i,null,o,r,_r,c),t}if(n.startsWith("@"))return tc(e,t,n.slice(1),o);let s=Mn(n);if(s!==-1){let i=n.slice(0,s),a=n.slice(s+1),p=i?e.find(t,i,c):[t];return p.length===0||tc(e,p[0],a,o),t}if(n===".")return ec(e,t,o),t;let l=e.find(t,n,c);return l.length===0||ec(e,l[0],o),t}function ec(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function tc(e,t,n,o){if(zo.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new rr(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(Gr.has(n)){let r=Xr(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function Zs(e,t,n,o){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]")){Array.isArray(t)?t.forEach((r,c)=>{typeof r=="object"&&r!==null&&o.push({path:hr([...n,c]),expected:"scalar",got:dr(r)})}):o.push({path:hr(n),expected:"array",got:dr(t)});return}t!==null&&typeof t=="object"&&o.push({path:hr(n),expected:"scalar",got:dr(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:hr(n),expected:"array",got:dr(t)});return}let r=e[1];t.forEach((c,s)=>Zs(r,c,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:hr(n),expected:"object",got:dr(t)});return}for(let[r,c]of Object.entries(e))Zs(c,t[r],[...n,r],o)}}}function dr(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function hr(e){return e.join(".")}function pr(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=Qs(t,e,n);return ei(t,e,n),{data:o,summary:n}}function Qs(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=>Qs(o,r,n))):void 0}if(typeof e=="object"&&e!==null){let o={};for(let[r,c]of Object.entries(e)){let s=Qs(c,t?.[r],n);s!==void 0&&(o[r]=s)}return o}}function ei(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)?ei(e[r],t[r],n):n.discarded+=xo(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>ei(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=xo(t))}}function xo(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+xo(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+xo(n),0):1}function ti(e,t,n){let o=ar(e,t),r={carriedOver:0,discarded:0,listItems:0},c={},s=new Set;for(let{name:l,rules:i}of o){if(s.add(l),!Object.prototype.hasOwnProperty.call(n,l)){c[l]={carriedOver:0,discarded:0,listItems:0};continue}let{data:a,summary:p}=pr(n[l],i);Jn(e,t,i,a),c[l]=p,r.carriedOver+=p.carriedOver,r.discarded+=p.discarded,r.listItems+=p.listItems}for(let l of Object.keys(n))s.has(l)||(r.discarded+=xo(n[l]));return{totals:r,byName:c,rulesTagCount:o.length}}async function ni({sourceUrl:e,dataByName:t,fromVersion:n,doc:o,loc:r,fetchFn:c}={}){if(o=o||(typeof document<"u"?document:null),r=r||(typeof location<"u"?location:null),c=c||(d=>fetch(d)),!o)throw new Error("upgrade.run requires a document context");if(e=e||$n(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:$n(o,"hyper-version"),t=t||Wr(jn,o);let l;try{l=await c(s.href)}catch(d){throw new Wo(s.href,d)}if(!l.ok)throw new Wo(s.href,new Error(`HTTP ${l.status}`));let i=await l.text(),a=new DOMParser().parseFromString(i,"text/html"),p=$n(a,"hyper-version"),f=t,u=!1,y=Gs(jn,a);if(y){let w=await(await Xs(y))(f,{fromVersion:n,toVersion:p});if(!w||typeof w!="object"||Array.isArray(w))throw new co("transform must return a plain object map of { rulesName: data }");f=w,u=!0}let{totals:b,byName:S,rulesTagCount:g}=ti(jn,a,f);if(g===0&&Object.keys(f).length>0)throw new fr(s.href);return{html:jf(a),fromVersion:n,toVersion:p,summary:{transformApplied:u,totals:b,byName:S}}}function jf(e){return`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
8
- `+e.documentElement.outerHTML}var oi=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",...Ll],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"]}),Bf=new Set(["textContent","innerText"]);function nc(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var Uf=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function oc(e,t,n=oi){if(!Uf.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>o.startsWith(r)))return`attribute "${o}" can run script`;if(n.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(n.urlAttributes.includes(o)&&t!=null){let r=o==="srcset"?String(t).split(",").map(c=>c.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let c of r){let s=nc(c);if(s&&n.refusedSchemes.includes(s))return`"${s}:" URLs are not allowed in "${o}"`}}return null}function ri(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function Hf(e,t){let n=ri(e,t)||"node",o=e.attr(t,"id");return o?`<${n}#${o}>`:`<${n}>`}function Wf(e,t,n){let o=t;for(;o;){let r=ri(e,o);if(r&&n.refusedTargets.includes(r))return r;o=e.parent(o)}return null}function rc(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function _f(e,t){return ri(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:rc(e,t)}function Vr(e,t=oi){let n=[],o=(i,a)=>(n.push({target:Hf(e,i),reason:a}),!1),r=i=>{let a=Wf(e,i,t);return a?o(i,`inside <${a}>, which is not content`):!0},c=i=>r(i)?rc(e,i)?o(i,"a text write here would delete the data rules tag"):!0:!1,s=(i,a,p)=>{if(!r(i))return!1;let f=oc(a,p,t);return f?o(i,f):!0};return{...e,text(i,a){if(a===void 0)return e.text(i);c(i)&&e.text(i,a)},attr(i,a,p){if(p===void 0)return e.attr(i,a);s(i,a,p)&&e.attr(i,a,p)},removeAttr(i,a){s(i,a,null)&&e.removeAttr(i,a)},prop(i,a,p){if(p===void 0)return e.prop(i,a);if(t.refusedRuleForms.includes(a))return o(i,`"@${a}" writes HTML, only text is allowed`);if(Bf.has(a)){c(i)&&e.prop(i,a,p);return}s(i,a==="className"?"class":a,p)&&e.prop(i,a,p)},remove(i){if(_f(e,i)){o(i,"removing this would delete the data rules tag");return}e.remove(i)},replaceWith(i,a){return a===e.prop(i,"outerHTML")||o(i,'"@outerHTML" writes HTML, only text is allowed'),i},refusals:n,assertClean(){if(n.length)throw new sr(n.slice())}}}function mr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function sc(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function si(e,t,n,o,r={}){let c=[],s=[];function l(a,p,f){if(Array.isArray(a)){let[,u]=a;if(!Array.isArray(p)||!mr(u))return;p.forEach((y,b)=>l(u,y,[...f,b]));return}if(!(!mr(a)||!mr(p)))for(let u of Object.keys(p))Object.prototype.hasOwnProperty.call(a,u)?l(a[u],p[u],[...f,u]):c.push(sc([...f,u]))}function i(a,p,f,u){if(f!==void 0){if(typeof p=="string"){if(p.endsWith("[]")||p==="."||p.startsWith("@"))return;let y=Mn(p),b=y===-1?p:p.slice(0,y);if(!b)return;e.find(a,b,r).length===0&&s.push({path:sc(u),selector:b});return}if(!Array.isArray(p)&&mr(p)&&mr(f))for(let[y,b]of Object.entries(p))i(a,b,f[y],[...u,y])}}return l(n,o,[]),i(t,n,o,[]),{unknownKeys:c,unmatched:s}}function ii(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 Ho(e,o,n)}return null}var gr={extract:(e,t,n={})=>zn(lo(e,n),e,t,n),apply:(e,t,n,o={})=>Jn(lo(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>Ho(jn,e,t),findRules:(e,t)=>ii(jn,e,t),bind:(e,t,n={})=>{let o=ii(jn,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:()=>zn(lo(e,n),e,o.rules,n),set:r=>Jn(lo(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:$s,parseRelaxed:wo,ruleAttrIndex:Mn,splitRule:Gn,errors:Kn,DOM_PROPERTIES:kr},li=e=>!!e&&typeof e.nodeType=="number";function ic(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=Ho(jn,t,"api");if(!n)throw new Kn.NoRulesTag("api");return n.rules}function qf(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function Ff(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function $f(e,t){let n=[];for(;t!==e;){let o=t.parentNode;n.push(Array.prototype.indexOf.call(o.childNodes,t)),t=o}return n.reverse()}function Kf(e,t){return t.reduce((n,o)=>n.childNodes[o],e)}function _o(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function zf(e,t){let n=_o(e,"option"),o=_o(t,"option");n.forEach((i,a)=>o[a].selected=i.selected);let r=_o(e,"input"),c=_o(t,"input");r.forEach((i,a)=>{let p=i.type.toLowerCase();p!=="file"&&(c[a].value=i.value),(p==="checkbox"||p==="radio")&&(c[a].checked=i.checked)});let s=_o(e,"textarea"),l=_o(t,"textarea");s.forEach((i,a)=>l[a].value=i.value)}function ci(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:Mn(e);if(n===-1)return;let o=e.slice(n+1);if(zo.has(o))throw new Kn.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>ci(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,o]of Object.entries(e))ci(o,t[n])}}function Gf(e,t,n){let o={templateAttr:"cms-template"},r=qf(e),c=$f(r,e),s=Ff(r);zf(r,s);let l=Kf(s,c),i=lo(s,{...o,_write:!0}),a=si(i,l,t,n,o);if(a.unknownKeys.length||a.unmatched.length)throw new Kn.WriteRejected(a.unknownKeys,a.unmatched);let p=Vr(i);Jn(p,l,t,n,o),p.assertClean(),ci(t,n);let f=Vr(lo(r,{...o,_write:!0}));Jn(f,e,t,n,o),f.assertClean()}function Xf(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof Kn.WriteRefused?e.details=e.refusals:e instanceof Kn.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof Kn.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 ai(e,t){let n=li(e)?e:document,o=li(e)?t:e;return o===void 0?zn(lo(n),n,ic(n)):gr.bind(n,o).get()}function fi(e,t,n){try{if(!li(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=n===void 0?ic(e):gr.bind(e,n).rules;Gf(e,o,t)}catch(o){throw Xf(o)}return e}var lc={buildForm:Jr,bindFormEvents:Zr,scaffold:So,morphForm:Us,path:xr},cc={checkForUpdate:Ws,run:ni,extractAll:zs,shapeMatch:pr};var Yf={engine:gr,cms:lc,upgrade:cc,extractData:ai,applyData:fi},Jf=Yf;return pc(Zf);})();
1
+ var HyperHtmlApi=(()=>{var Xr=Object.defineProperty;var kc=Object.getOwnPropertyDescriptor;var Ac=Object.getOwnPropertyNames;var Tc=Object.prototype.hasOwnProperty;var Jr=(e,t)=>{for(var n in t)Xr(e,n,{get:t[n],enumerable:!0})},Sc=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ac(t))!Tc.call(e,r)&&r!==n&&Xr(e,r,{get:()=>t[r],enumerable:!(o=kc(t,r))||o.enumerable});return e};var Nc=e=>Sc(Xr({},"__esModule",{value:!0}),e);var yu={};Jr(yu,{applyData:()=>gi,cms:()=>yc,default:()=>bu,engine:()=>gr,extractData:()=>mi,upgrade:()=>wc});var Ar={};Jr(Ar,{fromString:()=>kr,getRuleAtPath:()=>Zr,getValueAtPath:()=>zo,parseConfigKey:()=>Oc,setAtPath:()=>zn,toConfigKey:()=>vc,toString:()=>gn});function gn(e){return e.map(String).join(".")}function vc(e){return e.map(t=>typeof t=="number"?"*":String(t)).join(".")}function Oc(e){return e===""?[]:e.split(".")}function kr(e){return e===""?[]:e.split(".").map(t=>/^\d+$/.test(t)?Number(t):t)}function Zr(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 zo(e,t){let n=e;for(let o of t){if(n==null)return;n=n[o]}return n}function zn(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]=zn(i[o],r,n),i}return{...e&&typeof e=="object"?e:{},[o]:zn((e||{})[o],r,n)}}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"],ko=new Set(Tr),Qr=new Set(["textContent","innerText","innerHTML","value","checked","selected","disabled","readOnly","type","id","className","title"]),io=new Set(["tagName","nodeName","nodeType","nodeValue","childElementCount","classList","baseURI","documentURI","contentType","offsetWidth","offsetHeight","clientWidth","clientHeight","scrollWidth","scrollHeight","currentSrc","duration","paused","dataset"]),yi=new Set(["checked","selected","disabled","readOnly","paused"]);function es(e,t){return t==null?yi.has(e)?!1:"":yi.has(e)?t==="false"?!1:!!t:t}function bn(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}var wi="[*]";function en(e){let t=bn(e),n=t===-1?e:e.slice(0,t),o=n.endsWith(wi),r={selector:o?n.slice(0,-wi.length):n,prop:t===-1?null:e.slice(t+1)||null};return o&&(r.all=!0),r}function ts(e){let t=0,n=null,o=-1,r=!1;for(let i=0;i<e.length;i++){let s=e[i];s==="\\"?i++:n?s===n&&(n=null):s==='"'||s==="'"?n=s:s==="["||s==="("?t++:s==="]"||s===")"?t>0&&t--:t===0&&s===">"?o=i:t===0&&s===","&&(r=!0)}return r||o===-1||!Mc(e,o+1)?null:e.slice(0,o).trim()||null}function Mc(e,t){let n=t,o=e.replace(/\s+$/,"").length;for(;n<o&&/\s/.test(e[n]);)n++;let r=0,i=null;for(;n<o;n++){let s=e[n];if(s==="\\")n++;else if(i)s===i&&(i=null);else if(s==='"'||s==="'")i=s;else if(s==="["||s==="(")r++;else if(s==="]"||s===")")r>0&&r--;else if(r===0&&(s==="+"||s==="~"||/\s/.test(s)))return!1}return!0}function Ao(e,t){if(typeof e=="string")return e.endsWith("[]")?[]:Ec(e)?Ic(t,en(e).prop)?"":null:"";if(Array.isArray(e))return[];if(typeof e=="object"&&e!==null){let n={};for(let[o,r]of Object.entries(e))n[o]=Ao(r,t);return n}return""}function Ec(e){let{prop:t}=en(e);return t!==null&&!ko.has(t)}function Ic(e,t){if(!e||!t)return!1;let n=Cc(e),o=t.toLowerCase();for(let r=0;r<n.length;r++)if(n[r]==="\\")r++;else if(n[r]==="["){let i=n.indexOf("]",r);if(i===-1)return!1;let s=/^\s*([^\s\]=~^|*$]+)/.exec(n.slice(r+1,i));if(s&&s[1].toLowerCase()===o)return!0;r=i}return!1}function Cc(e){let t=0,n=null,o=0;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--:t===0&&(i===">"||i==="+"||i==="~"||/\s/.test(i))&&(o=r+1)}return e.slice(o)}var Sr=new WeakMap;var Rc=new Set(["checked","selected","disabled","readOnly","paused"]);function ns({rules:e,data:t,appRoot:n,cmsRoot:o}){let r=document.createDocumentFragment(),i={rules:e,appRoot:n,cmsRoot:o};return r.appendChild(rs({rule:e,value:t,path:[],ctx:i})),r}function os(e,{rules:t,getData:n,onChange:o}){e.setAttribute("data-hha-form-root",""),Ai.set(e,{rules:t,getData:n,onChange:o}),Lc()}var Ai=new WeakMap,xi=!1;function Lc(){xi||(document.addEventListener("input",ki,!0),document.addEventListener("change",ki,!0),document.addEventListener("click",Pc,!0),xi=!0)}function Ti(e){if(!(e instanceof Element))return null;let t=e.closest("[data-hha-form-root]");return t&&Ai.get(t)||null}function Pc(e){if(!(e.target instanceof Element))return;let t=e.target.closest("[data-hha-action]");if(!t||e.defaultPrevented)return;let n=Ti(t);if(!n)return;let{rules:o,getData:r,onChange:i}=n,s=t.getAttribute("data-hha-action"),l=kr(t.getAttribute("data-hha-path")||"");if(s==="scalar-array-add"){let c=zo(r(),l)||[];i(zn(r(),l,[...c,""]),{structural:!0});return}if(s==="object-array-add"){let c=Zr(o,l);if(!Array.isArray(c))return;let a=zo(r(),l)||[];i(zn(r(),l,[...a,Ao(c[1],c[0])]),{structural:!0});return}if(s==="array-remove"){if(l.length===0)return;let c=l.slice(0,-1),a=l[l.length-1],p=zo(r(),c)||[];if(typeof a!="number")return;let f=p.filter((d,w)=>w!==a);i(zn(r(),c,f),{structural:!0})}}function ki(e){let t=e.target;if(!t?.matches?.("input, textarea, select"))return;let n=Ti(t);if(!n)return;let{getData:o,onChange:r}=n,i=t.closest("[data-hha-path]");if(!i)return;let s=kr(i.getAttribute("data-hha-path")||""),l=t.type==="checkbox"?t.checked:t.value;r(zn(o(),s,l),{structural:!1})}function rs({rule:e,value:t,path:n,ctx:o}){if(typeof e=="string")return e.endsWith("[]")?Bc({rule:e,value:t,path:n,ctx:o}):Dc({rule:e,value:t,path:n,ctx:o});if(Array.isArray(e))return Uc({rule:e,value:t,path:n,ctx:o});if(typeof e=="object"&&e!==null)return jc({rule:e,value:t,path:n,ctx:o});let r=document.createElement("span");return r.textContent="(unsupported rule)",r}function jc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");if(r.className="form-section",r.setAttribute("data-hha-path",gn(n)),n.length>0){let i=document.createElement("div");i.className="form-section-label",i.textContent=Nr(n[n.length-1]),r.appendChild(i)}for(let[i,s]of Object.entries(e)){let l=[...n,i],c=t?.[i];r.appendChild(rs({rule:s,value:c,path:l,ctx:o}))}return r}function Dc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="field-row",r.setAttribute("data-hha-path",gn(n));let i=document.createElement("div");i.className="field-body";let s=document.createElement("label");s.className="field-label",s.textContent=Nr(n[n.length-1]||".")+$c(e);let l=Vc(e,o.appRoot),c=Hc(l,{value:t,rule:e,path:n,appRoot:o.appRoot}),a=c.el;return a.classList.add(l.type==="textarea"?"field-textarea":"field-input"),i.appendChild(s),i.appendChild(a),r.appendChild(i),Sr.set(r,c),r}function Bc({rule:e,value:t,path:n,ctx:o}){let r=document.createElement("div");r.className="form-section",r.setAttribute("data-hha-path",gn(n));let i=document.createElement("div");i.className="form-section-label",i.textContent=Nr(n[n.length-1]),r.appendChild(i);let s=Array.isArray(t)?t:[],l=document.createElement("div");r.appendChild(l),s.forEach((a,p)=>{let f=[...n,p],d=document.createElement("div");d.className="scalar-array-row",d.setAttribute("data-hha-path",gn(f));let w=document.createElement("input");w.type="text",w.className="field-input",w.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",gn(f)),d.appendChild(w),d.appendChild(b),l.appendChild(d)});let c=document.createElement("button");return c.type="button",c.className="array-add",c.textContent="+ add",c.setAttribute("data-hha-action","scalar-array-add"),c.setAttribute("data-hha-path",gn(n)),r.appendChild(c),r}function Uc({rule:e,value:t,path:n,ctx:o}){let[,r]=e,i=Array.isArray(t)?t:[],s=document.createElement("div");s.className="form-section",s.setAttribute("data-hha-path",gn(n));let l=document.createElement("div");l.className="form-section-label",l.textContent=Nr(n[n.length-1]),s.appendChild(l),i.forEach((a,p)=>{let f=[...n,p],d=document.createElement("div");d.className="array-card",d.setAttribute("data-hha-path",gn(f));let w=document.createElement("button");w.type="button",w.className="array-remove",w.textContent="\xD7",w.title="remove item",w.setAttribute("data-hha-action","array-remove"),w.setAttribute("data-hha-path",gn(f)),d.appendChild(w);let b=rs({rule:r,value:a,path:f,ctx:o});b.querySelector(".form-section-label")?.remove(),d.appendChild(b),s.appendChild(d)});let c=document.createElement("button");return c.type="button",c.className="array-add",c.textContent="+ add",c.setAttribute("data-hha-action","object-array-add"),c.setAttribute("data-hha-path",gn(n)),s.appendChild(c),s}function Hc(e,t){let n=Wc(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 Vc(e,t){let n=null;if(e.startsWith("@")?n=e.slice(1):n=en(e).prop,n&&Rc.has(n))return{type:"checkbox"};if(n==="innerHTML")return{type:"textarea"};let o=_c(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(l=>({value:l.getAttribute("value")||l.textContent,text:l.textContent.trim()||l.getAttribute("value")||""}))};if(r==="input"){let s=(o.getAttribute("type")||"text").toLowerCase();if(s==="checkbox"||s==="radio")return{type:"checkbox"};if(s==="number")return{type:"number"}}let i=(o.textContent||"").trim();return i.length>60||i.includes(`
2
+ `)?{type:"textarea"}:{type:"text"}}function _c(e,t){if(!t||e==="."||e===""||e.startsWith("@"))return null;let n=en(e).selector;if(!n)return null;try{return t.querySelector(n)}catch{return null}}function Wc(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 Nr(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 $c(e){return` \xB7 ${e}`}function vr(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 ss(e){let t=new Map;return(n,o)=>{if(typeof o!="string")return vr(o,e);let r=t.get(n);if(r&&r.text===o)return r.doc;let i=vr(o,e);return t.set(n,{text:o,doc:i}),i}}function Si(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 is=()=>!1;function ls(e,t=[]){if(typeof e!="function")return is;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 s=[],l=r,c=!1;for(;l&&l.nodeType===1;){let a=n.get(l);if(a!==void 0){c=a;break}if(s.push(l),e(l,o.has(l))){c=!0;break}if(o.has(l))break;l=l.parentElement}for(let a of s)n.set(a,c);return c}}var Lu=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 Gn(){return{lazyTwins:0,hashRejected:0,similarTiesStrict:0,similarTiesLoose:0,ambiguousMoves:0,certificationPairs:0,certificationVisited:0,fastPathAttempted:0,fastPathTaken:0,fastPathFallback:null}}var Fc="~",Ni="^";function cs(e,t){let n=new WeakMap;if(!e||!t||typeof t!="object"||Array.isArray(t))return n;let o=t[Fc],r=typeof o=="string"?o.split(",").map(Number):null,i=r&&typeof t[Ni]=="string"?t[Ni].split(","):null,s=f=>Number.isInteger(f)&&f>=0,l=0,c=!1,a=f=>{let d=f;for(;d>0;){let w=r[l++];if(l>r.length||!s(w))return!1;d+=w-1}return!0},p=(f,d)=>{if(c)return;if(r){let T=l++,g=r[T];if(T>=r.length||!s(g)){c=!0;return}let h=!i||i[T]===f.tagName.toLowerCase();if(!h||g!==f.children.length){let y=h&&t[d];typeof y=="string"&&y&&n.set(f,y),a(g)||(c=!0);return}}let w=t[d];typeof w=="string"&&w&&n.set(f,w);let b=f.children;for(let T=0;T<b.length;T++)p(b[T],d===""?String(T):`${d}.${T}`)};return p(e,""),n}function vi(e){return t=>{for(let n of e){let o=n(t);if(typeof o=="string"&&o!=="")return o}return null}}var dn=vi([e=>e.getAttribute("data-id"),e=>e.getAttribute("id")]);function Or(e,t,n,o=null,r=null){let i=new Map,s=new Set,l=c=>{if(n(c))return;let a=t(c);a&&(i.has(a)?s.add(a):i.set(a,c))};if(o){let c=a=>{for(let p of a.querySelectorAll(o))l(p);for(let p of a.querySelectorAll("template"))p.content&&c(p.content)};l(e),c(e.tagName==="TEMPLATE"&&e.content?e.content:e)}else{let c=a=>{l(a);let p=a.tagName==="TEMPLATE"&&a.content?a.content.children:a.children;for(let f=0;f<p.length;f++)c(p[f])};c(e)}for(let c of s)i.delete(c),r&&r.add(c),as(c);return i}function as(e){e.startsWith("merge:")&&console.warn(`[hyper-morph] merge disabled for duplicate identity "${e.slice(e.indexOf(":",6)+1)}"`)}var qc=new Set(["href","src","name","type","role"]),Mi=new Set(["SCRIPT","STYLE","TEXTAREA","TEMPLATE","IFRAME","OBJECT","CANVAS","VIDEO","AUDIO","svg","SVG"]);function To(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 Oi(e){return e.replace(/\s+/g," ")}var Kc=0;function Ei({ignored:e=()=>!1,ignoreAttribute:t=()=>!1,stats:n=null}={}){let o=new WeakMap,r=new WeakMap;function i(O){let R=O.attributes,M=R.length;if(M===0)return{all:"",sig:O.tagName+"|"};let j=[],U="",K=[];for(let W=0;W<M;W++){let H=R[W],k=H.name;t(O,k)||j.push(k+"="+H.value),k==="class"?U=H.value.indexOf(" ")<0?H.value:H.value.split(/\s+/).filter(Boolean).sort().join(" "):qc.has(k)&&K.push(k+"="+H.value)}return j.length>1&&j.sort(),K.length>1&&K.sort(),{all:j.join(""),sig:O.tagName+"|"+U+(K.length?"|"+K.join("|"):"")}}function s(O){return O.nodeType===1&&O.tagName==="TEMPLATE"&&O.content?O.content.childNodes:O.childNodes}function l(O){let R=o.get(O);if(R)return R;if(O.nodeType===3)R={hash:"T"+To(O.nodeValue),hint:Oi(O.nodeValue).slice(0,64),sig:null,tok:null};else if(O.nodeType===8)R={hash:"C"+To(O.nodeValue),hint:"",sig:null,tok:null};else if(O.nodeType===1){let M=i(O),j=To(O.tagName+""+M.all),U="";for(let K of a(O))if(K.nodeType===1){let W=l(K);j=To(W.hash,j),U.length<64&&(U+=" "+W.hint)}else j=To(p(K),j),K.kind==="text"&&U.length<64&&(U+=K.value.slice(0,64));R={hash:"E"+j,hint:Oi(U).trim().slice(0,64),sig:M.sig,tok:null}}else R={hash:"N"+O.nodeType,hint:"",sig:null,tok:null};return o.set(O,R),R}function c(O){if(!O.tok){O.tok=new Set;for(let R of O.hint.toLowerCase().split(/[^\p{L}\p{N}]+/u))R&&O.tok.add(R)}return O.tok}function a(O){let R=r.get(O);if(R)return R;R=[];let M=null,j=()=>{M&&(M.value=M.nodes.map(U=>U.nodeValue).join(""),R.push(M),M=null)};for(let U of s(O)){if(U.nodeType===3){M||(M={kind:"text",nodes:[],value:"",parent:O,hash:void 0}),M.nodes.push(U);continue}j(),U.nodeType===8?R.push({kind:"comment",nodes:[U],value:U.nodeValue,parent:O,hash:void 0}):U.nodeType===1&&!e(U)&&R.push(U)}return j(),r.set(O,R),R}function p(O){return O.nodeType===1?l(O).hash:(O.hash===void 0&&(O.hash=(O.kind==="text"?"T":"C")+To(O.value)),O.hash)}function f(O,R){let M=c(l(O)),j=c(l(R));if(M.size===0&&j.size===0)return{coef:1,share:1};if(M.size===0||j.size===0)return null;let U=0;for(let K of M)j.has(K)&&U++;return{coef:U/Math.min(M.size,j.size),share:U/Math.max(M.size,j.size)}}function d(O,R){let M=f(O,R);return!!M&&M.coef>=.5}let w=new WeakMap;function b(O){let R=w.get(O);if(R)return R;R=[];for(let M of O.attributes)t(O,M.name)||R.push([M.namespaceURI||"",M.localName,M.value]);return R.sort((M,j)=>M[0]<j[0]?-1:M[0]>j[0]?1:M[1]<j[1]?-1:M[1]>j[1]?1:0),w.set(O,R),R}let T=new WeakMap;function g(O,R){if(O===R)return!0;if(p(O)!==p(R))return!1;let M=T.get(O);if(M&&M.has(R))return M.get(R);let j=T.get(R);if(j&&j.has(O))return j.get(O);let U=h(O,R),K=U===!0;return U===!1&&n&&n.hashRejected++,M||T.set(O,M=new WeakMap),M.set(R,K),K}function h(O,R){if(O.nodeType===1){if(R.nodeType!==1||O.tagName!==R.tagName||O.namespaceURI!==R.namespaceURI)return!1;let M=b(O),j=b(R);if(M.length!==j.length)return!1;for(let W=0;W<M.length;W++)if(M[W][0]!==j[W][0]||M[W][1]!==j[W][1]||M[W][2]!==j[W][2])return!1;let U=a(O),K=a(R);if(U.length!==K.length)return!1;for(let W=0;W<U.length;W++){if(p(U[W])!==p(K[W]))return!1;if(!g(U[W],K[W]))return Kc}return!0}return R.nodeType===1?!1:O.kind===R.kind&&O.value===R.value}let y=new WeakMap,N=new Map,x=0;function S(O){let R=y.get(O);if(R)return R;let M=p(O),j=N.get(M);j||N.set(M,j=[]);let U=j.find(K=>g(K.unit,O));return R=U?U.key:"K"+x++,U||j.push({unit:O,key:R}),y.set(O,R),R}return{meta:l,unitsOf:a,unitHash:p,similar:d,score:f,childrenOf:s,equalUnits:g,exactUnitKey:S,ignored:e}}var Ii=16,zc=2e3,Gc=3,fs={align:0,certifyVisited:0,certifyScheduled:0};function us(e,t,n){let{meta:o,unitsOf:r,unitHash:i,similar:s,score:l,childrenOf:c,equalUnits:a,ignored:p}=n.analyzer,f=n.baseId||(()=>null),d=n.sideId||(()=>null),w=n.baseKey||(()=>null),b=n.sideKey||(()=>null),T=n.baseDropped||new Set,g=n.sideDropped||new Set,h=n.stats||null,y=h?new Set:null,N=h?new Set:null,x=new Map,S=new Map,O=new Set,R=new Map,M=new Set,j=new Set,U=new Set,K=[],W=[],H=[],k=[],A=zc,J=new Map,_=new Map,F=(V,Z)=>{x.set(V,Z),S.set(Z,V)},Oe=new Set,Ce=new Set,De=null,pe=V=>{let Z=V.nodeType?V.parentNode:V.parent;if(!Z||Z.nodeType!==11)return Z;if(!De){De=new WeakMap;let be=ke=>{for(let we of ke.querySelectorAll("template"))we.content&&(De.set(we.content,we),be(we.content))};for(let ke of[e,t])be(ke.tagName==="TEMPLATE"&&ke.content?ke.content:ke)}return De.get(Z)||null},Te=(V,Z)=>{for(let be=pe(V);be&&!Oe.has(be);be=pe(be))Oe.add(be);for(let be=pe(Z);be&&!Ce.has(be);be=pe(be))Ce.add(be)},ze=V=>{for(let Z=pe(V);Z;Z=pe(Z))if(x.has(Z))return j.has(Z);return!1},Me=V=>{for(let Z=pe(V);Z;Z=pe(Z)){let be=S.get(Z);if(be!==void 0)return j.has(be)}return!1},v=V=>!!V&&V.nodeType===1,G=(V,Z)=>{let be=R.get(V);return!!be&&be.has(Z)},ue=V=>Mi.has(V.tagName),ae=n.comparisons||n.scope,Pe=(V,Z)=>{if(ae){if(ae.same.get(V)===Z)return!0;if(ae.differ.get(V)===Z)return!1}if(!V.isEqualNode(Z))return!1;if(V.tagName==="TEMPLATE")return a(V,Z);let be=V.getElementsByTagName("template");if(be.length===0)return!0;let ke=Z.getElementsByTagName("template");if(be.length!==ke.length)return!1;for(let we=0;we<be.length;we++)if(!a(be[we],ke[we]))return!1;return!0},He=(V,Z)=>{let be=f(V);if(!be)return!0;let ke=d(Z);return!ke||be===ke},ve=V=>{let Z=w(V);return Z&&n.baseIndex.get(Z)===V&&!g.has(Z)?Z:null},Ze=V=>{let Z=b(V);return Z&&n.sideIndex.get(Z)===V&&!T.has(Z)?Z:null},Je=(V,Z)=>{let be=ve(V);if(!be)return!0;let ke=Ze(Z);return!ke||be===ke},pt=globalThis.__hyperMorphProfile,Ye=pt?performance.now():0;pt&&!n.scope&&(o(e),o(t),pt.meta=(pt.meta||0)+(performance.now()-Ye),Ye=performance.now()),F(e,t);let dt=new Set;for(let[V,Z]of n.baseIndex){let be=n.sideIndex.get(V);be&&be.tagName===Z.tagName&&!x.has(Z)&&!S.has(be)&&(F(Z,be),Te(Z,be),dt.add(Z))}if(dt.size){let V=[];if(n.scope)for(let we of n.scope.chain)dt.has(we)&&V.push(we);let Z=[n.scope?n.scope.root:e];for(;Z.length;){let we=Z.pop();dt.has(we)&&V.push(we);let te=c(we);for(let re=te.length-1;re>=0;re--)te[re].nodeType===1&&Z.push(te[re])}let be=new Set;for(let we=V.length-1;we>=0;we--){let te=V[we];n.scope&&n.scope.onChain.has(te)?be.add(te):Pt(te,x.get(te),be)?(j.add(te),U.add(te),h&&h.certificationPairs++):be.add(te)}let ke=new Set;for(let we of V)j.has(we)&&!ke.has(we)&&St(we,ke)}n.scope&&n.scope.head&&Ft(n.scope.head[0],n.scope.head[1]);function St(V,Z){let be=[V];for(;be.length;){let ke=be.pop();if(!Z.has(ke)){Z.add(ke),I(ke);for(let we of r(ke))v(we)&&x.has(we)&&be.push(we)}}}k.push([e,t]);for(let[V,Z]of x)v(V)&&V!==e&&k.push([V,Z]);return Ot(),vt(),pt&&(pt.align=(pt.align||0)+(performance.now()-Ye)),{map:x,reverse:S,moved:M,identical:j,pairIdenticalChildren:I,weak:O,unpair:bt,rematch:vt,insertedByHash:At,refused:N,identityPaired:dt};function vt(){Se(),Ot();for(let V=0;V<H.length;){let Z=H.length;Nt(V,Z),V=Z,Ot(),Se(),Ot()}}function bt(V){let Z=x.get(V);if(!Z)return;R.has(V)||R.set(V,new Set),R.get(V).add(Z);let be=(we,te)=>{x.delete(we),S.delete(te),M.delete(we),j.delete(we),O.delete(we),U.delete(we)},ke=(we,te)=>{for(let re of r(we)){let q=x.get(re);!q||dt.has(re)||!(v(q)?te.contains(q):te.contains(q.nodes[0]))||(be(re,q),v(re)&&ke(re,q))}};be(V,Z),v(V)&&ke(V,Z),K.push(V),W.push(Z)}function At(){let V=new Map;for(let Z of new Set(W)){if(S.has(Z))continue;let be=o(Z).hash;V.has(be)||V.set(be,[]),V.get(be).push(Z)}return V}function Ot(){for(;k.length;){let[V,Z]=k.shift();x.get(V)!==Z||U.has(V)||j.has(V)||nn(V,Z)}}function Bt(V,Z){if(!ue(V))for(let be of r(V))v(be)&&(Z.push(be),Bt(be,Z))}function nn(V,Z){U.add(V);let be=r(V),ke=r(Z);fs.align+=be.length+ke.length,J=new Map,_=new Map;for(let le=0;le<be.length;le++)J.set(be[le],le);for(let le=0;le<ke.length;le++)_.set(ke[le],le);if(V.tagName==="HTML")for(let le of["HEAD","BODY"]){let Ne=be.find(je=>v(je)&&je.tagName===le),Le=ke.find(je=>v(je)&&je.tagName===le);Ne&&Le&&!x.has(Ne)&&!S.has(Le)&&F(Ne,Le)}for(let le=0;le<be.length&&le<ke.length;le++){let Ne=be[le],Le=ke[le];x.has(Ne)||S.has(Le)||(v(Ne)?v(Le)&&Ne.tagName===Le.tagName&&Pe(Ne,Le)&&Ft(Ne,Le):!v(Le)&&Ne.kind===Le.kind&&Ne.value===Le.value&&Ft(Ne,Le))}fe(be,ke);let we=be.filter(le=>!x.has(le)),te=ke.filter(le=>!S.has(le));we.length&&te.length&&(an(we,te),P(we,te),$(we,te,be,ke),me(be,ke));let re=!1,q=!1;for(let le of be){if(!x.has(le)){v(le)&&(K.push(le),Bt(le,K),re=!0);continue}v(le)&&!j.has(le)&&k.push([le,x.get(le)])}for(let le of ke)!S.has(le)&&v(le)&&(W.push(le),Bt(le,W),q=!0);re&&q&&H.push([V,Z])}function Nt(V,Z){for(let be=V;be<Z;be++){let[ke,we]=H[be];if(x.get(ke)!==we)continue;let te=r(ke),re=r(we),q=new Map,le=new Map,Ne=null;for(let Le of te)v(Le)&&(x.has(Le)?Ne=Le:(q.has(Ne)||q.set(Ne,[]),q.get(Ne).push(Le)));Ne=null;for(let Le of re)v(Le)&&(S.has(Le)?Ne=S.get(Le):(le.has(Ne)||le.set(Ne,[]),le.get(Ne).push(Le)));for(let[Le,je]of q){let Ae=le.get(Le);if(!(!Ae||je.length!==Ae.length)&&je.every((Ge,et)=>Ae[et].tagName===Ge.tagName&&He(Ge,Ae[et])&&!G(Ge,Ae[et])))for(let Ge=0;Ge<je.length;Ge++)$t(je[Ge],Ae[Ge])}}}function $t(V,Z){F(V,Z),O.add(V),k.push([V,Z]),Ot()}function an(V,Z){let be=So(V,i),ke=So(Z,i),we=new Map;for(let te of Z){let re=i(te);ke.get(re)===1&&we.set(re,te)}for(let te of V){if(x.has(te))continue;let re=i(te);if(be.get(re)!==1)continue;let q=we.get(re);q&&!S.has(q)&&a(te,q)&&Ft(te,q)}}function Pt(V,Z,be){let ke=[[V,Z]];for(;ke.length;){let[we,te]=ke.pop();if(fs.certifyVisited++,h&&h.certificationVisited++,we.nodeType!==te.nodeType)return!1;if(we.nodeType===3||we.nodeType===8){if(we.nodeValue!==te.nodeValue)return!1;continue}if(we.nodeType!==1){if(!we.isEqualNode(te))return!1;continue}if(we.tagName!==te.tagName||we.namespaceURI!==te.namespaceURI||p(we)!==p(te))return!1;let re=we.attributes,q=te.attributes;if(re.length!==q.length)return!1;for(let Ae=0;Ae<re.length;Ae++){let Ge=re[Ae];if(te.getAttributeNS(Ge.namespaceURI,Ge.localName)!==Ge.value)return!1}let le=x.get(we);if(le!==void 0&&le!==te)return!1;let Ne=S.get(te);if(Ne!==void 0&&Ne!==we)return!1;if(we!==V){if(j.has(we))continue;if(be.has(we))return!1}let Le=c(we),je=c(te);if(Le.length!==je.length)return!1;fs.certifyScheduled+=Le.length;for(let Ae=Le.length-1;Ae>=0;Ae--)ke.push([Le[Ae],je[Ae]])}return!0}function Jt(V,Z){return!v(V)||!(Oe.has(V)||Ce.has(Z))?!0:!!Y(V,Z)||!(ve(V)||Ze(Z))}function Ft(V,Z){if(v(V)&&(Oe.has(V)||Ce.has(Z))){let be=Y(V,Z);if(!be){if(ve(V)||Ze(Z))return;F(V,Z),k.push([V,Z]);return}for(let ke=0;ke<be.length;ke+=2){let we=be[ke],te=be[ke+1],re=x.get(we);re!==void 0&&re!==te&&on(we,re);let q=S.get(te);q!==void 0&&q!==we&&on(q,te),x.get(we)===te&&(M.delete(we),O.delete(we),j.add(we),U.add(we))}}m(V,Z)}function on(V,Z){x.delete(V),S.delete(Z),M.delete(V),j.delete(V),O.delete(V),U.delete(V)}function Y(V,Z){let be=[V,Z,!1],ke=[];for(;be.length;){let we=be.pop(),te=be.pop(),re=be.pop(),q=x.get(re),le=S.get(te);if(re!==V&&(q!==void 0&&q!==te&&dt.has(re)||le!==void 0&&le!==re&&dt.has(le)))return null;if(!(q===te&&j.has(re))&&((q!==void 0||le!==void 0)&&ke.push(re,te),!!v(re))){if(we||q!==void 0&&q!==te||le!==void 0&&le!==re){let Ne=r(re),Le=r(te);for(let je=0;je<Ne.length&&je<Le.length;je++)be.push(Ne[je],Le[je],!0)}else if(Oe.has(re)||Ce.has(te)){let Ne=re.tagName==="TEMPLATE"?re.content:re,Le=te.tagName==="TEMPLATE"?te.content:te;for(let je=Ne.firstElementChild,Ae=Le.firstElementChild;je&&Ae;){if(p(je)){je=je.nextElementSibling;continue}if(p(Ae)){Ae=Ae.nextElementSibling;continue}(x.has(je)||S.has(Ae)||Oe.has(je)||Ce.has(Ae))&&be.push(je,Ae,!1),je=je.nextElementSibling,Ae=Ae.nextElementSibling}}}}return ke}function m(V,Z){F(V,Z),j.add(V),v(V)&&U.add(V)}function I(V){let Z=x.get(V);if(!Z||!v(V))return;let be=r(V),ke=r(Z);for(let we=0;we<be.length&&we<ke.length;we++)x.has(be[we])||m(be[we],ke[we])}function P(V,Z){let be=re=>v(re)&&!ue(re)?o(re).sig+""+o(re).hint:null,ke=So(V,be),we=So(Z,be),te=new Map;for(let re of Z){let q=be(re);q!=null&&we.get(q)===1&&te.set(q,re)}for(let re of V){if(x.has(re))continue;let q=be(re);if(q==null||ke.get(q)!==1)continue;let le=te.get(q);le&&!S.has(le)&&He(re,le)&&F(re,le)}}function $(V,Z,be,ke){let we=new Map;for(let re of Z){if(!v(re)||S.has(re)||ue(re))continue;let q=o(re).sig;we.has(q)||we.set(q,[]),we.get(q).push({el:re,index:_.get(re)})}let te=[];for(let re of V){if(x.has(re)||!v(re)||ue(re))continue;let q=we.get(o(re).sig);if(!q||!q.length)continue;let le=J.get(re),Ne=q.filter(Le=>!S.has(Le.el)).map(Le=>({c:Le,d:Math.abs(Le.index-le)}));Ne.sort((Le,je)=>Le.d-je.d),Ne.length>Ii&&(Ne=Ne.slice(0,Ii));for(let{c:Le,d:je}of Ne){if(!He(re,Le.el))continue;let Ae=l(re,Le.el);Ae&&Ae.coef>=.5&&te.push({b:re,s:Le.el,coef:Ae.coef,share:Ae.share,d:je,bi:le})}}if(te.sort((re,q)=>q.coef-re.coef||q.share-re.share||re.d-q.d||re.bi-q.bi),h&&te.length>1){let re=new Map;for(let q of te){let le=re.get(q.b);le?le.coef===q.coef&&(le.share===q.share?le.strict++:le.loose++):re.set(q.b,{coef:q.coef,share:q.share,strict:0,loose:0})}for(let[q,le]of re)y.has(q)||!(le.strict||le.loose)||(y.add(q),le.strict?h.similarTiesStrict++:h.similarTiesLoose++)}for(let re of te)!x.has(re.b)&&!S.has(re.s)&&F(re.b,re.s)}function Q(V,Z){return v(V)!==v(Z)?!1:v(V)?V.tagName!==Z.tagName||!He(V,Z)?!1:ue(V)||o(V).hint===""||o(Z).hint===""?!0:s(V,Z):V.kind===Z.kind}function B(V,Z){let be=(we,te)=>{let re=te===null?-1:we===Z?_.get(te):J.get(te),q=we[re+1];return q&&!v(q)?q:null},ke=null;for(let we of V){if(v(we)){ke=we;continue}if(x.has(we))continue;let te=ke===null?null:x.get(ke);if(ke!==null&&!te)continue;let re=be(Z,te);re&&!S.has(re)&&re.kind===we.kind&&F(we,re)}}function me(V,Z){B(V,Z);let be=xe(V,Z),ke=(te,re)=>v(te)&&o(te).hint!==""&&o(re).hint===""&&!!re.querySelector("br")&&!be(te,re),we=0;for(let te of V){if(x.has(te)){let q=_.get(x.get(te));q!==void 0&&q>=we&&(we=q+1);continue}let re=0;for(let q=we;q<Z.length&&re<Gc;q++){let le=Z[q];if(!S.has(le)&&(re++,Q(te,le)&&!G(te,le)&&!ke(te,le))){F(te,le),v(te)&&(o(te).hint===""||o(le).hint==="")&&O.add(te),we=q+1;break}}}fe(V,Z)}function xe(V,Z){let be=(ke,we,te)=>{for(let re=we-1;re>=0;re--)if(v(ke[re])&&te(ke[re]))return ke[re];return null};return(ke,we)=>{let te=J.get(ke),re=_.get(we);if(te===re)return!0;let q=be(V,te,Ne=>x.has(Ne)),le=be(Z,re,Ne=>S.has(Ne));return q?x.get(q)===le:!le}}function fe(V,Z){let be=V.filter(q=>v(q)&&!x.has(q)),ke=Z.filter(q=>v(q)&&!S.has(q));if(!be.length||!ke.length)return;let we=So(be,q=>q.tagName),te=So(ke,q=>q.tagName),re=xe(V,Z);for(let q of be){let le=q.tagName;if(we.get(le)!==1||te.get(le)!==1)continue;let Ne=ke.find(Le=>Le.tagName===le);Ne&&!S.has(Ne)&&re(q,Ne)&&He(q,Ne)&&!G(q,Ne)&&(a(q,Ne)?Ft(q,Ne):(F(q,Ne),O.add(q)))}}function Se(){let V=new Map;for(let q of O)if(v(q)&&v(x.get(q))){let le=o(q).hash;V.has(le)||V.set(le,[]),V.get(le).push(q)}if(V.size)for(let q of W){if(S.has(q)||!v(q)||Me(q))continue;let le=V.get(o(q).hash),Ne=le&&le.find(Le=>O.has(Le)&&!G(Le,q)&&He(Le,q)&&Je(Le,q)&&a(Le,q)&&Jt(Le,q));Ne&&(bt(Ne),Ft(Ne,q),Te(Ne,q),M.add(Ne))}let Z=new Map,be=new Map,ke=new Map;for(let q of O){let le=x.get(q);v(q)&&v(le)&&ke.set(le,q)}let we=(q,le)=>{if(!S.has(q))return!Me(q);let Ne=ke.get(q);return Ne===S.get(q)&&Ne!==le&&!Ne.contains(le)},te=q=>{if(S.has(q)){let le=ke.get(q);ke.delete(q),bt(le)}};for(let q of[...W,...ke.keys()]){if(S.has(q)&&!ke.has(q))continue;let le=o(q).hash;if(Z.has(le)||Z.set(le,[]),Z.get(le).push(q),ue(q))continue;let Ne=o(q).sig;be.has(Ne)||be.set(Ne,[]),be.get(Ne).push(q)}let re=new Set;for(let q of O){let le=x.get(q);!v(q)||!v(le)||ue(q)||o(q).hint===""||o(le).hint===""||s(q,le)||re.add(q)}for(let q of[...K,...re]){let le=x.get(q);if(le?!(O.has(q)&&re.has(q)):ze(q))continue;let Ne=et=>{le&&bt(q),te(et)},Le=Z.get(o(q).hash);if(Le){let et=Le.find(Qe=>Qe!==le&&we(Qe,q)&&!G(q,Qe)&&Je(q,Qe)&&a(q,Qe)&&Jt(q,Qe));if(et){Ne(et),Ft(q,et),Te(q,et),M.add(q);continue}}if(ue(q)||A<=0)continue;let je=be.get(o(q).sig);if(!je)continue;let Ae=null,Ge=0;for(let et of je)if(!(et===le||!we(et,q)||!He(q,et)||!Je(q,et)||G(q,et))&&(A--<=0||s(q,et)&&(Ge++,Ae=et,Ge>1)))break;Ge>1&&N&&N.add(q),Ge===1&&(Ne(Ae),F(q,Ae),Te(q,Ae),M.add(q),k.push([q,Ae]))}}}function So(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 Yc={diff:0},Ci=typeof Intl<"u"&&typeof Intl.Segmenter=="function"?new Intl.Segmenter(void 0,{granularity:"word"}):null,Xc=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}\p{Script=Lao}\p{Script=Khmer}\p{Script=Myanmar}]/u,Jc=/[\p{L}\p{M}\p{N}_'’]+|\s+|[\s\S]/gu,Zc=/\P{M}\p{M}*/gu;function Qc(e){if(e==="")return[];if(Ci){let n=[];for(let o of Ci.segment(e))n.push(o.segment);return n}let t=[];for(let n of e.match(Jc))if(Xc.test(n))for(let o of n.match(Zc))t.push(o);else t.push(n);return t}var ea=/^[  ]+$/,ta=e=>ea.test(e)?" ".repeat(e.length):e,Yn=e=>typeof e.k=="string"&&/^\s+$/.test(e.k),wt="",ds=e=>e.every(t=>Yn(t)||t.k===wt),na=/^[\x00-\x7f\u00A0]*$/,oa=/[A-Za-z0-9_']+|[ \u00A0]+|\s|./g;function ra(e){return e===""?[]:e.match(oa)}function tn(e,t=!1){return(t?ra(e):Qc(e)).map(n=>({k:ta(n),raw:n,len:n.length}))}var hn=(...e)=>e.every(t=>na.test(t));function hs(e,t,n){let o=e.length,r=t.length,i=Math.min(o+r,n),s=i+1,l=new Int32Array(2*i+3),c=[],a=o===0&&r===0;for(let w=0;w<=i&&!a;w++){c.push(l.slice(s-w,s+w+1));for(let b=-w;b<=w;b+=2){let T;b===-w||b!==w&&l[s+b-1]<l[s+b+1]?T=l[s+b+1]:T=l[s+b-1]+1;let g=T-b,h=T;for(;T<o&&g<r&&e[T].k===t[g].k;)T++,g++;if(Yc.diff+=1+T-h,l[s+b]=T,T>=o&&g>=r){a=!0;break}}}if(!a)return null;let p=[],f=o,d=r;for(let w=c.length-1;w>0;w--){let b=c[w],T=f-d,g=T+w,h=T===-w||T!==w&&b[g-1]<b[g+1]?T+1:T-1,y=b[h+w],N=y-h;for(;f>y&&d>N;)p.push([0,f-1,d-1]),f--,d--;f===y?(p.push([1,f,d-1]),d--):(p.push([-1,f-1,d]),f--)}for(;f>0&&d>0;)p.push([0,f-1,d-1]),f--,d--;return p.reverse(),p}function sa(e,t,n){let o=f=>f.k===wt;if(!e.some(o)&&!t.some(o))return hs(e,t,n);let r=[],i=[];for(let f=0;f<e.length;f++)o(e[f])||r.push(f);for(let f=0;f<t.length;f++)o(t[f])||i.push(f);let s=hs(r.map(f=>e[f]),i.map(f=>t[f]),n);if(!s)return null;let l=[],c=0,a=0,p=(f,d)=>{for(;c<f&&a<d&&e[c].k===t[a].k;)l.push([0,c++,a++]);let w=hs(e.slice(c,f),t.slice(a,d),n);if(!w)return!1;for(let[b,T,g]of w)l.push([b,T+c,g+a]);return c=f,a=d,!0};for(let[f,d,w]of s)if(f===0){if(!p(r[d],i[w]))return null;l.push([0,c,a]),c++,a++}return p(e.length,t.length)?l:null}function _n(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 s=e.slice(r,e.length-i),l=t.slice(r,t.length-i),c=ua(s,l)?null:sa(s,l,n);if(!c){let h=s.length||l.length?[{bs:r,be:r+s.length,toks:l}]:[];return{hunks:h,cosmetic:o,coarse:!0,parts:h.map(y=>({...y,gap:[],group:0})),cosmeticEq:o}}let a=[],p=(h,y)=>{s[h].raw!==l[y].raw&&o.push({bi:r+h,tok:l[y]})},f=null,d=[],w=0,b=0,T=()=>{f&&a.push(f),f=null;for(let[h,y]of d)p(h,y);d=[],w++};for(let[h,y,N]of c){if(h===0){f&&Yn(s[y])&&!s[y].k.includes(`
3
+ `)?d.push([y,N]):(T(),p(y,N)),b=y+1;continue}(!f||d.length)&&(f&&a.push(f),f={bs:r+b,be:r+b,toks:[],gap:d.map(([x,S])=>({bi:r+x,tok:l[S]})),group:w},d=[]),h===-1?(f.be=r+b+1,b=y+1):f.toks.push(l[N])}T(),ia(a,e);let g=ms(a);return{hunks:g.hunks,cosmetic:o.concat(g.cosmetic),parts:a,cosmeticEq:o}}function ia(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===wt&&t[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<t.length&&t[o.bs].k===wt&&t[o.be].k===wt;)o.bs++,o.be++}}function ms(e,t=()=>!1){let n=[],o=[],r=null,i=-1;for(let s of e){let l=t(s);if(r&&!r.alone&&!l&&s.group===i){r.be=s.be;for(let c of s.gap)r.toks.push(c.tok);for(let c of s.toks)r.toks.push(c);continue}r&&n.push({bs:r.bs,be:r.be,toks:r.toks});for(let c of s.gap)o.push(c);r={bs:s.bs,be:s.be,toks:s.toks.slice(),alone:l},i=s.group}return r&&n.push({bs:r.bs,be:r.be,toks:r.toks}),{hunks:n,cosmetic:o}}var la=(e,t)=>e.bs===t.bs&&e.be===t.be&&ys(e.toks,t.toks);function bs(e,t,n){let o=p=>f=>p.some(d=>la(f,d)),r=ms(e.parts,o(t.parts)),i=ms(t.parts,o(e.parts)),s=e.cosmeticEq.concat(r.cosmetic),l=t.cosmeticEq.concat(i.cosmetic),[c,a]=n?ca(r.hunks,i.hunks,n,s,l):[r.hunks,i.hunks];return{lh:c,rh:a,cosL:s,cosR:l}}function ca(e,t,n,o,r){let i=(b,T)=>b.k===T.k&&b.raw===T.raw,s=[{list:e.map(b=>({...b})),resp:new Set(o.map(b=>b.bi)),raw:new Map(o.map(b=>[b.bi,b.tok]))},{list:t.map(b=>({...b})),resp:new Set(r.map(b=>b.bi)),raw:new Map(r.map(b=>[b.bi,b.tok]))}],l=b=>b.bs===b.be,c=(b,T,g,h)=>{let y=b.list[T];if(!l(y))return h(y)===g?y.toks:null;let N=T?b.list[T-1].be:0,x=T+1<b.list.length?b.list[T+1].bs:n.length;if(g<N||g>x)return null;let S=y.toks,O=y.bs;for(;O>g;){let R=S[S.length-1];if(!i(R,n[O-1])||b.resp.has(O-1))return null;S=[R,...S.slice(0,-1)],O--}for(;O<g;){if(!i(S[0],n[O])||b.resp.has(O))return null;S=[...S.slice(1),S[0]],O++}return S},a=(b,T,g,h,y,N)=>{let x=b.list[T],S=y?g.slice(g.length-h):g.slice(0,h),O=y?g.slice(0,g.length-h):g.slice(h),R={bs:N,be:N,toks:S};if(l(x)){if(!O.length){b.list[T]=R;return}let j={bs:N,be:N,toks:O};y&&(j.lead=!0),b.list.splice(T,1,...y?[j,R]:[R,j]);return}let M={bs:x.bs,be:x.be,toks:O};b.list.splice(T,1,...y?[M,R]:[R,M])},p=(b,T,g,h,y)=>{let N=b.list[T],x=y?g.slice(g.length-h):g.slice(0,h),S=y?g.slice(0,g.length-h):g.slice(h),O={bs:N.bs,be:N.be,toks:x};if(!S.length){b.list[T]=O;return}let R=y?{bs:N.bs,be:N.bs,toks:S,lead:!0}:{bs:N.be,be:N.be,toks:S};b.list.splice(T,1,...y?[R,O]:[O,R])},f=(b,T,g,h)=>{let y=b.list[T],N=g.list[h],x=y.be,S=N.bs;if(x>=S||T+1<b.list.length&&b.list[T+1].bs<=N.be||h>0&&g.list[h-1].be>=y.bs)return!1;for(let _=x;_<S;_++)if(!Yn(n[_])||n[_].k.includes(`
4
+ `))return!1;let O=_=>n.slice(x,S).map((F,Oe)=>_.raw.get(x+Oe)||F),R=[...y.toks,...O(b)],M=[...O(g),...N.toks],j=(_,F,Oe)=>F>=0&&F+Oe.length<=_.length&&Oe.every((Ce,De)=>_[F+De].k===Ce.k),U=(_,F,Oe)=>ds(_)&&n.slice(F,Oe).some(Ce=>!Yn(Ce)),K=_=>_.some(F=>!Yn(F)),W,H,k,A;if(l(y)&&K(y.toks)&&j(M,0,y.toks)){let _=M.slice(y.toks.length);U(_,x,N.be)||(W=x,H=y.toks,k=M.slice(0,y.toks.length),A=[null,{bs:x,be:N.be,toks:_}])}if(W===void 0&&l(N)&&K(N.toks)){let _=R.length-N.toks.length,F=R.slice(0,_);j(R,_,N.toks)&&!U(F,y.bs,S)&&(W=S,H=R.slice(_),k=N.toks,A=[{bs:y.bs,be:S,toks:F},null])}if(W===void 0)return!1;let J=_=>_&&(_.bs<_.be||_.toks.length);return b.list.splice(T,1,...[A[0],{bs:W,be:W,toks:H}].filter(J)),g.list.splice(h,1,...[{bs:W,be:W,toks:k},A[1]].filter(J)),!0},d=s[0],w=s[1];for(let b=0;b<64;b++){let T=!1;e:for(let g=0;g<d.list.length;g++)for(let h=0;h<w.list.length;h++){let y=d.list[g],N=w.list[h];if(!(y.bs===N.bs&&y.be===N.be&&ys(y.toks,N.toks))){for(let x of[!0,!1]){let S=R=>x?R.be:R.bs,O=l(y)?[S(N),y.bs]:[S(y)];for(let R of O){let M=c(d,g,R,S),j=M&&c(w,h,R,S);if(!j)continue;let U=(A,J)=>x?A[A.length-1-J]:A[J],K=0;for(;K<M.length&&K<j.length&&U(M,K).k===U(j,K).k;)K++;if(!K)continue;let W=x?M.slice(0,M.length-K):M.slice(K),H=x?j.slice(0,j.length-K):j.slice(K);if(!(K<M.length&&K<j.length&&!ds(W)&&!ds(H)&&(l(y)&&l(N)||y.bs===N.bs&&y.be===N.be)||!(x?M.slice(M.length-K):M.slice(0,K)).some(A=>!Yn(A)))){if(K===M.length&&K===j.length&&l(y)&&l(N)){if(y.bs===R&&N.bs===R)continue;d.list[g]={bs:R,be:R,toks:M},w.list[h]={bs:R,be:R,toks:j}}else!l(y)&&y.bs===N.bs&&y.be===N.be?(p(d,g,M,K,x),p(w,h,j,K,x)):(a(d,g,M,K,x,R),a(w,h,j,K,x,R));T=!0;break e}}}if(f(d,g,w,h)||f(w,h,d,g)){T=!0;break e}}}if(!T)break}return[d.list,w.list]}var aa=48,fa=.3;function ua(e,t){let n=e.filter(s=>!Yn(s)),o=t.filter(s=>!Yn(s));if(Math.min(n.length,o.length)<aa)return!1;let r=new Map;for(let s of n)r.set(s.k,(r.get(s.k)||0)+1);let i=0;for(let s of o){let l=r.get(s.k);l>0&&(i++,r.set(s.k,l-1))}return i/Math.min(n.length,o.length)<fa}var da=(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},ys=(e,t)=>e.length===t.length&&e.every((n,o)=>n.k===t[o].k);function Ri(e,t,n,o="remote"){let r=_n(e,t),i=_n(e,n),{lh:s,rh:l,cosL:c,cosR:a}=bs(r,i,e),p=v=>v.bs===v.be,f=v=>v.toks.some(G=>typeof G.k=="string"),d=v=>p(v)&&!f(v),w=(v,G)=>G.bs<v.be&&v.bs<G.be,b=(v,G)=>!w(v,G)&&G.bs<=v.be&&v.bs<=G.be&&(p(v)&&f(v)||p(G)&&f(G))&&!(p(v)&&p(G)),T=(v,G)=>v.bs===G.bs&&v.be===G.be&&ys(v.toks,G.toks),g=[],h=new Set;for(let v of s){let G=l.find(ue=>!h.has(ue)&&T(v,ue));G?(h.add(G),g.push({bs:v.bs,be:v.be,side:"both",l:v,r:G,toks:v.toks})):g.push({bs:v.bs,be:v.be,side:"L",l:v,toks:v.toks,lead:!!v.lead})}for(let v of l)h.has(v)||g.push({bs:v.bs,be:v.be,side:"R",r:v,toks:v.toks,lead:!!v.lead});g.sort((v,G)=>v.bs-G.bs||v.be-G.be||G.lead-v.lead);let y=0,N=0;for(let v of g)v.side==="both"&&(y+=v.toks.length-(v.be-v.bs));let x=g.map((v,G)=>G),S=v=>x[v]===v?v:x[v]=S(x[v]),O=(v,G)=>(v=S(v),G=S(G),v===G?!1:(x[v]=G,!0)),R=g.map(v=>da({bs:v.bs,be:v.be,toks:v.toks},e)),M={L:new Map,R:new Map};g.forEach((v,G)=>{let ue=v.side==="both"?["L","R"]:[v.side];for(let ae of ue)for(let Pe of R[G])M[ae].has(Pe)||M[ae].set(Pe,[]),M[ae].get(Pe).push(G)});for(let v of[M.L,M.R])for(let G of v.values())for(let ue=1;ue<G.length;ue++)O(G[0],G[ue]);for(let v=0;v<g.length;v++)for(let G=v+1;G<g.length;G++){let ue=g[v],ae=g[G];ue.side===ae.side&&ue.side!=="both"||ue.bs>ae.be||(w(ue,ae)||b(ue,ae)?O(v,G):ue.bs===ae.bs&&p(ue)&&p(ae)&&N++)}let j=(v,G)=>{let ue=v==="L"?s:l;for(let ae of ue)if(ae.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===G.el))return ae.bs;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="close"&&e[ae].k.el===G.el)return ae;return-1};g.forEach((v,G)=>{if(!(!d(v)||v.side==="both"))for(let ue of v.toks){if(ue.kind!=="open")continue;let ae=j(v.side,ue.k);if(ae<=v.bs)continue;let Pe=new Uint8Array(ae-v.bs),He=[];if(g.forEach((ve,Ze)=>{if(!(ve.side===v.side||p(ve))&&ve.bs<ae&&ve.be>v.bs){He.push(Ze);for(let Je=Math.max(ve.bs,v.bs);Je<Math.min(ve.be,ae);Je++)Pe[Je-v.bs]=1}}),He.length&&Pe.every(ve=>ve===1))for(let ve of He)O(G,ve)}});let U=!0;for(;U;){U=!1;let v=new Map;g.forEach((G,ue)=>{let ae=S(ue),Pe=v.get(ae)||{bs:G.bs,be:G.be,L:!1,R:!1};Pe.bs=Math.min(Pe.bs,G.bs),Pe.be=Math.max(Pe.be,G.be),G.side!=="R"&&(Pe.L=!0),G.side!=="L"&&(Pe.R=!0),v.set(ae,Pe)}),g.forEach((G,ue)=>{for(let[ae,Pe]of v){if(S(ue)===S(ae)||!(Pe.L&&Pe.R))continue;let He=G.bs<Pe.be&&G.be>Pe.bs,ve=p(G)&&f(G)&&(G.bs===Pe.be||G.bs===Pe.bs);(He||ve)&&O(ue,ae)&&(U=!0)}})}let K=new Map;g.forEach((v,G)=>{let ue=S(G);K.has(ue)||K.set(ue,[]),K.get(ue).push(v)});let W=[];for(let v of K.values()){let G=v.some(ae=>ae.side==="L"),ue=v.some(ae=>ae.side==="R");if(G&&ue){let ae=Math.min(...v.map(Ze=>Ze.bs)),Pe=Math.max(...v.map(Ze=>Ze.be)),He=v.filter(Ze=>Ze.side!=="R").map(Ze=>Ze.l).sort((Ze,Je)=>Ze.bs-Je.bs),ve=v.filter(Ze=>Ze.side!=="L").map(Ze=>Ze.r).sort((Ze,Je)=>Ze.bs-Je.bs);W.push({bs:ae,be:Pe,kind:"conflict",localHunks:He,remoteHunks:ve})}else for(let ae of v)W.push({bs:ae.bs,be:ae.be,kind:ae.side,u:ae})}let H=(v,G)=>{let ue=v==="L"?s:l;for(let ae of ue)if(ae.toks.some(Pe=>Pe.kind==="close"&&Pe.k.el===G.el))return ae.bs+.5;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="close"&&e[ae].k.el===G.el)return ae;return 1/0},k=(v,G)=>{let ue=v==="L"?s:l;for(let ae of ue)if(ae.toks.some(Pe=>Pe.kind==="open"&&Pe.k.el===G.el))return ae.bs-.5;for(let ae=0;ae<e.length;ae++)if(e[ae].kind==="open"&&e[ae].k.el===G.el)return ae;return-1/0},A=v=>v.kind==="R"?"R":"L",J=v=>v.kind==="R"?1:0;W.sort((v,G)=>{if(v.bs!==G.bs)return v.bs-G.bs;let ue=v.bs===v.be,ae=G.bs===G.be;if(ue!==ae)return ue?-1:1;if(ue&&ae&&v.kind!=="conflict"&&G.kind!=="conflict"){let He=v.u.toks,ve=G.u.toks,Ze=pt=>pt.length&&pt.every(Ye=>Ye.kind==="open"),Je=pt=>pt.length&&pt.every(Ye=>Ye.kind==="close");if(Ze(He)&&Ze(ve)){let pt=Math.max(...He.map(dt=>H(A(v),dt.k))),Ye=Math.max(...ve.map(dt=>H(A(G),dt.k)));if(pt!==Ye)return Ye-pt}if(Je(He)&&Je(ve)){let pt=Math.min(...He.map(dt=>k(A(v),dt.k))),Ye=Math.min(...ve.map(dt=>k(A(G),dt.k)));return pt!==Ye?Ye-pt:J(G)-J(v)}}let Pe=He=>He.u&&He.u.lead?1:0;return Pe(G)-Pe(v)||J(v)-J(G)||v.be-G.be});let _=[],F=[],Oe=0,Ce=v=>{v>Oe&&(_.push({bs:Oe,be:v,toks:e.slice(Oe,v),source:"base"}),Oe=v)};for(let v of W){if(Ce(v.bs),v.kind==="conflict"){let G=gs(e,v.localHunks,v.bs,v.be),ue=gs(e,v.remoteHunks,v.bs,v.be),ae=o==="local"?G:o==="both"?G.concat(ue):ue,Pe=(Ze,Je)=>{let pt=0;for(let Ye of Ze)Ye.be<=v.bs&&!Je.includes(Ye)&&(pt+=Ye.toks.length-(Ye.be-Ye.bs));return pt},He=v.bs+Pe(s,v.localHunks),ve=v.bs+Pe(l,v.remoteHunks);F.push({bs:v.bs,be:v.be,ls:He,le:He+G.length,rs:ve,re:ve+ue.length,ms:0,me:0,base:e.slice(v.bs,v.be),local:G,remote:ue,resolved:ae}),_.push({bs:v.bs,be:v.be,toks:ae,source:"conflict",localHunks:v.localHunks,localToks:G,keepsLocal:o!=="remote"})}else _.push({bs:v.bs,be:v.be,toks:v.u.toks,source:v.kind==="R"?"remote":"local",localHunks:v.kind==="R"?[]:[v.u.l]});Oe=Math.max(Oe,v.be)}Ce(e.length);let De=0,pe=0;for(let v of _)v.source==="conflict"&&(F[pe].ms=De,F[pe].me=De+v.toks.length,pe++),De+=v.toks.length;let Te=new Map(c.map(v=>[v.bi,v.tok])),ze=new Map(a.map(v=>[v.bi,v.tok])),Me=[];for(let v of _){v.source==="base"&&(v.toks=v.toks.map((G,ue)=>{let ae=v.bs+ue,Pe=Te.get(ae),He=ze.get(ae),ve=Pe&&He?o==="remote"?He:Pe:Pe||He||G;return ve===G?G:{...ve,cosmetic:!0}}));for(let G of v.toks)Me.push({...G,src:v.source})}return{tokens:Me,segments:_,conflicts:F,localHunks:s,remoteHunks:l,collapsedDelta:y,samePoint:N,mapLocalOffset:ha(e,s,_)}}function gs(e,t,n,o){let r=[],i=n;for(let s of t)r=r.concat(e.slice(i,s.bs),s.toks),i=s.be;return r.concat(e.slice(i,o))}var ps=e=>e.reduce((t,n)=>t+n.len,0);function ha(e,t,n){let o=new Int32Array(e.length+1);for(let s=0;s<e.length;s++)o[s+1]=o[s]+e[s].len;let r=t.map(s=>({bs:o[s.bs],be:o[s.be],text:s.toks.map(l=>l.raw).join(""),ref:s})),i=n.map(s=>({bs:o[s.bs],be:o[s.be],len:ps(s.toks),source:s.source,localHunks:s.localHunks||[],localLen:s.localToks?ps(s.localToks):0,keepsLocal:s.keepsLocal,ref:s}));return s=>{let l=null,c=null,a=0,p=0,f=0;for(let w of r){let b=w.bs-f;if(s<=p+b){l=f+(s-p);break}if(p+=b,f=w.bs,s<=p+w.text.length){c=w,a=s-p,l=w.bs;break}p+=w.text.length,f=w.be}l===null&&(l=f+(s-p));let d=0;for(let w of i){if(!c&&l<=w.bs)return d;if(!(c?w.localHunks.includes(c.ref):l<w.be)){d+=w.len;continue}if(w.source==="base")return d+(l-w.bs);if(w.source==="remote")return d+w.len;if(w.source==="local")return d+Math.min(a,w.len);if(!w.keepsLocal||!c)return d+w.len;let T=w.localHunks.indexOf(c.ref),g=ps(gs(e,w.localHunks.slice(0,T),w.ref.bs,c.ref.bs));return d+Math.min(g+a,w.localLen)}return d}}function Go(e,t,n,o="remote"){if(t===n||n===e)return{text:t,conflicts:[],mapLocalOffset:h=>Math.min(h,t.length),granularity:"word"};let r=hn(e,t,n),i=tn(e,r),s=tn(t,r),l=tn(n,r),c=i.length<=2e4&&s.length<=2e4&&l.length<=2e4?Ri(i,s,l,o):null,a="word",p=i;if(!c){let h=y=>y.split(/(?<=\n)/).map(N=>({k:N,raw:N,len:N.length}));p=h(e),c=Ri(p,h(t),h(n),o),a="line"}let f=h=>h.map(y=>y.raw).join(""),d=h=>{let y=[0];for(let N of h)y.push(y[y.length-1]+N.len);return y},w=d(p),b=null,T=null,g=null;if(c.conflicts.length){let h=y=>y.split(/(?<=\n)/).map(N=>({k:N,raw:N,len:N.length}));b=d(a==="line"?h(t):s),T=d(a==="line"?h(n):l),g=d(c.tokens)}return{text:f(c.tokens),conflicts:c.conflicts.map(h=>({bs:w[h.bs],be:w[h.be],ls:b[h.ls],le:b[h.le],rs:T[h.rs],re:T[h.re],ms:g[h.ms],me:g[h.me],base:f(h.base),local:f(h.local),remote:f(h.remote),resolved:f(h.resolved)})),mapLocalOffset:c.mapLocalOffset,granularity:a}}function lo(e,t,n=4e3){if(e===t)return[];let o=hn(e,t),r=tn(e,o),i=tn(t,o),s=_n(r,i,n),l=[0];for(let c of r)l.push(l[l.length-1]+c.len);return s.hunks.map(c=>({bs:l[c.bs],be:l[c.be],text:c.toks.map(a=>a.raw).join("")}))}function Wt(e=2e4*8){return{remaining:e,comparisons:0,sortComparisons:0,mapCells:0,mapWrites:0,coverageChecks:0}}function Rn({base:e,side:t,retained:n,transfers:o,baseAtomKey:r=l=>l.el,sideAtomKey:i=l=>l.el,budget:s=Wt()}){let l=[],c=S=>({status:"fallback",reason:S}),a=S=>S>s.remaining?!1:(s.remaining-=S,!0);if(!a((n.length+o.length)*3))return c("work-limit");for(let[S,O]of[["retained",n],["transfer",o]])for(let R of O){let{from:M,to:j,target:U}=R;if(!Number.isInteger(M)||!Number.isInteger(j)||!Number.isInteger(U)||M<0||j<=M||j>e.text.length||U<0||U+j-M>t.text.length)return c("invalid-range");l.push({...R,kind:S})}let p=Symbol(),f=S=>(O,R)=>{if(!a(1))throw p;return s.sortComparisons++,S(O,R)},d,w;try{d=l.slice().sort(f((S,O)=>S.from-O.from||S.to-O.to)),w=l.slice().sort(f((S,O)=>S.target-O.target||S.to-S.from-(O.to-O.from)))}catch(S){if(S===p)return c("work-limit");throw S}if(!a(l.length*2))return c("work-limit");for(let S=1;S<d.length;S++)if(d[S].from<d[S-1].to)return c("source-overlap");for(let S=1;S<w.length;S++)if(w[S].target<w[S-1].target+w[S-1].to-w[S-1].from)return c("target-overlap");for(let S of d){let O=S.to-S.from;if(!a(O))return c("work-limit");for(let R=0;R<O;R++){let M=S.from+R,j=S.target+R;if(s.comparisons++,e.text[M]!==t.text[j])return c("unequal-occurrence");let U=e.atomAt.get(M),K=t.atomAt.get(j);if(!!U!=!!K||U&&r(U)!==i(K))return c("different-atom")}}let b=e.text.length+t.text.length+2,T=l.reduce((S,O)=>S+(O.to-O.from)*2,2);if(!a(b+T+l.length))return c("work-limit");let g=new Int32Array(e.text.length+1).fill(-1),h=new Int32Array(t.text.length+1).fill(-1);s.mapCells+=b,s.mapWrites+=T;let y=-1,N=!0;for(let S of d){S.target<y&&(N=!1),y=S.target+S.to-S.from;for(let O=0;O<S.to-S.from;O++)g[S.from+O]=S.target+O,h[S.target+O]=S.from+O}return g[e.text.length]=t.text.length,h[t.text.length]=e.text.length,{status:"ready",runs:d,bTo:g,toB:h,monotone:N,covers:(S,O)=>{if(!a(O-S))return null;s.coverageChecks+=O-S;for(let R=S;R<O;R++)if(e.text[R]!==wt&&!/\s/.test(e.text[R])&&g[R]<0)return!1;return!0}}}function ws({base:e,side:t,baseOf:n=()=>null,budget:o=Wt()}){if(e.text===t.text||!e.text.includes(wt)&&!t.text.includes(wt))return{status:"none"};let r=(e.text.length+t.text.length)*8;if(r>o.remaining)return{status:"fallback",reason:"work-limit"};o.remaining-=r,o.boundarySteps=(o.boundarySteps||0)+r;let i=(b,T)=>T<b.length&&(b[T]===wt||/\s/.test(b[T])),s=new Map,l=Symbol(),c=(b,T)=>{let g=b.stackAt[T]||[];if(!s.has(g)){if(g.length>o.remaining)throw l;o.remaining-=g.length,o.boundarySteps+=g.length,s.set(g,g.find(h=>h.block)?.el||null)}return s.get(g)},a=[],p=(b,T)=>{let g=c(e,b),h=c(t,T),y=g&&h&&n(h)!==g?"transfer":"retained",N=a[a.length-1];N&&N.to===b&&N.target+N.to-N.from===T&&N.kind===y&&N.destination===h?N.to++:a.push({from:b,to:b+1,target:T,destination:h,kind:y})},f=0,d=0,w=!1;try{for(;f<e.text.length||d<t.text.length;){if(f<e.text.length&&d<t.text.length&&e.text[f]===t.text[d]){let N=e.atomAt.get(f),x=t.atomAt.get(d);if(!!N!=!!x||N&&n(x.el)!==N.el)return{status:"none"};p(f++,d++);continue}if(!i(e.text,f)&&!i(t.text,d))return{status:"none"};let b=f,T=d;for(;i(e.text,f);)f++;for(;i(t.text,d);)d++;let g=e.text.slice(b,f),h=t.text.slice(T,d);(g.includes(wt)||h.includes(wt))&&(w=!0);let y=0;for(;y<f-b&&y<d-T&&e.text[f-y-1]===t.text[d-y-1];)y++;for(let N=y;N>0;N--)p(f-N,d-N)}}catch(b){if(b===l)return{status:"fallback",reason:"work-limit"};throw b}return w?Rn({base:e,side:t,retained:a.filter(b=>b.kind==="retained"),transfers:a.filter(b=>b.kind==="transfer"),sideAtomKey:b=>n(b.el)||b.el,budget:o}):{status:"none"}}var Li=/\s/,Mr=/\S/;function Tn(e,t,n,o,r,i,s=-1,l=-1){if(!e.length)return-1;r(o,e.length);let c=new Int32Array(e.length),a=0;for(let w=1;w<e.length;w++){for(r(o,1);a&&(r(o,1),e[a]!==e[w]);)a=c[a-1];r(o,1),e[a]===e[w]&&a++,c[w]=a}let p=-1,f=0,d=0;a=0;for(let w=0;w<t.length;w++){for(r(o,1);a&&(r(o,1),e[a]!==t[w]);)a=c[a-1];if(r(o,1),e[a]===t[w]&&a++,a!==e.length)continue;let b=w+1-e.length,T=w+1;for(a=c[a-1];f<n.length&&n[f].from<b;)r(o,1),f++;for(;d<n.length&&n[d].to<T;)r(o,1),d++;if(r(o,6),!(f===n.length||d===n.length||n[f].from!==b||n[d].to!==T||s>=0&&b<l&&T>s)){if(!i)return b;if(p>=0)return-1;p=b}}return p}function Yo(e){return!e.flat.atoms.length&&!e.flat.pins?.length}function xs(e,t,n,o){let r=null;for(let s of t)if(o(n,1),!(s.source!==e.source||s.side!==e.side))for(let l of s.runs){if(o(n,1),l.source!==e.source)continue;let c=Math.max(e.from,l.from),a=Math.min(e.to,l.to);c>=a||(r||(o(n,e.to-e.from),r=new Uint8Array(e.to-e.from)),o(n,a-c),r.fill(1,c-e.from,a-e.from))}if(!r)return!1;o(n,e.to-e.from);let i=!1;for(let s=e.from;s<e.to;s++)if(Mr.test(e.flat.text[s])){if(!r[s-e.from])return!1;i=!0}return i}function ks({source:e,side:t,views:n,eligible:o,blocked:r,baseId:i,model:s,tokensOf:l,budget:c,charge:a}){let{V:p,A:f,idOf:d}=n[t],w=n[1-t];if(e.nodeType!==1||f.identical.has(e)||w.A.identical.has(e)||r.has(e)||!o(e))return null;let b=p.twin(e),T=w.V.twin(e);if(!b||!T||f.map.get(e)!==b||f.reverse.get(b)!==e||w.A.map.get(e)!==T||w.A.reverse.get(T)!==e||!p.here(b)||!w.V.here(T)||!o(b)||!o(T))return null;let g=i(e);if(g!==d(b)||g!==w.idOf(T))return null;let h=s(e,null,c),y=s(b,f,c),N=s(T,w.A,c);if(!Yo(h)||!Yo(y)||!Yo(N))return null;let x=h.flat.text,S=y.flat.text;if(a(c,x.length+S.length*3),!Mr.test(S)||S.length>=x.length)return null;let O=x.startsWith(S),R=x.endsWith(S);if(O===R)return null;let M=O?S.length:0,j=O?x.length:x.length-S.length,U=M,K=j;for(;U<K&&(a(c,1),!!Li.test(x[U]));)U++;for(;K>U&&(a(c,1),!!Li.test(x[K-1]));)K--;if(U===K)return null;let W=l(h,c),H=!1,k=!1;for(let A of W)a(c,1),A.from===U&&(H=!0),A.to===K&&(k=!0);return!H||!k?null:{source:e,side:t,flat:h.flat,from:M,to:j}}function Pi({base:e,views:t,side:n,attempt:o,eligible:r,blocked:i,baseId:s,model:l,tokensOf:c,certificates:a,charge:p,exhausted:f,limit:d}){if(d<=0)return null;let w=Wt(d),{V:b,A:T,idOf:g}=t[n],h=t[1-n],[y,N,x,S]=o,O=null;try{for(let R=y;R<=N;R++){p(w,1);let M=e[R];if(M.nodeType!==1||T.identical.has(M)||h.A.identical.has(M)||i.has(M)||!r(M))continue;let j=ks({source:M,side:n,views:t,eligible:r,blocked:i,baseId:s,model:l,tokensOf:c,budget:w,charge:p});if(!j||xs(j,a,w,p))continue;let{flat:U,from:K,to:W}=j;p(w,(W-K)*2);let H=U.text.slice(K,W).trim();for(let k=x;k<=S;k++){p(w,1);let A=b.units[k],J=b.baseOf(A);if(!J||J===M||J.nodeType!==1||A.nodeType!==1||J.parentNode!==M.parentNode||A.parentNode!==T.map.get(M).parentNode||T.map.get(J)!==A||T.reverse.get(A)!==J||i.has(J)||!r(J)||!r(A)||s(J)!==g(A))continue;let _=l(J,null,w),F=l(A,T,w);if(!Yo(_)||!Yo(F))continue;let Oe=_.flat.text,Ce=F.flat.text;if(p(w,Oe.length),!Mr.test(Oe)||Ce.length<=Oe.length)continue;let De=c(F,w),pe=Tn(Oe,Ce,De,w,p,!0);if(!(pe<0)&&!(Tn(H,Ce,De,w,p,!1,pe,pe+Oe.length)<0)){(O||=[]).push(j);break}}}}catch(R){if(R!==f)throw R}return O}function ji(e,t,n,o,r,i,s){if(i==="both"||n.atoms.length||o.atoms.length||r.atoms.length)return i;let l=i==="remote";if(l?s.rss!==s.rse||s.lss===s.lse||s.local===s.base:s.lss!==s.lse||s.rss===s.rse||s.remote===s.base)return i;for(let c of e){if(c.source!==t||c.side!==(l?1:0)||c.flat.text!==n.text||c.flat.nodes.length!==n.nodes.length||s.be<=c.from||s.bs>=c.to)continue;let a=!0;for(let f=0;f<n.nodes.length;f++){let d=c.flat.nodes[f],w=n.nodes[f];if(d.node!==w.node||d.s!==w.s||d.e!==w.e){a=!1;break}}if(!a)continue;let p=!1;for(let f=s.bs;f<s.be;f++)if(Mr.test(n.text[f])){if(f<c.from||f>=c.to){a=!1;break}p=!0}if(a&&p)return l?"local":"remote"}return i}var Ln="\uFFFC";var pa={caret:0},pn=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(" ")),$i=new Set(["BR","WBR","IMG"]),As=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 Pn(e,t={}){if(e.nodeType===3)return!0;if(e.nodeType!==1)return!1;if(t.ignored&&t.ignored(e)||$i.has(e.tagName))return!0;if(!pn.has(e.tagName))return!As.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(!Pn(r,t)){o=!1;break}return t.inlineCache&&t.inlineCache.set(e,o),o}function ma(e){return!e.firstChild||e.textContent===""&&!e.querySelector("br,img,wbr")}function zt(e,t={}){let n={text:"",marks:[],atoms:[],nodes:[],stackAt:[],pins:[],placeholder:null,via:null},o=(r,i)=>{for(let s of r){if(s.nodeType===3){let f=s.nodeValue;if(!f)continue;n.nodes.push({node:s,s:n.text.length,e:n.text.length+f.length}),n.text+=f;for(let d=0;d<f.length;d++)n.stackAt.push(i);continue}if(s.nodeType!==1)continue;if(t.ignored&&t.ignored(s)){n.pins.push({el:s,i:n.text.length});continue}if(t.skip&&t.skip.has(s))continue;let l=t.via&&t.via(s)||s;l!==s&&(n.via||(n.via=new Map)).set(l,s);let c=s.tagName;if(t.blocks&&t.blocks.has(s)){n.text.length&&n.text[n.text.length-1]!==wt&&(n.stackAt.push(i),n.text+=wt);let f={el:s,tag:c,from:n.text.length,to:-1,depth:i.length,block:!0};n.marks.push(f);let d=i.concat([f]);o(l.childNodes,d),n.stackAt.push(d),n.text+=wt,f.to=n.text.length;continue}let a=pn.has(c)&&ma(l);if($i.has(c)||!pn.has(c)||t.remoteWins&&t.remoteWins(s)||t.atomize&&t.atomize(s)||a){n.atoms.push({i:n.text.length,el:s,key:a?c+":empty":c,stack:i}),n.stackAt.push(i),n.text+=Ln;continue}let p={el:s,tag:c,from:n.text.length,to:-1,depth:i.length};n.marks.push(p),o(l.childNodes,i.concat([p])),p.to=n.text.length}};if(o(e,[]),n.atoms.length===1&&n.atoms[0].el.tagName==="BR"&&n.marks.length===0&&Cr(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 ga(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/ /g,"&nbsp;")}function ba(e){let t="<"+e.tagName.toLowerCase();for(let n of e.attributes)t+=` ${n.name}="${n.value.replace(/"/g,"&quot;")}"`;return t+">"}function vo(e,t,n){let o="",r=[];for(let i=t;i<n;i++){let s=e.stackAt[i],l=0;for(;l<r.length&&l<s.length&&r[l]===s[l];)l++;for(;r.length>l;)o+=`</${r.pop().tag.toLowerCase()}>`;for(;r.length<s.length;){let a=s[r.length];o+=ba(a.el),r.push(a)}let c=e.atomAt.get(i);o+=c?c.el.outerHTML:e.text[i]===wt?"":ga(e.text[i])}for(;r.length;)o+=`</${r.pop().tag.toLowerCase()}>`;return o}function ya(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 Fi(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 Di(e,t=()=>!1){let n=new Map,o=i=>{let s=n.get(i);return s===void 0&&(s="{"+i.map(l=>ya(l,t)).sort().join(",")+"}",n.set(i,s)),s},r="";for(let i=0;i<e.text.length;i++){let s=e.atomAt.get(i);r+=(s?"["+Fi(s.el,t)+"]":e.text[i])+o(e.stackAt[i])}return e.text.length===0&&e.placeholder&&(r+="[br]"),r}function No(e,t,n,o=r=>r.key){let r=[],i=e.text,s=0,l=c=>{if(c<=s)return;let a=i.slice(s,c);if(n)for(let p of a.split(/(?<=\n)/))r.push({k:p,raw:p,len:p.length});else for(let p of tn(a,t))r.push(p)};for(let c of e.atoms)l(c.i),r.push({k:"\0"+o(c),raw:Ln,len:1,atom:!0}),s=c.i+1;return l(i.length),r}function Cr(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 Oo=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 Er(e,t,n,o){let r=Oo(t),i=Oo(n),s=[],l=0,c=0;for(let p of o.hunks){c+=p.bs-l;let f=c+p.toks.length;s.push({bs:r[p.bs],be:r[p.be],ss:i[c],se:i[f],text:e.text.slice(i[c],i[f]),toks:p.toks,lead:!!p.lead}),c=f,l=p.be}let a=new Map;for(let p of o.cosmetic)a.set(p.bi,p.tok.raw);return{hunks:s,respell:a}}function Bi(e,t,n){let o=s=>s===wt||/\s/.test(s),r=s=>s.replace(/[\u001E\s]/g,""),i=[];for(let s of e){let l=t.slice(s.bs,s.be),c=n.slice(s.ss,s.se);if(!l.includes(wt)&&!c.includes(wt)||l.includes(Ln)||c.includes(Ln)||r(l)!==r(c)){i.push(s);continue}let a=0,p=0;for(;;){let f=a,d=p;for(;f<l.length&&o(l[f]);)f++;for(;d<c.length&&o(c[d]);)d++;let w=a,b=p;for(;w<f&&b<d&&l[w]===c[b];)w++,b++;let T=f,g=d;for(;T>w&&g>b&&l[T-1]===c[g-1];)T--,g--;if(T>w||g>b){let h=c.slice(b,g);i.push({bs:s.bs+w,be:s.bs+T,ss:s.ss+b,se:s.ss+g,text:h,toks:[...h].map(y=>({k:y,raw:y,len:1})),lead:s.lead})}if(f>=l.length)break;a=f+1,p=d+1}}return i}function Ui(e,t,n){let o=new Int32Array(t+1).fill(-1),r=new Int32Array(n+1).fill(-1),i=0,s=0,l=c=>{for(;i<c;)o[i]=s,r[s]=i,i++,s++};for(let c of e)l(c.bs),i=c.be,s=c.se;return l(t),o[t]=s,r[s]=t,{bTo:o,toB:r}}function Hi(e,t,n){let o=[],r=0,i=0,s=(l,c)=>{if(r===l&&i===c)return;let a=t.text.slice(i,c);o.push({bs:r,be:l,ss:i,se:c,text:a,toks:tn(a,hn(a)),lead:!1})};for(let l of n.runs)s(l.from,l.target),r=l.to,i=l.target+l.to-l.from;return s(e.text.length,t.text.length),{hunks:o,respell:new Map}}function Vi(e,t,n,o){let r=Oo(t),i=Oo(n),s=(c,a)=>{let p=0,f=c.length;for(;p<f;){let d=p+f>>>1;c[d]<a?p=d+1:f=d}return c[p]===a?p:-1};for(let c of e.hunks)if(s(r,c.bs)<0||s(r,c.be)<0)return null;if(e.hunks.some(c=>s(i,c.ss)<0||s(i,c.se)<0)){if(!o)return null;let c=[];for(let d of e.hunks)c.push(d.ss,d.se);let a=[],p=0,f=0;for(let d of n){let w=f+d.len;for(;p<c.length&&c[p]<=f;)p++;let b=f;for(;p<c.length&&c[p]<w;){let T=c[p++];if(T>b){let g=d.raw.slice(b-f,T-f);a.push(...tn(g,hn(g))),b=T}}if(b===f)a.push(d);else{let T=d.raw.slice(b-f);a.push(...tn(T,hn(T)))}f=w}n=a,i=Oo(n)}let l=[];for(let c of e.hunks){let a=s(r,c.bs),p=s(r,c.be),f=s(i,c.ss),d=s(i,c.se);if(a<0||p<0||f<0||d<0)return null;l.push({bs:a,be:p,toks:n.slice(f,d),gap:[],group:l.length})}return{parts:l,cosmeticEq:[],tokens:n}}function Ts(e,t,n,o={},r=null){return qi(e,t,n,o.base,o.local,o.remote,r,{})}function qi(e,t,n,o,r,i,s,l){let c=hn(Cr(e),Cr(t),Cr(n)),a=No(e,c,!1,o),p=No(t,c,!1,r),f=No(n,c,!1,i),d=a.length>2e4||p.length>2e4||f.length>2e4;d&&(a=No(e,c,!0,o),p=No(t,c,!0,r),f=No(n,c,!0,i));let w=s?.local?Hi(e,t,s.local):null,b=s?.remote?Hi(e,n,s.remote):null,T=w?Vi(w,a,p,!d):_n(a,p),g=b?Vi(b,a,f,!d):_n(a,f);w&&T&&(p=T.tokens),b&&g&&(f=g.tokens);let h,y;if(T&&g){let N=bs(T,g,a);h=Er(t,a,p,{hunks:N.lh,cosmetic:N.cosL}),y=Er(n,a,f,{hunks:N.rh,cosmetic:N.cosR})}else h=w||Er(t,a,p,T),y=b||Er(n,a,f,g);return h.hunks=Bi(h.hunks,e.text,t.text),y.hunks=Bi(y.hunks,e.text,n.text),l.base=e,l.local=t,l.remote=n,l.lines=d,l.baseTokens=a,l.localEdits=h,l.remoteEdits=y,l.localMap=Ui(h.hunks,e.text.length,t.text.length),l.remoteMap=Ui(y.hunks,e.text.length,n.text.length),l.full=null,l}function _i(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Mo=/\s/;function Ir(e,t,n){for(let o=t;o<n;o++)if(!Mo.test(e[o]))return!1;return!0}function wa(e,t,n){let o=e.cache[n]||(e.cache[n]=new Map);if(o.has(t))return o.get(t);let r=n===0?"local":"remote",i=n===0?"remote":"local",s=t.baseMark,l=t[i+"Mark"],c=!t.block&&!t[r]&&!!l&&s.to>s.from;if(c){let a=n===0?e.ML:e.MR,p=n===0?e.MR:e.ML,f=n===0?e.fr:e.fl,d=!1;for(let w=s.from;w<s.to;w++){if(a.bTo[w]>=0){c=!1;break}p.bTo[w]<0&&!Mo.test(e.fb.text[w])&&(d=!0)}if(c&&!d){for(let w=l.from;w<l.to;w++)if(p.toB[w]<0&&!Mo.test(f.text[w])){d=!0;break}}c&&=d}return o.set(t,c),c}function Wi(e,t,n,o,r,i,s,l,c){let a=l===0?e.fl:e.fr,p=null;for(let f=n;f<o;f++){let d=t[f];if(!Ir(a.text,d.ss,d.se))return null;if(Ir(e.fb.text,d.bs,d.be)){if(d.bs<d.be&&d.ss<d.se||Mo.test(e.fb.text[d.bs-1]||"")||Mo.test(e.fb.text[d.be]||""))continue;return null}let w=!1;for(let b=d.bs;b<d.be;b++){if(Mo.test(e.fb.text[b]))continue;let T=null;for(let g of e.fb.stackAt[b]){let h=e.byEl.get(g.el);if(h&&wa(e,h,l)){T=h;break}}if(!T)return null;(p||(p=new Set)).add(T),w=!0}if(!w)return null}if(!p){if((l===0?"local":"remote")!==c)return null;let f=l===0?e.fr:e.fl,d=!1;for(let w=i;w<s;w++){let b=r[w];if(!Ir(e.fb.text,b.bs,b.be))return null;Ir(f.text,b.ss,b.se)||(d=!0)}if(!d)return null}return p||0}function Rr(e){let{out:t,policy:n="remote",L:o,R:r}=e,i=e.provenance||new WeakMap,s=e.textMappers||new WeakMap,l=e.conflicts||[],c=e.decisions||[],a=l.length,p=e.conflict||(u=>l.push(u)),f={textNodes:null,text:"",out:null,atomOut:new Map,breakOut:new Map,node:e.node||null},d=[],w=!!(o&&o.reverse&&o.map&&r&&r.reverse&&r.map),b={base:null,local:null,remote:null};if(!e.prepared&&w&&e.moveIn){let u=ye=>Re=>ye.some(he=>he===Re||he.nodeType===1&&he.contains(Re)),E=u(e.local),L=u(e.remote),D=u(e.base),z=new Set,oe=ye=>{if(!pn.has(ye.tagName))return;let Re=o.map.get(ye),he=r.map.get(ye);(Re&&!E(Re)||he&&!L(he))&&z.add(ye);for(let Ie of ye.children)oe(Ie)};for(let ye of e.base)ye.nodeType===1&&oe(ye);let ge=ye=>Re=>{if(!pn.has(Re.tagName))return!1;let he=ye.reverse.get(Re);return!!he&&(z.has(he)||!D(he))};z.size&&(b.base=ye=>z.has(ye)),b.local=ge(o),b.remote=ge(r)}let T={base:new Set,local:new Set,remote:new Set};if(!e.prepared&&w&&e.moveIn){let u=D=>z=>D.some(oe=>oe===z||oe.nodeType===1&&oe.contains(z)),E=u(e.local),L=u(e.remote);for(let D of zt(e.base,{...e,atomize:b.base}).atoms){let z=o.map.get(D.el),oe=r.map.get(D.el),ge=!!z&&!E(z),ye=!!oe&&!L(oe);!ge&&!ye||(ge&&e.movePlanned?.(D.el,"local",z,null),ye&&e.movePlanned?.(D.el,"remote",oe,null),T.base.add(D.el),z&&!ge&&T.local.add(z),oe&&!ye&&T.remote.add(oe),E(D.el)&&T.local.add(D.el),L(D.el)&&T.remote.add(D.el))}}let g=e.prepared?.base||zt(e.base,{...e,atomize:b.base,skip:T.base}),h=e.prepared?.local||zt(e.local,{...e,atomize:b.local,skip:T.local}),y=e.prepared?.remote||zt(e.remote,{...e,atomize:b.remote,skip:T.remote}),N=new Map(g.atoms.map(u=>[u.el,u])),x={},S=u=>e.prepared?e.prepared.full?.(u)||null:T[u].size?(x[u]||(x[u]=zt(e[u],{...e,atomize:b[u]})),x[u]):null,O=(u,E,L)=>{E.namespaceURI?u.setAttributeNS(E.namespaceURI,E.name,L):u.setAttribute(E.name,L)},R=(u,E,L,D)=>{if(!E&&(!L||!D)){for(let oe of(L||D).attributes)O(u,oe,oe.value);return}let z=new Map;for(let oe of[E,L,D])if(oe)for(let ge of oe.attributes)z.set(ge.name,ge);for(let[oe,ge]of z){let ye=E?E.getAttribute(oe):null,Re=L?L.getAttribute(oe):ye,he=D?D.getAttribute(oe):ye,Ie;Re===he?Ie=Re:Re===ye?(Ie=he,c.push({kind:"attr",el:u,name:oe,source:"remote"})):he===ye?(Ie=Re,c.push({kind:"attr",el:u,name:oe,source:"local"})):(Ie=n==="local"?Re:he,p({kind:"attr",el:u,name:oe,base:ye,local:Re,remote:he,resolved:Ie},{el:u,sample:ge}),c.push({kind:"attr",el:u,name:oe,source:"both"})),Ie!=null&&O(u,ge,Ie)}},M=(u,E,L,D)=>u&&e.mergeAttrs?e.mergeAttrs(u,E,L,D):R(D,u,E,L),j=e.mergeElement||((u,E,L)=>{let D=t.createElement(u.tagName);M(u,E,L,D);let z=E||u,oe=L||u,ge=n==="local"?z.isEqualNode(u)?oe:z:oe.isEqualNode(u)?z:oe;for(let ye of ge.childNodes)D.appendChild(t.importNode(ye,!0));return i.set(D,{base:u,local:E,remote:L}),D}),U=e.cloneUnit||((u,E)=>{let L=t.importNode(u,!0);return i.set(L,{base:null,local:E==="local"?u:null,remote:E==="remote"?u:null}),L}),K=e.atomKey||(u=>Fi(u,()=>!1)),W=(u,E)=>{let L=new Map;for(let D of u.atoms)if(e.remoteWins&&e.remoteWins(D.el)&&pn.has(D.el.tagName))L.set(D,"w"+D.el.tagName+"#"+(D.el.id||""));else if(!w)L.set(D,D.key);else if(u===g)L.set(D,"="+K(D.el));else{let z=E.reverse.get(D.el),oe=z?N.get(z):null;oe?L.set(D,"="+K(oe.el)):z?L.set(D,"m"+K(D.el)):L.set(D,"="+K(D.el))}return D=>L.get(D)},H=W(g,null),k=W(h,o),A=W(y,r),J=e.certifiedOrigins?e.certifiedOrigins(g,h,y,H,k,A):null;if(J?.fallback)return null;if(!J&&!e.prepared&&e.blocks){let u=Wt(),E=ws({base:g,side:h,baseOf:D=>o?.reverse?.get(D)||null,budget:u}),L=ws({base:g,side:y,baseOf:D=>r?.reverse?.get(D)||null,budget:u});(E.status==="ready"||L.status==="ready")&&(J={local:E.status==="ready"?E:null,remote:L.status==="ready"?L:null})}let _=e.prepared||qi(g,h,y,H,k,A,J,f),F=_.lines,Oe=_.baseTokens,Ce=_.localEdits,De=_.remoteEdits,pe=_.localMap,Te=_.remoteMap,ze=g.text.length,Me=u=>new Map(u.atoms.map(E=>[E.el,E])),v=Me(h),G=Me(y),ue=(u,E,L)=>{let D=new Set;if(!w)return D;for(let z of u.atoms){let oe=N.get(E.reverse.get(z.el));oe&&L.bTo[oe.i]<0&&D.add(oe)}return D},ae=ue(h,o,pe),Pe=ue(y,r,Te),He=u=>!Pn(u,{...e,remoteWins:null}),ve=new Set;if(w)for(let u of g.atoms){if(!He(u.el))continue;let E=o.map.get(u.el)||null,L=r.map.get(u.el)||null,D=E&&!L?E:L&&!E?L:null;D&&(v.has(D)||G.has(D))&&!D.isEqualNode(u.el)&&ve.add(u)}let Ze=1,Je=(u,E)=>({id:Ze++,tag:u,base:null,local:null,remote:null,rank:E}),pt=new Map,Ye=[];for(let u of g.marks){let E=Je(u.tag,u.depth);E.block=!!u.block,E.base=u.el,E.baseMark=u,pt.set(u.el,E),Ye.push(E)}let dt=(u,E)=>{let L=-1,D=-1;for(let z=u.from;z<u.to;z++){let oe=E[z];oe>=0&&(L<0&&(L=oe),D=oe+1)}return L<0?null:[L,D]},St=(u,E,L,D)=>{for(let z of u.marks){let oe=L?L.reverse.get(z.el):null;oe&&L.identical.has(oe)&&L.pairIdenticalChildren&&L.pairIdenticalChildren(oe);let ge=oe?pt.get(oe):null;if(ge&&ge[E]&&(ge=null),!ge){let ye=dt(z,D),Re=0;if(ye)for(let he of Ye){if(he.tag!==z.tag||he[E]||!!he.block!=!!z.block)continue;let Ie=Math.min(ye[1],he.baseMark.to)-Math.max(ye[0],he.baseMark.from);(Ie>Re||Ie===Re&&Ie>0&&Math.abs(he.rank-z.depth)<Math.abs(ge.rank-z.depth))&&(ge=he,Re=Ie)}}ge||(ge=Je(z.tag,z.depth),ge.block=!!z.block,ge.new=E),ge[E]=z.el,ge[E+"Mark"]=z,pt.set(z.el,ge)}};St(h,"local",o,pe.toB),St(y,"remote",r,Te.toB);let vt=u=>u.merged||u,bt=u=>{let E=new Set;for(let L of u)L.block||E.add(pt.get(L.el));return E},At=new Map,Ot=u=>{let E=At.get(u);return E||(E=bt(u),At.set(u,E)),E},Bt=(u,E)=>{let L=[],D=null;for(let z=0;z<ze;z++){let oe=E[z];if(oe<0){D&&L.push(D),D=null;continue}let ge=Ot(g.stackAt[z]),ye=Ot(u.stackAt[oe]),Re=new Set,he=new Set;for(let Ie of ye)ge.has(Ie)||Re.add(Ie);for(let Ie of ge)ye.has(Ie)||he.add(Ie);if(!Re.size&&!he.size){D&&L.push(D),D=null;continue}if(D&&_i(D.added,Re)&&_i(D.removed,he)){D.be=z+1;continue}D&&L.push(D),D={bs:z,be:z+1,added:Re,removed:he}}return D&&L.push(D),L},nn=Bt(h,pe.bTo),Nt=Bt(y,Te.bTo),$t=u=>u.be>u.bs?[u.bs,u.be-1]:[u.bs-1,u.bs],an=(u,E)=>{if(ze===0)return null;let[L,D]=$t(u);for(let z of E){if(z.be<=L)continue;if(z.bs>D)break;let oe=z.bs<=L&&D<z.be;return oe&&u.text===""&&z.bs===u.bs&&z.be===u.be?"straddle":oe?z:u.be>u.bs?"straddle":null}return null},Pt=u=>u.bs===u.be,Jt=(u,E,L=null)=>{let D=!1;for(let z=u.bs;z<u.be;z++){let oe=g.text[z];if(oe===wt)D=!0;else if(!/\s/.test(oe))return!1}for(let z=u.ss;z<u.se;z++){let oe=E.text[z];if(oe===wt)D=!0;else if(!/\s/.test(oe)){let ge=L&&e.scopeUnits&&Pt(u)&&E.atomAt.get(z);if(!ge||!He(ge.el)||L.ss!==L.se||L.bs>=L.be)return!1;for(let Re=L.bs;Re<L.be;Re++)if(!/\s/.test(g.text[Re]))return!1;let ye=E===h?1:2;if(!e.scopeUnits[ye].includes(ge.el)||(ye===1?o:r)?.reverse.has(ge.el))return!1;D=!0}}return D},Ft=(u,E)=>u.bs<E.be&&E.bs<u.be,on=(u,E)=>u.bs<=E.be&&E.bs<=u.be&&Pt(u)!==Pt(E),Y=(u,E)=>g.text.slice(u.bs,u.be).includes(wt)||E.text.slice(u.ss,u.se).includes(wt),m=u=>{if(Pt(u))return!1;let E=u.bs,L=u.be;for(;E>0&&/\s/.test(g.text[E-1]);)E--;for(;L<g.text.length&&/\s/.test(g.text[L]);)L++;return(E===0||g.text[E-1]===wt)&&(L===g.text.length||g.text[L]===wt)},I=(u,E)=>!Y(u,E)&&!m(u),P=(u,E)=>Ft(u,E)||on(u,E)&&!(u.transferIn||u.transferOut||E.transferIn||E.transferOut)&&!(Jt(u,h,E)&&I(E,y))&&!(Jt(E,y,u)&&I(u,h)),$=(u,E)=>{if(u.bs!==E.bs||u.be!==E.be||u.toks.length!==E.toks.length)return!1;let L=u.ss,D=E.ss;for(let z=0;z<u.toks.length;z++){let oe=u.toks[z],ge=E.toks[z];if(oe.k!==ge.k||oe.atom&&!h.atomAt.get(L).el.isEqualNode(y.atomAt.get(D).el))return!1;L+=oe.len,D+=ge.len}return!0},Q=(u,E,L,D)=>{for(let z of g.atoms){if(z.i<u.bs||z.i>=u.be||D.has(z)||ve.has(z))continue;let oe=E.bTo[z.i],ge=oe>=0?L.atomAt.get(oe):null;if(ge&&!ge.el.isEqualNode(z.el))return!0}return!1},B=[],me=null,xe=null,fe=Ce.hunks,Se=De.hunks,V=0,Z=0,be=0,ke=0,we=0,te=u=>{u>be&&(B.push({src:"base",from:be,to:u,dL:ke,dR:we}),be=u)};for(;V<fe.length||Z<Se.length;){let u=fe[V],E=Se[Z],L=!!u&&(!E||u.bs<E.bs||u.bs===E.bs&&u.be<=E.be&&!E.lead);if(u&&E&&u.bs===E.bs&&Pt(u)&&Pt(E)){let Ht=Jt(u,h),Ko=Jt(E,y);Ht!==Ko&&(L=Ko)}let D=L?u:E,z=L?E:u,oe=!!z&&$(u,E),ge=!!z&&(L?!!fe[V+1]&&$(fe[V+1],E):!!Se[Z+1]&&$(u,Se[Z+1])),ye=!!z&&!oe&&!ge&&(ze===0||P(u,E)),Re=ye,he=an(D,L?Nt:nn);if(he==="straddle"&&(Re=!0),!Re&&D.be>D.bs&&(Re=Q(D,L?Te:pe,L?y:h,L?ae:Pe)),!Re&&oe){te(D.bs),B.push({src:"both",lfrom:u.ss,rfrom:E.ss,len:D.text.length,owner:u.owner||E.owner||null,transfer:u.transferIn||E.transferIn||null}),be=D.be,ke+=D.text.length-(D.be-D.bs),we+=D.text.length-(D.be-D.bs),V++,Z++;continue}if(!Re){te(D.bs),B.push({src:L?"local":"remote",from:D.ss,to:D.se,inherit:he&&he!=="straddle"?he:null,owner:D.owner||null,transfer:D.transferIn||null}),be=D.be,L?(ke+=D.text.length-(D.be-D.bs),V++):(we+=D.text.length-(D.be-D.bs),Z++);continue}let Ie=D.bs,Xe=D.be,nt=V,at=Z,jt=Ht=>Ht.bs<Xe&&Ht.be>Ie||Pt(Ht)&&(Ht.bs===Ie||Ht.bs===Xe);L?nt++:at++,ye&&(Ie=Math.min(Ie,z.bs),Xe=Math.max(Xe,z.be),L?at++:nt++);let Rt=!0;for(;Rt;){for(Rt=!1;nt<fe.length&&jt(fe[nt]);)Ie=Math.min(Ie,fe[nt].bs),Xe=Math.max(Xe,fe[nt].be),nt++,Rt=!0;for(;at<Se.length&&jt(Se[at]);)Ie=Math.min(Ie,Se[at].bs),Xe=Math.max(Xe,Se[at].be),at++,Rt=!0}let ln=Ie+ke,Qt=Ie+we,un=Xe-Ie,mn=Xe-Ie;for(let Ht=V;Ht<nt;Ht++)un+=fe[Ht].text.length-(fe[Ht].be-fe[Ht].bs);for(let Ht=Z;Ht<at;Ht++)mn+=Se[Ht].text.length-(Se[Ht].be-Se[Ht].bs);let In=ln+un,Cn=Qt+mn;if(te(Ie),V<nt&&Z<at&&!J&&!e.prepared&&!e.nativeTransfers&&!e.sourceRetentions&&!g.atoms.length&&!h.atoms.length&&!y.atoms.length&&!g.pins.length&&!h.pins.length&&!y.pins.length){me||={fb:g,fl:h,fr:y,ML:pe,MR:Te,byEl:pt,cache:[null,null]};let Ht=Wi(me,fe,V,nt,Se,Z,at,0,n),Ko=Wi(me,Se,Z,at,fe,V,nt,1,n);if(Ht===null!=(Ko===null)){let Yr=Ht!==null,bi=Yr?Ht:Ko;if(bi){xe||=new Map;for(let xc of bi)xe.set(xc,Yr?"local":"remote")}B.push(Yr?{src:"remote",from:Qt,to:Cn}:{src:"local",from:ln,to:In}),be=Xe,ke+=un-(Xe-Ie),we+=mn-(Xe-Ie),V=nt,Z=at;continue}}let qt={kind:"text",node:e.node||null,base:vo(g,Ie,Xe),local:vo(h,ln,In),remote:vo(y,Qt,Cn),resolved:null,range:null,bs:Ie,be:Xe,lss:ln,lse:In,rss:Qt,rse:Cn},ro=e.sourceRetentions?ji(e.sourceRetentions,e.scope?.base,g,h,y,n,qt):n;qt.resolved=ro==="local"?qt.local:ro==="remote"?qt.remote:qt.local+qt.remote,ro!=="remote"&&B.push({src:"local",from:ln,to:In,conflict:qt}),ro!=="local"&&B.push({src:"remote",from:Qt,to:Cn,conflict:qt});let so={site:"inline",policy:ro,fb:g,fl:h,fr:y,scope:e.scope||null,synthetic:!!e.synthetic,full:S,merged:f};d.push(so),p(qt,so),be=Xe,ke+=un-(Xe-Ie),we+=mn-(Xe-Ie),V=nt,Z=at}te(ze);let re=g.text,q=[];if(Ce.respell.size||De.respell.size){let u=Oo(Oe),E=[];for(let L=0;L<Oe.length;L++){let D=Oe[L].raw,z=Ce.respell.get(L)??D,oe=De.respell.get(L)??D;(z!==D||oe!==D)&&q.push([u[L],z!==D&&oe!==D?"both":z!==D?"local":"remote"]),E.push(z===oe?z:z===D?oe:oe===D||n==="local"?z:oe)}re=E.join("")}let le="",Ne=[],Le=[],je=[],Ae=[];for(let u of B){let E=le.length;if(u.src==="base"){for(let L=u.from;L<u.to;L++)Ne.push(L),Le.push(e.nativeTransfers?pe.bTo[L]:L+u.dL),je.push(e.nativeTransfers?Te.bTo[L]:L+u.dR),Ae.push(u);le+=re.slice(u.from,u.to)}else if(u.src==="both"){for(let L=0;L<u.len;L++){let D=u.transfer&&(u.transfer.side==="remote"?u.rfrom+L:u.lfrom+L);Ne.push(u.transfer&&D>=u.transfer.ss&&D<u.transfer.se?u.transfer.bs+D-u.transfer.ss:-1),Le.push(u.lfrom+L),je.push(u.rfrom+L),Ae.push(u)}le+=h.text.slice(u.lfrom,u.lfrom+u.len)}else{let L=u.src==="local"?h:y,D=u.transfer&&e.nativeTransfers.byOrigin[u.src==="local"?"remote":"local"].get(u.transfer.key);for(let z=u.from;z<u.to;z++){let oe=u.transfer&&z>=u.transfer.ss&&z<u.transfer.se?u.transfer.bs+z-u.transfer.ss:-1,ge=oe>=0&&(!D||D.destination===u.owner)?(u.src==="local"?Te:pe).bTo[oe]:-1;Ne.push(oe),Le.push(u.src==="local"?z:ge),je.push(u.src==="remote"?z:ge),Ae.push(u)}le+=L.text.slice(u.from,u.to)}u.ms=E,u.me=le.length,u.conflict&&(u.conflict.range||(u.conflict.range=[E,E]),u.conflict.range[1]=le.length)}let Ge=le.length,et=new Int32Array(ze+1).fill(-1),Qe=new Int32Array(h.text.length+1).fill(-1),Ut=new Int32Array(y.text.length+1).fill(-1);for(let u=0;u<Ge;u++)Ne[u]>=0&&(et[Ne[u]]=u),Le[u]>=0&&(Qe[Le[u]]=u),je[u]>=0&&(Ut[je[u]]=u);let Mt=(u,E)=>{let L=-1,D=-1;for(let z=u.from;z<u.to;z++){let oe=E[z];oe>=0&&(L<0&&(L=oe),D=oe+1)}return L<0?null:[L,D]},Kt=[],Lt=[];for(let u of new Set(pt.values()))u.new==="local"?Kt.push(u):u.new==="remote"&&Lt.push(u);let _t=(u,E)=>{u.remote=E.remote,u.remoteMark=E.remoteMark,u.new="both",E.merged=u,pt.set(E.remote,u)};if(Kt.length&&Lt.length){let u=e.idOf;for(let E of Kt){let L=u?u.local(E.local):null;if(!L)continue;let D=Lt.find(z=>!z.merged&&z.tag===E.tag&&!!z.block==!!E.block&&u.remote(z.remote)===L);D&&_t(E,D)}for(let E of Kt){if(E.remote)continue;let L=Mt(E.localMark,Qe);if(L)for(let D of Lt){if(D.merged||D.tag!==E.tag||!!D.block!=!!E.block)continue;let z=Mt(D.remoteMark,Ut);if(z&&Math.min(L[1],z[1])-Math.max(L[0],z[0])>0){_t(E,D);break}}}}At.clear();let C=u=>{for(let E of u)if(E.block)return vt(pt.get(E.el));return null},X=g.marks.some(u=>u.block)||h.marks.some(u=>u.block)||y.marks.some(u=>u.block),ce=new Array(Ge).fill(null),de=new Set;if(e.nativeTransfers)for(let u=0;u<Ge;u++){let E=Ae[u].owner;ce[u]=E?vt(pt.get(E)):Ne[u]>=0?C(g.stackAt[Ne[u]]):null}else if(X){let u=(he,Ie,Xe)=>{let nt=new Set([he,Ie,Xe]);nt.delete(null);let at=[];for(let Rt of nt){let ln=Rt===he,Qt=Rt===Ie,un=Rt===Xe;(Qt===un?Qt:Qt===ln?un:Qt)&&at.push(Rt)}if(at.length<=1)return at[0]||null;let jt=n==="local"?Ie:Xe;return at.includes(jt)?jt:at[0]},E=(he,Ie)=>Ie>=0?C(he.stackAt[Ie]):null,L=new Map;for(let he=0;he<Ge;he++){if(le[he]!==wt)continue;let Ie=Ne[he]>=0?E(g,Ne[he]):null,Xe=E(h,Le[he]),nt=E(y,je[he]);L.set(he,[Ie,Ne[he]>=0?u(Ie,Xe,nt):Xe||nt])}let D=new Set([...L.values()].map(he=>he[1])),z=he=>he!==wt&&he!==Ln&&!/\s/.test(he),oe=(he,Ie)=>{let Xe=he;for(;Xe<Ie&&!z(le[Xe]);)Xe++;return Xe<Ie&&Ne[Xe]>=0?E(g,Ne[Xe]):null},ge=new Map,ye=0;for(let he=0;he<Ge;he++){if(le[he]!==wt)continue;let[Ie,Xe]=L.get(he),nt=oe(ye,he),at=Xe,jt=ge.get(at)===at&&nt===at;at&&ge.has(at)&&!jt&&Ie&&!ge.has(Ie)&&!D.has(Ie)&&(at=Ie),at&&!ge.has(at)&&ge.set(at,nt);for(let Rt=ye;Rt<=he;Rt++)ce[Rt]=at;ye=he+1}let Re=he=>{for(let Ie=0;Ie<he.text.length;Ie++)if(z(he.text[Ie])&&!E(he,Ie))return!0;return!1};if(!Re(g)&&!Re(h)&&!Re(y)){let he=[],Ie=0;for(let nt=0;nt<Ge;nt++)(le[nt]===wt||nt===Ge-1)&&(he.push([Ie,nt]),Ie=nt+1);let Xe=new Set(ce);for(let nt=0;nt<he.length;nt++){let[at,jt]=he[nt];if(ce[jt])continue;let Rt=at;for(;Rt<=jt&&!z(le[Rt]);)Rt++;if(Rt>jt)continue;let ln=E(g,Ne[Rt]),Qt=E(h,Le[Rt]),un=E(y,je[Rt]),mn=u(ln,Qt,un)||Qt||un||ln;if(mn&&!Xe.has(mn)){Xe.add(mn);for(let qt=at;qt<=jt;qt++)ce[qt]=mn;continue}let In=nt>0&&ce[he[nt-1][1]],Cn=nt+1<he.length&&ce[he[nt+1][1]];if(In)de.add(he[nt-1][1]);else if(Cn&&le[jt]===wt)de.add(jt);else continue;for(let qt=at;qt<=jt;qt++)ce[qt]=In||Cn}}}let ie=new Map,ee=u=>{let E=ie.get(u);if(E)return E;E=[1/0,-1/0];for(let[L,D]of[[u.baseMark,et],[u.localMark,Qe],[u.remoteMark,Ut]]){let z=L&&Mt(L,D);z&&(E[0]=Math.min(E[0],z[0]),E[1]=Math.max(E[1],z[1]))}return ie.set(u,E),E},se=(u,E,L)=>{let D=-1,z=-1;for(let oe=0;oe<u.length;oe++){let ge=pt.get(u[oe].el);ge===E&&(D=oe),ge===L&&(z=oe)}return D>=0&&z>=0?D-z:0},Ee=(u,E)=>[...u].sort((L,D)=>{for(let ge of E){let ye=se(ge,L,D);if(ye)return ye}let z=ee(L),oe=ee(D);return z[0]-oe[0]||oe[1]-z[1]||L.rank-D.rank||L.id-D.id}),_e=new Map,Fe=new Map,tt=e.nativeTransfers?[]:null,st=u=>{if(tt)return tt;let E=Ne[u],L=Le[u],D=je[u],z=Ae[u];if(E>=0){let nt=g.stackAt[E],at=h.stackAt[L],jt=y.stackAt[D],Rt=_e.get(nt);Rt||_e.set(nt,Rt=new Map);let ln=Rt.get(at);ln||Rt.set(at,ln=new Map);let Qt=ln.get(jt);if(Qt)return Qt;let un=Ot(nt),mn=Ot(at),In=Ot(jt),Cn=new Set;for(let qt of new Set([...un,...mn,...In])){let ro=un.has(qt),so=mn.has(qt),Ht=In.has(qt);(so===Ht?so:so===ro?Ht:so)&&Cn.add(qt)}return Qt=Ee(Cn,[at,jt,nt]),ln.set(jt,Qt),Qt}if(z.src==="both"){let nt=h.stackAt[L],at=y.stackAt[D];return Ee(new Set([...Ot(nt),...Ot(at)]),[nt,at])}let ge=(z.src==="local"?h:y).stackAt[z.src==="local"?L:D];if(!z.inherit)return Ee(Ot(ge),[ge]);let ye=Fe.get(z);ye||Fe.set(z,ye=new Map);let Re=ye.get(ge);if(Re)return Re;let he=new Set(Ot(ge));for(let nt of z.inherit.added)he.add(vt(nt));for(let nt of z.inherit.removed)he.delete(vt(nt));let Ie=z.src==="local"?y:h,Xe=(z.src==="local"?Te.bTo:pe.bTo)[z.inherit.bs];return Re=Ee(he,[ge,Ie.stackAt[Xe]]),ye.set(ge,Re),Re},it=new Int32Array(h.text.length+1);it[h.text.length]=Ge;for(let u=h.text.length-1;u>=0;u--)it[u]=Qe[u]>=0?Qe[u]:it[u+1];pa.caret+=h.text.length;let rt=u=>u<=0?0:(u>h.text.length&&(u=h.text.length),Qe[u-1]>=0?Qe[u-1]+1:it[u]),kt=[],xt=[],Et=null,$e=[],mt="",Tt=-1,Dt=u=>{Et?Et.appendChild(u):kt.push(u)},It=u=>{if(!mt)return;let E=t.createTextNode(mt);Dt(E),xt.push({node:E,ms:Tt,me:u,local:[],u:$e.length?$e[$e.length-1].u:null}),mt=""},kn=new Set,Zt=new Map,Fn=new Set,fn=u=>{let E=t.createElement(u.tag);if(u.block&&Be.add(E),!Zt.has(u)){Zt.set(u,E),M(u.base,u.local,u.remote,E),i.set(E,{base:u.base,local:u.local,remote:u.remote});let D=(ge,ye)=>w&&u[ye]&&ge.reverse.get(u[ye])?ye:null,z=!u.base&&(D(o,"local")||D(r,"remote"));if(z){let ge=z==="local"?o.reverse.get(u.local):r.reverse.get(u.remote),ye=i.get(E);ye.local=ye.local||o.map.get(ge)||null,ye.remote=ye.remote||r.map.get(ge)||null,c.push({kind:"move",el:E,source:z}),e.moveBuilt?.(ge,z,u[z],E)}else u.base||c.push({kind:"insert",el:E,source:u.local&&u.remote?"both":u.local?"local":"remote"});let oe=i.get(E);oe.local&&(Fn.has(oe.local)?oe.local=null:Fn.add(oe.local))}else{let D=Zt.get(u);for(let z of D.attributes)z.name!=="id"&&z.name!=="data-id"&&O(E,z,z.value);i.set(E,{base:null,local:null,remote:null})}Dt(E),$e.push({u,el:E}),Et=E},to=new Set,An=new Map;for(let u of h.pins){let E=rt(u.i);An.has(E)||An.set(E,[]),An.get(E).push(u)}let bo=u=>{let E=An.get(u);if(E){It(u);for(let L of E){let D=L.el.namespaceURI&&L.el.namespaceURI!=="http://www.w3.org/1999/xhtml"?t.createElementNS(L.el.namespaceURI,L.el.tagName):t.createElement(L.el.tagName);i.set(D,{base:null,local:L.el,remote:null,pinned:!0}),to.add(D),Dt(D)}}},_o=g.atoms.length||h.atoms.length||y.atoms.length,Gt=u=>{if(!_o)return null;let E=Ne[u]>=0?g.atomAt.get(Ne[u]):null,L=Le[u]>=0?h.atomAt.get(Le[u]):null,D=je[u]>=0?y.atomAt.get(je[u]):null;return E||L||D?{ab:E,al:L,ar:D}:null},Hn=(u,E,L)=>{let D=e.idOf;if(!D||!D.base)return!1;let z=D.base(u.el);return z!=null&&z===D[L](E.el)},Wo=(u,E,L,D,z)=>{if(!u||!w)return null;let oe=N.get(E.reverse.get(u.el))||null;return!oe||oe===D||(D?oe.el.isEqualNode(D.el)&&!Hn(oe,u,z):L.bTo[oe.i]>=0)?null:oe},yo=(u,E)=>{if(!u||!w||!e.moveIn)return null;let L=E.reverse.get(u.el);return L&&!N.has(L)?L:null},no=(u,E)=>{let L=new Map;for(let D of u.atoms)L.set(E(D),(L.get(E(D))||0)+1);return L},On=no(g,H),br=no(h,k),yr=no(y,A),wr=u=>{let E=H(u);return On.get(E)===1&&(br.get(E)||0)<=1&&(yr.get(E)||0)<=1},Vn=new Map,qn=new Set,oo=new Set,$o=new Set,wo=null;for(let u=0;u<Ge;u++){let E=Gt(u);if(!E)continue;let{ab:L,al:D,ar:z}=E,oe=Wo(z,r,Te,L,"remote"),ge=Wo(D,o,pe,L,"local"),ye=L,Re=null;if(oe?(ye=oe,Re="remote"):ge&&(ye=ge,Re="local"),ye){L&&ye!==L&&(wo||=new Map).set(L,Re),qn.has(ye)?Vn.set(u,{dup:ye.el}):(qn.add(ye),Vn.set(u,{bk:ye,from:Re,al:D,ar:z}));continue}let he=yo(z,r),Ie=yo(D,o),Xe=he||Ie;if(Xe){oo.has(Xe)?Vn.set(u,{dup:Xe}):(oo.add(Xe),Vn.set(u,{moveIn:Xe,side:he?"remote":"local",sideEl:he?z.el:D.el}));continue}let nt=(jt,Rt)=>jt&&w&&N.get(Rt.reverse.get(jt.el))||null,at=nt(z,r)||nt(D,o);if(at&&($o.add(at),Ae[u].conflict&&(wr(at)||z&&(z.el===at.el||r.identityPaired?.has(at.el))&&Hn(at,z,"remote")||D&&(D.el===at.el||o.identityPaired?.has(at.el))&&Hn(at,D,"local")))){if(qn.has(at)){Vn.set(u,{dup:at.el});continue}qn.add(at)}Vn.set(u,{al:D,ar:z})}let Mn=new Map,Fo,qo,xr=(u,E)=>{if(u[E]>=0)return u[E];for(let L=E-1;L>=0;L--)if(u[L]>=0)return u[L]+1;return 0};if(w)for(let u of g.atoms){if(qn.has(u)||$o.has(u))continue;let E=o.map.get(u.el)||null,L=r.map.get(u.el)||null,D=E&&v.get(E),z=L&&G.get(L);if(E&&!D||L&&!z)continue;let oe=!(D&&z)&&ve.has(u);if(!oe&&!(D&&z&&(wr(u)||wo?.has(u)||(D.el===u.el||o.identityPaired?.has(u.el))&&(z.el===u.el||r.identityPaired?.has(u.el))&&Hn(u,D,"local")&&Hn(u,z,"remote"))))continue;let ge=wo?.get(u),ye=n;if(ge){let nt=ge==="local"?y:h,at=ge==="local"?r:o,jt=ge==="local"?qo:Fo;if(jt===void 0){jt=nt.atoms.length===g.atoms.length;for(let Rt=0;jt&&Rt<g.atoms.length;Rt++)jt=at.reverse.get(nt.atoms[Rt].el)===g.atoms[Rt].el;ge==="local"?qo=jt:Fo=jt}jt&&(ye=ge)}let Re=ye==="local"?[[D,Qe],[z,Ut]]:[[z,Ut],[D,Qe]],[he,Ie]=Re.find(([nt])=>nt),Xe=xr(Ie,he.i);Mn.has(Xe)||Mn.set(Xe,[]),Mn.get(Xe).push({a:u,lt:E,rt:L,edited:oe}),qn.add(u)}if(w&&e.moveIn){let u=[[h,o,Qe,"local"],[y,r,Ut,"remote"]];n!=="local"&&u.reverse();for(let[E,L,D,z]of u)for(let oe of E.atoms){let ge=yo(oe,L);if(!ge||oo.has(ge))continue;oo.add(ge);let ye=xr(D,oe.i);Mn.has(ye)||Mn.set(ye,[]),Mn.get(ye).push({move:ge,side:z,sideEl:oe.el})}}let ne=u=>{let E=Mn.get(u);if(E){if(It(u),E.some(L=>He(L.move?L.sideEl:L.a.el)))for(;$e.length;)$e.pop(),Et=$e.length?$e[$e.length-1].el:null;for(let{a:L,lt:D,rt:z,edited:oe,move:ge,side:ye,sideEl:Re}of E){if(ge){let Ie=e.moveIn(ge,ye,Re);Ie&&Dt(Ie);continue}kn.add(L);let he=j(L.el,D,z);oe&&(p({kind:"structure",el:he,detail:"edit-beats-delete",base:L.el},{subject:L.el,deleted:D?"remote":"local"}),c.push({kind:"insert",el:he,source:D?"local":"remote"})),Dt(he)}}},Be=new Set,Ue=l.length>a;for(let u=0;u<Ge;u++){let E=Gt(u),L=e.scopeUnits&&E&&(E.ab?.stack.some(ge=>ge.block)||E.al?.stack.some(ge=>ge.block)||E.ar?.stack.some(ge=>ge.block)),z=!!E&&He((E.ab||E.al||E.ar).el)&&!L?[]:ce[u]?[ce[u],...st(u)]:st(u),oe=0;for(;oe<$e.length&&oe<z.length&&$e[oe].u===z[oe];)oe++;if(oe<$e.length)for(It(u);$e.length>oe;)$e.pop(),Et=$e.length?$e[$e.length-1].el:null;if(bo(u),ne(u),z.length>$e.length)for(It(u);$e.length<z.length;)fn(z[$e.length]);if(le[u]===wt){if(de.has(u))continue;It(u);let ge=$e.length;for(;ge>0&&!$e[ge-1].u.block;)ge--;if(ge>0)for(Ue&&f.breakOut.set(u,$e[ge-1].el);$e.length>=ge;)$e.pop(),Et=$e.length?$e[$e.length-1].el:null;continue}if(E){It(u);let ge=Vn.get(u),ye;if(ge.dup){p({kind:"structure",el:null,detail:"both-moved",base:ge.dup},{subject:ge.dup});continue}if(ge.moveIn){if(ye=e.moveIn(ge.moveIn,ge.side,ge.sideEl),!ye)continue}else if(ge.bk){let Re=ge.bk;if(kn.add(Re),Re===E.ab)ye=j(Re.el,ge.al.el,ge.ar.el);else{let he=o.map.get(Re.el)||null,Ie=r.map.get(Re.el)||null;ye=j(Re.el,he,Ie),(!he||!Ie)&&p({kind:"structure",el:null,detail:"move-beats-delete",base:Re.el},{subject:Re.el,deleted:he?"remote":"local"}),c.push({kind:"move",el:ye,source:ge.from})}}else ge.al?(ye=U(ge.al.el,"local"),ge.ar&&(i.get(ye).remote=ge.ar.el),c.push({kind:"insert",el:ye,source:ge.ar?"both":"local"})):(ye=U(ge.ar.el,"remote"),c.push({kind:"insert",el:ye,source:"remote"}));Ue&&f.atomOut.set(u,ye),Dt(ye);continue}mt||(Tt=u),mt+=le[u]}if(It(Ge),(An.has(Ge)||Mn.has(Ge))&&($e.length=0,Et=null,bo(Ge),ne(Ge)),Ge===0&&(h.placeholder||y.placeholder||g.placeholder)){let u=t.createElement("br");i.set(u,{base:g.placeholder,local:h.placeholder,remote:y.placeholder}),kt.push(u)}let qe=0,ht=u=>{for(;qe>0&&xt[qe-1].me>=u;)qe--;for(;qe<xt.length&&xt[qe].me<u;)qe++;let E=xt[qe];if(!E)return xt[xt.length-1]||null;let L=xt[qe+1];return E.me===u&&L&&L.ms===u?L:E},We=new Map,Ve={},lt=(u,E,L)=>{let D=ht(u)||(L?Ve:null);if(!D)return;let z=We.get(D)||{l:!1,r:!1};E!=="remote"&&(z.l=!0),E!=="local"&&(z.r=!0),We.set(D,z)},Ke=u=>{if(u.conflict)return!0;let E=u.src==="local"?h.text:u.src==="remote"?y.text:"";for(let L=u.from;L<u.to;L++)if(E[L]!==Ln&&E[L]!==wt)return!0;return!1};for(let u of B)u.src!=="base"&&lt(u.ms,u.conflict?"both":u.src,Ke(u));for(let[u,E]of q)et[u]>=0&&lt(et[u],E);for(let u of xt.length?xt:[Ve]){let E=We.get(u);E&&c.push({kind:"text",node:u.node||null,source:E.l&&E.r?"both":E.l?"local":"remote"})}for(let u of Ye){if(Zt.has(u))continue;let E=!u.local&&!(w&&o.map.get(u.base)),L=!u.remote&&!(w&&r.map.get(u.base));!E&&!L||c.push({kind:"remove",source:E&&L?"both":E?"local":"remote",base:u.base})}if(xe)for(let[u,E]of xe)Zt.has(u)&&p({kind:"structure",el:Zt.get(u),detail:"edit-beats-delete",base:u.base},{subject:u.base,deleted:E});let ct=(u,E,L)=>{if(E<=u)return!1;for(let D=u;D<E;D++)if(L[D]>=0)return!1;return!0};for(let u of Ye)for(let E of["local","remote"]){let L=u[E+"Mark"],D=u.baseMark;if(!L)continue;let z=E==="local"?pe:Te;if(!ct(D.from,D.to,z.bTo)||!ct(L.from,L.to,z.toB))continue;let oe=(E==="local"?fe:Se).find(ge=>ge.ss<=L.from&&L.from<ge.se);oe&&(oe.be<=D.from||oe.bs>=D.to)&&c.push({kind:"move",el:Zt.get(u)||null,source:E})}let ft=u=>{let E=pt.get(u.node.parentNode);return E?vt(E):null};for(let u of h.nodes){let E=-1;for(let D=u.s;D<u.e;D++)if(Qe[D]>=0){E=Qe[D];break}let L;if(E>=0)L=ht(E);else{let D=rt(u.s),z=ft(u);L=xt.find(oe=>oe.u===z&&oe.me>=D)||xt.filter(oe=>oe.u===z).pop()}L&&L.local.push(u)}let yt=new Map,gt=xt[xt.length-1]||null,Ct=0;for(let u of h.nodes){let E=null;for(let L=u.s;L<=u.e;L++){let D=rt(L);for(;Ct>0&&xt[Ct-1].me>=D;)Ct--;for(;Ct<xt.length&&xt[Ct].me<D;)Ct++;let z=ge=>ge&&D>=ge.ms&&D<=ge.me&&(D<ge.me||L===u.e||ge===E),oe=z(xt[Ct])?xt[Ct]:z(xt[Ct+1])?xt[Ct+1]:xt[Ct]||gt;if(!oe)break;if(E===oe){let ge=yt.get(oe);ge[ge.length-1].to=L-u.s;continue}E=oe,yt.has(oe)||yt.set(oe,[]),yt.get(oe).push({node:u.node,from:L-u.s,to:L-u.s,flatStart:u.s})}}for(let u of xt){let E=u.local,L=!1;for(let ge of E)for(let ye=ge.s;ye<ge.e&&!L;ye++)(Qe[ye]<u.ms||Qe[ye]>=u.me)&&(L=!0);i.set(u.node,{base:null,local:E.map(ge=>ge.node),remote:null,caret:yt.get(u)||[],partial:L});let D=u.ms,z=u.me-u.ms,oe=ge=>{let ye=0,Re=-1;for(let he of E){let Ie=he.e-he.s;if(ge<=ye+Ie){Re=he.s+(ge-ye);break}ye+=Ie}return Re<0&&(Re=E.length?E[E.length-1].e:0),Math.max(0,Math.min(rt(Re)-D,z))};oe.flat=ge=>Math.max(0,Math.min(rt(ge)-D,z)),s.set(u.node,oe)}function En(){if(!h.text.includes(wt))return[{flatLocal:h.text,localNodes:h.nodes,textNodes:xt,lToM:Qe,mapLocal:rt}];let u=[],E=0,L=0;for(let D=0;D<=h.text.length;D++){if(D<h.text.length&&h.text[D]!==wt)continue;let z=E,oe=D;if(oe>z){let ge=[];for(;L<h.nodes.length&&h.nodes[L].e<=z;)L++;for(let ye=L;ye<h.nodes.length&&h.nodes[ye].s<oe;ye++){let Re=h.nodes[ye],he=Math.max(Re.s,z),Ie=Math.min(Re.e,oe);he<Ie&&ge.push({node:Re.node,s:he-z,e:Ie-z})}u.push({flatLocal:h.text.slice(z,oe),localNodes:ge,textNodes:xt,lToM:Qe.subarray?Qe.subarray(z,oe+1):Qe.slice(z,oe+1),mapLocal:ye=>rt(z+Math.max(0,Math.min(ye,oe-z)))})}E=D+1}return u}let Kn={...e,blocks:Be,ignored:u=>to.has(u)||(e.ignored?e.ignored(u):!1)},xo=e.ignoreAttribute||(()=>!1),Gr=Di(zt(kt,Kn),xo)!==Di(y,xo);if(d.length){let u=E=>{let L=i.get(E);return L&&L.unchanged?L.remote:null};f.text=le,f.textNodes=xt,f.out=zt(kt,{...Kn,via:u})}let ut=null;if(e.scopeUnits){ut=new Map;let u=new Set(kt),E=ye=>{for(;ye&&!u.has(ye);)ye=ye.parentNode;return ye},L=e.scopeUnits.map(ye=>{let Re=new Map;for(let he of ye)if(he.nodeType===1)Re.set(he,he);else for(let Ie of he.nodes)Re.set(Ie,he);return Re}),D=(ye,Re)=>{for(;ye&&!Re.has(ye);)ye=ye.parentNode;return ye?Re.get(ye):null},z=[g,h,y].map((ye,Re)=>{let he=new Array(ye.text.length);for(let Ie of ye.nodes){let Xe=D(Ie.node,L[Re]);Xe&&he.fill(Xe,Ie.s,Ie.e)}for(let Ie of ye.atoms)he[Ie.i]=D(Ie.el,L[Re]);return he}),oe=(ye,Re)=>{if(!ye||!Re)return;let he=ut.get(ye);he||ut.set(ye,he=new Set),he.add(Re)};for(let ye of kt){let Re=i.get(ye);Re&&(oe(D(Re.base,L[0]),ye),oe(D(Re.local,L[1]),ye),oe(D(Re.remote,L[2]),ye))}for(let ye of xt){let Re=E(ye.node);for(let he=ye.ms;he<ye.me;he++)oe(z[0][Ne[he]],Re),oe(z[1][Le[he]],Re),oe(z[2][je[he]],Re)}let ge=new Map(kt.map((ye,Re)=>[ye,Re]));for(let[ye,Re]of ut)ut.set(ye,Array.from(Re).sort((he,Ie)=>ge.get(he)-ge.get(Ie)))}return{unitOutputs:ut,nodes:kt,text:le,textNodes:xt,localDiverged:Gr,mapLocal:rt,conflicts:l.slice(a),granularity:F?"line":"word",segments:En(),localHunks:fe,remoteHunks:Se,lToM:Qe}}var Ss=Symbol("lost");function zi(){return{links:new Map,removed:new Set,consumed:new Set,link(e,t){this.links.set(e,t)},remove(e){if(e)if(e.nodeType===1)this.removed.add(e);else for(let t of e.nodes)this.removed.add(t)},consume(e){for(let t of e)this.consumed.add(t)}}}var Ki=e=>e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content?e.content:e;function Gi({locals:e,rec:t,root:n,provenance:o,segments:r,ignored:i}){let s=new Map,l=(x,S)=>{let O=s.get(x);O||s.set(x,O=new Set),O.add(S)},c=new Set,a=new Set;for(let x of r){let S=x.textNodes;for(let O of S)c.add(O.node);for(let O of x.localNodes){a.add(O.node);let R=0,M=null;for(let j=O.s;j<O.e;j++){let U=x.lToM[j];if(U<0)continue;for((!S[R]||U<S[R].ms)&&(R=0);R<S.length&&S[R].me<=U;)R++;let K=S[R]&&S[R].ms<=U?S[R].node:Ss;K!==M&&l(O.node,K),M=K}}}let p=new Set,f=new Map,d=new Set;(function x(S){p.add(S);let O=o.get(S);if(S.nodeType===1)O&&O.local&&O.local.nodeType===1&&(l(O.local,S),O.unchanged&&d.add(O.local)),S.tagName==="TEMPLATE"&&S.content&&f.set(S.content,S);else if(O&&Array.isArray(O.local)&&!c.has(S))for(let R of O.local)l(R,S);for(let R=Ki(S).firstChild;R;R=R.nextSibling)x(R)})(n);let w=new Set;for(let[x,S]of t.links)l(x,S),w.add(x);let b=x=>{let S=x.parentNode;return S&&S.nodeType===11?f.get(S)||null:S},T=(x,S)=>{for(let O=x;O;O=b(O))if(O===S)return!0;return!1},g=x=>t.removed.has(x)||t.consumed.has(x),h=x=>{for(let S=x.parentNode;S&&S.nodeType===1;S=S.parentNode){if(d.has(S))return"kept";if(g(S))return"decided";if(s.has(S))return null}return null},y=new Map;for(let x of e)y.set(x,N(x));return y;function N(x){let S=s.get(x);if(S&&(S.size!==1||S.has(Ss)))return{kind:"unknown",reason:"several-outputs"};let O=S?S.values().next().value:null;if(O&&(O.nodeType!==1||!p.has(O)))return{kind:"unknown",reason:"output-not-placed"};if(!O){let U=g(x)?"decided":h(x);if(U==="kept")return{kind:"untouched"};if(U!=="decided")return{kind:"unknown",reason:"unmapped"}}let R=[],M=j(x,!!O&&(d.has(x)||w.has(x)),!O||g(x));if(M)return{kind:"unknown",reason:M};return O?{kind:"single",output:O,owned:R,carried:w.has(x)}:{kind:"removed"};function j(U,K,W){for(let H=Ki(U).firstChild;H;H=H.nextSibling){if(H.nodeType===1?i(H):H.nodeType!==3&&H.nodeType!==8)continue;let k=s.get(H);if(k)for(let A of k){if(A===Ss||!p.has(A))return"output-not-placed";if(!O)return"survives-elsewhere";if(!T(A,O))return"escaped";R.push(A)}else if(!K&&!W&&!g(H)&&!a.has(H))return"unmapped";if(H.nodeType===1){let A=j(H,K||d.has(H)||w.has(H),W||g(H));if(A)return A}}return null}}}function Yi(e,t){if(!t)return!1;let n=t.nodeType===1&&t.tagName==="TEMPLATE"?[t,...t.querySelectorAll("template")]:[...t.querySelectorAll("template")];for(let o of n)if(o.content.contains(e)||Yi(e,o.content))return!0;return!1}function Xi(e,t){if(!e||typeof e!="object"||typeof e.onResult!="function"||!e.elements||!Number.isSafeInteger(e.elements.length)||e.elements.length<0)throw new TypeError("lineage must be { elements, onResult }");let n=[],o=new Set;for(let r of Array.from(e.elements)){if(!r||r.nodeType!==1||r.ownerDocument!==t&&!Yi(r,t.documentElement))throw new TypeError("lineage.elements must be elements of the live document");o.has(r)||(o.add(r),n.push(r))}return n}var Ji=new WeakMap;function Zi(e){let t=new Map;for(let n of e){let o=[],r=!1;(function i(s){s.nodeType===1&&s.namespaceURI==="http://www.w3.org/1999/xhtml"&&s.localName==="template"&&(r=!0);for(let l=s.firstChild;l;l=l.nextSibling)o.push(l),l.nodeType===1&&i(l)})(n),t.set(n,{nodes:o,opaque:r})}return t}function Ns(e,t,n){if(e.lineage===void 0)return n(e);if(!t||t.nodeType!==1)throw new TypeError("lineage requires an element root");let o=e.lineage,r=Xi(o,t.ownerDocument),i=!1,s={...e,lineage:{elements:r,onResult(l,c){if(!i)return i=!0,o.onResult(l,c)}}};try{return Ji.set(s.lineage,Zi(r)),n(s)}catch(l){if(!i){i=!0;try{o.onResult({version:1,root:t,status:"incomplete",entries:r.map(yn)},null)}catch{}}throw l}}function vs(e,{liveRoot:t,localRoot:n,toLive:o}){let r=Xi(e,t.ownerDocument),i=a=>a===t||t.contains(a),s=new Map,l=new Set(r.filter(i));if(l.size&&n===t)for(let a of l)s.set(a,a);else l.size&&function a(p){let f=o(p);l.delete(f)&&s.set(f,p);for(let d=p.firstElementChild;d&&l.size;d=d.nextElementSibling)a(d)}(n);return{spec:e,watched:r,root:t,locals:Array.from(new Set(s.values())),before:Ji.get(e)||Zi(r),delivered:!1,result:null,finish(a,p){return this.resolve=p,this.plans=a,this.result={version:1,root:this.root,status:"complete",entries:r.map(f=>xa(f,s.get(f),a,p,this))},this.result},recheck(){return this.finish(this.plans,this.resolve)},remapRoot(a,p){this.root=p;let f=this.resolve,d=b=>{let T=f(b);return T===a?p:T};return this.finish(this.plans,d)},deliver(a){this.delivered||(this.delivered=!0,e.onResult(this.result,a))}}}var yn=e=>({from:e,to:[],kind:"unknown",complete:!1});function xa(e,t,n,o,r){let i=r.root,s=d=>!!d&&(d===i||i.contains(d)),l=t&&n?n.get(t):null;if(!l||l.kind==="unknown")return yn(e);let c=r.before.get(e);if(!c||c.opaque)return yn(e);let a=c.nodes,p=d=>s(d)||!!(d&&d.ownerDocument===i.ownerDocument&&i.ownerDocument.documentElement?.contains(d));if(l.kind==="untouched"){if(!s(e))return yn(e);for(let d of a)if(p(d)&&!e.contains(d))return yn(e);return{from:e,to:[e],kind:"retained",complete:!0}}if(l.kind==="removed")return p(e)||a.some(p)?yn(e):{from:e,to:[],kind:"removed",complete:!0};let f=o(l.output);if(!f||f.nodeType!==1||!s(f)||f!==e&&p(e))return yn(e);for(let d of a)if(p(d)&&!f.contains(d))return yn(e);for(let d of l.owned){let w=o(d),b=Array.isArray(w)?w:[w];for(let T of b)if(!T||!s(T)||!f.contains(T))return yn(e)}return l.carried&&!Qi(f,l.output,o)?yn(e):{from:e,to:[f],kind:f===e?"retained":"replaced",complete:!0}}function Qi(e,t,n){for(let o=t.firstChild;o;o=o.nextSibling){let r=n(o),i=Array.isArray(r)?r:[r];for(let s of i)if(!s||!e.contains(s))return!1;if(o.nodeType===1&&!Qi(e,o,n))return!1}return!0}function Xo(e,t,n){let o=vs(e,{liveRoot:t,localRoot:t,toLive:r=>r});return o.result={version:1,root:t,status:"complete",entries:o.watched.map(r=>yn(r))},n.lineage=o.result,o}function el(e,t,n,o,r){if(!r(e.length*8+1))return null;let i=0,s=t===0,l=!1;for(let c of tn(e,o)){if(!r(1))return null;if(i+=c.len,i===t&&(s=!0),i===n&&(l=!0),i>=n)break}return s&&l}function ka(e,t,n,o,r,i,s){if(!s(t.length*2))return!1;let l=new Map,c=new Map,a=new Set;for(let p of t){let f=p.bs<p.be,d=f?n[p.ownerIndex].text.base:n[p.ownerIndex].text[e],w=f?p.bs:p.ss,b=f?p.be:p.se;if(!s((b-w)*4+1))return!1;for(;w<b&&/\s/.test(d[w]);)w++;for(;b>w&&/\s/.test(d[b-1]);)b--;if(w===b)continue;let T=d.slice(w,b),g=f?l:c;f&&p.text&&a.add(T),g.has(T)?g.set(T,null):g.set(T,{h:p,from:w,to:b})}for(let p of o){if(!s(1))return!1;if(p.side!==e)continue;let f=p.deletion,d=n[f.ownerIndex].text.base;if(!s((f.be-f.bs)*3)||a.has(d.slice(f.bs,f.be).trim()))return!1}for(let[p,f]of l){if(!s(p.length+1))return!1;let d=c.get(p);if(!f||!d)continue;let w=f.h,b=d.h;if(!w.text||w.transferOut||b.transferIn||w.owner===b.owner)continue;let T=n[w.ownerIndex],g=n[b.ownerIndex];if(!s(T.text.base.length))return!1;if(!/\S/.test(T.text.base.slice(0,w.bs)+T.text.base.slice(w.be)))continue;let h=el(T.text.base,f.from,f.to,i,s),y=el(g.text[e],d.from,d.to,i,s);if(h===null||y===null)return!1;if(!h||!y)continue;let N=`${T.index}:${f.from}:${f.to}`,x={key:N,side:e,source:w.owner,destination:b.owner,deletion:w,insertion:b,sourceOffset:f.from-w.bs,targetOffset:d.from-b.ss,length:f.to-f.from};w.transferOut=x,b.transferIn=x,r[e].set(N,x),o.push(x)}return!0}function tl({base:e,local:t,remote:n,localTwin:o,remoteTwin:r,eligible:i,nodes:s,budget:l=Wt(2e4*32)}){let c=M=>M>l.remaining?!1:(l.remaining-=M,l.nativeSteps=(l.nativeSteps||0)+M,!0);if(e.length<2||t.length!==e.length||n.length!==e.length||!c(e.length*12))return null;for(let[M,j]of[["base",e],["local",t],["remote",n]]){let U=s[M];if(U.length!==j.length||U.some((K,W)=>K!==j[W]))return null}let a=[],p=0;for(let M=0;M<e.length;M++){let j=e[M],U=t[M],K=n[M];if(o(j)!==U||r(j)!==K)return null;let W={};for(let[H,k]of[["base",j],["local",U],["remote",K]]){if(!i(k)||k.tagName!==j.tagName||k.namespaceURI!==j.namespaceURI||!c(k.childNodes.length+1))return null;let A="";for(let J of k.childNodes){if(J.nodeType!==3||!c(J.data.length*4+1))return null;A+=J.data}if(A.includes(wt)||(p+=A.length+1,p>2e4))return null;W[H]=A}a.push({base:j,local:U,remote:K,index:M,text:W})}let f=a.every(M=>hn(M.text.base,M.text.local,M.text.remote)),d={local:[],remote:[]};for(let M of a){M.hunks={local:[],remote:[]};for(let j of["local","remote"]){let U=M.text.base,K=M.text[j];if(U===K)continue;let W=U.length+K.length+4,H=W*8;if(!c(H))return null;let k=Math.floor(l.remaining/8),A=Math.min(4e3,Math.max(0,Math.floor((Math.sqrt(W*W+k)-W)/2)));if(A<1||!c(4*(A+1)*(W+A+1)))return null;let J=0;for(let _ of lo(U,K,A)){if(!c(_.text.length+1))return null;let F=_.bs+J,Oe={..._,ss:F,se:F+_.text.length,toks:tn(_.text,f),owner:M.base,ownerIndex:M.index};M.hunks[j].push(Oe),d[j].push(Oe),J+=_.text.length-(_.be-_.bs)}}}let w=[],b={local:new Map,remote:new Map};for(let M of["local","remote"]){let j=new Map,U=new Map,K=!1,W=(H,k,A)=>{H.has(k)?H.set(k,null):H.set(k,A)};for(let H of d[M]){if(!c(1))return null;let k=a[H.ownerIndex].text.base;if(H.bs<H.be&&H.text===""){let A=k.slice(H.bs,H.be);if(!c(A.length*2))return null;/\S/.test(A)&&W(j,A,H)}else if(H.bs===H.be&&/\S/.test(H.text)){if(!c(H.text.length*2))return null;W(U,H.text,H)}else H.bs<H.be&&(K=!0)}for(let[H,k]of j){if(!c(H.length+1))return null;let A=U.get(H);if(!k||!A||k.owner===A.owner)continue;let J=a[k.ownerIndex];if(!c(J.text.base.length))return null;if(!/\S/.test(J.text.base.slice(0,k.bs)+J.text.base.slice(k.be)))continue;let _=`${J.index}:${k.bs}:${k.be}`,F={key:_,side:M,source:k.owner,destination:A.owner,deletion:k,insertion:A};k.transferOut=F,A.transferIn=F,b[M].set(_,F),w.push(F)}if(K&&U.size&&!ka(M,d[M],a,w,b,f,c))return null}if(!w.length)return null;let T=(M,j)=>M.bs<j.be&&j.bs<M.be,g=M=>M.bs===M.be,h=(M,j)=>M.bs<=j.be&&j.bs<=M.be&&g(M)!==g(j),y=(M,j)=>M.bs===j.bs&&M.be===j.be&&M.text===j.text,N=(M,j)=>!!(M.transferIn||M.transferOut&&(!M.text||j.bs===M.be&&/\s/.test(j.text[0])||j.bs===M.bs&&/\s/.test(j.text[j.text.length-1])));for(let M of w){let j=M.side==="local"?"remote":"local",U=a[M.deletion.ownerIndex];for(let K of U.hunks[j])if(!c(1)||T(M.deletion,K)&&K.transferOut?.key!==M.key)return null}for(let M of a)for(let j of M.hunks.local)for(let U of M.hunks.remote){if(!c(1))return null;if(y(j,U)){if(j.transferIn?.key!==U.transferIn?.key)return null;continue}if(T(j,U)||h(j,U)&&!N(j,U)&&!N(U,j))return null}if(!c(p*8))return null;let x=new Set([...e,...t,...n]),S={base:zt(e,{blocks:x}),local:zt(t,{blocks:x}),remote:zt(n,{blocks:x})},O={};for(let M of["base","local","remote"]){let j=S[M];if(j.atoms.length||j.pins.length)return null;O[M]=new Map(j.marks.filter(U=>U.block).map(U=>[U.el,U.from]))}for(let M of a){let j=O.base.get(M.base);if(j===void 0)return null;for(let U of["local","remote"]){let K=O[U].get(M[U]);if(K===void 0)return null;for(let W of M.hunks[U])W.bs+=j,W.be+=j,W.ss+=K,W.se+=K}}for(let M of w)M.bs=M.deletion.bs+(M.sourceOffset||0),M.be=M.length===void 0?M.deletion.be:M.bs+M.length,M.ss=M.insertion.ss+(M.targetOffset||0),M.se=M.length===void 0?M.insertion.se:M.ss+M.length;let R={};for(let M of["local","remote"]){let j=0,U=0,K=[];for(let H of d[M]){if(!c(1))return null;H.bs>j&&K.push({from:j,to:H.bs,target:U}),j=H.be,U=H.se}j<S.base.text.length&&K.push({from:j,to:S.base.text.length,target:U});let W=w.filter(H=>H.side===M).map(H=>({from:H.bs,to:H.be,target:H.ss,destination:H.destination}));if(R[M]=Rn({base:S.base,side:S[M],retained:K,transfers:W,budget:l}),R[M].status!=="ready")return null}return c(S.base.text.length)?{owners:a,blocks:x,transfers:w,byOrigin:b,budget:l,prepared:{base:S.base,local:S.local,remote:S.remote,lines:!1,baseTokens:tn(S.base.text,f),localEdits:{hunks:d.local,respell:new Map},remoteEdits:{hunks:d.remote,respell:new Map},localMap:R.local,remoteMap:R.remote,full:null}}:null}var Os=/\S/;function nl({certificates:e,scopes:t,views:n,eligible:o,baseId:r,limit:i=2e4*32}){let s=Wt(i),l=Symbol(),c=[],a=f=>{if(f>s.remaining)throw l;s.remaining-=f},p=(f,d=null)=>{if(a(1),!f||f.nodeType!==1||f.parentNode?.nodeType!==1||!o(f))return null;for(let T=f.parentNode;T;T=T.parentNode)if(a(1),T.nodeType===11)return null;let w="",b=0;for(let T of f.childNodes){if(a(1),T.nodeType!==3)return null;if(a(T.data.length*4+1),d){let g=d.flat.nodes[b++];if(!g||g.node!==T||g.s!==w.length||g.e!==w.length+T.data.length)return null}w+=T.data}return a(w.length*3+1),d&&(d.flat.atoms.length||d.flat.pins?.length||b!==d.flat.nodes.length||d.flat.text!==w)?null:Os.test(w)?w:null};try{a(t[0].length+t[1].length+t[2].length+e.length);let f=t.map(w=>new Set(w)),d=new Map;for(let w of e){a(1);let b=d.get(w.source);b||d.set(w.source,b=[]),b.push(w)}for(let w of d.values()){let b=[null,null],T=[];for(let g of w){a(1);let{source:h,target:y,side:N,models:x,runs:S}=g;if(N!==0&&N!==1||!f[0].has(h)||!f[N+1].has(y))continue;let{V:O,A:R,idOf:M}=n[N],j=n[1-N],U=O.twin(h),K=j.V.twin(h),W=O.baseOf(y);if(!U||!K||!W||W===h||!f[0].has(W)||!f[N+1].has(U)||!f[2-N].has(K)||R.map.get(h)!==U||R.reverse.get(U)!==h||j.A.map.get(h)!==K||j.A.reverse.get(K)!==h||R.map.get(W)!==y||R.reverse.get(y)!==W||y.parentNode!==U.parentNode||W.parentNode!==h.parentNode||h.tagName!==U.tagName||h.tagName!==K.tagName||r(h)!==M(U)||r(h)!==j.idOf(K)||r(W)!==M(y))continue;let H=x.get(h),k=x.get(y);if(!H||!k)continue;let A=p(h,H),J=p(y,k),_=p(U),F=p(K);if(a((A?.length||0)+(F?.length||0)),A===null||J===null||_===null||F===null||F===A)continue;let Oe=S.length>0,Ce=!1;for(let pe of S){if(a(1),pe.source!==h||pe.target!==y||!Number.isInteger(pe.from)||!Number.isInteger(pe.to)||!Number.isInteger(pe.targetFrom)||pe.from<0||pe.to<=pe.from||pe.to>A.length||pe.targetFrom<0||pe.targetFrom+pe.to-pe.from>J.length){Oe=!1;break}a((pe.to-pe.from)*3);for(let Te=pe.from;Te<pe.to;Te++){if(A[Te]!==J[pe.targetFrom+Te-pe.from]){Oe=!1;break}Os.test(A[Te])&&(Ce=!0)}if(!Oe)break}if(!Oe||!Ce)continue;let De=b[N];De||(a(A.length),De=b[N]={source:h,side:N,flat:H.flat,before:A,covered:new Uint8Array(A.length)});for(let pe of S)a(pe.to-pe.from),De.covered.fill(1,pe.from,pe.to)}for(let g of b){if(!g)continue;let{source:h,side:y,flat:N,before:x,covered:S}=g;a(x.length*3+1);let O=-1,R=-1;for(let M=0;M<=x.length;M++)M<x.length&&S[M]?(O<0&&(O=M),R=M+1):(M===x.length||Os.test(x[M]))&&O>=0&&(T.push({source:h,side:y,flat:N,from:O,to:R}),O=R=-1)}a(T.length),c.push(...T)}}catch(f){if(f!==l)throw f}return{records:c,budget:s}}var Aa="http://www.w3.org/1999/xhtml";function Ta(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 sn(e){return!!e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.namespaceURI===Aa}function Sa(e){let t=(e.getAttribute("type")||"").split(";")[0].trim().toLowerCase();return t==="application/json"||t.endsWith("+json")}function Pr(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+"|"+Ta(e.textContent.trim())}var Na={match:e=>e.hasAttribute("merge"),identity:e=>e.getAttribute("merge")};function Eo(e,t=[],n=!1){if(!sn(e)||e.hasAttribute("src"))return null;let o=[Na,...t];for(let r=0;r<o.length;r++){let i=o[r];if(!i.match(e))continue;if(!Sa(e))return n&&console.warn("[hyper-morph] merge ignored: script type is not JSON",e),null;let s=i.identity(e);return s==null||s===""?null:{key:r+":"+s,raw:s,recognizer:i}}return null}function ol(e,t,n){let o=new Set,r=i=>{sn(i)&&!t(i)&&o.add(Pr(i,n))};r(e);for(let i of e.querySelectorAll("script"))r(i);return o}function Jo(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 rl(e,t,n){let o=[],r=[],i=new Map,s=n.trackRecovery?new Set:null,l=Array.from(e.querySelectorAll("script"));sn(e)&&l.unshift(e);for(let c of l){if(!sn(c)||n.ignored(c)||n.skip.has(c)||t.has(Pr(c,n.baseURI)))continue;let a=c.ownerDocument.createElement("script");for(let p of c.attributes)a.setAttribute(p.name,p.value);if(a.textContent=c.textContent,n.beforeNodeAdded(a)===!1){s?.add(c);continue}a.hasAttribute("src")&&r.push(new Promise(p=>{a.addEventListener("load",()=>p()),a.addEventListener("error",()=>p())})),c.replaceWith(a),i.set(c,a),n.afterNodeAdded(a),o.push(a)}return{executed:o,loads:r,swapped:i,vetoed:s}}function va(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 Oa(e,t){try{let n=new URL(e,t);return n.origin+n.pathname+n.search}catch{return e}}function sl(e,t){let n=e.tagName;if(n==="TITLE"||n==="BASE")return n;if(n==="SCRIPT")return Pr(e,t);if(n==="LINK"){let o=e.getAttribute("href");return o?"link|"+(e.getAttribute("rel")||"")+"|"+Oa(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|"+va(e.textContent):e.outerHTML}function Ms(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 Ma(e){return e.replace(/\\'/g,"'").replace(/(\\*)"/g,(t,n)=>n.length%2===0?n+'\\"':t)}var Ea=/^-?(0|[1-9]\d*)(\.\d+)?([eE][+-]?\d+)?$/,Ia=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Es(e){try{return JSON.parse(e)}catch{return JSON.parse(Ca(e))}}function Ca(e){let t="",n=0,o=(r,i)=>{throw new Error(`Invalid relaxed JSON: ${r} at position ${i}`)};for(;n<e.length&&(n=Ms(e,n),!(n>=e.length));){let r=e[n];if("{}[]:".includes(r)){t+=r,n++;continue}if(r===","){let l=Ms(e,n+1);if(e[l]==="}"||e[l]==="]"){n++;continue}t+=r,n++;continue}if(r==='"'||r==="'"){let l=n+1;for(;l<e.length&&e[l]!==r;)e[l]==="\\"&&l++,l++;l>=e.length&&o("unterminated string",n);let c=e.slice(n+1,l);r==="'"&&(c=Ma(c)),t+='"'+c+'"',n=l+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 s=e.slice(n,i);if(s==="true"||s==="false"||s==="null"||Ea.test(s)){t+=s,n=i;continue}if(Ia.test(s)){if(e[Ms(e,i)]===":"){t+='"'+s+'"',n=i;continue}o("unquoted value "+JSON.stringify(s),n)}o("invalid token "+JSON.stringify(s),n)}return t}var Vt=Symbol("hyper-morph-json-merge:missing"),Ra=["id","_id","uuid","key","slug","code","name"];function Io(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Zo(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function La(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0})}var Pa=/^[A-Za-z_$][\w$]*$/;function ja(e,t){return Pa.test(t)?e===""?t:e+"."+t:e+"["+JSON.stringify(t)+"]"}function Da(e,t){return e===""?t:e+"."+t}function jr(e,t,n,o,r,i){if(e.onConflict){let s=l=>l===Vt?void 0:l;e.onConflict({path:t,base:s(n),local:s(o),remote:s(r),resolved:s(i)})}return i}function Wn(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(!Wn(e[n],t[n]))return!1;return!0}if(Io(e)&&Io(t)){let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let o of n)if(!Zo(t,o)||!Wn(e[o],t[o]))return!1;return!0}return!1}function Is(e,t,n,o,r,i){return Wn(t,n)?t:Wn(t,e)?n:Wn(n,e)?t:Io(t)&&Io(n)?Ba(Io(e)?e:{},t,n,o,r,i):Array.isArray(t)&&Array.isArray(n)?_a(e,t,n,o,r,i):jr(o,r,e,t,n,n)}function il(e,t,n,o,r,i){return t===Vt&&n===Vt?Vt:t===Vt?e===Vt?n:Wn(n,e)?Vt:jr(o,r,e,t,n,n):n===Vt?e===Vt?t:Wn(t,e)?Vt:jr(o,r,e,t,n,Vt):Is(e,t,n,o,r,i)}function Ba(e,t,n,o,r,i){let s={},l=new Set([...Object.keys(e),...Object.keys(t),...Object.keys(n)]);for(let c of l){let a=il(Zo(e,c)?e[c]:Vt,Zo(t,c)?t[c]:Vt,Zo(n,c)?n[c]:Vt,o,ja(r,c),Da(i,c));a!==Vt&&La(s,c,a)}return s}function Ua(e){return e===null||typeof e!="object"}function Dr(e){return typeof e+":"+String(e)}function Ha(e,t){for(let n of t){let o=new Set;for(let r of n){if(!Zo(r,e))return!1;let i=r[e];if(typeof i!="string"&&typeof i!="number")return!1;let s=Dr(i);if(o.has(s))return!1;o.add(s)}}return!0}function Va(e,t,n,o,r){let i=[e,t,n],s=!0;for(let l of i)for(let c of l)Io(c)||(s=!1);if(s){let l=o.keyPaths.get(r),c=l!==void 0?[l]:o.keyCandidates;for(let a of c)if(Ha(a,i))return{kind:"keyed",field:a};return null}for(let l of i){let c=new Set;for(let a of l){if(!Ua(a))return null;let p=Dr(a);if(c.has(p))return null;c.add(p)}}return{kind:"self"}}function _a(e,t,n,o,r,i){let s=Array.isArray(e)?e:[],l=Va(s,t,n,o,i),c=Array.isArray(e)&&e.length===t.length&&e.length===n.length;if(!l||l.kind==="self"&&c)return c?t.map((N,x)=>Is(e[x],N,n[x],o,r+"["+x+"]",i)):jr(o,r,e,t,n,n);let a=l.kind==="self"?Dr:N=>Dr(N[l.field]),p=N=>l.kind==="self"?r+"["+JSON.stringify(N)+"]":r+"["+l.field+"="+JSON.stringify(N[l.field])+"]",f=new Map,d=N=>{let x=new Map;for(let S of N){let O=a(S);x.set(O,S),f.has(O)||f.set(O,p(S))}return x},w=d(s),b=d(t),T=d(n),g=new Map,h=new Set([...w.keys(),...b.keys(),...T.keys()]);for(let N of h){let x=il(w.has(N)?w.get(N):Vt,b.has(N)?b.get(N):Vt,T.has(N)?T.get(N):Vt,o,f.get(N),i);x!==Vt&&g.set(N,x)}let y=[];for(let N of n){let x=a(N);g.has(x)&&y.push(x)}for(let N=0;N<t.length;N++){let x=a(t[N]);if(!g.has(x)||y.includes(x))continue;let S=0;for(let O=N-1;O>=0;O--){let R=y.indexOf(a(t[O]));if(R!==-1){S=R+1;break}}y.splice(S,0,x)}return y.map(N=>g.get(N))}function Wa(e){let t=new Map,n=[];for(let o of e.keyCandidates||[]){let r=o.lastIndexOf(":");r>=0?t.set(o.slice(0,r),o.slice(r+1)):n.push(o)}return{keyCandidates:[...n,...Ra],keyPaths:t,onConflict:e.onConflict||null}}function ll(e,t,n,o={}){return Is(e===void 0?Vt:e,t,n,Wa(o),"","")}function $a(e,t){let n=/^\s*/.exec(t)[0],o=/\s*$/.exec(t.slice(n.length))[0],r=t.slice(n.length,t.length-o.length),i=n.slice(n.lastIndexOf(`
6
+ `)+1),s=/\n([ \t]+)\S/.exec(r),l;if(!s)l=JSON.stringify(e);else{let c=s[1],a=c.length>i.length&&c.startsWith(i)?c.slice(i.length):" ";l=JSON.stringify(e,null,a).replace(/\n/g,`
7
+ `+i)}return n+l.replace(/</g,"\\u003c")+o}function Cs(e,t,n,o={}){let r=o.parse||Es,i=[],s=[],l=(d,w)=>{if(typeof d!="string")return Vt;try{return r(d)}catch(b){return i.push(`${w} side is not valid JSON (${b.message})`),Vt}},c=l(t,"local"),a=l(n,"remote");if(c===Vt)return{text:n,warnings:i,conflicts:s};if(a===Vt)return{text:t,warnings:i,conflicts:s};let p=l(e,"base"),f=ll(p===Vt?void 0:p,c,a,{...o,onConflict:d=>{s.push(d),o.onConflict?.(d)}});return Wn(f,a)?{text:n,warnings:i,conflicts:s}:Wn(f,c)?{text:t,warnings:i,conflicts:s}:{text:$a(f,n),warnings:i,conflicts:s}}var cl=e=>e.nodeType===3||e.nodeType===8?e.nodeValue.length:e.childNodes.length;function ao(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>cl(t)||r>cl(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 Xn(e,t,n={}){if(!ao(e))return null;let{startContainer:o,startOffset:r,endContainer:i,endOffset:s}=e;if(o===i&&(o.nodeType===3||o.nodeType===8))return o.nodeValue.slice(r,s);if(o===i&&r===s)return"";let l=new Set;for(let g=o;g;g=g.parentNode)l.add(g);let c=i;for(;!l.has(c);)c=c.parentNode;let a=(g,h)=>{let y=c.ownerDocument.createRange(),N=c.ownerDocument.createRange();return y.setStart(g[0],g[1]),y.collapse(!0),N.setStart(h[0],h[1]),N.collapse(!0),y.compareBoundaryPoints(0,N)},p=(g,h=!1)=>[g.parentNode,Array.prototype.indexOf.call(g.parentNode.childNodes,g)+Number(h)],f=[],d;if(t==="plain"){d="";let g=h=>{if(h.nodeType===3||h.nodeType===8){let y=d.length;d+=h.nodeValue,f.push({s:y,e:d.length,a:[h,0],b:[h,h.nodeValue.length],node:h})}else for(let y of h.childNodes)g(y)};g(c)}else{let g=n.blocks;if(!g){g=new Set;let y=N=>{N!==c&&N.nodeType===1&&As.has(N.tagName)&&g.add(N);for(let x of N.childNodes)y(x)};y(c)}let h=zt(Array.from(c.childNodes),{blocks:g,atomize:y=>!!n.atoms?.has(y),ignored:n.ignored});d=h.text;for(let y of h.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 h.atoms)f.push({s:y.i,e:y.i+1,a:p(y.el),b:p(y.el,!0)});for(let y=0;y<h.text.length;y++){if(h.text[y]!==wt)continue;let N=h.marks.find(S=>S.block&&S.to===y+1),x=h.marks.find(S=>S.block&&S.from===y+1);if(N)f.push({s:y,e:y+1,a:[N.el,N.el.childNodes.length],b:p(N.el,!0)});else if(x)f.push({s:y,e:y+1,a:p(x.el),b:[x.el,0]});else return null}}f.sort((g,h)=>g.s-h.s);let w=g=>{if(g[0].nodeType===3||g[0].nodeType===8){let y=f.find(N=>N.node===g[0]);return y?y.s+g[1]:null}let h=0;for(let y of f){if(a(g,y.a)<=0)return y.s;if(a(g,y.b)<0)return null;h=y.e}return h},b=w([o,r]),T=w([i,s]);return b!==null&&T!==null&&b<=T?d.slice(b,T):null}function co(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 al(e,t){if(!e||!t)return null;let n=co(e,t.start),o=co(e,t.end);return n&&o?{startContainer:n[0],startOffset:n[1],endContainer:o[0],endOffset:o[1]}:null}var fl=e=>e.nodeType===1?e.outerHTML:e.nodeValue;function ul(e,t,n){if(!t)return;let o=new Map,r=new Map,i=l=>{if(!l)return null;if(r.has(l))return r.get(l);let a=l.local.map(p=>co(t.localRoot,{path:p,offset:0})?.[0]).map(p=>p&&n(p)).filter(Boolean).map(p=>({node:p,parent:p.parentNode,previous:p.previousSibling,next:p.nextSibling,fragment:fl(p)}));return r.set(l,a),a},s=l=>{let c=al(t.localRoot,l);if(!c)return null;let a=n(c.startContainer),p=n(c.endContainer);if(!a||!p)return null;let f={...c,startContainer:a,endContainer:p};return ao(f)?f:null};for(let l of e){let c=l.recovery;if(!c||o.has(c))continue;let a={subject:i(c.subject),span:null,scope:null,touched:new Set};if(c.text){a.span=s(c.text.local.span),a.scope=s(c.text.local.scope);let p=a.span;if(p){let f=p.startContainer.ownerDocument.createRange();f.setStart(p.startContainer,p.startOffset),f.setEnd(p.endContainer,p.endOffset);let d=w=>{if(f.intersectsNode(w)){a.touched.add(w);for(let b of w.childNodes)d(b)}};d(f.commonAncestorContainer)}}if(c.structure){for(let p of[c.structure.localPlacement])p&&(i(p.parent),p.before.forEach(i),p.after.forEach(i));for(let p of c.structure.localOrder||[])i(p)}o.set(c,a)}t.localState={states:o,refs:r}}function dl(e,t,n,o){let r=n.localState?.states.get(e);if(!r)return!1;let i=l=>{let c=l.node;if(!o(c)||c.parentNode!==l.parent)return!1;let a=p=>Array.prototype.indexOf.call(c.parentNode.childNodes,p);return!(l.previous&&o(l.previous)&&l.previous.parentNode===c.parentNode&&a(l.previous)>=a(c)||l.next&&o(l.next)&&l.next.parentNode===c.parentNode&&a(l.next)<=a(c))};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 l=e.text.local,c=a=>a&&o(a.startContainer)&&o(a.endContainer);return c(r.span)&&c(r.scope)&&Xn(r.scope,e.text.encoding)===l.text&&Xn(r.span,e.text.encoding)===l.text.slice(l.start,l.end)}if(e.attribute){let l=e.attribute,c=r.subject[0].node;return(l.namespaceURI?c.getAttributeNS(l.namespaceURI,l.localName):c.getAttribute(l.qualifiedName))===t.local}let s=e.structure;if(s.localOrder){let l=-1,c=null;for(let a of s.localOrder){let p=n.localState.refs.get(a)?.[0]?.node;if(!p||!o(p)||c&&p.parentNode!==c)return!1;let f=Array.prototype.indexOf.call(p.parentNode.childNodes,p);if(f<=l)return!1;c=p.parentNode,l=f}return!0}return s.localAction==="moved"||r.subject.every(l=>fl(l.node)===l.fragment)}var Fa=1,rn=e=>!!e&&e.nodeType===1,Br=e=>rn(e)&&e.tagName==="TEMPLATE"&&!!e.content;function fo(e,t=null,n=null){let o=new Map,r=new Map,i=p=>{if(!t){t=new WeakMap;let f=[e];for(;f.length;){let d=f.pop();Br(d)&&(t.set(d.content,d),f.push(d.content));for(let w=d.firstChild;w;w=w.nextSibling)w.nodeType===1&&f.push(w)}}return t.get(p)||null},s=(p,f)=>{let d=r.get(p);if(!d){d=new Map;let w=0;for(let b=p.firstChild;b;b=b.nextSibling)d.set(b,w++);r.set(p,d)}return d.get(f)},l=p=>{if(!p)return null;if(n&&n.has(p))return l(n.get(p));if(p===e)return[];let f=o.get(p);if(f!==void 0)return f;let d=p.parentNode,w=null;if(d&&d.nodeType===11){let b=i(d),T=b?l(b):null;T&&(w=T.concat(["content",s(d,p)]))}else if(d){let b=l(d);b&&(w=b.concat([s(d,p)]))}return o.set(p,w),w};return{root:e,pathOf:l,logicalParent:p=>{let f=p.parentNode;return f&&f.nodeType===11?i(f):f},indexIn:s,containerPath:p=>{if(p.nodeType===11){let d=i(p),w=l(d);return w?w.concat(["content"]):null}let f=l(p);return f&&Br(p)?f.concat(["content"]):f},ownerOf:i}}var Sn=e=>Br(e)?e.content:e;function hl(e){let{L:t,R:n,unitsOf:o,provenance:r,policy:i}=e,s=[];return{note:(p,f)=>{s.push([p,f])},finish:p=>s.length?a(p):null};function a(p){let f={base:fo(e.roots.base),local:fo(e.roots.local),remote:fo(e.roots.remote)},d=Y=>Y==="local"?t:n,w=(Y,m)=>{if(!m)return null;if(Y.map.has(m))return Y.map.get(m);let I=[],P=rn(m)?f.base.logicalParent(m):m.parent;for(;P&&!Y.map.has(P);P=f.base.logicalParent(P))I.push(P);if(!P||!Y.identical.has(P))return null;let $=Y.map.get(P);for(let Q=I.length-1;Q>=0&&$;Q--)$=Sn($).childNodes[f.base.indexIn(I[Q].parentNode,I[Q])];return $?rn(m)?Sn($).childNodes[f.base.indexIn(m.parentNode,m)]||null:o($)[o(m.parent).indexOf(m)]||null:null},b=new Map,T=new Map,g=new WeakMap,h=0,y=(Y,m)=>{let I=b.get(Y);I||b.set(Y,I=[]),I.push(m)};(function Y(m){T.set(m,h++);let I=r.get(m);if(I&&!I.pinned){for(let P of[I.base,I.local,I.remote])if(P)if(Array.isArray(P))for(let $ of P)y($,m);else y(P,m)}if(Br(m)){g.set(m.content,m);for(let P=m.content.firstChild;P;P=P.nextSibling)Y(P)}for(let P=m.firstChild;P;P=P.nextSibling)Y(P)})(p);let N=new Map;f.out=fo(p,g,N);let x={refs:new Map,spans:new Map,anchors:new Map,via:N,outOwners:g,outRoot:p,localRoot:e.roots.local},S=Y=>rn(Y)?[Y]:Y.nodes,O=(Y,m)=>{let I=f[m].logicalParent(Y);if(!I)return null;for(let P of o(I))if(!rn(P)&&P.nodes.includes(Y))return P;return null},R=(Y,m)=>Y==null?null:Array.isArray(Y)?Y.length?O(Y[0],m):null:Y,M=Y=>{let m=new Set,I=[];for(let P of Y)for(let $ of b.get(P)||[])m.has($)||(m.add($),I.push($));return I.sort((P,$)=>T.get(P)-T.get($))},j=new Map,U=Y=>{let m=Y.b||Y.l||Y.r,I=j.get(m);if(I)return I;let P=[];for(let $ of[Y.b,Y.l,Y.r])$&&P.push(...S($));return I=M(P),j.set(m,I),I},K=Y=>({b:Y,l:w(t,Y),r:w(n,Y)}),W=(Y,m)=>{let I=d(m).reverse.get(Y);if(I)return K(I);for(let P of M(S(Y))){let $=r.get(P);if($&&!$.base&&$.local&&$.remote)return{b:null,l:R($.local,"local"),r:R($.remote,"remote")}}return m==="local"?{b:null,l:Y,r:null}:{b:null,l:null,r:Y}},H=new Map,k=Y=>{let m=r.get(Y);if(!m||m.pinned)return null;let I=R(m.base,"base");if(I)return K(I);let P=R(m.local,"local"),$=R(m.remote,"remote");if(P){let Q=t.reverse.get(P);if(Q)return K(Q)}if($){let Q=n.reverse.get($);if(Q)return K(Q)}return P||$?{b:null,l:P,r:$}:null},A=Y=>(H.has(Y)||H.set(Y,k(Y)),H.get(Y)),J=(Y,m)=>rn(Y)?f[m].logicalParent(Y):Y.parent,_=new Map,F=new Map,Oe=(Y,m)=>(rn(Y)?[f[m].pathOf(Y)]:Y.nodes.map(I=>f[m].pathOf(I))).filter(Boolean),Ce=Y=>{let m=Y.b||Y.l||Y.r,I=Y.b?"base":Y.l?"local":"remote",P=F.get(m);if(P)return P;let $=!rn(m),Q=Oe(m,I)[0],B=`${I[0]}:${JSON.stringify(Q===void 0?null:Q)}${$?":run":""}`,me=_.get(B);if(me)return F.set(m,me),me;let xe=U(Y);return me={key:B,nodeType:rn(m)?1:m.kind==="comment"?8:3,base:Y.b?Oe(Y.b,"base"):[],local:Y.l?Oe(Y.l,"local"):[],remote:Y.r?Oe(Y.r,"remote"):[],merged:xe.map(fe=>f.out.pathOf(fe)).filter(Boolean),live:[]},_.set(B,me),F.set(m,me),x.refs.set(me,xe),me},De={base:new Map,local:new Map,remote:new Map},pe=new Map,Te=(Y,m)=>{let I=J(Y,m);if(!I||I.nodeType!==1)return null;let P=De[m].get(I);if(!P){let Q=o(I),B=me=>Ce(m==="base"?K(me):W(me,m));P={parent:B(I),refs:Q.map(B),index:new Map(Q.map((me,xe)=>[me,xe]))},De[m].set(I,P)}let $=P.index.get(Y)??-1;return{parent:P.parent,before:P.refs.slice($+1),after:P.refs.slice(0,Math.max(0,$)).reverse()}},ze=Y=>{let m=Y.parentNode;if(!m)return null;let I=pe.get(m);if(!I){let $=m.nodeType===11?g.get(m):m,Q=$&&$.nodeType===1?A($):null;if(!Q)return null;let B=[],me=[],xe=new Map;for(let Se of m.childNodes){let V=A(Se),Z=V&&Ce(V),be=B.length,ke=B.length-1;Z&&Z!==B[ke]&&(B.push(Z),ke++);let we={ref:Z,group:ke,after:be};me.push(we),xe.set(Se,we)}let fe=B.length;for(let Se=me.length-1;Se>=0;Se--){let V=me[Se];V.before=fe,V.ref&&(fe=V.group)}I={parent:Ce(Q),refs:B,index:xe},pe.set(m,I)}let P=I.index.get(Y);return{parent:I.parent,before:I.refs.slice(P.before),after:I.refs.slice(0,P.after).reverse()}},Me=Y=>rn(Y)?Y.outerHTML:Y.value,v=Y=>rn(Y)?"element":Y.kind==="comment"?"comment":"text",G=(Y,m)=>({path:Y,offset:m}),ue=(Y,m,I)=>{if(!Y)return null;let P=f[I],$=0;if(m){let Q=rn(m)?m:m.nodes[m.nodes.length-1];Q.parentNode&&($=P.indexIn(Q.parentNode,Q)+1)}return G(P.containerPath(Y),$)},ae=(Y,m)=>{let I=J(Y,"base"),P=I?w(d(m),I):null;if(!rn(P))return null;let $=o(I),Q=null;for(let B=$.indexOf(Y)-1;B>=0&&!Q;B--){let me=w(d(m),$[B]);me&&J(me,m)===P&&(Q=me)}return ue(P,Q,m)},Pe=(Y,m,I,P)=>{let $=f[P],Q=0;for(let B=0;B<Y.nodes.length;B++){let me=Y.nodes[B],xe=me.nodeValue.length,fe=B===Y.nodes.length-1;if((I==="start"?m<Q+xe:m<=Q+xe)||fe)return G($.pathOf(me),Math.max(0,Math.min(m-Q,xe)));Q+=xe}return null},He=(Y,m)=>{let I=f[m],P=Y.firstChild,$=Y.lastChild;return P&&P.nodeType===3&&$.nodeType===3?{start:G(I.pathOf(P),0),end:G(I.pathOf($),$.nodeValue.length)}:{start:G(I.pathOf(Y),0),end:G(I.pathOf(Y),Y.childNodes.length)}},ve=(Y,m,I)=>{for(let B of Y.nodes)if(I==="start"?B.s<=m&&m<B.e:B.s<m&&m<=B.e)return{kind:"text",node:B.node,offset:m-B.s};let P=I==="start"?m:m-1,$=()=>{for(let B of Y.nodes)if(B.s===m||B.e===m)return{kind:"text",node:B.node,offset:m-B.s};return null},Q=Y.atomAt.get(P);if(Q)return{kind:I==="start"?"before":"after",node:Q.el};if(Y.text[P]===wt){let B=Y.marks.find(xe=>xe.block&&xe.to===P+1);if(B)return I==="start"?{kind:"end",node:B.el}:{kind:"after",node:B.el};let me=Y.marks.find(xe=>xe.block&&xe.from===P+1);if(me)return I==="start"?{kind:"before",node:me.el}:{kind:"startOf",node:me.el}}return $()},Ze=(Y,m)=>ve(Y,m,"end")||ve(Y,m,"start"),Je=(Y,m)=>{switch(m.kind){case"text":return G(Y.pathOf(m.node),m.offset);case"end":return G(Y.containerPath(m.node),Sn(m.node).childNodes.length);case"startOf":return G(Y.containerPath(m.node),0);default:{let I=m.node.parentNode;return G(Y.containerPath(I),Y.indexIn(I,m.node)+(m.kind==="after"?1:0))}}},pt=(Y,m,I,P,$)=>{let Q=ve(Y,m,I);return Q?Je(f[P],Q):$()},Ye=(Y,m,I,P)=>{let $=Y.textNodes.map(fe=>({s:fe.ms,e:fe.me,start:{kind:"text",node:fe.node,offset:0},end:{kind:"text",node:fe.node,offset:fe.me-fe.ms}}));for(let[fe,Se]of Y.atomOut)$.push({s:fe,e:fe+1,start:{kind:"before",node:Se},end:{kind:"after",node:Se}});for(let[fe,Se]of Y.breakOut)$.push({s:fe,e:fe+1,start:{kind:"end",node:Se},end:{kind:"after",node:Se}});for(let fe of $)if(fe.start.kind==="text"&&fe.s<m&&m<fe.e)return{kind:"text",node:fe.start.node,offset:m-fe.s};if(I!=="empty"){let fe=$.find(Se=>I==="start"?Se.s===m:Se.e===m);if(fe)return I==="start"?fe.start:fe.end}let Q=$.find(fe=>fe.e===m);if(Q)return Q.end;let B=$.find(fe=>fe.s===m);if(B)return B.start;let me=null,xe=null;for(let fe of $)fe.e<=m&&(!me||fe.e>me.e)&&(me=fe),fe.s>=m&&(!xe||fe.s<xe.s)&&(xe=fe);return me?me.end:xe?xe.start:P()},dt=(Y,m)=>{if(!m)return null;if(m.kind==="text"){let $=Y.nodes.find(Q=>Q.node===m.node);return $?$.s+Math.min(m.offset,$.e-$.s):null}let I=Y.atoms.find($=>$.el===m.node);if(I)return m.kind==="after"?I.i+1:I.i;let P=Y.marks.find($=>$.el===m.node);return P?m.kind==="before"&&P.block&&Y.text[P.from-1]===wt&&!Y.marks.some($=>$.block&&$.to===P.from)?P.from-1:m.kind==="startOf"||m.kind==="before"?P.from:m.kind==="end"&&P.block?P.to-1:P.to:null},St=(Y,m,I,P)=>{for(let me of Y.nodes)if(I==="start"?me.s<=m&&m<me.e:me.s<m&&m<=me.e)return{kind:"text",node:me.node,offset:m-me.s};let $=I==="start"?m:m-1;if(!Y.atomAt.has($)&&Y.text[$]!==wt){for(let me of Y.nodes)if(me.s===m||me.e===m)return{kind:"text",node:me.node,offset:m-me.s}}let Q=Y.atomAt.get($);if(Q)return{kind:I==="start"?"before":"after",node:Q.el};if(Y.text[$]===wt){let me=Y.marks.find(fe=>fe.block&&fe.to===$+1);if(me)return I==="start"?{kind:"end",node:me.el}:{kind:"after",node:me.el};let xe=Y.marks.find(fe=>fe.block&&fe.from===$+1);if(xe)return I==="start"?{kind:"before",node:xe.el}:{kind:"startOf",node:xe.el}}let B=Y.marks.find(me=>me.block&&me.from===m);return B?{kind:"startOf",node:B.el}:P?{kind:I==="start"?"startOf":"end",node:P}:null},vt=Y=>{if(!Y)return null;if(Y.kind==="wholeStart"||Y.kind==="wholeEnd"){let m=bt(Y.node);return Y.kind==="wholeStart"?m.start:m.end}return Je(f.out,Y)},bt=Y=>{let m=Y.firstChild,I=Y.lastChild;return m&&m.nodeType===3&&I.nodeType===3?{start:G(f.out.pathOf(m),0),end:G(f.out.pathOf(I),I.nodeValue.length)}:{start:G(f.out.pathOf(Y),0),end:G(f.out.pathOf(Y),Y.childNodes.length)}},At=Y=>{let m=J(Y,"base"),I=m?U(K(m))[0]:null;if(!I)return null;let P=Sn(I),$=o(m);for(let Q=$.indexOf(Y)-1;Q>=0;Q--){let B=U(K($[Q])).filter(me=>me.parentNode===P);if(B.length)return{kind:"after",node:B[B.length-1]}}return{kind:"startOf",node:I}},Ot=(Y,m,I,P,$,Q)=>({text:Y,start:m,end:I,fragment:P,span:$,scope:Q}),Bt=(Y,m,I,P,$)=>Ot(Y,m,I,Y.slice(m,I),P,$),nn=(Y,m,I,P,$)=>(x.spans.set(Y,{start:m,end:I,scopeStart:P,scopeEnd:$}),Y),Nt=new Map,$t=new Map,an=(Y,m,I)=>{let P=`text:${Y.key}:${m}:${I}`,$=$t.get(P)||0;return $t.set(P,$+1),`${P}:${$}`},Pt=(Y,m)=>{let I,P,$,Q="plain",B,me,xe,fe,Se,V=(ke,we,te,re,q)=>{if(!ke){let le=ae(q,re);return Bt("",0,0,{start:le,end:le},{start:le,end:le})}return Bt(ke.value,we,te,{start:Pe(ke,we,we===te?"end":"start",re),end:Pe(ke,te,"end",re)},{start:Pe(ke,0,"start",re),end:Pe(ke,ke.value.length,"end",re)})};if(m.site==="run"){let{bRun:ke,lRun:we,rRun:te,node:re,c:q}=m;I=K(ke),P=q.bs,$=q.be,B=V(ke,q.bs,q.be,"base",ke),me=V(we,q.ls,q.le,"local",ke),xe=V(te,q.rs,q.re,"remote",ke);let le=re?re.nodeValue:"",Ne=Le=>re?{kind:"text",node:re,offset:Le}:At(ke);fe=nn(Bt(le,q.ms,q.me,{start:vt(Ne(q.ms)),end:vt(Ne(q.me))},{start:vt(Ne(0)),end:vt(Ne(le.length))}),Ne(q.ms),Ne(q.me),Ne(0),Ne(le.length)),Se=re||(At(ke)||{}).node||null}else if(m.site==="whole"){let ke=m.el,we=r.get(ke);I=K(we.base),P=0,$=Y.base.length;let te=(q,le,Ne)=>{let Le=He(le,Ne);return Bt(q,0,q.length,Le,Le)};B=te(Y.base,we.base,"base"),me=te(Y.local,we.local,"local"),xe=te(Y.remote,we.remote,"remote");let re=bt(ke);fe=nn(Bt(Y.resolved,0,Y.resolved.length,re,re),{kind:"wholeStart",node:ke},{kind:"wholeEnd",node:ke},{kind:"wholeStart",node:ke},{kind:"wholeEnd",node:ke}),Se=ke}else if(m.site==="comment"){let{bRun:ke,lRun:we,rRun:te,node:re}=m;I=K(ke),P=0,$=Y.base.length;let q=(je,Ae)=>{if(!je){let Qe=ae(ke,Ae);return Bt("",0,0,{start:Qe,end:Qe},{start:Qe,end:Qe})}let Ge=je.nodes[0],et={start:G(f[Ae].pathOf(Ge),0),end:G(f[Ae].pathOf(Ge),je.value.length)};return Bt(je.value,0,je.value.length,et,et)};B=q(ke,"base"),me=q(we,"local"),xe=q(te,"remote");let le=Y.resolved,Ne=je=>re?{kind:"text",node:re,offset:je}:At(ke),Le={start:vt(Ne(0)),end:vt(Ne(le.length))};fe=nn(Bt(le,0,le.length,Le,Le),Ne(0),Ne(le.length),Ne(0),Ne(le.length)),Se=re||(At(ke)||{}).node||null}else{let{fb:ke,fl:we,fr:te,scope:re}=m,q=m.merged;Q="html",I=re.base?K(re.base):W(re.local,"local"),P=Y.bs,$=Y.be;let le=de=>{let ie=re[de];for(let ee=re.at-1;ee>=0;ee--){let se=re.units[ee],Ee=de==="base"?se:w(d(de),se);if(Ee&&J(Ee,de)===ie)return Ee}return null},Ne=de=>()=>ue(re[de],le(de),de),Le=(de,ie,ee,se,Ee)=>{let _e=Tt=>Tt?Je(f[Ee],Tt):Ne(Ee)(),Fe=ie===ee?Ze(de,ie):ve(de,ie,"start"),tt=ie===ee?Ze(de,ie):ve(de,ee,"end"),st=_e(Fe),it={start:st,end:ie===ee?st:_e(tt)},rt=m.full?m.full(Ee):null;if(!rt)return Ot(de.text,ie,ee,se,it,{start:_e(ve(de,0,"start")),end:_e(ve(de,de.text.length,"end"))});let kt=Fe?dt(rt,Fe):null,xt=tt?dt(rt,tt):null,Et=kt===null?0:kt,$e=Math.max(Et,xt===null?rt.text.length:xt),mt=_e(ve(rt,0,"start"));return Ot(rt.text,Et,$e,vo(rt,Et,$e),it,{start:mt,end:rt.text.length?_e(ve(rt,rt.text.length,"end")):mt})};B=m.synthetic?null:Le(ke,Y.bs,Y.be,Y.base,"base"),me=Le(we,Y.lss,Y.lse,Y.local,"local"),xe=Le(te,Y.rss,Y.rse,Y.remote,"remote");let[je,Ae]=Y.range||[0,0],Ge=q.out,et=()=>{let de=Sn(q.node);for(let ie=re.at-1;ie>=0;ie--){let ee=U(K(re.units[ie])).filter(se=>se.parentNode===de);if(ee.length)return{kind:"after",node:ee[ee.length-1]}}for(let ie=re.at;ie<re.units.length;ie++){let ee=U(K(re.units[ie])).filter(se=>se.parentNode===de);if(ee.length)return{kind:"before",node:ee[0]}}return{kind:"startOf",node:q.node}};if(Ge.via)for(let[de,ie]of Ge.via)N.set(de,ie);let Qe=Ye(q,je,je===Ae?"empty":"start",et),Ut=je===Ae?Qe:Ye(q,Ae,"end",et),Mt=Ge.text.length?St(Ge,0,"start",q.node):et(),Kt=Ge.text.length?St(Ge,Ge.text.length,"end",q.node):Mt,Lt=dt(Ge,Qe),_t=dt(Ge,Ut),C=Lt===null?0:Lt,X=Math.max(C,_t===null?Ge.text.length:_t);fe=nn(Ot(Ge.text,C,X,vo(Ge,C,X),{start:vt(Qe),end:vt(Ut)},{start:vt(Mt),end:vt(Kt)}),Qe,Ut,Mt,Kt);let ce=x.spans.get(fe);if(ce.flat=Ge,!Ge.text.length){let de=vt(Mt),ie=co(p,de),ee=ie[0],se=ie[1];ce.empty={parent:ee.nodeType===11?g.get(ee):ee,previous:ee.childNodes[se-1]||null,next:ee.childNodes[se]||null}}Se=Qe?Qe.node:q.node}let Z=Ce(I),be=(m.site==="whole"||m.site==="comment"||(m.policy||i)!=="both")&&Y.resolved!==Y.local;return{key:m.site==="comment"&&Nt.get(I.b||I.l||I.r)||an(Z,P,$),subject:Z,localLost:be,anchor:Se,text:{encoding:Q,base:B,local:me,remote:xe,merged:fe,liveSpan:null,liveScope:null}}},Jt=(Y,m)=>{let I=A(m.el),P=Ce(I),$=m.sample;return{key:`attr:${P.key}:${$.namespaceURI||""}:${$.localName}`,subject:P,localLost:Y.resolved!==Y.local,anchor:m.el,attribute:{namespaceURI:$.namespaceURI||null,localName:$.localName,qualifiedName:$.name}}},Ft=(Y,m)=>{let I=Y.detail,P=m.unit||K(m.subject),$=Ce(P),Q=x.refs.get($),B=P.l?Te(P.l,"local"):null,me=P.r?Te(P.r,"remote"):null,xe=Q.length?ze(Q[0]):null,fe,Se,V,Z=null,be=null,ke=m.deleted;switch(I){case"both-reordered":{fe=Se="reordered";let we=new Set(m.rKept),te=m.lKept.filter(Le=>we.has(Le)&&U(K(Le)).length),re=Le=>T.get(U(K(Le))[0]);Z=te.map(Le=>Ce(K(Le))),be=te.slice().sort((Le,je)=>re(Le)-re(je)).map(Le=>Ce(K(Le)));let q=Le=>!rn(Le)&&Le.kind!=="comment"&&Le.nodes.every(je=>!/[^\t\n\f\r ]/.test(je.data)),le=te.filter(Le=>!q(Le)),Ne=le.slice().sort((Le,je)=>re(Le)-re(je));V=le.some((Le,je)=>Le!==Ne[je]);break}case"both-moved":fe=Se="moved",V=!B||!Q.some(we=>{let te=we===Q[0]?xe:ze(we);return te&&te.parent===B.parent});break;case"edit-beats-delete":fe=ke==="local"?"deleted":"edited",Se=ke==="remote"?"deleted":"edited",V=ke==="local";break;case"move-beats-delete":fe=ke==="local"?"deleted":"moved",Se=ke==="remote"?"deleted":"moved",V=ke==="local";break;case"remote-wins":fe="edited",Se="edited",V=!0;break;default:fe=Se="inserted",V=m.localLost}return{key:`structure:${$.key}:${I}`,subject:$,localLost:V,anchor:Q[0]||null,structure:{localAction:fe,remoteAction:Se,localPlacement:B,remotePlacement:me,mergedPlacement:xe,localOrder:Z,mergedOrder:be,localFragment:I==="both-reordered"||!P.l?null:Me(P.l),fragmentKind:v(P.b||P.l||P.r)}}};for(let[Y,m]of s){if(Y.kind!=="structure")continue;let I=m.unit||K(m.subject),P=I.b||I.l||I.r;!rn(P)&&P.kind==="comment"&&Nt.set(P,`structure:${Ce(I).key}:${Y.detail}`)}let on=new Map;for(let[Y,m]of s){if(Y.kind==="structure"){let Q=Ce(m.unit||K(m.subject)),B=`structure:${Q.key}:${Y.detail}`,me=on.get(B);if(me&&me.structure){Y.recovery=me;let xe=x.refs.get(Q);Y.el==null&&xe.length&&(Y.el=rn(xe[0])?xe[0]:f.out.logicalParent(xe[0]));continue}}let I=Y.kind==="text"?Pt(Y,m):Y.kind==="attr"?Jt(Y,m):Ft(Y,m),P=on.get(I.key);P||(P={version:Fa,key:I.key,localLost:I.localLost,subject:I.subject,applied:!1,unavailable:null},on.set(I.key,P),x.anchors.set(P,I.anchor)),I.text&&(P.text=I.text),I.attribute&&(P.attribute=I.attribute),I.structure&&(P.structure=I.structure),I.text&&(P.localLost=I.localLost),Y.recovery=P;let $=x.refs.get(I.subject);Y.kind==="structure"&&Y.el==null&&$.length&&(Y.el=rn($[0])?$[0]:f.out.logicalParent($[0])),Y.kind==="text"&&Y.node==null&&$.length&&I.subject.nodeType===8&&(Y.node=$[0])}return x}}function pl(e,t,n){if(!t)return;let{lookup:o,vetoed:r,vetoedAttrs:i,liveAttr:s}=n,l=n.ignored||(()=>!1),c=fo(n.liveRoot),a=k=>!!k&&c.containerPath(k)!==null,p=k=>{let A=k.parentNode;return A&&A.nodeType===11?t.outOwners.get(A)||null:A},f=k=>{for(let A=k;A;A=p(A))if(t.via.has(A)&&(A=t.via.get(A)),r.has(A)||n.vetoedLive?.has(h(A)))return!0;return!1},d=k=>Array.from(Sn(k).children).filter(A=>!l(A)),w=(k,A)=>d(k)[d(A.parentNode).indexOf(A)],b=(k,A)=>{let J=null,_=null,F=0;for(let pe=A.previousSibling;pe;pe=pe.previousSibling){if(pe.nodeType===1&&!l(pe)){J=pe;break}pe.nodeType===3&&(F+=pe.nodeValue.length)}for(let pe=A.nextSibling;pe&&!_;pe=pe.nextSibling)pe.nodeType===1&&!l(pe)&&(_=pe);let Oe=J?w(k,J):null,Ce=_?w(k,_):null;if(J&&!Oe||_&&!Ce)return null;let De=[];for(let pe=Oe?Oe.nextSibling:Sn(k).firstChild;pe&&pe!==Ce;pe=pe.nextSibling)pe.nodeType===3&&De.push(pe);return De.length?{nodes:De,lead:F}:null},T=k=>{let A=[],J=k;for(;J&&!t.via.has(J);J=J.parentNode)A.push(J);if(!J||!A.length)return null;let _=h(t.via.get(J));for(let Ce=A.length-1;Ce>0&&_;Ce--)_=w(_,A[Ce]);if(!_)return null;let F=A[0];if(F.nodeType===3)return b(_,F);let Oe=F.nodeType===1?w(_,F):null;return Oe?{nodes:[Oe],lead:0}:null},g=k=>{let A=o(k),J=A?{nodes:Array.isArray(A)?A:[A],lead:0}:t.via.size?T(k):null;if(!J)return null;let _=J.nodes.filter(a);return _.length?{nodes:_,lead:J.lead}:null},h=k=>{let A=g(k);return A?A.nodes[0]:null},y=k=>{if(!k)return null;if(k.kind==="text"){let F=g(k.node);if(!F)return null;let Oe=F.nodes,Ce=k.offset+F.lead,De=0;for(let pe=0;pe<Oe.length;pe++){let Te=Oe[pe].nodeValue.length;if(Ce<=De+Te||pe===Oe.length-1)return Ce>=De&&Ce<=De+Te?[Oe[pe],Ce-De]:null;De+=Te}return null}let A=h(k.node);if(!A)return null;if(k.kind==="end")return[Sn(A),Sn(A).childNodes.length];if(k.kind==="startOf")return[Sn(A),0];if(k.kind==="wholeStart")return A.firstChild?[A.firstChild,0]:[A,0];if(k.kind==="wholeEnd")return A.lastChild?[A.lastChild,A.lastChild.nodeValue.length]:[A,A.childNodes.length];let J=A.parentNode;if(!J)return null;let _=Array.prototype.indexOf.call(J.childNodes,A);return[J,k.kind==="after"?_+1:_]},N=k=>({blocks:new Set((k.flat?.marks||[]).filter(A=>A.block).map(A=>h(A.el)).filter(Boolean)),atoms:new Set((k.flat?.atoms||[]).map(A=>h(A.el)).filter(Boolean)),ignored:l}),x=(k,A,J,_)=>{if(!k||!A||!ao(k)||!ao(A))return!1;for(let Ce of[k,A])if(!a(Ce.startContainer)||!a(Ce.endContainer))return!1;let F=J.merged;if(F.start===F.end&&(k.startContainer!==k.endContainer||k.startOffset!==k.endOffset))return!1;let Oe=N(_);return Xn(A,J.encoding,Oe)===F.text&&Xn(k,J.encoding,Oe)===F.text.slice(F.start,F.end)},S=new Map,O=k=>{let A=k.parentNode;return A?(S.has(A)||S.set(A,new Map(Array.from(A.childNodes,(J,_)=>[J,_]))),S.get(A).get(k)):-1},R=(k,A)=>{if(!A)return!1;let J=c.logicalParent(k);if(!A.parent.live.includes(J))return!1;let _=O(k);for(let[F,Oe]of[["before",1],["after",-1]]){let Ce=_;for(let De of A[F]){if(De.live.includes(k))continue;let pe=De.live.filter(ze=>ze!==k&&ze.parentNode===k.parentNode);if(!pe.length)continue;let Te=Oe===1?Math.min(...pe.map(O)):Math.max(...pe.map(O));if(Oe*(Te-Ce)<=0)return!1;Ce=Te}}return!0},M=k=>{let A=k.structure;if(A.mergedOrder){let J=new Set(k.subject.live.map(Sn)),_=null,F=-1;for(let Oe of A.mergedOrder){let Ce=Oe.live.find(De=>J.has(De.parentNode));if(!Ce||_&&Ce.parentNode!==_||O(Ce)<=F)return!1;_=Ce.parentNode,F=O(Ce)}return k.subject.live.length>0}return k.subject.live.some(J=>R(J,A.mergedPlacement))},j=(k,A)=>{let J=y(k),_=y(A);return J&&_?{startContainer:J[0],startOffset:J[1],endContainer:_[0],endOffset:_[1]}:null},U=new Set,K=k=>{if(!k||U.has(k))return;U.add(k);let A=[];for(let J of t.refs.get(k)||[]){let _=g(J);if(_)for(let F of _.nodes)A.includes(F)||A.push(F)}k.live=A},W=k=>{k&&(K(k.parent),k.before.forEach(K),k.after.forEach(K))},H=new Set;for(let k of e){let A=k.recovery;if(!A||H.has(A))continue;H.add(A),K(A.subject),A.structure&&(W(A.structure.localPlacement),W(A.structure.remotePlacement),W(A.structure.mergedPlacement),(A.structure.localOrder||[]).forEach(K),(A.structure.mergedOrder||[]).forEach(K));let J=t.anchors.get(A),_=J?h(J):null,F=!!_;if(A.text){let G=t.spans.get(A.text.merged),ue=G?j(G.start,G.end):null,ae=G?j(G.scopeStart,G.scopeEnd):null;if(G?.empty){let Pe=G.empty,He=Pe.previous?{kind:"after",node:Pe.previous}:{kind:"startOf",node:Pe.parent},ve=Pe.next?{kind:"before",node:Pe.next}:{kind:"end",node:Pe.parent},Ze=j(He,ve);!Ze||Ze.startContainer!==Ze.endContainer||Ze.startOffset!==Ze.endOffset?ue=null:ue=ae=Ze}x(ue,ae,A.text,G)||(ue=ae=null),A.text.liveSpan=ue,A.text.liveScope=ue?ae:null,ue||(F=!1)}A.structure&&F&&(F=M(A)),A.attribute&&F&&(F=s(_,A.attribute,k.resolved));let Oe=G=>G?.tagName==="TEXTAREA"?G:G?.parentNode?.tagName==="TEXTAREA"?G.parentNode:null,Ce=(!!A.attribute||!!A.text&&!!(Oe(_)||Oe(J)))&&!!i&&[J,_,Oe(_),Oe(J)].some(G=>i.get(G)?.has(A.attribute?A.attribute.qualifiedName:"value")),De=t.localState?.states.get(A),pe=!!A.text&&[...n.removedVetoes||[]].some(G=>De?.touched.has(G)),Te=A.structure?.localAction==="inserted"&&[...r].some(G=>G===J||J?.contains(G)),ze=J&&f(J)||Ce||pe||Te,Me=ze&&dl(A,k,t,a);Me&&(pe||Te&&A.localLost)&&(F=!1);let v=!F&&Me&&ze;A.applied=F,A.unavailable=F?null:v?"hook-veto":"missing-output",v&&(A.localLost=!1),!F&&A.text&&(A.text.liveSpan=A.text.liveScope=null)}}function Ur(e,t,n){let o=fo(t),r=fo(n),i=f=>!!f&&r.containerPath(f)!==null,s=f=>{if(f===t)return n;let d=o.pathOf(f);if(d&&t!==n){let w=co(n,{path:d,offset:0});if(w&&w[0].nodeType===f.nodeType)return w[0]}return f},l=new Set,c=f=>{!f||l.has(f)||(l.add(f),f.live=f.live.map(s).filter(i))},a=f=>{f&&(f.startContainer=s(f.startContainer),f.endContainer=s(f.endContainer))},p=new Set;for(let f of e){f.node===t&&n.tagName==="SCRIPT"&&(f.node=n),f.el===t&&f.kind==="structure"&&(f.el=n);let d=f.recovery;if(!d||p.has(d))continue;if(p.add(d),c(d.subject),d.text){a(d.text.liveSpan),a(d.text.liveScope);let b=d.text.liveSpan,T=d.text.liveScope,g=d.text.merged,h=y=>!!y&&ao(y)&&i(y.startContainer)&&i(y.endContainer);(!h(b)||!h(T)||Xn(T,d.text.encoding)!==g.text||Xn(b,d.text.encoding)!==g.text.slice(g.start,g.end))&&(d.text.liveSpan=null,d.text.liveScope=null,d.applied=!1,d.unavailable="missing-output")}let w=d.structure;if(w){for(let b of[w.localPlacement,w.remotePlacement,w.mergedPlacement])b&&(c(b.parent),b.before.forEach(c),b.after.forEach(c));(w.localOrder||[]).forEach(c),(w.mergedOrder||[]).forEach(c),d.subject.live.length||(d.applied=!1,d.unavailable="missing-output")}}}var Co=e=>e?.nodeType===1,Qo=e=>e?.tagName==="TEMPLATE"&&e.content?e.content:e;function qa({provenance:e,parentOf:t,twins:n,baseOf:o,build:r,ignored:i,remoteWins:s,discarded:l}){let c=new Map,a=new WeakMap;function p(w,b,T,g=!1){if(!Co(w)||!Co(T))return null;let h=c.get(w);if(h)(g||!h.selected&&b==="remote")&&(h.parent=t(T),h.port=T,h.sourceSide=b,h.selected=g);else{let y=a.get(w)||null;h={owner:w,parent:t(T),port:T,sourceSide:b,originalParent:t(w),originalPort:w,selected:g,state:y?"built":"planned",output:y,disposition:null},c.set(w,h)}return h}function f(w,b){if(!Co(w)||!Co(b))return;a.has(w)||a.set(w,b);let T=c.get(w);T&&T.state!=="attached"&&!T.output&&(T.output=b,T.state="built")}function d(w){if(!c.size)return;let b=new Map,T=new WeakMap,g=new WeakMap,h=new WeakSet,y=new Set,N=(W,H)=>{if(!W)return;if(Array.isArray(W)){for(let A of W)N(A,H);return}let k=b.get(W);k||b.set(W,k=[]),k.push(H)},x=(W,H)=>{if(!W)return;let k=[W];for(;k.length;){let A=k.pop();N(A,H);for(let J of Qo(A).childNodes)k.push(J)}};function S(W,H=null,k=!1){if(h.has(W))return;h.add(W),T.set(W,H);let A=e.get(W),J=k||!!(A&&s(A.remote||A.base));g.set(W,J);let _={node:W,kind:"node",authority:J};if(A?.pinned)x(A.local,{..._,kind:"ignored"});else if(A?.unchanged)for(let F of[A.base,A.local,A.remote])x(F,{..._,kind:"unchanged"});else if(A){for(let F of[A.base,A.local,A.remote])N(F,_);if(Co(A.local))for(let F of Qo(A.local).children)i(F)&&x(F,{..._,kind:"ignored"})}for(let F of Qo(W).childNodes)S(F,W,J)}let O=W=>{if(W.output&&h.has(W.output))return W.state="attached",W.disposition="node",!0;let{local:H,remote:k}=n(W.owner);for(let A of[W.owner,H,k]){let J=b.get(A);if(J?.length){let _=J.find(F=>F.kind==="node")||J[0];return W.output=_.node,W.state="attached",W.disposition=_.kind,!0}}return!1},R=(W,H)=>(b.get(W)||[]).find(A=>A.kind==="node"&&Co(A.node)&&(!A.authority||H.sourceSide==="remote"))?.node,M=(W,H,k)=>{let A=b.get(W)||[],J=k?[...A].reverse():A;for(let _ of J){if(_.kind!=="node")continue;let F=_.node;for(;F&&T.get(F)!==H;)F=T.get(F);if(F)return F}return null},j=(W,H,k)=>{let A=Qo(H);for(let J=k?.previousSibling;J;J=J.previousSibling){let _=M(J,H,!0);if(_){A.insertBefore(W,_.nextSibling);return}}for(let J=k?.nextSibling;J;J=J.nextSibling){let _=M(J,H,!1);if(_){A.insertBefore(W,_);return}}A.appendChild(W)};function U(W,H,k){let A=H==="base"?W:o(W,H),J=c.get(A);J&&J!==k&&K(J)}function K(W){if(W.state==="attached"||W.disposition==="remote-wins"||y.has(W)||O(W))return;y.add(W);let{local:H,remote:k}=n(W.owner);if(s(k||W.owner)){if(!k){W.disposition="remote-wins",l(W.owner,H),y.delete(W);return}W.parent=t(k),W.port=k,W.sourceSide="remote"}if(U(W.parent,W.sourceSide,W),O(W)){y.delete(W);return}let A=R(W.parent,W),J=W.port;if(!A){if(U(W.originalParent,"base",W),O(W)){y.delete(W);return}let F=W.originalParent;for(J=W.originalPort;F&&!A;)A=R(F,W),A||(J=F,F=t(F))}if(!A)throw new Error("A planned move has no allowed surviving parent");let _=W.output||r(W.owner);W.output=_,W.state="built",j(_,A,J),S(_,A,g.get(A)||!1),O(W),y.delete(W)}S(w);for(let W of c.values())K(W)}return{planned:c,has:w=>c.has(w),plan:p,produced:f,drain:d}}function Ro(e,t,n,o,r,i,s,l,c,a,p,f,d){let w=null;return qa({provenance:e,parentOf:g=>{if(!g)return null;let h=t(g);if(h||g.parentNode?.nodeType!==11)return h;if(!w){w=new WeakMap;let y=[f,d];for(;y.length;){let N=y.pop(),x=Qo(N);x!==N&&w.set(x,N);for(let S of x.children)y.push(S)}}return w.get(g.parentNode)||null},twins:g=>({local:r(n,g),remote:r(o,g)}),baseOf:(g,h)=>g&&(h==="local"?n:o).reverse.get(g)||null,build:g=>i(g,r(n,g),r(o,g),!1),ignored:s,remoteWins:l,discarded:(g,h)=>{h&&p(g,h,n)&&!c.some(y=>y.detail==="remote-wins"&&y.base===g)&&a({kind:"structure",el:null,detail:"remote-wins",base:g,local:h,remote:null},{subject:g})}})}function Ka({parent:e,base:t,views:n,eligible:o,ignored:r,remoteWins:i,budget:s=Wt(2e4*32),maxUnits:l=256,maxCharacters:c=2e4}){let a=(h,y=null)=>({status:h,reason:y,parent:e,records:[]});if(n.some(({V:h})=>h.asBase)||r(e)||i(e)||n.some(({V:h})=>!h.el||r(h.el)||i(h.el)))return a("none");let p=t.length+n[0].V.units.length+n[1].V.units.length;if(p>l)return a("fallback","unit-limit");let f=Symbol(),d=h=>{if(h>s.remaining)throw f;s.remaining-=h,s.crossParentSteps=(s.crossParentSteps||0)+h},w=new Map,b=0,T=h=>{if(d(1),w.has(h))return w.get(h);let y=h.nodeType===1?h.childNodes:h.nodes;d(y.length*4+1);let N=h.nodeType===1?Array.from(y):y,x=0;for(let R=0;R<N.length;R++){let M=N[R];if(M.nodeType!==3||R&&N[R-1].nextSibling!==M)return w.set(h,null),null;x+=M.data.length}if(x>c-b)throw f;d(x*8+1),b+=x;let S=zt(N);if(S.text.includes(wt))return w.set(h,null),null;let O={unit:h,nodes:N,flat:S};return w.set(h,O),O},g=[];try{d(p*8+1);for(let h=0;h<2;h++){let y=n[h].V,N=n[1-h].V,x=[],S=new Map;for(let O=0;O<t.length;O++){d(1);let R=t[O];if(R.kind!=="text"||y.twin(R))continue;let M=N.twin(R);if(!M||M.kind!=="text"||!N.here(M))continue;let j=T(R),U=T(M);if(!j||!U||!/\S/.test(j.flat.text))continue;d(j.flat.text.length*2+1);let K=j.flat.text;S.set(K,(S.get(K)||0)+1),x.push({source:R,opposite:M,sourceModel:j,oppositeModel:U,index:O})}for(let O of x){let{source:R,opposite:M,sourceModel:j,oppositeModel:U,index:K}=O,W=[];for(let G of[-1,1]){d(1);let ue=t[K+G];if(!ue||ue.nodeType!==1||!o(ue)||r(ue)||i(ue))continue;let ae=j.nodes[0],Pe=j.nodes.at(-1);if(G===-1?ae?.previousSibling!==ue:Pe?.nextSibling!==ue)continue;let He=y.twin(ue),ve=N.twin(ue);if(!He||!ve||!y.here(He)||N.here(ve)||y.baseOf(He)!==ue||N.baseOf(ve)!==ue||!o(He)||!o(ve)||r(He)||r(ve)||i(He)||i(ve)||He.tagName!==ue.tagName||ve.tagName!==ue.tagName||He.namespaceURI!==ue.namespaceURI||ve.namespaceURI!==ue.namespaceURI)continue;let Ze=T(ue),Je=T(He),pt=T(ve);if(!Ze||!Je||!pt||!/\S/.test(Ze.flat.text))continue;let Ye=Ze.flat.text,dt=j.flat.text,St=Je.flat.text;if(d((Ye.length+dt.length+St.length)*3+1),St.length!==Ye.length+dt.length)continue;let vt=G===-1;(vt?!St.startsWith(Ye)||!St.endsWith(dt):!St.startsWith(dt)||!St.endsWith(Ye))||W.push({owner:ue,target:He,moved:ve,ownerBase:Ze,joined:Je,ownerOther:pt,targetFrom:vt?Ye.length:0,retainedFrom:vt?0:dt.length})}if(!W.length)continue;if(W.length!==1||S.get(j.flat.text)!==1)return a("fallback","ambiguous-origin");let H=W[0],{owner:k,target:A,moved:J,ownerBase:_,joined:F,ownerOther:Oe,targetFrom:Ce,retainedFrom:De}=H;if(d(g.length+1),g.some(G=>G.owner===k))return a("fallback","ambiguous-owner");let pe={source:R,target:A,from:0,to:j.flat.text.length,targetFrom:Ce},Te=Rn({base:j.flat,side:F.flat,retained:[],transfers:[{from:pe.from,to:pe.to,target:Ce,destination:k}],budget:s});if(Te.status!=="ready"||Te.covers(pe.from,pe.to)!==!0)return a("fallback",Te.reason||"work-limit");let ze=[{unit:R,model:j,from:0,to:j.flat.text.length},null,null];ze[h+1]={unit:A,model:F,from:Ce,to:Ce+j.flat.text.length},ze[2-h]={unit:M,model:U,from:0,to:U.flat.text.length};let Me=[_,null,null];Me[h+1]=F,Me[2-h]=Oe;let v=[k,null,null];v[h+1]=A,v[2-h]=J,g.push({side:h,parent:e,source:R,target:A,owner:k,owners:v,ownerModels:Me,native:ze,models:w,runs:[pe],proof:Te,retained:[{source:k,target:A,from:0,to:_.flat.text.length,targetFrom:De}]})}}return g.length?{status:"ready",reason:null,parent:e,records:g}:a("none")}catch(h){if(h!==f)throw h;return a("fallback","work-limit")}}function ml({describe:e,parentOf:t,...n}){let o=new WeakMap,r=new WeakMap,i=n.budget||Wt(2e4*32),s=l=>{if(!l)return null;if(o.has(l))return o.get(l);o.set(l,{status:"planning",parent:l,records:[]});let c=e(l),a=c?Ka({...n,...c,parent:l,budget:i}):{status:"none",reason:null,parent:l,records:[]};if(o.set(l,a),a.status==="ready")for(let p of a.records)r.set(p.owner,[p]);return a};return{get:s,forOwner(l){return s(t(l))?.status==="ready"&&r.get(l)||null}}}function za(e,t){if(e.side!==0)return null;let n=e.native[0].model,o=e.ownerModels[0],r=e.native[1].from!==0,i=(N,x)=>r?[...N.nodes,...x.nodes]:[...x.nodes,...N.nodes],s=e.ownerModels.reduce((N,x)=>N+x.flat.text.length,0)+n.flat.text.length+e.native[2].model.flat.text.length;if(s*8>t.remaining)return null;t.remaining-=s*8;let l={base:i(o,n),local:e.ownerModels[1].nodes,remote:i(e.ownerModels[2],e.native[2].model)},c=zt(l.base),a=e.ownerModels[1].flat,p=zt(l.remote),f=r?o.flat.text.length:0,d=r?0:n.flat.text.length,w=Rn({base:c,side:a,retained:e.retained.map(N=>({from:d+N.from,to:d+N.to,target:N.targetFrom})),transfers:e.runs.map(N=>({from:f+N.from,to:f+N.to,target:N.targetFrom,destination:e.owner})),budget:t});if(w.status!=="ready"||w.covers(0,c.text.length)!==!0)return null;let b=e.ownerModels[2].flat,T=e.native[2].model.flat,g=[];for(let[N,x,S,O]of[[o.flat,b,d,r?0:T.text.length],[n.flat,T,f,r?b.text.length:0]]){let R=Ts(N,N,x).remoteMap.bTo,M=-1;for(let j=0;j<N.text.length;j++){if(R[j]<0){M=-1;continue}let U=g.at(-1);M>=0&&U.to===S+j&&U.target+U.to-U.from===O+R[j]?U.to++:(g.push({from:S+j,to:S+j+1,target:O+R[j]}),M=j)}}let h=Rn({base:c,side:p,retained:g,transfers:[],budget:t});if(h.status!=="ready")return null;let y=Ts(c,a,p,{},{local:w,remote:h});return y.localEdits.hunks.length?null:(y.localMap=w,y.remoteMap=h,{nodes:l,prepared:y})}function gl({L:e,R:t,twinIn:n,unitsOf:o,view:r,parentOf:i,ignored:s,remoteWins:l,eligible:c,build:a,out:p,policy:f,provenance:d,textMappers:w,segments:b,conflicts:T,conflict:g,decisions:h}){let y=Wt(2e4*32),N=W=>{let H=0;for(let k=W;k;k=i(k))if(++H>64||k.nodeType===1&&(s(k)||l(k)))return!1;return!0},x=ml({parentOf:i,eligible:c,ignored:s,remoteWins:l,budget:y,describe(W){let H=n(e,W),k=n(t,W);return!H||!k||!N(W)||!N(H)||!N(k)?null:{base:o(W),views:[{A:e,V:r(e,H,W,!1)},{A:t,V:r(t,k,W,!1)}]}}}),S=new WeakSet,O=new WeakMap,R=new WeakSet,M=[];function j(W){if(!W||S.has(W))return;S.add(W);let H=x.get(W);if(H?.status==="ready")for(let k of H.records){if((W.tagName==="TEMPLATE"&&W.content?W.content:W).childNodes.length!==k.native[0].model.nodes.length+1||!k.owners.every(N))continue;let J=za(k,y);if(!J)continue;let _={record:k,payload:J,state:"planned",output:null,result:null};O.set(k.owner,_),R.add(k.source),R.add(k.native[2].unit),M.push(_)}}function U(W,H){let k=O.get(W);if(!k)return!1;if(!k.result){if(k.result=Rr({...k.payload.nodes,prepared:k.payload.prepared,out:p,policy:f,provenance:d,textMappers:w,conflicts:T,conflict:g,decisions:h,node:H}),k.result.conflicts.length)throw new Error("Unsupported cross-parent payload conflict");b.push(...k.result.segments),k.decision={kind:"text",node:H,source:"local"},h.push(k.decision)}return k.decision.node=H,H.replaceChildren(...k.result.nodes),k.output=H,k.state="built",!0}function K(W){if(!M.length)return;let H=new WeakSet,k=new WeakMap,A=new WeakMap,J=new WeakMap,_=Te=>Te.tagName==="TEMPLATE"&&Te.content?Te.content:Te,F=(Te,ze)=>{if(!Te)return;if(Array.isArray(Te)){for(let v of Te)F(v,ze);return}let Me=J.get(Te);Me||J.set(Te,Me=[]),Me.push(ze)},Oe=(Te,ze=null,Me=!1)=>{H.add(Te),k.set(Te,ze);let v=d.get(Te),G=Me||!!(v&&l(v.remote||v.base));if(A.set(Te,G),v)for(let ue of[v.base,v.local,v.remote])F(ue,Te);if(!(v?.pinned||v?.unchanged))for(let ue of _(Te).childNodes)Oe(ue,Te,G)},Ce=Te=>(J.get(Te)||[]).find(ze=>ze.nodeType===1&&!A.get(ze)&&!d.get(ze)?.pinned&&!d.get(ze)?.unchanged),De=(Te,ze)=>{for(let Me of J.get(Te)||[]){let v=Me;for(;v&&k.get(v)!==ze;)v=k.get(v);if(v)return v}return null},pe=(Te,ze,Me)=>{let v=_(ze);for(let G=Me.nextSibling;G;G=G.nextSibling){let ue=De(G,ze);if(ue){v.insertBefore(Te,ue);return}}for(let G=Me.previousSibling;G;G=G.previousSibling){let ue=De(G,ze);if(ue){v.insertBefore(Te,ue.nextSibling);return}}v.appendChild(Te)};Oe(W);for(let Te of M){let{record:ze}=Te,Me=Ce(ze.owner)||Ce(ze.owners[1])||Ce(ze.owners[2]);if(Me)(!Te.result||Te.output!==Me||Te.result.nodes.some(v=>!H.has(v)||k.get(v)!==Me)||Me.textContent!==Te.result.text)&&(U(ze.owner,Me),Oe(Me,k.get(Me),A.get(Me)));else{let v=ze.parent,G=ze.owner,ue=null;for(;v&&!ue;)ue=Ce(v),ue||(G=v,v=i(v));if(!ue)throw new Error("A cross-parent payload has no allowed surviving parent");Me=Te.output||a(ze.owner,ze.owners[1],ze.owners[2],!1),Te.result||U(ze.owner,Me),pe(Me,ue,G),Oe(Me,ue,A.get(ue))}Te.state="attached"}}return{ensureParent:j,ensureOwner(W){j(i(W))},consumes(W){return R.has(W)},render:U,drain:K}}var wn=/\S/,bl=/[\p{L}\p{N}]/u;function uo(e,t,n,o){if(e?.nodeType!==1||!t(e))return!1;for(let r=e.firstChild;r;r=r.nextSibling)if(o(n,1),r.nodeType!==3)return!1;return!!e.firstChild}function Rs(e,t,n){for(let o=e.parentNode;o;o=o.parentNode)if(n(t,1),o.nodeType===11)return!1;return!0}function yl(e,t,n,o,r){let i=n(e,o),s=n(t,o),l=null,c=null,a=null,p=null;r(o,i.length+s.length);for(let f of i)bl.test(f.raw)&&(l||=f,c=f);for(let f of s)bl.test(f.raw)&&(a||=f,p=f);return!!(l&&a&&(l.raw===a.raw||c.raw===p.raw))}function Ga({base:e,V:t,A:n,source:o,original:r,current:i,edited:s,destination:l,at:c,ownLength:a,eligible:p,model:f,tokensOf:d,budget:w,charge:b}){let T=r.flat.text,g=i.flat.text,h=s.flat.text,y=l.flat.text;if(b(w,T.length+g.length+y.length),T.startsWith(g)||T.endsWith(g))return!1;let N=wn.test(y.slice(0,c)),x=wn.test(y.slice(c+a));if(N===x)return!1;let S=N?0:c+a,O=N?c:y.length;for(;S<O&&!wn.test(y[S]);)S++;for(;O>S&&!wn.test(y[O-1]);)O--;let R=y.slice(S,O);if(Tn(R,y,d(l,w),w,b,!0)!==S)return!1;let M=Tn(R,T,d(r,w),w,b,!0);if(M<0)return!1;let j=M+R.length,U=!wn.test(T.slice(0,M)),K=!wn.test(T.slice(j));if(U===K||Tn(R,g,d(i,w),w,b,!1)>=0)return!1;let W=U?T.slice(j):T.slice(0,M),H=U?h.length-W.length:0;if(b(w,T.length+h.length),H<0||!wn.test(W)||Tn(W,h,d(s,w),w,b,!0)!==H||!wn.test(U?h.slice(0,H):h.slice(W.length)))return!1;for(let k of e){if(b(w,1),k===o||!uo(k,p,w,b))continue;let A=f(k,null,w);if(Tn(R,A.flat.text,d(A,w),w,b,!1)>=0)return!1}for(let k of t.units){if(b(w,1),k===i.unit||k===l.unit||!uo(k,p,w,b))continue;let A=f(k,n,w);if(Tn(R,A.flat.text,d(A,w),w,b,!1)>=0)return!1}return!0}function wl({base:e,views:t,side:n,attempt:o,eligible:r,blocked:i,baseId:s,model:l,tokensOf:c,charge:a,exhausted:p,limit:f}){if(f<=0)return null;let d=Wt(f),{V:w,A:b,idOf:T}=t[n],g=t[1-n],[h,y,N,x]=o,S=null;try{for(let O=h;O<=y;O++){a(d,1);let R=e[O];if(R.parentNode?.nodeType!==1||i.has(R)||b.identical.has(R)||g.A.identical.has(R)||!uo(R,r,d,a)||s(R))continue;let M=w.twin(R),j=g.V.twin(R);if(!M||!j||!w.here(M)||!g.V.here(j)||b.map.get(R)!==M||b.reverse.get(M)!==R||g.A.map.get(R)!==j||g.A.reverse.get(j)!==R||T(M)||g.idOf(j)||M.tagName!==R.tagName||j.tagName!==R.tagName||!uo(M,r,d,a)||!uo(j,r,d,a)||!Rs(R,d,a)||!Rs(M,d,a)||!Rs(j,d,a))continue;let U=l(R,null,d),K=l(M,b,d),W=l(j,g.A,d),H=U.flat.text,k=K.flat.text,A=W.flat.text;if(a(d,H.length+k.length+A.length),!wn.test(H)||!wn.test(k)||!wn.test(A)||H===k||H===A||k===A||!yl(U,K,c,d,a)||!yl(U,W,c,d,a))continue;let J=null,_=!1;for(let Ce=N;Ce<=x;Ce++){a(d,1);let De=w.units[Ce],pe=w.baseOf(De);if(!pe||pe===R||i.has(pe)||pe.parentNode!==R.parentNode||De.parentNode!==M.parentNode||pe.tagName!==R.tagName||De.tagName!==R.tagName||b.map.get(pe)!==De||b.reverse.get(De)!==pe||s(pe)!==T(De)||!uo(pe,r,d,a)||!uo(De,r,d,a))continue;let Te=l(pe,null,d),ze=l(De,b,d),Me=Te.flat.text,v=ze.flat.text;if(a(d,Me.length),!wn.test(Me)||v.length<=Me.length)continue;let G=c(ze,d),ue=Tn(Me,v,G,d,a,!0);if(!(ue<0||Tn(H,v,G,d,a,!0,ue,ue+Me.length)<0&&!Ga({base:e,V:w,A:b,source:R,original:U,current:K,edited:W,destination:ze,at:ue,ownLength:Me.length,eligible:r,model:l,tokensOf:c,budget:d,charge:a}))){if(J){_=!0;break}J=De}}if(!J||_)continue;let F=n===0?M:j,Oe=n===0?j:M;(S||=[]).push({source:R,local:F,remote:Oe,models:[U,n===0?K:W,n===0?W:K]})}}catch(O){if(O!==p)throw O}return S}var jn=/\S/,cn=/\s/,Ya=/[\s\u001e]/g,Ls=/[^\s\p{P}\u001e\ufffc]/u;function Xa(e,t,n,o,r,i,s){let l=0;for(let c of e)s(i,1),c.nodeType===1&&!o.baseOf(c)&&l++;if(l<2)return!1;for(let c of e){if(c.nodeType!==1||o.baseOf(c))continue;let a=r.get(c).flat;if(a.atoms.length||a.pins?.length)continue;s(i,a.text.length*2+t.length+n.length);let p=new Uint8Array(a.text.length);for(let f of n)f.target===c&&p.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f of t)f.target===c&&p.fill(1,f.targetFrom,f.targetFrom+f.to-f.from);for(let f=0;f<a.text.length;f++)if(!p[f]&&jn.test(a.text[f]))return!0}return!1}function Ja(e,t,n){let{source:o,models:r,retained:i,runs:s}=e,l=r.get(o).flat.text;n(t,l.length*2+i.length+s.length);let c=new Uint8Array(l.length);for(let a of i)a.source===o&&(n(t,a.to-a.from),c.fill(1,a.from,a.to));for(let a of s)n(t,a.to-a.from),c.fill(1,a.from,a.to);for(let a=0;a<l.length;a++)if(!c[a]&&jn.test(l[a]))return!1;return!0}function Za(e,t,n,o,r,i,s,l,c,a){let p=i.get(e),f=i.get(t),d=p.flat.text,w=s.get(e);c(a,d.length*2+n.length);let b=d.length,T=0;for(let y=0;y<d.length;y++)!cn.test(d[y])&&!w[y]&&(b=Math.min(b,y),T=y+1);if(b>=T)return null;for(let y=b;y<T;y++)if(!cn.test(d[y])&&w[y])return null;let g=-1;for(let y of n)if(y.target===t&&y.from<=b&&y.to>b){g=y.targetFrom+b-y.from;break}if(g<0)return null;let h=d.slice(b,T);if(c(a,h.length*(n.length+2)),f.flat.text.slice(g,g+h.length)!==h)return null;for(let y=b;y<T;y++){if(cn.test(d[y]))continue;let N=!1;for(let x of n)if(x.target===t&&x.from<=y&&x.to>y&&x.targetFrom+y-x.from===g+y-b){N=!0;break}if(!N)return null}if(p.flat.atoms.length||f.flat.atoms.length){c(a,p.flat.atoms.length+f.flat.atoms.length);let y=0,N=f.flat.atoms;for(;y<N.length&&N[y].i<g;)y++;for(let x of p.flat.atoms){if(x.i<b||x.i>=T)continue;let S=N[y++];if(!S||S.i!==g+x.i-b||f.alignment?.reverse.get(S.el)!==x.el)return null}if(y<N.length&&N[y].i<g+T-b)return null}for(let[y,N,x]of[[o,e,b],[r,t,g]]){let S=!1;for(let O of y){let R=i.get(O),M=s.get(O),j=l(R,a);for(let U=0;U<j.length;U++){let K=j[U].from,W=K+h.length;if(c(a,h.length*2+1),R.flat.text.slice(K,W)!==h)continue;let H=U;for(;H<j.length&&j[H].to<W;)c(a,1),H++;if(H===j.length||j[H].to!==W)continue;let k=!0;for(let A=K;A<W;A++)if(!cn.test(R.flat.text[A])&&M[A]){k=!1;break}if(k){if(S||O!==N||K!==x)return null;S=!0}}}if(!S)return null}return h}function Qa(e,t,n,o,r,i,s,l){if(s(l,r.length+i.length+(o.length+1)*n.length*2),!n)return!1;let c=o.indexOf(n);return c<0||o.lastIndexOf(n)!==c||!i.some(a=>a.from===c)||!i.some(a=>a.to===c+n.length)?!1:r.some(a=>a.source===e&&a.target===t&&a.from===0&&a.to===n.length&&a.targetFrom===c)}function xl({base:e,views:t,eligible:n,baseId:o,ignored:r,remoteWins:i,atomKey:s,limit:l=2e4*8}){if(l<=0)return null;let c=Symbol(),a=(x,S)=>{if(S>x.remaining)throw c;x.remaining-=S},p=[new Map,new Map];for(let x=0;x<2;x++)for(let S=0;S<t[x].V.units.length;S++)p[x].set(t[x].V.units[S],S);let f=new Int32Array(e.length),d=new Int32Array(e.length),w=x=>t.every(({V:S},O)=>{let R=S.twin(x);return R&&p[O].has(R)}),b=-1;for(let x=0;x<e.length;x++)f[x]=b,w(e[x])&&(b=x);b=e.length;for(let x=e.length-1;x>=0;x--)d[x]=b,w(e[x])&&(b=x);let T=new Map,g=(x,S)=>{if(a(S,1),T.has(x))return T.get(x);let O=x.firstChild,R=1;for(;O;){if(a(S,R*8+8),O.nodeType===3&&a(S,O.data.length*8),O.nodeType===1&&pn.has(O.tagName)&&!r(O)&&!i(O)&&O.firstChild){O=O.firstChild,R++;continue}for(;O&&O!==x&&!O.nextSibling;)O=O.parentNode,R--;O=!O||O===x?null:O.nextSibling}let M=zt(Array.from(x.childNodes),{ignored:r,remoteWins:i});return T.set(x,M),M},h=(x,S,O,R,M,j)=>{for(let U of x.atoms){a(j,1);let K=S.atomAt.get(U.i+O);if(!K)return!1;let W=R?.reverse.get(U.el)||s(U.el),H=M?.reverse.get(K.el)||s(K.el);if(W!==H)return!1}return!0},y=(x,S,O,R,M)=>{let j=x.text.length<=S.text.length?x:S,U=j===x?S:x;if(a(M,j.text.length+U.text.length),!j.text||!jn.test(j.text.replaceAll(Ln,"")))return!1;let K;if(j.text===U.text)K=0;else{let W=U.text.length-j.text.length;if(a(M,(W+1)*j.text.length*2),U.text.startsWith(j.text))K=0;else if(U.text.endsWith(j.text))K=W;else return!1;if(U.text.indexOf(j.text)!==K||U.text.lastIndexOf(j.text)!==K)return!1;a(M,U.text.length*2);let H=0,k=K===0,A=!1;for(let J of tn(U.text,hn(U.text)))H+=J.len,H===K&&(k=!0),H===K+j.text.length&&(A=!0);if(!k||!A)return!1}return j===x?h(j,U,K,O,R,M):h(j,U,K,R,O,M)},N=null;for(let x=0;x<2;x++){let{V:S,A:O,idOf:R}=t[x],M=t[1-x];if(!S.asBase)for(let j=0;j<e.length;j++){let U=e[j];if(S.twin(U)||!n(U))continue;let K=M.V.twin(U);if(!K||!p[1-x].has(K)||!n(K))continue;let W={remaining:l};try{let H=f[j],k=d[j],A=0;for(let Oe=H+1;Oe<k;Oe++)a(W,1),!S.twin(e[Oe])&&M.V.twin(e[Oe])&&n(e[Oe])&&A++;if(A!==1||g(U,W).text===g(K,W).text)continue;let J=H<0?-1:p[x].get(S.twin(e[H])),_=k===e.length?S.units.length:p[x].get(S.twin(e[k]));if(J===void 0||_===void 0||J>=_)continue;let F=null;for(let Oe=J+1;Oe<_;Oe++){a(W,1);let Ce=S.units[Oe];if(S.baseOf(Ce)||!n(Ce)||Ce.tagName!==U.tagName||Ce.namespaceURI!==U.namespaceURI)continue;let De=o(U),pe=M.idOf(K),Te=R(Ce);if(!(De&&pe&&De!==pe||De&&Te&&De!==Te||pe&&Te&&pe!==Te)&&y(g(K,W),g(Ce,W),M.A,O,W)){if(F){F=null;break}F=Ce}}if(!F)continue;N||(N=[new Map,new Map]),N[x].set(U,F)}catch(H){if(H!==c)throw H}}}return N?t.map(({V:x},S)=>{let O=N[S];if(!O.size)return x;let R=new Map;for(let[M,j]of O)R.set(j,M);return{...x,twin:M=>O.get(M)||x.twin(M),baseOf:M=>R.get(M)||x.baseOf(M)}}):null}function kl({onUncertainSource:e,onUncertainOwner:t,base:n,views:o,eligible:r,ignored:i,remoteWins:s,baseId:l,atomKey:c,limit:a=2e4*32}){if(a<=0)return null;let p=new Set(n),f=new Map(n.map((H,k)=>[H,k])),d=new Map,w=[],b=null,T=null,g=null,h=new Set;for(let H of n)for(let{V:k}of o){let A=k.twin(H);A&&!k.asBase&&!k.here(A)&&h.add(H)}let y=new Set,N=Symbol(),x=(H,k)=>{if(k>H.remaining)throw N;H.remaining-=k},S=(H,k,A)=>{x(A,1);let J=d.get(H);if(J)return J;if(H.nodeType===1){let Oe=H.firstChild,Ce=1;for(;Oe;){if(x(A,Ce*8+8),Oe.nodeType===3&&x(A,Oe.data.length*8),Oe.nodeType===1&&pn.has(Oe.tagName)&&!i(Oe)&&!s(Oe)&&Oe.firstChild){Oe=Oe.firstChild,Ce++;continue}for(;Oe&&Oe!==H&&!Oe.nextSibling;)Oe=Oe.parentNode,Ce--;Oe=!Oe||Oe===H?null:Oe.nextSibling}}else x(A,H.value.length*8+H.nodes.length);let _=H.nodeType===1?Array.from(H.childNodes):H.nodes,F=_.length===1&&_[0].nodeType===3?{text:_[0].data,nodes:[{node:_[0],s:0,e:_[0].data.length}],atoms:[]}:zt(_,{ignored:i,remoteWins:s});return J={unit:H,flat:F,alignment:k,tokens:null},d.set(H,J),J},O=(H,k)=>{if(H.tokens)return H.tokens;x(k,H.flat.text.length*8);let{unit:A,flat:J,alignment:_}=H,F=[],Oe=hn(J.text),Ce=0,De=pe=>{for(let Te of tn(J.text.slice(Ce,pe),Oe))Te.from=Ce,Te.to=Ce+Te.len,Te.unit=A,F.push(Te),Ce+=Te.len};for(let pe of J.atoms){De(pe.i);let Te=s(pe.el)&&pe.el.nodeType===1?"w"+pe.el.tagName+"#"+(pe.el.id||""):c(_?.reverse.get(pe.el)||pe.el);F.push({k:Te,raw:Ln,len:1,from:Ce,to:Ce+1,unit:A,atom:!0}),Ce++}return De(J.text.length),H.tokens=F,F},R=(H,k,A,J,_)=>{if(!H.flat.atoms.length&&!k.flat.atoms.length)return!0;let F=O(H,_),Oe=O(k,_);x(_,F.length+Oe.length);let Ce=0;for(let De of Oe){if(!De.atom||De.from<A||De.from>=A+J)continue;for(;Ce<F.length&&!F[Ce].atom;)Ce++;let pe=F[Ce++];if(!pe||pe.from!==De.from-A||pe.k!==De.k)return!1}for(;Ce<F.length;)if(F[Ce++].atom)return!1;return!0},M=(H,k,A)=>{let J=H.length+k.length+4;if(J*8>A.remaining)return null;A.remaining-=J*8;let _=Math.floor(A.remaining/8),F=Math.min(H.length+k.length,4e3,Math.floor((Math.sqrt(J*J+_)-J)/2)),Oe=4*(F+1)*(J+F+1);if(F<1||Oe>A.remaining)return null;A.remaining-=Oe;let Ce=_n(H,k,F),De=[],pe=0,Te=0;for(let ze of Ce.hunks){for(;pe<ze.bs;)H[pe].raw===k[Te].raw&&De.push([H[pe],k[Te]]),pe++,Te++;pe=ze.be,Te+=ze.toks.length}for(;pe<H.length&&Te<k.length;)H[pe].raw===k[Te].raw&&De.push([H[pe],k[Te]]),pe++,Te++;return De},j=(H,k,A,J,_,F,Oe)=>{if(_<=J)return;let Ce=H[H.length-1];if(Ce&&Ce.source===k&&Ce.target===A&&Ce.to<=J&&Ce.targetFrom-Ce.from===F-J){x(Oe,(J-Ce.to)*3);let De=d.get(k).flat.text,pe=d.get(A).flat.text,Te=!0;for(let ze=Ce.to;ze<J;ze++)if(!cn.test(De[ze])||De[ze]!==pe[F+ze-J]){Te=!1;break}if(Te){Ce.to=_;return}}H.push({source:k,target:A,from:J,to:_,targetFrom:F})},U=H=>H.replace(Ya,"");for(let H=0;H<o.length;H++){let{V:k,A,idOf:J}=o[H];if(k.asBase)continue;let _=new Map(k.units.map((v,G)=>[v,G])),F=v=>{let G=k.twin(v);return G&&_.has(G)?G:null},Oe=(v,G)=>{let ue=new Int32Array(v.length),ae=new Int32Array(v.length),Pe=-1;for(let He=0;He<v.length;He++)ue[He]=Pe,G(v[He])&&(Pe=He);Pe=v.length;for(let He=v.length-1;He>=0;He--)ae[He]=Pe,G(v[He])&&(Pe=He);return{prev:ue,next:ae}},Ce=Oe(n,v=>(v.nodeType===1||v.kind==="text"&&jn.test(v.value))&&F(v)),De=Oe(k.units,v=>(v.nodeType===1||v.kind==="text"&&jn.test(v.value))&&p.has(k.baseOf(v))),pe=new Map,Te=(v,G,ue,ae)=>{if(v>G||ue>ae)return;let Pe=`${v}:${G}:${ue}:${ae}`;pe.set(Pe,[v,G,ue,ae])};for(let v=0;v<k.units.length;v++){let G=k.units[v];if(k.baseOf(G)||!r(G))continue;let ue=De.prev[v],ae=De.next[v],Pe=ue<0?0:f.get(k.baseOf(k.units[ue])),He=ae===k.units.length?n.length-1:f.get(k.baseOf(k.units[ae]));Te(Pe,He,Math.max(0,ue),Math.min(k.units.length-1,ae))}for(let v=0;v<n.length;v++){let G=n[v];if(h.has(G)||!r(G))continue;if(!k.twin(G)){let Ze=Ce.prev[v],Je=Ce.next[v],pt=Ze<0?0:_.get(F(n[Ze])),Ye=Je===n.length?k.units.length-1:_.get(F(n[Je]));Te(Math.max(0,Ze),Math.min(n.length-1,Je),pt,Ye)}let ue=F(G);if(!ue||A.identical.has(G)||!r(ue))continue;let ae=v+1;for(;ae<n.length&&n[ae].kind==="text"&&!n[ae].value.trim();)ae++;if(ae>=n.length||!r(n[ae]))continue;let Pe=F(n[ae]);if(!Pe||A.identical.has(n[ae])||!r(Pe))continue;let He=_.get(ue),ve=_.get(Pe);He<ve&&Te(v,ae,He,ve)}let ze=Array.from(pe.values()),Me=new Set;if(ze.length>1){let v=Wt(a);try{x(v,ze.length*4);let G=ze.slice().sort((Pe,He)=>(x(v,1),Pe[0]-He[0]||Pe[2]-He[2])),ue=[],ae=null;for(let Pe of G)x(v,1),ae&&Pe[0]<=ae[1]&&Pe[2]<=ae[3]&&Pe[3]>=ae[2]?(ae[1]=Math.max(ae[1],Pe[1]),ae[2]=Math.min(ae[2],Pe[2]),ae[3]=Math.max(ae[3],Pe[3]),ae[4].push(Pe)):(ae?.[4].length>1&&ue.push(ae),ae=[Pe[0],Pe[1],Pe[2],Pe[3],[Pe]]);ae?.[4].length>1&&ue.push(ae),ze=ue.concat(ze)}catch(G){if(G!==N)throw G}}for(let v of ze){if(Me.has(v))continue;let[G,ue,ae,Pe,He]=v,ve=Wt(a),Ze=[],Je=new Set,pt=!1;try{x(ve,(ue-G+Pe-ae+2)*4);let Ye=n.slice(G,ue+1).filter(B=>!A.identical.has(B)&&r(B)&&!h.has(B)),dt=k.units.slice(ae,Pe+1).filter(B=>r(B)&&(!k.baseOf(B)||p.has(k.baseOf(B)))&&!A.identical.has(k.baseOf(B))&&!h.has(k.baseOf(B))),St=new Set(dt),vt=!1,bt="",At="",Ot=0;for(let B of Ye){let me=S(B,null,ve);bt+=me.flat.text,Ot+=me.flat.text.length}for(let B of dt){let me=S(B,A,ve);At+=me.flat.text,Ot+=me.flat.text.length}x(ve,Ot);let Bt=U(bt),nn=U(At),Nt=Bt===nn;if(pt=Nt,He&&!Nt)continue;let $t=Nt?null:new Map;if($t)for(let B of Ye.concat(dt)){let me=d.get(B).flat.text.length;x(ve,me*16),$t.set(B,new Uint8Array(me))}let an=B=>{let me=[];for(let xe of B){let fe=d.get(xe);fe.flat.atoms.length?me.push(...O(fe,ve)):me.push({unit:xe,raw:fe.flat.text,from:0})}return me},Pt=[];for(let B of Nt?[]:Ye){let me=F(B);if(!St.has(me))continue;let xe=S(B,null,ve),fe=S(me,A,ve);x(ve,xe.flat.text.length+fe.flat.text.length);let Se=xe.flat.text&&fe.flat.text.startsWith(xe.flat.text)?0:xe.flat.text&&fe.flat.text.endsWith(xe.flat.text)?fe.flat.text.length-xe.flat.text.length:-1;if(Se>=0&&R(xe,fe,Se,xe.flat.text.length,ve)){$t.get(B).fill(1),$t.get(me).fill(1,Se,Se+xe.flat.text.length),j(Pt,B,me,0,xe.flat.text.length,Se,ve);continue}let V=M(O(xe,ve),O(fe,ve),ve);if(!V){vt=!0;break}for(let[Z,be]of V)$t.get(B).fill(1,Z.from,Z.to),$t.get(me).fill(1,be.from,be.to),j(Pt,B,me,Z.from,Z.to,be.from,ve)}if(vt)continue;let Jt=null,Ft=null;if(!Nt)for(let B of Ye){let me=F(B),xe=d.get(B);if(!me||xe.flat.atoms.length||!St.has(me))continue;let fe=xe.flat.text,Se=$t.get(B);x(ve,fe.length*3+dt.length);let V=-1,Z=-1,be=!1;for(let je=0;je<fe.length;je++)cn.test(fe[je])||(Se[je]?be=!0:(V<0&&(V=je),Z=je+1));if(!be||V<0)continue;let ke=!0;for(let je=V;je<Z;je++)if(Se[je]&&!cn.test(fe[je])){ke=!1;break}if(!ke)continue;let we=U(fe.slice(V,Z)),te=null,re=!1;for(let je of dt){if(k.baseOf(je))continue;let Ae=d.get(je);if(!Ae.flat.atoms.length&&(x(ve,Ae.flat.text.length),U(Ae.flat.text)===we)){if(te){re=!0;break}te=je}}if(re){(Ft||=new Set).add(B);continue}if(!te||Ft?.has(B))continue;let q=!1;for(let je of Ye){if(je===B||!St.has(F(je)))continue;let Ae=d.get(je);if(Ae.flat.atoms.length)continue;let Ge=$t.get(je);x(ve,Ae.flat.text.length*3);let et="",Qe=!1;for(let Ut=0;Ut<Ae.flat.text.length;Ut++)cn.test(Ae.flat.text[Ut])||(Ge[Ut]?Qe=!0:et+=Ae.flat.text[Ut]);Qe&&et===we&&(Ft||=new Set,Ft.add(B),Ft.add(je),q=!0)}if(q)continue;let le=d.get(te).flat.text;x(ve,Z-V+le.length);let Ne=V,Le=0;for(;Ne<Z&&Le<le.length;){for(;Ne<Z&&cn.test(fe[Ne]);)Ne++;for(;Le<le.length&&cn.test(le[Le]);)Le++;if(Ne>=Z||Le>=le.length)break;j(Jt||=[],B,te,Ne,Ne+1,Le,ve),Ne++,Le++}Se.fill(1,V,Z),$t.get(te).fill(1)}let on=B=>{let me=[];for(let xe of B){let fe=S(xe,p.has(xe)?null:A,ve),Se=$t.get(xe);for(let V of O(fe,ve)){let Z=V.from;for(;Z<V.to;){for(;Z<V.to&&Se[Z];)Z++;let be=Z;for(;Z<V.to&&!Se[Z];)Z++;if(Z>be){let ke=fe.flat.text.slice(be,Z);jn.test(ke)&&me.push({...V,raw:ke,len:Z-be,k:V.atom?V.k:ke,from:be,to:Z})}}}}return me},Y=Nt?an(Ye):on(Ye),m=Nt?an(dt):on(dt),I=Nt?Bt:Y.map(B=>U(B.raw)).join(""),P=Nt?nn:m.map(B=>U(B.raw)).join("");if((!I||!P)&&!Jt)continue;let $=Jt||[];if(I&&P&&I===P){let B=0,me=0,xe=0,fe=0;for(;B<Y.length&&me<m.length;){let Se=Y[B],V=m[me];for(;xe<Se.raw.length&&cn.test(Se.raw[xe]);)xe++;for(;fe<V.raw.length&&cn.test(V.raw[fe]);)fe++;if(xe===Se.raw.length){B++,xe=0;continue}if(fe===V.raw.length){me++,fe=0;continue}if((Se.atom||V.atom)&&Se.k!==V.k){vt=!0;break}j($,Se.unit,V.unit,Se.from+xe,Se.from+xe+1,V.from+fe,ve),xe++,fe++}}else if(I&&P){let B=M(Y,m,ve);if(!B)continue;for(let[me,xe]of B)j($,me.unit,xe.unit,me.from,me.to,xe.from,ve)}if(vt)continue;let Q=new Map;for(let B of $)if(!Ft?.has(B.source)){if(F(B.source)===B.target){Nt&&Pt.push(B);continue}Q.has(B.source)||Q.set(B.source,[]),Q.get(B.source).push(B)}for(let[B,me]of Q){let xe=S(B,null,ve),fe=F(B),Se=xe.flat.text,V=[],Z=new Set,be=o[1-H],ke=be.V.twin(B),we=ke&&be.V.here(ke)?S(ke,be.A,ve):null,te=(Ae,Ge)=>{let et=O(Ae,ve),Qe=O(Ge,ve);return x(ve,Ae.flat.text.length+Ge.flat.text.length+et.length+Qe.length),Ae.flat.text===Ge.flat.text&&et.length===Qe.length&&et.every((Ut,Mt)=>Ut.k===Qe[Mt].k)},re=fe&&we&&we.flat.text!==Se&&te(S(fe,A,ve),we);for(let Ae of new Set(me.map(Ge=>Ge.target))){if(B.nodeType!==1&&Ae.nodeType!==1)continue;let Ge=S(Ae,A,ve),et=k.baseOf(Ae);if(B.nodeType!==1&&et||(x(ve,Se.length*2+Ge.flat.text.length*3+Pt.length*2),fe&&U(Se)===U(Ge.flat.text)&&S(fe,A,ve).flat.text.trim()))continue;if(!fe&&!et&&B.nodeType===1&&Ae.nodeType===1){let Lt=l(B),_t=J(Ae);if(Lt&&_t&&Lt!==_t)continue}let Qe=Ge.flat.text,Ut=Se&&(Qe.startsWith(Se)||Qe.endsWith(Se)),Mt=!1;if(!fe&&we&&et&&we.flat.text!==Se){let Lt=S(et,null,ve).flat.text,_t=f.get(B)<f.get(et)?we.flat.text:Lt,C=f.get(B)<f.get(et)?Lt:we.flat.text;x(ve,_t.length+C.length+Qe.length),Mt=!!_t&&!!C&&_t.length+C.length<=Qe.length&&Qe.startsWith(_t)&&Qe.endsWith(C)&&!Qe.slice(_t.length,Qe.length-C.length).trim()}let Kt=!xe.flat.atoms.length&&!we?.flat.atoms.length&&!Ge.flat.atoms.length&&(re&&Ut||Mt);if(fe&&et){let Lt=S(fe,A,ve).flat.text,_t=Se.startsWith(Lt)||Se.endsWith(Lt),C=S(et,null,ve).flat.text,X=Ge.flat.text,ce=X.startsWith(C)||X.endsWith(C),de=!o[1-H].V.twin(et)&&!Pt.some(ie=>ie.source===et&&jn.test(C.slice(ie.from,ie.to)));if(!Nt&&(!_t&&!Kt||!ce&&!de)){let ie=Za(B,Ae,me,Ye,dt,d,$t,O,x,ve);if(!ie)continue;let ee=A.weak?.has(B)&&!A.identityPaired?.has(B)&&Se.trim()===ie;if(!_t&&!Kt&&!ee)continue;let se=A.weak?.has(et)&&!A.identityPaired?.has(et)&&Qe.trim()===ie&&!d.get(et).flat.atoms.length&&!Pt.some(Ee=>Ee.source===et&&jn.test(C.slice(Ee.from,Ee.to)));if(!ce&&!de&&!se&&!Qa(et,Ae,C,Qe,Pt,O(Ge,ve),x,ve))continue;ee&&Z.add(Ae)}}Kt&&Z.add(Ae),x(ve,me.length),V.push(...me.filter(Lt=>Lt.target===Ae))}if(!V.length)continue;let q=new Uint8Array(Se.length);x(ve,Se.length*4+Pt.length);for(let Ae of V)q.fill(1,Ae.from,Ae.to);let le=[];for(let Ae=0;Ae<Se.length;Ae++)cn.test(Se[Ae])||le.push(Ae);if(!le.length)continue;let Ne=new Set(V.map(Ae=>Ae.target));if(!Nt&&fe&&Ne.size>1&&Xa(Ne,$,Pt,k,d,ve,x)){if(g||=new Map,g.set(B,(g.get(B)||0)|1<<H),e){let Ae=ks({source:B,side:H,views:o,eligible:r,blocked:h,baseId:l,model:S,tokensOf:O,budget:ve,charge:x});if(Ae){x(ve,Ae.to-Ae.from);let Ge=!0;for(let et=Ae.from;et<Ae.to;et++)if(jn.test(Se[et])&&!q[et]){Ge=!1;break}Ge&&(b||=[]).push(Ae)}}continue}let Le=le.filter(Ae=>Ls.test(Se[Ae]));if(!V.some(Ae=>Ls.test(Se.slice(Ae.from,Ae.to)))&&!le.every(Ae=>q[Ae]))continue;if(!fe&&!Array.from(Ne).some(Ae=>Z.has(Ae))&&!le.every(Ae=>q[Ae])&&!(Le.length&&q[Le[0]]&&q[Le[Le.length-1]]&&Ne.size===1)){let Ae=null,Ge=0,et=0,Qe=null,Ut=null;if(!fe&&we&&B.nodeType===1&&!xe.flat.atoms.length){let Mt=O(xe,ve).filter(Kt=>Ls.test(Kt.raw));x(ve,dt.length+Se.length);for(let Kt of dt){let Lt=k.baseOf(Kt);if(!Lt||Lt===B||Lt.nodeType!==1||Kt.nodeType!==1||Lt.tagName!==B.tagName||Kt.tagName!==Lt.tagName)continue;let _t=f.get(B),C=f.get(Lt),X=!0;for(let Fe=Math.min(_t,C)+1;Fe<Math.max(_t,C);Fe++){let tt=n[Fe];if(x(ve,tt.nodeType===1?1:tt.value.length+1),tt.nodeType===1||tt.value.trim()){X=!1;break}}if(!X)continue;let ce=S(Lt,null,ve),de=S(Kt,A,ve);if(ce.flat.atoms.length||de.flat.atoms.length)continue;let ie=ce.flat.text,ee=de.flat.text;if(x(ve,ie.length+ee.length+Se.length),!ie||!Mt.length)continue;let se=0,Ee=ee.length;if(_t<C&&ee.endsWith(ie))Ee-=ie.length;else if(_t>C&&ee.startsWith(ie))se=ie.length;else continue;for(;se<Ee&&cn.test(ee[se]);)se++;for(;Ee>se&&cn.test(ee[Ee-1]);)Ee--;let _e=ee.slice(se,Ee);if(!(!_e||!(_e.startsWith(Mt[0].raw)||_e.endsWith(Mt[Mt.length-1].raw)))){if(Ae){Ae=null;break}Ae=Kt,Ge=se,et=Ee,Qe=Mt[0],Ut=Mt[Mt.length-1]}}}if(x(ve,V.length),!Ae||!Ne.has(Ae)||!V.some(Mt=>Mt.target===Ae&&(Mt.from<=Qe.from&&Mt.to>=Qe.to&&Mt.targetFrom+Qe.from-Mt.from===Ge||Mt.from<=Ut.from&&Mt.to>=Ut.to&&Mt.targetFrom+Ut.to-Mt.from===et)))continue}if(fe&&!(le.every(Ae=>q[Ae])&&(Nt||Array.from(Ne).some(Ae=>Z.has(Ae))))&&!Pt.some(Ae=>Ae.source===B&&jn.test(Se.slice(Ae.from,Ae.to))))continue;let je=!1;if(Nt){x(ve,Pt.length+le.length);for(let Ae of Pt)Ae.source===B&&(x(ve,Ae.to-Ae.from),q.fill(1,Ae.from,Ae.to));je=!0;for(let Ae of le)if(!q[Ae]){je=!1;break}}for(let Ae of Ne){x(ve,V.length);let Ge=V.filter(Qe=>Qe.target===Ae);Ze.push({side:H,source:B,target:Ae,runs:Ge,models:d,retained:Pt,conservedSource:je}),B.nodeType===1&&Je.add(B),Ae.nodeType===1&&Je.add(Ae);let et=k.baseOf(Ae);et?.nodeType===1&&Je.add(et)}}if(w.push(...Ze),He&&Ze.length)for(let B of He)Me.add(B);for(let B of Je)y.add(B)}catch(Ye){if(Ye!==N)throw Ye}finally{if(t&&!He&&!pt){let Ye=wl({base:n,views:o,side:H,attempt:v,eligible:r,blocked:h,baseId:l,model:S,tokensOf:O,charge:x,exhausted:N,limit:a});Ye&&(T||=[]).push(...Ye)}if(e&&!He&&!pt){let Ye=Pi({base:n,views:o,side:H,attempt:v,eligible:r,blocked:h,baseId:l,model:S,tokensOf:O,certificates:w,charge:x,exhausted:N,limit:a});Ye&&(b||=[]).push(...Ye)}}}}let K=w.length?new Map:null;for(let H of w){let k=K.get(H.source);k||K.set(H.source,k=[]),k.push(H)}let W=null;if(K){let H=null;for(let[k,A]of K){let J=g?.get(k)||0;if(A.length<2&&!J)continue;let _=0;for(let F of A)F.conservedSource&&(_|=1<<F.side);for(let F of A){if(F.conservedSource)continue;let Oe=1<<F.side,Ce=!0;if(_&Oe)Ce=!1;else if(J&Oe){Ce=!1;try{Ce=Ja(F,H||=Wt(a),x)}catch(De){if(De!==N)throw De}}Ce||(W||=new Set).add(F)}}}if(W){let H=0;for(let k of w)W.has(k)||(w[H++]=k);w.length=H;for(let[k,A]of K){H=0;for(let J of A)W.has(J)||(A[H++]=J);A.length=H,H||K.delete(k)}y.clear();for(let k of w){let{source:A,target:J,side:_}=k;A.nodeType===1&&y.add(A),J.nodeType===1&&y.add(J);let F=o[_].V.baseOf(J);F?.nodeType===1&&y.add(F)}}if(b){let H=Wt(a),k=!1;for(let A of b){let J=!1,_=K?.get(A.source);if(_&&!k)try{J=xs(A,_,H,x)}catch(F){if(F!==N)throw F;k=!0}J||e(A)}}if(T){let H=new Set,k=Wt(a);try{for(let A of T){if(x(k,1),H.has(A.source))continue;H.add(A.source);let J=!1;for(let _ of w)if(x(k,1),_.source===A.source||_.target===A.local||_.target===A.remote){J=!0;break}J||t(A)}}catch(A){if(A!==N)throw A}}for(let H of n)if(y.has(H))for(let{V:k}of o){let A=k.twin(H);A&&k.here(A)&&y.add(A)}return w.length?{blocks:y,certificates:w,certificatesBySource:K,models:d}:null}function Al({certificates:e,scopes:t,flats:n,keys:o,limit:r=2e4*32}){let i=Symbol(),s=Wt(r),l=g=>{if(g>s.remaining)throw i;s.remaining-=g},c=t.map(g=>new Set(g)),a=new Map,p=new Map,f=(g,h)=>{let y=a.get(g);if(y||a.set(g,y=new Map),y.has(h))return y.get(h);l(g.text.length);let N=p.get(h);if(!N){l(h.nodes.length+h.atoms.length),N={nodes:new Map,atoms:new Map};for(let R of h.nodes)N.nodes.set(R.node,R);for(let R of h.atoms)N.atoms.set(R.el,R.i);p.set(h,N)}let{nodes:x,atoms:S}=N,O=new Int32Array(g.text.length).fill(-1);for(let R of g.nodes){let M=x.get(R.node);if(!(!M||R.e-R.s!==M.e-M.s)){l(R.e-R.s);for(let j=R.s;j<R.e;j++)O[j]=M.s+j-R.s}}for(let R of g.atoms){let M=S.get(R.el);M!==void 0&&(O[R.i]=M)}return y.set(h,O),O},d=(g,h,y,N,x)=>{let S=g[g.length-1];S&&S.to===h&&S.target+S.to-S.from===N&&S.kind===x?S.to=y:g.push({from:h,to:y,target:N,kind:x})},w=(g,h,y,N)=>{l((N-y)*4);let x=[],S=y,O=j=>{let U=g.text.slice(S,j);for(let K of tn(U,hn(U)))K.from=S,K.to=S+K.len,x.push(K),S+=K.len},R=0,M=g.atoms.length;for(;R<M;){l(1);let j=R+M>>>1;g.atoms[j].i<y?R=j+1:M=j}for(let j=R;j<g.atoms.length&&g.atoms[j].i<N;j++){l(1);let U=g.atoms[j];O(U.i),x.push({k:h(U),raw:Ln,len:1,from:S,to:S+1}),S++}return O(N),x},b=(g,h,y,N,x,S)=>{if(y===N||x===S)return;if(N-y===S-x){l((N-y)*4);let k=!0;for(let A=y,J=x;A<N;A++,J++){if(n[0].text[A]!==n[h].text[J]){k=!1;break}let _=n[0].atomAt.get(A),F=n[h].atomAt.get(J);if(!!_!=!!F||_&&o[0](_)!==o[h](F)){k=!1;break}}if(k){d(g,y,N,x,"retained");return}}let O=w(n[0],o[0],y,N),R=w(n[h],o[h],x,S),M=O.length+R.length+4,j=Math.min(O.length+R.length,4e3,Math.floor((Math.sqrt(M*M+s.remaining/2)-M)/2));if(j<1)throw i;l(4*(j+1)*(M+j+1));let U=_n(O,R,j),K=0,W=0,H=()=>{let k=O[K++],A=R[W++];l(k.len),k.raw===A.raw&&d(g,k.from,k.to,A.from,"retained")};for(let k of U.hunks){for(;K<k.bs;)H();K=k.be,W+=k.toks.length}for(;K<O.length&&W<R.length;)H()},T=g=>{let h=e.filter(U=>U.side===g-1&&c[0].has(U.source)&&c[g].has(U.target));if(!h.length)return null;let y=[],N=(U,K,W)=>{if(!c[0].has(U.source)||!c[g].has(U.target))return;let H=f(K.get(U.source).flat,n[0]),k=f(K.get(U.target).flat,n[g]);l(U.to-U.from);for(let A=0;A<U.to-U.from;A++){let J=H[U.from+A],_=k[U.targetFrom+A];if(J<0||_<0)throw i;d(y,J,J+1,_,W)}},x=new Set;for(let U of h){if(!x.has(U.retained)){x.add(U.retained);for(let K of U.retained)N(K,U.models,"retained")}for(let K of U.runs)N(K,U.models,"transfer")}y.sort((U,K)=>(l(1),U.from-K.from||U.target-K.target));let S=[];for(let U of y){l(1);let K=S[S.length-1];if(K&&U.from<K.to){if(U.target-U.from!==K.target-K.from)throw i;K.to=Math.max(K.to,U.to),U.kind==="transfer"&&(K.kind="transfer")}else S.push(U)}let O=[],R=0,M=0;for(let U of S){if(U.target<M)throw i;b(O,g,R,U.from,M,U.target),O.push(U),R=U.to,M=U.target+U.to-U.from}b(O,g,R,n[0].text.length,M,n[g].text.length);let j=Rn({base:n[0],side:n[g],retained:O.filter(U=>U.kind==="retained"),transfers:O.filter(U=>U.kind==="transfer"),baseAtomKey:o[0],sideAtomKey:o[g],budget:s});if(j.status!=="ready"||!j.monotone)throw i;return j};try{let g=T(1),h=T(2);return g||h?{local:g,remote:h}:{fallback:!0}}catch(g){if(g!==i)throw g;return{fallback:!0}}}function Ps(e,t,n=!1){let o=-1,r=-1;for(let s=0;s<e.list.length;s++){let l=e.list[s];l.bLo<t.lo||l.bLo>t.hi||(o<0&&(o=s),r=s)}let i=[];for(let s=o;s>=0&&s<=r;s++){let l=e.list[s],c=!n&&s===o?l.inlineStart<0?l.to:l.inlineStart:l.from,a=!n&&s===r?l.inlineEnd<0?l.from:l.inlineEnd:l.to;for(let p=c;p<a;p++)i.push(e.units[p]);s<r&&i.push(e.units[l.next])}return i}var ot=e=>!!e&&e.nodeType===1,Hr=e=>ot(e)?e.getAttribute("data-id")||e.textContent||"":e.value!==void 0?e.value:e.nodeValue||"",Nn=new Set("P H1 H2 H3 H4 H5 H6 DIV LI DD DT BLOCKQUOTE FIGCAPTION SUMMARY ADDRESS".split(" "));function js(e){for(let t of e)if(Nn.has(t.tagName))return!0;return!1}function ef(e,t,n){let o=null;for(let r of t.childNodes)if(!(!ot(r)||!n(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 er="[id],[data-id],script,head>*";function Bs(e,t){return n=>{if(e!==null&&n.tagName==="SCRIPT"){let o=Eo(n,e);if(o)return"merge:"+o.key}return n.parentElement&&n.parentElement.tagName==="HEAD"?sl(n,t):null}}function Vr(e,t,n,o){let r=o.ignored,i=o.stats||Gn(),s=Ei({ignored:r,ignoreAttribute:o.ignoreAttribute,stats:i}),{unitsOf:l,meta:c}=s,a=o.baseURI,p=o.mergeTags!==null,f=Bs(o.mergeTags,a),d=C=>X=>{let ce=f(X);return ce!==null?ce:C(X)},w=d(o.identity.base),b=d(o.identity.local),T=d(o.identity.remote),g=o.authored||o.identity,h=C=>C&&C.nodeType===9?C.documentElement:C,y=h(e),N=h(t),x=h(n),S=globalThis.__hyperMorphProfile,O=S?performance.now():0,R=C=>C===dn?er:null,M=o.scope||null,j=M?M.baseDropped:new Set,U=new Set,K=M?M.remoteDropped:new Set,W=M?M.baseIndex:Or(y,w,r,R(o.identity.base),j),H=o.localIsBase||y===N?null:Or(N,b,r,R(o.identity.local),U),k=M?M.remoteIndex:Or(x,T,r,R(o.identity.remote),K),A=C=>{let X=ot(C)&&b(C);return X&&H?.get(X)===C&&!W.has(X)?X:null},J=C=>{let X=ot(C)&&T(C);return X&&k.get(X)===C&&!W.has(X)?X:null},_=H?us(y,N,{analyzer:s,baseIndex:W,sideIndex:H,baseId:g.base,sideId:g.local,baseKey:w,sideKey:b,baseDropped:j,sideDropped:U,stats:i}):Nl(),F=us(y,x,{analyzer:s,baseIndex:W,sideIndex:k,baseId:g.base,sideId:g.remote,baseKey:w,sideKey:T,baseDropped:j,sideDropped:K,stats:i,scope:M,comparisons:o.comparisons});if(M){if(!M.held(F))return null;for(let C of M.dropped)as(C)}let Oe=null;function Ce(C){if(!Oe){Oe=new WeakMap;let X=[y];for(;X.length;){let ce=X.pop();ce.tagName==="TEMPLATE"&&ce.content&&Oe.set(ce.content,ce);for(let de of s.childrenOf(ce))de.nodeType===1&&X.push(de)}}return Oe.get(C)||null}let De=C=>{let X=ot(C)||C.nodeType?C.parentNode:C.parent;return X&&X.nodeType===11?Ce(X):X};if(F.moved.size){let C=!1;for(let X of Array.from(F.moved))!ot(X)||F.identityPaired.has(X)||!g.base(X)||m(F,De(X))||(F.unpair(X),C=!0);C&&F.rematch()}on(),Y(_,F),Y(F,_);for(let C of[_,F])if(C.refused)for(let X of C.refused)C.moved.has(X)||i.ambiguousMoves++;S&&(S.alignTotal=(S.alignTotal||0)+(performance.now()-O),O=performance.now());let pe=y.ownerDocument.implementation.createHTMLDocument(""),Te=new WeakMap,ze=new WeakMap,Me=[],v=[],G=new Set,ue=[],ae=new Set,Pe=new Set,He=new Set,ve=new WeakMap,Ze=null,Je=o.lineage?.locals.length?zi():null,pt=C=>{let X=Rr(C);return X&&Je&&Je.consume(C.local),X},Ye=o.conflicts||"remote",dt=C=>Me.push(C),St=C=>Me.push(C),vt=hl({roots:{base:y,local:N,remote:x},L:_,R:F,unitsOf:l,provenance:Te,policy:Ye}),bt=(C,X)=>{v.push(C),X&&vt.note(C,X)},At=null,Ot=null,Bt=Jt(),nn=null,Nt=B(y,_.map.get(y),F.map.get(y),!!o.localIsBase,!!o.childrenOnly);Nt.tagName==="HTML"?pe.replaceChild(Nt,pe.documentElement):pe.body.appendChild(Nt),At?.drain(Nt),Ot?.drain(Nt),S&&(S.build=(S.build||0)+(performance.now()-O));let $t=o.childrenOnly?!et(Ae(Nt),Ae(x)):!Ne(Nt,x),an=vt.finish(Nt),Pt=Je?Gi({locals:o.lineage.locals,rec:Je,root:Nt,provenance:Te,segments:ue,ignored:r}):null;return{doc:pe,root:Nt,provenance:Te,textMappers:ze,decisions:Me,conflicts:v,recoveryLinks:an,localDiverged:$t,mergedScripts:G,segments:ue,remoteIdOf:o.identity.remote,customIdentity:o.identity.remote!==dn,L:_,R:F,stats:i,lineage:Pt};function Jt(){let C=new Map,X=new Set;if(o.localIsBase||!_.insertedByHash)return{partner:C,drop:X};let ce=_.insertedByHash(),de=F.insertedByHash();if(!ce.size||!de.size)return{partner:C,drop:X};let ie={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},ee=$e=>{let mt=0;for(let Tt=$e.parentNode;Tt;Tt=Tt.parentNode)mt++;return mt},se=[],Ee=$e=>{let mt=$e.textContent.trim();return mt.split(/\s+/).length>=3||mt.replace(/\s/g,"").length>=12},_e=$e=>{let mt=m(_,$e),Tt=m(F,$e);return mt&&_.reverse.get(mt.parentNode)!==$e.parentNode||Tt&&F.reverse.get(Tt.parentNode)!==$e.parentNode},Fe=($e,mt,Tt)=>{for(let It of Tt.parentNode.children){let kn=It!==Tt&&$e.reverse.get(It);if(kn&&_e(kn))return!0}let Dt=$e.reverse.get(Tt.parentNode);if(Dt){for(let It of Dt.children)if(!m(mt,It)&&!r(It))return!0}return!1},tt=new Map([[_,new Map],[F,new Map]]),st=($e,mt)=>{let Tt=tt.get($e),Dt=Tt.get(mt);if(Dt===void 0){Dt=!1;for(let It of mt.children)if($e.reverse.has(It)||st($e,It)){Dt=!0;break}Tt.set(mt,Dt)}return Dt},it=new Map;for(let $e of de.values())for(let mt of $e){let Tt=J(mt);Tt&&it.set(Tt,mt)}for(let $e of ce.values())for(let mt of $e){let Tt=A(mt),Dt=Tt?it.get(Tt):null;Dt&&Dt.tagName===mt.tagName&&!Pn(mt,ie)&&!Pn(Dt,ie)&&!o.remoteWins(mt)&&!o.remoteWins(Dt)&&se.push([mt,[Dt],ee(mt),!0,!0])}for(let[$e,mt]of ce){let Tt=de.get($e);if(!Tt)continue;let Dt=mt.length===1&&Tt.length===1;for(let It of mt)!Pn(It,ie)&&!A(It)&&se.push([It,Tt,ee(It),Dt&&(Ee(It)||Fe(_,F,It)||Fe(F,_,Tt[0]))])}if(!se.length)return{partner:C,drop:X};se.sort(($e,mt)=>$e[2]-mt[2]);let rt=new Set,kt=new Set,xt=$e=>{for(let mt of $e.querySelectorAll("*"))rt.add(mt)},Et=($e,mt)=>$e.reverse.get(mt.parentNode)||null;for(let[$e,mt,,Tt,Dt]of se){if(rt.has($e)||kt.has($e)||Dt&&(st(_,$e)||st(F,mt[0])))continue;let It=Et(_,$e),kn=fn=>!kt.has(fn)&&!rt.has(fn)&&(Dt||fn.tagName===$e.tagName&&!J(fn)&&s.equalUnits($e,fn)),Zt=mt.find(fn=>It&&Et(F,fn)===It&&kn(fn))||(Tt?mt.find(kn):null);if(!Zt)continue;kt.add($e),kt.add(Zt);let Fn=It&&Et(F,Zt)===It;(!Dt||!Fn||s.equalUnits($e,Zt))&&(xt($e),xt(Zt)),!Fn&&(C.set($e,Zt),C.set(Zt,$e),X.add(Ye==="local"?Zt:$e))}return{partner:C,drop:X}}function Ft(C,X,ce){if(ae.add(C),Bt.drop.has(C))return null;ae.add(ce);let de=X==="local"?C:ce,ie=X==="local"?ce:C,ee;return s.equalUnits(de,ie)?(ee=q(de,"local",!0),Te.get(ee).remote=ie):ee=re(de,ie),bt({kind:"structure",el:ee,detail:"both-moved",base:null,local:de,remote:ie},{unit:{b:null,l:de,r:ie}}),dt({kind:"insert",el:ee,source:"both"}),ee}function on(){if(!_.weak||!F.weak||!_.weak.size||!F.weak.size||!_.unpair)return;let C=new Map;for(let ce of _.weak){let de=m(_,ce);ot(ce)&&ot(de)&&C.set(s.unitHash(de),ce)}let X=!1;for(let ce of Array.from(F.weak)){let de=m(F,ce);if(!ot(ce)||!ot(de))continue;let ie=C.get(s.unitHash(de));if(!ie||ie===ce||!_.weak.has(ie)||m(_,ce)&&m(F,ie))continue;let ee=m(_,ie);ee.tagName===de.tagName&&s.equalUnits(ee,de)&&(_.unpair(ie),F.unpair(ce),X=!0)}X&&(_.rematch(),F.rematch())}function Y(C,X){if(!C.weak||!C.weak.size||!X.insertedByHash)return;let ce=X.insertedByHash();if(!ce.size)return;let de=!1;for(let ie of Array.from(C.weak)){let ee=m(C,ie);if(!ee)continue;let se=C===_?A(ee):J(ee);if(se){let _e=(C===_?k:H)?.get(se);_e&&_e.tagName===ee.tagName&&!X.reverse.has(_e)&&(C.unpair(ie),de=!0);continue}let Ee=ce.get(s.unitHash(ee));Ee&&Ee.some(_e=>_e.tagName===ee.tagName&&s.equalUnits(_e,ee))&&(C.unpair(ie),de=!0)}de&&C.rematch()}function m(C,X){if(!X)return null;if(C.map.has(X))return C.map.get(X);let ce=[],de=De(X);for(;de&&!C.map.has(de);de=De(de))ce.push(de);let ie=de;if(!ie||!C.identical.has(ie))return null;C.pairIdenticalChildren(ie);for(let se=ce.length-1;se>=0;se--)C.pairIdenticalChildren(ce[se]);let ee=C.map.get(X)||null;return ee&&i.lazyTwins++,ee}function I(C,X,ce,de){if(ot(C)&&Nn.has(C.tagName)&&!_.identical.has(C)&&(C.previousSibling?.nodeType===3||C.nextSibling?.nodeType===3)){let Ee=De(C),_e=m(_,C),Fe=m(F,C);_e&&Fe&&Lt(_e,m(_,Ee),_)&&!Lt(Fe,m(F,Ee),F)&&(Ot||=gl({L:_,R:F,twinIn:m,unitsOf:l,view:P,parentOf:De,ignored:r,remoteWins:o.remoteWins,eligible:tt=>ot(tt)&&Nn.has(tt.tagName),build:B,out:pe,policy:Ye,provenance:Te,textMappers:ze,segments:ue,conflicts:v,conflict:bt,decisions:Me}),Ot.ensureOwner(C))}if(X===null)return null;if(de!==void 0)return At||=Ro(Te,De,_,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(C,X,ce,!!de),de&&(At.produced(C,de),Pe.add(C)),de;if(Pe.has(C)||He.has(C))return bt({kind:"structure",el:null,detail:"both-moved",base:C},{subject:C}),Pe.has(C)?null:q(ce,X);At||=Ro(Te,De,_,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(C,X,ce,!0);let ie=m(_,C),ee=m(F,C);(!ie||!ee)&&bt({kind:"structure",el:null,detail:"move-beats-delete",base:C},{subject:C,deleted:ie?"remote":"local"});let se=B(C,ie,ee,!1);return(X==="local"?dt:St)({kind:"move",el:se,source:X}),se}function P(C,X,ce,de){return de||!X||X===ce?{el:ce,asBase:!0,twin:ie=>ie,baseOf:ie=>ie,units:l(ce),here:()=>!0,parentOfTwin:()=>ce}:{el:X,asBase:!1,twin:ie=>m(C,ie),baseOf:ie=>C.reverse.get(ie),units:l(X),here:ie=>ot(ie)?ie.parentNode===X||X.tagName==="TEMPLATE"&&ie.parentNode===X.content:ie.parent===X||X.tagName==="TEMPLATE"&&ie.parent===X.content}}function $(C,X,ce){return!X||ce&&ce.identical.has(C)?!1:ot(C)?!s.equalUnits(C,X)||!Q(C,X,ce):C.value!==X.value}function Q(C,X,ce){if(!ce||C===X)return!0;let de=[[C,X]];for(;de.length;){let[ie,ee]=de.pop(),se=l(ie),Ee=l(ee);for(let _e=0;_e<se.length&&_e<Ee.length;_e++){let Fe=se[_e],tt=Ee[_e];if(!ot(Fe)||!ot(tt))continue;let st=ce.map.get(Fe);if(st!==void 0&&st!==tt)return!1;let it=ce.reverse.get(tt);if(it!==void 0&&it!==Fe)return!1;de.push([Fe,tt])}}return!0}function B(C,X,ce,de,ie=!1){let ee=de||(ce?o.remoteWins(ce):o.remoteWins(C)),se=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?pe.createElementNS(C.namespaceURI,C.tagName):pe.createElement(C.tagName),Ee={base:C,local:X||null,remote:ce||null};if(Te.set(se,Ee),ee&&!de&&X&&$(C,X,_)&&(!ce||!s.equalUnits(X,ce))&&bt({kind:"structure",el:se,detail:"remote-wins",base:C,local:X,remote:ce||null},{subject:C}),ae.add(C),Pe.add(C),X&&ae.add(X),ce&&ae.add(ce),o.skipUnchanged&&!ie&&(o.localIsBase||_.identical.has(C))&&ce&&F.identical.has(C)&&!o.remoteWins(C)){Ee.unchanged=!0;for(let Fe of C.attributes)Fe.namespaceURI?se.setAttributeNS(Fe.namespaceURI,Fe.name,Fe.value):se.setAttribute(Fe.name,Fe.value);return At?.produced(C,se),se}He.add(C),ie||Se(C,ee?C:X,ce,se);let _e=C.tagName;if(sn(C))fe(C,ee?C:X,ce,se);else if(_e==="TEXTAREA"){let Fe=ee?C:X,tt=C.textContent,st=Fe?Fe.textContent:tt,it=ce?ce.textContent:tt,rt=me(C);if(rt&&st!==tt&&it!==tt){let kt=ke(rt,me(Fe),me(ce),ee);kt&&se.appendChild(kt)}else se.textContent=xe(tt,st,it,se,"text")}else if(!Ot?.render(C,se)){let Fe=le(C,X,ce,ee,se),tt=_e==="TEMPLATE"&&se.content?se.content:se;for(let st of Fe)tt.appendChild(st)}return He.delete(C),At?.produced(C,se),se}function me(C){if(!C)return null;let X=l(C)[0];return X&&!ot(X)&&X.kind==="text"?X:null}function xe(C,X,ce,de,ie){if(X===ce)return X;if(X===C)return ce!==C&&St({kind:ie,node:de,source:"remote"}),ce;if(ce===C)return dt({kind:ie,node:de,source:"local"}),X;let ee=Ye==="local"?X:ce;return bt({kind:ie,node:de,base:C,local:X,remote:ce,resolved:ee},{site:"whole",el:de}),Me.push({kind:ie,node:de,source:"both"}),ee}function fe(C,X,ce,de){let ie=C.textContent,ee=X?X.textContent:ie,se=ce?ce.textContent:ie,Ee=p?Eo(C,o.mergeTags,!0):null;if(Ee&&ee!==se){let _e=ce&&ce.getAttribute("merge-key")||C.getAttribute("merge-key"),{text:Fe,warnings:tt,conflicts:st}=Cs(o.localIsBase?void 0:ie,ee,se,{parse:Ee.recognizer.parse,keyCandidates:_e?_e.split(/[\s,]+/).filter(Boolean):void 0});for(let it of tt)console.warn(`[hyper-morph] merge "${Ee.raw}": ${it}`);for(let it of o.localIsBase?[]:st)bt({kind:"json",node:de,name:Ee.raw,path:it.path,base:it.base,local:it.local,remote:it.remote,resolved:it.resolved});de.textContent=Fe,G.add(de),Fe!==se?dt({kind:"text",node:de,source:Fe===ee?"local":"both"}):Fe!==ie&&St({kind:"text",node:de,source:"remote"});return}de.textContent=xe(ie,ee,se,de,"text")}function Se(C,X,ce,de){let ie=new Map;for(let ee of[C,X,ce])if(ee)for(let se of ee.attributes)o.ignoreAttribute(ee,se.name)||ie.set(se.name,se);for(let[ee,se]of ie){let Ee=C?C.getAttribute(ee):null,_e=X?X.getAttribute(ee):Ee,Fe=ce?ce.getAttribute(ee):Ee,tt;_e===Fe?tt=_e:_e===Ee?(tt=Fe,St({kind:"attr",el:de,name:ee,source:"remote"})):Fe===Ee?(tt=_e,dt({kind:"attr",el:de,name:ee,source:"local"})):(tt=be(ee,Ee,_e,Fe)??V(ee,[C,X,ce],Ee,_e,Fe),tt===void 0&&(tt=Ye==="local"?_e:Fe,bt({kind:"attr",el:de,name:ee,base:Ee,local:_e,remote:Fe,resolved:tt},{el:de,sample:se})),Me.push({kind:"attr",el:de,name:ee,source:"both"})),tt!=null&&(se.namespaceURI?de.setAttributeNS(se.namespaceURI,se.name,tt):de.setAttribute(ee,tt))}}function V(C,X,ce,de,ie){let ee=o.attributeMerge;if(typeof ee!="function")return;let se=X.filter(Boolean).map(Ee=>ee(Ee,C));if(!(!se.length||se.some(Ee=>Ee!==se[0]))){if(se[0]==="tokens")return Z(ce,de,ie);if(se[0]==="max"){let Ee=Number(de),_e=Number(ie);return Number.isFinite(Ee)&&Number.isFinite(_e)&&de!==""&&ie!==""?String(Math.max(Ee,_e)):void 0}}}function Z(C,X,ce){let de=it=>[...new Set((it||"").split(/\s+/).filter(Boolean))],ie=de(C),ee=new Set(ie),se=new Set(de(X)),Ee=new Set(de(ce)),_e=it=>se.has(it)===Ee.has(it)?se.has(it):se.has(it)===ee.has(it)?Ee.has(it):se.has(it),Fe=ie.filter(_e),tt=[...new Set([...se,...Ee])].filter(it=>!ee.has(it)&&_e(it)).sort(),st=[...Fe,...tt];return st.length?st.join(" "):null}function be(C,X,ce,de){if(C==="class"){let ie=Fe=>new Set((Fe||"").split(/\s+/).filter(Boolean)),ee=ie(X),se=ie(ce),Ee=ie(de),_e=new Set;for(let Fe of new Set([...ee,...se,...Ee])){let tt=ee.has(Fe),st=se.has(Fe),it=Ee.has(Fe);(st===it?st:st===tt?it:st)&&_e.add(Fe)}return[..._e].join(" ")}if(C==="style"){let ie=tt=>{let st=new Map;if(!tt)return st;let it=0,rt=null,kt="",xt=()=>{let Et=kt.indexOf(":");Et>0&&st.set(kt.slice(0,Et).trim(),kt.slice(Et+1).trim()),kt=""};for(let Et of tt){if(rt){kt+=Et,Et===rt&&(rt=null);continue}if(Et==='"'||Et==="'"){rt=Et,kt+=Et;continue}if(Et==="("?it++:Et===")"&&it--,Et===";"&&it===0){xt();continue}kt+=Et}return kt.trim()&&xt(),st},ee=ie(X),se=ie(ce),Ee=ie(de),_e=new Map,Fe=!1;for(let tt of new Set([...ee.keys(),...se.keys(),...Ee.keys()])){let st=ee.get(tt)??null,it=se.get(tt)??null,rt=Ee.get(tt)??null,kt;it===rt?kt=it:it===st?kt=rt:rt===st?kt=it:(kt=Ye==="local"?it:rt,Fe=!0),kt!=null&&_e.set(tt,kt)}return Fe?void 0:[..._e].map(([tt,st])=>`${tt}: ${st}`).join("; ")}}function ke(C,X,ce,de){let ie=C.value,ee=de?ie:X?X.value:"",se=ce?ce.value:"";ae.add(C),X&&ae.add(X),ce&&ae.add(ce);let Ee=Go(ie,ee,se,Ye),_e=Ee.text===""?null:pe.createTextNode(Ee.text);_e&&(Te.set(_e,{base:C.nodes,local:X?X.nodes:null,remote:ce?ce.nodes:null}),ze.set(_e,Ee.mapLocalOffset)),ee!==ie&&se!==ie?Me.push({kind:"text",node:_e,source:"both"}):ee!==ie?dt({kind:"text",node:_e,source:"local"}):se!==ie&&St({kind:"text",node:_e,source:"remote"});for(let Fe of Ee.conflicts)bt({kind:"text",node:_e,base:ie.slice(Fe.bs,Fe.be),local:Fe.local,remote:Fe.remote,resolved:Fe.resolved},{site:"run",bRun:C,lRun:X,rRun:ce,node:_e,c:Fe});return _e}function we(C,X){return lo(C,X).every(ce=>ce.bs===ce.be)}function te(C,X){let ce=C?C.value:"",de=X?X.value:"",ie;if(ce===de||!de?ie=ce:ce?we(ce,de)?ie=de:we(de,ce)?ie=ce:(ie=Ye==="local"?ce:Ye==="both"?ce+de:de,bt({kind:"structure",el:null,detail:"insert-collision",local:ce,remote:de,resolved:ie},{unit:{b:null,l:C,r:X},localLost:Ye==="remote"})):ie=de,C&&ae.add(C),X&&ae.add(X),ie==="")return null;let ee=pe.createTextNode(ie);return Te.set(ee,{base:null,local:C?C.nodes:null,remote:X?X.nodes:null}),ce?dt({kind:"insert",el:ee,source:de&&ce===de?"both":"local"}):St({kind:"insert",el:ee,source:"remote"}),ee}function re(C,X){let ce={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},de=Ee=>l(Ee).every(_e=>ot(_e)?Pn(_e,ce):_e.kind==="text"),ie=null;if(de(C)&&de(X)){let Ee=C.textContent,_e=X.textContent;Ee===_e||we(_e,Ee)?ie=X:we(Ee,_e)&&(ie=C)}if(!ie){let Ee=Ye==="local",_e=q(Ee?C:X,Ee?"local":"remote",!0),Fe=Te.get(_e);return Ee?Fe.remote=X:Fe.local=C,bt({kind:"structure",el:_e,detail:"insert-collision",local:C,remote:X,resolved:Ee?C:X},{unit:{b:null,l:C,r:X},localLost:!Ee}),_e}let ee=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?pe.createElementNS(C.namespaceURI,C.tagName):pe.createElement(C.tagName);Se(null,C,X,ee),Te.set(ee,{base:null,local:C,remote:X}),ae.add(C),ae.add(X);let se=pt({base:Array.from(ie.childNodes),local:Array.from(C.childNodes),remote:Array.from(X.childNodes),out:pe,policy:Ye,idOf:{local:b,remote:T},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,provenance:Te,textMappers:ze,conflicts:v,conflict:bt,scope:{base:null,local:C,remote:X,units:[],at:0},synthetic:!0,decisions:Me,node:ee});ue.push(...se.segments);for(let Ee of se.nodes)ee.appendChild(Ee);return ee}function q(C,X,ce=!1){if(!ce&&ot(C)){let se=Bt.partner.get(C);if(se)return Ft(C,X,se)}if(!ot(C)){if(C.value==="")return null;let se=C.kind==="comment"?pe.createComment(C.value):pe.createTextNode(C.value);return Te.set(se,{base:null,local:X==="local"?C.nodes:null,remote:X==="remote"?C.nodes:null}),ae.add(C),se}let de=C.namespaceURI&&C.namespaceURI!=="http://www.w3.org/1999/xhtml"?pe.createElementNS(C.namespaceURI,C.tagName):pe.createElement(C.tagName);for(let se of C.attributes)se.namespaceURI?de.setAttributeNS(se.namespaceURI,se.name,se.value):de.setAttribute(se.name,se.value);Te.set(de,{base:null,local:X==="local"?C:null,remote:X==="remote"?C:null}),ae.add(C);let ie=C.tagName==="TEMPLATE"&&de.content?de.content:de,ee=X==="local"?_:F;for(let se of l(C)){let Ee=ot(se)?ee.reverse.get(se):null;if(Ee&&I(Ee,null,null),Ee&&Pe.has(Ee)){bt({kind:"structure",el:null,detail:"both-moved",base:Ee},{subject:Ee});continue}if(Ee&&!He.has(Ee)){let Fe=m(_,Ee)||null,tt=m(F,Ee)||null;if(Fe||tt){At||=Ro(Te,De,_,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(Ee,X,se,!0);let st=B(Ee,Fe,tt,!1);X==="local"?dt({kind:"move",el:st,source:"local"}):St({kind:"move",el:st,source:"remote"}),ie.appendChild(st);continue}}let _e=q(se,X);_e&&ie.appendChild(_e)}if(!ce&&Bt.drop.size&&C.tagName==="DIV"&&!ie.firstChild&&!C.attributes.length&&!(X==="local"?b(C):T(C))&&!ee.reverse.has(C)&&!r(C)&&!o.remoteWins(C)){let se=C.firstChild;if(se&&se===C.lastChild&&ot(se)&&(Bt.drop.has(se)||nn?.has(se)))return(nn||=new WeakSet).add(C),null}return de}function le(C,X,ce,de,ie){X&&_.identical.has(C)&&_.pairIdenticalChildren(C),ce&&F.identical.has(C)&&F.pairIdenticalChildren(C);let ee=P(_,X,C,de),se=P(F,ce,C,!1),Ee=l(C),_e=new Set(Ee),Fe=new Map;for(let ne=0;ne<Ee.length;ne++)Fe.set(Ee[ne],ne);let tt=ne=>!ot(ne)&&ne.kind==="text"&&!/[^\t\n\f\r ]/.test(ne.value),st=[],it=new Set,rt=new Map,kt=new Set,xt=Je&&[],Et=Je&&[],$e=new Set,mt=[],Tt=null,Dt=new Map;if(!ee.asBase&&!se.asBase&&!_.identical.has(C)&&!F.identical.has(C))for(let ne of Ee){if(!ot(ne)||!Nn.has(ne.tagName))continue;let Be=ee.twin(ne),Ue=se.twin(ne);Be&&Ue&&(!ee.here(Be)||!se.here(Ue))&&I(ne,null,null)}let It=(ne,Be=!1)=>{let Ue=[];for(let qe of ne.units){if($e.has(qe)||!Be&&tt(qe))continue;let ht=ne.baseOf(qe);ht&&_e.has(ht)&&Ue.push(ht)}return Ue},kn=ne=>It(ne).map(Be=>Fe.get(Be)),Zt=ne=>ne.every((Be,Ue)=>Ue===0||Be>=ne[Ue-1]),Fn=()=>{let ne=!ee.asBase&&!Zt(kn(ee)),Be=!se.asBase&&!Zt(kn(se)),Ue=null;if(ne&&Be){let qe=It(ee),ht=It(se);if(Ue=nf(Ee.filter(We=>!$e.has(We)&&!tt(We)),Fe,qe,ht),Ue){let We=Ds(qe.map(lt=>Fe.get(lt))),Ve=Ds(ht.map(lt=>Fe.get(lt)));for(let lt of We)Ve.has(lt)&&(Ue=null)}}return{lRe:ne,rRe:Be,settled:Ue}},fn=Fn();xr(fn.lRe&&fn.rRe);let{lRe:to,rRe:An,settled:bo}=Fn(),_o=to&&An;_o&&!bo&&bt({kind:"structure",el:ie,detail:"both-reordered",base:C},{subject:C,lKept:It(ee,!0),rKept:It(se,!0)});let Gt=An||!to?{V:se,A:F,side:"remote",other:ee,otherA:_,otherSide:"local"}:{V:ee,A:_,side:"local",other:se,otherA:F,otherSide:"remote"},Hn=null,Wo=null;if(_o){Hn=wo(Gt.V.units),Wo=Gt.V.units,bo&&(Gt.V=of(Gt.V,bo));for(let ne of Ee)tt(ne)&&ae.add(ne);for(let ne of[ee,se])for(let Be of ne.units)tt(Be)&&ae.add(Be)}to?dt({kind:"move",el:null,source:An?"both":"local",base:C}):An&&St({kind:"move",el:null,source:"remote",base:C});let yo=ee.asBase?[]:ee.units.filter(ne=>!ee.baseOf(ne)&&!$e.has(ne)&&!Bt.partner.has(ne)),no=se.asBase?[]:se.units.filter(ne=>!se.baseOf(ne)&&!$e.has(ne)&&!Bt.partner.has(ne)),On=new Map;if(yo.length&&no.length){let ne=new Map,Be=new Map;for(let We of no){if(ot(We)){let lt=T(We);lt&&ne.set(lt,We)}let Ve=s.unitHash(We);Be.has(Ve)||Be.set(Ve,[]),Be.get(Ve).push(We)}let Ue=(We,Ve)=>{let lt=We.units.indexOf(Ve);for(let Ke=lt-1;Ke>=0;Ke--){let ct=We.baseOf(We.units[Ke]);if(ct)return ct}return"start"},qe=new Map,ht=new Map;for(let We of no){let Ve=Ue(se,We);ot(We)?(ht.has(Ve)||ht.set(Ve,[]),ht.get(Ve).push(We)):We.kind==="text"&&!qe.has(Ve)&&qe.set(Ve,We)}for(let We of yo){let Ve=null;if(ot(We)){let Ke=b(We);Ke&&ne.has(Ke)&&!On.has(ne.get(Ke))&&(Ve=ne.get(Ke))}else if(We.kind==="text"){let Ke=qe.get(Ue(ee,We));Ke&&!On.has(Ke)&&(Ve=Ke)}let lt=!!A(We);if(!Ve&&!lt){let Ke=Be.get(s.unitHash(We));Ke&&(Ve=Ke.find(ct=>!On.has(ct)&&ot(ct)===ot(We)&&(ot(ct)?ct.tagName===We.tagName&&!J(ct):ct.kind===We.kind)&&s.equalUnits(We,ct))||null)}if(!Ve&&ot(We)&&!lt){let Ke=g.local(We),ct=(ht.get(Ue(ee,We))||[]).filter(ft=>{let yt=g.remote(ft);return!On.has(ft)&&ft.tagName===We.tagName&&!J(ft)&&!(Ke&&yt&&Ke!==yt)&&s.similar(We,ft)});ct.length===1&&(Ve=ct[0])}Ve&&(On.set(Ve,We),On.set(We,Ve))}}let br=ne=>{if(Ot?.consumes(ne))return null;if(ae.has(ne)||At?.has(ne))return rt.get(ne)||null;let Be=ee.twin(ne),Ue=se.twin(ne),qe=Be&&!ee.asBase&&!ee.here(Be),ht=Ue&&!se.asBase&&!se.here(Ue);if(qe||ht){if((!Be||!Ue)&&bt({kind:"structure",el:null,detail:"move-beats-delete",base:ne},{subject:ne,deleted:Be?"remote":"local"}),!Kt(ne))return ot(ne)?(At||=Ro(Te,De,_,F,m,B,r,o.remoteWins,v,bt,$,N,x),qe&&At.plan(ne,"local",Be),ht&&At.plan(ne,"remote",Ue)):ae.add(ne),null;bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne})}if(Be&&!Ue&&!ee.asBase&&!se.asBase&&ot(ne)&&Nn.has(ne.tagName)&&!o.remoteWins(ne)&&!o.remoteWins(Be)&&$(ne,Be,_)&&ef(ne,Ae(se.el),r)){let ct={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},ft=yt=>ot(yt)?Pn(yt,ct):yt.kind==="text";if(l(ne).every(ft)&&l(Be).every(ft)){let yt=pt({base:[ne],local:[Be],remote:[],blocks:new Set([ne,Be]),out:pe,policy:Ye,L:_,R:F,idOf:{base:w,local:b,remote:T},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Ct,En,Kn)=>B(Ct,En,Kn,!1),cloneUnit:q,mergeAttrs:Se,atomKey:s.exactUnitKey,moveIn:I,moveBuilt:I,movePlanned:I,provenance:Te,textMappers:ze,conflicts:v,conflict:bt,scope:{base:C,local:ee.el,remote:se.el,units:Ee,at:Fe.get(ne)},decisions:Me,node:ie});ue.push(...yt.segments),ae.add(ne),ae.add(Be);let gt=pe.createDocumentFragment();for(let Ct of yt.nodes)gt.appendChild(Ct);return rt.set(ne,gt),rt.set(Be,gt),gt}}if(!Be&&!Ue)return ae.add(ne),St({kind:"remove",source:"both",base:ne}),null;if(!Be&&!$(ne,Ue,F))return ae.add(ne),dt({kind:"remove",source:"local",base:ne}),null;if(!Ue&&!$(ne,Be,_))return ae.add(ne),St({kind:"remove",source:"remote",base:ne}),Je&&(Je.remove(Be),xt.push({bk:ne,lk:Be})),null;let We=!Be||!Ue,Ve=ee.asBase?m(_,ne)||null:Be,lt=se.asBase&&ot(ne)&&(F.identityPaired.has(ne)||!g.base(ne))&&m(F,ne)||Ue,Ke;return ot(ne)?Ke=B(ne,Ve,lt,ee.asBase):ne.kind==="comment"?Ke=Ut(ne,Ve,Ue,ee.asBase):Ke=ke(ne,Ve,Ue,ee.asBase),ae.add(ne),Ke&&(rt.set(ne,Ke),Be&&rt.set(Be,Ke),Ue&&rt.set(Ue,Ke),We&&(bt({kind:"structure",el:Ke,detail:"edit-beats-delete",base:ne},{subject:ne,deleted:Be?"remote":"local"}),Be?dt({kind:"insert",el:Ke,source:"local"}):St({kind:"insert",el:Ke,source:"remote"}))),Ke},yr=(ne,Be,Ue,qe)=>{if(Ot?.consumes(ne))return null;if(ae.has(ne))return rt.get(ne)||null;let ht=Be.baseOf(ne);if(ht&&_e.has(ht))return $e.has(ht)&&!$e.has(ne)?wr(ht,ne,qe):br(ht);if(ht)return Vn(ht,ne,qe);let We=On.get(ne);if(We){let lt=qe==="local"?ne:We,Ke=qe==="local"?We:ne,ct;return ot(lt)?s.equalUnits(lt,Ke)?(ct=q(lt,"local"),ct&&(Te.get(ct).remote=Ke)):ct=re(lt,Ke):ct=te(lt,Ke),ae.add(lt),ae.add(Ke),ct&&(rt.set(lt,ct),rt.set(Ke,ct),ot(lt)&&dt({kind:"insert",el:ct,source:"both"})),ct}let Ve=q(ne,qe);return Ve&&(rt.set(ne,Ve),qe==="local"?dt({kind:"insert",el:Ve,source:"local"}):(St({kind:"insert",el:Ve,source:"remote"}),Je&&ot(ne)&&!Bt.partner.has(ne)&&Et.push({su:ne,node:Ve}))),Ve},wr=(ne,Be,Ue)=>{let qe;return ot(ne)?(qe=I(ne,Ue,Be),qe&&ae.add(Be)):(qe=q(Be,Ue),ae.add(Be),qe&&(Ue==="local"?dt:St)({kind:"insert",el:qe,source:Ue})),qe&&rt.set(Be,qe),qe},Vn=(ne,Be,Ue)=>{I(ne,null,null);let ht=m(Ue==="local"?F:_,ne),We=Be,Ve=ht?Lt(ht,Ue==="local"?ce:X,Ue==="local"?F:_):!1,lt=ht&&!Ve&&!_t(ne,ht);if(lt&&Ue===Gt.otherSide)return bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne}),null;if(lt&&bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne}),ht||bt({kind:"structure",el:null,detail:"move-beats-delete",base:ne},{subject:ne,deleted:Ue==="local"?"remote":"local"}),He.has(ne)){bt({kind:"structure",el:null,detail:"both-moved",base:ne},{subject:ne});let ct=q(We,Ue);return ct&&rt.set(Be,ct),ct}ot(ne)&&(At||=Ro(Te,De,_,F,m,B,r,o.remoteWins,v,bt,$,N,x),At.plan(ne,Ue,We,!0));let Ke=ot(ne)?B(ne,Ue==="local"?We:m(_,ne)||null,Ue==="remote"?We:m(F,ne)||null,!1):null;return Ke&&(rt.set(ne,Ke),rt.set(Be,Ke),ht&&rt.set(ht,Ke),Ue==="local"?dt({kind:"move",el:Ke,source:"local"}):St({kind:"move",el:Ke,source:"remote"})),Ke};for(let ne of Gt.V.units){if($e.has(ne)){if(Tt?.has(ne)){for(let qe of Tt.get(ne))it.has(qe)||(st.push(qe),it.add(qe));continue}let Ue=rt.get(ne);it.has(Ue)||(st.push(Ue),it.add(Ue));continue}if(ae.has(ne)&&!(rt.get(ne)&&it.has(rt.get(ne)))){let Ue=Gt.V.baseOf(ne);Ue&&!_e.has(Ue)&&bt({kind:"structure",el:null,detail:"both-moved",base:Ue},{subject:Ue});continue}let Be=yr(ne,Gt.V,Gt.A,Gt.side);Be&&!it.has(Be)&&(st.push(Be),it.add(Be),!Gt.V.baseOf(ne)&&!On.has(ne)&&!$e.has(ne)&&kt.add(Be))}for(let ne of mt)it.has(ne.frag)||(st.splice(ne.previous&&it.has(ne.previous)?st.indexOf(ne.previous)+1:qo(ne.at),0,ne.frag),it.add(ne.frag));if(!Gt.other.asBase){let ne=Gt.other,Be=Gt.otherSide,Ue=Gt.otherA,qe=null,ht=0,We=null;for(let Ve of ne.units){let lt=Dt.get(Ve)||rt.get(Ve);if(lt&&it.has(lt)){qe=lt,We=null;continue}if(ae.has(Ve)){let gt=ne.baseOf(Ve);gt&&!_e.has(gt)&&bt({kind:"structure",el:null,detail:"both-moved",base:gt},{subject:gt});continue}let Ke=yr(Ve,ne,Ue,Be);if(!Ke)continue;let ct=!ne.baseOf(Ve)&&!$e.has(Ve),ft=!qe&&!We,yt=We?st.indexOf(We)+1:qe?st.indexOf(qe)+1:ht;if(ct&&ot(Ke)){let gt=Hr(Ke);for(;yt<st.length&&kt.has(st[yt])&&ot(st[yt])&&Hr(st[yt])<gt;)yt++}else if(qe&&!We&&Be==="remote")for(;yt<st.length&&kt.has(st[yt]);)yt++;st.splice(yt,0,Ke),it.add(Ke),ct&&kt.add(Ke),ft&&(ht=yt+1),We=Ke}}for(let ne=0;ne<Ee.length;ne++){let Be=Ee[ne];if(ae.has(Be))continue;let Ue=br(Be);Ue&&st.splice(qo(ne),0,Ue)}return Je&&xt.length&&Et.length&&qn(),_o?Mn(st):st;function qn(){if(to||An)return;let ne=new Set(st),Be=ft=>ft&&_e.has(ft)&&ne.has(rt.get(ft))?ft:null,Ue=(ft,yt)=>{let gt=[{prev:null,units:[]}];for(let Ct of ft){let En=Be(yt(Ct));En?gt.push({prev:En,units:[]}):gt[gt.length-1].units.push(Ct)}return gt},qe=Ue(Ee,ft=>ft),ht=Ue(se.units,se.baseOf),We=ee.asBase?null:Ue(ee.units,ee.baseOf),Ve=ft=>ft.length===qe.length&&ft.every((yt,gt)=>yt.prev===qe[gt].prev);if(!Ve(ht)||We&&!Ve(We))return;let lt=new Map(xt.map(ft=>[ft.bk,ft])),Ke=new Map(Et.map(ft=>[ft.su,ft])),ct=ft=>ft?st.indexOf(rt.get(ft)):-1;for(let ft=0;ft<qe.length;ft++){if(qe[ft].units.length!==1||ht[ft].units.length!==1)continue;let yt=lt.get(qe[ft].units[0]),gt=Ke.get(ht[ft].units[0]);if(!yt||!gt||We&&(We[ft].units.length!==1||We[ft].units[0]!==yt.lk))continue;let Ct=ct(qe[ft].prev);(ft+1<qe.length?ct(qe[ft+1].prev):st.length)-Ct!==2||st[Ct+1]!==gt.node||$o(yt.bk,yt.lk,gt.su)&&Je.link(yt.lk,gt.node)}}function oo(ne,Be,Ue,qe){let ht=gt=>{let Ct=gt.filter(ot);return Ct.length===1?Ct[0]:null},We=ht(ne),Ve=ht(Be),lt=ht(Ue);if(!We||!Ve||!lt)return;let Ke=ne.indexOf(We);if(Be.indexOf(Ve)!==Ke||Ue.indexOf(lt)!==Ke||ne.length!==Be.length||ne.length!==Ue.length)return;for(let gt=0;gt<ne.length;gt++)if(gt!==Ke&&(ne[gt].value!==Be[gt].value||ne[gt].value!==Ue[gt].value))return;if((ee.asBase?We:ee.twin(We))!==Ve||se.twin(We)||F.reverse.get(lt)||Ve!==We&&$(We,Ve,_))return;let ct=qe.filter(gt=>gt.nodeType===1);if(ct.length!==1||Te.get(ct[0])?.remote!==lt)return;let ft=gt=>gt.map(Ct=>ot(Ct)?"":Ct.value??Ct.nodeValue).join(""),yt=qe.indexOf(ct[0]);ft(qe.slice(0,yt))!==ft(ne.slice(0,Ke))||ft(qe.slice(yt+1))!==ft(ne.slice(Ke+1))||$o(We,Ve,lt)&&Je.link(Ve,ct[0])}function $o(ne,Be,Ue){if(!ot(Be)||!ot(Ue)||!ot(ne)||Be.namespaceURI!==Ue.namespaceURI||Be.localName===Ue.localName)return!1;for(let Ve of[Be,Ue])if(Ve.tagName==="TEMPLATE"||sn(Ve)||Ve.querySelector("template"))return!1;if(o.remoteWins(ne)||o.remoteWins(Ue)||r(Ue)||Be.attributes.length!==Ue.attributes.length)return!1;for(let Ve of Be.attributes)if(Ue.getAttributeNS(Ve.namespaceURI,Ve.localName)!==Ve.value)return!1;let qe=Be.childNodes,ht=Ue.childNodes;if(qe.length!==ht.length)return!1;for(let Ve=0;Ve<qe.length;Ve++)if(!qe[Ve].isEqualNode(ht[Ve]))return!1;let We=[[ne,Ue]];for(;We.length;){let[Ve,lt]=We.pop();if(Ve.children.length!==lt.children.length)return!1;for(let Ke=0;Ke<lt.children.length;Ke++){let ct=F.reverse.get(lt.children[Ke]);if(ct!==void 0&&ct!==Ve.children[Ke])return!1;We.push([Ve.children[Ke],lt.children[Ke]])}}return!0}function wo(ne){let Be=[[]];for(let Ue of ne)tt(Ue)?Be[Be.length-1].push(Ue):Be.push([]);return Be}function Mn(ne){let Be=wo(Ee),Ue=(Ke,ct)=>{let ft=new Map,yt=Ke.filter(gt=>!tt(gt));for(let gt=0;gt<yt.length;gt++)ft.set(yt[gt],ct[gt+1]);return ft},qe=Ue(Ee,Be),ht=Ue(Wo,Hn),We=new Map;for(let[Ke,ct]of rt){if(!ct||We.has(ct))continue;let ft=qe.get(Ke),yt=ht.get(Ke);(ft||yt)&&We.set(ct,[ft,yt])}let Ve=[],lt=Fo(Be[0],Hn[0]);lt&&Ve.push(lt);for(let Ke of ne){Ve.push(Ke);let ct=We.get(Ke),ft=ct?Fo(ct[0],ct[1]):null;ft&&Ve.push(ft)}return Ve}function Fo(ne,Be){let Ue=!!ne&&ne.length>0,qe=Ue?ne:Be||[],ht=qe.map(lt=>lt.value).join("");if(ht==="")return null;let We=pe.createTextNode(ht),Ve=lt=>{let Ke=[];for(let ct of lt||[])ct&&Ke.push(...ct.nodes);return Ke.length?Ke:null};return Te.set(We,Ue?{base:Ve(ne),local:Ve(ne.map(lt=>ee.asBase?null:ee.twin(lt))),remote:Ve(ne.map(lt=>se.asBase?null:se.twin(lt)))}:{base:null,local:Gt.side==="local"?Ve(qe):null,remote:Gt.side==="remote"?Ve(qe):null}),We}function qo(ne){for(let Be=ne-1;Be>=0;Be--){let Ue=rt.get(Ee[Be]);if(Ue){let qe=st.indexOf(Ue);if(qe>=0)return qe+1}}return 0}function xr(ne){if((ee.asBase||_.identical.has(C))&&(se.asBase||F.identical.has(C)))return;let Be={ignored:r,remoteWins:o.remoteWins,inlineCache:ve},Ue=ut=>ot(ut)?Pn(ut,Be):ut.kind==="text";if(!ee.asBase&&!se.asBase)for(let ut of Ee){if(!ot(ut)||!Nn.has(ut.tagName))continue;let u=ee.twin(ut),E=se.twin(ut);if(!u&&E||u&&!E){let L=xl({base:Ee,views:[{V:ee,A:_,idOf:g.local},{V:se,A:F,idOf:g.remote}],eligible:D=>ot(D)&&Nn.has(D.tagName)&&!r(D)&&!o.remoteWins(D),baseId:g.base,ignored:r,remoteWins:o.remoteWins,atomKey:s.exactUnitKey});L&&(ee=L[0],se=L[1]);break}}let qe=!ee.asBase&&!se.asBase&&Ee.length>=2&&Nn.has(Ee[0].tagName)&&ee.units.length===Ee.length&&se.units.length===Ee.length?tl({base:Ee,local:ee.units,remote:se.units,localTwin:ee.twin,remoteTwin:se.twin,eligible:ut=>ot(ut)&&Nn.has(ut.tagName)&&!r(ut)&&!o.remoteWins(ut),nodes:{base:Array.from(Ae(C).childNodes),local:Array.from(Ae(ee.el).childNodes),remote:Array.from(Ae(se.el).childNodes)}}):null,ht=null,We=null;if(!qe&&!ee.asBase&&!se.asBase&&(js(Ee)||js(ee.units)||js(se.units))){let ut={ignored:r,remoteWins:()=>!1},u=L=>Ue(L)||ot(L)&&o.remoteWins(L)&&pn.has(L.tagName)&&Pn(L,ut),E=L=>ot(L)?Nn.has(L.tagName)&&!r(L)&&!o.remoteWins(L)&&l(L).every(u):L.kind==="text";ht=kl({onUncertainOwner:L=>{let D=o.identity.local(L.local);D&&D===o.identity.remote(L.remote)||(We||=[]).push(L)},onUncertainSource:L=>{Ze||(Ze=new Map);let D=Ze.get(L.source);D||Ze.set(L.source,D=[]);for(let z of D)if(z.side===L.side&&z.from===L.from&&z.to===L.to)return;D.push(L)},base:Ee,views:[{V:ee,A:_,idOf:g.local},{V:se,A:F,idOf:g.remote}],eligible:E,ignored:r,remoteWins:o.remoteWins,baseId:g.base,atomKey:s.exactUnitKey})}if(We){Tt||=new Map;for(let ut of We){let{source:u,local:E,remote:L}=ut,D={map:new Map,reverse:new Map,identical:new Set},z=pt({base:[u],local:[E],remote:[L],out:pe,policy:"both",L:D,R:D,ignored:r,remoteWins:o.remoteWins,atomKey:s.exactUnitKey,cloneUnit:q,provenance:Te,textMappers:ze,conflicts:v,decisions:Me,conflict:(oe,ge)=>bt(oe,{...ge,policy:"both"}),scope:{base:C,local:ee.el,remote:se.el,units:Ee,at:Fe.get(u)},node:ie});ue.push(...z.segments);for(let oe of[u,E,L])ae.add(oe),$e.add(oe),Tt.set(oe,z.nodes),rt.set(oe,z.nodes[z.nodes.length-1]);for(let oe=0;oe<z.nodes.length;oe++)mt.push({frag:z.nodes[oe],at:Fe.get(u),previous:oe?z.nodes[oe-1]:null})}}let Ve=qe?qe.blocks:null;if(ht){Ve=new Set;for(let ut of ht.blocks)Ve.add(ut)}let lt=ut=>!Ot?.consumes(ut)&&(Ve&&Ve.has(ut)||Ue(ut)),Ke=Ee.map(lt);if(!Ke.includes(!0))return;let ct=ut=>{let u=ut.units,E=new Map;for(let ye=0;ye<u.length;ye++)E.set(u[ye],ye);let L=[],D=-1;for(let ye=0;ye<Ee.length;ye++){if(Ke[ye])continue;let Re=ut.twin(Ee[ye]),he=Re?E.get(Re):void 0;he===void 0||he<=D||lt(Re)||(L.push([ye,he]),D=he)}let z=[],oe=-1,ge=-1;for(let ye=0;ye<=L.length;ye++){let[Re,he]=ye<L.length?L[ye]:[Ee.length,u.length],Ie={bLo:-1,bHi:-1,from:ge+1,to:he,inlineStart:-1,inlineEnd:-1,next:he};for(let Xe=oe+1;Xe<Re;Xe++)Ke[Xe]&&(Ie.bLo<0&&(Ie.bLo=Xe),Ie.bHi=Xe);for(let Xe=ge+1;Xe<he;Xe++){let nt=u[Xe];lt(nt)&&(Ie.inlineStart<0&&(Ie.inlineStart=Xe),Ie.inlineEnd=Xe+1)}z.push(Ie),oe=Re,ge=he}return{units:u,list:z}},ft=ct(ee),yt=ct(se),gt=[];for(let ut of[ft,yt])for(let u of ut.list)u.bLo>=0&&gt.push([u.bLo,u.bHi]);gt.sort((ut,u)=>ut[0]-u[0]);let Ct=[];for(let[ut,u]of gt){let E=Ct[Ct.length-1];E&&ut<=E.hi?E.hi=Math.max(E.hi,u):Ct.push({lo:ut,hi:u})}let En=(ut,u)=>ut.length===u.length&&ut.every((E,L)=>s.equalUnits(E,u[L])),Kn=ut=>!ot(ut)&&ut.kind==="comment",xo=ut=>{if(!ut.length)return[];let u=(oe,ge)=>ot(oe)?oe:oe.nodes[ge?oe.nodes.length-1:0],E=u(ut[0]),L=u(ut[ut.length-1],!0),D=oe=>oe&&ot(oe)&&r(oe);for(;D(E.previousSibling);)E=E.previousSibling;for(;D(L.nextSibling);)L=L.nextSibling;let z=[];for(let oe=E;oe&&(z.push(oe),oe!==L);oe=oe.nextSibling);return z},Gr=ut=>ut.some(u=>ot(u)&&r(u));for(let ut of Ct){let u=Ee.slice(ut.lo,ut.hi+1);if(ne&&!u.some(Re=>lt(Re)&&!tt(Re)))continue;let E=null;if(ht)for(let Re of u){let he=ht.certificatesBySource.get(Re);he&&(E||=[]).push(...he)}let L=ee.asBase?null:Ps(ft,ut),D=se.asBase?null:Ps(yt,ut);if(E){let Re=[new Set(L||u),new Set(D||u)],he=E.some(Ie=>!Re[Ie.side].has(Ie.target));for(let Ie of u)if(Ve.has(Ie))for(let[Xe,nt]of[[0,ee],[1,se]]){let at=nt.twin(Ie);at&&nt.here(at)&&!Re[Xe].has(at)&&(he=!0)}if(he)continue}if(u.some(Kn)||L&&L.some(Kn)||D&&D.some(Kn))continue;let z=xo(L||u),oe=xo(D||u);if((!L||En(u,L))&&(!D||En(u,D))&&!(L&&Gr(z)))continue;let ge=pt({base:xo(u),sourceRetentions:Ze?.get(C),local:z,remote:oe,out:pe,policy:Ye,blocks:Ve,scopeUnits:E?[u,L||u,D||u]:null,certifiedOrigins:E?(Re,he,Ie,Xe,nt,at)=>Al({certificates:E,scopes:[u,L||u,D||u],flats:[Re,he,Ie],keys:[Xe,nt,at]}):null,prepared:qe?qe.prepared:null,nativeTransfers:qe,L:L?_:Tl(_,C),R:D?F:Tl(F,C),idOf:{base:w,local:b,remote:T},ignored:r,ignoreAttribute:o.ignoreAttribute,remoteWins:o.remoteWins,mergeElement:(Re,he,Ie)=>B(Re,he,Ie,!1),cloneUnit:q,mergeAttrs:Se,atomKey:s.exactUnitKey,moveIn:I,moveBuilt:I,movePlanned:I,provenance:Te,textMappers:ze,conflicts:v,conflict:bt,scope:{base:C,local:ee.asBase?null:ee.el,remote:se.asBase?null:se.el,units:Ee,at:ut.lo},decisions:Me,node:ie});if(!ge){if(E){let Re=nl({certificates:E,scopes:[u,L||u,D||u],views:[{V:ee,A:_,idOf:g.local},{V:se,A:F,idOf:g.remote}],eligible:he=>ot(he)&&Nn.has(he.tagName)&&!r(he)&&!o.remoteWins(he),baseId:g.base});for(let he of Re.records){Ze||=new Map;let Ie=Ze.get(he.source);Ie||Ze.set(he.source,Ie=[]),Ie.push(he)}}continue}if(ue.push(...ge.segments),qe){let Re=new Map;for(let he of ge.nodes){let Ie=Te.get(he)?.base;if(!Ie||Re.has(Ie))throw new Error("Invalid native transfer owner output");Re.set(Ie,he)}if(Re.size!==qe.owners.length)throw new Error("Incomplete native transfer owner output");for(let he of qe.owners){let Ie=Re.get(he.base);if(!Ie)throw new Error("Missing native transfer owner output");for(let Xe of[he.base,he.local,he.remote])ae.add(Xe),$e.add(Xe),rt.set(Xe,Ie);mt.push({frag:Ie,at:Fe.get(he.base)})}continue}if(Je&&oo(u,L||u,D||u,ge.nodes),ge.unitOutputs){Tt||=new Map;for(let he of[...u,...L||[],...D||[]]){let Ie=ge.unitOutputs.get(he)||[];ae.add(he),$e.add(he),Tt.set(he,Ie),Ie.length&&rt.set(he,Ie[Ie.length-1])}let Re=ge.nodes[ge.nodes.length-1];if(Re)for(let he of[L||u,D||u]){let Ie=he[he.length-1];Ie&&Dt.set(Ie,Re)}for(let he=0;he<ge.nodes.length;he++)mt.push({frag:ge.nodes[he],at:ut.lo,previous:he>0?ge.nodes[he-1]:null});continue}Je&&oo(u,L||u,D||u,ge.nodes);let ye=pe.createDocumentFragment();for(let Re of ge.nodes)ye.appendChild(Re);for(let Re of[...u,...L||[],...D||[]])ae.add(Re),$e.add(Re),rt.set(Re,ye);mt.push({frag:ye,at:ut.lo})}}}function Ne(C,X){let ce=Te.get(C);return ce&&ce.unchanged?!ce.remote||ce.remote===X?!0:Le(ce.remote,X):C.tagName!==X.tagName||!Ge(C,X)?!1:et(Ae(C),Ae(X))}function Le(C,X){return C===X?!0:C.tagName!==X.tagName||C.namespaceURI!==X.namespaceURI||!Ge(C,X)?!1:je(Ae(C),Ae(X))}function je(C,X){let ce=Qe(C,r),de=Qe(X,r);if(ce.length!==de.length)return!1;for(let ie=0;ie<ce.length;ie++){let ee=ce[ie],se=de[ie];if(typeof ee=="string"||typeof se=="string"){if(ee!==se)return!1}else{if(ee.nodeType!==se.nodeType)return!1;if(ee.nodeType===1){if(!Le(ee,se))return!1}else if(ee.nodeValue!==se.nodeValue)return!1}}return!0}function Ae(C){return C.tagName==="TEMPLATE"&&C.content?C.content:C}function Ge(C,X){let ce=0;for(let de of C.attributes)if(!o.ignoreAttribute(C,de.name)&&(ce++,X.getAttribute(de.name)!==de.value))return!1;for(let de of X.attributes)o.ignoreAttribute(X,de.name)||ce--;return ce===0}function et(C,X){let ce=Qe(C,ie=>{let ee=Te.get(ie);return!!(ee&&ee.pinned)}),de=Qe(X,r);if(ce.length!==de.length)return!1;for(let ie=0;ie<ce.length;ie++){let ee=ce[ie],se=de[ie];if(typeof ee=="string"||typeof se=="string"){if(ee!==se)return!1}else{if(ee.nodeType!==se.nodeType)return!1;if(ee.nodeType===1){if(!Ne(ee,se))return!1}else if(ee.nodeValue!==se.nodeValue)return!1}}return!0}function Qe(C,X){let ce=[],de=null;for(let ie=C.firstChild;ie;ie=ie.nextSibling){if(ie.nodeType===3){de=de===null?ie.nodeValue:de+ie.nodeValue;continue}ie.nodeType===1&&X(ie)||(de!==null&&(de!==""&&ce.push(de),de=null),ce.push(ie))}return de!==null&&de!==""&&ce.push(de),ce}function Ut(C,X,ce,de){let ie=C.value,ee=de?ie:X?X.value:"",se=ce?ce.value:"";ae.add(C),X&&ae.add(X),ce&&ae.add(ce);let Ee=ee===se?ee:ee===ie?se:se===ie||Ye==="local"?ee:se,_e={site:"comment",bRun:C,lRun:X,rRun:ce,node:null};if(ee!==ie&&se!==ie&&ee!==se&&bt({kind:"text",node:null,base:ie,local:ee,remote:se,resolved:Ee},_e),!X&&!ce)return null;let Fe=pe.createComment(Ee);return _e.node=Fe,Te.set(Fe,{base:C.nodes,local:X?X.nodes:null,remote:ce?ce.nodes:null}),Fe}function Mt(C,X){let ce=m(X,C);if(!ce)return null;let de=ot(ce)?ce.parentNode:ce.parent,ie=ot(C)?C.parentNode:C.parent;return m(X,ie)===de?null:X.reverse.get(de)||null}function Kt(C){let X=new Set([C]),ce=C;for(let de=0;de<64;de++){let ie=Mt(ce,_)||Mt(ce,F);if(!ie)return!1;if(ie===C||ot(C)&&ot(ie)&&C.contains(ie)||X.has(ie))return!0;X.add(ie),ce=ie}return!0}function Lt(C,X,ce){if(!X)return!1;let de=ot(C)?C.parentNode:C.parent;return de===X||X.tagName==="TEMPLATE"&&de===X.content}function _t(C,X){let ce=De(C),de=m(_,ce);if(de&&Lt(X,de,_))return!0;let ie=m(F,ce);return!!(ie&&Lt(X,ie,F))}}function Tl(e,t){return e.map.get(t)?Nl():{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 Nl(){let e={get:t=>t,has:()=>!0};return{map:e,reverse:e,moved:new Set,identical:{has:()=>!0},pairIdenticalChildren:()=>{}}}function tf(e){let t=[],n=[],o=new Array(e.length).fill(-1);for(let i=0;i<e.length;i++){let s=0,l=t.length;for(;s<l;){let c=s+l>>1;t[c]<e[i]?s=c+1:l=c}t[s]=e[i],n[s]=i,o[i]=s>0?n[s-1]:-1}let r=new Set;for(let i=n[t.length-1];i!==void 0&&i>=0;i=o[i])r.add(i);return r}function Sl(e){let t=[],n=new Array(e.length);for(let o=0;o<e.length;o++){let r=0,i=t.length;for(;r<i;){let s=r+i>>1;t[s]<e[o]?r=s+1:i=s}t[r]=e[o],n[o]=r+1}return n}function Ds(e){let t=Sl(e),n=Sl(e.map(s=>-s).reverse()).reverse(),o=0;for(let s=0;s<t.length;s++)t[s]>o&&(o=t[s]);let r=new Map;for(let s=0;s<e.length;s++)t[s]+n[s]-1===o&&r.set(t[s],(r.get(t[s])||0)+1);let i=new Set;for(let s=0;s<e.length;s++)(!(t[s]+n[s]-1===o)||r.get(t[s])>1)&&i.add(e[s]);return i}function nf(e,t,n,o){let r=g=>{let h=tf(g.map(y=>t.get(y)));return new Set(g.filter((y,N)=>!h.has(N)))},i=r(n),s=r(o);for(let g of i)if(s.has(g))return null;let l=new Set(n),c=new Set(o),a=e.filter(g=>l.has(g)&&c.has(g)&&!i.has(g)&&!s.has(g)),p=new Set(a),f=(g,h)=>{let y=new Map,N=null;for(let x of g){if(p.has(x)){N=x;continue}h.has(x)&&(y.has(N)||y.set(N,[]),y.get(N).push(x))}return y},d=(g,h)=>Ds(g.map(y=>t.get(y))).size>h.size,w=[{at:f(o,s),ambiguous:d(o,s)},{at:f(n,i),ambiguous:d(n,i)}],b=g=>w.map(h=>{let y=h.at.get(g);return y?{group:y,ambiguous:h.ambiguous}:null}).filter(Boolean).sort((h,y)=>h.ambiguous-y.ambiguous||t.get(h.group[0])-t.get(y.group[0])).flatMap(h=>h.group),T=b(null);for(let g of a)T.push(g,...b(g));return new Map(T.map((g,h)=>[g,h]))}function of(e,t){let n=[],o=new Map,r=null;for(let l of e.units){let c=e.baseOf(l);if(c&&t.has(c)){r=l,o.set(l,[]);continue}(r?o.get(r):n).push(l)}let i=[...o.keys()].sort((l,c)=>t.get(e.baseOf(l))-t.get(e.baseOf(c))),s=l=>{let c=[],a=[],p=()=>{a.length&&c.push(...a.sort((f,d)=>Hr(f)<Hr(d)?-1:1)),a=[]};for(let f of l){if(e.baseOf(f)){p(),c.push(f);continue}a.push(f)}return p(),c};return{...e,units:[...s(n),...i.flatMap(l=>[l,...s(o.get(l))])]}}var vl=new Set(["INPUT","OPTION","TEXTAREA"]),Us=/[\t\n\f\r ]+/;function Ol(e,t,n,o){let r=e.ownerDocument,{provenance:i,textMappers:s}=n,l=o.hooks,c=[],a=[],p=[],f=new Set,d=[],w=[],b=new Map,T=new Set,g=new Map,h=n.conflicts.length>0||o.trackInserted===!0,y=new Map,N=new Set,x=new Map,S=(m,I)=>{let P=x.get(m);P||x.set(m,P=new Set),P.add(I)},O=h?new Set:null,R=(m,I,P)=>{let $=l.beforeAttributeUpdated(m,I,P);return h&&$===!1&&S(I,m),$},M=m=>!!m&&(m===e||e.contains(m)||e.nodeType===1&&e.tagName==="TEMPLATE"&&e.content.contains(m)),j=new Map,U=new Map,K=new Map,W=new Set,H=new Map;(function m(I){let P=i.get(I);if(P){if(I.nodeType===1){let Q=P.local?o.toLive(P.local):null;Q&&M(Q)&&Q.nodeType===1&&(j.set(I,Q),U.set(Q,I))}else if(Array.isArray(P.local)){let Q=F(P.local,P.local.map(B=>o.toLive(B)).filter(B=>B&&M(B)&&B.nodeType===I.nodeType));if(Q.length&&(j.set(I,Q[0]),U.set(Q[0],I),K.set(I,Q)),Array.isArray(P.caret))for(let B of P.caret){let me=o.toLive(B.node);if(!me||!M(me)||me.nodeType!==3)continue;let xe=H.get(me);Array.isArray(xe)||H.set(me,xe=[]),xe.push({merged:I,from:B.from,to:B.to,flatStart:B.flatStart})}else{let B=0;for(let me of Q)H.set(me,{merged:I,shift:B}),B+=me.nodeValue.length}}}let $=I.nodeType===1&&I.tagName==="TEMPLATE"&&I.content?I.content.childNodes:I.childNodes;for(let Q of $)m(Q)})(t);let k=new Set;for(let m of j.values())k.add(m);for(let m of K.values())for(let I of m)k.add(I);let A=o.localRoot&&o.localRoot!==e?new Set:null;if(A){for(let m=o.localRoot.firstElementChild;m;m=m.nextElementSibling)if(m.tagName==="HEAD")for(let I=m.firstElementChild;I;I=I.nextElementSibling){let P=o.toLive(I);P&&A.add(P)}}for(let m of n.segments||[])Oe(m);let J=o.restoreFocus===!1?null:rf(r,H);o.childrenOnly?Te(Ce(e),Ce(t)):De(e,t);for(let{node:m,parent:I}of d)f.has(m)||!m.parentNode||m.nodeType===1&&(o.ignored(m)||ze(m))||Ze(m,I);return sf(r,J,H,s,K,g,W),{applied:c,moved:a,replaced:p,identities:w,mergedScriptsLive:T,liveOf:j,heldBy:g,runOf:K,keptRuns:W,insertedLive:y,vetoed:N,vetoedAttrs:x,removedVetoes:O};function _(m,I){let P=m.slice(I.bs,I.be),$=0;for(;$<P.length&&$<I.text.length&&P[$]===I.text[$];)$++;let Q=0;for(;Q<P.length-$&&Q<I.text.length-$&&P[P.length-1-Q]===I.text[I.text.length-1-Q];)Q++;return{bs:I.bs+$,be:I.be-Q,text:I.text.slice($,I.text.length-Q)}}function F(m,I){if(!I.length)return I;let P=[];for(let B of m){let me=B.parentNode;if(!me)continue;let xe=b.get(me);if(!xe){xe=new Set;for(let fe=me.firstChild;fe;fe=fe.nextSibling)fe.nodeType===3&&xe.add(o.toLive(fe));b.set(me,xe)}P.includes(xe)||P.push(xe)}let $={has:B=>P.some(me=>me.has(B))},Q=[];for(let B of I){Q.push(B);for(let me=B.nextSibling;me&&me.nodeType===3&&!$.has(me)&&!Q.includes(me);me=me.nextSibling)Q.push(me)}return Q}function Oe(m){let I=[];for(let te of m.localNodes){let re=o.toLive(te.node);if(!re||!M(re)||re.nodeType!==3)return;I.push(re)}let P=F(m.localNodes.map(te=>te.node),I);if(!P.length)return;let $=P.map(te=>te.nodeValue).join(""),{flatLocal:Q,lToM:B,mapLocal:me}=m;if($===Q)return;let xe=m.textNodes.map(te=>({node:te.node,ms:te.ms,me:te.me})),fe=[],Se=0;for(let te of P)fe.push(Se),Se+=te.nodeValue.length;let V=(te,re)=>P.find((q,le)=>fe[le]<=te&&te+re<=fe[le]+q.nodeValue.length)||null,Z=[],be=0;for(let te of lo(Q,$).map(re=>_(Q,re))){let re=te.bs+be;be+=te.text.length-(te.be-te.bs);let q,le;if(te.be>te.bs){q=B[te.bs];let Ne=q>=0;for(let Le=te.bs;Ne&&Le<te.be;Le++)B[Le]!==q+(Le-te.bs)&&(Ne=!1);if(!Ne)continue;le=q+(te.be-te.bs)}else{let Ne=te.bs>0?B[te.bs-1]:0,Le=te.bs<Q.length?B[te.bs]:0;if(Ne<0||Le<0)continue;q=le=me(te.bs)}Z.push({ms:q,me:le,text:te.text,live:le===q?V(re,te.text.length):null})}Z.sort((te,re)=>re.ms-te.ms);let ke=(te,re)=>(K.get(te.node)||[j.get(te.node)]).includes(re),we=te=>!!te&&te.nodeType===1&&pn.has(te.tagName);for(let te of Z){let re=xe.find(le=>le.ms<=te.ms&&te.me<=le.me&&te.ms<le.me);if(re&&te.live&&re.ms===te.ms&&!ke(re,te.live)){let le=xe.find(Ne=>Ne.me===te.ms&&ke(Ne,te.live));le&&(re=le)}if(!re&&te.me===te.ms){let le=xe.find(Ae=>Ae.me===te.ms),Ne=xe.find(Ae=>Ae.ms===te.ms),Le=le||Ne;if(!Le)continue;let je=Le.node;for(;we(je.parentNode)&&(le?je.parentNode.lastChild:je.parentNode.firstChild)===je;)je=je.parentNode;if(je===Le.node)re=Le;else{let Ae=je.ownerDocument.createTextNode(te.text);je.parentNode.insertBefore(Ae,le?je.nextSibling:je);continue}}if(!re)continue;let q=re.node.nodeValue;re.node.nodeValue=q.slice(0,te.ms-re.ms)+te.text+q.slice(te.me-re.ms),re.me+=te.text.length-(te.me-te.ms)}}function Ce(m){return m.nodeType===1&&m.tagName==="TEMPLATE"&&m.content?m.content:m}function De(m,I){f.add(m);let P=i.get(I);if(P&&P.remote&&n.remoteIdOf){let Q=n.remoteIdOf(P.remote);Q&&w.push([m,Q])}if(P&&P.unchanged){o.opaque&&o.opaque(m)||(n.customIdentity&&P.remote&&ue(m,P.remote),P.remote&&G(m,P.remote));return}if(l.beforeNodeMorphed(m,I)===!1){N.add(I);return}vt(m,I,o.keepLiveOnly&&P&&P.local&&P.local.nodeType===1&&P.local!==m?P.local:null);let $=m.tagName;if(sn(m))m.textContent!==I.textContent&&(c.push({kind:"text",node:m,before:m.textContent,after:I.textContent}),m.textContent=I.textContent),n.mergedScripts.has(I)&&T.add(m);else if($==="TEXTAREA")Y(m,I,P);else{Ft(m,I,P);let Q=$==="TEMPLATE"&&m.content?m.content:m,B=$==="TEMPLATE"&&I.content?I.content:I;o.opaque&&o.opaque(m)||o.protectFocusedValue==="subtree"&&At(m)&&m!==r.body?pe(Q):Te(Q,B)}l.afterNodeMorphed(m,I)}function pe(m){for(let I=m.firstChild;I;I=I.nextSibling){let P=U.get(I);P&&j.get(P.parentNode)!==m||(f.add(I),I.nodeType===1&&pe(I))}}function Te(m,I){let P=He(m.firstChild),$=new Set;for(let Q of Array.from(I.childNodes)){let B=j.get(Q);B&&f.has(B)&&!$.has(B)&&(B=null);let me=i.get(Q);if(me&&me.pinned){B&&B.nodeType===1&&((B.parentNode!==m||He(B.nextSibling)!==P)&&ve(m,B,P),f.add(B),$.add(B));continue}if(B&&B.nodeType===1){if(B!==P){let Se=B.parentNode;if(Se===m&&P&&Ot(B)){let V=B.nextSibling;for(let Z=P;Z&&Z!==B;){let be=Z.nextSibling;ve(m,Z,V),Z=be}}else ve(m,B,P),Se!==m&&(a.push(B),c.push({kind:"move",el:B,from:Se,to:m}))}$.add(B),De(B,Q),P=He(B.nextSibling);continue}if(B&&B.nodeType!==1){let Se=K.get(Q)||[B],V=Se.map(be=>be.nodeValue).join(""),Z=Q.nodeValue;if(Q.nodeType===3){let be=Me(Q);be!=null&&V!==be&&(Z=Go(be,V,Q.nodeValue).text)}if(Se.length>1&&V===Z&&!Se.includes(P,1)&&Se.every((be,ke)=>be.parentNode===m&&(ke===0||Se[ke-1].nextSibling===be))){if(B!==P)for(let be of Se)ve(m,be,P);l.beforeNodeMorphed(B,Q)!==!1?l.afterNodeMorphed(B,Q):h&&N.add(Q);for(let be of Se)f.add(be),$.add(be);g.set(Q,B),W.add(Q),P=He(Se[Se.length-1].nextSibling);continue}B!==P&&ve(m,B,P),l.beforeNodeMorphed(B,Q)!==!1?(B.nodeValue!==Z&&(c.push({kind:"text",node:B,before:B.nodeValue,after:Z}),B.nodeValue=Z),l.afterNodeMorphed(B,Q)):N.add(Q),f.add(B),$.add(B),g.set(Q,B),P=He(B.nextSibling);continue}if(Q.nodeType===3&&P&&P.nodeType===3&&!f.has(P)&&!H.has(P)){P.nodeValue!==Q.nodeValue&&(c.push({kind:"text",node:P,before:P.nodeValue,after:Q.nodeValue}),P.nodeValue=Q.nodeValue),f.add(P),g.set(Q,P),P=He(P.nextSibling);continue}let xe=i.get(Q),fe=Je(xe&&xe.unchanged&&xe.remote?xe.remote:Q);if(l.beforeNodeAdded(fe)===!1){N.add(Q);continue}m.insertBefore(fe,P),f.add(fe),h&&y.set(Q,fe),fe.nodeType===3&&g.set(Q,fe),fe.nodeType===1&&(p.push(fe),Pe(fe,Q),n.customIdentity&&xe&&xe.unchanged&&xe.remote&&ue(fe,xe.remote),sn(fe)||pt(fe,Q),o.formState==="property"&&Jt(xe)&&G(fe,xe.remote)),P=He(fe.nextSibling),c.push({kind:"insert",node:fe,parent:m}),l.afterNodeAdded(fe)}for(let Q of Array.from(m.childNodes))f.has(Q)||$.has(Q)||Q.nodeType===1&&(o.ignored(Q)||ze(Q))||(k.has(Q)?d.push({node:Q,parent:m}):Ze(Q,m))}function ze(m){return m.parentNode&&m.parentNode.nodeType===1&&m.parentNode.tagName==="HEAD"&&(A&&!A.has(m)||o.preserve&&o.preserve(m)===!0)}function Me(m){let I=i.get(m);return!I||!Array.isArray(I.local)?null:I.local.map(P=>P.nodeValue).join("")}function v(m){return i.get(m)}function G(m,I){if(!vl.has(m.tagName)&&!m.querySelector("input,option,textarea"))return;let P=($,Q)=>{if($.tagName!==Q.tagName||($.tagName==="TEXTAREA"?Y($,Q,{remote:Q}):vl.has($.tagName)&&Ft($,Q,{remote:Q}),o.opaque&&o.opaque($)))return;let B=ae($),me=ae(Q);if(B.length===me.length)for(let xe=0;xe<B.length;xe++)P(B[xe],me[xe])};P(m,I)}function ue(m,I){if(o.opaque&&o.opaque(m))return;let P=ae(m),$=ae(I);if(P.length===$.length)for(let Q=0;Q<P.length;Q++){let B=n.remoteIdOf($[Q]);B&&w.push([P[Q],B]),ue(P[Q],$[Q])}}function ae(m){let I=m.tagName==="TEMPLATE"&&m.content?m.content:m;return Array.from(I.children).filter(P=>!o.ignored(P))}function Pe(m,I){if(!n.remoteIdOf)return;let P=($,Q)=>{let B=i.get(Q);if(B&&B.remote&&Q.nodeType===1){let fe=n.remoteIdOf(B.remote);fe&&w.push([$,fe])}let me=$.childNodes,xe=Q.childNodes;for(let fe=0;fe<me.length&&fe<xe.length;fe++)P(me[fe],xe[fe])};P(m,I)}function He(m){for(;m&&m.nodeType===1&&o.ignored(m);)m=m.nextSibling;return m}function ve(m,I,P){if(typeof m.moveBefore=="function"&&I.ownerDocument===m.ownerDocument)try{m.moveBefore(I,P);return}catch{}m.insertBefore(I,P)}function Ze(m,I){if(l.beforeNodeRemoved(m)===!1){h&&O.add(m);return}m.parentNode.removeChild(m),c.push({kind:"remove",node:m,parent:I}),l.afterNodeRemoved(m)}function Je(m){if(sn(m))return Jo(m,r);let I=r.importNode(m,!0);if(I.nodeType===1)for(let P of Array.from(I.querySelectorAll("script")))sn(P)&&P.replaceWith(Jo(P,r));return I}function pt(m,I){let P=m.tagName==="TEMPLATE"&&m.content?m.content:m,$=I.tagName==="TEMPLATE"&&I.content?I.content:I,Q=Array.from(P.childNodes),B=Array.from($.childNodes);for(let me=0;me<B.length&&me<Q.length;me++){let xe=B[me],fe=Q[me],Se=j.get(xe);Se&&f.has(Se)&&(Se=null);let V=i.get(xe);if(V&&V.pinned){if(Se&&Se.nodeType===1){let Z=Se.parentNode;ve(P,Se,fe),Z!==P&&(a.push(Se),c.push({kind:"move",el:Se,from:Z,to:P})),f.add(Se)}fe.remove();continue}if(Se){let Z=Se.parentNode;ve(P,Se,fe),fe.remove(),Se.nodeType===1?(Z!==P&&(a.push(Se),c.push({kind:"move",el:Se,from:Z,to:P})),De(Se,xe)):(f.add(Se),g.set(xe,Se),Se.nodeValue!==xe.nodeValue&&(c.push({kind:"text",node:Se,before:Se.nodeValue,after:xe.nodeValue}),Se.nodeValue=xe.nodeValue));continue}f.add(fe),h&&y.set(xe,fe),fe.nodeType===3&&g.set(xe,fe),V&&V.unchanged&&V.remote?(Ye(fe,V.remote),n.customIdentity&&ue(fe,V.remote)):xe.nodeType===1&&!sn(xe)&&pt(fe,xe)}}function Ye(m,I){let P=m.tagName==="TEMPLATE"&&m.content?m.content:m,$=I.tagName==="TEMPLATE"&&I.content?I.content:I;for(let Q of Array.from($.childNodes))P.appendChild(Je(Q))}function dt(m,I){return I.namespaceURI?m.getAttributeNS(I.namespaceURI,I.localName):m.getAttribute(I.name)}function St(m,I){let P=new Set((I||"").split(Us).filter(Boolean));return(m||"").split(Us).filter($=>$&&!P.has($))}function vt(m,I,P){for(let $ of Array.from(I.attributes)){if(bt(m,$.name)||o.ignoreAttribute(m,$.name,I))continue;let Q=dt(m,$);if(Q===$.value||P&&dt(P,$)===$.value)continue;let B=$.value;if(P&&$.name==="class"&&!$.namespaceURI){let me=$.value.split(Us).filter(Boolean),xe=St(Q,P.getAttribute("class")).filter(fe=>!me.includes(fe));xe.length&&(B=[...me,...xe].join(" "))}if(Q!==B){if(l.beforeAttributeUpdated($.name,m,"update")===!1){h&&S(I,$.name);continue}$.namespaceURI?m.setAttributeNS($.namespaceURI,$.name,B):m.setAttribute($.name,B),c.push({kind:"attr",el:m,name:$.name,before:Q,after:B})}}for(let $ of Array.from(m.attributes)){if(bt(m,$.name)||o.ignoreAttribute(m,$.name,I)||($.namespaceURI?I.hasAttributeNS($.namespaceURI,$.localName):I.hasAttribute($.name)))continue;if(P&&$.name==="class"&&!$.namespaceURI){let me=St($.value,P.getAttribute("class"));if(me.length){let xe=me.join(" ");if(xe===$.value)continue;if(l.beforeAttributeUpdated("class",m,"update")===!1){h&&S(I,"class");continue}m.setAttribute("class",xe),c.push({kind:"attr",el:m,name:"class",before:$.value,after:xe});continue}}if(P&&dt(P,$)===null&&!o.ignoreAttribute(P,$.name))continue;if(l.beforeAttributeUpdated($.name,m,"remove")===!1){h&&S(I,$.name);continue}let B=$.value;$.namespaceURI?m.removeAttributeNS($.namespaceURI,$.localName):m.removeAttribute($.name),c.push({kind:"attr",el:m,name:$.name,before:B,after:null})}}function bt(m,I){let P=m.tagName;return P==="INPUT"?I==="value"||I==="checked"||I==="disabled":P==="OPTION"?I==="selected":!1}function At(m){return m===r.activeElement}function Ot(m){let I=r.activeElement;return!!I&&I!==r.body&&m.contains(I)}function Bt(m,I){let P=I&&I.local&&I.local.nodeType===1&&I.local!==m?I.local:null;if(!P)return!0;let $=m.tagName==="TEXTAREA"?P.textContent:P.getAttribute("value")??"";return m.value!==$}function nn(m,I){return!!o.protectFocusedValue&&At(m)&&Bt(m,I)}function Nt(m,I,P){let $=Math.min(m.length,I.length),Q=0;for(;Q<$&&m[Q]===I[Q];)Q++;if(P<=Q)return P;let B=0;for(;B<$-Q&&m[m.length-1-B]===I[I.length-1-B];)B++;return P>=m.length-B?P+I.length-m.length:I.length-B}function $t(m){try{return m.selectionStart==null?null:[m.selectionStart,m.selectionEnd,m.selectionDirection]}catch{return null}}function an(m,I,P,$){try{m.setSelectionRange(Nt(I,P,$[0]),Nt(I,P,$[1]),$[2]||"none")}catch{}}function Pt(m,I){let P=m.value,$=$t(m);m.value=I,$&&an(m,P,I,$)}function Jt(m){let I=m&&m.remote;return I&&I.nodeType===1?I:null}function Ft(m,I,P){let $=m.tagName,Q=Jt(P),B=o.formState==="property"&&Q?Q:I;if($==="INPUT"){let me=nn(m,P),xe=(m.getAttribute("type")||"").toLowerCase(),fe=xe!=="file"&&xe!=="checkbox"&&xe!=="radio",Se=Q&&Q.hasAttribute("value")&&Q.value!==Q.getAttribute("value")?Q.value:null;if(fe&&!me)if(o.formState==="property"){let V=I.getAttribute("value"),Z=m.getAttribute("value");(Z!==V||m.value!==B.value)&&R("value",m,V==null?"remove":"update")!==!1&&(Z!==V&&(V==null?m.removeAttribute("value"):m.setAttribute("value",V),c.push({kind:"attr",el:m,name:"value",before:Z,after:V})),m.value!==B.value&&(At(m)?Pt(m,B.value):m.value=B.value))}else if(I.hasAttribute("value")||Se!=null){let V=Se??I.getAttribute("value");m.getAttribute("value")!==V&&R("value",m,"update")!==!1?(m.setAttribute("value",V),m.value!==V&&(At(m)?Pt(m,V):m.value=V),c.push({kind:"attr",el:m,name:"value",before:null,after:V})):m.value!==V&&m.getAttribute("value")===V&&(At(m)?Pt(m,V):m.value=V)}else(m.hasAttribute("value")||m.value!=="")&&R("value",m,"remove")!==!1&&(m.removeAttribute("value"),m.value="",c.push({kind:"attr",el:m,name:"value",before:"",after:null}));if(!fe&&xe!=="file"){let V=I.getAttribute("value");V==null?m.hasAttribute("value")&&R("value",m,"remove")!==!1&&m.removeAttribute("value"):m.getAttribute("value")!==V&&R("value",m,"update")!==!1&&m.setAttribute("value",V)}o.protectFocusedValue&&At(m)||(on(m,B,"checked"),o.formState==="property"&&m.indeterminate!==B.indeterminate&&(m.indeterminate=B.indeterminate)),on(m,B,"disabled")}else if($==="OPTION"){let me=m.parentNode&&m.closest("select");o.protectFocusedValue&&me&&At(me)||on(m,B,"selected")}}function on(m,I,P){if(o.ignoreAttribute(m,P,I))return;let $=o.formState==="property"?!!I[P]:I.hasAttribute(P);if(o.formState!=="property"){let Q=m.hasAttribute(P);if(Q!==$){if(R(P,m,$?"update":"remove")===!1)return;$?m.setAttribute(P,""):m.removeAttribute(P),c.push({kind:"attr",el:m,name:P,before:Q?"":null,after:$?"":null})}}m[P]!==$&&(m[P]=$)}function Y(m,I,P){if(nn(m,P)||R("value",m,"update")===!1)return;let $=Jt(P),Q=I.textContent,B=$&&$.value!==$.defaultValue?$.value:Q,me=At(m)?$t(m):null,xe=m.value;if(o.formState!=="property"&&m.textContent!==Q){c.push({kind:"text",node:m,before:m.textContent,after:Q});let fe=m.firstChild;fe&&fe.nodeType===3&&!fe.nextSibling?fe.data=Q:m.textContent=Q}m.value!==B&&(m.value=B),me&&m.value!==xe&&an(m,xe,m.value,me)}}function rf(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 sf(e,t,n,o,r,i,s){if(!t)return;let l=t.el;if(!l.isConnected&&t.id&&(l=e.getElementById(t.id)),!l||!l.isConnected)return;if(e.activeElement!==l)try{l.focus({preventScroll:!0})}catch{}try{l.scrollTop=t.scrollTop,l.scrollLeft=t.scrollLeft}catch{}if(t.selection){try{l.setSelectionRange&&!l.selectionEnd&&t.selection[1]!=null&&l.setSelectionRange(t.selection[0],t.selection[1],t.selection[2]||"none")}catch{}return}if(!t.range)return;let c=(f,d)=>{let w=n.get(f);if(Array.isArray(w)){let b=w.find(y=>d>=y.from&&d<y.to)||w.find(y=>d===y.to)||w[w.length-1],T=i.get(b.merged);if(!T||!T.isConnected)return null;let g=o.get(b.merged),h=g&&g.flat?g.flat(b.flatStart+d):d;return[T,Math.max(0,Math.min(h,T.nodeValue.length))]}if(w&&!s.has(w.merged)){let b=(r.get(w.merged)||[f])[0];if(!b.isConnected)return null;let T=o.get(w.merged),g=w.shift+d,h=T?T(g):g;return[b,Math.max(0,Math.min(h,b.nodeValue.length))]}return f.isConnected?[f,Math.min(d,f.nodeType===3?f.nodeValue.length:f.childNodes.length)]:null},a=c(t.range.sc,t.range.so),p=c(t.range.ec,t.range.eo);if(!(!a||!p))try{let f=e.createRange();f.setStart(a[0],a[1]),f.setEnd(p[0],p[1]);let d=e.getSelection();d.removeAllRanges(),d.addRange(f)}catch{}}var lf={compared:0},cf=new Set(["INPUT","SELECT","OPTION","TEXTAREA"]);function af(e,t,n,o){let r=(s,l)=>t.getAttribute(l)!==null&&typeof o=="function"&&!!o(s,l),i=0;for(let s of e.attributes)if(!(n(e,s.name)||r(e,s.name))&&(i++,t.getAttribute(s.name)!==s.value))return!1;for(let s of t.attributes)!n(t,s.name)&&!r(t,s.name)&&i--;return i===0}function Hs(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 Ml(e,t,n,o,r,i,s,l){let c=new Map,a=new Set,p=f=>{if(o(f))return;let d=n(f);d&&(i.add(d),r.has(d)||c.has(d)?a.add(d):c.set(d,f))};for(let f of e)p(f);p(t);for(let f of s||t.querySelectorAll("*"))p(f);for(let f of a)c.delete(f),l.add(f);return c}function El(e,t,n,o,r,i){let s=!1;for(let p of r)p.startsWith("merge:")&&(s=!0);if(!s)return[...o];let l=new Map,c=[],a=i===dn?er:"*";for(let p of[e,...e.querySelectorAll(a)]){if(n(p))continue;let f=t(p);if(!f||!(o.has(f)||r.has(f)))continue;let d=(l.get(f)||0)+1;l.set(f,d),d===2&&c.push(f)}return c}function Il({baseRoot:e,remoteRoot:t,liveRoot:n,toLive:o,o:r,identity:i,baseURI:s}){if(e.tagName!==t.tagName)return{bail:"root-tag"};if(e.getElementsByTagName("template").length||t.getElementsByTagName("template").length)return{bail:"script-or-template"};if(!af(e,t,r.ignoreAttribute,r.attributeMerge))return{bail:"root-attrs"};let{ignored:l,remoteWins:c}=r,a=Bs(r.scripts.merge===!1?null:r.scripts.mergeTags,s),p=Me=>{let v=a(Me);return v!==null?v:i.base(Me)||null},f=Me=>{let v=a(Me);return v!==null?v:i.remote(Me)||null},d=[],w=[],b=new Map,T=new Map,g={same:b,differ:T},h=Me=>({bail:Me,comparisons:g}),y=(Me,v,G=!0)=>{if(b.get(Me)===v)return!0;if(T.get(Me)===v)return!1;if(lf.compared++,G&&Me.isEqualNode(v))return b.set(Me,v),!0;let ue=Me.nodeType===v.nodeType;if(ue&&Me.nodeType===1){if(ue=Hs(Me,v),ue){let ae=Me.firstChild,Pe=v.firstChild;for(;ae&&Pe;ae=ae.nextSibling,Pe=Pe.nextSibling)if(!y(ae,Pe,!1)){ue=!1;break}(ae||Pe)&&(ue=!1)}}else ue&&(ue=Me.isEqualNode(v));return(ue?b:T).set(Me,v),ue},N=e,x=t,S=!1,O=()=>{b.set(N,x);for(let Me=0;Me<d.length;Me++)b.set(d[Me],w[Me]);return h("equal")};for(;;){let Me=N.childNodes,v=x.childNodes;if(Me.length!==v.length)break;let G=Je=>y(Me[Je],v[Je])?(b.set(Me[Je],v[Je]),!1):!0,ue=-1,ae=-1;for(let Je=0;Je<Me.length;Je++){if(Me[Je].nodeType!==1)continue;let pt=0;for(let Ye=Me[Je].firstElementChild;Ye;Ye=Ye.nextElementSibling)pt++;pt>=ae&&(ae=pt,ue=Je)}let Pe=[],He=!1;for(let Je=0;Je<Me.length&&Pe.length<2;Je++)Je!==ue&&G(Je)&&Pe.push(Je);if(ue>=0&&Pe.length<2&&(Pe.length===0&&Hs(N,x)?(Pe.push(ue),He=!0):G(ue)&&Pe.push(ue)),Pe.length!==1){if(!S&&Pe.length===0&&Hs(N,x))return O();break}let ve=Me[Pe[0]],Ze=v[Pe[0]];if(S=S||!He,S&&T.set(ve,Ze),ve.nodeType!==1||Ze.nodeType!==1||ve.tagName!==Ze.tagName)break;if(p(ve)!==f(Ze)){if(!S&&y(ve,Ze))return O();break}d.push(N),w.push(x),N=ve,x=Ze}T.set(N,x);for(let Me=0;Me<d.length;Me++)T.set(d[Me],w[Me]);if(N===e||N.tagName==="HEAD"||N.tagName==="BODY")return h("root-level");if(d.length<2||d[1].tagName!=="BODY")return h("not-in-body");if(l(N)||l(x))return h("ignored-ancestor");if(c(N)||c(x))return h("remote-wins-ancestor");for(let Me of d)if(cf.has(Me.tagName))return h("form-ancestor");if(N.tagName==="SCRIPT"||N.getElementsByTagName("script").length||x.getElementsByTagName("script").length)return h("script-or-template");let R=o(N);if(!R||R.nodeType!==1||R.tagName!==N.tagName)return h("no-live-twin");if(!n.contains(R))return h("live-detached");for(let Me of d){let v=o(Me);if(!v||v.nodeType!==1)return h("ancestor-live")}let M=i.base===dn&&i.remote===dn&&l===is,j=new Set,U=new Set,K=[],W=null,H=Me=>{Me&&(j.has(Me)?U.add(Me):j.add(Me))},k=(Me,v)=>{let G=a(Me),ue=G!==null?G:i.base(Me)||null;return ue!==(G!==null?G:i.remote(v)||null)?!1:(H(ue),!0)},A=(Me,v)=>{for(let G=Me.firstElementChild,ue=v.firstElementChild;G;G=G.nextElementSibling,ue=ue.nextElementSibling){let ae=l(G);if(ae!==l(ue))return!1;if(!ae&&(!k(G,ue)||!A(G,ue)))return!1}return!0},J=Me=>{let v=Me+1<d.length?d[Me+1]:N;for(let G=d[Me].firstElementChild,ue=w[Me].firstElementChild;G;G=G.nextElementSibling,ue=ue.nextElementSibling){if(G===v){let He=Me+1<d.length?J(Me+1):null;if(He)return He;continue}let ae=l(G);if(ae!==l(ue))return"outside-id-changed";if(ae)continue;let Pe=o(G);if(!Pe||Pe.nodeType!==1)return"sibling-live";if(K.push([G,ue]),!M&&(!k(G,ue)||!A(G,ue)))return"outside-id-changed";Me===0&&G.tagName==="HEAD"&&p(G)&&(W=[G,ue])}return null},_=J(0);if(_)return h(_);let F=new Set(d),Oe=null;if(i.base===dn){Oe=[];for(let Me of e.querySelectorAll(er))Me===N||F.has(Me)||(N.contains(Me)?Oe.push(Me):M&&H(p(Me)))}let Ce=new Set,De=new Set,pe=new Set,Te=Ml(d,N,p,l,j,Ce,Oe,De),ze=Ml(w,x,f,l,j,Ce,i.remote===dn&&x.querySelectorAll(er),pe);return W&&(U.has(p(W[0]))||Ce.has(p(W[0])))&&(W=null),{scope:{chain:d,root:N,onChain:F,baseIndex:Te,remoteIndex:ze,baseDropped:De,remoteDropped:pe,head:W,same:b,differ:T,dropped:[...El(e,p,l,U,De,i.base),...El(t,f,l,U,pe,i.remote)],held:Me=>{for(let v=1;v<d.length;v++)if(Me.map.get(d[v])!==w[v])return!1;for(let[v,G]of K)if(Me.map.get(v)!==G)return!1;return!0}}}}var ch=Symbol("hyper-morph-duplicate-key");var ff='[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"]',uf='[editor-ui],[clay~="editor-ui"],[no-undo],[clay~="no-undo"]',df='[no-undo]:not([editor-ui]):not([clay~="editor-ui"]),[clay~="no-undo"]:not([editor-ui]):not([clay~="editor-ui"])';function hf(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 pf(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=mf(e,t,o)),!!r)return n?Array.from(r.childNodes):r}function mf(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 c of i){let a=Eo(c,n);a&&!r.has(a.key)&&r.set(a.key,c.textContent)}if(!r.size)return null;let s=e.cloneNode(!0),l=!1;for(let c of[s,...s.querySelectorAll("script")]){let a=Eo(c,n);a&&r.has(a.key)&&(c.textContent=r.get(a.key),l=!0)}return l?s:null}function Cl(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 Vs(e,t,n={}){let o=n||{};if(!o.head?.block)return Rl(e,t,o);try{return Rl(e,t,o)}catch(r){return Promise.reject(r)}}function Rl(e,t,n){let o=n.policy||"sync",r=o==="raw"?void 0:(c,a)=>hf(c)||(o==="history"?!(a&&c.matches(df))&&c.matches(uf):c.matches(ff)),i=n.callbacks||{},s={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"&&(s.identity={base:n.key,local:n.key,remote:n.key}),e&&e.nodeType===9)return tr(Object.assign({},s,{live:e,base:n.scripts?.mergeBase||null,remote:Cl(t,e)}));if(e.tagName==="HTML"&&e.parentNode&&e.parentNode.nodeType===9){let c=Object.assign({},s,{live:e.ownerDocument,base:n.scripts?.mergeBase||null,remote:Cl(t,e.ownerDocument)});return tr(c)}n.morphStyle==="innerHTML"&&(s.children=!0);let l=pf(e,n.scripts?.mergeBase,!!s.children,s.scripts.mergeTags);return l!==void 0&&(s.base=l),_s(e,t,s)}var gf=new Set(["live","base","remote","local","identity","ignore","opaque","remoteWins","ignoreAttribute","attributeMerge","conflicts","protectFocusedValue","restoreFocus","head","scripts","formState","children","hooks","beforeApply","fastPath","keepLiveOnly","lineage"]),xn=()=>{};function nr(e,t=[]){if(!e||typeof e!="object")throw new TypeError("options object required");for(let l of Object.keys(e))if(!gf.has(l))throw new TypeError(`unknown option "${l}"`);let n=Object.assign({beforeNodeAdded:xn,afterNodeAdded:xn,beforeNodeRemoved:xn,afterNodeRemoved:xn,beforeNodeMorphed:xn,afterNodeMorphed:xn,beforeAttributeUpdated:xn},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");if(e.attributeMerge!==void 0&&typeof e.attributeMerge!="function")throw new TypeError("attributeMerge must be a function");let s=e.lineage;if(s!==void 0&&(!s||typeof s!="object"||typeof s.onResult!="function"||!s.elements||typeof s.elements.length!="number"))throw new TypeError("lineage must be { elements, onResult }");return{ignored:ls(e.ignore,t),remoteWins:ls(e.remoteWins,t),ignoreAttribute:typeof e.ignoreAttribute=="function"?e.ignoreAttribute:()=>!1,attributeMerge:typeof e.attributeMerge=="function"?e.attributeMerge:()=>null,opaque:typeof e.opaque=="function"?e.opaque:()=>!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,lineage:s||null}}function Lo(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 dn}function Po(e,t){if(typeof e=="function")return e;if(e&&typeof e=="object"&&e.map){let n=cs(t,e.map),o=typeof e.then=="function"?e.then:dn;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 dn}function bf(e,t,n,o={}){let r=w=>w&&w.nodeType===9?w.documentElement:w,i=r(t),s=r(n),l=r(e)||i;if(o.lineage!==void 0)throw new TypeError("lineage needs a live apply: use mergeDocument, morphDocument or morphElement");let c=Object.assign({},o);delete c.live,delete c.base,delete c.remote;let a=nr(c,[l,i,s].filter(Boolean)),p=o.identity||{},f=Gn(),d=Vr(l,i,s,{identity:{base:Po(p.base,l),local:Po(p.local,i),remote:Po(p.remote,s)},authored:{base:Lo(p.base),local:Lo(p.local),remote:Lo(p.remote)},skipUnchanged:a.hooks.beforeNodeMorphed===xn&&a.hooks.afterNodeMorphed===xn,ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,attributeMerge:a.attributeMerge,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:i.ownerDocument&&i.ownerDocument.baseURI||"about:blank",localIsBase:!e||e===t,childrenOnly:a.children,stats:f});return delete d.recoveryLinks,delete d.lineage,d}function Ws({liveRoot:e,baseRoot:t,localRoot:n,remoteRoot:o,toLive:r,options:i,identity:s,childrenOnly:l,isDocument:c}){let a=nr(i,[e,t,n,o].filter(Boolean));if(a.ignored(e)){let k=$s(),A=a.lineage?Xo(a.lineage,e,k):null;return{report:k,loads:[],lineage:A}}let p=e.ownerDocument,f=a.lineage?vs(a.lineage,{liveRoot:e,localRoot:n,toLive:r}):null,d=a.scripts.execute?ol(e,a.ignored,p.baseURI):null,w=Gn(),b=a.hooks.beforeNodeMorphed===xn&&a.hooks.afterNodeMorphed===xn,T={identity:{base:Po(s.base,t||n),local:Po(s.local,n),remote:Po(s.remote,o)},authored:{base:Lo(s.base),local:Lo(s.local),remote:Lo(s.remote)},ignored:a.ignored,remoteWins:a.remoteWins,ignoreAttribute:a.ignoreAttribute,attributeMerge:a.attributeMerge,conflicts:a.conflicts,mergeTags:a.scripts.merge===!1?null:a.scripts.mergeTags,baseURI:p.baseURI,localIsBase:!t,childrenOnly:l,skipUnchanged:b,lineage:f?{locals:f.locals}:null},g=a.fastPath&&c&&!l&&b&&t===n,h=null,y=null;if(g){let k=Il({baseRoot:t,remoteRoot:o,liveRoot:e,toLive:r,o:a,identity:T.identity,baseURI:p.baseURI});T.comparisons=k.comparisons||k.scope,k.bail?y=k.bail:(h=Vr(t,n,o,Object.assign({},T,{stats:w,scope:k.scope})),h||(y="chain-unpaired",w=Gn()))}h||(h=Vr(t||n,n,o,Object.assign({},T,{stats:w}))),g&&(w.fastPathAttempted=1,w.fastPathTaken=y?0:1,w.fastPathFallback=y),h.recoveryLinks&&["beforeNodeMorphed","beforeNodeAdded","beforeNodeRemoved","beforeAttributeUpdated"].some(k=>a.hooks[k]!==xn)&&ul(h.conflicts,h.recoveryLinks,r),a.beforeApply&&a.beforeApply(h.doc);let N=globalThis.__hyperMorphProfile,x=N?performance.now():0,S=Ol(e,h.root,h,{toLive:r,localRoot:n,ignored:a.ignored,ignoreAttribute:a.ignoreAttribute,opaque:a.opaque,formState:a.formState,protectFocusedValue:a.protectFocusedValue,restoreFocus:a.restoreFocus,preserve:a.head.preserve,hooks:a.hooks,childrenOnly:l,keepLiveOnly:a.keepLiveOnly,trackInserted:!!f});N&&(N.apply=(N.apply||0)+(performance.now()-x));let O=[];if(a.head.awaitLoads)for(let k of S.applied){if(k.kind!=="insert"||k.node.nodeType!==1)continue;let A=k.node;A.tagName==="LINK"&&/\bstylesheet\b/i.test(A.getAttribute("rel")||"")&&A.getAttribute("href")&&A.closest("head")&&O.push(new Promise(_=>{A.addEventListener("load",()=>_()),A.addEventListener("error",()=>_())}))}let R=null,M=null;if(d){let k=rl(e,d,{ignored:a.ignored,skip:S.mergedScriptsLive,baseURI:p.baseURI,beforeNodeAdded:a.hooks.beforeNodeAdded,afterNodeAdded:a.hooks.afterNodeAdded,trackRecovery:!!h.recoveryLinks});O.push(...k.loads),R=k.swapped,M=k.vetoed}let j=k=>R&&R.get(k)||k,U=k=>{if(S.keptRuns.has(k))return S.runOf.get(k);let A=S.liveOf.get(k)||S.heldBy.get(k)||S.insertedLive.get(k);return A?j(A):null},K=k=>{let A=k&&S.liveOf.get(k);return A?j(A):null},W=k=>{let A=k&&U(k);return Array.isArray(A)?A[0]:A};if(h.recoveryLinks){let k=(A,J,_)=>(J.namespaceURI?A.getAttributeNS(J.namespaceURI,J.localName):A.getAttribute(J.qualifiedName))===_;pl(h.conflicts,h.recoveryLinks,{lookup:U,vetoed:S.vetoed,vetoedAttrs:S.vetoedAttrs,removedVetoes:S.removedVetoes,vetoedLive:M,liveAttr:k,ignored:a.ignored,liveRoot:e})}let H={applied:S.applied,decisions:h.decisions.map(k=>Object.assign({},k,{node:k.node?K(k.node):null,el:k.el?K(k.el):null,applied:!!(k.node?K(k.node):k.el&&K(k.el))})),conflicts:h.conflicts.map(k=>Object.assign({},k,{node:k.node?k.kind==="text"&&k.recovery.subject.nodeType===8?W(k.node):K(k.node):k.node,el:k.el?k.kind==="structure"?W(k.el):K(k.el):k.el})),localDiverged:h.localDiverged,identities:S.identities,moved:S.moved,replaced:S.replaced,stats:w};return f&&(H.lineage=f.finish(h.lineage,U)),{report:H,loads:O,lineage:f}}var Ll=new WeakMap;function $s(){return{applied:[],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[],stats:Gn()}}function tr(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");return t.lineage===void 0?Pl(t):Ns(t,t.live.documentElement,o=>Pl(o))}function Pl(e){let t=e||{},n=t.live;if(!n||n.nodeType!==9)throw new TypeError("live must be a Document");let o=Ll.get(n);o||(o=ss(n),Ll.set(n,o));let r=o("remote",t.remote),i=typeof t.base=="string"&&t.base===""?null:t.base,s=i?o("base",i):null,l=t.local?t.local.root:n.documentElement,c=t.local?t.local.toLive:d=>d;Si(n,r);let{report:a,loads:p,lineage:f}=Ws({liveRoot:n.documentElement,baseRoot:s?s.documentElement:null,localRoot:l,remoteRoot:r.documentElement,toLive:c,options:t,identity:t.identity||{},childrenOnly:!1,isDocument:!0});return f?.deliver(a),Promise.all(p).then(()=>a)}function yf(e,t,n={}){return tr(Object.assign({},n,{live:e,base:null,remote:t}))}function jl(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=vr(e,t),s=o[1].toLowerCase()==="html"?i.documentElement:i.body;return{root:s,first:s}}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 _s(e,t,n={}){if(!e||e.nodeType!==1)throw new TypeError("oldEl must be an Element");return n.lineage===void 0?Dl(e,t,n):Ns(n,e,o=>Dl(e,t,o))}function Dl(e,t,n={}){let o=e.ownerDocument,{base:r,...i}=n,s=!!i.children,l=nr(i,[e]);if(l.ignored(e)){let T=$s();return l.lineage&&Xo(l.lineage,e,T).deliver(T),Promise.resolve(T)}let c=jl(t,o),a=r!=null?jl(r,o):null,p,f=null;if(s)p=c.root,f=a?a.root:null;else{if(p=c.first,f=a?a.first:null,!p){let T=nr(i),g=T.lineage?Xo(T.lineage,e,{}):null;T.hooks.beforeNodeRemoved(e)!==!1&&(e.remove(),T.hooks.afterNodeRemoved(e));let h={applied:[{kind:"remove",node:e,parent:null}],decisions:[],conflicts:[],localDiverged:!1,identities:[],moved:[],replaced:[e],stats:Gn()};return g&&(h.lineage=g.result,g.deliver(h)),Promise.resolve(h)}if(p.tagName!==e.tagName){let T=nr(i,[e,p]);if(T.hooks.beforeNodeMorphed(e,p)===!1){let y=$s();return T.lineage&&Xo(T.lineage,e,y).deliver(y),Promise.resolve(y)}let g=Ws({liveRoot:e,baseRoot:f&&f.tagName===e.tagName?f:null,localRoot:e,remoteRoot:p,toLive:y=>y,options:i,identity:i.identity||{},childrenOnly:!0,isDocument:!1}),h=sn(p)?Jo(p,o):o.importNode(p,!1);if(!sn(h))for(;e.firstChild;)h.appendChild(e.firstChild);return T.hooks.beforeNodeAdded(h)===!1?(Ur(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):T.hooks.beforeNodeRemoved(e)===!1?(Ur(g.report.conflicts,e,e),g.lineage&&(g.report.lineage=g.lineage.recheck(),g.lineage.deliver(g.report)),Promise.resolve(g.report)):(e.replaceWith(h),Ur(g.report.conflicts,e,h),T.hooks.afterNodeRemoved(e),T.hooks.afterNodeAdded(h),T.hooks.afterNodeMorphed(e,p),g.report.replaced.push(h),g.report.applied.push({kind:"insert",node:h,parent:h.parentNode},{kind:"remove",node:e,parent:h.parentNode}),g.lineage&&(g.report.lineage=g.lineage.remapRoot(e,h),g.lineage.deliver(g.report)),Promise.all(g.loads).then(()=>g.report))}}let{report:d,loads:w,lineage:b}=Ws({liveRoot:e,baseRoot:f,localRoot:e,remoteRoot:p,toLive:T=>T,options:i,identity:i.identity||{},childrenOnly:s,isDocument:!1});return b?.deliver(d),Promise.all(w).then(()=>d)}var Bl={mergeDocument:tr,morphDocument:yf,morphElement:_s,merge3:bf,morph:Vs};function Fs(e,t,{onWidgetRemoved:n}={}){Bl.morph(e,t,{morphStyle:"innerHTML",ignoreActiveValue:!0,restoreFocus:!0,formStateSync:"property",callbacks:{beforeNodeRemoved(o){let r=Sr.get(o);r?.destroy&&r.destroy(),n?.(o)}}})}var xf="hha:upgrade-check:";function Dn(e,t){let n=e.querySelector(`meta[name="${t}"]`),o=n?n.getAttribute("content"):null;return o&&o.trim()?o.trim():null}function qs(e){if(typeof e!="string")return null;let t=e.trim().replace(/^v/,"");return/^\d+(\.\d+)*$/.test(t)?t.split(".").map(Number):null}function Ul(e,t){let n=qs(e),o=qs(t);if(!n||!o)return!1;let r=Math.max(n.length,o.length);for(let i=0;i<r;i++){let s=n[i]||0,l=o[i]||0;if(s!==l)return s>l}return!1}function kf(e){try{let t=globalThis.localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}function Af(e,t){try{globalThis.localStorage.setItem(e,JSON.stringify(t))}catch{}}async function Ks({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||(d=>fetch(d)),r=r??Date.now(),!t)return null;let s=Dn(t,"hyper-source");if(!s)return null;let l=Dn(t,"hyper-version"),c;try{c=new URL(s,n?n.href:void 0)}catch{return null}if(n&&c.origin===n.origin&&c.pathname===n.pathname)return null;let a=`${xf}${c.href}:${l||"none"}`,p,f=e?null:kf(a);if(f&&typeof f.checkedAt=="number"&&r-f.checkedAt<i)p=f.sourceVersion;else{try{let d=await o(c.href);if(!d.ok)throw new Error(`HTTP ${d.status}`);let w=await d.text(),b=new DOMParser().parseFromString(w,"text/html");p=Dn(b,"hyper-version")}catch{p=null}Af(a,{checkedAt:r,sourceVersion:p})}return p?{available:Ul(p,l||"0.0.0"),currentVersion:l,sourceVersion:p,sourceUrl:c.href}:null}var Bn={};Jr(Bn,{EmptyListInsert:()=>Jn,MAX_RULE_DEPTH:()=>Do,MaxRuleDepthExceeded:()=>po,NoRulesTag:()=>zs,RuleTargetReadOnly:()=>rr,RulesParseError:()=>jo,ShapeMismatch:()=>or,UnknownRulesVersion:()=>ho,WriteNotRoundTripped:()=>_r,WriteRefused:()=>sr,WriteRejected:()=>Gs});var jo=class extends Error{constructor(t,n){super(t),this.name="RulesParseError",this.cause=n}},ho=class extends Error{constructor(t){super(`unknown rules version: ${t}. Library supports "1".`),this.name="UnknownRulesVersion",this.version=t}},Do=20,po=class extends Error{constructor(t){super(`rule depth exceeded ${Do} at path: ${t.join(".")}`),this.name="MaxRuleDepthExceeded",this.path=t}},or=class extends Error{constructor(t){super(`shape mismatch: ${t.length} field(s) failed validation`),this.name="ShapeMismatch",this.mismatches=t}},Jn=class extends Error{constructor(t,n){super(n?`cannot add items to empty list at "${t.join(".")}" \u2014 ${n}`:`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}},rr=class extends Error{constructor(t){super(`cannot write to read-only DOM property "${t}"`),this.name="RuleTargetReadOnly",this.target=t}},sr=class extends Error{constructor(t){super(`write refused: ${t.length} write(s) broke the content-only policy`),this.name="WriteRefused",this.refusals=t}};function Tf(e){return e.reduce((n,o)=>typeof o=="number"?`${n}[${o}]`:n?`${n}.${o}`:String(o),"")||"(root)"}var _r=class extends Error{constructor(t){super(`write did not round-trip at "${Tf(t)}"`),this.name="WriteNotRoundTripped",this.path=t}},zs=class extends Error{constructor(t){super(`no <script data-rules-name~="${t}"> rules tag in this document`),this.name="NoRulesTag",this.token=t}},Gs=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}};var Sf=/^--[A-Za-z0-9_-]+$/;function Zn(e){return typeof e=="string"&&Sf.test(e)}function Hl(e){let t=[],n=[],o=null,r=0;for(let i=0;i<e.length;i++){let s=e[i];if(o){s==="\\"?i++:s===o&&(o=null);continue}if(s==="/"&&e[i+1]==="*"){let l=e.indexOf("*/",i+2);i=l===-1?e.length:l+1;continue}s==='"'||s==="'"?o=s:s==="("?n.push(")"):s==="["?n.push("]"):s==="{"?n.push("}"):(s===")"||s==="]"||s==="}")&&n[n.length-1]===s?n.pop():s===";"&&n.length===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function Nf(e){let t="",n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){t+=r,r==="\\"&&o+1<e.length?t+=e[++o]:r===n&&(n=null);continue}if(r==="/"&&e[o+1]==="*"){let i=e.indexOf("*/",o+2);o=i===-1?e.length:i+1,t+=" ";continue}(r==='"'||r==="'")&&(n=r),t+=r}return t}function Vl(e){e=Nf(e);let t=e.indexOf(":");if(t===-1)return null;let n=e.slice(0,t).trim(),o=e.slice(t+1).trim(),r=/!\s*important\s*$/i.exec(o);return r&&(o=o.slice(0,r.index).trim()),{name:n,value:o,important:!!r}}function Bo(e,t){if(e==null)return null;let n=null;for(let o of Hl(String(e))){let r=Vl(o);!r||r.name!==t||(!n||r.important||!n.important)&&(n=r)}return n?n.value:null}function _l(e,t,n){let o=e==null?"":String(e),r=n==null||n==="",i=Hl(o),s=i.map(Vl),l=s.some(f=>f&&f.name===t&&f.important),c=[],a=!1;i.forEach((f,d)=>{let w=s[d];if(!w||w.name!==t){c.push(f);return}if(r||a)return;let b=/^\s*/.exec(f)[0];c.push(`${b}${t}: ${n}${l?" !important":""}`),a=!0});let p=c.join(";");if(!r&&!a){let f=p.trimEnd();p=f===""?`${t}: ${n}`:`${f}${f.endsWith(";")?" ":"; "}${t}: ${n}`}return p.trim()===""?null:p}function Wr(e,t,n,o){let r=e.attr(t,"style");if((Bo(r,n)??"")===o)return;let i=_l(r,n,o);i==null?e.removeAttr(t,"style"):e.attr(t,"style",i)}function Un(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 Xs(e,t,n,{depth:0,path:[]},o)}function Xs(e,t,n,o,r){if(o.depth>Do)throw new po(o.path);if(typeof n=="string")return vf(e,t,n,o,r);if(Array.isArray(n)){let[i,s]=n,l=e.find(t,i,r);return Wl(r,o,l),l.map((c,a)=>Xs(e,c,s,{depth:o.depth+1,path:[...o.path,a]},r))}if(typeof n=="object"&&n!==null){let i={};for(let[s,l]of Object.entries(n))i[s]=Xs(e,t,l,{depth:o.depth+1,path:[...o.path,s]},r);return i}return null}function vf(e,t,n,o,r){if(n.endsWith("[]")){let a=n.slice(0,-2),p=e.find(t,a,r);return Wl(r,o,p),p.map(f=>e.text(f))}if(n.startsWith("@"))return Ys(e,t,n.slice(1));let i=bn(n);if(i!==-1){let{selector:a,all:p}=en(n),f=n.slice(i+1),d=a?e.find(t,a,r):[t];return p&&r.allMatches?d.map(w=>Ys(e,w,f)):d.length===0?null:Ys(e,d[0],f)}if(n===".")return e.text(t);let{selector:s,all:l}=en(n),c=e.find(t,s,r);return l&&r.allMatches?c.map(a=>e.text(a)):c.length===0?null:e.text(c[0])}function Wl(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 Ys(e,t,n){if(Zn(n))return Bo(e.attr(t,"style"),n);if(ko.has(n)){let r=e.prop(t,n);return r==null?null:String(r)}let o=e.attr(t,n);return o??null}var $r=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"]})}),Of=Object.freeze({"editor-ui":Object.freeze(["no-data","no-save","no-snapshot","no-watch","no-undo"])}),$l=Object.freeze(["no-save","no-snapshot","no-trigger-autosave","no-dirty","no-watch","no-undo","no-data","freeze","editor-ui","live"]);function ir(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 Js(e,t){if(ir(e,t))return!0;for(let[n,o]of Object.entries(Of))if(o.includes(t)&&ir(e,n))return!0;return!1}function lr(e){let t=$r[e];if(!t)throw new Error(`Unknown region capability: ${e}`);return[...t.tokens,...t.bundles].flatMap(n=>[`[clay~="${n}"]`,`[${n}]`]).join(", ")}function Mf(e,t){let n=e&&e.nodeType===1?e:e?.parentElement;for(;n&&n.nodeType===1;){let o=$r[t];if(!o)throw new Error(`Unknown region capability: ${t}`);if(o.tokens.some(r=>Js(n,r))||o.bundles.some(r=>ir(n,r)))return n;n=n.parentElement}return null}function Fl(e,t){return!!Mf(e,t)}var Ef=/:(?:focus(?:-within|-visible)?|hover|active|visited|defined)\b/i;function If(e,t){if(!/^(INPUT|TEXTAREA|SELECT|OPTION)$/.test(e.tagName||""))return;let n=(e.getAttribute?.("type")||"").toLowerCase();"value"in e&&"value"in t&&e.tagName!=="OPTION"&&n!=="checkbox"&&n!=="radio"&&n!=="file"&&(t.value=e.value),e.tagName==="INPUT"&&(n==="checkbox"||n==="radio")&&(t.checked=e.checked),e.tagName==="OPTION"&&(t.selected=e.selected),"indeterminate"in e&&"indeterminate"in t&&(t.indeterminate=e.indeterminate)}function ql(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 Kl(e,t,n,o,r,i){return(i?Fl(e,t):ql(e,n,r,!1))||!!(o&&(i&&e!==r?e.matches(o):ql(e,o,r,i)))}function Cf(e,t){let n=$r[t];return n.tokens.some(o=>Js(e,o))||n.bundles.some(o=>ir(e,o))}var Rf=new Set(["INPUT","TEXTAREA","SELECT","OPTION"]);function zl(e,t,n,o){if(e.nodeType===1&&o(e)){n.dropped.push(t);return}n.cloneToLive.set(t,e),n.liveToClone.set(e,t);let r=e,i=t;if(e.nodeType===1){if(Rf.has(e.tagName)&&n.controls.push(e,t),e.tagName==="TEMPLATE"){for(;t.firstChild;)t.removeChild(t.firstChild);r=e.content,i=t.content,n.cloneToLive.set(i,r),n.liveToClone.set(r,i)}}else if(e.nodeType!==11)return;let s=i.firstChild;for(let l=r.firstChild;l&&s;l=l.nextSibling)zl(l,s,n,o),s=s.nextSibling}function cr(e,{capability:t="data",exclude:n=null,inherit:o=!0,provenance:r=null}={}){if(!e)throw new TypeError("createContentView requires a DOM context");let i=e.nodeType===9?e:e.ownerDocument;if(!i?.implementation?.createHTMLDocument)throw new TypeError("createContentView requires an HTML DOM implementation");let s=i.implementation.createHTMLDocument(""),l=r||new WeakMap,c=new WeakMap,a=e.nodeType===9?e.documentElement:e;n&&s.documentElement.matches(n);let p=lr(t),f=o?b=>Cf(b,t)||!!(n&&b.matches(n)):b=>Kl(b,t,p,n,a,!1),d=null;if(a.nodeType!==1||!Kl(a,t,p,n,a,o)){d=s.importNode(a,!0);let b={cloneToLive:l,liveToClone:c,dropped:[],controls:[]};zl(a,d,b,f);for(let T of b.dropped)T.remove();for(let T=0;T<b.controls.length;T+=2)If(b.controls[T],b.controls[T+1])}e.nodeType===9&&d&&(s.replaceChild(d,s.documentElement),c.set(e,s),l.set(s,e));let w=b=>{if(Ef.test(b))throw new Error(`Filtered content queries do not support stateful selector: ${b}`)};return{root:d,document:s,capability:t,selector:lr(t),cloneToLive:l,liveToClone:c,original(b){return l.get(b)||null},cloneOf(b){return c.get(b)||null},query(b,T=d){return w(b),Array.from(T.querySelectorAll(b),g=>l.get(g)||g)},text(b=d){return(b===d?d:c.get(b))?.textContent||""},html(b=d){return(b===d?d:c.get(b))?.innerHTML??""},clone(b=d){let T=b===d?d:c.get(b);return T?s.importNode(T,!0):null}}}function Yl(e){return e&&e.nodeType===1&&e.tagName==="SCRIPT"&&e.hasAttribute&&e.hasAttribute("data-rules-name")}function Lf(e){return e?(e.nodeType===9||e.nodeType===11,e):null}function Gl(e,t,n){!e||e.nodeType!==1||(t==="value"&&e.tagName==="INPUT"?e.value=n===null?"":n:t==="checked"&&e.tagName==="INPUT"?e.checked=n!==null:t==="selected"&&e.tagName==="OPTION"&&(e.selected=n!==null))}function Xl(e,t){e&&e.tagName==="TEXTAREA"&&(e.value=t)}function Jl(e){if(!e||e.nodeType!==1)return;let t=[e,...e.querySelectorAll?e.querySelectorAll("textarea, input, option"):[]];for(let n of t)if(n.tagName==="TEXTAREA")n.value=n.defaultValue;else if(n.tagName==="INPUT"){let o=n.type;o!=="file"&&o!=="checkbox"&&o!=="radio"&&(n.value=n.defaultValue),n.checked=n.defaultChecked}else n.tagName==="OPTION"&&(n.selected=n.defaultSelected)}var Xt={semanticExclude:!0,find(e,t,n={}){let o=Lf(e);if(!o||!o.querySelectorAll)return[];let r=Array.from(o.querySelectorAll(t));n.includeRulesTag||(r=r.filter(l=>!Yl(l)));let i=[];n.skip&&i.push(n.skip);let s=n.templateAttr===null?null:n.templateAttr||"cms-template";if(s&&i.push("["+s+"]"),i.length){let l=i.join(", ");r=r.filter(c=>!c.closest||!c.closest(l))}return r},parent(e){return e?e.parentElement:null},children(e){return e?Array.from(e.children):[]},matches(e,t){return!!(e&&e.matches)&&e.matches(t)},text(e,t){if(t===void 0)return(e.textContent||"").trim();e.textContent=t,Xl(e,t)},attr(e,t,n){if(n===void 0)return e.hasAttribute&&e.hasAttribute(t)?e.getAttribute(t):null;e.setAttribute(t,n),Gl(e,t,n)},removeAttr(e,t){e&&e.removeAttribute&&e.removeAttribute(t),Gl(e,t,null)},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){let t=e.cloneNode(!0);return Jl(t),t},insertAt(e,t,n){let o=e.children[n]||null;e.insertBefore(t,o)},insertBefore(e,t){e.parentNode.insertBefore(t,e)},insertAfter(e,t){e.parentNode.insertBefore(t,e.nextSibling)},identity(e){return e||null},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 Qn(e,t={}){if(t.exclude===null)return Xt;let n=[lr("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 Xt;let i=e.nodeType===9||!e.isConnected?e:e.ownerDocument,s=e.nodeType===9?e:e.ownerDocument,l=null,c=()=>l||(l=cr(i,{capability:"data",exclude:t.exclude||null})),a=b=>{let T=c();return b===e?T.cloneOf(e):T.cloneOf(b)||b},p=b=>l?.original(b)||b,f=(b,T)=>{c().liveToClone.set(b,T),c().cloneToLive.set(T,b);let g=b.childNodes||[],h=T.childNodes||[];for(let y=0;y<Math.min(g.length,h.length);y++)f(g[y],h[y])},d=(b,T,g,h)=>{let y=Array.from(b.childNodes).filter(R=>l.cloneOf(R)),x=y[0];for(;x&&y.includes(x);)x=x.nextSibling;for(let R of y)R.remove();if(g==="innerHTML"){let R=s.createElement("template");R.innerHTML=h;for(let M of Array.from(R.content.childNodes))b.insertBefore(M,x||null)}else b.insertBefore(s.createTextNode(h),x||null),Xl(b,h);let S=cr(b,{capability:"data",exclude:t.exclude||null});T.replaceChildren(...Array.from(S.root?.childNodes||[]));let O=R=>{let M=S.original(R);M&&(l.liveToClone.set(M,R),l.cloneToLive.set(R,M));for(let j of Array.from(R.childNodes||[]))O(j)};for(let R of Array.from(T.childNodes))O(R)},w={...Xt,find(b,T,g={}){let h=a(b);if(!h?.querySelectorAll)return[];let y=c().query(T,h);g.includeRulesTag||(y=y.filter(S=>!Yl(S)));let N=[];g.skip&&N.push(g.skip);let x=g.templateAttr===null?null:g.templateAttr||"cms-template";if(x&&N.push(`[${x}]`),N.length){let S=N.join(", ");y=y.filter(O=>!O.closest?.(S))}return y},parent(b){let T=a(b)?.parentElement;return T?p(T):null},children(b){return Array.from(a(b)?.children||[],p)},text(b,T){if(T===void 0){let y=p(b);return!y?.matches?.(n)&&!y?.querySelector?.(n)?Xt.text(y):(a(b)?.textContent||"").trim()}let g=p(b);if(!g?.matches?.(n)&&!g?.querySelector?.(n)&&!l){Xt.text(g,T);return}let h=c().cloneOf(g);h?d(g,h,"textContent",T):Xt.text(g,T)},attr(b,T,g){let h=p(b);if(g===void 0)return Xt.attr(h,T);Xt.attr(h,T,g);let y=l?.cloneOf(h);y&&(Xt.attr(y,T,g),cr(h,{capability:"data",exclude:t.exclude||null}).root===null&&(y.remove(),l.liveToClone.delete(h),l.cloneToLive.delete(y)))},removeAttr(b,T){let g=p(b);Xt.removeAttr(g,T);let h=l?.cloneOf(g);h&&Xt.removeAttr(h,T)},prop(b,T,g){let h=p(b);if(g===void 0)return T==="innerHTML"||T==="outerHTML"||T==="textContent"||T==="innerText"?Xt.prop(a(h),T):Xt.prop(h,T);let y=T==="innerHTML"||T==="textContent"||T==="innerText",N=y?c().cloneOf(h):l?.cloneOf(h);N&&y?d(h,N,T,g):(Xt.prop(h,T,g),N&&Xt.prop(N,T,g))},clone(b){let T=a(b);if(T===b)return Xt.clone(b);let g=s.importNode(T,!0);return Jl(g),g},insertAt(b,T,g){let h=p(b),N=w.children(h)[g]||(()=>{for(let O=h.children.length-1;O>=0;O--){let R=h.children[O];if(c().cloneOf(R))return R.nextElementSibling}return h.firstElementChild})(),x=p(T);h.insertBefore(x,N||null);let S=c().cloneOf(h);if(S){let O=c().cloneOf(x);O||(O=s.importNode(x,!0),f(x,O));let R=Array.from(S.children);S.insertBefore(O,R[g]||null)}},insertBefore(b,T){let g=p(b),h=p(T);g.parentNode.insertBefore(h,g);let y=c().cloneOf(g.parentNode);if(y){let N=c().cloneOf(h);N||(N=s.importNode(h,!0),f(h,N));let x=c().cloneOf(g);x?x.before(N):y.appendChild(N)}},insertAfter(b,T){let g=p(b),h=p(T);g.parentNode.insertBefore(h,g.nextSibling);let y=c().cloneOf(g.parentNode);if(y){let N=c().cloneOf(h);N||(N=s.importNode(h,!0),f(h,N));let x=c().cloneOf(g);x?x.after(N):y.appendChild(N)}},identity(b){return p(b)||null},remove(b){let T=p(b),g=c().cloneOf(T);Xt.remove(T),g&&Xt.remove(g)},replaceWith(b,T){let g=p(b),h=c().cloneOf(g),y=Xt.replaceWith(g,T);if(h){let N=cr(y,{capability:"data",exclude:t.exclude||null});if(!N.root)h.remove();else{h.replaceWith(N.root);let x=S=>{let O=N.original(S);O&&(l.liveToClone.set(O,S),l.cloneToLive.set(S,O));for(let R of Array.from(S.childNodes||[]))x(R)};x(N.root)}}return y}};return w}var vn=Xt;function Zs(e){try{return JSON.parse(e)}catch(t){throw new jo(`Invalid strict JSON: ${t.message}`,t)}}function mo(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=[],s=0;for(;s<r.length;){let l=r[s];if(/\s/.test(l)){s++;continue}if("{}".includes(l)){i.push({type:l,value:l}),s++;continue}if(l==="["){let f=!1,d=s+1;for(;d<r.length&&/\s/.test(r[d]);)d++;if(d<r.length&&/[a-zA-Z_]/.test(r[d])&&(f=!0),!f){i.push({type:l,value:l}),s++;continue}}if(l==="]"){i.push({type:l,value:l}),s++;continue}if(l===":"){i.push({type:t.COLON,value:l}),s++;continue}if(l===","){i.push({type:t.COMMA,value:l}),s++;continue}if(l==='"'||l==="'"){let f=l,d=s+1;for(;d<r.length&&r[d]!==f;)r[d]==="\\"&&d++,d++;i.push({type:t.STRING,value:r.substring(s+1,d),quoted:!0,sourceQuote:f}),s=d+1;continue}let c=s,a;for(;c<r.length&&!/[{},]/.test(r[c]);)if(r[c]===":"){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"],d=!1;for(let w of f){let b=w.substring(1);if(r.substring(c+1,c+1+b.length)===b){d=!0,c+=b.length;break}}if(!d)break}else if(r[c]==="["){for(c++;c<r.length&&r[c]!=="]";){if(r[c]==='"'||r[c]==="'"){let f=r[c];for(c++;c<r.length&&r[c]!==f;)r[c]==="\\"&&c++,c++}c++}c<r.length&&r[c]==="]"&&c++}else c++;a=r.substring(s,c);let p=t.IDENTIFIER;/^-?\d+(\.\d+)?$/.test(a)?p=t.NUMBER:a==="true"||a==="false"||a==="null"?p=t.BOOLEAN:/^[.#@\[]|[.#@\[]| /.test(a)&&(p=t.SELECTOR),i.push({type:p,value:a,quoted:!1}),s=c}return i}function o(r){let i="";for(let s=0;s<r.length;s++){let l=r[s];if("{}".includes(l.type)||"[]".includes(l.type)){i+=l.value;continue}if(l.type===t.COLON){i+=l.value;continue}if(l.type===t.COMMA){let c=r[s+1];if(c&&(c.type==="}"||c.type==="]"))continue;i+=l.value;continue}if(l.type===t.STRING&&l.quoted){let c=l.value;l.sourceQuote==="'"&&(c=c.replace(/\\'/g,"'"),c=c.replace(/(\\*)"/g,(a,p)=>p.length%2===0?p+'\\"':a)),i+=`"${c}"`;continue}if(l.type===t.NUMBER||l.type===t.BOOLEAN){i+=l.value;continue}if(l.type===t.SELECTOR||l.type===t.IDENTIFIER){i+=`"${l.value}"`;continue}i+=`"${l.value}"`}return i}try{let r=n(e),i=o(r);return JSON.parse(i)}catch(r){throw new jo("Invalid extraction rules syntax: "+r.message,r)}}var Qs="1",Zl=/^[a-zA-Z0-9_-]+$/;function Uo(e,t,n){let o;if(n===void 0)o="script[data-rules-name]";else{if(typeof n!="string"||!Zl.test(n))throw new Error(`hyper-html-api: invalid rules token ${JSON.stringify(n)} (must match ${Zl})`);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],s=e.attr(i,"data-rules-version");if(s!==Qs)throw new ho(s);return{rules:mo(e.text(i)),tagNode:i}}var Pf="script[data-rules-name]";function Ql(e){return typeof e=="string"?e.trim().replace(/\s+/g," "):""}function ar(e,t){let n=e.find(t,Pf,{includeRulesTag:!0}),o=new Set,r=[];for(let i of n){let s=Ql(e.attr(i,"data-rules-name"));if(!s)continue;if(o.has(s)){console.warn(`hyper-html-api: duplicate rules tag name "${s}"; using the first.`);continue}let l=e.attr(i,"data-rules-version");if(l!==Qs)throw new ho(l);o.add(s),r.push({name:s,rules:mo(e.text(i))})}return r}function Fr(e,t){let n={};for(let{name:o,rules:r}of ar(e,t))n[o]=Un(e,t,r);return n}function ei(e){let t=e||document,n=t.nodeType===9?t:t.ownerDocument||t;return{dataByName:Fr(vn,t),version:Dn(n,"hyper-version")}}var Ho=class extends Error{constructor(t,n){super(`could not fetch upgrade source: ${t}`),this.name="UpgradeSourceUnreachable",this.sourceUrl=t,this.cause=n}},fr=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}},eo=class extends Error{constructor(t,n){super(t),this.name="UpgradeTransformInvalid",this.cause=n}},ur=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 ec="text/hyper-upgrade";function ti(e,t){let n=e.find(t,`script[type="${ec}"]`);if(n.length===0)return null;if(n.length>1)throw new ur(n.length);return e.text(n[0])||null}var jf=new Function("url","return import(url)");async function ni(e){let t=new Blob([e],{type:"text/javascript"}),n=URL.createObjectURL(t),o;try{o=await jf(n)}catch(r){throw new eo(`transform failed to load: ${r&&r.message?r.message:r}`,r)}finally{URL.revokeObjectURL(n)}if(typeof o.default!="function")throw new eo("transform must `export default` a function");return o.default}function oc(e,t,n,o){let r=e.length,i=t.length,s=new Array(r).fill(-1);if(o){let h=new Set;for(let y=0;y<r;y++){let N=o[y];!(N>=0&&N<i)||h.has(N)||(s[y]=N,h.add(N))}}if(r===0||i===0)return s;let l=e.map(h=>tc(h,n)),c=t.map(h=>tc(h,n)),a=new Array(i).fill(!1);for(let h of s)h>=0&&(a[h]=!0);let p=new Map;c.forEach((h,y)=>{a[y]||p.set(h,p.has(h)?-1:y)});let f=new Map;l.forEach((h,y)=>{s[y]>=0||f.set(h,(f.get(h)||0)+1)}),l.forEach((h,y)=>{if(s[y]>=0||f.get(h)!==1)return;let N=p.get(h);N===void 0||N===-1||a[N]||(s[y]=N,a[N]=!0)});let d=[];for(let h=0;h<r;h++)s[h]<0&&d.push(h);let w=[];for(let h=0;h<i;h++)a[h]||w.push(h);if(d.length===0||w.length===0)return s;let b=r*i+1,T=Df(e,t,n),g=(h,y)=>T(h,y)*b+Math.abs(h-y);for(let[h,y]of Bf(d,w,g))s[h]=y;return s}var rc=e=>typeof e=="object"&&e!==null;function tc(e,t){if(!rc(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 Df(e,t,n){if(!rc(n))return(l,c)=>e[l]===t[c]?0:1;let o=Object.keys(n),r=l=>o.map(c=>JSON.stringify(l?.[c])),i=e.map(r),s=t.map(r);return(l,c)=>{let a=i[l],p=s[c],f=0;for(let d=0;d<o.length;d++)a[d]!==p[d]&&f++;return f}}function Bf(e,t,n){return e.length<=t.length?nc(e,t,n,!1):nc(t,e,(o,r)=>n(r,o),!0)}function nc(e,t,n,o){let r=e.length,i=t.length,s=[];for(let f=0;f<=r;f++)s.push(new Float64Array(i+1).fill(1/0));let l=[];for(let f=0;f<=r;f++)l.push(new Uint8Array(i+1));for(let f=0;f<=i;f++)s[r][f]=0;for(let f=r-1;f>=0;f--)for(let d=i-1;d>=0;d--){let w=n(e[f],t[d])+s[f+1][d+1],b=s[f][d+1];w<=b?(s[f][d]=w,l[f][d]=1):s[f][d]=b}let c=[],a=0,p=0;for(;a<r&&p<i;)l[a][p]&&(c.push(o?[t[p],e[a]]:[e[a],t[p]]),a++),p++;return c}function ri(e,t,n,o,r,i,s,l={}){let c=e.find(t,n,l);if(r.length===0){c.forEach(x=>e.remove(x)),oi(l,"onRowsApplied",i.path,[]);return}let a=r.length>c.length,p=c[0]||null;if(a&&!p&&(p=_f(e,t,n,l),!p))throw new Jn(i.path);let f=c.map(x=>Vf(e,x,o,l)),d=null;if(a&&p){d=e.clone(p),l.templateAttr&&e.removeAttr(d,l.templateAttr);let x=e.stripIds(d);x>0&&console.warn(`[hyper-html-api] stripped ${x} id attribute(s) from cloned template at "${i.path.join(".")||"(root)"}"`)}let w=oc(r,f,o,Uf(e,c,r,i,l)),b=c.length>0?e.parent(c[0]):qf(e,t,n,p,i,l),T=c.length>0?ac(e,b,c[0]):0,g=Gf(e,c),h=new Set,y=[],N=r.map((x,S)=>{let O=w[S];if(O>=0)return h.add(O),y.push(!1),c[O];y.push(!0);let R=e.clone(d);return e.stripIds(R),R});c.forEach((x,S)=>{h.has(S)||e.remove(x)}),g?zf(e,b,T,N,y):Yf(e,N,y,b,T),Hf(e,N,o,r,i,s,l),oi(l,"onRowsApplied",i.path,N)}function oi(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 Uf(e,t,n,o,r){let i=oi(r,"identifyRows",o.path,n);if(!Array.isArray(i))return null;let s=new Array(n.length).fill(-1),l=new Set,c=new Map(t.map((a,p)=>[e.identity(a),p]));for(let a=0;a<n.length;a++){if(!i[a])continue;let p=c.get(e.identity(i[a]));p===void 0||l.has(p)||(s[a]=p,l.add(p))}return s}function Hf(e,t,n,o,r,i,s){t.forEach((l,c)=>{if(n===null){let a=o[c],p=a==null?"":String(a);e.text(l)!==p&&e.text(l,p)}else{let a=i(e,l,n,o[c],{depth:r.depth+1,path:[...r.path,c]},s);a&&a!==l&&(t[c]=a)}})}function Vf(e,t,n,o){return n===null?e.text(t):Un(e,t,n,o.onRowsRead?{...o,onRowsRead:void 0}:o)}function ac(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 _f(e,t,n,o){if(!o.templateAttr)return null;let r=/^\s*:scope\s*>\s*/.test(n),i=new RegExp(":not\\(\\["+o.templateAttr.replace(/[.*+?^${}()|[\]\\-]/g,"\\$&")+"\\]\\)","g"),s=n.replace(/^\s*:scope\s*>\s*/,"").replace(i,""),l=r?Wf(s):0,c=ts(s),a=t;for(;a;){let p=e.find(a,s,{includeRulesTag:!1,templateAttr:null});for(let f of p)if(e.attr(f,o.templateAttr)!=null&&!(r&&!Ff(e,t,f,l))&&!(c&&!e.matches(e.parent(f),c)))return f;a=e.parent(a)}return null}function Wf(e){let t=0,n=null,o=1;for(let r=0;r<e.length;r++){let i=e[r];if(i==="\\")r++;else if(n)i===n&&(n=null);else if(i==='"'||i==="'")n=i;else if(i==="["||i==="(")t++;else if(i==="]"||i===")")t>0&&t--;else if(t===0&&i===">")o++;else{if(t===0&&(i==="+"||i==="~"))return null;if(t===0&&/\s/.test(i)){if(!$f(e,r))return null;for(;r+1<e.length&&/\s/.test(e[r+1]);)r++}}}return o}function $f(e,t){let n=t;for(;n<e.length&&/\s/.test(e[n]);)n++;let o=t>0?e[t-1]:"",r=n<e.length?e[n]:"";return sc(o)||sc(r)}function sc(e){return e===">"||e==="+"||e==="~"}function Ff(e,t,n,o){if(o===null)return!0;let r=n;for(let c=0;c<o;c++)if(r=e.parent(r),!r)return!1;let i=e.prop(t,"tagName");if(!i)return!0;let s=e.prop(r,"tagName");if(!s||String(s).toLowerCase()!==String(i).toLowerCase())return!1;let l=new Set(ic(e,r));return ic(e,t).every(c=>l.has(c))}function ic(e,t){let n=e.attr(t,"class");return n?String(n).split(/\s+/).filter(Boolean):[]}function qf(e,t,n,o,r,i){let s=e.parent(o);if(s&&Kf(e,t,s)&&!cc(e,s,i))return s;let l=ts(n);if(!l)throw new Jn(r.path,`the list selector "${n}" names no container to hold the new rows \u2014 write it as "container > row" (for example "ol.comments > li") so the cloned row lands in the list`);let a=(l===":scope"?e.prop(t,"tagName")?[t]:[]:e.find(t,l,i)).filter(p=>!cc(e,p,i));if(a.length===0)throw new Jn(r.path,`no container matching "${l}" inside this context to hold the new rows`);if(a.length>1)throw new Jn(r.path,`"${l}" matches ${a.length} containers inside this context, so the new rows have no single destination`);return a[0]}function Kf(e,t,n){let o=n;for(;o;){if(e.sameNode(o,t))return!0;o=e.parent(o)}return e.parent(t)?!1:e.find(t,"*",{includeRulesTag:!0,templateAttr:null}).some(r=>e.sameNode(r,n))}var lc=["no-data","editor-ui"];function cc(e,t,n){let o=t;for(;o;){if(n.templateAttr&&e.attr(o,n.templateAttr)!=null||lc.some(i=>e.attr(o,i)!=null))return!0;let r=e.attr(o,"clay");if(r&&r.split(/\s+/).some(i=>lc.includes(i)))return!0;o=e.parent(o)}return!1}function zf(e,t,n,o,r){let i=e.children(t),s=i.map(c=>e.identity(c)),l=!1;o.forEach((c,a)=>{let p=e.identity(c),f=n+a;if(s[f]===p)return;if(!r[a]){let w=s.indexOf(p);w!==-1&&(s.splice(w,1),i.splice(w,1))}let d=Math.min(f,i.length);d<i.length?e.insertBefore(i[d],c):i.length?l?e.insertAfter(i[i.length-1],c):(e.insertAt(t,c,f),l=!0):e.insertAt(t,c,0),s.splice(d,0,p),i.splice(d,0,c)})}function Gf(e,t){if(t.length<=1)return!0;let n=e.parent(t[0]);if(!n)return!1;let o=new Map(e.children(n).map((i,s)=>[e.identity(i),s])),r=[];for(let i of t){let s=o.get(e.identity(i));if(s===void 0)return!1;r.push(s)}return r.sort((i,s)=>i-s),r[r.length-1]-r[0]===r.length-1}function Yf(e,t,n,o,r){let i=null,s=r;for(let l=0;l<t.length;l++){if(!n[l]){i=t[l];continue}let c=i?e.parent(i):o;if(!c)continue;let a=i?ac(e,c,i)+1:s++;e.insertAt(c,t[l],a),i=t[l]}}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(si(n,o,[],i),i.length)throw new or(i);qr(e,t,n,o,{depth:0,path:[]},r)}function qr(e,t,n,o,r,i={}){if(r.depth>Do)throw new po(r.path);if(o===void 0)return t;if(typeof n=="string")return Xf(e,t,n,o,r,i);if(Array.isArray(n)){let[s,l]=n;return ri(e,t,s,l,o,r,qr,i),t}if(typeof n=="object"&&n!==null){for(let[s,l]of Object.entries(n)){let c=qr(e,t,l,o==null?o:o[s],{depth:r.depth+1,path:[...r.path,s]},i);c&&c!==t&&(t=c)}return t}return t}function Xf(e,t,n,o,r,i){if(n.endsWith("[]")){let p=n.slice(0,-2);return ri(e,t,p,null,o,r,qr,i),t}if(n.startsWith("@"))return uc(e,t,n.slice(1),o);let s=bn(n);if(s!==-1){let{selector:p,all:f}=en(n),d=n.slice(s+1),w=p?e.find(t,p,i):[t];for(let b of f?w:w.slice(0,1))uc(e,b,d,o);return t}if(n===".")return fc(e,t,o),t;let{selector:l,all:c}=en(n),a=e.find(t,l,i);for(let p of c?a:a.slice(0,1))fc(e,p,o);return t}function fc(e,t,n){let o=n==null?"":String(n);e.text(t)!==o&&e.text(t,o)}function Jf(e,t,n,o){if(e.styleVar){e.styleVar(t,n,o);return}Wr(e,t,n,o)}function uc(e,t,n,o){if(Zn(n))return Jf(e,t,n,o==null?"":String(o).trim()),t;if(io.has(n)){let r=e.prop(t,n);if(r===o||r!=null&&o!=null&&String(r)===String(o))return t;throw new rr(n)}if(n==="outerHTML"){let r=o==null?"":String(o);return e.replaceWith(t,r)}if(Qr.has(n)){let r=es(n,o);return e.prop(t,n)!==r&&e.prop(t,n,r),t}if(o==null)e.attr(t,n)!=null&&e.removeAttr(t,n);else{let r=String(o);e.attr(t,n)!==r&&e.attr(t,n,r)}return t}function si(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:hr([...n,i]),expected:"scalar",got:dr(r)})}):o.push({path:hr(n),expected:"array",got:dr(t)});return}t!==null&&typeof t=="object"&&o.push({path:hr(n),expected:"scalar",got:dr(t)});return}if(Array.isArray(e)){if(!Array.isArray(t)){o.push({path:hr(n),expected:"array",got:dr(t)});return}let r=e[1];t.forEach((i,s)=>si(r,i,[...n,s],o));return}if(typeof e=="object"&&e!==null){if(t===null||Array.isArray(t)||typeof t!="object"){o.push({path:hr(n),expected:"object",got:dr(t)});return}for(let[r,i]of Object.entries(e))si(i,t[r],[...n,r],o)}}}function dr(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function hr(e){return e.join(".")}function pr(e,t){let n={carriedOver:0,discarded:0,listItems:0},o=ii(t,e,n);return li(t,e,n),{data:o,summary:n}}function ii(e,t,n,o=!1){if(typeof e=="string")return e.endsWith("[]")?Array.isArray(t)?(n.listItems+=t.length,n.carriedOver+=t.length,t):o?[]:void 0:t==null||typeof t=="object"?o&&!Zf(e)?null:void 0:(n.carriedOver++,t);if(Array.isArray(e)){let[,r]=e;return Array.isArray(t)?(n.listItems+=t.length,t.map(i=>ii(r,i,n,!0))):o?[]:void 0}if(typeof e=="object"&&e!==null){let r={};for(let[i,s]of Object.entries(e)){let l=ii(s,t?.[i],n,o);l!==void 0&&(r[i]=l)}return r}}function Zf(e){let t=bn(e);return t!==-1&&io.has(e.slice(t+1))}function li(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)?li(e[r],t[r],n):n.discarded+=go(t[r]);return}if(Array.isArray(e)&&Array.isArray(t)){let o=e[1];t.forEach(r=>li(o,r,n));return}typeof e=="string"&&!e.endsWith("[]")&&typeof t=="object"&&t!==null&&(n.discarded+=go(t))}}function go(e){return e==null?0:Array.isArray(e)?e.reduce((t,n)=>t+go(n),0):typeof e=="object"?Object.values(e).reduce((t,n)=>t+go(n),0):1}function ci(e,t,n){let o=ar(e,t),r={carriedOver:0,discarded:0,listItems:0},i={},s=new Set;for(let{name:l,rules:c}of o){if(s.add(l),!Object.prototype.hasOwnProperty.call(n,l)){i[l]={carriedOver:0,discarded:0,listItems:0};continue}let{data:a,summary:p}=pr(n[l],c);$n(e,t,c,a,{templateAttr:"cms-template"}),i[l]=p,r.carriedOver+=p.carriedOver,r.discarded+=p.discarded,r.listItems+=p.listItems}for(let l of Object.keys(n))s.has(l)||(r.discarded+=go(n[l]));return{totals:r,byName:i,rulesTagCount:o.length}}async function ai({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||(h=>fetch(h)),!o)throw new Error("upgrade.run requires a document context");if(e=e||Dn(o,"hyper-source"),!e)throw new Error("upgrade.run: no sourceUrl given and no hyper-source meta tag found");let s=new URL(e,r?r.href:void 0);n=n!==void 0?n:Dn(o,"hyper-version"),t=t||Fr(vn,o);let l;try{l=await i(s.href)}catch(h){throw new Ho(s.href,h)}if(!l.ok)throw new Ho(s.href,new Error(`HTTP ${l.status}`));let c=await l.text(),a=new DOMParser().parseFromString(c,"text/html"),p=Dn(a,"hyper-version"),f=t,d=!1,w=ti(vn,a);if(w){let y=await(await ni(w))(f,{fromVersion:n,toVersion:p});if(!y||typeof y!="object"||Array.isArray(y))throw new eo("transform must return a plain object map of { rulesName: data }");f=y,d=!0}let{totals:b,byName:T,rulesTagCount:g}=ci(vn,a,f);if(g===0&&Object.keys(f).length>0)throw new fr(s.href);return{html:eu(a),fromVersion:n,toVersion:p,summary:{transformApplied:d,totals:b,byName:T}}}function Qf(e){for(let t of e.querySelectorAll("input")){let n=(t.getAttribute("type")||"").toLowerCase();n!=="file"&&(n==="checkbox"||n==="radio"?t.checked!==t.hasAttribute("checked")&&t.toggleAttribute("checked",t.checked):t.value!==(t.getAttribute("value")??"")&&t.setAttribute("value",t.value))}for(let t of e.querySelectorAll("textarea"))t.value!==t.textContent&&(t.textContent=t.value);for(let t of e.querySelectorAll("select")){let n=[...t.options];if(!t.multiple){let o=n.findIndex(r=>r.hasAttribute("selected"));if(t.selectedIndex===o||o===-1&&t.selectedIndex<=0)continue}for(let o of n)o.selected!==o.hasAttribute("selected")&&o.toggleAttribute("selected",o.selected)}}function eu(e){return Qf(e),`<!DOCTYPE ${e.doctype&&e.doctype.name?e.doctype.name:"html"}>
8
+ `+e.documentElement.outerHTML}var Kr=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",...$l],refusedAttributePrefixes:["on"],urlAttributes:["href","src","srcset","action","formaction","poster","cite","data","ping","background","longdesc","usemap","xlink:href","manifest","codebase","icon"],refusedSchemes:["javascript","vbscript","data"],customPropertyValues:Object.freeze({maxLength:200,refusedCharacters:[";","{","}","<",">","\\"],refusedFunctions:["url","src","image","image-set","-webkit-image-set","cross-fade","element","expression","paint"]})}),nu=new Set(["textContent","innerText"]);function dc(e){let n=String(e).replace(/^[\u0000- ]+|[\u0000- ]+$/g,"").replace(/[\t\n\r]/g,"").match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);return n?n[1].toLowerCase():null}var ou=/^[^\t\n\f\r "'>/=\u0000-\u001f\u007f]+$/;function hc(e,t,n=Kr){if(!ou.test(String(e)))return`attribute name ${JSON.stringify(String(e))} is not valid`;let o=String(e).toLowerCase();if(n.refusedAttributePrefixes.some(r=>o.startsWith(r)))return`attribute "${o}" can run script`;if(n.refusedAttributes.includes(o))return`attribute "${o}" is not content`;if(n.urlAttributes.includes(o)&&t!=null){let r=o==="srcset"?String(t).split(",").map(i=>i.trim().split(/\s+/)[0]).filter(Boolean):[String(t)];for(let i of r){let s=dc(i);if(s&&n.refusedSchemes.includes(s))return`"${s}:" URLs are not allowed in "${o}"`}}return null}function fi(e,t){let n=e.prop(t,"tagName");return n?String(n).toLowerCase():""}function ru(e,t){let n=fi(e,t)||"node",o=e.attr(t,"id");return o?`<${n}#${o}>`:`<${n}>`}function su(e,t,n){let o=t;for(;o;){let r=fi(e,o);if(r&&n.refusedTargets.includes(r))return r;o=e.parent(o)}return null}function pc(e,t){return e.find(t,"script[data-rules-name]",{includeRulesTag:!0,templateAttr:null}).length>0}function iu(e,t){return fi(e,t)==="script"&&e.attr(t,"data-rules-name")!=null?!0:pc(e,t)}function lu(e){if(/[\u0000-\u001f\u007f]/.test(e))return"control characters are not allowed in a custom property value";let t=[],n=null;for(let o=0;o<e.length;o++){let r=e[o];if(n){r===n&&(n=null);continue}if(r==='"'||r==="'")n=r;else{if(r==="/"&&e[o+1]==="*")return"comments are not allowed in a custom property value";if(r==="(")t.push(")");else if(r==="[")t.push("]");else if((r===")"||r==="]")&&t.pop()!==r)return`"${r}" does not close anything in this custom property value`}}return n?"a custom property value must close its quotes":t.length?"a custom property value must close its brackets":null}function mc(e,t=Kr){let n=t.customPropertyValues,o=String(e);if(o.length>n.maxLength)return`custom property values are limited to ${n.maxLength} characters`;let r=n.refusedCharacters.find(c=>o.includes(c));if(r)return`${JSON.stringify(r)} is not allowed in a custom property value`;let i=lu(o);if(i)return i;let s=o.toLowerCase(),l=n.refusedFunctions.find(c=>new RegExp(`(^|[^a-z0-9_-])${c.replace(/[-]/g,"\\-")}\\s*\\(`).test(s));return l?`"${l}()" is not allowed in a custom property value`:null}function zr(e,t=Kr){let n=[],o=(c,a)=>(n.push({target:ru(e,c),reason:a}),!1),r=c=>{let a=su(e,c,t);return a?o(c,`inside <${a}>, which is not content`):!0},i=c=>r(c)?pc(e,c)?o(c,"a text write here would delete the data rules tag"):!0:!1,s=(c,a,p)=>{if(!r(c))return!1;let f=hc(a,p,t);return f?o(c,f):!0};return{...e,text(c,a){if(a===void 0)return e.text(c);i(c)&&e.text(c,a)},attr(c,a,p){if(p===void 0)return e.attr(c,a);s(c,a,p)&&e.attr(c,a,p)},removeAttr(c,a){s(c,a,null)&&e.removeAttr(c,a)},styleVar(c,a,p){if((Bo(e.attr(c,"style"),a)??"")!==p&&r(c)){if(!Zn(a))return o(c,`"${a}" is not a custom property`);if(p!==""){let f=mc(p,t);if(f)return o(c,f)}Wr(e,c,a,p)}},prop(c,a,p){if(p===void 0)return e.prop(c,a);if(t.refusedRuleForms.includes(a))return o(c,`"@${a}" writes HTML, only text is allowed`);if(nu.has(a)){i(c)&&e.prop(c,a,p);return}s(c,a==="className"?"class":a,p)&&e.prop(c,a,p)},remove(c){if(iu(e,c)){o(c,"removing this would delete the data rules tag");return}e.remove(c)},replaceWith(c,a){return a===e.prop(c,"outerHTML")||o(c,'"@outerHTML" writes HTML, only text is allowed'),c},refusals:n,assertClean(){if(n.length)throw new sr(n.slice())}}}function mr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function gc(e){return e.reduce((t,n)=>typeof n=="number"?`${t}[${n}]`:t?`${t}.${n}`:n,"")}function ui(e,t,n,o,r={}){let i=[],s=[];function l(a,p,f){if(Array.isArray(a)){let[,d]=a;if(!Array.isArray(p)||!mr(d))return;p.forEach((w,b)=>l(d,w,[...f,b]));return}if(!(!mr(a)||!mr(p)))for(let d of Object.keys(p))Object.prototype.hasOwnProperty.call(a,d)?l(a[d],p[d],[...f,d]):i.push(gc([...f,d]))}function c(a,p,f,d){if(f!==void 0){if(typeof p=="string"){if(p.endsWith("[]")||p==="."||p.startsWith("@"))return;let{selector:w}=en(p);if(!w)return;e.find(a,w,r).length===0&&s.push({path:gc(d),selector:w});return}if(!Array.isArray(p)&&mr(p)&&mr(f))for(let[w,b]of Object.entries(p))c(a,b,f[w],[...d,w])}}return l(n,o,[]),c(t,n,o,[]),{unknownKeys:i,unmatched:s}}function di(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 Uo(e,o,n)}return null}var gr={extract:(e,t,n={})=>Un(Qn(e,n),e,t,n),apply:(e,t,n,o={})=>$n(Qn(e,{...o,_write:!0}),e,t,n,o),findRulesIn:(e,t)=>Uo(vn,e,t),findRules:(e,t)=>di(vn,e,t),bind:(e,t,n={})=>{let o=di(vn,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:()=>Un(Qn(e,n),e,o.rules,n),set:r=>$n(Qn(e,{...n,_write:!0}),e,o.rules,r,n)}},parseStrict:Zs,parseRelaxed:mo,ruleAttrIndex:bn,splitRule:en,errors:Bn,DOM_PROPERTIES:Tr},hi=e=>!!e&&typeof e.nodeType=="number";function bc(e){let t=e&&e.ownerDocument?e.ownerDocument:e,n=Uo(vn,t,"api");if(!n)throw new Bn.NoRulesTag("api");return n.rules}function au(e){if(e.nodeType===9)return e;let t=e.ownerDocument?.documentElement;if(t?.contains(e))return t;let n=e;for(;n.parentNode;)n=n.parentNode;return n}function fu(e){if(e.nodeType!==11||!e.host)return e.cloneNode(!0);let t=e.ownerDocument.createDocumentFragment();for(let n of e.childNodes)t.appendChild(n.cloneNode(!0));return t}function uu(e,t){let n=[];for(;t!==e;){let o=t.parentNode;n.push(Array.prototype.indexOf.call(o.childNodes,t)),t=o}return n.reverse()}function du(e,t){return t.reduce((n,o)=>n.childNodes[o],e)}function Vo(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}function hu(e,t){let n=Vo(e,"option"),o=Vo(t,"option");n.forEach((c,a)=>o[a].selected=c.selected);let r=Vo(e,"input"),i=Vo(t,"input");r.forEach((c,a)=>{let p=c.type.toLowerCase();p!=="file"&&(i[a].value=c.value),(p==="checkbox"||p==="radio")&&(i[a].checked=c.checked)});let s=Vo(e,"textarea"),l=Vo(t,"textarea");s.forEach((c,a)=>l[a].value=c.value)}function pi(e,t){if(t!==void 0){if(typeof e=="string"){if(e.endsWith("[]"))return;let n=e.startsWith("@")?0:bn(e);if(n===-1)return;let o=e.slice(n+1);if(io.has(o))throw new Bn.RuleTargetReadOnly(o);return}if(Array.isArray(e)){if(!Array.isArray(t))return;t.forEach(n=>pi(e[1],n));return}if(e&&typeof e=="object"&&t&&typeof t=="object"&&!Array.isArray(t))for(let[n,o]of Object.entries(e))pi(o,t[n])}}function pu(e,t,n){let o={templateAttr:"cms-template"},r=au(e),i=uu(r,e),s=fu(r);hu(r,s);let l=du(s,i),c=Qn(s,{...o,_write:!0}),a=ui(c,l,t,n,o);if(a.unknownKeys.length||a.unmatched.length)throw new Bn.WriteRejected(a.unknownKeys,a.unmatched);let p=zr(c);$n(p,l,t,n,o),p.assertClean(),pi(t,n);let f=zr(Qn(r,{...o,_write:!0}));$n(f,e,t,n,o),f.assertClean()}function mu(e){if(!(e instanceof Error))return e;let t=e.name||"Error";try{e.code=t}catch{Object.defineProperty(e,"code",{value:t,configurable:!0,enumerable:!0})}return e instanceof Bn.WriteRefused?e.details=e.refusals:e instanceof Bn.WriteRejected?e.details={unknownKeys:e.unknownKeys,unmatched:e.unmatched}:e instanceof Bn.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 mi(e,t){let n=hi(e)?e:document,o=hi(e)?t:e;return o===void 0?Un(Qn(n),n,bc(n)):gr.bind(n,o).get()}function gi(e,t,n){try{if(!hi(e))throw new Error("hyper-html-api: applyData(root, data, source?) needs a DOM root as the first argument.");let o=n===void 0?bc(e):gr.bind(e,n).rules;pu(e,o,t)}catch(o){throw mu(o)}return e}var yc={buildForm:ns,bindFormEvents:os,scaffold:Ao,morphForm:Fs,path:Ar},wc={checkForUpdate:Ks,run:ai,extractAll:ei,shapeMatch:pr};var gu={engine:gr,cms:yc,upgrade:wc,extractData:mi,applyData:gi},bu=gu;return Nc(yu);})();