@qwik.dev/core 2.0.0-beta.34 → 2.0.0-beta.36

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.34-dev+8b055bb
3
+ * @qwik.dev/core/server 2.0.0-beta.36-dev+3268fab
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
@@ -11,7 +11,7 @@ import { setPlatform as setPlatform2 } from "@qwik.dev/core";
11
11
 
12
12
  // packages/qwik/src/server/platform.ts
13
13
  import { setPlatform } from "@qwik.dev/core";
14
- import { isDev as isDev5 } from "@qwik.dev/core/build";
14
+ import { isDev as isDev6 } from "@qwik.dev/core/build";
15
15
 
16
16
  // packages/qwik/src/core/client/util-mapArray.ts
17
17
  import { isDev as isDev2 } from "@qwik.dev/core/build";
@@ -20,12 +20,11 @@ import { isDev as isDev2 } from "@qwik.dev/core/build";
20
20
  import { isDev } from "@qwik.dev/core/build";
21
21
 
22
22
  // packages/qwik/src/core/shared/utils/qdev.ts
23
- var g = globalThis;
24
- var qDev = g.qDev !== false;
25
- var qInspector = g.qInspector === true;
26
- var qDynamicPlatform = g.qDynamicPlatform !== false;
27
- var qTest = g.qTest === true;
28
- var qRuntimeQrl = g.qRuntimeQrl === true;
23
+ var qDev = globalThis.qDev !== false;
24
+ var qInspector = globalThis.qInspector === true;
25
+ var qDynamicPlatform = globalThis.qDynamicPlatform !== false;
26
+ var qTest = globalThis.qTest === true;
27
+ var qRuntimeQrl = globalThis.qRuntimeQrl === true;
29
28
 
30
29
  // packages/qwik/src/core/shared/utils/log.ts
31
30
  var STYLE = qDev ? `background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;` : "";
@@ -112,6 +111,9 @@ var mapArray_has = (array, key, start) => {
112
111
  return mapApp_findIndx(array, key, start) >= 0;
113
112
  };
114
113
 
114
+ // packages/qwik/src/core/shared/error/error.ts
115
+ import { isDev as isDev3 } from "@qwik.dev/core/build";
116
+
115
117
  // packages/qwik/src/core/shared/utils/types.ts
116
118
  var isObject = (v) => {
117
119
  return typeof v === "object" && v !== null;
@@ -126,7 +128,7 @@ var isString = (v) => {
126
128
  // packages/qwik/src/core/shared/error/error.ts
127
129
  var baseUrl = "https://qwikdev-build-v2.qwik-8nx.pages.dev/docs/errors/#q";
128
130
  var codeToText = (code, ...parts) => {
129
- if (qDev) {
131
+ if (isDev3) {
130
132
  const MAP = [
131
133
  "Error while serializing class or style attributes",
132
134
  // 0
@@ -228,12 +230,8 @@ var qError = (code, errorMessageArgs = []) => {
228
230
  };
229
231
 
230
232
  // packages/qwik/src/core/shared/qrl/qrl-utils.ts
231
- import { isDev as isDev3 } from "@qwik.dev/core/build";
233
+ import { isDev as isDev4 } from "@qwik.dev/core/build";
232
234
  var SYNC_QRL = "<sync>";
233
- var getSymbolHash = (symbolName) => {
234
- const index = symbolName.lastIndexOf("_") + 1;
235
- return symbolName.slice(index);
236
- };
237
235
 
238
236
  // packages/qwik/src/core/shared/types.ts
239
237
  var DEBUG_TYPE = "q:type";
@@ -525,6 +523,11 @@ var VNodeDataChar = {
525
523
  "~"
526
524
  )
527
525
  };
526
+ var getSegmentVNodeRefId = (segmentId, localIndex) => {
527
+ const segmentIndex = parseInt(segmentId, 10) - 1;
528
+ const diagonal = segmentIndex + localIndex;
529
+ return -(diagonal * (diagonal + 1) / 2 + localIndex + 1);
530
+ };
528
531
 
529
532
  // packages/qwik/src/core/shared/utils/character-escaping.ts
530
533
  function escapeHTML(html) {
@@ -575,11 +578,44 @@ function encodeVNodeDataString(str) {
575
578
  return escapedHTML + str.substring(lastIdx);
576
579
  }
577
580
  }
581
+ function encodeVNodeDataKey(str) {
582
+ const encoded = encodeURI(str);
583
+ let encodedKey = "";
584
+ const length = encoded.length;
585
+ let idx = 0;
586
+ let lastIdx = idx;
587
+ for (; idx < length; idx++) {
588
+ const ch = encoded.charCodeAt(idx);
589
+ let replacement = null;
590
+ if (ch === 59) {
591
+ replacement = "%3B";
592
+ } else if (ch === 61) {
593
+ replacement = "%3D";
594
+ } else if (ch === 63) {
595
+ replacement = "%3F";
596
+ } else if (ch === 64) {
597
+ replacement = "%40";
598
+ } else if (ch === 126) {
599
+ replacement = "%7E";
600
+ } else {
601
+ continue;
602
+ }
603
+ encodedKey += encoded.substring(lastIdx, idx) + replacement;
604
+ lastIdx = idx + 1;
605
+ }
606
+ if (lastIdx === 0) {
607
+ return encoded;
608
+ } else {
609
+ return encodedKey + encoded.substring(lastIdx);
610
+ }
611
+ }
578
612
 
579
613
  // packages/qwik/src/core/shared/utils/markers.ts
580
614
  var OnRenderProp = "q:renderFn";
581
615
  var QSlot = "q:slot";
582
616
  var QSlotParent = "q:sparent";
617
+ var QStatePatchAttr = "q:patch";
618
+ var QSuspenseResolved = "q:r";
583
619
  var QStyle = "q:style";
584
620
  var QStyleSelector = "style[q\\:style]";
585
621
  var QStyleSSelector = "style[q\\:sstyle]";
@@ -615,11 +651,12 @@ var NON_SERIALIZABLE_MARKER_PREFIX = ":";
615
651
  var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
616
652
  var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
617
653
  var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
654
+ var NEAREST_CURSOR_BOUNDARY = NON_SERIALIZABLE_MARKER_PREFIX + "nearestCursorBoundary";
618
655
  var Q_PROPS_SEPARATOR = ":";
619
656
  var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
620
657
 
621
658
  // packages/qwik/src/core/shared/utils/promises.ts
622
- import { isDev as isDev4, isServer } from "@qwik.dev/core/build";
659
+ import { isDev as isDev5, isServer } from "@qwik.dev/core/build";
623
660
  var MAX_RETRY_ON_PROMISE_COUNT = 100;
624
661
  var isPromise = (value) => {
625
662
  return !!value && typeof value == "object" && typeof value.then === "function";
@@ -648,7 +685,7 @@ function retryOnPromise(fn, onError = justThrow) {
648
685
  if (ok) {
649
686
  return result;
650
687
  }
651
- isDev4 && checkError(result);
688
+ isDev5 && checkError(result);
652
689
  return onError(result);
653
690
  }
654
691
  let retryCount = MAX_RETRY_ON_PROMISE_COUNT;
@@ -671,7 +708,7 @@ function retryOnPromise(fn, onError = justThrow) {
671
708
  }
672
709
  }
673
710
  }
674
- isDev4 && checkError(p);
711
+ isDev5 && checkError(p);
675
712
  return onError(p);
676
713
  };
677
714
  return ok ? result.catch(retry) : retry(result);
@@ -832,69 +869,9 @@ function isAriaAttribute(prop) {
832
869
  return prop.startsWith("aria-");
833
870
  }
834
871
 
835
- // packages/qwik/src/core/preloader/bundle-graph.ts
836
- import { isServer as isServer3 } 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 = (doc, containerEl, url) => {
882
- const baseURI = doc.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
872
  // packages/qwik/src/core/preloader/bundle-graph.ts
895
873
  var base;
896
874
  var graph;
897
- var isBrowser = import.meta.env.TEST ? !isServerPlatform() : !isServer3;
898
875
  var parseBundleGraph = (serialized) => {
899
876
  const graph2 = /* @__PURE__ */ new Map();
900
877
  let i = 0;
@@ -937,6 +914,26 @@ var isObjectEmpty = (obj) => {
937
914
  return true;
938
915
  };
939
916
 
917
+ // packages/qwik/src/core/ssr/stream-writer.ts
918
+ var stringifyRootRefPath = (path) => {
919
+ let text = String(path[0]);
920
+ for (let i = 1; i < path.length; i++) {
921
+ text += " " + path[i];
922
+ }
923
+ return text;
924
+ };
925
+ var writeStringRootRef = (writer, id) => writer.write(String(id));
926
+ var writeStringRootRefPath = (writer, path) => writer.write(stringifyRootRefPath(path));
927
+ var createStringStreamWriter = (write) => ({
928
+ write,
929
+ writeRootRef(id) {
930
+ return writeStringRootRef(this, id);
931
+ },
932
+ writeRootRefPath(path) {
933
+ return writeStringRootRefPath(this, path);
934
+ }
935
+ });
936
+
940
937
  // packages/qwik/src/core/shared/ssr-const.ts
941
938
  var LT = "<";
942
939
  var GT = ">";
@@ -961,20 +958,20 @@ var getDevSegmentPath = (mapper, hash, symbolName, parent) => {
961
958
  }
962
959
  if (!parent) {
963
960
  if (symbolName.startsWith("_") && symbolName.length < 6) {
964
- return [symbolName, `${import.meta.env.BASE_URL}@qwik-handlers`];
961
+ return [symbolName, `${import.meta.env?.BASE_URL}@qwik-handlers`];
965
962
  }
966
963
  console.error("qwik symbolMapper: unknown qrl requested without parent:", symbolName);
967
- return [symbolName, `${import.meta.env.BASE_URL}${symbolName}.js`];
964
+ return [symbolName, `${import.meta.env?.BASE_URL}${symbolName}.js`];
968
965
  }
969
- const qrlFile = `${import.meta.env.BASE_URL}${parent.startsWith("/") ? parent.slice(1) : parent}_${symbolName}.js`;
966
+ const qrlFile = `${import.meta.env?.BASE_URL}${parent.startsWith("/") ? parent.slice(1) : parent}_${symbolName}.js`;
970
967
  return [symbolName, qrlFile];
971
968
  };
972
- function createPlatform2(opts, resolvedManifest) {
969
+ function createPlatform(opts, resolvedManifest) {
973
970
  const mapper = resolvedManifest?.mapper;
974
971
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
975
- if (mapper || isDev5 && import.meta.env.MODE !== "test") {
976
- const hash = getSymbolHash2(symbolName);
977
- const result = !isDev5 ? mapper[hash] : getDevSegmentPath(mapper, hash, symbolName, parent);
972
+ if (mapper || isDev6 && import.meta.env?.MODE !== "test") {
973
+ const hash = getSymbolHash(symbolName);
974
+ const result = !isDev6 ? mapper[hash] : getDevSegmentPath(mapper, hash, symbolName, parent);
978
975
  if (!result) {
979
976
  if (hash === SYNC_QRL) {
980
977
  return [hash, ""];
@@ -991,7 +988,7 @@ function createPlatform2(opts, resolvedManifest) {
991
988
  const serverPlatform = {
992
989
  isServer: true,
993
990
  async importSymbol(_containerEl, url, symbolName) {
994
- const hash = getSymbolHash2(symbolName);
991
+ const hash = getSymbolHash(symbolName);
995
992
  const regSym = globalThis.__qwik_reg_symbols?.get(hash);
996
993
  if (regSym) {
997
994
  return regSym;
@@ -1009,10 +1006,10 @@ function createPlatform2(opts, resolvedManifest) {
1009
1006
  return serverPlatform;
1010
1007
  }
1011
1008
  async function setServerPlatform(opts, manifest) {
1012
- const platform = createPlatform2(opts, manifest);
1009
+ const platform = createPlatform(opts, manifest);
1013
1010
  setPlatform(platform);
1014
1011
  }
1015
- var getSymbolHash2 = (symbolName) => {
1012
+ var getSymbolHash = (symbolName) => {
1016
1013
  const index = symbolName.lastIndexOf("_");
1017
1014
  if (index > -1) {
1018
1015
  return symbolName.slice(index + 1);
@@ -1020,38 +1017,11 @@ var getSymbolHash2 = (symbolName) => {
1020
1017
  return symbolName;
1021
1018
  };
1022
1019
 
1023
- // packages/qwik/src/server/utils.ts
1024
- function createTimer() {
1025
- if (typeof performance === "undefined") {
1026
- return () => 0;
1027
- }
1028
- const start = performance.now();
1029
- return () => {
1030
- const end = performance.now();
1031
- const delta = end - start;
1032
- return delta / 1e6;
1033
- };
1034
- }
1035
- function getBuildBase(opts) {
1036
- let base2 = opts.base;
1037
- if (typeof opts.base === "function") {
1038
- base2 = opts.base(opts);
1039
- }
1040
- if (typeof base2 === "string") {
1041
- if (!base2.endsWith("/")) {
1042
- base2 += "/";
1043
- }
1044
- return base2;
1045
- }
1046
- return `${import.meta.env.BASE_URL || "/"}build/`;
1047
- }
1048
- var versions = {
1049
- qwik: "2.0.0-beta.34-dev+8b055bb",
1050
- qwikDom: "2.1.19"
1051
- };
1020
+ // packages/qwik/src/server/ssr-render.ts
1021
+ import { getClientManifest } from "@qwik.dev/core";
1052
1022
 
1053
1023
  // packages/qwik/src/server/ssr-container.ts
1054
- import { isDev as isDev7 } from "@qwik.dev/core/build";
1024
+ import { isDev as isDev8 } from "@qwik.dev/core/build";
1055
1025
  import {
1056
1026
  _SubscriptionData as SubscriptionData,
1057
1027
  _SharedContainer,
@@ -1064,6 +1034,69 @@ import {
1064
1034
  isSignal
1065
1035
  } from "@qwik.dev/core/internal";
1066
1036
 
1037
+ // packages/qwik/src/server/ooos-utils.ts
1038
+ import { _SubscriptionPatch as SubscriptionPatch } from "@qwik.dev/core/internal";
1039
+ var recordExternalRootEffect = (rootCtx, segmentCtx, storeProxyMap, records, producer, effect, prop, sourceEffects) => {
1040
+ if (!records || prop !== null && !sourceEffects) {
1041
+ return;
1042
+ }
1043
+ let rootObj = producer;
1044
+ if (prop !== null && producer && (typeof producer === "object" || typeof producer === "function")) {
1045
+ rootObj = storeProxyMap.get(producer) || producer;
1046
+ }
1047
+ const rootId = rootCtx.$hasRootId$(rootObj);
1048
+ segmentCtx.$addRoot$(rootObj);
1049
+ segmentCtx.$addRoot$(effect);
1050
+ if (prop !== null && typeof prop !== "string") {
1051
+ segmentCtx.$addRoot$(prop);
1052
+ }
1053
+ records.push({
1054
+ rootObj,
1055
+ rootId,
1056
+ effect,
1057
+ prop
1058
+ });
1059
+ };
1060
+ var collectSubscriptionPatches = (rootCtx, records, rootLimit) => {
1061
+ if (!records?.length) {
1062
+ return;
1063
+ }
1064
+ const patches = [];
1065
+ const patchesByRoot = /* @__PURE__ */ new Map();
1066
+ for (let i = 0; i < records.length; i++) {
1067
+ const entry = records[i];
1068
+ const rootId = entry.rootId === void 0 ? rootCtx.$hasRootId$(entry.rootObj) : entry.rootId;
1069
+ if (rootId === void 0 || rootId >= rootLimit) {
1070
+ continue;
1071
+ }
1072
+ let patch = patchesByRoot.get(rootId);
1073
+ if (!patch) {
1074
+ patch = new SubscriptionPatch(
1075
+ rootId,
1076
+ entry.prop === null ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Map()
1077
+ );
1078
+ patchesByRoot.set(rootId, patch);
1079
+ patches.push(patch);
1080
+ }
1081
+ const subscriptions = patch.subscriptions;
1082
+ if (entry.prop === null) {
1083
+ if (subscriptions instanceof Set) {
1084
+ subscriptions.add(entry.effect);
1085
+ }
1086
+ } else {
1087
+ if (subscriptions instanceof Map) {
1088
+ let effects = subscriptions.get(entry.prop);
1089
+ if (!effects) {
1090
+ effects = /* @__PURE__ */ new Set();
1091
+ subscriptions.set(entry.prop, effects);
1092
+ }
1093
+ effects.add(entry.effect);
1094
+ }
1095
+ }
1096
+ }
1097
+ return patches.length ? patches : void 0;
1098
+ };
1099
+
1067
1100
  // packages/qwik/src/server/preload-impl.ts
1068
1101
  import { getPlatform } from "@qwik.dev/core";
1069
1102
  var simplifyPath = (base2, path) => {
@@ -1084,8 +1117,8 @@ var simplifyPath = (base2, path) => {
1084
1117
  };
1085
1118
  var getBase = (container) => {
1086
1119
  let base2 = container.$buildBase$;
1087
- if (import.meta.env.DEV && !import.meta.env.TEST) {
1088
- base2 = import.meta.env.BASE_URL;
1120
+ if (import.meta.env?.DEV && !qTest) {
1121
+ base2 = import.meta.env?.BASE_URL;
1089
1122
  }
1090
1123
  return base2;
1091
1124
  };
@@ -1095,9 +1128,9 @@ var preloaderPre = (container, options, nonce) => {
1095
1128
  const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
1096
1129
  let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
1097
1130
  if (bundleGraphPath) {
1098
- bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
1131
+ bundleGraphPath = (import.meta.env?.BASE_URL || "/") + bundleGraphPath;
1099
1132
  }
1100
- if (preloaderBundle && bundleGraphPath && options !== false) {
1133
+ if (!(import.meta.env?.DEV && !qTest) && preloaderBundle && bundleGraphPath && options !== false) {
1101
1134
  const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
1102
1135
  initPreloader(bundleGraph);
1103
1136
  const opts = [];
@@ -1134,9 +1167,7 @@ var preloaderPre = (container, options, nonce) => {
1134
1167
  if (nonce) {
1135
1168
  scriptAttrs["nonce"] = nonce;
1136
1169
  }
1137
- container.openElement("script", null, scriptAttrs, null, null, null);
1138
- container.write(script);
1139
- container.closeElement();
1170
+ container.writeScript(scriptAttrs, script);
1140
1171
  }
1141
1172
  const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
1142
1173
  if (corePath) {
@@ -1191,13 +1222,14 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
1191
1222
  if (nonce) {
1192
1223
  attrs["nonce"] = nonce;
1193
1224
  }
1194
- container.openElement("script", null, attrs, null, null, null);
1195
- container.write(script);
1196
- container.closeElement();
1225
+ container.writeScript(attrs, script);
1197
1226
  }
1198
1227
  return null;
1199
1228
  };
1200
1229
  var preloaderPost = (ssrContainer, opts, nonce) => {
1230
+ if (import.meta.env?.DEV && !qTest) {
1231
+ return;
1232
+ }
1201
1233
  if (opts.preloader !== false) {
1202
1234
  const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
1203
1235
  const preloadBundles = getBundles(qrls);
@@ -1226,14 +1258,15 @@ var preLoaderOptionsDefault = {
1226
1258
  };
1227
1259
 
1228
1260
  // packages/qwik/src/server/scripts.ts
1229
- var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,r="w",n="wp",o="d",s="dp",i="e",c="ep",l="capture:",a=new Set,p=new Set([e]),q=new Map;let u,f,h;const d=(e,t)=>Array.from(e.querySelectorAll(t)),b=e=>{const t=[];return p.forEach(r=>t.push(...d(r,e))),t},m=(e,t,r,n=!1,o=!1)=>e.addEventListener(t,r,{capture:n,passive:o}),g=e=>{J(e);const t=d(e,"[q\\\\:shadowroot]");for(let e=0;e<t.length;e++){const r=t[e].shadowRoot;r&&g(r)}},v=e=>e&&"function"==typeof e.then,y=async e=>{for(let t=0;t<e.length;t++)await e[t]()},w=e=>{if(e.length){const t=()=>y(e);h=h?h.then(t,t):t()}},E=t=>{if(void 0===t._qwikjson_){let r=(t===e.documentElement?e.body:t).lastElementChild;for(;r;){if("SCRIPT"===r.tagName&&"qwik/json"===r.getAttribute("type")){t._qwikjson_=JSON.parse(r.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}r=r.previousElementSibling}}},A=(e,t)=>new CustomEvent(e,{detail:t}),C=(t,r)=>{e.dispatchEvent(A(t,r))},_=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),k=e=>e.replace(/-./g,e=>e[1].toUpperCase()),B=e=>{const t=e.indexOf(":");return{scope:e.slice(0,t),eventName:k(e.slice(t+1))}},S=e=>2===e.length,I=e=>e.charAt(0),N=e=>!!e&&1===e.nodeType,T=(e,t,r)=>e.hasAttribute(r)&&(!!e._qDispatch?.[t]||e.hasAttribute("q-"+t)),$=(t,r,n,o,s,i,c)=>{const l={qBase:n,symbol:i,element:r,reqTime:c};if(""===s){const r=t.getAttribute("q:instance"),n=(e["qFuncs_"+r]||[])[Number.parseInt(i)];if(!n){const e=Error("sym:"+i);C("qerror",{importError:"sync",error:e,...l}),console.error(e)}return n}const a=`${i}|${n}|${s}`,p=q.get(a);if(p)return p;const u=new URL(s,o).href,f=import(u);return E(t),f.then(e=>{const t=e[i];if(t)q.set(a,t),C("qsymbol",l);else{const e=Error(`${i} not in ${u}`);C("qerror",{importError:"no-symbol",error:e,...l}),console.error(e)}return t},e=>{C("qerror",{importError:"async",error:e,...l}),console.error(e)})},R=(t,r,n,o,s,i=!0)=>{let c=!1;s&&(i&&t.hasAttribute("preventdefault:"+s)&&r.preventDefault(),t.hasAttribute("stoppropagation:"+s)&&r.stopPropagation());const l=t._qDispatch?.[n];if(l){if("function"==typeof l){const e=()=>l(r,t);if(c)o.push(async()=>{const t=e();v(t)&&await t});else{const t=e();v(t)&&(c=!0,o.push(()=>t))}}else if(l.length)for(let e=0;e<l.length;e++){const n=l[e];if(n){const e=()=>n(r,t);if(c)o.push(async()=>{const t=e();v(t)&&await t});else{const t=e();v(t)&&(c=!0,o.push(()=>t))}}}return}const a=t.getAttribute("q-"+n);if(a){const n=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),s=n.getAttribute("q:base"),i=new URL(s,e.baseURI),l=a.split("|");for(let e=0;e<l.length;e++){const a=l[e],p=performance.now(),[q,u,f]=a.split("#"),h=e=>{if(e&&t.isConnected)try{const n=e.call(f,r,t);if(v(n))return n.catch(e=>{C("qerror",{error:e,qBase:s,symbol:u,element:t,reqTime:p})})}catch(e){C("qerror",{error:e,qBase:s,symbol:u,element:t,reqTime:p})}},d=$(n,t,s,i,q,u,p);if(c||v(d))c=!0,o.push(async()=>{await h(v(d)?await d:d)});else{const e=h(d);v(e)&&(c=!0,o.push(()=>e))}}}},x=(e,t=i,r=!0)=>{const n=_(e.type),o=t+":"+n,s=l+n,c=[],a=[],p=[];let q=e.target;for(;q;)N(q)?(c.push(q),a.push(T(q,o,s)),q=q.parentElement):q=q.parentElement;for(let t=c.length-1;t>=0;t--)if(a[t]&&(R(c[t],e,o,p,n,r),e.cancelBubble||e.cancelBubble))return void w(p);for(let t=0;t<c.length;t++)if(!a[t]&&(R(c[t],e,o,p,n,r),!e.bubbles||e.cancelBubble||e.cancelBubble))return void w(p);w(p)},L=e=>x(e,c,!1),U=(e,t,r=!0)=>{const n=_(t.type),o=e+":"+n,s=b("[q-"+e+"\\\\:"+n+"]"),i=[];for(let e=0;e<s.length;e++){const c=s[e];R(c,t,o,i,n,r)}w(i)},j=e=>{U(o,e)},D=e=>{U(s,e,!1)},O=e=>{U(r,e)},P=e=>{U(n,e,!1)},F=()=>{const r=e.readyState;if("interactive"==r||"complete"==r){if(f=1,p.forEach(g),a.has("d:qinit")){a.delete("d:qinit");const e=A("qinit"),t=b("[q-d\\\\:qinit]"),r=[];for(let n=0;n<t.length;n++){const o=t[n];R(o,e,"d:qinit",r),o.removeAttribute("q-d:qinit")}w(r)}if(a.has("d:qidle")&&(a.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=A("qidle"),t=b("[q-d\\\\:qidle]"),r=[];for(let n=0;n<t.length;n++){const o=t[n];R(o,e,"d:qidle",r),o.removeAttribute("q-d:qidle")}w(r)})),a.has("e:qvisible")){u||(u=new IntersectionObserver(e=>{const t=[];for(let r=0;r<e.length;r++){const n=e[r];n.isIntersecting&&(u.unobserve(n.target),R(n.target,A("qvisible",n),"e:qvisible",t))}w(t)}));const e=b("[q-e\\\\:qvisible]:not([q\\\\:observed])");for(let t=0;t<e.length;t++){const r=e[t];u.observe(r),r.setAttribute("q:observed","true")}}}},J=(...e)=>{for(let n=0;n<e.length;n++){const s=e[n];if("string"==typeof s){if(!a.has(s)){a.add(s);const{scope:e,eventName:n}=B(s),i=S(e),c=I(e);c===r?m(t,n,i?P:O,!0,i):p.forEach(e=>m(e,n,c===o?i?D:j:i?L:x,!0,i)),1!==f||"e:qvisible"!==s&&"d:qinit"!==s&&"d:qidle"!==s||F()}}else p.has(s)||(a.forEach(e=>{const{scope:t,eventName:n}=B(e),i=S(t),c=I(t);c!==r&&m(s,n,c===o?i?D:j:i?L:x,!0,i)}),p.add(s))}},M=t._qwikEv;M?.roots||(Array.isArray(M)?J(...M):J("e:click","e:input"),t._qwikEv={events:a,roots:p,push:J},m(e,"readystatechange",F),F())';
1230
- var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst passiveWindowPrefix = "wp";\nconst documentPrefix = "d";\nconst passiveDocumentPrefix = "dp";\nconst elementPrefix = "e";\nconst passiveElementPrefix = "ep";\nconst capturePrefix = "capture:";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nlet queuedTasks;\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, passive = false) => el.addEventListener(eventName, handler, { capture, passive });\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 runTasks = async (tasks) => {\n for (let i = 0; i < tasks.length; i++) {\n await tasks[i]();\n }\n};\nconst queueTasks = (tasks) => {\n if (tasks.length) {\n const run = () => runTasks(tasks);\n queuedTasks = queuedTasks ? queuedTasks.then(run, run) : run();\n }\n};\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 const separatorIndex = event.indexOf(":");\n const scope = event.slice(0, separatorIndex);\n return {\n scope,\n eventName: kebabToCamel(event.slice(separatorIndex + 1))\n };\n};\nconst isPassiveScope = (scope) => scope.length === 2;\nconst getRootScope = (scope) => scope.charAt(0);\nconst isElementNode = (node) => !!node && node.nodeType === 1;\nconst isCaptureHandlerElement = (element, scopedKebabName, captureAttribute) => element.hasAttribute(captureAttribute) && (!!element._qDispatch?.[scopedKebabName] || element.hasAttribute("q-" + scopedKebabName));\nconst resolveHandler = (container, element, qBase, base, chunk, symbol, reqTime) => {\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n if (chunk === "") {\n const hash = container.getAttribute("q:instance");\n const handler2 = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler2) {\n const error = new Error("sym:" + symbol);\n emitEvent("qerror", {\n importError: "sync",\n error,\n ...eventData\n });\n console.error(error);\n }\n return handler2;\n }\n const key = `${symbol}|${qBase}|${chunk}`;\n const handler = symbols.get(key);\n if (handler) {\n return handler;\n }\n const href = new URL(chunk, base).href;\n const module = import(\n href\n );\n resolveContainer(container);\n return module.then(\n (module2) => {\n const handler2 = module2[symbol];\n if (!handler2) {\n const error = new Error(`${symbol} not in ${href}`);\n emitEvent("qerror", {\n importError: "no-symbol",\n error,\n ...eventData\n });\n console.error(error);\n } else {\n symbols.set(key, handler2);\n emitEvent("qsymbol", eventData);\n }\n return handler2;\n },\n (error) => {\n emitEvent("qerror", {\n importError: "async",\n error,\n ...eventData\n });\n console.error(error);\n return void 0;\n }\n );\n};\nconst dispatch = (element, ev, scopedKebabName, tasks, kebabName, allowPreventDefault = true) => {\n let defer = false;\n if (kebabName) {\n if (allowPreventDefault && 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 run = () => handlers(ev, element);\n if (defer) {\n tasks.push(async () => {\n const result = run();\n if (isPromise(result)) {\n await result;\n }\n });\n } else {\n const result = run();\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\n } else if (handlers.length) {\n for (let i = 0; i < handlers.length; i++) {\n const handler = handlers[i];\n if (handler) {\n const run = () => handler(ev, element);\n if (defer) {\n tasks.push(async () => {\n const result = run();\n if (isPromise(result)) {\n await result;\n }\n });\n } else {\n const result = run();\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\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 run = (handler2) => {\n if (handler2 && element.isConnected) {\n try {\n const result = handler2.call(capturedIds, ev, element);\n if (isPromise(result)) {\n return result.catch((error) => {\n emitEvent("qerror", {\n error,\n qBase,\n symbol,\n element,\n reqTime\n });\n });\n }\n } catch (error) {\n emitEvent("qerror", {\n error,\n qBase,\n symbol,\n element,\n reqTime\n });\n }\n }\n };\n const handler = resolveHandler(container, element, qBase, base, chunk, symbol, reqTime);\n if (defer || isPromise(handler)) {\n defer = true;\n tasks.push(async () => {\n await run(isPromise(handler) ? await handler : handler);\n });\n } else {\n const result = run(handler);\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\n }\n }\n};\nconst processElementEvent = (ev, scope = elementPrefix, allowPreventDefault = true) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = scope + ":" + kebabName;\n const captureAttribute = capturePrefix + kebabName;\n const elements = [];\n const captureHandlers = [];\n const tasks = [];\n let current = ev.target;\n while (current) {\n if (isElementNode(current)) {\n elements.push(current);\n captureHandlers.push(isCaptureHandlerElement(current, scopedKebabName, captureAttribute));\n current = current.parentElement;\n } else {\n current = current.parentElement;\n }\n }\n for (let i = elements.length - 1; i >= 0; i--) {\n if (captureHandlers[i]) {\n dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n const continuePropagation = !ev.cancelBubble;\n if (!continuePropagation || ev.cancelBubble) {\n queueTasks(tasks);\n return;\n }\n }\n }\n for (let i = 0; i < elements.length; i++) {\n if (!captureHandlers[i]) {\n dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (!doBubble || ev.cancelBubble) {\n queueTasks(tasks);\n return;\n }\n }\n }\n queueTasks(tasks);\n};\nconst processPassiveElementEvent = (ev) => processElementEvent(ev, passiveElementPrefix, false);\nconst broadcast = (scope, ev, allowPreventDefault = true) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = scope + ":" + kebabName;\n const elements = querySelectorAll("[q-" + scope + "\\\\:" + kebabName + "]");\n const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n }\n queueTasks(tasks);\n};\nconst processDocumentEvent = (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processPassiveDocumentEvent = (ev) => {\n broadcast(passiveDocumentPrefix, ev, false);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processPassiveWindowEvent = (ev) => {\n broadcast(passiveWindowPrefix, ev, false);\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 const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qinit", tasks);\n el.removeAttribute("q-d:qinit");\n }\n queueTasks(tasks);\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 const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qidle", tasks);\n el.removeAttribute("q-d:qidle");\n }\n queueTasks(tasks);\n });\n }\n if (events.has("e:qvisible")) {\n observer || (observer = new IntersectionObserver((entries) => {\n const tasks = [];\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(\n entry.target,\n createEvent("qvisible", entry),\n "e:qvisible",\n tasks\n );\n }\n }\n queueTasks(tasks);\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 const passive = isPassiveScope(scope);\n const rootScope = getRootScope(scope);\n if (rootScope === windowPrefix) {\n addEventListener(\n win,\n eventName,\n passive ? processPassiveWindowEvent : processWindowEvent,\n true,\n passive\n );\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n rootScope === documentPrefix ? passive ? processPassiveDocumentEvent : processDocumentEvent : passive ? processPassiveElementEvent : processElementEvent,\n true,\n passive\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 const passive = isPassiveScope(scope);\n const rootScope = getRootScope(scope);\n if (rootScope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n rootScope === documentPrefix ? passive ? processPassiveDocumentEvent : processDocumentEvent : passive ? processPassiveElementEvent : processElementEvent,\n true,\n passive\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}';
1231
- var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]';function e(e,n){const o=n||e.querySelector("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");if(o){const n=o.querySelector(t);if(n){const t=JSON.parse(n.textContent||"[]"),r=e.createTreeWalker(o,NodeFilter.SHOW_ELEMENT);let c=r.currentNode,i=c.hasAttribute(":")?0:-1;for(let e=0;e<t.length;e+=3){const n=t[e],o=t[e+1];let s=t[e+2];for(;i<n&&(c=r.nextNode(),c);)c.hasAttribute(":")&&i++;const a=c;null==s||!1===s?a.removeAttribute(o):("boolean"==typeof s&&(s=""),a.setAttribute(o,s))}}}}const n=document.currentScript;if(n){const t=n.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");t&&e(document,t)}`;
1261
+ var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,n="w",r="wp",o="d",s="dp",i="e",c="ep",a="capture:",l="readystatechange",p="qready",u=new Set,q=new Set([e]),d=new Map;let h,f,b;const g=(e,t)=>Array.from(e.querySelectorAll(t)),m=e=>{const t=[];return q.forEach(n=>t.push(...g(n,e))),t},v=(e,t,n,r=!1,o=!1)=>e.addEventListener(t,n,{capture:r,passive:o}),y=e=>{z(e);const t=g(e,"[q\\\\:shadowroot]");for(let e=0;e<t.length;e++){const n=t[e].shadowRoot;n&&y(n)}},w=e=>e&&"function"==typeof e.then,E=async e=>{for(let t=0;t<e.length;t++)await e[t]()},A=e=>{if(e.length){const t=()=>E(e);b=b?b.then(t,t):t()}},C=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}}},_=t=>{const n=t.getAttribute("q:instance");return"paused"===t.getAttribute("q:container")&&"loading"===e.readyState&&!e[p]?.[n]&&new Promise(t=>{const r=o=>{o.detail===n&&(e.removeEventListener(p,r),t())};v(e,l,t),v(e,p,r)})},k=(e,t)=>new CustomEvent(e,{detail:t}),S=(t,n)=>{e.dispatchEvent(k(t,n))},$=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),I=e=>e.replace(/-./g,e=>e[1].toUpperCase()),L=e=>{const t=e.indexOf(":");return{scope:e.slice(0,t),eventName:I(e.slice(t+1))}},N=e=>2===e.length,R=e=>e.charAt(0),T=e=>!!e&&1===e.nodeType,x=(e,t,n)=>e.hasAttribute(n)&&(!!e._qDispatch?.[t]||e.hasAttribute("q-"+t)),B=(t,n,r,o,s,i,c,a=!0)=>{const l={qBase:r,symbol:i,element:n,reqTime:c};if(!s){const n=(e["qFuncs_"+t.getAttribute("q:instance")]||[])[+i];if(!n&&a){const e=Error("sym:"+i);S("qerror",{importError:"sync",error:e,...l}),console.error(e)}return n}const p=`${i}|${r}|${s}`,u=d.get(p);if(u)return u;const q=new URL(s,o).href,h=import(q);return C(t),h.then(e=>{const t=e[i];if(t)d.set(p,t),S("qsymbol",l);else{const e=Error(`${i} not in ${q}`);S("qerror",{importError:"no-symbol",error:e,...l}),console.error(e)}return t},e=>{S("qerror",{importError:"async",error:e,...l}),console.error(e)})},U=(t,n,r,o,s,i=!0)=>{let c=!1;s&&(i&&t.hasAttribute("preventdefault:"+s)&&n.preventDefault(),t.hasAttribute("stoppropagation:"+s)&&n.stopPropagation());const a=t._qDispatch?.[r];if(a){if("function"==typeof a){const e=()=>a(n,t);if(c)o.push(async()=>{const t=e();w(t)&&await t});else{const t=e();w(t)&&(c=!0,o.push(()=>t))}}else if(a.length)for(let e=0;e<a.length;e++){const r=a[e];if(r){const e=()=>r(n,t);if(c)o.push(async()=>{const t=e();w(t)&&await t});else{const t=e();w(t)&&(c=!0,o.push(()=>t))}}}return}const l=t.getAttribute("q-"+r);if(l){const r=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),s=r.getAttribute("q:base"),i=new URL(s,e.baseURI),a=l.split("|"),p=_(r);for(let e=0;e<a.length;e++){const l=a[e],u=performance.now(),[q,d,h]=l.split("#"),f=e=>{if(e&&t.isConnected){const o=n=>{const o=_(r);if(o)return o.then(()=>f(e));S("qerror",{error:n,qBase:s,symbol:d,element:t,reqTime:u})};try{const r=e.call(h,n,t);if(w(r))return r.catch(o)}catch(e){return o(e)}}},b=(e=!0)=>B(r,t,s,i,q,d,u,e),g=p&&!q?b(!1):b();if(w(g))c=!0,o.push(()=>g.then(f));else if(c||p&&!q&&!g)c=!0,o.push(async()=>{let e=g;!e&&p&&(await p,e=b(!1)),await f(e||await b())});else{const e=f(g);w(e)&&(c=!0,o.push(()=>e))}}}},j=(e,t=i,n=!0)=>{const r=$(e.type),o=t+":"+r,s=a+r,c=[],l=[],p=[];let u=e.target;for(;u;)T(u)?(c.push(u),l.push(x(u,o,s)),u=u.parentElement):u=u.parentElement;for(let t=c.length-1;t>=0;t--)if(l[t]&&(U(c[t],e,o,p,r,n),e.cancelBubble))return void A(p);for(let t=0;t<c.length;t++)if(!l[t]&&(U(c[t],e,o,p,r,n),!e.bubbles||e.cancelBubble))return void A(p);A(p)},D=e=>j(e,c,!1),O=(e,t,n=!0)=>{const r=$(t.type),o=e+":"+r,s=m("[q-"+e+"\\\\:"+r+"]"),i=[];for(let e=0;e<s.length;e++){const c=s[e];U(c,t,o,i,r,n)}A(i)},P=e=>{O(o,e)},F=e=>{O(s,e,!1)},J=e=>{O(n,e)},M=e=>{O(r,e,!1)},Z=()=>{const n=e.readyState;if("interactive"==n||"complete"==n){if(f=1,q.forEach(y),u.has("d:qinit")){u.delete("d:qinit");const e=k("qinit"),t=m("[q-d\\\\:qinit]"),n=[];for(let r=0;r<t.length;r++){const o=t[r];U(o,e,"d:qinit",n),o.removeAttribute("q-d:qinit")}A(n)}if(u.has("d:qidle")&&(u.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=k("qidle"),t=m("[q-d\\\\:qidle]"),n=[];for(let r=0;r<t.length;r++){const o=t[r];U(o,e,"d:qidle",n),o.removeAttribute("q-d:qidle")}A(n)})),u.has("e:qvisible")){h||(h=new IntersectionObserver(e=>{const t=[];for(let n=0;n<e.length;n++){const r=e[n];r.isIntersecting&&(h.unobserve(r.target),U(r.target,k("qvisible",r),"e:qvisible",t))}A(t)}));const e=m("[q-e\\\\:qvisible]:not([q\\\\:observed])");for(let t=0;t<e.length;t++){const n=e[t];h.observe(n),n.setAttribute("q:observed","true")}}}},z=(...e)=>{for(let r=0;r<e.length;r++){const s=e[r];if("string"==typeof s){if(!u.has(s)){u.add(s);const{scope:e,eventName:r}=L(s),i=N(e),c=R(e);c===n?v(t,r,i?M:J,!0,i):q.forEach(e=>v(e,r,c===o?i?F:P:i?D:j,!0,i)),1!==f||"e:qvisible"!==s&&"d:qinit"!==s&&"d:qidle"!==s||Z()}}else q.has(s)||(u.forEach(e=>{const{scope:t,eventName:r}=L(e),i=N(t),c=R(t);c!==n&&v(s,r,c===o?i?F:P:i?D:j,!0,i)}),q.add(s))}},G=t._qwikEv;G?.roots||(Array.isArray(G)?z(...G):z("e:click","e:input"),t._qwikEv={events:u,roots:q,push:z},v(e,l,Z),Z())';
1262
+ var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst passiveWindowPrefix = "wp";\nconst documentPrefix = "d";\nconst passiveDocumentPrefix = "dp";\nconst elementPrefix = "e";\nconst passiveElementPrefix = "ep";\nconst capturePrefix = "capture:";\nconst readyStateChange = "readystatechange";\nconst containerReady = "qready";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nlet queuedTasks;\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, passive = false) => el.addEventListener(eventName, handler, { capture, passive });\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 runTasks = async (tasks) => {\n for (let i = 0; i < tasks.length; i++) {\n await tasks[i]();\n }\n};\nconst queueTasks = (tasks) => {\n if (tasks.length) {\n const run = () => runTasks(tasks);\n queuedTasks = queuedTasks ? queuedTasks.then(run, run) : run();\n }\n};\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 waitForContainerReady = (container) => {\n const hash = container.getAttribute("q:instance");\n return container.getAttribute("q:container") === "paused" && doc.readyState === "loading" && !doc[containerReady]?.[hash] && new Promise((resolve) => {\n const ready = (ev) => {\n if (ev.detail === hash) {\n doc.removeEventListener(containerReady, ready);\n resolve();\n }\n };\n addEventListener(doc, readyStateChange, resolve);\n addEventListener(doc, containerReady, ready);\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 const separatorIndex = event.indexOf(":");\n const scope = event.slice(0, separatorIndex);\n return {\n scope,\n eventName: kebabToCamel(event.slice(separatorIndex + 1))\n };\n};\nconst isPassiveScope = (scope) => scope.length === 2;\nconst getRootScope = (scope) => scope.charAt(0);\nconst isElementNode = (node) => !!node && node.nodeType === 1;\nconst isCaptureHandlerElement = (element, scopedKebabName, captureAttribute) => element.hasAttribute(captureAttribute) && (!!element._qDispatch?.[scopedKebabName] || element.hasAttribute("q-" + scopedKebabName));\nconst resolveHandler = (container, element, qBase, base, chunk, symbol, reqTime, reportSyncError = true) => {\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n if (!chunk) {\n const handler2 = (doc["qFuncs_" + container.getAttribute("q:instance")] || [])[+symbol];\n if (!handler2 && reportSyncError) {\n const error = new Error("sym:" + symbol);\n emitEvent("qerror", {\n importError: "sync",\n error,\n ...eventData\n });\n console.error(error);\n }\n return handler2;\n }\n const key = `${symbol}|${qBase}|${chunk}`;\n const handler = symbols.get(key);\n if (handler) {\n return handler;\n }\n const href = new URL(chunk, base).href;\n const module = import(\n href\n );\n resolveContainer(container);\n return module.then(\n (module2) => {\n const handler2 = module2[symbol];\n if (!handler2) {\n const error = new Error(`${symbol} not in ${href}`);\n emitEvent("qerror", {\n importError: "no-symbol",\n error,\n ...eventData\n });\n console.error(error);\n } else {\n symbols.set(key, handler2);\n emitEvent("qsymbol", eventData);\n }\n return handler2;\n },\n (error) => {\n emitEvent("qerror", {\n importError: "async",\n error,\n ...eventData\n });\n console.error(error);\n return void 0;\n }\n );\n};\nconst dispatch = (element, ev, scopedKebabName, tasks, kebabName, allowPreventDefault = true) => {\n let defer = false;\n if (kebabName) {\n if (allowPreventDefault && 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 run = () => handlers(ev, element);\n if (defer) {\n tasks.push(async () => {\n const result = run();\n if (isPromise(result)) {\n await result;\n }\n });\n } else {\n const result = run();\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\n } else if (handlers.length) {\n for (let i = 0; i < handlers.length; i++) {\n const handler = handlers[i];\n if (handler) {\n const run = () => handler(ev, element);\n if (defer) {\n tasks.push(async () => {\n const result = run();\n if (isPromise(result)) {\n await result;\n }\n });\n } else {\n const result = run();\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\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 const waitForReady = waitForContainerReady(container);\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 run = (handler2) => {\n if (handler2 && element.isConnected) {\n const onError = (error) => {\n const retry = waitForContainerReady(container);\n if (retry) {\n return retry.then(() => run(handler2));\n }\n emitEvent("qerror", {\n error,\n qBase,\n symbol,\n element,\n reqTime\n });\n };\n try {\n const result = handler2.call(capturedIds, ev, element);\n if (isPromise(result)) {\n return result.catch(onError);\n }\n } catch (error) {\n return onError(error);\n }\n }\n };\n const resolve = (reportSyncError = true) => resolveHandler(container, element, qBase, base, chunk, symbol, reqTime, reportSyncError);\n const handler = waitForReady && !chunk ? resolve(false) : resolve();\n if (isPromise(handler)) {\n defer = true;\n tasks.push(() => handler.then(run));\n } else if (defer || waitForReady && !chunk && !handler) {\n defer = true;\n tasks.push(async () => {\n let retryHandler = handler;\n if (!retryHandler && waitForReady) {\n await waitForReady;\n retryHandler = resolve(false);\n }\n await run(retryHandler || await resolve());\n });\n } else {\n const result = run(handler);\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\n }\n }\n};\nconst processElementEvent = (ev, scope = elementPrefix, allowPreventDefault = true) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = scope + ":" + kebabName;\n const captureAttribute = capturePrefix + kebabName;\n const elements = [];\n const captureHandlers = [];\n const tasks = [];\n let current = ev.target;\n while (current) {\n if (isElementNode(current)) {\n elements.push(current);\n captureHandlers.push(isCaptureHandlerElement(current, scopedKebabName, captureAttribute));\n current = current.parentElement;\n } else {\n current = current.parentElement;\n }\n }\n for (let i = elements.length - 1; i >= 0; i--) {\n if (captureHandlers[i]) {\n dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n if (ev.cancelBubble) {\n queueTasks(tasks);\n return;\n }\n }\n }\n for (let i = 0; i < elements.length; i++) {\n if (!captureHandlers[i]) {\n dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n if (!ev.bubbles || ev.cancelBubble) {\n queueTasks(tasks);\n return;\n }\n }\n }\n queueTasks(tasks);\n};\nconst processPassiveElementEvent = (ev) => processElementEvent(ev, passiveElementPrefix, false);\nconst broadcast = (scope, ev, allowPreventDefault = true) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = scope + ":" + kebabName;\n const elements = querySelectorAll("[q-" + scope + "\\\\:" + kebabName + "]");\n const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n }\n queueTasks(tasks);\n};\nconst processDocumentEvent = (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processPassiveDocumentEvent = (ev) => {\n broadcast(passiveDocumentPrefix, ev, false);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processPassiveWindowEvent = (ev) => {\n broadcast(passiveWindowPrefix, ev, false);\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 const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qinit", tasks);\n el.removeAttribute("q-d:qinit");\n }\n queueTasks(tasks);\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 const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qidle", tasks);\n el.removeAttribute("q-d:qidle");\n }\n queueTasks(tasks);\n });\n }\n if (events.has("e:qvisible")) {\n observer || (observer = new IntersectionObserver((entries) => {\n const tasks = [];\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(\n entry.target,\n createEvent("qvisible", entry),\n "e:qvisible",\n tasks\n );\n }\n }\n queueTasks(tasks);\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 const passive = isPassiveScope(scope);\n const rootScope = getRootScope(scope);\n if (rootScope === windowPrefix) {\n addEventListener(\n win,\n eventName,\n passive ? processPassiveWindowEvent : processWindowEvent,\n true,\n passive\n );\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n rootScope === documentPrefix ? passive ? processPassiveDocumentEvent : processDocumentEvent : passive ? processPassiveElementEvent : processElementEvent,\n true,\n passive\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 const passive = isPassiveScope(scope);\n const rootScope = getRootScope(scope);\n if (rootScope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n rootScope === documentPrefix ? passive ? processPassiveDocumentEvent : processDocumentEvent : passive ? processPassiveElementEvent : processElementEvent,\n true,\n passive\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}';
1263
+ var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]';function e(e,n){const o=n||e.querySelector("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");if(o){const n=o.querySelectorAll(t),r=n[n.length-1];if(r){const t=JSON.parse(r.textContent||"[]"),n=e.createTreeWalker(o,NodeFilter.SHOW_ELEMENT);let c=n.currentNode,i=c.hasAttribute(":")?0:-1;for(let e=0;e<t.length;e+=3){const o=t[e],r=t[e+1];let l=t[e+2];for(;i<o&&(c=n.nextNode(),c);)c.hasAttribute(":")&&i++;const s=c;null==l||!1===l?s.removeAttribute(r):("boolean"==typeof l&&(l=""),s.setAttribute(r,l))}}}}const n=document.currentScript;if(n){const t=n.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");t&&e(document,t)}`;
1232
1264
  var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
1233
1265
  function executeBackpatch(doc, containerElement) {
1234
1266
  const container = containerElement || doc.querySelector("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");
1235
1267
  if (container) {
1236
- const script = container.querySelector(BACKPATCH_DATA_SELECTOR);
1268
+ const scripts = container.querySelectorAll(BACKPATCH_DATA_SELECTOR);
1269
+ const script = scripts[scripts.length - 1];
1237
1270
  if (script) {
1238
1271
  const data = JSON.parse(script.textContent || "[]");
1239
1272
  const walker = doc.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
@@ -1274,6 +1307,170 @@ if (executorScript) {
1274
1307
  executeBackpatch(document, container);
1275
1308
  }
1276
1309
  }`;
1310
+ var QWIK_OUT_OF_ORDER_EXECUTOR_MINIFIED = `const t='template[q\\\\:r="',e="q:r",n='[q\\\\:rp="',r="q:g",l="q:i",o="q:o",s="[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])",u=u=>{const i=new WeakMap,c=()=>{const t=u.currentScript;return t&&t.closest(s)||u},f=(t,e,n,r)=>{let l=i.get(t);return l||i.set(t,l={}),l[e]||(l[e]={r:{},n:0,t:n,o:r})},a=(t,e)=>t?(e&&e.style&&(e.style.display="none"),t.style&&(t.style.display="contents"),1):0,q=t=>{const e=t.o;let n,r,l=0;if("p"===e)for(const e in t.r)n=t.r[e],n[0]&&a(n[0],n[1])&&(n[0]=0,l++);else if("s"===e)for(r=t.n;(n=t.r[r])&&n[0]&&a(n[0],n[1]);r++)n[0]=0,l++,t.n=r+1;else if("r"===e){if(t.t<0)return 0;for(t.n<0&&(t.n=t.t-1),r=t.n;(n=t.r[r])&&n[0]&&a(n[0],n[1]);r--)n[0]=0,l++,t.n=r-1}else{if(t.t<0)return 0;for(r=0;r<t.t;r++)if(n=t.r[r],!n)return 0;for(r=0;r<t.t;r++)n=t.r[r],n[0]&&a(n[0],n[1])&&(n[0]=0,l++)}return l},p=s=>{const i=c(),p=((n,r)=>{const l=u.currentScript,o=l?l.previousElementSibling:null;if(o&&"template"===o.localName&&o.getAttribute(e)===r+"")return o;const s=n.querySelectorAll(t+r+'"]');return s.length?s[s.length-1]:null})(i,s);if(!p)return;const g=((e,r,l)=>{if(!l)return null;const o=((t,e)=>t.querySelector(n+e+'"]'))(e,r),s=o?((e,n)=>e.querySelector(t+n+'"]'))(o,r):null,u=s?s.parentNode:null;return s&&o&&u?(u.insertBefore(l.content,s),s.remove(),l.remove(),[o,o.previousElementSibling]):null})(i,s,p);if(!g)return;((t,e)=>{var n;const r=u;null==(n=r.qProcessOOOS)||n.call(r,t,e)})(s,g[0]||null);const m=p.getAttribute(r);if(m){const t=+(p.getAttribute(l)||0),e=f(i,m,-1,p.getAttribute(o)||"p");return e.r[t]=g,void q(e)}a(g[0]||null,g[1])};p.g=(t,e,n)=>{const r=f(c(),t,e,n);r.t=e,r.o=n,"r"===r.o&&0===r.n&&(r.n=e-1),q(r)},p.d=u,globalThis.qO=p};u(document)`;
1311
+ var QWIK_OUT_OF_ORDER_EXECUTOR_DEBUG = `const Q_RESOLVED_SELECTOR = 'template[q\\\\:r="';
1312
+ const Q_RESOLVED_ATTR = "q:r";
1313
+ const Q_RESULT_PARENT_SELECTOR = '[q\\\\:rp="';
1314
+ const Q_GROUP_ATTR = "q:g";
1315
+ const Q_INDEX_ATTR = "q:i";
1316
+ const Q_ORDER_ATTR = "q:o";
1317
+ const Q_CONTAINER_SELECTOR = "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])";
1318
+ const installOutOfOrderExecutor = (doc) => {
1319
+ const groups = /* @__PURE__ */ new WeakMap();
1320
+ const process = (boundaryId, content) => {
1321
+ var _a;
1322
+ const executorDoc = doc;
1323
+ (_a = executorDoc.qProcessOOOS) == null ? void 0 : _a.call(executorDoc, boundaryId, content);
1324
+ };
1325
+ const getScope = () => {
1326
+ const script = doc.currentScript;
1327
+ return script ? script.closest(Q_CONTAINER_SELECTOR) || doc : doc;
1328
+ };
1329
+ const group = (scope, groupId, total, order) => {
1330
+ let scopedGroups = groups.get(scope);
1331
+ if (!scopedGroups) {
1332
+ groups.set(scope, scopedGroups = {});
1333
+ }
1334
+ return scopedGroups[groupId] || (scopedGroups[groupId] = {
1335
+ r: {},
1336
+ n: 0,
1337
+ t: total,
1338
+ o: order
1339
+ });
1340
+ };
1341
+ const getResolvedTemplate = (scope, boundaryId) => {
1342
+ const currentScript = doc.currentScript;
1343
+ const previousElement = currentScript ? currentScript.previousElementSibling : null;
1344
+ if (previousElement && previousElement.localName === "template" && previousElement.getAttribute(Q_RESOLVED_ATTR) === String(boundaryId)) {
1345
+ return previousElement;
1346
+ }
1347
+ const templates = scope.querySelectorAll(Q_RESOLVED_SELECTOR + boundaryId + '"]');
1348
+ return templates.length ? templates[templates.length - 1] : null;
1349
+ };
1350
+ const getPlaceholderTemplate = (content, boundaryId) => {
1351
+ return content.querySelector(Q_RESOLVED_SELECTOR + boundaryId + '"]');
1352
+ };
1353
+ const getResultParent = (scope, boundaryId) => {
1354
+ return scope.querySelector(Q_RESULT_PARENT_SELECTOR + boundaryId + '"]');
1355
+ };
1356
+ const reveal = (content, fallback) => {
1357
+ if (!content) {
1358
+ return 0;
1359
+ }
1360
+ if (fallback && fallback.style) {
1361
+ fallback.style.display = "none";
1362
+ }
1363
+ if (content.style) {
1364
+ content.style.display = "contents";
1365
+ }
1366
+ return 1;
1367
+ };
1368
+ const move = (scope, boundaryId, resolved) => {
1369
+ if (!resolved) {
1370
+ return null;
1371
+ }
1372
+ const content = getResultParent(scope, boundaryId);
1373
+ const placeholder = content ? getPlaceholderTemplate(content, boundaryId) : null;
1374
+ const parent = placeholder ? placeholder.parentNode : null;
1375
+ if (!placeholder || !content || !parent) {
1376
+ return null;
1377
+ }
1378
+ parent.insertBefore(resolved.content, placeholder);
1379
+ placeholder.remove();
1380
+ resolved.remove();
1381
+ return [content, content.previousElementSibling];
1382
+ };
1383
+ const flush = (group2) => {
1384
+ const order = group2.o;
1385
+ let entry;
1386
+ let index;
1387
+ let swapped = 0;
1388
+ if (order === "p") {
1389
+ for (const key in group2.r) {
1390
+ entry = group2.r[key];
1391
+ if (entry[0] && reveal(entry[0], entry[1])) {
1392
+ entry[0] = 0;
1393
+ swapped++;
1394
+ }
1395
+ }
1396
+ } else if (order === "s") {
1397
+ for (index = group2.n; (entry = group2.r[index]) && entry[0]; index++) {
1398
+ if (!reveal(entry[0], entry[1])) {
1399
+ break;
1400
+ }
1401
+ entry[0] = 0;
1402
+ swapped++;
1403
+ group2.n = index + 1;
1404
+ }
1405
+ } else if (order === "r") {
1406
+ if (group2.t < 0) {
1407
+ return 0;
1408
+ }
1409
+ if (group2.n < 0) {
1410
+ group2.n = group2.t - 1;
1411
+ }
1412
+ for (index = group2.n; (entry = group2.r[index]) && entry[0]; index--) {
1413
+ if (!reveal(entry[0], entry[1])) {
1414
+ break;
1415
+ }
1416
+ entry[0] = 0;
1417
+ swapped++;
1418
+ group2.n = index - 1;
1419
+ }
1420
+ } else {
1421
+ if (group2.t < 0) {
1422
+ return 0;
1423
+ }
1424
+ for (index = 0; index < group2.t; index++) {
1425
+ entry = group2.r[index];
1426
+ if (!entry) {
1427
+ return 0;
1428
+ }
1429
+ }
1430
+ for (index = 0; index < group2.t; index++) {
1431
+ entry = group2.r[index];
1432
+ if (entry[0] && reveal(entry[0], entry[1])) {
1433
+ entry[0] = 0;
1434
+ swapped++;
1435
+ }
1436
+ }
1437
+ }
1438
+ return swapped;
1439
+ };
1440
+ const qO = ((boundaryId) => {
1441
+ const scope = getScope();
1442
+ const resolved = getResolvedTemplate(scope, boundaryId);
1443
+ if (!resolved) {
1444
+ return;
1445
+ }
1446
+ const entry = move(scope, boundaryId, resolved);
1447
+ if (!entry) {
1448
+ return;
1449
+ }
1450
+ process(boundaryId, entry[0] || null);
1451
+ const groupId = resolved.getAttribute(Q_GROUP_ATTR);
1452
+ if (groupId) {
1453
+ const index = +(resolved.getAttribute(Q_INDEX_ATTR) || 0);
1454
+ const currentGroup = group(scope, groupId, -1, resolved.getAttribute(Q_ORDER_ATTR) || "p");
1455
+ currentGroup.r[index] = entry;
1456
+ flush(currentGroup);
1457
+ return;
1458
+ }
1459
+ reveal(entry[0] || null, entry[1]);
1460
+ });
1461
+ qO.g = (groupId, total, order) => {
1462
+ const currentGroup = group(getScope(), groupId, total, order);
1463
+ currentGroup.t = total;
1464
+ currentGroup.o = order;
1465
+ if (currentGroup.o === "r" && currentGroup.n === 0) {
1466
+ currentGroup.n = total - 1;
1467
+ }
1468
+ flush(currentGroup);
1469
+ };
1470
+ qO.d = doc;
1471
+ globalThis.qO = qO;
1472
+ };
1473
+ installOutOfOrderExecutor(document)`;
1277
1474
  function getQwikLoaderScript(opts = {}) {
1278
1475
  return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
1279
1476
  }
@@ -1285,6 +1482,13 @@ function getQwikPrefetchWorkerScript(opts = {}) {
1285
1482
  function getQwikBackpatchExecutorScript(opts = {}) {
1286
1483
  return opts.debug ? QWIK_BACKPATCH_EXECUTOR_DEBUG : QWIK_BACKPATCH_EXECUTOR_MINIFIED;
1287
1484
  }
1485
+ function getQwikOutOfOrderExecutorScript(opts = {}) {
1486
+ if (!__EXPERIMENTAL__.suspense) {
1487
+ return "";
1488
+ }
1489
+ const script = opts.debug ? QWIK_OUT_OF_ORDER_EXECUTOR_DEBUG : QWIK_OUT_OF_ORDER_EXECUTOR_MINIFIED;
1490
+ return `if(!globalThis.qO||globalThis.qO.d!==document){${script}}`;
1491
+ }
1288
1492
 
1289
1493
  // packages/qwik/src/server/ssr-node.ts
1290
1494
  import {
@@ -1292,7 +1496,7 @@ import {
1292
1496
  _EMPTY_OBJ,
1293
1497
  _EFFECT_BACK_REF
1294
1498
  } from "@qwik.dev/core/internal";
1295
- import { isDev as isDev6 } from "@qwik.dev/core/build";
1499
+ import { isDev as isDev7 } from "@qwik.dev/core/build";
1296
1500
  var SsrNode = class {
1297
1501
  constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
1298
1502
  this.parentComponent = parentComponent;
@@ -1304,7 +1508,7 @@ var SsrNode = class {
1304
1508
  this.flags = 1 /* Updatable */;
1305
1509
  this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_OBJ;
1306
1510
  this.parentComponent?.addChild(this);
1307
- if (isDev6 && id.indexOf("undefined") != -1) {
1511
+ if (isDev7 && id.indexOf("undefined") != -1) {
1308
1512
  throw new Error(`Invalid SSR node id: ${id}`);
1309
1513
  }
1310
1514
  }
@@ -1382,7 +1586,7 @@ var SsrNode = class {
1382
1586
  }
1383
1587
  }
1384
1588
  toString() {
1385
- if (isDev6) {
1589
+ if (isDev7) {
1386
1590
  let stringifiedAttrs = "";
1387
1591
  for (const key in this.attrs) {
1388
1592
  const value = this.attrs[key];
@@ -1457,14 +1661,80 @@ var SsrComponentFrame = class {
1457
1661
  hasSlot(slotName) {
1458
1662
  return mapArray_has(this.slots, slotName, 0);
1459
1663
  }
1664
+ claimChildrenForSlot(slotName) {
1665
+ return mapApp_remove(this.slots, slotName, 0);
1666
+ }
1460
1667
  consumeChildrenForSlot(projectionNode, slotName) {
1461
- const children = mapApp_remove(this.slots, slotName, 0);
1668
+ const children = this.claimChildrenForSlot(slotName);
1462
1669
  this.componentNode.setProp(slotName, projectionNode.id);
1463
1670
  projectionNode.setProp(QSlotParent, this.componentNode.id);
1464
1671
  return children;
1465
1672
  }
1466
1673
  };
1467
1674
 
1675
+ // packages/qwik/src/server/ssr-stream-writer.ts
1676
+ var renderSSRChunks = (chunks, remap) => {
1677
+ let out = "";
1678
+ for (let i = 0; i < chunks.length; i++) {
1679
+ const chunk = chunks[i];
1680
+ if (typeof chunk === "string") {
1681
+ out += chunk;
1682
+ } else {
1683
+ const localId = chunk.type === "root-ref" ? chunk.localId : chunk.localPath[0];
1684
+ out += String(remap ? remap[localId] ?? localId : localId);
1685
+ if (chunk.type !== "root-ref-path") {
1686
+ continue;
1687
+ }
1688
+ const path = chunk.localPath;
1689
+ for (let j = 1; j < path.length; j++) {
1690
+ out += " " + path[j];
1691
+ }
1692
+ }
1693
+ }
1694
+ return out;
1695
+ };
1696
+ var StringSSRWriter = class {
1697
+ buffer = [];
1698
+ write(text) {
1699
+ this.buffer.push(text);
1700
+ }
1701
+ writeRootRef(id) {
1702
+ writeStringRootRef(this, id);
1703
+ }
1704
+ writeRootRefPath(path) {
1705
+ writeStringRootRefPath(this, path);
1706
+ }
1707
+ clear() {
1708
+ this.buffer.length = 0;
1709
+ }
1710
+ toString(_) {
1711
+ return this.buffer.join("");
1712
+ }
1713
+ };
1714
+ var StringBufferSegmentWriter = class {
1715
+ chunks = [];
1716
+ write(text) {
1717
+ this.chunks.push(text);
1718
+ }
1719
+ writeRootRef(id) {
1720
+ this.chunks.push({ type: "root-ref", localId: id });
1721
+ }
1722
+ writeRootRefPath(path) {
1723
+ this.chunks.push({ type: "root-ref-path", localPath: path });
1724
+ }
1725
+ clear() {
1726
+ this.chunks.length = 0;
1727
+ }
1728
+ extract() {
1729
+ const chunks = this.chunks;
1730
+ this.chunks = [];
1731
+ return chunks;
1732
+ }
1733
+ toString(remap) {
1734
+ return renderSSRChunks(this.chunks, remap);
1735
+ }
1736
+ };
1737
+
1468
1738
  // packages/qwik/src/server/tag-nesting.ts
1469
1739
  var allowedContent = (state) => {
1470
1740
  switch (state) {
@@ -1781,6 +2051,36 @@ function isInPhrasing(text, allowInput) {
1781
2051
  }
1782
2052
  }
1783
2053
 
2054
+ // packages/qwik/src/server/utils.ts
2055
+ function createTimer() {
2056
+ if (typeof performance === "undefined") {
2057
+ return () => 0;
2058
+ }
2059
+ const start = performance.now();
2060
+ return () => {
2061
+ const end = performance.now();
2062
+ const delta = end - start;
2063
+ return delta / 1e6;
2064
+ };
2065
+ }
2066
+ function getBuildBase(opts) {
2067
+ let base2 = opts.base;
2068
+ if (typeof opts.base === "function") {
2069
+ base2 = opts.base(opts);
2070
+ }
2071
+ if (typeof base2 === "string") {
2072
+ if (!base2.endsWith("/")) {
2073
+ base2 += "/";
2074
+ }
2075
+ return base2;
2076
+ }
2077
+ return `${import.meta.env?.BASE_URL || "/"}build/`;
2078
+ }
2079
+ var versions = {
2080
+ qwik: "2.0.0-beta.36-dev+3268fab",
2081
+ qwikDom: "2.1.19"
2082
+ };
2083
+
1784
2084
  // packages/qwik/src/server/vnode-data.ts
1785
2085
  var OPEN_FRAGMENT = Number.MAX_SAFE_INTEGER;
1786
2086
  var CLOSE_FRAGMENT = Number.MAX_SAFE_INTEGER - 1;
@@ -1838,7 +2138,7 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
1838
2138
  stack[stack.length - 1]++;
1839
2139
  }
1840
2140
  }
1841
- let refId = depthFirstElementIdx + "";
2141
+ let refId = String(depthFirstElementIdx);
1842
2142
  if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
1843
2143
  for (let i = 0; i < stack.length; i++) {
1844
2144
  const childCount = stack[i];
@@ -1877,11 +2177,24 @@ function encodeAsAlphanumeric(value) {
1877
2177
  }
1878
2178
 
1879
2179
  // packages/qwik/src/server/ssr-container.ts
2180
+ var NO_SCRIPT_HERE_ELEMENTS = /* @__PURE__ */ new Set([
2181
+ "script",
2182
+ "style",
2183
+ "textarea",
2184
+ "title",
2185
+ "iframe",
2186
+ "noframes",
2187
+ "noscript",
2188
+ "xmp",
2189
+ "template",
2190
+ "svg",
2191
+ "math"
2192
+ ]);
1880
2193
  function ssrCreateContainer(opts) {
1881
2194
  opts.renderOptions ||= {};
1882
2195
  return new SSRContainer({
1883
2196
  tagName: opts.tagName || "div",
1884
- writer: opts.writer || new StringBufferWriter(),
2197
+ writer: opts.writer || new StringSSRWriter(),
1885
2198
  streamHandler: opts.streamHandler,
1886
2199
  locale: opts.locale || "",
1887
2200
  timing: opts.timing || {
@@ -1900,16 +2213,16 @@ function ssrCreateContainer(opts) {
1900
2213
  renderOptions: opts.renderOptions
1901
2214
  });
1902
2215
  }
1903
- var StringBufferWriter = class {
1904
- buffer = [];
1905
- write(text) {
1906
- this.buffer.push(text);
1907
- }
1908
- toString() {
1909
- return this.buffer.join("");
2216
+ var noopStreamHandler = {
2217
+ flush() {
2218
+ },
2219
+ waitForPendingFlush() {
2220
+ },
2221
+ streamBlockStart() {
2222
+ },
2223
+ streamBlockEnd() {
1910
2224
  }
1911
2225
  };
1912
- var EMPTY_OBJ = {};
1913
2226
  var QTemplateProps = {
1914
2227
  hidden: true,
1915
2228
  "aria-hidden": true
@@ -1924,7 +2237,12 @@ var SSRContainer = class extends _SharedContainer {
1924
2237
  resolvedManifest;
1925
2238
  symbolToChunkResolver;
1926
2239
  renderOptions;
2240
+ outOfOrderStreaming;
1927
2241
  serializationCtx;
2242
+ // Sometimes there is no app state, but framework metadata still points to a vnode id.
2243
+ // For example, an OOOS segment can point outside the segment to a root vnode through
2244
+ // q:sparent, so root vnode data must still be emitted for the client ref table.
2245
+ hasVNodeRefsForSerialization = false;
1928
2246
  /**
1929
2247
  * We use this to append additional nodes in the head node
1930
2248
  *
@@ -1942,6 +2260,7 @@ var SSRContainer = class extends _SharedContainer {
1942
2260
  currentComponentNode = null;
1943
2261
  styleIds = /* @__PURE__ */ new Set();
1944
2262
  isBackpatchExecutorEmitted = false;
2263
+ isOutOfOrderExecutorEmitted = false;
1945
2264
  backpatchMap = /* @__PURE__ */ new Map();
1946
2265
  currentElementFrame = null;
1947
2266
  renderTimer;
@@ -1953,6 +2272,7 @@ var SSRContainer = class extends _SharedContainer {
1953
2272
  */
1954
2273
  depthFirstElementCount = -1;
1955
2274
  vNodeDatas = [];
2275
+ vNodeDataOffset = 0;
1956
2276
  componentStack = [];
1957
2277
  cleanupQueue = [];
1958
2278
  emitContainerDataFrame = null;
@@ -1961,8 +2281,22 @@ var SSRContainer = class extends _SharedContainer {
1961
2281
  $noMoreRoots$ = false;
1962
2282
  qlInclude;
1963
2283
  promiseAttributes = null;
2284
+ vnodeSegment = null;
2285
+ $containerState$ = 0 /* NotReady */;
2286
+ // OOOS related fields
2287
+ outOfOrderId = 0;
2288
+ outOfOrderUsed = false;
2289
+ outOfOrderPendingSegments = [];
2290
+ outOfOrderSegments = [];
2291
+ rootContainerReadyPromise = null;
2292
+ resolveRootContainerReady = null;
2293
+ renderQueue = Promise.resolve();
2294
+ emittedQwikEventNames = /* @__PURE__ */ new Set();
2295
+ emittedSyncFnCount = 0;
2296
+ rootContainerSerializedRootCount = 0;
2297
+ emittedVNodeDataOwners = null;
1964
2298
  constructor(opts) {
1965
- super(opts.renderOptions.serverData ?? EMPTY_OBJ, opts.locale);
2299
+ super(opts.renderOptions.serverData ?? {}, opts.locale);
1966
2300
  this.symbolToChunkResolver = (symbol) => {
1967
2301
  const idx = symbol.lastIndexOf("_");
1968
2302
  const chunk = this.resolvedManifest.mapper[idx == -1 ? symbol : symbol.substring(idx + 1)];
@@ -1983,6 +2317,17 @@ var SSRContainer = class extends _SharedContainer {
1983
2317
  this.$buildBase$ = opts.buildBase;
1984
2318
  this.resolvedManifest = opts.resolvedManifest;
1985
2319
  this.renderOptions = opts.renderOptions;
2320
+ const outOfOrderStreaming = this.renderOptions.streaming?.outOfOrder === true;
2321
+ if (!__EXPERIMENTAL__.suspense) {
2322
+ if (outOfOrderStreaming) {
2323
+ throw new Error(
2324
+ 'Out-of-order Suspense streaming requires `experimental: ["suspense"]` in the `qwikVite` plugin.'
2325
+ );
2326
+ }
2327
+ this.outOfOrderStreaming = false;
2328
+ } else {
2329
+ this.outOfOrderStreaming = outOfOrderStreaming;
2330
+ }
1986
2331
  this.$currentUniqueId$ = 1e5;
1987
2332
  const qlOpt = this.renderOptions.qwikLoader;
1988
2333
  this.qlInclude = qlOpt ? typeof qlOpt === "object" ? qlOpt.include === "never" ? 2 /* Done */ : 0 /* Module */ : qlOpt === "inline" ? 1 /* Inline */ : qlOpt === "never" ? 2 /* Done */ : 0 /* Module */ : 0 /* Module */;
@@ -2020,6 +2365,157 @@ var SSRContainer = class extends _SharedContainer {
2020
2365
  async renderJSX(jsx, options) {
2021
2366
  await _walkJSX(this, jsx, options);
2022
2367
  }
2368
+ $isReadyForOOOS$() {
2369
+ return this.$containerState$ === 2 /* OOOSReady */;
2370
+ }
2371
+ /** Queue OOOS serialization/write work that must not overlap with root state serialization. */
2372
+ $runQueuedRender$(render) {
2373
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming) {
2374
+ return render();
2375
+ }
2376
+ if (this.$containerState$ === 0 /* NotReady */) {
2377
+ return render();
2378
+ }
2379
+ const result = this.$containerState$ === 1 /* DataStreamStarted */ ? this.renderQueue.then(() => this.$waitForRootContainerReady$()).then(render) : this.renderQueue.then(render);
2380
+ this.renderQueue = result.catch(() => {
2381
+ });
2382
+ return result;
2383
+ }
2384
+ $waitForRootContainerReady$() {
2385
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming || this.$isReadyForOOOS$()) {
2386
+ return;
2387
+ }
2388
+ return this.rootContainerReadyPromise ||= new Promise((resolve) => {
2389
+ this.resolveRootContainerReady = resolve;
2390
+ });
2391
+ }
2392
+ $markRootContainerReady$() {
2393
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming || this.$isReadyForOOOS$()) {
2394
+ return;
2395
+ }
2396
+ this.rootContainerSerializedRootCount = this.serializationCtx.$roots$.length;
2397
+ this.$containerState$ = 2 /* OOOSReady */;
2398
+ this.resolveRootContainerReady?.();
2399
+ this.resolveRootContainerReady = null;
2400
+ this.rootContainerReadyPromise = null;
2401
+ }
2402
+ nextOutOfOrderId() {
2403
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming) {
2404
+ return 0;
2405
+ }
2406
+ this.outOfOrderUsed = true;
2407
+ return ++this.outOfOrderId;
2408
+ }
2409
+ emitOutOfOrderSegmentScripts(scripts) {
2410
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming || !scripts) {
2411
+ return;
2412
+ }
2413
+ this.write(scripts);
2414
+ }
2415
+ async segment(segmentId, jsx, options) {
2416
+ if (!__EXPERIMENTAL__.suspense) {
2417
+ throw new Error(
2418
+ 'Out-of-order Suspense streaming requires `experimental: ["suspense"]` in the `qwikVite` plugin.'
2419
+ );
2420
+ }
2421
+ if (!this.outOfOrderStreaming) {
2422
+ throw new Error(
2423
+ "Out-of-order Suspense streaming requires `streaming.outOfOrder` to be `true`."
2424
+ );
2425
+ }
2426
+ this.markVNodeRefForSerialization(options.parentComponentFrame?.componentNode);
2427
+ const writer = new StringBufferSegmentWriter();
2428
+ const segmentContainer = this.createSegmentContainer(segmentId, writer);
2429
+ this.outOfOrderSegments.push(segmentContainer);
2430
+ try {
2431
+ await segmentContainer.renderJSX(jsx, options);
2432
+ await segmentContainer.resolvePromiseAttributes();
2433
+ const htmlChunks = writer.extract();
2434
+ return {
2435
+ container: segmentContainer,
2436
+ writer,
2437
+ htmlChunks
2438
+ };
2439
+ } catch (error) {
2440
+ this.removeOutOfOrderSegment(segmentContainer);
2441
+ throw error;
2442
+ }
2443
+ }
2444
+ $getRootContainer$() {
2445
+ let rootContainer = this;
2446
+ while (rootContainer instanceof SSRSegmentContainer) {
2447
+ rootContainer = rootContainer.$rootContainer$;
2448
+ }
2449
+ return rootContainer;
2450
+ }
2451
+ createSegmentContainer(segmentId, writer) {
2452
+ const rootContainer = this.$getRootContainer$();
2453
+ const contentHostNode = this.getOrCreateLastNode();
2454
+ this.addRoot(contentHostNode);
2455
+ this.markVNodeRefForSerialization(contentHostNode);
2456
+ const rootFrame = {
2457
+ tagNesting: 10 /* ANYTHING */,
2458
+ parent: null,
2459
+ elementName: "#segment",
2460
+ depthFirstElementIdx: -1,
2461
+ // OOOS inserts this synthetic root under the Suspense content host on the client.
2462
+ vNodeData: [16 /* SERIALIZE */],
2463
+ currentFile: null,
2464
+ refBase: contentHostNode.id
2465
+ };
2466
+ const segmentContainer = new SSRSegmentContainer(
2467
+ {
2468
+ tagName: this.tag,
2469
+ writer,
2470
+ streamHandler: noopStreamHandler,
2471
+ locale: this.$locale$,
2472
+ timing: this.timing,
2473
+ buildBase: this.$buildBase$ || "/build/",
2474
+ resolvedManifest: this.resolvedManifest,
2475
+ renderOptions: this.renderOptions
2476
+ },
2477
+ rootContainer
2478
+ );
2479
+ const innerSegmentContainer = segmentContainer;
2480
+ innerSegmentContainer.$isOutOfOrderSegment$ = true;
2481
+ innerSegmentContainer.$storeProxyMap$ = this.$storeProxyMap$;
2482
+ segmentContainer.serializationCtx = segmentContainer.serializationCtxFactory(
2483
+ SsrNode,
2484
+ DomRef,
2485
+ this.symbolToChunkResolver,
2486
+ writer
2487
+ );
2488
+ segmentContainer.serializationCtx.$addSyncFn$ = this.serializationCtx.$addSyncFn$.bind(
2489
+ this.serializationCtx
2490
+ );
2491
+ segmentContainer.currentElementFrame = rootFrame;
2492
+ segmentContainer.currentComponentNode = this.currentComponentNode;
2493
+ segmentContainer.depthFirstElementCount = 0;
2494
+ segmentContainer.vNodeDatas = [rootFrame.vNodeData];
2495
+ segmentContainer.componentStack = this.componentStack.slice();
2496
+ segmentContainer.vnodeSegment = segmentId;
2497
+ segmentContainer.styleIds = this.styleIds;
2498
+ segmentContainer.emittedQwikEventNames = this.emittedQwikEventNames;
2499
+ segmentContainer.qlInclude = 2 /* Done */;
2500
+ segmentContainer.$instanceHash$ = this.$instanceHash$;
2501
+ innerSegmentContainer._didAddQwikLoader = true;
2502
+ return segmentContainer;
2503
+ }
2504
+ queueOutOfOrderSegment(segment) {
2505
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming) {
2506
+ return;
2507
+ }
2508
+ this.outOfOrderPendingSegments.push(segment);
2509
+ }
2510
+ removeOutOfOrderSegment(segment) {
2511
+ const segments = this.outOfOrderSegments;
2512
+ for (let i = 0; i < segments.length; i++) {
2513
+ if (segments[i] === segment) {
2514
+ segments.splice(i, 1);
2515
+ return;
2516
+ }
2517
+ }
2518
+ }
2023
2519
  setContext(host, context, value) {
2024
2520
  const ssrNode = host;
2025
2521
  let ctx = ssrNode.getProp(QCtxAttr);
@@ -2065,7 +2561,7 @@ var SSRContainer = class extends _SharedContainer {
2065
2561
  containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
2066
2562
  containerAttributes[QRuntimeAttr] = "2";
2067
2563
  containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
2068
- containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev7 ? "ssr-dev" : "ssr");
2564
+ containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev8 ? "ssr-dev" : "ssr");
2069
2565
  containerAttributes[QBaseAttr] = this.$buildBase$ || "";
2070
2566
  containerAttributes[QLocaleAttr] = this.$locale$;
2071
2567
  containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
@@ -2084,7 +2580,7 @@ var SSRContainer = class extends _SharedContainer {
2084
2580
  /** Renders opening tag for DOM element */
2085
2581
  openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null, hasMovedCaptures = true) {
2086
2582
  const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
2087
- if (elementName === "noscript" || elementName === "template" || elementName === "script") {
2583
+ if (NO_SCRIPT_HERE_ELEMENTS.has(elementName)) {
2088
2584
  this.$noScriptHere$++;
2089
2585
  }
2090
2586
  if (
@@ -2122,7 +2618,7 @@ var SSRContainer = class extends _SharedContainer {
2122
2618
  this.write(" " + Q_PROPS_SEPARATOR);
2123
2619
  if (key !== null) {
2124
2620
  this.write(`="${key}"`);
2125
- } else if (import.meta.env.TEST) {
2621
+ } else if (qTest) {
2126
2622
  this.write(EMPTY_ATTR);
2127
2623
  }
2128
2624
  if (constAttrs && !isObjectEmpty(constAttrs)) {
@@ -2182,7 +2678,7 @@ var SSRContainer = class extends _SharedContainer {
2182
2678
  this.write(GT);
2183
2679
  }
2184
2680
  this.lastNode = null;
2185
- if (elementName === "noscript" || elementName === "template" || elementName === "script") {
2681
+ if (NO_SCRIPT_HERE_ELEMENTS.has(elementName)) {
2186
2682
  this.$noScriptHere$--;
2187
2683
  }
2188
2684
  }
@@ -2204,7 +2700,13 @@ var SSRContainer = class extends _SharedContainer {
2204
2700
  this.openFragment(attrs);
2205
2701
  const componentFrame = this.getComponentFrame();
2206
2702
  if (componentFrame) {
2207
- this.serializationCtx.$addRoot$(componentFrame.componentNode);
2703
+ const projectionNode = this.getOrCreateLastNode();
2704
+ this.markVNodeRefForSerialization(projectionNode);
2705
+ if (!this.vnodeSegment) {
2706
+ this.addRoot(componentFrame.componentNode);
2707
+ } else {
2708
+ this.markVNodeRefForSerialization(componentFrame.componentNode);
2709
+ }
2208
2710
  componentFrame.projectionDepth++;
2209
2711
  }
2210
2712
  }
@@ -2253,13 +2755,18 @@ var SSRContainer = class extends _SharedContainer {
2253
2755
  for (let i = 0; i < componentFrame.slots.length; i += 2) {
2254
2756
  const slotName = componentFrame.slots[i];
2255
2757
  const children = componentFrame.slots[i + 1];
2758
+ if (this.vnodeSegment) {
2759
+ this.markVNodeRefForSerialization(componentFrame.componentNode);
2760
+ }
2256
2761
  this.openFragment(
2257
- isDev7 ? { [DEBUG_TYPE]: "P" /* Projection */, [QSlotParent]: componentFrame.componentNode.id } : { [QSlotParent]: componentFrame.componentNode.id }
2762
+ isDev8 ? {
2763
+ [DEBUG_TYPE]: "P" /* Projection */,
2764
+ [QSlotParent]: componentFrame.componentNode.id,
2765
+ [QSlot]: slotName
2766
+ } : { [QSlotParent]: componentFrame.componentNode.id, [QSlot]: slotName }
2258
2767
  );
2259
2768
  const lastNode = this.getOrCreateLastNode();
2260
- if (lastNode.vnodeData) {
2261
- lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
2262
- }
2769
+ lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
2263
2770
  componentFrame.componentNode.setProp(slotName, lastNode.id);
2264
2771
  await this.renderJSX(children, {
2265
2772
  currentStyleScoped: scopedStyleId,
@@ -2283,19 +2790,22 @@ var SSRContainer = class extends _SharedContainer {
2283
2790
  }
2284
2791
  addRoot(obj) {
2285
2792
  if (this.$noMoreRoots$) {
2286
- return this.serializationCtx.$hasRootId$(obj);
2793
+ const rootId = this.serializationCtx.$hasRootId$(obj);
2794
+ return rootId;
2287
2795
  }
2288
2796
  return this.serializationCtx.$addRoot$(obj);
2289
2797
  }
2290
2798
  getOrCreateLastNode() {
2291
2799
  if (!this.lastNode) {
2800
+ const currentFrame = this.currentElementFrame;
2801
+ const elementIndex = currentFrame.depthFirstElementIdx + 1;
2802
+ const refBase = currentFrame.refBase ?? (this.vnodeSegment ? getSegmentVNodeRefId(this.vnodeSegment, elementIndex) : elementIndex + this.vNodeDataOffset);
2292
2803
  this.lastNode = vNodeData_createSsrNodeReference(
2293
2804
  this.currentComponentNode,
2294
- this.currentElementFrame.vNodeData,
2295
- // we start at -1, so we need to add +1
2296
- this.currentElementFrame.depthFirstElementIdx + 1,
2805
+ currentFrame.vNodeData,
2806
+ refBase,
2297
2807
  this.cleanupQueue,
2298
- this.currentElementFrame.currentFile
2808
+ currentFrame.currentFile
2299
2809
  );
2300
2810
  }
2301
2811
  return this.lastNode;
@@ -2350,21 +2860,67 @@ var SSRContainer = class extends _SharedContainer {
2350
2860
  this.write(content);
2351
2861
  this.closeElement();
2352
2862
  }
2863
+ $deferRootPlaceholder$(scriptNode) {
2864
+ if (this.isHtml && this.currentElementFrame?.elementName === "html") {
2865
+ this.additionalHeadNodes.push(scriptNode);
2866
+ return true;
2867
+ }
2868
+ return false;
2869
+ }
2353
2870
  ////////////////////////////////////
2354
2871
  emitContainerData() {
2872
+ const isStreamingDisabled = this.renderOptions.streaming?.inOrder?.strategy === "disabled";
2873
+ const shouldFlushShell = !isStreamingDisabled || __EXPERIMENTAL__.suspense && this.outOfOrderStreaming && this.outOfOrderUsed;
2355
2874
  return maybeThen(
2356
- this.resolvePromiseAttributes(),
2357
- () => maybeThen(this.emitStateData(), () => {
2358
- this.$noMoreRoots$ = true;
2359
- this.emitVNodeData();
2360
- preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
2361
- this.emitSyncFnsData();
2362
- this.emitPatchDataIfNeeded();
2363
- this.emitExecutorIfNeeded();
2364
- this.emitQwikLoaderAtBottomIfNeeded();
2365
- })
2875
+ maybeThen(
2876
+ shouldFlushShell ? this.streamHandler.flush() : void 0,
2877
+ () => this.resolvePromiseAttributes()
2878
+ ),
2879
+ () => {
2880
+ this.$containerState$ = 1 /* DataStreamStarted */;
2881
+ return maybeThen(this.emitStateData(), () => {
2882
+ this.$noMoreRoots$ = true;
2883
+ return maybeThen(this.emitRestStateData(), () => this.emitOutOfOrderSegmentsAndData());
2884
+ });
2885
+ }
2366
2886
  );
2367
2887
  }
2888
+ emitRestStateData() {
2889
+ this.emitVNodeData();
2890
+ this.emitDelayedOutOfOrderSegmentVNodeData();
2891
+ if (!isDev8) {
2892
+ preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
2893
+ }
2894
+ this.emitSyncFnsData();
2895
+ this.emitPatchDataIfNeeded();
2896
+ this.emitExecutorIfNeeded();
2897
+ this.emitQwikLoaderAtBottomIfNeeded();
2898
+ this.emitContainerReadyEventIfNeeded();
2899
+ }
2900
+ emitDelayedOutOfOrderSegmentVNodeData() {
2901
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming || !this.outOfOrderUsed) {
2902
+ return;
2903
+ }
2904
+ for (let i = 0; i < this.outOfOrderSegments.length; i++) {
2905
+ const segment = this.outOfOrderSegments[i];
2906
+ if (segment.$outOfOrderState$ === 1 /* EarlyFinalized */) {
2907
+ segment.$emitDelayedOutOfOrderVNodeData$();
2908
+ i--;
2909
+ }
2910
+ }
2911
+ }
2912
+ emitOutOfOrderSegmentsAndData() {
2913
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming || !this.outOfOrderUsed) {
2914
+ return;
2915
+ }
2916
+ this.emitOutOfOrderExecutorIfNeeded();
2917
+ return maybeThen(this.streamHandler.flush(), async () => {
2918
+ this.$markRootContainerReady$();
2919
+ if (this.outOfOrderPendingSegments.length) {
2920
+ await Promise.all(this.outOfOrderPendingSegments);
2921
+ }
2922
+ });
2923
+ }
2368
2924
  /**
2369
2925
  * Serialize the vNodeData into a string and emit it as a script tag.
2370
2926
  *
@@ -2383,16 +2939,25 @@ var SSRContainer = class extends _SharedContainer {
2383
2939
  * NOTE: Not every element will need vNodeData. So we need to encode how many elements should be
2384
2940
  * skipped. By choosing different separators we can encode different numbers of elements to skip.
2385
2941
  */
2386
- emitVNodeData() {
2387
- if (!this.serializationCtx.$roots$.length) {
2942
+ emitVNodeData(segmentId) {
2943
+ this.$getRootContainer$().markVNodeDataOwnerEmitted(segmentId);
2944
+ if (!segmentId && !this.serializationCtx.$roots$.length && !this.hasVNodeRefsForSerialization) {
2388
2945
  return;
2389
2946
  }
2390
- this.openElement("script", null, { type: "qwik/vnode" });
2947
+ this.emitVNodeDataScript(segmentId, this.vNodeDatas.entries());
2948
+ }
2949
+ emitVNodeDataScript(segmentId, entries, patch = false) {
2950
+ const attrs = { type: "qwik/vnode" };
2951
+ if (__EXPERIMENTAL__.suspense && this.outOfOrderStreaming && segmentId) {
2952
+ attrs[QSuspenseResolved] = segmentId;
2953
+ }
2954
+ if (patch) {
2955
+ attrs[QStatePatchAttr] = true;
2956
+ }
2957
+ this.openScript(attrs);
2391
2958
  const vNodeAttrsStack = [];
2392
- const vNodeData = this.vNodeDatas;
2393
2959
  let lastSerializedIdx = 0;
2394
- for (let elementIdx = 0; elementIdx < vNodeData.length; elementIdx++) {
2395
- const vNode = vNodeData[elementIdx];
2960
+ for (const [elementIdx, vNode] of entries) {
2396
2961
  const flag = vNode[0];
2397
2962
  if (flag & 16 /* SERIALIZE */) {
2398
2963
  lastSerializedIdx = this.emitVNodeSeparators(lastSerializedIdx, elementIdx);
@@ -2442,14 +3007,51 @@ var SSRContainer = class extends _SharedContainer {
2442
3007
  }
2443
3008
  }
2444
3009
  }
2445
- this.closeElement();
3010
+ this.closeScript();
3011
+ if (patch && !segmentId) {
3012
+ this.emitInlineScript(
3013
+ "document.qProcessVNodeDataPatch&&document.qProcessVNodeDataPatch(document.currentScript.previousElementSibling)"
3014
+ );
3015
+ }
3016
+ }
3017
+ markVNodeRefForSerialization(node) {
3018
+ if (node) {
3019
+ this.hasVNodeRefsForSerialization = true;
3020
+ node.vnodeData[0] |= 16 /* SERIALIZE */ | 8 /* REFERENCE */;
3021
+ }
3022
+ }
3023
+ markVNodeDataOwnerEmitted(segmentId) {
3024
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming) {
3025
+ return;
3026
+ }
3027
+ (this.emittedVNodeDataOwners ||= /* @__PURE__ */ new Set()).add(segmentId);
3028
+ }
3029
+ isVNodeDataOwnerEmitted(owner) {
3030
+ return this.emittedVNodeDataOwners?.has(owner) === true;
3031
+ }
3032
+ getVNodeDataOwnerFromNodeId(id) {
3033
+ const refBase = parseInt(id, 10);
3034
+ if (refBase >= 0) {
3035
+ return { owner: void 0, localIndex: refBase };
3036
+ }
3037
+ const pair = -refBase - 1;
3038
+ const diagonal = Math.floor((Math.sqrt(8 * pair + 1) - 1) / 2);
3039
+ const diagonalStart = diagonal * (diagonal + 1) / 2;
3040
+ const localIndex = pair - diagonalStart;
3041
+ const segmentIndex = diagonal - localIndex;
3042
+ return { owner: String(segmentIndex + 1), localIndex };
2446
3043
  }
2447
3044
  writeFragmentAttrs(fragmentAttrs) {
2448
3045
  for (const key in fragmentAttrs) {
2449
- let value = fragmentAttrs[key];
2450
- let encodeValue = false;
2451
- if (typeof value !== "string") {
2452
- const rootId = this.addRoot(value);
3046
+ const rawValue = fragmentAttrs[key];
3047
+ let value = rawValue;
3048
+ let rootId;
3049
+ let encodeValue = null;
3050
+ if (key === ELEMENT_ID && typeof rawValue === "number") {
3051
+ rootId = rawValue;
3052
+ value = String(rawValue);
3053
+ } else if (typeof rawValue !== "string") {
3054
+ rootId = this.addRoot(rawValue);
2453
3055
  if (rootId === void 0) {
2454
3056
  continue;
2455
3057
  }
@@ -2469,7 +3071,7 @@ var SSRContainer = class extends _SharedContainer {
2469
3071
  this.write(VNodeDataChar.PROPS_CHAR);
2470
3072
  break;
2471
3073
  case ELEMENT_KEY:
2472
- encodeValue = true;
3074
+ encodeValue = encodeVNodeDataKey;
2473
3075
  this.write(VNodeDataChar.KEY_CHAR);
2474
3076
  break;
2475
3077
  case ELEMENT_SEQ:
@@ -2492,18 +3094,20 @@ var SSRContainer = class extends _SharedContainer {
2492
3094
  this.write(VNodeDataChar.SLOT_CHAR);
2493
3095
  break;
2494
3096
  default: {
2495
- encodeValue = true;
3097
+ encodeValue = encodeURI;
2496
3098
  this.write(VNodeDataChar.SEPARATOR_CHAR);
2497
3099
  this.write(encodeVNodeDataString(key));
2498
3100
  this.write(VNodeDataChar.SEPARATOR_CHAR);
2499
3101
  }
2500
3102
  }
2501
- const encodedValue = encodeVNodeDataString(encodeValue ? encodeURI(value) : value);
3103
+ const encodedValue = encodeVNodeDataString(encodeValue ? encodeValue(value) : value);
2502
3104
  const isEncoded = encodeValue ? encodedValue !== value : false;
2503
3105
  if (isEncoded) {
2504
3106
  this.write(VNodeDataChar.SEPARATOR_CHAR);
2505
3107
  this.write(encodedValue);
2506
3108
  this.write(VNodeDataChar.SEPARATOR_CHAR);
3109
+ } else if (typeof rootId === "number") {
3110
+ this.writeRootRef(rootId);
2507
3111
  } else {
2508
3112
  this.write(value);
2509
3113
  }
@@ -2514,33 +3118,48 @@ var SSRContainer = class extends _SharedContainer {
2514
3118
  return;
2515
3119
  }
2516
3120
  const attrs = this.stateScriptAttrs();
2517
- this.openElement("script", null, attrs);
3121
+ this.openScript(attrs);
3122
+ this.serializationCtx.$setWriter$(this.writer);
2518
3123
  return maybeThen(this.serializationCtx.$serialize$(), () => {
2519
- this.closeElement();
3124
+ this.closeScript();
2520
3125
  });
2521
3126
  }
2522
3127
  /** Add q-d:qidle attribute to eagerly resume some state if needed */
2523
3128
  stateScriptAttrs() {
2524
- const attrs = { type: "qwik/state" };
3129
+ const attrs = { type: "qwik/state", [QInstanceAttr]: this.$instanceHash$ };
2525
3130
  const eagerResume = this.serializationCtx.$eagerResume$;
2526
3131
  if (eagerResume.size > 0) {
2527
3132
  attrs["q-d:qidle"] = createQRL(null, "_res", _res, null, [...eagerResume]);
2528
3133
  }
2529
3134
  return attrs;
2530
3135
  }
2531
- emitSyncFnsData() {
3136
+ emitSyncFnsData(append = false) {
2532
3137
  const fns = this.serializationCtx.$syncFns$;
2533
- if (fns.length) {
3138
+ const start = append ? this.emittedSyncFnCount : 0;
3139
+ if (fns.length > start) {
2534
3140
  const scriptAttrs = { "q:func": "qwik/json" };
2535
3141
  if (this.renderOptions.serverData?.nonce) {
2536
3142
  scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
2537
3143
  }
2538
- this.openElement("script", null, scriptAttrs);
2539
- this.write(Q_FUNCS_PREFIX.replace("HASH", this.$instanceHash$));
2540
- this.write(BRACKET_OPEN);
2541
- this.writeArray(fns, COMMA);
2542
- this.write(BRACKET_CLOSE);
2543
- this.closeElement();
3144
+ this.openScript(scriptAttrs);
3145
+ if (append) {
3146
+ const qFuncsExpr = Q_FUNCS_PREFIX.replace("HASH", this.$instanceHash$).slice(0, -1);
3147
+ this.write(`(${qFuncsExpr}||(${qFuncsExpr}=[])).push(`);
3148
+ } else {
3149
+ this.write(Q_FUNCS_PREFIX.replace("HASH", this.$instanceHash$));
3150
+ }
3151
+ if (!append) {
3152
+ this.write(BRACKET_OPEN);
3153
+ }
3154
+ this.writeArray(append ? fns.slice(start) : fns, COMMA);
3155
+ if (!append) {
3156
+ this.write(BRACKET_CLOSE);
3157
+ }
3158
+ if (append) {
3159
+ this.write(")");
3160
+ }
3161
+ this.closeScript();
3162
+ this.emittedSyncFnCount = fns.length;
2544
3163
  }
2545
3164
  }
2546
3165
  emitPatchDataIfNeeded() {
@@ -2562,29 +3181,75 @@ var SSRContainer = class extends _SharedContainer {
2562
3181
  if (this.renderOptions.serverData?.nonce) {
2563
3182
  scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
2564
3183
  }
2565
- this.openElement("script", null, scriptAttrs);
2566
- this.write(JSON.stringify(patches));
2567
- this.closeElement();
3184
+ this.writeScript(scriptAttrs, JSON.stringify(patches));
2568
3185
  }
2569
3186
  }
3187
+ emitBackpatchDataAndExecutorIfNeeded() {
3188
+ if (this.backpatchMap.size === 0) {
3189
+ return;
3190
+ }
3191
+ this.emitPatchDataIfNeeded();
3192
+ this.emitExecutorIfNeeded();
3193
+ }
2570
3194
  emitExecutorIfNeeded() {
2571
3195
  if (!this.isBackpatchExecutorEmitted) {
2572
3196
  return;
2573
3197
  }
3198
+ this.isBackpatchExecutorEmitted = false;
2574
3199
  const scriptAttrs = { type: "text/javascript" };
2575
3200
  if (this.renderOptions.serverData?.nonce) {
2576
3201
  scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
2577
3202
  }
2578
- this.openElement("script", null, scriptAttrs);
2579
- const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev7 });
2580
- this.write(backpatchScript);
2581
- this.closeElement();
3203
+ const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev8 });
3204
+ this.writeScript(scriptAttrs, backpatchScript);
3205
+ }
3206
+ emitOutOfOrderExecutorIfNeeded() {
3207
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming || !this.outOfOrderUsed || this.isOutOfOrderExecutorEmitted) {
3208
+ return;
3209
+ }
3210
+ this.isOutOfOrderExecutorEmitted = true;
3211
+ this.writeScript(
3212
+ { type: "text/javascript", nonce: this.renderOptions.serverData?.nonce },
3213
+ getQwikOutOfOrderExecutorScript({ debug: isDev8 })
3214
+ );
3215
+ }
3216
+ emitInlineScript(script) {
3217
+ const scriptAttrs = { type: "text/javascript" };
3218
+ if (this.renderOptions.serverData?.nonce) {
3219
+ scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
3220
+ }
3221
+ this.writeScript(scriptAttrs, script);
3222
+ }
3223
+ emitContainerReadyEventIfNeeded() {
3224
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming || !this.outOfOrderUsed) {
3225
+ return;
3226
+ }
3227
+ this.emitInlineScript(
3228
+ `document.qready||(document.qready={});document.qready["${this.$instanceHash$}"]=1;try{document.dispatchEvent(new CustomEvent("qready",{detail:"${this.$instanceHash$}"}))}catch(e){}`
3229
+ );
3230
+ }
3231
+ writeScript(attrs, body) {
3232
+ this.openScript(attrs);
3233
+ if (body) {
3234
+ this.write(body);
3235
+ }
3236
+ this.closeScript();
3237
+ }
3238
+ openScript(attrs) {
3239
+ this.write("<script");
3240
+ this.writeAttrs("script", attrs, true, null, null, true);
3241
+ this.write(GT);
3242
+ }
3243
+ closeScript() {
3244
+ this.write("</script>");
2582
3245
  }
2583
3246
  emitPreloaderPre() {
2584
- preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
3247
+ if (!isDev8) {
3248
+ preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
3249
+ }
2585
3250
  }
2586
3251
  isStatic() {
2587
- return this.serializationCtx.$eventQrls$.size === 0;
3252
+ return !(__EXPERIMENTAL__.suspense && this.outOfOrderStreaming && this.outOfOrderUsed) && this.serializationCtx.$eventQrls$.size === 0;
2588
3253
  }
2589
3254
  emitQwikLoaderAtTopIfNeeded() {
2590
3255
  if (this.qlInclude === 0 /* Module */) {
@@ -2605,8 +3270,7 @@ var SSRContainer = class extends _SharedContainer {
2605
3270
  if (nonce) {
2606
3271
  scriptAttrs["nonce"] = nonce;
2607
3272
  }
2608
- this.openElement("script", null, scriptAttrs);
2609
- this.closeElement();
3273
+ this.writeScript(scriptAttrs);
2610
3274
  }
2611
3275
  }
2612
3276
  emitQwikLoaderInline() {
@@ -2620,18 +3284,26 @@ var SSRContainer = class extends _SharedContainer {
2620
3284
  if (this.renderOptions.serverData?.nonce) {
2621
3285
  scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
2622
3286
  }
2623
- this.openElement("script", null, scriptAttrs);
2624
- this.write(qwikLoaderScript);
2625
- this.closeElement();
3287
+ this.writeScript(scriptAttrs, qwikLoaderScript);
2626
3288
  }
2627
3289
  emitQwikLoaderAtBottomIfNeeded() {
2628
3290
  if (!this.isStatic()) {
2629
3291
  if (this.qlInclude !== 2 /* Done */) {
2630
3292
  this.emitQwikLoaderInline();
2631
3293
  }
2632
- this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
3294
+ this.emitNewQwikEvents();
2633
3295
  }
2634
3296
  }
3297
+ emitNewQwikEvents() {
3298
+ const eventNames = [];
3299
+ for (const eventName of this.serializationCtx.$eventNames$) {
3300
+ if (!this.emittedQwikEventNames.has(eventName)) {
3301
+ this.emittedQwikEventNames.add(eventName);
3302
+ eventNames.push(JSON.stringify(eventName));
3303
+ }
3304
+ }
3305
+ this.emitQwikEvents(eventNames);
3306
+ }
2635
3307
  emitQwikEvents(eventNames) {
2636
3308
  if (eventNames.length > 0) {
2637
3309
  const scriptAttrs = {};
@@ -2639,11 +3311,11 @@ var SSRContainer = class extends _SharedContainer {
2639
3311
  if (nonce) {
2640
3312
  scriptAttrs["nonce"] = nonce;
2641
3313
  }
2642
- this.openElement("script", null, scriptAttrs);
3314
+ this.openScript(scriptAttrs);
2643
3315
  this.write(`(window._qwikEv||(window._qwikEv=[])).push(`);
2644
3316
  this.writeArray(eventNames, COMMA);
2645
3317
  this.write(PAREN_CLOSE);
2646
- this.closeElement();
3318
+ this.closeScript();
2647
3319
  }
2648
3320
  }
2649
3321
  // Keep in sync with process-vnode-data.unit.ts
@@ -2674,7 +3346,7 @@ var SSRContainer = class extends _SharedContainer {
2674
3346
  }
2675
3347
  createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
2676
3348
  let tagNesting = 10 /* ANYTHING */;
2677
- if (isDev7) {
3349
+ if (isDev8) {
2678
3350
  if (!this.currentElementFrame) {
2679
3351
  tagNesting = initialTag(elementName);
2680
3352
  } else {
@@ -2711,7 +3383,7 @@ var SSRContainer = class extends _SharedContainer {
2711
3383
  text.push(
2712
3384
  `${indent}<${elementName}> <= is not allowed as a child of ${allowedContent(previousTagNesting)[0]}.`
2713
3385
  );
2714
- throw newTagError(text.map(escapeHTML).join("\n"));
3386
+ throw newTagError(text.join("\n"));
2715
3387
  }
2716
3388
  }
2717
3389
  }
@@ -2721,7 +3393,8 @@ var SSRContainer = class extends _SharedContainer {
2721
3393
  elementName,
2722
3394
  depthFirstElementIdx,
2723
3395
  vNodeData: [0 /* NONE */],
2724
- currentFile: isDev7 ? currentFile || null : null
3396
+ currentFile: isDev8 ? currentFile || null : null,
3397
+ refBase: null
2725
3398
  };
2726
3399
  this.currentElementFrame = frame;
2727
3400
  this.vNodeDatas.push(frame.vNodeData);
@@ -2736,6 +3409,17 @@ var SSRContainer = class extends _SharedContainer {
2736
3409
  this.size += text.length;
2737
3410
  this.writer.write(text);
2738
3411
  }
3412
+ writeRootRef(id) {
3413
+ this.size += String(id).length;
3414
+ this.writer.writeRootRef(id);
3415
+ }
3416
+ writeRootRefPath(path) {
3417
+ this.size += String(path[0]).length;
3418
+ this.writer.writeRootRefPath(path);
3419
+ for (let i = 1; i < path.length; i++) {
3420
+ this.size += 1 + String(path[i]).length;
3421
+ }
3422
+ }
2739
3423
  writeArray(array, separator) {
2740
3424
  for (let i = 0; i < array.length; i++) {
2741
3425
  const element = array[i];
@@ -2750,7 +3434,7 @@ var SSRContainer = class extends _SharedContainer {
2750
3434
  for (let key in attrs) {
2751
3435
  let value = attrs[key];
2752
3436
  if (isSSRUnsafeAttr(key)) {
2753
- if (isDev7) {
3437
+ if (isDev8) {
2754
3438
  throw qError(32 /* unsafeAttr */, [key]);
2755
3439
  }
2756
3440
  continue;
@@ -2771,7 +3455,11 @@ var SSRContainer = class extends _SharedContainer {
2771
3455
  throw qError(15 /* invalidRefValue */, [currentFile]);
2772
3456
  }
2773
3457
  } else if (key === ITERATION_ITEM_SINGLE || key === ITERATION_ITEM_MULTI) {
2774
- value = this.serializationCtx.$addRoot$(value);
3458
+ const rootId = this.addRoot(value);
3459
+ if (rootId === void 0) {
3460
+ continue;
3461
+ }
3462
+ value = typeof rootId === "number" ? [rootId] : String(rootId);
2775
3463
  } else if (isSignal(value)) {
2776
3464
  const lastNode = this.getOrCreateLastNode();
2777
3465
  const signalData = new SubscriptionData({
@@ -2787,7 +3475,11 @@ var SSRContainer = class extends _SharedContainer {
2787
3475
  const lastNode = this.getOrCreateLastNode();
2788
3476
  this.addPromiseAttribute(value);
2789
3477
  value.then((resolvedValue) => {
2790
- this.addBackpatchEntry(lastNode.id, key, resolvedValue);
3478
+ this.addBackpatchEntry(
3479
+ lastNode.id,
3480
+ key,
3481
+ serializeAttribute(key, resolvedValue, styleScopedId)
3482
+ );
2791
3483
  });
2792
3484
  continue;
2793
3485
  }
@@ -2805,7 +3497,7 @@ var SSRContainer = class extends _SharedContainer {
2805
3497
  }
2806
3498
  if (tag === "textarea" && key === "value") {
2807
3499
  if (value && typeof value !== "string") {
2808
- if (isDev7) {
3500
+ if (isDev8) {
2809
3501
  throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
2810
3502
  }
2811
3503
  continue;
@@ -2820,14 +3512,30 @@ var SSRContainer = class extends _SharedContainer {
2820
3512
  this.write(key);
2821
3513
  if (serializedValue !== true) {
2822
3514
  this.write(ATTR_EQUALS_QUOTE);
2823
- const strValue = escapeHTML(String(serializedValue));
2824
- this.write(strValue);
3515
+ if (Array.isArray(serializedValue)) {
3516
+ this.writeEscapedChunks(serializedValue);
3517
+ } else {
3518
+ const strValue = escapeHTML(String(serializedValue));
3519
+ this.write(strValue);
3520
+ }
2825
3521
  this.write(QUOTE);
2826
3522
  }
2827
3523
  }
2828
3524
  }
2829
3525
  return innerHTML;
2830
3526
  }
3527
+ writeEscapedChunks(chunks) {
3528
+ for (let i = 0; i < chunks.length; i++) {
3529
+ const chunk = chunks[i];
3530
+ if (typeof chunk === "string") {
3531
+ this.write(escapeHTML(chunk));
3532
+ } else if (typeof chunk === "number") {
3533
+ this.writeRootRef(chunk);
3534
+ } else {
3535
+ this.writeRootRefPath(chunk.path);
3536
+ }
3537
+ }
3538
+ }
2831
3539
  addPromiseAttribute(promise) {
2832
3540
  this.promiseAttributes ||= [];
2833
3541
  this.promiseAttributes.push(promise);
@@ -2839,6 +3547,277 @@ var SSRContainer = class extends _SharedContainer {
2839
3547
  }
2840
3548
  }
2841
3549
  };
3550
+ var SSRSegmentContainer = class extends SSRContainer {
3551
+ constructor(opts, $rootContainer$) {
3552
+ super(opts);
3553
+ this.$rootContainer$ = $rootContainer$;
3554
+ }
3555
+ $outOfOrderState$ = 0 /* Rendering */;
3556
+ $outOfOrderRootIdMap$ = null;
3557
+ subscriptionPatchRecords = [];
3558
+ pendingVNodeDataPatches = null;
3559
+ nextOutOfOrderId() {
3560
+ return this.$rootContainer$.nextOutOfOrderId();
3561
+ }
3562
+ $runQueuedRender$(render) {
3563
+ return this.$rootContainer$.$runQueuedRender$(render);
3564
+ }
3565
+ queueOutOfOrderSegment(segment) {
3566
+ this.$rootContainer$.queueOutOfOrderSegment(segment);
3567
+ }
3568
+ emitOutOfOrderSegmentScripts(scripts) {
3569
+ this.$rootContainer$.emitOutOfOrderSegmentScripts(scripts);
3570
+ }
3571
+ emitOutOfOrderExecutorIfNeeded() {
3572
+ this.$rootContainer$.emitOutOfOrderExecutorIfNeeded();
3573
+ }
3574
+ $recordExternalRootEffect$(producer, effect, prop, sourceEffects) {
3575
+ recordExternalRootEffect(
3576
+ this.$rootContainer$.serializationCtx,
3577
+ this.serializationCtx,
3578
+ this.$rootContainer$.$storeProxyMap$,
3579
+ this.subscriptionPatchRecords,
3580
+ producer,
3581
+ effect,
3582
+ prop,
3583
+ sourceEffects
3584
+ );
3585
+ }
3586
+ async $finalizeOutOfOrderSegment$(segmentId, segment) {
3587
+ const rootContainer = this.$rootContainer$;
3588
+ const rootReadyAtSegment = rootContainer.$isReadyForOOOS$();
3589
+ const segmentSerializationCtx = this.serializationCtx;
3590
+ try {
3591
+ const commit = this.$commitRoots$(rootContainer, segmentSerializationCtx);
3592
+ this.$mergeSegmentEventData$(rootContainer, segmentSerializationCtx);
3593
+ this.$mergeSegmentSyncFns$(rootContainer, segmentSerializationCtx);
3594
+ const subscriptionPatchRootId = this.$addSubscriptionsToRoots$(
3595
+ rootContainer,
3596
+ rootReadyAtSegment,
3597
+ segmentSerializationCtx
3598
+ );
3599
+ if (rootReadyAtSegment && (commit.newRootLocalIds.length > 0 || subscriptionPatchRootId !== void 0)) {
3600
+ segmentSerializationCtx.$forwardRefOffset$ = rootContainer.serializationCtx.$serializedForwardRefCount$;
3601
+ await this.emitStatePatchData(
3602
+ segmentId,
3603
+ commit.newRootStart,
3604
+ commit.newRootLocalIds,
3605
+ subscriptionPatchRootId
3606
+ );
3607
+ rootContainer.serializationCtx.$serializedRootCount$ = rootContainer.serializationCtx.$roots$.length + (rootContainer.serializationCtx.$hasRootStateForwardRefs$ ? 1 : 0);
3608
+ rootContainer.serializationCtx.$serializedForwardRefCount$ += segmentSerializationCtx.$serializedForwardRefCount$;
3609
+ }
3610
+ this.emitPendingVNodeDataPatches();
3611
+ if (rootReadyAtSegment) {
3612
+ this.$noMoreRoots$ = true;
3613
+ this.emitVNodeData(segmentId);
3614
+ const segmentCtx = this.serializationCtx;
3615
+ this.serializationCtx = rootContainer.serializationCtx;
3616
+ this.emittedSyncFnCount = rootContainer.emittedSyncFnCount;
3617
+ this.emitSyncFnsData(true);
3618
+ rootContainer.emittedSyncFnCount = this.emittedSyncFnCount;
3619
+ this.serializationCtx = segmentCtx;
3620
+ this.emitNewQwikEvents();
3621
+ }
3622
+ this.emitPatchDataIfNeeded();
3623
+ this.drainCleanupQueue();
3624
+ const rootIdMap = commit.rootIdMap;
3625
+ if (rootReadyAtSegment) {
3626
+ this.$outOfOrderState$ = 2 /* Done */;
3627
+ } else {
3628
+ this.$outOfOrderRootIdMap$ = rootIdMap;
3629
+ this.$outOfOrderState$ = 1 /* EarlyFinalized */;
3630
+ }
3631
+ return {
3632
+ html: renderSSRChunks(segment.htmlChunks, rootIdMap),
3633
+ scripts: segment.writer.toString(rootIdMap)
3634
+ };
3635
+ } finally {
3636
+ if (this.$outOfOrderState$ !== 1 /* EarlyFinalized */) {
3637
+ segmentSerializationCtx.$onAddRoot$ = void 0;
3638
+ rootContainer.removeOutOfOrderSegment(this);
3639
+ }
3640
+ rootContainer.serializationCtx.$setWriter$(rootContainer.writer);
3641
+ }
3642
+ }
3643
+ $emitDelayedOutOfOrderVNodeData$() {
3644
+ try {
3645
+ this.emitVNodeData(this.vnodeSegment);
3646
+ this.emitPendingVNodeDataPatches();
3647
+ this.$rootContainer$.emitOutOfOrderSegmentScripts(
3648
+ this.writer.toString(this.$outOfOrderRootIdMap$)
3649
+ );
3650
+ this.$outOfOrderState$ = 2 /* Done */;
3651
+ this.$rootContainer$.removeOutOfOrderSegment(this);
3652
+ } finally {
3653
+ this.serializationCtx.$onAddRoot$ = void 0;
3654
+ }
3655
+ }
3656
+ markVNodeDataForSerialization(node, flags = 16 /* SERIALIZE */) {
3657
+ const previousFlags = node.vnodeData[0];
3658
+ const nextFlags = previousFlags | flags;
3659
+ if (nextFlags !== previousFlags) {
3660
+ node.vnodeData[0] = nextFlags;
3661
+ this.queueLateVNodeDataPatch(node, nextFlags & ~previousFlags);
3662
+ }
3663
+ }
3664
+ queueLateVNodeDataPatch(node, addedFlags) {
3665
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming || !(addedFlags & (16 /* SERIALIZE */ | 8 /* REFERENCE */))) {
3666
+ return;
3667
+ }
3668
+ const owner = this.getVNodeDataOwnerFromNodeId(node.id);
3669
+ if (!this.$getRootContainer$().isVNodeDataOwnerEmitted(owner.owner)) {
3670
+ return;
3671
+ }
3672
+ let ownerPatches = (this.pendingVNodeDataPatches ||= /* @__PURE__ */ new Map()).get(owner.owner);
3673
+ if (!ownerPatches) {
3674
+ this.pendingVNodeDataPatches.set(owner.owner, ownerPatches = /* @__PURE__ */ new Map());
3675
+ }
3676
+ ownerPatches.set(owner.localIndex, node.vnodeData);
3677
+ }
3678
+ emitPendingVNodeDataPatches() {
3679
+ const pendingPatches = this.pendingVNodeDataPatches;
3680
+ this.pendingVNodeDataPatches = null;
3681
+ if (!pendingPatches) {
3682
+ return;
3683
+ }
3684
+ for (const [owner, entries] of pendingPatches) {
3685
+ if (entries.size === 0) {
3686
+ continue;
3687
+ }
3688
+ const sortedEntries = Array.from(entries).sort((a, b) => a[0] - b[0]);
3689
+ this.emitVNodeDataScript(owner, sortedEntries, true);
3690
+ }
3691
+ }
3692
+ $commitRoots$(rootContainer, segmentSerializationCtx) {
3693
+ const commit = this.commitSegmentRoots(rootContainer, segmentSerializationCtx);
3694
+ segmentSerializationCtx.$onAddRoot$ = (localId, root, obj) => {
3695
+ this.commitSegmentRoot(rootContainer, localId, root, obj, commit);
3696
+ };
3697
+ return commit;
3698
+ }
3699
+ $addSubscriptionsToRoots$(rootContainer, rootReadyAtSegment, segmentSerializationCtx) {
3700
+ let subscriptionPatchRootId = void 0;
3701
+ const subscriptionPatches = rootReadyAtSegment ? this.collectSubscriptionPatches(
3702
+ rootContainer,
3703
+ rootContainer.rootContainerSerializedRootCount
3704
+ ) : void 0;
3705
+ if (subscriptionPatches) {
3706
+ subscriptionPatchRootId = segmentSerializationCtx.$addRoot$(subscriptionPatches);
3707
+ }
3708
+ return subscriptionPatchRootId;
3709
+ }
3710
+ commitSegmentRoots(rootContainer, segmentSerializationCtx) {
3711
+ const rootIdMap = [];
3712
+ const newRootStart = rootContainer.$isReadyForOOOS$() ? rootContainer.serializationCtx.$serializedRootCount$ : rootContainer.serializationCtx.$roots$.length;
3713
+ const newRootLocalIds = [];
3714
+ const commit = {
3715
+ rootIdMap,
3716
+ newRootStart,
3717
+ newRootLocalIds
3718
+ };
3719
+ this.promoteSharedSegmentRoots(rootContainer, segmentSerializationCtx, commit);
3720
+ const segmentRoots = segmentSerializationCtx.$roots$;
3721
+ const segmentRootObjs = segmentSerializationCtx.$rootObjs$;
3722
+ for (let i = 0; i < segmentRoots.length; i++) {
3723
+ const rootObj = segmentRootObjs[i];
3724
+ this.commitSegmentRoot(rootContainer, i, segmentRoots[i], rootObj, commit);
3725
+ }
3726
+ return commit;
3727
+ }
3728
+ promoteSharedSegmentRoots(rootContainer, segmentSerializationCtx, commit) {
3729
+ const segmentRoots = segmentSerializationCtx.$roots$;
3730
+ const segmentRootObjs = segmentSerializationCtx.$rootObjs$;
3731
+ for (let i = 0; i < segmentRootObjs.length; i++) {
3732
+ const rootObj = segmentRootObjs[i];
3733
+ if (this.isRootOrUsedByOtherLiveSegment(rootContainer, rootObj)) {
3734
+ this.commitSegmentRoot(rootContainer, i, segmentRoots[i], rootObj, commit);
3735
+ }
3736
+ }
3737
+ }
3738
+ isRootOrUsedByOtherLiveSegment(rootContainer, obj) {
3739
+ if (rootContainer.serializationCtx.$hasRootId$(obj) !== void 0) {
3740
+ return true;
3741
+ }
3742
+ const segments = rootContainer.outOfOrderSegments;
3743
+ for (let i = 0; i < segments.length; i++) {
3744
+ const segment = segments[i];
3745
+ if (segment === this) {
3746
+ continue;
3747
+ }
3748
+ const rootObjs = segment.serializationCtx.$rootObjs$;
3749
+ for (let j = 0; j < rootObjs.length; j++) {
3750
+ if (rootObjs[j] === obj) {
3751
+ return true;
3752
+ }
3753
+ }
3754
+ }
3755
+ return false;
3756
+ }
3757
+ commitSegmentRoot(rootContainer, localId, root, rootObj, commit) {
3758
+ if (commit.rootIdMap[localId] !== void 0) {
3759
+ return;
3760
+ }
3761
+ let rootId = rootContainer.serializationCtx.$hasRootId$(rootObj);
3762
+ if (rootId === void 0) {
3763
+ rootId = rootContainer.serializationCtx.$commitRoot$(root, rootObj);
3764
+ commit.newRootLocalIds.push(localId);
3765
+ this.seedCommittedRootForLiveSegments(rootContainer, rootObj);
3766
+ }
3767
+ const rootCtx = rootContainer.serializationCtx;
3768
+ commit.rootIdMap[localId] = rootContainer.$isReadyForOOOS$() && rootId >= rootCtx.$rootStateRootCount$ ? rootId + (rootCtx.$hasRootStateForwardRefs$ ? 1 : 0) : rootId;
3769
+ }
3770
+ seedCommittedRootForLiveSegments(rootContainer, rootObj) {
3771
+ const segments = rootContainer.outOfOrderSegments;
3772
+ for (let i = 0; i < segments.length; i++) {
3773
+ const segment = segments[i];
3774
+ if (segment !== this && segment.$outOfOrderState$ === 0 /* Rendering */) {
3775
+ segment.serializationCtx.$addRoot$(rootObj);
3776
+ }
3777
+ }
3778
+ }
3779
+ $mergeSegmentEventData$(rootContainer, segmentSerializationCtx) {
3780
+ for (const eventName of segmentSerializationCtx.$eventNames$) {
3781
+ rootContainer.serializationCtx.$eventNames$.add(eventName);
3782
+ }
3783
+ for (const qrl of segmentSerializationCtx.$eventQrls$) {
3784
+ rootContainer.serializationCtx.$eventQrls$.add(qrl);
3785
+ }
3786
+ }
3787
+ $mergeSegmentSyncFns$(rootContainer, segmentSerializationCtx) {
3788
+ rootContainer.serializationCtx.$syncFns$.push(...segmentSerializationCtx.$syncFns$);
3789
+ }
3790
+ collectSubscriptionPatches(rootContainer, rootLimit) {
3791
+ if (!__EXPERIMENTAL__.suspense || !this.outOfOrderStreaming) {
3792
+ return;
3793
+ }
3794
+ return collectSubscriptionPatches(
3795
+ rootContainer.serializationCtx,
3796
+ this.subscriptionPatchRecords,
3797
+ rootLimit
3798
+ );
3799
+ }
3800
+ emitStatePatchData(segmentId, rootStart, rootIds, subscriptionPatchRootId) {
3801
+ const attrs = this.statePatchScriptAttrs(segmentId);
3802
+ this.openScript(attrs);
3803
+ this.serializationCtx.$setWriter$(this.writer);
3804
+ this.serializationCtx.$markSsrNodeForSerialization$ = this.markVNodeDataForSerialization.bind(this);
3805
+ return maybeThen(
3806
+ this.serializationCtx.$serializePatch$(rootStart, rootIds, subscriptionPatchRootId, 0),
3807
+ () => {
3808
+ this.closeScript();
3809
+ }
3810
+ );
3811
+ }
3812
+ statePatchScriptAttrs(segmentId) {
3813
+ const attrs = this.stateScriptAttrs();
3814
+ attrs[QStatePatchAttr] = true;
3815
+ if (segmentId) {
3816
+ attrs[QSuspenseResolved] = segmentId;
3817
+ }
3818
+ return attrs;
3819
+ }
3820
+ };
2842
3821
  var isQwikStyleElement = (tag, attrs) => {
2843
3822
  if (tag === "style" && attrs != null) {
2844
3823
  return Object.prototype.hasOwnProperty.call(attrs, QStyle) || Object.prototype.hasOwnProperty.call(attrs, QScopedStyle);
@@ -2870,9 +3849,6 @@ function addPreventDefaultEventToSerializationContext(serializationCtx, key) {
2870
3849
  }
2871
3850
  }
2872
3851
 
2873
- // packages/qwik/src/server/ssr-render.ts
2874
- import { manifest as builtManifest } from "@qwik-client-manifest";
2875
-
2876
3852
  // packages/qwik/src/server/ssr-stream-handler.ts
2877
3853
  var StreamHandler = class {
2878
3854
  constructor(opts, timing) {
@@ -2903,58 +3879,43 @@ var StreamHandler = class {
2903
3879
  let stream;
2904
3880
  switch (this.inOrderStreaming.strategy) {
2905
3881
  case "disabled":
2906
- stream = {
2907
- write(chunk) {
2908
- if (chunk === void 0 || chunk === null) {
2909
- return;
2910
- }
2911
- handler.enqueue(chunk);
2912
- },
2913
- waitForDrain() {
2914
- return handler.waitForPendingFlush();
3882
+ stream = createStringStreamWriter((chunk) => {
3883
+ if (chunk === void 0 || chunk === null) {
3884
+ return;
2915
3885
  }
2916
- };
3886
+ handler.enqueue(chunk);
3887
+ });
2917
3888
  break;
2918
3889
  case "direct": {
2919
3890
  const originalStream = this.nativeStream;
2920
- stream = {
2921
- write(chunk) {
2922
- if (chunk === void 0 || chunk === null) {
2923
- return;
2924
- }
2925
- if (handler.pendingFlush) {
2926
- const queued = handler.pendingFlush.then(() => originalStream.write(chunk));
2927
- return handler.trackPendingFlush(queued);
2928
- }
2929
- return handler.trackPendingFlush(originalStream.write(chunk));
2930
- },
2931
- waitForDrain() {
2932
- return handler.waitForPendingFlush();
3891
+ stream = createStringStreamWriter((chunk) => {
3892
+ if (chunk === void 0 || chunk === null) {
3893
+ return;
3894
+ }
3895
+ if (handler.pendingFlush) {
3896
+ const queued = handler.pendingFlush.then(() => originalStream.write(chunk));
3897
+ return handler.trackPendingFlush(queued);
2933
3898
  }
2934
- };
3899
+ return handler.trackPendingFlush(originalStream.write(chunk));
3900
+ });
2935
3901
  break;
2936
3902
  }
2937
3903
  default:
2938
3904
  case "auto": {
2939
3905
  const minimumChunkSize = this.inOrderStreaming.maximumChunk ?? 0;
2940
3906
  const initialChunkSize = this.inOrderStreaming.maximumInitialChunk ?? 0;
2941
- stream = {
2942
- write(chunk) {
2943
- if (chunk === void 0 || chunk === null) {
2944
- return;
2945
- }
2946
- handler.enqueue(chunk);
2947
- if (handler.streamBlockDepth === 0) {
2948
- const maxBufferSize = handler.networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
2949
- if (handler.bufferSize >= maxBufferSize) {
2950
- return handler.flush();
2951
- }
3907
+ stream = createStringStreamWriter((chunk) => {
3908
+ if (chunk === void 0 || chunk === null) {
3909
+ return;
3910
+ }
3911
+ handler.enqueue(chunk);
3912
+ if (handler.streamBlockDepth === 0) {
3913
+ const maxBufferSize = handler.networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
3914
+ if (handler.bufferSize >= maxBufferSize) {
3915
+ return handler.flush();
2952
3916
  }
2953
- },
2954
- waitForDrain() {
2955
- return handler.waitForPendingFlush();
2956
3917
  }
2957
- };
3918
+ });
2958
3919
  break;
2959
3920
  }
2960
3921
  }
@@ -3034,22 +3995,26 @@ var StreamHandler = class {
3034
3995
 
3035
3996
  // packages/qwik/src/server/ssr-render.ts
3036
3997
  var renderToString = async (jsx, opts = {}) => {
3037
- const chunks = [];
3038
- const stream = {
3039
- write(chunk) {
3040
- chunks.push(chunk);
3041
- }
3042
- };
3998
+ const stream = new StringSSRWriter();
3043
3999
  const result = await renderToStream(jsx, { ...opts, stream });
3044
4000
  return {
3045
4001
  isStatic: result.isStatic,
3046
4002
  timing: result.timing,
3047
4003
  manifest: result.manifest,
3048
4004
  snapshotResult: result.snapshotResult,
3049
- html: chunks.join("")
4005
+ html: stream.toString()
3050
4006
  };
3051
4007
  };
3052
4008
  var renderToStream = async (jsx, opts) => {
4009
+ if (__EXPERIMENTAL__.suspense && opts.streaming?.outOfOrder === void 0) {
4010
+ opts = {
4011
+ ...opts,
4012
+ streaming: {
4013
+ ...opts.streaming,
4014
+ outOfOrder: true
4015
+ }
4016
+ };
4017
+ }
3053
4018
  const timing = {
3054
4019
  firstFlush: 0,
3055
4020
  render: 0,
@@ -3084,6 +4049,7 @@ var renderToStream = async (jsx, opts) => {
3084
4049
  return result;
3085
4050
  };
3086
4051
  function resolveManifest(manifest) {
4052
+ const builtManifest = getClientManifest();
3087
4053
  const mergedManifest = manifest ? { ...builtManifest, ...manifest } : builtManifest;
3088
4054
  if (!mergedManifest || "mapper" in mergedManifest) {
3089
4055
  return mergedManifest;
@@ -3092,7 +4058,7 @@ function resolveManifest(manifest) {
3092
4058
  const mapper = {};
3093
4059
  for (const symbol in mergedManifest.mapping) {
3094
4060
  const bundleFilename = mergedManifest.mapping[symbol];
3095
- mapper[getSymbolHash2(symbol)] = [symbol, bundleFilename];
4061
+ mapper[getSymbolHash(symbol)] = [symbol, bundleFilename];
3096
4062
  }
3097
4063
  return {
3098
4064
  mapper,
@@ -3106,7 +4072,7 @@ var Q_FUNCS_PREFIX = 'document["qFuncs_HASH"]=';
3106
4072
 
3107
4073
  // packages/qwik/src/server/index.ts
3108
4074
  async function setServerPlatform2(manifest) {
3109
- const platform = createPlatform2({ manifest }, resolveManifest(manifest));
4075
+ const platform = createPlatform({ manifest }, resolveManifest(manifest));
3110
4076
  setPlatform2(platform);
3111
4077
  }
3112
4078
  export {