convex-cms 0.0.1 → 0.0.3

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 (267) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +99 -0
  3. package/admin-dist/nitro.json +15 -0
  4. package/admin-dist/public/assets/CmsEmptyState-CRswfTzk.js +5 -0
  5. package/admin-dist/public/assets/CmsPageHeader-CirpXndm.js +1 -0
  6. package/admin-dist/public/assets/CmsStatusBadge-CbEUpQu-.js +1 -0
  7. package/admin-dist/public/assets/CmsToolbar-BI2nZOXp.js +1 -0
  8. package/admin-dist/public/assets/ContentEntryEditor-CBeCyK_m.js +4 -0
  9. package/admin-dist/public/assets/ErrorState-BIVaWmom.js +1 -0
  10. package/admin-dist/public/assets/TaxonomyFilter-ChaY6Y_x.js +1 -0
  11. package/admin-dist/public/assets/_contentTypeId-DQ8k_Rvw.js +1 -0
  12. package/admin-dist/public/assets/_entryId-CKU_glsK.js +1 -0
  13. package/admin-dist/public/assets/alert-BXjTqrwQ.js +1 -0
  14. package/admin-dist/public/assets/badge-hvUOzpVZ.js +1 -0
  15. package/admin-dist/public/assets/circle-check-big-CF_pR17r.js +1 -0
  16. package/admin-dist/public/assets/command-DU82cJlt.js +1 -0
  17. package/admin-dist/public/assets/content-_LXl3pp7.js +1 -0
  18. package/admin-dist/public/assets/content-types-KjxaXGxY.js +2 -0
  19. package/admin-dist/public/assets/globals-CS6BZ0zp.css +1 -0
  20. package/admin-dist/public/assets/index-DNGIZHL-.js +1 -0
  21. package/admin-dist/public/assets/label-KNtpL71g.js +1 -0
  22. package/admin-dist/public/assets/link-2-Bw2aI4V4.js +1 -0
  23. package/admin-dist/public/assets/list-sYepHjt_.js +1 -0
  24. package/admin-dist/public/assets/main-CKj5yfEi.js +97 -0
  25. package/admin-dist/public/assets/media-Bkrkffm7.js +1 -0
  26. package/admin-dist/public/assets/new._contentTypeId-C3LstjNs.js +1 -0
  27. package/admin-dist/public/assets/plus-DUn8v_Xf.js +1 -0
  28. package/admin-dist/public/assets/rotate-ccw-DJEoHcRI.js +1 -0
  29. package/admin-dist/public/assets/scroll-area-DfIlT0in.js +1 -0
  30. package/admin-dist/public/assets/search-MuAUDJKR.js +1 -0
  31. package/admin-dist/public/assets/select-BD29IXCI.js +1 -0
  32. package/admin-dist/public/assets/settings-DmMyn_6A.js +1 -0
  33. package/admin-dist/public/assets/switch-h3Rrnl5i.js +1 -0
  34. package/admin-dist/public/assets/tabs-imc8h-Dp.js +1 -0
  35. package/admin-dist/public/assets/taxonomies-dAsrT65H.js +1 -0
  36. package/admin-dist/public/assets/textarea-BTy7nwzR.js +1 -0
  37. package/admin-dist/public/assets/trash-SAWKZZHv.js +1 -0
  38. package/admin-dist/public/assets/triangle-alert-E52Vfeuh.js +1 -0
  39. package/admin-dist/public/assets/useBreadcrumbLabel-BECBMCzM.js +1 -0
  40. package/admin-dist/public/assets/usePermissions-Basjs9BT.js +1 -0
  41. package/admin-dist/public/favicon.ico +0 -0
  42. package/admin-dist/server/_chunks/_libs/@date-fns/tz.mjs +217 -0
  43. package/admin-dist/server/_chunks/_libs/@floating-ui/core.mjs +719 -0
  44. package/admin-dist/server/_chunks/_libs/@floating-ui/dom.mjs +622 -0
  45. package/admin-dist/server/_chunks/_libs/@floating-ui/react-dom.mjs +292 -0
  46. package/admin-dist/server/_chunks/_libs/@floating-ui/utils.mjs +320 -0
  47. package/admin-dist/server/_chunks/_libs/@radix-ui/number.mjs +6 -0
  48. package/admin-dist/server/_chunks/_libs/@radix-ui/primitive.mjs +11 -0
  49. package/admin-dist/server/_chunks/_libs/@radix-ui/react-arrow.mjs +23 -0
  50. package/admin-dist/server/_chunks/_libs/@radix-ui/react-avatar.mjs +119 -0
  51. package/admin-dist/server/_chunks/_libs/@radix-ui/react-checkbox.mjs +270 -0
  52. package/admin-dist/server/_chunks/_libs/@radix-ui/react-collection.mjs +69 -0
  53. package/admin-dist/server/_chunks/_libs/@radix-ui/react-compose-refs.mjs +39 -0
  54. package/admin-dist/server/_chunks/_libs/@radix-ui/react-context.mjs +137 -0
  55. package/admin-dist/server/_chunks/_libs/@radix-ui/react-dialog.mjs +325 -0
  56. package/admin-dist/server/_chunks/_libs/@radix-ui/react-direction.mjs +9 -0
  57. package/admin-dist/server/_chunks/_libs/@radix-ui/react-dismissable-layer.mjs +210 -0
  58. package/admin-dist/server/_chunks/_libs/@radix-ui/react-dropdown-menu.mjs +253 -0
  59. package/admin-dist/server/_chunks/_libs/@radix-ui/react-focus-guards.mjs +29 -0
  60. package/admin-dist/server/_chunks/_libs/@radix-ui/react-focus-scope.mjs +206 -0
  61. package/admin-dist/server/_chunks/_libs/@radix-ui/react-id.mjs +14 -0
  62. package/admin-dist/server/_chunks/_libs/@radix-ui/react-label.mjs +23 -0
  63. package/admin-dist/server/_chunks/_libs/@radix-ui/react-menu.mjs +812 -0
  64. package/admin-dist/server/_chunks/_libs/@radix-ui/react-popover.mjs +300 -0
  65. package/admin-dist/server/_chunks/_libs/@radix-ui/react-popper.mjs +286 -0
  66. package/admin-dist/server/_chunks/_libs/@radix-ui/react-portal.mjs +16 -0
  67. package/admin-dist/server/_chunks/_libs/@radix-ui/react-presence.mjs +128 -0
  68. package/admin-dist/server/_chunks/_libs/@radix-ui/react-primitive.mjs +141 -0
  69. package/admin-dist/server/_chunks/_libs/@radix-ui/react-roving-focus.mjs +224 -0
  70. package/admin-dist/server/_chunks/_libs/@radix-ui/react-scroll-area.mjs +721 -0
  71. package/admin-dist/server/_chunks/_libs/@radix-ui/react-select.mjs +1163 -0
  72. package/admin-dist/server/_chunks/_libs/@radix-ui/react-separator.mjs +28 -0
  73. package/admin-dist/server/_chunks/_libs/@radix-ui/react-slot.mjs +601 -0
  74. package/admin-dist/server/_chunks/_libs/@radix-ui/react-switch.mjs +152 -0
  75. package/admin-dist/server/_chunks/_libs/@radix-ui/react-tabs.mjs +189 -0
  76. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-callback-ref.mjs +11 -0
  77. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-controllable-state.mjs +69 -0
  78. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-effect-event.mjs +1 -0
  79. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-escape-keydown.mjs +17 -0
  80. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-is-hydrated.mjs +15 -0
  81. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-layout-effect.mjs +6 -0
  82. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-previous.mjs +14 -0
  83. package/admin-dist/server/_chunks/_libs/@radix-ui/react-use-size.mjs +39 -0
  84. package/admin-dist/server/_chunks/_libs/@radix-ui/react-visually-hidden.mjs +33 -0
  85. package/admin-dist/server/_chunks/_libs/@tanstack/history.mjs +409 -0
  86. package/admin-dist/server/_chunks/_libs/@tanstack/react-router.mjs +1711 -0
  87. package/admin-dist/server/_chunks/_libs/@tanstack/react-store.mjs +56 -0
  88. package/admin-dist/server/_chunks/_libs/@tanstack/router-core.mjs +4829 -0
  89. package/admin-dist/server/_chunks/_libs/@tanstack/store.mjs +134 -0
  90. package/admin-dist/server/_chunks/_libs/react-dom.mjs +10781 -0
  91. package/admin-dist/server/_chunks/_libs/react.mjs +513 -0
  92. package/admin-dist/server/_libs/aria-hidden.mjs +122 -0
  93. package/admin-dist/server/_libs/class-variance-authority.mjs +44 -0
  94. package/admin-dist/server/_libs/clsx.mjs +16 -0
  95. package/admin-dist/server/_libs/cmdk.mjs +315 -0
  96. package/admin-dist/server/_libs/convex.mjs +4841 -0
  97. package/admin-dist/server/_libs/cookie-es.mjs +58 -0
  98. package/admin-dist/server/_libs/croner.mjs +1 -0
  99. package/admin-dist/server/_libs/crossws.mjs +1 -0
  100. package/admin-dist/server/_libs/date-fns.mjs +1716 -0
  101. package/admin-dist/server/_libs/detect-node-es.mjs +1 -0
  102. package/admin-dist/server/_libs/get-nonce.mjs +9 -0
  103. package/admin-dist/server/_libs/h3-v2.mjs +277 -0
  104. package/admin-dist/server/_libs/h3.mjs +401 -0
  105. package/admin-dist/server/_libs/hookable.mjs +1 -0
  106. package/admin-dist/server/_libs/isbot.mjs +20 -0
  107. package/admin-dist/server/_libs/lucide-react.mjs +850 -0
  108. package/admin-dist/server/_libs/ohash.mjs +1 -0
  109. package/admin-dist/server/_libs/react-day-picker.mjs +2201 -0
  110. package/admin-dist/server/_libs/react-remove-scroll-bar.mjs +82 -0
  111. package/admin-dist/server/_libs/react-remove-scroll.mjs +328 -0
  112. package/admin-dist/server/_libs/react-style-singleton.mjs +69 -0
  113. package/admin-dist/server/_libs/rou3.mjs +8 -0
  114. package/admin-dist/server/_libs/seroval-plugins.mjs +58 -0
  115. package/admin-dist/server/_libs/seroval.mjs +1765 -0
  116. package/admin-dist/server/_libs/srvx.mjs +719 -0
  117. package/admin-dist/server/_libs/tailwind-merge.mjs +3010 -0
  118. package/admin-dist/server/_libs/tiny-invariant.mjs +12 -0
  119. package/admin-dist/server/_libs/tiny-warning.mjs +5 -0
  120. package/admin-dist/server/_libs/tslib.mjs +39 -0
  121. package/admin-dist/server/_libs/ufo.mjs +54 -0
  122. package/admin-dist/server/_libs/unctx.mjs +1 -0
  123. package/admin-dist/server/_libs/unstorage.mjs +1 -0
  124. package/admin-dist/server/_libs/use-callback-ref.mjs +66 -0
  125. package/admin-dist/server/_libs/use-sidecar.mjs +106 -0
  126. package/admin-dist/server/_libs/use-sync-external-store.mjs +139 -0
  127. package/admin-dist/server/_libs/zod.mjs +4223 -0
  128. package/admin-dist/server/_ssr/CmsEmptyState-DU7-7-mV.mjs +290 -0
  129. package/admin-dist/server/_ssr/CmsPageHeader-CseW0AHm.mjs +24 -0
  130. package/admin-dist/server/_ssr/CmsStatusBadge-B_pi4KCp.mjs +127 -0
  131. package/admin-dist/server/_ssr/CmsToolbar-X75ex6ek.mjs +49 -0
  132. package/admin-dist/server/_ssr/ContentEntryEditor-CepusRsA.mjs +3720 -0
  133. package/admin-dist/server/_ssr/ErrorState-cI-bKLez.mjs +89 -0
  134. package/admin-dist/server/_ssr/TaxonomyFilter-Bwrq0-cz.mjs +188 -0
  135. package/admin-dist/server/_ssr/_contentTypeId-BqYKEcLr.mjs +379 -0
  136. package/admin-dist/server/_ssr/_entryId-CRfnqeDf.mjs +161 -0
  137. package/admin-dist/server/_ssr/_tanstack-start-manifest_v-BwDlABVk.mjs +4 -0
  138. package/admin-dist/server/_ssr/alert-CVt45UUP.mjs +92 -0
  139. package/admin-dist/server/_ssr/badge-6BsP37vG.mjs +125 -0
  140. package/admin-dist/server/_ssr/command-fy8epIKf.mjs +128 -0
  141. package/admin-dist/server/_ssr/config.server-D7JHDcDv.mjs +117 -0
  142. package/admin-dist/server/_ssr/content-B5RhL7uW.mjs +532 -0
  143. package/admin-dist/server/_ssr/content-types-BIOqCQYN.mjs +1166 -0
  144. package/admin-dist/server/_ssr/index-DHSHDPt1.mjs +193 -0
  145. package/admin-dist/server/_ssr/index.mjs +1275 -0
  146. package/admin-dist/server/_ssr/label-C8Dko1j7.mjs +22 -0
  147. package/admin-dist/server/_ssr/media-CSx3XttC.mjs +1832 -0
  148. package/admin-dist/server/_ssr/new._contentTypeId-DzanEZQM.mjs +144 -0
  149. package/admin-dist/server/_ssr/router-DDWcF-kt.mjs +1556 -0
  150. package/admin-dist/server/_ssr/scroll-area-bjPYwhXN.mjs +59 -0
  151. package/admin-dist/server/_ssr/select-BUhDDf4T.mjs +142 -0
  152. package/admin-dist/server/_ssr/settings-DAsxnw2q.mjs +348 -0
  153. package/admin-dist/server/_ssr/start-HYkvq4Ni.mjs +4 -0
  154. package/admin-dist/server/_ssr/switch-BgyRtQ1Z.mjs +31 -0
  155. package/admin-dist/server/_ssr/tabs-DzMdRB1A.mjs +628 -0
  156. package/admin-dist/server/_ssr/taxonomies-C8j8g5Q5.mjs +915 -0
  157. package/admin-dist/server/_ssr/textarea-9jNeYJSc.mjs +18 -0
  158. package/admin-dist/server/_ssr/trash-DYMxwhZB.mjs +291 -0
  159. package/admin-dist/server/_ssr/useBreadcrumbLabel-FNSAr2Ha.mjs +16 -0
  160. package/admin-dist/server/_ssr/usePermissions-BJGGahrJ.mjs +68 -0
  161. package/admin-dist/server/favicon.ico +0 -0
  162. package/admin-dist/server/index.mjs +627 -0
  163. package/dist/cli/index.js +0 -0
  164. package/dist/client/admin-config.d.ts +0 -1
  165. package/dist/client/admin-config.d.ts.map +1 -1
  166. package/dist/client/admin-config.js +0 -1
  167. package/dist/client/admin-config.js.map +1 -1
  168. package/dist/client/adminApi.d.ts.map +1 -1
  169. package/dist/client/agentTools.d.ts +1237 -135
  170. package/dist/client/agentTools.d.ts.map +1 -1
  171. package/dist/client/agentTools.js +33 -9
  172. package/dist/client/agentTools.js.map +1 -1
  173. package/dist/client/index.d.ts +1 -1
  174. package/dist/client/index.d.ts.map +1 -1
  175. package/dist/client/index.js.map +1 -1
  176. package/dist/component/_generated/component.d.ts +9 -0
  177. package/dist/component/_generated/component.d.ts.map +1 -1
  178. package/dist/component/mediaAssets.d.ts +35 -0
  179. package/dist/component/mediaAssets.d.ts.map +1 -1
  180. package/dist/component/mediaAssets.js +81 -0
  181. package/dist/component/mediaAssets.js.map +1 -1
  182. package/dist/test.d.ts.map +1 -1
  183. package/dist/test.js +2 -1
  184. package/dist/test.js.map +1 -1
  185. package/package.json +24 -9
  186. package/dist/component/auditLog.d.ts +0 -410
  187. package/dist/component/auditLog.d.ts.map +0 -1
  188. package/dist/component/auditLog.js +0 -607
  189. package/dist/component/auditLog.js.map +0 -1
  190. package/dist/component/types.d.ts +0 -4
  191. package/dist/component/types.d.ts.map +0 -1
  192. package/dist/component/types.js +0 -2
  193. package/dist/component/types.js.map +0 -1
  194. package/src/cli/commands/admin.ts +0 -104
  195. package/src/cli/index.ts +0 -21
  196. package/src/cli/utils/detectConvexUrl.ts +0 -54
  197. package/src/cli/utils/openBrowser.ts +0 -16
  198. package/src/client/admin-config.ts +0 -138
  199. package/src/client/adminApi.ts +0 -942
  200. package/src/client/agentTools.ts +0 -1311
  201. package/src/client/argTypes.ts +0 -316
  202. package/src/client/field-types.ts +0 -187
  203. package/src/client/index.ts +0 -1301
  204. package/src/client/queryBuilder.ts +0 -1100
  205. package/src/client/schema/codegen.ts +0 -500
  206. package/src/client/schema/defineContentType.ts +0 -501
  207. package/src/client/schema/index.ts +0 -169
  208. package/src/client/schema/schemaDrift.ts +0 -574
  209. package/src/client/schema/typedClient.ts +0 -688
  210. package/src/client/schema/types.ts +0 -666
  211. package/src/client/types.ts +0 -723
  212. package/src/client/workflows.ts +0 -141
  213. package/src/client/wrapper.ts +0 -4304
  214. package/src/component/_generated/api.ts +0 -140
  215. package/src/component/_generated/component.ts +0 -5029
  216. package/src/component/_generated/dataModel.ts +0 -60
  217. package/src/component/_generated/server.ts +0 -156
  218. package/src/component/authorization.ts +0 -647
  219. package/src/component/authorizationHooks.ts +0 -668
  220. package/src/component/bulkOperations.ts +0 -687
  221. package/src/component/contentEntries.ts +0 -1976
  222. package/src/component/contentEntryMutations.ts +0 -1223
  223. package/src/component/contentEntryValidation.ts +0 -707
  224. package/src/component/contentLock.ts +0 -550
  225. package/src/component/contentTypeMigration.ts +0 -1064
  226. package/src/component/contentTypeMutations.ts +0 -969
  227. package/src/component/contentTypes.ts +0 -346
  228. package/src/component/convex.config.ts +0 -44
  229. package/src/component/documentTypes.ts +0 -240
  230. package/src/component/eventEmitter.ts +0 -485
  231. package/src/component/exportImport.ts +0 -1169
  232. package/src/component/index.ts +0 -491
  233. package/src/component/lib/deepReferenceResolver.ts +0 -999
  234. package/src/component/lib/errors.ts +0 -816
  235. package/src/component/lib/index.ts +0 -145
  236. package/src/component/lib/mediaReferenceResolver.ts +0 -495
  237. package/src/component/lib/metadataExtractor.ts +0 -792
  238. package/src/component/lib/mutationAuth.ts +0 -199
  239. package/src/component/lib/queries.ts +0 -79
  240. package/src/component/lib/ragContentChunker.ts +0 -1371
  241. package/src/component/lib/referenceResolver.ts +0 -430
  242. package/src/component/lib/slugGenerator.ts +0 -262
  243. package/src/component/lib/slugUniqueness.ts +0 -333
  244. package/src/component/lib/softDelete.ts +0 -44
  245. package/src/component/localeFallbackChain.ts +0 -673
  246. package/src/component/localeFields.ts +0 -896
  247. package/src/component/mediaAssetMutations.ts +0 -725
  248. package/src/component/mediaAssets.ts +0 -932
  249. package/src/component/mediaFolderMutations.ts +0 -1046
  250. package/src/component/mediaUploadMutations.ts +0 -224
  251. package/src/component/mediaVariantMutations.ts +0 -900
  252. package/src/component/mediaVariants.ts +0 -793
  253. package/src/component/ragContentIndexer.ts +0 -1067
  254. package/src/component/rateLimitHooks.ts +0 -572
  255. package/src/component/roles.ts +0 -1360
  256. package/src/component/scheduledPublish.ts +0 -358
  257. package/src/component/schema.ts +0 -617
  258. package/src/component/taxonomies.ts +0 -949
  259. package/src/component/taxonomyMutations.ts +0 -1210
  260. package/src/component/trash.ts +0 -724
  261. package/src/component/userContext.ts +0 -898
  262. package/src/component/validation.ts +0 -1388
  263. package/src/component/validators.ts +0 -949
  264. package/src/component/versionMutations.ts +0 -392
  265. package/src/component/webhookTrigger.ts +0 -1922
  266. package/src/react/index.ts +0 -898
  267. package/src/test.ts +0 -1580
@@ -0,0 +1,1711 @@
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 Asset({
1361
+ tag,
1362
+ attrs,
1363
+ children,
1364
+ nonce
1365
+ }) {
1366
+ switch (tag) {
1367
+ case "title":
1368
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("title", { ...attrs, suppressHydrationWarning: true, children });
1369
+ case "meta":
1370
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("meta", { ...attrs, suppressHydrationWarning: true });
1371
+ case "link":
1372
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("link", { ...attrs, nonce, suppressHydrationWarning: true });
1373
+ case "style":
1374
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
1375
+ "style",
1376
+ {
1377
+ ...attrs,
1378
+ dangerouslySetInnerHTML: { __html: children },
1379
+ nonce
1380
+ }
1381
+ );
1382
+ case "script":
1383
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Script, { attrs, children });
1384
+ default:
1385
+ return null;
1386
+ }
1387
+ }
1388
+ function Script({
1389
+ attrs,
1390
+ children
1391
+ }) {
1392
+ const router = useRouter();
1393
+ reactExports.useEffect(() => {
1394
+ if (attrs?.src) {
1395
+ const normSrc = (() => {
1396
+ try {
1397
+ const base = document.baseURI || window.location.href;
1398
+ return new URL(attrs.src, base).href;
1399
+ } catch {
1400
+ return attrs.src;
1401
+ }
1402
+ })();
1403
+ const existingScript = Array.from(
1404
+ document.querySelectorAll("script[src]")
1405
+ ).find((el) => el.src === normSrc);
1406
+ if (existingScript) {
1407
+ return;
1408
+ }
1409
+ const script = document.createElement("script");
1410
+ for (const [key, value] of Object.entries(attrs)) {
1411
+ if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) {
1412
+ script.setAttribute(
1413
+ key,
1414
+ typeof value === "boolean" ? "" : String(value)
1415
+ );
1416
+ }
1417
+ }
1418
+ document.head.appendChild(script);
1419
+ return () => {
1420
+ if (script.parentNode) {
1421
+ script.parentNode.removeChild(script);
1422
+ }
1423
+ };
1424
+ }
1425
+ if (typeof children === "string") {
1426
+ const typeAttr = typeof attrs?.type === "string" ? attrs.type : "text/javascript";
1427
+ const nonceAttr = typeof attrs?.nonce === "string" ? attrs.nonce : void 0;
1428
+ const existingScript = Array.from(
1429
+ document.querySelectorAll("script:not([src])")
1430
+ ).find((el) => {
1431
+ if (!(el instanceof HTMLScriptElement)) return false;
1432
+ const sType = el.getAttribute("type") ?? "text/javascript";
1433
+ const sNonce = el.getAttribute("nonce") ?? void 0;
1434
+ return el.textContent === children && sType === typeAttr && sNonce === nonceAttr;
1435
+ });
1436
+ if (existingScript) {
1437
+ return;
1438
+ }
1439
+ const script = document.createElement("script");
1440
+ script.textContent = children;
1441
+ if (attrs) {
1442
+ for (const [key, value] of Object.entries(attrs)) {
1443
+ if (key !== "suppressHydrationWarning" && value !== void 0 && value !== false) {
1444
+ script.setAttribute(
1445
+ key,
1446
+ typeof value === "boolean" ? "" : String(value)
1447
+ );
1448
+ }
1449
+ }
1450
+ }
1451
+ document.head.appendChild(script);
1452
+ return () => {
1453
+ if (script.parentNode) {
1454
+ script.parentNode.removeChild(script);
1455
+ }
1456
+ };
1457
+ }
1458
+ return void 0;
1459
+ }, [attrs, children]);
1460
+ if (!router.isServer) {
1461
+ const { src, ...rest } = attrs || {};
1462
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
1463
+ "script",
1464
+ {
1465
+ suppressHydrationWarning: true,
1466
+ dangerouslySetInnerHTML: { __html: "" },
1467
+ ...rest
1468
+ }
1469
+ );
1470
+ }
1471
+ if (attrs?.src && typeof attrs.src === "string") {
1472
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("script", { ...attrs, suppressHydrationWarning: true });
1473
+ }
1474
+ if (typeof children === "string") {
1475
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(
1476
+ "script",
1477
+ {
1478
+ ...attrs,
1479
+ dangerouslySetInnerHTML: { __html: children },
1480
+ suppressHydrationWarning: true
1481
+ }
1482
+ );
1483
+ }
1484
+ return null;
1485
+ }
1486
+ const useTags = () => {
1487
+ const router = useRouter();
1488
+ const nonce = router.options.ssr?.nonce;
1489
+ const routeMeta = useRouterState({
1490
+ select: (state) => {
1491
+ return state.matches.map((match) => match.meta).filter(Boolean);
1492
+ }
1493
+ });
1494
+ const meta = reactExports.useMemo(() => {
1495
+ const resultMeta = [];
1496
+ const metaByAttribute = {};
1497
+ let title;
1498
+ for (let i = routeMeta.length - 1; i >= 0; i--) {
1499
+ const metas = routeMeta[i];
1500
+ for (let j = metas.length - 1; j >= 0; j--) {
1501
+ const m = metas[j];
1502
+ if (!m) continue;
1503
+ if (m.title) {
1504
+ if (!title) {
1505
+ title = {
1506
+ tag: "title",
1507
+ children: m.title
1508
+ };
1509
+ }
1510
+ } else if ("script:ld+json" in m) {
1511
+ try {
1512
+ const json = JSON.stringify(m["script:ld+json"]);
1513
+ resultMeta.push({
1514
+ tag: "script",
1515
+ attrs: {
1516
+ type: "application/ld+json"
1517
+ },
1518
+ children: escapeHtml(json)
1519
+ });
1520
+ } catch {
1521
+ }
1522
+ } else {
1523
+ const attribute = m.name ?? m.property;
1524
+ if (attribute) {
1525
+ if (metaByAttribute[attribute]) {
1526
+ continue;
1527
+ } else {
1528
+ metaByAttribute[attribute] = true;
1529
+ }
1530
+ }
1531
+ resultMeta.push({
1532
+ tag: "meta",
1533
+ attrs: {
1534
+ ...m,
1535
+ nonce
1536
+ }
1537
+ });
1538
+ }
1539
+ }
1540
+ }
1541
+ if (title) {
1542
+ resultMeta.push(title);
1543
+ }
1544
+ if (nonce) {
1545
+ resultMeta.push({
1546
+ tag: "meta",
1547
+ attrs: {
1548
+ property: "csp-nonce",
1549
+ content: nonce
1550
+ }
1551
+ });
1552
+ }
1553
+ resultMeta.reverse();
1554
+ return resultMeta;
1555
+ }, [routeMeta, nonce]);
1556
+ const links = useRouterState({
1557
+ select: (state) => {
1558
+ const constructed = state.matches.map((match) => match.links).filter(Boolean).flat(1).map((link) => ({
1559
+ tag: "link",
1560
+ attrs: {
1561
+ ...link,
1562
+ nonce
1563
+ }
1564
+ }));
1565
+ const manifest = router.ssr?.manifest;
1566
+ const assets = state.matches.map((match) => manifest?.routes[match.routeId]?.assets ?? []).filter(Boolean).flat(1).filter((asset) => asset.tag === "link").map(
1567
+ (asset) => ({
1568
+ tag: "link",
1569
+ attrs: {
1570
+ ...asset.attrs,
1571
+ suppressHydrationWarning: true,
1572
+ nonce
1573
+ }
1574
+ })
1575
+ );
1576
+ return [...constructed, ...assets];
1577
+ },
1578
+ structuralSharing: true
1579
+ });
1580
+ const preloadLinks = useRouterState({
1581
+ select: (state) => {
1582
+ const preloadLinks2 = [];
1583
+ state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
1584
+ (route) => router.ssr?.manifest?.routes[route.id]?.preloads?.filter(Boolean).forEach((preload) => {
1585
+ preloadLinks2.push({
1586
+ tag: "link",
1587
+ attrs: {
1588
+ rel: "modulepreload",
1589
+ href: preload,
1590
+ nonce
1591
+ }
1592
+ });
1593
+ })
1594
+ );
1595
+ return preloadLinks2;
1596
+ },
1597
+ structuralSharing: true
1598
+ });
1599
+ const styles = useRouterState({
1600
+ select: (state) => state.matches.map((match) => match.styles).flat(1).filter(Boolean).map(({ children, ...attrs }) => ({
1601
+ tag: "style",
1602
+ attrs: {
1603
+ ...attrs,
1604
+ nonce
1605
+ },
1606
+ children
1607
+ })),
1608
+ structuralSharing: true
1609
+ });
1610
+ const headScripts = useRouterState({
1611
+ select: (state) => state.matches.map((match) => match.headScripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
1612
+ tag: "script",
1613
+ attrs: {
1614
+ ...script,
1615
+ nonce
1616
+ },
1617
+ children
1618
+ })),
1619
+ structuralSharing: true
1620
+ });
1621
+ return uniqBy(
1622
+ [
1623
+ ...meta,
1624
+ ...preloadLinks,
1625
+ ...links,
1626
+ ...styles,
1627
+ ...headScripts
1628
+ ],
1629
+ (d) => {
1630
+ return JSON.stringify(d);
1631
+ }
1632
+ );
1633
+ };
1634
+ function uniqBy(arr, fn) {
1635
+ const seen = /* @__PURE__ */ new Set();
1636
+ return arr.filter((item) => {
1637
+ const key = fn(item);
1638
+ if (seen.has(key)) {
1639
+ return false;
1640
+ }
1641
+ seen.add(key);
1642
+ return true;
1643
+ });
1644
+ }
1645
+ function HeadContent() {
1646
+ const tags = useTags();
1647
+ const router = useRouter();
1648
+ const nonce = router.options.ssr?.nonce;
1649
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: tags.map((tag) => /* @__PURE__ */ reactExports.createElement(Asset, { ...tag, key: `tsr-meta-${JSON.stringify(tag)}`, nonce })) });
1650
+ }
1651
+ const Scripts = () => {
1652
+ const router = useRouter();
1653
+ const nonce = router.options.ssr?.nonce;
1654
+ const assetScripts = useRouterState({
1655
+ select: (state) => {
1656
+ const assetScripts2 = [];
1657
+ const manifest = router.ssr?.manifest;
1658
+ if (!manifest) {
1659
+ return [];
1660
+ }
1661
+ state.matches.map((match) => router.looseRoutesById[match.routeId]).forEach(
1662
+ (route) => manifest.routes[route.id]?.assets?.filter((d) => d.tag === "script").forEach((asset) => {
1663
+ assetScripts2.push({
1664
+ tag: "script",
1665
+ attrs: { ...asset.attrs, nonce },
1666
+ children: asset.children
1667
+ });
1668
+ })
1669
+ );
1670
+ return assetScripts2;
1671
+ },
1672
+ structuralSharing: true
1673
+ });
1674
+ const { scripts } = useRouterState({
1675
+ select: (state) => ({
1676
+ scripts: state.matches.map((match) => match.scripts).flat(1).filter(Boolean).map(({ children, ...script }) => ({
1677
+ tag: "script",
1678
+ attrs: {
1679
+ ...script,
1680
+ suppressHydrationWarning: true,
1681
+ nonce
1682
+ },
1683
+ children
1684
+ }))
1685
+ }),
1686
+ structuralSharing: true
1687
+ });
1688
+ let serverBufferedScript = void 0;
1689
+ if (router.serverSsr) {
1690
+ serverBufferedScript = router.serverSsr.takeBufferedScripts();
1691
+ }
1692
+ const allScripts = [...scripts, ...assetScripts];
1693
+ if (serverBufferedScript) {
1694
+ allScripts.unshift(serverBufferedScript);
1695
+ }
1696
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: allScripts.map((asset, i) => /* @__PURE__ */ reactExports.createElement(Asset, { ...asset, key: `tsr-scripts-${asset.tag}-${i}` })) });
1697
+ };
1698
+ export {
1699
+ HeadContent as H,
1700
+ Link as L,
1701
+ Outlet as O,
1702
+ RouterProvider as R,
1703
+ Scripts as S,
1704
+ createRootRoute as a,
1705
+ createFileRoute as b,
1706
+ createRouter as c,
1707
+ useNavigate as d,
1708
+ lazyRouteComponent as l,
1709
+ renderRouterToStream as r,
1710
+ useRouterState as u
1711
+ };