@agent-profile/web 0.1.3 → 0.1.5

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 (248) hide show
  1. package/README.md +70 -29
  2. package/build/client/_app/immutable/assets/{0.BG6jUcBX.css → 0.8hVtEx5X.css} +1 -1
  3. package/build/client/_app/immutable/assets/0.8hVtEx5X.css.br +0 -0
  4. package/build/client/_app/immutable/assets/0.8hVtEx5X.css.gz +0 -0
  5. package/build/client/_app/immutable/assets/9.BsbC-D7w.css +1 -0
  6. package/build/client/_app/immutable/assets/9.BsbC-D7w.css.br +0 -0
  7. package/build/client/_app/immutable/assets/9.BsbC-D7w.css.gz +0 -0
  8. package/build/client/_app/immutable/chunks/6SrQtk22.js +3 -0
  9. package/build/client/_app/immutable/chunks/6SrQtk22.js.br +0 -0
  10. package/build/client/_app/immutable/chunks/6SrQtk22.js.gz +0 -0
  11. package/build/client/_app/immutable/chunks/{BWDgWdtq.js → B1X0Iqjr.js} +2 -2
  12. package/build/client/_app/immutable/chunks/B1X0Iqjr.js.br +0 -0
  13. package/build/client/_app/immutable/chunks/B1X0Iqjr.js.gz +0 -0
  14. package/build/client/_app/immutable/chunks/BN4Ca4cJ.js +1 -0
  15. package/build/client/_app/immutable/chunks/BN4Ca4cJ.js.br +0 -0
  16. package/build/client/_app/immutable/chunks/BN4Ca4cJ.js.gz +0 -0
  17. package/build/client/_app/immutable/chunks/BYeYmN2n.js +1 -0
  18. package/build/client/_app/immutable/chunks/BYeYmN2n.js.br +2 -0
  19. package/build/client/_app/immutable/chunks/BYeYmN2n.js.gz +0 -0
  20. package/build/client/_app/immutable/chunks/D0_SwbnT.js +2 -0
  21. package/build/client/_app/immutable/chunks/D0_SwbnT.js.br +0 -0
  22. package/build/client/_app/immutable/chunks/D0_SwbnT.js.gz +0 -0
  23. package/build/client/_app/immutable/chunks/DRoN73NW.js +1 -0
  24. package/build/client/_app/immutable/chunks/DRoN73NW.js.br +2 -0
  25. package/build/client/_app/immutable/chunks/DRoN73NW.js.gz +0 -0
  26. package/build/client/_app/immutable/entry/app.B45QQayJ.js +2 -0
  27. package/build/client/_app/immutable/entry/app.B45QQayJ.js.br +0 -0
  28. package/build/client/_app/immutable/entry/app.B45QQayJ.js.gz +0 -0
  29. package/build/client/_app/immutable/entry/start.BIlQ_snM.js +1 -0
  30. package/build/client/_app/immutable/entry/start.BIlQ_snM.js.br +0 -0
  31. package/build/client/_app/immutable/entry/start.BIlQ_snM.js.gz +0 -0
  32. package/build/client/_app/immutable/nodes/0.JRffyfUR.js +1 -0
  33. package/build/client/_app/immutable/nodes/0.JRffyfUR.js.br +0 -0
  34. package/build/client/_app/immutable/nodes/0.JRffyfUR.js.gz +0 -0
  35. package/build/client/_app/immutable/nodes/1.56EgwKsF.js +1 -0
  36. package/build/client/_app/immutable/nodes/1.56EgwKsF.js.br +0 -0
  37. package/build/client/_app/immutable/nodes/1.56EgwKsF.js.gz +0 -0
  38. package/build/client/_app/immutable/nodes/{10.BOQgahuX.js → 10.Bhdlxk-S.js} +2 -2
  39. package/build/client/_app/immutable/nodes/10.Bhdlxk-S.js.br +0 -0
  40. package/build/client/_app/immutable/nodes/10.Bhdlxk-S.js.gz +0 -0
  41. package/build/client/_app/immutable/nodes/11.DAqRx2TI.js +1 -0
  42. package/build/client/_app/immutable/nodes/11.DAqRx2TI.js.br +0 -0
  43. package/build/client/_app/immutable/nodes/11.DAqRx2TI.js.gz +0 -0
  44. package/build/client/_app/immutable/nodes/2.CI-wpOC8.js +10 -0
  45. package/build/client/_app/immutable/nodes/2.CI-wpOC8.js.br +0 -0
  46. package/build/client/_app/immutable/nodes/2.CI-wpOC8.js.gz +0 -0
  47. package/build/client/_app/immutable/nodes/3.Bphawycs.js +2 -0
  48. package/build/client/_app/immutable/nodes/3.Bphawycs.js.br +0 -0
  49. package/build/client/_app/immutable/nodes/3.Bphawycs.js.gz +0 -0
  50. package/build/client/_app/immutable/nodes/4.BGFkNM65.js +4 -0
  51. package/build/client/_app/immutable/nodes/4.BGFkNM65.js.br +0 -0
  52. package/build/client/_app/immutable/nodes/4.BGFkNM65.js.gz +0 -0
  53. package/build/client/_app/immutable/nodes/5.VTs5grF0.js +2 -0
  54. package/build/client/_app/immutable/nodes/5.VTs5grF0.js.br +0 -0
  55. package/build/client/_app/immutable/nodes/5.VTs5grF0.js.gz +0 -0
  56. package/build/client/_app/immutable/nodes/6.CndSdLIk.js +5 -0
  57. package/build/client/_app/immutable/nodes/6.CndSdLIk.js.br +0 -0
  58. package/build/client/_app/immutable/nodes/6.CndSdLIk.js.gz +0 -0
  59. package/build/client/_app/immutable/nodes/7.DpFk4StA.js +4 -0
  60. package/build/client/_app/immutable/nodes/7.DpFk4StA.js.br +0 -0
  61. package/build/client/_app/immutable/nodes/7.DpFk4StA.js.gz +0 -0
  62. package/build/client/_app/immutable/nodes/8.Y7A99ODL.js +1 -0
  63. package/build/client/_app/immutable/nodes/8.Y7A99ODL.js.br +0 -0
  64. package/build/client/_app/immutable/nodes/8.Y7A99ODL.js.gz +0 -0
  65. package/build/client/_app/immutable/nodes/9.DF3LeTGi.js +3 -0
  66. package/build/client/_app/immutable/nodes/9.DF3LeTGi.js.br +0 -0
  67. package/build/client/_app/immutable/nodes/9.DF3LeTGi.js.gz +0 -0
  68. package/build/client/_app/version.json +1 -1
  69. package/build/client/_app/version.json.br +0 -0
  70. package/build/client/_app/version.json.gz +0 -0
  71. package/build/client/marketing.js +105 -0
  72. package/build/client/marketing.js.br +0 -0
  73. package/build/client/marketing.js.gz +0 -0
  74. package/build/server/chunks/{0-aBAedq2p.js → 0-DWEpTDaF.js} +17 -11
  75. package/build/server/chunks/0-DWEpTDaF.js.map +1 -0
  76. package/build/server/chunks/{1-7SwLsXP7.js → 1-B68UkVTE.js} +3 -3
  77. package/build/server/chunks/{1-7SwLsXP7.js.map → 1-B68UkVTE.js.map} +1 -1
  78. package/build/server/chunks/10-D7op0myD.js +9 -0
  79. package/build/server/chunks/{10-B1aX7ZZ8.js.map → 10-D7op0myD.js.map} +1 -1
  80. package/build/server/chunks/{11-4z6b2WB8.js → 11-Ms74wtl9.js} +6 -6
  81. package/build/server/chunks/{11-4z6b2WB8.js.map → 11-Ms74wtl9.js.map} +1 -1
  82. package/build/server/chunks/2-bmpngDVe.js +21 -0
  83. package/build/server/chunks/2-bmpngDVe.js.map +1 -0
  84. package/build/server/chunks/3-BkezOAX7.js +9 -0
  85. package/build/server/chunks/{3-CLWhM7Et.js.map → 3-BkezOAX7.js.map} +1 -1
  86. package/build/server/chunks/{4-BehBrXcu.js → 4-CSfQwQwV.js} +6 -6
  87. package/build/server/chunks/{4-BehBrXcu.js.map → 4-CSfQwQwV.js.map} +1 -1
  88. package/build/server/chunks/5-D_pZV4fS.js +9 -0
  89. package/build/server/chunks/{5-C1YtO2Ru.js.map → 5-D_pZV4fS.js.map} +1 -1
  90. package/build/server/chunks/{6-DJ03bQJy.js → 6-DcbRMrH1.js} +3 -3
  91. package/build/server/chunks/{6-DJ03bQJy.js.map → 6-DcbRMrH1.js.map} +1 -1
  92. package/build/server/chunks/{7-BHefj3jR.js → 7-BsMFIBGU.js} +8 -8
  93. package/build/server/chunks/{7-BHefj3jR.js.map → 7-BsMFIBGU.js.map} +1 -1
  94. package/build/server/chunks/8-DWleYW_e.js +9 -0
  95. package/build/server/chunks/{8-BNb36pCU.js.map → 8-DWleYW_e.js.map} +1 -1
  96. package/build/server/chunks/9-tHCipeiW.js +67 -0
  97. package/build/server/chunks/9-tHCipeiW.js.map +1 -0
  98. package/build/server/chunks/{Badge-BrV_lIru.js → Badge-BYK3z3lr.js} +2 -2
  99. package/build/server/chunks/{Badge-BrV_lIru.js.map → Badge-BYK3z3lr.js.map} +1 -1
  100. package/build/server/chunks/{SafetyBadge-BSDbVVMY.js → SafetyBadge-BXNCgLE-.js} +2 -2
  101. package/build/server/chunks/{SafetyBadge-BSDbVVMY.js.map → SafetyBadge-BXNCgLE-.js.map} +1 -1
  102. package/build/server/chunks/{_layout.svelte-C6Ru_7YV.js → _layout.svelte-Cv35k3JT.js} +8 -8
  103. package/build/server/chunks/_layout.svelte-Cv35k3JT.js.map +1 -0
  104. package/build/server/chunks/{_page.svelte-C8HqSRYY.js → _page.svelte-B-Kaw1RF.js} +2 -2
  105. package/build/server/chunks/{_page.svelte-C8HqSRYY.js.map → _page.svelte-B-Kaw1RF.js.map} +1 -1
  106. package/build/server/chunks/{_page.svelte-Bv-w7cKm.js → _page.svelte-BftcSD3f.js} +3 -3
  107. package/build/server/chunks/{_page.svelte-Bv-w7cKm.js.map → _page.svelte-BftcSD3f.js.map} +1 -1
  108. package/build/server/chunks/{_page.svelte-DRj4L7XZ.js → _page.svelte-CIEY8g8A.js} +4 -4
  109. package/build/server/chunks/{_page.svelte-DRj4L7XZ.js.map → _page.svelte-CIEY8g8A.js.map} +1 -1
  110. package/build/server/chunks/{_page.svelte-DuJcNgye.js → _page.svelte-CUnw0pLx.js} +3 -3
  111. package/build/server/chunks/{_page.svelte-DuJcNgye.js.map → _page.svelte-CUnw0pLx.js.map} +1 -1
  112. package/build/server/chunks/{_page.svelte-QyOMa9Ce.js → _page.svelte-Cat8tEeF.js} +5 -5
  113. package/build/server/chunks/{_page.svelte-QyOMa9Ce.js.map → _page.svelte-Cat8tEeF.js.map} +1 -1
  114. package/build/server/chunks/{_page.svelte-BS9xpx67.js → _page.svelte-CmuUQI4Y.js} +112 -54
  115. package/build/server/chunks/_page.svelte-CmuUQI4Y.js.map +1 -0
  116. package/build/server/chunks/{_page.svelte-DyYKrY-D.js → _page.svelte-DHNevyzi.js} +4 -4
  117. package/build/server/chunks/{_page.svelte-DyYKrY-D.js.map → _page.svelte-DHNevyzi.js.map} +1 -1
  118. package/build/server/chunks/_page.svelte-DLQqGym0.js +435 -0
  119. package/build/server/chunks/_page.svelte-DLQqGym0.js.map +1 -0
  120. package/build/server/chunks/{_page.svelte-DYBnVmA8.js → _page.svelte-DZX4Bixr.js} +6 -6
  121. package/build/server/chunks/{_page.svelte-DYBnVmA8.js.map → _page.svelte-DZX4Bixr.js.map} +1 -1
  122. package/build/server/chunks/{_page.svelte-r2AHAn4f.js → _page.svelte-DyI46sDh.js} +3 -3
  123. package/build/server/chunks/{_page.svelte-r2AHAn4f.js.map → _page.svelte-DyI46sDh.js.map} +1 -1
  124. package/build/server/chunks/_server.ts-5396UuLQ.js +8 -0
  125. package/build/server/chunks/_server.ts-5396UuLQ.js.map +1 -0
  126. package/build/server/chunks/_server.ts-BUQYdxPs.js +8 -0
  127. package/build/server/chunks/_server.ts-BUQYdxPs.js.map +1 -0
  128. package/build/server/chunks/_server.ts-CvdpZfED.js +8 -0
  129. package/build/server/chunks/_server.ts-CvdpZfED.js.map +1 -0
  130. package/build/server/chunks/_server.ts-DHt1bGpF.js +85 -0
  131. package/build/server/chunks/_server.ts-DHt1bGpF.js.map +1 -0
  132. package/build/server/chunks/_server.ts-Dq1jAomo.js +43 -0
  133. package/build/server/chunks/_server.ts-Dq1jAomo.js.map +1 -0
  134. package/build/server/chunks/_server.ts-sMKRiXFg.js +100 -0
  135. package/build/server/chunks/_server.ts-sMKRiXFg.js.map +1 -0
  136. package/build/server/chunks/{client-CBew73li.js → client-92HF3fc9.js} +3 -3
  137. package/build/server/chunks/{client-CBew73li.js.map → client-92HF3fc9.js.map} +1 -1
  138. package/build/server/chunks/{dev-CrqJ3ZR3.js → dev-Duv_-rxF.js} +2 -2
  139. package/build/server/chunks/{dev-CrqJ3ZR3.js.map → dev-Duv_-rxF.js.map} +1 -1
  140. package/build/server/chunks/{doctorSummary-CGjSiyKU.js → doctorSummary-Bm0dY6PW.js} +3 -3
  141. package/build/server/chunks/{doctorSummary-CGjSiyKU.js.map → doctorSummary-Bm0dY6PW.js.map} +1 -1
  142. package/build/server/chunks/{error.svelte-C78Jl1J5.js → error.svelte-BEI8QxGW.js} +5 -5
  143. package/build/server/chunks/{error.svelte-C78Jl1J5.js.map → error.svelte-BEI8QxGW.js.map} +1 -1
  144. package/build/server/chunks/hooks.server-BKavEpqC.js +81 -0
  145. package/build/server/chunks/hooks.server-BKavEpqC.js.map +1 -0
  146. package/build/server/chunks/index-CLnuRv4X.js +134 -0
  147. package/build/server/chunks/index-CLnuRv4X.js.map +1 -0
  148. package/build/server/chunks/index-DBqjc0Yf.js +77 -0
  149. package/build/server/chunks/index-DBqjc0Yf.js.map +1 -0
  150. package/build/server/chunks/{internal-WBaPpipk.js → internal-DBeni9My.js} +6 -81
  151. package/build/server/chunks/internal-DBeni9My.js.map +1 -0
  152. package/build/server/chunks/marketingSeo-Do5o0grg.js +132 -0
  153. package/build/server/chunks/marketingSeo-Do5o0grg.js.map +1 -0
  154. package/build/server/chunks/profileApiHelpers-BFzohffv.js +180 -0
  155. package/build/server/chunks/profileApiHelpers-BFzohffv.js.map +1 -0
  156. package/build/server/chunks/{projectContext-C4-xYqFg.js → projectContext-Cxsfz84C.js} +409 -44
  157. package/build/server/chunks/projectContext-Cxsfz84C.js.map +1 -0
  158. package/build/server/chunks/src2-DNqJAXv6.js +12 -0
  159. package/build/server/chunks/src2-DNqJAXv6.js.map +1 -0
  160. package/build/server/chunks/{dist--t-UlYlZ.js → src3-jm480tTA.js} +3 -3
  161. package/build/server/chunks/src3-jm480tTA.js.map +1 -0
  162. package/build/server/chunks/tokenStore-DQfTa-N3.js +57 -0
  163. package/build/server/chunks/tokenStore-DQfTa-N3.js.map +1 -0
  164. package/build/server/index.js +4593 -4
  165. package/build/server/index.js.map +1 -1
  166. package/build/server/manifest.js +57 -15
  167. package/build/server/manifest.js.map +1 -1
  168. package/package.json +10 -7
  169. package/build/client/_app/immutable/assets/0.BG6jUcBX.css.br +0 -0
  170. package/build/client/_app/immutable/assets/0.BG6jUcBX.css.gz +0 -0
  171. package/build/client/_app/immutable/chunks/B-io8J2C.js +0 -1
  172. package/build/client/_app/immutable/chunks/B-io8J2C.js.br +0 -2
  173. package/build/client/_app/immutable/chunks/B-io8J2C.js.gz +0 -0
  174. package/build/client/_app/immutable/chunks/BWDgWdtq.js.br +0 -0
  175. package/build/client/_app/immutable/chunks/BWDgWdtq.js.gz +0 -0
  176. package/build/client/_app/immutable/chunks/CBvCQPh1.js +0 -1
  177. package/build/client/_app/immutable/chunks/CBvCQPh1.js.br +0 -2
  178. package/build/client/_app/immutable/chunks/CBvCQPh1.js.gz +0 -0
  179. package/build/client/_app/immutable/chunks/DAWBIq3g.js +0 -2
  180. package/build/client/_app/immutable/chunks/DAWBIq3g.js.br +0 -0
  181. package/build/client/_app/immutable/chunks/DAWBIq3g.js.gz +0 -0
  182. package/build/client/_app/immutable/chunks/DCJP-V9E.js +0 -3
  183. package/build/client/_app/immutable/chunks/DCJP-V9E.js.br +0 -0
  184. package/build/client/_app/immutable/chunks/DCJP-V9E.js.gz +0 -0
  185. package/build/client/_app/immutable/chunks/SOrpfga1.js +0 -1
  186. package/build/client/_app/immutable/chunks/SOrpfga1.js.br +0 -0
  187. package/build/client/_app/immutable/chunks/SOrpfga1.js.gz +0 -0
  188. package/build/client/_app/immutable/entry/app.CvfSMy7S.js +0 -2
  189. package/build/client/_app/immutable/entry/app.CvfSMy7S.js.br +0 -0
  190. package/build/client/_app/immutable/entry/app.CvfSMy7S.js.gz +0 -0
  191. package/build/client/_app/immutable/entry/start.nKIgWfXU.js +0 -1
  192. package/build/client/_app/immutable/entry/start.nKIgWfXU.js.br +0 -0
  193. package/build/client/_app/immutable/entry/start.nKIgWfXU.js.gz +0 -0
  194. package/build/client/_app/immutable/nodes/0.l1JjQQQj.js +0 -1
  195. package/build/client/_app/immutable/nodes/0.l1JjQQQj.js.br +0 -0
  196. package/build/client/_app/immutable/nodes/0.l1JjQQQj.js.gz +0 -0
  197. package/build/client/_app/immutable/nodes/1.BzbldZDH.js +0 -1
  198. package/build/client/_app/immutable/nodes/1.BzbldZDH.js.br +0 -4
  199. package/build/client/_app/immutable/nodes/1.BzbldZDH.js.gz +0 -0
  200. package/build/client/_app/immutable/nodes/10.BOQgahuX.js.br +0 -0
  201. package/build/client/_app/immutable/nodes/10.BOQgahuX.js.gz +0 -0
  202. package/build/client/_app/immutable/nodes/11.BjwWla8T.js +0 -1
  203. package/build/client/_app/immutable/nodes/11.BjwWla8T.js.br +0 -0
  204. package/build/client/_app/immutable/nodes/11.BjwWla8T.js.gz +0 -0
  205. package/build/client/_app/immutable/nodes/2.BDMGSS6l.js +0 -9
  206. package/build/client/_app/immutable/nodes/2.BDMGSS6l.js.br +0 -0
  207. package/build/client/_app/immutable/nodes/2.BDMGSS6l.js.gz +0 -0
  208. package/build/client/_app/immutable/nodes/3.NnDkXnSG.js +0 -2
  209. package/build/client/_app/immutable/nodes/3.NnDkXnSG.js.br +0 -0
  210. package/build/client/_app/immutable/nodes/3.NnDkXnSG.js.gz +0 -0
  211. package/build/client/_app/immutable/nodes/4.8sZ5zCiS.js +0 -4
  212. package/build/client/_app/immutable/nodes/4.8sZ5zCiS.js.br +0 -0
  213. package/build/client/_app/immutable/nodes/4.8sZ5zCiS.js.gz +0 -0
  214. package/build/client/_app/immutable/nodes/5.CSOalQ9R.js +0 -2
  215. package/build/client/_app/immutable/nodes/5.CSOalQ9R.js.br +0 -0
  216. package/build/client/_app/immutable/nodes/5.CSOalQ9R.js.gz +0 -0
  217. package/build/client/_app/immutable/nodes/6.BMBuGW7y.js +0 -5
  218. package/build/client/_app/immutable/nodes/6.BMBuGW7y.js.br +0 -0
  219. package/build/client/_app/immutable/nodes/6.BMBuGW7y.js.gz +0 -0
  220. package/build/client/_app/immutable/nodes/7.CKFnFT6B.js +0 -4
  221. package/build/client/_app/immutable/nodes/7.CKFnFT6B.js.br +0 -0
  222. package/build/client/_app/immutable/nodes/7.CKFnFT6B.js.gz +0 -0
  223. package/build/client/_app/immutable/nodes/8.Dw5huUXy.js +0 -1
  224. package/build/client/_app/immutable/nodes/8.Dw5huUXy.js.br +0 -0
  225. package/build/client/_app/immutable/nodes/8.Dw5huUXy.js.gz +0 -0
  226. package/build/client/_app/immutable/nodes/9.CnkwRoxn.js +0 -5
  227. package/build/client/_app/immutable/nodes/9.CnkwRoxn.js.br +0 -0
  228. package/build/client/_app/immutable/nodes/9.CnkwRoxn.js.gz +0 -0
  229. package/build/server/chunks/0-aBAedq2p.js.map +0 -1
  230. package/build/server/chunks/10-B1aX7ZZ8.js +0 -9
  231. package/build/server/chunks/2-BT3hDge_.js +0 -9
  232. package/build/server/chunks/2-BT3hDge_.js.map +0 -1
  233. package/build/server/chunks/3-CLWhM7Et.js +0 -9
  234. package/build/server/chunks/5-C1YtO2Ru.js +0 -9
  235. package/build/server/chunks/8-BNb36pCU.js +0 -9
  236. package/build/server/chunks/9-LeS-ldcl.js +0 -57
  237. package/build/server/chunks/9-LeS-ldcl.js.map +0 -1
  238. package/build/server/chunks/_layout.svelte-C6Ru_7YV.js.map +0 -1
  239. package/build/server/chunks/_page.svelte-BS9xpx67.js.map +0 -1
  240. package/build/server/chunks/_page.svelte-IYyXbXcB.js +0 -424
  241. package/build/server/chunks/_page.svelte-IYyXbXcB.js.map +0 -1
  242. package/build/server/chunks/dist--t-UlYlZ.js.map +0 -1
  243. package/build/server/chunks/hooks.server-BU12K8IL.js +0 -38
  244. package/build/server/chunks/hooks.server-BU12K8IL.js.map +0 -1
  245. package/build/server/chunks/index-CNsiSQmW.js +0 -4727
  246. package/build/server/chunks/index-CNsiSQmW.js.map +0 -1
  247. package/build/server/chunks/internal-WBaPpipk.js.map +0 -1
  248. package/build/server/chunks/projectContext-C4-xYqFg.js.map +0 -1
@@ -1,4727 +0,0 @@
1
- import { H as HttpError, R as Redirect, c as coalesce_to_error, g as get_status, a as get_message, w as with_request_store, p as parse, S as SvelteKitError, o as options, s as set_private_env, b as set_public_env, d as get_hooks, n as noop, h as has_resolution_suffix, e as has_data_suffix, f as base, i as strip_resolution_suffix, j as strip_data_suffix, T as TRAILING_SLASH_PARAM, I as INVALIDATED_PARAM, k as decode_pathname, l as add_data_suffix, m as add_resolution_suffix, q as find_route, r as normalize_path, t as disable_search, u as public_env, v as validate_layout_server_exports, x as validate_layout_exports, y as validate_page_server_exports, z as validate_page_exports, A as noop_span, B as assets, C as app_dir, D as create_remote_key, E as hash, F as text_encoder$1, G as compact, J as once, K as normalize_error, L as resolve, M as parse_remote_arg, N as stringify, O as make_trackable, P as stringify$1, Q as ActionFailure, U as read_implementation, V as split_remote_key, W as get_relative_path, X as base64_encode, Y as override, Z as reset, _ as set_read_implementation } from './internal-WBaPpipk.js';
2
- import 'node:module';
3
- import { u as uneval, w as writable, r as readable } from './dev-CrqJ3ZR3.js';
4
-
5
- const text_encoder = new TextEncoder();
6
-
7
- /** @import { StandardSchemaV1 } from '@standard-schema/spec' */
8
-
9
-
10
- // TODO 3.0: remove these types as they are not used anymore (we can't remove them yet because that would be a breaking change)
11
- /**
12
- * @template {number} TNumber
13
- * @template {any[]} [TArray=[]]
14
- * @typedef {TNumber extends TArray['length'] ? TArray[number] : LessThan<TNumber, [...TArray, TArray['length']]>} LessThan
15
- */
16
-
17
- /**
18
- * @template {number} TStart
19
- * @template {number} TEnd
20
- * @typedef {Exclude<TEnd | LessThan<TEnd>, LessThan<TStart>>} NumericRange
21
- */
22
-
23
- // Keep the status codes as `number` because restricting to certain numbers makes it unnecessarily hard to use compared to the benefits
24
- // (we have runtime errors already to check for invalid codes). Also see https://github.com/sveltejs/kit/issues/11780
25
-
26
- // we have to repeat the JSDoc because the display for function overloads is broken
27
- // see https://github.com/microsoft/TypeScript/issues/55056
28
-
29
- /**
30
- * Throws an error with a HTTP status code and an optional message.
31
- * When called during request handling, this will cause SvelteKit to
32
- * return an error response without invoking `handleError`.
33
- * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
34
- * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
35
- * @param {App.Error} body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.
36
- * @overload
37
- * @param {number} status
38
- * @param {App.Error} body
39
- * @return {never}
40
- * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling.
41
- * @throws {Error} If the provided status is invalid (not between 400 and 599).
42
- */
43
- /**
44
- * Throws an error with a HTTP status code and an optional message.
45
- * When called during request handling, this will cause SvelteKit to
46
- * return an error response without invoking `handleError`.
47
- * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
48
- * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
49
- * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} [body] An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.
50
- * @overload
51
- * @param {number} status
52
- * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} [body]
53
- * @return {never}
54
- * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling.
55
- * @throws {Error} If the provided status is invalid (not between 400 and 599).
56
- */
57
- /**
58
- * Throws an error with a HTTP status code and an optional message.
59
- * When called during request handling, this will cause SvelteKit to
60
- * return an error response without invoking `handleError`.
61
- * Make sure you're not catching the thrown error, which would prevent SvelteKit from handling it.
62
- * @param {number} status The [HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses). Must be in the range 400-599.
63
- * @param {{ message: string } extends App.Error ? App.Error | string | undefined : never} body An object that conforms to the App.Error type. If a string is passed, it will be used as the message property.
64
- * @return {never}
65
- * @throws {HttpError} This error instructs SvelteKit to initiate HTTP error handling.
66
- * @throws {Error} If the provided status is invalid (not between 400 and 599).
67
- */
68
- function error(status, body) {
69
- if ((isNaN(status) || status < 400 || status > 599)) {
70
- throw new Error(`HTTP error status codes must be between 400 and 599 — ${status} is invalid`);
71
- }
72
-
73
- throw new HttpError(status, body);
74
- }
75
-
76
- /**
77
- * Checks whether this is a redirect thrown by {@link redirect}.
78
- * @param {unknown} e The object to check.
79
- * @return {e is Redirect}
80
- */
81
- function isRedirect(e) {
82
- return e instanceof Redirect;
83
- }
84
-
85
- /**
86
- * Create a JSON `Response` object from the supplied data.
87
- * @param {any} data The value that will be serialized as JSON.
88
- * @param {ResponseInit} [init] Options such as `status` and `headers` that will be added to the response. `Content-Type: application/json` and `Content-Length` headers will be added automatically.
89
- */
90
- function json(data, init) {
91
- // TODO deprecate this in favour of `Response.json` when it's
92
- // more widely supported
93
- const body = JSON.stringify(data);
94
-
95
- // we can't just do `text(JSON.stringify(data), init)` because
96
- // it will set a default `content-type` header. duplicated code
97
- // means less duplicated work
98
- const headers = new Headers(init?.headers);
99
- if (!headers.has('content-length')) {
100
- headers.set('content-length', text_encoder.encode(body).byteLength.toString());
101
- }
102
-
103
- if (!headers.has('content-type')) {
104
- headers.set('content-type', 'application/json');
105
- }
106
-
107
- return new Response(body, {
108
- ...init,
109
- headers
110
- });
111
- }
112
-
113
- /**
114
- * Create a `Response` object from the supplied body.
115
- * @param {string} body The value that will be used as-is.
116
- * @param {ResponseInit} [init] Options such as `status` and `headers` that will be added to the response. A `Content-Length` header will be added automatically.
117
- */
118
- function text(body, init) {
119
- const headers = new Headers(init?.headers);
120
- if (!headers.has('content-length')) {
121
- const encoded = text_encoder.encode(body);
122
- headers.set('content-length', encoded.byteLength.toString());
123
- return new Response(encoded, {
124
- ...init,
125
- headers
126
- });
127
- }
128
-
129
- return new Response(body, {
130
- ...init,
131
- headers
132
- });
133
- }
134
-
135
- /**
136
- * @template {{ tracing: { enabled: boolean, root: import('@opentelemetry/api').Span, current: import('@opentelemetry/api').Span } }} T
137
- * @param {T} event_like
138
- * @param {import('@opentelemetry/api').Span} current
139
- * @returns {T}
140
- */
141
- function merge_tracing(event_like, current) {
142
- return {
143
- ...event_like,
144
- tracing: {
145
- ...event_like.tracing,
146
- current
147
- }
148
- };
149
- }
150
-
151
- var ENDPOINT_METHODS = [
152
- "GET",
153
- "POST",
154
- "PUT",
155
- "PATCH",
156
- "DELETE",
157
- "OPTIONS",
158
- "HEAD"
159
- ];
160
- var PAGE_METHODS = [
161
- "GET",
162
- "POST",
163
- "HEAD"
164
- ];
165
- //#endregion
166
- //#region ../../node_modules/@sveltejs/kit/src/runtime/form-utils.js
167
- /** @import { RemoteForm } from '@sveltejs/kit' */
168
- /** @import { BinaryFormMeta, InternalRemoteFormIssue } from 'types' */
169
- /** @import { StandardSchemaV1 } from '@standard-schema/spec' */
170
- var decoder = new TextDecoder();
171
- /**
172
- * Sets a value in a nested object using a path string, mutating the original object
173
- * @param {Record<string, any>} object
174
- * @param {string} path_string
175
- * @param {any} value
176
- */
177
- function set_nested_value(object, path_string, value) {
178
- if (path_string.startsWith("n:")) {
179
- path_string = path_string.slice(2);
180
- value = value === "" ? void 0 : parseFloat(value);
181
- } else if (path_string.startsWith("b:")) {
182
- path_string = path_string.slice(2);
183
- value = value === "on";
184
- }
185
- deep_set(object, split_path(path_string), value);
186
- }
187
- /**
188
- * Convert `FormData` into a POJO
189
- * @param {FormData} data
190
- */
191
- function convert_formdata(data) {
192
- /** @type {Record<string, any>} */
193
- const result = {};
194
- for (let key of data.keys()) {
195
- const is_array = key.endsWith("[]");
196
- /** @type {any[]} */
197
- let values = data.getAll(key);
198
- if (is_array) key = key.slice(0, -2);
199
- if (values.length > 1 && !is_array) throw new Error(`Form cannot contain duplicated keys — "${key}" has ${values.length} values`);
200
- values = values.filter((entry) => typeof entry === "string" || entry.name !== "" || entry.size > 0);
201
- if (key.startsWith("n:")) {
202
- key = key.slice(2);
203
- values = values.map((v) => v === "" ? void 0 : parseFloat(v));
204
- } else if (key.startsWith("b:")) {
205
- key = key.slice(2);
206
- values = values.map((v) => v === "on");
207
- }
208
- set_nested_value(result, key, is_array ? values : values[0]);
209
- }
210
- return result;
211
- }
212
- var BINARY_FORM_CONTENT_TYPE = "application/x-sveltekit-formdata";
213
- var BINARY_FORM_VERSION = 0;
214
- var HEADER_BYTES = 7;
215
- /**
216
- * @param {Request} request
217
- * @returns {Promise<{ data: Record<string, any>; meta: BinaryFormMeta; form_data: FormData | null }>}
218
- */
219
- async function deserialize_binary_form(request) {
220
- if (request.headers.get("content-type") !== "application/x-sveltekit-formdata") {
221
- const form_data = await request.formData();
222
- return {
223
- data: convert_formdata(form_data),
224
- meta: {},
225
- form_data
226
- };
227
- }
228
- if (!request.body) throw deserialize_error("no body");
229
- const content_length = parseInt(request.headers.get("content-length") ?? "");
230
- if (Number.isNaN(content_length)) throw deserialize_error("invalid Content-Length header");
231
- const reader = request.body.getReader();
232
- /** @type {Array<Promise<Uint8Array<ArrayBuffer> | undefined>>} */
233
- const chunks = [];
234
- /**
235
- * @param {number} index
236
- * @returns {Promise<Uint8Array<ArrayBuffer> | undefined>}
237
- */
238
- function get_chunk(index) {
239
- if (index in chunks) return chunks[index];
240
- let i = chunks.length;
241
- while (i <= index) {
242
- chunks[i] = reader.read().then((chunk) => chunk.value);
243
- i++;
244
- }
245
- return chunks[index];
246
- }
247
- /**
248
- * @param {number} offset
249
- * @param {number} length
250
- * @returns {Promise<Uint8Array | null>}
251
- */
252
- async function get_buffer(offset, length) {
253
- /** @type {Uint8Array} */
254
- let start_chunk;
255
- let chunk_start = 0;
256
- /** @type {number} */
257
- let chunk_index;
258
- for (chunk_index = 0;; chunk_index++) {
259
- const chunk = await get_chunk(chunk_index);
260
- if (!chunk) return null;
261
- const chunk_end = chunk_start + chunk.byteLength;
262
- if (offset >= chunk_start && offset < chunk_end) {
263
- start_chunk = chunk;
264
- break;
265
- }
266
- chunk_start = chunk_end;
267
- }
268
- if (offset + length <= chunk_start + start_chunk.byteLength) return start_chunk.subarray(offset - chunk_start, offset + length - chunk_start);
269
- const chunks = [start_chunk.subarray(offset - chunk_start)];
270
- let cursor = start_chunk.byteLength - offset + chunk_start;
271
- while (cursor < length) {
272
- chunk_index++;
273
- let chunk = await get_chunk(chunk_index);
274
- if (!chunk) return null;
275
- if (chunk.byteLength > length - cursor) chunk = chunk.subarray(0, length - cursor);
276
- chunks.push(chunk);
277
- cursor += chunk.byteLength;
278
- }
279
- const buffer = new Uint8Array(length);
280
- cursor = 0;
281
- for (const chunk of chunks) {
282
- buffer.set(chunk, cursor);
283
- cursor += chunk.byteLength;
284
- }
285
- return buffer;
286
- }
287
- const header = await get_buffer(0, HEADER_BYTES);
288
- if (!header) throw deserialize_error("too short");
289
- if (header[0] !== BINARY_FORM_VERSION) throw deserialize_error(`got version ${header[0]}, expected version ${BINARY_FORM_VERSION}`);
290
- const header_view = new DataView(header.buffer, header.byteOffset, header.byteLength);
291
- const data_length = header_view.getUint32(1, true);
292
- if (HEADER_BYTES + data_length > content_length) throw deserialize_error("data overflow");
293
- const file_offsets_length = header_view.getUint16(5, true);
294
- if (HEADER_BYTES + data_length + file_offsets_length > content_length) throw deserialize_error("file offset table overflow");
295
- const data_buffer = await get_buffer(HEADER_BYTES, data_length);
296
- if (!data_buffer) throw deserialize_error("data too short");
297
- /** @type {Array<number | undefined>} */
298
- let file_offsets;
299
- /** @type {number} */
300
- let files_start_offset;
301
- if (file_offsets_length > 0) {
302
- const file_offsets_buffer = await get_buffer(HEADER_BYTES + data_length, file_offsets_length);
303
- if (!file_offsets_buffer) throw deserialize_error("file offset table too short");
304
- const parsed_offsets = JSON.parse(decoder.decode(file_offsets_buffer));
305
- if (!Array.isArray(parsed_offsets) || parsed_offsets.some((n) => typeof n !== "number" || !Number.isInteger(n) || n < 0)) throw deserialize_error("invalid file offset table");
306
- file_offsets = parsed_offsets;
307
- files_start_offset = HEADER_BYTES + data_length + file_offsets_length;
308
- }
309
- /** @type {Array<{ offset: number, size: number }>} */
310
- const file_spans = [];
311
- const [data, meta] = parse(decoder.decode(data_buffer), { File: ([name, type, size, last_modified, index]) => {
312
- if (typeof name !== "string" || typeof type !== "string" || typeof size !== "number" || typeof last_modified !== "number" || typeof index !== "number") throw deserialize_error("invalid file metadata");
313
- let offset = file_offsets[index];
314
- if (offset === void 0) throw deserialize_error("duplicate file offset table index");
315
- file_offsets[index] = void 0;
316
- offset += files_start_offset;
317
- if (offset + size > content_length) throw deserialize_error("file data overflow");
318
- file_spans.push({
319
- offset,
320
- size
321
- });
322
- return new Proxy(new LazyFile(name, type, size, last_modified, get_chunk, offset), { getPrototypeOf() {
323
- return File.prototype;
324
- } });
325
- } });
326
- file_spans.sort((a, b) => a.offset - b.offset || a.size - b.size);
327
- for (let i = 1; i < file_spans.length; i++) {
328
- const previous = file_spans[i - 1];
329
- const current = file_spans[i];
330
- const previous_end = previous.offset + previous.size;
331
- if (previous_end < current.offset) throw deserialize_error("gaps in file data");
332
- if (previous_end > current.offset) throw deserialize_error("overlapping file data");
333
- }
334
- (async () => {
335
- let has_more = true;
336
- while (has_more) has_more = !!await get_chunk(chunks.length);
337
- })();
338
- return {
339
- data,
340
- meta,
341
- form_data: null
342
- };
343
- }
344
- /**
345
- * @param {string} message
346
- */
347
- function deserialize_error(message) {
348
- return new SvelteKitError(400, "Bad Request", `Could not deserialize binary form: ${message}`);
349
- }
350
- /** @implements {File} */
351
- var LazyFile = class LazyFile {
352
- /** @type {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} */
353
- #get_chunk;
354
- /** @type {number} */
355
- #offset;
356
- /**
357
- * @param {string} name
358
- * @param {string} type
359
- * @param {number} size
360
- * @param {number} last_modified
361
- * @param {(index: number) => Promise<Uint8Array<ArrayBuffer> | undefined>} get_chunk
362
- * @param {number} offset
363
- */
364
- constructor(name, type, size, last_modified, get_chunk, offset) {
365
- this.name = name;
366
- this.type = type;
367
- this.size = size;
368
- this.lastModified = last_modified;
369
- this.webkitRelativePath = "";
370
- this.#get_chunk = get_chunk;
371
- this.#offset = offset;
372
- this.arrayBuffer = this.arrayBuffer.bind(this);
373
- this.bytes = this.bytes.bind(this);
374
- this.slice = this.slice.bind(this);
375
- this.stream = this.stream.bind(this);
376
- this.text = this.text.bind(this);
377
- }
378
- /** @type {ArrayBuffer | undefined} */
379
- #buffer;
380
- async arrayBuffer() {
381
- this.#buffer ??= await new Response(this.stream()).arrayBuffer();
382
- return this.#buffer;
383
- }
384
- async bytes() {
385
- return new Uint8Array(await this.arrayBuffer());
386
- }
387
- /**
388
- * @param {number=} start
389
- * @param {number=} end
390
- * @param {string=} contentType
391
- */
392
- slice(start = 0, end = this.size, contentType = this.type) {
393
- if (start < 0) start = Math.max(this.size + start, 0);
394
- else start = Math.min(start, this.size);
395
- if (end < 0) end = Math.max(this.size + end, 0);
396
- else end = Math.min(end, this.size);
397
- const size = Math.max(end - start, 0);
398
- return new LazyFile(this.name, contentType, size, this.lastModified, this.#get_chunk, this.#offset + start);
399
- }
400
- stream() {
401
- let cursor = 0;
402
- let chunk_index = 0;
403
- return new ReadableStream({
404
- start: async (controller) => {
405
- let chunk_start = 0;
406
- /** @type {Uint8Array} */
407
- let start_chunk;
408
- for (chunk_index = 0;; chunk_index++) {
409
- const chunk = await this.#get_chunk(chunk_index);
410
- if (!chunk) return null;
411
- const chunk_end = chunk_start + chunk.byteLength;
412
- if (this.#offset >= chunk_start && this.#offset < chunk_end) {
413
- start_chunk = chunk;
414
- break;
415
- }
416
- chunk_start = chunk_end;
417
- }
418
- if (this.#offset + this.size <= chunk_start + start_chunk.byteLength) {
419
- controller.enqueue(start_chunk.subarray(this.#offset - chunk_start, this.#offset + this.size - chunk_start));
420
- controller.close();
421
- } else {
422
- controller.enqueue(start_chunk.subarray(this.#offset - chunk_start));
423
- cursor = start_chunk.byteLength - this.#offset + chunk_start;
424
- }
425
- },
426
- pull: async (controller) => {
427
- chunk_index++;
428
- let chunk = await this.#get_chunk(chunk_index);
429
- if (!chunk) {
430
- controller.error("incomplete file data");
431
- controller.close();
432
- return;
433
- }
434
- if (chunk.byteLength > this.size - cursor) chunk = chunk.subarray(0, this.size - cursor);
435
- controller.enqueue(chunk);
436
- cursor += chunk.byteLength;
437
- if (cursor >= this.size) controller.close();
438
- }
439
- });
440
- }
441
- async text() {
442
- return decoder.decode(await this.arrayBuffer());
443
- }
444
- };
445
- var path_regex = /^[a-zA-Z_$]\w*(\.[a-zA-Z_$]\w*|\[\d+\])*$/;
446
- /**
447
- * @param {string} path
448
- */
449
- function split_path(path) {
450
- if (!path_regex.test(path)) throw new Error(`Invalid path ${path}`);
451
- return path.split(/\.|\[|\]/).filter(Boolean);
452
- }
453
- /**
454
- * Check if a property key is dangerous and could lead to prototype pollution
455
- * @param {string} key
456
- */
457
- function check_prototype_pollution(key) {
458
- if (key === "__proto__" || key === "constructor" || key === "prototype") throw new Error(`Invalid key "${key}"`);
459
- }
460
- /**
461
- * Sets a value in a nested object using an array of keys, mutating the original object.
462
- * @param {Record<string, any>} object
463
- * @param {string[]} keys
464
- * @param {any} value
465
- */
466
- function deep_set(object, keys, value) {
467
- let current = object;
468
- for (let i = 0; i < keys.length - 1; i += 1) {
469
- const key = keys[i];
470
- check_prototype_pollution(key);
471
- const is_array = /^\d+$/.test(keys[i + 1]);
472
- const inner = Object.hasOwn(current, key) ? current[key] : void 0;
473
- const exists = inner != null;
474
- if (exists && is_array !== Array.isArray(inner)) throw new Error(`Invalid array key ${keys[i + 1]}`);
475
- if (!exists) current[key] = is_array ? [] : {};
476
- current = current[key];
477
- }
478
- const final_key = keys[keys.length - 1];
479
- check_prototype_pollution(final_key);
480
- current[final_key] = value;
481
- }
482
- //#endregion
483
- //#region ../../node_modules/@sveltejs/kit/src/utils/http.js
484
- /**
485
- * Given an Accept header and a list of possible content types, pick
486
- * the most suitable one to respond with
487
- * @param {string} accept
488
- * @param {string[]} types
489
- */
490
- function negotiate(accept, types) {
491
- /** @type {Array<{ type: string, subtype: string, q: number, i: number }>} */
492
- const parts = [];
493
- accept.split(",").forEach((str, i) => {
494
- const match = /([^/ \t]+)\/([^; \t]+)[ \t]*(?:;[ \t]*q=([0-9.]+))?/.exec(str);
495
- if (match) {
496
- const [, type, subtype, q = "1"] = match;
497
- parts.push({
498
- type,
499
- subtype,
500
- q: +q,
501
- i
502
- });
503
- }
504
- });
505
- parts.sort((a, b) => {
506
- if (a.q !== b.q) return b.q - a.q;
507
- if (a.subtype === "*" !== (b.subtype === "*")) return a.subtype === "*" ? 1 : -1;
508
- if (a.type === "*" !== (b.type === "*")) return a.type === "*" ? 1 : -1;
509
- return a.i - b.i;
510
- });
511
- let accepted;
512
- let min_priority = Infinity;
513
- for (const mimetype of types) {
514
- const [type, subtype] = mimetype.split("/");
515
- const priority = parts.findIndex((part) => (part.type === type || part.type === "*") && (part.subtype === subtype || part.subtype === "*"));
516
- if (priority !== -1 && priority < min_priority) {
517
- accepted = mimetype;
518
- min_priority = priority;
519
- }
520
- }
521
- return accepted;
522
- }
523
- /**
524
- * Returns `true` if the request contains a `content-type` header with the given type
525
- * @param {Request} request
526
- * @param {...string} types
527
- */
528
- function is_content_type(request, ...types) {
529
- const type = request.headers.get("content-type")?.split(";", 1)[0].trim() ?? "";
530
- return types.includes(type.toLowerCase());
531
- }
532
- /**
533
- * @param {Request} request
534
- */
535
- function is_form_content_type(request) {
536
- return is_content_type(request, "application/x-www-form-urlencoded", "multipart/form-data", "text/plain", BINARY_FORM_CONTENT_TYPE);
537
- }
538
- //#endregion
539
- //#region ../../node_modules/@sveltejs/kit/src/utils/misc.js
540
- var s = JSON.stringify;
541
- //#endregion
542
- //#region ../../node_modules/@sveltejs/kit/src/utils/escape.js
543
- /**
544
- * When inside a double-quoted attribute value, only `&` and `"` hold special meaning.
545
- * @see https://html.spec.whatwg.org/multipage/parsing.html#attribute-value-(double-quoted)-state
546
- * @type {Record<string, string>}
547
- */
548
- var escape_html_attr_dict = {
549
- "&": "&amp;",
550
- "\"": "&quot;"
551
- };
552
- /**
553
- * @type {Record<string, string>}
554
- */
555
- var escape_html_dict = {
556
- "&": "&amp;",
557
- "<": "&lt;"
558
- };
559
- var escape_html_attr_regex = new RegExp(`[${Object.keys(escape_html_attr_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`, "g");
560
- var escape_html_regex = new RegExp(`[${Object.keys(escape_html_dict).join("")}]|[\\ud800-\\udbff](?![\\udc00-\\udfff])|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\udc00-\\udfff]`, "g");
561
- /**
562
- * Escapes unpaired surrogates (which are allowed in js strings but invalid in HTML) and
563
- * escapes characters that are special.
564
- *
565
- * @param {string} str
566
- * @param {boolean} [is_attr]
567
- * @returns {string} escaped string
568
- * @example const html = `<tag data-value="${escape_html('value', true)}">...</tag>`;
569
- */
570
- function escape_html(str, is_attr) {
571
- const dict = is_attr ? escape_html_attr_dict : escape_html_dict;
572
- return str.replace(is_attr ? escape_html_attr_regex : escape_html_regex, (match) => {
573
- if (match.length === 2) return match;
574
- return dict[match] ?? `&#${match.charCodeAt(0)};`;
575
- });
576
- }
577
- //#endregion
578
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/utils.js
579
- /**
580
- * @param {Partial<Record<import('types').HttpMethod, any>>} mod
581
- * @param {import('types').HttpMethod} method
582
- */
583
- function method_not_allowed(mod, method) {
584
- return text(`${method} method not allowed`, {
585
- status: 405,
586
- headers: { allow: allowed_methods(mod).join(", ") }
587
- });
588
- }
589
- /** @param {Partial<Record<import('types').HttpMethod, any>>} mod */
590
- function allowed_methods(mod) {
591
- const allowed = ENDPOINT_METHODS.filter((method) => method in mod);
592
- if ("GET" in mod && !("HEAD" in mod)) allowed.push("HEAD");
593
- return allowed;
594
- }
595
- /**
596
- * @param {import('types').SSROptions} options
597
- */
598
- function get_global_name(options) {
599
- return `__sveltekit_${options.version_hash}`;
600
- }
601
- /**
602
- * Return as a response that renders the error.html
603
- *
604
- * @param {import('types').SSROptions} options
605
- * @param {number} status
606
- * @param {string} message
607
- */
608
- function static_error_page(options, status, message) {
609
- return text(options.templates.error({
610
- status,
611
- message: escape_html(message)
612
- }), {
613
- headers: { "content-type": "text/html; charset=utf-8" },
614
- status
615
- });
616
- }
617
- /**
618
- * @param {import('@sveltejs/kit').RequestEvent} event
619
- * @param {import('types').RequestState} state
620
- * @param {import('types').SSROptions} options
621
- * @param {unknown} error
622
- */
623
- async function handle_fatal_error(event, state, options, error) {
624
- error = error instanceof HttpError ? error : coalesce_to_error(error);
625
- const status = get_status(error);
626
- const body = await handle_error_and_jsonify(event, state, options, error);
627
- const type = negotiate(event.request.headers.get("accept") || "text/html", ["application/json", "text/html"]);
628
- if (event.isDataRequest || type === "application/json") return json(body, { status });
629
- return static_error_page(options, status, body.message);
630
- }
631
- /**
632
- * @param {import('@sveltejs/kit').RequestEvent} event
633
- * @param {import('types').RequestState} state
634
- * @param {import('types').SSROptions} options
635
- * @param {any} error
636
- * @returns {Promise<App.Error>}
637
- */
638
- async function handle_error_and_jsonify(event, state, options, error) {
639
- if (error instanceof HttpError) return {
640
- message: "Unknown Error",
641
- ...error.body
642
- };
643
- const status = get_status(error);
644
- const message = get_message(error);
645
- return await with_request_store({
646
- event,
647
- state
648
- }, () => options.hooks.handleError({
649
- error,
650
- event,
651
- status,
652
- message
653
- })) ?? { message };
654
- }
655
- /**
656
- * @param {number} status
657
- * @param {string} location
658
- */
659
- function redirect_response(status, location) {
660
- return new Response(void 0, {
661
- status,
662
- headers: { location }
663
- });
664
- }
665
- /**
666
- * @param {import('@sveltejs/kit').RequestEvent} event
667
- * @param {Error & { path: string }} error
668
- */
669
- function clarify_devalue_error(event, error) {
670
- if (error.path) return `Data returned from \`load\` while rendering ${event.route.id} is not serializable: ${error.message} (${error.path}). If you need to serialize/deserialize custom types, use transport hooks: https://svelte.dev/docs/kit/hooks#Universal-hooks-transport.`;
671
- if (error.path === "") return `Data returned from \`load\` while rendering ${event.route.id} is not a plain object`;
672
- return error.message;
673
- }
674
- /**
675
- * @param {import('types').ServerDataNode} node
676
- */
677
- function serialize_uses(node) {
678
- const uses = {};
679
- if (node.uses && node.uses.dependencies.size > 0) uses.dependencies = Array.from(node.uses.dependencies);
680
- if (node.uses && node.uses.search_params.size > 0) uses.search_params = Array.from(node.uses.search_params);
681
- if (node.uses && node.uses.params.size > 0) uses.params = Array.from(node.uses.params);
682
- if (node.uses?.parent) uses.parent = 1;
683
- if (node.uses?.route) uses.route = 1;
684
- if (node.uses?.url) uses.url = 1;
685
- return uses;
686
- }
687
- /**
688
- * Returns `true` if the given path was prerendered
689
- * @param {import('@sveltejs/kit').SSRManifest} manifest
690
- * @param {string} pathname Should include the base and be decoded
691
- */
692
- function has_prerendered_path(manifest, pathname) {
693
- return manifest._.prerendered_routes.has(pathname) || pathname.at(-1) === "/" && manifest._.prerendered_routes.has(pathname.slice(0, -1));
694
- }
695
- /**
696
- * Formats the error into a nice message with sanitized stack trace
697
- * @param {number} status
698
- * @param {Error} error
699
- * @param {import('@sveltejs/kit').RequestEvent} event
700
- */
701
- function format_server_error(status, error, event) {
702
- const formatted_text = `\n\x1b[1;31m[${status}] ${event.request.method} ${event.url.pathname}\x1b[0m`;
703
- if (status === 404) return formatted_text;
704
- return `${formatted_text}\n${error.stack}`;
705
- }
706
- /**
707
- * Returns the filename without the extension. e.g., `+page.server`, `+page`, etc.
708
- * @param {string | undefined} node_id
709
- * @returns {string}
710
- */
711
- function get_node_type(node_id) {
712
- const filename = (node_id?.split("/"))?.at(-1);
713
- if (!filename) return "unknown";
714
- return filename.split(".").slice(0, -1).join(".");
715
- }
716
-
717
- var cookie = {};
718
-
719
- /*!
720
- * cookie
721
- * Copyright(c) 2012-2014 Roman Shtylman
722
- * Copyright(c) 2015 Douglas Christopher Wilson
723
- * MIT Licensed
724
- */
725
-
726
- var hasRequiredCookie;
727
-
728
- function requireCookie () {
729
- if (hasRequiredCookie) return cookie;
730
- hasRequiredCookie = 1;
731
-
732
- /**
733
- * Module exports.
734
- * @public
735
- */
736
-
737
- cookie.parse = parse;
738
- cookie.serialize = serialize;
739
-
740
- /**
741
- * Module variables.
742
- * @private
743
- */
744
-
745
- var __toString = Object.prototype.toString;
746
-
747
- /**
748
- * RegExp to match field-content in RFC 7230 sec 3.2
749
- *
750
- * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
751
- * field-vchar = VCHAR / obs-text
752
- * obs-text = %x80-FF
753
- */
754
-
755
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
756
-
757
- /**
758
- * Parse a cookie header.
759
- *
760
- * Parse the given cookie header string into an object
761
- * The object has the various cookies as keys(names) => values
762
- *
763
- * @param {string} str
764
- * @param {object} [options]
765
- * @return {object}
766
- * @public
767
- */
768
-
769
- function parse(str, options) {
770
- if (typeof str !== 'string') {
771
- throw new TypeError('argument str must be a string');
772
- }
773
-
774
- var obj = {};
775
- var opt = options || {};
776
- var dec = opt.decode || decode;
777
-
778
- var index = 0;
779
- while (index < str.length) {
780
- var eqIdx = str.indexOf('=', index);
781
-
782
- // no more cookie pairs
783
- if (eqIdx === -1) {
784
- break
785
- }
786
-
787
- var endIdx = str.indexOf(';', index);
788
-
789
- if (endIdx === -1) {
790
- endIdx = str.length;
791
- } else if (endIdx < eqIdx) {
792
- // backtrack on prior semicolon
793
- index = str.lastIndexOf(';', eqIdx - 1) + 1;
794
- continue
795
- }
796
-
797
- var key = str.slice(index, eqIdx).trim();
798
-
799
- // only assign once
800
- if (undefined === obj[key]) {
801
- var val = str.slice(eqIdx + 1, endIdx).trim();
802
-
803
- // quoted values
804
- if (val.charCodeAt(0) === 0x22) {
805
- val = val.slice(1, -1);
806
- }
807
-
808
- obj[key] = tryDecode(val, dec);
809
- }
810
-
811
- index = endIdx + 1;
812
- }
813
-
814
- return obj;
815
- }
816
-
817
- /**
818
- * Serialize data into a cookie header.
819
- *
820
- * Serialize the a name value pair into a cookie string suitable for
821
- * http headers. An optional options object specified cookie parameters.
822
- *
823
- * serialize('foo', 'bar', { httpOnly: true })
824
- * => "foo=bar; httpOnly"
825
- *
826
- * @param {string} name
827
- * @param {string} val
828
- * @param {object} [options]
829
- * @return {string}
830
- * @public
831
- */
832
-
833
- function serialize(name, val, options) {
834
- var opt = options || {};
835
- var enc = opt.encode || encode;
836
-
837
- if (typeof enc !== 'function') {
838
- throw new TypeError('option encode is invalid');
839
- }
840
-
841
- if (!fieldContentRegExp.test(name)) {
842
- throw new TypeError('argument name is invalid');
843
- }
844
-
845
- var value = enc(val);
846
-
847
- if (value && !fieldContentRegExp.test(value)) {
848
- throw new TypeError('argument val is invalid');
849
- }
850
-
851
- var str = name + '=' + value;
852
-
853
- if (null != opt.maxAge) {
854
- var maxAge = opt.maxAge - 0;
855
-
856
- if (isNaN(maxAge) || !isFinite(maxAge)) {
857
- throw new TypeError('option maxAge is invalid')
858
- }
859
-
860
- str += '; Max-Age=' + Math.floor(maxAge);
861
- }
862
-
863
- if (opt.domain) {
864
- if (!fieldContentRegExp.test(opt.domain)) {
865
- throw new TypeError('option domain is invalid');
866
- }
867
-
868
- str += '; Domain=' + opt.domain;
869
- }
870
-
871
- if (opt.path) {
872
- if (!fieldContentRegExp.test(opt.path)) {
873
- throw new TypeError('option path is invalid');
874
- }
875
-
876
- str += '; Path=' + opt.path;
877
- }
878
-
879
- if (opt.expires) {
880
- var expires = opt.expires;
881
-
882
- if (!isDate(expires) || isNaN(expires.valueOf())) {
883
- throw new TypeError('option expires is invalid');
884
- }
885
-
886
- str += '; Expires=' + expires.toUTCString();
887
- }
888
-
889
- if (opt.httpOnly) {
890
- str += '; HttpOnly';
891
- }
892
-
893
- if (opt.secure) {
894
- str += '; Secure';
895
- }
896
-
897
- if (opt.partitioned) {
898
- str += '; Partitioned';
899
- }
900
-
901
- if (opt.priority) {
902
- var priority = typeof opt.priority === 'string'
903
- ? opt.priority.toLowerCase()
904
- : opt.priority;
905
-
906
- switch (priority) {
907
- case 'low':
908
- str += '; Priority=Low';
909
- break
910
- case 'medium':
911
- str += '; Priority=Medium';
912
- break
913
- case 'high':
914
- str += '; Priority=High';
915
- break
916
- default:
917
- throw new TypeError('option priority is invalid')
918
- }
919
- }
920
-
921
- if (opt.sameSite) {
922
- var sameSite = typeof opt.sameSite === 'string'
923
- ? opt.sameSite.toLowerCase() : opt.sameSite;
924
-
925
- switch (sameSite) {
926
- case true:
927
- str += '; SameSite=Strict';
928
- break;
929
- case 'lax':
930
- str += '; SameSite=Lax';
931
- break;
932
- case 'strict':
933
- str += '; SameSite=Strict';
934
- break;
935
- case 'none':
936
- str += '; SameSite=None';
937
- break;
938
- default:
939
- throw new TypeError('option sameSite is invalid');
940
- }
941
- }
942
-
943
- return str;
944
- }
945
-
946
- /**
947
- * URL-decode string value. Optimized to skip native call when no %.
948
- *
949
- * @param {string} str
950
- * @returns {string}
951
- */
952
-
953
- function decode (str) {
954
- return str.indexOf('%') !== -1
955
- ? decodeURIComponent(str)
956
- : str
957
- }
958
-
959
- /**
960
- * URL-encode value.
961
- *
962
- * @param {string} val
963
- * @returns {string}
964
- */
965
-
966
- function encode (val) {
967
- return encodeURIComponent(val)
968
- }
969
-
970
- /**
971
- * Determine if value is a Date.
972
- *
973
- * @param {*} val
974
- * @private
975
- */
976
-
977
- function isDate (val) {
978
- return __toString.call(val) === '[object Date]' ||
979
- val instanceof Date
980
- }
981
-
982
- /**
983
- * Try decoding a string using a decoding function.
984
- *
985
- * @param {string} str
986
- * @param {function} decode
987
- * @private
988
- */
989
-
990
- function tryDecode(str, decode) {
991
- try {
992
- return decode(str);
993
- } catch (e) {
994
- return str;
995
- }
996
- }
997
- return cookie;
998
- }
999
-
1000
- var cookieExports = requireCookie();
1001
-
1002
- var defaultParseOptions = {
1003
- decodeValues: true,
1004
- map: false,
1005
- silent: false,
1006
- split: "auto", // auto = split strings but not arrays
1007
- };
1008
-
1009
- function isForbiddenKey(key) {
1010
- return typeof key !== "string" || key in {};
1011
- }
1012
-
1013
- function createNullObj() {
1014
- return Object.create(null);
1015
- }
1016
-
1017
- function isNonEmptyString(str) {
1018
- return typeof str === "string" && !!str.trim();
1019
- }
1020
-
1021
- function parseString(setCookieValue, options) {
1022
- var parts = setCookieValue.split(";").filter(isNonEmptyString);
1023
-
1024
- var nameValuePairStr = parts.shift();
1025
- var parsed = parseNameValuePair(nameValuePairStr);
1026
- var name = parsed.name;
1027
- var value = parsed.value;
1028
-
1029
- options = options
1030
- ? Object.assign({}, defaultParseOptions, options)
1031
- : defaultParseOptions;
1032
-
1033
- if (isForbiddenKey(name)) {
1034
- return null;
1035
- }
1036
-
1037
- try {
1038
- value = options.decodeValues ? decodeURIComponent(value) : value; // decode cookie value
1039
- } catch (e) {
1040
- console.error(
1041
- "set-cookie-parser: failed to decode cookie value. Set options.decodeValues=false to disable decoding.",
1042
- e
1043
- );
1044
- }
1045
-
1046
- var cookie = createNullObj();
1047
- cookie.name = name;
1048
- cookie.value = value;
1049
-
1050
- parts.forEach(function (part) {
1051
- var sides = part.split("=");
1052
- var key = sides.shift().trimLeft().toLowerCase();
1053
- if (isForbiddenKey(key)) {
1054
- return;
1055
- }
1056
- var value = sides.join("=");
1057
- if (key === "expires") {
1058
- cookie.expires = new Date(value);
1059
- } else if (key === "max-age") {
1060
- var n = parseInt(value, 10);
1061
- if (!Number.isNaN(n)) cookie.maxAge = n;
1062
- } else if (key === "secure") {
1063
- cookie.secure = true;
1064
- } else if (key === "httponly") {
1065
- cookie.httpOnly = true;
1066
- } else if (key === "samesite") {
1067
- cookie.sameSite = value;
1068
- } else if (key === "partitioned") {
1069
- cookie.partitioned = true;
1070
- } else if (key) {
1071
- cookie[key] = value;
1072
- }
1073
- });
1074
-
1075
- return cookie;
1076
- }
1077
-
1078
- function parseNameValuePair(nameValuePairStr) {
1079
- // Parses name-value-pair according to rfc6265bis draft
1080
-
1081
- var name = "";
1082
- var value = "";
1083
- var nameValueArr = nameValuePairStr.split("=");
1084
- if (nameValueArr.length > 1) {
1085
- name = nameValueArr.shift();
1086
- value = nameValueArr.join("="); // everything after the first =, joined by a "=" if there was more than one part
1087
- } else {
1088
- value = nameValuePairStr;
1089
- }
1090
-
1091
- return { name: name, value: value };
1092
- }
1093
-
1094
- function parseSetCookie(input, options) {
1095
- options = options
1096
- ? Object.assign({}, defaultParseOptions, options)
1097
- : defaultParseOptions;
1098
-
1099
- if (!input) {
1100
- if (!options.map) {
1101
- return [];
1102
- } else {
1103
- return createNullObj();
1104
- }
1105
- }
1106
-
1107
- if (input.headers) {
1108
- if (typeof input.headers.getSetCookie === "function") {
1109
- // for fetch responses - they combine headers of the same type in the headers array,
1110
- // but getSetCookie returns an uncombined array
1111
- input = input.headers.getSetCookie();
1112
- } else if (input.headers["set-cookie"]) {
1113
- // fast-path for node.js (which automatically normalizes header names to lower-case)
1114
- input = input.headers["set-cookie"];
1115
- } else {
1116
- // slow-path for other environments - see #25
1117
- var sch =
1118
- input.headers[
1119
- Object.keys(input.headers).find(function (key) {
1120
- return key.toLowerCase() === "set-cookie";
1121
- })
1122
- ];
1123
- // warn if called on a request-like object with a cookie header rather than a set-cookie header - see #34, 36
1124
- if (!sch && input.headers.cookie && !options.silent) {
1125
- console.warn(
1126
- "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
1127
- );
1128
- }
1129
- input = sch;
1130
- }
1131
- }
1132
-
1133
- var split = options.split;
1134
- var isArray = Array.isArray(input);
1135
-
1136
- if (split === "auto") {
1137
- split = !isArray;
1138
- }
1139
-
1140
- if (!isArray) {
1141
- input = [input];
1142
- }
1143
-
1144
- input = input.filter(isNonEmptyString);
1145
-
1146
- if (split) {
1147
- input = input.map(splitCookiesString).flat();
1148
- }
1149
-
1150
- if (!options.map) {
1151
- return input
1152
- .map(function (str) {
1153
- return parseString(str, options);
1154
- })
1155
- .filter(Boolean);
1156
- } else {
1157
- var cookies = createNullObj();
1158
- return input.reduce(function (cookies, str) {
1159
- var cookie = parseString(str, options);
1160
- if (cookie && !isForbiddenKey(cookie.name)) {
1161
- cookies[cookie.name] = cookie;
1162
- }
1163
- return cookies;
1164
- }, cookies);
1165
- }
1166
- }
1167
-
1168
- /*
1169
- Set-Cookie header field-values are sometimes comma joined in one string. This splits them without choking on commas
1170
- that are within a single set-cookie field-value, such as in the Expires portion.
1171
-
1172
- This is uncommon, but explicitly allowed - see https://tools.ietf.org/html/rfc2616#section-4.2
1173
- Node.js does this for every header *except* set-cookie - see https://github.com/nodejs/node/blob/d5e363b77ebaf1caf67cd7528224b651c86815c1/lib/_http_incoming.js#L128
1174
- React Native's fetch does this for *every* header, including set-cookie.
1175
-
1176
- Based on: https://github.com/google/j2objc/commit/16820fdbc8f76ca0c33472810ce0cb03d20efe25
1177
- Credits to: https://github.com/tomball for original and https://github.com/chrusart for JavaScript implementation
1178
- */
1179
- function splitCookiesString(cookiesString) {
1180
- if (Array.isArray(cookiesString)) {
1181
- return cookiesString;
1182
- }
1183
- if (typeof cookiesString !== "string") {
1184
- return [];
1185
- }
1186
-
1187
- var cookiesStrings = [];
1188
- var pos = 0;
1189
- var start;
1190
- var ch;
1191
- var lastComma;
1192
- var nextStart;
1193
- var cookiesSeparatorFound;
1194
-
1195
- function skipWhitespace() {
1196
- while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
1197
- pos += 1;
1198
- }
1199
- return pos < cookiesString.length;
1200
- }
1201
-
1202
- function notSpecialChar() {
1203
- ch = cookiesString.charAt(pos);
1204
-
1205
- return ch !== "=" && ch !== ";" && ch !== ",";
1206
- }
1207
-
1208
- while (pos < cookiesString.length) {
1209
- start = pos;
1210
- cookiesSeparatorFound = false;
1211
-
1212
- while (skipWhitespace()) {
1213
- ch = cookiesString.charAt(pos);
1214
- if (ch === ",") {
1215
- // ',' is a cookie separator if we have later first '=', not ';' or ','
1216
- lastComma = pos;
1217
- pos += 1;
1218
-
1219
- skipWhitespace();
1220
- nextStart = pos;
1221
-
1222
- while (pos < cookiesString.length && notSpecialChar()) {
1223
- pos += 1;
1224
- }
1225
-
1226
- // currently special character
1227
- if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
1228
- // we found cookies separator
1229
- cookiesSeparatorFound = true;
1230
- // pos is inside the next cookie, so back up and return it.
1231
- pos = nextStart;
1232
- cookiesStrings.push(cookiesString.substring(start, lastComma));
1233
- start = pos;
1234
- } else {
1235
- // in param ',' or param separator ';',
1236
- // we continue from that comma
1237
- pos = lastComma + 1;
1238
- }
1239
- } else {
1240
- pos += 1;
1241
- }
1242
- }
1243
-
1244
- if (!cookiesSeparatorFound || pos >= cookiesString.length) {
1245
- cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
1246
- }
1247
- }
1248
-
1249
- return cookiesStrings;
1250
- }
1251
-
1252
- // named export for CJS
1253
- parseSetCookie.parseSetCookie = parseSetCookie;
1254
- // for backwards compatibility
1255
- parseSetCookie.parse = parseSetCookie;
1256
- parseSetCookie.parseString = parseString;
1257
- parseSetCookie.splitCookiesString = splitCookiesString;
1258
-
1259
- //#region ../../node_modules/@sveltejs/kit/src/utils/promise.js
1260
- /** @see https://github.com/microsoft/TypeScript/blob/904e7dd97dc8da1352c8e05d70829dff17c73214/src/lib/es2024.promise.d.ts */
1261
- /**
1262
- * @template T
1263
- * @typedef {{
1264
- * promise: Promise<T>;
1265
- * resolve: (value: T | PromiseLike<T>) => void;
1266
- * reject: (reason?: any) => void;
1267
- * }} PromiseWithResolvers<T>
1268
- */
1269
- /**
1270
- * TODO: Whenever Node >21 is minimum supported version, we can use `Promise.withResolvers` to avoid this ceremony
1271
- *
1272
- * @template T
1273
- * @returns {PromiseWithResolvers<T>}
1274
- */
1275
- function with_resolvers() {
1276
- let resolve;
1277
- let reject;
1278
- return {
1279
- promise: new Promise((res, rej) => {
1280
- resolve = res;
1281
- reject = rej;
1282
- }),
1283
- resolve,
1284
- reject
1285
- };
1286
- }
1287
- //#endregion
1288
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/constants.js
1289
- var NULL_BODY_STATUS = [
1290
- 101,
1291
- 103,
1292
- 204,
1293
- 205,
1294
- 304
1295
- ];
1296
- var IN_WEBCONTAINER = !!globalThis.process?.versions?.webcontainer;
1297
- //#endregion
1298
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/endpoint.js
1299
- /**
1300
- * @param {import('@sveltejs/kit').RequestEvent} event
1301
- * @param {import('types').RequestState} event_state
1302
- * @param {import('types').SSREndpoint} mod
1303
- * @param {import('types').SSRState} state
1304
- * @returns {Promise<Response>}
1305
- */
1306
- async function render_endpoint(event, event_state, mod, state) {
1307
- const method = event.request.method;
1308
- let handler = mod[method] || mod.fallback;
1309
- if (method === "HEAD" && !mod.HEAD && mod.GET) handler = mod.GET;
1310
- if (!handler) return method_not_allowed(mod, method);
1311
- const prerender = mod.prerender ?? state.prerender_default;
1312
- if (prerender && (mod.POST || mod.PATCH || mod.PUT || mod.DELETE)) throw new Error("Cannot prerender endpoints that have mutative methods");
1313
- if (state.prerendering && !state.prerendering.inside_reroute && !prerender) if (state.depth > 0) throw new Error(`${event.route.id} is not prerenderable`);
1314
- else return new Response(void 0, { status: 204 });
1315
- try {
1316
- const response = await with_request_store({
1317
- event,
1318
- state: event_state
1319
- }, () => handler(event));
1320
- if (!(response instanceof Response)) throw new Error(`Invalid response from route ${event.url.pathname}: handler should return a Response object`);
1321
- if (state.prerendering && (!state.prerendering.inside_reroute || prerender)) {
1322
- const cloned = new Response(response.clone().body, {
1323
- status: response.status,
1324
- statusText: response.statusText,
1325
- headers: new Headers(response.headers)
1326
- });
1327
- cloned.headers.set("x-sveltekit-prerender", String(prerender));
1328
- if (state.prerendering.inside_reroute && prerender) {
1329
- cloned.headers.set("x-sveltekit-routeid", encodeURI(event.route.id));
1330
- state.prerendering.dependencies.set(event.url.pathname, {
1331
- response: cloned,
1332
- body: null
1333
- });
1334
- } else return cloned;
1335
- }
1336
- return response;
1337
- } catch (e) {
1338
- if (e instanceof Redirect) return new Response(void 0, {
1339
- status: e.status,
1340
- headers: { location: e.location }
1341
- });
1342
- throw e;
1343
- }
1344
- }
1345
- /**
1346
- * @param {import('@sveltejs/kit').RequestEvent} event
1347
- */
1348
- function is_endpoint_request(event) {
1349
- const { method, headers } = event.request;
1350
- if (ENDPOINT_METHODS.includes(method) && !PAGE_METHODS.includes(method)) return true;
1351
- if (method === "POST" && headers.get("x-sveltekit-action") === "true") return false;
1352
- return negotiate(event.request.headers.get("accept") ?? "*/*", ["*", "text/html"]) !== "text/html";
1353
- }
1354
- //#endregion
1355
- //#region ../../node_modules/@sveltejs/kit/src/runtime/telemetry/record_span.js
1356
- /** @import { RecordSpan } from 'types' */
1357
- /** @type {RecordSpan} */
1358
- async function record_span({ name, attributes, fn }) {
1359
- return fn(noop_span);
1360
- }
1361
- //#endregion
1362
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/page/actions.js
1363
- /** @import { RequestEvent, ActionResult, Actions } from '@sveltejs/kit' */
1364
- /** @import { SSROptions, SSRNode, ServerNode, ServerHooks } from 'types' */
1365
- /** @param {RequestEvent} event */
1366
- function is_action_json_request(event) {
1367
- return negotiate(event.request.headers.get("accept") ?? "*/*", ["application/json", "text/html"]) === "application/json" && event.request.method === "POST";
1368
- }
1369
- /**
1370
- * @param {RequestEvent} event
1371
- * @param {import('types').RequestState} event_state
1372
- * @param {SSROptions} options
1373
- * @param {SSRNode['server'] | undefined} server
1374
- */
1375
- async function handle_action_json_request(event, event_state, options, server) {
1376
- const actions = server?.actions;
1377
- if (!actions) {
1378
- const no_actions_error = new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`);
1379
- return action_json({
1380
- type: "error",
1381
- error: await handle_error_and_jsonify(event, event_state, options, no_actions_error)
1382
- }, {
1383
- status: no_actions_error.status,
1384
- headers: { allow: "GET" }
1385
- });
1386
- }
1387
- check_named_default_separate(actions);
1388
- try {
1389
- const data = await call_action(event, event_state, actions);
1390
- if (data instanceof ActionFailure) return action_json({
1391
- type: "failure",
1392
- status: data.status,
1393
- data: stringify_action_response(data.data, event.route.id, options.hooks.transport)
1394
- });
1395
- else return action_json({
1396
- type: "success",
1397
- status: data ? 200 : 204,
1398
- data: stringify_action_response(data, event.route.id, options.hooks.transport)
1399
- });
1400
- } catch (e) {
1401
- const err = normalize_error(e);
1402
- if (err instanceof Redirect) return action_json_redirect(err);
1403
- return action_json({
1404
- type: "error",
1405
- error: await handle_error_and_jsonify(event, event_state, options, check_incorrect_fail_use(err))
1406
- }, { status: get_status(err) });
1407
- }
1408
- }
1409
- /**
1410
- * @param {HttpError | Error} error
1411
- */
1412
- function check_incorrect_fail_use(error) {
1413
- return error instanceof ActionFailure ? /* @__PURE__ */ new Error("Cannot \"throw fail()\". Use \"return fail()\"") : error;
1414
- }
1415
- /**
1416
- * @param {Redirect} redirect
1417
- */
1418
- function action_json_redirect(redirect) {
1419
- return action_json({
1420
- type: "redirect",
1421
- status: redirect.status,
1422
- location: redirect.location
1423
- });
1424
- }
1425
- /**
1426
- * @param {ActionResult} data
1427
- * @param {ResponseInit} [init]
1428
- */
1429
- function action_json(data, init) {
1430
- return json(data, init);
1431
- }
1432
- /**
1433
- * @param {RequestEvent} event
1434
- */
1435
- function is_action_request(event) {
1436
- return event.request.method === "POST";
1437
- }
1438
- /**
1439
- * @param {RequestEvent} event
1440
- * @param {import('types').RequestState} event_state
1441
- * @param {SSRNode['server'] | undefined} server
1442
- * @returns {Promise<ActionResult>}
1443
- */
1444
- async function handle_action_request(event, event_state, server) {
1445
- const actions = server?.actions;
1446
- if (!actions) {
1447
- event.setHeaders({ allow: "GET" });
1448
- return {
1449
- type: "error",
1450
- error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`)
1451
- };
1452
- }
1453
- check_named_default_separate(actions);
1454
- try {
1455
- const data = await call_action(event, event_state, actions);
1456
- if (data instanceof ActionFailure) return {
1457
- type: "failure",
1458
- status: data.status,
1459
- data: data.data
1460
- };
1461
- else return {
1462
- type: "success",
1463
- status: 200,
1464
- data
1465
- };
1466
- } catch (e) {
1467
- const err = normalize_error(e);
1468
- if (err instanceof Redirect) return {
1469
- type: "redirect",
1470
- status: err.status,
1471
- location: err.location
1472
- };
1473
- return {
1474
- type: "error",
1475
- error: check_incorrect_fail_use(err)
1476
- };
1477
- }
1478
- }
1479
- /**
1480
- * @param {Actions} actions
1481
- */
1482
- function check_named_default_separate(actions) {
1483
- if (actions.default && Object.keys(actions).length > 1) throw new Error("When using named actions, the default action cannot be used. See the docs for more info: https://svelte.dev/docs/kit/form-actions#named-actions");
1484
- }
1485
- /**
1486
- * @param {RequestEvent} event
1487
- * @param {import('types').RequestState} event_state
1488
- * @param {NonNullable<ServerNode['actions']>} actions
1489
- * @throws {Redirect | HttpError | SvelteKitError | Error}
1490
- */
1491
- async function call_action(event, event_state, actions) {
1492
- const url = new URL(event.request.url);
1493
- let name = "default";
1494
- for (const param of url.searchParams) if (param[0].startsWith("/")) {
1495
- name = param[0].slice(1);
1496
- if (name === "default") throw new Error("Cannot use reserved action name \"default\"");
1497
- break;
1498
- }
1499
- const action = actions[name];
1500
- if (!action) throw new SvelteKitError(404, "Not Found", `No action with name '${name}' found`);
1501
- if (!is_form_content_type(event.request)) throw new SvelteKitError(415, "Unsupported Media Type", `Form actions expect form-encoded data — received ${event.request.headers.get("content-type")}`);
1502
- return record_span({
1503
- name: "sveltekit.form_action",
1504
- attributes: {
1505
- "http.route": event.route.id || "unknown"
1506
- },
1507
- fn: async (current) => {
1508
- const traced_event = merge_tracing(event, current);
1509
- const result = await with_request_store({
1510
- event: traced_event,
1511
- state: event_state
1512
- }, () => action(traced_event));
1513
- if (result instanceof ActionFailure) current.setAttributes({
1514
- "sveltekit.form_action.result.type": "failure",
1515
- "sveltekit.form_action.result.status": result.status
1516
- });
1517
- return result;
1518
- }
1519
- });
1520
- }
1521
- /**
1522
- * Try to `devalue.uneval` the data object, and if it fails, return a proper Error with context
1523
- * @param {any} data
1524
- * @param {string} route_id
1525
- * @param {ServerHooks['transport']} transport
1526
- */
1527
- function uneval_action_response(data, route_id, transport) {
1528
- const replacer = (thing) => {
1529
- for (const key in transport) {
1530
- const encoded = transport[key].encode(thing);
1531
- if (encoded) return `app.decode('${key}', ${uneval(encoded, replacer)})`;
1532
- }
1533
- };
1534
- return try_serialize(data, (value) => uneval(value, replacer), route_id);
1535
- }
1536
- /**
1537
- * Try to `devalue.stringify` the data object, and if it fails, return a proper Error with context
1538
- * @param {any} data
1539
- * @param {string} route_id
1540
- * @param {ServerHooks['transport']} transport
1541
- */
1542
- function stringify_action_response(data, route_id, transport) {
1543
- const encoders = Object.fromEntries(Object.entries(transport).map(([key, value]) => [key, value.encode]));
1544
- return try_serialize(data, (value) => stringify$1(value, encoders), route_id);
1545
- }
1546
- /**
1547
- * @param {any} data
1548
- * @param {(data: any) => string} fn
1549
- * @param {string} route_id
1550
- */
1551
- function try_serialize(data, fn, route_id) {
1552
- try {
1553
- return fn(data);
1554
- } catch (e) {
1555
- const error = e;
1556
- if (data instanceof Response) throw new Error(`Data returned from action inside ${route_id} is not serializable. Form actions need to return plain objects or fail(). E.g. return { success: true } or return fail(400, { message: "invalid" });`, { cause: e });
1557
- if ("path" in error) {
1558
- let message = `Data returned from action inside ${route_id} is not serializable: ${error.message}`;
1559
- if (error.path !== "") message += ` (data.${error.path})`;
1560
- throw new Error(message, { cause: e });
1561
- }
1562
- throw error;
1563
- }
1564
- }
1565
- //#endregion
1566
- //#region ../../node_modules/@sveltejs/kit/src/utils/streaming.js
1567
- /**
1568
- * Create an async iterator and a function to push values into it
1569
- * @template T
1570
- * @returns {{
1571
- * iterate: (transform?: (input: T) => T) => AsyncIterable<T>;
1572
- * add: (promise: Promise<T>) => void;
1573
- * }}
1574
- */
1575
- function create_async_iterator() {
1576
- let resolved = -1;
1577
- let returned = -1;
1578
- /** @type {import('./promise.js').PromiseWithResolvers<T>[]} */
1579
- const deferred = [];
1580
- return {
1581
- iterate: (transform = (x) => x) => {
1582
- return { [Symbol.asyncIterator]() {
1583
- return { next: async () => {
1584
- const next = deferred[++returned];
1585
- if (!next) return {
1586
- value: null,
1587
- done: true
1588
- };
1589
- return {
1590
- value: transform(await next.promise),
1591
- done: false
1592
- };
1593
- } };
1594
- } };
1595
- },
1596
- add: (promise) => {
1597
- deferred.push(with_resolvers());
1598
- promise.then((value) => {
1599
- deferred[++resolved].resolve(value);
1600
- });
1601
- }
1602
- };
1603
- }
1604
- //#endregion
1605
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/page/data_serializer.js
1606
- /**
1607
- * If the serialized data contains promises, `chunks` will be an
1608
- * async iterable containing their resolutions
1609
- * @param {import('@sveltejs/kit').RequestEvent} event
1610
- * @param {import('types').RequestState} event_state
1611
- * @param {import('types').SSROptions} options
1612
- * @returns {import('./types.js').ServerDataSerializer}
1613
- */
1614
- function server_data_serializer(event, event_state, options) {
1615
- let promise_id = 1;
1616
- let max_nodes = -1;
1617
- const iterator = create_async_iterator();
1618
- const global = get_global_name(options);
1619
- /** @param {number} index */
1620
- function get_replacer(index) {
1621
- /** @param {any} thing */
1622
- return function replacer(thing) {
1623
- if (typeof thing?.then === "function") {
1624
- const id = promise_id++;
1625
- const promise = thing.then(
1626
- /** @param {any} data */
1627
- (data) => ({ data })
1628
- ).catch(
1629
- /** @param {any} error */
1630
- async (error) => ({ error: await handle_error_and_jsonify(event, event_state, options, error) })
1631
- ).then(
1632
- /**
1633
- * @param {{data: any; error: any}} result
1634
- */
1635
- async ({ data, error }) => {
1636
- let str;
1637
- try {
1638
- str = uneval(error ? [, error] : [data], replacer);
1639
- } catch {
1640
- error = await handle_error_and_jsonify(event, event_state, options, /* @__PURE__ */ new Error(`Failed to serialize promise while rendering ${event.route.id}`));
1641
- str = uneval([, error], replacer);
1642
- }
1643
- return {
1644
- index,
1645
- str: `${global}.resolve(${id}, ${str.includes("app.decode") ? `(app) => ${str}` : `() => ${str}`})`
1646
- };
1647
- }
1648
- );
1649
- iterator.add(promise);
1650
- return `${global}.defer(${id})`;
1651
- } else for (const key in options.hooks.transport) {
1652
- const encoded = options.hooks.transport[key].encode(thing);
1653
- if (encoded) return `app.decode('${key}', ${uneval(encoded, replacer)})`;
1654
- }
1655
- };
1656
- }
1657
- const strings = [];
1658
- return {
1659
- set_max_nodes(i) {
1660
- max_nodes = i;
1661
- },
1662
- add_node(i, node) {
1663
- try {
1664
- if (!node) {
1665
- strings[i] = "null";
1666
- return;
1667
- }
1668
- /** @type {any} */
1669
- const payload = {
1670
- type: "data",
1671
- data: node.data,
1672
- uses: serialize_uses(node)
1673
- };
1674
- if (node.slash) payload.slash = node.slash;
1675
- strings[i] = uneval(payload, get_replacer(i));
1676
- } catch (e) {
1677
- e.path = e.path.slice(1);
1678
- throw new Error(clarify_devalue_error(event, e), { cause: e });
1679
- }
1680
- },
1681
- get_data(csp) {
1682
- const open = `<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>`;
1683
- const close = `<\/script>\n`;
1684
- return {
1685
- data: `[${compact(max_nodes > -1 ? strings.slice(0, max_nodes) : strings).join(",")}]`,
1686
- chunks: promise_id > 1 ? iterator.iterate(({ index, str }) => {
1687
- if (max_nodes > -1 && index >= max_nodes) return "";
1688
- return open + str + close;
1689
- }) : null
1690
- };
1691
- }
1692
- };
1693
- }
1694
- /**
1695
- * If the serialized data contains promises, `chunks` will be an
1696
- * async iterable containing their resolutions
1697
- * @param {import('@sveltejs/kit').RequestEvent} event
1698
- * @param {import('types').RequestState} event_state
1699
- * @param {import('types').SSROptions} options
1700
- * @returns {import('./types.js').ServerDataSerializerJson}
1701
- */
1702
- function server_data_serializer_json(event, event_state, options) {
1703
- let promise_id = 1;
1704
- const iterator = create_async_iterator();
1705
- const reducers = {
1706
- ...Object.fromEntries(Object.entries(options.hooks.transport).map(([key, value]) => [key, value.encode])),
1707
- /** @param {any} thing */
1708
- Promise: (thing) => {
1709
- if (typeof thing?.then !== "function") return;
1710
- const id = promise_id++;
1711
- /** @type {'data' | 'error'} */
1712
- let key = "data";
1713
- const promise = thing.catch(
1714
- /** @param {any} e */
1715
- async (e) => {
1716
- key = "error";
1717
- return handle_error_and_jsonify(event, event_state, options, e);
1718
- }
1719
- ).then(
1720
- /** @param {any} value */
1721
- async (value) => {
1722
- let str;
1723
- try {
1724
- str = stringify$1(value, reducers);
1725
- } catch {
1726
- const error = await handle_error_and_jsonify(event, event_state, options, /* @__PURE__ */ new Error(`Failed to serialize promise while rendering ${event.route.id}`));
1727
- key = "error";
1728
- str = stringify$1(error, reducers);
1729
- }
1730
- return `{"type":"chunk","id":${id},"${key}":${str}}\n`;
1731
- }
1732
- );
1733
- iterator.add(promise);
1734
- return id;
1735
- }
1736
- };
1737
- const strings = [];
1738
- return {
1739
- add_node(i, node) {
1740
- try {
1741
- if (!node) {
1742
- strings[i] = "null";
1743
- return;
1744
- }
1745
- if (node.type === "error" || node.type === "skip") {
1746
- strings[i] = JSON.stringify(node);
1747
- return;
1748
- }
1749
- strings[i] = `{"type":"data","data":${stringify$1(node.data, reducers)},"uses":${JSON.stringify(serialize_uses(node))}${node.slash ? `,"slash":${JSON.stringify(node.slash)}` : ""}}`;
1750
- } catch (e) {
1751
- e.path = "data" + e.path;
1752
- throw new Error(clarify_devalue_error(event, e), { cause: e });
1753
- }
1754
- },
1755
- get_data() {
1756
- return {
1757
- data: `{"type":"data","nodes":[${strings.join(",")}]}\n`,
1758
- chunks: promise_id > 1 ? iterator.iterate() : null
1759
- };
1760
- }
1761
- };
1762
- }
1763
- //#endregion
1764
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/page/load_data.js
1765
- /**
1766
- * Calls the user's server `load` function.
1767
- * @param {{
1768
- * event: import('@sveltejs/kit').RequestEvent;
1769
- * event_state: import('types').RequestState;
1770
- * state: import('types').SSRState;
1771
- * node: import('types').SSRNode | undefined;
1772
- * parent: () => Promise<Record<string, any>>;
1773
- * }} opts
1774
- * @returns {Promise<import('types').ServerDataNode | null>}
1775
- */
1776
- async function load_server_data({ event, event_state, state, node, parent }) {
1777
- if (!node?.server) return null;
1778
- let is_tracking = true;
1779
- const uses = {
1780
- dependencies: /* @__PURE__ */ new Set(),
1781
- params: /* @__PURE__ */ new Set(),
1782
- parent: false,
1783
- route: false,
1784
- url: false,
1785
- search_params: /* @__PURE__ */ new Set()
1786
- };
1787
- const load = node.server.load;
1788
- const slash = node.server.trailingSlash;
1789
- if (!load) return {
1790
- type: "data",
1791
- data: null,
1792
- uses,
1793
- slash
1794
- };
1795
- const url = make_trackable(event.url, () => {
1796
- if (is_tracking) uses.url = true;
1797
- }, (param) => {
1798
- if (is_tracking) uses.search_params.add(param);
1799
- });
1800
- if (state.prerendering) disable_search(url);
1801
- return {
1802
- type: "data",
1803
- data: await record_span({
1804
- name: "sveltekit.load",
1805
- attributes: {
1806
- "sveltekit.load.node_id": node.server_id || "unknown",
1807
- "sveltekit.load.node_type": get_node_type(node.server_id),
1808
- "http.route": event.route.id || "unknown"
1809
- },
1810
- fn: async (current) => {
1811
- const traced_event = merge_tracing(event, current);
1812
- return await with_request_store({
1813
- event: traced_event,
1814
- state: event_state
1815
- }, () => load.call(null, {
1816
- ...traced_event,
1817
- fetch: (info, init) => {
1818
- new URL(info instanceof Request ? info.url : info, event.url);
1819
- return event.fetch(info, init);
1820
- },
1821
- /** @param {string[]} deps */
1822
- depends: (...deps) => {
1823
- for (const dep of deps) {
1824
- const { href } = new URL(dep, event.url);
1825
- uses.dependencies.add(href);
1826
- }
1827
- },
1828
- params: new Proxy(event.params, { get: (target, key) => {
1829
- if (is_tracking) uses.params.add(key);
1830
- return target[key];
1831
- } }),
1832
- parent: async () => {
1833
- if (is_tracking) uses.parent = true;
1834
- return parent();
1835
- },
1836
- route: new Proxy(event.route, { get: (target, key) => {
1837
- if (is_tracking) uses.route = true;
1838
- return target[key];
1839
- } }),
1840
- url,
1841
- untrack(fn) {
1842
- is_tracking = false;
1843
- try {
1844
- return fn();
1845
- } finally {
1846
- is_tracking = true;
1847
- }
1848
- }
1849
- }));
1850
- }
1851
- }) ?? null,
1852
- uses,
1853
- slash
1854
- };
1855
- }
1856
- /**
1857
- * Calls the user's `load` function.
1858
- * @param {{
1859
- * event: import('@sveltejs/kit').RequestEvent;
1860
- * event_state: import('types').RequestState;
1861
- * fetched: import('./types.js').Fetched[];
1862
- * node: import('types').SSRNode | undefined;
1863
- * parent: () => Promise<Record<string, any>>;
1864
- * resolve_opts: import('types').RequiredResolveOptions;
1865
- * server_data_promise: Promise<import('types').ServerDataNode | null>;
1866
- * state: import('types').SSRState;
1867
- * csr: boolean;
1868
- * }} opts
1869
- * @returns {Promise<Record<string, any | Promise<any>> | null>}
1870
- */
1871
- async function load_data({ event, event_state, fetched, node, parent, server_data_promise, state, resolve_opts, csr }) {
1872
- const server_data_node = await server_data_promise;
1873
- const load = node?.universal?.load;
1874
- if (!load) return server_data_node?.data ?? null;
1875
- return await record_span({
1876
- name: "sveltekit.load",
1877
- attributes: {
1878
- "sveltekit.load.node_id": node.universal_id || "unknown",
1879
- "sveltekit.load.node_type": get_node_type(node.universal_id),
1880
- "http.route": event.route.id || "unknown"
1881
- },
1882
- fn: async (current) => {
1883
- const traced_event = merge_tracing(event, current);
1884
- return await with_request_store({
1885
- event: traced_event,
1886
- state: {
1887
- ...event_state,
1888
- is_in_universal_load: true
1889
- }
1890
- }, () => load.call(null, {
1891
- url: event.url,
1892
- params: event.params,
1893
- data: server_data_node?.data ?? null,
1894
- route: event.route,
1895
- fetch: create_universal_fetch(event, state, fetched, csr, resolve_opts),
1896
- setHeaders: event.setHeaders,
1897
- depends: noop,
1898
- parent,
1899
- untrack: (fn) => fn(),
1900
- tracing: traced_event.tracing
1901
- }));
1902
- }
1903
- }) ?? null;
1904
- }
1905
- /**
1906
- * @param {Pick<import('@sveltejs/kit').RequestEvent, 'fetch' | 'url' | 'request' | 'route'>} event
1907
- * @param {import('types').SSRState} state
1908
- * @param {import('./types.js').Fetched[]} fetched
1909
- * @param {boolean} csr
1910
- * @param {Pick<Required<import('@sveltejs/kit').ResolveOptions>, 'filterSerializedResponseHeaders'>} resolve_opts
1911
- * @returns {typeof fetch}
1912
- */
1913
- function create_universal_fetch(event, state, fetched, csr, resolve_opts) {
1914
- /**
1915
- * @param {URL | RequestInfo} input
1916
- * @param {RequestInit} [init]
1917
- */
1918
- const universal_fetch = async (input, init) => {
1919
- const cloned_body = input instanceof Request && input.body ? input.clone().body : null;
1920
- const cloned_headers = input instanceof Request && [...input.headers].length ? new Headers(input.headers) : init?.headers;
1921
- let response = await event.fetch(input, init);
1922
- const url = new URL(input instanceof Request ? input.url : input, event.url);
1923
- const same_origin = url.origin === event.url.origin;
1924
- /** @type {import('types').PrerenderDependency} */
1925
- let dependency;
1926
- if (same_origin) {
1927
- if (state.prerendering) {
1928
- dependency = {
1929
- response,
1930
- body: null
1931
- };
1932
- state.prerendering.dependencies.set(url.pathname, dependency);
1933
- }
1934
- } else if (url.protocol === "https:" || url.protocol === "http:") if ((input instanceof Request ? input.mode : init?.mode ?? "cors") === "no-cors") response = new Response("", {
1935
- status: response.status,
1936
- statusText: response.statusText,
1937
- headers: response.headers
1938
- });
1939
- else {
1940
- const acao = response.headers.get("access-control-allow-origin");
1941
- if (!acao || acao !== event.url.origin && acao !== "*") throw new Error(`CORS error: ${acao ? "Incorrect" : "No"} 'Access-Control-Allow-Origin' header is present on the requested resource`);
1942
- }
1943
- /** @type {ReadableStream<Uint8Array>} */
1944
- let teed_body;
1945
- const proxy = new Proxy(response, { get(response, key, receiver) {
1946
- /**
1947
- * @param {string | undefined} body
1948
- * @param {boolean} is_b64
1949
- */
1950
- async function push_fetched(body, is_b64) {
1951
- const status_number = Number(response.status);
1952
- if (isNaN(status_number)) throw new Error(`response.status is not a number. value: "${response.status}" type: ${typeof response.status}`);
1953
- fetched.push({
1954
- url: same_origin ? url.href.slice(event.url.origin.length) : url.href,
1955
- method: event.request.method,
1956
- request_body: input instanceof Request && cloned_body ? await stream_to_string(cloned_body) : init?.body,
1957
- request_headers: cloned_headers,
1958
- response_body: body,
1959
- response,
1960
- is_b64
1961
- });
1962
- }
1963
- if (key === "body") {
1964
- if (response.body === null) return null;
1965
- if (teed_body) return teed_body;
1966
- const [a, b] = response.body.tee();
1967
- (async () => {
1968
- let result = new Uint8Array();
1969
- for await (const chunk of a) {
1970
- const combined = new Uint8Array(result.length + chunk.length);
1971
- combined.set(result, 0);
1972
- combined.set(chunk, result.length);
1973
- result = combined;
1974
- }
1975
- if (dependency) dependency.body = new Uint8Array(result);
1976
- push_fetched(base64_encode(result), true);
1977
- })();
1978
- return teed_body = b;
1979
- }
1980
- if (key === "arrayBuffer") return async () => {
1981
- const buffer = await response.arrayBuffer();
1982
- const bytes = new Uint8Array(buffer);
1983
- if (dependency) dependency.body = bytes;
1984
- if (buffer instanceof ArrayBuffer) await push_fetched(base64_encode(bytes), true);
1985
- return buffer;
1986
- };
1987
- async function text() {
1988
- const body = await response.text();
1989
- if (body === "" && NULL_BODY_STATUS.includes(response.status)) {
1990
- await push_fetched(void 0, false);
1991
- return;
1992
- }
1993
- if (!body || typeof body === "string") await push_fetched(body, false);
1994
- if (dependency) dependency.body = body;
1995
- return body;
1996
- }
1997
- if (key === "text") return text;
1998
- if (key === "json") return async () => {
1999
- const body = await text();
2000
- return body ? JSON.parse(body) : void 0;
2001
- };
2002
- const value = Reflect.get(response, key, response);
2003
- if (value instanceof Function) return Object.defineProperties(
2004
- /**
2005
- * @this {any}
2006
- */
2007
- function() {
2008
- return Reflect.apply(value, this === receiver ? response : this, arguments);
2009
- },
2010
- {
2011
- name: { value: value.name },
2012
- length: { value: value.length }
2013
- }
2014
- );
2015
- return value;
2016
- } });
2017
- if (csr) {
2018
- const get = response.headers.get;
2019
- response.headers.get = (key) => {
2020
- const lower = key.toLowerCase();
2021
- const value = get.call(response.headers, lower);
2022
- if (value && !lower.startsWith("x-sveltekit-")) {
2023
- if (!resolve_opts.filterSerializedResponseHeaders(lower, value)) throw new Error(`Failed to get response header "${lower}" — it must be included by the \`filterSerializedResponseHeaders\` option: https://svelte.dev/docs/kit/hooks#Server-hooks-handle (at ${event.route.id})`);
2024
- }
2025
- return value;
2026
- };
2027
- }
2028
- return proxy;
2029
- };
2030
- return (input, init) => {
2031
- const response = universal_fetch(input, init);
2032
- response.catch(noop);
2033
- return response;
2034
- };
2035
- }
2036
- /**
2037
- * @param {ReadableStream<Uint8Array>} stream
2038
- */
2039
- async function stream_to_string(stream) {
2040
- let result = "";
2041
- const reader = stream.getReader();
2042
- const decoder = new TextDecoder();
2043
- while (true) {
2044
- const { done, value } = await reader.read();
2045
- if (done) {
2046
- result += decoder.decode();
2047
- break;
2048
- }
2049
- result += decoder.decode(value, { stream: true });
2050
- }
2051
- return result;
2052
- }
2053
- //#endregion
2054
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/page/serialize_data.js
2055
- /**
2056
- * Inside a script element, only `<\/script` and `<!--` hold special meaning to the HTML parser.
2057
- *
2058
- * The first closes the script element, so everything after is treated as raw HTML.
2059
- * The second disables further parsing until `-->`, so the script element might be unexpectedly
2060
- * kept open up until an unrelated HTML comment in the page.
2061
- *
2062
- * U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are escaped for the sake of pre-2018
2063
- * browsers.
2064
- *
2065
- * @see tests for unsafe parsing examples.
2066
- * @see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
2067
- * @see https://html.spec.whatwg.org/multipage/syntax.html#cdata-rcdata-restrictions
2068
- * @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-state
2069
- * @see https://html.spec.whatwg.org/multipage/parsing.html#script-data-double-escaped-state
2070
- * @see https://github.com/tc39/proposal-json-superset
2071
- * @type {Record<string, string>}
2072
- */
2073
- var replacements = {
2074
- "<": "\\u003C",
2075
- "\u2028": "\\u2028",
2076
- "\u2029": "\\u2029"
2077
- };
2078
- var pattern = new RegExp(`[${Object.keys(replacements).join("")}]`, "g");
2079
- /**
2080
- * Generates a raw HTML string containing a safe script element carrying data and associated attributes.
2081
- *
2082
- * It escapes all the special characters needed to guarantee the element is unbroken, but care must
2083
- * be taken to ensure it is inserted in the document at an acceptable position for a script element,
2084
- * and that the resulting string isn't further modified.
2085
- *
2086
- * @param {import('./types.js').Fetched} fetched
2087
- * @param {(name: string, value: string) => boolean} filter
2088
- * @param {boolean} [prerendering]
2089
- * @returns {string} The raw HTML of a script element carrying the JSON payload.
2090
- * @example const html = serialize_data('/data.json', null, { foo: 'bar' });
2091
- */
2092
- function serialize_data(fetched, filter, prerendering = false) {
2093
- /** @type {Record<string, string>} */
2094
- const headers = {};
2095
- let cache_control = null;
2096
- let age = null;
2097
- let varyAny = false;
2098
- for (const [key, value] of fetched.response.headers) {
2099
- if (filter(key, value)) headers[key] = value;
2100
- if (key === "cache-control") cache_control = value;
2101
- else if (key === "age") age = value;
2102
- else if (key === "vary" && value.trim() === "*") varyAny = true;
2103
- }
2104
- const payload = {
2105
- status: fetched.response.status,
2106
- statusText: fetched.response.statusText,
2107
- headers,
2108
- body: fetched.response_body
2109
- };
2110
- const safe_payload = JSON.stringify(payload).replace(pattern, (match) => replacements[match]);
2111
- const attrs = [
2112
- "type=\"application/json\"",
2113
- "data-sveltekit-fetched",
2114
- `data-url="${escape_html(fetched.url, true)}"`
2115
- ];
2116
- if (fetched.is_b64) attrs.push("data-b64");
2117
- if (fetched.request_headers || fetched.request_body) {
2118
- /** @type {import('types').StrictBody[]} */
2119
- const values = [];
2120
- if (fetched.request_headers) values.push([...new Headers(fetched.request_headers)].join(","));
2121
- if (fetched.request_body) values.push(fetched.request_body);
2122
- attrs.push(`data-hash="${hash(...values)}"`);
2123
- }
2124
- if (!prerendering && fetched.method === "GET" && cache_control && !varyAny) {
2125
- const match = /s-maxage=(\d+)/g.exec(cache_control) ?? /max-age=(\d+)/g.exec(cache_control);
2126
- if (match) {
2127
- const ttl = +match[1] - +(age ?? "0");
2128
- attrs.push(`data-ttl="${ttl}"`);
2129
- }
2130
- }
2131
- return `<script ${attrs.join(" ")}>${safe_payload}<\/script>`;
2132
- }
2133
- //#endregion
2134
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/page/crypto.js
2135
- /**
2136
- * SHA-256 hashing function adapted from https://bitwiseshiftleft.github.io/sjcl
2137
- * modified and redistributed under BSD license
2138
- * @param {string} data
2139
- */
2140
- function sha256(data) {
2141
- if (!key[0]) precompute();
2142
- const out = init.slice(0);
2143
- const array = encode(data);
2144
- for (let i = 0; i < array.length; i += 16) {
2145
- const w = array.subarray(i, i + 16);
2146
- let tmp;
2147
- let a;
2148
- let b;
2149
- let out0 = out[0];
2150
- let out1 = out[1];
2151
- let out2 = out[2];
2152
- let out3 = out[3];
2153
- let out4 = out[4];
2154
- let out5 = out[5];
2155
- let out6 = out[6];
2156
- let out7 = out[7];
2157
- for (let i = 0; i < 64; i++) {
2158
- if (i < 16) tmp = w[i];
2159
- else {
2160
- a = w[i + 1 & 15];
2161
- b = w[i + 14 & 15];
2162
- tmp = w[i & 15] = (a >>> 7 ^ a >>> 18 ^ a >>> 3 ^ a << 25 ^ a << 14) + (b >>> 17 ^ b >>> 19 ^ b >>> 10 ^ b << 15 ^ b << 13) + w[i & 15] + w[i + 9 & 15] | 0;
2163
- }
2164
- tmp = tmp + out7 + (out4 >>> 6 ^ out4 >>> 11 ^ out4 >>> 25 ^ out4 << 26 ^ out4 << 21 ^ out4 << 7) + (out6 ^ out4 & (out5 ^ out6)) + key[i];
2165
- out7 = out6;
2166
- out6 = out5;
2167
- out5 = out4;
2168
- out4 = out3 + tmp | 0;
2169
- out3 = out2;
2170
- out2 = out1;
2171
- out1 = out0;
2172
- out0 = tmp + (out1 & out2 ^ out3 & (out1 ^ out2)) + (out1 >>> 2 ^ out1 >>> 13 ^ out1 >>> 22 ^ out1 << 30 ^ out1 << 19 ^ out1 << 10) | 0;
2173
- }
2174
- out[0] = out[0] + out0 | 0;
2175
- out[1] = out[1] + out1 | 0;
2176
- out[2] = out[2] + out2 | 0;
2177
- out[3] = out[3] + out3 | 0;
2178
- out[4] = out[4] + out4 | 0;
2179
- out[5] = out[5] + out5 | 0;
2180
- out[6] = out[6] + out6 | 0;
2181
- out[7] = out[7] + out7 | 0;
2182
- }
2183
- const bytes = new Uint8Array(out.buffer);
2184
- reverse_endianness(bytes);
2185
- return btoa(String.fromCharCode(...bytes));
2186
- }
2187
- /** The SHA-256 initialization vector */
2188
- var init = new Uint32Array(8);
2189
- /** The SHA-256 hash key */
2190
- var key = new Uint32Array(64);
2191
- /** Function to precompute init and key. */
2192
- function precompute() {
2193
- /** @param {number} x */
2194
- function frac(x) {
2195
- return (x - Math.floor(x)) * 4294967296;
2196
- }
2197
- let prime = 2;
2198
- for (let i = 0; i < 64; prime++) {
2199
- let is_prime = true;
2200
- for (let factor = 2; factor * factor <= prime; factor++) if (prime % factor === 0) {
2201
- is_prime = false;
2202
- break;
2203
- }
2204
- if (is_prime) {
2205
- if (i < 8) init[i] = frac(prime ** (1 / 2));
2206
- key[i] = frac(prime ** (1 / 3));
2207
- i++;
2208
- }
2209
- }
2210
- }
2211
- /** @param {Uint8Array} bytes */
2212
- function reverse_endianness(bytes) {
2213
- for (let i = 0; i < bytes.length; i += 4) {
2214
- const a = bytes[i + 0];
2215
- const b = bytes[i + 1];
2216
- const c = bytes[i + 2];
2217
- const d = bytes[i + 3];
2218
- bytes[i + 0] = d;
2219
- bytes[i + 1] = c;
2220
- bytes[i + 2] = b;
2221
- bytes[i + 3] = a;
2222
- }
2223
- }
2224
- /** @param {string} str */
2225
- function encode(str) {
2226
- const encoded = text_encoder$1.encode(str);
2227
- const length = encoded.length * 8;
2228
- const size = 512 * Math.ceil((length + 65) / 512);
2229
- const bytes = new Uint8Array(size / 8);
2230
- bytes.set(encoded);
2231
- bytes[encoded.length] = 128;
2232
- reverse_endianness(bytes);
2233
- const words = new Uint32Array(bytes.buffer);
2234
- words[words.length - 2] = Math.floor(length / 4294967296);
2235
- words[words.length - 1] = length;
2236
- return words;
2237
- }
2238
- //#endregion
2239
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/page/csp.js
2240
- var array = new Uint8Array(16);
2241
- function generate_nonce() {
2242
- crypto.getRandomValues(array);
2243
- return btoa(String.fromCharCode(...array));
2244
- }
2245
- var quoted = new Set([
2246
- "self",
2247
- "unsafe-eval",
2248
- "unsafe-hashes",
2249
- "unsafe-inline",
2250
- "none",
2251
- "strict-dynamic",
2252
- "report-sample",
2253
- "wasm-unsafe-eval",
2254
- "script"
2255
- ]);
2256
- var crypto_pattern = /^(nonce|sha\d\d\d)-/;
2257
- var BaseProvider = class {
2258
- /** @type {boolean} */
2259
- #use_hashes;
2260
- /** @type {boolean} */
2261
- #script_needs_csp;
2262
- /** @type {boolean} */
2263
- #script_src_needs_csp;
2264
- /** @type {boolean} */
2265
- #script_src_elem_needs_csp;
2266
- /** @type {boolean} */
2267
- #style_needs_csp;
2268
- /** @type {boolean} */
2269
- #style_src_needs_csp;
2270
- /** @type {boolean} */
2271
- #style_src_attr_needs_csp;
2272
- /** @type {boolean} */
2273
- #style_src_elem_needs_csp;
2274
- /** @type {import('types').CspDirectives} */
2275
- #directives;
2276
- /** @type {Set<import('types').Csp.Source>} */
2277
- #script_src;
2278
- /** @type {Set<import('types').Csp.Source>} */
2279
- #script_src_elem;
2280
- /** @type {Set<import('types').Csp.Source>} */
2281
- #style_src;
2282
- /** @type {Set<import('types').Csp.Source>} */
2283
- #style_src_attr;
2284
- /** @type {Set<import('types').Csp.Source>} */
2285
- #style_src_elem;
2286
- /** @type {boolean} */
2287
- script_needs_nonce;
2288
- /** @type {boolean} */
2289
- style_needs_nonce;
2290
- /** @type {boolean} */
2291
- script_needs_hash;
2292
- /** @type {string} */
2293
- #nonce;
2294
- /**
2295
- * @param {boolean} use_hashes
2296
- * @param {import('types').CspDirectives} directives
2297
- * @param {string} nonce
2298
- */
2299
- constructor(use_hashes, directives, nonce) {
2300
- this.#use_hashes = use_hashes;
2301
- this.#directives = directives;
2302
- const d = this.#directives;
2303
- this.#script_src = /* @__PURE__ */ new Set();
2304
- this.#script_src_elem = /* @__PURE__ */ new Set();
2305
- this.#style_src = /* @__PURE__ */ new Set();
2306
- this.#style_src_attr = /* @__PURE__ */ new Set();
2307
- this.#style_src_elem = /* @__PURE__ */ new Set();
2308
- const effective_script_src = d["script-src"] || d["default-src"];
2309
- const script_src_elem = d["script-src-elem"];
2310
- const effective_style_src = d["style-src"] || d["default-src"];
2311
- const style_src_attr = d["style-src-attr"];
2312
- const style_src_elem = d["style-src-elem"];
2313
- /** @param {(import('types').Csp.Source | import('types').Csp.ActionSource)[] | undefined} directive */
2314
- const style_needs_csp = (directive) => !!directive && !directive.some((value) => value === "unsafe-inline");
2315
- /** @param {(import('types').Csp.Source | import('types').Csp.ActionSource)[] | undefined} directive */
2316
- const script_needs_csp = (directive) => !!directive && (!directive.some((value) => value === "unsafe-inline") || directive.some((value) => value === "strict-dynamic"));
2317
- this.#script_src_needs_csp = script_needs_csp(effective_script_src);
2318
- this.#script_src_elem_needs_csp = script_needs_csp(script_src_elem);
2319
- this.#style_src_needs_csp = style_needs_csp(effective_style_src);
2320
- this.#style_src_attr_needs_csp = style_needs_csp(style_src_attr);
2321
- this.#style_src_elem_needs_csp = style_needs_csp(style_src_elem);
2322
- this.#script_needs_csp = this.#script_src_needs_csp || this.#script_src_elem_needs_csp;
2323
- this.#style_needs_csp = this.#style_src_needs_csp || this.#style_src_attr_needs_csp || this.#style_src_elem_needs_csp;
2324
- this.script_needs_nonce = this.#script_needs_csp && !this.#use_hashes;
2325
- this.style_needs_nonce = this.#style_needs_csp && !this.#use_hashes;
2326
- this.script_needs_hash = this.#script_needs_csp && this.#use_hashes;
2327
- this.#nonce = nonce;
2328
- }
2329
- /** @param {string} content */
2330
- add_script(content) {
2331
- if (!this.#script_needs_csp) return;
2332
- /** @type {`nonce-${string}` | `sha256-${string}`} */
2333
- const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
2334
- if (this.#script_src_needs_csp) this.#script_src.add(source);
2335
- if (this.#script_src_elem_needs_csp) this.#script_src_elem.add(source);
2336
- }
2337
- /** @param {`sha256-${string}`[]} hashes */
2338
- add_script_hashes(hashes) {
2339
- for (const hash of hashes) {
2340
- if (this.#script_src_needs_csp) this.#script_src.add(hash);
2341
- if (this.#script_src_elem_needs_csp) this.#script_src_elem.add(hash);
2342
- }
2343
- }
2344
- /** @param {string} content */
2345
- add_style(content) {
2346
- if (!this.#style_needs_csp) return;
2347
- /** @type {`nonce-${string}` | `sha256-${string}`} */
2348
- const source = this.#use_hashes ? `sha256-${sha256(content)}` : `nonce-${this.#nonce}`;
2349
- if (this.#style_src_needs_csp) this.#style_src.add(source);
2350
- if (this.#style_src_attr_needs_csp) this.#style_src_attr.add(source);
2351
- if (this.#style_src_elem_needs_csp) {
2352
- const sha256_empty_comment_hash = "sha256-9OlNO0DNEeaVzHL4RZwCLsBHA8WBQ8toBp/4F5XV2nc=";
2353
- const d = this.#directives;
2354
- if (d["style-src-elem"] && !d["style-src-elem"].includes(sha256_empty_comment_hash) && !this.#style_src_elem.has(sha256_empty_comment_hash)) this.#style_src_elem.add(sha256_empty_comment_hash);
2355
- if (source !== sha256_empty_comment_hash) this.#style_src_elem.add(source);
2356
- }
2357
- }
2358
- /**
2359
- * @param {boolean} [is_meta]
2360
- */
2361
- get_header(is_meta = false) {
2362
- const header = [];
2363
- const directives = { ...this.#directives };
2364
- if (this.#style_src.size > 0) directives["style-src"] = [...directives["style-src"] || directives["default-src"] || [], ...this.#style_src];
2365
- if (this.#style_src_attr.size > 0) directives["style-src-attr"] = [...directives["style-src-attr"] || [], ...this.#style_src_attr];
2366
- if (this.#style_src_elem.size > 0) directives["style-src-elem"] = [...directives["style-src-elem"] || [], ...this.#style_src_elem];
2367
- if (this.#script_src.size > 0) directives["script-src"] = [...directives["script-src"] || directives["default-src"] || [], ...this.#script_src];
2368
- if (this.#script_src_elem.size > 0) directives["script-src-elem"] = [...directives["script-src-elem"] || [], ...this.#script_src_elem];
2369
- for (const key in directives) {
2370
- if (is_meta && (key === "frame-ancestors" || key === "report-uri" || key === "sandbox")) continue;
2371
- const value = directives[key];
2372
- if (!value) continue;
2373
- const directive = [key];
2374
- if (Array.isArray(value)) value.forEach((value) => {
2375
- if (quoted.has(value) || crypto_pattern.test(value)) directive.push(`'${value}'`);
2376
- else directive.push(value);
2377
- });
2378
- header.push(directive.join(" "));
2379
- }
2380
- return header.join("; ");
2381
- }
2382
- };
2383
- var CspProvider = class extends BaseProvider {
2384
- get_meta() {
2385
- const content = this.get_header(true);
2386
- if (!content) return;
2387
- return `<meta http-equiv="content-security-policy" content="${escape_html(content, true)}">`;
2388
- }
2389
- };
2390
- var CspReportOnlyProvider = class extends BaseProvider {
2391
- /**
2392
- * @param {boolean} use_hashes
2393
- * @param {import('types').CspDirectives} directives
2394
- * @param {string} nonce
2395
- */
2396
- constructor(use_hashes, directives, nonce) {
2397
- super(use_hashes, directives, nonce);
2398
- if (Object.values(directives).filter((v) => !!v).length > 0) {
2399
- const has_report_to = directives["report-to"]?.length ?? false;
2400
- const has_report_uri = directives["report-uri"]?.length ?? false;
2401
- if (!has_report_to && !has_report_uri) throw Error("`content-security-policy-report-only` must be specified with either the `report-to` or `report-uri` directives, or both");
2402
- }
2403
- }
2404
- };
2405
- var Csp = class {
2406
- /** @readonly */
2407
- nonce = generate_nonce();
2408
- /** @type {CspProvider} */
2409
- csp_provider;
2410
- /** @type {CspReportOnlyProvider} */
2411
- report_only_provider;
2412
- /**
2413
- * @param {import('./types.js').CspConfig} config
2414
- * @param {import('./types.js').CspOpts} opts
2415
- */
2416
- constructor({ mode, directives, reportOnly }, { prerender }) {
2417
- const use_hashes = mode === "hash" || mode === "auto" && prerender;
2418
- this.csp_provider = new CspProvider(use_hashes, directives, this.nonce);
2419
- this.report_only_provider = new CspReportOnlyProvider(use_hashes, reportOnly, this.nonce);
2420
- }
2421
- get script_needs_hash() {
2422
- return this.csp_provider.script_needs_hash || this.report_only_provider.script_needs_hash;
2423
- }
2424
- get script_needs_nonce() {
2425
- return this.csp_provider.script_needs_nonce || this.report_only_provider.script_needs_nonce;
2426
- }
2427
- get style_needs_nonce() {
2428
- return this.csp_provider.style_needs_nonce || this.report_only_provider.style_needs_nonce;
2429
- }
2430
- /** @param {string} content */
2431
- add_script(content) {
2432
- this.csp_provider.add_script(content);
2433
- this.report_only_provider.add_script(content);
2434
- }
2435
- /** @param {`sha256-${string}`[]} hashes */
2436
- add_script_hashes(hashes) {
2437
- this.csp_provider.add_script_hashes(hashes);
2438
- this.report_only_provider.add_script_hashes(hashes);
2439
- }
2440
- /** @param {string} content */
2441
- add_style(content) {
2442
- this.csp_provider.add_style(content);
2443
- this.report_only_provider.add_style(content);
2444
- }
2445
- };
2446
- //#endregion
2447
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/page/server_routing.js
2448
- /**
2449
- * @param {import('types').SSRClientRoute} route
2450
- * @param {URL} url
2451
- * @param {import('@sveltejs/kit').SSRManifest} manifest
2452
- * @returns {string}
2453
- */
2454
- function generate_route_object(route, url, manifest) {
2455
- const { errors, layouts, leaf } = route;
2456
- const nodes = [
2457
- ...errors,
2458
- ...layouts.map((l) => l?.[1]),
2459
- leaf[1]
2460
- ].filter((n) => typeof n === "number").map((n) => `'${n}': () => ${create_client_import(manifest._.client.nodes?.[n], url)}`).join(",\n ");
2461
- /** @type {import('types').CSRRouteServer} */
2462
- return [
2463
- `{\n\tid: ${s(route.id)}`,
2464
- `errors: ${s(route.errors)}`,
2465
- `layouts: ${s(route.layouts)}`,
2466
- `leaf: ${s(route.leaf)}`,
2467
- `nodes: {\n\t\t${nodes}\n\t}\n}`
2468
- ].join(",\n ");
2469
- }
2470
- /**
2471
- * @param {string | undefined} import_path
2472
- * @param {URL} url
2473
- */
2474
- function create_client_import(import_path, url) {
2475
- if (!import_path) return "Promise.resolve({})";
2476
- if (import_path[0] === "/") return `import('${import_path}')`;
2477
- if (assets !== "") return `import('${assets}/${import_path}')`;
2478
- let path = get_relative_path(url.pathname, `${base}/${import_path}`);
2479
- if (path[0] !== ".") path = `./${path}`;
2480
- return `import('${path}')`;
2481
- }
2482
- /**
2483
- * @param {string} resolved_path
2484
- * @param {URL} url
2485
- * @param {import('@sveltejs/kit').SSRManifest} manifest
2486
- * @returns {Promise<Response>}
2487
- */
2488
- async function resolve_route(resolved_path, url, manifest) {
2489
- if (!manifest._.client.routes) return text("Server-side route resolution disabled", { status: 400 });
2490
- const matchers = await manifest._.matchers();
2491
- const result = find_route(resolved_path, manifest._.client.routes, matchers);
2492
- return create_server_routing_response(result?.route ?? null, result?.params ?? {}, url, manifest).response;
2493
- }
2494
- /**
2495
- * @param {import('types').SSRClientRoute | null} route
2496
- * @param {Partial<Record<string, string>>} params
2497
- * @param {URL} url
2498
- * @param {import('@sveltejs/kit').SSRManifest} manifest
2499
- * @returns {{response: Response, body: string}}
2500
- */
2501
- function create_server_routing_response(route, params, url, manifest) {
2502
- const headers = new Headers({ "content-type": "application/javascript; charset=utf-8" });
2503
- if (route) {
2504
- const csr_route = generate_route_object(route, url, manifest);
2505
- const body = `${create_css_import(route, url, manifest)}\nexport const route = ${csr_route}; export const params = ${JSON.stringify(params)};`;
2506
- return {
2507
- response: text(body, { headers }),
2508
- body
2509
- };
2510
- } else return {
2511
- response: text("", { headers }),
2512
- body: ""
2513
- };
2514
- }
2515
- /**
2516
- * This function generates the client-side import for the CSS files that are
2517
- * associated with the current route. Vite takes care of that when using
2518
- * client-side route resolution, but for server-side resolution it does
2519
- * not know about the CSS files automatically.
2520
- *
2521
- * @param {import('types').SSRClientRoute} route
2522
- * @param {URL} url
2523
- * @param {import('@sveltejs/kit').SSRManifest} manifest
2524
- * @returns {string}
2525
- */
2526
- function create_css_import(route, url, manifest) {
2527
- const { errors, layouts, leaf } = route;
2528
- let css = "";
2529
- for (const node of [
2530
- ...errors,
2531
- ...layouts.map((l) => l?.[1]),
2532
- leaf[1]
2533
- ]) {
2534
- if (typeof node !== "number") continue;
2535
- const node_css = manifest._.client.css?.[node];
2536
- for (const css_path of node_css ?? []) css += `'${assets || base}/${css_path}',`;
2537
- }
2538
- if (!css) return "";
2539
- return `${create_client_import(manifest._.client.start, url)}.then(x => x.load_css([${css}]));`;
2540
- }
2541
- //#endregion
2542
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/page/render.js
2543
- var updated = {
2544
- ...readable(false),
2545
- check: () => false
2546
- };
2547
- /**
2548
- * Creates the HTML response.
2549
- * @param {{
2550
- * branch: Array<import('./types.js').Loaded>;
2551
- * fetched: Array<import('./types.js').Fetched>;
2552
- * options: import('types').SSROptions;
2553
- * manifest: import('@sveltejs/kit').SSRManifest;
2554
- * state: import('types').SSRState;
2555
- * page_config: { ssr: boolean; csr: boolean };
2556
- * status: number;
2557
- * error: App.Error | null;
2558
- * event: import('@sveltejs/kit').RequestEvent;
2559
- * event_state: import('types').RequestState;
2560
- * resolve_opts: import('types').RequiredResolveOptions;
2561
- * action_result?: import('@sveltejs/kit').ActionResult;
2562
- * data_serializer: import('./types.js').ServerDataSerializer;
2563
- * error_components?: Array<import('types').SSRComponent | undefined>
2564
- * }} opts
2565
- */
2566
- async function render_response({ branch, fetched, options, manifest, state, page_config, status, error = null, event, event_state, resolve_opts, action_result, data_serializer, error_components }) {
2567
- if (state.prerendering) {
2568
- if (options.csp.mode === "nonce") throw new Error("Cannot use prerendering if config.kit.csp.mode === \"nonce\"");
2569
- if (options.app_template_contains_nonce) throw new Error("Cannot use prerendering if page template contains %sveltekit.nonce%");
2570
- }
2571
- const { client } = manifest._;
2572
- const modulepreloads = new Set(client.imports);
2573
- const stylesheets = new Set(client.stylesheets);
2574
- const fonts = new Set(client.fonts);
2575
- /**
2576
- * The value of the Link header that is added to the response when not prerendering
2577
- * @type {Set<string>}
2578
- */
2579
- const link_headers = /* @__PURE__ */ new Set();
2580
- /** @type {Map<string, string>} */
2581
- const inline_styles = /* @__PURE__ */ new Map();
2582
- /** @type {ReturnType<typeof options.root.render>} */
2583
- let rendered;
2584
- const form_value = action_result?.type === "success" || action_result?.type === "failure" ? action_result.data ?? null : null;
2585
- /** @type {string} */
2586
- let base$1 = base;
2587
- /** @type {string} */
2588
- let assets$1 = assets;
2589
- /**
2590
- * An expression that will evaluate in the client to determine the resolved base path.
2591
- * We use a relative path when possible to support IPFS, the internet archive, etc.
2592
- */
2593
- let base_expression = s(base);
2594
- const csp = new Csp(options.csp, { prerender: !!state.prerendering });
2595
- if (!state.prerendering?.fallback) {
2596
- base$1 = event.url.pathname.slice(base.length).split("/").slice(2).map(() => "..").join("/") || ".";
2597
- base_expression = `new URL(${s(base$1)}, location).pathname.slice(0, -1)`;
2598
- if (!assets || assets[0] === "/" && assets !== "/_svelte_kit_assets") assets$1 = base$1;
2599
- } else if (options.hash_routing) base_expression = "new URL('.', location).pathname.slice(0, -1)";
2600
- if (page_config.ssr) {
2601
- /** @type {Record<string, any>} */
2602
- const props = {
2603
- stores: {
2604
- page: writable(null),
2605
- navigating: writable(null),
2606
- updated
2607
- },
2608
- constructors: await Promise.all(branch.map(({ node }) => {
2609
- if (!node.component) throw new Error(`Missing +page.svelte component for route ${event.route.id}`);
2610
- return node.component();
2611
- })),
2612
- form: form_value
2613
- };
2614
- if (error_components) {
2615
- if (error) props.error = error;
2616
- props.errors = error_components;
2617
- }
2618
- let data = {};
2619
- for (let i = 0; i < branch.length; i += 1) {
2620
- data = {
2621
- ...data,
2622
- ...branch[i].data
2623
- };
2624
- props[`data_${i}`] = data;
2625
- }
2626
- props.page = {
2627
- error,
2628
- params: event.params,
2629
- route: event.route,
2630
- status,
2631
- url: event.url,
2632
- data,
2633
- form: form_value,
2634
- state: {}
2635
- };
2636
- const render_opts = {
2637
- context: new Map([["__request__", { page: props.page }]]),
2638
- csp: csp.script_needs_nonce ? { nonce: csp.nonce } : { hash: csp.script_needs_hash },
2639
- transformError: error_components ? async (e) => {
2640
- if (isRedirect(e)) throw e;
2641
- const transformed = await handle_error_and_jsonify(event, event_state, options, e);
2642
- props.page.error = props.error = error = transformed;
2643
- props.page.status = status = get_status(e);
2644
- return transformed;
2645
- } : void 0
2646
- };
2647
- try {
2648
- rendered = await with_request_store({
2649
- event,
2650
- state: {
2651
- ...event_state,
2652
- is_in_render: true
2653
- }
2654
- }, async () => {
2655
- override({
2656
- base: base$1,
2657
- assets: assets$1
2658
- });
2659
- const maybe_promise = options.root.render(props, render_opts);
2660
- const rendered = options.async && "then" in maybe_promise ? maybe_promise.then((r) => r) : maybe_promise;
2661
- if (options.async) reset();
2662
- const { head, html, css, hashes } = options.async ? await rendered : rendered;
2663
- if (hashes) csp.add_script_hashes(hashes.script);
2664
- return {
2665
- head,
2666
- html,
2667
- css,
2668
- hashes
2669
- };
2670
- });
2671
- } finally {
2672
- reset();
2673
- }
2674
- } else rendered = {
2675
- head: "",
2676
- html: "",
2677
- css: {
2678
- code: "",
2679
- map: null
2680
- },
2681
- hashes: { script: [] }
2682
- };
2683
- for (const { node } of branch) {
2684
- for (const url of node.imports) modulepreloads.add(url);
2685
- for (const url of node.stylesheets) stylesheets.add(url);
2686
- for (const url of node.fonts) fonts.add(url);
2687
- if (node.inline_styles && !client.inline) Object.entries(await node.inline_styles()).forEach(([filename, css]) => {
2688
- if (typeof css === "string") {
2689
- inline_styles.set(filename, css);
2690
- return;
2691
- }
2692
- inline_styles.set(filename, css(`${assets$1}/${app_dir}/immutable/assets`, assets$1));
2693
- });
2694
- }
2695
- const head = new Head(rendered.head, !!state.prerendering);
2696
- let body = rendered.html;
2697
- /** @param {string} path */
2698
- const prefixed = (path) => {
2699
- if (path.startsWith("/")) return base + path;
2700
- return `${assets$1}/${path}`;
2701
- };
2702
- const style = client.inline ? client.inline?.style : Array.from(inline_styles.values()).join("\n");
2703
- if (style) {
2704
- const attributes = [];
2705
- if (csp.style_needs_nonce) attributes.push(`nonce="${csp.nonce}"`);
2706
- csp.add_style(style);
2707
- head.add_style(style, attributes);
2708
- }
2709
- for (const dep of stylesheets) {
2710
- const path = prefixed(dep);
2711
- const attributes = ["rel=\"stylesheet\""];
2712
- if (inline_styles.has(dep)) attributes.push("disabled", "media=\"(max-width: 0)\"");
2713
- else if (resolve_opts.preload({
2714
- type: "css",
2715
- path
2716
- })) link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="style"; nopush`);
2717
- head.add_stylesheet(path, attributes);
2718
- }
2719
- for (const dep of fonts) {
2720
- const path = prefixed(dep);
2721
- if (resolve_opts.preload({
2722
- type: "font",
2723
- path
2724
- })) {
2725
- const ext = dep.slice(dep.lastIndexOf(".") + 1);
2726
- head.add_link_tag(path, [
2727
- "rel=\"preload\"",
2728
- "as=\"font\"",
2729
- `type="font/${ext}"`,
2730
- "crossorigin"
2731
- ]);
2732
- link_headers.add(`<${encodeURI(path)}>; rel="preload"; as="font"; type="font/${ext}"; crossorigin; nopush`);
2733
- }
2734
- }
2735
- const global = get_global_name(options);
2736
- const { data, chunks } = data_serializer.get_data(csp);
2737
- if (page_config.ssr && page_config.csr) body += `\n\t\t\t${fetched.map((item) => serialize_data(item, resolve_opts.filterSerializedResponseHeaders, !!state.prerendering)).join("\n ")}`;
2738
- if (page_config.csr) {
2739
- const route = manifest._.client.routes?.find((r) => r.id === event.route.id) ?? null;
2740
- if (client.uses_env_dynamic_public && state.prerendering) modulepreloads.add(`${app_dir}/env.js`);
2741
- if (!client.inline) {
2742
- const included_modulepreloads = Array.from(modulepreloads, (dep) => prefixed(dep)).filter((path) => resolve_opts.preload({
2743
- type: "js",
2744
- path
2745
- }));
2746
- for (const path of included_modulepreloads) {
2747
- link_headers.add(`<${encodeURI(path)}>; rel="modulepreload"; nopush`);
2748
- if (options.preload_strategy !== "modulepreload") head.add_script_preload(path);
2749
- else head.add_link_tag(path, ["rel=\"modulepreload\""]);
2750
- }
2751
- }
2752
- if (manifest._.client.routes && state.prerendering && !state.prerendering.fallback) {
2753
- const pathname = add_resolution_suffix(event.url.pathname);
2754
- state.prerendering.dependencies.set(pathname, create_server_routing_response(route, event.params, new URL(pathname, event.url), manifest));
2755
- }
2756
- const blocks = [];
2757
- const load_env_eagerly = client.uses_env_dynamic_public && state.prerendering;
2758
- const properties = [`base: ${base_expression}`];
2759
- if (assets) properties.push(`assets: ${s(assets)}`);
2760
- if (client.uses_env_dynamic_public) properties.push(`env: ${load_env_eagerly ? "null" : s(public_env)}`);
2761
- if (chunks) {
2762
- blocks.push("const deferred = new Map();");
2763
- properties.push(`defer: (id) => new Promise((fulfil, reject) => {
2764
- deferred.set(id, { fulfil, reject });
2765
- })`);
2766
- let app_declaration = "";
2767
- if (Object.keys(options.hooks.transport).length > 0) if (client.inline) app_declaration = `const app = __sveltekit_${options.version_hash}.app.app;`;
2768
- else if (client.app) app_declaration = `const app = await import(${s(prefixed(client.app))});`;
2769
- else app_declaration = `const { app } = await import(${s(prefixed(client.start))});`;
2770
- const prelude = app_declaration ? `${app_declaration}
2771
- const [data, error] = fn(app);` : `const [data, error] = fn();`;
2772
- properties.push(`resolve: async (id, fn) => {
2773
- ${prelude}
2774
-
2775
- const try_to_resolve = () => {
2776
- if (!deferred.has(id)) {
2777
- setTimeout(try_to_resolve, 0);
2778
- return;
2779
- }
2780
- const { fulfil, reject } = deferred.get(id);
2781
- deferred.delete(id);
2782
- if (error) reject(error);
2783
- else fulfil(data);
2784
- }
2785
- try_to_resolve();
2786
- }`);
2787
- }
2788
- blocks.push(`${global} = {
2789
- ${properties.join(",\n ")}
2790
- };`);
2791
- const args = ["element"];
2792
- blocks.push("const element = document.currentScript.parentElement;");
2793
- if (page_config.ssr) {
2794
- const serialized = {
2795
- form: "null",
2796
- error: "null"
2797
- };
2798
- if (form_value) serialized.form = uneval_action_response(form_value, event.route.id, options.hooks.transport);
2799
- if (error) serialized.error = uneval(error);
2800
- const hydrate = [
2801
- `node_ids: [${branch.map(({ node }) => node.index).join(", ")}]`,
2802
- `data: ${data}`,
2803
- `form: ${serialized.form}`,
2804
- `error: ${serialized.error}`
2805
- ];
2806
- if (status !== 200) hydrate.push(`status: ${status}`);
2807
- if (manifest._.client.routes) {
2808
- if (route) {
2809
- const stringified = generate_route_object(route, event.url, manifest).replaceAll("\n", "\n ");
2810
- hydrate.push(`params: ${uneval(event.params)}`, `server_route: ${stringified}`);
2811
- }
2812
- } else if (options.embedded) hydrate.push(`params: ${uneval(event.params)}`, `route: ${s(event.route)}`);
2813
- const indent = " ".repeat(load_env_eagerly ? 7 : 6);
2814
- args.push(`{\n${indent}\t${hydrate.join(`,\n${indent}\t`)}\n${indent}}`);
2815
- }
2816
- const { remote } = event_state;
2817
- let serialized_query_data = "";
2818
- let serialized_prerender_data = "";
2819
- if (remote.data) {
2820
- /** @type {Record<string, any>} */
2821
- const query = {};
2822
- /** @type {Record<string, any>} */
2823
- const prerender = {};
2824
- for (const [internals, cache] of remote.data) {
2825
- if (!internals.id) continue;
2826
- for (const key in cache) {
2827
- const entry = cache[key];
2828
- if (!entry.serialize) continue;
2829
- const remote_key = create_remote_key(internals.id, key);
2830
- const store = internals.type === "prerender" ? prerender : query;
2831
- if (event_state.remote.refreshes?.has(remote_key) || event_state.remote.reconnects?.has(remote_key)) store[remote_key] = await entry.data;
2832
- else {
2833
- const result = await Promise.race([Promise.resolve(entry.data).then((v) => ({
2834
- settled: true,
2835
- value: v
2836
- }), (e) => ({
2837
- settled: true,
2838
- error: e
2839
- })), new Promise((resolve) => {
2840
- queueMicrotask(() => resolve({ settled: false }));
2841
- })]);
2842
- if (result.settled) {
2843
- if ("error" in result) throw result.error;
2844
- store[remote_key] = result.value;
2845
- }
2846
- }
2847
- }
2848
- }
2849
- const replacer = (thing) => {
2850
- for (const key in options.hooks.transport) {
2851
- const encoded = options.hooks.transport[key].encode(thing);
2852
- if (encoded) return `app.decode('${key}', ${uneval(encoded, replacer)})`;
2853
- }
2854
- };
2855
- if (Object.keys(query).length > 0) serialized_query_data = `${global}.query = ${uneval(query, replacer)};\n\n\t\t\t\t\t\t`;
2856
- if (Object.keys(prerender).length > 0) serialized_prerender_data = `${global}.prerender = ${uneval(prerender, replacer)};\n\n\t\t\t\t\t\t`;
2857
- }
2858
- const serialized_remote_data = `${serialized_query_data}${serialized_prerender_data}`;
2859
- const boot = client.inline ? `${client.inline.script}
2860
-
2861
- ${serialized_remote_data}${global}.app.start(${args.join(", ")});` : client.app ? `Promise.all([
2862
- import(${s(prefixed(client.start))}),
2863
- import(${s(prefixed(client.app))})
2864
- ]).then(([kit, app]) => {
2865
- ${serialized_remote_data}kit.start(app, ${args.join(", ")});
2866
- });` : `import(${s(prefixed(client.start))}).then((app) => {
2867
- ${serialized_remote_data}app.start(${args.join(", ")})
2868
- });`;
2869
- if (load_env_eagerly) blocks.push(`import(${s(`${base$1}/${app_dir}/env.js`)}).then(({ env }) => {
2870
- ${global}.env = env;
2871
-
2872
- ${boot.replace(/\n/g, "\n ")}
2873
- });`);
2874
- else blocks.push(boot);
2875
- if (options.service_worker) {
2876
- let opts = "";
2877
- if (options.service_worker_options != null) opts = `, ${s({ ...options.service_worker_options })}`;
2878
- blocks.push(`if ('serviceWorker' in navigator) {
2879
- const script_url = '${prefixed("service-worker.js")}';
2880
- const policy = globalThis?.window?.trustedTypes?.createPolicy(
2881
- 'sveltekit-trusted-url',
2882
- { createScriptURL(url) { return url; } }
2883
- );
2884
- const sanitised = policy?.createScriptURL(script_url) ?? script_url;
2885
- addEventListener('load', function () {
2886
- navigator.serviceWorker.register(sanitised${opts});
2887
- });
2888
- }`);
2889
- }
2890
- const init_app = `
2891
- {
2892
- ${blocks.join("\n\n ")}
2893
- }
2894
- `;
2895
- csp.add_script(init_app);
2896
- body += `\n\t\t\t<script${csp.script_needs_nonce ? ` nonce="${csp.nonce}"` : ""}>${init_app}<\/script>\n\t\t`;
2897
- }
2898
- const headers = new Headers({
2899
- "x-sveltekit-page": "true",
2900
- "content-type": "text/html"
2901
- });
2902
- if (state.prerendering) {
2903
- const csp_headers = csp.csp_provider.get_meta();
2904
- if (csp_headers) head.add_http_equiv(csp_headers);
2905
- if (state.prerendering.cache) head.add_http_equiv(`<meta http-equiv="cache-control" content="${state.prerendering.cache}">`);
2906
- } else {
2907
- const csp_header = csp.csp_provider.get_header();
2908
- if (csp_header) headers.set("content-security-policy", csp_header);
2909
- const report_only_header = csp.report_only_provider.get_header();
2910
- if (report_only_header) headers.set("content-security-policy-report-only", report_only_header);
2911
- if (link_headers.size) headers.set("link", Array.from(link_headers).join(", "));
2912
- }
2913
- const html = options.templates.app({
2914
- head: head.build(),
2915
- body,
2916
- assets: assets$1,
2917
- nonce: csp.nonce,
2918
- env: public_env
2919
- });
2920
- const transformed = await resolve_opts.transformPageChunk({
2921
- html,
2922
- done: true
2923
- }) || "";
2924
- if (!chunks) headers.set("etag", `"${hash(transformed)}"`);
2925
- return !chunks ? text(transformed, {
2926
- status,
2927
- headers
2928
- }) : new Response(new ReadableStream({
2929
- async start(controller) {
2930
- controller.enqueue(text_encoder$1.encode(transformed + "\n"));
2931
- for await (const chunk of chunks) if (chunk.length) controller.enqueue(text_encoder$1.encode(chunk));
2932
- controller.close();
2933
- },
2934
- type: "bytes"
2935
- }), { headers });
2936
- }
2937
- var Head = class {
2938
- #rendered;
2939
- #prerendering;
2940
- /** @type {string[]} */
2941
- #http_equiv = [];
2942
- /** @type {string[]} */
2943
- #link_tags = [];
2944
- /** @type {string[]} */
2945
- #script_preloads = [];
2946
- /** @type {string[]} */
2947
- #style_tags = [];
2948
- /** @type {string[]} */
2949
- #stylesheet_links = [];
2950
- /**
2951
- * @param {string} rendered
2952
- * @param {boolean} prerendering
2953
- */
2954
- constructor(rendered, prerendering) {
2955
- this.#rendered = rendered;
2956
- this.#prerendering = prerendering;
2957
- }
2958
- build() {
2959
- return [
2960
- ...this.#http_equiv,
2961
- ...this.#link_tags,
2962
- ...this.#script_preloads,
2963
- this.#rendered,
2964
- ...this.#style_tags,
2965
- ...this.#stylesheet_links
2966
- ].join("\n ");
2967
- }
2968
- /**
2969
- * @param {string} style
2970
- * @param {string[]} attributes
2971
- */
2972
- add_style(style, attributes) {
2973
- this.#style_tags.push(`<style${attributes.length ? " " + attributes.join(" ") : ""}>${style}</style>`);
2974
- }
2975
- /**
2976
- * @param {string} href
2977
- * @param {string[]} attributes
2978
- */
2979
- add_stylesheet(href, attributes) {
2980
- this.#stylesheet_links.push(`<link href="${href}" ${attributes.join(" ")}>`);
2981
- }
2982
- /** @param {string} href */
2983
- add_script_preload(href) {
2984
- this.#script_preloads.push(`<link rel="preload" as="script" crossorigin="anonymous" href="${href}">`);
2985
- }
2986
- /**
2987
- * @param {string} href
2988
- * @param {string[]} attributes
2989
- */
2990
- add_link_tag(href, attributes) {
2991
- if (!this.#prerendering) return;
2992
- this.#link_tags.push(`<link href="${href}" ${attributes.join(" ")}>`);
2993
- }
2994
- /** @param {string} tag */
2995
- add_http_equiv(tag) {
2996
- if (!this.#prerendering) return;
2997
- this.#http_equiv.push(tag);
2998
- }
2999
- };
3000
- //#endregion
3001
- //#region ../../node_modules/@sveltejs/kit/src/utils/page_nodes.js
3002
- var PageNodes = class {
3003
- /** All layout nodes and the page node, if any */
3004
- data;
3005
- /**
3006
- * @param {Array<import('types').SSRNode | undefined>} nodes
3007
- */
3008
- constructor(nodes) {
3009
- this.data = nodes;
3010
- }
3011
- layouts() {
3012
- return this.data.slice(0, -1);
3013
- }
3014
- page() {
3015
- return this.data.at(-1);
3016
- }
3017
- validate() {
3018
- for (const layout of this.layouts()) if (layout) {
3019
- validate_layout_server_exports(layout.server, layout.server_id);
3020
- validate_layout_exports(layout.universal, layout.universal_id);
3021
- }
3022
- const page = this.page();
3023
- if (page) {
3024
- validate_page_server_exports(page.server, page.server_id);
3025
- validate_page_exports(page.universal, page.universal_id);
3026
- }
3027
- }
3028
- /**
3029
- * @template {'prerender' | 'ssr' | 'csr' | 'trailingSlash'} Option
3030
- * @param {Option} option
3031
- * @returns {Value | undefined}
3032
- */
3033
- #get_option(option) {
3034
- /** @typedef {(import('types').UniversalNode | import('types').ServerNode)[Option]} Value */
3035
- return this.data.reduce((value, node) => {
3036
- return node?.universal?.[option] ?? node?.server?.[option] ?? value;
3037
- }, void 0);
3038
- }
3039
- csr() {
3040
- return this.#get_option("csr") ?? true;
3041
- }
3042
- ssr() {
3043
- return this.#get_option("ssr") ?? true;
3044
- }
3045
- prerender() {
3046
- return this.#get_option("prerender") ?? false;
3047
- }
3048
- trailing_slash() {
3049
- return this.#get_option("trailingSlash") ?? "never";
3050
- }
3051
- get_config() {
3052
- /** @type {any} */
3053
- let current = {};
3054
- for (const node of this.data) {
3055
- if (!node?.universal?.config && !node?.server?.config) continue;
3056
- current = {
3057
- ...current,
3058
- ...node?.universal?.config,
3059
- ...node?.server?.config
3060
- };
3061
- }
3062
- return Object.keys(current).length ? current : void 0;
3063
- }
3064
- should_prerender_data() {
3065
- return this.data.some((node) => node?.server?.load || node?.server?.trailingSlash !== void 0);
3066
- }
3067
- };
3068
- //#endregion
3069
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/page/respond_with_error.js
3070
- /**
3071
- * @typedef {import('./types.js').Loaded} Loaded
3072
- */
3073
- /**
3074
- * @param {{
3075
- * event: import('@sveltejs/kit').RequestEvent;
3076
- * event_state: import('types').RequestState;
3077
- * options: import('types').SSROptions;
3078
- * manifest: import('@sveltejs/kit').SSRManifest;
3079
- * state: import('types').SSRState;
3080
- * status: number;
3081
- * error: unknown;
3082
- * resolve_opts: import('types').RequiredResolveOptions;
3083
- * }} opts
3084
- */
3085
- async function respond_with_error({ event, event_state, options, manifest, state, status, error, resolve_opts }) {
3086
- if (event.request.headers.get("x-sveltekit-error")) return static_error_page(
3087
- options,
3088
- status,
3089
- /** @type {Error} */
3090
- error.message
3091
- );
3092
- /** @type {import('./types.js').Fetched[]} */
3093
- const fetched = [];
3094
- try {
3095
- const branch = [];
3096
- const default_layout = await manifest._.nodes[0]();
3097
- const nodes = new PageNodes([default_layout]);
3098
- const ssr = nodes.ssr();
3099
- const csr = nodes.csr();
3100
- const data_serializer = server_data_serializer(event, event_state, options);
3101
- if (ssr) {
3102
- state.error = true;
3103
- const server_data_promise = load_server_data({
3104
- event,
3105
- event_state,
3106
- state,
3107
- node: default_layout,
3108
- parent: async () => ({})
3109
- });
3110
- const server_data = await server_data_promise;
3111
- data_serializer.add_node(0, server_data);
3112
- const data = await load_data({
3113
- event,
3114
- event_state,
3115
- fetched,
3116
- node: default_layout,
3117
- parent: async () => ({}),
3118
- resolve_opts,
3119
- server_data_promise,
3120
- state,
3121
- csr
3122
- });
3123
- branch.push({
3124
- node: default_layout,
3125
- server_data,
3126
- data
3127
- }, {
3128
- node: await manifest._.nodes[1](),
3129
- data: null,
3130
- server_data: null
3131
- });
3132
- }
3133
- return await render_response({
3134
- options,
3135
- manifest,
3136
- state,
3137
- page_config: {
3138
- ssr,
3139
- csr
3140
- },
3141
- status,
3142
- error: await handle_error_and_jsonify(event, event_state, options, error),
3143
- branch,
3144
- error_components: [],
3145
- fetched,
3146
- event,
3147
- event_state,
3148
- resolve_opts,
3149
- data_serializer
3150
- });
3151
- } catch (e) {
3152
- if (e instanceof Redirect) return redirect_response(e.status, e.location);
3153
- return static_error_page(options, get_status(e), (await handle_error_and_jsonify(event, event_state, options, e)).message);
3154
- }
3155
- }
3156
- //#endregion
3157
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/remote.js
3158
- /** @import { ActionResult, RemoteForm, RequestEvent, SSRManifest } from '@sveltejs/kit' */
3159
- /** @import { RemoteFormInternals, RemoteFunctionResponse, RemoteInternals, RequestState, SSROptions } from 'types' */
3160
- /** @type {typeof handle_remote_call_internal} */
3161
- async function handle_remote_call(event, state, options, manifest, id) {
3162
- return record_span({
3163
- name: "sveltekit.remote.call",
3164
- attributes: { },
3165
- fn: (current) => {
3166
- const traced_event = merge_tracing(event, current);
3167
- return with_request_store({
3168
- event: traced_event,
3169
- state
3170
- }, () => handle_remote_call_internal(traced_event, state, options, manifest, id));
3171
- }
3172
- });
3173
- }
3174
- /**
3175
- * @param {RequestEvent} event
3176
- * @param {RequestState} state
3177
- * @param {SSROptions} options
3178
- * @param {SSRManifest} manifest
3179
- * @param {string} id
3180
- */
3181
- async function handle_remote_call_internal(event, state, options, manifest, id) {
3182
- const [hash, name, additional_args] = id.split("/");
3183
- const remotes = manifest._.remotes;
3184
- if (!remotes[hash]) error(404);
3185
- const fn = (await remotes[hash]()).default[name];
3186
- if (!fn) error(404);
3187
- /** @type {RemoteInternals} */
3188
- const internals = fn.__;
3189
- const transport = options.hooks.transport;
3190
- event.tracing.current.setAttributes({
3191
- "sveltekit.remote.call.type": internals.type,
3192
- "sveltekit.remote.call.name": internals.name
3193
- });
3194
- try {
3195
- if (internals.type === "query_batch") {
3196
- if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`query.batch\` functions must be invoked via POST request, not ${event.request.method}`);
3197
- /** @type {{ payloads: string[] }} */
3198
- const { payloads } = await event.request.json();
3199
- const args = await Promise.all(payloads.map((payload) => parse_remote_arg(payload, transport)));
3200
- return json({
3201
- type: "result",
3202
- result: stringify(await with_request_store({
3203
- event,
3204
- state
3205
- }, () => internals.run(args, options)), transport)
3206
- });
3207
- }
3208
- if (internals.type === "form") {
3209
- if (event.request.method !== "POST") throw new SvelteKitError(405, "Method Not Allowed", `\`form\` functions must be invoked via POST request, not ${event.request.method}`);
3210
- if (!is_form_content_type(event.request)) throw new SvelteKitError(415, "Unsupported Media Type", `\`form\` functions expect form-encoded data — received ${event.request.headers.get("content-type")}`);
3211
- const { data, meta, form_data } = await deserialize_binary_form(event.request);
3212
- state.remote.requested = create_requested_map(meta.remote_refreshes);
3213
- if (additional_args && !("id" in data)) data.id = JSON.parse(decodeURIComponent(additional_args));
3214
- const fn = internals.fn;
3215
- const result = await with_request_store({
3216
- event,
3217
- state
3218
- }, () => fn(data, meta, form_data));
3219
- return json({
3220
- type: "result",
3221
- result: stringify(result, transport),
3222
- refreshes: result.issues ? void 0 : await serialize_singleflight(state.remote.refreshes),
3223
- reconnects: result.issues ? void 0 : await serialize_singleflight(state.remote.reconnects)
3224
- });
3225
- }
3226
- if (internals.type === "command") {
3227
- /** @type {{ payload: string, refreshes?: string[] }} */
3228
- const { payload, refreshes } = await event.request.json();
3229
- state.remote.requested = create_requested_map(refreshes);
3230
- const arg = parse_remote_arg(payload, transport);
3231
- return json({
3232
- type: "result",
3233
- result: stringify(await with_request_store({
3234
- event,
3235
- state
3236
- }, () => fn(arg)), transport),
3237
- refreshes: await serialize_singleflight(state.remote.refreshes),
3238
- reconnects: await serialize_singleflight(state.remote.reconnects)
3239
- });
3240
- }
3241
- if (internals.type === "query_live") {
3242
- if (event.request.method !== "GET") throw new SvelteKitError(405, "Method Not Allowed", `\`query.live\` functions must be invoked via GET request, not ${event.request.method}`);
3243
- const payload = new URL(event.request.url).searchParams.get("payload");
3244
- const generator = internals.run(event, state, parse_remote_arg(payload, transport));
3245
- const encoder = new TextEncoder();
3246
- /**
3247
- * @param {ReadableStreamDefaultController} controller
3248
- * @param {any} payload
3249
- */
3250
- function send(controller, payload) {
3251
- controller.enqueue(encoder.encode(JSON.stringify(payload) + "\n"));
3252
- }
3253
- let closed = false;
3254
- /** @type {string | undefined} */
3255
- let result = void 0;
3256
- async function cancel() {
3257
- if (closed) return;
3258
- closed = true;
3259
- await generator.return(void 0);
3260
- }
3261
- event.request.signal.addEventListener("abort", cancel, { once: true });
3262
- return new Response(new ReadableStream({
3263
- async pull(controller) {
3264
- if (event.request.signal.aborted) {
3265
- await cancel();
3266
- controller.close();
3267
- return;
3268
- }
3269
- try {
3270
- while (true) {
3271
- const { value, done } = await generator.next();
3272
- if (done) {
3273
- await cancel();
3274
- controller.close();
3275
- return;
3276
- }
3277
- if (result !== (result = stringify(value, transport))) {
3278
- send(controller, {
3279
- type: "result",
3280
- result
3281
- });
3282
- return;
3283
- }
3284
- }
3285
- } catch (error) {
3286
- if (!event.request.signal.aborted) if (error instanceof Redirect) send(controller, {
3287
- type: "redirect",
3288
- location: error.location
3289
- });
3290
- else {
3291
- const status = error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
3292
- send(controller, {
3293
- type: "error",
3294
- error: await handle_error_and_jsonify(event, state, options, error),
3295
- status
3296
- });
3297
- }
3298
- await cancel();
3299
- controller.close();
3300
- }
3301
- },
3302
- cancel
3303
- }), { headers: {
3304
- "cache-control": "private, no-store",
3305
- "content-type": "application/x-ndjson"
3306
- } });
3307
- }
3308
- const payload = internals.type === "prerender" ? additional_args : new URL(event.request.url).searchParams.get("payload");
3309
- return json({
3310
- type: "result",
3311
- result: stringify(await with_request_store({
3312
- event,
3313
- state
3314
- }, () => fn(parse_remote_arg(payload, transport))), transport)
3315
- });
3316
- } catch (error) {
3317
- if (error instanceof Redirect) return json({
3318
- type: "redirect",
3319
- location: error.location,
3320
- refreshes: await serialize_singleflight(state.remote.refreshes),
3321
- reconnects: await serialize_singleflight(state.remote.reconnects)
3322
- });
3323
- const status = error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500;
3324
- return json({
3325
- type: "error",
3326
- error: await handle_error_and_jsonify(event, state, options, error),
3327
- status
3328
- }, {
3329
- status: state.prerendering ? status : void 0,
3330
- headers: { "cache-control": "private, no-store" }
3331
- });
3332
- }
3333
- /** @param {Map<string, Promise<any>> | null} map */
3334
- async function serialize_singleflight(map) {
3335
- if (!map || map.size === 0) return;
3336
- const results = await Promise.all(Array.from(map, async ([key, promise]) => {
3337
- try {
3338
- return [key, {
3339
- type: "result",
3340
- data: await promise
3341
- }];
3342
- } catch (error) {
3343
- return [key, {
3344
- type: "error",
3345
- status: error instanceof HttpError || error instanceof SvelteKitError ? error.status : 500,
3346
- error: await handle_error_and_jsonify(event, state, options, error)
3347
- }];
3348
- }
3349
- }));
3350
- return stringify(Object.fromEntries(results), transport);
3351
- }
3352
- }
3353
- /**
3354
- * @param {string[] | undefined} refreshes
3355
- */
3356
- function create_requested_map(refreshes) {
3357
- /** @type {Map<string, string[]>} */
3358
- const requested = /* @__PURE__ */ new Map();
3359
- for (const key of refreshes ?? []) {
3360
- const parts = split_remote_key(key);
3361
- const existing = requested.get(parts.id);
3362
- if (existing) existing.push(parts.payload);
3363
- else requested.set(parts.id, [parts.payload]);
3364
- }
3365
- return requested;
3366
- }
3367
- /** @type {typeof handle_remote_form_post_internal} */
3368
- async function handle_remote_form_post(event, state, manifest, id) {
3369
- return record_span({
3370
- name: "sveltekit.remote.form.post",
3371
- attributes: { },
3372
- fn: (current) => {
3373
- const traced_event = merge_tracing(event, current);
3374
- return with_request_store({
3375
- event: traced_event,
3376
- state
3377
- }, () => handle_remote_form_post_internal(traced_event, state, manifest, id));
3378
- }
3379
- });
3380
- }
3381
- /**
3382
- * @param {RequestEvent} event
3383
- * @param {RequestState} state
3384
- * @param {SSRManifest} manifest
3385
- * @param {string} id
3386
- * @returns {Promise<ActionResult>}
3387
- */
3388
- async function handle_remote_form_post_internal(event, state, manifest, id) {
3389
- const [hash, name, action_id] = id.split("/");
3390
- let form = (await manifest._.remotes[hash]?.())?.default[name];
3391
- if (!form) {
3392
- event.setHeaders({ allow: "GET" });
3393
- return {
3394
- type: "error",
3395
- error: new SvelteKitError(405, "Method Not Allowed", `POST method not allowed. No form actions exist for this page`)
3396
- };
3397
- }
3398
- if (action_id) form = with_request_store({
3399
- event,
3400
- state
3401
- }, () => form.for(JSON.parse(action_id)));
3402
- try {
3403
- const fn = form.__.fn;
3404
- const { data, meta, form_data } = await deserialize_binary_form(event.request);
3405
- if (action_id && !("id" in data)) data.id = JSON.parse(decodeURIComponent(action_id));
3406
- await with_request_store({
3407
- event,
3408
- state
3409
- }, () => fn(data, meta, form_data));
3410
- return {
3411
- type: "success",
3412
- status: 200
3413
- };
3414
- } catch (e) {
3415
- const err = normalize_error(e);
3416
- if (err instanceof Redirect) return {
3417
- type: "redirect",
3418
- status: err.status,
3419
- location: err.location
3420
- };
3421
- return {
3422
- type: "error",
3423
- error: check_incorrect_fail_use(err)
3424
- };
3425
- }
3426
- }
3427
- /**
3428
- * @param {URL} url
3429
- */
3430
- function get_remote_id(url) {
3431
- return url.pathname.startsWith(`${base}/_app/remote/`) && url.pathname.replace(`${base}/_app/remote/`, "");
3432
- }
3433
- /**
3434
- * @param {URL} url
3435
- */
3436
- function get_remote_action(url) {
3437
- return url.searchParams.get("/remote");
3438
- }
3439
- //#endregion
3440
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/page/index.js
3441
- /** @import { ActionResult, RequestEvent, SSRManifest } from '@sveltejs/kit' */
3442
- /** @import { PageNodeIndexes, RequestState, RequiredResolveOptions, ServerDataNode, SSRComponent, SSRNode, SSROptions, SSRState } from 'types' */
3443
- /**
3444
- * The maximum request depth permitted before assuming we're stuck in an infinite loop
3445
- */
3446
- var MAX_DEPTH = 10;
3447
- /**
3448
- * @param {RequestEvent} event
3449
- * @param {RequestState} event_state
3450
- * @param {PageNodeIndexes} page
3451
- * @param {SSROptions} options
3452
- * @param {SSRManifest} manifest
3453
- * @param {SSRState} state
3454
- * @param {import('../../../utils/page_nodes.js').PageNodes} nodes
3455
- * @param {RequiredResolveOptions} resolve_opts
3456
- * @returns {Promise<Response>}
3457
- */
3458
- async function render_page(event, event_state, page, options, manifest, state, nodes, resolve_opts) {
3459
- if (state.depth > MAX_DEPTH) return text(`Not found: ${event.url.pathname}`, { status: 404 });
3460
- if (is_action_json_request(event)) return handle_action_json_request(event, event_state, options, (await manifest._.nodes[page.leaf]())?.server);
3461
- try {
3462
- const leaf_node = nodes.page();
3463
- let status = 200;
3464
- /** @type {ActionResult | undefined} */
3465
- let action_result = void 0;
3466
- if (is_action_request(event)) {
3467
- const remote_id = get_remote_action(event.url);
3468
- if (remote_id) action_result = await handle_remote_form_post(event, event_state, manifest, remote_id);
3469
- else action_result = await handle_action_request(event, event_state, leaf_node.server);
3470
- if (action_result?.type === "redirect") return redirect_response(action_result.status, action_result.location);
3471
- if (action_result?.type === "error") status = get_status(action_result.error);
3472
- if (action_result?.type === "failure") status = action_result.status;
3473
- }
3474
- const should_prerender = nodes.prerender();
3475
- if (should_prerender) {
3476
- if (leaf_node.server?.actions) throw new Error("Cannot prerender pages with actions");
3477
- } else if (state.prerendering) return new Response(void 0, { status: 204 });
3478
- state.prerender_default = should_prerender;
3479
- const should_prerender_data = nodes.should_prerender_data();
3480
- const data_pathname = add_data_suffix(event.url.pathname);
3481
- /** @type {import('./types.js').Fetched[]} */
3482
- const fetched = [];
3483
- const ssr = nodes.ssr();
3484
- const csr = nodes.csr();
3485
- if (ssr === false && !(state.prerendering && should_prerender_data)) return await render_response({
3486
- branch: compact(nodes.data).map((node) => {
3487
- return {
3488
- node,
3489
- data: null,
3490
- server_data: null
3491
- };
3492
- }),
3493
- fetched,
3494
- page_config: {
3495
- ssr: false,
3496
- csr
3497
- },
3498
- status,
3499
- error: null,
3500
- event,
3501
- event_state,
3502
- options,
3503
- manifest,
3504
- state,
3505
- resolve_opts,
3506
- data_serializer: server_data_serializer(event, event_state, options)
3507
- });
3508
- /** @type {Array<import('./types.js').Loaded | null>} */
3509
- const branch = [];
3510
- /** @type {Error | null} */
3511
- let load_error = null;
3512
- const data_serializer = server_data_serializer(event, event_state, options);
3513
- const data_serializer_json = state.prerendering && should_prerender_data ? server_data_serializer_json(event, event_state, options) : null;
3514
- /** @type {Array<Promise<ServerDataNode | null>>} */
3515
- const server_promises = nodes.data.map((node, i) => {
3516
- if (load_error) throw load_error;
3517
- return Promise.resolve().then(async () => {
3518
- try {
3519
- if (node === leaf_node && action_result?.type === "error") throw action_result.error;
3520
- const server_data = await load_server_data({
3521
- event,
3522
- event_state,
3523
- state,
3524
- node,
3525
- parent: async () => {
3526
- /** @type {Record<string, any>} */
3527
- const data = {};
3528
- for (let j = 0; j < i; j += 1) {
3529
- const parent = await server_promises[j];
3530
- if (parent) Object.assign(data, parent.data);
3531
- }
3532
- return data;
3533
- }
3534
- });
3535
- if (node) data_serializer.add_node(i, server_data);
3536
- data_serializer_json?.add_node(i, server_data);
3537
- return server_data;
3538
- } catch (e) {
3539
- load_error = e;
3540
- throw load_error;
3541
- }
3542
- });
3543
- });
3544
- /** @type {Array<Promise<Record<string, any> | null>>} */
3545
- const load_promises = nodes.data.map((node, i) => {
3546
- if (load_error) throw load_error;
3547
- return Promise.resolve().then(async () => {
3548
- try {
3549
- return await load_data({
3550
- event,
3551
- event_state,
3552
- fetched,
3553
- node,
3554
- parent: async () => {
3555
- const data = {};
3556
- for (let j = 0; j < i; j += 1) Object.assign(data, await load_promises[j]);
3557
- return data;
3558
- },
3559
- resolve_opts,
3560
- server_data_promise: server_promises[i],
3561
- state,
3562
- csr
3563
- });
3564
- } catch (e) {
3565
- load_error = e;
3566
- throw load_error;
3567
- }
3568
- });
3569
- });
3570
- for (const p of server_promises) p.catch(noop);
3571
- for (const p of load_promises) p.catch(noop);
3572
- for (let i = 0; i < nodes.data.length; i += 1) {
3573
- const node = nodes.data[i];
3574
- if (node) try {
3575
- const server_data = await server_promises[i];
3576
- const data = await load_promises[i];
3577
- branch.push({
3578
- node,
3579
- server_data,
3580
- data
3581
- });
3582
- } catch (e) {
3583
- const err = normalize_error(e);
3584
- if (err instanceof Redirect) {
3585
- if (state.prerendering && should_prerender_data) {
3586
- const body = JSON.stringify({
3587
- type: "redirect",
3588
- location: err.location
3589
- });
3590
- state.prerendering.dependencies.set(data_pathname, {
3591
- response: text(body),
3592
- body
3593
- });
3594
- }
3595
- return redirect_response(err.status, err.location);
3596
- }
3597
- const status = get_status(err);
3598
- const error = await handle_error_and_jsonify(event, event_state, options, err);
3599
- while (i--) if (page.errors[i]) {
3600
- const index = page.errors[i];
3601
- const node = await manifest._.nodes[index]();
3602
- let j = i;
3603
- while (!branch[j]) j -= 1;
3604
- data_serializer.set_max_nodes(j + 1);
3605
- const layouts = compact(branch.slice(0, j + 1));
3606
- const nodes = new PageNodes(layouts.map((layout) => layout.node));
3607
- const error_branch = layouts.concat({
3608
- node,
3609
- data: null,
3610
- server_data: null
3611
- });
3612
- return await render_response({
3613
- event,
3614
- event_state,
3615
- options,
3616
- manifest,
3617
- state,
3618
- resolve_opts,
3619
- page_config: {
3620
- ssr: nodes.ssr(),
3621
- csr: nodes.csr()
3622
- },
3623
- status,
3624
- error,
3625
- error_components: await load_error_components(options, ssr, error_branch, page, manifest),
3626
- branch: error_branch,
3627
- fetched,
3628
- data_serializer
3629
- });
3630
- }
3631
- return static_error_page(options, status, error.message);
3632
- }
3633
- else branch.push(null);
3634
- }
3635
- if (state.prerendering && data_serializer_json) {
3636
- let { data, chunks } = data_serializer_json.get_data();
3637
- if (chunks) for await (const chunk of chunks) data += chunk;
3638
- state.prerendering.dependencies.set(data_pathname, {
3639
- response: text(data),
3640
- body: data
3641
- });
3642
- }
3643
- return await render_response({
3644
- event,
3645
- event_state,
3646
- options,
3647
- manifest,
3648
- state,
3649
- resolve_opts,
3650
- page_config: {
3651
- csr,
3652
- ssr
3653
- },
3654
- status,
3655
- error: null,
3656
- branch: compact(branch),
3657
- action_result,
3658
- fetched,
3659
- data_serializer: !ssr ? server_data_serializer(event, event_state, options) : data_serializer,
3660
- error_components: await load_error_components(options, ssr, branch, page, manifest)
3661
- });
3662
- } catch (e) {
3663
- if (e instanceof Redirect) return redirect_response(e.status, e.location);
3664
- return await respond_with_error({
3665
- event,
3666
- event_state,
3667
- options,
3668
- manifest,
3669
- state,
3670
- status: e instanceof HttpError ? e.status : 500,
3671
- error: e,
3672
- resolve_opts
3673
- });
3674
- }
3675
- }
3676
- /**
3677
- *
3678
- * @param {SSROptions} options
3679
- * @param {boolean} ssr
3680
- * @param {Array<import('./types.js').Loaded | null>} branch
3681
- * @param {PageNodeIndexes} page
3682
- * @param {SSRManifest} manifest
3683
- */
3684
- async function load_error_components(options, ssr, branch, page, manifest) {
3685
- /** @type {Array<SSRComponent | undefined> | undefined} */
3686
- let error_components;
3687
- if (options.server_error_boundaries && ssr) {
3688
- let last_idx = -1;
3689
- error_components = await Promise.all(branch.map((b, i) => {
3690
- if (i === 0) return void 0;
3691
- if (!b) return null;
3692
- i--;
3693
- while (i > last_idx + 1 && page.errors[i] === void 0) i -= 1;
3694
- last_idx = i;
3695
- const idx = page.errors[i];
3696
- if (idx == null) return void 0;
3697
- return manifest._.nodes[idx]?.().then((e) => e.component?.()).catch(() => void 0);
3698
- }).filter((e) => e !== null));
3699
- }
3700
- return error_components;
3701
- }
3702
- //#endregion
3703
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/data/index.js
3704
- /**
3705
- * @param {import('@sveltejs/kit').RequestEvent} event
3706
- * @param {import('types').RequestState} event_state
3707
- * @param {import('types').SSRRoute} route
3708
- * @param {import('types').SSROptions} options
3709
- * @param {import('@sveltejs/kit').SSRManifest} manifest
3710
- * @param {import('types').SSRState} state
3711
- * @param {boolean[] | undefined} invalidated_data_nodes
3712
- * @param {import('types').TrailingSlash} trailing_slash
3713
- * @returns {Promise<Response>}
3714
- */
3715
- async function render_data(event, event_state, route, options, manifest, state, invalidated_data_nodes, trailing_slash) {
3716
- if (!route.page) return new Response(void 0, { status: 404 });
3717
- try {
3718
- const node_ids = [...route.page.layouts, route.page.leaf];
3719
- const invalidated = invalidated_data_nodes ?? node_ids.map(() => true);
3720
- let aborted = false;
3721
- const url = new URL(event.url);
3722
- url.pathname = normalize_path(url.pathname, trailing_slash);
3723
- const new_event = {
3724
- ...event,
3725
- url
3726
- };
3727
- const functions = node_ids.map((n, i) => {
3728
- return once(async () => {
3729
- try {
3730
- if (aborted) return { type: "skip" };
3731
- return load_server_data({
3732
- event: new_event,
3733
- event_state,
3734
- state,
3735
- node: n == void 0 ? n : await manifest._.nodes[n](),
3736
- parent: async () => {
3737
- /** @type {Record<string, any>} */
3738
- const data = {};
3739
- for (let j = 0; j < i; j += 1) {
3740
- const parent = await functions[j]();
3741
- if (parent) Object.assign(data, parent.data);
3742
- }
3743
- return data;
3744
- }
3745
- });
3746
- } catch (e) {
3747
- aborted = true;
3748
- throw e;
3749
- }
3750
- });
3751
- });
3752
- const promises = functions.map(async (fn, i) => {
3753
- if (!invalidated[i]) return { type: "skip" };
3754
- return fn();
3755
- });
3756
- let length = promises.length;
3757
- const nodes = await Promise.all(promises.map((p, i) => p.catch(async (error) => {
3758
- if (error instanceof Redirect) throw error;
3759
- length = Math.min(length, i + 1);
3760
- return {
3761
- type: "error",
3762
- error: await handle_error_and_jsonify(event, event_state, options, error),
3763
- status: error instanceof HttpError || error instanceof SvelteKitError ? error.status : void 0
3764
- };
3765
- })));
3766
- const data_serializer = server_data_serializer_json(event, event_state, options);
3767
- for (let i = 0; i < nodes.length; i++) data_serializer.add_node(i, nodes[i]);
3768
- const { data, chunks } = data_serializer.get_data();
3769
- if (!chunks) return json_response(data);
3770
- return new Response(new ReadableStream({
3771
- async start(controller) {
3772
- controller.enqueue(text_encoder$1.encode(data));
3773
- for await (const chunk of chunks) controller.enqueue(text_encoder$1.encode(chunk));
3774
- controller.close();
3775
- },
3776
- type: "bytes"
3777
- }), { headers: {
3778
- "content-type": "text/sveltekit-data",
3779
- "cache-control": "private, no-store"
3780
- } });
3781
- } catch (e) {
3782
- const error = normalize_error(e);
3783
- if (error instanceof Redirect) return redirect_json_response(error);
3784
- else return json_response(await handle_error_and_jsonify(event, event_state, options, error), 500);
3785
- }
3786
- }
3787
- /**
3788
- * @param {Record<string, any> | string} json
3789
- * @param {number} [status]
3790
- */
3791
- function json_response(json, status = 200) {
3792
- return text(typeof json === "string" ? json : JSON.stringify(json), {
3793
- status,
3794
- headers: {
3795
- "content-type": "application/json",
3796
- "cache-control": "private, no-store"
3797
- }
3798
- });
3799
- }
3800
- /**
3801
- * @param {Redirect} redirect
3802
- */
3803
- function redirect_json_response(redirect) {
3804
- return json_response({
3805
- type: "redirect",
3806
- location: redirect.location
3807
- });
3808
- }
3809
- //#endregion
3810
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/cookie.js
3811
- var INVALID_COOKIE_CHARACTER_REGEX = /[\x00-\x1F\x7F()<>@,;:"/[\]?={} \t]/;
3812
- /** @param {import('./page/types.js').Cookie['options']} options */
3813
- function validate_options(options) {
3814
- if (options?.path === void 0) throw new Error("You must specify a `path` when setting, deleting or serializing cookies");
3815
- }
3816
- /**
3817
- * Generates a unique key for a cookie based on its domain, path, and name in
3818
- * the format: `<domain>/<path>?<name>`.
3819
- * If domain is undefined, it will be omitted.
3820
- * For example: `/?name`, `example.com/foo?name`.
3821
- *
3822
- * @param {string | undefined} domain
3823
- * @param {string} path
3824
- * @param {string} name
3825
- * @returns {string}
3826
- */
3827
- function generate_cookie_key(domain, path, name) {
3828
- return `${domain || ""}${path}?${encodeURIComponent(name)}`;
3829
- }
3830
- /**
3831
- * @param {Request} request
3832
- * @param {URL} url
3833
- */
3834
- function get_cookies(request, url) {
3835
- const header = request.headers.get("cookie") ?? "";
3836
- const initial_cookies = cookieExports.parse(header, { decode: (value) => value });
3837
- /** @type {string | undefined} */
3838
- let normalized_url;
3839
- /** @type {Map<string, import('./page/types.js').Cookie>} */
3840
- const new_cookies = /* @__PURE__ */ new Map();
3841
- /** @type {import('cookie').CookieSerializeOptions} */
3842
- const defaults = {
3843
- httpOnly: true,
3844
- sameSite: "lax",
3845
- secure: url.hostname === "localhost" && url.protocol === "http:" ? false : true
3846
- };
3847
- /** @type {import('@sveltejs/kit').Cookies} */
3848
- const cookies = {
3849
- /**
3850
- * @param {string} name
3851
- * @param {import('cookie').CookieParseOptions} [opts]
3852
- */
3853
- get(name, opts) {
3854
- const best_match = Array.from(new_cookies.values()).filter((c) => {
3855
- return c.name === name && domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path);
3856
- }).sort((a, b) => b.options.path.length - a.options.path.length)[0];
3857
- if (best_match) return best_match.options.maxAge === 0 ? void 0 : best_match.value;
3858
- return cookieExports.parse(header, { decode: opts?.decode })[name];
3859
- },
3860
- /**
3861
- * @param {import('cookie').CookieParseOptions} [opts]
3862
- */
3863
- getAll(opts) {
3864
- const cookies = cookieExports.parse(header, { decode: opts?.decode });
3865
- const lookup = /* @__PURE__ */ new Map();
3866
- for (const c of new_cookies.values()) if (domain_matches(url.hostname, c.options.domain) && path_matches(url.pathname, c.options.path)) {
3867
- const existing = lookup.get(c.name);
3868
- if (!existing || c.options.path.length > existing.options.path.length) lookup.set(c.name, c);
3869
- }
3870
- for (const c of lookup.values()) cookies[c.name] = c.value;
3871
- return Object.entries(cookies).map(([name, value]) => ({
3872
- name,
3873
- value
3874
- }));
3875
- },
3876
- /**
3877
- * @param {string} name
3878
- * @param {string} value
3879
- * @param {import('./page/types.js').Cookie['options']} options
3880
- */
3881
- set(name, value, options) {
3882
- const illegal_characters = name.match(INVALID_COOKIE_CHARACTER_REGEX);
3883
- if (illegal_characters) console.warn(`The cookie name "${name}" will be invalid in SvelteKit 3.0 as it contains ${illegal_characters.join(" and ")}. See RFC 2616 for more details https://datatracker.ietf.org/doc/html/rfc2616#section-2.2`);
3884
- validate_options(options);
3885
- set_internal(name, value, {
3886
- ...defaults,
3887
- ...options
3888
- });
3889
- },
3890
- /**
3891
- * @param {string} name
3892
- * @param {import('./page/types.js').Cookie['options']} options
3893
- */
3894
- delete(name, options) {
3895
- validate_options(options);
3896
- cookies.set(name, "", {
3897
- ...options,
3898
- maxAge: 0
3899
- });
3900
- },
3901
- /**
3902
- * @param {string} name
3903
- * @param {string} value
3904
- * @param {import('./page/types.js').Cookie['options']} options
3905
- */
3906
- serialize(name, value, options) {
3907
- validate_options(options);
3908
- let path = options.path;
3909
- if (!options.domain || options.domain === url.hostname) {
3910
- if (!normalized_url) throw new Error("Cannot serialize cookies until after the route is determined");
3911
- path = resolve(normalized_url, path);
3912
- }
3913
- return cookieExports.serialize(name, value, {
3914
- ...defaults,
3915
- ...options,
3916
- path
3917
- });
3918
- }
3919
- };
3920
- /**
3921
- * @param {URL} destination
3922
- * @param {string | null} header
3923
- */
3924
- function get_cookie_header(destination, header) {
3925
- /** @type {Record<string, string>} */
3926
- const combined_cookies = { ...initial_cookies };
3927
- for (const cookie of new_cookies.values()) {
3928
- if (!domain_matches(destination.hostname, cookie.options.domain)) continue;
3929
- if (!path_matches(destination.pathname, cookie.options.path)) continue;
3930
- const encoder = cookie.options.encode || encodeURIComponent;
3931
- combined_cookies[cookie.name] = encoder(cookie.value);
3932
- }
3933
- if (header) {
3934
- const parsed = cookieExports.parse(header, { decode: (value) => value });
3935
- for (const name in parsed) combined_cookies[name] = parsed[name];
3936
- }
3937
- return Object.entries(combined_cookies).map(([name, value]) => `${name}=${value}`).join("; ");
3938
- }
3939
- /** @type {Array<() => void>} */
3940
- const internal_queue = [];
3941
- /**
3942
- * @param {string} name
3943
- * @param {string} value
3944
- * @param {import('./page/types.js').Cookie['options']} options
3945
- */
3946
- function set_internal(name, value, options) {
3947
- if (!normalized_url) {
3948
- internal_queue.push(() => set_internal(name, value, options));
3949
- return;
3950
- }
3951
- let path = options.path;
3952
- if (!options.domain || options.domain === url.hostname) path = resolve(normalized_url, path);
3953
- const cookie_key = generate_cookie_key(options.domain, path, name);
3954
- const cookie = {
3955
- name,
3956
- value,
3957
- options: {
3958
- ...options,
3959
- path
3960
- }
3961
- };
3962
- new_cookies.set(cookie_key, cookie);
3963
- }
3964
- /**
3965
- * @param {import('types').TrailingSlash} trailing_slash
3966
- */
3967
- function set_trailing_slash(trailing_slash) {
3968
- normalized_url = normalize_path(url.pathname, trailing_slash);
3969
- internal_queue.forEach((fn) => fn());
3970
- }
3971
- return {
3972
- cookies,
3973
- new_cookies,
3974
- get_cookie_header,
3975
- set_internal,
3976
- set_trailing_slash
3977
- };
3978
- }
3979
- /**
3980
- * @param {string} hostname
3981
- * @param {string} [constraint]
3982
- */
3983
- function domain_matches(hostname, constraint) {
3984
- if (!constraint) return true;
3985
- const normalized = constraint[0] === "." ? constraint.slice(1) : constraint;
3986
- if (hostname === normalized) return true;
3987
- return hostname.endsWith("." + normalized);
3988
- }
3989
- /**
3990
- * @param {string} path
3991
- * @param {string} [constraint]
3992
- */
3993
- function path_matches(path, constraint) {
3994
- if (!constraint) return true;
3995
- const normalized = constraint.endsWith("/") ? constraint.slice(0, -1) : constraint;
3996
- if (path === normalized) return true;
3997
- return path.startsWith(normalized + "/");
3998
- }
3999
- /**
4000
- * @param {Headers} headers
4001
- * @param {MapIterator<import('./page/types.js').Cookie>} cookies
4002
- */
4003
- function add_cookies_to_headers(headers, cookies) {
4004
- for (const new_cookie of cookies) {
4005
- const { name, value, options } = new_cookie;
4006
- headers.append("set-cookie", cookieExports.serialize(name, value, options));
4007
- if (options.path.endsWith(".html")) {
4008
- const path = add_data_suffix(options.path);
4009
- headers.append("set-cookie", cookieExports.serialize(name, value, {
4010
- ...options,
4011
- path
4012
- }));
4013
- }
4014
- }
4015
- }
4016
- //#endregion
4017
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/fetch.js
4018
- /**
4019
- * @param {{
4020
- * event: import('@sveltejs/kit').RequestEvent;
4021
- * options: import('types').SSROptions;
4022
- * manifest: import('@sveltejs/kit').SSRManifest;
4023
- * state: import('types').SSRState;
4024
- * get_cookie_header: (url: URL, header: string | null) => string;
4025
- * set_internal: (name: string, value: string, opts: import('./page/types.js').Cookie['options']) => void;
4026
- * }} opts
4027
- * @returns {typeof fetch}
4028
- */
4029
- function create_fetch({ event, options, manifest, state, get_cookie_header, set_internal }) {
4030
- /**
4031
- * @type {typeof fetch}
4032
- */
4033
- const server_fetch = async (info, init) => {
4034
- const original_request = normalize_fetch_input(info, init, event.url);
4035
- let mode = (info instanceof Request ? info.mode : init?.mode) ?? "cors";
4036
- let credentials = (info instanceof Request ? info.credentials : init?.credentials) ?? "same-origin";
4037
- return options.hooks.handleFetch({
4038
- event,
4039
- request: original_request,
4040
- fetch: async (info, init) => {
4041
- const request = normalize_fetch_input(info, init, event.url);
4042
- const url = new URL(request.url);
4043
- if (!request.headers.has("origin")) request.headers.set("origin", event.url.origin);
4044
- if (info !== original_request) {
4045
- mode = (info instanceof Request ? info.mode : init?.mode) ?? "cors";
4046
- credentials = (info instanceof Request ? info.credentials : init?.credentials) ?? "same-origin";
4047
- }
4048
- if ((request.method === "GET" || request.method === "HEAD") && (mode === "no-cors" && url.origin !== event.url.origin || url.origin === event.url.origin)) request.headers.delete("origin");
4049
- const decoded = decodeURIComponent(url.pathname);
4050
- if (url.origin !== event.url.origin || base && decoded !== base && !decoded.startsWith(`${base}/`)) {
4051
- if (`.${url.hostname}`.endsWith(`.${event.url.hostname}`) && credentials !== "omit") {
4052
- const cookie = get_cookie_header(url, request.headers.get("cookie"));
4053
- if (cookie) request.headers.set("cookie", cookie);
4054
- }
4055
- return fetch(request);
4056
- }
4057
- const prefix = assets || base;
4058
- const filename = (decoded.startsWith(prefix) ? decoded.slice(prefix.length) : decoded).slice(1);
4059
- const filename_html = `${filename}/index.html`;
4060
- const is_asset = manifest.assets.has(filename) || filename in manifest._.server_assets;
4061
- const is_asset_html = manifest.assets.has(filename_html) || filename_html in manifest._.server_assets;
4062
- if (is_asset || is_asset_html) {
4063
- const file = is_asset ? filename : filename_html;
4064
- if (state.read) {
4065
- const type = is_asset ? manifest.mimeTypes[filename.slice(filename.lastIndexOf("."))] : "text/html";
4066
- return new Response(state.read(file), { headers: type ? { "content-type": type } : {} });
4067
- } else if (read_implementation && file in manifest._.server_assets) {
4068
- const length = manifest._.server_assets[file];
4069
- const type = manifest.mimeTypes[file.slice(file.lastIndexOf("."))];
4070
- return new Response(read_implementation(file), { headers: {
4071
- "Content-Length": "" + length,
4072
- "Content-Type": type
4073
- } });
4074
- }
4075
- return await fetch(request);
4076
- }
4077
- if (has_prerendered_path(manifest, base + decoded)) return await fetch(request);
4078
- if (credentials !== "omit") {
4079
- const cookie = get_cookie_header(url, request.headers.get("cookie"));
4080
- if (cookie) request.headers.set("cookie", cookie);
4081
- const authorization = event.request.headers.get("authorization");
4082
- if (authorization && !request.headers.has("authorization")) request.headers.set("authorization", authorization);
4083
- }
4084
- if (!request.headers.has("accept")) request.headers.set("accept", "*/*");
4085
- if (!request.headers.has("accept-language")) request.headers.set("accept-language", event.request.headers.get("accept-language"));
4086
- const response = await internal_fetch(request, options, manifest, state);
4087
- const set_cookie = response.headers.get("set-cookie");
4088
- if (set_cookie) for (const str of splitCookiesString(set_cookie)) {
4089
- const { name, value, ...options } = parseString(str, { decodeValues: false });
4090
- set_internal(name, value, {
4091
- path: options.path ?? (url.pathname.split("/").slice(0, -1).join("/") || "/"),
4092
- encode: (value) => value,
4093
- ...options
4094
- });
4095
- }
4096
- return response;
4097
- }
4098
- });
4099
- };
4100
- return (input, init) => {
4101
- const response = server_fetch(input, init);
4102
- response.catch(noop);
4103
- return response;
4104
- };
4105
- }
4106
- /**
4107
- * @param {RequestInfo | URL} info
4108
- * @param {RequestInit | undefined} init
4109
- * @param {URL} url
4110
- */
4111
- function normalize_fetch_input(info, init, url) {
4112
- if (info instanceof Request) return info;
4113
- return new Request(typeof info === "string" ? new URL(info, url) : info, init);
4114
- }
4115
- /**
4116
- * @param {Request} request
4117
- * @param {import('types').SSROptions} options
4118
- * @param {import('@sveltejs/kit').SSRManifest} manifest
4119
- * @param {import('types').SSRState} state
4120
- * @returns {Promise<Response>}
4121
- */
4122
- async function internal_fetch(request, options, manifest, state) {
4123
- if (request.signal) {
4124
- if (request.signal.aborted) throw new DOMException("The operation was aborted.", "AbortError");
4125
- let remove_abort_listener = noop;
4126
- /** @type {Promise<never>} */
4127
- const abort_promise = new Promise((_, reject) => {
4128
- const on_abort = () => {
4129
- reject(new DOMException("The operation was aborted.", "AbortError"));
4130
- };
4131
- request.signal.addEventListener("abort", on_abort, { once: true });
4132
- remove_abort_listener = () => request.signal.removeEventListener("abort", on_abort);
4133
- });
4134
- const result = await Promise.race([respond(request, options, manifest, {
4135
- ...state,
4136
- depth: state.depth + 1
4137
- }), abort_promise]);
4138
- remove_abort_listener();
4139
- return result;
4140
- } else return await respond(request, options, manifest, {
4141
- ...state,
4142
- depth: state.depth + 1
4143
- });
4144
- }
4145
- //#endregion
4146
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/env_module.js
4147
- /** @type {string} */
4148
- var body;
4149
- /** @type {string} */
4150
- var etag;
4151
- /** @type {Headers} */
4152
- var headers;
4153
- /**
4154
- * @param {Request} request
4155
- * @returns {Response}
4156
- */
4157
- function get_public_env(request) {
4158
- body ??= `export const env=${JSON.stringify(public_env)}`;
4159
- etag ??= `W/${Date.now()}`;
4160
- headers ??= new Headers({
4161
- "content-type": "application/javascript; charset=utf-8",
4162
- etag
4163
- });
4164
- if (request.headers.get("if-none-match") === etag) return new Response(void 0, {
4165
- status: 304,
4166
- headers
4167
- });
4168
- return new Response(body, { headers });
4169
- }
4170
- //#endregion
4171
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/respond.js
4172
- /** @import { RequestState, SSRNode } from 'types' */
4173
- /** @type {import('types').RequiredResolveOptions['transformPageChunk']} */
4174
- var default_transform = ({ html }) => html;
4175
- /** @type {import('types').RequiredResolveOptions['filterSerializedResponseHeaders']} */
4176
- var default_filter = () => false;
4177
- /** @type {import('types').RequiredResolveOptions['preload']} */
4178
- var default_preload = ({ type }) => type === "js" || type === "css";
4179
- var page_methods = new Set([
4180
- "GET",
4181
- "HEAD",
4182
- "POST"
4183
- ]);
4184
- var allowed_page_methods = new Set([
4185
- "GET",
4186
- "HEAD",
4187
- "OPTIONS"
4188
- ]);
4189
- var respond = propagate_context(internal_respond);
4190
- /**
4191
- * @param {Request} request
4192
- * @param {import('types').SSROptions} options
4193
- * @param {import('@sveltejs/kit').SSRManifest} manifest
4194
- * @param {import('types').SSRState} state
4195
- * @returns {Promise<Response>}
4196
- */
4197
- async function internal_respond(request, options, manifest, state) {
4198
- /** URL but stripped from the potential `/__data.json` suffix and its search param */
4199
- const url = new URL(request.url);
4200
- const is_route_resolution_request = has_resolution_suffix(url.pathname);
4201
- const is_data_request = has_data_suffix(url.pathname);
4202
- const remote_id = get_remote_id(url);
4203
- {
4204
- const request_origin = request.headers.get("origin");
4205
- if (remote_id) {
4206
- if (request.method !== "GET" && request_origin !== url.origin) return json({ message: "Cross-site remote requests are forbidden" }, { status: 403 });
4207
- } else if (options.csrf_check_origin) {
4208
- if (is_form_content_type(request) && (request.method === "POST" || request.method === "PUT" || request.method === "PATCH" || request.method === "DELETE") && request_origin !== url.origin && (!request_origin || !options.csrf_trusted_origins.includes(request_origin))) {
4209
- const message = `Cross-site ${request.method} form submissions are forbidden`;
4210
- const opts = { status: 403 };
4211
- if (request.headers.get("accept") === "application/json") return json({ message }, opts);
4212
- return text(message, opts);
4213
- }
4214
- }
4215
- }
4216
- if (options.hash_routing && url.pathname !== base + "/" && url.pathname !== "/[fallback]") return text("Not found", { status: 404 });
4217
- /** @type {boolean[] | undefined} */
4218
- let invalidated_data_nodes;
4219
- if (is_route_resolution_request)
4220
- /**
4221
- * If the request is for a route resolution, first modify the URL, then continue as normal
4222
- * for path resolution, then return the route object as a JS file.
4223
- */
4224
- url.pathname = strip_resolution_suffix(url.pathname);
4225
- else if (is_data_request) {
4226
- url.pathname = strip_data_suffix(url.pathname) + (url.searchParams.get("x-sveltekit-trailing-slash") === "1" ? "/" : "") || "/";
4227
- url.searchParams.delete(TRAILING_SLASH_PARAM);
4228
- invalidated_data_nodes = url.searchParams.get(INVALIDATED_PARAM)?.split("").map((node) => node === "1");
4229
- url.searchParams.delete(INVALIDATED_PARAM);
4230
- } else if (remote_id) {
4231
- url.pathname = request.headers.get("x-sveltekit-pathname") ?? base;
4232
- url.search = request.headers.get("x-sveltekit-search") ?? "";
4233
- }
4234
- /** @type {Record<string, string>} */
4235
- const headers = {};
4236
- const { cookies, new_cookies, get_cookie_header, set_internal, set_trailing_slash } = get_cookies(request, url);
4237
- /** @type {RequestState} */
4238
- const event_state = {
4239
- prerendering: state.prerendering,
4240
- transport: options.hooks.transport,
4241
- handleValidationError: options.hooks.handleValidationError,
4242
- tracing: { record_span },
4243
- remote: {
4244
- data: null,
4245
- forms: null,
4246
- /** A map of remote function key to corresponding single-flight-mutation promise */
4247
- refreshes: null,
4248
- reconnects: null,
4249
- /** A map of remote function ID to payloads requested for refreshing by the client */
4250
- requested: null
4251
- },
4252
- is_in_remote_function: false,
4253
- is_in_render: false,
4254
- is_in_universal_load: false
4255
- };
4256
- /** @type {import('@sveltejs/kit').RequestEvent} */
4257
- const event = {
4258
- cookies,
4259
- fetch: null,
4260
- getClientAddress: state.getClientAddress || (() => {
4261
- throw new Error(`@sveltejs/adapter-node does not specify getClientAddress. Please raise an issue`);
4262
- }),
4263
- locals: {},
4264
- params: {},
4265
- platform: state.platform,
4266
- request,
4267
- route: { id: null },
4268
- setHeaders: (new_headers) => {
4269
- for (const key in new_headers) {
4270
- const lower = key.toLowerCase();
4271
- const value = new_headers[key];
4272
- if (lower === "set-cookie") throw new Error("Use `event.cookies.set(name, value, options)` instead of `event.setHeaders` to set cookies");
4273
- else if (lower in headers) if (lower === "server-timing") headers[lower] += ", " + value;
4274
- else throw new Error(`"${key}" header is already set`);
4275
- else {
4276
- headers[lower] = value;
4277
- if (state.prerendering && lower === "cache-control") state.prerendering.cache = value;
4278
- }
4279
- }
4280
- },
4281
- url,
4282
- isDataRequest: is_data_request,
4283
- isSubRequest: state.depth > 0,
4284
- isRemoteRequest: !!remote_id
4285
- };
4286
- event.fetch = create_fetch({
4287
- event,
4288
- options,
4289
- manifest,
4290
- state,
4291
- get_cookie_header,
4292
- set_internal
4293
- });
4294
- if (state.emulator?.platform) event.platform = await state.emulator.platform({
4295
- config: {},
4296
- prerender: !!state.prerendering?.fallback
4297
- });
4298
- let resolved_path = url.pathname;
4299
- if (!remote_id) {
4300
- const prerendering_reroute_state = state.prerendering?.inside_reroute;
4301
- try {
4302
- if (state.prerendering) state.prerendering.inside_reroute = true;
4303
- resolved_path = await options.hooks.reroute({
4304
- url: new URL(url),
4305
- fetch: event.fetch
4306
- }) ?? url.pathname;
4307
- } catch {
4308
- return text("Internal Server Error", { status: 500 });
4309
- } finally {
4310
- if (state.prerendering) state.prerendering.inside_reroute = prerendering_reroute_state;
4311
- }
4312
- }
4313
- try {
4314
- resolved_path = decode_pathname(resolved_path);
4315
- } catch {
4316
- return text("Malformed URI", { status: 400 });
4317
- }
4318
- if (resolved_path !== decode_pathname(url.pathname) && !state.prerendering?.fallback && has_prerendered_path(manifest, resolved_path)) {
4319
- const url = new URL(request.url);
4320
- url.pathname = is_data_request ? add_data_suffix(resolved_path) : is_route_resolution_request ? add_resolution_suffix(resolved_path) : resolved_path;
4321
- try {
4322
- const response = await fetch(url, request);
4323
- const headers = new Headers(response.headers);
4324
- if (headers.has("content-encoding")) {
4325
- headers.delete("content-encoding");
4326
- headers.delete("content-length");
4327
- }
4328
- return new Response(response.body, {
4329
- headers,
4330
- status: response.status,
4331
- statusText: response.statusText
4332
- });
4333
- } catch (error) {
4334
- return await handle_fatal_error(event, event_state, options, error);
4335
- }
4336
- }
4337
- /** @type {import('types').SSRRoute | null} */
4338
- let route = null;
4339
- if (base && !state.prerendering?.fallback) {
4340
- if (!resolved_path.startsWith(base)) return text("Not found", { status: 404 });
4341
- resolved_path = resolved_path.slice(base.length) || "/";
4342
- }
4343
- if (is_route_resolution_request) return resolve_route(resolved_path, new URL(request.url), manifest);
4344
- if (resolved_path === `/_app/env.js`) return get_public_env(request);
4345
- if (!remote_id && resolved_path.startsWith(`/_app`)) {
4346
- const headers = new Headers();
4347
- headers.set("cache-control", "public, max-age=0, must-revalidate");
4348
- return text("Not found", {
4349
- status: 404,
4350
- headers
4351
- });
4352
- }
4353
- if (!state.prerendering?.fallback) {
4354
- const matchers = await manifest._.matchers();
4355
- const result = find_route(resolved_path, manifest._.routes, matchers);
4356
- if (result) {
4357
- route = result.route;
4358
- event.route = { id: route.id };
4359
- event.params = result.params;
4360
- }
4361
- }
4362
- /** @type {import('types').RequiredResolveOptions} */
4363
- let resolve_opts = {
4364
- transformPageChunk: default_transform,
4365
- filterSerializedResponseHeaders: default_filter,
4366
- preload: default_preload
4367
- };
4368
- /** @type {import('types').TrailingSlash} */
4369
- let trailing_slash = "never";
4370
- try {
4371
- /** @type {PageNodes | undefined} */
4372
- const page_nodes = route?.page ? new PageNodes(await load_page_nodes(route.page, manifest)) : void 0;
4373
- if (route && !remote_id) {
4374
- if (url.pathname === base || url.pathname === base + "/") trailing_slash = "always";
4375
- else if (page_nodes) trailing_slash = page_nodes.trailing_slash();
4376
- else if (route.endpoint) trailing_slash = (await route.endpoint()).trailingSlash ?? "never";
4377
- if (!is_data_request) {
4378
- const normalized = normalize_path(url.pathname, trailing_slash);
4379
- if (normalized !== url.pathname && !state.prerendering?.fallback) return new Response(void 0, {
4380
- status: 308,
4381
- headers: {
4382
- "x-sveltekit-normalize": "1",
4383
- location: (normalized.startsWith("//") ? url.origin + normalized : normalized) + (url.search === "?" ? "" : url.search)
4384
- }
4385
- });
4386
- }
4387
- if (state.before_handle || state.emulator?.platform) {
4388
- let config = {};
4389
- /** @type {import('types').PrerenderOption} */
4390
- let prerender = false;
4391
- if (route.endpoint) {
4392
- const node = await route.endpoint();
4393
- config = node.config ?? config;
4394
- prerender = node.prerender ?? prerender;
4395
- } else if (page_nodes) {
4396
- config = page_nodes.get_config() ?? config;
4397
- prerender = page_nodes.prerender();
4398
- }
4399
- if (state.before_handle) state.before_handle(event, config, prerender);
4400
- if (state.emulator?.platform) event.platform = await state.emulator.platform({
4401
- config,
4402
- prerender
4403
- });
4404
- }
4405
- }
4406
- set_trailing_slash(trailing_slash);
4407
- if (state.prerendering && !state.prerendering.fallback && !state.prerendering.inside_reroute) disable_search(url);
4408
- const response = await record_span({
4409
- name: "sveltekit.handle.root",
4410
- attributes: {
4411
- "http.route": event.route.id || "unknown",
4412
- "http.method": event.request.method,
4413
- "http.url": event.url.href,
4414
- "sveltekit.is_data_request": is_data_request,
4415
- "sveltekit.is_sub_request": event.isSubRequest
4416
- },
4417
- fn: async (root_span) => {
4418
- const traced_event = {
4419
- ...event,
4420
- tracing: {
4421
- enabled: false,
4422
- root: root_span,
4423
- current: root_span
4424
- }
4425
- };
4426
- return await with_request_store({
4427
- event: traced_event,
4428
- state: event_state
4429
- }, () => options.hooks.handle({
4430
- event: traced_event,
4431
- resolve: (event, opts) => {
4432
- return record_span({
4433
- name: "sveltekit.resolve",
4434
- attributes: { "http.route": event.route.id || "unknown" },
4435
- fn: (resolve_span) => {
4436
- return with_request_store(null, () => resolve(merge_tracing(event, resolve_span), page_nodes, opts).then((response) => {
4437
- for (const key in headers) {
4438
- const value = headers[key];
4439
- response.headers.set(key, value);
4440
- }
4441
- add_cookies_to_headers(response.headers, new_cookies.values());
4442
- if (state.prerendering && event.route.id !== null) response.headers.set("x-sveltekit-routeid", encodeURI(event.route.id));
4443
- resolve_span.setAttributes({
4444
- "http.response.status_code": response.status,
4445
- "http.response.body.size": response.headers.get("content-length") || "unknown"
4446
- });
4447
- return response;
4448
- }));
4449
- }
4450
- });
4451
- }
4452
- }));
4453
- }
4454
- });
4455
- if (response.status === 200 && response.headers.has("etag")) {
4456
- let if_none_match_value = request.headers.get("if-none-match");
4457
- if (if_none_match_value?.startsWith("W/\"")) if_none_match_value = if_none_match_value.substring(2);
4458
- const etag = response.headers.get("etag");
4459
- if (if_none_match_value === etag) {
4460
- const headers = new Headers({ etag });
4461
- for (const key of [
4462
- "cache-control",
4463
- "content-location",
4464
- "date",
4465
- "expires",
4466
- "vary",
4467
- "set-cookie"
4468
- ]) {
4469
- const value = response.headers.get(key);
4470
- if (value) headers.set(key, value);
4471
- }
4472
- return new Response(void 0, {
4473
- status: 304,
4474
- headers
4475
- });
4476
- }
4477
- }
4478
- if (is_data_request && response.status >= 300 && response.status <= 308) {
4479
- const location = response.headers.get("location");
4480
- if (location) return redirect_json_response(new Redirect(response.status, location));
4481
- }
4482
- return response;
4483
- } catch (e) {
4484
- if (e instanceof Redirect) try {
4485
- const response = is_data_request || remote_id ? redirect_json_response(e) : route?.page && is_action_json_request(event) ? action_json_redirect(e) : redirect_response(e.status, e.location);
4486
- add_cookies_to_headers(response.headers, new_cookies.values());
4487
- return response;
4488
- } catch (err) {
4489
- return await handle_fatal_error(event, event_state, options, err);
4490
- }
4491
- return await handle_fatal_error(event, event_state, options, e);
4492
- }
4493
- /**
4494
- * @param {import('@sveltejs/kit').RequestEvent} event
4495
- * @param {PageNodes | undefined} page_nodes
4496
- * @param {import('@sveltejs/kit').ResolveOptions} [opts]
4497
- */
4498
- async function resolve(event, page_nodes, opts) {
4499
- try {
4500
- if (opts) resolve_opts = {
4501
- transformPageChunk: opts.transformPageChunk || default_transform,
4502
- filterSerializedResponseHeaders: opts.filterSerializedResponseHeaders || default_filter,
4503
- preload: opts.preload || default_preload
4504
- };
4505
- if (options.hash_routing || state.prerendering?.fallback) return await render_response({
4506
- event,
4507
- event_state,
4508
- options,
4509
- manifest,
4510
- state,
4511
- page_config: {
4512
- ssr: false,
4513
- csr: true
4514
- },
4515
- status: 200,
4516
- error: null,
4517
- branch: [{
4518
- node: await manifest._.nodes[0](),
4519
- data: null,
4520
- server_data: null
4521
- }],
4522
- fetched: [],
4523
- resolve_opts,
4524
- data_serializer: server_data_serializer(event, event_state, options)
4525
- });
4526
- if (remote_id) return await handle_remote_call(event, event_state, options, manifest, remote_id);
4527
- if (route) {
4528
- const method = event.request.method;
4529
- /** @type {Response} */
4530
- let response;
4531
- if (is_data_request) response = await render_data(event, event_state, route, options, manifest, state, invalidated_data_nodes, trailing_slash);
4532
- else if (route.endpoint && (!route.page || is_endpoint_request(event))) response = await render_endpoint(event, event_state, await route.endpoint(), state);
4533
- else if (route.page) if (!page_nodes) throw new Error("page_nodes not found. This should never happen");
4534
- else if (page_methods.has(method)) response = await render_page(event, event_state, route.page, options, manifest, state, page_nodes, resolve_opts);
4535
- else {
4536
- const allowed_methods = new Set(allowed_page_methods);
4537
- if ((await manifest._.nodes[route.page.leaf]())?.server?.actions) allowed_methods.add("POST");
4538
- if (method === "OPTIONS") response = new Response(null, {
4539
- status: 204,
4540
- headers: { allow: Array.from(allowed_methods.values()).join(", ") }
4541
- });
4542
- else response = method_not_allowed([...allowed_methods].reduce((acc, curr) => {
4543
- acc[curr] = true;
4544
- return acc;
4545
- }, {}), method);
4546
- }
4547
- else throw new Error("Route is neither page nor endpoint. This should never happen");
4548
- if (request.method === "GET" && route.page && route.endpoint) {
4549
- const vary = response.headers.get("vary")?.split(",")?.map((v) => v.trim().toLowerCase());
4550
- if (!(vary?.includes("accept") || vary?.includes("*"))) {
4551
- response = new Response(response.body, {
4552
- status: response.status,
4553
- statusText: response.statusText,
4554
- headers: new Headers(response.headers)
4555
- });
4556
- response.headers.append("Vary", "Accept");
4557
- }
4558
- }
4559
- return response;
4560
- }
4561
- if (state.error && event.isSubRequest) {
4562
- const headers = new Headers(request.headers);
4563
- headers.set("x-sveltekit-error", "true");
4564
- return await fetch(request, { headers });
4565
- }
4566
- if (state.error) return text("Internal Server Error", { status: 500 });
4567
- if (state.depth === 0) return await respond_with_error({
4568
- event,
4569
- event_state,
4570
- options,
4571
- manifest,
4572
- state,
4573
- status: 404,
4574
- error: new SvelteKitError(404, "Not Found", `Not found: ${event.url.pathname}`),
4575
- resolve_opts
4576
- });
4577
- if (state.prerendering) return text("not found", { status: 404 });
4578
- const response = await fetch(request);
4579
- return new Response(response.body, response);
4580
- } catch (e) {
4581
- return await handle_fatal_error(event, event_state, options, e);
4582
- } finally {
4583
- event.cookies.set = () => {
4584
- throw new Error("Cannot use `cookies.set(...)` after the response has been generated");
4585
- };
4586
- event.setHeaders = () => {
4587
- throw new Error("Cannot use `setHeaders(...)` after the response has been generated");
4588
- };
4589
- }
4590
- }
4591
- }
4592
- /**
4593
- * @param {import('types').PageNodeIndexes} page
4594
- * @param {import('@sveltejs/kit').SSRManifest} manifest
4595
- */
4596
- function load_page_nodes(page, manifest) {
4597
- return Promise.all([...page.layouts.map((n) => n == void 0 ? n : manifest._.nodes[n]()), manifest._.nodes[page.leaf]()]);
4598
- }
4599
- /**
4600
- * It's likely that, in a distributed system, there are spans starting outside the SvelteKit server -- eg.
4601
- * started on the frontend client, or in a service that calls the SvelteKit server. There are standardized
4602
- * ways to represent this context in HTTP headers, so we can extract that context and run our tracing inside of it
4603
- * so that when our traces are exported, they are associated with the correct parent context.
4604
- * @param {typeof internal_respond} fn
4605
- * @returns {typeof internal_respond}
4606
- */
4607
- function propagate_context(fn) {
4608
- return async (req, ...rest) => {
4609
- return fn(req, ...rest);
4610
- };
4611
- }
4612
- //#endregion
4613
- //#region ../../node_modules/@sveltejs/kit/src/utils/env.js
4614
- /**
4615
- * @param {Record<string, string>} env
4616
- * @param {string} allowed
4617
- * @param {string} disallowed
4618
- * @returns {Record<string, string>}
4619
- */
4620
- function filter_env(env, allowed, disallowed) {
4621
- return Object.fromEntries(Object.entries(env).filter(([k]) => k.startsWith(allowed) && (disallowed === "" || !k.startsWith(disallowed))));
4622
- }
4623
- /**
4624
- * @param {{ decoders: Record<string, (data: any) => any> }} value
4625
- */
4626
- function set_app(value) {}
4627
- //#endregion
4628
- //#region ../../node_modules/@sveltejs/kit/src/runtime/server/index.js
4629
- /** @import { PromiseWithResolvers } from '../../utils/promise.js' */
4630
- /** @type {Promise<any>} */
4631
- var init_promise;
4632
- /** @type {Promise<void> | null} */
4633
- var current = null;
4634
- var Server = class {
4635
- /** @type {import('types').SSROptions} */
4636
- #options;
4637
- /** @type {import('@sveltejs/kit').SSRManifest} */
4638
- #manifest;
4639
- /** @param {import('@sveltejs/kit').SSRManifest} manifest */
4640
- constructor(manifest) {
4641
- /** @type {import('types').SSROptions} */
4642
- this.#options = options;
4643
- this.#manifest = manifest;
4644
- if (IN_WEBCONTAINER) {
4645
- const respond = this.respond.bind(this);
4646
- /** @type {typeof respond} */
4647
- this.respond = async (...args) => {
4648
- const { promise, resolve } = with_resolvers();
4649
- const previous = current;
4650
- current = promise;
4651
- await previous;
4652
- return respond(...args).finally(resolve);
4653
- };
4654
- }
4655
- }
4656
- /**
4657
- * @param {import('@sveltejs/kit').ServerInitOptions} opts
4658
- */
4659
- async init({ env, read }) {
4660
- const { env_public_prefix, env_private_prefix } = this.#options;
4661
- set_private_env(filter_env(env, env_private_prefix, env_public_prefix));
4662
- set_public_env(filter_env(env, env_public_prefix, env_private_prefix));
4663
- if (read) {
4664
- /** @param {string} file */
4665
- const wrapped_read = (file) => {
4666
- const result = read(file);
4667
- if (result instanceof ReadableStream) return result;
4668
- else return new ReadableStream({ async start(controller) {
4669
- try {
4670
- const stream = await Promise.resolve(result);
4671
- if (!stream) {
4672
- controller.close();
4673
- return;
4674
- }
4675
- const reader = stream.getReader();
4676
- while (true) {
4677
- const { done, value } = await reader.read();
4678
- if (done) break;
4679
- controller.enqueue(value);
4680
- }
4681
- controller.close();
4682
- } catch (error) {
4683
- controller.error(error);
4684
- }
4685
- } });
4686
- };
4687
- set_read_implementation(wrapped_read);
4688
- }
4689
- await (init_promise ??= (async () => {
4690
- try {
4691
- const module = await get_hooks();
4692
- this.#options.hooks = {
4693
- handle: module.handle || (({ event, resolve }) => resolve(event)),
4694
- handleError: module.handleError || (({ status, error, event }) => {
4695
- const error_message = format_server_error(status, error, event);
4696
- console.error(error_message);
4697
- }),
4698
- handleFetch: module.handleFetch || (({ request, fetch }) => fetch(request)),
4699
- handleValidationError: module.handleValidationError || (({ issues }) => {
4700
- console.error("Remote function schema validation failed:", issues);
4701
- return { message: "Bad Request" };
4702
- }),
4703
- reroute: module.reroute || noop,
4704
- transport: module.transport || {}
4705
- };
4706
- set_app({ decoders: module.transport ? Object.fromEntries(Object.entries(module.transport).map(([k, v]) => [k, v.decode])) : {} });
4707
- if (module.init) await module.init();
4708
- } catch (e) {
4709
- throw e;
4710
- }
4711
- })());
4712
- }
4713
- /**
4714
- * @param {Request} request
4715
- * @param {import('types').RequestOptions} options
4716
- */
4717
- async respond(request, options) {
4718
- return respond(request, this.#options, this.#manifest, {
4719
- ...options,
4720
- error: false,
4721
- depth: 0
4722
- });
4723
- }
4724
- };
4725
-
4726
- export { Server as S, error as e };
4727
- //# sourceMappingURL=index-CNsiSQmW.js.map