@qwik.dev/core 2.0.0-alpha.6 → 2.0.0-alpha.7

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 (52) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.darwin-x64.node +0 -0
  3. package/bindings/qwik.linux-x64-gnu.node +0 -0
  4. package/bindings/qwik.win32-x64-msvc.node +0 -0
  5. package/bindings/qwik_wasm_bg.wasm +0 -0
  6. package/dist/build/package.json +1 -1
  7. package/dist/cli.cjs +65 -42
  8. package/dist/core-internal.d.ts +77 -76
  9. package/dist/core.cjs +1498 -1323
  10. package/dist/core.cjs.map +1 -1
  11. package/dist/core.min.mjs +1 -1
  12. package/dist/core.mjs +1496 -1323
  13. package/dist/core.mjs.map +1 -1
  14. package/dist/core.prod.cjs +884 -782
  15. package/dist/core.prod.mjs +1006 -867
  16. package/dist/insights/index.qwik.cjs +3652 -154
  17. package/dist/insights/index.qwik.mjs +3652 -154
  18. package/dist/loader/index.cjs +2 -2
  19. package/dist/loader/index.mjs +2 -2
  20. package/dist/loader/package.json +1 -1
  21. package/dist/optimizer.cjs +210 -5714
  22. package/dist/optimizer.mjs +191 -6037
  23. package/dist/prefetch/package.json +1 -1
  24. package/dist/qwikloader.debug.js +12 -15
  25. package/dist/qwikloader.js +2 -2
  26. package/dist/server.cjs +762 -7127
  27. package/dist/server.mjs +778 -7121
  28. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +2 -0
  29. package/dist/starters/features/cypress/package.json +1 -1
  30. package/dist/starters/features/drizzle/drizzle/schema.ts +6 -18
  31. package/dist/starters/features/drizzle/drizzle.config.ts +5 -4
  32. package/dist/starters/features/drizzle/package.json +14 -11
  33. package/dist/starters/features/pandacss/package.json +1 -1
  34. package/dist/starters/features/partytown/package.json +1 -1
  35. package/dist/starters/features/postcss/package.json +1 -1
  36. package/dist/starters/features/prisma/package.json +1 -1
  37. package/dist/starters/features/react/package.json +1 -1
  38. package/dist/starters/features/storybook/package.json +1 -1
  39. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  40. package/dist/starters/features/tailwind/package.json +15 -9
  41. package/dist/starters/features/tailwind/src/global.css +1 -7
  42. package/dist/starters/features/turso/package.json +1 -1
  43. package/dist/starters/features/vitest/package.json +1 -1
  44. package/dist/testing/index.cjs +1265 -1124
  45. package/dist/testing/index.mjs +1271 -1124
  46. package/dist/testing/package.json +1 -1
  47. package/handlers.mjs +9 -0
  48. package/package.json +6 -4
  49. package/public.d.ts +2 -0
  50. package/dist/starters/features/tailwind/.vscode/settings.json +0 -3
  51. package/dist/starters/features/tailwind/postcss.config.cjs +0 -6
  52. package/dist/starters/features/tailwind/tailwind.config.js +0 -8
@@ -2,15 +2,23 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ var _a, _b, _c;
5
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
7
  const core = require("@qwik.dev/core");
8
+ var isBrowser = /* @__PURE__ */ (() => typeof window !== "undefined" && typeof HTMLElement !== "undefined" && !!window.document && String(HTMLElement).includes("[native code]"))();
9
+ var isServer = !isBrowser;
10
+ var isDev = false;
7
11
  /**
8
12
  * @license
9
- * @qwik.dev/core 2.0.0-alpha.6-dev+d848ba5
13
+ * @qwik.dev/core 2.0.0-alpha.7-dev+a26598a
10
14
  * Copyright QwikDev. All Rights Reserved.
11
15
  * Use of this source code is governed by an MIT-style license that can be
12
16
  * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
13
17
  */
18
+ const logError = (message, ...optionalParams) => createAndLogError(false, message, ...optionalParams);
19
+ const throwErrorAndStop = (message, ...optionalParams) => {
20
+ throw createAndLogError(false, message, ...optionalParams);
21
+ };
14
22
  const logErrorAndStop = (message, ...optionalParams) => createAndLogError(true, message, ...optionalParams);
15
23
  const createAndLogError = (asyncThrow, message, ...optionalParams) => {
16
24
  const err = message instanceof Error ? message : new Error(message);
@@ -18,6 +26,10 @@ const createAndLogError = (asyncThrow, message, ...optionalParams) => {
18
26
  throw err;
19
27
  }, 0), err;
20
28
  };
29
+ function assertDefined() {
30
+ }
31
+ function assertEqual() {
32
+ }
21
33
  function assertTrue() {
22
34
  }
23
35
  function assertFalse() {
@@ -25,12 +37,18 @@ function assertFalse() {
25
37
  const codeToText = (code) => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
26
38
  var QError;
27
39
  !function(QError2) {
28
- QError2[QError2.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError2[QError2.UNUSED_1 = 1] = "UNUSED_1", QError2[QError2.UNUSED_2 = 2] = "UNUSED_2", QError2[QError2.verifySerializable = 3] = "verifySerializable", QError2[QError2.UNUSED_4 = 4] = "UNUSED_4", QError2[QError2.cannotRenderOverExistingContainer = 5] = "cannotRenderOverExistingContainer", QError2[QError2.UNUSED_6 = 6] = "UNUSED_6", QError2[QError2.UNUSED_7 = 7] = "UNUSED_7", QError2[QError2.UNUSED_8 = 8] = "UNUSED_8", QError2[QError2.UNUSED_9 = 9] = "UNUSED_9", QError2[QError2.qrlIsNotFunction = 10] = "qrlIsNotFunction", QError2[QError2.dynamicImportFailed = 11] = "dynamicImportFailed", QError2[QError2.unknownTypeArgument = 12] = "unknownTypeArgument", QError2[QError2.notFoundContext = 13] = "notFoundContext", QError2[QError2.useMethodOutsideContext = 14] = "useMethodOutsideContext", QError2[QError2.UNUSED_15 = 15] = "UNUSED_15", QError2[QError2.UNUSED_16 = 16] = "UNUSED_16", QError2[QError2.UNUSED_17 = 17] = "UNUSED_17", QError2[QError2.UNUSED_18 = 18] = "UNUSED_18", QError2[QError2.UNUSED_19 = 19] = "UNUSED_19", QError2[QError2.useInvokeContext = 20] = "useInvokeContext", QError2[QError2.UNUSED_21 = 21] = "UNUSED_21", QError2[QError2.UNUSED_22 = 22] = "UNUSED_22", QError2[QError2.UNUSED_23 = 23] = "UNUSED_23", QError2[QError2.UNUSED_24 = 24] = "UNUSED_24", QError2[QError2.UNUSED_25 = 25] = "UNUSED_25", QError2[QError2.UNUSED_26 = 26] = "UNUSED_26", QError2[QError2.UNUSED_27 = 27] = "UNUSED_27", QError2[QError2.invalidContext = 28] = "invalidContext", QError2[QError2.tagError = 29] = "tagError", QError2[QError2.qrlMissingContainer = 30] = "qrlMissingContainer", QError2[QError2.qrlMissingChunk = 31] = "qrlMissingChunk", QError2[QError2.invalidRefValue = 32] = "invalidRefValue", QError2[QError2.serializeErrorNotImplemented = 33] = "serializeErrorNotImplemented", QError2[QError2.serializeErrorExpectedVNode = 34] = "serializeErrorExpectedVNode", QError2[QError2.serializeErrorCannotAllocate = 35] = "serializeErrorCannotAllocate", QError2[QError2.serializeErrorMissingRootId = 36] = "serializeErrorMissingRootId", QError2[QError2.serializeErrorUnknownType = 37] = "serializeErrorUnknownType", QError2[QError2.serializeErrorUnvisited = 38] = "serializeErrorUnvisited", QError2[QError2.serializeErrorMissingChunk = 39] = "serializeErrorMissingChunk", QError2[QError2.wrongTextareaValue = 40] = "wrongTextareaValue", QError2[QError2.containerNotFound = 41] = "containerNotFound", QError2[QError2.elementWithoutContainer = 42] = "elementWithoutContainer", QError2[QError2.invalidVNodeType = 43] = "invalidVNodeType", QError2[QError2.materializeVNodeDataError = 44] = "materializeVNodeDataError", QError2[QError2.cannotCoerceSignal = 45] = "cannotCoerceSignal", QError2[QError2.computedNotSync = 46] = "computedNotSync", QError2[QError2.computedReadOnly = 47] = "computedReadOnly", QError2[QError2.wrappedReadOnly = 48] = "wrappedReadOnly", QError2[QError2.promisesNotExpected = 49] = "promisesNotExpected", QError2[QError2.unsafeAttr = 50] = "unsafeAttr";
40
+ QError2[QError2.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError2[QError2.schedulerNotFound = 1] = "schedulerNotFound", QError2[QError2.trackObjectWithoutProp = 2] = "trackObjectWithoutProp", QError2[QError2.verifySerializable = 3] = "verifySerializable", QError2[QError2.UNUSED_4 = 4] = "UNUSED_4", QError2[QError2.cannotRenderOverExistingContainer = 5] = "cannotRenderOverExistingContainer", QError2[QError2.UNUSED_6 = 6] = "UNUSED_6", QError2[QError2.UNUSED_7 = 7] = "UNUSED_7", QError2[QError2.UNUSED_8 = 8] = "UNUSED_8", QError2[QError2.UNUSED_9 = 9] = "UNUSED_9", QError2[QError2.qrlIsNotFunction = 10] = "qrlIsNotFunction", QError2[QError2.dynamicImportFailed = 11] = "dynamicImportFailed", QError2[QError2.unknownTypeArgument = 12] = "unknownTypeArgument", QError2[QError2.notFoundContext = 13] = "notFoundContext", QError2[QError2.useMethodOutsideContext = 14] = "useMethodOutsideContext", QError2[QError2.UNUSED_15 = 15] = "UNUSED_15", QError2[QError2.UNUSED_16 = 16] = "UNUSED_16", QError2[QError2.UNUSED_17 = 17] = "UNUSED_17", QError2[QError2.UNUSED_18 = 18] = "UNUSED_18", QError2[QError2.UNUSED_19 = 19] = "UNUSED_19", QError2[QError2.useInvokeContext = 20] = "useInvokeContext", QError2[QError2.UNUSED_21 = 21] = "UNUSED_21", QError2[QError2.UNUSED_22 = 22] = "UNUSED_22", QError2[QError2.UNUSED_23 = 23] = "UNUSED_23", QError2[QError2.UNUSED_24 = 24] = "UNUSED_24", QError2[QError2.UNUSED_25 = 25] = "UNUSED_25", QError2[QError2.UNUSED_26 = 26] = "UNUSED_26", QError2[QError2.UNUSED_27 = 27] = "UNUSED_27", QError2[QError2.invalidContext = 28] = "invalidContext", QError2[QError2.tagError = 29] = "tagError", QError2[QError2.qrlMissingContainer = 30] = "qrlMissingContainer", QError2[QError2.qrlMissingChunk = 31] = "qrlMissingChunk", QError2[QError2.invalidRefValue = 32] = "invalidRefValue", QError2[QError2.serializeErrorNotImplemented = 33] = "serializeErrorNotImplemented", QError2[QError2.serializeErrorExpectedVNode = 34] = "serializeErrorExpectedVNode", QError2[QError2.serializeErrorCannotAllocate = 35] = "serializeErrorCannotAllocate", QError2[QError2.serializeErrorMissingRootId = 36] = "serializeErrorMissingRootId", QError2[QError2.serializeErrorUnknownType = 37] = "serializeErrorUnknownType", QError2[QError2.serializeErrorUnvisited = 38] = "serializeErrorUnvisited", QError2[QError2.serializeErrorMissingChunk = 39] = "serializeErrorMissingChunk", QError2[QError2.wrongTextareaValue = 40] = "wrongTextareaValue", QError2[QError2.containerNotFound = 41] = "containerNotFound", QError2[QError2.elementWithoutContainer = 42] = "elementWithoutContainer", QError2[QError2.invalidVNodeType = 43] = "invalidVNodeType", QError2[QError2.materializeVNodeDataError = 44] = "materializeVNodeDataError", QError2[QError2.cannotCoerceSignal = 45] = "cannotCoerceSignal", QError2[QError2.computedNotSync = 46] = "computedNotSync", QError2[QError2.computedReadOnly = 47] = "computedReadOnly", QError2[QError2.wrappedReadOnly = 48] = "wrappedReadOnly", QError2[QError2.unsafeAttr = 49] = "unsafeAttr";
29
41
  }(QError || (QError = {}));
30
42
  const qError = (code, errorMessageArgs = []) => {
31
43
  const text = codeToText(code, ...errorMessageArgs);
32
44
  return logErrorAndStop(text, ...errorMessageArgs);
33
45
  };
46
+ const isSyncQrl = (value) => isQrl$1(value) && "<sync>" == value.$symbol$;
47
+ const isQrl$1 = (value) => "function" == typeof value && "function" == typeof value.getSymbol;
48
+ const getSymbolHash = (symbolName) => {
49
+ const index = symbolName.lastIndexOf("_");
50
+ return index > -1 ? symbolName.slice(index + 1) : symbolName;
51
+ };
34
52
  var VirtualType;
35
53
  !function(VirtualType2) {
36
54
  VirtualType2.Virtual = "V", VirtualType2.Fragment = "F", VirtualType2.WrappedSignal = "S", VirtualType2.Awaited = "A", VirtualType2.Component = "C", VirtualType2.InlineComponent = "I", VirtualType2.Projection = "P";
@@ -48,93 +66,1675 @@ var QContainerValue;
48
66
  !function(QContainerValue2) {
49
67
  QContainerValue2.PAUSED = "paused", QContainerValue2.RESUMED = "resumed", QContainerValue2.HTML = "html", QContainerValue2.TEXT = "text";
50
68
  }(QContainerValue || (QContainerValue = {}));
69
+ const QSlot = "q:slot";
70
+ const QSlotS = "q:s";
71
+ const QStyle = "q:style";
72
+ const QStyleSelector = "style[q\\:style]";
73
+ const QStylesAllSelector = "style[q\\:style],style[q\\:sstyle]";
74
+ const getQFuncs = (document2, hash) => document2["qFuncs_" + hash] || [];
75
+ const QContainerIsland = "q:container-island";
76
+ const QContainerIslandEnd = "/" + QContainerIsland;
77
+ const QIgnore = "q:ignore";
78
+ const QIgnoreEnd = "/q:ignore";
79
+ const QTemplate = "q:template";
51
80
  const QContainerSelector = "[q\\:container]:not([q\\:container=" + QContainerValue.HTML + "]):not([q\\:container=" + QContainerValue.TEXT + "])";
81
+ const HTML_NS = "http://www.w3.org/1999/xhtml";
82
+ const SVG_NS = "http://www.w3.org/2000/svg";
83
+ const MATH_NS = "http://www.w3.org/1998/Math/MathML";
52
84
  const dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
85
+ const createPlatform = () => ({
86
+ isServer,
87
+ importSymbol(containerEl, url, symbolName) {
88
+ if (isServer) {
89
+ const hash = getSymbolHash(symbolName);
90
+ const regSym = globalThis.__qwik_reg_symbols?.get(hash);
91
+ if (regSym) {
92
+ return regSym;
93
+ }
94
+ }
95
+ if (!url) {
96
+ throw qError(QError.qrlMissingChunk, [symbolName]);
97
+ }
98
+ if (!containerEl) {
99
+ throw qError(QError.qrlMissingContainer, [url, symbolName]);
100
+ }
101
+ const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
102
+ const urlCopy = new URL(urlDoc);
103
+ urlCopy.hash = "";
104
+ return import(urlCopy.href).then((mod) => mod[symbolName]);
105
+ },
106
+ raf: (fn) => new Promise((resolve) => {
107
+ requestAnimationFrame(() => {
108
+ resolve(fn());
109
+ });
110
+ }),
111
+ nextTick: (fn) => new Promise((resolve) => {
112
+ setTimeout(() => {
113
+ resolve(fn());
114
+ });
115
+ }),
116
+ chunkForSymbol: (symbolName, chunk) => [symbolName, chunk ?? "_"]
117
+ });
118
+ const toUrl = (doc, containerEl, url) => {
119
+ const baseURI = doc.baseURI;
120
+ const base = new URL(containerEl.getAttribute("q:base") ?? baseURI, baseURI);
121
+ return new URL(url, base);
122
+ };
123
+ let _platform = /* @__PURE__ */ createPlatform();
124
+ const getPlatform = () => _platform;
125
+ const isServerPlatform = () => _platform.isServer;
53
126
  const isPromise = (value) => !!value && "object" == typeof value && "function" == typeof value.then;
127
+ const safeCall = (call, thenFn, rejectFn) => {
128
+ try {
129
+ const result = call();
130
+ return isPromise(result) ? result.then(thenFn, rejectFn) : thenFn(result);
131
+ } catch (e) {
132
+ return rejectFn(e);
133
+ }
134
+ };
135
+ const maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
136
+ const shouldNotError = (reason) => {
137
+ throwErrorAndStop(reason);
138
+ };
139
+ const delay = (timeout) => new Promise((resolve) => {
140
+ setTimeout(resolve, timeout);
141
+ });
142
+ function retryOnPromise(fn, retryCount = 0) {
143
+ const retryOrThrow = (e) => {
144
+ if (isPromise(e) && retryCount < 100) {
145
+ return e.then(retryOnPromise.bind(null, fn, retryCount++));
146
+ }
147
+ throw e;
148
+ };
149
+ try {
150
+ const result = fn();
151
+ return isPromise(result) ? result.catch((e) => retryOrThrow(e)) : result;
152
+ } catch (e) {
153
+ return retryOrThrow(e);
154
+ }
155
+ }
156
+ const isSerializableObject = (v) => {
157
+ const proto = Object.getPrototypeOf(v);
158
+ return proto === Object.prototype || proto === Array.prototype || null === proto;
159
+ };
54
160
  const isArray = (v) => Array.isArray(v);
161
+ const isString = (v) => "string" == typeof v;
162
+ const isFunction = (v) => "function" == typeof v;
55
163
  var VNodeDataFlag;
56
164
  !function(VNodeDataFlag2) {
57
165
  VNodeDataFlag2[VNodeDataFlag2.NONE = 0] = "NONE", VNodeDataFlag2[VNodeDataFlag2.TEXT_DATA = 1] = "TEXT_DATA", VNodeDataFlag2[VNodeDataFlag2.VIRTUAL_NODE = 2] = "VIRTUAL_NODE", VNodeDataFlag2[VNodeDataFlag2.ELEMENT_NODE = 4] = "ELEMENT_NODE", VNodeDataFlag2[VNodeDataFlag2.REFERENCE = 8] = "REFERENCE", VNodeDataFlag2[VNodeDataFlag2.SERIALIZE = 16] = "SERIALIZE";
58
166
  }(VNodeDataFlag || (VNodeDataFlag = {}));
59
- const isQrl$1 = (value) => "function" == typeof value && "function" == typeof value.getSymbol;
167
+ const isQrl = (value) => "function" == typeof value && "function" == typeof value.getSymbol;
168
+ const EMPTY_ARRAY = [];
60
169
  const EMPTY_OBJ = {};
61
- Object.freeze(EMPTY_OBJ);
170
+ Object.freeze(EMPTY_ARRAY), Object.freeze(EMPTY_OBJ);
171
+ var ChoreType;
172
+ !function(ChoreType2) {
173
+ ChoreType2[ChoreType2.MACRO = 240] = "MACRO", ChoreType2[ChoreType2.MICRO = 15] = "MICRO", ChoreType2[ChoreType2.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType2[ChoreType2.RUN_QRL = 2] = "RUN_QRL", ChoreType2[ChoreType2.TASK = 3] = "TASK", ChoreType2[ChoreType2.NODE_DIFF = 4] = "NODE_DIFF", ChoreType2[ChoreType2.NODE_PROP = 5] = "NODE_PROP", ChoreType2[ChoreType2.COMPONENT = 6] = "COMPONENT", ChoreType2[ChoreType2.RECOMPUTE_AND_SCHEDULE_EFFECTS = 7] = "RECOMPUTE_AND_SCHEDULE_EFFECTS", ChoreType2[ChoreType2.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType2[ChoreType2.VISIBLE = 32] = "VISIBLE", ChoreType2[ChoreType2.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType2[ChoreType2.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
174
+ }(ChoreType || (ChoreType = {}));
175
+ const Slot = (props) => _jsxSorted(Virtual, null, {
176
+ [QSlotS]: ""
177
+ }, props.children, 0, props.name ?? "");
178
+ const SkipRender = Symbol("skip render");
179
+ const SSRRaw = () => null;
180
+ const SSRComment = () => null;
181
+ const isJsxPropertyAnEventName = (name) => (name.startsWith("on") || name.startsWith("window:on") || name.startsWith("document:on")) && name.endsWith("$");
182
+ const isHtmlAttributeAnEventName = (name) => name.startsWith("on:") || name.startsWith("on-window:") || name.startsWith("on-document:");
183
+ const getEventNameFromJsxProp = (name) => {
184
+ if (name.endsWith("$")) {
185
+ let idx = -1;
186
+ if (name.startsWith("on") ? idx = 2 : name.startsWith("window:on") ? idx = 9 : name.startsWith("document:on") && (idx = 11), -1 != idx) {
187
+ const isCaseSensitive = isDashAt(name, idx) && !isDashAt(name, idx + 1);
188
+ isCaseSensitive && idx++;
189
+ let lastIdx = idx;
190
+ let eventName = "";
191
+ for (; ; ) {
192
+ idx = name.indexOf("-", lastIdx);
193
+ const chunk = name.substring(lastIdx, -1 === idx ? name.length - 1 : idx);
194
+ if (eventName += isCaseSensitive ? chunk : chunk.toLowerCase(), -1 == idx) {
195
+ return eventName;
196
+ }
197
+ isDashAt(name, idx + 1) ? (eventName += "-", idx++) : (eventName += name.charAt(idx + 1).toUpperCase(), idx++), lastIdx = idx + 1;
198
+ }
199
+ }
200
+ }
201
+ return null;
202
+ };
203
+ const getEventNameScopeFromJsxProp = (name) => {
204
+ const index = name.indexOf(":");
205
+ return -1 !== index ? name.substring(0, index) : "";
206
+ };
207
+ const isDashAt = (name, idx) => 45 === name.charCodeAt(idx);
208
+ const convertEventNameFromJsxPropToHtmlAttr = (name) => {
209
+ if (name.endsWith("$")) {
210
+ let prefix = null;
211
+ if (name.startsWith("on") ? prefix = "on:" : name.startsWith("window:on") ? prefix = "on-window:" : name.startsWith("document:on") && (prefix = "on-document:"), null !== prefix) {
212
+ const eventName = getEventNameFromJsxProp(name);
213
+ return prefix + fromCamelToKebabCase(eventName);
214
+ }
215
+ }
216
+ return null;
217
+ };
218
+ const fromCamelToKebabCase = (text) => text.replace(/([A-Z-])/g, "-$1").toLowerCase();
219
+ function isPreventDefault(key) {
220
+ return key.startsWith("preventdefault:");
221
+ }
222
+ function getFileLocationFromJsx(jsxDev) {
223
+ if (!jsxDev) {
224
+ return null;
225
+ }
226
+ const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
227
+ return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
228
+ }
229
+ const styleContent = (styleId) => "⚡️" + styleId;
230
+ function hasClassAttr(props) {
231
+ for (const key in props) {
232
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
233
+ return true;
234
+ }
235
+ }
236
+ return false;
237
+ }
238
+ function isClassAttr(key) {
239
+ return "class" === key || "className" === key;
240
+ }
241
+ function convertScopedStyleIdsToArray(scopedStyleIds) {
242
+ return scopedStyleIds?.split(" ") ?? null;
243
+ }
244
+ function convertStyleIdsToString(scopedStyleIds) {
245
+ return Array.from(scopedStyleIds).join(" ");
246
+ }
247
+ const addComponentStylePrefix = (styleId) => {
248
+ if (styleId) {
249
+ let idx = 0;
250
+ do {
251
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
252
+ } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
253
+ }
254
+ return styleId || null;
255
+ };
256
+ const unitlessNumbers = /* @__PURE__ */ new Set(["animationIterationCount", "aspectRatio", "borderImageOutset", "borderImageSlice", "borderImageWidth", "boxFlex", "boxFlexGroup", "boxOrdinalGroup", "columnCount", "columns", "flex", "flexGrow", "flexShrink", "gridArea", "gridRow", "gridRowEnd", "gridRowStart", "gridColumn", "gridColumnEnd", "gridColumnStart", "fontWeight", "lineClamp", "lineHeight", "opacity", "order", "orphans", "scale", "tabSize", "widows", "zIndex", "zoom", "MozAnimationIterationCount", "MozBoxFlex", "msFlex", "msFlexPositive", "WebkitAnimationIterationCount", "WebkitBoxFlex", "WebkitBoxOrdinalGroup", "WebkitColumnCount", "WebkitColumns", "WebkitFlex", "WebkitFlexGrow", "WebkitFlexShrink", "WebkitLineClamp"]);
257
+ const isUnitlessNumber = (name) => unitlessNumbers.has(name);
258
+ const serializeClass = (obj) => {
259
+ if (!obj) {
260
+ return "";
261
+ }
262
+ if (isString(obj)) {
263
+ return obj.trim();
264
+ }
265
+ const classes = [];
266
+ if (isArray(obj)) {
267
+ for (const o of obj) {
268
+ const classList = serializeClass(o);
269
+ classList && classes.push(classList);
270
+ }
271
+ } else {
272
+ for (const [key, value] of Object.entries(obj)) {
273
+ value && classes.push(key.trim());
274
+ }
275
+ }
276
+ return classes.join(" ");
277
+ };
278
+ const fromCamelToKebabCaseWithDash = (text) => text.replace(/([A-Z])/g, "-$1").toLowerCase();
279
+ const stringifyStyle = (obj) => {
280
+ if (null == obj) {
281
+ return "";
282
+ }
283
+ if ("object" == typeof obj) {
284
+ if (isArray(obj)) {
285
+ throw qError(QError.stringifyClassOrStyle, [obj, "style"]);
286
+ }
287
+ {
288
+ const chunks = [];
289
+ for (const key in obj) {
290
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
291
+ const value = obj[key];
292
+ null != value && "function" != typeof value && (key.startsWith("--") ? chunks.push(key + ":" + value) : chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value)));
293
+ }
294
+ }
295
+ return chunks.join(";");
296
+ }
297
+ }
298
+ return String(obj);
299
+ };
300
+ const serializeBooleanOrNumberAttribute = (value) => null != value ? String(value) : null;
301
+ function serializeAttribute(key, value, styleScopedId) {
302
+ if (isClassAttr(key)) {
303
+ const serializedClass = serializeClass(value);
304
+ value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
305
+ } else {
306
+ "style" === key ? value = stringifyStyle(value) : isEnumeratedBooleanAttribute(key) || "number" == typeof value ? value = serializeBooleanOrNumberAttribute(value) : false === value || null == value ? value = null : true === value && isPreventDefault(key) && (value = "");
307
+ }
308
+ return value;
309
+ }
310
+ function isEnumeratedBooleanAttribute(key) {
311
+ return isAriaAttribute(key) || ["spellcheck", "draggable", "contenteditable"].includes(key);
312
+ }
313
+ const setValueForStyle = (styleName, value) => "number" != typeof value || 0 === value || isUnitlessNumber(styleName) ? value : value + "px";
314
+ function isAriaAttribute(prop) {
315
+ return prop.startsWith("aria-");
316
+ }
62
317
  const STORE_TARGET = Symbol("store.target");
318
+ const STORE_HANDLER = Symbol("store.handler");
319
+ const STORE_ARRAY_PROP = Symbol("store.array");
63
320
  var StoreFlags;
64
321
  !function(StoreFlags2) {
65
322
  StoreFlags2[StoreFlags2.NONE = 0] = "NONE", StoreFlags2[StoreFlags2.RECURSIVE = 1] = "RECURSIVE", StoreFlags2[StoreFlags2.IMMUTABLE = 2] = "IMMUTABLE";
66
323
  }(StoreFlags || (StoreFlags = {}));
324
+ const getStoreHandler = (value) => value[STORE_HANDLER];
325
+ const getStoreTarget = (value) => value?.[STORE_TARGET] || null;
326
+ const unwrapStore = (value) => getStoreTarget(value) || value;
67
327
  const isStore = (value) => STORE_TARGET in value;
68
- class Subscriber {
328
+ function createStore(container, obj, flags) {
329
+ return new Proxy(obj, new StoreHandler(flags, container || null));
330
+ }
331
+ const getOrCreateStore = (obj, flags, container) => {
332
+ if (isSerializableObject(obj) && container) {
333
+ let store = container.$storeProxyMap$.get(obj);
334
+ return store || (store = createStore(container, obj, flags), container.$storeProxyMap$.set(obj, store)), store;
335
+ }
336
+ return obj;
337
+ };
338
+ class StoreHandler {
339
+ constructor($flags$, $container$) {
340
+ __publicField(this, "$flags$");
341
+ __publicField(this, "$container$");
342
+ __publicField(this, "$effects$", null);
343
+ this.$flags$ = $flags$, this.$container$ = $container$;
344
+ }
345
+ toString() {
346
+ return "[Store]";
347
+ }
348
+ get(target, prop) {
349
+ if ("symbol" == typeof prop) {
350
+ return prop === STORE_TARGET ? target : prop === STORE_HANDLER ? this : target[prop];
351
+ }
352
+ const ctx = tryGetInvokeContext();
353
+ const value = target[prop];
354
+ if (ctx) {
355
+ if (null === this.$container$) {
356
+ if (!ctx.$container$) {
357
+ return value;
358
+ }
359
+ this.$container$ = ctx.$container$;
360
+ } else {
361
+ assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$);
362
+ }
363
+ const effectSubscriber = ctx.$effectSubscriber$;
364
+ effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
365
+ }
366
+ if ("toString" === prop && value === Object.prototype.toString) {
367
+ return this.toString;
368
+ }
369
+ return this.$flags$ & StoreFlags.RECURSIVE && "object" == typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
370
+ }
371
+ set(target, prop, value) {
372
+ if ("symbol" == typeof prop) {
373
+ return target[prop] = value, true;
374
+ }
375
+ const newValue = this.$flags$ & StoreFlags.RECURSIVE ? unwrapStore(value) : value;
376
+ if (prop in target) {
377
+ newValue !== target[prop] && setNewValueAndTriggerEffects(prop, newValue, target, this);
378
+ } else {
379
+ setNewValueAndTriggerEffects(prop, newValue, target, this);
380
+ }
381
+ return true;
382
+ }
383
+ deleteProperty(target, prop) {
384
+ return "string" == typeof prop && delete target[prop] && (triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$)), true);
385
+ }
386
+ has(target, prop) {
387
+ if (prop === STORE_TARGET) {
388
+ return true;
389
+ }
390
+ if ("string" == typeof prop) {
391
+ const ctx = tryGetInvokeContext();
392
+ if (ctx) {
393
+ const effectSubscriber = ctx.$effectSubscriber$;
394
+ effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
395
+ }
396
+ }
397
+ return Object.prototype.hasOwnProperty.call(target, prop);
398
+ }
399
+ ownKeys(target) {
400
+ const ctx = tryGetInvokeContext();
401
+ const effectSubscriber = ctx?.$effectSubscriber$;
402
+ return effectSubscriber && addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber), Reflect.ownKeys(target);
403
+ }
404
+ getOwnPropertyDescriptor(target, prop) {
405
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
406
+ return Array.isArray(target) || "symbol" == typeof prop || descriptor && !descriptor.configurable ? descriptor : {
407
+ enumerable: true,
408
+ configurable: true
409
+ };
410
+ }
411
+ }
412
+ function addEffect(target, prop, store, effectSubscription) {
413
+ const effectsMap = store.$effects$ || (store.$effects$ = /* @__PURE__ */ new Map());
414
+ let effects = effectsMap.get(prop);
415
+ effects || (effects = /* @__PURE__ */ new Set(), effectsMap.set(prop, effects)), ensureContainsSubscription(effects, effectSubscription), ensureContainsBackRef(effectSubscription, target), addQrlToSerializationCtx(effectSubscription, store.$container$);
416
+ }
417
+ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
418
+ target[prop] = value, triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
419
+ }
420
+ function getEffects(target, prop, storeEffects) {
421
+ let effectsToTrigger;
422
+ if (storeEffects) {
423
+ if (Array.isArray(target)) {
424
+ for (const effects of storeEffects.values()) {
425
+ effectsToTrigger || (effectsToTrigger = /* @__PURE__ */ new Set());
426
+ for (const effect of effects) {
427
+ effectsToTrigger.add(effect);
428
+ }
429
+ }
430
+ } else {
431
+ effectsToTrigger = storeEffects.get(prop);
432
+ }
433
+ }
434
+ const storeArrayValue = storeEffects?.get(STORE_ARRAY_PROP);
435
+ if (storeArrayValue) {
436
+ effectsToTrigger || (effectsToTrigger = /* @__PURE__ */ new Set());
437
+ for (const effect of storeArrayValue) {
438
+ effectsToTrigger.add(effect);
439
+ }
440
+ }
441
+ return effectsToTrigger || null;
442
+ }
443
+ const NEEDS_COMPUTATION = Symbol("invalid");
444
+ const _EFFECT_BACK_REF = Symbol("backRef");
445
+ _a = _EFFECT_BACK_REF;
446
+ class BackRef {
69
447
  constructor() {
70
- __publicField(this, "$effectDependencies$", null);
448
+ __publicField(this, _a, null);
449
+ }
450
+ }
451
+ function clearAllEffects(container, consumer) {
452
+ vnode_isVNode(consumer) && vnode_isElementVNode(consumer) && ensureMaterialized(consumer);
453
+ const effects = consumer[_EFFECT_BACK_REF];
454
+ if (effects) {
455
+ for (const [, effect] of effects) {
456
+ const backRefs = effect[EffectSubscriptionProp.BACK_REF];
457
+ if (!backRefs) {
458
+ return;
459
+ }
460
+ for (const producer of backRefs) {
461
+ if (producer instanceof Signal) {
462
+ clearSignal(container, producer, effect);
463
+ } else if (container.$storeProxyMap$.has(producer)) {
464
+ const target = container.$storeProxyMap$.get(producer);
465
+ clearStore(getStoreHandler(target), effect);
466
+ }
467
+ }
468
+ }
469
+ }
470
+ }
471
+ function clearSignal(container, producer, effect) {
472
+ const effects = producer.$effects$;
473
+ effects && effects.delete(effect), producer instanceof WrappedSignal && (producer.$hostElement$ = null, clearAllEffects(container, producer));
474
+ }
475
+ function clearStore(producer, effect) {
476
+ const effects = producer?.$effects$;
477
+ if (effects) {
478
+ for (const propEffects of effects.values()) {
479
+ propEffects.delete(effect);
480
+ }
481
+ }
482
+ }
483
+ function getSubscriber(effect, prop, data) {
484
+ effect[_EFFECT_BACK_REF] || (isServer && isSsrNode(effect) ? effect.setProp("q:brefs", /* @__PURE__ */ new Map()) : effect[_EFFECT_BACK_REF] = /* @__PURE__ */ new Map());
485
+ const subMap = effect[_EFFECT_BACK_REF];
486
+ let sub = subMap.get(prop);
487
+ return sub || (sub = [effect, prop], subMap.set(prop, sub)), data && (sub[EffectSubscriptionProp.DATA] = data), sub;
488
+ }
489
+ function isSsrNode(value) {
490
+ return "__brand__" in value && "currentComponentNode" in value;
491
+ }
492
+ var TaskFlags;
493
+ !function(TaskFlags2) {
494
+ TaskFlags2[TaskFlags2.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags2[TaskFlags2.TASK = 2] = "TASK", TaskFlags2[TaskFlags2.RESOURCE = 4] = "RESOURCE", TaskFlags2[TaskFlags2.DIRTY = 8] = "DIRTY";
495
+ }(TaskFlags || (TaskFlags = {}));
496
+ const runTask = (task, container, host) => {
497
+ task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
498
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
499
+ iCtx.$container$ = container;
500
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
501
+ let cleanupFns = null;
502
+ const cleanup2 = (fn) => {
503
+ "function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize(() => {
504
+ task.$destroy$ = null, cleanupFns.forEach((fn2) => {
505
+ try {
506
+ fn2();
507
+ } catch (err) {
508
+ container.handleError(err, host);
509
+ }
510
+ });
511
+ })), cleanupFns.push(fn));
512
+ };
513
+ const taskApi = {
514
+ track: (obj, prop) => {
515
+ const ctx = newInvokeContext();
516
+ return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container, invoke(ctx, () => {
517
+ if (isFunction(obj)) {
518
+ return obj();
519
+ }
520
+ if (prop) {
521
+ return obj[prop];
522
+ }
523
+ if (isSignal(obj)) {
524
+ return obj.value;
525
+ }
526
+ throw qError(QError.trackObjectWithoutProp);
527
+ });
528
+ },
529
+ cleanup: cleanup2
530
+ };
531
+ return safeCall(() => taskFn(taskApi), cleanup2, (err) => {
532
+ if (isPromise(err)) {
533
+ return err.then(() => runTask(task, container, host));
534
+ }
535
+ throw err;
536
+ });
537
+ };
538
+ const cleanupTask = (task) => {
539
+ const destroy = task.$destroy$;
540
+ if (destroy) {
541
+ task.$destroy$ = null;
542
+ try {
543
+ destroy();
544
+ } catch (err) {
545
+ logError(err);
546
+ }
547
+ }
548
+ };
549
+ class Task extends BackRef {
550
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
551
+ super();
552
+ __publicField(this, "$flags$");
553
+ __publicField(this, "$index$");
554
+ __publicField(this, "$el$");
555
+ __publicField(this, "$qrl$");
556
+ __publicField(this, "$state$");
557
+ __publicField(this, "$destroy$");
558
+ this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$, this.$state$ = $state$, this.$destroy$ = $destroy$;
559
+ }
560
+ }
561
+ const isTask = (value) => value instanceof Task;
562
+ var VNodeFlags;
563
+ var VNodeFlagsIndex;
564
+ var VNodeProps;
565
+ var ElementVNodeProps;
566
+ var TextVNodeProps;
567
+ var VirtualVNodeProps;
568
+ !function(VNodeFlags2) {
569
+ VNodeFlags2[VNodeFlags2.Element = 1] = "Element", VNodeFlags2[VNodeFlags2.Virtual = 2] = "Virtual", VNodeFlags2[VNodeFlags2.ELEMENT_OR_VIRTUAL_MASK = 3] = "ELEMENT_OR_VIRTUAL_MASK", VNodeFlags2[VNodeFlags2.ELEMENT_OR_TEXT_MASK = 5] = "ELEMENT_OR_TEXT_MASK", VNodeFlags2[VNodeFlags2.TYPE_MASK = 7] = "TYPE_MASK", VNodeFlags2[VNodeFlags2.INFLATED_TYPE_MASK = 15] = "INFLATED_TYPE_MASK", VNodeFlags2[VNodeFlags2.Text = 4] = "Text", VNodeFlags2[VNodeFlags2.Inflated = 8] = "Inflated", VNodeFlags2[VNodeFlags2.Resolved = 16] = "Resolved", VNodeFlags2[VNodeFlags2.Deleted = 32] = "Deleted", VNodeFlags2[VNodeFlags2.NAMESPACE_MASK = 192] = "NAMESPACE_MASK", VNodeFlags2[VNodeFlags2.NEGATED_NAMESPACE_MASK = -193] = "NEGATED_NAMESPACE_MASK", VNodeFlags2[VNodeFlags2.NS_html = 0] = "NS_html", VNodeFlags2[VNodeFlags2.NS_svg = 64] = "NS_svg", VNodeFlags2[VNodeFlags2.NS_math = 128] = "NS_math";
570
+ }(VNodeFlags || (VNodeFlags = {})), function(VNodeFlagsIndex2) {
571
+ VNodeFlagsIndex2[VNodeFlagsIndex2.mask = -256] = "mask", VNodeFlagsIndex2[VNodeFlagsIndex2.negated_mask = 255] = "negated_mask", VNodeFlagsIndex2[VNodeFlagsIndex2.shift = 8] = "shift";
572
+ }(VNodeFlagsIndex || (VNodeFlagsIndex = {})), function(VNodeProps2) {
573
+ VNodeProps2[VNodeProps2.flags = 0] = "flags", VNodeProps2[VNodeProps2.parent = 1] = "parent", VNodeProps2[VNodeProps2.previousSibling = 2] = "previousSibling", VNodeProps2[VNodeProps2.nextSibling = 3] = "nextSibling";
574
+ }(VNodeProps || (VNodeProps = {})), function(ElementVNodeProps2) {
575
+ ElementVNodeProps2[ElementVNodeProps2.firstChild = 4] = "firstChild", ElementVNodeProps2[ElementVNodeProps2.lastChild = 5] = "lastChild", ElementVNodeProps2[ElementVNodeProps2.element = 6] = "element", ElementVNodeProps2[ElementVNodeProps2.elementName = 7] = "elementName", ElementVNodeProps2[ElementVNodeProps2.PROPS_OFFSET = 8] = "PROPS_OFFSET";
576
+ }(ElementVNodeProps || (ElementVNodeProps = {})), function(TextVNodeProps2) {
577
+ TextVNodeProps2[TextVNodeProps2.node = 4] = "node", TextVNodeProps2[TextVNodeProps2.text = 5] = "text";
578
+ }(TextVNodeProps || (TextVNodeProps = {})), function(VirtualVNodeProps2) {
579
+ VirtualVNodeProps2[VirtualVNodeProps2.firstChild = 4] = "firstChild", VirtualVNodeProps2[VirtualVNodeProps2.lastChild = 5] = "lastChild", VirtualVNodeProps2[VirtualVNodeProps2.PROPS_OFFSET = 6] = "PROPS_OFFSET";
580
+ }(VirtualVNodeProps || (VirtualVNodeProps = {}));
581
+ const mapApp_findIndx = (elementVNode, key, start) => {
582
+ let bottom = start >> 1;
583
+ let top = elementVNode.length - 2 >> 1;
584
+ for (; bottom <= top; ) {
585
+ const mid = bottom + (top - bottom >> 1);
586
+ const midKey = elementVNode[mid << 1];
587
+ if (midKey === key) {
588
+ return mid << 1;
589
+ }
590
+ midKey < key ? bottom = mid + 1 : top = mid - 1;
591
+ }
592
+ return ~(bottom << 1);
593
+ };
594
+ const mapArray_set = (elementVNode, key, value, start) => {
595
+ const indx = mapApp_findIndx(elementVNode, key, start);
596
+ indx >= 0 ? null == value ? elementVNode.splice(indx, 2) : elementVNode[indx + 1] = value : null != value && elementVNode.splice(~indx, 0, key, value);
597
+ };
598
+ const mapArray_get = (elementVNode, key, start) => {
599
+ const indx = mapApp_findIndx(elementVNode, key, start);
600
+ return indx >= 0 ? elementVNode[indx + 1] : null;
601
+ };
602
+ const isForeignObjectElement = (elementName) => "foreignObject" === elementName;
603
+ const isSvgElement = (elementName) => "svg" === elementName || isForeignObjectElement(elementName);
604
+ const isMathElement = (elementName) => "math" === elementName;
605
+ const vnode_isDefaultNamespace = (vnode) => !(vnode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK);
606
+ const vnode_getElementNamespaceFlags = (element) => {
607
+ switch (fastNamespaceURI(element)) {
608
+ case SVG_NS:
609
+ return VNodeFlags.NS_svg;
610
+ case MATH_NS:
611
+ return VNodeFlags.NS_math;
612
+ default:
613
+ return VNodeFlags.NS_html;
614
+ }
615
+ };
616
+ function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
617
+ const { elementNamespace, elementNamespaceFlag } = getNewElementNamespaceData(domParentVNode, newChild);
618
+ let domChildren = [];
619
+ if (elementNamespace === HTML_NS) {
620
+ domChildren = vnode_getDOMChildNodes(journal, newChild);
621
+ } else {
622
+ const children = vnode_getDOMChildNodes(journal, newChild, true);
623
+ for (let i = 0; i < children.length; i++) {
624
+ const childVNode = children[i];
625
+ if (vnode_isTextVNode(childVNode)) {
626
+ domChildren.push(childVNode[TextVNodeProps.node]);
627
+ continue;
628
+ }
629
+ if ((childVNode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK) == (domParentVNode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK)) {
630
+ domChildren.push(childVNode[ElementVNodeProps.element]);
631
+ continue;
632
+ }
633
+ const newChildElement = vnode_cloneElementWithNamespace(childVNode, domParentVNode, elementNamespace, elementNamespaceFlag);
634
+ newChildElement && domChildren.push(newChildElement);
635
+ }
636
+ }
637
+ return domChildren;
638
+ }
639
+ function cloneElementWithNamespace(element, elementName, namespace) {
640
+ const newElement = element.ownerDocument.createElementNS(namespace, elementName);
641
+ const attributes = element.attributes;
642
+ for (const attribute of attributes) {
643
+ const name = attribute.name;
644
+ name && ":" !== name && newElement.setAttribute(name, attribute.value);
645
+ }
646
+ return newElement;
647
+ }
648
+ function vnode_cloneElementWithNamespace(elementVNode, parentVNode, namespace, namespaceFlag) {
649
+ ensureElementVNode(elementVNode);
650
+ let vCursor = elementVNode;
651
+ let vParent = null;
652
+ let rootElement = null;
653
+ let parentElement = null;
654
+ for (; vCursor; ) {
655
+ let childElement = null;
656
+ let newChildElement = null;
657
+ if (vnode_isElementVNode(vCursor)) {
658
+ childElement = vCursor[ElementVNodeProps.element];
659
+ const childElementTag = vnode_getElementName(vCursor);
660
+ const vCursorParent = vnode_getParent(vCursor);
661
+ const vCursorDomParent = null == rootElement ? parentVNode : vCursorParent && vnode_getDomParentVNode(vCursorParent);
662
+ if (vCursorDomParent) {
663
+ const namespaceData = getNewElementNamespaceData(vCursorDomParent, vnode_getElementName(vCursor));
664
+ namespace = namespaceData.elementNamespace, namespaceFlag = namespaceData.elementNamespaceFlag;
665
+ }
666
+ newChildElement = cloneElementWithNamespace(childElement, childElementTag, namespace), childElement.remove(), null == rootElement && (rootElement = newChildElement), parentElement && parentElement.appendChild(newChildElement);
667
+ const vFirstChild = vnode_getFirstChild(vCursor);
668
+ if (vCursor[ElementVNodeProps.element] = newChildElement, vCursor[VNodeProps.flags] &= VNodeFlags.NEGATED_NAMESPACE_MASK, vCursor[VNodeProps.flags] |= namespaceFlag, vFirstChild) {
669
+ vCursor = vFirstChild, parentElement = newChildElement;
670
+ continue;
671
+ }
672
+ if (shouldIgnoreChildren(childElement)) {
673
+ const container = getDomContainerFromQContainerElement(childElement);
674
+ if (container) {
675
+ const innerContainerFirstVNode = vnode_getFirstChild(container.rootVNode);
676
+ if (innerContainerFirstVNode) {
677
+ vCursor = innerContainerFirstVNode, parentElement = newChildElement;
678
+ continue;
679
+ }
680
+ }
681
+ }
682
+ }
683
+ if (vCursor === elementVNode) {
684
+ return rootElement;
685
+ }
686
+ const vNextSibling = vnode_getNextSibling(vCursor);
687
+ if (vNextSibling) {
688
+ vCursor = vNextSibling;
689
+ } else {
690
+ for (vParent = vnode_getParent(vCursor); vParent; ) {
691
+ if (vParent === elementVNode) {
692
+ return rootElement;
693
+ }
694
+ const vNextParentSibling = vnode_getNextSibling(vParent);
695
+ if (vNextParentSibling) {
696
+ return vCursor = vNextParentSibling, rootElement;
697
+ }
698
+ vParent = vnode_getParent(vParent);
699
+ }
700
+ if (null == vParent) {
701
+ return rootElement;
702
+ }
703
+ }
704
+ }
705
+ return rootElement;
706
+ }
707
+ function isSvg(tagOrVNode) {
708
+ return "string" == typeof tagOrVNode ? isSvgElement(tagOrVNode) : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_svg);
709
+ }
710
+ function isMath(tagOrVNode) {
711
+ return "string" == typeof tagOrVNode ? isMathElement(tagOrVNode) : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_math);
712
+ }
713
+ function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
714
+ const parentIsDefaultNamespace = !domParentVNode || !!vnode_getElementName(domParentVNode) && vnode_isDefaultNamespace(domParentVNode);
715
+ const parentIsForeignObject = !parentIsDefaultNamespace && isForeignObjectElement(vnode_getElementName(domParentVNode));
716
+ let elementNamespace = HTML_NS;
717
+ let elementNamespaceFlag = VNodeFlags.NS_html;
718
+ const isElementVNodeOrString = "string" == typeof tagOrVNode || vnode_isElementVNode(tagOrVNode);
719
+ if (isElementVNodeOrString && isSvg(tagOrVNode)) {
720
+ elementNamespace = SVG_NS, elementNamespaceFlag = VNodeFlags.NS_svg;
721
+ } else if (isElementVNodeOrString && isMath(tagOrVNode)) {
722
+ elementNamespace = MATH_NS, elementNamespaceFlag = VNodeFlags.NS_math;
723
+ } else if (domParentVNode && !parentIsForeignObject && !parentIsDefaultNamespace) {
724
+ elementNamespace = !!(domParentVNode[VNodeProps.flags] & VNodeFlags.NS_svg) ? SVG_NS : !!(domParentVNode[VNodeProps.flags] & VNodeFlags.NS_math) ? MATH_NS : HTML_NS, elementNamespaceFlag = domParentVNode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK;
725
+ }
726
+ return {
727
+ elementNamespace,
728
+ elementNamespaceFlag
729
+ };
730
+ }
731
+ const executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
732
+ const iCtx = newInvokeContext(container.$locale$, subscriptionHost || void 0, void 0, "qRender");
733
+ let componentFn;
734
+ subscriptionHost && (iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, EffectProperty.COMPONENT), iCtx.$container$ = container), container.ensureProjectionResolved(renderHost);
735
+ let isInlineComponent = false;
736
+ if (null === componentQRL && assertDefined(componentQRL = container.getHostProp(renderHost, "q:renderFn")), isQrl$1(componentQRL)) {
737
+ (props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ).children && delete props.children, componentFn = componentQRL.getFn(iCtx);
738
+ } else if (isQwikComponent(componentQRL)) {
739
+ const qComponentFn = componentQRL;
740
+ componentFn = () => invokeApply(iCtx, qComponentFn, [props || EMPTY_OBJ, null, 0]);
741
+ } else {
742
+ isInlineComponent = true;
743
+ const inlineComponent = componentQRL;
744
+ componentFn = () => invokeApply(iCtx, inlineComponent, [props || EMPTY_OBJ]);
745
+ }
746
+ const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall(() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null), container.setHostProp(renderHost, ":onIdx", null), container.setHostProp(renderHost, "q:props", props)), vnode_isVNode(renderHost) && clearAllEffects(container, renderHost), componentFn(props)), (jsx2) => {
747
+ const useOnEvents = container.getHostProp(renderHost, ":on");
748
+ return useOnEvents ? addUseOnEvents(jsx2, useOnEvents) : jsx2;
749
+ }, (err) => {
750
+ if (isPromise(err) && retryCount < 100) {
751
+ return err.then(() => executeComponentWithPromiseExceptionRetry(retryCount++));
752
+ }
753
+ throw err;
754
+ });
755
+ return executeComponentWithPromiseExceptionRetry();
756
+ };
757
+ function addUseOnEvents(jsx2, useOnEvents) {
758
+ const jsxElement = findFirstStringJSX(jsx2);
759
+ let jsxResult = jsx2;
760
+ return maybeThen(jsxElement, (jsxElement2) => {
761
+ let isInvisibleComponent = false;
762
+ jsxElement2 || (isInvisibleComponent = true);
763
+ for (const key in useOnEvents) {
764
+ if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
765
+ if (isInvisibleComponent) {
766
+ if ("onQvisible$" === key) {
767
+ const [jsxElement3, jsx3] = addScriptNodeForInvisibleComponents(jsxResult);
768
+ jsxResult = jsx3, jsxElement3 && addUseOnEvent(jsxElement3, "document:onQinit$", useOnEvents[key]);
769
+ } else if (key.startsWith("document:") || key.startsWith("window:")) {
770
+ const [jsxElement3, jsx3] = addScriptNodeForInvisibleComponents(jsxResult);
771
+ jsxResult = jsx3, jsxElement3 && addUseOnEvent(jsxElement3, key, useOnEvents[key]);
772
+ } else ;
773
+ } else {
774
+ jsxElement2 && addUseOnEvent(jsxElement2, key, useOnEvents[key]);
775
+ }
776
+ }
777
+ }
778
+ return jsxResult;
779
+ });
780
+ }
781
+ function addUseOnEvent(jsxElement, key, value) {
782
+ let props = jsxElement.props;
783
+ props === EMPTY_OBJ && (props = jsxElement.props = {});
784
+ let propValue = props[key];
785
+ void 0 === propValue ? propValue = [] : Array.isArray(propValue) || (propValue = [propValue]), propValue.push(...value), props[key] = propValue;
786
+ }
787
+ function findFirstStringJSX(jsx2) {
788
+ const queue = [jsx2];
789
+ for (; queue.length; ) {
790
+ const jsx3 = queue.shift();
791
+ if (isJSXNode(jsx3)) {
792
+ if ("string" == typeof jsx3.type) {
793
+ return jsx3;
794
+ }
795
+ queue.push(jsx3.children);
796
+ } else if (Array.isArray(jsx3)) {
797
+ queue.push(...jsx3);
798
+ } else {
799
+ if (isPromise(jsx3)) {
800
+ return maybeThen(jsx3, (jsx4) => findFirstStringJSX(jsx4));
801
+ }
802
+ if (isSignal(jsx3)) {
803
+ return findFirstStringJSX(untrack(() => jsx3.value));
804
+ }
805
+ }
806
+ }
807
+ return null;
808
+ }
809
+ function addScriptNodeForInvisibleComponents(jsx2) {
810
+ if (isJSXNode(jsx2)) {
811
+ const jsxElement = new JSXNodeImpl("script", {}, {
812
+ type: "placeholder",
813
+ hidden: ""
814
+ }, null, 3);
815
+ return jsx2.type === Slot ? [jsxElement, _jsxSorted(Fragment, null, null, [jsx2, jsxElement], 0, null)] : (null == jsx2.children ? jsx2.children = jsxElement : Array.isArray(jsx2.children) ? jsx2.children.push(jsxElement) : jsx2.children = [jsx2.children, jsxElement], [jsxElement, jsx2]);
816
+ }
817
+ if (Array.isArray(jsx2) && jsx2.length) {
818
+ const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx2[0]);
819
+ return [jsxElement, jsx2];
820
+ }
821
+ return [null, null];
822
+ }
823
+ const _CONST_PROPS = Symbol("CONST");
824
+ const _VAR_PROPS = Symbol("VAR");
825
+ function isSlotProp(prop) {
826
+ return !prop.startsWith("q:") && !prop.startsWith(":");
827
+ }
828
+ function isParentSlotProp(prop) {
829
+ return prop.startsWith(":");
830
+ }
831
+ function escapeHTML(html) {
832
+ let escapedHTML = "";
833
+ const length = html.length;
834
+ let idx = 0;
835
+ let lastIdx = idx;
836
+ for (; idx < length; idx++) {
837
+ const ch = html.charCodeAt(idx);
838
+ if (60 === ch) {
839
+ escapedHTML += html.substring(lastIdx, idx) + "&lt;";
840
+ } else if (62 === ch) {
841
+ escapedHTML += html.substring(lastIdx, idx) + "&gt;";
842
+ } else if (38 === ch) {
843
+ escapedHTML += html.substring(lastIdx, idx) + "&amp;";
844
+ } else if (34 === ch) {
845
+ escapedHTML += html.substring(lastIdx, idx) + "&quot;";
846
+ } else {
847
+ if (39 !== ch) {
848
+ continue;
849
+ }
850
+ escapedHTML += html.substring(lastIdx, idx) + "&#39;";
851
+ }
852
+ lastIdx = idx + 1;
853
+ }
854
+ return 0 === lastIdx ? html : escapedHTML + html.substring(lastIdx);
855
+ }
856
+ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
857
+ let journal = container.$journal$;
858
+ const stack2 = [];
859
+ const asyncQueue = [];
860
+ let vParent = null;
861
+ let vCurrent = null;
862
+ let vNewNode = null;
863
+ let vSiblings = null;
864
+ let vSiblingsIdx = -1;
865
+ let jsxChildren = null;
866
+ let jsxValue = null;
867
+ let jsxIdx = 0;
868
+ let jsxCount = 0;
869
+ let shouldAdvance = true;
870
+ return diff(jsxNode, vStartNode), function drainAsyncQueue() {
871
+ for (; asyncQueue.length; ) {
872
+ const jsxNode2 = asyncQueue.shift();
873
+ const vHostNode = asyncQueue.shift();
874
+ if (isPromise(jsxNode2)) {
875
+ return jsxNode2.then((jsxNode3) => (diff(jsxNode3, vHostNode), drainAsyncQueue()));
876
+ }
877
+ diff(jsxNode2, vHostNode);
878
+ }
879
+ }();
880
+ function diff(jsxNode2, vStartNode2) {
881
+ for (vParent = vStartNode2, vNewNode = null, vCurrent = vnode_getFirstChild(vStartNode2), stackPush(jsxNode2, true); stack2.length; ) {
882
+ for (; jsxIdx < jsxCount; ) {
883
+ if ("string" == typeof jsxValue) {
884
+ expectText(jsxValue);
885
+ } else if ("number" == typeof jsxValue) {
886
+ expectText(String(jsxValue));
887
+ } else if (jsxValue && "object" == typeof jsxValue) {
888
+ if (Array.isArray(jsxValue)) {
889
+ descend(jsxValue, false);
890
+ } else if (isSignal(jsxValue)) {
891
+ vCurrent && clearAllEffects(container, vCurrent), expectVirtual(VirtualType.WrappedSignal, null), descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, EffectProperty.VNODE, container), true);
892
+ } else if (isPromise(jsxValue)) {
893
+ expectVirtual(VirtualType.Awaited, null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
894
+ } else if (isJSXNode(jsxValue)) {
895
+ const type = jsxValue.type;
896
+ "string" == typeof type ? (expectNoMoreTextNodes(), expectElement(jsxValue, type), descend(jsxValue.children, true)) : "function" == typeof type && (type === Fragment ? (expectNoMoreTextNodes(), expectVirtual(VirtualType.Fragment, jsxValue.key), descend(jsxValue.children, true)) : type === Slot ? (expectNoMoreTextNodes(), expectSlot() || descend(jsxValue.children, true)) : type === Projection ? (expectProjection(), descend(jsxValue.children, true)) : type === SSRComment || type === SSRRaw ? expectNoMore() : (expectNoMoreTextNodes(), expectComponent(type)));
897
+ }
898
+ } else {
899
+ jsxValue === SkipRender ? journal = [] : expectText("");
900
+ }
901
+ advance();
902
+ }
903
+ expectNoMore(), ascend();
904
+ }
905
+ }
906
+ function advance() {
907
+ if (shouldAdvance) {
908
+ if (jsxIdx++, jsxIdx < jsxCount) {
909
+ jsxValue = jsxChildren[jsxIdx];
910
+ } else if (false === stack2[stack2.length - 1]) {
911
+ return ascend();
912
+ }
913
+ null !== vNewNode ? vNewNode = null : advanceToNextSibling();
914
+ } else {
915
+ shouldAdvance = true;
916
+ }
917
+ }
918
+ function peekNextSibling() {
919
+ if (null !== vSiblings) {
920
+ const idx = vSiblingsIdx + SiblingsArray.NextVNode;
921
+ return idx < vSiblings.length ? vSiblings[idx] : null;
922
+ }
923
+ return vCurrent ? vnode_getNextSibling(vCurrent) : null;
924
+ }
925
+ function advanceToNextSibling() {
926
+ vCurrent = peekNextSibling(), null !== vSiblings && (vSiblingsIdx += SiblingsArray.Size);
927
+ }
928
+ function descend(children, descendVNode) {
929
+ null != children ? (stackPush(children, descendVNode), descendVNode && (vSiblings = null, vSiblingsIdx = -1, vParent = vNewNode || vCurrent, vCurrent = vnode_getFirstChild(vParent), vNewNode = null), shouldAdvance = false) : function() {
930
+ const vFirstChild = vCurrent && vnode_getFirstChild(vCurrent);
931
+ if (null !== vFirstChild) {
932
+ let vChild = vFirstChild;
933
+ for (; vChild; ) {
934
+ cleanup(container, vChild), vChild = vnode_getNextSibling(vChild);
935
+ }
936
+ vnode_truncate(journal, vCurrent, vFirstChild);
937
+ }
938
+ }();
939
+ }
940
+ function ascend() {
941
+ stack2.pop() && (vSiblingsIdx = stack2.pop(), vSiblings = stack2.pop(), vNewNode = stack2.pop(), vCurrent = stack2.pop(), vParent = stack2.pop()), jsxValue = stack2.pop(), jsxCount = stack2.pop(), jsxIdx = stack2.pop(), jsxChildren = stack2.pop(), advance();
942
+ }
943
+ function stackPush(children, descendVNode) {
944
+ stack2.push(jsxChildren, jsxIdx, jsxCount, jsxValue), descendVNode && stack2.push(vParent, vCurrent, vNewNode, vSiblings, vSiblingsIdx), stack2.push(descendVNode), Array.isArray(children) ? (jsxIdx = 0, jsxCount = children.length, jsxChildren = children, jsxValue = jsxCount > 0 ? children[0] : null) : void 0 === children ? (jsxIdx = 0, jsxValue = null, jsxChildren = null, jsxCount = 0) : (jsxIdx = 0, jsxValue = children, jsxChildren = null, jsxCount = 1);
945
+ }
946
+ function getInsertBefore() {
947
+ if (vNewNode) {
948
+ return vCurrent;
949
+ }
950
+ if (null !== vSiblings) {
951
+ const nextIdx = vSiblingsIdx + SiblingsArray.NextVNode;
952
+ return nextIdx < vSiblings.length ? vSiblings[nextIdx] : null;
953
+ }
954
+ return peekNextSibling();
955
+ }
956
+ function expectProjection() {
957
+ const slotName = jsxValue.key;
958
+ vCurrent = vnode_getProp(vParent, slotName, (id) => vnode_locate(container.rootVNode, id)), null == vCurrent && (vNewNode = vnode_newVirtual(), vnode_setProp(vNewNode, QSlot, slotName), vnode_setProp(vNewNode, ":", vParent), vnode_setProp(vParent, slotName, vNewNode));
959
+ }
960
+ function expectSlot() {
961
+ const vHost = vnode_getProjectionParentComponent(vParent, container.rootVNode);
962
+ const slotNameKey = function(vHost2) {
963
+ const jsxNode2 = jsxValue;
964
+ const constProps = jsxNode2.constProps;
965
+ if (constProps && "object" == typeof constProps && "name" in constProps) {
966
+ const constValue = constProps.name;
967
+ if (vHost2 && constValue instanceof WrappedSignal) {
968
+ return trackSignalAndAssignHost(constValue, vHost2, EffectProperty.COMPONENT, container);
969
+ }
970
+ }
971
+ return directGetPropsProxyProp(jsxNode2, "name") || "";
972
+ }(vHost);
973
+ const vProjectedNode = vHost ? vnode_getProp(vHost, slotNameKey, null) : null;
974
+ return null == vProjectedNode ? (vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()), vnode_setProp(vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, vNewNode), false) : (vProjectedNode === vCurrent || (vnode_insertBefore(journal, vParent, vNewNode = vProjectedNode, vCurrent && getInsertBefore()), vnode_setProp(vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, vNewNode), isDev), true);
975
+ }
976
+ function expectNoMore() {
977
+ if (null !== vCurrent) {
978
+ for (; vCurrent; ) {
979
+ const toRemove = vCurrent;
980
+ advanceToNextSibling(), cleanup(container, toRemove), vParent === vnode_getParent(toRemove) && vnode_remove(journal, vParent, toRemove, true);
981
+ }
982
+ }
983
+ }
984
+ function expectNoMoreTextNodes() {
985
+ for (; null !== vCurrent && vnode_isTextVNode(vCurrent); ) {
986
+ cleanup(container, vCurrent);
987
+ const toRemove = vCurrent;
988
+ advanceToNextSibling(), vnode_remove(journal, vParent, toRemove, true);
989
+ }
990
+ }
991
+ function createNewElement(jsx2, elementName, currentFile) {
992
+ const element = function(elementName2) {
993
+ const domParentVNode = vnode_getDomParentVNode(vParent);
994
+ const { elementNamespace, elementNamespaceFlag } = getNewElementNamespaceData(domParentVNode, elementName2);
995
+ const element2 = container.document.createElementNS(elementNamespace, elementName2);
996
+ return vNewNode = vnode_newElement(element2, elementName2), vNewNode[VNodeProps.flags] |= elementNamespaceFlag, element2;
997
+ }(elementName);
998
+ const { constProps } = jsx2;
999
+ let needsQDispatchEventPatch = false;
1000
+ if (constProps) {
1001
+ for (const key2 in constProps) {
1002
+ let value = constProps[key2];
1003
+ if (isJsxPropertyAnEventName(key2)) {
1004
+ const eventName = getEventNameFromJsxProp(key2);
1005
+ const scope = getEventNameScopeFromJsxProp(key2);
1006
+ if (eventName && (vnode_setProp(vNewNode, HANDLER_PREFIX + ":" + scope + ":" + eventName, value), registerQwikLoaderEvent(eventName)), scope) {
1007
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key2);
1008
+ htmlEvent && vnode_setAttr(journal, vNewNode, htmlEvent, "");
1009
+ }
1010
+ needsQDispatchEventPatch = true;
1011
+ } else {
1012
+ if ("ref" === key2) {
1013
+ if (isSignal(value)) {
1014
+ value.value = element;
1015
+ continue;
1016
+ }
1017
+ if ("function" == typeof value) {
1018
+ value(element);
1019
+ continue;
1020
+ }
1021
+ if (null == value) {
1022
+ continue;
1023
+ }
1024
+ throw qError(QError.invalidRefValue, [currentFile]);
1025
+ }
1026
+ if (isSignal(value)) {
1027
+ const signalData = new SubscriptionData({
1028
+ $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1029
+ $isConst$: true
1030
+ });
1031
+ value = trackSignalAndAssignHost(value, vNewNode, key2, container, signalData);
1032
+ }
1033
+ if (key2 !== dangerouslySetInnerHTML) {
1034
+ if ("textarea" !== elementName || "value" !== key2) {
1035
+ value = serializeAttribute(key2, value, scopedStyleIdPrefix), null != value && element.setAttribute(key2, String(value));
1036
+ } else {
1037
+ if (value && "string" != typeof value) {
1038
+ continue;
1039
+ }
1040
+ element.value = escapeHTML(value || "");
1041
+ }
1042
+ } else {
1043
+ element.innerHTML = value, element.setAttribute("q:container", QContainerValue.HTML);
1044
+ }
1045
+ }
1046
+ }
1047
+ }
1048
+ const key = jsx2.key;
1049
+ key && (element.setAttribute("q:key", key), vnode_setProp(vNewNode, "q:key", key));
1050
+ return !(hasClassAttr(jsx2.varProps) || jsx2.constProps && hasClassAttr(jsx2.constProps)) && scopedStyleIdPrefix && element.setAttribute("class", scopedStyleIdPrefix), vnode_insertBefore(journal, vParent, vNewNode, vCurrent), needsQDispatchEventPatch;
1051
+ }
1052
+ function expectElement(jsx2, elementName) {
1053
+ const isSameElementName = vCurrent && vnode_isElementVNode(vCurrent) && elementName === vnode_getElementName(vCurrent);
1054
+ const jsxKey = jsx2.key;
1055
+ let needsQDispatchEventPatch = false;
1056
+ const currentFile = getFileLocationFromJsx(jsx2.dev);
1057
+ isSameElementName && jsxKey === getKey(vCurrent) || (vNewNode = retrieveChildWithKey(elementName, jsxKey), null === vNewNode ? needsQDispatchEventPatch = createNewElement(jsx2, elementName) : (vnode_insertBefore(journal, vParent, vNewNode, vCurrent), vCurrent = vNewNode, vNewNode = null, null !== vSiblings && (vSiblingsIdx -= SiblingsArray.Size)));
1058
+ const jsxAttrs = [];
1059
+ const props = jsx2.varProps;
1060
+ for (const key in props) {
1061
+ const value = props[key];
1062
+ null != value && mapArray_set(jsxAttrs, key, value, 0);
1063
+ }
1064
+ null !== jsxKey && mapArray_set(jsxAttrs, "q:key", jsxKey, 0);
1065
+ const vNode = vNewNode || vCurrent;
1066
+ if (needsQDispatchEventPatch = function(vnode, srcAttrs, currentFile2) {
1067
+ vnode_ensureElementInflated(vnode);
1068
+ const dstAttrs = vnode_getProps(vnode);
1069
+ let srcIdx = 0;
1070
+ const srcLength = srcAttrs.length;
1071
+ let dstIdx = 0;
1072
+ let dstLength = dstAttrs.length;
1073
+ let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
1074
+ let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
1075
+ let patchEventDispatch = false;
1076
+ const record = (key, value) => {
1077
+ if (key.startsWith(":")) {
1078
+ vnode_setProp(vnode, key, value);
1079
+ } else {
1080
+ if ("ref" === key) {
1081
+ const element = vnode_getNode(vnode);
1082
+ if (isSignal(value)) {
1083
+ return void (value.value = element);
1084
+ }
1085
+ if ("function" == typeof value) {
1086
+ return void value(element);
1087
+ }
1088
+ if (null == value) {
1089
+ return;
1090
+ }
1091
+ throw qError(QError.invalidRefValue, [currentFile2]);
1092
+ }
1093
+ if (isSignal(value)) {
1094
+ const signalData = new SubscriptionData({
1095
+ $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1096
+ $isConst$: false
1097
+ });
1098
+ value = trackSignalAndAssignHost(value, vnode, key, container, signalData);
1099
+ }
1100
+ vnode_setAttr(journal, vnode, key, serializeAttribute(key, value, scopedStyleIdPrefix)), null === value && (dstLength = dstAttrs.length);
1101
+ }
1102
+ };
1103
+ const recordJsxEvent = (key, value) => {
1104
+ const eventName = getEventNameFromJsxProp(key);
1105
+ const scope = getEventNameScopeFromJsxProp(key);
1106
+ if (eventName && (record(":" + scope + ":" + eventName, value), registerQwikLoaderEvent(eventName)), scope) {
1107
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
1108
+ htmlEvent && record(htmlEvent, "");
1109
+ }
1110
+ };
1111
+ for (; null !== srcKey || null !== dstKey; ) {
1112
+ if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith("q:")) {
1113
+ dstIdx++, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
1114
+ } else if (null == srcKey) {
1115
+ dstKey && isHtmlAttributeAnEventName(dstKey) ? (patchEventDispatch = true, dstIdx++) : (record(dstKey, null), dstIdx--), dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
1116
+ } else if (null == dstKey) {
1117
+ isJsxPropertyAnEventName(srcKey) ? (patchEventDispatch = true, recordJsxEvent(srcKey, srcAttrs[srcIdx])) : record(srcKey, srcAttrs[srcIdx]), srcIdx++, srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null, dstIdx++, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
1118
+ } else if (srcKey == dstKey) {
1119
+ const srcValue = srcAttrs[srcIdx++];
1120
+ srcValue !== dstAttrs[dstIdx++] && record(dstKey, srcValue), srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
1121
+ } else {
1122
+ srcKey < dstKey ? (isJsxPropertyAnEventName(srcKey) ? (patchEventDispatch = true, recordJsxEvent(srcKey, srcAttrs[srcIdx])) : record(srcKey, srcAttrs[srcIdx]), srcIdx++, srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null, dstIdx++, dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null) : (isHtmlAttributeAnEventName(dstKey) ? (patchEventDispatch = true, dstIdx++) : (record(dstKey, null), dstIdx--), dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null);
1123
+ }
1124
+ }
1125
+ return patchEventDispatch;
1126
+ }(vNode, jsxAttrs, currentFile) || needsQDispatchEventPatch, needsQDispatchEventPatch) {
1127
+ const element = vnode_getNode(vNode);
1128
+ element.qDispatchEvent || (element.qDispatchEvent = (event, scope) => {
1129
+ const eventName = event.type;
1130
+ const eventProp = ":" + scope.substring(1) + ":" + eventName;
1131
+ const qrls = [vnode_getProp(vNode, eventProp, null), vnode_getProp(vNode, HANDLER_PREFIX + eventProp, null)];
1132
+ let returnValue = false;
1133
+ return qrls.flat(2).forEach((qrl2) => {
1134
+ if (qrl2) {
1135
+ const value = container.$scheduler$(ChoreType.RUN_QRL, vNode, qrl2, [event, element]);
1136
+ returnValue = returnValue || true === value;
1137
+ }
1138
+ }), returnValue;
1139
+ });
1140
+ }
1141
+ }
1142
+ function registerQwikLoaderEvent(eventName) {
1143
+ const window2 = container.document.defaultView;
1144
+ window2 && (window2.qwikevents || (window2.qwikevents = [])).push(eventName);
1145
+ }
1146
+ function retrieveChildWithKey(nodeName, key) {
1147
+ let vNodeWithKey = null;
1148
+ if (-1 === vSiblingsIdx) {
1149
+ vSiblings = [], vSiblingsIdx = 0;
1150
+ let vNode = vCurrent;
1151
+ for (; vNode; ) {
1152
+ const name = vnode_isElementVNode(vNode) ? vnode_getElementName(vNode) : null;
1153
+ const vKey = getKey(vNode) || getComponentHash(vNode, container.$getObjectById$);
1154
+ null === vNodeWithKey && vKey == key && name == nodeName ? vNodeWithKey = vNode : vSiblings.push(name, vKey, vNode), vNode = vnode_getNextSibling(vNode);
1155
+ }
1156
+ } else {
1157
+ for (let idx = vSiblingsIdx; idx < vSiblings.length; idx += SiblingsArray.Size) {
1158
+ if (vSiblings[idx + SiblingsArray.Key] === key && vSiblings[idx + SiblingsArray.Name] === nodeName) {
1159
+ vNodeWithKey = vSiblings[idx + SiblingsArray.VNode], vSiblings?.splice(idx, SiblingsArray.Size);
1160
+ break;
1161
+ }
1162
+ }
1163
+ }
1164
+ return vNodeWithKey;
1165
+ }
1166
+ function expectVirtual(type, jsxKey) {
1167
+ vCurrent && vnode_isVirtualVNode(vCurrent) && getKey(vCurrent) === jsxKey || (null === jsxKey || (vNewNode = retrieveChildWithKey(null, jsxKey), null == vNewNode) ? (vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()), vnode_setProp(vNewNode, "q:key", jsxKey), isDev) : vnode_insertBefore(journal, vParent, vNewNode, vCurrent && getInsertBefore()));
1168
+ }
1169
+ function expectComponent(component) {
1170
+ const componentMeta = component[SERIALIZABLE_STATE];
1171
+ let host = vNewNode || vCurrent;
1172
+ const jsxNode2 = jsxValue;
1173
+ if (componentMeta) {
1174
+ const jsxProps = jsxNode2.props;
1175
+ let shouldRender = false;
1176
+ const [componentQRL] = componentMeta;
1177
+ const componentHash = componentQRL.$hash$;
1178
+ const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
1179
+ const lookupKey = jsxNode2.key || componentHash;
1180
+ if (lookupKey === (getKey(host) || vNodeComponentHash) ? componentHash === vNodeComponentHash || (insertNewComponent(host, componentQRL, jsxProps), vNewNode && (host = vNewNode, shouldRender = true)) : (vNewNode = retrieveChildWithKey(null, lookupKey), vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewComponent(host, componentQRL, jsxProps), host = vNewNode, shouldRender = true), host) {
1181
+ const vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
1182
+ shouldRender = shouldRender || propsDiffer(jsxProps, vNodeProps), shouldRender && (host[VNodeProps.flags] &= ~VNodeFlags.Deleted, container.$scheduler$(ChoreType.COMPONENT, host, componentQRL, jsxProps));
1183
+ }
1184
+ !function(children, host2) {
1185
+ const projectionChildren = Array.isArray(children) ? children : [children];
1186
+ const createProjectionJSXNode = (slotName) => new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
1187
+ const projections = [];
1188
+ if (host2) {
1189
+ const props = vnode_getProps(host2);
1190
+ for (let i = 0; i < props.length; i += 2) {
1191
+ const prop = props[i];
1192
+ if (isSlotProp(prop)) {
1193
+ const slotName = prop;
1194
+ projections.push(slotName), projections.push(createProjectionJSXNode(slotName));
1195
+ }
1196
+ }
1197
+ }
1198
+ if (0 !== projections.length || null != children) {
1199
+ for (let i = 0; i < projectionChildren.length; i++) {
1200
+ const child = projectionChildren[i];
1201
+ const slotName = String(isJSXNode(child) && directGetPropsProxyProp(child, QSlot) || "");
1202
+ const idx = mapApp_findIndx(projections, slotName, 0);
1203
+ let jsxBucket;
1204
+ idx >= 0 ? jsxBucket = projections[idx + 1] : projections.splice(~idx, 0, slotName, jsxBucket = createProjectionJSXNode(slotName)), false === child || jsxBucket.children.push(child);
1205
+ }
1206
+ for (let i = projections.length - 2; i >= 0; i -= 2) {
1207
+ projections.splice(i, 1);
1208
+ }
1209
+ descend(projections, true);
1210
+ }
1211
+ }(jsxNode2.children, host);
1212
+ } else {
1213
+ const lookupKey = jsxNode2.key;
1214
+ if (lookupKey === getKey(host) || (vNewNode = retrieveChildWithKey(null, lookupKey), vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : function() {
1215
+ vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
1216
+ const jsxNode3 = jsxValue;
1217
+ vnode_setProp(vNewNode, "q:props", jsxNode3.props), jsxNode3.key && vnode_setProp(vNewNode, "q:key", jsxNode3.key);
1218
+ }(), host = vNewNode), host) {
1219
+ let componentHost = host;
1220
+ for (; componentHost && (!vnode_isVirtualVNode(componentHost) || null === vnode_getProp(componentHost, "q:renderFn", null)); ) {
1221
+ componentHost = vnode_getParent(componentHost);
1222
+ }
1223
+ const jsxOutput = executeComponent(container, host, componentHost || container.rootVNode, component, jsxNode2.props);
1224
+ asyncQueue.push(jsxOutput, host);
1225
+ }
1226
+ }
1227
+ }
1228
+ function insertNewComponent(host, componentQRL, jsxProps) {
1229
+ host && clearAllEffects(container, host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
1230
+ const jsxNode2 = jsxValue;
1231
+ container.setHostProp(vNewNode, "q:renderFn", componentQRL), container.setHostProp(vNewNode, "q:props", jsxProps), container.setHostProp(vNewNode, "q:key", jsxNode2.key);
1232
+ }
1233
+ function expectText(text) {
1234
+ if (null !== vCurrent) {
1235
+ if (3 === vnode_getType(vCurrent)) {
1236
+ return text !== vnode_getText(vCurrent) ? void vnode_setText(journal, vCurrent, text) : void 0;
1237
+ }
1238
+ }
1239
+ vnode_insertBefore(journal, vParent, vNewNode = vnode_newText(container.document.createTextNode(text), text), vCurrent);
1240
+ }
1241
+ };
1242
+ function getKey(vNode) {
1243
+ return null == vNode ? null : vnode_getProp(vNode, "q:key", null);
1244
+ }
1245
+ function getComponentHash(vNode, getObject) {
1246
+ if (null == vNode) {
1247
+ return null;
1248
+ }
1249
+ const qrl2 = vnode_getProp(vNode, "q:renderFn", getObject);
1250
+ return qrl2 ? qrl2.$hash$ : null;
1251
+ }
1252
+ function Projection() {
1253
+ }
1254
+ function propsDiffer(src, dst) {
1255
+ if (!src || !dst) {
1256
+ return true;
1257
+ }
1258
+ let srcKeys = removePropsKeys(Object.keys(src), ["children", "q:brefs"]);
1259
+ let dstKeys = removePropsKeys(Object.keys(dst), ["children", "q:brefs"]);
1260
+ if (srcKeys.length !== dstKeys.length) {
1261
+ return true;
1262
+ }
1263
+ srcKeys = srcKeys.sort(), dstKeys = dstKeys.sort();
1264
+ for (let idx = 0; idx < srcKeys.length; idx++) {
1265
+ const srcKey = srcKeys[idx];
1266
+ const dstKey = dstKeys[idx];
1267
+ if (srcKey !== dstKey || src[srcKey] !== dst[dstKey]) {
1268
+ return true;
1269
+ }
1270
+ }
1271
+ return false;
1272
+ }
1273
+ function removePropsKeys(keys, propKeys) {
1274
+ for (let i = propKeys.length - 1; i >= 0; i--) {
1275
+ const propIdx = keys.indexOf(propKeys[i]);
1276
+ -1 !== propIdx && keys.splice(propIdx, 1);
1277
+ }
1278
+ return keys;
1279
+ }
1280
+ function cleanup(container, vNode) {
1281
+ let vCursor = vNode;
1282
+ if (vnode_isTextVNode(vNode)) {
1283
+ return;
1284
+ }
1285
+ let vParent = null;
1286
+ for (; ; ) {
1287
+ const type = vCursor[VNodeProps.flags];
1288
+ if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
1289
+ if (clearAllEffects(container, vCursor), markVNodeAsDeleted(vCursor), type & VNodeFlags.Virtual) {
1290
+ const seq = container.getHostProp(vCursor, "q:seq");
1291
+ if (seq) {
1292
+ for (let i = 0; i < seq.length; i++) {
1293
+ const obj = seq[i];
1294
+ if (isTask(obj)) {
1295
+ const task = obj;
1296
+ clearAllEffects(container, task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
1297
+ }
1298
+ }
1299
+ }
1300
+ }
1301
+ if (type & VNodeFlags.Virtual && null !== vnode_getProp(vCursor, "q:renderFn", null)) {
1302
+ const attrs = vnode_getProps(vCursor);
1303
+ for (let i = 0; i < attrs.length; i += 2) {
1304
+ const key = attrs[i];
1305
+ if (!isParentSlotProp(key) && isSlotProp(key)) {
1306
+ const value = attrs[i + 1];
1307
+ if (value) {
1308
+ attrs[i + 1] = null;
1309
+ const projection = "string" == typeof value ? vnode_locate(container.rootVNode, value) : value;
1310
+ let projectionChild = vnode_getFirstChild(projection);
1311
+ for (; projectionChild; ) {
1312
+ cleanup(container, projectionChild), projectionChild = vnode_getNextSibling(projectionChild);
1313
+ }
1314
+ cleanupStaleUnclaimedProjection(container.$journal$, projection);
1315
+ }
1316
+ }
1317
+ }
1318
+ }
1319
+ if (type & VNodeFlags.Virtual && null !== vnode_getProp(vCursor, QSlot, null)) {
1320
+ if (vCursor === vNode) {
1321
+ const vFirstChild = vnode_getFirstChild(vCursor);
1322
+ if (vFirstChild) {
1323
+ return void vnode_walkVNode(vFirstChild);
1324
+ }
1325
+ }
1326
+ } else {
1327
+ const vFirstChild = vnode_getFirstChild(vCursor);
1328
+ if (vFirstChild) {
1329
+ vCursor = vFirstChild;
1330
+ continue;
1331
+ }
1332
+ }
1333
+ }
1334
+ if (vCursor === vNode) {
1335
+ return;
1336
+ }
1337
+ const vNextSibling = vnode_getNextSibling(vCursor);
1338
+ if (vNextSibling) {
1339
+ vCursor = vNextSibling;
1340
+ } else {
1341
+ for (vParent = vnode_getParent(vCursor); vParent; ) {
1342
+ if (vParent === vNode) {
1343
+ return;
1344
+ }
1345
+ const vNextParentSibling = vnode_getNextSibling(vParent);
1346
+ if (vNextParentSibling) {
1347
+ vCursor = vNextParentSibling;
1348
+ break;
1349
+ }
1350
+ vParent = vnode_getParent(vParent);
1351
+ }
1352
+ if (null == vParent) {
1353
+ return;
1354
+ }
1355
+ }
71
1356
  }
72
1357
  }
73
- function isSubscriber(value) {
74
- return value instanceof Subscriber || value instanceof WrappedSignal;
1358
+ function cleanupStaleUnclaimedProjection(journal, projection) {
1359
+ const projectionParent = vnode_getParent(projection);
1360
+ if (projectionParent) {
1361
+ projectionParent[VNodeProps.flags] & VNodeFlags.Element && vnode_getElementName(projectionParent) === QTemplate && vnode_remove(journal, projectionParent, projection, true);
1362
+ }
75
1363
  }
76
- var VNodeFlags;
77
- var VNodeFlagsIndex;
78
- var VNodeProps;
79
- var ElementVNodeProps;
80
- var TextVNodeProps;
81
- var VirtualVNodeProps;
82
- !function(VNodeFlags2) {
83
- VNodeFlags2[VNodeFlags2.Element = 1] = "Element", VNodeFlags2[VNodeFlags2.Virtual = 2] = "Virtual", VNodeFlags2[VNodeFlags2.ELEMENT_OR_VIRTUAL_MASK = 3] = "ELEMENT_OR_VIRTUAL_MASK", VNodeFlags2[VNodeFlags2.ELEMENT_OR_TEXT_MASK = 5] = "ELEMENT_OR_TEXT_MASK", VNodeFlags2[VNodeFlags2.TYPE_MASK = 7] = "TYPE_MASK", VNodeFlags2[VNodeFlags2.INFLATED_TYPE_MASK = 15] = "INFLATED_TYPE_MASK", VNodeFlags2[VNodeFlags2.Text = 4] = "Text", VNodeFlags2[VNodeFlags2.Inflated = 8] = "Inflated", VNodeFlags2[VNodeFlags2.Resolved = 16] = "Resolved", VNodeFlags2[VNodeFlags2.Deleted = 32] = "Deleted", VNodeFlags2[VNodeFlags2.NAMESPACE_MASK = 192] = "NAMESPACE_MASK", VNodeFlags2[VNodeFlags2.NEGATED_NAMESPACE_MASK = -193] = "NEGATED_NAMESPACE_MASK", VNodeFlags2[VNodeFlags2.NS_html = 0] = "NS_html", VNodeFlags2[VNodeFlags2.NS_svg = 64] = "NS_svg", VNodeFlags2[VNodeFlags2.NS_math = 128] = "NS_math";
84
- }(VNodeFlags || (VNodeFlags = {})), function(VNodeFlagsIndex2) {
85
- VNodeFlagsIndex2[VNodeFlagsIndex2.mask = -256] = "mask", VNodeFlagsIndex2[VNodeFlagsIndex2.negated_mask = 255] = "negated_mask", VNodeFlagsIndex2[VNodeFlagsIndex2.shift = 8] = "shift";
86
- }(VNodeFlagsIndex || (VNodeFlagsIndex = {})), function(VNodeProps2) {
87
- VNodeProps2[VNodeProps2.flags = 0] = "flags", VNodeProps2[VNodeProps2.parent = 1] = "parent", VNodeProps2[VNodeProps2.previousSibling = 2] = "previousSibling", VNodeProps2[VNodeProps2.nextSibling = 3] = "nextSibling";
88
- }(VNodeProps || (VNodeProps = {})), function(ElementVNodeProps2) {
89
- ElementVNodeProps2[ElementVNodeProps2.firstChild = 4] = "firstChild", ElementVNodeProps2[ElementVNodeProps2.lastChild = 5] = "lastChild", ElementVNodeProps2[ElementVNodeProps2.element = 6] = "element", ElementVNodeProps2[ElementVNodeProps2.elementName = 7] = "elementName", ElementVNodeProps2[ElementVNodeProps2.PROPS_OFFSET = 8] = "PROPS_OFFSET";
90
- }(ElementVNodeProps || (ElementVNodeProps = {})), function(TextVNodeProps2) {
91
- TextVNodeProps2[TextVNodeProps2.node = 4] = "node", TextVNodeProps2[TextVNodeProps2.text = 5] = "text";
92
- }(TextVNodeProps || (TextVNodeProps = {})), function(VirtualVNodeProps2) {
93
- VirtualVNodeProps2[VirtualVNodeProps2.firstChild = 4] = "firstChild", VirtualVNodeProps2[VirtualVNodeProps2.lastChild = 5] = "lastChild", VirtualVNodeProps2[VirtualVNodeProps2.PROPS_OFFSET = 6] = "PROPS_OFFSET";
94
- }(VirtualVNodeProps || (VirtualVNodeProps = {}));
1364
+ function markVNodeAsDeleted(vCursor) {
1365
+ vCursor[VNodeProps.flags] |= VNodeFlags.Deleted;
1366
+ }
1367
+ const HANDLER_PREFIX = ":";
95
1368
  var SiblingsArray;
96
1369
  !function(SiblingsArray2) {
97
1370
  SiblingsArray2[SiblingsArray2.Name = 0] = "Name", SiblingsArray2[SiblingsArray2.Key = 1] = "Key", SiblingsArray2[SiblingsArray2.VNode = 2] = "VNode", SiblingsArray2[SiblingsArray2.Size = 3] = "Size", SiblingsArray2[SiblingsArray2.NextVNode = 5] = "NextVNode";
98
1371
  }(SiblingsArray || (SiblingsArray = {}));
99
- var ChoreType;
100
- !function(ChoreType2) {
101
- ChoreType2[ChoreType2.MACRO = 240] = "MACRO", ChoreType2[ChoreType2.MICRO = 15] = "MICRO", ChoreType2[ChoreType2.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType2[ChoreType2.RESOURCE = 2] = "RESOURCE", ChoreType2[ChoreType2.TASK = 3] = "TASK", ChoreType2[ChoreType2.NODE_DIFF = 4] = "NODE_DIFF", ChoreType2[ChoreType2.NODE_PROP = 5] = "NODE_PROP", ChoreType2[ChoreType2.COMPONENT_SSR = 6] = "COMPONENT_SSR", ChoreType2[ChoreType2.COMPONENT = 7] = "COMPONENT", ChoreType2[ChoreType2.RECOMPUTE_AND_SCHEDULE_EFFECTS = 8] = "RECOMPUTE_AND_SCHEDULE_EFFECTS", ChoreType2[ChoreType2.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType2[ChoreType2.VISIBLE = 32] = "VISIBLE", ChoreType2[ChoreType2.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType2[ChoreType2.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
102
- }(ChoreType || (ChoreType = {}));
103
- var TaskFlags;
104
- !function(TaskFlags2) {
105
- TaskFlags2[TaskFlags2.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags2[TaskFlags2.TASK = 2] = "TASK", TaskFlags2[TaskFlags2.RESOURCE = 4] = "RESOURCE", TaskFlags2[TaskFlags2.DIRTY = 8] = "DIRTY";
106
- }(TaskFlags || (TaskFlags = {}));
107
- class Task extends Subscriber {
108
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
109
- super();
110
- __publicField(this, "$flags$");
111
- __publicField(this, "$index$");
112
- __publicField(this, "$el$");
113
- __publicField(this, "$qrl$");
114
- __publicField(this, "$state$");
115
- __publicField(this, "$destroy$");
116
- this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$, this.$state$ = $state$, this.$destroy$ = $destroy$;
1372
+ const _createResourceReturn = (opts) => ({
1373
+ __brand: "resource",
1374
+ value: void 0,
1375
+ loading: !isServerPlatform(),
1376
+ _resolved: void 0,
1377
+ _error: void 0,
1378
+ _state: "pending",
1379
+ _timeout: -1,
1380
+ _cache: 0
1381
+ });
1382
+ const createResourceReturn = (container, opts, initialPromise) => {
1383
+ const result = _createResourceReturn();
1384
+ return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
1385
+ };
1386
+ const runResource = (task, container, host) => {
1387
+ task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
1388
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
1389
+ iCtx.$container$ = container;
1390
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
1391
+ const resource = task.$state$;
1392
+ const cleanups = [];
1393
+ task.$destroy$ = noSerialize(() => {
1394
+ cleanups.forEach((fn) => {
1395
+ try {
1396
+ fn();
1397
+ } catch (err) {
1398
+ container.handleError(err, host);
1399
+ }
1400
+ }), done = true;
1401
+ });
1402
+ const resourceTarget = unwrapStore(resource);
1403
+ const opts = {
1404
+ track: (obj, prop) => {
1405
+ const ctx = newInvokeContext();
1406
+ return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container, invoke(ctx, () => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj);
1407
+ },
1408
+ cleanup(fn) {
1409
+ "function" == typeof fn && cleanups.push(fn);
1410
+ },
1411
+ cache(policy) {
1412
+ let milliseconds = 0;
1413
+ milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
1414
+ },
1415
+ previous: resourceTarget._resolved
1416
+ };
1417
+ let resolve;
1418
+ let reject;
1419
+ let done = false;
1420
+ const setState = (resolved, value) => !done && (done = true, resolved ? (done = true, resource.loading = false, resource._state = "resolved", resource._resolved = value, resource._error = void 0, resolve(value)) : (done = true, resource.loading = false, resource._state = "rejected", resource._error = value, reject(value)), true);
1421
+ cleanups.push(() => {
1422
+ if (true === untrack(() => resource.loading)) {
1423
+ const value = untrack(() => resource._resolved);
1424
+ setState(true, value);
1425
+ }
1426
+ }), invoke(iCtx, () => {
1427
+ resource._state = "pending", resource.loading = !isServerPlatform();
1428
+ (resource.value = new Promise((r, re) => {
1429
+ resolve = r, reject = re;
1430
+ })).catch(ignoreErrorToPreventNodeFromCrashing);
1431
+ });
1432
+ const promise = safeCall(() => Promise.resolve(taskFn(opts)), (value) => {
1433
+ setState(true, value);
1434
+ }, (err) => {
1435
+ if (isPromise(err)) {
1436
+ return err.then(() => runResource(task, container, host));
1437
+ }
1438
+ setState(false, err);
1439
+ });
1440
+ const timeout = resourceTarget._timeout;
1441
+ return timeout > 0 ? Promise.race([promise, delay(timeout).then(() => {
1442
+ setState(false, new Error("timeout")) && cleanupTask(task);
1443
+ })]) : promise;
1444
+ };
1445
+ const ignoreErrorToPreventNodeFromCrashing = () => {
1446
+ };
1447
+ const aVNodePath = [];
1448
+ const bVNodePath = [];
1449
+ const vnode_documentPosition = (a2, b, rootVNode) => {
1450
+ if (a2 === b) {
1451
+ return 0;
1452
+ }
1453
+ let aDepth = -1;
1454
+ let bDepth = -1;
1455
+ for (; a2; ) {
1456
+ a2 = (aVNodePath[++aDepth] = a2)[VNodeProps.parent] || rootVNode && vnode_getProp(a2, ":", (id) => vnode_locate(rootVNode, id));
1457
+ }
1458
+ for (; b; ) {
1459
+ b = (bVNodePath[++bDepth] = b)[VNodeProps.parent] || rootVNode && vnode_getProp(b, ":", (id) => vnode_locate(rootVNode, id));
1460
+ }
1461
+ for (; aDepth >= 0 && bDepth >= 0; ) {
1462
+ if ((a2 = aVNodePath[aDepth]) !== (b = bVNodePath[bDepth])) {
1463
+ let cursor = b;
1464
+ do {
1465
+ if (cursor = vnode_getNextSibling(cursor), cursor === a2) {
1466
+ return 1;
1467
+ }
1468
+ } while (cursor);
1469
+ cursor = b;
1470
+ do {
1471
+ if (cursor = vnode_getPreviousSibling(cursor), cursor === a2) {
1472
+ return -1;
1473
+ }
1474
+ } while (cursor);
1475
+ return rootVNode && vnode_getProp(b, ":", (id) => vnode_locate(rootVNode, id)) ? -1 : 1;
1476
+ }
1477
+ aDepth--, bDepth--;
1478
+ }
1479
+ return aDepth < bDepth ? -1 : 1;
1480
+ };
1481
+ const aSsrNodePath = [];
1482
+ const bSsrNodePath = [];
1483
+ const ssrNodeDocumentPosition = (a2, b) => {
1484
+ if (a2 === b) {
1485
+ return 0;
1486
+ }
1487
+ let aDepth = -1;
1488
+ let bDepth = -1;
1489
+ for (; a2; ) {
1490
+ a2 = (aSsrNodePath[++aDepth] = a2).currentComponentNode;
1491
+ }
1492
+ for (; b; ) {
1493
+ b = (bSsrNodePath[++bDepth] = b).currentComponentNode;
1494
+ }
1495
+ for (; aDepth >= 0 && bDepth >= 0; ) {
1496
+ if ((a2 = aSsrNodePath[aDepth]) !== (b = bSsrNodePath[bDepth])) {
1497
+ return 1;
1498
+ }
1499
+ aDepth--, bDepth--;
1500
+ }
1501
+ return aDepth < bDepth ? -1 : 1;
1502
+ };
1503
+ const getPromise = (chore) => chore.$promise$ || (chore.$promise$ = new Promise((resolve) => {
1504
+ chore.$resolve$ = resolve;
1505
+ }));
1506
+ const createScheduler = (container, scheduleDrain, journalFlush) => {
1507
+ const choreQueue = [];
1508
+ const qrlRuns = [];
1509
+ let currentChore = null;
1510
+ let drainScheduled = false;
1511
+ return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
1512
+ const isServer3 = !isDomContainer(container);
1513
+ const isComponentSsr = isServer3 && type === ChoreType.COMPONENT;
1514
+ const runLater = type !== ChoreType.WAIT_FOR_ALL && !isComponentSsr && type !== ChoreType.RUN_QRL;
1515
+ const isTask2 = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.CLEANUP_VISIBLE;
1516
+ const isClientOnly = type === ChoreType.JOURNAL_FLUSH || type === ChoreType.NODE_DIFF || type === ChoreType.NODE_PROP;
1517
+ if (isServer3 && isClientOnly) {
1518
+ return;
1519
+ }
1520
+ isTask2 && (hostOrTask.$flags$ |= TaskFlags.DIRTY);
1521
+ let chore = {
1522
+ $type$: type,
1523
+ $idx$: isTask2 ? hostOrTask.$index$ : "string" == typeof targetOrQrl ? targetOrQrl : 0,
1524
+ $host$: isTask2 ? hostOrTask.$el$ : hostOrTask,
1525
+ $target$: targetOrQrl,
1526
+ $payload$: isTask2 ? hostOrTask : payload,
1527
+ $resolve$: null,
1528
+ $promise$: null,
1529
+ $returnValue$: null,
1530
+ $executed$: false
1531
+ };
1532
+ chore = function(sortedArray, value, rootVNode) {
1533
+ const idx = function(sortedArray2, value2, rootVNode2) {
1534
+ let bottom = 0;
1535
+ let top = sortedArray2.length;
1536
+ for (; bottom < top; ) {
1537
+ const middle = bottom + (top - bottom >> 1);
1538
+ const comp = choreComparator(value2, sortedArray2[middle], rootVNode2);
1539
+ if (comp < 0) {
1540
+ top = middle;
1541
+ } else {
1542
+ if (!(comp > 0)) {
1543
+ return middle;
1544
+ }
1545
+ bottom = middle + 1;
1546
+ }
1547
+ }
1548
+ return ~bottom;
1549
+ }(sortedArray, value, rootVNode);
1550
+ if (idx < 0) {
1551
+ return sortedArray.splice(~idx, 0, value), value;
1552
+ }
1553
+ const existing = sortedArray[idx];
1554
+ existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = value.$payload$);
1555
+ existing.$executed$ && (existing.$executed$ = false);
1556
+ return existing;
1557
+ }(choreQueue, chore, container.rootVNode || null), !drainScheduled && runLater && (drainScheduled = true, schedule(ChoreType.JOURNAL_FLUSH), scheduleDrain()?.catch?.(() => {
1558
+ }));
1559
+ return runLater ? getPromise(chore) : drainUpTo(chore, isServer3);
1560
+ };
1561
+ function drainUpTo(runUptoChore, isServer3) {
1562
+ let maxRetries = 5e3;
1563
+ for (; choreQueue.length; ) {
1564
+ if (maxRetries-- < 0) {
1565
+ throw new Error("drainUpTo: max retries reached");
1566
+ }
1567
+ if (currentChore) {
1568
+ return getPromise(currentChore).then(() => drainUpTo(runUptoChore, isServer3)).catch((e) => {
1569
+ container.handleError(e, currentChore?.$host$);
1570
+ });
1571
+ }
1572
+ const nextChore = choreQueue[0];
1573
+ if (nextChore.$executed$) {
1574
+ if (choreQueue.shift(), nextChore === runUptoChore) {
1575
+ break;
1576
+ }
1577
+ } else {
1578
+ vNodeAlreadyDeleted(nextChore) && nextChore.$type$ !== ChoreType.CLEANUP_VISIBLE ? choreQueue.shift() : executeChore(nextChore, isServer3);
1579
+ }
1580
+ }
1581
+ return runUptoChore.$returnValue$;
1582
+ }
1583
+ function executeChore(chore, isServer3) {
1584
+ const host = chore.$host$;
1585
+ currentChore = chore;
1586
+ let returnValue = null;
1587
+ try {
1588
+ switch (chore.$type$) {
1589
+ case ChoreType.WAIT_FOR_ALL:
1590
+ isServer3 && (drainScheduled = false);
1591
+ break;
1592
+ case ChoreType.JOURNAL_FLUSH:
1593
+ returnValue = journalFlush(), drainScheduled = false;
1594
+ break;
1595
+ case ChoreType.COMPONENT:
1596
+ returnValue = safeCall(() => executeComponent(container, host, host, chore.$target$, chore.$payload$), (jsx2) => {
1597
+ if (isServer3) {
1598
+ return jsx2;
1599
+ }
1600
+ {
1601
+ const styleScopedId = container.getHostProp(host, "q:sstyle");
1602
+ return retryOnPromise(() => vnode_diff(container, jsx2, host, addComponentStylePrefix(styleScopedId)));
1603
+ }
1604
+ }, (err) => container.handleError(err, host));
1605
+ break;
1606
+ case ChoreType.RUN_QRL:
1607
+ {
1608
+ const fn = chore.$target$.getFn();
1609
+ const result = retryOnPromise(() => fn(...chore.$payload$));
1610
+ if (isPromise(result)) {
1611
+ const handled = result.finally(() => {
1612
+ qrlRuns.splice(qrlRuns.indexOf(handled), 1);
1613
+ }).catch((error) => {
1614
+ container.handleError(error, chore.$host$);
1615
+ });
1616
+ return qrlRuns.push(handled), chore.$returnValue$ = handled, chore.$resolve$?.(handled), currentChore = null, void (chore.$executed$ = true);
1617
+ }
1618
+ returnValue = null;
1619
+ }
1620
+ break;
1621
+ case ChoreType.TASK:
1622
+ case ChoreType.VISIBLE:
1623
+ {
1624
+ const payload = chore.$payload$;
1625
+ if (payload.$flags$ & TaskFlags.RESOURCE) {
1626
+ const result = runResource(payload, container, host);
1627
+ returnValue = isServer3 ? result : null;
1628
+ } else {
1629
+ returnValue = runTask(payload, container, host);
1630
+ }
1631
+ }
1632
+ break;
1633
+ case ChoreType.CLEANUP_VISIBLE:
1634
+ cleanupTask(chore.$payload$);
1635
+ break;
1636
+ case ChoreType.NODE_DIFF:
1637
+ {
1638
+ const parentVirtualNode = chore.$target$;
1639
+ let jsx2 = chore.$payload$;
1640
+ isSignal(jsx2) && (jsx2 = jsx2.value), returnValue = retryOnPromise(() => vnode_diff(container, jsx2, parentVirtualNode, null));
1641
+ }
1642
+ break;
1643
+ case ChoreType.NODE_PROP:
1644
+ {
1645
+ const virtualNode = chore.$host$;
1646
+ const payload = chore.$payload$;
1647
+ let value = payload.$value$;
1648
+ isSignal(value) && (value = value.value);
1649
+ const isConst = payload.$isConst$;
1650
+ const journal = container.$journal$;
1651
+ const property = chore.$idx$;
1652
+ const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
1653
+ if (isConst) {
1654
+ journal.push(VNodeJournalOpCode.SetAttribute, virtualNode[ElementVNodeProps.element], property, serializedValue);
1655
+ } else {
1656
+ vnode_setAttr(journal, virtualNode, property, serializedValue);
1657
+ }
1658
+ }
1659
+ break;
1660
+ case ChoreType.QRL_RESOLVE:
1661
+ {
1662
+ const target = chore.$target$;
1663
+ returnValue = target.resolved ? null : target.resolve();
1664
+ }
1665
+ break;
1666
+ case ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS: {
1667
+ const target = chore.$target$;
1668
+ const forceRunEffects = target.$forceRunEffects$;
1669
+ if (target.$forceRunEffects$ = false, !target.$effects$?.size) {
1670
+ break;
1671
+ }
1672
+ returnValue = retryOnPromise(() => {
1673
+ (target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
1674
+ });
1675
+ }
1676
+ }
1677
+ } catch (e) {
1678
+ returnValue = Promise.reject(e);
1679
+ }
1680
+ const after = (value, error) => {
1681
+ currentChore = null, chore.$executed$ = true, error ? container.handleError(error, host) : (chore.$returnValue$ = value, chore.$resolve$?.(value));
1682
+ };
1683
+ isPromise(returnValue) ? (chore.$promise$ = returnValue.then(after, (error) => after(void 0, error)), chore.$resolve$?.(chore.$promise$), chore.$resolve$ = void 0) : after(returnValue);
1684
+ }
1685
+ function choreComparator(a2, b, rootVNode) {
1686
+ const macroTypeDiff = (a2.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
1687
+ if (0 !== macroTypeDiff) {
1688
+ return macroTypeDiff;
1689
+ }
1690
+ const aHost = a2.$host$;
1691
+ const bHost = b.$host$;
1692
+ if (aHost !== bHost && null !== aHost && null !== bHost) {
1693
+ if (vnode_isVNode(aHost) && vnode_isVNode(bHost)) {
1694
+ const hostDiff = vnode_documentPosition(aHost, bHost, rootVNode);
1695
+ if (0 !== hostDiff) {
1696
+ return hostDiff;
1697
+ }
1698
+ } else {
1699
+ `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.
1700
+ You are attempting to change a state that has already been streamed to the client.
1701
+ This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
1702
+ Problematic Node: ${aHost.toString()}`;
1703
+ const hostDiff = ssrNodeDocumentPosition(aHost, bHost);
1704
+ if (0 !== hostDiff) {
1705
+ return hostDiff;
1706
+ }
1707
+ }
1708
+ }
1709
+ const microTypeDiff = (a2.$type$ & ChoreType.MICRO) - (b.$type$ & ChoreType.MICRO);
1710
+ if (0 !== microTypeDiff) {
1711
+ return microTypeDiff;
1712
+ }
1713
+ const idxDiff = toNumber(a2.$idx$) - toNumber(b.$idx$);
1714
+ return 0 !== idxDiff ? idxDiff : a2.$target$ !== b.$target$ || a2.$payload$ !== b.$payload$ || b === currentChore ? 1 : 0;
117
1715
  }
1716
+ };
1717
+ const toNumber = (value) => "number" == typeof value ? value : -1;
1718
+ function vNodeAlreadyDeleted(chore) {
1719
+ return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted);
118
1720
  }
119
- const isTask = (value) => value instanceof Task;
120
- const NEEDS_COMPUTATION = Symbol("invalid");
121
1721
  const throwIfQRLNotResolved = (qrl2) => {
122
1722
  if (!qrl2.resolved) {
123
1723
  throw qrl2.resolve();
124
1724
  }
125
1725
  };
126
1726
  const isSignal = (value) => value instanceof Signal;
127
- class EffectPropData {
1727
+ class SubscriptionData {
128
1728
  constructor(data) {
129
1729
  __publicField(this, "data");
130
1730
  this.data = data;
131
1731
  }
132
1732
  }
133
- var EffectSubscriptionsProp;
1733
+ var EffectSubscriptionProp;
134
1734
  var EffectProperty;
135
- !function(EffectSubscriptionsProp2) {
136
- EffectSubscriptionsProp2[EffectSubscriptionsProp2.EFFECT = 0] = "EFFECT", EffectSubscriptionsProp2[EffectSubscriptionsProp2.PROPERTY = 1] = "PROPERTY", EffectSubscriptionsProp2[EffectSubscriptionsProp2.FIRST_BACK_REF_OR_DATA = 2] = "FIRST_BACK_REF_OR_DATA";
137
- }(EffectSubscriptionsProp || (EffectSubscriptionsProp = {})), function(EffectProperty2) {
1735
+ !function(EffectSubscriptionProp2) {
1736
+ EffectSubscriptionProp2[EffectSubscriptionProp2.CONSUMER = 0] = "CONSUMER", EffectSubscriptionProp2[EffectSubscriptionProp2.PROPERTY = 1] = "PROPERTY", EffectSubscriptionProp2[EffectSubscriptionProp2.BACK_REF = 2] = "BACK_REF", EffectSubscriptionProp2[EffectSubscriptionProp2.DATA = 3] = "DATA";
1737
+ }(EffectSubscriptionProp || (EffectSubscriptionProp = {})), function(EffectProperty2) {
138
1738
  EffectProperty2.COMPONENT = ":", EffectProperty2.VNODE = ".";
139
1739
  }(EffectProperty || (EffectProperty = {}));
140
1740
  class Signal {
@@ -163,8 +1763,8 @@ class Signal {
163
1763
  }
164
1764
  const effectSubscriber = ctx.$effectSubscriber$;
165
1765
  if (effectSubscriber) {
166
- const effects = this.$effects$ || (this.$effects$ = []);
167
- ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, this), isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], this, this.$container$);
1766
+ const effects = this.$effects$ || (this.$effects$ = /* @__PURE__ */ new Set());
1767
+ ensureContainsSubscription(effects, effectSubscriber), ensureContainsBackRef(effectSubscriber, this), addQrlToSerializationCtx(effectSubscriber, this.$container$);
168
1768
  }
169
1769
  }
170
1770
  return this.untrackedValue;
@@ -175,7 +1775,7 @@ class Signal {
175
1775
  valueOf() {
176
1776
  }
177
1777
  toString() {
178
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
1778
+ return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e) => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "");
179
1779
  }
180
1780
  toJSON() {
181
1781
  return {
@@ -183,77 +1783,56 @@ class Signal {
183
1783
  };
184
1784
  }
185
1785
  }
186
- const ensureContains = (array, value) => {
187
- -1 === array.indexOf(value) && array.push(value);
188
- };
189
- const ensureContainsEffect = (array, effectSubscriptions) => {
190
- for (let i = 0; i < array.length; i++) {
191
- const existingEffect = array[i];
192
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
193
- return;
194
- }
195
- }
196
- array.push(effectSubscriptions);
1786
+ const ensureContainsSubscription = (array, effectSubscription) => {
1787
+ array.add(effectSubscription);
197
1788
  };
198
- const ensureEffectContainsSubscriber = (effect, subscriber, container) => {
199
- if (isSubscriber(effect)) {
200
- if (effect.$effectDependencies$ || (effect.$effectDependencies$ = []), subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
201
- return;
202
- }
203
- effect.$effectDependencies$.push(subscriber);
204
- } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
205
- let subscribers = vnode_getProp(effect, "q:subs", container ? container.$getObjectById$ : null);
206
- if (subscribers || (subscribers = []), subscriberExistInSubscribers(subscribers, subscriber)) {
207
- return;
208
- }
209
- subscribers.push(subscriber), vnode_setProp(effect, "q:subs", subscribers);
210
- } else if (isSSRNode(effect)) {
211
- let subscribers = effect.getProp("q:subs");
212
- if (subscribers || (subscribers = []), subscriberExistInSubscribers(subscribers, subscriber)) {
213
- return;
214
- }
215
- subscribers.push(subscriber), effect.setProp("q:subs", subscribers);
216
- }
1789
+ const ensureContainsBackRef = (array, value) => {
1790
+ var _a2;
1791
+ array[_a2 = EffectSubscriptionProp.BACK_REF] || (array[_a2] = /* @__PURE__ */ new Set()), array[EffectSubscriptionProp.BACK_REF].add(value);
217
1792
  };
218
- const isSSRNode = (effect) => "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
219
- const subscriberExistInSubscribers = (subscribers, subscriber) => {
220
- for (let i = 0; i < subscribers.length; i++) {
221
- if (subscribers[i] === subscriber) {
222
- return true;
223
- }
1793
+ const addQrlToSerializationCtx = (effectSubscriber, container) => {
1794
+ if (container && !isDomContainer(container)) {
1795
+ const effect = effectSubscriber[EffectSubscriptionProp.CONSUMER];
1796
+ const property = effectSubscriber[EffectSubscriptionProp.PROPERTY];
1797
+ let qrl2 = null;
1798
+ isTask(effect) ? qrl2 = effect.$qrl$ : effect instanceof ComputedSignal ? qrl2 = effect.$computeQrl$ : property === EffectProperty.COMPONENT && (qrl2 = container.getHostProp(effect, "q:renderFn")), qrl2 && container.serializationCtx.$eventQrls$.add(qrl2);
224
1799
  }
225
- return false;
226
1800
  };
227
1801
  const triggerEffects = (container, signal, effects) => {
1802
+ const isBrowser2 = isDomContainer(container);
228
1803
  if (effects) {
229
- const scheduleEffect = (effectSubscriptions) => {
230
- const effect = effectSubscriptions[EffectSubscriptionsProp.EFFECT];
231
- const property = effectSubscriptions[EffectSubscriptionsProp.PROPERTY];
232
- if (isTask(effect)) {
233
- effect.$flags$ |= TaskFlags.DIRTY;
1804
+ const scheduleEffect = (effectSubscription) => {
1805
+ const consumer = effectSubscription[EffectSubscriptionProp.CONSUMER];
1806
+ const property = effectSubscription[EffectSubscriptionProp.PROPERTY];
1807
+ if (isTask(consumer)) {
1808
+ consumer.$flags$ |= TaskFlags.DIRTY;
234
1809
  let choreType = ChoreType.TASK;
235
- effect.$flags$ & TaskFlags.VISIBLE_TASK ? choreType = ChoreType.VISIBLE : effect.$flags$ & TaskFlags.RESOURCE && (choreType = ChoreType.RESOURCE), container.$scheduler$(choreType, effect);
236
- } else if (effect instanceof Signal) {
237
- effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, effect.$computeQrl$)), effect.$invalidate$();
1810
+ consumer.$flags$ & TaskFlags.VISIBLE_TASK && (choreType = ChoreType.VISIBLE), container.$scheduler$(choreType, consumer);
1811
+ } else if (consumer instanceof Signal) {
1812
+ consumer instanceof ComputedSignal && (consumer.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, consumer.$computeQrl$)), consumer.$invalidate$();
238
1813
  } else if (property === EffectProperty.COMPONENT) {
239
- const host = effect;
1814
+ const host = consumer;
240
1815
  const qrl2 = container.getHostProp(host, "q:renderFn");
241
1816
  const props = container.getHostProp(host, "q:props");
242
1817
  container.$scheduler$(ChoreType.COMPONENT, host, qrl2, props);
243
- } else if (property === EffectProperty.VNODE) {
244
- container.$scheduler$(ChoreType.NODE_DIFF, effect, effect, signal);
245
- } else {
246
- const effectData = effectSubscriptions[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA];
247
- if (effectData instanceof EffectPropData) {
248
- const payload = {
249
- ...effectData.data,
250
- $value$: signal
251
- };
252
- container.$scheduler$(ChoreType.NODE_PROP, effect, property, payload);
1818
+ } else if (isBrowser2) {
1819
+ if (property === EffectProperty.VNODE) {
1820
+ container.$scheduler$(ChoreType.NODE_DIFF, consumer, consumer, signal);
1821
+ } else {
1822
+ const effectData = effectSubscription[EffectSubscriptionProp.DATA];
1823
+ if (effectData instanceof SubscriptionData) {
1824
+ const payload = {
1825
+ ...effectData.data,
1826
+ $value$: signal
1827
+ };
1828
+ container.$scheduler$(ChoreType.NODE_PROP, consumer, property, payload);
1829
+ }
253
1830
  }
254
1831
  }
255
1832
  };
256
- effects.forEach(scheduleEffect);
1833
+ for (const effect of effects) {
1834
+ scheduleEffect(effect);
1835
+ }
257
1836
  }
258
1837
  };
259
1838
  class ComputedSignal extends Signal {
@@ -282,7 +1861,7 @@ class ComputedSignal extends Signal {
282
1861
  throwIfQRLNotResolved(computeQrl);
283
1862
  const ctx = tryGetInvokeContext();
284
1863
  const previousEffectSubscription = ctx?.$effectSubscriber$;
285
- ctx && (ctx.$effectSubscriber$ = [this, EffectProperty.VNODE]);
1864
+ ctx && (ctx.$effectSubscriber$ = getSubscriber(this, EffectProperty.VNODE));
286
1865
  try {
287
1866
  const untrackedValue = computeQrl.getFn(ctx)();
288
1867
  if (isPromise(untrackedValue)) {
@@ -302,16 +1881,16 @@ class ComputedSignal extends Signal {
302
1881
  throw qError(QError.computedReadOnly);
303
1882
  }
304
1883
  }
305
- class WrappedSignal extends Signal {
1884
+ class WrappedSignal extends (_c = Signal, _b = _EFFECT_BACK_REF, _c) {
306
1885
  constructor(container, fn, args, fnStr) {
307
1886
  super(container, NEEDS_COMPUTATION);
308
1887
  __publicField(this, "$args$");
309
1888
  __publicField(this, "$func$");
310
1889
  __publicField(this, "$funcStr$");
311
1890
  __publicField(this, "$invalid$", true);
312
- __publicField(this, "$effectDependencies$", null);
313
1891
  __publicField(this, "$hostElement$", null);
314
1892
  __publicField(this, "$forceRunEffects$", false);
1893
+ __publicField(this, _b, null);
315
1894
  this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr;
316
1895
  }
317
1896
  $invalidate$() {
@@ -339,11 +1918,31 @@ class WrappedSignal extends Signal {
339
1918
  throw qError(QError.wrappedReadOnly);
340
1919
  }
341
1920
  }
342
- const _CONST_PROPS = Symbol("CONST");
343
- const _VAR_PROPS = Symbol("VAR");
1921
+ const version = "2.0.0-alpha.7-dev+a26598a";
1922
+ class _SharedContainer {
1923
+ constructor(scheduleDrain, journalFlush, serverData, locale) {
1924
+ __publicField(this, "$version$");
1925
+ __publicField(this, "$scheduler$");
1926
+ __publicField(this, "$storeProxyMap$");
1927
+ __publicField(this, "$locale$");
1928
+ __publicField(this, "$getObjectById$");
1929
+ __publicField(this, "$serverData$");
1930
+ __publicField(this, "$currentUniqueId$", 0);
1931
+ __publicField(this, "$instanceHash$", null);
1932
+ this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version, this.$storeProxyMap$ = /* @__PURE__ */ new WeakMap(), this.$getObjectById$ = () => {
1933
+ throw Error("Not implemented");
1934
+ }, this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
1935
+ }
1936
+ trackSignalValue(signal, subscriber, property, data) {
1937
+ return trackSignalAndAssignHost(signal, subscriber, property, this, data);
1938
+ }
1939
+ serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
1940
+ return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
1941
+ }
1942
+ }
344
1943
  const _jsxSorted = (type, varProps, constProps, children, flags, key) => {
345
1944
  const processed = null == key ? null : String(key);
346
- const node = new JSXNodeImpl(type, varProps || {}, null, children, flags, processed);
1945
+ const node = new JSXNodeImpl(type, varProps || {}, constProps || null, children, flags, processed);
347
1946
  return node;
348
1947
  };
349
1948
  const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
@@ -351,9 +1950,10 @@ const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
351
1950
  return sortedProps = varProps ? Object.fromEntries(untrack(() => Object.entries(varProps)).filter((entry) => {
352
1951
  const attr = entry[0];
353
1952
  return "children" === attr ? (children ?? (children = entry[1]), false) : "key" === attr ? (key = entry[1], false) : !constProps;
354
- }).sort(([a2], [b]) => a2 < b ? -1 : 1)) : EMPTY_OBJ, _jsxSorted(type, sortedProps, constProps, children, flags, key);
1953
+ }).sort(([a2], [b]) => a2 < b ? -1 : 1)) : "string" == typeof type ? EMPTY_OBJ : {}, _jsxSorted(type, sortedProps, constProps, children, flags, key);
355
1954
  };
356
1955
  const jsx = (type, props, key) => _jsxSplit(type, props, null, null, 0, null);
1956
+ const isPropsProxy = (obj) => obj && void 0 !== obj[_VAR_PROPS];
357
1957
  class JSXNodeImpl {
358
1958
  constructor(type, varProps, constProps, children, flags, key = null) {
359
1959
  __publicField(this, "type");
@@ -370,7 +1970,9 @@ class JSXNodeImpl {
370
1970
  return this._proxy || (this._proxy = createPropsProxy(this.varProps, this.constProps, this.children)), this._proxy;
371
1971
  }
372
1972
  }
1973
+ const Virtual = (props) => props.children;
373
1974
  const isJSXNode = (n) => n instanceof JSXNodeImpl;
1975
+ const Fragment = (props) => props.children;
374
1976
  function createPropsProxy(varProps, constProps, children) {
375
1977
  return new Proxy({}, new PropsProxyHandler(varProps, constProps, children));
376
1978
  }
@@ -424,6 +2026,7 @@ class PropsProxyHandler {
424
2026
  return out;
425
2027
  }
426
2028
  }
2029
+ const directGetPropsProxyProp = (jsx2, prop) => jsx2.constProps && prop in jsx2.constProps ? jsx2.constProps[prop] : jsx2.varProps[prop];
427
2030
  const stringifyPath = [];
428
2031
  function qwikDebugToString(value) {
429
2032
  if (null === value) {
@@ -441,7 +2044,7 @@ function qwikDebugToString(value) {
441
2044
  if (isTask(value)) {
442
2045
  return `Task(${qwikDebugToString(value.$qrl$)})`;
443
2046
  }
444
- if (isQrl$1(value)) {
2047
+ if (isQrl(value)) {
445
2048
  return `Qrl(${value.$symbol$})`;
446
2049
  }
447
2050
  if ("object" == typeof value || "function" == typeof value) {
@@ -486,17 +2089,121 @@ const jsxToString = (value) => {
486
2089
  }
487
2090
  return String(value);
488
2091
  };
2092
+ const VNodeDataSeparator = {
2093
+ REFERENCE_CH: "~",
2094
+ REFERENCE: 126,
2095
+ ADVANCE_1_CH: "!",
2096
+ ADVANCE_1: 33,
2097
+ ADVANCE_2_CH: '"',
2098
+ ADVANCE_2: 34,
2099
+ ADVANCE_4_CH: "#",
2100
+ ADVANCE_4: 35,
2101
+ ADVANCE_8_CH: "$",
2102
+ ADVANCE_8: 36,
2103
+ ADVANCE_16_CH: "%",
2104
+ ADVANCE_16: 37,
2105
+ ADVANCE_32_CH: "&",
2106
+ ADVANCE_32: 38,
2107
+ ADVANCE_64_CH: "'",
2108
+ ADVANCE_64: 39,
2109
+ ADVANCE_128_CH: "(",
2110
+ ADVANCE_128: 40,
2111
+ ADVANCE_256_CH: ")",
2112
+ ADVANCE_256: 41,
2113
+ ADVANCE_512_CH: "*",
2114
+ ADVANCE_512: 42,
2115
+ ADVANCE_1024_CH: "+",
2116
+ ADVANCE_1024: 43,
2117
+ ADVANCE_2048_CH: ",",
2118
+ ADVANCE_2048: 44,
2119
+ ADVANCE_4096_CH: "-",
2120
+ ADVANCE_4096: 45,
2121
+ ADVANCE_8192_CH: ".",
2122
+ ADVANCE_8192: 46
2123
+ };
2124
+ const VNodeDataChar = {
2125
+ OPEN: 123,
2126
+ OPEN_CHAR: "{",
2127
+ CLOSE: 125,
2128
+ CLOSE_CHAR: "}",
2129
+ SCOPED_STYLE: 59,
2130
+ SCOPED_STYLE_CHAR: ";",
2131
+ RENDER_FN: 60,
2132
+ RENDER_FN_CHAR: "<",
2133
+ ID: 61,
2134
+ ID_CHAR: "=",
2135
+ PROPS: 62,
2136
+ PROPS_CHAR: ">",
2137
+ SLOT_REF: 63,
2138
+ SLOT_REF_CHAR: "?",
2139
+ KEY: 64,
2140
+ KEY_CHAR: "@",
2141
+ SEQ: 91,
2142
+ SEQ_CHAR: "[",
2143
+ DON_T_USE: 92,
2144
+ DON_T_USE_CHAR: "\\",
2145
+ CONTEXT: 93,
2146
+ CONTEXT_CHAR: "]",
2147
+ SEQ_IDX: 94,
2148
+ SEQ_IDX_CHAR: "^",
2149
+ BACK_REFS: 96,
2150
+ BACK_REFS_CHAR: "`",
2151
+ SEPARATOR: 124,
2152
+ SEPARATOR_CHAR: "|",
2153
+ SLOT: 126,
2154
+ SLOT_CHAR: "~"
2155
+ };
2156
+ const mergeMaps = (map1, map2) => {
2157
+ for (const [k, v] of map2) {
2158
+ map1.set(k, v);
2159
+ }
2160
+ return map1;
2161
+ };
489
2162
  var VNodeJournalOpCode;
490
2163
  !function(VNodeJournalOpCode2) {
491
2164
  VNodeJournalOpCode2[VNodeJournalOpCode2.SetText = 1] = "SetText", VNodeJournalOpCode2[VNodeJournalOpCode2.SetAttribute = 2] = "SetAttribute", VNodeJournalOpCode2[VNodeJournalOpCode2.HoistStyles = 3] = "HoistStyles", VNodeJournalOpCode2[VNodeJournalOpCode2.Remove = 4] = "Remove", VNodeJournalOpCode2[VNodeJournalOpCode2.Insert = 5] = "Insert";
492
2165
  }(VNodeJournalOpCode || (VNodeJournalOpCode = {}));
2166
+ const vnode_newElement = (element, elementName) => {
2167
+ assertEqual(fastNodeType(element));
2168
+ const vnode = VNodeArray.createElement(VNodeFlags.Element | VNodeFlags.Inflated | -1 << VNodeFlagsIndex.shift, null, null, null, null, null, element, elementName);
2169
+ return assertTrue(vnode_isElementVNode(vnode)), assertFalse(vnode_isTextVNode(vnode)), assertFalse(vnode_isVirtualVNode(vnode)), vnode;
2170
+ };
2171
+ const vnode_newUnMaterializedElement = (element) => {
2172
+ assertEqual(fastNodeType(element));
2173
+ const vnode = VNodeArray.createElement(VNodeFlags.Element | -1 << VNodeFlagsIndex.shift, null, null, null, void 0, void 0, element, void 0);
2174
+ return assertTrue(vnode_isElementVNode(vnode)), assertFalse(vnode_isTextVNode(vnode)), assertFalse(vnode_isVirtualVNode(vnode)), vnode;
2175
+ };
2176
+ const vnode_newSharedText = (previousTextNode, sharedTextNode, textContent) => {
2177
+ sharedTextNode && assertEqual(fastNodeType(sharedTextNode));
2178
+ const vnode = VNodeArray.createText(VNodeFlags.Text | -1 << VNodeFlagsIndex.shift, null, previousTextNode, null, sharedTextNode, textContent);
2179
+ return assertFalse(vnode_isElementVNode(vnode)), assertTrue(vnode_isTextVNode(vnode)), assertFalse(vnode_isVirtualVNode(vnode)), vnode;
2180
+ };
2181
+ const vnode_newText = (textNode, textContent) => {
2182
+ const vnode = VNodeArray.createText(VNodeFlags.Text | VNodeFlags.Inflated | -1 << VNodeFlagsIndex.shift, null, null, null, textNode, textContent);
2183
+ return assertEqual(fastNodeType(textNode)), assertFalse(vnode_isElementVNode(vnode)), assertTrue(vnode_isTextVNode(vnode)), assertFalse(vnode_isVirtualVNode(vnode)), vnode;
2184
+ };
2185
+ const vnode_newVirtual = () => {
2186
+ const vnode = VNodeArray.createVirtual(VNodeFlags.Virtual | -1 << VNodeFlagsIndex.shift, null, null, null, null, null);
2187
+ return assertFalse(vnode_isElementVNode(vnode)), assertFalse(vnode_isTextVNode(vnode)), assertTrue(vnode_isVirtualVNode(vnode)), vnode;
2188
+ };
493
2189
  const vnode_isVNode = (vNode) => vNode instanceof VNodeArray;
2190
+ const vnode_isElementVNode = (vNode) => {
2191
+ return (vNode[VNodeProps.flags] & VNodeFlags.Element) === VNodeFlags.Element;
2192
+ };
2193
+ const vnode_isElementOrTextVNode = (vNode) => {
2194
+ return !!(vNode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_TEXT_MASK);
2195
+ };
494
2196
  const vnode_isTextVNode = (vNode) => {
495
2197
  return (vNode[VNodeProps.flags] & VNodeFlags.Text) === VNodeFlags.Text;
496
2198
  };
2199
+ const vnode_isVirtualVNode = (vNode) => {
2200
+ return (vNode[VNodeProps.flags] & VNodeFlags.Virtual) === VNodeFlags.Virtual;
2201
+ };
2202
+ const ensureTextVNode = (vNode) => (assertTrue(vnode_isTextVNode(vNode), "Expecting TextVNode was: " + vnode_getNodeTypeName(vNode)), vNode);
497
2203
  const ensureElementOrVirtualVNode = (vNode) => {
498
2204
  assertTrue(!!(vNode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK), "Expecting ElementVNode or VirtualVNode was: " + vnode_getNodeTypeName(vNode));
499
2205
  };
2206
+ const ensureElementVNode = (vNode) => (assertTrue(vnode_isElementVNode(vNode), "Expecting ElementVNode was: " + vnode_getNodeTypeName(vNode)), vNode);
500
2207
  const vnode_getNodeTypeName = (vNode) => {
501
2208
  if (vNode) {
502
2209
  switch (vNode[VNodeProps.flags] & VNodeFlags.TYPE_MASK) {
@@ -516,6 +2223,7 @@ const vnode_ensureElementInflated = (vnode) => {
516
2223
  elementVNode[VNodeProps.flags] ^= VNodeFlags.Inflated;
517
2224
  const element = elementVNode[ElementVNodeProps.element];
518
2225
  const attributes = element.attributes;
2226
+ const props = vnode_getProps(elementVNode);
519
2227
  for (let idx = 0; idx < attributes.length; idx++) {
520
2228
  const attr = attributes[idx];
521
2229
  const key = attr.name;
@@ -523,46 +2231,519 @@ const vnode_ensureElementInflated = (vnode) => {
523
2231
  break;
524
2232
  }
525
2233
  if (key.startsWith("q:container")) {
526
- attr.value === QContainerValue.HTML ? mapArray_set(elementVNode, dangerouslySetInnerHTML, element.innerHTML, ElementVNodeProps.PROPS_OFFSET) : attr.value === QContainerValue.TEXT && "value" in element && mapArray_set(elementVNode, "value", element.value, ElementVNodeProps.PROPS_OFFSET);
2234
+ attr.value === QContainerValue.HTML ? mapArray_set(props, dangerouslySetInnerHTML, element.innerHTML, 0) : attr.value === QContainerValue.TEXT && "value" in element && mapArray_set(props, "value", element.value, 0);
527
2235
  } else if (!key.startsWith("on:")) {
528
- mapArray_set(elementVNode, key, attr.value, ElementVNodeProps.PROPS_OFFSET);
2236
+ mapArray_set(props, key, attr.value, 0);
2237
+ }
2238
+ }
2239
+ }
2240
+ };
2241
+ function vnode_walkVNode(vNode) {
2242
+ let vCursor = vNode;
2243
+ if (vnode_isTextVNode(vNode)) {
2244
+ return;
2245
+ }
2246
+ let vParent = null;
2247
+ for (; ; ) {
2248
+ const vFirstChild = vnode_getFirstChild(vCursor);
2249
+ if (vFirstChild) {
2250
+ vCursor = vFirstChild;
2251
+ continue;
2252
+ }
2253
+ if (vCursor === vNode) {
2254
+ return;
2255
+ }
2256
+ const vNextSibling = vnode_getNextSibling(vCursor);
2257
+ if (vNextSibling) {
2258
+ vCursor = vNextSibling;
2259
+ } else {
2260
+ for (vParent = vnode_getParent(vCursor); vParent; ) {
2261
+ if (vParent === vNode) {
2262
+ return;
2263
+ }
2264
+ const vNextParentSibling = vnode_getNextSibling(vParent);
2265
+ if (vNextParentSibling) {
2266
+ vCursor = vNextParentSibling;
2267
+ break;
2268
+ }
2269
+ vParent = vnode_getParent(vParent);
2270
+ }
2271
+ if (null == vParent) {
2272
+ return;
2273
+ }
2274
+ }
2275
+ }
2276
+ }
2277
+ function vnode_getDOMChildNodes(journal, root, isVNode = false, childNodes = []) {
2278
+ if (vnode_isElementOrTextVNode(root)) {
2279
+ return vnode_isTextVNode(root) && vnode_ensureTextInflated(journal, root), childNodes.push(isVNode ? root : vnode_getNode(root)), childNodes;
2280
+ }
2281
+ let vNode = vnode_getFirstChild(root);
2282
+ for (; vNode; ) {
2283
+ vnode_isElementVNode(vNode) ? childNodes.push(isVNode ? vNode : vnode_getNode(vNode)) : vnode_isTextVNode(vNode) ? (vnode_ensureTextInflated(journal, vNode), childNodes.push(isVNode ? vNode : vnode_getNode(vNode))) : vnode_getDOMChildNodes(journal, vNode, !!isVNode, childNodes), vNode = vnode_getNextSibling(vNode);
2284
+ }
2285
+ return childNodes;
2286
+ }
2287
+ const vnode_getDomSibling = (vNode, nextDirection, descend) => {
2288
+ const childProp = nextDirection ? VirtualVNodeProps.firstChild : VirtualVNodeProps.lastChild;
2289
+ const siblingProp = nextDirection ? VNodeProps.nextSibling : VNodeProps.previousSibling;
2290
+ let cursor = vNode;
2291
+ for (; descend && cursor && vnode_isVirtualVNode(cursor); ) {
2292
+ const child = cursor[childProp];
2293
+ if (!child) {
2294
+ break;
2295
+ }
2296
+ if (child[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_TEXT_MASK) {
2297
+ return child;
2298
+ }
2299
+ cursor = child;
2300
+ }
2301
+ for (; cursor; ) {
2302
+ let sibling = cursor[siblingProp];
2303
+ if (sibling && sibling[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_TEXT_MASK) {
2304
+ return sibling;
2305
+ }
2306
+ if (!sibling) {
2307
+ let virtual = cursor[VNodeProps.parent];
2308
+ if (virtual && !vnode_isVirtualVNode(virtual)) {
2309
+ return null;
2310
+ }
2311
+ for (; virtual && !(sibling = virtual[siblingProp]); ) {
2312
+ if (virtual = virtual[VNodeProps.parent], virtual && !vnode_isVirtualVNode(virtual)) {
2313
+ return null;
2314
+ }
2315
+ }
2316
+ if (!sibling) {
2317
+ return null;
2318
+ }
2319
+ if (vnode_isTextVNode(sibling) && virtual && vnode_isElementVNode(virtual)) {
2320
+ return null;
2321
+ }
2322
+ }
2323
+ for (; sibling; ) {
2324
+ if (cursor = sibling, cursor[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_TEXT_MASK && vnode_getNode(cursor)) {
2325
+ return cursor;
2326
+ }
2327
+ sibling = cursor[childProp];
2328
+ }
2329
+ }
2330
+ return null;
2331
+ };
2332
+ const vnode_ensureInflatedIfText = (journal, vNode) => {
2333
+ vnode_isTextVNode(vNode) && vnode_ensureTextInflated(journal, vNode);
2334
+ };
2335
+ const vnode_ensureTextInflated = (journal, vnode) => {
2336
+ const textVNode = ensureTextVNode(vnode);
2337
+ if (!(textVNode[VNodeProps.flags] & VNodeFlags.Inflated)) {
2338
+ const parentNode = vnode_getDomParent(vnode);
2339
+ const sharedTextNode = textVNode[TextVNodeProps.node];
2340
+ const doc = parentNode.ownerDocument;
2341
+ let cursor = vnode_getDomSibling(vnode, false, true);
2342
+ const insertBeforeNode = sharedTextNode || vnode_getDomSibling(vnode, true, true)?.[ElementVNodeProps.element] || null;
2343
+ let lastPreviousTextNode = insertBeforeNode;
2344
+ for (; cursor && vnode_isTextVNode(cursor); ) {
2345
+ if (!(cursor[VNodeProps.flags] & VNodeFlags.Inflated)) {
2346
+ const textNode = doc.createTextNode(cursor[TextVNodeProps.text]);
2347
+ journal.push(VNodeJournalOpCode.Insert, parentNode, lastPreviousTextNode, textNode), lastPreviousTextNode = textNode, cursor[TextVNodeProps.node] = textNode, cursor[VNodeProps.flags] |= VNodeFlags.Inflated;
2348
+ }
2349
+ cursor = vnode_getDomSibling(cursor, false, true);
2350
+ }
2351
+ for (cursor = vnode; cursor && vnode_isTextVNode(cursor); ) {
2352
+ const next = vnode_getDomSibling(cursor, true, true);
2353
+ const isLastNode = !next || !vnode_isTextVNode(next);
2354
+ if (!(cursor[VNodeProps.flags] & VNodeFlags.Inflated)) {
2355
+ if (isLastNode && sharedTextNode) {
2356
+ journal.push(VNodeJournalOpCode.SetText, sharedTextNode, cursor[TextVNodeProps.text]);
2357
+ } else {
2358
+ const textNode = doc.createTextNode(cursor[TextVNodeProps.text]);
2359
+ journal.push(VNodeJournalOpCode.Insert, parentNode, insertBeforeNode, textNode), cursor[TextVNodeProps.node] = textNode;
2360
+ }
2361
+ cursor[VNodeProps.flags] |= VNodeFlags.Inflated;
2362
+ }
2363
+ cursor = next;
2364
+ }
2365
+ }
2366
+ };
2367
+ const vnode_locate = (rootVNode, id) => {
2368
+ ensureElementVNode(rootVNode);
2369
+ let vNode = rootVNode;
2370
+ const containerElement = rootVNode[ElementVNodeProps.element];
2371
+ const { qVNodeRefs } = containerElement;
2372
+ let elementOffset = -1;
2373
+ let refElement;
2374
+ if ("string" == typeof id ? (elementOffset = parseInt(id), refElement = qVNodeRefs.get(elementOffset)) : refElement = id, vnode_isVNode(refElement)) {
2375
+ vNode = refElement;
2376
+ } else {
2377
+ assertTrue(containerElement.contains(refElement));
2378
+ let parent = refElement;
2379
+ const elementPath = [refElement];
2380
+ for (; parent && parent !== containerElement; ) {
2381
+ parent = parent.parentElement, elementPath.push(parent);
2382
+ }
2383
+ for (let i = elementPath.length - 2; i >= 0; i--) {
2384
+ vNode = vnode_getVNodeForChildNode(vNode, elementPath[i]);
2385
+ }
2386
+ -1 != elementOffset && qVNodeRefs.set(elementOffset, vNode);
2387
+ }
2388
+ if ("string" == typeof id) {
2389
+ const idLength = id.length;
2390
+ let idx = indexOfAlphanumeric(id, idLength);
2391
+ let childIdx = 0;
2392
+ for (; idx < idLength; ) {
2393
+ const ch = id.charCodeAt(idx);
2394
+ childIdx *= 26, ch >= 97 ? childIdx += ch - 97 : (childIdx += ch - 65, vNode = vnode_getChildWithIdx(vNode, childIdx), childIdx = 0), idx++;
2395
+ }
2396
+ }
2397
+ return vNode;
2398
+ };
2399
+ const vnode_getChildWithIdx = (vNode, childIdx) => {
2400
+ let child = vnode_getFirstChild(vNode);
2401
+ for (assertDefined(); child[VNodeProps.flags] >>> VNodeFlagsIndex.shift !== childIdx; ) {
2402
+ child = vnode_getNextSibling(child);
2403
+ }
2404
+ return child;
2405
+ };
2406
+ const vNodeStack = [];
2407
+ const vnode_getVNodeForChildNode = (vNode, childElement) => {
2408
+ ensureElementVNode(vNode);
2409
+ let child = vnode_getFirstChild(vNode);
2410
+ for (assertDefined(); child && child[ElementVNodeProps.element] !== childElement; ) {
2411
+ if (vnode_isVirtualVNode(child)) {
2412
+ const next = vnode_getNextSibling(child);
2413
+ const firstChild = vnode_getFirstChild(child);
2414
+ firstChild ? (next && vNodeStack.push(next), child = firstChild) : child = next || (vNodeStack.length ? vNodeStack.pop() : null);
2415
+ } else {
2416
+ const next = vnode_getNextSibling(child);
2417
+ child = next || (next || vNodeStack.pop());
2418
+ }
2419
+ }
2420
+ for (; vNodeStack.length; ) {
2421
+ vNodeStack.pop();
2422
+ }
2423
+ return ensureElementVNode(child), assertEqual(child[ElementVNodeProps.element]), child;
2424
+ };
2425
+ const indexOfAlphanumeric = (id, length) => {
2426
+ let idx = 0;
2427
+ for (; idx < length; ) {
2428
+ if (!(id.charCodeAt(idx) <= 57)) {
2429
+ return idx;
2430
+ }
2431
+ idx++;
2432
+ }
2433
+ return length;
2434
+ };
2435
+ const parseBoolean = (value) => "false" !== value && Boolean(value);
2436
+ const isBooleanAttr = (element, key) => ("allowfullscreen" == key || "async" == key || "autofocus" == key || "autoplay" == key || "checked" == key || "controls" == key || "default" == key || "defer" == key || "disabled" == key || "formnovalidate" == key || "inert" == key || "ismap" == key || "itemscope" == key || "loop" == key || "multiple" == key || "muted" == key || "nomodule" == key || "novalidate" == key || "open" == key || "playsinline" == key || "readonly" == key || "required" == key || "reversed" == key || "selected" == key) && key in element;
2437
+ const vnode_applyJournal = (journal) => {
2438
+ let idx = 0;
2439
+ const length = journal.length;
2440
+ for (; idx < length; ) {
2441
+ switch (journal[idx++]) {
2442
+ case VNodeJournalOpCode.SetText:
2443
+ journal[idx++].nodeValue = journal[idx++];
2444
+ break;
2445
+ case VNodeJournalOpCode.SetAttribute:
2446
+ const element = journal[idx++];
2447
+ let key = journal[idx++];
2448
+ "className" === key && (key = "class");
2449
+ const value = journal[idx++];
2450
+ isBooleanAttr(element, key) ? element[key] = parseBoolean(value) : "value" === key && key in element ? element.value = escapeHTML(String(value)) : key === dangerouslySetInnerHTML ? element.innerHTML = value : null == value || false === value ? element.removeAttribute(key) : element.setAttribute(key, String(value));
2451
+ break;
2452
+ case VNodeJournalOpCode.HoistStyles:
2453
+ const document2 = journal[idx++];
2454
+ const head = document2.head;
2455
+ const styles = document2.querySelectorAll(QStylesAllSelector);
2456
+ for (let i = 0; i < styles.length; i++) {
2457
+ head.appendChild(styles[i]);
2458
+ }
2459
+ break;
2460
+ case VNodeJournalOpCode.Remove:
2461
+ const removeParent = journal[idx++];
2462
+ let nodeToRemove;
2463
+ for (; idx < length && "number" != typeof (nodeToRemove = journal[idx]); ) {
2464
+ removeParent.removeChild(nodeToRemove), idx++;
2465
+ }
2466
+ break;
2467
+ case VNodeJournalOpCode.Insert:
2468
+ const insertParent = journal[idx++];
2469
+ const insertBefore = journal[idx++];
2470
+ let newChild;
2471
+ for (; idx < length && "number" != typeof (newChild = journal[idx]); ) {
2472
+ insertParent.insertBefore(newChild, insertBefore), idx++;
2473
+ }
2474
+ }
2475
+ }
2476
+ journal.length = 0;
2477
+ };
2478
+ const vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
2479
+ ensureElementOrVirtualVNode(parent), vnode_isElementVNode(parent) && ensureMaterialized(parent), newChild === insertBefore && (insertBefore = null);
2480
+ let adjustedInsertBefore = null;
2481
+ null == insertBefore ? vnode_isVirtualVNode(parent) && (adjustedInsertBefore = vnode_getDomSibling(parent, true, false)) : adjustedInsertBefore = vnode_isVirtualVNode(insertBefore) ? vnode_getDomSibling(insertBefore, true, true) : insertBefore, adjustedInsertBefore && vnode_ensureInflatedIfText(journal, adjustedInsertBefore);
2482
+ const domParentVNode = vnode_getDomParentVNode(parent);
2483
+ const parentNode = domParentVNode && domParentVNode[ElementVNodeProps.element];
2484
+ if (parentNode) {
2485
+ const domChildren = vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild);
2486
+ domChildren.length && journal.push(VNodeJournalOpCode.Insert, parentNode, vnode_getNode(adjustedInsertBefore), ...domChildren);
2487
+ }
2488
+ const newChildCurrentParent = newChild[VNodeProps.parent];
2489
+ newChildCurrentParent && (newChild[VNodeProps.previousSibling] || newChild[VNodeProps.nextSibling] || vnode_isElementVNode(newChildCurrentParent) && newChildCurrentParent !== parent) && vnode_remove(journal, newChildCurrentParent, newChild, false);
2490
+ const vNext = insertBefore;
2491
+ const vPrevious = vNext ? vNext[VNodeProps.previousSibling] : parent[ElementVNodeProps.lastChild];
2492
+ vNext ? vNext[VNodeProps.previousSibling] = newChild : parent[ElementVNodeProps.lastChild] = newChild, vPrevious ? vPrevious[VNodeProps.nextSibling] = newChild : parent[ElementVNodeProps.firstChild] = newChild, newChild[VNodeProps.previousSibling] = vPrevious, newChild[VNodeProps.nextSibling] = vNext, newChild[VNodeProps.parent] = parent;
2493
+ };
2494
+ const vnode_getDomParent = (vnode) => (vnode = vnode_getDomParentVNode(vnode)) && vnode[ElementVNodeProps.element];
2495
+ const vnode_getDomParentVNode = (vnode) => {
2496
+ for (; vnode && !vnode_isElementVNode(vnode); ) {
2497
+ vnode = vnode[VNodeProps.parent];
2498
+ }
2499
+ return vnode;
2500
+ };
2501
+ const vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
2502
+ assertEqual(vParent, vnode_getParent(vToRemove)), vnode_isTextVNode(vToRemove) && vnode_ensureTextInflated(journal, vToRemove);
2503
+ const vPrevious = vToRemove[VNodeProps.previousSibling];
2504
+ const vNext = vToRemove[VNodeProps.nextSibling];
2505
+ if (vPrevious ? vPrevious[VNodeProps.nextSibling] = vNext : vParent[ElementVNodeProps.firstChild] = vNext, vNext ? vNext[VNodeProps.previousSibling] = vPrevious : vParent[ElementVNodeProps.lastChild] = vPrevious, vToRemove[VNodeProps.previousSibling] = null, vToRemove[VNodeProps.nextSibling] = null, removeDOM) {
2506
+ const domParent = vnode_getDomParent(vParent);
2507
+ if (vnode_getAttr(vParent, dangerouslySetInnerHTML)) {
2508
+ return;
2509
+ }
2510
+ const children = vnode_getDOMChildNodes(journal, vToRemove);
2511
+ domParent && children.length && journal.push(VNodeJournalOpCode.Remove, domParent, ...children);
2512
+ }
2513
+ };
2514
+ const vnode_truncate = (journal, vParent, vDelete) => {
2515
+ const parent = vnode_getDomParent(vParent);
2516
+ const children = vnode_getDOMChildNodes(journal, vDelete);
2517
+ parent && children.length && journal.push(VNodeJournalOpCode.Remove, parent, ...children);
2518
+ const vPrevious = vDelete[VNodeProps.previousSibling];
2519
+ vPrevious ? vPrevious[VNodeProps.nextSibling] = null : vParent[ElementVNodeProps.firstChild] = null, vParent[ElementVNodeProps.lastChild] = vPrevious;
2520
+ };
2521
+ const vnode_getElementName = (vnode) => {
2522
+ const elementVNode = ensureElementVNode(vnode);
2523
+ let elementName = elementVNode[ElementVNodeProps.elementName];
2524
+ if (void 0 === elementName) {
2525
+ const element = elementVNode[ElementVNodeProps.element];
2526
+ const nodeName = fastNodeName(element);
2527
+ elementName = elementVNode[ElementVNodeProps.elementName] = nodeName, elementVNode[VNodeProps.flags] |= vnode_getElementNamespaceFlags(element);
2528
+ }
2529
+ return elementName;
2530
+ };
2531
+ const vnode_getText = (vnode) => {
2532
+ const textVNode = ensureTextVNode(vnode);
2533
+ let text = textVNode[TextVNodeProps.text];
2534
+ return void 0 === text && (text = textVNode[TextVNodeProps.text] = textVNode[TextVNodeProps.node].nodeValue), text;
2535
+ };
2536
+ const vnode_setText = (journal, textVNode, text) => {
2537
+ vnode_ensureTextInflated(journal, textVNode);
2538
+ journal.push(VNodeJournalOpCode.SetText, textVNode[TextVNodeProps.node], textVNode[TextVNodeProps.text] = text);
2539
+ };
2540
+ const vnode_getFirstChild = (vnode) => {
2541
+ if (vnode_isTextVNode(vnode)) {
2542
+ return null;
2543
+ }
2544
+ let vFirstChild = vnode[ElementVNodeProps.firstChild];
2545
+ return void 0 === vFirstChild && (vFirstChild = ensureMaterialized(vnode)), vFirstChild;
2546
+ };
2547
+ const vnode_materialize = (vNode) => {
2548
+ const element = vNode[ElementVNodeProps.element];
2549
+ const firstChild = fastFirstChild(element);
2550
+ const vNodeData = element.ownerDocument?.qVNodeData?.get(element);
2551
+ return materialize(vNode, element, firstChild, vNodeData);
2552
+ };
2553
+ const materialize = (vNode, element, firstChild, vNodeData) => {
2554
+ if (vNodeData) {
2555
+ if (vNodeData.charCodeAt(0) === VNodeDataChar.SEPARATOR) {
2556
+ const elementVNodeDataStartIdx = 1;
2557
+ let elementVNodeDataEndIdx = 1;
2558
+ for (; vNodeData.charCodeAt(elementVNodeDataEndIdx) !== VNodeDataChar.SEPARATOR; ) {
2559
+ elementVNodeDataEndIdx++;
2560
+ }
2561
+ const elementVNodeData = vNodeData.substring(elementVNodeDataStartIdx, elementVNodeDataEndIdx);
2562
+ vNodeData = vNodeData.substring(elementVNodeDataEndIdx + 1);
2563
+ const vFirstChild = materializeFromDOM(vNode, firstChild, elementVNodeData);
2564
+ if (!vNodeData) {
2565
+ return vFirstChild;
2566
+ }
2567
+ }
2568
+ return materializeFromVNodeData(vNode, vNodeData, element, firstChild);
2569
+ }
2570
+ return materializeFromDOM(vNode, firstChild);
2571
+ };
2572
+ const ensureMaterialized = (vnode) => {
2573
+ const vParent = ensureElementVNode(vnode);
2574
+ let vFirstChild = vParent[ElementVNodeProps.firstChild];
2575
+ if (void 0 === vFirstChild) {
2576
+ vFirstChild = vParent[VNodeProps.parent] && shouldIgnoreChildren(vParent[ElementVNodeProps.element]) ? vParent[ElementVNodeProps.firstChild] = vParent[ElementVNodeProps.lastChild] = null : vnode_materialize(vParent);
2577
+ }
2578
+ return assertTrue(void 0 !== vParent[ElementVNodeProps.firstChild]), assertTrue(void 0 !== vParent[ElementVNodeProps.lastChild]), vFirstChild;
2579
+ };
2580
+ let _fastHasAttribute = null;
2581
+ const shouldIgnoreChildren = (node) => (_fastHasAttribute || (_fastHasAttribute = node.hasAttribute), _fastHasAttribute.call(node, "q:container"));
2582
+ let _fastNodeType = null;
2583
+ const fastNodeType = (node) => (_fastNodeType || (_fastNodeType = fastGetter(node, "nodeType")), _fastNodeType.call(node));
2584
+ const fastIsTextOrElement = (node) => {
2585
+ const type = fastNodeType(node);
2586
+ return 3 === type || 1 === type;
2587
+ };
2588
+ let _fastNextSibling = null;
2589
+ const fastNextSibling = (node) => {
2590
+ for (_fastNextSibling || (_fastNextSibling = fastGetter(node, "nextSibling")), _fastFirstChild || (_fastFirstChild = fastGetter(node, "firstChild")); node; ) {
2591
+ if (null !== (node = _fastNextSibling.call(node))) {
2592
+ const type = fastNodeType(node);
2593
+ if (3 === type || 1 === type) {
2594
+ break;
2595
+ }
2596
+ if (8 === type) {
2597
+ const nodeValue = node.nodeValue;
2598
+ if (nodeValue?.startsWith(QIgnore)) {
2599
+ return getNodeAfterCommentNode(node, QContainerIsland, _fastNextSibling, _fastFirstChild);
2600
+ }
2601
+ if (node.nodeValue?.startsWith(QContainerIslandEnd)) {
2602
+ return getNodeAfterCommentNode(node, QIgnoreEnd, _fastNextSibling, _fastFirstChild);
2603
+ }
2604
+ if (nodeValue?.startsWith("q:container")) {
2605
+ for (; node && (node = _fastNextSibling.call(node)) && (8 !== fastNodeType(node) || !node.nodeValue?.startsWith("/q:container")); ) {
2606
+ }
2607
+ }
2608
+ }
2609
+ }
2610
+ }
2611
+ return node;
2612
+ };
2613
+ function getNodeAfterCommentNode(node, commentValue, nextSibling, firstChild) {
2614
+ for (; node; ) {
2615
+ if (node.nodeValue?.startsWith(commentValue)) {
2616
+ return node = nextSibling.call(node) || null;
2617
+ }
2618
+ let nextNode = firstChild.call(node);
2619
+ nextNode || (nextNode = nextSibling.call(node)), nextNode || (nextNode = fastParentNode(node), nextNode && (nextNode = nextSibling.call(nextNode))), node = nextNode;
2620
+ }
2621
+ return null;
2622
+ }
2623
+ let _fastParentNode = null;
2624
+ const fastParentNode = (node) => (_fastParentNode || (_fastParentNode = fastGetter(node, "parentNode")), _fastParentNode.call(node));
2625
+ let _fastFirstChild = null;
2626
+ const fastFirstChild = (node) => {
2627
+ for (_fastFirstChild || (_fastFirstChild = fastGetter(node, "firstChild")), node = node && _fastFirstChild.call(node); node && !fastIsTextOrElement(node); ) {
2628
+ node = fastNextSibling(node);
2629
+ }
2630
+ return node;
2631
+ };
2632
+ let _fastNamespaceURI = null;
2633
+ const fastNamespaceURI = (element) => (_fastNamespaceURI || (_fastNamespaceURI = fastGetter(element, "namespaceURI")), _fastNamespaceURI.call(element));
2634
+ let _fastNodeName = null;
2635
+ const fastNodeName = (element) => (_fastNodeName || (_fastNodeName = fastGetter(element, "nodeName")), _fastNodeName.call(element));
2636
+ const fastGetter = (prototype, name) => {
2637
+ let getter;
2638
+ for (; prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get); ) {
2639
+ prototype = Object.getPrototypeOf(prototype);
2640
+ }
2641
+ return getter || function() {
2642
+ return this[name];
2643
+ };
2644
+ };
2645
+ const isQStyleElement = (node) => isElement(node) && "STYLE" === node.nodeName && (node.hasAttribute("q:sstyle") || node.hasAttribute(QStyle));
2646
+ const materializeFromDOM = (vParent, firstChild, vData) => {
2647
+ let vFirstChild = null;
2648
+ const skipStyleElements = () => {
2649
+ for (; isQStyleElement(child); ) {
2650
+ child = fastNextSibling(child);
2651
+ }
2652
+ };
2653
+ let child = firstChild;
2654
+ skipStyleElements();
2655
+ let vChild = null;
2656
+ for (; child; ) {
2657
+ const nodeType = fastNodeType(child);
2658
+ let vNextChild = null;
2659
+ 3 === nodeType ? vNextChild = vnode_newText(child, child.textContent ?? void 0) : 1 === nodeType && (vNextChild = vnode_newUnMaterializedElement(child)), vNextChild && (vNextChild[VNodeProps.parent] = vParent, vChild && (vChild[VNodeProps.nextSibling] = vNextChild), vNextChild[VNodeProps.previousSibling] = vChild, vChild = vNextChild), vFirstChild || (vParent[ElementVNodeProps.firstChild] = vFirstChild = vChild), child = fastNextSibling(child), skipStyleElements();
2660
+ }
2661
+ if (vParent[ElementVNodeProps.lastChild] = vChild || null, vParent[ElementVNodeProps.firstChild] = vFirstChild, vData) {
2662
+ let container = null;
2663
+ processVNodeData$1(vData, (peek, consumeValue) => {
2664
+ if (peek() === VNodeDataChar.ID) {
2665
+ container || (container = getDomContainer(vParent[ElementVNodeProps.element]));
2666
+ const id = consumeValue();
2667
+ container.$setRawState$(parseInt(id), vParent);
2668
+ } else {
2669
+ peek() === VNodeDataChar.BACK_REFS ? (container || (container = getDomContainer(vParent[ElementVNodeProps.element])), setEffectBackRefFromVNodeData(vParent, consumeValue(), container)) : consumeValue();
2670
+ }
2671
+ });
2672
+ }
2673
+ return vFirstChild;
2674
+ };
2675
+ function setEffectBackRefFromVNodeData(vParent, value, container) {
2676
+ const deserializedSubMap = container.$getObjectById$(value);
2677
+ if (vParent[_EFFECT_BACK_REF]) {
2678
+ mergeMaps(vParent[_EFFECT_BACK_REF], deserializedSubMap);
2679
+ } else {
2680
+ Object.defineProperty(vParent, _EFFECT_BACK_REF, {
2681
+ value: deserializedSubMap
2682
+ });
2683
+ }
2684
+ }
2685
+ const processVNodeData$1 = (vData, callback) => {
2686
+ let nextToConsumeIdx = 0;
2687
+ let ch = 0;
2688
+ let peekCh = 0;
2689
+ const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
2690
+ const consume = () => (ch = peek(), peekCh = 0, nextToConsumeIdx++, ch);
2691
+ const consumeValue = () => {
2692
+ consume();
2693
+ const start = nextToConsumeIdx;
2694
+ for (; peek() <= 58 && 0 !== peekCh || 95 === peekCh || peekCh >= 65 && peekCh <= 90 || peekCh >= 97 && peekCh <= 122; ) {
2695
+ consume();
2696
+ }
2697
+ return vData.substring(start, nextToConsumeIdx);
2698
+ };
2699
+ for (; 0 !== peek(); ) {
2700
+ callback(peek, consumeValue, consume, nextToConsumeIdx);
2701
+ }
2702
+ };
2703
+ const vnode_getNextSibling = (vnode) => vnode[VNodeProps.nextSibling];
2704
+ const vnode_getPreviousSibling = (vnode) => vnode[VNodeProps.previousSibling];
2705
+ const vnode_setAttr = (journal, vnode, key, value) => {
2706
+ const type = vnode[VNodeProps.flags];
2707
+ if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
2708
+ vnode_ensureElementInflated(vnode);
2709
+ const props = vnode_getProps(vnode);
2710
+ const idx = mapApp_findIndx(props, key, 0);
2711
+ if (idx >= 0) {
2712
+ if (props[idx + 1] != value && type & VNodeFlags.Element) {
2713
+ journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
529
2714
  }
2715
+ null == value ? props.splice(idx, 2) : props[idx + 1] = value;
2716
+ } else if (null != value && (props.splice(~idx, 0, key, value), type & VNodeFlags.Element)) {
2717
+ journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
530
2718
  }
531
2719
  }
532
2720
  };
533
- const mapApp_findIndx = (elementVNode, key, start) => {
534
- let bottom = start >> 1;
535
- let top = elementVNode.length - 2 >> 1;
536
- for (; bottom <= top; ) {
537
- const mid = bottom + (top - bottom >> 1);
538
- const midKey = elementVNode[mid << 1];
539
- if (midKey === key) {
540
- return mid << 1;
541
- }
542
- midKey < key ? bottom = mid + 1 : top = mid - 1;
2721
+ const vnode_getAttr = (vnode, key) => {
2722
+ if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
2723
+ vnode_ensureElementInflated(vnode);
2724
+ const props = vnode_getProps(vnode);
2725
+ return mapArray_get(props, key, 0);
543
2726
  }
544
- return ~(bottom << 1);
545
- };
546
- const mapArray_set = (elementVNode, key, value, start) => {
547
- const indx = mapApp_findIndx(elementVNode, key, start);
548
- indx >= 0 ? null == value ? elementVNode.splice(indx, 2) : elementVNode[indx + 1] = value : null != value && elementVNode.splice(~indx, 0, key, value);
2727
+ return null;
549
2728
  };
550
2729
  const vnode_getProp = (vnode, key, getObject) => {
551
2730
  const type = vnode[VNodeProps.flags];
552
2731
  if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
553
2732
  type & VNodeFlags.Element && vnode_ensureElementInflated(vnode);
554
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
2733
+ const props = vnode_getProps(vnode);
2734
+ const idx = mapApp_findIndx(props, key, 0);
555
2735
  if (idx >= 0) {
556
- let value = vnode[idx + 1];
557
- return "string" == typeof value && getObject && (vnode[idx + 1] = value = getObject(value)), value;
2736
+ let value = props[idx + 1];
2737
+ return "string" == typeof value && getObject && (props[idx + 1] = value = getObject(value)), value;
558
2738
  }
559
2739
  }
560
2740
  return null;
561
2741
  };
562
2742
  const vnode_setProp = (vnode, key, value) => {
563
2743
  ensureElementOrVirtualVNode(vnode);
564
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
565
- idx >= 0 ? vnode[idx + 1] = value : null != value && vnode.splice(~idx, 0, key, value);
2744
+ const props = vnode_getProps(vnode);
2745
+ const idx = mapApp_findIndx(props, key, 0);
2746
+ idx >= 0 ? props[idx + 1] = value : null != value && props.splice(~idx, 0, key, value);
566
2747
  };
567
2748
  const vnode_getPropStartIndex = (vnode) => {
568
2749
  const type = vnode[VNodeProps.flags] & VNodeFlags.TYPE_MASK;
@@ -574,21 +2755,124 @@ const vnode_getPropStartIndex = (vnode) => {
574
2755
  }
575
2756
  throw qError(QError.invalidVNodeType, [type]);
576
2757
  };
2758
+ const vnode_getProps = (vnode) => vnode[vnode_getPropStartIndex(vnode)];
2759
+ const vnode_getParent = (vnode) => vnode[VNodeProps.parent] || null;
2760
+ const vnode_getNode = (vnode) => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode)), vnode[TextVNodeProps.node]);
2761
+ const isNumber = (ch) => 48 <= ch && ch <= 57;
2762
+ const isLowercase = (ch) => 97 <= ch && ch <= 122;
2763
+ const stack = [];
2764
+ function materializeFromVNodeData(vParent, vData, element, child) {
2765
+ let idx = 0;
2766
+ let vFirst = null;
2767
+ let vLast = null;
2768
+ let previousTextNode = null;
2769
+ const addVNode = (node) => {
2770
+ node[VNodeProps.flags] = node[VNodeProps.flags] & VNodeFlagsIndex.negated_mask | idx << VNodeFlagsIndex.shift, idx++, vLast && (vLast[VNodeProps.nextSibling] = node), node[VNodeProps.previousSibling] = vLast, node[VNodeProps.parent] = vParent, vFirst || (vParent[ElementVNodeProps.firstChild] = vFirst = node), vLast = node;
2771
+ };
2772
+ let textIdx = 0;
2773
+ let combinedText = null;
2774
+ let container = null;
2775
+ return processVNodeData$1(vData, (peek, consumeValue, consume, nextToConsumeIdx) => {
2776
+ if (isNumber(peek())) {
2777
+ for (; !isElement(child); ) {
2778
+ if (!(child = fastNextSibling(child))) {
2779
+ throw qError(QError.materializeVNodeDataError, [vData, peek(), nextToConsumeIdx]);
2780
+ }
2781
+ }
2782
+ for (; isQStyleElement(child); ) {
2783
+ child = fastNextSibling(child);
2784
+ }
2785
+ combinedText = null, previousTextNode = null;
2786
+ let value = 0;
2787
+ for (; isNumber(peek()); ) {
2788
+ value *= 10, value += consume() - 48;
2789
+ }
2790
+ for (; value--; ) {
2791
+ addVNode(vnode_newUnMaterializedElement(child)), child = fastNextSibling(child);
2792
+ }
2793
+ } else if (peek() === VNodeDataChar.SCOPED_STYLE) {
2794
+ vnode_setAttr(null, vParent, "q:sstyle", consumeValue());
2795
+ } else if (peek() === VNodeDataChar.RENDER_FN) {
2796
+ vnode_setAttr(null, vParent, "q:renderFn", consumeValue());
2797
+ } else if (peek() === VNodeDataChar.ID) {
2798
+ container || (container = getDomContainer(element));
2799
+ const id = consumeValue();
2800
+ container.$setRawState$(parseInt(id), vParent);
2801
+ } else if (peek() === VNodeDataChar.PROPS) {
2802
+ vnode_setAttr(null, vParent, "q:props", consumeValue());
2803
+ } else if (peek() === VNodeDataChar.SLOT_REF) {
2804
+ vnode_setAttr(null, vParent, "q:sref", consumeValue());
2805
+ } else if (peek() === VNodeDataChar.KEY) {
2806
+ vnode_setAttr(null, vParent, "q:key", consumeValue());
2807
+ } else if (peek() === VNodeDataChar.SEQ) {
2808
+ vnode_setAttr(null, vParent, "q:seq", consumeValue());
2809
+ } else if (peek() === VNodeDataChar.SEQ_IDX) {
2810
+ vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
2811
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
2812
+ container || (container = getDomContainer(element)), setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
2813
+ } else if (peek() === VNodeDataChar.CONTEXT) {
2814
+ vnode_setAttr(null, vParent, "q:ctx", consumeValue());
2815
+ } else if (peek() === VNodeDataChar.OPEN) {
2816
+ consume(), addVNode(vnode_newVirtual()), stack.push(vParent, vFirst, vLast, previousTextNode, idx), idx = 0, vParent = vLast, vFirst = vLast = null;
2817
+ } else if (peek() === VNodeDataChar.SEPARATOR) {
2818
+ const key = consumeValue();
2819
+ const value = consumeValue();
2820
+ vnode_setAttr(null, vParent, key, value);
2821
+ } else if (peek() === VNodeDataChar.CLOSE) {
2822
+ consume(), vParent[ElementVNodeProps.lastChild] = vLast, idx = stack.pop(), previousTextNode = stack.pop(), vLast = stack.pop(), vFirst = stack.pop(), vParent = stack.pop();
2823
+ } else if (peek() === VNodeDataChar.SLOT) {
2824
+ vnode_setAttr(null, vParent, QSlot, consumeValue());
2825
+ } else {
2826
+ const textNode = child && 3 === fastNodeType(child) ? child : null;
2827
+ null === combinedText && (combinedText = textNode ? textNode.nodeValue : null, textIdx = 0);
2828
+ let length = 0;
2829
+ for (; isLowercase(peek()); ) {
2830
+ length += consume() - 97, length *= 26;
2831
+ }
2832
+ length += consume() - 65;
2833
+ const text = null === combinedText ? "" : combinedText.substring(textIdx, textIdx + length);
2834
+ addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text)), textIdx += length;
2835
+ }
2836
+ }), vParent[ElementVNodeProps.lastChild] = vLast, vFirst;
2837
+ }
2838
+ const vnode_getType = (vnode) => {
2839
+ const type = vnode[VNodeProps.flags];
2840
+ if (type & VNodeFlags.Element) {
2841
+ return 1;
2842
+ }
2843
+ if (type & VNodeFlags.Virtual) {
2844
+ return 11;
2845
+ }
2846
+ if (type & VNodeFlags.Text) {
2847
+ return 3;
2848
+ }
2849
+ throw qError(QError.invalidVNodeType, [type]);
2850
+ };
2851
+ const isElement = (node) => node && "object" == typeof node && 1 === fastNodeType(node);
2852
+ const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
2853
+ let projectionDepth = 1;
2854
+ for (; projectionDepth--; ) {
2855
+ for (; vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
2856
+ const qSlotParent = vnode_getProp(vHost, ":", (id) => vnode_locate(rootVNode, id));
2857
+ const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
2858
+ vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
2859
+ }
2860
+ projectionDepth > 0 && (vHost = vnode_getParent(vHost));
2861
+ }
2862
+ return vHost;
2863
+ };
577
2864
  const VNodeArray = class VNode extends Array {
578
2865
  static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
579
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
580
- return vnode.push(firstChild, lastChild, element, elementName), vnode;
2866
+ return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName, []);
581
2867
  }
582
2868
  static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
583
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
584
- return vnode.push(textNode, text), vnode;
2869
+ return new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
585
2870
  }
586
2871
  static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
587
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
588
- return vnode.push(firstChild, lastChild), vnode;
2872
+ return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, []);
589
2873
  }
590
- constructor(flags, parent, previousSibling, nextSibling) {
591
- super(), this.push(flags, parent, previousSibling, nextSibling);
2874
+ constructor(flags, parent, previousSibling, nextSibling, ...rest) {
2875
+ super(flags, parent, previousSibling, nextSibling, ...rest);
592
2876
  }
593
2877
  };
594
2878
  let _context;
@@ -616,9 +2900,11 @@ function invokeApply(context, fn, args) {
616
2900
  return returnValue;
617
2901
  }
618
2902
  const newInvokeContextFromTuple = ([element, event, url]) => {
619
- const container = element.closest(QContainerSelector);
2903
+ const domContainer = getDomContainer(element);
2904
+ const container = domContainer.element;
2905
+ const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
620
2906
  const locale = container?.getAttribute("q:locale") || void 0;
621
- return newInvokeContext(locale, void 0, element, event, url);
2907
+ return newInvokeContext(locale, vNode, element, event, url);
622
2908
  };
623
2909
  const newInvokeContext = (locale, hostElement, element, event, url) => {
624
2910
  const ctx = {
@@ -640,18 +2926,1230 @@ const trackSignal = (fn, subscriber, property, container, data) => {
640
2926
  const previousSubscriber = trackInvocation.$effectSubscriber$;
641
2927
  const previousContainer = trackInvocation.$container$;
642
2928
  try {
643
- return trackInvocation.$effectSubscriber$ = [subscriber, property], data && trackInvocation.$effectSubscriber$.push(data), trackInvocation.$container$ = container, invoke(trackInvocation, fn);
2929
+ return trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data), trackInvocation.$container$ = container, invoke(trackInvocation, fn);
644
2930
  } finally {
645
2931
  trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
646
2932
  }
647
2933
  };
2934
+ const trackSignalAndAssignHost = (value, host, property, container, data) => (value instanceof WrappedSignal && value.$hostElement$ !== host && host && (value.$hostElement$ = host), trackSignal(() => value.value, host, property, container, data));
2935
+ const createContextId = (name) => /* @__PURE__ */ Object.freeze({
2936
+ id: fromCamelToKebabCase(name)
2937
+ });
2938
+ const ERROR_CONTEXT = /* @__PURE__ */ createContextId("qk-error");
2939
+ function processVNodeData(document2) {
2940
+ const vNodeDataMap = document2.qVNodeData || (document2.qVNodeData = /* @__PURE__ */ new WeakMap());
2941
+ const prototype = document2.body;
2942
+ const getAttribute = prototype.getAttribute;
2943
+ const hasAttribute = prototype.hasAttribute;
2944
+ const getNodeType = ((prototype2, name) => {
2945
+ let getter;
2946
+ for (; prototype2 && !(getter = Object.getOwnPropertyDescriptor(prototype2, name)?.get); ) {
2947
+ prototype2 = Object.getPrototypeOf(prototype2);
2948
+ }
2949
+ return getter || function() {
2950
+ return this[name];
2951
+ };
2952
+ })(prototype, "nodeType");
2953
+ const attachVnodeDataAndRefs = (element) => {
2954
+ Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script) => {
2955
+ script.setAttribute("type", "x-qwik/vnode");
2956
+ const qContainerElement = script.closest("[q\\:container]");
2957
+ qContainerElement.qVnodeData = script.textContent, qContainerElement.qVNodeRefs = /* @__PURE__ */ new Map();
2958
+ }), element.querySelectorAll("[q\\:shadowroot]").forEach((parent) => {
2959
+ const shadowRoot = parent.shadowRoot;
2960
+ shadowRoot && attachVnodeDataAndRefs(shadowRoot);
2961
+ });
2962
+ };
2963
+ let NodeType;
2964
+ attachVnodeDataAndRefs(document2), function(NodeType2) {
2965
+ NodeType2[NodeType2.CONTAINER_MASK = 1] = "CONTAINER_MASK", NodeType2[NodeType2.ELEMENT = 2] = "ELEMENT", NodeType2[NodeType2.ELEMENT_CONTAINER = 3] = "ELEMENT_CONTAINER", NodeType2[NodeType2.ELEMENT_SHADOW_ROOT = 6] = "ELEMENT_SHADOW_ROOT", NodeType2[NodeType2.COMMENT_SKIP_START = 5] = "COMMENT_SKIP_START", NodeType2[NodeType2.COMMENT_SKIP_END = 8] = "COMMENT_SKIP_END", NodeType2[NodeType2.COMMENT_IGNORE_START = 16] = "COMMENT_IGNORE_START", NodeType2[NodeType2.COMMENT_IGNORE_END = 32] = "COMMENT_IGNORE_END", NodeType2[NodeType2.COMMENT_ISLAND_START = 65] = "COMMENT_ISLAND_START", NodeType2[NodeType2.COMMENT_ISLAND_END = 128] = "COMMENT_ISLAND_END", NodeType2[NodeType2.OTHER = 0] = "OTHER";
2966
+ }(NodeType || (NodeType = {}));
2967
+ const getFastNodeType = (node) => {
2968
+ const nodeType = getNodeType.call(node);
2969
+ if (1 === nodeType) {
2970
+ if (null === getAttribute.call(node, "q:container")) {
2971
+ if (hasAttribute.call(node, "q:shadowroot")) {
2972
+ return NodeType.ELEMENT_SHADOW_ROOT;
2973
+ }
2974
+ return hasAttribute.call(node, ":") ? NodeType.ELEMENT : NodeType.OTHER;
2975
+ }
2976
+ return NodeType.ELEMENT_CONTAINER;
2977
+ }
2978
+ if (8 === nodeType) {
2979
+ const nodeValue = node.nodeValue || "";
2980
+ if (nodeValue.startsWith("q:container-island")) {
2981
+ return NodeType.COMMENT_ISLAND_START;
2982
+ }
2983
+ if (nodeValue.startsWith("q:ignore")) {
2984
+ return NodeType.COMMENT_IGNORE_START;
2985
+ }
2986
+ if (nodeValue.startsWith("q:container")) {
2987
+ return NodeType.COMMENT_SKIP_START;
2988
+ }
2989
+ if (nodeValue.startsWith("/q:container-island")) {
2990
+ return NodeType.COMMENT_ISLAND_END;
2991
+ }
2992
+ if (nodeValue.startsWith("/q:ignore")) {
2993
+ return NodeType.COMMENT_IGNORE_END;
2994
+ }
2995
+ if (nodeValue.startsWith("/q:container")) {
2996
+ return NodeType.COMMENT_SKIP_END;
2997
+ }
2998
+ }
2999
+ return NodeType.OTHER;
3000
+ };
3001
+ const isSeparator = (ch) => VNodeDataSeparator.ADVANCE_1 <= ch && ch <= VNodeDataSeparator.ADVANCE_8192;
3002
+ const findVDataSectionEnd = (vData, start, end) => {
3003
+ let depth = 0;
3004
+ for (; start < end; ) {
3005
+ const ch = vData.charCodeAt(start);
3006
+ if (0 === depth && isSeparator(ch)) {
3007
+ break;
3008
+ }
3009
+ ch === VNodeDataChar.OPEN ? depth++ : ch === VNodeDataChar.CLOSE && depth--, start++;
3010
+ }
3011
+ return start;
3012
+ };
3013
+ const nextSibling = (node) => {
3014
+ for (; node && (node = node.nextSibling) && getFastNodeType(node) === NodeType.OTHER; ) {
3015
+ }
3016
+ return node;
3017
+ };
3018
+ const firstChild = (node) => {
3019
+ for (; node && (node = node.firstChild) && getFastNodeType(node) === NodeType.OTHER; ) {
3020
+ }
3021
+ return node;
3022
+ };
3023
+ const walkContainer = (walker2, containerNode, node, exitNode, vData, qVNodeRefs) => {
3024
+ const vData_length = vData.length;
3025
+ let elementIdx = 0;
3026
+ let vNodeElementIndex = -1;
3027
+ let vData_start = 0;
3028
+ let vData_end = 0;
3029
+ let ch = 0;
3030
+ let needsToStoreRef = -1;
3031
+ let nextNode = null;
3032
+ const howManyElementsToSkip = () => {
3033
+ let elementsToSkip = 0;
3034
+ for (; isSeparator(ch = vData.charCodeAt(vData_start)) && (elementsToSkip += 1 << ch - VNodeDataSeparator.ADVANCE_1, vData_start++, !(vData_start >= vData_length)); ) {
3035
+ }
3036
+ return elementsToSkip;
3037
+ };
3038
+ do {
3039
+ if (node === exitNode) {
3040
+ return;
3041
+ }
3042
+ nextNode = null;
3043
+ const nodeType = node == containerNode ? NodeType.ELEMENT : getFastNodeType(node);
3044
+ if (nodeType === NodeType.ELEMENT_CONTAINER) {
3045
+ const container = node;
3046
+ let cursor = node;
3047
+ for (; cursor && !(nextNode = nextSibling(cursor)); ) {
3048
+ cursor = cursor.parentNode;
3049
+ }
3050
+ walkContainer(walker2, container, node, nextNode, container.qVnodeData || "", container.qVNodeRefs);
3051
+ } else if (nodeType === NodeType.COMMENT_IGNORE_START) {
3052
+ let islandNode = node;
3053
+ do {
3054
+ if (islandNode = walker2.nextNode(), !islandNode) {
3055
+ throw new Error(`Island inside <!--${node?.nodeValue}--> not found!`);
3056
+ }
3057
+ } while (getFastNodeType(islandNode) !== NodeType.COMMENT_ISLAND_START);
3058
+ nextNode = null;
3059
+ } else if (nodeType === NodeType.COMMENT_ISLAND_END) {
3060
+ nextNode = node;
3061
+ do {
3062
+ if (nextNode = walker2.nextNode(), !nextNode) {
3063
+ throw new Error("Ignore block not closed!");
3064
+ }
3065
+ } while (getFastNodeType(nextNode) !== NodeType.COMMENT_IGNORE_END);
3066
+ nextNode = null;
3067
+ } else if (nodeType === NodeType.COMMENT_SKIP_START) {
3068
+ nextNode = node;
3069
+ do {
3070
+ if (nextNode = nextSibling(nextNode), !nextNode) {
3071
+ throw new Error(`<!--${node?.nodeValue}--> not closed!`);
3072
+ }
3073
+ } while (getFastNodeType(nextNode) !== NodeType.COMMENT_SKIP_END);
3074
+ walkContainer(walker2, node, node, nextNode, "", null);
3075
+ } else if (nodeType === NodeType.ELEMENT_SHADOW_ROOT) {
3076
+ nextNode = nextSibling(node);
3077
+ const shadowRootContainer = node;
3078
+ const shadowRoot = shadowRootContainer?.shadowRoot;
3079
+ shadowRoot && walkContainer(document2.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null);
3080
+ }
3081
+ if ((nodeType & NodeType.ELEMENT) === NodeType.ELEMENT) {
3082
+ if (vNodeElementIndex < elementIdx) {
3083
+ if (-1 === vNodeElementIndex && (vNodeElementIndex = 0), vData_start = vData_end, vData_start < vData_length) {
3084
+ vNodeElementIndex += howManyElementsToSkip();
3085
+ ch === VNodeDataSeparator.REFERENCE && (needsToStoreRef = vNodeElementIndex, vData_start++, ch = vData_start < vData_length ? vData.charCodeAt(vData_end) : VNodeDataSeparator.ADVANCE_1), vData_end = findVDataSectionEnd(vData, vData_start, vData_length);
3086
+ } else {
3087
+ vNodeElementIndex = Number.MAX_SAFE_INTEGER;
3088
+ }
3089
+ }
3090
+ if (elementIdx === vNodeElementIndex) {
3091
+ needsToStoreRef === elementIdx && qVNodeRefs.set(elementIdx, node);
3092
+ const instructions = vData.substring(vData_start, vData_end);
3093
+ vNodeDataMap.set(node, instructions);
3094
+ }
3095
+ elementIdx++;
3096
+ }
3097
+ } while (node = nextNode || walker2.nextNode());
3098
+ };
3099
+ const walker = document2.createTreeWalker(document2, 129);
3100
+ walkContainer(walker, null, walker.firstChild(), null, "", null);
3101
+ }
3102
+ function getDomContainer(element) {
3103
+ const qContainerElement = _getQContainerElement(element);
3104
+ if (!qContainerElement) {
3105
+ throw qError(QError.containerNotFound);
3106
+ }
3107
+ return getDomContainerFromQContainerElement(qContainerElement);
3108
+ }
3109
+ function getDomContainerFromQContainerElement(qContainerElement) {
3110
+ const qElement = qContainerElement;
3111
+ let container = qElement.qContainer;
3112
+ if (!container) {
3113
+ container = new DomContainer(qElement);
3114
+ const containerAttributes = {};
3115
+ if (qElement) {
3116
+ const attrs = qElement.attributes;
3117
+ if (attrs) {
3118
+ for (let index = 0; index < attrs.length; index++) {
3119
+ const attr = attrs[index];
3120
+ ":" !== attr.name && (containerAttributes[attr.name] = attr.value);
3121
+ }
3122
+ }
3123
+ }
3124
+ container.$serverData$ = {
3125
+ containerAttributes
3126
+ }, qElement.setAttribute("q:container", QContainerValue.RESUMED), qElement.qContainer = container;
3127
+ }
3128
+ return container;
3129
+ }
3130
+ function _getQContainerElement(element) {
3131
+ return (Array.isArray(element) ? vnode_getDomParent(element) : element).closest(QContainerSelector);
3132
+ }
3133
+ const isDomContainer = (container) => container instanceof DomContainer;
3134
+ class DomContainer extends _SharedContainer {
3135
+ constructor(element) {
3136
+ super(() => this.scheduleRender(), () => vnode_applyJournal(this.$journal$), {}, element.getAttribute("q:locale"));
3137
+ __publicField(this, "element");
3138
+ __publicField(this, "qContainer");
3139
+ __publicField(this, "qBase");
3140
+ __publicField(this, "qManifestHash");
3141
+ __publicField(this, "rootVNode");
3142
+ __publicField(this, "document");
3143
+ __publicField(this, "$journal$");
3144
+ __publicField(this, "renderDone", null);
3145
+ __publicField(this, "$rawStateData$");
3146
+ __publicField(this, "$storeProxyMap$", /* @__PURE__ */ new WeakMap());
3147
+ __publicField(this, "$qFuncs$");
3148
+ __publicField(this, "$instanceHash$");
3149
+ __publicField(this, "vNodeLocate", (id) => vnode_locate(this.rootVNode, id));
3150
+ __publicField(this, "$stateData$");
3151
+ __publicField(this, "$styleIds$", null);
3152
+ __publicField(this, "$renderCount$", 0);
3153
+ __publicField(this, "$getObjectById$", (id) => ("string" == typeof id && (id = parseFloat(id)), assertTrue(id < this.$rawStateData$.length / 2, `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`), this.$stateData$[id]));
3154
+ if (this.qContainer = element.getAttribute("q:container"), !this.qContainer) {
3155
+ throw qError(QError.elementWithoutContainer);
3156
+ }
3157
+ this.$journal$ = [VNodeJournalOpCode.HoistStyles, element.ownerDocument], this.document = element.ownerDocument, this.element = element, this.qBase = element.getAttribute("q:base"), this.$instanceHash$ = element.getAttribute("q:instance"), this.qManifestHash = element.getAttribute("q:manifest-hash"), this.rootVNode = vnode_newUnMaterializedElement(this.element), this.$rawStateData$ = null, this.$stateData$ = null;
3158
+ const document2 = this.element.ownerDocument;
3159
+ document2.qVNodeData || processVNodeData(document2), this.$rawStateData$ = [], this.$stateData$ = [];
3160
+ const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
3161
+ if (0 !== qwikStates.length) {
3162
+ this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent), this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
3163
+ }
3164
+ this.$qFuncs$ = getQFuncs(document2, this.$instanceHash$) || EMPTY_ARRAY;
3165
+ }
3166
+ $setRawState$(id, vParent) {
3167
+ this.$stateData$[id] = vParent;
3168
+ }
3169
+ parseQRL(qrl2) {
3170
+ return inflateQRL(this, parseQRL(qrl2));
3171
+ }
3172
+ handleError(err, host) {
3173
+ const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
3174
+ if (!errorStore) {
3175
+ throw err;
3176
+ }
3177
+ errorStore.error = err;
3178
+ }
3179
+ setContext(host, context, value) {
3180
+ let ctx = this.getHostProp(host, "q:ctx");
3181
+ ctx || this.setHostProp(host, "q:ctx", ctx = []), mapArray_set(ctx, context.id, value, 0);
3182
+ }
3183
+ resolveContext(host, contextId) {
3184
+ for (; host; ) {
3185
+ const ctx = this.getHostProp(host, "q:ctx");
3186
+ if (ctx) {
3187
+ const value = mapArray_get(ctx, contextId.id, 0);
3188
+ if (value) {
3189
+ return value;
3190
+ }
3191
+ }
3192
+ host = this.getParentHost(host);
3193
+ }
3194
+ }
3195
+ getParentHost(host) {
3196
+ let vNode = vnode_getParent(host);
3197
+ for (; vNode; ) {
3198
+ if (vnode_isVirtualVNode(vNode)) {
3199
+ if (null !== vnode_getProp(vNode, "q:renderFn", null)) {
3200
+ return vNode;
3201
+ }
3202
+ vNode = vnode_getParent(vNode) || vnode_getProp(vNode, ":", this.vNodeLocate);
3203
+ } else {
3204
+ vNode = vnode_getParent(vNode);
3205
+ }
3206
+ }
3207
+ return null;
3208
+ }
3209
+ setHostProp(host, name, value) {
3210
+ vnode_setProp(host, name, value);
3211
+ }
3212
+ getHostProp(host, name) {
3213
+ const vNode = host;
3214
+ let getObjectById2 = null;
3215
+ switch (name) {
3216
+ case "q:seq":
3217
+ case "q:props":
3218
+ case "q:renderFn":
3219
+ case "q:ctx":
3220
+ case "q:brefs":
3221
+ getObjectById2 = this.$getObjectById$;
3222
+ break;
3223
+ case "q:seqIdx":
3224
+ case ":onIdx":
3225
+ getObjectById2 = parseInt;
3226
+ }
3227
+ return vnode_getProp(vNode, name, getObjectById2);
3228
+ }
3229
+ scheduleRender() {
3230
+ return this.$renderCount$++, this.renderDone || (this.renderDone = getPlatform().nextTick(() => this.processChores())), this.renderDone.finally(() => emitEvent("qrender", {
3231
+ instanceHash: this.$instanceHash$,
3232
+ renderCount: this.$renderCount$
3233
+ }));
3234
+ }
3235
+ processChores() {
3236
+ let renderCount = this.$renderCount$;
3237
+ const result = this.$scheduler$(ChoreType.WAIT_FOR_ALL);
3238
+ if (isPromise(result)) {
3239
+ return result.then(async () => {
3240
+ for (; renderCount !== this.$renderCount$; ) {
3241
+ renderCount = this.$renderCount$, await this.$scheduler$(ChoreType.WAIT_FOR_ALL);
3242
+ }
3243
+ this.renderDone = null;
3244
+ });
3245
+ }
3246
+ renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
3247
+ }
3248
+ ensureProjectionResolved(vNode) {
3249
+ if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
3250
+ vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
3251
+ const props = vnode_getProps(vNode);
3252
+ for (let i = 0; i < props.length; i += 2) {
3253
+ if (isSlotProp(props[i])) {
3254
+ const value = props[i + 1];
3255
+ "string" == typeof value && (props[i + 1] = this.vNodeLocate(value));
3256
+ }
3257
+ }
3258
+ }
3259
+ }
3260
+ getSyncFn(id) {
3261
+ const fn = this.$qFuncs$[id];
3262
+ return fn;
3263
+ }
3264
+ $appendStyle$(content, styleId, host, scoped) {
3265
+ if (scoped) {
3266
+ const scopedStyleIdsString = this.getHostProp(host, "q:sstyle");
3267
+ const scopedStyleIds = new Set(convertScopedStyleIdsToArray(scopedStyleIdsString));
3268
+ scopedStyleIds.add(styleId), this.setHostProp(host, "q:sstyle", convertStyleIdsToString(scopedStyleIds));
3269
+ }
3270
+ if (null == this.$styleIds$ && (this.$styleIds$ = /* @__PURE__ */ new Set(), this.element.querySelectorAll(QStyleSelector).forEach((style) => {
3271
+ this.$styleIds$.add(style.getAttribute(QStyle));
3272
+ })), !this.$styleIds$.has(styleId)) {
3273
+ this.$styleIds$.add(styleId);
3274
+ const styleElement = this.document.createElement("style");
3275
+ styleElement.setAttribute(QStyle, styleId), styleElement.textContent = content, this.$journal$.push(VNodeJournalOpCode.Insert, this.document.head, null, styleElement);
3276
+ }
3277
+ }
3278
+ }
3279
+ const deserializedProxyMap = /* @__PURE__ */ new WeakMap();
3280
+ const isDeserializerProxy = (value) => "object" == typeof value && null !== value && SERIALIZER_PROXY_UNWRAP in value;
3281
+ const SERIALIZER_PROXY_UNWRAP = Symbol("UNWRAP");
3282
+ const wrapDeserializerProxy = (container, data) => {
3283
+ if (!Array.isArray(data) || vnode_isVNode(data) || isDeserializerProxy(data)) {
3284
+ return data;
3285
+ }
3286
+ let proxy = deserializedProxyMap.get(data);
3287
+ if (!proxy) {
3288
+ const target = Array(data.length / 2).fill(void 0);
3289
+ proxy = new Proxy(target, new DeserializationHandler(container, data)), deserializedProxyMap.set(data, proxy);
3290
+ }
3291
+ return proxy;
3292
+ };
3293
+ class DeserializationHandler {
3294
+ constructor($container$, $data$) {
3295
+ __publicField(this, "$container$");
3296
+ __publicField(this, "$data$");
3297
+ __publicField(this, "$length$");
3298
+ this.$container$ = $container$, this.$data$ = $data$, this.$length$ = this.$data$.length / 2;
3299
+ }
3300
+ get(target, property, receiver) {
3301
+ if (property === SERIALIZER_PROXY_UNWRAP) {
3302
+ return target;
3303
+ }
3304
+ const i = "number" == typeof property ? property : "string" == typeof property ? parseInt(property, 10) : NaN;
3305
+ if (Number.isNaN(i) || i < 0 || i >= this.$length$) {
3306
+ return Reflect.get(target, property, receiver);
3307
+ }
3308
+ const idx = 2 * i;
3309
+ const typeId = this.$data$[idx];
3310
+ const value = this.$data$[idx + 1];
3311
+ if (void 0 === typeId) {
3312
+ return value;
3313
+ }
3314
+ const container = this.$container$;
3315
+ let propValue = allocate(container, typeId, value);
3316
+ return typeId >= TypeIds.Error && (propValue = inflate(container, propValue, typeId, value)), Reflect.set(target, property, propValue), this.$data$[idx] = void 0, this.$data$[idx + 1] = propValue, propValue;
3317
+ }
3318
+ has(target, property) {
3319
+ return property === SERIALIZER_PROXY_UNWRAP || Object.prototype.hasOwnProperty.call(target, property);
3320
+ }
3321
+ set(target, property, value, receiver) {
3322
+ if (property === SERIALIZER_PROXY_UNWRAP) {
3323
+ return false;
3324
+ }
3325
+ const out = Reflect.set(target, property, value, receiver);
3326
+ const i = "number" == typeof property ? property : parseInt(property, 10);
3327
+ if (Number.isNaN(i) || i < 0 || i >= this.$data$.length / 2) {
3328
+ return out;
3329
+ }
3330
+ const idx = 2 * i;
3331
+ return this.$data$[idx] = void 0, this.$data$[idx + 1] = value, true;
3332
+ }
3333
+ }
3334
+ const _eagerDeserializeArray = (container, data) => {
3335
+ const out = Array(data.length / 2);
3336
+ for (let i = 0; i < data.length; i += 2) {
3337
+ out[i / 2] = deserializeData(container, data[i], data[i + 1]);
3338
+ }
3339
+ return out;
3340
+ };
3341
+ const resolvers = /* @__PURE__ */ new WeakMap();
3342
+ const inflate = (container, target, typeId, data) => {
3343
+ if (void 0 === typeId) {
3344
+ return target;
3345
+ }
3346
+ switch (typeId !== TypeIds.Object && Array.isArray(data) && (data = _eagerDeserializeArray(container, data)), typeId) {
3347
+ case TypeIds.Object:
3348
+ for (let i2 = 0; i2 < data.length; i2 += 4) {
3349
+ const key = deserializeData(container, data[i2], data[i2 + 1]);
3350
+ const valType = data[i2 + 2];
3351
+ const valData = data[i2 + 3];
3352
+ valType === TypeIds.RootRef || valType >= TypeIds.Error ? Object.defineProperty(target, key, {
3353
+ get() {
3354
+ const value = deserializeData(container, valType, valData);
3355
+ return target[key] = value, value;
3356
+ },
3357
+ set(value) {
3358
+ Object.defineProperty(target, key, {
3359
+ value,
3360
+ writable: true,
3361
+ enumerable: true,
3362
+ configurable: true
3363
+ });
3364
+ },
3365
+ enumerable: true,
3366
+ configurable: true
3367
+ }) : target[key] = deserializeData(container, valType, valData);
3368
+ }
3369
+ break;
3370
+ case TypeIds.QRL:
3371
+ inflateQRL(container, target);
3372
+ break;
3373
+ case TypeIds.Task:
3374
+ const task = target;
3375
+ const v = data;
3376
+ task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2], task.$el$ = v[3], task[_EFFECT_BACK_REF] = v[4], task.$state$ = v[5];
3377
+ break;
3378
+ case TypeIds.Resource:
3379
+ const [resolved, result, effects] = data;
3380
+ const resource = target;
3381
+ resolved ? (resource.value = Promise.resolve(result), resource._resolved = result, resource._state = "resolved") : (resource.value = Promise.reject(result), resource._error = result, resource._state = "rejected"), getStoreHandler(target).$effects$ = effects;
3382
+ break;
3383
+ case TypeIds.Component:
3384
+ target[SERIALIZABLE_STATE][0] = data[0];
3385
+ break;
3386
+ case TypeIds.Store:
3387
+ case TypeIds.StoreArray: {
3388
+ const [value, flags, effects2] = data;
3389
+ const store = getOrCreateStore(value, flags, container);
3390
+ getStoreHandler(store).$effects$ = effects2, target = store;
3391
+ break;
3392
+ }
3393
+ case TypeIds.Signal: {
3394
+ const signal = target;
3395
+ const d = data;
3396
+ signal.$untrackedValue$ = d[0], signal.$effects$ = new Set(d.slice(1));
3397
+ break;
3398
+ }
3399
+ case TypeIds.WrappedSignal: {
3400
+ const signal = target;
3401
+ const d = data;
3402
+ signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal[_EFFECT_BACK_REF] = d[2], signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = new Set(d.slice(5));
3403
+ break;
3404
+ }
3405
+ case TypeIds.ComputedSignal: {
3406
+ const computed = target;
3407
+ const d = data;
3408
+ computed.$computeQrl$ = d[0], computed.$effects$ = d[1], 3 === d.length ? computed.$untrackedValue$ = d[2] : (computed.$invalid$ = true, computed.$computeQrl$.resolve(), container.$scheduler$?.(ChoreType.QRL_RESOLVE, null, computed.$computeQrl$));
3409
+ break;
3410
+ }
3411
+ case TypeIds.Error: {
3412
+ const d = data;
3413
+ target.message = d[0];
3414
+ const second = d[1];
3415
+ if (second && Array.isArray(second)) {
3416
+ for (let i2 = 0; i2 < second.length; i2++) {
3417
+ target[second[i2++]] = d[i2];
3418
+ }
3419
+ target.stack = d[2];
3420
+ } else {
3421
+ target.stack = second;
3422
+ }
3423
+ break;
3424
+ }
3425
+ case TypeIds.FormData: {
3426
+ const formData = target;
3427
+ const d = data;
3428
+ for (let i2 = 0; i2 < d.length; i2++) {
3429
+ formData.append(d[i2++], d[i2]);
3430
+ }
3431
+ break;
3432
+ }
3433
+ case TypeIds.JSXNode: {
3434
+ const jsx2 = target;
3435
+ const [type, varProps, constProps, children, flags, key] = data;
3436
+ jsx2.type = type, jsx2.varProps = varProps, jsx2.constProps = constProps, jsx2.children = children, jsx2.flags = flags, jsx2.key = key;
3437
+ break;
3438
+ }
3439
+ case TypeIds.Set: {
3440
+ const set = target;
3441
+ const d = data;
3442
+ for (let i2 = 0; i2 < d.length; i2++) {
3443
+ set.add(d[i2]);
3444
+ }
3445
+ break;
3446
+ }
3447
+ case TypeIds.Map: {
3448
+ const map = target;
3449
+ const d = data;
3450
+ for (let i2 = 0; i2 < d.length; i2++) {
3451
+ map.set(d[i2++], d[i2]);
3452
+ }
3453
+ break;
3454
+ }
3455
+ case TypeIds.Promise: {
3456
+ const promise = target;
3457
+ const [resolved2, result2] = data;
3458
+ const [resolve, reject] = resolvers.get(promise);
3459
+ resolved2 ? resolve(result2) : reject(result2);
3460
+ break;
3461
+ }
3462
+ case TypeIds.Uint8Array:
3463
+ const bytes = target;
3464
+ const buf = atob(data);
3465
+ let i = 0;
3466
+ for (const s of buf) {
3467
+ bytes[i++] = s.charCodeAt(0);
3468
+ }
3469
+ break;
3470
+ case TypeIds.PropsProxy:
3471
+ const propsProxy = target;
3472
+ propsProxy[_VAR_PROPS] = 0 === data ? {} : data[0], propsProxy[_CONST_PROPS] = data[1];
3473
+ break;
3474
+ case TypeIds.EffectData: {
3475
+ const effectData = target;
3476
+ effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
3477
+ break;
3478
+ }
3479
+ default:
3480
+ throw qError(QError.serializeErrorNotImplemented, [typeId]);
3481
+ }
3482
+ return target;
3483
+ };
3484
+ const _constants = [void 0, null, true, false, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ARRAY_PROP, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER];
3485
+ const allocate = (container, typeId, value) => {
3486
+ if (void 0 === value) {
3487
+ return typeId;
3488
+ }
3489
+ switch (typeId) {
3490
+ case TypeIds.RootRef:
3491
+ return container.$getObjectById$(value);
3492
+ case TypeIds.Constant:
3493
+ return _constants[value];
3494
+ case TypeIds.Number:
3495
+ return value;
3496
+ case TypeIds.Array:
3497
+ return wrapDeserializerProxy(container, value);
3498
+ case TypeIds.Object:
3499
+ return {};
3500
+ case TypeIds.QRL:
3501
+ return parseQRL(container.$getObjectById$(value));
3502
+ case TypeIds.Task:
3503
+ return new Task(-1, -1, null, null, null, null);
3504
+ case TypeIds.Resource: {
3505
+ const res = createResourceReturn(container, void 0, void 0);
3506
+ return res.loading = false, res;
3507
+ }
3508
+ case TypeIds.URL:
3509
+ return new URL(value);
3510
+ case TypeIds.Date:
3511
+ return new Date(value);
3512
+ case TypeIds.Regex:
3513
+ const idx = value.lastIndexOf("/");
3514
+ return new RegExp(value.slice(1, idx), value.slice(idx + 1));
3515
+ case TypeIds.Error:
3516
+ return new Error();
3517
+ case TypeIds.Component:
3518
+ return componentQrl(null);
3519
+ case TypeIds.Signal:
3520
+ return new Signal(container, 0);
3521
+ case TypeIds.WrappedSignal:
3522
+ return new WrappedSignal(container, null, null, null);
3523
+ case TypeIds.ComputedSignal:
3524
+ return new ComputedSignal(container, null);
3525
+ case TypeIds.Store:
3526
+ case TypeIds.StoreArray:
3527
+ return null;
3528
+ case TypeIds.URLSearchParams:
3529
+ return new URLSearchParams(value);
3530
+ case TypeIds.FormData:
3531
+ return new FormData();
3532
+ case TypeIds.JSXNode:
3533
+ return new JSXNodeImpl(null, null, null, null, -1, null);
3534
+ case TypeIds.BigInt:
3535
+ return BigInt(value);
3536
+ case TypeIds.Set:
3537
+ return /* @__PURE__ */ new Set();
3538
+ case TypeIds.Map:
3539
+ return /* @__PURE__ */ new Map();
3540
+ case TypeIds.String:
3541
+ return value;
3542
+ case TypeIds.Promise:
3543
+ let resolve;
3544
+ let reject;
3545
+ const promise = new Promise((res, rej) => {
3546
+ resolve = res, reject = rej;
3547
+ });
3548
+ return resolvers.set(promise, [resolve, reject]), promise.catch(() => {
3549
+ }), promise;
3550
+ case TypeIds.Uint8Array:
3551
+ const encodedLength = value.length;
3552
+ const rest = 3 & encodedLength;
3553
+ return new Uint8Array(3 * (encodedLength >>> 2) + (rest ? rest - 1 : 0));
3554
+ case TypeIds.PropsProxy:
3555
+ return createPropsProxy(null, null);
3556
+ case TypeIds.VNode:
3557
+ return retrieveVNodeOrDocument(container, value);
3558
+ case TypeIds.RefVNode:
3559
+ const vNode = retrieveVNodeOrDocument(container, value);
3560
+ if (vnode_isVNode(vNode)) {
3561
+ return vnode_getNode(vNode);
3562
+ }
3563
+ throw qError(QError.serializeErrorExpectedVNode, [typeof vNode]);
3564
+ case TypeIds.EffectData:
3565
+ return new SubscriptionData({});
3566
+ default:
3567
+ throw qError(QError.serializeErrorCannotAllocate, [typeId]);
3568
+ }
3569
+ };
3570
+ function retrieveVNodeOrDocument(container, value) {
3571
+ return value ? container.rootVNode ? vnode_locate(container.rootVNode, value) : void 0 : container.element?.ownerDocument;
3572
+ }
3573
+ function parseQRL(qrl2) {
3574
+ const hashIdx = qrl2.indexOf("#");
3575
+ const captureStart = qrl2.indexOf("[", hashIdx);
3576
+ const captureEnd = qrl2.indexOf("]", captureStart);
3577
+ const chunk = qrl2.slice(0, hashIdx > -1 ? hashIdx : captureStart);
3578
+ const symbol = captureStart > -1 ? qrl2.slice(hashIdx + 1, captureStart) : qrl2.slice(hashIdx + 1);
3579
+ const captureIds = captureStart > -1 && captureEnd > -1 ? qrl2.slice(captureStart + 1, captureEnd).split(" ").filter((v) => v.length).map((s) => parseInt(s, 10)) : null;
3580
+ let qrlRef = null;
3581
+ if (chunk === QRL_RUNTIME_CHUNK) {
3582
+ const backChannel = globalThis[QRL_RUNTIME_CHUNK];
3583
+ qrlRef = backChannel.get(symbol);
3584
+ }
3585
+ return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
3586
+ }
3587
+ function inflateQRL(container, qrl2) {
3588
+ const captureIds = qrl2.$capture$;
3589
+ return qrl2.$captureRef$ = captureIds ? captureIds.map((id) => container.$getObjectById$(id)) : null, container.element && qrl2.$setContainer$(container.element), qrl2;
3590
+ }
3591
+ let isDomRef = () => false;
3592
+ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, getProp2, setProp, storeProxyMap, writer, prepVNodeData) => {
3593
+ if (!writer) {
3594
+ const buffer = [];
3595
+ writer = {
3596
+ write: (text) => buffer.push(text),
3597
+ toString: () => buffer.join("")
3598
+ };
3599
+ }
3600
+ const map = /* @__PURE__ */ new Map();
3601
+ const syncFnMap = /* @__PURE__ */ new Map();
3602
+ const syncFns = [];
3603
+ const roots = [];
3604
+ const $wasSeen$ = (obj) => map.get(obj);
3605
+ const $seen$ = (obj) => map.set(obj, -1);
3606
+ const $addRoot$ = (obj) => {
3607
+ let id = map.get(obj);
3608
+ return "number" == typeof id && -1 !== id || (id = roots.length, map.set(obj, id), roots.push(obj)), id;
3609
+ };
3610
+ const isSsrNode2 = NodeConstructor ? (obj) => obj instanceof NodeConstructor : () => false;
3611
+ return isDomRef = DomRefConstructor ? (obj) => obj instanceof DomRefConstructor : () => false, {
3612
+ $serialize$() {
3613
+ serialize(this);
3614
+ },
3615
+ $isSsrNode$: isSsrNode2,
3616
+ $isDomRef$: isDomRef,
3617
+ $symbolToChunkResolver$: symbolToChunkResolver,
3618
+ $wasSeen$,
3619
+ $roots$: roots,
3620
+ $seen$,
3621
+ $hasRootId$: (obj) => {
3622
+ const id = map.get(obj);
3623
+ return void 0 === id || -1 === id ? void 0 : id;
3624
+ },
3625
+ $addRoot$,
3626
+ $getRootId$: (obj) => {
3627
+ const id = map.get(obj);
3628
+ if (!id || -1 === id) {
3629
+ throw qError(QError.serializeErrorMissingRootId, [obj]);
3630
+ }
3631
+ return id;
3632
+ },
3633
+ $syncFns$: syncFns,
3634
+ $addSyncFn$: (funcStr, argCount, fn) => {
3635
+ const isFullFn = null == funcStr;
3636
+ isFullFn && (funcStr = fn.serialized || fn.toString());
3637
+ let id = syncFnMap.get(funcStr);
3638
+ if (void 0 === id) {
3639
+ if (id = syncFns.length, syncFnMap.set(funcStr, id), isFullFn) {
3640
+ syncFns.push(funcStr);
3641
+ } else {
3642
+ let code = "(";
3643
+ for (let i = 0; i < argCount; i++) {
3644
+ code += (0 == i ? "p" : ",p") + i;
3645
+ }
3646
+ syncFns.push(code += ")=>" + funcStr);
3647
+ }
3648
+ }
3649
+ return id;
3650
+ },
3651
+ $writer$: writer,
3652
+ $breakCircularDepsAndAwaitPromises$: async function() {
3653
+ const discoveredValues = [];
3654
+ const promises = [];
3655
+ const visit = (obj) => {
3656
+ if ("function" == typeof obj) {
3657
+ if (isQrl$1(obj)) {
3658
+ obj.$captureRef$ && discoveredValues.push(...obj.$captureRef$);
3659
+ } else if (isQwikComponent(obj)) {
3660
+ const [qrl2] = obj[SERIALIZABLE_STATE];
3661
+ discoveredValues.push(qrl2);
3662
+ }
3663
+ } else if ("object" != typeof obj || null === obj || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || vnode_isVNode(obj) || "undefined" != typeof FormData && obj instanceof FormData || fastSkipSerialize(obj)) ;
3664
+ else if (obj instanceof Error) {
3665
+ discoveredValues.push(...Object.values(obj));
3666
+ } else if (isStore(obj)) {
3667
+ const target = getStoreTarget(obj);
3668
+ const effects = getStoreHandler(obj).$effects$;
3669
+ discoveredValues.push(target, effects);
3670
+ for (const prop in target) {
3671
+ const propValue = target[prop];
3672
+ storeProxyMap.has(propValue) && discoveredValues.push(prop, storeProxyMap.get(propValue));
3673
+ }
3674
+ } else if (obj instanceof Set) {
3675
+ discoveredValues.push(...obj.values());
3676
+ } else if (obj instanceof Map) {
3677
+ obj.forEach((v, k) => {
3678
+ discoveredValues.push(k, v);
3679
+ });
3680
+ } else if (obj instanceof Signal) {
3681
+ const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$invalid$ || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
3682
+ v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(...obj.$effects$), obj instanceof WrappedSignal ? (discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues), obj.$args$ && discoveredValues.push(...obj.$args$), obj.$hostElement$ && discoveredValues.push(obj.$hostElement$)) : obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
3683
+ } else if (obj instanceof Task) {
3684
+ discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$), discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
3685
+ } else if (isSsrNode2(obj)) {
3686
+ if (discoverValuesForVNodeData(obj.vnodeData, discoveredValues), obj.childrenVNodeData && obj.childrenVNodeData.length) {
3687
+ for (const data of obj.childrenVNodeData) {
3688
+ discoverValuesForVNodeData(data, discoveredValues);
3689
+ }
3690
+ }
3691
+ } else if (isDomRef(obj)) {
3692
+ discoveredValues.push(obj.$ssrNode$.id);
3693
+ } else if (isJSXNode(obj)) {
3694
+ discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
3695
+ } else if (Array.isArray(obj)) {
3696
+ discoveredValues.push(...obj);
3697
+ } else if (isQrl$1(obj)) {
3698
+ obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
3699
+ } else if (isPropsProxy(obj)) {
3700
+ discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
3701
+ } else if (isPromise(obj)) {
3702
+ obj.then((value) => {
3703
+ promiseResults.set(obj, [true, value]), discoveredValues.push(value);
3704
+ }, (error) => {
3705
+ promiseResults.set(obj, [false, error]), discoveredValues.push(error);
3706
+ }), promises.push(obj);
3707
+ } else if (obj instanceof SubscriptionData) {
3708
+ discoveredValues.push(obj.data);
3709
+ } else {
3710
+ if (!isObjectLiteral(obj)) {
3711
+ throw qError(QError.serializeErrorUnknownType, [obj]);
3712
+ }
3713
+ Object.entries(obj).forEach(([key, value]) => {
3714
+ discoveredValues.push(key, value);
3715
+ });
3716
+ }
3717
+ };
3718
+ for (const root of roots) {
3719
+ visit(root);
3720
+ }
3721
+ do {
3722
+ for (; discoveredValues.length; ) {
3723
+ const obj = discoveredValues.pop();
3724
+ if (!shouldTrackObj(obj) && !frameworkType(obj)) {
3725
+ continue;
3726
+ }
3727
+ const id = $wasSeen$(obj);
3728
+ void 0 === id ? ($seen$(obj), visit(obj)) : -1 === id && $addRoot$(obj);
3729
+ }
3730
+ await Promise.allSettled(promises), promises.length = 0;
3731
+ } while (discoveredValues.length);
3732
+ },
3733
+ $eventQrls$: /* @__PURE__ */ new Set(),
3734
+ $eventNames$: /* @__PURE__ */ new Set(),
3735
+ $resources$: /* @__PURE__ */ new Set(),
3736
+ $renderSymbols$: /* @__PURE__ */ new Set(),
3737
+ $storeProxyMap$: storeProxyMap,
3738
+ $getProp$: getProp2,
3739
+ $setProp$: setProp,
3740
+ $prepVNodeData$: prepVNodeData
3741
+ };
3742
+ };
3743
+ const isSsrAttrs = (value) => Array.isArray(value) && value.length > 0;
3744
+ const discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
3745
+ for (const value of vnodeData) {
3746
+ if (isSsrAttrs(value)) {
3747
+ for (let i = 1; i < value.length; i += 2) {
3748
+ const attrValue = value[i];
3749
+ "string" != typeof attrValue && discoveredValues.push(attrValue);
3750
+ }
3751
+ }
3752
+ }
3753
+ };
3754
+ const discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
3755
+ if (effectsBackRefs) {
3756
+ let hasBackRefs = false;
3757
+ for (const [, effect] of effectsBackRefs) {
3758
+ if (effect[EffectSubscriptionProp.BACK_REF]) {
3759
+ hasBackRefs = true;
3760
+ break;
3761
+ }
3762
+ }
3763
+ hasBackRefs && discoveredValues.push(effectsBackRefs);
3764
+ }
3765
+ };
3766
+ const promiseResults = /* @__PURE__ */ new WeakMap();
3767
+ function serialize(serializationContext) {
3768
+ const { $writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$ } = serializationContext;
3769
+ let depth = -1;
3770
+ let writeType = false;
3771
+ const output = (type, value) => {
3772
+ if (writeType ? $writer$.write(`${type},`) : writeType = true, "number" == typeof value) {
3773
+ $writer$.write(value.toString());
3774
+ } else if ("string" == typeof value) {
3775
+ const s = JSON.stringify(value);
3776
+ let angleBracketIdx = -1;
3777
+ let lastIdx = 0;
3778
+ for (; -1 !== (angleBracketIdx = s.indexOf("</", lastIdx)); ) {
3779
+ $writer$.write(s.slice(lastIdx, angleBracketIdx)), $writer$.write("<\\/"), lastIdx = angleBracketIdx + 2;
3780
+ }
3781
+ $writer$.write(0 === lastIdx ? s : s.slice(lastIdx));
3782
+ } else {
3783
+ depth++, $writer$.write("[");
3784
+ let separator = false;
3785
+ for (let i = 0; i < value.length; i++) {
3786
+ separator ? $writer$.write(",") : separator = true, writeValue(value[i], i);
3787
+ }
3788
+ $writer$.write("]"), depth--;
3789
+ }
3790
+ };
3791
+ const writeValue = (value, idx) => {
3792
+ if (fastSkipSerialize(value)) {
3793
+ output(TypeIds.Constant, Constants.Undefined);
3794
+ } else if ("bigint" == typeof value) {
3795
+ output(TypeIds.BigInt, value.toString());
3796
+ } else if ("boolean" == typeof value) {
3797
+ output(TypeIds.Constant, value ? Constants.True : Constants.False);
3798
+ } else if ("function" == typeof value) {
3799
+ if (value === Slot) {
3800
+ output(TypeIds.Constant, Constants.Slot);
3801
+ } else if (value === Fragment) {
3802
+ output(TypeIds.Constant, Constants.Fragment);
3803
+ } else if (isQrl$1(value)) {
3804
+ const qrl2 = qrlToString(serializationContext, value);
3805
+ const id = serializationContext.$addRoot$(qrl2);
3806
+ output(TypeIds.QRL, id);
3807
+ } else if (isQwikComponent(value)) {
3808
+ const [qrl2] = value[SERIALIZABLE_STATE];
3809
+ serializationContext.$renderSymbols$.add(qrl2.$symbol$), output(TypeIds.Component, [qrl2]);
3810
+ } else {
3811
+ console.error("Cannot serialize function (ignoring for now): " + value.toString()), output(TypeIds.Constant, Constants.Undefined);
3812
+ }
3813
+ } else if ("number" == typeof value) {
3814
+ Number.isNaN(value) ? output(TypeIds.Constant, Constants.NaN) : Number.isFinite(value) ? value === Number.MAX_SAFE_INTEGER ? output(TypeIds.Constant, Constants.MaxSafeInt) : value === Number.MAX_SAFE_INTEGER - 1 ? output(TypeIds.Constant, Constants.AlmostMaxSafeInt) : value === Number.MIN_SAFE_INTEGER ? output(TypeIds.Constant, Constants.MinSafeInt) : output(TypeIds.Number, value) : output(TypeIds.Constant, value < 0 ? Constants.NegativeInfinity : Constants.PositiveInfinity);
3815
+ } else if ("object" == typeof value) {
3816
+ value === EMPTY_ARRAY ? output(TypeIds.Constant, Constants.EMPTY_ARRAY) : value === EMPTY_OBJ ? output(TypeIds.Constant, Constants.EMPTY_OBJ) : (depth++, null === value ? output(TypeIds.Constant, Constants.Null) : writeObjectValue(value, idx), depth--);
3817
+ } else if ("string" == typeof value) {
3818
+ if (0 === value.length) {
3819
+ output(TypeIds.Constant, Constants.EmptyString);
3820
+ } else {
3821
+ const seen = depth > 1 && serializationContext.$wasSeen$(value);
3822
+ "number" == typeof seen && seen >= 0 ? output(TypeIds.RootRef, seen) : output(TypeIds.String, value);
3823
+ }
3824
+ } else if (void 0 === value) {
3825
+ output(TypeIds.Constant, Constants.Undefined);
3826
+ } else if (value === NEEDS_COMPUTATION) {
3827
+ output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
3828
+ } else {
3829
+ if (value !== STORE_ARRAY_PROP) {
3830
+ throw qError(QError.serializeErrorUnknownType, [typeof value]);
3831
+ }
3832
+ output(TypeIds.Constant, Constants.STORE_ARRAY_PROP);
3833
+ }
3834
+ };
3835
+ const writeObjectValue = (value, idx) => {
3836
+ const isRootObject = 2 === depth;
3837
+ if (depth > 2) {
3838
+ const seen = serializationContext.$wasSeen$(value);
3839
+ if ("number" == typeof seen && seen >= 0) {
3840
+ return void output(TypeIds.RootRef, seen);
3841
+ }
3842
+ }
3843
+ if (isPropsProxy(value)) {
3844
+ const varProps = value[_VAR_PROPS];
3845
+ const constProps = value[_CONST_PROPS];
3846
+ const out = constProps ? [varProps, constProps] : Object.keys(varProps).length ? [varProps] : 0;
3847
+ output(TypeIds.PropsProxy, out);
3848
+ } else if (value instanceof SubscriptionData) {
3849
+ output(TypeIds.EffectData, [value.data.$scopedStyleIdPrefix$, value.data.$isConst$]);
3850
+ } else if (isStore(value)) {
3851
+ if (isResource(value)) {
3852
+ serializationContext.$resources$.add(value);
3853
+ const res = promiseResults.get(value.value);
3854
+ if (!res) {
3855
+ throw qError(QError.serializeErrorUnvisited, ["resource"]);
3856
+ }
3857
+ output(TypeIds.Resource, [...res, getStoreHandler(value).$effects$]);
3858
+ } else {
3859
+ const storeHandler = getStoreHandler(value);
3860
+ const storeTarget = getStoreTarget(value);
3861
+ const flags = storeHandler.$flags$;
3862
+ const effects = storeHandler.$effects$;
3863
+ const innerStores = [];
3864
+ for (const prop in storeTarget) {
3865
+ const propValue = storeTarget[prop];
3866
+ if ($storeProxyMap$.has(propValue)) {
3867
+ const innerStore = $storeProxyMap$.get(propValue);
3868
+ innerStores.push(innerStore), serializationContext.$addRoot$(innerStore);
3869
+ }
3870
+ }
3871
+ const out = [storeTarget, flags, effects, ...innerStores];
3872
+ for (; null == out[out.length - 1]; ) {
3873
+ out.pop();
3874
+ }
3875
+ output(Array.isArray(storeTarget) ? TypeIds.StoreArray : TypeIds.Store, out);
3876
+ }
3877
+ } else if (isObjectLiteral(value)) {
3878
+ if (Array.isArray(value)) {
3879
+ output(TypeIds.Array, value);
3880
+ } else {
3881
+ const out = [];
3882
+ for (const key in value) {
3883
+ Object.prototype.hasOwnProperty.call(value, key) && !fastSkipSerialize(value[key]) && out.push(key, value[key]);
3884
+ }
3885
+ output(TypeIds.Object, out);
3886
+ }
3887
+ } else if ($isDomRef$(value)) {
3888
+ value.$ssrNode$.vnodeData[0] |= VNodeDataFlag.SERIALIZE, output(TypeIds.RefVNode, value.$ssrNode$.id);
3889
+ } else if (value instanceof Signal) {
3890
+ const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
3891
+ if (value instanceof WrappedSignal) {
3892
+ output(TypeIds.WrappedSignal, [...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), v, value.$hostElement$, ...value.$effects$ || []]);
3893
+ } else if (value instanceof ComputedSignal) {
3894
+ const out = [value.$computeQrl$, value.$effects$];
3895
+ v !== NEEDS_COMPUTATION && out.push(v), output(TypeIds.ComputedSignal, out);
3896
+ } else {
3897
+ output(TypeIds.Signal, [v, ...value.$effects$ || []]);
3898
+ }
3899
+ } else if (value instanceof URL) {
3900
+ output(TypeIds.URL, value.href);
3901
+ } else if (value instanceof Date) {
3902
+ output(TypeIds.Date, Number.isNaN(value.valueOf()) ? "" : value.valueOf());
3903
+ } else if (value instanceof RegExp) {
3904
+ output(TypeIds.Regex, value.toString());
3905
+ } else if (value instanceof Error) {
3906
+ const out = [value.message];
3907
+ const extraProps = Object.entries(value).flat();
3908
+ extraProps.length && out.push(extraProps), out.push(value.stack), output(TypeIds.Error, out);
3909
+ } else if ($isSsrNode$(value)) {
3910
+ if (isRootObject) {
3911
+ $setProp$(value, "q:id", String(idx)), output(TypeIds.VNode, value.id);
3912
+ const vNodeData = value.vnodeData;
3913
+ if (vNodeData && (serializationContext.$prepVNodeData$?.(vNodeData), vNodeData[0] |= VNodeDataFlag.SERIALIZE), value.childrenVNodeData) {
3914
+ for (const vNodeData2 of value.childrenVNodeData) {
3915
+ vNodeData2[0] |= VNodeDataFlag.SERIALIZE;
3916
+ }
3917
+ }
3918
+ } else {
3919
+ serializationContext.$addRoot$(value), output(TypeIds.RootRef, serializationContext.$roots$.length - 1);
3920
+ }
3921
+ } else if ("undefined" != typeof FormData && value instanceof FormData) {
3922
+ const array = [];
3923
+ value.forEach((value2, key) => {
3924
+ array.push(key, "string" == typeof value2 ? value2 : value2.name);
3925
+ }), output(TypeIds.FormData, array);
3926
+ } else if (value instanceof URLSearchParams) {
3927
+ output(TypeIds.URLSearchParams, value.toString());
3928
+ } else if (value instanceof Set) {
3929
+ output(TypeIds.Set, [...value.values()]);
3930
+ } else if (value instanceof Map) {
3931
+ const combined = [];
3932
+ for (const [k, v] of value.entries()) {
3933
+ combined.push(k, v);
3934
+ }
3935
+ output(TypeIds.Map, combined);
3936
+ } else if (isJSXNode(value)) {
3937
+ output(TypeIds.JSXNode, [value.type, value.varProps, value.constProps, value.children, value.flags, value.key]);
3938
+ } else if (value instanceof Task) {
3939
+ const out = [value.$qrl$, value.$flags$, value.$index$, value.$el$, value[_EFFECT_BACK_REF], value.$state$];
3940
+ for (; null == out[out.length - 1]; ) {
3941
+ out.pop();
3942
+ }
3943
+ output(TypeIds.Task, out);
3944
+ } else if (isPromise(value)) {
3945
+ const res = promiseResults.get(value);
3946
+ if (!res) {
3947
+ throw qError(QError.serializeErrorUnvisited, ["promise"]);
3948
+ }
3949
+ output(TypeIds.Promise, res);
3950
+ } else if (value instanceof Uint8Array) {
3951
+ let buf = "";
3952
+ for (const c of value) {
3953
+ buf += String.fromCharCode(c);
3954
+ }
3955
+ const out = btoa(buf).replace(/=+$/, "");
3956
+ output(TypeIds.Uint8Array, out);
3957
+ } else {
3958
+ if (!vnode_isVNode(value)) {
3959
+ throw qError(QError.serializeErrorUnknownType, [typeof value]);
3960
+ }
3961
+ output(TypeIds.Constant, Constants.Undefined);
3962
+ }
3963
+ };
3964
+ writeValue(serializationContext.$roots$, -1);
3965
+ }
3966
+ function filterEffectBackRefs(effectBackRef) {
3967
+ let effectBackRefToSerialize = null;
3968
+ if (effectBackRef) {
3969
+ for (const [effectProp, effect] of effectBackRef) {
3970
+ effect[EffectSubscriptionProp.BACK_REF] && (effectBackRefToSerialize || (effectBackRefToSerialize = /* @__PURE__ */ new Map()), effectBackRefToSerialize.set(effectProp, effect));
3971
+ }
3972
+ }
3973
+ return effectBackRefToSerialize;
3974
+ }
3975
+ function serializeWrappingFn(serializationContext, value) {
3976
+ value.$funcStr$ && "{" === value.$funcStr$[0] && (value.$funcStr$ = `(${value.$funcStr$})`);
3977
+ return [serializationContext.$addSyncFn$(value.$funcStr$, value.$args$.length, value.$func$), value.$args$];
3978
+ }
3979
+ function qrlToString(serializationContext, value) {
3980
+ let symbol = value.$symbol$;
3981
+ let chunk = value.$chunk$;
3982
+ const platform = getPlatform();
3983
+ if (platform) {
3984
+ const result = platform.chunkForSymbol(symbol, chunk, value.dev?.file);
3985
+ result && (chunk = result[1], symbol = result[0]);
3986
+ }
3987
+ if (isSyncQrl(value)) {
3988
+ chunk = "", symbol = String(serializationContext.$addSyncFn$(null, 0, value.resolved));
3989
+ } else {
3990
+ chunk || (chunk = serializationContext.$symbolToChunkResolver$(value.$hash$));
3991
+ {
3992
+ let backChannel = globalThis[QRL_RUNTIME_CHUNK];
3993
+ backChannel || (backChannel = globalThis[QRL_RUNTIME_CHUNK] = /* @__PURE__ */ new Map()), backChannel.set(value.$symbol$, value._devOnlySymbolRef), chunk || (chunk = QRL_RUNTIME_CHUNK);
3994
+ }
3995
+ if (!chunk) {
3996
+ throw qError(QError.qrlMissingChunk, [value.$symbol$]);
3997
+ }
3998
+ chunk.startsWith("./") && (chunk = chunk.slice(2));
3999
+ }
4000
+ let qrlStringInline = `${chunk}#${symbol}`;
4001
+ if (Array.isArray(value.$captureRef$) && value.$captureRef$.length > 0) {
4002
+ let serializedReferences = "";
4003
+ for (let i = 0; i < value.$captureRef$.length; i++) {
4004
+ i > 0 && (serializedReferences += " "), serializedReferences += serializationContext.$addRoot$(value.$captureRef$[i]);
4005
+ }
4006
+ qrlStringInline += `[${serializedReferences}]`;
4007
+ } else {
4008
+ value.$capture$ && value.$capture$.length > 0 && (qrlStringInline += `[${value.$capture$.join(" ")}]`);
4009
+ }
4010
+ return qrlStringInline;
4011
+ }
4012
+ function deserializeData(container, typeId, value) {
4013
+ if (void 0 === typeId) {
4014
+ return value;
4015
+ }
4016
+ let propValue = allocate(container, typeId, value);
4017
+ return typeId >= TypeIds.Error && (propValue = inflate(container, propValue, typeId, value)), propValue;
4018
+ }
4019
+ function shouldTrackObj(obj) {
4020
+ return "object" == typeof obj && null !== obj || "string" == typeof obj && obj.length > 1;
4021
+ }
4022
+ function isObjectLiteral(obj) {
4023
+ const prototype = Object.getPrototypeOf(obj);
4024
+ return null == prototype || prototype === Object.prototype || prototype === Array.prototype;
4025
+ }
4026
+ function isResource(value) {
4027
+ return "__brand" in value && "resource" === value.__brand;
4028
+ }
4029
+ const frameworkType = (obj) => "object" == typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl$1(obj);
4030
+ const QRL_RUNTIME_CHUNK = "mock-chunk";
648
4031
  var TypeIds;
649
4032
  var Constants;
650
4033
  !function(TypeIds2) {
651
4034
  TypeIds2[TypeIds2.RootRef = 0] = "RootRef", TypeIds2[TypeIds2.Constant = 1] = "Constant", TypeIds2[TypeIds2.Number = 2] = "Number", TypeIds2[TypeIds2.String = 3] = "String", TypeIds2[TypeIds2.Array = 4] = "Array", TypeIds2[TypeIds2.URL = 5] = "URL", TypeIds2[TypeIds2.Date = 6] = "Date", TypeIds2[TypeIds2.Regex = 7] = "Regex", TypeIds2[TypeIds2.VNode = 8] = "VNode", TypeIds2[TypeIds2.RefVNode = 9] = "RefVNode", TypeIds2[TypeIds2.BigInt = 10] = "BigInt", TypeIds2[TypeIds2.URLSearchParams = 11] = "URLSearchParams", TypeIds2[TypeIds2.Error = 12] = "Error", TypeIds2[TypeIds2.Object = 13] = "Object", TypeIds2[TypeIds2.Promise = 14] = "Promise", TypeIds2[TypeIds2.Set = 15] = "Set", TypeIds2[TypeIds2.Map = 16] = "Map", TypeIds2[TypeIds2.Uint8Array = 17] = "Uint8Array", TypeIds2[TypeIds2.QRL = 18] = "QRL", TypeIds2[TypeIds2.Task = 19] = "Task", TypeIds2[TypeIds2.Resource = 20] = "Resource", TypeIds2[TypeIds2.Component = 21] = "Component", TypeIds2[TypeIds2.Signal = 22] = "Signal", TypeIds2[TypeIds2.WrappedSignal = 23] = "WrappedSignal", TypeIds2[TypeIds2.ComputedSignal = 24] = "ComputedSignal", TypeIds2[TypeIds2.Store = 25] = "Store", TypeIds2[TypeIds2.StoreArray = 26] = "StoreArray", TypeIds2[TypeIds2.FormData = 27] = "FormData", TypeIds2[TypeIds2.JSXNode = 28] = "JSXNode", TypeIds2[TypeIds2.PropsProxy = 29] = "PropsProxy", TypeIds2[TypeIds2.EffectData = 30] = "EffectData";
652
4035
  }(TypeIds || (TypeIds = {})), function(Constants2) {
653
- Constants2[Constants2.Undefined = 0] = "Undefined", Constants2[Constants2.Null = 1] = "Null", Constants2[Constants2.True = 2] = "True", Constants2[Constants2.False = 3] = "False", Constants2[Constants2.EmptyString = 4] = "EmptyString", Constants2[Constants2.EMPTY_ARRAY = 5] = "EMPTY_ARRAY", Constants2[Constants2.EMPTY_OBJ = 6] = "EMPTY_OBJ", Constants2[Constants2.NEEDS_COMPUTATION = 7] = "NEEDS_COMPUTATION", Constants2[Constants2.Slot = 8] = "Slot", Constants2[Constants2.Fragment = 9] = "Fragment", Constants2[Constants2.NaN = 10] = "NaN", Constants2[Constants2.PositiveInfinity = 11] = "PositiveInfinity", Constants2[Constants2.NegativeInfinity = 12] = "NegativeInfinity", Constants2[Constants2.MaxSafeInt = 13] = "MaxSafeInt", Constants2[Constants2.AlmostMaxSafeInt = 14] = "AlmostMaxSafeInt", Constants2[Constants2.MinSafeInt = 15] = "MinSafeInt";
4036
+ Constants2[Constants2.Undefined = 0] = "Undefined", Constants2[Constants2.Null = 1] = "Null", Constants2[Constants2.True = 2] = "True", Constants2[Constants2.False = 3] = "False", Constants2[Constants2.EmptyString = 4] = "EmptyString", Constants2[Constants2.EMPTY_ARRAY = 5] = "EMPTY_ARRAY", Constants2[Constants2.EMPTY_OBJ = 6] = "EMPTY_OBJ", Constants2[Constants2.NEEDS_COMPUTATION = 7] = "NEEDS_COMPUTATION", Constants2[Constants2.STORE_ARRAY_PROP = 8] = "STORE_ARRAY_PROP", Constants2[Constants2.Slot = 9] = "Slot", Constants2[Constants2.Fragment = 10] = "Fragment", Constants2[Constants2.NaN = 11] = "NaN", Constants2[Constants2.PositiveInfinity = 12] = "PositiveInfinity", Constants2[Constants2.NegativeInfinity = 13] = "NegativeInfinity", Constants2[Constants2.MaxSafeInt = 14] = "MaxSafeInt", Constants2[Constants2.AlmostMaxSafeInt = 15] = "AlmostMaxSafeInt", Constants2[Constants2.MinSafeInt = 16] = "MinSafeInt";
654
4037
  }(Constants || (Constants = {}));
4038
+ const noSerializeSet = /* @__PURE__ */ new WeakSet();
4039
+ const fastSkipSerialize = (obj) => noSerializeSet.has(obj);
4040
+ const noSerialize = (input) => (null != input && noSerializeSet.add(input), input);
4041
+ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
4042
+ let _containerEl;
4043
+ const qrl2 = async function(...args) {
4044
+ const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
4045
+ return await boundedFn(...args);
4046
+ };
4047
+ const setContainer = (el) => (_containerEl || (_containerEl = el), _containerEl);
4048
+ function bindFnToContext(currentCtx, beforeFn) {
4049
+ const bound = (...args) => {
4050
+ if (!qrl2.resolved) {
4051
+ return qrl2.resolve().then((fn) => {
4052
+ if (!isFunction(fn)) {
4053
+ throw qError(QError.qrlIsNotFunction);
4054
+ }
4055
+ return bound(...args);
4056
+ });
4057
+ }
4058
+ if (beforeFn && false === beforeFn()) {
4059
+ return;
4060
+ }
4061
+ const context = createOrReuseInvocationContext(currentCtx);
4062
+ const prevQrl = context.$qrl$;
4063
+ const prevEvent = context.$event$;
4064
+ context.$qrl$ = qrl2, context.$event$ || (context.$event$ = this);
4065
+ try {
4066
+ return invoke.call(this, context, symbolRef, ...args);
4067
+ } finally {
4068
+ context.$qrl$ = prevQrl, context.$event$ = prevEvent;
4069
+ }
4070
+ };
4071
+ return bound;
4072
+ }
4073
+ const wrapFn = (fn) => "function" != typeof fn || !capture?.length && !captureRef?.length ? fn : function(...args) {
4074
+ let context = tryGetInvokeContext();
4075
+ if (context) {
4076
+ if (context.$qrl$?.$symbol$ === qrl2.$symbol$) {
4077
+ return fn.apply(this, args);
4078
+ }
4079
+ const prevQrl = context.$qrl$;
4080
+ context.$qrl$ = qrl2;
4081
+ try {
4082
+ return fn.apply(this, args);
4083
+ } finally {
4084
+ context.$qrl$ = prevQrl;
4085
+ }
4086
+ }
4087
+ return context = newInvokeContext(), context.$qrl$ = qrl2, context.$event$ = this, invoke.call(this, context, fn, ...args);
4088
+ };
4089
+ const resolve = async (containerEl) => {
4090
+ if (null !== symbolRef) {
4091
+ return symbolRef;
4092
+ }
4093
+ if (containerEl && setContainer(containerEl), "" === chunk) {
4094
+ const hash2 = _containerEl.getAttribute("q:instance");
4095
+ const qFuncs = getQFuncs(_containerEl.ownerDocument, hash2);
4096
+ return qrl2.resolved = symbolRef = qFuncs[Number(symbol)];
4097
+ }
4098
+ const start = now();
4099
+ const ctx = tryGetInvokeContext();
4100
+ {
4101
+ const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
4102
+ symbolRef = maybeThen(imported, (ref) => qrl2.resolved = wrapFn(symbolRef = ref));
4103
+ }
4104
+ return "object" == typeof symbolRef && isPromise(symbolRef) && symbolRef.then(() => emitUsedSymbol(symbol, ctx?.$element$, start), (err) => {
4105
+ throw console.error(`qrl ${symbol} failed to load`, err), symbolRef = null, err;
4106
+ }), symbolRef;
4107
+ };
4108
+ const createOrReuseInvocationContext = (invoke2) => null == invoke2 ? newInvokeContext() : isArray(invoke2) ? newInvokeContextFromTuple(invoke2) : invoke2;
4109
+ const hash = getSymbolHash(symbol);
4110
+ return Object.assign(qrl2, {
4111
+ getSymbol: () => symbol,
4112
+ getHash: () => hash,
4113
+ getCaptured: () => captureRef,
4114
+ resolve,
4115
+ $resolveLazy$: (containerEl) => null !== symbolRef ? symbolRef : resolve(containerEl),
4116
+ $setContainer$: setContainer,
4117
+ $chunk$: chunk,
4118
+ $symbol$: symbol,
4119
+ $hash$: hash,
4120
+ getFn: bindFnToContext,
4121
+ $capture$: capture,
4122
+ $captureRef$: captureRef,
4123
+ dev: null,
4124
+ resolved: void 0
4125
+ }), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved) => qrl2.resolved = wrapFn(symbolRef = resolved))), qrl2;
4126
+ };
4127
+ const EMITTED = /* @__PURE__ */ new Set();
4128
+ const emitUsedSymbol = (symbol, element, reqTime) => {
4129
+ EMITTED.has(symbol) || (EMITTED.add(symbol), emitEvent("qsymbol", {
4130
+ symbol,
4131
+ element,
4132
+ reqTime
4133
+ }));
4134
+ };
4135
+ const emitEvent = (eventName, detail) => {
4136
+ isServerPlatform() || "object" != typeof document || document.dispatchEvent(new CustomEvent(eventName, {
4137
+ bubbles: false,
4138
+ detail
4139
+ }));
4140
+ };
4141
+ const now = () => isServerPlatform() ? 0 : "object" == typeof performance ? performance.now() : 0;
4142
+ const componentQrl = (componentQrl2) => {
4143
+ function QwikComponent(props, key, flags = 0) {
4144
+ const finalKey = componentQrl2.$hash$.slice(0, 4) + ":" + (key || "");
4145
+ const InnerCmp = () => {
4146
+ };
4147
+ return InnerCmp[SERIALIZABLE_STATE] = [componentQrl2], _jsxSplit(InnerCmp, props, null, props.children, flags, finalKey);
4148
+ }
4149
+ return QwikComponent[SERIALIZABLE_STATE] = [componentQrl2], QwikComponent;
4150
+ };
4151
+ const SERIALIZABLE_STATE = Symbol("serializable-data");
4152
+ const isQwikComponent = (component) => "function" == typeof component && void 0 !== component[SERIALIZABLE_STATE];
655
4153
  const insightsPing = core.sync$(
656
4154
  () => ((window2, document2, location2, navigator2, performance2, round, JSON_stringify) => {
657
4155
  var publicApiKey = __QI_KEY__, postUrl = __QI_URL__, getAttribute_s = "getAttribute", querySelector_s = "querySelector", manifest_s = "manifest", manifest_hash_s = `${manifest_s}-hash`, manifestHash_s = `${manifest_s}Hash`, version_s = "version", publicApiKey_s = "publicApiKey", sendBeacon_s = "sendBeacon", symbol_s = "symbol", length_s = "length", addEventListener_s = "addEventListener", route_s = "route", error_s = "error", stack_s = "stack", message_s = "message", symbols_s = `${symbol_s}s`, qVersion = document2[querySelector_s](`[q\\:${version_s}]`)?.[getAttribute_s](`q:${version_s}`) || "unknown", manifestHash = document2[querySelector_s](`[q\\:${manifest_hash_s}]`)?.[getAttribute_s](