@webqit/oohtml 5.0.0 → 5.0.2
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 +42 -35
- package/dist/bindings-api.js +1 -1
- package/dist/bindings-api.js.map +1 -1
- package/dist/context-api.js.map +1 -1
- package/dist/data-binding.js +14 -14
- package/dist/data-binding.js.map +2 -2
- package/dist/html-imports.js +1 -1
- package/dist/html-imports.js.map +2 -2
- package/dist/main.js +29 -29
- package/dist/main.js.map +2 -2
- package/dist/main.lite.js +50 -42
- package/dist/main.lite.js.map +3 -3
- package/dist/namespaced-html.js +1 -1
- package/dist/namespaced-html.js.map +2 -2
- package/dist/scoped-css.js +2 -2
- package/dist/scoped-css.js.map +2 -2
- package/dist/scoped-js.js.map +1 -1
- package/package.json +1 -1
- package/src/data-binding/index.js +6 -7
- package/src/html-imports/index.js +0 -1
- package/src/index.lite.js +1 -1
- package/src/namespaced-html/index.js +238 -219
- package/src/util.js +4 -4
- package/test/ii.html +0 -11
- package/test/ii2.html +0 -24
package/README.md
CHANGED
|
@@ -16,15 +16,15 @@ It comes as a script that plugs diretly into the DOM and have new semantics take
|
|
|
16
16
|
|
|
17
17
|
## Capabilities
|
|
18
18
|
|
|
19
|
-
### `1
|
|
19
|
+
### `1 | ` A component system
|
|
20
20
|
|
|
21
|
-
OOHTML enables a simple "define-and-use" system in HTML that is based on two complementary elements — the `<template
|
|
21
|
+
OOHTML enables a simple "define-and-use" system in HTML that is based on two complementary elements — the `<template>` and `<import>` elements. It makes it really easy to share repeating structures and stay organized.
|
|
22
22
|
|
|
23
|
-
### `2
|
|
23
|
+
### `2 | ` Data-binding and reactivity
|
|
24
24
|
|
|
25
25
|
OOHTML gives HTML the concept of data-binding (`{ expression }`) and reactivity that lets you embed application data in markup and have them stay in sync with application state. You get framework-grade reactivity without the overhead.
|
|
26
26
|
|
|
27
|
-
### `3
|
|
27
|
+
### `3 | ` New scoping behaviours
|
|
28
28
|
|
|
29
29
|
OOHTML extends the existing CSS scoping system to support the familiar `<style scoped>` syntax, introduces scoping for scripts (`<script scoped>`), and solves namespacing for IDs (`namespace`). They form a complete scoping system that is both declarative and powerful.
|
|
30
30
|
|
|
@@ -32,11 +32,11 @@ OOHTML extends the existing CSS scoping system to support the familiar `<style s
|
|
|
32
32
|
|
|
33
33
|
All of the above can be seen in a three-step tour. Each sample document below can be previewed directly in the browser:
|
|
34
34
|
|
|
35
|
-
### `1
|
|
35
|
+
### `1 | ` Write HTML as Reusable Components
|
|
36
36
|
|
|
37
37
|
At its core, OOHTML is a component system. It lets you write HTML as reusable components.
|
|
38
38
|
|
|
39
|
-
The standard `<template>` element already lets you define reusable markup. OOHTML completes the idea by introducing the `<import>` element.
|
|
39
|
+
The standard `<template>` element already lets you define reusable markup. OOHTML completes the idea by introducing the `<import>` element.
|
|
40
40
|
|
|
41
41
|
You write the following:
|
|
42
42
|
|
|
@@ -98,7 +98,7 @@ It resolves to the following, at runtime:
|
|
|
98
98
|
> [!NOTE]
|
|
99
99
|
> Later we'll cover the various usage patterns supported by the `<template>` and `<import>` system. We will also introduce file-based components and remote imports.
|
|
100
100
|
|
|
101
|
-
### `2
|
|
101
|
+
### `2 | ` Do Data-Binding with Standard HTML Comments
|
|
102
102
|
|
|
103
103
|
As a complete component system, OOHTML extends the DOM to support data-binding and reactivity.
|
|
104
104
|
|
|
@@ -148,7 +148,15 @@ It resolves to the following, at runtime:
|
|
|
148
148
|
<!-- increments live -->
|
|
149
149
|
|
|
150
150
|
<script>
|
|
151
|
-
|
|
151
|
+
document.bind({
|
|
152
|
+
title: "Hello OOHTML",
|
|
153
|
+
content: "Pure HTML, now reactive.",
|
|
154
|
+
count: 0,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
setInterval(() => {
|
|
158
|
+
document.bindings.count++;
|
|
159
|
+
}, 1000);
|
|
152
160
|
</script>
|
|
153
161
|
</body>
|
|
154
162
|
</html>
|
|
@@ -160,16 +168,18 @@ It resolves to the following, at runtime:
|
|
|
160
168
|
- Both styles – `<? ?>` and `<!-- -->` – are valid HTML comments and are interchangeable.
|
|
161
169
|
- `document.bind({ ... })` binds data to the DOM – at the document level.
|
|
162
170
|
- The data converges to `document.bindings` – a reactive data interface.
|
|
163
|
-
- Embedded expressions resolve from the bound data and stay in sync with it. Changes to data are automatically reflected in the
|
|
171
|
+
- Embedded expressions resolve from the bound data and stay in sync with it. Changes to data are automatically reflected in the UI.
|
|
164
172
|
|
|
165
173
|
> [!NOTE]
|
|
166
174
|
> Later we'll cover OOHTML's attribute-based binding syntax. We'll also formally introduce Mutation-Based Reactivity – the form of reactivity that OOHTML is based on.
|
|
167
175
|
|
|
168
|
-
### `3
|
|
176
|
+
### `3 | ` More Typical Usage Patterns
|
|
169
177
|
|
|
170
178
|
From the component and data-binding systems above to the scoping system yet to be discussed – OOHTML's features compose nicely into various usage patterns.
|
|
171
179
|
|
|
172
|
-
The document below brings some of that to life
|
|
180
|
+
The document below brings some of that to life.
|
|
181
|
+
|
|
182
|
+
You write:
|
|
173
183
|
|
|
174
184
|
```html
|
|
175
185
|
<!DOCTYPE html>
|
|
@@ -240,13 +250,13 @@ The document below brings some of that to life:
|
|
|
240
250
|
</html>
|
|
241
251
|
```
|
|
242
252
|
|
|
243
|
-
|
|
253
|
+
It resolves to the following, at runtime:
|
|
244
254
|
|
|
245
255
|
```html
|
|
246
256
|
<!DOCTYPE html>
|
|
247
257
|
<html>
|
|
248
258
|
<head>
|
|
249
|
-
|
|
259
|
+
<!-- existing contents -->
|
|
250
260
|
</head>
|
|
251
261
|
<body>
|
|
252
262
|
<h2 id="title">Card Demo</h2>
|
|
@@ -258,10 +268,10 @@ This resolves to the following at runtime:
|
|
|
258
268
|
<p id="body">Rendered inside the component.</p>
|
|
259
269
|
<p>Local count: 0</p>
|
|
260
270
|
<style scoped>
|
|
261
|
-
/* contents */
|
|
271
|
+
/* existing contents */
|
|
262
272
|
</style>
|
|
263
273
|
<script scoped>
|
|
264
|
-
/* contents */
|
|
274
|
+
/* existing contents */
|
|
265
275
|
</script>
|
|
266
276
|
</article>
|
|
267
277
|
|
|
@@ -270,17 +280,17 @@ This resolves to the following at runtime:
|
|
|
270
280
|
<p id="body">Rendered inside the component.</p>
|
|
271
281
|
<p>Local count: 0</p>
|
|
272
282
|
<style scoped>
|
|
273
|
-
/* contents */
|
|
283
|
+
/* existing contents */
|
|
274
284
|
</style>
|
|
275
285
|
<script scoped>
|
|
276
|
-
/* contents */
|
|
286
|
+
/* existing contents */
|
|
277
287
|
</script>
|
|
278
288
|
</article>
|
|
279
289
|
|
|
280
290
|
<p class="footer">Footer: Rendered outside the component.</p>
|
|
281
291
|
|
|
282
292
|
<script>
|
|
283
|
-
/* contents */
|
|
293
|
+
/* existing contents */
|
|
284
294
|
</script>
|
|
285
295
|
</body>
|
|
286
296
|
</html>
|
|
@@ -289,7 +299,7 @@ This resolves to the following at runtime:
|
|
|
289
299
|
#### Up there…
|
|
290
300
|
|
|
291
301
|
- We have a single component imported twice.
|
|
292
|
-
- Style, script, and IDs
|
|
302
|
+
- Style, script, and IDs scoped to the component so that repeating the structure in the DOM don't create collisions.
|
|
293
303
|
- Bindings resolve seamlessly inside and outside the component.
|
|
294
304
|
- The template ↔ import relationship hold live as before.
|
|
295
305
|
- Such that if you located the original `<template def> → <article>` element in the browser's console and deleted the node, all imports would dissolve; restored, all imports would resolve.
|
|
@@ -297,17 +307,17 @@ This resolves to the following at runtime:
|
|
|
297
307
|
|
|
298
308
|
## HTML for the Modern UI
|
|
299
309
|
|
|
300
|
-
By simply enhancing HTML, OOHTML makes it possible to directly author modern user interfaces in HTML and effectively removes the tooling tax traditionally associated with UI development. In
|
|
310
|
+
By simply enhancing HTML, OOHTML makes it possible to directly author modern user interfaces in HTML and effectively removes the tooling tax traditionally associated with UI development. In place of a compile step, you get a back-to-the-basics experience and an edit-in-the-browser workflow.
|
|
301
311
|
|
|
302
312
|
> [!TIP]
|
|
303
313
|
> In addition to inline components, OOHTML also supports file-based components. It's companion CLI tool – [OOHTML CLI](https://github.com/webqit/oohtml-cli) – lets you define your components in files and have them come together into a single file that you can directly import into your page.
|
|
304
314
|
|
|
305
315
|
> [!TIP]
|
|
306
|
-
> OOHTML solves the UI side of your application. You would need a framework to build a complete app with OOHTML. [Webflo](https://github.com/webqit/webflo) is a modern fullstack framework that converges on OOHTML for the UI. You even get Hot Module Replacement (HMR) on top.
|
|
316
|
+
> OOHTML solves the UI side of your application. You would need a framework to build a complete app with OOHTML. [Webflo](https://github.com/webqit/webflo) is a modern fullstack framework that converges on OOHTML for the UI. You even get Hot Module Replacement (HMR) on top as you edit your HTML components.
|
|
307
317
|
|
|
308
318
|
## Not a Replacement for Shadow DOM
|
|
309
319
|
|
|
310
|
-
OOHTML comes as its own addition to the DOM – alongside Web Components and Shadow DOM. Far from an Anti-Shadow DOM effort, OOHTML complements the HTML authoring experience inside the Shadow DOM itself – as it does outside of it. When used in the Shadow DOM, the Shadow DOM simply becomes the document that OOHTML sees – the Shadow Root itself (`#shadow-root`) being the new `document`
|
|
320
|
+
OOHTML comes as its own addition to the DOM – alongside Web Components and Shadow DOM. Far from an Anti-Shadow DOM effort, OOHTML complements the HTML authoring experience inside the Shadow DOM itself – as it does outside of it. When used in the Shadow DOM, the Shadow DOM simply becomes the document that OOHTML sees – the Shadow Root itself (`#shadow-root`) being the new `document` root that OOHTML works with.
|
|
311
321
|
|
|
312
322
|
Leveraging OOHTML in the Shadow DOM requires no additional step. Simply have the OOHTML script loaded in the main document as before and write.
|
|
313
323
|
|
|
@@ -320,7 +330,7 @@ For a quick way to see OOHTML in the Shadow DOM, we could suppose the whole of [
|
|
|
320
330
|
<html>
|
|
321
331
|
<head>
|
|
322
332
|
<script src="https://unpkg.com/@webqit/oohtml/dist/main.lite.js"></script>
|
|
323
|
-
<script>
|
|
333
|
+
<script type>
|
|
324
334
|
customElements.define('demo-component', class extends HTMLElement {
|
|
325
335
|
constructor() {
|
|
326
336
|
super();
|
|
@@ -328,8 +338,8 @@ For a quick way to see OOHTML in the Shadow DOM, we could suppose the whole of [
|
|
|
328
338
|
}
|
|
329
339
|
|
|
330
340
|
connectedCallback() {
|
|
341
|
+
// Shadow DOM markup
|
|
331
342
|
this.shadowRoot.innerHTML = `
|
|
332
|
-
<!-- Shadow DOM markup -->
|
|
333
343
|
<template def="card" scoped>
|
|
334
344
|
<!-- Reusable markup -->
|
|
335
345
|
<article namespace>
|
|
@@ -376,16 +386,14 @@ For a quick way to see OOHTML in the Shadow DOM, we could suppose the whole of [
|
|
|
376
386
|
<p class="footer">Footer: <?{ footerNote }?></p>
|
|
377
387
|
|
|
378
388
|
<scri` + `pt>
|
|
379
|
-
|
|
380
|
-
console.log(_this.shadowRoot);
|
|
381
|
-
_this.shadowRoot.bind({
|
|
389
|
+
this.shadowRoot.bind({
|
|
382
390
|
globalTitle: "Card Demo",
|
|
383
391
|
body: "Rendered outside the component.",
|
|
384
392
|
footerNote: "Rendered outside the component.",
|
|
385
393
|
count: 0,
|
|
386
394
|
});
|
|
387
395
|
|
|
388
|
-
setInterval(() =>
|
|
396
|
+
setInterval(() => this.shadowRoot.bindings.count++, 2000);
|
|
389
397
|
</scri` + `pt>`;
|
|
390
398
|
}
|
|
391
399
|
});
|
|
@@ -411,11 +419,10 @@ This README introduces the ideas.
|
|
|
411
419
|
The full reference each lives in the Wiki.
|
|
412
420
|
|
|
413
421
|
| Capability | Description | Reference |
|
|
414
|
-
|
|
|
422
|
+
| :-------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------------- |
|
|
415
423
|
| **HTML Imports** | Declarative & imperative module imports (`<template def>` · `<import ref>`) including remote modules, inheritance, contexts, and live resolution. | [HTML Imports](https://github.com/webqit/oohtml/wiki/HTML-Imports) |
|
|
416
424
|
| **Data Binding** | Comment-based bindings (`<?{ }?>`), attribute-based bindings (`render="…”`), list rendering, and runtime updates. | [Data Binding](https://github.com/webqit/oohtml/wiki/Data-Binding) |
|
|
417
|
-
| **
|
|
418
|
-
| **Namespacing** | Declarative ID/IDREF scoping for repeated structures (`namespace`, `#~id`, path selectors). | [Namespacing](https://github.com/webqit/oohtml/wiki/Namespacing) |
|
|
425
|
+
| **DOM Scoping** | Style and script scoping (`<style scoped>`, `<script scoped>`) Namespaces for IDs. | [DOM Scoping](https://github.com/webqit/oohtml/wiki/DOM-Scoping) |
|
|
419
426
|
| **Bindings API** | Reactive state surfaces on any DOM node (`node.bindings`, `node.bind()`), powering all binding resolution. | [Bindings API](https://github.com/webqit/oohtml/wiki/Bindings-API) |
|
|
420
427
|
| **Context API** | The request/response infrastructure that powers imports, bindings, namespacing, and scoping resolution. | [Context API](https://github.com/webqit/oohtml/wiki/Context-API) |
|
|
421
428
|
| **Live Scripts** | Fine-grained reactivity embedded directly in JavaScript using the Quantum runtime. | [Live Scripts](https://github.com/webqit/oohtml/wiki/Live-Scripts) |
|
|
@@ -428,7 +435,7 @@ The full reference each lives in the Wiki.
|
|
|
428
435
|
|
|
429
436
|
OOHTML can be used in two ways:
|
|
430
437
|
|
|
431
|
-
- Directly in the browser,
|
|
438
|
+
- Directly in the browser, via a client-side script
|
|
432
439
|
- Via npm – for integration with bundlers, jsdom, SSR, etc.
|
|
433
440
|
|
|
434
441
|
### 1. Browser Setup
|
|
@@ -452,8 +459,8 @@ OOHTML needs to be present **while** the document is parsed so it can activate t
|
|
|
452
459
|
|
|
453
460
|
OOHTML ships with two builds:
|
|
454
461
|
|
|
455
|
-
* **`main.lite.js`** – the *lite* edition; the default and recommended. Provides async execution for scoped scripts and
|
|
456
|
-
* **`main.js`** – the *full* edition;
|
|
462
|
+
* **`main.lite.js`** – the *lite* edition; the default and recommended. Provides async execution for scoped scripts and "live" scripts.
|
|
463
|
+
* **`main.js`** – the *full* edition; needed when you require synchronous script timing for scoped scripts and "live" scripts.
|
|
457
464
|
|
|
458
465
|
### 2. Via npm
|
|
459
466
|
|
|
@@ -474,7 +481,7 @@ init.call(window, UseLive/*, options */);
|
|
|
474
481
|
|
|
475
482
|
#### SSR with jsdom
|
|
476
483
|
|
|
477
|
-
For pure server-side operations and SSR, install `jsdom` and use its `window` as OOHTML's `window` option:
|
|
484
|
+
For pure server-side operations and SSR, install `jsdom` and use its `window` object as OOHTML's `window` option:
|
|
478
485
|
|
|
479
486
|
```js
|
|
480
487
|
import { JSDOM } from "jsdom";
|
package/dist/bindings-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var Kt=Object.defineProperty;var te=(n,t,r)=>t in n?Kt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var lt=(n,t,r)=>(te(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 X(n){return typeof n=="function"}function J(n){return n===null||n===""}function D(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||X(n)}function gt(n){return J(n)||D(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function b(n){return X(n)||n&&{}.toString.call(n)==="[object function]"}function Y(n){return n instanceof Number||typeof n=="number"}function S(n){return Y(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function Q(n){return n instanceof String||typeof n=="string"&&n!==null}function yt(n){return!Q(n)&&!D(n.length)}function ct(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function bt(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 bt(n,t).forEach(e=>{ct(r,...Object.getOwnPropertyNames(e))}),r}function j(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,c)=>{!A(f)&&!b(f)||(r?_t(f):Object.keys(f)).forEach(l=>{if(!!t(l,s,f,c)){var u=s[l],m=f[l];if((g(u)&&g(m)||w(u)&&w(m))&&(o===!0||o>0))s[l]=g(u)&&g(m)?[]:{},j([S(o)?o-1:o,s[l],u,m],t,r,e,i);else if(g(s)&&g(f))e?s[l]=m:s.push(m);else try{i?Object.defineProperty(s,l,Object.getOwnPropertyDescriptor(f,l)):s[l]=f[l]}catch{}}})}),s}function Z(...n){return j(n,(t,r,e)=>!0,!1,!1,!1)}function C(n,...t){if(!n||!["object","function"].includes(typeof n))throw new Error("Argument #1 must be of type object");let r=n[Symbol.for("wq")];if(r||(r=new ut,Object.defineProperty(n,Symbol.for("wq"),{value:r,enumerable:!1,configurable:!1,writable:!1})),!t.length)return r;let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new ut,i.set(e,r));return r}var ut=class extends Map{};function E(n,t=!0){return g(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&>(n)?[]:yt(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function K(n,t,r={},e={}){t=E(t).slice();for(var i=n;!D(i)&&!J(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):A(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 xt(n,t,r,e={},i={}){let o=(u,m,a)=>i.set?i.set(u,m,a):(S(t[f])&&g(u)?u.push(a):u[m]=a,!0);t=E(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!A(s)&&!b(s))return!1;var c=K(s,t[f],i);if(!A(c)){if(i.buildTree===!1)return!1;c=b(i.buildTree)?i.buildTree(f):S(t[f+1])?[]:{};var l=o(s,t[f],c);if(!l)return!1}s=c}else return o(s,t[f],r)}var tt=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),c=l=>{l!==void 0&&this.cycle(t,r,l)};f instanceof Promise?f.then(c):c(f)})};i instanceof Promise?i.then(o):o(i)})}};function Nt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function mt(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 Ht(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function et(n,t,r,e=!1,i=null){let o=i?.get(t)?.get(r);if(typeof o<"u")return o;let s=l=>(i?.has(t)||i?.set(t,new WeakMap),i?.get(t)?.set(r,l),l),f=t.getRootNode(),c=r.getRootNode();return f===c?s(t.contains(r)):e&&c instanceof n.ShadowRoot?s(et(n,t,c.host,e,i)):s(!1)}function $t(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 q=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Nt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=$t(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var G=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 q)&&t.length===1?t=[[],void 0,t[0]]:w(t[1])&&t.length===2?t=[E(t[0],!1),void 0,t[1]]:t[0]=E(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof q)&&!(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 q?r:new q(r)),t}registry(...t){return C(this.window,"realdom",this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,o=new Set,s=new WeakMap;for(let[f,c]of this.registry(t)){let l=[].concat(r).filter(m=>et(i,f.context,m.target,f.params.subtree==="cross-roots",s));if(!l.length)continue;let u=[f,Array.isArray(r)?l:l[0]];c?o.add(u):e.call(i,...u)}for(let f of o)e.call(i,...f);o.clear()}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 F=class extends G{type="attr";constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof q;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Wt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let c of s){let l=f?f.generate():{};r(c,l,o)}else{let c=f?.generate()||{};r(s,c,o)}if(e.live){f&&(e={...e,signalGenerator:f});let c=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,c)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof q;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&&Rt.call(s,"intercept",()=>{});let c=new s.MutationObserver(a=>{a=Ft(a).map(p=>Ut.call(s,p)),Dt.call(s,m,a,o)}),l={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(l.attributeFilter=t.map(a=>a+"")),c.observe(o,l);let u=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:u,disconnectable:c};return this.disconnectables(e.signal,c,u)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof q;[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";this.registry(f).size||Rt.call(s,f,a=>{this.forEachMatchingContext(f,a,Dt)});let c={disconnect(){m.delete(u)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:c},m=this.registry(f);return m.set(u,!!u.params.deferred),this.disconnectables(e.signal,c,l)}};function Ft(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||C(r.target,"realdom","internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Dt(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:c}=n;if(o.subtree||(t=t.filter(a=>a.target===r)),!t.length)return;let l=e.map(a=>a+"");if(o.atomic&&!s.size?t=Wt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(a=>l.includes(a.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(a=>{let p;return o.eventDetails||({event:p,...a}=a),!o.oldValue&&"oldValue"in a&&({oldValue:p,...a}=a),!o.newValue&&"value"in a?{value:p,...a}=a:o.newValue&&typeof a.value>"u"&&(a={...a,value:dt(a.target,a.name,()=>a.target.getAttribute(a.name))}),a})),o.atomic&&(t.forEach(a=>s.set(a.name,a)),t=Array.from(s.entries()).map(([,a])=>a));let u=f?t[0]:t,m=c?c.generate():{};i(u,m,r)}function dt(n,t,r){let e=C(n,"realdom","internalAttrInteractions").get(t);C(n,"realdom","internalAttrInteractions").set(t,!0);let i=r();return C(n,"realdom","internalAttrInteractions").set(t,e),i}function Wt(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:dt(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:dt(n,o.nodeName,()=>o.nodeValue),...e})}function Ut({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 Rt(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=(u,m)=>{e.realdom.attrInterceptionRecords.has(u.target)||e.realdom.attrInterceptionRecords.set(u.target,{});let a=e.realdom.attrInterceptionRecords.get(u.target);if(a[u.name]=a[u.name]||[],a[u.name].unshift(u.event),C(u.target,"realdom","internalAttrInteractions").get(u.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(_=>_([u]));let p=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(_=>_([u])),p};new r.MutationObserver(u=>{u=u.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),u=Ft(u).map(m=>Ut.call(r,m)),u.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(u)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(u)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let l=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(u=>{l[u]=o.prototype[u],o.prototype[u]=function(...m){let a,p=dt(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(u)&&(a=m[1]),u==="toggleAttribute"&&a===void 0&&(a=p===null);let _={target:this,name:m[0],value:a,oldValue:p,type:"interception",event:[this,u]};return f(_,()=>l[u].call(this,...m))}}),s}var rt=class extends G{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new F(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=l=>(o.has(l)||o.set(l,{target:l,entrants:[],exits:[],type:"query",event:null}),o.get(l));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(l=>s(i).entrants.push(l));else if(t.every(l=>l.type==="selector")){let[l,u]=t.reduce(([a,p],_)=>_.kind==="xpath"?[a,p.concat(_)]:[a.concat(_),p],[[],[]]),m=[];e.subtree?(l.length&&m.push(...i.querySelectorAll(l.join(","))),u.length&&m.push(...mt(this.window,i,u))):(l.length&&m.push(...[...i.children].filter(a=>a.matches(l))),u.length&&m.push(...mt(this.window,i,u,!1))),m.forEach(a=>s(a.parentNode||i).entrants.push(a))}}if(!r)return o;let f={disconnected:!1},c=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,l]of o){if(f.disconnected)break;let u=c?.generate()||{};r(l,u,i)}if(e.live){c&&(e={...e,signalGenerator:c});let l=this.observe(t,r,e);return this.disconnectables(e.signal,f,l)}return this.disconnectables(e.signal,f,c)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Gt.call(o,"sync",()=>{});let c=new o.MutationObserver(m=>m.forEach(a=>{At.call(o,u,Bt.call(o,a),i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c};if(e.staticSensitivity){let m=Vt.call(o,u);return this.disconnectables(e.signal,c,l,m)}return this.disconnectables(e.signal,c,l)}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";this.registry(s).size||Gt.call(o,s,a=>{this.forEachMatchingContext(s,a,At)});let f=new o.MutationObserver(a=>a.forEach(p=>{Array.isArray((p=Bt.call(o,p)).event)||At.call(o,u,p,i)}));f.observe(i,{childList:!0,subtree:e.subtree&&!0});let c={disconnect(){m.delete(u),f.disconnect()}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),u={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c},m=this.registry(s);if(m.set(u,!!u.params.deferred),e.staticSensitivity){let a=Vt.call(o,u);return this.disconnectables(e.signal,c,l,a)}return this.disconnectables(e.signal,c,l)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function Vt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(p=>p.kind==="css"),c=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],l=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],u=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(_=>_[1]).concat(c(p)).concat(l(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,_)=>p.concat(u(_+"")),[])))).length)return;let m=new Set,a=new Set;return m.push=p=>(a.delete(p),m.add(p)),a.push=p=>(m.delete(p),a.add(p)),n.$deliveryCache={entrants:m,exits:a},new F(r,t).observe(n.$attrs,p=>{let _=new Map,O=y=>(_.has(y)||_.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),_.get(y)),st=new WeakMap,d=y=>(st.has(y)||st.set(y,f.some(v=>y.matches(v+""))),st.get(y));for(let y of p)["entrants","exits"].forEach(v=>{o.generation&&v!==o.generation||n.$deliveryCache[v].has(y.target)||(v==="entrants"?!d(y.target):d(y.target))||(n.$deliveryCache[v].push(y.target),O(y.target)[v].push(y.target),O(y.target).event=y.event)});for(let[,y]of _){let v=s?.generate()||{};i(y,v,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function At(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,c={...t,entrants:[],exits:[]};if(o.eventDetails||delete c.event,["entrants","exits"].forEach(u=>{if(!(o.generation&&u!==o.generation)&&(e.length?c[u]=ge.call(this,e,o.subtree==="cross-roots",t[u],t.event!=="parse"):c[u]=[...t[u]],!!f))for(let m of c[u])f[u].push(m)}),!c.entrants.length&&!c.exits.length)return;let l=s?.generate()||{};i(c,l,r)}function ge(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(c=>s.kind==="xpath"?Ht(this,c,s+""):c.matches&&c.matches(s+""));if((e||s.isXpathAttr)&&(f=o.reduce((c,l)=>s.kind==="xpath"?[...c,...mt(this,l,s,e)]:l.querySelectorAll?[...c,...l.querySelectorAll(s+"")]:c,f)),f.length)return f}else if(o.includes(s.content)||e&&o.some(f=>et(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 Bt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=E(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=E(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 Gt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:c,HTMLTemplateElement:l,DocumentFragment:u}=r;e.realdom.domInterceptionHooks||Object.defineProperty(e.realdom,"domInterceptionHooks",{value:new Map}),e.realdom.domInterceptionNoRecurse||Object.defineProperty(e.realdom,"domInterceptionNoRecurse",{value:new Map}),e.realdom.domInterceptionHooks.has(n)||e.realdom.domInterceptionHooks.set(n,new Set),e.realdom.domInterceptionHooks.get(n).add(t);let m=()=>e.realdom.domInterceptionHooks.get(n).delete(t);if(e.realdom.domInterceptionHooks?.intercepting)return m;console.warn("DOM mutation APIs are now being intercepted."),e.realdom.domInterceptionHooks.intercepting=!0,Object.defineProperty(e.realdom,"domInterceptionRecords",{value:new Map});let a=(d,y,v)=>{e.realdom.domInterceptionNoRecurse.set(d,y);let h=v();return e.realdom.domInterceptionNoRecurse.delete(d),h},p=(d,y)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,d.event);let I=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:I,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let v=y();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),v},_={ShadowRoot:["innerHTML","setHTMLUnsafe"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTMLUnsafe","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},O={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(_).reduce((d,y)=>d.concat(y),[])).forEach(d=>{Object.keys(_).forEach(h=>{if(!_[h].includes(d))return;let I=Object.getOwnPropertyDescriptor(r[h].prototype,d);!I||(Object.defineProperty(r[h].prototype,d,"value"in I?{...I,value:y}:{...I,set:v}),O[h][d]=I)});function y(...h){let I=Object.keys(O).find(P=>this instanceof r[P]&&d in O[P]),z=O[I],L=()=>z[d].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===d)return L();let k=[],x=[],N=this;["insertBefore"].includes(d)?x=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(x=[h[1]],["beforebegin","afterend"].includes(h[0])&&(N=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(d)?(k=[...this.childNodes],x=d==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(d)?(k=[this],x=d==="replaceWith"?[...h]:[],N=this.parentNode):["replaceChild"].includes(d)?(k=[h[1]],x=[h[0]]):["removeChild"].includes(d)?k=[...h]:(x=[...h],["before","after"].includes(d)&&(N=this.parentNode));let ft=d;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(d)){let P=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return z[d].value.call(this,...h);P=this.parentNode.nodeName}let R=i.createElement(P.includes("-")?"div":P);z.setHTMLUnsafe.value.call(R,x[0],d==="setHTMLUnsafe"?h[1]:{}),x=[...R.childNodes],d==="insertAdjacentHTML"?(ft="insertAdjacentElement",h[1]=new u,a(h[1],"append",()=>h[1].append(...R.childNodes))):(ft="replaceChildren",h=[...R.childNodes])}return N?p({target:N,entrants:x,exits:k,type:"interception",event:[this,d]},()=>z[ft].value.call(this,...h)):L()}function v(h){let I=Object.keys(O).find(V=>this instanceof r[V]&&d in O[V]),z=O[I],L=()=>z[d].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===d)return L();let k=[],x=[],N=this;if(["outerHTML","outerText"].includes(d)?(k=[this],N=this.parentNode):this instanceof l?(N=this.content,k=[...this.content.childNodes]):k=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let V=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return L();V=this.parentNode.nodeName}let P=i.createElement(V.includes("-")?"div":V);if(a(P,d,()=>P[d]=h),x=this instanceof l?[...P.content.childNodes]:[...P.childNodes],this instanceof l&&this.hasAttribute("src")||this instanceof ShadowRoot){let R=B=>B.reduce((H,$)=>$ instanceof HTMLScriptElement?H.concat($):$ instanceof l?H.concat(R([$.content])):(H=H.concat(R([...$.querySelectorAll?.("template")||[]].map(Zt=>Zt.content))),H.concat(...$.querySelectorAll?.("script")||[])),[]);for(let B of R(x)){if(this instanceof ShadowRoot){B.setAttribute("data-handling","manual");continue}let H=i.createElement("script");[...B.attributes].forEach($=>H.setAttribute($.name,$.value)),H.textContent=B.textContent,a(B,"replaceWith",()=>B.replaceWith(H))}}d==="outerHTML"?(h=new u,a(h,"append",()=>h.append(...x)),L=()=>a(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof l?L=()=>a(this.content,"replaceChildren",()=>this.content.replaceChildren(...x)):L=()=>a(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...x))}return p({target:N,entrants:x,exits:k,type:"interception",event:[this,d]},L)}}),m}function zt(){ye.call(this),be.call(this),_e.call(this)}function ye(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function be(){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 _e(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Xt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},zt.call(n),n.webqit.realdom.meta=(...r)=>we.call(n,...r),n.webqit.realdom.ready=(...r)=>Et.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new rt(r,n);if(e==="attr")return new F(r,n)};let t=new tt(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function Et(...n){let t="interactive",r;Q(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=>Et.call(this,"interactive",o)),complete:new Promise(o=>Et.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 we(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 xt(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 pt(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 W=(n,...t)=>C(n,"oohtml",...t),M={};function Jt(n,t,r){let e=this,i=Xt.call(e);M.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(c=>{f==="api"&&typeof s[f][c]=="string"?s[f][c]=`${e.webqitConfig.prefix}${pt(s[f][c])}`:["attr","elements"].includes(f)&&s[f][c]?.startsWith("data-")===!1&&(s[f][c]=`${e.webqitConfig.prefix}-${s[f][c]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function St(n,t){return[...n].reduce(([r,e,i],o)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(o)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,e,i]),[null,0,[""]])[2].reverse()}function Yt(){let{window:n}=M,{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"],c=i.pop()||f[0];if(!f.includes(c))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:l,detail:u,targetContext:m,live:a,signal:p,diff:_,...O}=s;super(c,{...O,bubbles:O.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>l}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>u}),Object.defineProperty(this,"live",{get:()=>a}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>_}),Object.defineProperty(this,"options",{get:()=>O}),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 nt=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=M;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var it=class extends Error{};var ot=class{static instance(t){return W(t).get("contexts::instance")||new this(t)}constructor(t){W(t).get("contexts::instance")?.dispose(),W(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}[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[1]||r.detail===t[1]))}attach(t){if(!(t instanceof U))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new it(`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 nt((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(Yt())(...t);this["#"].host.dispatchEvent(o)})}};var Ct=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}}}}=M;return t}get name(){return[M.window.Document,M.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 Ct)||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}=ot.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;r.meta.answered=!1,e.dispatchEvent(r)}),this}},U=Ct;lt(U,"kind");var T=class extends U{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}}}=M;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()}};lt(T,"kind","bindings");function qt(n={}){let{config:t,window:r}=Jt.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=T,ve.call(r,t),Ee.call(r,t)}function Tt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!W(t).has("bindings")){let o=Object.create(null);W(t).set("bindings",o),e.observe(o,s=>{if(t instanceof r.Element){let f=ht(t.getAttribute(n.attr.bindingsreflection)||""),c=new Map(f);for(let l of s)l.detail?.publish!==!1&&(l.type==="delete"?f.delete(l.key):f.set(l.key,void 0));f.size&&f.size!==c.size?t.setAttribute(n.attr.bindingsreflection,`{ ${[...f.entries()].map(([l,u])=>u===void 0?l:`${l}: ${u}`).join(", ")} }`):f.size||t.toggleAttribute(n.attr.bindingsreflection,!1)}else{let f=t[i.api.contexts];for(let c of s)if(c.type==="delete"){let l=f.find(T.kind,c.key);l&&f.detach(l)}else f.find(T.kind,c.key)||f.attach(new T(c.key))}})}return W(t).get("bindings")}function ve(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 Ae.call(t,n,this,o,s)}}),Object.defineProperty(e,n.api.bindings,{get:function(){return r.proxy(Tt.call(t,n,this))}})})}function Ae(n,t,r,{merge:e,diff:i,publish:o,namespace:s}={}){let f=this,{webqit:{Observer:c}}=f,l=Tt.call(this,n,t),u={diff:i,namespace:s,detail:{publish:o}},m=e?[]:Object.keys(l).filter(a=>!(a in r));return c.batch(l,()=>(m.length&&c.deleteProperties(l,m,u),c.set(l,r,u)),u)}function Ee(n){let t=this,{webqit:{realdom:r,Observer:e,oohtml:{configs:i}}}=t,o=(f,c)=>{let l=f[i.CONTEXT_API.api.contexts];l.find(T.kind,c)||l.attach(new T(c))},s=(f,c)=>{let l,u=f[i.CONTEXT_API.api.contexts];for(;l=u.find(T.kind,c);)u.detach(l)};r.realtime(t.document).query(`[${t.CSS.escape(n.attr.bindingsreflection)}]`,f=>{f.exits.forEach(c=>s(c)),f.entrants.forEach(c=>{let l=ht(c.getAttribute(n.attr.bindingsreflection)||""),u=[...l.entries()].filter(([m,a])=>a!==void 0);u.length&&c[n.api.bind](Object.fromEntries(u),{merge:!0,publish:!1});for(let[m]of l)o(c,m)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),r.realtime(t.document,"attr").observe(n.attr.bindingsreflection,f=>{let c=Tt.call(t,n,f.target),l=ht(f.value||""),u=ht(f.oldValue||"");for(let m of new Set([...l.keys(),...u.keys()]))u.has(m)?l.has(m)?l.get(m)!==u.get(m)&&e.set(c,m,l.get(m),{detail:{publish:!1}}):(u.get(m)!==void 0&&e.deleteProperty(c,m,{detail:{publish:!1}}),s(f.target,m)):(l.get(m)!==void 0&&e.set(c,m,l.get(m),{detail:{publish:!1}}),o(f.target,m))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var ht=n=>(n=n.trim(),new Map(St(n.slice(1,-1),",").filter(t=>t.trim()).map(t=>St(t,":").map(r=>r.trim()))));qt.call(window);
|
|
1
|
+
var Kt=Object.defineProperty;var te=(n,t,r)=>t in n?Kt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r;var lt=(n,t,r)=>(te(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 X(n){return typeof n=="function"}function J(n){return n===null||n===""}function D(n){return arguments.length&&(n===void 0||typeof n>"u")}function A(n){return Array.isArray(n)||typeof n=="object"&&n||X(n)}function gt(n){return J(n)||D(n)||n===!1||n===0||A(n)&&!Object.keys(n).length}function b(n){return X(n)||n&&{}.toString.call(n)==="[object function]"}function Y(n){return n instanceof Number||typeof n=="number"}function S(n){return Y(n)||n!==!0&&n!==!1&&n!==null&&n!==""&&!isNaN(n*1)}function Q(n){return n instanceof String||typeof n=="string"&&n!==null}function yt(n){return!Q(n)&&!D(n.length)}function ct(n,...t){return t.forEach(r=>{n.indexOf(r)<0&&n.push(r)}),n}function bt(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 bt(n,t).forEach(e=>{ct(r,...Object.getOwnPropertyNames(e))}),r}function j(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,c)=>{!A(f)&&!b(f)||(r?_t(f):Object.keys(f)).forEach(l=>{if(!!t(l,s,f,c)){var a=s[l],m=f[l];if((g(a)&&g(m)||w(a)&&w(m))&&(o===!0||o>0))s[l]=g(a)&&g(m)?[]:{},j([S(o)?o-1:o,s[l],a,m],t,r,e,i);else if(g(s)&&g(f))e?s[l]=m:s.push(m);else try{i?Object.defineProperty(s,l,Object.getOwnPropertyDescriptor(f,l)):s[l]=f[l]}catch{}}})}),s}function Z(...n){return j(n,(t,r,e)=>!0,!1,!1,!1)}function C(n,...t){if(!n||!["object","function"].includes(typeof n))throw new Error("Argument #1 must be of type object");let r=n[Symbol.for("wq")];if(r||(r=new at,Object.defineProperty(n,Symbol.for("wq"),{value:r,enumerable:!1,configurable:!1,writable:!1})),!t.length)return r;let e,i;for(;e=t.shift();)(i=r)&&!(r=r.get(e))&&(r=new at,i.set(e,r));return r}var at=class extends Map{};function E(n,t=!0){return g(n)?n:!t&&w(n)?[n]:n!==!1&&n!==0&>(n)?[]:yt(n)?Array.prototype.slice.call(n):w(n)?Object.values(n):[n]}function K(n,t,r={},e={}){t=E(t).slice();for(var i=n;!D(i)&&!J(i)&&t.length;){var o=t.shift();if(!(r.get?r.get(i,o):A(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 xt(n,t,r,e={},i={}){let o=(a,m,u)=>i.set?i.set(a,m,u):(S(t[f])&&g(a)?a.push(u):a[m]=u,!0);t=E(t);for(var s=n,f=0;f<t.length;f++)if(f<t.length-1){if(!s||!A(s)&&!b(s))return!1;var c=K(s,t[f],i);if(!A(c)){if(i.buildTree===!1)return!1;c=b(i.buildTree)?i.buildTree(f):S(t[f+1])?[]:{};var l=o(s,t[f],c);if(!l)return!1}s=c}else return o(s,t[f],r)}var tt=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),c=l=>{l!==void 0&&this.cycle(t,r,l)};f instanceof Promise?f.then(c):c(f)})};i instanceof Promise?i.then(o):o(i)})}};function Nt(n){return(n=n.trim())&&n.startsWith("(")&&n.endsWith(")")}function mt(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 Ht(n,t,r){r=(Array.isArray(r)?r:[r]).map(e=>(e+"").replace("(","(self::")).join("|");try{return n.document.evaluate(`${r}`,t,null,n.XPathResult.BOOLEAN_TYPE).booleanValue}catch{}}function et(n,t,r,e=!1,i=null){let o=i?.get(t)?.get(r);if(typeof o<"u")return o;let s=l=>(i?.has(t)||i?.set(t,new WeakMap),i?.get(t)?.set(r,l),l),f=t.getRootNode(),c=r.getRootNode();return f===c?s(t.contains(r)):e&&c instanceof n.ShadowRoot?s(et(n,t,c.host,e,i)):s(!1)}function $t(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 q=class{constructor(t){this.content=t,this.type=typeof t=="string"?"selector":"instance",this.kind=this.type==="instance"?null:Nt(t)?"xpath":"css",this.kind==="xpath"&&(this.isXpathAttr=$t(t.trim().slice(1,-1),"@").length>1)}toString(){return this.content}};var G=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 q)&&t.length===1?t=[[],void 0,t[0]]:w(t[1])&&t.length===2?t=[E(t[0],!1),void 0,t[1]]:t[0]=E(t[0],!1),t[0].filter(r=>typeof r!="string"&&!(r instanceof q)&&!(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 q?r:new q(r)),t}registry(...t){return C(this.window,"realdom",this.namespace,...t)}createSignalGenerator(){return{generate(){return this.lastController?.abort(),this.lastController=new AbortController,{signal:this.lastController.signal}},disconnect(){this.lastController?.abort()}}}forEachMatchingContext(t,r,e){let{window:i}=this,o=new Set,s=new WeakMap;for(let[f,c]of this.registry(t)){let l=[].concat(r).filter(m=>et(i,f.context,m.target,f.params.subtree==="cross-roots",s));if(!l.length)continue;let a=[f,Array.isArray(r)?l:l[0]];c?o.add(a):e.call(i,...a)}for(let f of o)e.call(i,...f);o.clear()}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 F=class extends G{type="attr";constructor(t,...r){super(t,"attr",...r)}get(t,r=void 0,e={}){let i=typeof t=="string"||t instanceof q;[t=[],r=void 0,e={}]=this.resolveArgs(arguments);let{context:o}=this,s=Wt(o,t);if(!r)return s;let f=e.lifecycleSignals&&this.createSignalGenerator();if(i)for(let c of s){let l=f?f.generate():{};r(c,l,o)}else{let c=f?.generate()||{};r(s,c,o)}if(e.live){f&&(e={...e,signalGenerator:f});let c=this.observe(i?t[0]:t,r,{newValue:!0,...e});return this.disconnectables(e.signal,c)}}observe(t,r,e={}){let i=typeof t=="string"||t instanceof q;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&&Rt.call(s,"intercept",()=>{});let c=new s.MutationObserver(u=>{u=Ft(u).map(p=>Ut.call(s,p)),Dt.call(s,m,u,o)}),l={attributes:!0,attributeOldValue:e.oldValue,subtree:e.subtree&&!0};t.length&&(l.attributeFilter=t.map(u=>u+"")),c.observe(o,l);let a=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),m={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:a,disconnectable:c};return this.disconnectables(e.signal,c,a)}observeSync(t,r,e={}){let i=typeof t=="string"||t instanceof q;[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";this.registry(f).size||Rt.call(s,f,u=>{this.forEachMatchingContext(f,u,Dt)});let c={disconnect(){m.delete(a)}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:o,spec:t,callback:r,params:e,atomics:new Map,originalFilterIsString:i,signalGenerator:l,disconnectable:c},m=this.registry(f);return m.set(a,!!a.params.deferred),this.disconnectables(e.signal,c,l)}};function Ft(n){return n.reduce((t,r,e)=>t[e-1]?.attributeName===r.attributeName||C(r.target,"realdom","internalAttrInteractions").get(r.attributeName)?t:t.concat(r),[])}function Dt(n,t){let{context:r,spec:e,callback:i,params:o,atomics:s,originalFilterIsString:f,signalGenerator:c}=n;if(o.subtree||(t=t.filter(u=>u.target===r)),!t.length)return;let l=e.map(u=>u+"");if(o.atomic&&!s.size?t=Wt(r,e,t):o.timing!=="async"&&e.length&&(t=t.filter(u=>l.includes(u.name))),!t.length)return;o.newValue===null&&o.oldValue===null&&o.eventDetails||(t=t.map(u=>{let p;return o.eventDetails||({event:p,...u}=u),!o.oldValue&&"oldValue"in u&&({oldValue:p,...u}=u),!o.newValue&&"value"in u?{value:p,...u}=u:o.newValue&&typeof u.value>"u"&&(u={...u,value:dt(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 a=f?t[0]:t,m=c?c.generate():{};i(a,m,r)}function dt(n,t,r){let e=C(n,"realdom","internalAttrInteractions").get(t);C(n,"realdom","internalAttrInteractions").set(t,!0);let i=r();return C(n,"realdom","internalAttrInteractions").set(t,e),i}function Wt(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:dt(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:dt(n,o.nodeName,()=>o.nodeValue),...e})}function Ut({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 Rt(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=(a,m)=>{e.realdom.attrInterceptionRecords.has(a.target)||e.realdom.attrInterceptionRecords.set(a.target,{});let u=e.realdom.attrInterceptionRecords.get(a.target);if(u[a.name]=u[a.name]||[],u[a.name].unshift(a.event),C(a.target,"realdom","internalAttrInteractions").get(a.name))return m();e.realdom.attrInterceptionHooks.get("intercept")?.forEach(_=>_([a]));let p=m();return e.realdom.attrInterceptionHooks.get("sync")?.forEach(_=>_([a])),p};new r.MutationObserver(a=>{a=a.filter(m=>!(r.webqit.realdom.attrInterceptionRecords?.get(m.target)||{})[m.attributeName]?.shift()),a=Ft(a).map(m=>Ut.call(r,m)),a.length&&(e.realdom.attrInterceptionHooks.get("intercept")?.forEach(m=>m(a)),e.realdom.attrInterceptionHooks.get("sync")?.forEach(m=>m(a)))}).observe(i,{attributes:!0,subtree:!0,attributeOldValue:!0});let l=Object.create(null);return["setAttribute","removeAttribute","toggleAttribute"].forEach(a=>{l[a]=o.prototype[a],o.prototype[a]=function(...m){let u,p=dt(this,m[0],()=>this.getAttribute(m[0]));["setAttribute","toggleAttribute"].includes(a)&&(u=m[1]),a==="toggleAttribute"&&u===void 0&&(u=p===null);let _={target:this,name:m[0],value:u,oldValue:p,type:"interception",event:[this,a]};return f(_,()=>l[a].call(this,...m))}}),s}var rt=class extends G{constructor(t,...r){super(t,"tree",...r)}attr(t,r=void 0,e={}){let{context:i,window:o}=this;return new F(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=l=>(o.has(l)||o.set(l,{target:l,entrants:[],exits:[],type:"query",event:null}),o.get(l));if(!e.generation||e.generation==="entrants"){if(!t.length)[...i.children].forEach(l=>s(i).entrants.push(l));else if(t.every(l=>l.type==="selector")){let[l,a]=t.reduce(([u,p],_)=>_.kind==="xpath"?[u,p.concat(_)]:[u.concat(_),p],[[],[]]),m=[];e.subtree?(l.length&&m.push(...i.querySelectorAll(l.join(","))),a.length&&m.push(...mt(this.window,i,a))):(l.length&&m.push(...[...i.children].filter(u=>u.matches(l))),a.length&&m.push(...mt(this.window,i,a,!1))),m.forEach(u=>s(u.parentNode||i).entrants.push(u))}}if(!r)return o;let f={disconnected:!1},c=r&&e.lifecycleSignals&&this.createSignalGenerator();for(let[,l]of o){if(f.disconnected)break;let a=c?.generate()||{};r(l,a,i)}if(e.live){c&&(e={...e,signalGenerator:c});let l=this.observe(t,r,e);return this.disconnectables(e.signal,f,l)}return this.disconnectables(e.signal,f,c)}children(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!1})}subtree(t,r=void 0,e={}){return[t,r=void 0,e={}]=this.resolveArgs(arguments),this.query(t,r,{...e,subtree:!0})}observe(t,r,e={}){if([t,r,e={}]=this.resolveArgs(arguments),["sync","intercept"].includes(e.timing))return this.observeSync(t,r,e);if(e.timing&&e.timing!=="async")throw new Error(`Timing option "${e.timing}" invalid.`);let{context:i,window:o,webqit:s,document:f}=this;e.eventDetails&&(s.realdom.domInterceptionRecordsAlwaysOn=!0),(f.readyState==="loading"||s.realdom.domInterceptionRecordsAlwaysOn)&&!s.realdom.domInterceptionHooks?.intercepting&&Gt.call(o,"sync",()=>{});let c=new o.MutationObserver(m=>m.forEach(u=>{At.call(o,a,Bt.call(o,u),i)}));c.observe(i,{childList:!0,subtree:e.subtree&&!0});let l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c};if(e.staticSensitivity){let m=Vt.call(o,a);return this.disconnectables(e.signal,c,l,m)}return this.disconnectables(e.signal,c,l)}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";this.registry(s).size||Gt.call(o,s,u=>{this.forEachMatchingContext(s,u,At)});let f=new o.MutationObserver(u=>u.forEach(p=>{Array.isArray((p=Bt.call(o,p)).event)||At.call(o,a,p,i)}));f.observe(i,{childList:!0,subtree:e.subtree&&!0});let c={disconnect(){m.delete(a),f.disconnect()}},l=e.signalGenerator||e.lifecycleSignals&&this.createSignalGenerator(),a={context:i,spec:t,callback:r,params:e,signalGenerator:l,disconnectable:c},m=this.registry(s);if(m.set(a,!!a.params.deferred),e.staticSensitivity){let u=Vt.call(o,a);return this.disconnectables(e.signal,c,l,u)}return this.disconnectables(e.signal,c,l)}track(t,r,e={}){return e={subtree:!0,...e},this.observe(t,i=>{i.entrants.length&&r(!0,Array.isArray(t)?i.entrants:i.entrants[0]),i.exits.length&&r(!1,Array.isArray(t)?i.exits:i.exits[0])},e)}};function Vt(n){let t=this,{context:r,spec:e,callback:i,params:o,signalGenerator:s}=n,f=e.filter(p=>p.kind==="css"),c=p=>p.match(/\.([\w-]+)/g)?.length?["class"]:[],l=p=>p.match(/#([\w-]+)/g)?.length?["id"]:[],a=p=>[...p.matchAll(/\[([^\=\]]+)(\=[^\]]+)?\]/g)].map(_=>_[1]).concat(c(p)).concat(l(p));if(!(n.$attrs=Array.from(new Set(f.filter(p=>(p+"").includes("[")).reduce((p,_)=>p.concat(a(_+"")),[])))).length)return;let m=new Set,u=new Set;return m.push=p=>(u.delete(p),m.add(p)),u.push=p=>(m.delete(p),u.add(p)),n.$deliveryCache={entrants:m,exits:u},new F(r,t).observe(n.$attrs,p=>{let _=new Map,O=y=>(_.has(y)||_.set(y,{target:y,entrants:[],exits:[],type:"static",event:null}),_.get(y)),st=new WeakMap,d=y=>(st.has(y)||st.set(y,f.some(v=>y.matches(v+""))),st.get(y));for(let y of p)["entrants","exits"].forEach(v=>{o.generation&&v!==o.generation||n.$deliveryCache[v].has(y.target)||(v==="entrants"?!d(y.target):d(y.target))||(n.$deliveryCache[v].push(y.target),O(y.target)[v].push(y.target),O(y.target).event=y.event)});for(let[,y]of _){let v=s?.generate()||{};i(y,v,r)}},{subtree:o.subtree,timing:o.timing,eventDetails:o.eventDetails})}function At(n,t){let{context:r,spec:e,callback:i,params:o,signalGenerator:s,$deliveryCache:f}=n,c={...t,entrants:[],exits:[]};if(o.eventDetails||delete c.event,["entrants","exits"].forEach(a=>{if(!(o.generation&&a!==o.generation)&&(e.length?c[a]=ge.call(this,e,o.subtree==="cross-roots",t[a],t.event!=="parse"):c[a]=[...t[a]],!!f))for(let m of c[a])f[a].push(m)}),!c.entrants.length&&!c.exits.length)return;let l=s?.generate()||{};i(c,l,r)}function ge(n,t,r,e){r=Array.isArray(r)?r:[...r];let i=(o,s)=>{if(s.type==="selector"){let f=s.isXpathAttr?[]:o.filter(c=>s.kind==="xpath"?Ht(this,c,s+""):c.matches&&c.matches(s+""));if((e||s.isXpathAttr)&&(f=o.reduce((c,l)=>s.kind==="xpath"?[...c,...mt(this,l,s,e)]:l.querySelectorAll?[...c,...l.querySelectorAll(s+"")]:c,f)),f.length)return f}else if(o.includes(s.content)||e&&o.some(f=>et(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 Bt({target:n,addedNodes:t,removedNodes:r}){let e=this,i;return i=E(t).reduce((o,s)=>o||e.webqit.realdom.domInterceptionRecords?.get(s),null),i=E(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 Gt(n,t){let r=this,{webqit:e,document:i,Node:o,CharacterData:s,Element:f,HTMLElement:c,HTMLTemplateElement:l,DocumentFragment:a}=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=(d,y,v)=>{e.realdom.domInterceptionNoRecurse.set(d,y);let h=v();return e.realdom.domInterceptionNoRecurse.delete(d),h},p=(d,y)=>{d.entrants.concat(d.exits).forEach(h=>{clearTimeout(e.realdom.domInterceptionRecords.get(h)?.timeout),e.realdom.domInterceptionRecords.set(h,d.event);let I=setTimeout(()=>{e.realdom.domInterceptionRecords.delete(h)},0);Object.defineProperty(d.event,"timeout",{value:I,configurable:!0})}),e.realdom.domInterceptionHooks.get("intercept")?.forEach(h=>h(d));let v=y();return e.realdom.domInterceptionHooks.get("sync")?.forEach(h=>h(d)),v},_={ShadowRoot:["innerHTML","setHTMLUnsafe"],DocumentFragment:["replaceChildren","append","prepend"],Document:["replaceChildren","append","prepend"],HTMLElement:["outerText","innerText"],Element:["append","prepend","before","after","insertAdjacentElement","insertAdjacentHTML","remove","replaceChildren","replaceWith","setHTMLUnsafe","innerHTML","outerHTML"],CharacterData:["before","after","remove","replaceWith"],Node:["insertBefore","replaceChild","removeChild","appendChild","textContent","nodeValue"]},O={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(_).reduce((d,y)=>d.concat(y),[])).forEach(d=>{Object.keys(_).forEach(h=>{if(!_[h].includes(d))return;let I=Object.getOwnPropertyDescriptor(r[h].prototype,d);!I||(Object.defineProperty(r[h].prototype,d,"value"in I?{...I,value:y}:{...I,set:v}),O[h][d]=I)});function y(...h){let I=Object.keys(O).find(P=>this instanceof r[P]&&d in O[P]),z=O[I],L=()=>z[d].value.call(this,...h);if(e.realdom.domInterceptionNoRecurse.get(this)===d)return L();let k=[],x=[],N=this;["insertBefore"].includes(d)?x=[h[0]]:["insertAdjacentElement","insertAdjacentHTML"].includes(d)?(x=[h[1]],["beforebegin","afterend"].includes(h[0])&&(N=this.parentNode)):["setHTMLUnsafe","replaceChildren"].includes(d)?(k=[...this.childNodes],x=d==="replaceChildren"?[...h]:[h[0]]):["replaceWith","remove"].includes(d)?(k=[this],x=d==="replaceWith"?[...h]:[],N=this.parentNode):["replaceChild"].includes(d)?(k=[h[1]],x=[h[0]]):["removeChild"].includes(d)?k=[...h]:(x=[...h],["before","after"].includes(d)&&(N=this.parentNode));let ft=d;if(["insertAdjacentHTML","setHTMLUnsafe"].includes(d)){let P=this.nodeName;if(d==="insertAdjacentHTML"&&["beforebegin","afterend"].includes(h[0])){if(!this.parentNode)return z[d].value.call(this,...h);P=this.parentNode.nodeName}let R=i.createElement(P.includes("-")?"div":P);z.setHTMLUnsafe.value.call(R,x[0],d==="setHTMLUnsafe"?h[1]:{}),x=[...R.childNodes],d==="insertAdjacentHTML"?(ft="insertAdjacentElement",h[1]=new a,u(h[1],"append",()=>h[1].append(...R.childNodes))):(ft="replaceChildren",h=[...R.childNodes])}return N?p({target:N,entrants:x,exits:k,type:"interception",event:[this,d]},()=>z[ft].value.call(this,...h)):L()}function v(h){let I=Object.keys(O).find(V=>this instanceof r[V]&&d in O[V]),z=O[I],L=()=>z[d].set.call(this,h);if(this instanceof HTMLScriptElement||e.realdom.domInterceptionNoRecurse.get(this)===d)return L();let k=[],x=[],N=this;if(["outerHTML","outerText"].includes(d)?(k=[this],N=this.parentNode):this instanceof l?(N=this.content,k=[...this.content.childNodes]):k=[...this.childNodes],["outerHTML","innerHTML"].includes(d)){let V=this.nodeName;if(d==="outerHTML"){if(!this.parentNode)return L();V=this.parentNode.nodeName}let P=i.createElement(V.includes("-")?"div":V);if(u(P,d,()=>P[d]=h),x=this instanceof l?[...P.content.childNodes]:[...P.childNodes],this instanceof l&&this.hasAttribute("src")||this instanceof ShadowRoot){let R=B=>B.reduce((H,$)=>$ instanceof HTMLScriptElement?H.concat($):$ instanceof l?H.concat(R([$.content])):(H=H.concat(R([...$.querySelectorAll?.("template")||[]].map(Zt=>Zt.content))),H.concat(...$.querySelectorAll?.("script")||[])),[]);for(let B of R(x)){if(this instanceof ShadowRoot){B.setAttribute("data-handling","manual");continue}let H=i.createElement("script");[...B.attributes].forEach($=>H.setAttribute($.name,$.value)),H.textContent=B.textContent,u(B,"replaceWith",()=>B.replaceWith(H))}}d==="outerHTML"?(h=new a,u(h,"append",()=>h.append(...x)),L=()=>u(this,"replaceWith",()=>f.prototype.replaceWith.call(this,h))):this instanceof l?L=()=>u(this.content,"replaceChildren",()=>this.content.replaceChildren(...x)):L=()=>u(this,"replaceChildren",()=>f.prototype.replaceChildren.call(this,...x))}return p({target:N,entrants:x,exits:k,type:"interception",event:[this,d]},L)}}),m}function zt(){ye.call(this),be.call(this),_e.call(this)}function ye(){let n=this;n.CSS||(n.CSS={}),n.CSS.escape||(n.CSS.escape=t=>t.replace(/([\:@\~\$\&])/g,"\\$1"))}function be(){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 _e(){let n=this;n.Element.prototype.matches||(n.Element.prototype.matches=n.Element.prototype.matchesSelector||n.Element.prototype.mozMatchesSelector||n.Element.prototype.msMatchesSelector||n.Element.prototype.oMatchesSelector||n.Element.prototype.webkitMatchesSelector||function(t){for(var r=(this.document||this.ownerDocument).querySelectorAll(t),e=r.length;--e>=0&&r.item(e)!==this;);return e>-1})}function Xt(){let n=this;if(n.webqit||(n.webqit={}),n.webqit.realdom)return n.webqit.realdom;n.webqit.realdom={},zt.call(n),n.webqit.realdom.meta=(...r)=>we.call(n,...r),n.webqit.realdom.ready=(...r)=>Et.call(n,...r),n.webqit.realdom.realtime=(r,e="dom")=>{if(e==="dom")return new rt(r,n);if(e==="attr")return new F(r,n)};let t=new tt(n);return n.webqit.realdom.schedule=(r,...e)=>t[`on${r}`](...e),n.webqit.realdom.synthesizeWhile=(...r)=>t.synthesizeWhile(...r),n.webqit.realdom}function Et(...n){let t="interactive",r;Q(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=>Et.call(this,"interactive",o)),complete:new Promise(o=>Et.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 we(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 xt(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 pt(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 W=(n,...t)=>C(n,"oohtml",...t),M={};function Jt(n,t,r){let e=this,i=Xt.call(e);M.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(c=>{f==="api"&&typeof s[f][c]=="string"?s[f][c]=`${e.webqitConfig.prefix}${pt(s[f][c])}`:["attr","elements"].includes(f)&&s[f][c]?.startsWith("data-")===!1&&(s[f][c]=`${e.webqitConfig.prefix}-${s[f][c]}`)})})}return{config:e.webqit.oohtml.configs[o],realdom:i,window:e}}function St(n,t){return[...n].reduce(([r,e,i],o)=>!r&&e===0&&(Array.isArray(t)?t:[t]).includes(o)?[r,e,[""].concat(i)]:(!r&&["(","[","{"].includes(o)&&!i[0].endsWith("\\")&&e++,!r&&[")","]","}"].includes(o)&&!i[0].endsWith("\\")&&e--,['"',"'","`"].includes(o)&&!i[0].endsWith("\\")&&(r=r===o?null:r||o),i[0]+=o,[r,e,i]),[null,0,[""]])[2].reverse()}function Yt(){let{window:n}=M,{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"],c=i.pop()||f[0];if(!f.includes(c))throw new Error(`Invalid event type. Must be one of: ${f.join(",")}`);let{kind:l,detail:a,targetContext:m,live:u,signal:p,diff:_,...O}=s;super(c,{...O,bubbles:O.bubbles!==!1}),Object.defineProperty(this,"callback",{get:()=>o}),Object.defineProperty(this,"kind",{get:()=>l}),Object.defineProperty(this,"targetContext",{get:()=>m}),Object.defineProperty(this,"detail",{get:()=>a}),Object.defineProperty(this,"live",{get:()=>u}),Object.defineProperty(this,"signal",{get:()=>p}),Object.defineProperty(this,"diff",{get:()=>_}),Object.defineProperty(this,"options",{get:()=>O}),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 nt=class extends AbortController{constructor(t){super(),t(r=>{let{window:{webqit:{Observer:e}}}=M;e.defineProperty(this,"value",{value:r,configurable:!0,enumerable:!0})},this)}};var it=class extends Error{};var ot=class{static instance(t){return W(t).get("contexts::instance")||new this(t)}constructor(t){W(t).get("contexts::instance")?.dispose(),W(t).set("contexts::instance",this);let r={host:t,contexts:new Set};Object.defineProperty(this,"#",{get:()=>r})}[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[1]||r.detail===t[1]))}attach(t){if(!(t instanceof U))throw new TypeError("Context is not a valid DOMContext instance.");if(this.find(t.constructor.kind,t.detail))throw new it(`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 nt((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(Yt())(...t);this["#"].host.dispatchEvent(o)})}};var Ct=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}}}}=M;return t}get name(){return[M.window.Document,M.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 Ct)||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}=ot.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;r.meta.answered=!1,e.dispatchEvent(r)}),this}},U=Ct;lt(U,"kind");var T=class extends U{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}}}=M;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()}};lt(T,"kind","bindings");function qt(n={}){let{config:t,window:r}=Jt.call(this,"bindings-api",n,{attr:{bindingsreflection:"bindings"},api:{bind:"bind",bindings:"bindings"}});r.webqit.DOMBindingsContext=T,ve.call(r,t),Ee.call(r,t)}function Tt(n,t){let r=this,{webqit:{Observer:e,oohtml:{configs:{CONTEXT_API:i}}}}=r;if(!W(t).has("bindings")){let o=Object.create(null);W(t).set("bindings",o),e.observe(o,s=>{if(t instanceof r.Element){let f=ht(t.getAttribute(n.attr.bindingsreflection)||""),c=new Map(f);for(let l of s)l.detail?.publish!==!1&&(l.type==="delete"?f.delete(l.key):f.set(l.key,void 0));f.size&&f.size!==c.size?t.setAttribute(n.attr.bindingsreflection,`{ ${[...f.entries()].map(([l,a])=>a===void 0?l:`${l}: ${a}`).join(", ")} }`):f.size||t.toggleAttribute(n.attr.bindingsreflection,!1)}else{let f=t[i.api.contexts];for(let c of s)if(c.type==="delete"){let l=f.find(T.kind,c.key);l&&f.detach(l)}else f.find(T.kind,c.key)||f.attach(new T(c.key))}})}return W(t).get("bindings")}function ve(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 Ae.call(t,n,this,o,s)}}),Object.defineProperty(e,n.api.bindings,{get:function(){return r.proxy(Tt.call(t,n,this))}})})}function Ae(n,t,r,{merge:e,diff:i,publish:o,namespace:s}={}){let f=this,{webqit:{Observer:c}}=f,l=Tt.call(this,n,t),a={diff:i,namespace:s,detail:{publish:o}},m=e?[]:Object.keys(l).filter(u=>!(u in r));return c.batch(l,()=>(m.length&&c.deleteProperties(l,m,a),c.set(l,r,a)),a)}function Ee(n){let t=this,{webqit:{realdom:r,Observer:e,oohtml:{configs:i}}}=t,o=(f,c)=>{let l=f[i.CONTEXT_API.api.contexts];l.find(T.kind,c)||l.attach(new T(c))},s=(f,c)=>{let l,a=f[i.CONTEXT_API.api.contexts];for(;l=a.find(T.kind,c);)a.detach(l)};r.realtime(t.document).query(`[${t.CSS.escape(n.attr.bindingsreflection)}]`,f=>{f.exits.forEach(c=>s(c)),f.entrants.forEach(c=>{let l=ht(c.getAttribute(n.attr.bindingsreflection)||""),a=[...l.entries()].filter(([m,u])=>u!==void 0);a.length&&c[n.api.bind](Object.fromEntries(a),{merge:!0,publish:!1});for(let[m]of l)o(c,m)})},{id:"bindings:dom",live:!0,subtree:"cross-roots",timing:"sync",eventDetails:!0}),r.realtime(t.document,"attr").observe(n.attr.bindingsreflection,f=>{let c=Tt.call(t,n,f.target),l=ht(f.value||""),a=ht(f.oldValue||"");for(let m of new Set([...l.keys(),...a.keys()]))a.has(m)?l.has(m)?l.get(m)!==a.get(m)&&e.set(c,m,l.get(m),{detail:{publish:!1}}):(a.get(m)!==void 0&&e.deleteProperty(c,m,{detail:{publish:!1}}),s(f.target,m)):(l.get(m)!==void 0&&e.set(c,m,l.get(m),{detail:{publish:!1}}),o(f.target,m))},{id:"bindings:attr",subtree:"cross-roots",timing:"sync",newValue:!0,oldValue:!0})}var ht=n=>(n=n.trim(),new Map(St(n.slice(1,-1),",").filter(t=>t.trim()).map(t=>St(t,":").map(r=>r.trim()))));qt.call(window);
|
|
2
2
|
//# sourceMappingURL=bindings-api.js.map
|