marko 5.37.6 → 6.0.0-3.11

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 (648) hide show
  1. package/dist/common/attr-tag.d.ts +8 -0
  2. package/dist/common/compat-meta.d.ts +2 -0
  3. package/dist/common/for.d.ts +5 -0
  4. package/dist/common/helpers.d.ts +7 -0
  5. package/dist/common/meta.d.ts +2 -0
  6. package/dist/common/types.d.ts +105 -0
  7. package/dist/debug/dom.js +2111 -0
  8. package/dist/debug/dom.mjs +2088 -0
  9. package/dist/debug/html.js +2740 -0
  10. package/dist/debug/html.mjs +2663 -0
  11. package/dist/dom/abort-signal.d.ts +3 -0
  12. package/dist/dom/compat.d.ts +20 -0
  13. package/dist/dom/control-flow.d.ts +14 -0
  14. package/dist/dom/controllable.d.ts +12 -0
  15. package/dist/dom/dom.d.ts +19 -0
  16. package/dist/dom/event.d.ts +4 -0
  17. package/dist/dom/parse-html.d.ts +5 -0
  18. package/dist/dom/queue.d.ts +10 -0
  19. package/dist/dom/reconcile.d.ts +2 -0
  20. package/dist/dom/renderer.d.ts +21 -0
  21. package/dist/dom/resolve-cursor-position.d.ts +1 -0
  22. package/dist/dom/resume.d.ts +9 -0
  23. package/dist/dom/schedule.d.ts +2 -0
  24. package/dist/dom/scope.d.ts +7 -0
  25. package/dist/dom/signals.d.ts +39 -0
  26. package/dist/dom/template.d.ts +3 -0
  27. package/dist/dom/walker.d.ts +4 -0
  28. package/dist/dom.d.ts +15 -0
  29. package/dist/dom.js +1370 -0
  30. package/dist/dom.mjs +1350 -0
  31. package/dist/html/attrs.d.ts +14 -0
  32. package/dist/html/compat.d.ts +14 -0
  33. package/dist/html/content.d.ts +5 -0
  34. package/dist/html/dynamic-tag.d.ts +12 -0
  35. package/dist/html/for.d.ts +4 -0
  36. package/dist/html/inlined-runtimes.d.ts +2 -0
  37. package/dist/html/serializer.d.ts +14 -0
  38. package/dist/html/template.d.ts +3 -0
  39. package/dist/html/writer.d.ts +114 -0
  40. package/dist/html.d.ts +9 -0
  41. package/dist/html.js +1818 -0
  42. package/dist/html.mjs +1744 -0
  43. package/dist/translator/core/attrs.d.ts +3 -0
  44. package/dist/translator/core/client.d.ts +14 -0
  45. package/dist/translator/core/const.d.ts +3 -0
  46. package/dist/translator/core/debug.d.ts +3 -0
  47. package/dist/translator/core/define.d.ts +3 -0
  48. package/dist/translator/core/effect.d.ts +3 -0
  49. package/dist/translator/core/export.d.ts +3 -0
  50. package/dist/translator/core/for.d.ts +67 -0
  51. package/dist/translator/core/html-comment.d.ts +12 -0
  52. package/dist/translator/core/html-script.d.ts +9 -0
  53. package/dist/translator/core/html-style.d.ts +9 -0
  54. package/dist/translator/core/id.d.ts +3 -0
  55. package/dist/translator/core/if.d.ts +53 -0
  56. package/dist/translator/core/import.d.ts +3 -0
  57. package/dist/translator/core/index.d.ts +152 -0
  58. package/dist/translator/core/let.d.ts +8 -0
  59. package/dist/translator/core/lifecycle.d.ts +10 -0
  60. package/dist/translator/core/log.d.ts +3 -0
  61. package/dist/translator/core/return.d.ts +6 -0
  62. package/dist/translator/core/script.d.ts +3 -0
  63. package/dist/translator/core/server.d.ts +14 -0
  64. package/dist/translator/core/static.d.ts +14 -0
  65. package/dist/translator/core/style.d.ts +3 -0
  66. package/dist/translator/index.d.ts +201 -0
  67. package/dist/translator/index.js +9134 -490
  68. package/dist/translator/util/assert.d.ts +3 -0
  69. package/dist/translator/util/binding-has-downstream-expressions.d.ts +2 -0
  70. package/dist/translator/util/entry-builder.d.ts +19 -0
  71. package/dist/translator/util/evaluate.d.ts +11 -0
  72. package/dist/translator/util/for-each-identifier.d.ts +2 -0
  73. package/dist/translator/util/get-defined-binding-expression.d.ts +3 -0
  74. package/dist/translator/util/get-known-attr-values.d.ts +2 -0
  75. package/dist/translator/util/get-parent-tag.d.ts +2 -0
  76. package/dist/translator/util/get-root.d.ts +7 -0
  77. package/dist/translator/util/get-tag-name.d.ts +2 -0
  78. package/dist/translator/util/is-core-tag.d.ts +10 -0
  79. package/dist/translator/util/is-stateful.d.ts +3 -0
  80. package/dist/translator/util/is-static.d.ts +2 -0
  81. package/dist/translator/util/marko-config.d.ts +4 -0
  82. package/dist/translator/util/nested-attribute-tags.d.ts +17 -0
  83. package/dist/translator/util/normalize-string-expression.d.ts +3 -0
  84. package/dist/translator/util/optional.d.ts +20 -0
  85. package/dist/translator/util/plugin-hooks.d.ts +4 -0
  86. package/dist/translator/util/references.d.ts +84 -0
  87. package/dist/translator/util/runtime-info.d.ts +5 -0
  88. package/dist/translator/util/runtime.d.ts +15 -0
  89. package/dist/translator/util/scope-read.d.ts +6 -0
  90. package/dist/translator/util/sections.d.ts +51 -0
  91. package/dist/translator/util/signals.d.ts +61 -0
  92. package/dist/translator/util/simplify-fn.d.ts +5 -0
  93. package/dist/translator/util/state.d.ts +3 -0
  94. package/dist/translator/util/tag-name-type.d.ts +16 -0
  95. package/dist/translator/util/to-first-expression-or-block.d.ts +3 -0
  96. package/dist/translator/util/to-first-statement-or-block.d.ts +2 -0
  97. package/dist/translator/util/to-property-name.d.ts +7 -0
  98. package/dist/translator/util/translate-attrs.d.ts +12 -0
  99. package/dist/translator/util/translate-var.d.ts +2 -0
  100. package/dist/translator/util/traverse.d.ts +9 -0
  101. package/dist/translator/util/visitors.d.ts +11 -0
  102. package/dist/translator/util/walks.d.ts +15 -0
  103. package/dist/translator/util/with-previous-location.d.ts +2 -0
  104. package/dist/translator/util/writer.d.ts +13 -0
  105. package/dist/translator/visitors/cdata.d.ts +7 -0
  106. package/dist/translator/visitors/comment.d.ts +7 -0
  107. package/dist/translator/visitors/declaration.d.ts +7 -0
  108. package/dist/translator/visitors/document-type.d.ts +7 -0
  109. package/dist/translator/visitors/function.d.ts +19 -0
  110. package/dist/translator/visitors/import-declaration.d.ts +8 -0
  111. package/dist/translator/visitors/placeholder.d.ts +22 -0
  112. package/dist/translator/visitors/program/dom.d.ts +7 -0
  113. package/dist/translator/visitors/program/html.d.ts +8 -0
  114. package/dist/translator/visitors/program/index.d.ts +39 -0
  115. package/dist/translator/visitors/referenced-identifier.d.ts +7 -0
  116. package/dist/translator/visitors/scriptlet.d.ts +8 -0
  117. package/dist/translator/visitors/tag/attribute-tag.d.ts +11 -0
  118. package/dist/translator/visitors/tag/custom-tag.d.ts +19 -0
  119. package/dist/translator/visitors/tag/dynamic-tag.d.ts +18 -0
  120. package/dist/translator/visitors/tag/index.d.ts +15 -0
  121. package/dist/translator/visitors/tag/native-tag.d.ts +25 -0
  122. package/dist/translator/visitors/text.d.ts +7 -0
  123. package/package.json +34 -70
  124. package/tag-types/const.d.marko +7 -0
  125. package/tag-types/debug.d.marko +5 -0
  126. package/tag-types/define.d.marko +5 -0
  127. package/tag-types/do.d.marko +5 -0
  128. package/tag-types/effect.d.marko +5 -0
  129. package/tag-types/id.d.marko +3 -0
  130. package/tag-types/let.d.marko +8 -0
  131. package/tag-types/lifecycle.d.marko +7 -0
  132. package/tag-types/log.d.marko +5 -0
  133. package/tag-types/script.d.marko +5 -0
  134. package/README.md +0 -161
  135. package/bin/markoc +0 -2
  136. package/bin/markoc.js +0 -441
  137. package/browser-refresh.js +0 -5
  138. package/compiler-browser.marko +0 -15
  139. package/compiler.js +0 -7
  140. package/components-browser.marko +0 -15
  141. package/components.js +0 -7
  142. package/dist/build.json +0 -3
  143. package/dist/compiler/config.js +0 -45
  144. package/dist/compiler/index.js +0 -164
  145. package/dist/compiler/modules.js +0 -5
  146. package/dist/core-tags/components/init-components-tag.js +0 -54
  147. package/dist/core-tags/components/preferred-script-location-tag.js +0 -25
  148. package/dist/core-tags/components/preserve-tag.js +0 -1
  149. package/dist/core-tags/core/__flush_here_and_after__.js +0 -44
  150. package/dist/core-tags/core/await/AsyncValue.js +0 -121
  151. package/dist/core-tags/core/await/client-reorder-runtime.js +0 -51
  152. package/dist/core-tags/core/await/index.d.marko +0 -10
  153. package/dist/core-tags/core/await/renderer.js +0 -249
  154. package/dist/core-tags/core/await/reorderer-renderer.js +0 -156
  155. package/dist/index.js +0 -4
  156. package/dist/node-require/browser-refresh.js +0 -1
  157. package/dist/node-require/hot-reload.js +0 -45
  158. package/dist/node-require/index.js +0 -103
  159. package/dist/node_modules/@internal/components-beginComponent/index-browser.js +0 -23
  160. package/dist/node_modules/@internal/components-beginComponent/index.js +0 -84
  161. package/dist/node_modules/@internal/components-beginComponent/package.json +0 -11
  162. package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +0 -335
  163. package/dist/node_modules/@internal/components-define-widget-legacy/index.js +0 -18
  164. package/dist/node_modules/@internal/components-define-widget-legacy/package.json +0 -11
  165. package/dist/node_modules/@internal/components-endComponent/index-browser.js +0 -5
  166. package/dist/node_modules/@internal/components-endComponent/index.js +0 -11
  167. package/dist/node_modules/@internal/components-endComponent/package.json +0 -11
  168. package/dist/node_modules/@internal/components-entry/index-browser.js +0 -11
  169. package/dist/node_modules/@internal/components-entry/index.js +0 -301
  170. package/dist/node_modules/@internal/components-entry/package.json +0 -11
  171. package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +0 -76
  172. package/dist/node_modules/@internal/components-entry-legacy/index.js +0 -16
  173. package/dist/node_modules/@internal/components-entry-legacy/package.json +0 -11
  174. package/dist/node_modules/@internal/components-registry/index-browser.js +0 -586
  175. package/dist/node_modules/@internal/components-registry/index.js +0 -44
  176. package/dist/node_modules/@internal/components-registry/package.json +0 -11
  177. package/dist/node_modules/@internal/components-util/index-browser.js +0 -152
  178. package/dist/node_modules/@internal/components-util/index.js +0 -71
  179. package/dist/node_modules/@internal/components-util/package.json +0 -11
  180. package/dist/node_modules/@internal/create-readable/index-browser.js +0 -30
  181. package/dist/node_modules/@internal/create-readable/index.js +0 -57
  182. package/dist/node_modules/@internal/create-readable/package.json +0 -11
  183. package/dist/node_modules/@internal/loader/fallback-node.js +0 -89
  184. package/dist/node_modules/@internal/loader/index-browser.js +0 -2
  185. package/dist/node_modules/@internal/loader/index.js +0 -23
  186. package/dist/node_modules/@internal/loader/package.json +0 -10
  187. package/dist/node_modules/@internal/preserve-tag/index-browser.js +0 -46
  188. package/dist/node_modules/@internal/preserve-tag/index.js +0 -34
  189. package/dist/node_modules/@internal/preserve-tag/package.json +0 -11
  190. package/dist/node_modules/@internal/require/index-browser.js +0 -15
  191. package/dist/node_modules/@internal/require/index-legacy-browser.js +0 -20
  192. package/dist/node_modules/@internal/require/index-webpack.js +0 -16
  193. package/dist/node_modules/@internal/require/index.js +0 -15
  194. package/dist/node_modules/@internal/require/package.json +0 -11
  195. package/dist/node_modules/@internal/set-immediate/index-browser.js +0 -19
  196. package/dist/node_modules/@internal/set-immediate/index-worker.js +0 -31
  197. package/dist/node_modules/@internal/set-immediate/index.js +0 -3
  198. package/dist/node_modules/@internal/set-immediate/package.json +0 -11
  199. package/dist/node_modules/@internal/set-immediate/queueMicrotask.js +0 -8
  200. package/dist/runtime/RenderResult.js +0 -112
  201. package/dist/runtime/components/Component.js +0 -663
  202. package/dist/runtime/components/ComponentDef.js +0 -169
  203. package/dist/runtime/components/ComponentsContext.js +0 -59
  204. package/dist/runtime/components/GlobalComponentsContext.js +0 -10
  205. package/dist/runtime/components/KeySequence.js +0 -16
  206. package/dist/runtime/components/ServerComponent.js +0 -73
  207. package/dist/runtime/components/State.js +0 -101
  208. package/dist/runtime/components/attach-detach.js +0 -60
  209. package/dist/runtime/components/defineComponent.js +0 -60
  210. package/dist/runtime/components/dom-data.js +0 -8
  211. package/dist/runtime/components/event-delegation.js +0 -144
  212. package/dist/runtime/components/index.js +0 -1
  213. package/dist/runtime/components/legacy/browser.json +0 -9
  214. package/dist/runtime/components/legacy/defineComponent-legacy.js +0 -27
  215. package/dist/runtime/components/legacy/defineRenderer-legacy.js +0 -171
  216. package/dist/runtime/components/legacy/defineWidget-legacy.js +0 -1
  217. package/dist/runtime/components/legacy/dependencies/html.js +0 -3
  218. package/dist/runtime/components/legacy/dependencies/index.js +0 -177
  219. package/dist/runtime/components/legacy/dependencies/vdom.js +0 -3
  220. package/dist/runtime/components/legacy/index.js +0 -1
  221. package/dist/runtime/components/legacy/jquery.js +0 -52
  222. package/dist/runtime/components/legacy/ready.js +0 -152
  223. package/dist/runtime/components/legacy/renderer-legacy.js +0 -231
  224. package/dist/runtime/components/registry.js +0 -1
  225. package/dist/runtime/components/renderer.js +0 -236
  226. package/dist/runtime/components/update-manager.js +0 -94
  227. package/dist/runtime/createOut.js +0 -13
  228. package/dist/runtime/dom-insert.js +0 -77
  229. package/dist/runtime/events.js +0 -2
  230. package/dist/runtime/helpers/_change-case.js +0 -45
  231. package/dist/runtime/helpers/assign.js +0 -21
  232. package/dist/runtime/helpers/attr-tag.js +0 -43
  233. package/dist/runtime/helpers/class-value.js +0 -30
  234. package/dist/runtime/helpers/dynamic-tag.js +0 -181
  235. package/dist/runtime/helpers/empty-component.js +0 -1
  236. package/dist/runtime/helpers/merge.js +0 -13
  237. package/dist/runtime/helpers/of-fallback.js +0 -4
  238. package/dist/runtime/helpers/render-tag.js +0 -20
  239. package/dist/runtime/helpers/serialize-noop.js +0 -5
  240. package/dist/runtime/helpers/style-value.js +0 -45
  241. package/dist/runtime/helpers/tags-compat/dom-debug.js +0 -1
  242. package/dist/runtime/helpers/tags-compat/dom-debug.mjs +0 -4
  243. package/dist/runtime/helpers/tags-compat/dom.js +0 -1
  244. package/dist/runtime/helpers/tags-compat/dom.mjs +0 -4
  245. package/dist/runtime/helpers/tags-compat/html-debug.js +0 -3
  246. package/dist/runtime/helpers/tags-compat/html-debug.mjs +0 -4
  247. package/dist/runtime/helpers/tags-compat/html.js +0 -3
  248. package/dist/runtime/helpers/tags-compat/html.mjs +0 -4
  249. package/dist/runtime/helpers/tags-compat/runtime-dom.js +0 -239
  250. package/dist/runtime/helpers/tags-compat/runtime-html.js +0 -136
  251. package/dist/runtime/helpers/to-string.js +0 -5
  252. package/dist/runtime/html/AsyncStream.js +0 -805
  253. package/dist/runtime/html/BufferedWriter.js +0 -52
  254. package/dist/runtime/html/StringWriter.js +0 -73
  255. package/dist/runtime/html/helpers/_dynamic-attr.js +0 -35
  256. package/dist/runtime/html/helpers/attr.js +0 -80
  257. package/dist/runtime/html/helpers/attrs.js +0 -26
  258. package/dist/runtime/html/helpers/class-attr.js +0 -8
  259. package/dist/runtime/html/helpers/data-marko.js +0 -36
  260. package/dist/runtime/html/helpers/escape-quotes.js +0 -35
  261. package/dist/runtime/html/helpers/escape-script-placeholder.js +0 -24
  262. package/dist/runtime/html/helpers/escape-style-placeholder.js +0 -22
  263. package/dist/runtime/html/helpers/escape-xml.js +0 -21
  264. package/dist/runtime/html/helpers/merge-attrs.js +0 -55
  265. package/dist/runtime/html/helpers/props-script.js +0 -32
  266. package/dist/runtime/html/helpers/style-attr.js +0 -8
  267. package/dist/runtime/html/hot-reload.js +0 -26
  268. package/dist/runtime/html/index.js +0 -33
  269. package/dist/runtime/html/marko-namespace.js +0 -3
  270. package/dist/runtime/renderable.js +0 -194
  271. package/dist/runtime/vdom/AsyncVDOMBuilder.js +0 -456
  272. package/dist/runtime/vdom/VComment.js +0 -24
  273. package/dist/runtime/vdom/VComponent.js +0 -17
  274. package/dist/runtime/vdom/VDocumentFragment.js +0 -34
  275. package/dist/runtime/vdom/VElement.js +0 -375
  276. package/dist/runtime/vdom/VFragment.js +0 -26
  277. package/dist/runtime/vdom/VNode.js +0 -100
  278. package/dist/runtime/vdom/VText.js +0 -25
  279. package/dist/runtime/vdom/helpers/attrs.js +0 -62
  280. package/dist/runtime/vdom/helpers/const-element.js +0 -25
  281. package/dist/runtime/vdom/helpers/merge-attrs.js +0 -16
  282. package/dist/runtime/vdom/hot-reload.js +0 -115
  283. package/dist/runtime/vdom/index.js +0 -30
  284. package/dist/runtime/vdom/is-text-only.js +0 -10
  285. package/dist/runtime/vdom/marko-namespace.js +0 -3
  286. package/dist/runtime/vdom/morphdom/fragment.js +0 -95
  287. package/dist/runtime/vdom/morphdom/helpers.js +0 -42
  288. package/dist/runtime/vdom/morphdom/index.js +0 -741
  289. package/dist/runtime/vdom/parse-html.js +0 -18
  290. package/dist/runtime/vdom/vdom.js +0 -88
  291. package/dist/taglib/index.js +0 -51
  292. package/dist/translator/cdata/index.js +0 -15
  293. package/dist/translator/cdata/index[html].js +0 -15
  294. package/dist/translator/cdata/index[vdom].js +0 -12
  295. package/dist/translator/class.js +0 -65
  296. package/dist/translator/comment/index.js +0 -15
  297. package/dist/translator/comment/index[html].js +0 -17
  298. package/dist/translator/comment/index[vdom].js +0 -3
  299. package/dist/translator/declaration/index.js +0 -15
  300. package/dist/translator/declaration/index[html].js +0 -12
  301. package/dist/translator/declaration/index[vdom].js +0 -3
  302. package/dist/translator/document-type/index.js +0 -15
  303. package/dist/translator/document-type/index[html].js +0 -12
  304. package/dist/translator/document-type/index[vdom].js +0 -3
  305. package/dist/translator/placeholder/index.js +0 -15
  306. package/dist/translator/placeholder/index[html].js +0 -93
  307. package/dist/translator/placeholder/index[vdom].js +0 -22
  308. package/dist/translator/scriptlet.js +0 -4
  309. package/dist/translator/tag/attribute/directives/class.js +0 -42
  310. package/dist/translator/tag/attribute/directives/index.js +0 -15
  311. package/dist/translator/tag/attribute/directives/no-update-body-if.js +0 -15
  312. package/dist/translator/tag/attribute/directives/no-update-body.js +0 -10
  313. package/dist/translator/tag/attribute/directives/no-update-if.js +0 -12
  314. package/dist/translator/tag/attribute/directives/no-update.js +0 -48
  315. package/dist/translator/tag/attribute/directives/style.js +0 -42
  316. package/dist/translator/tag/attribute/index.js +0 -150
  317. package/dist/translator/tag/attribute/modifiers/index.js +0 -7
  318. package/dist/translator/tag/attribute/modifiers/no-update.js +0 -14
  319. package/dist/translator/tag/attribute/modifiers/scoped.js +0 -23
  320. package/dist/translator/tag/attribute-tag.js +0 -149
  321. package/dist/translator/tag/custom-tag.js +0 -146
  322. package/dist/translator/tag/dynamic-tag.js +0 -74
  323. package/dist/translator/tag/index.js +0 -287
  324. package/dist/translator/tag/macro-tag.js +0 -7
  325. package/dist/translator/tag/native-tag.js +0 -27
  326. package/dist/translator/tag/native-tag[html]/attributes.js +0 -151
  327. package/dist/translator/tag/native-tag[html]/index.js +0 -221
  328. package/dist/translator/tag/native-tag[vdom]/attributes.js +0 -105
  329. package/dist/translator/tag/native-tag[vdom]/index.js +0 -189
  330. package/dist/translator/tag/util.js +0 -246
  331. package/dist/translator/taglib/core/conditional/translate-else-if.js +0 -20
  332. package/dist/translator/taglib/core/conditional/translate-else.js +0 -20
  333. package/dist/translator/taglib/core/conditional/translate-if.js +0 -8
  334. package/dist/translator/taglib/core/conditional/util.js +0 -41
  335. package/dist/translator/taglib/core/index.js +0 -474
  336. package/dist/translator/taglib/core/macro/parse.js +0 -17
  337. package/dist/translator/taglib/core/macro/translate.js +0 -48
  338. package/dist/translator/taglib/core/parse-class.js +0 -79
  339. package/dist/translator/taglib/core/parse-export.js +0 -14
  340. package/dist/translator/taglib/core/parse-import.js +0 -14
  341. package/dist/translator/taglib/core/parse-module-code.js +0 -18
  342. package/dist/translator/taglib/core/parse-static.js +0 -18
  343. package/dist/translator/taglib/core/transform-style.js +0 -66
  344. package/dist/translator/taglib/core/translate-await.js +0 -41
  345. package/dist/translator/taglib/core/translate-body.js +0 -17
  346. package/dist/translator/taglib/core/translate-for.js +0 -156
  347. package/dist/translator/taglib/core/translate-html-comment.js +0 -52
  348. package/dist/translator/taglib/core/translate-include-content.js +0 -53
  349. package/dist/translator/taglib/core/translate-server-only.js +0 -5
  350. package/dist/translator/taglib/core/translate-while.js +0 -32
  351. package/dist/translator/taglib/index.js +0 -6
  352. package/dist/translator/taglib/migrate/all-templates.js +0 -46
  353. package/dist/translator/taglib/migrate/index.js +0 -5
  354. package/dist/translator/text/index.js +0 -10
  355. package/dist/translator/text/index[html].js +0 -12
  356. package/dist/translator/text/index[vdom].js +0 -20
  357. package/dist/translator/util/add-dependencies.js +0 -329
  358. package/dist/translator/util/escape-regexp.js +0 -4
  359. package/dist/translator/util/get-component-files.js +0 -86
  360. package/dist/translator/util/html-out-write.js +0 -15
  361. package/dist/translator/util/key-manager.js +0 -176
  362. package/dist/translator/util/optimize-html-writes.js +0 -52
  363. package/dist/translator/util/optimize-vdom-create.js +0 -164
  364. package/dist/translator/util/plugin-hooks.js +0 -22
  365. package/dist/translator/util/runtime-flags.js +0 -3
  366. package/dist/translator/util/vdom-out-write.js +0 -10
  367. package/dist/translator/util/with-previous-location.js +0 -6
  368. package/docs/10-awesome-marko-features.md +0 -291
  369. package/docs/body-content.md +0 -355
  370. package/docs/class-components.md +0 -1001
  371. package/docs/cloudflare-workers.md +0 -32
  372. package/docs/compiler-hooks.png +0 -0
  373. package/docs/compiler.md +0 -473
  374. package/docs/component-diagram.afdesign +0 -0
  375. package/docs/component-diagram.svg +0 -87
  376. package/docs/concise.md +0 -141
  377. package/docs/conditionals-and-lists.md +0 -72
  378. package/docs/core-tags.md +0 -325
  379. package/docs/custom-tags.md +0 -201
  380. package/docs/editor-plugins.md +0 -45
  381. package/docs/events.md +0 -131
  382. package/docs/express.md +0 -66
  383. package/docs/fastify.md +0 -65
  384. package/docs/getting-started.md +0 -95
  385. package/docs/http.md +0 -34
  386. package/docs/icons/js.svg +0 -4
  387. package/docs/icons/marko.svg +0 -1
  388. package/docs/icons/ts.svg +0 -1
  389. package/docs/installing.md +0 -51
  390. package/docs/koa.md +0 -35
  391. package/docs/lasso.md +0 -196
  392. package/docs/marko-5-upgrade.md +0 -59
  393. package/docs/marko-json.md +0 -248
  394. package/docs/marko-vs-react.md +0 -854
  395. package/docs/redux.md +0 -61
  396. package/docs/rendering.md +0 -268
  397. package/docs/rollup.md +0 -352
  398. package/docs/state.md +0 -105
  399. package/docs/structure.json +0 -49
  400. package/docs/styles.md +0 -29
  401. package/docs/syntax.md +0 -601
  402. package/docs/troubleshooting-streaming.md +0 -68
  403. package/docs/typescript.md +0 -406
  404. package/docs/vite.md +0 -86
  405. package/docs/webpack.md +0 -205
  406. package/docs/why-is-marko-fast.md +0 -239
  407. package/env.js +0 -7
  408. package/helpers/README.md +0 -3
  409. package/helpers/empty.js +0 -4
  410. package/helpers/notEmpty.js +0 -11
  411. package/index-browser.marko +0 -15
  412. package/index.d.ts +0 -375
  413. package/index.js +0 -7
  414. package/legacy-components-browser.marko +0 -15
  415. package/legacy-components.js +0 -7
  416. package/node-require.js +0 -8
  417. package/src/build.json +0 -3
  418. package/src/compiler/config.js +0 -45
  419. package/src/compiler/index.js +0 -164
  420. package/src/compiler/modules.js +0 -5
  421. package/src/core-tags/.eslintrc +0 -5
  422. package/src/core-tags/components/init-components-tag.js +0 -54
  423. package/src/core-tags/components/preferred-script-location-tag.js +0 -25
  424. package/src/core-tags/components/preserve-tag.js +0 -1
  425. package/src/core-tags/core/__flush_here_and_after__.js +0 -44
  426. package/src/core-tags/core/await/AsyncValue.js +0 -121
  427. package/src/core-tags/core/await/client-reorder-runtime.js +0 -51
  428. package/src/core-tags/core/await/index.d.marko +0 -10
  429. package/src/core-tags/core/await/renderer.js +0 -249
  430. package/src/core-tags/core/await/reorderer-renderer.js +0 -156
  431. package/src/index.js +0 -4
  432. package/src/node-require/browser-refresh.js +0 -18
  433. package/src/node-require/hot-reload.js +0 -45
  434. package/src/node-require/index.js +0 -103
  435. package/src/node_modules/@internal/components-beginComponent/index-browser.js +0 -23
  436. package/src/node_modules/@internal/components-beginComponent/index.js +0 -84
  437. package/src/node_modules/@internal/components-beginComponent/package.json +0 -11
  438. package/src/node_modules/@internal/components-define-widget-legacy/index-browser.js +0 -335
  439. package/src/node_modules/@internal/components-define-widget-legacy/index.js +0 -18
  440. package/src/node_modules/@internal/components-define-widget-legacy/package.json +0 -11
  441. package/src/node_modules/@internal/components-endComponent/index-browser.js +0 -5
  442. package/src/node_modules/@internal/components-endComponent/index.js +0 -11
  443. package/src/node_modules/@internal/components-endComponent/package.json +0 -11
  444. package/src/node_modules/@internal/components-entry/index-browser.js +0 -11
  445. package/src/node_modules/@internal/components-entry/index.js +0 -301
  446. package/src/node_modules/@internal/components-entry/package.json +0 -11
  447. package/src/node_modules/@internal/components-entry-legacy/index-browser.js +0 -76
  448. package/src/node_modules/@internal/components-entry-legacy/index.js +0 -16
  449. package/src/node_modules/@internal/components-entry-legacy/package.json +0 -11
  450. package/src/node_modules/@internal/components-registry/index-browser.js +0 -586
  451. package/src/node_modules/@internal/components-registry/index.js +0 -44
  452. package/src/node_modules/@internal/components-registry/package.json +0 -11
  453. package/src/node_modules/@internal/components-util/index-browser.js +0 -152
  454. package/src/node_modules/@internal/components-util/index.js +0 -75
  455. package/src/node_modules/@internal/components-util/package.json +0 -11
  456. package/src/node_modules/@internal/create-readable/index-browser.js +0 -30
  457. package/src/node_modules/@internal/create-readable/index.js +0 -57
  458. package/src/node_modules/@internal/create-readable/package.json +0 -11
  459. package/src/node_modules/@internal/loader/fallback-node.js +0 -89
  460. package/src/node_modules/@internal/loader/index-browser.js +0 -2
  461. package/src/node_modules/@internal/loader/index.js +0 -23
  462. package/src/node_modules/@internal/loader/package.json +0 -10
  463. package/src/node_modules/@internal/preserve-tag/index-browser.js +0 -46
  464. package/src/node_modules/@internal/preserve-tag/index.js +0 -34
  465. package/src/node_modules/@internal/preserve-tag/package.json +0 -11
  466. package/src/node_modules/@internal/require/index-browser.js +0 -15
  467. package/src/node_modules/@internal/require/index-legacy-browser.js +0 -20
  468. package/src/node_modules/@internal/require/index-webpack.js +0 -16
  469. package/src/node_modules/@internal/require/index.js +0 -15
  470. package/src/node_modules/@internal/require/package.json +0 -11
  471. package/src/node_modules/@internal/set-immediate/index-browser.js +0 -19
  472. package/src/node_modules/@internal/set-immediate/index-worker.js +0 -31
  473. package/src/node_modules/@internal/set-immediate/index.js +0 -3
  474. package/src/node_modules/@internal/set-immediate/package.json +0 -11
  475. package/src/node_modules/@internal/set-immediate/queueMicrotask.js +0 -8
  476. package/src/runtime/.eslintrc +0 -5
  477. package/src/runtime/RenderResult.js +0 -112
  478. package/src/runtime/components/Component.js +0 -663
  479. package/src/runtime/components/ComponentDef.js +0 -169
  480. package/src/runtime/components/ComponentsContext.js +0 -59
  481. package/src/runtime/components/GlobalComponentsContext.js +0 -10
  482. package/src/runtime/components/KeySequence.js +0 -16
  483. package/src/runtime/components/ServerComponent.js +0 -73
  484. package/src/runtime/components/State.js +0 -101
  485. package/src/runtime/components/attach-detach.js +0 -60
  486. package/src/runtime/components/defineComponent.js +0 -60
  487. package/src/runtime/components/dom-data.js +0 -8
  488. package/src/runtime/components/event-delegation.js +0 -144
  489. package/src/runtime/components/index.js +0 -1
  490. package/src/runtime/components/legacy/browser.json +0 -9
  491. package/src/runtime/components/legacy/defineComponent-legacy.js +0 -27
  492. package/src/runtime/components/legacy/defineRenderer-legacy.js +0 -171
  493. package/src/runtime/components/legacy/defineWidget-legacy.js +0 -1
  494. package/src/runtime/components/legacy/dependencies/html.js +0 -3
  495. package/src/runtime/components/legacy/dependencies/index.js +0 -177
  496. package/src/runtime/components/legacy/dependencies/vdom.js +0 -3
  497. package/src/runtime/components/legacy/index.js +0 -1
  498. package/src/runtime/components/legacy/jquery.js +0 -52
  499. package/src/runtime/components/legacy/ready.js +0 -152
  500. package/src/runtime/components/legacy/renderer-legacy.js +0 -231
  501. package/src/runtime/components/registry.js +0 -1
  502. package/src/runtime/components/renderer.js +0 -236
  503. package/src/runtime/components/update-manager.js +0 -94
  504. package/src/runtime/createOut.js +0 -13
  505. package/src/runtime/dom-insert.js +0 -77
  506. package/src/runtime/events.js +0 -2
  507. package/src/runtime/helpers/_change-case.js +0 -45
  508. package/src/runtime/helpers/assign.js +0 -21
  509. package/src/runtime/helpers/attr-tag.js +0 -43
  510. package/src/runtime/helpers/class-value.js +0 -30
  511. package/src/runtime/helpers/dynamic-tag.js +0 -181
  512. package/src/runtime/helpers/empty-component.js +0 -1
  513. package/src/runtime/helpers/merge.js +0 -13
  514. package/src/runtime/helpers/of-fallback.js +0 -4
  515. package/src/runtime/helpers/render-tag.js +0 -20
  516. package/src/runtime/helpers/serialize-noop.js +0 -5
  517. package/src/runtime/helpers/style-value.js +0 -45
  518. package/src/runtime/helpers/tags-compat/dom-debug.js +0 -1
  519. package/src/runtime/helpers/tags-compat/dom-debug.mjs +0 -4
  520. package/src/runtime/helpers/tags-compat/dom.js +0 -1
  521. package/src/runtime/helpers/tags-compat/dom.mjs +0 -4
  522. package/src/runtime/helpers/tags-compat/html-debug.js +0 -3
  523. package/src/runtime/helpers/tags-compat/html-debug.mjs +0 -4
  524. package/src/runtime/helpers/tags-compat/html.js +0 -3
  525. package/src/runtime/helpers/tags-compat/html.mjs +0 -4
  526. package/src/runtime/helpers/tags-compat/runtime-dom.js +0 -239
  527. package/src/runtime/helpers/tags-compat/runtime-html.js +0 -136
  528. package/src/runtime/helpers/to-string.js +0 -5
  529. package/src/runtime/html/AsyncStream.js +0 -805
  530. package/src/runtime/html/BufferedWriter.js +0 -52
  531. package/src/runtime/html/StringWriter.js +0 -73
  532. package/src/runtime/html/helpers/_dynamic-attr.js +0 -35
  533. package/src/runtime/html/helpers/attr.js +0 -80
  534. package/src/runtime/html/helpers/attrs.js +0 -26
  535. package/src/runtime/html/helpers/class-attr.js +0 -8
  536. package/src/runtime/html/helpers/data-marko.js +0 -36
  537. package/src/runtime/html/helpers/escape-quotes.js +0 -35
  538. package/src/runtime/html/helpers/escape-script-placeholder.js +0 -24
  539. package/src/runtime/html/helpers/escape-style-placeholder.js +0 -22
  540. package/src/runtime/html/helpers/escape-xml.js +0 -21
  541. package/src/runtime/html/helpers/merge-attrs.js +0 -55
  542. package/src/runtime/html/helpers/props-script.js +0 -32
  543. package/src/runtime/html/helpers/style-attr.js +0 -8
  544. package/src/runtime/html/hot-reload.js +0 -26
  545. package/src/runtime/html/index.js +0 -33
  546. package/src/runtime/html/marko-namespace.js +0 -3
  547. package/src/runtime/renderable.js +0 -194
  548. package/src/runtime/vdom/AsyncVDOMBuilder.js +0 -456
  549. package/src/runtime/vdom/VComment.js +0 -24
  550. package/src/runtime/vdom/VComponent.js +0 -17
  551. package/src/runtime/vdom/VDocumentFragment.js +0 -34
  552. package/src/runtime/vdom/VElement.js +0 -375
  553. package/src/runtime/vdom/VFragment.js +0 -26
  554. package/src/runtime/vdom/VNode.js +0 -100
  555. package/src/runtime/vdom/VText.js +0 -25
  556. package/src/runtime/vdom/helpers/attrs.js +0 -62
  557. package/src/runtime/vdom/helpers/const-element.js +0 -25
  558. package/src/runtime/vdom/helpers/merge-attrs.js +0 -16
  559. package/src/runtime/vdom/hot-reload.js +0 -115
  560. package/src/runtime/vdom/index.js +0 -30
  561. package/src/runtime/vdom/is-text-only.js +0 -10
  562. package/src/runtime/vdom/marko-namespace.js +0 -3
  563. package/src/runtime/vdom/morphdom/fragment.js +0 -95
  564. package/src/runtime/vdom/morphdom/helpers.js +0 -42
  565. package/src/runtime/vdom/morphdom/index.js +0 -741
  566. package/src/runtime/vdom/parse-html.js +0 -18
  567. package/src/runtime/vdom/vdom.js +0 -88
  568. package/src/taglib/index.js +0 -51
  569. package/src/translator/cdata/index.js +0 -15
  570. package/src/translator/cdata/index[html].js +0 -15
  571. package/src/translator/cdata/index[vdom].js +0 -12
  572. package/src/translator/class.js +0 -65
  573. package/src/translator/comment/index.js +0 -15
  574. package/src/translator/comment/index[html].js +0 -17
  575. package/src/translator/comment/index[vdom].js +0 -3
  576. package/src/translator/declaration/index.js +0 -15
  577. package/src/translator/declaration/index[html].js +0 -12
  578. package/src/translator/declaration/index[vdom].js +0 -3
  579. package/src/translator/document-type/index.js +0 -15
  580. package/src/translator/document-type/index[html].js +0 -12
  581. package/src/translator/document-type/index[vdom].js +0 -3
  582. package/src/translator/index.js +0 -552
  583. package/src/translator/placeholder/index.js +0 -15
  584. package/src/translator/placeholder/index[html].js +0 -93
  585. package/src/translator/placeholder/index[vdom].js +0 -22
  586. package/src/translator/scriptlet.js +0 -4
  587. package/src/translator/tag/attribute/directives/class.js +0 -42
  588. package/src/translator/tag/attribute/directives/index.js +0 -15
  589. package/src/translator/tag/attribute/directives/no-update-body-if.js +0 -15
  590. package/src/translator/tag/attribute/directives/no-update-body.js +0 -10
  591. package/src/translator/tag/attribute/directives/no-update-if.js +0 -12
  592. package/src/translator/tag/attribute/directives/no-update.js +0 -48
  593. package/src/translator/tag/attribute/directives/style.js +0 -42
  594. package/src/translator/tag/attribute/index.js +0 -150
  595. package/src/translator/tag/attribute/modifiers/index.js +0 -7
  596. package/src/translator/tag/attribute/modifiers/no-update.js +0 -14
  597. package/src/translator/tag/attribute/modifiers/scoped.js +0 -23
  598. package/src/translator/tag/attribute-tag.js +0 -149
  599. package/src/translator/tag/custom-tag.js +0 -146
  600. package/src/translator/tag/dynamic-tag.js +0 -74
  601. package/src/translator/tag/index.js +0 -287
  602. package/src/translator/tag/macro-tag.js +0 -7
  603. package/src/translator/tag/native-tag.js +0 -27
  604. package/src/translator/tag/native-tag[html]/attributes.js +0 -151
  605. package/src/translator/tag/native-tag[html]/index.js +0 -221
  606. package/src/translator/tag/native-tag[vdom]/attributes.js +0 -105
  607. package/src/translator/tag/native-tag[vdom]/index.js +0 -189
  608. package/src/translator/tag/util.js +0 -246
  609. package/src/translator/taglib/core/conditional/translate-else-if.js +0 -20
  610. package/src/translator/taglib/core/conditional/translate-else.js +0 -20
  611. package/src/translator/taglib/core/conditional/translate-if.js +0 -8
  612. package/src/translator/taglib/core/conditional/util.js +0 -41
  613. package/src/translator/taglib/core/index.js +0 -474
  614. package/src/translator/taglib/core/macro/parse.js +0 -17
  615. package/src/translator/taglib/core/macro/translate.js +0 -48
  616. package/src/translator/taglib/core/parse-class.js +0 -79
  617. package/src/translator/taglib/core/parse-export.js +0 -14
  618. package/src/translator/taglib/core/parse-import.js +0 -14
  619. package/src/translator/taglib/core/parse-module-code.js +0 -18
  620. package/src/translator/taglib/core/parse-static.js +0 -18
  621. package/src/translator/taglib/core/transform-style.js +0 -66
  622. package/src/translator/taglib/core/translate-await.js +0 -41
  623. package/src/translator/taglib/core/translate-body.js +0 -17
  624. package/src/translator/taglib/core/translate-for.js +0 -156
  625. package/src/translator/taglib/core/translate-html-comment.js +0 -52
  626. package/src/translator/taglib/core/translate-include-content.js +0 -53
  627. package/src/translator/taglib/core/translate-server-only.js +0 -5
  628. package/src/translator/taglib/core/translate-while.js +0 -32
  629. package/src/translator/taglib/index.js +0 -7
  630. package/src/translator/taglib/migrate/all-templates.js +0 -46
  631. package/src/translator/taglib/migrate/index.js +0 -5
  632. package/src/translator/text/index.js +0 -10
  633. package/src/translator/text/index[html].js +0 -12
  634. package/src/translator/text/index[vdom].js +0 -20
  635. package/src/translator/util/add-dependencies.js +0 -329
  636. package/src/translator/util/escape-regexp.js +0 -4
  637. package/src/translator/util/get-component-files.js +0 -86
  638. package/src/translator/util/html-out-write.js +0 -15
  639. package/src/translator/util/key-manager.js +0 -176
  640. package/src/translator/util/optimize-html-writes.js +0 -52
  641. package/src/translator/util/optimize-vdom-create.js +0 -164
  642. package/src/translator/util/plugin-hooks.js +0 -22
  643. package/src/translator/util/runtime-flags.js +0 -3
  644. package/src/translator/util/vdom-out-write.js +0 -10
  645. package/src/translator/util/with-previous-location.js +0 -6
  646. package/tags-html.d.ts +0 -3855
  647. package/translator/index.d.ts +0 -7
  648. package/translator/package.json +0 -5
package/dist/html.js ADDED
@@ -0,0 +1,1818 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+
17
+ // src/html.ts
18
+ var html_exports = {};
19
+ __export(html_exports, {
20
+ $global: () => $global,
21
+ attr: () => attr,
22
+ attrTag: () => attrTag,
23
+ attrTags: () => attrTags,
24
+ attrs: () => attrs,
25
+ classAttr: () => classAttr,
26
+ compat: () => compat,
27
+ controllable_detailsOrDialog_open: () => controllable_detailsOrDialog_open,
28
+ controllable_input_checked: () => controllable_input_checked,
29
+ controllable_input_checkedValue: () => controllable_input_checkedValue,
30
+ controllable_input_value: () => controllable_input_value,
31
+ controllable_select_value: () => controllable_select_value,
32
+ controllable_textarea_value: () => controllable_textarea_value,
33
+ createRenderer: () => createRenderer,
34
+ createTemplate: () => createTemplate,
35
+ dynamicTagArgs: () => dynamicTagArgs,
36
+ dynamicTagInput: () => dynamicTagInput,
37
+ ensureScopeWithId: () => ensureScopeWithId,
38
+ escapeScript: () => escapeScript,
39
+ escapeStyle: () => escapeStyle,
40
+ escapeXML: () => escapeXML,
41
+ forIn: () => forIn,
42
+ forInBy: () => forInBy,
43
+ forOf: () => forOf,
44
+ forOfBy: () => forOfBy,
45
+ forTo: () => forTo,
46
+ forToBy: () => forToBy,
47
+ fork: () => fork,
48
+ getScopeById: () => getScopeById,
49
+ markResumeCleanup: () => markResumeCleanup,
50
+ markResumeControlEnd: () => markResumeControlEnd,
51
+ markResumeControlSingleNodeEnd: () => markResumeControlSingleNodeEnd,
52
+ markResumeNode: () => markResumeNode,
53
+ markResumeScopeStart: () => markResumeScopeStart,
54
+ nextScopeId: () => nextScopeId,
55
+ nextTagId: () => nextTagId,
56
+ nodeRef: () => nodeRef,
57
+ normalizeDynamicRenderer: () => normalizeDynamicRenderer,
58
+ optionValueAttr: () => optionValueAttr,
59
+ partialAttrs: () => partialAttrs,
60
+ peekNextScope: () => peekNextScope,
61
+ register: () => register2,
62
+ styleAttr: () => styleAttr,
63
+ toString: () => toString,
64
+ tryCatch: () => tryCatch,
65
+ tryPlaceholder: () => tryPlaceholder,
66
+ write: () => write,
67
+ writeEffect: () => writeEffect,
68
+ writeExistingScope: () => writeExistingScope,
69
+ writeScope: () => writeScope,
70
+ writeTrailers: () => writeTrailers
71
+ });
72
+ module.exports = __toCommonJS(html_exports);
73
+
74
+ // src/common/attr-tag.ts
75
+ var empty = [], rest = Symbol();
76
+ function attrTag(attrs2) {
77
+ return attrs2[Symbol.iterator] = attrTagIterator, attrs2[rest] = empty, attrs2;
78
+ }
79
+ function attrTags(first, attrs2) {
80
+ return first ? (first[rest] === empty ? first[rest] = [attrs2] : first[rest].push(attrs2), first) : attrTag(attrs2);
81
+ }
82
+ function* attrTagIterator() {
83
+ yield this, yield* this[rest];
84
+ }
85
+
86
+ // src/common/helpers.ts
87
+ function classValue(value) {
88
+ return toDelimitedString(value, " ", stringifyClassObject);
89
+ }
90
+ function stringifyClassObject(name, value) {
91
+ return value ? name : "";
92
+ }
93
+ function styleValue(value) {
94
+ return toDelimitedString(value, ";", stringifyStyleObject);
95
+ }
96
+ var NON_DIMENSIONAL = /^(--|ta|or|li|z)|n-c|i(do|nk|m|t)|w$|we/;
97
+ function stringifyStyleObject(name, value) {
98
+ return value || value === 0 ? `${name}:${typeof value == "number" && value && !NON_DIMENSIONAL.test(name) ? value + "px" : value}` : "";
99
+ }
100
+ function toDelimitedString(val, delimiter, stringify) {
101
+ switch (typeof val) {
102
+ case "string":
103
+ return val;
104
+ case "object":
105
+ if (val !== null) {
106
+ let result = "", curDelimiter = "";
107
+ if (Array.isArray(val))
108
+ for (let v of val) {
109
+ let part = toDelimitedString(v, delimiter, stringify);
110
+ part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
111
+ }
112
+ else
113
+ for (let name in val) {
114
+ let v = val[name], part = stringify(name, v);
115
+ part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
116
+ }
117
+ return result;
118
+ }
119
+ }
120
+ return "";
121
+ }
122
+ function isEventHandler(name) {
123
+ return /^on[A-Z-]/.test(name);
124
+ }
125
+ function getEventHandlerName(name) {
126
+ return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
127
+ }
128
+ function isVoid(value) {
129
+ return value == null || value === !1;
130
+ }
131
+ function normalizeDynamicRenderer(value) {
132
+ if (value) return value.renderBody || value.default || value;
133
+ }
134
+
135
+ // src/html/content.ts
136
+ function toString(val) {
137
+ return val ? val + "" : val === 0 ? "0" : "";
138
+ }
139
+ var unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt;", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
140
+ function escapeXML(val) {
141
+ return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "&zwj;";
142
+ }
143
+ function escapeTextAreaValue(val) {
144
+ return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
145
+ }
146
+ var unsafeScriptReg = /<\/script/g, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
147
+ function escapeScript(val) {
148
+ return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
149
+ }
150
+ var unsafeStyleReg = /<\/style/g, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str;
151
+ function escapeStyle(val) {
152
+ return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
153
+ }
154
+
155
+ // src/html/inlined-runtimes.ts
156
+ var WALKER_RUNTIME_CODE = '(e=>self[e]=self[e]||(l=>{let t,d={},f=[],s=document,a=s.createTreeWalker(s,129),r=self[e][l]={i:l=e+l,d:s,l:d,v:f,x(){},w(e){for(;e=a.nextNode();)this.x(r=(r=e.data)&&!r.indexOf(l)&&(d[t=r.slice(x+1)]=e,r[x]),t,e),r>"#"&&f.push(e)}},x=l.length}))', REORDER_RUNTIME_CODE = '(e=>{let i,t,r,l,d={},n=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(o,a,c,p,b)=>{"#"==o?(d[a]=t).i++:c==r&&i(),"T"==c.tagName&&(a=c.getAttribute(e.i))&&((p=e.l["^"+a])?t=d[a]={i:0,c(i=e.l[a]||l||c){for(;i.parentNode!==p.parentNode;)i=i.parentNode;for(;i!=r;(r=p.nextSibling).remove());n(p,c)}}:(i=()=>{l=c.previousSibling,n(e.l[a],c),--p.i||p.c()},p=t=d[a],r=c.nextElementSibling||i()),b=t.c,(o=e.j[a])&&(t.c=()=>b()+o(e)),c.attributes.c&&t.c())}})';
157
+
158
+ // src/html/serializer.ts
159
+ var { hasOwnProperty } = {}, Generator = function* () {
160
+ }().constructor, AsyncGenerator = async function* () {
161
+ }().constructor, REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
162
+ let KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
163
+ for (let name of Object.getOwnPropertyNames(Symbol)) {
164
+ let symbol = Symbol[name];
165
+ typeof symbol == "symbol" && KNOWN_SYMBOLS2.set(symbol, "Symbol." + name);
166
+ }
167
+ return KNOWN_SYMBOLS2;
168
+ })(), KNOWN_FUNCTIONS = /* @__PURE__ */ new Map([
169
+ // This is by no means an exhaustive list,
170
+ // but it should cover most of the built-in functions.
171
+ [AggregateError, "AggregateError"],
172
+ [Array, "Array"],
173
+ [Array.from, "Array.from"],
174
+ [Array.isArray, "Array.isArray"],
175
+ [Array.of, "Array.of"],
176
+ [ArrayBuffer, "ArrayBuffer"],
177
+ [ArrayBuffer.isView, "ArrayBuffer.isView"],
178
+ [Atomics.add, "Atomics.add"],
179
+ [Atomics.and, "Atomics.and"],
180
+ [Atomics.compareExchange, "Atomics.compareExchange"],
181
+ [Atomics.exchange, "Atomics.exchange"],
182
+ [Atomics.isLockFree, "Atomics.isLockFree"],
183
+ [Atomics.load, "Atomics.load"],
184
+ [Atomics.notify, "Atomics.notify"],
185
+ [Atomics.or, "Atomics.or"],
186
+ [Atomics.store, "Atomics.store"],
187
+ [Atomics.sub, "Atomics.sub"],
188
+ [Atomics.wait, "Atomics.wait"],
189
+ [BigInt, "BigInt"],
190
+ [BigInt.asIntN, "BigInt.asIntN"],
191
+ [BigInt.asUintN, "BigInt.asUintN"],
192
+ [BigInt64Array, "BigInt64Array"],
193
+ [BigInt64Array.from, "BigInt64Array.from"],
194
+ [BigInt64Array.of, "BigInt64Array.of"],
195
+ [BigUint64Array, "BigUint64Array"],
196
+ [BigUint64Array.from, "BigUint64Array.from"],
197
+ [BigUint64Array.of, "BigUint64Array.of"],
198
+ [Boolean, "Boolean"],
199
+ [console.assert, "console.assert"],
200
+ [console.clear, "console.clear"],
201
+ [console.count, "console.count"],
202
+ [console.countReset, "console.countReset"],
203
+ [console.debug, "console.debug"],
204
+ [console.dir, "console.dir"],
205
+ [console.dirxml, "console.dirxml"],
206
+ [console.error, "console.error"],
207
+ [console.group, "console.group"],
208
+ [console.groupCollapsed, "console.groupCollapsed"],
209
+ [console.groupEnd, "console.groupEnd"],
210
+ [console.info, "console.info"],
211
+ [console.log, "console.log"],
212
+ [console.table, "console.table"],
213
+ [console.time, "console.time"],
214
+ [console.timeEnd, "console.timeEnd"],
215
+ [console.timeLog, "console.timeLog"],
216
+ [console.timeStamp, "console.timeStamp"],
217
+ [console.trace, "console.trace"],
218
+ [console.warn, "console.warn"],
219
+ [DataView, "DataView"],
220
+ [Date, "Date"],
221
+ [Date.now, "Date.now"],
222
+ [Date.parse, "Date.parse"],
223
+ [Date.UTC, "Date.UTC"],
224
+ [decodeURI, "decodeURI"],
225
+ [decodeURIComponent, "decodeURIComponent"],
226
+ [encodeURI, "encodeURI"],
227
+ [encodeURIComponent, "encodeURIComponent"],
228
+ [Error, "Error"],
229
+ [EvalError, "EvalError"],
230
+ [Float32Array, "Float32Array"],
231
+ [Float32Array.from, "Float32Array.from"],
232
+ [Float32Array.of, "Float32Array.of"],
233
+ [Float64Array, "Float64Array"],
234
+ [Float64Array.from, "Float64Array.from"],
235
+ [Float64Array.of, "Float64Array.of"],
236
+ [Function, "Function"],
237
+ [globalThis.atob, "atob"],
238
+ [globalThis.btoa, "btoa"],
239
+ [globalThis.clearImmediate, "clearImmediate"],
240
+ [globalThis.clearInterval, "clearInterval"],
241
+ [globalThis.clearTimeout, "clearTimeout"],
242
+ [globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
243
+ [globalThis.crypto?.randomUUID, "crypto.randomUUID"],
244
+ [globalThis.fetch, "fetch"],
245
+ [globalThis.performance?.now, "performance.now"],
246
+ [globalThis.queueMicrotask, "queueMicrotask"],
247
+ [globalThis.setImmediate, "setImmediate"],
248
+ [globalThis.setInterval, "setInterval"],
249
+ [globalThis.setTimeout, "setTimeout"],
250
+ [globalThis.structuredClone, "structuredClone"],
251
+ [globalThis.URL, "URL"],
252
+ [globalThis.URLSearchParams, "URLSearchParams"],
253
+ [globalThis.WritableStream, "WritableStream"],
254
+ [Int16Array, "Int16Array"],
255
+ [Int16Array.from, "Int16Array.from"],
256
+ [Int16Array.of, "Int16Array.of"],
257
+ [Int32Array, "Int32Array"],
258
+ [Int32Array.from, "Int32Array.from"],
259
+ [Int32Array.of, "Int32Array.of"],
260
+ [Int8Array, "Int8Array"],
261
+ [Int8Array.from, "Int8Array.from"],
262
+ [Int8Array.of, "Int8Array.of"],
263
+ [Intl.Collator, "Intl.Collator"],
264
+ [Intl.DateTimeFormat, "Intl.DateTimeFormat"],
265
+ [Intl.DisplayNames, "Intl.DisplayNames"],
266
+ [Intl.getCanonicalLocales, "Intl.getCanonicalLocales"],
267
+ [Intl.ListFormat, "Intl.ListFormat"],
268
+ [Intl.Locale, "Intl.Locale"],
269
+ [Intl.NumberFormat, "Intl.NumberFormat"],
270
+ [Intl.PluralRules, "Intl.PluralRules"],
271
+ [Intl.RelativeTimeFormat, "Intl.RelativeTimeFormat"],
272
+ [Intl.Segmenter, "Intl.Segmenter"],
273
+ [Intl.supportedValuesOf, "Intl.supportedValuesOf"],
274
+ [isFinite, "isFinite"],
275
+ [isNaN, "isNaN"],
276
+ [JSON.parse, "JSON.parse"],
277
+ [JSON.stringify, "JSON.stringify"],
278
+ [Map, "Map"],
279
+ [Map.groupBy, "Map.groupBy"],
280
+ [Math.abs, "Math.abs"],
281
+ [Math.acos, "Math.acos"],
282
+ [Math.acosh, "Math.acosh"],
283
+ [Math.asin, "Math.asin"],
284
+ [Math.asinh, "Math.asinh"],
285
+ [Math.atan, "Math.atan"],
286
+ [Math.atan2, "Math.atan2"],
287
+ [Math.atanh, "Math.atanh"],
288
+ [Math.cbrt, "Math.cbrt"],
289
+ [Math.ceil, "Math.ceil"],
290
+ [Math.clz32, "Math.clz32"],
291
+ [Math.cos, "Math.cos"],
292
+ [Math.cosh, "Math.cosh"],
293
+ [Math.exp, "Math.exp"],
294
+ [Math.expm1, "Math.expm1"],
295
+ [Math.floor, "Math.floor"],
296
+ [Math.fround, "Math.fround"],
297
+ [Math.hypot, "Math.hypot"],
298
+ [Math.imul, "Math.imul"],
299
+ [Math.log, "Math.log"],
300
+ [Math.log10, "Math.log10"],
301
+ [Math.log1p, "Math.log1p"],
302
+ [Math.log2, "Math.log2"],
303
+ [Math.max, "Math.max"],
304
+ [Math.min, "Math.min"],
305
+ [Math.pow, "Math.pow"],
306
+ [Math.random, "Math.random"],
307
+ [Math.round, "Math.round"],
308
+ [Math.sign, "Math.sign"],
309
+ [Math.sin, "Math.sin"],
310
+ [Math.sinh, "Math.sinh"],
311
+ [Math.sqrt, "Math.sqrt"],
312
+ [Math.tan, "Math.tan"],
313
+ [Math.tanh, "Math.tanh"],
314
+ [Math.trunc, "Math.trunc"],
315
+ [Number, "Number"],
316
+ [Number.isFinite, "Number.isFinite"],
317
+ [Number.isInteger, "Number.isInteger"],
318
+ [Number.isNaN, "Number.isNaN"],
319
+ [Number.isSafeInteger, "Number.isSafeInteger"],
320
+ [Number.parseFloat, "Number.parseFloat"],
321
+ [Number.parseInt, "Number.parseInt"],
322
+ [Object, "Object"],
323
+ [Object.assign, "Object.assign"],
324
+ [Object.create, "Object.create"],
325
+ [Object.defineProperties, "Object.defineProperties"],
326
+ [Object.defineProperty, "Object.defineProperty"],
327
+ [Object.entries, "Object.entries"],
328
+ [Object.freeze, "Object.freeze"],
329
+ [Object.fromEntries, "Object.fromEntries"],
330
+ [Object.getOwnPropertyDescriptor, "Object.getOwnPropertyDescriptor"],
331
+ [Object.getOwnPropertyDescriptors, "Object.getOwnPropertyDescriptors"],
332
+ [Object.getOwnPropertyNames, "Object.getOwnPropertyNames"],
333
+ [Object.getOwnPropertySymbols, "Object.getOwnPropertySymbols"],
334
+ [Object.getPrototypeOf, "Object.getPrototypeOf"],
335
+ [Object.is, "Object.is"],
336
+ [Object.isExtensible, "Object.isExtensible"],
337
+ [Object.isFrozen, "Object.isFrozen"],
338
+ [Object.isSealed, "Object.isSealed"],
339
+ [Object.keys, "Object.keys"],
340
+ [Object.preventExtensions, "Object.preventExtensions"],
341
+ [Object.seal, "Object.seal"],
342
+ [Object.setPrototypeOf, "Object.setPrototypeOf"],
343
+ [Object.values, "Object.values"],
344
+ [parseFloat, "parseFloat"],
345
+ [parseInt, "parseInt"],
346
+ [Promise, "Promise"],
347
+ [Proxy, "Proxy"],
348
+ [RangeError, "RangeError"],
349
+ [ReferenceError, "ReferenceError"],
350
+ [Reflect.apply, "Reflect.apply"],
351
+ [Reflect.construct, "Reflect.construct"],
352
+ [Reflect.defineProperty, "Reflect.defineProperty"],
353
+ [Reflect.deleteProperty, "Reflect.deleteProperty"],
354
+ [Reflect.get, "Reflect.get"],
355
+ [Reflect.getOwnPropertyDescriptor, "Reflect.getOwnPropertyDescriptor"],
356
+ [Reflect.getPrototypeOf, "Reflect.getPrototypeOf"],
357
+ [Reflect.has, "Reflect.has"],
358
+ [Reflect.isExtensible, "Reflect.isExtensible"],
359
+ [Reflect.ownKeys, "Reflect.ownKeys"],
360
+ [Reflect.preventExtensions, "Reflect.preventExtensions"],
361
+ [Reflect.set, "Reflect.set"],
362
+ [Reflect.setPrototypeOf, "Reflect.setPrototypeOf"],
363
+ [RegExp, "RegExp"],
364
+ [Set, "Set"],
365
+ [String, "String"],
366
+ [String.fromCharCode, "String.fromCharCode"],
367
+ [String.fromCodePoint, "String.fromCodePoint"],
368
+ [String.raw, "String.raw"],
369
+ [Symbol, "Symbol"],
370
+ [Symbol.for, "Symbol.for"],
371
+ [SyntaxError, "SyntaxError"],
372
+ [TypeError, "TypeError"],
373
+ [Uint16Array, "Uint16Array"],
374
+ [Uint16Array.from, "Uint16Array.from"],
375
+ [Uint16Array.of, "Uint16Array.of"],
376
+ [Uint32Array, "Uint32Array"],
377
+ [Uint32Array.from, "Uint32Array.from"],
378
+ [Uint32Array.of, "Uint32Array.of"],
379
+ [Uint8Array, "Uint8Array"],
380
+ [Uint8Array.from, "Uint8Array.from"],
381
+ [Uint8Array.of, "Uint8Array.of"],
382
+ [Uint8ClampedArray, "Uint8ClampedArray"],
383
+ [Uint8ClampedArray.from, "Uint8ClampedArray.from"],
384
+ [Uint8ClampedArray.of, "Uint8ClampedArray.of"],
385
+ [URIError, "URIError"],
386
+ [WeakMap, "WeakMap"],
387
+ [WeakSet, "WeakSet"]
388
+ ]), KNOWN_OBJECTS = /* @__PURE__ */ new Map([
389
+ [Atomics, "Atomics"],
390
+ [console, "console"],
391
+ [globalThis, "globalThis"],
392
+ [globalThis.crypto, "crypto"],
393
+ [Intl, "Intl"],
394
+ [JSON, "JSON"],
395
+ [Math, "Math"],
396
+ [Reflect, "Reflect"]
397
+ ]), State = class {
398
+ ids = 0;
399
+ flush = 0;
400
+ flushed = !1;
401
+ buf = [];
402
+ refs = /* @__PURE__ */ new WeakMap();
403
+ assigned = /* @__PURE__ */ new Set();
404
+ boundary = void 0;
405
+ }, Reference = class {
406
+ constructor(parent, accessor, flush, pos = null, id = null) {
407
+ this.parent = parent;
408
+ this.accessor = accessor;
409
+ this.flush = flush;
410
+ this.pos = pos;
411
+ this.id = id;
412
+ this.parent = parent, this.accessor = accessor, this.flush = flush, this.pos = pos, this.id = id;
413
+ }
414
+ init = "";
415
+ assigns = "";
416
+ }, Serializer = class {
417
+ #state = new State();
418
+ get flushed() {
419
+ return this.#state.flushed;
420
+ }
421
+ stringify(val, boundary) {
422
+ try {
423
+ return this.#state.flushed = !1, this.#state.boundary = boundary, writeRoot(this.#state, val);
424
+ } finally {
425
+ this.#flush();
426
+ }
427
+ }
428
+ nextId() {
429
+ return nextId(this.#state);
430
+ }
431
+ symbol(id) {
432
+ let symbol = Symbol();
433
+ return this.#state.refs.set(symbol, new Reference(null, null, 0, null, id)), symbol;
434
+ }
435
+ #flush() {
436
+ this.#state.flush++, this.#state.buf = [], this.#state.assigned = /* @__PURE__ */ new Set();
437
+ }
438
+ };
439
+ function register(id, val, scope) {
440
+ return REGISTRY.set(val, { id, scope, access: "_._" + toAccess(toObjectKey(id)) }), val;
441
+ }
442
+ function getRegistered(val) {
443
+ let registered = REGISTRY.get(val);
444
+ if (registered)
445
+ return {
446
+ id: registered.id,
447
+ scope: registered.scope
448
+ };
449
+ }
450
+ function writeRoot(state, root) {
451
+ let { buf, assigned } = state, hadBuf = buf.length !== 0, result = "";
452
+ if (hadBuf && buf.push(","), writeProp(state, root, null, "")) {
453
+ let rootRef = state.refs.get(root);
454
+ rootRef && ensureId(state, rootRef), assigned.size && (assigned.delete(rootRef) ? (assigned.add(rootRef), writeAssigned(state)) : (writeAssigned(state), buf.push("," + rootRef.id))), result = "(", buf.push(")");
455
+ } else
456
+ hadBuf && (buf.pop(), writeAssigned(state)), result = "{", buf.push("}");
457
+ for (let chunk of buf)
458
+ result += chunk;
459
+ return "_=>" + result;
460
+ }
461
+ function writeAssigned(state) {
462
+ for (let valueRef of state.assigned)
463
+ state.buf.push("," + valueRef.assigns + (valueRef.init || valueRef.id)), valueRef.init = "";
464
+ }
465
+ function writeProp(state, val, parent, accessor) {
466
+ switch (typeof val) {
467
+ case "string":
468
+ return writeString(state, val);
469
+ case "number":
470
+ return writeNumber(state, val);
471
+ case "boolean":
472
+ return writeBoolean(state, val);
473
+ case "bigint":
474
+ return writeBigInt(state, val);
475
+ case "symbol":
476
+ return writeSymbol(state, val, parent, accessor);
477
+ case "function":
478
+ return writeFunction(state, val, parent, accessor);
479
+ case "object":
480
+ return writeObject(state, val, parent, accessor);
481
+ default:
482
+ return !1;
483
+ }
484
+ }
485
+ function writeReferenceOr(state, write2, val, parent, accessor) {
486
+ let ref = state.refs.get(val);
487
+ if (ref)
488
+ return ref.init ? (ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1) : isCircular(parent, ref) ? (ref.assigns || (ensureId(state, ref), state.assigned.add(ref)), ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1) : (state.buf.push(ensureId(state, ref)), !0);
489
+ let registered = REGISTRY.get(val);
490
+ return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(
491
+ val,
492
+ ref = new Reference(parent, accessor, state.flush, state.buf.length)
493
+ ), write2(state, val, ref) ? !0 : (state.refs.delete(ref), !1));
494
+ }
495
+ function writeRegistered(state, val, parent, accessor, { access, scope }) {
496
+ if (scope) {
497
+ let scopeRef = state.refs.get(scope), fnRef = new Reference(
498
+ parent,
499
+ accessor,
500
+ state.flush,
501
+ state.buf.length
502
+ );
503
+ if (state.refs.set(val, fnRef), scopeRef) {
504
+ let scopeId = ensureId(state, scopeRef);
505
+ if (isCircular(parent, scopeRef))
506
+ return state.assigned.add(fnRef), fnRef.init = access + "(" + scopeId + ")", fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1;
507
+ state.buf.push(access + "(" + scopeId + ")");
508
+ } else {
509
+ state.buf.push(access + "("), writeProp(state, scope, parent, "");
510
+ let scopeRef2 = state.refs.get(scope);
511
+ scopeRef2 && ensureId(state, scopeRef2), state.buf.push(")");
512
+ }
513
+ } else
514
+ state.buf.push(access);
515
+ return !0;
516
+ }
517
+ function writeString(state, val) {
518
+ return state.buf.push(quote(val, 0)), !0;
519
+ }
520
+ function writeNumber(state, val) {
521
+ return state.buf.push(val + ""), !0;
522
+ }
523
+ function writeBoolean(state, val) {
524
+ return state.buf.push(val ? "!0" : "!1"), !0;
525
+ }
526
+ function writeBigInt(state, val) {
527
+ return state.buf.push(val + "n"), !0;
528
+ }
529
+ function writeFunction(state, val, parent, accessor) {
530
+ let wellKnownFunction = KNOWN_FUNCTIONS.get(val);
531
+ return wellKnownFunction ? (state.buf.push(wellKnownFunction), !0) : writeReferenceOr(state, writeNever, val, parent, accessor);
532
+ }
533
+ function writeSymbol(state, val, parent, accessor) {
534
+ let wellKnownSymbol = KNOWN_SYMBOLS.get(val);
535
+ if (wellKnownSymbol)
536
+ return state.buf.push(wellKnownSymbol), !0;
537
+ let key = Symbol.keyFor(val);
538
+ return key !== void 0 ? (state.buf.push("Symbol.for(" + quote(key, 0) + ")"), !0) : writeReferenceOr(state, writeUnknownSymbol, val, parent, accessor);
539
+ }
540
+ function writeUnknownSymbol(state) {
541
+ return state.buf.push("Symbol()"), !0;
542
+ }
543
+ function writeNever() {
544
+ return !1;
545
+ }
546
+ function writeNull(state) {
547
+ return state.buf.push("null"), !0;
548
+ }
549
+ function writeObject(state, val, parent, accessor) {
550
+ if (val === null) return writeNull(state);
551
+ let wellKnownObject = KNOWN_OBJECTS.get(val);
552
+ return wellKnownObject ? (state.buf.push(wellKnownObject), !0) : writeReferenceOr(state, writeUnknownObject, val, parent, accessor);
553
+ }
554
+ function writeUnknownObject(state, val, ref) {
555
+ switch (val.constructor) {
556
+ case void 0:
557
+ return writeNullObject(state, val, ref);
558
+ case Object:
559
+ return writePlainObject(state, val, ref);
560
+ case Array:
561
+ return writeArray(state, val, ref);
562
+ case Date:
563
+ return writeDate(state, val);
564
+ case RegExp:
565
+ return writeRegExp(state, val);
566
+ case Promise:
567
+ return writePromise(state, val, ref);
568
+ case Map:
569
+ return writeMap(state, val, ref);
570
+ case Set:
571
+ return writeSet(state, val, ref);
572
+ case Generator:
573
+ return writeGenerator(state, val, ref);
574
+ case AsyncGenerator:
575
+ return writeAsyncGenerator(state, val, ref);
576
+ case Error:
577
+ case EvalError:
578
+ case RangeError:
579
+ case ReferenceError:
580
+ case SyntaxError:
581
+ case TypeError:
582
+ case URIError:
583
+ return writeError(state, val, ref);
584
+ case AggregateError:
585
+ return writeAggregateError(state, val, ref);
586
+ case ArrayBuffer:
587
+ return writeArrayBuffer(state, val);
588
+ case Int8Array:
589
+ case Uint8Array:
590
+ case Uint8ClampedArray:
591
+ case Int16Array:
592
+ case Uint16Array:
593
+ case Int32Array:
594
+ case Uint32Array:
595
+ case Float32Array:
596
+ case Float64Array:
597
+ return writeTypedArray(state, val, ref);
598
+ case WeakSet:
599
+ return writeWeakSet(state);
600
+ case WeakMap:
601
+ return writeWeakMap(state);
602
+ // The following references use `globalThis`
603
+ // since they are not implemented by all runtimes.
604
+ case globalThis.URL:
605
+ return writeURL(state, val);
606
+ case globalThis.URLSearchParams:
607
+ return writeURLSearchParams(state, val);
608
+ case globalThis.Headers:
609
+ return writeHeaders(state, val);
610
+ case globalThis.FormData:
611
+ return writeFormData(state, val);
612
+ case globalThis.ReadableStream:
613
+ return writeReadableStream(state, val, ref);
614
+ case globalThis.Request:
615
+ return writeRequest(state, val, ref);
616
+ case globalThis.Response:
617
+ return writeResponse(state, val, ref);
618
+ }
619
+ return !1;
620
+ }
621
+ function writePlainObject(state, val, ref) {
622
+ return state.buf.push("{"), writeObjectProps(state, val, ref), state.buf.push("}"), !0;
623
+ }
624
+ function writeArray(state, val, ref) {
625
+ state.buf.push("["), writeProp(state, val[0], ref, "0");
626
+ for (let i = 1; i < val.length; i++)
627
+ state.buf.push(","), writeProp(state, val[i], ref, "" + i);
628
+ return state.buf.push("]"), !0;
629
+ }
630
+ function writeDate(state, val) {
631
+ return state.buf.push('new Date("' + val.toISOString() + '")'), !0;
632
+ }
633
+ function writeRegExp(state, val) {
634
+ return state.buf.push(val + ""), !0;
635
+ }
636
+ function writePromise(state, val, ref) {
637
+ let { boundary } = state;
638
+ if (!boundary) return !1;
639
+ let pId = nextRefAccess(state), pRef = new Reference(ref, null, state.flush, null, pId);
640
+ return state.buf.push("new Promise((f,r)=>" + pId + "={f,r})"), val.then(
641
+ (v) => writeAsyncCall(state, boundary, pRef, "f", v, pId),
642
+ (v) => writeAsyncCall(state, boundary, pRef, "r", v, pId)
643
+ ), boundary.startAsync(), !0;
644
+ }
645
+ function writeMap(state, val, ref) {
646
+ if (!val.size)
647
+ return state.buf.push("new Map"), !0;
648
+ let items = [], assigns = "";
649
+ for (let [itemKey, itemValue] of val)
650
+ itemKey === val && (itemKey = void 0, assigns += "i[" + items.length + "][0]="), itemValue === val && (itemValue = void 0, assigns += "i[" + items.length + "][1]="), itemValue === void 0 ? items.push([itemKey]) : items.push([itemKey, itemValue]);
651
+ let arrayRef = new Reference(
652
+ ref,
653
+ null,
654
+ state.flush,
655
+ null,
656
+ nextRefAccess(state)
657
+ );
658
+ return state.buf.push(
659
+ (assigns ? "((m,i)=>(" + assigns + "m,i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
660
+ ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
661
+ }
662
+ function writeSet(state, val, ref) {
663
+ if (!val.size)
664
+ return state.buf.push("new Set"), !0;
665
+ let items = [], assigns = "";
666
+ for (let item of val)
667
+ item === val && (item = void 0, assigns += "i[" + items.length + "]="), items.push(item);
668
+ let arrayRef = new Reference(
669
+ ref,
670
+ null,
671
+ state.flush,
672
+ null,
673
+ nextRefAccess(state)
674
+ );
675
+ return state.buf.push(
676
+ (assigns ? "((s,i)=>(" + assigns + "s,i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
677
+ ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
678
+ }
679
+ function writeArrayBuffer(state, val) {
680
+ let result = "";
681
+ if (val.byteLength) {
682
+ let view = new Int8Array(val);
683
+ result = hasOnlyZeros(view) ? "new ArrayBuffer(" + val.byteLength + ")" : "new Int8Array(" + typedArrayToInitString(view) + ").buffer";
684
+ } else
685
+ result = "new ArrayBuffer";
686
+ return state.buf.push(result), !0;
687
+ }
688
+ function writeTypedArray(state, val, ref) {
689
+ return val.byteOffset || state.refs.has(val.buffer) ? (state.buf.push("new " + val.constructor.name + "("), writeProp(state, val.buffer, ref, "buffer"), state.buf.push(val.byteOffset ? "," + val.byteOffset + ")" : ")")) : (state.refs.set(val.buffer, new Reference(ref, "buffer", state.flush, null)), state.buf.push(
690
+ "new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")")
691
+ )), !0;
692
+ }
693
+ function writeWeakSet(state) {
694
+ return state.buf.push("new WeakSet"), !0;
695
+ }
696
+ function writeWeakMap(state) {
697
+ return state.buf.push("new WeakMap"), !0;
698
+ }
699
+ function writeError(state, val, ref) {
700
+ let result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
701
+ return val.cause ? (state.buf.push(result + ",{cause:"), writeProp(state, val.cause, ref, "cause"), state.buf.push("})")) : state.buf.push(result + ")"), !0;
702
+ }
703
+ function writeAggregateError(state, val, ref) {
704
+ return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
705
+ }
706
+ function writeURL(state, val) {
707
+ return state.buf.push("new URL(" + quote(val.toString(), 0) + ")"), !0;
708
+ }
709
+ function writeURLSearchParams(state, val) {
710
+ let str = val.toString();
711
+ return str ? state.buf.push("new URLSearchParams(" + quote(str, 0) + ")") : state.buf.push("new URLSearchParams"), !0;
712
+ }
713
+ function writeHeaders(state, val) {
714
+ let headers = stringEntriesToProps(val);
715
+ return state.buf.push("new Headers" + (headers ? "({" + headers + "})" : "")), !0;
716
+ }
717
+ function writeFormData(state, val) {
718
+ let sep = "[", valStr = "";
719
+ for (let [key, value] of val)
720
+ typeof value == "string" && (valStr += sep + "[" + quote(key, 0) + "," + quote(value, 0) + "]", sep = ",");
721
+ return sep === "[" ? state.buf.push("new FormData") : state.buf.push(
722
+ "((f,i)=>(f,i.forEach(i=>f.append(i[0],i[1])),f))(new FormData," + valStr + "])"
723
+ ), !0;
724
+ }
725
+ function writeRequest(state, val, ref) {
726
+ let sep = "", hasBody = val.body && !val.bodyUsed && val.duplex === "half";
727
+ state.buf.push("new Request(" + quote(val.url, 0)), hasBody && (state.buf.push(",{body:"), writeProp(state, val.body, ref, "body") ? (state.buf.push(',duplex:"half"'), sep = ",") : state.buf.pop());
728
+ let options = "";
729
+ val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
730
+ let headers = stringEntriesToProps(val.headers);
731
+ return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:{" + headers + "}", sep = ","), val.integrity && (options += sep + "integrity:" + quote(val.integrity, 0), sep = ","), val.keepalive && (options += sep + "keepalive:true", sep = ","), val.method !== "GET" && (options += sep + "method:" + quote(val.method, 0), sep = ","), val.mode !== "cors" && (options += sep + "mode:" + quote(val.mode, 0), sep = ","), val.redirect !== "follow" && (options += sep + "redirect:" + quote(val.redirect, 0), sep = ","), val.referrer !== "about:client" && (options += sep + "referrer:" + quote(val.referrer, 0), sep = ","), val.referrerPolicy && (options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0), sep = ","), state.buf.push(
732
+ hasBody ? options + "})" : options ? ",{" + options + "})" : ")"
733
+ ), !0;
734
+ }
735
+ function writeResponse(state, val, ref) {
736
+ let sep = "", options = "";
737
+ val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
738
+ let headers = stringEntriesToProps(val.headers);
739
+ return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:{" + headers + "}", sep = ","), !val.body || val.bodyUsed ? state.buf.push(
740
+ "new Response" + (options ? "(null,{" + options + "})" : "")
741
+ ) : (state.buf.push("new Response("), state.buf.push(
742
+ (writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")")
743
+ )), !0;
744
+ }
745
+ function writeReadableStream(state, val, ref) {
746
+ let { boundary } = state;
747
+ if (!boundary || val.locked) return !1;
748
+ let reader = val.getReader(), iterId = nextRefAccess(state), iterRef = new Reference(ref, null, state.flush, null, iterId), onFulfilled = ({ value, done }) => {
749
+ done ? writeAsyncCall(state, boundary, iterRef, "r", value) : boundary.signal.aborted || (reader.read().then(onFulfilled, onRejected), boundary.startAsync(), writeAsyncCall(state, boundary, iterRef, "f", value));
750
+ }, onRejected = (reason) => {
751
+ writeAsyncCall(state, boundary, iterRef, "j", reason);
752
+ };
753
+ return state.buf.push(
754
+ "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))}})"
755
+ ), reader.read().then(onFulfilled, onRejected), boundary.startAsync(), !0;
756
+ }
757
+ function writeGenerator(state, iter, ref) {
758
+ let sep = "";
759
+ for (state.buf.push("(function*(){"); ; ) {
760
+ let { value, done } = iter.next();
761
+ if (done) {
762
+ value !== void 0 && (state.buf.push(sep + "return "), writeProp(state, value, ref, ""));
763
+ break;
764
+ }
765
+ value === void 0 ? state.buf.push(sep + "yield") : (state.buf.push(sep + "yield "), writeProp(state, value, ref, "")), sep = ";";
766
+ }
767
+ return state.buf.push("})()"), !0;
768
+ }
769
+ function writeAsyncGenerator(state, iter, ref) {
770
+ let { boundary } = state;
771
+ if (!boundary) return !1;
772
+ let iterId = nextRefAccess(state), iterRef = new Reference(ref, null, state.flush, null, iterId), onFulfilled = ({ value, done }) => {
773
+ done ? writeAsyncCall(state, boundary, iterRef, "r", value) : boundary.signal.aborted || (iter.next().then(onFulfilled, onRejected), boundary.startAsync(), writeAsyncCall(state, boundary, iterRef, "f", value));
774
+ }, onRejected = (reason) => {
775
+ writeAsyncCall(state, boundary, iterRef, "j", reason);
776
+ };
777
+ return state.buf.push(
778
+ "(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 + "={})"
779
+ ), iter.next().then(onFulfilled, onRejected), boundary.startAsync(), !0;
780
+ }
781
+ function writeNullObject(state, val, ref) {
782
+ return state.buf.push("{"), state.buf.push(writeObjectProps(state, val, ref) + "__proto__:null}"), !0;
783
+ }
784
+ function writeObjectProps(state, val, ref) {
785
+ let sep = "";
786
+ for (let key in val)
787
+ if (hasOwnProperty.call(val, key)) {
788
+ let escapedKey = toObjectKey(key);
789
+ state.buf.push(sep + escapedKey + ":"), writeProp(
790
+ state,
791
+ val[key],
792
+ ref,
793
+ escapedKey
794
+ ) ? sep = "," : state.buf.pop();
795
+ }
796
+ if (hasSymbolIterator(val) && (state.buf.push(sep + "[Symbol.iterator]:"), sep = ",", !writeReferenceOr(
797
+ state,
798
+ writeNever,
799
+ val[Symbol.iterator],
800
+ ref,
801
+ "Symbol.iterator"
802
+ ))) {
803
+ let arrayRef = new Reference(
804
+ ref,
805
+ null,
806
+ state.flush,
807
+ null,
808
+ nextRefAccess(state)
809
+ );
810
+ state.buf.push("(a=>()=>a.values())(" + arrayRef.id + "="), writeArray(state, [...val], arrayRef), state.buf.push(")");
811
+ }
812
+ return sep;
813
+ }
814
+ function writeAsyncCall(state, boundary, ref, method, value, preferredValueId = null) {
815
+ if (boundary.signal.aborted) return;
816
+ state.flushed = !0;
817
+ let valueStartIndex = state.buf.push(
818
+ (state.buf.length === 0 ? "" : ",") + ref.id + "." + method + "("
819
+ );
820
+ if (writeProp(state, value, ref, "")) {
821
+ let valueRef = state.refs.get(value);
822
+ valueRef && !valueRef.id && (valueRef.id = preferredValueId || nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
823
+ }
824
+ state.buf.push(")"), boundary.endAsync();
825
+ }
826
+ function isCircular(parent, ref) {
827
+ let cur = parent;
828
+ for (; cur; ) {
829
+ if (cur === ref) return !0;
830
+ cur = cur.parent;
831
+ }
832
+ return !1;
833
+ }
834
+ function toObjectKey(name) {
835
+ if (name === "")
836
+ return '""';
837
+ let startChar = name[0];
838
+ if (isDigit(startChar)) {
839
+ if (startChar === "0") {
840
+ if (name !== "0")
841
+ return quote(name, 1);
842
+ } else
843
+ for (let i = 1; i < name.length; i++)
844
+ if (!isDigit(name[i]))
845
+ return quote(name, i);
846
+ } else if (isWord(startChar)) {
847
+ for (let i = 1; i < name.length; i++)
848
+ if (!isWordOrDigit(name[i]))
849
+ return quote(name, i);
850
+ } else
851
+ return quote(name, 0);
852
+ return name;
853
+ }
854
+ function toAccess(accessor) {
855
+ let start = accessor[0];
856
+ return start === '"' || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
857
+ }
858
+ function quote(str, startPos) {
859
+ let result = "", lastPos = 0;
860
+ for (let i = startPos; i < str.length; i++) {
861
+ let replacement;
862
+ switch (str[i]) {
863
+ case '"':
864
+ replacement = '\\"';
865
+ break;
866
+ case "\\":
867
+ replacement = "\\\\";
868
+ break;
869
+ case "<":
870
+ replacement = "\\x3C";
871
+ break;
872
+ case `
873
+ `:
874
+ replacement = "\\n";
875
+ break;
876
+ case "\r":
877
+ replacement = "\\r";
878
+ break;
879
+ case "\u2028":
880
+ replacement = "\\u2028";
881
+ break;
882
+ case "\u2029":
883
+ replacement = "\\u2029";
884
+ break;
885
+ default:
886
+ continue;
887
+ }
888
+ result += str.slice(lastPos, i) + replacement, lastPos = i + 1;
889
+ }
890
+ return '"' + (lastPos === startPos ? str : result + str.slice(lastPos)) + '"';
891
+ }
892
+ function ensureId(state, ref) {
893
+ return ref.id || assignId(state, ref);
894
+ }
895
+ function assignId(state, ref) {
896
+ let { pos } = ref;
897
+ if (ref.id = nextRefAccess(state), pos !== null && ref.flush === state.flush)
898
+ return pos === 0 ? state.buf[0] = ref.id + "=" + state.buf[0] : state.buf[pos - 1] += ref.id + "=", ref.id;
899
+ let cur = ref, accessPrevValue = "";
900
+ do {
901
+ accessPrevValue = toAccess(cur.accessor) + accessPrevValue;
902
+ let parent = cur.parent;
903
+ if (parent.id) {
904
+ accessPrevValue = parent.id + accessPrevValue;
905
+ break;
906
+ }
907
+ if (parent.flush === state.flush) {
908
+ accessPrevValue = ensureId(state, parent) + accessPrevValue;
909
+ break;
910
+ }
911
+ cur = parent;
912
+ } while (cur);
913
+ return ref.id + "=" + accessPrevValue;
914
+ }
915
+ function nextRefAccess(state) {
916
+ return "_." + nextId(state);
917
+ }
918
+ function nextId(state) {
919
+ let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 11, index = state.ids++, mod = index % encodeStartLen, id = encodeChars[mod];
920
+ for (index = (index - mod) / encodeStartLen; index > 0; )
921
+ mod = index % encodeLen, id += encodeChars[mod], index = (index - mod) / encodeLen;
922
+ return id;
923
+ }
924
+ function hasSymbolIterator(value) {
925
+ return Symbol.iterator in value;
926
+ }
927
+ function stringEntriesToProps(entries) {
928
+ let result = "", sep = "";
929
+ for (let [key, value] of entries)
930
+ result += sep + toObjectKey(key) + ":" + quote(value, 0), sep = ",";
931
+ return result;
932
+ }
933
+ function typedArrayToInitString(view) {
934
+ let result = "[", sep = "";
935
+ for (let i = 0; i < view.length; i++)
936
+ result += sep + view[i], sep = ",";
937
+ return result += "]", result;
938
+ }
939
+ function hasOnlyZeros(typedArray) {
940
+ for (let i = 0; i < typedArray.length; i++)
941
+ if (typedArray[i] !== 0) return !1;
942
+ return !0;
943
+ }
944
+ function isWordOrDigit(char) {
945
+ return isWord(char) || isDigit(char);
946
+ }
947
+ function isDigit(char) {
948
+ return char >= "0" && char <= "9";
949
+ }
950
+ function isWord(char) {
951
+ return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$";
952
+ }
953
+
954
+ // src/html/writer.ts
955
+ var $chunk, NOOP = () => {
956
+ }, K_SCOPE_ID = Symbol("Scope ID");
957
+ function getChunk() {
958
+ return $chunk;
959
+ }
960
+ function getScopeId(scope) {
961
+ return scope[K_SCOPE_ID];
962
+ }
963
+ function write(html) {
964
+ $chunk.writeHTML(html);
965
+ }
966
+ function writeScript(script) {
967
+ $chunk.writeScript(script);
968
+ }
969
+ function writeEffect(scopeId, registryId) {
970
+ $chunk.boundary.state.needsMainRuntime = !0, $chunk.writeEffect(scopeId, registryId);
971
+ }
972
+ var kPendingContexts = Symbol("Pending Contexts");
973
+ function withContext(key, value, cb) {
974
+ let ctx = $chunk.context ||= { [kPendingContexts]: 0 }, prev = ctx[key];
975
+ ctx[kPendingContexts]++, ctx[key] = value;
976
+ try {
977
+ cb();
978
+ } finally {
979
+ ctx[kPendingContexts]--, ctx[key] = prev;
980
+ }
981
+ }
982
+ function register2(val, id, scopeId) {
983
+ return scopeId === void 0 ? register(id, val) : register(id, val, ensureScopeWithId(scopeId));
984
+ }
985
+ function nextTagId() {
986
+ let state = $chunk.boundary.state, { $global: $global2 } = state;
987
+ return "s" + $global2.runtimeId + $global2.renderId + (state.tagIndex++).toString(36);
988
+ }
989
+ function nextScopeId() {
990
+ return $chunk.boundary.state.scopeIndex++;
991
+ }
992
+ function peekNextScopeId() {
993
+ return $chunk.boundary.state.scopeIndex;
994
+ }
995
+ function peekNextScope() {
996
+ return ensureScopeWithId(peekNextScopeId());
997
+ }
998
+ function getScopeById(scopeId) {
999
+ if (scopeId !== void 0)
1000
+ return $chunk.boundary.state.scopes.get(scopeId);
1001
+ }
1002
+ function markResumeNode(scopeId, accessor) {
1003
+ let { state } = $chunk.boundary;
1004
+ return state.needsMainRuntime = !0, state.mark("*" /* Node */, scopeId + " " + accessor);
1005
+ }
1006
+ function nodeRef(scopeId, id) {
1007
+ let getter = () => {
1008
+ };
1009
+ return id ? register2(getter, id, scopeId) : getter;
1010
+ }
1011
+ function markResumeScopeStart(scopeId, index) {
1012
+ return $chunk.boundary.state.mark(
1013
+ "[" /* SectionStart */,
1014
+ scopeId + (index ? " " + index : "")
1015
+ );
1016
+ }
1017
+ function markResumeControlEnd(scopeId, accessor) {
1018
+ return $chunk.boundary.state.mark("]" /* SectionEnd */, scopeId + " " + accessor);
1019
+ }
1020
+ function markResumeControlSingleNodeEnd(scopeId, accessor, childScopeIds) {
1021
+ return $chunk.boundary.state.mark(
1022
+ "|" /* SectionSingleNodesEnd */,
1023
+ scopeId + " " + accessor + " " + (childScopeIds ?? "")
1024
+ );
1025
+ }
1026
+ function markResumeCleanup(scopeId) {
1027
+ return $chunk.boundary.state.mark("$" /* Cleanup */, "" + scopeId);
1028
+ }
1029
+ function writeScope(scopeId, partialScope) {
1030
+ let { state } = $chunk.boundary, { scopes } = state, scope = scopes.get(scopeId);
1031
+ return state.needsMainRuntime = !0, scope ? Object.assign(scope, partialScope) : (scope = partialScope, scope[K_SCOPE_ID] = scopeId, state.scopes.set(scopeId, scope)), state.writeScopes ? state.writeScopes[scopeId] = scope : state.hasGlobals ? state.writeScopes = { [scopeId]: scope } : (state.hasGlobals = !0, state.writeScopes = {
1032
+ $: getFilteredGlobals(state.$global),
1033
+ [scopeId]: scope
1034
+ }), scope;
1035
+ }
1036
+ function writeExistingScope(scope) {
1037
+ return writeScope(scope[K_SCOPE_ID], scope);
1038
+ }
1039
+ function ensureScopeWithId(scopeId) {
1040
+ let { state } = $chunk.boundary, scope = state.scopes.get(scopeId);
1041
+ return scope || (scope = { [K_SCOPE_ID]: scopeId }, state.scopes.set(scopeId, scope)), scope;
1042
+ }
1043
+ function $global() {
1044
+ return $chunk.boundary.state.$global;
1045
+ }
1046
+ function fork(promise, renderBody) {
1047
+ if (!isPromise(promise)) {
1048
+ renderBody(promise);
1049
+ return;
1050
+ }
1051
+ let chunk = $chunk, { boundary } = chunk;
1052
+ chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = { ...chunk.context, [kPendingContexts]: 0 }), boundary.startAsync(), promise.then(
1053
+ (value) => {
1054
+ chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(renderBody, value), boundary.endAsync(chunk)));
1055
+ },
1056
+ (err) => {
1057
+ chunk.async = !1, boundary.abort(err);
1058
+ }
1059
+ );
1060
+ }
1061
+ function tryPlaceholder(renderBody, renderPlaceholder) {
1062
+ let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
1063
+ if (body === body.render(renderBody)) {
1064
+ chunk.append(body);
1065
+ return;
1066
+ }
1067
+ chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context), chunk.placeholderBody = body, chunk.placeholderRender = renderPlaceholder;
1068
+ }
1069
+ function tryCatch(renderBody, renderCatch) {
1070
+ let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = new Chunk(catchBoundary, null, chunk.context), bodyEnd = body.render(renderBody);
1071
+ if (catchBoundary.signal.aborted) {
1072
+ renderCatch(catchBoundary.signal.reason);
1073
+ return;
1074
+ }
1075
+ if (body === bodyEnd) {
1076
+ chunk.append(body);
1077
+ return;
1078
+ }
1079
+ let reorderId = state.nextReorderId(), endMarker = state.mark("!" /* PlaceholderEnd */, reorderId), bodyNext = bodyEnd.next = $chunk = new Chunk(boundary, chunk.next, body.context);
1080
+ chunk.next = body, chunk.writeHTML(state.mark("!^" /* Placeholder */, reorderId)), bodyEnd.writeHTML(endMarker), boundary.startAsync(), catchBoundary.onNext = () => {
1081
+ if (!boundary.signal.aborted)
1082
+ if (catchBoundary.signal.aborted) {
1083
+ if (!bodyEnd.consumed) {
1084
+ let cur = body, writeMarker = !0;
1085
+ do {
1086
+ let next = cur.next;
1087
+ cur.boundary !== catchBoundary && cur.boundary.abort(catchBoundary.signal.reason), writeMarker && !cur.consumed && (writeMarker = !1, cur.async = !1, cur.next = bodyNext, cur.html = endMarker, cur.scripts = cur.effects = "", cur.placeholderBody = cur.placeholderRender = cur.reorderId = null), cur = next;
1088
+ } while (cur !== bodyNext);
1089
+ }
1090
+ let catchChunk = new Chunk(boundary, null, chunk.context);
1091
+ catchChunk.reorderId = reorderId, catchChunk.render(renderCatch, catchBoundary.signal.reason), state.reorder(catchChunk), boundary.endAsync();
1092
+ } else catchBoundary.done ? boundary.endAsync() : boundary.onNext();
1093
+ };
1094
+ }
1095
+ var State2 = class {
1096
+ constructor($global2) {
1097
+ this.$global = $global2;
1098
+ this.$global = $global2, $global2.cspNonce && (this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + ""));
1099
+ }
1100
+ tagIndex = 0;
1101
+ scopeIndex = 0;
1102
+ reorderIndex = 0;
1103
+ hasGlobals = !1;
1104
+ needsMainRuntime = !1;
1105
+ hasMainRuntime = !1;
1106
+ hasReorderRuntime = !1;
1107
+ hasWrittenResume = !1;
1108
+ trailerHTML = "";
1109
+ nonceAttr = "";
1110
+ serializer = new Serializer();
1111
+ writeReorders = null;
1112
+ scopes = /* @__PURE__ */ new Map();
1113
+ writeScopes = null;
1114
+ get runtimePrefix() {
1115
+ let { $global: $global2 } = this;
1116
+ return $global2.runtimeId + "." + $global2.renderId;
1117
+ }
1118
+ get commentPrefix() {
1119
+ let { $global: $global2 } = this;
1120
+ return $global2.runtimeId + $global2.renderId;
1121
+ }
1122
+ reorder(chunk) {
1123
+ this.writeReorders ? this.writeReorders.push(chunk) : (this.needsMainRuntime = !0, this.writeReorders = [chunk]);
1124
+ }
1125
+ nextReorderId() {
1126
+ let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 10, index = this.reorderIndex++, mod = index % encodeStartLen, id = encodeChars[mod];
1127
+ for (index = (index - mod) / encodeStartLen; index > 0; )
1128
+ mod = index % encodeLen, id += encodeChars[mod], index = (index - mod) / encodeLen;
1129
+ return id;
1130
+ }
1131
+ mark(code, str) {
1132
+ return "<!--" + this.commentPrefix + code + str + "-->";
1133
+ }
1134
+ }, Boundary = class extends AbortController {
1135
+ constructor(state, parent) {
1136
+ super();
1137
+ this.state = state;
1138
+ this.state = state, this.signal.addEventListener("abort", () => {
1139
+ this.count = 0, this.state = new State2(this.state.$global), this.onNext();
1140
+ }), parent && (parent.aborted ? this.abort(parent.reason) : parent.addEventListener("abort", () => {
1141
+ this.abort(parent.reason);
1142
+ }));
1143
+ }
1144
+ onNext = NOOP;
1145
+ count = 0;
1146
+ get done() {
1147
+ return this.count === 0;
1148
+ }
1149
+ startAsync() {
1150
+ this.signal.aborted || this.count++;
1151
+ }
1152
+ endAsync(chunk) {
1153
+ !this.signal.aborted && this.count && (this.count--, chunk?.reorderId && this.state.reorder(chunk), this.onNext());
1154
+ }
1155
+ }, Chunk = class {
1156
+ constructor(boundary, next, context) {
1157
+ this.boundary = boundary;
1158
+ this.next = next;
1159
+ this.context = context;
1160
+ this.boundary = boundary, this.next = next, this.context = context;
1161
+ }
1162
+ html = "";
1163
+ scripts = "";
1164
+ effects = "";
1165
+ async = !1;
1166
+ consumed = !1;
1167
+ reorderId = null;
1168
+ placeholderBody = null;
1169
+ placeholderRender = null;
1170
+ writeHTML(html) {
1171
+ this.html += html;
1172
+ }
1173
+ writeEffect(scopeId, registryId) {
1174
+ this.effects = concatEffects(
1175
+ this.effects,
1176
+ scopeId + ',"' + registryId + '"'
1177
+ );
1178
+ }
1179
+ writeScript(script) {
1180
+ this.scripts = concatScripts(this.scripts, script);
1181
+ }
1182
+ append(chunk) {
1183
+ this.html += chunk.html, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts);
1184
+ }
1185
+ flushPlaceholder() {
1186
+ if (this.placeholderBody) {
1187
+ let body = this.placeholderBody.consume();
1188
+ if (body.async) {
1189
+ let { state } = this.boundary, reorderId = body.reorderId = state.nextReorderId();
1190
+ this.writeHTML(state.mark("!^" /* Placeholder */, reorderId));
1191
+ let after = this.render(this.placeholderRender);
1192
+ after !== this && this.boundary.abort(
1193
+ new Error("An @placeholder cannot contain async content.")
1194
+ ), after.writeHTML(state.mark("!" /* PlaceholderEnd */, reorderId)), state.reorder(body);
1195
+ } else
1196
+ body.next = this.next, this.next = body;
1197
+ this.placeholderRender = this.placeholderBody = null;
1198
+ }
1199
+ }
1200
+ consume() {
1201
+ let cur = this;
1202
+ if (cur.next && !cur.async) {
1203
+ let html = "", effects = "", scripts = "";
1204
+ do
1205
+ cur.flushPlaceholder(), html += cur.html, effects += cur.effects, scripts = concatScripts(scripts, cur.scripts), cur.consumed = !0, cur = cur.next;
1206
+ while (cur.next && !cur.async);
1207
+ cur.html = html + cur.html, cur.effects = concatEffects(effects, cur.effects), cur.scripts = concatScripts(scripts, cur.scripts);
1208
+ }
1209
+ return cur;
1210
+ }
1211
+ render(renderBody, val) {
1212
+ let prev = $chunk;
1213
+ $chunk = this;
1214
+ try {
1215
+ return renderBody(val), $chunk;
1216
+ } catch (err) {
1217
+ return this.boundary.abort(err), this;
1218
+ } finally {
1219
+ $chunk = prev;
1220
+ }
1221
+ }
1222
+ };
1223
+ function prepareChunk(chunk) {
1224
+ let head = chunk.consume(), { boundary, effects } = head, { state } = boundary, { $global: $global2, runtimePrefix, serializer, nonceAttr } = state, { html, scripts } = head, hasWalk = !1;
1225
+ head.effects = "", state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
1226
+ scripts,
1227
+ WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
1228
+ ));
1229
+ let resumes = "";
1230
+ if ((state.writeScopes || serializer.flushed) && (resumes = state.serializer.stringify(state.writeScopes || {}, boundary), state.writeScopes = null), effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects), boundary.done && (resumes || state.hasWrittenResume) && (resumes = resumes ? resumes + ",0" : "0"), resumes && (state.hasWrittenResume ? scripts = concatScripts(
1231
+ scripts,
1232
+ runtimePrefix + ".r.push(" + resumes + ")"
1233
+ ) : (state.hasWrittenResume = !0, scripts = concatScripts(
1234
+ scripts,
1235
+ runtimePrefix + ".r=[" + resumes + "]"
1236
+ ))), state.writeReorders) {
1237
+ hasWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>", scripts = concatScripts(
1238
+ scripts,
1239
+ REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
1240
+ ));
1241
+ for (let reorderedChunk of state.writeReorders) {
1242
+ let { reorderId } = reorderedChunk, isSync = !0, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1243
+ for (reorderedChunk.reorderId = null; cur.flushPlaceholder(), reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
1244
+ "#" /* ReorderMarker */,
1245
+ cur.reorderId = state.nextReorderId()
1246
+ ), cur.html = cur.effects = cur.scripts = "", isSync = !1), cur.next; )
1247
+ cur = cur.next;
1248
+ reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
1249
+ scripts,
1250
+ runtimePrefix + ".r=[]"
1251
+ )), reorderScripts = concatScripts(
1252
+ reorderScripts,
1253
+ "_.push(" + reorderEffects + ")"
1254
+ )), scripts = concatScripts(
1255
+ scripts,
1256
+ reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
1257
+ ), html += "<t " + (isSync ? "c " : "") + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1258
+ }
1259
+ state.writeReorders = null;
1260
+ }
1261
+ return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), head.html = html, head.scripts = scripts, head;
1262
+ }
1263
+ function flushChunk(head, last) {
1264
+ let { boundary } = head, { state } = boundary, { html, scripts } = head, { $global: $global2 } = state, { __flush__ } = $global2, result = html;
1265
+ return head.html = head.scripts = "", scripts && (result += "<script" + state.nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, result = __flush__($global2, result)), last && state.trailerHTML && (result += state.trailerHTML), result;
1266
+ }
1267
+ function writeTrailers(html) {
1268
+ $chunk.boundary.state.trailerHTML += html;
1269
+ }
1270
+ function concatEffects(a, b) {
1271
+ return a ? b ? a + "," + b : a : b;
1272
+ }
1273
+ function concatScripts(a, b) {
1274
+ return a ? b ? a + ";" + b : a : b;
1275
+ }
1276
+ var tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue;
1277
+ function queueTick(cb) {
1278
+ tickQueue ? tickQueue.add(cb) : (tickQueue = /* @__PURE__ */ new Set([cb]), tick(flushTickQueue));
1279
+ }
1280
+ function offTick(cb) {
1281
+ tickQueue?.delete(cb);
1282
+ }
1283
+ function flushTickQueue() {
1284
+ let queue = tickQueue;
1285
+ tickQueue = void 0;
1286
+ for (let cb of queue)
1287
+ cb(!0);
1288
+ }
1289
+ function isPromise(value) {
1290
+ return value != null && typeof value.then == "function";
1291
+ }
1292
+ function getFilteredGlobals($global2) {
1293
+ if (!$global2) return;
1294
+ let serializedGlobals = $global2.serializedGlobals;
1295
+ if (!serializedGlobals) return;
1296
+ let filtered;
1297
+ if (Array.isArray(serializedGlobals))
1298
+ for (let key of serializedGlobals) {
1299
+ let value = $global2[key];
1300
+ value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
1301
+ }
1302
+ else
1303
+ for (let key in serializedGlobals)
1304
+ if (serializedGlobals[key]) {
1305
+ let value = $global2[key];
1306
+ value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
1307
+ }
1308
+ return filtered;
1309
+ }
1310
+
1311
+ // src/html/attrs.ts
1312
+ function classAttr(val) {
1313
+ return stringAttr("class", classValue(val));
1314
+ }
1315
+ function styleAttr(val) {
1316
+ return stringAttr("style", styleValue(val));
1317
+ }
1318
+ function optionValueAttr(value) {
1319
+ let { [kSelectedValue]: selectedValue } = getChunk()?.context || {};
1320
+ return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
1321
+ }
1322
+ var kSelectedValue = Symbol("selectedValue");
1323
+ function controllable_select_value(scopeId, nodeAccessor, value, valueChange, renderBody) {
1324
+ valueChange && writeControlledScope(
1325
+ 3 /* SelectValue */,
1326
+ scopeId,
1327
+ nodeAccessor,
1328
+ value,
1329
+ valueChange
1330
+ ), renderBody && withContext(kSelectedValue, value, renderBody);
1331
+ }
1332
+ function controllable_textarea_value(scopeId, nodeAccessor, value, valueChange) {
1333
+ return valueChange && writeControlledScope(
1334
+ 2 /* InputValue */,
1335
+ scopeId,
1336
+ nodeAccessor,
1337
+ void 0,
1338
+ valueChange
1339
+ ), escapeTextAreaValue(value);
1340
+ }
1341
+ function controllable_input_value(scopeId, nodeAccessor, value, valueChange) {
1342
+ return valueChange && writeControlledScope(
1343
+ 2 /* InputValue */,
1344
+ scopeId,
1345
+ nodeAccessor,
1346
+ void 0,
1347
+ valueChange
1348
+ ), attr("value", value);
1349
+ }
1350
+ function controllable_input_checked(scopeId, nodeAccessor, checked, checkedChange) {
1351
+ return checkedChange && writeControlledScope(
1352
+ 0 /* InputChecked */,
1353
+ scopeId,
1354
+ nodeAccessor,
1355
+ void 0,
1356
+ checkedChange
1357
+ ), attr("checked", checked);
1358
+ }
1359
+ function controllable_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value) {
1360
+ let multiple = Array.isArray(checkedValue), valueAttr = attr("value", value);
1361
+ return checkedValueChange && writeControlledScope(
1362
+ 1 /* InputCheckedValue */,
1363
+ scopeId,
1364
+ nodeAccessor,
1365
+ multiple ? checkedValue : void 0,
1366
+ checkedValueChange
1367
+ ), (multiple ? checkedValue.includes(value) : checkedValue === value) ? valueAttr + " checked" : valueAttr;
1368
+ }
1369
+ function controllable_detailsOrDialog_open(scopeId, nodeAccessor, open, openChange) {
1370
+ return openChange && writeControlledScope(
1371
+ 4 /* DetailsOrDialogOpen */,
1372
+ scopeId,
1373
+ nodeAccessor,
1374
+ open,
1375
+ openChange
1376
+ ), attr("open", open);
1377
+ }
1378
+ function attr(name, val) {
1379
+ return isVoid(val) ? "" : nonVoidAttr(name, val);
1380
+ }
1381
+ function attrs(data, nodeAccessor, scopeId, tagName) {
1382
+ let result = "", skip = /[\s/>"'=]/, events;
1383
+ switch (tagName) {
1384
+ case "input":
1385
+ if (data.checkedChange)
1386
+ result += controllable_input_checked(
1387
+ scopeId,
1388
+ nodeAccessor,
1389
+ data.checked,
1390
+ data.checkedChange
1391
+ );
1392
+ else if (data.checkedValue || data.checkedValueChange)
1393
+ result += controllable_input_checkedValue(
1394
+ scopeId,
1395
+ nodeAccessor,
1396
+ data.checkedValue,
1397
+ data.checkedValueChange,
1398
+ data.value
1399
+ );
1400
+ else if (data.valueChange)
1401
+ result += controllable_input_value(
1402
+ scopeId,
1403
+ nodeAccessor,
1404
+ data.value,
1405
+ data.valueChange
1406
+ );
1407
+ else
1408
+ break;
1409
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
1410
+ break;
1411
+ case "select":
1412
+ case "textarea":
1413
+ (data.value || data.valueChange) && (skip = /^value(?:Change)?$|[\s/>"'=]/);
1414
+ break;
1415
+ case "option":
1416
+ data.value && (result += optionValueAttr(data.value), skip = /^value$|[\s/>"'=]/);
1417
+ break;
1418
+ case "details":
1419
+ case "dialog":
1420
+ data.openChange && (result += controllable_detailsOrDialog_open(
1421
+ scopeId,
1422
+ nodeAccessor,
1423
+ data.open,
1424
+ data.openChange
1425
+ ), skip = /^open(?:Change)?$|[\s/>"'=]/);
1426
+ break;
1427
+ }
1428
+ for (let name in data) {
1429
+ let val = data[name];
1430
+ switch (name) {
1431
+ case "class":
1432
+ result += classAttr(val);
1433
+ break;
1434
+ case "style":
1435
+ result += styleAttr(val);
1436
+ break;
1437
+ case "":
1438
+ case "renderBody":
1439
+ break;
1440
+ default:
1441
+ isVoid(val) || (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, {
1442
+ [nodeAccessor + "~" /* EventAttributes */]: events
1443
+ })), events[getEventHandlerName(name)] = val) : skip.test(name) || (result += nonVoidAttr(name, val)));
1444
+ break;
1445
+ }
1446
+ }
1447
+ return result;
1448
+ }
1449
+ function partialAttrs(data, skip, nodeAccessor, scopeId, tagName) {
1450
+ let partial = {};
1451
+ for (let key in data)
1452
+ skip[key] || (partial[key] = data[key]);
1453
+ return attrs(partial, nodeAccessor, scopeId, tagName);
1454
+ }
1455
+ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
1456
+ writeScope(scopeId, {
1457
+ [nodeAccessor + "=" /* ControlledType */]: type,
1458
+ [nodeAccessor + ":" /* ControlledValue */]: value,
1459
+ [nodeAccessor + ";" /* ControlledHandler */]: valueChange
1460
+ });
1461
+ }
1462
+ function stringAttr(name, val) {
1463
+ return val && ` ${name}=${escapeAttrValue(val)}`;
1464
+ }
1465
+ function nonVoidAttr(name, val) {
1466
+ switch (typeof val) {
1467
+ case "string":
1468
+ return ` ${name + attrAssignment(val)}`;
1469
+ case "boolean":
1470
+ return ` ${name}`;
1471
+ case "number":
1472
+ return ` ${name}=${val}`;
1473
+ case "object":
1474
+ if (val instanceof RegExp)
1475
+ return ` ${name + attrAssignment(val.source)}`;
1476
+ break;
1477
+ }
1478
+ return ` ${name + attrAssignment(val + "")}`;
1479
+ }
1480
+ function attrAssignment(val) {
1481
+ return val ? `=${escapeAttrValue(val)}` : "";
1482
+ }
1483
+ var unsafeAttrChars = /["'>\s]/g;
1484
+ function escapeAttrValue(str) {
1485
+ if (unsafeAttrChars.test(str)) {
1486
+ let c = str[unsafeAttrChars.lastIndex - 1];
1487
+ return unsafeAttrChars.lastIndex = 0, c === '"' ? `'${str.replace(/'/g, "&#39;")}'` : `"${str.replace(/"/g, "&#34;")}"`;
1488
+ }
1489
+ return str;
1490
+ }
1491
+
1492
+ // src/common/compat-meta.ts
1493
+ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
1494
+
1495
+ // src/common/meta.ts
1496
+ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
1497
+
1498
+ // src/html/dynamic-tag.ts
1499
+ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
1500
+ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
1501
+ if (!tag && !renderBody) return;
1502
+ let scopeId = getScopeId(scope);
1503
+ return write(`${markResumeScopeStart(scopeId)}`), writeScope(scopeId, scope), tag ? typeof tag == "string" ? (nextScopeId(), write(
1504
+ `<${tag}${attrs(input, 0, scopeId, tag)}>`
1505
+ ), voidElementsReg.test(tag) || (tag === "textarea" ? write(
1506
+ controllable_textarea_value(
1507
+ scopeId,
1508
+ 0,
1509
+ input.value,
1510
+ input.valueChange
1511
+ )
1512
+ ) : renderBody && (tag === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
1513
+ scopeId,
1514
+ 0,
1515
+ input.value,
1516
+ input.valueChange,
1517
+ renderBody
1518
+ ) : renderBody()), write(`</${tag}>`)), null) : getDynamicRenderer(tag)(renderBody ? { ...input, renderBody } : input, tagVar) : renderBody();
1519
+ }
1520
+ function dynamicTagArgs(scope, tag, args) {
1521
+ if (!tag) return;
1522
+ let scopeId = getScopeId(scope);
1523
+ if (write(`${markResumeScopeStart(scopeId)}`), writeScope(scopeId, scope), typeof tag == "string") {
1524
+ nextScopeId(), write(
1525
+ `<${tag}${attrs(args[0], 0, scopeId, tag)}>`
1526
+ ), voidElementsReg.test(tag) || write(`</${tag}>`);
1527
+ return;
1528
+ }
1529
+ return getDynamicRenderer(tag)(...args);
1530
+ }
1531
+ var getDynamicRenderer = normalizeDynamicRenderer, createRenderer = (fn) => fn;
1532
+ function patchDynamicTag(newGetDynamicRenderer, newCreateRenderer) {
1533
+ getDynamicRenderer = newGetDynamicRenderer, createRenderer = newCreateRenderer;
1534
+ }
1535
+
1536
+ // src/html/compat.ts
1537
+ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
1538
+ fork,
1539
+ write,
1540
+ writeScript,
1541
+ nextScopeId,
1542
+ patchDynamicTag,
1543
+ writeSetScopeForComponent(m5c) {
1544
+ let scopeId = nextScopeId();
1545
+ writeScope(scopeId, { m5c }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
1546
+ },
1547
+ toJSON() {
1548
+ let compatRegistered = COMPAT_REGISTRY.get(this);
1549
+ if (!compatRegistered) {
1550
+ let registered = getRegistered(this);
1551
+ if (registered) {
1552
+ let scopeId = getScopeId(registered.scope);
1553
+ scopeId !== void 0 && writeScope(scopeId, {}), COMPAT_REGISTRY.set(
1554
+ this,
1555
+ compatRegistered = [registered.id, scopeId]
1556
+ );
1557
+ }
1558
+ }
1559
+ return compatRegistered;
1560
+ },
1561
+ render(renderer, willRerender, classAPIOut, component, input) {
1562
+ let $global2 = classAPIOut.global, state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
1563
+ state || ($global2.runtimeId ||= DEFAULT_RUNTIME_ID, $global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID, $global2[K_TAGS_API_STATE] = state = new State2($global2));
1564
+ let boundary = new Boundary(state), head = new Chunk(
1565
+ boundary,
1566
+ null,
1567
+ null
1568
+ );
1569
+ head.render(() => {
1570
+ if (willRerender) {
1571
+ let scopeId = peekNextScopeId();
1572
+ writeScope(scopeId, { m5c: component.id }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
1573
+ }
1574
+ renderer(input);
1575
+ });
1576
+ let asyncOut = classAPIOut.beginAsync();
1577
+ (boundary.onNext = () => {
1578
+ boundary.done && (boundary.signal.aborted ? asyncOut.error(boundary.signal.reason) : queueMicrotask(() => {
1579
+ let { scripts, html } = head = prepareChunk(head);
1580
+ asyncOut.script(scripts), asyncOut.write(html), asyncOut.end(), head.html = head.scripts = "";
1581
+ }));
1582
+ })();
1583
+ },
1584
+ registerRenderer(renderer, id) {
1585
+ return register(
1586
+ RENDERER_REGISTER_ID,
1587
+ renderer,
1588
+ register(id, () => {
1589
+ })
1590
+ );
1591
+ }
1592
+ };
1593
+
1594
+ // src/common/for.ts
1595
+ function forIn(obj, cb) {
1596
+ for (let key in obj)
1597
+ cb(key, obj[key]);
1598
+ }
1599
+ function forOf(list, cb) {
1600
+ if (list) {
1601
+ let i = 0;
1602
+ for (let item of list)
1603
+ cb(item, i++);
1604
+ }
1605
+ }
1606
+ function forTo(to, from, step, cb) {
1607
+ let start = from || 0, delta = step || 1;
1608
+ for (let steps = (to - start) / delta, i = 0; i <= steps; i++)
1609
+ cb(start + i * delta);
1610
+ }
1611
+
1612
+ // src/html/for.ts
1613
+ function forOfBy(by, item, index) {
1614
+ return by ? typeof by == "string" ? item[by] : by(item, index) : index;
1615
+ }
1616
+ function forInBy(by, name, value) {
1617
+ return by ? by(name, value) : name;
1618
+ }
1619
+ function forToBy(by, index) {
1620
+ return by ? by(index) : index;
1621
+ }
1622
+
1623
+ // src/html/template.ts
1624
+ var createTemplate = (templateId, renderer) => (renderer.render = render, renderer._ = renderer, register2(renderer, templateId));
1625
+ function render(input = {}) {
1626
+ let { $global: $global2 } = input;
1627
+ $global2 ? ({ $global: $global2, ...input } = input, $global2 = {
1628
+ runtimeId: DEFAULT_RUNTIME_ID,
1629
+ renderId: DEFAULT_RENDER_ID,
1630
+ ...$global2
1631
+ }) : $global2 = {
1632
+ runtimeId: DEFAULT_RUNTIME_ID,
1633
+ renderId: DEFAULT_RENDER_ID
1634
+ };
1635
+ let head = new Chunk(
1636
+ new Boundary(new State2($global2), $global2.signal),
1637
+ null,
1638
+ null
1639
+ );
1640
+ return head.render(this, input), new ServerRenderResult(head);
1641
+ }
1642
+ var ServerRenderResult = class {
1643
+ #head;
1644
+ #cachedPromise = null;
1645
+ constructor(head) {
1646
+ this.#head = head;
1647
+ }
1648
+ [Symbol.asyncIterator]() {
1649
+ let resolve, reject, value = "", done = !1, aborted = !1, reason, boundary = this.#read(
1650
+ (html) => {
1651
+ value += html, resolve && (resolve({ value, done }), value = "");
1652
+ },
1653
+ (err) => {
1654
+ aborted = !0, reason = err, reject && reject(err);
1655
+ },
1656
+ () => {
1657
+ done = !0, resolve && resolve({ value, done: !value });
1658
+ }
1659
+ );
1660
+ return {
1661
+ next() {
1662
+ if (value) {
1663
+ let result = { value, done: !1 };
1664
+ return value = "", Promise.resolve(result);
1665
+ }
1666
+ return done ? Promise.resolve({ value: "", done }) : aborted ? Promise.reject(reason) : new Promise(exec);
1667
+ },
1668
+ throw(error) {
1669
+ return done || aborted || boundary?.abort(error), Promise.resolve({
1670
+ value: "",
1671
+ done: !0
1672
+ });
1673
+ },
1674
+ return(value2) {
1675
+ return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({
1676
+ value: value2,
1677
+ done: !0
1678
+ });
1679
+ }
1680
+ };
1681
+ function exec(_resolve, _reject) {
1682
+ resolve = _resolve, reject = _reject;
1683
+ }
1684
+ }
1685
+ pipe(stream) {
1686
+ this.#read(
1687
+ (html) => {
1688
+ stream.write(html);
1689
+ },
1690
+ (err) => {
1691
+ let socket = "socket" in stream && stream.socket;
1692
+ if (socket && typeof socket.destroySoon == "function" && socket.destroySoon(), !stream.emit?.("error", err))
1693
+ throw err;
1694
+ },
1695
+ () => {
1696
+ stream.end();
1697
+ }
1698
+ );
1699
+ }
1700
+ toReadable() {
1701
+ return new ReadableStream({
1702
+ start: (ctrl) => {
1703
+ this.#read(
1704
+ (html) => {
1705
+ ctrl.enqueue(html);
1706
+ },
1707
+ (err) => {
1708
+ ctrl.error(err);
1709
+ },
1710
+ () => {
1711
+ ctrl.close();
1712
+ }
1713
+ );
1714
+ }
1715
+ });
1716
+ }
1717
+ then(onfulfilled, onrejected) {
1718
+ return this.#promise().then(onfulfilled, onrejected);
1719
+ }
1720
+ catch(onrejected) {
1721
+ return this.#promise().catch(onrejected);
1722
+ }
1723
+ finally(onfinally) {
1724
+ return this.#promise().finally(onfinally);
1725
+ }
1726
+ #promise() {
1727
+ return this.#cachedPromise ||= new Promise((resolve, reject) => {
1728
+ let head = this.#head;
1729
+ if (this.#head = null, !head)
1730
+ return reject(new Error("Cannot read from a consumed render result"));
1731
+ let { boundary } = head;
1732
+ (boundary.onNext = () => {
1733
+ boundary.done && (boundary.signal.aborted ? reject(boundary.signal.reason) : (head = prepareChunk(head), boundary.done && resolve(flushChunk(head, !0))));
1734
+ })();
1735
+ });
1736
+ }
1737
+ #read(onWrite, onAbort, onClose) {
1738
+ let tick2 = !0, head = this.#head;
1739
+ if (this.#head = null, !head) {
1740
+ onAbort(new Error("Cannot read from a consumed render result"));
1741
+ return;
1742
+ }
1743
+ let { boundary } = head, onNext = boundary.onNext = (write2) => {
1744
+ if (write2 || boundary.done) {
1745
+ if (boundary.signal.aborted) {
1746
+ tick2 || offTick(onNext), onAbort(boundary.signal.reason);
1747
+ return;
1748
+ }
1749
+ head = prepareChunk(head);
1750
+ }
1751
+ if (write2 || boundary.done) {
1752
+ let html = flushChunk(head, boundary.done);
1753
+ html && onWrite(html), boundary.done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
1754
+ } else tick2 && (tick2 = !1, queueTick(onNext));
1755
+ };
1756
+ return onNext(), boundary;
1757
+ }
1758
+ toString() {
1759
+ let head = this.#head;
1760
+ if (!head) throw new Error("Cannot read from a consumed render result");
1761
+ if (head.next) throw new Error("Cannot fork in sync mode");
1762
+ return this.#head = null, flushChunk(prepareChunk(head), !0);
1763
+ }
1764
+ };
1765
+ // Annotate the CommonJS export names for ESM import in node:
1766
+ 0 && (module.exports = {
1767
+ $global,
1768
+ attr,
1769
+ attrTag,
1770
+ attrTags,
1771
+ attrs,
1772
+ classAttr,
1773
+ compat,
1774
+ controllable_detailsOrDialog_open,
1775
+ controllable_input_checked,
1776
+ controllable_input_checkedValue,
1777
+ controllable_input_value,
1778
+ controllable_select_value,
1779
+ controllable_textarea_value,
1780
+ createRenderer,
1781
+ createTemplate,
1782
+ dynamicTagArgs,
1783
+ dynamicTagInput,
1784
+ ensureScopeWithId,
1785
+ escapeScript,
1786
+ escapeStyle,
1787
+ escapeXML,
1788
+ forIn,
1789
+ forInBy,
1790
+ forOf,
1791
+ forOfBy,
1792
+ forTo,
1793
+ forToBy,
1794
+ fork,
1795
+ getScopeById,
1796
+ markResumeCleanup,
1797
+ markResumeControlEnd,
1798
+ markResumeControlSingleNodeEnd,
1799
+ markResumeNode,
1800
+ markResumeScopeStart,
1801
+ nextScopeId,
1802
+ nextTagId,
1803
+ nodeRef,
1804
+ normalizeDynamicRenderer,
1805
+ optionValueAttr,
1806
+ partialAttrs,
1807
+ peekNextScope,
1808
+ register,
1809
+ styleAttr,
1810
+ toString,
1811
+ tryCatch,
1812
+ tryPlaceholder,
1813
+ write,
1814
+ writeEffect,
1815
+ writeExistingScope,
1816
+ writeScope,
1817
+ writeTrailers
1818
+ });