@webqit/oohtml 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
1
  # OOHTML
2
2
 
3
3
  [![npm version][npm-version-src]][npm-version-href]
4
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
4
+ <!--[![npm downloads][npm-downloads-src]][npm-downloads-href]-->
5
5
  [![bundle][bundle-src]][bundle-href]
6
6
  [![License][license-src]][license-href]
7
7
 
8
- **[Explainer](#explainer) • [On the Agenda](#on-the-agenda) • [Modular HTML](#modular-html) • [HTML Imports](#html-imports) • [Data Binding](#data-binding) • [Data Plumbing](#data-plumbing) • [Polyfill](#polyfill) • [Examples](#examples) • [License](#license)**
8
+ **[Explainer](#explainer) • [Features](#features) • [Modular HTML](#modular-html) • [HTML Imports](#html-imports) • [Data Binding](#data-binding) • [Data Plumbing](#data-plumbing) • [Implementation](#implementation) • [Examples](#examples) • [License](#license)**
9
9
 
10
10
  Object-Oriented HTML (OOHTML) is a set of features that extend standard HTML and the DOM to enable authoring modular, reusable and reactive markup - with a "buildless" and intuitive workflow as design goal! This project revisits the HTML problem space to solve for an object-oriented approach to HTML!
11
11
 
@@ -19,13 +19,14 @@ Building Single Page Applications? OOHTML is a special love letter! Writing Web
19
19
 
20
20
  ## Status
21
21
 
22
- + Working implementation via a polyfill
23
- + Actively developed
22
+ + Actively maintained
23
+ + A working implementation
24
+ + [Proposed at the WICG](https://github.com/WICG/proposals/issues/137)
24
25
  + Open to contributions
25
26
 
26
- ## Polyfill
27
+ ## Implementation
27
28
 
28
- OOHTML is being developed as something to be used today. This implementation adheres closely to the spec and helps evolve the proposal through a practice-driven process.
29
+ OOHTML may be used today. This implementation adheres closely to the spec and helps evolve the proposal through a practice-driven process.
29
30
 
30
31
  <details><summary>Load from a CDN<br>
31
32
  └───────── <a href="https://bundlephobia.com/result?p=@webqit/oohtml"><img align="right" src="https://img.shields.io/badge/21.8%20kB-black"></a></summary>
@@ -229,9 +230,11 @@ OOHTML comes, not as a specific technology, but as a conceptual "framework" of f
229
230
 
230
231
  OOHTML is effectively different from Web Components (and from the related Declarative Custom Elements and Declarative Shadow DOM efforts) in its focus on "arbitrary" HTML and the DOM rather than on just the Custom Element or Shadow DOM "subset" of the language. This in turn lets us have a niftier authoring experience in Web Components as the latter actually just relies on the very HTML and DOM.
231
232
 
233
+ └ You may want to learn more in the introductory article: [Revisiting the HTML Problem Space and Introducing OOHTML](https://dev.to/oxharris/revisiting-the-html-problem-space-and-introducing-oohtml-3oh5)
234
+
232
235
  </details>
233
236
 
234
- ## On the Agenda
237
+ ## Features
235
238
 
236
239
  + [Modular HTML](#modular-html)
237
240
  + [HTML Imports](#html-imports)
@@ -1,2 +1,2 @@
1
- (()=>{var zt=Object.defineProperty;var Xt=(n,t,r)=>t in n?zt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var rt=(n,t,r)=>(Xt(n,typeof t!="symbol"?t+"":t,r),r);function w(n){return!Array.isArray(n)&&typeof n=="object"&&n}function _(n){return Array.isArray(n)}function ct(n,t,r=null){return _(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function C(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new U}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new U,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new U,i.set(e,r));return r}var U=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)!(nt([t,"*"],i.type)&&nt([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(nt([t,"*"],i.type)&&nt([r,"*"],i.key))||i.callback(...e)}},nt=(n,t)=>Array.isArray(t)?ct(n,t).length:n.includes(t);function R(n){return typeof n=="function"}function B(n){return n===null||n===""}function k(n){return arguments.length&&(n===void 0||typeof n>"u")}function O(n){return Array.isArray(n)||typeof n=="object"&&n||R(n)}function ut(n){return B(n)||k(n)||n===!1||n===0||O(n)&&!Object.keys(n).length}function b(n){return R(n)||n&&{}.toString.call(n)==="[object function]"}function G(n){return n instanceof Number||typeof n=="number"}function S(n){return G(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function W(n){return n instanceof String||typeof n=="string"&&n!==null}function at(n){return!W(n)&&!k(n.length)}function it(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function mt(e,t){t=t||Object.prototype,t=t&&!_(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 dt(n,t){var r=[];return mt(n,t).forEach(e=>{it(r,...Object.getOwnPropertyNames(e))}),r}function P(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((S(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((f,a)=>{!O(f)&&!b(f)||(r?dt(f):Object.keys(f)).forEach(u=>{if(!!t(u,s,f,a)){var c=s[u],m=f[u];if((_(c)&&_(m)||w(c)&&w(m))&&(o===!0||o>0))s[u]=_(c)&&_(m)?[]:{},P([S(o)?o-1:o,s[u],c,m],t,r,e,i);else if(_(s)&&_(f))e?s[u]=m:s.push(m);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(f,u)):s[u]=f[u]}catch{}}})}),s}function z(...n){return P(n,(t,r,e)=>!0,!1,!1,!1)}function A(n,t=!0){return _(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&&ut(n)?[]:at(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function X(n,t,r={},e={}){t=A(t).slice();for(var i=n;!k(i)&&!B(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):O(i)?o in i:i[o])){e.exists=!1;return}i=r.get?r.get(i,o):i[o]}return e.exists=!0,i}function ht(n,t,r,e={},i={}){let o=(c,m,l)=>i.set?i.set(c,m,l):(S(t[f])&&_(c)?c.push(l):c[m]=l,!0);t=A(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!O(s)&&!b(s))return!1;var a=X(s,t[f],i);if(!O(a)){if(i.buildTree===!1)return!1;a=b(i.buildTree)?i.buildTree(f):S(t[f+1])?[]:{};var u=o(s,t[f],a);if(!u)return!1}s=a}else return o(s,t[f],r)}var Q=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),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,e),a=u=>{u!==void 0&&this.cycle(t,r,u)};f instanceof Promise?f.then(a):a(f)})};i instanceof Promise?i.then(o):o(i)})}};function Pt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function st(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",e?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function qt(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 J(n,t,r,e=!1){let i=t.getRootNode(),o=r.getRootNode();return i===o?t.contains(r):e&&o instanceof n.ShadowRoot?J(n,t,o.host,e):!1}function Mt(n,t="|"){return[...n].reduce(([r,e,i,o],s)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(s)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[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:Pt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Mt(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var F=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(b(t[0])?t=[[],...t]:w(t[0])&&!(t[0]instanceof T)&&t.length===1?t=[[],void 0,t[0]]:w(t[1])&&t.length===2?t=[A(t[0],!1),void 0,t[1]]:t[0]=A(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 C("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,o=Array.isArray(r)?r:[r],s=new Set;for(let[f,a]of this.registry(t))for(let[u,c]of a){let m=o.filter(l=>J(i,u,l.target,f==="cross-roots")?["subtree","cross-roots"].includes(f)||l.target===u:!1);if(!!m.length){Array.isArray(r)||(m=m[0]);for(let l of c)s.add([l,m,u])}}for(let[f,a,u]of s)e.call(i,f,a,u)}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&b(i.disconnect)&&i.disconnect()||b(i)&&i()||w(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var L=class extends F{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:o}=this,s=Ht(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let a of s){let u=f?.generate()||{};r(a,u,o)}else{let a=f?.generate()||{};r(s,a,o)}if(e.live){f&&(e={...e,signalGenerator:f});let a=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,a)}}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:o,window:s,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&jt.call(s,"intercept",()=>{});let a=new s.MutationObserver(l=>{l=Lt(l).map(h=>$t.call(s,h)),kt.call(s,m,l,o)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(u.attributeFilter=t.map(l=>l+"")),a.observe(o,u);let c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:a};return this.disconnectables(e.signal,a,c)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof T;[t,r,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 f=e.timing==="intercept"?"intercept":"sync",a=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(f).size||jt.call(s,f,y=>{this.forEachMatchingContext(f,y,kt)});let u={disconnect(){h.delete(m),h.size||l.delete(o)}},c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:u},l=this.registry(f,a);l.has(o)||l.set(o,new Set);let h=l.get(o);return h.add(m),this.disconnectables(e.signal,u,c)}};function Lt(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||C(r.target,"internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function kt(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:a}=n,u=e.map(l=>l+"");if(o.atomic&&!s.size?t=Ht(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(l=>u.includes(l.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(l=>{let h;return o.eventDetails||({event:h,...l}=l),!o.oldValue&&"oldValue"in l&&({oldValue:h,...l}=l),!o.newValue&&"value"in l?{value:h,...l}=l:o.newValue&&typeof l.value>"u"&&(l={...l,value:ft(l.target,l.name,()=>l.target.getAttribute(l.name))}),l})),o.atomic&&(t.forEach(l=>s.set(l.name,l)),t=Array.from(s.entries()).map(([,l])=>l));let c=f?t[0]:t,m=a?.generate()||{};i(c,m,r)}function ft(n,t,r){let e=C(n,"internalAttrInteractions").get(t);C(n,"internalAttrInteractions").set(t,!0);let i=r();return C(n,"internalAttrInteractions").set(t,e),i}function Ht(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:ft(n,o,()=>n.getAttribute(o)),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:ft(n,o.nodeName,()=>o.nodeValue),...e})}function $t({target:n,attributeName:t,value:r,oldValue:e}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:s}}function jt(n,t){let r=this,{webqit:e,document:i,Element:o}=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 s=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(c,m)=>{e.realdom.attrInterceptionRecords.has(c.target)||e.realdom.attrInterceptionRecords.set(c.target,{});let l=e.realdom.attrInterceptionRecords.get(c.target);if(l[c.name]=l[c.name]||[],l[c.name].unshift(c.event),C(c.target,"internalAttrInteractions").get(c.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(y=>y([c]));let h=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(y=>y([c])),h};new r.MutationObserver(c=>{c=c.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),c=Lt(c).map(m=>$t.call(r,m)),c.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(c)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(c)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(c=>{u[c]=o.prototype[c],o.prototype[c]=function(...m){let l,h=ft(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(c)&&(l=m[1]),c==="toggleAttribute"&&l===void 0&&(l=h===null);let y={target:this,name:m[0],value:l,oldValue:h,type:"interception",event:[this,c]};return f(y,()=>u[c].call(this,...m))}}),s}var Y=class extends F{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new L(i,o).get(...arguments)}query(t,r=void 0,e={}){[t,r=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"){if(!t.length)[...i.children].forEach(u=>s(i).entrants.push(u));else if(t.every(u=>u.type==="selector")){let[u,c]=t.reduce(([l,h],y)=>y.kind==="xpath"?[l,h.concat(y)]:[l.concat(y),h],[[],[]]),m=[];e.subtree?(u.length&&m.push(...i.querySelectorAll(u.join(","))),c.length&&m.push(...st(this.window,i,c))):(u.length&&m.push(...[...i.children].filter(l=>l.matches(u))),c.length&&m.push(...st(this.window,i,c,!1))),m.forEach(l=>s(l.parentNode||i).entrants.push(l))}}if(!r)return o;let f={disconnected:!1},a=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(f.disconnected)break;let c=a?.generate()||{};r(u,c,i)}if(e.live){a&&(e={...e,signalGenerator:a});let u=this.observe(t,r,e);return this.disconnectables(e.signal,f,u)}return this.disconnectables(e.signal,f,a)}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:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Nt.call(o,"sync",()=>{});let a=new o.MutationObserver(m=>m.forEach(l=>{_t.call(o,c,Ft.call(o,l),i)}));a.observe(i,{childList:!0,subtree:e.subtree&&!0});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:a};if(e.staticSensitivity){let m=Dt.call(o,c);return this.disconnectables(e.signal,a,u,m)}return this.disconnectables(e.signal,a,u)}observeSync(t,r,e={}){[t,r,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",f=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(s).size||Nt.call(o,s,y=>{this.forEachMatchingContext(s,y,_t)});let a=new o.MutationObserver(y=>y.forEach(x=>{Array.isArray((x=Ft.call(o,x)).event)||_t.call(o,m,x,i)}));a.observe(i,{childList:!0,subtree:e.subtree&&!0});let u={disconnect(){a.disconnect(),h.delete(m),h.size||l.delete(i)}},c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:i,spec:t,callback:r,params:e,signalGenerator:c,disconnectable:u},l=this.registry(s,f);l.has(i)||l.set(i,new Set);let h=l.get(i);if(h.add(m),e.staticSensitivity){let y=Dt.call(o,m);return this.disconnectables(e.signal,u,c,y)}return this.disconnectables(e.signal,u,c)}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 Dt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(h=>h.kind==="css"),a=h=>h.match(/\.([\w-]+)/g)?.length?["class"]:[],u=h=>h.match(/#([\w-]+)/g)?.length?["id"]:[],c=h=>[...h.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(y=>y[1]).concat(a(h)).concat(u(h));if(!(n.$attrs=Array.from(new Set(f.filter(h=>(h+"").includes("[")).reduce((h,y)=>h.concat(c(y+"")),[])))).length)return;let m=new Set,l=new Set;return m.push=h=>(l.delete(h),m.add(h)),l.push=h=>(m.delete(h),l.add(h)),n.$deliveryCache={entrants:m,exits:l},new L(r,t).observe(n.$attrs,h=>{let y=new Map,x=p=>(y.has(p)||y.set(p,{target:p,entrants:[],exits:[],type:"static",event:null}),y.get(p)),d=new WeakMap,v=p=>(d.has(p)||d.set(p,f.some(g=>p.matches(g+""))),d.get(p));for(let p of h)["entrants","exits"].forEach(g=>{o.generation&&g!==o.generation||n.$deliveryCache[g].has(p.target)||(g==="entrants"?!v(p.target):v(p.target))||(n.$deliveryCache[g].push(p.target),x(p.target)[g].push(p.target),x(p.target).event=p.event)});for(let[,p]of y){let g=s?.generate()||{};i(p,g,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function _t(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,a={...t,entrants:[],exits:[]};if(o.eventDetails||delete a.event,["entrants","exits"].forEach(c=>{if(!(o.generation&&c!==o.generation)&&(e.length?a[c]=ce.call(this,e,o.subtree==="cross-roots",t[c],t.event!=="parse"):a[c]=[...t[c]],!!f))for(let m of a[c])f[c].push(m)}),!a.entrants.length&&!a.exits.length)return;let u=s?.generate()||{};i(a,u,r)}function ce(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(a=>s.kind==="xpath"?qt(this,a,s+""):a.matches&&a.matches(s+""));if((e||s.isXpathAttr)&&(f=o.reduce((a,u)=>s.kind==="xpath"?[...a,...st(this,u,s,e)]:u.querySelectorAll?[...a,...u.querySelectorAll(s+"")]:a,f)),f.length)return f}else if(o.includes(s.content)||e&&o.some(f=>J(this,f,s.content,t)))return[s.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((o,s)=>{let f;return r.$$searchCache.has(s.content)?f=r.$$searchCache.get(s.content):(f=i(r,s)||[],s.type==="instance"&&r.$$searchCache.set(s.content,f)),o.concat(f)},[])}function Ft({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=A(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=A(r).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Nt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:a,HTMLTemplateElement:u,DocumentFragment:c}=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=(d,v,p)=>{e.realdom.domInterceptionNoRecurse.set(d,v);let g=p();return e.realdom.domInterceptionNoRecurse.delete(d),g},h=(d,v)=>{d.entrants.concat(d.exits).forEach(g=>{clearTimeout(e.realdom.domInterceptionRecords.get(g)?.timeout),e.realdom.domInterceptionRecords.set(g,d.event);let I=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(g)},0);Object.defineProperty(d.event,"timeout",{value:I,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(g=>g(d));let p=v();return e.realdom.domInterceptionHooks.get("sync")?.forEach(g=>g(d)),p},y={characterData:Object.create(null),other:Object.create(null)};["insertBefore","insertAdjacentElement","insertAdjacentHTML","setHTML","replaceChildren","replaceWith","remove","replaceChild","removeChild","before","after","append","prepend","appendChild"].forEach(d=>{function v(...p){let g=this instanceof s?y.characterData:y.other,I=()=>g[d].call(this,...p);if(!(this instanceof s||this instanceof f||this instanceof c)||e.realdom.domInterceptionNoRecurse.get(this)===d)return I();let M=[],E=[],V=this;["insertBefore"].includes(d)?E=[p[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(E=[p[1]],["beforebegin","afterend"].includes(p[0])&&(V=this.parentNode)):["setHTML","replaceChildren"].includes(d)?(M=[...this.childNodes],E=d==="replaceChildren"?[...p]:[p[0]]):["replaceWith","remove"].includes(d)?(M=[this],E=d==="replaceWith"?[...p]:[],V=this.parentNode):["replaceChild"].includes(d)?(M=[p[1]],E=[p[0]]):["removeChild"].includes(d)?M=[...p]:(E=[...p],["before","after"].includes(d)&&(V=this.parentNode));let D=d;if(["insertAdjacentHTML","setHTML"].includes(d)){let Ot=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(p[0])){if(!this.parentNode)return g[d].call(this,...p);Ot=this.parentNode.nodeName}let et=i.createElement(Ot);g.setHTML.call(et,E[0],d==="setHTML"?p[1]:{}),E=[...et.childNodes],d==="insertAdjacentHTML"?(D="insertAdjacentElement",p[1]=new c,l(p[1],"append",()=>p[1].append(...et.childNodes))):(D="replaceChildren",p=[...et.childNodes])}return h({target:V,entrants:E,exits:M,type:"interception",event:[this,d]},()=>g[D].call(this,...p))}["insertBefore","replaceChild","removeChild","appendChild"].includes(d)?(y.other[d]=o.prototype[d],o.prototype[d]=v):(["after","before","remove","replaceWith"].includes(d)&&(y.characterData[d]=s.prototype[d],s.prototype[d]=v),f.prototype[d]&&(y.other[d]=f.prototype[d],f.prototype[d]=v))});let x=Object.create(null);return["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(d=>{let v=["textContent","nodeValue"].includes(d)?o:["outerText","innerText"].includes(d)?a:f;x[d]=Object.getOwnPropertyDescriptor(v.prototype,d),Object.defineProperty(v.prototype,d,{...x[d],set:function(p){let g=()=>x[d].set.call(this,p);if(!(this instanceof f))return g();let I=[],M=[],E=this;if(["outerHTML","outerText"].includes(d)?(I=[this],E=this.parentNode):I=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let D=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return g();D=this.parentNode.nodeName}let N=i.createElement(D==="TEMPLATE"?"div":D);x[d].set.call(N,p),M=this instanceof u?[]:[...N.childNodes],d==="outerHTML"?(p=new c,l(p,"append",()=>p.append(...N.childNodes)),g=()=>l(this,"replaceWith",()=>f.prototype.replaceWith.call(this,p))):this instanceof u?g=()=>l(this.conten,"replaceChildren",()=>this.content.replaceChildren(...N.childNodes)):g=()=>l(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...N.childNodes))}return h({target:E,entrants:M,exits:I,type:"interception",event:[this,d]},g)}})}),["append","prepend","replaceChildren"].forEach(d=>{[i,c.prototype].forEach(v=>{let p=v[d];v[d]=function(...g){if(e.realdom.domInterceptionNoRecurse.get(this)===d)return p.call(this,...g);let I=d==="replaceChildren"?[...this.childNodes]:[];return h({target:this,entrants:g,exits:I,type:"interception",event:[this,d]},()=>p.call(this,...g))}})}),m}function Rt(){ue.call(this),ae.call(this),me.call(this)}function ue(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function ae(){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 me(){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 Wt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Rt.call(n),n.webqit.realdom.meta=(...r)=>de.call(n,...r),n.webqit.realdom.ready=(...r)=>bt.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new Y(r,n);if(e==="attr")return new L(r,n)};let t=new Q(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function bt(...n){let t="interactive",r;W(n[0])?(t=n[0],b(n[1])&&(r=n[1])):b(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(o=>bt.call(this,"interactive",o)),complete:new Promise(o=>bt.call(this,"complete",o))}),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 o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function de(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return ht(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:S(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}function lt(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 H=(...n)=>C("oohtml",...n),q={};function Ut(n,t,r){let e=this,i=Wt.call(e);q.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 o=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[o]){e.webqit.oohtml.configs[o]={};let s=e.webqit.oohtml.configs[o];z(2,s,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(s).forEach(f=>{Object.keys(s[f]).forEach(a=>{f==="api"&&typeof s[f][a]=="string"?s[f][a]=`${e.webqitConfig.prefix}${lt(s[f][a])}`:["attr","elements"].includes(f)&&s[f][a]?.startsWith("data-")===!1&&(s[f][a]=`${e.webqitConfig.prefix}-${s[f][a]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function Bt(){let{window:n}=q,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let o=i.pop();if(typeof o!="function")throw new Error("Callback must be provided.");let s=i.pop();if(!s?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],a=i.pop()||f[0];if(!f.includes(a))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:u,detail:c,targetContext:m,live:l,signal:h,diff:y,...x}=s;super(a,{...x,bubbles:x.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>u}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>c}),Object.defineProperty(this,"live",{get:()=>l}),Object.defineProperty(this,"signal",{get:()=>h}),Object.defineProperty(this,"diff",{get:()=>y}),Object.defineProperty(this,"options",{get:()=>x})}respondWith(i){if(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 Z=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=q;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var K=class extends Error{};var tt=class{static instance(t){return H(t).get("contexts::instance")||new this(t)}constructor(t){H(t).get("contexts::instance")?.dispose(),H(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 K(`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 Z((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(s=>typeof s=="object"&&s))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let o=new(Bt())(...t);this["#"].host.dispatchEvent(o)})}};var wt=class{static createRequest(){return{kind:this.kind}}constructor(t=null){Object.defineProperty(this,"detail",{get:()=>t}),Object.defineProperty(this,"subscriptions",{value:new Set})}get configs(){let{window:{webqit:{oohtml:{configs:t}}}}=q;return t}get name(){return this.host===q.window.document?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.target===this.host||!(t.detail instanceof wt))return;let r=new Set;return this.subscriptions.forEach(e=>{!t.target.contains(e.target)||!t.detail.matchEvent(e)||(t.stopPropagation(),this.subscriptions.delete(e),r.add(e))}),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}=tt.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}},$=wt;rt($,"kind");var j=class extends ${static createRequest(t=null){let r=super.createRequest();if(t?.startsWith("@")){let[e,...i]=i.slice(1).split(".").map(o=>o.trim());r.targetContext=e,r.detail=i.join(".")}else r.detail=t;return r}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t._controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:r}}}=q;t._controller=r.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],r.get,e=>{this.disposed||t.respondWith(e.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t._controller?.abort()}};rt(j,"kind","bindings");function vt(n={}){let{config:t,window:r}=Ut.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=j,ge.call(r,t)}function xt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!H(t).has("bindings")){let o=Object.create(null);H(t).set("bindings",o),e.observe(o,s=>{let f=Object.keys(o),a=t===r.document?r.document.documentElement:t,u=n.attr.bindingsreflection;f.length&&u?a.setAttribute(n.attr.bindingsreflection,f.join(" ")):u&&a.toggleAttribute(n.attr.bindingsreflection,!1);let c=t[i.api.contexts];for(let m of s)if(m.type==="delete"){let l=c.find(j.kind,m.key);l&&c.detach(l)}else c.find(j.kind,m.key)||c.attach(new j(m.key))})}return H(t).get("bindings")}function ge(n){let t=this,{webqit:{Observer:r}}=t;if(n.api.bind in t.document)throw new Error(`document already has a "${n.api.bind}" property!`);if(n.api.bindings in t.document)throw new Error(`document already has a "${n.api.bindings}" property!`);if(n.api.bind in t.Element.prototype)throw new Error(`The "Element" class already has a "${n.api.bind}" property!`);if(n.api.bindings in t.Element.prototype)throw new Error(`The "Element" class already has a "${n.api.bindings}" property!`);Object.defineProperty(t.document,n.api.bind,{value:function(e,i={}){return Gt.call(t,n,t.document,e,i)}}),Object.defineProperty(t.document,n.api.bindings,{get:function(){return r.proxy(xt.call(t,n,t.document))}}),Object.defineProperty(t.Element.prototype,n.api.bind,{value:function(e,i={}){return Gt.call(t,n,this,e,i)}}),Object.defineProperty(t.Element.prototype,n.api.bindings,{get:function(){return r.proxy(xt.call(t,n,this))}})}function Gt(n,t,r,{merge:e,diff:i,namespace:o}={}){let s=this,{webqit:{Observer:f}}=s,a=xt.call(this,n,t),u={diff:i,namespace:o},c=e?[]:f.ownKeys(a,u).filter(m=>!(m in r));return f.batch(a,()=>(c.length&&f.deleteProperties(a,c,u),f.set(a,r,u)),u)}vt.call(window);})();
1
+ (()=>{var Jt=Object.defineProperty;var Yt=(n,t,r)=>t in n?Jt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var ft=(n,t,r)=>(Yt(n,typeof t!="symbol"?t+"":t,r),r);function w(n){return!Array.isArray(n)&&typeof n=="object"&&n}function g(n){return Array.isArray(n)}function pt(n,t,r=null){return g(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function S(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new G}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new G,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new G,i.set(e,r));return r}var G=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)?pt(n,t).length:n.includes(t);function V(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 v(n){return Array.isArray(n)||typeof n=="object"&&n||V(n)}function ht(n){return z(n)||k(n)||n===!1||n===0||v(n)&&!Object.keys(n).length}function b(n){return V(n)||n&&{}.toString.call(n)==="[object function]"}function X(n){return n instanceof Number||typeof n=="number"}function T(n){return X(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function B(n){return n instanceof String||typeof n=="string"&&n!==null}function gt(n){return!B(n)&&!k(n.length)}function ct(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function yt(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 _t(n,t){var r=[];return yt(n,t).forEach(e=>{ct(r,...Object.getOwnPropertyNames(e))}),r}function M(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((T(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((f,l)=>{!v(f)&&!b(f)||(r?_t(f):Object.keys(f)).forEach(a=>{if(!!t(a,s,f,l)){var c=s[a],m=f[a];if((g(c)&&g(m)||w(c)&&w(m))&&(o===!0||o>0))s[a]=g(c)&&g(m)?[]:{},M([T(o)?o-1:o,s[a],c,m],t,r,e,i);else if(g(s)&&g(f))e?s[a]=m:s.push(m);else try{i?Object.defineProperty(s,a,Object.getOwnPropertyDescriptor(f,a)):s[a]=f[a]}catch{}}})}),s}function Q(...n){return M(n,(t,r,e)=>!0,!1,!1,!1)}function A(n,t=!0){return g(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&&ht(n)?[]:gt(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function J(n,t,r={},e={}){t=A(t).slice();for(var i=n;!k(i)&&!z(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):v(i)?o in i:i[o])){e.exists=!1;return}i=r.get?r.get(i,o):i[o]}return e.exists=!0,i}function wt(n,t,r,e={},i={}){let o=(c,m,u)=>i.set?i.set(c,m,u):(T(t[f])&&g(c)?c.push(u):c[m]=u,!0);t=A(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!v(s)&&!b(s))return!1;var l=J(s,t[f],i);if(!v(l)){if(i.buildTree===!1)return!1;l=b(i.buildTree)?i.buildTree(f):T(t[f+1])?[]:{};var a=o(s,t[f],l);if(!a)return!1}s=l}else return o(s,t[f],r)}var Y=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),o=s=>{s!==void 0&&this.onwrite(()=>{let f=r(s,e),l=a=>{a!==void 0&&this.cycle(t,r,a)};f instanceof Promise?f.then(l):l(f)})};i instanceof Promise?i.then(o):o(i)})}};function jt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function at(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(s=>(s+"").replace("(",e?"(.//":"(./")).join("|");let i=[],o;try{let s=n.document.evaluate(r,t,null,n.XPathResult.ANY_TYPE);for(;o=s.iterateNext();)i.push(o)}catch{}return i}function kt(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 Z(n,t,r,e=!1){let i=t.getRootNode(),o=r.getRootNode();return i===o?t.contains(r):e&&o instanceof n.ShadowRoot?Z(n,t,o.host,e):!1}function Nt(n,t="|"){return[...n].reduce(([r,e,i,o],s)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(s)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(s)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(s)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(s)&&!i[0].endsWith("\\")&&(r=r===s?null:r||s),i[0]+=s,[r,e,i]),[null,0,[""]])[2].reverse()}var I=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:jt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=Nt(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var W=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(b(t[0])?t=[[],...t]:w(t[0])&&!(t[0]instanceof I)&&t.length===1?t=[[],void 0,t[0]]:w(t[1])&&t.length===2?t=[A(t[0],!1),void 0,t[1]]:t[0]=A(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof I)&&!(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 I?r:new I(r)),t}registry(...t){return S("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,o=Array.isArray(r)?r:[r],s=new Set;for(let[f,l]of this.registry(t))for(let[a,c]of l){let m=o.filter(u=>Z(i,a,u.target,f==="cross-roots")?["subtree","cross-roots"].includes(f)||u.target===a:!1);if(!!m.length){Array.isArray(r)||(m=m[0]);for(let u of c)s.add([u,m,a])}}for(let[f,l,a]of s)e.call(i,f,l,a)}disconnectables(t,...r){let e={disconnect(){r.forEach(i=>i&&b(i.disconnect)&&i.disconnect()||b(i)&&i()||w(i)&&(i.disconnected=!0))}};return t&&t.addEventListener("abort",()=>e.disconnect()),e}};var D=class extends W{constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof I;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=$t(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let l of s){let a=f?.generate()||{};r(l,a,o)}else{let l=f?.generate()||{};r(s,l,o)}if(e.live){f&&(e={...e,signalGenerator:f});let l=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,l)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof I;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:o,window:s,webqit:f}=this;e.eventDetails&&!f.realdom.attrInterceptionHooks?.intercepting&&Ht.call(s,"intercept",()=>{});let l=new s.MutationObserver(u=>{u=Dt(u).map(d=>Rt.call(s,d)),Lt.call(s,m,u,o)}),a={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(a.attributeFilter=t.map(u=>u+"")),l.observe(o,a);let c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:l};return this.disconnectables(e.signal,l,c)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof I;[t,r,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 f=e.timing==="intercept"?"intercept":"sync",l=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(f).size||Ht.call(s,f,y=>{this.forEachMatchingContext(f,y,Lt)});let a={disconnect(){d.delete(m),d.size||u.delete(o)}},c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:c,disconnectable:a},u=this.registry(f,l);u.has(o)||u.set(o,new Set);let d=u.get(o);return d.add(m),this.disconnectables(e.signal,a,c)}};function Dt(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||S(r.target,"internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Lt(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:l}=n,a=e.map(u=>u+"");if(o.atomic&&!s.size?t=$t(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(u=>a.includes(u.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(u=>{let d;return o.eventDetails||({event:d,...u}=u),!o.oldValue&&"oldValue"in u&&({oldValue:d,...u}=u),!o.newValue&&"value"in u?{value:d,...u}=u:o.newValue&&typeof u.value>"u"&&(u={...u,value:mt(u.target,u.name,()=>u.target.getAttribute(u.name))}),u})),o.atomic&&(t.forEach(u=>s.set(u.name,u)),t=Array.from(s.entries()).map(([,u])=>u));let c=f?t[0]:t,m=l?.generate()||{};i(c,m,r)}function mt(n,t,r){let e=S(n,"internalAttrInteractions").get(t);S(n,"internalAttrInteractions").set(t,!0);let i=r();return S(n,"internalAttrInteractions").set(t,e),i}function $t(n,t,r=[]){let e={event:null,type:"attribute"};return t.length?t.map(o=>(o=o+"",r.find(s=>s.name===o)||{target:n,name:o,value:mt(n,o,()=>n.getAttribute(o)),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:mt(n,o.nodeName,()=>o.nodeValue),...e})}function Rt({target:n,attributeName:t,value:r,oldValue:e}){let s=(this.webqit.realdom.attrInterceptionRecords?.get(n)||{})[t]?.[0]||"mutation";return{target:n,name:t,value:r,oldValue:e,type:"observation",event:s}}function Ht(n,t){let r=this,{webqit:e,document:i,Element:o}=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 s=()=>e.realdom.attrInterceptionHooks.get(n).delete(t);if(e.realdom.attrInterceptionHooks?.intercepting)return s;console.warn("Attr mutation APIs are now being intercepted."),e.realdom.attrInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"attrInterceptionRecords",{value:new Map});let f=(c,m)=>{e.realdom.attrInterceptionRecords.has(c.target)||e.realdom.attrInterceptionRecords.set(c.target,{});let u=e.realdom.attrInterceptionRecords.get(c.target);if(u[c.name]=u[c.name]||[],u[c.name].unshift(c.event),S(c.target,"internalAttrInteractions").get(c.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(y=>y([c]));let d=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(y=>y([c])),d};new r.MutationObserver(c=>{c=c.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),c=Dt(c).map(m=>Rt.call(r,m)),c.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(c)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(c)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let a=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(c=>{a[c]=o.prototype[c],o.prototype[c]=function(...m){let u,d=mt(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(c)&&(u=m[1]),c==="toggleAttribute"&&u===void 0&&(u=d===null);let y={target:this,name:m[0],value:u,oldValue:d,type:"interception",event:[this,c]};return f(y,()=>a[c].call(this,...m))}}),s}var K=class extends W{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new D(i,o).get(...arguments)}query(t,r=void 0,e={}){[t,r=void 0,e={}]=this.resolveArgs(arguments);let{context:i}=this,o=new Map,s=a=>(o.has(a)||o.set(a,{target:a,entrants:[],exits:[],type:"query",event:null}),o.get(a));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(a=>s(i).entrants.push(a));else if(t.every(a=>a.type==="selector")){let[a,c]=t.reduce(([u,d],y)=>y.kind==="xpath"?[u,d.concat(y)]:[u.concat(y),d],[[],[]]),m=[];e.subtree?(a.length&&m.push(...i.querySelectorAll(a.join(","))),c.length&&m.push(...at(this.window,i,c))):(a.length&&m.push(...[...i.children].filter(u=>u.matches(a))),c.length&&m.push(...at(this.window,i,c,!1))),m.forEach(u=>s(u.parentNode||i).entrants.push(u))}}if(!r)return o;let f={disconnected:!1},l=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,a]of o){if(f.disconnected)break;let c=l?.generate()||{};r(a,c,i)}if(e.live){l&&(e={...e,signalGenerator:l});let a=this.observe(t,r,e);return this.disconnectables(e.signal,f,a)}return this.disconnectables(e.signal,f,l)}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:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Ut.call(o,"sync",()=>{});let l=new o.MutationObserver(m=>m.forEach(u=>{vt.call(o,c,Wt.call(o,u),i)}));l.observe(i,{childList:!0,subtree:e.subtree&&!0});let a=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),c={context:i,spec:t,callback:r,params:e,signalGenerator:a,disconnectable:l};if(e.staticSensitivity){let m=Ft.call(o,c);return this.disconnectables(e.signal,l,a,m)}return this.disconnectables(e.signal,l,a)}observeSync(t,r,e={}){[t,r,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",f=e.subtree==="cross-roots"?"cross-roots":e.subtree?"subtree":"children";this.registry(s).size||Ut.call(o,s,y=>{this.forEachMatchingContext(s,y,vt)});let l=new o.MutationObserver(y=>y.forEach(x=>{Array.isArray((x=Wt.call(o,x)).event)||vt.call(o,m,x,i)}));l.observe(i,{childList:!0,subtree:e.subtree&&!0});let a={disconnect(){l.disconnect(),d.delete(m),d.size||u.delete(i)}},c=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:i,spec:t,callback:r,params:e,signalGenerator:c,disconnectable:a},u=this.registry(s,f);u.has(i)||u.set(i,new Set);let d=u.get(i);if(d.add(m),e.staticSensitivity){let y=Ft.call(o,m);return this.disconnectables(e.signal,a,c,y)}return this.disconnectables(e.signal,a,c)}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 Ft(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(d=>d.kind==="css"),l=d=>d.match(/\.([\w-]+)/g)?.length?["class"]:[],a=d=>d.match(/#([\w-]+)/g)?.length?["id"]:[],c=d=>[...d.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(y=>y[1]).concat(l(d)).concat(a(d));if(!(n.$attrs=Array.from(new Set(f.filter(d=>(d+"").includes("[")).reduce((d,y)=>d.concat(c(y+"")),[])))).length)return;let m=new Set,u=new Set;return m.push=d=>(u.delete(d),m.add(d)),u.push=d=>(m.delete(d),u.add(d)),n.$deliveryCache={entrants:m,exits:u},new D(r,t).observe(n.$attrs,d=>{let y=new Map,x=_=>(y.has(_)||y.set(_,{target:_,entrants:[],exits:[],type:"static",event:null}),y.get(_)),it=new WeakMap,p=_=>(it.has(_)||it.set(_,f.some(O=>_.matches(O+""))),it.get(_));for(let _ of d)["entrants","exits"].forEach(O=>{o.generation&&O!==o.generation||n.$deliveryCache[O].has(_.target)||(O==="entrants"?!p(_.target):p(_.target))||(n.$deliveryCache[O].push(_.target),x(_.target)[O].push(_.target),x(_.target).event=_.event)});for(let[,_]of y){let O=s?.generate()||{};i(_,O,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function vt(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,l={...t,entrants:[],exits:[]};if(o.eventDetails||delete l.event,["entrants","exits"].forEach(c=>{if(!(o.generation&&c!==o.generation)&&(e.length?l[c]=me.call(this,e,o.subtree==="cross-roots",t[c],t.event!=="parse"):l[c]=[...t[c]],!!f))for(let m of l[c])f[c].push(m)}),!l.entrants.length&&!l.exits.length)return;let a=s?.generate()||{};i(l,a,r)}function me(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(l=>s.kind==="xpath"?kt(this,l,s+""):l.matches&&l.matches(s+""));if((e||s.isXpathAttr)&&(f=o.reduce((l,a)=>s.kind==="xpath"?[...l,...at(this,a,s,e)]:a.querySelectorAll?[...l,...a.querySelectorAll(s+"")]:l,f)),f.length)return f}else if(o.includes(s.content)||e&&o.some(f=>Z(this,f,s.content,t)))return[s.content]};return r.$$searchCache||(r.$$searchCache=new Map),n.reduce((o,s)=>{let f;return r.$$searchCache.has(s.content)?f=r.$$searchCache.get(s.content):(f=i(r,s)||[],s.type==="instance"&&r.$$searchCache.set(s.content,f)),o.concat(f)},[])}function Wt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=A(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=A(r).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),i),i=i||e.document.readyState==="loading"&&"parse"||"mutation",{target:n,entrants:t,exits:r,type:"observation",event:i}}function Ut(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:l,HTMLTemplateElement:a,DocumentFragment:c}=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 u=(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 q=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(p.event,"timeout",{value:q,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"]},x={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 q=Object.getOwnPropertyDescriptor(r[h].prototype,p);!q||(Object.defineProperty(r[h].prototype,p,"value"in q?{...q,value:_}:{...q,set:O}),x[h][p]=q)});function _(...h){let q=Object.keys(x).find(C=>this instanceof r[C]&&p in x[C]),U=x[q],L=()=>U[p].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===p)return L();let j=[],E=[],F=this;["insertBefore"].includes(p)?E=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(p)?(E=[h[1]],["beforebegin","afterend"].includes(h[0])&&(F=this.parentNode)):["setHTML","replaceChildren"].includes(p)?(j=[...this.childNodes],E=p==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(p)?(j=[this],E=p==="replaceWith"?[...h]:[],F=this.parentNode):["replaceChild"].includes(p)?(j=[h[1]],E=[h[0]]):["removeChild"].includes(p)?j=[...h]:(E=[...h],["before","after"].includes(p)&&(F=this.parentNode));let ot=p;if(["insertAdjacentHTML","setHTML"].includes(p)){let C=this.nodeName;if(p==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return U[p].value.call(this,...h);C=this.parentNode.nodeName}let st=i.createElement(C);U.setHTML.value.call(st,E[0],p==="setHTML"?h[1]:{}),E=[...st.childNodes],p==="insertAdjacentHTML"?(ot="insertAdjacentElement",h[1]=new c,u(h[1],"append",()=>h[1].append(...st.childNodes))):(ot="replaceChildren",h=[...st.childNodes])}return d({target:F,entrants:E,exits:j,type:"interception",event:[this,p]},()=>U[ot].value.call(this,...h))}function O(h){let q=Object.keys(x).find(H=>this instanceof r[H]&&p in x[H]),U=x[q],L=()=>U[p].set.call(this,h);if(e.realdom.domInterceptionNoRecurse.get(this)===p)return L();let j=[],E=[],F=this;if(["outerHTML","outerText"].includes(p)?(j=[this],F=this.parentNode):j=[...this.childNodes],["outerHTML","innerHTML"].includes(p)){let H=this.nodeName;if(p==="outerHTML"){if(!this.parentNode)return L();H=this.parentNode.nodeName}let C=i.createElement(H==="TEMPLATE"||H.includes("-")?"div":H);u(C,p,()=>C[p]=h),E=this instanceof a?[]:[...C.childNodes],p==="outerHTML"?(h=new c,u(h,"append",()=>h.append(...C.childNodes)),L=()=>u(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof a?L=()=>u(this.conten,"replaceChildren",()=>this.content.replaceChildren(...C.childNodes)):L=()=>u(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...C.childNodes))}return d({target:F,entrants:E,exits:j,type:"interception",event:[this,p]},L)}}),m}function Vt(){de.call(this),pe.call(this),he.call(this)}function de(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function pe(){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 he(){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 Bt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Vt.call(n),n.webqit.realdom.meta=(...r)=>ge.call(n,...r),n.webqit.realdom.ready=(...r)=>At.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new K(r,n);if(e==="attr")return new D(r,n)};let t=new Y(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function At(...n){let t="interactive",r;B(n[0])?(t=n[0],b(n[1])&&(r=n[1])):b(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(o=>At.call(this,"interactive",o)),complete:new Promise(o=>At.call(this,"complete",o))}),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 o=i.document.readyState;for(let s of i.webqit.realdom.readyStateCallbacks[o].splice(0))s(i)},!1)),i.webqit.realdom.readyStateCallbacks[t].push(r)}function ge(n){let t=this,r={},e;return(e=t.document.querySelector(`meta[name="${n}"]`))&&(r=(e.content||"").split(";").filter(i=>i).reduce((i,o)=>{let s=o.split("=").map(f=>f.trim());return wt(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:T(s[1])?parseInt(s[1]):s[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 $=(...n)=>S("oohtml",...n),P={};function zt(n,t,r){let e=this,i=Bt.call(e);P.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 o=n.toUpperCase().replace("-","_");if(!e.webqit.oohtml.configs[o]){e.webqit.oohtml.configs[o]={};let s=e.webqit.oohtml.configs[o];Q(2,s,r,t,i.meta(n).json()),e.webqitConfig.prefix&&Object.keys(s).forEach(f=>{Object.keys(s[f]).forEach(l=>{f==="api"&&typeof s[f][l]=="string"?s[f][l]=`${e.webqitConfig.prefix}${dt(s[f][l])}`:["attr","elements"].includes(f)&&s[f][l]?.startsWith("data-")===!1&&(s[f][l]=`${e.webqitConfig.prefix}-${s[f][l]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function Xt(){let{window:n}=P,{webqit:t}=n;if(t.DOMContextRequestEvent)return t.DOMContextRequestEvent;class r extends n.Event{constructor(...i){let o=i.pop();if(typeof o!="function")throw new Error("Callback must be provided.");let s=i.pop();if(!s?.kind)throw new Error('"options.kind" must be specified.');let f=["contextrequest","contextclaim"],l=i.pop()||f[0];if(!f.includes(l))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:a,detail:c,targetContext:m,live:u,signal:d,diff:y,...x}=s;super(l,{...x,bubbles:x.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>a}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>c}),Object.defineProperty(this,"live",{get:()=>u}),Object.defineProperty(this,"signal",{get:()=>d}),Object.defineProperty(this,"diff",{get:()=>y}),Object.defineProperty(this,"options",{get:()=>x}),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 tt=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=P;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var et=class extends Error{};var rt=new Map,nt=class{static instance(t){return $(t).get("contexts::instance")||new this(t)}constructor(t){$(t).get("contexts::instance")?.dispose(),$(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 R))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new et(`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 tt((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(l=>typeof l=="object"&&l))&&i.live&&(i.signal&&i.signal.addEventListener("abort",()=>e.abort()),t[t.indexOf(i)]={...i,signal:e.signal});let o=new(Xt())(...t),s=this["#"].host.getRootNode(),f=l=>{if(!l.answered){if(l.meta.target=l.target,rt.get(s)||rt.set(s,new Set),l.type==="contextrequest"&&l.live)rt.get(s).add(l);else if(l.type==="contextclaim"){let a=new Set;return rt.get(s).forEach(c=>{!this["#"].host.contains(c.target)||!l.detail.matchEvent(c)||(rt.get(s).delete(c),a.add(c))}),l.respondWith(a)}}};s.addEventListener(o.type,f),this["#"].host.dispatchEvent(o),s.removeEventListener(o.type,f)})}};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}}}}=P;return t}get name(){return[P.window.Document,P.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}=nt.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}},R=Et;ft(R,"kind");var N=class extends R{static createRequest(t=null){let r=super.createRequest();if(t?.startsWith("@")){let[e,...i]=i.slice(1).split(".").map(o=>o.trim());r.targetContext=e,r.detail=i.join(".")}else r.detail=t;return r}get bindingsObj(){return this.host[this.configs.BINDINGS_API.api.bindings]}matchEvent(t){return super.matchEvent(t)&&(!t.detail||!this.detail||(Array.isArray(t.detail)?t.detail[0]===this.detail:t.detail===this.detail))}handle(t){if(t.meta.controller?.abort(),!(t.detail+"").trim())return t.respondWith(this.bindingsObj);let{window:{webqit:{Observer:r}}}=P;t.meta.controller=r.reduce(this.bindingsObj,Array.isArray(t.detail)?t.detail:[t.detail],r.get,e=>{this.disposed||t.respondWith(e.value)},{live:t.live,signal:t.signal,descripted:!0})}unsubscribed(t){t.meta.controller?.abort()}};ft(N,"kind","bindings");function Ct(n={}){let{config:t,window:r}=zt.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=N,be.call(r,t)}function Qt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!$(t).has("bindings")){let o=Object.create(null);$(t).set("bindings",o),e.observe(o,s=>{let f=Object.keys(o),l=t instanceof r.Document?t.documentElement:t,a=n.attr.bindingsreflection;f.length&&a&&l.setAttribute?l.setAttribute(n.attr.bindingsreflection,f.join(" ")):a&&l.setAttribute&&l.toggleAttribute(n.attr.bindingsreflection,!1);let c=t[i.api.contexts];for(let m of s)if(m.type==="delete"){let u=c.find(N.kind,m.key);u&&c.detach(u)}else c.find(N.kind,m.key)||c.attach(new N(m.key))})}return $(t).get("bindings")}function be(n){let t=this,{webqit:{Observer:r}}=t;[t.Document.prototype,t.Element.prototype,t.ShadowRoot.prototype].forEach(e=>{let i=e===t.Document.prototype?"Document":e===t.ShadowRoot.prototype?"ShadowRoot":"Element";if(n.api.bind in e)throw new Error(`The ${i} prototype already has a "${n.api.bind}" API!`);if(n.api.bindings in e)throw new Error(`The ${i} prototype already has a "${n.api.bindings}" API!`);Object.defineProperty(e,n.api.bind,{value:function(o,s={}){return we.call(t,n,this,o,s)}}),Object.defineProperty(e,n.api.bindings,{get:function(){return r.proxy(Qt.call(t,n,this))}})})}function we(n,t,r,{merge:e,diff:i,namespace:o}={}){let s=this,{webqit:{Observer:f}}=s,l=Qt.call(this,n,t),a={diff:i,namespace:o},c=e?[]:f.ownKeys(l,a).filter(m=>!(m in r));return f.batch(l,()=>(c.length&&f.deleteProperties(l,c,a),f.set(l,r,a)),a)}Ct.call(window);})();
2
2
  //# sourceMappingURL=bindings-api.js.map