@aegis-framework/pandora 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -38
- package/dist/pandora.browser.js +8 -8
- package/dist/pandora.browser.js.map +6 -6
- package/dist/pandora.js +7 -7
- package/dist/pandora.js.map +6 -6
- package/dist/types/Component.d.ts +20 -2
- package/dist/types/Component.d.ts.map +1 -1
- package/dist/types/Decorators.d.ts.map +1 -1
- package/dist/types/Registry.d.ts.map +1 -1
- package/dist/types/ShadowComponent.d.ts.map +1 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -120,7 +120,14 @@ class MyCounter extends Component {
|
|
|
120
120
|
@Consumer('app.theme')
|
|
121
121
|
theme!: string;
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
constructor() {
|
|
124
|
+
super();
|
|
125
|
+
this.state = { count: 0 };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
onStateUpdate() {
|
|
129
|
+
this.forceRender();
|
|
130
|
+
}
|
|
124
131
|
|
|
125
132
|
render() {
|
|
126
133
|
return html`
|
|
@@ -174,14 +181,12 @@ class MyShadowComponent extends ShadowComponent {
|
|
|
174
181
|
this.props = { text: '' };
|
|
175
182
|
}
|
|
176
183
|
|
|
177
|
-
willMount() {
|
|
184
|
+
async willMount() {
|
|
178
185
|
// Set scoped styles
|
|
179
186
|
this.setStyle({
|
|
180
187
|
':host': { display: 'block' },
|
|
181
188
|
h2: { color: 'blue' }
|
|
182
189
|
});
|
|
183
|
-
|
|
184
|
-
return Promise.resolve();
|
|
185
190
|
}
|
|
186
191
|
|
|
187
192
|
render() {
|
|
@@ -191,6 +196,8 @@ class MyShadowComponent extends ShadowComponent {
|
|
|
191
196
|
}
|
|
192
197
|
```
|
|
193
198
|
|
|
199
|
+
> **Note:** In `ShadowComponent`, use `this.shadowRoot` instead of `this.dom` to access the shadow root, and use native `<slot>` elements for content projection instead of `slotContent`.
|
|
200
|
+
|
|
194
201
|
## API Reference
|
|
195
202
|
|
|
196
203
|
### Static Properties
|
|
@@ -204,19 +211,22 @@ class MyShadowComponent extends ShadowComponent {
|
|
|
204
211
|
|
|
205
212
|
| Property | Type | Description |
|
|
206
213
|
|----------|------|-------------|
|
|
207
|
-
| `props` | `object` | Component properties (read via proxy) |
|
|
208
|
-
| `state` | `object` | Internal component state |
|
|
209
|
-
| `dom` | `HTMLElement` | Reference to the component's DOM |
|
|
214
|
+
| `props` | `object` | Component properties (read via proxy, set via `setProps()`) |
|
|
215
|
+
| `state` | `object` | Internal component state (set via `setState()`) |
|
|
216
|
+
| `dom` | `HTMLElement` | Reference to the component's DOM element |
|
|
210
217
|
| `slotContent` | `string` | Original innerHTML content before rendering (for content projection) |
|
|
211
218
|
| `width` | `number` | Computed width in pixels |
|
|
212
219
|
| `height` | `number` | Computed height in pixels |
|
|
213
220
|
| `isConnected` | `boolean` | Whether the component is connected to the DOM |
|
|
214
221
|
| `isReady` | `boolean` | Whether the component has completed its initial mount |
|
|
222
|
+
| `isFirstMount` | `boolean` | Whether this is the first time the component is being mounted (as opposed to a reconnect) |
|
|
215
223
|
|
|
216
224
|
### Methods
|
|
217
225
|
|
|
218
226
|
#### State & Props
|
|
219
227
|
|
|
228
|
+
`setState()` and `setProps()` trigger the update lifecycle (`willUpdate` -> `update` -> `didUpdate` and `onStateUpdate`/`onPropsUpdate`), but they do **not** automatically re-render the component. Call `forceRender()` to update the DOM after state or props changes.
|
|
229
|
+
|
|
220
230
|
```javascript
|
|
221
231
|
// Update props (triggers update cycle)
|
|
222
232
|
element.setProps({ title: 'New Title' });
|
|
@@ -224,6 +234,9 @@ element.setProps({ title: 'New Title' });
|
|
|
224
234
|
// Update state (triggers update cycle)
|
|
225
235
|
element.setState({ count: 5 });
|
|
226
236
|
|
|
237
|
+
// Re-render the component
|
|
238
|
+
element.forceRender();
|
|
239
|
+
|
|
227
240
|
// Set component styles
|
|
228
241
|
element.setStyle({
|
|
229
242
|
h2: { color: 'red', fontSize: '24px' }
|
|
@@ -262,7 +275,7 @@ const items = element.queryAll('.item');
|
|
|
262
275
|
// Force re-render
|
|
263
276
|
await element.forceRender();
|
|
264
277
|
|
|
265
|
-
// Register ready callback
|
|
278
|
+
// Register ready callback (runs immediately if already ready)
|
|
266
279
|
element.ready(() => {
|
|
267
280
|
console.log('Component is ready!');
|
|
268
281
|
});
|
|
@@ -272,12 +285,13 @@ element.ready(() => {
|
|
|
272
285
|
|
|
273
286
|
### Lifecycle Hooks
|
|
274
287
|
|
|
275
|
-
Override these methods to hook into the component lifecycle
|
|
288
|
+
Override these methods to hook into the component lifecycle. All lifecycle hooks are async.
|
|
276
289
|
|
|
277
290
|
#### Mount Cycle
|
|
278
291
|
|
|
279
|
-
- `willMount()` - Called before the component is rendered
|
|
280
|
-
- `didMount()` - Called after the component is rendered
|
|
292
|
+
- `willMount()` - Called before the component is rendered (runs on every mount and reconnect)
|
|
293
|
+
- `didMount()` - Called after the component is rendered **for the first time only**
|
|
294
|
+
- `didReconnect()` - Called after the component is re-inserted into the DOM (not on first mount)
|
|
281
295
|
|
|
282
296
|
#### Update Cycle
|
|
283
297
|
|
|
@@ -297,19 +311,31 @@ The `origin` parameter can be `'props'`, `'state'`, or `'attribute'` depending o
|
|
|
297
311
|
|
|
298
312
|
```javascript
|
|
299
313
|
class MyComponent extends Component {
|
|
300
|
-
willMount() {
|
|
314
|
+
async willMount() {
|
|
315
|
+
// Runs on every mount (first and reconnect)
|
|
301
316
|
console.log('About to mount');
|
|
302
|
-
return Promise.resolve();
|
|
303
317
|
}
|
|
304
318
|
|
|
305
|
-
didMount() {
|
|
306
|
-
|
|
307
|
-
|
|
319
|
+
async didMount() {
|
|
320
|
+
// Only runs once — safe for listeners, subscriptions, intervals
|
|
321
|
+
this.on('click', () => this.handleClick());
|
|
322
|
+
console.log('Mounted for the first time!');
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
async didReconnect() {
|
|
326
|
+
// Runs when re-inserted into the DOM (e.g., after being moved)
|
|
327
|
+
console.log('Reconnected — refreshing data');
|
|
328
|
+
await this.refreshData();
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async onStateUpdate(property, oldValue, newValue) {
|
|
332
|
+
// Re-render when state changes
|
|
333
|
+
this.forceRender();
|
|
308
334
|
}
|
|
309
335
|
|
|
310
|
-
onPropsUpdate(property, oldValue, newValue) {
|
|
336
|
+
async onPropsUpdate(property, oldValue, newValue) {
|
|
311
337
|
console.log(`Prop ${property} changed from ${oldValue} to ${newValue}`);
|
|
312
|
-
|
|
338
|
+
this.forceRender();
|
|
313
339
|
}
|
|
314
340
|
}
|
|
315
341
|
```
|
|
@@ -322,9 +348,11 @@ To react to HTML attribute changes, define which attributes to observe:
|
|
|
322
348
|
class MyComponent extends Component {
|
|
323
349
|
static observedAttributes = ['title', 'count', 'disabled'];
|
|
324
350
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
351
|
+
// Attribute changes automatically trigger the update cycle,
|
|
352
|
+
// which calls onPropsUpdate. Override it to react:
|
|
353
|
+
async onPropsUpdate(property, oldValue, newValue) {
|
|
354
|
+
console.log(`${property} changed to ${newValue}`);
|
|
355
|
+
this.forceRender();
|
|
328
356
|
}
|
|
329
357
|
}
|
|
330
358
|
```
|
|
@@ -336,6 +364,7 @@ You can use HTML templates instead of the render method:
|
|
|
336
364
|
```html
|
|
337
365
|
<template id="my-component">
|
|
338
366
|
<div class="wrapper">
|
|
367
|
+
<h2>Static template content</h2>
|
|
339
368
|
<!-- For light DOM components, use slotContent in render() instead -->
|
|
340
369
|
<!-- For ShadowComponent, use native <slot> -->
|
|
341
370
|
</div>
|
|
@@ -345,14 +374,10 @@ You can use HTML templates instead of the render method:
|
|
|
345
374
|
Or set templates programmatically:
|
|
346
375
|
|
|
347
376
|
```javascript
|
|
348
|
-
//
|
|
349
|
-
MyComponent.template(
|
|
350
|
-
<div class="wrapper">
|
|
351
|
-
<h2>{{title}}</h2>
|
|
352
|
-
</div>
|
|
353
|
-
`);
|
|
377
|
+
// Static string template (no interpolation - for fixed HTML content)
|
|
378
|
+
MyComponent.template('<div class="wrapper"><h2>Hello</h2></div>');
|
|
354
379
|
|
|
355
|
-
// Function returning string
|
|
380
|
+
// Function returning string (use for dynamic content)
|
|
356
381
|
MyComponent.template((context) => `
|
|
357
382
|
<div class="wrapper">
|
|
358
383
|
<h2>${context.props.title}</h2>
|
|
@@ -376,6 +401,8 @@ MyComponent.template(async (context) => {
|
|
|
376
401
|
});
|
|
377
402
|
```
|
|
378
403
|
|
|
404
|
+
> **Note:** When you set a static template via `MyComponent.template(...)`, all existing mounted instances of that component are automatically re-rendered.
|
|
405
|
+
|
|
379
406
|
## lit-html Integration
|
|
380
407
|
|
|
381
408
|
Pandora includes [lit-html](https://lit.dev/docs/libraries/standalone-templates/) and re-exports its utilities for convenience. You don't need to install lit-html separately.
|
|
@@ -431,7 +458,7 @@ async render() {
|
|
|
431
458
|
|
|
432
459
|
// Promise-based render (no async keyword needed)
|
|
433
460
|
render() {
|
|
434
|
-
return fetchUserData().then(data =>
|
|
461
|
+
return fetchUserData().then(data =>
|
|
435
462
|
html`<div>Hello, ${data.name}!</div>`
|
|
436
463
|
);
|
|
437
464
|
}
|
|
@@ -535,7 +562,7 @@ class MyButton extends Component {
|
|
|
535
562
|
|
|
536
563
|
### @Consumer(stateKey)
|
|
537
564
|
|
|
538
|
-
Binds a class property to global Registry state. Automatically subscribes on connect and unsubscribes on disconnect:
|
|
565
|
+
Binds a class property to global Registry state. Automatically subscribes on connect and unsubscribes on disconnect. When the global state changes, the property updates and the component re-renders automatically:
|
|
539
566
|
|
|
540
567
|
```typescript
|
|
541
568
|
import { Component, Register, Consumer, html } from '@aegis-framework/pandora';
|
|
@@ -945,25 +972,21 @@ class ThemeToggle extends Component {
|
|
|
945
972
|
};
|
|
946
973
|
}
|
|
947
974
|
|
|
948
|
-
didMount() {
|
|
949
|
-
//
|
|
975
|
+
async didMount() {
|
|
976
|
+
// Only runs once — safe for subscriptions and listeners
|
|
950
977
|
this._unsubscribe = Registry.subscribe('theme', (newTheme) => {
|
|
951
978
|
this.setState({ theme: newTheme });
|
|
952
979
|
this.forceRender();
|
|
953
980
|
});
|
|
954
981
|
|
|
955
|
-
// Bind click event using event helpers
|
|
956
982
|
this.on('click', () => this.toggleTheme());
|
|
957
|
-
|
|
958
|
-
return Promise.resolve();
|
|
959
983
|
}
|
|
960
984
|
|
|
961
|
-
willUnmount() {
|
|
985
|
+
async willUnmount() {
|
|
962
986
|
// Clean up subscription
|
|
963
987
|
if (this._unsubscribe) {
|
|
964
988
|
this._unsubscribe();
|
|
965
989
|
}
|
|
966
|
-
return Promise.resolve();
|
|
967
990
|
}
|
|
968
991
|
|
|
969
992
|
toggleTheme() {
|
|
@@ -971,6 +994,10 @@ class ThemeToggle extends Component {
|
|
|
971
994
|
Registry.setState('theme', newTheme);
|
|
972
995
|
}
|
|
973
996
|
|
|
997
|
+
async onStateUpdate() {
|
|
998
|
+
this.forceRender();
|
|
999
|
+
}
|
|
1000
|
+
|
|
974
1001
|
render() {
|
|
975
1002
|
return `<button>Current: ${this.state.theme}</button>`;
|
|
976
1003
|
}
|
|
@@ -1053,8 +1080,8 @@ For direct browser usage without a bundler:
|
|
|
1053
1080
|
didMount() {
|
|
1054
1081
|
this.on('click', () => {
|
|
1055
1082
|
this.setState({ count: this.state.count + 1 });
|
|
1083
|
+
this.forceRender();
|
|
1056
1084
|
});
|
|
1057
|
-
return Promise.resolve();
|
|
1058
1085
|
}
|
|
1059
1086
|
|
|
1060
1087
|
render() {
|
package/dist/pandora.browser.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
1
|
+
var VJ=Object.defineProperty;var YJ=(J,W)=>{for(var X in W)VJ(J,X,{get:W[X],enumerable:!0,configurable:!0,set:(Y)=>W[X]=()=>Y})};var XJ={};YJ(XJ,{svg:()=>_J,render:()=>D,nothing:()=>U,noChange:()=>L,html:()=>MJ,Util:()=>JJ,Types:()=>PJ,ShadowComponent:()=>AJ,Registry:()=>I,Register:()=>EJ,Prop:()=>LJ,Consumer:()=>NJ,Component:()=>f});var j=globalThis,H=(J)=>{if(!j.emitLitDebugLogEvents)return;j.dispatchEvent(new CustomEvent("lit-debug",{detail:J}))},IJ=0,w;j.litIssuedWarnings??=new Set,w=(J,W)=>{if(W+=J?` See https://lit.dev/msg/${J} for more information.`:"",!j.litIssuedWarnings.has(W)&&!j.litIssuedWarnings.has(J))console.warn(W),j.litIssuedWarnings.add(W)},queueMicrotask(()=>{w("dev-mode","Lit is in dev mode. Not recommended for production!")});var O=j.ShadyDOM?.inUse&&j.ShadyDOM?.noPatch===!0?j.ShadyDOM.wrap:(J)=>J,v=j.trustedTypes,ZJ=v?v.createPolicy("lit-html",{createHTML:(J)=>J}):void 0,TJ=(J)=>J,u=(J,W,X)=>TJ,CJ=(J)=>{if(P!==u)throw Error("Attempted to overwrite existing lit-html security policy. setSanitizeDOMValueFactory should be called at most once.");P=J},hJ=()=>{P=u},l=(J,W,X)=>{return P(J,W,X)},FJ="$lit$",S=`lit$${Math.random().toFixed(9).slice(2)}$`,UJ="?"+S,wJ=`<${UJ}>`,N=document,x=()=>N.createComment(""),b=(J)=>J===null||typeof J!="object"&&typeof J!="function",n=Array.isArray,xJ=(J)=>n(J)||typeof J?.[Symbol.iterator]==="function",i=`[
|
|
2
2
|
\f\r]`,bJ=`[^
|
|
3
|
-
\f\r"'\`<>=]`,kJ=`[^\\s"'>=/]`,h=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,$J=1,s=2,yJ=3,qJ=/-->/g,GJ=/>/g,R=new RegExp(`>|${i}(?:(${kJ}+)(${i}*=${i}*(?:${bJ}|("|')|))|$)`,"g"),dJ=0,QJ=1,mJ=2,BJ=3,o=/'/g,r=/"/g,
|
|
3
|
+
\f\r"'\`<>=]`,kJ=`[^\\s"'>=/]`,h=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,$J=1,s=2,yJ=3,qJ=/-->/g,GJ=/>/g,R=new RegExp(`>|${i}(?:(${kJ}+)(${i}*=${i}*(?:${bJ}|("|')|))|$)`,"g"),dJ=0,QJ=1,mJ=2,BJ=3,o=/'/g,r=/"/g,zJ=/^(?:script|style|textarea|title)$/i,vJ=1,c=2,g=3,a=1,p=2,cJ=3,gJ=4,pJ=5,t=6,uJ=7,e=(J)=>(W,...X)=>{if(W.some((Y)=>Y===void 0))console.warn(`Some template strings are undefined.
|
|
4
4
|
This is probably caused by illegal octal escape sequences.`);if(X.some((Y)=>Y?._$litStatic$))w("",`Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates.
|
|
5
|
-
Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`);return{["_$litType$"]:J,strings:W,values:X}},
|
|
5
|
+
Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`);return{["_$litType$"]:J,strings:W,values:X}},MJ=e(vJ),_J=e(c),lJ=e(g),L=Symbol.for("lit-noChange"),U=Symbol.for("lit-nothing"),HJ=new WeakMap,E=N.createTreeWalker(N,129),P=u;function fJ(J,W){if(!n(J)||!J.hasOwnProperty("raw")){let X="invalid template strings array";throw X=`
|
|
6
6
|
Internal Error: expected template strings to be an array
|
|
7
7
|
with a 'raw' field. Faking a template strings array by
|
|
8
8
|
calling html or svg like an ordinary function is effectively
|
|
@@ -13,17 +13,17 @@ Please use the static 'html' tag function. See https://lit.dev/docs/templates/ex
|
|
|
13
13
|
https://github.com/lit/lit/issues/new?template=bug_report.md
|
|
14
14
|
and include information about your build tooling, if any.
|
|
15
15
|
`.trim().replace(/\n */g,`
|
|
16
|
-
`),Error(X)}return ZJ!==void 0?ZJ.createHTML(W):W}var iJ=(J,W)=>{let X=J.length-1,Y=[],Z=W===c?"<svg>":W===g?"<math>":"",$,q=h;for(let Q=0;Q<X;Q++){let F=J[Q],B=-1,_,K=0,z;while(K<F.length){if(q.lastIndex=K,z=q.exec(F),z===null)break;if(K=q.lastIndex,q===h){if(z[$J]==="!--")q=qJ;else if(z[$J]!==void 0)q=GJ;else if(z[s]!==void 0){if(UJ.test(z[s]))$=new RegExp(`</${z[s]}`,"g");q=R}else if(z[yJ]!==void 0)throw Error("Bindings in tag names are not supported. Please use static templates instead. See https://lit.dev/docs/templates/expressions/#static-expressions")}else if(q===R)if(z[dJ]===">")q=$??h,B=-1;else if(z[QJ]===void 0)B=-2;else B=q.lastIndex-z[mJ].length,_=z[QJ],q=z[BJ]===void 0?R:z[BJ]==='"'?r:o;else if(q===r||q===o)q=R;else if(q===qJ||q===GJ)q=h;else q=R,$=void 0}console.assert(B===-1||q===R||q===o||q===r,"unexpected parse state B");let A=q===R&&J[Q+1].startsWith("/>")?" ":"";Z+=q===h?F+wJ:B>=0?(Y.push(_),F.slice(0,B)+FJ+F.slice(B))+S+A:F+S+(B===-2?Q:A)}let G=Z+(J[X]||"<?>")+(W===c?"</svg>":W===g?"</math>":"");return[fJ(J,G),Y]};class k{constructor({strings:J,["_$litType$"]:W},X){this.parts=[];let Y,Z=0,$=0,q=J.length-1,G=this.parts,[Q,F]=iJ(J,W);if(this.el=k.createElement(Q,X),E.currentNode=this.el.content,W===c||W===g){let B=this.el.content.firstChild;B.replaceWith(...B.childNodes)}while((Y=E.nextNode())!==null&&G.length<q){if(Y.nodeType===1){{let B=Y.localName;if(/^(?:textarea|template)$/i.test(B)&&Y.innerHTML.includes(S)){let _=`Expressions are not supported inside \`${B}\` elements. See https://lit.dev/msg/expression-in-${B} for more information.`;if(B==="template")throw Error(_);else w("",_)}}if(Y.hasAttributes()){for(let B of Y.getAttributeNames())if(B.endsWith(FJ)){let _=F[$++],z=Y.getAttribute(B).split(S),A=/([.?@])?(.*)/.exec(_);G.push({type:a,index:Z,name:A[2],strings:z,ctor:A[1]==="."?OJ:A[1]==="?"?SJ:A[1]==="@"?DJ:d}),Y.removeAttribute(B)}else if(B.startsWith(S))G.push({type:t,index:Z}),Y.removeAttribute(B)}if(UJ.test(Y.tagName)){let B=Y.textContent.split(S),_=B.length-1;if(_>0){Y.textContent=v?v.emptyScript:"";for(let K=0;K<_;K++)Y.append(B[K],x()),E.nextNode(),G.push({type:p,index:++Z});Y.append(B[_],x())}}}else if(Y.nodeType===8)if(Y.data===MJ)G.push({type:p,index:Z});else{let _=-1;while((_=Y.data.indexOf(S,_+1))!==-1)G.push({type:uJ,index:Z}),_+=S.length-1}Z++}if(F.length!==$)throw Error('Detected duplicate attribute bindings. This occurs if your template has duplicate attributes on an element tag. For example "<input ?disabled=${true} ?disabled=${false}>" contains a duplicate "disabled" attribute. The error was detected in the following template: \n`'+J.join("${...}")+"`");H&&H({kind:"template prep",template:this,clonableTemplate:this.el,parts:this.parts,strings:J})}static createElement(J,W){let X=N.createElement("template");return X.innerHTML=J,X}}function T(J,W,X=J,Y){if(W===L)return W;let Z=Y!==void 0?X.__directives?.[Y]:X.__directive,$=b(W)?void 0:W._$litDirective$;if(Z?.constructor!==$){if(Z?._$notifyDirectiveConnectionChanged?.(!1),$===void 0)Z=void 0;else Z=new $(J),Z._$initialize(J,X,Y);if(Y!==void 0)(X.__directives??=[])[Y]=Z;else X.__directive=Z}if(Z!==void 0)W=T(J,Z._$resolve(J,W.values),Z,Y);return W}class jJ{constructor(J,W){this._$parts=[],this._$disconnectableChildren=void 0,this._$template=J,this._$parent=W}get parentNode(){return this._$parent.parentNode}get _$isConnected(){return this._$parent._$isConnected}_clone(J){let{el:{content:W},parts:X}=this._$template,Y=(J?.creationScope??N).importNode(W,!0);E.currentNode=Y;let Z=E.nextNode(),$=0,q=0,G=X[0];while(G!==void 0){if($===G.index){let Q;if(G.type===p)Q=new y(Z,Z.nextSibling,this,J);else if(G.type===a)Q=new G.ctor(Z,G.name,G.strings,this,J);else if(G.type===t)Q=new KJ(Z,this,J);this._$parts.push(Q),G=X[++q]}if($!==G?.index)Z=E.nextNode(),$++}return E.currentNode=N,Y}_update(J){let W=0;for(let X of this._$parts){if(X!==void 0)if(H&&H({kind:"set part",part:X,value:J[W],valueIndex:W,values:J,templateInstance:this}),X.strings!==void 0)X._$setValue(J,X,W),W+=X.strings.length-2;else X._$setValue(J[W]);W++}}}class y{get _$isConnected(){return this._$parent?._$isConnected??this.__isConnected}constructor(J,W,X,Y){this.type=p,this._$committedValue=M,this._$disconnectableChildren=void 0,this._$startNode=J,this._$endNode=W,this._$parent=X,this.options=Y,this.__isConnected=Y?.isConnected??!0,this._textSanitizer=void 0}get parentNode(){let J=O(this._$startNode).parentNode,W=this._$parent;if(W!==void 0&&J?.nodeType===11)J=W.parentNode;return J}get startNode(){return this._$startNode}get endNode(){return this._$endNode}_$setValue(J,W=this){if(this.parentNode===null)throw Error("This `ChildPart` has no `parentNode` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's `innerHTML` or `textContent` can do this.");if(J=T(this,J,W),b(J)){if(J===M||J==null||J===""){if(this._$committedValue!==M)H&&H({kind:"commit nothing to child",start:this._$startNode,end:this._$endNode,parent:this._$parent,options:this.options}),this._$clear();this._$committedValue=M}else if(J!==this._$committedValue&&J!==L)this._commitText(J)}else if(J._$litType$!==void 0)this._commitTemplateResult(J);else if(J.nodeType!==void 0){if(this.options?.host===J){this._commitText("[probable mistake: rendered a template's host in itself (commonly caused by writing ${this} in a template]"),console.warn("Attempted to render the template host",J,"inside itself. This is almost always a mistake, and in dev mode ","we render some warning text. In production however, we'll ","render it, which will usually result in an error, and sometimes ","in the element disappearing from the DOM.");return}this._commitNode(J)}else if(xJ(J))this._commitIterable(J);else this._commitText(J)}_insert(J){return O(O(this._$startNode).parentNode).insertBefore(J,this._$endNode)}_commitNode(J){if(this._$committedValue!==J){if(this._$clear(),V!==u){let W=this._$startNode.parentNode?.nodeName;if(W==="STYLE"||W==="SCRIPT"){let X="Forbidden";if(W==="STYLE")X="Lit does not support binding inside style nodes. This is a security risk, as style injection attacks can exfiltrate data and spoof UIs. Consider instead using css`...` literals to compose styles, and do dynamic styling with css custom properties, ::parts, <slot>s, and by mutating the DOM rather than stylesheets.";else X="Lit does not support binding inside script nodes. This is a security risk, as it could allow arbitrary code execution.";throw Error(X)}}H&&H({kind:"commit node",start:this._$startNode,parent:this._$parent,value:J,options:this.options}),this._$committedValue=this._insert(J)}}_commitText(J){if(this._$committedValue!==M&&b(this._$committedValue)){let W=O(this._$startNode).nextSibling;if(this._textSanitizer===void 0)this._textSanitizer=l(W,"data","property");J=this._textSanitizer(J),H&&H({kind:"commit text",node:W,value:J,options:this.options}),W.data=J}else{let W=N.createTextNode("");if(this._commitNode(W),this._textSanitizer===void 0)this._textSanitizer=l(W,"data","property");J=this._textSanitizer(J),H&&H({kind:"commit text",node:W,value:J,options:this.options}),W.data=J}this._$committedValue=J}_commitTemplateResult(J){let{values:W,["_$litType$"]:X}=J,Y=typeof X==="number"?this._$getTemplate(J):(X.el===void 0&&(X.el=k.createElement(fJ(X.h,X.h[0]),this.options)),X);if(this._$committedValue?._$template===Y)H&&H({kind:"template updating",template:Y,instance:this._$committedValue,parts:this._$committedValue._$parts,options:this.options,values:W}),this._$committedValue._update(W);else{let Z=new jJ(Y,this),$=Z._clone(this.options);H&&H({kind:"template instantiated",template:Y,instance:Z,parts:Z._$parts,options:this.options,fragment:$,values:W}),Z._update(W),H&&H({kind:"template instantiated and updated",template:Y,instance:Z,parts:Z._$parts,options:this.options,fragment:$,values:W}),this._commitNode($),this._$committedValue=Z}}_$getTemplate(J){let W=HJ.get(J.strings);if(W===void 0)HJ.set(J.strings,W=new k(J));return W}_commitIterable(J){if(!n(this._$committedValue))this._$committedValue=[],this._$clear();let W=this._$committedValue,X=0,Y;for(let Z of J){if(X===W.length)W.push(Y=new y(this._insert(x()),this._insert(x()),this,this.options));else Y=W[X];Y._$setValue(Z),X++}if(X<W.length)this._$clear(Y&&O(Y._$endNode).nextSibling,X),W.length=X}_$clear(J=O(this._$startNode).nextSibling,W){this._$notifyConnectionChanged?.(!1,!0,W);while(J!==this._$endNode){let X=O(J).nextSibling;O(J).remove(),J=X}}setConnected(J){if(this._$parent===void 0)this.__isConnected=J,this._$notifyConnectionChanged?.(J);else throw Error("part.setConnected() may only be called on a RootPart returned from render().")}}class d{get tagName(){return this.element.tagName}get _$isConnected(){return this._$parent._$isConnected}constructor(J,W,X,Y,Z){if(this.type=a,this._$committedValue=M,this._$disconnectableChildren=void 0,this.element=J,this.name=W,this._$parent=Y,this.options=Z,X.length>2||X[0]!==""||X[1]!=="")this._$committedValue=Array(X.length-1).fill(new String),this.strings=X;else this._$committedValue=M;this._sanitizer=void 0}_$setValue(J,W=this,X,Y){let Z=this.strings,$=!1;if(Z===void 0){if(J=T(this,J,W,0),$=!b(J)||J!==this._$committedValue&&J!==L,$)this._$committedValue=J}else{let q=J;J=Z[0];let G,Q;for(G=0;G<Z.length-1;G++){if(Q=T(this,q[X+G],W,G),Q===L)Q=this._$committedValue[G];if($||=!b(Q)||Q!==this._$committedValue[G],Q===M)J=M;else if(J!==M)J+=(Q??"")+Z[G+1];this._$committedValue[G]=Q}}if($&&!Y)this._commitValue(J)}_commitValue(J){if(J===M)O(this.element).removeAttribute(this.name);else{if(this._sanitizer===void 0)this._sanitizer=V(this.element,this.name,"attribute");J=this._sanitizer(J??""),H&&H({kind:"commit attribute",element:this.element,name:this.name,value:J,options:this.options}),O(this.element).setAttribute(this.name,J??"")}}}class OJ extends d{constructor(){super(...arguments);this.type=cJ}_commitValue(J){if(this._sanitizer===void 0)this._sanitizer=V(this.element,this.name,"property");J=this._sanitizer(J),H&&H({kind:"commit property",element:this.element,name:this.name,value:J,options:this.options}),this.element[this.name]=J===M?void 0:J}}class SJ extends d{constructor(){super(...arguments);this.type=gJ}_commitValue(J){H&&H({kind:"commit boolean attribute",element:this.element,name:this.name,value:!!(J&&J!==M),options:this.options}),O(this.element).toggleAttribute(this.name,!!J&&J!==M)}}class DJ extends d{constructor(J,W,X,Y,Z){super(J,W,X,Y,Z);if(this.type=pJ,this.strings!==void 0)throw Error(`A \`<${J.localName}>\` has a \`@${W}=...\` listener with invalid content. Event listeners in templates must have exactly one expression and no surrounding text.`)}_$setValue(J,W=this){if(J=T(this,J,W,0)??M,J===L)return;let X=this._$committedValue,Y=J===M&&X!==M||J.capture!==X.capture||J.once!==X.once||J.passive!==X.passive,Z=J!==M&&(X===M||Y);if(H&&H({kind:"commit event listener",element:this.element,name:this.name,value:J,options:this.options,removeListener:Y,addListener:Z,oldListener:X}),Y)this.element.removeEventListener(this.name,this,X);if(Z)this.element.addEventListener(this.name,this,J);this._$committedValue=J}handleEvent(J){if(typeof this._$committedValue==="function")this._$committedValue.call(this.options?.host??this.element,J);else this._$committedValue.handleEvent(J)}}class KJ{constructor(J,W,X){this.element=J,this.type=t,this._$disconnectableChildren=void 0,this._$parent=W,this.options=X}get _$isConnected(){return this._$parent._$isConnected}_$setValue(J){H&&H({kind:"commit to element binding",element:this.element,value:J,options:this.options}),T(this,J)}}var sJ=j.litHtmlPolyfillSupportDevMode;sJ?.(k,y);(j.litHtmlVersions??=[]).push("3.3.1");if(j.litHtmlVersions.length>1)queueMicrotask(()=>{w("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")});var D=(J,W,X)=>{if(W==null)throw TypeError(`The container to render into may not be ${W}`);let Y=IJ++,Z=X?.renderBefore??W,$=Z._$litPart$;if(H&&H({kind:"begin render",id:Y,value:J,container:W,options:X,part:$}),$===void 0){let q=X?.renderBefore??null;Z._$litPart$=$=new y(W.insertBefore(x(),q),q,void 0,X??{})}return $._$setValue(J),H&&H({kind:"end render",id:Y,value:J,container:W,options:X,part:$}),$};D.setSanitizer=CJ,D.createSanitizer=l,D._testOnlyClearSanitizerFactoryDoNotCallOrElse=hJ;var JJ={};YJ(JJ,{isTemplateResult:()=>P,deserializeCSS:()=>C,callAsync:()=>m});function m(J,W,...X){try{let Y=J.apply(W,X);return Y instanceof Promise?Y:Promise.resolve(Y)}catch(Y){return Promise.reject(Y)}}function P(J){return J!==null&&typeof J==="object"&&"_$litType$"in J}function C(J,W="",X=0){let Y=Object.keys(J),Z="";for(let $ of Y){let q=J[$];if(typeof q==="object"&&q!==null){if(W&&!$.startsWith("@"))if($.startsWith("&"))Z+=`${$.replace(/&/g,W)} {
|
|
16
|
+
`),Error(X)}return ZJ!==void 0?ZJ.createHTML(W):W}var iJ=(J,W)=>{let X=J.length-1,Y=[],Z=W===c?"<svg>":W===g?"<math>":"",$,q=h;for(let Q=0;Q<X;Q++){let F=J[Q],B=-1,_,K=0,M;while(K<F.length){if(q.lastIndex=K,M=q.exec(F),M===null)break;if(K=q.lastIndex,q===h){if(M[$J]==="!--")q=qJ;else if(M[$J]!==void 0)q=GJ;else if(M[s]!==void 0){if(zJ.test(M[s]))$=new RegExp(`</${M[s]}`,"g");q=R}else if(M[yJ]!==void 0)throw Error("Bindings in tag names are not supported. Please use static templates instead. See https://lit.dev/docs/templates/expressions/#static-expressions")}else if(q===R)if(M[dJ]===">")q=$??h,B=-1;else if(M[QJ]===void 0)B=-2;else B=q.lastIndex-M[mJ].length,_=M[QJ],q=M[BJ]===void 0?R:M[BJ]==='"'?r:o;else if(q===r||q===o)q=R;else if(q===qJ||q===GJ)q=h;else q=R,$=void 0}console.assert(B===-1||q===R||q===o||q===r,"unexpected parse state B");let A=q===R&&J[Q+1].startsWith("/>")?" ":"";Z+=q===h?F+wJ:B>=0?(Y.push(_),F.slice(0,B)+FJ+F.slice(B))+S+A:F+S+(B===-2?Q:A)}let G=Z+(J[X]||"<?>")+(W===c?"</svg>":W===g?"</math>":"");return[fJ(J,G),Y]};class k{constructor({strings:J,["_$litType$"]:W},X){this.parts=[];let Y,Z=0,$=0,q=J.length-1,G=this.parts,[Q,F]=iJ(J,W);if(this.el=k.createElement(Q,X),E.currentNode=this.el.content,W===c||W===g){let B=this.el.content.firstChild;B.replaceWith(...B.childNodes)}while((Y=E.nextNode())!==null&&G.length<q){if(Y.nodeType===1){{let B=Y.localName;if(/^(?:textarea|template)$/i.test(B)&&Y.innerHTML.includes(S)){let _=`Expressions are not supported inside \`${B}\` elements. See https://lit.dev/msg/expression-in-${B} for more information.`;if(B==="template")throw Error(_);else w("",_)}}if(Y.hasAttributes()){for(let B of Y.getAttributeNames())if(B.endsWith(FJ)){let _=F[$++],M=Y.getAttribute(B).split(S),A=/([.?@])?(.*)/.exec(_);G.push({type:a,index:Z,name:A[2],strings:M,ctor:A[1]==="."?OJ:A[1]==="?"?SJ:A[1]==="@"?DJ:d}),Y.removeAttribute(B)}else if(B.startsWith(S))G.push({type:t,index:Z}),Y.removeAttribute(B)}if(zJ.test(Y.tagName)){let B=Y.textContent.split(S),_=B.length-1;if(_>0){Y.textContent=v?v.emptyScript:"";for(let K=0;K<_;K++)Y.append(B[K],x()),E.nextNode(),G.push({type:p,index:++Z});Y.append(B[_],x())}}}else if(Y.nodeType===8)if(Y.data===UJ)G.push({type:p,index:Z});else{let _=-1;while((_=Y.data.indexOf(S,_+1))!==-1)G.push({type:uJ,index:Z}),_+=S.length-1}Z++}if(F.length!==$)throw Error('Detected duplicate attribute bindings. This occurs if your template has duplicate attributes on an element tag. For example "<input ?disabled=${true} ?disabled=${false}>" contains a duplicate "disabled" attribute. The error was detected in the following template: \n`'+J.join("${...}")+"`");H&&H({kind:"template prep",template:this,clonableTemplate:this.el,parts:this.parts,strings:J})}static createElement(J,W){let X=N.createElement("template");return X.innerHTML=J,X}}function T(J,W,X=J,Y){if(W===L)return W;let Z=Y!==void 0?X.__directives?.[Y]:X.__directive,$=b(W)?void 0:W._$litDirective$;if(Z?.constructor!==$){if(Z?._$notifyDirectiveConnectionChanged?.(!1),$===void 0)Z=void 0;else Z=new $(J),Z._$initialize(J,X,Y);if(Y!==void 0)(X.__directives??=[])[Y]=Z;else X.__directive=Z}if(Z!==void 0)W=T(J,Z._$resolve(J,W.values),Z,Y);return W}class jJ{constructor(J,W){this._$parts=[],this._$disconnectableChildren=void 0,this._$template=J,this._$parent=W}get parentNode(){return this._$parent.parentNode}get _$isConnected(){return this._$parent._$isConnected}_clone(J){let{el:{content:W},parts:X}=this._$template,Y=(J?.creationScope??N).importNode(W,!0);E.currentNode=Y;let Z=E.nextNode(),$=0,q=0,G=X[0];while(G!==void 0){if($===G.index){let Q;if(G.type===p)Q=new y(Z,Z.nextSibling,this,J);else if(G.type===a)Q=new G.ctor(Z,G.name,G.strings,this,J);else if(G.type===t)Q=new KJ(Z,this,J);this._$parts.push(Q),G=X[++q]}if($!==G?.index)Z=E.nextNode(),$++}return E.currentNode=N,Y}_update(J){let W=0;for(let X of this._$parts){if(X!==void 0)if(H&&H({kind:"set part",part:X,value:J[W],valueIndex:W,values:J,templateInstance:this}),X.strings!==void 0)X._$setValue(J,X,W),W+=X.strings.length-2;else X._$setValue(J[W]);W++}}}class y{get _$isConnected(){return this._$parent?._$isConnected??this.__isConnected}constructor(J,W,X,Y){this.type=p,this._$committedValue=U,this._$disconnectableChildren=void 0,this._$startNode=J,this._$endNode=W,this._$parent=X,this.options=Y,this.__isConnected=Y?.isConnected??!0,this._textSanitizer=void 0}get parentNode(){let J=O(this._$startNode).parentNode,W=this._$parent;if(W!==void 0&&J?.nodeType===11)J=W.parentNode;return J}get startNode(){return this._$startNode}get endNode(){return this._$endNode}_$setValue(J,W=this){if(this.parentNode===null)throw Error("This `ChildPart` has no `parentNode` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's `innerHTML` or `textContent` can do this.");if(J=T(this,J,W),b(J)){if(J===U||J==null||J===""){if(this._$committedValue!==U)H&&H({kind:"commit nothing to child",start:this._$startNode,end:this._$endNode,parent:this._$parent,options:this.options}),this._$clear();this._$committedValue=U}else if(J!==this._$committedValue&&J!==L)this._commitText(J)}else if(J._$litType$!==void 0)this._commitTemplateResult(J);else if(J.nodeType!==void 0){if(this.options?.host===J){this._commitText("[probable mistake: rendered a template's host in itself (commonly caused by writing ${this} in a template]"),console.warn("Attempted to render the template host",J,"inside itself. This is almost always a mistake, and in dev mode ","we render some warning text. In production however, we'll ","render it, which will usually result in an error, and sometimes ","in the element disappearing from the DOM.");return}this._commitNode(J)}else if(xJ(J))this._commitIterable(J);else this._commitText(J)}_insert(J){return O(O(this._$startNode).parentNode).insertBefore(J,this._$endNode)}_commitNode(J){if(this._$committedValue!==J){if(this._$clear(),P!==u){let W=this._$startNode.parentNode?.nodeName;if(W==="STYLE"||W==="SCRIPT"){let X="Forbidden";if(W==="STYLE")X="Lit does not support binding inside style nodes. This is a security risk, as style injection attacks can exfiltrate data and spoof UIs. Consider instead using css`...` literals to compose styles, and do dynamic styling with css custom properties, ::parts, <slot>s, and by mutating the DOM rather than stylesheets.";else X="Lit does not support binding inside script nodes. This is a security risk, as it could allow arbitrary code execution.";throw Error(X)}}H&&H({kind:"commit node",start:this._$startNode,parent:this._$parent,value:J,options:this.options}),this._$committedValue=this._insert(J)}}_commitText(J){if(this._$committedValue!==U&&b(this._$committedValue)){let W=O(this._$startNode).nextSibling;if(this._textSanitizer===void 0)this._textSanitizer=l(W,"data","property");J=this._textSanitizer(J),H&&H({kind:"commit text",node:W,value:J,options:this.options}),W.data=J}else{let W=N.createTextNode("");if(this._commitNode(W),this._textSanitizer===void 0)this._textSanitizer=l(W,"data","property");J=this._textSanitizer(J),H&&H({kind:"commit text",node:W,value:J,options:this.options}),W.data=J}this._$committedValue=J}_commitTemplateResult(J){let{values:W,["_$litType$"]:X}=J,Y=typeof X==="number"?this._$getTemplate(J):(X.el===void 0&&(X.el=k.createElement(fJ(X.h,X.h[0]),this.options)),X);if(this._$committedValue?._$template===Y)H&&H({kind:"template updating",template:Y,instance:this._$committedValue,parts:this._$committedValue._$parts,options:this.options,values:W}),this._$committedValue._update(W);else{let Z=new jJ(Y,this),$=Z._clone(this.options);H&&H({kind:"template instantiated",template:Y,instance:Z,parts:Z._$parts,options:this.options,fragment:$,values:W}),Z._update(W),H&&H({kind:"template instantiated and updated",template:Y,instance:Z,parts:Z._$parts,options:this.options,fragment:$,values:W}),this._commitNode($),this._$committedValue=Z}}_$getTemplate(J){let W=HJ.get(J.strings);if(W===void 0)HJ.set(J.strings,W=new k(J));return W}_commitIterable(J){if(!n(this._$committedValue))this._$committedValue=[],this._$clear();let W=this._$committedValue,X=0,Y;for(let Z of J){if(X===W.length)W.push(Y=new y(this._insert(x()),this._insert(x()),this,this.options));else Y=W[X];Y._$setValue(Z),X++}if(X<W.length)this._$clear(Y&&O(Y._$endNode).nextSibling,X),W.length=X}_$clear(J=O(this._$startNode).nextSibling,W){this._$notifyConnectionChanged?.(!1,!0,W);while(J!==this._$endNode){let X=O(J).nextSibling;O(J).remove(),J=X}}setConnected(J){if(this._$parent===void 0)this.__isConnected=J,this._$notifyConnectionChanged?.(J);else throw Error("part.setConnected() may only be called on a RootPart returned from render().")}}class d{get tagName(){return this.element.tagName}get _$isConnected(){return this._$parent._$isConnected}constructor(J,W,X,Y,Z){if(this.type=a,this._$committedValue=U,this._$disconnectableChildren=void 0,this.element=J,this.name=W,this._$parent=Y,this.options=Z,X.length>2||X[0]!==""||X[1]!=="")this._$committedValue=Array(X.length-1).fill(new String),this.strings=X;else this._$committedValue=U;this._sanitizer=void 0}_$setValue(J,W=this,X,Y){let Z=this.strings,$=!1;if(Z===void 0){if(J=T(this,J,W,0),$=!b(J)||J!==this._$committedValue&&J!==L,$)this._$committedValue=J}else{let q=J;J=Z[0];let G,Q;for(G=0;G<Z.length-1;G++){if(Q=T(this,q[X+G],W,G),Q===L)Q=this._$committedValue[G];if($||=!b(Q)||Q!==this._$committedValue[G],Q===U)J=U;else if(J!==U)J+=(Q??"")+Z[G+1];this._$committedValue[G]=Q}}if($&&!Y)this._commitValue(J)}_commitValue(J){if(J===U)O(this.element).removeAttribute(this.name);else{if(this._sanitizer===void 0)this._sanitizer=P(this.element,this.name,"attribute");J=this._sanitizer(J??""),H&&H({kind:"commit attribute",element:this.element,name:this.name,value:J,options:this.options}),O(this.element).setAttribute(this.name,J??"")}}}class OJ extends d{constructor(){super(...arguments);this.type=cJ}_commitValue(J){if(this._sanitizer===void 0)this._sanitizer=P(this.element,this.name,"property");J=this._sanitizer(J),H&&H({kind:"commit property",element:this.element,name:this.name,value:J,options:this.options}),this.element[this.name]=J===U?void 0:J}}class SJ extends d{constructor(){super(...arguments);this.type=gJ}_commitValue(J){H&&H({kind:"commit boolean attribute",element:this.element,name:this.name,value:!!(J&&J!==U),options:this.options}),O(this.element).toggleAttribute(this.name,!!J&&J!==U)}}class DJ extends d{constructor(J,W,X,Y,Z){super(J,W,X,Y,Z);if(this.type=pJ,this.strings!==void 0)throw Error(`A \`<${J.localName}>\` has a \`@${W}=...\` listener with invalid content. Event listeners in templates must have exactly one expression and no surrounding text.`)}_$setValue(J,W=this){if(J=T(this,J,W,0)??U,J===L)return;let X=this._$committedValue,Y=J===U&&X!==U||J.capture!==X.capture||J.once!==X.once||J.passive!==X.passive,Z=J!==U&&(X===U||Y);if(H&&H({kind:"commit event listener",element:this.element,name:this.name,value:J,options:this.options,removeListener:Y,addListener:Z,oldListener:X}),Y)this.element.removeEventListener(this.name,this,X);if(Z)this.element.addEventListener(this.name,this,J);this._$committedValue=J}handleEvent(J){if(typeof this._$committedValue==="function")this._$committedValue.call(this.options?.host??this.element,J);else this._$committedValue.handleEvent(J)}}class KJ{constructor(J,W,X){this.element=J,this.type=t,this._$disconnectableChildren=void 0,this._$parent=W,this.options=X}get _$isConnected(){return this._$parent._$isConnected}_$setValue(J){H&&H({kind:"commit to element binding",element:this.element,value:J,options:this.options}),T(this,J)}}var sJ=j.litHtmlPolyfillSupportDevMode;sJ?.(k,y);(j.litHtmlVersions??=[]).push("3.3.1");if(j.litHtmlVersions.length>1)queueMicrotask(()=>{w("multiple-versions","Multiple versions of Lit loaded. Loading multiple versions is not recommended.")});var D=(J,W,X)=>{if(W==null)throw TypeError(`The container to render into may not be ${W}`);let Y=IJ++,Z=X?.renderBefore??W,$=Z._$litPart$;if(H&&H({kind:"begin render",id:Y,value:J,container:W,options:X,part:$}),$===void 0){let q=X?.renderBefore??null;Z._$litPart$=$=new y(W.insertBefore(x(),q),q,void 0,X??{})}return $._$setValue(J),H&&H({kind:"end render",id:Y,value:J,container:W,options:X,part:$}),$};D.setSanitizer=CJ,D.createSanitizer=l,D._testOnlyClearSanitizerFactoryDoNotCallOrElse=hJ;var JJ={};YJ(JJ,{isTemplateResult:()=>V,deserializeCSS:()=>C,callAsync:()=>m});function m(J,W,...X){try{let Y=J.apply(W,X);return Y instanceof Promise?Y:Promise.resolve(Y)}catch(Y){return Promise.reject(Y)}}function V(J){return J!==null&&typeof J==="object"&&"_$litType$"in J}function C(J,W="",X=0){let Y=Object.keys(J),Z="";for(let $ of Y){let q=J[$];if(typeof q==="object"&&q!==null){if(W&&!$.startsWith("@"))if($.startsWith("&"))Z+=`${$.replace(/&/g,W)} {
|
|
17
17
|
`;else Z+=`${W} ${$} {
|
|
18
18
|
`;else Z+=`${$} {
|
|
19
19
|
`;let G=Object.keys(q);for(let Q of G){Z+="\t".repeat(X);let F=q[Q];if(typeof F==="object"&&F!==null){let B={};B[Q]=F,Z+=C(B,W,X+1)}else Z+=` ${Q}: ${F};
|
|
20
20
|
`}Z+=`}
|
|
21
21
|
`}else Z+="\t".repeat(X),Z+=` ${$}: ${q};
|
|
22
|
-
`}return Z}class
|
|
22
|
+
`}return Z}class z extends HTMLElement{_children;_state;_props;_ready;_connected;_isReady;_style;_updatingProps;_renderId;_propsProxy;_stateProxy;_hasBeenMounted;static _tag;static _template;static _observedAttributes=[];static _onMount;static _onUnmount;static _onError;static _applyMiddleware;static _hasMiddleware;static get observedAttributes(){return this._observedAttributes}static set observedAttributes(J){this._observedAttributes=J}static get tag(){if(typeof this._tag>"u"){let J=this.name,W=J.match(/([A-Z])/g);if(W!==null)for(let X of W)J=J.replace(X,`-${X}`.toLowerCase());this._tag=J.slice(1)}return this._tag}static set tag(J){this._tag=J}static template(J=null,W=null){if(J!==null)this._template=J,document.querySelectorAll(this.tag).forEach((X)=>{if(X instanceof z&&X._isReady)X.forceRender()});else{if(typeof this._template==="function")return this._template.call(W,W);return this._template}}constructor(){super();this._children="",this._state={},this._props={},this._ready=[],this._connected=!1,this._isReady=!1,this._style={},this._updatingProps=!1,this._renderId=0,this._propsProxy=null,this._stateProxy=null,this._hasBeenMounted=!1}get width(){return parseInt(getComputedStyle(this).width.replace("px",""))}set width(J){this.style.width=typeof J==="number"?`${J}px`:J}get height(){return parseInt(getComputedStyle(this).height.replace("px",""))}set height(J){this.style.height=typeof J==="number"?`${J}px`:J}get static(){return this.constructor}set static(J){throw Error("Component static properties cannot be reassigned.")}get props(){if(!this._propsProxy)this._propsProxy=new Proxy(this._props,{get:(J,W)=>{if(W in J&&typeof J[W]<"u")return J[W];if(this.hasAttribute(W)){let X=this.getAttribute(W);if(typeof X==="string"){if(X==="false")X=!1;else if(X==="true"||X==="")X=!0;else if(!isNaN(Number(X)))X=X.includes(".")?parseFloat(X):parseInt(X)}return X}return},set:()=>{throw Error("Component props should be set using the `setProps` function.")}});return this._propsProxy}set props(J){if(!this._connected)this._props={...this._props,...J},this._propsProxy=null;else throw Error("Component props cannot be directly assigned. Use the `setProps` function instead.")}get state(){if(!this._stateProxy)this._stateProxy=new Proxy(this._state,{get:(J,W)=>J[W],set:(J,W,X)=>{if(!this._connected)return J[W]=X,!0;else throw Error("Component state should be set using the `setState` function instead.")}});return this._stateProxy}set state(J){if(!this._connected)this._state={...this._state,...J},this._stateProxy=null;else throw Error("Component state should be set using the `setState` function instead.")}get dom(){return this}set dom(J){throw Error("Component DOM can not be overwritten.")}get slotContent(){return this._children}get isConnected(){return this._connected}get isReady(){return this._isReady}get isFirstMount(){return!this._hasBeenMounted}static register(){window.customElements.define(this.tag,this)}template(J=null){return this.constructor.template(J,this)}static _styleSheet=null;setStyle(J,W=!1){let X=this.constructor;if(!X._styleSheet)X._styleSheet=new CSSStyleSheet;let Y="";if(typeof J==="object"){if(!W)this._style={...this._style,...J};else this._style={...J};Y=C(this._style,X.tag)}else if(typeof J==="string")if(!W)Y=Array.from(X._styleSheet.cssRules||[]).map(($)=>$.cssText).join(`
|
|
23
23
|
`)+`
|
|
24
|
-
`+J;else Y=J;if(X._styleSheet.replaceSync(Y),!document.adoptedStyleSheets.includes(X._styleSheet))document.adoptedStyleSheets=[...document.adoptedStyleSheets,X._styleSheet];return this._style}setState(J){let W=J;if(
|
|
24
|
+
`+J;else Y=J;if(X._styleSheet.replaceSync(Y),!document.adoptedStyleSheets.includes(X._styleSheet))document.adoptedStyleSheets=[...document.adoptedStyleSheets,X._styleSheet];return this._style}setState(J){let W=J;if(z._hasMiddleware?.("state")&&z._applyMiddleware)W=z._applyMiddleware("state",this,J);let X={...this._state};this._state={...this._state,...W},this._stateProxy=null;for(let Y of Object.keys(W))this.updateCallback(Y,X[Y],this._state[Y],"state",X,this._state)}setProps(J){let W=J;if(z._hasMiddleware?.("props")&&z._applyMiddleware)W=z._applyMiddleware("props",this,J);let X={...this._props};this._props={...this._props,...W},this._propsProxy=null;for(let Y of Object.keys(W))this.updateCallback(Y,X[Y],this._props[Y],"props",X,this._props);this._updatingProps=!0,this._setPropAttributes(!0),this._updatingProps=!1}_setPropAttributes(J=!1){for(let[W,X]of Object.entries(this._props)){let Y=typeof X;if(Y==="string"||Y==="number"||Y==="boolean")if(J)this.setAttribute(W,String(X));else this._props[W]=this.props[W],this.setAttribute(W,String(this.props[W]))}}on(J,W,X){return this.addEventListener(J,W,X),this}off(J,W,X){return this.removeEventListener(J,W,X),this}once(J,W,X){let Y=typeof X==="boolean"?{capture:X,once:!0}:{...X,once:!0};return this.addEventListener(J,W,Y),this}emit(J,W,X){let Y=new CustomEvent(J,{detail:W,bubbles:!0,cancelable:!0,composed:!0,...X});return this.dispatchEvent(Y)}query(J){return this.dom.querySelector(J)}queryAll(J){return this.dom.querySelectorAll(J)}async willUpdate(J,W,X,Y,Z,$){}async update(J,W,X,Y,Z,$){}async didUpdate(J,W,X,Y,Z,$){}async onStateUpdate(J,W,X,Y,Z){}async onPropsUpdate(J,W,X,Y,Z){}async willMount(){}async didMount(){}async didReconnect(){}async willUnmount(){}async unmount(){}async didUnmount(){}forceRender(){return this._render()}render(){return""}async _render(){let J=++this._renderId,W=this.render;if(this.constructor._template!==void 0)W=()=>this.template();let X=await m(W,this);if(J!==this._renderId)return;let Y=V(X)||X===U?"lit":"string";if(z._hasMiddleware?.("render")&&z._applyMiddleware)X=z._applyMiddleware("render",this,X,Y);if(V(X)||X===U){if(!this.hasAttribute("data-lit-rendered"))this.innerHTML="",this.setAttribute("data-lit-rendered","");D(X,this,{host:this});return}let Z=X.trim();if(Z==="")return;let $=this.dom.querySelector("slot");if($!==null){let q=document.createElement("template");q.innerHTML=Z,$.replaceWith(q.content)}else if(this.innerHTML=Z,this._children!==""&&Z.indexOf(this._children)===-1)this.innerHTML+=this._children}async connectedCallback(){let J=this.static.tag;try{if(this._connected=!0,this.dataset.component=J,typeof this.static._template>"u"){let Y=document.querySelector(`template#${J}`);if(Y!==null)this.template(Y.innerHTML);else this.static._template=void 0}let W=!this._hasBeenMounted;if(W)this._children=this.innerHTML.trim();if(this._setPropAttributes(!1),await this.willMount(),await this._render(),W)await this.didMount();else await this.didReconnect();this._isReady=!0,this._hasBeenMounted=!0;let X=[...this._ready];this._ready=[];for(let Y of X)Y.call(this);if(z._onMount)z._onMount(this,J)}catch(W){if(z._onError)z._onError(W,this,J,"connectedCallback");else throw W}}ready(J){if(this._isReady)J.call(this);else this._ready.push(J)}async disconnectedCallback(){let J=this.static.tag;try{if(await this.willUnmount(),await this.unmount(),await this.didUnmount(),this._connected=!1,this._isReady=!1,this._ready=[],z._onUnmount)z._onUnmount(this,J)}catch(W){if(z._onError)z._onError(W,this,J,"disconnectedCallback");else throw W}}async updateCallback(J,W,X,Y="props",Z={},$={}){if(await this.willUpdate(Y,J,W,X,Z,$),await this.update(Y,J,W,X,Z,$),Y==="state")await this.onStateUpdate(J,W,X,Z,$);else if(Y==="props"||Y==="attribute")await this.onPropsUpdate(J,W,X,Z,$);await this.didUpdate(Y,J,W,X,Z,$)}attributeChangedCallback(J,W,X){if(W!==X&&!this._updatingProps)this.updateCallback(J,W,X,"attribute")}}var f=z;class RJ extends f{_shadowDOM;static _styleSheet=null;constructor(){super();this._shadowDOM=this.attachShadow({mode:"open"})}setStyle(J,W=!1){let X=this.constructor;if(!X._styleSheet)X._styleSheet=new CSSStyleSheet;let Y="";if(typeof J==="object"){if(!W)this._style={...this._style,...J};else this._style={...J};Y=C(this._style)}else if(typeof J==="string")if(!W)Y=Array.from(X._styleSheet.cssRules||[]).map(($)=>$.cssText).join(`
|
|
25
25
|
`)+`
|
|
26
|
-
`+J;else Y=J;return X._styleSheet.replaceSync(Y),this._shadowDOM.adoptedStyleSheets=[X._styleSheet],this._style}async _render(){let J=this.render;if(this.constructor._template!==void 0)
|
|
26
|
+
`+J;else Y=J;return X._styleSheet.replaceSync(Y),this._shadowDOM.adoptedStyleSheets=[X._styleSheet],this._style}async _render(){let J=++this._renderId,W=this.render;if(this.constructor._template!==void 0)W=()=>this.template();let X=await m(W,this);if(J!==this._renderId)return;let Y=V(X)||X===U?"lit":"string";if(f._hasMiddleware?.("render")&&f._applyMiddleware)X=f._applyMiddleware("render",this,X,Y);if(V(X)||X===U){D(X,this._shadowDOM,{host:this});return}let Z=X.trim(),$=Array.from(this._shadowDOM.childNodes);for(let G of $)G.remove();if(Z==="")return;let q=document.createElement("template");q.innerHTML=Z,this._shadowDOM.appendChild(q.content)}get dom(){throw Error("ShadowComponent DOM can not be accessed. Use the `shadowRoot` property instead.")}set dom(J){throw Error("ShadowComponent DOM can not be overwritten.")}get shadowRoot(){return this._shadowDOM}set shadowRoot(J){throw Error("ShadowComponent shadowRoot can not be overwritten.")}query(J){return this._shadowDOM.querySelector(J)}queryAll(J){return this._shadowDOM.querySelectorAll(J)}}var AJ=RJ;class WJ{static _debug=!1;static components={};static implementations={};static state={};static subscribers={};static mountCallbacks=new Set;static unmountCallbacks=new Set;static errorCallbacks=new Set;static aliases={};static lazyLoaders={};static middleware={props:new Set,state:new Set,render:new Set};static _initialized=!1;static _init(){if(this._initialized)return;this._initialized=!0,f._onMount=(J,W)=>this._notifyMount(J,W),f._onUnmount=(J,W)=>this._notifyUnmount(J,W),f._onError=(J,W,X,Y)=>this._notifyError(J,W,X,Y),f._applyMiddleware=(J,W,X,Y)=>this._applyMiddleware(J,W,X,Y),f._hasMiddleware=(J)=>this._hasMiddleware(J)}static register(J,W){if(this._init(),typeof this.components[J]>"u")this.components[J]=W,this.implementations[J]=W,W._tag=J,window.customElements.define(J,W),this.components[J]._registered=!0,this.log(`Registered: <${J}>`);else throw Error("A component with this tag has already been registered. Use the evolve() function to modify the component.")}static getImplementation(J){return this.implementations[J]||this.components[J]}static evolve(J,W,X=!1){if(typeof this.components[J]>"u")throw Error("No component with this tag has been registered. Cannot Evolve.");if(this.implementations[J]=W,W._registered=!0,this.log(`Evolved: <${J}>`),X){let Y=W.prototype,Z=Object.getOwnPropertyNames(Y),$={};try{$=Reflect.construct(W,[],W)}catch(q){this.log(`Could not extract defaults for <${J}> during evolve:`,q)}document.querySelectorAll(J).forEach((q)=>{if(q instanceof f&&q.isReady){let G=q;for(let Q of Z)if(Q!=="constructor"&&typeof Y[Q]==="function"){let F=Y[Q];G[Q]=F.bind(q)}if($._state){let Q=G._state||{},F=$._state;for(let B of Object.keys(F))if(!(B in Q))Q[B]=F[B];G._state=Q}if($._props){let Q=G._props||{},F=$._props;for(let B of Object.keys(F))if(!(B in Q))Q[B]=F[B];G._props=Q}q.forceRender()}})}}static instances(J,W){if(typeof this.components[J]<"u")if(typeof W==="function")document.querySelectorAll(J).forEach(W);else return document.querySelectorAll(J);else throw Error("No component with the provided tag has been registered.")}static instantiate(J,W){if(!this.has(J))throw Error(`No component with tag "${J}" has been registered.`);if(!this.components[J]._registered)this.register(J,this.components[J]);let X=document.createElement(this.components[J].tag);return X.setProps(W),X}static has(J){return typeof this.components[J]<"u"}static get(J){return this.components[J]}static setState(J,W){let X=this.state[J];if(this.state[J]=W,this.subscribers[J])this.subscribers[J].forEach((Y)=>{Y(W,X)})}static getState(J){return this.state[J]}static hasState(J){return J in this.state}static deleteState(J){if(J in this.state){let W=this.state[J];if(delete this.state[J],this.subscribers[J])this.subscribers[J].forEach((X)=>{X(void 0,W)});return!0}return!1}static subscribe(J,W){if(!this.subscribers[J])this.subscribers[J]=new Set;return this.subscribers[J].add(W),()=>{this.unsubscribe(J,W)}}static unsubscribe(J,W){if(this.subscribers[J])this.subscribers[J].delete(W)}static getAllState(){return{...this.state}}static clearState(){let J=Object.keys(this.state);for(let W of J)this.deleteState(W)}static get debug(){return this._debug}static set debug(J){this._debug=J}static log(J,W){if(this._debug)if(W!==void 0)console.log(`[Pandora] ${J}`,W);else console.log(`[Pandora] ${J}`)}static list(){return Object.keys(this.components)}static stats(J){if(J){if(!this.has(J))throw Error(`No component with tag "${J}" has been registered.`);return{tag:J,instanceCount:document.querySelectorAll(J).length,isRegistered:this.components[J]?._registered??!1,isLazy:J in this.lazyLoaders}}return this.list().map((W)=>({tag:W,instanceCount:document.querySelectorAll(W).length,isRegistered:this.components[W]?._registered??!1,isLazy:W in this.lazyLoaders}))}static onMount(J){return this._init(),this.mountCallbacks.add(J),()=>this.mountCallbacks.delete(J)}static onUnmount(J){return this._init(),this.unmountCallbacks.add(J),()=>this.unmountCallbacks.delete(J)}static _notifyMount(J,W){this.log(`Mounted: <${W}>`),this.mountCallbacks.forEach((X)=>{try{X(J,W)}catch(Y){console.error("[Pandora] Error in onMount callback:",Y)}})}static _notifyUnmount(J,W){this.log(`Unmounted: <${W}>`),this.unmountCallbacks.forEach((X)=>{try{X(J,W)}catch(Y){console.error("[Pandora] Error in onUnmount callback:",Y)}})}static onError(J){return this._init(),this.errorCallbacks.add(J),()=>this.errorCallbacks.delete(J)}static _notifyError(J,W,X,Y){if(this.log(`Error in <${X}> during ${Y}:`,J),this.errorCallbacks.size===0)throw J;this.errorCallbacks.forEach((Z)=>{try{Z(J,W,X,Y)}catch($){console.error("[Pandora] Error in onError callback:",$)}})}static alias(J,W){if(!this.has(W))throw Error(`Cannot create alias: no component with tag "${W}" has been registered.`);if(this.has(J))throw Error(`Cannot create alias: a component with tag "${J}" already exists.`);this.aliases[J]=W;let X=this.components[W],Y=class extends X{static _tag=J};this.components[J]=Y,window.customElements.define(J,Y),this.log(`Created alias: <${J}> -> <${W}>`)}static getOriginalTag(J){return this.aliases[J]}static isAlias(J){return J in this.aliases}static lazy(J,W){if(this._init(),this.has(J))throw Error(`Cannot register lazy component: a component with tag "${J}" already exists.`);this.lazyLoaders[J]=W;let X=WJ;class Y extends f{static _tag=J;_lazyLoaded=!1;async connectedCallback(){await X._loadLazyComponent(J);let Z=X.getImplementation(J);if(Z&&Z!==Y){let $=Z.prototype,q=Object.getOwnPropertyNames($),G=this;for(let F of q)if(F!=="constructor"&&typeof $[F]==="function"){let B=$[F];G[F]=B.bind(this)}let Q={};try{Q=Reflect.construct(Z,[],Z)}catch(F){X.log(`Could not extract defaults for lazy <${J}>:`,F)}if(Q._state)G._state={...Q._state};if(Q._props)G._props={...Q._props};this._lazyLoaded=!0}await super.connectedCallback()}}this.components[J]=Y,window.customElements.define(J,Y),this.log(`Registered lazy component: <${J}>`)}static async _loadLazyComponent(J){if(!(J in this.lazyLoaders))return;let W=this.lazyLoaders[J];this.log(`Loading lazy component: <${J}>`);try{let X=await W(),Y="default"in X?X.default:X;delete this.lazyLoaders[J],this.implementations[J]=Y,Y._registered=!0,this.log(`Loaded lazy component: <${J}>`)}catch(X){throw console.error(`[Pandora] Failed to load lazy component <${J}>:`,X),X}}static isLazy(J){return J in this.lazyLoaders}static async preload(J){if(this.isLazy(J))await this._loadLazyComponent(J)}static use(J,W){return this._init(),this.middleware[J].add(W),()=>this.middleware[J].delete(W)}static _applyMiddleware(J,W,X,Y){let Z=X;return this.middleware[J].forEach(($)=>{try{Z=$(W,Z,Y)}catch(q){console.error(`[Pandora] Error in ${J} middleware:`,q)}}),Z}static _hasMiddleware(J){return this.middleware[J].size>0}}var I=WJ;function EJ(J){return function(W){return I.register(J,W),W}}function NJ(J){return function(W,X){let{connectedCallback:Y,disconnectedCallback:Z}=W,$=Symbol(`__pandora_unsub_${X}`),q=Symbol(`__pandora_value_${X}`);W.connectedCallback=async function(){this[$]=I.subscribe(J,(Q)=>{if(this[q]===Q)return;if(this[q]=Q,this._isReady)this.forceRender()});let G=I.getState(J);if(G!==void 0)this[q]=G;if(Y)await Y.call(this)},W.disconnectedCallback=async function(){if(this[$])this[$](),this[$]=void 0;if(Z)await Z.call(this)},Object.defineProperty(W,X,{get:function(){return this[q]},set:function(G){if(this[q]===G)return;if(this[q]=G,I.setState(J,G),this._isReady)this.forceRender()},enumerable:!0,configurable:!0})}}function LJ(J){return function(W,X){let Y=J||X,Z=Symbol(`__pandora_prop_${X}`);if(!Object.hasOwn(W.constructor,"_observedAttributes"))W.constructor._observedAttributes=[];if(!W.constructor._observedAttributes.includes(Y))W.constructor._observedAttributes.push(Y);Object.defineProperty(W,X,{get:function(){if(this[Z]!==void 0)return this[Z];if(this.hasAttribute(Y)){let $=this.getAttribute(Y);return oJ($)}return},set:function($){if(this[Z]=$,typeof $==="string"||typeof $==="number"||typeof $==="boolean")if(typeof $==="boolean")if($)this.setAttribute(Y,"");else this.removeAttribute(Y);else this.setAttribute(Y,String($))},enumerable:!0,configurable:!0})}}function oJ(J){if(J===null)return;if(J===""||J==="true")return!0;if(J==="false")return!1;if(!isNaN(Number(J)))return J.includes(".")?parseFloat(J):parseInt(J,10);return J}var PJ={};if(typeof window==="object")window.Pandora=XJ;
|
|
27
27
|
|
|
28
|
-
//# debugId=
|
|
28
|
+
//# debugId=17AC6359CB048CB664756E2164756E21
|
|
29
29
|
//# sourceMappingURL=pandora.browser.js.map
|