@webqit/oohtml 4.1.13 → 4.1.14

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.
@@ -1,2 +1,2 @@
1
- (()=>{var Yt=Object.defineProperty;var Zt=(n,t,r)=>t in n?Yt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var It=(n,t,r)=>(Zt(n,typeof t!="symbol"?t+"":t,r),r);function x(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function ht(n,t,r=null){return g(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function E(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new J}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new J,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new J,i.set(e,r));return r}var J=class extends Map{constructor(...t){super(...t),this.observers=new Set}set(t,r){let e=super.set(t,r);return this.fire("set",t,r,t),e}delete(t){let r=super.delete(t);return this.fire("delete",t),r}has(t){return this.fire("has",t),super.has(t)}get(t){return this.fire("get",t),super.get(t)}keyNames(){return Array.from(super.keys())}observe(t,r,e){let i={type:t,key:r,callback:e};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(t,r,e){if(Array.isArray(t)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(ft([t,"*"],i.type)&&ft([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(ft([t,"*"],i.type)&&ft([r,"*"],i.key))||i.callback(...e)}},ft=(n,t)=>Array.isArray(t)?ht(n,t).length:n.includes(t);function X(n){return typeof n=="function"}function Y(n){return n===null||n===""}function L(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||X(n)}function gt(n){return Y(n)||L(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function w(n){return X(n)||n&&{}.toString.call(n)==="[object function]"}function Z(n){return n instanceof Number||typeof n=="number"}function S(n){return Z(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function Q(n){return n instanceof String||typeof n=="string"&&n!==null}function yt(n){return!Q(n)&&!L(n.length)}function lt(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function _t(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function wt(n,t){var r=[];return _t(n,t).forEach(e=>{lt(r,...Object.getOwnPropertyNames(e))}),r}function M(n,t,r=!1,e=!1,i=!1){var s=0,o=n.shift();if((S(o)||o===!0||o===!1)&&(s=o,o=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,c)=>{!A(f)&&!w(f)||(r?wt(f):Object.keys(f)).forEach(a=>{if(!!t(a,o,f,c)){var u=o[a],m=f[a];if((g(u)&&g(m)||x(u)&&x(m))&&(s===!0||s>0))o[a]=g(u)&&g(m)?[]:{},M([S(s)?s-1:s,o[a],u,m],t,r,e,i);else if(g(o)&&g(f))e?o[a]=m:o.push(m);else try{i?Object.defineProperty(o,a,Object.getOwnPropertyDescriptor(f,a)):o[a]=f[a]}catch{}}})}),o}function K(...n){return M(n,(t,r,e)=>!0,!1,!1,!1)}function C(n,t=!0){return g(n)?n:!t&&x(n)?[n]:n!==!1&&n!==0&&gt(n)?[]:yt(n)?Array.prototype.slice.call(n):x(n)?Object.values(n):[n]}function tt(n,t,r={},e={}){t=C(t).slice();for(var i=n;!L(i)&&!Y(i)&&t.length;){var s=t.shift();if(!(r.get?r.get(i,s):A(i)?s in i:i[s])){e.exists=!1;return}i=r.get?r.get(i,s):i[s]}return e.exists=!0,i}function bt(n,t,r,e={},i={}){let s=(u,m,l)=>i.set?i.set(u,m,l):(S(t[f])&&g(u)?u.push(l):u[m]=l,!0);t=C(t);for(var o=n,f=0;f<t.length;f++)if(f<t.length-1){if(!o||!A(o)&&!w(o))return!1;var c=tt(o,t[f],i);if(!A(c)){if(i.buildTree===!1)return!1;c=w(i.buildTree)?i.buildTree(f):S(t[f+1])?[]:{};var a=s(o,t[f],c);if(!a)return!1}o=c}else return s(o,t[f],r)}var et=class{constructor(t,r=!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}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let r=await t();return this._synthesis--,r}_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,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.readCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),s=o=>{o!==void 0&&this.onwrite(()=>{let f=r(o,e),c=a=>{a!==void 0&&this.cycle(t,r,a)};f instanceof Promise?f.then(c):c(f)})};i instanceof Promise?i.then(s):s(i)})}};function Dt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function ut(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(o=>(o+"").replace("(",e?"(.//":"(./")).join("|");let i=[],s;try{let o=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;s=o.iterateNext();)i.push(s)}catch{}return i}function Ht(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function rt(n,t,r,e=!1){let i=t.getRootNode(),s=r.getRootNode();return i===s?t.contains(r):e&&s instanceof n.ShadowRoot?rt(n,t,s.host,e):!1}function Nt(n,t="|"){return[...n].reduce(([r,e,i,s],o)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(o)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,e,i]),[null,0,[""]])[2].reverse()}var T=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Dt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Nt(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var U=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(w(t[0])?t=[[],...t]:x(t[0])&&!(t[0]instanceof T)&&t.length===1?t=[[],void 0,t[0]]:x(t[1])&&t.length===2?t=[C(t[0],!1),void 0,t[1]]:t[0]=C(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof T)&&!(r 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(r=>r instanceof T?r:new T(r)),t}registry(...t){return E("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,s=Array.isArray(r)?r:[r],o=new Set;for(let[f,c]of this.registry(t))for(let[a,u]of c){let m=s.filter(l=>rt(i,a,l.target,f==="cross-roots")?["subtree","cross-roots"].includes(f)||l.target===a:!1);if(!!m.length){Array.isArray(r)||(m=m[0]);for(let l of u)o.add([l,m,a])}}for(let[f,c,a]of[...o].reverse())e.call(i,f,c,a)}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||x(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var H=class extends U{constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof T;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:s}=this,o=Wt(s,t);if(!r)return o;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let c of o){let a=f?.generate()||{};r(c,a,s)}else{let c=f?.generate()||{};r(o,c,s)}if(e.live){f&&(e={...e,signalGenerator:f});let c=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,c)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof T;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:s,window:o,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Ft.call(o,"intercept",()=>{});let c=new o.MutationObserver(l=>{l=$t(l).map(d=>Ut.call(o,d)),Rt.call(o,m,l,s)}),a={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(a.attributeFilter=t.map(l=>l+"")),c.observe(s,a);let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:s,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:u,disconnectable:c};return this.disconnectables(e.signal,c,u)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof T;[t,r,e={}]=this.resolveArgs(arguments);let{context:s,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let f=e.timing==="intercept"?"intercept":"sync",c=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(f).size||Ft.call(o,f,y=>{this.forEachMatchingContext(f,y,Rt)});let a={disconnect(){d.delete(m),d.size||l.delete(s)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:s,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:u,disconnectable:a},l=this.registry(f,c);l.has(s)||l.set(s,new Set);let d=l.get(s);return d.add(m),this.disconnectables(e.signal,a,u)}};function $t(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||E(r.target,"internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Rt(n,t){let{context:r,spec:e,callback:i,params:s,atomics:o,originalFilterIsString:f,signalGenerator:c}=n,a=e.map(l=>l+"");if(s.atomic&&!o.size?t=Wt(r,e,t):s.timing!=="async"&&e.length&&(t=t.filter(l=>a.includes(l.name))),!t.length)return;s.newValue===null&&s.oldValue===null&&s.eventDetails||(t=t.map(l=>{let d;return s.eventDetails||({event:d,...l}=l),!s.oldValue&&"oldValue"in l&&({oldValue:d,...l}=l),!s.newValue&&"value"in l?{value:d,...l}=l:s.newValue&&typeof l.value>"u"&&(l={...l,value:at(l.target,l.name,()=>l.target.getAttribute(l.name))}),l})),s.atomic&&(t.forEach(l=>o.set(l.name,l)),t=Array.from(o.entries()).map(([,l])=>l));let u=f?t[0]:t,m=c?.generate()||{};i(u,m,r)}function at(n,t,r){let e=E(n,"internalAttrInteractions").get(t);E(n,"internalAttrInteractions").set(t,!0);let i=r();return E(n,"internalAttrInteractions").set(t,e),i}function Wt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(s=>(s=s+"",r.find(o=>o.name===s)||{target:n,name:s,value:at(n,s,()=>n.getAttribute(s)),...e})):Array.from(n.attributes).map(s=>r.find(o=>o.name===s.nodeName)||{target:n,name:s.nodeName,value:at(n,s.nodeName,()=>s.nodeValue),...e})}function Ut({target:n,attributeName:t,value:r,oldValue:e}){let o=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:o}}function Ft(n,t){let r=this,{webqit:e,document:i,Element:s}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let o=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return o;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(u,m)=>{e.realdom.attrInterceptionRecords.has(u.target)||e.realdom.attrInterceptionRecords.set(u.target,{});let l=e.realdom.attrInterceptionRecords.get(u.target);if(l[u.name]=l[u.name]||[],l[u.name].unshift(u.event),E(u.target,"internalAttrInteractions").get(u.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(y=>y([u]));let d=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(y=>y([u])),d};new r.MutationObserver(u=>{u=u.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),u=$t(u).map(m=>Ut.call(r,m)),u.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(u)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(u)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let a=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(u=>{a[u]=s.prototype[u],s.prototype[u]=function(...m){let l,d=at(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(u)&&(l=m[1]),u==="toggleAttribute"&&l===void 0&&(l=d===null);let y={target:this,name:m[0],value:l,oldValue:d,type:"interception",event:[this,u]};return f(y,()=>a[u].call(this,...m))}}),o}var nt=class extends U{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:s}=this;return new H(i,s).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,s=new Map,o=a=>(s.has(a)||s.set(a,{target:a,entrants:[],exits:[],type:"query",event:null}),s.get(a));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(a=>o(i).entrants.push(a));else if(t.every(a=>a.type==="selector")){let[a,u]=t.reduce(([l,d],y)=>y.kind==="xpath"?[l,d.concat(y)]:[l.concat(y),d],[[],[]]),m=[];e.subtree?(a.length&&m.push(...i.querySelectorAll(a.join(","))),u.length&&m.push(...ut(this.window,i,u))):(a.length&&m.push(...[...i.children].filter(l=>l.matches(a))),u.length&&m.push(...ut(this.window,i,u,!1))),m.forEach(l=>o(l.parentNode||i).entrants.push(l))}}if(!r)return s;let f={disconnected:!1},c=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,a]of s){if(f.disconnected)break;let u=c?.generate()||{};r(a,u,i)}if(e.live){c&&(e={...e,signalGenerator:c});let a=this.observe(t,r,e);return this.disconnectables(e.signal,f,a)}return this.disconnectables(e.signal,f,c)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:s,webqit:o,document:f}=this;e.eventDetails&&(o.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||o.realdom.domInterceptionRecordsAlwaysOn)&&!o.realdom.domInterceptionHooks?.intercepting&&Bt.call(s,"sync",()=>{});let c=new s.MutationObserver(m=>m.forEach(l=>{At.call(s,u,Gt.call(s,l),i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let a=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:i,spec:t,callback:r,params:e,signalGenerator:a,disconnectable:c};if(e.staticSensitivity){let m=Vt.call(s,u);return this.disconnectables(e.signal,c,a,m)}return this.disconnectables(e.signal,c,a)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let o=e.timing==="intercept"?"intercept":"sync",f=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(o).size||Bt.call(s,o,y=>{this.forEachMatchingContext(o,y,At)});let c=new s.MutationObserver(y=>y.forEach(b=>{Array.isArray((b=Gt.call(s,b)).event)||At.call(s,m,b,i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let a={disconnect(){c.disconnect(),d.delete(m),d.size||l.delete(i)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:a},l=this.registry(o,f);l.has(i)||l.set(i,new Set);let d=l.get(i);if(d.add(m),e.staticSensitivity){let y=Vt.call(s,m);return this.disconnectables(e.signal,a,u,y)}return this.disconnectables(e.signal,a,u)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function Vt(n){let t=this,{context:r,spec:e,callback:i,params:s,signalGenerator:o}=n,f=e.filter(d=>d.kind==="css"),c=d=>d.match(/\.([\w-]+)/g)?.length?["class"]:[],a=d=>d.match(/#([\w-]+)/g)?.length?["id"]:[],u=d=>[...d.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(y=>y[1]).concat(c(d)).concat(a(d));if(!(n.$attrs=Array.from(new Set(f.filter(d=>(d+"").includes("[")).reduce((d,y)=>d.concat(u(y+"")),[])))).length)return;let m=new Set,l=new Set;return m.push=d=>(l.delete(d),m.add(d)),l.push=d=>(m.delete(d),l.add(d)),n.$deliveryCache={entrants:m,exits:l},new H(r,t).observe(n.$attrs,d=>{let y=new Map,b=_=>(y.has(_)||y.set(_,{target:_,entrants:[],exits:[],type:"static",event:null}),y.get(_)),ot=new WeakMap,p=_=>(ot.has(_)||ot.set(_,f.some(O=>_.matches(O+""))),ot.get(_));for(let _ of d)["entrants","exits"].forEach(O=>{s.generation&&O!==s.generation||n.$deliveryCache[O].has(_.target)||(O==="entrants"?!p(_.target):p(_.target))||(n.$deliveryCache[O].push(_.target),b(_.target)[O].push(_.target),b(_.target).event=_.event)});for(let[,_]of y){let O=o?.generate()||{};i(_,O,r)}},{subtree:s.subtree,timing:s.timing,eventDetails:s.eventDetails})}function At(n,t){let{context:r,spec:e,callback:i,params:s,signalGenerator:o,$deliveryCache:f}=n,c={...t,entrants:[],exits:[]};if(s.eventDetails||delete c.event,["entrants","exits"].forEach(u=>{if(!(s.generation&&u!==s.generation)&&(e.length?c[u]=de.call(this,e,s.subtree==="cross-roots",t[u],t.event!=="parse"):c[u]=[...t[u]],!!f))for(let m of c[u])f[u].push(m)}),!c.entrants.length&&!c.exits.length)return;let a=o?.generate()||{};i(c,a,r)}function de(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(s,o)=>{if(o.type==="selector"){let f=o.isXpathAttr?[]:s.filter(c=>o.kind==="xpath"?Ht(this,c,o+""):c.matches&&c.matches(o+""));if((e||o.isXpathAttr)&&(f=s.reduce((c,a)=>o.kind==="xpath"?[...c,...ut(this,a,o,e)]:a.querySelectorAll?[...c,...a.querySelectorAll(o+"")]:c,f)),f.length)return f}else if(s.includes(o.content)||e&&s.some(f=>rt(this,f,o.content,t)))return[o.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((s,o)=>{let f;return r.$$searchCache.has(o.content)?f=r.$$searchCache.get(o.content):(f=i(r,o)||[],o.type==="instance"&&r.$$searchCache.set(o.content,f)),s.concat(f)},[])}function Gt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=C(t).reduce((s,o)=>s||e.webqit.realdom.domInterceptionRecords?.get(o),null),i=C(r).reduce((s,o)=>s||e.webqit.realdom.domInterceptionRecords?.get(o),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Bt(n,t){let r=this,{webqit:e,document:i,Node:s,CharacterData:o,Element:f,HTMLElement:c,HTMLTemplateElement:a,DocumentFragment:u}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionNoRecurse||Object.defineProperty(e.realdom,"domInterceptionNoRecurse",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let m=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let l=(p,_,O)=>{e.realdom.domInterceptionNoRecurse.set(p,_);let h=O();return e.realdom.domInterceptionNoRecurse.delete(p),h},d=(p,_)=>{p.entrants.concat(p.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,p.event);let I=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(p.event,"timeout",{value:I,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(p));let O=_();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(p)),O},y={ShadowRoot:["innerHTML"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTML","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},b={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(y).reduce((p,_)=>p.concat(_),[])).forEach(p=>{Object.keys(y).forEach(h=>{if(!y[h].includes(p))return;let I=Object.getOwnPropertyDescriptor(r[h].prototype,p);!I||(Object.defineProperty(r[h].prototype,p,"value"in I?{...I,value:_}:{...I,set:O}),b[h][p]=I)});function _(...h){let I=Object.keys(b).find(P=>this instanceof r[P]&&p in b[P]),B=b[I],k=()=>B[p].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===p)return k();let q=[],v=[],D=this;["insertBefore"].includes(p)?v=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(p)?(v=[h[1]],["beforebegin","afterend"].includes(h[0])&&(D=this.parentNode)):["setHTML","replaceChildren"].includes(p)?(q=[...this.childNodes],v=p==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(p)?(q=[this],v=p==="replaceWith"?[...h]:[],D=this.parentNode):["replaceChild"].includes(p)?(q=[h[1]],v=[h[0]]):["removeChild"].includes(p)?q=[...h]:(v=[...h],["before","after"].includes(p)&&(D=this.parentNode));let st=p;if(["insertAdjacentHTML","setHTML"].includes(p)){let P=this.nodeName;if(p==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return B[p].value.call(this,...h);P=this.parentNode.nodeName}let z=i.createElement(P);B.setHTML.value.call(z,v[0],p==="setHTML"?h[1]:{}),v=[...z.childNodes],p==="insertAdjacentHTML"?(st="insertAdjacentElement",h[1]=new u,l(h[1],"append",()=>h[1].append(...z.childNodes))):(st="replaceChildren",h=[...z.childNodes])}return d({target:D,entrants:v,exits:q,type:"interception",event:[this,p]},()=>B[st].value.call(this,...h))}function O(h){let I=Object.keys(b).find(F=>this instanceof r[F]&&p in b[F]),B=b[I],k=()=>B[p].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===p)return k();let q=[],v=[],D=this;if(["outerHTML","outerText"].includes(p)?(q=[this],D=this.parentNode):this instanceof a?(D=this.content,q=[...this.content.childNodes]):q=[...this.childNodes],["outerHTML","innerHTML"].includes(p)){let F=this.nodeName;if(p==="outerHTML"){if(!this.parentNode)return k();F=this.parentNode.nodeName}let P=i.createElement(F.includes("-")?"div":F);if(l(P,p,()=>P[p]=h),v=this instanceof a?[...P.content.childNodes]:[...P.childNodes],this instanceof a&&this.hasAttribute("src")){let z=v.reduce(($,W)=>W instanceof HTMLScriptElement?$.concat(W):$.concat(...W.querySelectorAll?.("script")||[]),[]);for(let $ of z){let W=i.createElement("script");[...$.attributes].forEach(Tt=>W.setAttribute(Tt.name,Tt.value)),W.textContent=$.textContent,l($,"replaceWith",()=>$.replaceWith(W))}}p==="outerHTML"?(h=new u,l(h,"append",()=>h.append(...v)),k=()=>l(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof a?k=()=>l(this.content,"replaceChildren",()=>this.content.replaceChildren(...v)):k=()=>l(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...v))}return d({target:D,entrants:v,exits:q,type:"interception",event:[this,p]},k)}}),m}function zt(){pe.call(this),he.call(this),ge.call(this)}function pe(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function he(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function ge(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Xt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},zt.call(n),n.webqit.realdom.meta=(...r)=>ye.call(n,...r),n.webqit.realdom.ready=(...r)=>Ct.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new nt(r,n);if(e==="attr")return new H(r,n)};let t=new et(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function Ct(...n){let t="interactive",r;Q(n[0])?(t=n[0],w(n[1])&&(r=n[1])):w(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(s=>Ct.call(this,"interactive",s)),complete:new Promise(s=>Ct.call(this,"complete",s))}),i.webqit.realdom.readyStatePromises[t];if(e[t].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let s=i.document.readyState;for(let o of i.webqit.realdom.readyStateCallbacks[s].splice(0))o(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function ye(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,s)=>{let o=s.split("=").map(f=>f.trim());return bt(i,o[0].split("."),o[1]==="true"?!0:o[1]==="false"?!1:S(o[1])?parseInt(o[1]):o[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function mt(n,t){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof t!==void 0&&t?r.substr(1).toLowerCase():r.substr(1))})}var dt=(...n)=>E("oohtml",...n),j={};function Jt(n,t,r){let e=this,i=Xt.call(e);j.window=e,e.webqitConfig||(e.webqitConfig=i.meta("webqit").json()),e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let s=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[s]){e.webqit.oohtml.configs[s]={};let o=e.webqit.oohtml.configs[s];K(2,o,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(o).forEach(f=>{Object.keys(o[f]).forEach(c=>{f==="api"&&typeof o[f][c]=="string"?o[f][c]=`${e.webqitConfig.prefix}${mt(o[f][c])}`:["attr","elements"].includes(f)&&o[f][c]?.startsWith("data-")===!1&&(o[f][c]=`${e.webqitConfig.prefix}-${o[f][c]}`)})})}return{config:e.webqit.oohtml.configs[s],realdom:i,window:e}}function pt(){let{window:n}=j,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let s=i.pop();if(typeof s!="function")throw new Error("Callback must be provided.");let o=i.pop();if(!o?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],c=i.pop()||f[0];if(!f.includes(c))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:a,detail:u,targetContext:m,live:l,signal:d,diff:y,...b}=o;super(c,{...b,bubbles:b.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>s}),Object.defineProperty(this,"kind",{get:()=>a}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>u}),Object.defineProperty(this,"live",{get:()=>l}),Object.defineProperty(this,"signal",{get:()=>d}),Object.defineProperty(this,"diff",{get:()=>y}),Object.defineProperty(this,"options",{get:()=>b}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(i){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===i)return;Object.defineProperty(this,"_prevValue",{value:i,configurable:!0})}return this.callback(i)}}return t.DOMContextRequestEvent=r,r}var V=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=j;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var Et=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}}}}=j;return t}get name(){return[j.window.Document,j.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 Et)||t.target===this.host)return;let r=new Set;if(this.subscriptions.forEach(e=>{!t.target.contains(e.target)||!t.detail.matchEvent(e)||(this.subscriptions.delete(e),this.unsubscribed(e),r.add(e))}),r.size)return t.respondWith(r)}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:r}=R.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return r?.forEach(e=>{this.subscriptions.add(e),this.subscribed(e),this.handle(e)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.subscriptions.delete(r),this.unsubscribed(r);let{target:e}=r;e.dispatchEvent(r)}),this}},N=Et;It(N,"kind");var G=class extends Error{};var it=new Map,R=class{static instance(t){return dt(t).get("contexts::instance")||new this(t)}constructor(t){dt(t).get("contexts::instance")?.dispose(),dt(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}get[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(r=>typeof t[0]=="function"?t[0](r):r.constructor.kind===t[0]&&(t.length===1||r.detail===t[1]))}attach(t){if(!(t instanceof N))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new G(`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 V((r,e)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(r):t[t.length-1]=r);let i;(i=t.find(c=>typeof c=="object"&&c))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let s=new(pt())(...t);s.meta.target=this["#"].host;let o=this["#"].host.getRootNode(),f=c=>{if(c.stopImmediatePropagation(),c.meta.target=c.target,!c.answered){if(it.get(o)||it.set(o,new Set),c.type==="contextrequest"&&c.live)it.get(o).add(c);else if(c.type==="contextclaim"){let a=new Set;return it.get(o).forEach(u=>{!this["#"].host.contains(u.target)||!c.detail.matchEvent(u)||(it.get(o).delete(u),a.add(u))}),c.respondWith(a)}}};o.addEventListener(s.type,f),this["#"].host.dispatchEvent(s),o.removeEventListener(s.type,f)})}};function St(n={}){let{config:t,window:r}=Jt.call(this,"context-api",n,{attr:{contextname:"contextname"},api:{contexts:"contexts"}});r.webqit.DOMContexts=R,r.webqit.DOMContext=N,r.webqit.DOMContextRequestEvent=pt(),r.webqit.DOMContextResponse=V,r.webqit.DuplicateContextError=G,xe.call(r,t)}function xe(n){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let e=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.contexts in r)throw new Error(`The ${e} prototype already has a "${n.api.contexts}" API!`);Object.defineProperty(r,n.api.contexts,{get:function(){return R.instance(this)}})})}St.call(window);})();
1
+ (()=>{var Zt=Object.defineProperty;var Kt=(n,t,r)=>t in n?Zt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var It=(n,t,r)=>(Kt(n,typeof t!="symbol"?t+"":t,r),r);function x(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function gt(n,t,r=null){return g(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function E(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new Y}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new Y,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new Y,i.set(e,r));return r}var Y=class extends Map{constructor(...t){super(...t),this.observers=new Set}set(t,r){let e=super.set(t,r);return this.fire("set",t,r,t),e}delete(t){let r=super.delete(t);return this.fire("delete",t),r}has(t){return this.fire("has",t),super.has(t)}get(t){return this.fire("get",t),super.get(t)}keyNames(){return Array.from(super.keys())}observe(t,r,e){let i={type:t,key:r,callback:e};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(t,r,e){if(Array.isArray(t)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(lt([t,"*"],i.type)&&lt([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(lt([t,"*"],i.type)&&lt([r,"*"],i.key))||i.callback(...e)}},lt=(n,t)=>Array.isArray(t)?gt(n,t).length:n.includes(t);function Q(n){return typeof n=="function"}function Z(n){return n===null||n===""}function k(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||Q(n)}function yt(n){return Z(n)||k(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function w(n){return Q(n)||n&&{}.toString.call(n)==="[object function]"}function K(n){return n instanceof Number||typeof n=="number"}function S(n){return K(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function J(n){return n instanceof String||typeof n=="string"&&n!==null}function _t(n){return!J(n)&&!k(n.length)}function ct(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function wt(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var r=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)r.push(e),e=e?Object.getPrototypeOf(e):null;return r}function xt(n,t){var r=[];return wt(n,t).forEach(e=>{ct(r,...Object.getOwnPropertyNames(e))}),r}function M(n,t,r=!1,e=!1,i=!1){var s=0,o=n.shift();if((S(o)||o===!0||o===!1)&&(s=o,o=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((f,c)=>{!A(f)&&!w(f)||(r?xt(f):Object.keys(f)).forEach(a=>{if(!!t(a,o,f,c)){var u=o[a],m=f[a];if((g(u)&&g(m)||x(u)&&x(m))&&(s===!0||s>0))o[a]=g(u)&&g(m)?[]:{},M([S(s)?s-1:s,o[a],u,m],t,r,e,i);else if(g(o)&&g(f))e?o[a]=m:o.push(m);else try{i?Object.defineProperty(o,a,Object.getOwnPropertyDescriptor(f,a)):o[a]=f[a]}catch{}}})}),o}function tt(...n){return M(n,(t,r,e)=>!0,!1,!1,!1)}function C(n,t=!0){return g(n)?n:!t&&x(n)?[n]:n!==!1&&n!==0&&yt(n)?[]:_t(n)?Array.prototype.slice.call(n):x(n)?Object.values(n):[n]}function et(n,t,r={},e={}){t=C(t).slice();for(var i=n;!k(i)&&!Z(i)&&t.length;){var s=t.shift();if(!(r.get?r.get(i,s):A(i)?s in i:i[s])){e.exists=!1;return}i=r.get?r.get(i,s):i[s]}return e.exists=!0,i}function vt(n,t,r,e={},i={}){let s=(u,m,l)=>i.set?i.set(u,m,l):(S(t[f])&&g(u)?u.push(l):u[m]=l,!0);t=C(t);for(var o=n,f=0;f<t.length;f++)if(f<t.length-1){if(!o||!A(o)&&!w(o))return!1;var c=et(o,t[f],i);if(!A(c)){if(i.buildTree===!1)return!1;c=w(i.buildTree)?i.buildTree(f):S(t[f+1])?[]:{};var a=s(o,t[f],c);if(!a)return!1}o=c}else return s(o,t[f],r)}var rt=class{constructor(t,r=!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}),!r&&this.window.requestAnimationFrame?this._loop():this._synthesis++}get synthesis(){return this._synthesis}async synthesizeWhile(t){this._synthesis++,this._fulfill();let r=await t();return this._synthesis--,r}_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,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.readCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.synthesis?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.synthesis?Promise.resolve().then(t):this.writeCallbacks.add(t)}cycle(t,r,e){this.onread(()=>{let i=t(e),s=o=>{o!==void 0&&this.onwrite(()=>{let f=r(o,e),c=a=>{a!==void 0&&this.cycle(t,r,a)};f instanceof Promise?f.then(c):c(f)})};i instanceof Promise?i.then(s):s(i)})}};function Dt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function at(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(o=>(o+"").replace("(",e?"(.//":"(./")).join("|");let i=[],s;try{let o=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;s=o.iterateNext();)i.push(s)}catch{}return i}function Ht(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function nt(n,t,r,e=!1){let i=t.getRootNode(),s=r.getRootNode();return i===s?t.contains(r):e&&s instanceof n.ShadowRoot?nt(n,t,s.host,e):!1}function Nt(n,t="|"){return[...n].reduce(([r,e,i,s],o)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(o)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,e,i]),[null,0,[""]])[2].reverse()}var T=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Dt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Nt(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var V=class{constructor(t,r,e){this.context=t,this.namespace=r,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){if(w(t[0])?t=[[],...t]:x(t[0])&&!(t[0]instanceof T)&&t.length===1?t=[[],void 0,t[0]]:x(t[1])&&t.length===2?t=[C(t[0],!1),void 0,t[1]]:t[0]=C(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof T)&&!(r 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(r=>r instanceof T?r:new T(r)),t}registry(...t){return E("realdom.realtime",this.window,this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,s=Array.isArray(r)?r:[r],o=new Set;for(let[f,c]of this.registry(t))for(let[a,u]of c){let m=s.filter(l=>nt(i,a,l.target,f==="cross-roots")?["subtree","cross-roots"].includes(f)||l.target===a:!1);if(!!m.length){Array.isArray(r)||(m=m[0]);for(let l of u)o.add([l,m,a])}}for(let[f,c,a]of[...o].reverse())e.call(i,f,c,a)}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||x(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var F=class extends V{constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof T;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:s}=this,o=Wt(s,t);if(!r)return o;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let c of o){let a=f?.generate()||{};r(c,a,s)}else{let c=f?.generate()||{};r(o,c,s)}if(e.live){f&&(e={...e,signalGenerator:f});let c=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,c)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof T;if([t=[],r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:s,window:o,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Ft.call(o,"intercept",()=>{});let c=new o.MutationObserver(l=>{l=$t(l).map(d=>Ut.call(o,d)),Rt.call(o,m,l,s)}),a={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(a.attributeFilter=t.map(l=>l+"")),c.observe(s,a);let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:s,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:u,disconnectable:c};return this.disconnectables(e.signal,c,u)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof T;[t,r,e={}]=this.resolveArgs(arguments);let{context:s,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let f=e.timing==="intercept"?"intercept":"sync",c=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(f).size||Ft.call(o,f,y=>{this.forEachMatchingContext(f,y,Rt)});let a={disconnect(){d.delete(m),d.size||l.delete(s)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:s,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:u,disconnectable:a},l=this.registry(f,c);l.has(s)||l.set(s,new Set);let d=l.get(s);return d.add(m),this.disconnectables(e.signal,a,u)}};function $t(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||E(r.target,"internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Rt(n,t){let{context:r,spec:e,callback:i,params:s,atomics:o,originalFilterIsString:f,signalGenerator:c}=n,a=e.map(l=>l+"");if(s.atomic&&!o.size?t=Wt(r,e,t):s.timing!=="async"&&e.length&&(t=t.filter(l=>a.includes(l.name))),!t.length)return;s.newValue===null&&s.oldValue===null&&s.eventDetails||(t=t.map(l=>{let d;return s.eventDetails||({event:d,...l}=l),!s.oldValue&&"oldValue"in l&&({oldValue:d,...l}=l),!s.newValue&&"value"in l?{value:d,...l}=l:s.newValue&&typeof l.value>"u"&&(l={...l,value:mt(l.target,l.name,()=>l.target.getAttribute(l.name))}),l})),s.atomic&&(t.forEach(l=>o.set(l.name,l)),t=Array.from(o.entries()).map(([,l])=>l));let u=f?t[0]:t,m=c?.generate()||{};i(u,m,r)}function mt(n,t,r){let e=E(n,"internalAttrInteractions").get(t);E(n,"internalAttrInteractions").set(t,!0);let i=r();return E(n,"internalAttrInteractions").set(t,e),i}function Wt(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(s=>(s=s+"",r.find(o=>o.name===s)||{target:n,name:s,value:mt(n,s,()=>n.getAttribute(s)),...e})):Array.from(n.attributes).map(s=>r.find(o=>o.name===s.nodeName)||{target:n,name:s.nodeName,value:mt(n,s.nodeName,()=>s.nodeValue),...e})}function Ut({target:n,attributeName:t,value:r,oldValue:e}){let o=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:o}}function Ft(n,t){let r=this,{webqit:e,document:i,Element:s}=r;e.realdom.attrInterceptionHooks||Object.defineProperty(e.realdom,"attrInterceptionHooks",{value:new Map}),e.realdom.attrInterceptionHooks.has(n)||e.realdom.attrInterceptionHooks.set(n,new Set),e.realdom.attrInterceptionHooks.get(n).add(t);let o=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return o;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(u,m)=>{e.realdom.attrInterceptionRecords.has(u.target)||e.realdom.attrInterceptionRecords.set(u.target,{});let l=e.realdom.attrInterceptionRecords.get(u.target);if(l[u.name]=l[u.name]||[],l[u.name].unshift(u.event),E(u.target,"internalAttrInteractions").get(u.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(y=>y([u]));let d=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(y=>y([u])),d};new r.MutationObserver(u=>{u=u.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),u=$t(u).map(m=>Ut.call(r,m)),u.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(u)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(u)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let a=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(u=>{a[u]=s.prototype[u],s.prototype[u]=function(...m){let l,d=mt(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(u)&&(l=m[1]),u==="toggleAttribute"&&l===void 0&&(l=d===null);let y={target:this,name:m[0],value:l,oldValue:d,type:"interception",event:[this,u]};return f(y,()=>a[u].call(this,...m))}}),o}var it=class extends V{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:s}=this;return new F(i,s).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,s=new Map,o=a=>(s.has(a)||s.set(a,{target:a,entrants:[],exits:[],type:"query",event:null}),s.get(a));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(a=>o(i).entrants.push(a));else if(t.every(a=>a.type==="selector")){let[a,u]=t.reduce(([l,d],y)=>y.kind==="xpath"?[l,d.concat(y)]:[l.concat(y),d],[[],[]]),m=[];e.subtree?(a.length&&m.push(...i.querySelectorAll(a.join(","))),u.length&&m.push(...at(this.window,i,u))):(a.length&&m.push(...[...i.children].filter(l=>l.matches(a))),u.length&&m.push(...at(this.window,i,u,!1))),m.forEach(l=>o(l.parentNode||i).entrants.push(l))}}if(!r)return s;let f={disconnected:!1},c=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,a]of s){if(f.disconnected)break;let u=c?.generate()||{};r(a,u,i)}if(e.live){c&&(e={...e,signalGenerator:c});let a=this.observe(t,r,e);return this.disconnectables(e.signal,f,a)}return this.disconnectables(e.signal,f,c)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:s,webqit:o,document:f}=this;e.eventDetails&&(o.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||o.realdom.domInterceptionRecordsAlwaysOn)&&!o.realdom.domInterceptionHooks?.intercepting&&Bt.call(s,"sync",()=>{});let c=new s.MutationObserver(m=>m.forEach(l=>{Ct.call(s,u,Gt.call(s,l),i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let a=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:i,spec:t,callback:r,params:e,signalGenerator:a,disconnectable:c};if(e.staticSensitivity){let m=Vt.call(s,u);return this.disconnectables(e.signal,c,a,m)}return this.disconnectables(e.signal,c,a)}observeSync(t,r,e={}){[t,r,e={}]=this.resolveArgs(arguments);let{context:i,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let o=e.timing==="intercept"?"intercept":"sync",f=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(o).size||Bt.call(s,o,y=>{this.forEachMatchingContext(o,y,Ct)});let c=new s.MutationObserver(y=>y.forEach(b=>{Array.isArray((b=Gt.call(s,b)).event)||Ct.call(s,m,b,i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let a={disconnect(){c.disconnect(),d.delete(m),d.size||l.delete(i)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:a},l=this.registry(o,f);l.has(i)||l.set(i,new Set);let d=l.get(i);if(d.add(m),e.staticSensitivity){let y=Vt.call(s,m);return this.disconnectables(e.signal,a,u,y)}return this.disconnectables(e.signal,a,u)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function Vt(n){let t=this,{context:r,spec:e,callback:i,params:s,signalGenerator:o}=n,f=e.filter(d=>d.kind==="css"),c=d=>d.match(/\.([\w-]+)/g)?.length?["class"]:[],a=d=>d.match(/#([\w-]+)/g)?.length?["id"]:[],u=d=>[...d.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(y=>y[1]).concat(c(d)).concat(a(d));if(!(n.$attrs=Array.from(new Set(f.filter(d=>(d+"").includes("[")).reduce((d,y)=>d.concat(u(y+"")),[])))).length)return;let m=new Set,l=new Set;return m.push=d=>(l.delete(d),m.add(d)),l.push=d=>(m.delete(d),l.add(d)),n.$deliveryCache={entrants:m,exits:l},new F(r,t).observe(n.$attrs,d=>{let y=new Map,b=_=>(y.has(_)||y.set(_,{target:_,entrants:[],exits:[],type:"static",event:null}),y.get(_)),st=new WeakMap,p=_=>(st.has(_)||st.set(_,f.some(O=>_.matches(O+""))),st.get(_));for(let _ of d)["entrants","exits"].forEach(O=>{s.generation&&O!==s.generation||n.$deliveryCache[O].has(_.target)||(O==="entrants"?!p(_.target):p(_.target))||(n.$deliveryCache[O].push(_.target),b(_.target)[O].push(_.target),b(_.target).event=_.event)});for(let[,_]of y){let O=o?.generate()||{};i(_,O,r)}},{subtree:s.subtree,timing:s.timing,eventDetails:s.eventDetails})}function Ct(n,t){let{context:r,spec:e,callback:i,params:s,signalGenerator:o,$deliveryCache:f}=n,c={...t,entrants:[],exits:[]};if(s.eventDetails||delete c.event,["entrants","exits"].forEach(u=>{if(!(s.generation&&u!==s.generation)&&(e.length?c[u]=pe.call(this,e,s.subtree==="cross-roots",t[u],t.event!=="parse"):c[u]=[...t[u]],!!f))for(let m of c[u])f[u].push(m)}),!c.entrants.length&&!c.exits.length)return;let a=o?.generate()||{};i(c,a,r)}function pe(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(s,o)=>{if(o.type==="selector"){let f=o.isXpathAttr?[]:s.filter(c=>o.kind==="xpath"?Ht(this,c,o+""):c.matches&&c.matches(o+""));if((e||o.isXpathAttr)&&(f=s.reduce((c,a)=>o.kind==="xpath"?[...c,...at(this,a,o,e)]:a.querySelectorAll?[...c,...a.querySelectorAll(o+"")]:c,f)),f.length)return f}else if(s.includes(o.content)||e&&s.some(f=>nt(this,f,o.content,t)))return[o.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((s,o)=>{let f;return r.$$searchCache.has(o.content)?f=r.$$searchCache.get(o.content):(f=i(r,o)||[],o.type==="instance"&&r.$$searchCache.set(o.content,f)),s.concat(f)},[])}function Gt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=C(t).reduce((s,o)=>s||e.webqit.realdom.domInterceptionRecords?.get(o),null),i=C(r).reduce((s,o)=>s||e.webqit.realdom.domInterceptionRecords?.get(o),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Bt(n,t){let r=this,{webqit:e,document:i,Node:s,CharacterData:o,Element:f,HTMLElement:c,HTMLTemplateElement:a,DocumentFragment:u}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionNoRecurse||Object.defineProperty(e.realdom,"domInterceptionNoRecurse",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let m=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let l=(p,_,O)=>{e.realdom.domInterceptionNoRecurse.set(p,_);let h=O();return e.realdom.domInterceptionNoRecurse.delete(p),h},d=(p,_)=>{p.entrants.concat(p.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,p.event);let I=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(p.event,"timeout",{value:I,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(p));let O=_();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(p)),O},y={ShadowRoot:["innerHTML"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTML","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},b={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(y).reduce((p,_)=>p.concat(_),[])).forEach(p=>{Object.keys(y).forEach(h=>{if(!y[h].includes(p))return;let I=Object.getOwnPropertyDescriptor(r[h].prototype,p);!I||(Object.defineProperty(r[h].prototype,p,"value"in I?{...I,value:_}:{...I,set:O}),b[h][p]=I)});function _(...h){let I=Object.keys(b).find(P=>this instanceof r[P]&&p in b[P]),z=b[I],H=()=>z[p].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===p)return H();let q=[],v=[],N=this;["insertBefore"].includes(p)?v=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(p)?(v=[h[1]],["beforebegin","afterend"].includes(h[0])&&(N=this.parentNode)):["setHTML","replaceChildren"].includes(p)?(q=[...this.childNodes],v=p==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(p)?(q=[this],v=p==="replaceWith"?[...h]:[],N=this.parentNode):["replaceChild"].includes(p)?(q=[h[1]],v=[h[0]]):["removeChild"].includes(p)?q=[...h]:(v=[...h],["before","after"].includes(p)&&(N=this.parentNode));let ft=p;if(["insertAdjacentHTML","setHTML"].includes(p)){let P=this.nodeName;if(p==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return z[p].value.call(this,...h);P=this.parentNode.nodeName}let R=i.createElement(P);z.setHTML.value.call(R,v[0],p==="setHTML"?h[1]:{}),v=[...R.childNodes],p==="insertAdjacentHTML"?(ft="insertAdjacentElement",h[1]=new u,l(h[1],"append",()=>h[1].append(...R.childNodes))):(ft="replaceChildren",h=[...R.childNodes])}return d({target:N,entrants:v,exits:q,type:"interception",event:[this,p]},()=>z[ft].value.call(this,...h))}function O(h){let I=Object.keys(b).find(U=>this instanceof r[U]&&p in b[U]),z=b[I],H=()=>z[p].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===p)return H();let q=[],v=[],N=this;if(["outerHTML","outerText"].includes(p)?(q=[this],N=this.parentNode):this instanceof a?(N=this.content,q=[...this.content.childNodes]):q=[...this.childNodes],["outerHTML","innerHTML"].includes(p)){let U=this.nodeName;if(p==="outerHTML"){if(!this.parentNode)return H();U=this.parentNode.nodeName}let P=i.createElement(U.includes("-")?"div":U);if(l(P,p,()=>P[p]=h),v=this instanceof a?[...P.content.childNodes]:[...P.childNodes],this instanceof a&&this.hasAttribute("src")){let R=X=>X.reduce((L,j)=>j instanceof HTMLScriptElement?L.concat(j):j instanceof a?L.concat(R([j.content])):(L=L.concat(R([...j.querySelectorAll?.("template")||[]].map(Yt=>Yt.content))),L.concat(...j.querySelectorAll?.("script")||[])),[]);for(let X of R(v)){let L=i.createElement("script");[...X.attributes].forEach(j=>L.setAttribute(j.name,j.value)),L.textContent=X.textContent,l(X,"replaceWith",()=>X.replaceWith(L))}}p==="outerHTML"?(h=new u,l(h,"append",()=>h.append(...v)),H=()=>l(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof a?H=()=>l(this.content,"replaceChildren",()=>this.content.replaceChildren(...v)):H=()=>l(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...v))}return d({target:N,entrants:v,exits:q,type:"interception",event:[this,p]},H)}}),m}function zt(){he.call(this),ge.call(this),ye.call(this)}function he(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function ge(){let n=this;"isConnected"in n.Node.prototype||Object.defineProperty(n.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function ye(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Xt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},zt.call(n),n.webqit.realdom.meta=(...r)=>_e.call(n,...r),n.webqit.realdom.ready=(...r)=>Et.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new it(r,n);if(e==="attr")return new F(r,n)};let t=new rt(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function Et(...n){let t="interactive",r;J(n[0])?(t=n[0],w(n[1])&&(r=n[1])):w(n[0])&&(r=n[0]);let e={interactive:["interactive","complete"],complete:["complete"]};if(!e[t])throw new Error(`Invalid ready-state timing: ${t}.`);let i=this;if(!r)return i.webqit.realdom.readyStatePromises||(i.webqit.realdom.readyStatePromises={interactive:new Promise(s=>Et.call(this,"interactive",s)),complete:new Promise(s=>Et.call(this,"complete",s))}),i.webqit.realdom.readyStatePromises[t];if(e[t].includes(i.document.readyState))return r(i);i.webqit.realdom.readyStateCallbacks||(i.webqit.realdom.readyStateCallbacks={interactive:[],complete:[]},i.document.addEventListener("readystatechange",()=>{let s=i.document.readyState;for(let o of i.webqit.realdom.readyStateCallbacks[s].splice(0))o(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function _e(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,s)=>{let o=s.split("=").map(f=>f.trim());return vt(i,o[0].split("."),o[1]==="true"?!0:o[1]==="false"?!1:S(o[1])?parseInt(o[1]):o[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function dt(n,t){return typeof n!="string"?n:n.replace(/\w\S*/g,function(r){return r.charAt(0).toUpperCase()+(typeof t!==void 0&&t?r.substr(1).toLowerCase():r.substr(1))})}var pt=(...n)=>E("oohtml",...n),D={};function Jt(n,t,r){let e=this,i=Xt.call(e);D.window=e,e.webqitConfig||(e.webqitConfig=i.meta("webqit").json()),e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let s=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[s]){e.webqit.oohtml.configs[s]={};let o=e.webqit.oohtml.configs[s];tt(2,o,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(o).forEach(f=>{Object.keys(o[f]).forEach(c=>{f==="api"&&typeof o[f][c]=="string"?o[f][c]=`${e.webqitConfig.prefix}${dt(o[f][c])}`:["attr","elements"].includes(f)&&o[f][c]?.startsWith("data-")===!1&&(o[f][c]=`${e.webqitConfig.prefix}-${o[f][c]}`)})})}return{config:e.webqit.oohtml.configs[s],realdom:i,window:e}}function ht(){let{window:n}=D,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let s=i.pop();if(typeof s!="function")throw new Error("Callback must be provided.");let o=i.pop();if(!o?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],c=i.pop()||f[0];if(!f.includes(c))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:a,detail:u,targetContext:m,live:l,signal:d,diff:y,...b}=o;super(c,{...b,bubbles:b.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>s}),Object.defineProperty(this,"kind",{get:()=>a}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>u}),Object.defineProperty(this,"live",{get:()=>l}),Object.defineProperty(this,"signal",{get:()=>d}),Object.defineProperty(this,"diff",{get:()=>y}),Object.defineProperty(this,"options",{get:()=>b}),Object.defineProperty(this,"meta",{value:{}})}get target(){return super.target||this.meta.target}get answered(){return this.meta.answered||!1}respondWith(i){if(this.meta.answered=!0,this.diff){if("_prevValue"in this&&this._prevValue===i)return;Object.defineProperty(this,"_prevValue",{value:i,configurable:!0})}return this.callback(i)}}return t.DOMContextRequestEvent=r,r}var G=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=D;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var St=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}}}}=D;return t}get name(){return[D.window.Document,D.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 St)||t.target===this.host)return;let r=new Set;if(this.subscriptions.forEach(e=>{!t.target.contains(e.target)||!t.detail.matchEvent(e)||(this.subscriptions.delete(e),this.unsubscribed(e),r.add(e))}),r.size)return t.respondWith(r)}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:r}=W.instance(t).request("contextclaim",{kind:this.constructor.kind,detail:this});return r?.forEach(e=>{this.subscriptions.add(e),this.subscribed(e),this.handle(e)}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.subscriptions.delete(r),this.unsubscribed(r);let{target:e}=r;e.dispatchEvent(r)}),this}},$=St;It($,"kind");var B=class extends Error{};var ot=new Map,W=class{static instance(t){return pt(t).get("contexts::instance")||new this(t)}constructor(t){pt(t).get("contexts::instance")?.dispose(),pt(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}get[Symbol.iterator](){return this["#"].contexts[Symbol.iterator]}get length(){return this["#"].contexts.size}find(...t){return[...this["#"].contexts].find(r=>typeof t[0]=="function"?t[0](r):r.constructor.kind===t[0]&&(t.length===1||r.detail===t[1]))}attach(t){if(!(t instanceof $))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new B(`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 G((r,e)=>{typeof t[t.length-1]!="function"&&(t[t.length-1]?t.push(r):t[t.length-1]=r);let i;(i=t.find(c=>typeof c=="object"&&c))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let s=new(ht())(...t);s.meta.target=this["#"].host;let o=this["#"].host.getRootNode(),f=c=>{if(c.stopImmediatePropagation(),c.meta.target=c.target,!c.answered){if(ot.get(o)||ot.set(o,new Set),c.type==="contextrequest"&&c.live)ot.get(o).add(c);else if(c.type==="contextclaim"){let a=new Set;return ot.get(o).forEach(u=>{!this["#"].host.contains(u.target)||!c.detail.matchEvent(u)||(ot.get(o).delete(u),a.add(u))}),c.respondWith(a)}}};o.addEventListener(s.type,f),this["#"].host.dispatchEvent(s),o.removeEventListener(s.type,f)})}};function Tt(n={}){let{config:t,window:r}=Jt.call(this,"context-api",n,{attr:{contextname:"contextname"},api:{contexts:"contexts"}});r.webqit.DOMContexts=W,r.webqit.DOMContext=$,r.webqit.DOMContextRequestEvent=ht(),r.webqit.DOMContextResponse=G,r.webqit.DuplicateContextError=B,be.call(r,t)}function be(n){let t=this;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(r=>{let e=r===t.Document.prototype?"Document":r===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.contexts in r)throw new Error(`The ${e} prototype already has a "${n.api.contexts}" API!`);Object.defineProperty(r,n.api.contexts,{get:function(){return W.instance(this)}})})}Tt.call(window);})();
2
2
  //# sourceMappingURL=context-api.js.map