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

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.
package/dist/server.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/server 2.0.0-beta.30-dev+5421ed4
3
+ * @qwik.dev/core/server 2.0.0-beta.31-dev+906321a
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
@@ -227,6 +227,10 @@ var qError = (code, errorMessageArgs = []) => {
227
227
  // packages/qwik/src/core/shared/qrl/qrl-utils.ts
228
228
  import { isDev as isDev3 } from "@qwik.dev/core/build";
229
229
  var SYNC_QRL = "<sync>";
230
+ var getSymbolHash = (symbolName) => {
231
+ const index = symbolName.lastIndexOf("_") + 1;
232
+ return symbolName.slice(index);
233
+ };
230
234
 
231
235
  // packages/qwik/src/core/shared/types.ts
232
236
  var DEBUG_TYPE = "q:type";
@@ -749,7 +753,8 @@ var serializeClass = (obj) => {
749
753
  }
750
754
  const classes = [];
751
755
  if (isArray(obj)) {
752
- for (const o of obj) {
756
+ for (let i = 0; i < obj.length; i++) {
757
+ const o = obj[i];
753
758
  const classList = serializeClass(o);
754
759
  if (classList) {
755
760
  classes.push(classList);
@@ -828,19 +833,90 @@ function isAriaAttribute(prop) {
828
833
  import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
829
834
 
830
835
  // packages/qwik/src/core/preloader/bundle-graph.ts
831
- import { isBrowser as isBrowser2 } from "@qwik.dev/core/build";
836
+ import { isServer as isServer4 } from "@qwik.dev/core/build";
837
+
838
+ // packages/qwik/src/core/shared/platform/platform.ts
839
+ import { isServer as isServer2 } from "@qwik.dev/core/build";
840
+ var createPlatform = () => {
841
+ return {
842
+ isServer: isServer2,
843
+ importSymbol(containerEl, url, symbolName) {
844
+ if (isServer2) {
845
+ const hash = getSymbolHash(symbolName);
846
+ const regSym = globalThis.__qwik_reg_symbols?.get(hash);
847
+ if (regSym) {
848
+ return regSym;
849
+ }
850
+ throw qError(6 /* dynamicImportFailed */, [symbolName]);
851
+ }
852
+ if (!url) {
853
+ throw qError(14 /* qrlMissingChunk */, [symbolName]);
854
+ }
855
+ if (!containerEl) {
856
+ throw qError(13 /* qrlMissingContainer */, [url, symbolName]);
857
+ }
858
+ const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
859
+ const urlCopy = new URL(urlDoc);
860
+ urlCopy.hash = "";
861
+ const importURL = urlCopy.href;
862
+ return import(
863
+ /* @vite-ignore */
864
+ importURL
865
+ ).then((mod) => {
866
+ return mod[symbolName];
867
+ });
868
+ },
869
+ raf: (fn) => {
870
+ return new Promise((resolve) => {
871
+ requestAnimationFrame(() => {
872
+ resolve(fn());
873
+ });
874
+ });
875
+ },
876
+ chunkForSymbol(symbolName, chunk) {
877
+ return [symbolName, chunk ?? "_"];
878
+ }
879
+ };
880
+ };
881
+ var toUrl = (doc2, containerEl, url) => {
882
+ const baseURI = doc2.baseURI;
883
+ const base2 = new URL(containerEl.getAttribute(QBaseAttr) ?? baseURI, baseURI);
884
+ return new URL(url, base2);
885
+ };
886
+ var _platform = /* @__PURE__ */ createPlatform();
887
+ var isServerPlatform = () => {
888
+ if (qDynamicPlatform) {
889
+ return _platform.isServer;
890
+ }
891
+ return false;
892
+ };
893
+
894
+ // packages/qwik/src/core/shared/platform/next-tick.ts
895
+ var createMacroTask = (fn) => {
896
+ let macroTask;
897
+ if (typeof MessageChannel !== "undefined") {
898
+ const channel = new MessageChannel();
899
+ channel.port1.onmessage = () => fn();
900
+ macroTask = () => channel.port2.postMessage(null);
901
+ } else {
902
+ macroTask = () => setTimeout(fn);
903
+ }
904
+ return macroTask;
905
+ };
832
906
 
833
907
  // packages/qwik/src/core/preloader/constants.ts
834
- import { isBrowser } from "@qwik.dev/core/build";
908
+ import { isServer as isServer3 } from "@qwik.dev/core/build";
909
+ var isBrowser = import.meta.env.TEST ? !isServerPlatform() : !isServer3;
835
910
  var doc = isBrowser ? document : void 0;
836
911
  var config = {
837
912
  $DEBUG$: false,
838
913
  $maxIdlePreloads$: 25,
839
914
  $invPreloadProbability$: 0.65
840
915
  };
841
- var rel = isBrowser && doc.createElement("link").relList.supports("modulepreload") ? "modulePreload" : "preload";
842
- var loadStart = Date.now();
916
+ var rel = isBrowser && doc.createElement("link").relList?.supports?.("modulepreload") ? "modulePreload" : "preload";
917
+ var loadStart = performance.now();
843
918
  var isJSRegex = /\.[mc]?js$/;
919
+ var yieldInterval = 1e3 / 60;
844
920
 
845
921
  // packages/qwik/src/core/preloader/types.ts
846
922
  var BundleImportState_None = 0;
@@ -852,13 +928,14 @@ var BundleImportState_Loaded = 4;
852
928
  // packages/qwik/src/core/preloader/bundle-graph.ts
853
929
  var base;
854
930
  var graph;
931
+ var isBrowser2 = import.meta.env.TEST ? !isServerPlatform() : !isServer4;
855
932
  var makeBundle = (name, deps) => {
856
933
  return {
857
934
  $name$: name,
858
935
  $state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
859
936
  $deps$: shouldResetFactor ? deps?.map((d) => ({ ...d, $factor$: 1 })) : deps,
860
937
  $inverseProbability$: 1,
861
- $createdTs$: Date.now(),
938
+ $createdTs$: performance.now(),
862
939
  $waitedMs$: 0,
863
940
  $loadedMs$: 0
864
941
  };
@@ -927,9 +1004,16 @@ var shouldResetFactor;
927
1004
  var queueDirty;
928
1005
  var preloadCount = 0;
929
1006
  var queue = [];
1007
+ var nextTriggerMacroTask = createMacroTask(trigger);
1008
+ var nextAdjustmentMacroTask = createMacroTask(processPendingAdjustments);
1009
+ var isTriggerScheduled = false;
1010
+ var isAdjustmentScheduled = false;
1011
+ var isProcessingAdjustments = false;
1012
+ var shouldYieldInBrowser = import.meta.env.TEST ? !isServerPlatform() : isBrowser3;
1013
+ var adjustmentStack = [];
930
1014
  var log = (...args) => {
931
1015
  console.log(
932
- `Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
1016
+ `Preloader ${performance.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
933
1017
  ...args
934
1018
  );
935
1019
  };
@@ -939,6 +1023,10 @@ var resetQueue = () => {
939
1023
  shouldResetFactor = true;
940
1024
  preloadCount = 0;
941
1025
  queue.length = 0;
1026
+ adjustmentStack.length = 0;
1027
+ isTriggerScheduled = false;
1028
+ isAdjustmentScheduled = false;
1029
+ isProcessingAdjustments = false;
942
1030
  };
943
1031
  var sortQueue = () => {
944
1032
  if (queueDirty) {
@@ -950,7 +1038,8 @@ var getQueue = () => {
950
1038
  sortQueue();
951
1039
  let probability = 0.4;
952
1040
  const result = [];
953
- for (const b of queue) {
1041
+ for (let i = 0; i < queue.length; i++) {
1042
+ const b = queue[i];
954
1043
  const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
955
1044
  if (nextProbability !== probability) {
956
1045
  probability = nextProbability;
@@ -960,11 +1049,14 @@ var getQueue = () => {
960
1049
  }
961
1050
  return result;
962
1051
  };
963
- var trigger = () => {
1052
+ function trigger() {
1053
+ isTriggerScheduled = false;
964
1054
  if (!queue.length) {
965
1055
  return;
966
1056
  }
967
1057
  sortQueue();
1058
+ const deadline = performance.now() + yieldInterval;
1059
+ let shouldYield = false;
968
1060
  while (queue.length) {
969
1061
  const bundle = queue[0];
970
1062
  const inverseProbability = bundle.$inverseProbability$;
@@ -976,10 +1068,18 @@ var trigger = () => {
976
1068
  if (probability >= 0.99 || preloadCount < allowedPreloads) {
977
1069
  queue.shift();
978
1070
  preloadOne(bundle);
1071
+ if (performance.now() >= deadline) {
1072
+ shouldYield = true;
1073
+ break;
1074
+ }
979
1075
  } else {
980
1076
  break;
981
1077
  }
982
1078
  }
1079
+ if (shouldYield && queue.length && !isTriggerScheduled) {
1080
+ isTriggerScheduled = true;
1081
+ nextTriggerMacroTask();
1082
+ }
983
1083
  if (config.$DEBUG$ && !queue.length) {
984
1084
  const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
985
1085
  const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
@@ -988,13 +1088,112 @@ var trigger = () => {
988
1088
  `>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
989
1089
  );
990
1090
  }
1091
+ }
1092
+ var enqueueAdjustment = (bundle, inverseProbability, context, seen) => {
1093
+ adjustmentStack.unshift({
1094
+ $bundle$: bundle,
1095
+ $inverseProbability$: inverseProbability,
1096
+ $seen$: seen,
1097
+ $context$: context
1098
+ });
991
1099
  };
1100
+ var processAdjustmentFrame = () => {
1101
+ const frame = adjustmentStack[adjustmentStack.length - 1];
1102
+ const bundle = frame.$bundle$;
1103
+ if (frame.$deps$) {
1104
+ const index = frame.$index$;
1105
+ if (index >= frame.$deps$.length) {
1106
+ adjustmentStack.pop();
1107
+ return false;
1108
+ }
1109
+ const dep = frame.$deps$[index];
1110
+ frame.$index$ = index + 1;
1111
+ const depBundle = getBundle(dep.$name$);
1112
+ if (depBundle.$inverseProbability$ === 0) {
1113
+ return true;
1114
+ }
1115
+ const probability = 1 - bundle.$inverseProbability$;
1116
+ let newInverseProbability;
1117
+ if (probability === 1 || probability >= 0.99 && frame.$context$.$depsCount$ < 100) {
1118
+ frame.$context$.$depsCount$++;
1119
+ newInverseProbability = Math.min(0.01, 1 - dep.$importProbability$);
1120
+ } else {
1121
+ const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
1122
+ const prevAdjust = dep.$factor$;
1123
+ const factor = newInverseImportProbability / prevAdjust;
1124
+ newInverseProbability = Math.max(0.02, depBundle.$inverseProbability$ * factor);
1125
+ dep.$factor$ = factor;
1126
+ }
1127
+ adjustmentStack.push({
1128
+ $bundle$: depBundle,
1129
+ $inverseProbability$: newInverseProbability,
1130
+ $seen$: frame.$seen$,
1131
+ $context$: frame.$context$
1132
+ });
1133
+ return true;
1134
+ }
1135
+ if (frame.$seen$?.has(bundle)) {
1136
+ adjustmentStack.pop();
1137
+ return false;
1138
+ }
1139
+ const previousInverseProbability = bundle.$inverseProbability$;
1140
+ bundle.$inverseProbability$ = frame.$inverseProbability$;
1141
+ if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
1142
+ adjustmentStack.pop();
1143
+ return false;
1144
+ }
1145
+ if (
1146
+ // don't queue until we have initialized the preloader
1147
+ base != null && bundle.$state$ < BundleImportState_Preload
1148
+ ) {
1149
+ if (bundle.$state$ === BundleImportState_None) {
1150
+ bundle.$state$ = BundleImportState_Queued;
1151
+ queue.push(bundle);
1152
+ config.$DEBUG$ && log(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
1153
+ }
1154
+ queueDirty = true;
1155
+ }
1156
+ if (bundle.$deps$?.length) {
1157
+ const seen = frame.$seen$ || /* @__PURE__ */ new Set();
1158
+ seen.add(bundle);
1159
+ frame.$seen$ = seen;
1160
+ frame.$deps$ = bundle.$deps$;
1161
+ frame.$index$ = 0;
1162
+ return false;
1163
+ }
1164
+ adjustmentStack.pop();
1165
+ return false;
1166
+ };
1167
+ function processPendingAdjustments() {
1168
+ if (isProcessingAdjustments || !adjustmentStack.length) {
1169
+ return;
1170
+ }
1171
+ isAdjustmentScheduled = false;
1172
+ isProcessingAdjustments = true;
1173
+ const deadline = shouldYieldInBrowser ? performance.now() + yieldInterval : 0;
1174
+ let processed = false;
1175
+ while (adjustmentStack.length) {
1176
+ processed = true;
1177
+ const checkDeadline = processAdjustmentFrame();
1178
+ if (shouldYieldInBrowser && checkDeadline && performance.now() >= deadline) {
1179
+ if (!isAdjustmentScheduled) {
1180
+ isAdjustmentScheduled = true;
1181
+ nextAdjustmentMacroTask();
1182
+ }
1183
+ break;
1184
+ }
1185
+ }
1186
+ isProcessingAdjustments = false;
1187
+ if (processed && shouldYieldInBrowser) {
1188
+ nextTriggerMacroTask();
1189
+ }
1190
+ }
992
1191
  var preloadOne = (bundle) => {
993
1192
  if (bundle.$state$ >= BundleImportState_Preload) {
994
1193
  return;
995
1194
  }
996
1195
  preloadCount++;
997
- const start = Date.now();
1196
+ const start = performance.now();
998
1197
  bundle.$waitedMs$ = start - bundle.$createdTs$;
999
1198
  bundle.$state$ = BundleImportState_Preload;
1000
1199
  config.$DEBUG$ && log(
@@ -1007,89 +1206,58 @@ var preloadOne = (bundle) => {
1007
1206
  link.as = "script";
1008
1207
  link.onload = link.onerror = () => {
1009
1208
  preloadCount--;
1010
- const end = Date.now();
1209
+ const end = performance.now();
1011
1210
  bundle.$loadedMs$ = end - start;
1012
1211
  bundle.$state$ = BundleImportState_Loaded;
1013
1212
  config.$DEBUG$ && log(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
1014
1213
  link.remove();
1015
- trigger();
1214
+ nextTriggerMacroTask();
1016
1215
  };
1017
1216
  doc.head.appendChild(link);
1018
1217
  };
1019
1218
  var adjustProbabilities = (bundle, newInverseProbability, seen) => {
1020
- if (seen?.has(bundle)) {
1021
- return;
1022
- }
1023
- const previousInverseProbability = bundle.$inverseProbability$;
1024
- bundle.$inverseProbability$ = newInverseProbability;
1025
- if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
1026
- return;
1027
- }
1028
- if (
1029
- // don't queue until we have initialized the preloader
1030
- base != null && bundle.$state$ < BundleImportState_Preload
1031
- ) {
1032
- if (bundle.$state$ === BundleImportState_None) {
1033
- bundle.$state$ = BundleImportState_Queued;
1034
- queue.push(bundle);
1035
- config.$DEBUG$ && log(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
1036
- }
1037
- queueDirty = true;
1038
- }
1039
- if (bundle.$deps$) {
1040
- seen ||= /* @__PURE__ */ new Set();
1041
- seen.add(bundle);
1042
- const probability = 1 - bundle.$inverseProbability$;
1043
- for (const dep of bundle.$deps$) {
1044
- const depBundle = getBundle(dep.$name$);
1045
- if (depBundle.$inverseProbability$ === 0) {
1046
- continue;
1047
- }
1048
- let newInverseProbability2;
1049
- if (probability === 1 || probability >= 0.99 && depsCount < 100) {
1050
- depsCount++;
1051
- newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
1052
- } else {
1053
- const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
1054
- const prevAdjust = dep.$factor$;
1055
- const factor = newInverseImportProbability / prevAdjust;
1056
- newInverseProbability2 = Math.max(0.02, depBundle.$inverseProbability$ * factor);
1057
- dep.$factor$ = factor;
1058
- }
1059
- adjustProbabilities(depBundle, newInverseProbability2, seen);
1060
- }
1219
+ enqueueAdjustment(bundle, newInverseProbability, { $depsCount$: 0 }, seen);
1220
+ if (shouldYieldInBrowser) {
1221
+ nextAdjustmentMacroTask();
1222
+ } else {
1223
+ processPendingAdjustments();
1061
1224
  }
1062
1225
  };
1063
- var handleBundle = (name, inverseProbability) => {
1226
+ var handleBundle = (name, inverseProbability, context) => {
1064
1227
  const bundle = getBundle(name);
1065
1228
  if (bundle && bundle.$inverseProbability$ > inverseProbability) {
1066
- adjustProbabilities(bundle, inverseProbability);
1229
+ if (context) {
1230
+ enqueueAdjustment(bundle, inverseProbability, context);
1231
+ } else {
1232
+ adjustProbabilities(bundle, inverseProbability);
1233
+ }
1067
1234
  }
1068
1235
  };
1069
- var depsCount;
1070
1236
  var preload = (name, probability) => {
1071
1237
  if (!name?.length) {
1072
1238
  return;
1073
1239
  }
1074
- depsCount = 0;
1075
1240
  let inverseProbability = probability ? 1 - probability : 0.4;
1241
+ const context = { $depsCount$: 0 };
1076
1242
  if (Array.isArray(name)) {
1077
1243
  for (let i = name.length - 1; i >= 0; i--) {
1078
1244
  const item = name[i];
1079
1245
  if (typeof item === "number") {
1080
1246
  inverseProbability = 1 - item / 10;
1081
1247
  } else {
1082
- handleBundle(item, inverseProbability);
1248
+ handleBundle(item, inverseProbability, context);
1083
1249
  }
1084
1250
  }
1085
1251
  } else {
1086
- handleBundle(name, inverseProbability);
1252
+ handleBundle(name, inverseProbability, context);
1087
1253
  }
1088
- if (isBrowser3) {
1089
- trigger();
1254
+ if (shouldYieldInBrowser) {
1255
+ nextAdjustmentMacroTask();
1256
+ } else {
1257
+ processPendingAdjustments();
1090
1258
  }
1091
1259
  };
1092
- if (isBrowser3) {
1260
+ if (import.meta.env.TEST ? !isServerPlatform() : isBrowser3) {
1093
1261
  document.addEventListener("qsymbol", (ev) => {
1094
1262
  const { symbol, href } = ev.detail;
1095
1263
  if (href) {
@@ -1141,11 +1309,11 @@ var getDevSegmentPath = (mapper, hash, symbolName, parent) => {
1141
1309
  const qrlFile = `${import.meta.env.BASE_URL}${parent.startsWith("/") ? parent.slice(1) : parent}_${symbolName}.js`;
1142
1310
  return [symbolName, qrlFile];
1143
1311
  };
1144
- function createPlatform(opts, resolvedManifest) {
1312
+ function createPlatform2(opts, resolvedManifest) {
1145
1313
  const mapper = resolvedManifest?.mapper;
1146
1314
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
1147
1315
  if (mapper || isDev5 && import.meta.env.MODE !== "test") {
1148
- const hash = getSymbolHash(symbolName);
1316
+ const hash = getSymbolHash2(symbolName);
1149
1317
  const result = !isDev5 ? mapper[hash] : getDevSegmentPath(mapper, hash, symbolName, parent);
1150
1318
  if (!result) {
1151
1319
  if (hash === SYNC_QRL) {
@@ -1163,7 +1331,7 @@ function createPlatform(opts, resolvedManifest) {
1163
1331
  const serverPlatform = {
1164
1332
  isServer: true,
1165
1333
  async importSymbol(_containerEl, url, symbolName) {
1166
- const hash = getSymbolHash(symbolName);
1334
+ const hash = getSymbolHash2(symbolName);
1167
1335
  const regSym = globalThis.__qwik_reg_symbols?.get(hash);
1168
1336
  if (regSym) {
1169
1337
  return regSym;
@@ -1181,10 +1349,10 @@ function createPlatform(opts, resolvedManifest) {
1181
1349
  return serverPlatform;
1182
1350
  }
1183
1351
  async function setServerPlatform(opts, manifest) {
1184
- const platform = createPlatform(opts, manifest);
1352
+ const platform = createPlatform2(opts, manifest);
1185
1353
  setPlatform(platform);
1186
1354
  }
1187
- var getSymbolHash = (symbolName) => {
1355
+ var getSymbolHash2 = (symbolName) => {
1188
1356
  const index = symbolName.lastIndexOf("_");
1189
1357
  if (index > -1) {
1190
1358
  return symbolName.slice(index + 1);
@@ -1218,7 +1386,7 @@ function getBuildBase(opts) {
1218
1386
  return `${import.meta.env.BASE_URL || "/"}build/`;
1219
1387
  }
1220
1388
  var versions = {
1221
- qwik: "2.0.0-beta.30-dev+5421ed4",
1389
+ qwik: "2.0.0-beta.31-dev+906321a",
1222
1390
  qwikDom: "2.1.19"
1223
1391
  };
1224
1392
 
@@ -1244,7 +1412,8 @@ function flattenPrefetchResources(prefetchResources) {
1244
1412
  const urls = [];
1245
1413
  const addPrefetchResource = (prefetchResources2) => {
1246
1414
  if (prefetchResources2) {
1247
- for (const prefetchResource of prefetchResources2) {
1415
+ for (let i = 0; i < prefetchResources2.length; i++) {
1416
+ const prefetchResource = prefetchResources2[i];
1248
1417
  if (!urls.includes(prefetchResource.url)) {
1249
1418
  urls.push(prefetchResource.url);
1250
1419
  if (prefetchResource.imports) {
@@ -1291,8 +1460,8 @@ function getPreloadPaths(qrls, opts, resolvedManifest) {
1291
1460
  }
1292
1461
  }
1293
1462
  const symbols = /* @__PURE__ */ new Set();
1294
- for (const qrl of qrls) {
1295
- const symbol = getSymbolHash(qrl.$symbol$);
1463
+ for (let i = 0; i < qrls.length; i++) {
1464
+ const symbol = getSymbolHash2(qrls[i].$symbol$);
1296
1465
  if (symbol && symbol.length >= 10) {
1297
1466
  symbols.add(symbol);
1298
1467
  }
@@ -1305,8 +1474,8 @@ var expandBundles = (names, resolvedManifest) => {
1305
1474
  }
1306
1475
  resetQueue();
1307
1476
  let probability = 0.99;
1308
- for (const name of names) {
1309
- preload(name, probability);
1477
+ for (let i = 0; i < names.length; i++) {
1478
+ preload(names[i], probability);
1310
1479
  probability *= 0.95;
1311
1480
  }
1312
1481
  return getQueue();
@@ -1319,7 +1488,8 @@ var simplifyPath = (base2, path) => {
1319
1488
  }
1320
1489
  const segments = `${base2}${path}`.split("/");
1321
1490
  const simplified = [];
1322
- for (const segment of segments) {
1491
+ for (let i = 0; i < segments.length; i++) {
1492
+ const segment = segments[i];
1323
1493
  if (segment === ".." && simplified.length > 0) {
1324
1494
  simplified.pop();
1325
1495
  } else {
@@ -1421,7 +1591,8 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
1421
1591
  const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
1422
1592
  let probability = 4;
1423
1593
  const tenXMinProbability = ssrPreloadProbability * 10;
1424
- for (const hrefOrProbability of expandedBundles) {
1594
+ for (let i = 0; i < expandedBundles.length; i++) {
1595
+ const hrefOrProbability = expandedBundles[i];
1425
1596
  if (typeof hrefOrProbability === "string") {
1426
1597
  if (probability < tenXMinProbability) {
1427
1598
  break;
@@ -1484,8 +1655,8 @@ var preLoaderOptionsDefault = {
1484
1655
  };
1485
1656
 
1486
1657
  // packages/qwik/src/server/scripts.ts
1487
- var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,o="w",n="d",r=new Set,s=new Set([e]),i=new Map;let a,c;const l=(e,t)=>Array.from(e.querySelectorAll(t)),q=e=>{const t=[];return s.forEach(o=>t.push(...l(o,e))),t},d=(e,t,o,n=!1)=>e.addEventListener(t,o,{capture:n,passive:!1}),b=e=>{_(e),l(e,"[q\\\\:shadowroot]").forEach(e=>{const t=e.shadowRoot;t&&b(t)})},f=e=>e&&"function"==typeof e.then,p=t=>{if(void 0===t._qwikjson_){let o=(t===e.documentElement?e.body:t).lastElementChild;for(;o;){if("SCRIPT"===o.tagName&&"qwik/json"===o.getAttribute("type")){t._qwikjson_=JSON.parse(o.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}o=o.previousElementSibling}}},u=(e,t)=>new CustomEvent(e,{detail:t}),h=(t,o)=>{e.dispatchEvent(u(t,o))},m=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),v=e=>e.replace(/-./g,e=>e[1].toUpperCase()),w=e=>({scope:e.charAt(0),eventName:v(e.slice(2))}),y=async(t,o,n,r)=>{r&&(t.hasAttribute("preventdefault:"+r)&&o.preventDefault(),t.hasAttribute("stoppropagation:"+r)&&o.stopPropagation());const s=t._qDispatch?.[n];if(s){if("function"==typeof s){const e=s(o,t);f(e)&&await e}else if(s.length)for(let e=0;e<s.length;e++){const n=s[e],r=n?.(o,t);f(r)&&await r}return}const a=t.getAttribute("q-"+n);if(a){const n=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),r=n.getAttribute("q:base"),s=new URL(r,e.baseURI);for(const c of a.split("|")){const a=performance.now(),[l,q,d]=c.split("#"),b={qBase:r,symbol:q,element:t,reqTime:a};let u,m,v;if(""===l){const t=n.getAttribute("q:instance");u=(e["qFuncs_"+t]||[])[Number.parseInt(q)],u||(m="sync",v=Error("sym:"+q))}else{const e=`${q}|${r}|${l}`;if(u=i.get(e),!u){const t=new URL(l,s).href;try{const o=import(t);p(n),u=(await o)[q],u?(i.set(e,u),h("qsymbol",b)):(m="no-symbol",v=Error(`${q} not in ${t}`))}catch(e){m="async",v=e}}}if(u){if(t.isConnected)try{const e=u.call(d,o,t);f(e)&&await e}catch(e){h("qerror",{error:e,...b})}}else h("qerror",{importError:m,error:v,...b}),console.error(v)}}},g=async e=>{const t=m(e.type),o="e:"+t;let n=e.target;for(;n&&n.getAttribute;){const r=y(n,e,o,t),s=e.bubbles&&!e.cancelBubble;f(r)&&await r,n=s&&e.bubbles&&!e.cancelBubble?n.parentElement:null}},E=(e,t)=>{const o=m(t.type),n=e+":"+o;q("[q-"+e+"\\\\:"+o+"]").forEach(e=>y(e,t,n,o))},A=async e=>{E(n,e)},C=e=>{E(o,e)},k=()=>{const o=e.readyState;if("interactive"==o||"complete"==o){if(c=1,s.forEach(b),r.has("d:qinit")){r.delete("d:qinit");const e=u("qinit");q("[q-d\\\\:qinit]").forEach(t=>{y(t,e,"d:qinit"),t.removeAttribute("q-d:qinit")})}r.has("d:qidle")&&(r.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=u("qidle");q("[q-d\\\\:qidle]").forEach(t=>{y(t,e,"d:qidle"),t.removeAttribute("q-d:qidle")})})),r.has("e:qvisible")&&(a||(a=new IntersectionObserver(e=>{for(const t of e)t.isIntersecting&&(a.unobserve(t.target),y(t.target,u("qvisible",t),"e:qvisible"))})),q("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach(e=>{a.observe(e),e.setAttribute("q:observed","true")}))}},_=(...e)=>{for(let i=0;i<e.length;i++){const a=e[i];if("string"==typeof a){if(!r.has(a)){r.add(a);const{scope:e,eventName:i}=w(a);e===o?d(t,i,C,!0):s.forEach(t=>d(t,i,e===n?A:g,!0)),1!==c||"e:qvisible"!==a&&"d:qinit"!==a&&"d:qidle"!==a||k()}}else s.has(a)||(r.forEach(e=>{const{scope:t,eventName:r}=w(e);t!==o&&d(a,r,t===n?A:g,!0)}),s.add(a))}},S=t._qwikEv;S?.roots||(Array.isArray(S)?_(...S):_("e:click","e:input"),t._qwikEv={events:r,roots:s,push:_},d(e,"readystatechange",k),k())';
1488
- var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst documentPrefix = "d";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst addEventListener = (el, eventName, handler, capture = false) => el.addEventListener(eventName, handler, { capture, passive: false });\nconst findShadowRoots = (fragment) => {\n addEventOrRoot(fragment);\n nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent) => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n });\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst parseKebabEvent = (event) => ({\n scope: event.charAt(0),\n eventName: kebabToCamel(event.slice(2))\n});\nconst dispatch = async (element, ev, scopedKebabName, kebabName) => {\n if (kebabName) {\n if (element.hasAttribute("preventdefault:" + kebabName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + kebabName)) {\n ev.stopPropagation();\n }\n }\n const handlers = element._qDispatch?.[scopedKebabName];\n if (handlers) {\n if (typeof handlers === "function") {\n const result = handlers(ev, element);\n if (isPromise(result)) {\n await result;\n }\n } else if (handlers.length) {\n for (let i = 0; i < handlers.length; i++) {\n const handler = handlers[i];\n const result = handler?.(ev, element);\n if (isPromise(result)) {\n await result;\n }\n }\n }\n return;\n }\n const attrValue = element.getAttribute("q-" + scopedKebabName);\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("|")) {\n const reqTime = performance.now();\n const [chunk, symbol, capturedIds] = qrl.split("#");\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n let handler;\n let importError;\n let error;\n if (chunk === "") {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n const key = `${symbol}|${qBase}|${chunk}`;\n handler = symbols.get(key);\n if (!handler) {\n const href = new URL(chunk, base).href;\n try {\n const module = import(\n href\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${href}`);\n } else {\n symbols.set(key, handler);\n emitEvent("qsymbol", eventData);\n }\n } catch (err) {\n importError = "async";\n error = err;\n }\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n continue;\n }\n if (element.isConnected) {\n try {\n const result = handler.call(capturedIds, ev, element);\n if (isPromise(result)) {\n await result;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n }\n }\n }\n }\n};\nconst processElementEvent = async (ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = "e:" + kebabName;\n let element = ev.target;\n while (element && element.getAttribute) {\n const results = dispatch(element, ev, scopedKebabName, kebabName);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n element = doBubble && ev.bubbles && !ev.cancelBubble ? element.parentElement : null;\n }\n};\nconst broadcast = (infix, ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = infix + ":" + kebabName;\n querySelectorAll("[q-" + infix + "\\\\:" + kebabName + "]").forEach(\n (el) => dispatch(el, ev, scopedKebabName, kebabName)\n );\n};\nconst processDocumentEvent = async (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (readyState == "interactive" || readyState == "complete") {\n hasInitialized = 1;\n roots.forEach(findShadowRoots);\n if (events.has("d:qinit")) {\n events.delete("d:qinit");\n const ev = createEvent("qinit");\n querySelectorAll("[q-d\\\\:qinit]").forEach((el) => {\n dispatch(el, ev, "d:qinit");\n el.removeAttribute("q-d:qinit");\n });\n }\n if (events.has("d:qidle")) {\n events.delete("d:qidle");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => {\n const ev = createEvent("qidle");\n querySelectorAll("[q-d\\\\:qidle]").forEach((el) => {\n dispatch(el, ev, "d:qidle");\n el.removeAttribute("q-d:qidle");\n });\n });\n }\n if (events.has("e:qvisible")) {\n observer || (observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, createEvent("qvisible", entry), "e:qvisible");\n }\n }\n }));\n querySelectorAll("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach((el) => {\n observer.observe(el);\n el.setAttribute("q:observed", "true");\n });\n }\n }\n};\nconst addEventOrRoot = (...eventNames) => {\n for (let i = 0; i < eventNames.length; i++) {\n const eventNameOrRoot = eventNames[i];\n if (typeof eventNameOrRoot === "string") {\n if (!events.has(eventNameOrRoot)) {\n events.add(eventNameOrRoot);\n const { scope, eventName } = parseKebabEvent(eventNameOrRoot);\n if (scope === windowPrefix) {\n addEventListener(win, eventName, processWindowEvent, true);\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n )\n );\n }\n if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) {\n processReadyStateChange();\n }\n }\n } else {\n if (!roots.has(eventNameOrRoot)) {\n events.forEach((kebabEventName) => {\n const { scope, eventName } = parseKebabEvent(kebabEventName);\n if (scope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n );\n }\n });\n roots.add(eventNameOrRoot);\n }\n }\n }\n};\nconst _qwikEv = win._qwikEv;\nif (!_qwikEv?.roots) {\n if (Array.isArray(_qwikEv)) {\n addEventOrRoot(..._qwikEv);\n } else {\n addEventOrRoot("e:click", "e:input");\n }\n win._qwikEv = {\n events,\n roots,\n push: addEventOrRoot\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
1658
+ var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,n="w",o="d",r=new Set,s=new Set([e]),i=new Map;let a,c;const l=(e,t)=>Array.from(e.querySelectorAll(t)),q=e=>{const t=[];return s.forEach(n=>t.push(...l(n,e))),t},d=(e,t,n,o=!1)=>e.addEventListener(t,n,{capture:o,passive:!1}),b=e=>{_(e);const t=l(e,"[q\\\\:shadowroot]");for(let e=0;e<t.length;e++){const n=t[e].shadowRoot;n&&b(n)}},f=e=>e&&"function"==typeof e.then,p=t=>{if(void 0===t._qwikjson_){let n=(t===e.documentElement?e.body:t).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){t._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},u=(e,t)=>new CustomEvent(e,{detail:t}),h=(t,n)=>{e.dispatchEvent(u(t,n))},g=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),m=e=>e.replace(/-./g,e=>e[1].toUpperCase()),v=e=>({scope:e.charAt(0),eventName:m(e.slice(2))}),w=async(t,n,o,r)=>{r&&(t.hasAttribute("preventdefault:"+r)&&n.preventDefault(),t.hasAttribute("stoppropagation:"+r)&&n.stopPropagation());const s=t._qDispatch?.[o];if(s){if("function"==typeof s){const e=s(n,t);f(e)&&await e}else if(s.length)for(let e=0;e<s.length;e++){const o=s[e],r=o?.(n,t);f(r)&&await r}return}const a=t.getAttribute("q-"+o);if(a){const o=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),r=o.getAttribute("q:base"),s=new URL(r,e.baseURI),c=a.split("|");for(let a=0;a<c.length;a++){const l=c[a],q=performance.now(),[d,b,u]=l.split("#"),g={qBase:r,symbol:b,element:t,reqTime:q};let m,v,w;if(""===d){const t=o.getAttribute("q:instance");m=(e["qFuncs_"+t]||[])[Number.parseInt(b)],m||(v="sync",w=Error("sym:"+b))}else{const e=`${b}|${r}|${d}`;if(m=i.get(e),!m){const t=new URL(d,s).href;try{const n=import(t);p(o),m=(await n)[b],m?(i.set(e,m),h("qsymbol",g)):(v="no-symbol",w=Error(`${b} not in ${t}`))}catch(e){v="async",w=e}}}if(m){if(t.isConnected)try{const e=m.call(u,n,t);f(e)&&await e}catch(e){h("qerror",{error:e,...g})}}else h("qerror",{importError:v,error:w,...g}),console.error(w)}}},y=async e=>{const t=g(e.type),n="e:"+t;let o=e.target;for(;o&&o.getAttribute;){const r=w(o,e,n,t),s=e.bubbles&&!e.cancelBubble;f(r)&&await r,o=s&&e.bubbles&&!e.cancelBubble?o.parentElement:null}},A=(e,t)=>{const n=g(t.type),o=e+":"+n,r=q("[q-"+e+"\\\\:"+n+"]");for(let e=0;e<r.length;e++){const s=r[e];w(s,t,o,n)}},E=async e=>{A(o,e)},C=e=>{A(n,e)},k=()=>{const n=e.readyState;if("interactive"==n||"complete"==n){if(c=1,s.forEach(b),r.has("d:qinit")){r.delete("d:qinit");const e=u("qinit"),t=q("[q-d\\\\:qinit]");for(let n=0;n<t.length;n++){const o=t[n];w(o,e,"d:qinit"),o.removeAttribute("q-d:qinit")}}if(r.has("d:qidle")&&(r.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=u("qidle"),t=q("[q-d\\\\:qidle]");for(let n=0;n<t.length;n++){const o=t[n];w(o,e,"d:qidle"),o.removeAttribute("q-d:qidle")}})),r.has("e:qvisible")){a||(a=new IntersectionObserver(e=>{for(let t=0;t<e.length;t++){const n=e[t];n.isIntersecting&&(a.unobserve(n.target),w(n.target,u("qvisible",n),"e:qvisible"))}}));const e=q("[q-e\\\\:qvisible]:not([q\\\\:observed])");for(let t=0;t<e.length;t++){const n=e[t];a.observe(n),n.setAttribute("q:observed","true")}}}},_=(...e)=>{for(let i=0;i<e.length;i++){const a=e[i];if("string"==typeof a){if(!r.has(a)){r.add(a);const{scope:e,eventName:i}=v(a);e===n?d(t,i,C,!0):s.forEach(t=>d(t,i,e===o?E:y,!0)),1!==c||"e:qvisible"!==a&&"d:qinit"!==a&&"d:qidle"!==a||k()}}else s.has(a)||(r.forEach(e=>{const{scope:t,eventName:r}=v(e);t!==n&&d(a,r,t===o?E:y,!0)}),s.add(a))}},S=t._qwikEv;S?.roots||(Array.isArray(S)?_(...S):_("e:click","e:input"),t._qwikEv={events:r,roots:s,push:_},d(e,"readystatechange",k),k())';
1659
+ var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst documentPrefix = "d";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst addEventListener = (el, eventName, handler, capture = false) => el.addEventListener(eventName, handler, { capture, passive: false });\nconst findShadowRoots = (fragment) => {\n addEventOrRoot(fragment);\n const shadowRoots = nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]");\n for (let i = 0; i < shadowRoots.length; i++) {\n const parent = shadowRoots[i];\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst parseKebabEvent = (event) => ({\n scope: event.charAt(0),\n eventName: kebabToCamel(event.slice(2))\n});\nconst dispatch = async (element, ev, scopedKebabName, kebabName) => {\n if (kebabName) {\n if (element.hasAttribute("preventdefault:" + kebabName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + kebabName)) {\n ev.stopPropagation();\n }\n }\n const handlers = element._qDispatch?.[scopedKebabName];\n if (handlers) {\n if (typeof handlers === "function") {\n const result = handlers(ev, element);\n if (isPromise(result)) {\n await result;\n }\n } else if (handlers.length) {\n for (let i = 0; i < handlers.length; i++) {\n const handler = handlers[i];\n const result = handler?.(ev, element);\n if (isPromise(result)) {\n await result;\n }\n }\n }\n return;\n }\n const attrValue = element.getAttribute("q-" + scopedKebabName);\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const base = new URL(qBase, doc.baseURI);\n const qrls = attrValue.split("|");\n for (let i = 0; i < qrls.length; i++) {\n const qrl = qrls[i];\n const reqTime = performance.now();\n const [chunk, symbol, capturedIds] = qrl.split("#");\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n let handler;\n let importError;\n let error;\n if (chunk === "") {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n const key = `${symbol}|${qBase}|${chunk}`;\n handler = symbols.get(key);\n if (!handler) {\n const href = new URL(chunk, base).href;\n try {\n const module = import(\n href\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${href}`);\n } else {\n symbols.set(key, handler);\n emitEvent("qsymbol", eventData);\n }\n } catch (err) {\n importError = "async";\n error = err;\n }\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n continue;\n }\n if (element.isConnected) {\n try {\n const result = handler.call(capturedIds, ev, element);\n if (isPromise(result)) {\n await result;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n }\n }\n }\n }\n};\nconst processElementEvent = async (ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = "e:" + kebabName;\n let element = ev.target;\n while (element && element.getAttribute) {\n const results = dispatch(element, ev, scopedKebabName, kebabName);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n element = doBubble && ev.bubbles && !ev.cancelBubble ? element.parentElement : null;\n }\n};\nconst broadcast = (infix, ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = infix + ":" + kebabName;\n const elements = querySelectorAll("[q-" + infix + "\\\\:" + kebabName + "]");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, scopedKebabName, kebabName);\n }\n};\nconst processDocumentEvent = async (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (readyState == "interactive" || readyState == "complete") {\n hasInitialized = 1;\n roots.forEach(findShadowRoots);\n if (events.has("d:qinit")) {\n events.delete("d:qinit");\n const ev = createEvent("qinit");\n const elements = querySelectorAll("[q-d\\\\:qinit]");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qinit");\n el.removeAttribute("q-d:qinit");\n }\n }\n if (events.has("d:qidle")) {\n events.delete("d:qidle");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => {\n const ev = createEvent("qidle");\n const elements = querySelectorAll("[q-d\\\\:qidle]");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qidle");\n el.removeAttribute("q-d:qidle");\n }\n });\n }\n if (events.has("e:qvisible")) {\n observer || (observer = new IntersectionObserver((entries) => {\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, createEvent("qvisible", entry), "e:qvisible");\n }\n }\n }));\n const elements = querySelectorAll("[q-e\\\\:qvisible]:not([q\\\\:observed])");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n observer.observe(el);\n el.setAttribute("q:observed", "true");\n }\n }\n }\n};\nconst addEventOrRoot = (...eventNames) => {\n for (let i = 0; i < eventNames.length; i++) {\n const eventNameOrRoot = eventNames[i];\n if (typeof eventNameOrRoot === "string") {\n if (!events.has(eventNameOrRoot)) {\n events.add(eventNameOrRoot);\n const { scope, eventName } = parseKebabEvent(eventNameOrRoot);\n if (scope === windowPrefix) {\n addEventListener(win, eventName, processWindowEvent, true);\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n )\n );\n }\n if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) {\n processReadyStateChange();\n }\n }\n } else {\n if (!roots.has(eventNameOrRoot)) {\n events.forEach((kebabEventName) => {\n const { scope, eventName } = parseKebabEvent(kebabEventName);\n if (scope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n );\n }\n });\n roots.add(eventNameOrRoot);\n }\n }\n }\n};\nconst _qwikEv = win._qwikEv;\nif (!_qwikEv?.roots) {\n if (Array.isArray(_qwikEv)) {\n addEventOrRoot(..._qwikEv);\n } else {\n addEventOrRoot("e:click", "e:input");\n }\n win._qwikEv = {\n events,\n roots,\n push: addEventOrRoot\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
1489
1660
  var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]',e=document.currentScript;if(e){const o=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");if(o){const e=o.querySelector(t);if(e){const t=JSON.parse(e.textContent||"[]"),n=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT);let r=n.currentNode,c=r.hasAttribute(":")?0:-1;for(let e=0;e<t.length;e+=3){const o=t[e],i=t[e+1];let s=t[e+2];for(;c<o&&(r=n.nextNode(),r);)r.hasAttribute(":")&&c++;const l=r;null==s||!1===s?l.removeAttribute(i):("boolean"==typeof s&&(s=""),l.setAttribute(i,s))}}}}`;
1490
1661
  var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
1491
1662
  const executorScript = document.currentScript;
@@ -1626,7 +1797,8 @@ var SsrNode = class {
1626
1797
  if (this.flags & 1 /* Updatable */) {
1627
1798
  this.flags &= ~1 /* Updatable */;
1628
1799
  if (this.children) {
1629
- for (const child of this.children) {
1800
+ for (let i = 0; i < this.children.length; i++) {
1801
+ const child = this.children[i];
1630
1802
  child.setTreeNonUpdatable();
1631
1803
  }
1632
1804
  }
@@ -2335,6 +2507,9 @@ var SSRContainer = class extends _SharedContainer {
2335
2507
  /** Renders opening tag for DOM element */
2336
2508
  openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null, hasMovedCaptures = true) {
2337
2509
  const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
2510
+ if (elementName === "noscript" || elementName === "template" || elementName === "script") {
2511
+ this.$noScriptHere$++;
2512
+ }
2338
2513
  if (
2339
2514
  // don't append qwik loader before qwik style elements
2340
2515
  // it will confuse the resuming, because styles are expected to be the first nodes in subtree
@@ -2342,8 +2517,6 @@ var SSRContainer = class extends _SharedContainer {
2342
2517
  ) {
2343
2518
  if (this.$noScriptHere$ === 0 && this.size > 30 * 1024 && elementName !== "body") {
2344
2519
  this.emitQwikLoaderInline();
2345
- } else if (elementName === "noscript" || elementName === "template") {
2346
- this.$noScriptHere$++;
2347
2520
  }
2348
2521
  }
2349
2522
  let innerHTML = void 0;
@@ -2432,10 +2605,8 @@ var SSRContainer = class extends _SharedContainer {
2432
2605
  this.write(GT);
2433
2606
  }
2434
2607
  this.lastNode = null;
2435
- if (this.qlInclude === 1 /* Inline */) {
2436
- if (elementName === "noscript" || elementName === "template") {
2437
- this.$noScriptHere$--;
2438
- }
2608
+ if (elementName === "noscript" || elementName === "template" || elementName === "script") {
2609
+ this.$noScriptHere$--;
2439
2610
  }
2440
2611
  }
2441
2612
  /** Writes opening data to vNodeData for fragment boundaries */
@@ -2798,7 +2969,8 @@ var SSRContainer = class extends _SharedContainer {
2798
2969
  emitPatchDataIfNeeded() {
2799
2970
  const patches = [];
2800
2971
  for (const [elementIndex, backpatchEntries] of this.backpatchMap) {
2801
- for (const backpatchEntry of backpatchEntries) {
2972
+ for (let i = 0; i < backpatchEntries.length; i++) {
2973
+ const backpatchEntry = backpatchEntries[i];
2802
2974
  patches.push(
2803
2975
  elementIndex,
2804
2976
  backpatchEntry.attrName,
@@ -2950,7 +3122,8 @@ var SSRContainer = class extends _SharedContainer {
2950
3122
  );
2951
3123
  let indent = " ";
2952
3124
  let lastName = "";
2953
- for (const frame3 of frames) {
3125
+ for (let i = 0; i < frames.length; i++) {
3126
+ const frame3 = frames[i];
2954
3127
  const [name, example] = allowedContent(frame3.tagNesting);
2955
3128
  text.push(
2956
3129
  `${indent}<${frame3.elementName}>${lastName !== name ? ` [${name}]${example ? ` -> ${example}` : ""}` : ""}`
@@ -2961,7 +3134,7 @@ var SSRContainer = class extends _SharedContainer {
2961
3134
  text.push(
2962
3135
  `${indent}<${elementName}> <= is not allowed as a child of ${allowedContent(previousTagNesting)[0]}.`
2963
3136
  );
2964
- throw newTagError(text.join("\n"));
3137
+ throw newTagError(text.map(escapeHTML).join("\n"));
2965
3138
  }
2966
3139
  }
2967
3140
  }
@@ -3289,9 +3462,10 @@ function resolveManifest(manifest) {
3289
3462
  }
3290
3463
  if (mergedManifest.mapping) {
3291
3464
  const mapper = {};
3292
- Object.entries(mergedManifest.mapping).forEach(([symbol, bundleFilename]) => {
3293
- mapper[getSymbolHash(symbol)] = [symbol, bundleFilename];
3294
- });
3465
+ for (const symbol in mergedManifest.mapping) {
3466
+ const bundleFilename = mergedManifest.mapping[symbol];
3467
+ mapper[getSymbolHash2(symbol)] = [symbol, bundleFilename];
3468
+ }
3295
3469
  return {
3296
3470
  mapper,
3297
3471
  manifest: mergedManifest,
@@ -3304,7 +3478,7 @@ var Q_FUNCS_PREFIX = 'document["qFuncs_HASH"]=';
3304
3478
 
3305
3479
  // packages/qwik/src/server/index.ts
3306
3480
  async function setServerPlatform2(manifest) {
3307
- const platform = createPlatform({ manifest }, resolveManifest(manifest));
3481
+ const platform = createPlatform2({ manifest }, resolveManifest(manifest));
3308
3482
  setPlatform2(platform);
3309
3483
  }
3310
3484
  export {