convex-cms 0.0.2 → 0.0.5-alpha.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 (311) hide show
  1. package/README.md +109 -13
  2. package/admin-dist/nitro.json +15 -0
  3. package/admin-dist/public/assets/CmsEmptyState-CiMQwSQV.js +5 -0
  4. package/admin-dist/public/assets/CmsPageHeader-ohOq0luT.js +1 -0
  5. package/admin-dist/public/assets/CmsStatusBadge-BdNf0V9v.js +1 -0
  6. package/admin-dist/public/assets/CmsSurface-CWup6Jh7.js +1 -0
  7. package/admin-dist/public/assets/CmsToolbar-cEBlCHa3.js +1 -0
  8. package/admin-dist/public/assets/ContentEntryEditor-BY5ypfUs.js +4 -0
  9. package/admin-dist/public/assets/ErrorState-C4nJ-ml4.js +1 -0
  10. package/admin-dist/public/assets/TaxonomyFilter-BgE_SR_O.js +1 -0
  11. package/admin-dist/public/assets/_contentTypeId-DtZectcC.js +1 -0
  12. package/admin-dist/public/assets/_entryId-BpSmrfAm.js +1 -0
  13. package/admin-dist/public/assets/alert-Bf2l8kxw.js +1 -0
  14. package/admin-dist/public/assets/badge-qPrc4AUM.js +1 -0
  15. package/admin-dist/public/assets/circle-check-big-Dgozy3vV.js +1 -0
  16. package/admin-dist/public/assets/command-QOmNhlb0.js +1 -0
  17. package/admin-dist/public/assets/content-OEBGlxg1.js +1 -0
  18. package/admin-dist/public/assets/content-types-CjQliqVV.js +2 -0
  19. package/admin-dist/public/assets/globals-hAmgC66w.css +1 -0
  20. package/admin-dist/public/assets/index-BH_ECMhv.js +1 -0
  21. package/admin-dist/public/assets/label-DCsUdvFh.js +1 -0
  22. package/admin-dist/public/assets/link-2-Czw1N61H.js +1 -0
  23. package/admin-dist/public/assets/list-DtCsXj8-.js +1 -0
  24. package/admin-dist/public/assets/main-CXgkZMhe.js +97 -0
  25. package/admin-dist/public/assets/media-DTJ3-ViE.js +1 -0
  26. package/admin-dist/public/assets/new._contentTypeId-CoTDxKzf.js +1 -0
  27. package/admin-dist/public/assets/plus-xCFJK0RC.js +1 -0
  28. package/admin-dist/public/assets/rotate-ccw-DIqK63wY.js +1 -0
  29. package/admin-dist/public/assets/scroll-area-B-yrE66a.js +1 -0
  30. package/admin-dist/public/assets/search-CbCbboeU.js +1 -0
  31. package/admin-dist/public/assets/select-Co3TZFJb.js +1 -0
  32. package/admin-dist/public/assets/settings-BspTTv_o.js +1 -0
  33. package/admin-dist/public/assets/switch-CfavASmR.js +1 -0
  34. package/admin-dist/public/assets/tabs-CN5s5u2W.js +1 -0
  35. package/admin-dist/public/assets/tanstack-adapter-npeE3RdY.js +1 -0
  36. package/admin-dist/public/assets/taxonomies-CgG46fIF.js +1 -0
  37. package/admin-dist/public/assets/textarea-BJ0XFZpT.js +1 -0
  38. package/admin-dist/public/assets/trash-B3daldm5.js +1 -0
  39. package/admin-dist/public/assets/triangle-alert-BZRcqsUg.js +1 -0
  40. package/admin-dist/public/assets/useBreadcrumbLabel-DwZlwvFF.js +1 -0
  41. package/admin-dist/public/assets/usePermissions-C1JQhfqb.js +1 -0
  42. package/admin-dist/public/favicon.ico +0 -0
  43. package/admin-dist/server/_chunks/_libs/@date-fns/tz.mjs +217 -0
  44. package/admin-dist/server/_chunks/_libs/@floating-ui/core.mjs +719 -0
  45. package/admin-dist/server/_chunks/_libs/@floating-ui/dom.mjs +622 -0
  46. package/admin-dist/server/_chunks/_libs/@floating-ui/react-dom.mjs +292 -0
  47. package/admin-dist/server/_chunks/_libs/@floating-ui/utils.mjs +320 -0
  48. package/admin-dist/server/_chunks/_libs/@radix-ui/number.mjs +6 -0
  49. package/admin-dist/server/_chunks/_libs/@radix-ui/primitive.mjs +11 -0
  50. package/admin-dist/server/_chunks/_libs/@radix-ui/react-arrow.mjs +23 -0
  51. package/admin-dist/server/_chunks/_libs/@radix-ui/react-avatar.mjs +119 -0
  52. package/admin-dist/server/_chunks/_libs/@radix-ui/react-checkbox.mjs +270 -0
  53. package/admin-dist/server/_chunks/_libs/@radix-ui/react-collection.mjs +69 -0
  54. package/admin-dist/server/_chunks/_libs/@radix-ui/react-compose-refs.mjs +39 -0
  55. package/admin-dist/server/_chunks/_libs/@radix-ui/react-context.mjs +137 -0
  56. package/admin-dist/server/_chunks/_libs/@radix-ui/react-dialog.mjs +325 -0
  57. package/admin-dist/server/_chunks/_libs/@radix-ui/react-direction.mjs +9 -0
  58. package/admin-dist/server/_chunks/_libs/@radix-ui/react-dismissable-layer.mjs +210 -0
  59. package/admin-dist/server/_chunks/_libs/@radix-ui/react-dropdown-menu.mjs +253 -0
  60. package/admin-dist/server/_chunks/_libs/@radix-ui/react-focus-guards.mjs +29 -0
  61. package/admin-dist/server/_chunks/_libs/@radix-ui/react-focus-scope.mjs +206 -0
  62. package/admin-dist/server/_chunks/_libs/@radix-ui/react-id.mjs +14 -0
  63. package/admin-dist/server/_chunks/_libs/@radix-ui/react-label.mjs +23 -0
  64. package/admin-dist/server/_chunks/_libs/@radix-ui/react-menu.mjs +812 -0
  65. package/admin-dist/server/_chunks/_libs/@radix-ui/react-popover.mjs +300 -0
  66. package/admin-dist/server/_chunks/_libs/@radix-ui/react-popper.mjs +286 -0
  67. package/admin-dist/server/_chunks/_libs/@radix-ui/react-portal.mjs +16 -0
  68. package/admin-dist/server/_chunks/_libs/@radix-ui/react-presence.mjs +128 -0
  69. package/admin-dist/server/_chunks/_libs/@radix-ui/react-primitive.mjs +141 -0
  70. package/admin-dist/server/_chunks/_libs/@radix-ui/react-roving-focus.mjs +224 -0
  71. package/admin-dist/server/_chunks/_libs/@radix-ui/react-scroll-area.mjs +721 -0
  72. package/admin-dist/server/_chunks/_libs/@radix-ui/react-select.mjs +1163 -0
  73. package/admin-dist/server/_chunks/_libs/@radix-ui/react-separator.mjs +28 -0
  74. package/admin-dist/server/_chunks/_libs/@radix-ui/react-slot.mjs +601 -0
  75. package/admin-dist/server/_chunks/_libs/@radix-ui/react-switch.mjs +152 -0
  76. package/admin-dist/server/_chunks/_libs/@radix-ui/react-tabs.mjs +189 -0
  77. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-callback-ref.mjs +11 -0
  78. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-controllable-state.mjs +69 -0
  79. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-effect-event.mjs +1 -0
  80. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-escape-keydown.mjs +17 -0
  81. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-is-hydrated.mjs +15 -0
  82. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-layout-effect.mjs +6 -0
  83. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-previous.mjs +14 -0
  84. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-size.mjs +39 -0
  85. package/admin-dist/server/_chunks/_libs/@radix-ui/react-visually-hidden.mjs +33 -0
  86. package/admin-dist/server/_chunks/_libs/@tanstack/history.mjs +409 -0
  87. package/admin-dist/server/_chunks/_libs/@tanstack/react-router.mjs +1718 -0
  88. package/admin-dist/server/_chunks/_libs/@tanstack/react-store.mjs +56 -0
  89. package/admin-dist/server/_chunks/_libs/@tanstack/router-core.mjs +4829 -0
  90. package/admin-dist/server/_chunks/_libs/@tanstack/store.mjs +134 -0
  91. package/admin-dist/server/_chunks/_libs/react-dom.mjs +10781 -0
  92. package/admin-dist/server/_chunks/_libs/react.mjs +513 -0
  93. package/admin-dist/server/_libs/aria-hidden.mjs +122 -0
  94. package/admin-dist/server/_libs/class-variance-authority.mjs +44 -0
  95. package/admin-dist/server/_libs/clsx.mjs +16 -0
  96. package/admin-dist/server/_libs/cmdk.mjs +315 -0
  97. package/admin-dist/server/_libs/convex.mjs +4841 -0
  98. package/admin-dist/server/_libs/cookie-es.mjs +58 -0
  99. package/admin-dist/server/_libs/croner.mjs +1 -0
  100. package/admin-dist/server/_libs/crossws.mjs +1 -0
  101. package/admin-dist/server/_libs/date-fns.mjs +1716 -0
  102. package/admin-dist/server/_libs/detect-node-es.mjs +1 -0
  103. package/admin-dist/server/_libs/get-nonce.mjs +9 -0
  104. package/admin-dist/server/_libs/h3-v2.mjs +277 -0
  105. package/admin-dist/server/_libs/h3.mjs +401 -0
  106. package/admin-dist/server/_libs/hookable.mjs +1 -0
  107. package/admin-dist/server/_libs/isbot.mjs +20 -0
  108. package/admin-dist/server/_libs/lucide-react.mjs +850 -0
  109. package/admin-dist/server/_libs/ohash.mjs +1 -0
  110. package/admin-dist/server/_libs/react-day-picker.mjs +2201 -0
  111. package/admin-dist/server/_libs/react-remove-scroll-bar.mjs +82 -0
  112. package/admin-dist/server/_libs/react-remove-scroll.mjs +328 -0
  113. package/admin-dist/server/_libs/react-style-singleton.mjs +69 -0
  114. package/admin-dist/server/_libs/rou3.mjs +8 -0
  115. package/admin-dist/server/_libs/seroval-plugins.mjs +58 -0
  116. package/admin-dist/server/_libs/seroval.mjs +1765 -0
  117. package/admin-dist/server/_libs/srvx.mjs +719 -0
  118. package/admin-dist/server/_libs/tailwind-merge.mjs +3010 -0
  119. package/admin-dist/server/_libs/tiny-invariant.mjs +12 -0
  120. package/admin-dist/server/_libs/tiny-warning.mjs +5 -0
  121. package/admin-dist/server/_libs/tslib.mjs +39 -0
  122. package/admin-dist/server/_libs/ufo.mjs +54 -0
  123. package/admin-dist/server/_libs/unctx.mjs +1 -0
  124. package/admin-dist/server/_libs/unstorage.mjs +1 -0
  125. package/admin-dist/server/_libs/use-callback-ref.mjs +66 -0
  126. package/admin-dist/server/_libs/use-sidecar.mjs +106 -0
  127. package/admin-dist/server/_libs/use-sync-external-store.mjs +139 -0
  128. package/admin-dist/server/_libs/zod.mjs +4223 -0
  129. package/admin-dist/server/_ssr/CmsButton-B45JAKR1.mjs +125 -0
  130. package/admin-dist/server/_ssr/CmsEmptyState-D_BQFAVR.mjs +290 -0
  131. package/admin-dist/server/_ssr/CmsPageHeader-CrUZA59A.mjs +24 -0
  132. package/admin-dist/server/_ssr/CmsStatusBadge-B-sj6yaj.mjs +127 -0
  133. package/admin-dist/server/_ssr/CmsSurface-DKJZhpjk.mjs +44 -0
  134. package/admin-dist/server/_ssr/CmsToolbar-ByaW5iXf.mjs +49 -0
  135. package/admin-dist/server/_ssr/ContentEntryEditor-D3_Jb1dq.mjs +3720 -0
  136. package/admin-dist/server/_ssr/ErrorState-cI-bKLez.mjs +89 -0
  137. package/admin-dist/server/_ssr/TaxonomyFilter-BRJkuCtA.mjs +188 -0
  138. package/admin-dist/server/_ssr/_contentTypeId-B9kA6CaM.mjs +379 -0
  139. package/admin-dist/server/_ssr/_entryId-BddcMkZN.mjs +161 -0
  140. package/admin-dist/server/_ssr/_tanstack-start-manifest_v-Dd7AmelK.mjs +4 -0
  141. package/admin-dist/server/_ssr/command-CGtVr8Gb.mjs +128 -0
  142. package/admin-dist/server/_ssr/config.server-D7JHDcDv.mjs +117 -0
  143. package/admin-dist/server/_ssr/content-D1tbeOd0.mjs +647 -0
  144. package/admin-dist/server/_ssr/content-types-BZqY_BER.mjs +1342 -0
  145. package/admin-dist/server/_ssr/index-BIdq4xaC.mjs +264 -0
  146. package/admin-dist/server/_ssr/index.mjs +1275 -0
  147. package/admin-dist/server/_ssr/label-T-QNKAr6.mjs +22 -0
  148. package/admin-dist/server/_ssr/media-C-xqjBrl.mjs +1832 -0
  149. package/admin-dist/server/_ssr/new._contentTypeId-DWic9cRq.mjs +144 -0
  150. package/admin-dist/server/_ssr/router-D1BMAMJT.mjs +1556 -0
  151. package/admin-dist/server/_ssr/scroll-area-C0pic_WA.mjs +59 -0
  152. package/admin-dist/server/_ssr/select-CqmuN2F6.mjs +142 -0
  153. package/admin-dist/server/_ssr/settings-CAkncGGV.mjs +430 -0
  154. package/admin-dist/server/_ssr/start-HYkvq4Ni.mjs +4 -0
  155. package/admin-dist/server/_ssr/switch-CgmuJkT9.mjs +31 -0
  156. package/admin-dist/server/_ssr/tabs-CnMj0aRy.mjs +630 -0
  157. package/admin-dist/server/_ssr/tanstack-adapter-BXZrMauE.mjs +119 -0
  158. package/admin-dist/server/_ssr/taxonomies-thl3BfVm.mjs +1015 -0
  159. package/admin-dist/server/_ssr/textarea-4K5OJgeh.mjs +18 -0
  160. package/admin-dist/server/_ssr/trash-B40Gx5zP.mjs +411 -0
  161. package/admin-dist/server/_ssr/useBreadcrumbLabel-rn-fL4zV.mjs +16 -0
  162. package/admin-dist/server/_ssr/usePermissions-CKeM6_Vw.mjs +68 -0
  163. package/admin-dist/server/favicon.ico +0 -0
  164. package/admin-dist/server/index.mjs +641 -0
  165. package/dist/cli/commands/init.d.ts +6 -0
  166. package/dist/cli/commands/init.d.ts.map +1 -0
  167. package/dist/cli/commands/init.js +156 -0
  168. package/dist/cli/commands/init.js.map +1 -0
  169. package/dist/cli/index.js +6 -0
  170. package/dist/cli/index.js.map +1 -1
  171. package/dist/client/admin-config.d.ts +2 -3
  172. package/dist/client/admin-config.d.ts.map +1 -1
  173. package/dist/client/admin-config.js +2 -3
  174. package/dist/client/admin-config.js.map +1 -1
  175. package/dist/client/adminApi.d.ts +1877 -1851
  176. package/dist/client/adminApi.d.ts.map +1 -1
  177. package/dist/client/adminApi.js +649 -629
  178. package/dist/client/adminApi.js.map +1 -1
  179. package/dist/client/agentTools.d.ts +1231 -139
  180. package/dist/client/agentTools.d.ts.map +1 -1
  181. package/dist/client/agentTools.js +37 -13
  182. package/dist/client/agentTools.js.map +1 -1
  183. package/dist/client/index.d.ts +5 -5
  184. package/dist/client/index.d.ts.map +1 -1
  185. package/dist/client/index.js +4 -4
  186. package/dist/client/index.js.map +1 -1
  187. package/dist/client/schema/codegen.d.ts +2 -2
  188. package/dist/client/schema/codegen.d.ts.map +1 -1
  189. package/dist/client/schema/codegen.js +3 -3
  190. package/dist/client/schema/codegen.js.map +1 -1
  191. package/dist/client/schema/defineContentType.d.ts +3 -3
  192. package/dist/client/schema/defineContentType.js +3 -3
  193. package/dist/client/schema/index.d.ts +7 -7
  194. package/dist/client/schema/index.d.ts.map +1 -1
  195. package/dist/client/schema/index.js +5 -5
  196. package/dist/client/schema/index.js.map +1 -1
  197. package/dist/client/schema/schemaDrift.d.ts +1 -1
  198. package/dist/client/schema/schemaDrift.js +1 -1
  199. package/dist/client/schema/typedClient.d.ts +2 -2
  200. package/dist/client/schema/typedClient.js +2 -2
  201. package/dist/client/schema/types.d.ts +1 -1
  202. package/dist/client/schema/types.js +1 -1
  203. package/dist/client/wrapper.d.ts +108 -65
  204. package/dist/client/wrapper.d.ts.map +1 -1
  205. package/dist/client/wrapper.js +22 -22
  206. package/dist/client/wrapper.js.map +1 -1
  207. package/dist/component/_generated/component.d.ts +9 -0
  208. package/dist/component/_generated/component.d.ts.map +1 -1
  209. package/dist/component/convex.config.d.ts +2 -2
  210. package/dist/component/convex.config.js +2 -2
  211. package/dist/component/index.d.ts +1 -1
  212. package/dist/component/index.js +1 -1
  213. package/dist/component/lib/ragContentChunker.d.ts +1 -1
  214. package/dist/component/lib/ragContentChunker.js +1 -1
  215. package/dist/component/mediaAssets.d.ts +35 -0
  216. package/dist/component/mediaAssets.d.ts.map +1 -1
  217. package/dist/component/mediaAssets.js +81 -0
  218. package/dist/component/mediaAssets.js.map +1 -1
  219. package/dist/component/roles.d.ts +1 -1
  220. package/dist/component/roles.js +1 -1
  221. package/dist/react/index.d.ts +2 -2
  222. package/dist/react/index.d.ts.map +1 -1
  223. package/dist/react/index.js +13 -7
  224. package/dist/react/index.js.map +1 -1
  225. package/dist/test.d.ts +2 -2
  226. package/dist/test.d.ts.map +1 -1
  227. package/dist/test.js +4 -3
  228. package/dist/test.js.map +1 -1
  229. package/package.json +37 -13
  230. package/dist/component/auditLog.d.ts +0 -410
  231. package/dist/component/auditLog.d.ts.map +0 -1
  232. package/dist/component/auditLog.js +0 -607
  233. package/dist/component/auditLog.js.map +0 -1
  234. package/dist/component/types.d.ts +0 -4
  235. package/dist/component/types.d.ts.map +0 -1
  236. package/dist/component/types.js +0 -2
  237. package/dist/component/types.js.map +0 -1
  238. package/src/cli/commands/admin.ts +0 -104
  239. package/src/cli/index.ts +0 -21
  240. package/src/cli/utils/detectConvexUrl.ts +0 -54
  241. package/src/cli/utils/openBrowser.ts +0 -16
  242. package/src/client/admin-config.ts +0 -138
  243. package/src/client/adminApi.ts +0 -942
  244. package/src/client/agentTools.ts +0 -1311
  245. package/src/client/argTypes.ts +0 -316
  246. package/src/client/field-types.ts +0 -187
  247. package/src/client/index.ts +0 -1301
  248. package/src/client/queryBuilder.ts +0 -1100
  249. package/src/client/schema/codegen.ts +0 -500
  250. package/src/client/schema/defineContentType.ts +0 -501
  251. package/src/client/schema/index.ts +0 -169
  252. package/src/client/schema/schemaDrift.ts +0 -574
  253. package/src/client/schema/typedClient.ts +0 -688
  254. package/src/client/schema/types.ts +0 -666
  255. package/src/client/types.ts +0 -723
  256. package/src/client/workflows.ts +0 -141
  257. package/src/client/wrapper.ts +0 -4304
  258. package/src/component/_generated/api.ts +0 -140
  259. package/src/component/_generated/component.ts +0 -5029
  260. package/src/component/_generated/dataModel.ts +0 -60
  261. package/src/component/_generated/server.ts +0 -156
  262. package/src/component/authorization.ts +0 -647
  263. package/src/component/authorizationHooks.ts +0 -668
  264. package/src/component/bulkOperations.ts +0 -687
  265. package/src/component/contentEntries.ts +0 -1976
  266. package/src/component/contentEntryMutations.ts +0 -1223
  267. package/src/component/contentEntryValidation.ts +0 -707
  268. package/src/component/contentLock.ts +0 -550
  269. package/src/component/contentTypeMigration.ts +0 -1064
  270. package/src/component/contentTypeMutations.ts +0 -969
  271. package/src/component/contentTypes.ts +0 -346
  272. package/src/component/convex.config.ts +0 -44
  273. package/src/component/documentTypes.ts +0 -240
  274. package/src/component/eventEmitter.ts +0 -485
  275. package/src/component/exportImport.ts +0 -1169
  276. package/src/component/index.ts +0 -491
  277. package/src/component/lib/deepReferenceResolver.ts +0 -999
  278. package/src/component/lib/errors.ts +0 -816
  279. package/src/component/lib/index.ts +0 -145
  280. package/src/component/lib/mediaReferenceResolver.ts +0 -495
  281. package/src/component/lib/metadataExtractor.ts +0 -792
  282. package/src/component/lib/mutationAuth.ts +0 -199
  283. package/src/component/lib/queries.ts +0 -79
  284. package/src/component/lib/ragContentChunker.ts +0 -1371
  285. package/src/component/lib/referenceResolver.ts +0 -430
  286. package/src/component/lib/slugGenerator.ts +0 -262
  287. package/src/component/lib/slugUniqueness.ts +0 -333
  288. package/src/component/lib/softDelete.ts +0 -44
  289. package/src/component/localeFallbackChain.ts +0 -673
  290. package/src/component/localeFields.ts +0 -896
  291. package/src/component/mediaAssetMutations.ts +0 -725
  292. package/src/component/mediaAssets.ts +0 -932
  293. package/src/component/mediaFolderMutations.ts +0 -1046
  294. package/src/component/mediaUploadMutations.ts +0 -224
  295. package/src/component/mediaVariantMutations.ts +0 -900
  296. package/src/component/mediaVariants.ts +0 -793
  297. package/src/component/ragContentIndexer.ts +0 -1067
  298. package/src/component/rateLimitHooks.ts +0 -572
  299. package/src/component/roles.ts +0 -1360
  300. package/src/component/scheduledPublish.ts +0 -358
  301. package/src/component/schema.ts +0 -617
  302. package/src/component/taxonomies.ts +0 -949
  303. package/src/component/taxonomyMutations.ts +0 -1210
  304. package/src/component/trash.ts +0 -724
  305. package/src/component/userContext.ts +0 -898
  306. package/src/component/validation.ts +0 -1388
  307. package/src/component/validators.ts +0 -949
  308. package/src/component/versionMutations.ts +0 -392
  309. package/src/component/webhookTrigger.ts +0 -1922
  310. package/src/react/index.ts +0 -898
  311. package/src/test.ts +0 -1580
@@ -0,0 +1,1718 @@
1
+ import { j as jsxRuntimeExports, r as reactExports, R as React, a as React$1 } from "../react.mjs";
2
+ import { w as warning } from "../../../_libs/tiny-warning.mjs";
3
+ import { r as replaceEqualDeep, t as trimPathRight, g as getLocationChangeInfo, h as handleHashScroll, i as isNotFound, d as defaultGetScrollRestorationKey, a as restoreScroll, e as escapeHtml, s as storageKey, b as rootRouteId, c as createControlledPromise, f as isRedirect, j as transformReadableStreamWithRouter, k as transformPipeableStreamWithRouter, l as isDangerousProtocol, p as preloadWarning, m as functionalUpdate, n as exactPathTest, o as removeTrailingSlash, q as deepEqual, B as BaseRootRoute, u as BaseRoute, v as isModuleNotFoundError, R as RouterCore } from "./router-core.mjs";
4
+ import { i as invariant } from "../../../_libs/tiny-invariant.mjs";
5
+ import { PassThrough } from "node:stream";
6
+ import { R as ReactDOMServer, r as reactDomExports } from "../react-dom.mjs";
7
+ import { i as isbot } from "../../../_libs/isbot.mjs";
8
+ import { u as useStore } from "./react-store.mjs";
9
+ function CatchBoundary(props) {
10
+ const errorComponent = props.errorComponent ?? ErrorComponent;
11
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
12
+ CatchBoundaryImpl,
13
+ {
14
+ getResetKey: props.getResetKey,
15
+ onCatch: props.onCatch,
16
+ children: ({ error, reset }) => {
17
+ if (error) {
18
+ return reactExports.createElement(errorComponent, {
19
+ error,
20
+ reset
21
+ });
22
+ }
23
+ return props.children;
24
+ }
25
+ }
26
+ );
27
+ }
28
+ class CatchBoundaryImpl extends reactExports.Component {
29
+ constructor() {
30
+ super(...arguments);
31
+ this.state = { error: null };
32
+ }
33
+ static getDerivedStateFromProps(props) {
34
+ return { resetKey: props.getResetKey() };
35
+ }
36
+ static getDerivedStateFromError(error) {
37
+ return { error };
38
+ }
39
+ reset() {
40
+ this.setState({ error: null });
41
+ }
42
+ componentDidUpdate(prevProps, prevState) {
43
+ if (prevState.error && prevState.resetKey !== this.state.resetKey) {
44
+ this.reset();
45
+ }
46
+ }
47
+ componentDidCatch(error, errorInfo) {
48
+ if (this.props.onCatch) {
49
+ this.props.onCatch(error, errorInfo);
50
+ }
51
+ }
52
+ render() {
53
+ return this.props.children({
54
+ error: this.state.resetKey !== this.props.getResetKey() ? null : this.state.error,
55
+ reset: () => {
56
+ this.reset();
57
+ }
58
+ });
59
+ }
60
+ }
61
+ function ErrorComponent({ error }) {
62
+ const [show, setShow] = reactExports.useState(false);
63
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { padding: ".5rem", maxWidth: "100%" }, children: [
64
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { display: "flex", alignItems: "center", gap: ".5rem" }, children: [
65
+ /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { style: { fontSize: "1rem" }, children: "Something went wrong!" }),
66
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
67
+ "button",
68
+ {
69
+ style: {
70
+ appearance: "none",
71
+ fontSize: ".6em",
72
+ border: "1px solid currentColor",
73
+ padding: ".1rem .2rem",
74
+ fontWeight: "bold",
75
+ borderRadius: ".25rem"
76
+ },
77
+ onClick: () => setShow((d) => !d),
78
+ children: show ? "Hide Error" : "Show Error"
79
+ }
80
+ )
81
+ ] }),
82
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { height: ".25rem" } }),
83
+ show ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
84
+ "pre",
85
+ {
86
+ style: {
87
+ fontSize: ".7em",
88
+ border: "1px solid red",
89
+ borderRadius: ".25rem",
90
+ padding: ".3rem",
91
+ color: "red",
92
+ overflow: "auto"
93
+ },
94
+ children: error.message ? /* @__PURE__ */ jsxRuntimeExports.jsx("code", { children: error.message }) : null
95
+ }
96
+ ) }) : null
97
+ ] });
98
+ }
99
+ const routerContext = reactExports.createContext(null);
100
+ function getRouterContext() {
101
+ if (typeof document === "undefined") {
102
+ return routerContext;
103
+ }
104
+ if (window.__TSR_ROUTER_CONTEXT__) {
105
+ return window.__TSR_ROUTER_CONTEXT__;
106
+ }
107
+ window.__TSR_ROUTER_CONTEXT__ = routerContext;
108
+ return routerContext;
109
+ }
110
+ function useRouter(opts) {
111
+ const value = reactExports.useContext(getRouterContext());
112
+ warning(
113
+ !((opts?.warn ?? true) && !value)
114
+ );
115
+ return value;
116
+ }
117
+ function useRouterState(opts) {
118
+ const contextRouter = useRouter({
119
+ warn: opts?.router === void 0
120
+ });
121
+ const router = opts?.router || contextRouter;
122
+ const previousResult = reactExports.useRef(void 0);
123
+ return useStore(router.__store, (state) => {
124
+ if (opts?.select) {
125
+ if (opts.structuralSharing ?? router.options.defaultStructuralSharing) {
126
+ const newSlice = replaceEqualDeep(
127
+ previousResult.current,
128
+ opts.select(state)
129
+ );
130
+ previousResult.current = newSlice;
131
+ return newSlice;
132
+ }
133
+ return opts.select(state);
134
+ }
135
+ return state;
136
+ });
137
+ }
138
+ const REACT_USE = "use";
139
+ const reactUse = React[REACT_USE];
140
+ const useLayoutEffect = typeof window !== "undefined" ? reactExports.useLayoutEffect : reactExports.useEffect;
141
+ function usePrevious(value) {
142
+ const ref = reactExports.useRef({
143
+ value,
144
+ prev: null
145
+ });
146
+ const current = ref.current.value;
147
+ if (value !== current) {
148
+ ref.current = {
149
+ value,
150
+ prev: current
151
+ };
152
+ }
153
+ return ref.current.prev;
154
+ }
155
+ function useIntersectionObserver(ref, callback, intersectionObserverOptions2 = {}, options = {}) {
156
+ reactExports.useEffect(() => {
157
+ if (!ref.current || options.disabled || typeof IntersectionObserver !== "function") {
158
+ return;
159
+ }
160
+ const observer = new IntersectionObserver(([entry]) => {
161
+ callback(entry);
162
+ }, intersectionObserverOptions2);
163
+ observer.observe(ref.current);
164
+ return () => {
165
+ observer.disconnect();
166
+ };
167
+ }, [callback, intersectionObserverOptions2, options.disabled, ref]);
168
+ }
169
+ function useForwardedRef(ref) {
170
+ const innerRef = reactExports.useRef(null);
171
+ reactExports.useImperativeHandle(ref, () => innerRef.current, []);
172
+ return innerRef;
173
+ }
174
+ function Transitioner() {
175
+ const router = useRouter();
176
+ const mountLoadForRouter = reactExports.useRef({ router, mounted: false });
177
+ const [isTransitioning, setIsTransitioning] = reactExports.useState(false);
178
+ const { hasPendingMatches, isLoading } = useRouterState({
179
+ select: (s) => ({
180
+ isLoading: s.isLoading,
181
+ hasPendingMatches: s.matches.some((d) => d.status === "pending")
182
+ }),
183
+ structuralSharing: true
184
+ });
185
+ const previousIsLoading = usePrevious(isLoading);
186
+ const isAnyPending = isLoading || isTransitioning || hasPendingMatches;
187
+ const previousIsAnyPending = usePrevious(isAnyPending);
188
+ const isPagePending = isLoading || hasPendingMatches;
189
+ const previousIsPagePending = usePrevious(isPagePending);
190
+ router.startTransition = (fn) => {
191
+ setIsTransitioning(true);
192
+ reactExports.startTransition(() => {
193
+ fn();
194
+ setIsTransitioning(false);
195
+ });
196
+ };
197
+ reactExports.useEffect(() => {
198
+ const unsub = router.history.subscribe(
199
+ ({ navigateOpts }) => {
200
+ if (navigateOpts?.skipTransitionerLoad) {
201
+ return;
202
+ }
203
+ router.load();
204
+ }
205
+ );
206
+ const nextLocation = router.buildLocation({
207
+ to: router.latestLocation.pathname,
208
+ search: true,
209
+ params: true,
210
+ hash: true,
211
+ state: true,
212
+ _includeValidateSearch: true
213
+ });
214
+ if (trimPathRight(router.latestLocation.publicHref) !== trimPathRight(nextLocation.publicHref)) {
215
+ router.commitLocation({ ...nextLocation, replace: true });
216
+ }
217
+ return () => {
218
+ unsub();
219
+ };
220
+ }, [router, router.history]);
221
+ useLayoutEffect(() => {
222
+ if (
223
+ // if we are hydrating from SSR, loading is triggered in ssr-client
224
+ typeof window !== "undefined" && router.ssr || mountLoadForRouter.current.router === router && mountLoadForRouter.current.mounted
225
+ ) {
226
+ return;
227
+ }
228
+ mountLoadForRouter.current = { router, mounted: true };
229
+ const tryLoad = async () => {
230
+ try {
231
+ await router.load();
232
+ } catch (err) {
233
+ console.error(err);
234
+ }
235
+ };
236
+ tryLoad();
237
+ }, [router]);
238
+ useLayoutEffect(() => {
239
+ if (previousIsLoading && !isLoading) {
240
+ router.emit({
241
+ type: "onLoad",
242
+ // When the new URL has committed, when the new matches have been loaded into state.matches
243
+ ...getLocationChangeInfo(router.state)
244
+ });
245
+ }
246
+ }, [previousIsLoading, router, isLoading]);
247
+ useLayoutEffect(() => {
248
+ if (previousIsPagePending && !isPagePending) {
249
+ router.emit({
250
+ type: "onBeforeRouteMount",
251
+ ...getLocationChangeInfo(router.state)
252
+ });
253
+ }
254
+ }, [isPagePending, previousIsPagePending, router]);
255
+ useLayoutEffect(() => {
256
+ if (previousIsAnyPending && !isAnyPending) {
257
+ const changeInfo = getLocationChangeInfo(router.state);
258
+ router.emit({
259
+ type: "onResolved",
260
+ ...changeInfo
261
+ });
262
+ router.__store.setState((s) => ({
263
+ ...s,
264
+ status: "idle",
265
+ resolvedLocation: s.location
266
+ }));
267
+ if (changeInfo.hrefChanged) {
268
+ handleHashScroll(router);
269
+ }
270
+ }
271
+ }, [isAnyPending, previousIsAnyPending, router]);
272
+ return null;
273
+ }
274
+ const matchContext = reactExports.createContext(void 0);
275
+ const dummyMatchContext = reactExports.createContext(
276
+ void 0
277
+ );
278
+ function CatchNotFound(props) {
279
+ const resetKey = useRouterState({
280
+ select: (s) => `not-found-${s.location.pathname}-${s.status}`
281
+ });
282
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
283
+ CatchBoundary,
284
+ {
285
+ getResetKey: () => resetKey,
286
+ onCatch: (error, errorInfo) => {
287
+ if (isNotFound(error)) {
288
+ props.onCatch?.(error, errorInfo);
289
+ } else {
290
+ throw error;
291
+ }
292
+ },
293
+ errorComponent: ({ error }) => {
294
+ if (isNotFound(error)) {
295
+ return props.fallback?.(error);
296
+ } else {
297
+ throw error;
298
+ }
299
+ },
300
+ children: props.children
301
+ }
302
+ );
303
+ }
304
+ function DefaultGlobalNotFound() {
305
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Not Found" });
306
+ }
307
+ function SafeFragment(props) {
308
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: props.children });
309
+ }
310
+ function renderRouteNotFound(router, route, data) {
311
+ if (!route.options.notFoundComponent) {
312
+ if (router.options.defaultNotFoundComponent) {
313
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.defaultNotFoundComponent, { ...data });
314
+ }
315
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultGlobalNotFound, {});
316
+ }
317
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(route.options.notFoundComponent, { ...data });
318
+ }
319
+ function ScriptOnce({ children }) {
320
+ const router = useRouter();
321
+ if (!router.isServer) {
322
+ return null;
323
+ }
324
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
325
+ "script",
326
+ {
327
+ nonce: router.options.ssr?.nonce,
328
+ dangerouslySetInnerHTML: {
329
+ __html: children + ";document.currentScript.remove()"
330
+ }
331
+ }
332
+ );
333
+ }
334
+ function ScrollRestoration() {
335
+ const router = useRouter();
336
+ if (!router.isScrollRestoring || !router.isServer) {
337
+ return null;
338
+ }
339
+ if (typeof router.options.scrollRestoration === "function") {
340
+ const shouldRestore = router.options.scrollRestoration({
341
+ location: router.latestLocation
342
+ });
343
+ if (!shouldRestore) {
344
+ return null;
345
+ }
346
+ }
347
+ const getKey = router.options.getScrollRestorationKey || defaultGetScrollRestorationKey;
348
+ const userKey = getKey(router.latestLocation);
349
+ const resolvedKey = userKey !== defaultGetScrollRestorationKey(router.latestLocation) ? userKey : void 0;
350
+ const restoreScrollOptions = {
351
+ storageKey,
352
+ shouldScrollRestoration: true
353
+ };
354
+ if (resolvedKey) {
355
+ restoreScrollOptions.key = resolvedKey;
356
+ }
357
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
358
+ ScriptOnce,
359
+ {
360
+ children: `(${restoreScroll.toString()})(${escapeHtml(JSON.stringify(restoreScrollOptions))})`
361
+ }
362
+ );
363
+ }
364
+ function ClientOnly({ children, fallback = null }) {
365
+ return useHydrated() ? /* @__PURE__ */ jsxRuntimeExports.jsx(React$1.Fragment, { children }) : /* @__PURE__ */ jsxRuntimeExports.jsx(React$1.Fragment, { children: fallback });
366
+ }
367
+ function useHydrated() {
368
+ return React$1.useSyncExternalStore(
369
+ subscribe,
370
+ () => true,
371
+ () => false
372
+ );
373
+ }
374
+ function subscribe() {
375
+ return () => {
376
+ };
377
+ }
378
+ const Match = reactExports.memo(function MatchImpl({
379
+ matchId
380
+ }) {
381
+ const router = useRouter();
382
+ const matchState = useRouterState({
383
+ select: (s) => {
384
+ const match = s.matches.find((d) => d.id === matchId);
385
+ invariant(
386
+ match
387
+ );
388
+ return {
389
+ routeId: match.routeId,
390
+ ssr: match.ssr,
391
+ _displayPending: match._displayPending
392
+ };
393
+ },
394
+ structuralSharing: true
395
+ });
396
+ const route = router.routesById[matchState.routeId];
397
+ const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
398
+ const pendingElement = PendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(PendingComponent, {}) : null;
399
+ const routeErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
400
+ const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch;
401
+ const routeNotFoundComponent = route.isRoot ? (
402
+ // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
403
+ route.options.notFoundComponent ?? router.options.notFoundRoute?.options.component
404
+ ) : route.options.notFoundComponent;
405
+ const resolvedNoSsr = matchState.ssr === false || matchState.ssr === "data-only";
406
+ const ResolvedSuspenseBoundary = (
407
+ // If we're on the root route, allow forcefully wrapping in suspense
408
+ (!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) && (route.options.wrapInSuspense ?? PendingComponent ?? (route.options.errorComponent?.preload || resolvedNoSsr)) ? reactExports.Suspense : SafeFragment
409
+ );
410
+ const ResolvedCatchBoundary = routeErrorComponent ? CatchBoundary : SafeFragment;
411
+ const ResolvedNotFoundBoundary = routeNotFoundComponent ? CatchNotFound : SafeFragment;
412
+ const resetKey = useRouterState({
413
+ select: (s) => s.loadedAt
414
+ });
415
+ const parentRouteId = useRouterState({
416
+ select: (s) => {
417
+ const index = s.matches.findIndex((d) => d.id === matchId);
418
+ return s.matches[index - 1]?.routeId;
419
+ }
420
+ });
421
+ const ShellComponent = route.isRoot ? route.options.shellComponent ?? SafeFragment : SafeFragment;
422
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(ShellComponent, { children: [
423
+ /* @__PURE__ */ jsxRuntimeExports.jsx(matchContext.Provider, { value: matchId, children: /* @__PURE__ */ jsxRuntimeExports.jsx(ResolvedSuspenseBoundary, { fallback: pendingElement, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
424
+ ResolvedCatchBoundary,
425
+ {
426
+ getResetKey: () => resetKey,
427
+ errorComponent: routeErrorComponent || ErrorComponent,
428
+ onCatch: (error, errorInfo) => {
429
+ if (isNotFound(error)) throw error;
430
+ routeOnCatch?.(error, errorInfo);
431
+ },
432
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
433
+ ResolvedNotFoundBoundary,
434
+ {
435
+ fallback: (error) => {
436
+ if (!routeNotFoundComponent || error.routeId && error.routeId !== matchState.routeId || !error.routeId && !route.isRoot)
437
+ throw error;
438
+ return reactExports.createElement(routeNotFoundComponent, error);
439
+ },
440
+ children: resolvedNoSsr || matchState._displayPending ? /* @__PURE__ */ jsxRuntimeExports.jsx(ClientOnly, { fallback: pendingElement, children: /* @__PURE__ */ jsxRuntimeExports.jsx(MatchInner, { matchId }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(MatchInner, { matchId })
441
+ }
442
+ )
443
+ }
444
+ ) }) }),
445
+ parentRouteId === rootRouteId && router.options.scrollRestoration ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
446
+ /* @__PURE__ */ jsxRuntimeExports.jsx(OnRendered, {}),
447
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollRestoration, {})
448
+ ] }) : null
449
+ ] });
450
+ });
451
+ function OnRendered() {
452
+ const router = useRouter();
453
+ const prevLocationRef = reactExports.useRef(
454
+ void 0
455
+ );
456
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
457
+ "script",
458
+ {
459
+ suppressHydrationWarning: true,
460
+ ref: (el) => {
461
+ if (el && (prevLocationRef.current === void 0 || prevLocationRef.current.href !== router.latestLocation.href)) {
462
+ router.emit({
463
+ type: "onRendered",
464
+ ...getLocationChangeInfo(router.state)
465
+ });
466
+ prevLocationRef.current = router.latestLocation;
467
+ }
468
+ }
469
+ },
470
+ router.latestLocation.state.__TSR_key
471
+ );
472
+ }
473
+ const MatchInner = reactExports.memo(function MatchInnerImpl({
474
+ matchId
475
+ }) {
476
+ const router = useRouter();
477
+ const { match, key, routeId } = useRouterState({
478
+ select: (s) => {
479
+ const match2 = s.matches.find((d) => d.id === matchId);
480
+ const routeId2 = match2.routeId;
481
+ const remountFn = router.routesById[routeId2].options.remountDeps ?? router.options.defaultRemountDeps;
482
+ const remountDeps = remountFn?.({
483
+ routeId: routeId2,
484
+ loaderDeps: match2.loaderDeps,
485
+ params: match2._strictParams,
486
+ search: match2._strictSearch
487
+ });
488
+ const key2 = remountDeps ? JSON.stringify(remountDeps) : void 0;
489
+ return {
490
+ key: key2,
491
+ routeId: routeId2,
492
+ match: {
493
+ id: match2.id,
494
+ status: match2.status,
495
+ error: match2.error,
496
+ invalid: match2.invalid,
497
+ _forcePending: match2._forcePending,
498
+ _displayPending: match2._displayPending
499
+ }
500
+ };
501
+ },
502
+ structuralSharing: true
503
+ });
504
+ const route = router.routesById[routeId];
505
+ const out = reactExports.useMemo(() => {
506
+ const Comp = route.options.component ?? router.options.defaultComponent;
507
+ if (Comp) {
508
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Comp, {}, key);
509
+ }
510
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Outlet, {});
511
+ }, [key, route.options.component, router.options.defaultComponent]);
512
+ if (match._displayPending) {
513
+ throw router.getMatch(match.id)?._nonReactive.displayPendingPromise;
514
+ }
515
+ if (match._forcePending) {
516
+ throw router.getMatch(match.id)?._nonReactive.minPendingPromise;
517
+ }
518
+ if (match.status === "pending") {
519
+ const pendingMinMs = route.options.pendingMinMs ?? router.options.defaultPendingMinMs;
520
+ if (pendingMinMs) {
521
+ const routerMatch = router.getMatch(match.id);
522
+ if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {
523
+ if (!router.isServer) {
524
+ const minPendingPromise = createControlledPromise();
525
+ routerMatch._nonReactive.minPendingPromise = minPendingPromise;
526
+ setTimeout(() => {
527
+ minPendingPromise.resolve();
528
+ routerMatch._nonReactive.minPendingPromise = void 0;
529
+ }, pendingMinMs);
530
+ }
531
+ }
532
+ }
533
+ throw router.getMatch(match.id)?._nonReactive.loadPromise;
534
+ }
535
+ if (match.status === "notFound") {
536
+ invariant(isNotFound(match.error));
537
+ return renderRouteNotFound(router, route, match.error);
538
+ }
539
+ if (match.status === "redirected") {
540
+ invariant(isRedirect(match.error));
541
+ throw router.getMatch(match.id)?._nonReactive.loadPromise;
542
+ }
543
+ if (match.status === "error") {
544
+ if (router.isServer) {
545
+ const RouteErrorComponent = (route.options.errorComponent ?? router.options.defaultErrorComponent) || ErrorComponent;
546
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
547
+ RouteErrorComponent,
548
+ {
549
+ error: match.error,
550
+ reset: void 0,
551
+ info: {
552
+ componentStack: ""
553
+ }
554
+ }
555
+ );
556
+ }
557
+ throw match.error;
558
+ }
559
+ return out;
560
+ });
561
+ const Outlet = reactExports.memo(function OutletImpl() {
562
+ const router = useRouter();
563
+ const matchId = reactExports.useContext(matchContext);
564
+ const routeId = useRouterState({
565
+ select: (s) => s.matches.find((d) => d.id === matchId)?.routeId
566
+ });
567
+ const route = router.routesById[routeId];
568
+ const parentGlobalNotFound = useRouterState({
569
+ select: (s) => {
570
+ const matches = s.matches;
571
+ const parentMatch = matches.find((d) => d.id === matchId);
572
+ invariant(
573
+ parentMatch
574
+ );
575
+ return parentMatch.globalNotFound;
576
+ }
577
+ });
578
+ const childMatchId = useRouterState({
579
+ select: (s) => {
580
+ const matches = s.matches;
581
+ const index = matches.findIndex((d) => d.id === matchId);
582
+ return matches[index + 1]?.id;
583
+ }
584
+ });
585
+ const pendingElement = router.options.defaultPendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.defaultPendingComponent, {}) : null;
586
+ if (parentGlobalNotFound) {
587
+ return renderRouteNotFound(router, route, void 0);
588
+ }
589
+ if (!childMatchId) {
590
+ return null;
591
+ }
592
+ const nextMatch = /* @__PURE__ */ jsxRuntimeExports.jsx(Match, { matchId: childMatchId });
593
+ if (routeId === rootRouteId) {
594
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: pendingElement, children: nextMatch });
595
+ }
596
+ return nextMatch;
597
+ });
598
+ function Matches() {
599
+ const router = useRouter();
600
+ const rootRoute = router.routesById[rootRouteId];
601
+ const PendingComponent = rootRoute.options.pendingComponent ?? router.options.defaultPendingComponent;
602
+ const pendingElement = PendingComponent ? /* @__PURE__ */ jsxRuntimeExports.jsx(PendingComponent, {}) : null;
603
+ const ResolvedSuspense = router.isServer || typeof document !== "undefined" && router.ssr ? SafeFragment : reactExports.Suspense;
604
+ const inner = /* @__PURE__ */ jsxRuntimeExports.jsxs(ResolvedSuspense, { fallback: pendingElement, children: [
605
+ !router.isServer && /* @__PURE__ */ jsxRuntimeExports.jsx(Transitioner, {}),
606
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MatchesInner, {})
607
+ ] });
608
+ return router.options.InnerWrap ? /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.InnerWrap, { children: inner }) : inner;
609
+ }
610
+ function MatchesInner() {
611
+ const router = useRouter();
612
+ const matchId = useRouterState({
613
+ select: (s) => {
614
+ return s.matches[0]?.id;
615
+ }
616
+ });
617
+ const resetKey = useRouterState({
618
+ select: (s) => s.loadedAt
619
+ });
620
+ const matchComponent = matchId ? /* @__PURE__ */ jsxRuntimeExports.jsx(Match, { matchId }) : null;
621
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(matchContext.Provider, { value: matchId, children: router.options.disableGlobalCatchBoundary ? matchComponent : /* @__PURE__ */ jsxRuntimeExports.jsx(
622
+ CatchBoundary,
623
+ {
624
+ getResetKey: () => resetKey,
625
+ errorComponent: ErrorComponent,
626
+ onCatch: (error) => {
627
+ warning(false, error.message || error.toString());
628
+ },
629
+ children: matchComponent
630
+ }
631
+ ) });
632
+ }
633
+ function RouterContextProvider({
634
+ router,
635
+ children,
636
+ ...rest
637
+ }) {
638
+ if (Object.keys(rest).length > 0) {
639
+ router.update({
640
+ ...router.options,
641
+ ...rest,
642
+ context: {
643
+ ...router.options.context,
644
+ ...rest.context
645
+ }
646
+ });
647
+ }
648
+ const routerContext2 = getRouterContext();
649
+ const provider = /* @__PURE__ */ jsxRuntimeExports.jsx(routerContext2.Provider, { value: router, children });
650
+ if (router.options.Wrap) {
651
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(router.options.Wrap, { children: provider });
652
+ }
653
+ return provider;
654
+ }
655
+ function RouterProvider({ router, ...rest }) {
656
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(RouterContextProvider, { router, ...rest, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Matches, {}) });
657
+ }
658
+ const renderRouterToStream = async ({
659
+ request,
660
+ router,
661
+ responseHeaders,
662
+ children
663
+ }) => {
664
+ if (typeof ReactDOMServer.renderToReadableStream === "function") {
665
+ const stream = await ReactDOMServer.renderToReadableStream(children, {
666
+ signal: request.signal,
667
+ nonce: router.options.ssr?.nonce,
668
+ progressiveChunkSize: Number.POSITIVE_INFINITY
669
+ });
670
+ if (isbot(request.headers.get("User-Agent"))) {
671
+ await stream.allReady;
672
+ }
673
+ const responseStream = transformReadableStreamWithRouter(
674
+ router,
675
+ stream
676
+ );
677
+ return new Response(responseStream, {
678
+ status: router.state.statusCode,
679
+ headers: responseHeaders
680
+ });
681
+ }
682
+ if (typeof ReactDOMServer.renderToPipeableStream === "function") {
683
+ const reactAppPassthrough = new PassThrough();
684
+ try {
685
+ const pipeable = ReactDOMServer.renderToPipeableStream(children, {
686
+ nonce: router.options.ssr?.nonce,
687
+ progressiveChunkSize: Number.POSITIVE_INFINITY,
688
+ ...isbot(request.headers.get("User-Agent")) ? {
689
+ onAllReady() {
690
+ pipeable.pipe(reactAppPassthrough);
691
+ }
692
+ } : {
693
+ onShellReady() {
694
+ pipeable.pipe(reactAppPassthrough);
695
+ }
696
+ },
697
+ onError: (error, info) => {
698
+ console.error("Error in renderToPipeableStream:", error, info);
699
+ if (!reactAppPassthrough.destroyed) {
700
+ reactAppPassthrough.destroy(
701
+ error instanceof Error ? error : new Error(String(error))
702
+ );
703
+ }
704
+ }
705
+ });
706
+ } catch (e) {
707
+ console.error("Error in renderToPipeableStream:", e);
708
+ reactAppPassthrough.destroy(e instanceof Error ? e : new Error(String(e)));
709
+ }
710
+ const responseStream = transformPipeableStreamWithRouter(
711
+ router,
712
+ reactAppPassthrough
713
+ );
714
+ return new Response(responseStream, {
715
+ status: router.state.statusCode,
716
+ headers: responseHeaders
717
+ });
718
+ }
719
+ throw new Error(
720
+ "No renderToReadableStream or renderToPipeableStream found in react-dom/server. Ensure you are using a version of react-dom that supports streaming."
721
+ );
722
+ };
723
+ function useMatch(opts) {
724
+ const nearestMatchId = reactExports.useContext(
725
+ opts.from ? dummyMatchContext : matchContext
726
+ );
727
+ const matchSelection = useRouterState({
728
+ select: (state) => {
729
+ const match = state.matches.find(
730
+ (d) => opts.from ? opts.from === d.routeId : d.id === nearestMatchId
731
+ );
732
+ invariant(
733
+ !((opts.shouldThrow ?? true) && !match),
734
+ `Could not find ${opts.from ? `an active match from "${opts.from}"` : "a nearest match!"}`
735
+ );
736
+ if (match === void 0) {
737
+ return void 0;
738
+ }
739
+ return opts.select ? opts.select(match) : match;
740
+ },
741
+ structuralSharing: opts.structuralSharing
742
+ });
743
+ return matchSelection;
744
+ }
745
+ function useLoaderData(opts) {
746
+ return useMatch({
747
+ from: opts.from,
748
+ strict: opts.strict,
749
+ structuralSharing: opts.structuralSharing,
750
+ select: (s) => {
751
+ return opts.select ? opts.select(s.loaderData) : s.loaderData;
752
+ }
753
+ });
754
+ }
755
+ function useLoaderDeps(opts) {
756
+ const { select, ...rest } = opts;
757
+ return useMatch({
758
+ ...rest,
759
+ select: (s) => {
760
+ return select ? select(s.loaderDeps) : s.loaderDeps;
761
+ }
762
+ });
763
+ }
764
+ function useParams(opts) {
765
+ return useMatch({
766
+ from: opts.from,
767
+ shouldThrow: opts.shouldThrow,
768
+ structuralSharing: opts.structuralSharing,
769
+ strict: opts.strict,
770
+ select: (match) => {
771
+ const params = opts.strict === false ? match.params : match._strictParams;
772
+ return opts.select ? opts.select(params) : params;
773
+ }
774
+ });
775
+ }
776
+ function useSearch(opts) {
777
+ return useMatch({
778
+ from: opts.from,
779
+ strict: opts.strict,
780
+ shouldThrow: opts.shouldThrow,
781
+ structuralSharing: opts.structuralSharing,
782
+ select: (match) => {
783
+ return opts.select ? opts.select(match.search) : match.search;
784
+ }
785
+ });
786
+ }
787
+ function useNavigate(_defaultOpts) {
788
+ const router = useRouter();
789
+ return reactExports.useCallback(
790
+ (options) => {
791
+ return router.navigate({
792
+ ...options,
793
+ from: options.from ?? _defaultOpts?.from
794
+ });
795
+ },
796
+ [_defaultOpts?.from, router]
797
+ );
798
+ }
799
+ function useLinkProps(options, forwardedRef) {
800
+ const router = useRouter();
801
+ const [isTransitioning, setIsTransitioning] = reactExports.useState(false);
802
+ const hasRenderFetched = reactExports.useRef(false);
803
+ const innerRef = useForwardedRef(forwardedRef);
804
+ const isHydrated = useHydrated();
805
+ const {
806
+ // custom props
807
+ activeProps,
808
+ inactiveProps,
809
+ activeOptions,
810
+ to,
811
+ preload: userPreload,
812
+ preloadDelay: userPreloadDelay,
813
+ hashScrollIntoView,
814
+ replace,
815
+ startTransition,
816
+ resetScroll,
817
+ viewTransition,
818
+ // element props
819
+ children,
820
+ target,
821
+ disabled,
822
+ style,
823
+ className,
824
+ onClick,
825
+ onFocus,
826
+ onMouseEnter,
827
+ onMouseLeave,
828
+ onTouchStart,
829
+ ignoreBlocker,
830
+ // prevent these from being returned
831
+ params: _params,
832
+ search: _search,
833
+ hash: _hash,
834
+ state: _state,
835
+ mask: _mask,
836
+ reloadDocument: _reloadDocument,
837
+ unsafeRelative: _unsafeRelative,
838
+ from: _from,
839
+ _fromLocation,
840
+ ...propsSafeToSpread
841
+ } = options;
842
+ const currentSearch = useRouterState({
843
+ select: (s) => s.location.search,
844
+ structuralSharing: true
845
+ });
846
+ const from = options.from;
847
+ const _options = reactExports.useMemo(
848
+ () => {
849
+ return { ...options, from };
850
+ },
851
+ // eslint-disable-next-line react-hooks/exhaustive-deps
852
+ [
853
+ router,
854
+ currentSearch,
855
+ from,
856
+ options._fromLocation,
857
+ options.hash,
858
+ options.to,
859
+ options.search,
860
+ options.params,
861
+ options.state,
862
+ options.mask,
863
+ options.unsafeRelative
864
+ ]
865
+ );
866
+ const next = reactExports.useMemo(
867
+ () => router.buildLocation({ ..._options }),
868
+ [router, _options]
869
+ );
870
+ const hrefOption = reactExports.useMemo(() => {
871
+ if (disabled) {
872
+ return void 0;
873
+ }
874
+ let href = next.maskedLocation ? next.maskedLocation.url.href : next.url.href;
875
+ let external = false;
876
+ if (router.origin) {
877
+ if (href.startsWith(router.origin)) {
878
+ href = router.history.createHref(href.replace(router.origin, "")) || "/";
879
+ } else {
880
+ external = true;
881
+ }
882
+ }
883
+ return { href, external };
884
+ }, [disabled, next.maskedLocation, next.url, router.origin, router.history]);
885
+ const externalLink = reactExports.useMemo(() => {
886
+ if (hrefOption?.external) {
887
+ if (isDangerousProtocol(hrefOption.href)) {
888
+ return void 0;
889
+ }
890
+ return hrefOption.href;
891
+ }
892
+ const isSafeInternal = typeof to === "string" && to.charCodeAt(0) === 47 && // '/'
893
+ to.charCodeAt(1) !== 47;
894
+ if (isSafeInternal) return void 0;
895
+ try {
896
+ new URL(to);
897
+ if (isDangerousProtocol(to)) {
898
+ if (false) ;
899
+ return void 0;
900
+ }
901
+ return to;
902
+ } catch {
903
+ }
904
+ return void 0;
905
+ }, [to, hrefOption]);
906
+ const preload = options.reloadDocument || externalLink ? false : userPreload ?? router.options.defaultPreload;
907
+ const preloadDelay = userPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
908
+ const isActive = useRouterState({
909
+ select: (s) => {
910
+ if (externalLink) return false;
911
+ if (activeOptions?.exact) {
912
+ const testExact = exactPathTest(
913
+ s.location.pathname,
914
+ next.pathname,
915
+ router.basepath
916
+ );
917
+ if (!testExact) {
918
+ return false;
919
+ }
920
+ } else {
921
+ const currentPathSplit = removeTrailingSlash(
922
+ s.location.pathname,
923
+ router.basepath
924
+ );
925
+ const nextPathSplit = removeTrailingSlash(
926
+ next.pathname,
927
+ router.basepath
928
+ );
929
+ const pathIsFuzzyEqual = currentPathSplit.startsWith(nextPathSplit) && (currentPathSplit.length === nextPathSplit.length || currentPathSplit[nextPathSplit.length] === "/");
930
+ if (!pathIsFuzzyEqual) {
931
+ return false;
932
+ }
933
+ }
934
+ if (activeOptions?.includeSearch ?? true) {
935
+ const searchTest = deepEqual(s.location.search, next.search, {
936
+ partial: !activeOptions?.exact,
937
+ ignoreUndefined: !activeOptions?.explicitUndefined
938
+ });
939
+ if (!searchTest) {
940
+ return false;
941
+ }
942
+ }
943
+ if (activeOptions?.includeHash) {
944
+ return isHydrated && s.location.hash === next.hash;
945
+ }
946
+ return true;
947
+ }
948
+ });
949
+ const doPreload = reactExports.useCallback(() => {
950
+ router.preloadRoute({ ..._options }).catch((err) => {
951
+ console.warn(err);
952
+ console.warn(preloadWarning);
953
+ });
954
+ }, [router, _options]);
955
+ const preloadViewportIoCallback = reactExports.useCallback(
956
+ (entry) => {
957
+ if (entry?.isIntersecting) {
958
+ doPreload();
959
+ }
960
+ },
961
+ [doPreload]
962
+ );
963
+ useIntersectionObserver(
964
+ innerRef,
965
+ preloadViewportIoCallback,
966
+ intersectionObserverOptions,
967
+ { disabled: !!disabled || !(preload === "viewport") }
968
+ );
969
+ reactExports.useEffect(() => {
970
+ if (hasRenderFetched.current) {
971
+ return;
972
+ }
973
+ if (!disabled && preload === "render") {
974
+ doPreload();
975
+ hasRenderFetched.current = true;
976
+ }
977
+ }, [disabled, doPreload, preload]);
978
+ const handleClick = (e) => {
979
+ const elementTarget = e.currentTarget.getAttribute("target");
980
+ const effectiveTarget = target !== void 0 ? target : elementTarget;
981
+ if (!disabled && !isCtrlEvent(e) && !e.defaultPrevented && (!effectiveTarget || effectiveTarget === "_self") && e.button === 0) {
982
+ e.preventDefault();
983
+ reactDomExports.flushSync(() => {
984
+ setIsTransitioning(true);
985
+ });
986
+ const unsub = router.subscribe("onResolved", () => {
987
+ unsub();
988
+ setIsTransitioning(false);
989
+ });
990
+ router.navigate({
991
+ ..._options,
992
+ replace,
993
+ resetScroll,
994
+ hashScrollIntoView,
995
+ startTransition,
996
+ viewTransition,
997
+ ignoreBlocker
998
+ });
999
+ }
1000
+ };
1001
+ if (externalLink) {
1002
+ return {
1003
+ ...propsSafeToSpread,
1004
+ ref: innerRef,
1005
+ href: externalLink,
1006
+ ...children && { children },
1007
+ ...target && { target },
1008
+ ...disabled && { disabled },
1009
+ ...style && { style },
1010
+ ...className && { className },
1011
+ ...onClick && { onClick },
1012
+ ...onFocus && { onFocus },
1013
+ ...onMouseEnter && { onMouseEnter },
1014
+ ...onMouseLeave && { onMouseLeave },
1015
+ ...onTouchStart && { onTouchStart }
1016
+ };
1017
+ }
1018
+ const handleFocus = (_) => {
1019
+ if (disabled) return;
1020
+ if (preload) {
1021
+ doPreload();
1022
+ }
1023
+ };
1024
+ const handleTouchStart = handleFocus;
1025
+ const handleEnter = (e) => {
1026
+ if (disabled || !preload) return;
1027
+ if (!preloadDelay) {
1028
+ doPreload();
1029
+ } else {
1030
+ const eventTarget = e.target;
1031
+ if (timeoutMap.has(eventTarget)) {
1032
+ return;
1033
+ }
1034
+ const id = setTimeout(() => {
1035
+ timeoutMap.delete(eventTarget);
1036
+ doPreload();
1037
+ }, preloadDelay);
1038
+ timeoutMap.set(eventTarget, id);
1039
+ }
1040
+ };
1041
+ const handleLeave = (e) => {
1042
+ if (disabled || !preload || !preloadDelay) return;
1043
+ const eventTarget = e.target;
1044
+ const id = timeoutMap.get(eventTarget);
1045
+ if (id) {
1046
+ clearTimeout(id);
1047
+ timeoutMap.delete(eventTarget);
1048
+ }
1049
+ };
1050
+ const resolvedActiveProps = isActive ? functionalUpdate(activeProps, {}) ?? STATIC_ACTIVE_OBJECT : STATIC_EMPTY_OBJECT;
1051
+ const resolvedInactiveProps = isActive ? STATIC_EMPTY_OBJECT : functionalUpdate(inactiveProps, {}) ?? STATIC_EMPTY_OBJECT;
1052
+ const resolvedClassName = [
1053
+ className,
1054
+ resolvedActiveProps.className,
1055
+ resolvedInactiveProps.className
1056
+ ].filter(Boolean).join(" ");
1057
+ const resolvedStyle = (style || resolvedActiveProps.style || resolvedInactiveProps.style) && {
1058
+ ...style,
1059
+ ...resolvedActiveProps.style,
1060
+ ...resolvedInactiveProps.style
1061
+ };
1062
+ return {
1063
+ ...propsSafeToSpread,
1064
+ ...resolvedActiveProps,
1065
+ ...resolvedInactiveProps,
1066
+ href: hrefOption?.href,
1067
+ ref: innerRef,
1068
+ onClick: composeHandlers([onClick, handleClick]),
1069
+ onFocus: composeHandlers([onFocus, handleFocus]),
1070
+ onMouseEnter: composeHandlers([onMouseEnter, handleEnter]),
1071
+ onMouseLeave: composeHandlers([onMouseLeave, handleLeave]),
1072
+ onTouchStart: composeHandlers([onTouchStart, handleTouchStart]),
1073
+ disabled: !!disabled,
1074
+ target,
1075
+ ...resolvedStyle && { style: resolvedStyle },
1076
+ ...resolvedClassName && { className: resolvedClassName },
1077
+ ...disabled && STATIC_DISABLED_PROPS,
1078
+ ...isActive && STATIC_ACTIVE_PROPS,
1079
+ ...isTransitioning && STATIC_TRANSITIONING_PROPS
1080
+ };
1081
+ }
1082
+ const STATIC_EMPTY_OBJECT = {};
1083
+ const STATIC_ACTIVE_OBJECT = { className: "active" };
1084
+ const STATIC_DISABLED_PROPS = { role: "link", "aria-disabled": true };
1085
+ const STATIC_ACTIVE_PROPS = { "data-status": "active", "aria-current": "page" };
1086
+ const STATIC_TRANSITIONING_PROPS = { "data-transitioning": "transitioning" };
1087
+ const timeoutMap = /* @__PURE__ */ new WeakMap();
1088
+ const intersectionObserverOptions = {
1089
+ rootMargin: "100px"
1090
+ };
1091
+ const composeHandlers = (handlers) => (e) => {
1092
+ for (const handler of handlers) {
1093
+ if (!handler) continue;
1094
+ if (e.defaultPrevented) return;
1095
+ handler(e);
1096
+ }
1097
+ };
1098
+ const Link = reactExports.forwardRef(
1099
+ (props, ref) => {
1100
+ const { _asChild, ...rest } = props;
1101
+ const { type: _type, ...linkProps } = useLinkProps(rest, ref);
1102
+ const children = typeof rest.children === "function" ? rest.children({
1103
+ isActive: linkProps["data-status"] === "active"
1104
+ }) : rest.children;
1105
+ if (!_asChild) {
1106
+ const { disabled: _, ...rest2 } = linkProps;
1107
+ return reactExports.createElement("a", rest2, children);
1108
+ }
1109
+ return reactExports.createElement(_asChild, linkProps, children);
1110
+ }
1111
+ );
1112
+ function isCtrlEvent(e) {
1113
+ return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
1114
+ }
1115
+ class Route extends BaseRoute {
1116
+ /**
1117
+ * @deprecated Use the `createRoute` function instead.
1118
+ */
1119
+ constructor(options) {
1120
+ super(options);
1121
+ this.useMatch = (opts) => {
1122
+ return useMatch({
1123
+ select: opts?.select,
1124
+ from: this.id,
1125
+ structuralSharing: opts?.structuralSharing
1126
+ });
1127
+ };
1128
+ this.useRouteContext = (opts) => {
1129
+ return useMatch({
1130
+ ...opts,
1131
+ from: this.id,
1132
+ select: (d) => opts?.select ? opts.select(d.context) : d.context
1133
+ });
1134
+ };
1135
+ this.useSearch = (opts) => {
1136
+ return useSearch({
1137
+ select: opts?.select,
1138
+ structuralSharing: opts?.structuralSharing,
1139
+ from: this.id
1140
+ });
1141
+ };
1142
+ this.useParams = (opts) => {
1143
+ return useParams({
1144
+ select: opts?.select,
1145
+ structuralSharing: opts?.structuralSharing,
1146
+ from: this.id
1147
+ });
1148
+ };
1149
+ this.useLoaderDeps = (opts) => {
1150
+ return useLoaderDeps({ ...opts, from: this.id });
1151
+ };
1152
+ this.useLoaderData = (opts) => {
1153
+ return useLoaderData({ ...opts, from: this.id });
1154
+ };
1155
+ this.useNavigate = () => {
1156
+ return useNavigate({ from: this.fullPath });
1157
+ };
1158
+ this.Link = React$1.forwardRef(
1159
+ (props, ref) => {
1160
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { ref, from: this.fullPath, ...props });
1161
+ }
1162
+ );
1163
+ this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
1164
+ }
1165
+ }
1166
+ function createRoute(options) {
1167
+ return new Route(
1168
+ // TODO: Help us TypeChris, you're our only hope!
1169
+ options
1170
+ );
1171
+ }
1172
+ class RootRoute extends BaseRootRoute {
1173
+ /**
1174
+ * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
1175
+ */
1176
+ constructor(options) {
1177
+ super(options);
1178
+ this.useMatch = (opts) => {
1179
+ return useMatch({
1180
+ select: opts?.select,
1181
+ from: this.id,
1182
+ structuralSharing: opts?.structuralSharing
1183
+ });
1184
+ };
1185
+ this.useRouteContext = (opts) => {
1186
+ return useMatch({
1187
+ ...opts,
1188
+ from: this.id,
1189
+ select: (d) => opts?.select ? opts.select(d.context) : d.context
1190
+ });
1191
+ };
1192
+ this.useSearch = (opts) => {
1193
+ return useSearch({
1194
+ select: opts?.select,
1195
+ structuralSharing: opts?.structuralSharing,
1196
+ from: this.id
1197
+ });
1198
+ };
1199
+ this.useParams = (opts) => {
1200
+ return useParams({
1201
+ select: opts?.select,
1202
+ structuralSharing: opts?.structuralSharing,
1203
+ from: this.id
1204
+ });
1205
+ };
1206
+ this.useLoaderDeps = (opts) => {
1207
+ return useLoaderDeps({ ...opts, from: this.id });
1208
+ };
1209
+ this.useLoaderData = (opts) => {
1210
+ return useLoaderData({ ...opts, from: this.id });
1211
+ };
1212
+ this.useNavigate = () => {
1213
+ return useNavigate({ from: this.fullPath });
1214
+ };
1215
+ this.Link = React$1.forwardRef(
1216
+ (props, ref) => {
1217
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Link, { ref, from: this.fullPath, ...props });
1218
+ }
1219
+ );
1220
+ this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
1221
+ }
1222
+ }
1223
+ function createRootRoute(options) {
1224
+ return new RootRoute(options);
1225
+ }
1226
+ function createFileRoute(path) {
1227
+ if (typeof path === "object") {
1228
+ return new FileRoute(path, {
1229
+ silent: true
1230
+ }).createRoute(path);
1231
+ }
1232
+ return new FileRoute(path, {
1233
+ silent: true
1234
+ }).createRoute;
1235
+ }
1236
+ class FileRoute {
1237
+ constructor(path, _opts) {
1238
+ this.path = path;
1239
+ this.createRoute = (options) => {
1240
+ warning(
1241
+ this.silent
1242
+ );
1243
+ const route = createRoute(options);
1244
+ route.isRoot = false;
1245
+ return route;
1246
+ };
1247
+ this.silent = _opts?.silent;
1248
+ }
1249
+ }
1250
+ class LazyRoute {
1251
+ constructor(opts) {
1252
+ this.useMatch = (opts2) => {
1253
+ return useMatch({
1254
+ select: opts2?.select,
1255
+ from: this.options.id,
1256
+ structuralSharing: opts2?.structuralSharing
1257
+ });
1258
+ };
1259
+ this.useRouteContext = (opts2) => {
1260
+ return useMatch({
1261
+ from: this.options.id,
1262
+ select: (d) => opts2?.select ? opts2.select(d.context) : d.context
1263
+ });
1264
+ };
1265
+ this.useSearch = (opts2) => {
1266
+ return useSearch({
1267
+ select: opts2?.select,
1268
+ structuralSharing: opts2?.structuralSharing,
1269
+ from: this.options.id
1270
+ });
1271
+ };
1272
+ this.useParams = (opts2) => {
1273
+ return useParams({
1274
+ select: opts2?.select,
1275
+ structuralSharing: opts2?.structuralSharing,
1276
+ from: this.options.id
1277
+ });
1278
+ };
1279
+ this.useLoaderDeps = (opts2) => {
1280
+ return useLoaderDeps({ ...opts2, from: this.options.id });
1281
+ };
1282
+ this.useLoaderData = (opts2) => {
1283
+ return useLoaderData({ ...opts2, from: this.options.id });
1284
+ };
1285
+ this.useNavigate = () => {
1286
+ const router = useRouter();
1287
+ return useNavigate({ from: router.routesById[this.options.id].fullPath });
1288
+ };
1289
+ this.options = opts;
1290
+ this.$$typeof = /* @__PURE__ */ Symbol.for("react.memo");
1291
+ }
1292
+ }
1293
+ function createLazyFileRoute(id) {
1294
+ if (typeof id === "object") {
1295
+ return new LazyRoute(id);
1296
+ }
1297
+ return (opts) => new LazyRoute({ id, ...opts });
1298
+ }
1299
+ function lazyRouteComponent(importer, exportName) {
1300
+ let loadPromise;
1301
+ let comp;
1302
+ let error;
1303
+ let reload;
1304
+ const load = () => {
1305
+ if (!loadPromise) {
1306
+ loadPromise = importer().then((res) => {
1307
+ loadPromise = void 0;
1308
+ comp = res[exportName];
1309
+ }).catch((err) => {
1310
+ error = err;
1311
+ if (isModuleNotFoundError(error)) {
1312
+ if (error instanceof Error && typeof window !== "undefined" && typeof sessionStorage !== "undefined") {
1313
+ const storageKey2 = `tanstack_router_reload:${error.message}`;
1314
+ if (!sessionStorage.getItem(storageKey2)) {
1315
+ sessionStorage.setItem(storageKey2, "1");
1316
+ reload = true;
1317
+ }
1318
+ }
1319
+ }
1320
+ });
1321
+ }
1322
+ return loadPromise;
1323
+ };
1324
+ const lazyComp = function Lazy(props) {
1325
+ if (reload) {
1326
+ window.location.reload();
1327
+ throw new Promise(() => {
1328
+ });
1329
+ }
1330
+ if (error) {
1331
+ throw error;
1332
+ }
1333
+ if (!comp) {
1334
+ if (reactUse) {
1335
+ reactUse(load());
1336
+ } else {
1337
+ throw load();
1338
+ }
1339
+ }
1340
+ return reactExports.createElement(comp, props);
1341
+ };
1342
+ lazyComp.preload = load;
1343
+ return lazyComp;
1344
+ }
1345
+ const createRouter = (options) => {
1346
+ return new Router(options);
1347
+ };
1348
+ class Router extends RouterCore {
1349
+ constructor(options) {
1350
+ super(options);
1351
+ }
1352
+ }
1353
+ if (typeof globalThis !== "undefined") {
1354
+ globalThis.createFileRoute = createFileRoute;
1355
+ globalThis.createLazyFileRoute = createLazyFileRoute;
1356
+ } else if (typeof window !== "undefined") {
1357
+ window.createFileRoute = createFileRoute;
1358
+ window.createLazyFileRoute = createLazyFileRoute;
1359
+ }
1360
+ function useLocation(opts) {
1361
+ return useRouterState({
1362
+ select: (state) => state.location
1363
+ });
1364
+ }
1365
+ function Asset({
1366
+ tag,
1367
+ attrs,
1368
+ children,
1369
+ nonce
1370
+ }) {
1371
+ switch (tag) {
1372
+ case "title":
1373
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("title", { ...attrs, suppressHydrationWarning: true, children });
1374
+ case "meta":
1375
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("meta", { ...attrs, suppressHydrationWarning: true });
1376
+ case "link":
1377
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("link", { ...attrs, nonce, suppressHydrationWarning: true });
1378
+ case "style":
1379
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
1380
+ "style",
1381
+ {
1382
+ ...attrs,
1383
+ dangerouslySetInnerHTML: { __html: children },
1384
+ nonce
1385
+ }
1386
+ );
1387
+ case "script":
1388
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Script, { attrs, children });
1389
+ default:
1390
+ return null;
1391
+ }
1392
+ }
1393
+ function Script({
1394
+ attrs,
1395
+ children
1396
+ }) {
1397
+ const router = useRouter();
1398
+ reactExports.useEffect(() => {
1399
+ if (attrs?.src) {
1400
+ const normSrc = (() => {
1401
+ try {
1402
+ const base = document.baseURI || window.location.href;
1403
+ return new URL(attrs.src, base).href;
1404
+ } catch {
1405
+ return attrs.src;
1406
+ }
1407
+ })();
1408
+ const existingScript = Array.from(
1409
+ document.querySelectorAll("script[src]")
1410
+ ).find((el) => el.src === normSrc);
1411
+ if (existingScript) {
1412
+ return;
1413
+ }
1414
+ const script = document.createElement("script");
1415
+ for (const [key, value] of Object.entries(attrs)) {
1416
+ if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) {
1417
+ script.setAttribute(
1418
+ key,
1419
+ typeof value === "boolean" ? "" : String(value)
1420
+ );
1421
+ }
1422
+ }
1423
+ document.head.appendChild(script);
1424
+ return () => {
1425
+ if (script.parentNode) {
1426
+ script.parentNode.removeChild(script);
1427
+ }
1428
+ };
1429
+ }
1430
+ if (typeof children === "string") {
1431
+ const typeAttr = typeof attrs?.type === "string" ? attrs.type : "text/javascript";
1432
+ const nonceAttr = typeof attrs?.nonce === "string" ? attrs.nonce : void 0;
1433
+ const existingScript = Array.from(
1434
+ document.querySelectorAll("script:not([src])")
1435
+ ).find((el) => {
1436
+ if (!(el instanceof HTMLScriptElement)) return false;
1437
+ const sType = el.getAttribute("type") ?? "text/javascript";
1438
+ const sNonce = el.getAttribute("nonce") ?? void 0;
1439
+ return el.textContent === children && sType === typeAttr && sNonce === nonceAttr;
1440
+ });
1441
+ if (existingScript) {
1442
+ return;
1443
+ }
1444
+ const script = document.createElement("script");
1445
+ script.textContent = children;
1446
+ if (attrs) {
1447
+ for (const [key, value] of Object.entries(attrs)) {
1448
+ if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) {
1449
+ script.setAttribute(
1450
+ key,
1451
+ typeof value === "boolean" ? "" : String(value)
1452
+ );
1453
+ }
1454
+ }
1455
+ }
1456
+ document.head.appendChild(script);
1457
+ return () => {
1458
+ if (script.parentNode) {
1459
+ script.parentNode.removeChild(script);
1460
+ }
1461
+ };
1462
+ }
1463
+ return void 0;
1464
+ }, [attrs, children]);
1465
+ if (!router.isServer) {
1466
+ const { src, ...rest } = attrs || {};
1467
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
1468
+ "script",
1469
+ {
1470
+ suppressHydrationWarning: true,
1471
+ dangerouslySetInnerHTML: { __html: "" },
1472
+ ...rest
1473
+ }
1474
+ );
1475
+ }
1476
+ if (attrs?.src && typeof attrs.src === "string") {
1477
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("script", { ...attrs, suppressHydrationWarning: true });
1478
+ }
1479
+ if (typeof children === "string") {
1480
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
1481
+ "script",
1482
+ {
1483
+ ...attrs,
1484
+ dangerouslySetInnerHTML: { __html: children },
1485
+ suppressHydrationWarning: true
1486
+ }
1487
+ );
1488
+ }
1489
+ return null;
1490
+ }
1491
+ const useTags = () => {
1492
+ const router = useRouter();
1493
+ const nonce = router.options.ssr?.nonce;
1494
+ const routeMeta = useRouterState({
1495
+ select: (state) => {
1496
+ return state.matches.map((match) => match.meta).filter(Boolean);
1497
+ }
1498
+ });
1499
+ const meta = reactExports.useMemo(() => {
1500
+ const resultMeta = [];
1501
+ const metaByAttribute = {};
1502
+ let title;
1503
+ for (let i = routeMeta.length - 1; i >= 0; i--) {
1504
+ const metas = routeMeta[i];
1505
+ for (let j = metas.length - 1; j >= 0; j--) {
1506
+ const m = metas[j];
1507
+ if (!m) continue;
1508
+ if (m.title) {
1509
+ if (!title) {
1510
+ title = {
1511
+ tag: "title",
1512
+ children: m.title
1513
+ };
1514
+ }
1515
+ } else if ("script:ld+json" in m) {
1516
+ try {
1517
+ const json = JSON.stringify(m["script:ld+json"]);
1518
+ resultMeta.push({
1519
+ tag: "script",
1520
+ attrs: {
1521
+ type: "application/ld+json"
1522
+ },
1523
+ children: escapeHtml(json)
1524
+ });
1525
+ } catch {
1526
+ }
1527
+ } else {
1528
+ const attribute = m.name ?? m.property;
1529
+ if (attribute) {
1530
+ if (metaByAttribute[attribute]) {
1531
+ continue;
1532
+ } else {
1533
+ metaByAttribute[attribute] = true;
1534
+ }
1535
+ }
1536
+ resultMeta.push({
1537
+ tag: "meta",
1538
+ attrs: {
1539
+ ...m,
1540
+ nonce
1541
+ }
1542
+ });
1543
+ }
1544
+ }
1545
+ }
1546
+ if (title) {
1547
+ resultMeta.push(title);
1548
+ }
1549
+ if (nonce) {
1550
+ resultMeta.push({
1551
+ tag: "meta",
1552
+ attrs: {
1553
+ property: "csp-nonce",
1554
+ content: nonce
1555
+ }
1556
+ });
1557
+ }
1558
+ resultMeta.reverse();
1559
+ return resultMeta;
1560
+ }, [routeMeta, nonce]);
1561
+ const links = useRouterState({
1562
+ select: (state) => {
1563
+ const constructed = state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
1564
+ tag: "link",
1565
+ attrs: {
1566
+ ...link,
1567
+ nonce
1568
+ }
1569
+ }));
1570
+ const manifest = router.ssr?.manifest;
1571
+ const assets = state.matches.map((match) => manifest?.routes[match.routeId]?.assets ?? []).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map(
1572
+ (asset) => ({
1573
+ tag: "link",
1574
+ attrs: {
1575
+ ...asset.attrs,
1576
+ suppressHydrationWarning: true,
1577
+ nonce
1578
+ }
1579
+ })
1580
+ );
1581
+ return [...constructed, ...assets];
1582
+ },
1583
+ structuralSharing: true
1584
+ });
1585
+ const preloadLinks = useRouterState({
1586
+ select: (state) => {
1587
+ const preloadLinks2 = [];
1588
+ state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
1589
+ (route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
1590
+ preloadLinks2.push({
1591
+ tag: "link",
1592
+ attrs: {
1593
+ rel: "modulepreload",
1594
+ href: preload,
1595
+ nonce
1596
+ }
1597
+ });
1598
+ })
1599
+ );
1600
+ return preloadLinks2;
1601
+ },
1602
+ structuralSharing: true
1603
+ });
1604
+ const styles = useRouterState({
1605
+ select: (state) => state.matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
1606
+ tag: "style",
1607
+ attrs: {
1608
+ ...attrs,
1609
+ nonce
1610
+ },
1611
+ children
1612
+ })),
1613
+ structuralSharing: true
1614
+ });
1615
+ const headScripts = useRouterState({
1616
+ select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
1617
+ tag: "script",
1618
+ attrs: {
1619
+ ...script,
1620
+ nonce
1621
+ },
1622
+ children
1623
+ })),
1624
+ structuralSharing: true
1625
+ });
1626
+ return uniqBy(
1627
+ [
1628
+ ...meta,
1629
+ ...preloadLinks,
1630
+ ...links,
1631
+ ...styles,
1632
+ ...headScripts
1633
+ ],
1634
+ (d) => {
1635
+ return JSON.stringify(d);
1636
+ }
1637
+ );
1638
+ };
1639
+ function uniqBy(arr, fn) {
1640
+ const seen = /* @__PURE__ */ new Set();
1641
+ return arr.filter((item) => {
1642
+ const key = fn(item);
1643
+ if (seen.has(key)) {
1644
+ return false;
1645
+ }
1646
+ seen.add(key);
1647
+ return true;
1648
+ });
1649
+ }
1650
+ function HeadContent() {
1651
+ const tags = useTags();
1652
+ const router = useRouter();
1653
+ const nonce = router.options.ssr?.nonce;
1654
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: tags.map((tag) => /* @__PURE__ */ reactExports.createElement(Asset, { ...tag, key: `tsr-meta-${JSON.stringify(tag)}`, nonce })) });
1655
+ }
1656
+ const Scripts = () => {
1657
+ const router = useRouter();
1658
+ const nonce = router.options.ssr?.nonce;
1659
+ const assetScripts = useRouterState({
1660
+ select: (state) => {
1661
+ const assetScripts2 = [];
1662
+ const manifest = router.ssr?.manifest;
1663
+ if (!manifest) {
1664
+ return [];
1665
+ }
1666
+ state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
1667
+ (route) => manifest.routes[route.id]?.assets?.filter((d) => d.tag === "script").forEach((asset) => {
1668
+ assetScripts2.push({
1669
+ tag: "script",
1670
+ attrs: { ...asset.attrs, nonce },
1671
+ children: asset.children
1672
+ });
1673
+ })
1674
+ );
1675
+ return assetScripts2;
1676
+ },
1677
+ structuralSharing: true
1678
+ });
1679
+ const { scripts } = useRouterState({
1680
+ select: (state) => ({
1681
+ scripts: state.matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
1682
+ tag: "script",
1683
+ attrs: {
1684
+ ...script,
1685
+ suppressHydrationWarning: true,
1686
+ nonce
1687
+ },
1688
+ children
1689
+ }))
1690
+ }),
1691
+ structuralSharing: true
1692
+ });
1693
+ let serverBufferedScript = void 0;
1694
+ if (router.serverSsr) {
1695
+ serverBufferedScript = router.serverSsr.takeBufferedScripts();
1696
+ }
1697
+ const allScripts = [...scripts, ...assetScripts];
1698
+ if (serverBufferedScript) {
1699
+ allScripts.unshift(serverBufferedScript);
1700
+ }
1701
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: allScripts.map((asset, i) => /* @__PURE__ */ reactExports.createElement(Asset, { ...asset, key: `tsr-scripts-${asset.tag}-${i}` })) });
1702
+ };
1703
+ export {
1704
+ HeadContent as H,
1705
+ Link as L,
1706
+ Outlet as O,
1707
+ RouterProvider as R,
1708
+ Scripts as S,
1709
+ createRootRoute as a,
1710
+ createFileRoute as b,
1711
+ createRouter as c,
1712
+ useNavigate as d,
1713
+ useLocation as e,
1714
+ useParams as f,
1715
+ lazyRouteComponent as l,
1716
+ renderRouterToStream as r,
1717
+ useRouterState as u
1718
+ };