@qwik.dev/core 2.0.0-alpha.9 → 2.0.0-beta.1

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