@vielzeug/ore 26.11.7 → 26.11.9

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/dist/ore.js CHANGED
@@ -73,18 +73,27 @@ var resolveMaybeReactive = (e) => typeof e == "function" ? e() : i(e) ? e.value
73
73
  "poster",
74
74
  "src",
75
75
  "xlink:href"
76
- ]), u = /^\s*(?:(?:javascript|vbscript|blob):|data:(?:[^,]*\/(?:html|svg\+xml)|application\/(?:xhtml|xml)))/i, d = /[\t\n\r]/g, f = /^[\s\p{C}]+|[\s\p{C}]+$/gu, normalizeUrlForSchemeCheck = (e) => e.replace(d, "").replace(f, ""), isDangerousUrl = (e) => u.test(normalizeUrlForSchemeCheck(e)), setAttr = (e, t, n) => {
77
- let r = t.toLowerCase();
78
- if (/^on[a-z]/i.test(t)) {
76
+ ]), u = /^\s*(?:(?:javascript|vbscript|blob):|data:(?:[^,]*\/(?:html|svg\+xml)|application\/(?:xhtml|xml)))/i, d = /[\t\n\r]/g, f = /^[\s\p{C}]+|[\s\p{C}]+$/gu, normalizeUrlForSchemeCheck = (e) => e.replace(d, "").replace(f, ""), isDangerousUrl = (e) => u.test(normalizeUrlForSchemeCheck(e)), p = /* @__PURE__ */ new Map(), m = 512, getAttrWritePlan = (e) => {
77
+ let t = p.get(e);
78
+ if (t) return t;
79
+ let n = e.toLowerCase(), r = {
80
+ event: /^on[a-z]/i.test(e),
81
+ srcdoc: n === "srcdoc",
82
+ url: l.has(n)
83
+ };
84
+ return p.size >= m && p.clear(), p.set(e, r), r;
85
+ }, setAttr = (e, t, n) => {
86
+ let r = getAttrWritePlan(t);
87
+ if (r.event) {
79
88
  `${t}${t.slice(2)}`, e.removeAttribute(t);
80
89
  return;
81
90
  }
82
- if (r === "srcdoc" || n == null || n === !1) {
91
+ if (r.srcdoc || n == null || n === !1) {
83
92
  e.removeAttribute(t);
84
93
  return;
85
94
  }
86
95
  let i = n === !0 ? "true" : String(n);
87
- l.has(r) && isDangerousUrl(i) ? (`${t}`, e.removeAttribute(t)) : e.setAttribute(t, i);
96
+ r.url && isDangerousUrl(i) ? (`${t}`, e.removeAttribute(t)) : e.setAttribute(t, i);
88
97
  }, listen = (e, t, n, r) => {
89
98
  if (!e) return s.listenNullTarget(t), () => {};
90
99
  let i = n;
@@ -100,28 +109,28 @@ var resolveMaybeReactive = (e) => typeof e == "function" ? e() : i(e) ? e.value
100
109
  e && t.add(e);
101
110
  }
102
111
  return t;
103
- }, isStructuredValue = (e) => Array.isArray(e) || typeof e == "object" && !!e, p = null, createRuntimeContext = (e) => ({
112
+ }, isStructuredValue = (e) => Array.isArray(e) || typeof e == "object" && !!e, h = null, createRuntimeContext = (e) => ({
104
113
  element: e,
105
114
  formResetCallbacks: [],
106
115
  mountCallbacks: []
107
- }), m = 0, beginPendingWork = () => {
108
- m++;
116
+ }), g = 0, beginPendingWork = () => {
117
+ g++;
109
118
  let e = !1;
110
119
  return () => {
111
- e || (e = !0, m--);
120
+ e || (e = !0, g--);
112
121
  };
113
122
  }, runWithContext = (e, t) => {
114
- let n = p;
115
- p = e;
123
+ let n = h;
124
+ h = e;
116
125
  try {
117
126
  return t();
118
127
  } finally {
119
- p = n;
128
+ h = n;
120
129
  }
121
130
  }, requireSetupContext = (e) => {
122
- if (p) return p;
131
+ if (h) return h;
123
132
  throw new OreApiError(`${e}: ${s.lifecycleOutsideSetup}`);
124
- }, getHost = () => requireSetupContext("getHost").element, tryRegisterCleanup = (e) => p ? (r(() => e), !0) : !1, onCleanup = (e) => {
133
+ }, getHost = () => requireSetupContext("getHost").element, tryRegisterCleanup = (e) => h ? (r(() => e), !0) : !1, onCleanup = (e) => {
125
134
  if (!tryRegisterCleanup(e)) throw new OreApiError(`onCleanup: ${s.lifecycleOutsideSetup}`);
126
135
  }, onMounted = (e) => {
127
136
  requireSetupContext("onMounted").mountCallbacks.push(e);
@@ -139,39 +148,39 @@ function onEvent(e, t, n, r) {
139
148
  var onElement = (e, t) => watchEffect(() => {
140
149
  let n = e.value;
141
150
  if (n) return t(n);
142
- }), h = /* @__PURE__ */ new WeakMap(), buildAncestorChain = (e) => {
151
+ }), _ = /* @__PURE__ */ new WeakMap(), buildAncestorChain = (e) => {
143
152
  let t = [], n = e;
144
153
  for (; n;) n instanceof HTMLElement && t.push(n), n = n.parentNode ?? (n instanceof ShadowRoot ? n.host : null);
145
154
  return t;
146
155
  }, provideOnElement = (e, t, n) => {
147
- let r = h.get(e) ?? /* @__PURE__ */ new Map();
148
- r.has(t) && `${e.localName}`, r.set(t, n), h.set(e, r);
156
+ let r = _.get(e) ?? /* @__PURE__ */ new Map();
157
+ r.has(t) && `${e.localName}`, r.set(t, n), _.set(e, r);
149
158
  }, provide = (e, t) => {
150
159
  let n = requireSetupContext("provide").element;
151
160
  provideOnElement(n, e, t), onCleanup(() => {
152
- let t = h.get(n);
153
- t && (t.delete(e), t.size === 0 && h.delete(n));
161
+ let t = _.get(n);
162
+ t && (t.delete(e), t.size === 0 && _.delete(n));
154
163
  });
155
- }, g = Symbol("inject.not_found"), _ = /* @__PURE__ */ new WeakMap(), walkAndFind = (e, t) => {
164
+ }, v = Symbol("inject.not_found"), y = /* @__PURE__ */ new WeakMap(), walkAndFind = (e, t) => {
156
165
  let n = buildAncestorChain(e);
157
166
  for (let e of n) {
158
- let n = h.get(e);
167
+ let n = _.get(e);
159
168
  if (n?.has(t)) return n.get(t);
160
169
  }
161
- return g;
170
+ return v;
162
171
  }, lookup = (e, t) => {
163
- let n = _.get(e);
164
- n || (n = /* @__PURE__ */ new Map(), _.set(e, n));
172
+ let n = y.get(e);
173
+ n || (n = /* @__PURE__ */ new Map(), y.set(e, n));
165
174
  let r = t;
166
175
  return n.has(r) || n.set(r, walkAndFind(e.element, t)), n.get(r);
167
176
  };
168
177
  function inject(e, ...t) {
169
178
  let n = lookup(requireSetupContext("inject"), e);
170
- return n === g ? t.length > 0 ? t[0] : void 0 : n;
179
+ return n === v ? t.length > 0 ? t[0] : void 0 : n;
171
180
  }
172
181
  var injectStrict = (e) => {
173
182
  let t = requireSetupContext("injectStrict"), n = lookup(t, e);
174
- if (n !== g) return n;
183
+ if (n !== v) return n;
175
184
  throw new OreApiError(s.injectStrictFailed(String(e), t.element.localName));
176
185
  };
177
186
  function createContext(e) {
@@ -204,7 +213,7 @@ function _stringProp(e) {
204
213
  reflect: !0
205
214
  };
206
215
  }
207
- var v = {
216
+ var b = {
208
217
  bool(e) {
209
218
  return {
210
219
  default: e ?? !1,
@@ -269,9 +278,9 @@ function validatePropDefs(e) {
269
278
  }
270
279
  return t;
271
280
  }
272
- var y = /* @__PURE__ */ new WeakMap(), getPropMeta = (e, t) => y.get(e)?.get(t), coerceIncoming = (e, t) => typeof e == "string" ? t(e) : e, registerProp = (e, t, n, r) => {
273
- let i = y.get(e);
274
- i || (i = /* @__PURE__ */ new Map(), y.set(e, i));
281
+ var x = /* @__PURE__ */ new WeakMap(), getPropMeta = (e, t) => x.get(e)?.get(t), coerceIncoming = (e, t) => typeof e == "string" ? t(e) : e, registerProp = (e, t, n, r) => {
282
+ let i = x.get(e);
283
+ i || (i = /* @__PURE__ */ new Map(), x.set(e, i));
275
284
  let { default: o, parse: s, reflect: c = !1 } = r, l = a(o), u = i.get(n), d = Object.hasOwn(e, t), f = d ? e[t] : void 0, p = {
276
285
  parse: s,
277
286
  reflect: c,
@@ -301,34 +310,34 @@ var makeBrand = (e) => {
301
310
  is,
302
311
  stamp
303
312
  };
304
- }, b = makeBrand("ore:css-result"), x = b.is, cssResultToString = function() {
313
+ }, S = makeBrand("ore:css-result"), C = S.is, cssResultToString = function() {
305
314
  return this.content;
306
315
  }, css = (e, ...t) => {
307
316
  let n = "";
308
317
  for (let r = 0; r < e.length; r++) if (n += e[r], r < t.length) {
309
318
  let e = t[r];
310
- n += x(e) ? e.content : String(e);
319
+ n += C(e) ? e.content : String(e);
311
320
  }
312
- return b.stamp({
321
+ return S.stamp({
313
322
  content: n.trim(),
314
323
  toString: cssResultToString
315
324
  });
316
- }, S = /* @__PURE__ */ new Map(), C = 256, loadStylesheet = (e) => {
325
+ }, w = /* @__PURE__ */ new Map(), T = 256, loadStylesheet = (e) => {
317
326
  if (e instanceof CSSStyleSheet) return e;
318
- let t = typeof e == "string" ? e : e.content, n = S.get(t);
319
- if (n) return S.delete(t), S.set(t, n), n;
327
+ let t = typeof e == "string" ? e : e.content, n = w.get(t);
328
+ if (n) return w.delete(t), w.set(t, n), n;
320
329
  let r = new CSSStyleSheet();
321
330
  try {
322
331
  r.replaceSync(t);
323
332
  } catch {
324
333
  return r;
325
334
  }
326
- if (S.set(t, r), S.size > C) {
327
- let e = S.keys().next().value;
328
- e !== void 0 && S.delete(e);
335
+ if (w.set(t, r), w.size > T) {
336
+ let e = w.keys().next().value;
337
+ e !== void 0 && w.delete(e);
329
338
  }
330
339
  return r;
331
- }, w = {
340
+ }, E = {
332
341
  SETUP_DONE: "setup_done",
333
342
  SETUP_RUNNING: "setup_running",
334
343
  UNINITIALIZED: "uninitialized",
@@ -337,7 +346,7 @@ var makeBrand = (e) => {
337
346
  formResetCallbacks: [],
338
347
  generation: 0,
339
348
  mountCallbacks: [],
340
- phase: w.UNINITIALIZED,
349
+ phase: E.UNINITIALIZED,
341
350
  scope: n(),
342
351
  templateResult: null
343
352
  }), isPromiseLike = (e) => (typeof e == "object" || typeof e == "function") && e !== null && "then" in e && typeof e.then == "function", BaseElement = class extends HTMLElement {
@@ -346,6 +355,8 @@ var makeBrand = (e) => {
346
355
  static formAssociated = !1;
347
356
  static observedAttributes = [];
348
357
  _component;
358
+ _pendingTeardown = null;
359
+ _stylesApplied = !1;
349
360
  constructor() {
350
361
  super();
351
362
  let e = this.constructor._definition;
@@ -356,7 +367,7 @@ var makeBrand = (e) => {
356
367
  }
357
368
  connectedCallback() {
358
369
  o(() => {
359
- this._component.phase === w.UNINITIALIZED && this._runSetup(), this._init();
370
+ this._pendingTeardown === null ? (this._component.phase === E.UNINITIALIZED && this._runSetup(), this._init()) : (this._pendingTeardown = null, this._component.phase = E.SETUP_DONE, this._scheduleMountCallbacks());
360
371
  });
361
372
  }
362
373
  attributeChangedCallback(e, t, n) {
@@ -367,10 +378,14 @@ var makeBrand = (e) => {
367
378
  Object.is(o(() => r.signal.value), i) || (r.signal.value = i);
368
379
  }
369
380
  disconnectedCallback() {
370
- this._component.generation++, this._component.phase = w.UNMOUNTED, this._resetSetupState();
381
+ this._component.phase = E.UNMOUNTED;
382
+ let e = {};
383
+ this._pendingTeardown = e, queueMicrotask(() => {
384
+ this._pendingTeardown === e && (this._pendingTeardown = null, this._component.generation++, this._resetSetupState());
385
+ });
371
386
  }
372
387
  _resetSetupState() {
373
- this._component.scope.dispose(), this._component.formResetCallbacks = [], this._component.mountCallbacks = [], this._component.phase = w.UNINITIALIZED, this._component.scope = n(), this._component.templateResult = null;
388
+ this._component.scope.dispose(), this._component.formResetCallbacks = [], this._component.mountCallbacks = [], this._component.phase = E.UNINITIALIZED, this._component.scope = n(), this._component.templateResult = null;
374
389
  }
375
390
  formResetCallback() {
376
391
  for (let e of this._component.formResetCallbacks) try {
@@ -388,7 +403,7 @@ var makeBrand = (e) => {
388
403
  }), this);
389
404
  }
390
405
  _runSetup() {
391
- this._component.phase = w.SETUP_RUNNING;
406
+ this._component.phase = E.SETUP_RUNNING;
392
407
  let e = this.constructor._definition, t = this.constructor._normalizedPropDefs, n = createRuntimeContext(this);
393
408
  try {
394
409
  let r;
@@ -398,7 +413,7 @@ var makeBrand = (e) => {
398
413
  return e.setup(n);
399
414
  });
400
415
  }), this._component.mountCallbacks.push(...n.mountCallbacks), this._component.formResetCallbacks.push(...n.formResetCallbacks), isPromiseLike(r)) throw new OreApiError(s.asyncSetupUnsupported);
401
- this._component.templateResult = r ?? null, this._component.phase = w.SETUP_DONE;
416
+ this._component.templateResult = r ?? null, this._component.phase = E.SETUP_DONE;
402
417
  } catch (e) {
403
418
  throw this._reportLifecycleError(e, "setup"), this._resetSetupState(), e;
404
419
  }
@@ -416,11 +431,12 @@ var makeBrand = (e) => {
416
431
  });
417
432
  }
418
433
  _init() {
419
- this._applyStyles(), this._mountTemplate(), this._component.phase === w.SETUP_DONE && this._scheduleMountCallbacks();
434
+ this._applyStyles(), this._mountTemplate(), this._component.phase === E.SETUP_DONE && this._scheduleMountCallbacks();
420
435
  }
421
436
  _applyStyles() {
437
+ if (this._stylesApplied) return;
422
438
  let e = this.constructor._definition;
423
- this.shadowRoot && e?.styles?.length && (this.shadowRoot.adoptedStyleSheets = e.styles.map(loadStylesheet));
439
+ this.shadowRoot && e?.styles?.length && (this.shadowRoot.adoptedStyleSheets = e.styles.map(loadStylesheet), this._stylesApplied = !0);
424
440
  }
425
441
  _mountTemplate() {
426
442
  let e = this._component.templateResult;
@@ -478,55 +494,81 @@ var classMap = (e) => t(() => [...resolveClassTokens(e)].join(" "));
478
494
  function ref() {
479
495
  return a(null);
480
496
  }
481
- var T = makeBrand("ore:directive"), createDirectiveResult = (e) => T.stamp({ mount: e }), E = T.is, D = makeBrand("ore:html-result"), O = D.is;
497
+ var D = makeBrand("ore:directive"), createDirectiveResult = (e) => D.stamp({ mount: e }), O = D.is, k = makeBrand("ore:html-result"), A = k.is;
482
498
  function createHtmlResult(e, t) {
483
499
  let mount = (n, r, i) => {
484
500
  let a = Array.from(e.childNodes);
485
501
  return n.insertBefore(e, r), t(i), a;
486
502
  };
487
- return D.stamp({
503
+ return k.stamp({
488
504
  apply: t,
489
505
  fragment: e,
490
506
  mount
491
507
  });
492
508
  }
493
509
  // src/directives/each.ts
494
- var createItem = (e, t, r, i, o) => {
495
- let s = a(e), c = a(t), l = n(), u = [], d = [];
496
- return l.run(() => {
497
- d = r(s, c).mount(i, o, (e) => u.push(e));
498
- }), {
499
- cleanups: u,
500
- data: s,
501
- index: c,
502
- nodes: d,
503
- scope: l
510
+ var createItem = (e, t, r, i) => {
511
+ let o = a(e), s = a(t), c = n(), l = [], u = [], d = document.createComment("each/item-start");
512
+ i.appendChild(d), c.run(() => {
513
+ u = r(o, s).mount(i, null, (e) => l.push(e));
514
+ });
515
+ let f = document.createComment("each/item");
516
+ return i.appendChild(f), u = [
517
+ d,
518
+ ...u,
519
+ f
520
+ ], {
521
+ cleanups: l,
522
+ data: o,
523
+ index: s,
524
+ nodes: u,
525
+ scope: c
504
526
  };
505
527
  }, removeItem = (e) => {
506
528
  e.scope.dispose(), runAll(e.cleanups), removeNodes(e.nodes);
507
- }, reconcileItems = (t, n, r, i, a, s, c) => {
529
+ }, reusedEntriesInOrder = (e, t) => {
530
+ let n = /* @__PURE__ */ new Map();
531
+ for (let e = 0; e < t.length; e++) n.set(t[e], e);
532
+ let r = -1;
533
+ for (let t of e) {
534
+ let e = n.get(t);
535
+ if (e !== void 0) {
536
+ if (e < r) return !1;
537
+ r = e;
538
+ }
539
+ }
540
+ return !0;
541
+ }, reconcileItems = (t, n, r, i, a, s, c, l) => {
542
+ let u = document.createDocumentFragment();
508
543
  for (let e = 0; e < n.length; e++) {
509
- let l = r[e];
510
- if (t.has(l)) continue;
511
- let u = o(() => createItem(n[e], e, i, a, s));
512
- c.push(u), t.set(l, u);
544
+ let a = r[e];
545
+ if (t.has(a)) continue;
546
+ let s = o(() => createItem(n[e], e, i, u));
547
+ c.push(s), t.set(a, s);
513
548
  }
514
- let l = [];
549
+ let d = [];
515
550
  e(() => {
516
551
  for (let e = 0; e < n.length; e++) {
517
552
  let i = t.get(r[e]);
518
- invariant(i, "each() reconcile phase 2 lost an entry created in phase 1"), i.data.value = n[e], i.index.value = e, l.push(i);
553
+ invariant(i, "each() reconcile phase 2 lost an entry created in phase 1"), i.data.value = n[e], i.index.value = e, d.push(i);
519
554
  }
520
555
  });
521
- let u = s;
522
- for (let e = l.length - 1; e >= 0; e--) {
523
- let t = l[e], n = t.nodes[0], r = t.nodes[t.nodes.length - 1];
524
- if (n && r !== u.previousSibling) for (let e of t.nodes) a.insertBefore(e, u);
525
- u = n ?? u;
556
+ let f = reusedEntriesInOrder(d, l), p = new Set(c), m = s;
557
+ for (let e = d.length - 1; e >= 0; e--) {
558
+ let t = d[e], n = t.nodes[0], r = t.nodes[t.nodes.length - 1];
559
+ if ((!f || p.has(t)) && r !== m.previousSibling) {
560
+ let e = n;
561
+ for (; e;) {
562
+ let t = e === r ? null : e.nextSibling;
563
+ if (a.insertBefore(e, m), e === r) break;
564
+ e = t;
565
+ }
566
+ }
567
+ m = n;
526
568
  }
527
- let d = new Set(r);
528
- for (let [e, n] of t) d.has(e) || (removeItem(n), t.delete(e));
529
- return l;
569
+ let h = new Set(r);
570
+ for (let [e, n] of t) h.has(e) || (removeItem(n), t.delete(e));
571
+ return d;
530
572
  }, rollbackCreated = (e, t) => {
531
573
  for (let n of t) {
532
574
  removeItem(n);
@@ -558,8 +600,10 @@ function each(e, n, i, s) {
558
600
  invariant(a, "each() anchor comment has no parent node");
559
601
  let l = document.createComment("each/end");
560
602
  a.insertBefore(l, e.nextSibling);
561
- let u = /* @__PURE__ */ new Map(), d = [], f = null, p = [], mountFallback = () => {
562
- s && (f = s().mount(a, l, (e) => p.push(e)));
603
+ let container = () => l.parentNode, u = /* @__PURE__ */ new Map(), d = [], f = null, p = [], mountFallback = () => {
604
+ if (!s) return;
605
+ let e = container();
606
+ e && (f = s().mount(e, l, (e) => p.push(e)));
563
607
  }, clearFallback = () => {
564
608
  f && (runAll(p), removeNodes(f), f = null, p = []);
565
609
  }, m = r(() => {
@@ -577,9 +621,11 @@ function each(e, n, i, s) {
577
621
  return;
578
622
  }
579
623
  clearFallback();
624
+ let a = container();
625
+ if (!a) return;
580
626
  let s = [];
581
627
  try {
582
- d = o(() => reconcileItems(u, t, r, i, a, l, s));
628
+ d = o(() => reconcileItems(u, t, r, i, a, l, s, d));
583
629
  } catch (t) {
584
630
  reportEachError(t, e), o(() => rollbackCreated(u, s));
585
631
  }
@@ -592,7 +638,7 @@ function each(e, n, i, s) {
592
638
  });
593
639
  }
594
640
  // src/directives/live.ts
595
- var k = makeBrand("ore:live"), live = (e) => k.stamp({ source: e }), A = k.is, j = makeBrand("ore:model"), M = j.is, modelDefaultGet = (e) => e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? e.checked : e.value, modelDefaultEvent = (e) => e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") || e instanceof HTMLSelectElement ? "change" : "input", model = (e, t) => j.stamp({
641
+ var j = makeBrand("ore:live"), live = (e) => j.stamp({ source: e }), M = j.is, N = makeBrand("ore:model"), P = N.is, modelDefaultGet = (e) => e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") ? e.checked : e.value, modelDefaultEvent = (e) => e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio") || e instanceof HTMLSelectElement ? "change" : "input", model = (e, t) => N.stamp({
596
642
  event: t?.event,
597
643
  get: t?.get,
598
644
  source: e
@@ -620,7 +666,9 @@ function unsafeHtml(e) {
620
666
  let o = document.createComment("unsafe-html/end");
621
667
  if (a.insertBefore(o, t.nextSibling), n) {
622
668
  let e = createReplaceableSlot(), t = r(() => {
623
- e.clear(), e.setNodes(parseHtml(n.value, a, o));
669
+ e.clear();
670
+ let t = o.parentNode;
671
+ t && e.setNodes(parseHtml(n.value, t, o));
624
672
  });
625
673
  i(() => t.dispose()), i(() => {
626
674
  e.clear(), o.remove();
@@ -629,25 +677,27 @@ function unsafeHtml(e) {
629
677
  });
630
678
  }
631
679
  // src/directives/when.ts
632
- var N = "when() anchor comment has no parent node";
680
+ var F = "when() anchor comment has no parent node";
633
681
  function when(e, n, a) {
634
682
  return typeof e != "function" && !i(e) ? createDirectiveResult((t, r) => {
635
683
  let i = e ? n() : a ? a() : null;
636
- if (!i || !O(i)) return;
684
+ if (!i || !A(i)) return;
637
685
  let o = t.parentNode;
638
- invariant(o, N);
686
+ invariant(o, F);
639
687
  let s = i.mount(o, t, r);
640
688
  r(() => removeNodes(s));
641
689
  }) : createDirectiveResult((i, s) => {
642
690
  let c = (typeof e == "function" ? t(e) : null) ?? e, l = i.parentNode;
643
- invariant(l, N);
691
+ invariant(l, F);
644
692
  let u = document.createComment("when/end");
645
693
  l.insertBefore(u, i.nextSibling);
646
694
  let d = createReplaceableSlot(), f = r(() => {
647
695
  let e = c.value;
648
696
  d.clear();
649
697
  let t = e ? n() : a ? a() : null;
650
- t && O(t) && d.setNodes(o(() => t.mount(l, u, d.registerCleanup)));
698
+ if (!t || !A(t)) return;
699
+ let r = u.parentNode;
700
+ r && d.setNodes(o(() => t.mount(r, u, d.registerCleanup)));
651
701
  });
652
702
  s(() => f.dispose()), s(() => {
653
703
  d.clear(), u.remove();
@@ -655,12 +705,12 @@ function when(e, n, a) {
655
705
  });
656
706
  }
657
707
  // src/forms/field.ts
658
- var P = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakSet(), useField = (e) => {
708
+ var I = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakSet(), useField = (e) => {
659
709
  let t = getHost();
660
710
  if (!t.constructor.formAssociated) throw new OreApiError(s.defineFieldRequiresFormAssociated(t.localName));
661
- if (F.has(t)) throw new OreApiError(s.useFieldAlreadyCalled(t.localName));
662
- let n = P.get(t) ?? t.attachInternals();
663
- P.set(t, n), F.add(t), onCleanup(() => F.delete(t));
711
+ if (L.has(t)) throw new OreApiError(s.useFieldAlreadyCalled(t.localName));
712
+ let n = I.get(t) ?? t.attachInternals();
713
+ I.set(t, n), L.add(t), onCleanup(() => L.delete(t));
664
714
  let r = e.toFormValue ?? ((t) => t == null ? e.emptyStringForNull ? "" : null : t instanceof File || t instanceof FormData ? t : String(t));
665
715
  watchEffect(() => {
666
716
  n.setFormValue(r(e.value.value));
@@ -691,7 +741,7 @@ var P = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakSet(), useFie
691
741
  }, normalizeHostAttrKey = (e) => e === "role" || e.startsWith("aria-") ? e : e.startsWith("aria") ? `aria-${e.slice(4).toLowerCase()}` : e, bind = (e, t) => {
692
742
  let n = t?.target ?? getHost(), r = [];
693
743
  if (e.attr) for (let [t, i] of Object.entries(e.attr)) {
694
- let e = applyAttribute(n, I(t), i);
744
+ let e = applyAttribute(n, R(t), i);
695
745
  e && r.push(e);
696
746
  }
697
747
  if (e.class && r.push(applyClassMap(n, e.class)), e.style) for (let [t, i] of Object.entries(e.style)) {
@@ -709,7 +759,7 @@ var P = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakSet(), useFie
709
759
  for (let e of r) e();
710
760
  };
711
761
  return tryRegisterCleanup(cleanup), cleanup;
712
- }, I = normalizeHostAttrKey, applyReactiveBinding = (e, t) => {
762
+ }, R = normalizeHostAttrKey, applyReactiveBinding = (e, t) => {
713
763
  if (typeof e == "function") return watchEffect(() => {
714
764
  t(e());
715
765
  });
@@ -740,7 +790,7 @@ function applyClassMap(e, t) {
740
790
  });
741
791
  }
742
792
  // src/slots.ts
743
- var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
793
+ var z = "default", normalizeSlotName = (e) => e || z, createSlots = (e) => {
744
794
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), ensureSlotEntry = (e) => {
745
795
  let n = t.get(e);
746
796
  return n || (n = {
@@ -778,10 +828,23 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
778
828
  });
779
829
  }, recomputeAllSlots = () => {
780
830
  for (let e of n.keys()) recomputeSlot(e);
831
+ }, isOrContainsSlot = (e) => e instanceof HTMLSlotElement || e.nodeType === Node.ELEMENT_NODE && e.querySelector("slot") !== null, unbindSlotsIn = (e) => {
832
+ e instanceof HTMLSlotElement ? unbindSlot(e) : e.nodeType === Node.ELEMENT_NODE && e.querySelectorAll("slot").forEach((e) => {
833
+ unbindSlot(e);
834
+ });
781
835
  }, i = null, initSlots = () => {
782
836
  bindAllSlots(), recomputeAllSlots(), !i && e.shadowRoot && (i = new MutationObserver((e) => {
783
- for (let t of e) for (let e of t.removedNodes) e instanceof HTMLSlotElement && unbindSlot(e);
784
- bindAllSlots(), r.size > 0 && recomputeAllSlots();
837
+ let t = !1;
838
+ for (let n of e) {
839
+ for (let e of n.removedNodes) isOrContainsSlot(e) && (t = !0, unbindSlotsIn(e));
840
+ if (!t) {
841
+ for (let e of n.addedNodes) if (isOrContainsSlot(e)) {
842
+ t = !0;
843
+ break;
844
+ }
845
+ }
846
+ }
847
+ t && (bindAllSlots(), r.size > 0 && recomputeAllSlots());
785
848
  }), i.observe(e.shadowRoot, {
786
849
  childList: !0,
787
850
  subtree: !0
@@ -790,14 +853,14 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
790
853
  return onMounted(initSlots), onCleanup(() => {
791
854
  i?.disconnect(), i = null;
792
855
  for (let e of r.values()) e();
793
- r.clear(), n.clear(), t.clear(), R.delete(e);
856
+ r.clear(), n.clear(), t.clear(), B.delete(e);
794
857
  }), {
795
858
  elements: (e) => ensureSlotEntry(normalizeSlotName(e)).elements,
796
859
  has: (e) => ensureSlotEntry(normalizeSlotName(e)).presence
797
860
  };
798
- }, R = /* @__PURE__ */ new WeakMap(), useSlots = () => {
799
- let e = requireSetupContext("useSlots"), t = R.get(e.element);
800
- return t || (t = createSlots(e.element), R.set(e.element, t)), t;
861
+ }, B = /* @__PURE__ */ new WeakMap(), useSlots = () => {
862
+ let e = requireSetupContext("useSlots"), t = B.get(e.element);
863
+ return t || (t = createSlots(e.element), B.set(e.element, t)), t;
801
864
  }, signalEffect = (e, t, n) => {
802
865
  let i = r(() => {
803
866
  t(e.value);
@@ -849,7 +912,7 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
849
912
  }, insertHtmlValues = (e, t, n) => {
850
913
  let r = [], i = t.parentNode;
851
914
  invariant(i, "html binding anchor has no parent node");
852
- for (let a of e) if (O(a)) {
915
+ for (let a of e) if (A(a)) {
853
916
  let e = Array.from(a.fragment.childNodes);
854
917
  i.insertBefore(a.fragment, t), a.apply(n), r.push(...e);
855
918
  } else if (a != null && a !== !1) {
@@ -891,7 +954,7 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
891
954
  break;
892
955
  case "ref": applyRefBinding(e, t);
893
956
  }
894
- }, createAttrBindingFromValue = (e, n, r, a) => A(a) ? {
957
+ }, createAttrBindingFromValue = (e, n, r, a) => M(a) ? {
895
958
  el: e,
896
959
  live: !0,
897
960
  mode: n,
@@ -916,14 +979,14 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
916
979
  name: r,
917
980
  type: "attr",
918
981
  value: a
919
- }, resolveStaticText = (e) => e == null ? "" : String(e), z = {
982
+ }, resolveStaticText = (e) => e == null ? "" : String(e), V = {
920
983
  ATTR: "attr",
921
984
  BOOL_ATTR: "boolAttr",
922
985
  EVENT: "event",
923
986
  NODE: "node",
924
987
  PROP: "prop",
925
988
  REF: "ref"
926
- }, B = {
989
+ }, H = {
927
990
  capture: !0,
928
991
  once: !0,
929
992
  prevent: !0,
@@ -932,73 +995,73 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
932
995
  if (t.length === 0) return;
933
996
  let n = {};
934
997
  for (let r of t) {
935
- if (!(r in B)) throw new OreApiError(s.eventModifierUnknown(e, r));
998
+ if (!(r in H)) throw new OreApiError(s.eventModifierUnknown(e, r));
936
999
  n[r] = !0;
937
1000
  }
938
1001
  return n;
939
- }, V = /\s+@([a-zA-Z_][-a-zA-Z0-9_.-]*)\s*=\s*["']?$/, H = /\s+ref\s*=\s*["']?$/, U = /\s+\?([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/, W = /\s+\.([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/, G = /\s+([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/, K = /* @__PURE__ */ new Set([
1002
+ }, U = /\s+@([a-zA-Z_][-a-zA-Z0-9_.-]*)\s*=\s*["']?$/, W = /\s+ref\s*=\s*["']?$/, G = /\s+\?([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/, K = /\s+\.([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/, q = /\s+([a-zA-Z_][-a-zA-Z0-9_]*)\s*=\s*["']?$/, J = /* @__PURE__ */ new Set([
940
1003
  "innerhtml",
941
1004
  "outerhtml",
942
1005
  "srcdoc"
943
1006
  ]), detectSlot = (e) => {
944
1007
  let t;
945
- if (t = V.exec(e)) {
1008
+ if (t = U.exec(e)) {
946
1009
  let n = e.slice(0, -t[0].length), [r, ...i] = t[1].split(".");
947
1010
  return {
948
1011
  eventModifiers: parseEventModifiers(r, i),
949
- kind: z.EVENT,
1012
+ kind: V.EVENT,
950
1013
  name: r,
951
1014
  prefix: n
952
1015
  };
953
1016
  }
954
- if (t = H.exec(e)) return {
955
- kind: z.REF,
1017
+ if (t = W.exec(e)) return {
1018
+ kind: V.REF,
956
1019
  prefix: e.slice(0, -t[0].length)
957
1020
  };
958
- if (t = U.exec(e)) return {
959
- kind: z.BOOL_ATTR,
1021
+ if (t = G.exec(e)) return {
1022
+ kind: V.BOOL_ATTR,
960
1023
  name: t[1],
961
1024
  prefix: e.slice(0, -t[0].length)
962
1025
  };
963
- if (t = W.exec(e)) {
1026
+ if (t = K.exec(e)) {
964
1027
  let n = t[1];
965
1028
  if (n === "__proto__" || n === "constructor" || n === "prototype") throw new OreApiError(s.propBindingForbiddenName(n));
966
- if (K.has(n.toLowerCase())) throw new OreApiError(s.propBindingHtmlInjectionName(n));
1029
+ if (J.has(n.toLowerCase())) throw new OreApiError(s.propBindingHtmlInjectionName(n));
967
1030
  return {
968
- kind: z.PROP,
1031
+ kind: V.PROP,
969
1032
  name: n,
970
1033
  prefix: e.slice(0, -t[0].length)
971
1034
  };
972
1035
  }
973
- if (t = G.exec(e)) return {
974
- kind: z.ATTR,
1036
+ if (t = q.exec(e)) return {
1037
+ kind: V.ATTR,
975
1038
  name: t[1],
976
1039
  prefix: e.slice(0, -t[0].length)
977
1040
  };
978
1041
  let n = e.lastIndexOf("<");
979
1042
  if (n > e.lastIndexOf(">") && e[n + 1] !== "/") throw new OreApiError(s.templateInterpolationInTag);
980
1043
  return {
981
- kind: z.NODE,
1044
+ kind: V.NODE,
982
1045
  prefix: e
983
1046
  };
984
- }, q = /* @__PURE__ */ new WeakMap(), J = /[@?]?[a-zA-Z_][-a-zA-Z0-9_.]*\s*=\s*$/, normalizeTemplateStrings = (e) => {
1047
+ }, Y = /* @__PURE__ */ new WeakMap(), X = /[@?]?[a-zA-Z_][-a-zA-Z0-9_.]*\s*=\s*$/, normalizeTemplateStrings = (e) => {
985
1048
  let t = Array.from(e), n = !1;
986
1049
  for (let e = 0; e < t.length - 1; e++) {
987
1050
  let r = t[e], i = r[r.length - 1];
988
1051
  for (let e of r) e === "<" ? n = !0 : e === ">" && (n = !1);
989
- if ((i === "\"" || i === "'") && n && J.test(r.slice(0, -1))) {
1052
+ if ((i === "\"" || i === "'") && n && X.test(r.slice(0, -1))) {
990
1053
  t[e] = r.slice(0, -1);
991
1054
  let n = t[e + 1];
992
1055
  n.startsWith(i) && (t[e + 1] = n.slice(1));
993
1056
  }
994
1057
  }
995
1058
  return t;
996
- }, Y = "data-ore-b", X = /^ore:(\d+)$/, walkNode = (e, t, n, r) => {
1059
+ }, Z = "data-ore-b", ee = /^ore:(\d+)$/, walkNode = (e, t, n, r) => {
997
1060
  if (e.nodeType === Node.ELEMENT_NODE) {
998
- let r = e, i = r.getAttribute(Y);
999
- i !== null && (n.set(Number(i), [...t]), r.removeAttribute(Y));
1061
+ let r = e, i = r.getAttribute(Z);
1062
+ i !== null && (n.set(Number(i), [...t]), r.removeAttribute(Z));
1000
1063
  } else if (e.nodeType === Node.COMMENT_NODE) {
1001
- let n = e.nodeValue, i = n === null ? null : X.exec(n);
1064
+ let n = e.nodeValue, i = n === null ? null : ee.exec(n);
1002
1065
  i && r.set(Number(i[1]), [...t]);
1003
1066
  }
1004
1067
  let i = e.childNodes;
@@ -1007,13 +1070,13 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
1007
1070
  let t = normalizeTemplateStrings(e), n = "", r, i = 0, a = 0, o = [];
1008
1071
  for (let e = 0; e < t.length - 1; e++) {
1009
1072
  let s = t[e], c = detectSlot(s);
1010
- if (c.kind === z.NODE) n += `${c.prefix}<!--ore:${a}-->`, o.push({
1073
+ if (c.kind === V.NODE) n += `${c.prefix}<!--ore:${a}-->`, o.push({
1011
1074
  commentId: a,
1012
- kind: z.NODE
1075
+ kind: V.NODE
1013
1076
  }), a++, r = void 0;
1014
1077
  else {
1015
- r === void 0 || c.prefix.lastIndexOf("<") > c.prefix.lastIndexOf(">") ? (r = i++, n += `${c.prefix} ${Y}="${r}"`) : n += c.prefix;
1016
- let e = c.kind === z.BOOL_ATTR ? "bool" : c.kind === z.ATTR ? "attr" : void 0;
1078
+ r === void 0 || c.prefix.lastIndexOf("<") > c.prefix.lastIndexOf(">") ? (r = i++, n += `${c.prefix} ${Z}="${r}"`) : n += c.prefix;
1079
+ let e = c.kind === V.BOOL_ATTR ? "bool" : c.kind === V.ATTR ? "attr" : void 0;
1017
1080
  o.push({
1018
1081
  elementId: r,
1019
1082
  eventModifiers: c.eventModifiers,
@@ -1035,20 +1098,20 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
1035
1098
  slots: o
1036
1099
  };
1037
1100
  }, getStaticTemplate = (e) => {
1038
- let t = q.get(e);
1039
- return t || (t = buildStaticTemplate(e), q.set(e, t)), t;
1101
+ let t = Y.get(e);
1102
+ return t || (t = buildStaticTemplate(e), Y.set(e, t)), t;
1040
1103
  }, followPath = (e, t) => {
1041
1104
  let n = e;
1042
1105
  for (let e of t) n = n.childNodes[e];
1043
1106
  return n;
1044
- }, Z = "html`...`: node-slot comment anchor has no parent node", embedStaticResult = (e, t, n) => {
1107
+ }, Q = "html`...`: node-slot comment anchor has no parent node", embedStaticResult = (e, t, n) => {
1045
1108
  let r = t.parentNode;
1046
- for (invariant(r, Z); e.fragment.firstChild;) r.insertBefore(e.fragment.firstChild, t);
1109
+ for (invariant(r, Q); e.fragment.firstChild;) r.insertBefore(e.fragment.firstChild, t);
1047
1110
  n.push(e.apply.bind(e));
1048
1111
  }, compileTemplate = (e, n) => {
1049
1112
  let r = getStaticTemplate(e), a = r.element.content.cloneNode(!0), o = [], c = [], l = r.slots.map((e, t) => {
1050
1113
  let i = n[t];
1051
- if (e.kind === z.NODE) {
1114
+ if (e.kind === V.NODE) {
1052
1115
  let t = e.commentId === void 0 ? void 0 : r.commentPaths.get(e.commentId);
1053
1116
  return invariant(t, `compiled template is missing a comment path for node slot ${e.commentId}`), {
1054
1117
  comment: followPath(a, t),
@@ -1063,9 +1126,9 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
1063
1126
  value: i
1064
1127
  };
1065
1128
  });
1066
- for (let { comment: e, el: n, slot: r, value: a } of l) if (r.kind === z.NODE) {
1129
+ for (let { comment: e, el: n, slot: r, value: a } of l) if (r.kind === V.NODE) {
1067
1130
  let t = e;
1068
- if (invariant(t, "compiled template produced a node slot without a comment anchor"), E(a)) {
1131
+ if (invariant(t, "compiled template produced a node slot without a comment anchor"), O(a)) {
1069
1132
  o.push({
1070
1133
  anchor: t,
1071
1134
  directive: a,
@@ -1073,7 +1136,7 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
1073
1136
  });
1074
1137
  continue;
1075
1138
  }
1076
- if (O(a)) {
1139
+ if (A(a)) {
1077
1140
  embedStaticResult(a, t, c), t.remove();
1078
1141
  continue;
1079
1142
  }
@@ -1086,16 +1149,16 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
1086
1149
  continue;
1087
1150
  }
1088
1151
  if (Array.isArray(a)) {
1089
- for (let e of a) if (O(e)) embedStaticResult(e, t, c);
1152
+ for (let e of a) if (A(e)) embedStaticResult(e, t, c);
1090
1153
  else {
1091
1154
  let n = t.parentNode;
1092
- invariant(n, Z), n.insertBefore(document.createTextNode(resolveStaticText(e)), t);
1155
+ invariant(n, Q), n.insertBefore(document.createTextNode(resolveStaticText(e)), t);
1093
1156
  }
1094
1157
  t.remove();
1095
1158
  continue;
1096
1159
  }
1097
1160
  t.replaceWith(document.createTextNode(resolveStaticText(a)));
1098
- } else if (invariant(n, "compiled template produced an element slot without an element"), r.kind === z.EVENT) {
1161
+ } else if (invariant(n, "compiled template produced an element slot without an element"), r.kind === V.EVENT) {
1099
1162
  let e = r.name;
1100
1163
  if (invariant(e, "compiled template produced an event slot without an event name"), typeof a == "function") o.push({
1101
1164
  el: n,
@@ -1117,7 +1180,7 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
1117
1180
  type: "event"
1118
1181
  });
1119
1182
  }
1120
- } else if (r.kind === z.PROP) {
1183
+ } else if (r.kind === V.PROP) {
1121
1184
  let e = r.name;
1122
1185
  invariant(e, "compiled template produced a prop slot without a property name"), typeof a == "function" ? o.push({
1123
1186
  el: n,
@@ -1135,12 +1198,12 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
1135
1198
  type: "prop",
1136
1199
  value: a
1137
1200
  });
1138
- } else if (r.kind === z.REF) a && o.push({
1201
+ } else if (r.kind === V.REF) a && o.push({
1139
1202
  el: n,
1140
1203
  ref: a,
1141
1204
  type: "ref"
1142
1205
  });
1143
- else if (invariant(r.name, "compiled template produced an attr slot without an attribute name"), M(a)) {
1206
+ else if (invariant(r.name, "compiled template produced an attr slot without an attribute name"), P(a)) {
1144
1207
  if (r.mode !== "attr") throw new OreApiError(s.modelRequiresValueBinding(r.name));
1145
1208
  o.push({
1146
1209
  el: n,
@@ -1154,7 +1217,7 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
1154
1217
  for (let t of o) applyBinding(t, e);
1155
1218
  for (let t of c) t(e);
1156
1219
  });
1157
- }, html = (e, ...t) => compileTemplate(e, t), Q = {
1220
+ }, html = (e, ...t) => compileTemplate(e, t), $ = {
1158
1221
  bubbles: !0,
1159
1222
  cancelable: !0,
1160
1223
  composed: !0
@@ -1162,12 +1225,12 @@ var L = "default", normalizeSlotName = (e) => e || L, createSlots = (e) => {
1162
1225
  let e = getHost();
1163
1226
  return ((t, ...n) => {
1164
1227
  let r = n.length > 0 ? {
1165
- ...Q,
1228
+ ...$,
1166
1229
  detail: n[0]
1167
- } : Q;
1230
+ } : $;
1168
1231
  return e.dispatchEvent(new CustomEvent(String(t), r));
1169
1232
  });
1170
- }, $ = 0, ee = Math.random().toString(36).slice(2, 6), createId = (e = "id") => `${e}-${ee}${++$}`;
1171
- export { OreApiError, OreError, OreInternalError, OreLifecycleError, bind, classMap, createContext, createId, css, define, each, getHost, html, inject, injectStrict, live, model, onCleanup, onElement, onEvent, onFormReset, onMounted, v as prop, provide, ref, styleMap, unsafeHtml, useEmit, useField, useSlots, watchEffect, when };
1233
+ }, te = 0, ne = Math.random().toString(36).slice(2, 6), createId = (e = "id") => `${e}-${ne}${++te}`;
1234
+ export { OreApiError, OreError, OreInternalError, OreLifecycleError, bind, classMap, createContext, createId, css, define, each, getHost, html, inject, injectStrict, live, model, onCleanup, onElement, onEvent, onFormReset, onMounted, b as prop, provide, ref, styleMap, unsafeHtml, useEmit, useField, useSlots, watchEffect, when };
1172
1235
 
1173
1236
  //# sourceMappingURL=ore.js.map