jj 2.7.2 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bundle.cjs +24 -17
- package/lib/bundle.cjs.map +1 -1
- package/lib/bundle.d.cts +19 -18
- package/lib/bundle.d.ts +19 -18
- package/lib/bundle.global.js +24 -17
- package/lib/bundle.global.js.map +1 -1
- package/lib/bundle.js +24 -17
- package/lib/bundle.js.map +1 -1
- package/lib/bundle.min.cjs +1 -1
- package/lib/bundle.min.cjs.map +1 -1
- package/lib/bundle.min.d.cts +19 -18
- package/lib/bundle.min.d.ts +19 -18
- package/lib/bundle.min.global.js +1 -1
- package/lib/bundle.min.global.js.map +1 -1
- package/lib/bundle.min.js +1 -1
- package/lib/bundle.min.js.map +1 -1
- package/package.json +12 -6
package/lib/bundle.min.d.cts
CHANGED
|
@@ -217,7 +217,7 @@ declare class JJET<T extends EventTarget = EventTarget> {
|
|
|
217
217
|
* @param args - Arguments to pass to the function.
|
|
218
218
|
* @returns The return value of the function.
|
|
219
219
|
*/
|
|
220
|
-
run<R, Args extends
|
|
220
|
+
run<R, Args extends unknown[]>(fn: (this: this, ...args: Args) => R, ...args: Args): R;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
/**
|
|
@@ -249,15 +249,16 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
249
249
|
* This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
|
|
250
250
|
*
|
|
251
251
|
* @param x an unknown value
|
|
252
|
-
* @returns true if `x` is a string, Node (or its
|
|
252
|
+
* @returns true if `x` is a string, Node (or its descendent), JJN (or its descendent)
|
|
253
253
|
*/
|
|
254
|
-
static
|
|
254
|
+
static isWrappable(x: unknown): x is Wrappable;
|
|
255
255
|
/**
|
|
256
256
|
* Wraps a native DOM node or string into the most specific JJ wrapper available.
|
|
257
257
|
*
|
|
258
258
|
* @remarks
|
|
259
259
|
* This function acts as a factory, inspecting the input type and returning the appropriate
|
|
260
260
|
* subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
|
|
261
|
+
* JJN.ts overrides this method to a richer version that handles all subclasses of JJN.
|
|
261
262
|
*
|
|
262
263
|
* @example
|
|
263
264
|
* ```ts
|
|
@@ -342,7 +343,7 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
342
343
|
* @returns This instance for chaining.
|
|
343
344
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode | document.createTextNode}
|
|
344
345
|
*/
|
|
345
|
-
addText(
|
|
346
|
+
addText(...textArr: unknown[]): this;
|
|
346
347
|
}
|
|
347
348
|
|
|
348
349
|
declare abstract class JJNx<T extends Element | Document | DocumentFragment> extends JJN<T> {
|
|
@@ -658,8 +659,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
|
|
|
658
659
|
* @throws {TypeError} If arguments are invalid types.
|
|
659
660
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute | Element.setAttribute}
|
|
660
661
|
*/
|
|
661
|
-
setAttr(name: string, value:
|
|
662
|
-
setAttr(obj: Record<string,
|
|
662
|
+
setAttr(name: string, value: unknown): this;
|
|
663
|
+
setAttr(obj: Record<string, unknown>): this;
|
|
663
664
|
/**
|
|
664
665
|
* Removes one or more attributes from the Element.
|
|
665
666
|
*
|
|
@@ -712,8 +713,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
|
|
|
712
713
|
*
|
|
713
714
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes | ARIA Attributes}
|
|
714
715
|
*/
|
|
715
|
-
setAria(name: string, value:
|
|
716
|
-
setAria(obj: Record<string,
|
|
716
|
+
setAria(name: string, value: unknown): this;
|
|
717
|
+
setAria(obj: Record<string, unknown>): this;
|
|
717
718
|
/**
|
|
718
719
|
* Removes one or more ARIA attributes from the Element.
|
|
719
720
|
*
|
|
@@ -955,14 +956,14 @@ declare abstract class JJEx<T extends HTMLElement | SVGElement> extends JJE<T> {
|
|
|
955
956
|
* ```ts
|
|
956
957
|
* el.setData('myKey', 'myValue') // Single
|
|
957
958
|
* el.setData({ myKey: 'myValue', otherKey: 'otherValue' }) // Multiple
|
|
958
|
-
* el.setData('count', 42) // Numbers are automatically converted
|
|
959
|
+
* el.setData('count', 42) // Numbers are automatically converted to strings
|
|
959
960
|
* ```
|
|
960
961
|
*
|
|
961
962
|
* @throws {TypeError} If arguments are invalid types.
|
|
962
963
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
|
|
963
964
|
*/
|
|
964
|
-
setData(name: string, value
|
|
965
|
-
setData(obj: Record<string,
|
|
965
|
+
setData(name: string, value?: string): this;
|
|
966
|
+
setData(obj: Record<string, string | undefined>): this;
|
|
966
967
|
/**
|
|
967
968
|
* Removes one or more data attributes from the HTMLElement.
|
|
968
969
|
*
|
|
@@ -1049,7 +1050,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
|
|
|
1049
1050
|
* @throws {Error} If the HTMLElement does not have a value property.
|
|
1050
1051
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
|
|
1051
1052
|
*/
|
|
1052
|
-
setValue(value:
|
|
1053
|
+
setValue(value: unknown): this;
|
|
1053
1054
|
/**
|
|
1054
1055
|
* Focuses the HTMLElement.
|
|
1055
1056
|
*
|
|
@@ -1086,7 +1087,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
|
|
|
1086
1087
|
* @returns This instance for chaining.
|
|
1087
1088
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
|
|
1088
1089
|
*/
|
|
1089
|
-
setText(text?:
|
|
1090
|
+
setText(text?: unknown): this;
|
|
1090
1091
|
}
|
|
1091
1092
|
|
|
1092
1093
|
/**
|
|
@@ -1229,7 +1230,7 @@ declare class JJSE<T extends SVGElement = SVGElement> extends JJEx<T> {
|
|
|
1229
1230
|
* @returns This instance for chaining.
|
|
1230
1231
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1231
1232
|
*/
|
|
1232
|
-
setText(text?:
|
|
1233
|
+
setText(text?: unknown): this;
|
|
1233
1234
|
/**
|
|
1234
1235
|
* Sets the fill attribute.
|
|
1235
1236
|
*
|
|
@@ -1367,7 +1368,7 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
|
|
|
1367
1368
|
* @returns This instance for chaining.
|
|
1368
1369
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1369
1370
|
*/
|
|
1370
|
-
setText(text?:
|
|
1371
|
+
setText(text?: unknown): this;
|
|
1371
1372
|
/**
|
|
1372
1373
|
* Appends text to the existing content.
|
|
1373
1374
|
*
|
|
@@ -1378,11 +1379,11 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
|
|
|
1378
1379
|
* console.log(text.getText()) // 'hello world'
|
|
1379
1380
|
* ```
|
|
1380
1381
|
*
|
|
1381
|
-
* @param
|
|
1382
|
+
* @param textArr - The string to add to the existing contents. If null or undefined, nothing is added.
|
|
1382
1383
|
* @returns This instance for chaining.
|
|
1383
1384
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1384
1385
|
*/
|
|
1385
|
-
addText(
|
|
1386
|
+
addText(...textArr: unknown[]): this;
|
|
1386
1387
|
/**
|
|
1387
1388
|
* Clears the text content of the Text node.
|
|
1388
1389
|
*
|
|
@@ -1659,7 +1660,7 @@ declare function fetchStyle(url: URL | string): Promise<CSSStyleSheet>;
|
|
|
1659
1660
|
* @returns `true` if it tried to set the attribute; otherwise `false`.
|
|
1660
1661
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes | Responding to attribute changes}
|
|
1661
1662
|
*/
|
|
1662
|
-
declare function attr2prop(instance: HTMLElement, name: string, oldValue:
|
|
1663
|
+
declare function attr2prop(instance: HTMLElement, name: string, oldValue: unknown, newValue: unknown): boolean;
|
|
1663
1664
|
/**
|
|
1664
1665
|
* Registers the custom element with the browser and waits till it is defined.
|
|
1665
1666
|
*
|
package/lib/bundle.min.d.ts
CHANGED
|
@@ -217,7 +217,7 @@ declare class JJET<T extends EventTarget = EventTarget> {
|
|
|
217
217
|
* @param args - Arguments to pass to the function.
|
|
218
218
|
* @returns The return value of the function.
|
|
219
219
|
*/
|
|
220
|
-
run<R, Args extends
|
|
220
|
+
run<R, Args extends unknown[]>(fn: (this: this, ...args: Args) => R, ...args: Args): R;
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
/**
|
|
@@ -249,15 +249,16 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
249
249
|
* This is useful for filtering the array that is passed to `append()`, `prepend()` or `setChildren()`
|
|
250
250
|
*
|
|
251
251
|
* @param x an unknown value
|
|
252
|
-
* @returns true if `x` is a string, Node (or its
|
|
252
|
+
* @returns true if `x` is a string, Node (or its descendent), JJN (or its descendent)
|
|
253
253
|
*/
|
|
254
|
-
static
|
|
254
|
+
static isWrappable(x: unknown): x is Wrappable;
|
|
255
255
|
/**
|
|
256
256
|
* Wraps a native DOM node or string into the most specific JJ wrapper available.
|
|
257
257
|
*
|
|
258
258
|
* @remarks
|
|
259
259
|
* This function acts as a factory, inspecting the input type and returning the appropriate
|
|
260
260
|
* subclass of `JJN` (e.g., `JJHE` for `HTMLElement`, `JJT` for `Text`).
|
|
261
|
+
* JJN.ts overrides this method to a richer version that handles all subclasses of JJN.
|
|
261
262
|
*
|
|
262
263
|
* @example
|
|
263
264
|
* ```ts
|
|
@@ -342,7 +343,7 @@ declare class JJN<T extends Node = Node> extends JJET<T> {
|
|
|
342
343
|
* @returns This instance for chaining.
|
|
343
344
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/createTextNode | document.createTextNode}
|
|
344
345
|
*/
|
|
345
|
-
addText(
|
|
346
|
+
addText(...textArr: unknown[]): this;
|
|
346
347
|
}
|
|
347
348
|
|
|
348
349
|
declare abstract class JJNx<T extends Element | Document | DocumentFragment> extends JJN<T> {
|
|
@@ -658,8 +659,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
|
|
|
658
659
|
* @throws {TypeError} If arguments are invalid types.
|
|
659
660
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute | Element.setAttribute}
|
|
660
661
|
*/
|
|
661
|
-
setAttr(name: string, value:
|
|
662
|
-
setAttr(obj: Record<string,
|
|
662
|
+
setAttr(name: string, value: unknown): this;
|
|
663
|
+
setAttr(obj: Record<string, unknown>): this;
|
|
663
664
|
/**
|
|
664
665
|
* Removes one or more attributes from the Element.
|
|
665
666
|
*
|
|
@@ -712,8 +713,8 @@ declare class JJE<T extends Element = Element> extends JJNx<T> {
|
|
|
712
713
|
*
|
|
713
714
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes | ARIA Attributes}
|
|
714
715
|
*/
|
|
715
|
-
setAria(name: string, value:
|
|
716
|
-
setAria(obj: Record<string,
|
|
716
|
+
setAria(name: string, value: unknown): this;
|
|
717
|
+
setAria(obj: Record<string, unknown>): this;
|
|
717
718
|
/**
|
|
718
719
|
* Removes one or more ARIA attributes from the Element.
|
|
719
720
|
*
|
|
@@ -955,14 +956,14 @@ declare abstract class JJEx<T extends HTMLElement | SVGElement> extends JJE<T> {
|
|
|
955
956
|
* ```ts
|
|
956
957
|
* el.setData('myKey', 'myValue') // Single
|
|
957
958
|
* el.setData({ myKey: 'myValue', otherKey: 'otherValue' }) // Multiple
|
|
958
|
-
* el.setData('count', 42) // Numbers are automatically converted
|
|
959
|
+
* el.setData('count', 42) // Numbers are automatically converted to strings
|
|
959
960
|
* ```
|
|
960
961
|
*
|
|
961
962
|
* @throws {TypeError} If arguments are invalid types.
|
|
962
963
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset | HTMLElement.dataset}
|
|
963
964
|
*/
|
|
964
|
-
setData(name: string, value
|
|
965
|
-
setData(obj: Record<string,
|
|
965
|
+
setData(name: string, value?: string): this;
|
|
966
|
+
setData(obj: Record<string, string | undefined>): this;
|
|
966
967
|
/**
|
|
967
968
|
* Removes one or more data attributes from the HTMLElement.
|
|
968
969
|
*
|
|
@@ -1049,7 +1050,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
|
|
|
1049
1050
|
* @throws {Error} If the HTMLElement does not have a value property.
|
|
1050
1051
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/value | HTMLInputElement.value}
|
|
1051
1052
|
*/
|
|
1052
|
-
setValue(value:
|
|
1053
|
+
setValue(value: unknown): this;
|
|
1053
1054
|
/**
|
|
1054
1055
|
* Focuses the HTMLElement.
|
|
1055
1056
|
*
|
|
@@ -1086,7 +1087,7 @@ declare class JJHE<T extends HTMLElement = HTMLElement> extends JJEx<T> {
|
|
|
1086
1087
|
* @returns This instance for chaining.
|
|
1087
1088
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText | HTMLElement.innerText}
|
|
1088
1089
|
*/
|
|
1089
|
-
setText(text?:
|
|
1090
|
+
setText(text?: unknown): this;
|
|
1090
1091
|
}
|
|
1091
1092
|
|
|
1092
1093
|
/**
|
|
@@ -1229,7 +1230,7 @@ declare class JJSE<T extends SVGElement = SVGElement> extends JJEx<T> {
|
|
|
1229
1230
|
* @returns This instance for chaining.
|
|
1230
1231
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1231
1232
|
*/
|
|
1232
|
-
setText(text?:
|
|
1233
|
+
setText(text?: unknown): this;
|
|
1233
1234
|
/**
|
|
1234
1235
|
* Sets the fill attribute.
|
|
1235
1236
|
*
|
|
@@ -1367,7 +1368,7 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
|
|
|
1367
1368
|
* @returns This instance for chaining.
|
|
1368
1369
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1369
1370
|
*/
|
|
1370
|
-
setText(text?:
|
|
1371
|
+
setText(text?: unknown): this;
|
|
1371
1372
|
/**
|
|
1372
1373
|
* Appends text to the existing content.
|
|
1373
1374
|
*
|
|
@@ -1378,11 +1379,11 @@ declare class JJT<T extends Text = Text> extends JJN<Text> {
|
|
|
1378
1379
|
* console.log(text.getText()) // 'hello world'
|
|
1379
1380
|
* ```
|
|
1380
1381
|
*
|
|
1381
|
-
* @param
|
|
1382
|
+
* @param textArr - The string to add to the existing contents. If null or undefined, nothing is added.
|
|
1382
1383
|
* @returns This instance for chaining.
|
|
1383
1384
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent | Node.textContent}
|
|
1384
1385
|
*/
|
|
1385
|
-
addText(
|
|
1386
|
+
addText(...textArr: unknown[]): this;
|
|
1386
1387
|
/**
|
|
1387
1388
|
* Clears the text content of the Text node.
|
|
1388
1389
|
*
|
|
@@ -1659,7 +1660,7 @@ declare function fetchStyle(url: URL | string): Promise<CSSStyleSheet>;
|
|
|
1659
1660
|
* @returns `true` if it tried to set the attribute; otherwise `false`.
|
|
1660
1661
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes | Responding to attribute changes}
|
|
1661
1662
|
*/
|
|
1662
|
-
declare function attr2prop(instance: HTMLElement, name: string, oldValue:
|
|
1663
|
+
declare function attr2prop(instance: HTMLElement, name: string, oldValue: unknown, newValue: unknown): boolean;
|
|
1663
1664
|
/**
|
|
1664
1665
|
* Registers the custom element with the browser and waits till it is defined.
|
|
1665
1666
|
*
|
package/lib/bundle.min.global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(()=>{var V=e=>{throw TypeError(e)};var P=(e,t,r)=>t.has(e)||V("Cannot "+r);var c=(e,t,r)=>(P(e,t,"read from private field"),r?r.call(e):t.get(e)),h=(e,t,r)=>t.has(e)?V("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),J=(e,t,r,o)=>(P(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r),G=(e,t,r)=>(P(e,t,"access private method"),r);function M(e){return e!==void 0}function g(e){return typeof e=="function"}var{isNaN:K,isFinite:at,isInteger:ut}=Number;function H(e){return typeof e=="number"&&!K(e)}function F(e,t,r){if(!H(e))throw new TypeError(`inRange(): "x" must be a number. Got ${e} (${typeof e})`);if(M(t)){if(!H(t))throw new TypeError(`inRange(): "min" must be a number. Got ${t} (${typeof t})`);if(M(r)){if(!H(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return t>r?r<=e&&e<=t:t<=e&&e<=r}return e>=t}else if(M(r)){if(!H(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return e<=r}throw new TypeError(`inRange(): expected at least min or max to be defined. Got min=${t} and max=${r}`)}var{isArray:Z}=Array;function N(e,t=0,r){return Z(e)&&F(e.length,t,r)}var{hasOwnProperty:lt}=Object;function f(e){return!!e&&typeof e=="object"}function s(e,t){if(!g(t))throw new TypeError(`Expected a constructor function. Got ${t} (${typeof t})`);return e instanceof t}function w(e,...t){if(!f(e))return!1;for(let r of t)if(!(r in e))return!1;return!0}function i(e){return typeof e=="string"}var{hasOwnProperty:Jt}=Object,{isArray:At}=Array;function y(e,t,r){return`Expected '${e}' to be ${t}. Got ${r} (${typeof r})`}function n(e,t,r){return new TypeError(y(e,t,r))}function I(e){if(!i(e))throw n("path","a string",e);let t=e.lastIndexOf(".");if(t===-1)return"";let r=e.slice(t+1);return r.indexOf("/")!==-1?"":r.toLowerCase().trim()}function Pt(){return new Promise(e=>requestAnimationFrame(e))}function Gt(e=0){return new Promise(t=>setTimeout(t,e))}async function C(e){return await new CSSStyleSheet().replace(e)}function Ut(e){if(!i(e))throw n("str","a string",e);if(/[^a-zA-Z0-9_]/.test(e))throw new SyntaxError(y("str","alphanumeric characters and underscores",e));return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function Vt(e){if(!i(e))throw n("str","a string",e);return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")||(e.length>0?e.charAt(0).toUpperCase()+e.slice(1):"")}function z(e){if(!i(e))throw n("str","a string",e);return e.replace(/^-+|-+$/g,"").replace(/-+([a-z])/g,(t,r)=>r.toUpperCase())}var A,$,L,O,j=class j{constructor(t){h(this,L);h(this,A);h(this,$,new WeakMap);if(!s(t,EventTarget))throw new TypeError(`JJET expects an EventTarget instance. Got ${t} (${typeof t}). `);J(this,A,t)}static from(t){return new j(t)}get ref(){return c(this,A)}on(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.addEventListener(t,a,o),this}off(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.removeEventListener(t,a,o),this}trigger(t){return this.ref.dispatchEvent(t),this}run(t,...r){return t.call(this,...r)}};A=new WeakMap,$=new WeakMap,L=new WeakSet,O=function(t){if(t===null)return null;let r=c(this,$).get(t);return r||(typeof t=="function"?r=t.bind(this):r={handleEvent:t.handleEvent.bind(this)},c(this,$).set(t,r)),r};var W=j;var u=class e extends W{static from(t){return new e(t)}static isWrapable(t){return i(t)||s(t,Node)||s(t,e)}static wrap(t){throw new ReferenceError("The mixin is supposed to override this method.")}static unwrap(t){if(i(t))return document.createTextNode(t);if(!f(t))throw new TypeError(`JJN.unwrap() expects a string, DOM Node, or JJ wrapper. Got ${t} (${typeof t}). `);if(s(t,Node))return t;if(s(t,e))return t.ref;throw new TypeError(`Could not unwrap ${t} (${typeof t}). Expected a string, Node, or JJ wrapper. Make sure you're passing a valid DOM element or JJ wrapper.`)}static wrapAll(t){return Array.from(t,e.wrap)}static unwrapAll(t){return Array.from(t,e.unwrap)}constructor(t){if(!s(t,Node))throw new TypeError(`JJN expects a Node instance. Got ${t} (${typeof t}). Use JJN.from(node) with a DOM Node, or check that you're passing a valid DOM element.`);super(t)}clone(t){return e.wrap(this.ref.cloneNode(t))}addText(t){return t&&this.ref.appendChild(document.createTextNode(t)),this}};var m=class extends u{find(t,r=!1){let o=this.ref.querySelector(t);if(o)return u.wrap(o);if(r)throw new TypeError(`No element matched query "${t}"`);return null}findAll(t){return u.wrapAll(this.ref.querySelectorAll(t))}addChild(...t){let r=u.unwrapAll(t.filter(u.isWrapable));return this.ref.append(...r),this}preChild(...t){let r=u.unwrapAll(t.filter(u.isWrapable));return this.ref.prepend(...r),this}addChildMap(t,r){return this.addChild(...t.map(r))}preChildMap(t,r){return this.preChild(...t.map(r))}setChildren(...t){let r=u.unwrapAll(t.filter(u.isWrapable));return this.ref.replaceChildren(...r),this}empty(){return this.setChildren(),this}};var l=class e extends m{static from(t){return new e(t)}static create(){return new e(document.createDocumentFragment())}constructor(t){if(!s(t,DocumentFragment))throw n("ref","a DocumentFragment",t);super(t)}};var E=class e extends l{static from(t){return new e(t)}constructor(t){if(!s(t,ShadowRoot))throw new TypeError(`JJSR expects a ShadowRoot instance. Got ${t} (${typeof t}). Access a shadow root using element.shadowRoot after calling element.attachShadow().`);super(t)}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}addStyleSheets(...t){return this.ref.adoptedStyleSheets.push(...t),this}};var T=class e extends m{static from(t){return new e(t)}constructor(t){if(!s(t,Element))throw new TypeError(`JJE expects an Element instance. Got ${t} (${typeof t}). Use JJE.from(element) with a DOM Element, or use the specific wrapper (JJHE for HTMLElement, JJSE for SVGElement).`);super(t)}getAttr(t){if(!i(t))throw n("name","a string",t);return this.ref.getAttribute(t)}hasAttr(t){if(!i(t))throw n("name","a string",t);return this.ref.hasAttribute(t)}setAttr(t,r){if(typeof t=="string")this.ref.setAttribute(t,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(o,a);else throw n("nameOrObj","a string or object",t);return this}rmAttr(...t){for(let r of t){if(!i(r))throw n("name","a string",r);this.ref.removeAttribute(r)}return this}getAria(t){if(!i(t))throw n("name","a string",t);return this.ref.getAttribute(`aria-${t}`)}hasAria(t){if(!i(t))throw n("name","a string",t);return this.ref.hasAttribute(`aria-${t}`)}setAria(t,r){if(i(t))this.ref.setAttribute(`aria-${t}`,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(`aria-${o}`,a);else throw n("nameOrObj","a string or object",t);return this}rmAria(...t){for(let r of t){if(!i(r))throw n("name","a string",r);this.ref.removeAttribute(`aria-${r}`)}return this}getClass(){return this.getAttr("class")}setClass(t){if(typeof t=="string")return this.setAttr("class",t);for(let[r,o]of Object.entries(t))o?this.ref.classList.add(r):this.ref.classList.remove(r);return this}addClass(...t){for(let r of t)if(!i(r))throw n("className","a string",r);return this.ref.classList.add(...t),this}rmClass(...t){for(let r of t)if(!i(r))throw n("className","a string",r);return this.ref.classList.remove(...t),this}hasClass(t){if(!i(t))throw n("className","a string",t);return this.ref.classList.contains(t)}toggleClass(t){if(!i(t))throw n("className","a string",t);return this.ref.classList.toggle(t),this}replaceClass(t,r){if(!i(t))throw n("oldClassName","a string",t);if(!i(r))throw n("newClassName","a string",r);return this.ref.classList.replace(t,r),this}closest(t){if(!i(t))throw n("selector","a string",t);let r=this.ref.closest(t);return r?u.wrap(r):null}hide(){return this.setAttr("hidden","").setAttr("aria-hidden","true")}show(){return this.rmAttr("hidden","aria-hidden")}disable(){return this.setAttr("disabled","").setAttr("aria-disabled","true")}enable(){return this.rmAttr("disabled","aria-disabled")}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}initShadow(t="open",r){let o=this.ref.shadowRoot??this.ref.attachShadow({mode:t});if(f(r)){let{template:a,styles:d}=r;a&&(i(a)?o.innerHTML=a:o.appendChild(a)),N(d)&&d.length&&o.adoptedStyleSheets.push(...d)}return this}get shadow(){return this.ref.shadowRoot?new E(this.ref.shadowRoot):null}};var S=class extends T{getData(t){if(!i(t))throw n("name","a string",t);return this.ref.dataset[t]}hasData(t){if(!i(t))throw n("name","a string",t);return w(this.ref.dataset,t)}setData(t,r){if(typeof t=="string")this.ref.dataset[t]=r;else if(f(t))for(let[o,a]of Object.entries(t))this.ref.dataset[o]=a;else throw n("nameOrObj","a string or object",t);return this}rmData(...t){for(let r of t){if(!i(r))throw n("name","a string",r);delete this.ref.dataset[r]}return this}};var p=class e extends S{static from(t){return new e(t)}static create(t,r){if(!i(t))throw n("tagName","a string like 'div' or 'button'",t);return new e(document.createElement(t,r))}constructor(t){if(!s(t,HTMLElement))throw n("ref","an HTMLElement",t);super(t)}getValue(){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value}setValue(t){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value=t,this}focus(){return this.ref.focus(),this}click(){return this.ref.click(),this}getText(){return this.ref.innerText}setText(t){return this.ref.innerText=t??"",this}};var D=class e extends u{static from(t){return new e(t)}static fromStr(t){return new e(document.createTextNode(t))}constructor(t){if(!s(t,Text))throw new TypeError(`JJT expects a Text node. Got ${t} (${typeof t}). Create a Text node with JJT.fromStr() or document.createTextNode('text').`);super(t)}getText(){return this.ref.textContent}setText(t){return this.ref.textContent=t??null,this}addText(t){return t!=null&&(this.ref.textContent+=t),this}empty(){return this.setText("")}};var x=class e extends m{static from(t){return new e(t)}constructor(t){if(!s(t,Document))throw new TypeError(`JJD expects a Document instance. Got ${t} (${typeof t}). `);super(t)}get head(){return p.from(this.ref.head)}get body(){return p.from(this.ref.body)}};var Q="http://www.w3.org/2000/svg",k=class e extends S{static from(t){return new e(t)}static create(t,r){if(!i(t))throw n("tagName",'a string like "circle" or "path"',t);let o=document.createElementNS(Q,t,r);return new e(o)}constructor(t){if(!s(t,SVGElement))throw n("ref","an SVGElement",t);super(t)}getText(){return this.ref.textContent??""}setText(t){return this.ref.textContent=t??"",this}setFill(t){return this.setAttr("fill",t)}setStroke(t){return this.setAttr("stroke",t)}setStrokeWidth(t){return this.setAttr("stroke-width",String(t))}setViewBox(t,r,o,a){if(typeof t=="number"&&r!==void 0&&o!==void 0&&a!==void 0)return this.setAttr("viewBox",`${t} ${r} ${o} ${a}`);let d=t;return this.setAttr("viewBox",Array.isArray(d)?d.join(" "):d)}setWidth(t){return this.setAttr("width",String(t))}setHeight(t){return this.setAttr("height",String(t))}setD(t){return this.setAttr("d",Array.isArray(t)?t.join(" "):t)}setTransform(t){return this.setAttr("transform",t)}};u.wrap=function(t){if(i(t))return D.fromStr(t);if(!f(t))throw n("raw","an object",t);if(s(t,u))return t;if(s(t,HTMLElement))return p.from(t);if(s(t,SVGElement))return k.from(t);if(s(t,Element))return T.from(t);if(s(t,ShadowRoot))return E.from(t);if(s(t,DocumentFragment))return l.from(t);if(s(t,Document))return x.from(t);if(s(t,Text))return D.from(t);if(s(t,Node))return u.from(t);throw n("raw","a Node",t)};function ir(e,t,...r){let o=p.create(e).addChild(...r);return t&&o.setAttr(t),o}function X(e){switch(I(e)){case"html":case"htm":case"md":return"fetch";case"css":return"style";case"js":case"mjs":case"cjs":return"script";default:throw new Error(`No 'as' attribute was specified and we failed to guess it from the URL: ${e}`)}}function Y(e,t,r){if(!i(e)){if(!s(e,URL))throw n("href","a string or URL",e);e=e.toString()}if(!["prefetch","preload"].includes(t))throw new RangeError(y("rel","'prefetch' or 'preload'",t));if(!r&&(r=X(e),!r))throw new Error(`Could not guess 'as' attribute from URL: ${e}`);if(!["fetch","style","script"].includes(r))throw new RangeError(y("as","'fetch', 'style', or 'script'",r));return p.create("link").setAttr({href:e,rel:t,as:r})}function sr(...e){let t=Y(...e);return document.head.append(t.ref),t}async function B(e,t="text/*"){if(!i(t))throw n("mime","a string",t);let r=await fetch(e,{headers:{Accept:t}});if(!r.ok)throw new Error(`GET ${e} failed: ${r.status} ${r.statusText}`);return r.text()}async function or(e){return await B(e,"text/html")}async function _(e){return await B(e,"text/css")}async function ar(e){return await C(await _(e))}function hr(e,t,r,o){if(!s(e,HTMLElement))throw n("instance","an HTMLElement",e);if(r!==o){let a=z(t);if(w(e,a))return e[a]=o,!0}return!1}async function mr(e,t,r){if(!i(e))throw n("name","a string",e);if(!g(t))throw n("constructor","a function",t);customElements.get(e)||(customElements.define(e,t,r),await customElements.whenDefined(e))}async function tt(e){if(e!==void 0){if(g(e)&&(e=await e()),e=await e,i(e))return e;if(s(e,l))return e.ref.cloneNode(!0);if(s(e,DocumentFragment))return e.cloneNode(!0);if(s(e,p))return e.ref instanceof HTMLTemplateElement?e.ref.content.cloneNode(!0):e.ref.outerHTML;if(s(e,HTMLElement))return e instanceof HTMLTemplateElement?e.content.cloneNode(!0):e.outerHTML;throw n("template","a string, JJHE, JJDF, HTMLElement, or DocumentFragment",e)}}async function et(e){if(g(e)&&(e=await e()),e=await e,s(e,CSSStyleSheet))return e;if(i(e))return await C(e);throw n("style","a CSS string or CSSStyleSheet",e)}function rt(e){return N(e)?e.map(et):[]}async function nt(e,t){let[r,...o]=await Promise.all([tt(e),...rt(t)]);return{template:r,styles:o}}var R,v,b,U=class U{constructor(){h(this,R);h(this,v,[]);h(this,b)}static create(){return new U}setTemplate(t){return J(this,R,t),this}addStyles(...t){return c(this,v).push(...t),this}async getResolved(){return c(this,b)||J(this,b,nt(c(this,R),c(this,v))),await c(this,b)}};R=new WeakMap,v=new WeakMap,b=new WeakMap;var q=U;var Ar=x.from(document);})();
|
|
1
|
+
"use strict";(()=>{var V=e=>{throw TypeError(e)};var P=(e,t,r)=>t.has(e)||V("Cannot "+r);var c=(e,t,r)=>(P(e,t,"read from private field"),r?r.call(e):t.get(e)),h=(e,t,r)=>t.has(e)?V("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),J=(e,t,r,o)=>(P(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r),G=(e,t,r)=>(P(e,t,"access private method"),r);function v(e){return e!==void 0}function g(e){return typeof e=="function"}var{isNaN:K,isFinite:at,isInteger:ut}=Number;function M(e){return typeof e=="number"&&!K(e)}function F(e,t,r){if(!M(e))throw new TypeError(`inRange(): "x" must be a number. Got ${e} (${typeof e})`);if(v(t)){if(!M(t))throw new TypeError(`inRange(): "min" must be a number. Got ${t} (${typeof t})`);if(v(r)){if(!M(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return t>r?r<=e&&e<=t:t<=e&&e<=r}return e>=t}else if(v(r)){if(!M(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return e<=r}throw new TypeError(`inRange(): expected at least min or max to be defined. Got min=${t} and max=${r}`)}var{isArray:Z}=Array;function H(e,t=0,r){return Z(e)&&F(e.length,t,r)}var{hasOwnProperty:lt}=Object;function f(e){return!!e&&typeof e=="object"}function i(e,t){if(!g(t))throw new TypeError(`Expected a constructor function. Got ${t} (${typeof t})`);return e instanceof t}function w(e,...t){if(!f(e))return!1;for(let r of t)if(!(r in e))return!1;return!0}function s(e){return typeof e=="string"}var{hasOwnProperty:Jt}=Object,{isArray:At}=Array;function E(e,t,r){return`Expected '${e}' to be ${t}. Got ${r} (${typeof r})`}function n(e,t,r){return new TypeError(E(e,t,r))}function I(e){if(!s(e))throw n("path","a string",e);let t=e.lastIndexOf(".");if(t===-1)return"";let r=e.slice(t+1);return r.indexOf("/")!==-1?"":r.toLowerCase().trim()}function Pt(){return new Promise(e=>requestAnimationFrame(e))}function Gt(e=0){return new Promise(t=>setTimeout(t,e))}async function N(e){return await new CSSStyleSheet().replace(e)}function Ut(e){if(!s(e))throw n("str","a string",e);if(/[^a-zA-Z0-9_]/.test(e))throw new SyntaxError(E("str","alphanumeric characters and underscores",e));return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function Vt(e){if(!s(e))throw n("str","a string",e);return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")||(e.length>0?e.charAt(0).toUpperCase()+e.slice(1):"")}function z(e){if(!s(e))throw n("str","a string",e);return e.replace(/^-+|-+$/g,"").replace(/-+([a-z])/g,(t,r)=>r.toUpperCase())}var A,$,L,O,j=class j{constructor(t){h(this,L);h(this,A);h(this,$,new WeakMap);if(!i(t,EventTarget))throw new TypeError(`JJET expects an EventTarget instance. Got ${t} (${typeof t}). `);J(this,A,t)}static from(t){return new j(t)}get ref(){return c(this,A)}on(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.addEventListener(t,a,o),this}off(t,r,o){let a=G(this,L,O).call(this,r);return this.ref.removeEventListener(t,a,o),this}trigger(t){return this.ref.dispatchEvent(t),this}run(t,...r){return t.call(this,...r)}};A=new WeakMap,$=new WeakMap,L=new WeakSet,O=function(t){if(t===null)return null;let r=c(this,$).get(t);return r||(typeof t=="function"?r=t.bind(this):r={handleEvent:t.handleEvent.bind(this)},c(this,$).set(t,r)),r};var C=j;var u=class e extends C{static from(t){return new e(t)}static isWrappable(t){return s(t)||i(t,Node)||i(t,e)}static wrap(t){if(f(t)){if(i(t,e))return t;if(i(t,Node))return new e(t)}throw n("raw","a Node",t)}static unwrap(t){if(s(t))return document.createTextNode(t);if(!f(t))throw new TypeError(`JJN.unwrap() expects a string, DOM Node, or JJ wrapper. Got ${t} (${typeof t}). `);if(i(t,Node))return t;if(i(t,e))return t.ref;throw new TypeError(`Could not unwrap ${t} (${typeof t}). Expected a string, Node, or JJ wrapper. Make sure you're passing a valid DOM element or JJ wrapper.`)}static wrapAll(t){return Array.from(t,e.wrap)}static unwrapAll(t){return Array.from(t,e.unwrap)}constructor(t){if(!i(t,Node))throw new TypeError(`JJN expects a Node instance. Got ${t} (${typeof t}). Use JJN.from(node) with a DOM Node, or check that you're passing a valid DOM element.`);super(t)}clone(t){return e.wrap(this.ref.cloneNode(t))}addText(...t){return t&&this.ref.appendChild(document.createTextNode(t.join(""))),this}};var m=class extends u{find(t,r=!1){let o=this.ref.querySelector(t);if(o)return u.wrap(o);if(r)throw new TypeError(`No element matched query "${t}"`);return null}findAll(t){return u.wrapAll(this.ref.querySelectorAll(t))}addChild(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.append(...r),this}preChild(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.prepend(...r),this}addChildMap(t,r){return this.addChild(...t.map(r))}preChildMap(t,r){return this.preChild(...t.map(r))}setChildren(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.replaceChildren(...r),this}empty(){return this.setChildren(),this}};var l=class e extends m{static from(t){return new e(t)}static create(){return new e(document.createDocumentFragment())}constructor(t){if(!i(t,DocumentFragment))throw n("ref","a DocumentFragment",t);super(t)}};var y=class e extends l{static from(t){return new e(t)}constructor(t){if(!i(t,ShadowRoot))throw new TypeError(`JJSR expects a ShadowRoot instance. Got ${t} (${typeof t}). Access a shadow root using element.shadowRoot after calling element.attachShadow().`);super(t)}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}addStyleSheets(...t){return this.ref.adoptedStyleSheets.push(...t),this}};var T=class e extends m{static from(t){return new e(t)}constructor(t){if(!i(t,Element))throw new TypeError(`JJE expects an Element instance. Got ${t} (${typeof t}). Use JJE.from(element) with a DOM Element, or use the specific wrapper (JJHE for HTMLElement, JJSE for SVGElement).`);super(t)}getAttr(t){if(!s(t))throw n("name","a string",t);return this.ref.getAttribute(t)}hasAttr(t){if(!s(t))throw n("name","a string",t);return this.ref.hasAttribute(t)}setAttr(t,r){if(typeof t=="string")this.ref.setAttribute(t,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(o,a);else throw n("nameOrObj","a string or object",t);return this}rmAttr(...t){for(let r of t){if(!s(r))throw n("name","a string",r);this.ref.removeAttribute(r)}return this}getAria(t){if(!s(t))throw n("name","a string",t);return this.ref.getAttribute(`aria-${t}`)}hasAria(t){if(!s(t))throw n("name","a string",t);return this.ref.hasAttribute(`aria-${t}`)}setAria(t,r){if(s(t))this.ref.setAttribute(`aria-${t}`,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(`aria-${o}`,a);else throw n("nameOrObj","a string or object",t);return this}rmAria(...t){for(let r of t){if(!s(r))throw n("name","a string",r);this.ref.removeAttribute(`aria-${r}`)}return this}getClass(){return this.getAttr("class")}setClass(t){if(typeof t=="string")return this.setAttr("class",t);for(let[r,o]of Object.entries(t))o?this.ref.classList.add(r):this.ref.classList.remove(r);return this}addClass(...t){for(let r of t)if(!s(r))throw n("className","a string",r);return this.ref.classList.add(...t),this}rmClass(...t){for(let r of t)if(!s(r))throw n("className","a string",r);return this.ref.classList.remove(...t),this}hasClass(t){if(!s(t))throw n("className","a string",t);return this.ref.classList.contains(t)}toggleClass(t){if(!s(t))throw n("className","a string",t);return this.ref.classList.toggle(t),this}replaceClass(t,r){if(!s(t))throw n("oldClassName","a string",t);if(!s(r))throw n("newClassName","a string",r);return this.ref.classList.replace(t,r),this}closest(t){if(!s(t))throw n("selector","a string",t);let r=this.ref.closest(t);return r?u.wrap(r):null}hide(){return this.setAttr("hidden","").setAttr("aria-hidden","true")}show(){return this.rmAttr("hidden","aria-hidden")}disable(){return this.setAttr("disabled","").setAttr("aria-disabled","true")}enable(){return this.rmAttr("disabled","aria-disabled")}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}initShadow(t="open",r){let o=this.ref.shadowRoot??this.ref.attachShadow({mode:t});if(f(r)){let{template:a,styles:d}=r;a&&(s(a)?o.innerHTML=a:o.appendChild(a)),H(d)&&d.length&&o.adoptedStyleSheets.push(...d)}return this}get shadow(){return this.ref.shadowRoot?new y(this.ref.shadowRoot):null}};var S=class extends T{getData(t){if(!s(t))throw n("name","a string",t);return this.ref.dataset[t]}hasData(t){if(!s(t))throw n("name","a string",t);return w(this.ref.dataset,t)}setData(t,r){if(typeof t=="string")this.ref.dataset[t]=r;else if(f(t))for(let[o,a]of Object.entries(t))this.ref.dataset[o]=a;else throw n("nameOrObj","a string or object",t);return this}rmData(...t){for(let r of t){if(!s(r))throw n("name","a string",r);delete this.ref.dataset[r]}return this}};var p=class e extends S{static from(t){return new e(t)}static create(t,r){if(!s(t))throw n("tagName","a string like 'div' or 'button'",t);return new e(document.createElement(t,r))}constructor(t){if(!i(t,HTMLElement))throw n("ref","an HTMLElement",t);super(t)}getValue(){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value}setValue(t){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value=t,this}focus(){return this.ref.focus(),this}click(){return this.ref.click(),this}getText(){return this.ref.innerText}setText(t){return this.ref.innerText=t,this}};var k=class e extends u{static from(t){return new e(t)}static fromStr(t){return new e(document.createTextNode(t))}constructor(t){if(!i(t,Text))throw new TypeError(`JJT expects a Text node. Got ${t} (${typeof t}). Create a Text node with JJT.fromStr() or document.createTextNode('text').`);super(t)}getText(){return this.ref.textContent}setText(t){return this.ref.textContent=t,this}addText(...t){return this.setText(this.getText()+t.join("")),this}empty(){return this.setText("")}};var x=class e extends m{static from(t){return new e(t)}constructor(t){if(!i(t,Document))throw new TypeError(`JJD expects a Document instance. Got ${t} (${typeof t}). `);super(t)}get head(){return p.from(this.ref.head)}get body(){return p.from(this.ref.body)}};var Q="http://www.w3.org/2000/svg",W=class e extends S{static from(t){return new e(t)}static create(t,r){if(!s(t))throw n("tagName",'a string like "circle" or "path"',t);let o=document.createElementNS(Q,t,r);return new e(o)}constructor(t){if(!i(t,SVGElement))throw n("ref","an SVGElement",t);super(t)}getText(){return this.ref.textContent??""}setText(t){return this.ref.textContent=t,this}setFill(t){return this.setAttr("fill",t)}setStroke(t){return this.setAttr("stroke",t)}setStrokeWidth(t){return this.setAttr("stroke-width",String(t))}setViewBox(t,r,o,a){if(typeof t=="number"&&r!==void 0&&o!==void 0&&a!==void 0)return this.setAttr("viewBox",`${t} ${r} ${o} ${a}`);let d=t;return this.setAttr("viewBox",Array.isArray(d)?d.join(" "):d)}setWidth(t){return this.setAttr("width",String(t))}setHeight(t){return this.setAttr("height",String(t))}setD(t){return this.setAttr("d",Array.isArray(t)?t.join(" "):t)}setTransform(t){return this.setAttr("transform",t)}};u.wrap=function(t){if(s(t))return k.fromStr(t);if(!f(t))throw n("raw","an object",t);if(i(t,u))return t;if(i(t,HTMLElement))return p.from(t);if(i(t,SVGElement))return W.from(t);if(i(t,Element))return T.from(t);if(i(t,ShadowRoot))return y.from(t);if(i(t,DocumentFragment))return l.from(t);if(i(t,Document))return x.from(t);if(i(t,Text))return k.from(t);if(i(t,Node))return u.from(t);throw n("raw","a Node",t)};function sr(e,t,...r){let o=p.create(e).addChild(...r);return t&&o.setAttr(t),o}function X(e){switch(I(e)){case"html":case"htm":case"md":return"fetch";case"css":return"style";case"js":case"mjs":case"cjs":return"script";default:throw new Error(`No 'as' attribute was specified and we failed to guess it from the URL: ${e}`)}}function Y(e,t,r){if(!s(e)){if(!i(e,URL))throw n("href","a string or URL",e);e=e.toString()}if(!["prefetch","preload"].includes(t))throw new RangeError(E("rel","'prefetch' or 'preload'",t));if(!r&&(r=X(e),!r))throw new Error(`Could not guess 'as' attribute from URL: ${e}`);if(!["fetch","style","script"].includes(r))throw new RangeError(E("as","'fetch', 'style', or 'script'",r));return p.create("link").setAttr({href:e,rel:t,as:r})}function or(...e){let t=Y(...e);return document.head.append(t.ref),t}async function B(e,t="text/*"){if(!s(t))throw n("mime","a string",t);let r=await fetch(e,{headers:{Accept:t}});if(!r.ok)throw new Error(`GET ${e} failed: ${r.status} ${r.statusText}`);return r.text()}async function ar(e){return await B(e,"text/html")}async function _(e){return await B(e,"text/css")}async function ur(e){return await N(await _(e))}function mr(e,t,r,o){if(!i(e,HTMLElement))throw n("instance","an HTMLElement",e);if(r!==o){let a=z(t);if(w(e,a))return e[a]=o,!0}return!1}async function lr(e,t,r){if(!s(e))throw n("name","a string",e);if(!g(t))throw n("constructor","a function",t);customElements.get(e)||(customElements.define(e,t,r),await customElements.whenDefined(e))}async function tt(e){if(e!==void 0){if(g(e)&&(e=await e()),e=await e,s(e))return e;if(i(e,l))return e.ref.cloneNode(!0);if(i(e,DocumentFragment))return e.cloneNode(!0);if(i(e,p))return e.ref instanceof HTMLTemplateElement?e.ref.content.cloneNode(!0):e.ref.outerHTML;if(i(e,HTMLElement))return e instanceof HTMLTemplateElement?e.content.cloneNode(!0):e.outerHTML;throw n("template","a string, JJHE, JJDF, HTMLElement, or DocumentFragment",e)}}async function et(e){if(g(e)&&(e=await e()),e=await e,i(e,CSSStyleSheet))return e;if(s(e))return await N(e);throw n("style","a CSS string or CSSStyleSheet",e)}function rt(e){return H(e)?e.map(et):[]}async function nt(e,t){let[r,...o]=await Promise.all([tt(e),...rt(t)]);return{template:r,styles:o}}var D,R,b,U=class U{constructor(){h(this,D);h(this,R,[]);h(this,b)}static create(){return new U}setTemplate(t){return J(this,D,t),this}addStyles(...t){return c(this,R).push(...t),this}async getResolved(){return c(this,b)||J(this,b,nt(c(this,D),c(this,R))),await c(this,b)}};D=new WeakMap,R=new WeakMap,b=new WeakMap;var q=U;var $r=x.from(document);})();
|
|
2
2
|
//# sourceMappingURL=bundle.min.global.js.map
|