@shortfuse/materialdesignweb 0.10.3 → 0.11.1

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.
@@ -28,7 +28,6 @@ import { generateUID } from './uid.js';
28
28
  * @prop {ShadowRoot} [shadowRoot] where
29
29
  * @prop {any} [context] `this` on callbacks/events
30
30
  * @prop {any} [injections]
31
- * @prop {number} [iterationIndex]
32
31
  */
33
32
 
34
33
  /**
@@ -196,7 +195,7 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
196
195
  const { commentIndex, nodeIndex } = this;
197
196
  const nodeState = nodeStates[nodeIndex];
198
197
  // eslint-disable-next-line no-bitwise
199
- const hidden = nodeState & 0b0001;
198
+ const hidden = nodeState & 0b0001; // has hidden bit
200
199
  const show = value != null && value !== false;
201
200
  if (!show) {
202
201
  // Should be hidden
@@ -209,16 +208,26 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
209
208
  }
210
209
  nodes[nodeIndex].replaceWith(comment);
211
210
  // eslint-disable-next-line no-bitwise
212
- nodeStates[nodeIndex] |= 0b0001;
211
+ nodeStates[nodeIndex] |= 0b0001; // set hidden bit
213
212
  return;
214
213
  }
215
214
  // Must be shown
216
215
  // Update node first (offscreen rendering)
217
216
  const node = nodes[nodeIndex];
218
217
  // eslint-disable-next-line no-bitwise
219
- const isDynamicNode = nodeState & 0b0010;
220
-
221
- if (typeof value === 'object') {
218
+ const isDynamicNode = nodeState & 0b0010; // has dynamic-node bit (non-text)
219
+
220
+ if (value instanceof Node) {
221
+ const DOCUMENT_FRAGMENT_NODE = 11; // Node.DOCUMENT_FRAGMENT_NODE
222
+ if (value.nodeType === DOCUMENT_FRAGMENT_NODE) {
223
+ console.warn('Dynamic nodes do not support DocumentFragment yet');
224
+ } else if (node !== value) {
225
+ node.replaceWith(value);
226
+ nodes[nodeIndex] = /** @type {Element} */ (value);
227
+ }
228
+ // eslint-disable-next-line no-bitwise
229
+ nodeStates[nodeIndex] |= 0b0010; // set dynamic-node bit
230
+ } else if (typeof value === 'object') {
222
231
  // Not string data, need to replace
223
232
  console.warn('Dynamic nodes not supported yet');
224
233
  } else if (isDynamicNode) {
@@ -226,7 +235,7 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
226
235
  node.replaceWith(textNode);
227
236
  nodes[nodeIndex] = textNode;
228
237
  // eslint-disable-next-line no-bitwise
229
- nodeStates[nodeIndex] &= ~0b0010;
238
+ nodeStates[nodeIndex] &= ~0b0010; // unset dynamic-node bit
230
239
  } else {
231
240
  /** @type {Text} */ (node).data = value;
232
241
  }
@@ -237,7 +246,7 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
237
246
  const comment = comments[commentIndex];
238
247
  comment.replaceWith(node);
239
248
  // eslint-disable-next-line no-bitwise
240
- nodeStates[nodeIndex] &= ~0b0001;
249
+ nodeStates[nodeIndex] &= ~0b0001; // unset hidden bit
241
250
  }
242
251
  // Done
243
252
  }
@@ -249,7 +258,7 @@ function writeDynamicNode({ nodeStates, comments, nodes }, value) {
249
258
  function writeDOMElementAttachedState({ nodeStates, nodes, comments }, value) {
250
259
  const { commentIndex, nodeIndex } = this;
251
260
  // eslint-disable-next-line no-bitwise
252
- const hidden = nodeStates[nodeIndex] & 1;
261
+ const hidden = nodeStates[nodeIndex] & 1; // has hidden bit
253
262
  const show = value != null && value !== false;
254
263
  if (show === !hidden) return;
255
264
 
@@ -262,11 +271,11 @@ function writeDOMElementAttachedState({ nodeStates, nodes, comments }, value) {
262
271
  if (show) {
263
272
  comment.replaceWith(element);
264
273
  // eslint-disable-next-line no-bitwise
265
- nodeStates[nodeIndex] &= ~0b0001;
274
+ nodeStates[nodeIndex] &= ~0b0001; // unset hidden bit
266
275
  } else {
267
276
  element.replaceWith(comment);
268
277
  // eslint-disable-next-line no-bitwise
269
- nodeStates[nodeIndex] |= 0b0001;
278
+ nodeStates[nodeIndex] |= 0b0001; // set hidden bit
270
279
  }
271
280
  }
272
281
 
@@ -280,7 +289,7 @@ function writeDOMHideNodeOnInit({ comments, nodeStates, nodes }) {
280
289
  const comment = createEmptyComment();
281
290
  comments[commentIndex] = comment;
282
291
  // eslint-disable-next-line no-bitwise
283
- nodeStates[nodeIndex] |= 1;
292
+ nodeStates[nodeIndex] |= 1; // set hidden bit
284
293
 
285
294
  nodes[nodeIndex].replaceWith(comment);
286
295
  }
@@ -364,7 +373,7 @@ function searchWithProp(state, changes) {
364
373
  function searchWithDeepProp(state, changes, data) {
365
374
  let scope = changes;
366
375
  for (const prop of this.deepProp) {
367
- if (scope === null) return null;
376
+ if (scope == null) return scope;
368
377
  if (prop in scope === false) return undefined;
369
378
  scope = scope[prop];
370
379
  }
@@ -389,7 +398,7 @@ function searchWithDeepProp(state, changes, data) {
389
398
  * @prop {HTMLElement[]} refs
390
399
  * @prop {number} lastChildNodeIndex
391
400
  * @prop {RenderOptions<?>} options
392
- * @prop {CompositionAdapter<any>[][]} adapters
401
+ * @prop {CompositionAdapter<any>[]} adapters
393
402
  */
394
403
 
395
404
  /** Splits: `{template}text{template}` as `['', 'template', 'text', 'template', '']` */
@@ -1020,7 +1029,7 @@ export default class Composition {
1020
1029
  expression = inlineFunctionOptions.fn;
1021
1030
  invocation = searchWithExpression;
1022
1031
  if (inlineFunctionOptions.props) {
1023
- // console.log('This function has already been called. Reuse props', inlineFunctionOptions, this);
1032
+ // console.log('This function has already been called. Reuse props', inlineFunctionOptions, this);
1024
1033
  propsUsed = inlineFunctionOptions.props;
1025
1034
  deepPropsUsed = inlineFunctionOptions.deepProps;
1026
1035
  defaultValue = inlineFunctionOptions.defaultValue ?? null;
@@ -1040,7 +1049,7 @@ export default class Composition {
1040
1049
 
1041
1050
  if (!propsUsed) {
1042
1051
  if (typeof defaultValue === 'function') {
1043
- // Value must be reinterpolated and function observed
1052
+ // Value must be reinterpolated and function observed
1044
1053
  const observeResult = observeFunction.call(this, defaultValue, options?.defaults, options?.injections);
1045
1054
  const uniqueProps = new Set([
1046
1055
  ...observeResult.props.this,
@@ -1056,9 +1065,9 @@ export default class Composition {
1056
1065
  propsUsed = [...uniqueProps];
1057
1066
  deepPropsUsed = [...uniqueDeepProps].map((deepPropString) => deepPropString.split('.'));
1058
1067
  invocation = searchWithExpression;
1059
- // console.log(this.static.name, fn.name || parsedValue, combinedSet);
1068
+ // console.log(this.static.name, fn.name || parsedValue, combinedSet);
1060
1069
  } else {
1061
- // property binding
1070
+ // property binding
1062
1071
  const parsedProps = parsedValue.split('.');
1063
1072
  if (parsedProps.length === 1) {
1064
1073
  prop = parsedValue;
@@ -1321,10 +1330,8 @@ export default class Composition {
1321
1330
  injections,
1322
1331
  invocation(state, value, changes, data) {
1323
1332
  // Optimistic get
1324
- let adaptersArray = state.adapters[this.adapterIndex];
1325
- const iterationIndex = state.options.iterationIndex ?? 0;
1326
- let adapter;
1327
- if (!adaptersArray || (!(adapter = adaptersArray[iterationIndex]))) {
1333
+ let adapter = state.adapters[this.adapterIndex];
1334
+ if (!adapter) {
1328
1335
  const instanceAnchorElement = state.nodes[this.nodeIndex];
1329
1336
  const anchorNode = createEmptyComment();
1330
1337
 
@@ -1348,9 +1355,7 @@ export default class Composition {
1348
1355
  },
1349
1356
  });
1350
1357
 
1351
- // eslint-disable-next-line no-multi-assign
1352
- adaptersArray = ((state.adapters[this.adapterIndex] ??= []));
1353
- adaptersArray[iterationIndex] = adapter;
1358
+ state.adapters[this.adapterIndex] = adapter;
1354
1359
  }
1355
1360
 
1356
1361
  const currentInjections = state.options.injections ?? this.injections;
@@ -1393,7 +1398,6 @@ export default class Composition {
1393
1398
  currentInjections[valueName] = resource;
1394
1399
  currentInjections.index = index;
1395
1400
  adapter.renderOptions.injections = currentInjections;
1396
- adapter.renderOptions.iterationIndex = index;
1397
1401
  adapter.renderData(index, innerChanges, data, resource, change);
1398
1402
  }
1399
1403
  } else {
@@ -1419,7 +1423,6 @@ export default class Composition {
1419
1423
  currentInjections[valueName] = resource;
1420
1424
  currentInjections.index = index;
1421
1425
  adapter.renderOptions.injections = currentInjections;
1422
- adapter.renderOptions.iterationIndex = index;
1423
1426
  adapter.renderData(index, innerChanges, data, resource, change);
1424
1427
  // adapter.renderIndex(index, innerChanges, data, resource);
1425
1428
  }
@@ -1500,7 +1503,7 @@ export default class Composition {
1500
1503
  break;
1501
1504
  case Node.TEXT_NODE:
1502
1505
  element = node.parentElement;
1503
- if (this.#interpolateNode(/** @type {Text} */ (node), element, options)) {
1506
+ if (this.#interpolateNode(/** @type {Text} */(node), element, options)) {
1504
1507
  const nextNode = treeWalker.nextNode();
1505
1508
  /** @type {Text} */ (node).remove();
1506
1509
  node = nextNode;
@@ -47,19 +47,27 @@ function restoreFocus(focused) {
47
47
  /**
48
48
  * @param {Element|Comment} node
49
49
  * @param {ChildNode} beforeNode
50
+ * @param {ParentNode} parentNode
50
51
  */
51
- function moveNode(node, beforeNode) {
52
+ function moveNode(node, beforeNode, parentNode) {
52
53
  const focused = captureFocus(node);
53
54
  if (beforeNode) {
54
55
  beforeNode.before(node);
55
56
  } else {
56
- node.parentNode?.append(node);
57
+ parentNode.append(node);
57
58
  }
58
59
  restoreFocus(focused);
59
60
  }
60
61
 
61
62
  // @ts-expect-error Bad typings
62
63
  const hasMoveBefore = typeof Element.prototype.moveBefore === 'function';
64
+ /** @type {(node: Element|Comment, beforeNode: ChildNode, parentNode: Node) => void} */
65
+ const moveBeforeNode = hasMoveBefore
66
+ ? (node, beforeNode, parentNode) => {
67
+ // @ts-ignore Bad typings
68
+ parentNode.moveBefore(node, beforeNode);
69
+ }
70
+ : moveNode;
63
71
 
64
72
  /** @template T */
65
73
  export default class CompositionAdapter {
@@ -137,11 +145,14 @@ export default class CompositionAdapter {
137
145
  }
138
146
 
139
147
  /** @param {number} index */
140
- removeByIndex(index) {
148
+ moveToEndByIndex(index) {
141
149
  const [metadata] = this.metadata.splice(index, 1);
142
150
  const { domNode, key } = metadata;
143
151
  this.keys.splice(index, 1);
144
- domNode.remove();
152
+ const removalContainer = domNode.parentNode;
153
+ if (removalContainer) {
154
+ moveNode(domNode, null, removalContainer);
155
+ }
145
156
 
146
157
  // Don't release in case we may need it later
147
158
  if (this.metadataCache) {
@@ -213,8 +224,8 @@ export default class CompositionAdapter {
213
224
  this.metadata.splice(newIndex, 0, previousMetadata);
214
225
  this.keys.splice(newIndex, 0, key);
215
226
 
216
- const previousSibling = this.metadata[newIndex - 1]?.domNode ?? this.anchorNode;
217
- previousSibling.after(previousMetadata.domNode);
227
+ moveBeforeNode(previousMetadata.domNode, metadataAtIndex.domNode, metadataAtIndex.domNode.parentNode);
228
+ previousMetadata.render(changes, data);
218
229
  metadataCache.delete(key);
219
230
  return;
220
231
  }
@@ -233,11 +244,11 @@ export default class CompositionAdapter {
233
244
  // console.warn('Found key for', newIndex, '@', oldIndex);
234
245
  // console.warn('swapping', newIndex, '<=>', oldIndex);
235
246
  if ((newIndex - oldIndex) === -1) {
236
- // (Optimistic removal)
237
- // If element should be one step sooner, remove instead to shift up.
247
+ // (Optimistic move-to-end)
248
+ // If element should be one step sooner, move current to end to shift up.
238
249
  // If should have been swap, will correct itself next step.
239
- // console.warn('Removing', newIndex, 'instead');
240
- this.removeByIndex(newIndex);
250
+ // console.warn('Moving', newIndex, 'to end instead');
251
+ this.moveToEndByIndex(newIndex);
241
252
  return;
242
253
  }
243
254
  // Swap with other element
@@ -256,18 +267,9 @@ export default class CompositionAdapter {
256
267
 
257
268
  const removalContainer = domNodeToRemove.parentNode;
258
269
  const correctNext = correctMetadata.domNode.nextSibling;
259
- if (hasMoveBefore) {
260
- // @ts-expect-error Bad typings
261
- removalContainer.moveBefore(correctMetadata.domNode, domNodeToRemove);
262
- if (correctNext) {
263
- // @ts-expect-error Bad typings
264
- removalContainer.moveBefore(domNodeToRemove, correctNext);
265
- }
266
- } else {
267
- moveNode(correctMetadata.domNode, domNodeToRemove);
268
- if (correctNext) {
269
- moveNode(domNodeToRemove, correctNext);
270
- }
270
+ moveBeforeNode(correctMetadata.domNode, domNodeToRemove, removalContainer);
271
+ if (correctNext) {
272
+ moveBeforeNode(domNodeToRemove, correctNext, removalContainer);
271
273
  }
272
274
 
273
275
  if (!skipOnMatch) {
@@ -1,2 +1,2 @@
1
- var De,Ue;function me(){return(De??=new Text).cloneNode()}function W(){return(Ue??=new Comment).cloneNode()}function Ve(i){var e,t;return(e=i==null?void 0:i.matches)!=null&&e.call(i,":focus")?i:(t=i==null?void 0:i.querySelector)==null?void 0:t.call(i,":focus")}function qe(i){i&&i.isConnected&&!i.matches(":focus")&&i.focus()}function ye(i,e){var n;let t=Ve(i);e?e.before(i):(n=i.parentNode)==null||n.append(i),qe(t)}var $e=typeof Element.prototype.moveBefore=="function",q=class{constructor(e){this.anchorNode=e.anchorNode,this.metadata=[],this.keys=[],this.needsArrayKeyFastPath=!1,this.composition=e.composition,this.renderOptions=e.renderOptions,this.metadataCache=null,this.queuedElements=[],this.batchStartIndex=null,this.batchEndIndex=null}render(e,t){return this.composition.render(e,t,this.renderOptions)}startBatch(){this.needsArrayKeyFastPath=!0}writeBatch(){var t;if(!this.queuedElements.length)return;(((t=this.metadata[this.batchStartIndex-1])==null?void 0:t.domNode)??this.anchorNode).after(...this.queuedElements),this.queuedElements.length=0}stopBatch(){if(this.writeBatch(),this.needsArrayKeyFastPath=!1,this.batchStartIndex=null,this.batchEndIndex=null,this.metadataCache){for(let{domNode:e}of this.metadataCache.values())e.remove();this.metadataCache.clear()}}removeByIndex(e){let[t]=this.metadata.splice(e,1),{domNode:n,key:s}=t;this.keys.splice(e,1),n.remove(),this.metadataCache?this.metadataCache.set(s,t):this.metadataCache=new Map([[s,t]])}renderData(e,t,n,s,r,o){var l;if(e<this.metadata.length){let u=this.metadata[e],p=u.key,x=p===s,g=r!==s;if(x){g?u.render(t,n):o||u.render(t,n);return}let y=this.metadataCache??=new Map,h=!1;this.needsArrayKeyFastPath&&(h=!this.keys.includes(s),this.needsArrayFastPath=!1);let f=h?-1:this.keys.indexOf(s,e+1);if(f===-1){if(y.has(s)){let d=y.get(s);this.metadata.splice(e,0,d),this.keys.splice(e,0,s),(((l=this.metadata[e-1])==null?void 0:l.domNode)??this.anchorNode).after(d.domNode),y.delete(s);return}y.set(p,u)}else{if(e-f===-1){this.removeByIndex(e);return}let d=this.metadata[f];this.metadata[e]=d,this.metadata[f]=u;let{domNode:m}=u,b=m.parentNode,w=d.domNode.nextSibling;$e?(b.moveBefore(d.domNode,m),w&&b.moveBefore(m,w)):(ye(d.domNode,m),w&&ye(m,w)),o||d.render(t,n),this.keys[e]=s,this.keys[f]=p;return}}let a=this.render(t,n),c=a.target;this.metadata[e]={render:a,element:c,key:s,domNode:c},this.keys[e]=s,(this.batchEndIndex===null||this.batchEndIndex!==e-1)&&(this.writeBatch(),this.batchStartIndex=e),this.batchEndIndex=e,this.queuedElements.push(c)}removeEntries(e=0){let{length:t}=this.metadata;for(let n=t-1;n>=e;n--){let s=this.metadata[n];!s||!s.domNode||s.domNode.remove()}this.metadata.length=e,this.keys.length=e}hide(e,t,n){if(!t&&(e==null&&(e=this.keys.indexOf(n)),t=this.metadata[e],!t)||t.hidden)return!1;let{comment:s,element:r}=t;return s||(s=W(),t.comment=s),r.replaceWith(s),t.domNode=s,t.hidden=!0,!0}show(e,t,n){if(!t&&(e==null&&(e=this.keys.indexOf(n)),t=this.metadata[e],!t)||!t.hidden)return!1;let{comment:s,element:r}=t;return s.replaceWith(r),t.domNode=r,t.hidden=!1,!0}};var ee=new Map;function G(i,e=!0){if(e&&ee.has(i))return ee.get(i);let t=new CSSStyleSheet;return t.replaceSync(i),e&&ee.set(i,t),t}var te=new Map,be;function He(i,e=!0){let t;return e&&te.has(i)?t=te.get(i):(be??=document.implementation.createHTMLDocument(),t=be.createElement("style"),t.textContent=i,e&&te.set(i,t)),t.cloneNode(!0)}var Q;function ge(i,e=!0){if(Q==null)try{let t=G(i,e);return Q=!0,t}catch{Q=!1}return Q?G(i,e):He(i,e)}function*xe(i,e=!0){for(let t of i)t instanceof HTMLStyleElement?yield G(t.textContent,e):t.ownerNode?yield G([...t.cssRules].map(n=>n.cssText).join(""),e):yield t}var ne=new WeakMap;function*Ce(i,e=!0){for(let t of i)if(t instanceof HTMLStyleElement)yield t;else if(t.ownerNode instanceof HTMLStyleElement)yield t.ownerNode.cloneNode(!0);else if(e&&ne.has(t))yield ne.get(t).cloneNode(!0);else{let n=document.createElement("style");n.textContent=[...t.cssRules].map(s=>s.cssText).join(""),e&&ne.set(t,n),yield n.cloneNode(!0)}}function Se(i,...e){return ge(typeof i=="string"?i:String.raw({raw:i},...e))}function Ie(i){switch(i){case void 0:case null:case!1:return null;case!0:return"";default:return`${i}`}}var X;function D(i){if(X??=new Map,X.has(i))return X.get(i);let e=i.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`);return X.set(i,e),e}var we,Ke=Number.parseFloat((we=navigator.userAgent.match(/Chrome\/([\d.]+)/))==null?void 0:we[1]),Pe,ut=Number.parseFloat((Pe=navigator.userAgent.match(/Firefox\/([\d.]+)/))==null?void 0:Pe[1]),ke,dt=Ke||!navigator.userAgent.includes("AppleWebKit")?Number.NaN:Number.parseFloat((ke=navigator.userAgent.match(/Version\/([\d.]+)/))==null?void 0:ke[1]);function Ee(i,e){if(i===e)return i;if(Array.isArray(e)||i==null||e==null||typeof e!="object")return e;typeof i!="object"&&(i={});for(let[t,n]of Object.entries(e))n==null?t in i&&delete i[t]:i[t]=Ee(i[t],n);return i}function Ne(i,e){if(i===e)return i;let t=e!=null&&typeof e=="object"&&!Array.isArray(e),n=i!=null&&typeof i=="object"&&!Array.isArray(i);if(!t||!n)return e;for(let[s,r]of Object.entries(e))r==null?s in i&&delete i[s]:i[s]=Ne(i[s],r);return i}function ve(i,e,t="reference"){switch(t){case"clone":case"object":return Ee(i,e);default:return Ne(i,e)}}function _e(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e))return e;let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=_e(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function Ae(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e))return structuredClone(e);let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=Ae(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function se(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e)){for(let[s,r]of e.entries()){if(r===null){t[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(t[s]=o)}return e.length!==i.length&&(t.length=e.length),t}let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function Oe(i,e,t="reference"){switch(t){case"clone":return Ae(i,e);case"object":return se(i,e);default:return _e(i,e)}}function ie(i,e){if(i===e)return!1;if(e==null||typeof e!="object"||i!=null&&typeof i!="object")return!0;for(let[t,n]of Object.entries(e))if(n==null){if(t in i)return!0}else if(ie(i[t],n))return!0;return!1}function Qe(i,e){return Array.isArray(e)?i!==e:ie(i,e)}function Me(i,e,t="reference"){switch(t){case"clone":case"object":return Qe(i,e);default:return ie(i,e)}}function je(i){switch(i){case"boolean":return!1;case"integer":case"float":case"number":return 0;case"map":return new Map;case"set":return new Set;case"array":return[];case"proxy":case"object":return null;default:case"string":return""}}function re(i,e,t,n){return i??={},new Proxy(i,{get(s,r){let o=s[r];if(typeof r!="symbol"){let a=n?`${n}.${r}`:r;if(n?t.add(a):e.add(a),typeof o=="object"&&o!=null)return re(o,e,t,a)}return o},has(s,r){let o=Reflect.has(s,r);if(typeof r!="symbol"){let a=n?`${n}.${r}`:r;n?t.add(a):e.add(a)}return o}})}var Y=new WeakMap,oe=new WeakMap;function Ge(i){if(i==null||typeof i!="object")return null;let e=oe.get(i);if(!e){let t=new Set;e={subscribe(n){t.add(n)},unsubscribe(n){t.delete(n)},emit(n){for(let s of t)s(n)}},oe.set(i,e)}return e}function z(i,e){let t={},n=t;for(let s=0;s<i.length-1;s++)n[i[s]]={},n=n[i[s]];return n[i.at(-1)]=e,t}function Te(i,e,t,n,s){if(i==null||typeof i!="object")return i;let r=Ge(i);s||(s=r);let o=Y.get(i);if(o||(o=new Map,Y.set(i,o)),o.has(n))return o.get(n);let a=new Proxy(i,{get(c,l){if(typeof l=="symbol")return c[l];let u=c[l];return Te(u,e,t.concat(l),n,s)},set(c,l,u){if(c[l]=u,typeof l!="symbol"){let p=z(t.concat(l),u);if(e(p),s==null||s.emit(p),r&&r!==s){let x=z([l],u);r.emit(x)}}return!0},deleteProperty(c,l){if(typeof l!="symbol"){let u=z(t.concat(l),null);if(e(u),s==null||s.emit(u),r&&r!==s){let p=z([l],null);r.emit(p)}}return Reflect.deleteProperty(c,l)}});return Y.set(a,o),r&&oe.set(a,r),o.set(n,a),a}function Xe(i){switch(i){case"boolean":return e=>!!e;case"integer":return Math.round;case"float":case"number":return e=>+e;case"map":return Map;case"set":return Set;case"object":case"array":case"proxy":return e=>e;default:case"string":return e=>`${e}`}}function ae(i,...e){let t=new Set,n=new Set,s=e.map(c=>{let l=new Set,u=new Set,p=re(c,l,u);return{poked:l,pokedDeep:u,proxy:p}}),r=re(this??{},t,n),o=i.apply(r,s.map(c=>c.proxy)),a=i.name?!0:!t.size;return{props:{this:[...t],args:s.map(c=>[...c.poked])},deepPropStrings:{this:[...n],args:s.map(c=>[...c.pokedDeep])},deepProps:{this:[...n].map(c=>c.split(".")),args:s.map(c=>[...c.pokedDeep].map(l=>l.split(".")))},defaultValue:o,reusable:a}}function ze(){return null}function Ye(i,e,t){let n=typeof e=="string"?{type:e}:e,{watchers:s,value:r,readonly:o,empty:a,type:c,enumerable:l,reflect:u,attr:p,nullable:x,parser:g,nullParser:y,get:h,is:f,diff:d,props:m}=n;if(s??=[],o??=!1,a===void 0&&(a=null),r??=a,h&&!m){let b=ae(h.bind(t),t,()=>r);r??=b.defaultValue,m=new Set([...b.props.this,...b.props.args[0]])}if(!c)if(r==null)c="string";else{let b=typeof r;c=b==="number"?Number.isInteger(r)?"integer":"float":b}return l??=i[0]!=="_",x??=c==="boolean"?!1:a==null,x||(a??=je(c),r??=a),u??=l?c!=="object":p?"write":!1,p??=u?D(i):null,g??=Xe(c),y||(x?y=ze:y=a===null?()=>je(c):()=>a),f??=c==="object"||c==="proxy"?(b,w)=>!Me(b,w):c==="array"?()=>!1:Object.is,d===void 0&&(d=c==="object"?(b,w)=>Oe(b,w):null),{...n,type:c,is:f,diff:d,attr:p,reflect:u,readonly:o,enumerable:l,value:r,parser:g,nullParser:y,key:i,props:m,watchers:s}}function $(i,e,t){var r,o;i.get;let n=t==null?i.nullParser.call(this,t):i.parser.call(this,t),s=n;if(e==null){if(n==null)return!1}else if(n!=null){if(i.diff){if(s=i.diff.call(this,e,n),s==null)return!1}else if(i.is.call(this,e,n))return!1}return i.values?i.values.set(this,n):i.values=new WeakMap([[this,n]]),(r=i.propChangedCallback)==null||r.call(this,i.key,e,n,s),(o=i.changedCallback)==null||o.call(this,e,n,s),!0}function ce(i,e,t){let n=Ye(e,t,i);function s(h){if(n.type!=="proxy"||h==null||typeof h!="object")return h;let f=Y.get(h);if(f&&f.has(this))return f.get(this);let d=this;return Te(h,b=>{var P,j,T;let w=((P=n.values)==null?void 0:P.get(d))??h;(j=n.propChangedCallback)==null||j.call(d,n.key,w,w,b),(T=n.changedCallback)==null||T.call(d,w,w,b)},[],d,null)}function r(){var h;return(h=n.values)!=null&&h.has(this)?n.values.get(this):n.value}function o(){var f;if((f=n.values)!=null&&f.has(this))return n.values.get(this);let h=s.call(this,n.value);return h!==n.value&&(n.values?n.values.set(this,h):n.values=new WeakMap([[this,h]])),h}function a(h){var d;if(i===this&&((d=this==null?void 0:this.constructor)==null?void 0:d.prototype)===this)return;let f=this[e];$.call(this,n,f,h)}function c(h){var m;if(i===this&&((m=this==null?void 0:this.constructor)==null?void 0:m.prototype)===this)return;let f=this[e],d=s.call(this,h);$.call(this,n,f,d)}function l(){var d,m;let h=(d=n.computedValues)==null?void 0:d.get(this),f=this[e];(m=n.needsSelfInvalidation)==null||m.delete(this),$.call(this,n,h,f)}if(n.props)for(let h of n.props)n.watchers.push([h,l]);function u(){let h=n.get.call(this,this,r.bind(this));return(n.computedValues??=new WeakMap).set(this,h),h}function p(){let h=n.get.call(this,this,o.bind(this)),f=s.call(this,h);return(n.computedValues??=new WeakMap).set(this,f),f}function x(h){n.needsSelfInvalidation?n.needsSelfInvalidation.add(this):n.needsSelfInvalidation=new WeakSet([this]);let f=this[e];n.set.call(this,h,a.bind(this));let d=this[e];n.needsSelfInvalidation.has(this)&&(n.needsSelfInvalidation.delete(this),$.call(this,n,f,d))}function g(h){n.needsSelfInvalidation?n.needsSelfInvalidation.add(this):n.needsSelfInvalidation=new WeakSet([this]);let f=this[e];n.set.call(this,h,c.bind(this));let d=this[e];n.needsSelfInvalidation.has(this)&&(n.needsSelfInvalidation.delete(this),$.call(this,n,f,d))}let y={enumerable:n.enumerable,configurable:!0,get:n.get?n.type==="proxy"?p:u:n.type==="proxy"?o:r,set:n.set?n.type==="proxy"?g:x:n.type==="proxy"?c:a};return Object.defineProperty(i,e,y),n}var Fe=new Set;function H(i="mdw_",e=4){let t;for(;Fe.has(t=Math.random().toString(36).slice(2,e+2)););return Fe.add(t),`${i}${t}`}var le,Be,Re;function U(i){return le??=document.implementation.createHTMLDocument(),i?(Re??=le.createRange(),Re.createContextualFragment(i)):(Be??=le.createDocumentFragment(),Be.cloneNode())}var Z=new Map;function ue(i){let e=`#${H()}`;return Z.set(e,{fn:i}),`{${e}}`}var he=new Map;function de(i,...e){let t,n=e.map(o=>{switch(typeof o){case"string":return o;case"function":return ue(o);case"object":{if(o==null)return"";let a=H();return t??=new Map,t.set(a,o),`<div id="${a}"></div>`}default:throw new Error(`Unexpected substitution: ${o}`)}}),s=String.raw({raw:i},...n);if(t){let o=U(s);for(let[a,c]of t)o.getElementById(a).replaceWith(c);return o}let r;return he.has(s)?r=he.get(s):(r=U(s),he.set(s,r)),r.cloneNode(!0)}function Ze({nodes:i},e){let{nodeIndex:t,attrName:n}=this,s=i[t];switch(e){case void 0:case null:case!1:return s.removeAttribute(n),!1;case!0:return s.setAttribute(n,""),"";default:return s.setAttribute(n,e),e}}function Je({nodeStates:i,comments:e,nodes:t},n){let{commentIndex:s,nodeIndex:r}=this,o=i[r],a=o&1;if(!(n!=null&&n!==!1)){if(a)return;let p=e[s];p||(p=W(),e[s]=p),t[r].replaceWith(p),i[r]|=1;return}let l=t[r],u=o&2;if(typeof n!="object")if(u){let p=new Text(n);l.replaceWith(p),t[r]=p,i[r]&=-3}else l.data=n;a&&(e[s].replaceWith(l),i[r]&=-2)}function et({nodeStates:i,nodes:e,comments:t},n){let{commentIndex:s,nodeIndex:r}=this,o=i[r]&1,a=n!=null&&n!==!1;if(a===!o)return;let c=e[r],l=t[s];l||(l=W(),t[s]=l),a?(l.replaceWith(c),i[r]&=-2):(c.replaceWith(l),i[r]|=1)}function tt({comments:i,nodeStates:e,nodes:t}){let{commentIndex:n,nodeIndex:s}=this,r=W();i[n]=r,e[s]|=1,t[s].replaceWith(r)}function fe(i,...e){let[{caches:t,searchStates:n}]=e,{cacheIndex:s,searchIndex:r,subSearch:o,invocation:a}=i,c=t[s],l=n[r];if(l&1)return{value:c,dirty:(l&2)===2};n[r]|=1;let u;if(a){if(o){let p=fe(o,...e);if(!p.dirty&&c!==void 0)return n[r]&=-3,{value:c,dirty:!1};u=i.invocation(p.value)}else u=i.invocation(...e);if(u===void 0||c===u)return{value:u,dirty:!1}}return t[s]=u,n[r]|=2,{value:u,dirty:!0}}function We({options:{context:i,store:e,injections:t}},n,s){return this.expression.call(i,e??s,t)}function nt(i,e){return e[this.prop]}function st(i,e,t){let n=e;for(let s of this.deepProp){if(n===null)return null;if(!(s in n))return;n=n[s]}return n}var it=/{([^}]*)}/g;function rt(i,e){if(e)return e[i]}function K(i,e){if(!e)return;let t=e,n;for(n of i)if(typeof t=="object"){if(t===null)return null;if(!(n in t))return;t=t[n]}else return t[n];return t}function ot(i,e){let t=e;for(let n of i.split("."))if(!n||(t=t[n],t==null))return null;return t===e?null:t}var Le=new Map,V=class i{static EVENT_PREFIX_REGEX=/^([*1~]+)?(.*)$/;_interpolationState={nodeIndex:-1,searchIndex:0,cacheIndex:0,commentIndex:0,adapterIndex:0,nodeEntry:null};static shadowRootTag=Symbol();nodesToBind=[];props=[];searches=[];initCache=[];searchByQuery;actionsByPropsUsed;postInitActions=[];tagsWithBindings;tags=[];adapter;events;cloneable;styles=[];adoptedStyleSheets=[];stylesFragment;allIds=[];temporaryIds;interpolated=!1;constructor(...e){this.template=U(),this.append(...e)}*[Symbol.iterator](){for(let e of this.styles)yield e;yield this.template}static compose(...e){for(let[n,s]of Le)if(n.length===e.length&&e.every((r,o)=>r===n[o]))return s;let t=new i(...e);return Le.set(e,t),t}append(...e){for(let t of e)typeof t=="string"?this.append(U(t.trim())):t instanceof i?this.append(...t):t instanceof DocumentFragment?this.template.append(t):(t instanceof CSSStyleSheet||t instanceof HTMLStyleElement)&&this.styles.push(t);return this}addCompositionEventListener(e){let t=e.tag??"",n=this.events??=new Map;return n.has(t)?n.get(t).push(e):n.set(t,[e]),this}#s(e,t,n){var s;if((s=this.events)!=null&&s.has(e))for(let r of this.events.get(e)){let o;r.handleEvent?o=r.handleEvent:r.deepProp.length?o=K(r.deepProp,this.interpolateOptions.defaults):o=rt(r.prop,this.interpolateOptions.defaults),t.addEventListener(r.type,n?o.bind(n):o,r)}}render(e,t,n={}){this.interpolated||this.interpolate({defaults:t??e,...n});let s=this.cloneable.cloneNode(!0),r=n.shadowRoot,o=r??n.target??s.firstElementChild,a={lastChildNode:null,lastChildNodeIndex:0,lastElement:null,nodeStates:new Uint8Array(this._interpolationState.nodeIndex+1),searchStates:new Uint8Array(this._interpolationState.searchIndex),comments:[],nodes:[],caches:this.initCache.slice(),refs:[],adapters:[],options:n},{nodes:c,refs:l,searchStates:u,caches:p}=a;for(let{tag:g,textNodes:y}of this.nodesToBind){let h;if(g===""){if(!y.length)continue;l.push(null),c.push(null),h=s.firstChild}else{let d=s.getElementById(g);if(l.push(d),c.push(d),this.#s(g,d,n.context),!y.length)continue;h=d.firstChild}let f=0;for(let d of y){for(;d!==f;)h=h.nextSibling,f++;c.push(h)}}this.#s("",n.context),this.#s(i.shadowRootTag,n.context.shadowRoot,n.context);for(let g of this.postInitActions)g.invocation(a);let x=(g,y)=>{var f;if(!g)return;let h=!1;for(let d of this.props){if(!((f=this.actionsByPropsUsed)!=null&&f.has(d))||!(d in g))continue;let m=this.actionsByPropsUsed.get(d);for(let b of m){h=!0;let{dirty:w,value:P}=fe(b.search,a,g,y);w&&b.invocation(a,P,g,y)}}h&&u.fill(0)};return r?(n.context??=r.host,"adoptedStyleSheets"in r?this.adoptedStyleSheets.length&&(r.adoptedStyleSheets=[...r.adoptedStyleSheets,...this.adoptedStyleSheets]):this.stylesFragment.hasChildNodes()&&s.prepend(this.stylesFragment.cloneNode(!0))):n.context??=o,e!==this.interpolateOptions.defaults&&x(e,t),r&&(r.append(s),customElements.upgrade(r)),x.target=o,x.byProp=(g,y,h)=>{var b,w;if(!((b=this.actionsByPropsUsed)!=null&&b.has(g)))return;let f=!1;if((w=this.searchByQuery)!=null&&w.has(g)){f=!0;let P=this.searchByQuery.get(g);if(p[P.cacheIndex]===y)return;p[P.cacheIndex]=y,u[P.searchIndex]=3}let d,m=this.actionsByPropsUsed.get(g);for(let P of m)if(P.search.query===g)P.invocation(a,y);else{d??={[g]:y},h??=d,f=!0;let j=fe(P.search,a,d,h);j.dirty&&P.invocation(a,j.value,d,h)}f&&u.fill(0)},x.state=a,x}#n(e,t,n,s){var j,T;let{nodeValue:r,nodeName:o,nodeType:a}=e,c,l;if(a===Node.ATTRIBUTE_NODE?c=e:l=e,s==null){if(!r)return;let E=r.trim();if(!E)return;if(c||(t==null?void 0:t.tagName)==="STYLE"){if(E[0]!=="{")return;let{length:v}=E;if(E[v-1]!=="}")return;s=E.slice(1,-1)}else{let v=E.split(it);if(v.length<3)return;if(v.length===3&&!v[0]&&!v[2])s=v[1];else{for(let[C,S]of v.entries())if(C%2){let N=me();l.before(N),this.#n(N,t,n,S)}else S&&l.before(S);return!0}}}let u=s,p=s[0]==="!",x=!1;p&&(s=s.slice(1),x=s[0]==="!",x&&(s=s.slice(1)));let g,y;if(l){t!==l.parentElement&&(t=l.parentElement),y=0;let E=l;for(;E=E.previousSibling;)y++}else if(t!==c.ownerElement&&(t=c.ownerElement),o.startsWith("on")){let E=o.indexOf("-");if(E===-1)return;g=E===2}if(g){t.removeAttribute(o);let E=this.#t(t),v=o.slice(3),[,C,S]=v.match(/^([*1~]+)?(.*)$/),N,O,k=[];if(s.startsWith("#"))N=Z.get(s).fn;else{let _=s.split(".");_.length===1?(O=s,k=[]):(O=_[0],k=_)}this.addCompositionEventListener({tag:E,type:S,handleEvent:N,prop:O,deepProp:k,once:C==null?void 0:C.includes("1"),passive:C==null?void 0:C.includes("~"),capture:C==null?void 0:C.includes("*")});return}let h;if((j=this.searchByQuery)!=null&&j.has(u))h=this.searchByQuery.get(u);else{let E=s,v=E!==u,C;if(v&&((T=this.searchByQuery)!=null&&T.has(E)))C=this.searchByQuery.get(E);else{let S,N,O,k,_,B,R,A;if(s.startsWith("#")){if(A=Z.get(s),!A)return;S=A.fn,R=We,A.props?(N=A.props,O=A.deepProps,k=A.defaultValue??null):k=A.fn}else k=null,n!=null&&n.defaults&&(k=K(s.split("."),n.defaults)??null),k==null&&(n!=null&&n.injections)&&(k=ot(s,n.injections));if(!N)if(typeof k=="function"){let I=ae.call(this,k,n==null?void 0:n.defaults,n==null?void 0:n.injections),M=new Set([...I.props.this,...I.props.args[0],...I.props.args[1]]),F=new Set([...I.deepPropStrings.this,...I.deepPropStrings.args[0]]);S=k,k=I.defaultValue,N=[...M],O=[...F].map(L=>L.split(".")),R=We}else{let I=s.split(".");I.length===1?(_=s,N=[_],R=nt):(N=[I[0]],B=I,O=[I],R=st)}A&&(A.defaultValue=k,A.props=N,A.deepProps=O),C={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:E,defaultValue:k,subSearch:null,prop:_,propsUsed:N,deepProp:B,deepPropsUsed:O,invocation:R,expression:S},this.addSearch(C)}v?(h={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:u,subSearch:C,negate:p,doubleNegate:x,prop:C.prop,deepProp:C.deepProp,propsUsed:C.propsUsed,deepPropsUsed:C.deepPropsUsed,defaultValue:x?!!C.defaultValue:p?!C.defaultValue:C.defaultValue,invocation(S){return this.doubleNegate?!!S:this.negate?!S:S}},this.addSearch(h)):h=C}let f,d=null,m=h.defaultValue;l?d=y:o==="mdw-if"?(f=this.#t(t),t.removeAttribute(o),m=m!=null&&m!==!1):(d=o,o==="id"||m==null||m===!1?t.removeAttribute(o):t.setAttribute(o,m===!0?"":m)),f??=this.#t(t);let b=this._interpolationState.nodeEntry;(!b||b.tag!==f)&&(b={tag:f,textNodes:[]},this._interpolationState.nodeEntry=b,this.nodesToBind.push(b),this._interpolationState.nodeIndex++);let w;if(l)switch(b.textNodes.push(y),this._interpolationState.nodeIndex++,w={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,invocation:Je,defaultValue:m,search:h},typeof m){case"string":l.data=m;break;case"number":l.data=`${m}`;break;default:l.data="";break}else d?w={nodeIndex:this._interpolationState.nodeIndex,attrName:d,defaultValue:m,invocation:Ze,search:h}:(w={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,defaultValue:m,invocation:et,search:h},m||this.postInitActions.push({...w,invocation:tt}));this.addAction(w),(this.tagsWithBindings??=new Set).add(f)}#t(e){if(!e)return"";let t=e.id;return t?this.allIds.includes(t)||this.allIds.push(t):(t=H(),(this.temporaryIds??=new Set).add(t),this.allIds.push(t),e.id=t),t}#e(e,t){let n=e.getAttribute("mdw-for"),s=n==null?void 0:n.trim();if(!s||s[0]!=="{")return null;let{length:r}=s;if(s[r-1]!=="}")return null;let o=s.slice(1,-1),[a,c]=o.split(/\s+of\s+/);e.removeAttribute("mdw-for");let l=e.ownerDocument.createElement("template");e.replaceWith(l);let u=this.#t(l),p=this._interpolationState.nodeEntry;(!p||p.tag!==u)&&(p={tag:u,textNodes:[]},this._interpolationState.nodeEntry=p,this.nodesToBind.push(p),this._interpolationState.nodeIndex++);let x=new i;x.template.append(e);let g={...t.injections,[a]:null,index:null},y=c.split("."),h=y.length>1?y:null,f=h?y[0]:c,d=[f],m={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:null,prop:null,deepProp:h,propsUsed:d,deepPropsUsed:h?[h]:[[f]],defaultValue:{},invocation:null},b={defaultValue:null,nodeIndex:this._interpolationState.nodeIndex,search:m,commentIndex:this._interpolationState.commentIndex++,adapterIndex:this._interpolationState.adapterIndex++,injections:g,invocation(P,j,T,E){let v=P.adapters[this.adapterIndex],C=P.options.iterationIndex??0,S;if(!v||!(S=v[C])){let I=P.nodes[this.nodeIndex],M=W();if(P.comments[this.commentIndex])throw new Error("Comment already exists at index");P.comments[this.commentIndex]=M,I.replaceWith(M),S=new q({anchorNode:M,composition:x,renderOptions:{target:null,context:P.options.context,store:P.options.store,injections:this.injections}}),v=P.adapters[this.adapterIndex]??=[],v[C]=S}let N=P.options.injections??this.injections,O=E??P.options.store,k=h?K(h,O):O[f];if(k===void 0&&h&&N&&(k=K(h,N)),!k||k.length===0){S.removeEntries();return}let _=h?K(h,T):T[f];if(_===void 0)return;let B={...T},R=x.props.some(I=>I!==f&&I in T);S.startBatch();let A;if(!R&&!(A=Array.isArray(_))){let I=A?_.entries():Object.entries(_);for(let[M,F]of I){if(M==="length"||F===null)continue;let L=+M,pe=k[L];B[a]=F,N[a]=pe,N.index=L,S.renderOptions.injections=N,S.renderOptions.iterationIndex=L,S.renderData(L,B,E,pe,F)}}else{_||delete B[a];for(let[I,M]of k.entries()){let F;if(_){if(!R&&!(I in _)||(F=_[I],F===null))continue;B[a]=F}N[a]=M,N.index=I,S.renderOptions.injections=N,S.renderOptions.iterationIndex=I,S.renderData(I,B,E,M,F)}}S.stopBatch(),S.removeEntries(k.length)}};return x.interpolate({defaults:t.defaults,injections:g}),d.push(...x.props),this.addSearch(m),this.addAction(b),(this.tagsWithBindings??=new Set).add(u),x}interpolate(e){var r;this.interpolateOptions=e,this.cloneable=this.template.cloneNode(!0);let n=document.createTreeWalker(this.cloneable,5),s=n.nextNode();for(;s;){let o=null;switch(s.nodeType){case Node.ELEMENT_NODE:if(o=s,o.tagName==="TEMPLATE"){for(;o.contains(s=n.nextNode()););continue}if(o.tagName==="SCRIPT"){for(;o.contains(s=n.nextNode()););continue}if(o.hasAttribute("mdw-for")){for(;o.contains(s=n.nextNode()););this.#e(o,e);continue}else{let a=o.attributes.id;a&&(this.#n(a,o,e),this.#t(o));for(let c of[...o.attributes].reverse())c.nodeName!=="id"&&this.#n(c,o,e)}break;case Node.TEXT_NODE:if(o=s.parentElement,this.#n(s,o,e)){let a=n.nextNode();s.remove(),s=a;continue}break;default:throw new Error(`Unexpected node type: ${s.nodeType}`)}s=n.nextNode()}"adoptedStyleSheets"in document?this.adoptedStyleSheets=[...xe(this.styles)]:(this.stylesFragment=U(),this.stylesFragment.append(...Ce(this.styles))),this.props=this.actionsByPropsUsed?[...this.actionsByPropsUsed.keys()]:[];for(let o of this.allIds)(r=this.tagsWithBindings)!=null&&r.has(o)||this.nodesToBind.push({tag:o,textNodes:[]});this.tags=this.nodesToBind.map(o=>o.tag),this.interpolated=!0}addSearch(e){return this.searches.push(e),e.query&&((this.searchByQuery??=new Map).set(e.query,e),this.initCache[e.cacheIndex]=e.defaultValue),e}addAction(e){let t=this.actionsByPropsUsed??=new Map;for(let n of e.search.propsUsed)t.has(n)?t.get(n).push(e):t.set(n,[e]);return e}};function Tt(i,e){return(t,n,s)=>{n==null?s.refs[e].removeAttribute(i):s.refs[e].setAttribute(i,n)}}var J=class i extends HTMLElement{static elementName;static get observedAttributes(){return this.attrList.keys()}compose(){return this.#e??=new V}static _composition=null;static _props=new Map;static _attrs=new Map;static _propChangedCallbacks=new Map;static _attributeChangedCallbacks=new Map;static _onComposeCallbacks=[];static _onConnectedCallbacks=[];static _onDisconnectedCallbacks=[];static _onConstructedCallbacks=[];static interpolatesTemplate=!0;static supportsElementInternals="attachInternals"in HTMLElement.prototype;static supportsElementInternalsRole=i.supportsElementInternals&&"role"in ElementInternals.prototype;static defined=!1;static registrations=new Map;static expressions=this.set;static methods=this.set;static overrides=this.set;static props=this.observe;static idl=this.prop;static _addCallback(e,t){if(!this.hasOwnProperty(e)){this[e]=[...this[e],t];return}this[e].push(t)}static _removeCallback(e,t){this.hasOwnProperty(e)||(this[e]=[...this[e]]),this[e]=this[e].filter(n=>n!==t)}static _removeFromCallbackMap(e,t,n){if(!e.has(t))return;if(!n){e.delete(t);return}let s=e.get(t).filter(r=>r!==n);s.length===0?e.delete(t):e.set(t,s)}static append(...e){return this._onComposeCallbacks.push(({composition:t})=>{t.append(...e)}),this._addCallback("_onComposeCallbacks",(t=>{let{composition:n}=t;n.append(...e)})),this}static recompose(e){return this._addCallback("_onComposeCallbacks",e),this}static css(e,...t){return this._addCallback("_onComposeCallbacks",(n=>{let{composition:s}=n;typeof e=="string"||Array.isArray(e)?s.append(Se(e,...t)):s.append(e,...t)})),this}static autoRegister(e){return this.hasOwnProperty("defined")&&this.defined?this:(this.register(e),this)}static html(e,...t){return this._addCallback("_onComposeCallbacks",(n=>{let{composition:s}=n;s.append(de(e,...t))})),this}static extend(e){return e?e(this):class extends this{}}static setStatic(e){return Object.assign(this,e),this}static readonly(e,t){return this.set(e,{...t,writable:!1})}static set(e,t){return Object.defineProperties(this.prototype,Object.fromEntries([...Object.entries(e).map(([n,s])=>(this.undefine(n),[n,{enumerable:n[0]!=="_",configurable:!0,value:s,writable:!0,...t}])),...Object.getOwnPropertySymbols(e).map(n=>[n,{enumerable:!1,configurable:!0,value:e[n],writable:!0,...t}])])),this}static mixin(e){return e(this)}static register(e){return e&&(this.elementName=e),customElements.define(this.elementName,this),i.registrations.set(this.elementName,this),this.defined=!0,this}static get propList(){return this.hasOwnProperty("_props")||(this._props=new Map(this._props)),this._props}static get attrList(){return this.hasOwnProperty("_attrs")||(this._attrs=new Map(this._attrs)),this._attrs}static get propChangedCallbacks(){return this.hasOwnProperty("_propChangedCallbacks")||(this._propChangedCallbacks=new Map([...this._propChangedCallbacks].map(([e,t])=>[e,t.slice()]))),this._propChangedCallbacks}static get attributeChangedCallbacks(){return this.hasOwnProperty("_attributeChangedCallbacks")||(this._attributeChangedCallbacks=new Map([...this._attributeChangedCallbacks].map(([e,t])=>[e,t.slice()]))),this._attributeChangedCallbacks}static prop(e,t){let n=ce(this.prototype,e,t),{changedCallback:s,attr:r,reflect:o,watchers:a}=n;return s&&a.push([e,s]),n.changedCallback=function(l,u,p){this.#l.call(this,e,l,u,p)},this.propList.set(e,n),r&&(o===!0||o==="read")&&(n.enumerable||!this.attrList.has(r)||!this.attrList.get(r).enumerable)&&this.attrList.set(r,n),this.onPropChanged(a),this}static setPrototype(e,t){return this.prop(e,t),null}static define(e){return Object.defineProperties(this.prototype,Object.fromEntries(Object.entries(e).map(([t,n])=>(this.undefine(t),[t,{enumerable:t[0]!=="_",configurable:!0,...typeof n=="function"?{get:n}:n}])))),this}static undefine(e){if(Reflect.deleteProperty(this.prototype,e),this.propList.has(e)){let{watchers:t,attr:n,reflect:s}=this.propList.get(e);if(t.length&&this.propChangedCallbacks.has(e)){let r=this.propChangedCallbacks.get(e);for(let[o,a]of t){let c=r.indexOf(a);c!==-1&&r.splice(c,1)}}n&&(s===!0||s==="read")&&this.attrList.delete(n),this.propList.delete(e)}return this}static observe(e){for(let[t,n]of Object.entries(e??{})){let s=typeof n=="function"?{reflect:!1,get:n}:n;this.prop(t,s)}return this}static defineStatic(e){for(let[t,n]of Object.entries(e??{}))ce(this,t,{reflect:!1,...typeof n=="function"?{get:n}:typeof n=="string"?{type:n}:n});return this}static events(e,t){return this.on({composed({composition:n}){for(let[s,r]of Object.entries(e)){let[,o,a]=s.match(/^([*1~]+)?(.*)$/),c,l=[];if(typeof r=="string"){let u=r.split(".");u.length===1?(c=r,l=[]):(c=u[0],l=u)}n.addCompositionEventListener({type:a,once:o==null?void 0:o.includes("1"),passive:o==null?void 0:o.includes("~"),capture:o==null?void 0:o.includes("*"),...typeof r=="function"?{handleEvent:r}:typeof r=="string"?{prop:c,deepProp:l}:r,...t})}}}),this}static childEvents(e,t){for(let[n,s]of Object.entries(e))this.events(s,{tag:D(n),...t});return this}static rootEvents(e,t){return this.events(e,{tag:V.shadowRootTag,...t})}static on(e,t){let n=typeof e=="string"?{[e]:t}:e;for(let[s,r]of Object.entries(n)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.onPropChanged(r);continue;case"attrs":this.onAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.onPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._addCallback(o,r)}return this}static off(e,t){let n=typeof e=="string"?{[e]:t}:e;for(let[s,r]of Object.entries(n)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.offPropChanged(r);continue;case"attrs":this.offAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.offPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._removeCallback(o,r)}return this}static offPropChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:n}=this;for(let[s,r]of t)this._removeFromCallbackMap(n,s,r);return this}static offAttributeChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:n}=this;for(let[s,r]of t)this._removeFromCallbackMap(n,s,r);return this}static onPropChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:n}=this;for(let[s,r]of t)n.has(s)?n.get(s).push(r):n.set(s,[r]);return this}static onAttributeChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:n}=this;for(let[s,r]of t)n.has(s)?n.get(s).push(r):n.set(s,[r]);return this}#s;#n=new Map;#t=new Map;#e;#r=!1;#i=[];#o;#a=null;constructor(...e){super(),i.supportsElementInternals&&(this.elementInternals=this.attachInternals()),this.attachShadow({mode:"open",delegatesFocus:this.delegatesFocus}),this.render=this.composition.render(this.constructor.prototype,this,{defaults:this.constructor.prototype,store:this,shadowRoot:this.shadowRoot,context:this});for(let t of this.static._onConstructedCallbacks)t.call(this,this.callbackArguments)}propChangedCallback(e,t,n,s=n){this.#r?this.#i.push([e,s,this]):this.render.byProp(e,s,this);let{_propChangedCallbacks:r}=this.static;if(r.has(e))for(let o of r.get(e))o.call(this,t,n,s,this)}attributeChangedCallback(e,t,n){let{attributeChangedCallbacks:s}=this.static;if(s.has(e))for(let u of s.get(e))u.call(this,t,n,this);let{attrList:r}=this.static;if(!r.has(e))return;let o=r.get(e);if(o.attributeChangedCallback){o.attributeChangedCallback.call(this,e,t,n);return}let a;if(this.attributeCache.has(e)&&(a=this.attributeCache.get(e),a.stringValue===n))return;let c=this[o.key],l=n===null?o.nullParser(n):o.type==="boolean"?!0:o.parser(n);l!==c&&(a?(a.stringValue=n,a.parsedValue=l):this.attributeCache.set(e,{stringValue:n,parsedValue:l}),this[o.key]=l)}get#c(){var e;return(e=this.#e)==null?void 0:e.template}#l(e,t,n,s){let{propList:r}=this.static;if(r.has(e)){let{reflect:o,attr:a}=r.get(e);if(a&&(o===!0||o==="write")){let c,l=!1,{attributeCache:u}=this;if(u.has(a)?(c=u.get(a),l=c.parsedValue!==n):(c={},u.set(a,c),l=!0),l){let p=Ie(n);c.parsedValue=n,c.stringValue=p,p==null?this.removeAttribute(a):this.setAttribute(a,p)}}}this.propChangedCallback(e,t,n,s)}get static(){return this.constructor}patch(e){this.#r=!0,ve(this,e,"object");for(let[t,n,s]of this.#i)t in e||this.render.byProp(t,n,s);this.#i.slice(0,this.#i.length),this.render(e),this.#r=!1}get refs(){return this.#s??=new Proxy({},{get:(e,t)=>{let n=this.composition,s;if(!n.interpolated){if(this.#t.has(t)&&(s=this.#t.get(t).deref(),s))return s;let a=D(t);return s=n.template.getElementById(a),s?(this.#t.set(t,new WeakRef(s)),s):null}if(this.#n.has(t)&&(s=this.#n.get(t).deref(),s))return s;let r=D(t),o=this.composition.tags.indexOf(r);return s=this.render.state.refs[o],s?(this.#n.set(t,new WeakRef(s)),s):null}})}get attributeCache(){return this.#o??=new Map}get callbackArguments(){return this.#a??={composition:this.#e,refs:this.refs,html:de.bind(this),inline:ue,template:this.#c,element:this}}get composition(){if(this.#e)return this.#e;if(this.static.hasOwnProperty("_composition"))return this.#e=this.static._composition,this.static._composition;this.compose();for(let e of this.static._onComposeCallbacks)e.call(this,this.callbackArguments);return this.static._composition=this.#e,this.#e}connectedCallback(){for(let e of this.static._onConnectedCallbacks)e.call(this,this.callbackArguments)}disconnectedCallback(){for(let e of this.static._onDisconnectedCallbacks)e.call(this,this.callbackArguments)}};J.prototype.delegatesFocus=!1;export{Tt as cloneAttributeCallback,J as default};
1
+ var Le,Ue;function pe(){return(Le??=new Text).cloneNode()}function F(){return(Ue??=new Comment).cloneNode()}function Ve(i){var e,t;return(e=i==null?void 0:i.matches)!=null&&e.call(i,":focus")?i:(t=i==null?void 0:i.querySelector)==null?void 0:t.call(i,":focus")}function qe(i){i&&i.isConnected&&!i.matches(":focus")&&i.focus()}function me(i,e,t){let n=Ve(i);e?e.before(i):t.append(i),qe(n)}var $e=typeof Element.prototype.moveBefore=="function",J=$e?(i,e,t)=>{t.moveBefore(i,e)}:me,U=class{constructor(e){this.anchorNode=e.anchorNode,this.metadata=[],this.keys=[],this.needsArrayKeyFastPath=!1,this.composition=e.composition,this.renderOptions=e.renderOptions,this.metadataCache=null,this.queuedElements=[],this.batchStartIndex=null,this.batchEndIndex=null}render(e,t){return this.composition.render(e,t,this.renderOptions)}startBatch(){this.needsArrayKeyFastPath=!0}writeBatch(){var t;if(!this.queuedElements.length)return;(((t=this.metadata[this.batchStartIndex-1])==null?void 0:t.domNode)??this.anchorNode).after(...this.queuedElements),this.queuedElements.length=0}stopBatch(){if(this.writeBatch(),this.needsArrayKeyFastPath=!1,this.batchStartIndex=null,this.batchEndIndex=null,this.metadataCache){for(let{domNode:e}of this.metadataCache.values())e.remove();this.metadataCache.clear()}}moveToEndByIndex(e){let[t]=this.metadata.splice(e,1),{domNode:n,key:s}=t;this.keys.splice(e,1);let r=n.parentNode;r&&me(n,null,r),this.metadataCache?this.metadataCache.set(s,t):this.metadataCache=new Map([[s,t]])}renderData(e,t,n,s,r,o){if(e<this.metadata.length){let c=this.metadata[e],u=c.key,p=u===s,x=r!==s;if(p){x?c.render(t,n):o||c.render(t,n);return}let y=this.metadataCache??=new Map,C=!1;this.needsArrayKeyFastPath&&(C=!this.keys.includes(s),this.needsArrayFastPath=!1);let h=C?-1:this.keys.indexOf(s,e+1);if(h===-1){if(y.has(s)){let d=y.get(s);this.metadata.splice(e,0,d),this.keys.splice(e,0,s),J(d.domNode,c.domNode,c.domNode.parentNode),d.render(t,n),y.delete(s);return}y.set(u,c)}else{if(e-h===-1){this.moveToEndByIndex(e);return}let d=this.metadata[h];this.metadata[e]=d,this.metadata[h]=c;let{domNode:f}=c,m=f.parentNode,g=d.domNode.nextSibling;J(d.domNode,f,m),g&&J(f,g,m),o||d.render(t,n),this.keys[e]=s,this.keys[h]=u;return}}let a=this.render(t,n),l=a.target;this.metadata[e]={render:a,element:l,key:s,domNode:l},this.keys[e]=s,(this.batchEndIndex===null||this.batchEndIndex!==e-1)&&(this.writeBatch(),this.batchStartIndex=e),this.batchEndIndex=e,this.queuedElements.push(l)}removeEntries(e=0){let{length:t}=this.metadata;for(let n=t-1;n>=e;n--){let s=this.metadata[n];!s||!s.domNode||s.domNode.remove()}this.metadata.length=e,this.keys.length=e}hide(e,t,n){if(!t&&(e==null&&(e=this.keys.indexOf(n)),t=this.metadata[e],!t)||t.hidden)return!1;let{comment:s,element:r}=t;return s||(s=F(),t.comment=s),r.replaceWith(s),t.domNode=s,t.hidden=!0,!0}show(e,t,n){if(!t&&(e==null&&(e=this.keys.indexOf(n)),t=this.metadata[e],!t)||!t.hidden)return!1;let{comment:s,element:r}=t;return s.replaceWith(r),t.domNode=r,t.hidden=!1,!0}};var ee=new Map;function G(i,e=!0){if(e&&ee.has(i))return ee.get(i);let t=new CSSStyleSheet;return t.replaceSync(i),e&&ee.set(i,t),t}var te=new Map,ye;function He(i,e=!0){let t;return e&&te.has(i)?t=te.get(i):(ye??=document.implementation.createHTMLDocument(),t=ye.createElement("style"),t.textContent=i,e&&te.set(i,t)),t.cloneNode(!0)}var K;function be(i,e=!0){if(K==null)try{let t=G(i,e);return K=!0,t}catch{K=!1}return K?G(i,e):He(i,e)}function*ge(i,e=!0){for(let t of i)t instanceof HTMLStyleElement?yield G(t.textContent,e):t.ownerNode?yield G([...t.cssRules].map(n=>n.cssText).join(""),e):yield t}var ne=new WeakMap;function*Ce(i,e=!0){for(let t of i)if(t instanceof HTMLStyleElement)yield t;else if(t.ownerNode instanceof HTMLStyleElement)yield t.ownerNode.cloneNode(!0);else if(e&&ne.has(t))yield ne.get(t).cloneNode(!0);else{let n=document.createElement("style");n.textContent=[...t.cssRules].map(s=>s.cssText).join(""),e&&ne.set(t,n),yield n.cloneNode(!0)}}function xe(i,...e){return be(typeof i=="string"?i:String.raw({raw:i},...e))}function ke(i){switch(i){case void 0:case null:case!1:return null;case!0:return"";default:return`${i}`}}var Q;function R(i){if(Q??=new Map,Q.has(i))return Q.get(i);let e=i.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`);return Q.set(i,e),e}var we,Ke=Number.parseFloat((we=navigator.userAgent.match(/Chrome\/([\d.]+)/))==null?void 0:we[1]),Se,ut=Number.parseFloat((Se=navigator.userAgent.match(/Firefox\/([\d.]+)/))==null?void 0:Se[1]),Pe,dt=Ke||!navigator.userAgent.includes("AppleWebKit")?Number.NaN:Number.parseFloat((Pe=navigator.userAgent.match(/Version\/([\d.]+)/))==null?void 0:Pe[1]);function Ee(i,e){if(i===e)return i;if(Array.isArray(e)||i==null||e==null||typeof e!="object")return e;typeof i!="object"&&(i={});for(let[t,n]of Object.entries(e))n==null?t in i&&delete i[t]:i[t]=Ee(i[t],n);return i}function Ne(i,e){if(i===e)return i;let t=e!=null&&typeof e=="object"&&!Array.isArray(e),n=i!=null&&typeof i=="object"&&!Array.isArray(i);if(!t||!n)return e;for(let[s,r]of Object.entries(e))r==null?s in i&&delete i[s]:i[s]=Ne(i[s],r);return i}function Ie(i,e,t="reference"){switch(t){case"clone":case"object":return Ee(i,e);default:return Ne(i,e)}}function ve(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e))return e;let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=ve(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function _e(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e))return structuredClone(e);let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=_e(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function se(i,e){if(i===e)return null;if(e==null||typeof e!="object")return e;if(i==null||typeof i!="object")return structuredClone(e);let t={};if(Array.isArray(e)){for(let[s,r]of e.entries()){if(r===null){t[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(t[s]=o)}return e.length!==i.length&&(t.length=e.length),t}let n=new Set(Object.keys(i));for(let[s,r]of Object.entries(e)){if(n.delete(s),r===null){t[s]=null;continue}if(r==null)continue;let o=se(i[s],r);o!==null&&(t[s]=o)}for(let s of n)t[s]=null;return t}function Ae(i,e,t="reference"){switch(t){case"clone":return _e(i,e);case"object":return se(i,e);default:return ve(i,e)}}function ie(i,e){if(i===e)return!1;if(e==null||typeof e!="object"||i!=null&&typeof i!="object")return!0;for(let[t,n]of Object.entries(e))if(n==null){if(t in i)return!0}else if(ie(i[t],n))return!0;return!1}function Ge(i,e){return Array.isArray(e)?i!==e:ie(i,e)}function Me(i,e,t="reference"){switch(t){case"clone":case"object":return Ge(i,e);default:return ie(i,e)}}function Oe(i){switch(i){case"boolean":return!1;case"integer":case"float":case"number":return 0;case"map":return new Map;case"set":return new Set;case"array":return[];case"proxy":case"object":return null;default:case"string":return""}}function re(i,e,t,n){return i??={},new Proxy(i,{get(s,r){let o=s[r];if(typeof r!="symbol"){let a=n?`${n}.${r}`:r;if(n?t.add(a):e.add(a),typeof o=="object"&&o!=null)return re(o,e,t,a)}return o},has(s,r){let o=Reflect.has(s,r);if(typeof r!="symbol"){let a=n?`${n}.${r}`:r;n?t.add(a):e.add(a)}return o}})}var z=new WeakMap,oe=new WeakMap;function Qe(i){if(i==null||typeof i!="object")return null;let e=oe.get(i);if(!e){let t=new Set;e={subscribe(n){t.add(n)},unsubscribe(n){t.delete(n)},emit(n){for(let s of t)s(n)}},oe.set(i,e)}return e}function X(i,e){let t={},n=t;for(let s=0;s<i.length-1;s++)n[i[s]]={},n=n[i[s]];return n[i.at(-1)]=e,t}function je(i,e,t,n,s){if(i==null||typeof i!="object")return i;let r=Qe(i);s||(s=r);let o=z.get(i);if(o||(o=new Map,z.set(i,o)),o.has(n))return o.get(n);let a=new Proxy(i,{get(l,c){if(typeof c=="symbol")return l[c];let u=l[c];return je(u,e,t.concat(c),n,s)},set(l,c,u){if(l[c]=u,typeof c!="symbol"){let p=X(t.concat(c),u);if(e(p),s==null||s.emit(p),r&&r!==s){let x=X([c],u);r.emit(x)}}return!0},deleteProperty(l,c){if(typeof c!="symbol"){let u=X(t.concat(c),null);if(e(u),s==null||s.emit(u),r&&r!==s){let p=X([c],null);r.emit(p)}}return Reflect.deleteProperty(l,c)}});return z.set(a,o),r&&oe.set(a,r),o.set(n,a),a}function Xe(i){switch(i){case"boolean":return e=>!!e;case"integer":return Math.round;case"float":case"number":return e=>+e;case"map":return Map;case"set":return Set;case"object":case"array":case"proxy":return e=>e;default:case"string":return e=>`${e}`}}function ae(i,...e){let t=new Set,n=new Set,s=e.map(l=>{let c=new Set,u=new Set,p=re(l,c,u);return{poked:c,pokedDeep:u,proxy:p}}),r=re(this??{},t,n),o=i.apply(r,s.map(l=>l.proxy)),a=i.name?!0:!t.size;return{props:{this:[...t],args:s.map(l=>[...l.poked])},deepPropStrings:{this:[...n],args:s.map(l=>[...l.pokedDeep])},deepProps:{this:[...n].map(l=>l.split(".")),args:s.map(l=>[...l.pokedDeep].map(c=>c.split(".")))},defaultValue:o,reusable:a}}function ze(){return null}function Ye(i,e,t){let n=typeof e=="string"?{type:e}:e,{watchers:s,value:r,readonly:o,empty:a,type:l,enumerable:c,reflect:u,attr:p,nullable:x,parser:y,nullParser:C,get:h,is:d,diff:f,props:m}=n;if(s??=[],o??=!1,a===void 0&&(a=null),r??=a,h&&!m){let g=ae(h.bind(t),t,()=>r);r??=g.defaultValue,m=new Set([...g.props.this,...g.props.args[0]])}if(!l)if(r==null)l="string";else{let g=typeof r;l=g==="number"?Number.isInteger(r)?"integer":"float":g}return c??=i[0]!=="_",x??=l==="boolean"?!1:a==null,x||(a??=Oe(l),r??=a),u??=c?l!=="object":p?"write":!1,p??=u?R(i):null,y??=Xe(l),C||(x?C=ze:C=a===null?()=>Oe(l):()=>a),d??=l==="object"||l==="proxy"?(g,N)=>!Me(g,N):l==="array"?()=>!1:Object.is,f===void 0&&(f=l==="object"?(g,N)=>Ae(g,N):null),{...n,type:l,is:d,diff:f,attr:p,reflect:u,readonly:o,enumerable:c,value:r,parser:y,nullParser:C,key:i,props:m,watchers:s}}function V(i,e,t){var r,o;i.get;let n=t==null?i.nullParser.call(this,t):i.parser.call(this,t),s=n;if(e==null){if(n==null)return!1}else if(n!=null){if(i.diff){if(s=i.diff.call(this,e,n),s==null)return!1}else if(i.is.call(this,e,n))return!1}return i.values?i.values.set(this,n):i.values=new WeakMap([[this,n]]),(r=i.propChangedCallback)==null||r.call(this,i.key,e,n,s),(o=i.changedCallback)==null||o.call(this,e,n,s),!0}function ce(i,e,t){let n=Ye(e,t,i);function s(h){if(n.type!=="proxy"||h==null||typeof h!="object")return h;let d=z.get(h);if(d&&d.has(this))return d.get(this);let f=this;return je(h,g=>{var S,O,j;let N=((S=n.values)==null?void 0:S.get(f))??h;(O=n.propChangedCallback)==null||O.call(f,n.key,N,N,g),(j=n.changedCallback)==null||j.call(f,N,N,g)},[],f,null)}function r(){var h;return(h=n.values)!=null&&h.has(this)?n.values.get(this):n.value}function o(){var d;if((d=n.values)!=null&&d.has(this))return n.values.get(this);let h=s.call(this,n.value);return h!==n.value&&(n.values?n.values.set(this,h):n.values=new WeakMap([[this,h]])),h}function a(h){var f;if(i===this&&((f=this==null?void 0:this.constructor)==null?void 0:f.prototype)===this)return;let d=this[e];V.call(this,n,d,h)}function l(h){var m;if(i===this&&((m=this==null?void 0:this.constructor)==null?void 0:m.prototype)===this)return;let d=this[e],f=s.call(this,h);V.call(this,n,d,f)}function c(){var f,m;let h=(f=n.computedValues)==null?void 0:f.get(this),d=this[e];(m=n.needsSelfInvalidation)==null||m.delete(this),V.call(this,n,h,d)}if(n.props)for(let h of n.props)n.watchers.push([h,c]);function u(){let h=n.get.call(this,this,r.bind(this));return(n.computedValues??=new WeakMap).set(this,h),h}function p(){let h=n.get.call(this,this,o.bind(this)),d=s.call(this,h);return(n.computedValues??=new WeakMap).set(this,d),d}function x(h){n.needsSelfInvalidation?n.needsSelfInvalidation.add(this):n.needsSelfInvalidation=new WeakSet([this]);let d=this[e];n.set.call(this,h,a.bind(this));let f=this[e];n.needsSelfInvalidation.has(this)&&(n.needsSelfInvalidation.delete(this),V.call(this,n,d,f))}function y(h){n.needsSelfInvalidation?n.needsSelfInvalidation.add(this):n.needsSelfInvalidation=new WeakSet([this]);let d=this[e];n.set.call(this,h,l.bind(this));let f=this[e];n.needsSelfInvalidation.has(this)&&(n.needsSelfInvalidation.delete(this),V.call(this,n,d,f))}let C={enumerable:n.enumerable,configurable:!0,get:n.get?n.type==="proxy"?p:u:n.type==="proxy"?o:r,set:n.set?n.type==="proxy"?y:x:n.type==="proxy"?l:a};return Object.defineProperty(i,e,C),n}var Te=new Set;function q(i="mdw_",e=4){let t;for(;Te.has(t=Math.random().toString(36).slice(2,e+2)););return Te.add(t),`${i}${t}`}var le,Fe,Re;function B(i){return le??=document.implementation.createHTMLDocument(),i?(Re??=le.createRange(),Re.createContextualFragment(i)):(Fe??=le.createDocumentFragment(),Fe.cloneNode())}var Y=new Map;function ue(i){let e=`#${q()}`;return Y.set(e,{fn:i}),`{${e}}`}var he=new Map;function de(i,...e){let t,n=e.map(o=>{switch(typeof o){case"string":return o;case"function":return ue(o);case"object":{if(o==null)return"";let a=q();return t??=new Map,t.set(a,o),`<div id="${a}"></div>`}default:throw new Error(`Unexpected substitution: ${o}`)}}),s=String.raw({raw:i},...n);if(t){let o=B(s);for(let[a,l]of t)o.getElementById(a).replaceWith(l);return o}let r;return he.has(s)?r=he.get(s):(r=B(s),he.set(s,r)),r.cloneNode(!0)}function Ze({nodes:i},e){let{nodeIndex:t,attrName:n}=this,s=i[t];switch(e){case void 0:case null:case!1:return s.removeAttribute(n),!1;case!0:return s.setAttribute(n,""),"";default:return s.setAttribute(n,e),e}}function Je({nodeStates:i,comments:e,nodes:t},n){let{commentIndex:s,nodeIndex:r}=this,o=i[r],a=o&1;if(!(n!=null&&n!==!1)){if(a)return;let p=e[s];p||(p=F(),e[s]=p),t[r].replaceWith(p),i[r]|=1;return}let c=t[r],u=o&2;if(n instanceof Node)n.nodeType===11||c!==n&&(c.replaceWith(n),t[r]=n),i[r]|=2;else if(typeof n!="object")if(u){let p=new Text(n);c.replaceWith(p),t[r]=p,i[r]&=-3}else c.data=n;a&&(e[s].replaceWith(c),i[r]&=-2)}function et({nodeStates:i,nodes:e,comments:t},n){let{commentIndex:s,nodeIndex:r}=this,o=i[r]&1,a=n!=null&&n!==!1;if(a===!o)return;let l=e[r],c=t[s];c||(c=F(),t[s]=c),a?(c.replaceWith(l),i[r]&=-2):(l.replaceWith(c),i[r]|=1)}function tt({comments:i,nodeStates:e,nodes:t}){let{commentIndex:n,nodeIndex:s}=this,r=F();i[n]=r,e[s]|=1,t[s].replaceWith(r)}function fe(i,...e){let[{caches:t,searchStates:n}]=e,{cacheIndex:s,searchIndex:r,subSearch:o,invocation:a}=i,l=t[s],c=n[r];if(c&1)return{value:l,dirty:(c&2)===2};n[r]|=1;let u;if(a){if(o){let p=fe(o,...e);if(!p.dirty&&l!==void 0)return n[r]&=-3,{value:l,dirty:!1};u=i.invocation(p.value)}else u=i.invocation(...e);if(u===void 0||l===u)return{value:u,dirty:!1}}return t[s]=u,n[r]|=2,{value:u,dirty:!0}}function Be({options:{context:i,store:e,injections:t}},n,s){return this.expression.call(i,e??s,t)}function nt(i,e){return e[this.prop]}function st(i,e,t){let n=e;for(let s of this.deepProp){if(n==null)return n;if(!(s in n))return;n=n[s]}return n}var it=/{([^}]*)}/g;function rt(i,e){if(e)return e[i]}function $(i,e){if(!e)return;let t=e,n;for(n of i)if(typeof t=="object"){if(t===null)return null;if(!(n in t))return;t=t[n]}else return t[n];return t}function ot(i,e){let t=e;for(let n of i.split("."))if(!n||(t=t[n],t==null))return null;return t===e?null:t}var We=new Map,W=class i{static EVENT_PREFIX_REGEX=/^([*1~]+)?(.*)$/;_interpolationState={nodeIndex:-1,searchIndex:0,cacheIndex:0,commentIndex:0,adapterIndex:0,nodeEntry:null};static shadowRootTag=Symbol();nodesToBind=[];props=[];searches=[];initCache=[];searchByQuery;actionsByPropsUsed;postInitActions=[];tagsWithBindings;tags=[];adapter;events;cloneable;styles=[];adoptedStyleSheets=[];stylesFragment;allIds=[];temporaryIds;interpolated=!1;constructor(...e){this.template=B(),this.append(...e)}*[Symbol.iterator](){for(let e of this.styles)yield e;yield this.template}static compose(...e){for(let[n,s]of We)if(n.length===e.length&&e.every((r,o)=>r===n[o]))return s;let t=new i(...e);return We.set(e,t),t}append(...e){for(let t of e)typeof t=="string"?this.append(B(t.trim())):t instanceof i?this.append(...t):t instanceof DocumentFragment?this.template.append(t):(t instanceof CSSStyleSheet||t instanceof HTMLStyleElement)&&this.styles.push(t);return this}addCompositionEventListener(e){let t=e.tag??"",n=this.events??=new Map;return n.has(t)?n.get(t).push(e):n.set(t,[e]),this}#s(e,t,n){var s;if((s=this.events)!=null&&s.has(e))for(let r of this.events.get(e)){let o;r.handleEvent?o=r.handleEvent:r.deepProp.length?o=$(r.deepProp,this.interpolateOptions.defaults):o=rt(r.prop,this.interpolateOptions.defaults),t.addEventListener(r.type,n?o.bind(n):o,r)}}render(e,t,n={}){this.interpolated||this.interpolate({defaults:t??e,...n});let s=this.cloneable.cloneNode(!0),r=n.shadowRoot,o=r??n.target??s.firstElementChild,a={lastChildNode:null,lastChildNodeIndex:0,lastElement:null,nodeStates:new Uint8Array(this._interpolationState.nodeIndex+1),searchStates:new Uint8Array(this._interpolationState.searchIndex),comments:[],nodes:[],caches:this.initCache.slice(),refs:[],adapters:[],options:n},{nodes:l,refs:c,searchStates:u,caches:p}=a;for(let{tag:y,textNodes:C}of this.nodesToBind){let h;if(y===""){if(!C.length)continue;c.push(null),l.push(null),h=s.firstChild}else{let f=s.getElementById(y);if(c.push(f),l.push(f),this.#s(y,f,n.context),!C.length)continue;h=f.firstChild}let d=0;for(let f of C){for(;f!==d;)h=h.nextSibling,d++;l.push(h)}}this.#s("",n.context),this.#s(i.shadowRootTag,n.context.shadowRoot,n.context);for(let y of this.postInitActions)y.invocation(a);let x=(y,C)=>{var d;if(!y)return;let h=!1;for(let f of this.props){if(!((d=this.actionsByPropsUsed)!=null&&d.has(f))||!(f in y))continue;let m=this.actionsByPropsUsed.get(f);for(let g of m){h=!0;let{dirty:N,value:S}=fe(g.search,a,y,C);N&&g.invocation(a,S,y,C)}}h&&u.fill(0)};return r?(n.context??=r.host,"adoptedStyleSheets"in r?this.adoptedStyleSheets.length&&(r.adoptedStyleSheets=[...r.adoptedStyleSheets,...this.adoptedStyleSheets]):this.stylesFragment.hasChildNodes()&&s.prepend(this.stylesFragment.cloneNode(!0))):n.context??=o,e!==this.interpolateOptions.defaults&&x(e,t),r&&(r.append(s),customElements.upgrade(r)),x.target=o,x.byProp=(y,C,h)=>{var g,N;if(!((g=this.actionsByPropsUsed)!=null&&g.has(y)))return;let d=!1;if((N=this.searchByQuery)!=null&&N.has(y)){d=!0;let S=this.searchByQuery.get(y);if(p[S.cacheIndex]===C)return;p[S.cacheIndex]=C,u[S.searchIndex]=3}let f,m=this.actionsByPropsUsed.get(y);for(let S of m)if(S.search.query===y)S.invocation(a,C);else{f??={[y]:C},h??=f,d=!0;let O=fe(S.search,a,f,h);O.dirty&&S.invocation(a,O.value,f,h)}d&&u.fill(0)},x.state=a,x}#n(e,t,n,s){var O,j;let{nodeValue:r,nodeName:o,nodeType:a}=e,l,c;if(a===Node.ATTRIBUTE_NODE?l=e:c=e,s==null){if(!r)return;let P=r.trim();if(!P)return;if(l||(t==null?void 0:t.tagName)==="STYLE"){if(P[0]!=="{")return;let{length:w}=P;if(P[w-1]!=="}")return;s=P.slice(1,-1)}else{let w=P.split(it);if(w.length<3)return;if(w.length===3&&!w[0]&&!w[2])s=w[1];else{for(let[b,M]of w.entries())if(b%2){let I=pe();c.before(I),this.#n(I,t,n,M)}else M&&c.before(M);return!0}}}let u=s,p=s[0]==="!",x=!1;p&&(s=s.slice(1),x=s[0]==="!",x&&(s=s.slice(1)));let y,C;if(c){t!==c.parentElement&&(t=c.parentElement),C=0;let P=c;for(;P=P.previousSibling;)C++}else if(t!==l.ownerElement&&(t=l.ownerElement),o.startsWith("on")){let P=o.indexOf("-");if(P===-1)return;y=P===2}if(y){t.removeAttribute(o);let P=this.#t(t),w=o.slice(3),[,b,M]=w.match(/^([*1~]+)?(.*)$/),I,_,k=[];if(s.startsWith("#"))I=Y.get(s).fn;else{let T=s.split(".");T.length===1?(_=s,k=[]):(_=T[0],k=T)}this.addCompositionEventListener({tag:P,type:M,handleEvent:I,prop:_,deepProp:k,once:b==null?void 0:b.includes("1"),passive:b==null?void 0:b.includes("~"),capture:b==null?void 0:b.includes("*")});return}let h;if((O=this.searchByQuery)!=null&&O.has(u))h=this.searchByQuery.get(u);else{let P=s,w=P!==u,b;if(w&&((j=this.searchByQuery)!=null&&j.has(P)))b=this.searchByQuery.get(P);else{let M,I,_,k,T,D,A,E;if(s.startsWith("#")){if(E=Y.get(s),!E)return;M=E.fn,A=Be,E.props?(I=E.props,_=E.deepProps,k=E.defaultValue??null):k=E.fn}else k=null,n!=null&&n.defaults&&(k=$(s.split("."),n.defaults)??null),k==null&&(n!=null&&n.injections)&&(k=ot(s,n.injections));if(!I)if(typeof k=="function"){let v=ae.call(this,k,n==null?void 0:n.defaults,n==null?void 0:n.injections),L=new Set([...v.props.this,...v.props.args[0],...v.props.args[1]]),H=new Set([...v.deepPropStrings.this,...v.deepPropStrings.args[0]]);M=k,k=v.defaultValue,I=[...L],_=[...H].map(De=>De.split(".")),A=Be}else{let v=s.split(".");v.length===1?(T=s,I=[T],A=nt):(I=[v[0]],D=v,_=[v],A=st)}E&&(E.defaultValue=k,E.props=I,E.deepProps=_),b={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:P,defaultValue:k,subSearch:null,prop:T,propsUsed:I,deepProp:D,deepPropsUsed:_,invocation:A,expression:M},this.addSearch(b)}w?(h={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:u,subSearch:b,negate:p,doubleNegate:x,prop:b.prop,deepProp:b.deepProp,propsUsed:b.propsUsed,deepPropsUsed:b.deepPropsUsed,defaultValue:x?!!b.defaultValue:p?!b.defaultValue:b.defaultValue,invocation(M){return this.doubleNegate?!!M:this.negate?!M:M}},this.addSearch(h)):h=b}let d,f=null,m=h.defaultValue;c?f=C:o==="mdw-if"?(d=this.#t(t),t.removeAttribute(o),m=m!=null&&m!==!1):(f=o,o==="id"||m==null||m===!1?t.removeAttribute(o):t.setAttribute(o,m===!0?"":m)),d??=this.#t(t);let g=this._interpolationState.nodeEntry;(!g||g.tag!==d)&&(g={tag:d,textNodes:[]},this._interpolationState.nodeEntry=g,this.nodesToBind.push(g),this._interpolationState.nodeIndex++);let N;if(c)switch(g.textNodes.push(C),this._interpolationState.nodeIndex++,N={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,invocation:Je,defaultValue:m,search:h},typeof m){case"string":c.data=m;break;case"number":c.data=`${m}`;break;default:c.data="";break}else f?N={nodeIndex:this._interpolationState.nodeIndex,attrName:f,defaultValue:m,invocation:Ze,search:h}:(N={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,defaultValue:m,invocation:et,search:h},m||this.postInitActions.push({...N,invocation:tt}));this.addAction(N),(this.tagsWithBindings??=new Set).add(d)}#t(e){if(!e)return"";let t=e.id;return t?this.allIds.includes(t)||this.allIds.push(t):(t=q(),(this.temporaryIds??=new Set).add(t),this.allIds.push(t),e.id=t),t}#e(e,t){let n=e.getAttribute("mdw-for"),s=n==null?void 0:n.trim();if(!s||s[0]!=="{")return null;let{length:r}=s;if(s[r-1]!=="}")return null;let o=s.slice(1,-1),[a,l]=o.split(/\s+of\s+/);e.removeAttribute("mdw-for");let c=e.ownerDocument.createElement("template");e.replaceWith(c);let u=this.#t(c),p=this._interpolationState.nodeEntry;(!p||p.tag!==u)&&(p={tag:u,textNodes:[]},this._interpolationState.nodeEntry=p,this.nodesToBind.push(p),this._interpolationState.nodeIndex++);let x=new i;x.template.append(e);let y={...t.injections,[a]:null,index:null},C=l.split("."),h=C.length>1?C:null,d=h?C[0]:l,f=[d],m={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:null,prop:null,deepProp:h,propsUsed:f,deepPropsUsed:h?[h]:[[d]],defaultValue:{},invocation:null},g={defaultValue:null,nodeIndex:this._interpolationState.nodeIndex,search:m,commentIndex:this._interpolationState.commentIndex++,adapterIndex:this._interpolationState.adapterIndex++,injections:y,invocation(S,O,j,P){let w=S.adapters[this.adapterIndex];if(!w){let A=S.nodes[this.nodeIndex],E=F();if(S.comments[this.commentIndex])throw new Error("Comment already exists at index");S.comments[this.commentIndex]=E,A.replaceWith(E),w=new U({anchorNode:E,composition:x,renderOptions:{target:null,context:S.options.context,store:S.options.store,injections:this.injections}}),S.adapters[this.adapterIndex]=w}let b=S.options.injections??this.injections,M=P??S.options.store,I=h?$(h,M):M[d];if(I===void 0&&h&&b&&(I=$(h,b)),!I||I.length===0){w.removeEntries();return}let _=h?$(h,j):j[d];if(_===void 0)return;let k={...j},T=x.props.some(A=>A!==d&&A in j);w.startBatch();let D;if(!T&&!(D=Array.isArray(_))){let A=D?_.entries():Object.entries(_);for(let[E,v]of A){if(E==="length"||v===null)continue;let L=+E,H=I[L];k[a]=v,b[a]=H,b.index=L,w.renderOptions.injections=b,w.renderData(L,k,P,H,v)}}else{_||delete k[a];for(let[A,E]of I.entries()){let v;if(_){if(!T&&!(A in _)||(v=_[A],v===null))continue;k[a]=v}b[a]=E,b.index=A,w.renderOptions.injections=b,w.renderData(A,k,P,E,v)}}w.stopBatch(),w.removeEntries(I.length)}};return x.interpolate({defaults:t.defaults,injections:y}),f.push(...x.props),this.addSearch(m),this.addAction(g),(this.tagsWithBindings??=new Set).add(u),x}interpolate(e){var r;this.interpolateOptions=e,this.cloneable=this.template.cloneNode(!0);let n=document.createTreeWalker(this.cloneable,5),s=n.nextNode();for(;s;){let o=null;switch(s.nodeType){case Node.ELEMENT_NODE:if(o=s,o.tagName==="TEMPLATE"){for(;o.contains(s=n.nextNode()););continue}if(o.tagName==="SCRIPT"){for(;o.contains(s=n.nextNode()););continue}if(o.hasAttribute("mdw-for")){for(;o.contains(s=n.nextNode()););this.#e(o,e);continue}else{let a=o.attributes.id;a&&(this.#n(a,o,e),this.#t(o));for(let l of[...o.attributes].reverse())l.nodeName!=="id"&&this.#n(l,o,e)}break;case Node.TEXT_NODE:if(o=s.parentElement,this.#n(s,o,e)){let a=n.nextNode();s.remove(),s=a;continue}break;default:throw new Error(`Unexpected node type: ${s.nodeType}`)}s=n.nextNode()}"adoptedStyleSheets"in document?this.adoptedStyleSheets=[...ge(this.styles)]:(this.stylesFragment=B(),this.stylesFragment.append(...Ce(this.styles))),this.props=this.actionsByPropsUsed?[...this.actionsByPropsUsed.keys()]:[];for(let o of this.allIds)(r=this.tagsWithBindings)!=null&&r.has(o)||this.nodesToBind.push({tag:o,textNodes:[]});this.tags=this.nodesToBind.map(o=>o.tag),this.interpolated=!0}addSearch(e){return this.searches.push(e),e.query&&((this.searchByQuery??=new Map).set(e.query,e),this.initCache[e.cacheIndex]=e.defaultValue),e}addAction(e){let t=this.actionsByPropsUsed??=new Map;for(let n of e.search.propsUsed)t.has(n)?t.get(n).push(e):t.set(n,[e]);return e}};function Tt(i,e){return(t,n,s)=>{n==null?s.refs[e].removeAttribute(i):s.refs[e].setAttribute(i,n)}}var Z=class i extends HTMLElement{static elementName;static get observedAttributes(){return this.attrList.keys()}compose(){return this.#e??=new W}static _composition=null;static _props=new Map;static _attrs=new Map;static _propChangedCallbacks=new Map;static _attributeChangedCallbacks=new Map;static _onComposeCallbacks=[];static _onConnectedCallbacks=[];static _onDisconnectedCallbacks=[];static _onConstructedCallbacks=[];static interpolatesTemplate=!0;static supportsElementInternals="attachInternals"in HTMLElement.prototype;static supportsElementInternalsRole=i.supportsElementInternals&&"role"in ElementInternals.prototype;static defined=!1;static registrations=new Map;static expressions=this.set;static methods=this.set;static overrides=this.set;static props=this.observe;static idl=this.prop;static _addCallback(e,t){if(!this.hasOwnProperty(e)){this[e]=[...this[e],t];return}this[e].push(t)}static _removeCallback(e,t){this.hasOwnProperty(e)||(this[e]=[...this[e]]),this[e]=this[e].filter(n=>n!==t)}static _removeFromCallbackMap(e,t,n){if(!e.has(t))return;if(!n){e.delete(t);return}let s=e.get(t).filter(r=>r!==n);s.length===0?e.delete(t):e.set(t,s)}static append(...e){return this._onComposeCallbacks.push(({composition:t})=>{t.append(...e)}),this._addCallback("_onComposeCallbacks",(t=>{let{composition:n}=t;n.append(...e)})),this}static recompose(e){return this._addCallback("_onComposeCallbacks",e),this}static css(e,...t){return this._addCallback("_onComposeCallbacks",(n=>{let{composition:s}=n;typeof e=="string"||Array.isArray(e)?s.append(xe(e,...t)):s.append(e,...t)})),this}static autoRegister(e){return this.hasOwnProperty("defined")&&this.defined?this:(this.register(e),this)}static html(e,...t){return this._addCallback("_onComposeCallbacks",(n=>{let{composition:s}=n;s.append(de(e,...t))})),this}static extend(e){return e?e(this):class extends this{}}static setStatic(e){return Object.assign(this,e),this}static readonly(e,t){return this.set(e,{...t,writable:!1})}static set(e,t){return Object.defineProperties(this.prototype,Object.fromEntries([...Object.entries(e).map(([n,s])=>(this.undefine(n),[n,{enumerable:n[0]!=="_",configurable:!0,value:s,writable:!0,...t}])),...Object.getOwnPropertySymbols(e).map(n=>[n,{enumerable:!1,configurable:!0,value:e[n],writable:!0,...t}])])),this}static mixin(e){return e(this)}static register(e){return e&&(this.elementName=e),customElements.define(this.elementName,this),i.registrations.set(this.elementName,this),this.defined=!0,this}static get propList(){return this.hasOwnProperty("_props")||(this._props=new Map(this._props)),this._props}static get attrList(){return this.hasOwnProperty("_attrs")||(this._attrs=new Map(this._attrs)),this._attrs}static get propChangedCallbacks(){return this.hasOwnProperty("_propChangedCallbacks")||(this._propChangedCallbacks=new Map([...this._propChangedCallbacks].map(([e,t])=>[e,t.slice()]))),this._propChangedCallbacks}static get attributeChangedCallbacks(){return this.hasOwnProperty("_attributeChangedCallbacks")||(this._attributeChangedCallbacks=new Map([...this._attributeChangedCallbacks].map(([e,t])=>[e,t.slice()]))),this._attributeChangedCallbacks}static prop(e,t){let n=ce(this.prototype,e,t),{changedCallback:s,attr:r,reflect:o,watchers:a}=n;return s&&a.push([e,s]),n.changedCallback=function(c,u,p){this.#l.call(this,e,c,u,p)},this.propList.set(e,n),r&&(o===!0||o==="read")&&(n.enumerable||!this.attrList.has(r)||!this.attrList.get(r).enumerable)&&this.attrList.set(r,n),this.onPropChanged(a),this}static setPrototype(e,t){return this.prop(e,t),null}static define(e){return Object.defineProperties(this.prototype,Object.fromEntries(Object.entries(e).map(([t,n])=>(this.undefine(t),[t,{enumerable:t[0]!=="_",configurable:!0,...typeof n=="function"?{get:n}:n}])))),this}static undefine(e){if(Reflect.deleteProperty(this.prototype,e),this.propList.has(e)){let{watchers:t,attr:n,reflect:s}=this.propList.get(e);if(t.length&&this.propChangedCallbacks.has(e)){let r=this.propChangedCallbacks.get(e);for(let[o,a]of t){let l=r.indexOf(a);l!==-1&&r.splice(l,1)}}n&&(s===!0||s==="read")&&this.attrList.delete(n),this.propList.delete(e)}return this}static observe(e){for(let[t,n]of Object.entries(e??{})){let s=typeof n=="function"?{reflect:!1,get:n}:n;this.prop(t,s)}return this}static defineStatic(e){for(let[t,n]of Object.entries(e??{}))ce(this,t,{reflect:!1,...typeof n=="function"?{get:n}:typeof n=="string"?{type:n}:n});return this}static events(e,t){return this.on({composed({composition:n}){for(let[s,r]of Object.entries(e)){let[,o,a]=s.match(/^([*1~]+)?(.*)$/),l,c=[];if(typeof r=="string"){let u=r.split(".");u.length===1?(l=r,c=[]):(l=u[0],c=u)}n.addCompositionEventListener({type:a,once:o==null?void 0:o.includes("1"),passive:o==null?void 0:o.includes("~"),capture:o==null?void 0:o.includes("*"),...typeof r=="function"?{handleEvent:r}:typeof r=="string"?{prop:l,deepProp:c}:r,...t})}}}),this}static childEvents(e,t){for(let[n,s]of Object.entries(e))this.events(s,{tag:R(n),...t});return this}static rootEvents(e,t){return this.events(e,{tag:W.shadowRootTag,...t})}static on(e,t){let n=typeof e=="string"?{[e]:t}:e;for(let[s,r]of Object.entries(n)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.onPropChanged(r);continue;case"attrs":this.onAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.onPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._addCallback(o,r)}return this}static off(e,t){let n=typeof e=="string"?{[e]:t}:e;for(let[s,r]of Object.entries(n)){let o;switch(s){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.offPropChanged(r);continue;case"attrs":this.offAttributeChanged(r);continue;default:if(s.endsWith("Changed")){let a=s.slice(0,s.length-7);this.offPropChanged({[a]:r});continue}throw new Error("Invalid callback name")}this._removeCallback(o,r)}return this}static offPropChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:n}=this;for(let[s,r]of t)this._removeFromCallbackMap(n,s,r);return this}static offAttributeChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:n}=this;for(let[s,r]of t)this._removeFromCallbackMap(n,s,r);return this}static onPropChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{propChangedCallbacks:n}=this;for(let[s,r]of t)n.has(s)?n.get(s).push(r):n.set(s,[r]);return this}static onAttributeChanged(e){let t=Array.isArray(e)?e:Object.entries(e),{attributeChangedCallbacks:n}=this;for(let[s,r]of t)n.has(s)?n.get(s).push(r):n.set(s,[r]);return this}#s;#n=new Map;#t=new Map;#e;#r=!1;#i=[];#o;#a=null;constructor(...e){super(),i.supportsElementInternals&&(this.elementInternals=this.attachInternals()),this.attachShadow({mode:"open",delegatesFocus:this.delegatesFocus}),this.render=this.composition.render(this.constructor.prototype,this,{defaults:this.constructor.prototype,store:this,shadowRoot:this.shadowRoot,context:this});for(let t of this.static._onConstructedCallbacks)t.call(this,this.callbackArguments)}propChangedCallback(e,t,n,s=n){this.#r?this.#i.push([e,s,this]):this.render.byProp(e,s,this);let{_propChangedCallbacks:r}=this.static;if(r.has(e))for(let o of r.get(e))o.call(this,t,n,s,this)}attributeChangedCallback(e,t,n){let{attributeChangedCallbacks:s}=this.static;if(s.has(e))for(let u of s.get(e))u.call(this,t,n,this);let{attrList:r}=this.static;if(!r.has(e))return;let o=r.get(e);if(o.attributeChangedCallback){o.attributeChangedCallback.call(this,e,t,n);return}let a;if(this.attributeCache.has(e)&&(a=this.attributeCache.get(e),a.stringValue===n))return;let l=this[o.key],c=n===null?o.nullParser(n):o.type==="boolean"?!0:o.parser(n);c!==l&&(a?(a.stringValue=n,a.parsedValue=c):this.attributeCache.set(e,{stringValue:n,parsedValue:c}),this[o.key]=c)}get#c(){var e;return(e=this.#e)==null?void 0:e.template}#l(e,t,n,s){let{propList:r}=this.static;if(r.has(e)){let{reflect:o,attr:a}=r.get(e);if(a&&(o===!0||o==="write")){let l,c=!1,{attributeCache:u}=this;if(u.has(a)?(l=u.get(a),c=l.parsedValue!==n):(l={},u.set(a,l),c=!0),c){let p=ke(n);l.parsedValue=n,l.stringValue=p,p==null?this.removeAttribute(a):this.setAttribute(a,p)}}}this.propChangedCallback(e,t,n,s)}get static(){return this.constructor}patch(e){this.#r=!0,Ie(this,e,"object");for(let[t,n,s]of this.#i)t in e||this.render.byProp(t,n,s);this.#i.slice(0,this.#i.length),this.render(e),this.#r=!1}get refs(){return this.#s??=new Proxy({},{get:(e,t)=>{let n=this.composition,s;if(!n.interpolated){if(this.#t.has(t)&&(s=this.#t.get(t).deref(),s))return s;let a=R(t);return s=n.template.getElementById(a),s?(this.#t.set(t,new WeakRef(s)),s):null}if(this.#n.has(t)&&(s=this.#n.get(t).deref(),s))return s;let r=R(t),o=this.composition.tags.indexOf(r);return s=this.render.state.refs[o],s?(this.#n.set(t,new WeakRef(s)),s):null}})}get attributeCache(){return this.#o??=new Map}get callbackArguments(){return this.#a??={composition:this.#e,refs:this.refs,html:de.bind(this),inline:ue,template:this.#c,element:this}}get composition(){if(this.#e)return this.#e;if(this.static.hasOwnProperty("_composition"))return this.#e=this.static._composition,this.static._composition;this.compose();for(let e of this.static._onComposeCallbacks)e.call(this,this.callbackArguments);return this.static._composition=this.#e,this.#e}connectedCallback(){for(let e of this.static._onConnectedCallbacks)e.call(this,this.callbackArguments)}disconnectedCallback(){for(let e of this.static._onDisconnectedCallbacks)e.call(this,this.callbackArguments)}};Z.prototype.delegatesFocus=!1;export{Tt as cloneAttributeCallback,Z as default};
2
2
  //# sourceMappingURL=CustomElement.min.js.map