@nanoforge-dev/editor 0.0.1

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