@aegis-framework/pandora 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Pandora
2
2
 
3
- Pandora is a lightweight Web Components library that allows you to create simple and reusable custom HTML elements with reactive state management, lifecycle hooks, and Shadow DOM support.
3
+ Pandora is a lightweight Web Components library that allows you to create simple and reusable custom HTML elements with reactive state management, lifecycle hooks, and Shadow DOM support. It includes built-in [lit-html](https://lit.dev/docs/libraries/standalone-templates/) integration for efficient DOM updates.
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,11 +10,14 @@ npm install @aegis-framework/pandora
10
10
 
11
11
  # Using yarn
12
12
  yarn add @aegis-framework/pandora
13
+
14
+ # Using bun
15
+ bun add @aegis-framework/pandora
13
16
  ```
14
17
 
15
18
  ## Quick Start
16
19
 
17
- ### Basic Component
20
+ ### Basic Component (String Templates)
18
21
 
19
22
  ```javascript
20
23
  import { Component } from '@aegis-framework/pandora';
@@ -38,6 +41,25 @@ console.log(CustomElement.tag); // 'custom-element'
38
41
  window.customElements.define(CustomElement.tag, CustomElement);
39
42
  ```
40
43
 
44
+ ### Basic Component (lit-html Templates)
45
+
46
+ For better performance with frequent updates, use lit-html's tagged templates:
47
+
48
+ ```javascript
49
+ import { Component, html } from '@aegis-framework/pandora';
50
+
51
+ class CustomElement extends Component {
52
+ constructor() {
53
+ super();
54
+ this.props = { text: '' };
55
+ }
56
+
57
+ render() {
58
+ return html`<h2>${this.props.text}</h2>`;
59
+ }
60
+ }
61
+ ```
62
+
41
63
  Using it in the HTML:
42
64
 
43
65
  ```html
@@ -49,7 +71,7 @@ Using it in the HTML:
49
71
  Pandora supports generic types for props and state:
50
72
 
51
73
  ```typescript
52
- import { Component } from '@aegis-framework/pandora';
74
+ import { Component, html } from '@aegis-framework/pandora';
53
75
 
54
76
  interface MyProps {
55
77
  name: string;
@@ -73,7 +95,7 @@ class TypedComponent extends Component<MyProps, MyState> {
73
95
  }
74
96
 
75
97
  render() {
76
- return `
98
+ return html`
77
99
  <div class="${this.state.active ? 'active' : ''}">
78
100
  <h2>${this.props.name}</h2>
79
101
  <span>Count: ${this.props.count}</span>
@@ -83,6 +105,33 @@ class TypedComponent extends Component<MyProps, MyState> {
83
105
  }
84
106
  ```
85
107
 
108
+ ### Using Decorators
109
+
110
+ Pandora provides decorators for cleaner component registration and state binding:
111
+
112
+ ```typescript
113
+ import { Component, Register, Consumer, Prop, html } from '@aegis-framework/pandora';
114
+
115
+ @Register('my-counter')
116
+ class MyCounter extends Component {
117
+ @Prop()
118
+ initialCount: number = 0;
119
+
120
+ @Consumer('app.theme')
121
+ theme!: string;
122
+
123
+ state = { count: 0 };
124
+
125
+ render() {
126
+ return html`
127
+ <div class="theme-${this.theme}">
128
+ Count: ${this.state.count}
129
+ </div>
130
+ `;
131
+ }
132
+ }
133
+ ```
134
+
86
135
  ## Components
87
136
 
88
137
  ### Component
@@ -114,10 +163,10 @@ class MyComponent extends Component {
114
163
 
115
164
  ### ShadowComponent
116
165
 
117
- A component that uses Shadow DOM for style encapsulation.
166
+ A component that uses Shadow DOM for style encapsulation. ShadowComponent uses [Constructable Stylesheets](https://web.dev/constructable-stylesheets/) for high-performance styling - styles are shared across all instances of the same component class and updates use `replaceSync()` for fast synchronous changes.
118
167
 
119
168
  ```javascript
120
- import { ShadowComponent } from '@aegis-framework/pandora';
169
+ import { ShadowComponent, html } from '@aegis-framework/pandora';
121
170
 
122
171
  class MyShadowComponent extends ShadowComponent {
123
172
  constructor() {
@@ -128,6 +177,7 @@ class MyShadowComponent extends ShadowComponent {
128
177
  willMount() {
129
178
  // Set scoped styles
130
179
  this.setStyle({
180
+ ':host': { display: 'block' },
131
181
  h2: { color: 'blue' }
132
182
  });
133
183
 
@@ -135,7 +185,8 @@ class MyShadowComponent extends ShadowComponent {
135
185
  }
136
186
 
137
187
  render() {
138
- return `<h2>${this.props.text}</h2>`;
188
+ // Can use string templates or lit-html
189
+ return html`<h2>${this.props.text}</h2>`;
139
190
  }
140
191
  }
141
192
  ```
@@ -156,6 +207,7 @@ class MyShadowComponent extends ShadowComponent {
156
207
  | `props` | `object` | Component properties (read via proxy) |
157
208
  | `state` | `object` | Internal component state |
158
209
  | `dom` | `HTMLElement` | Reference to the component's DOM |
210
+ | `slotContent` | `string` | Original innerHTML content before rendering (for content projection) |
159
211
  | `width` | `number` | Computed width in pixels |
160
212
  | `height` | `number` | Computed height in pixels |
161
213
  | `isConnected` | `boolean` | Whether the component is connected to the DOM |
@@ -282,7 +334,8 @@ You can use HTML templates instead of the render method:
282
334
  ```html
283
335
  <template id="my-component">
284
336
  <div class="wrapper">
285
- <slot></slot>
337
+ <!-- For light DOM components, use slotContent in render() instead -->
338
+ <!-- For ShadowComponent, use native <slot> -->
286
339
  </div>
287
340
  </template>
288
341
  ```
@@ -290,18 +343,240 @@ You can use HTML templates instead of the render method:
290
343
  Or set templates programmatically:
291
344
 
292
345
  ```javascript
346
+ // String template
293
347
  MyComponent.template(`
294
348
  <div class="wrapper">
295
349
  <h2>{{title}}</h2>
296
350
  </div>
297
351
  `);
298
352
 
299
- // Or with a function for dynamic templates
353
+ // Function returning string
300
354
  MyComponent.template((context) => `
301
355
  <div class="wrapper">
302
356
  <h2>${context.props.title}</h2>
303
357
  </div>
304
358
  `);
359
+
360
+ // Function returning lit-html (recommended for dynamic content)
361
+ import { html } from '@aegis-framework/pandora';
362
+
363
+ MyComponent.template((context) => html`
364
+ <div class="wrapper">
365
+ <h2>${context.props.title}</h2>
366
+ <button @click=${() => context.handleClick()}>Click me</button>
367
+ </div>
368
+ `);
369
+ ```
370
+
371
+ ## lit-html Integration
372
+
373
+ 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.
374
+
375
+ ### Exports
376
+
377
+ ```javascript
378
+ import {
379
+ // Tagged template functions
380
+ html, // For HTML templates
381
+ svg, // For SVG templates
382
+
383
+ // Special values
384
+ nothing, // Render nothing
385
+ noChange, // Skip updating a value
386
+
387
+ // Manual rendering (rarely needed)
388
+ render,
389
+
390
+ // Types (TypeScript)
391
+ TemplateResult,
392
+ SVGTemplateResult,
393
+ RenderOptions
394
+ } from '@aegis-framework/pandora';
395
+ ```
396
+
397
+ ### String vs lit-html Templates
398
+
399
+ Both rendering modes work seamlessly. Use strings for simple components, lit-html for complex UIs:
400
+
401
+ ```javascript
402
+ // String template (simple, familiar)
403
+ render() {
404
+ return `<div>${this.props.name}</div>`;
405
+ }
406
+
407
+ // lit-html template (efficient updates, event binding)
408
+ render() {
409
+ return html`
410
+ <div>
411
+ ${this.props.name}
412
+ <button @click=${() => this.handleClick()}>Click</button>
413
+ </div>
414
+ `;
415
+ }
416
+ ```
417
+
418
+ ### lit-html Features
419
+
420
+ When using `html` templates, you get access to lit-html features:
421
+
422
+ ```javascript
423
+ import { html, nothing } from '@aegis-framework/pandora';
424
+
425
+ class MyComponent extends Component {
426
+ render() {
427
+ return html`
428
+ <!-- Conditional rendering -->
429
+ ${this.state.show ? html`<div>Visible</div>` : nothing}
430
+
431
+ <!-- List rendering -->
432
+ <ul>
433
+ ${this.state.items.map(item => html`<li>${item}</li>`)}
434
+ </ul>
435
+
436
+ <!-- Event binding -->
437
+ <button @click=${(e) => this.handleClick(e)}>Click</button>
438
+
439
+ <!-- Property binding -->
440
+ <input .value=${this.state.name}>
441
+
442
+ <!-- Boolean attributes -->
443
+ <button ?disabled=${this.state.loading}>Submit</button>
444
+ `;
445
+ }
446
+ }
447
+ ```
448
+
449
+ ### Content Projection with slotContent
450
+
451
+ Use the `slotContent` property to include the original innerHTML in your templates:
452
+
453
+ ```html
454
+ <!-- Usage -->
455
+ <my-card>
456
+ <h3>Card Title</h3>
457
+ <p>Card content goes here.</p>
458
+ </my-card>
459
+ ```
460
+
461
+ ```javascript
462
+ class MyCard extends Component {
463
+ render() {
464
+ // String template
465
+ return `
466
+ <div class="card">
467
+ <div class="card-body">
468
+ ${this.slotContent}
469
+ </div>
470
+ </div>
471
+ `;
472
+ }
473
+ }
474
+
475
+ // Or with lit-html
476
+ class MyCard extends Component {
477
+ render() {
478
+ return html`
479
+ <div class="card">
480
+ <div class="card-body">
481
+ ${this.slotContent}
482
+ </div>
483
+ </div>
484
+ `;
485
+ }
486
+ }
487
+ ```
488
+
489
+ > **Note:** For ShadowComponent, use the native `<slot>` element instead of `slotContent` for proper Shadow DOM content projection.
490
+
491
+ ## Decorators
492
+
493
+ Pandora provides TypeScript/JavaScript decorators for cleaner component definitions.
494
+
495
+ > **Note:** Decorators require TypeScript or a build tool (Babel, esbuild, etc.) that supports the decorator syntax. For plain browser JavaScript, use the functional form: `Register('my-tag')(MyClass)` instead of `@Register('my-tag')`.
496
+
497
+ ### @Register(tagName)
498
+
499
+ Automatically registers the component with the CustomElementsRegistry:
500
+
501
+ ```typescript
502
+ import { Component, Register } from '@aegis-framework/pandora';
503
+
504
+ @Register('my-button')
505
+ class MyButton extends Component {
506
+ render() {
507
+ return `<button>${this.slotContent}</button>`;
508
+ }
509
+ }
510
+
511
+ // No need for: Registry.register('my-button', MyButton);
512
+ ```
513
+
514
+ ### @Consumer(stateKey)
515
+
516
+ Binds a class property to global Registry state. Automatically subscribes on connect and unsubscribes on disconnect:
517
+
518
+ ```typescript
519
+ import { Component, Register, Consumer, html } from '@aegis-framework/pandora';
520
+ import { Registry } from '@aegis-framework/pandora';
521
+
522
+ // Set initial state
523
+ Registry.setState('user.theme', 'light');
524
+ Registry.setState('user.name', 'Guest');
525
+
526
+ @Register('user-greeting')
527
+ class UserGreeting extends Component {
528
+ @Consumer('user.theme')
529
+ theme!: string;
530
+
531
+ @Consumer('user.name')
532
+ name!: string;
533
+
534
+ render() {
535
+ return html`
536
+ <div class="theme-${this.theme}">
537
+ Hello, ${this.name}!
538
+ </div>
539
+ `;
540
+ }
541
+ }
542
+
543
+ // Later, updating state automatically updates all @Consumer properties
544
+ Registry.setState('user.name', 'Alice'); // All UserGreeting instances re-render
545
+ ```
546
+
547
+ ### @Prop(attributeName?)
548
+
549
+ Declares a property that syncs with a DOM attribute:
550
+
551
+ ```typescript
552
+ import { Component, Register, Prop, html } from '@aegis-framework/pandora';
553
+
554
+ @Register('my-input')
555
+ class MyInput extends Component {
556
+ @Prop()
557
+ placeholder: string = '';
558
+
559
+ @Prop('max-length') // Custom attribute name
560
+ maxLength: number = 100;
561
+
562
+ @Prop()
563
+ disabled: boolean = false;
564
+
565
+ render() {
566
+ return html`
567
+ <input
568
+ placeholder=${this.placeholder}
569
+ maxlength=${this.maxLength}
570
+ ?disabled=${this.disabled}
571
+ >
572
+ `;
573
+ }
574
+ }
575
+ ```
576
+
577
+ ```html
578
+ <!-- Attributes sync with properties -->
579
+ <my-input placeholder="Enter text" max-length="50" disabled></my-input>
305
580
  ```
306
581
 
307
582
  ## Registry
@@ -598,10 +873,15 @@ const unsubscribeState = Registry.use('state', (component, state) => {
598
873
  return state;
599
874
  });
600
875
 
601
- // Render middleware - can modify rendered HTML
602
- const unsubscribeRender = Registry.use('render', (component, html) => {
603
- // Add wrapper or modify output
604
- return html;
876
+ // Render middleware - can modify rendered output
877
+ // The third parameter `renderType` indicates if the template is 'string' or 'lit'
878
+ const unsubscribeRender = Registry.use('render', (component, value, renderType) => {
879
+ if (renderType === 'string') {
880
+ // String templates can be modified directly
881
+ return value.replace('{{timestamp}}', Date.now());
882
+ }
883
+ // lit-html TemplateResults should be returned as-is or wrapped
884
+ return value;
605
885
  });
606
886
 
607
887
  // Clean up middleware
@@ -620,10 +900,14 @@ if (process.env.NODE_ENV === 'development') {
620
900
  return state;
621
901
  });
622
902
 
623
- // Track render performance
624
- Registry.use('render', (component, html) => {
625
- console.log(`[${component.static.tag}] rendered ${html.length} chars`);
626
- return html;
903
+ // Track render performance (type-aware)
904
+ Registry.use('render', (component, value, renderType) => {
905
+ if (renderType === 'string') {
906
+ console.log(`[${component.static.tag}] rendered ${value.length} chars (string)`);
907
+ } else {
908
+ console.log(`[${component.static.tag}] rendered (lit-html)`);
909
+ }
910
+ return value;
627
911
  });
628
912
  }
629
913
  ```
@@ -673,9 +957,15 @@ class ThemeToggle extends Component {
673
957
 
674
958
  ## Styling
675
959
 
960
+ Both `Component` and `ShadowComponent` use [Constructable Stylesheets](https://web.dev/constructable-stylesheets/) for optimal performance:
961
+
962
+ - **Shared across instances** - One stylesheet per component class, not per instance
963
+ - **Fast updates** - Uses `replaceSync()` for synchronous style changes
964
+ - **No DOM overhead** - No `<style>` element parsing
965
+
676
966
  ### Regular Components
677
967
 
678
- Styles are added to a shared `<style>` element in the document:
968
+ Styles are adopted into `document.adoptedStyleSheets` and automatically scoped using the component's tag name as a selector prefix:
679
969
 
680
970
  ```javascript
681
971
  element.setStyle({
@@ -687,11 +977,12 @@ element.setStyle({
687
977
  color: 'red'
688
978
  }
689
979
  });
980
+ // Generates: my-element h2 { color: blue; ... }
690
981
  ```
691
982
 
692
983
  ### Shadow Components
693
984
 
694
- Styles are scoped to the Shadow DOM:
985
+ Styles are adopted into the shadow root's `adoptedStyleSheets` and naturally scoped by Shadow DOM encapsulation:
695
986
 
696
987
  ```javascript
697
988
  shadowElement.setStyle({
@@ -729,23 +1020,7 @@ For direct browser usage without a bundler:
729
1020
  ```html
730
1021
  <script src="path/to/pandora.browser.js"></script>
731
1022
  <script>
732
- class MyElement extends Pandora.Component {
733
- render() {
734
- return '<h2>Hello World!</h2>';
735
- }
736
- }
737
-
738
- // Register using the Registry
739
- Pandora.Registry.register('my-element', MyElement);
740
- </script>
741
- ```
742
-
743
- Or use the Registry for component management:
744
-
745
- ```html
746
- <script src="path/to/pandora.browser.js"></script>
747
- <script>
748
- const { Component, Registry } = Pandora;
1023
+ const { Component, ShadowComponent, Registry, html } = Pandora;
749
1024
 
750
1025
  class CounterElement extends Component {
751
1026
  constructor() {
@@ -753,13 +1028,22 @@ Or use the Registry for component management:
753
1028
  this.state = { count: 0 };
754
1029
  }
755
1030
 
1031
+ didMount() {
1032
+ this.on('click', () => {
1033
+ this.setState({ count: this.state.count + 1 });
1034
+ });
1035
+ return Promise.resolve();
1036
+ }
1037
+
756
1038
  render() {
757
- return `<button>Count: ${this.state.count}</button>`;
1039
+ return html`<button>Count: ${this.state.count}</button>`;
758
1040
  }
759
1041
  }
760
1042
 
761
1043
  Registry.register('counter-element', CounterElement);
762
1044
  </script>
1045
+
1046
+ <counter-element></counter-element>
763
1047
  ```
764
1048
 
765
1049
  ## License
@@ -1,10 +1,29 @@
1
- var D=Object.defineProperty;var E=(x,B)=>{for(var F in B)D(x,F,{get:B[F],enumerable:!0,configurable:!0,set:(G)=>B[F]=()=>G})};var U={};E(U,{Util:()=>N,Types:()=>A,ShadowComponent:()=>f,Registry:()=>R,Component:()=>Z});var N={};E(N,{deserializeCSS:()=>$,callAsync:()=>q});function q(x,B,...F){try{let G=x.apply(B,F);return G instanceof Promise?G:Promise.resolve(G)}catch(G){return Promise.reject(G)}}function $(x,B="",F=0){let G=Object.keys(x),H="";for(let J of G){let X=x[J];if(typeof X==="object"&&X!==null){if(B&&!J.startsWith("@"))if(J.startsWith("&"))H+=`${J.replace(/&/g,B)} {
2
- `;else H+=`${B} ${J} {
3
- `;else H+=`${J} {
4
- `;let _=Object.keys(X);for(let K of _){H+="\t".repeat(F);let W=X[K];if(typeof W==="object"&&W!==null){let Y={};Y[K]=W,H+=$(Y,B,F+1)}else H+=` ${K}: ${W};
5
- `}H+=`}
6
- `}else H+="\t".repeat(F),H+=` ${J}: ${X};
7
- `}return H}class P extends HTMLElement{_children;_state;_props;_ready;_connected;_isReady;_style;_styleElement;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(x){this._observedAttributes=x}static get tag(){if(typeof this._tag>"u"){let x=this.name,B=x.match(/([A-Z])/g);if(B!==null)for(let F of B)x=x.replace(F,`-${F}`.toLowerCase());this._tag=x.slice(1)}return this._tag}static set tag(x){this._tag=x}static template(x=null,B=null){if(x!==null)this._template=x,document.querySelectorAll(this.tag).forEach((F)=>{if(F instanceof P&&F._isReady)F.forceRender()});else{if(typeof this._template==="function")return this._template.call(B,B);return this._template}}constructor(){super();this._children=this.innerHTML.trim(),this._state={},this._props={},this._ready=[],this._connected=!1,this._isReady=!1,this._style={},this._styleElement=null}get width(){return parseInt(getComputedStyle(this).width.replace("px",""))}set width(x){this.style.width=typeof x==="number"?`${x}px`:x}get height(){return parseInt(getComputedStyle(this).height.replace("px",""))}set height(x){this.style.height=typeof x==="number"?`${x}px`:x}get static(){return this.constructor}set static(x){throw Error("Component static properties cannot be reassigned.")}get props(){return new Proxy(this._props,{get:(x,B)=>{if(this.hasAttribute(B)){let F=this.getAttribute(B);if(typeof F==="string"){if(F==="false")F=!1;else if(F==="true"||F==="")F=!0;else if(!isNaN(Number(F)))F=F.includes(".")?parseFloat(F):parseInt(F)}return F}else if(B in x)return x[B];return null},set:()=>{throw Error("Component props should be set using the `setProps` function.")}})}set props(x){if(!this._connected)this._props={...this._props,...x};else throw Error("Component props cannot be directly assigned. Use the `setProps` function instead.")}get state(){return new Proxy(this._state,{get:(x,B)=>x[B],set:(x,B,F)=>{if(!this._connected)return x[B]=F,!0;else throw Error("Component state should be set using the `setState` function instead.")}})}set state(x){if(!this._connected)this._state={...this._state,...x};else throw Error("Component state should be set using the `setState` function instead.")}get dom(){return this}set dom(x){throw Error("Component DOM can not be overwritten.")}get isConnected(){return this._connected}get isReady(){return this._isReady}static register(){window.customElements.define(this.tag,this)}template(x=null){return this.constructor.template(x,this)}_createStyleElement(){let x=document.body.querySelector(`style#${this.constructor.tag}`);if(x instanceof HTMLStyleElement)this._styleElement=x;if(this._styleElement instanceof HTMLStyleElement)return;this._styleElement=document.createElement("style"),this._styleElement.id=this.constructor.tag,document.body.prepend(this._styleElement)}setStyle(x,B=!1){if(this._createStyleElement(),typeof x==="object"){if(!B)this._style={...this._style,...x};else this._style={...x};this._styleElement.innerHTML=$(this._style,this.constructor.tag)}else if(typeof x==="string")if(!B)this._styleElement.innerHTML+=x;else this._styleElement.innerHTML=x;return this._style}setState(x){let B=x;if(P._hasMiddleware?.("state")&&P._applyMiddleware)B=P._applyMiddleware("state",this,x);let F={...this._state};this._state={...this._state,...B};for(let G of Object.keys(B))this.updateCallback(G,F[G],this._state[G],"state",F,this._state)}setProps(x){let B=x;if(P._hasMiddleware?.("props")&&P._applyMiddleware)B=P._applyMiddleware("props",this,x);let F={...this._props};this._props={...this._props,...B};for(let G of Object.keys(B))this.updateCallback(G,F[G],this._props[G],"props",F,this._props);this._setPropAttributes(!0)}_setPropAttributes(x=!1){for(let[B,F]of Object.entries(this._props)){let G=typeof F;if(G==="string"||G==="number"||G==="boolean")if(x)this.setAttribute(B,String(F));else this._props[B]=this.props[B],this.setAttribute(B,String(this.props[B]))}}on(x,B,F){return this.addEventListener(x,B,F),this}off(x,B,F){return this.removeEventListener(x,B,F),this}once(x,B,F){let G=typeof F==="boolean"?{capture:F,once:!0}:{...F,once:!0};return this.addEventListener(x,B,G),this}emit(x,B,F){let G=new CustomEvent(x,{detail:B,bubbles:!0,cancelable:!0,composed:!0,...F});return this.dispatchEvent(G)}query(x){return this.dom.querySelector(x)}queryAll(x){return this.dom.querySelectorAll(x)}willUpdate(x,B,F,G,H,J){return Promise.resolve()}update(x,B,F,G,H,J){return Promise.resolve()}didUpdate(x,B,F,G,H,J){return Promise.resolve()}onStateUpdate(x,B,F,G,H){return Promise.resolve()}onPropsUpdate(x,B,F,G,H){return Promise.resolve()}willMount(){return Promise.resolve()}didMount(){return Promise.resolve()}willUnmount(){return Promise.resolve()}unmount(){return Promise.resolve()}didUnmount(){return Promise.resolve()}forceRender(){return this._render()}render(){return""}async _render(){let x=this.render;if(this.constructor._template!==void 0)x=this.template;let B=await q(x,this);if(B=B.trim(),P._hasMiddleware?.("render")&&P._applyMiddleware)B=P._applyMiddleware("render",this,B);if(B==="")return"";let F=this.dom.querySelector("slot");if(F!==null)F.replaceWith(B);else if(this.innerHTML=B,this._children!==""&&B.indexOf(this._children)===-1)this.innerHTML+=this._children;return B}async connectedCallback(){let x=this.static.tag;try{if(this._connected=!0,this.dataset.component=x,typeof this.static._template>"u"){let F=document.querySelector(`template#${x}`);if(F!==null)this.template(F.innerHTML);else this.static._template=void 0}this._setPropAttributes(!1),await this.willMount(),await this._render(),await this.didMount(),this._isReady=!0;let B=[...this._ready];this._ready=[];for(let F of B)F.call(this);if(P._onMount)P._onMount(this,x)}catch(B){if(P._onError)P._onError(B,this,x,"connectedCallback");else throw B}}ready(x){if(this._ready.push(x),this._isReady)x.call(this)}async disconnectedCallback(){let x=this.static.tag;try{if(await this.willUnmount(),await this.unmount(),await this.didUnmount(),this._connected=!1,P._onUnmount)P._onUnmount(this,x)}catch(B){if(P._onError)P._onError(B,this,x,"disconnectedCallback");else throw B}}async updateCallback(x,B,F,G="props",H={},J={}){if(await this.willUpdate(G,x,B,F,H,J),await this.update(G,x,B,F,H,J),G==="state")await this.onStateUpdate(x,B,F,H,J);else if(G==="props"||G==="attribute")await this.onPropsUpdate(x,B,F,H,J);await this.didUpdate(G,x,B,F,H,J)}attributeChangedCallback(x,B,F){if(B!==F)this.updateCallback(x,B,F,"attribute")}}var Z=P;class M extends Z{_shadowDOM;constructor(){super();this._shadowDOM=this.attachShadow({mode:"open"})}setStyle(x,B=!1){if(this._createStyleElement(),typeof x==="object"){if(!B)this._style={...this._style,...x};else this._style={...x};this._styleElement.innerHTML=$(this._style)}else if(typeof x==="string")if(!B)this._styleElement.innerHTML+=x;else this._styleElement.innerHTML=x;return this._style}_createStyleElement(){if(this._styleElement instanceof HTMLStyleElement)return;this._styleElement=document.createElement("style"),this._shadowDOM.prepend(this._styleElement)}async _render(){let x=this.render;if(this.constructor._template!==void 0)x=this.template;let B=await q(x,this),F=Array.from(this._shadowDOM.childNodes);for(let H of F)if(H!==this._styleElement)H.remove();let G=document.createElement("template");return G.innerHTML=B,this._shadowDOM.appendChild(G.content),B}get dom(){throw Error("ShadowComponent DOM can not be accessed. Use the `shadowRoot` property instead.")}set dom(x){throw Error("ShadowComponent DOM can not be overwritten.")}get shadowRoot(){return this._shadowDOM}set shadowRoot(x){throw Error("ShadowComponent shadowRoot can not be overwritten.")}query(x){return this._shadowDOM.querySelector(x)}queryAll(x){return this._shadowDOM.querySelectorAll(x)}}var f=M;class Q{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,Z._onMount=(x,B)=>this._notifyMount(x,B),Z._onUnmount=(x,B)=>this._notifyUnmount(x,B),Z._onError=(x,B,F,G)=>this._notifyError(x,B,F,G),Z._applyMiddleware=(x,B,F)=>this._applyMiddleware(x,B,F),Z._hasMiddleware=(x)=>this._hasMiddleware(x)}static register(x,B){if(this._init(),typeof this.components[x]>"u")this.components[x]=B,this.implementations[x]=B,B._tag=x,window.customElements.define(x,B),this.components[x]._registered=!0,this.log(`Registered: <${x}>`);else throw Error("A component with this tag has already been registered. Use the evolve() function to modify the component.")}static getImplementation(x){return this.implementations[x]||this.components[x]}static evolve(x,B,F=!1){if(typeof this.components[x]>"u")throw Error("No component with this tag has been registered. Cannot Evolve.");if(this.implementations[x]=B,B._registered=!0,this.log(`Evolved: <${x}>`),F){let G=B.prototype,H=Object.getOwnPropertyNames(G),J=Object.create(G);try{B.call(J)}catch{}document.querySelectorAll(x).forEach((X)=>{if(X instanceof Z&&X.isReady){let _=X;for(let K of H)if(K!=="constructor"&&typeof G[K]==="function"){let W=G[K];_[K]=W.bind(X)}if(J._state){let K=_._state||{},W=J._state;for(let Y of Object.keys(W))if(!(Y in K))K[Y]=W[Y];_._state=K}if(J._props){let K=_._props||{},W=J._props;for(let Y of Object.keys(W))if(!(Y in K))K[Y]=W[Y];_._props=K}X.forceRender()}})}}static instances(x,B){if(typeof this.components[x]<"u")if(typeof B==="function")document.querySelectorAll(x).forEach(B);else return document.querySelectorAll(x);else throw Error("No component with the provided tag has been registered.")}static instantiate(x,B){if(!this.has(x))throw Error(`No component with tag "${x}" has been registered.`);if(!this.components[x]._registered)this.register(x,this.components[x]);let F=document.createElement(this.components[x].tag);return F.setProps(B),F}static has(x){return typeof this.components[x]<"u"}static get(x){return this.components[x]}static setState(x,B){let F=this.state[x];if(this.state[x]=B,this.subscribers[x])this.subscribers[x].forEach((G)=>{G(B,F)})}static getState(x){return this.state[x]}static hasState(x){return x in this.state}static deleteState(x){if(x in this.state){let B=this.state[x];if(delete this.state[x],this.subscribers[x])this.subscribers[x].forEach((F)=>{F(void 0,B)});return!0}return!1}static subscribe(x,B){if(!this.subscribers[x])this.subscribers[x]=new Set;return this.subscribers[x].add(B),()=>{this.unsubscribe(x,B)}}static unsubscribe(x,B){if(this.subscribers[x])this.subscribers[x].delete(B)}static getAllState(){return{...this.state}}static clearState(){let x=Object.keys(this.state);for(let B of x)this.deleteState(B)}static get debug(){return this._debug}static set debug(x){this._debug=x}static log(x,B){if(this._debug)if(B!==void 0)console.log(`[Pandora] ${x}`,B);else console.log(`[Pandora] ${x}`)}static list(){return Object.keys(this.components)}static stats(x){if(x){if(!this.has(x))throw Error(`No component with tag "${x}" has been registered.`);return{tag:x,instanceCount:document.querySelectorAll(x).length,isRegistered:this.components[x]?._registered??!1,isLazy:x in this.lazyLoaders}}return this.list().map((B)=>({tag:B,instanceCount:document.querySelectorAll(B).length,isRegistered:this.components[B]?._registered??!1,isLazy:B in this.lazyLoaders}))}static onMount(x){return this._init(),this.mountCallbacks.add(x),()=>this.mountCallbacks.delete(x)}static onUnmount(x){return this._init(),this.unmountCallbacks.add(x),()=>this.unmountCallbacks.delete(x)}static _notifyMount(x,B){this.log(`Mounted: <${B}>`),this.mountCallbacks.forEach((F)=>{try{F(x,B)}catch(G){console.error("[Pandora] Error in onMount callback:",G)}})}static _notifyUnmount(x,B){this.log(`Unmounted: <${B}>`),this.unmountCallbacks.forEach((F)=>{try{F(x,B)}catch(G){console.error("[Pandora] Error in onUnmount callback:",G)}})}static onError(x){return this._init(),this.errorCallbacks.add(x),()=>this.errorCallbacks.delete(x)}static _notifyError(x,B,F,G){if(this.log(`Error in <${F}> during ${G}:`,x),this.errorCallbacks.size===0)throw x;this.errorCallbacks.forEach((H)=>{try{H(x,B,F,G)}catch(J){console.error("[Pandora] Error in onError callback:",J)}})}static alias(x,B){if(!this.has(B))throw Error(`Cannot create alias: no component with tag "${B}" has been registered.`);if(this.has(x))throw Error(`Cannot create alias: a component with tag "${x}" already exists.`);this.aliases[x]=B;let F=this.components[B],G=class extends F{static _tag=x};this.components[x]=G,window.customElements.define(x,G),this.log(`Created alias: <${x}> -> <${B}>`)}static getOriginalTag(x){return this.aliases[x]}static isAlias(x){return x in this.aliases}static lazy(x,B){if(this._init(),this.has(x))throw Error(`Cannot register lazy component: a component with tag "${x}" already exists.`);this.lazyLoaders[x]=B;let F=Q;class G extends Z{static _tag=x;_lazyLoaded=!1;async connectedCallback(){await F._loadLazyComponent(x);let H=F.getImplementation(x);if(H&&H!==G){let J=H.prototype,X=Object.getOwnPropertyNames(J),_=this;for(let W of X)if(W!=="constructor"&&typeof J[W]==="function"){let Y=J[W];_[W]=Y.bind(this)}let K=Object.create(J);try{H.call(K)}catch{}if(K._state)_._state={...K._state};if(K._props)_._props={...K._props};this._lazyLoaded=!0}await super.connectedCallback()}}this.components[x]=G,window.customElements.define(x,G),this.log(`Registered lazy component: <${x}>`)}static async _loadLazyComponent(x){if(!(x in this.lazyLoaders))return;let B=this.lazyLoaders[x];this.log(`Loading lazy component: <${x}>`);try{let F=await B(),G="default"in F?F.default:F;delete this.lazyLoaders[x],this.implementations[x]=G,G._registered=!0,this.log(`Loaded lazy component: <${x}>`)}catch(F){throw console.error(`[Pandora] Failed to load lazy component <${x}>:`,F),F}}static isLazy(x){return x in this.lazyLoaders}static async preload(x){if(this.isLazy(x))await this._loadLazyComponent(x)}static use(x,B){return this._init(),this.middleware[x].add(B),()=>this.middleware[x].delete(B)}static _applyMiddleware(x,B,F){let G=F;return this.middleware[x].forEach((H)=>{try{G=H(B,G)}catch(J){console.error(`[Pandora] Error in ${x} middleware:`,J)}}),G}static _hasMiddleware(x){return this.middleware[x].size>0}}var R=Q;var A={};if(typeof window==="object")window.Pandora=U;
1
+ var PJ=Object.defineProperty;var YJ=(J,W)=>{for(var X in W)PJ(J,X,{get:W[X],enumerable:!0,configurable:!0,set:(Y)=>W[X]=()=>Y})};var XJ={};YJ(XJ,{svg:()=>_J,render:()=>D,nothing:()=>M,noChange:()=>L,html:()=>zJ,Util:()=>JJ,Types:()=>VJ,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(V!==u)throw Error("Attempted to overwrite existing lit-html security policy. setSanitizeDOMValueFactory should be called at most once.");V=J},hJ=()=>{V=u},l=(J,W,X)=>{return V(J,W,X)},FJ="$lit$",S=`lit$${Math.random().toFixed(9).slice(2)}$`,MJ="?"+S,wJ=`<${MJ}>`,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
+ \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,UJ=/^(?: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
+ 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}},zJ=e(vJ),_J=e(c),lJ=e(g),L=Symbol.for("lit-noChange"),M=Symbol.for("lit-nothing"),HJ=new WeakMap,E=N.createTreeWalker(N,129),V=u;function fJ(J,W){if(!n(J)||!J.hasOwnProperty("raw")){let X="invalid template strings array";throw X=`
6
+ Internal Error: expected template strings to be an array
7
+ with a 'raw' field. Faking a template strings array by
8
+ calling html or svg like an ordinary function is effectively
9
+ the same as calling unsafeHtml and can lead to major security
10
+ issues, e.g. opening your code up to XSS attacks.
11
+ If you're using the html or svg tagged template functions normally
12
+ and still seeing this error, please file a bug at
13
+ https://github.com/lit/lit/issues/new?template=bug_report.md
14
+ and include information about your build tooling, if any.
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)} {
17
+ `;else Z+=`${W} ${$} {
18
+ `;else Z+=`${$} {
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
+ `}Z+=`}
21
+ `}else Z+="\t".repeat(X),Z+=` ${$}: ${q};
22
+ `}return Z}class U extends HTMLElement{_children;_state;_props;_ready;_connected;_isReady;_style;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 U&&X._isReady)X.forceRender()});else{if(typeof this._template==="function")return this._template.call(W,W);return this._template}}constructor(){super();this._children=this.innerHTML.trim(),this._state={},this._props={},this._ready=[],this._connected=!1,this._isReady=!1,this._style={}}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(){return new Proxy(this._props,{get:(J,W)=>{if(W in J)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.")}})}set props(J){if(!this._connected)this._props={...this._props,...J};else throw Error("Component props cannot be directly assigned. Use the `setProps` function instead.")}get state(){return 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.")}})}set state(J){if(!this._connected)this._state={...this._state,...J};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}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
+ `)+`
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(U._hasMiddleware?.("state")&&U._applyMiddleware)W=U._applyMiddleware("state",this,J);let X={...this._state};this._state={...this._state,...W};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(U._hasMiddleware?.("props")&&U._applyMiddleware)W=U._applyMiddleware("props",this,J);let X={...this._props};this._props={...this._props,...W};for(let Y of Object.keys(W))this.updateCallback(Y,X[Y],this._props[Y],"props",X,this._props);this._setPropAttributes(!0)}_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)}willUpdate(J,W,X,Y,Z,$){return Promise.resolve()}update(J,W,X,Y,Z,$){return Promise.resolve()}didUpdate(J,W,X,Y,Z,$){return Promise.resolve()}onStateUpdate(J,W,X,Y,Z){return Promise.resolve()}onPropsUpdate(J,W,X,Y,Z){return Promise.resolve()}willMount(){return Promise.resolve()}didMount(){return Promise.resolve()}willUnmount(){return Promise.resolve()}unmount(){return Promise.resolve()}didUnmount(){return Promise.resolve()}forceRender(){return this._render()}render(){return""}async _render(){let J=this.render;if(this.constructor._template!==void 0)J=this.template;let W=await m(J,this),X=P(W)||W===M?"lit":"string";if(U._hasMiddleware?.("render")&&U._applyMiddleware)W=U._applyMiddleware("render",this,W,X);if(P(W)||W===M){if(!this.hasAttribute("data-lit-rendered"))this.innerHTML="",this.setAttribute("data-lit-rendered","");D(W,this,{host:this});return}let Y=W.trim();if(Y==="")return;let Z=this.dom.querySelector("slot");if(Z!==null)Z.replaceWith(Y);else if(this.innerHTML=Y,this._children!==""&&Y.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 X=document.querySelector(`template#${J}`);if(X!==null)this.template(X.innerHTML);else this.static._template=void 0}this._setPropAttributes(!1),await this.willMount(),await this._render(),await this.didMount(),this._isReady=!0;let W=[...this._ready];this._ready=[];for(let X of W)X.call(this);if(U._onMount)U._onMount(this,J)}catch(W){if(U._onError)U._onError(W,this,J,"connectedCallback");else throw W}}ready(J){if(this._ready.push(J),this._isReady)J.call(this)}async disconnectedCallback(){let J=this.static.tag;try{if(await this.willUnmount(),await this.unmount(),await this.didUnmount(),this._connected=!1,U._onUnmount)U._onUnmount(this,J)}catch(W){if(U._onError)U._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.updateCallback(J,W,X,"attribute")}}var f=U;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
+ `)+`
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)J=this.template;let W=await m(J,this),X=P(W)||W===M?"lit":"string";if(f._hasMiddleware?.("render")&&f._applyMiddleware)W=f._applyMiddleware("render",this,W,X);if(P(W)||W===M){D(W,this._shadowDOM,{host:this});return}let Y=W.trim(),Z=Array.from(this._shadowDOM.childNodes);for(let q of Z)q.remove();if(Y==="")return;let $=document.createElement("template");$.innerHTML=Y,this._shadowDOM.appendChild($.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),$=Object.create(Y);try{W.call($)}catch{}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=Object.create($);try{Z.call(Q)}catch{}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,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(!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 VJ={};if(typeof window==="object")window.Pandora=XJ;
8
27
 
9
- //# debugId=35D63DF32B8B755564756E2164756E21
28
+ //# debugId=F8DBE633E0B5D37C64756E2164756E21
10
29
  //# sourceMappingURL=pandora.browser.js.map