@melodicdev/components 1.6.10 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/assets/melodic-components.css +1 -1
  2. package/assets/melodic-components.js +474 -326
  3. package/assets/melodic-components.js.map +1 -1
  4. package/assets/melodic-components.min.css +1 -1
  5. package/assets/melodic-components.min.js +2094 -1974
  6. package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
  7. package/lib/components/data-display/data-grid/data-grid.component.js +15 -0
  8. package/lib/components/data-display/table/table.component.d.ts +6 -3
  9. package/lib/components/data-display/table/table.component.d.ts.map +1 -1
  10. package/lib/components/data-display/table/table.component.js +7 -17
  11. package/lib/components/data-display/table/table.template.js +1 -1
  12. package/lib/components/forms/radio/radio-group.component.d.ts +2 -0
  13. package/lib/components/forms/radio/radio-group.component.d.ts.map +1 -1
  14. package/lib/components/forms/radio/radio-group.component.js +10 -1
  15. package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts +1 -0
  16. package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts.map +1 -1
  17. package/lib/components/forms/radio-card-group/radio-card-group.component.js +7 -0
  18. package/lib/components/overlays/dialog/dialog.component.d.ts.map +1 -1
  19. package/lib/components/overlays/dialog/dialog.component.js +6 -1
  20. package/lib/components/overlays/dialog/dialog.service.d.ts +9 -1
  21. package/lib/components/overlays/dialog/dialog.service.d.ts.map +1 -1
  22. package/lib/components/overlays/dialog/dialog.service.js +16 -1
  23. package/lib/components/overlays/dropdown/dropdown.component.d.ts +1 -0
  24. package/lib/components/overlays/dropdown/dropdown.component.d.ts.map +1 -1
  25. package/lib/components/overlays/dropdown/dropdown.component.js +13 -0
  26. package/lib/components/overlays/popover/popover.component.d.ts +1 -0
  27. package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
  28. package/lib/components/overlays/popover/popover.component.js +11 -0
  29. package/lib/components/overlays/tooltip/tooltip.styles.d.ts.map +1 -1
  30. package/lib/components/overlays/tooltip/tooltip.styles.js +4 -2
  31. package/lib/theme/functions/apply-theme.function.d.ts.map +1 -1
  32. package/lib/theme/functions/apply-theme.function.js +8 -0
  33. package/lib/theme/functions/create-theme.function.d.ts +3 -2
  34. package/lib/theme/functions/create-theme.function.d.ts.map +1 -1
  35. package/lib/theme/functions/create-theme.function.js +22 -7
  36. package/lib/theme/presets/dark.preset.js +1 -1
  37. package/lib/utils/virtual-scroll/index.d.ts.map +1 -1
  38. package/lib/utils/virtual-scroll/index.js +10 -9
  39. package/package.json +2 -2
@@ -1,7 +1,8 @@
1
- const getTokenKey = (token) => {
2
- if (typeof token === "string") return token;
3
- if (typeof token === "symbol") return token.toString();
4
- return token.name;
1
+ const getTokenKey = (token) => token;
2
+ const describeToken = (key) => {
3
+ if (typeof key === "string") return key;
4
+ if (typeof key === "symbol") return key.toString();
5
+ return key.name || "AnonymousToken";
5
6
  };
6
7
  function Inject(token) {
7
8
  return function(target, _, index) {
@@ -82,6 +83,22 @@ var Binding = class {
82
83
  return this;
83
84
  }
84
85
  };
86
+ function resolveInjectedParams(target, resolve) {
87
+ const paramTokens = target?.params;
88
+ const dependencies = [];
89
+ if (!Array.isArray(paramTokens)) return dependencies;
90
+ for (let i = 0; i < paramTokens.length; i++) {
91
+ const param = paramTokens[i];
92
+ if (param && typeof param === "object" && param.__injectionToken !== void 0) dependencies.push(resolve(param.__injectionToken));
93
+ else dependencies.push(void 0);
94
+ }
95
+ return dependencies;
96
+ }
97
+ var activeComponent = null;
98
+ const setActiveComponent = (component) => {
99
+ activeComponent = component;
100
+ };
101
+ const getActiveComponent = () => activeComponent;
85
102
  var InjectionEngine = class {
86
103
  constructor() {
87
104
  this._bindings = /* @__PURE__ */ new Map();
@@ -128,7 +145,7 @@ var InjectionEngine = class {
128
145
  get(token) {
129
146
  const key = getTokenKey(token);
130
147
  const binding = this._bindings.get(key);
131
- if (!binding) throw new Error(`Dependency could not be found: ${key}`);
148
+ if (!binding) throw new Error(`Dependency could not be found: ${describeToken(key)}`);
132
149
  return this.resolve(binding, key);
133
150
  }
134
151
  has(token) {
@@ -151,7 +168,7 @@ var InjectionEngine = class {
151
168
  const existing = binding.getInstance();
152
169
  if (existing !== void 0 && binding.isSingleton) return existing;
153
170
  if (this._constructionStack.has(key)) {
154
- const chain = Array.from(this._constructionStack).join(" -> ") + ` -> ${key}`;
171
+ const chain = [...this._constructionStack, key].map(describeToken).join(" -> ");
155
172
  throw new Error(`Circular dependency detected: ${chain}`);
156
173
  }
157
174
  this._constructionStack.add(key);
@@ -168,23 +185,22 @@ var InjectionEngine = class {
168
185
  construct(binding, currentToken) {
169
186
  const cls = binding.targetClass;
170
187
  let dependencies = [];
171
- const paramTokens = cls.params;
172
- if (paramTokens && Array.isArray(paramTokens)) for (let i = 0; i < paramTokens.length; i++) {
173
- const param = paramTokens[i];
174
- if (param && typeof param === "object" && param.__injectionToken) {
175
- const depKey = param.__injectionToken;
176
- const depBinding = this._bindings.get(depKey);
177
- if (!depBinding) throw new Error(`Dependency '${depKey}' not found (required by '${currentToken}')`);
178
- dependencies.push(this.resolve(depBinding, depKey));
179
- } else dependencies.push(void 0);
180
- }
181
- else if (binding.dependencies.length > 0) for (const depKey of binding.dependencies) {
188
+ const resolveDependency = (depKey) => {
182
189
  const depBinding = this._bindings.get(depKey);
183
- if (!depBinding) throw new Error(`Dependency '${depKey}' not found (required by '${currentToken}')`);
184
- dependencies.push(this.resolve(depBinding, depKey));
185
- }
190
+ if (!depBinding) throw new Error(`Dependency '${describeToken(depKey)}' not found (required by '${describeToken(currentToken)}')`);
191
+ return this.resolve(depBinding, depKey);
192
+ };
193
+ const paramTokens = cls.params;
194
+ if (Array.isArray(paramTokens) && paramTokens.length > 0) dependencies = resolveInjectedParams(cls, resolveDependency);
195
+ else if (binding.dependencies.length > 0) dependencies = binding.dependencies.map(resolveDependency);
186
196
  if (binding.args.length > 0) dependencies = dependencies.concat(binding.args);
187
- return Reflect.construct(cls, dependencies);
197
+ const prevActive = getActiveComponent();
198
+ setActiveComponent(null);
199
+ try {
200
+ return Reflect.construct(cls, dependencies);
201
+ } finally {
202
+ setActiveComponent(prevActive);
203
+ }
188
204
  }
189
205
  };
190
206
  const Injector = new InjectionEngine();
@@ -320,6 +336,51 @@ const setActiveEffect = (effect) => {
320
336
  activeEffect = effect;
321
337
  };
322
338
  const getActiveEffect = () => activeEffect;
339
+ var batchDepth = 0;
340
+ var flushing = false;
341
+ var pendingNotifications = /* @__PURE__ */ new Set();
342
+ var pendingEffects = /* @__PURE__ */ new Set();
343
+ function isBatching() {
344
+ return batchDepth > 0;
345
+ }
346
+ function isCoalescingEffects() {
347
+ return batchDepth > 0 || flushing;
348
+ }
349
+ function scheduleNotify(notify) {
350
+ pendingNotifications.add(notify);
351
+ }
352
+ function scheduleEffect(effect) {
353
+ pendingEffects.add(effect);
354
+ }
355
+ function flushBatch() {
356
+ flushing = true;
357
+ try {
358
+ while (pendingNotifications.size > 0 || pendingEffects.size > 0) {
359
+ if (pendingNotifications.size > 0) {
360
+ const notifications = [...pendingNotifications];
361
+ pendingNotifications.clear();
362
+ for (const notify of notifications) notify();
363
+ }
364
+ if (pendingEffects.size > 0) {
365
+ const effects = [...pendingEffects];
366
+ pendingEffects.clear();
367
+ for (const effect of effects) effect.runNow();
368
+ }
369
+ }
370
+ } finally {
371
+ flushing = false;
372
+ }
373
+ }
374
+ function batch(fn) {
375
+ batchDepth++;
376
+ try {
377
+ return fn();
378
+ } finally {
379
+ batchDepth--;
380
+ if (batchDepth === 0) flushBatch();
381
+ }
382
+ }
383
+ var MAX_EFFECT_ITERATIONS = 100;
323
384
  var SignalEffect = class {
324
385
  constructor(execute) {
325
386
  this.execute = execute;
@@ -327,25 +388,38 @@ var SignalEffect = class {
327
388
  this._isRunning = false;
328
389
  this._needsRerun = false;
329
390
  this.run = () => {
330
- if (this._isRunning) {
331
- this._needsRerun = true;
391
+ if (isCoalescingEffects()) {
392
+ scheduleEffect(this);
332
393
  return;
333
394
  }
334
- this._isRunning = true;
335
- do {
336
- this._needsRerun = false;
337
- this._dependencies.forEach((signal$1) => {
338
- signal$1.unsubscribe(this.run);
339
- });
340
- this._dependencies.clear();
341
- const prevEffect = getActiveEffect();
342
- setActiveEffect(this);
343
- this.execute();
344
- setActiveEffect(prevEffect);
345
- } while (this._needsRerun);
346
- this._isRunning = false;
395
+ this.runNow();
347
396
  };
348
397
  }
398
+ runNow() {
399
+ if (this._isRunning) {
400
+ this._needsRerun = true;
401
+ return;
402
+ }
403
+ this._isRunning = true;
404
+ let iterations = 0;
405
+ do {
406
+ if (++iterations > MAX_EFFECT_ITERATIONS) {
407
+ this._isRunning = false;
408
+ this._needsRerun = false;
409
+ throw new Error(`Circular dependency detected in effect: exceeded ${MAX_EFFECT_ITERATIONS} synchronous re-runs. An effect is repeatedly writing to a signal it also reads.`);
410
+ }
411
+ this._needsRerun = false;
412
+ this._dependencies.forEach((signal$1) => {
413
+ signal$1.unsubscribe(this.run);
414
+ });
415
+ this._dependencies.clear();
416
+ const prevEffect = getActiveEffect();
417
+ setActiveEffect(this);
418
+ this.execute();
419
+ setActiveEffect(prevEffect);
420
+ } while (this._needsRerun);
421
+ this._isRunning = false;
422
+ }
349
423
  addDependency(signal$1) {
350
424
  this._dependencies.add(signal$1);
351
425
  }
@@ -362,6 +436,10 @@ function signal(initialValue) {
362
436
  let destroyed = false;
363
437
  const subscribers = /* @__PURE__ */ new Set();
364
438
  const notify = () => {
439
+ if (isBatching()) {
440
+ scheduleNotify(notify);
441
+ return;
442
+ }
365
443
  [...subscribers].forEach((subscriber) => subscriber(value));
366
444
  };
367
445
  const read = (() => {
@@ -375,7 +453,7 @@ function signal(initialValue) {
375
453
  });
376
454
  read.set = (newValue) => {
377
455
  if (destroyed) throw new Error(DESTROYED_MESSAGE);
378
- if (value !== newValue) {
456
+ if (!Object.is(value, newValue)) {
379
457
  value = newValue;
380
458
  notify();
381
459
  }
@@ -415,6 +493,7 @@ function computed(computation) {
415
493
  effect.destroy();
416
494
  originalDestroy();
417
495
  };
496
+ getActiveComponent()?.registerDisposable(computedSignal);
418
497
  return computedSignal;
419
498
  }
420
499
  var globalMessages = {};
@@ -431,11 +510,6 @@ function resolveMessage(message, params) {
431
510
  if (typeof message === "function") return message(params ?? {});
432
511
  return message;
433
512
  }
434
- var activeComponent = null;
435
- const setActiveComponent = (component) => {
436
- activeComponent = component;
437
- };
438
- const getActiveComponent = () => activeComponent;
439
513
  var AbstractControl = class {
440
514
  constructor(initialValue, options = {}) {
441
515
  this.parent = null;
@@ -479,6 +553,12 @@ var AbstractControl = class {
479
553
  enabled: !this.disabled()
480
554
  }));
481
555
  }
556
+ get destroyed() {
557
+ return this._destroyed;
558
+ }
559
+ getRawValue() {
560
+ return this.value();
561
+ }
482
562
  markAsTouched() {
483
563
  this._touched.set(true);
484
564
  if (this.updateOn === "blur") this.runValidation();
@@ -560,6 +640,7 @@ var AbstractControl = class {
560
640
  }
561
641
  }
562
642
  async runValidation() {
643
+ const id = ++this._asyncValidationId;
563
644
  const value = this.value();
564
645
  let errors = null;
565
646
  for (const validator of this._validators) {
@@ -570,11 +651,11 @@ var AbstractControl = class {
570
651
  };
571
652
  }
572
653
  if (errors !== null) {
654
+ this._pending.set(false);
573
655
  this.errors.set(errors);
574
656
  return;
575
657
  }
576
658
  if (this._asyncValidators.length > 0) {
577
- const id = ++this._asyncValidationId;
578
659
  this._pending.set(true);
579
660
  try {
580
661
  const results = await Promise.all(this._asyncValidators.map((v) => v(value)));
@@ -587,7 +668,7 @@ var AbstractControl = class {
587
668
  if (id === this._asyncValidationId) this._pending.set(false);
588
669
  }
589
670
  }
590
- this.errors.set(errors);
671
+ if (id === this._asyncValidationId) this.errors.set(errors);
591
672
  }
592
673
  computeDirty() {
593
674
  return this._dirty();
@@ -629,6 +710,10 @@ var ComponentBase = class extends HTMLElement {
629
710
  this._unsubscribers = [];
630
711
  this._renderScheduled = false;
631
712
  this._booleanProperties = /* @__PURE__ */ new Set();
713
+ this._reactiveSources = [];
714
+ this._created = false;
715
+ this._destroyed = false;
716
+ this._teardownScheduled = false;
632
717
  this._meta = meta;
633
718
  this._component = component;
634
719
  this._component.elementRef = this;
@@ -649,21 +734,46 @@ var ComponentBase = class extends HTMLElement {
649
734
  getSelectCache() {
650
735
  return this._selectCache;
651
736
  }
652
- async connectedCallback() {
737
+ connectedCallback() {
738
+ this._teardownScheduled = false;
739
+ this.subscribeReactiveSources();
653
740
  this.render();
654
- if (this._component.onCreate !== void 0) {
655
- const prev = getActiveComponent();
656
- setActiveComponent(this);
657
- try {
658
- this._component.onCreate();
659
- } finally {
660
- setActiveComponent(prev);
741
+ const prev = getActiveComponent();
742
+ setActiveComponent(this);
743
+ try {
744
+ if (!this._created) {
745
+ this._created = true;
746
+ this._component.onCreate?.();
661
747
  }
748
+ this._component.onConnect?.();
749
+ } finally {
750
+ setActiveComponent(prev);
662
751
  }
663
752
  }
664
753
  disconnectedCallback() {
665
754
  this._unsubscribers.forEach((unsubscribe) => unsubscribe());
666
755
  this._unsubscribers = [];
756
+ this._component.onDisconnect?.();
757
+ if (!this._teardownScheduled && !this._destroyed) {
758
+ this._teardownScheduled = true;
759
+ queueMicrotask(() => {
760
+ this._teardownScheduled = false;
761
+ if (!this.isConnected && !this._destroyed) this.teardown();
762
+ });
763
+ }
764
+ }
765
+ attributeChangedCallback(attribute, oldVal, newVal) {
766
+ const prop = attribute.replace(/-([a-z])/g, (_, ch) => ch.toUpperCase());
767
+ if (this._component[prop] !== void 0) {
768
+ let value = newVal;
769
+ if (this._booleanProperties.has(prop)) value = newVal !== null && newVal !== "false";
770
+ this._component[prop] = value;
771
+ }
772
+ this.scheduleRender();
773
+ if (this._component.onAttributeChange !== void 0) this._component.onAttributeChange(attribute, oldVal, newVal);
774
+ }
775
+ teardown() {
776
+ this._destroyed = true;
667
777
  const parts = this._root.__parts;
668
778
  if (parts) {
669
779
  for (const part of parts) if (part.actionCleanup) try {
@@ -683,16 +793,6 @@ var ComponentBase = class extends HTMLElement {
683
793
  this._disposables.clear();
684
794
  this._selectCache.clear();
685
795
  }
686
- attributeChangedCallback(attribute, oldVal, newVal) {
687
- const prop = attribute.replace(/-([a-z])/g, (_, ch) => ch.toUpperCase());
688
- if (this._component[prop] !== void 0) {
689
- let value = newVal;
690
- if (this._booleanProperties.has(prop)) value = newVal !== null && newVal !== "false";
691
- this._component[prop] = value;
692
- }
693
- this.scheduleRender();
694
- if (this._component.onAttributeChange !== void 0) this._component.onAttributeChange(attribute, oldVal, newVal);
695
- }
696
796
  renderStyles() {
697
797
  const styleNode = document.createElement("style");
698
798
  if (this._meta.styles) render(this._meta.styles(), styleNode);
@@ -731,18 +831,21 @@ var ComponentBase = class extends HTMLElement {
731
831
  proto = Object.getPrototypeOf(proto);
732
832
  }
733
833
  const filtered = properties.filter((prop) => {
834
+ if (prop.startsWith("_") || prop === "elementRef" || prop === "constructor") return false;
835
+ const descriptor = this.getPropertyDescriptor(this._component, prop);
836
+ if (descriptor && descriptor.get && !descriptor.set) return false;
734
837
  const value = this._component[prop];
735
- if (prop.startsWith("_")) return false;
736
838
  if (isSignal(value)) {
737
- this.subscribeToSignal(value);
839
+ this._reactiveSources.push(value);
738
840
  return false;
739
841
  }
740
842
  if (value instanceof AbstractControl) {
741
- this.subscribeToSignal(value.state);
843
+ this._reactiveSources.push(value.value);
844
+ this._reactiveSources.push(value.state);
742
845
  return false;
743
846
  }
744
847
  if (typeof value === "function") return false;
745
- return prop !== "elementRef" && prop !== "constructor";
848
+ return true;
746
849
  });
747
850
  for (const prop of filtered) {
748
851
  const descriptor = this.getPropertyDescriptor(this._component, prop);
@@ -751,7 +854,7 @@ var ComponentBase = class extends HTMLElement {
751
854
  if (typeof value === "boolean") this._booleanProperties.add(prop);
752
855
  let componentGetter = () => value;
753
856
  let componentSetter = (newVal) => {
754
- if (value !== newVal) {
857
+ if (!Object.is(value, newVal)) {
755
858
  this._component.onPropertyChange?.(prop, value, newVal);
756
859
  value = newVal;
757
860
  this.scheduleRender();
@@ -759,7 +862,7 @@ var ComponentBase = class extends HTMLElement {
759
862
  };
760
863
  if (descriptor?.get) {
761
864
  const originalGetter = descriptor.get;
762
- componentGetter = () => originalGetter.call(this._component) ?? value;
865
+ componentGetter = () => originalGetter.call(this._component);
763
866
  }
764
867
  if (descriptor?.set) {
765
868
  const originalSetter = descriptor.set;
@@ -798,9 +901,9 @@ var ComponentBase = class extends HTMLElement {
798
901
  });
799
902
  return attributes;
800
903
  }
801
- subscribeToSignal(signal$1) {
802
- const unsubscriber = signal$1.subscribe(() => this.scheduleRender());
803
- this._unsubscribers.push(unsubscriber);
904
+ subscribeReactiveSources() {
905
+ if (this._destroyed) return;
906
+ for (const source of this._reactiveSources) this._unsubscribers.push(source.subscribe(() => this.scheduleRender()));
804
907
  }
805
908
  };
806
909
  function MelodicComponent(meta) {
@@ -808,13 +911,7 @@ function MelodicComponent(meta) {
808
911
  if (customElements.get(meta.selector) === void 0) {
809
912
  const webComponent = class extends ComponentBase {
810
913
  constructor() {
811
- const dependencies = [];
812
- const paramTokens = component.params;
813
- if (paramTokens && Array.isArray(paramTokens)) for (const i of paramTokens) {
814
- const param = paramTokens[i];
815
- if (param && typeof param === "object" && param.__injectionToken) dependencies.push(Injector.get(param.__injectionToken));
816
- else dependencies.push(void 0);
817
- }
914
+ const dependencies = resolveInjectedParams(component, (token) => Injector.get(token));
818
915
  const disposables = /* @__PURE__ */ new Set();
819
916
  const selectCache = /* @__PURE__ */ new Map();
820
917
  const placeholder = {
@@ -909,6 +1006,7 @@ var AbortError = class AbortError extends HttpBaseError {
909
1006
  var RequestManager = class {
910
1007
  constructor() {
911
1008
  this._pendingRequests = /* @__PURE__ */ new Map();
1009
+ this._opaqueCounter = 0;
912
1010
  }
913
1011
  generateRequestKey(method, url, body) {
914
1012
  let key = `${method}:${url}`;
@@ -951,11 +1049,9 @@ var RequestManager = class {
951
1049
  this._pendingRequests.delete(key);
952
1050
  }
953
1051
  hashBody(body) {
1052
+ if (body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof ReadableStream) return `opaque:${++this._opaqueCounter}`;
954
1053
  let str;
955
1054
  if (typeof body === "string") str = body;
956
- else if (body instanceof FormData) str = "[FormData]";
957
- else if (body instanceof Blob) str = `[Blob:${body.size}]`;
958
- else if (body instanceof ArrayBuffer) str = `[ArrayBuffer:${body.byteLength}]`;
959
1055
  else if (body instanceof URLSearchParams) str = body.toString();
960
1056
  else if (typeof body === "object" && body !== null) str = JSON.stringify(body);
961
1057
  else str = String(body);
@@ -1036,7 +1132,6 @@ var HttpClient = class {
1036
1132
  let requestConfig = this.mergeConfig(config);
1037
1133
  requestConfig = await this.executeRequestInterceptors(requestConfig);
1038
1134
  if (requestConfig.cancel?.cancelled) {
1039
- if (requestConfig.cancel.cancelReason) console.log("[HttpClient] Request cancelled:", requestConfig.cancel.cancelReason);
1040
1135
  let cancelledResponse = {
1041
1136
  data: null,
1042
1137
  status: 0,
@@ -1072,13 +1167,13 @@ var HttpClient = class {
1072
1167
  }
1073
1168
  async handleResponseError(error, originalConfig) {
1074
1169
  const retryCount = originalConfig._retryCount ?? 0;
1170
+ let retryInitiated = false;
1075
1171
  for (let i = 0; i < this._interceptors.response.length; i++) {
1076
1172
  const interceptor = this._interceptors.response[i];
1077
1173
  if (!interceptor.error) continue;
1078
- let retryCalled = false;
1079
1174
  const retry = async () => {
1080
- if (retryCalled) throw new Error("[HttpClient] retry() may only be called once per error handler invocation");
1081
- retryCalled = true;
1175
+ if (retryInitiated) throw new Error("[HttpClient] retry() may only be called once per error pass");
1176
+ retryInitiated = true;
1082
1177
  if (retryCount >= MAX_RETRIES) throw new Error(`[HttpClient] Max retries (${MAX_RETRIES}) exceeded`);
1083
1178
  return this.internalRequest({
1084
1179
  ...originalConfig,
@@ -1094,6 +1189,7 @@ var HttpClient = class {
1094
1189
  const result = await interceptor.error(error, context);
1095
1190
  if (this.isHttpResponse(result)) return this.executeResponseInterceptors(result, i + 1);
1096
1191
  } catch {}
1192
+ if (retryInitiated) break;
1097
1193
  }
1098
1194
  throw error;
1099
1195
  }
@@ -1111,6 +1207,13 @@ var HttpClient = class {
1111
1207
  const requestKey = this._requestManager.generateRequestKey(config.method, config.url, config.body);
1112
1208
  if (this._requestManager.hasPendingRequest(requestKey)) return this._requestManager.getPendingRequest(requestKey);
1113
1209
  }
1210
+ let timeoutId;
1211
+ if (config.timeout && config.timeout > 0 && config.abortController) {
1212
+ const controller = config.abortController;
1213
+ timeoutId = setTimeout(() => {
1214
+ controller.abort(new DOMException("Request timed out", "TimeoutError"));
1215
+ }, config.timeout);
1216
+ }
1114
1217
  const fetchPromise = fetch(config.url, {
1115
1218
  method: config.method,
1116
1219
  headers: config.headers,
@@ -1130,8 +1233,10 @@ var HttpClient = class {
1130
1233
  return httpResponse;
1131
1234
  }).catch((error) => {
1132
1235
  if (error instanceof HttpError) throw error;
1133
- if (error instanceof Error && error.name === "AbortError") throw new AbortError("Request aborted", config);
1236
+ if (error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError")) throw new AbortError(error.name === "TimeoutError" ? "Request timed out" : "Request aborted", config);
1134
1237
  throw new NetworkError((error instanceof Error ? error.message : "Network error") || "Network error", config);
1238
+ }).finally(() => {
1239
+ if (timeoutId !== void 0) clearTimeout(timeoutId);
1135
1240
  });
1136
1241
  if (config.deduplicate === true) this._requestManager.addPendingRequest(config, fetchPromise);
1137
1242
  return await fetchPromise;
@@ -1162,10 +1267,21 @@ var HttpClient = class {
1162
1267
  };
1163
1268
  }
1164
1269
  buildUrl(url, params) {
1165
- let fullUrl = `${this._clientConfig.baseURL || ""}${url}`;
1270
+ const baseUrl = this._clientConfig.baseURL || "";
1271
+ let fullUrl;
1272
+ if (!baseUrl || /^[a-z][a-z\d+\-.]*:\/\//i.test(url)) fullUrl = url;
1273
+ else fullUrl = `${baseUrl.replace(/\/+$/, "")}/${url.replace(/^\/+/, "")}`;
1166
1274
  if (params) {
1167
- const queryString = Object.entries(params).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`).join("&");
1168
- fullUrl += `${fullUrl.includes("?") ? "&" : "?"}${queryString}`;
1275
+ const pairs = [];
1276
+ for (const [key, value] of Object.entries(params)) {
1277
+ if (value === null || value === void 0) continue;
1278
+ const values = Array.isArray(value) ? value : [value];
1279
+ for (const v of values) {
1280
+ if (v === null || v === void 0) continue;
1281
+ pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(v))}`);
1282
+ }
1283
+ }
1284
+ if (pairs.length > 0) fullUrl += `${fullUrl.includes("?") ? "&" : "?"}${pairs.join("&")}`;
1169
1285
  }
1170
1286
  return fullUrl;
1171
1287
  }
@@ -1195,15 +1311,21 @@ var HttpClient = class {
1195
1311
  const blob = new Blob(chunks);
1196
1312
  if (contentType.includes("application/json")) {
1197
1313
  const text = await blob.text();
1198
- return JSON.parse(text);
1314
+ return text ? JSON.parse(text) : null;
1199
1315
  }
1200
1316
  return blob;
1201
1317
  }
1202
- if (contentType.includes("application/json")) return await response.json();
1318
+ if (contentType.includes("application/json")) {
1319
+ const text = await response.text();
1320
+ return text ? JSON.parse(text) : null;
1321
+ }
1203
1322
  if (contentType.includes("text/")) return await response.text();
1204
- if (contentType.includes("application/octet-stream") || contentType.includes("image/")) return await response.blob();
1323
+ if (this.isBinaryContentType(contentType)) return await response.blob();
1205
1324
  return await response.text();
1206
1325
  }
1326
+ isBinaryContentType(contentType) {
1327
+ return contentType.includes("application/octet-stream") || contentType.includes("application/pdf") || contentType.includes("application/zip") || contentType.startsWith("image/") || contentType.startsWith("audio/") || contentType.startsWith("video/") || contentType.startsWith("font/");
1328
+ }
1207
1329
  };
1208
1330
  function provideHttp(httpClientConfig, interceptors) {
1209
1331
  return (injector) => {
@@ -1228,21 +1350,48 @@ function createResolver(fn) {
1228
1350
  }
1229
1351
  var RouteMatcher = class {
1230
1352
  constructor(route, rules) {
1231
- this._reEscape = /[-[\]{}()+?.,\\^$|#\s]/g;
1353
+ this._reEscape = /[-[\]{}()+?.,\\^$|#\s*]/g;
1354
+ this._reToken = /(\*\*)|:(\w+)|\*(\w+)|(\*)/g;
1232
1355
  this._reParam = /([:*])(\w+)/g;
1233
1356
  this._names = [];
1234
1357
  this._isWildcard = false;
1235
1358
  this._route = route;
1236
1359
  this._rules = rules;
1237
1360
  this._isWildcard = route.includes("*");
1238
- let escapedRoute = this._route.replace(this._reEscape, "\\$&");
1239
- escapedRoute = escapedRoute.replace(this._reParam, (_, mode, name) => {
1240
- this._names.push(name);
1241
- return mode === ":" ? "([^/]*)" : "(.*)";
1242
- });
1361
+ const escapedRoute = this.buildPattern(route);
1243
1362
  this._routeRegex = /* @__PURE__ */ new RegExp("^" + escapedRoute + "$");
1244
1363
  this._prefixRegex = /* @__PURE__ */ new RegExp("^" + escapedRoute + "(?:/|$)");
1245
1364
  }
1365
+ buildPattern(route) {
1366
+ this._reToken.lastIndex = 0;
1367
+ let pattern = "";
1368
+ let lastIndex = 0;
1369
+ let anonCount = 0;
1370
+ let match;
1371
+ while ((match = this._reToken.exec(route)) !== null) {
1372
+ pattern += route.slice(lastIndex, match.index).replace(this._reEscape, "\\$&");
1373
+ if (match[1] || match[4]) {
1374
+ this._names.push(`_wildcard${anonCount++}`);
1375
+ pattern += "(.*)";
1376
+ } else if (match[2]) {
1377
+ this._names.push(match[2]);
1378
+ pattern += "([^/]*)";
1379
+ } else if (match[3]) {
1380
+ this._names.push(match[3]);
1381
+ pattern += "(.*)";
1382
+ }
1383
+ lastIndex = this._reToken.lastIndex;
1384
+ }
1385
+ pattern += route.slice(lastIndex).replace(this._reEscape, "\\$&");
1386
+ return pattern;
1387
+ }
1388
+ decode(value) {
1389
+ try {
1390
+ return decodeURIComponent(value);
1391
+ } catch {
1392
+ return value;
1393
+ }
1394
+ }
1246
1395
  parse(url) {
1247
1396
  let i = 0;
1248
1397
  let param;
@@ -1252,7 +1401,7 @@ var RouteMatcher = class {
1252
1401
  if (!matches) return null;
1253
1402
  while (i < this._names.length) {
1254
1403
  param = this._names[i++];
1255
- value = matches[i];
1404
+ value = this.decode(matches[i]);
1256
1405
  if (this._rules && param in this._rules && !this.validateRule(this._rules[param], value)) return null;
1257
1406
  params[param] = value;
1258
1407
  }
@@ -1269,7 +1418,7 @@ var RouteMatcher = class {
1269
1418
  const params = {};
1270
1419
  for (let i = 0; i < this._names.length; i++) {
1271
1420
  const name = this._names[i];
1272
- const value = matches[i + 1];
1421
+ const value = this.decode(matches[i + 1]);
1273
1422
  if (this._rules && name in this._rules && !this.validateRule(this._rules[name], value)) return null;
1274
1423
  params[name] = value;
1275
1424
  }
@@ -1287,7 +1436,7 @@ var RouteMatcher = class {
1287
1436
  re = /* @__PURE__ */ new RegExp("[:*]" + param + "\\b");
1288
1437
  result = result.replace(re, params[param]);
1289
1438
  }
1290
- return result.replace(this._reParam, "");
1439
+ return result.replace(this._reParam, "").replace(/\*+/g, "");
1291
1440
  }
1292
1441
  calculateMatchedPath(url) {
1293
1442
  if (this._isWildcard) return url;
@@ -1418,7 +1567,7 @@ function buildPathFromRoute(routes, name, params = {}) {
1418
1567
  }
1419
1568
  return false;
1420
1569
  }
1421
- if (findAndBuildPath(routes, name)) return "/" + pathParts.filter(Boolean).join("/");
1570
+ if (findAndBuildPath(routes, name)) return "/" + pathParts.join("/").split("/").filter(Boolean).join("/");
1422
1571
  return null;
1423
1572
  }
1424
1573
  function __decorate(decorators, target, key, desc) {
@@ -1556,6 +1705,8 @@ var RouterService = class RouterService$1 {
1556
1705
  this._currentMatches = [];
1557
1706
  this._resolversExecutedForPath = null;
1558
1707
  this._currentPath = `${window.location.pathname}${window.location.search}`;
1708
+ this._navigationId = 0;
1709
+ this._pendingTarget = null;
1559
1710
  this._contextService = new RouteContextService();
1560
1711
  window.addEventListener("NavigationEvent", (event) => {
1561
1712
  this._route = event.detail.state;
@@ -1583,7 +1734,7 @@ var RouterService = class RouterService$1 {
1583
1734
  return this._contextService.getCurrentParams()[name];
1584
1735
  }
1585
1736
  getQueryParams() {
1586
- return new URLSearchParams(window.location.search);
1737
+ return this.targetQueryParams();
1587
1738
  }
1588
1739
  getCurrentMatches() {
1589
1740
  return [...this._currentMatches];
@@ -1595,7 +1746,29 @@ var RouterService = class RouterService$1 {
1595
1746
  return this._contextService.getMergedResolvedData(depth);
1596
1747
  }
1597
1748
  matchPath(path) {
1598
- return matchRouteTree(this._routes, path);
1749
+ return matchRouteTree(this._routes, this.normalizePath(path));
1750
+ }
1751
+ parseUrl(url) {
1752
+ const hashIndex = url.indexOf("#");
1753
+ const hash = hashIndex >= 0 ? url.slice(hashIndex) : "";
1754
+ const withoutHash = hashIndex >= 0 ? url.slice(0, hashIndex) : url;
1755
+ const queryIndex = withoutHash.indexOf("?");
1756
+ const search = queryIndex >= 0 ? withoutHash.slice(queryIndex) : "";
1757
+ return {
1758
+ pathname: queryIndex >= 0 ? withoutHash.slice(0, queryIndex) : withoutHash,
1759
+ search,
1760
+ hash
1761
+ };
1762
+ }
1763
+ normalizePath(url) {
1764
+ const { pathname } = this.parseUrl(url);
1765
+ return pathname.length > 1 ? pathname.replace(/\/+$/, "") : pathname;
1766
+ }
1767
+ targetPathname() {
1768
+ return this._pendingTarget ? this._pendingTarget.pathname : window.location.pathname;
1769
+ }
1770
+ targetQueryParams() {
1771
+ return new URLSearchParams(this._pendingTarget ? this._pendingTarget.queryParams : window.location.search);
1599
1772
  }
1600
1773
  setCurrentMatches(result) {
1601
1774
  this._currentMatches = result.matches;
@@ -1615,60 +1788,74 @@ var RouterService = class RouterService$1 {
1615
1788
  const { data, replace = false, queryParams, skipGuards = false, skipResolvers = false, scrollToTop = true } = options;
1616
1789
  let fullPath = path;
1617
1790
  if (queryParams && Object.keys(queryParams).length > 0) fullPath = `${path}?${new URLSearchParams(queryParams).toString()}`;
1618
- if (!skipGuards && this._currentMatches.length > 0) {
1619
- const deactivateResult = await this.runDeactivationGuards(fullPath);
1620
- if (deactivateResult !== true) {
1621
- if (typeof deactivateResult === "string") return this.navigate(deactivateResult, {
1622
- ...options,
1623
- skipGuards: true
1624
- });
1625
- return {
1626
- success: false,
1627
- error: "Navigation blocked by guard"
1628
- };
1629
- }
1630
- }
1631
- const matchResult = this.matchPath(path);
1632
- if (matchResult.redirectTo) return this.navigate(matchResult.redirectTo, {
1633
- ...options,
1634
- replace: true
1791
+ const navId = ++this._navigationId;
1792
+ const { pathname, search } = this.parseUrl(fullPath);
1793
+ this._pendingTarget = {
1794
+ pathname,
1795
+ queryParams: new URLSearchParams(search)
1796
+ };
1797
+ const superseded = () => ({
1798
+ success: false,
1799
+ error: "Navigation superseded"
1635
1800
  });
1636
- if (!skipGuards && matchResult.matches.length > 0) {
1637
- const guardResult = await this.runGuards(matchResult);
1638
- if (guardResult !== true) {
1639
- if (typeof guardResult === "string") return this.navigate(guardResult, {
1640
- ...options,
1641
- skipGuards: true
1642
- });
1643
- return {
1801
+ try {
1802
+ if (!skipGuards && this._currentMatches.length > 0) {
1803
+ const deactivateResult = await this.runDeactivationGuards(fullPath);
1804
+ if (this._navigationId !== navId) return superseded();
1805
+ if (deactivateResult !== true) {
1806
+ if (typeof deactivateResult === "string") return this.navigate(deactivateResult, {
1807
+ ...options,
1808
+ skipGuards: true
1809
+ });
1810
+ return {
1811
+ success: false,
1812
+ error: "Navigation blocked by guard"
1813
+ };
1814
+ }
1815
+ }
1816
+ const matchResult = this.matchPath(path);
1817
+ if (matchResult.redirectTo) return this.navigate(matchResult.redirectTo, options);
1818
+ if (!skipGuards && matchResult.matches.length > 0) {
1819
+ const guardResult = await this.runGuards(matchResult);
1820
+ if (this._navigationId !== navId) return superseded();
1821
+ if (guardResult !== true) {
1822
+ if (typeof guardResult === "string") return this.navigate(guardResult, {
1823
+ ...options,
1824
+ skipGuards: true
1825
+ });
1826
+ return {
1827
+ success: false,
1828
+ error: "Navigation blocked by guard"
1829
+ };
1830
+ }
1831
+ }
1832
+ if (!skipResolvers && matchResult.matches.length > 0) {
1833
+ const resolverResult = await this.runResolversInternal(matchResult);
1834
+ if (this._navigationId !== navId) return superseded();
1835
+ if (!resolverResult.success) return {
1644
1836
  success: false,
1645
- error: "Navigation blocked by guard"
1837
+ error: resolverResult.error ?? "Navigation blocked by resolver"
1646
1838
  };
1839
+ this._resolversExecutedForPath = fullPath;
1647
1840
  }
1648
- }
1649
- if (!skipResolvers && matchResult.matches.length > 0) {
1650
- const resolverResult = await this.runResolversInternal(matchResult);
1651
- if (!resolverResult.success) return {
1652
- success: false,
1653
- error: resolverResult.error ?? "Navigation blocked by resolver"
1841
+ this.setCurrentMatches(matchResult);
1842
+ if (replace) history.replaceState(data, "", fullPath);
1843
+ else history.pushState(data, "", fullPath);
1844
+ this._currentPath = fullPath;
1845
+ if (scrollToTop) {
1846
+ const hash = fullPath.includes("#") ? fullPath.split("#")[1] : null;
1847
+ if (hash) {
1848
+ const element = document.getElementById(hash);
1849
+ if (element) element.scrollIntoView();
1850
+ } else window.scrollTo(0, 0);
1851
+ }
1852
+ return {
1853
+ success: true,
1854
+ url: fullPath
1654
1855
  };
1655
- this._resolversExecutedForPath = fullPath;
1656
- }
1657
- this.setCurrentMatches(matchResult);
1658
- if (replace) history.replaceState(data, "", fullPath);
1659
- else history.pushState(data, "", fullPath);
1660
- this._currentPath = fullPath;
1661
- if (scrollToTop) {
1662
- const hash = fullPath.includes("#") ? fullPath.split("#")[1] : null;
1663
- if (hash) {
1664
- const element = document.getElementById(hash);
1665
- if (element) element.scrollIntoView();
1666
- } else window.scrollTo(0, 0);
1856
+ } finally {
1857
+ if (this._navigationId === navId) this._pendingTarget = null;
1667
1858
  }
1668
- return {
1669
- success: true,
1670
- url: fullPath
1671
- };
1672
1859
  }
1673
1860
  async navigateByName(name, params = {}, options = {}) {
1674
1861
  const path = buildPathFromRoute(this._routes, name, params);
@@ -1734,8 +1921,8 @@ var RouterService = class RouterService$1 {
1734
1921
  route: match,
1735
1922
  matchedRoutes: matchResult.matches,
1736
1923
  params: matchResult.params,
1737
- queryParams: new URLSearchParams(window.location.search),
1738
- targetPath: window.location.pathname,
1924
+ queryParams: this.targetQueryParams(),
1925
+ targetPath: this.targetPathname(),
1739
1926
  currentPath: window.location.pathname,
1740
1927
  data: match.route.data
1741
1928
  };
@@ -1787,8 +1974,8 @@ var RouterService = class RouterService$1 {
1787
1974
  route: match,
1788
1975
  matchedRoutes: matchResult.matches,
1789
1976
  params: matchResult.params,
1790
- queryParams: new URLSearchParams(window.location.search),
1791
- targetPath: window.location.pathname
1977
+ queryParams: this.targetQueryParams(),
1978
+ targetPath: this.targetPathname()
1792
1979
  };
1793
1980
  }
1794
1981
  };
@@ -1815,7 +2002,7 @@ function getRegisteredDirectives() {
1815
2002
  return Array.from(directiveRegistry.keys());
1816
2003
  }
1817
2004
  function isDirective(value) {
1818
- return typeof value === "object" && value !== null && "__directive" in value;
2005
+ return typeof value === "object" && value !== null && value.__directive === true && typeof value.render === "function";
1819
2006
  }
1820
2007
  var MARKER = `m${Math.random().toString(36).slice(2, 9)}`;
1821
2008
  var COMMENT_NODE_MARKER = `<!--${MARKER}-->`;
@@ -2389,7 +2576,8 @@ var TemplateResult = class TemplateResult {
2389
2576
  else element.setAttribute(part.name, composed);
2390
2577
  part.previousValue = composed;
2391
2578
  continue;
2392
- } else if (value === null || value === void 0 || value === false) element.removeAttribute(part.name);
2579
+ } else if (typeof value === "boolean" && part.name.startsWith("aria-")) element.setAttribute(part.name, String(value));
2580
+ else if (value === null || value === void 0 || value === false) element.removeAttribute(part.name);
2393
2581
  else if (value === true) element.setAttribute(part.name, "");
2394
2582
  else element.setAttribute(part.name, String(value));
2395
2583
  }
@@ -2453,6 +2641,7 @@ var RouterOutletComponent = class RouterOutletComponent$1 {
2453
2641
  this._parentOutlet = null;
2454
2642
  this._initialized = false;
2455
2643
  this._navigationCleanup = null;
2644
+ this._renderToken = 0;
2456
2645
  this.routes = [];
2457
2646
  this.name = "primary";
2458
2647
  }
@@ -2563,6 +2752,7 @@ var RouterOutletComponent = class RouterOutletComponent$1 {
2563
2752
  if (this._depth === 0) this.matchAndRender(window.location.pathname);
2564
2753
  }
2565
2754
  async matchAndRender(fullPath) {
2755
+ const token = ++this._renderToken;
2566
2756
  const routes = this.routes.length > 0 ? this.routes : this._router.getRoutes();
2567
2757
  if (routes.length === 0) return;
2568
2758
  const matchResult = matchRouteTree(routes, fullPath);
@@ -2572,6 +2762,7 @@ var RouterOutletComponent = class RouterOutletComponent$1 {
2572
2762
  }
2573
2763
  if (matchResult.matches.length > 0) {
2574
2764
  const guardResult = await this._router.runGuards(matchResult);
2765
+ if (token !== this._renderToken) return;
2575
2766
  if (guardResult !== true) {
2576
2767
  if (typeof guardResult === "string") this._router.navigate(guardResult, {
2577
2768
  replace: true,
@@ -2582,6 +2773,7 @@ var RouterOutletComponent = class RouterOutletComponent$1 {
2582
2773
  }
2583
2774
  if (matchResult.matches.length > 0) {
2584
2775
  const resolverResult = await this._router.runResolvers(matchResult);
2776
+ if (token !== this._renderToken) return;
2585
2777
  if (!resolverResult.success) {
2586
2778
  console.error("Resolver failed:", resolverResult.error);
2587
2779
  await this.render404();
@@ -2685,6 +2877,7 @@ var RouterLinkComponent = class RouterLinkComponent$1 {
2685
2877
  constructor() {
2686
2878
  this._anchorElement = null;
2687
2879
  this._navigationCleanup = null;
2880
+ this._clickCleanup = null;
2688
2881
  this.href = "";
2689
2882
  this.data = null;
2690
2883
  this.queryParams = {};
@@ -2699,14 +2892,16 @@ var RouterLinkComponent = class RouterLinkComponent$1 {
2699
2892
  const initialActiveClass = this.elementRef.getAttribute("active-class");
2700
2893
  if (initialActiveClass) this.activeClass = initialActiveClass;
2701
2894
  this.updateAnchorHref();
2702
- this.elementRef.addEventListener("click", (e) => {
2895
+ const clickHandler = (e) => {
2703
2896
  e.preventDefault();
2704
2897
  if (e.ctrlKey || e.metaKey || e.shiftKey) {
2705
2898
  window.open(this.buildFullPath(), "_blank");
2706
2899
  return;
2707
2900
  }
2708
2901
  this.navigate();
2709
- }, false);
2902
+ };
2903
+ this.elementRef.addEventListener("click", clickHandler, false);
2904
+ this._clickCleanup = () => this.elementRef.removeEventListener("click", clickHandler, false);
2710
2905
  const handler = () => this.updateActiveState();
2711
2906
  window.addEventListener("NavigationEvent", handler);
2712
2907
  this._navigationCleanup = () => window.removeEventListener("NavigationEvent", handler);
@@ -2714,6 +2909,7 @@ var RouterLinkComponent = class RouterLinkComponent$1 {
2714
2909
  }
2715
2910
  onDestroy() {
2716
2911
  this._navigationCleanup?.();
2912
+ this._clickCleanup?.();
2717
2913
  }
2718
2914
  onAttributeChange(attribute, _, newVal) {
2719
2915
  if (attribute === "href") {
@@ -2951,6 +3147,8 @@ var ComponentStateBaseService = class extends EffectsBase {
2951
3147
  effect.effect(action).then((newAction) => {
2952
3148
  if (newAction === void 0) return;
2953
3149
  (Array.isArray(newAction) ? newAction : [newAction]).forEach((na) => this.dispatch(na));
3150
+ }).catch((error) => {
3151
+ console.error(`[ComponentState] Effect for action '${action.type}' failed:`, error);
2954
3152
  });
2955
3153
  });
2956
3154
  }
@@ -3002,6 +3200,8 @@ var SignalStoreService = class SignalStoreService$1 {
3002
3200
  newAction.forEach((na) => {
3003
3201
  this.dispatch(na);
3004
3202
  });
3203
+ }).catch((error) => {
3204
+ console.error(`[SignalStore] Effect for action '${action.type}' failed:`, error);
3005
3205
  });
3006
3206
  });
3007
3207
  }
@@ -3080,103 +3280,6 @@ function provideRX(initState, actionReducers, effects, debug = false) {
3080
3280
  ] });
3081
3281
  };
3082
3282
  }
3083
- var compiledCache = /* @__PURE__ */ new WeakMap();
3084
- var CompiledTemplate = class CompiledTemplate {
3085
- constructor(strings) {
3086
- this._factory = null;
3087
- this._hasEvents = false;
3088
- this._canCompile = false;
3089
- this.analyzeAndCompile(strings);
3090
- }
3091
- static compile(strings) {
3092
- let compiled = compiledCache.get(strings);
3093
- if (!compiled) {
3094
- compiled = new CompiledTemplate(strings);
3095
- compiledCache.set(strings, compiled);
3096
- }
3097
- return compiled;
3098
- }
3099
- canUseFastPath() {
3100
- return this._canCompile && !this._hasEvents;
3101
- }
3102
- create(values) {
3103
- if (this._factory) return {
3104
- nodes: [this._factory(values)],
3105
- eventTargets: []
3106
- };
3107
- return {
3108
- nodes: [],
3109
- eventTargets: []
3110
- };
3111
- }
3112
- createDirect(values) {
3113
- return this._factory ? this._factory(values) : null;
3114
- }
3115
- analyzeAndCompile(strings) {
3116
- if (strings.length < 2) return;
3117
- for (const s of strings) if (s.includes("@")) {
3118
- this._hasEvents = true;
3119
- return;
3120
- }
3121
- let html$1 = strings[0];
3122
- for (let i = 1; i < strings.length; i++) html$1 += `\${${i - 1}}` + strings[i];
3123
- const fullMatch = html$1.match(/^<([\w-]+)([^>]*)>(.*)$/s);
3124
- if (!fullMatch) return;
3125
- const [, tag, attrString, rest] = fullMatch;
3126
- const closingTag = `</${tag}>`;
3127
- if (!rest.endsWith(closingTag)) return;
3128
- const textContent = rest.slice(0, -closingTag.length);
3129
- const attrs = [];
3130
- const attrRegex = /([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|\$\{(\d+)\})/g;
3131
- let attrMatch;
3132
- while ((attrMatch = attrRegex.exec(attrString)) !== null) {
3133
- const name = attrMatch[1];
3134
- const staticVal = attrMatch[2] ?? attrMatch[3];
3135
- const dynamicIndex = attrMatch[4];
3136
- if (dynamicIndex !== void 0) attrs.push({
3137
- name,
3138
- valueIndex: parseInt(dynamicIndex, 10)
3139
- });
3140
- else if (staticVal !== void 0) {
3141
- const placeholderMatch = staticVal.match(/\$\{(\d+)\}/);
3142
- if (placeholderMatch) attrs.push({
3143
- name,
3144
- valueIndex: parseInt(placeholderMatch[1], 10)
3145
- });
3146
- else attrs.push({
3147
- name,
3148
- valueIndex: null,
3149
- staticValue: staticVal
3150
- });
3151
- }
3152
- }
3153
- const textParts = [];
3154
- const remaining = textContent;
3155
- const placeholderRegex = /\$\{(\d+)\}/g;
3156
- let lastIndex = 0;
3157
- let textMatch;
3158
- placeholderRegex.lastIndex = 0;
3159
- while ((textMatch = placeholderRegex.exec(remaining)) !== null) {
3160
- if (textMatch.index > lastIndex) textParts.push({ static: remaining.slice(lastIndex, textMatch.index) });
3161
- textParts.push({ valueIndex: parseInt(textMatch[1], 10) });
3162
- lastIndex = textMatch.index + textMatch[0].length;
3163
- }
3164
- if (lastIndex < remaining.length) textParts.push({ static: remaining.slice(lastIndex) });
3165
- this._factory = (values) => {
3166
- const el = document.createElement(tag);
3167
- for (const attr of attrs) if (attr.valueIndex !== null) {
3168
- const value = values[attr.valueIndex];
3169
- if (value !== null && value !== void 0 && value !== false) el.setAttribute(attr.name, value === true ? "" : String(value));
3170
- } else if (attr.staticValue !== void 0) el.setAttribute(attr.name, attr.staticValue);
3171
- let text = "";
3172
- for (const part of textParts) if ("static" in part) text += part.static;
3173
- else text += values[part.valueIndex] ?? "";
3174
- el.textContent = text;
3175
- return el;
3176
- };
3177
- this._canCompile = true;
3178
- }
3179
- };
3180
3283
  function directive(renderFn) {
3181
3284
  return {
3182
3285
  __directive: true,
@@ -3227,12 +3330,6 @@ function updateList$1(newItems, keyFn, template, state) {
3227
3330
  return;
3228
3331
  }
3229
3332
  }
3230
- if (state.useCompiledPath === void 0 && newItems.length > 0) {
3231
- const sampleTemplate = template(newItems[0], 0);
3232
- const compiled = CompiledTemplate.compile(sampleTemplate.strings);
3233
- state.useCompiledPath = compiled.canUseFastPath();
3234
- if (state.useCompiledPath) state.compiledTemplate = compiled;
3235
- }
3236
3333
  const oldItemsByKey = /* @__PURE__ */ new Map();
3237
3334
  const oldIndexByKey = /* @__PURE__ */ new Map();
3238
3335
  for (const oldItem of oldItems) {
@@ -3252,7 +3349,7 @@ function updateList$1(newItems, keyFn, template, state) {
3252
3349
  isNew: false
3253
3350
  });
3254
3351
  } else {
3255
- const repeatItem = createRepeatItem(item, i, key, template, state);
3352
+ const repeatItem = createRepeatItem(item, i, key, template);
3256
3353
  newEntries.push({
3257
3354
  item: repeatItem,
3258
3355
  oldIndex: -1,
@@ -3278,29 +3375,14 @@ function updateList$1(newItems, keyFn, template, state) {
3278
3375
  state.keyToIndex = newKeyToIndex;
3279
3376
  state.items = newEntries.map((entry) => entry.item);
3280
3377
  }
3281
- function createRepeatItem(item, index, key, template, state) {
3378
+ function createRepeatItem(item, index, key, template) {
3282
3379
  const templateResult = template(item, index);
3283
- let nodes;
3284
- let container;
3285
- if (state.useCompiledPath && state.compiledTemplate) {
3286
- const node = state.compiledTemplate.createDirect(templateResult.values);
3287
- if (node) {
3288
- nodes = [node];
3289
- container = document.createDocumentFragment();
3290
- container.appendChild(node);
3291
- } else {
3292
- container = document.createDocumentFragment();
3293
- nodes = templateResult.renderOnce(container);
3294
- }
3295
- } else {
3296
- container = document.createDocumentFragment();
3297
- nodes = templateResult.renderOnce(container);
3298
- }
3380
+ const container = document.createDocumentFragment();
3299
3381
  return {
3300
3382
  key,
3301
3383
  value: item,
3302
3384
  container,
3303
- nodes,
3385
+ nodes: templateResult.renderOnce(container),
3304
3386
  start: document.createComment("repeat-item-start"),
3305
3387
  end: document.createComment("repeat-item-end")
3306
3388
  };
@@ -3663,7 +3745,7 @@ var FormControl = class extends AbstractControl {
3663
3745
  setValue(value, options) {
3664
3746
  if (this._ownDisabled()) return;
3665
3747
  this.value.set(value);
3666
- this._dirty.set(!options?.markAsPristine);
3748
+ if (options?.markAsPristine) this._dirty.set(false);
3667
3749
  if (this.updateOn === "change") this.runValidation();
3668
3750
  }
3669
3751
  patchValue(value, options) {
@@ -3678,7 +3760,6 @@ var FormControl = class extends AbstractControl {
3678
3760
  this.value.set(value ?? this.initialValue);
3679
3761
  this._dirty.set(false);
3680
3762
  this._touched.set(false);
3681
- this.errors.set(null);
3682
3763
  this.runValidation();
3683
3764
  }
3684
3765
  destroy() {
@@ -3718,19 +3799,26 @@ var FormGroup = class FormGroup extends AbstractControl {
3718
3799
  const control = this.controls()[name];
3719
3800
  if (!control) return;
3720
3801
  control.parent = null;
3721
- control.destroy();
3722
3802
  this.controls.update((current) => {
3723
3803
  const next = { ...current };
3724
3804
  delete next[name];
3725
3805
  return next;
3726
3806
  });
3807
+ control.destroy();
3727
3808
  }
3728
3809
  setValue(value, options) {
3729
3810
  if (this._ownDisabled()) return;
3730
3811
  const controls = this.controls();
3731
- for (const key of Object.keys(value)) controls[key]?.setValue(value[key], options);
3812
+ const controlKeys = Object.keys(controls);
3813
+ const valueKeys = Object.keys(value);
3814
+ for (const key of valueKeys) if (!(key in controls)) throw new Error(`FormGroup.setValue: unknown control name '${key}'. Use patchValue() for partial updates.`);
3815
+ for (const key of controlKeys) if (!(key in value)) throw new Error(`FormGroup.setValue: missing value for control name '${key}'. Use patchValue() for partial updates.`);
3816
+ for (const key of controlKeys) controls[key].setValue(value[key], options);
3732
3817
  if (options?.markAsPristine) this._dirty.set(false);
3733
3818
  }
3819
+ getRawValue() {
3820
+ return FormGroup.computeValue(this.controls(), true);
3821
+ }
3734
3822
  patchValue(value, options) {
3735
3823
  if (this._ownDisabled()) return;
3736
3824
  const controls = this.controls();
@@ -3807,9 +3895,13 @@ var FormGroup = class FormGroup extends AbstractControl {
3807
3895
  const controls = this.controls();
3808
3896
  return Object.keys(controls).some((key) => controls[key].invalid());
3809
3897
  }
3810
- static computeValue(controls) {
3898
+ static computeValue(controls, includeDisabled = false) {
3811
3899
  const result = {};
3812
- for (const key of Object.keys(controls)) result[key] = controls[key].value();
3900
+ for (const key of Object.keys(controls)) {
3901
+ const control = controls[key];
3902
+ if (!includeDisabled && control.disabled()) continue;
3903
+ result[key] = includeDisabled ? control.getRawValue() : control.value();
3904
+ }
3813
3905
  return result;
3814
3906
  }
3815
3907
  };
@@ -3822,7 +3914,7 @@ var FormArray = class extends AbstractControl {
3822
3914
  this._childValueEffect = new SignalEffect(() => {
3823
3915
  const controls = this.controls();
3824
3916
  for (const control of controls) control.value();
3825
- this.value.set(controls.map((c) => c.value()));
3917
+ this.value.set(controls.filter((c) => !c.disabled()).map((c) => c.value()));
3826
3918
  this.runValidation();
3827
3919
  });
3828
3920
  this._childValueEffect.run();
@@ -3849,25 +3941,27 @@ var FormArray = class extends AbstractControl {
3849
3941
  const control = this.controls()[index];
3850
3942
  if (!control) return;
3851
3943
  control.parent = null;
3852
- control.destroy();
3853
3944
  this.controls.update((current) => current.filter((_, i) => i !== index));
3945
+ control.destroy();
3854
3946
  }
3855
3947
  clear() {
3856
3948
  const controls = this.controls();
3857
- for (const control of controls) {
3858
- control.parent = null;
3859
- control.destroy();
3860
- }
3949
+ for (const control of controls) control.parent = null;
3861
3950
  this.controls.set([]);
3951
+ for (const control of controls) control.destroy();
3862
3952
  }
3863
3953
  setValue(value, options) {
3864
3954
  if (this._ownDisabled()) return;
3865
3955
  const controls = this.controls();
3956
+ if (value.length !== controls.length) throw new Error(`FormArray.setValue: expected ${controls.length} value(s) but received ${value.length}. Use patchValue() for partial updates.`);
3866
3957
  value.forEach((v, i) => {
3867
- controls[i]?.setValue(v, options);
3958
+ controls[i].setValue(v, options);
3868
3959
  });
3869
3960
  if (options?.markAsPristine) this._dirty.set(false);
3870
3961
  }
3962
+ getRawValue() {
3963
+ return this.controls().map((c) => c.getRawValue());
3964
+ }
3871
3965
  patchValue(value, options) {
3872
3966
  if (this._ownDisabled()) return;
3873
3967
  const controls = this.controls();
@@ -4147,12 +4241,15 @@ function formControlDirective(element, value, _) {
4147
4241
  }
4148
4242
  const cleanupFns = [];
4149
4243
  const syncElementValue = (val) => {
4244
+ if (control.destroyed) return;
4150
4245
  adapter.setValue(element, val);
4151
4246
  };
4152
4247
  const syncDisabled = (disabled) => {
4248
+ if (control.destroyed) return;
4153
4249
  adapter.setDisabled?.(element, disabled);
4154
4250
  };
4155
4251
  const syncClasses = () => {
4252
+ if (control.destroyed) return;
4156
4253
  element.classList.toggle("mf-valid", control.valid());
4157
4254
  element.classList.toggle("mf-invalid", control.invalid());
4158
4255
  element.classList.toggle("mf-dirty", control.dirty());
@@ -4162,6 +4259,7 @@ function formControlDirective(element, value, _) {
4162
4259
  element.classList.toggle("mf-disabled", control.disabled());
4163
4260
  };
4164
4261
  const syncError = () => {
4262
+ if (control.destroyed) return;
4165
4263
  if (!control.touched() || !control.errors()) {
4166
4264
  element.removeAttribute("error");
4167
4265
  return;
@@ -4172,7 +4270,10 @@ function formControlDirective(element, value, _) {
4172
4270
  };
4173
4271
  const handleInput = (event) => {
4174
4272
  const target = event.target;
4175
- if (target === element || element.contains(target)) control.setValue(adapter.getValue(element));
4273
+ if (target === element || element.contains(target)) {
4274
+ control.setValue(adapter.getValue(element));
4275
+ control.markAsDirty();
4276
+ }
4176
4277
  };
4177
4278
  const handleBlur = () => {
4178
4279
  control.markAsTouched();
@@ -4632,7 +4733,7 @@ const darkThemeCss = `[data-theme="dark"] {
4632
4733
  }
4633
4734
 
4634
4735
  @media (prefers-color-scheme: dark) {
4635
- :root:not([data-theme="light"]) {
4736
+ :root:not([data-theme]) {
4636
4737
  ${Object.entries(darkTheme).map(([key, value]) => `${key}: ${value};`).join("\n ")}
4637
4738
 
4638
4739
  color-scheme: dark;
@@ -4651,7 +4752,10 @@ function getTheme() {
4651
4752
  return currentTheme;
4652
4753
  }
4653
4754
  function getResolvedTheme() {
4654
- if (currentTheme === "system") return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
4755
+ if (currentTheme === "system") {
4756
+ if (typeof window === "undefined" || !window.matchMedia) return "light";
4757
+ return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
4758
+ }
4655
4759
  return currentTheme;
4656
4760
  }
4657
4761
  function applyTheme(theme) {
@@ -4660,6 +4764,10 @@ function applyTheme(theme) {
4660
4764
  mediaQueryCleanup = null;
4661
4765
  }
4662
4766
  currentTheme = theme;
4767
+ if (typeof document === "undefined" || typeof window === "undefined" || !window.matchMedia) {
4768
+ notifyListeners(theme, theme === "dark" ? "dark" : "light");
4769
+ return;
4770
+ }
4663
4771
  if (theme === "system") {
4664
4772
  const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
4665
4773
  const handleChange = () => {
@@ -4691,6 +4799,7 @@ function createTheme(name, overrides) {
4691
4799
  return `[data-theme="${name}"] {\n\t${Object.entries(overrides).map(([key, value]) => `${key}: ${value};`).join("\n ")}\n}`;
4692
4800
  }
4693
4801
  function injectTheme(name, overrides) {
4802
+ if (typeof document === "undefined") throw new Error("injectTheme requires a DOM (document is undefined).");
4694
4803
  const css$1 = createTheme(name, overrides);
4695
4804
  const style = document.createElement("style");
4696
4805
  style.id = `ml-theme-${name}`;
@@ -4700,13 +4809,19 @@ function injectTheme(name, overrides) {
4700
4809
  document.head.appendChild(style);
4701
4810
  return style;
4702
4811
  }
4812
+ function setColorWithVariants(overrides, token, color) {
4813
+ overrides[token] = color;
4814
+ overrides[`${token}-hover`] = `color-mix(in srgb, ${color}, black 12%)`;
4815
+ overrides[`${token}-active`] = `color-mix(in srgb, ${color}, black 22%)`;
4816
+ overrides[`${token}-subtle`] = `color-mix(in srgb, ${color}, white 88%)`;
4817
+ }
4703
4818
  function createBrandTheme(name, options) {
4704
4819
  const overrides = {};
4705
- if (options.primary) overrides["--ml-color-primary"] = options.primary;
4706
- if (options.secondary) overrides["--ml-color-secondary"] = options.secondary;
4707
- if (options.success) overrides["--ml-color-success"] = options.success;
4708
- if (options.warning) overrides["--ml-color-warning"] = options.warning;
4709
- if (options.danger) overrides["--ml-color-danger"] = options.danger;
4820
+ if (options.primary) setColorWithVariants(overrides, "--ml-color-primary", options.primary);
4821
+ if (options.secondary) setColorWithVariants(overrides, "--ml-color-secondary", options.secondary);
4822
+ if (options.success) setColorWithVariants(overrides, "--ml-color-success", options.success);
4823
+ if (options.warning) setColorWithVariants(overrides, "--ml-color-warning", options.warning);
4824
+ if (options.danger) setColorWithVariants(overrides, "--ml-color-danger", options.danger);
4710
4825
  return createTheme(name, overrides);
4711
4826
  }
4712
4827
  function getBasePlacement(reference, floating, placement) {
@@ -5334,14 +5449,14 @@ var VirtualScroller = class {
5334
5449
  this._resizeObserver = null;
5335
5450
  this._options = null;
5336
5451
  this._handleScroll = () => {
5337
- this._compute(this._viewport.clientHeight);
5452
+ this._compute();
5338
5453
  };
5339
5454
  }
5340
5455
  attach(viewport, options) {
5341
5456
  this._viewport = viewport;
5342
5457
  this._options = options;
5343
- this._resizeObserver = new ResizeObserver((entries) => {
5344
- for (const entry of entries) this._compute(entry.contentRect.height);
5458
+ this._resizeObserver = new ResizeObserver(() => {
5459
+ this._compute();
5345
5460
  });
5346
5461
  this._resizeObserver.observe(viewport);
5347
5462
  viewport.addEventListener("scroll", this._handleScroll);
@@ -5354,10 +5469,9 @@ var VirtualScroller = class {
5354
5469
  this._options = null;
5355
5470
  }
5356
5471
  invalidate() {
5357
- if (!this._viewport) return;
5358
- this._compute(this._viewport.clientHeight);
5472
+ this._compute();
5359
5473
  }
5360
- _compute(viewportHeight) {
5474
+ _compute() {
5361
5475
  if (!this._viewport || !this._options) return;
5362
5476
  const { rowHeight, itemCount, onUpdate, enabled, buffer = 3 } = this._options;
5363
5477
  const count = itemCount();
@@ -5365,6 +5479,7 @@ var VirtualScroller = class {
5365
5479
  onUpdate(0, count);
5366
5480
  return;
5367
5481
  }
5482
+ const viewportHeight = this._viewport.clientHeight;
5368
5483
  const scrollTop = this._viewport.scrollTop;
5369
5484
  const rowH = rowHeight();
5370
5485
  onUpdate(Math.max(0, Math.floor(scrollTop / rowH) - buffer), Math.min(count, Math.ceil((scrollTop + viewportHeight) / rowH) + buffer));
@@ -7317,6 +7432,11 @@ var RadioGroupComponent = class RadioGroupComponent$1 {
7317
7432
  }
7318
7433
  onInit() {
7319
7434
  this.elementRef.addEventListener("ml:change", this.handleChildChange);
7435
+ }
7436
+ onCreate() {
7437
+ (this.elementRef.shadowRoot?.querySelector("slot"))?.addEventListener("slotchange", () => this.updateChildRadios());
7438
+ }
7439
+ onRender() {
7320
7440
  this.updateChildRadios();
7321
7441
  }
7322
7442
  updateChildRadios() {
@@ -7504,6 +7624,9 @@ var RadioCardGroupComponent = class RadioCardGroupComponent$1 {
7504
7624
  }
7505
7625
  onCreate() {
7506
7626
  this.elementRef.addEventListener("ml:card-select", this._handleCardSelect);
7627
+ this.elementRef.shadowRoot?.querySelector("slot")?.addEventListener("slotchange", this.handleSlotChange);
7628
+ }
7629
+ onRender() {
7507
7630
  this.syncCards();
7508
7631
  }
7509
7632
  onDestroy() {
@@ -13693,7 +13816,7 @@ function tableTemplate(c) {
13693
13816
  [`ml-table--${c.size}`]: true,
13694
13817
  "ml-table--striped": c.striped,
13695
13818
  "ml-table--hoverable": c.hoverable,
13696
- "ml-table--row-clickable": c._rowClickable,
13819
+ "ml-table--row-clickable": c.clickableRows,
13697
13820
  "ml-table--sticky-header": c.stickyHeader,
13698
13821
  "ml-table--virtual": c.virtual
13699
13822
  })}>
@@ -14115,15 +14238,9 @@ const tableStyles = () => css`
14115
14238
  padding: var(--ml-space-2) var(--ml-space-4);
14116
14239
  }
14117
14240
  `;
14118
- var _rowClickTargets = /* @__PURE__ */ new WeakSet();
14119
- var _origAddEventListener = EventTarget.prototype.addEventListener;
14120
- EventTarget.prototype.addEventListener = function(type, listener, options) {
14121
- if (type === "ml:row-click") _rowClickTargets.add(this);
14122
- _origAddEventListener.call(this, type, listener, options);
14123
- };
14124
14241
  var TableComponent = class TableComponent$1 {
14125
14242
  constructor() {
14126
- this._rowClickable = false;
14243
+ this.clickableRows = false;
14127
14244
  this.hasFooter = false;
14128
14245
  this.hasHeaderActions = false;
14129
14246
  this.selectable = false;
@@ -14193,9 +14310,6 @@ var TableComponent = class TableComponent$1 {
14193
14310
  onPropertyChange(name, _oldVal, _newVal) {
14194
14311
  if (name === "rows" || name === "columns") this._scroller.invalidate();
14195
14312
  }
14196
- onInit() {
14197
- this._rowClickable = _rowClickTargets.has(this.elementRef);
14198
- }
14199
14313
  onCreate() {
14200
14314
  const shadow = this.elementRef.shadowRoot;
14201
14315
  if (!shadow) return;
@@ -14296,7 +14410,8 @@ TableComponent = __decorate([MelodicComponent({
14296
14410
  "description",
14297
14411
  "sticky-header",
14298
14412
  "virtual",
14299
- "manual-sort"
14413
+ "manual-sort",
14414
+ "clickable-rows"
14300
14415
  ]
14301
14416
  })], TableComponent);
14302
14417
  function renderCell(col, row, index) {
@@ -15103,6 +15218,7 @@ var DataGridComponent = class DataGridComponent$1 {
15103
15218
  this.sortDirection = "asc";
15104
15219
  }
15105
15220
  this.currentPage = 1;
15221
+ this.selectedIndices = [];
15106
15222
  this._scroller.invalidate();
15107
15223
  this.elementRef.dispatchEvent(new CustomEvent("ml:sort", {
15108
15224
  bubbles: true,
@@ -15120,6 +15236,7 @@ var DataGridComponent = class DataGridComponent$1 {
15120
15236
  [key]: val
15121
15237
  };
15122
15238
  this.currentPage = 1;
15239
+ this.selectedIndices = [];
15123
15240
  this._scroller.invalidate();
15124
15241
  this.elementRef.dispatchEvent(new CustomEvent("ml:filter", {
15125
15242
  bubbles: true,
@@ -15212,6 +15329,7 @@ var DataGridComponent = class DataGridComponent$1 {
15212
15329
  this.goToPage = (page) => {
15213
15330
  if (page < 1 || page > this.totalPages) return;
15214
15331
  this.currentPage = page;
15332
+ this.selectedIndices = [];
15215
15333
  if (this._viewport) this._viewport.scrollTop = 0;
15216
15334
  this._scroller.invalidate();
15217
15335
  this.elementRef.dispatchEvent(new CustomEvent("ml:page-change", {
@@ -15229,6 +15347,10 @@ var DataGridComponent = class DataGridComponent$1 {
15229
15347
  }
15230
15348
  onPropertyChange(name, _oldVal, newVal) {
15231
15349
  if (name === "columns" && Array.isArray(newVal)) this._syncColumnState(newVal);
15350
+ if (name === "rows") {
15351
+ this.selectedIndices = [];
15352
+ queueMicrotask(() => this._scroller.invalidate());
15353
+ }
15232
15354
  }
15233
15355
  onCreate() {
15234
15356
  this._syncColumnState(this.columns);
@@ -22871,6 +22993,7 @@ var DialogService = class DialogService$1 {
22871
22993
  const dialogRef = new DialogRef(dialogID, dialogEl);
22872
22994
  this._dialogs.set(dialogID, {
22873
22995
  dialogRef,
22996
+ dialogEl,
22874
22997
  dialogComponent: void 0
22875
22998
  });
22876
22999
  dialogEl.addEventListener("close", () => {
@@ -22879,7 +23002,11 @@ var DialogService = class DialogService$1 {
22879
23002
  });
22880
23003
  return dialogRef;
22881
23004
  }
22882
- removeDialog(dialogID) {
23005
+ removeDialog(dialogID, dialogEl) {
23006
+ if (dialogEl) {
23007
+ const elements = this._dialogs.get(dialogID);
23008
+ if (!elements || elements.dialogEl !== dialogEl) return;
23009
+ }
22883
23010
  this._dialogs.delete(dialogID);
22884
23011
  }
22885
23012
  open(dialogComponentOrID, config) {
@@ -22935,7 +23062,8 @@ var DialogComponent = class DialogComponent$1 {
22935
23062
  this._registered = true;
22936
23063
  }
22937
23064
  onDestroy() {
22938
- this._dialogService.removeDialog(this._dialogID);
23065
+ if (!this._registered) return;
23066
+ this._dialogService.removeDialog(this._dialogID, this._dialogEl);
22939
23067
  }
22940
23068
  open() {
22941
23069
  this.registerDialog();
@@ -23405,7 +23533,12 @@ var DropdownComponent = class DropdownComponent$1 {
23405
23533
  this.isOpen = false;
23406
23534
  this._focusedIndex = -1;
23407
23535
  this._cleanupAutoUpdate = null;
23536
+ this._justDismissed = false;
23408
23537
  this.toggle = () => {
23538
+ if (this._justDismissed) {
23539
+ this._justDismissed = false;
23540
+ return;
23541
+ }
23409
23542
  const menuEl = this.getMenuEl();
23410
23543
  if (menuEl) menuEl.togglePopover();
23411
23544
  };
@@ -23420,6 +23553,10 @@ var DropdownComponent = class DropdownComponent$1 {
23420
23553
  }));
23421
23554
  } else {
23422
23555
  this.isOpen = false;
23556
+ this._justDismissed = true;
23557
+ setTimeout(() => {
23558
+ this._justDismissed = false;
23559
+ }, 0);
23423
23560
  this.clearFocus();
23424
23561
  this._cleanupAutoUpdate?.();
23425
23562
  this._cleanupAutoUpdate = null;
@@ -23856,8 +23993,10 @@ const tooltipStyles = () => css`
23856
23993
  --ml-tooltip-max-width: 320px;
23857
23994
  --ml-tooltip-padding-y: var(--ml-space-2);
23858
23995
  --ml-tooltip-padding-x: var(--ml-space-3);
23859
- --ml-tooltip-bg: var(--ml-tooltip-bg);
23860
- --ml-tooltip-color: var(--ml-tooltip-text);
23996
+ /* bg/color derive from the global tooltip theme tokens; referencing
23997
+ --ml-tooltip-bg here would be self-referential (invalid → transparent). */
23998
+ --ml-tooltip-bg: var(--ml-color-neutral-900, var(--ml-gray-900));
23999
+ --ml-tooltip-color: var(--ml-tooltip-text, var(--ml-white));
23861
24000
  --ml-tooltip-font-size: var(--ml-text-xs);
23862
24001
  --ml-tooltip-font-weight: var(--ml-font-medium);
23863
24002
  --ml-tooltip-line-height: var(--ml-leading-snug);
@@ -24126,7 +24265,12 @@ var PopoverComponent = class PopoverComponent$1 {
24126
24265
  this.arrow = false;
24127
24266
  this.isOpen = false;
24128
24267
  this._cleanupAutoUpdate = null;
24268
+ this._justDismissed = false;
24129
24269
  this.toggle = () => {
24270
+ if (this._justDismissed) {
24271
+ this._justDismissed = false;
24272
+ return;
24273
+ }
24130
24274
  const popoverEl = this.getPopoverEl();
24131
24275
  if (popoverEl) popoverEl.togglePopover();
24132
24276
  };
@@ -24136,6 +24280,10 @@ var PopoverComponent = class PopoverComponent$1 {
24136
24280
  this.startPositioning();
24137
24281
  } else {
24138
24282
  this.isOpen = false;
24283
+ this._justDismissed = true;
24284
+ setTimeout(() => {
24285
+ this._justDismissed = false;
24286
+ }, 0);
24139
24287
  this._cleanupAutoUpdate?.();
24140
24288
  this._cleanupAutoUpdate = null;
24141
24289
  }
@@ -25798,6 +25946,6 @@ DashboardPageComponent = __decorate([MelodicComponent({
25798
25946
  "layout"
25799
25947
  ]
25800
25948
  })], DashboardPageComponent);
25801
- export { APP_CONFIG, AbortError, AbstractControl, ActivityFeedComponent, ActivityFeedItemComponent, AlertComponent, AppShellComponent, AvatarComponent, BadgeComponent, BadgeGroupComponent, Binding, BreadcrumbComponent, BreadcrumbItemComponent, ButtonComponent, ButtonGroupComponent, ButtonGroupItemComponent, CalendarComponent, CalendarViewComponent, CardComponent, CheckboxComponent, ComponentBase, ComponentStateBaseService, ContainerComponent, DashboardPageComponent, DatePickerComponent, DialogComponent, DialogRef, DialogService, Directive, DividerComponent, DrawerComponent, DropdownComponent, DropdownGroupComponent, DropdownItemComponent, DropdownSeparatorComponent, EffectsBase, FormArray, FormControl, FormFieldComponent, FormGroup, HeroSectionComponent, HttpBaseError, HttpClient, HttpError, IconComponent, Inject, Injectable, InjectionEngine, Injector, InputComponent, ListComponent, ListItemComponent, LoginPageComponent, MelodicComponent, NetworkError, PageHeaderComponent, PaginationComponent, PopoverComponent, ProgressComponent, ROUTE_CONTEXT_EVENT, RX_ACTION_PROVIDERS, RX_EFFECTS_PROVIDERS, RX_INIT_STATE, RX_STATE_DEBUG, RadioCardComponent, RadioCardGroupComponent, RadioComponent, RadioGroupComponent, RouteContextEvent, RouteContextService, RouteMatcher, RouterLinkComponent, RouterOutletComponent, RouterService, SIGNAL_MARKER, SelectComponent, Service, SidebarComponent, SidebarGroupComponent, SidebarItemComponent, SignalEffect, SignalStoreService, SignupPageComponent, SliderComponent, SpinnerComponent, StackComponent, StepComponent, StepPanelComponent, StepsComponent, TabComponent, TabPanelComponent, TableComponent, TabsComponent, TagComponent, TemplateResult, TextareaComponent, ToastComponent, ToastContainerComponent, ToastService, ToggleComponent, TooltipComponent, Validators, VirtualScroller, activityFeedItemStyles, activityFeedItemTemplate, activityFeedStyles, activityFeedTemplate, allTokens, announce, appShellStyles, appShellTemplate, applyGlobalStyles, applyTheme, arrow, autoUpdate, baseThemeCss, bootstrap, borderTokens, breadcrumbItemStyles, breadcrumbItemTemplate, breadcrumbStyles, breadcrumbTemplate, breakpointTokens, breakpoints, buildPathFromRoute, calendarViewStyles, calendarViewTemplate, checkboxAdapter, classMap, clickOutside, colorTokens, componentBaseStyles, computePosition, computed, containerStyles, containerTemplate, createAction, createAsyncValidator, createBrandTheme, createDeactivateGuard, createFocusTrap, createFormArray, createFormControl, createFormGroup, createGuard, createLiveRegion, createReducer, createResolver, createState, createTheme, createToken, createValidator, css, darkTheme, darkThemeCss, dashboardPageStyles, dashboardPageTemplate, defineConfig, directive, drawerStyles, drawerTemplate, dropdownGroupStyles, dropdownGroupTemplate, dropdownItemStyles, dropdownItemTemplate, dropdownSeparatorStyles, dropdownSeparatorTemplate, dropdownStyles, dropdownTemplate, environment, findRouteByName, flip, focusFirst, focusLast, focusTrap, focusVisible, formControlDirective, formFieldStyles, formFieldTemplate, getActiveComponent, getActiveEffect, getAdapter, getAttributeDirective, getEnvironment, getFirstFocusable, getFocusableElements, getGlobalMessage, getLastFocusable, getRegisteredDirectives, getResolvedTheme, getTheme, getTokenKey, hasAttributeDirective, heroSectionStyles, heroSectionTemplate, html, injectTheme, isDirective, isFocusVisible, isSignal, lightTheme, lightThemeCss, listItemStyles, listItemTemplate, listStyles, listTemplate, loginPageStyles, loginPageTemplate, matchRouteTree, newID, offset, onAction, onThemeChange, pageHeaderStyles, pageHeaderTemplate, paginationStyles, paginationTemplate, portalDirective, primitiveColors, progressStyles, progressTemplate, props, provideConfig, provideHttp, provideRX, radioAdapter, registerAdapter, registerAttributeDirective, registerDefaultMessages, render, repeat, repeatRaw, resetStyles, resolveMessage, routerLinkDirective, selectStyles, selectTemplate, setActiveComponent, setActiveEffect, setDefaultMessage, shadowTokens, shift, sidebarGroupStyles, sidebarGroupTemplate, sidebarItemStyles, sidebarItemTemplate, sidebarStyles, sidebarTemplate, signal, signupPageStyles, signupPageTemplate, sliderStyles, sliderTemplate, spacingTokens, stepPanelStyles, stepPanelTemplate, stepStyles, stepTemplate, stepsStyles, stepsTemplate, styleMap, tabPanelStyles, tabPanelTemplate, tabStyles, tabTemplate, tableStyles, tableTemplate, tabsStyles, tabsTemplate, textAdapter, toastContainerStyles, toastContainerTemplate, toastStyles, toastTemplate, toggleTheme, tokensToCss, tooltipDirective, transitionTokens, typographyTokens, unregisterAttributeDirective, unsafeHTML, visuallyHiddenStyles, when };
25949
+ export { APP_CONFIG, AbortError, AbstractControl, ActivityFeedComponent, ActivityFeedItemComponent, AlertComponent, AppShellComponent, AvatarComponent, BadgeComponent, BadgeGroupComponent, Binding, BreadcrumbComponent, BreadcrumbItemComponent, ButtonComponent, ButtonGroupComponent, ButtonGroupItemComponent, CalendarComponent, CalendarViewComponent, CardComponent, CheckboxComponent, ComponentBase, ComponentStateBaseService, ContainerComponent, DashboardPageComponent, DatePickerComponent, DialogComponent, DialogRef, DialogService, Directive, DividerComponent, DrawerComponent, DropdownComponent, DropdownGroupComponent, DropdownItemComponent, DropdownSeparatorComponent, EffectsBase, FormArray, FormControl, FormFieldComponent, FormGroup, HeroSectionComponent, HttpBaseError, HttpClient, HttpError, IconComponent, Inject, Injectable, InjectionEngine, Injector, InputComponent, ListComponent, ListItemComponent, LoginPageComponent, MelodicComponent, NetworkError, PageHeaderComponent, PaginationComponent, PopoverComponent, ProgressComponent, ROUTE_CONTEXT_EVENT, RX_ACTION_PROVIDERS, RX_EFFECTS_PROVIDERS, RX_INIT_STATE, RX_STATE_DEBUG, RadioCardComponent, RadioCardGroupComponent, RadioComponent, RadioGroupComponent, RouteContextEvent, RouteContextService, RouteMatcher, RouterLinkComponent, RouterOutletComponent, RouterService, SIGNAL_MARKER, SelectComponent, Service, SidebarComponent, SidebarGroupComponent, SidebarItemComponent, SignalEffect, SignalStoreService, SignupPageComponent, SliderComponent, SpinnerComponent, StackComponent, StepComponent, StepPanelComponent, StepsComponent, TabComponent, TabPanelComponent, TableComponent, TabsComponent, TagComponent, TemplateResult, TextareaComponent, ToastComponent, ToastContainerComponent, ToastService, ToggleComponent, TooltipComponent, Validators, VirtualScroller, activityFeedItemStyles, activityFeedItemTemplate, activityFeedStyles, activityFeedTemplate, allTokens, announce, appShellStyles, appShellTemplate, applyGlobalStyles, applyTheme, arrow, autoUpdate, baseThemeCss, batch, bootstrap, borderTokens, breadcrumbItemStyles, breadcrumbItemTemplate, breadcrumbStyles, breadcrumbTemplate, breakpointTokens, breakpoints, buildPathFromRoute, calendarViewStyles, calendarViewTemplate, checkboxAdapter, classMap, clickOutside, colorTokens, componentBaseStyles, computePosition, computed, containerStyles, containerTemplate, createAction, createAsyncValidator, createBrandTheme, createDeactivateGuard, createFocusTrap, createFormArray, createFormControl, createFormGroup, createGuard, createLiveRegion, createReducer, createResolver, createState, createTheme, createToken, createValidator, css, darkTheme, darkThemeCss, dashboardPageStyles, dashboardPageTemplate, defineConfig, describeToken, directive, drawerStyles, drawerTemplate, dropdownGroupStyles, dropdownGroupTemplate, dropdownItemStyles, dropdownItemTemplate, dropdownSeparatorStyles, dropdownSeparatorTemplate, dropdownStyles, dropdownTemplate, environment, findRouteByName, flip, focusFirst, focusLast, focusTrap, focusVisible, formControlDirective, formFieldStyles, formFieldTemplate, getActiveComponent, getActiveEffect, getAdapter, getAttributeDirective, getEnvironment, getFirstFocusable, getFocusableElements, getGlobalMessage, getLastFocusable, getRegisteredDirectives, getResolvedTheme, getTheme, getTokenKey, hasAttributeDirective, heroSectionStyles, heroSectionTemplate, html, injectTheme, isDirective, isFocusVisible, isSignal, lightTheme, lightThemeCss, listItemStyles, listItemTemplate, listStyles, listTemplate, loginPageStyles, loginPageTemplate, matchRouteTree, newID, offset, onAction, onThemeChange, pageHeaderStyles, pageHeaderTemplate, paginationStyles, paginationTemplate, portalDirective, primitiveColors, progressStyles, progressTemplate, props, provideConfig, provideHttp, provideRX, radioAdapter, registerAdapter, registerAttributeDirective, registerDefaultMessages, render, repeat, repeatRaw, resetStyles, resolveMessage, routerLinkDirective, selectStyles, selectTemplate, setActiveComponent, setActiveEffect, setDefaultMessage, shadowTokens, shift, sidebarGroupStyles, sidebarGroupTemplate, sidebarItemStyles, sidebarItemTemplate, sidebarStyles, sidebarTemplate, signal, signupPageStyles, signupPageTemplate, sliderStyles, sliderTemplate, spacingTokens, stepPanelStyles, stepPanelTemplate, stepStyles, stepTemplate, stepsStyles, stepsTemplate, styleMap, tabPanelStyles, tabPanelTemplate, tabStyles, tabTemplate, tableStyles, tableTemplate, tabsStyles, tabsTemplate, textAdapter, toastContainerStyles, toastContainerTemplate, toastStyles, toastTemplate, toggleTheme, tokensToCss, tooltipDirective, transitionTokens, typographyTokens, unregisterAttributeDirective, unsafeHTML, visuallyHiddenStyles, when };
25802
25950
 
25803
25951
  //# sourceMappingURL=melodic-components.js.map