defuss 2.1.11 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/dist/component-registry-CPBzgkm2.cjs +20 -0
  2. package/dist/component-registry-rwX6GHzq.mjs +15 -0
  3. package/dist/dom--qQgTXnx.mjs +2603 -0
  4. package/dist/dom-0JFHc2kn.cjs +2810 -0
  5. package/dist/dom-4vhaViIf.mjs +2801 -0
  6. package/dist/dom-5V9JcMrR.mjs +2695 -0
  7. package/dist/dom-B0lpSx0p.mjs +2604 -0
  8. package/dist/dom-B0mZwIcb.cjs +2859 -0
  9. package/dist/dom-B4MQngSF.cjs +2782 -0
  10. package/dist/dom-B58Ij3VD.cjs +2907 -0
  11. package/dist/dom-B5zbx-3T.mjs +2810 -0
  12. package/dist/dom-B6fFOlKv.cjs +2898 -0
  13. package/dist/dom-B7UqtWqL.cjs +2814 -0
  14. package/dist/dom-BDL4winW.cjs +2892 -0
  15. package/dist/dom-BHi3SKvU.mjs +2595 -0
  16. package/dist/dom-BMSWQp9d.cjs +2899 -0
  17. package/dist/dom-BOjwen4W.cjs +2894 -0
  18. package/dist/dom-BSXG5cMV.mjs +2678 -0
  19. package/dist/dom-BUUPuzZG.cjs +2681 -0
  20. package/dist/dom-BW8oGJV-.cjs +2890 -0
  21. package/dist/dom-B_g5muLk.mjs +2798 -0
  22. package/dist/dom-Ba8Rmsy6.mjs +2557 -0
  23. package/dist/dom-BaaPAgsv.mjs +2569 -0
  24. package/dist/dom-Bb17xYzx.mjs +2599 -0
  25. package/dist/dom-BcW3GkDu.cjs +2897 -0
  26. package/dist/dom-BfqchTxj.mjs +2696 -0
  27. package/dist/dom-Bg0Eqh-g.cjs +2718 -0
  28. package/dist/dom-Bi5Eowqw.cjs +2728 -0
  29. package/dist/dom-BjFpmoeW.mjs +2818 -0
  30. package/dist/dom-BjwVMyGv.mjs +2644 -0
  31. package/dist/dom-Bjy_d0D1.mjs +2652 -0
  32. package/dist/dom-BkrsFnv4.mjs +2719 -0
  33. package/dist/dom-Bl9sFsMf.mjs +2797 -0
  34. package/dist/dom-BpugjT-d.cjs +2764 -0
  35. package/dist/dom-BzcdRPS7.cjs +2676 -0
  36. package/dist/dom-C1Dv_k31.cjs +2831 -0
  37. package/dist/dom-C2miKN96.cjs +2887 -0
  38. package/dist/dom-C3iIctYx.cjs +2602 -0
  39. package/dist/dom-C6c71RsI.cjs +2892 -0
  40. package/dist/dom-C6qPzZDU.mjs +2526 -0
  41. package/dist/dom-C91wPWgb.mjs +2587 -0
  42. package/dist/dom-CEEtTZJb.cjs +2891 -0
  43. package/dist/dom-CG8ZC5zA.cjs +2645 -0
  44. package/dist/dom-CHfN0q0-.cjs +2805 -0
  45. package/dist/dom-CLpZk5Ok.cjs +2890 -0
  46. package/dist/dom-CMwQ9pmp.cjs +2767 -0
  47. package/dist/dom-COTHhb5r.mjs +2634 -0
  48. package/dist/dom-CRRoa52F.mjs +2805 -0
  49. package/dist/dom-CUHgK6d1.mjs +2807 -0
  50. package/dist/dom-CfCTjzif.mjs +2803 -0
  51. package/dist/dom-Cg17fK2D.mjs +2490 -0
  52. package/dist/dom-CjffEyZp.mjs +2809 -0
  53. package/dist/dom-Cn7eypGU.cjs +2898 -0
  54. package/dist/dom-CoBIe6TZ.mjs +2685 -0
  55. package/dist/dom-Cr99biSm.mjs +2795 -0
  56. package/dist/dom-CuPnZIwb.mjs +2803 -0
  57. package/dist/dom-CyaFGBis.cjs +2897 -0
  58. package/dist/dom-CzDaYcdd.cjs +2896 -0
  59. package/dist/dom-D-M2CWHK.cjs +2805 -0
  60. package/dist/dom-D00lHhSQ.cjs +2887 -0
  61. package/dist/dom-DA76MFiR.mjs +2808 -0
  62. package/dist/dom-DCxc_aGE.mjs +2634 -0
  63. package/dist/dom-DDB7B6E0.mjs +2801 -0
  64. package/dist/dom-DDtrH45u.cjs +2673 -0
  65. package/dist/dom-DKZZG5RP.mjs +2798 -0
  66. package/dist/dom-DOswyRty.mjs +2681 -0
  67. package/dist/dom-DQiJQigd.cjs +2890 -0
  68. package/dist/dom-DRUJMjpd.cjs +2736 -0
  69. package/dist/dom-DU3JvIZO.cjs +2886 -0
  70. package/dist/dom-DWDVSwjd.cjs +2566 -0
  71. package/dist/dom-D_3LE_Qi.mjs +2722 -0
  72. package/dist/dom-DbhNF_Km.cjs +2665 -0
  73. package/dist/dom-Deh17qfR.mjs +2795 -0
  74. package/dist/dom-DfIL_s0t.mjs +2634 -0
  75. package/dist/dom-DhzvIchP.cjs +2680 -0
  76. package/dist/dom-DjEOa9GM.mjs +2801 -0
  77. package/dist/dom-DqWHLuln.cjs +2763 -0
  78. package/dist/dom-Dw0cUaXk.cjs +2717 -0
  79. package/dist/dom-FaIf556X.mjs +2801 -0
  80. package/dist/dom-Kdtm5aoM.mjs +2798 -0
  81. package/dist/dom-O2cdv0jV.cjs +2887 -0
  82. package/dist/dom-YfFA0iKZ.mjs +2726 -0
  83. package/dist/dom-YpZtMxDS.cjs +2783 -0
  84. package/dist/dom-YuuCUzeb.mjs +2744 -0
  85. package/dist/dom-_naqXmaM.mjs +2677 -0
  86. package/dist/dom-iQGpbrON.cjs +2718 -0
  87. package/dist/dom-j57Lsb1X.cjs +2884 -0
  88. package/dist/dom-jKUS5flE.mjs +2771 -0
  89. package/dist/dom-khd7HASe.cjs +2771 -0
  90. package/dist/dom-lEWdDKb4.mjs +2718 -0
  91. package/dist/dom-mA0CVs3o.mjs +2809 -0
  92. package/dist/dom-mt5spBGS.cjs +2634 -0
  93. package/dist/dom-rjEgJGTC.cjs +2806 -0
  94. package/dist/dom-smXiaXEP.mjs +2718 -0
  95. package/dist/dom-wcIpcL6F.mjs +2807 -0
  96. package/dist/dom-xtwhQmkx.cjs +2884 -0
  97. package/dist/dom-xu1m78jm.mjs +2808 -0
  98. package/dist/index-B4BHyohJ.d.ts +1536 -0
  99. package/dist/index-BDnHS4Fq.d.ts +1425 -0
  100. package/dist/index-BENswTvz.d.ts +1505 -0
  101. package/dist/index-BFHuQ4xu.d.ts +1435 -0
  102. package/dist/index-BM5mxtvJ.d.ts +1543 -0
  103. package/dist/index-BOHKDFwH.d.ts +1435 -0
  104. package/dist/index-BRnR4FIe.d.ts +1436 -0
  105. package/dist/index-B_mKPzYo.d.ts +1578 -0
  106. package/dist/index-BctcSoO5.d.ts +1576 -0
  107. package/dist/index-BfvJsCS_.d.ts +1426 -0
  108. package/dist/index-BhNZrSrs.d.ts +1352 -0
  109. package/dist/index-Bi8j-_h_.d.cts +1488 -0
  110. package/dist/index-Bi8j-_h_.d.ts +1488 -0
  111. package/dist/index-BkobKBZk.d.ts +1430 -0
  112. package/dist/index-Bu2vwaJ2.d.ts +1352 -0
  113. package/dist/index-BvvZRMKD.d.ts +1569 -0
  114. package/dist/index-C1AAn__7.d.ts +1433 -0
  115. package/dist/index-C6Eg-vsd.d.ts +1424 -0
  116. package/dist/index-C6OhaPcR.d.ts +1433 -0
  117. package/dist/index-CCeP2S3d.d.ts +1434 -0
  118. package/dist/index-CEIsFrMM.d.ts +1542 -0
  119. package/dist/index-CFDpKGh7.d.ts +1428 -0
  120. package/dist/index-CFrYY_Mt.d.ts +1436 -0
  121. package/dist/index-CGDnSWTS.d.ts +1527 -0
  122. package/dist/index-CKwxYOvH.d.ts +1437 -0
  123. package/dist/index-CLBqO3Y7.d.ts +1544 -0
  124. package/dist/index-CRsLiENw.d.ts +1436 -0
  125. package/dist/index-CTjaPtOu.d.ts +1544 -0
  126. package/dist/index-CWP_xArI.d.ts +1433 -0
  127. package/dist/index-CZunST0r.d.ts +1436 -0
  128. package/dist/index-CeqDyZsK.d.ts +1436 -0
  129. package/dist/index-CiDj5eUV.d.ts +1576 -0
  130. package/dist/index-CidSP07o.d.ts +1361 -0
  131. package/dist/index-Cj_9DtdX.d.ts +1436 -0
  132. package/dist/index-Cm1e5jei.d.ts +1436 -0
  133. package/dist/index-CnQ2vhtJ.d.ts +1563 -0
  134. package/dist/index-CpkEL1jH.d.ts +1569 -0
  135. package/dist/index-Cq5d1Zz3.d.ts +1437 -0
  136. package/dist/index-CuCNTbJn.d.ts +1503 -0
  137. package/dist/index-CxFq13gU.d.ts +1352 -0
  138. package/dist/index-D5dNz_3e.d.ts +1571 -0
  139. package/dist/index-D5yYZNhb.d.ts +1428 -0
  140. package/dist/index-D64A9cbc.d.ts +1428 -0
  141. package/dist/index-DE8BSmm3.d.ts +1575 -0
  142. package/dist/index-DG6bq7_g.d.ts +1436 -0
  143. package/dist/index-DHy5_GN-.d.ts +1437 -0
  144. package/dist/index-DTegsEZx.d.ts +1435 -0
  145. package/dist/index-DXx9mqPm.d.ts +1352 -0
  146. package/dist/index-DbOTogCX.d.ts +1435 -0
  147. package/dist/index-DfXUO0lq.d.ts +1352 -0
  148. package/dist/index-DirmTpEb.d.ts +1352 -0
  149. package/dist/index-DnUO13Ql.d.ts +1365 -0
  150. package/dist/index-DqFnifuO.d.ts +1576 -0
  151. package/dist/index-DsAkAm0h.d.ts +1429 -0
  152. package/dist/index-DsDkGdbl.d.ts +1352 -0
  153. package/dist/index-DugBnSpg.d.ts +1439 -0
  154. package/dist/index-DyF8SurV.d.ts +1437 -0
  155. package/dist/index-VAwbjQuD.d.ts +1436 -0
  156. package/dist/index-VRdwaTq1.d.ts +1544 -0
  157. package/dist/index-WJDLtNz6.d.ts +1437 -0
  158. package/dist/index-XHQiCZJu.d.ts +1344 -0
  159. package/dist/index-YGI08ZC3.d.ts +1435 -0
  160. package/dist/index-YlvmjCMz.d.ts +1574 -0
  161. package/dist/index-_R_iWuBk.d.ts +1435 -0
  162. package/dist/index-bKRdI8Js.d.ts +1544 -0
  163. package/dist/index-sdb3nXP9.d.ts +1436 -0
  164. package/dist/index-u8kUqFhR.d.ts +1442 -0
  165. package/dist/index-uCL6lDoN.d.ts +1365 -0
  166. package/dist/index-wMtGrbTW.d.ts +1435 -0
  167. package/dist/index-wmq1KsvF.d.ts +1523 -0
  168. package/dist/index.cjs +298 -92
  169. package/dist/index.d.cts +6 -5
  170. package/dist/index.d.ts +198 -35
  171. package/dist/index.mjs +277 -94
  172. package/dist/mount--bdP_py-.cjs +27 -0
  173. package/dist/mount-5mGNlNE0.cjs +29 -0
  174. package/dist/mount-9aJ90VEy.cjs +29 -0
  175. package/dist/mount-B-nSxYMI.cjs +29 -0
  176. package/dist/mount-B1ZGm6Vx.mjs +26 -0
  177. package/dist/mount-B268CIyG.mjs +26 -0
  178. package/dist/mount-B7ZORKUE.mjs +26 -0
  179. package/dist/mount-BDMCcckP.mjs +26 -0
  180. package/dist/mount-BFwjtKGf.mjs +23 -0
  181. package/dist/mount-BIX7Q5ve.cjs +29 -0
  182. package/dist/mount-BIjY0oQo.cjs +29 -0
  183. package/dist/mount-BJ2d7Snl.cjs +29 -0
  184. package/dist/mount-BJUfLVrn.cjs +27 -0
  185. package/dist/mount-BL3IoYf-.cjs +29 -0
  186. package/dist/mount-BLgGRFKO.mjs +26 -0
  187. package/dist/mount-BPdF-23b.mjs +26 -0
  188. package/dist/mount-BREA5x3R.mjs +26 -0
  189. package/dist/mount-BSj7I235.cjs +29 -0
  190. package/dist/mount-BSqj-PWe.cjs +26 -0
  191. package/dist/mount-B_MohJp1.mjs +24 -0
  192. package/dist/mount-BhJaAQYc.cjs +29 -0
  193. package/dist/mount-BmhdXDtN.mjs +26 -0
  194. package/dist/mount-Bn8gK_5W.mjs +26 -0
  195. package/dist/mount-BnITFgq_.mjs +26 -0
  196. package/dist/mount-BoeMXBAs.cjs +29 -0
  197. package/dist/mount-BsWXMcQo.mjs +26 -0
  198. package/dist/mount-BvArK3iG.cjs +26 -0
  199. package/dist/mount-Bw7-xmEB.mjs +24 -0
  200. package/dist/mount-BwNr0Cw7.cjs +29 -0
  201. package/dist/mount-C1WHPtGU.mjs +26 -0
  202. package/dist/mount-C6Wj_FWd.cjs +29 -0
  203. package/dist/mount-C7-zVnHp.mjs +26 -0
  204. package/dist/mount-C99AnUyn.mjs +24 -0
  205. package/dist/mount-CC8_T-gT.cjs +29 -0
  206. package/dist/mount-CE1mUC04.cjs +27 -0
  207. package/dist/mount-CGOXBqpC.cjs +29 -0
  208. package/dist/mount-CJGmuyD_.cjs +29 -0
  209. package/dist/mount-COdfKsz3.mjs +26 -0
  210. package/dist/mount-CTXA2JwJ.cjs +29 -0
  211. package/dist/mount-CVcZv8p4.mjs +24 -0
  212. package/dist/mount-CY2jiisH.cjs +27 -0
  213. package/dist/mount-C_THF3G-.mjs +26 -0
  214. package/dist/mount-CgYRpExe.mjs +24 -0
  215. package/dist/mount-CiSuPb2d.cjs +29 -0
  216. package/dist/mount-CjvdhG7D.mjs +24 -0
  217. package/dist/mount-Ck4Sw7qu.cjs +29 -0
  218. package/dist/mount-CkBH-ziv.mjs +26 -0
  219. package/dist/mount-Cl5bq4AK.mjs +26 -0
  220. package/dist/mount-CnRlxDvH.cjs +26 -0
  221. package/dist/mount-Cnhy4x8j.cjs +29 -0
  222. package/dist/mount-CofCsKEL.cjs +27 -0
  223. package/dist/mount-CuZ9kuJ_.cjs +29 -0
  224. package/dist/mount-Cz18Dqhg.cjs +29 -0
  225. package/dist/mount-CzoPJJ3U.cjs +29 -0
  226. package/dist/mount-D-08N9KC.mjs +26 -0
  227. package/dist/mount-D-RpVmv-.cjs +27 -0
  228. package/dist/mount-D0wRLhsJ.mjs +23 -0
  229. package/dist/mount-DBHsNvGL.mjs +24 -0
  230. package/dist/mount-DE_6OU5O.cjs +27 -0
  231. package/dist/mount-DFrJC1Ee.mjs +26 -0
  232. package/dist/mount-DRpQI95j.mjs +26 -0
  233. package/dist/mount-DaS_nGtr.cjs +26 -0
  234. package/dist/mount-DbFi8R0Q.mjs +26 -0
  235. package/dist/mount-DeqZS1eY.mjs +26 -0
  236. package/dist/mount-DetJmqRg.mjs +26 -0
  237. package/dist/mount-DhMUtUgA.cjs +29 -0
  238. package/dist/mount-DlsFpu0l.mjs +26 -0
  239. package/dist/mount-DmThSQhX.mjs +26 -0
  240. package/dist/mount-DpCAhV34.cjs +29 -0
  241. package/dist/mount-DqMUI3Li.cjs +29 -0
  242. package/dist/mount-DrvT4c9H.mjs +23 -0
  243. package/dist/mount-DyrgmigG.mjs +26 -0
  244. package/dist/mount-E-PFWZoH.cjs +29 -0
  245. package/dist/mount-EbSuNkcp.cjs +29 -0
  246. package/dist/mount-FGWwjyl3.mjs +23 -0
  247. package/dist/mount-NvaShFIJ.mjs +24 -0
  248. package/dist/mount-OwEsrEgH.mjs +26 -0
  249. package/dist/mount-OzbDDNzG.cjs +29 -0
  250. package/dist/mount-TA9rAjfX.mjs +26 -0
  251. package/dist/mount-Ta6JNwOd.cjs +29 -0
  252. package/dist/mount-WayWo_Wo.cjs +29 -0
  253. package/dist/mount-cbdw4Rn8.mjs +26 -0
  254. package/dist/mount-euC2wM_H.mjs +26 -0
  255. package/dist/mount-gY0N84Yl.cjs +29 -0
  256. package/dist/mount-j5GGTHgL.mjs +26 -0
  257. package/dist/mount-lrm6DtLS.cjs +29 -0
  258. package/dist/mount-mI6oAeYn.mjs +26 -0
  259. package/dist/mount-qXpzCgOn.cjs +27 -0
  260. package/dist/mount-s4KN8Ng-.mjs +26 -0
  261. package/dist/mount-wMBAOpuQ.mjs +26 -0
  262. package/dist/mount-yB4RTAZ9.cjs +29 -0
  263. package/dist/mount-zEZORNEX.mjs +26 -0
  264. package/dist/mount-zk9YB0XU.cjs +29 -0
  265. package/dist/render/client.cjs +28 -11
  266. package/dist/render/client.d.ts +4 -4
  267. package/dist/render/client.mjs +13 -13
  268. package/dist/render/dev/index.cjs +4 -1
  269. package/dist/render/dev/index.d.ts +2 -3
  270. package/dist/render/dev/index.mjs +1 -1
  271. package/dist/render/index.cjs +20 -1
  272. package/dist/render/index.d.cts +76 -1
  273. package/dist/render/index.d.ts +88 -3
  274. package/dist/render/index.mjs +2 -1
  275. package/dist/render/server.cjs +19 -1
  276. package/dist/render/server.d.ts +4 -4
  277. package/dist/render/server.mjs +3 -2
  278. package/package.json +19 -11
@@ -0,0 +1,2566 @@
1
+ 'use strict';
2
+
3
+ var defussRuntime = require('defuss-runtime');
4
+
5
+ class Call {
6
+ name;
7
+ fn;
8
+ args;
9
+ constructor(name, fn, ...args) {
10
+ this.name = name;
11
+ this.fn = fn;
12
+ this.args = args;
13
+ }
14
+ }
15
+ const globalRegistry = globalThis;
16
+ if (!globalRegistry.__defuss_nonChainedReturnCallNames) {
17
+ globalRegistry.__defuss_nonChainedReturnCallNames = [
18
+ "getFirstElement",
19
+ "toArray",
20
+ "map",
21
+ "isHidden",
22
+ "isVisible",
23
+ "hasClass",
24
+ "dimension",
25
+ "position",
26
+ "offset",
27
+ "prop",
28
+ "val",
29
+ "form",
30
+ "attr",
31
+ "data",
32
+ "css",
33
+ "html",
34
+ "serialize"
35
+ ];
36
+ }
37
+ function addNonChainedReturnCallNames(callNames) {
38
+ const global = globalRegistry.__defuss_nonChainedReturnCallNames;
39
+ callNames.forEach((name) => {
40
+ if (!global.includes(name)) {
41
+ global.push(name);
42
+ }
43
+ });
44
+ }
45
+ function getNonChainedReturnCallNames() {
46
+ return [...globalRegistry.__defuss_nonChainedReturnCallNames];
47
+ }
48
+ function isNonChainedReturnCall(callName) {
49
+ return globalRegistry.__defuss_nonChainedReturnCallNames.includes(callName);
50
+ }
51
+ const emptyImpl = (nodes) => {
52
+ nodes.forEach((el) => {
53
+ const element = el;
54
+ while (element.firstChild) {
55
+ element.firstChild.remove();
56
+ }
57
+ });
58
+ return nodes;
59
+ };
60
+ class CallChainImpl {
61
+ isResolved;
62
+ options;
63
+ elementCreationOptions;
64
+ callStack;
65
+ resultStack;
66
+ stackPointer;
67
+ lastResolvedStackPointer;
68
+ stoppedWithError;
69
+ lastResult;
70
+ length;
71
+ chainStartTime;
72
+ chainAsyncStartTime;
73
+ chainAsyncFinishTime;
74
+ // SSR-ability
75
+ document;
76
+ window;
77
+ performance;
78
+ Parser;
79
+ constructor(options = {}) {
80
+ this.options = {
81
+ ...getDefaultDequeryOptions(),
82
+ ...options
83
+ };
84
+ const optionsKeys = Object.keys(getDefaultDequeryOptions());
85
+ this.options = defussRuntime.pick(this.options, optionsKeys);
86
+ this.window = this.options.globals.window;
87
+ this.document = this.options.globals.window.document;
88
+ this.performance = this.options.globals.performance;
89
+ this.Parser = this.options.globals.window.DOMParser;
90
+ const elementCreationOptions = defussRuntime.omit(
91
+ options,
92
+ optionsKeys
93
+ );
94
+ this.elementCreationOptions = elementCreationOptions;
95
+ this.callStack = [];
96
+ this.resultStack = options.resultStack ? [options.resultStack] : [];
97
+ this.stackPointer = 0;
98
+ this.lastResolvedStackPointer = 0;
99
+ this.stoppedWithError = null;
100
+ this.lastResult = [];
101
+ this.length = 0;
102
+ this.isResolved = false;
103
+ this.chainStartTime = this.performance.now() ?? 0;
104
+ this.chainAsyncStartTime = 0;
105
+ this.chainAsyncFinishTime = 0;
106
+ }
107
+ get globals() {
108
+ return this.options.globals;
109
+ }
110
+ // sync methods
111
+ // currently selected nodes
112
+ get nodes() {
113
+ return this.resultStack.length > 0 ? this.resultStack[this.resultStack.length - 1] : [];
114
+ }
115
+ // allow for for .. of loop
116
+ [Symbol.iterator]() {
117
+ return this.nodes[Symbol.iterator]();
118
+ }
119
+ // async, direct result method
120
+ getFirstElement() {
121
+ return createCall(
122
+ this,
123
+ "getFirstElement",
124
+ async () => this[0]
125
+ );
126
+ }
127
+ // async, wrapped/chainable API methods
128
+ debug(cb) {
129
+ return createCall(this, "debug", async () => {
130
+ cb(this);
131
+ return this.nodes;
132
+ });
133
+ }
134
+ ref(ref) {
135
+ return createCall(this, "ref", async () => {
136
+ if (ref.current) {
137
+ return [ref.current];
138
+ }
139
+ await defussRuntime.waitForRef(ref, this.options.timeout);
140
+ if (ref.current) {
141
+ return [ref.current];
142
+ } else {
143
+ console.log("\u274C ref() - ref is still null after timeout");
144
+ throw new Error("Ref is null or undefined after timeout");
145
+ }
146
+ });
147
+ }
148
+ query(selector) {
149
+ return createCall(
150
+ this,
151
+ "query",
152
+ async () => {
153
+ return Array.from(
154
+ await waitForDOM(
155
+ () => Array.from(this.document.querySelectorAll(selector)),
156
+ this.options.timeout,
157
+ this.document
158
+ )
159
+ );
160
+ },
161
+ selector
162
+ );
163
+ }
164
+ next() {
165
+ return traverse(this, "next", (el) => el.nextElementSibling);
166
+ }
167
+ prev() {
168
+ return traverse(this, "prev", (el) => el.previousElementSibling);
169
+ }
170
+ find(selector) {
171
+ return createCall(
172
+ this,
173
+ "find",
174
+ async () => {
175
+ const results = await Promise.all(
176
+ this.nodes.map(async (el) => {
177
+ return await waitForDOM(
178
+ () => Array.from(el.querySelectorAll(selector)),
179
+ this.options.timeout,
180
+ this.document
181
+ );
182
+ })
183
+ );
184
+ return results.flat();
185
+ },
186
+ selector
187
+ );
188
+ }
189
+ parent() {
190
+ return traverse(this, "parent", (el) => el.parentElement);
191
+ }
192
+ children() {
193
+ return traverse(this, "children", (el) => Array.from(el.children));
194
+ }
195
+ closest(selector) {
196
+ return traverse(this, "closest", (el) => el.closest(selector));
197
+ }
198
+ first() {
199
+ return createCall(this, "first", async () => {
200
+ return this.nodes.slice(0, 1);
201
+ });
202
+ }
203
+ last() {
204
+ return createCall(this, "last", async () => {
205
+ return this.nodes.slice(-1);
206
+ });
207
+ }
208
+ attr(name, value) {
209
+ return createGetterSetterCall(
210
+ this,
211
+ "attr",
212
+ value,
213
+ // Getter function
214
+ () => {
215
+ if (this.nodes.length === 0) return null;
216
+ return this.nodes[0].getAttribute(name);
217
+ },
218
+ // Setter function
219
+ (val) => {
220
+ this.nodes.forEach((el) => el.setAttribute(name, val));
221
+ }
222
+ );
223
+ }
224
+ prop(name, value) {
225
+ return createGetterSetterCall(
226
+ this,
227
+ "prop",
228
+ value,
229
+ // Getter function
230
+ () => {
231
+ if (this.nodes.length === 0) return void 0;
232
+ return this.nodes[0][name];
233
+ },
234
+ // Setter function
235
+ (val) => {
236
+ this.nodes.forEach((el) => {
237
+ el[name] = val;
238
+ });
239
+ }
240
+ );
241
+ }
242
+ // --- CSS & Class Methods ---
243
+ static resultCache = /* @__PURE__ */ new WeakMap();
244
+ css(prop, value) {
245
+ if (typeof prop === "object") {
246
+ return createCall(this, "css", async () => {
247
+ const elements = this.nodes;
248
+ elements.forEach((el) => {
249
+ const htmlEl = el;
250
+ Object.entries(prop).forEach(([key, val]) => {
251
+ htmlEl.style.setProperty(
252
+ key.replace(/([A-Z])/g, "-$1").toLowerCase(),
253
+ String(val)
254
+ );
255
+ });
256
+ });
257
+ return this.nodes;
258
+ });
259
+ }
260
+ return createGetterSetterCall(
261
+ this,
262
+ "css",
263
+ value,
264
+ // Getter with caching
265
+ () => {
266
+ if (this.nodes.length === 0) return "";
267
+ const el = this.nodes[0];
268
+ const cache = CallChainImpl.resultCache.get(el) || /* @__PURE__ */ new Map();
269
+ const cacheKey = `css:${prop}`;
270
+ if (cache.has(cacheKey)) {
271
+ return cache.get(cacheKey);
272
+ }
273
+ const result = el.style.getPropertyValue(prop);
274
+ cache.set(cacheKey, result);
275
+ CallChainImpl.resultCache.set(el, cache);
276
+ return result;
277
+ },
278
+ // Setter with cache invalidation
279
+ (val) => {
280
+ this.nodes.forEach((el) => {
281
+ el.style.setProperty(prop, String(val));
282
+ const cache = CallChainImpl.resultCache.get(el);
283
+ if (cache) {
284
+ cache.delete(`css:${prop}`);
285
+ }
286
+ });
287
+ }
288
+ );
289
+ }
290
+ addClass(name) {
291
+ return createCall(this, "addClass", async () => {
292
+ const list = Array.isArray(name) ? name : [name];
293
+ this.nodes.forEach((el) => el.classList.add(...list));
294
+ return this.nodes;
295
+ });
296
+ }
297
+ removeClass(name) {
298
+ return createCall(this, "removeClass", async () => {
299
+ const list = Array.isArray(name) ? name : [name];
300
+ this.nodes.forEach((el) => el.classList.remove(...list));
301
+ return this.nodes;
302
+ });
303
+ }
304
+ hasClass(name) {
305
+ return createCall(
306
+ this,
307
+ "hasClass",
308
+ async () => this.nodes.every(
309
+ (el) => el.classList.contains(name)
310
+ )
311
+ );
312
+ }
313
+ toggleClass(name) {
314
+ return createCall(this, "toggleClass", async () => {
315
+ this.nodes.forEach((el) => el.classList.toggle(name));
316
+ return this.nodes;
317
+ });
318
+ }
319
+ animateClass(name, duration) {
320
+ return createCall(this, "animateClass", async () => {
321
+ this.nodes.forEach((el) => {
322
+ const e = el;
323
+ e.classList.add(name);
324
+ setTimeout(() => e.classList.remove(name), duration);
325
+ });
326
+ return this.nodes;
327
+ });
328
+ }
329
+ // --- Content Manipulation Methods ---
330
+ empty() {
331
+ return createCall(
332
+ this,
333
+ "empty",
334
+ async () => emptyImpl(this.nodes)
335
+ );
336
+ }
337
+ html(html) {
338
+ return createGetterSetterCall(
339
+ this,
340
+ "html",
341
+ html,
342
+ () => {
343
+ if (this.nodes.length === 0) return "";
344
+ return this.nodes[0].innerHTML;
345
+ },
346
+ (val) => {
347
+ this.nodes.forEach((el) => {
348
+ el.innerHTML = val;
349
+ });
350
+ }
351
+ );
352
+ }
353
+ jsx(vdom) {
354
+ if (!isJSX(vdom)) {
355
+ throw new Error("Invalid JSX input");
356
+ }
357
+ return createCall(this, "jsx", async () => {
358
+ this.nodes.forEach(
359
+ (el) => updateDomWithVdom(el, vdom, globalThis)
360
+ );
361
+ return this.nodes;
362
+ });
363
+ }
364
+ text(text) {
365
+ return createGetterSetterCall(
366
+ this,
367
+ "text",
368
+ text,
369
+ // Getter function
370
+ () => {
371
+ if (this.nodes.length === 0) return "";
372
+ return this.nodes[0].textContent || "";
373
+ },
374
+ // Setter function
375
+ (val) => {
376
+ this.nodes.forEach((el) => {
377
+ el.textContent = val;
378
+ });
379
+ }
380
+ );
381
+ }
382
+ remove() {
383
+ return createCall(this, "remove", async () => {
384
+ const removedElements = [...this.nodes];
385
+ this.nodes.forEach((el) => el.remove());
386
+ return removedElements;
387
+ });
388
+ }
389
+ replaceWith(content) {
390
+ return createCall(this, "replaceWith", async () => {
391
+ const newElements = [];
392
+ const newElement = await renderNode(content, this);
393
+ for (const originalEl of this.nodes) {
394
+ if (!originalEl?.parentNode) continue;
395
+ if (!newElement) continue;
396
+ originalEl.parentNode.replaceChild(newElement, originalEl);
397
+ newElements.push(newElement);
398
+ }
399
+ this.resultStack[this.resultStack.length - 1] = newElements;
400
+ mapArrayIndexAccess(this, this);
401
+ return newElements;
402
+ });
403
+ }
404
+ append(content) {
405
+ return createCall(this, "append", async () => {
406
+ if (content == null) {
407
+ return this.nodes;
408
+ }
409
+ if (content instanceof Node) {
410
+ this.nodes.forEach((el) => {
411
+ if (el && content && !el.isEqualNode(content) && el.parentNode !== content) {
412
+ el.appendChild(content);
413
+ }
414
+ });
415
+ return this.nodes;
416
+ }
417
+ const element = await renderNode(content, this);
418
+ if (!element) return this.nodes;
419
+ if (isDequery(content)) {
420
+ this.nodes.forEach((el) => {
421
+ content.nodes.forEach((childEl) => {
422
+ if (childEl.nodeType && el.nodeType && !childEl.isEqualNode(el) && el.parentNode !== childEl) {
423
+ el.appendChild(childEl);
424
+ }
425
+ });
426
+ });
427
+ } else if (typeof content === "string" && isMarkup(content, this.Parser)) {
428
+ const elements = renderMarkup(content, this.Parser);
429
+ this.nodes.forEach((el) => {
430
+ elements.forEach(
431
+ (childEl) => el.appendChild(childEl)
432
+ );
433
+ });
434
+ } else {
435
+ this.nodes.forEach((el) => {
436
+ if (!element) return;
437
+ el.appendChild(element);
438
+ });
439
+ }
440
+ return this.nodes;
441
+ });
442
+ }
443
+ appendTo(target) {
444
+ return createCall(this, "appendTo", async () => {
445
+ const nodes = await resolveNodes(
446
+ target,
447
+ this.options.timeout,
448
+ this.document
449
+ );
450
+ if (nodes.length === 0) {
451
+ return this.nodes;
452
+ }
453
+ nodes.forEach((node) => {
454
+ this.nodes.forEach((el) => {
455
+ if (!node || !el) return;
456
+ node.appendChild(el.cloneNode(true));
457
+ });
458
+ });
459
+ return this.nodes;
460
+ });
461
+ }
462
+ update(input, transitionConfig) {
463
+ return createCall(this, "update", async () => {
464
+ return await updateDom(
465
+ input,
466
+ this.nodes,
467
+ this.options.timeout,
468
+ this.Parser,
469
+ transitionConfig
470
+ );
471
+ });
472
+ }
473
+ // --- Event Methods ---
474
+ on(event, handler) {
475
+ return createCall(
476
+ this,
477
+ "on",
478
+ async () => {
479
+ this.nodes.forEach((el) => {
480
+ addElementEvent(el, event, handler);
481
+ });
482
+ return this.nodes;
483
+ },
484
+ event,
485
+ handler
486
+ );
487
+ }
488
+ off(event, handler) {
489
+ return createCall(this, "off", async () => {
490
+ this.nodes.forEach((el) => {
491
+ removeElementEvent(el, event, handler);
492
+ });
493
+ return this.nodes;
494
+ });
495
+ }
496
+ clearEvents() {
497
+ return createCall(this, "clearEvents", async () => {
498
+ this.nodes.forEach((el) => {
499
+ clearElementEvents(el);
500
+ });
501
+ return this.nodes;
502
+ });
503
+ }
504
+ trigger(eventType) {
505
+ return createCall(this, "trigger", async () => {
506
+ this.nodes.forEach(
507
+ (el) => el.dispatchEvent(
508
+ new Event(eventType, { bubbles: true, cancelable: true })
509
+ )
510
+ );
511
+ return this.nodes;
512
+ });
513
+ }
514
+ // --- Position Methods ---
515
+ position() {
516
+ return createCall(
517
+ this,
518
+ "position",
519
+ async () => ({
520
+ top: this.nodes[0].offsetTop,
521
+ left: this.nodes[0].offsetLeft
522
+ })
523
+ );
524
+ }
525
+ offset() {
526
+ return createCall(this, "offset", async () => {
527
+ const el = this.nodes[0];
528
+ const rect = el.getBoundingClientRect();
529
+ return {
530
+ top: rect.top + window.scrollY,
531
+ left: rect.left + window.scrollX
532
+ };
533
+ });
534
+ }
535
+ // --- Data Methods ---
536
+ data(name, value) {
537
+ return createGetterSetterCall(
538
+ this,
539
+ "data",
540
+ value,
541
+ // Getter function
542
+ () => {
543
+ if (this.nodes.length === 0) return void 0;
544
+ return this.nodes[0].dataset[name];
545
+ },
546
+ // Setter function
547
+ (val) => {
548
+ this.nodes.forEach((el) => {
549
+ el.dataset[name] = val;
550
+ });
551
+ }
552
+ );
553
+ }
554
+ val(val) {
555
+ return createGetterSetterCall(
556
+ this,
557
+ "val",
558
+ val,
559
+ // Getter function
560
+ () => {
561
+ if (this.nodes.length === 0) return "";
562
+ const el = this.nodes[0];
563
+ if (el.type === "checkbox") {
564
+ return el.checked;
565
+ }
566
+ return el.value;
567
+ },
568
+ // Setter function
569
+ (value) => {
570
+ this.nodes.forEach((el) => {
571
+ const input = el;
572
+ if (input.type === "checkbox" && typeof value === "boolean") {
573
+ input.checked = value;
574
+ } else {
575
+ input.value = String(value);
576
+ }
577
+ });
578
+ }
579
+ );
580
+ }
581
+ serialize(format = "querystring") {
582
+ const mapValue = (value) => typeof value === "boolean" ? value ? "on" : "off" : value;
583
+ return createCall(this, "serialize", async () => {
584
+ const formData = getAllFormValues(this);
585
+ if (format === "json") {
586
+ return JSON.stringify(formData);
587
+ } else {
588
+ const urlSearchParams = new URLSearchParams();
589
+ const keys = Object.keys(formData);
590
+ keys.forEach((key) => {
591
+ const value = formData[key];
592
+ if (typeof value === "string") {
593
+ urlSearchParams.append(key, value);
594
+ } else if (typeof value === "boolean") {
595
+ urlSearchParams.append(key, mapValue(value));
596
+ } else if (Array.isArray(value)) {
597
+ value.forEach(
598
+ (value2) => urlSearchParams.append(key, mapValue(value2))
599
+ );
600
+ }
601
+ });
602
+ return urlSearchParams.toString();
603
+ }
604
+ });
605
+ }
606
+ form(formData) {
607
+ return createGetterSetterCall(
608
+ this,
609
+ "form",
610
+ formData,
611
+ // Getter function
612
+ () => getAllFormValues(this),
613
+ // Setter function
614
+ (values) => {
615
+ this.nodes.forEach((el) => {
616
+ processAllFormElements(el, (input, key) => {
617
+ if (values[key] !== void 0) {
618
+ if (input.type === "checkbox") {
619
+ input.checked = Boolean(values[key]);
620
+ } else {
621
+ input.value = String(values[key]);
622
+ }
623
+ }
624
+ });
625
+ });
626
+ }
627
+ );
628
+ }
629
+ // --- Dimension Methods ---
630
+ dimension(includeMarginOrPadding, includePaddingIfMarginTrue) {
631
+ return createCall(this, "dimension", async () => {
632
+ if (this.nodes.length === 0) {
633
+ return { width: 0, height: 0 };
634
+ }
635
+ const el = this.nodes[0];
636
+ const style = this.window.getComputedStyle(el);
637
+ if (!style) return { width: 0, height: 0 };
638
+ const rect = el.getBoundingClientRect();
639
+ let width = rect.width;
640
+ let height = rect.height;
641
+ let includeMargin = false;
642
+ let includePadding = true;
643
+ if (includePaddingIfMarginTrue !== void 0) {
644
+ includeMargin = !!includeMarginOrPadding;
645
+ includePadding = !!includePaddingIfMarginTrue;
646
+ } else if (includeMarginOrPadding !== void 0) {
647
+ includePadding = !!includeMarginOrPadding;
648
+ }
649
+ if (!includePadding) {
650
+ const paddingLeft = Number.parseFloat(style.paddingLeft) || 0;
651
+ const paddingRight = Number.parseFloat(style.paddingRight) || 0;
652
+ const paddingTop = Number.parseFloat(style.paddingTop) || 0;
653
+ const paddingBottom = Number.parseFloat(style.paddingBottom) || 0;
654
+ const borderLeft = Number.parseFloat(style.borderLeftWidth) || 0;
655
+ const borderRight = Number.parseFloat(style.borderRightWidth) || 0;
656
+ const borderTop = Number.parseFloat(style.borderTopWidth) || 0;
657
+ const borderBottom = Number.parseFloat(style.borderBottomWidth) || 0;
658
+ width -= paddingLeft + paddingRight + borderLeft + borderRight;
659
+ height -= paddingTop + paddingBottom + borderTop + borderBottom;
660
+ }
661
+ if (includeMargin) {
662
+ const marginLeft = Number.parseFloat(style.marginLeft) || 0;
663
+ const marginRight = Number.parseFloat(style.marginRight) || 0;
664
+ const marginTop = Number.parseFloat(style.marginTop) || 0;
665
+ const marginBottom = Number.parseFloat(style.marginBottom) || 0;
666
+ const baseWidthForOuter = includePadding ? rect.width : width;
667
+ const baseHeightForOuter = includePadding ? rect.height : height;
668
+ const outerWidth = baseWidthForOuter + marginLeft + marginRight;
669
+ const outerHeight = baseHeightForOuter + marginTop + marginBottom;
670
+ return {
671
+ width,
672
+ height,
673
+ outerWidth,
674
+ outerHeight
675
+ };
676
+ }
677
+ return {
678
+ width,
679
+ height
680
+ };
681
+ });
682
+ }
683
+ // --- Visibility Methods ---
684
+ isVisible() {
685
+ return createCall(this, "isVisible", async () => {
686
+ if (this.nodes.length === 0) return false;
687
+ const el = this.nodes[0];
688
+ return checkElementVisibility(el, this.window, this.document);
689
+ });
690
+ }
691
+ isHidden() {
692
+ return createCall(this, "isHidden", async () => {
693
+ if (this.nodes.length === 0) return true;
694
+ const el = this.nodes[0];
695
+ return !checkElementVisibility(el, this.window, this.document);
696
+ });
697
+ }
698
+ // --- Scrolling Methods ---
699
+ scrollTo(xOrOptions, y) {
700
+ return createCall(this, "scrollTo", async () => {
701
+ return scrollHelper("scrollTo", this.nodes, xOrOptions, y);
702
+ });
703
+ }
704
+ scrollBy(xOrOptions, y) {
705
+ return createCall(this, "scrollBy", async () => {
706
+ return scrollHelper("scrollBy", this.nodes, xOrOptions, y);
707
+ });
708
+ }
709
+ scrollIntoView(options) {
710
+ return createCall(this, "scrollIntoView", async () => {
711
+ if (this.nodes.length === 0) return this.nodes;
712
+ this.nodes[0].scrollIntoView(options);
713
+ return this.nodes;
714
+ });
715
+ }
716
+ // --- Transformation Methods ---
717
+ map(cb) {
718
+ return createCall(this, "map", async () => {
719
+ const elements = this.nodes;
720
+ const results = new Array(elements.length);
721
+ for (let i = 0; i < elements.length; i++) {
722
+ results[i] = cb(elements[i], i);
723
+ }
724
+ return results;
725
+ });
726
+ }
727
+ toArray() {
728
+ return createCall(
729
+ this,
730
+ "toArray",
731
+ async () => [...this.nodes]
732
+ );
733
+ }
734
+ filter(selector) {
735
+ return createCall(
736
+ this,
737
+ "filter",
738
+ async () => this.nodes.filter(
739
+ (el) => el instanceof Element && el.matches(selector)
740
+ )
741
+ );
742
+ }
743
+ // --- Cleanup Methods ---
744
+ /** memory cleanup (chain becomes useless after calling this method) */
745
+ dispose() {
746
+ return createCall(this, "dispose", async () => {
747
+ this.nodes.forEach((el) => {
748
+ CallChainImpl.resultCache.delete(el);
749
+ });
750
+ this.callStack.length = 0;
751
+ this.resultStack.length = 0;
752
+ this.stackPointer = 0;
753
+ this.lastResolvedStackPointer = 0;
754
+ return void 0;
755
+ });
756
+ }
757
+ ready(callback) {
758
+ return createCall(this, "ready", async () => {
759
+ if (this.document.readyState === "complete" || this.document.readyState === "interactive") {
760
+ if (callback) {
761
+ callback();
762
+ }
763
+ return this.nodes;
764
+ }
765
+ const nodes = this.nodes;
766
+ const document = this.document;
767
+ return new Promise((resolve) => {
768
+ const handleDOMContentLoaded = () => {
769
+ document.removeEventListener(
770
+ "DOMContentLoaded",
771
+ handleDOMContentLoaded
772
+ );
773
+ if (callback) {
774
+ callback();
775
+ }
776
+ resolve(nodes);
777
+ };
778
+ document.addEventListener("DOMContentLoaded", handleDOMContentLoaded);
779
+ });
780
+ });
781
+ }
782
+ // TODO:
783
+ // - deserialize (from URL string, JSON, etc.)
784
+ }
785
+ class CallChainImplThenable extends CallChainImpl {
786
+ constructor(options = {}, isResolved = false) {
787
+ super(options);
788
+ this.isResolved = isResolved;
789
+ }
790
+ // biome-ignore lint/suspicious/noThenProperty: <explanation>
791
+ then(onfulfilled, onrejected) {
792
+ this.chainAsyncStartTime = this.performance.now() ?? 0;
793
+ if (this.stoppedWithError) {
794
+ return Promise.reject(this.stoppedWithError).then(
795
+ onfulfilled,
796
+ onrejected
797
+ );
798
+ }
799
+ if (this.isResolved && this.stackPointer >= this.callStack.length) {
800
+ this.lastResolvedStackPointer = this.stackPointer;
801
+ const lastCallName = this.callStack[this.callStack.length - 1]?.name;
802
+ let result;
803
+ if (isNonChainedReturnCall(lastCallName)) {
804
+ result = this.lastResult;
805
+ } else {
806
+ result = createSubChain(this, CallChainImpl, true);
807
+ }
808
+ this.chainAsyncFinishTime = (this.performance.now() ?? 0) - this.chainAsyncStartTime;
809
+ return Promise.resolve(result).then(onfulfilled, onrejected);
810
+ }
811
+ return runWithTimeGuard(
812
+ this.options.timeout,
813
+ async () => {
814
+ let call;
815
+ while (this.stackPointer < this.callStack.length) {
816
+ call = this.callStack[this.stackPointer];
817
+ try {
818
+ const callReturnValue = await call.fn.apply(this);
819
+ this.lastResult = callReturnValue;
820
+ if (!isNonChainedReturnCall(call.name)) {
821
+ this.resultStack.push(callReturnValue);
822
+ }
823
+ if (Array.isArray(this.lastResult)) {
824
+ mapArrayIndexAccess(this, this);
825
+ }
826
+ this.stackPointer++;
827
+ } catch (err) {
828
+ this.stoppedWithError = err;
829
+ throw err;
830
+ }
831
+ }
832
+ this.isResolved = true;
833
+ this.chainAsyncFinishTime = (this.performance.now() ?? 0) - this.chainAsyncStartTime;
834
+ return this;
835
+ },
836
+ [this],
837
+ // ← Pass the chain context as args[0]
838
+ // Timeout error handler - called by runWithTimeGuard when timeout is exceeded
839
+ (ms, call) => {
840
+ this.stoppedWithError = new Error(
841
+ `Chain execution timeout after ${ms}ms`
842
+ );
843
+ }
844
+ ).then((result) => {
845
+ onfulfilled(result);
846
+ return result;
847
+ }).catch(onrejected);
848
+ }
849
+ catch(onrejected) {
850
+ return this.then(void 0, onrejected);
851
+ }
852
+ finally(onfinally) {
853
+ return this.then(
854
+ (value) => {
855
+ onfinally?.();
856
+ return value;
857
+ },
858
+ (reason) => {
859
+ onfinally?.();
860
+ throw reason;
861
+ }
862
+ );
863
+ }
864
+ }
865
+ function scrollHelper(methodName, elements, xOrOptions, y) {
866
+ elements.forEach((el) => {
867
+ const element = el;
868
+ if (typeof xOrOptions === "object") {
869
+ element[methodName](xOrOptions);
870
+ } else if (y !== void 0) {
871
+ element[methodName](xOrOptions, y);
872
+ } else {
873
+ element[methodName](xOrOptions, 0);
874
+ }
875
+ });
876
+ return elements;
877
+ }
878
+ function getAllFormValues(chain) {
879
+ const formFields = {};
880
+ const mapCheckboxValue = (value) => value === "on" ? true : value;
881
+ chain.nodes.forEach((el) => {
882
+ processAllFormElements(el, (input, key) => {
883
+ if (!key) return;
884
+ if (input instanceof HTMLInputElement) {
885
+ if (input.type === "checkbox") {
886
+ if (input.checked) {
887
+ const value = mapCheckboxValue(input.value);
888
+ if (typeof formFields[key] !== "undefined") {
889
+ formFields[key] = [formFields[key], value];
890
+ } else if (Array.isArray(formFields[key])) {
891
+ formFields[key].push(value);
892
+ } else {
893
+ formFields[key] = value;
894
+ }
895
+ }
896
+ } else if (input.type === "radio") {
897
+ if (input.checked) {
898
+ formFields[key] = input.value === "on" ? true : input.value;
899
+ }
900
+ } else if (input.type === "file") {
901
+ if (input.files?.length) {
902
+ const fileNames = Array.from(input.files).map((file) => file.name);
903
+ formFields[key] = fileNames.length === 1 ? fileNames[0] : fileNames;
904
+ }
905
+ } else {
906
+ formFields[key] = input.value;
907
+ }
908
+ } else if (input instanceof HTMLSelectElement) {
909
+ if (input.multiple) {
910
+ const values = Array.from(input.selectedOptions).map(
911
+ (option) => option.value
912
+ );
913
+ formFields[key] = values.length === 1 ? values[0] : values;
914
+ } else {
915
+ formFields[key] = input.value;
916
+ }
917
+ } else if (input instanceof HTMLTextAreaElement) {
918
+ formFields[key] = input.value;
919
+ }
920
+ });
921
+ });
922
+ return formFields;
923
+ }
924
+ function delayedAutoStart(chain) {
925
+ if (chain.options.autoStart) {
926
+ setTimeout(async () => {
927
+ if (chain.chainAsyncStartTime === 0) {
928
+ chain = await chain;
929
+ }
930
+ }, chain.options.autoStartDelay);
931
+ }
932
+ return chain;
933
+ }
934
+ function dequery(selectorRefOrEl, options = getDefaultDequeryOptions()) {
935
+ if (typeof selectorRefOrEl === "function") {
936
+ const syncChain = dequery("body", options);
937
+ queueMicrotask(async () => {
938
+ const result = await selectorRefOrEl();
939
+ if (!syncChain.isResolved) {
940
+ if (typeof result !== "undefined") {
941
+ const newChain = dequery(result, options);
942
+ syncChain.resultStack = newChain.resultStack;
943
+ syncChain.lastResult = newChain.lastResult;
944
+ mapArrayIndexAccess(newChain, syncChain);
945
+ }
946
+ }
947
+ });
948
+ return delayedAutoStart(syncChain);
949
+ }
950
+ const chain = new CallChainImplThenable({
951
+ ...options,
952
+ resultStack: []
953
+ });
954
+ if (!selectorRefOrEl)
955
+ throw new Error("dequery: selector/ref/element required");
956
+ if (typeof selectorRefOrEl === "string") {
957
+ if (selectorRefOrEl.indexOf("<") === 0) {
958
+ const elements = renderMarkup(selectorRefOrEl, chain.Parser);
959
+ const renderRootEl = elements[0];
960
+ const { text, html, ...attributes } = chain.elementCreationOptions;
961
+ if (renderRootEl instanceof Element) {
962
+ Object.entries(attributes).forEach(([key, value]) => {
963
+ renderRootEl.setAttribute(key, String(value));
964
+ });
965
+ if (html) {
966
+ renderRootEl.innerHTML = html;
967
+ } else if (text) {
968
+ renderRootEl.textContent = text;
969
+ }
970
+ }
971
+ chain.resultStack = [elements];
972
+ return delayedAutoStart(chain);
973
+ } else {
974
+ return delayedAutoStart(
975
+ chain.query(selectorRefOrEl)
976
+ );
977
+ }
978
+ } else if (isRef(selectorRefOrEl)) {
979
+ return delayedAutoStart(
980
+ chain.ref(selectorRefOrEl)
981
+ );
982
+ } else if (selectorRefOrEl.nodeType) {
983
+ chain.resultStack = [[selectorRefOrEl]];
984
+ return delayedAutoStart(chain);
985
+ } else if (isJSX(selectorRefOrEl)) {
986
+ const renderResult = renderIsomorphicSync(
987
+ selectorRefOrEl,
988
+ chain.document.body,
989
+ chain.globals
990
+ );
991
+ const elements = typeof renderResult !== "undefined" ? Array.isArray(renderResult) ? renderResult : [renderResult] : [];
992
+ chain.resultStack = [elements];
993
+ return delayedAutoStart(chain);
994
+ }
995
+ throw new Error("Unsupported selectorOrEl type");
996
+ }
997
+ dequery.extend = (ExtensionClass, nonChainedReturnCalls = []) => {
998
+ const extensionPrototype = ExtensionClass.prototype;
999
+ const basePrototype = CallChainImpl.prototype;
1000
+ const extensionMethods = Object.getOwnPropertyNames(extensionPrototype);
1001
+ const baseMethods = Object.getOwnPropertyNames(basePrototype);
1002
+ extensionMethods.forEach((methodName) => {
1003
+ if (methodName !== "constructor" && !baseMethods.includes(methodName) && typeof extensionPrototype[methodName] === "function") {
1004
+ CallChainImpl.prototype[methodName] = extensionPrototype[methodName];
1005
+ CallChainImplThenable.prototype[methodName] = extensionPrototype[methodName];
1006
+ }
1007
+ });
1008
+ if (nonChainedReturnCalls.length > 0) {
1009
+ addNonChainedReturnCallNames(nonChainedReturnCalls);
1010
+ }
1011
+ return (selectorRefOrEl, options) => {
1012
+ return dequery(
1013
+ selectorRefOrEl,
1014
+ options
1015
+ );
1016
+ };
1017
+ };
1018
+ const $ = dequery;
1019
+ function isDequery(obj) {
1020
+ return typeof obj === "object" && obj !== null && "isResolved" in obj && "lastResult" in obj && "resultStack" in obj && "callStack" in obj && "stackPointer" in obj;
1021
+ }
1022
+ function isDequeryOptionsObject(o) {
1023
+ return o && typeof o === "object" && o.timeout !== void 0 && o.globals !== void 0;
1024
+ }
1025
+ let defaultOptions = null;
1026
+ function getDefaultDequeryOptions() {
1027
+ if (!defaultOptions) {
1028
+ defaultOptions = {
1029
+ timeout: 5e3,
1030
+ // even long sync chains would execute in < .1ms
1031
+ // so after 1ms, we can assume the "await" in front is
1032
+ // missing (intentionally non-blocking in sync code)
1033
+ autoStartDelay: 1,
1034
+ autoStart: true,
1035
+ resultStack: [],
1036
+ globals: {
1037
+ document: globalThis.document,
1038
+ window: globalThis.window,
1039
+ performance: globalThis.performance
1040
+ }
1041
+ };
1042
+ }
1043
+ return { ...defaultOptions };
1044
+ }
1045
+ function mapArrayIndexAccess(source, target) {
1046
+ const elements = source.nodes;
1047
+ for (let i = 0; i < elements.length; i++) {
1048
+ target[i] = elements[i];
1049
+ }
1050
+ target.length = elements.length;
1051
+ }
1052
+ function createCall(chain, methodName, handler, ...callArgs) {
1053
+ chain.callStack.push(new Call(methodName, handler, ...callArgs));
1054
+ return subChainForNextAwait(chain);
1055
+ }
1056
+ function createGetterSetterCall(chain, methodName, value, getter, setter) {
1057
+ if (value !== void 0) {
1058
+ return createCall(chain, methodName, async () => {
1059
+ setter(value);
1060
+ return chain.nodes;
1061
+ });
1062
+ } else {
1063
+ return createCall(chain, methodName, async () => {
1064
+ return getter();
1065
+ });
1066
+ }
1067
+ }
1068
+ function createSubChain(source, Constructor = CallChainImpl, isResolved = false) {
1069
+ const subChain = new Constructor(source.options);
1070
+ subChain.callStack = source.callStack;
1071
+ subChain.resultStack = source.resultStack;
1072
+ subChain.stackPointer = source.stackPointer;
1073
+ subChain.stoppedWithError = source.stoppedWithError;
1074
+ subChain.lastResult = source.lastResult;
1075
+ subChain.isResolved = typeof isResolved !== "undefined" ? isResolved : source.isResolved;
1076
+ subChain.lastResolvedStackPointer = source.lastResolvedStackPointer;
1077
+ if (Array.isArray(subChain.lastResult)) {
1078
+ mapArrayIndexAccess(source, subChain);
1079
+ }
1080
+ return delayedAutoStart(subChain);
1081
+ }
1082
+ function subChainForNextAwait(source) {
1083
+ if (source.lastResolvedStackPointer) {
1084
+ source.callStack = source.callStack.slice(source.lastResolvedStackPointer);
1085
+ source.stackPointer = source.stackPointer - source.lastResolvedStackPointer;
1086
+ source.resultStack = source.resultStack.slice(
1087
+ source.lastResolvedStackPointer
1088
+ );
1089
+ source.lastResult = source.resultStack[source.resultStack.length - 1] || [];
1090
+ source.lastResolvedStackPointer = 0;
1091
+ source.stoppedWithError = null;
1092
+ }
1093
+ return source instanceof CallChainImplThenable ? source : createSubChain(source, CallChainImplThenable);
1094
+ }
1095
+ function runWithTimeGuard(timeout, fn, args, onError) {
1096
+ const operationId = Math.random().toString(36).substr(2, 9);
1097
+ return defussRuntime.createTimeoutPromise(
1098
+ timeout,
1099
+ async () => {
1100
+ const chainContext = args[0];
1101
+ if (chainContext?.callStack && chainContext.stackPointer !== void 0) {
1102
+ chainContext.callStack.slice(chainContext.stackPointer).map((call) => call.name).join(" -> ");
1103
+ }
1104
+ const result = await fn(...args);
1105
+ return result;
1106
+ },
1107
+ (ms) => {
1108
+ console.log(`\u{1F534} TIMEOUT [${operationId}] after ${ms}ms`);
1109
+ const chainContext = args[0];
1110
+ if (chainContext?.callStack && chainContext.stackPointer !== void 0) {
1111
+ const currentCall = chainContext.callStack[chainContext.stackPointer];
1112
+ const remainingCalls = chainContext.callStack.slice(chainContext.stackPointer).map((call) => `${call.name}(${call.args.join(", ")})`).join(" -> ");
1113
+ console.log(
1114
+ `\u{1F534} TIMEOUT occurred during call: ${currentCall?.name || "unknown"}`
1115
+ );
1116
+ console.log(`\u{1F534} Remaining calls were: ${remainingCalls}`);
1117
+ } else {
1118
+ console.log("\u{1F534} Call stack at timeout: unknown");
1119
+ }
1120
+ const fakeCall = new Call("timeout", async () => []);
1121
+ onError(ms, fakeCall);
1122
+ }
1123
+ );
1124
+ }
1125
+ async function renderNode(input, chain) {
1126
+ if (input == null) {
1127
+ return null;
1128
+ }
1129
+ if (typeof input === "string") {
1130
+ if (isMarkup(input, chain.Parser)) {
1131
+ return renderMarkup(input, chain.Parser)[0];
1132
+ } else {
1133
+ return chain.document.createTextNode(input);
1134
+ }
1135
+ } else if (isJSX(input)) {
1136
+ return renderIsomorphicSync(
1137
+ input,
1138
+ chain.document.body,
1139
+ chain.options.globals
1140
+ );
1141
+ } else if (isRef(input)) {
1142
+ await defussRuntime.waitForRef(input, chain.options.timeout);
1143
+ return input.current;
1144
+ } else if (input && typeof input === "object" && "nodeType" in input) {
1145
+ return input;
1146
+ } else if (isDequery(input)) {
1147
+ return await input.getFirstElement();
1148
+ }
1149
+ console.warn("resolveContent: unsupported content type", input);
1150
+ return null;
1151
+ }
1152
+ async function resolveNodes(input, timeout, document) {
1153
+ let nodes = [];
1154
+ if (isRef(input)) {
1155
+ await defussRuntime.waitForRef(input, timeout);
1156
+ nodes = [input.current];
1157
+ } else if (typeof input === "string" && document) {
1158
+ const result = await waitForDOM(
1159
+ () => {
1160
+ const el2 = document.querySelector(input);
1161
+ if (el2) {
1162
+ return [el2];
1163
+ } else {
1164
+ return [];
1165
+ }
1166
+ },
1167
+ timeout,
1168
+ document
1169
+ );
1170
+ const el = result[0];
1171
+ if (el) nodes = [el];
1172
+ } else if (input && typeof input === "object" && "nodeType" in input) {
1173
+ nodes = [input];
1174
+ } else if (isDequery(input)) {
1175
+ const elements = input.nodes;
1176
+ nodes = elements.filter((el) => el.nodeType !== void 0).map((el) => el);
1177
+ } else {
1178
+ console.warn("resolveTargets: expected selector, ref or node, got", input);
1179
+ }
1180
+ return nodes;
1181
+ }
1182
+ function traverse(chain, methodName, selector) {
1183
+ return createCall(chain, methodName, async () => {
1184
+ return chain.nodes.flatMap((el) => {
1185
+ if (el instanceof Element) {
1186
+ try {
1187
+ const result = selector(el);
1188
+ if (Array.isArray(result)) {
1189
+ return result.filter(
1190
+ (item) => item instanceof Element
1191
+ );
1192
+ } else if (result instanceof Element) {
1193
+ return [result];
1194
+ }
1195
+ } catch (err) {
1196
+ console.warn("Error in traverse selector function:", err);
1197
+ }
1198
+ }
1199
+ return [];
1200
+ });
1201
+ });
1202
+ }
1203
+
1204
+ const newInMemoryGenericStorageBackend = () => {
1205
+ const cache = /* @__PURE__ */ new Map();
1206
+ return {
1207
+ clear: () => {
1208
+ cache.clear();
1209
+ },
1210
+ getItem: (key) => {
1211
+ return cache.get(String(key)) ?? null;
1212
+ },
1213
+ removeItem: (key) => {
1214
+ cache.delete(String(key));
1215
+ },
1216
+ setItem: (key, value) => {
1217
+ cache.set(String(key), value);
1218
+ }
1219
+ };
1220
+ };
1221
+ const memory = newInMemoryGenericStorageBackend();
1222
+ class WebStorageProvider {
1223
+ storage;
1224
+ constructor(storage) {
1225
+ this.storage = storage || memory;
1226
+ }
1227
+ get(key, defaultValue, middlewareFn) {
1228
+ const rawValue = this.storage.getItem(key);
1229
+ if (rawValue === null) return defaultValue;
1230
+ let value = JSON.parse(rawValue);
1231
+ if (middlewareFn) {
1232
+ value = middlewareFn(key, value);
1233
+ }
1234
+ return value;
1235
+ }
1236
+ set(key, value, middlewareFn) {
1237
+ if (middlewareFn) {
1238
+ value = middlewareFn(key, value);
1239
+ }
1240
+ this.storage.setItem(key, JSON.stringify(value));
1241
+ }
1242
+ remove(key) {
1243
+ this.storage.removeItem(key);
1244
+ }
1245
+ removeAll() {
1246
+ this.storage.clear();
1247
+ }
1248
+ get backendApi() {
1249
+ return this.storage;
1250
+ }
1251
+ }
1252
+
1253
+ const getPersistenceProvider$1 = (provider, _options) => {
1254
+ switch (provider) {
1255
+ case "session":
1256
+ return new WebStorageProvider(window.sessionStorage);
1257
+ case "local":
1258
+ return new WebStorageProvider(window.localStorage);
1259
+ }
1260
+ return new WebStorageProvider();
1261
+ };
1262
+
1263
+ const getPersistenceProvider = (_provider, _options) => {
1264
+ return new WebStorageProvider();
1265
+ };
1266
+
1267
+ const isServer = () => typeof window === "undefined" || typeof window.document === "undefined";
1268
+
1269
+ const webstorage = (provider = "local", options) => {
1270
+ if (isServer()) {
1271
+ return getPersistenceProvider();
1272
+ } else {
1273
+ return getPersistenceProvider$1(provider);
1274
+ }
1275
+ };
1276
+
1277
+ const createStore = (initialValue) => {
1278
+ let value = initialValue;
1279
+ const listeners = [];
1280
+ const notify = (oldValue, changedKey) => {
1281
+ listeners.forEach((listener) => listener(value, oldValue, changedKey));
1282
+ };
1283
+ let storage = null;
1284
+ let storageKey = null;
1285
+ let storageProvider;
1286
+ const initStorage = (provider) => {
1287
+ if (!storage || storageProvider !== provider) {
1288
+ storage = webstorage(provider);
1289
+ storageProvider = provider;
1290
+ }
1291
+ return storage;
1292
+ };
1293
+ const persistToStorage = () => {
1294
+ if (storage && storageKey) {
1295
+ storage.set(storageKey, value);
1296
+ }
1297
+ };
1298
+ return {
1299
+ // allow reading value but prevent external mutation
1300
+ get value() {
1301
+ return value;
1302
+ },
1303
+ persist(key, provider = "local") {
1304
+ storage = initStorage(provider);
1305
+ storageKey = key;
1306
+ persistToStorage();
1307
+ },
1308
+ restore(key, provider = "local") {
1309
+ storage = initStorage(provider);
1310
+ storageKey = key;
1311
+ const storedValue = storage.get(key, value);
1312
+ const valueAsString = JSON.stringify(value);
1313
+ const storedValueAsString = JSON.stringify(storedValue);
1314
+ if (valueAsString !== storedValueAsString) {
1315
+ value = storedValue;
1316
+ notify(value);
1317
+ }
1318
+ },
1319
+ get(path) {
1320
+ return path ? defussRuntime.getByPath(value, path) : value;
1321
+ },
1322
+ set(pathOrValue, newValue) {
1323
+ const oldValue = value;
1324
+ if (newValue === void 0) {
1325
+ const valueAsString = JSON.stringify(value);
1326
+ const newValueAsString = JSON.stringify(pathOrValue);
1327
+ if (valueAsString !== newValueAsString) {
1328
+ value = pathOrValue;
1329
+ notify(oldValue);
1330
+ persistToStorage();
1331
+ }
1332
+ } else {
1333
+ const updatedValue = defussRuntime.setByPath(value, pathOrValue, newValue);
1334
+ const updatedValueAsString = JSON.stringify(updatedValue);
1335
+ const oldValueAsString = JSON.stringify(oldValue);
1336
+ if (oldValueAsString !== updatedValueAsString) {
1337
+ value = updatedValue;
1338
+ notify(oldValue, pathOrValue);
1339
+ persistToStorage();
1340
+ }
1341
+ }
1342
+ },
1343
+ subscribe(listener) {
1344
+ listeners.push(listener);
1345
+ return () => {
1346
+ const index = listeners.indexOf(listener);
1347
+ if (index >= 0) listeners.splice(index, 1);
1348
+ };
1349
+ }
1350
+ };
1351
+ };
1352
+
1353
+ const isRef = (obj) => Boolean(obj && typeof obj === "object" && "current" in obj);
1354
+ function createRef(refUpdateFn, defaultState) {
1355
+ const stateStore = createStore(defaultState);
1356
+ const ref = {
1357
+ current: null,
1358
+ store: stateStore,
1359
+ get state() {
1360
+ return stateStore.value;
1361
+ },
1362
+ set state(value) {
1363
+ stateStore.set(value);
1364
+ },
1365
+ persist: (key, provider = "local") => {
1366
+ stateStore.persist(key, provider);
1367
+ },
1368
+ restore: (key, provider = "local") => {
1369
+ stateStore.restore(key, provider);
1370
+ },
1371
+ updateState: (state) => {
1372
+ stateStore.set(state);
1373
+ },
1374
+ update: async (input) => await $(ref.current).update(input),
1375
+ subscribe: (refUpdateFn2) => stateStore.subscribe(refUpdateFn2)
1376
+ };
1377
+ if (typeof refUpdateFn === "function") {
1378
+ ref.subscribe(refUpdateFn);
1379
+ }
1380
+ return ref;
1381
+ }
1382
+
1383
+ const injectShakeKeyframes = () => {
1384
+ if (!document.getElementById("defuss-shake")) {
1385
+ const style = document.createElement("style");
1386
+ style.id = "defuss-shake";
1387
+ style.textContent = "@keyframes shake{0%,100%{transform:translate3d(0,0,0)}10%,30%,50%,70%,90%{transform:translate3d(-10px,0,0)}20%,40%,60%,80%{transform:translate3d(10px,0,0)}}";
1388
+ document.head.appendChild(style);
1389
+ }
1390
+ };
1391
+ const getTransitionStyles = (type, duration, easing = "ease-in-out") => {
1392
+ const t = `transform ${duration}ms ${easing}, opacity ${duration}ms ${easing}`;
1393
+ const styles = {
1394
+ fade: {
1395
+ enter: { opacity: "0", transition: t, transform: "translate3d(0,0,0)" },
1396
+ enterActive: { opacity: "1" },
1397
+ exit: { opacity: "1", transition: t, transform: "translate3d(0,0,0)" },
1398
+ exitActive: { opacity: "0" }
1399
+ },
1400
+ "slide-left": {
1401
+ enter: {
1402
+ transform: "translate3d(100%,0,0)",
1403
+ opacity: "0.5",
1404
+ transition: t
1405
+ },
1406
+ enterActive: { transform: "translate3d(0,0,0)", opacity: "1" },
1407
+ exit: { transform: "translate3d(0,0,0)", opacity: "1", transition: t },
1408
+ exitActive: { transform: "translate3d(-100%,0,0)", opacity: "0.5" }
1409
+ },
1410
+ "slide-right": {
1411
+ enter: {
1412
+ transform: "translate3d(-100%,0,0)",
1413
+ opacity: "0.5",
1414
+ transition: t
1415
+ },
1416
+ enterActive: { transform: "translate3d(0,0,0)", opacity: "1" },
1417
+ exit: { transform: "translate3d(0,0,0)", opacity: "1", transition: t },
1418
+ exitActive: { transform: "translate3d(100%,0,0)", opacity: "0.5" }
1419
+ },
1420
+ shake: (() => {
1421
+ injectShakeKeyframes();
1422
+ return {
1423
+ enter: {
1424
+ transform: "translate3d(0,0,0)",
1425
+ opacity: "1",
1426
+ transition: "none"
1427
+ },
1428
+ enterActive: {
1429
+ transform: "translate3d(0,0,0)",
1430
+ opacity: "1",
1431
+ animation: `shake ${duration}ms cubic-bezier(0.36,0.07,0.19,0.97)`
1432
+ },
1433
+ exit: {
1434
+ transform: "translate3d(0,0,0)",
1435
+ opacity: "1",
1436
+ transition: "none"
1437
+ },
1438
+ exitActive: {
1439
+ transform: "translate3d(0,0,0)",
1440
+ opacity: "1",
1441
+ animation: `shake ${duration}ms cubic-bezier(0.36,0.07,0.19,0.97)`
1442
+ }
1443
+ };
1444
+ })()
1445
+ };
1446
+ return styles[type] || { enter: {}, enterActive: {}, exit: {}, exitActive: {} };
1447
+ };
1448
+ const applyStyles = (el, styles) => Object.entries(styles).forEach(
1449
+ ([k, v]) => el.style.setProperty(k, String(v))
1450
+ );
1451
+ const DEFAULT_TRANSITION_CONFIG = {
1452
+ type: "fade",
1453
+ duration: 300,
1454
+ easing: "ease-in-out",
1455
+ delay: 0,
1456
+ target: "parent"
1457
+ };
1458
+ const wait = (ms) => new Promise((r) => setTimeout(r, ms));
1459
+ const performCrossfade = async (element, updateCallback, duration, easing) => {
1460
+ const originalStyle = element.style.cssText;
1461
+ const snapshot = element.cloneNode(true);
1462
+ try {
1463
+ const container = element.parentElement || element;
1464
+ const rect = element.getBoundingClientRect();
1465
+ snapshot.style.cssText = `position:absolute;top:${rect.top}px;left:${rect.left}px;width:${rect.width}px;height:${rect.height}px;opacity:1;transition:opacity ${duration}ms ${easing};z-index:1000;`;
1466
+ element.style.opacity = "0";
1467
+ element.style.transition = `opacity ${duration}ms ${easing}`;
1468
+ document.body.appendChild(snapshot);
1469
+ await updateCallback();
1470
+ void element.offsetHeight;
1471
+ snapshot.style.opacity = "0";
1472
+ element.style.opacity = "1";
1473
+ await wait(duration);
1474
+ document.body.removeChild(snapshot);
1475
+ } catch (error) {
1476
+ if (snapshot.parentElement) document.body.removeChild(snapshot);
1477
+ throw error;
1478
+ } finally {
1479
+ element.style.cssText = originalStyle;
1480
+ }
1481
+ };
1482
+ const performTransition = async (element, updateCallback, config = {}) => {
1483
+ const {
1484
+ type = "fade",
1485
+ duration = 300,
1486
+ easing = "ease-in-out",
1487
+ delay = 0
1488
+ } = { ...DEFAULT_TRANSITION_CONFIG, ...config };
1489
+ if (type === "none") {
1490
+ await updateCallback();
1491
+ return;
1492
+ }
1493
+ if (delay > 0) await wait(delay);
1494
+ if (type === "fade") {
1495
+ await performCrossfade(element, updateCallback, duration, easing);
1496
+ return;
1497
+ }
1498
+ const styles = config.styles || getTransitionStyles(type, duration, easing);
1499
+ const originalTransition = element.style.transition;
1500
+ const originalAnimation = element.style.animation;
1501
+ try {
1502
+ if (type === "shake") {
1503
+ element.style.animation = "none";
1504
+ void element.offsetHeight;
1505
+ }
1506
+ applyStyles(element, styles.exit);
1507
+ void element.offsetHeight;
1508
+ applyStyles(element, styles.exitActive);
1509
+ await wait(duration);
1510
+ await updateCallback();
1511
+ applyStyles(element, styles.enter);
1512
+ void element.offsetHeight;
1513
+ applyStyles(element, styles.enterActive);
1514
+ await wait(duration);
1515
+ element.style.transition = originalTransition;
1516
+ element.style.animation = originalAnimation;
1517
+ } catch (error) {
1518
+ element.style.transition = originalTransition;
1519
+ element.style.animation = originalAnimation;
1520
+ throw error;
1521
+ }
1522
+ };
1523
+
1524
+ const CAPTURE_ONLY_EVENTS = /* @__PURE__ */ new Set([
1525
+ "focus",
1526
+ "blur",
1527
+ "scroll",
1528
+ "mouseenter",
1529
+ "mouseleave",
1530
+ "focusin",
1531
+ "focusout"
1532
+ ]);
1533
+ const elementHandlerMap = /* @__PURE__ */ new WeakMap();
1534
+ const installedDocListeners = /* @__PURE__ */ new WeakMap();
1535
+ const parseEventPropName = (propName) => {
1536
+ if (!propName.startsWith("on")) return null;
1537
+ const raw = propName.slice(2);
1538
+ if (!raw) return null;
1539
+ const lower = raw.toLowerCase();
1540
+ const isCapture = lower.endsWith("capture");
1541
+ const eventType = isCapture ? lower.slice(0, -"capture".length) : lower;
1542
+ if (!eventType) return null;
1543
+ return { eventType, capture: isCapture };
1544
+ };
1545
+ const getOrCreateElementHandlers = (el) => {
1546
+ const existing = elementHandlerMap.get(el);
1547
+ if (existing) return existing;
1548
+ const created = /* @__PURE__ */ new Map();
1549
+ elementHandlerMap.set(el, created);
1550
+ return created;
1551
+ };
1552
+ const getEventPath = (event) => {
1553
+ const composedPath = event.composedPath?.();
1554
+ if (composedPath && composedPath.length > 0) return composedPath;
1555
+ const path = [];
1556
+ let node = event.target;
1557
+ while (node) {
1558
+ path.push(node);
1559
+ const maybeNode = node;
1560
+ if (typeof maybeNode === "object" && maybeNode && "parentNode" in maybeNode) {
1561
+ node = maybeNode.parentNode;
1562
+ continue;
1563
+ }
1564
+ break;
1565
+ }
1566
+ const doc = event.target?.ownerDocument;
1567
+ if (doc && path[path.length - 1] !== doc) path.push(doc);
1568
+ const win = doc?.defaultView;
1569
+ if (win && path[path.length - 1] !== win) path.push(win);
1570
+ return path;
1571
+ };
1572
+ const ensureDocumentListener = (doc, eventType, phase) => {
1573
+ const installed = installedDocListeners.get(doc) ?? /* @__PURE__ */ new Set();
1574
+ installedDocListeners.set(doc, installed);
1575
+ const key = `${eventType}:${phase}`;
1576
+ if (installed.has(key)) return;
1577
+ const useCapture = phase === "capture";
1578
+ const handler = (event) => {
1579
+ const path = getEventPath(event).filter(
1580
+ (t) => typeof t === "object" && t !== null && t.nodeType === Node.ELEMENT_NODE
1581
+ );
1582
+ const ordered = phase === "capture" ? [...path].reverse() : path;
1583
+ for (const target of ordered) {
1584
+ const handlersByEvent = elementHandlerMap.get(target);
1585
+ if (!handlersByEvent) continue;
1586
+ const entry = handlersByEvent.get(eventType);
1587
+ if (!entry) continue;
1588
+ const fn = phase === "capture" ? entry.capture : entry.bubble;
1589
+ if (!fn) continue;
1590
+ fn.call(target, event);
1591
+ if (event.cancelBubble) return;
1592
+ }
1593
+ };
1594
+ doc.addEventListener(eventType, handler, useCapture);
1595
+ installed.add(key);
1596
+ };
1597
+ const registerDelegatedEvent = (element, eventType, handler, options = {}) => {
1598
+ const doc = element.ownerDocument ?? globalThis.document;
1599
+ const capture = options.capture || CAPTURE_ONLY_EVENTS.has(eventType);
1600
+ ensureDocumentListener(doc, eventType, capture ? "capture" : "bubble");
1601
+ const byEvent = getOrCreateElementHandlers(element);
1602
+ const entry = byEvent.get(eventType) ?? {};
1603
+ byEvent.set(eventType, entry);
1604
+ if (capture) {
1605
+ entry.capture = handler;
1606
+ } else {
1607
+ entry.bubble = handler;
1608
+ }
1609
+ };
1610
+ const removeDelegatedEvent = (element, eventType, options = {}) => {
1611
+ const capture = options.capture || CAPTURE_ONLY_EVENTS.has(eventType);
1612
+ const byEvent = elementHandlerMap.get(element);
1613
+ if (!byEvent) return;
1614
+ const entry = byEvent.get(eventType);
1615
+ if (!entry) return;
1616
+ if (capture) {
1617
+ entry.capture = void 0;
1618
+ } else {
1619
+ entry.bubble = void 0;
1620
+ }
1621
+ if (!entry.capture && !entry.bubble) {
1622
+ byEvent.delete(eventType);
1623
+ }
1624
+ };
1625
+ const clearDelegatedEvents = (element) => {
1626
+ const byEvent = elementHandlerMap.get(element);
1627
+ if (!byEvent) return;
1628
+ byEvent.clear();
1629
+ };
1630
+
1631
+ const queueCallback = (cb) => () => queueMicrotask(cb);
1632
+
1633
+ const CLASS_ATTRIBUTE_NAME = "class";
1634
+ const XLINK_ATTRIBUTE_NAME = "xlink";
1635
+ const XMLNS_ATTRIBUTE_NAME = "xmlns";
1636
+ const REF_ATTRIBUTE_NAME = "ref";
1637
+ const DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE = "dangerouslySetInnerHTML";
1638
+ const nsMap = {
1639
+ [XMLNS_ATTRIBUTE_NAME]: "http://www.w3.org/2000/xmlns/",
1640
+ [XLINK_ATTRIBUTE_NAME]: "http://www.w3.org/1999/xlink",
1641
+ svg: "http://www.w3.org/2000/svg"
1642
+ };
1643
+ const isJSXComment = (node) => (
1644
+ /* v8 ignore next */
1645
+ node && typeof node === "object" && !node.attributes && !node.type && !node.children
1646
+ );
1647
+ const filterComments = (children) => children.filter((child) => !isJSXComment(child));
1648
+ const createInPlaceErrorMessageVNode = (error) => ({
1649
+ type: "p",
1650
+ attributes: {},
1651
+ children: [`FATAL ERROR: ${error?.message || error}`]
1652
+ });
1653
+ const jsx = (type, attributes, key, sourceInfo) => {
1654
+ attributes = { ...attributes };
1655
+ if (typeof key !== "undefined") {
1656
+ attributes.key = key;
1657
+ }
1658
+ let children = (attributes?.children ? [].concat(attributes.children) : []).filter(Boolean);
1659
+ delete attributes?.children;
1660
+ children = filterComments(
1661
+ // Implementation to flatten virtual node children structures like:
1662
+ // [<p>1</p>, [<p>2</p>,<p>3</p>]] to: [<p>1</p>,<p>2</p>,<p>3</p>]
1663
+ [].concat.apply(
1664
+ [],
1665
+ children
1666
+ )
1667
+ );
1668
+ if (type === "fragment") {
1669
+ return filterComments(children);
1670
+ }
1671
+ if (typeof type === "function" && type.constructor.name !== "AsyncFunction") {
1672
+ try {
1673
+ return type({
1674
+ children,
1675
+ ...attributes
1676
+ });
1677
+ } catch (error) {
1678
+ if (typeof error === "string") {
1679
+ error = `[JsxError] in ${type.name}: ${error}`;
1680
+ } else if (error instanceof Error) {
1681
+ error.message = `[JsxError] in ${type.name}: ${error.message}`;
1682
+ }
1683
+ return createInPlaceErrorMessageVNode(error);
1684
+ }
1685
+ }
1686
+ return {
1687
+ type,
1688
+ attributes,
1689
+ children,
1690
+ sourceInfo
1691
+ };
1692
+ };
1693
+ const observeUnmount = (domNode, onUnmount) => {
1694
+ if (!domNode || typeof onUnmount !== "function") {
1695
+ throw new Error(
1696
+ "Invalid arguments. Ensure domNode and onUnmount are valid."
1697
+ );
1698
+ }
1699
+ const parentNode = domNode.parentNode;
1700
+ if (!parentNode) {
1701
+ throw new Error("The provided domNode does not have a parentNode.");
1702
+ }
1703
+ const observer = new MutationObserver((mutationsList) => {
1704
+ for (const mutation of mutationsList) {
1705
+ if (mutation.removedNodes.length > 0) {
1706
+ for (const removedNode of mutation.removedNodes) {
1707
+ if (removedNode === domNode) {
1708
+ onUnmount();
1709
+ observer.disconnect();
1710
+ return;
1711
+ }
1712
+ }
1713
+ }
1714
+ }
1715
+ });
1716
+ observer.observe(parentNode, { childList: true });
1717
+ };
1718
+ const handleLifecycleEventsForOnMount = (newEl) => {
1719
+ if (typeof newEl?.$onMount === "function") {
1720
+ newEl.$onMount();
1721
+ newEl.$onMount = null;
1722
+ }
1723
+ if (typeof newEl?.$onUnmount === "function") {
1724
+ observeUnmount(newEl, newEl.$onUnmount);
1725
+ }
1726
+ };
1727
+ const getRenderer = (document) => {
1728
+ const renderer = {
1729
+ hasElNamespace: (domElement) => domElement.namespaceURI === nsMap.svg,
1730
+ hasSvgNamespace: (parentElement, type) => renderer.hasElNamespace(parentElement) && type !== "STYLE" && type !== "SCRIPT",
1731
+ createElementOrElements: (virtualNode, parentDomElement) => {
1732
+ if (Array.isArray(virtualNode)) {
1733
+ return renderer.createChildElements(virtualNode, parentDomElement);
1734
+ }
1735
+ if (typeof virtualNode !== "undefined") {
1736
+ return renderer.createElement(virtualNode, parentDomElement);
1737
+ }
1738
+ return renderer.createTextNode("", parentDomElement);
1739
+ },
1740
+ createElement: (virtualNode, parentDomElement) => {
1741
+ let newEl = void 0;
1742
+ try {
1743
+ if (virtualNode.constructor.name === "AsyncFunction") {
1744
+ newEl = document.createElement("div");
1745
+ } else if (typeof virtualNode.type === "function") {
1746
+ newEl = document.createElement("div");
1747
+ newEl.innerText = `FATAL ERROR: ${virtualNode.type._error}`;
1748
+ } else if (
1749
+ // SVG support
1750
+ virtualNode.type.toUpperCase() === "SVG" || parentDomElement && renderer.hasSvgNamespace(
1751
+ parentDomElement,
1752
+ virtualNode.type.toUpperCase()
1753
+ )
1754
+ ) {
1755
+ newEl = document.createElementNS(
1756
+ nsMap.svg,
1757
+ virtualNode.type
1758
+ );
1759
+ } else {
1760
+ newEl = document.createElement(virtualNode.type);
1761
+ }
1762
+ if (virtualNode.attributes) {
1763
+ renderer.setAttributes(virtualNode, newEl);
1764
+ if (virtualNode.attributes.dangerouslySetInnerHTML) {
1765
+ newEl.innerHTML = virtualNode.attributes.dangerouslySetInnerHTML.__html;
1766
+ }
1767
+ }
1768
+ if (virtualNode.children) {
1769
+ renderer.createChildElements(virtualNode.children, newEl);
1770
+ }
1771
+ if (parentDomElement) {
1772
+ parentDomElement.appendChild(newEl);
1773
+ handleLifecycleEventsForOnMount(newEl);
1774
+ }
1775
+ } catch (e) {
1776
+ console.error(
1777
+ "Fatal error! Error happend while rendering the VDOM!",
1778
+ e,
1779
+ virtualNode
1780
+ );
1781
+ throw e;
1782
+ }
1783
+ return newEl;
1784
+ },
1785
+ createTextNode: (text, domElement) => {
1786
+ const node = document.createTextNode(text.toString());
1787
+ if (domElement) {
1788
+ domElement.appendChild(node);
1789
+ }
1790
+ return node;
1791
+ },
1792
+ createChildElements: (virtualChildren, domElement) => {
1793
+ const children = [];
1794
+ for (let i = 0; i < virtualChildren.length; i++) {
1795
+ const virtualChild = virtualChildren[i];
1796
+ if (virtualChild === null || typeof virtualChild !== "object" && typeof virtualChild !== "function") {
1797
+ children.push(
1798
+ renderer.createTextNode(
1799
+ (typeof virtualChild === "undefined" || virtualChild === null ? "" : virtualChild).toString(),
1800
+ domElement
1801
+ )
1802
+ );
1803
+ } else {
1804
+ children.push(
1805
+ renderer.createElement(virtualChild, domElement)
1806
+ );
1807
+ }
1808
+ }
1809
+ return children;
1810
+ },
1811
+ setAttribute: (name, value, domElement, virtualNode) => {
1812
+ if (typeof value === "undefined") return;
1813
+ if (name === DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE) return;
1814
+ if (name === "key") {
1815
+ domElement._defussKey = String(value);
1816
+ return;
1817
+ }
1818
+ if (name === REF_ATTRIBUTE_NAME && typeof value !== "function") {
1819
+ const ref = value;
1820
+ ref.current = domElement;
1821
+ domElement._defussRef = value;
1822
+ domElement.$onUnmount = queueCallback(() => {
1823
+ });
1824
+ if (domElement.parentNode) {
1825
+ observeUnmount(domElement, domElement.$onUnmount);
1826
+ } else {
1827
+ queueMicrotask(() => {
1828
+ if (domElement.parentNode) {
1829
+ observeUnmount(domElement, domElement.$onUnmount);
1830
+ }
1831
+ });
1832
+ }
1833
+ return;
1834
+ }
1835
+ const parsed = parseEventPropName(name);
1836
+ if (parsed && typeof value === "function") {
1837
+ const { eventType, capture } = parsed;
1838
+ if (eventType === "mount") {
1839
+ domElement.$onMount = queueCallback(value);
1840
+ return;
1841
+ }
1842
+ if (eventType === "unmount") {
1843
+ if (domElement.$onUnmount) {
1844
+ const existingUnmount = domElement.$onUnmount;
1845
+ domElement.$onUnmount = () => {
1846
+ existingUnmount();
1847
+ value();
1848
+ };
1849
+ } else {
1850
+ domElement.$onUnmount = queueCallback(value);
1851
+ }
1852
+ return;
1853
+ }
1854
+ registerDelegatedEvent(domElement, eventType, value, { capture });
1855
+ return;
1856
+ }
1857
+ if (name === "className") {
1858
+ name = CLASS_ATTRIBUTE_NAME;
1859
+ }
1860
+ if (name === CLASS_ATTRIBUTE_NAME && Array.isArray(value)) {
1861
+ value = value.join(" ");
1862
+ }
1863
+ const nsEndIndex = name.match(/[A-Z]/)?.index;
1864
+ if (renderer.hasElNamespace(domElement) && nsEndIndex) {
1865
+ const ns = name.substring(0, nsEndIndex).toLowerCase();
1866
+ const attrName = name.substring(nsEndIndex, name.length).toLowerCase();
1867
+ const namespace = nsMap[ns] || null;
1868
+ domElement.setAttributeNS(
1869
+ namespace,
1870
+ ns === XLINK_ATTRIBUTE_NAME || ns === XMLNS_ATTRIBUTE_NAME ? `${ns}:${attrName}` : name,
1871
+ String(value)
1872
+ );
1873
+ } else if (name === "style" && typeof value !== "string") {
1874
+ const styleObj = value;
1875
+ for (const prop of Object.keys(styleObj)) {
1876
+ domElement.style[prop] = String(styleObj[prop]);
1877
+ }
1878
+ } else if (typeof value === "boolean") {
1879
+ domElement[name] = value;
1880
+ } else {
1881
+ domElement.setAttribute(name, String(value));
1882
+ }
1883
+ },
1884
+ setAttributes: (virtualNode, domElement) => {
1885
+ const attrNames = Object.keys(virtualNode.attributes);
1886
+ for (let i = 0; i < attrNames.length; i++) {
1887
+ renderer.setAttribute(
1888
+ attrNames[i],
1889
+ virtualNode.attributes[attrNames[i]],
1890
+ domElement,
1891
+ virtualNode
1892
+ );
1893
+ }
1894
+ }
1895
+ };
1896
+ return renderer;
1897
+ };
1898
+ const renderIsomorphicSync = (virtualNode, parentDomElement, globals) => {
1899
+ if (isDequery(parentDomElement)) {
1900
+ parentDomElement = parentDomElement.getFirstElement() || parentDomElement;
1901
+ }
1902
+ let renderResult;
1903
+ if (typeof virtualNode === "string") {
1904
+ renderResult = getRenderer(globals.window.document).createTextNode(
1905
+ virtualNode,
1906
+ parentDomElement
1907
+ );
1908
+ } else {
1909
+ renderResult = getRenderer(globals.window.document).createElementOrElements(
1910
+ virtualNode,
1911
+ parentDomElement
1912
+ );
1913
+ }
1914
+ return renderResult;
1915
+ };
1916
+ const renderIsomorphicAsync = async (virtualNode, parentDomElement, globals) => {
1917
+ if (parentDomElement instanceof Promise) {
1918
+ parentDomElement = await parentDomElement;
1919
+ }
1920
+ if (isDequery(parentDomElement)) {
1921
+ parentDomElement = (await parentDomElement.toArray())[0];
1922
+ }
1923
+ if (virtualNode instanceof Promise) {
1924
+ virtualNode = await virtualNode;
1925
+ }
1926
+ return renderIsomorphicSync(
1927
+ virtualNode,
1928
+ parentDomElement,
1929
+ globals
1930
+ );
1931
+ };
1932
+ const globalScopeDomApis = (window, document) => {
1933
+ globalThis.__defuss_document = document;
1934
+ globalThis.__defuss_window = window;
1935
+ };
1936
+ const isJSX = (o) => {
1937
+ if (o === null || typeof o !== "object") return false;
1938
+ if (Array.isArray(o)) return o.every(isJSX);
1939
+ if (typeof o.type === "string") return true;
1940
+ if (typeof o.type === "function") return true;
1941
+ if (typeof o.attributes === "object" && typeof o.children === "object")
1942
+ return true;
1943
+ return false;
1944
+ };
1945
+ const Fragment = (props) => props.children;
1946
+ const jsxs = jsx;
1947
+ const jsxDEV = (type, attributes, key, allChildrenAreStatic, sourceInfo, selfReference) => {
1948
+ let renderResult;
1949
+ try {
1950
+ if (sourceInfo) {
1951
+ if (typeof type === "function" && type.constructor.name !== "AsyncFunction") {
1952
+ sourceInfo.exportName = type.name || sourceInfo?.exportName;
1953
+ }
1954
+ sourceInfo.allChildrenAreStatic = allChildrenAreStatic;
1955
+ sourceInfo.selfReference = selfReference;
1956
+ }
1957
+ renderResult = jsx(type, attributes, key, sourceInfo);
1958
+ } catch (error) {
1959
+ console.error(
1960
+ "JSX error:",
1961
+ error,
1962
+ "in",
1963
+ sourceInfo,
1964
+ "component",
1965
+ selfReference
1966
+ );
1967
+ }
1968
+ return renderResult;
1969
+ };
1970
+ async function performCoreDomUpdate(input, nodes, timeout, Parser) {
1971
+ let processedInput = input;
1972
+ if (isDequery(processedInput)) {
1973
+ processedInput = processedInput[0];
1974
+ }
1975
+ if (isRef(processedInput)) {
1976
+ await defussRuntime.waitForRef(processedInput, timeout);
1977
+ processedInput = processedInput.current;
1978
+ }
1979
+ if (processedInput instanceof Node) {
1980
+ const vnode = domNodeToVNode(processedInput);
1981
+ nodes.forEach((el) => {
1982
+ if (el) {
1983
+ updateDomWithVdom(el, vnode, globalThis);
1984
+ }
1985
+ });
1986
+ return;
1987
+ }
1988
+ if (typeof processedInput === "string") {
1989
+ if (isMarkup(processedInput, Parser)) {
1990
+ const vNodes = htmlStringToVNodes(processedInput, Parser);
1991
+ nodes.forEach((el) => {
1992
+ if (el) {
1993
+ updateDomWithVdom(el, vNodes, globalThis);
1994
+ }
1995
+ });
1996
+ } else {
1997
+ nodes.forEach((el) => {
1998
+ if (el) {
1999
+ updateDomWithVdom(
2000
+ el,
2001
+ processedInput,
2002
+ globalThis
2003
+ );
2004
+ }
2005
+ });
2006
+ }
2007
+ } else if (isJSX(processedInput)) {
2008
+ nodes.forEach((el) => {
2009
+ if (el) {
2010
+ updateDomWithVdom(
2011
+ el,
2012
+ processedInput,
2013
+ globalThis
2014
+ );
2015
+ }
2016
+ });
2017
+ } else {
2018
+ console.warn("update: unsupported content type", processedInput);
2019
+ }
2020
+ }
2021
+ async function updateDom(input, nodes, timeout, Parser, transitionConfig) {
2022
+ if (transitionConfig && transitionConfig.type !== "none") {
2023
+ const config = { ...DEFAULT_TRANSITION_CONFIG, ...transitionConfig };
2024
+ const { target = "self" } = config;
2025
+ const transitionPromises = nodes.map(async (node) => {
2026
+ if (!node) return node;
2027
+ const element = node;
2028
+ const transitionTarget = target === "self" ? element : element.parentElement;
2029
+ if (!transitionTarget) {
2030
+ await performCoreDomUpdate(input, [node], timeout, Parser);
2031
+ return node;
2032
+ }
2033
+ await performTransition(
2034
+ transitionTarget,
2035
+ () => performCoreDomUpdate(input, [node], timeout, Parser),
2036
+ config
2037
+ );
2038
+ return node;
2039
+ });
2040
+ await Promise.all(transitionPromises);
2041
+ return nodes;
2042
+ }
2043
+ await performCoreDomUpdate(input, nodes, timeout, Parser);
2044
+ return nodes;
2045
+ }
2046
+
2047
+ const areDomNodesEqual = (oldNode, newNode) => {
2048
+ if (oldNode === newNode) return true;
2049
+ if (oldNode.nodeType !== newNode.nodeType) return false;
2050
+ if (oldNode.nodeType === Node.ELEMENT_NODE) {
2051
+ const oldElement = oldNode;
2052
+ const newElement = newNode;
2053
+ if (oldElement.tagName !== newElement.tagName) return false;
2054
+ const oldAttrs = oldElement.attributes;
2055
+ const newAttrs = newElement.attributes;
2056
+ if (oldAttrs.length !== newAttrs.length) return false;
2057
+ for (let i = 0; i < oldAttrs.length; i++) {
2058
+ const oldAttr = oldAttrs[i];
2059
+ const newAttrValue = newElement.getAttribute(oldAttr.name);
2060
+ if (oldAttr.value !== newAttrValue) return false;
2061
+ }
2062
+ }
2063
+ if (oldNode.nodeType === Node.TEXT_NODE) {
2064
+ if (oldNode.textContent !== newNode.textContent) return false;
2065
+ }
2066
+ return true;
2067
+ };
2068
+ function isTextLike(value) {
2069
+ return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
2070
+ }
2071
+ function isVNode(value) {
2072
+ return Boolean(value && typeof value === "object" && "type" in value);
2073
+ }
2074
+ function toValidChild(child) {
2075
+ if (child == null) return child;
2076
+ if (isTextLike(child)) return child;
2077
+ if (isVNode(child)) return child;
2078
+ return void 0;
2079
+ }
2080
+ function normalizeChildren(input) {
2081
+ const raw = [];
2082
+ const pushChild = (child) => {
2083
+ if (Array.isArray(child)) {
2084
+ child.forEach(pushChild);
2085
+ return;
2086
+ }
2087
+ const valid = toValidChild(child);
2088
+ if (typeof valid === "undefined") return;
2089
+ if (isVNode(valid) && (valid.type === "fragment" || valid.type === "Fragment")) {
2090
+ const nested = Array.isArray(valid.children) ? valid.children : [];
2091
+ nested.forEach(pushChild);
2092
+ return;
2093
+ }
2094
+ if (valid === null || typeof valid === "undefined" || typeof valid === "boolean") return;
2095
+ raw.push(valid);
2096
+ };
2097
+ pushChild(input);
2098
+ const fused = [];
2099
+ let buffer = null;
2100
+ const flush = () => {
2101
+ if (buffer !== null && buffer.length > 0) fused.push(buffer);
2102
+ buffer = null;
2103
+ };
2104
+ for (const child of raw) {
2105
+ if (typeof child === "string" || typeof child === "number" || typeof child === "boolean") {
2106
+ buffer = (buffer ?? "") + String(child);
2107
+ continue;
2108
+ }
2109
+ flush();
2110
+ fused.push(child);
2111
+ }
2112
+ flush();
2113
+ return fused;
2114
+ }
2115
+ function getVNodeMatchKey(child) {
2116
+ if (!child || typeof child !== "object") return null;
2117
+ const key = child.attributes?.key;
2118
+ if (typeof key === "string" || typeof key === "number") return `k:${String(key)}`;
2119
+ const id = child.attributes?.id;
2120
+ if (typeof id === "string" && id.length > 0) return `id:${id}`;
2121
+ return null;
2122
+ }
2123
+ function getDomMatchKeys(node) {
2124
+ if (node.nodeType !== Node.ELEMENT_NODE) return [];
2125
+ const el = node;
2126
+ const keys = [];
2127
+ const internalKey = el._defussKey;
2128
+ if (internalKey) keys.push(`k:${internalKey}`);
2129
+ const attrKey = el.getAttribute("key");
2130
+ if (attrKey) keys.push(`k:${attrKey}`);
2131
+ const id = el.id;
2132
+ if (id) keys.push(`id:${id}`);
2133
+ return keys;
2134
+ }
2135
+ function areNodeAndChildMatching(domNode, child) {
2136
+ if (typeof child === "string" || typeof child === "number" || typeof child === "boolean") {
2137
+ return domNode.nodeType === Node.TEXT_NODE;
2138
+ }
2139
+ if (child && typeof child === "object") {
2140
+ if (domNode.nodeType !== Node.ELEMENT_NODE) return false;
2141
+ const oldTag = domNode.tagName.toLowerCase();
2142
+ const newType = typeof child.type === "string" ? child.type.toLowerCase() : "";
2143
+ if (!newType) return false;
2144
+ return oldTag === newType;
2145
+ }
2146
+ return false;
2147
+ }
2148
+ function createDomFromChild(child, globals) {
2149
+ const renderer = getRenderer(globals.window.document);
2150
+ if (child == null) return void 0;
2151
+ if (typeof child === "string" || typeof child === "number" || typeof child === "boolean") {
2152
+ return globals.window.document.createTextNode(String(child));
2153
+ }
2154
+ const created = renderer.createElementOrElements(child);
2155
+ if (!created) return void 0;
2156
+ return Array.isArray(created) ? created : [created];
2157
+ }
2158
+ function shouldPreserveFormStateAttribute(el, attrName, vnode) {
2159
+ const tag = el.tagName.toLowerCase();
2160
+ const hasExplicit = Object.prototype.hasOwnProperty.call(vnode.attributes ?? {}, attrName);
2161
+ if (hasExplicit) return false;
2162
+ if (tag === "input") return attrName === "value" || attrName === "checked";
2163
+ if (tag === "textarea") return attrName === "value";
2164
+ if (tag === "select") return attrName === "value";
2165
+ return false;
2166
+ }
2167
+ function patchElementInPlace(el, vnode, globals) {
2168
+ const renderer = getRenderer(globals.window.document);
2169
+ const existingAttrs = Array.from(el.attributes);
2170
+ const nextAttrs = vnode.attributes ?? {};
2171
+ for (const attr of existingAttrs) {
2172
+ const { name } = attr;
2173
+ if (name === "key") continue;
2174
+ if (name.startsWith("on")) continue;
2175
+ if (name === "class" && (Object.prototype.hasOwnProperty.call(nextAttrs, "class") || Object.prototype.hasOwnProperty.call(nextAttrs, "className"))) {
2176
+ continue;
2177
+ }
2178
+ if (!Object.prototype.hasOwnProperty.call(nextAttrs, name)) {
2179
+ if (shouldPreserveFormStateAttribute(el, name, vnode)) continue;
2180
+ el.removeAttribute(name);
2181
+ }
2182
+ }
2183
+ renderer.setAttributes(vnode, el);
2184
+ const d = vnode.attributes?.dangerouslySetInnerHTML;
2185
+ if (d && typeof d === "object" && typeof d.__html === "string") {
2186
+ el.innerHTML = d.__html;
2187
+ return;
2188
+ }
2189
+ const tag = el.tagName.toLowerCase();
2190
+ if (tag === "textarea") {
2191
+ const isControlled = Object.prototype.hasOwnProperty.call(nextAttrs, "value");
2192
+ const isActive = el.ownerDocument?.activeElement === el;
2193
+ if (isActive && !isControlled) return;
2194
+ }
2195
+ updateDomWithVdom(el, vnode.children ?? [], globals);
2196
+ }
2197
+ function morphNode(domNode, child, globals) {
2198
+ if (typeof child === "string" || typeof child === "number" || typeof child === "boolean") {
2199
+ const text = String(child);
2200
+ if (domNode.nodeType === Node.TEXT_NODE) {
2201
+ if (domNode.nodeValue !== text) domNode.nodeValue = text;
2202
+ return domNode;
2203
+ }
2204
+ const next = globals.window.document.createTextNode(text);
2205
+ domNode.parentNode?.replaceChild(next, domNode);
2206
+ return next;
2207
+ }
2208
+ if (child && typeof child === "object") {
2209
+ const newType = typeof child.type === "string" ? child.type : null;
2210
+ if (!newType) return domNode;
2211
+ if (domNode.nodeType !== Node.ELEMENT_NODE) {
2212
+ const created = createDomFromChild(child, globals);
2213
+ const first = Array.isArray(created) ? created[0] : created;
2214
+ if (!first) return null;
2215
+ domNode.parentNode?.replaceChild(first, domNode);
2216
+ handleLifecycleEventsForOnMount(first);
2217
+ return first;
2218
+ }
2219
+ const el = domNode;
2220
+ const oldTag = el.tagName.toLowerCase();
2221
+ const newTag = newType.toLowerCase();
2222
+ if (oldTag !== newTag) {
2223
+ const created = createDomFromChild(child, globals);
2224
+ const first = Array.isArray(created) ? created[0] : created;
2225
+ if (!first) return null;
2226
+ el.parentNode?.replaceChild(first, el);
2227
+ handleLifecycleEventsForOnMount(first);
2228
+ return first;
2229
+ }
2230
+ patchElementInPlace(el, child, globals);
2231
+ return el;
2232
+ }
2233
+ domNode.parentNode?.removeChild(domNode);
2234
+ return null;
2235
+ }
2236
+ function updateDomWithVdom(parentElement, newVDOM, globals) {
2237
+ const nextChildren = normalizeChildren(newVDOM);
2238
+ const existing = Array.from(parentElement.childNodes);
2239
+ const keyedPool = /* @__PURE__ */ new Map();
2240
+ const nodeKeys = /* @__PURE__ */ new WeakMap();
2241
+ const unkeyedPool = [];
2242
+ for (const node of existing) {
2243
+ const keys = getDomMatchKeys(node);
2244
+ if (keys.length > 0) {
2245
+ nodeKeys.set(node, keys);
2246
+ for (const k of keys) {
2247
+ if (!keyedPool.has(k)) keyedPool.set(k, node);
2248
+ }
2249
+ } else {
2250
+ unkeyedPool.push(node);
2251
+ }
2252
+ }
2253
+ const consumeKeyedNode = (node) => {
2254
+ const keys = nodeKeys.get(node) ?? [];
2255
+ for (const k of keys) keyedPool.delete(k);
2256
+ };
2257
+ const takeUnkeyedMatch = (child) => {
2258
+ for (let i = 0; i < unkeyedPool.length; i++) {
2259
+ const candidate = unkeyedPool[i];
2260
+ if (areNodeAndChildMatching(candidate, child)) {
2261
+ unkeyedPool.splice(i, 1);
2262
+ return candidate;
2263
+ }
2264
+ }
2265
+ return unkeyedPool.shift();
2266
+ };
2267
+ let domIndex = 0;
2268
+ for (const child of nextChildren) {
2269
+ const key = getVNodeMatchKey(child);
2270
+ let match;
2271
+ if (key) {
2272
+ match = keyedPool.get(key);
2273
+ if (match) consumeKeyedNode(match);
2274
+ } else {
2275
+ match = takeUnkeyedMatch(child);
2276
+ }
2277
+ const anchor = parentElement.childNodes[domIndex] ?? null;
2278
+ if (match) {
2279
+ if (match !== anchor) {
2280
+ parentElement.insertBefore(match, anchor);
2281
+ }
2282
+ morphNode(match, child, globals);
2283
+ domIndex++;
2284
+ continue;
2285
+ }
2286
+ const created = createDomFromChild(child, globals);
2287
+ if (!created || Array.isArray(created) && created.length === 0) continue;
2288
+ const nodes = Array.isArray(created) ? created : [created];
2289
+ for (const node of nodes) {
2290
+ parentElement.insertBefore(node, anchor);
2291
+ handleLifecycleEventsForOnMount(node);
2292
+ domIndex++;
2293
+ }
2294
+ }
2295
+ const remaining = /* @__PURE__ */ new Set();
2296
+ for (const node of unkeyedPool) remaining.add(node);
2297
+ for (const node of keyedPool.values()) remaining.add(node);
2298
+ for (const node of remaining) {
2299
+ if (node.parentNode === parentElement) {
2300
+ parentElement.removeChild(node);
2301
+ }
2302
+ }
2303
+ }
2304
+ function replaceDomWithVdom(parentElement, newVDOM, globals) {
2305
+ while (parentElement.firstChild) {
2306
+ parentElement.removeChild(parentElement.firstChild);
2307
+ }
2308
+ const renderer = getRenderer(globals.window.document);
2309
+ const newDom = renderer.createElementOrElements(
2310
+ newVDOM
2311
+ );
2312
+ if (Array.isArray(newDom)) {
2313
+ for (const node of newDom) {
2314
+ if (node) {
2315
+ parentElement.appendChild(node);
2316
+ handleLifecycleEventsForOnMount(node);
2317
+ }
2318
+ }
2319
+ } else if (newDom) {
2320
+ parentElement.appendChild(newDom);
2321
+ handleLifecycleEventsForOnMount(newDom);
2322
+ }
2323
+ }
2324
+ async function waitForDOM(check, timeout, document) {
2325
+ const initialResult = check();
2326
+ if (initialResult.length) return initialResult;
2327
+ return defussRuntime.createTimeoutPromise(timeout, () => {
2328
+ return new Promise((resolve) => {
2329
+ if (!document) {
2330
+ setTimeout(() => resolve(check()), 0);
2331
+ return;
2332
+ }
2333
+ const observer = new MutationObserver(() => {
2334
+ const result = check();
2335
+ if (result.length) {
2336
+ observer.disconnect();
2337
+ resolve(result);
2338
+ }
2339
+ });
2340
+ observer.observe(document.documentElement, {
2341
+ childList: true,
2342
+ subtree: true,
2343
+ attributes: true
2344
+ });
2345
+ return () => observer.disconnect();
2346
+ });
2347
+ });
2348
+ }
2349
+ function parseDOM(input, type, Parser) {
2350
+ return new Parser().parseFromString(input, type);
2351
+ }
2352
+ function isSVG(input, Parser) {
2353
+ const doc = parseDOM(input, "image/svg+xml", Parser);
2354
+ if (!doc.documentElement) return false;
2355
+ return doc.documentElement.nodeName.toLowerCase() === "svg";
2356
+ }
2357
+ function isHTML(input, Parser) {
2358
+ const doc = parseDOM(input, "text/html", Parser);
2359
+ return doc.documentElement.querySelectorAll("*").length > 2;
2360
+ }
2361
+ const isMarkup = (input, Parser) => input.indexOf("<") > -1 && input.indexOf(">") > -1 && (isHTML(input, Parser) || isSVG(input, Parser));
2362
+ function renderMarkup(markup, Parser, doc) {
2363
+ return Array.from(
2364
+ (doc ? doc : parseDOM(markup, getMimeType(markup, Parser), Parser)).body.childNodes
2365
+ );
2366
+ }
2367
+ function getMimeType(input, Parser) {
2368
+ if (isSVG(input, Parser)) {
2369
+ return "image/svg+xml";
2370
+ }
2371
+ return "text/html";
2372
+ }
2373
+ function processAllFormElements(node, callback) {
2374
+ if (node instanceof Element) {
2375
+ if (node instanceof HTMLFormElement) {
2376
+ Array.from(node.elements).forEach((element) => {
2377
+ if (element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) {
2378
+ const key = element.name || element.id;
2379
+ if (key) {
2380
+ callback(element, key);
2381
+ }
2382
+ }
2383
+ });
2384
+ } else {
2385
+ const inputElements = node.querySelectorAll("input, select, textarea");
2386
+ inputElements.forEach((element) => {
2387
+ if (element instanceof HTMLInputElement || element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) {
2388
+ const key = element.name || element.id;
2389
+ if (key) {
2390
+ callback(element, key);
2391
+ }
2392
+ }
2393
+ });
2394
+ }
2395
+ }
2396
+ }
2397
+ function checkElementVisibility(element, window, document) {
2398
+ const style = window.getComputedStyle(element);
2399
+ if (!style) return false;
2400
+ if (element.offsetWidth === 0 || element.offsetHeight === 0) return false;
2401
+ if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0" || Number.parseFloat(style.opacity) === 0)
2402
+ return false;
2403
+ if (!document.body.contains(element)) return false;
2404
+ let parent = element.parentElement;
2405
+ while (parent) {
2406
+ const parentStyle = window.getComputedStyle(parent);
2407
+ if (parentStyle && (parentStyle.display === "none" || parentStyle.visibility === "hidden" || parentStyle.opacity === "0" || Number.parseFloat(parentStyle.opacity) === 0)) {
2408
+ return false;
2409
+ }
2410
+ parent = parent.parentElement;
2411
+ }
2412
+ return true;
2413
+ }
2414
+ function getEventMap(element) {
2415
+ if (!element._dequeryEvents) {
2416
+ element._dequeryEvents = /* @__PURE__ */ new Map();
2417
+ }
2418
+ return element._dequeryEvents;
2419
+ }
2420
+ function addElementEvent(element, eventType, handler) {
2421
+ const eventMap = getEventMap(element);
2422
+ if (!eventMap.has(eventType)) {
2423
+ eventMap.set(eventType, /* @__PURE__ */ new Set());
2424
+ }
2425
+ eventMap.get(eventType).add(handler);
2426
+ element.addEventListener(eventType, handler);
2427
+ }
2428
+ function removeElementEvent(element, eventType, handler) {
2429
+ const eventMap = getEventMap(element);
2430
+ if (!eventMap.has(eventType)) return;
2431
+ if (handler) {
2432
+ if (eventMap.get(eventType).has(handler)) {
2433
+ element.removeEventListener(eventType, handler);
2434
+ eventMap.get(eventType).delete(handler);
2435
+ if (eventMap.get(eventType).size === 0) {
2436
+ eventMap.delete(eventType);
2437
+ }
2438
+ }
2439
+ } else {
2440
+ eventMap.get(eventType).forEach((h) => {
2441
+ element.removeEventListener(eventType, h);
2442
+ });
2443
+ eventMap.delete(eventType);
2444
+ }
2445
+ }
2446
+ function clearElementEvents(element) {
2447
+ const eventMap = getEventMap(element);
2448
+ eventMap.forEach((handlers, eventType) => {
2449
+ handlers.forEach((handler) => {
2450
+ element.removeEventListener(eventType, handler);
2451
+ });
2452
+ });
2453
+ eventMap.clear();
2454
+ }
2455
+ function domNodeToVNode(node) {
2456
+ if (node.nodeType === Node.TEXT_NODE) {
2457
+ return node.textContent || "";
2458
+ }
2459
+ if (node.nodeType === Node.ELEMENT_NODE) {
2460
+ const element = node;
2461
+ const attributes = {};
2462
+ for (let i = 0; i < element.attributes.length; i++) {
2463
+ const attr = element.attributes[i];
2464
+ attributes[attr.name] = attr.value;
2465
+ }
2466
+ const children = [];
2467
+ for (let i = 0; i < element.childNodes.length; i++) {
2468
+ const childVNode = domNodeToVNode(element.childNodes[i]);
2469
+ children.push(childVNode);
2470
+ }
2471
+ return {
2472
+ type: element.tagName.toLowerCase(),
2473
+ attributes,
2474
+ children
2475
+ };
2476
+ }
2477
+ return "";
2478
+ }
2479
+ function htmlStringToVNodes(html, Parser) {
2480
+ const parser = new Parser();
2481
+ const doc = parser.parseFromString(html, "text/html");
2482
+ const vNodes = [];
2483
+ for (let i = 0; i < doc.body.childNodes.length; i++) {
2484
+ const vnode = domNodeToVNode(doc.body.childNodes[i]);
2485
+ if (vnode !== "") {
2486
+ vNodes.push(vnode);
2487
+ }
2488
+ }
2489
+ return vNodes;
2490
+ }
2491
+
2492
+ exports.$ = $;
2493
+ exports.CAPTURE_ONLY_EVENTS = CAPTURE_ONLY_EVENTS;
2494
+ exports.CLASS_ATTRIBUTE_NAME = CLASS_ATTRIBUTE_NAME;
2495
+ exports.Call = Call;
2496
+ exports.CallChainImpl = CallChainImpl;
2497
+ exports.CallChainImplThenable = CallChainImplThenable;
2498
+ exports.DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE = DANGEROUSLY_SET_INNER_HTML_ATTRIBUTE;
2499
+ exports.DEFAULT_TRANSITION_CONFIG = DEFAULT_TRANSITION_CONFIG;
2500
+ exports.Fragment = Fragment;
2501
+ exports.REF_ATTRIBUTE_NAME = REF_ATTRIBUTE_NAME;
2502
+ exports.XLINK_ATTRIBUTE_NAME = XLINK_ATTRIBUTE_NAME;
2503
+ exports.XMLNS_ATTRIBUTE_NAME = XMLNS_ATTRIBUTE_NAME;
2504
+ exports.addElementEvent = addElementEvent;
2505
+ exports.addNonChainedReturnCallNames = addNonChainedReturnCallNames;
2506
+ exports.applyStyles = applyStyles;
2507
+ exports.areDomNodesEqual = areDomNodesEqual;
2508
+ exports.checkElementVisibility = checkElementVisibility;
2509
+ exports.clearDelegatedEvents = clearDelegatedEvents;
2510
+ exports.clearElementEvents = clearElementEvents;
2511
+ exports.createCall = createCall;
2512
+ exports.createGetterSetterCall = createGetterSetterCall;
2513
+ exports.createInPlaceErrorMessageVNode = createInPlaceErrorMessageVNode;
2514
+ exports.createRef = createRef;
2515
+ exports.createStore = createStore;
2516
+ exports.createSubChain = createSubChain;
2517
+ exports.delayedAutoStart = delayedAutoStart;
2518
+ exports.dequery = dequery;
2519
+ exports.domNodeToVNode = domNodeToVNode;
2520
+ exports.emptyImpl = emptyImpl;
2521
+ exports.getAllFormValues = getAllFormValues;
2522
+ exports.getDefaultDequeryOptions = getDefaultDequeryOptions;
2523
+ exports.getEventMap = getEventMap;
2524
+ exports.getMimeType = getMimeType;
2525
+ exports.getNonChainedReturnCallNames = getNonChainedReturnCallNames;
2526
+ exports.getRenderer = getRenderer;
2527
+ exports.getTransitionStyles = getTransitionStyles;
2528
+ exports.globalScopeDomApis = globalScopeDomApis;
2529
+ exports.handleLifecycleEventsForOnMount = handleLifecycleEventsForOnMount;
2530
+ exports.htmlStringToVNodes = htmlStringToVNodes;
2531
+ exports.isDequery = isDequery;
2532
+ exports.isDequeryOptionsObject = isDequeryOptionsObject;
2533
+ exports.isHTML = isHTML;
2534
+ exports.isJSX = isJSX;
2535
+ exports.isMarkup = isMarkup;
2536
+ exports.isNonChainedReturnCall = isNonChainedReturnCall;
2537
+ exports.isRef = isRef;
2538
+ exports.isSVG = isSVG;
2539
+ exports.isServer = isServer;
2540
+ exports.jsx = jsx;
2541
+ exports.jsxDEV = jsxDEV;
2542
+ exports.jsxs = jsxs;
2543
+ exports.mapArrayIndexAccess = mapArrayIndexAccess;
2544
+ exports.observeUnmount = observeUnmount;
2545
+ exports.parseDOM = parseDOM;
2546
+ exports.parseEventPropName = parseEventPropName;
2547
+ exports.performTransition = performTransition;
2548
+ exports.processAllFormElements = processAllFormElements;
2549
+ exports.queueCallback = queueCallback;
2550
+ exports.registerDelegatedEvent = registerDelegatedEvent;
2551
+ exports.removeDelegatedEvent = removeDelegatedEvent;
2552
+ exports.removeElementEvent = removeElementEvent;
2553
+ exports.renderIsomorphicAsync = renderIsomorphicAsync;
2554
+ exports.renderIsomorphicSync = renderIsomorphicSync;
2555
+ exports.renderMarkup = renderMarkup;
2556
+ exports.renderNode = renderNode;
2557
+ exports.replaceDomWithVdom = replaceDomWithVdom;
2558
+ exports.resolveNodes = resolveNodes;
2559
+ exports.runWithTimeGuard = runWithTimeGuard;
2560
+ exports.scrollHelper = scrollHelper;
2561
+ exports.subChainForNextAwait = subChainForNextAwait;
2562
+ exports.traverse = traverse;
2563
+ exports.updateDom = updateDom;
2564
+ exports.updateDomWithVdom = updateDomWithVdom;
2565
+ exports.waitForDOM = waitForDOM;
2566
+ exports.webstorage = webstorage;