tanstack_start_ts 1.0.0

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 (336) hide show
  1. package/.wrangler/deploy/config.json +1 -0
  2. package/bunfig.toml +6 -0
  3. package/components.json +22 -0
  4. package/config.json +0 -0
  5. package/dist/client/.assetsignore +2 -0
  6. package/dist/client/assets/ProductCard-DbIkJAE-.js +1 -0
  7. package/dist/client/assets/about-AskxOruL.js +1 -0
  8. package/dist/client/assets/admin-BZVcAQM3.js +1 -0
  9. package/dist/client/assets/admin.functions--RdVcuBx.js +1 -0
  10. package/dist/client/assets/admin.login-QgrF_9Fp.js +1 -0
  11. package/dist/client/assets/affiliate-disclosure-BIAsA-HO.js +1 -0
  12. package/dist/client/assets/categories-D0N418mK.js +1 -0
  13. package/dist/client/assets/category._slug-aCaQm14E.js +1 -0
  14. package/dist/client/assets/contact-PhvO-V15.js +1 -0
  15. package/dist/client/assets/faq-BsiHWPM8.js +1 -0
  16. package/dist/client/assets/hero-bg-BP2eVUIX.jpg +0 -0
  17. package/dist/client/assets/index-BU9rnkF3.js +1 -0
  18. package/dist/client/assets/index-BpJWZkva.js +1 -0
  19. package/dist/client/assets/index-vRX-zAyq.js +1 -0
  20. package/dist/client/assets/login-DteE0ZGp.js +1 -0
  21. package/dist/client/assets/logo-pSNfLJQk.png +0 -0
  22. package/dist/client/assets/privacy-B_Pu7040.js +1 -0
  23. package/dist/client/assets/product-links-BkZ41Gv3.js +1 -0
  24. package/dist/client/assets/product._id-BVUysCW-.js +1 -0
  25. package/dist/client/assets/products.functions-cGzRziKO.js +1 -0
  26. package/dist/client/assets/profile-CveRcKq2.js +1 -0
  27. package/dist/client/assets/reset-password-ySEjItX_.js +1 -0
  28. package/dist/client/assets/saved-CHtdQDJF.js +1 -0
  29. package/dist/client/assets/search-CXWfET1y.js +1 -0
  30. package/dist/client/assets/signup-CEx90iuV.js +1 -0
  31. package/dist/client/assets/styles-DrNJG0BO.css +1 -0
  32. package/dist/client/assets/terms-VqJ9kX9b.js +1 -0
  33. package/dist/client/assets/update-password-C-d0ix5e.js +1 -0
  34. package/dist/client/assets/vendor-aria-hidden-DvXkyWUv.js +1 -0
  35. package/dist/client/assets/vendor-class-variance-authority-5VPnzWs2.js +1 -0
  36. package/dist/client/assets/vendor-clsx-B-dksMZM.js +1 -0
  37. package/dist/client/assets/vendor-cookie-es-CS0aJGDi.js +1 -0
  38. package/dist/client/assets/vendor-detect-node-es-l0sNRNKZ.js +1 -0
  39. package/dist/client/assets/vendor-floating-ui-core-BlUy28sp.js +1 -0
  40. package/dist/client/assets/vendor-floating-ui-dom-BxK0hn2R.js +1 -0
  41. package/dist/client/assets/vendor-floating-ui-react-dom-Bas3975S.js +1 -0
  42. package/dist/client/assets/vendor-floating-ui-utils-BfYUAVcw.js +1 -0
  43. package/dist/client/assets/vendor-framer-motion-BMdL-cuX.js +9 -0
  44. package/dist/client/assets/vendor-get-nonce-C-Z93AgS.js +1 -0
  45. package/dist/client/assets/vendor-iceberg-js-tWD4K6Lg.js +1 -0
  46. package/dist/client/assets/vendor-lovable.dev-cloud-auth-js-VuzqtJVg.js +1 -0
  47. package/dist/client/assets/vendor-lucide-react-b5K2fehp.js +1 -0
  48. package/dist/client/assets/vendor-motion-dom-BETJamZt.js +1 -0
  49. package/dist/client/assets/vendor-motion-utils-BuWewJbj.js +1 -0
  50. package/dist/client/assets/vendor-radix-ui-primitive-Dc_FVRD7.js +1 -0
  51. package/dist/client/assets/vendor-radix-ui-react-accordion-C22Rgxe9.js +1 -0
  52. package/dist/client/assets/vendor-radix-ui-react-arrow-DMHj2mKI.js +1 -0
  53. package/dist/client/assets/vendor-radix-ui-react-avatar-CVPBkFXg.js +1 -0
  54. package/dist/client/assets/vendor-radix-ui-react-collapsible-BvM-4sKX.js +1 -0
  55. package/dist/client/assets/vendor-radix-ui-react-collection-D9KtqmHm.js +1 -0
  56. package/dist/client/assets/vendor-radix-ui-react-compose-refs-Cvq0AS8Z.js +1 -0
  57. package/dist/client/assets/vendor-radix-ui-react-context-CAqqn5Nx.js +1 -0
  58. package/dist/client/assets/vendor-radix-ui-react-dialog-DZ01vOLq.js +5 -0
  59. package/dist/client/assets/vendor-radix-ui-react-direction-DxZwNuei.js +1 -0
  60. package/dist/client/assets/vendor-radix-ui-react-dismissable-layer-Dqgrs55Y.js +1 -0
  61. package/dist/client/assets/vendor-radix-ui-react-dropdown-menu-0uzvrqkn.js +1 -0
  62. package/dist/client/assets/vendor-radix-ui-react-focus-guards-DgWoZ-fP.js +1 -0
  63. package/dist/client/assets/vendor-radix-ui-react-focus-scope-BLIu5QaL.js +1 -0
  64. package/dist/client/assets/vendor-radix-ui-react-id-bpga_rLa.js +1 -0
  65. package/dist/client/assets/vendor-radix-ui-react-menu-D0qf2r6_.js +1 -0
  66. package/dist/client/assets/vendor-radix-ui-react-popper-BafIylxU.js +1 -0
  67. package/dist/client/assets/vendor-radix-ui-react-portal-BnAsfNCS.js +1 -0
  68. package/dist/client/assets/vendor-radix-ui-react-presence-C-f3UKQ2.js +1 -0
  69. package/dist/client/assets/vendor-radix-ui-react-primitive-zTHwXNoz.js +1 -0
  70. package/dist/client/assets/vendor-radix-ui-react-roving-focus-jyJB8K2E.js +1 -0
  71. package/dist/client/assets/vendor-radix-ui-react-slot-6LXHJrHl.js +1 -0
  72. package/dist/client/assets/vendor-radix-ui-react-use-callback-ref-E91aPc6s.js +1 -0
  73. package/dist/client/assets/vendor-radix-ui-react-use-controllable-state-Ca3eMtxa.js +1 -0
  74. package/dist/client/assets/vendor-radix-ui-react-use-effect-event-CPeX4A3c.js +1 -0
  75. package/dist/client/assets/vendor-radix-ui-react-use-escape-keydown-7n3YsXFo.js +1 -0
  76. package/dist/client/assets/vendor-radix-ui-react-use-is-hydrated-C1PY1qNv.js +1 -0
  77. package/dist/client/assets/vendor-radix-ui-react-use-layout-effect-B3AcGWPy.js +1 -0
  78. package/dist/client/assets/vendor-radix-ui-react-use-size-CXS04sct.js +1 -0
  79. package/dist/client/assets/vendor-react-dom-BnNs-kzm.js +9 -0
  80. package/dist/client/assets/vendor-react-gJPiVnX5.js +1 -0
  81. package/dist/client/assets/vendor-react-remove-scroll-DHKl-IMP.js +4 -0
  82. package/dist/client/assets/vendor-react-remove-scroll-bar-CSjdInc2.js +38 -0
  83. package/dist/client/assets/vendor-react-style-singleton-BqHpkgXn.js +1 -0
  84. package/dist/client/assets/vendor-scheduler-7OC5HNn7.js +1 -0
  85. package/dist/client/assets/vendor-seroval-B_Fur-nl.js +3 -0
  86. package/dist/client/assets/vendor-seroval-plugins-CBHnPkZJ.js +1 -0
  87. package/dist/client/assets/vendor-sonner-71-LdGG1.js +1 -0
  88. package/dist/client/assets/vendor-supabase-auth-js-DWrN-bIx.js +18 -0
  89. package/dist/client/assets/vendor-supabase-functions-js-uY_V-TxC.js +1 -0
  90. package/dist/client/assets/vendor-supabase-phoenix-BzEf37Ve.js +2 -0
  91. package/dist/client/assets/vendor-supabase-postgrest-js-C4rBWbCx.js +4 -0
  92. package/dist/client/assets/vendor-supabase-realtime-js-D6BlOYKE.js +23 -0
  93. package/dist/client/assets/vendor-supabase-storage-js-BG98L3Zz.js +1 -0
  94. package/dist/client/assets/vendor-supabase-supabase-js-DCCzdwBJ.js +1 -0
  95. package/dist/client/assets/vendor-tailwind-merge-Ct12j0u0.js +1 -0
  96. package/dist/client/assets/vendor-tanstack-history-C617CaxG.js +1 -0
  97. package/dist/client/assets/vendor-tanstack-query-core-7wuJJ5ZL.js +1 -0
  98. package/dist/client/assets/vendor-tanstack-react-query-HImzo8sX.js +1 -0
  99. package/dist/client/assets/vendor-tanstack-react-router-sIZLK-LU.js +1 -0
  100. package/dist/client/assets/vendor-tanstack-react-start-client-GiYCfWmf.js +1 -0
  101. package/dist/client/assets/vendor-tanstack-react-store-EvTi3ahh.js +1 -0
  102. package/dist/client/assets/vendor-tanstack-router-core-Cr7bYUZv.js +1 -0
  103. package/dist/client/assets/vendor-tanstack-start-client-core-C-00BBOu.js +2 -0
  104. package/dist/client/assets/vendor-tanstack-start-fn-stubs-l0sNRNKZ.js +1 -0
  105. package/dist/client/assets/vendor-tanstack-store-BC7mA7pq.js +1 -0
  106. package/dist/client/assets/vendor-tslib-Du-meQkk.js +1 -0
  107. package/dist/client/assets/vendor-use-callback-ref-C_fIAtot.js +1 -0
  108. package/dist/client/assets/vendor-use-sidecar-Bh0DDN6h.js +1 -0
  109. package/dist/client/assets/vendor-use-sync-external-store-ZvKHXaIn.js +1 -0
  110. package/dist/client/assets/vendor-vercel-analytics-DwPM5BWs.js +1 -0
  111. package/dist/client/assets/vendor-zod-By9teAtI.js +1 -0
  112. package/dist/client/robots.txt +2 -0
  113. package/dist/server/.dev.vars +5 -0
  114. package/dist/server/.vite/manifest.json +2528 -0
  115. package/dist/server/assets/ProductCard-CUPXy5Eo.js +149 -0
  116. package/dist/server/assets/_tanstack-start-manifest_v-do7vTWFD.js +4 -0
  117. package/dist/server/assets/about-TfKQw0Ga.js +28 -0
  118. package/dist/server/assets/admin-DspfJOJk.js +578 -0
  119. package/dist/server/assets/admin.functions-B78ppWLR.js +645 -0
  120. package/dist/server/assets/admin.functions-BWlKBoTL.js +93 -0
  121. package/dist/server/assets/admin.login-CV7QfeA6.js +139 -0
  122. package/dist/server/assets/affiliate-disclosure-B1wI1cDb.js +86 -0
  123. package/dist/server/assets/auth-middleware-Cn49MidW.js +62 -0
  124. package/dist/server/assets/categories-Z7jnAYZP.js +108 -0
  125. package/dist/server/assets/category._slug-D0XY3FGK.js +112 -0
  126. package/dist/server/assets/contact-IzyONsXs.js +104 -0
  127. package/dist/server/assets/faq-aRhB_CR3.js +133 -0
  128. package/dist/server/assets/hero-bg-BP2eVUIX.jpg +0 -0
  129. package/dist/server/assets/index-BTPHbXw9.js +221 -0
  130. package/dist/server/assets/index-ByJkHkrU.js +30 -0
  131. package/dist/server/assets/login-Dvy5Dm0f.js +175 -0
  132. package/dist/server/assets/logo-pSNfLJQk.png +0 -0
  133. package/dist/server/assets/privacy-B6Wiez1P.js +93 -0
  134. package/dist/server/assets/product-links-CGYEPP56.js +16 -0
  135. package/dist/server/assets/product._id-BpRa-1z0.js +231 -0
  136. package/dist/server/assets/products.functions-DSlmibYN.js +209 -0
  137. package/dist/server/assets/products.functions-DlHkRiqi.js +24 -0
  138. package/dist/server/assets/profile-B0NWzVAZ.js +314 -0
  139. package/dist/server/assets/reset-password-CY-rmqMr.js +115 -0
  140. package/dist/server/assets/saved-7FA6Dbom.js +126 -0
  141. package/dist/server/assets/search-Yw5c_fZa.js +329 -0
  142. package/dist/server/assets/signup-UPzgZo4i.js +143 -0
  143. package/dist/server/assets/styles-DrNJG0BO.css +1 -0
  144. package/dist/server/assets/terms-CMnX95bP.js +89 -0
  145. package/dist/server/assets/update-password-Cr94ea8n.js +131 -0
  146. package/dist/server/assets/vendor-aria-hidden-DPa16MWu.js +122 -0
  147. package/dist/server/assets/vendor-class-variance-authority-0YxJPB9Y.js +44 -0
  148. package/dist/server/assets/vendor-cloudflare-unenv-preset-ya0VEFBz.js +250 -0
  149. package/dist/server/assets/vendor-clsx-DgYk2OaC.js +16 -0
  150. package/dist/server/assets/vendor-cookie-es-DAoofYiI.js +44 -0
  151. package/dist/server/assets/vendor-detect-node-es-l0sNRNKZ.js +1 -0
  152. package/dist/server/assets/vendor-floating-ui-core-3tkK0THV.js +726 -0
  153. package/dist/server/assets/vendor-floating-ui-dom-C-cPtgJv.js +626 -0
  154. package/dist/server/assets/vendor-floating-ui-react-dom-CRG6gBpH.js +319 -0
  155. package/dist/server/assets/vendor-floating-ui-utils-DmXANH-E.js +320 -0
  156. package/dist/server/assets/vendor-framer-motion-X4zAkX3J.js +1979 -0
  157. package/dist/server/assets/vendor-get-nonce-DiSj3EHl.js +9 -0
  158. package/dist/server/assets/vendor-h3-v2-CCobnLY5.js +287 -0
  159. package/dist/server/assets/vendor-iceberg-js-bHCkXyJn.js +534 -0
  160. package/dist/server/assets/vendor-isbot-CZ7WjwVs.js +21 -0
  161. package/dist/server/assets/vendor-lovable.dev-cloud-auth-js-BE03njZw.js +180 -0
  162. package/dist/server/assets/vendor-lucide-react-Ddew6HYb.js +458 -0
  163. package/dist/server/assets/vendor-motion-dom-D2MTwGIG.js +5983 -0
  164. package/dist/server/assets/vendor-motion-utils-LJlIFN6m.js +161 -0
  165. package/dist/server/assets/vendor-radix-ui-primitive-B-mNdDrH.js +11 -0
  166. package/dist/server/assets/vendor-radix-ui-react-accordion-1Izf6x00.js +308 -0
  167. package/dist/server/assets/vendor-radix-ui-react-arrow-B882lnFK.js +23 -0
  168. package/dist/server/assets/vendor-radix-ui-react-avatar-BVgZt2Ab.js +209 -0
  169. package/dist/server/assets/vendor-radix-ui-react-collapsible-DCBbMZiS.js +147 -0
  170. package/dist/server/assets/vendor-radix-ui-react-collection-BZ2srfgU.js +150 -0
  171. package/dist/server/assets/vendor-radix-ui-react-compose-refs-D3qsKVk1.js +39 -0
  172. package/dist/server/assets/vendor-radix-ui-react-context-BVoNDLue.js +78 -0
  173. package/dist/server/assets/vendor-radix-ui-react-dialog-DlxMaNYK.js +406 -0
  174. package/dist/server/assets/vendor-radix-ui-react-direction-Dt_WDL1t.js +9 -0
  175. package/dist/server/assets/vendor-radix-ui-react-dismissable-layer-CjsuPohV.js +210 -0
  176. package/dist/server/assets/vendor-radix-ui-react-dropdown-menu-DVxKumY8.js +263 -0
  177. package/dist/server/assets/vendor-radix-ui-react-focus-guards-D_6NoePE.js +29 -0
  178. package/dist/server/assets/vendor-radix-ui-react-focus-scope-DEIhTJJH.js +206 -0
  179. package/dist/server/assets/vendor-radix-ui-react-id-DFFpgh6m.js +14 -0
  180. package/dist/server/assets/vendor-radix-ui-react-menu-CiTMLwjT.js +893 -0
  181. package/dist/server/assets/vendor-radix-ui-react-popper-23Ye2Vyc.js +286 -0
  182. package/dist/server/assets/vendor-radix-ui-react-portal-CZCH5uPk.js +16 -0
  183. package/dist/server/assets/vendor-radix-ui-react-presence-CaAULlDU.js +128 -0
  184. package/dist/server/assets/vendor-radix-ui-react-primitive-BeOk3UYa.js +124 -0
  185. package/dist/server/assets/vendor-radix-ui-react-roving-focus-DES9GR8l.js +224 -0
  186. package/dist/server/assets/vendor-radix-ui-react-slot-DUhZbzoH.js +103 -0
  187. package/dist/server/assets/vendor-radix-ui-react-use-callback-ref-BynBgohw.js +11 -0
  188. package/dist/server/assets/vendor-radix-ui-react-use-controllable-state-C9KpT6DG.js +69 -0
  189. package/dist/server/assets/vendor-radix-ui-react-use-effect-event-gpNY2xjS.js +1 -0
  190. package/dist/server/assets/vendor-radix-ui-react-use-escape-keydown-CcYRQ2pp.js +17 -0
  191. package/dist/server/assets/vendor-radix-ui-react-use-is-hydrated-D_LcBPXY.js +15 -0
  192. package/dist/server/assets/vendor-radix-ui-react-use-layout-effect-1LNLXAjr.js +6 -0
  193. package/dist/server/assets/vendor-radix-ui-react-use-size-D6fiKJQo.js +39 -0
  194. package/dist/server/assets/vendor-react-DvBrY0qp.js +511 -0
  195. package/dist/server/assets/vendor-react-dom-yvMLPM0j.js +10484 -0
  196. package/dist/server/assets/vendor-react-remove-scroll-BNtiEvVN.js +328 -0
  197. package/dist/server/assets/vendor-react-remove-scroll-bar-hLqRASRk.js +82 -0
  198. package/dist/server/assets/vendor-react-style-singleton-BXjcXskB.js +69 -0
  199. package/dist/server/assets/vendor-rou3-3NaGPdI8.js +8 -0
  200. package/dist/server/assets/vendor-seroval-dJyC-Zhz.js +1775 -0
  201. package/dist/server/assets/vendor-seroval-plugins-Pq_U2meB.js +58 -0
  202. package/dist/server/assets/vendor-sonner-CqbjhsRh.js +1086 -0
  203. package/dist/server/assets/vendor-srvx-BA-baEX9.js +6 -0
  204. package/dist/server/assets/vendor-supabase-auth-js-D4xjVprw.js +7602 -0
  205. package/dist/server/assets/vendor-supabase-functions-js-sWy4UYn1.js +322 -0
  206. package/dist/server/assets/vendor-supabase-phoenix-Bw3Uh2Nn.js +1777 -0
  207. package/dist/server/assets/vendor-supabase-postgrest-js-AO-BXa7I.js +4938 -0
  208. package/dist/server/assets/vendor-supabase-realtime-js-BtdNgJbm.js +2111 -0
  209. package/dist/server/assets/vendor-supabase-storage-js-Dk_MrPYO.js +2679 -0
  210. package/dist/server/assets/vendor-supabase-supabase-js-D1EEtG3j.js +697 -0
  211. package/dist/server/assets/vendor-tailwind-merge-BHb_obmC.js +3255 -0
  212. package/dist/server/assets/vendor-tanstack-history-C4pKJmkt.js +204 -0
  213. package/dist/server/assets/vendor-tanstack-query-core-PwwTR5ld.js +2552 -0
  214. package/dist/server/assets/vendor-tanstack-react-query-hhHzXAK1.js +190 -0
  215. package/dist/server/assets/vendor-tanstack-react-router-XzqpA65A.js +1120 -0
  216. package/dist/server/assets/vendor-tanstack-react-start-RvWUpvat.js +37 -0
  217. package/dist/server/assets/vendor-tanstack-react-start-client-gpNY2xjS.js +1 -0
  218. package/dist/server/assets/vendor-tanstack-react-start-server-uj_Y9pEN.js +15 -0
  219. package/dist/server/assets/vendor-tanstack-react-store-gpNY2xjS.js +1 -0
  220. package/dist/server/assets/vendor-tanstack-router-core-6wywV3KN.js +4252 -0
  221. package/dist/server/assets/vendor-tanstack-start-client-core-DoOKV2pA.js +1741 -0
  222. package/dist/server/assets/vendor-tanstack-start-fn-stubs-l0sNRNKZ.js +1 -0
  223. package/dist/server/assets/vendor-tanstack-start-server-core-CsAstXv7.js +1421 -0
  224. package/dist/server/assets/vendor-tanstack-start-storage-context-DgH9hIJT.js +17 -0
  225. package/dist/server/assets/vendor-tanstack-store-l0sNRNKZ.js +1 -0
  226. package/dist/server/assets/vendor-tslib-_8ICaZ64.js +67 -0
  227. package/dist/server/assets/vendor-unenv-DUvF4YIF.js +544 -0
  228. package/dist/server/assets/vendor-use-callback-ref-DMFDRvmi.js +66 -0
  229. package/dist/server/assets/vendor-use-sidecar-DG1tHua4.js +106 -0
  230. package/dist/server/assets/vendor-use-sync-external-store-rZ8vi0It.js +64 -0
  231. package/dist/server/assets/vendor-vercel-analytics-oP8BDp0L.js +168 -0
  232. package/dist/server/assets/vendor-zod-BRyQdbC-.js +3580 -0
  233. package/dist/server/index.js +158 -0
  234. package/dist/server/wrangler.json +1 -0
  235. package/enable-powershell.ps1 +7 -0
  236. package/eslint.config.js +41 -0
  237. package/lint.bat +4 -0
  238. package/package.json +95 -0
  239. package/public/robots.txt +2 -0
  240. package/run-npm-build.cjs +20 -0
  241. package/run-npm-build.js +20 -0
  242. package/src/assets/hero-bg.jpg +0 -0
  243. package/src/assets/logo.png +0 -0
  244. package/src/components/scrollsy/Footer.tsx +68 -0
  245. package/src/components/scrollsy/LiveTicker.tsx +31 -0
  246. package/src/components/scrollsy/Logo.tsx +28 -0
  247. package/src/components/scrollsy/Nav.tsx +255 -0
  248. package/src/components/scrollsy/ProductCard.tsx +190 -0
  249. package/src/components/scrollsy/ProductFilters.tsx +226 -0
  250. package/src/components/scrollsy/SupportWidget.tsx +197 -0
  251. package/src/components/ui/accordion.tsx +51 -0
  252. package/src/components/ui/alert-dialog.tsx +115 -0
  253. package/src/components/ui/alert.tsx +49 -0
  254. package/src/components/ui/aspect-ratio.tsx +5 -0
  255. package/src/components/ui/avatar.tsx +47 -0
  256. package/src/components/ui/badge.tsx +32 -0
  257. package/src/components/ui/breadcrumb.tsx +101 -0
  258. package/src/components/ui/button.tsx +49 -0
  259. package/src/components/ui/calendar.tsx +177 -0
  260. package/src/components/ui/card.tsx +55 -0
  261. package/src/components/ui/carousel.tsx +240 -0
  262. package/src/components/ui/chart.tsx +331 -0
  263. package/src/components/ui/checkbox.tsx +26 -0
  264. package/src/components/ui/collapsible.tsx +11 -0
  265. package/src/components/ui/command.tsx +143 -0
  266. package/src/components/ui/context-menu.tsx +187 -0
  267. package/src/components/ui/dialog.tsx +104 -0
  268. package/src/components/ui/drawer.tsx +98 -0
  269. package/src/components/ui/dropdown-menu.tsx +188 -0
  270. package/src/components/ui/form.tsx +171 -0
  271. package/src/components/ui/hover-card.tsx +27 -0
  272. package/src/components/ui/input-otp.tsx +69 -0
  273. package/src/components/ui/input.tsx +22 -0
  274. package/src/components/ui/label.tsx +21 -0
  275. package/src/components/ui/menubar.tsx +229 -0
  276. package/src/components/ui/navigation-menu.tsx +120 -0
  277. package/src/components/ui/pagination.tsx +98 -0
  278. package/src/components/ui/popover.tsx +31 -0
  279. package/src/components/ui/progress.tsx +25 -0
  280. package/src/components/ui/radio-group.tsx +36 -0
  281. package/src/components/ui/resizable.tsx +37 -0
  282. package/src/components/ui/scroll-area.tsx +44 -0
  283. package/src/components/ui/select.tsx +152 -0
  284. package/src/components/ui/separator.tsx +24 -0
  285. package/src/components/ui/sheet.tsx +122 -0
  286. package/src/components/ui/sidebar.tsx +744 -0
  287. package/src/components/ui/skeleton.tsx +7 -0
  288. package/src/components/ui/slider.tsx +23 -0
  289. package/src/components/ui/sonner.tsx +23 -0
  290. package/src/components/ui/switch.tsx +27 -0
  291. package/src/components/ui/table.tsx +94 -0
  292. package/src/components/ui/tabs.tsx +53 -0
  293. package/src/components/ui/textarea.tsx +21 -0
  294. package/src/components/ui/toggle-group.tsx +57 -0
  295. package/src/components/ui/toggle.tsx +42 -0
  296. package/src/components/ui/tooltip.tsx +32 -0
  297. package/src/hooks/use-auth.ts +26 -0
  298. package/src/hooks/use-mobile.tsx +19 -0
  299. package/src/integrations/lovable/index.ts +41 -0
  300. package/src/lib/admin.functions.ts +564 -0
  301. package/src/lib/error-capture.ts +27 -0
  302. package/src/lib/error-page.ts +30 -0
  303. package/src/lib/product-links.ts +39 -0
  304. package/src/lib/products.functions.ts +101 -0
  305. package/src/lib/utils.ts +6 -0
  306. package/src/routeTree.gen.ts +480 -0
  307. package/src/router.tsx +16 -0
  308. package/src/routes/__root.tsx +177 -0
  309. package/src/routes/about.tsx +66 -0
  310. package/src/routes/admin.login.tsx +95 -0
  311. package/src/routes/admin.tsx +811 -0
  312. package/src/routes/affiliate-disclosure.tsx +35 -0
  313. package/src/routes/categories.tsx +57 -0
  314. package/src/routes/category.$slug.tsx +51 -0
  315. package/src/routes/contact.tsx +69 -0
  316. package/src/routes/faq.tsx +63 -0
  317. package/src/routes/index.tsx +269 -0
  318. package/src/routes/login.tsx +160 -0
  319. package/src/routes/privacy.tsx +39 -0
  320. package/src/routes/product.$id.tsx +212 -0
  321. package/src/routes/profile.tsx +393 -0
  322. package/src/routes/reset-password.tsx +71 -0
  323. package/src/routes/saved.tsx +83 -0
  324. package/src/routes/search.tsx +136 -0
  325. package/src/routes/signup.tsx +108 -0
  326. package/src/routes/sitemap[.]xml.ts +34 -0
  327. package/src/routes/terms.tsx +40 -0
  328. package/src/routes/update-password.tsx +91 -0
  329. package/src/server.ts +80 -0
  330. package/src/start.ts +24 -0
  331. package/src/styles.css +333 -0
  332. package/terminal-test-output.txt +1 -0
  333. package/tsconfig.json +27 -0
  334. package/vercel.json +26 -0
  335. package/vite.config.ts +38 -0
  336. package/wrangler.jsonc +7 -0
@@ -0,0 +1,4252 @@
1
+ import { p as parseHref } from "./vendor-tanstack-history-C4pKJmkt.js";
2
+ import { a as ai, r as re, S as Sn, d as dn } from "./vendor-seroval-dJyC-Zhz.js";
3
+ import { p } from "./vendor-seroval-plugins-Pq_U2meB.js";
4
+ import { s as splitSetCookieString } from "./vendor-cookie-es-DAoofYiI.js";
5
+ import { ReadableStream as ReadableStream$1 } from "node:stream/web";
6
+ import { Readable } from "node:stream";
7
+ const isServer = true;
8
+ function last(arr) {
9
+ return arr[arr.length - 1];
10
+ }
11
+ function isFunction(d) {
12
+ return typeof d === "function";
13
+ }
14
+ function functionalUpdate(updater, previous) {
15
+ if (isFunction(updater)) return updater(previous);
16
+ return updater;
17
+ }
18
+ const hasOwn = Object.prototype.hasOwnProperty;
19
+ function hasKeys(obj) {
20
+ for (const key in obj) if (hasOwn.call(obj, key)) return true;
21
+ return false;
22
+ }
23
+ const createNull = () => /* @__PURE__ */ Object.create(null);
24
+ const nullReplaceEqualDeep = (prev, next) => replaceEqualDeep(prev, next, createNull);
25
+ function replaceEqualDeep(prev, _next, _makeObj = () => ({}), _depth = 0) {
26
+ return _next;
27
+ }
28
+ function isPlainObject(o) {
29
+ if (!hasObjectPrototype(o)) return false;
30
+ const ctor = o.constructor;
31
+ if (typeof ctor === "undefined") return true;
32
+ const prot = ctor.prototype;
33
+ if (!hasObjectPrototype(prot)) return false;
34
+ if (!prot.hasOwnProperty("isPrototypeOf")) return false;
35
+ return true;
36
+ }
37
+ function hasObjectPrototype(o) {
38
+ return Object.prototype.toString.call(o) === "[object Object]";
39
+ }
40
+ function deepEqual(a, b, opts) {
41
+ if (a === b) return true;
42
+ if (typeof a !== typeof b) return false;
43
+ if (Array.isArray(a) && Array.isArray(b)) {
44
+ if (a.length !== b.length) return false;
45
+ for (let i = 0, l = a.length; i < l; i++) if (!deepEqual(a[i], b[i], opts)) return false;
46
+ return true;
47
+ }
48
+ if (isPlainObject(a) && isPlainObject(b)) {
49
+ const ignoreUndefined = opts?.ignoreUndefined ?? true;
50
+ if (opts?.partial) {
51
+ for (const k in b) if (!ignoreUndefined || b[k] !== void 0) {
52
+ if (!deepEqual(a[k], b[k], opts)) return false;
53
+ }
54
+ return true;
55
+ }
56
+ let aCount = 0;
57
+ if (!ignoreUndefined) aCount = Object.keys(a).length;
58
+ else for (const k in a) if (a[k] !== void 0) aCount++;
59
+ let bCount = 0;
60
+ for (const k in b) if (!ignoreUndefined || b[k] !== void 0) {
61
+ bCount++;
62
+ if (bCount > aCount || !deepEqual(a[k], b[k], opts)) return false;
63
+ }
64
+ return aCount === bCount;
65
+ }
66
+ return false;
67
+ }
68
+ function createControlledPromise(onResolve) {
69
+ let resolveLoadPromise;
70
+ let rejectLoadPromise;
71
+ const controlledPromise = new Promise((resolve, reject) => {
72
+ resolveLoadPromise = resolve;
73
+ rejectLoadPromise = reject;
74
+ });
75
+ controlledPromise.status = "pending";
76
+ controlledPromise.resolve = (value) => {
77
+ controlledPromise.status = "resolved";
78
+ controlledPromise.value = value;
79
+ resolveLoadPromise(value);
80
+ onResolve?.(value);
81
+ };
82
+ controlledPromise.reject = (e) => {
83
+ controlledPromise.status = "rejected";
84
+ rejectLoadPromise(e);
85
+ };
86
+ return controlledPromise;
87
+ }
88
+ function isModuleNotFoundError(error) {
89
+ if (typeof error?.message !== "string") return false;
90
+ return error.message.startsWith("Failed to fetch dynamically imported module") || error.message.startsWith("error loading dynamically imported module") || error.message.startsWith("Importing a module script failed");
91
+ }
92
+ function isPromise(value) {
93
+ return Boolean(value && typeof value === "object" && typeof value.then === "function");
94
+ }
95
+ function sanitizePathSegment(segment) {
96
+ return segment.replace(/[\x00-\x1f\x7f]/g, "");
97
+ }
98
+ function decodeSegment(segment) {
99
+ let decoded;
100
+ try {
101
+ decoded = decodeURI(segment);
102
+ } catch {
103
+ decoded = segment.replaceAll(/%[0-9A-F]{2}/gi, (match) => {
104
+ try {
105
+ return decodeURI(match);
106
+ } catch {
107
+ return match;
108
+ }
109
+ });
110
+ }
111
+ return sanitizePathSegment(decoded);
112
+ }
113
+ const DEFAULT_PROTOCOL_ALLOWLIST = [
114
+ "http:",
115
+ "https:",
116
+ "mailto:",
117
+ "tel:"
118
+ ];
119
+ function isDangerousProtocol(url, allowlist) {
120
+ if (!url) return false;
121
+ try {
122
+ const parsed = new URL(url);
123
+ return !allowlist.has(parsed.protocol);
124
+ } catch {
125
+ return false;
126
+ }
127
+ }
128
+ const HTML_ESCAPE_LOOKUP = {
129
+ "&": "\\u0026",
130
+ ">": "\\u003e",
131
+ "<": "\\u003c",
132
+ "\u2028": "\\u2028",
133
+ "\u2029": "\\u2029"
134
+ };
135
+ const HTML_ESCAPE_REGEX = /[&><\u2028\u2029]/g;
136
+ function escapeHtml(str) {
137
+ return str.replace(HTML_ESCAPE_REGEX, (match) => HTML_ESCAPE_LOOKUP[match]);
138
+ }
139
+ function decodePath(path) {
140
+ if (!path) return {
141
+ path,
142
+ handledProtocolRelativeURL: false
143
+ };
144
+ if (!/[%\\\x00-\x1f\x7f]/.test(path) && !path.startsWith("//")) return {
145
+ path,
146
+ handledProtocolRelativeURL: false
147
+ };
148
+ const re2 = /%25|%5C/gi;
149
+ let cursor = 0;
150
+ let result = "";
151
+ let match;
152
+ while (null !== (match = re2.exec(path))) {
153
+ result += decodeSegment(path.slice(cursor, match.index)) + match[0];
154
+ cursor = re2.lastIndex;
155
+ }
156
+ result = result + decodeSegment(cursor ? path.slice(cursor) : path);
157
+ let handledProtocolRelativeURL = false;
158
+ if (result.startsWith("//")) {
159
+ handledProtocolRelativeURL = true;
160
+ result = "/" + result.replace(/^\/+/, "");
161
+ }
162
+ return {
163
+ path: result,
164
+ handledProtocolRelativeURL
165
+ };
166
+ }
167
+ function encodePathLikeUrl(path) {
168
+ if (!/\s|[^\u0000-\u007F]/.test(path)) return path;
169
+ return path.replace(/\s|[^\u0000-\u007F]/gu, encodeURIComponent);
170
+ }
171
+ function arraysEqual(a, b) {
172
+ if (a === b) return true;
173
+ if (a.length !== b.length) return false;
174
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
175
+ return true;
176
+ }
177
+ function invariant() {
178
+ throw new Error("Invariant failed");
179
+ }
180
+ function createLRUCache(max) {
181
+ const cache = /* @__PURE__ */ new Map();
182
+ let oldest;
183
+ let newest;
184
+ const touch = (entry) => {
185
+ if (!entry.next) return;
186
+ if (!entry.prev) {
187
+ entry.next.prev = void 0;
188
+ oldest = entry.next;
189
+ entry.next = void 0;
190
+ if (newest) {
191
+ entry.prev = newest;
192
+ newest.next = entry;
193
+ }
194
+ } else {
195
+ entry.prev.next = entry.next;
196
+ entry.next.prev = entry.prev;
197
+ entry.next = void 0;
198
+ if (newest) {
199
+ newest.next = entry;
200
+ entry.prev = newest;
201
+ }
202
+ }
203
+ newest = entry;
204
+ };
205
+ return {
206
+ get(key) {
207
+ const entry = cache.get(key);
208
+ if (!entry) return void 0;
209
+ touch(entry);
210
+ return entry.value;
211
+ },
212
+ set(key, value) {
213
+ if (cache.size >= max && oldest) {
214
+ const toDelete = oldest;
215
+ cache.delete(toDelete.key);
216
+ if (toDelete.next) {
217
+ oldest = toDelete.next;
218
+ toDelete.next.prev = void 0;
219
+ }
220
+ if (toDelete === newest) newest = void 0;
221
+ }
222
+ const existing = cache.get(key);
223
+ if (existing) {
224
+ existing.value = value;
225
+ touch(existing);
226
+ } else {
227
+ const entry = {
228
+ key,
229
+ value,
230
+ prev: newest
231
+ };
232
+ if (newest) newest.next = entry;
233
+ newest = entry;
234
+ if (!oldest) oldest = entry;
235
+ cache.set(key, entry);
236
+ }
237
+ },
238
+ clear() {
239
+ cache.clear();
240
+ oldest = void 0;
241
+ newest = void 0;
242
+ }
243
+ };
244
+ }
245
+ const SEGMENT_TYPE_INDEX = 4;
246
+ const SEGMENT_TYPE_PATHLESS = 5;
247
+ function getOpenAndCloseBraces(part) {
248
+ const openBrace = part.indexOf("{");
249
+ if (openBrace === -1) return null;
250
+ const closeBrace = part.indexOf("}", openBrace);
251
+ if (closeBrace === -1) return null;
252
+ if (openBrace + 1 >= part.length) return null;
253
+ return [openBrace, closeBrace];
254
+ }
255
+ function parseSegment(path, start, output = new Uint16Array(6)) {
256
+ const next = path.indexOf("/", start);
257
+ const end = next === -1 ? path.length : next;
258
+ const part = path.substring(start, end);
259
+ if (!part || !part.includes("$")) {
260
+ output[0] = 0;
261
+ output[1] = start;
262
+ output[2] = start;
263
+ output[3] = end;
264
+ output[4] = end;
265
+ output[5] = end;
266
+ return output;
267
+ }
268
+ if (part === "$") {
269
+ const total = path.length;
270
+ output[0] = 2;
271
+ output[1] = start;
272
+ output[2] = start;
273
+ output[3] = total;
274
+ output[4] = total;
275
+ output[5] = total;
276
+ return output;
277
+ }
278
+ if (part.charCodeAt(0) === 36) {
279
+ output[0] = 1;
280
+ output[1] = start;
281
+ output[2] = start + 1;
282
+ output[3] = end;
283
+ output[4] = end;
284
+ output[5] = end;
285
+ return output;
286
+ }
287
+ const braces = getOpenAndCloseBraces(part);
288
+ if (braces) {
289
+ const [openBrace, closeBrace] = braces;
290
+ const firstChar = part.charCodeAt(openBrace + 1);
291
+ if (firstChar === 45) {
292
+ if (openBrace + 2 < part.length && part.charCodeAt(openBrace + 2) === 36) {
293
+ const paramStart = openBrace + 3;
294
+ const paramEnd = closeBrace;
295
+ if (paramStart < paramEnd) {
296
+ output[0] = 3;
297
+ output[1] = start + openBrace;
298
+ output[2] = start + paramStart;
299
+ output[3] = start + paramEnd;
300
+ output[4] = start + closeBrace + 1;
301
+ output[5] = end;
302
+ return output;
303
+ }
304
+ }
305
+ } else if (firstChar === 36) {
306
+ const dollarPos = openBrace + 1;
307
+ const afterDollar = openBrace + 2;
308
+ if (afterDollar === closeBrace) {
309
+ output[0] = 2;
310
+ output[1] = start + openBrace;
311
+ output[2] = start + dollarPos;
312
+ output[3] = start + afterDollar;
313
+ output[4] = start + closeBrace + 1;
314
+ output[5] = path.length;
315
+ return output;
316
+ }
317
+ output[0] = 1;
318
+ output[1] = start + openBrace;
319
+ output[2] = start + afterDollar;
320
+ output[3] = start + closeBrace;
321
+ output[4] = start + closeBrace + 1;
322
+ output[5] = end;
323
+ return output;
324
+ }
325
+ }
326
+ output[0] = 0;
327
+ output[1] = start;
328
+ output[2] = start;
329
+ output[3] = end;
330
+ output[4] = end;
331
+ output[5] = end;
332
+ return output;
333
+ }
334
+ function parseSegments(defaultCaseSensitive, data, route, start, node, depth, onRoute) {
335
+ onRoute?.(route);
336
+ let cursor = start;
337
+ {
338
+ const path = route.fullPath ?? route.from;
339
+ const length = path.length;
340
+ const caseSensitive = route.options?.caseSensitive ?? defaultCaseSensitive;
341
+ const parseParams = route.options?.params?.parse ?? route.options?.parseParams;
342
+ while (cursor < length) {
343
+ const segment = parseSegment(path, cursor, data);
344
+ let nextNode;
345
+ const start2 = cursor;
346
+ const end = segment[5];
347
+ cursor = end + 1;
348
+ depth++;
349
+ switch (segment[0]) {
350
+ case 0: {
351
+ const value = path.substring(segment[2], segment[3]);
352
+ if (caseSensitive) {
353
+ const existingNode = node.static?.get(value);
354
+ if (existingNode) nextNode = existingNode;
355
+ else {
356
+ node.static ??= /* @__PURE__ */ new Map();
357
+ const next = createStaticNode(route.fullPath ?? route.from);
358
+ next.parent = node;
359
+ next.depth = depth;
360
+ nextNode = next;
361
+ node.static.set(value, next);
362
+ }
363
+ } else {
364
+ const name = value.toLowerCase();
365
+ const existingNode = node.staticInsensitive?.get(name);
366
+ if (existingNode) nextNode = existingNode;
367
+ else {
368
+ node.staticInsensitive ??= /* @__PURE__ */ new Map();
369
+ const next = createStaticNode(route.fullPath ?? route.from);
370
+ next.parent = node;
371
+ next.depth = depth;
372
+ nextNode = next;
373
+ node.staticInsensitive.set(name, next);
374
+ }
375
+ }
376
+ break;
377
+ }
378
+ case 1: {
379
+ const prefix_raw = path.substring(start2, segment[1]);
380
+ const suffix_raw = path.substring(segment[4], end);
381
+ const actuallyCaseSensitive = caseSensitive && !!(prefix_raw || suffix_raw);
382
+ const prefix = !prefix_raw ? void 0 : actuallyCaseSensitive ? prefix_raw : prefix_raw.toLowerCase();
383
+ const suffix = !suffix_raw ? void 0 : actuallyCaseSensitive ? suffix_raw : suffix_raw.toLowerCase();
384
+ const existingNode = !parseParams && node.dynamic?.find((s) => !s.parse && s.caseSensitive === actuallyCaseSensitive && s.prefix === prefix && s.suffix === suffix);
385
+ if (existingNode) nextNode = existingNode;
386
+ else {
387
+ const next = createDynamicNode(1, route.fullPath ?? route.from, actuallyCaseSensitive, prefix, suffix);
388
+ nextNode = next;
389
+ next.depth = depth;
390
+ next.parent = node;
391
+ node.dynamic ??= [];
392
+ node.dynamic.push(next);
393
+ }
394
+ break;
395
+ }
396
+ case 3: {
397
+ const prefix_raw = path.substring(start2, segment[1]);
398
+ const suffix_raw = path.substring(segment[4], end);
399
+ const actuallyCaseSensitive = caseSensitive && !!(prefix_raw || suffix_raw);
400
+ const prefix = !prefix_raw ? void 0 : actuallyCaseSensitive ? prefix_raw : prefix_raw.toLowerCase();
401
+ const suffix = !suffix_raw ? void 0 : actuallyCaseSensitive ? suffix_raw : suffix_raw.toLowerCase();
402
+ const existingNode = !parseParams && node.optional?.find((s) => !s.parse && s.caseSensitive === actuallyCaseSensitive && s.prefix === prefix && s.suffix === suffix);
403
+ if (existingNode) nextNode = existingNode;
404
+ else {
405
+ const next = createDynamicNode(3, route.fullPath ?? route.from, actuallyCaseSensitive, prefix, suffix);
406
+ nextNode = next;
407
+ next.parent = node;
408
+ next.depth = depth;
409
+ node.optional ??= [];
410
+ node.optional.push(next);
411
+ }
412
+ break;
413
+ }
414
+ case 2: {
415
+ const prefix_raw = path.substring(start2, segment[1]);
416
+ const suffix_raw = path.substring(segment[4], end);
417
+ const actuallyCaseSensitive = caseSensitive && !!(prefix_raw || suffix_raw);
418
+ const prefix = !prefix_raw ? void 0 : actuallyCaseSensitive ? prefix_raw : prefix_raw.toLowerCase();
419
+ const suffix = !suffix_raw ? void 0 : actuallyCaseSensitive ? suffix_raw : suffix_raw.toLowerCase();
420
+ const next = createDynamicNode(2, route.fullPath ?? route.from, actuallyCaseSensitive, prefix, suffix);
421
+ nextNode = next;
422
+ next.parent = node;
423
+ next.depth = depth;
424
+ node.wildcard ??= [];
425
+ node.wildcard.push(next);
426
+ }
427
+ }
428
+ node = nextNode;
429
+ }
430
+ if (parseParams && route.children && !route.isRoot && route.id && route.id.charCodeAt(route.id.lastIndexOf("/") + 1) === 95) {
431
+ const pathlessNode = createStaticNode(route.fullPath ?? route.from);
432
+ pathlessNode.kind = SEGMENT_TYPE_PATHLESS;
433
+ pathlessNode.parent = node;
434
+ depth++;
435
+ pathlessNode.depth = depth;
436
+ node.pathless ??= [];
437
+ node.pathless.push(pathlessNode);
438
+ node = pathlessNode;
439
+ }
440
+ const isLeaf = (route.path || !route.children) && !route.isRoot;
441
+ if (isLeaf && path.endsWith("/")) {
442
+ const indexNode = createStaticNode(route.fullPath ?? route.from);
443
+ indexNode.kind = SEGMENT_TYPE_INDEX;
444
+ indexNode.parent = node;
445
+ depth++;
446
+ indexNode.depth = depth;
447
+ node.index = indexNode;
448
+ node = indexNode;
449
+ }
450
+ node.parse = parseParams ?? null;
451
+ node.priority = route.options?.params?.priority ?? 0;
452
+ if (isLeaf && !node.route) {
453
+ node.route = route;
454
+ node.fullPath = route.fullPath ?? route.from;
455
+ }
456
+ }
457
+ if (route.children) for (const child of route.children) parseSegments(defaultCaseSensitive, data, child, cursor, node, depth, onRoute);
458
+ }
459
+ function sortDynamic(a, b) {
460
+ if (a.parse && !b.parse) return -1;
461
+ if (!a.parse && b.parse) return 1;
462
+ if (a.parse && b.parse && (a.priority || b.priority)) return b.priority - a.priority;
463
+ if (a.prefix && b.prefix && a.prefix !== b.prefix) {
464
+ if (a.prefix.startsWith(b.prefix)) return -1;
465
+ if (b.prefix.startsWith(a.prefix)) return 1;
466
+ }
467
+ if (a.suffix && b.suffix && a.suffix !== b.suffix) {
468
+ if (a.suffix.endsWith(b.suffix)) return -1;
469
+ if (b.suffix.endsWith(a.suffix)) return 1;
470
+ }
471
+ if (a.prefix && !b.prefix) return -1;
472
+ if (!a.prefix && b.prefix) return 1;
473
+ if (a.suffix && !b.suffix) return -1;
474
+ if (!a.suffix && b.suffix) return 1;
475
+ if (a.caseSensitive && !b.caseSensitive) return -1;
476
+ if (!a.caseSensitive && b.caseSensitive) return 1;
477
+ return 0;
478
+ }
479
+ function sortTreeNodes(node) {
480
+ if (node.pathless) for (const child of node.pathless) sortTreeNodes(child);
481
+ if (node.static) for (const child of node.static.values()) sortTreeNodes(child);
482
+ if (node.staticInsensitive) for (const child of node.staticInsensitive.values()) sortTreeNodes(child);
483
+ if (node.dynamic?.length) {
484
+ node.dynamic.sort(sortDynamic);
485
+ for (const child of node.dynamic) sortTreeNodes(child);
486
+ }
487
+ if (node.optional?.length) {
488
+ node.optional.sort(sortDynamic);
489
+ for (const child of node.optional) sortTreeNodes(child);
490
+ }
491
+ if (node.wildcard?.length) {
492
+ node.wildcard.sort(sortDynamic);
493
+ for (const child of node.wildcard) sortTreeNodes(child);
494
+ }
495
+ }
496
+ function createStaticNode(fullPath) {
497
+ return {
498
+ kind: 0,
499
+ depth: 0,
500
+ pathless: null,
501
+ index: null,
502
+ static: null,
503
+ staticInsensitive: null,
504
+ dynamic: null,
505
+ optional: null,
506
+ wildcard: null,
507
+ route: null,
508
+ fullPath,
509
+ parent: null,
510
+ parse: null,
511
+ priority: 0
512
+ };
513
+ }
514
+ function createDynamicNode(kind, fullPath, caseSensitive, prefix, suffix) {
515
+ return {
516
+ kind,
517
+ depth: 0,
518
+ pathless: null,
519
+ index: null,
520
+ static: null,
521
+ staticInsensitive: null,
522
+ dynamic: null,
523
+ optional: null,
524
+ wildcard: null,
525
+ route: null,
526
+ fullPath,
527
+ parent: null,
528
+ parse: null,
529
+ priority: 0,
530
+ caseSensitive,
531
+ prefix,
532
+ suffix
533
+ };
534
+ }
535
+ function processRouteMasks(routeList, processedTree) {
536
+ const segmentTree = createStaticNode("/");
537
+ const data = new Uint16Array(6);
538
+ for (const route of routeList) parseSegments(false, data, route, 1, segmentTree, 0);
539
+ sortTreeNodes(segmentTree);
540
+ processedTree.masksTree = segmentTree;
541
+ processedTree.flatCache = createLRUCache(1e3);
542
+ }
543
+ function findFlatMatch(path, processedTree) {
544
+ path ||= "/";
545
+ const cached = processedTree.flatCache.get(path);
546
+ if (cached) return cached;
547
+ const result = findMatch(path, processedTree.masksTree);
548
+ processedTree.flatCache.set(path, result);
549
+ return result;
550
+ }
551
+ function findSingleMatch(from, caseSensitive, fuzzy, path, processedTree) {
552
+ from ||= "/";
553
+ path ||= "/";
554
+ const key = caseSensitive ? `case\0${from}` : from;
555
+ let tree = processedTree.singleCache.get(key);
556
+ if (!tree) {
557
+ tree = createStaticNode("/");
558
+ parseSegments(caseSensitive, new Uint16Array(6), { from }, 1, tree, 0);
559
+ processedTree.singleCache.set(key, tree);
560
+ }
561
+ return findMatch(path, tree, fuzzy);
562
+ }
563
+ function findRouteMatch(path, processedTree, fuzzy = false) {
564
+ const key = fuzzy ? path : `nofuzz\0${path}`;
565
+ const cached = processedTree.matchCache.get(key);
566
+ if (cached !== void 0) return cached;
567
+ path ||= "/";
568
+ let result;
569
+ try {
570
+ result = findMatch(path, processedTree.segmentTree, fuzzy);
571
+ } catch (err) {
572
+ if (err instanceof URIError) result = null;
573
+ else throw err;
574
+ }
575
+ if (result) result.branch = buildRouteBranch(result.route);
576
+ processedTree.matchCache.set(key, result);
577
+ return result;
578
+ }
579
+ function trimPathRight$1(path) {
580
+ return path === "/" ? path : path.replace(/\/{1,}$/, "");
581
+ }
582
+ function processRouteTree(routeTree, caseSensitive = false, initRoute) {
583
+ const segmentTree = createStaticNode(routeTree.fullPath);
584
+ const data = new Uint16Array(6);
585
+ const routesById = {};
586
+ const routesByPath = {};
587
+ let index = 0;
588
+ parseSegments(caseSensitive, data, routeTree, 1, segmentTree, 0, (route) => {
589
+ initRoute?.(route, index);
590
+ if (route.id in routesById) {
591
+ invariant();
592
+ }
593
+ routesById[route.id] = route;
594
+ if (index !== 0 && route.path) {
595
+ const trimmedFullPath = trimPathRight$1(route.fullPath);
596
+ if (!routesByPath[trimmedFullPath] || route.fullPath.endsWith("/")) routesByPath[trimmedFullPath] = route;
597
+ }
598
+ index++;
599
+ });
600
+ sortTreeNodes(segmentTree);
601
+ return {
602
+ processedTree: {
603
+ segmentTree,
604
+ singleCache: createLRUCache(1e3),
605
+ matchCache: createLRUCache(1e3),
606
+ flatCache: null,
607
+ masksTree: null
608
+ },
609
+ routesById,
610
+ routesByPath
611
+ };
612
+ }
613
+ function findMatch(path, segmentTree, fuzzy = false) {
614
+ const parts = path.split("/");
615
+ const leaf = getNodeMatch(path, parts, segmentTree, fuzzy);
616
+ if (!leaf) return null;
617
+ const [rawParams] = extractParams(path, parts, leaf);
618
+ return {
619
+ route: leaf.node.route,
620
+ rawParams
621
+ };
622
+ }
623
+ function extractParams(path, parts, leaf) {
624
+ const list = buildBranch(leaf.node);
625
+ let nodeParts = null;
626
+ const rawParams = /* @__PURE__ */ Object.create(null);
627
+ let partIndex = leaf.extract?.part ?? 0;
628
+ let nodeIndex = leaf.extract?.node ?? 0;
629
+ let pathIndex = leaf.extract?.path ?? 0;
630
+ let segmentCount = leaf.extract?.segment ?? 0;
631
+ for (; nodeIndex < list.length; partIndex++, nodeIndex++, pathIndex++, segmentCount++) {
632
+ const node = list[nodeIndex];
633
+ if (node.kind === SEGMENT_TYPE_INDEX) break;
634
+ if (node.kind === SEGMENT_TYPE_PATHLESS) {
635
+ segmentCount--;
636
+ partIndex--;
637
+ pathIndex--;
638
+ continue;
639
+ }
640
+ const part = parts[partIndex];
641
+ const currentPathIndex = pathIndex;
642
+ if (part) pathIndex += part.length;
643
+ if (node.kind === 1) {
644
+ nodeParts ??= leaf.node.fullPath.split("/");
645
+ const nodePart = nodeParts[segmentCount];
646
+ const preLength = node.prefix?.length ?? 0;
647
+ if (nodePart.charCodeAt(preLength) === 123) {
648
+ const sufLength = node.suffix?.length ?? 0;
649
+ const name = nodePart.substring(preLength + 2, nodePart.length - sufLength - 1);
650
+ const value = part.substring(preLength, part.length - sufLength);
651
+ rawParams[name] = decodeURIComponent(value);
652
+ } else {
653
+ const name = nodePart.substring(1);
654
+ rawParams[name] = decodeURIComponent(part);
655
+ }
656
+ } else if (node.kind === 3) {
657
+ if (leaf.skipped & 1 << nodeIndex) {
658
+ partIndex--;
659
+ pathIndex = currentPathIndex - 1;
660
+ continue;
661
+ }
662
+ nodeParts ??= leaf.node.fullPath.split("/");
663
+ const nodePart = nodeParts[segmentCount];
664
+ const preLength = node.prefix?.length ?? 0;
665
+ const sufLength = node.suffix?.length ?? 0;
666
+ const name = nodePart.substring(preLength + 3, nodePart.length - sufLength - 1);
667
+ const value = node.suffix || node.prefix ? part.substring(preLength, part.length - sufLength) : part;
668
+ if (value) rawParams[name] = decodeURIComponent(value);
669
+ } else if (node.kind === 2) {
670
+ const n = node;
671
+ const value = path.substring(currentPathIndex + (n.prefix?.length ?? 0), path.length - (n.suffix?.length ?? 0));
672
+ const splat = decodeURIComponent(value);
673
+ rawParams["*"] = splat;
674
+ rawParams._splat = splat;
675
+ break;
676
+ }
677
+ }
678
+ if (leaf.rawParams) Object.assign(rawParams, leaf.rawParams);
679
+ return [rawParams, {
680
+ part: partIndex,
681
+ node: nodeIndex,
682
+ path: pathIndex,
683
+ segment: segmentCount
684
+ }];
685
+ }
686
+ function buildRouteBranch(route) {
687
+ const list = [route];
688
+ while (route.parentRoute) {
689
+ route = route.parentRoute;
690
+ list.push(route);
691
+ }
692
+ list.reverse();
693
+ return list;
694
+ }
695
+ function buildBranch(node) {
696
+ const list = Array(node.depth + 1);
697
+ do {
698
+ list[node.depth] = node;
699
+ node = node.parent;
700
+ } while (node);
701
+ return list;
702
+ }
703
+ function getNodeMatch(path, parts, segmentTree, fuzzy) {
704
+ if (path === "/" && segmentTree.index) return {
705
+ node: segmentTree.index,
706
+ skipped: 0
707
+ };
708
+ const trailingSlash = !last(parts);
709
+ const pathIsIndex = trailingSlash && path !== "/";
710
+ const partsLength = parts.length - (trailingSlash ? 1 : 0);
711
+ const stack = [{
712
+ node: segmentTree,
713
+ index: 1,
714
+ skipped: 0,
715
+ depth: 1,
716
+ statics: 0,
717
+ dynamics: 0,
718
+ optionals: 0
719
+ }];
720
+ let bestFuzzy = null;
721
+ let bestMatch = null;
722
+ while (stack.length) {
723
+ const frame = stack.pop();
724
+ const { node, index, skipped, depth, statics, dynamics, optionals } = frame;
725
+ let { extract, rawParams } = frame;
726
+ if (node.kind === 2 && node.route && !isFrameMoreSpecific(bestMatch, frame)) continue;
727
+ if (node.parse) {
728
+ if (!validateParseParams(path, parts, frame)) continue;
729
+ rawParams = frame.rawParams;
730
+ extract = frame.extract;
731
+ }
732
+ if (fuzzy && node.route && node.kind !== SEGMENT_TYPE_INDEX && isFrameMoreSpecific(bestFuzzy, frame)) bestFuzzy = frame;
733
+ const isBeyondPath = index === partsLength;
734
+ if (isBeyondPath) {
735
+ if (node.route && (!pathIsIndex || node.kind === SEGMENT_TYPE_INDEX || node.kind === 2) && isFrameMoreSpecific(bestMatch, frame)) bestMatch = frame;
736
+ if (!node.optional && !node.wildcard && !node.index && !node.pathless) continue;
737
+ }
738
+ const part = isBeyondPath ? void 0 : parts[index];
739
+ let lowerPart;
740
+ if (isBeyondPath && node.index) {
741
+ const indexFrame = {
742
+ node: node.index,
743
+ index,
744
+ skipped,
745
+ depth: depth + 1,
746
+ statics,
747
+ dynamics,
748
+ optionals,
749
+ extract,
750
+ rawParams
751
+ };
752
+ let indexValid = true;
753
+ if (node.index.parse) {
754
+ if (!validateParseParams(path, parts, indexFrame)) indexValid = false;
755
+ }
756
+ if (indexValid) {
757
+ if (!dynamics && !optionals && !skipped && isPerfectStaticMatch(statics, partsLength)) return indexFrame;
758
+ if (isFrameMoreSpecific(bestMatch, indexFrame)) bestMatch = indexFrame;
759
+ }
760
+ }
761
+ if (node.wildcard) for (let i = node.wildcard.length - 1; i >= 0; i--) {
762
+ const segment = node.wildcard[i];
763
+ const { prefix, suffix } = segment;
764
+ if (prefix) {
765
+ if (isBeyondPath) continue;
766
+ if (!(segment.caseSensitive ? part : lowerPart ??= part.toLowerCase()).startsWith(prefix)) continue;
767
+ }
768
+ if (suffix) {
769
+ if (isBeyondPath) continue;
770
+ const end = parts.slice(index).join("/").slice(-suffix.length);
771
+ if ((segment.caseSensitive ? end : end.toLowerCase()) !== suffix) continue;
772
+ }
773
+ stack.push({
774
+ node: segment,
775
+ index: partsLength,
776
+ skipped,
777
+ depth: depth + 1,
778
+ statics,
779
+ dynamics,
780
+ optionals,
781
+ extract,
782
+ rawParams
783
+ });
784
+ }
785
+ if (node.optional) {
786
+ const nextSkipped = skipped | 1 << depth;
787
+ const nextDepth = depth + 1;
788
+ for (let i = node.optional.length - 1; i >= 0; i--) {
789
+ const segment = node.optional[i];
790
+ stack.push({
791
+ node: segment,
792
+ index,
793
+ skipped: nextSkipped,
794
+ depth: nextDepth,
795
+ statics,
796
+ dynamics,
797
+ optionals,
798
+ extract,
799
+ rawParams
800
+ });
801
+ }
802
+ if (!isBeyondPath) for (let i = node.optional.length - 1; i >= 0; i--) {
803
+ const segment = node.optional[i];
804
+ const { prefix, suffix } = segment;
805
+ if (prefix || suffix) {
806
+ const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
807
+ if (prefix && !casePart.startsWith(prefix)) continue;
808
+ if (suffix && !casePart.endsWith(suffix)) continue;
809
+ }
810
+ stack.push({
811
+ node: segment,
812
+ index: index + 1,
813
+ skipped,
814
+ depth: nextDepth,
815
+ statics,
816
+ dynamics,
817
+ optionals: optionals + segmentScore(partsLength, index),
818
+ extract,
819
+ rawParams
820
+ });
821
+ }
822
+ }
823
+ if (!isBeyondPath && node.dynamic && part) for (let i = node.dynamic.length - 1; i >= 0; i--) {
824
+ const segment = node.dynamic[i];
825
+ const { prefix, suffix } = segment;
826
+ if (prefix || suffix) {
827
+ const casePart = segment.caseSensitive ? part : lowerPart ??= part.toLowerCase();
828
+ if (prefix && !casePart.startsWith(prefix)) continue;
829
+ if (suffix && !casePart.endsWith(suffix)) continue;
830
+ }
831
+ stack.push({
832
+ node: segment,
833
+ index: index + 1,
834
+ skipped,
835
+ depth: depth + 1,
836
+ statics,
837
+ dynamics: dynamics + segmentScore(partsLength, index),
838
+ optionals,
839
+ extract,
840
+ rawParams
841
+ });
842
+ }
843
+ if (!isBeyondPath && node.staticInsensitive) {
844
+ const match = node.staticInsensitive.get(lowerPart ??= part.toLowerCase());
845
+ if (match) stack.push({
846
+ node: match,
847
+ index: index + 1,
848
+ skipped,
849
+ depth: depth + 1,
850
+ statics: statics + segmentScore(partsLength, index),
851
+ dynamics,
852
+ optionals,
853
+ extract,
854
+ rawParams
855
+ });
856
+ }
857
+ if (!isBeyondPath && node.static) {
858
+ const match = node.static.get(part);
859
+ if (match) stack.push({
860
+ node: match,
861
+ index: index + 1,
862
+ skipped,
863
+ depth: depth + 1,
864
+ statics: statics + segmentScore(partsLength, index),
865
+ dynamics,
866
+ optionals,
867
+ extract,
868
+ rawParams
869
+ });
870
+ }
871
+ if (node.pathless) {
872
+ const nextDepth = depth + 1;
873
+ for (let i = node.pathless.length - 1; i >= 0; i--) {
874
+ const segment = node.pathless[i];
875
+ stack.push({
876
+ node: segment,
877
+ index,
878
+ skipped,
879
+ depth: nextDepth,
880
+ statics,
881
+ dynamics,
882
+ optionals,
883
+ extract,
884
+ rawParams
885
+ });
886
+ }
887
+ }
888
+ }
889
+ if (bestMatch) return bestMatch;
890
+ if (fuzzy && bestFuzzy) {
891
+ let sliceIndex = bestFuzzy.index;
892
+ for (let i = 0; i < bestFuzzy.index; i++) sliceIndex += parts[i].length;
893
+ const splat = sliceIndex === path.length ? "/" : path.slice(sliceIndex);
894
+ bestFuzzy.rawParams ??= /* @__PURE__ */ Object.create(null);
895
+ bestFuzzy.rawParams["**"] = decodeURIComponent(splat);
896
+ return bestFuzzy;
897
+ }
898
+ return null;
899
+ }
900
+ function segmentScore(partsLength, index) {
901
+ return 2 ** (partsLength - index - 1);
902
+ }
903
+ function isPerfectStaticMatch(statics, partsLength) {
904
+ return statics === 2 ** (partsLength - 1) - 1;
905
+ }
906
+ function validateParseParams(path, parts, frame) {
907
+ let rawParams;
908
+ let state;
909
+ try {
910
+ [rawParams, state] = extractParams(path, parts, frame);
911
+ } catch {
912
+ return null;
913
+ }
914
+ frame.rawParams = rawParams;
915
+ frame.extract = state;
916
+ if (!frame.node.parse) return true;
917
+ try {
918
+ if (frame.node.parse(rawParams) === false) return null;
919
+ } catch {
920
+ }
921
+ return true;
922
+ }
923
+ function isFrameMoreSpecific(prev, next) {
924
+ if (!prev) return true;
925
+ return next.statics > prev.statics || next.statics === prev.statics && (next.dynamics > prev.dynamics || next.dynamics === prev.dynamics && (next.optionals > prev.optionals || next.optionals === prev.optionals && ((next.node.kind === SEGMENT_TYPE_INDEX) > (prev.node.kind === SEGMENT_TYPE_INDEX) || next.node.kind === SEGMENT_TYPE_INDEX === (prev.node.kind === SEGMENT_TYPE_INDEX) && next.depth > prev.depth)));
926
+ }
927
+ function joinPaths(paths) {
928
+ return cleanPath(paths.filter((val) => {
929
+ return val !== void 0;
930
+ }).join("/"));
931
+ }
932
+ function cleanPath(path) {
933
+ return path.replace(/\/{2,}/g, "/");
934
+ }
935
+ function trimPathLeft(path) {
936
+ return path === "/" ? path : path.replace(/^\/{1,}/, "");
937
+ }
938
+ function trimPathRight(path) {
939
+ const len = path.length;
940
+ return len > 1 && path[len - 1] === "/" ? path.replace(/\/{1,}$/, "") : path;
941
+ }
942
+ function trimPath(path) {
943
+ return trimPathRight(trimPathLeft(path));
944
+ }
945
+ function removeTrailingSlash(value, basepath) {
946
+ if (value?.endsWith("/") && value !== "/" && value !== `${basepath}/`) return value.slice(0, -1);
947
+ return value;
948
+ }
949
+ function exactPathTest(pathName1, pathName2, basepath) {
950
+ return removeTrailingSlash(pathName1, basepath) === removeTrailingSlash(pathName2, basepath);
951
+ }
952
+ function resolvePath({ base, to, trailingSlash = "never", cache }) {
953
+ const isAbsolute = to.startsWith("/");
954
+ const isBase = !isAbsolute && to === ".";
955
+ let key;
956
+ if (cache) {
957
+ key = isAbsolute ? to : isBase ? base : base + "\0" + to;
958
+ const cached = cache.get(key);
959
+ if (cached) return cached;
960
+ }
961
+ let baseSegments;
962
+ if (isBase) baseSegments = base.split("/");
963
+ else if (isAbsolute) baseSegments = to.split("/");
964
+ else {
965
+ baseSegments = base.split("/");
966
+ while (baseSegments.length > 1 && last(baseSegments) === "") baseSegments.pop();
967
+ const toSegments = to.split("/");
968
+ for (let index = 0, length = toSegments.length; index < length; index++) {
969
+ const value = toSegments[index];
970
+ if (value === "") {
971
+ if (!index) baseSegments = [value];
972
+ else if (index === length - 1) baseSegments.push(value);
973
+ } else if (value === "..") baseSegments.pop();
974
+ else if (value === ".") ;
975
+ else baseSegments.push(value);
976
+ }
977
+ }
978
+ if (baseSegments.length > 1) {
979
+ if (last(baseSegments) === "") {
980
+ if (trailingSlash === "never") baseSegments.pop();
981
+ } else if (trailingSlash === "always") baseSegments.push("");
982
+ }
983
+ const result = cleanPath(baseSegments.join("/")) || "/";
984
+ if (key && cache) cache.set(key, result);
985
+ return result;
986
+ }
987
+ function compileDecodeCharMap(pathParamsAllowedCharacters) {
988
+ const charMap = new Map(pathParamsAllowedCharacters.map((char) => [encodeURIComponent(char), char]));
989
+ const pattern = Array.from(charMap.keys()).map((key) => key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
990
+ const regex = new RegExp(pattern, "g");
991
+ return (encoded) => encoded.replace(regex, (match) => charMap.get(match) ?? match);
992
+ }
993
+ function encodeParam(key, params, decoder) {
994
+ const value = params[key];
995
+ if (typeof value !== "string") return value;
996
+ if (key === "_splat") {
997
+ if (/^[a-zA-Z0-9\-._~!/]*$/.test(value)) return value;
998
+ return value.split("/").map((segment) => encodePathParam(segment, decoder)).join("/");
999
+ } else return encodePathParam(value, decoder);
1000
+ }
1001
+ function interpolatePath({ path, params, decoder, ...rest }) {
1002
+ let isMissingParams = false;
1003
+ const usedParams = /* @__PURE__ */ Object.create(null);
1004
+ if (!path || path === "/") return {
1005
+ interpolatedPath: "/",
1006
+ usedParams,
1007
+ isMissingParams
1008
+ };
1009
+ if (!path.includes("$")) return {
1010
+ interpolatedPath: path,
1011
+ usedParams,
1012
+ isMissingParams
1013
+ };
1014
+ {
1015
+ if (path.indexOf("{") === -1) {
1016
+ const length2 = path.length;
1017
+ let cursor2 = 0;
1018
+ let joined2 = "";
1019
+ while (cursor2 < length2) {
1020
+ while (cursor2 < length2 && path.charCodeAt(cursor2) === 47) cursor2++;
1021
+ if (cursor2 >= length2) break;
1022
+ const start = cursor2;
1023
+ let end = path.indexOf("/", cursor2);
1024
+ if (end === -1) end = length2;
1025
+ cursor2 = end;
1026
+ const part = path.substring(start, end);
1027
+ if (!part) continue;
1028
+ if (part.charCodeAt(0) === 36) if (part.length === 1) {
1029
+ const splat = params._splat;
1030
+ usedParams._splat = splat;
1031
+ usedParams["*"] = splat;
1032
+ if (!splat) {
1033
+ isMissingParams = true;
1034
+ continue;
1035
+ }
1036
+ const value = encodeParam("_splat", params, decoder);
1037
+ joined2 += "/" + value;
1038
+ } else {
1039
+ const key = part.substring(1);
1040
+ if (!isMissingParams && !(key in params)) isMissingParams = true;
1041
+ usedParams[key] = params[key];
1042
+ const value = encodeParam(key, params, decoder) ?? "undefined";
1043
+ joined2 += "/" + value;
1044
+ }
1045
+ else joined2 += "/" + part;
1046
+ }
1047
+ if (path.endsWith("/")) joined2 += "/";
1048
+ return {
1049
+ usedParams,
1050
+ interpolatedPath: joined2 || "/",
1051
+ isMissingParams
1052
+ };
1053
+ }
1054
+ }
1055
+ const length = path.length;
1056
+ let cursor = 0;
1057
+ let segment;
1058
+ let joined = "";
1059
+ while (cursor < length) {
1060
+ const start = cursor;
1061
+ segment = parseSegment(path, start, segment);
1062
+ const end = segment[5];
1063
+ cursor = end + 1;
1064
+ if (start === end) continue;
1065
+ const kind = segment[0];
1066
+ if (kind === 0) {
1067
+ joined += "/" + path.substring(start, end);
1068
+ continue;
1069
+ }
1070
+ if (kind === 2) {
1071
+ const splat = params._splat;
1072
+ usedParams._splat = splat;
1073
+ usedParams["*"] = splat;
1074
+ const prefix = path.substring(start, segment[1]);
1075
+ const suffix = path.substring(segment[4], end);
1076
+ if (!splat) {
1077
+ isMissingParams = true;
1078
+ if (prefix || suffix) joined += "/" + prefix + suffix;
1079
+ continue;
1080
+ }
1081
+ const value = encodeParam("_splat", params, decoder);
1082
+ joined += "/" + prefix + value + suffix;
1083
+ continue;
1084
+ }
1085
+ if (kind === 1) {
1086
+ const key = path.substring(segment[2], segment[3]);
1087
+ if (!isMissingParams && !(key in params)) isMissingParams = true;
1088
+ usedParams[key] = params[key];
1089
+ const prefix = path.substring(start, segment[1]);
1090
+ const suffix = path.substring(segment[4], end);
1091
+ const value = encodeParam(key, params, decoder) ?? "undefined";
1092
+ joined += "/" + prefix + value + suffix;
1093
+ continue;
1094
+ }
1095
+ if (kind === 3) {
1096
+ const key = path.substring(segment[2], segment[3]);
1097
+ const valueRaw = params[key];
1098
+ if (valueRaw == null) continue;
1099
+ usedParams[key] = valueRaw;
1100
+ const prefix = path.substring(start, segment[1]);
1101
+ const suffix = path.substring(segment[4], end);
1102
+ const value = encodeParam(key, params, decoder) ?? "";
1103
+ joined += "/" + prefix + value + suffix;
1104
+ continue;
1105
+ }
1106
+ }
1107
+ if (path.endsWith("/")) joined += "/";
1108
+ return {
1109
+ usedParams,
1110
+ interpolatedPath: joined || "/",
1111
+ isMissingParams
1112
+ };
1113
+ }
1114
+ function encodePathParam(value, decoder) {
1115
+ const encoded = encodeURIComponent(value);
1116
+ return decoder?.(encoded) ?? encoded;
1117
+ }
1118
+ function notFound(options = {}) {
1119
+ options.isNotFound = true;
1120
+ if (options.throw) throw options;
1121
+ return options;
1122
+ }
1123
+ function isNotFound(obj) {
1124
+ return obj?.isNotFound === true;
1125
+ }
1126
+ function encode(obj, stringify = String) {
1127
+ const result = new URLSearchParams();
1128
+ for (const key in obj) {
1129
+ const val = obj[key];
1130
+ if (val !== void 0) result.set(key, stringify(val));
1131
+ }
1132
+ return result.toString();
1133
+ }
1134
+ function toValue(str) {
1135
+ if (!str) return "";
1136
+ if (str === "false") return false;
1137
+ if (str === "true") return true;
1138
+ return +str * 0 === 0 && +str + "" === str ? +str : str;
1139
+ }
1140
+ function decode(str) {
1141
+ const searchParams = new URLSearchParams(str);
1142
+ const result = /* @__PURE__ */ Object.create(null);
1143
+ for (const [key, value] of searchParams.entries()) {
1144
+ const previousValue = result[key];
1145
+ if (previousValue == null) result[key] = toValue(value);
1146
+ else if (Array.isArray(previousValue)) previousValue.push(toValue(value));
1147
+ else result[key] = [previousValue, toValue(value)];
1148
+ }
1149
+ return result;
1150
+ }
1151
+ const defaultParseSearch = parseSearchWith(JSON.parse);
1152
+ const defaultStringifySearch = stringifySearchWith(JSON.stringify, JSON.parse);
1153
+ function parseSearchWith(parser) {
1154
+ return (searchStr) => {
1155
+ if (searchStr[0] === "?") searchStr = searchStr.substring(1);
1156
+ const query = decode(searchStr);
1157
+ for (const key in query) {
1158
+ const value = query[key];
1159
+ if (typeof value === "string") try {
1160
+ query[key] = parser(value);
1161
+ } catch (_err) {
1162
+ }
1163
+ }
1164
+ return query;
1165
+ };
1166
+ }
1167
+ function stringifySearchWith(stringify, parser) {
1168
+ const hasParser = typeof parser === "function";
1169
+ function stringifyValue(val) {
1170
+ if (typeof val === "object" && val !== null) try {
1171
+ return stringify(val);
1172
+ } catch (_err) {
1173
+ }
1174
+ else if (hasParser && typeof val === "string") try {
1175
+ parser(val);
1176
+ return stringify(val);
1177
+ } catch (_err) {
1178
+ }
1179
+ return val;
1180
+ }
1181
+ return (search) => {
1182
+ const searchStr = encode(search, stringifyValue);
1183
+ return searchStr ? `?${searchStr}` : "";
1184
+ };
1185
+ }
1186
+ const rootRouteId = "__root__";
1187
+ function redirect(opts) {
1188
+ opts.statusCode = opts.statusCode || opts.code || 307;
1189
+ if (!opts._builtLocation && !opts.reloadDocument && typeof opts.href === "string") try {
1190
+ new URL(opts.href);
1191
+ opts.reloadDocument = true;
1192
+ } catch {
1193
+ }
1194
+ const headers = new Headers(opts.headers);
1195
+ if (opts.href && headers.get("Location") === null) headers.set("Location", opts.href);
1196
+ const response = new Response(null, {
1197
+ status: opts.statusCode,
1198
+ headers
1199
+ });
1200
+ response.options = opts;
1201
+ if (opts.throw) throw response;
1202
+ return response;
1203
+ }
1204
+ function isRedirect(obj) {
1205
+ return obj instanceof Response && !!obj.options;
1206
+ }
1207
+ function isResolvedRedirect(obj) {
1208
+ return isRedirect(obj) && !!obj.options.href;
1209
+ }
1210
+ function parseRedirect(obj) {
1211
+ if (obj !== null && typeof obj === "object" && obj.isSerializedRedirect) return redirect(obj);
1212
+ }
1213
+ const triggerOnReady = (inner) => {
1214
+ if (!inner.rendered) {
1215
+ inner.rendered = true;
1216
+ return inner.onReady?.();
1217
+ }
1218
+ };
1219
+ const resolvePreload = (inner, matchId) => {
1220
+ return !!(inner.preload && !inner.router.stores.matchStores.has(matchId));
1221
+ };
1222
+ const buildMatchContext = (inner, index, includeCurrentMatch = true) => {
1223
+ const context = { ...inner.router.options.context ?? {} };
1224
+ const end = includeCurrentMatch ? index : index - 1;
1225
+ for (let i = 0; i <= end; i++) {
1226
+ const innerMatch = inner.matches[i];
1227
+ if (!innerMatch) continue;
1228
+ const m = inner.router.getMatch(innerMatch.id);
1229
+ if (!m) continue;
1230
+ Object.assign(context, m.__routeContext, m.__beforeLoadContext);
1231
+ }
1232
+ return context;
1233
+ };
1234
+ const getNotFoundBoundaryIndex = (inner, err) => {
1235
+ if (!inner.matches.length) return;
1236
+ const requestedRouteId = err.routeId;
1237
+ const matchedRootIndex = inner.matches.findIndex((m) => m.routeId === inner.router.routeTree.id);
1238
+ const rootIndex = matchedRootIndex >= 0 ? matchedRootIndex : 0;
1239
+ let startIndex = requestedRouteId ? inner.matches.findIndex((match) => match.routeId === requestedRouteId) : inner.firstBadMatchIndex ?? inner.matches.length - 1;
1240
+ if (startIndex < 0) startIndex = rootIndex;
1241
+ for (let i = startIndex; i >= 0; i--) {
1242
+ const match = inner.matches[i];
1243
+ if (inner.router.looseRoutesById[match.routeId].options.notFoundComponent) return i;
1244
+ }
1245
+ return requestedRouteId ? startIndex : rootIndex;
1246
+ };
1247
+ const handleRedirectAndNotFound = (inner, match, err) => {
1248
+ if (!isRedirect(err) && !isNotFound(err)) return;
1249
+ if (isRedirect(err) && err.redirectHandled && !err.options.reloadDocument) throw err;
1250
+ if (match) {
1251
+ match._nonReactive.beforeLoadPromise?.resolve();
1252
+ match._nonReactive.loaderPromise?.resolve();
1253
+ match._nonReactive.beforeLoadPromise = void 0;
1254
+ match._nonReactive.loaderPromise = void 0;
1255
+ match._nonReactive.error = err;
1256
+ inner.updateMatch(match.id, (prev) => ({
1257
+ ...prev,
1258
+ status: isRedirect(err) ? "redirected" : isNotFound(err) ? "notFound" : prev.status === "pending" ? "success" : prev.status,
1259
+ context: buildMatchContext(inner, match.index),
1260
+ isFetching: false,
1261
+ error: err
1262
+ }));
1263
+ if (isNotFound(err) && !err.routeId) err.routeId = match.routeId;
1264
+ match._nonReactive.loadPromise?.resolve();
1265
+ }
1266
+ if (isRedirect(err)) {
1267
+ inner.rendered = true;
1268
+ err.options._fromLocation = inner.location;
1269
+ err.redirectHandled = true;
1270
+ err = inner.router.resolveRedirect(err);
1271
+ }
1272
+ throw err;
1273
+ };
1274
+ const shouldSkipLoader = (inner, matchId) => {
1275
+ const match = inner.router.getMatch(matchId);
1276
+ if (!match) return true;
1277
+ if (match.ssr === false) return true;
1278
+ return false;
1279
+ };
1280
+ const syncMatchContext = (inner, matchId, index) => {
1281
+ const nextContext = buildMatchContext(inner, index);
1282
+ inner.updateMatch(matchId, (prev) => {
1283
+ return {
1284
+ ...prev,
1285
+ context: nextContext
1286
+ };
1287
+ });
1288
+ };
1289
+ const handleSerialError = (inner, index, err, routerCode) => {
1290
+ const { id: matchId, routeId } = inner.matches[index];
1291
+ const route = inner.router.looseRoutesById[routeId];
1292
+ if (err instanceof Promise) throw err;
1293
+ err.routerCode = routerCode;
1294
+ inner.firstBadMatchIndex ??= index;
1295
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
1296
+ try {
1297
+ route.options.onError?.(err);
1298
+ } catch (errorHandlerErr) {
1299
+ err = errorHandlerErr;
1300
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), err);
1301
+ }
1302
+ inner.updateMatch(matchId, (prev) => {
1303
+ prev._nonReactive.beforeLoadPromise?.resolve();
1304
+ prev._nonReactive.beforeLoadPromise = void 0;
1305
+ prev._nonReactive.loadPromise?.resolve();
1306
+ return {
1307
+ ...prev,
1308
+ error: err,
1309
+ status: "error",
1310
+ isFetching: false,
1311
+ updatedAt: Date.now(),
1312
+ abortController: new AbortController()
1313
+ };
1314
+ });
1315
+ if (!inner.preload && !isRedirect(err) && !isNotFound(err)) inner.serialError ??= err;
1316
+ };
1317
+ const isBeforeLoadSsr = (inner, matchId, index, route) => {
1318
+ const existingMatch = inner.router.getMatch(matchId);
1319
+ const parentMatchId = inner.matches[index - 1]?.id;
1320
+ const parentMatch = parentMatchId ? inner.router.getMatch(parentMatchId) : void 0;
1321
+ if (inner.router.isShell()) {
1322
+ existingMatch.ssr = route.id === rootRouteId;
1323
+ return;
1324
+ }
1325
+ if (parentMatch?.ssr === false) {
1326
+ existingMatch.ssr = false;
1327
+ return;
1328
+ }
1329
+ const parentOverride = (tempSsr2) => {
1330
+ if (tempSsr2 === true && parentMatch?.ssr === "data-only") return "data-only";
1331
+ return tempSsr2;
1332
+ };
1333
+ const defaultSsr = inner.router.options.defaultSsr ?? true;
1334
+ if (route.options.ssr === void 0) {
1335
+ existingMatch.ssr = parentOverride(defaultSsr);
1336
+ return;
1337
+ }
1338
+ if (typeof route.options.ssr !== "function") {
1339
+ existingMatch.ssr = parentOverride(route.options.ssr);
1340
+ return;
1341
+ }
1342
+ const { search, params } = existingMatch;
1343
+ const ssrFnContext = {
1344
+ search: makeMaybe(search, existingMatch.searchError),
1345
+ params: makeMaybe(params, existingMatch.paramsError),
1346
+ location: inner.location,
1347
+ matches: inner.matches.map((match) => ({
1348
+ index: match.index,
1349
+ pathname: match.pathname,
1350
+ fullPath: match.fullPath,
1351
+ staticData: match.staticData,
1352
+ id: match.id,
1353
+ routeId: match.routeId,
1354
+ search: makeMaybe(match.search, match.searchError),
1355
+ params: makeMaybe(match.params, match.paramsError),
1356
+ ssr: match.ssr
1357
+ }))
1358
+ };
1359
+ const tempSsr = route.options.ssr(ssrFnContext);
1360
+ if (isPromise(tempSsr)) return tempSsr.then((ssr) => {
1361
+ existingMatch.ssr = parentOverride(ssr ?? defaultSsr);
1362
+ });
1363
+ existingMatch.ssr = parentOverride(tempSsr ?? defaultSsr);
1364
+ };
1365
+ const setupPendingTimeout = (inner, matchId, route, match) => {
1366
+ if (match._nonReactive.pendingTimeout !== void 0) return;
1367
+ const pendingMs = route.options.pendingMs ?? inner.router.options.defaultPendingMs;
1368
+ if (!!(inner.onReady && false)) {
1369
+ const pendingTimeout = setTimeout(() => {
1370
+ triggerOnReady(inner);
1371
+ }, pendingMs);
1372
+ match._nonReactive.pendingTimeout = pendingTimeout;
1373
+ }
1374
+ };
1375
+ const preBeforeLoadSetup = (inner, matchId, route) => {
1376
+ const existingMatch = inner.router.getMatch(matchId);
1377
+ if (!existingMatch._nonReactive.beforeLoadPromise && !existingMatch._nonReactive.loaderPromise) return;
1378
+ setupPendingTimeout(inner, matchId, route, existingMatch);
1379
+ const then = () => {
1380
+ const match = inner.router.getMatch(matchId);
1381
+ if (match.preload && (match.status === "redirected" || match.status === "notFound")) handleRedirectAndNotFound(inner, match, match.error);
1382
+ };
1383
+ return existingMatch._nonReactive.beforeLoadPromise ? existingMatch._nonReactive.beforeLoadPromise.then(then) : then();
1384
+ };
1385
+ const executeBeforeLoad = (inner, matchId, index, route) => {
1386
+ const match = inner.router.getMatch(matchId);
1387
+ let prevLoadPromise = match._nonReactive.loadPromise;
1388
+ match._nonReactive.loadPromise = createControlledPromise(() => {
1389
+ prevLoadPromise?.resolve();
1390
+ prevLoadPromise = void 0;
1391
+ });
1392
+ const { paramsError, searchError } = match;
1393
+ if (paramsError) handleSerialError(inner, index, paramsError, "PARSE_PARAMS");
1394
+ if (searchError) handleSerialError(inner, index, searchError, "VALIDATE_SEARCH");
1395
+ setupPendingTimeout(inner, matchId, route, match);
1396
+ const abortController = new AbortController();
1397
+ let isPending = false;
1398
+ const pending = () => {
1399
+ if (isPending) return;
1400
+ isPending = true;
1401
+ inner.updateMatch(matchId, (prev) => ({
1402
+ ...prev,
1403
+ isFetching: "beforeLoad",
1404
+ fetchCount: prev.fetchCount + 1,
1405
+ abortController
1406
+ }));
1407
+ };
1408
+ const resolve = () => {
1409
+ match._nonReactive.beforeLoadPromise?.resolve();
1410
+ match._nonReactive.beforeLoadPromise = void 0;
1411
+ inner.updateMatch(matchId, (prev) => ({
1412
+ ...prev,
1413
+ isFetching: false
1414
+ }));
1415
+ };
1416
+ if (!route.options.beforeLoad) {
1417
+ inner.router.batch(() => {
1418
+ pending();
1419
+ resolve();
1420
+ });
1421
+ return;
1422
+ }
1423
+ match._nonReactive.beforeLoadPromise = createControlledPromise();
1424
+ const context = {
1425
+ ...buildMatchContext(inner, index, false),
1426
+ ...match.__routeContext
1427
+ };
1428
+ const { search, params, cause } = match;
1429
+ const preload = resolvePreload(inner, matchId);
1430
+ const beforeLoadFnContext = {
1431
+ search,
1432
+ abortController,
1433
+ params,
1434
+ preload,
1435
+ context,
1436
+ location: inner.location,
1437
+ navigate: (opts) => inner.router.navigate({
1438
+ ...opts,
1439
+ _fromLocation: inner.location
1440
+ }),
1441
+ buildLocation: inner.router.buildLocation,
1442
+ cause: preload ? "preload" : cause,
1443
+ matches: inner.matches,
1444
+ routeId: route.id,
1445
+ ...inner.router.options.additionalContext
1446
+ };
1447
+ const updateContext = (beforeLoadContext2) => {
1448
+ if (beforeLoadContext2 === void 0) {
1449
+ inner.router.batch(() => {
1450
+ pending();
1451
+ resolve();
1452
+ });
1453
+ return;
1454
+ }
1455
+ if (isRedirect(beforeLoadContext2) || isNotFound(beforeLoadContext2)) {
1456
+ pending();
1457
+ handleSerialError(inner, index, beforeLoadContext2, "BEFORE_LOAD");
1458
+ }
1459
+ inner.router.batch(() => {
1460
+ pending();
1461
+ inner.updateMatch(matchId, (prev) => ({
1462
+ ...prev,
1463
+ __beforeLoadContext: beforeLoadContext2
1464
+ }));
1465
+ resolve();
1466
+ });
1467
+ };
1468
+ let beforeLoadContext;
1469
+ try {
1470
+ beforeLoadContext = route.options.beforeLoad(beforeLoadFnContext);
1471
+ if (isPromise(beforeLoadContext)) {
1472
+ pending();
1473
+ return beforeLoadContext.catch((err) => {
1474
+ handleSerialError(inner, index, err, "BEFORE_LOAD");
1475
+ }).then(updateContext);
1476
+ }
1477
+ } catch (err) {
1478
+ pending();
1479
+ handleSerialError(inner, index, err, "BEFORE_LOAD");
1480
+ }
1481
+ updateContext(beforeLoadContext);
1482
+ };
1483
+ const handleBeforeLoad = (inner, index) => {
1484
+ const { id: matchId, routeId } = inner.matches[index];
1485
+ const route = inner.router.looseRoutesById[routeId];
1486
+ const serverSsr = () => {
1487
+ {
1488
+ const maybePromise = isBeforeLoadSsr(inner, matchId, index, route);
1489
+ if (isPromise(maybePromise)) return maybePromise.then(queueExecution);
1490
+ }
1491
+ return queueExecution();
1492
+ };
1493
+ const execute = () => executeBeforeLoad(inner, matchId, index, route);
1494
+ const queueExecution = () => {
1495
+ if (shouldSkipLoader(inner, matchId)) return;
1496
+ const result = preBeforeLoadSetup(inner, matchId, route);
1497
+ return isPromise(result) ? result.then(execute) : execute();
1498
+ };
1499
+ return serverSsr();
1500
+ };
1501
+ const executeHead = (inner, matchId, route) => {
1502
+ const match = inner.router.getMatch(matchId);
1503
+ if (!match) return;
1504
+ if (!route.options.head && !route.options.scripts && !route.options.headers) return;
1505
+ const assetContext = {
1506
+ ssr: inner.router.options.ssr,
1507
+ matches: inner.matches,
1508
+ match,
1509
+ params: match.params,
1510
+ loaderData: match.loaderData
1511
+ };
1512
+ return Promise.all([
1513
+ route.options.head?.(assetContext),
1514
+ route.options.scripts?.(assetContext),
1515
+ route.options.headers?.(assetContext)
1516
+ ]).then(([headFnContent, scripts, headers]) => {
1517
+ return {
1518
+ meta: headFnContent?.meta,
1519
+ links: headFnContent?.links,
1520
+ headScripts: headFnContent?.scripts,
1521
+ headers,
1522
+ scripts,
1523
+ styles: headFnContent?.styles
1524
+ };
1525
+ });
1526
+ };
1527
+ const getLoaderContext = (inner, matchPromises, matchId, index, route) => {
1528
+ const parentMatchPromise = matchPromises[index - 1];
1529
+ const { params, loaderDeps, abortController, cause } = inner.router.getMatch(matchId);
1530
+ const context = buildMatchContext(inner, index);
1531
+ const preload = resolvePreload(inner, matchId);
1532
+ return {
1533
+ params,
1534
+ deps: loaderDeps,
1535
+ preload: !!preload,
1536
+ parentMatchPromise,
1537
+ abortController,
1538
+ context,
1539
+ location: inner.location,
1540
+ navigate: (opts) => inner.router.navigate({
1541
+ ...opts,
1542
+ _fromLocation: inner.location
1543
+ }),
1544
+ cause: preload ? "preload" : cause,
1545
+ route,
1546
+ ...inner.router.options.additionalContext
1547
+ };
1548
+ };
1549
+ const runLoader = async (inner, matchPromises, matchId, index, route) => {
1550
+ try {
1551
+ const match = inner.router.getMatch(matchId);
1552
+ try {
1553
+ if (!(isServer ?? inner.router.isServer) || match.ssr === true) loadRouteChunk(route);
1554
+ const routeLoader = route.options.loader;
1555
+ const loader = typeof routeLoader === "function" ? routeLoader : routeLoader?.handler;
1556
+ const loaderResult = loader?.(getLoaderContext(inner, matchPromises, matchId, index, route));
1557
+ const loaderResultIsPromise = !!loader && isPromise(loaderResult);
1558
+ if (!!(loaderResultIsPromise || route._lazyPromise || route._componentsPromise || route.options.head || route.options.scripts || route.options.headers || match._nonReactive.minPendingPromise)) inner.updateMatch(matchId, (prev) => ({
1559
+ ...prev,
1560
+ isFetching: "loader"
1561
+ }));
1562
+ if (loader) {
1563
+ const loaderData = loaderResultIsPromise ? await loaderResult : loaderResult;
1564
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), loaderData);
1565
+ if (loaderData !== void 0) inner.updateMatch(matchId, (prev) => ({
1566
+ ...prev,
1567
+ loaderData
1568
+ }));
1569
+ }
1570
+ if (route._lazyPromise) await route._lazyPromise;
1571
+ const pendingPromise = match._nonReactive.minPendingPromise;
1572
+ if (pendingPromise) await pendingPromise;
1573
+ if (route._componentsPromise) await route._componentsPromise;
1574
+ inner.updateMatch(matchId, (prev) => ({
1575
+ ...prev,
1576
+ error: void 0,
1577
+ context: buildMatchContext(inner, index),
1578
+ status: "success",
1579
+ isFetching: false,
1580
+ updatedAt: Date.now()
1581
+ }));
1582
+ } catch (e) {
1583
+ let error = e;
1584
+ if (error?.name === "AbortError") {
1585
+ if (match.abortController.signal.aborted) {
1586
+ match._nonReactive.loaderPromise?.resolve();
1587
+ match._nonReactive.loaderPromise = void 0;
1588
+ return;
1589
+ }
1590
+ inner.updateMatch(matchId, (prev) => ({
1591
+ ...prev,
1592
+ status: prev.status === "pending" ? "success" : prev.status,
1593
+ isFetching: false,
1594
+ context: buildMatchContext(inner, index)
1595
+ }));
1596
+ return;
1597
+ }
1598
+ const pendingPromise = match._nonReactive.minPendingPromise;
1599
+ if (pendingPromise) await pendingPromise;
1600
+ if (isNotFound(e)) await route.options.notFoundComponent?.preload?.();
1601
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), e);
1602
+ try {
1603
+ route.options.onError?.(e);
1604
+ } catch (onErrorError) {
1605
+ error = onErrorError;
1606
+ handleRedirectAndNotFound(inner, inner.router.getMatch(matchId), onErrorError);
1607
+ }
1608
+ if (!isRedirect(error) && !isNotFound(error)) await loadRouteChunk(route, ["errorComponent"]);
1609
+ inner.updateMatch(matchId, (prev) => ({
1610
+ ...prev,
1611
+ error,
1612
+ context: buildMatchContext(inner, index),
1613
+ status: "error",
1614
+ isFetching: false
1615
+ }));
1616
+ }
1617
+ } catch (err) {
1618
+ const match = inner.router.getMatch(matchId);
1619
+ if (match) match._nonReactive.loaderPromise = void 0;
1620
+ handleRedirectAndNotFound(inner, match, err);
1621
+ }
1622
+ };
1623
+ const loadRouteMatch = async (inner, matchPromises, index) => {
1624
+ async function handleLoader(preload, prevMatch, previousRouteMatchId, match2, route2) {
1625
+ const age = Date.now() - prevMatch.updatedAt;
1626
+ const staleAge = preload ? route2.options.preloadStaleTime ?? inner.router.options.defaultPreloadStaleTime ?? 3e4 : route2.options.staleTime ?? inner.router.options.defaultStaleTime ?? 0;
1627
+ const shouldReloadOption = route2.options.shouldReload;
1628
+ const shouldReload = typeof shouldReloadOption === "function" ? shouldReloadOption(getLoaderContext(inner, matchPromises, matchId, index, route2)) : shouldReloadOption;
1629
+ const { status, invalid } = match2;
1630
+ const staleMatchShouldReload = age >= staleAge && (!!inner.forceStaleReload || match2.cause === "enter" || previousRouteMatchId !== void 0 && previousRouteMatchId !== match2.id);
1631
+ loaderShouldRunAsync = status === "success" && (invalid || (shouldReload ?? staleMatchShouldReload));
1632
+ if (preload && route2.options.preload === false) ;
1633
+ else if (loaderShouldRunAsync && !inner.sync && shouldReloadInBackground) {
1634
+ loaderIsRunningAsync = true;
1635
+ (async () => {
1636
+ try {
1637
+ await runLoader(inner, matchPromises, matchId, index, route2);
1638
+ const match3 = inner.router.getMatch(matchId);
1639
+ match3._nonReactive.loaderPromise?.resolve();
1640
+ match3._nonReactive.loadPromise?.resolve();
1641
+ match3._nonReactive.loaderPromise = void 0;
1642
+ match3._nonReactive.loadPromise = void 0;
1643
+ } catch (err) {
1644
+ if (isRedirect(err)) await inner.router.navigate(err.options);
1645
+ }
1646
+ })();
1647
+ } else if (status !== "success" || loaderShouldRunAsync) await runLoader(inner, matchPromises, matchId, index, route2);
1648
+ else syncMatchContext(inner, matchId, index);
1649
+ }
1650
+ const { id: matchId, routeId } = inner.matches[index];
1651
+ let loaderShouldRunAsync = false;
1652
+ let loaderIsRunningAsync = false;
1653
+ const route = inner.router.looseRoutesById[routeId];
1654
+ const routeLoader = route.options.loader;
1655
+ const shouldReloadInBackground = ((typeof routeLoader === "function" ? void 0 : routeLoader?.staleReloadMode) ?? inner.router.options.defaultStaleReloadMode) !== "blocking";
1656
+ if (shouldSkipLoader(inner, matchId)) {
1657
+ if (!inner.router.getMatch(matchId)) return inner.matches[index];
1658
+ syncMatchContext(inner, matchId, index);
1659
+ return inner.router.getMatch(matchId);
1660
+ } else {
1661
+ const prevMatch = inner.router.getMatch(matchId);
1662
+ const activeIdAtIndex = inner.router.stores.matchesId.get()[index];
1663
+ const previousRouteMatchId = (activeIdAtIndex && inner.router.stores.matchStores.get(activeIdAtIndex) || null)?.routeId === routeId ? activeIdAtIndex : inner.router.stores.matches.get().find((d) => d.routeId === routeId)?.id;
1664
+ const preload = resolvePreload(inner, matchId);
1665
+ if (prevMatch._nonReactive.loaderPromise) {
1666
+ if (prevMatch.status === "success" && !inner.sync && !prevMatch.preload && shouldReloadInBackground) return prevMatch;
1667
+ await prevMatch._nonReactive.loaderPromise;
1668
+ const match2 = inner.router.getMatch(matchId);
1669
+ const error = match2._nonReactive.error || match2.error;
1670
+ if (error) handleRedirectAndNotFound(inner, match2, error);
1671
+ if (match2.status === "pending") await handleLoader(preload, prevMatch, previousRouteMatchId, match2, route);
1672
+ } else {
1673
+ const nextPreload = preload && !inner.router.stores.matchStores.has(matchId);
1674
+ const match2 = inner.router.getMatch(matchId);
1675
+ match2._nonReactive.loaderPromise = createControlledPromise();
1676
+ if (nextPreload !== match2.preload) inner.updateMatch(matchId, (prev) => ({
1677
+ ...prev,
1678
+ preload: nextPreload
1679
+ }));
1680
+ await handleLoader(preload, prevMatch, previousRouteMatchId, match2, route);
1681
+ }
1682
+ }
1683
+ const match = inner.router.getMatch(matchId);
1684
+ if (!loaderIsRunningAsync) {
1685
+ match._nonReactive.loaderPromise?.resolve();
1686
+ match._nonReactive.loadPromise?.resolve();
1687
+ match._nonReactive.loadPromise = void 0;
1688
+ }
1689
+ clearTimeout(match._nonReactive.pendingTimeout);
1690
+ match._nonReactive.pendingTimeout = void 0;
1691
+ if (!loaderIsRunningAsync) match._nonReactive.loaderPromise = void 0;
1692
+ match._nonReactive.dehydrated = void 0;
1693
+ const nextIsFetching = loaderIsRunningAsync ? match.isFetching : false;
1694
+ if (nextIsFetching !== match.isFetching || match.invalid !== false) {
1695
+ inner.updateMatch(matchId, (prev) => ({
1696
+ ...prev,
1697
+ isFetching: nextIsFetching,
1698
+ invalid: false
1699
+ }));
1700
+ return inner.router.getMatch(matchId);
1701
+ } else return match;
1702
+ };
1703
+ async function loadMatches(arg) {
1704
+ const inner = arg;
1705
+ const matchPromises = [];
1706
+ let beforeLoadNotFound;
1707
+ for (let i = 0; i < inner.matches.length; i++) {
1708
+ try {
1709
+ const beforeLoad = handleBeforeLoad(inner, i);
1710
+ if (isPromise(beforeLoad)) await beforeLoad;
1711
+ } catch (err) {
1712
+ if (isRedirect(err)) throw err;
1713
+ if (isNotFound(err)) beforeLoadNotFound = err;
1714
+ else if (!inner.preload) throw err;
1715
+ break;
1716
+ }
1717
+ if (inner.serialError || inner.firstBadMatchIndex != null) break;
1718
+ }
1719
+ const baseMaxIndexExclusive = inner.firstBadMatchIndex ?? inner.matches.length;
1720
+ const boundaryIndex = beforeLoadNotFound && !inner.preload ? getNotFoundBoundaryIndex(inner, beforeLoadNotFound) : void 0;
1721
+ const maxIndexExclusive = beforeLoadNotFound && inner.preload ? 0 : boundaryIndex !== void 0 ? Math.min(boundaryIndex + 1, baseMaxIndexExclusive) : baseMaxIndexExclusive;
1722
+ let firstNotFound;
1723
+ let firstUnhandledRejection;
1724
+ for (let i = 0; i < maxIndexExclusive; i++) matchPromises.push(loadRouteMatch(inner, matchPromises, i));
1725
+ try {
1726
+ await Promise.all(matchPromises);
1727
+ } catch {
1728
+ const settled = await Promise.allSettled(matchPromises);
1729
+ for (const result of settled) {
1730
+ if (result.status !== "rejected") continue;
1731
+ const reason = result.reason;
1732
+ if (isRedirect(reason)) throw reason;
1733
+ if (isNotFound(reason)) firstNotFound ??= reason;
1734
+ else firstUnhandledRejection ??= reason;
1735
+ }
1736
+ if (firstUnhandledRejection !== void 0) throw firstUnhandledRejection;
1737
+ }
1738
+ const notFoundToThrow = firstNotFound ?? (beforeLoadNotFound && !inner.preload ? beforeLoadNotFound : void 0);
1739
+ let headMaxIndex = inner.firstBadMatchIndex !== void 0 ? inner.firstBadMatchIndex : inner.matches.length - 1;
1740
+ if (!notFoundToThrow && beforeLoadNotFound && inner.preload) return inner.matches;
1741
+ if (notFoundToThrow) {
1742
+ const renderedBoundaryIndex = getNotFoundBoundaryIndex(inner, notFoundToThrow);
1743
+ if (renderedBoundaryIndex === void 0) {
1744
+ invariant();
1745
+ }
1746
+ const boundaryMatch = inner.matches[renderedBoundaryIndex];
1747
+ const boundaryRoute = inner.router.looseRoutesById[boundaryMatch.routeId];
1748
+ const defaultNotFoundComponent = inner.router.options?.defaultNotFoundComponent;
1749
+ if (!boundaryRoute.options.notFoundComponent && defaultNotFoundComponent) boundaryRoute.options.notFoundComponent = defaultNotFoundComponent;
1750
+ notFoundToThrow.routeId = boundaryMatch.routeId;
1751
+ const boundaryIsRoot = boundaryMatch.routeId === inner.router.routeTree.id;
1752
+ inner.updateMatch(boundaryMatch.id, (prev) => ({
1753
+ ...prev,
1754
+ ...boundaryIsRoot ? {
1755
+ status: "success",
1756
+ globalNotFound: true,
1757
+ error: void 0
1758
+ } : {
1759
+ status: "notFound",
1760
+ error: notFoundToThrow
1761
+ },
1762
+ isFetching: false
1763
+ }));
1764
+ headMaxIndex = renderedBoundaryIndex;
1765
+ await loadRouteChunk(boundaryRoute, ["notFoundComponent"]);
1766
+ } else if (!inner.preload) {
1767
+ const rootMatch = inner.matches[0];
1768
+ if (!rootMatch.globalNotFound) {
1769
+ if (inner.router.getMatch(rootMatch.id)?.globalNotFound) inner.updateMatch(rootMatch.id, (prev) => ({
1770
+ ...prev,
1771
+ globalNotFound: false,
1772
+ error: void 0
1773
+ }));
1774
+ }
1775
+ }
1776
+ if (inner.serialError && inner.firstBadMatchIndex !== void 0) {
1777
+ const errorRoute = inner.router.looseRoutesById[inner.matches[inner.firstBadMatchIndex].routeId];
1778
+ await loadRouteChunk(errorRoute, ["errorComponent"]);
1779
+ }
1780
+ for (let i = 0; i <= headMaxIndex; i++) {
1781
+ const { id: matchId, routeId } = inner.matches[i];
1782
+ const route = inner.router.looseRoutesById[routeId];
1783
+ try {
1784
+ const headResult = executeHead(inner, matchId, route);
1785
+ if (headResult) {
1786
+ const head = await headResult;
1787
+ inner.updateMatch(matchId, (prev) => ({
1788
+ ...prev,
1789
+ ...head
1790
+ }));
1791
+ }
1792
+ } catch (err) {
1793
+ console.error(`Error executing head for route ${routeId}:`, err);
1794
+ }
1795
+ }
1796
+ const readyPromise = triggerOnReady(inner);
1797
+ if (isPromise(readyPromise)) await readyPromise;
1798
+ if (notFoundToThrow) throw notFoundToThrow;
1799
+ if (inner.serialError && !inner.preload && !inner.onReady) throw inner.serialError;
1800
+ return inner.matches;
1801
+ }
1802
+ function preloadRouteComponents(route, componentTypesToLoad) {
1803
+ const preloads = componentTypesToLoad.map((type) => route.options[type]?.preload?.()).filter(Boolean);
1804
+ if (preloads.length === 0) return void 0;
1805
+ return Promise.all(preloads);
1806
+ }
1807
+ function loadRouteChunk(route, componentTypesToLoad = componentTypes) {
1808
+ if (!route._lazyLoaded && route._lazyPromise === void 0) if (route.lazyFn) route._lazyPromise = route.lazyFn().then((lazyRoute) => {
1809
+ const { id: _id, ...options } = lazyRoute.options;
1810
+ Object.assign(route.options, options);
1811
+ route._lazyLoaded = true;
1812
+ route._lazyPromise = void 0;
1813
+ });
1814
+ else route._lazyLoaded = true;
1815
+ const runAfterLazy = () => route._componentsLoaded ? void 0 : componentTypesToLoad === componentTypes ? (() => {
1816
+ if (route._componentsPromise === void 0) {
1817
+ const componentsPromise = preloadRouteComponents(route, componentTypes);
1818
+ if (componentsPromise) route._componentsPromise = componentsPromise.then(() => {
1819
+ route._componentsLoaded = true;
1820
+ route._componentsPromise = void 0;
1821
+ });
1822
+ else route._componentsLoaded = true;
1823
+ }
1824
+ return route._componentsPromise;
1825
+ })() : preloadRouteComponents(route, componentTypesToLoad);
1826
+ return route._lazyPromise ? route._lazyPromise.then(runAfterLazy) : runAfterLazy();
1827
+ }
1828
+ function makeMaybe(value, error) {
1829
+ if (error) return {
1830
+ status: "error",
1831
+ error
1832
+ };
1833
+ return {
1834
+ status: "success",
1835
+ value
1836
+ };
1837
+ }
1838
+ function routeNeedsPreload(route) {
1839
+ for (const componentType of componentTypes) if (route.options[componentType]?.preload) return true;
1840
+ return false;
1841
+ }
1842
+ const componentTypes = [
1843
+ "component",
1844
+ "errorComponent",
1845
+ "pendingComponent",
1846
+ "notFoundComponent"
1847
+ ];
1848
+ function composeRewrites(rewrites) {
1849
+ return {
1850
+ input: ({ url }) => {
1851
+ for (const rewrite of rewrites) url = executeRewriteInput(rewrite, url);
1852
+ return url;
1853
+ },
1854
+ output: ({ url }) => {
1855
+ for (let i = rewrites.length - 1; i >= 0; i--) url = executeRewriteOutput(rewrites[i], url);
1856
+ return url;
1857
+ }
1858
+ };
1859
+ }
1860
+ function rewriteBasepath(opts) {
1861
+ const trimmedBasepath = trimPath(opts.basepath);
1862
+ const normalizedBasepath = `/${trimmedBasepath}`;
1863
+ const checkBasepath = opts.caseSensitive ? normalizedBasepath : normalizedBasepath.toLowerCase();
1864
+ const checkBasepathWithSlash = `${checkBasepath}/`;
1865
+ return {
1866
+ input: ({ url }) => {
1867
+ const pathname = opts.caseSensitive ? url.pathname : url.pathname.toLowerCase();
1868
+ if (pathname === checkBasepath) url.pathname = "/";
1869
+ else if (pathname.startsWith(checkBasepathWithSlash)) url.pathname = url.pathname.slice(normalizedBasepath.length);
1870
+ return url;
1871
+ },
1872
+ output: ({ url }) => {
1873
+ url.pathname = joinPaths([
1874
+ "/",
1875
+ trimmedBasepath,
1876
+ url.pathname
1877
+ ]);
1878
+ return url;
1879
+ }
1880
+ };
1881
+ }
1882
+ function executeRewriteInput(rewrite, url) {
1883
+ const res = rewrite?.input?.({ url });
1884
+ if (res) {
1885
+ if (typeof res === "string") return new URL(res);
1886
+ else if (res instanceof URL) return res;
1887
+ }
1888
+ return url;
1889
+ }
1890
+ function executeRewriteOutput(rewrite, url) {
1891
+ const res = rewrite?.output?.({ url });
1892
+ if (res) {
1893
+ if (typeof res === "string") return new URL(res);
1894
+ else if (res instanceof URL) return res;
1895
+ }
1896
+ return url;
1897
+ }
1898
+ function createNonReactiveMutableStore(initialValue) {
1899
+ let value = initialValue;
1900
+ return {
1901
+ get() {
1902
+ return value;
1903
+ },
1904
+ set(nextOrUpdater) {
1905
+ value = functionalUpdate(nextOrUpdater, value);
1906
+ }
1907
+ };
1908
+ }
1909
+ function createNonReactiveReadonlyStore(read) {
1910
+ return { get() {
1911
+ return read();
1912
+ } };
1913
+ }
1914
+ function createRouterStores(initialState, config) {
1915
+ const { createMutableStore, createReadonlyStore, batch, init } = config;
1916
+ const matchStores = /* @__PURE__ */ new Map();
1917
+ const pendingMatchStores = /* @__PURE__ */ new Map();
1918
+ const cachedMatchStores = /* @__PURE__ */ new Map();
1919
+ const status = createMutableStore(initialState.status);
1920
+ const loadedAt = createMutableStore(initialState.loadedAt);
1921
+ const isLoading = createMutableStore(initialState.isLoading);
1922
+ const isTransitioning = createMutableStore(initialState.isTransitioning);
1923
+ const location = createMutableStore(initialState.location);
1924
+ const resolvedLocation = createMutableStore(initialState.resolvedLocation);
1925
+ const statusCode = createMutableStore(initialState.statusCode);
1926
+ const redirect2 = createMutableStore(initialState.redirect);
1927
+ const matchesId = createMutableStore([]);
1928
+ const pendingIds = createMutableStore([]);
1929
+ const cachedIds = createMutableStore([]);
1930
+ const matches = createReadonlyStore(() => readPoolMatches(matchStores, matchesId.get()));
1931
+ const pendingMatches = createReadonlyStore(() => readPoolMatches(pendingMatchStores, pendingIds.get()));
1932
+ const cachedMatches = createReadonlyStore(() => readPoolMatches(cachedMatchStores, cachedIds.get()));
1933
+ const firstId = createReadonlyStore(() => matchesId.get()[0]);
1934
+ const hasPending = createReadonlyStore(() => matchesId.get().some((matchId) => {
1935
+ return matchStores.get(matchId)?.get().status === "pending";
1936
+ }));
1937
+ const matchRouteDeps = createReadonlyStore(() => ({
1938
+ locationHref: location.get().href,
1939
+ resolvedLocationHref: resolvedLocation.get()?.href,
1940
+ status: status.get()
1941
+ }));
1942
+ const __store = createReadonlyStore(() => ({
1943
+ status: status.get(),
1944
+ loadedAt: loadedAt.get(),
1945
+ isLoading: isLoading.get(),
1946
+ isTransitioning: isTransitioning.get(),
1947
+ matches: matches.get(),
1948
+ location: location.get(),
1949
+ resolvedLocation: resolvedLocation.get(),
1950
+ statusCode: statusCode.get(),
1951
+ redirect: redirect2.get()
1952
+ }));
1953
+ const matchStoreByRouteIdCache = createLRUCache(64);
1954
+ function getRouteMatchStore(routeId) {
1955
+ let cached = matchStoreByRouteIdCache.get(routeId);
1956
+ if (!cached) {
1957
+ cached = createReadonlyStore(() => {
1958
+ const ids = matchesId.get();
1959
+ for (const id of ids) {
1960
+ const matchStore = matchStores.get(id);
1961
+ if (matchStore && matchStore.routeId === routeId) return matchStore.get();
1962
+ }
1963
+ });
1964
+ matchStoreByRouteIdCache.set(routeId, cached);
1965
+ }
1966
+ return cached;
1967
+ }
1968
+ const store = {
1969
+ status,
1970
+ loadedAt,
1971
+ isLoading,
1972
+ isTransitioning,
1973
+ location,
1974
+ resolvedLocation,
1975
+ statusCode,
1976
+ redirect: redirect2,
1977
+ matchesId,
1978
+ pendingIds,
1979
+ cachedIds,
1980
+ matches,
1981
+ pendingMatches,
1982
+ cachedMatches,
1983
+ firstId,
1984
+ hasPending,
1985
+ matchRouteDeps,
1986
+ matchStores,
1987
+ pendingMatchStores,
1988
+ cachedMatchStores,
1989
+ __store,
1990
+ getRouteMatchStore,
1991
+ setMatches,
1992
+ setPending,
1993
+ setCached
1994
+ };
1995
+ setMatches(initialState.matches);
1996
+ init?.(store);
1997
+ function setMatches(nextMatches) {
1998
+ reconcileMatchPool(nextMatches, matchStores, matchesId, createMutableStore, batch);
1999
+ }
2000
+ function setPending(nextMatches) {
2001
+ reconcileMatchPool(nextMatches, pendingMatchStores, pendingIds, createMutableStore, batch);
2002
+ }
2003
+ function setCached(nextMatches) {
2004
+ reconcileMatchPool(nextMatches, cachedMatchStores, cachedIds, createMutableStore, batch);
2005
+ }
2006
+ return store;
2007
+ }
2008
+ function readPoolMatches(pool, ids) {
2009
+ const matches = [];
2010
+ for (const id of ids) {
2011
+ const matchStore = pool.get(id);
2012
+ if (matchStore) matches.push(matchStore.get());
2013
+ }
2014
+ return matches;
2015
+ }
2016
+ function reconcileMatchPool(nextMatches, pool, idStore, createMutableStore, batch) {
2017
+ const nextIds = nextMatches.map((d) => d.id);
2018
+ const nextIdSet = new Set(nextIds);
2019
+ batch(() => {
2020
+ for (const id of pool.keys()) if (!nextIdSet.has(id)) pool.delete(id);
2021
+ for (const nextMatch of nextMatches) {
2022
+ const existing = pool.get(nextMatch.id);
2023
+ if (!existing) {
2024
+ const matchStore = createMutableStore(nextMatch);
2025
+ matchStore.routeId = nextMatch.routeId;
2026
+ pool.set(nextMatch.id, matchStore);
2027
+ continue;
2028
+ }
2029
+ existing.routeId = nextMatch.routeId;
2030
+ if (existing.get() !== nextMatch) existing.set(nextMatch);
2031
+ }
2032
+ if (!arraysEqual(idStore.get(), nextIds)) idStore.set(nextIds);
2033
+ });
2034
+ }
2035
+ function getLocationChangeInfo(location, resolvedLocation) {
2036
+ const fromLocation = resolvedLocation;
2037
+ const toLocation = location;
2038
+ return {
2039
+ fromLocation,
2040
+ toLocation,
2041
+ pathChanged: fromLocation?.pathname !== toLocation.pathname,
2042
+ hrefChanged: fromLocation?.href !== toLocation.href,
2043
+ hashChanged: fromLocation?.hash !== toLocation.hash
2044
+ };
2045
+ }
2046
+ const locationHistoryActions = /* @__PURE__ */ new WeakMap();
2047
+ var RouterCore = class {
2048
+ /**
2049
+ * @deprecated Use the `createRouter` function instead
2050
+ */
2051
+ constructor(options, getStoreConfig) {
2052
+ this.tempLocationKey = `${Math.round(Math.random() * 1e7)}`;
2053
+ this.resetNextScroll = true;
2054
+ this.shouldViewTransition = void 0;
2055
+ this.isViewTransitionTypesSupported = void 0;
2056
+ this.subscribers = /* @__PURE__ */ new Set();
2057
+ this.isScrollRestoring = false;
2058
+ this.isScrollRestorationSetup = false;
2059
+ this.routeBranchCache = /* @__PURE__ */ new WeakMap();
2060
+ this.startTransition = (fn) => fn();
2061
+ this.update = (newOptions) => {
2062
+ const prevOptions = this.options;
2063
+ const prevBasepath = this.basepath ?? prevOptions?.basepath ?? "/";
2064
+ const basepathWasUnset = this.basepath === void 0;
2065
+ const prevRewriteOption = prevOptions?.rewrite;
2066
+ this.options = {
2067
+ ...prevOptions,
2068
+ ...newOptions
2069
+ };
2070
+ this.isServer = this.options.isServer ?? typeof document === "undefined";
2071
+ this.protocolAllowlist = new Set(this.options.protocolAllowlist);
2072
+ if (this.options.pathParamsAllowedCharacters) this.pathParamsDecoder = compileDecodeCharMap(this.options.pathParamsAllowedCharacters);
2073
+ if (!this.history || this.options.history && this.options.history !== this.history) if (!this.options.history) ;
2074
+ else this.history = this.options.history;
2075
+ this.origin = this.options.origin;
2076
+ if (!this.origin) this.origin = "http://localhost";
2077
+ if (this.history) this.updateLatestLocation();
2078
+ if (this.options.routeTree !== this.routeTree) {
2079
+ this.routeTree = this.options.routeTree;
2080
+ let processRouteTreeResult;
2081
+ if (globalThis.__TSR_CACHE__ && globalThis.__TSR_CACHE__.routeTree === this.routeTree) {
2082
+ const cached = globalThis.__TSR_CACHE__;
2083
+ this.resolvePathCache = cached.resolvePathCache;
2084
+ processRouteTreeResult = cached.processRouteTreeResult;
2085
+ } else {
2086
+ this.resolvePathCache = createLRUCache(1e3);
2087
+ processRouteTreeResult = this.buildRouteTree();
2088
+ if (globalThis.__TSR_CACHE__ === void 0) globalThis.__TSR_CACHE__ = {
2089
+ routeTree: this.routeTree,
2090
+ processRouteTreeResult,
2091
+ resolvePathCache: this.resolvePathCache
2092
+ };
2093
+ }
2094
+ this.setRoutes(processRouteTreeResult);
2095
+ }
2096
+ if (!this.stores && this.latestLocation) {
2097
+ const config = this.getStoreConfig(this);
2098
+ this.batch = config.batch;
2099
+ this.stores = createRouterStores(getInitialRouterState(this.latestLocation), config);
2100
+ }
2101
+ let needsLocationUpdate = false;
2102
+ const nextBasepath = this.options.basepath ?? "/";
2103
+ const nextRewriteOption = this.options.rewrite;
2104
+ if (basepathWasUnset || prevBasepath !== nextBasepath || prevRewriteOption !== nextRewriteOption) {
2105
+ this.basepath = nextBasepath;
2106
+ const rewrites = [];
2107
+ const trimmed = trimPath(nextBasepath);
2108
+ if (trimmed && trimmed !== "/") rewrites.push(rewriteBasepath({ basepath: nextBasepath }));
2109
+ if (nextRewriteOption) rewrites.push(nextRewriteOption);
2110
+ this.rewrite = rewrites.length === 0 ? void 0 : rewrites.length === 1 ? rewrites[0] : composeRewrites(rewrites);
2111
+ if (this.history) this.updateLatestLocation();
2112
+ needsLocationUpdate = true;
2113
+ }
2114
+ if (needsLocationUpdate && this.stores) this.stores.location.set(this.latestLocation);
2115
+ if (typeof window !== "undefined" && "CSS" in window && typeof window.CSS?.supports === "function") this.isViewTransitionTypesSupported = window.CSS.supports("selector(:active-view-transition-type(a))");
2116
+ };
2117
+ this.updateLatestLocation = () => {
2118
+ this.latestLocation = this.parseLocation(this.history.location, this.latestLocation);
2119
+ };
2120
+ this.buildRouteTree = () => {
2121
+ const result = processRouteTree(this.routeTree, this.options.caseSensitive, (route, i) => {
2122
+ route.init({ originalIndex: i });
2123
+ });
2124
+ if (this.options.routeMasks) processRouteMasks(this.options.routeMasks, result.processedTree);
2125
+ return result;
2126
+ };
2127
+ this.subscribe = (eventType, fn) => {
2128
+ const listener = {
2129
+ eventType,
2130
+ fn
2131
+ };
2132
+ this.subscribers.add(listener);
2133
+ return () => {
2134
+ this.subscribers.delete(listener);
2135
+ };
2136
+ };
2137
+ this.emit = (routerEvent) => {
2138
+ this.subscribers.forEach((listener) => {
2139
+ if (listener.eventType === routerEvent.type) listener.fn(routerEvent);
2140
+ });
2141
+ };
2142
+ this.parseLocation = (locationToParse, previousLocation) => {
2143
+ const parse = ({ pathname, search, hash, href, state }) => {
2144
+ if (!this.rewrite && !/[ \x00-\x1f\x7f\u0080-\uffff]/.test(pathname)) {
2145
+ const parsedSearch2 = this.options.parseSearch(search);
2146
+ const searchStr2 = this.options.stringifySearch(parsedSearch2);
2147
+ return {
2148
+ href: pathname + searchStr2 + hash,
2149
+ publicHref: pathname + searchStr2 + hash,
2150
+ pathname: decodePath(pathname).path,
2151
+ external: false,
2152
+ searchStr: searchStr2,
2153
+ search: nullReplaceEqualDeep(previousLocation?.search, parsedSearch2),
2154
+ hash: decodePath(hash.slice(1)).path,
2155
+ state: replaceEqualDeep(previousLocation?.state, state)
2156
+ };
2157
+ }
2158
+ const fullUrl = new URL(href, this.origin);
2159
+ const url = executeRewriteInput(this.rewrite, fullUrl);
2160
+ const parsedSearch = this.options.parseSearch(url.search);
2161
+ const searchStr = this.options.stringifySearch(parsedSearch);
2162
+ url.search = searchStr;
2163
+ return {
2164
+ href: url.href.replace(url.origin, ""),
2165
+ publicHref: href,
2166
+ pathname: decodePath(url.pathname).path,
2167
+ external: !!this.rewrite && url.origin !== this.origin,
2168
+ searchStr,
2169
+ search: nullReplaceEqualDeep(previousLocation?.search, parsedSearch),
2170
+ hash: decodePath(url.hash.slice(1)).path,
2171
+ state: replaceEqualDeep(previousLocation?.state, state)
2172
+ };
2173
+ };
2174
+ const location = parse(locationToParse);
2175
+ const { __tempLocation, __tempKey } = location.state;
2176
+ if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {
2177
+ const parsedTempLocation = parse(__tempLocation);
2178
+ parsedTempLocation.state.key = location.state.key;
2179
+ parsedTempLocation.state.__TSR_key = location.state.__TSR_key;
2180
+ delete parsedTempLocation.state.__tempLocation;
2181
+ return {
2182
+ ...parsedTempLocation,
2183
+ maskedLocation: location
2184
+ };
2185
+ }
2186
+ return location;
2187
+ };
2188
+ this.resolvePathWithBase = (from, path) => {
2189
+ return resolvePath({
2190
+ base: from,
2191
+ to: path.includes("//") ? cleanPath(path) : path,
2192
+ trailingSlash: this.options.trailingSlash,
2193
+ cache: this.resolvePathCache
2194
+ });
2195
+ };
2196
+ this.matchRoutes = (pathnameOrNext, locationSearchOrOpts, opts) => {
2197
+ if (typeof pathnameOrNext === "string") return this.matchRoutesInternal({
2198
+ pathname: pathnameOrNext,
2199
+ search: locationSearchOrOpts
2200
+ }, opts);
2201
+ return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts);
2202
+ };
2203
+ this.getMatchedRoutes = (pathname) => {
2204
+ return getMatchedRoutes({
2205
+ pathname,
2206
+ routesById: this.routesById,
2207
+ processedTree: this.processedTree
2208
+ });
2209
+ };
2210
+ this.cancelMatch = (id) => {
2211
+ const match = this.getMatch(id);
2212
+ if (!match) return;
2213
+ match.abortController.abort();
2214
+ clearTimeout(match._nonReactive.pendingTimeout);
2215
+ match._nonReactive.pendingTimeout = void 0;
2216
+ };
2217
+ this.cancelMatches = () => {
2218
+ this.stores.pendingIds.get().forEach((matchId) => {
2219
+ this.cancelMatch(matchId);
2220
+ });
2221
+ this.stores.matchesId.get().forEach((matchId) => {
2222
+ if (this.stores.pendingMatchStores.has(matchId)) return;
2223
+ const match = this.stores.matchStores.get(matchId)?.get();
2224
+ if (!match) return;
2225
+ if (match.status === "pending" || match.isFetching === "loader") this.cancelMatch(matchId);
2226
+ });
2227
+ };
2228
+ this.buildLocation = (opts) => {
2229
+ const build = (dest = {}) => {
2230
+ const currentLocation = dest._fromLocation || this.pendingBuiltLocation || this.latestLocation;
2231
+ const lightweightResult = this.matchRoutesLightweight(currentLocation);
2232
+ if (dest.from && false) ;
2233
+ const defaultedFromPath = dest.unsafeRelative === "path" ? currentLocation.pathname : dest.from ?? lightweightResult.fullPath;
2234
+ const destTo = dest.to ? `${dest.to}` : void 0;
2235
+ const fromSearch = lightweightResult.search;
2236
+ const fromParams = Object.assign(/* @__PURE__ */ Object.create(null), lightweightResult.params);
2237
+ const sourcePath = destTo?.charCodeAt(0) === 47 ? "/" : this.resolvePathWithBase(defaultedFromPath, ".");
2238
+ const nextTo = destTo ? this.resolvePathWithBase(sourcePath, destTo) : sourcePath;
2239
+ const nextParams = dest.params === false || dest.params === null ? /* @__PURE__ */ Object.create(null) : (dest.params ?? true) === true ? fromParams : Object.assign(fromParams, functionalUpdate(dest.params, fromParams));
2240
+ const destRoute = this.routesByPath[trimPathRight(nextTo)];
2241
+ let destRoutes;
2242
+ if (destRoute) destRoutes = this.getRouteBranch(destRoute);
2243
+ else if (nextTo.includes("$")) destRoutes = [];
2244
+ else {
2245
+ const destMatchResult = this.getMatchedRoutes(nextTo);
2246
+ destRoutes = destMatchResult.matchedRoutes;
2247
+ if (this.options.notFoundRoute && (!destMatchResult.foundRoute || destMatchResult.foundRoute.path !== "/" && destMatchResult.routeParams["**"])) destRoutes = [...destRoutes, this.options.notFoundRoute];
2248
+ }
2249
+ if (destRoutes.length && hasKeys(nextParams)) for (const route of destRoutes) {
2250
+ const fn = route.options.params?.stringify ?? route.options.stringifyParams;
2251
+ if (fn) try {
2252
+ Object.assign(nextParams, fn(nextParams));
2253
+ } catch {
2254
+ }
2255
+ }
2256
+ const nextPathname = opts.leaveParams ? nextTo : decodePath(interpolatePath({
2257
+ path: nextTo,
2258
+ params: nextParams,
2259
+ decoder: this.pathParamsDecoder,
2260
+ server: this.isServer
2261
+ }).interpolatedPath).path;
2262
+ let nextSearch = fromSearch;
2263
+ if (opts._includeValidateSearch && this.options.search?.strict) {
2264
+ const validatedSearch = {};
2265
+ destRoutes.forEach((route) => {
2266
+ if (route.options.validateSearch) try {
2267
+ Object.assign(validatedSearch, validateSearch(route.options.validateSearch, {
2268
+ ...validatedSearch,
2269
+ ...nextSearch
2270
+ }));
2271
+ } catch {
2272
+ }
2273
+ });
2274
+ nextSearch = validatedSearch;
2275
+ }
2276
+ nextSearch = applySearchMiddleware({
2277
+ search: nextSearch,
2278
+ dest,
2279
+ destRoutes,
2280
+ _includeValidateSearch: opts._includeValidateSearch
2281
+ });
2282
+ nextSearch = nullReplaceEqualDeep(fromSearch, nextSearch);
2283
+ const searchStr = this.options.stringifySearch(nextSearch);
2284
+ const hash = dest.hash === true ? currentLocation.hash : dest.hash ? functionalUpdate(dest.hash, currentLocation.hash) : void 0;
2285
+ const hashStr = hash ? `#${hash}` : "";
2286
+ let nextState = dest.state === true ? currentLocation.state : dest.state ? functionalUpdate(dest.state, currentLocation.state) : {};
2287
+ nextState = replaceEqualDeep(currentLocation.state, nextState);
2288
+ const fullPath = `${nextPathname}${searchStr}${hashStr}`;
2289
+ let href;
2290
+ let publicHref;
2291
+ let external = false;
2292
+ if (this.rewrite) {
2293
+ const url = new URL(fullPath, this.origin);
2294
+ const rewrittenUrl = executeRewriteOutput(this.rewrite, url);
2295
+ href = url.href.replace(url.origin, "");
2296
+ if (rewrittenUrl.origin !== this.origin) {
2297
+ publicHref = rewrittenUrl.href;
2298
+ external = true;
2299
+ } else publicHref = rewrittenUrl.pathname + rewrittenUrl.search + rewrittenUrl.hash;
2300
+ } else {
2301
+ href = encodePathLikeUrl(fullPath);
2302
+ publicHref = href;
2303
+ }
2304
+ return {
2305
+ publicHref,
2306
+ href,
2307
+ pathname: nextPathname,
2308
+ search: nextSearch,
2309
+ searchStr,
2310
+ state: nextState,
2311
+ hash: hash ?? "",
2312
+ external,
2313
+ unmaskOnReload: dest.unmaskOnReload
2314
+ };
2315
+ };
2316
+ const buildWithMatches = (dest = {}, maskedDest) => {
2317
+ const next = build(dest);
2318
+ let maskedNext = maskedDest ? build(maskedDest) : void 0;
2319
+ if (!maskedNext) {
2320
+ const params = /* @__PURE__ */ Object.create(null);
2321
+ if (this.options.routeMasks) {
2322
+ const match = findFlatMatch(next.pathname, this.processedTree);
2323
+ if (match) {
2324
+ Object.assign(params, match.rawParams);
2325
+ const { from: _from, params: maskParams, ...maskProps } = match.route;
2326
+ const nextParams = maskParams === false || maskParams === null ? /* @__PURE__ */ Object.create(null) : (maskParams ?? true) === true ? params : Object.assign(params, functionalUpdate(maskParams, params));
2327
+ maskedDest = {
2328
+ from: opts.from,
2329
+ ...maskProps,
2330
+ params: nextParams
2331
+ };
2332
+ maskedNext = build(maskedDest);
2333
+ }
2334
+ }
2335
+ }
2336
+ if (maskedNext) next.maskedLocation = maskedNext;
2337
+ return next;
2338
+ };
2339
+ if (opts.mask) return buildWithMatches(opts, {
2340
+ from: opts.from,
2341
+ ...opts.mask
2342
+ });
2343
+ return buildWithMatches(opts);
2344
+ };
2345
+ this.commitLocation = async ({ viewTransition, ignoreBlocker, ...next }) => {
2346
+ let historyAction;
2347
+ const isSameState = () => {
2348
+ const ignoredProps = [
2349
+ "key",
2350
+ "__TSR_key",
2351
+ "__TSR_index",
2352
+ "__hashScrollIntoViewOptions"
2353
+ ];
2354
+ ignoredProps.forEach((prop) => {
2355
+ next.state[prop] = this.latestLocation.state[prop];
2356
+ });
2357
+ const isEqual = deepEqual(next.state, this.latestLocation.state);
2358
+ ignoredProps.forEach((prop) => {
2359
+ delete next.state[prop];
2360
+ });
2361
+ return isEqual;
2362
+ };
2363
+ const isSameUrl = trimPathRight(this.latestLocation.href) === trimPathRight(next.href);
2364
+ let previousCommitPromise = this.commitLocationPromise;
2365
+ this.commitLocationPromise = createControlledPromise(() => {
2366
+ previousCommitPromise?.resolve();
2367
+ previousCommitPromise = void 0;
2368
+ });
2369
+ if (isSameUrl && isSameState()) this.load();
2370
+ else {
2371
+ let { maskedLocation, hashScrollIntoView, ...nextHistory } = next;
2372
+ if (maskedLocation) {
2373
+ nextHistory = {
2374
+ ...maskedLocation,
2375
+ state: {
2376
+ ...maskedLocation.state,
2377
+ __tempKey: void 0,
2378
+ __tempLocation: {
2379
+ ...nextHistory,
2380
+ search: nextHistory.searchStr,
2381
+ state: {
2382
+ ...nextHistory.state,
2383
+ __tempKey: void 0,
2384
+ __tempLocation: void 0,
2385
+ __TSR_key: void 0,
2386
+ key: void 0
2387
+ }
2388
+ }
2389
+ }
2390
+ };
2391
+ if (nextHistory.unmaskOnReload ?? this.options.unmaskOnReload ?? false) nextHistory.state.__tempKey = this.tempLocationKey;
2392
+ }
2393
+ nextHistory.state.__hashScrollIntoViewOptions = hashScrollIntoView ?? this.options.defaultHashScrollIntoView ?? true;
2394
+ this.shouldViewTransition = viewTransition;
2395
+ historyAction = next.replace ? "REPLACE" : "PUSH";
2396
+ this.history[historyAction === "REPLACE" ? "replace" : "push"](nextHistory.publicHref, nextHistory.state, { ignoreBlocker });
2397
+ }
2398
+ this.resetNextScroll = next.resetScroll ?? true;
2399
+ if (!this.history.subscribers.size) this.load(historyAction ? { action: { type: historyAction } } : void 0);
2400
+ return this.commitLocationPromise;
2401
+ };
2402
+ this.buildAndCommitLocation = ({ replace, resetScroll, hashScrollIntoView, viewTransition, ignoreBlocker, href, ...rest } = {}) => {
2403
+ if (href) {
2404
+ const currentIndex = this.history.location.state.__TSR_index;
2405
+ const parsed = parseHref(href, { __TSR_index: replace ? currentIndex : currentIndex + 1 });
2406
+ const hrefUrl = new URL(parsed.pathname, this.origin);
2407
+ rest.to = executeRewriteInput(this.rewrite, hrefUrl).pathname;
2408
+ rest.search = this.options.parseSearch(parsed.search);
2409
+ rest.hash = parsed.hash.slice(1);
2410
+ }
2411
+ const location = this.buildLocation({
2412
+ ...rest,
2413
+ _includeValidateSearch: true
2414
+ });
2415
+ this.pendingBuiltLocation = location;
2416
+ const commitPromise = this.commitLocation({
2417
+ ...location,
2418
+ viewTransition,
2419
+ replace,
2420
+ resetScroll,
2421
+ hashScrollIntoView,
2422
+ ignoreBlocker
2423
+ });
2424
+ Promise.resolve().then(() => {
2425
+ if (this.pendingBuiltLocation === location) this.pendingBuiltLocation = void 0;
2426
+ });
2427
+ return commitPromise;
2428
+ };
2429
+ this.navigate = async ({ to, reloadDocument, href, publicHref, ...rest }) => {
2430
+ let hrefIsUrl = false;
2431
+ if (href) try {
2432
+ new URL(`${href}`);
2433
+ hrefIsUrl = true;
2434
+ } catch {
2435
+ }
2436
+ if (hrefIsUrl && !reloadDocument) reloadDocument = true;
2437
+ if (reloadDocument) {
2438
+ if (to !== void 0 || !href) {
2439
+ const location = this.buildLocation({
2440
+ to,
2441
+ ...rest
2442
+ });
2443
+ href = href ?? location.publicHref;
2444
+ publicHref = publicHref ?? location.publicHref;
2445
+ }
2446
+ const reloadHref = !hrefIsUrl && publicHref ? publicHref : href;
2447
+ if (isDangerousProtocol(reloadHref, this.protocolAllowlist)) {
2448
+ return Promise.resolve();
2449
+ }
2450
+ if (!rest.ignoreBlocker) {
2451
+ const blockers = this.history.getBlockers?.() ?? [];
2452
+ for (const blocker of blockers) if (blocker?.blockerFn) {
2453
+ if (await blocker.blockerFn({
2454
+ currentLocation: this.latestLocation,
2455
+ nextLocation: this.latestLocation,
2456
+ action: "PUSH"
2457
+ })) return Promise.resolve();
2458
+ }
2459
+ }
2460
+ if (rest.replace) window.location.replace(reloadHref);
2461
+ else window.location.href = reloadHref;
2462
+ return Promise.resolve();
2463
+ }
2464
+ return this.buildAndCommitLocation({
2465
+ ...rest,
2466
+ href,
2467
+ to,
2468
+ _isNavigate: true
2469
+ });
2470
+ };
2471
+ this.beforeLoad = () => {
2472
+ this.cancelMatches();
2473
+ this.updateLatestLocation();
2474
+ {
2475
+ const nextLocation = this.buildLocation({
2476
+ to: this.latestLocation.pathname,
2477
+ search: true,
2478
+ params: true,
2479
+ hash: true,
2480
+ state: true,
2481
+ _includeValidateSearch: true
2482
+ });
2483
+ if (this.latestLocation.publicHref !== nextLocation.publicHref) {
2484
+ const href = this.getParsedLocationHref(nextLocation);
2485
+ if (nextLocation.external) throw redirect({ href });
2486
+ else throw redirect({
2487
+ href,
2488
+ _builtLocation: nextLocation
2489
+ });
2490
+ }
2491
+ }
2492
+ const pendingMatches = this.matchRoutes(this.latestLocation);
2493
+ const nextCachedMatches = this.stores.cachedMatches.get().filter((d) => !pendingMatches.some((e) => e.id === d.id));
2494
+ this.batch(() => {
2495
+ this.stores.status.set("pending");
2496
+ this.stores.statusCode.set(200);
2497
+ this.stores.isLoading.set(true);
2498
+ this.stores.location.set(this.latestLocation);
2499
+ this.stores.setPending(pendingMatches);
2500
+ this.stores.setCached(nextCachedMatches);
2501
+ });
2502
+ };
2503
+ this.load = async (opts) => {
2504
+ const historyAction = opts?.action?.type;
2505
+ let redirect2;
2506
+ let notFound2;
2507
+ let loadPromise;
2508
+ const previousLocation = this.stores.resolvedLocation.get() ?? this.stores.location.get();
2509
+ loadPromise = new Promise((resolve) => {
2510
+ this.startTransition(async () => {
2511
+ try {
2512
+ this.beforeLoad();
2513
+ if (historyAction) locationHistoryActions.set(this.latestLocation, historyAction);
2514
+ else locationHistoryActions.delete(this.latestLocation);
2515
+ const next = this.latestLocation;
2516
+ const locationChangeInfo = getLocationChangeInfo(next, this.stores.resolvedLocation.get());
2517
+ if (!this.stores.redirect.get()) this.emit({
2518
+ type: "onBeforeNavigate",
2519
+ ...locationChangeInfo
2520
+ });
2521
+ this.emit({
2522
+ type: "onBeforeLoad",
2523
+ ...locationChangeInfo
2524
+ });
2525
+ await loadMatches({
2526
+ router: this,
2527
+ sync: opts?.sync,
2528
+ forceStaleReload: previousLocation.href === next.href,
2529
+ matches: this.stores.pendingMatches.get(),
2530
+ location: next,
2531
+ updateMatch: this.updateMatch,
2532
+ onReady: async () => {
2533
+ this.startTransition(() => {
2534
+ this.startViewTransition(async () => {
2535
+ let exitingMatches = null;
2536
+ let hookExitingMatches = null;
2537
+ let hookEnteringMatches = null;
2538
+ let hookStayingMatches = null;
2539
+ this.batch(() => {
2540
+ const pendingMatches = this.stores.pendingMatches.get();
2541
+ const mountPending = pendingMatches.length;
2542
+ const currentMatches = this.stores.matches.get();
2543
+ exitingMatches = mountPending ? currentMatches.filter((match) => !this.stores.pendingMatchStores.has(match.id)) : null;
2544
+ const pendingRouteIds = /* @__PURE__ */ new Set();
2545
+ for (const s of this.stores.pendingMatchStores.values()) if (s.routeId) pendingRouteIds.add(s.routeId);
2546
+ const activeRouteIds = /* @__PURE__ */ new Set();
2547
+ for (const s of this.stores.matchStores.values()) if (s.routeId) activeRouteIds.add(s.routeId);
2548
+ hookExitingMatches = mountPending ? currentMatches.filter((match) => !pendingRouteIds.has(match.routeId)) : null;
2549
+ hookEnteringMatches = mountPending ? pendingMatches.filter((match) => !activeRouteIds.has(match.routeId)) : null;
2550
+ hookStayingMatches = mountPending ? pendingMatches.filter((match) => activeRouteIds.has(match.routeId)) : currentMatches;
2551
+ this.stores.isLoading.set(false);
2552
+ this.stores.loadedAt.set(Date.now());
2553
+ if (mountPending) {
2554
+ this.stores.setMatches(pendingMatches);
2555
+ this.stores.setPending([]);
2556
+ this.stores.setCached([...this.stores.cachedMatches.get(), ...exitingMatches.filter((d) => d.status !== "error" && d.status !== "notFound" && d.status !== "redirected")]);
2557
+ this.clearExpiredCache();
2558
+ }
2559
+ });
2560
+ for (const [matches, hook] of [
2561
+ [hookExitingMatches, "onLeave"],
2562
+ [hookEnteringMatches, "onEnter"],
2563
+ [hookStayingMatches, "onStay"]
2564
+ ]) {
2565
+ if (!matches) continue;
2566
+ for (const match of matches) this.looseRoutesById[match.routeId].options[hook]?.(match);
2567
+ }
2568
+ });
2569
+ });
2570
+ }
2571
+ });
2572
+ } catch (err) {
2573
+ if (isRedirect(err)) {
2574
+ redirect2 = err;
2575
+ } else if (isNotFound(err)) notFound2 = err;
2576
+ const nextStatusCode = redirect2 ? redirect2.status : notFound2 ? 404 : this.stores.matches.get().some((d) => d.status === "error") ? 500 : 200;
2577
+ this.batch(() => {
2578
+ this.stores.statusCode.set(nextStatusCode);
2579
+ this.stores.redirect.set(redirect2);
2580
+ });
2581
+ }
2582
+ if (this.latestLoadPromise === loadPromise) {
2583
+ this.commitLocationPromise?.resolve();
2584
+ this.latestLoadPromise = void 0;
2585
+ this.commitLocationPromise = void 0;
2586
+ }
2587
+ resolve();
2588
+ });
2589
+ });
2590
+ this.latestLoadPromise = loadPromise;
2591
+ await loadPromise;
2592
+ while (this.latestLoadPromise && loadPromise !== this.latestLoadPromise) await this.latestLoadPromise;
2593
+ let newStatusCode = void 0;
2594
+ if (this.hasNotFoundMatch()) newStatusCode = 404;
2595
+ else if (this.stores.matches.get().some((d) => d.status === "error")) newStatusCode = 500;
2596
+ if (newStatusCode !== void 0) this.stores.statusCode.set(newStatusCode);
2597
+ };
2598
+ this.startViewTransition = (fn) => {
2599
+ const shouldViewTransition = this.shouldViewTransition ?? this.options.defaultViewTransition;
2600
+ this.shouldViewTransition = void 0;
2601
+ if (shouldViewTransition && typeof document !== "undefined" && "startViewTransition" in document && typeof document.startViewTransition === "function") {
2602
+ let startViewTransitionParams;
2603
+ if (typeof shouldViewTransition === "object" && this.isViewTransitionTypesSupported) {
2604
+ const next = this.latestLocation;
2605
+ const prevLocation = this.stores.resolvedLocation.get();
2606
+ const resolvedViewTransitionTypes = typeof shouldViewTransition.types === "function" ? shouldViewTransition.types(getLocationChangeInfo(next, prevLocation)) : shouldViewTransition.types;
2607
+ if (resolvedViewTransitionTypes === false) {
2608
+ fn();
2609
+ return;
2610
+ }
2611
+ startViewTransitionParams = {
2612
+ update: fn,
2613
+ types: resolvedViewTransitionTypes
2614
+ };
2615
+ } else startViewTransitionParams = fn;
2616
+ document.startViewTransition(startViewTransitionParams);
2617
+ } else fn();
2618
+ };
2619
+ this.updateMatch = (id, updater) => {
2620
+ this.startTransition(() => {
2621
+ const pendingMatch = this.stores.pendingMatchStores.get(id);
2622
+ if (pendingMatch) {
2623
+ pendingMatch.set(updater);
2624
+ return;
2625
+ }
2626
+ const activeMatch = this.stores.matchStores.get(id);
2627
+ if (activeMatch) {
2628
+ activeMatch.set(updater);
2629
+ return;
2630
+ }
2631
+ const cachedMatch = this.stores.cachedMatchStores.get(id);
2632
+ if (cachedMatch) {
2633
+ const next = updater(cachedMatch.get());
2634
+ if (next.status === "redirected") {
2635
+ if (this.stores.cachedMatchStores.delete(id)) this.stores.cachedIds.set((prev) => prev.filter((matchId) => matchId !== id));
2636
+ } else cachedMatch.set(next);
2637
+ }
2638
+ });
2639
+ };
2640
+ this.getMatch = (matchId) => {
2641
+ return this.stores.cachedMatchStores.get(matchId)?.get() ?? this.stores.pendingMatchStores.get(matchId)?.get() ?? this.stores.matchStores.get(matchId)?.get();
2642
+ };
2643
+ this.invalidate = (opts) => {
2644
+ const invalidate = (d) => {
2645
+ if (opts?.filter?.(d) ?? true) return {
2646
+ ...d,
2647
+ invalid: true,
2648
+ ...opts?.forcePending || d.status === "error" || d.status === "notFound" ? {
2649
+ status: "pending",
2650
+ error: void 0
2651
+ } : void 0
2652
+ };
2653
+ return d;
2654
+ };
2655
+ this.batch(() => {
2656
+ this.stores.setMatches(this.stores.matches.get().map(invalidate));
2657
+ this.stores.setCached(this.stores.cachedMatches.get().map(invalidate));
2658
+ this.stores.setPending(this.stores.pendingMatches.get().map(invalidate));
2659
+ });
2660
+ this.shouldViewTransition = false;
2661
+ return this.load({ sync: opts?.sync });
2662
+ };
2663
+ this.getParsedLocationHref = (location) => {
2664
+ return location.publicHref || "/";
2665
+ };
2666
+ this.resolveRedirect = (redirect2) => {
2667
+ const locationHeader = redirect2.headers.get("Location");
2668
+ if (!redirect2.options.href || redirect2.options._builtLocation) {
2669
+ const location = redirect2.options._builtLocation ?? this.buildLocation(redirect2.options);
2670
+ const href = this.getParsedLocationHref(location);
2671
+ redirect2.options.href = href;
2672
+ redirect2.headers.set("Location", href);
2673
+ } else if (locationHeader) try {
2674
+ const url = new URL(locationHeader);
2675
+ if (this.origin && url.origin === this.origin) {
2676
+ const href = url.pathname + url.search + url.hash;
2677
+ redirect2.options.href = href;
2678
+ redirect2.headers.set("Location", href);
2679
+ }
2680
+ } catch {
2681
+ }
2682
+ if (redirect2.options.href && !redirect2.options._builtLocation && isDangerousProtocol(redirect2.options.href, this.protocolAllowlist)) throw new Error("Redirect blocked: unsafe protocol");
2683
+ if (!redirect2.headers.get("Location")) redirect2.headers.set("Location", redirect2.options.href);
2684
+ return redirect2;
2685
+ };
2686
+ this.clearCache = (opts) => {
2687
+ const filter = opts?.filter;
2688
+ if (filter !== void 0) this.stores.setCached(this.stores.cachedMatches.get().filter((m) => !filter(m)));
2689
+ else this.stores.setCached([]);
2690
+ };
2691
+ this.clearExpiredCache = () => {
2692
+ const now = Date.now();
2693
+ const filter = (d) => {
2694
+ const route = this.looseRoutesById[d.routeId];
2695
+ if (!route.options.loader) return true;
2696
+ const gcTime = (d.preload ? route.options.preloadGcTime ?? this.options.defaultPreloadGcTime : route.options.gcTime ?? this.options.defaultGcTime) ?? 300 * 1e3;
2697
+ if (d.status === "error") return true;
2698
+ return now - d.updatedAt >= gcTime;
2699
+ };
2700
+ this.clearCache({ filter });
2701
+ };
2702
+ this.loadRouteChunk = loadRouteChunk;
2703
+ this.preloadRoute = async (opts) => {
2704
+ const next = opts._builtLocation ?? this.buildLocation(opts);
2705
+ let matches = this.matchRoutes(next, {
2706
+ throwOnError: true,
2707
+ preload: true,
2708
+ dest: opts
2709
+ });
2710
+ const activeMatchIds = /* @__PURE__ */ new Set([...this.stores.matchesId.get(), ...this.stores.pendingIds.get()]);
2711
+ const loadedMatchIds = /* @__PURE__ */ new Set([...activeMatchIds, ...this.stores.cachedIds.get()]);
2712
+ const matchesToCache = matches.filter((match) => !loadedMatchIds.has(match.id));
2713
+ if (matchesToCache.length) {
2714
+ const cachedMatches = this.stores.cachedMatches.get();
2715
+ this.stores.setCached([...cachedMatches, ...matchesToCache]);
2716
+ }
2717
+ try {
2718
+ matches = await loadMatches({
2719
+ router: this,
2720
+ matches,
2721
+ location: next,
2722
+ preload: true,
2723
+ updateMatch: (id, updater) => {
2724
+ if (activeMatchIds.has(id)) matches = matches.map((d) => d.id === id ? updater(d) : d);
2725
+ else this.updateMatch(id, updater);
2726
+ }
2727
+ });
2728
+ return matches;
2729
+ } catch (err) {
2730
+ if (isRedirect(err)) {
2731
+ if (err.options.reloadDocument) return;
2732
+ return await this.preloadRoute({
2733
+ ...err.options,
2734
+ _fromLocation: next
2735
+ });
2736
+ }
2737
+ if (!isNotFound(err)) console.error(err);
2738
+ return;
2739
+ }
2740
+ };
2741
+ this.matchRoute = (location, opts) => {
2742
+ const matchLocation = {
2743
+ ...location,
2744
+ to: location.to ? this.resolvePathWithBase(location.from || "", location.to) : void 0,
2745
+ params: location.params || {},
2746
+ leaveParams: true
2747
+ };
2748
+ const next = this.buildLocation(matchLocation);
2749
+ if (opts?.pending && this.stores.status.get() !== "pending") return false;
2750
+ const baseLocation = (opts?.pending === void 0 ? !this.stores.isLoading.get() : opts.pending) ? this.latestLocation : this.stores.resolvedLocation.get() || this.stores.location.get();
2751
+ const match = findSingleMatch(next.pathname, opts?.caseSensitive ?? false, opts?.fuzzy ?? false, baseLocation.pathname, this.processedTree);
2752
+ if (!match) return false;
2753
+ if (location.params) {
2754
+ if (!deepEqual(match.rawParams, location.params, { partial: true })) return false;
2755
+ }
2756
+ if (opts?.includeSearch ?? true) return deepEqual(baseLocation.search, next.search, { partial: true }) ? match.rawParams : false;
2757
+ return match.rawParams;
2758
+ };
2759
+ this.hasNotFoundMatch = () => {
2760
+ return this.stores.matches.get().some((d) => d.status === "notFound" || d.globalNotFound);
2761
+ };
2762
+ this.getStoreConfig = getStoreConfig;
2763
+ this.update({
2764
+ defaultPreloadDelay: 50,
2765
+ defaultPendingMs: 1e3,
2766
+ defaultPendingMinMs: 500,
2767
+ context: void 0,
2768
+ ...options,
2769
+ caseSensitive: options.caseSensitive ?? false,
2770
+ notFoundMode: options.notFoundMode ?? "fuzzy",
2771
+ stringifySearch: options.stringifySearch ?? defaultStringifySearch,
2772
+ parseSearch: options.parseSearch ?? defaultParseSearch,
2773
+ protocolAllowlist: options.protocolAllowlist ?? DEFAULT_PROTOCOL_ALLOWLIST
2774
+ });
2775
+ if (typeof document !== "undefined") self.__TSR_ROUTER__ = this;
2776
+ }
2777
+ isShell() {
2778
+ return !!this.options.isShell;
2779
+ }
2780
+ isPrerendering() {
2781
+ return !!this.options.isPrerendering;
2782
+ }
2783
+ get state() {
2784
+ return this.stores.__store.get();
2785
+ }
2786
+ setRoutes({ routesById, routesByPath, processedTree }) {
2787
+ this.routesById = routesById;
2788
+ this.routesByPath = routesByPath;
2789
+ this.processedTree = processedTree;
2790
+ const notFoundRoute = this.options.notFoundRoute;
2791
+ if (notFoundRoute) {
2792
+ notFoundRoute.init({ originalIndex: 99999999999 });
2793
+ this.routesById[notFoundRoute.id] = notFoundRoute;
2794
+ }
2795
+ }
2796
+ getRouteBranch(route) {
2797
+ let branch = this.routeBranchCache.get(route);
2798
+ if (!branch) {
2799
+ branch = buildRouteBranch(route);
2800
+ this.routeBranchCache.set(route, branch);
2801
+ }
2802
+ return branch;
2803
+ }
2804
+ get looseRoutesById() {
2805
+ return this.routesById;
2806
+ }
2807
+ getParentContext(parentMatch) {
2808
+ return !parentMatch?.id ? this.options.context ?? void 0 : parentMatch.context ?? this.options.context ?? void 0;
2809
+ }
2810
+ matchRoutesInternal(next, opts) {
2811
+ const matchedRoutesResult = this.getMatchedRoutes(next.pathname);
2812
+ const { foundRoute, routeParams } = matchedRoutesResult;
2813
+ let { matchedRoutes } = matchedRoutesResult;
2814
+ let isGlobalNotFound = false;
2815
+ if (foundRoute ? foundRoute.path !== "/" && routeParams["**"] : trimPathRight(next.pathname)) if (this.options.notFoundRoute) matchedRoutes = [...matchedRoutes, this.options.notFoundRoute];
2816
+ else isGlobalNotFound = true;
2817
+ const globalNotFoundRouteId = isGlobalNotFound ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes) : void 0;
2818
+ const matches = new Array(matchedRoutes.length);
2819
+ const previousActiveMatchesByRouteId = /* @__PURE__ */ new Map();
2820
+ for (const store of this.stores.matchStores.values()) if (store.routeId) previousActiveMatchesByRouteId.set(store.routeId, store.get());
2821
+ for (let index = 0; index < matchedRoutes.length; index++) {
2822
+ const route = matchedRoutes[index];
2823
+ const parentMatch = matches[index - 1];
2824
+ let preMatchSearch;
2825
+ let strictMatchSearch;
2826
+ let searchError;
2827
+ {
2828
+ const parentSearch = parentMatch?.search ?? next.search;
2829
+ const parentStrictSearch = parentMatch?._strictSearch ?? void 0;
2830
+ try {
2831
+ const strictSearch = validateSearch(route.options.validateSearch, { ...parentSearch }) ?? void 0;
2832
+ preMatchSearch = {
2833
+ ...parentSearch,
2834
+ ...strictSearch
2835
+ };
2836
+ strictMatchSearch = {
2837
+ ...parentStrictSearch,
2838
+ ...strictSearch
2839
+ };
2840
+ searchError = void 0;
2841
+ } catch (err) {
2842
+ let searchParamError = err;
2843
+ if (!(err instanceof SearchParamError)) searchParamError = new SearchParamError(err.message, { cause: err });
2844
+ if (opts?.throwOnError) throw searchParamError;
2845
+ preMatchSearch = parentSearch;
2846
+ strictMatchSearch = {};
2847
+ searchError = searchParamError;
2848
+ }
2849
+ }
2850
+ const loaderDeps = route.options.loaderDeps?.({ search: preMatchSearch }) ?? "";
2851
+ const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : "";
2852
+ const { interpolatedPath, usedParams } = interpolatePath({
2853
+ path: route.fullPath,
2854
+ params: routeParams,
2855
+ decoder: this.pathParamsDecoder,
2856
+ server: this.isServer
2857
+ });
2858
+ const matchId = route.id + interpolatedPath + loaderDepsHash;
2859
+ const existingMatch = this.getMatch(matchId);
2860
+ const previousMatch = previousActiveMatchesByRouteId.get(route.id);
2861
+ const strictParams = existingMatch?._strictParams ?? usedParams;
2862
+ let paramsError = void 0;
2863
+ if (!existingMatch) try {
2864
+ extractStrictParams(route, strictParams);
2865
+ } catch (err) {
2866
+ if (isNotFound(err) || isRedirect(err)) paramsError = err;
2867
+ else paramsError = new PathParamError(err.message, { cause: err });
2868
+ if (opts?.throwOnError) throw paramsError;
2869
+ }
2870
+ Object.assign(routeParams, strictParams);
2871
+ const cause = previousMatch ? "stay" : "enter";
2872
+ let match;
2873
+ if (existingMatch) match = {
2874
+ ...existingMatch,
2875
+ cause,
2876
+ params: previousMatch?.params ?? routeParams,
2877
+ _strictParams: strictParams,
2878
+ search: previousMatch ? nullReplaceEqualDeep(previousMatch.search, preMatchSearch) : nullReplaceEqualDeep(existingMatch.search, preMatchSearch),
2879
+ _strictSearch: strictMatchSearch
2880
+ };
2881
+ else {
2882
+ const status = route.options.loader || route.options.beforeLoad || route.lazyFn || routeNeedsPreload(route) ? "pending" : "success";
2883
+ match = {
2884
+ id: matchId,
2885
+ ssr: void 0,
2886
+ index,
2887
+ routeId: route.id,
2888
+ params: previousMatch?.params ?? routeParams,
2889
+ _strictParams: strictParams,
2890
+ pathname: interpolatedPath,
2891
+ updatedAt: Date.now(),
2892
+ search: previousMatch ? nullReplaceEqualDeep(previousMatch.search, preMatchSearch) : preMatchSearch,
2893
+ _strictSearch: strictMatchSearch,
2894
+ searchError: void 0,
2895
+ status,
2896
+ isFetching: false,
2897
+ error: void 0,
2898
+ paramsError,
2899
+ __routeContext: void 0,
2900
+ _nonReactive: { loadPromise: createControlledPromise() },
2901
+ __beforeLoadContext: void 0,
2902
+ context: {},
2903
+ abortController: new AbortController(),
2904
+ fetchCount: 0,
2905
+ cause,
2906
+ loaderDeps: previousMatch ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps) : loaderDeps,
2907
+ invalid: false,
2908
+ preload: false,
2909
+ links: void 0,
2910
+ scripts: void 0,
2911
+ headScripts: void 0,
2912
+ meta: void 0,
2913
+ staticData: route.options.staticData || {},
2914
+ fullPath: route.fullPath
2915
+ };
2916
+ }
2917
+ if (!opts?.preload) match.globalNotFound = globalNotFoundRouteId === route.id;
2918
+ match.searchError = searchError;
2919
+ const parentContext = this.getParentContext(parentMatch);
2920
+ match.context = {
2921
+ ...parentContext,
2922
+ ...match.__routeContext,
2923
+ ...match.__beforeLoadContext
2924
+ };
2925
+ matches[index] = match;
2926
+ }
2927
+ for (let index = 0; index < matches.length; index++) {
2928
+ const match = matches[index];
2929
+ const route = this.looseRoutesById[match.routeId];
2930
+ const existingMatch = this.getMatch(match.id);
2931
+ const previousMatch = previousActiveMatchesByRouteId.get(match.routeId);
2932
+ match.params = previousMatch ? nullReplaceEqualDeep(previousMatch.params, routeParams) : routeParams;
2933
+ if (!existingMatch) {
2934
+ const parentMatch = matches[index - 1];
2935
+ const parentContext = this.getParentContext(parentMatch);
2936
+ if (route.options.context) {
2937
+ const contextFnContext = {
2938
+ deps: match.loaderDeps,
2939
+ params: match.params,
2940
+ context: parentContext ?? {},
2941
+ location: next,
2942
+ navigate: (opts2) => this.navigate({
2943
+ ...opts2,
2944
+ _fromLocation: next
2945
+ }),
2946
+ buildLocation: this.buildLocation,
2947
+ cause: match.cause,
2948
+ abortController: match.abortController,
2949
+ preload: !!match.preload,
2950
+ matches,
2951
+ routeId: route.id
2952
+ };
2953
+ match.__routeContext = route.options.context(contextFnContext) ?? void 0;
2954
+ }
2955
+ match.context = {
2956
+ ...parentContext,
2957
+ ...match.__routeContext,
2958
+ ...match.__beforeLoadContext
2959
+ };
2960
+ }
2961
+ }
2962
+ return matches;
2963
+ }
2964
+ /**
2965
+ * Lightweight route matching for buildLocation.
2966
+ * Only computes fullPath, accumulated search, and params - skipping expensive
2967
+ * operations like AbortController, ControlledPromise, loaderDeps, and full match objects.
2968
+ */
2969
+ matchRoutesLightweight(location) {
2970
+ const { matchedRoutes, routeParams } = this.getMatchedRoutes(location.pathname);
2971
+ const lastRoute = last(matchedRoutes);
2972
+ const accumulatedSearch = { ...location.search };
2973
+ for (const route of matchedRoutes) try {
2974
+ Object.assign(accumulatedSearch, validateSearch(route.options.validateSearch, accumulatedSearch));
2975
+ } catch {
2976
+ }
2977
+ const lastStateMatchId = last(this.stores.matchesId.get());
2978
+ const lastStateMatch = lastStateMatchId && this.stores.matchStores.get(lastStateMatchId)?.get();
2979
+ const canReuseParams = lastStateMatch && lastStateMatch.routeId === lastRoute.id && lastStateMatch.pathname === location.pathname;
2980
+ let params;
2981
+ if (canReuseParams) params = lastStateMatch.params;
2982
+ else {
2983
+ const strictParams = Object.assign(/* @__PURE__ */ Object.create(null), routeParams);
2984
+ for (const route of matchedRoutes) try {
2985
+ extractStrictParams(route, strictParams);
2986
+ } catch {
2987
+ }
2988
+ params = strictParams;
2989
+ }
2990
+ return {
2991
+ matchedRoutes,
2992
+ fullPath: lastRoute.fullPath,
2993
+ search: accumulatedSearch,
2994
+ params
2995
+ };
2996
+ }
2997
+ };
2998
+ var SearchParamError = class extends Error {
2999
+ };
3000
+ var PathParamError = class extends Error {
3001
+ };
3002
+ function getInitialRouterState(location) {
3003
+ return {
3004
+ loadedAt: 0,
3005
+ isLoading: false,
3006
+ isTransitioning: false,
3007
+ status: "idle",
3008
+ resolvedLocation: void 0,
3009
+ location,
3010
+ matches: [],
3011
+ statusCode: 200
3012
+ };
3013
+ }
3014
+ function validateSearch(validateSearch2, input) {
3015
+ if (validateSearch2 == null) return {};
3016
+ if ("~standard" in validateSearch2) {
3017
+ const result = validateSearch2["~standard"].validate(input);
3018
+ if (result instanceof Promise) throw new SearchParamError("Async validation not supported");
3019
+ if (result.issues) throw new SearchParamError(JSON.stringify(result.issues, void 0, 2), { cause: result });
3020
+ return result.value;
3021
+ }
3022
+ if ("parse" in validateSearch2) return validateSearch2.parse(input);
3023
+ if (typeof validateSearch2 === "function") return validateSearch2(input);
3024
+ return {};
3025
+ }
3026
+ function getMatchedRoutes({ pathname, routesById, processedTree }) {
3027
+ const routeParams = /* @__PURE__ */ Object.create(null);
3028
+ const trimmedPath = trimPathRight(pathname);
3029
+ let foundRoute = void 0;
3030
+ const match = findRouteMatch(trimmedPath, processedTree, true);
3031
+ if (match) {
3032
+ foundRoute = match.route;
3033
+ Object.assign(routeParams, match.rawParams);
3034
+ }
3035
+ return {
3036
+ matchedRoutes: match?.branch || [routesById["__root__"]],
3037
+ routeParams,
3038
+ foundRoute
3039
+ };
3040
+ }
3041
+ function applySearchMiddleware({ search, dest, destRoutes, _includeValidateSearch }) {
3042
+ return buildMiddlewareChain(destRoutes)(search, dest, _includeValidateSearch ?? false);
3043
+ }
3044
+ function buildMiddlewareChain(destRoutes) {
3045
+ const context = {
3046
+ dest: null,
3047
+ _includeValidateSearch: false,
3048
+ middlewares: []
3049
+ };
3050
+ for (const route of destRoutes) {
3051
+ if ("search" in route.options) {
3052
+ if (route.options.search?.middlewares) context.middlewares.push(...route.options.search.middlewares);
3053
+ } else if (route.options.preSearchFilters || route.options.postSearchFilters) {
3054
+ const legacyMiddleware = ({ search, next }) => {
3055
+ let nextSearch = search;
3056
+ if ("preSearchFilters" in route.options && route.options.preSearchFilters) nextSearch = route.options.preSearchFilters.reduce((prev, next2) => next2(prev), search);
3057
+ const result = next(nextSearch);
3058
+ if ("postSearchFilters" in route.options && route.options.postSearchFilters) return route.options.postSearchFilters.reduce((prev, next2) => next2(prev), result);
3059
+ return result;
3060
+ };
3061
+ context.middlewares.push(legacyMiddleware);
3062
+ }
3063
+ if (route.options.validateSearch) {
3064
+ const validate = ({ search, next }) => {
3065
+ const result = next(search);
3066
+ if (!context._includeValidateSearch) return result;
3067
+ try {
3068
+ return {
3069
+ ...result,
3070
+ ...validateSearch(route.options.validateSearch, result) ?? void 0
3071
+ };
3072
+ } catch {
3073
+ return result;
3074
+ }
3075
+ };
3076
+ context.middlewares.push(validate);
3077
+ }
3078
+ }
3079
+ const final = ({ search }) => {
3080
+ const dest = context.dest;
3081
+ if (!dest.search) return {};
3082
+ if (dest.search === true) return search;
3083
+ return functionalUpdate(dest.search, search);
3084
+ };
3085
+ context.middlewares.push(final);
3086
+ const applyNext = (index, currentSearch, middlewares) => {
3087
+ if (index >= middlewares.length) return currentSearch;
3088
+ const middleware = middlewares[index];
3089
+ const next = (newSearch) => {
3090
+ return applyNext(index + 1, newSearch, middlewares);
3091
+ };
3092
+ return middleware({
3093
+ search: currentSearch,
3094
+ next
3095
+ });
3096
+ };
3097
+ return function middleware(search, dest, _includeValidateSearch) {
3098
+ context.dest = dest;
3099
+ context._includeValidateSearch = _includeValidateSearch;
3100
+ return applyNext(0, search, context.middlewares);
3101
+ };
3102
+ }
3103
+ function findGlobalNotFoundRouteId(notFoundMode, routes) {
3104
+ if (notFoundMode !== "root") for (let i = routes.length - 1; i >= 0; i--) {
3105
+ const route = routes[i];
3106
+ if (route.children) return route.id;
3107
+ }
3108
+ return rootRouteId;
3109
+ }
3110
+ function extractStrictParams(route, accumulatedParams) {
3111
+ const parseParams = route.options.params?.parse ?? route.options.parseParams;
3112
+ if (parseParams) {
3113
+ const result = parseParams(accumulatedParams);
3114
+ if (result === false) throw new Error("Route params.parse returned false for a matched route");
3115
+ Object.assign(accumulatedParams, result);
3116
+ }
3117
+ }
3118
+ function getAssetCrossOrigin(assetCrossOrigin, kind) {
3119
+ if (!assetCrossOrigin) return;
3120
+ if (typeof assetCrossOrigin === "string") return assetCrossOrigin;
3121
+ return assetCrossOrigin[kind];
3122
+ }
3123
+ function resolveManifestAssetLink(link) {
3124
+ if (typeof link === "string") return {
3125
+ href: link,
3126
+ crossOrigin: void 0
3127
+ };
3128
+ return link;
3129
+ }
3130
+ function getStylesheetHref(asset) {
3131
+ if (asset.tag !== "link") return void 0;
3132
+ const rel = asset.attrs?.rel;
3133
+ const href = asset.attrs?.href;
3134
+ if (typeof href !== "string") return void 0;
3135
+ if (!(typeof rel === "string" ? rel.split(/\s+/) : []).includes("stylesheet")) return void 0;
3136
+ return href;
3137
+ }
3138
+ function isInlinableStylesheet(manifest, asset) {
3139
+ const href = getStylesheetHref(asset);
3140
+ return !!href && manifest?.inlineCss?.styles[href] !== void 0;
3141
+ }
3142
+ function createInlineCssStyleAsset(css) {
3143
+ return {
3144
+ tag: "style",
3145
+ attrs: { suppressHydrationWarning: true },
3146
+ inlineCss: true,
3147
+ children: css
3148
+ };
3149
+ }
3150
+ function createInlineCssPlaceholderAsset() {
3151
+ return {
3152
+ tag: "style",
3153
+ attrs: { suppressHydrationWarning: true },
3154
+ inlineCss: true
3155
+ };
3156
+ }
3157
+ var BaseRoute = class {
3158
+ get to() {
3159
+ return this._to;
3160
+ }
3161
+ get id() {
3162
+ return this._id;
3163
+ }
3164
+ get path() {
3165
+ return this._path;
3166
+ }
3167
+ get fullPath() {
3168
+ return this._fullPath;
3169
+ }
3170
+ constructor(options) {
3171
+ this.init = (opts) => {
3172
+ this.originalIndex = opts.originalIndex;
3173
+ const options2 = this.options;
3174
+ const isRoot = !options2?.path && !options2?.id;
3175
+ this.parentRoute = this.options.getParentRoute?.();
3176
+ if (isRoot) this._path = rootRouteId;
3177
+ else if (!this.parentRoute) {
3178
+ invariant();
3179
+ }
3180
+ let path = isRoot ? rootRouteId : options2?.path;
3181
+ if (path && path !== "/") path = trimPathLeft(path);
3182
+ const customId = options2?.id || path;
3183
+ let id = isRoot ? rootRouteId : joinPaths([this.parentRoute.id === "__root__" ? "" : this.parentRoute.id, customId]);
3184
+ if (path === "__root__") path = "/";
3185
+ if (id !== "__root__") id = joinPaths(["/", id]);
3186
+ const fullPath = id === "__root__" ? "/" : joinPaths([this.parentRoute.fullPath, path]);
3187
+ this._path = path;
3188
+ this._id = id;
3189
+ this._fullPath = fullPath;
3190
+ this._to = trimPathRight(fullPath);
3191
+ };
3192
+ this.addChildren = (children) => {
3193
+ return this._addFileChildren(children);
3194
+ };
3195
+ this._addFileChildren = (children) => {
3196
+ if (Array.isArray(children)) this.children = children;
3197
+ if (typeof children === "object" && children !== null) this.children = Object.values(children);
3198
+ return this;
3199
+ };
3200
+ this._addFileTypes = () => {
3201
+ return this;
3202
+ };
3203
+ this.updateLoader = (options2) => {
3204
+ Object.assign(this.options, options2);
3205
+ return this;
3206
+ };
3207
+ this.update = (options2) => {
3208
+ Object.assign(this.options, options2);
3209
+ return this;
3210
+ };
3211
+ this.lazy = (lazyFn) => {
3212
+ this.lazyFn = lazyFn;
3213
+ return this;
3214
+ };
3215
+ this.redirect = (opts) => redirect({
3216
+ from: this.fullPath,
3217
+ ...opts
3218
+ });
3219
+ this.options = options || {};
3220
+ this.isRoot = !options?.getParentRoute;
3221
+ if (options?.id && options?.path) throw new Error(`Route cannot have both an 'id' and a 'path' option.`);
3222
+ }
3223
+ };
3224
+ var BaseRootRoute = class extends BaseRoute {
3225
+ constructor(options) {
3226
+ super(options);
3227
+ }
3228
+ };
3229
+ const GLOBAL_TSR = "$_TSR";
3230
+ const TSR_SCRIPT_BARRIER_ID = "$tsr-stream-barrier";
3231
+ function createSerializationAdapter(opts) {
3232
+ return opts;
3233
+ }
3234
+ // @__NO_SIDE_EFFECTS__
3235
+ function makeSsrSerovalPlugin(serializationAdapter, options) {
3236
+ return /* @__PURE__ */ ai({
3237
+ tag: "$TSR/t/" + serializationAdapter.key,
3238
+ test: serializationAdapter.test,
3239
+ parse: { stream(value, ctx, _data) {
3240
+ return { v: ctx.parse(serializationAdapter.toSerializable(value)) };
3241
+ } },
3242
+ serialize(node, ctx, _data) {
3243
+ options.didRun = true;
3244
+ return GLOBAL_TSR + '.t.get("' + serializationAdapter.key + '")(' + ctx.serialize(node.v) + ")";
3245
+ },
3246
+ deserialize: void 0
3247
+ });
3248
+ }
3249
+ // @__NO_SIDE_EFFECTS__
3250
+ function makeSerovalPlugin(serializationAdapter) {
3251
+ return /* @__PURE__ */ ai({
3252
+ tag: "$TSR/t/" + serializationAdapter.key,
3253
+ test: serializationAdapter.test,
3254
+ parse: {
3255
+ sync(value, ctx, _data) {
3256
+ return { v: ctx.parse(serializationAdapter.toSerializable(value)) };
3257
+ },
3258
+ async async(value, ctx, _data) {
3259
+ return { v: await ctx.parse(serializationAdapter.toSerializable(value)) };
3260
+ },
3261
+ stream(value, ctx, _data) {
3262
+ return { v: ctx.parse(serializationAdapter.toSerializable(value)) };
3263
+ }
3264
+ },
3265
+ serialize: void 0,
3266
+ deserialize(node, ctx, _data) {
3267
+ return serializationAdapter.fromSerializable(ctx.deserialize(node.v));
3268
+ }
3269
+ });
3270
+ }
3271
+ var RawStream = class {
3272
+ constructor(stream, options) {
3273
+ this.stream = stream;
3274
+ this.hint = options?.hint ?? "binary";
3275
+ }
3276
+ };
3277
+ const BufferCtor = globalThis.Buffer;
3278
+ const hasNodeBuffer = !!BufferCtor && typeof BufferCtor.from === "function";
3279
+ function uint8ArrayToBase64(bytes) {
3280
+ if (bytes.length === 0) return "";
3281
+ if (hasNodeBuffer) return BufferCtor.from(bytes).toString("base64");
3282
+ const CHUNK_SIZE = 32768;
3283
+ const chunks = [];
3284
+ for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
3285
+ const chunk = bytes.subarray(i, i + CHUNK_SIZE);
3286
+ chunks.push(String.fromCharCode.apply(null, chunk));
3287
+ }
3288
+ return btoa(chunks.join(""));
3289
+ }
3290
+ function base64ToUint8Array(base64) {
3291
+ if (base64.length === 0) return new Uint8Array(0);
3292
+ if (hasNodeBuffer) {
3293
+ const buf = BufferCtor.from(base64, "base64");
3294
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
3295
+ }
3296
+ const binary = atob(base64);
3297
+ const bytes = new Uint8Array(binary.length);
3298
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
3299
+ return bytes;
3300
+ }
3301
+ const RAW_STREAM_FACTORY_BINARY = /* @__PURE__ */ Object.create(null);
3302
+ const RAW_STREAM_FACTORY_TEXT = /* @__PURE__ */ Object.create(null);
3303
+ const RAW_STREAM_FACTORY_CONSTRUCTOR_BINARY = (stream) => new ReadableStream({ start(controller) {
3304
+ stream.on({
3305
+ next(base64) {
3306
+ try {
3307
+ controller.enqueue(base64ToUint8Array(base64));
3308
+ } catch {
3309
+ }
3310
+ },
3311
+ throw(error) {
3312
+ controller.error(error);
3313
+ },
3314
+ return() {
3315
+ try {
3316
+ controller.close();
3317
+ } catch {
3318
+ }
3319
+ }
3320
+ });
3321
+ } });
3322
+ const textEncoderForFactory = new TextEncoder();
3323
+ const RAW_STREAM_FACTORY_CONSTRUCTOR_TEXT = (stream) => {
3324
+ return new ReadableStream({ start(controller) {
3325
+ stream.on({
3326
+ next(value) {
3327
+ try {
3328
+ if (typeof value === "string") controller.enqueue(textEncoderForFactory.encode(value));
3329
+ else controller.enqueue(base64ToUint8Array(value.$b64));
3330
+ } catch {
3331
+ }
3332
+ },
3333
+ throw(error) {
3334
+ controller.error(error);
3335
+ },
3336
+ return() {
3337
+ try {
3338
+ controller.close();
3339
+ } catch {
3340
+ }
3341
+ }
3342
+ });
3343
+ } });
3344
+ };
3345
+ const FACTORY_BINARY = `(s=>new ReadableStream({start(c){s.on({next(b){try{const d=atob(b),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}catch(_){}},throw(e){c.error(e)},return(){try{c.close()}catch(_){}}})}}))`;
3346
+ const FACTORY_TEXT = `(s=>{const e=new TextEncoder();return new ReadableStream({start(c){s.on({next(v){try{if(typeof v==='string'){c.enqueue(e.encode(v))}else{const d=atob(v.$b64),a=new Uint8Array(d.length);for(let i=0;i<d.length;i++)a[i]=d.charCodeAt(i);c.enqueue(a)}}catch(_){}},throw(x){c.error(x)},return(){try{c.close()}catch(_){}}})}})})`;
3347
+ function toBinaryStream(readable) {
3348
+ const stream = re();
3349
+ const reader = readable.getReader();
3350
+ (async () => {
3351
+ try {
3352
+ while (true) {
3353
+ const { done, value } = await reader.read();
3354
+ if (done) {
3355
+ stream.return(void 0);
3356
+ break;
3357
+ }
3358
+ stream.next(uint8ArrayToBase64(value));
3359
+ }
3360
+ } catch (error) {
3361
+ stream.throw(error);
3362
+ } finally {
3363
+ reader.releaseLock();
3364
+ }
3365
+ })();
3366
+ return stream;
3367
+ }
3368
+ function toTextStream(readable) {
3369
+ const stream = re();
3370
+ const reader = readable.getReader();
3371
+ const decoder = new TextDecoder("utf-8", { fatal: true });
3372
+ (async () => {
3373
+ try {
3374
+ while (true) {
3375
+ const { done, value } = await reader.read();
3376
+ if (done) {
3377
+ try {
3378
+ const remaining = decoder.decode();
3379
+ if (remaining.length > 0) stream.next(remaining);
3380
+ } catch {
3381
+ }
3382
+ stream.return(void 0);
3383
+ break;
3384
+ }
3385
+ try {
3386
+ const text = decoder.decode(value, { stream: true });
3387
+ if (text.length > 0) stream.next(text);
3388
+ } catch {
3389
+ stream.next({ $b64: uint8ArrayToBase64(value) });
3390
+ }
3391
+ }
3392
+ } catch (error) {
3393
+ stream.throw(error);
3394
+ } finally {
3395
+ reader.releaseLock();
3396
+ }
3397
+ })();
3398
+ return stream;
3399
+ }
3400
+ const RawStreamSSRPlugin = /* @__PURE__ */ ai({
3401
+ tag: "tss/RawStream",
3402
+ extends: [/* @__PURE__ */ ai({
3403
+ tag: "tss/RawStreamFactory",
3404
+ test(value) {
3405
+ return value === RAW_STREAM_FACTORY_BINARY;
3406
+ },
3407
+ parse: {
3408
+ sync(_value, _ctx, _data) {
3409
+ return {};
3410
+ },
3411
+ async async(_value, _ctx, _data) {
3412
+ return {};
3413
+ },
3414
+ stream(_value, _ctx, _data) {
3415
+ return {};
3416
+ }
3417
+ },
3418
+ serialize(_node, _ctx, _data) {
3419
+ return FACTORY_BINARY;
3420
+ },
3421
+ deserialize(_node, _ctx, _data) {
3422
+ return RAW_STREAM_FACTORY_BINARY;
3423
+ }
3424
+ }), /* @__PURE__ */ ai({
3425
+ tag: "tss/RawStreamFactoryText",
3426
+ test(value) {
3427
+ return value === RAW_STREAM_FACTORY_TEXT;
3428
+ },
3429
+ parse: {
3430
+ sync(_value, _ctx, _data) {
3431
+ return {};
3432
+ },
3433
+ async async(_value, _ctx, _data) {
3434
+ return {};
3435
+ },
3436
+ stream(_value, _ctx, _data) {
3437
+ return {};
3438
+ }
3439
+ },
3440
+ serialize(_node, _ctx, _data) {
3441
+ return FACTORY_TEXT;
3442
+ },
3443
+ deserialize(_node, _ctx, _data) {
3444
+ return RAW_STREAM_FACTORY_TEXT;
3445
+ }
3446
+ })],
3447
+ test(value) {
3448
+ return value instanceof RawStream;
3449
+ },
3450
+ parse: {
3451
+ sync(value, ctx, _data) {
3452
+ const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
3453
+ return {
3454
+ hint: ctx.parse(value.hint),
3455
+ factory: ctx.parse(factory),
3456
+ stream: ctx.parse(re())
3457
+ };
3458
+ },
3459
+ async async(value, ctx, _data) {
3460
+ const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
3461
+ const encodedStream = value.hint === "text" ? toTextStream(value.stream) : toBinaryStream(value.stream);
3462
+ return {
3463
+ hint: await ctx.parse(value.hint),
3464
+ factory: await ctx.parse(factory),
3465
+ stream: await ctx.parse(encodedStream)
3466
+ };
3467
+ },
3468
+ stream(value, ctx, _data) {
3469
+ const factory = value.hint === "text" ? RAW_STREAM_FACTORY_TEXT : RAW_STREAM_FACTORY_BINARY;
3470
+ const encodedStream = value.hint === "text" ? toTextStream(value.stream) : toBinaryStream(value.stream);
3471
+ return {
3472
+ hint: ctx.parse(value.hint),
3473
+ factory: ctx.parse(factory),
3474
+ stream: ctx.parse(encodedStream)
3475
+ };
3476
+ }
3477
+ },
3478
+ serialize(node, ctx, _data) {
3479
+ return "(" + ctx.serialize(node.factory) + ")(" + ctx.serialize(node.stream) + ")";
3480
+ },
3481
+ deserialize(node, ctx, _data) {
3482
+ const stream = ctx.deserialize(node.stream);
3483
+ return ctx.deserialize(node.hint) === "text" ? RAW_STREAM_FACTORY_CONSTRUCTOR_TEXT(stream) : RAW_STREAM_FACTORY_CONSTRUCTOR_BINARY(stream);
3484
+ }
3485
+ });
3486
+ // @__NO_SIDE_EFFECTS__
3487
+ function createRawStreamRPCPlugin(onRawStream) {
3488
+ let nextStreamId = 1;
3489
+ return /* @__PURE__ */ ai({
3490
+ tag: "tss/RawStream",
3491
+ test(value) {
3492
+ return value instanceof RawStream;
3493
+ },
3494
+ parse: {
3495
+ async async(value, ctx, _data) {
3496
+ const streamId = nextStreamId++;
3497
+ onRawStream(streamId, value.stream);
3498
+ return { streamId: await ctx.parse(streamId) };
3499
+ },
3500
+ stream(value, ctx, _data) {
3501
+ const streamId = nextStreamId++;
3502
+ onRawStream(streamId, value.stream);
3503
+ return { streamId: ctx.parse(streamId) };
3504
+ }
3505
+ },
3506
+ serialize() {
3507
+ throw new Error("RawStreamRPCPlugin.serialize should not be called. RPC uses JSON serialization, not JS code generation.");
3508
+ },
3509
+ deserialize() {
3510
+ throw new Error("RawStreamRPCPlugin.deserialize should not be called. Use createRawStreamDeserializePlugin on client.");
3511
+ }
3512
+ });
3513
+ }
3514
+ const ShallowErrorPlugin = /* @__PURE__ */ ai({
3515
+ tag: "$TSR/Error",
3516
+ test(value) {
3517
+ return value instanceof Error;
3518
+ },
3519
+ parse: {
3520
+ sync(value, ctx) {
3521
+ return { message: ctx.parse(value.message) };
3522
+ },
3523
+ async async(value, ctx) {
3524
+ return { message: await ctx.parse(value.message) };
3525
+ },
3526
+ stream(value, ctx) {
3527
+ return { message: ctx.parse(value.message) };
3528
+ }
3529
+ },
3530
+ serialize(node, ctx) {
3531
+ return "new Error(" + ctx.serialize(node.message) + ")";
3532
+ },
3533
+ deserialize(node, ctx) {
3534
+ return new Error(ctx.deserialize(node.message));
3535
+ }
3536
+ });
3537
+ const defaultSerovalPlugins = [
3538
+ ShallowErrorPlugin,
3539
+ RawStreamSSRPlugin,
3540
+ p
3541
+ ];
3542
+ function getScrollRestorationScriptForRouter(_router) {
3543
+ return null;
3544
+ }
3545
+ function dehydrateSsrMatchId(id) {
3546
+ return id.replaceAll("/", "\0");
3547
+ }
3548
+ var tsrScript_default = "self.$_TSR={h(){this.hydrated=!0,this.c()},e(){this.streamEnded=!0,this.c()},c(){this.hydrated&&this.streamEnded&&(delete self.$_TSR,delete self.$R.tsr)},p(e){this.initialized?e():this.buffer.push(e)},buffer:[]}";
3549
+ const SCOPE_ID = "tsr";
3550
+ const TSR_PREFIX = GLOBAL_TSR + ".router=";
3551
+ const P_PREFIX = GLOBAL_TSR + ".p(()=>";
3552
+ const P_SUFFIX = ")";
3553
+ function dehydrateMatch(match) {
3554
+ const dehydratedMatch = {
3555
+ i: dehydrateSsrMatchId(match.id),
3556
+ u: match.updatedAt,
3557
+ s: match.status
3558
+ };
3559
+ for (const [key, shorthand] of [
3560
+ ["__beforeLoadContext", "b"],
3561
+ ["loaderData", "l"],
3562
+ ["error", "e"],
3563
+ ["ssr", "ssr"]
3564
+ ]) if (match[key] !== void 0) dehydratedMatch[shorthand] = match[key];
3565
+ if (match.globalNotFound) dehydratedMatch.g = true;
3566
+ return dehydratedMatch;
3567
+ }
3568
+ const INITIAL_SCRIPTS = [dn(SCOPE_ID), tsrScript_default];
3569
+ var ScriptBuffer = class {
3570
+ constructor(router) {
3571
+ this._scriptBarrierLifted = false;
3572
+ this._cleanedUp = false;
3573
+ this._pendingMicrotask = false;
3574
+ this.router = router;
3575
+ this._queue = INITIAL_SCRIPTS.slice();
3576
+ }
3577
+ enqueue(script) {
3578
+ if (this._cleanedUp) return;
3579
+ this._queue.push(script);
3580
+ if (this._scriptBarrierLifted && !this._pendingMicrotask) {
3581
+ this._pendingMicrotask = true;
3582
+ queueMicrotask(() => {
3583
+ this._pendingMicrotask = false;
3584
+ this.injectBufferedScripts();
3585
+ });
3586
+ }
3587
+ }
3588
+ liftBarrier() {
3589
+ if (this._scriptBarrierLifted || this._cleanedUp) return;
3590
+ this._scriptBarrierLifted = true;
3591
+ if (this._queue.length > 0 && !this._pendingMicrotask) {
3592
+ this._pendingMicrotask = true;
3593
+ queueMicrotask(() => {
3594
+ this._pendingMicrotask = false;
3595
+ this.injectBufferedScripts();
3596
+ });
3597
+ }
3598
+ }
3599
+ /**
3600
+ * Flushes any pending scripts synchronously.
3601
+ * Call this before emitting onSerializationFinished to ensure all scripts are injected.
3602
+ *
3603
+ * IMPORTANT: Only injects if the barrier has been lifted. Before the barrier is lifted,
3604
+ * scripts should remain in the queue so takeBufferedScripts() can retrieve them
3605
+ */
3606
+ flush() {
3607
+ if (!this._scriptBarrierLifted) return;
3608
+ if (this._cleanedUp) return;
3609
+ this._pendingMicrotask = false;
3610
+ const scriptsToInject = this.takeAll();
3611
+ if (scriptsToInject && this.router?.serverSsr) this.router.serverSsr.injectScript(scriptsToInject);
3612
+ }
3613
+ takeAll() {
3614
+ const bufferedScripts = this._queue;
3615
+ this._queue = [];
3616
+ if (bufferedScripts.length === 0) return;
3617
+ if (bufferedScripts.length === 1) return bufferedScripts[0] + ";document.currentScript.remove()";
3618
+ return bufferedScripts.join(";") + ";document.currentScript.remove()";
3619
+ }
3620
+ injectBufferedScripts() {
3621
+ if (this._cleanedUp) return;
3622
+ if (this._queue.length === 0) return;
3623
+ const scriptsToInject = this.takeAll();
3624
+ if (scriptsToInject && this.router?.serverSsr) this.router.serverSsr.injectScript(scriptsToInject);
3625
+ }
3626
+ cleanup() {
3627
+ this._cleanedUp = true;
3628
+ this._queue = [];
3629
+ this.router = void 0;
3630
+ }
3631
+ };
3632
+ const MANIFEST_CACHE_SIZE = 100;
3633
+ const manifestCaches = /* @__PURE__ */ new WeakMap();
3634
+ const inlineCssCaches = /* @__PURE__ */ new WeakMap();
3635
+ function getManifestCache(manifest) {
3636
+ const cache = manifestCaches.get(manifest);
3637
+ if (cache) return cache;
3638
+ const newCache = createLRUCache(MANIFEST_CACHE_SIZE);
3639
+ manifestCaches.set(manifest, newCache);
3640
+ return newCache;
3641
+ }
3642
+ function getInlineCssCache(manifest) {
3643
+ const cache = inlineCssCaches.get(manifest);
3644
+ if (cache) return cache;
3645
+ const newCache = createLRUCache(MANIFEST_CACHE_SIZE);
3646
+ inlineCssCaches.set(manifest, newCache);
3647
+ return newCache;
3648
+ }
3649
+ function getInlineCssHrefsForMatches(manifest, matches) {
3650
+ const styles = manifest?.inlineCss?.styles;
3651
+ if (!styles) return [];
3652
+ const seen = /* @__PURE__ */ new Set();
3653
+ const hrefs = [];
3654
+ for (const match of matches) {
3655
+ const assets = manifest?.routes[match.routeId]?.assets ?? [];
3656
+ for (const asset of assets) {
3657
+ const href = getStylesheetHref(asset);
3658
+ if (!href || seen.has(href) || styles[href] === void 0) continue;
3659
+ seen.add(href);
3660
+ hrefs.push(href);
3661
+ }
3662
+ }
3663
+ return hrefs;
3664
+ }
3665
+ function getInlineCssForHrefs(manifest, hrefs) {
3666
+ const styles = manifest.inlineCss?.styles;
3667
+ if (!styles || hrefs.length === 0) return void 0;
3668
+ const cacheKey = hrefs.join("\0");
3669
+ {
3670
+ const cached = getInlineCssCache(manifest).get(cacheKey);
3671
+ if (cached !== void 0) return cached;
3672
+ }
3673
+ const css = hrefs.map((href) => styles[href]).join("");
3674
+ getInlineCssCache(manifest).set(cacheKey, css);
3675
+ return css;
3676
+ }
3677
+ function getInlineCssAssetForMatches(manifest, matches) {
3678
+ if (!manifest?.inlineCss) return void 0;
3679
+ const css = getInlineCssForHrefs(manifest, getInlineCssHrefsForMatches(manifest, matches));
3680
+ return css === void 0 ? void 0 : createInlineCssStyleAsset(css);
3681
+ }
3682
+ function stripInlinedStylesheetAssets(manifest, routes, matches) {
3683
+ if (!manifest.inlineCss) return routes;
3684
+ const nextRoutes = {};
3685
+ for (const [routeId, route] of Object.entries(routes)) {
3686
+ const assets = route.assets?.filter((asset) => !isInlinableStylesheet(manifest, asset));
3687
+ const nextRoute = { ...route };
3688
+ if (assets) if (assets.length > 0) nextRoute.assets = assets;
3689
+ else delete nextRoute.assets;
3690
+ nextRoutes[routeId] = nextRoute;
3691
+ }
3692
+ if (getInlineCssAssetForMatches(manifest, matches)) {
3693
+ const rootRoute = nextRoutes["__root__"] ?? {};
3694
+ nextRoutes[rootRouteId] = {
3695
+ ...rootRoute,
3696
+ assets: [createInlineCssPlaceholderAsset(), ...rootRoute.assets ?? []]
3697
+ };
3698
+ }
3699
+ return nextRoutes;
3700
+ }
3701
+ function attachRouterServerSsrUtils({ router, manifest, getRequestAssets, includeUnmatchedRouteAssets = true }) {
3702
+ router.ssr = { get manifest() {
3703
+ if (!manifest) return manifest;
3704
+ const requestAssets = getRequestAssets?.();
3705
+ const inlineCssAsset = getInlineCssAssetForMatches(manifest, router.stores.matches.get());
3706
+ if (!requestAssets?.length && !inlineCssAsset) return manifest;
3707
+ return {
3708
+ ...manifest,
3709
+ routes: {
3710
+ ...manifest.routes,
3711
+ [rootRouteId]: {
3712
+ ...manifest.routes[rootRouteId],
3713
+ assets: [
3714
+ ...requestAssets ?? [],
3715
+ ...inlineCssAsset ? [inlineCssAsset] : [],
3716
+ ...manifest.routes["__root__"]?.assets ?? []
3717
+ ]
3718
+ }
3719
+ }
3720
+ };
3721
+ } };
3722
+ let _dehydrated = false;
3723
+ let _serializationFinished = false;
3724
+ const renderFinishedListeners = [];
3725
+ const serializationFinishedListeners = [];
3726
+ const scriptBuffer = new ScriptBuffer(router);
3727
+ let injectedHtmlBuffer = "";
3728
+ router.serverSsr = {
3729
+ injectHtml: (html) => {
3730
+ if (!html) return;
3731
+ injectedHtmlBuffer += html;
3732
+ router.emit({ type: "onInjectedHtml" });
3733
+ },
3734
+ injectScript: (script) => {
3735
+ if (!script) return;
3736
+ const html = `<script${router.options.ssr?.nonce ? ` nonce='${router.options.ssr.nonce}'` : ""}>${script}<\/script>`;
3737
+ router.serverSsr.injectHtml(html);
3738
+ },
3739
+ dehydrate: async (opts) => {
3740
+ if (_dehydrated) {
3741
+ invariant();
3742
+ }
3743
+ let matchesToDehydrate = router.stores.matches.get();
3744
+ if (router.isShell()) matchesToDehydrate = matchesToDehydrate.slice(0, 1);
3745
+ const matches = matchesToDehydrate.map(dehydrateMatch);
3746
+ let manifestToDehydrate = void 0;
3747
+ if (manifest) {
3748
+ const currentRouteIdsList = matchesToDehydrate.map((m) => m.routeId);
3749
+ const manifestCacheKey = `${currentRouteIdsList.join("\0")}\0includeUnmatchedRouteAssets=${includeUnmatchedRouteAssets}`;
3750
+ let filteredRoutes;
3751
+ filteredRoutes = getManifestCache(manifest).get(manifestCacheKey);
3752
+ if (!filteredRoutes) {
3753
+ const currentRouteIds = new Set(currentRouteIdsList);
3754
+ const nextFilteredRoutes = {};
3755
+ for (const routeId in manifest.routes) {
3756
+ const routeManifest = manifest.routes[routeId];
3757
+ if (currentRouteIds.has(routeId)) nextFilteredRoutes[routeId] = routeManifest;
3758
+ else if (includeUnmatchedRouteAssets && routeManifest.assets && routeManifest.assets.length > 0) nextFilteredRoutes[routeId] = { assets: routeManifest.assets };
3759
+ }
3760
+ filteredRoutes = stripInlinedStylesheetAssets(manifest, nextFilteredRoutes, matchesToDehydrate);
3761
+ getManifestCache(manifest).set(manifestCacheKey, filteredRoutes);
3762
+ }
3763
+ manifestToDehydrate = { routes: { ...filteredRoutes } };
3764
+ if (opts?.requestAssets?.length) {
3765
+ const existingRoot = manifestToDehydrate.routes[rootRouteId];
3766
+ manifestToDehydrate.routes[rootRouteId] = {
3767
+ ...existingRoot,
3768
+ assets: [...opts.requestAssets, ...existingRoot?.assets ?? []]
3769
+ };
3770
+ }
3771
+ }
3772
+ const dehydratedRouter = {
3773
+ manifest: manifestToDehydrate,
3774
+ matches
3775
+ };
3776
+ const lastMatchId = matchesToDehydrate[matchesToDehydrate.length - 1]?.id;
3777
+ if (lastMatchId) dehydratedRouter.lastMatchId = dehydrateSsrMatchId(lastMatchId);
3778
+ const dehydratedData = await router.options.dehydrate?.();
3779
+ if (dehydratedData) dehydratedRouter.dehydratedData = dehydratedData;
3780
+ _dehydrated = true;
3781
+ const trackPlugins = { didRun: false };
3782
+ const serializationAdapters = router.options.serializationAdapters;
3783
+ const plugins = serializationAdapters ? serializationAdapters.map((t) => /* @__PURE__ */ makeSsrSerovalPlugin(t, trackPlugins)).concat(defaultSerovalPlugins) : defaultSerovalPlugins;
3784
+ const signalSerializationComplete = () => {
3785
+ _serializationFinished = true;
3786
+ try {
3787
+ serializationFinishedListeners.forEach((l) => l());
3788
+ router.emit({ type: "onSerializationFinished" });
3789
+ } catch (err) {
3790
+ console.error("Serialization listener error:", err);
3791
+ } finally {
3792
+ serializationFinishedListeners.length = 0;
3793
+ renderFinishedListeners.length = 0;
3794
+ }
3795
+ };
3796
+ Sn(dehydratedRouter, {
3797
+ refs: /* @__PURE__ */ new Map(),
3798
+ plugins,
3799
+ onSerialize: (data, initial) => {
3800
+ let serialized = initial ? TSR_PREFIX + data : data;
3801
+ if (trackPlugins.didRun) serialized = P_PREFIX + serialized + P_SUFFIX;
3802
+ scriptBuffer.enqueue(serialized);
3803
+ },
3804
+ onError: (err) => {
3805
+ console.error("Serialization error:", err);
3806
+ if (err && err.stack) console.error(err.stack);
3807
+ signalSerializationComplete();
3808
+ },
3809
+ scopeId: SCOPE_ID,
3810
+ onDone: () => {
3811
+ scriptBuffer.enqueue(GLOBAL_TSR + ".e()");
3812
+ scriptBuffer.flush();
3813
+ signalSerializationComplete();
3814
+ }
3815
+ });
3816
+ },
3817
+ isDehydrated() {
3818
+ return _dehydrated;
3819
+ },
3820
+ isSerializationFinished() {
3821
+ return _serializationFinished;
3822
+ },
3823
+ onRenderFinished: (listener) => renderFinishedListeners.push(listener),
3824
+ onSerializationFinished: (listener) => serializationFinishedListeners.push(listener),
3825
+ setRenderFinished: () => {
3826
+ try {
3827
+ renderFinishedListeners.forEach((l) => l());
3828
+ } catch (err) {
3829
+ console.error("Error in render finished listener:", err);
3830
+ } finally {
3831
+ renderFinishedListeners.length = 0;
3832
+ }
3833
+ scriptBuffer.liftBarrier();
3834
+ },
3835
+ takeBufferedScripts() {
3836
+ const scripts = scriptBuffer.takeAll();
3837
+ return {
3838
+ tag: "script",
3839
+ attrs: {
3840
+ nonce: router.options.ssr?.nonce,
3841
+ className: "$tsr",
3842
+ id: TSR_SCRIPT_BARRIER_ID
3843
+ },
3844
+ children: scripts
3845
+ };
3846
+ },
3847
+ liftScriptBarrier() {
3848
+ scriptBuffer.liftBarrier();
3849
+ },
3850
+ takeBufferedHtml() {
3851
+ if (!injectedHtmlBuffer) return;
3852
+ const buffered = injectedHtmlBuffer;
3853
+ injectedHtmlBuffer = "";
3854
+ return buffered;
3855
+ },
3856
+ cleanup() {
3857
+ if (!router.serverSsr) return;
3858
+ renderFinishedListeners.length = 0;
3859
+ serializationFinishedListeners.length = 0;
3860
+ injectedHtmlBuffer = "";
3861
+ scriptBuffer.cleanup();
3862
+ router.serverSsr = void 0;
3863
+ }
3864
+ };
3865
+ }
3866
+ function getOrigin(request) {
3867
+ try {
3868
+ return new URL(request.url).origin;
3869
+ } catch {
3870
+ }
3871
+ return "http://localhost";
3872
+ }
3873
+ function getNormalizedURL(url, base) {
3874
+ if (typeof url === "string") url = url.replace("\\", "%5C");
3875
+ const rawUrl = new URL(url, base);
3876
+ const { path: decodedPathname, handledProtocolRelativeURL } = decodePath(rawUrl.pathname);
3877
+ const searchParams = new URLSearchParams(rawUrl.search);
3878
+ const normalizedHref = decodedPathname + (searchParams.size > 0 ? "?" : "") + searchParams.toString() + rawUrl.hash;
3879
+ return {
3880
+ url: new URL(normalizedHref, rawUrl.origin),
3881
+ handledProtocolRelativeURL
3882
+ };
3883
+ }
3884
+ function toHeadersInstance(init) {
3885
+ if (init instanceof Headers) return init;
3886
+ else if (Array.isArray(init)) return new Headers(init);
3887
+ else if (typeof init === "object") return new Headers(init);
3888
+ else return null;
3889
+ }
3890
+ function mergeHeaders(...headers) {
3891
+ return headers.reduce((acc, header) => {
3892
+ const headersInstance = toHeadersInstance(header);
3893
+ if (!headersInstance) return acc;
3894
+ for (const [key, value] of headersInstance.entries()) if (key === "set-cookie") splitSetCookieString(value).forEach((cookie) => acc.append("set-cookie", cookie));
3895
+ else acc.set(key, value);
3896
+ return acc;
3897
+ }, new Headers());
3898
+ }
3899
+ function defineHandlerCallback(handler) {
3900
+ return handler;
3901
+ }
3902
+ function transformReadableStreamWithRouter(router, routerStream) {
3903
+ return transformStreamWithRouter(router, routerStream);
3904
+ }
3905
+ function transformPipeableStreamWithRouter(router, routerStream) {
3906
+ return Readable.fromWeb(transformStreamWithRouter(router, Readable.toWeb(routerStream)));
3907
+ }
3908
+ const BODY_END_TAG = "</body>";
3909
+ const HTML_END_TAG = "</html>";
3910
+ const MIN_CLOSING_TAG_LENGTH = 4;
3911
+ const DEFAULT_SERIALIZATION_TIMEOUT_MS = 6e4;
3912
+ const DEFAULT_LIFETIME_TIMEOUT_MS = 6e4;
3913
+ const textEncoder = new TextEncoder();
3914
+ function findLastClosingTagEnd(str) {
3915
+ const len = str.length;
3916
+ if (len < MIN_CLOSING_TAG_LENGTH) return -1;
3917
+ let i = len - 1;
3918
+ while (i >= MIN_CLOSING_TAG_LENGTH - 1) {
3919
+ if (str.charCodeAt(i) === 62) {
3920
+ let j = i - 1;
3921
+ while (j >= 1) {
3922
+ const code = str.charCodeAt(j);
3923
+ if (code >= 97 && code <= 122 || code >= 65 && code <= 90 || code >= 48 && code <= 57 || code === 95 || code === 58 || code === 46 || code === 45) j--;
3924
+ else break;
3925
+ }
3926
+ const tagNameStart = j + 1;
3927
+ if (tagNameStart < i) {
3928
+ const startCode = str.charCodeAt(tagNameStart);
3929
+ if (startCode >= 97 && startCode <= 122 || startCode >= 65 && startCode <= 90) {
3930
+ if (j >= 1 && str.charCodeAt(j) === 47 && str.charCodeAt(j - 1) === 60) return i + 1;
3931
+ }
3932
+ }
3933
+ }
3934
+ i--;
3935
+ }
3936
+ return -1;
3937
+ }
3938
+ function transformStreamWithRouter(router, appStream, opts) {
3939
+ const serializationAlreadyFinished = router.serverSsr?.isSerializationFinished() ?? false;
3940
+ const initialBufferedHtml = router.serverSsr?.takeBufferedHtml();
3941
+ if (serializationAlreadyFinished && !initialBufferedHtml) {
3942
+ let cleanedUp2 = false;
3943
+ let controller2;
3944
+ let isStreamClosed2 = false;
3945
+ let lifetimeTimeoutHandle2;
3946
+ const cleanup2 = () => {
3947
+ if (cleanedUp2) return;
3948
+ cleanedUp2 = true;
3949
+ if (lifetimeTimeoutHandle2 !== void 0) {
3950
+ clearTimeout(lifetimeTimeoutHandle2);
3951
+ lifetimeTimeoutHandle2 = void 0;
3952
+ }
3953
+ router.serverSsr?.cleanup();
3954
+ };
3955
+ const safeClose2 = () => {
3956
+ if (isStreamClosed2) return;
3957
+ isStreamClosed2 = true;
3958
+ try {
3959
+ controller2?.close();
3960
+ } catch {
3961
+ }
3962
+ };
3963
+ const safeError2 = (error) => {
3964
+ if (isStreamClosed2) return;
3965
+ isStreamClosed2 = true;
3966
+ try {
3967
+ controller2?.error(error);
3968
+ } catch {
3969
+ }
3970
+ };
3971
+ const lifetimeMs2 = DEFAULT_LIFETIME_TIMEOUT_MS;
3972
+ lifetimeTimeoutHandle2 = setTimeout(() => {
3973
+ if (!cleanedUp2 && !isStreamClosed2) {
3974
+ console.warn(`SSR stream transform exceeded maximum lifetime (${lifetimeMs2}ms), forcing cleanup`);
3975
+ safeError2(/* @__PURE__ */ new Error("Stream lifetime exceeded"));
3976
+ cleanup2();
3977
+ }
3978
+ }, lifetimeMs2);
3979
+ const stream2 = new ReadableStream$1({
3980
+ start(c) {
3981
+ controller2 = c;
3982
+ },
3983
+ cancel() {
3984
+ isStreamClosed2 = true;
3985
+ cleanup2();
3986
+ }
3987
+ });
3988
+ (async () => {
3989
+ const reader = appStream.getReader();
3990
+ try {
3991
+ while (true) {
3992
+ const { done, value } = await reader.read();
3993
+ if (done) break;
3994
+ if (cleanedUp2 || isStreamClosed2) return;
3995
+ controller2?.enqueue(value);
3996
+ }
3997
+ if (cleanedUp2 || isStreamClosed2) return;
3998
+ router.serverSsr?.setRenderFinished();
3999
+ safeClose2();
4000
+ cleanup2();
4001
+ } catch (error) {
4002
+ if (cleanedUp2) return;
4003
+ console.error("Error reading appStream:", error);
4004
+ router.serverSsr?.setRenderFinished();
4005
+ safeError2(error);
4006
+ cleanup2();
4007
+ } finally {
4008
+ reader.releaseLock();
4009
+ }
4010
+ })().catch((error) => {
4011
+ if (cleanedUp2) return;
4012
+ console.error("Error in stream transform:", error);
4013
+ safeError2(error);
4014
+ cleanup2();
4015
+ });
4016
+ return stream2;
4017
+ }
4018
+ let stopListeningToInjectedHtml;
4019
+ let stopListeningToSerializationFinished;
4020
+ let serializationTimeoutHandle;
4021
+ let lifetimeTimeoutHandle;
4022
+ let cleanedUp = false;
4023
+ let controller;
4024
+ let isStreamClosed = false;
4025
+ const textDecoder = new TextDecoder();
4026
+ let pendingRouterHtml = initialBufferedHtml ?? "";
4027
+ let leftover = "";
4028
+ let pendingClosingTags = "";
4029
+ const MAX_LEFTOVER_CHARS = 2048;
4030
+ let isAppRendering = true;
4031
+ let streamBarrierLifted = false;
4032
+ let serializationFinished = serializationAlreadyFinished;
4033
+ function safeEnqueue(chunk) {
4034
+ if (isStreamClosed) return;
4035
+ if (typeof chunk === "string") controller.enqueue(textEncoder.encode(chunk));
4036
+ else controller.enqueue(chunk);
4037
+ }
4038
+ function safeClose() {
4039
+ if (isStreamClosed) return;
4040
+ isStreamClosed = true;
4041
+ try {
4042
+ controller.close();
4043
+ } catch {
4044
+ }
4045
+ }
4046
+ function safeError(error) {
4047
+ if (isStreamClosed) return;
4048
+ isStreamClosed = true;
4049
+ try {
4050
+ controller.error(error);
4051
+ } catch {
4052
+ }
4053
+ }
4054
+ function cleanup() {
4055
+ if (cleanedUp) return;
4056
+ cleanedUp = true;
4057
+ try {
4058
+ stopListeningToInjectedHtml?.();
4059
+ stopListeningToSerializationFinished?.();
4060
+ } catch {
4061
+ }
4062
+ stopListeningToInjectedHtml = void 0;
4063
+ stopListeningToSerializationFinished = void 0;
4064
+ if (serializationTimeoutHandle !== void 0) {
4065
+ clearTimeout(serializationTimeoutHandle);
4066
+ serializationTimeoutHandle = void 0;
4067
+ }
4068
+ if (lifetimeTimeoutHandle !== void 0) {
4069
+ clearTimeout(lifetimeTimeoutHandle);
4070
+ lifetimeTimeoutHandle = void 0;
4071
+ }
4072
+ pendingRouterHtml = "";
4073
+ leftover = "";
4074
+ pendingClosingTags = "";
4075
+ router.serverSsr?.cleanup();
4076
+ }
4077
+ const stream = new ReadableStream$1({
4078
+ start(c) {
4079
+ controller = c;
4080
+ },
4081
+ cancel() {
4082
+ isStreamClosed = true;
4083
+ cleanup();
4084
+ }
4085
+ });
4086
+ function flushPendingRouterHtml() {
4087
+ if (!pendingRouterHtml) return;
4088
+ safeEnqueue(pendingRouterHtml);
4089
+ pendingRouterHtml = "";
4090
+ }
4091
+ function appendRouterHtml(html) {
4092
+ if (!html) return;
4093
+ pendingRouterHtml += html;
4094
+ }
4095
+ function tryFinish() {
4096
+ if (isAppRendering || !serializationFinished) return;
4097
+ if (cleanedUp || isStreamClosed) return;
4098
+ if (serializationTimeoutHandle !== void 0) {
4099
+ clearTimeout(serializationTimeoutHandle);
4100
+ serializationTimeoutHandle = void 0;
4101
+ }
4102
+ const decoderRemainder = textDecoder.decode();
4103
+ if (leftover) safeEnqueue(leftover);
4104
+ if (decoderRemainder) safeEnqueue(decoderRemainder);
4105
+ flushPendingRouterHtml();
4106
+ if (pendingClosingTags) safeEnqueue(pendingClosingTags);
4107
+ safeClose();
4108
+ cleanup();
4109
+ }
4110
+ const lifetimeMs = DEFAULT_LIFETIME_TIMEOUT_MS;
4111
+ lifetimeTimeoutHandle = setTimeout(() => {
4112
+ if (!cleanedUp && !isStreamClosed) {
4113
+ console.warn(`SSR stream transform exceeded maximum lifetime (${lifetimeMs}ms), forcing cleanup`);
4114
+ safeError(/* @__PURE__ */ new Error("Stream lifetime exceeded"));
4115
+ cleanup();
4116
+ }
4117
+ }, lifetimeMs);
4118
+ if (!serializationAlreadyFinished) {
4119
+ stopListeningToInjectedHtml = router.subscribe("onInjectedHtml", () => {
4120
+ if (cleanedUp || isStreamClosed) return;
4121
+ const html = router.serverSsr?.takeBufferedHtml();
4122
+ if (!html) return;
4123
+ if (isAppRendering || leftover || pendingClosingTags) appendRouterHtml(html);
4124
+ else {
4125
+ flushPendingRouterHtml();
4126
+ safeEnqueue(html);
4127
+ }
4128
+ });
4129
+ stopListeningToSerializationFinished = router.subscribe("onSerializationFinished", () => {
4130
+ serializationFinished = true;
4131
+ tryFinish();
4132
+ });
4133
+ }
4134
+ (async () => {
4135
+ const reader = appStream.getReader();
4136
+ try {
4137
+ while (true) {
4138
+ const { done, value } = await reader.read();
4139
+ if (done) break;
4140
+ if (cleanedUp || isStreamClosed) return;
4141
+ const text = value instanceof Uint8Array ? textDecoder.decode(value, { stream: true }) : String(value);
4142
+ const chunkString = leftover ? leftover + text : text;
4143
+ if (!streamBarrierLifted) {
4144
+ if (chunkString.includes("$tsr-stream-barrier")) {
4145
+ streamBarrierLifted = true;
4146
+ router.serverSsr?.liftScriptBarrier();
4147
+ }
4148
+ }
4149
+ if (pendingClosingTags) {
4150
+ pendingClosingTags += chunkString;
4151
+ leftover = "";
4152
+ continue;
4153
+ }
4154
+ const bodyEndIndex = chunkString.indexOf(BODY_END_TAG);
4155
+ const htmlEndIndex = chunkString.indexOf(HTML_END_TAG);
4156
+ if (bodyEndIndex !== -1 && htmlEndIndex !== -1 && bodyEndIndex < htmlEndIndex) {
4157
+ pendingClosingTags = chunkString.slice(bodyEndIndex);
4158
+ safeEnqueue(chunkString.slice(0, bodyEndIndex));
4159
+ flushPendingRouterHtml();
4160
+ leftover = "";
4161
+ continue;
4162
+ }
4163
+ const lastClosingTagEnd = findLastClosingTagEnd(chunkString);
4164
+ if (lastClosingTagEnd > 0) {
4165
+ safeEnqueue(chunkString.slice(0, lastClosingTagEnd));
4166
+ flushPendingRouterHtml();
4167
+ leftover = chunkString.slice(lastClosingTagEnd);
4168
+ if (leftover.length > MAX_LEFTOVER_CHARS) {
4169
+ safeEnqueue(leftover.slice(0, leftover.length - MAX_LEFTOVER_CHARS));
4170
+ leftover = leftover.slice(-MAX_LEFTOVER_CHARS);
4171
+ }
4172
+ } else {
4173
+ const combined = chunkString;
4174
+ if (combined.length > MAX_LEFTOVER_CHARS) {
4175
+ const flushUpto = combined.length - MAX_LEFTOVER_CHARS;
4176
+ safeEnqueue(combined.slice(0, flushUpto));
4177
+ leftover = combined.slice(flushUpto);
4178
+ } else leftover = combined;
4179
+ }
4180
+ }
4181
+ if (cleanedUp || isStreamClosed) return;
4182
+ isAppRendering = false;
4183
+ router.serverSsr?.setRenderFinished();
4184
+ if (serializationFinished) tryFinish();
4185
+ else {
4186
+ const timeoutMs = opts?.timeoutMs ?? DEFAULT_SERIALIZATION_TIMEOUT_MS;
4187
+ serializationTimeoutHandle = setTimeout(() => {
4188
+ if (!cleanedUp && !isStreamClosed) {
4189
+ console.error("Serialization timeout after app render finished");
4190
+ safeError(/* @__PURE__ */ new Error("Serialization timeout after app render finished"));
4191
+ cleanup();
4192
+ }
4193
+ }, timeoutMs);
4194
+ }
4195
+ } catch (error) {
4196
+ if (cleanedUp) return;
4197
+ console.error("Error reading appStream:", error);
4198
+ isAppRendering = false;
4199
+ router.serverSsr?.setRenderFinished();
4200
+ safeError(error);
4201
+ cleanup();
4202
+ } finally {
4203
+ reader.releaseLock();
4204
+ }
4205
+ })().catch((error) => {
4206
+ if (cleanedUp) return;
4207
+ console.error("Error in stream transform:", error);
4208
+ safeError(error);
4209
+ cleanup();
4210
+ });
4211
+ return stream;
4212
+ }
4213
+ export {
4214
+ isServer as A,
4215
+ BaseRootRoute as B,
4216
+ makeSerovalPlugin as C,
4217
+ mergeHeaders as D,
4218
+ notFound as E,
4219
+ parseRedirect as F,
4220
+ removeTrailingSlash as G,
4221
+ resolveManifestAssetLink as H,
4222
+ rootRouteId as I,
4223
+ transformPipeableStreamWithRouter as J,
4224
+ transformReadableStreamWithRouter as K,
4225
+ RouterCore as R,
4226
+ BaseRoute as a,
4227
+ attachRouterServerSsrUtils as b,
4228
+ createNonReactiveMutableStore as c,
4229
+ createNonReactiveReadonlyStore as d,
4230
+ createRawStreamRPCPlugin as e,
4231
+ createSerializationAdapter as f,
4232
+ deepEqual as g,
4233
+ defaultSerovalPlugins as h,
4234
+ defineHandlerCallback as i,
4235
+ escapeHtml as j,
4236
+ exactPathTest as k,
4237
+ executeRewriteInput as l,
4238
+ functionalUpdate as m,
4239
+ getAssetCrossOrigin as n,
4240
+ getNormalizedURL as o,
4241
+ getOrigin as p,
4242
+ getScrollRestorationScriptForRouter as q,
4243
+ getStylesheetHref as r,
4244
+ hasKeys as s,
4245
+ invariant as t,
4246
+ isDangerousProtocol as u,
4247
+ isInlinableStylesheet as v,
4248
+ isModuleNotFoundError as w,
4249
+ isNotFound as x,
4250
+ isRedirect as y,
4251
+ isResolvedRedirect as z
4252
+ };