regor 1.0.9 → 1.1.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.
@@ -18,10 +18,7 @@ var __spreadValues = (a, b) => {
18
18
  return a;
19
19
  };
20
20
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- var __publicField = (obj, key, value) => {
22
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
23
- return value;
24
- };
21
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
25
22
 
26
23
  // src/common/is-what.ts
27
24
  var isFunction = (value) => {
@@ -54,7 +51,8 @@ var errors = {
54
51
  [1 /* ComponentTemplateNotFound */]: (selector) => `Component template cannot be found. selector: ${selector} .`,
55
52
  [2 /* ComposablesRequireScope */]: "Use composables in scope. usage: useScope(() => new MyApp()).",
56
53
  [3 /* RequiresRefSourceArgument */]: (name2) => `${name2} requires ref source argument`,
57
- [4 /* ComputedIsReadOnly */]: "computed is readonly."
54
+ [4 /* ComputedIsReadOnly */]: "computed is readonly.",
55
+ [5 /* PersistRequiresKey */]: "persist requires a string key."
58
56
  };
59
57
  var getError = (type, ...args) => {
60
58
  const msg = errors[type];
@@ -67,8 +65,7 @@ var bindDataSymbol = Symbol(":regor");
67
65
  // src/cleanup/getBindData.ts
68
66
  var getBindData = (node) => {
69
67
  const bindData = node[bindDataSymbol];
70
- if (bindData)
71
- return bindData;
68
+ if (bindData) return bindData;
72
69
  const newBindData = {
73
70
  unbinders: [],
74
71
  data: {}
@@ -94,8 +91,7 @@ var pushScope = () => {
94
91
  };
95
92
  var peekScope = (noThrow) => {
96
93
  const scope = scopes[scopes.length - 1];
97
- if (!scope && !noThrow)
98
- throw getError(2 /* ComposablesRequireScope */);
94
+ if (!scope && !noThrow) throw getError(2 /* ComposablesRequireScope */);
99
95
  return scope;
100
96
  };
101
97
  var popScope = (context) => {
@@ -110,8 +106,7 @@ var setScope = (context) => {
110
106
  const existing = data[scopeSymbol];
111
107
  if (existing) {
112
108
  const cs = peekScope();
113
- if (existing === cs)
114
- return;
109
+ if (existing === cs) return;
115
110
  cs.onMounted.length > 0 && existing.onMounted.push(...cs.onMounted);
116
111
  cs.onUnmounted.length > 0 && existing.onUnmounted.push(...cs.onUnmounted);
117
112
  return;
@@ -143,8 +138,7 @@ var isRef = (value) => {
143
138
  var observe = (source, observer, init) => {
144
139
  if (!isRef(source))
145
140
  throw getError(3 /* RequiresRefSourceArgument */, "observe");
146
- if (init)
147
- observer(source());
141
+ if (init) observer(source());
148
142
  const srefImpl = source;
149
143
  const stop = srefImpl(
150
144
  void 0,
@@ -163,8 +157,7 @@ var unbind = (node) => {
163
157
  const currentElement = queue.shift();
164
158
  unbindSingle(currentElement);
165
159
  const childNodes = currentElement.childNodes;
166
- if (!childNodes)
167
- continue;
160
+ if (!childNodes) continue;
168
161
  for (const item of childNodes) {
169
162
  queue.push(item);
170
163
  }
@@ -172,8 +165,7 @@ var unbind = (node) => {
172
165
  };
173
166
  var unbindSingle = (node) => {
174
167
  const bindData = node[bindDataSymbol];
175
- if (!bindData)
176
- return;
168
+ if (!bindData) return;
177
169
  for (const unbinder of bindData.unbinders) {
178
170
  unbinder();
179
171
  }
@@ -207,12 +199,9 @@ var warning = (type, ...args) => {
207
199
  const msg = warnings[type];
208
200
  const item = isFunction(msg) ? msg.call(warnings, ...args) : msg;
209
201
  const handler = warningHandler.warning;
210
- if (!handler)
211
- return;
212
- if (isString(item))
213
- handler(item);
214
- else
215
- handler(item, ...item.args);
202
+ if (!handler) return;
203
+ if (isString(item)) handler(item);
204
+ else handler(item, ...item.args);
216
205
  };
217
206
  var warningHandler = { warning: console.warn };
218
207
 
@@ -251,11 +240,9 @@ var getSwitches = (nodes) => {
251
240
  return [...set];
252
241
  };
253
242
  var setSwitchOwner = (owner, switchNodes) => {
254
- if (!hasSwitch())
255
- return;
243
+ if (!hasSwitch()) return;
256
244
  const switches2 = getSwitches(switchNodes);
257
- if (switches2.length === 0)
258
- return;
245
+ if (switches2.length === 0) return;
259
246
  switches2.forEach(refSwitch);
260
247
  addUnbinder(owner, () => {
261
248
  switches2.forEach(removeSwitch);
@@ -311,8 +298,7 @@ var IfBinder = class {
311
298
  return isIfElement;
312
299
  }
313
300
  __isProcessedOrMark(el) {
314
- if (el[ifMarker])
315
- return true;
301
+ if (el[ifMarker]) return true;
316
302
  el[ifMarker] = true;
317
303
  findElements(el, this.__ifSelector).forEach(
318
304
  (x) => x[ifMarker] = true
@@ -343,8 +329,7 @@ var IfBinder = class {
343
329
  removeNode(x);
344
330
  });
345
331
  el.remove();
346
- if (type !== "if")
347
- el[elseMarker] = 1;
332
+ if (type !== "if") el[elseMarker] = 1;
348
333
  const commentEnd = document.createComment(
349
334
  `__end__ :${type}${expression != null ? expression : ""}`
350
335
  );
@@ -357,8 +342,7 @@ var IfBinder = class {
357
342
  };
358
343
  }
359
344
  __collectElses(el, refresh) {
360
- if (!el)
361
- return [];
345
+ if (!el) return [];
362
346
  const nextElement = el.nextElementSibling;
363
347
  if (el.hasAttribute(this.__else)) {
364
348
  el.removeAttribute(this.__else);
@@ -380,8 +364,7 @@ var IfBinder = class {
380
364
  ];
381
365
  } else {
382
366
  const expression = el.getAttribute(this.__elseif);
383
- if (!expression)
384
- return [];
367
+ if (!expression) return [];
385
368
  el.removeAttribute(this.__elseif);
386
369
  const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
387
370
  el,
@@ -490,8 +473,7 @@ var bindChildNodes = (binder, childNodes) => {
490
473
  var findElements = (element, selector) => {
491
474
  var _a;
492
475
  const result = element.querySelectorAll(selector);
493
- if ((_a = element.matches) == null ? void 0 : _a.call(element, selector))
494
- return [element, ...result];
476
+ if ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) return [element, ...result];
495
477
  return result;
496
478
  };
497
479
  var isTemplate = (node) => node instanceof HTMLTemplateElement;
@@ -513,8 +495,7 @@ var defineRefValue = (result, isReadOnly) => {
513
495
  return result();
514
496
  },
515
497
  set(value) {
516
- if (isReadOnly)
517
- throw new Error("value is readonly.");
498
+ if (isReadOnly) throw new Error("value is readonly.");
518
499
  return result(value);
519
500
  },
520
501
  enumerable: true,
@@ -522,10 +503,8 @@ var defineRefValue = (result, isReadOnly) => {
522
503
  });
523
504
  };
524
505
  var isOptionDynamic = (option, dynamic) => {
525
- if (!option)
526
- return false;
527
- if (option.startsWith("["))
528
- return option.substring(1, option.length - 1);
506
+ if (!option) return false;
507
+ if (option.startsWith("[")) return option.substring(1, option.length - 1);
529
508
  const len = dynamic.length;
530
509
  if (option.startsWith(dynamic)) {
531
510
  return option.substring(len, option.length - len);
@@ -551,19 +530,16 @@ var cacheStringFunction = (fn) => {
551
530
  };
552
531
  var camelizeRE = /-(\w)/g;
553
532
  var camelize = cacheStringFunction((str) => {
554
- if (!str)
555
- return str;
533
+ if (!str) return str;
556
534
  return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
557
535
  });
558
536
  var hyphenateRE = /\B([A-Z])/g;
559
537
  var hyphenate = cacheStringFunction((str) => {
560
- if (!str)
561
- return str;
538
+ if (!str) return str;
562
539
  return str.replace(hyphenateRE, "-$1").toLowerCase();
563
540
  });
564
541
  var capitalize = cacheStringFunction((str) => {
565
- if (!str)
566
- return str;
542
+ if (!str) return str;
567
543
  return str.charAt(0).toUpperCase() + str.slice(1);
568
544
  });
569
545
 
@@ -571,14 +547,12 @@ var capitalize = cacheStringFunction((str) => {
571
547
  var collectedRefs = [];
572
548
  var collectRef = (ref2) => {
573
549
  var _a;
574
- if (collectedRefs.length === 0)
575
- return;
550
+ if (collectedRefs.length === 0) return;
576
551
  (_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
577
552
  };
578
553
  var watchEffect = (effect) => {
579
- if (!effect)
580
- return () => {
581
- };
554
+ if (!effect) return () => {
555
+ };
582
556
  const terminator = { stop: () => {
583
557
  } };
584
558
  watchEffectInternal(effect, terminator);
@@ -586,13 +560,11 @@ var watchEffect = (effect) => {
586
560
  return terminator.stop;
587
561
  };
588
562
  var watchEffectInternal = (effect, terminator) => {
589
- if (!effect)
590
- return;
563
+ if (!effect) return;
591
564
  let stopObservingList = [];
592
565
  let isStopped = false;
593
566
  const stopWatch = () => {
594
- for (const stop of stopObservingList)
595
- stop();
567
+ for (const stop of stopObservingList) stop();
596
568
  stopObservingList = [];
597
569
  isStopped = true;
598
570
  };
@@ -601,8 +573,7 @@ var watchEffectInternal = (effect, terminator) => {
601
573
  const set = /* @__PURE__ */ new Set();
602
574
  collectedRefs.push(set);
603
575
  effect((onCleanup) => stopObservingList.push(onCleanup));
604
- if (isStopped)
605
- return;
576
+ if (isStopped) return;
606
577
  for (const r of [...set]) {
607
578
  const stopObserving = observe(r, () => {
608
579
  stopWatch();
@@ -642,15 +613,12 @@ var isRaw = (value) => {
642
613
 
643
614
  // src/reactivity/trigger.ts
644
615
  var trigger = (source, eventSource, isRecursive) => {
645
- if (!isRef(source))
646
- return;
616
+ if (!isRef(source)) return;
647
617
  const srefImpl = source;
648
618
  srefImpl(void 0, eventSource, 1 /* trigger */);
649
- if (!isRecursive)
650
- return;
619
+ if (!isRecursive) return;
651
620
  const obj = srefImpl();
652
- if (!obj)
653
- return;
621
+ if (!obj) return;
654
622
  if (isArray(obj) || isSet(obj)) {
655
623
  for (const el of obj) {
656
624
  trigger(el, eventSource, true);
@@ -683,8 +651,7 @@ var createProxy = (originalProto, proxyProto, methodsToPatch4) => {
683
651
  define(proxyProto, method, function mutator(...args) {
684
652
  const result = original.apply(this, args);
685
653
  const subscribers = this[srefSymbol];
686
- for (const subscriber of subscribers)
687
- trigger(subscriber);
654
+ for (const subscriber of subscribers) trigger(subscriber);
688
655
  return result;
689
656
  });
690
657
  });
@@ -729,17 +696,14 @@ createProxy(setProto, proxySetProto, methodsToPatch3);
729
696
  // src/reactivity/sref.ts
730
697
  var batchCollector = {};
731
698
  var sref = (value) => {
732
- if (isRef(value) || isRaw(value))
733
- return value;
699
+ if (isRef(value) || isRaw(value)) return value;
734
700
  const refObj = {
735
701
  auto: true,
736
702
  _value: value
737
703
  };
738
704
  const createProxy2 = (value2) => {
739
- if (!isObject(value2))
740
- return false;
741
- if (srefSymbol in value2)
742
- return true;
705
+ if (!isObject(value2)) return false;
706
+ if (srefSymbol in value2) return true;
743
707
  const isAnArray = isArray(value2);
744
708
  if (isAnArray) {
745
709
  Object.setPrototypeOf(value2, proxyArrayProto);
@@ -760,24 +724,22 @@ var sref = (value) => {
760
724
  const isProxy = createProxy2(value);
761
725
  const observers = /* @__PURE__ */ new Set();
762
726
  const trigger2 = (newValue, eventSource) => {
763
- if (batchCollector.set) {
764
- batchCollector.set.add(srefFunction);
727
+ if (batchCollector.stack && batchCollector.stack.length) {
728
+ const current = batchCollector.stack[batchCollector.stack.length - 1];
729
+ current.add(srefFunction);
765
730
  return;
766
731
  }
767
- if (observers.size === 0)
768
- return;
732
+ if (observers.size === 0) return;
769
733
  silence(() => {
770
734
  for (const callback of [...observers.keys()]) {
771
- if (!observers.has(callback))
772
- continue;
735
+ if (!observers.has(callback)) continue;
773
736
  callback(newValue, eventSource);
774
737
  }
775
738
  });
776
739
  };
777
740
  const attachProxyHandle = (value2) => {
778
741
  let proxyHandle = value2[srefSymbol];
779
- if (!proxyHandle)
780
- value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
742
+ if (!proxyHandle) value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
781
743
  proxyHandle.add(srefFunction);
782
744
  };
783
745
  const srefFunction = (...args) => {
@@ -785,15 +747,12 @@ var sref = (value) => {
785
747
  let newValue = args[0];
786
748
  const eventSource = args[1];
787
749
  if (0 in args) {
788
- if (refObj._value === newValue)
789
- return newValue;
750
+ if (refObj._value === newValue) return newValue;
790
751
  if (isRef(newValue)) {
791
752
  newValue = newValue();
792
- if (refObj._value === newValue)
793
- return newValue;
753
+ if (refObj._value === newValue) return newValue;
794
754
  }
795
- if (createProxy2(newValue))
796
- attachProxyHandle(newValue);
755
+ if (createProxy2(newValue)) attachProxyHandle(newValue);
797
756
  refObj._value = newValue;
798
757
  if (refObj.auto) {
799
758
  trigger2(newValue, eventSource);
@@ -808,9 +767,8 @@ var sref = (value) => {
808
767
  switch (operation) {
809
768
  case 0 /* observe */: {
810
769
  const observer = args[3];
811
- if (!observer)
812
- return () => {
813
- };
770
+ if (!observer) return () => {
771
+ };
814
772
  const removeObserver = (observer2) => {
815
773
  observers.delete(observer2);
816
774
  };
@@ -840,8 +798,7 @@ var sref = (value) => {
840
798
  };
841
799
  srefFunction[srefSymbol] = 1;
842
800
  defineRefValue(srefFunction, false);
843
- if (isProxy)
844
- attachProxyHandle(value);
801
+ if (isProxy) attachProxyHandle(value);
845
802
  return srefFunction;
846
803
  };
847
804
 
@@ -868,14 +825,12 @@ var MountList = class {
868
825
  }
869
826
  __setValueMap(item) {
870
827
  const value = this.__getKey(item.value);
871
- if (value)
872
- this.__valueMap.set(value, item);
828
+ if (value !== void 0) this.__valueMap.set(value, item);
873
829
  }
874
830
  __deleteValueMap(index) {
875
831
  var _a;
876
832
  const value = this.__getKey((_a = this.__list[index]) == null ? void 0 : _a.value);
877
- if (value)
878
- this.__valueMap.delete(value);
833
+ if (value !== void 0) this.__valueMap.delete(value);
879
834
  }
880
835
  /**
881
836
  * @internal
@@ -895,8 +850,7 @@ var MountList = class {
895
850
  }
896
851
  __insertAt(index, item) {
897
852
  const len = this.__length;
898
- for (let i = index; i < len; ++i)
899
- this.__list[i].order = i + 1;
853
+ for (let i = index; i < len; ++i) this.__list[i].order = i + 1;
900
854
  item.order = index;
901
855
  this.__list.splice(index, 0, item);
902
856
  this.__setValueMap(item);
@@ -914,13 +868,11 @@ var MountList = class {
914
868
  this.__deleteValueMap(index);
915
869
  this.__list.splice(index, 1);
916
870
  const len = this.__length;
917
- for (let i = index; i < len; ++i)
918
- this.__list[i].order = i;
871
+ for (let i = index; i < len; ++i) this.__list[i].order = i;
919
872
  }
920
873
  __removeAllAfter(index) {
921
874
  const len = this.__length;
922
- for (let i = index; i < len; ++i)
923
- this.__deleteValueMap(i);
875
+ for (let i = index; i < len; ++i) this.__deleteValueMap(i);
924
876
  this.__list.splice(index);
925
877
  }
926
878
  __isValueMounted(value) {
@@ -955,8 +907,7 @@ var _ForBinder = class _ForBinder {
955
907
  return isForElement;
956
908
  }
957
909
  __isProcessedOrMark(el) {
958
- if (el[forMarker])
959
- return true;
910
+ if (el[forMarker]) return true;
960
911
  el[forMarker] = true;
961
912
  findElements(el, this.__forSelector).forEach(
962
913
  (x) => x[forMarker] = true
@@ -964,8 +915,7 @@ var _ForBinder = class _ForBinder {
964
915
  return false;
965
916
  }
966
917
  __bindFor(el) {
967
- if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el))
968
- return;
918
+ if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el)) return;
969
919
  const forPath = el.getAttribute(this.__for);
970
920
  if (!forPath) {
971
921
  warning(0 /* MissingBindingExpression */, this.__for, el);
@@ -975,10 +925,8 @@ var _ForBinder = class _ForBinder {
975
925
  this.__bindForToPath(el, forPath);
976
926
  }
977
927
  __getIterable(obj) {
978
- if (isNullOrUndefined(obj))
979
- return [];
980
- if (isFunction(obj))
981
- obj = obj();
928
+ if (isNullOrUndefined(obj)) return [];
929
+ if (isFunction(obj)) obj = obj();
982
930
  if (Symbol.iterator in Object(obj)) {
983
931
  return obj;
984
932
  }
@@ -1015,8 +963,7 @@ var _ForBinder = class _ForBinder {
1015
963
  const areEqual = (a, b) => getKey(a) === getKey(b);
1016
964
  const nodes = getNodes(el);
1017
965
  const parent = el.parentNode;
1018
- if (!parent)
1019
- return;
966
+ if (!parent) return;
1020
967
  const title = `${this.__for} => ${forPath}`;
1021
968
  const commentBegin = new Comment(`__begin__ ${title}`);
1022
969
  parent.insertBefore(commentBegin, el);
@@ -1075,8 +1022,7 @@ var _ForBinder = class _ForBinder {
1075
1022
  };
1076
1023
  const updateDom = (newValues) => {
1077
1024
  let len = mountList.__length;
1078
- if (isFunction(newValues))
1079
- newValues = newValues();
1025
+ if (isFunction(newValues)) newValues = newValues();
1080
1026
  const unrefedNewValue = unref(newValues[0]);
1081
1027
  if (isArray(unrefedNewValue) && unrefedNewValue.length === 0) {
1082
1028
  unmount(commentBegin, commentEnd);
@@ -1092,8 +1038,7 @@ var _ForBinder = class _ForBinder {
1092
1038
  const modify = () => {
1093
1039
  if (i2 < len) {
1094
1040
  const mountItem = mountList.__get(i2++);
1095
- if (areEqual(mountItem.value, newValue))
1096
- return;
1041
+ if (areEqual(mountItem.value, newValue)) return;
1097
1042
  const newValueMountPosition = mountList.__lookupValueOrderIfMounted(
1098
1043
  getKey(newValue)
1099
1044
  );
@@ -1108,8 +1053,7 @@ var _ForBinder = class _ForBinder {
1108
1053
  --len;
1109
1054
  if (newValueMountPosition > i2 + 1) {
1110
1055
  for (let j2 = i2; j2 < newValueMountPosition - 1 && j2 < len; ) {
1111
- if (areEqual(mountList.__get(i2).value, newValue))
1112
- break;
1056
+ if (areEqual(mountList.__get(i2).value, newValue)) break;
1113
1057
  ++j2;
1114
1058
  remove(i2);
1115
1059
  mountList.__removeAt(i2);
@@ -1140,8 +1084,7 @@ var _ForBinder = class _ForBinder {
1140
1084
  }
1141
1085
  const j = i2;
1142
1086
  len = mountList.__length;
1143
- while (i2 < len)
1144
- remove(i2++);
1087
+ while (i2 < len) remove(i2++);
1145
1088
  mountList.__removeAllAfter(j);
1146
1089
  updateIndexes(firstRemovalOrInsertionIndex);
1147
1090
  };
@@ -1166,16 +1109,13 @@ var _ForBinder = class _ForBinder {
1166
1109
  __parseForPath(forPath) {
1167
1110
  var _a, _b;
1168
1111
  const matches = _ForBinder.__forPathRegex.exec(forPath);
1169
- if (!matches)
1170
- return;
1112
+ if (!matches) return;
1171
1113
  const keys = (matches[1] + ((_a = matches[2]) != null ? _a : "")).split(",").map((key) => key.trim());
1172
1114
  const indexOfIndex = keys.length > 1 ? keys.length - 1 : -1;
1173
1115
  const index = indexOfIndex !== -1 && (keys[indexOfIndex] === "index" || ((_b = keys[indexOfIndex]) == null ? void 0 : _b.startsWith("#"))) ? keys[indexOfIndex] : "";
1174
- if (index)
1175
- keys.splice(indexOfIndex, 1);
1116
+ if (index) keys.splice(indexOfIndex, 1);
1176
1117
  const list = matches[3];
1177
- if (!list || keys.length === 0)
1178
- return;
1118
+ if (!list || keys.length === 0) return;
1179
1119
  const hasDestructuring = /[{[]/.test(forPath);
1180
1120
  return {
1181
1121
  list,
@@ -1203,7 +1143,7 @@ var _ForBinder = class _ForBinder {
1203
1143
  };
1204
1144
  }
1205
1145
  };
1206
- __publicField(_ForBinder, "__forPathRegex", /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+([^\s]+)\s*/);
1146
+ __publicField(_ForBinder, "__forPathRegex", /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+(.*)\s*$/);
1207
1147
  var ForBinder = _ForBinder;
1208
1148
 
1209
1149
  // src/bind/DynamicBinder.ts
@@ -1234,8 +1174,7 @@ var DynamicBinder = class {
1234
1174
  let expression = el.getAttribute(this.__is);
1235
1175
  if (!expression) {
1236
1176
  expression = el.getAttribute("is");
1237
- if (!expression || !expression.startsWith("regor:"))
1238
- return;
1177
+ if (!expression || !expression.startsWith("regor:")) return;
1239
1178
  expression = `'${expression.slice(6)}'`;
1240
1179
  el.removeAttribute("is");
1241
1180
  }
@@ -1293,13 +1232,11 @@ var DynamicBinder = class {
1293
1232
  unmount(commentBegin, commentEnd);
1294
1233
  return;
1295
1234
  }
1296
- if (mounted.name === name2)
1297
- return;
1235
+ if (mounted.name === name2) return;
1298
1236
  unmount(commentBegin, commentEnd);
1299
1237
  const componentElement = document.createElement(name2);
1300
1238
  for (const attr of el.getAttributeNames()) {
1301
- if (attr === this.__is)
1302
- continue;
1239
+ if (attr === this.__is) continue;
1303
1240
  componentElement.setAttribute(attr, el.getAttribute(attr));
1304
1241
  }
1305
1242
  mount2(componentChildNodes, componentElement);
@@ -1340,8 +1277,7 @@ var propsDirective = {
1340
1277
  const key = item[0];
1341
1278
  const value2 = item[1];
1342
1279
  const ctxKey = ctx[key];
1343
- if (ctxKey === value2)
1344
- continue;
1280
+ if (ctxKey === value2) continue;
1345
1281
  if (isRef(ctxKey)) {
1346
1282
  ctxKey(value2);
1347
1283
  } else {
@@ -1371,8 +1307,7 @@ var propsOnceDirective = {
1371
1307
  const key = item[0];
1372
1308
  const value2 = item[1];
1373
1309
  const ctxKey = ctx[key];
1374
- if (ctxKey === value2)
1375
- continue;
1310
+ if (ctxKey === value2) continue;
1376
1311
  if (isRef(ctxKey)) {
1377
1312
  ctxKey(value2);
1378
1313
  } else {
@@ -1461,16 +1396,14 @@ var useScope = (context) => {
1461
1396
  }
1462
1397
  };
1463
1398
  var isScope = (value) => {
1464
- if (!isObject(value))
1465
- return false;
1399
+ if (!isObject(value)) return false;
1466
1400
  return scopeSymbol2 in value;
1467
1401
  };
1468
1402
 
1469
1403
  // src/reactivity/entangle.ts
1470
1404
  var entangle = (r1, r2) => {
1471
- if (r1 === r2)
1472
- return () => {
1473
- };
1405
+ if (r1 === r2) return () => {
1406
+ };
1474
1407
  const stop1 = observe(r1, (v) => r2(v));
1475
1408
  const stop2 = observe(r2, (v) => r1(v));
1476
1409
  r2(r1());
@@ -1494,9 +1427,8 @@ var callMounted = (context) => {
1494
1427
  var singlePropDirective = {
1495
1428
  collectRefObj: true,
1496
1429
  onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
1497
- if (!option)
1498
- return () => {
1499
- };
1430
+ if (!option) return () => {
1431
+ };
1500
1432
  const key = camelize(option);
1501
1433
  const stopObserving = observe(
1502
1434
  parseResult.value,
@@ -1505,8 +1437,7 @@ var singlePropDirective = {
1505
1437
  const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
1506
1438
  const ctx = parseResult.context;
1507
1439
  const ctxKey = ctx[option];
1508
- if (ctxKey === value)
1509
- return;
1440
+ if (ctxKey === value) return;
1510
1441
  if (isRef(ctxKey)) {
1511
1442
  ctxKey(value);
1512
1443
  } else {
@@ -1543,28 +1474,22 @@ var ComponentBinder = class {
1543
1474
  ...[...registeredComponents.keys()].map(hyphenate),
1544
1475
  ...[...Object.keys(contextComponents)].map(hyphenate)
1545
1476
  ].join(",");
1546
- if (isNullOrWhitespace(selector))
1547
- return;
1477
+ if (isNullOrWhitespace(selector)) return;
1548
1478
  const list = element.querySelectorAll(selector);
1549
1479
  const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
1550
1480
  for (const component of components) {
1551
- if (component.hasAttribute(binder.__pre))
1552
- continue;
1481
+ if (component.hasAttribute(binder.__pre)) continue;
1553
1482
  const parent = component.parentNode;
1554
- if (!parent)
1555
- continue;
1483
+ if (!parent) continue;
1556
1484
  const nextSibling = component.nextSibling;
1557
1485
  const tagName = camelize(component.tagName).toUpperCase();
1558
1486
  const contextComponent = contextComponents[tagName];
1559
1487
  const registeredComponent = contextComponent != null ? contextComponent : registeredComponentsUpperCase.get(tagName);
1560
- if (!registeredComponent)
1561
- continue;
1488
+ if (!registeredComponent) continue;
1562
1489
  const templateElement = registeredComponent.template;
1563
- if (!templateElement)
1564
- continue;
1490
+ if (!templateElement) continue;
1565
1491
  const componentParent = component.parentElement;
1566
- if (!componentParent)
1567
- continue;
1492
+ if (!componentParent) continue;
1568
1493
  const startOfComponent = new Comment(
1569
1494
  " begin component: " + component.tagName
1570
1495
  );
@@ -1580,30 +1505,24 @@ var ComponentBinder = class {
1580
1505
  const hasPropsOnce = component2.hasAttribute(propsOnceName);
1581
1506
  parser.__scoped(capturedContext2, () => {
1582
1507
  parser.__push(props);
1583
- if (hasProps)
1584
- binder.__bind(propsDirective, component2, propsName);
1508
+ if (hasProps) binder.__bind(propsDirective, component2, propsName);
1585
1509
  if (hasPropsOnce)
1586
1510
  binder.__bind(propsOnceDirective, component2, propsOnceName);
1587
1511
  let definedProps = registeredComponent.props;
1588
- if (!definedProps || definedProps.length === 0)
1589
- return;
1512
+ if (!definedProps || definedProps.length === 0) return;
1590
1513
  definedProps = definedProps.map(camelize);
1591
1514
  for (const name2 of definedProps.concat(definedProps.map(hyphenate))) {
1592
1515
  const value = component2.getAttribute(name2);
1593
- if (value === null)
1594
- continue;
1516
+ if (value === null) continue;
1595
1517
  props[camelize(name2)] = value;
1596
1518
  component2.removeAttribute(name2);
1597
1519
  }
1598
1520
  const map = binder.__directiveCollector.__collect(component2, false);
1599
1521
  for (const [attrName, item] of map.entries()) {
1600
1522
  const [name2, option] = item.__terms;
1601
- if (!option)
1602
- continue;
1603
- if (!definedProps.includes(camelize(option)))
1604
- continue;
1605
- if (name2 !== "." && name2 !== ":" && name2 !== bindName)
1606
- continue;
1523
+ if (!option) continue;
1524
+ if (!definedProps.includes(camelize(option))) continue;
1525
+ if (name2 !== "." && name2 !== ":" && name2 !== bindName) continue;
1607
1526
  binder.__bind(
1608
1527
  singlePropDirective,
1609
1528
  component2,
@@ -1635,16 +1554,13 @@ var ComponentBinder = class {
1635
1554
  for (const [key, propsValue] of Object.entries(props)) {
1636
1555
  if (key in componentCtx2) {
1637
1556
  const compValue = componentCtx2[key];
1638
- if (compValue === propsValue)
1639
- continue;
1557
+ if (compValue === propsValue) continue;
1640
1558
  if (head2.entangle && isRef(compValue) && isRef(propsValue)) {
1641
1559
  addUnbinder(startOfComponent, entangle(propsValue, compValue));
1642
1560
  } else if (isRef(compValue)) {
1643
1561
  compValue(propsValue);
1644
- } else
1645
- componentCtx2[key] = unref(propsValue);
1646
- } else
1647
- componentCtx2[key] = propsValue;
1562
+ } else componentCtx2[key] = unref(propsValue);
1563
+ } else componentCtx2[key] = propsValue;
1648
1564
  }
1649
1565
  (_a2 = head2.onAutoPropsAssigned) == null ? void 0 : _a2.call(head2);
1650
1566
  }
@@ -1667,8 +1583,7 @@ var ComponentBinder = class {
1667
1583
  name2 = slot.getAttributeNames().filter((x) => x.startsWith("#"))[0];
1668
1584
  if (isNullOrWhitespace(name2)) {
1669
1585
  name2 = "default";
1670
- } else
1671
- name2 = name2.substring(1);
1586
+ } else name2 = name2.substring(1);
1672
1587
  }
1673
1588
  let compTemplate = component.querySelector(
1674
1589
  `template[name='${name2}'], template[\\#${name2}]`
@@ -1679,8 +1594,7 @@ var ComponentBinder = class {
1679
1594
  compTemplate = null;
1680
1595
  }
1681
1596
  const createSwitchContext = (childNodes2) => {
1682
- if (head.disableSwitch)
1683
- return;
1597
+ if (head.disableSwitch) return;
1684
1598
  parser.__scoped(capturedContext, () => {
1685
1599
  parser.__push(componentCtx);
1686
1600
  const props = getProps(slot, parser.__capture());
@@ -1689,8 +1603,7 @@ var ComponentBinder = class {
1689
1603
  const switchContext = parser.__capture();
1690
1604
  const id = addSwitch(switchContext);
1691
1605
  for (const child of childNodes2) {
1692
- if (!isElement(child))
1693
- continue;
1606
+ if (!isElement(child)) continue;
1694
1607
  child.setAttribute(rswitch, id);
1695
1608
  refSwitch(id);
1696
1609
  addUnbinder(child, () => {
@@ -1723,8 +1636,7 @@ var ComponentBinder = class {
1723
1636
  }
1724
1637
  };
1725
1638
  const expandNestedSlots = (node) => {
1726
- if (!isElement(node))
1727
- return;
1639
+ if (!isElement(node)) return;
1728
1640
  const slots = node.querySelectorAll("slot");
1729
1641
  if (isSlot(node)) {
1730
1642
  expandSlot(node);
@@ -1746,8 +1658,7 @@ var ComponentBinder = class {
1746
1658
  expandSlots();
1747
1659
  componentParent.insertBefore(endOfComponent, nextSibling);
1748
1660
  const transferAttributesToTheComponentChild = () => {
1749
- if (!registeredComponent.inheritAttrs)
1750
- return;
1661
+ if (!registeredComponent.inheritAttrs) return;
1751
1662
  let inheritorChildNodes = childNodes.filter(
1752
1663
  (x) => x.nodeType === Node.ELEMENT_NODE
1753
1664
  );
@@ -1756,11 +1667,9 @@ var ComponentBinder = class {
1756
1667
  (x) => x.hasAttribute(this.__inherit)
1757
1668
  );
1758
1669
  const inheritor = inheritorChildNodes[0];
1759
- if (!inheritor)
1760
- return;
1670
+ if (!inheritor) return;
1761
1671
  for (const attrName of component.getAttributeNames()) {
1762
- if (attrName === propsName || attrName === propsOnceName)
1763
- continue;
1672
+ if (attrName === propsName || attrName === propsOnceName) continue;
1764
1673
  const value = component.getAttribute(attrName);
1765
1674
  if (attrName === "class") {
1766
1675
  inheritor.classList.add(...value.split(" "));
@@ -1820,12 +1729,10 @@ var DirectiveElement = class {
1820
1729
  __parse() {
1821
1730
  let name2 = this.__name;
1822
1731
  const isPropShortcut = name2.startsWith(".");
1823
- if (isPropShortcut)
1824
- name2 = ":" + name2.slice(1);
1732
+ if (isPropShortcut) name2 = ":" + name2.slice(1);
1825
1733
  const firstFlagIndex = name2.indexOf(".");
1826
1734
  const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
1827
- if (isNullOrWhitespace(terms[0]))
1828
- terms[0] = isPropShortcut ? "." : name2[0];
1735
+ if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
1829
1736
  if (firstFlagIndex >= 0) {
1830
1737
  const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
1831
1738
  if (flags.includes("camel")) {
@@ -1847,21 +1754,18 @@ var DirectiveCollector = class {
1847
1754
  }
1848
1755
  __collect(element, isRecursive) {
1849
1756
  const map = /* @__PURE__ */ new Map();
1850
- if (!isHTMLElement(element))
1851
- return map;
1757
+ if (!isHTMLElement(element)) return map;
1852
1758
  const prefixes2 = this.__prefixes;
1853
1759
  const processNode = (node) => {
1854
1760
  const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
1855
1761
  for (const name2 of names) {
1856
- if (!map.has(name2))
1857
- map.set(name2, new DirectiveElement(name2));
1762
+ if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
1858
1763
  const item = map.get(name2);
1859
1764
  item.__elements.push(node);
1860
1765
  }
1861
1766
  };
1862
1767
  processNode(element);
1863
- if (!isRecursive)
1864
- return map;
1768
+ if (!isRecursive) return map;
1865
1769
  const nodes = element.querySelectorAll("*");
1866
1770
  for (const node of nodes) {
1867
1771
  processNode(node);
@@ -1898,15 +1802,12 @@ var Binder = class {
1898
1802
  __unwrapTemplates(element) {
1899
1803
  const templates = isTemplate(element) ? [element] : element.querySelectorAll("template");
1900
1804
  for (const template of templates) {
1901
- if (template.hasAttribute(this.__pre))
1902
- continue;
1805
+ if (template.hasAttribute(this.__pre)) continue;
1903
1806
  const parent = template.parentNode;
1904
- if (!parent)
1905
- continue;
1807
+ if (!parent) continue;
1906
1808
  const nextSibling = template.nextSibling;
1907
1809
  template.remove();
1908
- if (!template.content)
1909
- continue;
1810
+ if (!template.content) continue;
1910
1811
  const childNodes = [...template.content.childNodes];
1911
1812
  for (const child of childNodes) {
1912
1813
  parent.insertBefore(child, nextSibling);
@@ -1917,12 +1818,9 @@ var Binder = class {
1917
1818
  __bindDefault(element) {
1918
1819
  if (element.nodeType !== Node.ELEMENT_NODE || element.hasAttribute(this.__pre))
1919
1820
  return;
1920
- if (this.__ifBinder.__bindAll(element))
1921
- return;
1922
- if (this.__forBinder.__bindAll(element))
1923
- return;
1924
- if (this.__dynamicBinder.__bindAll(element))
1925
- return;
1821
+ if (this.__ifBinder.__bindAll(element)) return;
1822
+ if (this.__forBinder.__bindAll(element)) return;
1823
+ if (this.__dynamicBinder.__bindAll(element)) return;
1926
1824
  this.__componentBinder.__bindAll(element);
1927
1825
  this.__unwrapTemplates(element);
1928
1826
  this.__bindAttributes(element, true);
@@ -1944,16 +1842,13 @@ var Binder = class {
1944
1842
  }
1945
1843
  }
1946
1844
  __bind(config, el, attribute, _noWarning, option, flags) {
1947
- if (el.hasAttribute(this.__pre))
1948
- return;
1845
+ if (el.hasAttribute(this.__pre)) return;
1949
1846
  const bindExpression = el.getAttribute(attribute);
1950
1847
  el.removeAttribute(attribute);
1951
1848
  const getParentSwitch = (el2) => {
1952
1849
  const switchId = el2.getAttribute(rswitch);
1953
- if (switchId)
1954
- return switchId;
1955
- if (!el2.parentElement)
1956
- return null;
1850
+ if (switchId) return switchId;
1851
+ if (!el2.parentElement) return null;
1957
1852
  return getParentSwitch(el2.parentElement);
1958
1853
  };
1959
1854
  if (hasSwitch()) {
@@ -1968,15 +1863,12 @@ var Binder = class {
1968
1863
  this.__bindToExpression(config, el, bindExpression, option, flags);
1969
1864
  }
1970
1865
  __handleTeleport(config, el, valueExpression) {
1971
- if (config !== teleportDirective)
1972
- return false;
1973
- if (isNullOrWhitespace(valueExpression))
1974
- return true;
1866
+ if (config !== teleportDirective) return false;
1867
+ if (isNullOrWhitespace(valueExpression)) return true;
1975
1868
  const teleportTo = document.querySelector(valueExpression);
1976
1869
  if (teleportTo) {
1977
1870
  const parent = el.parentElement;
1978
- if (!parent)
1979
- return true;
1871
+ if (!parent) return true;
1980
1872
  const placeholder = new Comment(`teleported => '${valueExpression}'`);
1981
1873
  parent.insertBefore(placeholder, el);
1982
1874
  el.teleportedFrom = placeholder;
@@ -1990,10 +1882,8 @@ var Binder = class {
1990
1882
  }
1991
1883
  __bindToExpression(config, el, valueExpression, option, flags) {
1992
1884
  var _a;
1993
- if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null)
1994
- return;
1995
- if (this.__handleTeleport(config, el, valueExpression))
1996
- return;
1885
+ if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null) return;
1886
+ if (this.__handleTeleport(config, el, valueExpression)) return;
1997
1887
  const result = this.__parser.__parse(
1998
1888
  valueExpression,
1999
1889
  config.isLazy,
@@ -2037,8 +1927,7 @@ var Binder = class {
2037
1927
  return previousOption;
2038
1928
  };
2039
1929
  const observeTailChanges = () => {
2040
- if (!config.onChange)
2041
- return;
1930
+ if (!config.onChange) return;
2042
1931
  const stopObserving = observe(result.value, (_) => {
2043
1932
  var _a2;
2044
1933
  const pre = previousValues;
@@ -2055,8 +1944,7 @@ var Binder = class {
2055
1944
  stopObserverList.push(stopObserving2);
2056
1945
  }
2057
1946
  };
2058
- if (!config.once)
2059
- observeTailChanges();
1947
+ if (!config.once) observeTailChanges();
2060
1948
  if (config.onBind)
2061
1949
  stopObserverList.push(
2062
1950
  config.onBind(
@@ -2246,8 +2134,7 @@ var Jsep = class {
2246
2134
  }
2247
2135
  __runHook(hookType, hookCalltype, node) {
2248
2136
  const hook = this.__hooks[hookType];
2249
- if (!hook)
2250
- return node;
2137
+ if (!hook) return node;
2251
2138
  const env = { node };
2252
2139
  const hookFn = (f) => {
2253
2140
  f.call(this, env);
@@ -2266,8 +2153,7 @@ var Jsep = class {
2266
2153
  }
2267
2154
  parse() {
2268
2155
  const nodes = this.__gobbleExpressions();
2269
- if (nodes.length === 1)
2270
- return nodes[0];
2156
+ if (nodes.length === 1) return nodes[0];
2271
2157
  return {
2272
2158
  type: 0 /* Compound */,
2273
2159
  body: nodes
@@ -2883,8 +2769,7 @@ var Jsep = class {
2883
2769
  this.__updateBinariesToArrows(env.node);
2884
2770
  }
2885
2771
  __updateBinariesToArrows(node) {
2886
- if (!node)
2887
- return;
2772
+ if (!node) return;
2888
2773
  Object.values(node).forEach((val) => {
2889
2774
  if (val && typeof val === "object") {
2890
2775
  this.__updateBinariesToArrows(val);
@@ -2903,8 +2788,7 @@ var Jsep = class {
2903
2788
  }
2904
2789
  }
2905
2790
  __fixAssignmentOperators(env) {
2906
- if (env.node)
2907
- this.__updateBinariesToAssignments(env.node);
2791
+ if (env.node) this.__updateBinariesToAssignments(env.node);
2908
2792
  }
2909
2793
  __updateBinariesToAssignments(node) {
2910
2794
  if (assigmentOperatorsSet.has(node.operator)) {
@@ -2920,12 +2804,10 @@ var Jsep = class {
2920
2804
  }
2921
2805
  }
2922
2806
  __gobbleTaggedTemplateIdentifier(env) {
2923
- if (!env.node)
2924
- return;
2807
+ if (!env.node) return;
2925
2808
  const type = env.node.type;
2926
2809
  const condition = (type === 2 /* Identifier */ || type === 3 /* Member */) && this.__isCode(BTICK_CODE);
2927
- if (!condition)
2928
- return;
2810
+ if (!condition) return;
2929
2811
  env.node = {
2930
2812
  type: 17 /* TaggedTemplateExpression */,
2931
2813
  tag: env.node,
@@ -2933,8 +2815,7 @@ var Jsep = class {
2933
2815
  };
2934
2816
  }
2935
2817
  __gobbleTemplateLiteral(env) {
2936
- if (!this.__isCode(BTICK_CODE))
2937
- return;
2818
+ if (!this.__isCode(BTICK_CODE)) return;
2938
2819
  const node = {
2939
2820
  type: 19 /* TemplateLiteral */,
2940
2821
  quasis: [],
@@ -3005,8 +2886,7 @@ var Jsep = class {
3005
2886
  __gobbleNew(env) {
3006
2887
  var _a;
3007
2888
  const node = env.node;
3008
- if (!node || node.operator !== "new" || !node.argument)
3009
- return;
2889
+ if (!node || node.operator !== "new" || !node.argument) return;
3010
2890
  if (!node.argument || ![6 /* Call */, 3 /* Member */].includes(node.argument.type))
3011
2891
  throw this.__getError("Expected new function()");
3012
2892
  env.node = node.argument;
@@ -3017,8 +2897,7 @@ var Jsep = class {
3017
2897
  callNode.type = 20 /* NewExpression */;
3018
2898
  }
3019
2899
  __gobbleRegexLiteral(env) {
3020
- if (!this.__isCode(FSLASH_CODE))
3021
- return;
2900
+ if (!this.__isCode(FSLASH_CODE)) return;
3022
2901
  const patternIndex = ++this.__index;
3023
2902
  let inCharSet = false;
3024
2903
  while (this.__index < this.__expr.length) {
@@ -3119,8 +2998,7 @@ var evalUnaryOp = {
3119
2998
  // placed here for type safety, never executed,
3120
2999
  };
3121
3000
  var spreadArgs = (args) => {
3122
- if (!(args == null ? void 0 : args.some(shouldSpreadArray)))
3123
- return args;
3001
+ if (!(args == null ? void 0 : args.some(shouldSpreadArray))) return args;
3124
3002
  const result = [];
3125
3003
  args.forEach(
3126
3004
  (x) => shouldSpreadArray(x) ? result.push(...x) : result.push(x)
@@ -3129,8 +3007,7 @@ var spreadArgs = (args) => {
3129
3007
  };
3130
3008
  var arrayEvaluator = (...args) => spreadArgs(args);
3131
3009
  var createLazyContext = (e, context) => {
3132
- if (!e)
3133
- return context;
3010
+ if (!e) return context;
3134
3011
  const ctx = Object.create(context != null ? context : {});
3135
3012
  ctx.$event = e;
3136
3013
  return ctx;
@@ -3285,22 +3162,17 @@ var RegorEval = class {
3285
3162
  this.__collectRefObj = !!collectRefObj;
3286
3163
  }
3287
3164
  __findContext(name2, context) {
3288
- if (context && name2 in context)
3289
- return context;
3165
+ if (context && name2 in context) return context;
3290
3166
  for (const ctx of this.__contexts) {
3291
- if (name2 in ctx)
3292
- return ctx;
3167
+ if (name2 in ctx) return ctx;
3293
3168
  }
3294
3169
  return void 0;
3295
3170
  }
3296
3171
  [2 /* Identifier */](expr, _, context) {
3297
3172
  const name2 = expr.name;
3298
- if (name2 === "$root")
3299
- return this.__contexts[this.__contexts.length - 1];
3300
- if (name2 === "$parent")
3301
- return this.__contexts[1];
3302
- if (name2 === "$ctx")
3303
- return [...this.__contexts];
3173
+ if (name2 === "$root") return this.__contexts[this.__contexts.length - 1];
3174
+ if (name2 === "$parent") return this.__contexts[1];
3175
+ if (name2 === "$ctx") return [...this.__contexts];
3304
3176
  if (context && name2 in context) {
3305
3177
  this.__lastEvaluatedValueBeforeUnref = context[name2];
3306
3178
  return associateThis(unref(context[name2]), context);
@@ -3442,8 +3314,7 @@ var RegorEval = class {
3442
3314
  if (arg.type === 2 /* Identifier */) {
3443
3315
  const name2 = arg.name;
3444
3316
  const ctx = this.__findContext(name2, context);
3445
- if (isNullOrUndefined(ctx))
3446
- return void 0;
3317
+ if (isNullOrUndefined(ctx)) return void 0;
3447
3318
  return updater[op](ctx, name2);
3448
3319
  }
3449
3320
  if (arg.type === 3 /* Member */) {
@@ -3461,8 +3332,7 @@ var RegorEval = class {
3461
3332
  if (arg.type === 2 /* Identifier */) {
3462
3333
  const name2 = arg.name;
3463
3334
  const ctx = this.__findContext(name2, context);
3464
- if (isNullOrUndefined(ctx))
3465
- return void 0;
3335
+ if (isNullOrUndefined(ctx)) return void 0;
3466
3336
  const value = this.__eval(expr.right, depth, context);
3467
3337
  return applyAssigment[op](ctx, name2, value);
3468
3338
  }
@@ -3478,8 +3348,7 @@ var RegorEval = class {
3478
3348
  }
3479
3349
  [14 /* Spread */](expr, depth, context) {
3480
3350
  const spreaded = this.__eval(expr.argument, depth, context);
3481
- if (isArray(spreaded))
3482
- spreaded.s = spreadElementSymbol;
3351
+ if (isArray(spreaded)) spreaded.s = spreadElementSymbol;
3483
3352
  return spreaded;
3484
3353
  }
3485
3354
  [17 /* TaggedTemplateExpression */](expr, depth, context) {
@@ -3567,8 +3436,7 @@ var RegorEval = class {
3567
3436
  }
3568
3437
  __transformLazy(depth, context, evaluator, ...args) {
3569
3438
  const isLazy = this.__isLazy;
3570
- if (!isLazy)
3571
- return this.__transform(depth, context, evaluator, ...args);
3439
+ if (!isLazy) return this.__transform(depth, context, evaluator, ...args);
3572
3440
  const evaluatedArgs = args.map(
3573
3441
  (arg, i) => arg && (arg.type !== 15 /* Arrow */ && isLazy(i, depth) ? (e) => this.__eval(arg, depth, createLazyContext(e, context)) : this.__eval(arg, depth, context))
3574
3442
  );
@@ -3620,8 +3488,7 @@ var Parser = class {
3620
3488
  refs: [],
3621
3489
  context: this.__contexts[0]
3622
3490
  };
3623
- if (isNullOrWhitespace(expression))
3624
- return result;
3491
+ if (isNullOrWhitespace(expression)) return result;
3625
3492
  const globalContext = this.__config.globalContext;
3626
3493
  const refs = [];
3627
3494
  const evaluate = (expr, contexts, collectRefs2, context) => {
@@ -3730,8 +3597,7 @@ var attrDirective = {
3730
3597
  onChange: (el, values, previousValues, option, previousOption, flags) => {
3731
3598
  var _a;
3732
3599
  if (option) {
3733
- if (flags && flags.includes("camel"))
3734
- option = camelize(option);
3600
+ if (flags && flags.includes("camel")) option = camelize(option);
3735
3601
  patchAttribute(el, option, values[0], previousOption);
3736
3602
  return;
3737
3603
  }
@@ -3817,25 +3683,22 @@ var patchClass = (el, next, prev) => {
3817
3683
  if (next && !isClassString) {
3818
3684
  if (prev && !isPrevClassString) {
3819
3685
  for (const key in prev) {
3820
- if (!(key in next)) {
3686
+ if (!(key in next) || !next[key]) {
3821
3687
  classList.remove(key);
3822
3688
  }
3823
3689
  }
3824
3690
  }
3825
3691
  for (const key in next) {
3826
- if (next[key])
3827
- classList.add(key);
3692
+ if (next[key]) classList.add(key);
3828
3693
  }
3829
3694
  } else {
3830
3695
  if (isClassString) {
3831
3696
  if (prev !== next) {
3832
- if (isPrevClassString)
3833
- classList.remove(...prev == null ? void 0 : prev.split(","));
3697
+ if (isPrevClassString) classList.remove(...prev == null ? void 0 : prev.split(","));
3834
3698
  classList.add(...next.split(","));
3835
3699
  }
3836
3700
  } else if (prev) {
3837
- if (isPrevClassString)
3838
- classList.remove(...prev == null ? void 0 : prev.split(","));
3701
+ if (isPrevClassString) classList.remove(...prev == null ? void 0 : prev.split(","));
3839
3702
  }
3840
3703
  }
3841
3704
  };
@@ -3844,17 +3707,14 @@ var patchClass = (el, next, prev) => {
3844
3707
  var htmlDirective = {
3845
3708
  onChange: (el, values) => {
3846
3709
  const [value, replacer] = values;
3847
- if (isFunction(replacer))
3848
- replacer(el, value);
3849
- else
3850
- el.innerHTML = value == null ? void 0 : value.toString();
3710
+ if (isFunction(replacer)) replacer(el, value);
3711
+ else el.innerHTML = value == null ? void 0 : value.toString();
3851
3712
  }
3852
3713
  };
3853
3714
 
3854
3715
  // src/common/looseEqual.ts
3855
3716
  function looseCompareArrays(a, b) {
3856
- if (a.length !== b.length)
3857
- return false;
3717
+ if (a.length !== b.length) return false;
3858
3718
  let equal = true;
3859
3719
  for (let i = 0; equal && i < a.length; i++) {
3860
3720
  equal = looseEqual(a[i], b[i]);
@@ -3862,8 +3722,7 @@ function looseCompareArrays(a, b) {
3862
3722
  return equal;
3863
3723
  }
3864
3724
  function looseEqual(a, b) {
3865
- if (a === b)
3866
- return true;
3725
+ if (a === b) return true;
3867
3726
  let aValidType = isDate(a);
3868
3727
  let bValidType = isDate(b);
3869
3728
  if (aValidType || bValidType) {
@@ -3969,8 +3828,7 @@ var updateDomElementValue = (el, value) => {
3969
3828
  }
3970
3829
  } else {
3971
3830
  if (looseEqual(getValue(option), value)) {
3972
- if (el.selectedIndex !== i)
3973
- el.selectedIndex = i;
3831
+ if (el.selectedIndex !== i) el.selectedIndex = i;
3974
3832
  return;
3975
3833
  }
3976
3834
  }
@@ -3983,10 +3841,8 @@ var updateDomElementValue = (el, value) => {
3983
3841
  }
3984
3842
  };
3985
3843
  var getFlags = (flag) => {
3986
- if (isRef(flag))
3987
- flag = flag();
3988
- if (isFunction(flag))
3989
- flag = flag();
3844
+ if (isRef(flag)) flag = flag();
3845
+ if (isFunction(flag)) flag = flag();
3990
3846
  if (!flag)
3991
3847
  return {
3992
3848
  trim: false,
@@ -4020,7 +3876,7 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
4020
3876
  const f1 = getFlags(directiveFlags == null ? void 0 : directiveFlags.join(","));
4021
3877
  const f2 = getFlags(parsedValue()[1]);
4022
3878
  const flags = {
4023
- int: f1.int || f1.int,
3879
+ int: f1.int || f2.int,
4024
3880
  lazy: f1.lazy || f2.lazy,
4025
3881
  number: f1.number || f2.number,
4026
3882
  trim: f1.trim || f2.trim
@@ -4052,8 +3908,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
4052
3908
  const eventType = isLazy ? "change" : "input";
4053
3909
  const isNumber = isNumberInput(el);
4054
3910
  const trimmer = () => {
4055
- if (!flags.trim && !getFlags(parsedValue()[1]).trim)
4056
- return;
3911
+ if (!flags.trim && !getFlags(parsedValue()[1]).trim) return;
4057
3912
  el.value = el.value.trim();
4058
3913
  };
4059
3914
  const onCompositionStart = (e) => {
@@ -4076,8 +3931,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
4076
3931
  };
4077
3932
  const listener = (event) => {
4078
3933
  const target = event.target;
4079
- if (!target || target.composing)
4080
- return;
3934
+ if (!target || target.composing) return;
4081
3935
  let value = target.value;
4082
3936
  const flags2 = getFlags(parsedValue()[1]);
4083
3937
  if (isNumber || flags2.number || flags2.int) {
@@ -4088,15 +3942,12 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
4088
3942
  if (endsWithDecimalSeparator) {
4089
3943
  value += "0";
4090
3944
  value = parseFloat(value);
4091
- if (isNaN(value))
4092
- value = "";
4093
- else if (modelRef() === value)
4094
- return;
3945
+ if (isNaN(value)) value = "";
3946
+ else if (modelRef() === value) return;
4095
3947
  }
4096
3948
  value = parseFloat(value);
4097
3949
  }
4098
- if (isNaN(value))
4099
- value = "";
3950
+ if (isNaN(value)) value = "";
4100
3951
  el.value = value;
4101
3952
  } else if (flags2.trim) {
4102
3953
  value = value.trim();
@@ -4153,8 +4004,7 @@ var getCheckboxValue = (el, checked) => {
4153
4004
  return el[key];
4154
4005
  }
4155
4006
  const attrKey = checked ? trueValueAttrKey : falseValueAttrKey;
4156
- if (el.hasAttribute(attrKey))
4157
- return el.getAttribute(attrKey);
4007
+ if (el.hasAttribute(attrKey)) return el.getAttribute(attrKey);
4158
4008
  return checked;
4159
4009
  };
4160
4010
  var getCheckboxChecked = (el, value) => {
@@ -4196,8 +4046,7 @@ var handleSelect = (el, modelRef, parsedValue) => {
4196
4046
  pause(modelRef);
4197
4047
  if (isSet(modelValue)) {
4198
4048
  modelValue.clear();
4199
- for (const sel of selectedValue)
4200
- modelValue.add(sel);
4049
+ for (const sel of selectedValue) modelValue.add(sel);
4201
4050
  } else if (isArray(modelValue)) {
4202
4051
  modelValue.splice(0);
4203
4052
  modelValue.push(...selectedValue);
@@ -4249,9 +4098,8 @@ var onDirective = {
4249
4098
  if (dynamicOption) {
4250
4099
  const values2 = parseResult.value();
4251
4100
  const option2 = unref(dynamicOption.value()[0]);
4252
- if (!isString(option2))
4253
- return () => {
4254
- };
4101
+ if (!isString(option2)) return () => {
4102
+ };
4255
4103
  return attachEventListener(
4256
4104
  el,
4257
4105
  camelize(option2),
@@ -4275,18 +4123,15 @@ var onDirective = {
4275
4123
  const len = values.length;
4276
4124
  for (let i = 0; i < len; ++i) {
4277
4125
  let next = values[i];
4278
- if (isFunction(next))
4279
- next = next();
4126
+ if (isFunction(next)) next = next();
4280
4127
  if (isObject(next)) {
4281
4128
  for (const item of Object.entries(next)) {
4282
4129
  const eventType = item[0];
4283
4130
  const method = () => {
4284
4131
  let obj = parseResult.value()[i];
4285
- if (isFunction(obj))
4286
- obj = obj();
4132
+ if (isFunction(obj)) obj = obj();
4287
4133
  obj = obj[eventType];
4288
- if (isFunction(obj))
4289
- obj = obj();
4134
+ if (isFunction(obj)) obj = obj();
4290
4135
  return obj;
4291
4136
  };
4292
4137
  const flags2 = next[eventType + "_flags"];
@@ -4310,22 +4155,17 @@ var getShouldExecuteEvent = (eventType, flags) => {
4310
4155
  const isAlt = parts.includes("alt");
4311
4156
  const isMeta = parts.includes("meta");
4312
4157
  const checkModifiers = (e) => {
4313
- if (isCtrl && !e.ctrlKey)
4314
- return false;
4315
- if (isShift && !e.shiftKey)
4316
- return false;
4317
- if (isAlt && !e.altKey)
4318
- return false;
4319
- if (isMeta && !e.metaKey)
4320
- return false;
4158
+ if (isCtrl && !e.ctrlKey) return false;
4159
+ if (isShift && !e.shiftKey) return false;
4160
+ if (isAlt && !e.altKey) return false;
4161
+ if (isMeta && !e.metaKey) return false;
4321
4162
  return true;
4322
4163
  };
4323
4164
  if (keyType) {
4324
4165
  return [
4325
4166
  eventType,
4326
4167
  (e) => {
4327
- if (!checkModifiers(e))
4328
- return false;
4168
+ if (!checkModifiers(e)) return false;
4329
4169
  return e.key.toUpperCase() === keyType.toUpperCase();
4330
4170
  }
4331
4171
  ];
@@ -4349,15 +4189,11 @@ var attachEventListener = (el, eventType, method, flags) => {
4349
4189
  let shouldExecuteEvent;
4350
4190
  [eventType, shouldExecuteEvent] = getShouldExecuteEvent(eventType, flags);
4351
4191
  const execute = (e) => {
4352
- if (!shouldExecuteEvent(e))
4353
- return;
4354
- if (!method && eventType === "submit" && (flag == null ? void 0 : flag.prevent))
4355
- return;
4192
+ if (!shouldExecuteEvent(e)) return;
4193
+ if (!method && eventType === "submit" && (flag == null ? void 0 : flag.prevent)) return;
4356
4194
  let r = method(e);
4357
- if (isFunction(r))
4358
- r = r(e);
4359
- if (isFunction(r))
4360
- r(e);
4195
+ if (isFunction(r)) r = r(e);
4196
+ if (isFunction(r)) r(e);
4361
4197
  };
4362
4198
  const unbinder = () => {
4363
4199
  el.removeEventListener(eventType, listener, options);
@@ -4368,22 +4204,15 @@ var attachEventListener = (el, eventType, method, flags) => {
4368
4204
  return;
4369
4205
  }
4370
4206
  try {
4371
- if (flag.left && e.button !== 1)
4372
- return;
4373
- if (flag.middle && e.button !== 2)
4374
- return;
4375
- if (flag.right && e.button !== 3)
4376
- return;
4377
- if (flag.self && e.target !== el)
4378
- return;
4379
- if (flag.stop)
4380
- e.stopPropagation();
4381
- if (flag.prevent)
4382
- e.preventDefault();
4207
+ if (flag.left && e.button !== 0) return;
4208
+ if (flag.middle && e.button !== 1) return;
4209
+ if (flag.right && e.button !== 2) return;
4210
+ if (flag.self && e.target !== el) return;
4211
+ if (flag.stop) e.stopPropagation();
4212
+ if (flag.prevent) e.preventDefault();
4383
4213
  execute(e);
4384
4214
  } finally {
4385
- if (flag.once)
4386
- unbinder();
4215
+ if (flag.once) unbinder();
4387
4216
  }
4388
4217
  };
4389
4218
  el.addEventListener(eventType, listener, options);
@@ -4394,8 +4223,7 @@ var attachEventListener = (el, eventType, method, flags) => {
4394
4223
  var propDirective = {
4395
4224
  onChange: (el, values, _previousValues, option, _previousOption, flags) => {
4396
4225
  if (option) {
4397
- if (flags && flags.includes("camel"))
4398
- option = camelize(option);
4226
+ if (flags && flags.includes("camel")) option = camelize(option);
4399
4227
  patchProp(el, option, values[0]);
4400
4228
  return;
4401
4229
  }
@@ -4478,18 +4306,14 @@ var refDirective = {
4478
4306
  const value = result.value()[0];
4479
4307
  const isAnArray = isArray(value);
4480
4308
  const sref2 = result.refs[0];
4481
- if (isAnArray)
4482
- value.push(el);
4483
- else if (sref2)
4484
- sref2 == null ? void 0 : sref2(el);
4485
- else
4486
- result.context[expr] = el;
4309
+ if (isAnArray) value.push(el);
4310
+ else if (sref2) sref2 == null ? void 0 : sref2(el);
4311
+ else result.context[expr] = el;
4487
4312
  return () => {
4488
4313
  if (isAnArray) {
4489
4314
  const i = value.indexOf(el);
4490
4315
  i !== -1 && value.splice(i, 1);
4491
- } else
4492
- sref2 == null ? void 0 : sref2(null);
4316
+ } else sref2 == null ? void 0 : sref2(null);
4493
4317
  };
4494
4318
  }
4495
4319
  };
@@ -4503,10 +4327,8 @@ var showDirective = {
4503
4327
  originalDisplay = data._ord = el.style.display;
4504
4328
  }
4505
4329
  const isVisible = !!values[0];
4506
- if (isVisible)
4507
- el.style.display = originalDisplay;
4508
- else
4509
- el.style.display = "none";
4330
+ if (isVisible) el.style.display = originalDisplay;
4331
+ else el.style.display = "none";
4510
4332
  }
4511
4333
  };
4512
4334
 
@@ -4552,8 +4374,7 @@ var patchStyle = (el, next, prev) => {
4552
4374
  el.removeAttribute("style");
4553
4375
  }
4554
4376
  const data = getBindData(el).data;
4555
- if ("_ord" in data)
4556
- return;
4377
+ if ("_ord" in data) return;
4557
4378
  style.display = currentDisplay;
4558
4379
  }
4559
4380
  };
@@ -4564,8 +4385,7 @@ function setStyle(style, name2, val) {
4564
4385
  setStyle(style, name2, v);
4565
4386
  });
4566
4387
  } else {
4567
- if (val == null)
4568
- val = "";
4388
+ if (val == null) val = "";
4569
4389
  if (name2.startsWith("--")) {
4570
4390
  style.setProperty(name2, val);
4571
4391
  } else {
@@ -4607,11 +4427,9 @@ function autoPrefix(style, rawName) {
4607
4427
  var flatten = (reference) => {
4608
4428
  return flattenContent(unref(reference));
4609
4429
  };
4610
- var flattenContent = (value) => {
4611
- if (!value)
4612
- return value;
4613
- if (!isObject(value))
4614
- return value;
4430
+ var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
4431
+ if (!value) return value;
4432
+ if (!isObject(value)) return value;
4615
4433
  if (isArray(value)) {
4616
4434
  return value.map(flatten);
4617
4435
  }
@@ -4624,14 +4442,16 @@ var flattenContent = (value) => {
4624
4442
  }
4625
4443
  if (isMap(value)) {
4626
4444
  const map = /* @__PURE__ */ new Map();
4627
- for (const el of map) {
4445
+ for (const el of value) {
4628
4446
  map.set(flatten(el[0]), flatten(el[1]));
4629
4447
  }
4630
4448
  return map;
4631
4449
  }
4450
+ if (weakMap.has(value)) return unref(weakMap.get(value));
4632
4451
  const result = __spreadValues({}, value);
4452
+ weakMap.set(value, result);
4633
4453
  for (const entry of Object.entries(result)) {
4634
- result[entry[0]] = flatten(entry[1]);
4454
+ result[entry[0]] = flattenContent(unref(entry[1]), weakMap);
4635
4455
  }
4636
4456
  return result;
4637
4457
  };
@@ -4659,8 +4479,7 @@ var isDeepRef = (value) => {
4659
4479
 
4660
4480
  // src/reactivity/ref.ts
4661
4481
  var ref = (value) => {
4662
- if (isRaw(value))
4663
- return value;
4482
+ if (isRaw(value)) return value;
4664
4483
  let result;
4665
4484
  if (isRef(value)) {
4666
4485
  result = value;
@@ -4675,21 +4494,18 @@ var ref = (value) => {
4675
4494
  const len = value.length;
4676
4495
  for (let i = 0; i < len; ++i) {
4677
4496
  const item = value[i];
4678
- if (isDeepRef(item))
4679
- continue;
4497
+ if (isDeepRef(item)) continue;
4680
4498
  value[i] = ref(item);
4681
4499
  }
4682
4500
  return result;
4683
4501
  }
4684
- if (!isObject(value))
4685
- return result;
4502
+ if (!isObject(value)) return result;
4686
4503
  for (const item of Object.entries(value)) {
4687
4504
  const val = item[1];
4688
- if (isDeepRef(val))
4689
- continue;
4505
+ if (isDeepRef(val)) continue;
4690
4506
  const key = item[0];
4691
- if (isSymbol(key))
4692
- continue;
4507
+ if (isSymbol(key)) continue;
4508
+ value[key] = null;
4693
4509
  value[key] = ref(val);
4694
4510
  }
4695
4511
  return result;
@@ -4824,8 +4640,7 @@ var RegorConfig = _RegorConfig;
4824
4640
 
4825
4641
  // src/bind/interpolation.ts
4826
4642
  var interpolate = (element, config) => {
4827
- if (!element)
4828
- return;
4643
+ if (!element) return;
4829
4644
  const builtInNames = (config != null ? config : RegorConfig.getDefault()).__builtInNames;
4830
4645
  for (const textNode of getTextNodes(element, builtInNames.pre)) {
4831
4646
  interpolateTextNode(textNode, builtInNames.text);
@@ -4835,12 +4650,10 @@ var interpolationRegex = /({{[^]*?}})/g;
4835
4650
  var interpolateTextNode = (textNode, textDirective2) => {
4836
4651
  var _a;
4837
4652
  const text = textNode.textContent;
4838
- if (!text)
4839
- return;
4653
+ if (!text) return;
4840
4654
  const mustacheRegex = interpolationRegex;
4841
4655
  const parts = text.split(mustacheRegex);
4842
- if (parts.length <= 1)
4843
- return;
4656
+ if (parts.length <= 1) return;
4844
4657
  if (((_a = textNode.parentElement) == null ? void 0 : _a.childNodes.length) === 1 && parts.length === 3) {
4845
4658
  const part = parts[1];
4846
4659
  if (isNullOrWhitespace(parts[0]) && isNullOrWhitespace(parts[2]) && part.startsWith("{{") && part.endsWith("}}")) {
@@ -4872,8 +4685,7 @@ var getTextNodes = (node, preDirective) => {
4872
4685
  textNodes.push(node2);
4873
4686
  }
4874
4687
  } else {
4875
- if ((_b = node2 == null ? void 0 : node2.hasAttribute) == null ? void 0 : _b.call(node2, preDirective))
4876
- return;
4688
+ if ((_b = node2 == null ? void 0 : node2.hasAttribute) == null ? void 0 : _b.call(node2, preDirective)) return;
4877
4689
  for (const child of getChildNodes(node2)) {
4878
4690
  traverseTextNodes(child);
4879
4691
  }
@@ -4888,10 +4700,8 @@ var svgTags = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-
4888
4700
  var svgSet = new Set(svgTags.toUpperCase().split(","));
4889
4701
  var svgNamespace = "http://www.w3.org/2000/svg";
4890
4702
  var appendChild = (parent, el) => {
4891
- if (isTemplate(parent))
4892
- parent.content.appendChild(el);
4893
- else
4894
- parent.appendChild(el);
4703
+ if (isTemplate(parent)) parent.content.appendChild(el);
4704
+ else parent.appendChild(el);
4895
4705
  };
4896
4706
  var render = (json, parent, isSVG, config) => {
4897
4707
  var _a;
@@ -4912,8 +4722,7 @@ var render = (json, parent, isSVG, config) => {
4912
4722
  }
4913
4723
  const children = json.c;
4914
4724
  if (children) {
4915
- for (const child of children)
4916
- render(child, el, isSVG, config);
4725
+ for (const child of children) render(child, el, isSVG, config);
4917
4726
  }
4918
4727
  appendChild(parent, el);
4919
4728
  return;
@@ -4929,10 +4738,8 @@ var render = (json, parent, isSVG, config) => {
4929
4738
  node = document.createTextNode(textData);
4930
4739
  break;
4931
4740
  }
4932
- if (node)
4933
- appendChild(parent, node);
4934
- else
4935
- throw new Error("unsupported node type.");
4741
+ if (node) appendChild(parent, node);
4742
+ else throw new Error("unsupported node type.");
4936
4743
  }
4937
4744
  };
4938
4745
  var toFragment = (json, isSVG, config) => {
@@ -4949,16 +4756,13 @@ var toFragment = (json, isSVG, config) => {
4949
4756
  };
4950
4757
 
4951
4758
  // src/app/createApp.ts
4952
- var createApp = (context, templateOptions = { selector: "#app" }, config) => {
4953
- if (isString(templateOptions))
4954
- templateOptions = { selector: "#app", template: templateOptions };
4955
- if (isScope(context))
4956
- context = context.context;
4957
- const root = templateOptions.element ? templateOptions.element : templateOptions.selector ? document.querySelector(templateOptions.selector) : null;
4958
- if (!root || !isElement(root))
4959
- throw getError(0 /* AppRootElementMissing */);
4960
- if (!config)
4961
- config = RegorConfig.getDefault();
4759
+ var createApp = (context, template = { selector: "#app" }, config) => {
4760
+ if (isString(template))
4761
+ template = { selector: "#app", template };
4762
+ if (isScope(context)) context = context.context;
4763
+ const root = template.element ? template.element : template.selector ? document.querySelector(template.selector) : null;
4764
+ if (!root || !isElement(root)) throw getError(0 /* AppRootElementMissing */);
4765
+ if (!config) config = RegorConfig.getDefault();
4962
4766
  const cleanRoot = () => {
4963
4767
  for (const child of [...root.childNodes]) {
4964
4768
  removeNode(child);
@@ -4969,22 +4773,21 @@ var createApp = (context, templateOptions = { selector: "#app" }, config) => {
4969
4773
  root.appendChild(child);
4970
4774
  }
4971
4775
  };
4972
- if (templateOptions.template) {
4973
- const element = document.createRange().createContextualFragment(templateOptions.template);
4776
+ if (template.template) {
4777
+ const element = document.createRange().createContextualFragment(template.template);
4974
4778
  cleanRoot();
4975
4779
  appendChildren(element.childNodes);
4976
- templateOptions.element = element;
4977
- } else if (templateOptions.json) {
4780
+ template.element = element;
4781
+ } else if (template.json) {
4978
4782
  const element = toFragment(
4979
- templateOptions.json,
4980
- templateOptions.isSVG,
4783
+ template.json,
4784
+ template.isSVG,
4981
4785
  config
4982
4786
  );
4983
4787
  cleanRoot();
4984
4788
  appendChildren(element.childNodes);
4985
4789
  }
4986
- if (config.useInterpolation)
4987
- interpolate(root, config);
4790
+ if (config.useInterpolation) interpolate(root, config);
4988
4791
  const app = new RegorApp(context, root, config);
4989
4792
  app.__bind();
4990
4793
  addUnbinder(root, () => {
@@ -5025,13 +4828,10 @@ var toJsonTemplate = (node) => {
5025
4828
  return node.map((x) => toJsonTemplate(x));
5026
4829
  }
5027
4830
  const json = {};
5028
- if (node.tagName)
5029
- json.t = node.tagName;
4831
+ if (node.tagName) json.t = node.tagName;
5030
4832
  else {
5031
- if (node.nodeType === Node.COMMENT_NODE)
5032
- json.n = Node.COMMENT_NODE;
5033
- if (node.textContent)
5034
- json.d = node.textContent;
4833
+ if (node.nodeType === Node.COMMENT_NODE) json.n = Node.COMMENT_NODE;
4834
+ if (node.textContent) json.d = node.textContent;
5035
4835
  return json;
5036
4836
  }
5037
4837
  const attrNames = node.getAttributeNames();
@@ -5050,51 +4850,48 @@ var toJsonTemplate = (node) => {
5050
4850
  };
5051
4851
 
5052
4852
  // src/app/createComponent.ts
5053
- var createComponent = (context, templateOptions, options = {}) => {
4853
+ var createComponent = (context, template, options = {}) => {
5054
4854
  var _a, _b, _c, _d;
5055
- if (isArray(options))
5056
- options = { props: options };
5057
- if (isString(templateOptions))
5058
- templateOptions = { template: templateOptions };
4855
+ if (isArray(options)) options = { props: options };
4856
+ if (isString(template)) template = { template };
5059
4857
  let svgHandled = false;
5060
- if (templateOptions.element) {
5061
- const element2 = templateOptions.element;
4858
+ if (template.element) {
4859
+ const element2 = template.element;
5062
4860
  element2.remove();
5063
- templateOptions.element = element2;
5064
- } else if (templateOptions.selector) {
5065
- const element2 = document.querySelector(templateOptions.selector);
4861
+ template.element = element2;
4862
+ } else if (template.selector) {
4863
+ const element2 = document.querySelector(template.selector);
5066
4864
  if (!element2)
5067
4865
  throw getError(
5068
4866
  1 /* ComponentTemplateNotFound */,
5069
- templateOptions.selector
4867
+ template.selector
5070
4868
  );
5071
4869
  element2.remove();
5072
- templateOptions.element = element2;
5073
- } else if (templateOptions.template) {
5074
- const element2 = document.createRange().createContextualFragment(templateOptions.template);
5075
- templateOptions.element = element2;
5076
- } else if (templateOptions.json) {
5077
- templateOptions.element = toFragment(
5078
- templateOptions.json,
5079
- templateOptions.isSVG,
4870
+ template.element = element2;
4871
+ } else if (template.template) {
4872
+ const element2 = document.createRange().createContextualFragment(template.template);
4873
+ template.element = element2;
4874
+ } else if (template.json) {
4875
+ template.element = toFragment(
4876
+ template.json,
4877
+ template.isSVG,
5080
4878
  options.config
5081
4879
  );
5082
4880
  svgHandled = true;
5083
4881
  }
5084
- if (!templateOptions.element)
5085
- templateOptions.element = document.createDocumentFragment();
5086
- if ((_a = options.useInterpolation) != null ? _a : true)
5087
- interpolate(templateOptions.element);
5088
- const element = templateOptions.element;
5089
- if (!svgHandled && (((_c = templateOptions.isSVG) != null ? _c : isHTMLElement(element) && ((_b = element.hasAttribute) == null ? void 0 : _b.call(element, "isSVG"))) || isHTMLElement(element) && !!element.querySelector("[isSVG]"))) {
5090
- const content = templateOptions.element.content;
4882
+ if (!template.element)
4883
+ template.element = document.createDocumentFragment();
4884
+ if ((_a = options.useInterpolation) != null ? _a : true) interpolate(template.element);
4885
+ const element = template.element;
4886
+ if (!svgHandled && (((_c = template.isSVG) != null ? _c : isHTMLElement(element) && ((_b = element.hasAttribute) == null ? void 0 : _b.call(element, "isSVG"))) || isHTMLElement(element) && !!element.querySelector("[isSVG]"))) {
4887
+ const content = template.element.content;
5091
4888
  const nodes = content ? [...content.childNodes] : [...element.childNodes];
5092
4889
  const json = toJsonTemplate(nodes);
5093
- templateOptions.element = toFragment(json, true, options.config);
4890
+ template.element = toFragment(json, true, options.config);
5094
4891
  }
5095
4892
  return {
5096
4893
  context,
5097
- template: templateOptions.element,
4894
+ template: template.element,
5098
4895
  inheritAttrs: (_d = options.inheritAttrs) != null ? _d : true,
5099
4896
  props: options.props,
5100
4897
  defaultName: options.defaultName
@@ -5108,8 +4905,7 @@ var computed = (compute) => {
5108
4905
  const result = (...args) => {
5109
4906
  if (args.length <= 2 && 0 in args)
5110
4907
  throw getError(4 /* ComputedIsReadOnly */);
5111
- if (computer && !status.isStopped)
5112
- return computer(...args);
4908
+ if (computer && !status.isStopped) return computer(...args);
5113
4909
  computer = computedOnce(compute, status);
5114
4910
  return computer(...args);
5115
4911
  };
@@ -5149,8 +4945,7 @@ var computeMany = (sources, compute) => {
5149
4945
  const result = (...args) => {
5150
4946
  if (args.length <= 2 && 0 in args)
5151
4947
  throw getError(4 /* ComputedIsReadOnly */);
5152
- if (computer && !status.isStopped)
5153
- return computer(...args);
4948
+ if (computer && !status.isStopped) return computer(...args);
5154
4949
  computer = computeManyOnce(sources, compute, status);
5155
4950
  return computer(...args);
5156
4951
  };
@@ -5200,8 +4995,7 @@ var computeRef = (source, compute) => {
5200
4995
  const result = (...args) => {
5201
4996
  if (args.length <= 2 && 0 in args)
5202
4997
  throw getError(4 /* ComputedIsReadOnly */);
5203
- if (computer && !status.isStopped)
5204
- return computer(...args);
4998
+ if (computer && !status.isStopped) return computer(...args);
5205
4999
  computer = computeRefOnce(source, compute, status);
5206
5000
  return computer(...args);
5207
5001
  };
@@ -5246,31 +5040,44 @@ var markRaw = (value) => {
5246
5040
 
5247
5041
  // src/misc/persist.ts
5248
5042
  var persist = (anyRef, key) => {
5249
- if (!key)
5250
- throw new Error("persist requires a string key.");
5043
+ if (!key) throw getError(5 /* PersistRequiresKey */);
5251
5044
  const deepRef = isDeepRef(anyRef);
5252
5045
  const makeRef = deepRef ? ref : (x) => x;
5253
5046
  const store = () => localStorage.setItem(key, JSON.stringify(flatten(anyRef())));
5254
5047
  const existing = localStorage.getItem(key);
5255
5048
  if (existing != null) {
5256
- anyRef(makeRef(JSON.parse(existing)));
5049
+ try {
5050
+ anyRef(makeRef(JSON.parse(existing)));
5051
+ } catch (e) {
5052
+ warning(
5053
+ 6 /* ErrorLog */,
5054
+ `persist: failed to parse data for key ${key}`,
5055
+ e
5056
+ );
5057
+ store();
5058
+ }
5257
5059
  } else {
5258
5060
  store();
5259
5061
  }
5260
5062
  const stopObserving = watchEffect(store);
5261
- onUnmounted(() => stopObserving, true);
5063
+ onUnmounted(stopObserving, true);
5262
5064
  return anyRef;
5263
5065
  };
5264
5066
 
5265
5067
  // src/misc/tagged-html.ts
5266
5068
  var html = (templates, ...args) => {
5267
- let str = "";
5268
- if (args.length === 0)
5269
- return templates.join();
5270
- templates.forEach((template, i) => {
5271
- str += template + args[i];
5272
- });
5273
- return str;
5069
+ let result = "";
5070
+ const tpl = templates;
5071
+ const a = args;
5072
+ const tplLen = tpl.length;
5073
+ const argLen = a.length;
5074
+ for (let i = 0; i < tplLen; ++i) {
5075
+ result += tpl[i];
5076
+ if (i < argLen) {
5077
+ result += a[i];
5078
+ }
5079
+ }
5080
+ return result;
5274
5081
  };
5275
5082
  var raw = html;
5276
5083
 
@@ -5283,8 +5090,7 @@ var observeMany = (sources, observer, init) => {
5283
5090
  for (const source of sources) {
5284
5091
  stopObservingList.push(observe(source, callObserver));
5285
5092
  }
5286
- if (init)
5287
- callObserver();
5093
+ if (init) callObserver();
5288
5094
  const stop = () => {
5289
5095
  for (const stopObserving of stopObservingList) {
5290
5096
  stopObserving();
@@ -5297,7 +5103,7 @@ var observeMany = (sources, observer, init) => {
5297
5103
  // src/observer/observerCount.ts
5298
5104
  var observerCount = (source) => {
5299
5105
  if (!isRef(source))
5300
- throw getError(3 /* RequiresRefSourceArgument */, "observe");
5106
+ throw getError(3 /* RequiresRefSourceArgument */, "observerCount");
5301
5107
  const srefImpl = source;
5302
5108
  return srefImpl(void 0, void 0, 2 /* observerCount */);
5303
5109
  };
@@ -5312,14 +5118,19 @@ var batch = (updater) => {
5312
5118
  }
5313
5119
  };
5314
5120
  var startBatch = () => {
5315
- if (!batchCollector.set)
5316
- batchCollector.set = /* @__PURE__ */ new Set();
5121
+ if (!batchCollector.stack) batchCollector.stack = [];
5122
+ batchCollector.stack.push(/* @__PURE__ */ new Set());
5317
5123
  };
5318
5124
  var endBatch = () => {
5319
- const set = batchCollector.set;
5320
- if (!set)
5125
+ const stack = batchCollector.stack;
5126
+ if (!stack || stack.length === 0) return;
5127
+ const set = stack.pop();
5128
+ if (stack.length) {
5129
+ const parent = stack[stack.length - 1];
5130
+ for (const ref2 of set) parent.add(ref2);
5321
5131
  return;
5322
- delete batchCollector.set;
5132
+ }
5133
+ delete batchCollector.stack;
5323
5134
  for (const ref2 of set) {
5324
5135
  try {
5325
5136
  trigger(ref2);