@qwik.dev/core 2.0.0-beta.30 → 2.0.0-beta.32

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/testing 2.0.0-beta.30-dev+5421ed4
3
+ * @qwik.dev/core/testing 2.0.0-beta.32-dev+0e29f8a
4
4
  * Copyright QwikDev. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
@@ -23773,6 +23773,7 @@ var isPrimitiveOrNullUndefined = (v) => {
23773
23773
  };
23774
23774
 
23775
23775
  // packages/qwik/src/core/shared/error/error.ts
23776
+ var baseUrl = "https://qwikdev-build-v2.qwik-8nx.pages.dev/docs/errors/#Q";
23776
23777
  var codeToText = (code2, ...parts) => {
23777
23778
  if (qDev) {
23778
23779
  const MAP = [
@@ -23850,8 +23851,10 @@ Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in
23850
23851
  // 32
23851
23852
  "SerializerSymbol function returned rejected promise",
23852
23853
  // 33
23853
- "Serialization Error: Cannot serialize function: {{0}}"
23854
+ "Serialization Error: Cannot serialize function: {{0}}",
23854
23855
  // 34
23856
+ "Cannot read .value of a clientOnly async signal during SSR. Use .loading to check state, or provide an initial value."
23857
+ // 35
23855
23858
  ];
23856
23859
  let text = MAP[code2] ?? "";
23857
23860
  if (parts.length) {
@@ -23865,7 +23868,7 @@ Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in
23865
23868
  }
23866
23869
  return `Code(Q${code2}): ${text}`;
23867
23870
  } else {
23868
- return `Code(Q${code2}) https://github.com/QwikDev/qwik/blob/build/v2/packages/qwik/src/core/shared/error/error.ts#${parts.join()}L${9 + code2}`;
23871
+ return `Code(Q${code2}) ${baseUrl}${code2}`;
23869
23872
  }
23870
23873
  };
23871
23874
  var qError = (code2, errorMessageArgs = []) => {
@@ -24169,56 +24172,59 @@ var useSequentialScope = () => {
24169
24172
 
24170
24173
  // packages/qwik/src/core/shared/utils/event-names.ts
24171
24174
  var EVENT_SUFFIX = "$";
24175
+ var DOM_CONTENT_LOADED_EVENT = "DOMContentLoaded";
24172
24176
  var isJsxPropertyAnEventName = (name) => {
24173
24177
  return name.endsWith(EVENT_SUFFIX) && (name.startsWith("on" /* on */) || name.startsWith("window:on" /* window */) || name.startsWith("document:on" /* document */));
24174
24178
  };
24175
24179
  var isHtmlAttributeAnEventName = (name) => {
24176
- return name.charCodeAt(0) === 113 && name.charCodeAt(1) === 45 && name.charCodeAt(3) === 58;
24180
+ return name.charCodeAt(0) === 113 && name.charCodeAt(1) === 45 && (name.charCodeAt(3) === 58 || name.charCodeAt(3) === 112 && name.charCodeAt(4) === 58);
24177
24181
  };
24178
- function jsxEventToHtmlAttribute(jsxEvent) {
24182
+ function jsxEventToHtmlAttribute(jsxEvent, isPassive = false) {
24179
24183
  if (jsxEvent.endsWith(EVENT_SUFFIX)) {
24180
- const [prefix, idx] = getEventScopeDataFromJsxEvent(jsxEvent);
24184
+ const [prefix, idx] = getEventScopeDataFromJsxEvent(jsxEvent, isPassive);
24181
24185
  if (idx !== -1) {
24182
- const name = jsxEvent.slice(idx, -1);
24183
- return name === "DOMContentLoaded" ? (
24184
- // The only DOM event that is not all lowercase
24185
- prefix + "-d-o-m-content-loaded"
24186
- ) : createEventName(
24187
- name.charAt(0) === "-" ? (
24188
- // marker for case sensitive event name
24189
- name.slice(1)
24190
- ) : name.toLowerCase(),
24191
- prefix
24192
- );
24186
+ return prefix + normalizeJsxEventName(jsxEvent.slice(idx, -1));
24193
24187
  }
24194
24188
  }
24195
24189
  return null;
24196
24190
  }
24197
- function createEventName(event, prefix) {
24191
+ function createEventName(event, prefix = "") {
24198
24192
  const eventName = fromCamelToKebabCase(event);
24199
24193
  return prefix + eventName;
24200
24194
  }
24201
- function getEventScopeDataFromJsxEvent(eventName) {
24195
+ function getEventScopeDataFromJsxEvent(eventName, isPassive = false) {
24202
24196
  let prefix;
24203
24197
  let idx = -1;
24204
24198
  if (eventName.startsWith("on" /* on */)) {
24205
- prefix = "q-e:" /* on */;
24199
+ prefix = isPassive ? "q-ep:" /* onPassive */ : "q-e:" /* on */;
24206
24200
  idx = 2;
24207
24201
  } else if (eventName.startsWith("window:on" /* window */)) {
24208
- prefix = "q-w:" /* window */;
24202
+ prefix = isPassive ? "q-wp:" /* windowPassive */ : "q-w:" /* window */;
24209
24203
  idx = 9;
24210
24204
  } else if (eventName.startsWith("document:on" /* document */)) {
24211
- prefix = "q-d:" /* document */;
24205
+ prefix = isPassive ? "q-dp:" /* documentPassive */ : "q-d:" /* document */;
24212
24206
  idx = 11;
24213
24207
  }
24214
24208
  return [prefix, idx];
24215
24209
  }
24210
+ var normalizeJsxEventName = (name) => {
24211
+ return name === DOM_CONTENT_LOADED_EVENT ? "-d-o-m-content-loaded" : createEventName(
24212
+ name.charAt(0) === "-" ? (
24213
+ // marker for case sensitive event name
24214
+ name.slice(1)
24215
+ ) : name.toLowerCase()
24216
+ );
24217
+ };
24216
24218
  function isPreventDefault(key) {
24217
24219
  return key.startsWith("preventdefault:");
24218
24220
  }
24219
24221
  var fromCamelToKebabCase = (text) => {
24220
24222
  return text.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());
24221
24223
  };
24224
+ var getEventDataFromHtmlAttribute = (htmlKey) => {
24225
+ const separatorIndex = htmlKey.indexOf(":");
24226
+ return [htmlKey.slice(2, separatorIndex), htmlKey.slice(separatorIndex + 1)];
24227
+ };
24222
24228
 
24223
24229
  // packages/qwik/src/core/use/use-context.ts
24224
24230
  import { isDev as isDev4 } from "@qwik.dev/core/build";
@@ -24287,7 +24293,106 @@ Object.freeze(EMPTY_ARRAY);
24287
24293
  Object.freeze(EMPTY_OBJ);
24288
24294
 
24289
24295
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
24290
- import { isBrowser as isBrowser3, isDev as isDev20 } from "@qwik.dev/core/build";
24296
+ import { isBrowser as isBrowser4, isDev as isDev20 } from "@qwik.dev/core/build";
24297
+
24298
+ // packages/qwik/src/core/shared/qrl/qrl-class-dev.ts
24299
+ import { isBrowser } from "@qwik.dev/core/build";
24300
+ var initLazyRefDev = (lazy) => {
24301
+ lazy.dev = null;
24302
+ if (typeof document !== "undefined") {
24303
+ lazy.qrls = /* @__PURE__ */ new Set();
24304
+ }
24305
+ };
24306
+ var initQrlClassDev = (lazy, captures, qrl) => {
24307
+ if (captures && typeof captures === "object") {
24308
+ for (let i = 0; i < captures.length; i++) {
24309
+ const item = captures[i];
24310
+ verifySerializable(item, "Captured variable in the closure can not be serialized");
24311
+ }
24312
+ }
24313
+ if (lazy.qrls) {
24314
+ lazy.qrls.add(new WeakRef(qrl));
24315
+ }
24316
+ };
24317
+ var setupHmr = (LazyRefClass, setGetLazyRef) => {
24318
+ if (!(isBrowser && import.meta.hot)) {
24319
+ return;
24320
+ }
24321
+ const allLazyRefs = /* @__PURE__ */ new Map();
24322
+ setGetLazyRef((chunk, symbol, symbolFn, ref, container) => {
24323
+ let lazyRef = allLazyRefs.get(symbol);
24324
+ if (!lazyRef) {
24325
+ lazyRef = new LazyRefClass(chunk, symbol, symbolFn, ref, container);
24326
+ if (chunk !== "") {
24327
+ allLazyRefs.set(symbol, lazyRef);
24328
+ }
24329
+ }
24330
+ return lazyRef;
24331
+ });
24332
+ const bustTimestamp = (url, t) => {
24333
+ const [path, query] = url.split("?", 2);
24334
+ if (!query) {
24335
+ return `${path}?t=${t}`;
24336
+ }
24337
+ const params = query.split("&").filter((p) => !p.startsWith("t="));
24338
+ params.push(`t=${t}`);
24339
+ return `${path}?${params.join("&")}`;
24340
+ };
24341
+ document.addEventListener("qHmr", (ev) => {
24342
+ const files = ev.detail.files;
24343
+ const t = ev.detail.t || document.__hmrT || Date.now();
24344
+ let didReload = false;
24345
+ for (const lazy of allLazyRefs.values()) {
24346
+ const devFile = lazy.dev?.file || lazy.$chunk$;
24347
+ if (!devFile || !files.some((file) => devFile.startsWith(file))) {
24348
+ continue;
24349
+ }
24350
+ const chunk = lazy.$chunk$;
24351
+ if (chunk) {
24352
+ lazy.$chunk$ = bustTimestamp(chunk, t);
24353
+ didReload = true;
24354
+ }
24355
+ const fnStr = lazy.$symbolFn$?.toString();
24356
+ if (fnStr) {
24357
+ const newStr = fnStr.replace(/import\((['"])(.+?)\1\)/, (match, p1, p2) => {
24358
+ const newPath = bustTimestamp(p2, t);
24359
+ return `import(${p1}${newPath}${p1})`;
24360
+ });
24361
+ if (newStr !== fnStr) {
24362
+ try {
24363
+ lazy.$symbolFn$ = new Function(`return (${newStr})`)();
24364
+ didReload = true;
24365
+ } catch (err) {
24366
+ console.error(`Failed to update symbolFn for ${lazy.$symbol$}`, err);
24367
+ }
24368
+ } else {
24369
+ console.warn(
24370
+ `Couldn't find import() in symbolFn for ${lazy.$symbol$}, cannot update it for HMR`,
24371
+ fnStr
24372
+ );
24373
+ }
24374
+ }
24375
+ if (didReload) {
24376
+ lazy.$ref$ = void 0;
24377
+ document.__hmrDone = document.__hmrT;
24378
+ if (lazy.qrls) {
24379
+ for (const qrlRef of lazy.qrls) {
24380
+ const qrl = qrlRef.deref();
24381
+ if (qrl) {
24382
+ if (qrl.resolved) {
24383
+ qrl.resolved = void 0;
24384
+ }
24385
+ } else {
24386
+ lazy.qrls.delete(qrlRef);
24387
+ }
24388
+ }
24389
+ }
24390
+ }
24391
+ }
24392
+ });
24393
+ };
24394
+
24395
+ // packages/qwik/src/core/shared/qrl/qrl-class.ts
24291
24396
  import { p as preload } from "@qwik.dev/core/preloader";
24292
24397
 
24293
24398
  // packages/qwik/src/core/shared/serdes/inflate.ts
@@ -24738,7 +24843,7 @@ var isPropsProxy = (obj) => {
24738
24843
  };
24739
24844
 
24740
24845
  // packages/qwik/src/core/reactive-primitives/impl/async-signal-impl.ts
24741
- import { isBrowser, isDev as isDev10, isServer as isServer5 } from "@qwik.dev/core/build";
24846
+ import { isBrowser as isBrowser2, isDev as isDev10, isServer as isServer5 } from "@qwik.dev/core/build";
24742
24847
 
24743
24848
  // packages/qwik/src/core/reactive-primitives/subscriber.ts
24744
24849
  import { isServer as isServer4 } from "@qwik.dev/core/build";
@@ -24800,7 +24905,8 @@ var cleanupFn = (target, handleError) => {
24800
24905
  target.$destroy$ = () => {
24801
24906
  target.$destroy$ = null;
24802
24907
  let cleanupPromises = null;
24803
- for (const fn2 of cleanupFns) {
24908
+ for (let i = 0; i < cleanupFns.length; i++) {
24909
+ const fn2 = cleanupFns[i];
24804
24910
  try {
24805
24911
  const result2 = fn2();
24806
24912
  if (isPromise(result2)) {
@@ -24904,15 +25010,16 @@ var log3 = (...args) => (
24904
25010
  console.log("ASYNC COMPUTED SIGNAL", ...args.map(qwikDebugToString))
24905
25011
  );
24906
25012
  var AsyncJob = class {
24907
- constructor($signal$) {
25013
+ constructor($signal$, info, $infoVersion$) {
24908
25014
  this.$signal$ = $signal$;
24909
25015
  /** First holds the compute promise and then the cleanup promise */
24910
25016
  __publicField(this, "$promise$", null);
24911
25017
  __publicField(this, "$cleanupRequested$", false);
24912
25018
  __publicField(this, "$canWrite$", true);
24913
- __publicField(this, "$track$");
24914
- __publicField(this, "$cleanups$");
24915
- __publicField(this, "$abortController$");
25019
+ if (info !== void 0) {
25020
+ this.info = info;
25021
+ this.$infoVersion$ = $infoVersion$;
25022
+ }
24916
25023
  }
24917
25024
  get track() {
24918
25025
  return this.$track$ || (this.$track$ = trackFn(this.$signal$, this.$signal$.$container$));
@@ -24923,7 +25030,7 @@ var AsyncJob = class {
24923
25030
  /** Backward compatible cache method for resource */
24924
25031
  cache() {
24925
25032
  isDev10 && console.error(
24926
- "useResource cache() method does not do anything. Use `useAsync$` instead of `useResource$`, use the `interval` option for polling behavior."
25033
+ "useResource cache() method does not do anything. Use `useAsync$` instead of `useResource$`, use the `expires` option for polling behavior."
24927
25034
  );
24928
25035
  }
24929
25036
  get previous() {
@@ -24944,37 +25051,45 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
24944
25051
  super(container, fn, flags);
24945
25052
  __publicField(this, "$untrackedLoading$", false);
24946
25053
  __publicField(this, "$untrackedError$");
24947
- __publicField(this, "$loadingEffects$");
24948
- __publicField(this, "$errorEffects$");
24949
25054
  __publicField(this, "$current$", null);
24950
- // TODO only create the array if concurrency > 1
24951
- __publicField(this, "$jobs$", []);
24952
- __publicField(this, "$concurrency$", 1);
24953
- __publicField(this, "$interval$", 0);
24954
- __publicField(this, "$timeoutMs$");
24955
25055
  __publicField(this, _a3);
24956
- const interval = options?.interval;
24957
- const concurrency = options?.concurrency ?? 1;
24958
- const initial = options?.initial;
24959
- const timeout = options?.timeout;
24960
- const eagerCleanup = options?.eagerCleanup;
24961
- const clientOnly = options?.clientOnly;
25056
+ if (!options) {
25057
+ return;
25058
+ }
25059
+ const initial = options.initial;
24962
25060
  if (initial !== void 0) {
24963
25061
  const initialValue = typeof initial === "function" ? initial() : initial;
24964
25062
  this.$untrackedValue$ = initialValue;
24965
25063
  }
24966
- this.$concurrency$ = concurrency;
25064
+ const concurrency = options.concurrency;
25065
+ if (concurrency !== void 0 && concurrency >= 0 && concurrency !== 1) {
25066
+ this.$concurrency$ = concurrency;
25067
+ this.$jobs$ = [];
25068
+ }
25069
+ const timeout = options.timeout;
24967
25070
  if (timeout) {
24968
25071
  this.$timeoutMs$ = timeout;
24969
25072
  }
24970
- if (eagerCleanup) {
25073
+ if (options.eagerCleanup) {
24971
25074
  this.$flags$ |= 32 /* EAGER_CLEANUP */;
24972
25075
  }
24973
- if (clientOnly) {
25076
+ if (options.clientOnly) {
24974
25077
  this.$flags$ |= 64 /* CLIENT_ONLY */;
24975
25078
  }
24976
- if (interval) {
24977
- this.interval = interval;
25079
+ if (options.allowStale === false) {
25080
+ if (isDev10 && initial !== void 0) {
25081
+ throw new Error(
25082
+ "allowStale: false and initial cannot be used together. allowStale: false clears the value on invalidation, which conflicts with providing an initial value."
25083
+ );
25084
+ }
25085
+ this.$flags$ |= 128 /* CLEAR_ON_INVALIDATE */;
25086
+ }
25087
+ const expires = options.expires ?? (options.interval ? Math.abs(options.interval) : void 0);
25088
+ if (expires) {
25089
+ this.expires = expires;
25090
+ }
25091
+ if (options.poll === false || options.interval !== void 0 && options.interval < 0) {
25092
+ this.$flags$ |= 256 /* NO_POLL */;
24978
25093
  }
24979
25094
  }
24980
25095
  get untrackedValue() {
@@ -24992,15 +25107,43 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
24992
25107
  throw this.$untrackedError$;
24993
25108
  }
24994
25109
  if ((import.meta.env.TEST ? isServerPlatform() : isServer5) && this.$flags$ & 64 /* CLIENT_ONLY */ && this.$untrackedValue$ === NEEDS_COMPUTATION) {
24995
- throw new Error(
24996
- isDev10 ? "During SSR, cannot read .value from clientOnly async signal without an initial value. Use .loading or provide an initial value." : "Cannot read .value from clientOnly"
24997
- );
25110
+ throw qError(35 /* asyncClientOnlyValueDuringSSR */);
24998
25111
  }
24999
25112
  return this.$untrackedValue$;
25000
25113
  }
25001
25114
  set untrackedValue(value) {
25002
25115
  this.$untrackedValue$ = value;
25003
25116
  }
25117
+ /**
25118
+ * Read the value, subscribing if in a tracking context. Triggers computation if needed.
25119
+ *
25120
+ * Setting the value will mark the signal as not loading and clear any error, and prevent any
25121
+ * pending computations from writing their results.
25122
+ *
25123
+ * If you want to set the value without affecting loading or error state, set `untrackedValue`
25124
+ * instead and make sure to trigger effects manually if needed.
25125
+ *
25126
+ * If you want to abort pending computations when setting, you have to call `abort()` manually.
25127
+ */
25128
+ get value() {
25129
+ return super.value;
25130
+ }
25131
+ set value(value) {
25132
+ this.$flags$ &= ~1 /* INVALID */;
25133
+ this.untrackedLoading = false;
25134
+ this.untrackedError = void 0;
25135
+ this.$info$ = void 0;
25136
+ if (this.$jobs$) {
25137
+ for (let i = 0; i < this.$jobs$.length; i++) {
25138
+ this.$jobs$[i].$canWrite$ = false;
25139
+ }
25140
+ } else if (this.$current$) {
25141
+ this.$current$.$canWrite$ = false;
25142
+ }
25143
+ this.$clearNextPoll$();
25144
+ super.value = value;
25145
+ this.$scheduleNextPoll$();
25146
+ }
25004
25147
  /**
25005
25148
  * Loading is true if the signal is still waiting for the promise to resolve, false if the promise
25006
25149
  * has resolved or rejected.
@@ -25067,23 +25210,59 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
25067
25210
  get untrackedError() {
25068
25211
  return this.$untrackedError$;
25069
25212
  }
25070
- get interval() {
25071
- return this.$interval$;
25213
+ get expires() {
25214
+ return this.$expires$ || 0;
25072
25215
  }
25073
- set interval(value) {
25216
+ set expires(value) {
25074
25217
  this.$clearNextPoll$();
25075
- this.$interval$ = value;
25076
- if (this.$interval$ > 0 && this.$effects$?.size) {
25218
+ this.$expires$ = value;
25219
+ if (this.$expires$ && this.$hasSubscribers$()) {
25220
+ this.$scheduleNextPoll$();
25221
+ }
25222
+ }
25223
+ get poll() {
25224
+ return !(this.$flags$ & 256 /* NO_POLL */);
25225
+ }
25226
+ set poll(value) {
25227
+ if (value) {
25228
+ this.$flags$ &= ~256 /* NO_POLL */;
25229
+ } else {
25230
+ this.$flags$ |= 256 /* NO_POLL */;
25231
+ }
25232
+ if (this.$expires$ && this.$hasSubscribers$()) {
25233
+ this.$clearNextPoll$();
25077
25234
  this.$scheduleNextPoll$();
25078
25235
  }
25079
25236
  }
25237
+ /** @deprecated Use `expires` and `poll` instead. */
25238
+ get interval() {
25239
+ const expires = this.$expires$ || 0;
25240
+ return this.$flags$ & 256 /* NO_POLL */ ? -expires : expires;
25241
+ }
25242
+ set interval(value) {
25243
+ if (value < 0) {
25244
+ this.$flags$ |= 256 /* NO_POLL */;
25245
+ } else {
25246
+ this.$flags$ &= ~256 /* NO_POLL */;
25247
+ }
25248
+ this.expires = Math.abs(value);
25249
+ }
25080
25250
  /** Invalidates the signal, causing it to re-compute its value. */
25081
- async invalidate() {
25251
+ async invalidate(info) {
25252
+ if (arguments.length > 0) {
25253
+ this.$info$ = info;
25254
+ this.$infoVersion$ = this.$infoVersion$ === void 0 ? 1 : this.$infoVersion$ + 1;
25255
+ }
25256
+ this.$setInvalid$(true, this.$flags$ & 128 /* CLEAR_ON_INVALIDATE */);
25257
+ }
25258
+ $setInvalid$(allowRecalc, mustClear) {
25082
25259
  this.$flags$ |= 1 /* INVALID */;
25083
25260
  this.$clearNextPoll$();
25084
- if (this.$effects$?.size || this.$loadingEffects$?.size || this.$errorEffects$?.size) {
25085
- await true;
25086
- this.$computeIfNeeded$();
25261
+ if (mustClear) {
25262
+ this.$untrackedValue$ = NEEDS_COMPUTATION;
25263
+ }
25264
+ if (allowRecalc && (this.$effects$?.size || this.$loadingEffects$?.size || this.$errorEffects$?.size)) {
25265
+ Promise.resolve().then(() => this.$computeIfNeeded$());
25087
25266
  }
25088
25267
  }
25089
25268
  /** Abort the current computation and run cleanups if needed. */
@@ -25097,7 +25276,7 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
25097
25276
  if (!(this.$flags$ & 32 /* EAGER_CLEANUP */) || this.$hasSubscribers$()) {
25098
25277
  return;
25099
25278
  }
25100
- if (!(import.meta.env.TEST ? !isServerPlatform() : isBrowser)) {
25279
+ if (!(import.meta.env.TEST ? !isServerPlatform() : isBrowser2)) {
25101
25280
  return;
25102
25281
  }
25103
25282
  setTimeout(() => {
@@ -25124,58 +25303,75 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
25124
25303
  return;
25125
25304
  }
25126
25305
  this.$clearNextPoll$();
25127
- if (this.$current$) {
25128
- this.$requestCleanups$(this.$current$);
25306
+ this.$flags$ &= ~1 /* INVALID */;
25307
+ const current = this.$current$;
25308
+ if (current) {
25309
+ this.$requestCleanups$(current);
25129
25310
  }
25130
- const limit = this.$concurrency$ === 0 ? Number.POSITIVE_INFINITY : this.$concurrency$;
25131
- if (this.$jobs$.length >= limit) {
25311
+ const limit = this.$concurrency$ === 0 ? Number.POSITIVE_INFINITY : this.$concurrency$ ?? 1;
25312
+ if (this.$jobs$ ? this.$jobs$.length >= limit : current?.$promise$) {
25132
25313
  DEBUG3 && log3(`Concurrency limit ${limit} reached, not starting new computation`);
25314
+ this.$flags$ |= 1 /* INVALID */;
25133
25315
  return;
25134
25316
  }
25135
25317
  DEBUG3 && log3("Starting new async computation");
25136
- this.$flags$ &= ~1 /* INVALID */;
25137
- const running = new AsyncJob(this);
25318
+ const infoVersion = this.$infoVersion$;
25319
+ const running = new AsyncJob(this, this.$info$, infoVersion);
25138
25320
  this.$current$ = running;
25139
- this.$jobs$.push(running);
25321
+ if (this.$jobs$) {
25322
+ this.$jobs$.push(running);
25323
+ }
25140
25324
  running.$promise$ = this.$runComputation$(running);
25141
25325
  }
25142
25326
  async $runComputation$(running) {
25143
25327
  const isCurrent = () => running === this.$current$;
25144
25328
  this.untrackedLoading = true;
25145
- const fn = this.$computeQrl$.resolved || await this.$computeQrl$.resolve();
25329
+ let fn = this.$computeQrl$.resolved;
25330
+ if (!fn) {
25331
+ fn = await this.$computeQrl$.resolve();
25332
+ if (running.$abortController$?.signal.aborted) {
25333
+ DEBUG3 && log3("Computation aborted before it started");
25334
+ running.$promise$ = null;
25335
+ return;
25336
+ }
25337
+ }
25146
25338
  try {
25147
25339
  if (this.$timeoutMs$) {
25148
25340
  this.$computationTimeoutId$ = setTimeout(() => {
25149
- running.$abortController$?.abort();
25150
- const error = new Error(`timeout`);
25151
- if (isCurrent()) {
25152
- this.untrackedError = error;
25153
- running.$canWrite$ = false;
25154
- }
25341
+ const error = new Error(`timeout ${this.$timeoutMs$}ms`);
25342
+ this.$setError$(running, error);
25343
+ running.$abortController$?.abort(error);
25155
25344
  }, this.$timeoutMs$);
25156
25345
  }
25157
- const value = await retryOnPromise(fn.bind(null, running));
25346
+ const valuePromise = retryOnPromise(fn.bind(null, running));
25347
+ const value = isPromise(valuePromise) ? await valuePromise : valuePromise;
25158
25348
  running.$promise$ = null;
25159
25349
  if (running.$canWrite$) {
25160
- const index = this.$jobs$.indexOf(running);
25161
- if (index !== -1) {
25162
- for (let i = 0; i < index; i++) {
25163
- this.$jobs$[i].$canWrite$ = false;
25350
+ const jobs = this.$jobs$;
25351
+ if (jobs) {
25352
+ let doDisable = false;
25353
+ for (let i = jobs.length - 1; i >= 0; i--) {
25354
+ if (jobs[i] === running) {
25355
+ doDisable = true;
25356
+ } else if (doDisable) {
25357
+ jobs[i].$canWrite$ = false;
25358
+ }
25164
25359
  }
25165
25360
  }
25166
25361
  DEBUG3 && log3("Promise resolved", value);
25167
25362
  this.untrackedError = void 0;
25168
- this.value = value;
25363
+ super.value = value;
25169
25364
  }
25170
25365
  } catch (err) {
25171
25366
  running.$promise$ = null;
25172
25367
  DEBUG3 && log3("Error caught in promise.catch", err);
25173
- if (isCurrent()) {
25174
- this.untrackedError = err;
25175
- }
25368
+ this.$setError$(running, err);
25176
25369
  }
25177
25370
  if (isCurrent()) {
25178
25371
  clearTimeout(this.$computationTimeoutId$);
25372
+ if (running.$infoVersion$ === this.$infoVersion$) {
25373
+ this.$info$ = void 0;
25374
+ }
25179
25375
  if (this.$flags$ & 1 /* INVALID */) {
25180
25376
  DEBUG3 && log3("Computation finished but signal is invalid, re-running");
25181
25377
  this.$computeIfNeeded$();
@@ -25185,14 +25381,34 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
25185
25381
  }
25186
25382
  }
25187
25383
  }
25384
+ /**
25385
+ * Sets the error from the given job. We only accept errors from the current job and we ignore
25386
+ * AbortErrors.
25387
+ */
25388
+ $setError$(job, error) {
25389
+ if (job !== this.$current$ || !job.$canWrite$) {
25390
+ return;
25391
+ }
25392
+ job.$canWrite$ = false;
25393
+ if (error instanceof Error && error.name === "AbortError") {
25394
+ return;
25395
+ }
25396
+ this.untrackedError = error;
25397
+ this.untrackedValue = NEEDS_COMPUTATION;
25398
+ }
25188
25399
  /** Called after SSR/unmount */
25189
25400
  async $destroy$() {
25190
25401
  this.$clearNextPoll$();
25191
25402
  clearTimeout(this.$computationTimeoutId$);
25192
- if (this.$current$) {
25193
- await this.$requestCleanups$(this.$current$);
25403
+ const current = this.$current$;
25404
+ if (current) {
25405
+ this.$requestCleanups$(current);
25406
+ }
25407
+ if (this.$jobs$) {
25408
+ await Promise.all(this.$jobs$.map((job) => job.$promise$));
25409
+ } else {
25410
+ await current?.$promise$;
25194
25411
  }
25195
- await Promise.all(this.$jobs$.map((job) => job.$promise$));
25196
25412
  }
25197
25413
  $clearNextPoll$() {
25198
25414
  if (this.$pollTimeoutId$ !== void 0) {
@@ -25201,61 +25417,76 @@ var AsyncSignalImpl = class extends (_b2 = ComputedSignalImpl, _a3 = _EFFECT_BAC
25201
25417
  }
25202
25418
  }
25203
25419
  $scheduleNextPoll$() {
25204
- if ((import.meta.env.TEST ? !isServerPlatform() : isBrowser) && this.$interval$ > 0) {
25205
- this.$clearNextPoll$();
25206
- this.$pollTimeoutId$ = setTimeout(this.invalidate.bind(this), this.$interval$);
25207
- this.$pollTimeoutId$?.unref?.();
25420
+ if ((import.meta.env.TEST ? isServerPlatform() : isServer5) || !this.$expires$) {
25421
+ return;
25208
25422
  }
25423
+ this.$clearNextPoll$();
25424
+ const allowRecalc = !(this.$flags$ & 256 /* NO_POLL */);
25425
+ const mustClear = this.$flags$ & 128 /* CLEAR_ON_INVALIDATE */ && !allowRecalc;
25426
+ this.$pollTimeoutId$ = setTimeout(
25427
+ () => this.$setInvalid$(allowRecalc, mustClear),
25428
+ this.$expires$
25429
+ );
25430
+ this.$pollTimeoutId$?.unref?.();
25209
25431
  }
25210
25432
  $hasSubscribers$() {
25211
25433
  return !!(this.$effects$?.size || this.$loadingEffects$?.size || this.$errorEffects$?.size);
25212
25434
  }
25213
- async $requestCleanups$(job, reason) {
25435
+ $requestCleanups$(job, reason) {
25214
25436
  if (job.$cleanupRequested$) {
25215
- return job.$promise$;
25437
+ return;
25216
25438
  }
25217
25439
  DEBUG3 && log3("Requesting cleanups for job", job);
25218
25440
  job.$cleanupRequested$ = true;
25219
25441
  job.$abortController$?.abort(reason);
25220
- job.$promise$ = Promise.resolve(job.$promise$).then(
25221
- () => job.$promise$ = this.$runCleanups$(job)
25222
- );
25442
+ job.$promise$ = maybeThen(job.$promise$, () => this.$runCleanups$(job));
25223
25443
  }
25224
25444
  /** Clean up and trigger signal compute once complete */
25225
- async $runCleanups$(job) {
25445
+ $runCleanups$(job) {
25226
25446
  const cleanups = job.$cleanups$;
25227
- if (cleanups?.length) {
25228
- DEBUG3 && log3("cleanup start", job);
25229
- const onError = (err) => {
25230
- const handleError = this.$container$?.handleError;
25231
- if (handleError) {
25232
- handleError(err, null);
25233
- } else {
25234
- console.error("Error in async signal cleanup", err);
25447
+ DEBUG3 && log3("cleanup start", job);
25448
+ const onError = (err) => {
25449
+ const handleError = this.$container$?.handleError;
25450
+ if (handleError) {
25451
+ handleError(err, null);
25452
+ } else {
25453
+ console.error("Error in async signal cleanup", err);
25454
+ }
25455
+ };
25456
+ const onDone = () => {
25457
+ job.$promise$ = null;
25458
+ if (cleanups) {
25459
+ cleanups.length = 0;
25460
+ }
25461
+ DEBUG3 && log3("cleanup finished", job);
25462
+ const jobs = this.$jobs$;
25463
+ if (jobs) {
25464
+ const idx = jobs.indexOf(job);
25465
+ if (idx !== -1) {
25466
+ jobs.splice(idx, 1);
25235
25467
  }
25236
- };
25468
+ }
25469
+ this.$computeIfNeeded$();
25470
+ };
25471
+ let promiseChain = void 0;
25472
+ if (cleanups) {
25237
25473
  DEBUG3 && log3("cleanup start for real", job);
25238
- await Promise.all(
25239
- cleanups.map((fn) => {
25240
- try {
25241
- const result2 = fn();
25242
- if (isPromise(result2)) {
25243
- return result2.catch(onError);
25244
- }
25245
- } catch (err) {
25246
- onError(err);
25474
+ for (let i = 0; i < cleanups.length; i++) {
25475
+ try {
25476
+ const result2 = cleanups[i]();
25477
+ if (isPromise(result2)) {
25478
+ promiseChain = (promiseChain ? promiseChain.then(() => result2) : result2).catch(onError);
25247
25479
  }
25248
- })
25249
- );
25250
- cleanups.length = 0;
25251
- DEBUG3 && log3("cleanup finished", job);
25480
+ } catch (err) {
25481
+ onError(err);
25482
+ }
25483
+ }
25252
25484
  }
25253
- const jobs = this.$jobs$;
25254
- const idx = jobs.indexOf(job);
25255
- if (idx !== -1) {
25256
- jobs.splice(idx, 1);
25485
+ if (promiseChain) {
25486
+ return promiseChain.then(onDone);
25487
+ } else {
25488
+ onDone();
25257
25489
  }
25258
- this.$computeIfNeeded$();
25259
25490
  }
25260
25491
  };
25261
25492
 
@@ -25398,6 +25629,7 @@ function removeCursorFromQueue(cursor, container, keepCursorFlag) {
25398
25629
  var cursorDatas = /* @__PURE__ */ new WeakMap();
25399
25630
  var NODE_PROPS_DATA_KEY = ":nodeProps";
25400
25631
  var NODE_DIFF_DATA_KEY = ":nodeDiff";
25632
+ var ERROR_DATA_KEY = ":errorData";
25401
25633
  var HOST_SIGNAL = ":signal";
25402
25634
  function setCursorPosition(container, cursorData, position) {
25403
25635
  cursorData.position = position;
@@ -25650,8 +25882,9 @@ function addUseOnEvents(jsx2, useOnEvents) {
25650
25882
  targetElement = placeholderElement;
25651
25883
  } else {
25652
25884
  if (isDev12) {
25885
+ const sourceLocation = getUseOnSourceLocation(useOnEvents[key].qrls);
25653
25886
  logWarn(
25654
- 'You are trying to add an event "' + key + '" using `useOn` hook, but a node to which you can add an event is not found. Please make sure that the component has a valid element node. '
25887
+ 'You are trying to add an event "' + key + '" using `useOn` hook, but a node to which you can add an event is not found. Please make sure that the component outputs a DOM element.' + (sourceLocation ? ` Offending \`useOn\`: ${sourceLocation}.` : "")
25655
25888
  );
25656
25889
  }
25657
25890
  continue;
@@ -25661,8 +25894,9 @@ function addUseOnEvents(jsx2, useOnEvents) {
25661
25894
  if (targetElement.type === "script" && key === qVisibleEvent) {
25662
25895
  eventKey = "q-d:qinit";
25663
25896
  if (isDev12) {
25897
+ const sourceLocation = getUseOnSourceLocation(useOnEvents[key].qrls);
25664
25898
  logWarn(
25665
- 'You are trying to add an event "' + key + '" using the `useVisibleTask$` hook with the "intersection-observer" strategy, but a node to which you can add an event is not found. Using "document-ready" or "document-idle" instead.'
25899
+ `You are trying to add the event "${key}" using the \`useVisibleTask$\` hook with the "intersection-observer" strategy, but this only works when the component outputs a DOM element. Falling back to "document-ready" instead.` + (sourceLocation ? ` Offending \`useVisibleTask$\`: ${sourceLocation}.` : "")
25666
25900
  );
25667
25901
  }
25668
25902
  }
@@ -25673,25 +25907,57 @@ function addUseOnEvents(jsx2, useOnEvents) {
25673
25907
  return jsxResult;
25674
25908
  });
25675
25909
  }
25910
+ function getUseOnSourceLocation(eventQrls) {
25911
+ for (let i = 0; i < eventQrls.length; i++) {
25912
+ const eventQrl = eventQrls[i];
25913
+ const task = eventQrl?.getCaptured()?.[0];
25914
+ if (isTask(task)) {
25915
+ const dev = task.$qrl$.dev;
25916
+ if (dev?.file) {
25917
+ return typeof dev.lo === "number" && typeof dev.hi === "number" ? `${dev.file}:${dev.lo}-${dev.hi}` : dev.file;
25918
+ }
25919
+ }
25920
+ }
25921
+ return null;
25922
+ }
25676
25923
  function addUseOnEvent(jsxElement, key, value) {
25677
25924
  const props = jsxElement.constProps || (jsxElement.constProps = {});
25678
25925
  const propValue = props[key];
25926
+ const qrls = value.qrls;
25679
25927
  if (propValue == null) {
25680
- props[key] = value;
25928
+ props[key] = qrls;
25681
25929
  } else if (Array.isArray(propValue)) {
25682
- propValue.push(...value);
25930
+ propValue.push(...qrls);
25683
25931
  } else {
25684
- props[key] = [propValue, ...value];
25932
+ props[key] = [propValue, ...qrls];
25685
25933
  }
25686
25934
  const varProp = jsxElement.varProps[key];
25687
25935
  if (varProp) {
25688
25936
  if (Array.isArray(propValue)) {
25689
25937
  propValue.push(...props[key]);
25690
25938
  } else {
25691
- jsxElement.varProps[key] = [propValue, ...value];
25939
+ jsxElement.varProps[key] = [propValue, ...qrls];
25692
25940
  }
25693
25941
  props[key] = void 0;
25694
25942
  }
25943
+ const capture = value.capture;
25944
+ const preventdefault = value.preventdefault;
25945
+ const stoppropagation = value.stoppropagation;
25946
+ if (!capture && !preventdefault && !stoppropagation) {
25947
+ return;
25948
+ }
25949
+ const [, eventName] = getEventDataFromHtmlAttribute(key);
25950
+ capture && addUseOnModifier(jsxElement, eventName, "capture");
25951
+ preventdefault && addUseOnModifier(jsxElement, eventName, "preventdefault");
25952
+ stoppropagation && addUseOnModifier(jsxElement, eventName, "stoppropagation");
25953
+ }
25954
+ function addUseOnModifier(jsxElement, eventName, modifier) {
25955
+ const key = `${modifier}:${eventName}`;
25956
+ const varProps = jsxElement.varProps;
25957
+ if (varProps === EMPTY_OBJ) {
25958
+ jsxElement.varProps = {};
25959
+ }
25960
+ jsxElement.varProps[key] = true;
25695
25961
  }
25696
25962
  function findFirstElementNode(jsx2) {
25697
25963
  const queue2 = [jsx2];
@@ -25770,13 +26036,15 @@ var vnode_getElementNamespaceFlags = (element) => {
25770
26036
  };
25771
26037
  function cloneDomTreeWithNamespace(element, elementName, namespace, deep = false) {
25772
26038
  const newElement = element.ownerDocument.createElementNS(namespace, elementName);
25773
- for (const attr of element.attributes) {
26039
+ for (let i = 0; i < element.attributes.length; i++) {
26040
+ const attr = element.attributes[i];
25774
26041
  if (attr.name !== Q_PROPS_SEPARATOR) {
25775
26042
  newElement.setAttribute(attr.name, attr.value);
25776
26043
  }
25777
26044
  }
25778
26045
  if (deep) {
25779
- for (const child of element.childNodes) {
26046
+ for (let i = 0; i < element.childNodes.length; i++) {
26047
+ const child = element.childNodes[i];
25780
26048
  const nodeType = child.nodeType;
25781
26049
  if (nodeType === 3) {
25782
26050
  newElement.appendChild(child.cloneNode());
@@ -26415,7 +26683,8 @@ var serializeClass = (obj) => {
26415
26683
  }
26416
26684
  const classes = [];
26417
26685
  if (isArray(obj)) {
26418
- for (const o of obj) {
26686
+ for (let i = 0; i < obj.length; i++) {
26687
+ const o = obj[i];
26419
26688
  const classList = serializeClass(o);
26420
26689
  if (classList) {
26421
26690
  classes.push(classList);
@@ -27038,15 +27307,16 @@ function getSlotNameKey(diffContext, vHost) {
27038
27307
  return directGetPropsProxyProp(jsxNode, "name") || QDefaultSlot;
27039
27308
  }
27040
27309
  function cleanupSideBuffer(diffContext) {
27041
- if (diffContext.$vSideBuffer$) {
27042
- for (const vNode of diffContext.$vSideBuffer$.values()) {
27310
+ const sideBuffer = diffContext.$vSideBuffer$;
27311
+ if (sideBuffer) {
27312
+ for (const vNode of sideBuffer.values()) {
27043
27313
  if (vNode.flags & 32 /* Deleted */) {
27044
27314
  continue;
27045
27315
  }
27046
27316
  cleanup(diffContext.$container$, diffContext.$journal$, vNode, diffContext.$cursor$);
27047
27317
  vnode_remove(diffContext.$journal$, diffContext.$vParent$, vNode, true);
27048
27318
  }
27049
- diffContext.$vSideBuffer$.clear();
27319
+ sideBuffer.clear();
27050
27320
  diffContext.$vSideBuffer$ = null;
27051
27321
  }
27052
27322
  diffContext.$vCurrent$ = null;
@@ -27849,7 +28119,9 @@ function cleanup(container, journal, vNode, cursorRoot = null) {
27849
28119
  }
27850
28120
  const attrs = vCursor.props;
27851
28121
  if (attrs) {
27852
- for (const key of Object.keys(attrs)) {
28122
+ const keys = Object.keys(attrs);
28123
+ for (let i = 0; i < keys.length; i++) {
28124
+ const key = keys[i];
27853
28125
  if (isSlotProp(key)) {
27854
28126
  const value = attrs[key];
27855
28127
  if (value) {
@@ -27948,7 +28220,8 @@ function containsWrappedSignal(data, signal) {
27948
28220
  if (!(signal instanceof WrappedSignalImpl)) {
27949
28221
  return false;
27950
28222
  }
27951
- for (const item of data) {
28223
+ for (let i = 0; i < data.length; i++) {
28224
+ const item = data[i];
27952
28225
  if (item instanceof WrappedSignalImpl && areWrappedSignalsEqual(item, signal)) {
27953
28226
  return true;
27954
28227
  }
@@ -28218,7 +28491,8 @@ function executeTasks(vNode, container, cursorData) {
28218
28491
  return;
28219
28492
  }
28220
28493
  let taskPromise;
28221
- for (const item of elementSeq) {
28494
+ for (let i = 0; i < elementSeq.length; i++) {
28495
+ const item = elementSeq[i];
28222
28496
  if (item instanceof Task) {
28223
28497
  const task = item;
28224
28498
  if (!(task.$flags$ & 4 /* DIRTY */)) {
@@ -28249,6 +28523,36 @@ function setNodeDiffPayload(vNode, payload) {
28249
28523
  const props = vNode.props || (vNode.props = {});
28250
28524
  props[NODE_DIFF_DATA_KEY] = payload;
28251
28525
  }
28526
+ function getErrorPayload(vNode) {
28527
+ const props = vNode.props;
28528
+ return props?.[ERROR_DATA_KEY] ?? null;
28529
+ }
28530
+ function setErrorPayload(vNode, error) {
28531
+ const props = vNode.props || (vNode.props = {});
28532
+ props[ERROR_DATA_KEY] = error;
28533
+ }
28534
+ function executeErrorWrap(vNode, journal) {
28535
+ vNode.dirty &= ~256 /* ERROR_WRAP */;
28536
+ const err = getErrorPayload(vNode);
28537
+ if (!err) {
28538
+ return;
28539
+ }
28540
+ setErrorPayload(vNode, null);
28541
+ const vHost = vNode;
28542
+ const vHostParent = vHost.parent;
28543
+ const vHostNextSibling = vHost.nextSibling;
28544
+ const vErrorDiv = vnode_createErrorDiv(journal, document, vHost, err);
28545
+ const insertHost = vnode_isElementVNode(vHost) ? vHostParent || vHost : vHost;
28546
+ const insertBefore = insertHost === vHost ? null : vHostNextSibling;
28547
+ vnode_insertElementBefore(
28548
+ journal,
28549
+ insertHost,
28550
+ vErrorDiv,
28551
+ insertBefore
28552
+ );
28553
+ vNode.dirty &= ~32 /* CHILDREN */;
28554
+ vNode.dirtyChildren = null;
28555
+ }
28252
28556
  function executeNodeDiff(vNode, container, journal, cursor) {
28253
28557
  vNode.dirty &= ~2 /* NODE_DIFF */;
28254
28558
  const domVNode = vNode;
@@ -28358,7 +28662,8 @@ function executeCleanup(vNode, container) {
28358
28662
  if (!elementSeq || elementSeq.length === 0) {
28359
28663
  return;
28360
28664
  }
28361
- for (const item of elementSeq) {
28665
+ for (let i = 0; i < elementSeq.length; i++) {
28666
+ const item = elementSeq[i];
28362
28667
  if (item instanceof Task) {
28363
28668
  if (item.$flags$ & 16 /* NEEDS_CLEANUP */) {
28364
28669
  item.$flags$ &= ~16 /* NEEDS_CLEANUP */;
@@ -28557,8 +28862,8 @@ function executeAfterFlush(container, cursorData) {
28557
28862
  visibleTasks.map((t) => t.$qrl$.$symbol$)
28558
28863
  );
28559
28864
  let visibleTaskPromise;
28560
- for (const visibleTask of visibleTasks) {
28561
- const task = visibleTask;
28865
+ for (let i = 0; i < visibleTasks.length; i++) {
28866
+ const task = visibleTasks[i];
28562
28867
  const result2 = runTask(task, container, task.$el$);
28563
28868
  if (isPromise(result2)) {
28564
28869
  visibleTaskPromise = visibleTaskPromise ? visibleTaskPromise.then(() => result2) : result2;
@@ -28597,7 +28902,7 @@ var createMacroTask = (fn) => {
28597
28902
  };
28598
28903
 
28599
28904
  // packages/qwik/src/core/shared/cursor/cursor-walker.ts
28600
- import { isBrowser as isBrowser2, isDev as isDev16, isServer as isServer7 } from "@qwik.dev/core/build";
28905
+ import { isBrowser as isBrowser3, isDev as isDev16, isServer as isServer7 } from "@qwik.dev/core/build";
28601
28906
  var DEBUG6 = false;
28602
28907
  var nextMicroTask = createMicroTask(processCursorQueue);
28603
28908
  var nextMacroTask = createMacroTask(processCursorQueue);
@@ -28650,7 +28955,7 @@ function walkCursor(cursor, options) {
28650
28955
  if (cursorData.promise) {
28651
28956
  return;
28652
28957
  }
28653
- if (!(currentVNode.dirty & 255 /* DIRTY_MASK */)) {
28958
+ if (!(currentVNode.dirty & 511 /* DIRTY_MASK */)) {
28654
28959
  setCursorPosition(container, cursorData, getNextVNode(currentVNode, cursor));
28655
28960
  continue;
28656
28961
  }
@@ -28664,7 +28969,7 @@ function walkCursor(cursor, options) {
28664
28969
  continue;
28665
28970
  }
28666
28971
  }
28667
- currentVNode.dirty &= ~255 /* DIRTY_MASK */;
28972
+ currentVNode.dirty &= ~511 /* DIRTY_MASK */;
28668
28973
  setCursorPosition(container, cursorData, getNextVNode(currentVNode, cursor));
28669
28974
  continue;
28670
28975
  }
@@ -28688,6 +28993,8 @@ function walkCursor(cursor, options) {
28688
28993
  currentVNode = next;
28689
28994
  continue;
28690
28995
  }
28996
+ } else if (currentVNode.dirty & 256 /* ERROR_WRAP */) {
28997
+ executeErrorWrap(currentVNode, journal);
28691
28998
  }
28692
28999
  } catch (error) {
28693
29000
  container.handleError(error, currentVNode);
@@ -28706,7 +29013,7 @@ function walkCursor(cursor, options) {
28706
29013
  });
28707
29014
  return;
28708
29015
  }
28709
- if (isBrowser2) {
29016
+ if (isBrowser3) {
28710
29017
  const elapsed = performance.now() - startTime;
28711
29018
  if (elapsed >= timeBudget) {
28712
29019
  scheduleYield();
@@ -28715,16 +29022,16 @@ function walkCursor(cursor, options) {
28715
29022
  }
28716
29023
  }
28717
29024
  isDev16 && assertFalse(
28718
- !!(cursor.dirty & 255 /* DIRTY_MASK */ && !cursorData.position),
29025
+ !!(cursor.dirty & 511 /* DIRTY_MASK */ && !cursorData.position),
28719
29026
  "Cursor is still dirty and position is not set after walking"
28720
29027
  );
28721
29028
  finishWalk(container, cursor, cursorData, isRunningOnServer);
28722
29029
  }
28723
- function finishWalk(container, cursor, cursorData, isServer13) {
28724
- if (!(cursor.dirty & 255 /* DIRTY_MASK */)) {
29030
+ function finishWalk(container, cursor, cursorData, isServer15) {
29031
+ if (!(cursor.dirty & 511 /* DIRTY_MASK */)) {
28725
29032
  removeCursorFromQueue(cursor, container);
28726
29033
  DEBUG6 && console.warn("walkCursor: cursor done", cursor.toString());
28727
- if (!isServer13) {
29034
+ if (!isServer15) {
28728
29035
  executeFlushPhase(cursor, container);
28729
29036
  }
28730
29037
  if (cursorData.extraPromises) {
@@ -28768,7 +29075,7 @@ function partitionDirtyChildren(dirtyChildren, parent) {
28768
29075
  }
28769
29076
  function getNextVNode(vNode, cursor) {
28770
29077
  if (vNode === cursor) {
28771
- if (cursor.dirty & 255 /* DIRTY_MASK */) {
29078
+ if (cursor.dirty & 511 /* DIRTY_MASK */) {
28772
29079
  return cursor;
28773
29080
  }
28774
29081
  return null;
@@ -28780,7 +29087,7 @@ function getNextVNode(vNode, cursor) {
28780
29087
  parent = vNode.parent;
28781
29088
  }
28782
29089
  if (!parent) {
28783
- if (cursor.dirty & 255 /* DIRTY_MASK */) {
29090
+ if (cursor.dirty & 511 /* DIRTY_MASK */) {
28784
29091
  return cursor;
28785
29092
  }
28786
29093
  return null;
@@ -28791,7 +29098,7 @@ function getNextVNode(vNode, cursor) {
28791
29098
  let count = len;
28792
29099
  while (count-- > 0) {
28793
29100
  const nextVNode = dirtyChildren[index];
28794
- if (nextVNode.dirty & 255 /* DIRTY_MASK */) {
29101
+ if (nextVNode.dirty & 511 /* DIRTY_MASK */) {
28795
29102
  parent.nextDirtyChildIndex = (index + 1) % len;
28796
29103
  return nextVNode;
28797
29104
  }
@@ -28854,7 +29161,7 @@ function propagateToCursorRoot(vNode, cursorRoot) {
28854
29161
  reusablePath.push(vNode);
28855
29162
  let current = vNode.slotParent || vNode.parent;
28856
29163
  while (current) {
28857
- const isDirty = current.dirty & 255 /* DIRTY_MASK */;
29164
+ const isDirty = current.dirty & 511 /* DIRTY_MASK */;
28858
29165
  const currentIsCursor = isCursor(current);
28859
29166
  if (current === cursorRoot || isDirty) {
28860
29167
  propagatePath(current);
@@ -28908,8 +29215,8 @@ function markVNodeDirty(container, vNode, bits, cursorRoot = null) {
28908
29215
  }
28909
29216
  return;
28910
29217
  }
28911
- const isRealDirty = bits & 255 /* DIRTY_MASK */;
28912
- if ((isRealDirty ? prevDirty & 255 /* DIRTY_MASK */ : prevDirty) || vNode === cursorRoot) {
29218
+ const isRealDirty = bits & 511 /* DIRTY_MASK */;
29219
+ if ((isRealDirty ? prevDirty & 511 /* DIRTY_MASK */ : prevDirty) || vNode === cursorRoot) {
28913
29220
  return;
28914
29221
  }
28915
29222
  const parent = vNode.slotParent || vNode.parent;
@@ -28917,7 +29224,7 @@ function markVNodeDirty(container, vNode, bits, cursorRoot = null) {
28917
29224
  propagateToCursorRoot(vNode, cursorRoot);
28918
29225
  return;
28919
29226
  }
28920
- if (parent && parent.dirty & 255 /* DIRTY_MASK */) {
29227
+ if (parent && parent.dirty & 511 /* DIRTY_MASK */) {
28921
29228
  if (isRealDirty) {
28922
29229
  parent.dirty |= 32 /* CHILDREN */;
28923
29230
  }
@@ -29164,7 +29471,7 @@ function _executeSsrChores(container, ssrNode) {
29164
29471
  if (ssrNode.dirty & 16 /* COMPUTE */) {
29165
29472
  executeCompute(ssrNode, container);
29166
29473
  }
29167
- if (ssrNode.dirty & 255 /* DIRTY_MASK */) {
29474
+ if (ssrNode.dirty & 511 /* DIRTY_MASK */) {
29168
29475
  const warningMessage = `A chore was scheduled on a host element that has already been streamed to the client.
29169
29476
  This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
29170
29477
 
@@ -29175,7 +29482,7 @@ function _executeSsrChores(container, ssrNode) {
29175
29482
  This is often caused by modifying a signal in an already rendered component during SSR.`;
29176
29483
  logWarn(warningMessage);
29177
29484
  }
29178
- ssrNode.dirty &= ~255 /* DIRTY_MASK */;
29485
+ ssrNode.dirty &= ~511 /* DIRTY_MASK */;
29179
29486
  return;
29180
29487
  }
29181
29488
  let promise = null;
@@ -29189,7 +29496,7 @@ function _executeSsrChores(container, ssrNode) {
29189
29496
  const result2 = executeReconcileChore(container, ssrNode);
29190
29497
  promise = promise ? promise.then(() => result2) : result2;
29191
29498
  }
29192
- ssrNode.dirty &= ~(255 /* DIRTY_MASK */ & ~4 /* COMPONENT */);
29499
+ ssrNode.dirty &= ~(511 /* DIRTY_MASK */ & ~4 /* COMPONENT */);
29193
29500
  if (promise) {
29194
29501
  return promise;
29195
29502
  }
@@ -29201,7 +29508,8 @@ function executeTasksChore(container, ssrNode) {
29201
29508
  return null;
29202
29509
  }
29203
29510
  let promise = null;
29204
- for (const item of elementSeq) {
29511
+ for (let i = 0; i < elementSeq.length; i++) {
29512
+ const item = elementSeq[i];
29205
29513
  if (item instanceof Task) {
29206
29514
  const task = item;
29207
29515
  if (!(task.$flags$ & 4 /* DIRTY */)) {
@@ -29306,6 +29614,8 @@ var Serializer = class {
29306
29614
  __publicField(this, "$parent$");
29307
29615
  __publicField(this, "$qrlMap$", /* @__PURE__ */ new Map());
29308
29616
  __publicField(this, "$writer$");
29617
+ /** We need to determine this at runtime because polyfills may not be loaded a module load time */
29618
+ __publicField(this, "$hasTemporal$", typeof Temporal !== "undefined");
29309
29619
  this.$writer$ = $serializationContext$.$writer$;
29310
29620
  }
29311
29621
  async serialize() {
@@ -29345,6 +29655,29 @@ var Serializer = class {
29345
29655
  }
29346
29656
  return false;
29347
29657
  }
29658
+ maybeNumericObjectKey$(key) {
29659
+ if (key.length === 0 || key.length >= 8) {
29660
+ return key;
29661
+ }
29662
+ let i = 0;
29663
+ if (key.charCodeAt(0) === 45) {
29664
+ if (key.length === 1) {
29665
+ return key;
29666
+ }
29667
+ i = 1;
29668
+ }
29669
+ const first = key.charCodeAt(i);
29670
+ if (first < 49 || first > 57) {
29671
+ return key;
29672
+ }
29673
+ for (i++; i < key.length; i++) {
29674
+ const c = key.charCodeAt(i);
29675
+ if (c < 48 || c > 57) {
29676
+ return key;
29677
+ }
29678
+ }
29679
+ return Number(key);
29680
+ }
29348
29681
  /** Output a type,value pair. If the value is an array, it calls writeValue on each item. */
29349
29682
  output(type, value, keepUndefined) {
29350
29683
  if (typeof value === "number") {
@@ -29450,6 +29783,8 @@ var Serializer = class {
29450
29783
  this.output(3 /* Constant */, 8 /* STORE_ALL_PROPS */);
29451
29784
  } else if (value === _UNINITIALIZED) {
29452
29785
  this.output(3 /* Constant */, 9 /* UNINITIALIZED */);
29786
+ } else if (value === explicitUndefined) {
29787
+ this.output(3 /* Constant */, 0 /* Undefined */);
29453
29788
  }
29454
29789
  break;
29455
29790
  case "function":
@@ -29483,7 +29818,7 @@ var Serializer = class {
29483
29818
  } else if (isQwikComponent(value)) {
29484
29819
  const [qrl] = value[SERIALIZABLE_STATE];
29485
29820
  this.$serializationContext$.$renderSymbols$.add(qrl.$symbol$);
29486
- this.output(21 /* Component */, [qrl]);
29821
+ this.output(29 /* Component */, [qrl]);
29487
29822
  } else {
29488
29823
  throw qError(34 /* serializeErrorCannotSerializeFunction */, [value.toString()]);
29489
29824
  }
@@ -29515,19 +29850,19 @@ var Serializer = class {
29515
29850
  writeObjectValue(value) {
29516
29851
  if (isPropsProxy(value)) {
29517
29852
  const owner = value[_OWNER];
29518
- this.output(30 /* PropsProxy */, [
29853
+ this.output(38 /* PropsProxy */, [
29519
29854
  _serializationWeakRef(owner),
29520
29855
  owner.varProps,
29521
29856
  owner.constProps,
29522
29857
  value[_PROPS_HANDLER].$effects$
29523
29858
  ]);
29524
29859
  } else if (value instanceof SubscriptionData) {
29525
- this.output(31 /* SubscriptionData */, [
29860
+ this.output(39 /* SubscriptionData */, [
29526
29861
  value.data.$scopedStyleIdPrefix$,
29527
29862
  value.data.$isConst$
29528
29863
  ]);
29529
29864
  } else if (value instanceof EffectSubscription) {
29530
- this.output(32 /* EffectSubscription */, [value.consumer, value.property, value.data]);
29865
+ this.output(40 /* EffectSubscription */, [value.consumer, value.property, value.data]);
29531
29866
  } else if (isStore(value)) {
29532
29867
  const storeHandler = getStoreHandler(value);
29533
29868
  const storeTarget = getStoreTarget(value);
@@ -29545,13 +29880,13 @@ var Serializer = class {
29545
29880
  while (out[out.length - 1] === void 0) {
29546
29881
  out.pop();
29547
29882
  }
29548
- this.output(27 /* Store */, out);
29883
+ this.output(35 /* Store */, out);
29549
29884
  } else if (isSerializerObj(value)) {
29550
29885
  const result2 = value[SerializerSymbol](value);
29551
29886
  if (isPromise(result2)) {
29552
29887
  const forwardRef = this.resolvePromise(result2, (resolved, resolvedValue) => {
29553
29888
  return new PromiseResult(
29554
- 26 /* SerializerSignal */,
29889
+ 34 /* SerializerSignal */,
29555
29890
  resolved,
29556
29891
  resolvedValue,
29557
29892
  void 0,
@@ -29573,7 +29908,7 @@ var Serializer = class {
29573
29908
  if (Object.prototype.hasOwnProperty.call(value, key)) {
29574
29909
  const subVal = value[key];
29575
29910
  if (!fastSkipSerialize(subVal)) {
29576
- out.push(key, subVal);
29911
+ out.push(this.maybeNumericObjectKey$(key), subVal);
29577
29912
  }
29578
29913
  }
29579
29914
  }
@@ -29588,7 +29923,7 @@ var Serializer = class {
29588
29923
  if (isPromise(maybeValue)) {
29589
29924
  const forwardRefId = this.resolvePromise(maybeValue, (resolved, resolvedValue) => {
29590
29925
  return new PromiseResult(
29591
- 26 /* SerializerSignal */,
29926
+ 34 /* SerializerSignal */,
29592
29927
  resolved,
29593
29928
  resolvedValue,
29594
29929
  value.$effects$,
@@ -29597,12 +29932,12 @@ var Serializer = class {
29597
29932
  });
29598
29933
  this.output(2 /* ForwardRef */, forwardRefId);
29599
29934
  } else {
29600
- this.output(26 /* SerializerSignal */, [value.$computeQrl$, value.$effects$, maybeValue]);
29935
+ this.output(34 /* SerializerSignal */, [value.$computeQrl$, value.$effects$, maybeValue]);
29601
29936
  }
29602
29937
  return;
29603
29938
  }
29604
29939
  if (value instanceof WrappedSignalImpl) {
29605
- this.output(23 /* WrappedSignal */, [
29940
+ this.output(31 /* WrappedSignal */, [
29606
29941
  ...serializeWrappingFn(this.$serializationContext$, value),
29607
29942
  value.$flags$,
29608
29943
  value.$hostElement$,
@@ -29615,7 +29950,7 @@ var Serializer = class {
29615
29950
  const isInvalid = value.$flags$ & 1 /* INVALID */;
29616
29951
  const isSkippable = fastSkipSerialize(value.$untrackedValue$);
29617
29952
  const isAsync = value instanceof AsyncSignalImpl;
29618
- const interval = isAsync && value.$interval$ > 0 ? value.$interval$ : void 0;
29953
+ const expires = isAsync && value.$expires$ !== 0 ? value.$expires$ : void 0;
29619
29954
  const concurrency = isAsync && value.$concurrency$ !== 1 ? value.$concurrency$ : void 0;
29620
29955
  const timeout = isAsync && value.$timeoutMs$ !== 0 ? value.$timeoutMs$ : void 0;
29621
29956
  const asyncFlags = isAsync && value.$flags$ & ~24 /* SERIALIZATION_ALL_STRATEGIES */ || void 0;
@@ -29631,32 +29966,43 @@ var Serializer = class {
29631
29966
  out.push(value.$loadingEffects$, value.$errorEffects$, value.$untrackedError$);
29632
29967
  out.push(asyncFlags || void 0);
29633
29968
  }
29634
- let keepUndefined = false;
29635
- if (v !== NEEDS_COMPUTATION || interval !== void 0 || concurrency !== void 0 || timeout !== void 0) {
29636
- out.push(v);
29637
- if (v === void 0) {
29638
- keepUndefined = true;
29639
- }
29969
+ if (v !== NEEDS_COMPUTATION || expires !== void 0 || concurrency !== void 0 || timeout !== void 0) {
29970
+ out.push(v === void 0 ? explicitUndefined : v);
29640
29971
  }
29641
29972
  if (isAsync) {
29642
- out.push(interval);
29973
+ out.push(expires);
29643
29974
  out.push(concurrency);
29644
29975
  out.push(timeout);
29645
29976
  }
29646
- this.output(isAsync ? 25 /* AsyncSignal */ : 24 /* ComputedSignal */, out, keepUndefined);
29977
+ this.output(isAsync ? 33 /* AsyncSignal */ : 32 /* ComputedSignal */, out);
29647
29978
  } else {
29648
29979
  const v = value.$untrackedValue$;
29649
- const keepUndefined = v === void 0;
29650
- const out = [v];
29980
+ const out = [v === void 0 ? explicitUndefined : v];
29651
29981
  if (value.$effects$) {
29652
29982
  out.push(...value.$effects$);
29653
29983
  }
29654
- this.output(22 /* Signal */, out, keepUndefined);
29984
+ this.output(30 /* Signal */, out);
29655
29985
  }
29656
29986
  } else if (value instanceof URL) {
29657
29987
  this.output(6 /* URL */, value.href);
29658
29988
  } else if (value instanceof Date) {
29659
29989
  this.output(7 /* Date */, Number.isNaN(value.valueOf()) ? "" : value.valueOf());
29990
+ } else if (this.$hasTemporal$ && value instanceof Temporal.Duration) {
29991
+ this.output(15 /* TemporalDuration */, value.toJSON());
29992
+ } else if (this.$hasTemporal$ && value instanceof Temporal.Instant) {
29993
+ this.output(16 /* TemporalInstant */, value.toJSON());
29994
+ } else if (this.$hasTemporal$ && value instanceof Temporal.PlainDate) {
29995
+ this.output(17 /* TemporalPlainDate */, value.toJSON());
29996
+ } else if (this.$hasTemporal$ && value instanceof Temporal.PlainDateTime) {
29997
+ this.output(18 /* TemporalPlainDateTime */, value.toJSON());
29998
+ } else if (this.$hasTemporal$ && value instanceof Temporal.PlainMonthDay) {
29999
+ this.output(19 /* TemporalPlainMonthDay */, value.toJSON());
30000
+ } else if (this.$hasTemporal$ && value instanceof Temporal.PlainTime) {
30001
+ this.output(20 /* TemporalPlainTime */, value.toJSON());
30002
+ } else if (this.$hasTemporal$ && value instanceof Temporal.PlainYearMonth) {
30003
+ this.output(21 /* TemporalPlainYearMonth */, value.toJSON());
30004
+ } else if (this.$hasTemporal$ && value instanceof Temporal.ZonedDateTime) {
30005
+ this.output(22 /* TemporalZonedDateTime */, value.toJSON());
29660
30006
  } else if (value instanceof RegExp) {
29661
30007
  this.output(8 /* Regex */, value.toString());
29662
30008
  } else if (value instanceof Error) {
@@ -29665,7 +30011,7 @@ var Serializer = class {
29665
30011
  if (isDev18) {
29666
30012
  out.push("stack", value.stack);
29667
30013
  }
29668
- this.output(15 /* Error */, out);
30014
+ this.output(23 /* Error */, out);
29669
30015
  } else if (this.$serializationContext$.$isSsrNode$(value)) {
29670
30016
  const rootIndex = this.$serializationContext$.$addRoot$(value);
29671
30017
  this.$serializationContext$.$setProp$(value, ELEMENT_ID, String(rootIndex));
@@ -29684,15 +30030,6 @@ var Serializer = class {
29684
30030
  const child = value.children[i];
29685
30031
  const childVNodeData = child.vnodeData;
29686
30032
  if (childVNodeData) {
29687
- for (let i2 = 0; i2 < childVNodeData.length; i2++) {
29688
- const value2 = childVNodeData[i2];
29689
- if (isSsrAttrs(value2)) {
29690
- const backRefs = tryGetBackRefs(value2);
29691
- if (backRefs) {
29692
- this.$serializationContext$.$addRoot$(backRefs);
29693
- }
29694
- }
29695
- }
29696
30033
  childVNodeData[0] |= 16 /* SERIALIZE */;
29697
30034
  }
29698
30035
  }
@@ -29704,17 +30041,17 @@ var Serializer = class {
29704
30041
  array.push(k, v);
29705
30042
  }
29706
30043
  }
29707
- this.output(28 /* FormData */, array);
30044
+ this.output(36 /* FormData */, array);
29708
30045
  } else if (value instanceof URLSearchParams) {
29709
30046
  this.output(13 /* URLSearchParams */, value.toString());
29710
30047
  } else if (value instanceof Set) {
29711
- this.output(17 /* Set */, [...value.values()]);
30048
+ this.output(25 /* Set */, [...value.values()]);
29712
30049
  } else if (value instanceof Map) {
29713
30050
  const combined = [];
29714
30051
  for (const [k, v] of value.entries()) {
29715
30052
  combined.push(k, v);
29716
30053
  }
29717
- this.output(18 /* Map */, combined);
30054
+ this.output(26 /* Map */, combined);
29718
30055
  } else if (isJSXNode(value)) {
29719
30056
  const out = [
29720
30057
  value.type,
@@ -29727,22 +30064,22 @@ var Serializer = class {
29727
30064
  while (out[out.length - 1] === void 0) {
29728
30065
  out.pop();
29729
30066
  }
29730
- this.output(29 /* JSXNode */, out);
30067
+ this.output(37 /* JSXNode */, out);
29731
30068
  } else if (value instanceof Task) {
29732
30069
  const out = [value.$qrl$, value.$flags$, value.$index$, value.$el$, value.$state$];
29733
30070
  while (out[out.length - 1] === void 0) {
29734
30071
  out.pop();
29735
30072
  }
29736
- this.output(20 /* Task */, out);
30073
+ this.output(28 /* Task */, out);
29737
30074
  } else if (isPromise(value)) {
29738
30075
  const forwardRefId = this.resolvePromise(value, (resolved, resolvedValue) => {
29739
- return new PromiseResult(16 /* Promise */, resolved, resolvedValue);
30076
+ return new PromiseResult(24 /* Promise */, resolved, resolvedValue);
29740
30077
  });
29741
30078
  this.output(2 /* ForwardRef */, forwardRefId);
29742
30079
  } else if (value instanceof PromiseResult) {
29743
- if (value.$type$ === 26 /* SerializerSignal */) {
30080
+ if (value.$type$ === 34 /* SerializerSignal */) {
29744
30081
  if (value.$qrl$) {
29745
- this.output(26 /* SerializerSignal */, [value.$qrl$, value.$effects$, value.$value$]);
30082
+ this.output(34 /* SerializerSignal */, [value.$qrl$, value.$effects$, value.$value$]);
29746
30083
  } else if (value.$resolved$) {
29747
30084
  const index = this.$parent$.$index$;
29748
30085
  this.$parent$ = this.$parent$.$parent$;
@@ -29752,7 +30089,7 @@ var Serializer = class {
29752
30089
  throw qError(33 /* serializerSymbolRejectedPromise */);
29753
30090
  }
29754
30091
  } else {
29755
- this.output(16 /* Promise */, [value.$resolved$, value.$value$]);
30092
+ this.output(24 /* Promise */, [value.$resolved$, value.$value$]);
29756
30093
  }
29757
30094
  } else if (value instanceof Uint8Array) {
29758
30095
  let buf = "";
@@ -29761,7 +30098,7 @@ var Serializer = class {
29761
30098
  buf += String.fromCharCode(value[i]);
29762
30099
  }
29763
30100
  const out = btoa(buf).replace(/=+$/, "");
29764
- this.output(19 /* Uint8Array */, out);
30101
+ this.output(27 /* Uint8Array */, out);
29765
30102
  } else if (value instanceof SerializationWeakRef) {
29766
30103
  const obj = value.$obj$;
29767
30104
  if (this.getSeenRefOrOutput(obj, this.$parent$.$index$, true)) {
@@ -29898,9 +30235,6 @@ function serializeWrappingFn(serializationContext, value) {
29898
30235
  );
29899
30236
  return [syncFnId, value.$args$];
29900
30237
  }
29901
- function tryGetBackRefs(props) {
29902
- return Object.prototype.hasOwnProperty.call(props, QBackRefs) ? props[QBackRefs] : void 0;
29903
- }
29904
30238
  var SerializationWeakRef = class {
29905
30239
  constructor($obj$) {
29906
30240
  this.$obj$ = $obj$;
@@ -30127,30 +30461,46 @@ var allocate = (container, typeId, value) => {
30127
30461
  }
30128
30462
  return qrl;
30129
30463
  }
30130
- case 20 /* Task */:
30464
+ case 28 /* Task */:
30131
30465
  return new Task(-1, -1, null, null, null, null);
30132
30466
  case 6 /* URL */:
30133
30467
  return new URL(value);
30134
30468
  case 7 /* Date */:
30135
30469
  return new Date(value);
30470
+ case 15 /* TemporalDuration */:
30471
+ return Temporal.Duration.from(value);
30472
+ case 16 /* TemporalInstant */:
30473
+ return Temporal.Instant.from(value);
30474
+ case 17 /* TemporalPlainDate */:
30475
+ return Temporal.PlainDate.from(value);
30476
+ case 18 /* TemporalPlainDateTime */:
30477
+ return Temporal.PlainDateTime.from(value);
30478
+ case 19 /* TemporalPlainMonthDay */:
30479
+ return Temporal.PlainMonthDay.from(value);
30480
+ case 20 /* TemporalPlainTime */:
30481
+ return Temporal.PlainTime.from(value);
30482
+ case 21 /* TemporalPlainYearMonth */:
30483
+ return Temporal.PlainYearMonth.from(value);
30484
+ case 22 /* TemporalZonedDateTime */:
30485
+ return Temporal.ZonedDateTime.from(value);
30136
30486
  case 8 /* Regex */:
30137
30487
  const idx = value.lastIndexOf("/");
30138
30488
  return new RegExp(value.slice(1, idx), value.slice(idx + 1));
30139
- case 15 /* Error */:
30489
+ case 23 /* Error */:
30140
30490
  return new Error();
30141
- case 21 /* Component */:
30491
+ case 29 /* Component */:
30142
30492
  return componentQrl(null);
30143
- case 22 /* Signal */:
30493
+ case 30 /* Signal */:
30144
30494
  return new SignalImpl(container, 0);
30145
- case 23 /* WrappedSignal */:
30495
+ case 31 /* WrappedSignal */:
30146
30496
  return new WrappedSignalImpl(container, null, null, null);
30147
- case 24 /* ComputedSignal */:
30497
+ case 32 /* ComputedSignal */:
30148
30498
  return new ComputedSignalImpl(container, null);
30149
- case 25 /* AsyncSignal */:
30150
- return new AsyncSignalImpl(container, null, void 0, { interval: 0 });
30151
- case 26 /* SerializerSignal */:
30499
+ case 33 /* AsyncSignal */:
30500
+ return new AsyncSignalImpl(container, null, void 0, {});
30501
+ case 34 /* SerializerSignal */:
30152
30502
  return new SerializerSignalImpl(container, null);
30153
- case 27 /* Store */: {
30503
+ case 35 /* Store */: {
30154
30504
  const data = value;
30155
30505
  const t = data[0];
30156
30506
  const v = data[1];
@@ -30165,17 +30515,17 @@ var allocate = (container, typeId, value) => {
30165
30515
  }
30166
30516
  case 13 /* URLSearchParams */:
30167
30517
  return new URLSearchParams(value);
30168
- case 28 /* FormData */:
30518
+ case 36 /* FormData */:
30169
30519
  return new FormData();
30170
- case 29 /* JSXNode */:
30520
+ case 37 /* JSXNode */:
30171
30521
  return new JSXNodeImpl(null, null, null, null, 0, null);
30172
30522
  case 12 /* BigInt */:
30173
30523
  return BigInt(value);
30174
- case 17 /* Set */:
30524
+ case 25 /* Set */:
30175
30525
  return /* @__PURE__ */ new Set();
30176
- case 18 /* Map */:
30526
+ case 26 /* Map */:
30177
30527
  return /* @__PURE__ */ new Map();
30178
- case 16 /* Promise */:
30528
+ case 24 /* Promise */:
30179
30529
  let resolve;
30180
30530
  let reject;
30181
30531
  const promise = new Promise((res, rej) => {
@@ -30186,13 +30536,13 @@ var allocate = (container, typeId, value) => {
30186
30536
  promise.catch(() => {
30187
30537
  });
30188
30538
  return promise;
30189
- case 19 /* Uint8Array */:
30539
+ case 27 /* Uint8Array */:
30190
30540
  const encodedLength = value.length;
30191
30541
  const blocks = encodedLength >>> 2;
30192
30542
  const rest = encodedLength & 3;
30193
30543
  const decodedLength = blocks * 3 + (rest ? rest - 1 : 0);
30194
30544
  return new Uint8Array(decodedLength);
30195
- case 30 /* PropsProxy */:
30545
+ case 38 /* PropsProxy */:
30196
30546
  return createPropsProxy(null);
30197
30547
  case 10 /* VNode */:
30198
30548
  return retrieveVNodeOrDocument(container, value);
@@ -30204,9 +30554,9 @@ var allocate = (container, typeId, value) => {
30204
30554
  } else {
30205
30555
  throw qError(17 /* serializeErrorExpectedVNode */, [typeof vNode]);
30206
30556
  }
30207
- case 31 /* SubscriptionData */:
30557
+ case 39 /* SubscriptionData */:
30208
30558
  return new SubscriptionData({});
30209
- case 32 /* EffectSubscription */:
30559
+ case 40 /* EffectSubscription */:
30210
30560
  return new EffectSubscription(null, null, null, null);
30211
30561
  default:
30212
30562
  throw qError(18 /* serializeErrorCannotAllocate */, [typeId]);
@@ -30227,6 +30577,9 @@ var dangerousObjectKeys = /* @__PURE__ */ new Set([
30227
30577
  "then"
30228
30578
  ]);
30229
30579
  var isSafeObjectKV = (key, value) => {
30580
+ if (typeof key === "number") {
30581
+ return true;
30582
+ }
30230
30583
  return typeof key === "string" && key !== "__proto__" && (typeof value !== "function" || !dangerousObjectKeys.has(key));
30231
30584
  };
30232
30585
  var inflate = (container, target, typeId, data) => {
@@ -30253,7 +30606,7 @@ var inflate = (container, target, typeId, data) => {
30253
30606
  target[key] = value;
30254
30607
  }
30255
30608
  break;
30256
- case 20 /* Task */:
30609
+ case 28 /* Task */:
30257
30610
  const task = target;
30258
30611
  const v = data;
30259
30612
  task.$qrl$ = v[0];
@@ -30262,10 +30615,10 @@ var inflate = (container, target, typeId, data) => {
30262
30615
  task.$el$ = v[3];
30263
30616
  task.$state$ = v[4];
30264
30617
  break;
30265
- case 21 /* Component */:
30618
+ case 29 /* Component */:
30266
30619
  target[SERIALIZABLE_STATE][0] = data[0];
30267
30620
  break;
30268
- case 27 /* Store */: {
30621
+ case 35 /* Store */: {
30269
30622
  const store = unwrapStore(target);
30270
30623
  const storeTarget = pendingStoreTargets.get(store);
30271
30624
  if (storeTarget) {
@@ -30279,7 +30632,7 @@ var inflate = (container, target, typeId, data) => {
30279
30632
  restoreEffectBackRefForEffectsMap(storeHandler.$effects$, store);
30280
30633
  break;
30281
30634
  }
30282
- case 22 /* Signal */: {
30635
+ case 30 /* Signal */: {
30283
30636
  const signal = target;
30284
30637
  const d2 = data;
30285
30638
  signal.$untrackedValue$ = d2[0];
@@ -30287,7 +30640,7 @@ var inflate = (container, target, typeId, data) => {
30287
30640
  restoreEffectBackRefForEffects(signal.$effects$, signal);
30288
30641
  break;
30289
30642
  }
30290
- case 23 /* WrappedSignal */: {
30643
+ case 31 /* WrappedSignal */: {
30291
30644
  const signal = target;
30292
30645
  const d2 = data;
30293
30646
  signal.$func$ = container.getSyncFn(d2[0]);
@@ -30301,14 +30654,22 @@ var inflate = (container, target, typeId, data) => {
30301
30654
  restoreEffectBackRefForEffects(signal.$effects$, signal);
30302
30655
  break;
30303
30656
  }
30304
- case 25 /* AsyncSignal */: {
30657
+ case 33 /* AsyncSignal */: {
30305
30658
  const asyncSignal = target;
30306
30659
  const d2 = data;
30307
30660
  asyncSignal.$computeQrl$ = d2[0];
30308
- asyncSignal.$effects$ = new Set(d2[1]);
30309
- asyncSignal.$loadingEffects$ = new Set(d2[2]);
30310
- asyncSignal.$errorEffects$ = new Set(d2[3]);
30311
- asyncSignal.$untrackedError$ = d2[4];
30661
+ if (d2[1]) {
30662
+ asyncSignal.$effects$ = new Set(d2[1]);
30663
+ }
30664
+ if (d2[2]) {
30665
+ asyncSignal.$loadingEffects$ = new Set(d2[2]);
30666
+ }
30667
+ if (d2[3]) {
30668
+ asyncSignal.$errorEffects$ = new Set(d2[3]);
30669
+ }
30670
+ if (d2[4]) {
30671
+ asyncSignal.$untrackedError$ = d2[4];
30672
+ }
30312
30673
  asyncSignal.$flags$ = d2[5] ?? 0;
30313
30674
  if (asyncSignal.$flags$ & 64 /* CLIENT_ONLY */) {
30314
30675
  asyncSignal.$untrackedLoading$ = true;
@@ -30320,8 +30681,15 @@ var inflate = (container, target, typeId, data) => {
30320
30681
  if (asyncSignal.$untrackedValue$ === NEEDS_COMPUTATION) {
30321
30682
  asyncSignal.$flags$ |= 1 /* INVALID */;
30322
30683
  }
30323
- asyncSignal.interval = d2[7] ?? 0;
30324
- asyncSignal.$concurrency$ = d2[8] ?? 1;
30684
+ const rawExpires = d2[7] ?? 0;
30685
+ asyncSignal.expires = Math.abs(rawExpires);
30686
+ if (rawExpires < 0) {
30687
+ asyncSignal.$flags$ |= 256 /* NO_POLL */;
30688
+ }
30689
+ if (d2[8] !== void 0 && d2[8] !== 1) {
30690
+ asyncSignal.$concurrency$ = d2[8] ?? 1;
30691
+ asyncSignal.$jobs$ = [];
30692
+ }
30325
30693
  asyncSignal.$timeoutMs$ = d2[9] ?? 0;
30326
30694
  restoreEffectBackRefForEffects(asyncSignal.$effects$, asyncSignal);
30327
30695
  restoreEffectBackRefForEffects(asyncSignal.$loadingEffects$, asyncSignal);
@@ -30329,8 +30697,8 @@ var inflate = (container, target, typeId, data) => {
30329
30697
  break;
30330
30698
  }
30331
30699
  // Inflating a SerializerSignal is the same as inflating a ComputedSignal
30332
- case 26 /* SerializerSignal */:
30333
- case 24 /* ComputedSignal */: {
30700
+ case 34 /* SerializerSignal */:
30701
+ case 32 /* ComputedSignal */: {
30334
30702
  const computed = target;
30335
30703
  const d2 = data;
30336
30704
  computed.$computeQrl$ = d2[0];
@@ -30344,13 +30712,13 @@ var inflate = (container, target, typeId, data) => {
30344
30712
  if (hasValue) {
30345
30713
  computed.$untrackedValue$ = d2[2];
30346
30714
  }
30347
- if (typeId !== 26 /* SerializerSignal */ && computed.$untrackedValue$ !== NEEDS_COMPUTATION) {
30715
+ if (typeId !== 34 /* SerializerSignal */ && computed.$untrackedValue$ !== NEEDS_COMPUTATION) {
30348
30716
  computed.$flags$ &= ~1 /* INVALID */;
30349
30717
  }
30350
30718
  restoreEffectBackRefForEffects(computed.$effects$, computed);
30351
30719
  break;
30352
30720
  }
30353
- case 15 /* Error */: {
30721
+ case 23 /* Error */: {
30354
30722
  const d2 = data;
30355
30723
  target.message = d2[0];
30356
30724
  for (let i2 = 1; i2 < d2.length; i2 += 2) {
@@ -30358,7 +30726,7 @@ var inflate = (container, target, typeId, data) => {
30358
30726
  }
30359
30727
  break;
30360
30728
  }
30361
- case 28 /* FormData */: {
30729
+ case 36 /* FormData */: {
30362
30730
  const formData = target;
30363
30731
  const d2 = data;
30364
30732
  for (let i2 = 0; i2 < d2.length; i2++) {
@@ -30366,7 +30734,7 @@ var inflate = (container, target, typeId, data) => {
30366
30734
  }
30367
30735
  break;
30368
30736
  }
30369
- case 29 /* JSXNode */: {
30737
+ case 37 /* JSXNode */: {
30370
30738
  const jsx2 = target;
30371
30739
  const [type, key, varProps, constProps, children, toSort] = data;
30372
30740
  jsx2.type = type;
@@ -30377,7 +30745,7 @@ var inflate = (container, target, typeId, data) => {
30377
30745
  jsx2.toSort = !!toSort;
30378
30746
  break;
30379
30747
  }
30380
- case 17 /* Set */: {
30748
+ case 25 /* Set */: {
30381
30749
  const set = target;
30382
30750
  const d2 = data;
30383
30751
  for (let i2 = 0; i2 < d2.length; i2++) {
@@ -30385,7 +30753,7 @@ var inflate = (container, target, typeId, data) => {
30385
30753
  }
30386
30754
  break;
30387
30755
  }
30388
- case 18 /* Map */: {
30756
+ case 26 /* Map */: {
30389
30757
  const map = target;
30390
30758
  const d2 = data;
30391
30759
  for (let i2 = 0; i2 < d2.length; i2++) {
@@ -30393,7 +30761,7 @@ var inflate = (container, target, typeId, data) => {
30393
30761
  }
30394
30762
  break;
30395
30763
  }
30396
- case 16 /* Promise */: {
30764
+ case 24 /* Promise */: {
30397
30765
  const promise = target;
30398
30766
  const [resolved, result2] = data;
30399
30767
  const [resolve, reject] = resolvers.get(promise);
@@ -30404,15 +30772,16 @@ var inflate = (container, target, typeId, data) => {
30404
30772
  }
30405
30773
  break;
30406
30774
  }
30407
- case 19 /* Uint8Array */:
30775
+ case 27 /* Uint8Array */:
30408
30776
  const bytes = target;
30409
30777
  const buf = atob(data);
30410
30778
  let i = 0;
30411
- for (const s of buf) {
30779
+ for (let j = 0; j < buf.length; j++) {
30780
+ const s = buf[j];
30412
30781
  bytes[i++] = s.charCodeAt(0);
30413
30782
  }
30414
30783
  break;
30415
- case 30 /* PropsProxy */:
30784
+ case 38 /* PropsProxy */:
30416
30785
  const propsProxy = target;
30417
30786
  const d = data;
30418
30787
  let owner = d[0];
@@ -30425,13 +30794,13 @@ var inflate = (container, target, typeId, data) => {
30425
30794
  propsHandler.$effects$ = d[3];
30426
30795
  restoreEffectBackRefForEffectsMap(propsHandler.$effects$, propsProxy);
30427
30796
  break;
30428
- case 31 /* SubscriptionData */: {
30797
+ case 39 /* SubscriptionData */: {
30429
30798
  const effectData = target;
30430
30799
  effectData.data.$scopedStyleIdPrefix$ = data[0];
30431
30800
  effectData.data.$isConst$ = data[1];
30432
30801
  break;
30433
30802
  }
30434
- case 32 /* EffectSubscription */: {
30803
+ case 40 /* EffectSubscription */: {
30435
30804
  const effectSub = target;
30436
30805
  const d2 = data;
30437
30806
  effectSub.consumer = d2[0];
@@ -30558,6 +30927,9 @@ var ElementVNode = class extends VirtualVNode {
30558
30927
  };
30559
30928
 
30560
30929
  // packages/qwik/src/core/shared/qrl/qrl-class.ts
30930
+ var getLazyRef = (chunk, symbol, symbolFn, ref, container) => {
30931
+ return new LazyRef(chunk, symbol, symbolFn, ref, container);
30932
+ };
30561
30933
  var LazyRef = class {
30562
30934
  constructor($chunk$, $symbol$, $symbolFn$, $ref$, container) {
30563
30935
  this.$chunk$ = $chunk$;
@@ -30565,18 +30937,14 @@ var LazyRef = class {
30565
30937
  this.$symbolFn$ = $symbolFn$;
30566
30938
  this.$ref$ = $ref$;
30567
30939
  __publicField(this, "$container$");
30568
- // Don't allocate dev property immediately so that in prod we don't have this property
30569
- __publicField(this, "dev");
30570
30940
  if ($ref$) {
30571
30941
  this.$setRef$($ref$);
30572
30942
  }
30573
30943
  if (container && !$ref$ && typeof $chunk$ === "string" && !$symbolFn$) {
30574
30944
  this.$container$ = container;
30575
30945
  }
30576
- if (qDev) {
30577
- this.dev = null;
30578
- }
30579
- if (isBrowser3 && $chunk$) {
30946
+ qDev && initLazyRefDev(this);
30947
+ if (isBrowser4 && $chunk$) {
30580
30948
  preload($chunk$, 0.8);
30581
30949
  }
30582
30950
  }
@@ -30608,7 +30976,7 @@ var LazyRef = class {
30608
30976
  const qFuncs2 = getQFuncs(doc2, hash2);
30609
30977
  return this.$ref$ = qFuncs2[Number(this.$symbol$)];
30610
30978
  }
30611
- if (isBrowser3 && this.$chunk$) {
30979
+ if (isBrowser4 && this.$chunk$) {
30612
30980
  preload(this.$chunk$, 1);
30613
30981
  }
30614
30982
  const symbol = this.$symbol$;
@@ -30621,6 +30989,9 @@ var LazyRef = class {
30621
30989
  return this.$ref$;
30622
30990
  }
30623
30991
  };
30992
+ isBrowser4 && import.meta.hot && setupHmr(LazyRef, (fn) => {
30993
+ getLazyRef = fn;
30994
+ });
30624
30995
  var QRL_STATE = /* @__PURE__ */ Symbol("qrl-state");
30625
30996
  var getInstance = (instance) => {
30626
30997
  return instance?.[QRL_STATE] ?? instance;
@@ -30632,18 +31003,14 @@ var QRLClass = class {
30632
31003
  // This is defined or undefined for the lifetime of the QRL, so we set it lazily
30633
31004
  __publicField(this, "$captures$");
30634
31005
  __publicField(this, "$container$");
31006
+ if (qDev) {
31007
+ initQrlClassDev($lazy$, $captures$, this);
31008
+ }
30635
31009
  if ($captures$) {
30636
31010
  this.$captures$ = $captures$;
30637
31011
  if (typeof $captures$ === "string") {
30638
31012
  this.$container$ = container;
30639
31013
  }
30640
- if (qDev) {
30641
- if ($captures$ && typeof $captures$ === "object") {
30642
- for (const item of $captures$) {
30643
- verifySerializable(item, "Captured variable in the closure can not be serialized");
30644
- }
30645
- }
30646
- }
30647
31014
  }
30648
31015
  if ($lazy$.$ref$ != null && typeof this.$captures$ !== "string" && !isPromise($lazy$.$ref$)) {
30649
31016
  this.resolved = bindCaptures(this, $lazy$.$ref$);
@@ -30755,6 +31122,13 @@ var QRL_FUNCTION_PROTO = Object.create(Function.prototype, {
30755
31122
  return this[QRL_STATE].$lazy$.dev;
30756
31123
  }
30757
31124
  },
31125
+ ...qDev ? {
31126
+ $setDev$: {
31127
+ value(dev) {
31128
+ this[QRL_STATE].$lazy$.dev = dev;
31129
+ }
31130
+ }
31131
+ } : void 0,
30758
31132
  $callFn$: {
30759
31133
  value: qrlCallFn
30760
31134
  },
@@ -30786,7 +31160,9 @@ var setCaptures = (captures) => {
30786
31160
  };
30787
31161
  var deserializeCaptures = (container, captures) => {
30788
31162
  const refs = [];
30789
- for (const id of captures.split(" ")) {
31163
+ const captureIds = captures.split(" ");
31164
+ for (let i = 0; i < captureIds.length; i++) {
31165
+ const id = captureIds[i];
30790
31166
  refs.push(container.$getObjectById$(id));
30791
31167
  }
30792
31168
  return refs;
@@ -30848,7 +31224,7 @@ var $resolve$ = (qrl, container) => {
30848
31224
  return maybePromise;
30849
31225
  };
30850
31226
  var createQRL = (chunk, symbol, symbolRef, symbolFn, captures, container) => {
30851
- const lazy = new LazyRef(chunk, symbol, symbolFn, symbolRef, container);
31227
+ const lazy = getLazyRef(chunk, symbol, symbolFn, symbolRef, container);
30852
31228
  const qrl = new QRLClass(lazy, captures, container);
30853
31229
  return makeQrlFn(qrl);
30854
31230
  };
@@ -30894,7 +31270,69 @@ var now = () => {
30894
31270
  // packages/qwik/src/core/shared/jsx/jsx-internal.ts
30895
31271
  var BIND_VALUE = "bind:value";
30896
31272
  var BIND_CHECKED = "bind:checked";
31273
+ var PASSIVE = "passive:";
31274
+ var PREVENT_DEFAULT = "preventdefault:";
30897
31275
  var _hasOwnProperty3 = Object.prototype.hasOwnProperty;
31276
+ var removePassiveMarkers = (props, passiveKeys, preventDefaultKeys, passiveEvents, canMutate = false) => {
31277
+ let mutableProps = props;
31278
+ let copied = canMutate;
31279
+ if (passiveKeys.length > 0) {
31280
+ if (!copied) {
31281
+ mutableProps = { ...mutableProps };
31282
+ copied = true;
31283
+ }
31284
+ for (let i = 0; i < passiveKeys.length; i++) {
31285
+ const k = passiveKeys[i];
31286
+ delete mutableProps[k];
31287
+ }
31288
+ }
31289
+ if (preventDefaultKeys.length > 0) {
31290
+ for (let i = 0; i < preventDefaultKeys.length; i++) {
31291
+ const k = preventDefaultKeys[i];
31292
+ if (passiveEvents.has(normalizeJsxEventName(k.slice(PREVENT_DEFAULT.length)))) {
31293
+ if (!copied) {
31294
+ mutableProps = { ...mutableProps };
31295
+ copied = true;
31296
+ }
31297
+ delete mutableProps[k];
31298
+ }
31299
+ }
31300
+ }
31301
+ return mutableProps;
31302
+ };
31303
+ var getPassiveEventKey = (key) => {
31304
+ if (key.startsWith("on") && key.endsWith("$")) {
31305
+ return normalizeJsxEventName(key.slice(2, -1));
31306
+ }
31307
+ if (key.startsWith("window:on") && key.endsWith("$")) {
31308
+ return normalizeJsxEventName(key.slice(9, -1));
31309
+ }
31310
+ if (key.startsWith("document:on") && key.endsWith("$")) {
31311
+ return normalizeJsxEventName(key.slice(11, -1));
31312
+ }
31313
+ return null;
31314
+ };
31315
+ var convertJsxEventProps = (props, eventKeys, keyOrder, passiveEvents, canMutate = false) => {
31316
+ let mutableProps = props;
31317
+ let copied = canMutate;
31318
+ for (let i = 0; i < eventKeys.length; i++) {
31319
+ const k = eventKeys[i];
31320
+ const passiveEventKey = getPassiveEventKey(k);
31321
+ const attr = jsxEventToHtmlAttribute(k, passiveEvents.has(passiveEventKey));
31322
+ if (attr) {
31323
+ if (!copied) {
31324
+ mutableProps = { ...mutableProps };
31325
+ copied = true;
31326
+ }
31327
+ const attrIndex = keyOrder.get(attr);
31328
+ if (attrIndex === void 0 || attrIndex < keyOrder.get(k)) {
31329
+ mutableProps[attr] = mutableProps[k];
31330
+ }
31331
+ delete mutableProps[k];
31332
+ }
31333
+ }
31334
+ return mutableProps;
31335
+ };
30898
31336
  var _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => {
30899
31337
  return new JSXNodeImpl(type, varProps, constProps, children, flags, key, false, dev);
30900
31338
  };
@@ -30905,49 +31343,90 @@ var _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
30905
31343
  let bindValueSignal = null;
30906
31344
  let bindCheckedSignal = null;
30907
31345
  if (typeof type === "string") {
31346
+ const passiveEvents = /* @__PURE__ */ new Set();
31347
+ const constEventKeys = [];
31348
+ const varEventKeys = [];
31349
+ const constPassiveKeys = [];
31350
+ const varPassiveKeys = [];
31351
+ const constPreventDefaultKeys = [];
31352
+ const varPreventDefaultKeys = [];
31353
+ const constKeyOrder = /* @__PURE__ */ new Map();
31354
+ const varKeyOrder = /* @__PURE__ */ new Map();
30908
31355
  if (constProps) {
30909
- const processedKeys = /* @__PURE__ */ new Set();
31356
+ let index = 0;
30910
31357
  for (const k in constProps) {
30911
- const attr = jsxEventToHtmlAttribute(k);
30912
- if (attr) {
30913
- if (!constPropsCopied) {
30914
- constProps = { ...constProps };
30915
- constPropsCopied = true;
30916
- }
30917
- if (!_hasOwnProperty3.call(constProps, attr) || processedKeys.has(attr)) {
30918
- constProps[attr] = constProps[k];
30919
- }
30920
- delete constProps[k];
31358
+ constKeyOrder.set(k, index++);
31359
+ if (k.startsWith(PASSIVE)) {
31360
+ constPassiveKeys.push(k);
31361
+ passiveEvents.add(normalizeJsxEventName(k.slice(PASSIVE.length)));
31362
+ } else if (k.startsWith(PREVENT_DEFAULT)) {
31363
+ constPreventDefaultKeys.push(k);
31364
+ } else if (getPassiveEventKey(k) !== null) {
31365
+ constEventKeys.push(k);
30921
31366
  } else if (k === BIND_CHECKED) {
30922
31367
  bindCheckedSignal = constProps[k];
30923
31368
  } else if (k === BIND_VALUE) {
30924
31369
  bindValueSignal = constProps[k];
30925
31370
  }
30926
- processedKeys.add(k);
30927
31371
  }
30928
31372
  }
30929
31373
  if (varProps) {
30930
- const processedKeys = /* @__PURE__ */ new Set();
31374
+ let index = 0;
30931
31375
  for (const k in varProps) {
30932
- const attr = jsxEventToHtmlAttribute(k);
30933
- if (attr) {
30934
- if (!varPropsCopied) {
30935
- varProps = { ...varProps };
30936
- varPropsCopied = true;
30937
- }
30938
- if (!_hasOwnProperty3.call(varProps, attr) || processedKeys.has(attr)) {
30939
- varProps[attr] = varProps[k];
30940
- }
30941
- delete varProps[k];
30942
- toSort = true;
31376
+ varKeyOrder.set(k, index++);
31377
+ if (k.startsWith(PASSIVE)) {
31378
+ varPassiveKeys.push(k);
31379
+ passiveEvents.add(normalizeJsxEventName(k.slice(PASSIVE.length)));
31380
+ } else if (k.startsWith(PREVENT_DEFAULT)) {
31381
+ varPreventDefaultKeys.push(k);
31382
+ } else if (getPassiveEventKey(k) !== null) {
31383
+ varEventKeys.push(k);
30943
31384
  } else if (k === BIND_CHECKED) {
30944
31385
  bindCheckedSignal = varProps[k];
30945
31386
  } else if (k === BIND_VALUE) {
30946
31387
  bindValueSignal = varProps[k];
30947
31388
  }
30948
- processedKeys.add(k);
30949
31389
  }
30950
31390
  }
31391
+ if (constProps) {
31392
+ const originalConstProps = constProps;
31393
+ constProps = removePassiveMarkers(
31394
+ constProps,
31395
+ constPassiveKeys,
31396
+ constPreventDefaultKeys,
31397
+ passiveEvents,
31398
+ constPropsCopied
31399
+ );
31400
+ constPropsCopied = constPropsCopied || constProps !== originalConstProps;
31401
+ constProps = convertJsxEventProps(
31402
+ constProps,
31403
+ constEventKeys,
31404
+ constKeyOrder,
31405
+ passiveEvents,
31406
+ constPropsCopied
31407
+ );
31408
+ constPropsCopied = constPropsCopied || constProps !== originalConstProps;
31409
+ }
31410
+ if (varProps) {
31411
+ const originalVarProps = varProps;
31412
+ varProps = removePassiveMarkers(
31413
+ varProps,
31414
+ varPassiveKeys,
31415
+ varPreventDefaultKeys,
31416
+ passiveEvents,
31417
+ varPropsCopied
31418
+ );
31419
+ varPropsCopied = varPropsCopied || varProps !== originalVarProps;
31420
+ varProps = convertJsxEventProps(
31421
+ varProps,
31422
+ varEventKeys,
31423
+ varKeyOrder,
31424
+ passiveEvents,
31425
+ varPropsCopied
31426
+ );
31427
+ varPropsCopied = varPropsCopied || varProps !== originalVarProps;
31428
+ toSort = toSort || varEventKeys.length > 0;
31429
+ }
30951
31430
  if (bindCheckedSignal || bindValueSignal) {
30952
31431
  if (!varPropsCopied) {
30953
31432
  varProps = { ...varProps };
@@ -31071,6 +31550,7 @@ var Slot = (props) => {
31071
31550
  };
31072
31551
 
31073
31552
  // packages/qwik/src/core/shared/serdes/constants.ts
31553
+ var explicitUndefined = /* @__PURE__ */ Symbol("undefined");
31074
31554
  var _constants = [
31075
31555
  void 0,
31076
31556
  null,
@@ -31127,6 +31607,14 @@ var _typeIdNames = [
31127
31607
  "BigInt",
31128
31608
  "URLSearchParams",
31129
31609
  "ForwardRefs",
31610
+ "TemporalDuration",
31611
+ "TemporalInstant",
31612
+ "TemporalPlainDate",
31613
+ "TemporalPlainDateTime",
31614
+ "TemporalPlainMonthDay",
31615
+ "TemporalPlainTime",
31616
+ "TemporalPlainYearMonth",
31617
+ "TemporalZonedDateTime",
31130
31618
  "Error",
31131
31619
  "Promise",
31132
31620
  "Set",
@@ -31148,7 +31636,7 @@ var _typeIdNames = [
31148
31636
  ];
31149
31637
 
31150
31638
  // packages/qwik/src/core/shared/serdes/deser-proxy.ts
31151
- var needsInflation = (typeId) => typeId >= 15 /* Error */ || typeId === 4 /* Array */ || typeId === 5 /* Object */;
31639
+ var needsInflation = (typeId) => typeId >= 23 /* Error */ || typeId === 4 /* Array */ || typeId === 5 /* Object */;
31152
31640
  var deserializedProxyMap = /* @__PURE__ */ new WeakMap();
31153
31641
  var isDeserializerProxy = (value) => {
31154
31642
  return isObject(value) && SERIALIZER_PROXY_UNWRAP in value;
@@ -31247,15 +31735,19 @@ function processVNodeData(document2) {
31247
31735
  const hasAttribute = prototype.hasAttribute;
31248
31736
  const getNodeType = getter(prototype, "nodeType");
31249
31737
  const attachVnodeDataAndRefs = (element) => {
31250
- Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script2) => {
31738
+ const scripts = element.querySelectorAll('script[type="qwik/vnode"]');
31739
+ for (let i = 0; i < scripts.length; i++) {
31740
+ const script2 = scripts[i];
31251
31741
  const qContainerElement = script2.closest("[q\\:container]");
31252
31742
  qContainerElement.qVnodeData = script2.textContent;
31253
31743
  qContainerElement.qVNodeRefs = /* @__PURE__ */ new Map();
31254
- });
31255
- element.querySelectorAll("[q\\:shadowroot]").forEach((parent) => {
31744
+ }
31745
+ const shadowRoots = element.querySelectorAll("[q\\:shadowroot]");
31746
+ for (let i = 0; i < shadowRoots.length; i++) {
31747
+ const parent = shadowRoots[i];
31256
31748
  const shadowRoot = parent.shadowRoot;
31257
31749
  shadowRoot && attachVnodeDataAndRefs(shadowRoot);
31258
- });
31750
+ }
31259
31751
  };
31260
31752
  attachVnodeDataAndRefs(document2);
31261
31753
  let NodeType;
@@ -31582,22 +32074,8 @@ var DomContainer = class extends _SharedContainer {
31582
32074
  handleError(err, host) {
31583
32075
  if (qDev && host) {
31584
32076
  if (typeof document !== "undefined") {
31585
- const createErrorWrapper = () => {
31586
- const vHost = host;
31587
- const vHostParent = vHost.parent;
31588
- const vHostNextSibling = vHost.nextSibling;
31589
- const journal = [];
31590
- const vErrorDiv = vnode_createErrorDiv(journal, document, vHost, err);
31591
- const insertHost = vnode_isElementVNode(vHost) ? vHostParent || vHost : vHost;
31592
- const insertBefore = insertHost === vHost ? null : vHostNextSibling;
31593
- vnode_insertElementBefore(
31594
- journal,
31595
- insertHost,
31596
- vErrorDiv,
31597
- insertBefore
31598
- );
31599
- };
31600
- this.$renderPromise$ ? this.$renderPromise$.then(createErrorWrapper) : createErrorWrapper();
32077
+ setErrorPayload(host, err);
32078
+ markVNodeDirty(this, host, 256 /* ERROR_WRAP */);
31601
32079
  }
31602
32080
  if (err && err instanceof Error) {
31603
32081
  if (!("hostElement" in err)) {
@@ -31673,7 +32151,9 @@ var DomContainer = class extends _SharedContainer {
31673
32151
  vNode.flags |= 16 /* Resolved */;
31674
32152
  const props = vNode.props;
31675
32153
  if (props) {
31676
- for (const prop of Object.keys(props)) {
32154
+ const propKeys = Object.keys(props);
32155
+ for (let i = 0; i < propKeys.length; i++) {
32156
+ const prop = propKeys[i];
31677
32157
  if (isSlotProp(prop)) {
31678
32158
  const value = props[prop];
31679
32159
  if (typeof value == "string") {
@@ -31699,9 +32179,11 @@ var DomContainer = class extends _SharedContainer {
31699
32179
  }
31700
32180
  if (this.$styleIds$ == null) {
31701
32181
  this.$styleIds$ = /* @__PURE__ */ new Set();
31702
- this.element.querySelectorAll(QStyleSelector).forEach((style) => {
32182
+ const styleElements = this.document.querySelectorAll(QStyleSelector);
32183
+ for (let i = 0; i < styleElements.length; i++) {
32184
+ const style = styleElements[i];
31703
32185
  this.$styleIds$.add(style.getAttribute(QStyle));
31704
- });
32186
+ }
31705
32187
  }
31706
32188
  if (!this.$styleIds$.has(styleId)) {
31707
32189
  this.$styleIds$.add(styleId);
@@ -32053,6 +32535,7 @@ function getEffects2(target, prop, storeEffects) {
32053
32535
  // packages/qwik/src/core/shared/serdes/can-serialize.ts
32054
32536
  var getKeyVal = (value, key) => value[key];
32055
32537
  var canSerialize = (value, seen = /* @__PURE__ */ new WeakSet()) => {
32538
+ const hasTemporal = typeof Temporal !== "undefined";
32056
32539
  if (value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
32057
32540
  return true;
32058
32541
  } else if (typeof value === "object") {
@@ -32073,6 +32556,9 @@ var canSerialize = (value, seen = /* @__PURE__ */ new WeakSet()) => {
32073
32556
  return true;
32074
32557
  } else if (proto == Array.prototype) {
32075
32558
  for (let i = 0; i < value.length; i++) {
32559
+ if (!(i in value)) {
32560
+ return false;
32561
+ }
32076
32562
  if (!canSerialize(value[i], seen)) {
32077
32563
  return false;
32078
32564
  }
@@ -32086,12 +32572,30 @@ var canSerialize = (value, seen = /* @__PURE__ */ new WeakSet()) => {
32086
32572
  return true;
32087
32573
  } else if (isJSXNode(value)) {
32088
32574
  return true;
32575
+ } else if (isSerializerObj(value)) {
32576
+ return true;
32089
32577
  } else if (value instanceof Error) {
32090
32578
  return true;
32091
32579
  } else if (value instanceof URL) {
32092
32580
  return true;
32093
32581
  } else if (value instanceof Date) {
32094
32582
  return true;
32583
+ } else if (hasTemporal && value instanceof Temporal.Duration) {
32584
+ return true;
32585
+ } else if (hasTemporal && value instanceof Temporal.Instant) {
32586
+ return true;
32587
+ } else if (hasTemporal && value instanceof Temporal.PlainDate) {
32588
+ return true;
32589
+ } else if (hasTemporal && value instanceof Temporal.PlainDateTime) {
32590
+ return true;
32591
+ } else if (hasTemporal && value instanceof Temporal.PlainMonthDay) {
32592
+ return true;
32593
+ } else if (hasTemporal && value instanceof Temporal.PlainTime) {
32594
+ return true;
32595
+ } else if (hasTemporal && value instanceof Temporal.PlainYearMonth) {
32596
+ return true;
32597
+ } else if (hasTemporal && value instanceof Temporal.ZonedDateTime) {
32598
+ return true;
32095
32599
  } else if (value instanceof RegExp) {
32096
32600
  return true;
32097
32601
  } else if (value instanceof URLSearchParams) {
@@ -32292,16 +32796,23 @@ var _verifySerializable = (value, seen, ctx, preMessage) => {
32292
32796
  }
32293
32797
  if (isArray(unwrapped)) {
32294
32798
  let expectIndex = 0;
32295
- unwrapped.forEach((v, i) => {
32799
+ for (let i = 0; i < unwrapped.length; i++) {
32800
+ if (!(i in unwrapped)) {
32801
+ throw qError(3 /* verifySerializable */, [unwrapped]);
32802
+ }
32803
+ const v = unwrapped[i];
32296
32804
  if (i !== expectIndex) {
32297
32805
  throw qError(3 /* verifySerializable */, [unwrapped]);
32298
32806
  }
32299
32807
  _verifySerializable(v, seen, ctx + "[" + i + "]");
32300
32808
  expectIndex = i + 1;
32301
- });
32809
+ }
32302
32810
  return value;
32303
32811
  }
32304
- if (unwrapped.__brand) {
32812
+ if (unwrapped instanceof VNode) {
32813
+ return value;
32814
+ }
32815
+ if (unwrapped.__brand || unwrapped.__brand__) {
32305
32816
  return value;
32306
32817
  }
32307
32818
  if (isSerializableObject(unwrapped)) {
@@ -32387,7 +32898,7 @@ var addQrlToSerializationCtx = (effectSubscriber, container) => {
32387
32898
  }
32388
32899
  };
32389
32900
  var scheduleEffects = (container, signal, effects) => {
32390
- const isBrowser6 = import.meta.env.TEST ? !isServerPlatform() : !isServer12;
32901
+ const isBrowser8 = import.meta.env.TEST ? !isServerPlatform() : !isServer12;
32391
32902
  if (effects) {
32392
32903
  const scheduleEffect = (effectSubscription) => {
32393
32904
  const consumer = effectSubscription.consumer;
@@ -32401,7 +32912,7 @@ var scheduleEffects = (container, signal, effects) => {
32401
32912
  } else if (property === ":" /* COMPONENT */) {
32402
32913
  markVNodeDirty(container, consumer, 4 /* COMPONENT */);
32403
32914
  } else if (property === "." /* VNODE */) {
32404
- if (isBrowser6) {
32915
+ if (isBrowser8) {
32405
32916
  setNodeDiffPayload(consumer, signal);
32406
32917
  markVNodeDirty(container, consumer, 2 /* NODE_DIFF */);
32407
32918
  }
@@ -32414,7 +32925,7 @@ var scheduleEffects = (container, signal, effects) => {
32414
32925
  scopedStyleIdPrefix: data.$scopedStyleIdPrefix$,
32415
32926
  value: signal
32416
32927
  };
32417
- if (isBrowser6) {
32928
+ if (isBrowser8) {
32418
32929
  setNodePropData(consumer, property, payload);
32419
32930
  } else {
32420
32931
  const node = consumer;
@@ -32510,16 +33021,19 @@ var jsxToString = (value) => {
32510
33021
  }
32511
33022
  let str = "<" + value.type;
32512
33023
  if (value.props) {
32513
- for (const [key, val] of Object.entries(value.props)) {
33024
+ const propsEntries = Object.entries(value.props);
33025
+ for (let i = 0; i < propsEntries.length; i++) {
33026
+ const [key, val] = propsEntries[i];
32514
33027
  str += " " + key + "=" + qwikDebugToString(val);
32515
33028
  }
32516
33029
  const children = value.children;
32517
33030
  if (children != null) {
32518
33031
  str += ">";
32519
33032
  if (Array.isArray(children)) {
32520
- children.forEach((child) => {
33033
+ for (let i = 0; i < children.length; i++) {
33034
+ const child = children[i];
32521
33035
  str += jsxToString(child);
32522
- });
33036
+ }
32523
33037
  } else {
32524
33038
  str += jsxToString(children);
32525
33039
  }
@@ -33780,12 +34294,14 @@ function vnode_toString(depth = 20, offset = "", materialize2 = false, siblings
33780
34294
  attrs.push(` dirty:${vnode.dirty}`);
33781
34295
  }
33782
34296
  if (container) {
33783
- vnode_getAttrKeys(container, vnode).forEach((key) => {
34297
+ const attrKeys = vnode_getAttrKeys(container, vnode);
34298
+ for (let i = 0; i < attrKeys.length; i++) {
34299
+ const key = attrKeys[i];
33784
34300
  if (key !== DEBUG_TYPE && key !== debugStyleScopeIdPrefixAttr) {
33785
34301
  const value = vnode_getProp(vnode, key, null);
33786
34302
  attrs.push(" " + key + "=" + qwikDebugToString(value));
33787
34303
  }
33788
- });
34304
+ }
33789
34305
  }
33790
34306
  const name = (colorize ? NAME_COL_PREFIX : "") + (VirtualTypeName[vnode_getProp(vnode, DEBUG_TYPE, null) || "V" /* Virtual */] || VirtualTypeName["V" /* Virtual */]) + (colorize ? NAME_COL_SUFFIX : "");
33791
34307
  strings.push("<" + name + attrs.join("") + ">");
@@ -33807,7 +34323,8 @@ function vnode_toString(depth = 20, offset = "", materialize2 = false, siblings
33807
34323
  attrs.push(` dirtyChildren[${vnode.dirtyChildren.length}]`);
33808
34324
  }
33809
34325
  const keys = container ? vnode_getAttrKeys(container, vnode) : [];
33810
- for (const key of keys) {
34326
+ for (let i = 0; i < keys.length; i++) {
34327
+ const key = keys[i];
33811
34328
  const value = vnode_getProp(vnode, key, null);
33812
34329
  attrs.push(" " + key + "=" + qwikDebugToString(value));
33813
34330
  }
@@ -34140,9 +34657,12 @@ var MockShadowRoot = class extends import_domino.default.impl.DocumentFragment {
34140
34657
  this.ownerDocument = host.ownerDocument;
34141
34658
  }
34142
34659
  append(...nodes) {
34143
- for (const node of nodes) {
34660
+ for (let i = 0; i < nodes.length; i++) {
34661
+ const node = nodes[i];
34144
34662
  if (node.nodeType === 11) {
34145
- for (const child of Array.from(node.childNodes)) {
34663
+ const childNodes = Array.from(node.childNodes);
34664
+ for (let j = 0; j < childNodes.length; j++) {
34665
+ const child = childNodes[j];
34146
34666
  this.appendChild(child);
34147
34667
  }
34148
34668
  } else {
@@ -34665,9 +35185,10 @@ function diffJsxVNode(received, expected, path = [], container, isSsr) {
34665
35185
  receivedElement && propsAdd(allProps, constPropsFromElement(receivedElement));
34666
35186
  path.push(tagToString(expected.type));
34667
35187
  allProps.sort();
34668
- allProps.forEach((prop) => {
35188
+ for (let i = 0; i < allProps.length; i++) {
35189
+ const prop = allProps[i];
34669
35190
  if (isJsxPropertyAnEventName(prop) || isHtmlAttributeAnEventName(prop)) {
34670
- return;
35191
+ continue;
34671
35192
  }
34672
35193
  const propLowerCased = prop.toLowerCase();
34673
35194
  let convertNullToUndefined = false;
@@ -34691,7 +35212,7 @@ function diffJsxVNode(received, expected, path = [], container, isSsr) {
34691
35212
  diffs.push(" EXPECTED: " + JSON.stringify(expectedValue));
34692
35213
  diffs.push(" RECEIVED: " + JSON.stringify(receivedValue));
34693
35214
  }
34694
- });
35215
+ }
34695
35216
  diffJsxVNodeChildren(received, expected, path, container, isSsr, diffs);
34696
35217
  } else if (isSsr && isSkippableNode(expected)) {
34697
35218
  diffJsxVNodeChildren(received, expected, path, container, isSsr, diffs);
@@ -34745,7 +35266,8 @@ function getFilteredJSXChildren(children, isSsr, data) {
34745
35266
  }
34746
35267
  };
34747
35268
  function processChildren(children2) {
34748
- for (const child of children2) {
35269
+ for (let i = 0; i < children2.length; i++) {
35270
+ const child = children2[i];
34749
35271
  if (typeof child === "string" || typeof child === "number") {
34750
35272
  if (child !== "") {
34751
35273
  data.mergedText = typeof data.mergedText === "string" ? data.mergedText + child : String(child);
@@ -34805,9 +35327,11 @@ function jsxToHTML(jsx2, pad2 = "") {
34805
35327
  const html = [];
34806
35328
  if (jsx2.type) {
34807
35329
  html.push(pad2, "<", tagToString(jsx2.type), ">\n");
34808
- getJSXChildren(jsx2).forEach((jsx3) => {
35330
+ const children = getJSXChildren(jsx2);
35331
+ for (let i = 0; i < children.length; i++) {
35332
+ const jsx3 = children[i];
34809
35333
  html.push(jsxToHTML(jsx3, pad2 + " "));
34810
- });
35334
+ }
34811
35335
  html.push(pad2, "</", tagToString(jsx2.type), ">\n");
34812
35336
  } else {
34813
35337
  html.push(pad2, JSON.stringify(jsx2), "\n");
@@ -34839,7 +35363,8 @@ function walkJSX(jsx2, apply) {
34839
35363
  if (_isJSXNode(jsx2)) {
34840
35364
  apply.enter(jsx2);
34841
35365
  if (Array.isArray(jsx2.children)) {
34842
- for (const child of jsx2.children) {
35366
+ for (let i = 0; i < jsx2.children.length; i++) {
35367
+ const child = jsx2.children[i];
34843
35368
  processChild(child);
34844
35369
  }
34845
35370
  } else if (jsx2.children) {
@@ -34935,11 +35460,12 @@ function constPropsFromElement(element) {
34935
35460
  return props;
34936
35461
  }
34937
35462
  function propsAdd(existing, incoming) {
34938
- for (const prop of incoming) {
35463
+ for (let i = 0; i < incoming.length; i++) {
35464
+ const prop = incoming[i];
34939
35465
  if (prop !== "children") {
34940
35466
  let found = false;
34941
- for (let i = 0; i < existing.length; i++) {
34942
- if (existing[i].toLowerCase() === prop.toLowerCase()) {
35467
+ for (let j = 0; j < existing.length; j++) {
35468
+ if (existing[j].toLowerCase() === prop.toLowerCase()) {
34943
35469
  found = true;
34944
35470
  break;
34945
35471
  }
@@ -34990,7 +35516,9 @@ var ElementFixture = class {
34990
35516
  this.parent.innerHTML = options.html;
34991
35517
  this.host = this.parent.firstElementChild;
34992
35518
  assertDefined(this.host, "host element must be defined");
34993
- this.host.querySelectorAll('script[q\\:func="qwik/json"]').forEach((script2) => {
35519
+ const scripts = this.host.querySelectorAll('script[q\\:func="qwik/json"]');
35520
+ for (let i = 0; i < scripts.length; i++) {
35521
+ const script2 = scripts[i];
34994
35522
  const code2 = script2.textContent;
34995
35523
  if (code2?.match(Q_FUNCS_PREFIX)) {
34996
35524
  const equal = code2.indexOf("=");
@@ -34999,7 +35527,7 @@ var ElementFixture = class {
34999
35527
  const hash2 = container.getAttribute(QInstanceAttr);
35000
35528
  document[QFuncsPrefix + hash2] = qFuncs2;
35001
35529
  }
35002
- });
35530
+ }
35003
35531
  this.child = null;
35004
35532
  } else {
35005
35533
  this.host = this.document.createElement(options.tagName || "host");
@@ -35011,28 +35539,15 @@ var ElementFixture = class {
35011
35539
  };
35012
35540
  async function trigger(root, queryOrElement, eventName, eventPayload = {}, options) {
35013
35541
  const waitForIdle = options?.waitForIdle ?? true;
35014
- let scope;
35015
- let kebabName;
35016
- let scopedKebabName;
35017
- if (eventName.charAt(1) === ":") {
35018
- scopedKebabName = eventName;
35019
- scope = eventName.charAt(0);
35020
- kebabName = eventName.substring(2);
35021
- if (kebabName === "DOMContentLoaded") {
35022
- kebabName = "-d-o-m-content-loaded";
35023
- scopedKebabName = scope + ":" + kebabName;
35024
- }
35025
- } else {
35026
- scope = "e";
35027
- kebabName = fromCamelToKebabCase(eventName);
35028
- scopedKebabName = "e:" + kebabName;
35029
- }
35030
- if (scope !== "e") {
35031
- queryOrElement = `[q-${scope}\\:${kebabName}]`;
35542
+ const { rootScope, kebabName, selectors, scopedEventNames } = parseTriggerEvent(eventName);
35543
+ let event = null;
35544
+ if (selectors) {
35545
+ queryOrElement = selectors;
35032
35546
  }
35033
35547
  const elements = typeof queryOrElement === "string" ? Array.from(root.querySelectorAll(queryOrElement)) : [queryOrElement];
35034
35548
  let container = null;
35035
- for (const element of elements) {
35549
+ for (let i = 0; i < elements.length; i++) {
35550
+ const element = elements[i];
35036
35551
  if (!element) {
35037
35552
  continue;
35038
35553
  }
@@ -35040,29 +35555,114 @@ async function trigger(root, queryOrElement, eventName, eventPayload = {}, optio
35040
35555
  container = getDomContainer2(element);
35041
35556
  }
35042
35557
  const { bubbles = true, cancelable = true, ...rest } = eventPayload ?? {};
35043
- const event = new Event(eventName, {
35558
+ event = new Event(eventName, {
35044
35559
  bubbles,
35045
35560
  cancelable
35046
35561
  });
35047
35562
  Object.assign(event, rest);
35048
- await dispatch(element, event, scopedKebabName, kebabName);
35563
+ for (let i2 = 0; i2 < scopedEventNames.length; i2++) {
35564
+ const { scope, scopedKebabName } = scopedEventNames[i2];
35565
+ await dispatch(element, event, scopedKebabName, kebabName, scope === rootScope);
35566
+ }
35049
35567
  }
35050
35568
  if (waitForIdle && container) {
35051
35569
  await waitForDrain(container);
35052
35570
  }
35571
+ return event;
35053
35572
  }
35054
- var PREVENT_DEFAULT = "preventdefault:";
35573
+ var parseTriggerEvent = (eventName) => {
35574
+ let scope = "e";
35575
+ let kebabName = eventName;
35576
+ const separatorIndex = eventName.indexOf(":");
35577
+ if (separatorIndex !== -1) {
35578
+ scope = eventName.slice(0, separatorIndex);
35579
+ kebabName = eventName.substring(separatorIndex + 1);
35580
+ if (kebabName === "DOMContentLoaded") {
35581
+ kebabName = "-d-o-m-content-loaded";
35582
+ }
35583
+ } else {
35584
+ kebabName = fromCamelToKebabCase(eventName);
35585
+ }
35586
+ const rootScope = scope.charAt(0);
35587
+ const scopes = scope.length === 2 ? [scope] : [scope, `${scope}p`];
35588
+ return {
35589
+ rootScope,
35590
+ kebabName,
35591
+ selectors: rootScope === "e" ? void 0 : scopes.map((scope2) => `[q-${scope2}\\:${kebabName}]`).join(", "),
35592
+ scopedEventNames: scopes.map((scope2) => ({
35593
+ scope: scope2,
35594
+ scopedKebabName: `${scope2}:${kebabName}`
35595
+ }))
35596
+ };
35597
+ };
35598
+ var PREVENT_DEFAULT2 = "preventdefault:";
35055
35599
  var STOP_PROPAGATION = "stoppropagation:";
35600
+ var CAPTURE = "capture:";
35056
35601
  var Q_FUNCS_PREFIX = /document.qdata\["qFuncs_(.+)"\]=/;
35057
35602
  var QContainerSelector2 = "[q\\:container]";
35058
- var dispatch = async (element, event, scopedKebabName, kebabName) => {
35059
- const preventAttributeName = PREVENT_DEFAULT + kebabName;
35603
+ var isElementNode = (node) => !!node && node.nodeType === 1;
35604
+ var isPromise2 = (promise) => promise && typeof promise.then === "function";
35605
+ var queuedTasks;
35606
+ var runTasks = async (tasks) => {
35607
+ for (let i = 0; i < tasks.length; i++) {
35608
+ await tasks[i]();
35609
+ }
35610
+ };
35611
+ var queueTasks = (tasks) => {
35612
+ const run = () => runTasks(tasks);
35613
+ queuedTasks = queuedTasks ? queuedTasks.then(run, run) : run();
35614
+ return queuedTasks;
35615
+ };
35616
+ var dispatch = async (element, event, scopedKebabName, kebabName, allowPreventDefault = true) => {
35617
+ const captureAttributeName = CAPTURE + kebabName;
35618
+ const elements = [];
35619
+ const captureHandlers = [];
35620
+ const tasks = [];
35621
+ let current = element;
35622
+ while (current) {
35623
+ if (isElementNode(current)) {
35624
+ elements.push(current);
35625
+ captureHandlers.push(
35626
+ current.hasAttribute(captureAttributeName) && (!!current.getAttribute("q-" + scopedKebabName) || "_qDispatch" in current && !!current._qDispatch?.[scopedKebabName])
35627
+ );
35628
+ current = current.parentElement;
35629
+ } else {
35630
+ current = current.parentElement;
35631
+ }
35632
+ }
35633
+ for (let i = elements.length - 1; i >= 0; i--) {
35634
+ if (captureHandlers[i]) {
35635
+ dispatchOnElement(elements[i], event, scopedKebabName, tasks, kebabName, allowPreventDefault);
35636
+ const continuePropagation = !event.cancelBubble;
35637
+ if (!continuePropagation || event.cancelBubble) {
35638
+ await queueTasks(tasks);
35639
+ return;
35640
+ }
35641
+ }
35642
+ }
35643
+ for (let i = 0; i < elements.length; i++) {
35644
+ if (!captureHandlers[i]) {
35645
+ dispatchOnElement(elements[i], event, scopedKebabName, tasks, kebabName, allowPreventDefault);
35646
+ const doBubble = event.bubbles && !event.cancelBubble;
35647
+ if (!doBubble || event.cancelBubble) {
35648
+ await queueTasks(tasks);
35649
+ return;
35650
+ }
35651
+ }
35652
+ }
35653
+ await queueTasks(tasks);
35654
+ };
35655
+ var dispatchOnElement = (element, event, scopedKebabName, tasks, kebabName, allowPreventDefault = true) => {
35656
+ const preventAttributeName = PREVENT_DEFAULT2 + kebabName;
35060
35657
  const stopPropagationName = STOP_PROPAGATION + kebabName;
35061
- while (element) {
35658
+ if (element) {
35659
+ let defer = false;
35660
+ const handlers = "_qDispatch" in element ? element._qDispatch?.[scopedKebabName] : void 0;
35661
+ const attrValue = element.getAttribute("q-" + scopedKebabName);
35062
35662
  if (kebabName) {
35063
35663
  const preventDefault = element.hasAttribute(preventAttributeName);
35064
35664
  const stopPropagation = element.hasAttribute(stopPropagationName);
35065
- if (preventDefault) {
35665
+ if (allowPreventDefault && preventDefault) {
35066
35666
  event.preventDefault();
35067
35667
  }
35068
35668
  if (stopPropagation) {
@@ -35070,44 +35670,91 @@ var dispatch = async (element, event, scopedKebabName, kebabName) => {
35070
35670
  }
35071
35671
  }
35072
35672
  if ("_qDispatch" in element) {
35073
- const handlers = element._qDispatch?.[scopedKebabName];
35074
35673
  if (handlers) {
35075
35674
  if (typeof handlers === "function") {
35076
- await handlers(event, element);
35675
+ const run = () => handlers(event, element);
35676
+ if (defer) {
35677
+ tasks.push(async () => {
35678
+ const result2 = run();
35679
+ if (isPromise2(result2)) {
35680
+ await result2;
35681
+ }
35682
+ });
35683
+ } else {
35684
+ const result2 = run();
35685
+ if (isPromise2(result2)) {
35686
+ defer = true;
35687
+ tasks.push(() => result2);
35688
+ }
35689
+ }
35077
35690
  } else if (handlers.length) {
35078
- for (const handler of handlers) {
35691
+ for (let i = 0; i < handlers.length; i++) {
35692
+ const handler = handlers[i];
35079
35693
  if (handler) {
35080
- await handler(event, element);
35694
+ const run = () => handler(event, element);
35695
+ if (defer) {
35696
+ tasks.push(async () => {
35697
+ const result2 = run();
35698
+ if (isPromise2(result2)) {
35699
+ await result2;
35700
+ }
35701
+ });
35702
+ } else {
35703
+ const result2 = run();
35704
+ if (isPromise2(result2)) {
35705
+ defer = true;
35706
+ tasks.push(() => result2);
35707
+ }
35708
+ }
35081
35709
  }
35082
35710
  }
35083
35711
  }
35712
+ return;
35084
35713
  }
35085
- } else if (element.hasAttribute("q-" + scopedKebabName)) {
35086
- const qrls = element.getAttribute("q-" + scopedKebabName);
35714
+ }
35715
+ if (attrValue) {
35716
+ const qrls = attrValue;
35087
35717
  try {
35088
- for (const qrl of qrls.split("|")) {
35718
+ const qrlsArray = qrls.split("|");
35719
+ for (let i = 0; i < qrlsArray.length; i++) {
35720
+ const qrl = qrlsArray[i];
35089
35721
  const [chunk, symbol, captures] = qrl.split("#");
35090
- let fn;
35091
- if (chunk) {
35092
- fn = globalThis.__qrl_back_channel__?.get(symbol);
35093
- if (typeof fn !== "function") {
35094
- throw new Error(`QRL function not found in back channel for ${qrl}`);
35722
+ const run = () => {
35723
+ let fn;
35724
+ if (chunk) {
35725
+ fn = globalThis.__qrl_back_channel__?.get(symbol);
35726
+ if (typeof fn !== "function") {
35727
+ throw new Error(`QRL function not found in back channel for ${qrl}`);
35728
+ }
35729
+ } else {
35730
+ const container = getDomContainer2(element);
35731
+ const sync = container.parseQRL(qrl);
35732
+ sync.resolve();
35733
+ fn = sync.resolved;
35095
35734
  }
35735
+ return fn.apply(captures, [event, element]);
35736
+ };
35737
+ if (chunk || defer) {
35738
+ defer = true;
35739
+ tasks.push(async () => {
35740
+ const result2 = run();
35741
+ if (isPromise2(result2)) {
35742
+ await result2;
35743
+ }
35744
+ });
35096
35745
  } else {
35097
- const container = getDomContainer2(element);
35098
- const sync = container.parseQRL(qrl);
35099
- sync.resolve();
35100
- fn = sync.resolved;
35746
+ const result2 = run();
35747
+ if (isPromise2(result2)) {
35748
+ defer = true;
35749
+ tasks.push(() => result2);
35750
+ }
35101
35751
  }
35102
- await fn.apply(captures, [event, element]);
35103
35752
  }
35104
35753
  } catch (error) {
35105
35754
  console.error("!!! qrl error", qrls, error);
35106
35755
  throw error;
35107
35756
  }
35108
- return;
35109
35757
  }
35110
- element = event.bubbles && !event.cancelBubble ? element.parentElement : null;
35111
35758
  }
35112
35759
  };
35113
35760
 
@@ -35180,7 +35827,8 @@ function toPath(url) {
35180
35827
  }
35181
35828
  const path = fileURLToPath(String(normalizedUrl));
35182
35829
  const importPaths = [path, ...testExts.map((ext) => path + ext)];
35183
- for (const importPath of importPaths) {
35830
+ for (let i = 0; i < importPaths.length; i++) {
35831
+ const importPath = importPaths[i];
35184
35832
  if (existsSync(importPath)) {
35185
35833
  return importPath;
35186
35834
  }
@@ -35234,19 +35882,24 @@ import { fileURLToPath as fileURLToPath2 } from "url";
35234
35882
  import { expect as expect2 } from "vitest";
35235
35883
 
35236
35884
  // packages/qwik/src/core/preloader/queue.ts
35237
- import { isBrowser as isBrowser5 } from "@qwik.dev/core/build";
35885
+ import { isBrowser as isBrowser7 } from "@qwik.dev/core/build";
35886
+
35887
+ // packages/qwik/src/core/preloader/bundle-graph.ts
35888
+ import { isServer as isServer14 } from "@qwik.dev/core/build";
35238
35889
 
35239
35890
  // packages/qwik/src/core/preloader/constants.ts
35240
- import { isBrowser as isBrowser4 } from "@qwik.dev/core/build";
35241
- var doc = isBrowser4 ? document : void 0;
35891
+ import { isServer as isServer13 } from "@qwik.dev/core/build";
35892
+ var isBrowser5 = import.meta.env.TEST ? !isServerPlatform() : !isServer13;
35893
+ var doc = isBrowser5 ? document : void 0;
35242
35894
  var config = {
35243
35895
  $DEBUG$: false,
35244
35896
  $maxIdlePreloads$: 25,
35245
35897
  $invPreloadProbability$: 0.65
35246
35898
  };
35247
- var rel = isBrowser4 && doc.createElement("link").relList.supports("modulepreload") ? "modulePreload" : "preload";
35248
- var loadStart = Date.now();
35899
+ var rel = isBrowser5 && doc.createElement("link").relList?.supports?.("modulepreload") ? "modulePreload" : "preload";
35900
+ var loadStart = performance.now();
35249
35901
  var isJSRegex = /\.[mc]?js$/;
35902
+ var yieldInterval = 1e3 / 60;
35250
35903
 
35251
35904
  // packages/qwik/src/core/preloader/types.ts
35252
35905
  var BundleImportState_None = 0;
@@ -35258,13 +35911,14 @@ var BundleImportState_Loaded = 4;
35258
35911
  // packages/qwik/src/core/preloader/bundle-graph.ts
35259
35912
  var base;
35260
35913
  var graph;
35914
+ var isBrowser6 = import.meta.env.TEST ? !isServerPlatform() : !isServer14;
35261
35915
  var makeBundle = (name, deps) => {
35262
35916
  return {
35263
35917
  $name$: name,
35264
35918
  $state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
35265
35919
  $deps$: shouldResetFactor ? deps?.map((d) => ({ ...d, $factor$: 1 })) : deps,
35266
35920
  $inverseProbability$: 1,
35267
- $createdTs$: Date.now(),
35921
+ $createdTs$: performance.now(),
35268
35922
  $waitedMs$: 0,
35269
35923
  $loadedMs$: 0
35270
35924
  };
@@ -35333,9 +35987,16 @@ var shouldResetFactor;
35333
35987
  var queueDirty;
35334
35988
  var preloadCount = 0;
35335
35989
  var queue = [];
35990
+ var nextTriggerMacroTask = createMacroTask(trigger2);
35991
+ var nextAdjustmentMacroTask = createMacroTask(processPendingAdjustments);
35992
+ var isTriggerScheduled = false;
35993
+ var isAdjustmentScheduled = false;
35994
+ var isProcessingAdjustments = false;
35995
+ var shouldYieldInBrowser = import.meta.env.TEST ? !isServerPlatform() : isBrowser7;
35996
+ var adjustmentStack = [];
35336
35997
  var log7 = (...args) => {
35337
35998
  console.log(
35338
- `Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
35999
+ `Preloader ${performance.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
35339
36000
  ...args
35340
36001
  );
35341
36002
  };
@@ -35345,6 +36006,10 @@ var resetQueue = () => {
35345
36006
  shouldResetFactor = true;
35346
36007
  preloadCount = 0;
35347
36008
  queue.length = 0;
36009
+ adjustmentStack.length = 0;
36010
+ isTriggerScheduled = false;
36011
+ isAdjustmentScheduled = false;
36012
+ isProcessingAdjustments = false;
35348
36013
  };
35349
36014
  var sortQueue = () => {
35350
36015
  if (queueDirty) {
@@ -35356,7 +36021,8 @@ var getQueue = () => {
35356
36021
  sortQueue();
35357
36022
  let probability = 0.4;
35358
36023
  const result2 = [];
35359
- for (const b of queue) {
36024
+ for (let i = 0; i < queue.length; i++) {
36025
+ const b = queue[i];
35360
36026
  const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
35361
36027
  if (nextProbability !== probability) {
35362
36028
  probability = nextProbability;
@@ -35366,11 +36032,14 @@ var getQueue = () => {
35366
36032
  }
35367
36033
  return result2;
35368
36034
  };
35369
- var trigger2 = () => {
36035
+ function trigger2() {
36036
+ isTriggerScheduled = false;
35370
36037
  if (!queue.length) {
35371
36038
  return;
35372
36039
  }
35373
36040
  sortQueue();
36041
+ const deadline = performance.now() + yieldInterval;
36042
+ let shouldYield = false;
35374
36043
  while (queue.length) {
35375
36044
  const bundle = queue[0];
35376
36045
  const inverseProbability = bundle.$inverseProbability$;
@@ -35382,10 +36051,18 @@ var trigger2 = () => {
35382
36051
  if (probability >= 0.99 || preloadCount < allowedPreloads) {
35383
36052
  queue.shift();
35384
36053
  preloadOne(bundle);
36054
+ if (performance.now() >= deadline) {
36055
+ shouldYield = true;
36056
+ break;
36057
+ }
35385
36058
  } else {
35386
36059
  break;
35387
36060
  }
35388
36061
  }
36062
+ if (shouldYield && queue.length && !isTriggerScheduled) {
36063
+ isTriggerScheduled = true;
36064
+ nextTriggerMacroTask();
36065
+ }
35389
36066
  if (config.$DEBUG$ && !queue.length) {
35390
36067
  const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
35391
36068
  const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
@@ -35394,13 +36071,112 @@ var trigger2 = () => {
35394
36071
  `>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
35395
36072
  );
35396
36073
  }
36074
+ }
36075
+ var enqueueAdjustment = (bundle, inverseProbability, context, seen) => {
36076
+ adjustmentStack.unshift({
36077
+ $bundle$: bundle,
36078
+ $inverseProbability$: inverseProbability,
36079
+ $seen$: seen,
36080
+ $context$: context
36081
+ });
35397
36082
  };
36083
+ var processAdjustmentFrame = () => {
36084
+ const frame = adjustmentStack[adjustmentStack.length - 1];
36085
+ const bundle = frame.$bundle$;
36086
+ if (frame.$deps$) {
36087
+ const index = frame.$index$;
36088
+ if (index >= frame.$deps$.length) {
36089
+ adjustmentStack.pop();
36090
+ return false;
36091
+ }
36092
+ const dep = frame.$deps$[index];
36093
+ frame.$index$ = index + 1;
36094
+ const depBundle = getBundle(dep.$name$);
36095
+ if (depBundle.$inverseProbability$ === 0) {
36096
+ return true;
36097
+ }
36098
+ const probability = 1 - bundle.$inverseProbability$;
36099
+ let newInverseProbability;
36100
+ if (probability === 1 || probability >= 0.99 && frame.$context$.$depsCount$ < 100) {
36101
+ frame.$context$.$depsCount$++;
36102
+ newInverseProbability = Math.min(0.01, 1 - dep.$importProbability$);
36103
+ } else {
36104
+ const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
36105
+ const prevAdjust = dep.$factor$;
36106
+ const factor = newInverseImportProbability / prevAdjust;
36107
+ newInverseProbability = Math.max(0.02, depBundle.$inverseProbability$ * factor);
36108
+ dep.$factor$ = factor;
36109
+ }
36110
+ adjustmentStack.push({
36111
+ $bundle$: depBundle,
36112
+ $inverseProbability$: newInverseProbability,
36113
+ $seen$: frame.$seen$,
36114
+ $context$: frame.$context$
36115
+ });
36116
+ return true;
36117
+ }
36118
+ if (frame.$seen$?.has(bundle)) {
36119
+ adjustmentStack.pop();
36120
+ return false;
36121
+ }
36122
+ const previousInverseProbability = bundle.$inverseProbability$;
36123
+ bundle.$inverseProbability$ = frame.$inverseProbability$;
36124
+ if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
36125
+ adjustmentStack.pop();
36126
+ return false;
36127
+ }
36128
+ if (
36129
+ // don't queue until we have initialized the preloader
36130
+ base != null && bundle.$state$ < BundleImportState_Preload
36131
+ ) {
36132
+ if (bundle.$state$ === BundleImportState_None) {
36133
+ bundle.$state$ = BundleImportState_Queued;
36134
+ queue.push(bundle);
36135
+ config.$DEBUG$ && log7(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
36136
+ }
36137
+ queueDirty = true;
36138
+ }
36139
+ if (bundle.$deps$?.length) {
36140
+ const seen = frame.$seen$ || /* @__PURE__ */ new Set();
36141
+ seen.add(bundle);
36142
+ frame.$seen$ = seen;
36143
+ frame.$deps$ = bundle.$deps$;
36144
+ frame.$index$ = 0;
36145
+ return false;
36146
+ }
36147
+ adjustmentStack.pop();
36148
+ return false;
36149
+ };
36150
+ function processPendingAdjustments() {
36151
+ if (isProcessingAdjustments || !adjustmentStack.length) {
36152
+ return;
36153
+ }
36154
+ isAdjustmentScheduled = false;
36155
+ isProcessingAdjustments = true;
36156
+ const deadline = shouldYieldInBrowser ? performance.now() + yieldInterval : 0;
36157
+ let processed = false;
36158
+ while (adjustmentStack.length) {
36159
+ processed = true;
36160
+ const checkDeadline = processAdjustmentFrame();
36161
+ if (shouldYieldInBrowser && checkDeadline && performance.now() >= deadline) {
36162
+ if (!isAdjustmentScheduled) {
36163
+ isAdjustmentScheduled = true;
36164
+ nextAdjustmentMacroTask();
36165
+ }
36166
+ break;
36167
+ }
36168
+ }
36169
+ isProcessingAdjustments = false;
36170
+ if (processed && shouldYieldInBrowser) {
36171
+ nextTriggerMacroTask();
36172
+ }
36173
+ }
35398
36174
  var preloadOne = (bundle) => {
35399
36175
  if (bundle.$state$ >= BundleImportState_Preload) {
35400
36176
  return;
35401
36177
  }
35402
36178
  preloadCount++;
35403
- const start = Date.now();
36179
+ const start = performance.now();
35404
36180
  bundle.$waitedMs$ = start - bundle.$createdTs$;
35405
36181
  bundle.$state$ = BundleImportState_Preload;
35406
36182
  config.$DEBUG$ && log7(
@@ -35413,89 +36189,58 @@ var preloadOne = (bundle) => {
35413
36189
  link.as = "script";
35414
36190
  link.onload = link.onerror = () => {
35415
36191
  preloadCount--;
35416
- const end = Date.now();
36192
+ const end = performance.now();
35417
36193
  bundle.$loadedMs$ = end - start;
35418
36194
  bundle.$state$ = BundleImportState_Loaded;
35419
36195
  config.$DEBUG$ && log7(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
35420
36196
  link.remove();
35421
- trigger2();
36197
+ nextTriggerMacroTask();
35422
36198
  };
35423
36199
  doc.head.appendChild(link);
35424
36200
  };
35425
36201
  var adjustProbabilities = (bundle, newInverseProbability, seen) => {
35426
- if (seen?.has(bundle)) {
35427
- return;
35428
- }
35429
- const previousInverseProbability = bundle.$inverseProbability$;
35430
- bundle.$inverseProbability$ = newInverseProbability;
35431
- if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
35432
- return;
35433
- }
35434
- if (
35435
- // don't queue until we have initialized the preloader
35436
- base != null && bundle.$state$ < BundleImportState_Preload
35437
- ) {
35438
- if (bundle.$state$ === BundleImportState_None) {
35439
- bundle.$state$ = BundleImportState_Queued;
35440
- queue.push(bundle);
35441
- config.$DEBUG$ && log7(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
35442
- }
35443
- queueDirty = true;
35444
- }
35445
- if (bundle.$deps$) {
35446
- seen || (seen = /* @__PURE__ */ new Set());
35447
- seen.add(bundle);
35448
- const probability = 1 - bundle.$inverseProbability$;
35449
- for (const dep of bundle.$deps$) {
35450
- const depBundle = getBundle(dep.$name$);
35451
- if (depBundle.$inverseProbability$ === 0) {
35452
- continue;
35453
- }
35454
- let newInverseProbability2;
35455
- if (probability === 1 || probability >= 0.99 && depsCount < 100) {
35456
- depsCount++;
35457
- newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
35458
- } else {
35459
- const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
35460
- const prevAdjust = dep.$factor$;
35461
- const factor = newInverseImportProbability / prevAdjust;
35462
- newInverseProbability2 = Math.max(0.02, depBundle.$inverseProbability$ * factor);
35463
- dep.$factor$ = factor;
35464
- }
35465
- adjustProbabilities(depBundle, newInverseProbability2, seen);
35466
- }
36202
+ enqueueAdjustment(bundle, newInverseProbability, { $depsCount$: 0 }, seen);
36203
+ if (shouldYieldInBrowser) {
36204
+ nextAdjustmentMacroTask();
36205
+ } else {
36206
+ processPendingAdjustments();
35467
36207
  }
35468
36208
  };
35469
- var handleBundle = (name, inverseProbability) => {
36209
+ var handleBundle = (name, inverseProbability, context) => {
35470
36210
  const bundle = getBundle(name);
35471
36211
  if (bundle && bundle.$inverseProbability$ > inverseProbability) {
35472
- adjustProbabilities(bundle, inverseProbability);
36212
+ if (context) {
36213
+ enqueueAdjustment(bundle, inverseProbability, context);
36214
+ } else {
36215
+ adjustProbabilities(bundle, inverseProbability);
36216
+ }
35473
36217
  }
35474
36218
  };
35475
- var depsCount;
35476
36219
  var preload2 = (name, probability) => {
35477
36220
  if (!name?.length) {
35478
36221
  return;
35479
36222
  }
35480
- depsCount = 0;
35481
36223
  let inverseProbability = probability ? 1 - probability : 0.4;
36224
+ const context = { $depsCount$: 0 };
35482
36225
  if (Array.isArray(name)) {
35483
36226
  for (let i = name.length - 1; i >= 0; i--) {
35484
36227
  const item = name[i];
35485
36228
  if (typeof item === "number") {
35486
36229
  inverseProbability = 1 - item / 10;
35487
36230
  } else {
35488
- handleBundle(item, inverseProbability);
36231
+ handleBundle(item, inverseProbability, context);
35489
36232
  }
35490
36233
  }
35491
36234
  } else {
35492
- handleBundle(name, inverseProbability);
36235
+ handleBundle(name, inverseProbability, context);
35493
36236
  }
35494
- if (isBrowser5) {
35495
- trigger2();
36237
+ if (shouldYieldInBrowser) {
36238
+ nextAdjustmentMacroTask();
36239
+ } else {
36240
+ processPendingAdjustments();
35496
36241
  }
35497
36242
  };
35498
- if (isBrowser5) {
36243
+ if (import.meta.env.TEST ? !isServerPlatform() : isBrowser7) {
35499
36244
  document.addEventListener("qsymbol", (ev) => {
35500
36245
  const { symbol, href } = ev.detail;
35501
36246
  if (href) {
@@ -35629,7 +36374,8 @@ function flattenPrefetchResources(prefetchResources) {
35629
36374
  const urls = [];
35630
36375
  const addPrefetchResource = (prefetchResources2) => {
35631
36376
  if (prefetchResources2) {
35632
- for (const prefetchResource of prefetchResources2) {
36377
+ for (let i = 0; i < prefetchResources2.length; i++) {
36378
+ const prefetchResource = prefetchResources2[i];
35633
36379
  if (!urls.includes(prefetchResource.url)) {
35634
36380
  urls.push(prefetchResource.url);
35635
36381
  if (prefetchResource.imports) {
@@ -35676,8 +36422,8 @@ function getPreloadPaths(qrls, opts, resolvedManifest) {
35676
36422
  }
35677
36423
  }
35678
36424
  const symbols = /* @__PURE__ */ new Set();
35679
- for (const qrl of qrls) {
35680
- const symbol = getSymbolHash2(qrl.$symbol$);
36425
+ for (let i = 0; i < qrls.length; i++) {
36426
+ const symbol = getSymbolHash2(qrls[i].$symbol$);
35681
36427
  if (symbol && symbol.length >= 10) {
35682
36428
  symbols.add(symbol);
35683
36429
  }
@@ -35690,8 +36436,8 @@ var expandBundles = (names, resolvedManifest) => {
35690
36436
  }
35691
36437
  resetQueue();
35692
36438
  let probability = 0.99;
35693
- for (const name of names) {
35694
- preload2(name, probability);
36439
+ for (let i = 0; i < names.length; i++) {
36440
+ preload2(names[i], probability);
35695
36441
  probability *= 0.95;
35696
36442
  }
35697
36443
  return getQueue();
@@ -35704,7 +36450,8 @@ var simplifyPath = (base2, path) => {
35704
36450
  }
35705
36451
  const segments = `${base2}${path}`.split("/");
35706
36452
  const simplified = [];
35707
- for (const segment of segments) {
36453
+ for (let i = 0; i < segments.length; i++) {
36454
+ const segment = segments[i];
35708
36455
  if (segment === ".." && simplified.length > 0) {
35709
36456
  simplified.pop();
35710
36457
  } else {
@@ -35806,7 +36553,8 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
35806
36553
  const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
35807
36554
  let probability = 4;
35808
36555
  const tenXMinProbability = ssrPreloadProbability * 10;
35809
- for (const hrefOrProbability of expandedBundles) {
36556
+ for (let i = 0; i < expandedBundles.length; i++) {
36557
+ const hrefOrProbability = expandedBundles[i];
35810
36558
  if (typeof hrefOrProbability === "string") {
35811
36559
  if (probability < tenXMinProbability) {
35812
36560
  break;
@@ -35970,7 +36718,8 @@ var SsrNode = class {
35970
36718
  if (this.flags & 1 /* Updatable */) {
35971
36719
  this.flags &= ~1 /* Updatable */;
35972
36720
  if (this.children) {
35973
- for (const child of this.children) {
36721
+ for (let i = 0; i < this.children.length; i++) {
36722
+ const child = this.children[i];
35974
36723
  child.setTreeNonUpdatable();
35975
36724
  }
35976
36725
  }
@@ -36365,6 +37114,9 @@ var SSRContainer = class extends _SharedContainer2 {
36365
37114
  /** Renders opening tag for DOM element */
36366
37115
  openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null, hasMovedCaptures = true) {
36367
37116
  const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
37117
+ if (elementName === "noscript" || elementName === "template" || elementName === "script") {
37118
+ this.$noScriptHere$++;
37119
+ }
36368
37120
  if (
36369
37121
  // don't append qwik loader before qwik style elements
36370
37122
  // it will confuse the resuming, because styles are expected to be the first nodes in subtree
@@ -36372,8 +37124,6 @@ var SSRContainer = class extends _SharedContainer2 {
36372
37124
  ) {
36373
37125
  if (this.$noScriptHere$ === 0 && this.size > 30 * 1024 && elementName !== "body") {
36374
37126
  this.emitQwikLoaderInline();
36375
- } else if (elementName === "noscript" || elementName === "template") {
36376
- this.$noScriptHere$++;
36377
37127
  }
36378
37128
  }
36379
37129
  let innerHTML = void 0;
@@ -36462,10 +37212,8 @@ var SSRContainer = class extends _SharedContainer2 {
36462
37212
  this.write(GT);
36463
37213
  }
36464
37214
  this.lastNode = null;
36465
- if (this.qlInclude === 1 /* Inline */) {
36466
- if (elementName === "noscript" || elementName === "template") {
36467
- this.$noScriptHere$--;
36468
- }
37215
+ if (elementName === "noscript" || elementName === "template" || elementName === "script") {
37216
+ this.$noScriptHere$--;
36469
37217
  }
36470
37218
  }
36471
37219
  /** Writes opening data to vNodeData for fragment boundaries */
@@ -36828,7 +37576,8 @@ var SSRContainer = class extends _SharedContainer2 {
36828
37576
  emitPatchDataIfNeeded() {
36829
37577
  const patches = [];
36830
37578
  for (const [elementIndex, backpatchEntries] of this.backpatchMap) {
36831
- for (const backpatchEntry of backpatchEntries) {
37579
+ for (let i = 0; i < backpatchEntries.length; i++) {
37580
+ const backpatchEntry = backpatchEntries[i];
36832
37581
  patches.push(
36833
37582
  elementIndex,
36834
37583
  backpatchEntry.attrName,
@@ -36980,7 +37729,8 @@ var SSRContainer = class extends _SharedContainer2 {
36980
37729
  );
36981
37730
  let indent = " ";
36982
37731
  let lastName = "";
36983
- for (const frame3 of frames) {
37732
+ for (let i = 0; i < frames.length; i++) {
37733
+ const frame3 = frames[i];
36984
37734
  const [name, example] = allowedContent(frame3.tagNesting);
36985
37735
  text.push(
36986
37736
  `${indent}<${frame3.elementName}>${lastName !== name ? ` [${name}]${example ? ` -> ${example}` : ""}` : ""}`
@@ -36991,7 +37741,7 @@ var SSRContainer = class extends _SharedContainer2 {
36991
37741
  text.push(
36992
37742
  `${indent}<${elementName}> <= is not allowed as a child of ${allowedContent(previousTagNesting)[0]}.`
36993
37743
  );
36994
- throw newTagError(text.join("\n"));
37744
+ throw newTagError(text.map(escapeHTML).join("\n"));
36995
37745
  }
36996
37746
  }
36997
37747
  }
@@ -37319,9 +38069,10 @@ function resolveManifest(manifest) {
37319
38069
  }
37320
38070
  if (mergedManifest.mapping) {
37321
38071
  const mapper = {};
37322
- Object.entries(mergedManifest.mapping).forEach(([symbol, bundleFilename]) => {
38072
+ for (const symbol in mergedManifest.mapping) {
38073
+ const bundleFilename = mergedManifest.mapping[symbol];
37323
38074
  mapper[getSymbolHash2(symbol)] = [symbol, bundleFilename];
37324
- });
38075
+ }
37325
38076
  return {
37326
38077
  mapper,
37327
38078
  manifest: mergedManifest,
@@ -37356,7 +38107,9 @@ async function domRender(jsx2, opts = {}) {
37356
38107
  function getStylesFactory(document2) {
37357
38108
  return () => {
37358
38109
  const styles = {};
37359
- Array.from(document2.querySelectorAll("style")).forEach((style) => {
38110
+ const styleElements = document2.querySelectorAll("style");
38111
+ for (let i = 0; i < styleElements.length; i++) {
38112
+ const style = styleElements[i];
37360
38113
  const id = style.hasAttribute(QStyle) ? style.getAttribute(QStyle) : style.getAttribute(QScopedStyle) ? style.getAttribute(QScopedStyle) : null;
37361
38114
  if (id !== null) {
37362
38115
  const text = style.textContent;
@@ -37367,7 +38120,7 @@ function getStylesFactory(document2) {
37367
38120
  styles[id] = text;
37368
38121
  }
37369
38122
  }
37370
- });
38123
+ }
37371
38124
  return styles;
37372
38125
  };
37373
38126
  }
@@ -37439,7 +38192,8 @@ async function ssrRenderToDom(jsx2, opts = {}) {
37439
38192
  child = child.nextSibling;
37440
38193
  }
37441
38194
  vnode_insertBefore(journal, containerVNode, fragment, insertBefore);
37442
- for (const child2 of childrenToMove) {
38195
+ for (let i = 0; i < childrenToMove.length; i++) {
38196
+ const child2 = childrenToMove[i];
37443
38197
  vnode_moveToVirtual(fragment, child2, null);
37444
38198
  }
37445
38199
  vNode = fragment;