@webqit/oohtml 3.1.6 → 3.1.8

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
@@ -5,11 +5,11 @@
5
5
  [![bundle][bundle-src]][bundle-href]
6
6
  [![License][license-src]][license-href]
7
7
 
8
- **[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) • [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)**
9
9
 
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", web-native workflow as design goal! This project presents what "modern HTML" could mean today!
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
 
12
- Building Single Page Applications? OOHTML is a special love letter!
12
+ Building Single Page Applications? OOHTML is a special love letter! Writing Web Components? Now you can do that with zero tooling! Love vanilla HTML but can't go far with that? Now you can!
13
13
 
14
14
  <details><summary>Versions</summary>
15
15
 
@@ -17,17 +17,17 @@ Building Single Page Applications? OOHTML is a special love letter!
17
17
 
18
18
  </details>
19
19
 
20
- ## Motivation
20
+ ## Explainer
21
21
 
22
22
  <details><summary>Show</summary>
23
23
 
24
- Vanilla HTML is unsurprisingly becoming the most compelling option for an increasing number of developers! But the current authoring experience still leaves much to be desired in how the language lacks modularity, reusability, and other fundamental capabilities like data binding! Authors still have to rely on tools - or, to say the least, have to do half of the work in HTML and half in JS - to get even basic things working!
24
+ Amidst a multitude of approaches, vanilla HTML remains an attractive option for the UI author! But the current authoring experience still leaves much to be desired in how the language lacks modularity, reusability, and certain modern paradigms like data binding! Authors still have to rely on tools - and, for the most part, have to do half of the work in HTML and half in JS - to express even basic concepts!
25
25
 
26
- This project pursues an object-oriented approach to HTML and implicitly revisits much of what inhibits the idea of a *component* architecture for HTML!
26
+ "As an author, I want to be able to do 'x' *declaratively* instead of *imperatively* in JavaScript or by means of a special Custom Element!" "As a Web Component author, I want to be able to leverage *conventions* that keep my component logic *concise*!" All such "user stories" represent important developer intuitions that has yet to be met in HTML; much of which belong under a broad subject: an object-oriented markup language! This subject is what we explore with OOHTML!
27
27
 
28
- <!--
29
- └ [See more in the introductory blog post](https://dev.to/oxharris/the-web-native-equations-1m1p-temp-slug-6661657?preview=ba70ad2c17f05b5761bc74516dbde8c9eff8b581a0420d87334fd9ef6bab9d6e6d3ab6aaf3fe02542bb9e7250d0a88a6df91dae40919aabcc9a07320)<sup>draft</sup>
30
- -->
28
+ OOHTML comes, not as a specific technology, but as a conceptual "framework" of features that solves for HTML as an object-oriented language - whether that means re-aligning existing features or introducing new ones! While features may be discussed or explored individually, the one agenda "Object-Oriented HTML" helps us stay aligned with the original problem! Each of these features has been introduced below with a small explainer.
29
+
30
+ 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 turns lets us have a niftier authoring experience in Web Components as the latter actually just relies on the very HTML and DOM.
31
31
 
32
32
  </details>
33
33
 
@@ -48,7 +48,7 @@ OOHTML makes this possible by introducing "namespacing" and style and script sco
48
48
 
49
49
  Naming things is hard! That's especially so where you have one global namespace and a miriad of potentially conflicting names to coordinate!
50
50
 
51
- Here, we get the `namespace` attribute for designating an element as own naming context for identifiers instead of the global document namespace:
51
+ Here, we get the `namespace` attribute for designating an element as own naming context for identifiers in its subtree:
52
52
 
53
53
  ```html
54
54
  <div id="user" namespace>
@@ -126,7 +126,7 @@ console.log(window.foo); // div
126
126
 
127
127
  ### Style and Script Scoping
128
128
 
129
- We often need a way to keep things like component-specific stylesheets and scripts [scoped to a component](https://vuejs.org/guide/scaling-up/sfc.html).
129
+ We often need a way to keep component-specific stylesheets and scripts [scoped to a component](https://vuejs.org/guide/scaling-up/sfc.html). **This is especially crucial to Page Components in an SPA architecture.**
130
130
 
131
131
  Here, we get the `scoped` attribute for doing just that:
132
132
 
@@ -161,15 +161,15 @@ Here, the `scoped` attribute has two effects on the `<script>` element:
161
161
 
162
162
  ## HTML Imports
163
163
 
164
- HTML Imports is a realtime module system for HTML that speaks HTML! Something like it is the [`<defs>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs) and [`<use>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use) system in SVG.
164
+ HTML Imports is a realtime *import* system for HTML that's drawn entirely on HTML - and worlds apart from [the abandoned `<link type="import">` feature](https://www.w3.org/TR/html-imports/) and the [HTML Modules proposal](https://github.com/WICG/webcomponents/blob/gh-pages/proposals/html-modules-explainer.md)! **Something like it is the [`<defs>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs) and [`<use>`](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/use) system in SVG.**
165
165
 
166
166
  OOHTML makes this possible in just simple conventions - via a new `def` attribute and a complementary new `<import>` element!
167
167
 
168
168
  ### Module Definition
169
169
 
170
- A module here is any piece of markup that can be reused.
170
+ A "module" here is any piece of markup that can be reused.
171
171
 
172
- Here, we get the `def` attribute for defining those - both at the `<template>` element level and at its contents (*fragment*) level:
172
+ Here, we get the `def` attribute for defining those - both at the `<template>` element level and at its direct children (*fragments*) level:
173
173
 
174
174
  ```html
175
175
  <head>
@@ -201,7 +201,7 @@ Here, we get the `def` attribute for defining those - both at the `<template>` e
201
201
 
202
202
  ### Remote Modules
203
203
 
204
- We shouldn't need a different mechanism to work with remote content.
204
+ We shouldn't need a different mechanism - like `fetch('/foo.html')` - to work with remote content.
205
205
 
206
206
  Here, we get remote-loading modules with same `<template>` element using the `src` attribute:
207
207
 
@@ -222,7 +222,7 @@ Here, we get remote-loading modules with same `<template>` element using the `sr
222
222
  <div def="fragment2"></div>
223
223
  ```
224
224
 
225
- **-->** *which borrow from how `src` works in elements like `<img>`; terminating with either a `load` or an `error` event*:
225
+ **-->** *which just borrows from the `src` in elements like `<img>`; terminating with either a `load` or an `error` event*:
226
226
 
227
227
  ```js
228
228
  foo.addEventListener('load', loadCallback);
@@ -231,7 +231,7 @@ foo.addEventListener('error', errorCallback);
231
231
 
232
232
  ### Declarative Module Imports
233
233
 
234
- HTML snippets should be reusable in HTML itself!
234
+ HTML snippets should be reusable declaratively!
235
235
 
236
236
  Here, we get an `<import>` element that lets us do just that:
237
237
 
@@ -253,12 +253,12 @@ Here, we get an `<import>` element that lets us do just that:
253
253
 
254
254
  Here, import *refs* are live bindings that are sensitive to:
255
255
 
256
- + changes in the *ref* itself (as to getting defined/undefined/redefined)
257
- + changes in the referenced *defs* themselves (as to becoming available/loaded/unavailable)
256
+ + changes in the *ref* itself (as to later becoming defined/undefined/redefined)
257
+ + changes in the referenced *defs* themselves (as to later becoming available/loaded/unavailable)
258
258
 
259
259
  And an `<import>` element that has been resolved will self-restore in the event that:
260
260
 
261
- + the above changes resolve to no imports.
261
+ + the above changes invalidate the reference.
262
262
  + the previously slotted contents have *all* been programmatically removed and slot is empty.
263
263
 
264
264
  </details>
@@ -668,7 +668,7 @@ Now, on getting to the client, that extra bit of information gets decoded, and o
668
668
 
669
669
  ### Inline Data-Binding
670
670
 
671
- Here, we get the `expr` attribute for a declarative, neat, key/value data-binding syntax:
671
+ For attributes, OOHTML deviates from the usual but problematic idea of bringing markup-style bindings into attributes: `title="Hello { titleValue }"`; as though attributes had the same semantics as markup. Instead, we get a dedicated "expressions" attribute - `expr` - for a key/value data-binding approach:
672
672
 
673
673
  ```html
674
674
  <div expr="<directive> <param>: <arg>;"></div>
@@ -1,2 +1,2 @@
1
- (()=>{var Vt=Object.defineProperty;var Wt=(n,t,r)=>t in n?Vt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var tt=(n,t,r)=>(Wt(n,typeof t!="symbol"?t+"":t,r),r);function w(n){return!Array.isArray(n)&&typeof n=="object"&&n}function y(n){return Array.isArray(n)}function ot(n,t,r=null){return y(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function $(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new W}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new W,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new W,i.set(e,r));return r}var W=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)!(et([t,"*"],i.type)&&et([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(et([t,"*"],i.type)&&et([r,"*"],i.key))||i.callback(...e)}},et=(n,t)=>Array.isArray(t)?ot(n,t).length:n.includes(t);function N(n){return typeof n=="function"}function B(n){return n===null||n===""}function I(n){return arguments.length&&(n===void 0||typeof n>"u")}function v(n){return Array.isArray(n)||typeof n=="object"&&n||N(n)}function st(n){return B(n)||I(n)||n===!1||n===0||v(n)&&!Object.keys(n).length}function b(n){return N(n)||n&&{}.toString.call(n)==="[object function]"}function G(n){return n instanceof Number||typeof n=="number"}function C(n){return G(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function R(n){return n instanceof String||typeof n=="string"&&n!==null}function ft(n){return!R(n)&&!I(n.length)}function rt(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function lt(e,t){t=t||Object.prototype,t=t&&!y(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 ct(n,t){var r=[];return lt(n,t).forEach(e=>{rt(r,...Object.getOwnPropertyNames(e))}),r}function T(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((C(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,m)=>{!v(f)&&!b(f)||(r?ct(f):Object.keys(f)).forEach(u=>{if(!!t(u,s,f,m)){var l=s[u],a=f[u];if((y(l)&&y(a)||w(l)&&w(a))&&(o===!0||o>0))s[u]=y(l)&&y(a)?[]:{},T([C(o)?o-1:o,s[u],l,a],t,r,e,i);else if(y(s)&&y(f))e?s[u]=a:s.push(a);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(f,u)):s[u]=f[u]}catch{}}})}),s}function X(...n){return T(n,(t,r,e)=>!0,!1,!1,!1)}function A(n,t=!0){return y(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&&st(n)?[]:ft(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function U(n,t,r={},e={}){t=A(t).slice();for(var i=n;!I(i)&&!B(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 at(n,t,r,e={},i={}){let o=(l,a,c)=>i.set?i.set(l,a,c):(C(t[f])&&y(l)?l.push(c):l[a]=c,!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 m=U(s,t[f],i);if(!v(m)){if(i.buildTree===!1)return!1;m=b(i.buildTree)?i.buildTree(f):C(t[f+1])?[]:{};var u=o(s,t[f],m);if(!u)return!1}s=m}else return o(s,t[f],r)}var z=class{constructor(t,r=!0){Object.defineProperty(this,"window",{value:t}),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(()=>{for(let t of this.readCallbacks)t(),this.readCallbacks.delete(t);for(let t of this.writeCallbacks)t(),this.writeCallbacks.delete(t);this._run()})}onread(t,r=!1){if(r)return new Promise(e=>{this.async===!1?e(t()):this.readCallbacks.add(()=>{e(t())})});this.async===!1?t():this.readCallbacks.add(t)}onwrite(t,r=!1){if(r)return new Promise(e=>{this.async===!1?e(t()):this.writeCallbacks.add(()=>{e(t())})});this.async===!1?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),m=u=>{u!==void 0&&this.cycle(t,r,u)};f instanceof Promise?f.then(m):m(f)})};i instanceof Promise?i.then(o):o(i)})}};function Et(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function it(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(f=>(f+"").replace("(",e?"(.//":"(./")).join("|");let i=n.document.evaluate(r,t,null,XPathResult.ANY_TYPE),o=[],s;for(;s=i.iterateNext();)o.push(s);return o}function Ct(n,t,r){return r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|"),n.document.evaluate(`${r}`,t,null,XPathResult.BOOLEAN_TYPE).booleanValue}function St(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 S=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Et(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=St(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var D=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 S)&&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 S)&&!(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 S?r:new S(r)),t}registry(...t){return $("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,m]of this.registry(t))for(let[u,l]of m){let a=o.filter(c=>u.contains(c.target)?f==="subtree"||c.target===u:!1);if(!!a.length){Array.isArray(r)||(a=a[0]);for(let c of l)s.add([c,a,u])}}for(let[f,m,u]of s)e.call(i,f,m,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 k=class extends D{constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof S;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Mt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let m of s){let u=f?.generate()||{};r(m,u,o)}else{let m=f?.generate()||{};r(s,m,o)}if(e.live){f&&(e={...e,signalGenerator:f});let m=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,m)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof S;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&&Pt.call(s,"intercept",()=>{});let m=new s.MutationObserver(c=>{c=It(c).map(p=>kt.call(s,p)),qt.call(s,a,c,o)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree};t.length&&(u.attributeFilter=t.map(c=>c+"")),m.observe(o,u);let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:m};return this.disconnectables(e.signal,m,l)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof S;[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",m=e.subtree?"subtree":"children";this.registry(f).size||Pt.call(s,f,_=>{this.forEachMatchingContext(f,_,qt)});let u={disconnect(){p.delete(a),p.size||c.delete(o)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:u},c=this.registry(f,m);c.has(o)||c.set(o,new Set);let p=c.get(o);return p.add(a),this.disconnectables(e.signal,u,l)}};function It(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName?t:t.concat(r),[])}function qt(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:m}=n,u=e.map(c=>c+"");if(o.atomic&&!s.size?t=Mt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(c=>u.includes(c.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(c=>{let p;return o.eventDetails||({event:p,...c}=c),!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 l=f?t[0]:t,a=m?.generate()||{};i(l,a,r)}function Mt(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:n.getAttribute(o),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:o.nodeValue,...e})}function kt({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 Pt(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=(l,a)=>{e.realdom.attrInterceptionRecords.has(l.target)||e.realdom.attrInterceptionRecords.set(l.target,{});let c=e.realdom.attrInterceptionRecords.get(l.target);c[l.name]=c[l.name]||[],c[l.name].unshift(l.event),e.realdom.attrInterceptionHooks.get("intercept")?.forEach(_=>_([l]));let p=a();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(_=>_([l])),p};new r.MutationObserver(l=>{l=l.filter(a=>!(r.webqit.realdom.attrInterceptionRecords?.get(a.target)||{})[a.attributeName]?.shift()),l=It(l).map(a=>kt.call(r,a)),l.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(a=>a(l)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(a=>a(l)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{u[l]=o.prototype[l],o.prototype[l]=function(...a){let c,p=this.getAttribute(a[0]);["setAttribute","toggleAttribute"].includes(l)&&(c=a[1]),l==="toggleAttribute"&&c===void 0&&(c=p===null);let _={target:this,name:a[0],value:c,oldValue:p,type:"interception",event:[this,l]};return f(_,()=>u[l].call(this,...a))}}),s}var J=class extends D{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new k(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,l]=t.reduce(([c,p],_)=>_.kind==="xpath"?[c,p.concat(_)]:[c.concat(_),p],[[],[]]),a=[];e.subtree?(u.length&&a.push(...i.querySelectorAll(u.join(","))),l.length&&a.push(...it(this.window,i,l))):(u.length&&a.push(...[...i.children].filter(c=>c.matches(u))),l.length&&a.push(...it(this.window,i,l,!1))),a.forEach(c=>s(c.parentNode||i).entrants.push(c))}}if(!r)return o;let f={disconnected:!1},m=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(f.disconnected)break;let l=m?.generate()||{};r(u,l,i)}if(e.live){m&&(e={...e,signalGenerator:m});let u=this.observe(t,r,e);return this.disconnectables(e.signal,f,u)}return this.disconnectables(e.signal,f,m)}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&&Lt.call(o,"sync",()=>{});let m=new o.MutationObserver(a=>a.forEach(c=>{dt.call(o,l,Ht.call(o,c),i)}));m.observe(i,{childList:!0,subtree:e.subtree});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:m};if(e.staticSensitivity){let a=jt.call(o,l);return this.disconnectables(e.signal,m,u,a)}return this.disconnectables(e.signal,m,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?"subtree":"children";this.registry(s).size||Lt.call(o,s,_=>{this.forEachMatchingContext(s,_,dt)});let m=new o.MutationObserver(_=>_.forEach(d=>{Array.isArray((d=Ht.call(o,d)).event)||dt.call(o,a,d,i)}));m.observe(i,{childList:!0,subtree:e.subtree});let u={disconnect(){m.disconnect(),p.delete(a),p.size||c.delete(i)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:u},c=this.registry(s,f);c.has(i)||c.set(i,new Set);let p=c.get(i);if(p.add(a),e.staticSensitivity){let _=jt.call(o,a);return this.disconnectables(e.signal,u,l,_)}return this.disconnectables(e.signal,u,l)}};function jt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(p=>p.kind==="css"),m=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],u=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],l=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(_=>_[1]).concat(m(p)).concat(u(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,_)=>p.concat(l(_+"")),[])))).length)return;let a=new Set,c=new Set;return a.push=p=>(c.delete(p),a.add(p)),c.push=p=>(a.delete(p),c.add(p)),n.$deliveryCache={entrants:a,exits:c},new k(r,t).observe(n.$attrs,p=>{let _=new Map,d=h=>(_.has(h)||_.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),_.get(h)),O=new WeakMap,g=h=>(O.has(h)||O.set(h,f.some(x=>h.matches(x+""))),O.get(h));for(let h of p)["entrants","exits"].forEach(x=>{o.generation&&x!==o.generation||n.$deliveryCache[x].has(h.target)||(x==="entrants"?!g(h.target):g(h.target))||(n.$deliveryCache[x].push(h.target),d(h.target)[x].push(h.target),d(h.target).event=h.event)});for(let[,h]of _){let x=s?.generate()||{};i(h,x,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function dt(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,m={...t,entrants:[],exits:[]};if(o.eventDetails||delete m.event,["entrants","exits"].forEach(l=>{if(!(o.generation&&l!==o.generation)&&(e.length?m[l]=ie.call(this,e,t[l],t.event!=="parse"):m[l]=[...t[l]],!!f))for(let a of m[l])f[l].push(a)}),!m.entrants.length&&!m.exits.length)return;let u=s?.generate()||{};i(m,u,r)}function ie(n,t,r){t=Array.isArray(t)?t:[...t];let e=(i,o)=>{if(o.type==="selector"){let s=o.isXpathAttr?[]:i.filter(f=>o.kind==="xpath"?Ct(this,f,o+""):f.matches&&f.matches(o+""));if((r||o.isXpathAttr)&&(s=i.reduce((f,m)=>o.kind==="xpath"?[...f,...it(this,m,o,r)]:m.querySelectorAll?[...f,...m.querySelectorAll(o+"")]:f,s)),s.length)return s}else if(i.includes(o.content)||r&&i.some(s=>s.contains(o.content)))return[o.content]};return t.$$searchCache||(t.$$searchCache=new Map),n.reduce((i,o)=>{let s;return t.$$searchCache.has(o.content)?s=t.$$searchCache.get(o.content):(s=e(t,o)||[],o.type==="instance"&&t.$$searchCache.set(o.content,s)),i.concat(s)},[])}function Ht({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 Lt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:m,HTMLTemplateElement:u,DocumentFragment:l}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let a=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return a;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let c=(d,O)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,d.event);let x=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:x,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let g=O();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),g},p={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 O(...g){let h=this instanceof s?p.characterData:p.other,x=()=>h[d].call(this,...g);if(!(this instanceof s||this instanceof f||this instanceof l))return x();let P=[],E=[],V=this;["insertBefore"].includes(d)?E=[g[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(E=[g[1]],["beforebegin","afterend"].includes(g[0])&&(V=this.parentNode)):["setHTML","replaceChildren"].includes(d)?(P=[...this.childNodes],E=d==="replaceChildren"?[...g]:[g[0]]):["replaceWith","remove"].includes(d)?(P=[this],E=d==="replaceWith"?[...g]:[],V=this.parentNode):["replaceChild"].includes(d)?(P=[g[1]],E=[g[0]]):["removeChild"].includes(d)?P=[...g]:(E=[...g],["before","after"].includes(d)&&(V=this.parentNode));let L=d;if(["insertAdjacentHTML","setHTML"].includes(d)){let _t=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(g[0])){if(!this.parentNode)return h[d].call(this,...g);_t=this.parentNode.nodeName}let K=i.createElement(_t);h.setHTML.call(K,E[0],d==="setHTML"?g[1]:{}),E=[...K.childNodes],d==="insertAdjacentHTML"?(L="insertAdjacentElement",g[1]=new l,g[1].______isTemp=!0,g[1].append(...K.childNodes)):(L="replaceChildren",g=[...K.childNodes])}return c({target:V,entrants:E,exits:P,type:"interception",event:[this,d]},()=>h[L].call(this,...g))}["insertBefore","replaceChild","removeChild","appendChild"].includes(d)?(p.other[d]=o.prototype[d],o.prototype[d]=O):(["after","before","remove","replaceWith"].includes(d)&&(p.characterData[d]=s.prototype[d],s.prototype[d]=O),f.prototype[d]&&(p.other[d]=f.prototype[d],f.prototype[d]=O))});let _=Object.create(null);return["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(d=>{let O=["textContent","nodeValue"].includes(d)?o:["outerText","innerText"].includes(d)?m:f;_[d]=Object.getOwnPropertyDescriptor(O.prototype,d),Object.defineProperty(O.prototype,d,{..._[d],set:function(g){let h=()=>_[d].set.call(this,g);if(!(this instanceof f))return h();let x=[],P=[],E=this;if(["outerHTML","outerText"].includes(d)?(x=[this],E=this.parentNode):x=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let L=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return h();L=this.parentNode.nodeName}let F=i.createElement(L==="TEMPLATE"?"div":L);_[d].set.call(F,g),P=this instanceof u?[]:[...F.childNodes],d==="outerHTML"?(g=new l,g.______isTemp=!0,g.append(...F.childNodes),h=()=>f.prototype.replaceWith.call(this,g)):this instanceof u?h=()=>this.content.replaceChildren(...F.childNodes):h=()=>f.prototype.replaceChildren.call(this,...F.childNodes)}return c({target:E,entrants:P,exits:x,type:"interception",event:[this,d]},h)}})}),["append","prepend","replaceChildren"].forEach(d=>{[i,l.prototype].forEach(O=>{let g=O[d];O[d]=function(...h){if(this.______isTemp)return g.call(this,...h);let x=d==="replaceChildren"?[...this.childNodes]:[];return c({target:this,entrants:h,exits:x,type:"interception",event:[this,d]},()=>g.call(this,...h))}})}),a}function Dt(){oe.call(this),se.call(this),fe.call(this)}function oe(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function se(){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 fe(){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 Ft(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Dt.call(n),n.webqit.realdom.meta=(...r)=>le.call(n,...r),n.webqit.realdom.ready=(...r)=>pt.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new J(r,n);if(e==="attr")return new k(r,n)};let t=new z(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom}function pt(...n){let t="interactive",r;R(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=>pt.call(this,"interactive",o)),complete:new Promise(o=>pt.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 le(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 at(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:C(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}var j=(...n)=>$("oohtml",...n),q={};function $t(n,t,r){let e=this,i=Ft.call(e);e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");return e.webqit.oohtml.configs[o]||(e.webqit.oohtml.configs[o]={}),q.window=e,X(2,e.webqit.oohtml.configs[o],r,t,i.meta(n).json()),{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function Nt(){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"],m=i.pop()||f[0];if(!f.includes(m))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:u,detail:l,targetContext:a,live:c,signal:p,diff:_,...d}=s;super(m,{...d,bubbles:d.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>u}),Object.defineProperty(this,"targetContext",{get:()=>a}),Object.defineProperty(this,"detail",{get:()=>l}),Object.defineProperty(this,"live",{get:()=>c}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>_}),Object.defineProperty(this,"options",{get:()=>d})}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 Y=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 Q=class extends Error{};var Z=class{static instance(t){return j(t).get("contexts::instance")||new this(t)}constructor(t){j(t).get("contexts::instance")?.dispose(),j(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 H))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new Q(`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 Y((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(Nt())(...t);this["#"].host.dispatchEvent(o)})}};var ht=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 ht))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}=Z.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}},H=ht;tt(H,"kind");var M=class extends H{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()}};tt(M,"kind","bindings");function yt(n={}){let{config:t,window:r}=$t.call(this,"bindings-api",n,{context:{attr:{bindingsreflection:"bindings"}},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=M,ce.call(r,t)}function gt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!j(t).has("bindings")){let o=Object.create(null);j(t).set("bindings",o),e.observe(o,s=>{let f=Object.keys(o),m=t===r.document?r.document.documentElement:t,u=n.context.attr.bindingsreflection;f.length&&u?m.setAttribute(n.context.attr.bindingsreflection,f.join(" ")):u&&m.toggleAttribute(n.context.attr.bindingsreflection,!1);let l=t[i.api.contexts];for(let a of s)if(a.type==="delete"){let c=l.find(M.kind,a.key);c&&l.detach(c)}else l.find(M.kind,a.key)||l.attach(new M(a.key))})}return j(t).get("bindings")}function Rt(n,t,r,{merge:e,diff:i,namespace:o}={}){let s=this,{webqit:{Observer:f}}=s,m=gt.call(this,n,t),u={diff:i,namespace:o},l=e?[]:f.ownKeys(m,u).filter(a=>!(a in r));return f.batch(m,()=>(l.length&&f.deleteProperties(m,l,u),f.set(m,r,u)),u)}function ce(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 Rt.call(t,n,t.document,e,i)}}),Object.defineProperty(t.document,n.api.bindings,{get:function(){return r.proxy(gt.call(t,n,t.document))}}),Object.defineProperty(t.Element.prototype,n.api.bind,{value:function(e,i={}){return Rt.call(t,n,this,e,i)}}),Object.defineProperty(t.Element.prototype,n.api.bindings,{get:function(){return r.proxy(gt.call(t,n,this))}})}yt.call(window);})();
1
+ (()=>{var Rt=Object.defineProperty;var Vt=(n,t,r)=>t in n?Rt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var tt=(n,t,r)=>(Vt(n,typeof t!="symbol"?t+"":t,r),r);function w(n){return!Array.isArray(n)&&typeof n=="object"&&n}function y(n){return Array.isArray(n)}function ot(n,t,r=null){return y(t)?n.filter(e=>r?t.filter(i=>r(e,i)).length:t.indexOf(e)!==-1):[]}function $(n,...t){if(globalThis.webqit||(globalThis.webqit={}),globalThis.webqit.refs||Object.defineProperty(globalThis.webqit,"refs",{value:new V}),!arguments.length)return globalThis.webqit.refs;let r=globalThis.webqit.refs.get(n);r||(r=new V,globalThis.webqit.refs.set(n,r));let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new V,i.set(e,r));return r}var V=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)!(et([t,"*"],i.type)&&et([r,"*"],i.key)&&i.callback===e)||this.observers.delete(i)}fire(t,r,...e){for(let i of this.observers)!(et([t,"*"],i.type)&&et([r,"*"],i.key))||i.callback(...e)}},et=(n,t)=>Array.isArray(t)?ot(n,t).length:n.includes(t);function N(n){return typeof n=="function"}function B(n){return n===null||n===""}function I(n){return arguments.length&&(n===void 0||typeof n>"u")}function O(n){return Array.isArray(n)||typeof n=="object"&&n||N(n)}function st(n){return B(n)||I(n)||n===!1||n===0||O(n)&&!Object.keys(n).length}function b(n){return N(n)||n&&{}.toString.call(n)==="[object function]"}function G(n){return n instanceof Number||typeof n=="number"}function C(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 ft(n){return!W(n)&&!I(n.length)}function rt(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function lt(e,t){t=t||Object.prototype,t=t&&!y(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 ct(n,t){var r=[];return lt(n,t).forEach(e=>{rt(r,...Object.getOwnPropertyNames(e))}),r}function T(n,t,r=!1,e=!1,i=!1){var o=0,s=n.shift();if((C(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,m)=>{!O(f)&&!b(f)||(r?ct(f):Object.keys(f)).forEach(u=>{if(!!t(u,s,f,m)){var l=s[u],a=f[u];if((y(l)&&y(a)||w(l)&&w(a))&&(o===!0||o>0))s[u]=y(l)&&y(a)?[]:{},T([C(o)?o-1:o,s[u],l,a],t,r,e,i);else if(y(s)&&y(f))e?s[u]=a:s.push(a);else try{i?Object.defineProperty(s,u,Object.getOwnPropertyDescriptor(f,u)):s[u]=f[u]}catch{}}})}),s}function X(...n){return T(n,(t,r,e)=>!0,!1,!1,!1)}function A(n,t=!0){return y(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&&st(n)?[]:ft(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function U(n,t,r={},e={}){t=A(t).slice();for(var i=n;!I(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 at(n,t,r,e={},i={}){let o=(l,a,c)=>i.set?i.set(l,a,c):(C(t[f])&&y(l)?l.push(c):l[a]=c,!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 m=U(s,t[f],i);if(!O(m)){if(i.buildTree===!1)return!1;m=b(i.buildTree)?i.buildTree(f):C(t[f+1])?[]:{};var u=o(s,t[f],m);if(!u)return!1}s=m}else return o(s,t[f],r)}var z=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),m=u=>{u!==void 0&&this.cycle(t,r,u)};f instanceof Promise?f.then(m):m(f)})};i instanceof Promise?i.then(o):o(i)})}};function Et(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function it(n,t,r,e=!0){r=(Array.isArray(r)?r:[r]).map(f=>(f+"").replace("(",e?"(.//":"(./")).join("|");let i=n.document.evaluate(r,t,null,XPathResult.ANY_TYPE),o=[],s;for(;s=i.iterateNext();)o.push(s);return o}function Ct(n,t,r){return r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|"),n.document.evaluate(`${r}`,t,null,XPathResult.BOOLEAN_TYPE).booleanValue}function St(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 S=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Et(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=St(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var D=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 S)&&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 S)&&!(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 S?r:new S(r)),t}registry(...t){return $("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,m]of this.registry(t))for(let[u,l]of m){let a=o.filter(c=>u.contains(c.target)?f==="subtree"||c.target===u:!1);if(!!a.length){Array.isArray(r)||(a=a[0]);for(let c of l)s.add([c,a,u])}}for(let[f,m,u]of s)e.call(i,f,m,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 k=class extends D{constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof S;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Mt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let m of s){let u=f?.generate()||{};r(m,u,o)}else{let m=f?.generate()||{};r(s,m,o)}if(e.live){f&&(e={...e,signalGenerator:f});let m=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,m)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof S;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&&Pt.call(s,"intercept",()=>{});let m=new s.MutationObserver(c=>{c=It(c).map(p=>kt.call(s,p)),qt.call(s,a,c,o)}),u={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree};t.length&&(u.attributeFilter=t.map(c=>c+"")),m.observe(o,u);let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:m};return this.disconnectables(e.signal,m,l)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof S;[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",m=e.subtree?"subtree":"children";this.registry(f).size||Pt.call(s,f,_=>{this.forEachMatchingContext(f,_,qt)});let u={disconnect(){p.delete(a),p.size||c.delete(o)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:u},c=this.registry(f,m);c.has(o)||c.set(o,new Set);let p=c.get(o);return p.add(a),this.disconnectables(e.signal,u,l)}};function It(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName?t:t.concat(r),[])}function qt(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:m}=n,u=e.map(c=>c+"");if(o.atomic&&!s.size?t=Mt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(c=>u.includes(c.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(c=>{let p;return o.eventDetails||({event:p,...c}=c),!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 l=f?t[0]:t,a=m?.generate()||{};i(l,a,r)}function Mt(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:n.getAttribute(o),...e})):Array.from(n.attributes).map(o=>r.find(s=>s.name===o.nodeName)||{target:n,name:o.nodeName,value:o.nodeValue,...e})}function kt({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 Pt(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=(l,a)=>{e.realdom.attrInterceptionRecords.has(l.target)||e.realdom.attrInterceptionRecords.set(l.target,{});let c=e.realdom.attrInterceptionRecords.get(l.target);c[l.name]=c[l.name]||[],c[l.name].unshift(l.event),e.realdom.attrInterceptionHooks.get("intercept")?.forEach(_=>_([l]));let p=a();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(_=>_([l])),p};new r.MutationObserver(l=>{l=l.filter(a=>!(r.webqit.realdom.attrInterceptionRecords?.get(a.target)||{})[a.attributeName]?.shift()),l=It(l).map(a=>kt.call(r,a)),l.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(a=>a(l)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(a=>a(l)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let u=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(l=>{u[l]=o.prototype[l],o.prototype[l]=function(...a){let c,p=this.getAttribute(a[0]);["setAttribute","toggleAttribute"].includes(l)&&(c=a[1]),l==="toggleAttribute"&&c===void 0&&(c=p===null);let _={target:this,name:a[0],value:c,oldValue:p,type:"interception",event:[this,l]};return f(_,()=>u[l].call(this,...a))}}),s}var J=class extends D{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new k(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,l]=t.reduce(([c,p],_)=>_.kind==="xpath"?[c,p.concat(_)]:[c.concat(_),p],[[],[]]),a=[];e.subtree?(u.length&&a.push(...i.querySelectorAll(u.join(","))),l.length&&a.push(...it(this.window,i,l))):(u.length&&a.push(...[...i.children].filter(c=>c.matches(u))),l.length&&a.push(...it(this.window,i,l,!1))),a.forEach(c=>s(c.parentNode||i).entrants.push(c))}}if(!r)return o;let f={disconnected:!1},m=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,u]of o){if(f.disconnected)break;let l=m?.generate()||{};r(u,l,i)}if(e.live){m&&(e={...e,signalGenerator:m});let u=this.observe(t,r,e);return this.disconnectables(e.signal,f,u)}return this.disconnectables(e.signal,f,m)}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&&Lt.call(o,"sync",()=>{});let m=new o.MutationObserver(a=>a.forEach(c=>{dt.call(o,l,Ht.call(o,c),i)}));m.observe(i,{childList:!0,subtree:e.subtree});let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),l={context:i,spec:t,callback:r,params:e,signalGenerator:u,disconnectable:m};if(e.staticSensitivity){let a=jt.call(o,l);return this.disconnectables(e.signal,m,u,a)}return this.disconnectables(e.signal,m,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?"subtree":"children";this.registry(s).size||Lt.call(o,s,_=>{this.forEachMatchingContext(s,_,dt)});let m=new o.MutationObserver(_=>_.forEach(d=>{Array.isArray((d=Ht.call(o,d)).event)||dt.call(o,a,d,i)}));m.observe(i,{childList:!0,subtree:e.subtree});let u={disconnect(){m.disconnect(),p.delete(a),p.size||c.delete(i)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:u},c=this.registry(s,f);c.has(i)||c.set(i,new Set);let p=c.get(i);if(p.add(a),e.staticSensitivity){let _=jt.call(o,a);return this.disconnectables(e.signal,u,l,_)}return this.disconnectables(e.signal,u,l)}};function jt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(p=>p.kind==="css"),m=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],u=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],l=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(_=>_[1]).concat(m(p)).concat(u(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,_)=>p.concat(l(_+"")),[])))).length)return;let a=new Set,c=new Set;return a.push=p=>(c.delete(p),a.add(p)),c.push=p=>(a.delete(p),c.add(p)),n.$deliveryCache={entrants:a,exits:c},new k(r,t).observe(n.$attrs,p=>{let _=new Map,d=h=>(_.has(h)||_.set(h,{target:h,entrants:[],exits:[],type:"static",event:null}),_.get(h)),v=new WeakMap,g=h=>(v.has(h)||v.set(h,f.some(x=>h.matches(x+""))),v.get(h));for(let h of p)["entrants","exits"].forEach(x=>{o.generation&&x!==o.generation||n.$deliveryCache[x].has(h.target)||(x==="entrants"?!g(h.target):g(h.target))||(n.$deliveryCache[x].push(h.target),d(h.target)[x].push(h.target),d(h.target).event=h.event)});for(let[,h]of _){let x=s?.generate()||{};i(h,x,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function dt(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,m={...t,entrants:[],exits:[]};if(o.eventDetails||delete m.event,["entrants","exits"].forEach(l=>{if(!(o.generation&&l!==o.generation)&&(e.length?m[l]=ie.call(this,e,t[l],t.event!=="parse"):m[l]=[...t[l]],!!f))for(let a of m[l])f[l].push(a)}),!m.entrants.length&&!m.exits.length)return;let u=s?.generate()||{};i(m,u,r)}function ie(n,t,r){t=Array.isArray(t)?t:[...t];let e=(i,o)=>{if(o.type==="selector"){let s=o.isXpathAttr?[]:i.filter(f=>o.kind==="xpath"?Ct(this,f,o+""):f.matches&&f.matches(o+""));if((r||o.isXpathAttr)&&(s=i.reduce((f,m)=>o.kind==="xpath"?[...f,...it(this,m,o,r)]:m.querySelectorAll?[...f,...m.querySelectorAll(o+"")]:f,s)),s.length)return s}else if(i.includes(o.content)||r&&i.some(s=>s.contains(o.content)))return[o.content]};return t.$$searchCache||(t.$$searchCache=new Map),n.reduce((i,o)=>{let s;return t.$$searchCache.has(o.content)?s=t.$$searchCache.get(o.content):(s=e(t,o)||[],o.type==="instance"&&t.$$searchCache.set(o.content,s)),i.concat(s)},[])}function Ht({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 Lt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:m,HTMLTemplateElement:u,DocumentFragment:l}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let a=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return a;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let c=(d,v)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,d.event);let x=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:x,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let g=v();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),g},p={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(...g){let h=this instanceof s?p.characterData:p.other,x=()=>h[d].call(this,...g);if(!(this instanceof s||this instanceof f||this instanceof l))return x();let P=[],E=[],R=this;["insertBefore"].includes(d)?E=[g[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(E=[g[1]],["beforebegin","afterend"].includes(g[0])&&(R=this.parentNode)):["setHTML","replaceChildren"].includes(d)?(P=[...this.childNodes],E=d==="replaceChildren"?[...g]:[g[0]]):["replaceWith","remove"].includes(d)?(P=[this],E=d==="replaceWith"?[...g]:[],R=this.parentNode):["replaceChild"].includes(d)?(P=[g[1]],E=[g[0]]):["removeChild"].includes(d)?P=[...g]:(E=[...g],["before","after"].includes(d)&&(R=this.parentNode));let L=d;if(["insertAdjacentHTML","setHTML"].includes(d)){let _t=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(g[0])){if(!this.parentNode)return h[d].call(this,...g);_t=this.parentNode.nodeName}let K=i.createElement(_t);h.setHTML.call(K,E[0],d==="setHTML"?g[1]:{}),E=[...K.childNodes],d==="insertAdjacentHTML"?(L="insertAdjacentElement",g[1]=new l,g[1].______isTemp=!0,g[1].append(...K.childNodes)):(L="replaceChildren",g=[...K.childNodes])}return c({target:R,entrants:E,exits:P,type:"interception",event:[this,d]},()=>h[L].call(this,...g))}["insertBefore","replaceChild","removeChild","appendChild"].includes(d)?(p.other[d]=o.prototype[d],o.prototype[d]=v):(["after","before","remove","replaceWith"].includes(d)&&(p.characterData[d]=s.prototype[d],s.prototype[d]=v),f.prototype[d]&&(p.other[d]=f.prototype[d],f.prototype[d]=v))});let _=Object.create(null);return["outerHTML","outerText","innerHTML","innerText","textContent","nodeValue"].forEach(d=>{let v=["textContent","nodeValue"].includes(d)?o:["outerText","innerText"].includes(d)?m:f;_[d]=Object.getOwnPropertyDescriptor(v.prototype,d),Object.defineProperty(v.prototype,d,{..._[d],set:function(g){let h=()=>_[d].set.call(this,g);if(!(this instanceof f))return h();let x=[],P=[],E=this;if(["outerHTML","outerText"].includes(d)?(x=[this],E=this.parentNode):x=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let L=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return h();L=this.parentNode.nodeName}let F=i.createElement(L==="TEMPLATE"?"div":L);_[d].set.call(F,g),P=this instanceof u?[]:[...F.childNodes],d==="outerHTML"?(g=new l,g.______isTemp=!0,g.append(...F.childNodes),h=()=>f.prototype.replaceWith.call(this,g)):this instanceof u?h=()=>this.content.replaceChildren(...F.childNodes):h=()=>f.prototype.replaceChildren.call(this,...F.childNodes)}return c({target:E,entrants:P,exits:x,type:"interception",event:[this,d]},h)}})}),["append","prepend","replaceChildren"].forEach(d=>{[i,l.prototype].forEach(v=>{let g=v[d];v[d]=function(...h){if(this.______isTemp)return g.call(this,...h);let x=d==="replaceChildren"?[...this.childNodes]:[];return c({target:this,entrants:h,exits:x,type:"interception",event:[this,d]},()=>g.call(this,...h))}})}),a}function Dt(){oe.call(this),se.call(this),fe.call(this)}function oe(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function se(){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 fe(){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 Ft(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},Dt.call(n),n.webqit.realdom.meta=(...r)=>le.call(n,...r),n.webqit.realdom.ready=(...r)=>pt.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new J(r,n);if(e==="attr")return new k(r,n)};let t=new z(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function pt(...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=>pt.call(this,"interactive",o)),complete:new Promise(o=>pt.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 le(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 at(i,s[0].split("."),s[1]==="true"?!0:s[1]==="false"?!1:C(s[1])?parseInt(s[1]):s[1]),i},{})),{get name(){return n},get content(){return e.content},json(){return JSON.parse(JSON.stringify(r))}}}var j=(...n)=>$("oohtml",...n),q={};function $t(n,t,r){let e=this,i=Ft.call(e);e.webqit||(e.webqit={}),e.webqit.oohtml||(e.webqit.oohtml={}),e.webqit.oohtml.configs||(e.webqit.oohtml.configs={});let o=n.toUpperCase().replace("-","_");return e.webqit.oohtml.configs[o]||(e.webqit.oohtml.configs[o]={}),q.window=e,X(2,e.webqit.oohtml.configs[o],r,t,i.meta(n).json()),{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function Nt(){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"],m=i.pop()||f[0];if(!f.includes(m))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:u,detail:l,targetContext:a,live:c,signal:p,diff:_,...d}=s;super(m,{...d,bubbles:d.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>u}),Object.defineProperty(this,"targetContext",{get:()=>a}),Object.defineProperty(this,"detail",{get:()=>l}),Object.defineProperty(this,"live",{get:()=>c}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>_}),Object.defineProperty(this,"options",{get:()=>d})}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 Y=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 Q=class extends Error{};var Z=class{static instance(t){return j(t).get("contexts::instance")||new this(t)}constructor(t){j(t).get("contexts::instance")?.dispose(),j(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 H))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new Q(`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 Y((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(Nt())(...t);this["#"].host.dispatchEvent(o)})}};var ht=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 ht))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}=Z.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}},H=ht;tt(H,"kind");var M=class extends H{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()}};tt(M,"kind","bindings");function yt(n={}){let{config:t,window:r}=$t.call(this,"bindings-api",n,{context:{attr:{bindingsreflection:"bindings"}},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=M,ce.call(r,t)}function gt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!j(t).has("bindings")){let o=Object.create(null);j(t).set("bindings",o),e.observe(o,s=>{let f=Object.keys(o),m=t===r.document?r.document.documentElement:t,u=n.context.attr.bindingsreflection;f.length&&u?m.setAttribute(n.context.attr.bindingsreflection,f.join(" ")):u&&m.toggleAttribute(n.context.attr.bindingsreflection,!1);let l=t[i.api.contexts];for(let a of s)if(a.type==="delete"){let c=l.find(M.kind,a.key);c&&l.detach(c)}else l.find(M.kind,a.key)||l.attach(new M(a.key))})}return j(t).get("bindings")}function Wt(n,t,r,{merge:e,diff:i,namespace:o}={}){let s=this,{webqit:{Observer:f}}=s,m=gt.call(this,n,t),u={diff:i,namespace:o},l=e?[]:f.ownKeys(m,u).filter(a=>!(a in r));return f.batch(m,()=>(l.length&&f.deleteProperties(m,l,u),f.set(m,r,u)),u)}function ce(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 Wt.call(t,n,t.document,e,i)}}),Object.defineProperty(t.document,n.api.bindings,{get:function(){return r.proxy(gt.call(t,n,t.document))}}),Object.defineProperty(t.Element.prototype,n.api.bind,{value:function(e,i={}){return Wt.call(t,n,this,e,i)}}),Object.defineProperty(t.Element.prototype,n.api.bindings,{get:function(){return r.proxy(gt.call(t,n,this))}})}yt.call(window);})();
2
2
  //# sourceMappingURL=bindings-api.js.map