@claude-sessions/web 0.4.5 → 0.4.6

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 (175) hide show
  1. package/build/client/_app/immutable/assets/0.cQgYior5.css +1 -0
  2. package/build/client/_app/immutable/assets/0.cQgYior5.css.br +0 -0
  3. package/build/client/_app/immutable/assets/0.cQgYior5.css.gz +0 -0
  4. package/build/client/_app/immutable/chunks/B8g5xi4b.js +1 -0
  5. package/build/client/_app/immutable/chunks/B8g5xi4b.js.br +0 -0
  6. package/build/client/_app/immutable/chunks/B8g5xi4b.js.gz +0 -0
  7. package/build/client/_app/immutable/chunks/CG99hqDQ.js +2 -0
  8. package/build/client/_app/immutable/chunks/CG99hqDQ.js.br +0 -0
  9. package/build/client/_app/immutable/chunks/CG99hqDQ.js.gz +0 -0
  10. package/build/client/_app/immutable/chunks/CiIZzKcO.js +1 -0
  11. package/build/client/_app/immutable/chunks/CiIZzKcO.js.br +0 -0
  12. package/build/client/_app/immutable/chunks/CiIZzKcO.js.gz +0 -0
  13. package/build/client/_app/immutable/chunks/{BmH_exS6.js → DDmWtjsj.js} +1 -1
  14. package/build/client/_app/immutable/chunks/DDmWtjsj.js.br +0 -0
  15. package/build/client/_app/immutable/chunks/DDmWtjsj.js.gz +0 -0
  16. package/build/client/_app/immutable/chunks/DWa7QuMS.js +1 -0
  17. package/build/client/_app/immutable/chunks/DWa7QuMS.js.br +0 -0
  18. package/build/client/_app/immutable/chunks/DWa7QuMS.js.gz +0 -0
  19. package/build/client/_app/immutable/chunks/Dw50LpzA.js +1 -0
  20. package/build/client/_app/immutable/chunks/Dw50LpzA.js.br +0 -0
  21. package/build/client/_app/immutable/chunks/Dw50LpzA.js.gz +0 -0
  22. package/build/client/_app/immutable/chunks/aZi3OCpL.js +96 -0
  23. package/build/client/_app/immutable/chunks/aZi3OCpL.js.br +0 -0
  24. package/build/client/_app/immutable/chunks/aZi3OCpL.js.gz +0 -0
  25. package/build/client/_app/immutable/entry/app.CYY1PZCN.js +2 -0
  26. package/build/client/_app/immutable/entry/app.CYY1PZCN.js.br +0 -0
  27. package/build/client/_app/immutable/entry/app.CYY1PZCN.js.gz +0 -0
  28. package/build/client/_app/immutable/entry/start.D84fuMw9.js +1 -0
  29. package/build/client/_app/immutable/entry/start.D84fuMw9.js.br +2 -0
  30. package/build/client/_app/immutable/entry/start.D84fuMw9.js.gz +0 -0
  31. package/build/client/_app/immutable/nodes/0.B2uv-WBM.js +1 -0
  32. package/build/client/_app/immutable/nodes/0.B2uv-WBM.js.br +0 -0
  33. package/build/client/_app/immutable/nodes/0.B2uv-WBM.js.gz +0 -0
  34. package/build/client/_app/immutable/nodes/1.BoxEAqK6.js +1 -0
  35. package/build/client/_app/immutable/nodes/1.BoxEAqK6.js.br +3 -0
  36. package/build/client/_app/immutable/nodes/1.BoxEAqK6.js.gz +0 -0
  37. package/build/client/_app/immutable/nodes/{2.yd31CwaR.js → 2.mKAMmHlh.js} +1 -1
  38. package/build/client/_app/immutable/nodes/2.mKAMmHlh.js.br +0 -0
  39. package/build/client/_app/immutable/nodes/2.mKAMmHlh.js.gz +0 -0
  40. package/build/client/_app/immutable/nodes/3.Dj8iwfME.js +4 -0
  41. package/build/client/_app/immutable/nodes/3.Dj8iwfME.js.br +0 -0
  42. package/build/client/_app/immutable/nodes/3.Dj8iwfME.js.gz +0 -0
  43. package/build/client/_app/version.json +1 -1
  44. package/build/client/_app/version.json.br +0 -0
  45. package/build/client/_app/version.json.gz +0 -0
  46. package/build/handler.js +290 -228
  47. package/build/server/chunks/0-DChhR3gd.js +17 -0
  48. package/build/server/chunks/{0-D3SWM5E2.js.map → 0-DChhR3gd.js.map} +1 -1
  49. package/build/server/chunks/1-BBSPd3nB.js +9 -0
  50. package/build/server/chunks/{1-CXfgX4ux.js.map → 1-BBSPd3nB.js.map} +1 -1
  51. package/build/server/chunks/2-C20RW_lJ.js +9 -0
  52. package/build/server/chunks/{2-MV5uDYTL.js.map → 2-C20RW_lJ.js.map} +1 -1
  53. package/build/server/chunks/3-D3wL2YSE.js +9 -0
  54. package/build/server/chunks/{3-CsnDqfbG.js.map → 3-D3wL2YSE.js.map} +1 -1
  55. package/build/server/chunks/{InputModal-B9P0hP_j.js → InputModal-1qJGryUa.js} +6 -7
  56. package/build/server/chunks/InputModal-1qJGryUa.js.map +1 -0
  57. package/build/server/chunks/{Toast-DWQ-hmJu.js → Toast-C9b_dWm4.js} +7 -8
  58. package/build/server/chunks/Toast-C9b_dWm4.js.map +1 -0
  59. package/build/server/chunks/_layout.svelte-CdDMC1RI.js +134 -0
  60. package/build/server/chunks/_layout.svelte-CdDMC1RI.js.map +1 -0
  61. package/build/server/chunks/{_page.svelte-CGQGusC6.js → _page.svelte-CVL9fjg-.js} +10 -13
  62. package/build/server/chunks/_page.svelte-CVL9fjg-.js.map +1 -0
  63. package/build/server/chunks/{_page.svelte-BiD6gfpa.js → _page.svelte-Dx2ikKP_.js} +451 -497
  64. package/build/server/chunks/_page.svelte-Dx2ikKP_.js.map +1 -0
  65. package/build/server/chunks/{_server.ts-CDdRYdYO.js → _server.ts-B3M-jxF5.js} +2 -2
  66. package/build/server/chunks/{_server.ts-CDdRYdYO.js.map → _server.ts-B3M-jxF5.js.map} +1 -1
  67. package/build/server/chunks/{_server.ts-iCUks3KF.js → _server.ts-BCOHCAjW.js} +2 -2
  68. package/build/server/chunks/{_server.ts-iCUks3KF.js.map → _server.ts-BCOHCAjW.js.map} +1 -1
  69. package/build/server/chunks/{_server.ts-ChObRyrd.js → _server.ts-BGA9W8aM.js} +2 -2
  70. package/build/server/chunks/{_server.ts-ChObRyrd.js.map → _server.ts-BGA9W8aM.js.map} +1 -1
  71. package/build/server/chunks/{_server.ts-D5wsc-pR.js → _server.ts-BWxgSwZN.js} +2 -2
  72. package/build/server/chunks/{_server.ts-D5wsc-pR.js.map → _server.ts-BWxgSwZN.js.map} +1 -1
  73. package/build/server/chunks/{_server.ts-kfmLCgu8.js → _server.ts-C0mKXnG1.js} +2 -2
  74. package/build/server/chunks/{_server.ts-kfmLCgu8.js.map → _server.ts-C0mKXnG1.js.map} +1 -1
  75. package/build/server/chunks/{_server.ts-BsgoVOBd.js → _server.ts-C9GYaVf1.js} +3 -3
  76. package/build/server/chunks/{_server.ts-BsgoVOBd.js.map → _server.ts-C9GYaVf1.js.map} +1 -1
  77. package/build/server/chunks/{_server.ts-CPDPReZU.js → _server.ts-COPvamIQ.js} +2 -2
  78. package/build/server/chunks/{_server.ts-CPDPReZU.js.map → _server.ts-COPvamIQ.js.map} +1 -1
  79. package/build/server/chunks/{_server.ts-DLSXCOEM.js → _server.ts-CrKc6LEy.js} +2 -2
  80. package/build/server/chunks/{_server.ts-DLSXCOEM.js.map → _server.ts-CrKc6LEy.js.map} +1 -1
  81. package/build/server/chunks/{_server.ts-CKxzPqOL.js → _server.ts-DOSGEHuw.js} +2 -2
  82. package/build/server/chunks/{_server.ts-CKxzPqOL.js.map → _server.ts-DOSGEHuw.js.map} +1 -1
  83. package/build/server/chunks/{_server.ts-Be1LFWpG.js → _server.ts-DP0i5Bdl.js} +2 -2
  84. package/build/server/chunks/{_server.ts-Be1LFWpG.js.map → _server.ts-DP0i5Bdl.js.map} +1 -1
  85. package/build/server/chunks/{_server.ts-crvQ7CTS.js → _server.ts-DmN9rdOH.js} +3 -3
  86. package/build/server/chunks/{_server.ts-crvQ7CTS.js.map → _server.ts-DmN9rdOH.js.map} +1 -1
  87. package/build/server/chunks/{_server.ts-Brg38LxG.js → _server.ts-DmWsoikX.js} +2 -2
  88. package/build/server/chunks/{_server.ts-Brg38LxG.js.map → _server.ts-DmWsoikX.js.map} +1 -1
  89. package/build/server/chunks/{_server.ts-BOyCbZXG.js → _server.ts-F01KLghS.js} +2 -2
  90. package/build/server/chunks/{_server.ts-BOyCbZXG.js.map → _server.ts-F01KLghS.js.map} +1 -1
  91. package/build/server/chunks/{_server.ts-blDzB5RZ.js → _server.ts-QLTE_2dV.js} +2 -2
  92. package/build/server/chunks/{_server.ts-blDzB5RZ.js.map → _server.ts-QLTE_2dV.js.map} +1 -1
  93. package/build/server/chunks/{_server.ts-Fv64R5tZ.js → _server.ts-WZF_VFnZ.js} +2 -2
  94. package/build/server/chunks/{_server.ts-Fv64R5tZ.js.map → _server.ts-WZF_VFnZ.js.map} +1 -1
  95. package/build/server/chunks/{_server.ts-Dc0z7zpD.js → _server.ts-rTWeIoSC.js} +3 -3
  96. package/build/server/chunks/{_server.ts-Dc0z7zpD.js.map → _server.ts-rTWeIoSC.js.map} +1 -1
  97. package/build/server/chunks/{index4-B6vRxXfo.js → client-BtcIwznP.js} +3 -23
  98. package/build/server/chunks/client-BtcIwznP.js.map +1 -0
  99. package/build/server/chunks/{error.svelte-BNCG_dZH.js → error.svelte-B02-pvoO.js} +5 -4
  100. package/build/server/chunks/error.svelte-B02-pvoO.js.map +1 -0
  101. package/build/server/chunks/index-CoD1IJuy.js.map +1 -1
  102. package/build/server/chunks/index2-B2Ld-FFX.js +3575 -0
  103. package/build/server/chunks/index2-B2Ld-FFX.js.map +1 -0
  104. package/build/server/chunks/{index3-D8yIZRD-.js → index3-DNyQGNm8.js} +3 -3
  105. package/build/server/chunks/index3-DNyQGNm8.js.map +1 -0
  106. package/build/server/chunks/index4-CfOR2iO6.js +21 -0
  107. package/build/server/chunks/index4-CfOR2iO6.js.map +1 -0
  108. package/build/server/chunks/root-B5iYE7yO.js +1182 -0
  109. package/build/server/chunks/root-B5iYE7yO.js.map +1 -0
  110. package/build/server/chunks/{session-BwU3zV40.js → session-Dxp1vf6f.js} +2 -2
  111. package/build/server/chunks/{session-BwU3zV40.js.map → session-Dxp1vf6f.js.map} +1 -1
  112. package/build/server/index.js +703 -1411
  113. package/build/server/index.js.map +1 -1
  114. package/build/server/manifest.js +21 -21
  115. package/build/server/manifest.js.map +1 -1
  116. package/package.json +23 -23
  117. package/build/client/_app/immutable/assets/0.BTIBK81-.css +0 -1
  118. package/build/client/_app/immutable/assets/0.BTIBK81-.css.br +0 -0
  119. package/build/client/_app/immutable/assets/0.BTIBK81-.css.gz +0 -0
  120. package/build/client/_app/immutable/chunks/B-Z9hXPk.js +0 -1
  121. package/build/client/_app/immutable/chunks/B-Z9hXPk.js.br +0 -0
  122. package/build/client/_app/immutable/chunks/B-Z9hXPk.js.gz +0 -0
  123. package/build/client/_app/immutable/chunks/BmH_exS6.js.br +0 -0
  124. package/build/client/_app/immutable/chunks/BmH_exS6.js.gz +0 -0
  125. package/build/client/_app/immutable/chunks/Cr0eW1j3.js +0 -1
  126. package/build/client/_app/immutable/chunks/Cr0eW1j3.js.br +0 -0
  127. package/build/client/_app/immutable/chunks/Cr0eW1j3.js.gz +0 -0
  128. package/build/client/_app/immutable/chunks/DOXVKi87.js +0 -2
  129. package/build/client/_app/immutable/chunks/DOXVKi87.js.br +0 -0
  130. package/build/client/_app/immutable/chunks/DOXVKi87.js.gz +0 -0
  131. package/build/client/_app/immutable/chunks/WodlV_jD.js +0 -96
  132. package/build/client/_app/immutable/chunks/WodlV_jD.js.br +0 -0
  133. package/build/client/_app/immutable/chunks/WodlV_jD.js.gz +0 -0
  134. package/build/client/_app/immutable/chunks/YXuXYbOb.js +0 -1
  135. package/build/client/_app/immutable/chunks/YXuXYbOb.js.br +0 -0
  136. package/build/client/_app/immutable/chunks/YXuXYbOb.js.gz +0 -0
  137. package/build/client/_app/immutable/chunks/vDyoI7lw.js +0 -1
  138. package/build/client/_app/immutable/chunks/vDyoI7lw.js.br +0 -0
  139. package/build/client/_app/immutable/chunks/vDyoI7lw.js.gz +0 -0
  140. package/build/client/_app/immutable/entry/app.Kf_4i_t0.js +0 -2
  141. package/build/client/_app/immutable/entry/app.Kf_4i_t0.js.br +0 -0
  142. package/build/client/_app/immutable/entry/app.Kf_4i_t0.js.gz +0 -0
  143. package/build/client/_app/immutable/entry/start.DrVGwFzz.js +0 -1
  144. package/build/client/_app/immutable/entry/start.DrVGwFzz.js.br +0 -0
  145. package/build/client/_app/immutable/entry/start.DrVGwFzz.js.gz +0 -0
  146. package/build/client/_app/immutable/nodes/0.Dfn2ZpXY.js +0 -1
  147. package/build/client/_app/immutable/nodes/0.Dfn2ZpXY.js.br +0 -0
  148. package/build/client/_app/immutable/nodes/0.Dfn2ZpXY.js.gz +0 -0
  149. package/build/client/_app/immutable/nodes/1.CWRD2TOY.js +0 -1
  150. package/build/client/_app/immutable/nodes/1.CWRD2TOY.js.br +0 -0
  151. package/build/client/_app/immutable/nodes/1.CWRD2TOY.js.gz +0 -0
  152. package/build/client/_app/immutable/nodes/2.yd31CwaR.js.br +0 -0
  153. package/build/client/_app/immutable/nodes/2.yd31CwaR.js.gz +0 -0
  154. package/build/client/_app/immutable/nodes/3.Dh5fbLPm.js +0 -4
  155. package/build/client/_app/immutable/nodes/3.Dh5fbLPm.js.br +0 -0
  156. package/build/client/_app/immutable/nodes/3.Dh5fbLPm.js.gz +0 -0
  157. package/build/server/chunks/0-D3SWM5E2.js +0 -17
  158. package/build/server/chunks/1-CXfgX4ux.js +0 -9
  159. package/build/server/chunks/2-MV5uDYTL.js +0 -9
  160. package/build/server/chunks/3-CsnDqfbG.js +0 -9
  161. package/build/server/chunks/InputModal-B9P0hP_j.js.map +0 -1
  162. package/build/server/chunks/Toast-DWQ-hmJu.js.map +0 -1
  163. package/build/server/chunks/_layout.svelte-Cgt3CiZy.js +0 -106
  164. package/build/server/chunks/_layout.svelte-Cgt3CiZy.js.map +0 -1
  165. package/build/server/chunks/_page.svelte-BiD6gfpa.js.map +0 -1
  166. package/build/server/chunks/_page.svelte-CGQGusC6.js.map +0 -1
  167. package/build/server/chunks/error.svelte-BNCG_dZH.js.map +0 -1
  168. package/build/server/chunks/exports-BXvEiaiv.js +0 -238
  169. package/build/server/chunks/exports-BXvEiaiv.js.map +0 -1
  170. package/build/server/chunks/index-D4ev3Ona.js +0 -1352
  171. package/build/server/chunks/index-D4ev3Ona.js.map +0 -1
  172. package/build/server/chunks/index2-ybZwlzIk.js +0 -1925
  173. package/build/server/chunks/index2-ybZwlzIk.js.map +0 -1
  174. package/build/server/chunks/index3-D8yIZRD-.js.map +0 -1
  175. package/build/server/chunks/index4-B6vRxXfo.js.map +0 -1
@@ -0,0 +1,3575 @@
1
+ const browser = false;
2
+ const escaped = {
3
+ "<": "\\u003C",
4
+ "\\": "\\\\",
5
+ "\b": "\\b",
6
+ "\f": "\\f",
7
+ "\n": "\\n",
8
+ "\r": "\\r",
9
+ " ": "\\t",
10
+ "\u2028": "\\u2028",
11
+ "\u2029": "\\u2029"
12
+ };
13
+ class DevalueError extends Error {
14
+ /**
15
+ * @param {string} message
16
+ * @param {string[]} keys
17
+ * @param {any} [value] - The value that failed to be serialized
18
+ * @param {any} [root] - The root value being serialized
19
+ */
20
+ constructor(message, keys, value, root) {
21
+ super(message);
22
+ this.name = "DevalueError";
23
+ this.path = keys.join("");
24
+ this.value = value;
25
+ this.root = root;
26
+ }
27
+ }
28
+ function is_primitive(thing) {
29
+ return Object(thing) !== thing;
30
+ }
31
+ const object_proto_names = /* @__PURE__ */ Object.getOwnPropertyNames(
32
+ Object.prototype
33
+ ).sort().join("\0");
34
+ function is_plain_object(thing) {
35
+ const proto = Object.getPrototypeOf(thing);
36
+ return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null || Object.getOwnPropertyNames(proto).sort().join("\0") === object_proto_names;
37
+ }
38
+ function get_type(thing) {
39
+ return Object.prototype.toString.call(thing).slice(8, -1);
40
+ }
41
+ function get_escaped_char(char) {
42
+ switch (char) {
43
+ case '"':
44
+ return '\\"';
45
+ case "<":
46
+ return "\\u003C";
47
+ case "\\":
48
+ return "\\\\";
49
+ case "\n":
50
+ return "\\n";
51
+ case "\r":
52
+ return "\\r";
53
+ case " ":
54
+ return "\\t";
55
+ case "\b":
56
+ return "\\b";
57
+ case "\f":
58
+ return "\\f";
59
+ case "\u2028":
60
+ return "\\u2028";
61
+ case "\u2029":
62
+ return "\\u2029";
63
+ default:
64
+ return char < " " ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : "";
65
+ }
66
+ }
67
+ function stringify_string(str) {
68
+ let result = "";
69
+ let last_pos = 0;
70
+ const len = str.length;
71
+ for (let i = 0; i < len; i += 1) {
72
+ const char = str[i];
73
+ const replacement = get_escaped_char(char);
74
+ if (replacement) {
75
+ result += str.slice(last_pos, i) + replacement;
76
+ last_pos = i + 1;
77
+ }
78
+ }
79
+ return `"${last_pos === 0 ? str : result + str.slice(last_pos)}"`;
80
+ }
81
+ function enumerable_symbols(object) {
82
+ return Object.getOwnPropertySymbols(object).filter(
83
+ (symbol) => Object.getOwnPropertyDescriptor(object, symbol).enumerable
84
+ );
85
+ }
86
+ const is_identifier = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;
87
+ function stringify_key(key) {
88
+ return is_identifier.test(key) ? "." + key : "[" + JSON.stringify(key) + "]";
89
+ }
90
+ function is_valid_array_index(s) {
91
+ if (s.length === 0) return false;
92
+ if (s.length > 1 && s.charCodeAt(0) === 48) return false;
93
+ for (let i = 0; i < s.length; i++) {
94
+ const c = s.charCodeAt(i);
95
+ if (c < 48 || c > 57) return false;
96
+ }
97
+ const n = +s;
98
+ if (n >= 2 ** 32 - 1) return false;
99
+ if (n < 0) return false;
100
+ return true;
101
+ }
102
+ function valid_array_indices(array) {
103
+ const keys = Object.keys(array);
104
+ for (var i = keys.length - 1; i >= 0; i--) {
105
+ if (is_valid_array_index(keys[i])) {
106
+ break;
107
+ }
108
+ }
109
+ keys.length = i + 1;
110
+ return keys;
111
+ }
112
+
113
+ const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
114
+ const unsafe_chars = /[<\b\f\n\r\t\0\u2028\u2029]/g;
115
+ const reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
116
+ function uneval(value, replacer) {
117
+ const counts = /* @__PURE__ */ new Map();
118
+ const keys = [];
119
+ const custom = /* @__PURE__ */ new Map();
120
+ function walk(thing) {
121
+ if (!is_primitive(thing)) {
122
+ if (counts.has(thing)) {
123
+ counts.set(thing, counts.get(thing) + 1);
124
+ return;
125
+ }
126
+ counts.set(thing, 1);
127
+ if (replacer) {
128
+ const str2 = replacer(thing, (value2) => uneval(value2, replacer));
129
+ if (typeof str2 === "string") {
130
+ custom.set(thing, str2);
131
+ return;
132
+ }
133
+ }
134
+ if (typeof thing === "function") {
135
+ throw new DevalueError(`Cannot stringify a function`, keys, thing, value);
136
+ }
137
+ const type = get_type(thing);
138
+ switch (type) {
139
+ case "Number":
140
+ case "BigInt":
141
+ case "String":
142
+ case "Boolean":
143
+ case "Date":
144
+ case "RegExp":
145
+ case "URL":
146
+ case "URLSearchParams":
147
+ return;
148
+ case "Array":
149
+ thing.forEach((value2, i) => {
150
+ keys.push(`[${i}]`);
151
+ walk(value2);
152
+ keys.pop();
153
+ });
154
+ break;
155
+ case "Set":
156
+ Array.from(thing).forEach(walk);
157
+ break;
158
+ case "Map":
159
+ for (const [key, value2] of thing) {
160
+ keys.push(
161
+ `.get(${is_primitive(key) ? stringify_primitive(key) : "..."})`
162
+ );
163
+ walk(value2);
164
+ keys.pop();
165
+ }
166
+ break;
167
+ case "Int8Array":
168
+ case "Uint8Array":
169
+ case "Uint8ClampedArray":
170
+ case "Int16Array":
171
+ case "Uint16Array":
172
+ case "Int32Array":
173
+ case "Uint32Array":
174
+ case "Float32Array":
175
+ case "Float64Array":
176
+ case "BigInt64Array":
177
+ case "BigUint64Array":
178
+ walk(thing.buffer);
179
+ return;
180
+ case "ArrayBuffer":
181
+ return;
182
+ case "Temporal.Duration":
183
+ case "Temporal.Instant":
184
+ case "Temporal.PlainDate":
185
+ case "Temporal.PlainTime":
186
+ case "Temporal.PlainDateTime":
187
+ case "Temporal.PlainMonthDay":
188
+ case "Temporal.PlainYearMonth":
189
+ case "Temporal.ZonedDateTime":
190
+ return;
191
+ default:
192
+ if (!is_plain_object(thing)) {
193
+ throw new DevalueError(
194
+ `Cannot stringify arbitrary non-POJOs`,
195
+ keys,
196
+ thing,
197
+ value
198
+ );
199
+ }
200
+ if (enumerable_symbols(thing).length > 0) {
201
+ throw new DevalueError(
202
+ `Cannot stringify POJOs with symbolic keys`,
203
+ keys,
204
+ thing,
205
+ value
206
+ );
207
+ }
208
+ for (const key of Object.keys(thing)) {
209
+ if (key === "__proto__") {
210
+ throw new DevalueError(
211
+ `Cannot stringify objects with __proto__ keys`,
212
+ keys,
213
+ thing,
214
+ value
215
+ );
216
+ }
217
+ keys.push(stringify_key(key));
218
+ walk(thing[key]);
219
+ keys.pop();
220
+ }
221
+ }
222
+ }
223
+ }
224
+ walk(value);
225
+ const names = /* @__PURE__ */ new Map();
226
+ Array.from(counts).filter((entry) => entry[1] > 1).sort((a, b) => b[1] - a[1]).forEach((entry, i) => {
227
+ names.set(entry[0], get_name(i));
228
+ });
229
+ function stringify2(thing) {
230
+ if (names.has(thing)) {
231
+ return names.get(thing);
232
+ }
233
+ if (is_primitive(thing)) {
234
+ return stringify_primitive(thing);
235
+ }
236
+ if (custom.has(thing)) {
237
+ return custom.get(thing);
238
+ }
239
+ const type = get_type(thing);
240
+ switch (type) {
241
+ case "Number":
242
+ case "String":
243
+ case "Boolean":
244
+ return `Object(${stringify2(thing.valueOf())})`;
245
+ case "RegExp":
246
+ return `new RegExp(${stringify_string(thing.source)}, "${thing.flags}")`;
247
+ case "Date":
248
+ return `new Date(${thing.getTime()})`;
249
+ case "URL":
250
+ return `new URL(${stringify_string(thing.toString())})`;
251
+ case "URLSearchParams":
252
+ return `new URLSearchParams(${stringify_string(thing.toString())})`;
253
+ case "Array": {
254
+ let has_holes = false;
255
+ let result = "[";
256
+ for (let i = 0; i < thing.length; i += 1) {
257
+ if (i > 0) result += ",";
258
+ if (Object.hasOwn(thing, i)) {
259
+ result += stringify2(thing[i]);
260
+ } else if (!has_holes) {
261
+ const populated_keys = valid_array_indices(
262
+ /** @type {any[]} */
263
+ thing
264
+ );
265
+ const population = populated_keys.length;
266
+ const d = String(thing.length).length;
267
+ const hole_cost = thing.length + 2;
268
+ const sparse_cost = 25 + d + population * (d + 2);
269
+ if (hole_cost > sparse_cost) {
270
+ const entries = populated_keys.map((k) => `${k}:${stringify2(thing[k])}`).join(",");
271
+ return `Object.assign(Array(${thing.length}),{${entries}})`;
272
+ }
273
+ has_holes = true;
274
+ i -= 1;
275
+ }
276
+ }
277
+ const tail = thing.length === 0 || thing.length - 1 in thing ? "" : ",";
278
+ return result + tail + "]";
279
+ }
280
+ case "Set":
281
+ case "Map":
282
+ return `new ${type}([${Array.from(thing).map(stringify2).join(",")}])`;
283
+ case "Int8Array":
284
+ case "Uint8Array":
285
+ case "Uint8ClampedArray":
286
+ case "Int16Array":
287
+ case "Uint16Array":
288
+ case "Int32Array":
289
+ case "Uint32Array":
290
+ case "Float32Array":
291
+ case "Float64Array":
292
+ case "BigInt64Array":
293
+ case "BigUint64Array": {
294
+ let str2 = `new ${type}`;
295
+ if (counts.get(thing.buffer) === 1) {
296
+ const array = new thing.constructor(thing.buffer);
297
+ str2 += `([${array}])`;
298
+ } else {
299
+ str2 += `([${stringify2(thing.buffer)}])`;
300
+ }
301
+ const a = thing.byteOffset;
302
+ const b = a + thing.byteLength;
303
+ if (a > 0 || b !== thing.buffer.byteLength) {
304
+ const m = +/(\d+)/.exec(type)[1] / 8;
305
+ str2 += `.subarray(${a / m},${b / m})`;
306
+ }
307
+ return str2;
308
+ }
309
+ case "ArrayBuffer": {
310
+ const ui8 = new Uint8Array(thing);
311
+ return `new Uint8Array([${ui8.toString()}]).buffer`;
312
+ }
313
+ case "Temporal.Duration":
314
+ case "Temporal.Instant":
315
+ case "Temporal.PlainDate":
316
+ case "Temporal.PlainTime":
317
+ case "Temporal.PlainDateTime":
318
+ case "Temporal.PlainMonthDay":
319
+ case "Temporal.PlainYearMonth":
320
+ case "Temporal.ZonedDateTime":
321
+ return `${type}.from(${stringify_string(thing.toString())})`;
322
+ default:
323
+ const keys2 = Object.keys(thing);
324
+ const obj = keys2.map((key) => `${safe_key(key)}:${stringify2(thing[key])}`).join(",");
325
+ const proto = Object.getPrototypeOf(thing);
326
+ if (proto === null) {
327
+ return keys2.length > 0 ? `{${obj},__proto__:null}` : `{__proto__:null}`;
328
+ }
329
+ return `{${obj}}`;
330
+ }
331
+ }
332
+ const str = stringify2(value);
333
+ if (names.size) {
334
+ const params = [];
335
+ const statements = [];
336
+ const values = [];
337
+ names.forEach((name, thing) => {
338
+ params.push(name);
339
+ if (custom.has(thing)) {
340
+ values.push(
341
+ /** @type {string} */
342
+ custom.get(thing)
343
+ );
344
+ return;
345
+ }
346
+ if (is_primitive(thing)) {
347
+ values.push(stringify_primitive(thing));
348
+ return;
349
+ }
350
+ const type = get_type(thing);
351
+ switch (type) {
352
+ case "Number":
353
+ case "String":
354
+ case "Boolean":
355
+ values.push(`Object(${stringify2(thing.valueOf())})`);
356
+ break;
357
+ case "RegExp":
358
+ values.push(thing.toString());
359
+ break;
360
+ case "Date":
361
+ values.push(`new Date(${thing.getTime()})`);
362
+ break;
363
+ case "Array":
364
+ values.push(`Array(${thing.length})`);
365
+ thing.forEach((v, i) => {
366
+ statements.push(`${name}[${i}]=${stringify2(v)}`);
367
+ });
368
+ break;
369
+ case "Set":
370
+ values.push(`new Set`);
371
+ statements.push(
372
+ `${name}.${Array.from(thing).map((v) => `add(${stringify2(v)})`).join(".")}`
373
+ );
374
+ break;
375
+ case "Map":
376
+ values.push(`new Map`);
377
+ statements.push(
378
+ `${name}.${Array.from(thing).map(([k, v]) => `set(${stringify2(k)}, ${stringify2(v)})`).join(".")}`
379
+ );
380
+ break;
381
+ case "ArrayBuffer":
382
+ values.push(
383
+ `new Uint8Array([${new Uint8Array(thing).join(",")}]).buffer`
384
+ );
385
+ break;
386
+ default:
387
+ values.push(
388
+ Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}"
389
+ );
390
+ Object.keys(thing).forEach((key) => {
391
+ statements.push(
392
+ `${name}${safe_prop(key)}=${stringify2(thing[key])}`
393
+ );
394
+ });
395
+ }
396
+ });
397
+ statements.push(`return ${str}`);
398
+ return `(function(${params.join(",")}){${statements.join(
399
+ ";"
400
+ )}}(${values.join(",")}))`;
401
+ } else {
402
+ return str;
403
+ }
404
+ }
405
+ function get_name(num) {
406
+ let name = "";
407
+ do {
408
+ name = chars[num % chars.length] + name;
409
+ num = ~~(num / chars.length) - 1;
410
+ } while (num >= 0);
411
+ return reserved.test(name) ? `${name}0` : name;
412
+ }
413
+ function escape_unsafe_char(c) {
414
+ return escaped[c] || c;
415
+ }
416
+ function escape_unsafe_chars(str) {
417
+ return str.replace(unsafe_chars, escape_unsafe_char);
418
+ }
419
+ function safe_key(key) {
420
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escape_unsafe_chars(JSON.stringify(key));
421
+ }
422
+ function safe_prop(key) {
423
+ return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? `.${key}` : `[${escape_unsafe_chars(JSON.stringify(key))}]`;
424
+ }
425
+ function stringify_primitive(thing) {
426
+ if (typeof thing === "string") return stringify_string(thing);
427
+ if (thing === void 0) return "void 0";
428
+ if (thing === 0 && 1 / thing < 0) return "-0";
429
+ const str = String(thing);
430
+ if (typeof thing === "number") return str.replace(/^(-)?0\./, "$1.");
431
+ if (typeof thing === "bigint") return thing + "n";
432
+ return str;
433
+ }
434
+ var is_array = Array.isArray;
435
+ var index_of = Array.prototype.indexOf;
436
+ var includes = Array.prototype.includes;
437
+ var array_from = Array.from;
438
+ var define_property = Object.defineProperty;
439
+ var get_descriptor = Object.getOwnPropertyDescriptor;
440
+ var object_prototype = Object.prototype;
441
+ var array_prototype = Array.prototype;
442
+ var get_prototype_of = Object.getPrototypeOf;
443
+ var is_extensible = Object.isExtensible;
444
+ var has_own_property = Object.prototype.hasOwnProperty;
445
+ const noop = () => {
446
+ };
447
+ function is_promise(value) {
448
+ return typeof value?.then === "function";
449
+ }
450
+ function run_all(arr) {
451
+ for (var i = 0; i < arr.length; i++) {
452
+ arr[i]();
453
+ }
454
+ }
455
+ function deferred() {
456
+ var resolve;
457
+ var reject;
458
+ var promise = new Promise((res, rej) => {
459
+ resolve = res;
460
+ reject = rej;
461
+ });
462
+ return { promise, resolve, reject };
463
+ }
464
+ function equals(value) {
465
+ return value === this.v;
466
+ }
467
+ function safe_not_equal(a, b) {
468
+ return a != a ? b == b : a !== b || a !== null && typeof a === "object" || typeof a === "function";
469
+ }
470
+ function safe_equals(value) {
471
+ return !safe_not_equal(value, this.v);
472
+ }
473
+ const DERIVED = 1 << 1;
474
+ const EFFECT = 1 << 2;
475
+ const RENDER_EFFECT = 1 << 3;
476
+ const MANAGED_EFFECT = 1 << 24;
477
+ const BLOCK_EFFECT = 1 << 4;
478
+ const BRANCH_EFFECT = 1 << 5;
479
+ const ROOT_EFFECT = 1 << 6;
480
+ const BOUNDARY_EFFECT = 1 << 7;
481
+ const CONNECTED = 1 << 9;
482
+ const CLEAN = 1 << 10;
483
+ const DIRTY = 1 << 11;
484
+ const MAYBE_DIRTY = 1 << 12;
485
+ const INERT = 1 << 13;
486
+ const DESTROYED = 1 << 14;
487
+ const REACTION_RAN = 1 << 15;
488
+ const DESTROYING = 1 << 25;
489
+ const EFFECT_TRANSPARENT = 1 << 16;
490
+ const EAGER_EFFECT = 1 << 17;
491
+ const HEAD_EFFECT = 1 << 18;
492
+ const EFFECT_PRESERVED = 1 << 19;
493
+ const USER_EFFECT = 1 << 20;
494
+ const WAS_MARKED = 1 << 16;
495
+ const REACTION_IS_UPDATING = 1 << 21;
496
+ const ASYNC = 1 << 22;
497
+ const ERROR_VALUE = 1 << 23;
498
+ const STATE_SYMBOL = /* @__PURE__ */ Symbol("$state");
499
+ const LEGACY_PROPS = /* @__PURE__ */ Symbol("legacy props");
500
+ const STALE_REACTION = new class StaleReactionError extends Error {
501
+ name = "StaleReactionError";
502
+ message = "The reaction that called `getAbortSignal()` was re-run or destroyed";
503
+ }();
504
+ const COMMENT_NODE = 8;
505
+ function lifecycle_outside_component(name) {
506
+ {
507
+ throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
508
+ }
509
+ }
510
+ function effect_update_depth_exceeded() {
511
+ {
512
+ throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
513
+ }
514
+ }
515
+ function hydration_failed() {
516
+ {
517
+ throw new Error(`https://svelte.dev/e/hydration_failed`);
518
+ }
519
+ }
520
+ function state_descriptors_fixed() {
521
+ {
522
+ throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
523
+ }
524
+ }
525
+ function state_prototype_fixed() {
526
+ {
527
+ throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
528
+ }
529
+ }
530
+ function state_unsafe_mutation() {
531
+ {
532
+ throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
533
+ }
534
+ }
535
+ function svelte_boundary_reset_onerror() {
536
+ {
537
+ throw new Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`);
538
+ }
539
+ }
540
+ const HYDRATION_START = "[";
541
+ const HYDRATION_START_ELSE = "[!";
542
+ const HYDRATION_START_FAILED = "[?";
543
+ const HYDRATION_END = "]";
544
+ const HYDRATION_ERROR = {};
545
+ const ELEMENT_IS_NAMESPACED = 1;
546
+ const ELEMENT_PRESERVE_ATTRIBUTE_CASE = 1 << 1;
547
+ const ELEMENT_IS_INPUT = 1 << 2;
548
+ const UNINITIALIZED = /* @__PURE__ */ Symbol();
549
+ let tracing_mode_flag = false;
550
+ let component_context = null;
551
+ function set_component_context(context) {
552
+ component_context = context;
553
+ }
554
+ function push$1(props, runes = false, fn) {
555
+ component_context = {
556
+ p: component_context,
557
+ i: false,
558
+ c: null,
559
+ e: null,
560
+ s: props,
561
+ x: null,
562
+ r: (
563
+ /** @type {Effect} */
564
+ active_effect
565
+ ),
566
+ l: null
567
+ };
568
+ }
569
+ function pop$1(component) {
570
+ var context = (
571
+ /** @type {ComponentContext} */
572
+ component_context
573
+ );
574
+ var effects = context.e;
575
+ if (effects !== null) {
576
+ context.e = null;
577
+ for (var fn of effects) {
578
+ create_user_effect(fn);
579
+ }
580
+ }
581
+ context.i = true;
582
+ component_context = context.p;
583
+ return (
584
+ /** @type {T} */
585
+ {}
586
+ );
587
+ }
588
+ function is_runes() {
589
+ return true;
590
+ }
591
+ let micro_tasks = [];
592
+ function run_micro_tasks() {
593
+ var tasks = micro_tasks;
594
+ micro_tasks = [];
595
+ run_all(tasks);
596
+ }
597
+ function queue_micro_task(fn) {
598
+ if (micro_tasks.length === 0 && !is_flushing_sync) {
599
+ var tasks = micro_tasks;
600
+ queueMicrotask(() => {
601
+ if (tasks === micro_tasks) run_micro_tasks();
602
+ });
603
+ }
604
+ micro_tasks.push(fn);
605
+ }
606
+ function flush_tasks() {
607
+ while (micro_tasks.length > 0) {
608
+ run_micro_tasks();
609
+ }
610
+ }
611
+ function handle_error(error) {
612
+ var effect = active_effect;
613
+ if (effect === null) {
614
+ active_reaction.f |= ERROR_VALUE;
615
+ return error;
616
+ }
617
+ if ((effect.f & REACTION_RAN) === 0 && (effect.f & EFFECT) === 0) {
618
+ throw error;
619
+ }
620
+ invoke_error_boundary(error, effect);
621
+ }
622
+ function invoke_error_boundary(error, effect) {
623
+ while (effect !== null) {
624
+ if ((effect.f & BOUNDARY_EFFECT) !== 0) {
625
+ if ((effect.f & REACTION_RAN) === 0) {
626
+ throw error;
627
+ }
628
+ try {
629
+ effect.b.error(error);
630
+ return;
631
+ } catch (e) {
632
+ error = e;
633
+ }
634
+ }
635
+ effect = effect.parent;
636
+ }
637
+ throw error;
638
+ }
639
+ const STATUS_MASK = -7169;
640
+ function set_signal_status(signal, status) {
641
+ signal.f = signal.f & STATUS_MASK | status;
642
+ }
643
+ function update_derived_status(derived2) {
644
+ if ((derived2.f & CONNECTED) !== 0 || derived2.deps === null) {
645
+ set_signal_status(derived2, CLEAN);
646
+ } else {
647
+ set_signal_status(derived2, MAYBE_DIRTY);
648
+ }
649
+ }
650
+ function clear_marked(deps) {
651
+ if (deps === null) return;
652
+ for (const dep of deps) {
653
+ if ((dep.f & DERIVED) === 0 || (dep.f & WAS_MARKED) === 0) {
654
+ continue;
655
+ }
656
+ dep.f ^= WAS_MARKED;
657
+ clear_marked(
658
+ /** @type {Derived} */
659
+ dep.deps
660
+ );
661
+ }
662
+ }
663
+ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
664
+ if ((effect.f & DIRTY) !== 0) {
665
+ dirty_effects.add(effect);
666
+ } else if ((effect.f & MAYBE_DIRTY) !== 0) {
667
+ maybe_dirty_effects.add(effect);
668
+ }
669
+ clear_marked(effect.deps);
670
+ set_signal_status(effect, CLEAN);
671
+ }
672
+ const batches = /* @__PURE__ */ new Set();
673
+ let current_batch = null;
674
+ let batch_values = null;
675
+ let last_scheduled_effect = null;
676
+ let is_flushing_sync = false;
677
+ let is_processing = false;
678
+ let collected_effects = null;
679
+ let legacy_updates = null;
680
+ var flush_count = 0;
681
+ let uid = 1;
682
+ class Batch {
683
+ // for debugging. TODO remove once async is stable
684
+ id = uid++;
685
+ /**
686
+ * The current values of any sources that are updated in this batch
687
+ * They keys of this map are identical to `this.#previous`
688
+ * @type {Map<Source, any>}
689
+ */
690
+ current = /* @__PURE__ */ new Map();
691
+ /**
692
+ * The values of any sources that are updated in this batch _before_ those updates took place.
693
+ * They keys of this map are identical to `this.#current`
694
+ * @type {Map<Source, any>}
695
+ */
696
+ previous = /* @__PURE__ */ new Map();
697
+ /**
698
+ * When the batch is committed (and the DOM is updated), we need to remove old branches
699
+ * and append new ones by calling the functions added inside (if/each/key/etc) blocks
700
+ * @type {Set<(batch: Batch) => void>}
701
+ */
702
+ #commit_callbacks = /* @__PURE__ */ new Set();
703
+ /**
704
+ * If a fork is discarded, we need to destroy any effects that are no longer needed
705
+ * @type {Set<(batch: Batch) => void>}
706
+ */
707
+ #discard_callbacks = /* @__PURE__ */ new Set();
708
+ /**
709
+ * The number of async effects that are currently in flight
710
+ */
711
+ #pending = 0;
712
+ /**
713
+ * The number of async effects that are currently in flight, _not_ inside a pending boundary
714
+ */
715
+ #blocking_pending = 0;
716
+ /**
717
+ * A deferred that resolves when the batch is committed, used with `settled()`
718
+ * TODO replace with Promise.withResolvers once supported widely enough
719
+ * @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
720
+ */
721
+ #deferred = null;
722
+ /**
723
+ * The root effects that need to be flushed
724
+ * @type {Effect[]}
725
+ */
726
+ #roots = [];
727
+ /**
728
+ * Deferred effects (which run after async work has completed) that are DIRTY
729
+ * @type {Set<Effect>}
730
+ */
731
+ #dirty_effects = /* @__PURE__ */ new Set();
732
+ /**
733
+ * Deferred effects that are MAYBE_DIRTY
734
+ * @type {Set<Effect>}
735
+ */
736
+ #maybe_dirty_effects = /* @__PURE__ */ new Set();
737
+ /**
738
+ * A map of branches that still exist, but will be destroyed when this batch
739
+ * is committed — we skip over these during `process`.
740
+ * The value contains child effects that were dirty/maybe_dirty before being reset,
741
+ * so they can be rescheduled if the branch survives.
742
+ * @type {Map<Effect, { d: Effect[], m: Effect[] }>}
743
+ */
744
+ #skipped_branches = /* @__PURE__ */ new Map();
745
+ is_fork = false;
746
+ #decrement_queued = false;
747
+ #is_deferred() {
748
+ return this.is_fork || this.#blocking_pending > 0;
749
+ }
750
+ /**
751
+ * Add an effect to the #skipped_branches map and reset its children
752
+ * @param {Effect} effect
753
+ */
754
+ skip_effect(effect) {
755
+ if (!this.#skipped_branches.has(effect)) {
756
+ this.#skipped_branches.set(effect, { d: [], m: [] });
757
+ }
758
+ }
759
+ /**
760
+ * Remove an effect from the #skipped_branches map and reschedule
761
+ * any tracked dirty/maybe_dirty child effects
762
+ * @param {Effect} effect
763
+ */
764
+ unskip_effect(effect) {
765
+ var tracked = this.#skipped_branches.get(effect);
766
+ if (tracked) {
767
+ this.#skipped_branches.delete(effect);
768
+ for (var e of tracked.d) {
769
+ set_signal_status(e, DIRTY);
770
+ this.schedule(e);
771
+ }
772
+ for (e of tracked.m) {
773
+ set_signal_status(e, MAYBE_DIRTY);
774
+ this.schedule(e);
775
+ }
776
+ }
777
+ }
778
+ #process() {
779
+ if (flush_count++ > 1e3) {
780
+ infinite_loop_guard();
781
+ }
782
+ const roots = this.#roots;
783
+ this.#roots = [];
784
+ this.apply();
785
+ var effects = collected_effects = [];
786
+ var render_effects = [];
787
+ var updates = legacy_updates = [];
788
+ for (const root of roots) {
789
+ this.#traverse(root, effects, render_effects);
790
+ }
791
+ current_batch = null;
792
+ if (updates.length > 0) {
793
+ var batch = Batch.ensure();
794
+ for (const e of updates) {
795
+ batch.schedule(e);
796
+ }
797
+ }
798
+ collected_effects = null;
799
+ legacy_updates = null;
800
+ if (this.#is_deferred()) {
801
+ this.#defer_effects(render_effects);
802
+ this.#defer_effects(effects);
803
+ for (const [e, t] of this.#skipped_branches) {
804
+ reset_branch(e, t);
805
+ }
806
+ } else {
807
+ this.#dirty_effects.clear();
808
+ this.#maybe_dirty_effects.clear();
809
+ for (const fn of this.#commit_callbacks) fn(this);
810
+ this.#commit_callbacks.clear();
811
+ flush_queued_effects(render_effects);
812
+ flush_queued_effects(effects);
813
+ if (this.#pending === 0) {
814
+ this.#commit();
815
+ }
816
+ this.#deferred?.resolve();
817
+ }
818
+ var next_batch = (
819
+ /** @type {Batch | null} */
820
+ /** @type {unknown} */
821
+ current_batch
822
+ );
823
+ if (next_batch !== null) {
824
+ batches.add(next_batch);
825
+ next_batch.#process();
826
+ }
827
+ }
828
+ /**
829
+ * Traverse the effect tree, executing effects or stashing
830
+ * them for later execution as appropriate
831
+ * @param {Effect} root
832
+ * @param {Effect[]} effects
833
+ * @param {Effect[]} render_effects
834
+ */
835
+ #traverse(root, effects, render_effects) {
836
+ root.f ^= CLEAN;
837
+ var effect = root.first;
838
+ while (effect !== null) {
839
+ var flags = effect.f;
840
+ var is_branch = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
841
+ var is_skippable_branch = is_branch && (flags & CLEAN) !== 0;
842
+ var skip = is_skippable_branch || (flags & INERT) !== 0 || this.#skipped_branches.has(effect);
843
+ if (!skip && effect.fn !== null) {
844
+ if (is_branch) {
845
+ effect.f ^= CLEAN;
846
+ } else if ((flags & EFFECT) !== 0) {
847
+ effects.push(effect);
848
+ } else if (is_dirty(effect)) {
849
+ if ((flags & BLOCK_EFFECT) !== 0) this.#maybe_dirty_effects.add(effect);
850
+ update_effect(effect);
851
+ }
852
+ var child = effect.first;
853
+ if (child !== null) {
854
+ effect = child;
855
+ continue;
856
+ }
857
+ }
858
+ while (effect !== null) {
859
+ var next = effect.next;
860
+ if (next !== null) {
861
+ effect = next;
862
+ break;
863
+ }
864
+ effect = effect.parent;
865
+ }
866
+ }
867
+ }
868
+ /**
869
+ * @param {Effect[]} effects
870
+ */
871
+ #defer_effects(effects) {
872
+ for (var i = 0; i < effects.length; i += 1) {
873
+ defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects);
874
+ }
875
+ }
876
+ /**
877
+ * Associate a change to a given source with the current
878
+ * batch, noting its previous and current values
879
+ * @param {Source} source
880
+ * @param {any} value
881
+ */
882
+ capture(source2, value) {
883
+ if (value !== UNINITIALIZED && !this.previous.has(source2)) {
884
+ this.previous.set(source2, value);
885
+ }
886
+ if ((source2.f & ERROR_VALUE) === 0) {
887
+ this.current.set(source2, source2.v);
888
+ batch_values?.set(source2, source2.v);
889
+ }
890
+ }
891
+ activate() {
892
+ current_batch = this;
893
+ }
894
+ deactivate() {
895
+ current_batch = null;
896
+ batch_values = null;
897
+ }
898
+ flush() {
899
+ try {
900
+ is_processing = true;
901
+ current_batch = this;
902
+ if (!this.#is_deferred()) {
903
+ for (const e of this.#dirty_effects) {
904
+ this.#maybe_dirty_effects.delete(e);
905
+ set_signal_status(e, DIRTY);
906
+ this.schedule(e);
907
+ }
908
+ for (const e of this.#maybe_dirty_effects) {
909
+ set_signal_status(e, MAYBE_DIRTY);
910
+ this.schedule(e);
911
+ }
912
+ }
913
+ this.#process();
914
+ } finally {
915
+ flush_count = 0;
916
+ last_scheduled_effect = null;
917
+ collected_effects = null;
918
+ legacy_updates = null;
919
+ is_processing = false;
920
+ current_batch = null;
921
+ batch_values = null;
922
+ old_values.clear();
923
+ }
924
+ }
925
+ discard() {
926
+ for (const fn of this.#discard_callbacks) fn(this);
927
+ this.#discard_callbacks.clear();
928
+ }
929
+ #commit() {
930
+ if (batches.size > 1) {
931
+ this.previous.clear();
932
+ var previous_batch = current_batch;
933
+ var previous_batch_values = batch_values;
934
+ var is_earlier = true;
935
+ for (const batch of batches) {
936
+ if (batch === this) {
937
+ is_earlier = false;
938
+ continue;
939
+ }
940
+ const sources = [];
941
+ for (const [source2, value] of this.current) {
942
+ if (batch.current.has(source2)) {
943
+ if (is_earlier && value !== batch.current.get(source2)) {
944
+ batch.current.set(source2, value);
945
+ } else {
946
+ continue;
947
+ }
948
+ }
949
+ sources.push(source2);
950
+ }
951
+ if (sources.length === 0) {
952
+ continue;
953
+ }
954
+ const others = [...batch.current.keys()].filter((s) => !this.current.has(s));
955
+ if (others.length > 0) {
956
+ batch.activate();
957
+ const marked = /* @__PURE__ */ new Set();
958
+ const checked = /* @__PURE__ */ new Map();
959
+ for (const source2 of sources) {
960
+ mark_effects(source2, others, marked, checked);
961
+ }
962
+ if (batch.#roots.length > 0) {
963
+ batch.apply();
964
+ for (const root of batch.#roots) {
965
+ batch.#traverse(root, [], []);
966
+ }
967
+ }
968
+ batch.deactivate();
969
+ }
970
+ }
971
+ current_batch = previous_batch;
972
+ batch_values = previous_batch_values;
973
+ }
974
+ this.#skipped_branches.clear();
975
+ batches.delete(this);
976
+ }
977
+ /**
978
+ *
979
+ * @param {boolean} blocking
980
+ */
981
+ increment(blocking) {
982
+ this.#pending += 1;
983
+ if (blocking) this.#blocking_pending += 1;
984
+ }
985
+ /**
986
+ * @param {boolean} blocking
987
+ * @param {boolean} skip - whether to skip updates (because this is triggered by a stale reaction)
988
+ */
989
+ decrement(blocking, skip) {
990
+ this.#pending -= 1;
991
+ if (blocking) this.#blocking_pending -= 1;
992
+ if (this.#decrement_queued || skip) return;
993
+ this.#decrement_queued = true;
994
+ queue_micro_task(() => {
995
+ this.#decrement_queued = false;
996
+ this.flush();
997
+ });
998
+ }
999
+ /** @param {(batch: Batch) => void} fn */
1000
+ oncommit(fn) {
1001
+ this.#commit_callbacks.add(fn);
1002
+ }
1003
+ /** @param {(batch: Batch) => void} fn */
1004
+ ondiscard(fn) {
1005
+ this.#discard_callbacks.add(fn);
1006
+ }
1007
+ settled() {
1008
+ return (this.#deferred ??= deferred()).promise;
1009
+ }
1010
+ static ensure() {
1011
+ if (current_batch === null) {
1012
+ const batch = current_batch = new Batch();
1013
+ if (!is_processing) {
1014
+ batches.add(current_batch);
1015
+ if (!is_flushing_sync) {
1016
+ queue_micro_task(() => {
1017
+ if (current_batch !== batch) {
1018
+ return;
1019
+ }
1020
+ batch.flush();
1021
+ });
1022
+ }
1023
+ }
1024
+ }
1025
+ return current_batch;
1026
+ }
1027
+ apply() {
1028
+ return;
1029
+ }
1030
+ /**
1031
+ *
1032
+ * @param {Effect} effect
1033
+ */
1034
+ schedule(effect) {
1035
+ last_scheduled_effect = effect;
1036
+ if (effect.b?.is_pending && (effect.f & (EFFECT | RENDER_EFFECT | MANAGED_EFFECT)) !== 0 && (effect.f & REACTION_RAN) === 0) {
1037
+ effect.b.defer_effect(effect);
1038
+ return;
1039
+ }
1040
+ var e = effect;
1041
+ while (e.parent !== null) {
1042
+ e = e.parent;
1043
+ var flags = e.f;
1044
+ if (collected_effects !== null && e === active_effect) {
1045
+ if ((active_reaction === null || (active_reaction.f & DERIVED) === 0) && true) {
1046
+ return;
1047
+ }
1048
+ }
1049
+ if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
1050
+ if ((flags & CLEAN) === 0) {
1051
+ return;
1052
+ }
1053
+ e.f ^= CLEAN;
1054
+ }
1055
+ }
1056
+ this.#roots.push(e);
1057
+ }
1058
+ }
1059
+ function flushSync(fn) {
1060
+ var was_flushing_sync = is_flushing_sync;
1061
+ is_flushing_sync = true;
1062
+ try {
1063
+ var result;
1064
+ if (fn) ;
1065
+ while (true) {
1066
+ flush_tasks();
1067
+ if (current_batch === null) {
1068
+ return (
1069
+ /** @type {T} */
1070
+ result
1071
+ );
1072
+ }
1073
+ current_batch.flush();
1074
+ }
1075
+ } finally {
1076
+ is_flushing_sync = was_flushing_sync;
1077
+ }
1078
+ }
1079
+ function infinite_loop_guard() {
1080
+ try {
1081
+ effect_update_depth_exceeded();
1082
+ } catch (error) {
1083
+ invoke_error_boundary(error, last_scheduled_effect);
1084
+ }
1085
+ }
1086
+ let eager_block_effects = null;
1087
+ function flush_queued_effects(effects) {
1088
+ var length = effects.length;
1089
+ if (length === 0) return;
1090
+ var i = 0;
1091
+ while (i < length) {
1092
+ var effect = effects[i++];
1093
+ if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) {
1094
+ eager_block_effects = /* @__PURE__ */ new Set();
1095
+ update_effect(effect);
1096
+ if (effect.deps === null && effect.first === null && effect.nodes === null && effect.teardown === null && effect.ac === null) {
1097
+ unlink_effect(effect);
1098
+ }
1099
+ if (eager_block_effects?.size > 0) {
1100
+ old_values.clear();
1101
+ for (const e of eager_block_effects) {
1102
+ if ((e.f & (DESTROYED | INERT)) !== 0) continue;
1103
+ const ordered_effects = [e];
1104
+ let ancestor = e.parent;
1105
+ while (ancestor !== null) {
1106
+ if (eager_block_effects.has(ancestor)) {
1107
+ eager_block_effects.delete(ancestor);
1108
+ ordered_effects.push(ancestor);
1109
+ }
1110
+ ancestor = ancestor.parent;
1111
+ }
1112
+ for (let j = ordered_effects.length - 1; j >= 0; j--) {
1113
+ const e2 = ordered_effects[j];
1114
+ if ((e2.f & (DESTROYED | INERT)) !== 0) continue;
1115
+ update_effect(e2);
1116
+ }
1117
+ }
1118
+ eager_block_effects.clear();
1119
+ }
1120
+ }
1121
+ }
1122
+ eager_block_effects = null;
1123
+ }
1124
+ function mark_effects(value, sources, marked, checked) {
1125
+ if (marked.has(value)) return;
1126
+ marked.add(value);
1127
+ if (value.reactions !== null) {
1128
+ for (const reaction of value.reactions) {
1129
+ const flags = reaction.f;
1130
+ if ((flags & DERIVED) !== 0) {
1131
+ mark_effects(
1132
+ /** @type {Derived} */
1133
+ reaction,
1134
+ sources,
1135
+ marked,
1136
+ checked
1137
+ );
1138
+ } else if ((flags & (ASYNC | BLOCK_EFFECT)) !== 0 && (flags & DIRTY) === 0 && depends_on(reaction, sources, checked)) {
1139
+ set_signal_status(reaction, DIRTY);
1140
+ schedule_effect(
1141
+ /** @type {Effect} */
1142
+ reaction
1143
+ );
1144
+ }
1145
+ }
1146
+ }
1147
+ }
1148
+ function depends_on(reaction, sources, checked) {
1149
+ const depends = checked.get(reaction);
1150
+ if (depends !== void 0) return depends;
1151
+ if (reaction.deps !== null) {
1152
+ for (const dep of reaction.deps) {
1153
+ if (includes.call(sources, dep)) {
1154
+ return true;
1155
+ }
1156
+ if ((dep.f & DERIVED) !== 0 && depends_on(
1157
+ /** @type {Derived} */
1158
+ dep,
1159
+ sources,
1160
+ checked
1161
+ )) {
1162
+ checked.set(
1163
+ /** @type {Derived} */
1164
+ dep,
1165
+ true
1166
+ );
1167
+ return true;
1168
+ }
1169
+ }
1170
+ }
1171
+ checked.set(reaction, false);
1172
+ return false;
1173
+ }
1174
+ function schedule_effect(effect) {
1175
+ current_batch.schedule(effect);
1176
+ }
1177
+ function reset_branch(effect, tracked) {
1178
+ if ((effect.f & BRANCH_EFFECT) !== 0 && (effect.f & CLEAN) !== 0) {
1179
+ return;
1180
+ }
1181
+ if ((effect.f & DIRTY) !== 0) {
1182
+ tracked.d.push(effect);
1183
+ } else if ((effect.f & MAYBE_DIRTY) !== 0) {
1184
+ tracked.m.push(effect);
1185
+ }
1186
+ set_signal_status(effect, CLEAN);
1187
+ var e = effect.first;
1188
+ while (e !== null) {
1189
+ reset_branch(e, tracked);
1190
+ e = e.next;
1191
+ }
1192
+ }
1193
+ function destroy_derived_effects(derived2) {
1194
+ var effects = derived2.effects;
1195
+ if (effects !== null) {
1196
+ derived2.effects = null;
1197
+ for (var i = 0; i < effects.length; i += 1) {
1198
+ destroy_effect(
1199
+ /** @type {Effect} */
1200
+ effects[i]
1201
+ );
1202
+ }
1203
+ }
1204
+ }
1205
+ function get_derived_parent_effect(derived2) {
1206
+ var parent = derived2.parent;
1207
+ while (parent !== null) {
1208
+ if ((parent.f & DERIVED) === 0) {
1209
+ return (parent.f & DESTROYED) === 0 ? (
1210
+ /** @type {Effect} */
1211
+ parent
1212
+ ) : null;
1213
+ }
1214
+ parent = parent.parent;
1215
+ }
1216
+ return null;
1217
+ }
1218
+ function execute_derived(derived2) {
1219
+ var value;
1220
+ var prev_active_effect = active_effect;
1221
+ set_active_effect(get_derived_parent_effect(derived2));
1222
+ {
1223
+ try {
1224
+ derived2.f &= ~WAS_MARKED;
1225
+ destroy_derived_effects(derived2);
1226
+ value = update_reaction(derived2);
1227
+ } finally {
1228
+ set_active_effect(prev_active_effect);
1229
+ }
1230
+ }
1231
+ return value;
1232
+ }
1233
+ function update_derived(derived2) {
1234
+ var value = execute_derived(derived2);
1235
+ if (!derived2.equals(value)) {
1236
+ derived2.wv = increment_write_version();
1237
+ if (!current_batch?.is_fork || derived2.deps === null) {
1238
+ derived2.v = value;
1239
+ if (derived2.deps === null) {
1240
+ set_signal_status(derived2, CLEAN);
1241
+ return;
1242
+ }
1243
+ }
1244
+ }
1245
+ if (is_destroying_effect) {
1246
+ return;
1247
+ }
1248
+ if (batch_values !== null) {
1249
+ if (effect_tracking() || current_batch?.is_fork) {
1250
+ batch_values.set(derived2, value);
1251
+ }
1252
+ } else {
1253
+ update_derived_status(derived2);
1254
+ }
1255
+ }
1256
+ function freeze_derived_effects(derived2) {
1257
+ if (derived2.effects === null) return;
1258
+ for (const e of derived2.effects) {
1259
+ if (e.teardown || e.ac) {
1260
+ e.teardown?.();
1261
+ e.ac?.abort(STALE_REACTION);
1262
+ e.teardown = noop;
1263
+ e.ac = null;
1264
+ remove_reactions(e, 0);
1265
+ destroy_effect_children(e);
1266
+ }
1267
+ }
1268
+ }
1269
+ function unfreeze_derived_effects(derived2) {
1270
+ if (derived2.effects === null) return;
1271
+ for (const e of derived2.effects) {
1272
+ if (e.teardown) {
1273
+ update_effect(e);
1274
+ }
1275
+ }
1276
+ }
1277
+ let eager_effects = /* @__PURE__ */ new Set();
1278
+ const old_values = /* @__PURE__ */ new Map();
1279
+ let eager_effects_deferred = false;
1280
+ function source(v, stack) {
1281
+ var signal = {
1282
+ f: 0,
1283
+ // TODO ideally we could skip this altogether, but it causes type errors
1284
+ v,
1285
+ reactions: null,
1286
+ equals,
1287
+ rv: 0,
1288
+ wv: 0
1289
+ };
1290
+ return signal;
1291
+ }
1292
+ // @__NO_SIDE_EFFECTS__
1293
+ function state(v, stack) {
1294
+ const s = source(v);
1295
+ push_reaction_value(s);
1296
+ return s;
1297
+ }
1298
+ // @__NO_SIDE_EFFECTS__
1299
+ function mutable_source(initial_value, immutable = false, trackable = true) {
1300
+ const s = source(initial_value);
1301
+ if (!immutable) {
1302
+ s.equals = safe_equals;
1303
+ }
1304
+ return s;
1305
+ }
1306
+ function set(source2, value, should_proxy = false) {
1307
+ if (active_reaction !== null && // since we are untracking the function inside `$inspect.with` we need to add this check
1308
+ // to ensure we error if state is set inside an inspect effect
1309
+ (!untracking || (active_reaction.f & EAGER_EFFECT) !== 0) && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | EAGER_EFFECT)) !== 0 && (current_sources === null || !includes.call(current_sources, source2))) {
1310
+ state_unsafe_mutation();
1311
+ }
1312
+ let new_value = should_proxy ? proxy(value) : value;
1313
+ return internal_set(source2, new_value, legacy_updates);
1314
+ }
1315
+ function internal_set(source2, value, updated_during_traversal = null) {
1316
+ if (!source2.equals(value)) {
1317
+ var old_value = source2.v;
1318
+ if (is_destroying_effect) {
1319
+ old_values.set(source2, value);
1320
+ } else {
1321
+ old_values.set(source2, old_value);
1322
+ }
1323
+ source2.v = value;
1324
+ var batch = Batch.ensure();
1325
+ batch.capture(source2, old_value);
1326
+ if ((source2.f & DERIVED) !== 0) {
1327
+ const derived2 = (
1328
+ /** @type {Derived} */
1329
+ source2
1330
+ );
1331
+ if ((source2.f & DIRTY) !== 0) {
1332
+ execute_derived(derived2);
1333
+ }
1334
+ update_derived_status(derived2);
1335
+ }
1336
+ source2.wv = increment_write_version();
1337
+ mark_reactions(source2, DIRTY, updated_during_traversal);
1338
+ if (active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) {
1339
+ if (untracked_writes === null) {
1340
+ set_untracked_writes([source2]);
1341
+ } else {
1342
+ untracked_writes.push(source2);
1343
+ }
1344
+ }
1345
+ if (!batch.is_fork && eager_effects.size > 0 && !eager_effects_deferred) {
1346
+ flush_eager_effects();
1347
+ }
1348
+ }
1349
+ return value;
1350
+ }
1351
+ function flush_eager_effects() {
1352
+ eager_effects_deferred = false;
1353
+ for (const effect of eager_effects) {
1354
+ if ((effect.f & CLEAN) !== 0) {
1355
+ set_signal_status(effect, MAYBE_DIRTY);
1356
+ }
1357
+ if (is_dirty(effect)) {
1358
+ update_effect(effect);
1359
+ }
1360
+ }
1361
+ eager_effects.clear();
1362
+ }
1363
+ function increment(source2) {
1364
+ set(source2, source2.v + 1);
1365
+ }
1366
+ function mark_reactions(signal, status, updated_during_traversal) {
1367
+ var reactions = signal.reactions;
1368
+ if (reactions === null) return;
1369
+ var length = reactions.length;
1370
+ for (var i = 0; i < length; i++) {
1371
+ var reaction = reactions[i];
1372
+ var flags = reaction.f;
1373
+ var not_dirty = (flags & DIRTY) === 0;
1374
+ if (not_dirty) {
1375
+ set_signal_status(reaction, status);
1376
+ }
1377
+ if ((flags & DERIVED) !== 0) {
1378
+ var derived2 = (
1379
+ /** @type {Derived} */
1380
+ reaction
1381
+ );
1382
+ batch_values?.delete(derived2);
1383
+ if ((flags & WAS_MARKED) === 0) {
1384
+ if (flags & CONNECTED) {
1385
+ reaction.f |= WAS_MARKED;
1386
+ }
1387
+ mark_reactions(derived2, MAYBE_DIRTY, updated_during_traversal);
1388
+ }
1389
+ } else if (not_dirty) {
1390
+ var effect = (
1391
+ /** @type {Effect} */
1392
+ reaction
1393
+ );
1394
+ if ((flags & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {
1395
+ eager_block_effects.add(effect);
1396
+ }
1397
+ if (updated_during_traversal !== null) {
1398
+ updated_during_traversal.push(effect);
1399
+ } else {
1400
+ schedule_effect(effect);
1401
+ }
1402
+ }
1403
+ }
1404
+ }
1405
+ function proxy(value) {
1406
+ if (typeof value !== "object" || value === null || STATE_SYMBOL in value) {
1407
+ return value;
1408
+ }
1409
+ const prototype = get_prototype_of(value);
1410
+ if (prototype !== object_prototype && prototype !== array_prototype) {
1411
+ return value;
1412
+ }
1413
+ var sources = /* @__PURE__ */ new Map();
1414
+ var is_proxied_array = is_array(value);
1415
+ var version = /* @__PURE__ */ state(0);
1416
+ var parent_version = update_version;
1417
+ var with_parent = (fn) => {
1418
+ if (update_version === parent_version) {
1419
+ return fn();
1420
+ }
1421
+ var reaction = active_reaction;
1422
+ var version2 = update_version;
1423
+ set_active_reaction(null);
1424
+ set_update_version(parent_version);
1425
+ var result = fn();
1426
+ set_active_reaction(reaction);
1427
+ set_update_version(version2);
1428
+ return result;
1429
+ };
1430
+ if (is_proxied_array) {
1431
+ sources.set("length", /* @__PURE__ */ state(
1432
+ /** @type {any[]} */
1433
+ value.length
1434
+ ));
1435
+ }
1436
+ return new Proxy(
1437
+ /** @type {any} */
1438
+ value,
1439
+ {
1440
+ defineProperty(_, prop, descriptor) {
1441
+ if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) {
1442
+ state_descriptors_fixed();
1443
+ }
1444
+ var s = sources.get(prop);
1445
+ if (s === void 0) {
1446
+ with_parent(() => {
1447
+ var s2 = /* @__PURE__ */ state(descriptor.value);
1448
+ sources.set(prop, s2);
1449
+ return s2;
1450
+ });
1451
+ } else {
1452
+ set(s, descriptor.value, true);
1453
+ }
1454
+ return true;
1455
+ },
1456
+ deleteProperty(target, prop) {
1457
+ var s = sources.get(prop);
1458
+ if (s === void 0) {
1459
+ if (prop in target) {
1460
+ const s2 = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
1461
+ sources.set(prop, s2);
1462
+ increment(version);
1463
+ }
1464
+ } else {
1465
+ set(s, UNINITIALIZED);
1466
+ increment(version);
1467
+ }
1468
+ return true;
1469
+ },
1470
+ get(target, prop, receiver) {
1471
+ if (prop === STATE_SYMBOL) {
1472
+ return value;
1473
+ }
1474
+ var s = sources.get(prop);
1475
+ var exists = prop in target;
1476
+ if (s === void 0 && (!exists || get_descriptor(target, prop)?.writable)) {
1477
+ s = with_parent(() => {
1478
+ var p = proxy(exists ? target[prop] : UNINITIALIZED);
1479
+ var s2 = /* @__PURE__ */ state(p);
1480
+ return s2;
1481
+ });
1482
+ sources.set(prop, s);
1483
+ }
1484
+ if (s !== void 0) {
1485
+ var v = get$1(s);
1486
+ return v === UNINITIALIZED ? void 0 : v;
1487
+ }
1488
+ return Reflect.get(target, prop, receiver);
1489
+ },
1490
+ getOwnPropertyDescriptor(target, prop) {
1491
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1492
+ if (descriptor && "value" in descriptor) {
1493
+ var s = sources.get(prop);
1494
+ if (s) descriptor.value = get$1(s);
1495
+ } else if (descriptor === void 0) {
1496
+ var source2 = sources.get(prop);
1497
+ var value2 = source2?.v;
1498
+ if (source2 !== void 0 && value2 !== UNINITIALIZED) {
1499
+ return {
1500
+ enumerable: true,
1501
+ configurable: true,
1502
+ value: value2,
1503
+ writable: true
1504
+ };
1505
+ }
1506
+ }
1507
+ return descriptor;
1508
+ },
1509
+ has(target, prop) {
1510
+ if (prop === STATE_SYMBOL) {
1511
+ return true;
1512
+ }
1513
+ var s = sources.get(prop);
1514
+ var has = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop);
1515
+ if (s !== void 0 || active_effect !== null && (!has || get_descriptor(target, prop)?.writable)) {
1516
+ if (s === void 0) {
1517
+ s = with_parent(() => {
1518
+ var p = has ? proxy(target[prop]) : UNINITIALIZED;
1519
+ var s2 = /* @__PURE__ */ state(p);
1520
+ return s2;
1521
+ });
1522
+ sources.set(prop, s);
1523
+ }
1524
+ var value2 = get$1(s);
1525
+ if (value2 === UNINITIALIZED) {
1526
+ return false;
1527
+ }
1528
+ }
1529
+ return has;
1530
+ },
1531
+ set(target, prop, value2, receiver) {
1532
+ var s = sources.get(prop);
1533
+ var has = prop in target;
1534
+ if (is_proxied_array && prop === "length") {
1535
+ for (var i = value2; i < /** @type {Source<number>} */
1536
+ s.v; i += 1) {
1537
+ var other_s = sources.get(i + "");
1538
+ if (other_s !== void 0) {
1539
+ set(other_s, UNINITIALIZED);
1540
+ } else if (i in target) {
1541
+ other_s = with_parent(() => /* @__PURE__ */ state(UNINITIALIZED));
1542
+ sources.set(i + "", other_s);
1543
+ }
1544
+ }
1545
+ }
1546
+ if (s === void 0) {
1547
+ if (!has || get_descriptor(target, prop)?.writable) {
1548
+ s = with_parent(() => /* @__PURE__ */ state(void 0));
1549
+ set(s, proxy(value2));
1550
+ sources.set(prop, s);
1551
+ }
1552
+ } else {
1553
+ has = s.v !== UNINITIALIZED;
1554
+ var p = with_parent(() => proxy(value2));
1555
+ set(s, p);
1556
+ }
1557
+ var descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
1558
+ if (descriptor?.set) {
1559
+ descriptor.set.call(receiver, value2);
1560
+ }
1561
+ if (!has) {
1562
+ if (is_proxied_array && typeof prop === "string") {
1563
+ var ls = (
1564
+ /** @type {Source<number>} */
1565
+ sources.get("length")
1566
+ );
1567
+ var n = Number(prop);
1568
+ if (Number.isInteger(n) && n >= ls.v) {
1569
+ set(ls, n + 1);
1570
+ }
1571
+ }
1572
+ increment(version);
1573
+ }
1574
+ return true;
1575
+ },
1576
+ ownKeys(target) {
1577
+ get$1(version);
1578
+ var own_keys = Reflect.ownKeys(target).filter((key2) => {
1579
+ var source3 = sources.get(key2);
1580
+ return source3 === void 0 || source3.v !== UNINITIALIZED;
1581
+ });
1582
+ for (var [key, source2] of sources) {
1583
+ if (source2.v !== UNINITIALIZED && !(key in target)) {
1584
+ own_keys.push(key);
1585
+ }
1586
+ }
1587
+ return own_keys;
1588
+ },
1589
+ setPrototypeOf() {
1590
+ state_prototype_fixed();
1591
+ }
1592
+ }
1593
+ );
1594
+ }
1595
+ var $window;
1596
+ var first_child_getter;
1597
+ var next_sibling_getter;
1598
+ function init_operations() {
1599
+ if ($window !== void 0) {
1600
+ return;
1601
+ }
1602
+ $window = window;
1603
+ var element_prototype = Element.prototype;
1604
+ var node_prototype = Node.prototype;
1605
+ var text_prototype = Text.prototype;
1606
+ first_child_getter = get_descriptor(node_prototype, "firstChild").get;
1607
+ next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
1608
+ if (is_extensible(element_prototype)) {
1609
+ element_prototype.__click = void 0;
1610
+ element_prototype.__className = void 0;
1611
+ element_prototype.__attributes = null;
1612
+ element_prototype.__style = void 0;
1613
+ element_prototype.__e = void 0;
1614
+ }
1615
+ if (is_extensible(text_prototype)) {
1616
+ text_prototype.__t = void 0;
1617
+ }
1618
+ }
1619
+ function create_text(value = "") {
1620
+ return document.createTextNode(value);
1621
+ }
1622
+ // @__NO_SIDE_EFFECTS__
1623
+ function get_first_child(node) {
1624
+ return (
1625
+ /** @type {TemplateNode | null} */
1626
+ first_child_getter.call(node)
1627
+ );
1628
+ }
1629
+ // @__NO_SIDE_EFFECTS__
1630
+ function get_next_sibling(node) {
1631
+ return (
1632
+ /** @type {TemplateNode | null} */
1633
+ next_sibling_getter.call(node)
1634
+ );
1635
+ }
1636
+ function clear_text_content(node) {
1637
+ node.textContent = "";
1638
+ }
1639
+ function without_reactive_context(fn) {
1640
+ var previous_reaction = active_reaction;
1641
+ var previous_effect = active_effect;
1642
+ set_active_reaction(null);
1643
+ set_active_effect(null);
1644
+ try {
1645
+ return fn();
1646
+ } finally {
1647
+ set_active_reaction(previous_reaction);
1648
+ set_active_effect(previous_effect);
1649
+ }
1650
+ }
1651
+ function push_effect(effect, parent_effect) {
1652
+ var parent_last = parent_effect.last;
1653
+ if (parent_last === null) {
1654
+ parent_effect.last = parent_effect.first = effect;
1655
+ } else {
1656
+ parent_last.next = effect;
1657
+ effect.prev = parent_last;
1658
+ parent_effect.last = effect;
1659
+ }
1660
+ }
1661
+ function create_effect(type, fn) {
1662
+ var parent = active_effect;
1663
+ if (parent !== null && (parent.f & INERT) !== 0) {
1664
+ type |= INERT;
1665
+ }
1666
+ var effect = {
1667
+ ctx: component_context,
1668
+ deps: null,
1669
+ nodes: null,
1670
+ f: type | DIRTY | CONNECTED,
1671
+ first: null,
1672
+ fn,
1673
+ last: null,
1674
+ next: null,
1675
+ parent,
1676
+ b: parent && parent.b,
1677
+ prev: null,
1678
+ teardown: null,
1679
+ wv: 0,
1680
+ ac: null
1681
+ };
1682
+ var e = effect;
1683
+ if ((type & EFFECT) !== 0) {
1684
+ if (collected_effects !== null) {
1685
+ collected_effects.push(effect);
1686
+ } else {
1687
+ Batch.ensure().schedule(effect);
1688
+ }
1689
+ } else if (fn !== null) {
1690
+ try {
1691
+ update_effect(effect);
1692
+ } catch (e2) {
1693
+ destroy_effect(effect);
1694
+ throw e2;
1695
+ }
1696
+ if (e.deps === null && e.teardown === null && e.nodes === null && e.first === e.last && // either `null`, or a singular child
1697
+ (e.f & EFFECT_PRESERVED) === 0) {
1698
+ e = e.first;
1699
+ if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) {
1700
+ e.f |= EFFECT_TRANSPARENT;
1701
+ }
1702
+ }
1703
+ }
1704
+ if (e !== null) {
1705
+ e.parent = parent;
1706
+ if (parent !== null) {
1707
+ push_effect(e, parent);
1708
+ }
1709
+ if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0 && (type & ROOT_EFFECT) === 0) {
1710
+ var derived2 = (
1711
+ /** @type {Derived} */
1712
+ active_reaction
1713
+ );
1714
+ (derived2.effects ??= []).push(e);
1715
+ }
1716
+ }
1717
+ return effect;
1718
+ }
1719
+ function effect_tracking() {
1720
+ return active_reaction !== null && !untracking;
1721
+ }
1722
+ function create_user_effect(fn) {
1723
+ return create_effect(EFFECT | USER_EFFECT, fn);
1724
+ }
1725
+ function component_root(fn) {
1726
+ Batch.ensure();
1727
+ const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn);
1728
+ return (options = {}) => {
1729
+ return new Promise((fulfil) => {
1730
+ if (options.outro) {
1731
+ pause_effect(effect, () => {
1732
+ destroy_effect(effect);
1733
+ fulfil(void 0);
1734
+ });
1735
+ } else {
1736
+ destroy_effect(effect);
1737
+ fulfil(void 0);
1738
+ }
1739
+ });
1740
+ };
1741
+ }
1742
+ function render_effect(fn, flags = 0) {
1743
+ return create_effect(RENDER_EFFECT | flags, fn);
1744
+ }
1745
+ function block(fn, flags = 0) {
1746
+ var effect = create_effect(BLOCK_EFFECT | flags, fn);
1747
+ return effect;
1748
+ }
1749
+ function branch(fn) {
1750
+ return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn);
1751
+ }
1752
+ function execute_effect_teardown(effect) {
1753
+ var teardown = effect.teardown;
1754
+ if (teardown !== null) {
1755
+ const previously_destroying_effect = is_destroying_effect;
1756
+ const previous_reaction = active_reaction;
1757
+ set_is_destroying_effect(true);
1758
+ set_active_reaction(null);
1759
+ try {
1760
+ teardown.call(null);
1761
+ } finally {
1762
+ set_is_destroying_effect(previously_destroying_effect);
1763
+ set_active_reaction(previous_reaction);
1764
+ }
1765
+ }
1766
+ }
1767
+ function destroy_effect_children(signal, remove_dom = false) {
1768
+ var effect = signal.first;
1769
+ signal.first = signal.last = null;
1770
+ while (effect !== null) {
1771
+ const controller2 = effect.ac;
1772
+ if (controller2 !== null) {
1773
+ without_reactive_context(() => {
1774
+ controller2.abort(STALE_REACTION);
1775
+ });
1776
+ }
1777
+ var next = effect.next;
1778
+ if ((effect.f & ROOT_EFFECT) !== 0) {
1779
+ effect.parent = null;
1780
+ } else {
1781
+ destroy_effect(effect, remove_dom);
1782
+ }
1783
+ effect = next;
1784
+ }
1785
+ }
1786
+ function destroy_block_effect_children(signal) {
1787
+ var effect = signal.first;
1788
+ while (effect !== null) {
1789
+ var next = effect.next;
1790
+ if ((effect.f & BRANCH_EFFECT) === 0) {
1791
+ destroy_effect(effect);
1792
+ }
1793
+ effect = next;
1794
+ }
1795
+ }
1796
+ function destroy_effect(effect, remove_dom = true) {
1797
+ var removed = false;
1798
+ if ((remove_dom || (effect.f & HEAD_EFFECT) !== 0) && effect.nodes !== null && effect.nodes.end !== null) {
1799
+ remove_effect_dom(
1800
+ effect.nodes.start,
1801
+ /** @type {TemplateNode} */
1802
+ effect.nodes.end
1803
+ );
1804
+ removed = true;
1805
+ }
1806
+ set_signal_status(effect, DESTROYING);
1807
+ destroy_effect_children(effect, remove_dom && !removed);
1808
+ remove_reactions(effect, 0);
1809
+ var transitions = effect.nodes && effect.nodes.t;
1810
+ if (transitions !== null) {
1811
+ for (const transition of transitions) {
1812
+ transition.stop();
1813
+ }
1814
+ }
1815
+ execute_effect_teardown(effect);
1816
+ effect.f ^= DESTROYING;
1817
+ effect.f |= DESTROYED;
1818
+ var parent = effect.parent;
1819
+ if (parent !== null && parent.first !== null) {
1820
+ unlink_effect(effect);
1821
+ }
1822
+ effect.next = effect.prev = effect.teardown = effect.ctx = effect.deps = effect.fn = effect.nodes = effect.ac = null;
1823
+ }
1824
+ function remove_effect_dom(node, end) {
1825
+ while (node !== null) {
1826
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
1827
+ node.remove();
1828
+ node = next;
1829
+ }
1830
+ }
1831
+ function unlink_effect(effect) {
1832
+ var parent = effect.parent;
1833
+ var prev = effect.prev;
1834
+ var next = effect.next;
1835
+ if (prev !== null) prev.next = next;
1836
+ if (next !== null) next.prev = prev;
1837
+ if (parent !== null) {
1838
+ if (parent.first === effect) parent.first = next;
1839
+ if (parent.last === effect) parent.last = prev;
1840
+ }
1841
+ }
1842
+ function pause_effect(effect, callback, destroy = true) {
1843
+ var transitions = [];
1844
+ pause_children(effect, transitions, true);
1845
+ var fn = () => {
1846
+ if (destroy) destroy_effect(effect);
1847
+ if (callback) callback();
1848
+ };
1849
+ var remaining = transitions.length;
1850
+ if (remaining > 0) {
1851
+ var check = () => --remaining || fn();
1852
+ for (var transition of transitions) {
1853
+ transition.out(check);
1854
+ }
1855
+ } else {
1856
+ fn();
1857
+ }
1858
+ }
1859
+ function pause_children(effect, transitions, local) {
1860
+ if ((effect.f & INERT) !== 0) return;
1861
+ effect.f ^= INERT;
1862
+ var t = effect.nodes && effect.nodes.t;
1863
+ if (t !== null) {
1864
+ for (const transition of t) {
1865
+ if (transition.is_global || local) {
1866
+ transitions.push(transition);
1867
+ }
1868
+ }
1869
+ }
1870
+ var child = effect.first;
1871
+ while (child !== null) {
1872
+ var sibling = child.next;
1873
+ var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || // If this is a branch effect without a block effect parent,
1874
+ // it means the parent block effect was pruned. In that case,
1875
+ // transparency information was transferred to the branch effect.
1876
+ (child.f & BRANCH_EFFECT) !== 0 && (effect.f & BLOCK_EFFECT) !== 0;
1877
+ pause_children(child, transitions, transparent ? local : false);
1878
+ child = sibling;
1879
+ }
1880
+ }
1881
+ function move_effect(effect, fragment) {
1882
+ if (!effect.nodes) return;
1883
+ var node = effect.nodes.start;
1884
+ var end = effect.nodes.end;
1885
+ while (node !== null) {
1886
+ var next = node === end ? null : /* @__PURE__ */ get_next_sibling(node);
1887
+ fragment.append(node);
1888
+ node = next;
1889
+ }
1890
+ }
1891
+ let is_updating_effect = false;
1892
+ let is_destroying_effect = false;
1893
+ function set_is_destroying_effect(value) {
1894
+ is_destroying_effect = value;
1895
+ }
1896
+ let active_reaction = null;
1897
+ let untracking = false;
1898
+ function set_active_reaction(reaction) {
1899
+ active_reaction = reaction;
1900
+ }
1901
+ let active_effect = null;
1902
+ function set_active_effect(effect) {
1903
+ active_effect = effect;
1904
+ }
1905
+ let current_sources = null;
1906
+ function push_reaction_value(value) {
1907
+ if (active_reaction !== null && true) {
1908
+ if (current_sources === null) {
1909
+ current_sources = [value];
1910
+ } else {
1911
+ current_sources.push(value);
1912
+ }
1913
+ }
1914
+ }
1915
+ let new_deps = null;
1916
+ let skipped_deps = 0;
1917
+ let untracked_writes = null;
1918
+ function set_untracked_writes(value) {
1919
+ untracked_writes = value;
1920
+ }
1921
+ let write_version = 1;
1922
+ let read_version = 0;
1923
+ let update_version = read_version;
1924
+ function set_update_version(value) {
1925
+ update_version = value;
1926
+ }
1927
+ function increment_write_version() {
1928
+ return ++write_version;
1929
+ }
1930
+ function is_dirty(reaction) {
1931
+ var flags = reaction.f;
1932
+ if ((flags & DIRTY) !== 0) {
1933
+ return true;
1934
+ }
1935
+ if (flags & DERIVED) {
1936
+ reaction.f &= ~WAS_MARKED;
1937
+ }
1938
+ if ((flags & MAYBE_DIRTY) !== 0) {
1939
+ var dependencies = (
1940
+ /** @type {Value[]} */
1941
+ reaction.deps
1942
+ );
1943
+ var length = dependencies.length;
1944
+ for (var i = 0; i < length; i++) {
1945
+ var dependency = dependencies[i];
1946
+ if (is_dirty(
1947
+ /** @type {Derived} */
1948
+ dependency
1949
+ )) {
1950
+ update_derived(
1951
+ /** @type {Derived} */
1952
+ dependency
1953
+ );
1954
+ }
1955
+ if (dependency.wv > reaction.wv) {
1956
+ return true;
1957
+ }
1958
+ }
1959
+ if ((flags & CONNECTED) !== 0 && // During time traveling we don't want to reset the status so that
1960
+ // traversal of the graph in the other batches still happens
1961
+ batch_values === null) {
1962
+ set_signal_status(reaction, CLEAN);
1963
+ }
1964
+ }
1965
+ return false;
1966
+ }
1967
+ function schedule_possible_effect_self_invalidation(signal, effect, root = true) {
1968
+ var reactions = signal.reactions;
1969
+ if (reactions === null) return;
1970
+ if (current_sources !== null && includes.call(current_sources, signal)) {
1971
+ return;
1972
+ }
1973
+ for (var i = 0; i < reactions.length; i++) {
1974
+ var reaction = reactions[i];
1975
+ if ((reaction.f & DERIVED) !== 0) {
1976
+ schedule_possible_effect_self_invalidation(
1977
+ /** @type {Derived} */
1978
+ reaction,
1979
+ effect,
1980
+ false
1981
+ );
1982
+ } else if (effect === reaction) {
1983
+ if (root) {
1984
+ set_signal_status(reaction, DIRTY);
1985
+ } else if ((reaction.f & CLEAN) !== 0) {
1986
+ set_signal_status(reaction, MAYBE_DIRTY);
1987
+ }
1988
+ schedule_effect(
1989
+ /** @type {Effect} */
1990
+ reaction
1991
+ );
1992
+ }
1993
+ }
1994
+ }
1995
+ function update_reaction(reaction) {
1996
+ var previous_deps = new_deps;
1997
+ var previous_skipped_deps = skipped_deps;
1998
+ var previous_untracked_writes = untracked_writes;
1999
+ var previous_reaction = active_reaction;
2000
+ var previous_sources = current_sources;
2001
+ var previous_component_context = component_context;
2002
+ var previous_untracking = untracking;
2003
+ var previous_update_version = update_version;
2004
+ var flags = reaction.f;
2005
+ new_deps = /** @type {null | Value[]} */
2006
+ null;
2007
+ skipped_deps = 0;
2008
+ untracked_writes = null;
2009
+ active_reaction = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
2010
+ current_sources = null;
2011
+ set_component_context(reaction.ctx);
2012
+ untracking = false;
2013
+ update_version = ++read_version;
2014
+ if (reaction.ac !== null) {
2015
+ without_reactive_context(() => {
2016
+ reaction.ac.abort(STALE_REACTION);
2017
+ });
2018
+ reaction.ac = null;
2019
+ }
2020
+ try {
2021
+ reaction.f |= REACTION_IS_UPDATING;
2022
+ var fn = (
2023
+ /** @type {Function} */
2024
+ reaction.fn
2025
+ );
2026
+ var result = fn();
2027
+ reaction.f |= REACTION_RAN;
2028
+ var deps = reaction.deps;
2029
+ var is_fork = current_batch?.is_fork;
2030
+ if (new_deps !== null) {
2031
+ var i;
2032
+ if (!is_fork) {
2033
+ remove_reactions(reaction, skipped_deps);
2034
+ }
2035
+ if (deps !== null && skipped_deps > 0) {
2036
+ deps.length = skipped_deps + new_deps.length;
2037
+ for (i = 0; i < new_deps.length; i++) {
2038
+ deps[skipped_deps + i] = new_deps[i];
2039
+ }
2040
+ } else {
2041
+ reaction.deps = deps = new_deps;
2042
+ }
2043
+ if (effect_tracking() && (reaction.f & CONNECTED) !== 0) {
2044
+ for (i = skipped_deps; i < deps.length; i++) {
2045
+ (deps[i].reactions ??= []).push(reaction);
2046
+ }
2047
+ }
2048
+ } else if (!is_fork && deps !== null && skipped_deps < deps.length) {
2049
+ remove_reactions(reaction, skipped_deps);
2050
+ deps.length = skipped_deps;
2051
+ }
2052
+ if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & (DERIVED | MAYBE_DIRTY | DIRTY)) === 0) {
2053
+ for (i = 0; i < /** @type {Source[]} */
2054
+ untracked_writes.length; i++) {
2055
+ schedule_possible_effect_self_invalidation(
2056
+ untracked_writes[i],
2057
+ /** @type {Effect} */
2058
+ reaction
2059
+ );
2060
+ }
2061
+ }
2062
+ if (previous_reaction !== null && previous_reaction !== reaction) {
2063
+ read_version++;
2064
+ if (previous_reaction.deps !== null) {
2065
+ for (let i2 = 0; i2 < previous_skipped_deps; i2 += 1) {
2066
+ previous_reaction.deps[i2].rv = read_version;
2067
+ }
2068
+ }
2069
+ if (previous_deps !== null) {
2070
+ for (const dep of previous_deps) {
2071
+ dep.rv = read_version;
2072
+ }
2073
+ }
2074
+ if (untracked_writes !== null) {
2075
+ if (previous_untracked_writes === null) {
2076
+ previous_untracked_writes = untracked_writes;
2077
+ } else {
2078
+ previous_untracked_writes.push(.../** @type {Source[]} */
2079
+ untracked_writes);
2080
+ }
2081
+ }
2082
+ }
2083
+ if ((reaction.f & ERROR_VALUE) !== 0) {
2084
+ reaction.f ^= ERROR_VALUE;
2085
+ }
2086
+ return result;
2087
+ } catch (error) {
2088
+ return handle_error(error);
2089
+ } finally {
2090
+ reaction.f ^= REACTION_IS_UPDATING;
2091
+ new_deps = previous_deps;
2092
+ skipped_deps = previous_skipped_deps;
2093
+ untracked_writes = previous_untracked_writes;
2094
+ active_reaction = previous_reaction;
2095
+ current_sources = previous_sources;
2096
+ set_component_context(previous_component_context);
2097
+ untracking = previous_untracking;
2098
+ update_version = previous_update_version;
2099
+ }
2100
+ }
2101
+ function remove_reaction(signal, dependency) {
2102
+ let reactions = dependency.reactions;
2103
+ if (reactions !== null) {
2104
+ var index = index_of.call(reactions, signal);
2105
+ if (index !== -1) {
2106
+ var new_length = reactions.length - 1;
2107
+ if (new_length === 0) {
2108
+ reactions = dependency.reactions = null;
2109
+ } else {
2110
+ reactions[index] = reactions[new_length];
2111
+ reactions.pop();
2112
+ }
2113
+ }
2114
+ }
2115
+ if (reactions === null && (dependency.f & DERIVED) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
2116
+ // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
2117
+ // allows us to skip the expensive work of disconnecting and immediately reconnecting it
2118
+ (new_deps === null || !includes.call(new_deps, dependency))) {
2119
+ var derived2 = (
2120
+ /** @type {Derived} */
2121
+ dependency
2122
+ );
2123
+ if ((derived2.f & CONNECTED) !== 0) {
2124
+ derived2.f ^= CONNECTED;
2125
+ derived2.f &= ~WAS_MARKED;
2126
+ }
2127
+ update_derived_status(derived2);
2128
+ freeze_derived_effects(derived2);
2129
+ remove_reactions(derived2, 0);
2130
+ }
2131
+ }
2132
+ function remove_reactions(signal, start_index) {
2133
+ var dependencies = signal.deps;
2134
+ if (dependencies === null) return;
2135
+ for (var i = start_index; i < dependencies.length; i++) {
2136
+ remove_reaction(signal, dependencies[i]);
2137
+ }
2138
+ }
2139
+ function update_effect(effect) {
2140
+ var flags = effect.f;
2141
+ if ((flags & DESTROYED) !== 0) {
2142
+ return;
2143
+ }
2144
+ set_signal_status(effect, CLEAN);
2145
+ var previous_effect = active_effect;
2146
+ var was_updating_effect = is_updating_effect;
2147
+ active_effect = effect;
2148
+ is_updating_effect = true;
2149
+ try {
2150
+ if ((flags & (BLOCK_EFFECT | MANAGED_EFFECT)) !== 0) {
2151
+ destroy_block_effect_children(effect);
2152
+ } else {
2153
+ destroy_effect_children(effect);
2154
+ }
2155
+ execute_effect_teardown(effect);
2156
+ var teardown = update_reaction(effect);
2157
+ effect.teardown = typeof teardown === "function" ? teardown : null;
2158
+ effect.wv = write_version;
2159
+ var dep;
2160
+ if (browser && tracing_mode_flag && (effect.f & DIRTY) !== 0 && effect.deps !== null) ;
2161
+ } finally {
2162
+ is_updating_effect = was_updating_effect;
2163
+ active_effect = previous_effect;
2164
+ }
2165
+ }
2166
+ function get$1(signal) {
2167
+ var flags = signal.f;
2168
+ var is_derived = (flags & DERIVED) !== 0;
2169
+ if (active_reaction !== null && !untracking) {
2170
+ var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
2171
+ if (!destroyed && (current_sources === null || !includes.call(current_sources, signal))) {
2172
+ var deps = active_reaction.deps;
2173
+ if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
2174
+ if (signal.rv < read_version) {
2175
+ signal.rv = read_version;
2176
+ if (new_deps === null && deps !== null && deps[skipped_deps] === signal) {
2177
+ skipped_deps++;
2178
+ } else if (new_deps === null) {
2179
+ new_deps = [signal];
2180
+ } else {
2181
+ new_deps.push(signal);
2182
+ }
2183
+ }
2184
+ } else {
2185
+ (active_reaction.deps ??= []).push(signal);
2186
+ var reactions = signal.reactions;
2187
+ if (reactions === null) {
2188
+ signal.reactions = [active_reaction];
2189
+ } else if (!includes.call(reactions, active_reaction)) {
2190
+ reactions.push(active_reaction);
2191
+ }
2192
+ }
2193
+ }
2194
+ }
2195
+ if (is_destroying_effect && old_values.has(signal)) {
2196
+ return old_values.get(signal);
2197
+ }
2198
+ if (is_derived) {
2199
+ var derived2 = (
2200
+ /** @type {Derived} */
2201
+ signal
2202
+ );
2203
+ if (is_destroying_effect) {
2204
+ var value = derived2.v;
2205
+ if ((derived2.f & CLEAN) === 0 && derived2.reactions !== null || depends_on_old_values(derived2)) {
2206
+ value = execute_derived(derived2);
2207
+ }
2208
+ old_values.set(derived2, value);
2209
+ return value;
2210
+ }
2211
+ var should_connect = (derived2.f & CONNECTED) === 0 && !untracking && active_reaction !== null && (is_updating_effect || (active_reaction.f & CONNECTED) !== 0);
2212
+ var is_new = (derived2.f & REACTION_RAN) === 0;
2213
+ if (is_dirty(derived2)) {
2214
+ if (should_connect) {
2215
+ derived2.f |= CONNECTED;
2216
+ }
2217
+ update_derived(derived2);
2218
+ }
2219
+ if (should_connect && !is_new) {
2220
+ unfreeze_derived_effects(derived2);
2221
+ reconnect(derived2);
2222
+ }
2223
+ }
2224
+ if (batch_values?.has(signal)) {
2225
+ return batch_values.get(signal);
2226
+ }
2227
+ if ((signal.f & ERROR_VALUE) !== 0) {
2228
+ throw signal.v;
2229
+ }
2230
+ return signal.v;
2231
+ }
2232
+ function reconnect(derived2) {
2233
+ derived2.f |= CONNECTED;
2234
+ if (derived2.deps === null) return;
2235
+ for (const dep of derived2.deps) {
2236
+ (dep.reactions ??= []).push(derived2);
2237
+ if ((dep.f & DERIVED) !== 0 && (dep.f & CONNECTED) === 0) {
2238
+ unfreeze_derived_effects(
2239
+ /** @type {Derived} */
2240
+ dep
2241
+ );
2242
+ reconnect(
2243
+ /** @type {Derived} */
2244
+ dep
2245
+ );
2246
+ }
2247
+ }
2248
+ }
2249
+ function depends_on_old_values(derived2) {
2250
+ if (derived2.v === UNINITIALIZED) return true;
2251
+ if (derived2.deps === null) return false;
2252
+ for (const dep of derived2.deps) {
2253
+ if (old_values.has(dep)) {
2254
+ return true;
2255
+ }
2256
+ if ((dep.f & DERIVED) !== 0 && depends_on_old_values(
2257
+ /** @type {Derived} */
2258
+ dep
2259
+ )) {
2260
+ return true;
2261
+ }
2262
+ }
2263
+ return false;
2264
+ }
2265
+ function untrack(fn) {
2266
+ var previous_untracking = untracking;
2267
+ try {
2268
+ untracking = true;
2269
+ return fn();
2270
+ } finally {
2271
+ untracking = previous_untracking;
2272
+ }
2273
+ }
2274
+ const DOM_BOOLEAN_ATTRIBUTES = [
2275
+ "allowfullscreen",
2276
+ "async",
2277
+ "autofocus",
2278
+ "autoplay",
2279
+ "checked",
2280
+ "controls",
2281
+ "default",
2282
+ "disabled",
2283
+ "formnovalidate",
2284
+ "indeterminate",
2285
+ "inert",
2286
+ "ismap",
2287
+ "loop",
2288
+ "multiple",
2289
+ "muted",
2290
+ "nomodule",
2291
+ "novalidate",
2292
+ "open",
2293
+ "playsinline",
2294
+ "readonly",
2295
+ "required",
2296
+ "reversed",
2297
+ "seamless",
2298
+ "selected",
2299
+ "webkitdirectory",
2300
+ "defer",
2301
+ "disablepictureinpicture",
2302
+ "disableremoteplayback"
2303
+ ];
2304
+ function is_boolean_attribute(name) {
2305
+ return DOM_BOOLEAN_ATTRIBUTES.includes(name);
2306
+ }
2307
+ const PASSIVE_EVENTS = ["touchstart", "touchmove"];
2308
+ function is_passive_event(name) {
2309
+ return PASSIVE_EVENTS.includes(name);
2310
+ }
2311
+ const ATTR_REGEX = /[&"<]/g;
2312
+ const CONTENT_REGEX = /[&<]/g;
2313
+ function escape_html(value, is_attr) {
2314
+ const str = String(value ?? "");
2315
+ const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX;
2316
+ pattern.lastIndex = 0;
2317
+ let escaped2 = "";
2318
+ let last = 0;
2319
+ while (pattern.test(str)) {
2320
+ const i = pattern.lastIndex - 1;
2321
+ const ch = str[i];
2322
+ escaped2 += str.substring(last, i) + (ch === "&" ? "&amp;" : ch === '"' ? "&quot;" : "&lt;");
2323
+ last = i + 1;
2324
+ }
2325
+ return escaped2 + str.substring(last);
2326
+ }
2327
+ function r(e) {
2328
+ var t, f, n = "";
2329
+ if ("string" == typeof e || "number" == typeof e) n += e;
2330
+ else if ("object" == typeof e) if (Array.isArray(e)) {
2331
+ var o = e.length;
2332
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
2333
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
2334
+ return n;
2335
+ }
2336
+ function clsx$1() {
2337
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
2338
+ return n;
2339
+ }
2340
+ const replacements = {
2341
+ translate: /* @__PURE__ */ new Map([
2342
+ [true, "yes"],
2343
+ [false, "no"]
2344
+ ])
2345
+ };
2346
+ function attr(name, value, is_boolean = false) {
2347
+ if (name === "hidden" && value !== "until-found") {
2348
+ is_boolean = true;
2349
+ }
2350
+ if (value == null || !value && is_boolean) return "";
2351
+ const normalized = has_own_property.call(replacements, name) && replacements[name].get(value) || value;
2352
+ const assignment = is_boolean ? `=""` : `="${escape_html(normalized, true)}"`;
2353
+ return ` ${name}${assignment}`;
2354
+ }
2355
+ function clsx(value) {
2356
+ if (typeof value === "object") {
2357
+ return clsx$1(value);
2358
+ } else {
2359
+ return value ?? "";
2360
+ }
2361
+ }
2362
+ const whitespace = [..." \n\r\f \v\uFEFF"];
2363
+ function to_class(value, hash, directives) {
2364
+ var classname = value == null ? "" : "" + value;
2365
+ if (hash) {
2366
+ classname = classname ? classname + " " + hash : hash;
2367
+ }
2368
+ if (directives) {
2369
+ for (var key of Object.keys(directives)) {
2370
+ if (directives[key]) {
2371
+ classname = classname ? classname + " " + key : key;
2372
+ } else if (classname.length) {
2373
+ var len = key.length;
2374
+ var a = 0;
2375
+ while ((a = classname.indexOf(key, a)) >= 0) {
2376
+ var b = a + len;
2377
+ if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) {
2378
+ classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
2379
+ } else {
2380
+ a = b;
2381
+ }
2382
+ }
2383
+ }
2384
+ }
2385
+ }
2386
+ return classname === "" ? null : classname;
2387
+ }
2388
+ function append_styles(styles, important = false) {
2389
+ var separator = important ? " !important;" : ";";
2390
+ var css = "";
2391
+ for (var key of Object.keys(styles)) {
2392
+ var value = styles[key];
2393
+ if (value != null && value !== "") {
2394
+ css += " " + key + ": " + value + separator;
2395
+ }
2396
+ }
2397
+ return css;
2398
+ }
2399
+ function to_css_name(name) {
2400
+ if (name[0] !== "-" || name[1] !== "-") {
2401
+ return name.toLowerCase();
2402
+ }
2403
+ return name;
2404
+ }
2405
+ function to_style(value, styles) {
2406
+ if (styles) {
2407
+ var new_style = "";
2408
+ var normal_styles;
2409
+ var important_styles;
2410
+ if (Array.isArray(styles)) {
2411
+ normal_styles = styles[0];
2412
+ important_styles = styles[1];
2413
+ } else {
2414
+ normal_styles = styles;
2415
+ }
2416
+ if (value) {
2417
+ value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
2418
+ var in_str = false;
2419
+ var in_apo = 0;
2420
+ var in_comment = false;
2421
+ var reserved_names = [];
2422
+ if (normal_styles) {
2423
+ reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
2424
+ }
2425
+ if (important_styles) {
2426
+ reserved_names.push(...Object.keys(important_styles).map(to_css_name));
2427
+ }
2428
+ var start_index = 0;
2429
+ var name_index = -1;
2430
+ const len = value.length;
2431
+ for (var i = 0; i < len; i++) {
2432
+ var c = value[i];
2433
+ if (in_comment) {
2434
+ if (c === "/" && value[i - 1] === "*") {
2435
+ in_comment = false;
2436
+ }
2437
+ } else if (in_str) {
2438
+ if (in_str === c) {
2439
+ in_str = false;
2440
+ }
2441
+ } else if (c === "/" && value[i + 1] === "*") {
2442
+ in_comment = true;
2443
+ } else if (c === '"' || c === "'") {
2444
+ in_str = c;
2445
+ } else if (c === "(") {
2446
+ in_apo++;
2447
+ } else if (c === ")") {
2448
+ in_apo--;
2449
+ }
2450
+ if (!in_comment && in_str === false && in_apo === 0) {
2451
+ if (c === ":" && name_index === -1) {
2452
+ name_index = i;
2453
+ } else if (c === ";" || i === len - 1) {
2454
+ if (name_index !== -1) {
2455
+ var name = to_css_name(value.substring(start_index, name_index).trim());
2456
+ if (!reserved_names.includes(name)) {
2457
+ if (c !== ";") {
2458
+ i++;
2459
+ }
2460
+ var property = value.substring(start_index, i).trim();
2461
+ new_style += " " + property + ";";
2462
+ }
2463
+ }
2464
+ start_index = i + 1;
2465
+ name_index = -1;
2466
+ }
2467
+ }
2468
+ }
2469
+ }
2470
+ if (normal_styles) {
2471
+ new_style += append_styles(normal_styles);
2472
+ }
2473
+ if (important_styles) {
2474
+ new_style += append_styles(important_styles, true);
2475
+ }
2476
+ new_style = new_style.trim();
2477
+ return new_style === "" ? null : new_style;
2478
+ }
2479
+ return value == null ? null : String(value);
2480
+ }
2481
+ function subscribe_to_store(store, run, invalidate) {
2482
+ if (store == null) {
2483
+ run(void 0);
2484
+ if (invalidate) invalidate(void 0);
2485
+ return noop;
2486
+ }
2487
+ const unsub = untrack(
2488
+ () => store.subscribe(
2489
+ run,
2490
+ // @ts-expect-error
2491
+ invalidate
2492
+ )
2493
+ );
2494
+ return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
2495
+ }
2496
+ const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
2497
+ const BLOCK_OPEN_ELSE = `<!--${HYDRATION_START_ELSE}-->`;
2498
+ const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
2499
+ const EMPTY_COMMENT = `<!---->`;
2500
+ let controller = null;
2501
+ function abort() {
2502
+ controller?.abort(STALE_REACTION);
2503
+ controller = null;
2504
+ }
2505
+ function await_invalid() {
2506
+ const error = new Error(`await_invalid
2507
+ Encountered asynchronous work while rendering synchronously.
2508
+ https://svelte.dev/e/await_invalid`);
2509
+ error.name = "Svelte error";
2510
+ throw error;
2511
+ }
2512
+ function invalid_csp() {
2513
+ const error = new Error(`invalid_csp
2514
+ \`csp.nonce\` was set while \`csp.hash\` was \`true\`. These options cannot be used simultaneously.
2515
+ https://svelte.dev/e/invalid_csp`);
2516
+ error.name = "Svelte error";
2517
+ throw error;
2518
+ }
2519
+ function server_context_required() {
2520
+ const error = new Error(`server_context_required
2521
+ Could not resolve \`render\` context.
2522
+ https://svelte.dev/e/server_context_required`);
2523
+ error.name = "Svelte error";
2524
+ throw error;
2525
+ }
2526
+ var ssr_context = null;
2527
+ function set_ssr_context(v) {
2528
+ ssr_context = v;
2529
+ }
2530
+ function getContext(key) {
2531
+ const context_map = get_or_init_context_map();
2532
+ const result = (
2533
+ /** @type {T} */
2534
+ context_map.get(key)
2535
+ );
2536
+ return result;
2537
+ }
2538
+ function setContext(key, context) {
2539
+ get_or_init_context_map().set(key, context);
2540
+ return context;
2541
+ }
2542
+ function get_or_init_context_map(name) {
2543
+ if (ssr_context === null) {
2544
+ lifecycle_outside_component();
2545
+ }
2546
+ return ssr_context.c ??= new Map(get_parent_context(ssr_context) || void 0);
2547
+ }
2548
+ function push(fn) {
2549
+ ssr_context = { p: ssr_context, c: null, r: null };
2550
+ }
2551
+ function pop() {
2552
+ ssr_context = /** @type {SSRContext} */
2553
+ ssr_context.p;
2554
+ }
2555
+ function get_parent_context(ssr_context2) {
2556
+ let parent = ssr_context2.p;
2557
+ while (parent !== null) {
2558
+ const context_map = parent.c;
2559
+ if (context_map !== null) {
2560
+ return context_map;
2561
+ }
2562
+ parent = parent.p;
2563
+ }
2564
+ return null;
2565
+ }
2566
+ function unresolved_hydratable(key, stack) {
2567
+ {
2568
+ console.warn(`https://svelte.dev/e/unresolved_hydratable`);
2569
+ }
2570
+ }
2571
+ function get_render_context() {
2572
+ const store = als?.getStore();
2573
+ {
2574
+ server_context_required();
2575
+ }
2576
+ return store;
2577
+ }
2578
+ let als = null;
2579
+ let text_encoder;
2580
+ let crypto;
2581
+ const obfuscated_import = (module_name) => import(
2582
+ /* @vite-ignore */
2583
+ module_name
2584
+ );
2585
+ async function sha256(data) {
2586
+ text_encoder ??= new TextEncoder();
2587
+ crypto ??= globalThis.crypto?.subtle?.digest ? globalThis.crypto : (
2588
+ // @ts-ignore - we don't install node types in the prod build
2589
+ // don't use import('node:crypto') directly because static analysers will think we rely on node when we don't
2590
+ (await obfuscated_import("node:crypto")).webcrypto
2591
+ );
2592
+ const hash_buffer = await crypto.subtle.digest("SHA-256", text_encoder.encode(data));
2593
+ return base64_encode(hash_buffer);
2594
+ }
2595
+ function base64_encode(bytes) {
2596
+ if (globalThis.Buffer) {
2597
+ return globalThis.Buffer.from(bytes).toString("base64");
2598
+ }
2599
+ let binary = "";
2600
+ for (let i = 0; i < bytes.length; i++) {
2601
+ binary += String.fromCharCode(bytes[i]);
2602
+ }
2603
+ return btoa(binary);
2604
+ }
2605
+ class Renderer {
2606
+ /**
2607
+ * The contents of the renderer.
2608
+ * @type {RendererItem[]}
2609
+ */
2610
+ #out = [];
2611
+ /**
2612
+ * Any `onDestroy` callbacks registered during execution of this renderer.
2613
+ * @type {(() => void)[] | undefined}
2614
+ */
2615
+ #on_destroy = void 0;
2616
+ /**
2617
+ * Whether this renderer is a component body.
2618
+ * @type {boolean}
2619
+ */
2620
+ #is_component_body = false;
2621
+ /**
2622
+ * If set, this renderer is an error boundary. When async collection
2623
+ * of the children fails, the failed snippet is rendered instead.
2624
+ * @type {{
2625
+ * failed: (renderer: Renderer, error: unknown, reset: () => void) => void;
2626
+ * transformError: (error: unknown) => unknown;
2627
+ * context: SSRContext | null;
2628
+ * } | null}
2629
+ */
2630
+ #boundary = null;
2631
+ /**
2632
+ * The type of string content that this renderer is accumulating.
2633
+ * @type {RendererType}
2634
+ */
2635
+ type;
2636
+ /** @type {Renderer | undefined} */
2637
+ #parent;
2638
+ /**
2639
+ * Asynchronous work associated with this renderer
2640
+ * @type {Promise<void> | undefined}
2641
+ */
2642
+ promise = void 0;
2643
+ /**
2644
+ * State which is associated with the content tree as a whole.
2645
+ * It will be re-exposed, uncopied, on all children.
2646
+ * @type {SSRState}
2647
+ * @readonly
2648
+ */
2649
+ global;
2650
+ /**
2651
+ * State that is local to the branch it is declared in.
2652
+ * It will be shallow-copied to all children.
2653
+ *
2654
+ * @type {{ select_value: string | undefined }}
2655
+ */
2656
+ local;
2657
+ /**
2658
+ * @param {SSRState} global
2659
+ * @param {Renderer | undefined} [parent]
2660
+ */
2661
+ constructor(global, parent) {
2662
+ this.#parent = parent;
2663
+ this.global = global;
2664
+ this.local = parent ? { ...parent.local } : { select_value: void 0 };
2665
+ this.type = parent ? parent.type : "body";
2666
+ }
2667
+ /**
2668
+ * @param {(renderer: Renderer) => void} fn
2669
+ */
2670
+ head(fn) {
2671
+ const head2 = new Renderer(this.global, this);
2672
+ head2.type = "head";
2673
+ this.#out.push(head2);
2674
+ head2.child(fn);
2675
+ }
2676
+ /**
2677
+ * @param {Array<Promise<void>>} blockers
2678
+ * @param {(renderer: Renderer) => void} fn
2679
+ */
2680
+ async_block(blockers, fn) {
2681
+ this.#out.push(BLOCK_OPEN);
2682
+ this.async(blockers, fn);
2683
+ this.#out.push(BLOCK_CLOSE);
2684
+ }
2685
+ /**
2686
+ * @param {Array<Promise<void>>} blockers
2687
+ * @param {(renderer: Renderer) => void} fn
2688
+ */
2689
+ async(blockers, fn) {
2690
+ let callback = fn;
2691
+ if (blockers.length > 0) {
2692
+ const context = ssr_context;
2693
+ callback = (renderer) => {
2694
+ return Promise.all(blockers).then(() => {
2695
+ const previous_context = ssr_context;
2696
+ try {
2697
+ set_ssr_context(context);
2698
+ return fn(renderer);
2699
+ } finally {
2700
+ set_ssr_context(previous_context);
2701
+ }
2702
+ });
2703
+ };
2704
+ }
2705
+ this.child(callback);
2706
+ }
2707
+ /**
2708
+ * @param {Array<() => void>} thunks
2709
+ */
2710
+ run(thunks) {
2711
+ const context = ssr_context;
2712
+ let promise = Promise.resolve(thunks[0]());
2713
+ const promises = [promise];
2714
+ for (const fn of thunks.slice(1)) {
2715
+ promise = promise.then(() => {
2716
+ const previous_context = ssr_context;
2717
+ set_ssr_context(context);
2718
+ try {
2719
+ return fn();
2720
+ } finally {
2721
+ set_ssr_context(previous_context);
2722
+ }
2723
+ });
2724
+ promises.push(promise);
2725
+ }
2726
+ promise.catch(noop);
2727
+ this.promise = promise;
2728
+ return promises;
2729
+ }
2730
+ /**
2731
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
2732
+ */
2733
+ child_block(fn) {
2734
+ this.#out.push(BLOCK_OPEN);
2735
+ this.child(fn);
2736
+ this.#out.push(BLOCK_CLOSE);
2737
+ }
2738
+ /**
2739
+ * Create a child renderer. The child renderer inherits the state from the parent,
2740
+ * but has its own content.
2741
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
2742
+ */
2743
+ child(fn) {
2744
+ const child = new Renderer(this.global, this);
2745
+ this.#out.push(child);
2746
+ const parent = ssr_context;
2747
+ set_ssr_context({
2748
+ ...ssr_context,
2749
+ p: parent,
2750
+ c: null,
2751
+ r: child
2752
+ });
2753
+ const result = fn(child);
2754
+ set_ssr_context(parent);
2755
+ if (result instanceof Promise) {
2756
+ result.catch(noop);
2757
+ result.finally(() => set_ssr_context(null)).catch(noop);
2758
+ if (child.global.mode === "sync") {
2759
+ await_invalid();
2760
+ }
2761
+ child.promise = result;
2762
+ }
2763
+ return child;
2764
+ }
2765
+ /**
2766
+ * Render children inside an error boundary. If the children throw and the API-level
2767
+ * `transformError` transform handles the error (doesn't re-throw), the `failed` snippet is
2768
+ * rendered instead. Otherwise the error propagates.
2769
+ *
2770
+ * @param {{ failed?: (renderer: Renderer, error: unknown, reset: () => void) => void }} props
2771
+ * @param {(renderer: Renderer) => MaybePromise<void>} children_fn
2772
+ */
2773
+ boundary(props, children_fn) {
2774
+ const child = new Renderer(this.global, this);
2775
+ this.#out.push(child);
2776
+ const parent_context = ssr_context;
2777
+ if (props.failed) {
2778
+ child.#boundary = {
2779
+ failed: props.failed,
2780
+ transformError: this.global.transformError,
2781
+ context: parent_context
2782
+ };
2783
+ }
2784
+ set_ssr_context({
2785
+ ...ssr_context,
2786
+ p: parent_context,
2787
+ c: null,
2788
+ r: child
2789
+ });
2790
+ try {
2791
+ const result = children_fn(child);
2792
+ set_ssr_context(parent_context);
2793
+ if (result instanceof Promise) {
2794
+ if (child.global.mode === "sync") {
2795
+ await_invalid();
2796
+ }
2797
+ result.catch(noop);
2798
+ child.promise = result;
2799
+ }
2800
+ } catch (error) {
2801
+ set_ssr_context(parent_context);
2802
+ const failed_snippet = props.failed;
2803
+ if (!failed_snippet) throw error;
2804
+ const result = this.global.transformError(error);
2805
+ child.#out.length = 0;
2806
+ child.#boundary = null;
2807
+ if (result instanceof Promise) {
2808
+ if (this.global.mode === "sync") {
2809
+ await_invalid();
2810
+ }
2811
+ child.promise = /** @type {Promise<unknown>} */
2812
+ result.then((transformed) => {
2813
+ set_ssr_context(parent_context);
2814
+ child.#out.push(Renderer.#serialize_failed_boundary(transformed));
2815
+ failed_snippet(child, transformed, noop);
2816
+ child.#out.push(BLOCK_CLOSE);
2817
+ });
2818
+ child.promise.catch(noop);
2819
+ } else {
2820
+ child.#out.push(Renderer.#serialize_failed_boundary(result));
2821
+ failed_snippet(child, result, noop);
2822
+ child.#out.push(BLOCK_CLOSE);
2823
+ }
2824
+ }
2825
+ }
2826
+ /**
2827
+ * Create a component renderer. The component renderer inherits the state from the parent,
2828
+ * but has its own content. It is treated as an ordering boundary for ondestroy callbacks.
2829
+ * @param {(renderer: Renderer) => MaybePromise<void>} fn
2830
+ * @param {Function} [component_fn]
2831
+ * @returns {void}
2832
+ */
2833
+ component(fn, component_fn) {
2834
+ push();
2835
+ const child = this.child(fn);
2836
+ child.#is_component_body = true;
2837
+ pop();
2838
+ }
2839
+ /**
2840
+ * @param {Record<string, any>} attrs
2841
+ * @param {(renderer: Renderer) => void} fn
2842
+ * @param {string | undefined} [css_hash]
2843
+ * @param {Record<string, boolean> | undefined} [classes]
2844
+ * @param {Record<string, string> | undefined} [styles]
2845
+ * @param {number | undefined} [flags]
2846
+ * @param {boolean | undefined} [is_rich]
2847
+ * @returns {void}
2848
+ */
2849
+ select(attrs, fn, css_hash, classes, styles, flags, is_rich) {
2850
+ const { value, ...select_attrs } = attrs;
2851
+ this.push(`<select${attributes(select_attrs, css_hash, classes, styles, flags)}>`);
2852
+ this.child((renderer) => {
2853
+ renderer.local.select_value = value;
2854
+ fn(renderer);
2855
+ });
2856
+ this.push(`${is_rich ? "<!>" : ""}</select>`);
2857
+ }
2858
+ /**
2859
+ * @param {Record<string, any>} attrs
2860
+ * @param {string | number | boolean | ((renderer: Renderer) => void)} body
2861
+ * @param {string | undefined} [css_hash]
2862
+ * @param {Record<string, boolean> | undefined} [classes]
2863
+ * @param {Record<string, string> | undefined} [styles]
2864
+ * @param {number | undefined} [flags]
2865
+ * @param {boolean | undefined} [is_rich]
2866
+ */
2867
+ option(attrs, body, css_hash, classes, styles, flags, is_rich) {
2868
+ this.#out.push(`<option${attributes(attrs, css_hash, classes, styles, flags)}`);
2869
+ const close = (renderer, value, { head: head2, body: body2 }) => {
2870
+ if (has_own_property.call(attrs, "value")) {
2871
+ value = attrs.value;
2872
+ }
2873
+ if (value === this.local.select_value) {
2874
+ renderer.#out.push(' selected=""');
2875
+ }
2876
+ renderer.#out.push(`>${body2}${is_rich ? "<!>" : ""}</option>`);
2877
+ if (head2) {
2878
+ renderer.head((child) => child.push(head2));
2879
+ }
2880
+ };
2881
+ if (typeof body === "function") {
2882
+ this.child((renderer) => {
2883
+ const r2 = new Renderer(this.global, this);
2884
+ body(r2);
2885
+ if (this.global.mode === "async") {
2886
+ return r2.#collect_content_async().then((content) => {
2887
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
2888
+ });
2889
+ } else {
2890
+ const content = r2.#collect_content();
2891
+ close(renderer, content.body.replaceAll("<!---->", ""), content);
2892
+ }
2893
+ });
2894
+ } else {
2895
+ close(this, body, { body: escape_html(body) });
2896
+ }
2897
+ }
2898
+ /**
2899
+ * @param {(renderer: Renderer) => void} fn
2900
+ */
2901
+ title(fn) {
2902
+ const path = this.get_path();
2903
+ const close = (head2) => {
2904
+ this.global.set_title(head2, path);
2905
+ };
2906
+ this.child((renderer) => {
2907
+ const r2 = new Renderer(renderer.global, renderer);
2908
+ fn(r2);
2909
+ if (renderer.global.mode === "async") {
2910
+ return r2.#collect_content_async().then((content) => {
2911
+ close(content.head);
2912
+ });
2913
+ } else {
2914
+ const content = r2.#collect_content();
2915
+ close(content.head);
2916
+ }
2917
+ });
2918
+ }
2919
+ /**
2920
+ * @param {string | (() => Promise<string>)} content
2921
+ */
2922
+ push(content) {
2923
+ if (typeof content === "function") {
2924
+ this.child(async (renderer) => renderer.push(await content()));
2925
+ } else {
2926
+ this.#out.push(content);
2927
+ }
2928
+ }
2929
+ /**
2930
+ * @param {() => void} fn
2931
+ */
2932
+ on_destroy(fn) {
2933
+ (this.#on_destroy ??= []).push(fn);
2934
+ }
2935
+ /**
2936
+ * @returns {number[]}
2937
+ */
2938
+ get_path() {
2939
+ return this.#parent ? [...this.#parent.get_path(), this.#parent.#out.indexOf(this)] : [];
2940
+ }
2941
+ /**
2942
+ * @deprecated this is needed for legacy component bindings
2943
+ */
2944
+ copy() {
2945
+ const copy = new Renderer(this.global, this.#parent);
2946
+ copy.#out = this.#out.map((item) => item instanceof Renderer ? item.copy() : item);
2947
+ copy.promise = this.promise;
2948
+ return copy;
2949
+ }
2950
+ /**
2951
+ * @param {Renderer} other
2952
+ * @deprecated this is needed for legacy component bindings
2953
+ */
2954
+ subsume(other) {
2955
+ if (this.global.mode !== other.global.mode) {
2956
+ throw new Error(
2957
+ "invariant: A renderer cannot switch modes. If you're seeing this, there's a compiler bug. File an issue!"
2958
+ );
2959
+ }
2960
+ this.local = other.local;
2961
+ this.#out = other.#out.map((item) => {
2962
+ if (item instanceof Renderer) {
2963
+ item.subsume(item);
2964
+ }
2965
+ return item;
2966
+ });
2967
+ this.promise = other.promise;
2968
+ this.type = other.type;
2969
+ }
2970
+ get length() {
2971
+ return this.#out.length;
2972
+ }
2973
+ /**
2974
+ * Creates the hydration comment that marks the start of a failed boundary.
2975
+ * The error is JSON-serialized and embedded inside an HTML comment for the client
2976
+ * to parse during hydration. The JSON is escaped to prevent `-->` or `<!--` sequences
2977
+ * from breaking out of the comment (XSS). Uses unicode escapes which `JSON.parse()`
2978
+ * handles transparently.
2979
+ * @param {unknown} error
2980
+ * @returns {string}
2981
+ */
2982
+ static #serialize_failed_boundary(error) {
2983
+ var json = JSON.stringify(error);
2984
+ var escaped2 = json.replace(/>/g, "\\u003e").replace(/</g, "\\u003c");
2985
+ return `<!--${HYDRATION_START_FAILED}${escaped2}-->`;
2986
+ }
2987
+ /**
2988
+ * Only available on the server and when compiling with the `server` option.
2989
+ * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app.
2990
+ * @template {Record<string, any>} Props
2991
+ * @param {Component<Props>} component
2992
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} [options]
2993
+ * @returns {RenderOutput}
2994
+ */
2995
+ static render(component, options = {}) {
2996
+ let sync;
2997
+ const result = (
2998
+ /** @type {RenderOutput} */
2999
+ {}
3000
+ );
3001
+ Object.defineProperties(result, {
3002
+ html: {
3003
+ get: () => {
3004
+ return (sync ??= Renderer.#render(component, options)).body;
3005
+ }
3006
+ },
3007
+ head: {
3008
+ get: () => {
3009
+ return (sync ??= Renderer.#render(component, options)).head;
3010
+ }
3011
+ },
3012
+ body: {
3013
+ get: () => {
3014
+ return (sync ??= Renderer.#render(component, options)).body;
3015
+ }
3016
+ },
3017
+ hashes: {
3018
+ value: {
3019
+ script: ""
3020
+ }
3021
+ },
3022
+ then: {
3023
+ value: (
3024
+ /**
3025
+ * this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
3026
+ *
3027
+ * @template TResult1
3028
+ * @template [TResult2=never]
3029
+ * @param { (value: SyncRenderOutput) => TResult1 } onfulfilled
3030
+ * @param { (reason: unknown) => TResult2 } onrejected
3031
+ */
3032
+ (onfulfilled, onrejected) => {
3033
+ {
3034
+ const result2 = sync ??= Renderer.#render(component, options);
3035
+ const user_result = onfulfilled({
3036
+ head: result2.head,
3037
+ body: result2.body,
3038
+ html: result2.body,
3039
+ hashes: { script: [] }
3040
+ });
3041
+ return Promise.resolve(user_result);
3042
+ }
3043
+ }
3044
+ )
3045
+ }
3046
+ });
3047
+ return result;
3048
+ }
3049
+ /**
3050
+ * Collect all of the `onDestroy` callbacks registered during rendering. In an async context, this is only safe to call
3051
+ * after awaiting `collect_async`.
3052
+ *
3053
+ * Child renderers are "porous" and don't affect execution order, but component body renderers
3054
+ * create ordering boundaries. Within a renderer, callbacks run in order until hitting a component boundary.
3055
+ * @returns {Iterable<() => void>}
3056
+ */
3057
+ *#collect_on_destroy() {
3058
+ for (const component of this.#traverse_components()) {
3059
+ yield* component.#collect_ondestroy();
3060
+ }
3061
+ }
3062
+ /**
3063
+ * Performs a depth-first search of renderers, yielding the deepest components first, then additional components as we backtrack up the tree.
3064
+ * @returns {Iterable<Renderer>}
3065
+ */
3066
+ *#traverse_components() {
3067
+ for (const child of this.#out) {
3068
+ if (typeof child !== "string") {
3069
+ yield* child.#traverse_components();
3070
+ }
3071
+ }
3072
+ if (this.#is_component_body) {
3073
+ yield this;
3074
+ }
3075
+ }
3076
+ /**
3077
+ * @returns {Iterable<() => void>}
3078
+ */
3079
+ *#collect_ondestroy() {
3080
+ if (this.#on_destroy) {
3081
+ for (const fn of this.#on_destroy) {
3082
+ yield fn;
3083
+ }
3084
+ }
3085
+ for (const child of this.#out) {
3086
+ if (child instanceof Renderer && !child.#is_component_body) {
3087
+ yield* child.#collect_ondestroy();
3088
+ }
3089
+ }
3090
+ }
3091
+ /**
3092
+ * Render a component. Throws if any of the children are performing asynchronous work.
3093
+ *
3094
+ * @template {Record<string, any>} Props
3095
+ * @param {Component<Props>} component
3096
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string }} options
3097
+ * @returns {AccumulatedContent}
3098
+ */
3099
+ static #render(component, options) {
3100
+ var previous_context = ssr_context;
3101
+ try {
3102
+ const renderer = Renderer.#open_render("sync", component, options);
3103
+ const content = renderer.#collect_content();
3104
+ return Renderer.#close_render(content, renderer);
3105
+ } finally {
3106
+ abort();
3107
+ set_ssr_context(previous_context);
3108
+ }
3109
+ }
3110
+ /**
3111
+ * Render a component.
3112
+ *
3113
+ * @template {Record<string, any>} Props
3114
+ * @param {Component<Props>} component
3115
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp }} options
3116
+ * @returns {Promise<AccumulatedContent & { hashes: { script: Sha256Source[] } }>}
3117
+ */
3118
+ static async #render_async(component, options) {
3119
+ const previous_context = ssr_context;
3120
+ try {
3121
+ const renderer = Renderer.#open_render("async", component, options);
3122
+ const content = await renderer.#collect_content_async();
3123
+ const hydratables = await renderer.#collect_hydratables();
3124
+ if (hydratables !== null) {
3125
+ content.head = hydratables + content.head;
3126
+ }
3127
+ return Renderer.#close_render(content, renderer);
3128
+ } finally {
3129
+ set_ssr_context(previous_context);
3130
+ abort();
3131
+ }
3132
+ }
3133
+ /**
3134
+ * Collect all of the code from the `out` array and return it as a string, or a promise resolving to a string.
3135
+ * @param {AccumulatedContent} content
3136
+ * @returns {AccumulatedContent}
3137
+ */
3138
+ #collect_content(content = { head: "", body: "" }) {
3139
+ for (const item of this.#out) {
3140
+ if (typeof item === "string") {
3141
+ content[this.type] += item;
3142
+ } else if (item instanceof Renderer) {
3143
+ item.#collect_content(content);
3144
+ }
3145
+ }
3146
+ return content;
3147
+ }
3148
+ /**
3149
+ * Collect all of the code from the `out` array and return it as a string.
3150
+ * @param {AccumulatedContent} content
3151
+ * @returns {Promise<AccumulatedContent>}
3152
+ */
3153
+ async #collect_content_async(content = { head: "", body: "" }) {
3154
+ await this.promise;
3155
+ for (const item of this.#out) {
3156
+ if (typeof item === "string") {
3157
+ content[this.type] += item;
3158
+ } else if (item instanceof Renderer) {
3159
+ if (item.#boundary) {
3160
+ const boundary_content = { head: "", body: "" };
3161
+ try {
3162
+ await item.#collect_content_async(boundary_content);
3163
+ content.head += boundary_content.head;
3164
+ content.body += boundary_content.body;
3165
+ } catch (error) {
3166
+ const { context, failed, transformError } = item.#boundary;
3167
+ set_ssr_context(context);
3168
+ let transformed = await transformError(error);
3169
+ const failed_renderer = new Renderer(item.global, item);
3170
+ failed_renderer.type = item.type;
3171
+ failed_renderer.#out.push(Renderer.#serialize_failed_boundary(transformed));
3172
+ failed(failed_renderer, transformed, noop);
3173
+ failed_renderer.#out.push(BLOCK_CLOSE);
3174
+ await failed_renderer.#collect_content_async(content);
3175
+ }
3176
+ } else {
3177
+ await item.#collect_content_async(content);
3178
+ }
3179
+ }
3180
+ }
3181
+ return content;
3182
+ }
3183
+ async #collect_hydratables() {
3184
+ const ctx = get_render_context().hydratable;
3185
+ for (const [_, key] of ctx.unresolved_promises) {
3186
+ unresolved_hydratable(key, ctx.lookup.get(key)?.stack ?? "<missing stack trace>");
3187
+ }
3188
+ for (const comparison of ctx.comparisons) {
3189
+ await comparison;
3190
+ }
3191
+ return await this.#hydratable_block(ctx);
3192
+ }
3193
+ /**
3194
+ * @template {Record<string, any>} Props
3195
+ * @param {'sync' | 'async'} mode
3196
+ * @param {import('svelte').Component<Props>} component
3197
+ * @param {{ props?: Omit<Props, '$$slots' | '$$events'>; context?: Map<any, any>; idPrefix?: string; csp?: Csp; transformError?: (error: unknown) => unknown }} options
3198
+ * @returns {Renderer}
3199
+ */
3200
+ static #open_render(mode, component, options) {
3201
+ var previous_context = ssr_context;
3202
+ try {
3203
+ const renderer = new Renderer(
3204
+ new SSRState(
3205
+ mode,
3206
+ options.idPrefix ? options.idPrefix + "-" : "",
3207
+ options.csp,
3208
+ options.transformError
3209
+ )
3210
+ );
3211
+ const context = { p: null, c: options.context ?? null, r: renderer };
3212
+ set_ssr_context(context);
3213
+ renderer.push(BLOCK_OPEN);
3214
+ component(renderer, options.props ?? {});
3215
+ renderer.push(BLOCK_CLOSE);
3216
+ return renderer;
3217
+ } finally {
3218
+ set_ssr_context(previous_context);
3219
+ }
3220
+ }
3221
+ /**
3222
+ * @param {AccumulatedContent} content
3223
+ * @param {Renderer} renderer
3224
+ * @returns {AccumulatedContent & { hashes: { script: Sha256Source[] } }}
3225
+ */
3226
+ static #close_render(content, renderer) {
3227
+ for (const cleanup of renderer.#collect_on_destroy()) {
3228
+ cleanup();
3229
+ }
3230
+ let head2 = content.head + renderer.global.get_title();
3231
+ let body = content.body;
3232
+ for (const { hash, code } of renderer.global.css) {
3233
+ head2 += `<style id="${hash}">${code}</style>`;
3234
+ }
3235
+ return {
3236
+ head: head2,
3237
+ body,
3238
+ hashes: {
3239
+ script: renderer.global.csp.script_hashes
3240
+ }
3241
+ };
3242
+ }
3243
+ /**
3244
+ * @param {HydratableContext} ctx
3245
+ */
3246
+ async #hydratable_block(ctx) {
3247
+ if (ctx.lookup.size === 0) {
3248
+ return null;
3249
+ }
3250
+ let entries = [];
3251
+ let has_promises = false;
3252
+ for (const [k, v] of ctx.lookup) {
3253
+ if (v.promises) {
3254
+ has_promises = true;
3255
+ for (const p of v.promises) await p;
3256
+ }
3257
+ entries.push(`[${uneval(k)},${v.serialized}]`);
3258
+ }
3259
+ let prelude = `const h = (window.__svelte ??= {}).h ??= new Map();`;
3260
+ if (has_promises) {
3261
+ prelude = `const r = (v) => Promise.resolve(v);
3262
+ ${prelude}`;
3263
+ }
3264
+ const body = `
3265
+ {
3266
+ ${prelude}
3267
+
3268
+ for (const [k, v] of [
3269
+ ${entries.join(",\n ")}
3270
+ ]) {
3271
+ h.set(k, v);
3272
+ }
3273
+ }
3274
+ `;
3275
+ let csp_attr = "";
3276
+ if (this.global.csp.nonce) {
3277
+ csp_attr = ` nonce="${this.global.csp.nonce}"`;
3278
+ } else if (this.global.csp.hash) {
3279
+ const hash = await sha256(body);
3280
+ this.global.csp.script_hashes.push(`sha256-${hash}`);
3281
+ }
3282
+ return `
3283
+ <script${csp_attr}>${body}<\/script>`;
3284
+ }
3285
+ }
3286
+ class SSRState {
3287
+ /** @readonly @type {Csp & { script_hashes: Sha256Source[] }} */
3288
+ csp;
3289
+ /** @readonly @type {'sync' | 'async'} */
3290
+ mode;
3291
+ /** @readonly @type {() => string} */
3292
+ uid;
3293
+ /** @readonly @type {Set<{ hash: string; code: string }>} */
3294
+ css = /* @__PURE__ */ new Set();
3295
+ /**
3296
+ * `transformError` passed to `render`. Called when an error boundary catches an error.
3297
+ * Throws by default if unset in `render`.
3298
+ * @type {(error: unknown) => unknown}
3299
+ */
3300
+ transformError;
3301
+ /** @type {{ path: number[], value: string }} */
3302
+ #title = { path: [], value: "" };
3303
+ /**
3304
+ * @param {'sync' | 'async'} mode
3305
+ * @param {string} id_prefix
3306
+ * @param {Csp} csp
3307
+ * @param {((error: unknown) => unknown) | undefined} [transformError]
3308
+ */
3309
+ constructor(mode, id_prefix = "", csp = { hash: false }, transformError) {
3310
+ this.mode = mode;
3311
+ this.csp = { ...csp, script_hashes: [] };
3312
+ this.transformError = transformError ?? ((error) => {
3313
+ throw error;
3314
+ });
3315
+ let uid2 = 1;
3316
+ this.uid = () => `${id_prefix}s${uid2++}`;
3317
+ }
3318
+ get_title() {
3319
+ return this.#title.value;
3320
+ }
3321
+ /**
3322
+ * Performs a depth-first (lexicographic) comparison using the path. Rejects sets
3323
+ * from earlier than or equal to the current value.
3324
+ * @param {string} value
3325
+ * @param {number[]} path
3326
+ */
3327
+ set_title(value, path) {
3328
+ const current = this.#title.path;
3329
+ let i = 0;
3330
+ let l = Math.min(path.length, current.length);
3331
+ while (i < l && path[i] === current[i]) i += 1;
3332
+ if (path[i] === void 0) return;
3333
+ if (current[i] === void 0 || path[i] > current[i]) {
3334
+ this.#title.path = path;
3335
+ this.#title.value = value;
3336
+ }
3337
+ }
3338
+ }
3339
+ const INVALID_ATTR_NAME_CHAR_REGEX = /[\s'">/=\u{FDD0}-\u{FDEF}\u{FFFE}\u{FFFF}\u{1FFFE}\u{1FFFF}\u{2FFFE}\u{2FFFF}\u{3FFFE}\u{3FFFF}\u{4FFFE}\u{4FFFF}\u{5FFFE}\u{5FFFF}\u{6FFFE}\u{6FFFF}\u{7FFFE}\u{7FFFF}\u{8FFFE}\u{8FFFF}\u{9FFFE}\u{9FFFF}\u{AFFFE}\u{AFFFF}\u{BFFFE}\u{BFFFF}\u{CFFFE}\u{CFFFF}\u{DFFFE}\u{DFFFF}\u{EFFFE}\u{EFFFF}\u{FFFFE}\u{FFFFF}\u{10FFFE}\u{10FFFF}]/u;
3340
+ function render(component, options = {}) {
3341
+ if (options.csp?.hash && options.csp.nonce) {
3342
+ invalid_csp();
3343
+ }
3344
+ return Renderer.render(
3345
+ /** @type {Component<Props>} */
3346
+ component,
3347
+ options
3348
+ );
3349
+ }
3350
+ function head(hash, renderer, fn) {
3351
+ renderer.head((renderer2) => {
3352
+ renderer2.push(`<!--${hash}-->`);
3353
+ renderer2.child(fn);
3354
+ renderer2.push(EMPTY_COMMENT);
3355
+ });
3356
+ }
3357
+ function attributes(attrs, css_hash, classes, styles, flags = 0) {
3358
+ if (styles) {
3359
+ attrs.style = to_style(attrs.style, styles);
3360
+ }
3361
+ if (attrs.class) {
3362
+ attrs.class = clsx(attrs.class);
3363
+ }
3364
+ if (css_hash || classes) {
3365
+ attrs.class = to_class(attrs.class, css_hash, classes);
3366
+ }
3367
+ let attr_str = "";
3368
+ let name;
3369
+ const is_html = (flags & ELEMENT_IS_NAMESPACED) === 0;
3370
+ const lowercase = (flags & ELEMENT_PRESERVE_ATTRIBUTE_CASE) === 0;
3371
+ const is_input = (flags & ELEMENT_IS_INPUT) !== 0;
3372
+ for (name of Object.keys(attrs)) {
3373
+ if (typeof attrs[name] === "function") continue;
3374
+ if (name[0] === "$" && name[1] === "$") continue;
3375
+ if (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;
3376
+ var value = attrs[name];
3377
+ var lower = name.toLowerCase();
3378
+ if (lowercase) name = lower;
3379
+ if (lower.length > 2 && lower.startsWith("on")) continue;
3380
+ if (is_input) {
3381
+ if (name === "defaultvalue" || name === "defaultchecked") {
3382
+ name = name === "defaultvalue" ? "value" : "checked";
3383
+ if (attrs[name]) continue;
3384
+ }
3385
+ }
3386
+ attr_str += attr(name, value, is_html && is_boolean_attribute(name));
3387
+ }
3388
+ return attr_str;
3389
+ }
3390
+ function stringify(value) {
3391
+ return typeof value === "string" ? value : value == null ? "" : value + "";
3392
+ }
3393
+ function attr_class(value, hash, directives) {
3394
+ var result = to_class(value, hash, directives);
3395
+ return result ? ` class="${escape_html(result, true)}"` : "";
3396
+ }
3397
+ function store_get(store_values, store_name, store) {
3398
+ if (store_name in store_values && store_values[store_name][0] === store) {
3399
+ return store_values[store_name][2];
3400
+ }
3401
+ store_values[store_name]?.[1]();
3402
+ store_values[store_name] = [store, null, void 0];
3403
+ const unsub = subscribe_to_store(
3404
+ store,
3405
+ /** @param {any} v */
3406
+ (v) => store_values[store_name][2] = v
3407
+ );
3408
+ store_values[store_name][1] = unsub;
3409
+ return store_values[store_name][2];
3410
+ }
3411
+ function unsubscribe_stores(store_values) {
3412
+ for (const store_name of Object.keys(store_values)) {
3413
+ store_values[store_name][1]();
3414
+ }
3415
+ }
3416
+ function bind_props(props_parent, props_now) {
3417
+ for (const key of Object.keys(props_now)) {
3418
+ const initial_value = props_parent[key];
3419
+ const value = props_now[key];
3420
+ if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) {
3421
+ props_parent[key] = value;
3422
+ }
3423
+ }
3424
+ }
3425
+ function await_block(renderer, promise, pending_fn, then_fn) {
3426
+ if (is_promise(promise)) {
3427
+ renderer.push(BLOCK_OPEN);
3428
+ promise.then(null, noop);
3429
+ if (pending_fn !== null) {
3430
+ pending_fn();
3431
+ }
3432
+ } else if (then_fn !== null) {
3433
+ renderer.push(BLOCK_OPEN_ELSE);
3434
+ then_fn(promise);
3435
+ }
3436
+ }
3437
+ function ensure_array_like(array_like_or_iterator) {
3438
+ if (array_like_or_iterator) {
3439
+ return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
3440
+ }
3441
+ return [];
3442
+ }
3443
+ function once(get_value) {
3444
+ let value = (
3445
+ /** @type {V} */
3446
+ UNINITIALIZED
3447
+ );
3448
+ return () => {
3449
+ if (value === UNINITIALIZED) {
3450
+ value = get_value();
3451
+ }
3452
+ return value;
3453
+ };
3454
+ }
3455
+ function derived$1(fn) {
3456
+ const get_value = ssr_context === null ? fn : once(fn);
3457
+ let updated_value;
3458
+ return function(new_value) {
3459
+ if (arguments.length === 0) {
3460
+ return updated_value ?? get_value();
3461
+ }
3462
+ updated_value = new_value;
3463
+ return updated_value;
3464
+ };
3465
+ }
3466
+
3467
+ const subscriber_queue = [];
3468
+ function readable(value, start) {
3469
+ return {
3470
+ subscribe: writable(value, start).subscribe
3471
+ };
3472
+ }
3473
+ function writable(value, start = noop) {
3474
+ let stop = null;
3475
+ const subscribers = /* @__PURE__ */ new Set();
3476
+ function set(new_value) {
3477
+ if (safe_not_equal(value, new_value)) {
3478
+ value = new_value;
3479
+ if (stop) {
3480
+ const run_queue = !subscriber_queue.length;
3481
+ for (const subscriber of subscribers) {
3482
+ subscriber[1]();
3483
+ subscriber_queue.push(subscriber, value);
3484
+ }
3485
+ if (run_queue) {
3486
+ for (let i = 0; i < subscriber_queue.length; i += 2) {
3487
+ subscriber_queue[i][0](subscriber_queue[i + 1]);
3488
+ }
3489
+ subscriber_queue.length = 0;
3490
+ }
3491
+ }
3492
+ }
3493
+ }
3494
+ function update(fn) {
3495
+ set(fn(
3496
+ /** @type {T} */
3497
+ value
3498
+ ));
3499
+ }
3500
+ function subscribe(run, invalidate = noop) {
3501
+ const subscriber = [run, invalidate];
3502
+ subscribers.add(subscriber);
3503
+ if (subscribers.size === 1) {
3504
+ stop = start(set, update) || noop;
3505
+ }
3506
+ run(
3507
+ /** @type {T} */
3508
+ value
3509
+ );
3510
+ return () => {
3511
+ subscribers.delete(subscriber);
3512
+ if (subscribers.size === 0 && stop) {
3513
+ stop();
3514
+ stop = null;
3515
+ }
3516
+ };
3517
+ }
3518
+ return { set, update, subscribe };
3519
+ }
3520
+ function derived(stores, fn, initial_value) {
3521
+ const single = !Array.isArray(stores);
3522
+ const stores_array = single ? [stores] : stores;
3523
+ if (!stores_array.every(Boolean)) {
3524
+ throw new Error("derived() expects stores as input, got a falsy value");
3525
+ }
3526
+ const auto = fn.length < 2;
3527
+ return readable(initial_value, (set, update) => {
3528
+ let started = false;
3529
+ const values = [];
3530
+ let pending = 0;
3531
+ let cleanup = noop;
3532
+ const sync = () => {
3533
+ if (pending) {
3534
+ return;
3535
+ }
3536
+ cleanup();
3537
+ const result = fn(single ? values[0] : values, set, update);
3538
+ if (auto) {
3539
+ set(result);
3540
+ } else {
3541
+ cleanup = typeof result === "function" ? result : noop;
3542
+ }
3543
+ };
3544
+ const unsubscribers = stores_array.map(
3545
+ (store, i) => subscribe_to_store(
3546
+ store,
3547
+ (value) => {
3548
+ values[i] = value;
3549
+ pending &= ~(1 << i);
3550
+ if (started) {
3551
+ sync();
3552
+ }
3553
+ },
3554
+ () => {
3555
+ pending |= 1 << i;
3556
+ }
3557
+ )
3558
+ );
3559
+ started = true;
3560
+ sync();
3561
+ return function stop() {
3562
+ run_all(unsubscribers);
3563
+ cleanup();
3564
+ started = false;
3565
+ };
3566
+ });
3567
+ }
3568
+ function get(store) {
3569
+ let value;
3570
+ subscribe_to_store(store, (_) => value = _)();
3571
+ return value;
3572
+ }
3573
+
3574
+ export { setContext as $, get_prototype_of as A, object_prototype as B, noop as C, DevalueError as D, render as E, set as F, get$1 as G, flushSync as H, define_property as I, mutable_source as J, init_operations as K, LEGACY_PROPS as L, get_first_child as M, COMMENT_NODE as N, HYDRATION_START as O, get_next_sibling as P, HYDRATION_ERROR as Q, hydration_failed as R, clear_text_content as S, component_root as T, create_text as U, array_from as V, is_passive_event as W, set_active_reaction as X, set_active_effect as Y, active_reaction as Z, active_effect as _, is_plain_object as a, BOUNDARY_EFFECT as a0, block as a1, branch as a2, queue_micro_task as a3, pause_effect as a4, current_batch as a5, move_effect as a6, set_signal_status as a7, DIRTY as a8, MAYBE_DIRTY as a9, defer_effect as aa, set_component_context as ab, Batch as ac, handle_error as ad, component_context as ae, internal_set as af, destroy_effect as ag, invoke_error_boundary as ah, effect_tracking as ai, render_effect as aj, HYDRATION_END as ak, HYDRATION_START_ELSE as al, svelte_boundary_reset_onerror as am, source as an, untrack as ao, increment as ap, HYDRATION_START_FAILED as aq, push$1 as ar, pop$1 as as, EFFECT_TRANSPARENT as at, EFFECT_PRESERVED as au, bind_props as av, ssr_context as aw, get as ax, stringify_string as b, browser as c, attr as d, enumerable_symbols as e, stringify as f, get_type as g, head as h, is_primitive as i, store_get as j, escape_html as k, attr_class as l, derived$1 as m, derived as n, unsubscribe_stores as o, getContext as p, ensure_array_like as q, readable as r, stringify_key as s, clsx as t, uneval as u, valid_array_indices as v, writable as w, attributes as x, await_block as y, is_array as z };
3575
+ //# sourceMappingURL=index2-B2Ld-FFX.js.map