@sylwellsoftware/fray 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- var ue = Object.defineProperty;
2
- var ce = (e, t, n) => t in e ? ue(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var u = (e, t, n) => ce(e, typeof t != "symbol" ? t + "" : t, n);
4
- const I = {
1
+ var pe = Object.defineProperty;
2
+ var he = (e, t, r) => t in e ? pe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var c = (e, t, r) => he(e, typeof t != "symbol" ? t + "" : t, r);
4
+ const D = {
5
5
  after: {
6
6
  content: '""',
7
7
  display: "block",
@@ -152,13 +152,13 @@ const I = {
152
152
  "box-shadow": "var(--fray-toolbar-shadow, var(--toolbar-shadow))",
153
153
  color: "var(--fray-toolbar-color, var(--toolbar-color))"
154
154
  }
155
- }, U = "data-fray-structural-styles";
156
- let fe = 1;
157
- class J {
158
- constructor(t = `runtime-${fe++}`) {
159
- u(this, "id");
160
- u(this, "cssFragments", /* @__PURE__ */ new Set());
161
- u(this, "baseStyleMap", /* @__PURE__ */ new Map());
155
+ }, K = "data-fray-structural-styles";
156
+ let be = 1;
157
+ class Q {
158
+ constructor(t = `runtime-${be++}`) {
159
+ c(this, "id");
160
+ c(this, "cssFragments", /* @__PURE__ */ new Set());
161
+ c(this, "baseStyleMap", /* @__PURE__ */ new Map());
162
162
  if (typeof t != "string") throw new TypeError("StyleRegistry id must be a string");
163
163
  this.id = t;
164
164
  }
@@ -166,17 +166,17 @@ class J {
166
166
  if (typeof t != "string") throw new TypeError("Component CSS must be a string");
167
167
  return t.trim().length > 0 && this.cssFragments.add(t.trim()), this;
168
168
  }
169
- registerBaseStyle(t, n) {
169
+ registerBaseStyle(t, r) {
170
170
  if (typeof t != "string" || t.trim().length === 0)
171
171
  throw new TypeError("Base style selector must be a non-empty string");
172
- const r = typeof n == "string" ? [n] : n;
173
- if (!Array.isArray(r))
172
+ const n = typeof r == "string" ? [r] : r;
173
+ if (!Array.isArray(n))
174
174
  throw new TypeError("Base style names must be a string or array");
175
- for (const i of r) {
176
- if (!Object.hasOwn(I, i))
175
+ for (const i of n) {
176
+ if (!Object.hasOwn(D, i))
177
177
  throw new Error(`Unknown Fray base style: ${String(i)}`);
178
- const o = i, s = this.baseStyleMap.get(o) ?? /* @__PURE__ */ new Set();
179
- s.add(t.trim()), this.baseStyleMap.set(o, s);
178
+ const s = i, o = this.baseStyleMap.get(s) ?? /* @__PURE__ */ new Set();
179
+ o.add(t.trim()), this.baseStyleMap.set(s, o);
180
180
  }
181
181
  return this;
182
182
  }
@@ -203,13 +203,13 @@ class J {
203
203
  }
204
204
  generateBaseStyleCSS() {
205
205
  let t = "";
206
- for (const [n, r] of this.baseStyleMap) {
207
- const { properties: i, variants: o } = he(I[n]), s = [...r];
208
- t += D(n, s, i);
209
- for (const [a, l] of Object.entries(o))
210
- t += D(
211
- `${n}${a}`,
212
- s.map((c) => be(c, a)),
206
+ for (const [r, n] of this.baseStyleMap) {
207
+ const { properties: i, variants: s } = ge(D[r]), o = [...n];
208
+ t += U(r, o, i);
209
+ for (const [a, l] of Object.entries(s))
210
+ t += U(
211
+ `${r}${a}`,
212
+ o.map((u) => ve(u, a)),
213
213
  l
214
214
  );
215
215
  }
@@ -229,54 +229,144 @@ class J {
229
229
  injectAll(t = globalThis.document) {
230
230
  if ((t == null ? void 0 : t.head) == null)
231
231
  throw new TypeError("StyleRegistry.injectAll requires a document with a head");
232
- const n = `style[${U}="${ye(this.id)}"]`;
233
- let r = t.head.querySelector(n);
234
- r == null && (r = t.createElement("style"), r.setAttribute(U, this.id), t.head.prepend(r));
232
+ const r = `style[${K}="${we(this.id)}"]`;
233
+ let n = t.head.querySelector(r);
234
+ n == null && (n = t.createElement("style"), n.setAttribute(K, this.id), t.head.prepend(n));
235
235
  const i = this.generateCSS();
236
- return r.textContent !== i && (r.textContent = i), r;
236
+ return n.textContent !== i && (n.textContent = i), n;
237
237
  }
238
238
  reset() {
239
239
  this.cssFragments.clear(), this.baseStyleMap.clear();
240
240
  }
241
241
  }
242
- function de() {
243
- return new J();
242
+ function ye() {
243
+ return new Q();
244
244
  }
245
- const pe = new J("");
246
- function he(e) {
245
+ const me = new Q("");
246
+ function ge(e) {
247
247
  const t = {};
248
- let n = {};
249
- for (const [r, i] of Object.entries(e))
250
- if (r === "variants") {
248
+ let r = {};
249
+ for (const [n, i] of Object.entries(e))
250
+ if (n === "variants") {
251
251
  if (typeof i != "object")
252
252
  throw new TypeError("Base style variants must be declaration maps");
253
- n = i;
253
+ r = i;
254
254
  } else if (typeof i == "string")
255
- t[r] = i;
255
+ t[n] = i;
256
256
  else
257
- throw new TypeError(`Base style property ${r} must be a string`);
258
- return { properties: t, variants: n };
257
+ throw new TypeError(`Base style property ${n} must be a string`);
258
+ return { properties: t, variants: r };
259
259
  }
260
- function D(e, t, n) {
261
- if (t.length === 0 || Object.keys(n).length === 0) return "";
262
- const r = Object.entries(n).map(([i, o]) => ` ${i}: ${o};`).join(`
260
+ function U(e, t, r) {
261
+ if (t.length === 0 || Object.keys(r).length === 0) return "";
262
+ const n = Object.entries(r).map(([i, s]) => ` ${i}: ${s};`).join(`
263
263
  `);
264
264
  return `/* ${e} */
265
265
  ${t.join(`,
266
266
  `)} {
267
- ${r}
267
+ ${n}
268
268
  }
269
269
 
270
270
  `;
271
271
  }
272
- function be(e, t) {
273
- const n = e.indexOf("::");
274
- return n < 0 ? `${e}${t}` : `${e.slice(0, n)}${t}${e.slice(n)}`;
272
+ function ve(e, t) {
273
+ const r = e.indexOf("::");
274
+ return r < 0 ? `${e}${t}` : `${e.slice(0, r)}${t}${e.slice(r)}`;
275
275
  }
276
- function ye(e) {
276
+ function we(e) {
277
277
  return e.replaceAll("\\", "\\\\").replaceAll('"', '\\"');
278
278
  }
279
- const me = /* @__PURE__ */ new Set([
279
+ const X = /* @__PURE__ */ new WeakSet(), ee = /* @__PURE__ */ new WeakSet();
280
+ function Ue(e) {
281
+ if (typeof e != "string" || e.trim() === "")
282
+ throw new TypeError("Service name must be a non-empty string");
283
+ const t = Object.freeze({ name: e.trim() });
284
+ return X.add(t), t;
285
+ }
286
+ function We(e, t) {
287
+ if (z(e), typeof t != "function")
288
+ throw new TypeError(`Service provider "${e.name}" requires a factory function`);
289
+ const r = Object.freeze({ key: e, create: t });
290
+ return ee.add(r), r;
291
+ }
292
+ class te {
293
+ constructor(t = []) {
294
+ c(this, "providers", /* @__PURE__ */ new Map());
295
+ c(this, "instances", /* @__PURE__ */ new Map());
296
+ c(this, "creationOrder", []);
297
+ c(this, "resolving", []);
298
+ c(this, "disposed", !1);
299
+ if (!Array.isArray(t))
300
+ throw new TypeError("ServiceScope providers must be an array");
301
+ for (const r of t) {
302
+ if (Re(r), this.providers.has(r.key))
303
+ throw new Error(`Service "${r.key.name}" is registered more than once`);
304
+ this.providers.set(r.key, r);
305
+ }
306
+ }
307
+ get isDisposed() {
308
+ return this.disposed;
309
+ }
310
+ has(t) {
311
+ return this.assertActive(), z(t), this.providers.has(t);
312
+ }
313
+ require(t) {
314
+ if (this.assertActive(), z(t), this.instances.has(t)) return this.instances.get(t);
315
+ const r = this.providers.get(t);
316
+ if (r == null) throw new Error(`Service "${t.name}" is not registered`);
317
+ const n = this.resolving.indexOf(t);
318
+ if (n >= 0) {
319
+ const i = [...this.resolving.slice(n), t].map((s) => s.name).join(" -> ");
320
+ throw new Error(`Circular service dependency: ${i}`);
321
+ }
322
+ this.resolving.push(t);
323
+ try {
324
+ const i = r.create(this);
325
+ return this.instances.set(t, i), this.creationOrder.push(t), i;
326
+ } finally {
327
+ this.resolving.pop();
328
+ }
329
+ }
330
+ dispose() {
331
+ if (this.disposed) return;
332
+ this.disposed = !0;
333
+ const t = [];
334
+ for (const r of [...this.creationOrder].reverse()) {
335
+ const n = this.instances.get(r);
336
+ try {
337
+ const i = je(n);
338
+ i != null && i.call(n);
339
+ } catch (i) {
340
+ t.push(i);
341
+ }
342
+ }
343
+ if (this.instances.clear(), this.creationOrder.length = 0, this.resolving.length = 0, t.length === 1) throw t[0];
344
+ if (t.length > 1)
345
+ throw new AggregateError(t, "Several services failed during disposal");
346
+ }
347
+ assertActive() {
348
+ if (this.disposed) throw new Error("ServiceScope has been disposed");
349
+ }
350
+ }
351
+ function Se(e = []) {
352
+ return new te(e);
353
+ }
354
+ function Ee(e) {
355
+ return e != null && (typeof e == "object" || typeof e == "function") && X.has(e);
356
+ }
357
+ function z(e) {
358
+ if (!Ee(e)) throw new TypeError("Expected a service key created by defineService()");
359
+ }
360
+ function Re(e) {
361
+ if (e == null || typeof e != "object" && typeof e != "function" || !ee.has(e))
362
+ throw new TypeError("Expected a service provider created by provideService()");
363
+ }
364
+ function je(e) {
365
+ if (e == null || typeof e != "object" && typeof e != "function") return null;
366
+ const t = Reflect.get(e, "dispose");
367
+ return typeof t == "function" ? t : null;
368
+ }
369
+ const Te = /* @__PURE__ */ new Set([
280
370
  "annotation-xml",
281
371
  "color-profile",
282
372
  "font-face",
@@ -287,43 +377,45 @@ const me = /* @__PURE__ */ new Set([
287
377
  "missing-glyph"
288
378
  ]);
289
379
  class L {
290
- constructor(t = {}, n = de()) {
291
- u(this, "elementPrefix");
292
- u(this, "elementNameOverrides");
293
- u(this, "styleRegistry");
380
+ constructor(t = {}, r = ye()) {
381
+ c(this, "elementPrefix");
382
+ c(this, "elementNameOverrides");
383
+ c(this, "styleRegistry");
384
+ c(this, "services");
294
385
  if (t == null || typeof t != "object" || Array.isArray(t))
295
386
  throw new TypeError("FrayRuntime options must be an object");
296
- const r = t.elementNames ?? {};
297
- if (r == null || typeof r != "object" || Array.isArray(r))
387
+ const n = t.elementNames ?? {};
388
+ if (n == null || typeof n != "object" || Array.isArray(n))
298
389
  throw new TypeError("Fray elementNames must be an object");
299
- const i = r.prefix === void 0 ? "fray" : r.prefix;
300
- i !== null && T(i, "Fray element prefix");
301
- const o = r.overrides ?? {};
302
- if (o == null || typeof o != "object" || Array.isArray(o))
390
+ const i = n.prefix === void 0 ? "fray" : n.prefix;
391
+ i !== null && C(i, "Fray element prefix");
392
+ const s = n.overrides ?? {};
393
+ if (s == null || typeof s != "object" || Array.isArray(s))
303
394
  throw new TypeError("Fray element-name overrides must be an object");
304
- for (const [s, a] of Object.entries(o))
305
- T(s, "Fray component host name"), K(a);
306
- this.elementPrefix = i, this.elementNameOverrides = Object.freeze({ ...o }), this.styleRegistry = n;
395
+ for (const [o, a] of Object.entries(s))
396
+ C(o, "Fray component host name"), Z(a);
397
+ if (this.elementPrefix = i, this.elementNameOverrides = Object.freeze({ ...s }), this.styleRegistry = r, this.services = t.services ?? Se(), !(this.services instanceof te))
398
+ throw new TypeError("Fray services must be a ServiceScope");
307
399
  }
308
- resolveElementName(t, n = null) {
309
- T(t, "Fray component host name");
310
- const i = this.elementNameOverrides[t] ?? (this.elementPrefix == null ? n ?? t : `${this.elementPrefix}-${t}`);
311
- return K(i), i;
400
+ resolveElementName(t, r = null) {
401
+ C(t, "Fray component host name");
402
+ const i = this.elementNameOverrides[t] ?? (this.elementPrefix == null ? r ?? t : `${this.elementPrefix}-${t}`);
403
+ return Z(i), i;
312
404
  }
313
- resolveHostSelector(t, n, r = null) {
405
+ resolveHostSelector(t, r, n = null) {
314
406
  if (typeof t != "string") throw new TypeError("Host selector must be a string");
315
- return t.replaceAll("&", this.resolveElementName(n, r));
407
+ return t.replaceAll("&", this.resolveElementName(r, n));
316
408
  }
317
- resolveHostCSS(t, n, r = null) {
409
+ resolveHostCSS(t, r, n = null) {
318
410
  if (typeof t != "string") throw new TypeError("Host CSS must be a string");
319
- return t.replaceAll("&", this.resolveElementName(n, r));
411
+ return t.replaceAll("&", this.resolveElementName(r, n));
320
412
  }
321
- create(t, ...n) {
322
- const r = new t(...n);
323
- return r._setRuntime(this), r;
413
+ create(t, ...r) {
414
+ const n = new t(...r);
415
+ return n._setRuntime(this), n;
324
416
  }
325
- mount(t, n, r = null) {
326
- return t._setRuntime(this), t.mount(n, r), t;
417
+ mount(t, r, n = null) {
418
+ return t._setRuntime(this), t.mount(r, n), t;
327
419
  }
328
420
  registerStyles(t) {
329
421
  if (t == null || typeof t.registerStyles != "function")
@@ -334,19 +426,19 @@ class L {
334
426
  return this.styleRegistry.injectAll(t);
335
427
  }
336
428
  }
337
- function _e(e = {}) {
429
+ function Ze(e = {}) {
338
430
  return new L(e);
339
431
  }
340
- const Z = new L({}, pe);
341
- function T(e, t) {
432
+ const W = new L({}, me);
433
+ function C(e, t) {
342
434
  if (typeof e != "string" || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(e))
343
435
  throw new TypeError(`${t} must be a lowercase kebab-case name`);
344
436
  }
345
- function K(e) {
346
- if (T(e, "Fray element name"), !e.includes("-") || me.has(e))
437
+ function Z(e) {
438
+ if (C(e, "Fray element name"), !e.includes("-") || Te.has(e))
347
439
  throw new TypeError(`Fray element name must be a non-reserved name containing a hyphen: ${e}`);
348
440
  }
349
- const P = Symbol.for("@sylwellsoftware/fray.Fragment"), Q = /* @__PURE__ */ new WeakSet(), ge = /* @__PURE__ */ new Set([
441
+ const P = Symbol.for("@sylwellsoftware/fray.Fragment"), re = /* @__PURE__ */ new WeakSet(), ke = /* @__PURE__ */ new Set([
350
442
  "allowFullScreen",
351
443
  "async",
352
444
  "autoFocus",
@@ -370,7 +462,7 @@ const P = Symbol.for("@sylwellsoftware/fray.Fragment"), Q = /* @__PURE__ */ new
370
462
  "required",
371
463
  "reversed",
372
464
  "selected"
373
- ]), we = /* @__PURE__ */ new Set([
465
+ ]), Ce = /* @__PURE__ */ new Set([
374
466
  "checked",
375
467
  "defaultChecked",
376
468
  "defaultValue",
@@ -385,79 +477,79 @@ const P = Symbol.for("@sylwellsoftware/fray.Fragment"), Q = /* @__PURE__ */ new
385
477
  "tabIndex",
386
478
  "value"
387
479
  ]);
388
- function Me(e) {
389
- H(e, "live");
480
+ function Ye(e) {
481
+ I(e, "live");
390
482
  const t = Object.freeze({ emitter: e });
391
- return Q.add(t), t;
483
+ return re.add(t), t;
392
484
  }
393
- function A(e, t = null, ...n) {
394
- const r = t ?? {};
395
- if (typeof r != "object" || Array.isArray(r))
485
+ function A(e, t = null, ...r) {
486
+ const n = t ?? {};
487
+ if (typeof n != "object" || Array.isArray(n))
396
488
  throw new TypeError("VNode props must be an object or null");
397
489
  const {
398
490
  children: i,
399
- key: o = null,
400
- ...s
401
- } = r;
491
+ key: s = null,
492
+ ...o
493
+ } = n;
402
494
  return {
403
495
  type: e,
404
- key: o,
496
+ key: s,
405
497
  props: {
406
- ...s,
407
- children: X([i, n])
498
+ ...o,
499
+ children: ne([i, r])
408
500
  }
409
501
  };
410
502
  }
411
- function Ve(e, ...t) {
412
- return e.reduce((n, r, i) => n + r + String(t[i] ?? ""), "");
503
+ function Ge(e, ...t) {
504
+ return e.reduce((r, n, i) => r + n + String(t[i] ?? ""), "");
413
505
  }
414
- const b = class b {
506
+ const h = class h {
415
507
  constructor(t = {}) {
416
- u(this, "props");
417
- u(this, "dom", null);
508
+ c(this, "props");
509
+ c(this, "dom", null);
418
510
  /** @internal */
419
- u(this, "_rendered", null);
511
+ c(this, "_rendered", null);
420
512
  /** @internal */
421
- u(this, "_childComponents", /* @__PURE__ */ new Set());
422
- u(this, "initialized", !1);
423
- u(this, "mounted", !1);
424
- u(this, "destroyed", !1);
425
- u(this, "updating", !1);
426
- u(this, "updateRequested", !1);
427
- u(this, "cleanupFunctions", /* @__PURE__ */ new Set());
428
- u(this, "watched", /* @__PURE__ */ new Map());
429
- u(this, "renderReadSubscriptions", /* @__PURE__ */ new Map());
430
- u(this, "collectingRenderReads", null);
513
+ c(this, "_childComponents", /* @__PURE__ */ new Set());
514
+ c(this, "initialized", !1);
515
+ c(this, "mounted", !1);
516
+ c(this, "destroyed", !1);
517
+ c(this, "updating", !1);
518
+ c(this, "updateRequested", !1);
519
+ c(this, "cleanupFunctions", /* @__PURE__ */ new Set());
520
+ c(this, "watched", /* @__PURE__ */ new Map());
521
+ c(this, "renderReadSubscriptions", /* @__PURE__ */ new Map());
522
+ c(this, "collectingRenderReads", null);
431
523
  /** @internal */
432
- u(this, "_runtime", Z);
524
+ c(this, "_runtime", W);
433
525
  /** JSX component for this instance's runtime-configured custom host. */
434
- u(this, "Host", ({
526
+ c(this, "Host", ({
435
527
  children: t = [],
436
- ...n
437
- }) => this.host(n, t));
528
+ ...r
529
+ }) => this.host(r, t));
438
530
  if (t == null || typeof t != "object" || Array.isArray(t))
439
531
  throw new TypeError(`${this.constructor.name} props must be an object`);
440
532
  this.props = t;
441
533
  }
442
534
  static new(...t) {
443
- const n = new this(...t);
444
- if (!(n instanceof b))
535
+ const r = new this(...t);
536
+ if (!(r instanceof h))
445
537
  throw new TypeError("Component.new() requires a Component constructor");
446
- return n.mount();
538
+ return r.mount();
447
539
  }
448
540
  static get baseStyles() {
449
541
  return {};
450
542
  }
451
- static registerStyles(t = Z, n = /* @__PURE__ */ new Set()) {
452
- if (n.has(this)) return;
453
- n.add(this);
454
- const r = this.hostName ?? null, i = this.standaloneHostName ?? null;
455
- this.css && t.styleRegistry.registerCSS(r == null ? this.css : t.resolveHostCSS(this.css, r, i));
456
- const o = Be(this.baseStyles);
457
- for (const [s, a] of o)
458
- t.styleRegistry.registerBaseStyle(r == null ? s : t.resolveHostSelector(s, r, i), a);
459
- for (const s of this.dependencies ?? [])
460
- s.registerStyles(t, n);
543
+ static registerStyles(t = W, r = /* @__PURE__ */ new Set()) {
544
+ if (r.has(this)) return;
545
+ r.add(this);
546
+ const n = this.hostName ?? null, i = this.standaloneHostName ?? null;
547
+ this.css && t.styleRegistry.registerCSS(n == null ? this.css : t.resolveHostCSS(this.css, n, i));
548
+ const s = De(this.baseStyles);
549
+ for (const [o, a] of s)
550
+ t.styleRegistry.registerBaseStyle(n == null ? o : t.resolveHostSelector(o, n, i), a);
551
+ for (const o of this.dependencies ?? [])
552
+ o.registerStyles(t, r);
461
553
  }
462
554
  /** One-time setup hook. Constructors must not subscribe or render. */
463
555
  initialize() {
@@ -466,17 +558,17 @@ const b = class b {
466
558
  throw new Error(`${this.constructor.name} must implement render()`);
467
559
  }
468
560
  /** Render this component's configured custom host element. */
469
- host(t = null, ...n) {
470
- const r = this.constructor, i = r.hostName;
561
+ host(t = null, ...r) {
562
+ const n = this.constructor, i = n.hostName;
471
563
  if (i == null)
472
564
  throw new Error(`${this.constructor.name} does not declare a custom host name`);
473
565
  return A(this._runtime.resolveElementName(
474
566
  i,
475
- r.standaloneHostName
567
+ n.standaloneHostName
476
568
  ), {
477
569
  ...t,
478
570
  "data-fray-component": i
479
- }, ...n);
571
+ }, ...r);
480
572
  }
481
573
  /** @internal Assign an immutable application runtime before initialization or mounting. */
482
574
  _setRuntime(t) {
@@ -487,10 +579,10 @@ const b = class b {
487
579
  throw new Error("Cannot change a component runtime after initialization");
488
580
  return this._runtime = t, this;
489
581
  }
490
- mount(t = null, n = null) {
582
+ mount(t = null, r = null) {
491
583
  if (this.destroyed) throw new Error("Cannot mount a destroyed component");
492
- let r = !1;
493
- return this.initialized || (this.initialized = !0, this.initialize()), this.mounted || (this.mounted = !0, this.update(), r = !0), t != null && (ze(t), q(t, this._rendered, n)), r && this.afterMount(this.dom), this;
584
+ let n = !1;
585
+ return this.initialized || (this.validateRequiredServices(), this.initialized = !0, this.initialize()), this.mounted || (this.mounted = !0, this.update(), n = !0), t != null && (Ie(t), H(t, this._rendered, r)), n && this.afterMount(this.dom), this;
494
586
  }
495
587
  attachTo(t) {
496
588
  return this.mount(t), this;
@@ -504,15 +596,15 @@ const b = class b {
504
596
  try {
505
597
  do {
506
598
  this.updateRequested = !1;
507
- const n = /* @__PURE__ */ new Set();
508
- this.collectingRenderReads = n;
509
- let r;
599
+ const r = /* @__PURE__ */ new Set();
600
+ this.collectingRenderReads = r;
601
+ let n;
510
602
  try {
511
- r = R(this.render());
603
+ n = R(this.render());
512
604
  } finally {
513
605
  this.collectingRenderReads = null;
514
606
  }
515
- this._rendered = _(this._rendered, r, this), this.dom = re(this._rendered), this.reconcileRenderReads(n), this.afterUpdate(this.dom);
607
+ this._rendered = M(this._rendered, n, this), this.dom = ae(this._rendered), this.reconcileRenderReads(r), this.afterUpdate(this.dom);
516
608
  } while (this.updateRequested && !this.destroyed);
517
609
  } finally {
518
610
  this.updating = !1;
@@ -529,15 +621,15 @@ const b = class b {
529
621
  afterUpdate(t) {
530
622
  }
531
623
  watch(...t) {
532
- for (const n of t) {
533
- if (n == null || typeof n.subscribe != "function")
624
+ for (const r of t) {
625
+ if (r == null || typeof r.subscribe != "function")
534
626
  throw new TypeError("watch requires emitter-like values");
535
- if (this.watched.has(n)) continue;
536
- const r = n.subscribe(({ event: i }) => {
627
+ if (this.watched.has(r)) continue;
628
+ const n = r.subscribe(({ event: i }) => {
537
629
  this.mounted && !this.destroyed && this.update(i);
538
630
  }, { emitCurrent: !1 });
539
- this.watched.set(n, r), this.onCleanup(() => {
540
- r(), this.watched.delete(n);
631
+ this.watched.set(r, n), this.onCleanup(() => {
632
+ n(), this.watched.delete(r);
541
633
  });
542
634
  }
543
635
  return this;
@@ -563,19 +655,30 @@ const b = class b {
563
655
  return t(), () => {
564
656
  };
565
657
  this.cleanupFunctions.add(t);
566
- let n = !0;
658
+ let r = !0;
567
659
  return () => {
568
- n && (n = !1, this.cleanupFunctions.delete(t), t());
660
+ r && (r = !1, this.cleanupFunctions.delete(t), t());
569
661
  };
570
662
  }
571
- listen(t, n, r, i) {
663
+ /** Resolve one explicitly declared application service from this component's runtime. */
664
+ requireService(t) {
665
+ if (!this.initialized)
666
+ throw new Error("Components may resolve services during initialize() or later");
667
+ const r = this.constructor;
668
+ if (!r.requiredServices.includes(t))
669
+ throw new Error(
670
+ `${r.name} must declare service "${t.name}" in requiredServices`
671
+ );
672
+ return this._runtime.services.require(t);
673
+ }
674
+ listen(t, r, n, i) {
572
675
  if (t == null || typeof t.addEventListener != "function")
573
676
  throw new TypeError("listen target must be an EventTarget");
574
- const o = r;
575
- return t.addEventListener(n, o, i), this.onCleanup(() => t.removeEventListener(n, o, i)), this;
677
+ const s = n;
678
+ return t.addEventListener(r, s, i), this.onCleanup(() => t.removeEventListener(r, s, i)), this;
576
679
  }
577
680
  registerChild(t) {
578
- if (!(t instanceof b))
681
+ if (!(t instanceof h))
579
682
  throw new TypeError("registerChild requires a Component");
580
683
  return this._childComponents.add(t), t;
581
684
  }
@@ -588,39 +691,45 @@ const b = class b {
588
691
  this.renderReadSubscriptions.clear(), this.collectingRenderReads = null, this._rendered && g(this._rendered, !0), this._rendered = null, this.dom = null, this._childComponents.clear(), this.onDestroy();
589
692
  }
590
693
  }
694
+ validateRequiredServices() {
695
+ const t = this.constructor;
696
+ for (const r of t.requiredServices)
697
+ if (!this._runtime.services.has(r))
698
+ throw new Error(`${t.name} requires unregistered service "${r.name}"`);
699
+ }
591
700
  onDestroy() {
592
701
  }
593
702
  trackRenderRead(t) {
594
- if (H(t, "Component.read"), this.collectingRenderReads == null)
703
+ if (I(t, "Component.read"), this.collectingRenderReads == null)
595
704
  throw new Error("Component.read() and snapshot() may only be called during render()");
596
705
  this.collectingRenderReads.add(t);
597
706
  }
598
707
  reconcileRenderReads(t) {
599
- for (const [n, r] of this.renderReadSubscriptions)
600
- t.has(n) || (r(), this.renderReadSubscriptions.delete(n));
601
- for (const n of t) {
602
- if (this.watched.has(n) || this.renderReadSubscriptions.has(n)) continue;
603
- const r = n.subscribe(({ event: i }) => {
708
+ for (const [r, n] of this.renderReadSubscriptions)
709
+ t.has(r) || (n(), this.renderReadSubscriptions.delete(r));
710
+ for (const r of t) {
711
+ if (this.watched.has(r) || this.renderReadSubscriptions.has(r)) continue;
712
+ const n = r.subscribe(({ event: i }) => {
604
713
  this.mounted && !this.destroyed && this.update(i);
605
714
  }, { emitCurrent: !1 });
606
- this.renderReadSubscriptions.set(n, r);
715
+ this.renderReadSubscriptions.set(r, n);
607
716
  }
608
717
  }
609
718
  };
610
- u(b, "dependencies", []), u(b, "css", ""), u(b, "hostName", null), u(b, "standaloneHostName", null);
611
- let h = b;
719
+ c(h, "dependencies", []), c(h, "requiredServices", []), c(h, "css", ""), c(h, "hostName", null), c(h, "standaloneHostName", null);
720
+ let b = h;
612
721
  function R(e) {
613
722
  return Array.isArray(e) ? A(P, null, e) : e == null || typeof e == "boolean" ? A(P) : e;
614
723
  }
615
- function X(e) {
616
- const t = [], n = (r) => {
617
- if (Array.isArray(r))
618
- for (const i of r) n(i);
619
- else r != null && typeof r != "boolean" && t.push(r);
724
+ function ne(e) {
725
+ const t = [], r = (n) => {
726
+ if (Array.isArray(n))
727
+ for (const i of n) r(i);
728
+ else n != null && typeof n != "boolean" && t.push(n);
620
729
  };
621
- return n(e), t;
730
+ return r(e), t;
622
731
  }
623
- function k(e, t) {
732
+ function j(e, t) {
624
733
  if (typeof e == "string" || typeof e == "number")
625
734
  return {
626
735
  kind: "text",
@@ -629,21 +738,21 @@ function k(e, t) {
629
738
  node: document.createTextNode(String(e)),
630
739
  owner: t
631
740
  };
632
- if (N(e)) {
633
- const o = document.createComment("fray-emitter-start"), s = document.createComment("fray-emitter-end"), a = e.get();
741
+ if ($(e)) {
742
+ const s = document.createComment("fray-emitter-start"), o = document.createComment("fray-emitter-end"), a = e.get();
634
743
  if (Object.is(a, e))
635
744
  throw new TypeError("A Fray emitter child cannot render itself");
636
745
  const l = document.createDocumentFragment();
637
- l.append(o, s);
638
- const c = k(R(a), t);
639
- q(l, c, s);
746
+ l.append(s, o);
747
+ const u = j(R(a), t);
748
+ H(l, u, o);
640
749
  const d = {
641
750
  kind: "emitter",
642
751
  key: null,
643
752
  source: e,
644
- start: o,
645
- end: s,
646
- child: c,
753
+ start: s,
754
+ end: o,
755
+ child: u,
647
756
  unsubscribe: () => {
648
757
  },
649
758
  owner: t
@@ -651,13 +760,13 @@ function k(e, t) {
651
760
  return d.unsubscribe = e.subscribe(({ value: m }) => {
652
761
  if (Object.is(m, e))
653
762
  throw new TypeError("A Fray emitter child cannot render itself");
654
- d.child = _(d.child, R(m), t);
763
+ d.child = M(d.child, R(m), t);
655
764
  }, { emitCurrent: !1 }), d;
656
765
  }
657
- if (e instanceof h)
766
+ if (e instanceof b)
658
767
  return e._setRuntime(t._runtime), e.mount(), t.registerChild(e), {
659
768
  kind: "component",
660
- key: ie(e.props),
769
+ key: ce(e.props),
661
770
  type: e.constructor,
662
771
  instance: e,
663
772
  prebuilt: !0,
@@ -666,33 +775,33 @@ function k(e, t) {
666
775
  owner: t
667
776
  };
668
777
  if (!y(e))
669
- throw new TypeError(`Invalid Fray child: ${G(e)}`);
670
- const { type: n, key: r = null, props: i } = e;
671
- if (n === P) {
672
- const o = document.createComment("fray-fragment-start"), s = document.createComment("fray-fragment-end"), a = {
778
+ throw new TypeError(`Invalid Fray child: ${J(e)}`);
779
+ const { type: r, key: n = null, props: i } = e;
780
+ if (r === P) {
781
+ const s = document.createComment("fray-fragment-start"), o = document.createComment("fray-fragment-end"), a = {
673
782
  kind: "fragment",
674
- key: r,
675
- type: n,
676
- start: o,
677
- end: s,
783
+ key: n,
784
+ type: r,
785
+ start: s,
786
+ end: o,
678
787
  children: [],
679
788
  owner: t
680
789
  }, l = document.createDocumentFragment();
681
- return l.append(o, s), a.children = O(
790
+ return l.append(s, o), a.children = O(
682
791
  l,
683
792
  [],
684
793
  i.children,
685
794
  t,
686
- s,
687
- o
795
+ o,
796
+ s
688
797
  ), a;
689
798
  }
690
- if (typeof n == "string") {
691
- const o = document.createElement(n), s = {
799
+ if (typeof r == "string") {
800
+ const s = document.createElement(r), o = {
692
801
  kind: "element",
693
- key: r,
694
- type: n,
695
- node: o,
802
+ key: n,
803
+ type: r,
804
+ node: s,
696
805
  props: {},
697
806
  listeners: /* @__PURE__ */ new Map(),
698
807
  liveProps: /* @__PURE__ */ new Map(),
@@ -701,267 +810,267 @@ function k(e, t) {
701
810
  children: [],
702
811
  owner: t
703
812
  };
704
- return ne(s, i), s.children = O(o, [], i.children, t), s;
813
+ return oe(o, i), o.children = O(s, [], i.children, t), o;
705
814
  }
706
- if (se(n)) {
707
- const o = i, s = W(o), a = new n(s);
815
+ if (ue(r)) {
816
+ const s = i, o = Y(s), a = new r(o);
708
817
  a._setRuntime(t._runtime);
709
818
  const l = {
710
819
  kind: "component",
711
- key: r,
712
- type: n,
820
+ key: n,
821
+ type: r,
713
822
  instance: a,
714
823
  prebuilt: !1,
715
- props: s,
824
+ props: o,
716
825
  liveProps: /* @__PURE__ */ new Map(),
717
826
  owner: t
718
827
  };
719
- return te(l, o), a.mount(), t.registerChild(a), l;
828
+ return se(l, s), a.mount(), t.registerChild(a), l;
720
829
  }
721
- if (typeof n == "function") {
722
- const o = n, s = i, a = W(s), l = R(o(a)), c = {
830
+ if (typeof r == "function") {
831
+ const s = r, o = i, a = Y(o), l = R(s(a)), u = {
723
832
  kind: "function",
724
- key: r,
725
- type: o,
833
+ key: n,
834
+ type: s,
726
835
  props: a,
727
- sourceProps: s,
836
+ sourceProps: o,
728
837
  liveProps: /* @__PURE__ */ new Map(),
729
- child: k(l, t),
838
+ child: j(l, t),
730
839
  owner: t
731
840
  };
732
- return Se(c), c;
841
+ return Ae(u), u;
733
842
  }
734
- throw new TypeError(`Unsupported vnode type: ${G(n)}`);
843
+ throw new TypeError(`Unsupported vnode type: ${J(r)}`);
735
844
  }
736
- function _(e, t, n) {
737
- if (e == null) return k(t, n);
738
- if (oe(e, t)) return ee(e, t, n);
739
- const r = k(t, n), i = re(e), o = (i == null ? void 0 : i.parentNode) ?? null;
740
- return o && q(o, r, i), g(e, !0), r;
845
+ function M(e, t, r) {
846
+ if (e == null) return j(t, r);
847
+ if (le(e, t)) return ie(e, t, r);
848
+ const n = j(t, r), i = ae(e), s = (i == null ? void 0 : i.parentNode) ?? null;
849
+ return s && H(s, n, i), g(e, !0), n;
741
850
  }
742
- function ee(e, t, n) {
743
- return e.kind === "text" ? (typeof t != "string" && typeof t != "number" || Object.is(e.value, t) || (e.value = t, e.node.data = String(t)), e) : e.kind === "emitter" ? (!N(t) || e.source !== t, e) : e.kind === "component" ? (t instanceof h || y(t) && ve(e, t.props), e) : y(t) ? e.kind === "function" ? (Ee(e, t.props), e) : e.kind === "fragment" ? (e.children = O(
851
+ function ie(e, t, r) {
852
+ return e.kind === "text" ? (typeof t != "string" && typeof t != "number" || Object.is(e.value, t) || (e.value = t, e.node.data = String(t)), e) : e.kind === "emitter" ? (!$(t) || e.source !== t, e) : e.kind === "component" ? (t instanceof b || y(t) && Pe(e, t.props), e) : y(t) ? e.kind === "function" ? (Oe(e, t.props), e) : e.kind === "fragment" ? (e.children = O(
744
853
  e.start.parentNode,
745
854
  e.children,
746
855
  t.props.children,
747
- n,
856
+ r,
748
857
  e.end,
749
858
  e.start
750
- ), e) : (ne(e, t.props), e.children = O(
859
+ ), e) : (oe(e, t.props), e.children = O(
751
860
  e.node,
752
861
  e.children,
753
862
  t.props.children,
754
- n
863
+ r
755
864
  ), e) : e;
756
865
  }
757
- function W(e) {
758
- return Object.fromEntries(Object.entries(e).map(([t, n]) => [
866
+ function Y(e) {
867
+ return Object.fromEntries(Object.entries(e).map(([t, r]) => [
759
868
  t,
760
- j(n) ? n.emitter.get() : n
869
+ T(r) ? r.emitter.get() : r
761
870
  ]));
762
871
  }
763
- function te(e, t) {
764
- M(e.liveProps, t, (n, r) => {
765
- e.props = { ...e.props, [n]: r }, e.instance.setProps(e.props);
872
+ function se(e, t) {
873
+ q(e.liveProps, t, (r, n) => {
874
+ e.props = { ...e.props, [r]: n }, e.instance.setProps(e.props);
766
875
  }), e.props = V(e.liveProps, t), e.instance.setProps(e.props);
767
876
  }
768
- function ve(e, t) {
769
- te(e, t);
877
+ function Pe(e, t) {
878
+ se(e, t);
770
879
  }
771
- function Se(e) {
772
- M(e.liveProps, e.sourceProps, (t, n) => {
773
- e.props = { ...e.props, [t]: n }, z(e);
880
+ function Ae(e) {
881
+ q(e.liveProps, e.sourceProps, (t, r) => {
882
+ e.props = { ...e.props, [t]: r }, _(e);
774
883
  }), e.props = V(e.liveProps, e.sourceProps);
775
884
  }
776
- function Ee(e, t) {
777
- e.sourceProps = t, M(e.liveProps, t, (n, r) => {
778
- e.props = { ...e.props, [n]: r }, z(e);
779
- }), e.props = V(e.liveProps, t), z(e);
885
+ function Oe(e, t) {
886
+ e.sourceProps = t, q(e.liveProps, t, (r, n) => {
887
+ e.props = { ...e.props, [r]: n }, _(e);
888
+ }), e.props = V(e.liveProps, t), _(e);
780
889
  }
781
- function z(e) {
890
+ function _(e) {
782
891
  const t = R(e.type(e.props));
783
- e.child = _(e.child, t, e.owner);
892
+ e.child = M(e.child, t, e.owner);
784
893
  }
785
- function M(e, t, n) {
786
- for (const [r, i] of e) {
787
- const o = t[r];
788
- j(o) && o.emitter === i.source || (i.unsubscribe(), e.delete(r));
894
+ function q(e, t, r) {
895
+ for (const [n, i] of e) {
896
+ const s = t[n];
897
+ T(s) && s.emitter === i.source || (i.unsubscribe(), e.delete(n));
789
898
  }
790
- for (const [r, i] of Object.entries(t)) {
791
- if (!j(i) || e.has(r)) continue;
792
- const o = {
899
+ for (const [n, i] of Object.entries(t)) {
900
+ if (!T(i) || e.has(n)) continue;
901
+ const s = {
793
902
  source: i.emitter,
794
903
  value: i.emitter.get(),
795
904
  unsubscribe: () => {
796
905
  }
797
906
  };
798
- o.unsubscribe = i.emitter.subscribe(({ value: s }) => {
799
- e.get(r) === o && (o.value = s, n(r, s));
800
- }, { emitCurrent: !1 }), e.set(r, o);
907
+ s.unsubscribe = i.emitter.subscribe(({ value: o }) => {
908
+ e.get(n) === s && (s.value = o, r(n, o));
909
+ }, { emitCurrent: !1 }), e.set(n, s);
801
910
  }
802
911
  }
803
912
  function V(e, t) {
804
- return Object.fromEntries(Object.entries(t).map(([n, r]) => {
913
+ return Object.fromEntries(Object.entries(t).map(([r, n]) => {
805
914
  var i;
806
915
  return [
807
- n,
808
- j(r) ? ((i = e.get(n)) == null ? void 0 : i.value) ?? r.emitter.get() : r
916
+ r,
917
+ T(n) ? ((i = e.get(r)) == null ? void 0 : i.value) ?? n.emitter.get() : n
809
918
  ];
810
919
  }));
811
920
  }
812
- function O(e, t, n, r, i = null, o = null) {
921
+ function O(e, t, r, n, i = null, s = null) {
813
922
  if (e == null) throw new Error("Cannot patch a detached fragment range");
814
- const s = X(n), a = /* @__PURE__ */ new Map(), l = [];
923
+ const o = ne(r), a = /* @__PURE__ */ new Map(), l = [];
815
924
  for (const f of t)
816
925
  f.key == null ? l.push(f) : a.has(f.key) || a.set(f.key, f);
817
- const c = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), m = [];
818
- let le = 0;
819
- for (const f of s) {
926
+ const u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), m = [];
927
+ let de = 0;
928
+ for (const f of o) {
820
929
  const p = E(f);
821
930
  if (p != null) {
822
- if (c.has(p)) throw new Error(`Duplicate sibling key: ${String(p)}`);
823
- c.add(p);
931
+ if (u.has(p)) throw new Error(`Duplicate sibling key: ${String(p)}`);
932
+ u.add(p);
824
933
  }
825
- const C = p == null ? l[le++] : a.get(p);
826
- C && oe(C, f) ? (d.add(C), m.push(ee(C, f, r))) : m.push(k(f, r));
934
+ const k = p == null ? l[de++] : a.get(p);
935
+ k && le(k, f) ? (d.add(k), m.push(ie(k, f, n))) : m.push(j(f, n));
827
936
  }
828
937
  for (const f of t)
829
938
  d.has(f) || g(f, !0);
830
- let S = o ? o.nextSibling : e.firstChild;
939
+ let S = s ? s.nextSibling : e.firstChild;
831
940
  for (const f of m)
832
- for (const p of w(f))
941
+ for (const p of v(f))
833
942
  p === S ? S = S.nextSibling : (e.insertBefore(p, S ?? i), S = p.nextSibling);
834
943
  return m;
835
944
  }
836
- function ne(e, t) {
837
- const { children: n, ...r } = t, i = e.props, o = /* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(r)]);
838
- for (const s of ["value", "checked"])
839
- if (Object.hasOwn(r, s) && Object.hasOwn(r, `bind:${s}`))
840
- throw new Error(`${s} and bind:${s} cannot be used together`);
841
- for (const s of o) {
842
- const a = i[s], l = r[s];
843
- if (xe(s))
844
- ke(e, s, l);
845
- else if (s === "ref")
846
- a !== l && Ce(e, l);
847
- else if (Oe(s))
848
- je(e, s, l);
849
- else if (j(l))
850
- Re(e, s, l);
945
+ function oe(e, t) {
946
+ const { children: r, ...n } = t, i = e.props, s = /* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(n)]);
947
+ for (const o of ["value", "checked"])
948
+ if (Object.hasOwn(n, o) && Object.hasOwn(n, `bind:${o}`))
949
+ throw new Error(`${o} and bind:${o} cannot be used together`);
950
+ for (const o of s) {
951
+ const a = i[o], l = n[o];
952
+ if (Me(o))
953
+ $e(e, o, l);
954
+ else if (o === "ref")
955
+ a !== l && Fe(e, l);
956
+ else if (Le(o))
957
+ Ne(e, o, l);
958
+ else if (T(l))
959
+ xe(e, o, l);
851
960
  else {
852
- const c = e.liveProps.get(s);
853
- c && (c.unsubscribe(), e.liveProps.delete(s));
854
- const d = (c == null ? void 0 : c.value) ?? a;
855
- Object.is(d, l) || v(e.node, s, d, l);
961
+ const u = e.liveProps.get(o);
962
+ u && (u.unsubscribe(), e.liveProps.delete(o));
963
+ const d = (u == null ? void 0 : u.value) ?? a;
964
+ Object.is(d, l) || w(e.node, o, d, l);
856
965
  }
857
966
  }
858
- e.props = { ...r };
967
+ e.props = { ...n };
859
968
  }
860
- function Re(e, t, n) {
861
- const r = e.liveProps.get(t);
862
- if ((r == null ? void 0 : r.source) === n.emitter) return;
863
- r == null || r.unsubscribe();
864
- const i = n.emitter.get();
865
- v(e.node, t, (r == null ? void 0 : r.value) ?? e.props[t], i);
866
- const o = {
867
- source: n.emitter,
969
+ function xe(e, t, r) {
970
+ const n = e.liveProps.get(t);
971
+ if ((n == null ? void 0 : n.source) === r.emitter) return;
972
+ n == null || n.unsubscribe();
973
+ const i = r.emitter.get();
974
+ w(e.node, t, (n == null ? void 0 : n.value) ?? e.props[t], i);
975
+ const s = {
976
+ source: r.emitter,
868
977
  value: i,
869
978
  unsubscribe: () => {
870
979
  }
871
980
  };
872
- o.unsubscribe = n.emitter.subscribe(({ value: s }) => {
873
- const a = o.value;
874
- o.value = s, Object.is(a, s) || v(e.node, t, a, s);
875
- }, { emitCurrent: !1 }), e.liveProps.set(t, o);
876
- }
877
- function ke(e, t, n) {
878
- const r = t.slice(5), i = e.nativeBindings.get(t);
879
- if (n == null) {
880
- i && (i.unsubscribe(), e.node.removeEventListener(i.eventName, i.listener), e.nativeBindings.delete(t), v(e.node, r, i.value, void 0));
981
+ s.unsubscribe = r.emitter.subscribe(({ value: o }) => {
982
+ const a = s.value;
983
+ s.value = o, Object.is(a, o) || w(e.node, t, a, o);
984
+ }, { emitCurrent: !1 }), e.liveProps.set(t, s);
985
+ }
986
+ function $e(e, t, r) {
987
+ const n = t.slice(5), i = e.nativeBindings.get(t);
988
+ if (r == null) {
989
+ i && (i.unsubscribe(), e.node.removeEventListener(i.eventName, i.listener), e.nativeBindings.delete(t), w(e.node, n, i.value, void 0));
881
990
  return;
882
991
  }
883
- if (Ne(n, t), (i == null ? void 0 : i.source) === n) return;
884
- i && (i.unsubscribe(), e.node.removeEventListener(i.eventName, i.listener)), Fe(e.node, r);
885
- const o = $e(e.node, r), s = n.get();
886
- v(e.node, r, i == null ? void 0 : i.value, s);
992
+ if (qe(r, t), (i == null ? void 0 : i.source) === r) return;
993
+ i && (i.unsubscribe(), e.node.removeEventListener(i.eventName, i.listener)), Ve(e.node, n);
994
+ const s = He(e.node, n), o = r.get();
995
+ w(e.node, n, i == null ? void 0 : i.value, o);
887
996
  const a = () => {
888
- n.set(Reflect.get(e.node, r), `${t} changed`);
997
+ r.set(Reflect.get(e.node, n), `${t} changed`);
889
998
  }, l = {
890
- source: n,
891
- value: s,
892
- eventName: o,
999
+ source: r,
1000
+ value: o,
1001
+ eventName: s,
893
1002
  listener: a,
894
1003
  unsubscribe: () => {
895
1004
  }
896
1005
  };
897
- l.unsubscribe = n.subscribe(({ value: c }) => {
1006
+ l.unsubscribe = r.subscribe(({ value: u }) => {
898
1007
  const d = l.value;
899
- l.value = c, Object.is(d, c) || v(e.node, r, d, c);
900
- }, { emitCurrent: !1 }), e.node.addEventListener(o, a), e.nativeBindings.set(t, l);
1008
+ l.value = u, Object.is(d, u) || w(e.node, n, d, u);
1009
+ }, { emitCurrent: !1 }), e.node.addEventListener(s, a), e.nativeBindings.set(t, l);
901
1010
  }
902
- function je(e, t, n) {
903
- const r = t.slice(2).toLowerCase(), i = e.listeners.get(t);
904
- if (i && i !== n && (e.node.removeEventListener(r, i), e.listeners.delete(t)), n != null && typeof n != "function")
1011
+ function Ne(e, t, r) {
1012
+ const n = t.slice(2).toLowerCase(), i = e.listeners.get(t);
1013
+ if (i && i !== r && (e.node.removeEventListener(n, i), e.listeners.delete(t)), r != null && typeof r != "function")
905
1014
  throw new TypeError(`${t} must be a function or null`);
906
- if (typeof n == "function" && i !== n) {
907
- const o = n;
908
- e.node.addEventListener(r, o), e.listeners.set(t, o);
1015
+ if (typeof r == "function" && i !== r) {
1016
+ const s = r;
1017
+ e.node.addEventListener(n, s), e.listeners.set(t, s);
909
1018
  }
910
1019
  }
911
- function Ce(e, t) {
1020
+ function Fe(e, t) {
912
1021
  if (B(e.ref, null), t != null && typeof t != "function" && typeof t != "object")
913
1022
  throw new TypeError("ref must be a function, object, or null");
914
1023
  e.ref = t, B(e.ref, e.node);
915
1024
  }
916
- function v(e, t, n, r) {
1025
+ function w(e, t, r, n) {
917
1026
  if (t === "class" || t === "className") {
918
- F(e, "class", r);
1027
+ N(e, "class", n);
919
1028
  return;
920
1029
  }
921
1030
  if (t === "for" || t === "htmlFor") {
922
- F(e, "for", r);
1031
+ N(e, "for", n);
923
1032
  return;
924
1033
  }
925
1034
  if (t === "dataset") {
926
- Te(e, n, r);
1035
+ ze(e, r, n);
927
1036
  return;
928
1037
  }
929
1038
  if (t === "style") {
930
- Pe(e, n, r);
1039
+ _e(e, r, n);
931
1040
  return;
932
1041
  }
933
1042
  if (t === "dangerouslySetInnerHTML")
934
1043
  throw new Error("dangerouslySetInnerHTML is not supported");
935
- const i = Ae(t);
936
- if (ge.has(i)) {
937
- const o = !!r;
938
- i in e && Reflect.set(e, i, o), e.toggleAttribute($(t), o);
1044
+ const i = Be(t);
1045
+ if (ke.has(i)) {
1046
+ const s = !!n;
1047
+ i in e && Reflect.set(e, i, s), e.toggleAttribute(F(t), s);
939
1048
  return;
940
1049
  }
941
- if (we.has(i) && i in e) {
942
- const o = r ?? (i === "value" ? "" : !1);
943
- Object.is(Reflect.get(e, i), o) || Reflect.set(e, i, o), r == null && e.removeAttribute($(t));
1050
+ if (Ce.has(i) && i in e) {
1051
+ const s = n ?? (i === "value" ? "" : !1);
1052
+ Object.is(Reflect.get(e, i), s) || Reflect.set(e, i, s), n == null && e.removeAttribute(F(t));
944
1053
  return;
945
1054
  }
946
- F(e, $(t), r);
1055
+ N(e, F(t), n);
947
1056
  }
948
- function Te(e, t, n) {
949
- const r = x(t, "dataset"), i = x(n, "dataset");
950
- for (const o of /* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(i)])) {
951
- const s = i[o];
952
- s == null ? delete e.dataset[o] : e.dataset[o] = String(s);
1057
+ function ze(e, t, r) {
1058
+ const n = x(t, "dataset"), i = x(r, "dataset");
1059
+ for (const s of /* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(i)])) {
1060
+ const o = i[s];
1061
+ o == null ? delete e.dataset[s] : e.dataset[s] = String(o);
953
1062
  }
954
1063
  }
955
- function Pe(e, t, n) {
956
- if (typeof n == "string") {
957
- e.style.cssText = n;
1064
+ function _e(e, t, r) {
1065
+ if (typeof r == "string") {
1066
+ e.style.cssText = r;
958
1067
  return;
959
1068
  }
960
- const r = typeof t == "string" ? {} : x(t, "style"), i = x(n, "style");
1069
+ const n = typeof t == "string" ? {} : x(t, "style"), i = x(r, "style");
961
1070
  typeof t == "string" && (e.style.cssText = "");
962
- for (const o of /* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(i)])) {
963
- const s = i[o];
964
- o.startsWith("--") ? s == null ? e.style.removeProperty(o) : e.style.setProperty(o, String(s)) : Reflect.set(e.style, o, s == null ? "" : String(s));
1071
+ for (const s of /* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(i)])) {
1072
+ const o = i[s];
1073
+ s.startsWith("--") ? o == null ? e.style.removeProperty(s) : e.style.setProperty(s, String(o)) : Reflect.set(e.style, s, o == null ? "" : String(o));
965
1074
  }
966
1075
  }
967
1076
  function x(e, t) {
@@ -970,16 +1079,16 @@ function x(e, t) {
970
1079
  throw new TypeError(`${t} must be an object or null`);
971
1080
  return e;
972
1081
  }
973
- function F(e, t, n) {
974
- n == null || n === !1 ? e.removeAttribute(t) : n === !0 ? e.setAttribute(t, "") : e.setAttribute(t, String(n));
1082
+ function N(e, t, r) {
1083
+ r == null || r === !1 ? e.removeAttribute(t) : r === !0 ? e.setAttribute(t, "") : e.setAttribute(t, String(r));
975
1084
  }
976
- function Ae(e) {
1085
+ function Be(e) {
977
1086
  return e === "readonly" ? "readOnly" : e === "autofocus" ? "autoFocus" : e;
978
1087
  }
979
- function $(e) {
980
- return e === "className" ? "class" : e === "htmlFor" ? "for" : /^aria[A-Z]/.test(e) || /^data[A-Z]/.test(e) ? Y(e) : e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
1088
+ function F(e) {
1089
+ return e === "className" ? "class" : e === "htmlFor" ? "for" : /^aria[A-Z]/.test(e) || /^data[A-Z]/.test(e) ? G(e) : e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
981
1090
  }
982
- function Y(e) {
1091
+ function G(e) {
983
1092
  return e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
984
1093
  }
985
1094
  function B(e, t) {
@@ -988,156 +1097,160 @@ function B(e, t) {
988
1097
  function g(e, t) {
989
1098
  if (e.kind === "emitter") {
990
1099
  if (e.unsubscribe(), g(e.child, !1), t)
991
- for (const n of w(e)) n.remove();
1100
+ for (const r of v(e)) r.remove();
992
1101
  return;
993
1102
  }
994
1103
  if (e.kind === "component") {
995
- for (const n of e.liveProps.values()) n.unsubscribe();
1104
+ for (const r of e.liveProps.values()) r.unsubscribe();
996
1105
  e.liveProps.clear(), e.owner._childComponents.delete(e.instance), e.instance.destroy();
997
1106
  return;
998
1107
  }
999
1108
  if (e.kind === "function") {
1000
- for (const n of e.liveProps.values()) n.unsubscribe();
1109
+ for (const r of e.liveProps.values()) r.unsubscribe();
1001
1110
  e.liveProps.clear(), g(e.child, t);
1002
1111
  return;
1003
1112
  }
1004
1113
  if (e.kind === "element") {
1005
1114
  B(e.ref, null);
1006
- for (const [n, r] of e.listeners)
1007
- e.node.removeEventListener(n.slice(2).toLowerCase(), r);
1115
+ for (const [r, n] of e.listeners)
1116
+ e.node.removeEventListener(r.slice(2).toLowerCase(), n);
1008
1117
  e.listeners.clear();
1009
- for (const n of e.liveProps.values()) n.unsubscribe();
1118
+ for (const r of e.liveProps.values()) r.unsubscribe();
1010
1119
  e.liveProps.clear();
1011
- for (const n of e.nativeBindings.values())
1012
- n.unsubscribe(), e.node.removeEventListener(n.eventName, n.listener);
1120
+ for (const r of e.nativeBindings.values())
1121
+ r.unsubscribe(), e.node.removeEventListener(r.eventName, r.listener);
1013
1122
  e.nativeBindings.clear();
1014
- for (const n of e.children) g(n, !1);
1123
+ for (const r of e.children) g(r, !1);
1015
1124
  t && e.node.remove();
1016
1125
  return;
1017
1126
  }
1018
1127
  if (e.kind === "fragment") {
1019
- for (const n of e.children) g(n, !1);
1128
+ for (const r of e.children) g(r, !1);
1020
1129
  if (t)
1021
- for (const n of w(e)) n.remove();
1130
+ for (const r of v(e)) r.remove();
1022
1131
  return;
1023
1132
  }
1024
1133
  t && e.node.remove();
1025
1134
  }
1026
- function q(e, t, n = null) {
1135
+ function H(e, t, r = null) {
1027
1136
  if (t != null)
1028
- for (const r of w(t)) e.insertBefore(r, n);
1137
+ for (const n of v(t)) e.insertBefore(n, r);
1029
1138
  }
1030
- function w(e) {
1139
+ function v(e) {
1031
1140
  if (e == null) return [];
1032
1141
  if (e.kind === "text" || e.kind === "element") return [e.node];
1033
- if (e.kind === "component") return w(e.instance._rendered);
1034
- if (e.kind === "function") return w(e.child);
1142
+ if (e.kind === "component") return v(e.instance._rendered);
1143
+ if (e.kind === "function") return v(e.child);
1035
1144
  const t = [];
1036
- let n = e.start;
1037
- for (; n && (t.push(n), n !== e.end); )
1038
- n = n.nextSibling;
1145
+ let r = e.start;
1146
+ for (; r && (t.push(r), r !== e.end); )
1147
+ r = r.nextSibling;
1039
1148
  return t;
1040
1149
  }
1041
- function re(e) {
1042
- return w(e)[0] ?? null;
1150
+ function ae(e) {
1151
+ return v(e)[0] ?? null;
1043
1152
  }
1044
1153
  function E(e) {
1045
- return e instanceof h ? ie(e.props) : y(e) ? e.key : null;
1154
+ return e instanceof b ? ce(e.props) : y(e) ? e.key : null;
1046
1155
  }
1047
- function ie(e) {
1156
+ function ce(e) {
1048
1157
  const t = e.key;
1049
1158
  return typeof t == "string" || typeof t == "number" ? t : null;
1050
1159
  }
1051
- function oe(e, t) {
1052
- return e.kind === "text" ? typeof t == "string" || typeof t == "number" : e.kind === "emitter" ? N(t) && e.source === t : e.kind === "component" ? t instanceof h ? e.instance === t : y(t) && se(t.type) && e.type === t.type && e.key === E(t) : e.kind === "function" ? y(t) && e.type === t.type && e.key === E(t) : e.kind === "fragment" ? y(t) && t.type === P && e.key === E(t) : y(t) && typeof t.type == "string" && e.type === t.type && e.key === E(t);
1160
+ function le(e, t) {
1161
+ return e.kind === "text" ? typeof t == "string" || typeof t == "number" : e.kind === "emitter" ? $(t) && e.source === t : e.kind === "component" ? t instanceof b ? e.instance === t : y(t) && ue(t.type) && e.type === t.type && e.key === E(t) : e.kind === "function" ? y(t) && e.type === t.type && e.key === E(t) : e.kind === "fragment" ? y(t) && t.type === P && e.key === E(t) : y(t) && typeof t.type == "string" && e.type === t.type && e.key === E(t);
1053
1162
  }
1054
1163
  function y(e) {
1055
1164
  return e != null && typeof e == "object" && Object.hasOwn(e, "type");
1056
1165
  }
1057
- function se(e) {
1058
- return typeof e == "function" && (e === h || e.prototype instanceof h);
1166
+ function ue(e) {
1167
+ return typeof e == "function" && (e === b || e.prototype instanceof b);
1059
1168
  }
1060
- function Oe(e) {
1169
+ function Le(e) {
1061
1170
  return /^on[A-Z]/.test(e);
1062
1171
  }
1063
- function xe(e) {
1172
+ function Me(e) {
1064
1173
  return e === "bind:value" || e === "bind:checked";
1065
1174
  }
1066
- function j(e) {
1067
- return e != null && typeof e == "object" && Q.has(e);
1175
+ function T(e) {
1176
+ return e != null && typeof e == "object" && re.has(e);
1068
1177
  }
1069
- function N(e) {
1178
+ function $(e) {
1070
1179
  return (typeof e != "object" || e == null) && typeof e != "function" ? !1 : typeof Reflect.get(e, "get") == "function" && typeof Reflect.get(e, "getFetchState") == "function" && typeof Reflect.get(e, "getError") == "function" && typeof Reflect.get(e, "subscribe") == "function";
1071
1180
  }
1072
- function H(e, t) {
1073
- if (!N(e)) throw new TypeError(`${t} requires a readable emitter`);
1181
+ function I(e, t) {
1182
+ if (!$(e)) throw new TypeError(`${t} requires a readable emitter`);
1074
1183
  }
1075
- function Ne(e, t) {
1076
- if (H(e, t), typeof Reflect.get(e, "set") != "function")
1184
+ function qe(e, t) {
1185
+ if (I(e, t), typeof Reflect.get(e, "set") != "function")
1077
1186
  throw new TypeError(`${t} requires a writable emitter`);
1078
1187
  }
1079
- function Fe(e, t) {
1080
- const n = e.localName;
1081
- if (!(t === "checked" ? n === "input" : n === "input" || n === "textarea" || n === "select")) throw new TypeError(`bind:${t} is not supported on ${n}`);
1188
+ function Ve(e, t) {
1189
+ const r = e.localName;
1190
+ if (!(t === "checked" ? r === "input" : r === "input" || r === "textarea" || r === "select")) throw new TypeError(`bind:${t} is not supported on ${r}`);
1082
1191
  }
1083
- function $e(e, t) {
1192
+ function He(e, t) {
1084
1193
  return t === "value" && e.localName !== "select" ? "input" : "change";
1085
1194
  }
1086
- function ze(e) {
1195
+ function Ie(e) {
1087
1196
  if (e == null || typeof e != "object" && typeof e != "function" || typeof Reflect.get(e, "insertBefore") != "function")
1088
1197
  throw new TypeError("Component parent must be a DOM ParentNode");
1089
1198
  }
1090
- function G(e) {
1199
+ function J(e) {
1091
1200
  try {
1092
1201
  return String(e);
1093
1202
  } catch {
1094
1203
  return Object.prototype.toString.call(e);
1095
1204
  }
1096
1205
  }
1097
- function Be(e) {
1206
+ function De(e) {
1098
1207
  if (e == null) return [];
1099
1208
  if (Array.isArray(e))
1100
1209
  return e.map((t) => {
1101
1210
  if (!Array.isArray(t) || t.length < 2 || typeof t[0] != "string")
1102
1211
  throw new TypeError("Component baseStyles entries must be selector/style tuples");
1103
- const n = t[1];
1104
- if (typeof n != "string" && (!Array.isArray(n) || n.some((r) => typeof r != "string")))
1212
+ const r = t[1];
1213
+ if (typeof r != "string" && (!Array.isArray(r) || r.some((n) => typeof n != "string")))
1105
1214
  throw new TypeError("Component base style names must be strings");
1106
- return [t[0], n];
1215
+ return [t[0], r];
1107
1216
  });
1108
1217
  if (typeof e != "object")
1109
1218
  throw new TypeError("Component baseStyles must be an object or tuple array");
1110
- return Object.entries(e).map(([t, n]) => [
1219
+ return Object.entries(e).map(([t, r]) => [
1111
1220
  t,
1112
- n
1221
+ r
1113
1222
  ]);
1114
1223
  }
1115
- function ae(e, t, n) {
1116
- const r = t == null ? {} : { ...t };
1117
- return n !== void 0 && (r.key = n), A(e, r);
1224
+ function fe(e, t, r) {
1225
+ const n = t == null ? {} : { ...t };
1226
+ return r !== void 0 && (n.key = r), A(e, n);
1118
1227
  }
1119
- const qe = ae, He = ae;
1120
- function Ie(e) {
1121
- if (!(e instanceof h))
1228
+ const Je = fe, Qe = fe;
1229
+ function Xe(e) {
1230
+ if (!(e instanceof b))
1122
1231
  throw new TypeError("createPrebuiltElement requires a Component instance");
1123
1232
  return e;
1124
1233
  }
1125
1234
  export {
1126
- h as C,
1235
+ b as C,
1127
1236
  P as F,
1128
- J as S,
1129
- qe as a,
1237
+ te as S,
1238
+ Je as a,
1130
1239
  L as b,
1131
- Ve as c,
1132
- _e as d,
1133
- de as e,
1134
- Z as f,
1135
- He as g,
1136
- A as h,
1240
+ Ge as c,
1241
+ Q as d,
1242
+ Ze as e,
1243
+ Se as f,
1244
+ ye as g,
1245
+ W as h,
1137
1246
  y as i,
1138
- ae as j,
1139
- Ie as k,
1140
- Me as l,
1141
- pe as s
1247
+ fe as j,
1248
+ Ue as k,
1249
+ A as l,
1250
+ Qe as m,
1251
+ Ye as n,
1252
+ Xe as o,
1253
+ We as p,
1254
+ me as s
1142
1255
  };
1143
- //# sourceMappingURL=jsx-dev-runtime-DukiDpV9.js.map
1256
+ //# sourceMappingURL=jsx-dev-runtime-pzseD2Sz.js.map