marko 6.4.5 → 6.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/cheatsheet.md +2 -1
  2. package/dist/common/errors.d.ts +3 -1
  3. package/dist/common/helpers.d.ts +7 -7
  4. package/dist/debug/dom/catch.feat.js +4 -4
  5. package/dist/debug/dom/catch.feat.mjs +4 -4
  6. package/dist/debug/dom/controllable-input.feat.js +1 -1
  7. package/dist/debug/dom/controllable-input.feat.mjs +1 -1
  8. package/dist/debug/dom/controllable-open.feat.js +1 -1
  9. package/dist/debug/dom/controllable-open.feat.mjs +1 -1
  10. package/dist/debug/dom/controllable-select.feat.js +1 -1
  11. package/dist/debug/dom/controllable-select.feat.mjs +1 -1
  12. package/dist/debug/dom/controllable-textarea.feat.js +1 -1
  13. package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
  14. package/dist/debug/dom/controllable.feat.js +5 -5
  15. package/dist/debug/dom/controllable.feat.mjs +5 -5
  16. package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
  17. package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
  18. package/dist/debug/dom/dynamic-tag-var.feat.js +2 -2
  19. package/dist/debug/dom/dynamic-tag-var.feat.mjs +2 -2
  20. package/dist/debug/dom/lazy.feat.js +1 -1
  21. package/dist/debug/dom/lazy.feat.mjs +1 -1
  22. package/dist/debug/dom/placeholder.feat.js +1 -1
  23. package/dist/debug/dom/placeholder.feat.mjs +1 -1
  24. package/dist/debug/{dom-BeY1nGUb.mjs → dom-CFCBDift.mjs} +133 -135
  25. package/dist/debug/{dom-CUxvM4i9.js → dom-D8znnhpf.js} +148 -150
  26. package/dist/debug/dom.js +21 -22
  27. package/dist/debug/dom.mjs +22 -22
  28. package/dist/debug/html.js +736 -664
  29. package/dist/debug/html.mjs +736 -665
  30. package/dist/dom/catch.feat.js +5 -5
  31. package/dist/dom/catch.feat.mjs +4 -4
  32. package/dist/dom/control-flow.d.ts +3 -3
  33. package/dist/dom/controllable-input.feat.js +2 -2
  34. package/dist/dom/controllable-input.feat.mjs +1 -1
  35. package/dist/dom/controllable-open.feat.js +2 -2
  36. package/dist/dom/controllable-open.feat.mjs +1 -1
  37. package/dist/dom/controllable-select.feat.js +2 -2
  38. package/dist/dom/controllable-select.feat.mjs +1 -1
  39. package/dist/dom/controllable-textarea.feat.js +2 -2
  40. package/dist/dom/controllable-textarea.feat.mjs +1 -1
  41. package/dist/dom/controllable.d.ts +4 -4
  42. package/dist/dom/controllable.feat.js +2 -2
  43. package/dist/dom/controllable.feat.mjs +2 -2
  44. package/dist/dom/dom.d.ts +5 -5
  45. package/dist/dom/dynamic-tag-script.feat.js +2 -2
  46. package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
  47. package/dist/dom/dynamic-tag-var.feat.js +3 -3
  48. package/dist/dom/dynamic-tag-var.feat.mjs +2 -2
  49. package/dist/dom/lazy.feat.js +1 -1
  50. package/dist/dom/lazy.feat.mjs +1 -1
  51. package/dist/dom/placeholder.feat.js +2 -2
  52. package/dist/dom/placeholder.feat.mjs +1 -1
  53. package/dist/dom/renderer.d.ts +1 -3
  54. package/dist/dom/resume.d.ts +2 -3
  55. package/dist/dom/signals.d.ts +6 -8
  56. package/dist/{dom-Diu8MpmL.js → dom-Bpkm72vV.js} +157 -166
  57. package/dist/{dom-DefWmvQB.mjs → dom-CVAevsbz.mjs} +103 -107
  58. package/dist/dom.d.ts +1 -1
  59. package/dist/dom.js +37 -37
  60. package/dist/dom.mjs +22 -22
  61. package/dist/html/assets.d.ts +2 -2
  62. package/dist/html/compat.d.ts +2 -1
  63. package/dist/html/control-flow.d.ts +20 -0
  64. package/dist/html/inlined-runtimes.d.ts +2 -2
  65. package/dist/html/inlined-runtimes.debug.d.ts +2 -2
  66. package/dist/html/serializer.d.ts +63 -16
  67. package/dist/html/template.d.ts +1 -1
  68. package/dist/html/writer.d.ts +47 -35
  69. package/dist/html.d.ts +3 -2
  70. package/dist/html.js +531 -484
  71. package/dist/html.mjs +531 -484
  72. package/dist/translator/core/for.d.ts +0 -4
  73. package/dist/translator/core/return.d.ts +0 -3
  74. package/dist/translator/core/style.d.ts +2 -2
  75. package/dist/translator/index.js +8093 -8021
  76. package/dist/translator/util/analyze-errors.d.ts +2 -1
  77. package/dist/translator/util/assert.d.ts +15 -1
  78. package/dist/translator/util/bindings.d.ts +24 -12
  79. package/dist/translator/util/body-to-text.d.ts +9 -0
  80. package/dist/translator/util/branch-tag.d.ts +10 -3
  81. package/dist/translator/util/build-string-expression.d.ts +4 -0
  82. package/dist/translator/util/content-derives.d.ts +7 -0
  83. package/dist/translator/util/cyclic-memo.d.ts +6 -2
  84. package/dist/translator/util/entry-builder.d.ts +6 -3
  85. package/dist/translator/util/finalize-references.d.ts +6 -3
  86. package/dist/translator/util/for-selector.d.ts +1 -1
  87. package/dist/translator/util/generate-uid.d.ts +4 -2
  88. package/dist/translator/util/get-root.d.ts +3 -3
  89. package/dist/translator/util/get-tag-name.d.ts +1 -1
  90. package/dist/translator/util/known-tag.d.ts +14 -9
  91. package/dist/translator/util/module-read.d.ts +0 -3
  92. package/dist/translator/util/module-registrations.d.ts +44 -0
  93. package/dist/translator/util/nested-attribute-tags.d.ts +1 -1
  94. package/dist/translator/util/optional.d.ts +7 -2
  95. package/dist/translator/util/params-tree.d.ts +18 -0
  96. package/dist/translator/util/reasons.d.ts +13 -8
  97. package/dist/translator/util/references.d.ts +23 -27
  98. package/dist/translator/util/runtime.d.ts +0 -12
  99. package/dist/translator/util/scope-accessor.d.ts +0 -1
  100. package/dist/translator/util/scope-read.d.ts +3 -0
  101. package/dist/translator/util/section-renderer.d.ts +4 -0
  102. package/dist/translator/util/sections.d.ts +21 -21
  103. package/dist/translator/util/setup-work.d.ts +2 -1
  104. package/dist/translator/util/signals.d.ts +16 -14
  105. package/dist/translator/util/simplify-fn.d.ts +1 -0
  106. package/dist/translator/util/slots.d.ts +4 -4
  107. package/dist/translator/util/solve-reasons.d.ts +1 -3
  108. package/dist/translator/util/sources.d.ts +2 -1
  109. package/dist/translator/util/state.d.ts +4 -2
  110. package/dist/translator/util/statement-tag.d.ts +2 -0
  111. package/dist/translator/util/static-text.d.ts +2 -1
  112. package/dist/translator/util/structure.d.ts +0 -10
  113. package/dist/translator/util/tag-facts.d.ts +8 -1
  114. package/dist/translator/util/tag-import.d.ts +20 -0
  115. package/dist/translator/util/tag-name-type.d.ts +9 -2
  116. package/dist/translator/util/to-only-or-block.d.ts +3 -0
  117. package/dist/translator/util/to-property-name.d.ts +2 -0
  118. package/dist/translator/util/translate-attrs.d.ts +7 -5
  119. package/dist/translator/util/translate-var.d.ts +2 -0
  120. package/dist/translator/util/traverse.d.ts +1 -2
  121. package/dist/translator/util/visitors.d.ts +4 -1
  122. package/dist/translator/util/with-previous-location.d.ts +1 -1
  123. package/dist/translator/util/write-guard.d.ts +2 -2
  124. package/dist/translator/util/writer.d.ts +1 -2
  125. package/dist/translator/visitors/export-declaration.d.ts +2 -3
  126. package/dist/translator/visitors/function.d.ts +0 -35
  127. package/dist/translator/visitors/import-declaration.d.ts +1 -15
  128. package/dist/translator/visitors/placeholder.d.ts +2 -1
  129. package/dist/translator/visitors/program/html.d.ts +0 -1
  130. package/dist/translator/visitors/program/index.d.ts +4 -5
  131. package/dist/translator/visitors/program/pre-analyze.d.ts +2 -0
  132. package/dist/translator/visitors/tag/custom-tag.d.ts +0 -14
  133. package/dist/translator/visitors/tag/dynamic-tag.d.ts +1 -0
  134. package/dist/translator/visitors/tag/native-tag.d.ts +3 -12
  135. package/package.json +4 -4
  136. package/dist/translator/util/binding-has-prop.d.ts +0 -8
  137. package/dist/translator/util/binding-prop-tree.d.ts +0 -18
  138. package/dist/translator/util/body-to-text-literal.d.ts +0 -9
  139. package/dist/translator/util/import-reference.d.ts +0 -3
  140. package/dist/translator/util/normalize-string-expression.d.ts +0 -4
  141. package/dist/translator/util/plugin-hooks.d.ts +0 -4
  142. package/dist/translator/util/resolve-relative-to-entry.d.ts +0 -2
  143. package/dist/translator/util/set-tag-derived-from.d.ts +0 -7
  144. package/dist/translator/util/to-first-expression-or-block.d.ts +0 -2
  145. package/dist/translator/util/to-first-statement-or-block.d.ts +0 -2
package/dist/html.mjs CHANGED
@@ -244,22 +244,17 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
244
244
  if (ch === "\0") return "\\x00";
245
245
  let code = ch.charCodeAt(0);
246
246
  return code >= 55296 && code <= 57343 ? "\\u" + code.toString(16).padStart(4, "0") : match;
247
- }, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /["\r]|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, $chunk, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kIsAsync = Symbol("Is Async"), writeScope = (scopeId, partialScope) => {
248
- let { state } = $chunk.boundary, target = $chunk.serializeState, scope = scopeWithId(state, scopeId), pending = target.writeScopes[scopeId];
249
- return state.needsMainRuntime = !0, countResumeWrite($chunk), Object.assign(scope, partialScope), pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0, scope;
250
- }, CLIENT_ALL = 715827883, NOOP$2 = () => {}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, unsafeXMLReg = /[<&\r]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : "&#13;", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<(\/?script|!--)/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\u003C$1") : str, unsafeScriptTemplateLiteralReg = /[`\\\r]|\$\{|<(?=\/?script|!--)/gi, replaceUnsafeScriptTemplateLiteral = (c) => c === "<" ? "\\x3C" : c === "\r" ? "\\r" : "\\" + c, quoteScriptTemplateLiteral = (str) => "`" + (unsafeScriptTemplateLiteralReg.test(str) ? str.replace(unsafeScriptTemplateLiteralReg, replaceUnsafeScriptTemplateLiteral) : str) + "`", unsafeStyleReg = /<(\/style)/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str, unsafeCommentReg = />/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, markerGuard, tagVar) => {
247
+ }, unsafeQuoteReg = /["\\<\n\r\u2028\u2029\0\ud800-\udfff]/u, kSelectedValue = Symbol("selectedValue"), checkedValuesRefs = /* @__PURE__ */ new WeakMap(), singleQuoteAttrReplacements = /['\r]|&(?=[#a-zA-Z])/g, doubleQuoteAttrReplacements = /["\r]|&(?=[#a-zA-Z])/g, needsQuotedAttr = /["'>\s]|&[#a-zA-Z]|\/$/g, $chunk, kPendingContexts = Symbol("Pending Contexts"), kBranchId = Symbol("Branch Id"), kAsyncContent = Symbol("Async Content"), writeScope = (scopeId, partialScope) => {
248
+ let { state } = $chunk.boundary, target = $chunk.channel, scope = scopeWithId(state, scopeId);
249
+ return state.needsWalkerRuntime = !0, countResumeWrite($chunk), writeAsyncVisits($chunk), Object.assign(scope, partialScope), state.queueScope(target, scopeId, partialScope), scope;
250
+ }, ALL_GROUPS = 715827883, NOOP$2 = () => {}, tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue, unsafeXMLReg = /[<&\r]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : "&#13;", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str, unsafeScriptReg = /<(\/?script|!--)/gi, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\u003C$1") : str, unsafeScriptTemplateLiteralReg = /[`\\\r]|\$\{|<(?=\/?script|!--)/gi, replaceUnsafeScriptTemplateLiteral = (c) => c === "<" ? "\\x3C" : c === "\r" ? "\\r" : "\\" + c, quoteScriptTemplateLiteral = (str) => "`" + (unsafeScriptTemplateLiteralReg.test(str) ? str.replace(unsafeScriptTemplateLiteralReg, replaceUnsafeScriptTemplateLiteral) : str) + "`", unsafeStyleReg = /<(\/style)/gi, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str, unsafeCommentReg = />/g, voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/, _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, markerGuard, tagVar) => {
251
251
  let shouldResume = markerGuard !== 0, renderer = normalizeDynamicRenderer(tag), state = getState(), branchId = _peek_scope_id(), rendered, result;
252
252
  if (typeof renderer == "string") {
253
253
  let input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
254
254
  rendered = !0, (() => {
255
255
  if (_scope_id(), _html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`), !voidElementsReg.test(renderer)) {
256
256
  let renderContent = content || normalizeDynamicRenderer(input.content);
257
- if (renderer === "textarea") _html(_attrs_textarea_value(branchId, "a", input));
258
- else {
259
- if (renderContent && typeof renderContent != "function") throw Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
260
- renderer === "select" && ("value" in input || "valueChange" in input) ? _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, markerGuard) : void 0, 1) : renderContent && _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, markerGuard);
261
- }
262
- _html(`</${renderer}>`);
257
+ renderer === "textarea" ? _html(_attrs_textarea_value(branchId, "a", input)) : renderer === "select" && ("value" in input || "valueChange" in input) ? _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent ? () => _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, markerGuard) : void 0, 1) : renderContent && _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, markerGuard), _html(`</${renderer}>`);
263
258
  }
264
259
  let childScope = getScopeById(branchId), needsScript = childScope && (childScope.Ia || childScope.Ea);
265
260
  needsScript && _script(branchId, "_d"), (shouldResume || needsScript) && _html(state.mark("(", scopeId + " " + accessor + " " + branchId));
@@ -267,7 +262,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
267
262
  } else {
268
263
  let chunk = getChunk(), beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0, render = () => {
269
264
  if (renderer) try {
270
- return _set_scope_reason(shouldResume ? CLIENT_ALL : 0), inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
265
+ return _set_scope_reason(shouldResume ? ALL_GROUPS : 0), inputIsArgs ? renderer(...inputOrArgs) : renderer(content ? {
271
266
  ...inputOrArgs,
272
267
  content
273
268
  } : inputOrArgs);
@@ -280,11 +275,11 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
280
275
  }
281
276
  return rendered ? shouldResume && writeScope(scopeId, { ["D" + accessor]: rendererKey(renderer) }) : _scope_id(), result;
282
277
  }, patchDynamicTag = /* @__PURE__ */ ((originalDynamicTag) => (patch) => {
283
- _dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, resume, tagVar) => {
278
+ _dynamic_tag = (scopeId, accessor, tag, input, content, inputIsArgs, markerGuard, tagVar) => {
284
279
  let patched = patch(tag, scopeId, accessor);
285
- return patched !== tag && (patched.a = tag), originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, resume, tagVar);
280
+ return patched !== tag && (patched.a = tag), originalDynamicTag(scopeId, accessor, patched, input, content, inputIsArgs, markerGuard, tagVar);
286
281
  };
287
- })(_dynamic_tag), CONSUMED_RESULT_MESSAGE = "Cannot read from a consumed render result", _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), kAssets = Symbol(), kHead = Symbol(), SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_ID = "$C_b", K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
282
+ })(_dynamic_tag), _template = (templateId, renderer, page) => (renderer.render = render, renderer.i = !page, renderer._ = renderer, _content_resume(templateId, renderer)), kAssets = Symbol(), kHead = Symbol(), SET_SCOPE_REGISTER_ID = "$C_s", RENDER_BODY_ID = "$C_b", K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
288
283
  $global,
289
284
  writeLoadAsset,
290
285
  fork: _await,
@@ -320,7 +315,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
320
315
  return function() {
321
316
  let compatRegistered = COMPAT_REGISTRY.get(this);
322
317
  if (!compatRegistered) {
323
- let registered = getRegistered(this);
318
+ let registered = REGISTRY.get(this);
324
319
  if (registered) {
325
320
  let scopeId = registered.scope ? getScopeId(registered.scope) : void 0;
326
321
  scopeId !== void 0 && _script(scopeId, SET_SCOPE_REGISTER_ID), COMPAT_REGISTRY.set(this, compatRegistered = [registered.id, scopeId]);
@@ -352,8 +347,8 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
352
347
  flushScript(chunk, reorders) {
353
348
  let { boundary } = chunk, { state } = boundary, html = "", scripts = "";
354
349
  if (reorders) for (let reorder of reorders) state.reorder(reorder);
355
- if (boundary.flush() === 0 && ({html, scripts} = chunk.flushScript(boundary)), boundary.aborted) throw boundary.reason;
356
- if (boundary.count) throw Error("Cannot serialize promise across tags/class compat layer.");
350
+ if (boundary.flush() === 0 && ({html, scripts} = chunk.flush(boundary)), boundary.aborted) throw boundary.reason;
351
+ if (boundary.count) throw /* @__PURE__ */ Error();
357
352
  return {
358
353
  html,
359
354
  scripts
@@ -379,7 +374,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
379
374
  writeScope(scopeId, { m5c: component.id }), _script(scopeId, SET_SCOPE_REGISTER_ID);
380
375
  }
381
376
  }), head.render(() => {
382
- _set_scope_reason(willRerender ? CLIENT_ALL : 0);
377
+ _set_scope_reason(willRerender ? ALL_GROUPS : 0);
383
378
  try {
384
379
  renderer(normalizedInput);
385
380
  } finally {
@@ -412,7 +407,7 @@ let empty = [], rest = Symbol(), unsafeStyleAttrReg = /[\\;]/g, replaceUnsafeSty
412
407
  registerClassFunctions(input) {
413
408
  for (let key in input) {
414
409
  let value = input[key];
415
- typeof value == "function" && !getRegistered(value) && register(RENDER_BODY_ID, value);
410
+ typeof value == "function" && !REGISTRY.has(value) && register(RENDER_BODY_ID, value);
416
411
  }
417
412
  },
418
413
  registerClassFunction($global, id, fn, hostId) {
@@ -439,10 +434,10 @@ function* attrTagIterator() {
439
434
  }
440
435
  //#endregion
441
436
  //#region src/common/helpers.ts
442
- function stringifyClassObject(name, value) {
437
+ function stringifyClassEntry(name, value) {
443
438
  return value ? name : "";
444
439
  }
445
- function stringifyStyleObject(name, value) {
440
+ function stringifyStyleEntry(name, value) {
446
441
  return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
447
442
  }
448
443
  function escapeStyleAttr(str) {
@@ -456,17 +451,17 @@ function escapeStyleValue(str) {
456
451
  function isEventHandler(name) {
457
452
  return /^on[A-Z-]/.test(name);
458
453
  }
459
- function getEventHandlerName(name) {
454
+ function getEventType(name) {
460
455
  return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
461
456
  }
462
457
  function hasKeys(obj) {
463
458
  for (let _ in obj) return !0;
464
459
  return !1;
465
460
  }
466
- function isVoid(value) {
461
+ function isNullishOrFalse(value) {
467
462
  return value == null || value === !1;
468
463
  }
469
- function isNotVoid(value) {
464
+ function isNotNullishOrFalse(value) {
470
465
  return value != null && value !== !1;
471
466
  }
472
467
  function isPromise(value) {
@@ -484,27 +479,9 @@ function normalizeDynamicRenderer(value) {
484
479
  function _assert_class_toggles(classes, toggles) {}
485
480
  function _el_read_error() {}
486
481
  function _hoist_read_error() {}
482
+ function _signal_read_error() {}
487
483
  function _assert_hoist(value) {}
488
484
  //#endregion
489
- //#region src/common/for.ts
490
- function forIn(obj, cb) {
491
- for (let key in obj) cb(key, obj[key]);
492
- }
493
- function forOf(list, cb) {
494
- if (list) {
495
- let i = 0;
496
- for (let item of list) cb(item, i++);
497
- }
498
- }
499
- function forTo(to, from, step, cb) {
500
- let start = from || 0, delta = step || 1;
501
- for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
502
- }
503
- function forUntil(until, from, step, cb) {
504
- let start = from || 0, delta = step || 1;
505
- for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
506
- }
507
- //#endregion
508
485
  //#region src/common/opt.ts
509
486
  function reduce(opt, cb, acc) {
510
487
  if (opt) {
@@ -534,14 +511,44 @@ var State$1 = class {
534
511
  buf = [];
535
512
  strs = /* @__PURE__ */ new Map();
536
513
  refs = /* @__PURE__ */ new WeakMap();
537
- pendingAssignments = /* @__PURE__ */ new Set();
514
+ deferredRefs = /* @__PURE__ */ new Set();
538
515
  boundary;
539
516
  channel = void 0;
540
517
  channelDeps = null;
541
- mutated = [];
518
+ queuedCalls = [];
519
+ queuedReadyCalls = [];
520
+ scopeRef(scope, scopeId) {
521
+ return this.refs.get(scope) || newScopeReference(this, scope, scopeId);
522
+ }
523
+ writeScopeProps(props, ref) {
524
+ return writeObjectProps(this, props, ref);
525
+ }
526
+ scopesCursor(scopeId) {
527
+ return scopeId + ",";
528
+ }
529
+ writeTrailing(scopesIndex) {
530
+ let { buf } = this;
531
+ return ~scopesIndex && (buf[scopesIndex] = "_([" + buf[scopesIndex], buf.push("])")), writeDeferred(this), ",0)";
532
+ }
533
+ wrapPayload(result, extras) {
534
+ let arrow = this.wroteUndefined ? "(_,$)=>" : "_=>";
535
+ return this.wroteUndefined = !1, extras ? arrow + result : arrow + "[" + result + "]";
536
+ }
537
+ writeScopedRegistration(val, parent, accessor, registered) {
538
+ let ref = new Reference(parent, accessor, this.flushId, this.buf.length);
539
+ ref.channel = this.channel, this.refs.set(val, ref);
540
+ let scope = registered.scope, scopeId = scope[K_SCOPE_ID];
541
+ trackScope(this, scope, scopeId);
542
+ let locals = registered.locals?.(this.boundary.state.scope);
543
+ if (locals) {
544
+ this.buf.push(registered.access + "(_(" + scopeId + ")");
545
+ for (let local of locals) this.buf.push(","), writePlainObject(this, local, newArgReference(this, ref, local));
546
+ } else this.buf.push("_(" + scopeId + "," + quoteRegisterId(registered.id));
547
+ this.buf.push(")");
548
+ }
542
549
  }, Reference = class {
543
550
  assignments = null;
544
- calls = null;
551
+ deferredMembers = null;
545
552
  scopeId = void 0;
546
553
  channel = void 0;
547
554
  parent;
@@ -553,136 +560,121 @@ var State$1 = class {
553
560
  constructor(parent, accessor, flushId, pos = null, id = null) {
554
561
  this.parent = parent, this.accessor = accessor, this.flushId = flushId, this.pos = pos, this.id = id;
555
562
  }
556
- }, Serializer = class {
557
- #state = new State$1();
558
- pending(channel) {
559
- return hasMatchingMutations(this.#state.mutated, channel?.readyId);
560
- }
561
- pendingReadyChannel() {
562
- for (let mutation of this.#state.mutated) if (mutation.channel?.readyId) return mutation.channel;
563
- }
564
- stringifyScopes(flushes, boundary, channel) {
565
- try {
566
- return this.#state.boundary = boundary, this.#state.channel = channel, writeScopesRoot(this.#state, flushes);
567
- } catch (err) {
568
- return abortRender(boundary, err), "";
569
- } finally {
570
- this.#state.flushId++, this.#state.buf = [];
571
- }
572
- }
573
- written(val) {
574
- return this.#state.refs.has(val);
575
- }
576
- takeChannelDeps() {
577
- let deps = this.#state.channelDeps;
578
- return this.#state.channelDeps = null, deps;
579
- }
580
- writeCall(value, object, property, channel) {
581
- this.#state.mutated.push({
582
- value,
583
- object,
584
- property,
585
- channel
586
- });
563
+ };
564
+ function stringifyScopes(state, flushes, boundary, channel) {
565
+ try {
566
+ return state.boundary = boundary, state.channel = channel, writeScopesRoot(state, flushes);
567
+ } catch (err) {
568
+ return abortRender(boundary, err), "";
569
+ } finally {
570
+ state.flushId++, state.buf = [];
587
571
  }
588
- dropCall(value, object, property) {
589
- let { mutated } = this.#state;
590
- for (let i = 0; i < mutated.length; i++) {
591
- let mutation = mutated[i];
592
- if (mutation.value === value && mutation.object === object && mutation.property === property) return mutated.splice(i, 1), !0;
593
- }
594
- return !1;
572
+ }
573
+ function pendingReadyChannel(state) {
574
+ let calls = state.queuedReadyCalls;
575
+ return calls.length ? calls[0].channel : void 0;
576
+ }
577
+ function takeChannelDeps(state) {
578
+ let deps = state.channelDeps;
579
+ return state.channelDeps = null, deps;
580
+ }
581
+ function queueCall(state, value, object, method, channel) {
582
+ (channel?.readyId ? state.queuedReadyCalls : state.queuedCalls).push({
583
+ method,
584
+ value,
585
+ object,
586
+ channel,
587
+ valueId: null
588
+ });
589
+ }
590
+ function dropQueuedCall(state, value, object, method, channel) {
591
+ let queuedCalls = channel?.readyId ? state.queuedReadyCalls : state.queuedCalls;
592
+ for (let i = 0; i < queuedCalls.length; i++) {
593
+ let call = queuedCalls[i];
594
+ if (call.value === value && call.object === object && call.method === method) return queuedCalls.splice(i, 1), !0;
595
595
  }
596
- };
597
- function register(id, val, scope, locals) {
596
+ return !1;
597
+ }
598
+ function register(id, val, scope, locals, access = "_._" + toAccess(toObjectKey(id))) {
598
599
  return REGISTRY.set(val, {
599
600
  id,
600
601
  scope,
601
602
  locals,
602
- access: "_._" + toAccess(toObjectKey(id))
603
+ access
603
604
  }), val;
604
605
  }
605
- function getRegistered(val) {
606
- let registered = REGISTRY.get(val);
607
- if (registered) return {
608
- id: registered.id,
609
- scope: registered.scope
610
- };
611
- }
612
606
  function writeScopesRoot(state, flushes) {
613
- let { buf } = state, nextSlotId = -1, fillIndex = -1;
607
+ let { buf } = state, nextSlotId = -1, scopesIndex = -1;
614
608
  for (let flush of flushes) {
615
- let scopeId = flush[0], scope = flush[1], ref = state.refs.get(scope) || newScopeReference(state, scope, scopeId), openIndex = buf.push("") - 1;
616
- writeObjectProps(state, flush[2], ref) ? (buf[openIndex] = nextSlotId === -1 ? scopeId + ",{" : (scopeId === nextSlotId ? "" : "," + (scopeId - nextSlotId)) + ",{", fillIndex === -1 && (fillIndex = openIndex), nextSlotId = scopeId + 1, buf.push("}")) : buf.pop();
609
+ let scopeId = flush[0], scope = flush[1], ref = state.scopeRef(scope, scopeId), openIndex = buf.push("") - 1;
610
+ state.writeScopeProps(flush[2], ref) ? (buf[openIndex] = nextSlotId === -1 ? state.scopesCursor(scopeId) + "{" : (scopeId === nextSlotId ? "" : "," + (scopeId - nextSlotId)) + ",{", scopesIndex === -1 && (scopesIndex = openIndex), nextSlotId = scopeId + 1, buf.push("}")) : buf.pop();
617
611
  }
618
612
  let extras = "";
619
- (state.pendingAssignments.size || hasChannelMutations(state)) && (extras = ",0)", fillIndex !== -1 && (buf[fillIndex] = "_([" + buf[fillIndex], buf.push("])")), writeAssigned(state));
613
+ (state.deferredRefs.size || hasChannelCalls(state)) && (extras = state.writeTrailing(scopesIndex));
620
614
  let result = extras && "(";
621
615
  for (let chunk of buf) result += chunk;
622
- if (result += extras, !result) return "";
623
- let arrow = state.wroteUndefined ? "(_,$)=>" : "_=>";
624
- return state.wroteUndefined = !1, extras ? arrow + result : arrow + "[" + result + "]";
616
+ return result += extras, result ? state.wrapPayload(result, extras) : "";
625
617
  }
626
- function writeAssigned(state) {
618
+ function writeDeferred(state) {
627
619
  let sep = state.buf.length ? "," : "";
628
- if (state.pendingAssignments.size) {
629
- let pending = state.pendingAssignments;
630
- state.pendingAssignments = /* @__PURE__ */ new Set();
620
+ if (state.deferredRefs.size) {
621
+ let pending = state.deferredRefs;
622
+ state.deferredRefs = /* @__PURE__ */ new Set();
631
623
  let buf = "", hasCalls = !1;
632
- for (let ref of pending) ref.assignments && (buf += sep + assignmentsToString(ref.assignments, ref.id), ref.assignments = null, sep = ","), hasCalls ||= ref.calls !== null;
633
- if (buf && state.buf.push(buf), hasCalls) {
634
- for (let ref of pending) if (ref.calls) {
635
- for (let { method, args } of ref.calls) {
636
- state.buf.push((state.buf.length ? "," : "") + ref.id + "." + method + "(");
637
- for (let a = 0; a < args.length; a++) a && state.buf.push(","), writeCallArg(state, args[a]);
638
- state.buf.push(")");
639
- }
640
- ref.calls = null;
641
- }
624
+ for (let ref of pending) ref.assignments && (buf += sep + assignmentsToString(ref.assignments, ref.id), ref.assignments = null, sep = ","), hasCalls ||= ref.deferredMembers !== null;
625
+ if (buf && state.buf.push(buf), hasCalls) for (let ref of pending) {
626
+ let members = ref.deferredMembers;
627
+ members && (writeDeferredMembers(state, ref.id, members), ref.deferredMembers = null);
642
628
  }
643
629
  }
644
- if (hasChannelMutations(state)) {
630
+ let readyId = state.channel?.readyId, calls = state.queuedCalls;
631
+ if (readyId) {
632
+ calls = [];
645
633
  let remaining = [];
646
- for (let mutation of state.mutated) {
647
- if (!mutationMatchesReadyId(mutation, state.channel?.readyId)) {
648
- remaining.push(mutation);
649
- continue;
650
- }
651
- let hasSeen = state.refs.get(mutation.object)?.id, objectStartIndex = state.buf.push(state.buf.length === 0 ? "" : ",");
652
- if (writeProp(state, mutation.object, null, "")) {
653
- let objectRef = state.refs.get(mutation.object);
654
- objectRef && objectRef.scopeId === void 0 && (!objectRef.id && !isAncestorChannelRef(state, objectRef) ? (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex], state.buf.push(")")) : hasSeen || (state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex], state.buf.push(")")));
655
- } else state.buf.push("void 0");
656
- let valueStartIndex = state.buf.push(toAccess(toObjectKey(mutation.property)) + "(");
657
- if (mutation.value !== void 0) {
658
- if (writeProp(state, mutation.value, null, "")) {
659
- let valueRef = typeof mutation.value == "string" ? state.strs.get(mutation.value) : state.refs.get(mutation.value);
660
- valueRef && !valueRef.id && valueRef.scopeId === void 0 && !isAncestorChannelRef(state, valueRef) && (valueRef.id = mutation.valueId || nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
661
- } else state.buf.push("void 0");
662
- }
663
- state.buf.push(")");
664
- }
665
- state.mutated = remaining;
634
+ for (let call of state.queuedReadyCalls) (call.channel.readyId === readyId ? calls : remaining).push(call);
635
+ state.queuedReadyCalls = remaining;
636
+ } else calls.length && (state.queuedCalls = []);
637
+ for (let call of calls) {
638
+ let objectStartIndex = state.buf.push(state.buf.length === 0 ? "" : ",");
639
+ if (writeProp(state, call.object, null, "")) {
640
+ let objectRef = state.refs.get(call.object);
641
+ !objectRef.id && !isAncestorChannelRef(state, objectRef) ? (objectRef.id = nextRefAccess(state), state.buf[objectStartIndex] = "(" + objectRef.id + "=" + state.buf[objectStartIndex], state.buf.push(")")) : objectRef.id && state.buf[objectStartIndex] !== objectRef.id && (state.buf[objectStartIndex] = "(" + state.buf[objectStartIndex], state.buf.push(")"));
642
+ } else state.buf.push("void 0");
643
+ state.buf.push("." + call.method + "("), call.value !== void 0 && writeCallArg(state, call.value, call.valueId), state.buf.push(")");
644
+ }
645
+ state.deferredRefs.size && writeDeferred(state);
646
+ }
647
+ function writeDeferredMembers(state, id, { collection, first, rest }) {
648
+ if (collection instanceof Map) {
649
+ writeDeferredEntry(state, id, first);
650
+ for (let entry of rest) writeDeferredEntry(state, id, entry);
651
+ } else {
652
+ writeDeferredMember(state, id, first);
653
+ for (let member of rest) writeDeferredMember(state, id, member);
666
654
  }
667
- state.pendingAssignments.size && writeAssigned(state);
668
655
  }
669
- function writeCallArg(state, val) {
656
+ function writeDeferredEntry(state, id, [key, value]) {
657
+ state.buf.push("," + id + ".set("), (key !== void 0 || value !== void 0) && writeCallArg(state, key, null), value !== void 0 && (state.buf.push(","), writeCallArg(state, value, null)), state.buf.push(")");
658
+ }
659
+ function writeDeferredMember(state, id, member) {
660
+ state.buf.push("," + id + ".add("), member !== void 0 && writeCallArg(state, member, null), state.buf.push(")");
661
+ }
662
+ function writeCallArg(state, val, valueId) {
663
+ let startIndex = state.buf.length;
670
664
  if (val === void 0) state.wroteUndefined = !0, state.buf.push("$");
671
665
  else if (writeProp(state, val, null, "")) {
672
- let ref = state.refs.get(val) || state.strs.get(val);
673
- ref && ensureId(state, ref);
666
+ let ref = typeof val == "string" ? state.strs.get(val) : state.refs.get(val);
667
+ ref && !ref.id && ref.scopeId === void 0 && !isAncestorChannelRef(state, ref) && (ref.id = valueId || nextRefAccess(state), state.buf[startIndex] = ref.id + "=" + state.buf[startIndex]);
674
668
  } else state.buf.push("void 0");
675
669
  }
676
- function hasChannelMutations(state) {
677
- return hasMatchingMutations(state.mutated, state.channel?.readyId);
670
+ function hasChannelCalls(state) {
671
+ return hasMatchingCalls(state, state.channel?.readyId);
678
672
  }
679
- function hasMatchingMutations(mutated, readyId) {
680
- for (let mutation of mutated) if (mutationMatchesReadyId(mutation, readyId)) return !0;
673
+ function hasMatchingCalls(state, readyId) {
674
+ if (!readyId) return state.queuedCalls.length > 0;
675
+ for (let call of state.queuedReadyCalls) if (call.channel.readyId === readyId) return !0;
681
676
  return !1;
682
677
  }
683
- function mutationMatchesReadyId(mutation, readyId) {
684
- return mutation.channel?.readyId ? mutation.channel.readyId === readyId : !readyId;
685
- }
686
678
  function writeProp(state, val, parent, accessor) {
687
679
  switch (typeof val) {
688
680
  case "string": return writeString(state, val, parent, accessor);
@@ -697,7 +689,7 @@ function writeProp(state, val, parent, accessor) {
697
689
  }
698
690
  function writeReferenceOr(state, write, val, parent, accessor) {
699
691
  let ref = state.refs.get(val);
700
- if (ref) return trackChannel(state, ref) ? parent && isCircular(parent, ref) ? (ensureId(state, ref), state.pendingAssignments.add(ref), addAssignment(ref, accessId(state, parent) + toAccess(accessor)), !1) : (writeRef(state, ref), !0) : !1;
692
+ if (ref) return trackChannel(state, ref) ? parent && isCircular(parent, ref) ? (ensureRefAccess(state, ref), state.deferredRefs.add(ref), addAssignment(ref, accessId(state, parent) + toAccess(accessor)), !1) : (writeRef(state, ref), !0) : !1;
701
693
  let registered = REGISTRY.get(val);
702
694
  return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(val, ref = new Reference(parent, accessor, state.flushId, state.buf.length)), ref.channel = state.channel, write(state, val, ref) ? !0 : (state.refs.delete(val), !1));
703
695
  }
@@ -714,19 +706,7 @@ function quoteRegisterId(id) {
714
706
  }
715
707
  function writeRegistered(state, val, parent, accessor, registered) {
716
708
  let { scope } = registered;
717
- if (scope) {
718
- let ref = new Reference(parent, accessor, state.flushId, state.buf.length);
719
- ref.channel = state.channel, state.refs.set(val, ref);
720
- let scopeId = scope[K_SCOPE_ID];
721
- trackScope(state, scope, scopeId);
722
- let locals = registered.locals?.(state.boundary.state.scope);
723
- if (locals) {
724
- state.buf.push(registered.access + "(_(" + scopeId + ")");
725
- for (let local of locals) state.buf.push(","), writePlainObject(state, local, newArgReference(state, ref, local));
726
- } else state.buf.push("_(" + scopeId + "," + quoteRegisterId(registered.id));
727
- state.buf.push(")");
728
- } else state.buf.push(registered.access);
729
- return !0;
709
+ return scope ? state.writeScopedRegistration(val, parent, accessor, registered) : state.buf.push(registered.access), !0;
730
710
  }
731
711
  function writeString(state, val, parent, accessor) {
732
712
  if (val.length > 12) {
@@ -862,7 +842,7 @@ function writeRegExp(state, val) {
862
842
  }
863
843
  function writePromise(state, val, ref) {
864
844
  let { boundary, channel } = state, pId = nextRefAccess(state), handle = newAsyncHandle(state, ref, pId);
865
- return state.buf.push("(p=>p=new Promise((f,r)=>" + pId + "={f,r(e){p.catch(_=>0);r(e)}}))()"), val.then((v) => writeAsyncCall(state, boundary, handle, "f", v, channel, pId), (v) => writeAsyncCall(state, boundary, handle, "r", v, channel, pId)), boundary.startAsync(), !0;
845
+ return state.buf.push("(p=>p=new Promise((f,r)=>" + pId + "={f,r(e){p.catch(_=>0);r(e)}}))()"), val.then((v) => queueAsyncCall(state, boundary, handle, "f", v, channel, pId), (v) => queueAsyncCall(state, boundary, handle, "r", v, channel, pId)), boundary.startAsync(), !0;
866
846
  }
867
847
  function newAsyncHandle(state, parent, id) {
868
848
  let handle = {}, handleRef = new Reference(parent, null, state.flushId, null, id);
@@ -870,23 +850,25 @@ function newAsyncHandle(state, parent, id) {
870
850
  }
871
851
  function writeMap(state, val, ref) {
872
852
  if (!val.size) return state.buf.push("new Map"), !0;
873
- let items = [], assignments, needsId, deferring = !1, i = 0;
853
+ let items = [], assignments, needsId, i = 0, entries = val.entries();
874
854
  if (val.size < 25) {
875
- for (let [itemKey, itemValue] of val) {
876
- if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) && (deferring = !0), deferring) {
877
- deferCall(state, ref, "set", [itemKey, itemValue]);
878
- continue;
855
+ for (let entry of entries) {
856
+ let [itemKey, itemValue] = entry;
857
+ if (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) {
858
+ if (deferMembers(state, ref, val, entry, entries), !i) return state.buf.push("new Map"), !0;
859
+ break;
879
860
  }
880
- itemKey === val && (itemKey = void 0, (assignments ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assignments ||= []).push("a[" + i + "][1]")), needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue), i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
861
+ itemKey === val && (itemKey = void 0, (assignments ||= []).push("a[" + i + "][0]")), itemValue === val && (itemValue = void 0, (assignments ||= []).push("a[" + i + "][1]")), needsId ||= isReusableMember(itemKey) || isReusableMember(itemValue), i = items.push(itemValue === void 0 ? itemKey === void 0 ? [] : [itemKey] : [itemKey, itemValue]);
881
862
  }
882
863
  writeArrayArg(state, ref, items, assignments && "((m,a)=>(" + assignmentsToString(assignments, "m") + ",a.forEach(i=>m.set(i[0],i[1])),m))(new Map,", "new Map(", needsId);
883
864
  } else {
884
- for (let [itemKey, itemValue] of val) {
885
- if (!deferring && (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) && (deferring = !0), deferring) {
886
- deferCall(state, ref, "set", [itemKey, itemValue]);
887
- continue;
865
+ for (let entry of entries) {
866
+ let [itemKey, itemValue] = entry;
867
+ if (itemKey !== val && isAncestorMember(state, ref, itemKey) || itemValue !== val && isAncestorMember(state, ref, itemValue)) {
868
+ if (deferMembers(state, ref, val, entry, entries), !i) return state.buf.push("new Map"), !0;
869
+ break;
888
870
  }
889
- itemKey === val && (itemKey = 0, (assignments ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assignments ||= []).push("a[" + (i + 1) + "]")), needsId ||= isDedupedMember(itemKey) || isDedupedMember(itemValue), i = items.push(itemKey, itemValue);
871
+ itemKey === val && (itemKey = 0, (assignments ||= []).push("a[" + i + "]")), itemValue === val && (itemValue = 0, (assignments ||= []).push("a[" + (i + 1) + "]")), needsId ||= isReusableMember(itemKey) || isReusableMember(itemValue), i = items.push(itemKey, itemValue);
890
872
  }
891
873
  writeArrayArg(state, ref, items, assignments && "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1])," + assignmentsToString(assignments, "new Map") + "))(", "(a=>a.reduce((m,v,i)=>i%2?m:m.set(v,a[i+1]),new Map))(", needsId);
892
874
  }
@@ -894,13 +876,13 @@ function writeMap(state, val, ref) {
894
876
  }
895
877
  function writeSet(state, val, ref) {
896
878
  if (!val.size) return state.buf.push("new Set"), !0;
897
- let items = [], assignments, needsId, deferring = !1, i = 0;
898
- for (let item of val) {
899
- if (!deferring && item !== val && isAncestorMember(state, ref, item) && (deferring = !0), deferring) {
900
- deferCall(state, ref, "add", [item]);
901
- continue;
879
+ let items = [], assignments, needsId, i = 0, members = val.values();
880
+ for (let item of members) {
881
+ if (item !== val && isAncestorMember(state, ref, item)) {
882
+ if (deferMembers(state, ref, val, item, members), !i) return state.buf.push("new Set"), !0;
883
+ break;
902
884
  }
903
- item === val ? (item = 0, (assignments ||= []).push("i[" + i + "]")) : needsId ||= isDedupedMember(item), i = items.push(item);
885
+ item === val ? (item = 0, (assignments ||= []).push("i[" + i + "]")) : needsId ||= isReusableMember(item), i = items.push(item);
904
886
  }
905
887
  return writeArrayArg(state, ref, items, assignments && "((s,i)=>(" + assignmentsToString(assignments, "s") + ",i.forEach(i=>s.add(i)),s))(new Set,", "new Set(", needsId), !0;
906
888
  }
@@ -909,11 +891,12 @@ function isAncestorMember(state, container, member) {
909
891
  let ref = state.refs.get(member);
910
892
  return ref !== void 0 && isCircular(container, ref);
911
893
  }
912
- function deferCall(state, ref, method, args) {
913
- ensureId(state, ref), (ref.calls ||= []).push({
914
- method,
915
- args
916
- }), state.pendingAssignments.add(ref);
894
+ function deferMembers(state, ref, collection, first, rest) {
895
+ ensureRefAccess(state, ref), ref.deferredMembers = {
896
+ collection,
897
+ first,
898
+ rest
899
+ }, state.deferredRefs.add(ref);
917
900
  }
918
901
  function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
919
902
  if (assignsPrefix || needsId) {
@@ -925,14 +908,14 @@ function writeArrayArg(state, ref, items, assignsPrefix, plainPrefix, needsId) {
925
908
  function newArgReference(state, parent, val) {
926
909
  for (let key in val) {
927
910
  let member = val[key];
928
- if (isDedupedMember(member) && !(typeof member == "string" ? state.strs.has(member) : state.refs.has(member))) {
911
+ if (isReusableMember(member) && !(typeof member == "string" ? state.strs.has(member) : state.refs.has(member))) {
929
912
  let ref = new Reference(parent, null, state.flushId, null, nextRefAccess(state));
930
913
  return state.buf.push(ref.id + "="), ref;
931
914
  }
932
915
  }
933
916
  return new Reference(parent, null, state.flushId, state.buf.length);
934
917
  }
935
- function isDedupedMember(val) {
918
+ function isReusableMember(val) {
936
919
  switch (typeof val) {
937
920
  case "object": return val !== null && val[K_SCOPE_ID] === void 0;
938
921
  case "function":
@@ -985,7 +968,7 @@ function writeAggregateError(state, val, ref) {
985
968
  let inlined = writeProp(state, val.errors, ref, "errors");
986
969
  if (inlined || state.buf.push("[]"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), inlined) {
987
970
  let errorsRef = state.refs.get(val.errors);
988
- errorsRef?.id && (state.pendingAssignments.add(errorsRef), addAssignment(errorsRef, accessId(state, ref) + toAccess("errors")));
971
+ errorsRef?.id && (state.deferredRefs.add(errorsRef), addAssignment(errorsRef, accessId(state, ref) + toAccess("errors")));
989
972
  }
990
973
  return !0;
991
974
  }
@@ -1014,7 +997,7 @@ function writeRequest(state, val, ref) {
1014
997
  let options = "";
1015
998
  val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
1016
999
  let seenHeaders = state.refs.get(val.headers);
1017
- if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders), sep = ",";
1000
+ if (seenHeaders) options += sep + "headers:" + ensureRefAccess(state, seenHeaders), sep = ",";
1018
1001
  else {
1019
1002
  state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
1020
1003
  let headers = stringEntriesToHeadersInit(val.headers);
@@ -1026,7 +1009,7 @@ function writeResponse(state, val, ref) {
1026
1009
  let sep = "", options = "";
1027
1010
  val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
1028
1011
  let seenHeaders = state.refs.get(val.headers);
1029
- if (seenHeaders) options += sep + "headers:" + ensureId(state, seenHeaders);
1012
+ if (seenHeaders) options += sep + "headers:" + ensureRefAccess(state, seenHeaders);
1030
1013
  else {
1031
1014
  state.refs.set(val.headers, new Reference(ref, "headers", state.flushId, null));
1032
1015
  let headers = stringEntriesToHeadersInit(val.headers);
@@ -1049,9 +1032,9 @@ function writeTemporal(state, val, name) {
1049
1032
  function writeReadableStream(state, val, ref) {
1050
1033
  if (val.locked) return !1;
1051
1034
  let { boundary, channel } = state, reader = val.getReader(), iterId = nextRefAccess(state), handle = newAsyncHandle(state, ref, iterId), onFulfilled = ({ value, done }) => {
1052
- done ? writeAsyncCall(state, boundary, handle, "r", value, channel) : boundary.aborted || (reader.read().then(onFulfilled, onRejected), boundary.startAsync(), writeAsyncCall(state, boundary, handle, "f", value, channel));
1035
+ done ? queueAsyncCall(state, boundary, handle, "r", value, channel) : boundary.aborted || (reader.read().then(onFulfilled, onRejected), boundary.startAsync(), queueAsyncCall(state, boundary, handle, "f", value, channel));
1053
1036
  }, onRejected = (reason) => {
1054
- writeAsyncCall(state, boundary, handle, "j", reason, channel);
1037
+ queueAsyncCall(state, boundary, handle, "j", reason, channel);
1055
1038
  };
1056
1039
  return state.buf.push("new ReadableStream({start(c){(async(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()]))=>{for(i of a)v=await i,i==l?c.close():c.enqueue(v)})(" + iterId + "={}).catch(e=>c.error(e))}})"), reader.read().then(onFulfilled, onRejected), boundary.startAsync(), !0;
1057
1040
  }
@@ -1064,7 +1047,7 @@ function writeGenerator(state, iter, ref) {
1064
1047
  returnValue = value;
1065
1048
  break;
1066
1049
  }
1067
- needsId ||= isDedupedMember(value), yields.push(value);
1050
+ needsId ||= isReusableMember(value), yields.push(value);
1068
1051
  }
1069
1052
  if (returnValue === void 0 && !yields.length) return state.buf.push("(function*(){})()"), !0;
1070
1053
  let heldReturn = returnValue !== void 0 && isAncestorMember(state, ref, returnValue);
@@ -1075,18 +1058,18 @@ function writeGenerator(state, iter, ref) {
1075
1058
  if (heldReturn) {
1076
1059
  let holder = new Reference(ref, null, state.flushId, null, nextRefAccess(state));
1077
1060
  state.buf.push("," + holder.id + "={}"), writeProp(state, returnValue, holder, "v");
1078
- } else if (returnValue !== void 0 && (state.buf.push(","), writeProp(state, returnValue, ref, "") && isDedupedMember(returnValue))) {
1061
+ } else if (returnValue !== void 0 && (state.buf.push(","), writeProp(state, returnValue, ref, "") && isReusableMember(returnValue))) {
1079
1062
  let retRef = typeof returnValue == "string" ? state.strs.get(returnValue) : state.refs.get(returnValue);
1080
- retRef && ensureId(state, retRef);
1063
+ retRef && ensureRefAccess(state, retRef);
1081
1064
  }
1082
1065
  return state.buf.push(")"), !0;
1083
1066
  }
1084
1067
  function writeAsyncGenerator(state, iter, ref) {
1085
1068
  if (iter[kTouchedIterator]) return state.buf.push("(async function*(){}())"), !0;
1086
1069
  let { boundary, channel } = state, iterId = nextRefAccess(state), handle = newAsyncHandle(state, ref, iterId), onFulfilled = ({ value, done }) => {
1087
- done ? writeAsyncCall(state, boundary, handle, "r", value, channel) : boundary.aborted || (iter.next().then(onFulfilled, onRejected), boundary.startAsync(), writeAsyncCall(state, boundary, handle, "f", value, channel));
1070
+ done ? queueAsyncCall(state, boundary, handle, "r", value, channel) : boundary.aborted || (iter.next().then(onFulfilled, onRejected), boundary.startAsync(), queueAsyncCall(state, boundary, handle, "f", value, channel));
1088
1071
  }, onRejected = (reason) => {
1089
- writeAsyncCall(state, boundary, handle, "j", reason, channel);
1072
+ queueAsyncCall(state, boundary, handle, "j", reason, channel);
1090
1073
  };
1091
1074
  return state.buf.push("(async function*(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()])){for(i of a)v=await i,i!=l&&(yield v);return v})(" + iterId + "={})"), iter.next().then(onFulfilled, onRejected), boundary.startAsync(), !0;
1092
1075
  }
@@ -1114,11 +1097,11 @@ function writeMaybeIterableProps(state, val, ref) {
1114
1097
  }
1115
1098
  return sep;
1116
1099
  }
1117
- function writeAsyncCall(state, boundary, handle, method, value, channel, valueId = null) {
1118
- boundary.aborted || (state.mutated.push({
1100
+ function queueAsyncCall(state, boundary, handle, method, value, channel, valueId = null) {
1101
+ boundary.aborted || ((channel?.readyId ? state.queuedReadyCalls : state.queuedCalls).push({
1102
+ method,
1119
1103
  value,
1120
1104
  object: handle,
1121
- property: method,
1122
1105
  channel,
1123
1106
  valueId
1124
1107
  }), boundary.endAsync());
@@ -1219,16 +1202,16 @@ function quote(str, startPos) {
1219
1202
  return "\"" + (lastPos === startPos ? str : result + str.slice(lastPos)) + "\"";
1220
1203
  }
1221
1204
  function writeRef(state, ref) {
1222
- ref.id === null && ref.scopeId === void 0 && ref.path === null && (ref.pos === null || ref.flushId !== state.flushId) && !isAncestorChannelRef(state, ref) ? (ref.path = accessPath(state, ref), ref.pos = state.buf.length, ref.flushId = state.flushId, state.buf.push(ref.path)) : state.buf.push(ensureId(state, ref));
1205
+ ref.id === null && ref.scopeId === void 0 && ref.path === null && (ref.pos === null || ref.flushId !== state.flushId) && !isAncestorChannelRef(state, ref) ? (ref.path = accessPath(state, ref), ref.pos = state.buf.length, ref.flushId = state.flushId, state.buf.push(ref.path)) : state.buf.push(ensureRefAccess(state, ref));
1223
1206
  }
1224
- function ensureId(state, ref) {
1225
- return ref.scopeId === void 0 ? ref.id ? (trackChannel(state, ref), ref.id) : assignId(state, ref) : (trackChannel(state, ref), "_(" + ref.scopeId + ")");
1207
+ function ensureRefAccess(state, ref) {
1208
+ return ref.scopeId === void 0 ? ref.id ? (trackChannel(state, ref), ref.id) : claimRefAccess(state, ref) : (trackChannel(state, ref), "_(" + ref.scopeId + ")");
1226
1209
  }
1227
1210
  function accessId(state, ref) {
1228
- let id = ensureId(state, ref);
1211
+ let id = ensureRefAccess(state, ref);
1229
1212
  return id === ref.id || ref.scopeId !== void 0 ? id : "(" + id + ")";
1230
1213
  }
1231
- function assignId(state, ref) {
1214
+ function claimRefAccess(state, ref) {
1232
1215
  let { pos } = ref;
1233
1216
  return pos !== null && ref.flushId === state.flushId ? (ref.id = nextRefAccess(state), pos === 0 ? state.buf[0] = ref.id + "=" + state.buf[0] : state.buf[pos - 1] += ref.id + "=", ref.id) : isAncestorChannelRef(state, ref) ? ref.path || accessPath(state, ref) : (ref.id = nextRefAccess(state), ref.id + "=" + (ref.path || accessPath(state, ref)));
1234
1217
  }
@@ -1295,10 +1278,10 @@ function patchIteratorNext(proto) {
1295
1278
  //#endregion
1296
1279
  //#region src/html/attrs.ts
1297
1280
  function _attr_class(value) {
1298
- return stringAttr("class", toDelimitedString(value, " ", stringifyClassObject));
1281
+ return stringAttr("class", toDelimitedString(value, " ", stringifyClassEntry));
1299
1282
  }
1300
1283
  function _attr_style(value) {
1301
- return stringAttr("style", toDelimitedString(value, ";", stringifyStyleObject));
1284
+ return stringAttr("style", toDelimitedString(value, ";", stringifyStyleEntry));
1302
1285
  }
1303
1286
  function _attr_option_value(value) {
1304
1287
  let valueAttr = _attr("value", value), selectedValue = getContext(kSelectedValue);
@@ -1324,7 +1307,7 @@ function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeT
1324
1307
  return valueChange && writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType), _attr("value", value);
1325
1308
  }
1326
1309
  function _attr_input_checked(scopeId, nodeAccessor, checked, checkedChange, serializeType) {
1327
- return checkedChange && writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType), isNotVoid(checked) ? " checked" : "";
1310
+ return checkedChange && writeControlledScope(0, scopeId, nodeAccessor, void 0, checkedChange, serializeType), isNotNullishOrFalse(checked) ? " checked" : "";
1328
1311
  }
1329
1312
  function _attr_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value, serializeType) {
1330
1313
  let valueAttr = _attr("value", value);
@@ -1337,7 +1320,7 @@ function getCheckedValueRef(checkedValue) {
1337
1320
  }
1338
1321
  }
1339
1322
  function _attr_details_or_dialog_open(scopeId, nodeAccessor, open, openChange, serializeType) {
1340
- let normalizedOpen = isNotVoid(open);
1323
+ let normalizedOpen = isNotNullishOrFalse(open);
1341
1324
  return openChange && writeControlledScope(4, scopeId, nodeAccessor, normalizedOpen || void 0, openChange, serializeType), normalizedOpen ? " open" : "";
1342
1325
  }
1343
1326
  function _attr_nonce() {
@@ -1348,7 +1331,7 @@ function _style_html(decls) {
1348
1331
  return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
1349
1332
  }
1350
1333
  function _attr(name, value) {
1351
- return isVoid(value) ? "" : nonVoidAttr(name, value);
1334
+ return isNullishOrFalse(value) ? "" : stringifyAttr(name, value);
1352
1335
  }
1353
1336
  function _attr_and(name, value, attr) {
1354
1337
  return value ? attr : _attr(name, value);
@@ -1384,7 +1367,7 @@ function _attrs(data, nodeAccessor, scopeId, tagName) {
1384
1367
  case "style":
1385
1368
  result += _attr_style(value);
1386
1369
  break;
1387
- default: name && !(isVoid(value) || skip.test(name) || name === "content" && tagName !== "meta") && (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, { ["I" + nodeAccessor]: events })), events[getEventHandlerName(name)] = value) : result += nonVoidAttr(name, value));
1370
+ default: name && !(isNullishOrFalse(value) || skip.test(name) || name === "content" && tagName !== "meta") && (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, { ["I" + nodeAccessor]: events })), events[getEventType(name)] = value) : result += stringifyAttr(name, value));
1388
1371
  }
1389
1372
  }
1390
1373
  return result;
@@ -1395,7 +1378,7 @@ function _attrs_content(data, nodeAccessor, scopeId, tagName, markerGuard) {
1395
1378
  function _attrs_partial(data, skip, nodeAccessor, scopeId, tagName) {
1396
1379
  let partial = {};
1397
1380
  for (let name in data) {
1398
- let key = isEventHandler(name) ? `on-${getEventHandlerName(name)}` : name;
1381
+ let key = isEventHandler(name) ? `on-${getEventType(name)}` : name;
1399
1382
  skip[key] || (partial[key] = data[name]);
1400
1383
  }
1401
1384
  return _attrs(partial, nodeAccessor, scopeId, tagName);
@@ -1416,7 +1399,7 @@ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange, s
1416
1399
  function stringAttr(name, value) {
1417
1400
  return value && " " + name + attrAssignment(value);
1418
1401
  }
1419
- function nonVoidAttr(name, value) {
1402
+ function stringifyAttr(name, value) {
1420
1403
  switch (typeof value) {
1421
1404
  case "string": return " " + name + attrAssignment(value);
1422
1405
  case "boolean": return " " + name;
@@ -1447,18 +1430,7 @@ function normalizedValueMatches(a, b) {
1447
1430
  return !1;
1448
1431
  }
1449
1432
  function normalizeStrAttrValue(value) {
1450
- return isNotVoid(value) && value !== !0 ? value + "" : "";
1451
- }
1452
- //#endregion
1453
- //#region src/html/for.ts
1454
- function forOfBy(by, item, index) {
1455
- return by ? typeof by == "string" ? item[by] : by(item, index) : index;
1456
- }
1457
- function forInBy(by, name, value) {
1458
- return by ? by(name, value) : name;
1459
- }
1460
- function forStepBy(by, index) {
1461
- return by ? by(index) : index;
1433
+ return isNotNullishOrFalse(value) && value !== !0 ? value + "" : "";
1462
1434
  }
1463
1435
  //#endregion
1464
1436
  //#region src/html/inlined-runtimes.ts
@@ -1504,11 +1476,11 @@ function _scope_id() {
1504
1476
  function _peek_scope_id() {
1505
1477
  return $chunk.boundary.state.scopeId;
1506
1478
  }
1507
- function withContext(key, value, cb, cbValue) {
1479
+ function withContext(key, value, cb, cbValue, cbValue2) {
1508
1480
  let ctx = $chunk.context ||= { [kPendingContexts]: 0 }, prev = ctx[key];
1509
1481
  ctx[kPendingContexts]++, ctx[key] = value;
1510
1482
  try {
1511
- return cb(cbValue);
1483
+ return cb(cbValue, cbValue2);
1512
1484
  } finally {
1513
1485
  ctx[kPendingContexts]--, ctx[key] = prev;
1514
1486
  }
@@ -1522,11 +1494,11 @@ function captureContext(chunk) {
1522
1494
  function isInResumedBranch() {
1523
1495
  return $chunk?.context?.[kBranchId] !== void 0;
1524
1496
  }
1525
- function withBranchId(branchId, cb, cbValue) {
1526
- return withContext(kBranchId, branchId, cb, cbValue);
1497
+ function withBranchId(branchId, cb, cbValue, cbValue2) {
1498
+ return withContext(kBranchId, branchId, cb, cbValue, cbValue2);
1527
1499
  }
1528
- function withIsAsync(async, cb, value) {
1529
- return withContext(kIsAsync, async, cb, value);
1500
+ function withAsyncContent(async, cb, value) {
1501
+ return withContext(kAsyncContent, async, cb, value);
1530
1502
  }
1531
1503
  function _html(html) {
1532
1504
  $chunk.writeHTML(html);
@@ -1544,7 +1516,7 @@ function mayDrop(written) {
1544
1516
  return !1;
1545
1517
  }
1546
1518
  function _script(scopeId, registryId, markerGuard) {
1547
- markerGuard === 0 && ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) && _resume_branch(scopeId), $chunk.boundary.state.needsMainRuntime = !0, $chunk.writeEffect(scopeId, registryId);
1519
+ markerGuard === 0 && ($chunk.channel.readyId || $chunk.context?.[kAsyncContent]) && _resume_branch(scopeId), $chunk.boundary.state.queueEffect(scopeId, registryId);
1548
1520
  }
1549
1521
  function _trailers(html) {
1550
1522
  $chunk.boundary.state.trailerHTML += html;
@@ -1562,24 +1534,24 @@ function _hoist(scopeId, id) {
1562
1534
  let getter = () => void 0;
1563
1535
  return getter[Symbol.iterator] = _hoist_read_error, _resume(getter, id, scopeId);
1564
1536
  }
1565
- function _el_resume(scopeId, accessor, shouldResume) {
1566
- if (shouldResume === 0) return "";
1537
+ function _el_resume(scopeId, accessor, markerGuard) {
1538
+ if (markerGuard === 0) return "";
1567
1539
  let { state } = $chunk.boundary;
1568
- return state.needsMainRuntime = !0, state.mark("$", scopeId + " " + accessor);
1540
+ return state.needsWalkerRuntime = !0, state.mark("$", scopeId + " " + accessor);
1569
1541
  }
1570
- function _text_resume(scopeId, accessor, val, shouldResume) {
1571
- return markText(scopeId, accessor, _escape(val), shouldResume);
1542
+ function _text_resume(scopeId, accessor, val, markerGuard) {
1543
+ return markText(scopeId, accessor, _escape(val), markerGuard);
1572
1544
  }
1573
- function _html_resume(scopeId, accessor, val, shouldResume) {
1545
+ function _html_resume(scopeId, accessor, val, markerGuard) {
1574
1546
  let html = _unescaped(val);
1575
- if (shouldResume === 0 || !~html.indexOf("<")) return markText(scopeId, accessor, html, shouldResume);
1547
+ if (markerGuard === 0 || !~html.indexOf("<")) return markText(scopeId, accessor, html, markerGuard);
1576
1548
  let { state } = $chunk.boundary;
1577
- return state.needsMainRuntime = !0, state.mark("&", "") + html + state.mark("'", scopeId + " " + accessor);
1549
+ return state.needsWalkerRuntime = !0, state.mark("&", "") + html + state.mark("'", scopeId + " " + accessor);
1578
1550
  }
1579
- function markText(scopeId, accessor, text, shouldResume) {
1580
- if (shouldResume === 0) return text;
1551
+ function markText(scopeId, accessor, text, markerGuard) {
1552
+ if (markerGuard === 0) return text;
1581
1553
  let { state } = $chunk.boundary;
1582
- return state.needsMainRuntime = !0, text ? (shouldResume === 2 ? "<!>" : "") + text + state.mark("$", scopeId + " " + accessor) : state.mark("%", scopeId + " " + accessor);
1554
+ return state.needsWalkerRuntime = !0, text ? (markerGuard === 2 ? "<!>" : "") + text + state.mark("$", scopeId + " " + accessor) : state.mark("%", scopeId + " " + accessor);
1583
1555
  }
1584
1556
  function _resume_branch(scopeId) {
1585
1557
  let branchId = $chunk.context?.[kBranchId];
@@ -1588,7 +1560,7 @@ function _resume_branch(scopeId) {
1588
1560
  function _attr_content(nodeAccessor, scopeId, content, markerGuard) {
1589
1561
  let shouldResume = markerGuard !== 0, render = normalizeServerRender(content), branchId = _peek_scope_id();
1590
1562
  if (render) try {
1591
- _set_scope_reason(shouldResume ? CLIENT_ALL : 0), shouldResume ? withBranchId(branchId, render) : render();
1563
+ _set_scope_reason(shouldResume ? ALL_GROUPS : 0), shouldResume ? withBranchId(branchId, render) : render();
1592
1564
  } finally {
1593
1565
  _set_scope_reason(void 0);
1594
1566
  }
@@ -1607,83 +1579,8 @@ function _var(parentScopeId, scopeOffsetAccessor, childScopeId, registryId, node
1607
1579
  nodeAccessor !== void 0 && writeScope(parentScopeId, { ["A" + nodeAccessor]: childScope });
1608
1580
  }
1609
1581
  function writeScopePassive(scopeId, partialScope) {
1610
- let target = $chunk.serializeState, scope = _scope_with_id(scopeId), passive = target.passiveScopes ||= {};
1611
- return Object.assign(scope, partialScope), passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope), scope;
1612
- }
1613
- function _show_start(display, markerGuard, branchExprGuard, parentEndTag) {
1614
- display ? resumesMarker(markerGuard, branchExprGuard, parentEndTag) && $chunk.writeHTML($chunk.boundary.state.mark("[", "")) : $chunk.writeHTML("<t hidden>");
1615
- }
1616
- function _show_end(scopeId, accessor, display, markerGuard, branchExprGuard, parentEndTag, singleNode) {
1617
- let branchId = _scope_id(), wrap = !display;
1618
- wrap && $chunk.writeHTML("</t>"), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
1619
- }
1620
- function _for_of(list, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
1621
- forBranches(by, (each) => each ? forOf(list, (item, index) => {
1622
- let itemKey = forOfBy(by, item, index);
1623
- each(itemKey, itemKey === index, () => cb(item, index));
1624
- }) : forOf(list, cb), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
1625
- }
1626
- function _for_in(obj, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
1627
- forBranches(by, (each) => each ? forIn(obj, (key, value) => {
1628
- each(forInBy(by, key, value), !1, () => cb(key, value));
1629
- }) : forIn(obj, cb), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
1630
- }
1631
- function _for_to(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
1632
- forBranches(by, (each) => {
1633
- let index = 0;
1634
- return each ? forTo(to, from, step, (value) => {
1635
- let itemKey = forStepBy(by, value);
1636
- each(itemKey, itemKey === index++, () => cb(value));
1637
- }) : forTo(to, from, step, cb);
1638
- }, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
1639
- }
1640
- function _for_until(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
1641
- forBranches(by, (each) => {
1642
- let index = 0;
1643
- return each ? forUntil(to, from, step, (value) => {
1644
- let itemKey = forStepBy(by, value);
1645
- each(itemKey, itemKey === index++, () => cb(value));
1646
- }) : forUntil(to, from, step, cb);
1647
- }, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
1648
- }
1649
- function forBranches(by, iterate, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
1650
- if (branchGuard === 0) {
1651
- iterate(0), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, "");
1652
- return;
1653
- }
1654
- let { state } = $chunk.boundary, resumeKeys = markerGuard !== 0, resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag), flushBranchIds = "", loopScopes;
1655
- iterate((itemKey, sameAsIndex, render) => {
1656
- let branchId = _peek_scope_id();
1657
- resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, () => {
1658
- render();
1659
- let branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { M: itemKey } : {});
1660
- resumeMarker || (loopScopes = push(loopScopes, branchScope));
1661
- });
1662
- }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes }), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
1663
- }
1664
- function _if(cb, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
1665
- let resumeBranch = branchGuard !== 0, resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag), branchId = _peek_scope_id(), chunk = $chunk, beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0, branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
1666
- beforeBranch !== void 0 && applyBranchStart(chunk, beforeBranch, shouldWriteBranch), shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
1667
- ["D" + accessor]: branchIndex || void 0,
1668
- ["A" + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
1669
- }), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
1670
- }
1671
- function deferBranchStart(chunk) {
1672
- let beforeBranch = chunk.html;
1673
- return chunk.html = "", beforeBranch;
1674
- }
1675
- function applyBranchStart(chunk, beforeBranch, rendered) {
1676
- chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
1677
- }
1678
- function resumesMarker(markerGuard, branchExprGuard, parentEndTag) {
1679
- return markerGuard !== 0 && (!parentEndTag || branchExprGuard !== 0);
1680
- }
1681
- function writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, branchIds) {
1682
- let endTag = parentEndTag || "";
1683
- if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) {
1684
- let { state } = $chunk.boundary, mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
1685
- $chunk.writeHTML(mark + endTag);
1686
- } else markerGuard === 0 ? $chunk.writeHTML(endTag) : $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
1582
+ let target = $chunk.channel, scope = _scope_with_id(scopeId);
1583
+ return Object.assign(scope, partialScope), $chunk.boundary.state.queuePassiveScope(target, scopeId, partialScope), scope;
1687
1584
  }
1688
1585
  function _existing_scope(scopeId) {
1689
1586
  return writeScope(scopeId, {});
@@ -1697,13 +1594,13 @@ function scopeWithId(state, scopeId) {
1697
1594
  }
1698
1595
  function _subscribe(subscribers, scope, resumeId, markerGuard) {
1699
1596
  if (subscribers) {
1700
- let { boundary, serializeState } = $chunk, { serializer } = boundary.state;
1701
- !serializeState.readyId && !serializer.written(subscribers) ? subscribers.add(scope) : resumeId ? _script(scope[K_SCOPE_ID], resumeId, markerGuard) : serializer.writeCall(scope, subscribers, "add", serializeState), boundary.withinCatch && (boundary.subscribed ||= []).push(subscribers, scope, serializeState);
1597
+ let { boundary, channel } = $chunk, { serializer } = boundary.state;
1598
+ !channel.readyId && !serializer.refs.has(subscribers) ? subscribers.add(scope) : resumeId ? _script(scope[K_SCOPE_ID], resumeId, markerGuard) : queueCall(serializer, scope, subscribers, "add", channel), boundary.withinCatch && (boundary.subscribed ||= []).push(subscribers, scope, channel);
1702
1599
  }
1703
1600
  return scope;
1704
1601
  }
1705
- function maskGroup(mask, group) {
1706
- return mask === 715827883 ? 1 : typeof mask == "number" ? group < 15 ? mask >>> 1 + 2 * group & 3 : 0 : mask[group] ?? 0;
1602
+ function getGroupReason(reason, group) {
1603
+ return reason === 715827883 ? 1 : typeof reason == "number" ? group < 15 ? reason >>> 1 + 2 * group & 3 : 0 : reason[group] ?? 0;
1707
1604
  }
1708
1605
  function _set_scope_reason(reason) {
1709
1606
  $chunk.boundary.state.scopeReason = reason;
@@ -1712,148 +1609,65 @@ function _scope_reason() {
1712
1609
  let reason = $chunk.boundary.state.scopeReason;
1713
1610
  return $chunk.boundary.state.scopeReason = void 0, reason;
1714
1611
  }
1715
- function _write_if(condition, key) {
1716
- return condition && maskGroup(condition, key) ? 1 : void 0;
1612
+ function _write_if(reason, group) {
1613
+ return reason && getGroupReason(reason, group) ? 1 : void 0;
1717
1614
  }
1718
- function _write_guard(condition, key) {
1719
- return _write_if(condition, key) || 0;
1615
+ function _write_guard(reason, group) {
1616
+ return _write_if(reason, group) || 0;
1720
1617
  }
1721
1618
  function writeWaitReady(readyId, renderer, input) {
1722
1619
  let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context, {
1723
1620
  readyId,
1724
- parent: chunk.serializeState,
1621
+ parent: chunk.channel,
1725
1622
  resumes: "",
1726
1623
  writeScopes: {},
1727
1624
  flushScopes: !1
1728
1625
  }), bodyEnd = body.render(renderer, input);
1729
1626
  if (boundary.aborted) throw boundary.reason;
1730
- body === bodyEnd ? (chunk.writeHTML(body.html), body.deferOwnReady(), chunk.deferredReady = push(chunk.deferredReady, body)) : (bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next), chunk.next = body);
1731
- }
1732
- function _await(scopeId, accessor, promise, content, markerGuard) {
1733
- let resumeMarker = markerGuard !== 0;
1734
- if (!isPromise(promise)) {
1735
- if (resumeMarker) {
1736
- let branchId = _peek_scope_id();
1737
- $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withBranchId(branchId, content, promise), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1738
- } else content(promise);
1739
- return;
1740
- }
1741
- let chunk = $chunk, { boundary } = chunk, startId = _peek_scope_id(), after = chunk.next = $chunk = chunk.fork(boundary, chunk.next);
1742
- chunk.async = !0, captureContext(chunk), boundary.startAsync(), promise.then((value) => {
1743
- if (chunk.async && (chunk.async = !1, !boundary.aborted)) {
1744
- let { state } = boundary;
1745
- chunk.render(() => {
1746
- if (resumeMarker) {
1747
- let branchId = _peek_scope_id();
1748
- $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withBranchId(branchId, () => withIsAsync({ parent: getAsyncContent(chunk) }, content, value)), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
1749
- } else {
1750
- let renderedSince = _peek_scope_id() !== startId, async = { parent: getAsyncContent(chunk) };
1751
- withIsAsync(async, content, value), async.visit = renderedSince && (after.html || after.next) ? $chunk.boundary.state.mark("]", scopeId + " " + accessor) : "", async.resumed && $chunk.writeHTML(async.visit), async.end = $chunk;
1752
- }
1753
- }), !chunk.async && boundary.pendingReorders?.delete(chunk) && state.reorder(chunk), boundary.endAsync();
1754
- }
1755
- }, (err) => {
1756
- chunk.async = !1, boundary.abort(err);
1757
- });
1627
+ body === bodyEnd ? (chunk.writeHTML(body.html), body.deferOwnReady(), chunk.deferredReady = push(chunk.deferredReady, body)) : (bodyEnd.next = chunk.forkRest(boundary), chunk.next = body);
1758
1628
  }
1759
- function _try(scopeId, accessor, content, placeholderContent, catchContent, placeholderId, catchId) {
1760
- let placeholderBranchId = placeholderContent ? _scope_id() : 0, branchId = _peek_scope_id(), chunk = $chunk, { boundary } = chunk, { state } = boundary, { resumeWrites } = boundary, beforeBranch = deferBranchStart(chunk), renderers = () => writeTryRenderers(branchId, catchContent && _resume(catchContent, catchId), placeholderContent && _resume(placeholderContent, placeholderId)), renderersWritten = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, branchId, renderers), rendered = chunk !== $chunk || boundary.resumeWrites !== resumeWrites;
1761
- applyBranchStart(chunk, beforeBranch, rendered), rendered && (renderersWritten || renderers(), $chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId)));
1762
- }
1763
- function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBranchId) {
1764
- let chunk = $chunk, { boundary } = chunk, body = chunk.fork(boundary, null);
1765
- if (body === body.render(content)) {
1766
- chunk.append(body);
1767
- return;
1768
- }
1769
- chunk.next = $chunk = chunk.fork(boundary, chunk.next), captureContext(chunk), chunk.placeholder = {
1770
- body,
1771
- render: placeholder,
1772
- branchId,
1773
- scopeId,
1774
- placeholderBranchId
1775
- };
1629
+ function deferBranchStart(chunk) {
1630
+ let beforeBranch = chunk.html;
1631
+ return chunk.html = "", beforeBranch;
1776
1632
  }
1777
- function tryBoundary(content, catchContent, branchId, renderers) {
1778
- let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state, void 0, boundary);
1779
- catchContent && (catchBoundary.withinCatch = !0);
1780
- let body = chunk.fork(catchBoundary, null), bodyEnd = body.render(() => withBranchId(branchId, content));
1781
- if (catchBoundary.aborted) {
1782
- if (!catchContent) throw catchBoundary.reason;
1783
- return catchContent(catchBoundary.reason), !0;
1784
- }
1785
- if (body === bodyEnd) return chunk.append(body), !1;
1786
- let renderersAtSettle = !catchBoundary.resumeWrites, bodyNext = bodyEnd.next = $chunk = chunk.fork(boundary, chunk.next);
1787
- chunk.next = body, boundary.startAsync();
1788
- let reorderId = catchContent ? state.nextReorderId() : "";
1789
- return reorderId && (chunk.catchRange = {
1790
- id: reorderId,
1791
- end: bodyEnd
1792
- }, captureContext(chunk)), catchBoundary.onNext = () => {
1793
- if (!boundary.aborted) {
1794
- if (catchBoundary.aborted) {
1795
- if (!reorderId) {
1796
- boundary.abort(catchBoundary.reason);
1797
- return;
1798
- }
1799
- let streamed = !chunk.catchRange, catchChunk = chunk.fork(boundary, null);
1800
- chunk.catchRange = null, renderersAtSettle || catchChunk.render(clearTryRenderers, branchId);
1801
- let inOrder = catchChunk === catchChunk.render(catchContent, catchBoundary.reason);
1802
- if (boundary.aborted) return;
1803
- if ((bodyEnd.consumed || !inOrder) && (catchChunk.reorderBranch = branchId), bodyEnd.consumed) catchChunk.reorderId = reorderId, state.reorder(catchChunk);
1804
- else {
1805
- let reorder = null;
1806
- inOrder ? streamed && (reorder = chunk.fork(boundary, null)) : reorder = catchChunk, reorder && (reorder.reorderId = reorderId);
1807
- let endMarker = state.mark("!", reorderId), cut = body;
1808
- for (; cut.consumed;) cut = cut.next;
1809
- cut.async = !1, cut.next = inOrder ? catchChunk : bodyNext, cut.html = streamed ? endMarker : inOrder ? "" : state.mark("!^", reorderId) + endMarker, cut.scripts = cut.effects = cut.lastEffect = "", cut.placeholder = cut.reorderId = cut.catchRange = null, cut.deferredReorder = reorder, inOrder && (catchChunk.next = bodyNext);
1810
- }
1811
- boundary.endAsync();
1812
- } else catchBoundary.count ? boundary.onNext() : (renderersAtSettle && catchBoundary.resumeWrites && bodyEnd.render(renderers), chunk.catchRange = null, boundary.endAsync());
1813
- }
1814
- }, renderersAtSettle;
1633
+ function applyBranchStart(chunk, beforeBranch, rendered) {
1634
+ chunk.html = beforeBranch + (rendered ? chunk.boundary.state.mark("[", "") : "") + chunk.html;
1815
1635
  }
1816
1636
  function unsubscribe(subscribed, serializer) {
1817
1637
  for (let i = 0; i < subscribed.length; i += 3) {
1818
1638
  let subscribers = subscribed[i], scope = subscribed[i + 1];
1819
- serializer.written(subscribers) ? serializer.dropCall(scope, subscribers, "add") || serializer.writeCall(scope, subscribers, "delete", subscribed[i + 2]) : subscribers.delete(scope);
1639
+ if (!serializer.refs.has(subscribers)) subscribers.delete(scope);
1640
+ else {
1641
+ let channel = subscribed[i + 2];
1642
+ dropQueuedCall(serializer, scope, subscribers, "add", channel) || queueCall(serializer, scope, subscribers, "delete", channel);
1643
+ }
1820
1644
  }
1821
1645
  }
1822
- function clearTryRenderers(branchId) {
1823
- writeScope(branchId, {
1824
- E: 0,
1825
- Q: _scope_with_id(branchId).Q && 0
1826
- });
1827
- }
1828
- function writeTryRenderers(branchId, catchContent, placeholderContent) {
1829
- writeScope(branchId, {
1830
- E: catchContent,
1831
- Q: placeholderContent
1832
- });
1833
- }
1834
1646
  function countResumeWrite(chunk) {
1835
1647
  for (let boundary = chunk.boundary; boundary; boundary = boundary.parent) boundary.resumeWrites++;
1648
+ }
1649
+ function writeAsyncVisits(chunk) {
1836
1650
  for (let async = getAsyncContent(chunk); async && !async.resumed; async = async.parent) async.resumed = !0, async.end?.writeHTML(async.visit);
1837
1651
  }
1838
1652
  function getAsyncContent(chunk) {
1839
- return chunk.context?.[kIsAsync];
1653
+ return chunk.context?.[kAsyncContent];
1840
1654
  }
1841
1655
  var State = class {
1842
1656
  tagId = 1;
1843
1657
  scopeId = 1;
1844
1658
  reorderId = 1;
1845
1659
  readyGate = 1;
1846
- hasGlobals = !1;
1847
- needsMainRuntime = !1;
1848
- hasMainRuntime = !1;
1849
- hasReadyRuntime = !1;
1660
+ hasWrittenGlobals = !1;
1661
+ needsWalkerRuntime = !1;
1662
+ hasWalkerRuntime = !1;
1663
+ hasWrittenReady = !1;
1850
1664
  hasReorderRuntime = !1;
1851
1665
  hasWrittenResume = !1;
1852
1666
  walkOnNextFlush = !1;
1853
1667
  trailerHTML = "";
1854
1668
  resumes = "";
1855
1669
  nonceAttr = "";
1856
- serializer = new Serializer();
1670
+ serializer = new State$1();
1857
1671
  writeReorders = null;
1858
1672
  scopes = /* @__PURE__ */ new Map();
1859
1673
  scope = (scopeId) => scopeWithId(this, scopeId);
@@ -1865,13 +1679,36 @@ var State = class {
1865
1679
  constructor($global) {
1866
1680
  this.$global = $global, $global.cspNonce && (this.nonceAttr = " nonce" + attrAssignment($global.cspNonce));
1867
1681
  }
1868
- flushChunk(html, scripts, pending) {
1682
+ joinFlush(html, scripts, pending) {
1869
1683
  let { $global, nonceAttr } = this, { __flush__ } = $global;
1870
1684
  return scripts && (html += "<script" + nonceAttr + ">" + scripts + "<\/script>"), __flush__ && ($global.__flush__ = void 0, html = __flush__($global, html)), pending ? html : html + this.trailerHTML;
1871
1685
  }
1872
1686
  walkScript() {
1873
1687
  return this.runtimePrefix + ".w()";
1874
1688
  }
1689
+ addResumes(channel, resumes) {
1690
+ channel.resumes = concatSequence(channel.resumes, resumes);
1691
+ }
1692
+ queueScope(target, scopeId, partialScope) {
1693
+ let pending = target.writeScopes[scopeId];
1694
+ pending && pending !== partialScope ? Object.assign(pending, partialScope) : target.writeScopes[scopeId] = partialScope, target.flushScopes = !0;
1695
+ }
1696
+ queuePassiveScope(target, scopeId, partialScope) {
1697
+ let passive = target.passiveScopes ||= {};
1698
+ passive[scopeId] = Object.assign(passive[scopeId] || {}, partialScope);
1699
+ }
1700
+ queueEffect(scopeId, registryId) {
1701
+ this.needsWalkerRuntime = !0, $chunk.writeEffect(scopeId, registryId);
1702
+ }
1703
+ serializeFlush(boundary) {
1704
+ flushSerializer(boundary, this);
1705
+ }
1706
+ runtimeScript() {
1707
+ return "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(r=l.slice(s+1),(l=l[s])>\"#\"||(a[r]=e),l),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + this.$global.runtimeId + "\")(\"" + this.$global.renderId + "\")";
1708
+ }
1709
+ keepsTryMarks(chunk, resumeWrites) {
1710
+ return chunk !== $chunk || chunk.boundary.resumeWrites !== resumeWrites;
1711
+ }
1875
1712
  resumeScript(resumes) {
1876
1713
  return this.hasWrittenResume ? this.runtimePrefix + ".r.push(" + resumes + ")" : (this.hasWrittenResume = !0, this.runtimePrefix + ".r=[" + resumes + "]");
1877
1714
  }
@@ -1884,11 +1721,11 @@ var State = class {
1884
1721
  return $global.runtimeId + $global.renderId;
1885
1722
  }
1886
1723
  reorder(chunk) {
1887
- this.writeReorders ? this.writeReorders.push(chunk) : (this.needsMainRuntime = !0, this.writeReorders = [chunk]);
1724
+ this.writeReorders ? this.writeReorders.push(chunk) : (this.needsWalkerRuntime = !0, this.writeReorders = [chunk]);
1888
1725
  }
1889
- writeReady(id, resumes) {
1726
+ readyScript(id, resumes) {
1890
1727
  let readyKey = toObjectKey(id);
1891
- return this.readyIds?.has(id) ? this.readyAccess(readyKey) + ".push(" + resumes + ")" : ((this.readyIds ||= /* @__PURE__ */ new Set()).add(id), this.hasReadyRuntime ? this.readyAccess(readyKey) + "=[" + resumes + "]" : (this.hasReadyRuntime = !0, this.runtimePrefix + ".b={" + readyKey + ":[" + resumes + "]}"));
1728
+ return this.readyIds?.has(id) ? this.readyAccess(readyKey) + ".push(" + resumes + ")" : ((this.readyIds ||= /* @__PURE__ */ new Set()).add(id), this.hasWrittenReady ? this.readyAccess(readyKey) + "=[" + resumes + "]" : (this.hasWrittenReady = !0, this.runtimePrefix + ".b={" + readyKey + ":[" + resumes + "]}"));
1892
1729
  }
1893
1730
  readyAccess(readyKey) {
1894
1731
  return this.runtimePrefix + ".b" + toAccess(readyKey);
@@ -1930,7 +1767,7 @@ var State = class {
1930
1767
  this.abort(event.target.reason);
1931
1768
  }
1932
1769
  flush() {
1933
- return this.aborted || flushSerializer(this, this.state), this.count ? 1 : this.aborted ? 2 : 0;
1770
+ return this.aborted || this.state.serializeFlush(this), this.count ? 1 : this.aborted ? 2 : 0;
1934
1771
  }
1935
1772
  startAsync() {
1936
1773
  this.aborted || this.count++;
@@ -1955,18 +1792,21 @@ var State = class {
1955
1792
  boundary;
1956
1793
  next;
1957
1794
  context;
1958
- serializeState;
1959
- constructor(boundary, next, context, serializeState) {
1960
- this.boundary = boundary, this.next = next, this.context = context, this.serializeState = serializeState;
1795
+ channel;
1796
+ constructor(boundary, next, context, channel) {
1797
+ this.boundary = boundary, this.next = next, this.context = context, this.channel = channel;
1961
1798
  }
1962
1799
  fork(boundary, next) {
1963
- return new Chunk(boundary, next, this.context, this.serializeState);
1800
+ return new Chunk(boundary, next, this.context, this.channel);
1801
+ }
1802
+ forkRest(boundary) {
1803
+ return $chunk = this.fork(boundary, this.next);
1964
1804
  }
1965
1805
  writeHTML(html) {
1966
1806
  this.html += html;
1967
1807
  }
1968
1808
  writeEffect(scopeId, registryId) {
1969
- countResumeWrite(this), this.lastEffect === registryId ? this.effects = concatEffects(this.effects, scopeId + "") : (this.lastEffect = registryId, this.effects = concatEffects(this.effects, registryId + " " + scopeId));
1809
+ countResumeWrite(this), writeAsyncVisits(this), this.lastEffect === registryId ? this.effects = concatEffects(this.effects, scopeId + "") : (this.lastEffect = registryId, this.effects = concatEffects(this.effects, registryId + " " + scopeId));
1970
1810
  }
1971
1811
  writeScript(script) {
1972
1812
  this.scripts = concatScripts(this.scripts, script);
@@ -1983,7 +1823,7 @@ var State = class {
1983
1823
  return this.deferredReady = null, deferredReady;
1984
1824
  }
1985
1825
  deferOwnReady() {
1986
- if (this.serializeState.readyId && (this.effects || this.scripts || this.serializeState.flushScopes)) {
1826
+ if (this.channel.readyId && (this.effects || this.scripts || this.channel.flushScopes)) {
1987
1827
  let deferred = this.fork(this.boundary, null);
1988
1828
  deferred.effects = this.effects, deferred.scripts = this.scripts, this.effects = this.scripts = this.lastEffect = "", this.deferredReady = concat(deferred, this.deferredReady);
1989
1829
  }
@@ -2021,9 +1861,9 @@ var State = class {
2021
1861
  let { branchId, scopeId, placeholderBranchId } = placeholder, reorderId = body.reorderId = branchId + "";
2022
1862
  this.writeHTML(state.mark("!^", reorderId));
2023
1863
  let { effects } = this, beforeBranch = deferBranchStart(this);
2024
- if (this.render(() => withBranchId(placeholderBranchId, placeholder.render)) !== this && this.boundary.abort(/* @__PURE__ */ Error("An @placeholder cannot contain async content.")), this.boundary.aborted) return !0;
1864
+ if (this.render(withBranchId, placeholderBranchId, placeholder.render) !== this && this.boundary.abort(/* @__PURE__ */ Error()), this.boundary.aborted) return !0;
2025
1865
  let stateful = this.effects !== effects;
2026
- return applyBranchStart(this, beforeBranch, stateful), stateful && (this.render(() => writeScope(branchId, { P: scopeWithId(state, placeholderBranchId) })), this.writeHTML(state.mark("]", scopeId + " " + ("P" + branchId) + " " + placeholderBranchId)), dismissChunk(end, body).writeEffect(branchId, "_f")), this.writeHTML(state.mark("!", reorderId)), this.deferredReorder = body, !1;
1866
+ return applyBranchStart(this, beforeBranch, stateful), stateful && (this.render(writeScope, branchId, { P: scopeWithId(state, placeholderBranchId) }), this.writeHTML(state.mark("]", scopeId + " " + ("P" + branchId) + " " + placeholderBranchId)), dismissChunk(end, body).writeEffect(branchId, "_f")), this.writeHTML(state.mark("!", reorderId)), this.deferredReorder = body, !1;
2027
1867
  }
2028
1868
  markCatchRange() {
2029
1869
  let { catchRange } = this;
@@ -2039,14 +1879,14 @@ var State = class {
2039
1879
  consume(boundary) {
2040
1880
  this.renderPlaceholders(boundary);
2041
1881
  let cur = this, html = "", effects = "", scripts = "", effectsEnd, heldEffects = this.heldEffects, deferredReady;
2042
- for (this.heldEffects = null, this.serializeState.readyId && this.effects && followHeldEffects(this); cur.next && !cur.async;) cur.markCatchRange(), cur.queueDeferredReorder(), html += cur.html, cur.serializeState.readyId ? deferredReady = push(deferredReady, cur) : (cur.effects && (effectsEnd && effectsEnd.boundary !== cur.boundary && (heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects), effects = ""), effectsEnd = cur, effects = concatEffects(effects, cur.effects)), scripts = concatScripts(scripts, cur.scripts)), deferredReady = concat(deferredReady, cur.takeDeferredReady()), cur.consumed = !0, cur = cur.next;
2043
- return cur.deferOwnReady(), effects && (cur.serializeState.readyId ? heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects) : effectsEnd.boundary === cur.boundary ? (cur.effects = concatEffects(effects, cur.effects), cur.lastEffect ||= effectsEnd.lastEffect) : (heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects), isWithin(cur.boundary, effectsEnd.boundary) && (cur.lastEffect ||= effectsEnd.lastEffect))), cur.heldEffects = heldEffects, cur.deferredReady = concat(deferredReady, cur.deferredReady), cur.html = html + cur.html, cur.scripts = concatScripts(scripts, cur.scripts), cur;
1882
+ for (this.heldEffects = null, this.channel.readyId && this.effects && followHeldEffects(this); cur.next && !cur.async;) cur.markCatchRange(), cur.queueDeferredReorder(), html += cur.html, cur.channel.readyId ? deferredReady = push(deferredReady, cur) : (cur.effects && (effectsEnd && effectsEnd.boundary !== cur.boundary && (heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects), effects = ""), effectsEnd = cur, effects = concatEffects(effects, cur.effects)), scripts = concatScripts(scripts, cur.scripts)), deferredReady = concat(deferredReady, cur.takeDeferredReady()), cur.consumed = !0, cur = cur.next;
1883
+ return cur.deferOwnReady(), effects && (cur.channel.readyId ? heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects) : effectsEnd.boundary === cur.boundary ? (cur.effects = concatEffects(effects, cur.effects), cur.lastEffect ||= effectsEnd.lastEffect) : (heldEffects = holdEffectsOn(heldEffects, effectsEnd, effects), isWithin(cur.boundary, effectsEnd.boundary) && (cur.lastEffect ||= effectsEnd.lastEffect))), cur.heldEffects = heldEffects, cur.deferredReady = concat(deferredReady, cur.deferredReady), cur.html = html + cur.html, cur.scripts = concatScripts(scripts, cur.scripts), cur;
2044
1884
  }
2045
- render(content, val) {
1885
+ render(content, val, val2) {
2046
1886
  let prev = $chunk;
2047
1887
  $chunk = this;
2048
1888
  try {
2049
- return content(val), $chunk;
1889
+ return content(val, val2), $chunk;
2050
1890
  } catch (err) {
2051
1891
  return this.boundary.abort(err), this;
2052
1892
  } finally {
@@ -2054,39 +1894,39 @@ var State = class {
2054
1894
  }
2055
1895
  }
2056
1896
  flushReadyScripts(boundary, reservations, holdEffects) {
2057
- let { serializeState } = this, { readyId } = serializeState, scripts = "", held = this.takeDeferredReady();
1897
+ let { channel } = this, { readyId } = channel, scripts = "", held = this.takeDeferredReady();
2058
1898
  if (held) for (let chunk of Array.isArray(held) ? held : [held]) chunk.boundary.aborted || (scripts = concatScripts(scripts, chunk.flushReadyScripts(boundary, reservations, holdEffects)), (chunk.effects || chunk.deferredReady) && (this.deferredReady = push(this.deferredReady, chunk)));
2059
1899
  if (readyId && !this.async) {
2060
1900
  let { state } = boundary;
2061
- flushSerializer(boundary, serializeState);
2062
- let deps = state.serializer.takeChannelDeps(), effects = holdEffects ? "" : this.effects, { resumes } = serializeState, chunkScripts = this.scripts;
2063
- if (serializeState.resumes = this.scripts = "", effects && (this.effects = this.lastEffect = ""), resumes || effects) {
2064
- state.needsMainRuntime = !0;
1901
+ flushSerializer(boundary, channel);
1902
+ let deps = takeChannelDeps(state.serializer), effects = holdEffects ? "" : this.effects, { resumes } = channel, chunkScripts = this.scripts;
1903
+ if (channel.resumes = this.scripts = "", effects && (this.effects = this.lastEffect = ""), resumes || effects) {
1904
+ state.needsWalkerRuntime = !0;
2065
1905
  let batch = concatSequence(depsMarker(deps), concatSequence(resumes, effects && `"${effects}"`));
2066
1906
  if (reservations) {
2067
1907
  let gate = state.readyGate++;
2068
- reservations.push(state.writeReady(readyId, gate + "")), scripts = concatScripts(scripts, "(b=>b.splice(b.indexOf(" + gate + "),1," + batch + "))(" + state.readyAccess(toObjectKey(readyId)) + ")");
2069
- } else scripts = concatScripts(scripts, state.writeReady(readyId, batch));
1908
+ reservations.push(state.readyScript(readyId, gate + "")), scripts = concatScripts(scripts, "(b=>b.splice(b.indexOf(" + gate + "),1," + batch + "))(" + state.readyAccess(toObjectKey(readyId)) + ")");
1909
+ } else scripts = concatScripts(scripts, state.readyScript(readyId, batch));
2070
1910
  }
2071
1911
  scripts = concatScripts(scripts, chunkScripts);
2072
1912
  }
2073
1913
  return scripts;
2074
1914
  }
2075
- flushScript(boundary) {
2076
- let { state } = boundary, { $global, runtimePrefix } = state, needsWalk = state.walkOnNextFlush;
1915
+ flush(boundary) {
1916
+ let { state } = boundary, { runtimePrefix } = state, needsWalk = state.walkOnNextFlush;
2077
1917
  needsWalk && (state.walkOnNextFlush = !1), flushSerializer(boundary, state);
2078
1918
  let readyResumeScripts = this.flushReadyScripts(boundary, void 0, this.async);
2079
- for (let channel; !boundary.aborted && (channel = state.serializer.pendingReadyChannel());) {
2080
- let resumes = state.serializer.stringifyScopes([], boundary, channel), deps = state.serializer.takeChannelDeps();
2081
- state.needsMainRuntime = !0, readyResumeScripts = concatScripts(readyResumeScripts, state.writeReady(channel.readyId, concatSequence(depsMarker(deps), resumes)));
1919
+ for (let channel; !boundary.aborted && (channel = pendingReadyChannel(state.serializer));) {
1920
+ let resumes = stringifyScopes(state.serializer, [], boundary, channel), deps = takeChannelDeps(state.serializer);
1921
+ state.needsWalkerRuntime = !0, readyResumeScripts = concatScripts(readyResumeScripts, state.readyScript(channel.readyId, concatSequence(depsMarker(deps), resumes)));
2082
1922
  }
2083
1923
  readyResumeScripts && (needsWalk = !0);
2084
1924
  let effects = this.async ? "" : joinHeldEffects(this.takeHeldEffects(), this.effects), { html, scripts } = this;
2085
- html && state.hasReorderRuntime && (html = state.mark("*", "") + html), state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(r=l.slice(s+1),(l=l[s])>\"#\"||(a[r]=e),l),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\"");
1925
+ html && state.hasReorderRuntime && (html = state.mark("*", "") + html), state.needsWalkerRuntime && !state.hasWalkerRuntime && (state.hasWalkerRuntime = !0, scripts = concatScripts(scripts, state.runtimeScript())), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\"");
2086
1926
  let reordered = "", needsResumeArray = !1;
2087
1927
  if (state.writeReorders) {
2088
1928
  for (let reorderedChunk of state.writeReorders) {
2089
- needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:1,r:a,c(i=e.l[\"^\"+a],f=d.cloneNode()){if(--o.i)return 1;for(;f.prepend(r=e.l[a].previousSibling||i),i!=r;);c(a,d)}}),e.v.push({data:e.i+\"*\"+l.r}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
1929
+ needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=e=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:1,r:a,c(i=e.l[\"^\"+a],f=d.cloneNode()){if(--o.i)return 1;for(;f.prepend(r=e.l[a].previousSibling||i),i!=r;);c(a,d)}}),e.v.push({data:e.i+\"*\"+l.r}),(n=e.j[a])&&(g=l.c,l.c=i=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
2090
1930
  let { reorderId, reorderBranch } = reorderedChunk, rootBranch = reorderBranch || +reorderId, readyReservations = [], reorderHTML = "", reorderEffects = "", effectsBoundary = reorderedChunk.boundary, reorderScripts = "", cur = reorderedChunk.boundary.aborted ? null : reorderedChunk;
2091
1931
  for (reorderedChunk.reorderId = null; cur;) {
2092
1932
  cur.markCatchRange(), cur.queueDeferredReorder(), cur.deferOwnReady();
@@ -2108,9 +1948,9 @@ var State = class {
2108
1948
  }
2109
1949
  flushHTML(boundary) {
2110
1950
  let { state } = boundary;
2111
- this.flushScript(boundary);
1951
+ this.flush(boundary);
2112
1952
  let { html, scripts } = this;
2113
- return this.html = this.scripts = "", state.flushChunk(html, scripts, boundary.count);
1953
+ return this.html = this.scripts = "", state.joinFlush(html, scripts, boundary.count);
2114
1954
  }
2115
1955
  };
2116
1956
  function renderReorderPlaceholders(reorder, reorders) {
@@ -2129,7 +1969,7 @@ function followHeldEffects(chunk) {
2129
1969
  held !== chunk && (held.effects = concatEffects(held.effects, chunk.effects), chunk.effects = "");
2130
1970
  }
2131
1971
  function lastHeldOf(held, cur) {
2132
- return cur.serializeState === held.serializeState && cur.boundary === held.boundary ? cur : held;
1972
+ return cur.channel === held.channel && cur.boundary === held.boundary ? cur : held;
2133
1973
  }
2134
1974
  function holdEffectsOn(heldEffects, chunk, effects) {
2135
1975
  return chunk.effects = effects, push(heldEffects, chunk);
@@ -2139,7 +1979,7 @@ function isWithin(boundary, outer) {
2139
1979
  return !!boundary;
2140
1980
  }
2141
1981
  function holdReorderEffects(head, boundary, effects) {
2142
- head.serializeState.readyId || (head.effects && (head.heldEffects = holdEffectsOn(head.heldEffects, head.fork(head.boundary, null), head.effects)), head.effects = head.lastEffect = ""), head.heldEffects = holdEffectsOn(head.heldEffects, head.fork(boundary, null), effects);
1982
+ head.channel.readyId || (head.effects && (head.heldEffects = holdEffectsOn(head.heldEffects, head.fork(head.boundary, null), head.effects)), head.effects = head.lastEffect = ""), head.heldEffects = holdEffectsOn(head.heldEffects, head.fork(boundary, null), effects);
2143
1983
  }
2144
1984
  function joinHeldEffects(heldEffects, effects) {
2145
1985
  return concatEffects(reduce(heldEffects, joinUncaught, ""), effects);
@@ -2147,16 +1987,16 @@ function joinHeldEffects(heldEffects, effects) {
2147
1987
  function joinUncaught(joined, held) {
2148
1988
  return held.boundary.aborted ? joined : concatEffects(joined, held.effects);
2149
1989
  }
2150
- function flushSerializer(boundary, serializeState) {
2151
- let { state } = boundary, { serializer } = state, pending = serializer.pending(serializeState);
2152
- if (serializeState.flushScopes || pending) {
2153
- let { writeScopes, passiveScopes } = serializeState, isBlockingState = serializeState !== state, flushes = [];
1990
+ function flushSerializer(boundary, channel) {
1991
+ let { state } = boundary, { serializer } = state, pending = hasMatchingCalls(serializer, channel.readyId);
1992
+ if (channel.flushScopes || pending) {
1993
+ let { writeScopes, passiveScopes } = channel, flushes = [];
2154
1994
  if (passiveScopes) for (let key in passiveScopes) {
2155
1995
  let props = writeScopes[key];
2156
1996
  props && (writeScopes[key] = Object.assign(passiveScopes[key], props), delete passiveScopes[key]);
2157
1997
  }
2158
- if (!isBlockingState && !state.hasGlobals) {
2159
- state.hasGlobals = !0;
1998
+ if (!channel.readyId && !state.hasWrittenGlobals) {
1999
+ state.hasWrittenGlobals = !0;
2160
2000
  let globals = getFilteredGlobals(state.$global);
2161
2001
  globals && flushes.push([
2162
2002
  0,
@@ -2172,12 +2012,12 @@ function flushSerializer(boundary, serializeState) {
2172
2012
  props
2173
2013
  ]);
2174
2014
  }
2175
- (flushes.length || pending) && (isBlockingState && !state.hasGlobals && flushSerializerGlobals(boundary), serializeState.resumes = concatSequence(serializeState.resumes, serializer.stringifyScopes(flushes, boundary, serializeState))), serializeState.writeScopes = {}, serializeState.flushScopes = !1, pending && (state.walkOnNextFlush = !0);
2015
+ (flushes.length || pending) && (channel.readyId && !state.hasWrittenGlobals && flushSerializerGlobals(boundary), state.addResumes(channel, stringifyScopes(serializer, flushes, boundary, channel))), channel.writeScopes = {}, channel.flushScopes = !1, pending && (state.walkOnNextFlush = !0);
2176
2016
  }
2177
2017
  }
2178
2018
  function flushSerializerGlobals(boundary) {
2179
2019
  let { state } = boundary, globals = getFilteredGlobals(state.$global);
2180
- globals && (state.hasGlobals = !0, state.needsMainRuntime = !0, state.resumes = concatSequence(state.resumes, state.serializer.stringifyScopes([[
2020
+ globals && (state.hasWrittenGlobals = !0, state.needsWalkerRuntime = !0, state.resumes = concatSequence(state.resumes, stringifyScopes(state.serializer, [[
2181
2021
  0,
2182
2022
  globals,
2183
2023
  globals
@@ -2343,7 +2183,7 @@ var ServerRendered = class {
2343
2183
  });
2344
2184
  },
2345
2185
  return(value) {
2346
- return done || aborted || boundary?.abort(/* @__PURE__ */ Error("Iterator returned before consumed.")), Promise.resolve({
2186
+ return done || aborted || boundary?.abort(/* @__PURE__ */ Error()), Promise.resolve({
2347
2187
  value,
2348
2188
  done: !0
2349
2189
  });
@@ -2392,7 +2232,7 @@ var ServerRendered = class {
2392
2232
  #promise() {
2393
2233
  return this.#cachedPromise ||= new Promise((resolve, reject) => {
2394
2234
  let head = this.#head;
2395
- if (this.#head = null, !head) return reject(/* @__PURE__ */ Error(CONSUMED_RESULT_MESSAGE));
2235
+ if (this.#head = null, !head) return reject(/* @__PURE__ */ Error());
2396
2236
  let { boundary } = head, html = "";
2397
2237
  (boundary.onNext = () => {
2398
2238
  switch (!boundary.count && boundary.flush()) {
@@ -2409,7 +2249,7 @@ var ServerRendered = class {
2409
2249
  #read(onWrite, onAbort, onClose) {
2410
2250
  let tick = !0, flushing = !1, again = !1, head = this.#head;
2411
2251
  if (this.#head = null, !head) {
2412
- onAbort(/* @__PURE__ */ Error(CONSUMED_RESULT_MESSAGE));
2252
+ onAbort(/* @__PURE__ */ Error());
2413
2253
  return;
2414
2254
  }
2415
2255
  let { boundary } = head, onNext = boundary.onNext = (write) => {
@@ -2442,9 +2282,9 @@ var ServerRendered = class {
2442
2282
  }
2443
2283
  toString() {
2444
2284
  let head = this.#head;
2445
- if (this.#head = null, !head) throw Error(CONSUMED_RESULT_MESSAGE);
2285
+ if (this.#head = null, !head) throw /* @__PURE__ */ Error();
2446
2286
  let { boundary } = head, html = boundary.flush() === 0 ? head.consume(boundary).flushHTML(boundary) : "";
2447
- if (boundary.count && boundary.abort(/* @__PURE__ */ Error("Cannot consume asynchronous render with 'toString'")), settle(boundary), boundary.aborted) throw boundary.reason;
2287
+ if (boundary.count && boundary.abort(/* @__PURE__ */ Error()), settle(boundary), boundary.aborted) throw boundary.reason;
2448
2288
  return html;
2449
2289
  }
2450
2290
  };
@@ -2454,18 +2294,19 @@ function settle(boundary) {
2454
2294
  function NOOP$1() {}
2455
2295
  //#endregion
2456
2296
  //#region src/html/assets.ts
2457
- function withLoadAssets(renderer, flush, assetId, triggers) {
2458
- return register(renderer.a, Object.assign((input) => (writeLoadAsset(assetId, flush, triggers), writeWaitReady(assetId, renderer, input)), renderer));
2297
+ function withLoadAssets(template, id, flush, assetId, triggers) {
2298
+ let renderer = (input) => (writeLoadAsset(assetId, flush, triggers), writeWaitReady(assetId, template(), input));
2299
+ return _template(id, renderer), renderer;
2459
2300
  }
2460
2301
  function writeLoadAsset(assetId, flush, triggers) {
2461
2302
  let g = $global();
2462
2303
  writeAsset(g, addAsset(g, assetId, flush, triggers));
2463
2304
  }
2464
- function withPageAssets(template, runtime, assetId, runtimeId) {
2305
+ function withPageAssets(template, flush, assetId, runtimeId) {
2465
2306
  return Object.assign((input) => {
2466
2307
  let g = $global();
2467
2308
  runtimeId && (g[kAssets] || (g.runtimeId = runtimeId));
2468
- let asset = addAsset(g, assetId, runtime);
2309
+ let asset = addAsset(g, assetId, flush);
2469
2310
  return g.__flush__ ? (writeAsset(g, asset), writeWaitReady(assetId, template, input)) : (g.__flush__ = flushPage, template(input));
2470
2311
  }, template);
2471
2312
  }
@@ -2536,6 +2377,212 @@ function toObjectExpression(options) {
2536
2377
  //#endregion
2537
2378
  //#region src/common/compat-meta.ts
2538
2379
  //#endregion
2380
+ //#region src/common/for.ts
2381
+ function forIn(obj, cb) {
2382
+ for (let key in obj) cb(key, obj[key]);
2383
+ }
2384
+ function forOf(list, cb) {
2385
+ if (list) {
2386
+ let i = 0;
2387
+ for (let item of list) cb(item, i++);
2388
+ }
2389
+ }
2390
+ function forTo(to, from, step, cb) {
2391
+ let start = from || 0, delta = step || 1;
2392
+ for (let steps = (to - start) / delta, i = 0; i <= steps; i++) cb(start + i * delta);
2393
+ }
2394
+ function forUntil(until, from, step, cb) {
2395
+ let start = from || 0, delta = step || 1;
2396
+ for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
2397
+ }
2398
+ //#endregion
2399
+ //#region src/html/for.ts
2400
+ function forOfBy(by, item, index) {
2401
+ return by ? typeof by == "string" ? item[by] : by(item, index) : index;
2402
+ }
2403
+ function forInBy(by, name, value) {
2404
+ return by ? by(name, value) : name;
2405
+ }
2406
+ function forStepBy(by, index) {
2407
+ return by ? by(index) : index;
2408
+ }
2409
+ //#endregion
2410
+ //#region src/html/control-flow.ts
2411
+ function _show_start(display, markerGuard, branchExprGuard, parentEndTag) {
2412
+ display ? resumesMarker(markerGuard, branchExprGuard, parentEndTag) && $chunk.writeHTML($chunk.boundary.state.mark("[", "")) : $chunk.writeHTML("<t hidden>");
2413
+ }
2414
+ function _show_end(scopeId, accessor, display, markerGuard, branchExprGuard, parentEndTag, singleNode) {
2415
+ let branchId = _scope_id(), wrap = !display;
2416
+ wrap && $chunk.writeHTML("</t>"), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, wrap || singleNode ? 1 : void 0, " " + branchId);
2417
+ }
2418
+ function _for_of(list, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
2419
+ forBranches(by, cb, iterateForOf(list, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
2420
+ }
2421
+ function iterateForOf(list, cb, by) {
2422
+ return (each) => each ? forOf(list, (item, index) => {
2423
+ let itemKey = forOfBy(by, item, index);
2424
+ each(itemKey, itemKey === index, item, index);
2425
+ }) : forOf(list, cb);
2426
+ }
2427
+ function _for_in(obj, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
2428
+ forBranches(by, cb, iterateForIn(obj, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
2429
+ }
2430
+ function iterateForIn(obj, cb, by) {
2431
+ return (each) => each ? forIn(obj, (key, value) => {
2432
+ each(forInBy(by, key, value), !1, key, value);
2433
+ }) : forIn(obj, cb);
2434
+ }
2435
+ function _for_to(to, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
2436
+ forBranches(by, cb, iterateForTo(to, from, step, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
2437
+ }
2438
+ function iterateForTo(to, from, step, cb, by) {
2439
+ return (each) => {
2440
+ let index = 0;
2441
+ return each ? forTo(to, from, step, (value) => {
2442
+ let itemKey = forStepBy(by, value);
2443
+ each(itemKey, itemKey === index++, value);
2444
+ }) : forTo(to, from, step, cb);
2445
+ };
2446
+ }
2447
+ function _for_until(until, from, step, cb, by, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
2448
+ forBranches(by, cb, iterateForUntil(until, from, step, cb, by), scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode);
2449
+ }
2450
+ function iterateForUntil(until, from, step, cb, by) {
2451
+ return (each) => {
2452
+ let index = 0;
2453
+ return each ? forUntil(until, from, step, (value) => {
2454
+ let itemKey = forStepBy(by, value);
2455
+ each(itemKey, itemKey === index++, value);
2456
+ }) : forUntil(until, from, step, cb);
2457
+ };
2458
+ }
2459
+ function forBranches(by, cb, iterate, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
2460
+ if (branchGuard === 0) {
2461
+ iterate(0), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, "");
2462
+ return;
2463
+ }
2464
+ let { state } = $chunk.boundary, resumeKeys = markerGuard !== 0, resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag), flushBranchIds = "", loopScopes;
2465
+ iterate((itemKey, sameAsIndex, a, b) => {
2466
+ let branchId = _peek_scope_id();
2467
+ resumeMarker && (singleNode ? flushBranchIds = " " + branchId + flushBranchIds : ($chunk.writeHTML(state.mark("[", flushBranchIds)), flushBranchIds = branchId + "")), withBranchId(branchId, cb, a, b);
2468
+ let branchScope = writeScope(branchId, resumeKeys && !sameAsIndex ? { M: itemKey } : {});
2469
+ resumeMarker || (loopScopes = push(loopScopes, branchScope));
2470
+ }), loopScopes && writeScope(scopeId, { ["A" + accessor]: loopScopes }), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, singleNode ? flushBranchIds : flushBranchIds ? " " + flushBranchIds : "");
2471
+ }
2472
+ function _if(cb, scopeId, accessor, branchGuard, markerGuard, branchExprGuard, parentEndTag, singleNode) {
2473
+ let resumeBranch = branchGuard !== 0, resumeMarker = resumesMarker(markerGuard, branchExprGuard, parentEndTag), branchId = _peek_scope_id(), chunk = $chunk, beforeBranch = resumeMarker && resumeBranch && !singleNode ? deferBranchStart(chunk) : void 0, branchIndex = resumeBranch ? withBranchId(branchId, cb) : cb(), shouldWriteBranch = resumeBranch && branchIndex !== void 0;
2474
+ beforeBranch !== void 0 && applyBranchStart(chunk, beforeBranch, shouldWriteBranch), shouldWriteBranch && (branchIndex || !resumeMarker) && writeScope(scopeId, {
2475
+ ["D" + accessor]: branchIndex || void 0,
2476
+ ["A" + accessor]: resumeMarker ? void 0 : writeScope(branchId, {})
2477
+ }), writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, shouldWriteBranch ? " " + branchId : "");
2478
+ }
2479
+ function resumesMarker(markerGuard, branchExprGuard, parentEndTag) {
2480
+ return markerGuard !== 0 && (!parentEndTag || branchExprGuard !== 0);
2481
+ }
2482
+ function writeBranchEnd(scopeId, accessor, branchExprGuard, markerGuard, parentEndTag, singleNode, branchIds) {
2483
+ let endTag = parentEndTag || "";
2484
+ if (resumesMarker(markerGuard, branchExprGuard, parentEndTag)) {
2485
+ let { state } = $chunk.boundary, mark = singleNode ? state.mark(parentEndTag ? "}" : "|", scopeId + " " + accessor + (branchIds || "")) : state.mark(parentEndTag ? ")" : "]", scopeId + " " + accessor + (branchIds || ""));
2486
+ $chunk.writeHTML(mark + endTag);
2487
+ } else markerGuard === 0 ? $chunk.writeHTML(endTag) : $chunk.writeHTML(endTag + _el_resume(scopeId, accessor));
2488
+ }
2489
+ function _await(scopeId, accessor, promise, content, markerGuard) {
2490
+ let resumeMarker = markerGuard !== 0;
2491
+ if (!isPromise(promise)) {
2492
+ if (resumeMarker) {
2493
+ let branchId = _peek_scope_id();
2494
+ $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withBranchId(branchId, content, promise), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2495
+ } else content(promise);
2496
+ return;
2497
+ }
2498
+ let chunk = $chunk, { boundary } = chunk, startId = _peek_scope_id(), after = chunk.next = chunk.forkRest(boundary);
2499
+ chunk.async = !0, captureContext(chunk), boundary.startAsync(), promise.then((value) => {
2500
+ if (chunk.async && (chunk.async = !1, !boundary.aborted)) {
2501
+ let { state } = boundary;
2502
+ chunk.render(() => {
2503
+ if (resumeMarker) {
2504
+ let branchId = _peek_scope_id();
2505
+ $chunk.writeHTML($chunk.boundary.state.mark("[", "")), withBranchId(branchId, () => withAsyncContent({ parent: getAsyncContent(chunk) }, content, value)), $chunk.writeHTML($chunk.boundary.state.mark("]", scopeId + " " + accessor + " " + branchId));
2506
+ } else {
2507
+ let renderedSince = _peek_scope_id() !== startId, async = { parent: getAsyncContent(chunk) };
2508
+ withAsyncContent(async, content, value), async.visit = renderedSince && (after.html || after.next) ? $chunk.boundary.state.mark("]", scopeId + " " + accessor) : "", async.resumed && $chunk.writeHTML(async.visit), async.end = $chunk;
2509
+ }
2510
+ }), !chunk.async && boundary.pendingReorders?.delete(chunk) && state.reorder(chunk), boundary.endAsync();
2511
+ }
2512
+ }, (err) => {
2513
+ chunk.async = !1, boundary.abort(err);
2514
+ });
2515
+ }
2516
+ function _try(scopeId, accessor, content, placeholderContent, catchContent, placeholderId, catchId) {
2517
+ let placeholderBranchId = placeholderContent ? _scope_id() : 0, branchId = _peek_scope_id(), chunk = $chunk, { boundary } = chunk, { state } = boundary, { resumeWrites } = boundary, beforeBranch = deferBranchStart(chunk), renderers = () => writeTryRenderers(branchId, catchContent && _resume(catchContent, catchId), placeholderContent && _resume(placeholderContent, placeholderId)), writesRenderers = tryBoundary(placeholderContent ? () => tryPlaceholder(content, placeholderContent, branchId, scopeId, placeholderBranchId) : content, catchContent, branchId, renderers), keepsMarks = state.keepsTryMarks(chunk, resumeWrites);
2518
+ applyBranchStart(chunk, beforeBranch, keepsMarks), keepsMarks && (writesRenderers || renderers(), $chunk.writeHTML(state.mark("]", scopeId + " " + accessor + " " + branchId)));
2519
+ }
2520
+ function tryPlaceholder(content, placeholder, branchId, scopeId, placeholderBranchId) {
2521
+ let chunk = $chunk, { boundary } = chunk, body = chunk.fork(boundary, null);
2522
+ if (body === body.render(content)) {
2523
+ chunk.append(body);
2524
+ return;
2525
+ }
2526
+ chunk.next = chunk.forkRest(boundary), captureContext(chunk), chunk.placeholder = {
2527
+ body,
2528
+ render: placeholder,
2529
+ branchId,
2530
+ scopeId,
2531
+ placeholderBranchId
2532
+ };
2533
+ }
2534
+ function tryBoundary(content, catchContent, branchId, renderers) {
2535
+ let chunk = $chunk, { boundary } = chunk, { state } = boundary, bodyBoundary = new Boundary(state, void 0, boundary);
2536
+ catchContent && (bodyBoundary.withinCatch = !0);
2537
+ let body = chunk.fork(bodyBoundary, null), bodyEnd = body.render(withBranchId, branchId, content);
2538
+ if (bodyBoundary.aborted) {
2539
+ if (!catchContent) throw bodyBoundary.reason;
2540
+ return catchContent(bodyBoundary.reason), !0;
2541
+ }
2542
+ if (body === bodyEnd) return chunk.append(body), !1;
2543
+ let renderersAtSettle = !bodyBoundary.resumeWrites, bodyNext = bodyEnd.next = chunk.forkRest(boundary);
2544
+ chunk.next = body, boundary.startAsync();
2545
+ let reorderId = catchContent ? state.nextReorderId() : "";
2546
+ return reorderId && (chunk.catchRange = {
2547
+ id: reorderId,
2548
+ end: bodyEnd
2549
+ }, captureContext(chunk)), bodyBoundary.onNext = () => {
2550
+ if (!boundary.aborted) {
2551
+ if (bodyBoundary.aborted) {
2552
+ if (!reorderId) {
2553
+ boundary.abort(bodyBoundary.reason);
2554
+ return;
2555
+ }
2556
+ let streamed = !chunk.catchRange, catchChunk = chunk.fork(boundary, null);
2557
+ chunk.catchRange = null, renderersAtSettle || catchChunk.render(clearTryRenderers, branchId);
2558
+ let inOrder = catchChunk === catchChunk.render(catchContent, bodyBoundary.reason);
2559
+ if (boundary.aborted) return;
2560
+ if ((bodyEnd.consumed || !inOrder) && (catchChunk.reorderBranch = branchId), bodyEnd.consumed) catchChunk.reorderId = reorderId, state.reorder(catchChunk);
2561
+ else {
2562
+ let reorder = null;
2563
+ inOrder ? streamed && (reorder = chunk.fork(boundary, null)) : reorder = catchChunk, reorder && (reorder.reorderId = reorderId);
2564
+ let endMarker = state.mark("!", reorderId), cut = body;
2565
+ for (; cut.consumed;) cut = cut.next;
2566
+ cut.async = !1, cut.next = inOrder ? catchChunk : bodyNext, cut.html = streamed ? endMarker : inOrder ? "" : state.mark("!^", reorderId) + endMarker, cut.scripts = cut.effects = cut.lastEffect = "", cut.placeholder = cut.reorderId = cut.catchRange = null, cut.deferredReorder = reorder, inOrder && (catchChunk.next = bodyNext);
2567
+ }
2568
+ boundary.endAsync();
2569
+ } else bodyBoundary.count ? boundary.onNext() : (renderersAtSettle && bodyBoundary.resumeWrites && bodyEnd.render(renderers), chunk.catchRange = null, boundary.endAsync());
2570
+ }
2571
+ }, renderersAtSettle;
2572
+ }
2573
+ function clearTryRenderers(branchId) {
2574
+ writeScope(branchId, {
2575
+ E: 0,
2576
+ Q: _scope_with_id(branchId).Q && 0
2577
+ });
2578
+ }
2579
+ function writeTryRenderers(branchId, catchContent, placeholderContent) {
2580
+ writeScope(branchId, {
2581
+ E: catchContent,
2582
+ Q: placeholderContent
2583
+ });
2584
+ }
2585
+ //#endregion
2539
2586
  //#region src/html/compat.ts
2540
2587
  function drainClassFunctions($global, writeScope) {
2541
2588
  let pending = pendingClassFunctions.get($global), scopeByHost = {};
@@ -2548,4 +2595,4 @@ function swapReorders(state, reorders) {
2548
2595
  }
2549
2596
  function NOOP() {}
2550
2597
  //#endregion
2551
- export { $global, _assert_class_toggles, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_select_value, _attrs_textarea_value, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _html_resume, _id, _if, _peek_scope_id, _resume, _resume_branch, _resume_locals, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _set_scope_reason, _show_end, _show_start, _style_html, _subscribe, _template, _text_resume, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, _write_guard, _write_if, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, withLoadAssets, withPageAssets };
2598
+ export { $global, _assert_class_toggles, _assert_hoist, _attr, _attr_and, _attr_class, _attr_content, _attr_details_or_dialog_open as _attr_details_open, _attr_details_or_dialog_open as _attr_dialog_open, _attr_input_checked, _attr_input_checkedValue, _attr_input_value, _attr_nonce, _attr_nullish, _attr_option_value, _attr_or, _attr_select_value, _attr_style, _attr_textarea_value, _attrs, _attrs_content, _attrs_partial, _attrs_partial_content, _attrs_select_value, _attrs_textarea_value, _await, _content, _content_resume, _dynamic_tag, _el, _el_read_error, _el_resume, _escape, _escape_comment, _escape_script, _escape_style, _escape_style_value, _existing_scope, _flush_head, _for_in, _for_of, _for_to, _for_until, _hoist, _hoist_read_error, _html, _html_resume, _id, _if, _peek_scope_id, _resume, _resume_branch, _resume_locals, writeScope as _scope, _scope_id, _scope_reason, _scope_with_id, _script, _set_scope_reason, _show_end, _show_start, _signal_read_error, _style_html, _subscribe, _template, _text_resume, _textarea_value, _to_text, _trailers, _try, _unescaped, _var, _write_guard, _write_if, attrTag, attrTags, compat, forIn, forOf, forTo, forUntil, withLoadAssets, withPageAssets };