@webqit/oohtml 2.1.9 → 2.1.12

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
- (()=>{function x(r){return!Array.isArray(r)&&typeof r=="object"&&r}function L(r,...t){globalThis.WebQitInternalsRegistry||(globalThis.WebQitInternalsRegistry=new Map);var n=globalThis.WebQitInternalsRegistry.get(r);if(!n){if(n=new Map,t[0]===!1)return n;globalThis.WebQitInternalsRegistry.set(r,n)}for(var e,i;e=t.shift();)if((i=n)&&!(n=n.get(e))){if(n=new Map,t[0]===!1)return n;i.set(e,n)}return n}function g(r){return Array.isArray(r)}function R(r){return typeof r=="function"}function D(r){return r===null||r===""}function S(r){return arguments.length&&(r===void 0||typeof r>"u")}function O(r){return Array.isArray(r)||typeof r=="object"&&r||R(r)}function J(r){return D(r)||S(r)||r===!1||r===0||O(r)&&!Object.keys(r).length}function w(r){return R(r)||r&&{}.toString.call(r)==="[object function]"}function N(r){return r instanceof Number||typeof r=="number"}function E(r){return N(r)||r!==!0&&r!==!1&&r!==null&&r!==""&&!isNaN(r*1)}function W(r){return r instanceof String||typeof r=="string"&&r!==null}function Q(r){return!W(r)&&!S(r.length)}function B(r,...t){return t.forEach(n=>{r.indexOf(n)<0&&r.push(n)}),r}function X(e,t){t=t||Object.prototype,t=t&&!g(t)?[t]:t;for(var n=[],e=e;e&&(!t||t.indexOf(e)<0)&&e.name!=="default";)n.push(e),e=e?Object.getPrototypeOf(e):null;return n}function Y(r,t){var n=[];return X(r,t).forEach(e=>{B(n,...Object.getOwnPropertyNames(e))}),n}function T(r,t,n=!1,e=!1,i=!1){var o=0,s=r.shift();if((E(s)||s===!0||s===!1)&&(o=s,s=r.shift()),!r.length)throw new Error("_merge() requires two or more array/objects.");return r.forEach((l,a)=>{!O(l)&&!w(l)||(n?Y(l):Object.keys(l)).forEach(u=>{if(!!t(u,s,l,a)){var f=s[u],c=l[u];if((g(f)&&g(c)||x(f)&&x(c))&&(o===!0||o>0))s[u]=g(f)&&g(c)?[]:{},T([E(o)?o-1:o,s[u],f,c],t,n,e,i);else if(g(s)&&g(l))e?s[u]=c:s.push(c);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(l,u)):s[u]=l[u]}catch{}}})}),s}function k(...r){return T(r,(t,n,e)=>!0,!1,!1,!1)}function b(r,t=!0){return g(r)?r:!t&&x(r)?[r]:r!==!1&&r!==0&&J(r)?[]:Q(r)?Array.prototype.slice.call(r):x(r)?Object.values(r):[r]}function P(r,t,n={},e={}){t=b(t).slice();for(var i=r;!S(i)&&!D(i)&&t.length;){var o=t.shift();if(!(n.get?n.get(i,o):O(i)?o in i:i[o])){e.exists=!1;return}i=n.get?n.get(i,o):i[o]}return e.exists=!0,i}function K(r,t,n,e={},i={}){let o=(f,c,p)=>i.set?i.set(f,c,p):(E(t[l])&&g(f)?f.push(p):f[c]=p,!0);t=b(t);for(var s=r,l=0;l<t.length;l++)if(l<t.length-1){if(!s||!O(s)&&!w(s))return!1;var a=P(s,t[l],i);if(!O(a)){if(i.buildTree===!1)return!1;a=w(i.buildTree)?i.buildTree(l):E(t[l+1])?[]:{};var u=o(s,t[l],a);if(!u)return!1}s=a}else return o(s,t[l],n)}var ft=r=>class{constructor(n=!0){Object.defineProperty(this,"window",{value:r}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),this.async=n,this.window.requestAnimationFrame?this._run():this.async=!1}_run(){this.window.requestAnimationFrame(()=>{this.readCallbacks.forEach(n=>{n()||this.readCallbacks.delete(n)}),this.writeCallbacks.forEach(n=>{n()||this.writeCallbacks.delete(n)}),this._run()})}onread(n,e=!1){if(e)return new Promise((i,o)=>{this.async===!1?n(i,o):this.readCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.readCallbacks.add(n)}onwrite(n,e=!1){if(e)return new Promise((i,o)=>{this.async===!1?n(i,o):this.writeCallbacks.add(()=>{n(i,o)})});this.async===!1?n():this.writeCallbacks.add(n)}cycle(n,e,i){this.onread(()=>{let o=n(i),s=l=>{l!==void 0&&this.onwrite(()=>{let a=e(l,i),u=f=>{f!==void 0&&this.cycle(n,e,f)};a instanceof Promise?a.then(u):u(a)})};o instanceof Promise?o.then(s):s(o)})}};var H=class{constructor(t,n,e){this.context=t,this.namespace=n,this.window=t.defaultView||t.ownerDocument?.defaultView||e,this.document=this.window.document,this.wq=this.window.wq,Object.defineProperty(this,"#",{value:{}})}resolveArgs(t){return w(t[0])?t=[[],...t]:x(t[0])&&t.length===1?t=[[],void 0,t[0]]:x(t[1])&&t.length===2?t=[b(t[0],!1),void 0,t[1]]:t[0]=b(t[0],!1),t}registry(...t){return L(this.window,"dom.realtime",this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,n,e){let{window:i}=this,o=Array.isArray(n)?n:[n],s=new Set;for(let[l,a]of this.registry(t))for(let[u,f]of a){let c=o.filter(p=>u.contains(p.target)?l==="subtree"||p.target===u:!1);if(!!c.length){Array.isArray(n)||(c=c[0]);for(let p of f)s.add([p,c,u])}}for(let[l,a,u]of s)e.call(this,l,a,u)}disconnectables(t,...n){let e={disconnect(){n.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 q=class extends H{constructor(t,...n){super(t,"attr",...n)}get(t,n=void 0,e={}){let i=typeof t=="string";[t=[],n=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=dt(o,t),l=i?s[0]:s;if(!n)return l;let a=n&&e.lifecycleSignals&&this.createSignalGenerator(),u=a?.generate()||{};if(n(l,u,o),e.live){a&&(e={...e,signalGenerator:a});let f=this.observe(i?t[0]:t,n,{newValue:!0,...e});return this.disconnectables(e.signal,f)}}observe(t,n,e={}){let i=typeof t=="string";if([t=[],n,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(i?t[0]:t,n,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:o,window:s,wq:l}=this;e.eventDetails&&!l.dom.attrInterceptionHooks?.intercepting&&mt.call(s,"intercept",()=>{});let a=new s.MutationObserver(p=>{p=at(p).map(y=>pt.call(s,y)),lt.call(s,c,p,o)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree};t.length&&(u.attributeFilter=t),a.observe(o,u);let f=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:o,filter:t,callback:n,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:a};return this.disconnectables(e.signal,a,f)}observeSync(t,n,e={}){let i=typeof t=="string";[t,n,e={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let l=e.timing==="intercept"?"intercept":"sync",a=e.subtree?"subtree":"children";this.registry(l).size||mt.call(s,l,m=>{this.forEachMatchingContext(l,m,lt)});let u={disconnect(){y.delete(c),y.size||p.delete(o)}},f=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:o,filter:t,callback:n,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:u},p=this.registry(l,a);p.has(o)||p.set(o,new Set);let y=p.get(o);return y.add(c),this.disconnectables(e.signal,u,f)}};function at(r){return r.reduce((t,n,e)=>t[e-1]?.attributeName===n.attributeName?t:t.concat(n),[])}function lt(r,t){let{context:n,filter:e,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:a}=r;o.atomic&&!s.size&&(t=dt(n,e,t)),o.newValue===null&&o.oldValue===null||(t=t.map(c=>{let p;return!o.oldValue&&"oldValue"in c&&({oldValue:p,...c}=c),!o.newValue&&"value"in c?{value:p,...c}=c:o.newValue&&typeof c.value>"u"&&(c={...c,value:c.target.getAttribute(c.name)}),c})),o.atomic&&(t.forEach(c=>s.set(c.name,c)),t=Array.from(s.entries()).map(([,c])=>c));let u=l?t[0]:t,f=a?.generate()||{};i(u,f,n)}function dt(r,t,n=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>n.find(s=>s.name===o)||{target:r,name:o,value:r.getAttribute(o),...e}):Array.from(r.attributes).map(o=>n.find(s=>s.name===o.nodeName)||{target:r,name:o.nodeName,value:o.nodeValue,...e})}function pt({target:r,attributeName:t,value:n,oldValue:e}){let s=(this.wq.dom.attrInterceptionRecords?.get(r)||{})[t]||"mutation";return{target:r,name:t,value:n,oldValue:e,type:"observation",event:s}}function mt(r,t){let n=this,{wq:e,document:i,Element:o}=n;e.dom.attrInterceptionHooks||(e.dom.attrInterceptionHooks=new Map),e.dom.attrInterceptionHooks.has(r)||e.dom.attrInterceptionHooks.set(r,new Set),e.dom.attrInterceptionHooks.get(r).add(t);let s=()=>e.dom.attrInterceptionHooks.get(r).delete(t);if(e.dom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.dom.attrInterceptionHooks.intercepting=!0,e.dom.attrInterceptionRecords=new Map;let l=(f,c)=>{e.dom.attrInterceptionRecords.has(f.target)||e.dom.attrInterceptionRecords.set(f.target,{});let p=e.dom.attrInterceptionRecords.get(f.target);clearTimeout(p[f.name]?.timeout),p[f.name]=f.event;let y=setTimeout(()=>{delete p[f.name]},0);Object.defineProperty(f.event,"timeout",{value:y,configurable:!0}),e.dom.attrInterceptionHooks.get("intercept")?.forEach(h=>h([f]));let m=c();return e.dom.attrInterceptionHooks.get("sync")?.forEach(h=>h([f])),m};new n.MutationObserver(f=>{f=at(f).map(c=>pt.call(n,c)).filter((c,p)=>!Array.isArray(c.event)),f.length&&(e.dom.attrInterceptionHooks.get("intercept")?.forEach(c=>c(f)),e.dom.attrInterceptionHooks.get("sync")?.forEach(c=>c(f)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(f=>{u[f]=o.prototype[f],o.prototype[f]=function(...c){let p,y=this.getAttribute(c[0]);["setAttribute","toggleAttribute"].includes(f)&&(p=c[1]),f==="toggleAttribute"&&p===void 0&&(p=y===null);let m={target:this,name:c[0],value:p,oldValue:y,type:"interception",event:[this,f]};return l(m,()=>u[f].call(this,...c))}}),s}var F=class extends H{constructor(t,...n){super(t,"tree",...n)}attr(t,n=void 0,e={}){let{context:i,window:o}=this;return new q(i,o).get(...arguments)}query(t,n=void 0,e={}){[t,n=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=u=>(o.has(u)||o.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),o.get(u));if((!e.generation||e.generation==="entrants")&&(t.length?t.every(u=>typeof u=="string")&&(t=t.join(","))&&(e.subtree?i.querySelectorAll(t):[...i.children].filter(f=>f.matches(t))).forEach(f=>s(f.parentNode||i).entrants.push(f)):[...i.children].forEach(u=>s(i).entrants.push(u))),!n)return o;let l={disconnected:!1},a=n&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(l.disconnected)break;let f=a?.generate()||{};n(u,f,i)}if(e.live){a&&(e={...e,signalGenerator:a});let u=this.observe(t,n,e);return this.disconnectables(e.signal,l,u)}return this.disconnectables(e.signal,l,a)}children(t,n=void 0,e={}){return[t,n=void 0,e={}]=this.resolveArgs(arguments),this.query(t,n,{...e,subtree:!1})}subtree(t,n=void 0,e={}){return[t,n=void 0,e={}]=this.resolveArgs(arguments),this.query(t,n,{...e,subtree:!0})}observe(t,n,e={}){if([t,n,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,n,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,wq:s,document:l}=this;e.eventDetails&&(s.dom.domInterceptionRecordsAlwaysOn=!0),(l.readyState==="loading"||s.dom.domInterceptionRecordsAlwaysOn)&&!s.dom.domInterceptionHooks?.intercepting&&yt.call(o,"sync",()=>{});let a=new o.MutationObserver(c=>c.forEach(p=>{gt.call(o,f,_t.call(o,p),i)}));a.observe(i,{childList:!0,subtree:e.subtree});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:t,callback:n,params:e,signalGenerator:u,disconnectable:a};if(e.staticSensitivity){let c=ht.call(o,f);return this.disconnectables(e.signal,a,u,c)}return this.disconnectables(e.signal,a,u)}observeSync(t,n,e={}){[t,n,e={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(e.timing&&!["sync","intercept"].includes(e.timing))throw new Error(`Timing option "${e.timing}" invalid.`);let s=e.timing==="intercept"?"intercept":"sync",l=e.subtree?"subtree":"children";this.registry(s).size||yt.call(o,s,y=>{this.forEachMatchingContext(s,y,gt)});let a={disconnect(){p.delete(f),p.size||c.delete(i)}},u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:t,callback:n,params:e,signalGenerator:u,disconnectable:a},c=this.registry(s,l);c.has(i)||c.set(i,new Set);let p=c.get(i);if(p.add(f),e.staticSensitivity){let y=ht.call(o,f);return this.disconnectables(e.signal,a,u,y)}return this.disconnectables(e.signal,a,u)}};function ht(r){let t=this,{context:n,selectors:e,callback:i,params:o,signalGenerator:s}=r,l=f=>[...f.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(c=>c[1]);if(!(r.$attrs=e.filter(f=>typeof f=="string"&&f.includes("[")).reduce((f,c)=>f.concat(l(c)),[])).length)return;let a=new Set,u=new Set;return a.push=f=>(u.delete(f),a.add(f)),u.push=f=>(a.delete(f),u.add(f)),r.$deliveryCache={entrants:a,exits:u},new q(n,t).observe(r.$attrs,f=>{let c=new Map,p=h=>(c.has(h)||c.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),c.get(h)),y=new WeakMap,m=h=>(y.has(h)||y.set(h,e.some(d=>h.matches(d))),y.get(h));for(let h of f)["entrants","exits"].forEach(d=>{o.generation&&d!==o.generation||r.$deliveryCache[d].has(h.target)||(d==="entrants"?!m(h.target):m(h.target))||(r.$deliveryCache[d].push(h.target),p(h.target)[d].push(h.target),p(h.target).event=h.event)});for(let[,h]of c){let d=s?.generate()||{};i(h,d,n)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function gt(r,t){let{context:n,selectors:e,callback:i,params:o,signalGenerator:s,$deliveryCache:l}=r,a={...t,entrants:[],exits:[]};if(["entrants","exits"].forEach(f=>{if(!(o.generation&&f!==o.generation)&&(e.length?a[f]=Ft(e,t[f],t.event!=="parse"):a[f]=[...t[f]],!!l))for(let c of a[f])l[f].push(c)}),!a.entrants.length&&!a.exits.length)return;let u=s?.generate()||{};i(a,u,n)}function Ft(r,t,n){t=Array.isArray(t)?t:[...t];let e=(i,o)=>{if(i=i.filter(s=>s.matches),typeof o=="string"){let s=i.filter(l=>l.matches(o));if(n&&(s=i.reduce((l,a)=>[...l,...a.querySelectorAll(o)],s)),s.length)return s}else if(i.includes(o)||n&&i.some(s=>s.contains(o)))return[o]};return t.$$searchCache||(t.$$searchCache=new Map),r.reduce((i,o)=>{let s;return t.$$searchCache.has(o)?s=t.$$searchCache.get(o):(s=e(t,o)||[],x(o)&&t.$$searchCache.set(o,s)),i.concat(s)},[])}function _t({target:r,addedNodes:t,removedNodes:n}){let e=this,i;return i=b(t).reduce((o,s)=>o||e.wq.dom.domInterceptionRecords?.get(s),null),i=b(n).reduce((o,s)=>o||e.wq.dom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:r,entrants:t,exits:n,type:"observation",event:i}}function yt(r,t){let n=this,{wq:e,document:i,Node:o,Element:s,HTMLElement:l,HTMLTemplateElement:a,DocumentFragment:u}=n;e.dom.domInterceptionHooks||(e.dom.domInterceptionHooks=new Map),e.dom.domInterceptionHooks.has(r)||e.dom.domInterceptionHooks.set(r,new Set),e.dom.domInterceptionHooks.get(r).add(t);let f=()=>e.dom.domInterceptionHooks.get(r).delete(t);if(e.dom.domInterceptionHooks?.intercepting)return f;console.warn("DOM mutation APIs are now being intercepted."),e.dom.domInterceptionHooks.intercepting=!0,e.dom.domInterceptionRecords=new Map;let c=()=>!0,p=(m,h)=>{c()?m.entrants.concat(m.exits).forEach(_=>{clearTimeout(e.dom.domInterceptionRecords.get(_)?.timeout),e.dom.domInterceptionRecords.set(_,m.event);let v=setTimeout(()=>{e.dom.domInterceptionRecords.delete(_)},0);Object.defineProperty(m.event,"timeout",{value:v,configurable:!0})}):e.dom.domInterceptionRecords.clear(),e.dom.domInterceptionHooks.get("intercept")?.forEach(_=>_(m));let d=h();return e.dom.domInterceptionHooks.get("sync")?.forEach(_=>_(m)),d};if(c()){let m=new n.MutationObserver(h=>h.forEach(d=>{Array.isArray((d=_t.call(n,d)).event)||(e.dom.domInterceptionHooks.get("intercept")?.forEach(_=>_(d)),e.dom.domInterceptionHooks.get("sync")?.forEach(_=>_(d)))}));m.observe(i,{childList:!0,subtree:!0}),i.addEventListener("readystatechange",()=>!c()&&m.disconnect())}let y=Object.create(null);return["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(m=>{let h=["insertBefore","replaceChild","removeChild","appendChild"].includes(m)?o:s;y[m]=h.prototype[m],y[m]&&(h.prototype[m]=function(...d){let _=()=>y[m].call(this,...d);if(!(this instanceof s||this instanceof u))return _();let v=[],A=[],I=this;["insertBefore"].includes(m)?A=[d[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(m)?(A=[d[1]],["beforebegin","afterend"].includes(d[0])&&(I=this.parentNode)):["setHTML","replaceChildren"].includes(m)?(v=[...this.childNodes],A=m==="replaceChildren"?[...d]:[d[0]]):["replaceWith","remove"].includes(m)?(v=[this],A=m==="replaceWith"?[...d]:[],I=this.parentNode):["replaceChild"].includes(m)?(v=[d[1]],A=[d[0]]):["removeChild"].includes(m)?v=[...d]:(A=[...d],["before","after"].includes(m)&&(I=this.parentNode));let V=m;if(["insertAdjacentHTML","setHTML"].includes(m)){let M=this.nodeName;if(m==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(d[0])){if(!this.parentNode)return y[m].call(this,...d);M=this.parentNode.nodeName}let G=i.createElement(M);y.setHTML.call(G,A[0],m==="setHTML"?d[1]:{}),A=[...G.childNodes],m==="insertAdjacentHTML"?(V="insertAdjacentElement",d[1]=new u,d[1].______isTemp=!0,d[1].append(...G.childNodes)):(V="replaceChildren",d=[...G.childNodes])}return p({target:I,entrants:A,exits:v,type:"interception",event:[this,m]},()=>y[V].call(this,...d))})}),["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(m=>{let h=["textContent","nodeValue"].includes(m)?o:["outerText","innerText"].includes(m)?l:s;y[m]=Object.getOwnPropertyDescriptor(h.prototype,m),Object.defineProperty(h.prototype,m,{...y[m],set:function(d){let _=()=>y[m].set.call(this,d);if(!(this instanceof s))return _();let v=[],A=[],I=this;if(["outerHTML","outerText"].includes(m)?(v=[this],I=this.parentNode):v=[...this.childNodes],["outerHTML","innerHTML"].includes(m)){let j=this.nodeName;if(m==="outerHTML"){if(!this.parentNode)return _();j=this.parentNode.nodeName}let M=i.createElement(j==="TEMPLATE"?"div":j);y[m].set.call(M,d),A=this instanceof a?[]:[...M.childNodes],m==="outerHTML"?(d=new u,d.______isTemp=!0,d.append(...M.childNodes),_=()=>y.replaceWith.call(this,d)):this instanceof a?_=()=>this.content.replaceChildren(...M.childNodes):_=()=>y.replaceChildren.call(this,...M.childNodes)}return p({target:I,entrants:A,exits:v,type:"interception",event:[this,m]},_)}})}),["append","prepend","replaceChildren"].forEach(m=>{[i,u.prototype].forEach(h=>{let d=h[m];h[m]=function(..._){if(this.______isTemp)return d.call(this,..._);let v=m==="replaceChildren"?[...this.childNodes]:[];return p({target:this,entrants:_,exits:v,type:"interception",event:[this,m]},()=>d.call(this,..._))}})}),f}function xt(){Dt.call(this),Nt.call(this),kt.call(this)}function Dt(){let r=this;r.CSS||(r.CSS={}),r.CSS.escape||(r.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function Nt(){let r=this;"isConnected"in r.Node.prototype||Object.defineProperty(r.Node.prototype,"isConnected",{get:function(){return!this.ownerDocument||!(this.ownerDocument.compareDocumentPosition(this)&this.DOCUMENT_POSITION_DISCONNECTED)}})}function kt(){let r=this;r.Element.prototype.matches||(r.Element.prototype.matches=r.Element.prototype.matchesSelector||r.Element.prototype.mozMatchesSelector||r.Element.prototype.msMatchesSelector||r.Element.prototype.oMatchesSelector||r.Element.prototype.webkitMatchesSelector||function(t){for(var n=(this.document||this.ownerDocument).querySelectorAll(t),e=n.length;--e>=0&&n.item(e)!==this;);return e>-1})}function wt(){let r=this;if(r.wq||(r.wq={}),r.wq.dom)return r.wq.dom;r.wq.dom={},xt.call(r);let t=ft(r);return r.wq.dom.Reflow=new t,r.wq.dom.DOMRealtime=F,r.wq.dom.AttrRealtime=q,r.wq.dom.realtime=(n,e="tree")=>{if(e==="tree")return new F(n,r);if(e==="attr")return new q(n,r)},r.wq.dom.ready=$t.bind(r),r.wq.dom.meta=Vt.bind(r),r.wq.dom}function $t(r){let t=this;t.document.readyState==="complete"?r(t):(t.document.domReadyCallbacks||(t.document.domReadyCallbacks=[],t.document.addEventListener("DOMContentLoaded",()=>{t.document.domReadyCallbacks.splice(0).forEach(n=>n(t))},!1)),t.document.domReadyCallbacks.push(r))}function Vt(r,t=!1){let n=this,e={content:{}};return!(e.el=n.document.querySelector(`meta[name="${r}"]`))&&t&&(e.el=n.document.createElement("meta"),e.el.setAttribute("name",r),n.document.head.append(e.el)),e.el&&(e.content=(e.el.getAttribute("content")||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(l=>l.trim());return K(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:E(s[1])?parseInt(s[1]):s[1]),i},{})),e.get=function(i){return JSON.parse(JSON.stringify(P(this.content,i.split("."))))},e.copy=function(){return JSON.parse(JSON.stringify(this.content))},e.copyWithDefaults=function(...i){return i.length?k(!0,{},...i.reverse().concat(this.content)):this.copy()},e}function Ot(){let r=this;return class extends r.Event{constructor(n,e,{type:i="contextrequest",...o}={}){super(i,o),Object.defineProperty(this,"request",{get:()=>n}),Object.defineProperty(this,"callback",{get:()=>e})}respondWith(n,...e){if(this.request.diff){if("previousValue"in this&&this.previousValue===n)return;this.previousValue=n}return this.callback(n,...e)}}}var z=(r,...t)=>L(r,"oohtml",...t),et=(r,t,n=1,e=!1)=>{if(n&&typeof r=="object"&&r&&typeof t=="object"&&t&&(!e||Object.keys(r).length===Object.keys(t).length)){for(let i in r)if(!et(r[i],t[i],n-1,e))return!1;return!0}return Array.isArray(r)&&Array.isArray(t)&&r.length===t.length?(t=t.slice(0).sort())&&r.slice(0).sort().every((i,o)=>i===t[o]):r===t};var C=class{static instance(t){return z(t).get("contextsmanager::instance")||new this(t)}constructor(t){z(t).get("contextsmanager::instance")?.dispose(),z(t).set("contextsmanager::instance",this);let n={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>n});let e=Ot.call(t.ownerDocument?.defaultView||t.defaultView);Object.defineProperty(this,"ContextRequestEvent",{get:()=>e}),this[Symbol.iterator]=function*(){yield n.contexts[Symbol.iterator]().next().value}}get length(){this["#"].contexts.size}find(t){return[...this["#"].contexts].find(t)}attach(t){this["#"].contexts.add(t),t.initialize(this["#"].host)}detach(t){t.dispose(this["#"].host),this["#"].contexts.delete(t)}ask(t,n,e={}){return this["#"].host.dispatchEvent(new this.ContextRequestEvent(t,n,{bubbles:!0,...e}))}dispose(){}};var $=class{static get params(){return{}}static attachTo(t,n,e=!1){let i,o=C.instance(t);return!e&&(i=o.find(s=>this.matchRequest(s.id,n,!0)))?i:o.attach(new this(n))}static detachFrom(t,n,e=!1){let i,o=C.instance(t);for(i of o["#"].contexts)if(!(!this.matchRequest(i.id,n,!0)||typeof e=="function"&&!e(i))&&(o.detach(i),typeof e!="function"&&!e))return i}static createId(t,n={}){let e={type:"HTMLModules",...n};return e.name||(t.getAttribute&&!(e.name=(t.getAttribute(this.params.context.attr.contextname)||"").trim())?delete e.name:t.ownerDocument||(e.name="root")),e}static createRequest(t={}){return{...t}}static matchRequest(t,n,e=!1){return e?et(t,n,1,!0):n.type===t.type&&!n.name||n.name===t.name}constructor(t){Object.defineProperty(this,"id",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get length(){this.subscriptions.size}handle(t){}subscribe(t){this.subscriptions.add(t),t.request.signal&&t.request.signal.addEventListener("abort",()=>{this.unsubscribe(t)})}unsubscribe(t){this.subscriptions.delete(t),t.request.controller?.abort()}handleEvent(t){if(!(this.disposed||t.target===this.host&&t.request?.superContextOnly||!t.request||typeof t.callback!="function"||!this.constructor.matchRequest(this.id,t.request)))if(t.stopPropagation(),t.type==="contextclaim"){let n=new Set;this.subscriptions.forEach(e=>{!t.target.contains(e.request.superContextOnly?e.target.parentNode:e.target)||!this.constructor.matchRequest(t.request,e.request)||(this.subscriptions.delete(e),n.add(e))}),t.respondWith(n)}else t.type==="contextrequest"&&(t.request.live&&this.subscribe(t),this.handle(t))}initialize(t){return this.host=t,this.disposed=!1,t.addEventListener("contextrequest",this),t.addEventListener("contextclaim",this),C.instance(t).ask({...this.id,superContextOnly:!0},n=>n.forEach(e=>{this.subscribe(e),this.handle(e)}),{type:"contextclaim"}),this}dispose(t){return this.disposed=!0,t.removeEventListener("contextrequest",this),t.removeEventListener("contextclaim",this),this.subscriptions.forEach(n=>{this.unsubscribe(n);let{target:e,request:i,callback:o,params:s}=n;C.instance(e).ask(i,o,s)}),this}};function rt(r={}){let t=this,n=wt.call(t);t.wq||(t.wq={}),t.wq.HTMLContextManager=C,t.wq.HTMLContext=$;let e=n.meta("oohtml").copyWithDefaults(r,{api:{context:"context"}});jt.call(this,e)}function jt(r){let t=this;if(r.api.context in t.document)throw new Error(`document already has a "${r.api.context}" property!`);if(r.api.context in t.HTMLElement.prototype)throw new Error(`The "HTMLElement" class already has a "${r.api.context}" property!`);Object.defineProperty(t.document,r.api.context,{get:function(){return C.instance(t.document)}}),Object.defineProperty(t.HTMLElement.prototype,r.api.context,{get:function(){return C.instance(this)}})}rt.call(window);})();
1
+ (()=>{function x(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function Q(n,e,r=null){return g(e)?n.filter(t=>r?e.filter(i=>r(t,i)).length:e.indexOf(t)!==-1):[]}function H(n,...e){globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new R});var r=globalThis.webqit.refs.get(n);r||(r=new R,globalThis.webqit.refs.set(n,r));for(var t,i;t=e.shift();)(i=r)&&!(r=r.get(t))&&(r=new R,i.set(t,r));return r}var R=class extends Map{constructor(...e){super(...e),this.observers=new Set}set(e,r){let t=super.set(e,r);return this.fire("set",e,r,e),t}delete(e){let r=super.delete(e);return this.fire("delete",e),r}has(e){return this.fire("has",e),super.has(e)}get(e){return this.fire("get",e),super.get(e)}keyNames(){return Array.from(super.keys())}observe(e,r,t){let i={type:e,key:r,callback:t};return this.observers.add(i),()=>this.observers.delete(i)}unobserve(e,r,t){if(Array.isArray(e)||Array.isArray(r))throw new Error('The "type" and "key" arguments can only be strings.');for(let i of this.observers)!(B([e,"*"],i.type)&&B([r,"*"],i.key)&&i.callback===t)||this.observers.delete(i)}fire(e,r,...t){for(let i of this.observers)!(B([e,"*"],i.type)&&B([r,"*"],i.key))||i.callback(...t)}},B=(n,e)=>Array.isArray(e)?Q(n,e).length:n.includes(e);function L(n){return typeof n=="function"}function N(n){return n===null||n===""}function S(n){return arguments.length&&(n===void 0||typeof n>"u")}function b(n){return Array.isArray(n)||typeof n=="object"&&n||L(n)}function X(n){return N(n)||S(n)||n===!1||n===0||b(n)&&!Object.keys(n).length}function w(n){return L(n)||n&&{}.toString.call(n)==="[object function]"}function j(n){return n instanceof Number||typeof n=="number"}function E(n){return j(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function W(n){return n instanceof String||typeof n=="string"&&n!==null}function Y(n){return!W(n)&&!S(n.length)}function U(n,...e){return e.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function Z(t,e){e=e||Object.prototype,e=e&&!g(e)?[e]:e;for(var r=[],t=t;t&&(!e||e.indexOf(t)<0)&&t.name!=="default";)r.push(t),t=t?Object.getPrototypeOf(t):null;return r}function K(n,e){var r=[];return Z(n,e).forEach(t=>{U(r,...Object.getOwnPropertyNames(t))}),r}function T(n,e,r=!1,t=!1,i=!1){var o=0,s=n.shift();if((E(s)||s===!0||s===!1)&&(o=s,s=n.shift()),!n.length)throw new Error("_merge() requires two or more array/objects.");return n.forEach((l,m)=>{!b(l)&&!w(l)||(r?K(l):Object.keys(l)).forEach(u=>{if(!!e(u,s,l,m)){var f=s[u],c=l[u];if((g(f)&&g(c)||x(f)&&x(c))&&(o===!0||o>0))s[u]=g(f)&&g(c)?[]:{},T([E(o)?o-1:o,s[u],f,c],e,r,t,i);else if(g(s)&&g(l))t?s[u]=c:s.push(c);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(l,u)):s[u]=l[u]}catch{}}})}),s}function O(n,e=!0){return g(n)?n:!e&&x(n)?[n]:n!==!1&&n!==0&&X(n)?[]:Y(n)?Array.prototype.slice.call(n):x(n)?Object.values(n):[n]}function k(n,e,r={},t={}){e=O(e).slice();for(var i=n;!S(i)&&!N(i)&&e.length;){var o=e.shift();if(!(r.get?r.get(i,o):b(i)?o in i:i[o])){t.exists=!1;return}i=r.get?r.get(i,o):i[o]}return t.exists=!0,i}function te(...n){return T(n,(e,r,t)=>{if(g(r)&&g(t)){if(r.indexOf(t[e])===-1)return!0}else if(!(e in r))return!0})}function re(n,e,r,t={},i={}){let o=(f,c,p)=>i.set?i.set(f,c,p):(E(e[l])&&g(f)?f.push(p):f[c]=p,!0);e=O(e);for(var s=n,l=0;l<e.length;l++)if(l<e.length-1){if(!s||!b(s)&&!w(s))return!1;var m=k(s,e[l],i);if(!b(m)){if(i.buildTree===!1)return!1;m=w(i.buildTree)?i.buildTree(l):E(e[l+1])?[]:{};var u=o(s,e[l],m);if(!u)return!1}s=m}else return o(s,e[l],r)}var ae=n=>class{constructor(r=!0){Object.defineProperty(this,"window",{value:n}),Object.defineProperty(this,"readCallbacks",{value:new Set}),Object.defineProperty(this,"writeCallbacks",{value:new Set}),this.async=r,this.window.requestAnimationFrame?this._run():this.async=!1}_run(){this.window.requestAnimationFrame(()=>{this.readCallbacks.forEach(r=>{r()||this.readCallbacks.delete(r)}),this.writeCallbacks.forEach(r=>{r()||this.writeCallbacks.delete(r)}),this._run()})}onread(r,t=!1){if(t)return new Promise((i,o)=>{this.async===!1?r(i,o):this.readCallbacks.add(()=>{r(i,o)})});this.async===!1?r():this.readCallbacks.add(r)}onwrite(r,t=!1){if(t)return new Promise((i,o)=>{this.async===!1?r(i,o):this.writeCallbacks.add(()=>{r(i,o)})});this.async===!1?r():this.writeCallbacks.add(r)}cycle(r,t,i){this.onread(()=>{let o=r(i),s=l=>{l!==void 0&&this.onwrite(()=>{let m=t(l,i),u=f=>{f!==void 0&&this.cycle(r,t,f)};m instanceof Promise?m.then(u):u(m)})};o instanceof Promise?o.then(s):s(o)})}};var P=class{constructor(e,r,t){this.context=e,this.namespace=r,this.window=e.defaultView||e.ownerDocument?.defaultView||t,this.document=this.window.document,this.webqit=this.window.webqit,Object.defineProperty(this,"#",{value:{}})}resolveArgs(e){return w(e[0])?e=[[],...e]:x(e[0])&&e.length===1?e=[[],void 0,e[0]]:x(e[1])&&e.length===2?e=[O(e[0],!1),void 0,e[1]]:e[0]=O(e[0],!1),e}registry(...e){return H("dom.realtime",this.window,this.namespace,...e)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(e,r,t){let{window:i}=this,o=Array.isArray(r)?r:[r],s=new Set;for(let[l,m]of this.registry(e))for(let[u,f]of m){let c=o.filter(p=>u.contains(p.target)?l==="subtree"||p.target===u:!1);if(!!c.length){Array.isArray(r)||(c=c[0]);for(let p of f)s.add([p,c,u])}}for(let[l,m,u]of s)t.call(this,l,m,u)}disconnectables(e,...r){let t={disconnect(){r.forEach(i=>i&&w(i.disconnect)&&i.disconnect()||w(i)&&i()||x(i)&&(i.disconnected=!0))}};return e&&e.addEventListener("abort",()=>t.disconnect()),t}};var q=class extends P{constructor(e,...r){super(e,"attr",...r)}get(e,r=void 0,t={}){let i=typeof e=="string";[e=[],r=void 0,t={}]=this.resolveArgs(arguments);let{context:o}=this,s=ye(o,e),l=i?s[0]:s;if(!r)return l;let m=r&&t.lifecycleSignals&&this.createSignalGenerator(),u=m?.generate()||{};if(r(l,u,o),t.live){m&&(t={...t,signalGenerator:m});let f=this.observe(i?e[0]:e,r,{newValue:!0,...t});return this.disconnectables(t.signal,f)}}observe(e,r,t={}){let i=typeof e=="string";if([e=[],r,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(i?e[0]:e,r,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:o,window:s,webqit:l}=this;t.eventDetails&&!l.dom.attrInterceptionHooks?.intercepting&&he.call(s,"intercept",()=>{});let m=new s.MutationObserver(p=>{p=ge(p).map(y=>_e.call(s,y)),pe.call(s,c,p,o)}),u={attributes:!0,attributeOldValue:t.oldValue,subtree:t.subtree};e.length&&(u.attributeFilter=e),m.observe(o,u);let f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),c={context:o,filter:e,callback:r,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:m};return this.disconnectables(t.signal,m,f)}observeSync(e,r,t={}){let i=typeof e=="string";[e,r,t={}]=this.resolveArgs(arguments);let{context:o,window:s}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let l=t.timing==="intercept"?"intercept":"sync",m=t.subtree?"subtree":"children";this.registry(l).size||he.call(s,l,a=>{this.forEachMatchingContext(l,a,pe)});let u={disconnect(){y.delete(c),y.size||p.delete(o)}},f=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),c={context:o,filter:e,callback:r,params:t,atomics:new Map,originalFilterIsString:i,signalGenerator:f,disconnectable:u},p=this.registry(l,m);p.has(o)||p.set(o,new Set);let y=p.get(o);return y.add(c),this.disconnectables(t.signal,u,f)}};function ge(n){return n.reduce((e,r,t)=>e[t-1]?.attributeName===r.attributeName?e:e.concat(r),[])}function pe(n,e){let{context:r,filter:t,callback:i,params:o,atomics:s,originalFilterIsString:l,signalGenerator:m}=n;o.atomic&&!s.size&&(e=ye(r,t,e)),o.newValue===null&&o.oldValue===null||(e=e.map(c=>{let p;return!o.oldValue&&"oldValue"in c&&({oldValue:p,...c}=c),!o.newValue&&"value"in c?{value:p,...c}=c:o.newValue&&typeof c.value>"u"&&(c={...c,value:c.target.getAttribute(c.name)}),c})),o.atomic&&(e.forEach(c=>s.set(c.name,c)),e=Array.from(s.entries()).map(([,c])=>c));let u=l?e[0]:e,f=m?.generate()||{};i(u,f,r)}function ye(n,e,r=[]){let t={event:null,type:"attribute"};return e.length?e.map(o=>r.find(s=>s.name===o)||{target:n,name:o,value:n.getAttribute(o),...t}):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:o.nodeValue,...t})}function _e({target:n,attributeName:e,value:r,oldValue:t}){let s=(this.webqit.dom.attrInterceptionRecords?.get(n)||{})[e]||"mutation";return{target:n,name:e,value:r,oldValue:t,type:"observation",event:s}}function he(n,e){let r=this,{webqit:t,document:i,Element:o}=r;t.dom.attrInterceptionHooks||Object.defineProperty(t.dom,"attrInterceptionHooks",{value:new Map}),t.dom.attrInterceptionHooks.has(n)||t.dom.attrInterceptionHooks.set(n,new Set),t.dom.attrInterceptionHooks.get(n).add(e);let s=()=>t.dom.attrInterceptionHooks.get(n).delete(e);if(t.dom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),t.dom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(t.dom,"attrInterceptionRecords",{value:new Map});let l=(f,c)=>{t.dom.attrInterceptionRecords.has(f.target)||t.dom.attrInterceptionRecords.set(f.target,{});let p=t.dom.attrInterceptionRecords.get(f.target);clearTimeout(p[f.name]?.timeout),p[f.name]=f.event;let y=setTimeout(()=>{delete p[f.name]},0);Object.defineProperty(f.event,"timeout",{value:y,configurable:!0}),t.dom.attrInterceptionHooks.get("intercept")?.forEach(h=>h([f]));let a=c();return t.dom.attrInterceptionHooks.get("sync")?.forEach(h=>h([f])),a};new r.MutationObserver(f=>{f=ge(f).map(c=>_e.call(r,c)).filter((c,p)=>!Array.isArray(c.event)),f.length&&(t.dom.attrInterceptionHooks.get("intercept")?.forEach(c=>c(f)),t.dom.attrInterceptionHooks.get("sync")?.forEach(c=>c(f)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(f=>{u[f]=o.prototype[f],o.prototype[f]=function(...c){let p,y=this.getAttribute(c[0]);["setAttribute","toggleAttribute"].includes(f)&&(p=c[1]),f==="toggleAttribute"&&p===void 0&&(p=y===null);let a={target:this,name:c[0],value:p,oldValue:y,type:"interception",event:[this,f]};return l(a,()=>u[f].call(this,...c))}}),s}var F=class extends P{constructor(e,...r){super(e,"tree",...r)}attr(e,r=void 0,t={}){let{context:i,window:o}=this;return new q(i,o).get(...arguments)}query(e,r=void 0,t={}){[e,r=void 0,t={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=u=>(o.has(u)||o.set(u,{target:u,entrants:[],exits:[],type:"query",event:null}),o.get(u));if((!t.generation||t.generation==="entrants")&&(e.length?e.every(u=>typeof u=="string")&&(e=e.join(","))&&(t.subtree?i.querySelectorAll(e):[...i.children].filter(f=>f.matches(e))).forEach(f=>s(f.parentNode||i).entrants.push(f)):[...i.children].forEach(u=>s(i).entrants.push(u))),!r)return o;let l={disconnected:!1},m=r&&t.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(l.disconnected)break;let f=m?.generate()||{};r(u,f,i)}if(t.live){m&&(t={...t,signalGenerator:m});let u=this.observe(e,r,t);return this.disconnectables(t.signal,l,u)}return this.disconnectables(t.signal,l,m)}children(e,r=void 0,t={}){return[e,r=void 0,t={}]=this.resolveArgs(arguments),this.query(e,r,{...t,subtree:!1})}subtree(e,r=void 0,t={}){return[e,r=void 0,t={}]=this.resolveArgs(arguments),this.query(e,r,{...t,subtree:!0})}observe(e,r,t={}){if([e,r,t={}]=this.resolveArgs(arguments),["sync","intercept"].includes(t.timing))return this.observeSync(e,r,t);if(t.timing&&t.timing!=="async")throw new Error(`Timing option "${t.timing}" invalid.`);let{context:i,window:o,webqit:s,document:l}=this;t.eventDetails&&(s.dom.domInterceptionRecordsAlwaysOn=!0),(l.readyState==="loading"||s.dom.domInterceptionRecordsAlwaysOn)&&!s.dom.domInterceptionHooks?.intercepting&&be.call(o,"sync",()=>{});let m=new o.MutationObserver(c=>c.forEach(p=>{we.call(o,f,Oe.call(o,p),i)}));m.observe(i,{childList:!0,subtree:t.subtree});let u=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:e,callback:r,params:t,signalGenerator:u,disconnectable:m};if(t.staticSensitivity){let c=xe.call(o,f);return this.disconnectables(t.signal,m,u,c)}return this.disconnectables(t.signal,m,u)}observeSync(e,r,t={}){[e,r,t={}]=this.resolveArgs(arguments);let{context:i,window:o}=this;if(t.timing&&!["sync","intercept"].includes(t.timing))throw new Error(`Timing option "${t.timing}" invalid.`);let s=t.timing==="intercept"?"intercept":"sync",l=t.subtree?"subtree":"children";this.registry(s).size||be.call(o,s,y=>{this.forEachMatchingContext(s,y,we)});let m={disconnect(){p.delete(f),p.size||c.delete(i)}},u=t.signalGenerator||t.lifecycleSignals&&this.createSignalGenerator(),f={context:i,selectors:e,callback:r,params:t,signalGenerator:u,disconnectable:m},c=this.registry(s,l);c.has(i)||c.set(i,new Set);let p=c.get(i);if(p.add(f),t.staticSensitivity){let y=xe.call(o,f);return this.disconnectables(t.signal,m,u,y)}return this.disconnectables(t.signal,m,u)}};function xe(n){let e=this,{context:r,selectors:t,callback:i,params:o,signalGenerator:s}=n,l=f=>[...f.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(c=>c[1]);if(!(n.$attrs=t.filter(f=>typeof f=="string"&&f.includes("[")).reduce((f,c)=>f.concat(l(c)),[])).length)return;let m=new Set,u=new Set;return m.push=f=>(u.delete(f),m.add(f)),u.push=f=>(m.delete(f),u.add(f)),n.$deliveryCache={entrants:m,exits:u},new q(r,e).observe(n.$attrs,f=>{let c=new Map,p=h=>(c.has(h)||c.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),c.get(h)),y=new WeakMap,a=h=>(y.has(h)||y.set(h,t.some(d=>h.matches(d))),y.get(h));for(let h of f)["entrants","exits"].forEach(d=>{o.generation&&d!==o.generation||n.$deliveryCache[d].has(h.target)||(d==="entrants"?!a(h.target):a(h.target))||(n.$deliveryCache[d].push(h.target),p(h.target)[d].push(h.target),p(h.target).event=h.event)});for(let[,h]of c){let d=s?.generate()||{};i(h,d,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function we(n,e){let{context:r,selectors:t,callback:i,params:o,signalGenerator:s,$deliveryCache:l}=n,m={...e,entrants:[],exits:[]};if(["entrants","exits"].forEach(f=>{if(!(o.generation&&f!==o.generation)&&(t.length?m[f]=$e(t,e[f],e.event!=="parse"):m[f]=[...e[f]],!!l))for(let c of m[f])l[f].push(c)}),!m.entrants.length&&!m.exits.length)return;let u=s?.generate()||{};i(m,u,r)}function $e(n,e,r){e=Array.isArray(e)?e:[...e];let t=(i,o)=>{if(i=i.filter(s=>s.matches),typeof o=="string"){let s=i.filter(l=>l.matches(o));if(r&&(s=i.reduce((l,m)=>[...l,...m.querySelectorAll(o)],s)),s.length)return s}else if(i.includes(o)||r&&i.some(s=>s.contains(o)))return[o]};return e.$$searchCache||(e.$$searchCache=new Map),n.reduce((i,o)=>{let s;return e.$$searchCache.has(o)?s=e.$$searchCache.get(o):(s=t(e,o)||[],x(o)&&e.$$searchCache.set(o,s)),i.concat(s)},[])}function Oe({target:n,addedNodes:e,removedNodes:r}){let t=this,i;return i=O(e).reduce((o,s)=>o||t.webqit.dom.domInterceptionRecords?.get(s),null),i=O(r).reduce((o,s)=>o||t.webqit.dom.domInterceptionRecords?.get(s),i),i=i||t.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:e,exits:r,type:"observation",event:i}}function be(n,e){let r=this,{webqit:t,document:i,Node:o,Element:s,HTMLElement:l,HTMLTemplateElement:m,DocumentFragment:u}=r;t.dom.domInterceptionHooks||Object.defineProperty(t.dom,"domInterceptionHooks",{value:new Map}),t.dom.domInterceptionHooks.has(n)||t.dom.domInterceptionHooks.set(n,new Set),t.dom.domInterceptionHooks.get(n).add(e);let f=()=>t.dom.domInterceptionHooks.get(n).delete(e);if(t.dom.domInterceptionHooks?.intercepting)return f;console.warn("DOM mutation APIs are now being intercepted."),t.dom.domInterceptionHooks.intercepting=!0,Object.defineProperty(t.dom,"domInterceptionRecords",{value:new Map});let c=()=>!0,p=(a,h)=>{c()?a.entrants.concat(a.exits).forEach(_=>{clearTimeout(t.dom.domInterceptionRecords.get(_)?.timeout),t.dom.domInterceptionRecords.set(_,a.event);let v=setTimeout(()=>{t.dom.domInterceptionRecords.delete(_)},0);Object.defineProperty(a.event,"timeout",{value:v,configurable:!0})}):t.dom.domInterceptionRecords.clear(),t.dom.domInterceptionHooks.get("intercept")?.forEach(_=>_(a));let d=h();return t.dom.domInterceptionHooks.get("sync")?.forEach(_=>_(a)),d};if(c()){let a=new r.MutationObserver(h=>h.forEach(d=>{Array.isArray((d=Oe.call(r,d)).event)||(t.dom.domInterceptionHooks.get("intercept")?.forEach(_=>_(d)),t.dom.domInterceptionHooks.get("sync")?.forEach(_=>_(d)))}));a.observe(i,{childList:!0,subtree:!0}),i.addEventListener("readystatechange",()=>!c()&&a.disconnect())}let y=Object.create(null);return["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(a=>{let h=["insertBefore","replaceChild","removeChild","appendChild"].includes(a)?o:s;y[a]=h.prototype[a],y[a]&&(h.prototype[a]=function(...d){let _=()=>y[a].call(this,...d);if(!(this instanceof s||this instanceof u))return _();let v=[],A=[],I=this;["insertBefore"].includes(a)?A=[d[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(a)?(A=[d[1]],["beforebegin","afterend"].includes(d[0])&&(I=this.parentNode)):["setHTML","replaceChildren"].includes(a)?(v=[...this.childNodes],A=a==="replaceChildren"?[...d]:[d[0]]):["replaceWith","remove"].includes(a)?(v=[this],A=a==="replaceWith"?[...d]:[],I=this.parentNode):["replaceChild"].includes(a)?(v=[d[1]],A=[d[0]]):["removeChild"].includes(a)?v=[...d]:(A=[...d],["before","after"].includes(a)&&(I=this.parentNode));let $=a;if(["insertAdjacentHTML","setHTML"].includes(a)){let M=this.nodeName;if(a==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(d[0])){if(!this.parentNode)return y[a].call(this,...d);M=this.parentNode.nodeName}let G=i.createElement(M);y.setHTML.call(G,A[0],a==="setHTML"?d[1]:{}),A=[...G.childNodes],a==="insertAdjacentHTML"?($="insertAdjacentElement",d[1]=new u,d[1].______isTemp=!0,d[1].append(...G.childNodes)):($="replaceChildren",d=[...G.childNodes])}return p({target:I,entrants:A,exits:v,type:"interception",event:[this,a]},()=>y[$].call(this,...d))})}),["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(a=>{let h=["textContent","nodeValue"].includes(a)?o:["outerText","innerText"].includes(a)?l:s;y[a]=Object.getOwnPropertyDescriptor(h.prototype,a),Object.defineProperty(h.prototype,a,{...y[a],set:function(d){let _=()=>y[a].set.call(this,d);if(!(this instanceof s))return _();let v=[],A=[],I=this;if(["outerHTML","outerText"].includes(a)?(v=[this],I=this.parentNode):v=[...this.childNodes],["outerHTML","innerHTML"].includes(a)){let V=this.nodeName;if(a==="outerHTML"){if(!this.parentNode)return _();V=this.parentNode.nodeName}let M=i.createElement(V==="TEMPLATE"?"div":V);y[a].set.call(M,d),A=this instanceof m?[]:[...M.childNodes],a==="outerHTML"?(d=new u,d.______isTemp=!0,d.append(...M.childNodes),_=()=>y.replaceWith.call(this,d)):this instanceof m?_=()=>this.content.replaceChildren(...M.childNodes):_=()=>y.replaceChildren.call(this,...M.childNodes)}return p({target:I,entrants:A,exits:v,type:"interception",event:[this,a]},_)}})}),["append","prepend","replaceChildren"].forEach(a=>{[i,u.prototype].forEach(h=>{let d=h[a];h[a]=function(..._){if(this.______isTemp)return d.call(this,..._);let v=a==="replaceChildren"?[...this.childNodes]:[];return p({target:this,entrants:_,exits:v,type:"interception",event:[this,a]},()=>d.call(this,..._))}})}),f}function ve(){Ve.call(this),Ge.call(this),Be.call(this)}function Ve(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=e=>e.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 Be(){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(e){for(var r=(this.document||this.ownerDocument).querySelectorAll(e),t=r.length;--t>=0&&r.item(t)!==this;);return t>-1})}function Ae(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.dom)return n.webqit.dom;n.webqit.dom={},ve.call(n);let e=ae(n);return n.webqit.dom.Reflow=new e,n.webqit.dom.DOMRealtime=F,n.webqit.dom.AttrRealtime=q,n.webqit.dom.realtime=(r,t="tree")=>{if(t==="tree")return new F(r,n);if(t==="attr")return new q(r,n)},n.webqit.dom.ready=We.bind(n),n.webqit.dom.meta=Ue.bind(n),n.webqit.dom}function We(n){let e=this;e.document.readyState==="complete"?n(e):(e.document.domReadyCallbacks||(e.document.domReadyCallbacks=[],e.document.addEventListener("DOMContentLoaded",()=>{e.document.domReadyCallbacks.splice(0).forEach(r=>r(e))},!1)),e.document.domReadyCallbacks.push(n))}function Ue(n){let e=this,r={},t;return(t=e.document.querySelector(`meta[name="${n}"]`))&&(r=(t.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(l=>l.trim());return re(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:E(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return t.content},json(){return JSON.parse(JSON.stringify(r))}}}var J=(...n)=>H("oohtml",...n);function Ee(n,e,r){let t=this,i=Ae.call(t);t.webqit||(t.webqit={}),t.webqit.oohtml||(t.webqit.oohtml={}),t.webqit.oohtml.configs||(t.webqit.oohtml.configs={});let o=te(1,i.meta(n).json(),e,r);return t.webqit.oohtml.configs[n.toUpperCase().replace("-","_")]=o,{config:o,dom:i,window:t}}function ie(n,e,r=1,t=!1){if(r&&typeof n=="object"&&n&&typeof e=="object"&&e&&(!t||Object.keys(n).length===Object.keys(e).length)){for(let i in n)if(!ie(n[i],e[i],r-1,t))return!1;return!0}return Array.isArray(n)&&Array.isArray(e)&&n.length===e.length?(e=e.slice(0).sort())&&n.slice(0).sort().every((i,o)=>i===e[o]):n===e}function Ce(){let n=this;return class extends n.Event{constructor(r,t,{type:i="contextrequest",...o}={}){super(i,o),Object.defineProperty(this,"request",{get:()=>r}),Object.defineProperty(this,"callback",{get:()=>t})}respondWith(r,...t){if(this.request.diff){if("previousValue"in this&&this.previousValue===r)return;this.previousValue=r}return this.callback(r,...t)}}}var C=class{static instance(e){return J(e).get("contextsmanager::instance")||new this(e)}constructor(e){J(e).get("contextsmanager::instance")?.dispose(),J(e).set("contextsmanager::instance",this);let r={host:e,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r});let t=Ce.call(e.ownerDocument?.defaultView||e.defaultView);Object.defineProperty(this,"ContextRequestEvent",{get:()=>t}),this[Symbol.iterator]=function*(){yield r.contexts[Symbol.iterator]().next().value}}get length(){this["#"].contexts.size}find(e){return[...this["#"].contexts].find(e)}attach(e){this["#"].contexts.add(e),e.initialize(this["#"].host)}detach(e){e.dispose(this["#"].host),this["#"].contexts.delete(e)}ask(e,r,t={}){return this["#"].host.dispatchEvent(new this.ContextRequestEvent(e,r,{bubbles:!0,...t}))}dispose(){}};var D=class{static get config(){return{}}static attachTo(e,r,t=!1){let i,o=C.instance(e);return!t&&(i=o.find(s=>this.matchRequest(s.id,r,!0)))?i:o.attach(new this(r))}static detachFrom(e,r,t=!1){let i,o=C.instance(e);for(i of o["#"].contexts)if(!(!this.matchRequest(i.id,r,!0)||typeof t=="function"&&!t(i))&&(o.detach(i),typeof t!="function"&&!t))return i}static createId(e,r={}){let t={type:"HTMLModules",...r};return t.name||(e.getAttribute&&!(t.name=(e.getAttribute(this.config.context.attr.contextname)||"").trim())?delete t.name:e.ownerDocument||(t.name="root")),t}static createRequest(e={}){return{...e}}static matchRequest(e,r,t=!1){return t?ie(e,r,1,!0):r.type===e.type&&!r.name||r.name===e.name}constructor(e){Object.defineProperty(this,"id",{get:()=>e}),Object.defineProperty(this,"subscriptions",{value:new Set})}get length(){this.subscriptions.size}handle(e){}subscribe(e){this.subscriptions.add(e),e.request.signal&&e.request.signal.addEventListener("abort",()=>{this.unsubscribe(e)})}unsubscribe(e){this.subscriptions.delete(e),e.request.controller?.abort()}handleEvent(e){if(!(this.disposed||e.target===this.host&&e.request?.superContextOnly||!e.request||typeof e.callback!="function"||!this.constructor.matchRequest(this.id,e.request)))if(e.stopPropagation(),e.type==="contextclaim"){let r=new Set;this.subscriptions.forEach(t=>{!e.target.contains(t.request.superContextOnly?t.target.parentNode:t.target)||!this.constructor.matchRequest(e.request,t.request)||(this.subscriptions.delete(t),r.add(t))}),e.respondWith(r)}else e.type==="contextrequest"&&(e.request.live&&this.subscribe(e),this.handle(e))}initialize(e){return this.host=e,this.disposed=!1,e.addEventListener("contextrequest",this),e.addEventListener("contextclaim",this),C.instance(e).ask({...this.id,superContextOnly:!0},r=>r.forEach(t=>{this.subscribe(t),this.handle(t)}),{type:"contextclaim"}),this}dispose(e){return this.disposed=!0,e.removeEventListener("contextrequest",this),e.removeEventListener("contextclaim",this),this.subscriptions.forEach(r=>{this.unsubscribe(r);let{target:t,request:i,callback:o,params:s}=r;C.instance(t).ask(i,o,s)}),this}};function oe(n={}){let{config:e,window:r}=Ee.call(this,"context-api",n,{api:{context:"context"}});r.webqit.HTMLContextManager=C,r.webqit.HTMLContext=D,ze.call(r,e)}function ze(n){let e=this;if(n.api.context in e.document)throw new Error(`document already has a "${n.api.context}" property!`);if(n.api.context in e.HTMLElement.prototype)throw new Error(`The "HTMLElement" class already has a "${n.api.context}" property!`);Object.defineProperty(e.document,n.api.context,{get:function(){return C.instance(e.document)}}),Object.defineProperty(e.HTMLElement.prototype,n.api.context,{get:function(){return C.instance(this)}})}oe.call(window);})();
2
2
  //# sourceMappingURL=context-api.js.map