@webqit/oohtml 4.4.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.lite.js CHANGED
@@ -13,7 +13,7 @@ ${p}
13
13
  const ast = parse( source, params.parserParams );
14
14
  const { toString, ...compilation } = compile( ast, params.compilerParams );
15
15
  e.ports[ 0 ]?.postMessage( compilation );
16
- };`;globalThis.webqit.$qCompilerWorker=new Worker(`data:text/javascript;base64,${btoa(o)}`)}return new Promise(r=>{let n=new MessageChannel;webqit.$qCompilerWorker.postMessage({source:e,params:t},[n.port2]),n.port1.onmessage=o=>{let{...a}=o.data;Object.defineProperty(a,"toString",{value:s=>s==="base64"?a.compiledSourceBase64:a.compiledSource}),r(a)}})}function ie(i,t,e={},r={}){t=j(t).slice();for(var n=i;!st(n)&&!Vt(n)&&t.length;){var o=t.shift();if(!(e.get?e.get(n,o):M(n)?o in n:n[o])){r.exists=!1;return}n=e.get?e.get(n,o):n[o]}return r.exists=!0,n}function ze(i,t,e,r={},n={}){let o=(l,f,d)=>n.set?n.set(l,f,d):(X(t[s])&&E(l)?l.push(d):l[f]=d,!0);t=j(t);for(var a=i,s=0;s<t.length;s++)if(s<t.length-1){if(!a||!M(a)&&!I(a))return!1;var u=ie(a,t[s],n);if(!M(u)){if(n.buildTree===!1)return!1;u=I(n.buildTree)?n.buildTree(s):X(t[s+1])?[]:{};var c=o(a,t[s],u);if(!c)return!1}a=u}else return o(a,t[s],e)}var ne=class{constructor(t,e=!1){Object.defineProperty(this,"window",{value:t}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!e&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let e=await t();return this._synthesis--,e}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,e=!1){if(e)return new Promise(r=>{this.synthesis?r(t()):this.readCallbacks.add(()=>{r(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,e=!1){if(e)return new Promise(r=>{this.synthesis?r(t()):this.writeCallbacks.add(()=>{r(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,e,r){this.onread(()=>{let n=t(r),o=a=>{a!==void 0&&this.onwrite(()=>{let s=e(a,r),u=c=>{c!==void 0&&this.cycle(t,e,c)};s instanceof Promise?s.then(u):u(s)})};n instanceof Promise?n.then(o):o(n)})}};function Ar(i){return(i=i.trim())&&i.startsWith("(")&&i.endsWith(")")}function Nt(i,t,e,r=!0){e=(Array.isArray(e)?e:[e]).map(a=>(a+"").replace("(",r?"(.//":"(./")).join("|");let n=[],o;try{let a=i.document.evaluate(e,t,null,i.XPathResult.ANY_TYPE);for(;o=a.iterateNext();)n.push(o)}catch{}return n}function $r(i,t,e){e=(Array.isArray(e)?e:[e]).map(r=>(r+"").replace("(","(self::")).join("|");try{return i.document.evaluate(`${e}`,t,null,i.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function oe(i,t,e,r=!1,n=null){let o=n?.get(t)?.get(e);if(typeof o<"u")return o;let a=c=>(n?.has(t)||n?.set(t,new WeakMap),n?.get(t)?.set(e,c),c),s=t.getRootNode(),u=e.getRootNode();return s===u?a(t.contains(e)):r&&u instanceof i.ShadowRoot?a(oe(i,t,u.host,r,n)):a(!1)}function Er(i,t="|"){return[...i].reduce(([e,r,n,o],a)=>!e&&r===0&&(Array.isArray(t)?t:[t]).includes(a)?[e,r,[""].concat(n)]:(!e&&["(","[","{"].includes(a)&&!n[0].endsWith("\\")&&r++,!e&&[")","]","}"].includes(a)&&!n[0].endsWith("\\")&&r--,['"',"'","`"].includes(a)&&!n[0].endsWith("\\")&&(e=e===a?null:e||a),n[0]+=a,[e,r,n]),[null,0,[""]])[2].reverse()}var Y=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Ar(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Er(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var At=class{constructor(t,e,r){this.context=t,this.namespace=e,this.window=t.defaultView||t.ownerDocument?.defaultView||r,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(I(t[0])?t=[[],...t]:T(t[0])&&!(t[0]instanceof Y)&&t.length===1?t=[[],void 0,t[0]]:T(t[1])&&t.length===2?t=[j(t[0],!1),void 0,t[1]]:t[0]=j(t[0],!1),t[0].filter(e=>typeof e!="string"&&!(e instanceof Y)&&!(e instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return t[0]=t[0].map(e=>e instanceof Y?e:new Y(e)),t}registry(...t){return V(this.window,"realdom",this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,e,r){let{window:n}=this,o=new Set,a=new WeakMap;for(let[s,u]of this.registry(t)){let c=[].concat(e).filter(f=>oe(n,s.context,f.target,s.params.subtree==="cross-roots",a));if(!c.length)continue;let l=[s,Array.isArray(e)?c:c[0]];u?o.add(l):r.call(n,...l)}for(let s of o)r.call(n,...s);o.clear()}disconnectables(t,...e){let r={disconnect(){e.forEach(n=>n&&I(n.disconnect)&&n.disconnect()||I(n)&&n()||T(n)&&(n.disconnected=!0))}};return t&&t.addEventListener("abort",()=>r.disconnect()),r}};var dt=class extends At{type="attr";constructor(t,...e){super(t,"attr",...e)}get(t,e=void 0,r={}){let n=typeof t=="string"||t instanceof Y;[t=[],e=void 0,r={}]=this.resolveArgs(arguments);let{context:o}=this,a=Ir(o,t);if(!e)return a;let s=r.lifecycleSignals&&this.createSignalGenerator();if(n)for(let u of a){let c=s?s.generate():{};e(u,c,o)}else{let u=s?.generate()||{};e(a,u,o)}if(r.live){s&&(r={...r,signalGenerator:s});let u=this.observe(n?t[0]:t,e,{newValue:!0,...r});return this.disconnectables(r.signal,u)}}observe(t,e,r={}){let n=typeof t=="string"||t instanceof Y;if([t=[],e,r={}]=this.resolveArgs(arguments),["sync","intercept"].includes(r.timing))return this.observeSync(n?t[0]:t,e,r);if(r.timing&&r.timing!=="async")throw new Error(`Timing option "${r.timing}" invalid.`);let{context:o,window:a,webqit:s}=this;r.eventDetails&&!s.realdom.attrInterceptionHooks?.intercepting&&Cr.call(a,"intercept",()=>{});let u=new a.MutationObserver(d=>{d=Tr(d).map(h=>Mr.call(a,h)),Pr.call(a,f,d,o)}),c={attributes:!0,attributeOldValue:r.oldValue,subtree:r.subtree&&!0};t.length&&(c.attributeFilter=t.map(d=>d+"")),u.observe(o,c);let l=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),f={context:o,spec:t,callback:e,params:r,atomics:new Map,originalFilterIsString:n,signalGenerator:l,disconnectable:u};return this.disconnectables(r.signal,u,l)}observeSync(t,e,r={}){let n=typeof t=="string"||t instanceof Y;[t,e,r={}]=this.resolveArgs(arguments);let{context:o,window:a}=this;if(r.timing&&!["sync","intercept"].includes(r.timing))throw new Error(`Timing option "${r.timing}" invalid.`);let s=r.timing==="intercept"?"intercept":"sync";this.registry(s).size||Cr.call(a,s,d=>{this.forEachMatchingContext(s,d,Pr)});let u={disconnect(){f.delete(l)}},c=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),l={context:o,spec:t,callback:e,params:r,atomics:new Map,originalFilterIsString:n,signalGenerator:c,disconnectable:u},f=this.registry(s);return f.set(l,!!l.params.deferred),this.disconnectables(r.signal,u,c)}};function Tr(i){return i.reduce((t,e,r)=>t[r-1]?.attributeName===e.attributeName||V(e.target,"realdom","internalAttrInteractions").get(e.attributeName)?t:t.concat(e),[])}function Pr(i,t){let{context:e,spec:r,callback:n,params:o,atomics:a,originalFilterIsString:s,signalGenerator:u}=i;if(o.subtree||(t=t.filter(d=>d.target===e)),!t.length)return;let c=r.map(d=>d+"");if(o.atomic&&!a.size?t=Ir(e,r,t):o.timing!=="async"&&r.length&&(t=t.filter(d=>c.includes(d.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(d=>{let h;return o.eventDetails||({event:h,...d}=d),!o.oldValue&&"oldValue"in d&&({oldValue:h,...d}=d),!o.newValue&&"value"in d?{value:h,...d}=d:o.newValue&&typeof d.value>"u"&&(d={...d,value:he(d.target,d.name,()=>d.target.getAttribute(d.name))}),d})),o.atomic&&(t.forEach(d=>a.set(d.name,d)),t=Array.from(a.entries()).map(([,d])=>d));let l=s?t[0]:t,f=u?u.generate():{};n(l,f,e)}function he(i,t,e){let r=V(i,"realdom","internalAttrInteractions").get(t);V(i,"realdom","internalAttrInteractions").set(t,!0);let n=e();return V(i,"realdom","internalAttrInteractions").set(t,r),n}function Ir(i,t,e=[]){let r={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",e.find(a=>a.name===o)||{target:i,name:o,value:he(i,o,()=>i.getAttribute(o)),...r})):Array.from(i.attributes).map(o=>e.find(a=>a.name===o.nodeName)||{target:i,name:o.nodeName,value:he(i,o.nodeName,()=>o.nodeValue),...r})}function Mr({target:i,attributeName:t,value:e,oldValue:r}){let a=(this.webqit.realdom.attrInterceptionRecords?.get(i)||{})[t]?.[0]||"mutation";return{target:i,name:t,value:e,oldValue:r,type:"observation",event:a}}function Cr(i,t){let e=this,{webqit:r,document:n,Element:o}=e;r.realdom.attrInterceptionHooks||Object.defineProperty(r.realdom,"attrInterceptionHooks",{value:new Map}),r.realdom.attrInterceptionHooks.has(i)||r.realdom.attrInterceptionHooks.set(i,new Set),r.realdom.attrInterceptionHooks.get(i).add(t);let a=()=>r.realdom.attrInterceptionHooks.get(i).delete(t);if(r.realdom.attrInterceptionHooks?.intercepting)return a;console.warn("Attr mutation APIs are now being intercepted."),r.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(r.realdom,"attrInterceptionRecords",{value:new Map});let s=(l,f)=>{r.realdom.attrInterceptionRecords.has(l.target)||r.realdom.attrInterceptionRecords.set(l.target,{});let d=r.realdom.attrInterceptionRecords.get(l.target);if(d[l.name]=d[l.name]||[],d[l.name].unshift(l.event),V(l.target,"realdom","internalAttrInteractions").get(l.name))return f();r.realdom.attrInterceptionHooks.get("intercept")?.forEach(p=>p([l]));let h=f();return r.realdom.attrInterceptionHooks.get("sync")?.forEach(p=>p([l])),h};new e.MutationObserver(l=>{l=l.filter(f=>!(e.webqit.realdom.attrInterceptionRecords?.get(f.target)||{})[f.attributeName]?.shift()),l=Tr(l).map(f=>Mr.call(e,f)),l.length&&(r.realdom.attrInterceptionHooks.get("intercept")?.forEach(f=>f(l)),r.realdom.attrInterceptionHooks.get("sync")?.forEach(f=>f(l)))}).observe(n,{attributes:!0,subtree:!0,attributeOldValue:!0});let c=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{c[l]=o.prototype[l],o.prototype[l]=function(...f){let d,h=he(this,f[0],()=>this.getAttribute(f[0]));["setAttribute","toggleAttribute"].includes(l)&&(d=f[1]),l==="toggleAttribute"&&d===void 0&&(d=h===null);let p={target:this,name:f[0],value:d,oldValue:h,type:"interception",event:[this,l]};return s(p,()=>c[l].call(this,...f))}}),a}var se=class extends At{constructor(t,...e){super(t,"tree",...e)}attr(t,e=void 0,r={}){let{context:n,window:o}=this;return new dt(n,o).get(...arguments)}query(t,e=void 0,r={}){[t,e=void 0,r={}]=this.resolveArgs(arguments);let{context:n}=this,o=new Map,a=c=>(o.has(c)||o.set(c,{target:c,entrants:[],exits:[],type:"query",event:null}),o.get(c));if(!r.generation||r.generation==="entrants"){if(!t.length)[...n.children].forEach(c=>a(n).entrants.push(c));else if(t.every(c=>c.type==="selector")){let[c,l]=t.reduce(([d,h],p)=>p.kind==="xpath"?[d,h.concat(p)]:[d.concat(p),h],[[],[]]),f=[];r.subtree?(c.length&&f.push(...n.querySelectorAll(c.join(","))),l.length&&f.push(...Nt(this.window,n,l))):(c.length&&f.push(...[...n.children].filter(d=>d.matches(c))),l.length&&f.push(...Nt(this.window,n,l,!1))),f.forEach(d=>a(d.parentNode||n).entrants.push(d))}}if(!e)return o;let s={disconnected:!1},u=e&&r.lifecycleSignals&&this.createSignalGenerator();for(let[,c]of o){if(s.disconnected)break;let l=u?.generate()||{};e(c,l,n)}if(r.live){u&&(r={...r,signalGenerator:u});let c=this.observe(t,e,r);return this.disconnectables(r.signal,s,c)}return this.disconnectables(r.signal,s,u)}children(t,e=void 0,r={}){return[t,e=void 0,r={}]=this.resolveArgs(arguments),this.query(t,e,{...r,subtree:!1})}subtree(t,e=void 0,r={}){return[t,e=void 0,r={}]=this.resolveArgs(arguments),this.query(t,e,{...r,subtree:!0})}observe(t,e,r={}){if([t,e,r={}]=this.resolveArgs(arguments),["sync","intercept"].includes(r.timing))return this.observeSync(t,e,r);if(r.timing&&r.timing!=="async")throw new Error(`Timing option "${r.timing}" invalid.`);let{context:n,window:o,webqit:a,document:s}=this;r.eventDetails&&(a.realdom.domInterceptionRecordsAlwaysOn=!0),(s.readyState==="loading"||a.realdom.domInterceptionRecordsAlwaysOn)&&!a.realdom.domInterceptionHooks?.intercepting&&Rr.call(o,"sync",()=>{});let u=new o.MutationObserver(f=>f.forEach(d=>{Ge.call(o,l,kr.call(o,d),n)}));u.observe(n,{childList:!0,subtree:r.subtree&&!0});let c=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),l={context:n,spec:t,callback:e,params:r,signalGenerator:c,disconnectable:u};if(r.staticSensitivity){let f=qr.call(o,l);return this.disconnectables(r.signal,u,c,f)}return this.disconnectables(r.signal,u,c)}observeSync(t,e,r={}){[t,e,r={}]=this.resolveArgs(arguments);let{context:n,window:o}=this;if(r.timing&&!["sync","intercept"].includes(r.timing))throw new Error(`Timing option "${r.timing}" invalid.`);let a=r.timing==="intercept"?"intercept":"sync";this.registry(a).size||Rr.call(o,a,d=>{this.forEachMatchingContext(a,d,Ge)});let s=new o.MutationObserver(d=>d.forEach(h=>{Array.isArray((h=kr.call(o,h)).event)||Ge.call(o,l,h,n)}));s.observe(n,{childList:!0,subtree:r.subtree&&!0});let u={disconnect(){f.delete(l),s.disconnect()}},c=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),l={context:n,spec:t,callback:e,params:r,signalGenerator:c,disconnectable:u},f=this.registry(a);if(f.set(l,!!l.params.deferred),r.staticSensitivity){let d=qr.call(o,l);return this.disconnectables(r.signal,u,c,d)}return this.disconnectables(r.signal,u,c)}track(t,e,r={}){return r={subtree:!0,...r},this.observe(t,n=>{n.entrants.length&&e(!0,Array.isArray(t)?n.entrants:n.entrants[0]),n.exits.length&&e(!1,Array.isArray(t)?n.exits:n.exits[0])},r)}};function qr(i){let t=this,{context:e,spec:r,callback:n,params:o,signalGenerator:a}=i,s=r.filter(h=>h.kind==="css"),u=h=>h.match(/\.([\w-]+)/g)?.length?["class"]:[],c=h=>h.match(/#([\w-]+)/g)?.length?["id"]:[],l=h=>[...h.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(p=>p[1]).concat(u(h)).concat(c(h));if(!(i.$attrs=Array.from(new Set(s.filter(h=>(h+"").includes("[")).reduce((h,p)=>h.concat(l(p+"")),[])))).length)return;let f=new Set,d=new Set;return f.push=h=>(d.delete(h),f.add(h)),d.push=h=>(f.delete(h),d.add(h)),i.$deliveryCache={entrants:f,exits:d},new dt(e,t).observe(i.$attrs,h=>{let p=new Map,v=w=>(p.has(w)||p.set(w,{target:w,entrants:[],exits:[],type:"static",event:null}),p.get(w)),O=new WeakMap,g=w=>(O.has(w)||O.set(w,s.some(b=>w.matches(b+""))),O.get(w));for(let w of h)["entrants","exits"].forEach(b=>{o.generation&&b!==o.generation||i.$deliveryCache[b].has(w.target)||(b==="entrants"?!g(w.target):g(w.target))||(i.$deliveryCache[b].push(w.target),v(w.target)[b].push(w.target),v(w.target).event=w.event)});for(let[,w]of p){let b=a?.generate()||{};n(w,b,e)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function Ge(i,t){let{context:e,spec:r,callback:n,params:o,signalGenerator:a,$deliveryCache:s}=i,u={...t,entrants:[],exits:[]};if(o.eventDetails||delete u.event,["entrants","exits"].forEach(l=>{if(!(o.generation&&l!==o.generation)&&(r.length?u[l]=ki.call(this,r,o.subtree==="cross-roots",t[l],t.event!=="parse"):u[l]=[...t[l]],!!s))for(let f of u[l])s[l].push(f)}),!u.entrants.length&&!u.exits.length)return;let c=a?.generate()||{};n(u,c,e)}function ki(i,t,e,r){e=Array.isArray(e)?e:[...e];let n=(o,a)=>{if(a.type==="selector"){let s=a.isXpathAttr?[]:o.filter(u=>a.kind==="xpath"?$r(this,u,a+""):u.matches&&u.matches(a+""));if((r||a.isXpathAttr)&&(s=o.reduce((u,c)=>a.kind==="xpath"?[...u,...Nt(this,c,a,r)]:c.querySelectorAll?[...u,...c.querySelectorAll(a+"")]:u,s)),s.length)return s}else if(o.includes(a.content)||r&&o.some(s=>oe(this,s,a.content,t)))return[a.content]};return e.$$searchCache||(e.$$searchCache=new Map),i.reduce((o,a)=>{let s;return e.$$searchCache.has(a.content)?s=e.$$searchCache.get(a.content):(s=n(e,a)||[],a.type==="instance"&&e.$$searchCache.set(a.content,s)),o.concat(s)},[])}function kr({target:i,addedNodes:t,removedNodes:e}){let r=this,n;return n=j(t).reduce((o,a)=>o||r.webqit.realdom.domInterceptionRecords?.get(a),null),n=j(e).reduce((o,a)=>o||r.webqit.realdom.domInterceptionRecords?.get(a),n),n=n||r.document.readyState==="loading"&&"parse"||"mutation",{target:i,entrants:t,exits:e,type:"observation",event:n}}function Rr(i,t){let e=this,{webqit:r,document:n,Node:o,CharacterData:a,Element:s,HTMLElement:u,HTMLTemplateElement:c,DocumentFragment:l}=e;r.realdom.domInterceptionHooks||Object.defineProperty(r.realdom,"domInterceptionHooks",{value:new Map}),r.realdom.domInterceptionNoRecurse||Object.defineProperty(r.realdom,"domInterceptionNoRecurse",{value:new Map}),r.realdom.domInterceptionHooks.has(i)||r.realdom.domInterceptionHooks.set(i,new Set),r.realdom.domInterceptionHooks.get(i).add(t);let f=()=>r.realdom.domInterceptionHooks.get(i).delete(t);if(r.realdom.domInterceptionHooks?.intercepting)return f;console.warn("DOM mutation APIs are now being intercepted."),r.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(r.realdom,"domInterceptionRecords",{value:new Map});let d=(g,w,b)=>{r.realdom.domInterceptionNoRecurse.set(g,w);let y=b();return r.realdom.domInterceptionNoRecurse.delete(g),y},h=(g,w)=>{g.entrants.concat(g.exits).forEach(y=>{clearTimeout(r.realdom.domInterceptionRecords.get(y)?.timeout),r.realdom.domInterceptionRecords.set(y,g.event);let m=setTimeout(()=>{r.realdom.domInterceptionRecords.delete(y)},0);Object.defineProperty(g.event,"timeout",{value:m,configurable:!0})}),r.realdom.domInterceptionHooks.get("intercept")?.forEach(y=>y(g));let b=w();return r.realdom.domInterceptionHooks.get("sync")?.forEach(y=>y(g)),b},p={ShadowRoot:["innerHTML","setHTMLUnsafe"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTMLUnsafe","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},v={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(p).reduce((g,w)=>g.concat(w),[])).forEach(g=>{Object.keys(p).forEach(y=>{if(!p[y].includes(g))return;let m=Object.getOwnPropertyDescriptor(e[y].prototype,g);!m||(Object.defineProperty(e[y].prototype,g,"value"in m?{...m,value:w}:{...m,set:b}),v[y][g]=m)});function w(...y){let m=Object.keys(v).find(L=>this instanceof e[L]&&g in v[L]),_=v[m],x=()=>_[g].value.call(this,...y);if(r.realdom.domInterceptionNoRecurse.get(this)===g)return x();let $=[],A=[],C=this;["insertBefore"].includes(g)?A=[y[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(g)?(A=[y[1]],["beforebegin","afterend"].includes(y[0])&&(C=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(g)?($=[...this.childNodes],A=g==="replaceChildren"?[...y]:[y[0]]):["replaceWith","remove"].includes(g)?($=[this],A=g==="replaceWith"?[...y]:[],C=this.parentNode):["replaceChild"].includes(g)?($=[y[1]],A=[y[0]]):["removeChild"].includes(g)?$=[...y]:(A=[...y],["before","after"].includes(g)&&(C=this.parentNode));let k=g;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(g)){let L=this.nodeName;if(g==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(y[0])){if(!this.parentNode)return _[g].value.call(this,...y);L=this.parentNode.nodeName}let H=n.createElement(L.includes("-")?"div":L);_.setHTMLUnsafe.value.call(H,A[0],g==="setHTMLUnsafe"?y[1]:{}),A=[...H.childNodes],g==="insertAdjacentHTML"?(k="insertAdjacentElement",y[1]=new l,d(y[1],"append",()=>y[1].append(...H.childNodes))):(k="replaceChildren",y=[...H.childNodes])}return h({target:C,entrants:A,exits:$,type:"interception",event:[this,g]},()=>_[k].value.call(this,...y))}function b(y){let m=Object.keys(v).find(N=>this instanceof e[N]&&g in v[N]),_=v[m],x=()=>_[g].set.call(this,y);if(this instanceof HTMLScriptElement||r.realdom.domInterceptionNoRecurse.get(this)===g)return x();let $=[],A=[],C=this;if(["outerHTML","outerText"].includes(g)?($=[this],C=this.parentNode):this instanceof c?(C=this.content,$=[...this.content.childNodes]):$=[...this.childNodes],["outerHTML","innerHTML"].includes(g)){let N=this.nodeName;if(g==="outerHTML"){if(!this.parentNode)return x();N=this.parentNode.nodeName}let L=n.createElement(N.includes("-")?"div":N);if(d(L,g,()=>L[g]=y),A=this instanceof c?[...L.content.childNodes]:[...L.childNodes],this instanceof c&&this.hasAttribute("src")||this instanceof ShadowRoot){let H=gt=>gt.reduce((nt,ot)=>ot instanceof HTMLScriptElement?nt.concat(ot):ot instanceof c?nt.concat(H([ot.content])):(nt=nt.concat(H([...ot.querySelectorAll?.("template")||[]].map(Zr=>Zr.content))),nt.concat(...ot.querySelectorAll?.("script")||[])),[]);for(let gt of H(A)){if(this instanceof ShadowRoot){gt.setAttribute("data-handling","manual");continue}let nt=n.createElement("script");[...gt.attributes].forEach(ot=>nt.setAttribute(ot.name,ot.value)),nt.textContent=gt.textContent,d(gt,"replaceWith",()=>gt.replaceWith(nt))}}g==="outerHTML"?(y=new l,d(y,"append",()=>y.append(...A)),x=()=>d(this,"replaceWith",()=>s.prototype.replaceWith.call(this,y))):this instanceof c?x=()=>d(this.content,"replaceChildren",()=>this.content.replaceChildren(...A)):x=()=>d(this,"replaceChildren",()=>s.prototype.replaceChildren.call(this,...A))}return h({target:C,entrants:A,exits:$,type:"interception",event:[this,g]},x)}}),f}function jr(){Ri.call(this),ji.call(this),Ni.call(this)}function Ri(){let i=this;i.CSS||(i.CSS={}),i.CSS.escape||(i.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function ji(){let i=this;"isConnected"in i.Node.prototype||Object.defineProperty(i.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function Ni(){let i=this;i.Element.prototype.matches||(i.Element.prototype.matches=i.Element.prototype.matchesSelector||i.Element.prototype.mozMatchesSelector||i.Element.prototype.msMatchesSelector||i.Element.prototype.oMatchesSelector||i.Element.prototype.webkitMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),r=e.length;--r>=0&&e.item(r)!==this;);return r>-1})}function Nr(){let i=this;if(i.webqit||(i.webqit={}),i.webqit.realdom)return i.webqit.realdom;i.webqit.realdom={},jr.call(i),i.webqit.realdom.meta=(...e)=>Di.call(i,...e),i.webqit.realdom.ready=(...e)=>Qe.call(i,...e),i.webqit.realdom.realtime=(e,r="dom")=>{if(r==="dom")return new se(e,i);if(r==="attr")return new dt(e,i)};let t=new ne(i);return i.webqit.realdom.schedule=(e,...r)=>t[`on${e}`](...r),i.webqit.realdom.synthesizeWhile=(...e)=>t.synthesizeWhile(...e),i.webqit.realdom}function Qe(...i){let t="interactive",e;Mt(i[0])?(t=i[0],I(i[1])&&(e=i[1])):I(i[0])&&(e=i[0]);let r={interactive:["interactive","complete"],complete:["complete"]};if(!r[t])throw new Error(`Invalid ready-state timing: ${t}.`);let n=this;if(!e)return n.webqit.realdom.readyStatePromises||(n.webqit.realdom.readyStatePromises={interactive:new Promise(o=>Qe.call(this,"interactive",o)),complete:new Promise(o=>Qe.call(this,"complete",o))}),n.webqit.realdom.readyStatePromises[t];if(r[t].includes(n.document.readyState))return e(n);n.webqit.realdom.readyStateCallbacks||(n.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},n.document.addEventListener("readystatechange",()=>{let o=n.document.readyState;for(let a of n.webqit.realdom.readyStateCallbacks[o].splice(0))a(n)},!1)),n.webqit.realdom.readyStateCallbacks[t].push(e)}function Di(i){let t=this,e={},r;return(r=t.document.querySelector(`meta[name="${i}"]`))&&(e=(r.content||"").split(";").filter(n=>n).reduce((n,o)=>{let a=o.split("=").map(s=>s.trim());return ze(n,a[0].split("."),a[1]==="true"?!0:a[1]==="false"?!1:X(a[1])?parseInt(a[1]):a[1]),n},{})),{get name(){return i},get content(){return r.content},json(){return JSON.parse(JSON.stringify(e))}}}function me(i,t){return typeof i!="string"?i:i.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+(typeof t!==void 0&&t?e.substr(1).toLowerCase():e.substr(1))})}var S=(i,...t)=>V(i,"oohtml",...t),q={};function z(i,t,e){let r=this,n=Nr.call(r);q.window=r,r.webqitConfig||(r.webqitConfig=n.meta("webqit").json()),r.webqit||(r.webqit={}),r.webqit.oohtml||(r.webqit.oohtml={}),r.webqit.oohtml.configs||(r.webqit.oohtml.configs={});let o=i.toUpperCase().replace("-","_");if(!r.webqit.oohtml.configs[o]){r.webqit.oohtml.configs[o]={};let a=r.webqit.oohtml.configs[o];Ut(2,a,e,t,n.meta(i).json()),r.webqitConfig.prefix&&Object.keys(a).forEach(s=>{Object.keys(a[s]).forEach(u=>{s==="api"&&typeof a[s][u]=="string"?a[s][u]=`${r.webqitConfig.prefix}${me(a[s][u])}`:["attr","elements"].includes(s)&&a[s][u]?.startsWith("data-")===!1&&(a[s][u]=`${r.webqitConfig.prefix}-${a[s][u]}`)})})}return{config:r.webqit.oohtml.configs[o],realdom:n,window:r}}function Je(i,t){return S(i,"internalAttrInteractions").get(t)}function Lr(i,t,e){let r=S(i,"internalAttrInteractions").get(t);S(i,"internalAttrInteractions").set(t,!0);let n=e();return S(i,"internalAttrInteractions").set(t,r),n}function ut(i,t){return[...i].reduce(([e,r,n],o)=>!e&&r===0&&(Array.isArray(t)?t:[t]).includes(o)?[e,r,[""].concat(n)]:(!e&&["(","[","{"].includes(o)&&!n[0].endsWith("\\")&&r++,!e&&[")","]","}"].includes(o)&&!n[0].endsWith("\\")&&r--,['"',"'","`"].includes(o)&&!n[0].endsWith("\\")&&(e=e===o?null:e||o),n[0]+=o,[e,r,n]),[null,0,[""]])[2].reverse()}var Fi=()=>(0|Math.random()*9e6).toString(36),Xe=new Map;function $t(i){let t;return(t=Xe.get(i))||(t=Fi(),Xe.set(i,t)),t}function ge(i){let t;return Xe.forEach((e,r)=>{e===i&&(t=r)}),t}function ye(){let{window:i}=q,{webqit:t}=i;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class e extends i.Event{constructor(...n){let o=n.pop();if(typeof o!="function")throw new Error("Callback must be provided.");let a=n.pop();if(!a?.kind)throw new Error('"options.kind" must be specified.');let s=["contextrequest","contextclaim"],u=n.pop()||s[0];if(!s.includes(u))throw new Error(`Invalid event type. Must be one of: ${s.join(",")}`);let{kind:c,detail:l,targetContext:f,live:d,signal:h,diff:p,...v}=a;super(u,{...v,bubbles:v.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>c}),Object.defineProperty(this,"targetContext",{get:()=>f}),Object.defineProperty(this,"detail",{get:()=>l}),Object.defineProperty(this,"live",{get:()=>d}),Object.defineProperty(this,"signal",{get:()=>h}),Object.defineProperty(this,"diff",{get:()=>p}),Object.defineProperty(this,"options",{get:()=>v}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(n){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===n)return;Object.defineProperty(this,"_prevValue",{value:n,configurable:!0})}return this.callback(n)}}return t.DOMContextRequestEvent=e,e}var Et=class extends AbortController{constructor(t){super(),t(e=>{let{window:{webqit:{Observer:r}}}=q;r.defineProperty(this,"value",{value:e,configurable:!0,enumerable:!0})},this)}};var Pt=class extends Error{};var pt=class{static instance(t){return _wq(t).get("contexts::instance")||new this(t)}constructor(t){_wq(t).get("contexts::instance")?.dispose(),_wq(t).set("contexts::instance",this);let e={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>e})}[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]()}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(e=>typeof t[0]=="function"?t[0](e):e.constructor.kind===t[0]&&(!t[1]||e.detail===t[1]))}attach(t){if(!(t instanceof U))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new Pt(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new Et((e,r)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(e):t[t.length-1]=e);let n;(n=t.find(a=>typeof a=="object"&&a))&&n.live&&(n.signal&&n.signal.addEventListener("abort",()=>r.abort()),t[t.indexOf(n)]={...n,signal:r.signal});let o=new(ye())(...t);this["#"].host.dispatchEvent(o)})}};var Ye=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=q;return t}get name(){return[q.window.Document,q.window.ShadowRoot].some(t=>this.host instanceof t)?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(!(t.detail instanceof Ye)||t.target===this.host)return;let e=new Set;if(this.subscriptions.forEach(r=>{!t.target.contains(r.target)||!t.detail.matchEvent(r)||(this.subscriptions.delete(r),this.unsubscribed(r),e.add(r))}),e.size)return t.respondWith(e)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:e}=pt.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return e?.forEach(r=>{this.subscriptions.add(r),this.subscribed(r),this.handle(r)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(e=>{this.subscriptions.delete(e),this.unsubscribed(e);let{target:r}=e;e.meta.answered=!1,r.dispatchEvent(e)}),this}},U=Ye;W(U,"kind");var Dt=class extends U{static createRequest(t=null){let e=super.createRequest();if(t?.startsWith("@")){let[r,...n]=n.slice(1).split("/").map(o=>o.trim());e.targetContext=r,e.detail=n.join("/")}else e.detail=t;return e}get namespaceObj(){return this.host[this.configs.NAMESPACED_HTML.api.namespace]}handle(t){let{window:{webqit:{Observer:e}}}=q;if(t.meta.controller?.abort(),!(t.detail||"").trim())return t.respondWith(e.unproxy(this.namespaceObj));let r=(t.detail||"").split("/").map(n=>n.trim()).filter(n=>n);if(!r.length)return t.respondWith();r=r.join(`/${this.configs.NAMESPACED_HTML.api.namespace}/`)?.split("/")||[],t.meta.controller=e.reduce(this.namespaceObj,r,e.get,n=>{this.disposed||t.respondWith(n.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};W(Dt,"kind","namespace");function Ze(i={}){let{config:t,window:e}=z.call(this,"namespaced-html",i,{attr:{namespace:"namespace",lid:"id"},api:{namespace:"namespace"},tokens:{lidrefPrefix:"~",lidrefSeparator:":"},target:{className:":target",eventName:":target",scrolling:!0}});t.lidSelector=`[${e.CSS.escape(t.attr.lid)}]`,t.namespaceSelector=`[${e.CSS.escape(t.attr.namespace)}]`,e.webqit.DOMNamingContext=Dt,Wi.call(e,t),Bi.call(e,t)}function Hr(i){let{lidrefPrefix:t,lidrefSeparator:e}=i.tokens;return{escape(r,n=1){return[...r].map(o=>/\w/.test(o)?o:n===2?`\\\\${o}`:`\\${o}`).join("")},lidrefPrefix(r=0){return r?this.escape(t,r):t},lidrefSeparator(r=0){return r?this.escape(e,r):e},isUuid(r,n=0){return r.startsWith(this.lidrefPrefix(n))&&r.includes(this.lidrefSeparator(n))},toUuid(r,n,o=0){return r.endsWith("-root")?n:`${this.lidrefPrefix(o)}${r}${this.lidrefSeparator(o)}${n}`},uuidToId(r,n=0){return this.isUuid(r)?r.split(this.lidrefSeparator(n))[1]:r},uuidToLidref(r,n=0){return this.isUuid(r)?`${this.lidrefPrefix(n)}${r.split(this.lidrefSeparator(n))[1]}`:r}}}function Ke(i,t,e=null,r=0){let n=this,{webqit:{oohtml:{configs:{NAMESPACED_HTML:o}}}}=n,a=Hr(o),s=new RegExp(`${e?":scope|":""}#(${a.lidrefPrefix(r+1)})?([\\w]+${a.lidrefSeparator(r+1)})?((?:[\\w-]|\\\\.)+)`,"g"),[u,c]=ut(i,",").reduce(([f,d],h)=>{let p,v;return h=h.replace(s,(O,g,w,b,y)=>{if(p||(p=[...h.matchAll(/(["'])(?:(?=(\\?))\2.)*?\1/g)]),p.some($=>y>$.index&&y+O.length<$.index+$[0].length))return O;if(O===":scope")return v=!0,e;let m=g&&!w;if(g&&w)return`#${a.escape(O.replace("#",""),1)}`;if(m&&o.attr.lid==="id"&&t&&!t.endsWith("-root"))return`#${a.toUuid(t,b,1)}`;let x;return o.attr.lid==="id"?x=`:is(#${b},[id^="${a.lidrefPrefix(r)}"][id$="${a.lidrefSeparator(r)}${b}"])`:x=`:is(#${b},[${n.CSS.escape(o.attr.lid)}="${b}"])`,m?`:is(${x}):not(${e?e+" ":""}${o.namespaceSelector} *)`:x}),v?[f,d.concat(h)]:[f.concat(h),d]},[[],[]]),l;return e&&u.length?l=[u.length>1?`${e} :is(${u.join(", ")})`:`${e} ${u[0]}`,c.join(", ")].filter(f=>f).join(", "):l=[...u,...c].join(", "),l}function we(i){let t=this;if(!S(i).has("namespace")){let e=Object.create(null);S(i).set("namespace",e);let r=[t.Document,t.ShadowRoot].some(n=>i instanceof n);Object.defineProperty(e,Symbol.toStringTag,{get(){return r?"RootNamespaceRegistry":"NamespaceRegistry"}})}return S(i).get("namespace")}function Lt(i,t=!1){let e=this,{webqit:{oohtml:{configs:{NAMESPACED_HTML:r}}}}=e,n=[e.Document,e.ShadowRoot].some(o=>i instanceof o);return we.call(e,n?i:(t?i.parentNode:i)?.closest?.(r.namespaceSelector)||i.getRootNode())}function be(i){let t=Object.prototype.toString.call(i)==="[object RootNamespaceRegistry]";return(ge(i)||$t(i))+(t?"-root":"")}function Wi(i){let t=this,{webqit:{Observer:e}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let n=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.namespace in r)throw new Error(`The ${n} prototype already has a "${i.api.namespace}" API!`);Object.defineProperty(r,i.api.namespace,{get:function(){return e.proxy(we.call(t,this))}})})}function Bi(i){let t=this,{webqit:{Observer:e,realdom:r,oohtml:{configs:n},DOMNamingContext:o}}=t,a=["aria-owns","aria-controls","aria-labelledby","aria-describedby","aria-flowto"],s=["for","list","form","aria-activedescendant","aria-details","aria-errormessage"],u=[i.attr.lid,...a,...s],c={id:"id",for:"htmlFor","aria-owns":"ariaOwns","aria-controls":"ariaControls","aria-labelledby":"ariaLabelledBy","aria-describedby":"ariaDescribedBy","aria-flowto":"ariaFlowto","aria-activedescendant":"ariaActiveDescendant","aria-details":"ariaDetails","aria-errormessage":"ariaErrorMessage"},l=Hr(i),f=(m,_,x)=>{if(!Je(m,_)&&S(m,"attrOriginals").has(_))return S(m,"attrOriginals").get(_);let $=x();return Je(m,_)?$:$&&$.split(" ").map(A=>(A=A.trim())&&(_===i.attr.lid?l.uuidToId:l.uuidToLidref).call(l,A)).join(" ")},d=Object.getOwnPropertyDescriptor(t.Document.prototype,"getElementById");Object.defineProperty(t.Document.prototype,"getElementById",{...d,value(m){return this.querySelector(`#${m}`)}});for(let m of["querySelector","querySelectorAll"])for(nodeApi of[t.Document,t.Element]){let _=Object.getOwnPropertyDescriptor(nodeApi.prototype,m);Object.defineProperty(nodeApi.prototype,m,{..._,value(x){return _.value.call(this,Ke.call(t,x,be(we.call(t,this))))}})}let h=Object.getOwnPropertyDescriptor(t.Element.prototype,"getAttribute");Object.defineProperty(t.Element.prototype,"getAttribute",{...h,value(m){let _=()=>h.value.call(this,m);return u.includes(m)&&!S(this,"lock").get(m)?f(this,m,_):_()}});let p=Object.getOwnPropertyDescriptor(t.Attr.prototype,"value");Object.defineProperty(t.Attr.prototype,"value",{...p,get(){let m=()=>p.get.call(this);return u.includes(this.name)?f(this.ownerElement,this.name,m):m()}});let v=Object.getOwnPropertyDescriptor(t.Node.prototype,"nodeValue");Object.defineProperty(t.Node.prototype,"nodeValue",{...v,get(){let m=()=>v.get.call(this);return this instanceof t.Attr&&u.includes(this.name)?f(this.ownerElement,this.name,m):m()}});for(let m of u){if(!(m in c))continue;let _=m==="for"?[t.HTMLLabelElement,t.HTMLOutputElement]:[t.Element];for(let x of _){let $=Object.getOwnPropertyDescriptor(x.prototype,c[m]);!$||Object.defineProperty(x.prototype,c[m],{...$,get(){return f(this,m,()=>$.get.call(this,m))}})}}i.attr.lid!=="id"&&Object.defineProperty(t.Element.prototype,i.attr.lid,{configurable:!0,enumerable:!0,get(){return this.getAttribute(i.attr.lid)},set(m){return this.setAttribute(i.attr.lid,m)}});let O=(m,_,x,$)=>Lr(m,_,()=>(typeof x=="function"&&(x=x()),$(x))),g=(m,_,x,$=null)=>{O(m,_,x,A=>{let C=_===i.attr.lid,k=$||Lt.call(t,m,C),N=be(k);if(C){let L=l.uuidToId(A);if(e.get(k,L)!==m){let H=l.toUuid(N,L);H!==A&&m.setAttribute("id",H),e.set(k,L,m)}}else{S(m,"attrOriginals").set(_,A);let L=A.split(" ").map(H=>(H=H.trim())&&l.isUuid(H)?H:l.toUuid(N,H)).join(" ");m.setAttribute(_,L),S(k).set("idrefs",S(k).get("idrefs")||new Set),S(k).get("idrefs").add(m)}})},w=(m,_,x,$=null)=>{O(m,_,x,A=>{let C=_===i.attr.lid,k=$||Lt.call(t,m,C);if(C){let N=l.uuidToId(A);e.get(k,N)===m&&e.deleteProperty(k,N)}else{let N=S(m,"attrOriginals").get(_);m.hasAttribute(_)&&m.setAttribute(_,N),S(k).get("idrefs")?.delete(m)}})};r.realtime(t.document).query(i.namespaceSelector,m=>{let _=(x,$,A,C)=>{if(!x.hasAttribute($))return;let k=()=>x.getAttribute($);w(x,$,k,A),x.isConnected&&g(x,$,S(x,"attrOriginals").get($)||k,C)};m.exits.forEach(x=>{if(x.isConnected){let C=we.call(t,x);for(let k of new Set([...Object.values(C),...S(C).get("idrefs")||[]]))for(let N of u)_(k,N,C)}let $=x[n.CONTEXT_API.api.contexts],A=$.find(o.kind);A&&$.detach(A)}),m.entrants.forEach(x=>{let $,A=Lt.call(t,x,!0);for(let k of new Set([...Object.values(A),...S(A).get("idrefs")||[]]))if(($=Lt.call(t,k,!0))!==A)for(let N of u)_(k,N,A,$);let C=x[n.CONTEXT_API.api.contexts];C.find(o.kind)||C.attach(new o)})},{id:"namespace-html:namespace",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(`[${u.map(m=>t.CSS.escape(m)).join("],[")}]`,m=>{let _={forID:new Map,forOther:new Map};for(let x of u){let $=x===i.attr.lid?_.forID:_.forOther;m.exits.forEach(A=>{if(!A.hasAttribute(x))return;let C=$.get(A);typeof C>"u"&&(C=(x===i.attr.lid?A.parentNode:A)?.closest?.(i.namespaceSelector)||A.getRootNode().host,$.set(A,C)),!(C&&!C.isConnected)&&w(A,x,()=>A.getAttribute(x))}),m.entrants.forEach(A=>{!A.hasAttribute(x)||g(A,x,()=>A.getAttribute(x))})}_.forID.clear(),_.forOther.clear()},{id:"namespace-html:attrs",live:!0,subtree:"cross-roots",timing:"sync"}),r.realtime(t.document,"attr").observe(u,m=>{for(let _ of m)_.oldValue&&w(_.target,_.name,_.oldValue),_.value&&g(_.target,_.name,_.value)},{id:"namespace-html:attr(attrs)",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0});let b,y=()=>{if(!t.location.hash?.startsWith(`#${l.lidrefPrefix()}`))return;let m=t.location.hash?.substring(`#${l.lidrefPrefix()}`.length).split("/").map(x=>x.trim()).filter(x=>x)||[],_=m.reduce((x,$)=>x&&x[i.api.namespace][$],t.document);b&&i.target.className&&b.classList.toggle(i.target.className,!1),_&&_!==t.document&&(i.target.className&&_.classList.toggle(i.target.className,!0),i.target.eventName&&_.dispatchEvent(new t.CustomEvent(i.target.eventName)),i.target.scrolling&&m.length>1&&_.scrollIntoView(),b=_)};t.addEventListener("hashchange",y),r.ready(y)}function tr({advanced:i={},...t}){let{config:e,window:r}=z.call(this,"scoped-js",t,{script:{retention:"retain",mimeTypes:"module|text/javascript|application/javascript",timing:"auto"},api:{scripts:"scripts"},advanced:kt(i)}),n=Array.isArray(e.script.mimeTypes)?e.script.mimeTypes:e.script.mimeTypes.split("|").filter(o=>o);e.scriptSelector=n.map(o=>`script[type="${r.CSS.escape(o)}"]:not([oohtmlignore])`).concat("script:not([type])").join(","),r.webqit.oohtml.Script={compileCache:[new Map,new Map],execute:zi.bind(r,e)},Vi.call(r,e),Ui.call(r,e)}function Vi(i){let t=this,e=new Map;if(i.api.scripts in t.Element.prototype)throw new Error(`The "Element" class already has a "${i.api.scripts}" property!`);[t.ShadowRoot.prototype,t.Element.prototype].forEach(r=>{Object.defineProperty(r,i.api.scripts,{get:function(){return e.has(this)||e.set(this,[]),e.get(this)}})}),Object.defineProperties(t.HTMLScriptElement.prototype,{scoped:{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}},quantum:{configurable:!0,get(){return this.hasAttribute("quantum")},set(r){this.toggleAttribute("quantum",r)}}})}async function zi(i,t){let e=this,{realdom:r}=e.webqit,n=ge(t);if(!n)throw new Error("Argument must be a valid exec hash.");let{script:o,compiledScript:a,thisContext:s}=n;i.script.retention==="dispose"?o.remove():i.script.retention==="hidden"?o.textContent='"source hidden"':o.textContent=await a.toString();let u=o.scoped?s:o.getRootNode();S(u).has("scriptEnv")||S(u).set("scriptEnv",Object.create(null));let c=await(await a.bind(s,S(u).get("scriptEnv"))).execute();o.quantum&&Object.defineProperty(o,"state",{value:c}),r.realtime(e.document).observe(o,()=>{o.quantum&&c.dispose(),s instanceof e.Element&&s[i.api.scripts]?.splice(s[i.api.scripts].indexOf(o,1))},{id:"scoped-js:script-exits",subtree:"cross-roots",timing:"sync",generation:"exits"})}function Ui(i){let t=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1,e=this,{webqit:{oohtml:r,realdom:n}}=e;e.HTMLScriptElement.supports||(e.HTMLScriptElement.supports=a=>["text/javascript","application/javascript"].includes(a));let o=new WeakSet;n.realtime(e.document).query(i.scriptSelector,a=>{a.entrants.forEach(s=>{if(o.has(s)||!t&&!s.hasAttribute("ssr"))return;let u=Fr.call(e,i,s);if(!u)return;o.add(s);let c=s.scoped?s.parentNode||a.target:s.type==="module"?void 0:e;s.scoped&&c[i.api.scripts].push(s);let l=$t({script:s,compiledScript:u,thisContext:c});a.type==="query"||s.type&&!e.HTMLScriptElement.supports(s.type)||s.getAttribute("data-handling")==="manual"||i.script.timing==="manual"?r.Script.execute(l):s.textContent=`webqit.oohtml.Script.execute( '${l}' );`})},{id:"scoped-js:script-entries",live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants",eventDetails:!0})}function Fr(i,t){let e=this,{webqit:{oohtml:r,QuantumScript:n,AsyncQuantumScript:o,QuantumModule:a}}=e,s=(t._=t.textContent.trim())&&t._.startsWith("/*@oohtml*/if(false){")&&t._.endsWith("}/*@oohtml*/")?t._.slice(21,-12):t.textContent;if(!s.trim().length)return;let u=$t(s),c=r.Script.compileCache[t.quantum?0:1],l;if(!(l=c.get(u))){let{parserParams:f,compilerParams:d,runtimeParams:h}=i.advanced;l=new(t.type==="module"?a:n||o)(s,{exportNamespace:`#${t.id}`,fileName:`${e.document.url?.split("#")?.[0]||""}#${t.id}`,parserParams:{...f,executionMode:t.quantum&&"QuantumProgram"||"RegularProgram"},compilerParams:d,runtimeParams:h}),c.set(u,l)}return l}function Wr(i){let t=this,{webqit:{oohtml:{configs:{SCOPED_JS:e}}}}=t;[...i?.querySelectorAll(e.scriptSelector)||[]].forEach(r=>{Fr.call(t,e,r)})}function ir(i={}){let{config:t,window:e}=z.call(this,"data-binding",i,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"},advanced:kt({runtimeParams:{spec:{handler:n=>{}}}})});({CONTEXT_API:t.CONTEXT_API,BINDINGS_API:t.BINDINGS_API,HTML_IMPORTS:t.HTML_IMPORTS}=e.webqit.oohtml.configs),t.attrSelector=`[${e.CSS.escape(t.attr.render)}]`;let r=(n,o)=>{let a=`starts-with(., "${n}")`,s=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${a} and ${s}`};t.discreteBindingsSelector=`comment()[${r(t.tokens.tagStart,t.tokens.tagEnd)}]`,Gi.call(e,t)}function Gi(i){let t=this,{webqit:{realdom:e}}=t;e.realtime(t.document).query(i.attrSelector,r=>{Br.call(this,...r.exits),setTimeout(()=>{Xi.call(t,i,...r.entrants)},0)},{id:"data-binding:attr",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0,staticSensitivity:!0}),e.realtime(t.document).query(`(${i.discreteBindingsSelector})`,r=>{setTimeout(()=>{Br.call(this,...r.exits),Qi.call(t,i,...r.entrants)},0)},{id:"data-binding:descrete",live:!0,subtree:"cross-roots",timing:"sync"})}function Vr(i,t){let{webqit:{realdom:e,Observer:r,DOMBindingsContext:n}}=this;if(S(t).has("data-binding"))return S(t).get("data-binding");let o=Object.create(null),a=new AbortController;o.$exec__=(u,c,...l)=>{(()=>{try{u[c](...l)}catch(d){throw new Error(`Error executing "${c}()": ${d.message} at ${d.cause}`)}})()},o.$assign__=(u,c,l)=>{(()=>{try{u[c]=l}catch(d){throw new Error(`Error executing "${c} = ${l}": ${d.message} at ${d.cause}`)}})()},r.intercept(o,{get:(u,c,l)=>{if(!(u.key in o)){let f={...n.createRequest(u.key),live:!0,signal:a.signal};t[i.CONTEXT_API.api.contexts].request(f,d=>{r.set(o,u.key,d)})}return l(o[u.key]??(u.key in globalThis?globalThis[u.key]:void 0))},has:(u,c,l)=>l(!0)});let s={scope:o,abortController:a,bindings:new Map};return S(t).set("data-binding",s),s}function Br(...i){for(let t of i){let e=t.nodeName==="#text"?t.parentNode:t,{bindings:r,abortController:n}=S(e).get("data-binding")||{};if(!r?.has(t))return;r.get(t).state.dispose(),r.get(t).signals?.forEach(o=>o.abort()),r.delete(t),r.size||(n.abort(),S(e).delete("data-binding"))}}function zr(i,t){let e=i.tokens.tagStart.split("").map(c=>`\\${c}`).join(""),r=i.tokens.tagEnd.split("").map(c=>`\\${c}`).join(""),n=i.tokens.stateStart.split("").map(c=>c===" "?"(?:\\s+)?":`\\${c}`).join(""),o=i.tokens.stateEnd.split("").map(c=>`\\${c}`).join(""),a=`^${e}(.*?)(?:${n}(\\d+)${o}(?:\\s+)?)?${r}$`,[,s,u]=t.match(new RegExp(a));return{raw:t,expr:s,span:parseInt(u??0)}}async function Qi(i,...t){let e=this,r=t.reduce((n,o)=>{if(o.isBound)return n;let a=zr(i,o.nodeValue),s=o;if(a.span){if(s=o.nextSibling,s?.nodeName!=="#text"||s.nodeValue.length<a.span)return n;s.nodeValue.length>a.span&&s.splitText(a.span)}else s=o.ownerDocument.createTextNode(""),o.after(s);s.isBound=!0;let u=o;return e.webqit.env!=="server"&&(u.remove(),u=null),n.concat({textNode:s,template:a,anchorNode:u})},[]);for(let{textNode:n,template:o,anchorNode:a}of r){let s=Ur.call(e,i,o.expr),{scope:u,bindings:c}=Vr.call(this,i,n.parentNode);Object.defineProperty(n,"$oohtml_internal_databinding_anchorNode",{value:a,configurable:!0});try{c.set(n,{state:await(await s.bind(n,u)).execute()})}catch(l){console.log(l)}}}var er=new Map;function Ur(i,t){if(er.has(t))return er.get(t);let e=`let content = ((${t}) ?? '') + '';`;e+="$assign__wq(this, 'nodeValue', content);",e+=`if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__wq(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${i.tokens.tagStart}${Ht(t)}${i.tokens.stateStart}" + content.length + "${i.tokens.stateEnd} ${i.tokens.tagEnd}"); }`;let{webqit:{QuantumModule:r}}=this,{parserParams:n,compilerParams:o,runtimeParams:a}=i.advanced,s=new r(e,{parserParams:n,compilerParams:o,runtimeParams:a});return er.set(t,s),s}async function Xi(i,...t){for(let e of t){let r=Gr.call(this,i,e.getAttribute(i.attr.render)),{scope:n,bindings:o}=Vr.call(this,i,e),a=[];Object.defineProperty(e,"$oohtml_internal_databinding_signals",{value:a,configurable:!0});try{o.set(e,{signals:a,state:await(await r.bind(e,n)).execute()})}catch(s){console.log(s)}}}var rr=new Map;function Gr(i,t){if(rr.has(t))return rr.get(t);let e={},r=-1,n=ut(t,";").map(l=>{let[f,d]=ut(l,":").map(g=>g.trim()),h=f[0],p=f.slice(1).trim(),v=`(${d})`,O=`(${v} ?? '')`;if(h==="&")return p.startsWith("--")?`$exec__wq(this.style, 'setProperty', "${Ht(p)}", ${O});`:`$assign__wq(this.style, "${Ht(p)}", ${O});`;if(h==="%")return`$exec__wq(this.classList, 'toggle', "${Ht(p)}", !!${v});`;if(h==="~")return p.startsWith("?")?`$exec__wq(this, 'toggleAttribute', "${Ht(p.substring(1).trim())}", !!${v});`:`$exec__wq(this, 'setAttribute', "${Ht(p)}", ${O});`;if(h==="#"){if(e[p])throw new Error(`Duplicate binding: ${f}.`);if(e[p]=!0,p==="text")return`$assign__wq(this, 'textContent', ${O});`;if(p==="html")return`$assign__wq(this, 'innerHTML', ${O});`;if(p==="items"){let[g,w]=ut(d,"/");if(!w)throw new Error(`Invalid ${h}items spec: ${l}; no import specifier.`);let[b,y,m,_]=g.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!b)throw new Error(`Invalid ${h}items spec: ${l}.`);if(y.startsWith("(")?y=y.trim().slice(1,-1).split(",").map($=>$.trim()):y=[y],y.length>(m==="in"?3:2))throw new Error(`Invalid ${h}items spec: ${l}.`);let x=m==="in"?y[2]:y[1]||"$index__";return`
16
+ };`;globalThis.webqit.$qCompilerWorker=new Worker(`data:text/javascript;base64,${btoa(o)}`)}return new Promise(r=>{let n=new MessageChannel;webqit.$qCompilerWorker.postMessage({source:e,params:t},[n.port2]),n.port1.onmessage=o=>{let{...a}=o.data;Object.defineProperty(a,"toString",{value:s=>s==="base64"?a.compiledSourceBase64:a.compiledSource}),r(a)}})}function ie(i,t,e={},r={}){t=j(t).slice();for(var n=i;!st(n)&&!Vt(n)&&t.length;){var o=t.shift();if(!(e.get?e.get(n,o):M(n)?o in n:n[o])){r.exists=!1;return}n=e.get?e.get(n,o):n[o]}return r.exists=!0,n}function ze(i,t,e,r={},n={}){let o=(l,f,d)=>n.set?n.set(l,f,d):(X(t[s])&&E(l)?l.push(d):l[f]=d,!0);t=j(t);for(var a=i,s=0;s<t.length;s++)if(s<t.length-1){if(!a||!M(a)&&!I(a))return!1;var u=ie(a,t[s],n);if(!M(u)){if(n.buildTree===!1)return!1;u=I(n.buildTree)?n.buildTree(s):X(t[s+1])?[]:{};var c=o(a,t[s],u);if(!c)return!1}a=u}else return o(a,t[s],e)}var ne=class{constructor(t,e=!1){Object.defineProperty(this,"window",{value:t}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),Object.defineProperty(this,"_synthesis",{value:0,writable:!0}),!e&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let e=await t();return this._synthesis--,e}_fulfill(){for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t)}_loop(){this.window.requestAnimationFrame(()=>{this._fulfill(),this._loop()})}onread(t,e=!1){if(e)return new Promise(r=>{this.synthesis?r(t()):this.readCallbacks.add(()=>{r(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,e=!1){if(e)return new Promise(r=>{this.synthesis?r(t()):this.writeCallbacks.add(()=>{r(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,e,r){this.onread(()=>{let n=t(r),o=a=>{a!==void 0&&this.onwrite(()=>{let s=e(a,r),u=c=>{c!==void 0&&this.cycle(t,e,c)};s instanceof Promise?s.then(u):u(s)})};n instanceof Promise?n.then(o):o(n)})}};function Ar(i){return(i=i.trim())&&i.startsWith("(")&&i.endsWith(")")}function Nt(i,t,e,r=!0){e=(Array.isArray(e)?e:[e]).map(a=>(a+"").replace("(",r?"(.//":"(./")).join("|");let n=[],o;try{let a=i.document.evaluate(e,t,null,i.XPathResult.ANY_TYPE);for(;o=a.iterateNext();)n.push(o)}catch{}return n}function $r(i,t,e){e=(Array.isArray(e)?e:[e]).map(r=>(r+"").replace("(","(self::")).join("|");try{return i.document.evaluate(`${e}`,t,null,i.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function oe(i,t,e,r=!1,n=null){let o=n?.get(t)?.get(e);if(typeof o<"u")return o;let a=c=>(n?.has(t)||n?.set(t,new WeakMap),n?.get(t)?.set(e,c),c),s=t.getRootNode(),u=e.getRootNode();return s===u?a(t.contains(e)):r&&u instanceof i.ShadowRoot?a(oe(i,t,u.host,r,n)):a(!1)}function Er(i,t="|"){return[...i].reduce(([e,r,n,o],a)=>!e&&r===0&&(Array.isArray(t)?t:[t]).includes(a)?[e,r,[""].concat(n)]:(!e&&["(","[","{"].includes(a)&&!n[0].endsWith("\\")&&r++,!e&&[")","]","}"].includes(a)&&!n[0].endsWith("\\")&&r--,['"',"'","`"].includes(a)&&!n[0].endsWith("\\")&&(e=e===a?null:e||a),n[0]+=a,[e,r,n]),[null,0,[""]])[2].reverse()}var Y=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Ar(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Er(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var At=class{constructor(t,e,r){this.context=t,this.namespace=e,this.window=t.defaultView||t.ownerDocument?.defaultView||r,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(I(t[0])?t=[[],...t]:T(t[0])&&!(t[0]instanceof Y)&&t.length===1?t=[[],void 0,t[0]]:T(t[1])&&t.length===2?t=[j(t[0],!1),void 0,t[1]]:t[0]=j(t[0],!1),t[0].filter(e=>typeof e!="string"&&!(e instanceof Y)&&!(e instanceof this.window.Node)).length)throw new Error("Argument #2 must be either a string or a Node object, or a list of those.");return t[0]=t[0].map(e=>e instanceof Y?e:new Y(e)),t}registry(...t){return V(this.window,"realdom",this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,e,r){let{window:n}=this,o=new Set,a=new WeakMap;for(let[s,u]of this.registry(t)){let c=[].concat(e).filter(f=>oe(n,s.context,f.target,s.params.subtree==="cross-roots",a));if(!c.length)continue;let l=[s,Array.isArray(e)?c:c[0]];u?o.add(l):r.call(n,...l)}for(let s of o)r.call(n,...s);o.clear()}disconnectables(t,...e){let r={disconnect(){e.forEach(n=>n&&I(n.disconnect)&&n.disconnect()||I(n)&&n()||T(n)&&(n.disconnected=!0))}};return t&&t.addEventListener("abort",()=>r.disconnect()),r}};var dt=class extends At{type="attr";constructor(t,...e){super(t,"attr",...e)}get(t,e=void 0,r={}){let n=typeof t=="string"||t instanceof Y;[t=[],e=void 0,r={}]=this.resolveArgs(arguments);let{context:o}=this,a=Ir(o,t);if(!e)return a;let s=r.lifecycleSignals&&this.createSignalGenerator();if(n)for(let u of a){let c=s?s.generate():{};e(u,c,o)}else{let u=s?.generate()||{};e(a,u,o)}if(r.live){s&&(r={...r,signalGenerator:s});let u=this.observe(n?t[0]:t,e,{newValue:!0,...r});return this.disconnectables(r.signal,u)}}observe(t,e,r={}){let n=typeof t=="string"||t instanceof Y;if([t=[],e,r={}]=this.resolveArgs(arguments),["sync","intercept"].includes(r.timing))return this.observeSync(n?t[0]:t,e,r);if(r.timing&&r.timing!=="async")throw new Error(`Timing option "${r.timing}" invalid.`);let{context:o,window:a,webqit:s}=this;r.eventDetails&&!s.realdom.attrInterceptionHooks?.intercepting&&Cr.call(a,"intercept",()=>{});let u=new a.MutationObserver(d=>{d=Tr(d).map(h=>Mr.call(a,h)),Pr.call(a,f,d,o)}),c={attributes:!0,attributeOldValue:r.oldValue,subtree:r.subtree&&!0};t.length&&(c.attributeFilter=t.map(d=>d+"")),u.observe(o,c);let l=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),f={context:o,spec:t,callback:e,params:r,atomics:new Map,originalFilterIsString:n,signalGenerator:l,disconnectable:u};return this.disconnectables(r.signal,u,l)}observeSync(t,e,r={}){let n=typeof t=="string"||t instanceof Y;[t,e,r={}]=this.resolveArgs(arguments);let{context:o,window:a}=this;if(r.timing&&!["sync","intercept"].includes(r.timing))throw new Error(`Timing option "${r.timing}" invalid.`);let s=r.timing==="intercept"?"intercept":"sync";this.registry(s).size||Cr.call(a,s,d=>{this.forEachMatchingContext(s,d,Pr)});let u={disconnect(){f.delete(l)}},c=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),l={context:o,spec:t,callback:e,params:r,atomics:new Map,originalFilterIsString:n,signalGenerator:c,disconnectable:u},f=this.registry(s);return f.set(l,!!l.params.deferred),this.disconnectables(r.signal,u,c)}};function Tr(i){return i.reduce((t,e,r)=>t[r-1]?.attributeName===e.attributeName||V(e.target,"realdom","internalAttrInteractions").get(e.attributeName)?t:t.concat(e),[])}function Pr(i,t){let{context:e,spec:r,callback:n,params:o,atomics:a,originalFilterIsString:s,signalGenerator:u}=i;if(o.subtree||(t=t.filter(d=>d.target===e)),!t.length)return;let c=r.map(d=>d+"");if(o.atomic&&!a.size?t=Ir(e,r,t):o.timing!=="async"&&r.length&&(t=t.filter(d=>c.includes(d.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(d=>{let h;return o.eventDetails||({event:h,...d}=d),!o.oldValue&&"oldValue"in d&&({oldValue:h,...d}=d),!o.newValue&&"value"in d?{value:h,...d}=d:o.newValue&&typeof d.value>"u"&&(d={...d,value:he(d.target,d.name,()=>d.target.getAttribute(d.name))}),d})),o.atomic&&(t.forEach(d=>a.set(d.name,d)),t=Array.from(a.entries()).map(([,d])=>d));let l=s?t[0]:t,f=u?u.generate():{};n(l,f,e)}function he(i,t,e){let r=V(i,"realdom","internalAttrInteractions").get(t);V(i,"realdom","internalAttrInteractions").set(t,!0);let n=e();return V(i,"realdom","internalAttrInteractions").set(t,r),n}function Ir(i,t,e=[]){let r={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",e.find(a=>a.name===o)||{target:i,name:o,value:he(i,o,()=>i.getAttribute(o)),...r})):Array.from(i.attributes).map(o=>e.find(a=>a.name===o.nodeName)||{target:i,name:o.nodeName,value:he(i,o.nodeName,()=>o.nodeValue),...r})}function Mr({target:i,attributeName:t,value:e,oldValue:r}){let a=(this.webqit.realdom.attrInterceptionRecords?.get(i)||{})[t]?.[0]||"mutation";return{target:i,name:t,value:e,oldValue:r,type:"observation",event:a}}function Cr(i,t){let e=this,{webqit:r,document:n,Element:o}=e;r.realdom.attrInterceptionHooks||Object.defineProperty(r.realdom,"attrInterceptionHooks",{value:new Map}),r.realdom.attrInterceptionHooks.has(i)||r.realdom.attrInterceptionHooks.set(i,new Set),r.realdom.attrInterceptionHooks.get(i).add(t);let a=()=>r.realdom.attrInterceptionHooks.get(i).delete(t);if(r.realdom.attrInterceptionHooks?.intercepting)return a;console.warn("Attr mutation APIs are now being intercepted."),r.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(r.realdom,"attrInterceptionRecords",{value:new Map});let s=(l,f)=>{r.realdom.attrInterceptionRecords.has(l.target)||r.realdom.attrInterceptionRecords.set(l.target,{});let d=r.realdom.attrInterceptionRecords.get(l.target);if(d[l.name]=d[l.name]||[],d[l.name].unshift(l.event),V(l.target,"realdom","internalAttrInteractions").get(l.name))return f();r.realdom.attrInterceptionHooks.get("intercept")?.forEach(p=>p([l]));let h=f();return r.realdom.attrInterceptionHooks.get("sync")?.forEach(p=>p([l])),h};new e.MutationObserver(l=>{l=l.filter(f=>!(e.webqit.realdom.attrInterceptionRecords?.get(f.target)||{})[f.attributeName]?.shift()),l=Tr(l).map(f=>Mr.call(e,f)),l.length&&(r.realdom.attrInterceptionHooks.get("intercept")?.forEach(f=>f(l)),r.realdom.attrInterceptionHooks.get("sync")?.forEach(f=>f(l)))}).observe(n,{attributes:!0,subtree:!0,attributeOldValue:!0});let c=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{c[l]=o.prototype[l],o.prototype[l]=function(...f){let d,h=he(this,f[0],()=>this.getAttribute(f[0]));["setAttribute","toggleAttribute"].includes(l)&&(d=f[1]),l==="toggleAttribute"&&d===void 0&&(d=h===null);let p={target:this,name:f[0],value:d,oldValue:h,type:"interception",event:[this,l]};return s(p,()=>c[l].call(this,...f))}}),a}var se=class extends At{constructor(t,...e){super(t,"tree",...e)}attr(t,e=void 0,r={}){let{context:n,window:o}=this;return new dt(n,o).get(...arguments)}query(t,e=void 0,r={}){[t,e=void 0,r={}]=this.resolveArgs(arguments);let{context:n}=this,o=new Map,a=c=>(o.has(c)||o.set(c,{target:c,entrants:[],exits:[],type:"query",event:null}),o.get(c));if(!r.generation||r.generation==="entrants"){if(!t.length)[...n.children].forEach(c=>a(n).entrants.push(c));else if(t.every(c=>c.type==="selector")){let[c,l]=t.reduce(([d,h],p)=>p.kind==="xpath"?[d,h.concat(p)]:[d.concat(p),h],[[],[]]),f=[];r.subtree?(c.length&&f.push(...n.querySelectorAll(c.join(","))),l.length&&f.push(...Nt(this.window,n,l))):(c.length&&f.push(...[...n.children].filter(d=>d.matches(c))),l.length&&f.push(...Nt(this.window,n,l,!1))),f.forEach(d=>a(d.parentNode||n).entrants.push(d))}}if(!e)return o;let s={disconnected:!1},u=e&&r.lifecycleSignals&&this.createSignalGenerator();for(let[,c]of o){if(s.disconnected)break;let l=u?.generate()||{};e(c,l,n)}if(r.live){u&&(r={...r,signalGenerator:u});let c=this.observe(t,e,r);return this.disconnectables(r.signal,s,c)}return this.disconnectables(r.signal,s,u)}children(t,e=void 0,r={}){return[t,e=void 0,r={}]=this.resolveArgs(arguments),this.query(t,e,{...r,subtree:!1})}subtree(t,e=void 0,r={}){return[t,e=void 0,r={}]=this.resolveArgs(arguments),this.query(t,e,{...r,subtree:!0})}observe(t,e,r={}){if([t,e,r={}]=this.resolveArgs(arguments),["sync","intercept"].includes(r.timing))return this.observeSync(t,e,r);if(r.timing&&r.timing!=="async")throw new Error(`Timing option "${r.timing}" invalid.`);let{context:n,window:o,webqit:a,document:s}=this;r.eventDetails&&(a.realdom.domInterceptionRecordsAlwaysOn=!0),(s.readyState==="loading"||a.realdom.domInterceptionRecordsAlwaysOn)&&!a.realdom.domInterceptionHooks?.intercepting&&Rr.call(o,"sync",()=>{});let u=new o.MutationObserver(f=>f.forEach(d=>{Ge.call(o,l,kr.call(o,d),n)}));u.observe(n,{childList:!0,subtree:r.subtree&&!0});let c=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),l={context:n,spec:t,callback:e,params:r,signalGenerator:c,disconnectable:u};if(r.staticSensitivity){let f=qr.call(o,l);return this.disconnectables(r.signal,u,c,f)}return this.disconnectables(r.signal,u,c)}observeSync(t,e,r={}){[t,e,r={}]=this.resolveArgs(arguments);let{context:n,window:o}=this;if(r.timing&&!["sync","intercept"].includes(r.timing))throw new Error(`Timing option "${r.timing}" invalid.`);let a=r.timing==="intercept"?"intercept":"sync";this.registry(a).size||Rr.call(o,a,d=>{this.forEachMatchingContext(a,d,Ge)});let s=new o.MutationObserver(d=>d.forEach(h=>{Array.isArray((h=kr.call(o,h)).event)||Ge.call(o,l,h,n)}));s.observe(n,{childList:!0,subtree:r.subtree&&!0});let u={disconnect(){f.delete(l),s.disconnect()}},c=r.signalGenerator||r.lifecycleSignals&&this.createSignalGenerator(),l={context:n,spec:t,callback:e,params:r,signalGenerator:c,disconnectable:u},f=this.registry(a);if(f.set(l,!!l.params.deferred),r.staticSensitivity){let d=qr.call(o,l);return this.disconnectables(r.signal,u,c,d)}return this.disconnectables(r.signal,u,c)}track(t,e,r={}){return r={subtree:!0,...r},this.observe(t,n=>{n.entrants.length&&e(!0,Array.isArray(t)?n.entrants:n.entrants[0]),n.exits.length&&e(!1,Array.isArray(t)?n.exits:n.exits[0])},r)}};function qr(i){let t=this,{context:e,spec:r,callback:n,params:o,signalGenerator:a}=i,s=r.filter(h=>h.kind==="css"),u=h=>h.match(/\.([\w-]+)/g)?.length?["class"]:[],c=h=>h.match(/#([\w-]+)/g)?.length?["id"]:[],l=h=>[...h.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(p=>p[1]).concat(u(h)).concat(c(h));if(!(i.$attrs=Array.from(new Set(s.filter(h=>(h+"").includes("[")).reduce((h,p)=>h.concat(l(p+"")),[])))).length)return;let f=new Set,d=new Set;return f.push=h=>(d.delete(h),f.add(h)),d.push=h=>(f.delete(h),d.add(h)),i.$deliveryCache={entrants:f,exits:d},new dt(e,t).observe(i.$attrs,h=>{let p=new Map,v=w=>(p.has(w)||p.set(w,{target:w,entrants:[],exits:[],type:"static",event:null}),p.get(w)),O=new WeakMap,g=w=>(O.has(w)||O.set(w,s.some(b=>w.matches(b+""))),O.get(w));for(let w of h)["entrants","exits"].forEach(b=>{o.generation&&b!==o.generation||i.$deliveryCache[b].has(w.target)||(b==="entrants"?!g(w.target):g(w.target))||(i.$deliveryCache[b].push(w.target),v(w.target)[b].push(w.target),v(w.target).event=w.event)});for(let[,w]of p){let b=a?.generate()||{};n(w,b,e)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function Ge(i,t){let{context:e,spec:r,callback:n,params:o,signalGenerator:a,$deliveryCache:s}=i,u={...t,entrants:[],exits:[]};if(o.eventDetails||delete u.event,["entrants","exits"].forEach(l=>{if(!(o.generation&&l!==o.generation)&&(r.length?u[l]=ki.call(this,r,o.subtree==="cross-roots",t[l],t.event!=="parse"):u[l]=[...t[l]],!!s))for(let f of u[l])s[l].push(f)}),!u.entrants.length&&!u.exits.length)return;let c=a?.generate()||{};n(u,c,e)}function ki(i,t,e,r){e=Array.isArray(e)?e:[...e];let n=(o,a)=>{if(a.type==="selector"){let s=a.isXpathAttr?[]:o.filter(u=>a.kind==="xpath"?$r(this,u,a+""):u.matches&&u.matches(a+""));if((r||a.isXpathAttr)&&(s=o.reduce((u,c)=>a.kind==="xpath"?[...u,...Nt(this,c,a,r)]:c.querySelectorAll?[...u,...c.querySelectorAll(a+"")]:u,s)),s.length)return s}else if(o.includes(a.content)||r&&o.some(s=>oe(this,s,a.content,t)))return[a.content]};return e.$$searchCache||(e.$$searchCache=new Map),i.reduce((o,a)=>{let s;return e.$$searchCache.has(a.content)?s=e.$$searchCache.get(a.content):(s=n(e,a)||[],a.type==="instance"&&e.$$searchCache.set(a.content,s)),o.concat(s)},[])}function kr({target:i,addedNodes:t,removedNodes:e}){let r=this,n;return n=j(t).reduce((o,a)=>o||r.webqit.realdom.domInterceptionRecords?.get(a),null),n=j(e).reduce((o,a)=>o||r.webqit.realdom.domInterceptionRecords?.get(a),n),n=n||r.document.readyState==="loading"&&"parse"||"mutation",{target:i,entrants:t,exits:e,type:"observation",event:n}}function Rr(i,t){let e=this,{webqit:r,document:n,Node:o,CharacterData:a,Element:s,HTMLElement:u,HTMLTemplateElement:c,DocumentFragment:l}=e;r.realdom.domInterceptionHooks||Object.defineProperty(r.realdom,"domInterceptionHooks",{value:new Map}),r.realdom.domInterceptionNoRecurse||Object.defineProperty(r.realdom,"domInterceptionNoRecurse",{value:new Map}),r.realdom.domInterceptionHooks.has(i)||r.realdom.domInterceptionHooks.set(i,new Set),r.realdom.domInterceptionHooks.get(i).add(t);let f=()=>r.realdom.domInterceptionHooks.get(i).delete(t);if(r.realdom.domInterceptionHooks?.intercepting)return f;console.warn("DOM mutation APIs are now being intercepted."),r.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(r.realdom,"domInterceptionRecords",{value:new Map});let d=(g,w,b)=>{r.realdom.domInterceptionNoRecurse.set(g,w);let y=b();return r.realdom.domInterceptionNoRecurse.delete(g),y},h=(g,w)=>{g.entrants.concat(g.exits).forEach(y=>{clearTimeout(r.realdom.domInterceptionRecords.get(y)?.timeout),r.realdom.domInterceptionRecords.set(y,g.event);let m=setTimeout(()=>{r.realdom.domInterceptionRecords.delete(y)},0);Object.defineProperty(g.event,"timeout",{value:m,configurable:!0})}),r.realdom.domInterceptionHooks.get("intercept")?.forEach(y=>y(g));let b=w();return r.realdom.domInterceptionHooks.get("sync")?.forEach(y=>y(g)),b},p={ShadowRoot:["innerHTML","setHTMLUnsafe"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTMLUnsafe","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},v={ShadowRoot:Object.create(null),DocumentFragment:Object.create(null),Document:Object.create(null),HTMLElement:Object.create(null),Element:Object.create(null),CharacterData:Object.create(null),Node:Object.create(null)};return new Set(Object.values(p).reduce((g,w)=>g.concat(w),[])).forEach(g=>{Object.keys(p).forEach(y=>{if(!p[y].includes(g))return;let m=Object.getOwnPropertyDescriptor(e[y].prototype,g);!m||(Object.defineProperty(e[y].prototype,g,"value"in m?{...m,value:w}:{...m,set:b}),v[y][g]=m)});function w(...y){let m=Object.keys(v).find(L=>this instanceof e[L]&&g in v[L]),_=v[m],x=()=>_[g].value.call(this,...y);if(r.realdom.domInterceptionNoRecurse.get(this)===g)return x();let $=[],A=[],C=this;["insertBefore"].includes(g)?A=[y[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(g)?(A=[y[1]],["beforebegin","afterend"].includes(y[0])&&(C=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(g)?($=[...this.childNodes],A=g==="replaceChildren"?[...y]:[y[0]]):["replaceWith","remove"].includes(g)?($=[this],A=g==="replaceWith"?[...y]:[],C=this.parentNode):["replaceChild"].includes(g)?($=[y[1]],A=[y[0]]):["removeChild"].includes(g)?$=[...y]:(A=[...y],["before","after"].includes(g)&&(C=this.parentNode));let k=g;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(g)){let L=this.nodeName;if(g==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(y[0])){if(!this.parentNode)return _[g].value.call(this,...y);L=this.parentNode.nodeName}let H=n.createElement(L.includes("-")?"div":L);_.setHTMLUnsafe.value.call(H,A[0],g==="setHTMLUnsafe"?y[1]:{}),A=[...H.childNodes],g==="insertAdjacentHTML"?(k="insertAdjacentElement",y[1]=new l,d(y[1],"append",()=>y[1].append(...H.childNodes))):(k="replaceChildren",y=[...H.childNodes])}return h({target:C,entrants:A,exits:$,type:"interception",event:[this,g]},()=>_[k].value.call(this,...y))}function b(y){let m=Object.keys(v).find(N=>this instanceof e[N]&&g in v[N]),_=v[m],x=()=>_[g].set.call(this,y);if(this instanceof HTMLScriptElement||r.realdom.domInterceptionNoRecurse.get(this)===g)return x();let $=[],A=[],C=this;if(["outerHTML","outerText"].includes(g)?($=[this],C=this.parentNode):this instanceof c?(C=this.content,$=[...this.content.childNodes]):$=[...this.childNodes],["outerHTML","innerHTML"].includes(g)){let N=this.nodeName;if(g==="outerHTML"){if(!this.parentNode)return x();N=this.parentNode.nodeName}let L=n.createElement(N.includes("-")?"div":N);if(d(L,g,()=>L[g]=y),A=this instanceof c?[...L.content.childNodes]:[...L.childNodes],this instanceof c&&this.hasAttribute("src")||this instanceof ShadowRoot){let H=gt=>gt.reduce((nt,ot)=>ot instanceof HTMLScriptElement?nt.concat(ot):ot instanceof c?nt.concat(H([ot.content])):(nt=nt.concat(H([...ot.querySelectorAll?.("template")||[]].map(Zr=>Zr.content))),nt.concat(...ot.querySelectorAll?.("script")||[])),[]);for(let gt of H(A)){if(this instanceof ShadowRoot){gt.setAttribute("data-handling","manual");continue}let nt=n.createElement("script");[...gt.attributes].forEach(ot=>nt.setAttribute(ot.name,ot.value)),nt.textContent=gt.textContent,d(gt,"replaceWith",()=>gt.replaceWith(nt))}}g==="outerHTML"?(y=new l,d(y,"append",()=>y.append(...A)),x=()=>d(this,"replaceWith",()=>s.prototype.replaceWith.call(this,y))):this instanceof c?x=()=>d(this.content,"replaceChildren",()=>this.content.replaceChildren(...A)):x=()=>d(this,"replaceChildren",()=>s.prototype.replaceChildren.call(this,...A))}return h({target:C,entrants:A,exits:$,type:"interception",event:[this,g]},x)}}),f}function jr(){Ri.call(this),ji.call(this),Ni.call(this)}function Ri(){let i=this;i.CSS||(i.CSS={}),i.CSS.escape||(i.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function ji(){let i=this;"isConnected"in i.Node.prototype||Object.defineProperty(i.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function Ni(){let i=this;i.Element.prototype.matches||(i.Element.prototype.matches=i.Element.prototype.matchesSelector||i.Element.prototype.mozMatchesSelector||i.Element.prototype.msMatchesSelector||i.Element.prototype.oMatchesSelector||i.Element.prototype.webkitMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),r=e.length;--r>=0&&e.item(r)!==this;);return r>-1})}function Nr(){let i=this;if(i.webqit||(i.webqit={}),i.webqit.realdom)return i.webqit.realdom;i.webqit.realdom={},jr.call(i),i.webqit.realdom.meta=(...e)=>Di.call(i,...e),i.webqit.realdom.ready=(...e)=>Qe.call(i,...e),i.webqit.realdom.realtime=(e,r="dom")=>{if(r==="dom")return new se(e,i);if(r==="attr")return new dt(e,i)};let t=new ne(i);return i.webqit.realdom.schedule=(e,...r)=>t[`on${e}`](...r),i.webqit.realdom.synthesizeWhile=(...e)=>t.synthesizeWhile(...e),i.webqit.realdom}function Qe(...i){let t="interactive",e;Mt(i[0])?(t=i[0],I(i[1])&&(e=i[1])):I(i[0])&&(e=i[0]);let r={interactive:["interactive","complete"],complete:["complete"]};if(!r[t])throw new Error(`Invalid ready-state timing: ${t}.`);let n=this;if(!e)return n.webqit.realdom.readyStatePromises||(n.webqit.realdom.readyStatePromises={interactive:new Promise(o=>Qe.call(this,"interactive",o)),complete:new Promise(o=>Qe.call(this,"complete",o))}),n.webqit.realdom.readyStatePromises[t];if(r[t].includes(n.document.readyState))return e(n);n.webqit.realdom.readyStateCallbacks||(n.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},n.document.addEventListener("readystatechange",()=>{let o=n.document.readyState;for(let a of n.webqit.realdom.readyStateCallbacks[o].splice(0))a(n)},!1)),n.webqit.realdom.readyStateCallbacks[t].push(e)}function Di(i){let t=this,e={},r;return(r=t.document.querySelector(`meta[name="${i}"]`))&&(e=(r.content||"").split(";").filter(n=>n).reduce((n,o)=>{let a=o.split("=").map(s=>s.trim());return ze(n,a[0].split("."),a[1]==="true"?!0:a[1]==="false"?!1:X(a[1])?parseInt(a[1]):a[1]),n},{})),{get name(){return i},get content(){return r.content},json(){return JSON.parse(JSON.stringify(e))}}}function me(i,t){return typeof i!="string"?i:i.replace(/\w\S*/g,function(e){return e.charAt(0).toUpperCase()+(typeof t!==void 0&&t?e.substr(1).toLowerCase():e.substr(1))})}var S=(i,...t)=>V(i,"oohtml",...t),q={};function z(i,t,e){let r=this,n=Nr.call(r);q.window=r,r.webqitConfig||(r.webqitConfig=n.meta("webqit").json()),r.webqit||(r.webqit={}),r.webqit.oohtml||(r.webqit.oohtml={}),r.webqit.oohtml.configs||(r.webqit.oohtml.configs={});let o=i.toUpperCase().replace("-","_");if(!r.webqit.oohtml.configs[o]){r.webqit.oohtml.configs[o]={};let a=r.webqit.oohtml.configs[o];Ut(2,a,e,t,n.meta(i).json()),r.webqitConfig.prefix&&Object.keys(a).forEach(s=>{Object.keys(a[s]).forEach(u=>{s==="api"&&typeof a[s][u]=="string"?a[s][u]=`${r.webqitConfig.prefix}${me(a[s][u])}`:["attr","elements"].includes(s)&&a[s][u]?.startsWith("data-")===!1&&(a[s][u]=`${r.webqitConfig.prefix}-${a[s][u]}`)})})}return{config:r.webqit.oohtml.configs[o],realdom:n,window:r}}function Je(i,t){return S(i,"internalAttrInteractions").get(t)}function Lr(i,t,e){let r=S(i,"internalAttrInteractions").get(t);S(i,"internalAttrInteractions").set(t,!0);let n=e();return S(i,"internalAttrInteractions").set(t,r),n}function ut(i,t){return[...i].reduce(([e,r,n],o)=>!e&&r===0&&(Array.isArray(t)?t:[t]).includes(o)?[e,r,[""].concat(n)]:(!e&&["(","[","{"].includes(o)&&!n[0].endsWith("\\")&&r++,!e&&[")","]","}"].includes(o)&&!n[0].endsWith("\\")&&r--,['"',"'","`"].includes(o)&&!n[0].endsWith("\\")&&(e=e===o?null:e||o),n[0]+=o,[e,r,n]),[null,0,[""]])[2].reverse()}var Fi=()=>(0|Math.random()*9e6).toString(36),Xe=new Map;function $t(i){let t;return(t=Xe.get(i))||(t=Fi(),Xe.set(i,t)),t}function ge(i){let t;return Xe.forEach((e,r)=>{e===i&&(t=r)}),t}function ye(){let{window:i}=q,{webqit:t}=i;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class e extends i.Event{constructor(...n){let o=n.pop();if(typeof o!="function")throw new Error("Callback must be provided.");let a=n.pop();if(!a?.kind)throw new Error('"options.kind" must be specified.');let s=["contextrequest","contextclaim"],u=n.pop()||s[0];if(!s.includes(u))throw new Error(`Invalid event type. Must be one of: ${s.join(",")}`);let{kind:c,detail:l,targetContext:f,live:d,signal:h,diff:p,...v}=a;super(u,{...v,bubbles:v.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>c}),Object.defineProperty(this,"targetContext",{get:()=>f}),Object.defineProperty(this,"detail",{get:()=>l}),Object.defineProperty(this,"live",{get:()=>d}),Object.defineProperty(this,"signal",{get:()=>h}),Object.defineProperty(this,"diff",{get:()=>p}),Object.defineProperty(this,"options",{get:()=>v}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(n){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===n)return;Object.defineProperty(this,"_prevValue",{value:n,configurable:!0})}return this.callback(n)}}return t.DOMContextRequestEvent=e,e}var Et=class extends AbortController{constructor(t){super(),t(e=>{let{window:{webqit:{Observer:r}}}=q;r.defineProperty(this,"value",{value:e,configurable:!0,enumerable:!0})},this)}};var Pt=class extends Error{};var pt=class{static instance(t){return S(t).get("contexts::instance")||new this(t)}constructor(t){S(t).get("contexts::instance")?.dispose(),S(t).set("contexts::instance",this);let e={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>e})}[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]()}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(e=>typeof t[0]=="function"?t[0](e):e.constructor.kind===t[0]&&(!t[1]||e.detail===t[1]))}attach(t){if(!(t instanceof U))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new Pt(`Context of same kind "${t.constructor.kind}"${t.detail?` and detail "${t.detail}"`:""} already exists.`);this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}request(...t){return new Et((e,r)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(e):t[t.length-1]=e);let n;(n=t.find(a=>typeof a=="object"&&a))&&n.live&&(n.signal&&n.signal.addEventListener("abort",()=>r.abort()),t[t.indexOf(n)]={...n,signal:r.signal});let o=new(ye())(...t);this["#"].host.dispatchEvent(o)})}};var Ye=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=q;return t}get name(){return[q.window.Document,q.window.ShadowRoot].some(t=>this.host instanceof t)?1/0:this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname)}subscribed(t){}handle(t){}unsubscribed(t){}matchEvent(t){return t.kind===this.constructor.kind&&(!t.targetContext||t.targetContext===this.name)}handleEvent(t){if(!(this.disposed||typeof t.respondWith!="function")){if(t.type==="contextclaim"){if(!(t.detail instanceof Ye)||t.target===this.host)return;let e=new Set;if(this.subscriptions.forEach(r=>{!t.target.contains(r.target)||!t.detail.matchEvent(r)||(this.subscriptions.delete(r),this.unsubscribed(r),e.add(r))}),e.size)return t.respondWith(e)}if(t.type==="contextrequest")return this.matchEvent(t)?(t.live&&(this.subscriptions.add(t),this.subscribed(t),t.signal?.addEventListener("abort",()=>{this.subscriptions.delete(t),this.unsubscribed(t)})),t.stopPropagation(),this.handle(t)):void 0}}initialize(t){this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this);let{value:e}=pt.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return e?.forEach(r=>{this.subscriptions.add(r),this.subscribed(r),this.handle(r)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(e=>{this.subscriptions.delete(e),this.unsubscribed(e);let{target:r}=e;e.meta.answered=!1,r.dispatchEvent(e)}),this}},U=Ye;W(U,"kind");var Dt=class extends U{static createRequest(t=null){let e=super.createRequest();if(t?.startsWith("@")){let[r,...n]=n.slice(1).split("/").map(o=>o.trim());e.targetContext=r,e.detail=n.join("/")}else e.detail=t;return e}get namespaceObj(){return this.host[this.configs.NAMESPACED_HTML.api.namespace]}handle(t){let{window:{webqit:{Observer:e}}}=q;if(t.meta.controller?.abort(),!(t.detail||"").trim())return t.respondWith(e.unproxy(this.namespaceObj));let r=(t.detail||"").split("/").map(n=>n.trim()).filter(n=>n);if(!r.length)return t.respondWith();r=r.join(`/${this.configs.NAMESPACED_HTML.api.namespace}/`)?.split("/")||[],t.meta.controller=e.reduce(this.namespaceObj,r,e.get,n=>{this.disposed||t.respondWith(n.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};W(Dt,"kind","namespace");function Ze(i={}){let{config:t,window:e}=z.call(this,"namespaced-html",i,{attr:{namespace:"namespace",lid:"id"},api:{namespace:"namespace"},tokens:{lidrefPrefix:"~",lidrefSeparator:":"},target:{className:":target",eventName:":target",scrolling:!0}});t.lidSelector=`[${e.CSS.escape(t.attr.lid)}]`,t.namespaceSelector=`[${e.CSS.escape(t.attr.namespace)}]`,e.webqit.DOMNamingContext=Dt,Wi.call(e,t),Bi.call(e,t)}function Hr(i){let{lidrefPrefix:t,lidrefSeparator:e}=i.tokens;return{escape(r,n=1){return[...r].map(o=>/\w/.test(o)?o:n===2?`\\\\${o}`:`\\${o}`).join("")},lidrefPrefix(r=0){return r?this.escape(t,r):t},lidrefSeparator(r=0){return r?this.escape(e,r):e},isUuid(r,n=0){return r.startsWith(this.lidrefPrefix(n))&&r.includes(this.lidrefSeparator(n))},toUuid(r,n,o=0){return r.endsWith("-root")?n:`${this.lidrefPrefix(o)}${r}${this.lidrefSeparator(o)}${n}`},uuidToId(r,n=0){return this.isUuid(r)?r.split(this.lidrefSeparator(n))[1]:r},uuidToLidref(r,n=0){return this.isUuid(r)?`${this.lidrefPrefix(n)}${r.split(this.lidrefSeparator(n))[1]}`:r}}}function Ke(i,t,e=null,r=0){let n=this,{webqit:{oohtml:{configs:{NAMESPACED_HTML:o}}}}=n,a=Hr(o),s=new RegExp(`${e?":scope|":""}#(${a.lidrefPrefix(r+1)})?([\\w]+${a.lidrefSeparator(r+1)})?((?:[\\w-]|\\\\.)+)`,"g"),[u,c]=ut(i,",").reduce(([f,d],h)=>{let p,v;return h=h.replace(s,(O,g,w,b,y)=>{if(p||(p=[...h.matchAll(/(["'])(?:(?=(\\?))\2.)*?\1/g)]),p.some($=>y>$.index&&y+O.length<$.index+$[0].length))return O;if(O===":scope")return v=!0,e;let m=g&&!w;if(g&&w)return`#${a.escape(O.replace("#",""),1)}`;if(m&&o.attr.lid==="id"&&t&&!t.endsWith("-root"))return`#${a.toUuid(t,b,1)}`;let x;return o.attr.lid==="id"?x=`:is(#${b},[id^="${a.lidrefPrefix(r)}"][id$="${a.lidrefSeparator(r)}${b}"])`:x=`:is(#${b},[${n.CSS.escape(o.attr.lid)}="${b}"])`,m?`:is(${x}):not(${e?e+" ":""}${o.namespaceSelector} *)`:x}),v?[f,d.concat(h)]:[f.concat(h),d]},[[],[]]),l;return e&&u.length?l=[u.length>1?`${e} :is(${u.join(", ")})`:`${e} ${u[0]}`,c.join(", ")].filter(f=>f).join(", "):l=[...u,...c].join(", "),l}function we(i){let t=this;if(!S(i).has("namespace")){let e=Object.create(null);S(i).set("namespace",e);let r=[t.Document,t.ShadowRoot].some(n=>i instanceof n);Object.defineProperty(e,Symbol.toStringTag,{get(){return r?"RootNamespaceRegistry":"NamespaceRegistry"}})}return S(i).get("namespace")}function Lt(i,t=!1){let e=this,{webqit:{oohtml:{configs:{NAMESPACED_HTML:r}}}}=e,n=[e.Document,e.ShadowRoot].some(o=>i instanceof o);return we.call(e,n?i:(t?i.parentNode:i)?.closest?.(r.namespaceSelector)||i.getRootNode())}function be(i){let t=Object.prototype.toString.call(i)==="[object RootNamespaceRegistry]";return(ge(i)||$t(i))+(t?"-root":"")}function Wi(i){let t=this,{webqit:{Observer:e}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let n=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.namespace in r)throw new Error(`The ${n} prototype already has a "${i.api.namespace}" API!`);Object.defineProperty(r,i.api.namespace,{get:function(){return e.proxy(we.call(t,this))}})})}function Bi(i){let t=this,{webqit:{Observer:e,realdom:r,oohtml:{configs:n},DOMNamingContext:o}}=t,a=["aria-owns","aria-controls","aria-labelledby","aria-describedby","aria-flowto"],s=["for","list","form","aria-activedescendant","aria-details","aria-errormessage"],u=[i.attr.lid,...a,...s],c={id:"id",for:"htmlFor","aria-owns":"ariaOwns","aria-controls":"ariaControls","aria-labelledby":"ariaLabelledBy","aria-describedby":"ariaDescribedBy","aria-flowto":"ariaFlowto","aria-activedescendant":"ariaActiveDescendant","aria-details":"ariaDetails","aria-errormessage":"ariaErrorMessage"},l=Hr(i),f=(m,_,x)=>{if(!Je(m,_)&&S(m,"attrOriginals").has(_))return S(m,"attrOriginals").get(_);let $=x();return Je(m,_)?$:$&&$.split(" ").map(A=>(A=A.trim())&&(_===i.attr.lid?l.uuidToId:l.uuidToLidref).call(l,A)).join(" ")},d=Object.getOwnPropertyDescriptor(t.Document.prototype,"getElementById");Object.defineProperty(t.Document.prototype,"getElementById",{...d,value(m){return this.querySelector(`#${m}`)}});for(let m of["querySelector","querySelectorAll"])for(nodeApi of[t.Document,t.Element]){let _=Object.getOwnPropertyDescriptor(nodeApi.prototype,m);Object.defineProperty(nodeApi.prototype,m,{..._,value(x){return _.value.call(this,Ke.call(t,x,be(we.call(t,this))))}})}let h=Object.getOwnPropertyDescriptor(t.Element.prototype,"getAttribute");Object.defineProperty(t.Element.prototype,"getAttribute",{...h,value(m){let _=()=>h.value.call(this,m);return u.includes(m)&&!S(this,"lock").get(m)?f(this,m,_):_()}});let p=Object.getOwnPropertyDescriptor(t.Attr.prototype,"value");Object.defineProperty(t.Attr.prototype,"value",{...p,get(){let m=()=>p.get.call(this);return u.includes(this.name)?f(this.ownerElement,this.name,m):m()}});let v=Object.getOwnPropertyDescriptor(t.Node.prototype,"nodeValue");Object.defineProperty(t.Node.prototype,"nodeValue",{...v,get(){let m=()=>v.get.call(this);return this instanceof t.Attr&&u.includes(this.name)?f(this.ownerElement,this.name,m):m()}});for(let m of u){if(!(m in c))continue;let _=m==="for"?[t.HTMLLabelElement,t.HTMLOutputElement]:[t.Element];for(let x of _){let $=Object.getOwnPropertyDescriptor(x.prototype,c[m]);!$||Object.defineProperty(x.prototype,c[m],{...$,get(){return f(this,m,()=>$.get.call(this,m))}})}}i.attr.lid!=="id"&&Object.defineProperty(t.Element.prototype,i.attr.lid,{configurable:!0,enumerable:!0,get(){return this.getAttribute(i.attr.lid)},set(m){return this.setAttribute(i.attr.lid,m)}});let O=(m,_,x,$)=>Lr(m,_,()=>(typeof x=="function"&&(x=x()),$(x))),g=(m,_,x,$=null)=>{O(m,_,x,A=>{let C=_===i.attr.lid,k=$||Lt.call(t,m,C),N=be(k);if(C){let L=l.uuidToId(A);if(e.get(k,L)!==m){let H=l.toUuid(N,L);H!==A&&m.setAttribute("id",H),e.set(k,L,m)}}else{S(m,"attrOriginals").set(_,A);let L=A.split(" ").map(H=>(H=H.trim())&&l.isUuid(H)?H:l.toUuid(N,H)).join(" ");m.setAttribute(_,L),S(k).set("idrefs",S(k).get("idrefs")||new Set),S(k).get("idrefs").add(m)}})},w=(m,_,x,$=null)=>{O(m,_,x,A=>{let C=_===i.attr.lid,k=$||Lt.call(t,m,C);if(C){let N=l.uuidToId(A);e.get(k,N)===m&&e.deleteProperty(k,N)}else{let N=S(m,"attrOriginals").get(_);m.hasAttribute(_)&&m.setAttribute(_,N),S(k).get("idrefs")?.delete(m)}})};r.realtime(t.document).query(i.namespaceSelector,m=>{let _=(x,$,A,C)=>{if(!x.hasAttribute($))return;let k=()=>x.getAttribute($);w(x,$,k,A),x.isConnected&&g(x,$,S(x,"attrOriginals").get($)||k,C)};m.exits.forEach(x=>{if(x.isConnected){let C=we.call(t,x);for(let k of new Set([...Object.values(C),...S(C).get("idrefs")||[]]))for(let N of u)_(k,N,C)}let $=x[n.CONTEXT_API.api.contexts],A=$.find(o.kind);A&&$.detach(A)}),m.entrants.forEach(x=>{let $,A=Lt.call(t,x,!0);for(let k of new Set([...Object.values(A),...S(A).get("idrefs")||[]]))if(($=Lt.call(t,k,!0))!==A)for(let N of u)_(k,N,A,$);let C=x[n.CONTEXT_API.api.contexts];C.find(o.kind)||C.attach(new o)})},{id:"namespace-html:namespace",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(`[${u.map(m=>t.CSS.escape(m)).join("],[")}]`,m=>{let _={forID:new Map,forOther:new Map};for(let x of u){let $=x===i.attr.lid?_.forID:_.forOther;m.exits.forEach(A=>{if(!A.hasAttribute(x))return;let C=$.get(A);typeof C>"u"&&(C=(x===i.attr.lid?A.parentNode:A)?.closest?.(i.namespaceSelector)||A.getRootNode().host,$.set(A,C)),!(C&&!C.isConnected)&&w(A,x,()=>A.getAttribute(x))}),m.entrants.forEach(A=>{!A.hasAttribute(x)||g(A,x,()=>A.getAttribute(x))})}_.forID.clear(),_.forOther.clear()},{id:"namespace-html:attrs",live:!0,subtree:"cross-roots",timing:"sync"}),r.realtime(t.document,"attr").observe(u,m=>{for(let _ of m)_.oldValue&&w(_.target,_.name,_.oldValue),_.value&&g(_.target,_.name,_.value)},{id:"namespace-html:attr(attrs)",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0});let b,y=()=>{if(!t.location.hash?.startsWith(`#${l.lidrefPrefix()}`))return;let m=t.location.hash?.substring(`#${l.lidrefPrefix()}`.length).split("/").map(x=>x.trim()).filter(x=>x)||[],_=m.reduce((x,$)=>x&&x[i.api.namespace][$],t.document);b&&i.target.className&&b.classList.toggle(i.target.className,!1),_&&_!==t.document&&(i.target.className&&_.classList.toggle(i.target.className,!0),i.target.eventName&&_.dispatchEvent(new t.CustomEvent(i.target.eventName)),i.target.scrolling&&m.length>1&&_.scrollIntoView(),b=_)};t.addEventListener("hashchange",y),r.ready(y)}function tr({advanced:i={},...t}){let{config:e,window:r}=z.call(this,"scoped-js",t,{script:{retention:"retain",mimeTypes:"module|text/javascript|application/javascript",timing:"auto"},api:{scripts:"scripts"},advanced:kt(i)}),n=Array.isArray(e.script.mimeTypes)?e.script.mimeTypes:e.script.mimeTypes.split("|").filter(o=>o);e.scriptSelector=n.map(o=>`script[type="${r.CSS.escape(o)}"]:not([oohtmlignore])`).concat("script:not([type])").join(","),r.webqit.oohtml.Script={compileCache:[new Map,new Map],execute:zi.bind(r,e)},Vi.call(r,e),Ui.call(r,e)}function Vi(i){let t=this,e=new Map;if(i.api.scripts in t.Element.prototype)throw new Error(`The "Element" class already has a "${i.api.scripts}" property!`);[t.ShadowRoot.prototype,t.Element.prototype].forEach(r=>{Object.defineProperty(r,i.api.scripts,{get:function(){return e.has(this)||e.set(this,[]),e.get(this)}})}),Object.defineProperties(t.HTMLScriptElement.prototype,{scoped:{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}},quantum:{configurable:!0,get(){return this.hasAttribute("quantum")},set(r){this.toggleAttribute("quantum",r)}}})}async function zi(i,t){let e=this,{realdom:r}=e.webqit,n=ge(t);if(!n)throw new Error("Argument must be a valid exec hash.");let{script:o,compiledScript:a,thisContext:s}=n;i.script.retention==="dispose"?o.remove():i.script.retention==="hidden"?o.textContent='"source hidden"':o.textContent=await a.toString();let u=o.scoped?s:o.getRootNode();S(u).has("scriptEnv")||S(u).set("scriptEnv",Object.create(null));let c=await(await a.bind(s,S(u).get("scriptEnv"))).execute();o.quantum&&Object.defineProperty(o,"state",{value:c}),r.realtime(e.document).observe(o,()=>{o.quantum&&c.dispose(),s instanceof e.Element&&s[i.api.scripts]?.splice(s[i.api.scripts].indexOf(o,1))},{id:"scoped-js:script-exits",subtree:"cross-roots",timing:"sync",generation:"exits"})}function Ui(i){let t=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1,e=this,{webqit:{oohtml:r,realdom:n}}=e;e.HTMLScriptElement.supports||(e.HTMLScriptElement.supports=a=>["text/javascript","application/javascript"].includes(a));let o=new WeakSet;n.realtime(e.document).query(i.scriptSelector,a=>{a.entrants.forEach(s=>{if(o.has(s)||!t&&!s.hasAttribute("ssr"))return;let u=Fr.call(e,i,s);if(!u)return;o.add(s);let c=s.scoped?s.parentNode||a.target:s.type==="module"?void 0:e;s.scoped&&c[i.api.scripts].push(s);let l=$t({script:s,compiledScript:u,thisContext:c});a.type==="query"||s.type&&!e.HTMLScriptElement.supports(s.type)||s.getAttribute("data-handling")==="manual"||i.script.timing==="manual"?r.Script.execute(l):s.textContent=`webqit.oohtml.Script.execute( '${l}' );`})},{id:"scoped-js:script-entries",live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants",eventDetails:!0})}function Fr(i,t){let e=this,{webqit:{oohtml:r,QuantumScript:n,AsyncQuantumScript:o,QuantumModule:a}}=e,s=(t._=t.textContent.trim())&&t._.startsWith("/*@oohtml*/if(false){")&&t._.endsWith("}/*@oohtml*/")?t._.slice(21,-12):t.textContent;if(!s.trim().length)return;let u=$t(s),c=r.Script.compileCache[t.quantum?0:1],l;if(!(l=c.get(u))){let{parserParams:f,compilerParams:d,runtimeParams:h}=i.advanced;l=new(t.type==="module"?a:n||o)(s,{exportNamespace:`#${t.id}`,fileName:`${e.document.url?.split("#")?.[0]||""}#${t.id}`,parserParams:{...f,executionMode:t.quantum&&"QuantumProgram"||"RegularProgram"},compilerParams:d,runtimeParams:h}),c.set(u,l)}return l}function Wr(i){let t=this,{webqit:{oohtml:{configs:{SCOPED_JS:e}}}}=t;[...i?.querySelectorAll(e.scriptSelector)||[]].forEach(r=>{Fr.call(t,e,r)})}function ir(i={}){let{config:t,window:e}=z.call(this,"data-binding",i,{attr:{render:"render",itemIndex:"data-key"},tokens:{nodeType:"processing-instruction",tagStart:"?{",tagEnd:"}?",stateStart:"; [=",stateEnd:"]"},advanced:kt({runtimeParams:{spec:{handler:n=>{}}}})});({CONTEXT_API:t.CONTEXT_API,BINDINGS_API:t.BINDINGS_API,HTML_IMPORTS:t.HTML_IMPORTS}=e.webqit.oohtml.configs),t.attrSelector=`[${e.CSS.escape(t.attr.render)}]`;let r=(n,o)=>{let a=`starts-with(., "${n}")`,s=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${a} and ${s}`};t.discreteBindingsSelector=`comment()[${r(t.tokens.tagStart,t.tokens.tagEnd)}]`,Gi.call(e,t)}function Gi(i){let t=this,{webqit:{realdom:e}}=t;e.realtime(t.document).query(i.attrSelector,r=>{Br.call(this,...r.exits),setTimeout(()=>{Xi.call(t,i,...r.entrants)},0)},{id:"data-binding:attr",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0,staticSensitivity:!0}),e.realtime(t.document).query(`(${i.discreteBindingsSelector})`,r=>{setTimeout(()=>{Br.call(this,...r.exits),Qi.call(t,i,...r.entrants)},0)},{id:"data-binding:descrete",live:!0,subtree:"cross-roots",timing:"sync"})}function Vr(i,t){let{webqit:{realdom:e,Observer:r,DOMBindingsContext:n}}=this;if(S(t).has("data-binding"))return S(t).get("data-binding");let o=Object.create(null),a=new AbortController;o.$exec__=(u,c,...l)=>{(()=>{try{u[c](...l)}catch(d){throw new Error(`Error executing "${c}()": ${d.message} at ${d.cause}`)}})()},o.$assign__=(u,c,l)=>{(()=>{try{u[c]=l}catch(d){throw new Error(`Error executing "${c} = ${l}": ${d.message} at ${d.cause}`)}})()},r.intercept(o,{get:(u,c,l)=>{if(!(u.key in o)){let f={...n.createRequest(u.key),live:!0,signal:a.signal};t[i.CONTEXT_API.api.contexts].request(f,d=>{r.set(o,u.key,d)})}return l(o[u.key]??(u.key in globalThis?globalThis[u.key]:void 0))},has:(u,c,l)=>l(!0)});let s={scope:o,abortController:a,bindings:new Map};return S(t).set("data-binding",s),s}function Br(...i){for(let t of i){let e=t.nodeName==="#text"?t.parentNode:t,{bindings:r,abortController:n}=S(e).get("data-binding")||{};if(!r?.has(t))return;r.get(t).state.dispose(),r.get(t).signals?.forEach(o=>o.abort()),r.delete(t),r.size||(n.abort(),S(e).delete("data-binding"))}}function zr(i,t){let e=i.tokens.tagStart.split("").map(c=>`\\${c}`).join(""),r=i.tokens.tagEnd.split("").map(c=>`\\${c}`).join(""),n=i.tokens.stateStart.split("").map(c=>c===" "?"(?:\\s+)?":`\\${c}`).join(""),o=i.tokens.stateEnd.split("").map(c=>`\\${c}`).join(""),a=`^${e}(.*?)(?:${n}(\\d+)${o}(?:\\s+)?)?${r}$`,[,s,u]=t.match(new RegExp(a));return{raw:t,expr:s,span:parseInt(u??0)}}async function Qi(i,...t){let e=this,r=t.reduce((n,o)=>{if(o.isBound)return n;let a=zr(i,o.nodeValue),s=o;if(a.span){if(s=o.nextSibling,s?.nodeName!=="#text"||s.nodeValue.length<a.span)return n;s.nodeValue.length>a.span&&s.splitText(a.span)}else s=o.ownerDocument.createTextNode(""),o.after(s);s.isBound=!0;let u=o;return e.webqit.env!=="server"&&(u.remove(),u=null),n.concat({textNode:s,template:a,anchorNode:u})},[]);for(let{textNode:n,template:o,anchorNode:a}of r){let s=Ur.call(e,i,o.expr),{scope:u,bindings:c}=Vr.call(this,i,n.parentNode);Object.defineProperty(n,"$oohtml_internal_databinding_anchorNode",{value:a,configurable:!0});try{c.set(n,{state:await(await s.bind(n,u)).execute()})}catch(l){console.log(l)}}}var er=new Map;function Ur(i,t){if(er.has(t))return er.get(t);let e=`let content = ((${t}) ?? '') + '';`;e+="$assign__wq(this, 'nodeValue', content);",e+=`if ( this.$oohtml_internal_databinding_anchorNode ) { $assign__wq(this.$oohtml_internal_databinding_anchorNode, 'nodeValue', "${i.tokens.tagStart}${Ht(t)}${i.tokens.stateStart}" + content.length + "${i.tokens.stateEnd} ${i.tokens.tagEnd}"); }`;let{webqit:{QuantumModule:r}}=this,{parserParams:n,compilerParams:o,runtimeParams:a}=i.advanced,s=new r(e,{parserParams:n,compilerParams:o,runtimeParams:a});return er.set(t,s),s}async function Xi(i,...t){for(let e of t){let r=Gr.call(this,i,e.getAttribute(i.attr.render)),{scope:n,bindings:o}=Vr.call(this,i,e),a=[];Object.defineProperty(e,"$oohtml_internal_databinding_signals",{value:a,configurable:!0});try{o.set(e,{signals:a,state:await(await r.bind(e,n)).execute()})}catch(s){console.log(s)}}}var rr=new Map;function Gr(i,t){if(rr.has(t))return rr.get(t);let e={},r=-1,n=ut(t,";").map(l=>{let[f,d]=ut(l,":").map(g=>g.trim()),h=f[0],p=f.slice(1).trim(),v=`(${d})`,O=`(${v} ?? '')`;if(h==="&")return p.startsWith("--")?`$exec__wq(this.style, 'setProperty', "${Ht(p)}", ${O});`:`$assign__wq(this.style, "${Ht(p)}", ${O});`;if(h==="%")return`$exec__wq(this.classList, 'toggle', "${Ht(p)}", !!${v});`;if(h==="~")return p.startsWith("?")?`$exec__wq(this, 'toggleAttribute', "${Ht(p.substring(1).trim())}", !!${v});`:`$exec__wq(this, 'setAttribute', "${Ht(p)}", ${O});`;if(h==="#"){if(e[p])throw new Error(`Duplicate binding: ${f}.`);if(e[p]=!0,p==="text")return`$assign__wq(this, 'textContent', ${O});`;if(p==="html")return`$assign__wq(this, 'innerHTML', ${O});`;if(p==="items"){let[g,w]=ut(d,"/");if(!w)throw new Error(`Invalid ${h}items spec: ${l}; no import specifier.`);let[b,y,m,_]=g.trim().match(/(.*?[\)\s+])(of|in)([\(\{\[\s+].*)/i)||[];if(!b)throw new Error(`Invalid ${h}items spec: ${l}.`);if(y.startsWith("(")?y=y.trim().slice(1,-1).split(",").map($=>$.trim()):y=[y],y.length>(m==="in"?3:2))throw new Error(`Invalid ${h}items spec: ${l}.`);let x=m==="in"?y[2]:y[1]||"$index__";return`
17
17
  let $iteratee__ = ${_};
18
18
  let $import__ = this.${i.HTML_IMPORTS.api.import}( ${w.trim()}, true );
19
19
  this.$oohtml_internal_databinding_signals?.push( $import__ );
@@ -51,7 +51,7 @@ ${p}
51
51
  const abort${r} = () => this.removeEventListener( '${p}', handler${r} );
52
52
  this.$oohtml_internal_databinding_signals?.push( { abort: abort${r} } );
53
53
  `;if(h==="$")return`$exec__wq(this, '${p}', ${v});`;if(l.trim())throw new Error(`Invalid binding: ${l}.`)}).join(`
54
- `),{webqit:{QuantumModule:o}}=this,{parserParams:a,compilerParams:s,runtimeParams:u}=i.advanced,c=new o(n,{parserParams:a,compilerParams:s,runtimeParams:u});return rr.set(t,c),c}var Ht=i=>i.replace(/"/g,'\\"');function Qr(i){let t=this,{webqit:{oohtml:{configs:{DATA_BINDING:e}}}}=t;(i?.matches(e.attrSelector)?[i]:[]).concat([...i?.querySelectorAll(e.attrSelector)||[]]).forEach(r=>{Gr.call(t,e,r.getAttribute(e.attr.render))}),Nt(t,i,`(${e.discreteBindingsSelector})`).forEach(r=>{let n=zr(e,r.nodeValue);Ur.call(t,e,n.expr)})}var Z=class extends U{static createRequest(t=null){let e=super.createRequest();if(t?.startsWith("@")){let[r,...n]=n.slice(1).split(".").map(o=>o.trim());e.targetContext=r,e.detail=n.join(".")}else e.detail=t;return e}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:e}}}=q;t.meta.controller=e.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],e.get,r=>{this.disposed||t.respondWith(r.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};W(Z,"kind","bindings");function nr(i={}){let{config:t,window:e}=z.call(this,"bindings-api",i,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});e.webqit.DOMBindingsContext=Z,Ji.call(e,t),Zi.call(e,t)}function or(i,t){let e=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:n}}}}=e;if(!S(t).has("bindings")){let o=Object.create(null);S(t).set("bindings",o),r.observe(o,a=>{if(t instanceof e.Element){let s=xe(t.getAttribute(i.attr.bindingsreflection)||""),u=new Map(s);for(let c of a)c.detail?.publish!==!1&&(c.type==="delete"?s.delete(c.key):s.set(c.key,void 0));s.size&&s.size!==u.size?t.setAttribute(i.attr.bindingsreflection,`{ ${[...s.entries()].map(([c,l])=>l===void 0?c:`${c}: ${l}`).join(", ")} }`):s.size||t.toggleAttribute(i.attr.bindingsreflection,!1)}else{let s=t[n.api.contexts];for(let u of a)if(u.type==="delete"){let c=s.find(Z.kind,u.key);c&&s.detach(c)}else s.find(Z.kind,u.key)||s.attach(new Z(u.key))}})}return S(t).get("bindings")}function Ji(i){let t=this,{webqit:{Observer:e}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let n=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.bind in r)throw new Error(`The ${n} prototype already has a "${i.api.bind}" API!`);if(i.api.bindings in r)throw new Error(`The ${n} prototype already has a "${i.api.bindings}" API!`);Object.defineProperty(r,i.api.bind,{value:function(o,a={}){return Yi.call(t,i,this,o,a)}}),Object.defineProperty(r,i.api.bindings,{get:function(){return e.proxy(or.call(t,i,this))}})})}function Yi(i,t,e,{merge:r,diff:n,publish:o,namespace:a}={}){let s=this,{webqit:{Observer:u}}=s,c=or.call(this,i,t),l={diff:n,namespace:a,detail:{publish:o}},f=r?[]:u.ownKeys(c,l).filter(d=>!(d in e));return u.batch(c,()=>(f.length&&u.deleteProperties(c,f,l),u.set(c,e,l)),l)}function Zi(i){let t=this,{webqit:{realdom:e,Observer:r,oohtml:{configs:n}}}=t,o=(s,u)=>{let c=s[n.CONTEXT_API.api.contexts];c.find(Z.kind,u)||c.attach(new Z(u))},a=(s,u)=>{let c,l=s[n.CONTEXT_API.api.contexts];for(;c=l.find(Z.kind,u);)l.detach(c)};e.realtime(t.document).query(`[${t.CSS.escape(i.attr.bindingsreflection)}]`,s=>{s.exits.forEach(u=>a(u)),s.entrants.forEach(u=>{let c=xe(u.getAttribute(i.attr.bindingsreflection)||""),l=[...c.entries()].filter(([f,d])=>d!==void 0);l.length&&u[i.api.bind](Object.fromEntries(l),{merge:!0,publish:!1});for(let[f]of c)o(u,f)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),e.realtime(t.document,"attr").observe(i.attr.bindingsreflection,s=>{let u=or.call(t,i,s.target),c=xe(s.value||""),l=xe(s.oldValue||"");for(let f of new Set([...c.keys(),...l.keys()]))l.has(f)?c.has(f)?c.get(f)!==l.get(f)&&r.set(u,f,c.get(f),{detail:{publish:!1}}):(l.get(f)!==void 0&&r.deleteProperty(u,f,{detail:{publish:!1}}),a(s.target,f)):(c.get(f)!==void 0&&r.set(u,f,c.get(f),{detail:{publish:!1}}),o(s.target,f))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var xe=i=>(i=i.trim(),new Map(ut(i.slice(1,-1),",").filter(t=>t.trim()).map(t=>ut(t,":").map(e=>e.trim()))));var it=class{static instance(t){return S(t).get("defsmanager::instance")||new this(t)}constructor(t,e=null,r=0){let{window:n}=q,{webqit:{realdom:o,oohtml:{configs:a}}}=n;S(t).get("defsmanager::instance")?.dispose(),S(t).set("defsmanager::instance",this),this.window=n,this.host=t,this.config=a.HTML_IMPORTS,this.parent=e,this.level=r,this.defs=ht(this.host),this.defId=(this.host.getAttribute(this.config.attr.def)||"").trim(),this.validateDefId(this.defId),this.realtimeA=o.realtime(this.host.content).children(s=>{this.expose(s.entrants,!0),this.expose(s.exits,!1)},{live:!0,timing:"sync"}),this.realtimeB=o.realtime(this.host).attr(["src","loading"],(...s)=>this.evaluateLoading(...s),{live:!0,atomic:!0,timing:"sync",lifecycleSignals:!0}),this.realtimeC=this.evalInheritance()}validateDefId(t){if(["@","/","*","#"].some(e=>t.includes(e)))throw new Error(`The export ID "${t}" contains an invalid character.`)}expose(t,e){let{window:r}=q,{webqit:{Observer:n}}=r,o,a=this.defs["#"]||[];t.forEach(s=>{if(s.nodeType!==1)return;let u=s.matches(this.config.templateSelector),c=(s.getAttribute(u?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();e?(u&&c?new it(s,this.host,this.level+1):(a.push(s),o=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(l=>l.call(this.window,s))})),c&&(this.validateDefId(c),n.set(this.defs,(!u&&"#"||"")+c,s))):(u&&c?it.instance(s).dispose():(a=a.filter(l=>l!==s),o=!0),c&&n.deleteProperty(this.defs,(!u&&"#"||"")+c))}),o&&n.set(this.defs,"#",a)}evaluateLoading([t,e],{signal:r}){let{window:{webqit:{Observer:n}}}=q,o=(t.value||"").trim();if(!o)return;let a,s=l=>{if(!l)return a;a=l.then(()=>c.remove())},u=(e.value||"").trim(),c=n.intercept(this.defs,"get",async(l,f,d)=>(u==="lazy"&&s(this.load(o,!0)),await s(),d()),{signal:r});u!=="lazy"&&s(this.load(o))}load(t){let{window:e}=q;if(this.host.content.children.length)return Promise.resolve();if(this.fetchInFlight?.src===t)return this.fetchInFlight.request;this.fetchInFlight?.controller.abort();let r=new AbortController,n=(a,s)=>this.host.dispatchEvent(new e.CustomEvent(a,{detail:s})),o=e.fetch(t,{signal:r.signal,element:this.host}).then(a=>a.ok?a.text():Promise.reject(a.statusText)).then(a=>(this.host.innerHTML=a.trim(),n("load"),this.host)).catch(a=>(console.error(`Error fetching the bundle at "${t}": ${a.message}`),this.fetchInFlight=null,n("loaderror"),this.host));return this.fetchInFlight={src:t,request:o,controller:r},o}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:t}}}=q,e=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim().split(" ").map(s=>s.trim()).filter(s=>s),n=s=>{s.forEach(u=>{t.get(this.defs,u.key)===u.oldValue&&(["get","set","def"].includes(u.type)?t[u.type.replace("get","set")](this.defs,u.key,u.value):u.type==="delete"&&t.deleteProperty(this.defs,u.key))})},o=[],a=ht(this.parent);return e&&o.push(t.reduce(a,[e,this.config.api.defs,1/0],t.get,n,{live:!0})),r.length&&o.push(t.get(a,r.includes("*")?1/0:r,n,{live:!0})),o}dispose(){this.realtimeA.disconnect(),this.realtimeB.disconnect(),this.realtimeC.forEach(t=>t instanceof Promise?t.then(e=>e.abort()):t.abort()),Object.entries(this.defs).forEach(([t,e])=>{t.startsWith("#")||it.instance(e).dispose()})}};var mt,Q,Ft,Wt,ft=class extends U{constructor(){super(...arguments);Bt(this,mt,{});Bt(this,Q,void 0);Bt(this,Ft,void 0);Bt(this,Wt,void 0)}static createRequest(e=null){let r=super.createRequest();if(e?.startsWith("/"))r.detail=e,r.targetContext=1/0;else if(e?.startsWith("@")){let[n,...o]=e.slice(1).split(/(?<=\w)(?=\/|#)/).map(a=>a.trim());r.targetContext=n,r.detail=o.join("")}else r.detail=e;return r}get localModules(){return ht(this.host)}get inheritedModules(){return F(this,mt)}handle(e){let{window:{webqit:{Observer:r}}}=q;e.meta.controller?.abort();let n=(e.detail||"").split(/\/|(?<=\w)(?=#)/g).map(a=>a.trim()).filter(a=>a);if(!n.length)return e.respondWith();n=n.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/").map(a=>a==="*"?1/0:a)||[];let o={live:e.live,signal:e.signal,descripted:!0};e.meta.controller=r.reduce(F(this,Q),n,r.get,a=>{if(Array.isArray(a)){if(!a.length){e.respondWith();return}for(let s of a)e.respondWith(s)}else e.respondWith(a.value)},o)}unsubscribed(e){e.meta.controller?.abort()}initialize(e){this.host=e;let{window:{webqit:{Observer:r}}}=q,n=()=>{for(let a of new Set([...Object.keys(this.localModules),...Object.keys(this.inheritedModules),...Object.keys(F(this,Q))]))if(!r.has(this.localModules,a)&&!r.has(this.inheritedModules,a))r.deleteProperty(F(this,Q),a);else if(a==="#"&&r.has(this.localModules,a)&&r.has(this.inheritedModules,a))r.set(F(this,Q),a,[...r.get(this.localModules,a),...r.get(this.inheritedModules,a)]);else{let s=r.get(this.localModules,a)||r.get(this.inheritedModules,a);r.get(F(this,Q),a)!==s&&r.set(F(this,Q),a,s)}};Ct(this,Q,{...this.localModules}),F(this,Ft)?.abort(),Ct(this,Ft,r.observe(this.localModules,()=>n("local"),{timing:"sync"}));let o=this.configs.HTML_IMPORTS;if(this.host.matches&&o.attr.importscontext){let a=this.host.ownerDocument.defaultView.webqit.realdom,s;F(this,Wt)?.disconnect(),Ct(this,Wt,a.realtime(this.host).attr(o.attr.importscontext,(u,{signal:c})=>{let l=(u.value||"").trim();if(l===s)return;s=l,Ct(this,mt,{});let f={...this.constructor.createRequest(l?`${l}/*`:"*"),live:!0,signal:c,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(f,d=>{d?d.type==="delete"?(delete F(this,mt)[d.key],Reflect.has(this.localModules,d.key)||r.deleteProperty(F(this,Q),d.key)):(F(this,mt)[d.key]=d.value,!Reflect.has(this.localModules,d.key)&&Reflect.get(F(this,Q),d.key)!==d.value&&r.set(F(this,Q),d.key,d.value)):(Ct(this,mt,{}),n("inherited"))}),n("inherited")},{live:!0,timing:"sync",oldValue:!0,lifecycleSignals:!0}))}return super.initialize(e)}dispose(e){return F(this,Ft)?.abort(),F(this,Wt)?.disconnect(),super.dispose(e)}};mt=new WeakMap,Q=new WeakMap,Ft=new WeakMap,Wt=new WeakMap,W(ft,"kind","html-imports");function Xr(){let{window:i}=q,{webqit:t}=i,{realdom:e,oohtml:{configs:r}}=t;if(t.HTMLImportElement)return t.HTMLImportElement;let n=r.HTML_IMPORTS.elements.import.includes("-")?i.HTMLElement:class{};class o extends n{static instance(s){return r.HTML_IMPORTS.elements.import.includes("-")&&s instanceof this?s:S(s).get("import::instance")||new this(s)}constructor(...s){super();let u=s[0]||this;S(u).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>u,configurable:!1});let c={};Object.defineProperty(this,"#",{get:()=>c,configurable:!1}),c.slottedElements=new Set,c.setAnchorNode=l=>(c.anchorNode=l,l),c.live=l=>{if(c.liveImportsRealtime)throw new Error("Import element already in live mode.");let f=this.el.isConnected?this.el.parentNode:c.anchorNode.parentNode;c.liveImportsRealtime=e.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(d,{signal:h})=>{c.moduleRef=d.value;let p=c.moduleRef.includes("#")?c.moduleRef:`${c.moduleRef}#`,v={...ft.createRequest(p),live:h&&!0,signal:h,diff:!p.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(v,O=>{l((O instanceof i.HTMLTemplateElement?[...O.content.children]:Array.isArray(O)?O:O&&[O])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),c.autoDestroyRealtime=e.realtime(i.document).track(f,()=>{c.die()},{subtree:"cross-roots",timing:"sync",generation:"exits"})},c.die=()=>{c.autoDestroyRealtime?.disconnect(),c.liveImportsRealtime?.disconnect(),c.liveImportsRealtime=null},c.hydrate=(l,f)=>{l.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.live(d=>{if(c.originalsRemapped)return this.fill(d);let h=d.map((p,v)=>({el:p,fragmentDef:p.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:p.tagName,i:v}));f.forEach((p,v)=>{let O=p.tagName,g=p.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",w=(v++,h.find(b=>b.tagName===O&&b.fragmentDef===g&&b.i===v));w&&S(p).set("original@imports",w.el),S(p).set("slot@imports",this.el),c.slottedElements.add(p)}),c.originalsRemapped=!0})},c.autoRestore=(l=null)=>{c.autoRestoreRealtime?.disconnect(),l&&l();let f=()=>{this.el.isConnected||(this.el.setAttribute("data-nodecount",0),c.internalMutation=!0,c.anchorNode.replaceWith(this.el),c.internalMutation=!1,c.setAnchorNode(null))};if(!c.slottedElements.size)return f();let d=e.realtime(c.anchorNode.parentNode).observe([...c.slottedElements],h=>{if(h.exits.forEach(p=>{S(p).delete("slot@imports"),c.slottedElements.delete(p)}),!c.slottedElements.size){if(d.disconnect(),!h.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});c.autoRestoreRealtime=d},c.connectedCallback=()=>{c.internalMutation||c.live(l=>this.fill(l))},c.disconnectedCallback=()=>{c.internalMutation||c.die()}}createAnchorNode(){if(i.webqit.env!=="server")return i.document.createTextNode("");let s=i.document.createElement("div");s.textContent=this.el.outerHTML;let u=i.document.createComment(s.innerHTML);return S(u).set("isAnchorNode",!0),u}fill(s,u){!this.el.isConnected&&(!this["#"].anchorNode||!this["#"].anchorNode.isConnected)||(Array.isArray(s)&&(s=new Set(s)),this.el.setAttribute("data-nodecount",s.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(c=>{let l=S(c).get("original@imports");s.has(l)?s.delete(l):(this["#"].slottedElements.delete(c),c.remove())}),s.size&&this.el.isConnected){let c=this["#"].setAnchorNode(this.createAnchorNode());this["#"].internalMutation=!0,this.el.replaceWith(c),this["#"].internalMutation=!1}s.forEach(c=>{let l=c.cloneNode(!0);l.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||l.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),S(l).set("original@imports",c),S(l).set("slot@imports",this.el),this["#"].slottedElements.add(l),this["#"].anchorNode.before(l)})}))}empty(){this["#"].slottedElements.forEach(s=>s.remove())}get anchorNode(){return this["#"].anchorNode}get moduleRef(){return this["#"].moduleRef}get slottedElements(){return this["#"].slottedElements}}return r.HTML_IMPORTS.elements.import.includes("-")&&customElements.define(r.HTML_IMPORTS.elements.import,o),t.HTMLImportElement=o,o}function sr(i={}){let{config:t,window:e}=z.call(this,"html-imports",i,{elements:{import:"import"},attr:{def:"def",extends:"extends",inherits:"inherits",ref:"ref",importscontext:"importscontext"},api:{def:"def",defs:"defs",import:"import"}});t.attr.fragmentdef||(t.attr.fragmentdef=t.attr.def),t.templateSelector=`template[${e.CSS.escape(t.attr.def)}]`,t.importsContextSelector=`[${e.CSS.escape(t.attr.importscontext)}]`,t.slottedElementsSelector=`[${e.CSS.escape(t.attr.fragmentdef)}]:not(template)`;let r=(n,o)=>{let a=`starts-with(., "${n}")`,s=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${a} and ${s}`};t.anchorNodeSelector=`comment()[${r(`&lt;${t.elements.import}`,`&lt;/${t.elements.import}&gt;`)}]`,e.webqit.HTMLImportsContext=ft,e.webqit.HTMLImportElement=Xr(),Ki.call(e,t),tn.call(e,t)}function ht(i,t=!0){if(!S(i).has("defs")&&t){let e=Object.create(null);S(i).set("defs",e)}return S(i).get("defs")}function Ki(i){let t=this,{webqit:{oohtml:{configs:e}}}=t;if(i.api.def in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${i.api.def}" API!`);if(i.api.defs in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${i.api.defs}" API!`);Object.defineProperty(t.HTMLTemplateElement.prototype,i.api.def,{get:function(){return this.getAttribute(i.attr.def)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,i.api.defs,{get:function(){return ht(this)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(n){this.toggleAttribute("scoped",n)}}),[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(n=>{let o=n===t.Document.prototype?"Document":n===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.import in n)throw new Error(`The ${o} prototype already has a "${i.api.import}" API!`);Object.defineProperty(n,i.api.import,{value:function(a,s=!1,u=null){return r(this,...arguments)}})});function r(n,o,a=!1,s=null){let u={};typeof a=="function"?(s=a,a=!1):typeof a=="object"&&a?u={...a,...u}:u={live:a};let c={...ft.createRequest(o),...u};return n[e.CONTEXT_API.api.contexts].request(c,s)}}function tn(i){let t=this,{webqit:{Observer:e,realdom:r,oohtml:{configs:n},HTMLImportElement:o,HTMLImportsContext:a}}=t,s=l=>{let f=l[n.CONTEXT_API.api.contexts];f.find(a.kind)||f.attach(new a)},u=l=>{let f=l[n.CONTEXT_API.api.contexts],d=f.find(a.kind);d&&(!l.isConnected||!l.matches?.(i.importsContextSelector)&&!Object.keys(d.localModules).length)&&f.detach(d)};r.realtime(t.document).query([i.templateSelector,i.importsContextSelector],l=>{l.entrants.forEach(f=>{if(f.matches(i.templateSelector)){let d=it.instance(f);d.ownerContext=f.scoped?f.parentNode:f.getRootNode();let h=ht(d.ownerContext);d.defId&&e.set(h,d.defId,f),s(d.ownerContext)}else s(f)}),l.exits.forEach(f=>{if(f.matches(i.templateSelector)){let d=it.instance(f),h=ht(d.ownerContext);d.defId&&d.ownerContext.isConnected&&e.deleteProperty(h,d.defId),u(d.ownerContext)}else u(f)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(i.elements.import,l=>{l.entrants.forEach(f=>c(f,!0,l)),l.exits.forEach(f=>c(f,!1,l))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function c(l,f){let d=o.instance(l);f?d["#"].connectedCallback():d["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${i.anchorNodeSelector})`,l=>{l.entrants.forEach(f=>{if(S(f).get("isAnchorNode"))return;let d=t.document.createElement("div");d.innerHTML=f.nodeValue,d.innerHTML=d.firstChild.textContent;let h=d.firstChild,p=parseInt(h.getAttribute("data-nodecount")),v=new Set,O=f;for(;(O=O.previousElementSibling)&&O.matches(i.slottedElementsSelector)&&p--;)v.add(O);o.instance(h)["#"].hydrate(f,v)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}function ar(i={}){let{config:t,window:e}=z.call(this,"context-api",i,{elements:{roots:"root,webflo-embedded"},attr:{contextname:"contextname"},api:{contexts:"contexts"}}),r=new Map,n=e.EventTarget.prototype.dispatchEvent;Object.defineProperty(e.EventTarget.prototype,"dispatchEvent",{value:function(...o){let a=o[0],s=this?.closest?.(t.elements.roots)||this.getRootNode?.();if(["contextclaim","contextrequest"].includes(a.type)&&s){a.meta&&(a.meta.target=this);let u=l=>{if(l.stopImmediatePropagation(),l.meta&&(l.meta.target=l.target),!l.answered){if(r.get(s)||r.set(s,new Set),l.type==="contextrequest"&&l.live)r.get(s).add(l);else if(l.type==="contextclaim"){let f=new Set;return r.get(s).forEach(d=>{!l.target.contains(d.target)||!l.detail?.matchEvent?.(d)||(r.get(s).delete(d),f.add(d))}),r.get(s).size||r.delete(s),l.respondWith?.(f)}}};s.addEventListener(a.type,u);let c=n.call(this,...o);return s.removeEventListener(a.type,u),c}return n.call(this,...o)}}),e.webqit.DOMContexts=pt,e.webqit.DOMContext=U,e.webqit.DOMContextRequestEvent=ye(),e.webqit.DOMContextResponse=Et,e.webqit.DuplicateContextError=Pt,en.call(e,t)}function en(i){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let r=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.contexts in e)throw new Error(`The ${r} prototype already has a "${i.api.contexts}" API!`);Object.defineProperty(e,i.api.contexts,{get:function(){return pt.instance(this)}})})}function lr({advanced:i={},...t}){let{config:e,window:r}=z.call(this,"scoped-css",t,{api:{styleSheets:"styleSheets"},style:{retention:"retain",mimeTypes:"text/css",strategy:null}});e.styleSelector=(Array.isArray(e.style.mimeTypes)?e.style.mimeTypes:e.style.mimeTypes.split("|")).concat("").reduce((n,o)=>{let a=o?`[type="${r.CSS.escape(o)}"]`:":not([type])";return n.concat(`style${a}`)},[]).join(","),r.webqit.oohtml.Style={compileCache:new Map},rn.call(r,e),nn.call(r,e)}function rn(i){let t=this,e=new Map;[t.Element.prototype].forEach(r=>{let n="Element";if(i.api.styleSheets in r)throw new Error(`The ${n} prototype already has a "${i.api.styleSheets}" API!`);Object.defineProperty(r,i.api.styleSheets,{get:function(){return e.has(this)||e.set(this,[]),e.get(this)}})}),Object.defineProperty(t.HTMLStyleElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}})}function nn(i){let t=this,{webqit:{oohtml:e,realdom:r}}=t,n=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1;t.CSS.supports||(t.CSS.supports=()=>!1);let o=new WeakSet;r.realtime(t.document).query(i.styleSelector,a=>{a.entrants.forEach(s=>{if(o.has(s))return;o.add(s);let u=$t(s.textContent),c=CSS.supports("selector(:has(a,b))"),l=s.scoped&&(c?`:has(> style[rand-${u}])`:`[rand-${u}]`),f=s.scoped&&t.CSSScopeRule&&!1,d=s.scoped&&s.parentNode||s.getRootNode();if(d instanceof t.Element){if(d[i.api.styleSheets].push(s),!n)return;(c?s:d).toggleAttribute(`rand-${u}`,!0)}if(!!n)if(s.scoped&&s.hasAttribute("shared")){let h;(h=e.Style.compileCache.get(u))||(h=on.call(t,s,null,f,l),e.Style.compileCache.set(u,h)),Object.defineProperty(s,"sheet",{value:h,configurable:!0}),s.textContent=`
54
+ `),{webqit:{QuantumModule:o}}=this,{parserParams:a,compilerParams:s,runtimeParams:u}=i.advanced,c=new o(n,{parserParams:a,compilerParams:s,runtimeParams:u});return rr.set(t,c),c}var Ht=i=>i.replace(/"/g,'\\"');function Qr(i){let t=this,{webqit:{oohtml:{configs:{DATA_BINDING:e}}}}=t;(i?.matches(e.attrSelector)?[i]:[]).concat([...i?.querySelectorAll(e.attrSelector)||[]]).forEach(r=>{Gr.call(t,e,r.getAttribute(e.attr.render))}),Nt(t,i,`(${e.discreteBindingsSelector})`).forEach(r=>{let n=zr(e,r.nodeValue);Ur.call(t,e,n.expr)})}var Z=class extends U{static createRequest(t=null){let e=super.createRequest();if(t?.startsWith("@")){let[r,...n]=n.slice(1).split(".").map(o=>o.trim());e.targetContext=r,e.detail=n.join(".")}else e.detail=t;return e}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:e}}}=q;t.meta.controller=e.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],e.get,r=>{this.disposed||t.respondWith(r.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};W(Z,"kind","bindings");function nr(i={}){let{config:t,window:e}=z.call(this,"bindings-api",i,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});e.webqit.DOMBindingsContext=Z,Ji.call(e,t),Zi.call(e,t)}function or(i,t){let e=this,{webqit:{Observer:r,oohtml:{configs:{CONTEXT_API:n}}}}=e;if(!S(t).has("bindings")){let o=Object.create(null);S(t).set("bindings",o),r.observe(o,a=>{if(t instanceof e.Element){let s=xe(t.getAttribute(i.attr.bindingsreflection)||""),u=new Map(s);for(let c of a)c.detail?.publish!==!1&&(c.type==="delete"?s.delete(c.key):s.set(c.key,void 0));s.size&&s.size!==u.size?t.setAttribute(i.attr.bindingsreflection,`{ ${[...s.entries()].map(([c,l])=>l===void 0?c:`${c}: ${l}`).join(", ")} }`):s.size||t.toggleAttribute(i.attr.bindingsreflection,!1)}else{let s=t[n.api.contexts];for(let u of a)if(u.type==="delete"){let c=s.find(Z.kind,u.key);c&&s.detach(c)}else s.find(Z.kind,u.key)||s.attach(new Z(u.key))}})}return S(t).get("bindings")}function Ji(i){let t=this,{webqit:{Observer:e}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let n=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.bind in r)throw new Error(`The ${n} prototype already has a "${i.api.bind}" API!`);if(i.api.bindings in r)throw new Error(`The ${n} prototype already has a "${i.api.bindings}" API!`);Object.defineProperty(r,i.api.bind,{value:function(o,a={}){return Yi.call(t,i,this,o,a)}}),Object.defineProperty(r,i.api.bindings,{get:function(){return e.proxy(or.call(t,i,this))}})})}function Yi(i,t,e,{merge:r,diff:n,publish:o,namespace:a}={}){let s=this,{webqit:{Observer:u}}=s,c=or.call(this,i,t),l={diff:n,namespace:a,detail:{publish:o}},f=r?[]:Object.keys(c,l).filter(d=>!(d in e));return u.batch(c,()=>(f.length&&u.deleteProperties(c,f,l),u.set(c,e,l)),l)}function Zi(i){let t=this,{webqit:{realdom:e,Observer:r,oohtml:{configs:n}}}=t,o=(s,u)=>{let c=s[n.CONTEXT_API.api.contexts];c.find(Z.kind,u)||c.attach(new Z(u))},a=(s,u)=>{let c,l=s[n.CONTEXT_API.api.contexts];for(;c=l.find(Z.kind,u);)l.detach(c)};e.realtime(t.document).query(`[${t.CSS.escape(i.attr.bindingsreflection)}]`,s=>{s.exits.forEach(u=>a(u)),s.entrants.forEach(u=>{let c=xe(u.getAttribute(i.attr.bindingsreflection)||""),l=[...c.entries()].filter(([f,d])=>d!==void 0);l.length&&u[i.api.bind](Object.fromEntries(l),{merge:!0,publish:!1});for(let[f]of c)o(u,f)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),e.realtime(t.document,"attr").observe(i.attr.bindingsreflection,s=>{let u=or.call(t,i,s.target),c=xe(s.value||""),l=xe(s.oldValue||"");for(let f of new Set([...c.keys(),...l.keys()]))l.has(f)?c.has(f)?c.get(f)!==l.get(f)&&r.set(u,f,c.get(f),{detail:{publish:!1}}):(l.get(f)!==void 0&&r.deleteProperty(u,f,{detail:{publish:!1}}),a(s.target,f)):(c.get(f)!==void 0&&r.set(u,f,c.get(f),{detail:{publish:!1}}),o(s.target,f))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var xe=i=>(i=i.trim(),new Map(ut(i.slice(1,-1),",").filter(t=>t.trim()).map(t=>ut(t,":").map(e=>e.trim()))));var it=class{static instance(t){return S(t).get("defsmanager::instance")||new this(t)}constructor(t,e=null,r=0){let{window:n}=q,{webqit:{realdom:o,oohtml:{configs:a}}}=n;S(t).get("defsmanager::instance")?.dispose(),S(t).set("defsmanager::instance",this),this.window=n,this.host=t,this.config=a.HTML_IMPORTS,this.parent=e,this.level=r,this.defs=ht(this.host),this.defId=(this.host.getAttribute(this.config.attr.def)||"").trim(),this.validateDefId(this.defId),this.realtimeA=o.realtime(this.host.content).children(s=>{this.expose(s.entrants,!0),this.expose(s.exits,!1)},{live:!0,timing:"sync"}),this.realtimeB=o.realtime(this.host).attr(["src","loading"],(...s)=>this.evaluateLoading(...s),{live:!0,atomic:!0,timing:"sync",lifecycleSignals:!0}),this.realtimeC=this.evalInheritance()}validateDefId(t){if(["@","/","*","#"].some(e=>t.includes(e)))throw new Error(`The export ID "${t}" contains an invalid character.`)}expose(t,e){let{window:r}=q,{webqit:{Observer:n}}=r,o,a=this.defs["#"]||[];t.forEach(s=>{if(s.nodeType!==1)return;let u=s.matches(this.config.templateSelector),c=(s.getAttribute(u?this.config.attr.def:this.config.attr.fragmentdef)||"").trim();e?(u&&c?new it(s,this.host,this.level+1):(a.push(s),o=!0,typeof requestIdleCallback=="function"&&requestIdleCallback(()=>{this.config.idleCompilers?.forEach(l=>l.call(this.window,s))})),c&&(this.validateDefId(c),n.set(this.defs,(!u&&"#"||"")+c,s))):(u&&c?it.instance(s).dispose():(a=a.filter(l=>l!==s),o=!0),c&&n.deleteProperty(this.defs,(!u&&"#"||"")+c))}),o&&n.set(this.defs,"#",a)}evaluateLoading([t,e],{signal:r}){let{window:{webqit:{Observer:n}}}=q,o=(t.value||"").trim();if(!o)return;let a,s=l=>{if(!l)return a;a=l.then(()=>c.remove())},u=(e.value||"").trim(),c=n.intercept(this.defs,"get",async(l,f,d)=>(u==="lazy"&&s(this.load(o,!0)),await s(),d()),{signal:r});u!=="lazy"&&s(this.load(o))}load(t){let{window:e}=q;if(this.host.content.children.length)return Promise.resolve();if(this.fetchInFlight?.src===t)return this.fetchInFlight.request;this.fetchInFlight?.controller.abort();let r=new AbortController,n=(a,s)=>this.host.dispatchEvent(new e.CustomEvent(a,{detail:s})),o=e.fetch(t,{signal:r.signal,element:this.host}).then(a=>a.ok?a.text():Promise.reject(a.statusText)).then(a=>(this.host.innerHTML=a.trim(),n("load"),this.host)).catch(a=>(console.error(`Error fetching the bundle at "${t}": ${a.message}`),this.fetchInFlight=null,n("loaderror"),this.host));return this.fetchInFlight={src:t,request:o,controller:r},o}evalInheritance(){if(!this.parent)return[];let{window:{webqit:{Observer:t}}}=q,e=(this.host.getAttribute(this.config.attr.extends)||"").trim(),r=(this.host.getAttribute(this.config.attr.inherits)||"").trim().split(" ").map(s=>s.trim()).filter(s=>s),n=s=>{s.forEach(u=>{t.get(this.defs,u.key)===u.oldValue&&(["get","set","def"].includes(u.type)?t[u.type.replace("get","set")](this.defs,u.key,u.value):u.type==="delete"&&t.deleteProperty(this.defs,u.key))})},o=[],a=ht(this.parent);return e&&o.push(t.reduce(a,[e,this.config.api.defs,1/0],t.get,n,{live:!0})),r.length&&o.push(t.get(a,r.includes("*")?1/0:r,n,{live:!0})),o}dispose(){this.realtimeA.disconnect(),this.realtimeB.disconnect(),this.realtimeC.forEach(t=>t instanceof Promise?t.then(e=>e.abort()):t.abort()),Object.entries(this.defs).forEach(([t,e])=>{t.startsWith("#")||it.instance(e).dispose()})}};var mt,Q,Ft,Wt,ft=class extends U{constructor(){super(...arguments);Bt(this,mt,{});Bt(this,Q,void 0);Bt(this,Ft,void 0);Bt(this,Wt,void 0)}static createRequest(e=null){let r=super.createRequest();if(e?.startsWith("/"))r.detail=e,r.targetContext=1/0;else if(e?.startsWith("@")){let[n,...o]=e.slice(1).split(/(?<=\w)(?=\/|#)/).map(a=>a.trim());r.targetContext=n,r.detail=o.join("")}else r.detail=e;return r}get localModules(){return ht(this.host)}get inheritedModules(){return F(this,mt)}handle(e){let{window:{webqit:{Observer:r}}}=q;e.meta.controller?.abort();let n=(e.detail||"").split(/\/|(?<=\w)(?=#)/g).map(a=>a.trim()).filter(a=>a);if(!n.length)return e.respondWith();n=n.join(`/${this.configs.HTML_IMPORTS.api.defs}/`)?.split("/").map(a=>a==="*"?1/0:a)||[];let o={live:e.live,signal:e.signal,descripted:!0};e.meta.controller=r.reduce(F(this,Q),n,r.get,a=>{if(Array.isArray(a)){if(!a.length){e.respondWith();return}for(let s of a)e.respondWith(s)}else e.respondWith(a.value)},o)}unsubscribed(e){e.meta.controller?.abort()}initialize(e){this.host=e;let{window:{webqit:{Observer:r}}}=q,n=()=>{for(let a of new Set([...Object.keys(this.localModules),...Object.keys(this.inheritedModules),...Object.keys(F(this,Q))]))if(!r.has(this.localModules,a)&&!r.has(this.inheritedModules,a))r.deleteProperty(F(this,Q),a);else if(a==="#"&&r.has(this.localModules,a)&&r.has(this.inheritedModules,a))r.set(F(this,Q),a,[...r.get(this.localModules,a),...r.get(this.inheritedModules,a)]);else{let s=r.get(this.localModules,a)||r.get(this.inheritedModules,a);r.get(F(this,Q),a)!==s&&r.set(F(this,Q),a,s)}};Ct(this,Q,{...this.localModules}),F(this,Ft)?.abort(),Ct(this,Ft,r.observe(this.localModules,()=>n("local"),{timing:"sync"}));let o=this.configs.HTML_IMPORTS;if(this.host.matches&&o.attr.importscontext){let a=this.host.ownerDocument.defaultView.webqit.realdom,s;F(this,Wt)?.disconnect(),Ct(this,Wt,a.realtime(this.host).attr(o.attr.importscontext,(u,{signal:c})=>{let l=(u.value||"").trim();if(l===s)return;s=l,Ct(this,mt,{});let f={...this.constructor.createRequest(l?`${l}/*`:"*"),live:!0,signal:c,diff:!0};this.host.parentNode[this.configs.CONTEXT_API.api.contexts].request(f,d=>{d?d.type==="delete"?(delete F(this,mt)[d.key],Reflect.has(this.localModules,d.key)||r.deleteProperty(F(this,Q),d.key)):(F(this,mt)[d.key]=d.value,!Reflect.has(this.localModules,d.key)&&Reflect.get(F(this,Q),d.key)!==d.value&&r.set(F(this,Q),d.key,d.value)):(Ct(this,mt,{}),n("inherited"))}),n("inherited")},{live:!0,timing:"sync",oldValue:!0,lifecycleSignals:!0}))}return super.initialize(e)}dispose(e){return F(this,Ft)?.abort(),F(this,Wt)?.disconnect(),super.dispose(e)}};mt=new WeakMap,Q=new WeakMap,Ft=new WeakMap,Wt=new WeakMap,W(ft,"kind","html-imports");function Xr(){let{window:i}=q,{webqit:t}=i,{realdom:e,oohtml:{configs:r}}=t;if(t.HTMLImportElement)return t.HTMLImportElement;let n=r.HTML_IMPORTS.elements.import.includes("-")?i.HTMLElement:class{};class o extends n{static instance(s){return r.HTML_IMPORTS.elements.import.includes("-")&&s instanceof this?s:S(s).get("import::instance")||new this(s)}constructor(...s){super();let u=s[0]||this;S(u).set("import::instance",this),Object.defineProperty(this,"el",{get:()=>u,configurable:!1});let c={};Object.defineProperty(this,"#",{get:()=>c,configurable:!1}),c.slottedElements=new Set,c.setAnchorNode=l=>(c.anchorNode=l,l),c.live=l=>{if(c.liveImportsRealtime)throw new Error("Import element already in live mode.");let f=this.el.isConnected?this.el.parentNode:c.anchorNode.parentNode;c.liveImportsRealtime=e.realtime(this.el).attr(r.HTML_IMPORTS.attr.ref,(d,{signal:h})=>{c.moduleRef=d.value;let p=c.moduleRef.includes("#")?c.moduleRef:`${c.moduleRef}#`,v={...ft.createRequest(p),live:h&&!0,signal:h,diff:!p.endsWith("#")};f[r.CONTEXT_API.api.contexts].request(v,O=>{l((O instanceof i.HTMLTemplateElement?[...O.content.children]:Array.isArray(O)?O:O&&[O])||[])})},{live:!0,timing:"sync",lifecycleSignals:!0}),c.autoDestroyRealtime=e.realtime(i.document).track(f,()=>{c.die()},{subtree:"cross-roots",timing:"sync",generation:"exits"})},c.die=()=>{c.autoDestroyRealtime?.disconnect(),c.liveImportsRealtime?.disconnect(),c.liveImportsRealtime=null},c.hydrate=(l,f)=>{l.replaceWith(c.setAnchorNode(this.createAnchorNode())),c.live(d=>{if(c.originalsRemapped)return this.fill(d);let h=d.map((p,v)=>({el:p,fragmentDef:p.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",tagName:p.tagName,i:v}));f.forEach((p,v)=>{let O=p.tagName,g=p.getAttribute(r.HTML_IMPORTS.attr.fragmentdef)||"",w=(v++,h.find(b=>b.tagName===O&&b.fragmentDef===g&&b.i===v));w&&S(p).set("original@imports",w.el),S(p).set("slot@imports",this.el),c.slottedElements.add(p)}),c.originalsRemapped=!0})},c.autoRestore=(l=null)=>{c.autoRestoreRealtime?.disconnect(),l&&l();let f=()=>{this.el.isConnected||(this.el.setAttribute("data-nodecount",0),c.internalMutation=!0,c.anchorNode.replaceWith(this.el),c.internalMutation=!1,c.setAnchorNode(null))};if(!c.slottedElements.size)return f();let d=e.realtime(c.anchorNode.parentNode).observe([...c.slottedElements],h=>{if(h.exits.forEach(p=>{S(p).delete("slot@imports"),c.slottedElements.delete(p)}),!c.slottedElements.size){if(d.disconnect(),!h.target.isConnected)return;f()}},{subtree:"cross-roots",timing:"sync",generation:"exits"});c.autoRestoreRealtime=d},c.connectedCallback=()=>{c.internalMutation||c.live(l=>this.fill(l))},c.disconnectedCallback=()=>{c.internalMutation||c.die()}}createAnchorNode(){if(i.webqit.env!=="server")return i.document.createTextNode("");let s=i.document.createElement("div");s.textContent=this.el.outerHTML;let u=i.document.createComment(s.innerHTML);return S(u).set("isAnchorNode",!0),u}fill(s,u){!this.el.isConnected&&(!this["#"].anchorNode||!this["#"].anchorNode.isConnected)||(Array.isArray(s)&&(s=new Set(s)),this.el.setAttribute("data-nodecount",s.size),this["#"].autoRestore(()=>{if(this["#"].slottedElements.forEach(c=>{let l=S(c).get("original@imports");s.has(l)?s.delete(l):(this["#"].slottedElements.delete(c),c.remove())}),s.size&&this.el.isConnected){let c=this["#"].setAnchorNode(this.createAnchorNode());this["#"].internalMutation=!0,this.el.replaceWith(c),this["#"].internalMutation=!1}s.forEach(c=>{let l=c.cloneNode(!0);l.hasAttribute(r.HTML_IMPORTS.attr.fragmentdef)||l.toggleAttribute(r.HTML_IMPORTS.attr.fragmentdef,!0),S(l).set("original@imports",c),S(l).set("slot@imports",this.el),this["#"].slottedElements.add(l),this["#"].anchorNode.before(l)})}))}empty(){this["#"].slottedElements.forEach(s=>s.remove())}get anchorNode(){return this["#"].anchorNode}get moduleRef(){return this["#"].moduleRef}get slottedElements(){return this["#"].slottedElements}}return r.HTML_IMPORTS.elements.import.includes("-")&&customElements.define(r.HTML_IMPORTS.elements.import,o),t.HTMLImportElement=o,o}function sr(i={}){let{config:t,window:e}=z.call(this,"html-imports",i,{elements:{import:"import"},attr:{def:"def",extends:"extends",inherits:"inherits",ref:"ref",importscontext:"importscontext"},api:{def:"def",defs:"defs",import:"import"}});t.attr.fragmentdef||(t.attr.fragmentdef=t.attr.def),t.templateSelector=`template[${e.CSS.escape(t.attr.def)}]`,t.importsContextSelector=`[${e.CSS.escape(t.attr.importscontext)}]`,t.slottedElementsSelector=`[${e.CSS.escape(t.attr.fragmentdef)}]:not(template)`;let r=(n,o)=>{let a=`starts-with(., "${n}")`,s=`substring(., string-length(.) - string-length("${o}") + 1) = "${o}"`;return`${a} and ${s}`};t.anchorNodeSelector=`comment()[${r(`&lt;${t.elements.import}`,`&lt;/${t.elements.import}&gt;`)}]`,e.webqit.HTMLImportsContext=ft,e.webqit.HTMLImportElement=Xr(),Ki.call(e,t),tn.call(e,t)}function ht(i,t=!0){if(!S(i).has("defs")&&t){let e=Object.create(null);S(i).set("defs",e)}return S(i).get("defs")}function Ki(i){let t=this,{webqit:{oohtml:{configs:e}}}=t;if(i.api.def in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${i.api.def}" API!`);if(i.api.defs in t.HTMLTemplateElement.prototype)throw new Error(`The "HTMLTemplateElement" prototype already has a "${i.api.defs}" API!`);Object.defineProperty(t.HTMLTemplateElement.prototype,i.api.def,{get:function(){return this.getAttribute(i.attr.def)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,i.api.defs,{get:function(){return ht(this)}}),Object.defineProperty(t.HTMLTemplateElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(n){this.toggleAttribute("scoped",n)}}),[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(n=>{let o=n===t.Document.prototype?"Document":n===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.import in n)throw new Error(`The ${o} prototype already has a "${i.api.import}" API!`);Object.defineProperty(n,i.api.import,{value:function(a,s=!1,u=null){return r(this,...arguments)}})});function r(n,o,a=!1,s=null){let u={};typeof a=="function"?(s=a,a=!1):typeof a=="object"&&a?u={...a,...u}:u={live:a};let c={...ft.createRequest(o),...u};return n[e.CONTEXT_API.api.contexts].request(c,s)}}function tn(i){let t=this,{webqit:{Observer:e,realdom:r,oohtml:{configs:n},HTMLImportElement:o,HTMLImportsContext:a}}=t,s=l=>{let f=l[n.CONTEXT_API.api.contexts];f.find(a.kind)||f.attach(new a)},u=l=>{let f=l[n.CONTEXT_API.api.contexts],d=f.find(a.kind);d&&(!l.isConnected||!l.matches?.(i.importsContextSelector)&&!Object.keys(d.localModules).length)&&f.detach(d)};r.realtime(t.document).query([i.templateSelector,i.importsContextSelector],l=>{l.entrants.forEach(f=>{if(f.matches(i.templateSelector)){let d=it.instance(f);d.ownerContext=f.scoped?f.parentNode:f.getRootNode();let h=ht(d.ownerContext);d.defId&&e.set(h,d.defId,f),s(d.ownerContext)}else s(f)}),l.exits.forEach(f=>{if(f.matches(i.templateSelector)){let d=it.instance(f),h=ht(d.ownerContext);d.defId&&d.ownerContext.isConnected&&e.deleteProperty(h,d.defId),u(d.ownerContext)}else u(f)})},{id:"imports:template/importscontext",live:!0,subtree:"cross-roots",timing:"sync",staticSensitivity:!0,eventDetails:!0}),r.realtime(t.document).query(i.elements.import,l=>{l.entrants.forEach(f=>c(f,!0,l)),l.exits.forEach(f=>c(f,!1,l))},{id:"imports:import",live:!0,subtree:"cross-roots",timing:"sync",deferred:!0});function c(l,f){let d=o.instance(l);f?d["#"].connectedCallback():d["#"].disconnectedCallback()}t.webqit.env!=="server"&&r.realtime(t.document).query(`(${i.anchorNodeSelector})`,l=>{l.entrants.forEach(f=>{if(S(f).get("isAnchorNode"))return;let d=t.document.createElement("div");d.innerHTML=f.nodeValue,d.innerHTML=d.firstChild.textContent;let h=d.firstChild,p=parseInt(h.getAttribute("data-nodecount")),v=new Set,O=f;for(;(O=O.previousElementSibling)&&O.matches(i.slottedElementsSelector)&&p--;)v.add(O);o.instance(h)["#"].hydrate(f,v)})},{id:"imports:hydration",live:!0,subtree:"cross-roots",timing:"sync"})}function ar(i={}){let{config:t,window:e}=z.call(this,"context-api",i,{elements:{roots:"root,webflo-embedded"},attr:{contextname:"contextname"},api:{contexts:"contexts"}}),r=new Map,n=e.EventTarget.prototype.dispatchEvent;Object.defineProperty(e.EventTarget.prototype,"dispatchEvent",{value:function(...o){let a=o[0],s=this?.closest?.(t.elements.roots)||this.getRootNode?.();if(["contextclaim","contextrequest"].includes(a.type)&&s){a.meta&&(a.meta.target=this);let u=l=>{if(l.stopImmediatePropagation(),l.meta&&(l.meta.target=l.target),!l.answered){if(r.get(s)||r.set(s,new Set),l.type==="contextrequest"&&l.live)r.get(s).add(l);else if(l.type==="contextclaim"){let f=new Set;return r.get(s).forEach(d=>{!l.target.contains(d.target)||!l.detail?.matchEvent?.(d)||(r.get(s).delete(d),f.add(d))}),r.get(s).size||r.delete(s),l.respondWith?.(f)}}};s.addEventListener(a.type,u);let c=n.call(this,...o);return s.removeEventListener(a.type,u),c}return n.call(this,...o)}}),e.webqit.DOMContexts=pt,e.webqit.DOMContext=U,e.webqit.DOMContextRequestEvent=ye(),e.webqit.DOMContextResponse=Et,e.webqit.DuplicateContextError=Pt,en.call(e,t)}function en(i){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let r=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(i.api.contexts in e)throw new Error(`The ${r} prototype already has a "${i.api.contexts}" API!`);Object.defineProperty(e,i.api.contexts,{get:function(){return pt.instance(this)}})})}function lr({advanced:i={},...t}){let{config:e,window:r}=z.call(this,"scoped-css",t,{api:{styleSheets:"styleSheets"},style:{retention:"retain",mimeTypes:"text/css",strategy:null}});e.styleSelector=(Array.isArray(e.style.mimeTypes)?e.style.mimeTypes:e.style.mimeTypes.split("|")).concat("").reduce((n,o)=>{let a=o?`[type="${r.CSS.escape(o)}"]`:":not([type])";return n.concat(`style${a}`)},[]).join(","),r.webqit.oohtml.Style={compileCache:new Map},rn.call(r,e),nn.call(r,e)}function rn(i){let t=this,e=new Map;[t.Element.prototype].forEach(r=>{let n="Element";if(i.api.styleSheets in r)throw new Error(`The ${n} prototype already has a "${i.api.styleSheets}" API!`);Object.defineProperty(r,i.api.styleSheets,{get:function(){return e.has(this)||e.set(this,[]),e.get(this)}})}),Object.defineProperty(t.HTMLStyleElement.prototype,"scoped",{configurable:!0,get(){return this.hasAttribute("scoped")},set(r){this.toggleAttribute("scoped",r)}})}function nn(i){let t=this,{webqit:{oohtml:e,realdom:r}}=t,n=Object.getOwnPropertyDescriptor(globalThis,"window")?.get?.toString().includes("[native code]")??!1;t.CSS.supports||(t.CSS.supports=()=>!1);let o=new WeakSet;r.realtime(t.document).query(i.styleSelector,a=>{a.entrants.forEach(s=>{if(o.has(s))return;o.add(s);let u=$t(s.textContent),c=CSS.supports("selector(:has(a,b))"),l=s.scoped&&(c?`:has(> style[rand-${u}])`:`[rand-${u}]`),f=s.scoped&&t.CSSScopeRule&&!1,d=s.scoped&&s.parentNode||s.getRootNode();if(d instanceof t.Element){if(d[i.api.styleSheets].push(s),!n)return;(c?s:d).toggleAttribute(`rand-${u}`,!0)}if(!!n)if(s.scoped&&s.hasAttribute("shared")){let h;(h=e.Style.compileCache.get(u))||(h=on.call(t,s,null,f,l),e.Style.compileCache.set(u,h)),Object.defineProperty(s,"sheet",{value:h,configurable:!0}),s.textContent=`
55
55
  /*[ Shared style sheet ]*/
56
56
  `}else{let h=()=>{let p=be(Lt.call(t,d));cr.call(this,s.sheet,p,!f&&l)};s.isConnected?h():setTimeout(()=>{h()},0)}})},{id:"scoped-css",live:!0,subtree:"cross-roots",timing:"intercept",generation:"entrants"})}function on(i,t,e,r){let n=this,o=i.textContent,a,s=e&&r?`@scope (${r}) {
57
57
  ${o.trim()}