@oscarpalmer/abydon 0.16.0 → 0.19.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.
Files changed (54) hide show
  1. package/dist/{abydon.full.js → abydon.full.mjs} +542 -234
  2. package/dist/constants.d.mts +37 -0
  3. package/dist/constants.mjs +44 -0
  4. package/dist/fragment-9qTBAvtR.d.mts +82 -0
  5. package/dist/fragment.d.mts +2 -0
  6. package/dist/{fragment.js → fragment.mjs} +35 -6
  7. package/dist/fragments.d.mts +16 -0
  8. package/dist/{fragments.js → fragments.mjs} +11 -6
  9. package/dist/helpers/dom.d.mts +7 -0
  10. package/dist/helpers/{dom.js → dom.mjs} +7 -2
  11. package/dist/helpers/index.d.mts +10 -0
  12. package/dist/helpers/{index.js → index.mjs} +5 -6
  13. package/dist/index.d.mts +21 -0
  14. package/dist/index.mjs +24 -0
  15. package/dist/models.d.mts +2 -0
  16. package/dist/models.mjs +1 -0
  17. package/dist/node/attribute/index.d.mts +6 -0
  18. package/dist/node/attribute/{index.js → index.mjs} +11 -4
  19. package/dist/node/attribute/value.d.mts +6 -0
  20. package/dist/node/attribute/{value.js → value.mjs} +13 -10
  21. package/dist/node/event.d.mts +4 -0
  22. package/dist/node/{event.js → event.mjs} +5 -3
  23. package/dist/node/index.d.mts +6 -0
  24. package/dist/node/{index.js → index.mjs} +9 -7
  25. package/dist/node/value.d.mts +7 -0
  26. package/dist/node/{value.js → value.mjs} +9 -6
  27. package/dist/parse.d.mts +6 -0
  28. package/dist/{parse.js → parse.mjs} +3 -1
  29. package/package.json +42 -41
  30. package/src/constants.ts +38 -4
  31. package/src/fragment.ts +2 -2
  32. package/src/fragments.ts +10 -4
  33. package/src/helpers/dom.ts +10 -0
  34. package/src/helpers/index.ts +13 -10
  35. package/src/node/attribute/index.ts +11 -1
  36. package/src/node/attribute/value.ts +18 -10
  37. package/src/node/event.ts +9 -4
  38. package/src/node/value.ts +3 -2
  39. package/dist/constants.js +0 -25
  40. package/dist/index.js +0 -11
  41. package/dist/models.js +0 -0
  42. package/types/constants.d.ts +0 -17
  43. package/types/fragment.d.ts +0 -38
  44. package/types/fragments.d.ts +0 -13
  45. package/types/helpers/dom.d.ts +0 -3
  46. package/types/helpers/index.d.ts +0 -5
  47. package/types/index.d.ts +0 -20
  48. package/types/models.d.ts +0 -41
  49. package/types/node/attribute/index.d.ts +0 -2
  50. package/types/node/attribute/value.d.ts +0 -2
  51. package/types/node/event.d.ts +0 -1
  52. package/types/node/index.d.ts +0 -2
  53. package/types/node/value.d.ts +0 -3
  54. package/types/parse.d.ts +0 -2
@@ -1,3 +1,4 @@
1
+ //#region node_modules/@oscarpalmer/mora/dist/constants.mjs
1
2
  const ACTIVE = {};
2
3
  const BATCH = {
3
4
  depth: 0,
@@ -29,6 +30,8 @@ const NAME_ALL = new Set([
29
30
  NAME_SIGNAL,
30
31
  NAME_STORE
31
32
  ]);
33
+ //#endregion
34
+ //#region node_modules/@oscarpalmer/mora/dist/effect.mjs
32
35
  var Effect = class {
33
36
  constructor(callback) {
34
37
  Object.defineProperty(this, NAME_MORA, { value: NAME_EFFECT });
@@ -36,36 +39,70 @@ var Effect = class {
36
39
  runEffect(this);
37
40
  }
38
41
  };
39
- function runEffect(effect$1) {
42
+ function runEffect(effect) {
40
43
  const previousEffect = ACTIVE.effect;
41
- ACTIVE.effect = effect$1;
44
+ ACTIVE.effect = effect;
42
45
  try {
43
- effect$1.state.callback();
46
+ effect.state.callback();
44
47
  } finally {
45
48
  ACTIVE.effect = previousEffect;
46
49
  }
47
50
  }
51
+ /**
52
+ * Create an effect
53
+ * @param callback Callback for handling signal effects
54
+ * @returns Effect
55
+ */
48
56
  function effect(callback) {
49
57
  return typeof callback === "function" ? new Effect(callback) : void 0;
50
58
  }
59
+ //#endregion
60
+ //#region node_modules/@oscarpalmer/mora/dist/helpers/is.mjs
61
+ /**
62
+ * Is the value a reactive array?
63
+ * @param value Value to check
64
+ * @returns True if value is a {@link ReactiveArray}
65
+ */
51
66
  function isArray(value) {
52
67
  return isMora(value, NAME_ARRAY);
53
68
  }
69
+ /**
70
+ * Is the value a computed signal?
71
+ * @param value Value to check
72
+ * @returns True if value is a {@link Computed}
73
+ */
54
74
  function isComputed(value) {
55
75
  return isMora(value, NAME_COMPUTED);
56
76
  }
77
+ /**
78
+ * Is the value an effect?
79
+ * @param value Value to check
80
+ * @returns True if value is an {@link Effect}
81
+ */
57
82
  function isEffect(value) {
58
83
  return isMora(value, NAME_EFFECT);
59
84
  }
60
85
  function isMora(value, name) {
61
86
  return typeof value === "object" && value != null && "$mora" in value && (typeof name === "string" ? value["$mora"] === name : name.has(value["$mora"]));
62
87
  }
88
+ /**
89
+ * Is the value reactive?
90
+ * @param value Value to check
91
+ * @returns True if value is a {@link Reactive}
92
+ */
63
93
  function isReactive(value) {
64
94
  return isMora(value, NAME_ALL);
65
95
  }
96
+ /**
97
+ * Is the value a signal?
98
+ * @param value Value to check
99
+ * @returns True if value is a {@link Signal}
100
+ */
66
101
  function isSignal(value) {
67
102
  return isMora(value, NAME_SIGNAL);
68
103
  }
104
+ //#endregion
105
+ //#region node_modules/@oscarpalmer/mora/dist/batch.mjs
69
106
  function flushHandlers() {
70
107
  while (BATCH.depth === 0 && BATCH.handlers.size > 0) {
71
108
  const handlers = [...BATCH.handlers];
@@ -74,13 +111,23 @@ function flushHandlers() {
74
111
  else handler.callback(handler.state.value);
75
112
  }
76
113
  }
114
+ /**
115
+ * Start batching effects
116
+ *
117
+ * _(Use {@link stopBatch} to flush and run batched effects)_
118
+ */
77
119
  function startBatch() {
78
120
  BATCH.depth += 1;
79
121
  }
122
+ /**
123
+ * Stop batching effects and flush _(run)_ them
124
+ */
80
125
  function stopBatch() {
81
126
  if (BATCH.depth > 0) BATCH.depth -= 1;
82
127
  flushHandlers();
83
128
  }
129
+ //#endregion
130
+ //#region node_modules/@oscarpalmer/mora/dist/subscription.mjs
84
131
  var Subscription = class {
85
132
  callback;
86
133
  state;
@@ -106,6 +153,8 @@ function unsubscribe(state, callback) {
106
153
  state.subscriptions.get(callback)?.destroy();
107
154
  state.subscriptions.delete(callback);
108
155
  }
156
+ //#endregion
157
+ //#region node_modules/@oscarpalmer/mora/dist/value/reactive.mjs
109
158
  var Reactive = class {
110
159
  state = {
111
160
  computeds: /* @__PURE__ */ new Set(),
@@ -119,22 +168,45 @@ var Reactive = class {
119
168
  if (typeof options === "object" && typeof options.equal === "function") this.state.equal = options.equal;
120
169
  Object.defineProperty(this, NAME_MORA, { value: name });
121
170
  }
171
+ /**
172
+ * Get the value _(without reactivity)_
173
+ * @return Current value
174
+ */
122
175
  peek() {
123
176
  return this.state.value;
124
177
  }
178
+ /**
179
+ * Subscribe to changes
180
+ * @param callback Callback for changes
181
+ * @return Unsubscribe callback
182
+ */
125
183
  subscribe(callback) {
126
184
  return subscribe(this.state, callback);
127
185
  }
186
+ /**
187
+ * JSON representation of the value
188
+ * @return JSON value
189
+ */
128
190
  toJSON() {
129
191
  return this.get();
130
192
  }
193
+ /**
194
+ * String representation of the value
195
+ * @return Value as string
196
+ */
131
197
  toString() {
132
198
  return String(this.get());
133
199
  }
200
+ /**
201
+ * Unsubscribe from changes
202
+ * @param callback Callback to unsubscribe
203
+ */
134
204
  unsubscribe(callback) {
135
205
  unsubscribe(this.state, callback);
136
206
  }
137
207
  };
208
+ //#endregion
209
+ //#region node_modules/@oscarpalmer/mora/dist/value/computed.mjs
138
210
  var Computed = class extends Reactive {
139
211
  effect = {
140
212
  dirty: true,
@@ -150,13 +222,16 @@ var Computed = class extends Reactive {
150
222
  ACTIVE.computed = previousComputed;
151
223
  if (!this.state.equal(this.state.value, value)) {
152
224
  this.state.value = value;
153
- for (const computed$1 of this.state.computeds) computed$1.effect.dirty = true;
154
- for (const effect$1 of this.state.effects) BATCH.handlers.add(effect$1);
225
+ for (const computed of this.state.computeds) computed.effect.dirty = true;
226
+ for (const effect of this.state.effects) BATCH.handlers.add(effect);
155
227
  for (const [, subscription] of this.state.subscriptions) subscription.callback(value);
156
228
  }
157
229
  this.effect.dirty = false;
158
230
  });
159
231
  }
232
+ /**
233
+ * @inheritdoc
234
+ */
160
235
  get() {
161
236
  if (ACTIVE.computed != null && this !== ACTIVE.computed) this.state.computeds.add(ACTIVE.computed);
162
237
  if (ACTIVE.effect != null && ACTIVE.effect !== this.effect.instance) this.state.effects.add(ACTIVE.effect);
@@ -164,12 +239,20 @@ var Computed = class extends Reactive {
164
239
  return this.state.value;
165
240
  }
166
241
  };
242
+ /**
243
+ * Create a computed value
244
+ * @param callback Callback to compute the value
245
+ * @param options Reactivity options
246
+ * @returns Computed value
247
+ */
167
248
  function computed(callback, options) {
168
249
  return new Computed(callback, options);
169
250
  }
251
+ //#endregion
252
+ //#region node_modules/@oscarpalmer/mora/dist/helpers/value.mjs
170
253
  function emitValue(state) {
171
- for (const computed$1 of state.computeds) computed$1.effect.dirty = true;
172
- for (const effect$1 of state.effects) BATCH.handlers.add(effect$1);
254
+ for (const computed of state.computeds) computed.effect.dirty = true;
255
+ for (const effect of state.effects) BATCH.handlers.add(effect);
173
256
  for (const [, subscription] of state.subscriptions) BATCH.handlers.add(subscription);
174
257
  if (BATCH.depth === 0) flushHandlers();
175
258
  }
@@ -191,36 +274,57 @@ function getValue$1(state) {
191
274
  if (ACTIVE.effect != null) state.effects.add(ACTIVE.effect);
192
275
  return state.value;
193
276
  }
277
+ //#endregion
278
+ //#region node_modules/@oscarpalmer/mora/dist/value/signal.mjs
194
279
  var Signal = class extends Reactive {
195
280
  constructor(value, options) {
196
281
  super(NAME_SIGNAL, value, options);
197
282
  }
283
+ /**
284
+ * @inheritdoc
285
+ */
198
286
  get() {
199
287
  return getValue$1(this.state);
200
288
  }
289
+ /**
290
+ * Set the value
291
+ * @param value New value
292
+ */
201
293
  set(value) {
202
294
  if (!this.state.equal(this.state.value, value)) {
203
295
  this.state.value = value;
204
296
  emitValue(this.state);
205
297
  }
206
298
  }
299
+ /**
300
+ * Update the value _(based on the current value)_
301
+ * @param callback Callback to update the value
302
+ */
207
303
  update(callback) {
208
304
  this.set(callback(this.state.value));
209
305
  }
210
306
  };
307
+ /**
308
+ * Create a reactive value
309
+ * @param value Initial value
310
+ * @param options Reactivity options
311
+ * @returns Reactive value
312
+ */
211
313
  function signal(value, options) {
212
314
  return new Signal(value, options);
213
315
  }
316
+ //#endregion
317
+ //#region node_modules/@oscarpalmer/mora/dist/helpers/proxy.mjs
214
318
  function emityProxyValues(state, mapped) {
215
319
  const values = [...mapped.values()];
216
320
  const { length } = values;
217
321
  for (let index = 0; index < length; index += 1) values[index].effect.dirty = true;
218
322
  emitValue(state);
219
323
  }
220
- function getReactiveValueInProxy(reactive, mapped, key, isArray$1) {
324
+ function getReactiveValueInProxy(reactive, mapped, key, isArray) {
221
325
  let item = mapped.get(key);
222
326
  if (item == null) {
223
- item = computed(() => isArray$1 ? reactive.get().at(key) : reactive.get()[key]);
327
+ item = computed(() => isArray ? reactive.get().at(key) : reactive.get()[key]);
224
328
  mapped.set(key, item);
225
329
  }
226
330
  return item;
@@ -242,34 +346,42 @@ function setProxyValue(proxy, value) {
242
346
  stopBatch();
243
347
  }
244
348
  function setValueInProxy(parameters) {
245
- const { isArray: isArray$1, length, property, state, target, value } = parameters;
246
- if (isArray$1) {
349
+ const { isArray, length, property, state, target, value } = parameters;
350
+ if (isArray) {
247
351
  if (!(!Number.isNaN(Number(property)) || property === "length")) return Reflect.set(target, property, value);
248
352
  }
249
353
  const previous = Reflect.get(target, property);
250
354
  if (!state.equal(previous, value)) {
251
355
  Reflect.set(target, property, value);
252
356
  emitValue(state);
253
- if (isArray$1) length?.set(target.length);
357
+ if (isArray) length?.set(target.length);
254
358
  }
255
359
  return true;
256
360
  }
361
+ //#endregion
362
+ //#region node_modules/@oscarpalmer/mora/dist/value/array.mjs
257
363
  var ReactiveArray = class extends Reactive {
258
364
  #indiced = /* @__PURE__ */ new Map();
259
365
  #size = signal(0);
366
+ /**
367
+ * The length of the array
368
+ */
260
369
  get length() {
261
370
  return this.#size.get();
262
371
  }
372
+ /**
373
+ * Set the length of the array
374
+ */
263
375
  set length(value) {
264
376
  if (typeof value === "number" && value >= 0 && value !== this.state.value.length) this.get().length = value;
265
377
  }
266
378
  constructor(value, options) {
267
379
  super(NAME_ARRAY, new Proxy(value, {
268
380
  get: (target, property) => METHODS_UPDATE.has(property) ? updateArray(property, target, this.state, this.#size) : Reflect.get(target, property),
269
- set: (target, property, value$1) => setValueInProxy({
381
+ set: (target, property, value) => setValueInProxy({
270
382
  property,
271
383
  target,
272
- value: value$1,
384
+ value,
273
385
  isArray: true,
274
386
  state: this.state,
275
387
  length: this.#size
@@ -277,9 +389,17 @@ var ReactiveArray = class extends Reactive {
277
389
  }), options);
278
390
  this.#size.set(value.length);
279
391
  }
392
+ /**
393
+ * Clear the array
394
+ */
280
395
  clear() {
281
396
  this.length = 0;
282
397
  }
398
+ /**
399
+ * Create a computed, filtered array
400
+ * @param callback Callback to evaluate each item
401
+ * @return Computed array of filtered items
402
+ */
283
403
  filter(callback) {
284
404
  return computed(() => this.get().filter(callback));
285
405
  }
@@ -287,9 +407,20 @@ var ReactiveArray = class extends Reactive {
287
407
  if (typeof first === "number") return getReactiveValueInProxy(this, this.#indiced, first, true).get();
288
408
  return first === "length" ? this.length : getValue$1(this.state);
289
409
  }
410
+ /**
411
+ * Create a computed, mapped array
412
+ * @param callback Callback to transform each item
413
+ * @return Computed array of mapped items
414
+ */
290
415
  map(callback) {
291
416
  return computed(() => this.get().map(callback));
292
417
  }
418
+ /**
419
+ * Notify dependents of changes
420
+ *
421
+ * _This bypasses equality checks and will immediately notify dependents.
422
+ * Use this only if you're modifying nested data that would be ignored by equality checks._
423
+ */
293
424
  notify() {
294
425
  emityProxyValues(this.state, this.#indiced);
295
426
  }
@@ -297,9 +428,18 @@ var ReactiveArray = class extends Reactive {
297
428
  if (value === "length") return this.#size.peek();
298
429
  return typeof value === "number" ? this.state.value.at(value) : [...this.state.value];
299
430
  }
431
+ /**
432
+ * Remove and return the last item of the array
433
+ * @returns Removed item, or `undefined` if the array is empty
434
+ */
300
435
  pop() {
301
436
  return this.state.value.pop();
302
437
  }
438
+ /**
439
+ * Add items to the end of the array
440
+ * @param items Items to add
441
+ * @returns New array length
442
+ */
303
443
  push(...items) {
304
444
  return this.state.value.push(...items);
305
445
  }
@@ -308,9 +448,20 @@ var ReactiveArray = class extends Reactive {
308
448
  else if (first === "length") this.length = second;
309
449
  else if (typeof first === "number" && !Number.isNaN(first)) setAtIndex(this.state.value, first, second);
310
450
  }
451
+ /**
452
+ * Remove and return the first item of the array
453
+ * @returns Removed item, or `undefined` if the array is empty
454
+ */
311
455
  shift() {
312
456
  return this.state.value.shift();
313
457
  }
458
+ /**
459
+ * Remove and return items from the array _(and optionally add new items)_
460
+ * @param from Index to start removing items from
461
+ * @param to Index to stop removing items at _(defaults to the end of the array)_
462
+ * @param items Optional items to add
463
+ * @returns Removed items
464
+ */
314
465
  splice(from, to, ...items) {
315
466
  return this.state.value.splice(from, to ?? this.state.value.length, ...items);
316
467
  }
@@ -318,63 +469,105 @@ var ReactiveArray = class extends Reactive {
318
469
  if (typeof first === "number" && typeof second === "function") return getReactiveValueInProxy(this, this.#indiced, first, true).subscribe(second);
319
470
  return typeof first === "function" ? subscribe(this.state, first) : noop$1;
320
471
  }
472
+ /**
473
+ * Add items to the beginning of the array
474
+ * @param items Items to add
475
+ * @returns New array length
476
+ */
321
477
  unshift(...items) {
322
478
  return this.state.value.unshift(...items);
323
479
  }
480
+ /**
481
+ * Update the value _(based on the current value)_
482
+ * @param callback Callback to update the value
483
+ */
324
484
  update(callback) {
325
485
  const updated = callback(this.state.value);
326
486
  if (updated == null || Array.isArray(updated)) this.set(updated);
327
487
  }
328
488
  };
489
+ /**
490
+ * Create a reactive array
491
+ * @param value Initial array of items
492
+ * @param options Reactivity options
493
+ * @returns Reactive array
494
+ */
329
495
  function array(value, options) {
330
496
  return new ReactiveArray(Array.isArray(value) ? value : [], options);
331
497
  }
332
- function updateArray(type, array$1, state, length) {
498
+ function updateArray(type, array, state, length) {
333
499
  const affectsLength = METHODS_AFFECTING_LENGTH.has(type);
334
- const previousArray = affectsLength ? [] : [...array$1];
335
- const previousLength = array$1.length;
500
+ const previousArray = affectsLength ? [] : [...array];
501
+ const previousLength = array.length;
336
502
  return (...args) => {
337
- const result = array$1[type](...args);
338
- if (affectsLength ? array$1.length !== previousLength : !equalArrays(state, previousArray, array$1)) {
503
+ const result = array[type](...args);
504
+ if (affectsLength ? array.length !== previousLength : !equalArrays(state, previousArray, array)) {
339
505
  emitValue(state);
340
- length.set(array$1.length);
506
+ length.set(array.length);
341
507
  }
342
508
  return result;
343
509
  };
344
510
  }
345
- function setAtIndex(array$1, index, value) {
346
- const actual = index < 0 ? array$1.length + index : index;
347
- if (actual > -1) array$1[actual] = value;
348
- }
511
+ function setAtIndex(array, index, value) {
512
+ const actual = index < 0 ? array.length + index : index;
513
+ if (actual > -1) array[actual] = value;
514
+ }
515
+ //#endregion
516
+ //#region node_modules/@oscarpalmer/atoms/dist/internal/is.mjs
517
+ /**
518
+ * Is the value a key?
519
+ * @param value Value to check
520
+ * @returns `true` if the value is a `Key` _(`number` or `string`)_, otherwise `false`
521
+ */
349
522
  function isKey(value) {
350
523
  return typeof value === "number" || typeof value === "string";
351
524
  }
352
- function isPlainObject$2(value) {
525
+ /**
526
+ * Is the value a plain object?
527
+ * @param value Value to check
528
+ * @returns `true` if the value is a plain object, otherwise `false`
529
+ */
530
+ function isPlainObject(value) {
353
531
  if (value === null || typeof value !== "object") return false;
354
532
  if (Symbol.toStringTag in value || Symbol.iterator in value) return false;
355
533
  const prototype = Object.getPrototypeOf(value);
356
534
  return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
357
535
  }
358
- new Set([
359
- Int8Array,
360
- Uint8Array,
361
- Uint8ClampedArray,
362
- Int16Array,
363
- Uint16Array,
364
- Int32Array,
365
- Uint32Array,
366
- Float32Array,
367
- Float64Array,
368
- BigInt64Array,
369
- BigUint64Array
370
- ]);
536
+ //#endregion
537
+ //#region node_modules/@oscarpalmer/atoms/dist/internal/string.mjs
538
+ /**
539
+ * Get the string value from any value
540
+ * @param value Original value
541
+ * @returns String representation of the value
542
+ */
543
+ function getString(value) {
544
+ if (typeof value === "string") return value;
545
+ if (value == null) return "";
546
+ if (typeof value === "function") return getString(value());
547
+ if (typeof value !== "object") return String(value);
548
+ const asString = String(value.valueOf?.() ?? value);
549
+ return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
550
+ }
551
+ //#endregion
552
+ //#region node_modules/@oscarpalmer/atoms/dist/is.mjs
553
+ /**
554
+ * Is the value `undefined`, `null`, or a whitespace-only string?
555
+ * @param value Value to check
556
+ * @returns `true` if the value is nullable or a whitespace-only string, otherwise `false`
557
+ */
558
+ function isNullableOrWhitespace(value) {
559
+ return value == null || EXPRESSION_WHITESPACE$1.test(getString(value));
560
+ }
561
+ const EXPRESSION_WHITESPACE$1 = /^\s*$/;
562
+ //#endregion
563
+ //#region node_modules/@oscarpalmer/mora/dist/value/store.mjs
371
564
  var Store = class extends Reactive {
372
565
  #keyed = /* @__PURE__ */ new Map();
373
566
  constructor(value, options) {
374
- super(NAME_STORE, new Proxy(value, { set: (target, property, value$1) => setValueInProxy({
567
+ super(NAME_STORE, new Proxy(value, { set: (target, property, value) => setValueInProxy({
375
568
  target,
376
569
  property,
377
- value: value$1,
570
+ value,
378
571
  isArray: false,
379
572
  state: this.state
380
573
  }) }), options);
@@ -382,6 +575,12 @@ var Store = class extends Reactive {
382
575
  get(key) {
383
576
  return isKey(key) ? getReactiveValueInProxy(this, this.#keyed, key, false).get() : getValue$1(this.state);
384
577
  }
578
+ /**
579
+ * Notify dependents of changes
580
+ *
581
+ * _This bypasses equality checks and will immediately notify dependents.
582
+ * Use this only if you're modifying nested data that would be ignored by equality checks._
583
+ */
385
584
  notify() {
386
585
  emityProxyValues(this.state, this.#keyed);
387
586
  }
@@ -390,95 +589,108 @@ var Store = class extends Reactive {
390
589
  }
391
590
  set(first, second) {
392
591
  if (isKey(first)) this.state.value[first] = second;
393
- else if (first == null || isPlainObject$2(first)) setProxyValue(this.state.value, first ?? {});
592
+ else if (first == null || isPlainObject(first)) setProxyValue(this.state.value, first ?? {});
394
593
  }
395
594
  subscribe(first, second) {
396
595
  if (isKey(first) && typeof second === "function") return getReactiveValueInProxy(this, this.#keyed, first, false).subscribe(second);
397
596
  return typeof first === "function" ? subscribe(this.state, first) : noop$1;
398
597
  }
598
+ /**
599
+ * Update the value _(based on the current value)_
600
+ * @param callback Callback to update the value
601
+ */
399
602
  update(callback) {
400
603
  const updated = callback({ ...this.state.value });
401
- if (updated == null || isPlainObject$2(updated)) setProxyValue(this.state.value, updated ?? {});
604
+ if (updated == null || isPlainObject(updated)) setProxyValue(this.state.value, updated ?? {});
402
605
  }
403
606
  };
607
+ /**
608
+ * Create a reactive store
609
+ * @param value Initial object value
610
+ * @param options Reactivity options
611
+ * @returns Reactive store
612
+ */
404
613
  function store(value, options) {
405
- return new Store(isPlainObject$2(value) ? value : {}, options);
406
- }
407
- function isPlainObject$1(value) {
408
- if (value === null || typeof value !== "object") return false;
409
- if (Symbol.toStringTag in value || Symbol.iterator in value) return false;
410
- const prototype = Object.getPrototypeOf(value);
411
- return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
412
- }
413
- new Set([
414
- Int8Array,
415
- Uint8Array,
416
- Uint8ClampedArray,
417
- Int16Array,
418
- Uint16Array,
419
- Int32Array,
420
- Uint32Array,
421
- Float32Array,
422
- Float64Array,
423
- BigInt64Array,
424
- BigUint64Array
425
- ]);
426
- function getString$1(value) {
427
- if (typeof value === "string") return value;
428
- if (value == null) return "";
429
- if (typeof value === "function") return getString$1(value());
430
- if (typeof value !== "object") return String(value);
431
- const asString = String(value.valueOf?.() ?? value);
432
- return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
433
- }
434
- function isNullableOrWhitespace(value) {
435
- return value == null || EXPRESSION_WHITESPACE$1.test(getString$1(value));
436
- }
437
- var EXPRESSION_WHITESPACE$1 = /^\s*$/;
614
+ return new Store(isPlainObject(value) ? value : {}, options);
615
+ }
616
+ //#endregion
617
+ //#region node_modules/@oscarpalmer/toretto/dist/internal/is.mjs
618
+ /**
619
+ * Is the value an event target?
620
+ * @param value Value to check
621
+ * @returns `true` if it's an event target, otherwise `false`
622
+ */
438
623
  function isEventTarget(value) {
439
624
  return typeof value === "object" && value != null && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function" && typeof value.dispatchEvent === "function";
440
625
  }
626
+ /**
627
+ * Is the value an HTML or SVG element?
628
+ * @param value Value to check
629
+ * @returns `true` if it's an HTML or SVG element, otherwise `false`
630
+ */
441
631
  function isHTMLOrSVGElement(value) {
442
632
  return value instanceof HTMLElement || value instanceof SVGElement;
443
633
  }
444
- function getString(value) {
445
- if (typeof value === "string") return value;
446
- if (value == null) return "";
447
- if (typeof value === "function") return getString(value());
448
- if (typeof value !== "object") return String(value);
449
- const asString = String(value.valueOf?.() ?? value);
450
- return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
451
- }
452
- function isPlainObject(value) {
453
- if (value === null || typeof value !== "object") return false;
454
- if (Symbol.toStringTag in value || Symbol.iterator in value) return false;
455
- const prototype = Object.getPrototypeOf(value);
456
- return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
634
+ //#endregion
635
+ //#region node_modules/@oscarpalmer/toretto/dist/is.mjs
636
+ /**
637
+ * Is the value a child node?
638
+ * @param value Value to check
639
+ * @returns `true` if it's a child node, otherwise `false`
640
+ */
641
+ function isChildNode(value) {
642
+ return value instanceof Node && CHILD_NODE_TYPES.has(value.nodeType);
457
643
  }
458
- new Set([
459
- Int8Array,
460
- Uint8Array,
461
- Uint8ClampedArray,
462
- Int16Array,
463
- Uint16Array,
464
- Int32Array,
465
- Uint32Array,
466
- Float32Array,
467
- Float64Array,
468
- BigInt64Array,
469
- BigUint64Array
644
+ const CHILD_NODE_TYPES = new Set([
645
+ Node.ELEMENT_NODE,
646
+ Node.TEXT_NODE,
647
+ Node.PROCESSING_INSTRUCTION_NODE,
648
+ Node.COMMENT_NODE,
649
+ Node.DOCUMENT_TYPE_NODE
470
650
  ]);
651
+ //#endregion
652
+ //#region node_modules/@oscarpalmer/toretto/dist/internal/element-value.mjs
653
+ function setElementValue(element, first, second, third, callback) {
654
+ if (!isHTMLOrSVGElement(element)) return;
655
+ if (typeof first === "string") setElementValues(element, first, second, third, callback);
656
+ else if (isAttribute(first)) setElementValues(element, first.name, first.value, third, callback);
657
+ }
658
+ function setElementValues(element, first, second, third, callback) {
659
+ if (!isHTMLOrSVGElement(element)) return;
660
+ if (typeof first === "string") {
661
+ callback(element, first, second, third);
662
+ return;
663
+ }
664
+ const isArray = Array.isArray(first);
665
+ if (!isArray && !(typeof first === "object" && first !== null)) return;
666
+ const entries = isArray ? first : Object.entries(first).map(([name, value]) => ({
667
+ name,
668
+ value
669
+ }));
670
+ const { length } = entries;
671
+ for (let index = 0; index < length; index += 1) {
672
+ const entry = entries[index];
673
+ if (typeof entry === "object" && typeof entry?.name === "string") callback(element, entry.name, entry.value, third);
674
+ }
675
+ }
676
+ function updateElementValue(element, key, value, set, remove, isBoolean, json) {
677
+ if (isBoolean ? value == null : isNullableOrWhitespace(value)) remove.call(element, key);
678
+ else set.call(element, key, json ? JSON.stringify(value) : String(value));
679
+ }
680
+ //#endregion
681
+ //#region node_modules/@oscarpalmer/toretto/dist/internal/attribute.mjs
471
682
  function badAttributeHandler(name, value) {
472
- if (name == null || value == null) return true;
683
+ if (typeof name !== "string" || name.trim().length === 0 || typeof value !== "string") return true;
473
684
  if (EXPRESSION_CLOBBERED_NAME.test(name) && (value in document || value in formElement) || EXPRESSION_EVENT_NAME$1.test(name)) return true;
474
685
  if (EXPRESSION_SKIP_NAME.test(name) || EXPRESSION_URI_VALUE.test(value) || isValidSourceAttribute(name, value)) return false;
475
686
  return EXPRESSION_DATA_OR_SCRIPT.test(value);
476
687
  }
477
688
  function booleanAttributeHandler(name, value) {
478
- if (name == null || value == null) return true;
479
- if (!booleanAttributesSet.has(name)) return false;
480
- const normalized = value.toLowerCase().trim();
481
- return !(normalized.length === 0 || normalized === name);
689
+ if (typeof name !== "string" || name.trim().length === 0 || typeof value !== "string") return true;
690
+ const normalizedName = name.toLowerCase();
691
+ if (!booleanAttributesSet.has(normalizedName)) return false;
692
+ const normalized = value.toLowerCase();
693
+ return !(normalized.length === 0 || normalized === normalizedName);
482
694
  }
483
695
  function decodeAttribute(value) {
484
696
  textArea ??= document.createElement("textarea");
@@ -499,7 +711,7 @@ function handleAttribute(callback, decode, first, second) {
499
711
  return callback(name, value?.replace(EXPRESSION_WHITESPACE, ""));
500
712
  }
501
713
  function isAttribute(value) {
502
- return value instanceof Attr || isPlainObject(value) && typeof value.name === "string" && typeof value.value === "string";
714
+ return value instanceof Attr || isPlainObject(value) && typeof value.name === "string" && "value" in value;
503
715
  }
504
716
  function _isBadAttribute(first, second, decode) {
505
717
  return handleAttribute(badAttributeHandler, decode, first, second);
@@ -513,35 +725,33 @@ function _isEmptyNonBooleanAttribute(first, second, decode) {
513
725
  function _isInvalidBooleanAttribute(first, second, decode) {
514
726
  return handleAttribute(booleanAttributeHandler, decode, first, second);
515
727
  }
516
- function isProperty(value) {
517
- return isPlainObject(value) && typeof value.name === "string";
518
- }
519
728
  function isValidSourceAttribute(name, value) {
520
729
  return EXPRESSION_SOURCE_NAME.test(name) && EXPRESSION_SOURCE_VALUE.test(value);
521
730
  }
522
- function updateAttribute(element, name, value) {
523
- const isBoolean = booleanAttributesSet.has(name.toLowerCase());
524
- if (isBoolean) updateProperty$1(element, name, value);
525
- if (isBoolean ? value !== true : value == null) element.removeAttribute(name);
526
- else element.setAttribute(name, isBoolean ? "" : getString(value));
527
- }
528
- function updateProperty$1(element, name, value) {
529
- const actual = name.toLowerCase();
530
- element[actual] = value === "" || typeof value === "string" && value.toLowerCase() === actual || value === true;
531
- }
532
- function updateValue$1(element, first, second) {
533
- if (!isHTMLOrSVGElement(element)) return;
534
- if (isProperty(first)) updateAttribute(element, first.name, first.value);
535
- else if (typeof first === "string") updateAttribute(element, first, second);
536
- }
537
- var EXPRESSION_CLOBBERED_NAME = /^(id|name)$/i;
538
- var EXPRESSION_DATA_OR_SCRIPT = /^(?:data|\w+script):/i;
539
- var EXPRESSION_EVENT_NAME$1 = /^on/i;
540
- var EXPRESSION_SKIP_NAME = /^(aria-[-\w]+|data-[-\w.\u00B7-\uFFFF]+)$/i;
541
- var EXPRESSION_SOURCE_NAME = /^src$/i;
542
- var EXPRESSION_SOURCE_VALUE = /^data:/i;
543
- var EXPRESSION_URI_VALUE = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i;
544
- var EXPRESSION_WHITESPACE = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;
731
+ function updateAttribute(element, name, value, dispatch) {
732
+ const normalizedName = name.toLowerCase();
733
+ const isBoolean = booleanAttributesSet.has(normalizedName);
734
+ const next = isBoolean ? value === true || typeof value === "string" && (value === "" || value.toLowerCase() === normalizedName) : value == null ? "" : value;
735
+ if (name in element) updateProperty$1(element, normalizedName, next, dispatch);
736
+ updateElementValue(element, name, isBoolean ? next ? "" : null : value, element.setAttribute, element.removeAttribute, isBoolean, false);
737
+ }
738
+ function updateProperty$1(element, name, value, dispatch) {
739
+ if (Object.is(element[name], value)) return;
740
+ element[name] = value;
741
+ const event = dispatch !== false && elementEvents[element.tagName]?.[name];
742
+ if (typeof event === "string") element.dispatchEvent(new Event(event, { bubbles: true }));
743
+ }
744
+ const EXPRESSION_CLOBBERED_NAME = /^(id|name)$/i;
745
+ const EXPRESSION_DATA_OR_SCRIPT = /^(?:data|\w+script):/i;
746
+ const EXPRESSION_EVENT_NAME$1 = /^on/i;
747
+ const EXPRESSION_SKIP_NAME = /^(aria-[-\w]+|data-[-\w.\u00B7-\uFFFF]+)$/i;
748
+ const EXPRESSION_SOURCE_NAME = /^src$/i;
749
+ const EXPRESSION_SOURCE_VALUE = /^data:/i;
750
+ const EXPRESSION_URI_VALUE = /^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i;
751
+ const EXPRESSION_WHITESPACE = /[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;
752
+ /**
753
+ * List of boolean attributes
754
+ */
545
755
  const booleanAttributes = Object.freeze([
546
756
  "async",
547
757
  "autofocus",
@@ -568,15 +778,25 @@ const booleanAttributes = Object.freeze([
568
778
  "reversed",
569
779
  "selected"
570
780
  ]);
571
- var booleanAttributesSet = new Set(booleanAttributes);
572
- var formElement = document.createElement("form");
573
- var textArea;
574
- function setAttribute$1(element, first, second) {
575
- updateValue$1(element, first, second);
576
- }
577
- function setProperty(element, first, second) {
578
- updateValue$1(element, first, second);
579
- }
781
+ const booleanAttributesSet = new Set(booleanAttributes);
782
+ const elementEvents = {
783
+ DETAILS: { open: "toggle" },
784
+ INPUT: {
785
+ checked: "change",
786
+ value: "input"
787
+ },
788
+ SELECT: { value: "change" },
789
+ TEXTAREA: { value: "input" }
790
+ };
791
+ const formElement = document.createElement("form");
792
+ let textArea;
793
+ //#endregion
794
+ //#region node_modules/@oscarpalmer/toretto/dist/attribute/set.mjs
795
+ function setAttribute$1(element, first, second, third) {
796
+ setElementValue(element, first, second, third, updateAttribute);
797
+ }
798
+ //#endregion
799
+ //#region node_modules/@oscarpalmer/toretto/dist/html/sanitize.mjs
580
800
  function handleElement(element, depth) {
581
801
  if (depth === 0) {
582
802
  const removable = element.querySelectorAll(REMOVE_SELECTOR);
@@ -584,6 +804,11 @@ function handleElement(element, depth) {
584
804
  }
585
805
  sanitizeAttributes(element, [...element.attributes]);
586
806
  }
807
+ /**
808
+ * Is the element clobbered?
809
+ *
810
+ * Thanks, DOMPurify _(https://github.com/cure53/DOMPurify)_
811
+ */
587
812
  function isClobbered(value) {
588
813
  return value instanceof HTMLFormElement && (typeof value.nodeName !== "string" || typeof value.textContent !== "string" || typeof value.removeChild !== "function" || !(value.attributes instanceof NamedNodeMap) || typeof value.removeAttribute !== "function" || typeof value.setAttribute !== "function" || typeof value.namespaceURI !== "string" || typeof value.insertBefore !== "function" || typeof value.hasChildNodes !== "function");
589
814
  }
@@ -627,8 +852,10 @@ function sanitizeNodes(nodes, depth) {
627
852
  }
628
853
  return nodes;
629
854
  }
630
- var COMMENT_HARMFUL = /<[/\w]/g;
631
- var REMOVE_SELECTOR = "script, toretto-temporary";
855
+ const COMMENT_HARMFUL = /<[/\w]/g;
856
+ const REMOVE_SELECTOR = "script, toretto-temporary";
857
+ //#endregion
858
+ //#region node_modules/@oscarpalmer/toretto/dist/html/index.mjs
632
859
  function createHtml(value) {
633
860
  const parsed = getParser().parseFromString(getHtml(value), PARSE_TYPE_HTML);
634
861
  parsed.body.normalize();
@@ -666,7 +893,7 @@ function getTemplate(value, options) {
666
893
  const element = EXPRESSION_ID.test(value) ? document.querySelector(`#${value}`) : null;
667
894
  return createTemplate(element instanceof HTMLTemplateElement ? element : value, options);
668
895
  }
669
- var html$1 = ((value, options) => {
896
+ const html$1 = ((value, options) => {
670
897
  return getNodes(value, getOptions$1(options));
671
898
  });
672
899
  html$1.clear = () => {
@@ -683,22 +910,32 @@ html$1.remove = (template) => {
683
910
  }
684
911
  templates = updated;
685
912
  };
686
- var EXPRESSION_ID = /^[a-z][\w-]*$/i;
687
- var PARSE_TYPE_HTML = "text/html";
688
- var TEMPLATE_TAG = "template";
689
- var TEMPORARY_ELEMENT = "<toretto-temporary></toretto-temporary>";
690
- var parser;
691
- var templates = {};
692
- const ATTRIBUTE_CLASS_PREFIX_LENGTH = 6;
913
+ const EXPRESSION_ID = /^[a-z][\w-]*$/i;
914
+ const PARSE_TYPE_HTML = "text/html";
915
+ const TEMPLATE_TAG = "template";
916
+ const TEMPORARY_ELEMENT = "<toretto-temporary></toretto-temporary>";
917
+ let parser;
918
+ let templates = {};
919
+ //#endregion
920
+ //#region src/constants.ts
921
+ const ARRAY_COMPARISON_ADDED = "added";
922
+ const ARRAY_COMPARISON_DISSIMILAR = "dissimilar";
923
+ const ARRAY_COMPARISON_REMOVED = "removed";
924
+ const ERROR_FRAGMENT = "Fragment function must return a Fragment instance";
925
+ const ERROR_IDENTIFIER_DUPLICATE = "Duplicate identifier found: '<id>'";
926
+ const ERROR_IDENTIFIER_TYPE = "Identifier cannot be null or undefined";
927
+ const EVENT_CHANGE = "change";
928
+ const EVENT_INPUT = "input";
929
+ const EVENT_SUBMIT = "submit";
693
930
  const EVENT_DEFAULTS = {
694
931
  A: "click",
695
932
  BUTTON: "click",
696
933
  DETAILS: "toggle",
697
- FORM: "submit",
698
- SELECT: "change",
699
- TEXTAREA: "input"
934
+ FORM: EVENT_SUBMIT,
935
+ SELECT: EVENT_CHANGE,
936
+ TEXTAREA: EVENT_INPUT
700
937
  };
701
- const EXPRESSION_ABYDON_ATTRIBUTE_FULL = /(@?\w+)="<!--abydon.(\d+)-->"/g;
938
+ const EXPRESSION_ABYDON_ATTRIBUTE_FULL = /(@?[\w-]+)="<!--abydon.(\d+)-->"/g;
702
939
  const EXPRESSION_ABYDON_ATTRIBUTE_PREFIX = /^_/;
703
940
  const EXPRESSION_ABYDON_CONTENT = /^@?abydon\.(\d+)@?$/;
704
941
  const EXPRESSION_ATTRIBUTE_CLASS = /^class\./;
@@ -713,12 +950,31 @@ const EXPRESSION_EVENT_PREFIX = /^@/;
713
950
  const EXPRESSION_PERIOD = /\./;
714
951
  const NAME_FRAGMENT = "$fragment";
715
952
  const NAME_FRAGMENTS = "$fragments";
953
+ const PROPERTY_CHECKED = "checked";
954
+ const PROPERTY_VALUE = "value";
955
+ //#endregion
956
+ //#region node_modules/@oscarpalmer/atoms/dist/string/index.mjs
957
+ /**
958
+ * Parse a JSON string into its proper value _(or `undefined` if it fails)_
959
+ * @param value JSON string to parse
960
+ * @param reviver Reviver function to transform the parsed values
961
+ * @returns Parsed value or `undefined` if parsing fails
962
+ */
963
+ function parse$1(value, reviver) {
964
+ try {
965
+ return JSON.parse(value, reviver);
966
+ } catch {
967
+ return;
968
+ }
969
+ }
970
+ //#endregion
971
+ //#region src/helpers/index.ts
716
972
  function compareArrays(first, second) {
717
973
  const firstIsLarger = first.length > second.length;
718
974
  const from = firstIsLarger ? first : second;
719
975
  const to = firstIsLarger ? second : first;
720
- if (!from.filter((key) => to.includes(key)).every((key, index) => to[index] === key)) return COMPARISON_DISSIMILAR;
721
- return firstIsLarger ? COMPARISON_REMOVED : COMPARISON_ADDED;
976
+ if (!from.filter((key) => to.includes(key)).every((key, index) => to[index] === key)) return ARRAY_COMPARISON_DISSIMILAR;
977
+ return firstIsLarger ? ARRAY_COMPARISON_REMOVED : ARRAY_COMPARISON_ADDED;
722
978
  }
723
979
  function isFragment(value) {
724
980
  return isNamed(value, NAME_FRAGMENT);
@@ -729,11 +985,13 @@ function isFragments(value) {
729
985
  function isNamed(value, name) {
730
986
  return typeof value === "object" && value != null && name in value && value[name] === true;
731
987
  }
732
- const COMPARISON_ADDED = "added";
733
- const COMPARISON_DISSIMILAR = "dissimilar";
734
- const COMPARISON_REMOVED = "removed";
988
+ //#endregion
989
+ //#region src/fragments.ts
735
990
  var Fragments = class {
736
991
  #state;
992
+ /**
993
+ * Fragment items
994
+ */
737
995
  get items() {
738
996
  return this.#state.mapped;
739
997
  }
@@ -762,13 +1020,13 @@ function handleItems(state, items) {
762
1020
  for (let index = 0; index < length; index += 1) {
763
1021
  const item = items[index];
764
1022
  const identifier = state.identify(item);
765
- if (identifier == null) throw new Error("Identifier cannot be null or undefined");
766
- const key = getString$1(identifier);
767
- if (keys.has(key)) throw new Error(`Duplicate identifier found: "${key}"`);
1023
+ if (identifier == null) throw new TypeError(ERROR_IDENTIFIER_TYPE);
1024
+ const key = getString(identifier);
1025
+ if (keys.has(key)) throw new Error(ERROR_IDENTIFIER_DUPLICATE.replace("<>", key));
768
1026
  let instance = state.instances[key];
769
1027
  if (instance == null) {
770
1028
  instance = state.fragment(item);
771
- if (!isFragment(instance)) throw new Error("Fragment function must return a Fragment instance");
1029
+ if (!isFragment(instance)) throw new Error(ERROR_FRAGMENT);
772
1030
  }
773
1031
  instance.identify(key);
774
1032
  state.instances[key] = instance;
@@ -802,20 +1060,15 @@ function updateFragments(state, active) {
802
1060
  active?.clear();
803
1061
  }
804
1062
  const states = /* @__PURE__ */ new WeakMap();
805
- function isChildNode(value) {
806
- return value instanceof Node && CHILD_NODE_TYPES.has(value.nodeType);
807
- }
808
- var CHILD_NODE_TYPES = new Set([
809
- Node.ELEMENT_NODE,
810
- Node.TEXT_NODE,
811
- Node.PROCESSING_INSTRUCTION_NODE,
812
- Node.COMMENT_NODE,
813
- Node.DOCUMENT_TYPE_NODE
814
- ]);
1063
+ //#endregion
1064
+ //#region src/helpers/dom.ts
815
1065
  function createNodes(value) {
816
1066
  if (isFragment(value)) return value.get();
817
1067
  if (isChildNode(value)) return [value];
818
- return [new Text(getString$1(value))];
1068
+ return [new Text(getString(value))];
1069
+ }
1070
+ function isInputElement(node) {
1071
+ return node instanceof HTMLInputElement || node instanceof HTMLSelectElement || node instanceof HTMLTextAreaElement;
819
1072
  }
820
1073
  function removeNodes(nodes) {
821
1074
  const { length } = nodes;
@@ -826,9 +1079,13 @@ function replaceNodes(from, to) {
826
1079
  const { length } = from;
827
1080
  for (let index = 1; index < length; index += 1) from[index].remove();
828
1081
  }
1082
+ //#endregion
1083
+ //#region node_modules/@oscarpalmer/toretto/dist/internal/get-value.mjs
829
1084
  function getBoolean(value, defaultValue) {
830
1085
  return typeof value === "boolean" ? value : defaultValue ?? false;
831
1086
  }
1087
+ //#endregion
1088
+ //#region node_modules/@oscarpalmer/toretto/dist/event/delegation.mjs
832
1089
  function addDelegatedHandler(doc, type, name, passive) {
833
1090
  if (DELEGATED.has(name)) return;
834
1091
  DELEGATED.add(name);
@@ -880,11 +1137,11 @@ function removeDelegatedListener(target, name, listener) {
880
1137
  if (handlers.size === 0) target[name] = void 0;
881
1138
  return true;
882
1139
  }
883
- var DELEGATED = /* @__PURE__ */ new Set();
884
- var EVENT_PREFIX = "@";
885
- var EVENT_SUFFIX_ACTIVE = ":active";
886
- var EVENT_SUFFIX_PASSIVE = ":passive";
887
- var EVENT_TYPES = new Set([
1140
+ const DELEGATED = /* @__PURE__ */ new Set();
1141
+ const EVENT_PREFIX = "@";
1142
+ const EVENT_SUFFIX_ACTIVE = ":active";
1143
+ const EVENT_SUFFIX_PASSIVE = ":passive";
1144
+ const EVENT_TYPES = new Set([
888
1145
  "beforeinput",
889
1146
  "click",
890
1147
  "dblclick",
@@ -908,26 +1165,16 @@ var EVENT_TYPES = new Set([
908
1165
  "touchmove",
909
1166
  "touchstart"
910
1167
  ]);
911
- var HANDLER_ACTIVE = delegatedEventHandler.bind(false);
912
- var HANDLER_PASSIVE = delegatedEventHandler.bind(true);
1168
+ const HANDLER_ACTIVE = delegatedEventHandler.bind(false);
1169
+ const HANDLER_PASSIVE = delegatedEventHandler.bind(true);
1170
+ //#endregion
1171
+ //#region node_modules/@oscarpalmer/atoms/dist/internal/function/misc.mjs
1172
+ /**
1173
+ * A function that does nothing, which can be useful, I guess…
1174
+ */
913
1175
  function noop() {}
914
- function calculate() {
915
- return new Promise((resolve) => {
916
- const values = [];
917
- let last;
918
- function step(now) {
919
- if (last != null) values.push(now - last);
920
- last = now;
921
- if (values.length >= CALCULATION_TOTAL) resolve(values.sort().slice(CALCULATION_TRIM_PART, -CALCULATION_TRIM_PART).reduce((first, second) => first + second, 0) / (values.length - CALCULATION_TRIM_TOTAL));
922
- else requestAnimationFrame(step);
923
- }
924
- requestAnimationFrame(step);
925
- });
926
- }
927
- var CALCULATION_TOTAL = 10;
928
- var CALCULATION_TRIM_PART = 2;
929
- var CALCULATION_TRIM_TOTAL = 4;
930
- calculate().then((value) => {});
1176
+ //#endregion
1177
+ //#region node_modules/@oscarpalmer/toretto/dist/event/index.mjs
931
1178
  function createEventOptions(options) {
932
1179
  return {
933
1180
  capture: getBoolean(options?.capture),
@@ -947,6 +1194,8 @@ function on(target, type, listener, options) {
947
1194
  target.removeEventListener(type, listener, extended);
948
1195
  };
949
1196
  }
1197
+ //#endregion
1198
+ //#region src/node/event.ts
950
1199
  function getOptions(options) {
951
1200
  const parts = options.split(":");
952
1201
  return {
@@ -958,8 +1207,8 @@ function getOptions(options) {
958
1207
  function getType(element, type) {
959
1208
  if (type !== "on") return type;
960
1209
  if (element instanceof HTMLInputElement) {
961
- if (EXPRESSION_EVENT_CHANGE_TYPES.test(element.type)) return "change";
962
- return element.type === "submit" ? "submit" : "input";
1210
+ if (EXPRESSION_EVENT_CHANGE_TYPES.test(element.type)) return EVENT_CHANGE;
1211
+ return element.type === "submit" ? EVENT_SUBMIT : EVENT_INPUT;
963
1212
  }
964
1213
  return EVENT_DEFAULTS[element.tagName] ?? type;
965
1214
  }
@@ -967,9 +1216,13 @@ function mapEvent(element, name, value) {
967
1216
  const [, type, options] = EXPRESSION_EVENT_NAME.exec(name) ?? [];
968
1217
  if (type != null && typeof value === "function") on(element, getType(element, type), value, getOptions(options ?? ""));
969
1218
  }
1219
+ //#endregion
1220
+ //#region node_modules/@oscarpalmer/toretto/dist/attribute/index.mjs
970
1221
  function isBooleanAttribute(first) {
971
1222
  return _isBooleanAttribute(first, true);
972
1223
  }
1224
+ //#endregion
1225
+ //#region src/node/attribute/value.ts
973
1226
  function getCallback(element, name) {
974
1227
  if (isBooleanAttribute(name) && name in element) return name === "checked" ? updateChecked : updateProperty;
975
1228
  return name === "value" ? updateValue : setAttribute$1;
@@ -988,20 +1241,20 @@ function setAttribute(data, element, name, value) {
988
1241
  }
989
1242
  }
990
1243
  function setClasses(data, element, name, value) {
991
- function update(value$1) {
992
- if (value$1 === true) element.classList.add(...classes);
1244
+ function update(value) {
1245
+ if (value === true) element.classList.add(...classes);
993
1246
  else element.classList.remove(...classes);
994
1247
  }
995
- const classes = name.slice(ATTRIBUTE_CLASS_PREFIX_LENGTH).split(".");
1248
+ const classes = name.slice(6).split(".");
996
1249
  if (isReactive(value)) data.mora.subscribers.add(value.subscribe(update));
997
1250
  else update(value);
998
1251
  }
999
1252
  function setStyle(data, element, name, value) {
1000
1253
  const [, property, unit] = EXPRESSION_ATTRIBUTE_STYLE_FULL.exec(name) ?? [];
1001
1254
  if (property == null) return;
1002
- function update(value$1) {
1003
- if (value$1 == null || value$1 === false || value$1 === true && unit == null) element.style.removeProperty(property);
1004
- else element.style.setProperty(property, value$1 === true ? unit : String(value$1));
1255
+ function update(value) {
1256
+ if (value == null || value === false || value === true && unit == null) element.style.removeProperty(property);
1257
+ else element.style.setProperty(property, value === true ? unit : String(value));
1005
1258
  }
1006
1259
  if (isReactive(value)) data.mora.subscribers.add(value.subscribe(update));
1007
1260
  else update(value);
@@ -1014,20 +1267,23 @@ function setValue(data, element, name, value) {
1014
1267
  else callback(element, name, value);
1015
1268
  }
1016
1269
  function updateChecked(element, name, value) {
1017
- updateElement("change", "checked", element, name, value, value === true);
1270
+ updateElement(EVENT_CHANGE, PROPERTY_CHECKED, element, name, value, value === true);
1018
1271
  }
1019
1272
  function updateElement(event, property, element, name, value, next) {
1020
1273
  if (!(property in element) || element[property] === next) return;
1021
1274
  setAttribute$1(element, name, value);
1275
+ if (element[property] === next) return;
1022
1276
  element[property] = next;
1023
1277
  element.dispatchEvent(new Event(event, { bubbles: true }));
1024
1278
  }
1025
1279
  function updateProperty(element, name, value) {
1026
- setProperty(element, name, value === true);
1280
+ setAttribute$1(element, name, value === true);
1027
1281
  }
1028
1282
  function updateValue(element, name, value) {
1029
- updateElement(element instanceof HTMLSelectElement ? "change" : "input", "value", element, name, value, String(value));
1283
+ updateElement(element instanceof HTMLSelectElement ? EVENT_CHANGE : EVENT_INPUT, PROPERTY_VALUE, element, name, value, String(value));
1030
1284
  }
1285
+ //#endregion
1286
+ //#region src/node/attribute/index.ts
1031
1287
  function getValue(data, original) {
1032
1288
  const matches = EXPRESSION_ABYDON_CONTENT.exec(original ?? "");
1033
1289
  return matches == null ? original : data.values[+matches[1]];
@@ -1056,12 +1312,17 @@ function mapAttributes(data, element) {
1056
1312
  function mapValue$1(data, element, name, value) {
1057
1313
  if (typeof value === "function") setComputedAttribute(data, element, name, value);
1058
1314
  else setAttribute(data, element, name, value);
1315
+ if (name === "value" && isInputElement(element) && isSignal(value)) mapEvent(element, "@on", () => {
1316
+ value.set(parse$1(element.value) ?? element.value);
1317
+ });
1059
1318
  }
1060
1319
  function setComputedAttribute(data, element, name, callback) {
1061
1320
  const value = computed(callback);
1062
1321
  data.mora.values.add(value);
1063
1322
  setAttribute(data, element, name, value);
1064
1323
  }
1324
+ //#endregion
1325
+ //#region src/node/value.ts
1065
1326
  function addToArray(identifiers, items, nodes, added) {
1066
1327
  let position = nodes[0];
1067
1328
  const before = added && !identifiers.previous.has(items.templates[0].identifier);
@@ -1083,7 +1344,7 @@ function handleArray(identifiers, items, nodes) {
1083
1344
  if (comparison !== "removed") addToArray(identifiers, {
1084
1345
  ...items,
1085
1346
  next
1086
- }, nodes, comparison === "added");
1347
+ }, nodes, comparison === ARRAY_COMPARISON_ADDED);
1087
1348
  const toRemove = items.fragments?.filter((fragment) => !identifiers.next.has(fragment.identifier)) ?? [];
1088
1349
  const { length } = toRemove;
1089
1350
  for (let index = 0; index < length; index += 1) toRemove[index].remove();
@@ -1092,10 +1353,10 @@ function handleArray(identifiers, items, nodes) {
1092
1353
  nodes: next.flatMap((fragment) => fragment.get())
1093
1354
  };
1094
1355
  }
1095
- function removeFragments(fragments$1) {
1096
- if (fragments$1 != null) {
1097
- const { length } = fragments$1;
1098
- for (let index = 0; index < length; index += 1) fragments$1[index].remove();
1356
+ function removeFragments(fragments) {
1357
+ if (fragments != null) {
1358
+ const { length } = fragments;
1359
+ for (let index = 0; index < length; index += 1) fragments[index].remove();
1099
1360
  }
1100
1361
  }
1101
1362
  function replaceText(item, comment, isNullable) {
@@ -1106,20 +1367,20 @@ function replaceText(item, comment, isNullable) {
1106
1367
  }
1107
1368
  function setArray(item, comment, value) {
1108
1369
  if (value.length === 0) return { nodes: setText(item, comment, value) };
1109
- let templates$1 = value.filter((item$1) => isFragment(item$1) && item$1.identifier != null);
1110
- const next = templates$1.map((fragment) => fragment.identifier);
1370
+ let templates = value.filter((item) => isFragment(item) && item.identifier != null);
1371
+ const next = templates.map((fragment) => fragment.identifier);
1111
1372
  const previous = item.fragments?.map((fragment) => fragment.identifier) ?? [];
1112
- if (new Set(next).size !== templates$1.length) templates$1 = [];
1113
- const noTemplates = templates$1.length === 0;
1373
+ if (new Set(next).size !== templates.length) templates = [];
1374
+ const noTemplates = templates.length === 0;
1114
1375
  if (noTemplates || item.nodes == null || previous.some((identifier) => identifier == null)) return {
1115
- fragments: noTemplates ? void 0 : templates$1,
1116
- nodes: setNodes(item, comment, noTemplates ? value.flatMap((item$1) => createNodes(item$1)) : templates$1.flatMap((template) => template.get()))
1376
+ fragments: noTemplates ? void 0 : templates,
1377
+ nodes: setNodes(item, comment, noTemplates ? value.flatMap((item) => createNodes(item)) : templates.flatMap((template) => template.get()))
1117
1378
  };
1118
1379
  return handleArray({
1119
1380
  next: new Set(next),
1120
1381
  previous: new Set(previous)
1121
1382
  }, {
1122
- templates: templates$1,
1383
+ templates,
1123
1384
  fragments: item.fragments ?? []
1124
1385
  }, item.nodes);
1125
1386
  }
@@ -1132,7 +1393,7 @@ function setNodes(item, comment, next) {
1132
1393
  return next;
1133
1394
  }
1134
1395
  function setReactiveValue(data, comment, reactive) {
1135
- let item = data.items.find((item$1) => item$1.nodes?.includes(comment));
1396
+ let item = data.items.find((item) => item.nodes?.includes(comment));
1136
1397
  item ??= {};
1137
1398
  item.text = new Text();
1138
1399
  data.mora.subscribers.add(reactive.subscribe((value) => {
@@ -1156,7 +1417,7 @@ function setReactiveValueForSingle(item, comment, value) {
1156
1417
  }
1157
1418
  function setText(item, comment, value) {
1158
1419
  const isNullable = isNullableOrWhitespace(value);
1159
- if (item.text != null) item.text.textContent = isNullable ? "" : getString$1(value);
1420
+ if (item.text != null) item.text.textContent = isNullable ? "" : getString(value);
1160
1421
  let result = false;
1161
1422
  if (item.nodes != null) {
1162
1423
  replaceText(item, comment, isNullable);
@@ -1169,6 +1430,8 @@ function setText(item, comment, value) {
1169
1430
  removeFragments(item.fragments);
1170
1431
  if (result) return item.text == null ? [] : [item.text];
1171
1432
  }
1433
+ //#endregion
1434
+ //#region src/node/index.ts
1172
1435
  function mapNode(data, comment) {
1173
1436
  const matches = EXPRESSION_ABYDON_CONTENT.exec(comment.textContent ?? "");
1174
1437
  const value = matches == null ? null : data.values[+matches[1]];
@@ -1204,7 +1467,7 @@ function mapValue(data, comment, value) {
1204
1467
  }
1205
1468
  }
1206
1469
  function replaceComment(data, comment, value) {
1207
- const item = data.items.find((item$1) => item$1.nodes?.includes(comment));
1470
+ const item = data.items.find((item) => item.nodes?.includes(comment));
1208
1471
  const nodes = createNodes(value);
1209
1472
  if (item != null) {
1210
1473
  item.fragments = isFragment(value) ? [value] : void 0;
@@ -1217,6 +1480,8 @@ function setComputedValue(data, comment, callback) {
1217
1480
  data.mora.values.add(value);
1218
1481
  setReactiveValue(data, comment, value);
1219
1482
  }
1483
+ //#endregion
1484
+ //#region src/parse.ts
1220
1485
  function handleExpression(data, prefix, expression) {
1221
1486
  if (Array.isArray(expression)) {
1222
1487
  const { length } = expression;
@@ -1243,12 +1508,17 @@ function transformAttribute(_, name, index) {
1243
1508
  function transformExpression(prefix, index) {
1244
1509
  return `${prefix}<!--abydon.${index}-->`;
1245
1510
  }
1511
+ //#endregion
1512
+ //#region src/fragment.ts
1246
1513
  var Fragment = class {
1247
1514
  #data;
1248
1515
  #configuration = {
1249
1516
  identifier: void 0,
1250
1517
  cache: true
1251
1518
  };
1519
+ /**
1520
+ * Fragment identifier
1521
+ */
1252
1522
  get identifier() {
1253
1523
  return this.#configuration.identifier;
1254
1524
  }
@@ -1265,15 +1535,28 @@ var Fragment = class {
1265
1535
  values: []
1266
1536
  };
1267
1537
  }
1538
+ /**
1539
+ * Append the fragment to the given element
1540
+ * @param element Element to append to
1541
+ */
1268
1542
  appendTo(element) {
1269
1543
  element.append(...this.get());
1270
1544
  }
1545
+ /**
1546
+ * Configure the fragment
1547
+ * @param configuration Configuration options
1548
+ * @returns Fragment
1549
+ */
1271
1550
  configure(configuration) {
1272
- const actual = isPlainObject$1(configuration) ? configuration : {};
1551
+ const actual = isPlainObject(configuration) ? configuration : {};
1273
1552
  if ("identifier" in actual) this.#configuration.identifier = actual.identifier;
1274
1553
  if (typeof actual.cache === "boolean") this.#configuration.cache = actual.cache;
1275
1554
  return this;
1276
1555
  }
1556
+ /**
1557
+ * Get a list of the fragment's nodes
1558
+ * @returns List of nodes
1559
+ */
1277
1560
  get() {
1278
1561
  const data = this.#data;
1279
1562
  if (data.items.length === 0) {
@@ -1283,10 +1566,21 @@ var Fragment = class {
1283
1566
  }
1284
1567
  return data.items.flatMap((item) => item.fragments?.flatMap((fragment) => fragment.get()) ?? item.nodes ?? []);
1285
1568
  }
1569
+ /**
1570
+ * Set an identifier for the fragment
1571
+ *
1572
+ * _An identifier can be used to uniquely identify a fragment,
1573
+ * which helps prevent re-rendering in certain scenarios._
1574
+ * @param identifier Identifier
1575
+ * @returns Fragment
1576
+ */
1286
1577
  identify(identifier) {
1287
1578
  this.#configuration.identifier = identifier;
1288
1579
  return this;
1289
1580
  }
1581
+ /**
1582
+ * Remove the fragment from the DOM
1583
+ */
1290
1584
  remove() {
1291
1585
  removeFragment(this.#data);
1292
1586
  }
@@ -1295,9 +1589,9 @@ function removeFragment(data) {
1295
1589
  removeMora(data);
1296
1590
  let { length } = data.items;
1297
1591
  for (let index = 0; index < length; index += 1) {
1298
- const { fragments: fragments$1, nodes } = data.items[index];
1299
- const fragmentsLength = fragments$1?.length ?? 0;
1300
- for (let fragmentIndex = 0; fragmentIndex < fragmentsLength; fragmentIndex += 1) fragments$1?.[fragmentIndex]?.remove();
1592
+ const { fragments, nodes } = data.items[index];
1593
+ const fragmentsLength = fragments?.length ?? 0;
1594
+ for (let fragmentIndex = 0; fragmentIndex < fragmentsLength; fragmentIndex += 1) fragments?.[fragmentIndex]?.remove();
1301
1595
  removeNodes(nodes ?? []);
1302
1596
  }
1303
1597
  data.items.length = 0;
@@ -1311,12 +1605,26 @@ function removeMora(data) {
1311
1605
  const unsubscribers = [...data.mora.subscribers];
1312
1606
  data.mora.subscribers.clear();
1313
1607
  data.mora.values.clear();
1314
- for (const unsubscribe$1 of unsubscribers) unsubscribe$1();
1315
- }
1316
- function fragments(array$1, identify, fragment) {
1317
- return new Fragments(array$1, identify, fragment);
1318
- }
1608
+ for (const unsubscribe of unsubscribers) unsubscribe();
1609
+ }
1610
+ //#endregion
1611
+ //#region src/index.ts
1612
+ /**
1613
+ * Create Fragments from a reactive array
1614
+ * @param array Reactive array
1615
+ * @param identify Function to identify item
1616
+ * @param fragment Function to create fragment from item
1617
+ * @returns Fragments
1618
+ */
1619
+ function fragments(array, identify, fragment) {
1620
+ return new Fragments(array, identify, fragment);
1621
+ }
1622
+ /**
1623
+ * Create Fragment from a template
1624
+ * @returns Fragment
1625
+ */
1319
1626
  function html(template, ...values) {
1320
1627
  return new Fragment(template, values);
1321
1628
  }
1629
+ //#endregion
1322
1630
  export { array, computed, effect, fragments, html, isArray, isComputed, isEffect, isReactive, isSignal, signal, startBatch, stopBatch, store };