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.
@@ -34,14 +34,11 @@ var __copyProps = (to, from, except, desc) => {
34
34
  return to;
35
35
  };
36
36
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
- var __publicField = (obj, key, value) => {
38
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
39
- return value;
40
- };
37
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
41
38
 
42
39
  // src/index.ts
43
- var src_exports = {};
44
- __export(src_exports, {
40
+ var index_exports = {};
41
+ __export(index_exports, {
45
42
  ComponentHead: () => ComponentHead,
46
43
  RegorConfig: () => RegorConfig,
47
44
  addUnbinder: () => addUnbinder,
@@ -84,7 +81,7 @@ __export(src_exports, {
84
81
  warningHandler: () => warningHandler,
85
82
  watchEffect: () => watchEffect
86
83
  });
87
- module.exports = __toCommonJS(src_exports);
84
+ module.exports = __toCommonJS(index_exports);
88
85
 
89
86
  // src/common/is-what.ts
90
87
  var isFunction = (value) => {
@@ -117,7 +114,8 @@ var errors = {
117
114
  [1 /* ComponentTemplateNotFound */]: (selector) => `Component template cannot be found. selector: ${selector} .`,
118
115
  [2 /* ComposablesRequireScope */]: "Use composables in scope. usage: useScope(() => new MyApp()).",
119
116
  [3 /* RequiresRefSourceArgument */]: (name2) => `${name2} requires ref source argument`,
120
- [4 /* ComputedIsReadOnly */]: "computed is readonly."
117
+ [4 /* ComputedIsReadOnly */]: "computed is readonly.",
118
+ [5 /* PersistRequiresKey */]: "persist requires a string key."
121
119
  };
122
120
  var getError = (type, ...args) => {
123
121
  const msg = errors[type];
@@ -130,8 +128,7 @@ var bindDataSymbol = Symbol(":regor");
130
128
  // src/cleanup/getBindData.ts
131
129
  var getBindData = (node) => {
132
130
  const bindData = node[bindDataSymbol];
133
- if (bindData)
134
- return bindData;
131
+ if (bindData) return bindData;
135
132
  const newBindData = {
136
133
  unbinders: [],
137
134
  data: {}
@@ -157,8 +154,7 @@ var pushScope = () => {
157
154
  };
158
155
  var peekScope = (noThrow) => {
159
156
  const scope = scopes[scopes.length - 1];
160
- if (!scope && !noThrow)
161
- throw getError(2 /* ComposablesRequireScope */);
157
+ if (!scope && !noThrow) throw getError(2 /* ComposablesRequireScope */);
162
158
  return scope;
163
159
  };
164
160
  var popScope = (context) => {
@@ -173,8 +169,7 @@ var setScope = (context) => {
173
169
  const existing = data[scopeSymbol];
174
170
  if (existing) {
175
171
  const cs = peekScope();
176
- if (existing === cs)
177
- return;
172
+ if (existing === cs) return;
178
173
  cs.onMounted.length > 0 && existing.onMounted.push(...cs.onMounted);
179
174
  cs.onUnmounted.length > 0 && existing.onUnmounted.push(...cs.onUnmounted);
180
175
  return;
@@ -206,8 +201,7 @@ var isRef = (value) => {
206
201
  var observe = (source, observer, init) => {
207
202
  if (!isRef(source))
208
203
  throw getError(3 /* RequiresRefSourceArgument */, "observe");
209
- if (init)
210
- observer(source());
204
+ if (init) observer(source());
211
205
  const srefImpl = source;
212
206
  const stop = srefImpl(
213
207
  void 0,
@@ -226,8 +220,7 @@ var unbind = (node) => {
226
220
  const currentElement = queue.shift();
227
221
  unbindSingle(currentElement);
228
222
  const childNodes = currentElement.childNodes;
229
- if (!childNodes)
230
- continue;
223
+ if (!childNodes) continue;
231
224
  for (const item of childNodes) {
232
225
  queue.push(item);
233
226
  }
@@ -235,8 +228,7 @@ var unbind = (node) => {
235
228
  };
236
229
  var unbindSingle = (node) => {
237
230
  const bindData = node[bindDataSymbol];
238
- if (!bindData)
239
- return;
231
+ if (!bindData) return;
240
232
  for (const unbinder of bindData.unbinders) {
241
233
  unbinder();
242
234
  }
@@ -270,12 +262,9 @@ var warning = (type, ...args) => {
270
262
  const msg = warnings[type];
271
263
  const item = isFunction(msg) ? msg.call(warnings, ...args) : msg;
272
264
  const handler = warningHandler.warning;
273
- if (!handler)
274
- return;
275
- if (isString(item))
276
- handler(item);
277
- else
278
- handler(item, ...item.args);
265
+ if (!handler) return;
266
+ if (isString(item)) handler(item);
267
+ else handler(item, ...item.args);
279
268
  };
280
269
  var warningHandler = { warning: console.warn };
281
270
 
@@ -314,11 +303,9 @@ var getSwitches = (nodes) => {
314
303
  return [...set];
315
304
  };
316
305
  var setSwitchOwner = (owner, switchNodes) => {
317
- if (!hasSwitch())
318
- return;
306
+ if (!hasSwitch()) return;
319
307
  const switches2 = getSwitches(switchNodes);
320
- if (switches2.length === 0)
321
- return;
308
+ if (switches2.length === 0) return;
322
309
  switches2.forEach(refSwitch);
323
310
  addUnbinder(owner, () => {
324
311
  switches2.forEach(removeSwitch);
@@ -374,8 +361,7 @@ var IfBinder = class {
374
361
  return isIfElement;
375
362
  }
376
363
  __isProcessedOrMark(el) {
377
- if (el[ifMarker])
378
- return true;
364
+ if (el[ifMarker]) return true;
379
365
  el[ifMarker] = true;
380
366
  findElements(el, this.__ifSelector).forEach(
381
367
  (x) => x[ifMarker] = true
@@ -406,8 +392,7 @@ var IfBinder = class {
406
392
  removeNode(x);
407
393
  });
408
394
  el.remove();
409
- if (type !== "if")
410
- el[elseMarker] = 1;
395
+ if (type !== "if") el[elseMarker] = 1;
411
396
  const commentEnd = document.createComment(
412
397
  `__end__ :${type}${expression != null ? expression : ""}`
413
398
  );
@@ -420,8 +405,7 @@ var IfBinder = class {
420
405
  };
421
406
  }
422
407
  __collectElses(el, refresh) {
423
- if (!el)
424
- return [];
408
+ if (!el) return [];
425
409
  const nextElement = el.nextElementSibling;
426
410
  if (el.hasAttribute(this.__else)) {
427
411
  el.removeAttribute(this.__else);
@@ -443,8 +427,7 @@ var IfBinder = class {
443
427
  ];
444
428
  } else {
445
429
  const expression = el.getAttribute(this.__elseif);
446
- if (!expression)
447
- return [];
430
+ if (!expression) return [];
448
431
  el.removeAttribute(this.__elseif);
449
432
  const { nodes, parent, commentBegin, commentEnd } = this.__createRegion(
450
433
  el,
@@ -553,8 +536,7 @@ var bindChildNodes = (binder, childNodes) => {
553
536
  var findElements = (element, selector) => {
554
537
  var _a;
555
538
  const result = element.querySelectorAll(selector);
556
- if ((_a = element.matches) == null ? void 0 : _a.call(element, selector))
557
- return [element, ...result];
539
+ if ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) return [element, ...result];
558
540
  return result;
559
541
  };
560
542
  var isTemplate = (node) => node instanceof HTMLTemplateElement;
@@ -576,8 +558,7 @@ var defineRefValue = (result, isReadOnly) => {
576
558
  return result();
577
559
  },
578
560
  set(value) {
579
- if (isReadOnly)
580
- throw new Error("value is readonly.");
561
+ if (isReadOnly) throw new Error("value is readonly.");
581
562
  return result(value);
582
563
  },
583
564
  enumerable: true,
@@ -585,10 +566,8 @@ var defineRefValue = (result, isReadOnly) => {
585
566
  });
586
567
  };
587
568
  var isOptionDynamic = (option, dynamic) => {
588
- if (!option)
589
- return false;
590
- if (option.startsWith("["))
591
- return option.substring(1, option.length - 1);
569
+ if (!option) return false;
570
+ if (option.startsWith("[")) return option.substring(1, option.length - 1);
592
571
  const len = dynamic.length;
593
572
  if (option.startsWith(dynamic)) {
594
573
  return option.substring(len, option.length - len);
@@ -614,19 +593,16 @@ var cacheStringFunction = (fn) => {
614
593
  };
615
594
  var camelizeRE = /-(\w)/g;
616
595
  var camelize = cacheStringFunction((str) => {
617
- if (!str)
618
- return str;
596
+ if (!str) return str;
619
597
  return str.replace(camelizeRE, (_, c) => c ? c.toUpperCase() : "");
620
598
  });
621
599
  var hyphenateRE = /\B([A-Z])/g;
622
600
  var hyphenate = cacheStringFunction((str) => {
623
- if (!str)
624
- return str;
601
+ if (!str) return str;
625
602
  return str.replace(hyphenateRE, "-$1").toLowerCase();
626
603
  });
627
604
  var capitalize = cacheStringFunction((str) => {
628
- if (!str)
629
- return str;
605
+ if (!str) return str;
630
606
  return str.charAt(0).toUpperCase() + str.slice(1);
631
607
  });
632
608
 
@@ -634,14 +610,12 @@ var capitalize = cacheStringFunction((str) => {
634
610
  var collectedRefs = [];
635
611
  var collectRef = (ref2) => {
636
612
  var _a;
637
- if (collectedRefs.length === 0)
638
- return;
613
+ if (collectedRefs.length === 0) return;
639
614
  (_a = collectedRefs[collectedRefs.length - 1]) == null ? void 0 : _a.add(ref2);
640
615
  };
641
616
  var watchEffect = (effect) => {
642
- if (!effect)
643
- return () => {
644
- };
617
+ if (!effect) return () => {
618
+ };
645
619
  const terminator = { stop: () => {
646
620
  } };
647
621
  watchEffectInternal(effect, terminator);
@@ -649,13 +623,11 @@ var watchEffect = (effect) => {
649
623
  return terminator.stop;
650
624
  };
651
625
  var watchEffectInternal = (effect, terminator) => {
652
- if (!effect)
653
- return;
626
+ if (!effect) return;
654
627
  let stopObservingList = [];
655
628
  let isStopped = false;
656
629
  const stopWatch = () => {
657
- for (const stop of stopObservingList)
658
- stop();
630
+ for (const stop of stopObservingList) stop();
659
631
  stopObservingList = [];
660
632
  isStopped = true;
661
633
  };
@@ -664,8 +636,7 @@ var watchEffectInternal = (effect, terminator) => {
664
636
  const set = /* @__PURE__ */ new Set();
665
637
  collectedRefs.push(set);
666
638
  effect((onCleanup) => stopObservingList.push(onCleanup));
667
- if (isStopped)
668
- return;
639
+ if (isStopped) return;
669
640
  for (const r of [...set]) {
670
641
  const stopObserving = observe(r, () => {
671
642
  stopWatch();
@@ -705,15 +676,12 @@ var isRaw = (value) => {
705
676
 
706
677
  // src/reactivity/trigger.ts
707
678
  var trigger = (source, eventSource, isRecursive) => {
708
- if (!isRef(source))
709
- return;
679
+ if (!isRef(source)) return;
710
680
  const srefImpl = source;
711
681
  srefImpl(void 0, eventSource, 1 /* trigger */);
712
- if (!isRecursive)
713
- return;
682
+ if (!isRecursive) return;
714
683
  const obj = srefImpl();
715
- if (!obj)
716
- return;
684
+ if (!obj) return;
717
685
  if (isArray(obj) || isSet(obj)) {
718
686
  for (const el of obj) {
719
687
  trigger(el, eventSource, true);
@@ -746,8 +714,7 @@ var createProxy = (originalProto, proxyProto, methodsToPatch4) => {
746
714
  define(proxyProto, method, function mutator(...args) {
747
715
  const result = original.apply(this, args);
748
716
  const subscribers = this[srefSymbol];
749
- for (const subscriber of subscribers)
750
- trigger(subscriber);
717
+ for (const subscriber of subscribers) trigger(subscriber);
751
718
  return result;
752
719
  });
753
720
  });
@@ -792,17 +759,14 @@ createProxy(setProto, proxySetProto, methodsToPatch3);
792
759
  // src/reactivity/sref.ts
793
760
  var batchCollector = {};
794
761
  var sref = (value) => {
795
- if (isRef(value) || isRaw(value))
796
- return value;
762
+ if (isRef(value) || isRaw(value)) return value;
797
763
  const refObj = {
798
764
  auto: true,
799
765
  _value: value
800
766
  };
801
767
  const createProxy2 = (value2) => {
802
- if (!isObject(value2))
803
- return false;
804
- if (srefSymbol in value2)
805
- return true;
768
+ if (!isObject(value2)) return false;
769
+ if (srefSymbol in value2) return true;
806
770
  const isAnArray = isArray(value2);
807
771
  if (isAnArray) {
808
772
  Object.setPrototypeOf(value2, proxyArrayProto);
@@ -823,24 +787,22 @@ var sref = (value) => {
823
787
  const isProxy = createProxy2(value);
824
788
  const observers = /* @__PURE__ */ new Set();
825
789
  const trigger2 = (newValue, eventSource) => {
826
- if (batchCollector.set) {
827
- batchCollector.set.add(srefFunction);
790
+ if (batchCollector.stack && batchCollector.stack.length) {
791
+ const current = batchCollector.stack[batchCollector.stack.length - 1];
792
+ current.add(srefFunction);
828
793
  return;
829
794
  }
830
- if (observers.size === 0)
831
- return;
795
+ if (observers.size === 0) return;
832
796
  silence(() => {
833
797
  for (const callback of [...observers.keys()]) {
834
- if (!observers.has(callback))
835
- continue;
798
+ if (!observers.has(callback)) continue;
836
799
  callback(newValue, eventSource);
837
800
  }
838
801
  });
839
802
  };
840
803
  const attachProxyHandle = (value2) => {
841
804
  let proxyHandle = value2[srefSymbol];
842
- if (!proxyHandle)
843
- value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
805
+ if (!proxyHandle) value2[srefSymbol] = proxyHandle = /* @__PURE__ */ new Set();
844
806
  proxyHandle.add(srefFunction);
845
807
  };
846
808
  const srefFunction = (...args) => {
@@ -848,15 +810,12 @@ var sref = (value) => {
848
810
  let newValue = args[0];
849
811
  const eventSource = args[1];
850
812
  if (0 in args) {
851
- if (refObj._value === newValue)
852
- return newValue;
813
+ if (refObj._value === newValue) return newValue;
853
814
  if (isRef(newValue)) {
854
815
  newValue = newValue();
855
- if (refObj._value === newValue)
856
- return newValue;
816
+ if (refObj._value === newValue) return newValue;
857
817
  }
858
- if (createProxy2(newValue))
859
- attachProxyHandle(newValue);
818
+ if (createProxy2(newValue)) attachProxyHandle(newValue);
860
819
  refObj._value = newValue;
861
820
  if (refObj.auto) {
862
821
  trigger2(newValue, eventSource);
@@ -871,9 +830,8 @@ var sref = (value) => {
871
830
  switch (operation) {
872
831
  case 0 /* observe */: {
873
832
  const observer = args[3];
874
- if (!observer)
875
- return () => {
876
- };
833
+ if (!observer) return () => {
834
+ };
877
835
  const removeObserver = (observer2) => {
878
836
  observers.delete(observer2);
879
837
  };
@@ -903,8 +861,7 @@ var sref = (value) => {
903
861
  };
904
862
  srefFunction[srefSymbol] = 1;
905
863
  defineRefValue(srefFunction, false);
906
- if (isProxy)
907
- attachProxyHandle(value);
864
+ if (isProxy) attachProxyHandle(value);
908
865
  return srefFunction;
909
866
  };
910
867
 
@@ -931,14 +888,12 @@ var MountList = class {
931
888
  }
932
889
  __setValueMap(item) {
933
890
  const value = this.__getKey(item.value);
934
- if (value)
935
- this.__valueMap.set(value, item);
891
+ if (value !== void 0) this.__valueMap.set(value, item);
936
892
  }
937
893
  __deleteValueMap(index) {
938
894
  var _a;
939
895
  const value = this.__getKey((_a = this.__list[index]) == null ? void 0 : _a.value);
940
- if (value)
941
- this.__valueMap.delete(value);
896
+ if (value !== void 0) this.__valueMap.delete(value);
942
897
  }
943
898
  /**
944
899
  * @internal
@@ -958,8 +913,7 @@ var MountList = class {
958
913
  }
959
914
  __insertAt(index, item) {
960
915
  const len = this.__length;
961
- for (let i = index; i < len; ++i)
962
- this.__list[i].order = i + 1;
916
+ for (let i = index; i < len; ++i) this.__list[i].order = i + 1;
963
917
  item.order = index;
964
918
  this.__list.splice(index, 0, item);
965
919
  this.__setValueMap(item);
@@ -977,13 +931,11 @@ var MountList = class {
977
931
  this.__deleteValueMap(index);
978
932
  this.__list.splice(index, 1);
979
933
  const len = this.__length;
980
- for (let i = index; i < len; ++i)
981
- this.__list[i].order = i;
934
+ for (let i = index; i < len; ++i) this.__list[i].order = i;
982
935
  }
983
936
  __removeAllAfter(index) {
984
937
  const len = this.__length;
985
- for (let i = index; i < len; ++i)
986
- this.__deleteValueMap(i);
938
+ for (let i = index; i < len; ++i) this.__deleteValueMap(i);
987
939
  this.__list.splice(index);
988
940
  }
989
941
  __isValueMounted(value) {
@@ -1018,8 +970,7 @@ var _ForBinder = class _ForBinder {
1018
970
  return isForElement;
1019
971
  }
1020
972
  __isProcessedOrMark(el) {
1021
- if (el[forMarker])
1022
- return true;
973
+ if (el[forMarker]) return true;
1023
974
  el[forMarker] = true;
1024
975
  findElements(el, this.__forSelector).forEach(
1025
976
  (x) => x[forMarker] = true
@@ -1027,8 +978,7 @@ var _ForBinder = class _ForBinder {
1027
978
  return false;
1028
979
  }
1029
980
  __bindFor(el) {
1030
- if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el))
1031
- return;
981
+ if (el.hasAttribute(this.__pre) || this.__isProcessedOrMark(el)) return;
1032
982
  const forPath = el.getAttribute(this.__for);
1033
983
  if (!forPath) {
1034
984
  warning(0 /* MissingBindingExpression */, this.__for, el);
@@ -1038,10 +988,8 @@ var _ForBinder = class _ForBinder {
1038
988
  this.__bindForToPath(el, forPath);
1039
989
  }
1040
990
  __getIterable(obj) {
1041
- if (isNullOrUndefined(obj))
1042
- return [];
1043
- if (isFunction(obj))
1044
- obj = obj();
991
+ if (isNullOrUndefined(obj)) return [];
992
+ if (isFunction(obj)) obj = obj();
1045
993
  if (Symbol.iterator in Object(obj)) {
1046
994
  return obj;
1047
995
  }
@@ -1078,8 +1026,7 @@ var _ForBinder = class _ForBinder {
1078
1026
  const areEqual = (a, b) => getKey(a) === getKey(b);
1079
1027
  const nodes = getNodes(el);
1080
1028
  const parent = el.parentNode;
1081
- if (!parent)
1082
- return;
1029
+ if (!parent) return;
1083
1030
  const title = `${this.__for} => ${forPath}`;
1084
1031
  const commentBegin = new Comment(`__begin__ ${title}`);
1085
1032
  parent.insertBefore(commentBegin, el);
@@ -1138,8 +1085,7 @@ var _ForBinder = class _ForBinder {
1138
1085
  };
1139
1086
  const updateDom = (newValues) => {
1140
1087
  let len = mountList.__length;
1141
- if (isFunction(newValues))
1142
- newValues = newValues();
1088
+ if (isFunction(newValues)) newValues = newValues();
1143
1089
  const unrefedNewValue = unref(newValues[0]);
1144
1090
  if (isArray(unrefedNewValue) && unrefedNewValue.length === 0) {
1145
1091
  unmount(commentBegin, commentEnd);
@@ -1155,8 +1101,7 @@ var _ForBinder = class _ForBinder {
1155
1101
  const modify = () => {
1156
1102
  if (i2 < len) {
1157
1103
  const mountItem = mountList.__get(i2++);
1158
- if (areEqual(mountItem.value, newValue))
1159
- return;
1104
+ if (areEqual(mountItem.value, newValue)) return;
1160
1105
  const newValueMountPosition = mountList.__lookupValueOrderIfMounted(
1161
1106
  getKey(newValue)
1162
1107
  );
@@ -1171,8 +1116,7 @@ var _ForBinder = class _ForBinder {
1171
1116
  --len;
1172
1117
  if (newValueMountPosition > i2 + 1) {
1173
1118
  for (let j2 = i2; j2 < newValueMountPosition - 1 && j2 < len; ) {
1174
- if (areEqual(mountList.__get(i2).value, newValue))
1175
- break;
1119
+ if (areEqual(mountList.__get(i2).value, newValue)) break;
1176
1120
  ++j2;
1177
1121
  remove(i2);
1178
1122
  mountList.__removeAt(i2);
@@ -1203,8 +1147,7 @@ var _ForBinder = class _ForBinder {
1203
1147
  }
1204
1148
  const j = i2;
1205
1149
  len = mountList.__length;
1206
- while (i2 < len)
1207
- remove(i2++);
1150
+ while (i2 < len) remove(i2++);
1208
1151
  mountList.__removeAllAfter(j);
1209
1152
  updateIndexes(firstRemovalOrInsertionIndex);
1210
1153
  };
@@ -1229,16 +1172,13 @@ var _ForBinder = class _ForBinder {
1229
1172
  __parseForPath(forPath) {
1230
1173
  var _a, _b;
1231
1174
  const matches = _ForBinder.__forPathRegex.exec(forPath);
1232
- if (!matches)
1233
- return;
1175
+ if (!matches) return;
1234
1176
  const keys = (matches[1] + ((_a = matches[2]) != null ? _a : "")).split(",").map((key) => key.trim());
1235
1177
  const indexOfIndex = keys.length > 1 ? keys.length - 1 : -1;
1236
1178
  const index = indexOfIndex !== -1 && (keys[indexOfIndex] === "index" || ((_b = keys[indexOfIndex]) == null ? void 0 : _b.startsWith("#"))) ? keys[indexOfIndex] : "";
1237
- if (index)
1238
- keys.splice(indexOfIndex, 1);
1179
+ if (index) keys.splice(indexOfIndex, 1);
1239
1180
  const list = matches[3];
1240
- if (!list || keys.length === 0)
1241
- return;
1181
+ if (!list || keys.length === 0) return;
1242
1182
  const hasDestructuring = /[{[]/.test(forPath);
1243
1183
  return {
1244
1184
  list,
@@ -1266,7 +1206,7 @@ var _ForBinder = class _ForBinder {
1266
1206
  };
1267
1207
  }
1268
1208
  };
1269
- __publicField(_ForBinder, "__forPathRegex", /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+([^\s]+)\s*/);
1209
+ __publicField(_ForBinder, "__forPathRegex", /\{?\[?\(?([^)}\]]+)\)?\]?\}?([^)]+)?\s+\b(?:in|of)\b\s+(.*)\s*$/);
1270
1210
  var ForBinder = _ForBinder;
1271
1211
 
1272
1212
  // src/bind/DynamicBinder.ts
@@ -1297,8 +1237,7 @@ var DynamicBinder = class {
1297
1237
  let expression = el.getAttribute(this.__is);
1298
1238
  if (!expression) {
1299
1239
  expression = el.getAttribute("is");
1300
- if (!expression || !expression.startsWith("regor:"))
1301
- return;
1240
+ if (!expression || !expression.startsWith("regor:")) return;
1302
1241
  expression = `'${expression.slice(6)}'`;
1303
1242
  el.removeAttribute("is");
1304
1243
  }
@@ -1356,13 +1295,11 @@ var DynamicBinder = class {
1356
1295
  unmount(commentBegin, commentEnd);
1357
1296
  return;
1358
1297
  }
1359
- if (mounted.name === name2)
1360
- return;
1298
+ if (mounted.name === name2) return;
1361
1299
  unmount(commentBegin, commentEnd);
1362
1300
  const componentElement = document.createElement(name2);
1363
1301
  for (const attr of el.getAttributeNames()) {
1364
- if (attr === this.__is)
1365
- continue;
1302
+ if (attr === this.__is) continue;
1366
1303
  componentElement.setAttribute(attr, el.getAttribute(attr));
1367
1304
  }
1368
1305
  mount2(componentChildNodes, componentElement);
@@ -1403,8 +1340,7 @@ var propsDirective = {
1403
1340
  const key = item[0];
1404
1341
  const value2 = item[1];
1405
1342
  const ctxKey = ctx[key];
1406
- if (ctxKey === value2)
1407
- continue;
1343
+ if (ctxKey === value2) continue;
1408
1344
  if (isRef(ctxKey)) {
1409
1345
  ctxKey(value2);
1410
1346
  } else {
@@ -1434,8 +1370,7 @@ var propsOnceDirective = {
1434
1370
  const key = item[0];
1435
1371
  const value2 = item[1];
1436
1372
  const ctxKey = ctx[key];
1437
- if (ctxKey === value2)
1438
- continue;
1373
+ if (ctxKey === value2) continue;
1439
1374
  if (isRef(ctxKey)) {
1440
1375
  ctxKey(value2);
1441
1376
  } else {
@@ -1524,16 +1459,14 @@ var useScope = (context) => {
1524
1459
  }
1525
1460
  };
1526
1461
  var isScope = (value) => {
1527
- if (!isObject(value))
1528
- return false;
1462
+ if (!isObject(value)) return false;
1529
1463
  return scopeSymbol2 in value;
1530
1464
  };
1531
1465
 
1532
1466
  // src/reactivity/entangle.ts
1533
1467
  var entangle = (r1, r2) => {
1534
- if (r1 === r2)
1535
- return () => {
1536
- };
1468
+ if (r1 === r2) return () => {
1469
+ };
1537
1470
  const stop1 = observe(r1, (v) => r2(v));
1538
1471
  const stop2 = observe(r2, (v) => r1(v));
1539
1472
  r2(r1());
@@ -1557,9 +1490,8 @@ var callMounted = (context) => {
1557
1490
  var singlePropDirective = {
1558
1491
  collectRefObj: true,
1559
1492
  onBind: (_, parseResult, _expr, option, _dynamicOption, _flags) => {
1560
- if (!option)
1561
- return () => {
1562
- };
1493
+ if (!option) return () => {
1494
+ };
1563
1495
  const key = camelize(option);
1564
1496
  const stopObserving = observe(
1565
1497
  parseResult.value,
@@ -1568,8 +1500,7 @@ var singlePropDirective = {
1568
1500
  const value = (_a = parseResult.refs[0]) != null ? _a : parseResult.value()[0];
1569
1501
  const ctx = parseResult.context;
1570
1502
  const ctxKey = ctx[option];
1571
- if (ctxKey === value)
1572
- return;
1503
+ if (ctxKey === value) return;
1573
1504
  if (isRef(ctxKey)) {
1574
1505
  ctxKey(value);
1575
1506
  } else {
@@ -1606,28 +1537,22 @@ var ComponentBinder = class {
1606
1537
  ...[...registeredComponents.keys()].map(hyphenate),
1607
1538
  ...[...Object.keys(contextComponents)].map(hyphenate)
1608
1539
  ].join(",");
1609
- if (isNullOrWhitespace(selector))
1610
- return;
1540
+ if (isNullOrWhitespace(selector)) return;
1611
1541
  const list = element.querySelectorAll(selector);
1612
1542
  const components = ((_a = element.matches) == null ? void 0 : _a.call(element, selector)) ? [element, ...list] : list;
1613
1543
  for (const component of components) {
1614
- if (component.hasAttribute(binder.__pre))
1615
- continue;
1544
+ if (component.hasAttribute(binder.__pre)) continue;
1616
1545
  const parent = component.parentNode;
1617
- if (!parent)
1618
- continue;
1546
+ if (!parent) continue;
1619
1547
  const nextSibling = component.nextSibling;
1620
1548
  const tagName = camelize(component.tagName).toUpperCase();
1621
1549
  const contextComponent = contextComponents[tagName];
1622
1550
  const registeredComponent = contextComponent != null ? contextComponent : registeredComponentsUpperCase.get(tagName);
1623
- if (!registeredComponent)
1624
- continue;
1551
+ if (!registeredComponent) continue;
1625
1552
  const templateElement = registeredComponent.template;
1626
- if (!templateElement)
1627
- continue;
1553
+ if (!templateElement) continue;
1628
1554
  const componentParent = component.parentElement;
1629
- if (!componentParent)
1630
- continue;
1555
+ if (!componentParent) continue;
1631
1556
  const startOfComponent = new Comment(
1632
1557
  " begin component: " + component.tagName
1633
1558
  );
@@ -1643,30 +1568,24 @@ var ComponentBinder = class {
1643
1568
  const hasPropsOnce = component2.hasAttribute(propsOnceName);
1644
1569
  parser.__scoped(capturedContext2, () => {
1645
1570
  parser.__push(props);
1646
- if (hasProps)
1647
- binder.__bind(propsDirective, component2, propsName);
1571
+ if (hasProps) binder.__bind(propsDirective, component2, propsName);
1648
1572
  if (hasPropsOnce)
1649
1573
  binder.__bind(propsOnceDirective, component2, propsOnceName);
1650
1574
  let definedProps = registeredComponent.props;
1651
- if (!definedProps || definedProps.length === 0)
1652
- return;
1575
+ if (!definedProps || definedProps.length === 0) return;
1653
1576
  definedProps = definedProps.map(camelize);
1654
1577
  for (const name2 of definedProps.concat(definedProps.map(hyphenate))) {
1655
1578
  const value = component2.getAttribute(name2);
1656
- if (value === null)
1657
- continue;
1579
+ if (value === null) continue;
1658
1580
  props[camelize(name2)] = value;
1659
1581
  component2.removeAttribute(name2);
1660
1582
  }
1661
1583
  const map = binder.__directiveCollector.__collect(component2, false);
1662
1584
  for (const [attrName, item] of map.entries()) {
1663
1585
  const [name2, option] = item.__terms;
1664
- if (!option)
1665
- continue;
1666
- if (!definedProps.includes(camelize(option)))
1667
- continue;
1668
- if (name2 !== "." && name2 !== ":" && name2 !== bindName)
1669
- continue;
1586
+ if (!option) continue;
1587
+ if (!definedProps.includes(camelize(option))) continue;
1588
+ if (name2 !== "." && name2 !== ":" && name2 !== bindName) continue;
1670
1589
  binder.__bind(
1671
1590
  singlePropDirective,
1672
1591
  component2,
@@ -1698,16 +1617,13 @@ var ComponentBinder = class {
1698
1617
  for (const [key, propsValue] of Object.entries(props)) {
1699
1618
  if (key in componentCtx2) {
1700
1619
  const compValue = componentCtx2[key];
1701
- if (compValue === propsValue)
1702
- continue;
1620
+ if (compValue === propsValue) continue;
1703
1621
  if (head2.entangle && isRef(compValue) && isRef(propsValue)) {
1704
1622
  addUnbinder(startOfComponent, entangle(propsValue, compValue));
1705
1623
  } else if (isRef(compValue)) {
1706
1624
  compValue(propsValue);
1707
- } else
1708
- componentCtx2[key] = unref(propsValue);
1709
- } else
1710
- componentCtx2[key] = propsValue;
1625
+ } else componentCtx2[key] = unref(propsValue);
1626
+ } else componentCtx2[key] = propsValue;
1711
1627
  }
1712
1628
  (_a2 = head2.onAutoPropsAssigned) == null ? void 0 : _a2.call(head2);
1713
1629
  }
@@ -1730,8 +1646,7 @@ var ComponentBinder = class {
1730
1646
  name2 = slot.getAttributeNames().filter((x) => x.startsWith("#"))[0];
1731
1647
  if (isNullOrWhitespace(name2)) {
1732
1648
  name2 = "default";
1733
- } else
1734
- name2 = name2.substring(1);
1649
+ } else name2 = name2.substring(1);
1735
1650
  }
1736
1651
  let compTemplate = component.querySelector(
1737
1652
  `template[name='${name2}'], template[\\#${name2}]`
@@ -1742,8 +1657,7 @@ var ComponentBinder = class {
1742
1657
  compTemplate = null;
1743
1658
  }
1744
1659
  const createSwitchContext = (childNodes2) => {
1745
- if (head.disableSwitch)
1746
- return;
1660
+ if (head.disableSwitch) return;
1747
1661
  parser.__scoped(capturedContext, () => {
1748
1662
  parser.__push(componentCtx);
1749
1663
  const props = getProps(slot, parser.__capture());
@@ -1752,8 +1666,7 @@ var ComponentBinder = class {
1752
1666
  const switchContext = parser.__capture();
1753
1667
  const id = addSwitch(switchContext);
1754
1668
  for (const child of childNodes2) {
1755
- if (!isElement(child))
1756
- continue;
1669
+ if (!isElement(child)) continue;
1757
1670
  child.setAttribute(rswitch, id);
1758
1671
  refSwitch(id);
1759
1672
  addUnbinder(child, () => {
@@ -1786,8 +1699,7 @@ var ComponentBinder = class {
1786
1699
  }
1787
1700
  };
1788
1701
  const expandNestedSlots = (node) => {
1789
- if (!isElement(node))
1790
- return;
1702
+ if (!isElement(node)) return;
1791
1703
  const slots = node.querySelectorAll("slot");
1792
1704
  if (isSlot(node)) {
1793
1705
  expandSlot(node);
@@ -1809,8 +1721,7 @@ var ComponentBinder = class {
1809
1721
  expandSlots();
1810
1722
  componentParent.insertBefore(endOfComponent, nextSibling);
1811
1723
  const transferAttributesToTheComponentChild = () => {
1812
- if (!registeredComponent.inheritAttrs)
1813
- return;
1724
+ if (!registeredComponent.inheritAttrs) return;
1814
1725
  let inheritorChildNodes = childNodes.filter(
1815
1726
  (x) => x.nodeType === Node.ELEMENT_NODE
1816
1727
  );
@@ -1819,11 +1730,9 @@ var ComponentBinder = class {
1819
1730
  (x) => x.hasAttribute(this.__inherit)
1820
1731
  );
1821
1732
  const inheritor = inheritorChildNodes[0];
1822
- if (!inheritor)
1823
- return;
1733
+ if (!inheritor) return;
1824
1734
  for (const attrName of component.getAttributeNames()) {
1825
- if (attrName === propsName || attrName === propsOnceName)
1826
- continue;
1735
+ if (attrName === propsName || attrName === propsOnceName) continue;
1827
1736
  const value = component.getAttribute(attrName);
1828
1737
  if (attrName === "class") {
1829
1738
  inheritor.classList.add(...value.split(" "));
@@ -1883,12 +1792,10 @@ var DirectiveElement = class {
1883
1792
  __parse() {
1884
1793
  let name2 = this.__name;
1885
1794
  const isPropShortcut = name2.startsWith(".");
1886
- if (isPropShortcut)
1887
- name2 = ":" + name2.slice(1);
1795
+ if (isPropShortcut) name2 = ":" + name2.slice(1);
1888
1796
  const firstFlagIndex = name2.indexOf(".");
1889
1797
  const terms = this.__terms = (firstFlagIndex < 0 ? name2 : name2.substring(0, firstFlagIndex)).split(/[:@]/);
1890
- if (isNullOrWhitespace(terms[0]))
1891
- terms[0] = isPropShortcut ? "." : name2[0];
1798
+ if (isNullOrWhitespace(terms[0])) terms[0] = isPropShortcut ? "." : name2[0];
1892
1799
  if (firstFlagIndex >= 0) {
1893
1800
  const flags = this.__flags = name2.slice(firstFlagIndex + 1).split(".");
1894
1801
  if (flags.includes("camel")) {
@@ -1910,21 +1817,18 @@ var DirectiveCollector = class {
1910
1817
  }
1911
1818
  __collect(element, isRecursive) {
1912
1819
  const map = /* @__PURE__ */ new Map();
1913
- if (!isHTMLElement(element))
1914
- return map;
1820
+ if (!isHTMLElement(element)) return map;
1915
1821
  const prefixes2 = this.__prefixes;
1916
1822
  const processNode = (node) => {
1917
1823
  const names = node.getAttributeNames().filter((name2) => prefixes2.some((p) => name2.startsWith(p)));
1918
1824
  for (const name2 of names) {
1919
- if (!map.has(name2))
1920
- map.set(name2, new DirectiveElement(name2));
1825
+ if (!map.has(name2)) map.set(name2, new DirectiveElement(name2));
1921
1826
  const item = map.get(name2);
1922
1827
  item.__elements.push(node);
1923
1828
  }
1924
1829
  };
1925
1830
  processNode(element);
1926
- if (!isRecursive)
1927
- return map;
1831
+ if (!isRecursive) return map;
1928
1832
  const nodes = element.querySelectorAll("*");
1929
1833
  for (const node of nodes) {
1930
1834
  processNode(node);
@@ -1961,15 +1865,12 @@ var Binder = class {
1961
1865
  __unwrapTemplates(element) {
1962
1866
  const templates = isTemplate(element) ? [element] : element.querySelectorAll("template");
1963
1867
  for (const template of templates) {
1964
- if (template.hasAttribute(this.__pre))
1965
- continue;
1868
+ if (template.hasAttribute(this.__pre)) continue;
1966
1869
  const parent = template.parentNode;
1967
- if (!parent)
1968
- continue;
1870
+ if (!parent) continue;
1969
1871
  const nextSibling = template.nextSibling;
1970
1872
  template.remove();
1971
- if (!template.content)
1972
- continue;
1873
+ if (!template.content) continue;
1973
1874
  const childNodes = [...template.content.childNodes];
1974
1875
  for (const child of childNodes) {
1975
1876
  parent.insertBefore(child, nextSibling);
@@ -1980,12 +1881,9 @@ var Binder = class {
1980
1881
  __bindDefault(element) {
1981
1882
  if (element.nodeType !== Node.ELEMENT_NODE || element.hasAttribute(this.__pre))
1982
1883
  return;
1983
- if (this.__ifBinder.__bindAll(element))
1984
- return;
1985
- if (this.__forBinder.__bindAll(element))
1986
- return;
1987
- if (this.__dynamicBinder.__bindAll(element))
1988
- return;
1884
+ if (this.__ifBinder.__bindAll(element)) return;
1885
+ if (this.__forBinder.__bindAll(element)) return;
1886
+ if (this.__dynamicBinder.__bindAll(element)) return;
1989
1887
  this.__componentBinder.__bindAll(element);
1990
1888
  this.__unwrapTemplates(element);
1991
1889
  this.__bindAttributes(element, true);
@@ -2007,16 +1905,13 @@ var Binder = class {
2007
1905
  }
2008
1906
  }
2009
1907
  __bind(config, el, attribute, _noWarning, option, flags) {
2010
- if (el.hasAttribute(this.__pre))
2011
- return;
1908
+ if (el.hasAttribute(this.__pre)) return;
2012
1909
  const bindExpression = el.getAttribute(attribute);
2013
1910
  el.removeAttribute(attribute);
2014
1911
  const getParentSwitch = (el2) => {
2015
1912
  const switchId = el2.getAttribute(rswitch);
2016
- if (switchId)
2017
- return switchId;
2018
- if (!el2.parentElement)
2019
- return null;
1913
+ if (switchId) return switchId;
1914
+ if (!el2.parentElement) return null;
2020
1915
  return getParentSwitch(el2.parentElement);
2021
1916
  };
2022
1917
  if (hasSwitch()) {
@@ -2031,15 +1926,12 @@ var Binder = class {
2031
1926
  this.__bindToExpression(config, el, bindExpression, option, flags);
2032
1927
  }
2033
1928
  __handleTeleport(config, el, valueExpression) {
2034
- if (config !== teleportDirective)
2035
- return false;
2036
- if (isNullOrWhitespace(valueExpression))
2037
- return true;
1929
+ if (config !== teleportDirective) return false;
1930
+ if (isNullOrWhitespace(valueExpression)) return true;
2038
1931
  const teleportTo = document.querySelector(valueExpression);
2039
1932
  if (teleportTo) {
2040
1933
  const parent = el.parentElement;
2041
- if (!parent)
2042
- return true;
1934
+ if (!parent) return true;
2043
1935
  const placeholder = new Comment(`teleported => '${valueExpression}'`);
2044
1936
  parent.insertBefore(placeholder, el);
2045
1937
  el.teleportedFrom = placeholder;
@@ -2053,10 +1945,8 @@ var Binder = class {
2053
1945
  }
2054
1946
  __bindToExpression(config, el, valueExpression, option, flags) {
2055
1947
  var _a;
2056
- if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null)
2057
- return;
2058
- if (this.__handleTeleport(config, el, valueExpression))
2059
- return;
1948
+ if (el.nodeType !== Node.ELEMENT_NODE || valueExpression == null) return;
1949
+ if (this.__handleTeleport(config, el, valueExpression)) return;
2060
1950
  const result = this.__parser.__parse(
2061
1951
  valueExpression,
2062
1952
  config.isLazy,
@@ -2100,8 +1990,7 @@ var Binder = class {
2100
1990
  return previousOption;
2101
1991
  };
2102
1992
  const observeTailChanges = () => {
2103
- if (!config.onChange)
2104
- return;
1993
+ if (!config.onChange) return;
2105
1994
  const stopObserving = observe(result.value, (_) => {
2106
1995
  var _a2;
2107
1996
  const pre = previousValues;
@@ -2118,8 +2007,7 @@ var Binder = class {
2118
2007
  stopObserverList.push(stopObserving2);
2119
2008
  }
2120
2009
  };
2121
- if (!config.once)
2122
- observeTailChanges();
2010
+ if (!config.once) observeTailChanges();
2123
2011
  if (config.onBind)
2124
2012
  stopObserverList.push(
2125
2013
  config.onBind(
@@ -2309,8 +2197,7 @@ var Jsep = class {
2309
2197
  }
2310
2198
  __runHook(hookType, hookCalltype, node) {
2311
2199
  const hook = this.__hooks[hookType];
2312
- if (!hook)
2313
- return node;
2200
+ if (!hook) return node;
2314
2201
  const env = { node };
2315
2202
  const hookFn = (f) => {
2316
2203
  f.call(this, env);
@@ -2329,8 +2216,7 @@ var Jsep = class {
2329
2216
  }
2330
2217
  parse() {
2331
2218
  const nodes = this.__gobbleExpressions();
2332
- if (nodes.length === 1)
2333
- return nodes[0];
2219
+ if (nodes.length === 1) return nodes[0];
2334
2220
  return {
2335
2221
  type: 0 /* Compound */,
2336
2222
  body: nodes
@@ -2946,8 +2832,7 @@ var Jsep = class {
2946
2832
  this.__updateBinariesToArrows(env.node);
2947
2833
  }
2948
2834
  __updateBinariesToArrows(node) {
2949
- if (!node)
2950
- return;
2835
+ if (!node) return;
2951
2836
  Object.values(node).forEach((val) => {
2952
2837
  if (val && typeof val === "object") {
2953
2838
  this.__updateBinariesToArrows(val);
@@ -2966,8 +2851,7 @@ var Jsep = class {
2966
2851
  }
2967
2852
  }
2968
2853
  __fixAssignmentOperators(env) {
2969
- if (env.node)
2970
- this.__updateBinariesToAssignments(env.node);
2854
+ if (env.node) this.__updateBinariesToAssignments(env.node);
2971
2855
  }
2972
2856
  __updateBinariesToAssignments(node) {
2973
2857
  if (assigmentOperatorsSet.has(node.operator)) {
@@ -2983,12 +2867,10 @@ var Jsep = class {
2983
2867
  }
2984
2868
  }
2985
2869
  __gobbleTaggedTemplateIdentifier(env) {
2986
- if (!env.node)
2987
- return;
2870
+ if (!env.node) return;
2988
2871
  const type = env.node.type;
2989
2872
  const condition = (type === 2 /* Identifier */ || type === 3 /* Member */) && this.__isCode(BTICK_CODE);
2990
- if (!condition)
2991
- return;
2873
+ if (!condition) return;
2992
2874
  env.node = {
2993
2875
  type: 17 /* TaggedTemplateExpression */,
2994
2876
  tag: env.node,
@@ -2996,8 +2878,7 @@ var Jsep = class {
2996
2878
  };
2997
2879
  }
2998
2880
  __gobbleTemplateLiteral(env) {
2999
- if (!this.__isCode(BTICK_CODE))
3000
- return;
2881
+ if (!this.__isCode(BTICK_CODE)) return;
3001
2882
  const node = {
3002
2883
  type: 19 /* TemplateLiteral */,
3003
2884
  quasis: [],
@@ -3068,8 +2949,7 @@ var Jsep = class {
3068
2949
  __gobbleNew(env) {
3069
2950
  var _a;
3070
2951
  const node = env.node;
3071
- if (!node || node.operator !== "new" || !node.argument)
3072
- return;
2952
+ if (!node || node.operator !== "new" || !node.argument) return;
3073
2953
  if (!node.argument || ![6 /* Call */, 3 /* Member */].includes(node.argument.type))
3074
2954
  throw this.__getError("Expected new function()");
3075
2955
  env.node = node.argument;
@@ -3080,8 +2960,7 @@ var Jsep = class {
3080
2960
  callNode.type = 20 /* NewExpression */;
3081
2961
  }
3082
2962
  __gobbleRegexLiteral(env) {
3083
- if (!this.__isCode(FSLASH_CODE))
3084
- return;
2963
+ if (!this.__isCode(FSLASH_CODE)) return;
3085
2964
  const patternIndex = ++this.__index;
3086
2965
  let inCharSet = false;
3087
2966
  while (this.__index < this.__expr.length) {
@@ -3182,8 +3061,7 @@ var evalUnaryOp = {
3182
3061
  // placed here for type safety, never executed,
3183
3062
  };
3184
3063
  var spreadArgs = (args) => {
3185
- if (!(args == null ? void 0 : args.some(shouldSpreadArray)))
3186
- return args;
3064
+ if (!(args == null ? void 0 : args.some(shouldSpreadArray))) return args;
3187
3065
  const result = [];
3188
3066
  args.forEach(
3189
3067
  (x) => shouldSpreadArray(x) ? result.push(...x) : result.push(x)
@@ -3192,8 +3070,7 @@ var spreadArgs = (args) => {
3192
3070
  };
3193
3071
  var arrayEvaluator = (...args) => spreadArgs(args);
3194
3072
  var createLazyContext = (e, context) => {
3195
- if (!e)
3196
- return context;
3073
+ if (!e) return context;
3197
3074
  const ctx = Object.create(context != null ? context : {});
3198
3075
  ctx.$event = e;
3199
3076
  return ctx;
@@ -3348,22 +3225,17 @@ var RegorEval = class {
3348
3225
  this.__collectRefObj = !!collectRefObj;
3349
3226
  }
3350
3227
  __findContext(name2, context) {
3351
- if (context && name2 in context)
3352
- return context;
3228
+ if (context && name2 in context) return context;
3353
3229
  for (const ctx of this.__contexts) {
3354
- if (name2 in ctx)
3355
- return ctx;
3230
+ if (name2 in ctx) return ctx;
3356
3231
  }
3357
3232
  return void 0;
3358
3233
  }
3359
3234
  [2 /* Identifier */](expr, _, context) {
3360
3235
  const name2 = expr.name;
3361
- if (name2 === "$root")
3362
- return this.__contexts[this.__contexts.length - 1];
3363
- if (name2 === "$parent")
3364
- return this.__contexts[1];
3365
- if (name2 === "$ctx")
3366
- return [...this.__contexts];
3236
+ if (name2 === "$root") return this.__contexts[this.__contexts.length - 1];
3237
+ if (name2 === "$parent") return this.__contexts[1];
3238
+ if (name2 === "$ctx") return [...this.__contexts];
3367
3239
  if (context && name2 in context) {
3368
3240
  this.__lastEvaluatedValueBeforeUnref = context[name2];
3369
3241
  return associateThis(unref(context[name2]), context);
@@ -3505,8 +3377,7 @@ var RegorEval = class {
3505
3377
  if (arg.type === 2 /* Identifier */) {
3506
3378
  const name2 = arg.name;
3507
3379
  const ctx = this.__findContext(name2, context);
3508
- if (isNullOrUndefined(ctx))
3509
- return void 0;
3380
+ if (isNullOrUndefined(ctx)) return void 0;
3510
3381
  return updater[op](ctx, name2);
3511
3382
  }
3512
3383
  if (arg.type === 3 /* Member */) {
@@ -3524,8 +3395,7 @@ var RegorEval = class {
3524
3395
  if (arg.type === 2 /* Identifier */) {
3525
3396
  const name2 = arg.name;
3526
3397
  const ctx = this.__findContext(name2, context);
3527
- if (isNullOrUndefined(ctx))
3528
- return void 0;
3398
+ if (isNullOrUndefined(ctx)) return void 0;
3529
3399
  const value = this.__eval(expr.right, depth, context);
3530
3400
  return applyAssigment[op](ctx, name2, value);
3531
3401
  }
@@ -3541,8 +3411,7 @@ var RegorEval = class {
3541
3411
  }
3542
3412
  [14 /* Spread */](expr, depth, context) {
3543
3413
  const spreaded = this.__eval(expr.argument, depth, context);
3544
- if (isArray(spreaded))
3545
- spreaded.s = spreadElementSymbol;
3414
+ if (isArray(spreaded)) spreaded.s = spreadElementSymbol;
3546
3415
  return spreaded;
3547
3416
  }
3548
3417
  [17 /* TaggedTemplateExpression */](expr, depth, context) {
@@ -3630,8 +3499,7 @@ var RegorEval = class {
3630
3499
  }
3631
3500
  __transformLazy(depth, context, evaluator, ...args) {
3632
3501
  const isLazy = this.__isLazy;
3633
- if (!isLazy)
3634
- return this.__transform(depth, context, evaluator, ...args);
3502
+ if (!isLazy) return this.__transform(depth, context, evaluator, ...args);
3635
3503
  const evaluatedArgs = args.map(
3636
3504
  (arg, i) => arg && (arg.type !== 15 /* Arrow */ && isLazy(i, depth) ? (e) => this.__eval(arg, depth, createLazyContext(e, context)) : this.__eval(arg, depth, context))
3637
3505
  );
@@ -3683,8 +3551,7 @@ var Parser = class {
3683
3551
  refs: [],
3684
3552
  context: this.__contexts[0]
3685
3553
  };
3686
- if (isNullOrWhitespace(expression))
3687
- return result;
3554
+ if (isNullOrWhitespace(expression)) return result;
3688
3555
  const globalContext = this.__config.globalContext;
3689
3556
  const refs = [];
3690
3557
  const evaluate = (expr, contexts, collectRefs2, context) => {
@@ -3793,8 +3660,7 @@ var attrDirective = {
3793
3660
  onChange: (el, values, previousValues, option, previousOption, flags) => {
3794
3661
  var _a;
3795
3662
  if (option) {
3796
- if (flags && flags.includes("camel"))
3797
- option = camelize(option);
3663
+ if (flags && flags.includes("camel")) option = camelize(option);
3798
3664
  patchAttribute(el, option, values[0], previousOption);
3799
3665
  return;
3800
3666
  }
@@ -3880,25 +3746,22 @@ var patchClass = (el, next, prev) => {
3880
3746
  if (next && !isClassString) {
3881
3747
  if (prev && !isPrevClassString) {
3882
3748
  for (const key in prev) {
3883
- if (!(key in next)) {
3749
+ if (!(key in next) || !next[key]) {
3884
3750
  classList.remove(key);
3885
3751
  }
3886
3752
  }
3887
3753
  }
3888
3754
  for (const key in next) {
3889
- if (next[key])
3890
- classList.add(key);
3755
+ if (next[key]) classList.add(key);
3891
3756
  }
3892
3757
  } else {
3893
3758
  if (isClassString) {
3894
3759
  if (prev !== next) {
3895
- if (isPrevClassString)
3896
- classList.remove(...prev == null ? void 0 : prev.split(","));
3760
+ if (isPrevClassString) classList.remove(...prev == null ? void 0 : prev.split(","));
3897
3761
  classList.add(...next.split(","));
3898
3762
  }
3899
3763
  } else if (prev) {
3900
- if (isPrevClassString)
3901
- classList.remove(...prev == null ? void 0 : prev.split(","));
3764
+ if (isPrevClassString) classList.remove(...prev == null ? void 0 : prev.split(","));
3902
3765
  }
3903
3766
  }
3904
3767
  };
@@ -3907,17 +3770,14 @@ var patchClass = (el, next, prev) => {
3907
3770
  var htmlDirective = {
3908
3771
  onChange: (el, values) => {
3909
3772
  const [value, replacer] = values;
3910
- if (isFunction(replacer))
3911
- replacer(el, value);
3912
- else
3913
- el.innerHTML = value == null ? void 0 : value.toString();
3773
+ if (isFunction(replacer)) replacer(el, value);
3774
+ else el.innerHTML = value == null ? void 0 : value.toString();
3914
3775
  }
3915
3776
  };
3916
3777
 
3917
3778
  // src/common/looseEqual.ts
3918
3779
  function looseCompareArrays(a, b) {
3919
- if (a.length !== b.length)
3920
- return false;
3780
+ if (a.length !== b.length) return false;
3921
3781
  let equal = true;
3922
3782
  for (let i = 0; equal && i < a.length; i++) {
3923
3783
  equal = looseEqual(a[i], b[i]);
@@ -3925,8 +3785,7 @@ function looseCompareArrays(a, b) {
3925
3785
  return equal;
3926
3786
  }
3927
3787
  function looseEqual(a, b) {
3928
- if (a === b)
3929
- return true;
3788
+ if (a === b) return true;
3930
3789
  let aValidType = isDate(a);
3931
3790
  let bValidType = isDate(b);
3932
3791
  if (aValidType || bValidType) {
@@ -4032,8 +3891,7 @@ var updateDomElementValue = (el, value) => {
4032
3891
  }
4033
3892
  } else {
4034
3893
  if (looseEqual(getValue(option), value)) {
4035
- if (el.selectedIndex !== i)
4036
- el.selectedIndex = i;
3894
+ if (el.selectedIndex !== i) el.selectedIndex = i;
4037
3895
  return;
4038
3896
  }
4039
3897
  }
@@ -4046,10 +3904,8 @@ var updateDomElementValue = (el, value) => {
4046
3904
  }
4047
3905
  };
4048
3906
  var getFlags = (flag) => {
4049
- if (isRef(flag))
4050
- flag = flag();
4051
- if (isFunction(flag))
4052
- flag = flag();
3907
+ if (isRef(flag)) flag = flag();
3908
+ if (isFunction(flag)) flag = flag();
4053
3909
  if (!flag)
4054
3910
  return {
4055
3911
  trim: false,
@@ -4083,7 +3939,7 @@ var attachDOMChangeListener = (el, parseResult, directiveFlags) => {
4083
3939
  const f1 = getFlags(directiveFlags == null ? void 0 : directiveFlags.join(","));
4084
3940
  const f2 = getFlags(parsedValue()[1]);
4085
3941
  const flags = {
4086
- int: f1.int || f1.int,
3942
+ int: f1.int || f2.int,
4087
3943
  lazy: f1.lazy || f2.lazy,
4088
3944
  number: f1.number || f2.number,
4089
3945
  trim: f1.trim || f2.trim
@@ -4115,8 +3971,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
4115
3971
  const eventType = isLazy ? "change" : "input";
4116
3972
  const isNumber = isNumberInput(el);
4117
3973
  const trimmer = () => {
4118
- if (!flags.trim && !getFlags(parsedValue()[1]).trim)
4119
- return;
3974
+ if (!flags.trim && !getFlags(parsedValue()[1]).trim) return;
4120
3975
  el.value = el.value.trim();
4121
3976
  };
4122
3977
  const onCompositionStart = (e) => {
@@ -4139,8 +3994,7 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
4139
3994
  };
4140
3995
  const listener = (event) => {
4141
3996
  const target = event.target;
4142
- if (!target || target.composing)
4143
- return;
3997
+ if (!target || target.composing) return;
4144
3998
  let value = target.value;
4145
3999
  const flags2 = getFlags(parsedValue()[1]);
4146
4000
  if (isNumber || flags2.number || flags2.int) {
@@ -4151,15 +4005,12 @@ var handleInputAndTextArea = (el, flags, modelRef, parsedValue) => {
4151
4005
  if (endsWithDecimalSeparator) {
4152
4006
  value += "0";
4153
4007
  value = parseFloat(value);
4154
- if (isNaN(value))
4155
- value = "";
4156
- else if (modelRef() === value)
4157
- return;
4008
+ if (isNaN(value)) value = "";
4009
+ else if (modelRef() === value) return;
4158
4010
  }
4159
4011
  value = parseFloat(value);
4160
4012
  }
4161
- if (isNaN(value))
4162
- value = "";
4013
+ if (isNaN(value)) value = "";
4163
4014
  el.value = value;
4164
4015
  } else if (flags2.trim) {
4165
4016
  value = value.trim();
@@ -4216,8 +4067,7 @@ var getCheckboxValue = (el, checked) => {
4216
4067
  return el[key];
4217
4068
  }
4218
4069
  const attrKey = checked ? trueValueAttrKey : falseValueAttrKey;
4219
- if (el.hasAttribute(attrKey))
4220
- return el.getAttribute(attrKey);
4070
+ if (el.hasAttribute(attrKey)) return el.getAttribute(attrKey);
4221
4071
  return checked;
4222
4072
  };
4223
4073
  var getCheckboxChecked = (el, value) => {
@@ -4259,8 +4109,7 @@ var handleSelect = (el, modelRef, parsedValue) => {
4259
4109
  pause(modelRef);
4260
4110
  if (isSet(modelValue)) {
4261
4111
  modelValue.clear();
4262
- for (const sel of selectedValue)
4263
- modelValue.add(sel);
4112
+ for (const sel of selectedValue) modelValue.add(sel);
4264
4113
  } else if (isArray(modelValue)) {
4265
4114
  modelValue.splice(0);
4266
4115
  modelValue.push(...selectedValue);
@@ -4312,9 +4161,8 @@ var onDirective = {
4312
4161
  if (dynamicOption) {
4313
4162
  const values2 = parseResult.value();
4314
4163
  const option2 = unref(dynamicOption.value()[0]);
4315
- if (!isString(option2))
4316
- return () => {
4317
- };
4164
+ if (!isString(option2)) return () => {
4165
+ };
4318
4166
  return attachEventListener(
4319
4167
  el,
4320
4168
  camelize(option2),
@@ -4338,18 +4186,15 @@ var onDirective = {
4338
4186
  const len = values.length;
4339
4187
  for (let i = 0; i < len; ++i) {
4340
4188
  let next = values[i];
4341
- if (isFunction(next))
4342
- next = next();
4189
+ if (isFunction(next)) next = next();
4343
4190
  if (isObject(next)) {
4344
4191
  for (const item of Object.entries(next)) {
4345
4192
  const eventType = item[0];
4346
4193
  const method = () => {
4347
4194
  let obj = parseResult.value()[i];
4348
- if (isFunction(obj))
4349
- obj = obj();
4195
+ if (isFunction(obj)) obj = obj();
4350
4196
  obj = obj[eventType];
4351
- if (isFunction(obj))
4352
- obj = obj();
4197
+ if (isFunction(obj)) obj = obj();
4353
4198
  return obj;
4354
4199
  };
4355
4200
  const flags2 = next[eventType + "_flags"];
@@ -4373,22 +4218,17 @@ var getShouldExecuteEvent = (eventType, flags) => {
4373
4218
  const isAlt = parts.includes("alt");
4374
4219
  const isMeta = parts.includes("meta");
4375
4220
  const checkModifiers = (e) => {
4376
- if (isCtrl && !e.ctrlKey)
4377
- return false;
4378
- if (isShift && !e.shiftKey)
4379
- return false;
4380
- if (isAlt && !e.altKey)
4381
- return false;
4382
- if (isMeta && !e.metaKey)
4383
- return false;
4221
+ if (isCtrl && !e.ctrlKey) return false;
4222
+ if (isShift && !e.shiftKey) return false;
4223
+ if (isAlt && !e.altKey) return false;
4224
+ if (isMeta && !e.metaKey) return false;
4384
4225
  return true;
4385
4226
  };
4386
4227
  if (keyType) {
4387
4228
  return [
4388
4229
  eventType,
4389
4230
  (e) => {
4390
- if (!checkModifiers(e))
4391
- return false;
4231
+ if (!checkModifiers(e)) return false;
4392
4232
  return e.key.toUpperCase() === keyType.toUpperCase();
4393
4233
  }
4394
4234
  ];
@@ -4412,15 +4252,11 @@ var attachEventListener = (el, eventType, method, flags) => {
4412
4252
  let shouldExecuteEvent;
4413
4253
  [eventType, shouldExecuteEvent] = getShouldExecuteEvent(eventType, flags);
4414
4254
  const execute = (e) => {
4415
- if (!shouldExecuteEvent(e))
4416
- return;
4417
- if (!method && eventType === "submit" && (flag == null ? void 0 : flag.prevent))
4418
- return;
4255
+ if (!shouldExecuteEvent(e)) return;
4256
+ if (!method && eventType === "submit" && (flag == null ? void 0 : flag.prevent)) return;
4419
4257
  let r = method(e);
4420
- if (isFunction(r))
4421
- r = r(e);
4422
- if (isFunction(r))
4423
- r(e);
4258
+ if (isFunction(r)) r = r(e);
4259
+ if (isFunction(r)) r(e);
4424
4260
  };
4425
4261
  const unbinder = () => {
4426
4262
  el.removeEventListener(eventType, listener, options);
@@ -4431,22 +4267,15 @@ var attachEventListener = (el, eventType, method, flags) => {
4431
4267
  return;
4432
4268
  }
4433
4269
  try {
4434
- if (flag.left && e.button !== 1)
4435
- return;
4436
- if (flag.middle && e.button !== 2)
4437
- return;
4438
- if (flag.right && e.button !== 3)
4439
- return;
4440
- if (flag.self && e.target !== el)
4441
- return;
4442
- if (flag.stop)
4443
- e.stopPropagation();
4444
- if (flag.prevent)
4445
- e.preventDefault();
4270
+ if (flag.left && e.button !== 0) return;
4271
+ if (flag.middle && e.button !== 1) return;
4272
+ if (flag.right && e.button !== 2) return;
4273
+ if (flag.self && e.target !== el) return;
4274
+ if (flag.stop) e.stopPropagation();
4275
+ if (flag.prevent) e.preventDefault();
4446
4276
  execute(e);
4447
4277
  } finally {
4448
- if (flag.once)
4449
- unbinder();
4278
+ if (flag.once) unbinder();
4450
4279
  }
4451
4280
  };
4452
4281
  el.addEventListener(eventType, listener, options);
@@ -4457,8 +4286,7 @@ var attachEventListener = (el, eventType, method, flags) => {
4457
4286
  var propDirective = {
4458
4287
  onChange: (el, values, _previousValues, option, _previousOption, flags) => {
4459
4288
  if (option) {
4460
- if (flags && flags.includes("camel"))
4461
- option = camelize(option);
4289
+ if (flags && flags.includes("camel")) option = camelize(option);
4462
4290
  patchProp(el, option, values[0]);
4463
4291
  return;
4464
4292
  }
@@ -4541,18 +4369,14 @@ var refDirective = {
4541
4369
  const value = result.value()[0];
4542
4370
  const isAnArray = isArray(value);
4543
4371
  const sref2 = result.refs[0];
4544
- if (isAnArray)
4545
- value.push(el);
4546
- else if (sref2)
4547
- sref2 == null ? void 0 : sref2(el);
4548
- else
4549
- result.context[expr] = el;
4372
+ if (isAnArray) value.push(el);
4373
+ else if (sref2) sref2 == null ? void 0 : sref2(el);
4374
+ else result.context[expr] = el;
4550
4375
  return () => {
4551
4376
  if (isAnArray) {
4552
4377
  const i = value.indexOf(el);
4553
4378
  i !== -1 && value.splice(i, 1);
4554
- } else
4555
- sref2 == null ? void 0 : sref2(null);
4379
+ } else sref2 == null ? void 0 : sref2(null);
4556
4380
  };
4557
4381
  }
4558
4382
  };
@@ -4566,10 +4390,8 @@ var showDirective = {
4566
4390
  originalDisplay = data._ord = el.style.display;
4567
4391
  }
4568
4392
  const isVisible = !!values[0];
4569
- if (isVisible)
4570
- el.style.display = originalDisplay;
4571
- else
4572
- el.style.display = "none";
4393
+ if (isVisible) el.style.display = originalDisplay;
4394
+ else el.style.display = "none";
4573
4395
  }
4574
4396
  };
4575
4397
 
@@ -4615,8 +4437,7 @@ var patchStyle = (el, next, prev) => {
4615
4437
  el.removeAttribute("style");
4616
4438
  }
4617
4439
  const data = getBindData(el).data;
4618
- if ("_ord" in data)
4619
- return;
4440
+ if ("_ord" in data) return;
4620
4441
  style.display = currentDisplay;
4621
4442
  }
4622
4443
  };
@@ -4627,8 +4448,7 @@ function setStyle(style, name2, val) {
4627
4448
  setStyle(style, name2, v);
4628
4449
  });
4629
4450
  } else {
4630
- if (val == null)
4631
- val = "";
4451
+ if (val == null) val = "";
4632
4452
  if (name2.startsWith("--")) {
4633
4453
  style.setProperty(name2, val);
4634
4454
  } else {
@@ -4670,11 +4490,9 @@ function autoPrefix(style, rawName) {
4670
4490
  var flatten = (reference) => {
4671
4491
  return flattenContent(unref(reference));
4672
4492
  };
4673
- var flattenContent = (value) => {
4674
- if (!value)
4675
- return value;
4676
- if (!isObject(value))
4677
- return value;
4493
+ var flattenContent = (value, weakMap = /* @__PURE__ */ new WeakMap()) => {
4494
+ if (!value) return value;
4495
+ if (!isObject(value)) return value;
4678
4496
  if (isArray(value)) {
4679
4497
  return value.map(flatten);
4680
4498
  }
@@ -4687,14 +4505,16 @@ var flattenContent = (value) => {
4687
4505
  }
4688
4506
  if (isMap(value)) {
4689
4507
  const map = /* @__PURE__ */ new Map();
4690
- for (const el of map) {
4508
+ for (const el of value) {
4691
4509
  map.set(flatten(el[0]), flatten(el[1]));
4692
4510
  }
4693
4511
  return map;
4694
4512
  }
4513
+ if (weakMap.has(value)) return unref(weakMap.get(value));
4695
4514
  const result = __spreadValues({}, value);
4515
+ weakMap.set(value, result);
4696
4516
  for (const entry of Object.entries(result)) {
4697
- result[entry[0]] = flatten(entry[1]);
4517
+ result[entry[0]] = flattenContent(unref(entry[1]), weakMap);
4698
4518
  }
4699
4519
  return result;
4700
4520
  };
@@ -4722,8 +4542,7 @@ var isDeepRef = (value) => {
4722
4542
 
4723
4543
  // src/reactivity/ref.ts
4724
4544
  var ref = (value) => {
4725
- if (isRaw(value))
4726
- return value;
4545
+ if (isRaw(value)) return value;
4727
4546
  let result;
4728
4547
  if (isRef(value)) {
4729
4548
  result = value;
@@ -4738,21 +4557,18 @@ var ref = (value) => {
4738
4557
  const len = value.length;
4739
4558
  for (let i = 0; i < len; ++i) {
4740
4559
  const item = value[i];
4741
- if (isDeepRef(item))
4742
- continue;
4560
+ if (isDeepRef(item)) continue;
4743
4561
  value[i] = ref(item);
4744
4562
  }
4745
4563
  return result;
4746
4564
  }
4747
- if (!isObject(value))
4748
- return result;
4565
+ if (!isObject(value)) return result;
4749
4566
  for (const item of Object.entries(value)) {
4750
4567
  const val = item[1];
4751
- if (isDeepRef(val))
4752
- continue;
4568
+ if (isDeepRef(val)) continue;
4753
4569
  const key = item[0];
4754
- if (isSymbol(key))
4755
- continue;
4570
+ if (isSymbol(key)) continue;
4571
+ value[key] = null;
4756
4572
  value[key] = ref(val);
4757
4573
  }
4758
4574
  return result;
@@ -4887,8 +4703,7 @@ var RegorConfig = _RegorConfig;
4887
4703
 
4888
4704
  // src/bind/interpolation.ts
4889
4705
  var interpolate = (element, config) => {
4890
- if (!element)
4891
- return;
4706
+ if (!element) return;
4892
4707
  const builtInNames = (config != null ? config : RegorConfig.getDefault()).__builtInNames;
4893
4708
  for (const textNode of getTextNodes(element, builtInNames.pre)) {
4894
4709
  interpolateTextNode(textNode, builtInNames.text);
@@ -4898,12 +4713,10 @@ var interpolationRegex = /({{[^]*?}})/g;
4898
4713
  var interpolateTextNode = (textNode, textDirective2) => {
4899
4714
  var _a;
4900
4715
  const text = textNode.textContent;
4901
- if (!text)
4902
- return;
4716
+ if (!text) return;
4903
4717
  const mustacheRegex = interpolationRegex;
4904
4718
  const parts = text.split(mustacheRegex);
4905
- if (parts.length <= 1)
4906
- return;
4719
+ if (parts.length <= 1) return;
4907
4720
  if (((_a = textNode.parentElement) == null ? void 0 : _a.childNodes.length) === 1 && parts.length === 3) {
4908
4721
  const part = parts[1];
4909
4722
  if (isNullOrWhitespace(parts[0]) && isNullOrWhitespace(parts[2]) && part.startsWith("{{") && part.endsWith("}}")) {
@@ -4935,8 +4748,7 @@ var getTextNodes = (node, preDirective) => {
4935
4748
  textNodes.push(node2);
4936
4749
  }
4937
4750
  } else {
4938
- if ((_b = node2 == null ? void 0 : node2.hasAttribute) == null ? void 0 : _b.call(node2, preDirective))
4939
- return;
4751
+ if ((_b = node2 == null ? void 0 : node2.hasAttribute) == null ? void 0 : _b.call(node2, preDirective)) return;
4940
4752
  for (const child of getChildNodes(node2)) {
4941
4753
  traverseTextNodes(child);
4942
4754
  }
@@ -4951,10 +4763,8 @@ var svgTags = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-
4951
4763
  var svgSet = new Set(svgTags.toUpperCase().split(","));
4952
4764
  var svgNamespace = "http://www.w3.org/2000/svg";
4953
4765
  var appendChild = (parent, el) => {
4954
- if (isTemplate(parent))
4955
- parent.content.appendChild(el);
4956
- else
4957
- parent.appendChild(el);
4766
+ if (isTemplate(parent)) parent.content.appendChild(el);
4767
+ else parent.appendChild(el);
4958
4768
  };
4959
4769
  var render = (json, parent, isSVG, config) => {
4960
4770
  var _a;
@@ -4975,8 +4785,7 @@ var render = (json, parent, isSVG, config) => {
4975
4785
  }
4976
4786
  const children = json.c;
4977
4787
  if (children) {
4978
- for (const child of children)
4979
- render(child, el, isSVG, config);
4788
+ for (const child of children) render(child, el, isSVG, config);
4980
4789
  }
4981
4790
  appendChild(parent, el);
4982
4791
  return;
@@ -4992,10 +4801,8 @@ var render = (json, parent, isSVG, config) => {
4992
4801
  node = document.createTextNode(textData);
4993
4802
  break;
4994
4803
  }
4995
- if (node)
4996
- appendChild(parent, node);
4997
- else
4998
- throw new Error("unsupported node type.");
4804
+ if (node) appendChild(parent, node);
4805
+ else throw new Error("unsupported node type.");
4999
4806
  }
5000
4807
  };
5001
4808
  var toFragment = (json, isSVG, config) => {
@@ -5012,16 +4819,13 @@ var toFragment = (json, isSVG, config) => {
5012
4819
  };
5013
4820
 
5014
4821
  // src/app/createApp.ts
5015
- var createApp = (context, templateOptions = { selector: "#app" }, config) => {
5016
- if (isString(templateOptions))
5017
- templateOptions = { selector: "#app", template: templateOptions };
5018
- if (isScope(context))
5019
- context = context.context;
5020
- const root = templateOptions.element ? templateOptions.element : templateOptions.selector ? document.querySelector(templateOptions.selector) : null;
5021
- if (!root || !isElement(root))
5022
- throw getError(0 /* AppRootElementMissing */);
5023
- if (!config)
5024
- config = RegorConfig.getDefault();
4822
+ var createApp = (context, template = { selector: "#app" }, config) => {
4823
+ if (isString(template))
4824
+ template = { selector: "#app", template };
4825
+ if (isScope(context)) context = context.context;
4826
+ const root = template.element ? template.element : template.selector ? document.querySelector(template.selector) : null;
4827
+ if (!root || !isElement(root)) throw getError(0 /* AppRootElementMissing */);
4828
+ if (!config) config = RegorConfig.getDefault();
5025
4829
  const cleanRoot = () => {
5026
4830
  for (const child of [...root.childNodes]) {
5027
4831
  removeNode(child);
@@ -5032,22 +4836,21 @@ var createApp = (context, templateOptions = { selector: "#app" }, config) => {
5032
4836
  root.appendChild(child);
5033
4837
  }
5034
4838
  };
5035
- if (templateOptions.template) {
5036
- const element = document.createRange().createContextualFragment(templateOptions.template);
4839
+ if (template.template) {
4840
+ const element = document.createRange().createContextualFragment(template.template);
5037
4841
  cleanRoot();
5038
4842
  appendChildren(element.childNodes);
5039
- templateOptions.element = element;
5040
- } else if (templateOptions.json) {
4843
+ template.element = element;
4844
+ } else if (template.json) {
5041
4845
  const element = toFragment(
5042
- templateOptions.json,
5043
- templateOptions.isSVG,
4846
+ template.json,
4847
+ template.isSVG,
5044
4848
  config
5045
4849
  );
5046
4850
  cleanRoot();
5047
4851
  appendChildren(element.childNodes);
5048
4852
  }
5049
- if (config.useInterpolation)
5050
- interpolate(root, config);
4853
+ if (config.useInterpolation) interpolate(root, config);
5051
4854
  const app = new RegorApp(context, root, config);
5052
4855
  app.__bind();
5053
4856
  addUnbinder(root, () => {
@@ -5088,13 +4891,10 @@ var toJsonTemplate = (node) => {
5088
4891
  return node.map((x) => toJsonTemplate(x));
5089
4892
  }
5090
4893
  const json = {};
5091
- if (node.tagName)
5092
- json.t = node.tagName;
4894
+ if (node.tagName) json.t = node.tagName;
5093
4895
  else {
5094
- if (node.nodeType === Node.COMMENT_NODE)
5095
- json.n = Node.COMMENT_NODE;
5096
- if (node.textContent)
5097
- json.d = node.textContent;
4896
+ if (node.nodeType === Node.COMMENT_NODE) json.n = Node.COMMENT_NODE;
4897
+ if (node.textContent) json.d = node.textContent;
5098
4898
  return json;
5099
4899
  }
5100
4900
  const attrNames = node.getAttributeNames();
@@ -5113,51 +4913,48 @@ var toJsonTemplate = (node) => {
5113
4913
  };
5114
4914
 
5115
4915
  // src/app/createComponent.ts
5116
- var createComponent = (context, templateOptions, options = {}) => {
4916
+ var createComponent = (context, template, options = {}) => {
5117
4917
  var _a, _b, _c, _d;
5118
- if (isArray(options))
5119
- options = { props: options };
5120
- if (isString(templateOptions))
5121
- templateOptions = { template: templateOptions };
4918
+ if (isArray(options)) options = { props: options };
4919
+ if (isString(template)) template = { template };
5122
4920
  let svgHandled = false;
5123
- if (templateOptions.element) {
5124
- const element2 = templateOptions.element;
4921
+ if (template.element) {
4922
+ const element2 = template.element;
5125
4923
  element2.remove();
5126
- templateOptions.element = element2;
5127
- } else if (templateOptions.selector) {
5128
- const element2 = document.querySelector(templateOptions.selector);
4924
+ template.element = element2;
4925
+ } else if (template.selector) {
4926
+ const element2 = document.querySelector(template.selector);
5129
4927
  if (!element2)
5130
4928
  throw getError(
5131
4929
  1 /* ComponentTemplateNotFound */,
5132
- templateOptions.selector
4930
+ template.selector
5133
4931
  );
5134
4932
  element2.remove();
5135
- templateOptions.element = element2;
5136
- } else if (templateOptions.template) {
5137
- const element2 = document.createRange().createContextualFragment(templateOptions.template);
5138
- templateOptions.element = element2;
5139
- } else if (templateOptions.json) {
5140
- templateOptions.element = toFragment(
5141
- templateOptions.json,
5142
- templateOptions.isSVG,
4933
+ template.element = element2;
4934
+ } else if (template.template) {
4935
+ const element2 = document.createRange().createContextualFragment(template.template);
4936
+ template.element = element2;
4937
+ } else if (template.json) {
4938
+ template.element = toFragment(
4939
+ template.json,
4940
+ template.isSVG,
5143
4941
  options.config
5144
4942
  );
5145
4943
  svgHandled = true;
5146
4944
  }
5147
- if (!templateOptions.element)
5148
- templateOptions.element = document.createDocumentFragment();
5149
- if ((_a = options.useInterpolation) != null ? _a : true)
5150
- interpolate(templateOptions.element);
5151
- const element = templateOptions.element;
5152
- if (!svgHandled && (((_c = templateOptions.isSVG) != null ? _c : isHTMLElement(element) && ((_b = element.hasAttribute) == null ? void 0 : _b.call(element, "isSVG"))) || isHTMLElement(element) && !!element.querySelector("[isSVG]"))) {
5153
- const content = templateOptions.element.content;
4945
+ if (!template.element)
4946
+ template.element = document.createDocumentFragment();
4947
+ if ((_a = options.useInterpolation) != null ? _a : true) interpolate(template.element);
4948
+ const element = template.element;
4949
+ if (!svgHandled && (((_c = template.isSVG) != null ? _c : isHTMLElement(element) && ((_b = element.hasAttribute) == null ? void 0 : _b.call(element, "isSVG"))) || isHTMLElement(element) && !!element.querySelector("[isSVG]"))) {
4950
+ const content = template.element.content;
5154
4951
  const nodes = content ? [...content.childNodes] : [...element.childNodes];
5155
4952
  const json = toJsonTemplate(nodes);
5156
- templateOptions.element = toFragment(json, true, options.config);
4953
+ template.element = toFragment(json, true, options.config);
5157
4954
  }
5158
4955
  return {
5159
4956
  context,
5160
- template: templateOptions.element,
4957
+ template: template.element,
5161
4958
  inheritAttrs: (_d = options.inheritAttrs) != null ? _d : true,
5162
4959
  props: options.props,
5163
4960
  defaultName: options.defaultName
@@ -5171,8 +4968,7 @@ var computed = (compute) => {
5171
4968
  const result = (...args) => {
5172
4969
  if (args.length <= 2 && 0 in args)
5173
4970
  throw getError(4 /* ComputedIsReadOnly */);
5174
- if (computer && !status.isStopped)
5175
- return computer(...args);
4971
+ if (computer && !status.isStopped) return computer(...args);
5176
4972
  computer = computedOnce(compute, status);
5177
4973
  return computer(...args);
5178
4974
  };
@@ -5212,8 +5008,7 @@ var computeMany = (sources, compute) => {
5212
5008
  const result = (...args) => {
5213
5009
  if (args.length <= 2 && 0 in args)
5214
5010
  throw getError(4 /* ComputedIsReadOnly */);
5215
- if (computer && !status.isStopped)
5216
- return computer(...args);
5011
+ if (computer && !status.isStopped) return computer(...args);
5217
5012
  computer = computeManyOnce(sources, compute, status);
5218
5013
  return computer(...args);
5219
5014
  };
@@ -5263,8 +5058,7 @@ var computeRef = (source, compute) => {
5263
5058
  const result = (...args) => {
5264
5059
  if (args.length <= 2 && 0 in args)
5265
5060
  throw getError(4 /* ComputedIsReadOnly */);
5266
- if (computer && !status.isStopped)
5267
- return computer(...args);
5061
+ if (computer && !status.isStopped) return computer(...args);
5268
5062
  computer = computeRefOnce(source, compute, status);
5269
5063
  return computer(...args);
5270
5064
  };
@@ -5309,31 +5103,44 @@ var markRaw = (value) => {
5309
5103
 
5310
5104
  // src/misc/persist.ts
5311
5105
  var persist = (anyRef, key) => {
5312
- if (!key)
5313
- throw new Error("persist requires a string key.");
5106
+ if (!key) throw getError(5 /* PersistRequiresKey */);
5314
5107
  const deepRef = isDeepRef(anyRef);
5315
5108
  const makeRef = deepRef ? ref : (x) => x;
5316
5109
  const store = () => localStorage.setItem(key, JSON.stringify(flatten(anyRef())));
5317
5110
  const existing = localStorage.getItem(key);
5318
5111
  if (existing != null) {
5319
- anyRef(makeRef(JSON.parse(existing)));
5112
+ try {
5113
+ anyRef(makeRef(JSON.parse(existing)));
5114
+ } catch (e) {
5115
+ warning(
5116
+ 6 /* ErrorLog */,
5117
+ `persist: failed to parse data for key ${key}`,
5118
+ e
5119
+ );
5120
+ store();
5121
+ }
5320
5122
  } else {
5321
5123
  store();
5322
5124
  }
5323
5125
  const stopObserving = watchEffect(store);
5324
- onUnmounted(() => stopObserving, true);
5126
+ onUnmounted(stopObserving, true);
5325
5127
  return anyRef;
5326
5128
  };
5327
5129
 
5328
5130
  // src/misc/tagged-html.ts
5329
5131
  var html = (templates, ...args) => {
5330
- let str = "";
5331
- if (args.length === 0)
5332
- return templates.join();
5333
- templates.forEach((template, i) => {
5334
- str += template + args[i];
5335
- });
5336
- return str;
5132
+ let result = "";
5133
+ const tpl = templates;
5134
+ const a = args;
5135
+ const tplLen = tpl.length;
5136
+ const argLen = a.length;
5137
+ for (let i = 0; i < tplLen; ++i) {
5138
+ result += tpl[i];
5139
+ if (i < argLen) {
5140
+ result += a[i];
5141
+ }
5142
+ }
5143
+ return result;
5337
5144
  };
5338
5145
  var raw = html;
5339
5146
 
@@ -5346,8 +5153,7 @@ var observeMany = (sources, observer, init) => {
5346
5153
  for (const source of sources) {
5347
5154
  stopObservingList.push(observe(source, callObserver));
5348
5155
  }
5349
- if (init)
5350
- callObserver();
5156
+ if (init) callObserver();
5351
5157
  const stop = () => {
5352
5158
  for (const stopObserving of stopObservingList) {
5353
5159
  stopObserving();
@@ -5360,7 +5166,7 @@ var observeMany = (sources, observer, init) => {
5360
5166
  // src/observer/observerCount.ts
5361
5167
  var observerCount = (source) => {
5362
5168
  if (!isRef(source))
5363
- throw getError(3 /* RequiresRefSourceArgument */, "observe");
5169
+ throw getError(3 /* RequiresRefSourceArgument */, "observerCount");
5364
5170
  const srefImpl = source;
5365
5171
  return srefImpl(void 0, void 0, 2 /* observerCount */);
5366
5172
  };
@@ -5375,14 +5181,19 @@ var batch = (updater) => {
5375
5181
  }
5376
5182
  };
5377
5183
  var startBatch = () => {
5378
- if (!batchCollector.set)
5379
- batchCollector.set = /* @__PURE__ */ new Set();
5184
+ if (!batchCollector.stack) batchCollector.stack = [];
5185
+ batchCollector.stack.push(/* @__PURE__ */ new Set());
5380
5186
  };
5381
5187
  var endBatch = () => {
5382
- const set = batchCollector.set;
5383
- if (!set)
5188
+ const stack = batchCollector.stack;
5189
+ if (!stack || stack.length === 0) return;
5190
+ const set = stack.pop();
5191
+ if (stack.length) {
5192
+ const parent = stack[stack.length - 1];
5193
+ for (const ref2 of set) parent.add(ref2);
5384
5194
  return;
5385
- delete batchCollector.set;
5195
+ }
5196
+ delete batchCollector.stack;
5386
5197
  for (const ref2 of set) {
5387
5198
  try {
5388
5199
  trigger(ref2);