chunk-HMTWJNYB.js 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354
  1. "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }/**
  2. * react-router v7.10.1
  3. *
  4. * Copyright (c) Remix Software Inc.
  5. *
  6. * This source code is licensed under the MIT license found in the
  7. * LICENSE.md file in the root directory of this source tree.
  8. *
  9. * @license MIT
  10. */
  11. var _chunkRBZI3ZHDjs = require('./chunk-RBZI3ZHD.js');
  12. // lib/dom/dom.ts
  13. var defaultMethod = "get";
  14. var defaultEncType = "application/x-www-form-urlencoded";
  15. function isHtmlElement(object) {
  16. return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
  17. }
  18. function isButtonElement(object) {
  19. return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
  20. }
  21. function isFormElement(object) {
  22. return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
  23. }
  24. function isInputElement(object) {
  25. return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
  26. }
  27. function isModifiedEvent(event) {
  28. return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
  29. }
  30. function shouldProcessLinkClick(event, target) {
  31. return event.button === 0 && // Ignore everything but left clicks
  32. (!target || target === "_self") && // Let browser handle "target=_blank" etc.
  33. !isModifiedEvent(event);
  34. }
  35. function createSearchParams(init = "") {
  36. return new URLSearchParams(
  37. typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
  38. let value = init[key];
  39. return memo.concat(
  40. Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]
  41. );
  42. }, [])
  43. );
  44. }
  45. function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
  46. let searchParams = createSearchParams(locationSearch);
  47. if (defaultSearchParams) {
  48. defaultSearchParams.forEach((_, key) => {
  49. if (!searchParams.has(key)) {
  50. defaultSearchParams.getAll(key).forEach((value) => {
  51. searchParams.append(key, value);
  52. });
  53. }
  54. });
  55. }
  56. return searchParams;
  57. }
  58. var _formDataSupportsSubmitter = null;
  59. function isFormDataSubmitterSupported() {
  60. if (_formDataSupportsSubmitter === null) {
  61. try {
  62. new FormData(
  63. document.createElement("form"),
  64. // @ts-expect-error if FormData supports the submitter parameter, this will throw
  65. 0
  66. );
  67. _formDataSupportsSubmitter = false;
  68. } catch (e) {
  69. _formDataSupportsSubmitter = true;
  70. }
  71. }
  72. return _formDataSupportsSubmitter;
  73. }
  74. var supportedFormEncTypes = /* @__PURE__ */ new Set([
  75. "application/x-www-form-urlencoded",
  76. "multipart/form-data",
  77. "text/plain"
  78. ]);
  79. function getFormEncType(encType) {
  80. if (encType != null && !supportedFormEncTypes.has(encType)) {
  81. _chunkRBZI3ZHDjs.warning.call(void 0,
  82. false,
  83. `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
  84. );
  85. return null;
  86. }
  87. return encType;
  88. }
  89. function getFormSubmissionInfo(target, basename) {
  90. let method;
  91. let action;
  92. let encType;
  93. let formData;
  94. let body;
  95. if (isFormElement(target)) {
  96. let attr = target.getAttribute("action");
  97. action = attr ? _chunkRBZI3ZHDjs.stripBasename.call(void 0, attr, basename) : null;
  98. method = target.getAttribute("method") || defaultMethod;
  99. encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
  100. formData = new FormData(target);
  101. } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
  102. let form = target.form;
  103. if (form == null) {
  104. throw new Error(
  105. `Cannot submit a <button> or <input type="submit"> without a <form>`
  106. );
  107. }
  108. let attr = target.getAttribute("formaction") || form.getAttribute("action");
  109. action = attr ? _chunkRBZI3ZHDjs.stripBasename.call(void 0, attr, basename) : null;
  110. method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
  111. encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
  112. formData = new FormData(form, target);
  113. if (!isFormDataSubmitterSupported()) {
  114. let { name, type, value } = target;
  115. if (type === "image") {
  116. let prefix = name ? `${name}.` : "";
  117. formData.append(`${prefix}x`, "0");
  118. formData.append(`${prefix}y`, "0");
  119. } else if (name) {
  120. formData.append(name, value);
  121. }
  122. }
  123. } else if (isHtmlElement(target)) {
  124. throw new Error(
  125. `Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
  126. );
  127. } else {
  128. method = defaultMethod;
  129. action = null;
  130. encType = defaultEncType;
  131. body = target;
  132. }
  133. if (formData && encType === "text/plain") {
  134. body = formData;
  135. formData = void 0;
  136. }
  137. return { action, method: method.toLowerCase(), encType, formData, body };
  138. }
  139. // lib/dom/lib.tsx
  140. var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
  141. var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
  142. try {
  143. if (isBrowser) {
  144. window.__reactRouterVersion = // @ts-expect-error
  145. "7.10.1";
  146. }
  147. } catch (e) {
  148. }
  149. function createBrowserRouter(routes, opts) {
  150. return _chunkRBZI3ZHDjs.createRouter.call(void 0, {
  151. basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
  152. getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
  153. future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
  154. history: _chunkRBZI3ZHDjs.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _5 => _5.window]) }),
  155. hydrationData: _optionalChain([opts, 'optionalAccess', _6 => _6.hydrationData]) || parseHydrationData(),
  156. routes,
  157. mapRouteProperties: _chunkRBZI3ZHDjs.mapRouteProperties,
  158. hydrationRouteProperties: _chunkRBZI3ZHDjs.hydrationRouteProperties,
  159. dataStrategy: _optionalChain([opts, 'optionalAccess', _7 => _7.dataStrategy]),
  160. patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _8 => _8.patchRoutesOnNavigation]),
  161. window: _optionalChain([opts, 'optionalAccess', _9 => _9.window]),
  162. unstable_instrumentations: _optionalChain([opts, 'optionalAccess', _10 => _10.unstable_instrumentations])
  163. }).initialize();
  164. }
  165. function createHashRouter(routes, opts) {
  166. return _chunkRBZI3ZHDjs.createRouter.call(void 0, {
  167. basename: _optionalChain([opts, 'optionalAccess', _11 => _11.basename]),
  168. getContext: _optionalChain([opts, 'optionalAccess', _12 => _12.getContext]),
  169. future: _optionalChain([opts, 'optionalAccess', _13 => _13.future]),
  170. history: _chunkRBZI3ZHDjs.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _14 => _14.window]) }),
  171. hydrationData: _optionalChain([opts, 'optionalAccess', _15 => _15.hydrationData]) || parseHydrationData(),
  172. routes,
  173. mapRouteProperties: _chunkRBZI3ZHDjs.mapRouteProperties,
  174. hydrationRouteProperties: _chunkRBZI3ZHDjs.hydrationRouteProperties,
  175. dataStrategy: _optionalChain([opts, 'optionalAccess', _16 => _16.dataStrategy]),
  176. patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _17 => _17.patchRoutesOnNavigation]),
  177. window: _optionalChain([opts, 'optionalAccess', _18 => _18.window]),
  178. unstable_instrumentations: _optionalChain([opts, 'optionalAccess', _19 => _19.unstable_instrumentations])
  179. }).initialize();
  180. }
  181. function parseHydrationData() {
  182. let state = _optionalChain([window, 'optionalAccess', _20 => _20.__staticRouterHydrationData]);
  183. if (state && state.errors) {
  184. state = {
  185. ...state,
  186. errors: deserializeErrors(state.errors)
  187. };
  188. }
  189. return state;
  190. }
  191. function deserializeErrors(errors) {
  192. if (!errors) return null;
  193. let entries = Object.entries(errors);
  194. let serialized = {};
  195. for (let [key, val] of entries) {
  196. if (val && val.__type === "RouteErrorResponse") {
  197. serialized[key] = new (0, _chunkRBZI3ZHDjs.ErrorResponseImpl)(
  198. val.status,
  199. val.statusText,
  200. val.data,
  201. val.internal === true
  202. );
  203. } else if (val && val.__type === "Error") {
  204. if (val.__subType) {
  205. let ErrorConstructor = window[val.__subType];
  206. if (typeof ErrorConstructor === "function") {
  207. try {
  208. let error = new ErrorConstructor(val.message);
  209. error.stack = "";
  210. serialized[key] = error;
  211. } catch (e) {
  212. }
  213. }
  214. }
  215. if (serialized[key] == null) {
  216. let error = new Error(val.message);
  217. error.stack = "";
  218. serialized[key] = error;
  219. }
  220. } else {
  221. serialized[key] = val;
  222. }
  223. }
  224. return serialized;
  225. }
  226. function BrowserRouter({
  227. basename,
  228. children,
  229. unstable_useTransitions,
  230. window: window2
  231. }) {
  232. let historyRef = React.useRef();
  233. if (historyRef.current == null) {
  234. historyRef.current = _chunkRBZI3ZHDjs.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
  235. }
  236. let history = historyRef.current;
  237. let [state, setStateImpl] = React.useState({
  238. action: history.action,
  239. location: history.location
  240. });
  241. let setState = React.useCallback(
  242. (newState) => {
  243. if (unstable_useTransitions === false) {
  244. setStateImpl(newState);
  245. } else {
  246. React.startTransition(() => setStateImpl(newState));
  247. }
  248. },
  249. [unstable_useTransitions]
  250. );
  251. React.useLayoutEffect(() => history.listen(setState), [history, setState]);
  252. return /* @__PURE__ */ React.createElement(
  253. _chunkRBZI3ZHDjs.Router,
  254. {
  255. basename,
  256. children,
  257. location: state.location,
  258. navigationType: state.action,
  259. navigator: history,
  260. unstable_useTransitions: unstable_useTransitions === true
  261. }
  262. );
  263. }
  264. function HashRouter({
  265. basename,
  266. children,
  267. unstable_useTransitions,
  268. window: window2
  269. }) {
  270. let historyRef = React.useRef();
  271. if (historyRef.current == null) {
  272. historyRef.current = _chunkRBZI3ZHDjs.createHashHistory.call(void 0, { window: window2, v5Compat: true });
  273. }
  274. let history = historyRef.current;
  275. let [state, setStateImpl] = React.useState({
  276. action: history.action,
  277. location: history.location
  278. });
  279. let setState = React.useCallback(
  280. (newState) => {
  281. if (unstable_useTransitions === false) {
  282. setStateImpl(newState);
  283. } else {
  284. React.startTransition(() => setStateImpl(newState));
  285. }
  286. },
  287. [unstable_useTransitions]
  288. );
  289. React.useLayoutEffect(() => history.listen(setState), [history, setState]);
  290. return /* @__PURE__ */ React.createElement(
  291. _chunkRBZI3ZHDjs.Router,
  292. {
  293. basename,
  294. children,
  295. location: state.location,
  296. navigationType: state.action,
  297. navigator: history,
  298. unstable_useTransitions: unstable_useTransitions === true
  299. }
  300. );
  301. }
  302. function HistoryRouter({
  303. basename,
  304. children,
  305. history,
  306. unstable_useTransitions
  307. }) {
  308. let [state, setStateImpl] = React.useState({
  309. action: history.action,
  310. location: history.location
  311. });
  312. let setState = React.useCallback(
  313. (newState) => {
  314. if (unstable_useTransitions === false) {
  315. setStateImpl(newState);
  316. } else {
  317. React.startTransition(() => setStateImpl(newState));
  318. }
  319. },
  320. [unstable_useTransitions]
  321. );
  322. React.useLayoutEffect(() => history.listen(setState), [history, setState]);
  323. return /* @__PURE__ */ React.createElement(
  324. _chunkRBZI3ZHDjs.Router,
  325. {
  326. basename,
  327. children,
  328. location: state.location,
  329. navigationType: state.action,
  330. navigator: history,
  331. unstable_useTransitions: unstable_useTransitions === true
  332. }
  333. );
  334. }
  335. HistoryRouter.displayName = "unstable_HistoryRouter";
  336. var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
  337. var Link = React.forwardRef(
  338. function LinkWithRef({
  339. onClick,
  340. discover = "render",
  341. prefetch = "none",
  342. relative,
  343. reloadDocument,
  344. replace,
  345. state,
  346. target,
  347. to,
  348. preventScrollReset,
  349. viewTransition,
  350. ...rest
  351. }, forwardedRef) {
  352. let { basename, unstable_useTransitions } = React.useContext(_chunkRBZI3ZHDjs.NavigationContext);
  353. let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
  354. let absoluteHref;
  355. let isExternal = false;
  356. if (typeof to === "string" && isAbsolute) {
  357. absoluteHref = to;
  358. if (isBrowser) {
  359. try {
  360. let currentUrl = new URL(window.location.href);
  361. let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
  362. let path = _chunkRBZI3ZHDjs.stripBasename.call(void 0, targetUrl.pathname, basename);
  363. if (targetUrl.origin === currentUrl.origin && path != null) {
  364. to = path + targetUrl.search + targetUrl.hash;
  365. } else {
  366. isExternal = true;
  367. }
  368. } catch (e) {
  369. _chunkRBZI3ZHDjs.warning.call(void 0,
  370. false,
  371. `<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
  372. );
  373. }
  374. }
  375. }
  376. let href = _chunkRBZI3ZHDjs.useHref.call(void 0, to, { relative });
  377. let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkRBZI3ZHDjs.usePrefetchBehavior.call(void 0,
  378. prefetch,
  379. rest
  380. );
  381. let internalOnClick = useLinkClickHandler(to, {
  382. replace,
  383. state,
  384. target,
  385. preventScrollReset,
  386. relative,
  387. viewTransition,
  388. unstable_useTransitions
  389. });
  390. function handleClick(event) {
  391. if (onClick) onClick(event);
  392. if (!event.defaultPrevented) {
  393. internalOnClick(event);
  394. }
  395. }
  396. let link = (
  397. // eslint-disable-next-line jsx-a11y/anchor-has-content
  398. /* @__PURE__ */ React.createElement(
  399. "a",
  400. {
  401. ...rest,
  402. ...prefetchHandlers,
  403. href: absoluteHref || href,
  404. onClick: isExternal || reloadDocument ? onClick : handleClick,
  405. ref: _chunkRBZI3ZHDjs.mergeRefs.call(void 0, forwardedRef, prefetchRef),
  406. target,
  407. "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
  408. }
  409. )
  410. );
  411. return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(_chunkRBZI3ZHDjs.PrefetchPageLinks, { page: href })) : link;
  412. }
  413. );
  414. Link.displayName = "Link";
  415. var NavLink = React.forwardRef(
  416. function NavLinkWithRef({
  417. "aria-current": ariaCurrentProp = "page",
  418. caseSensitive = false,
  419. className: classNameProp = "",
  420. end = false,
  421. style: styleProp,
  422. to,
  423. viewTransition,
  424. children,
  425. ...rest
  426. }, ref) {
  427. let path = _chunkRBZI3ZHDjs.useResolvedPath.call(void 0, to, { relative: rest.relative });
  428. let location = _chunkRBZI3ZHDjs.useLocation.call(void 0, );
  429. let routerState = React.useContext(_chunkRBZI3ZHDjs.DataRouterStateContext);
  430. let { navigator, basename } = React.useContext(_chunkRBZI3ZHDjs.NavigationContext);
  431. let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
  432. // eslint-disable-next-line react-hooks/rules-of-hooks
  433. useViewTransitionState(path) && viewTransition === true;
  434. let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
  435. let locationPathname = location.pathname;
  436. let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
  437. if (!caseSensitive) {
  438. locationPathname = locationPathname.toLowerCase();
  439. nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
  440. toPathname = toPathname.toLowerCase();
  441. }
  442. if (nextLocationPathname && basename) {
  443. nextLocationPathname = _chunkRBZI3ZHDjs.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
  444. }
  445. const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
  446. let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
  447. let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
  448. let renderProps = {
  449. isActive,
  450. isPending,
  451. isTransitioning
  452. };
  453. let ariaCurrent = isActive ? ariaCurrentProp : void 0;
  454. let className;
  455. if (typeof classNameProp === "function") {
  456. className = classNameProp(renderProps);
  457. } else {
  458. className = [
  459. classNameProp,
  460. isActive ? "active" : null,
  461. isPending ? "pending" : null,
  462. isTransitioning ? "transitioning" : null
  463. ].filter(Boolean).join(" ");
  464. }
  465. let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
  466. return /* @__PURE__ */ React.createElement(
  467. Link,
  468. {
  469. ...rest,
  470. "aria-current": ariaCurrent,
  471. className,
  472. ref,
  473. style,
  474. to,
  475. viewTransition
  476. },
  477. typeof children === "function" ? children(renderProps) : children
  478. );
  479. }
  480. );
  481. NavLink.displayName = "NavLink";
  482. var Form = React.forwardRef(
  483. ({
  484. discover = "render",
  485. fetcherKey,
  486. navigate,
  487. reloadDocument,
  488. replace,
  489. state,
  490. method = defaultMethod,
  491. action,
  492. onSubmit,
  493. relative,
  494. preventScrollReset,
  495. viewTransition,
  496. ...props
  497. }, forwardedRef) => {
  498. let { unstable_useTransitions } = React.useContext(_chunkRBZI3ZHDjs.NavigationContext);
  499. let submit = useSubmit();
  500. let formAction = useFormAction(action, { relative });
  501. let formMethod = method.toLowerCase() === "get" ? "get" : "post";
  502. let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX.test(action);
  503. let submitHandler = (event) => {
  504. onSubmit && onSubmit(event);
  505. if (event.defaultPrevented) return;
  506. event.preventDefault();
  507. let submitter = event.nativeEvent.submitter;
  508. let submitMethod = _optionalChain([submitter, 'optionalAccess', _21 => _21.getAttribute, 'call', _22 => _22("formmethod")]) || method;
  509. let doSubmit = () => submit(submitter || event.currentTarget, {
  510. fetcherKey,
  511. method: submitMethod,
  512. navigate,
  513. replace,
  514. state,
  515. relative,
  516. preventScrollReset,
  517. viewTransition
  518. });
  519. if (unstable_useTransitions && navigate !== false) {
  520. React.startTransition(() => doSubmit());
  521. } else {
  522. doSubmit();
  523. }
  524. };
  525. return /* @__PURE__ */ React.createElement(
  526. "form",
  527. {
  528. ref: forwardedRef,
  529. method: formMethod,
  530. action: formAction,
  531. onSubmit: reloadDocument ? onSubmit : submitHandler,
  532. ...props,
  533. "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
  534. }
  535. );
  536. }
  537. );
  538. Form.displayName = "Form";
  539. function ScrollRestoration({
  540. getKey,
  541. storageKey,
  542. ...props
  543. }) {
  544. let remixContext = React.useContext(_chunkRBZI3ZHDjs.FrameworkContext);
  545. let { basename } = React.useContext(_chunkRBZI3ZHDjs.NavigationContext);
  546. let location = _chunkRBZI3ZHDjs.useLocation.call(void 0, );
  547. let matches = _chunkRBZI3ZHDjs.useMatches.call(void 0, );
  548. useScrollRestoration({ getKey, storageKey });
  549. let ssrKey = React.useMemo(
  550. () => {
  551. if (!remixContext || !getKey) return null;
  552. let userKey = getScrollRestorationKey(
  553. location,
  554. matches,
  555. basename,
  556. getKey
  557. );
  558. return userKey !== location.key ? userKey : null;
  559. },
  560. // Nah, we only need this the first time for the SSR render
  561. // eslint-disable-next-line react-hooks/exhaustive-deps
  562. []
  563. );
  564. if (!remixContext || remixContext.isSpaMode) {
  565. return null;
  566. }
  567. let restoreScroll = ((storageKey2, restoreKey) => {
  568. if (!window.history.state || !window.history.state.key) {
  569. let key = Math.random().toString(32).slice(2);
  570. window.history.replaceState({ key }, "");
  571. }
  572. try {
  573. let positions = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
  574. let storedY = positions[restoreKey || window.history.state.key];
  575. if (typeof storedY === "number") {
  576. window.scrollTo(0, storedY);
  577. }
  578. } catch (error) {
  579. console.error(error);
  580. sessionStorage.removeItem(storageKey2);
  581. }
  582. }).toString();
  583. return /* @__PURE__ */ React.createElement(
  584. "script",
  585. {
  586. ...props,
  587. suppressHydrationWarning: true,
  588. dangerouslySetInnerHTML: {
  589. __html: `(${restoreScroll})(${JSON.stringify(
  590. storageKey || SCROLL_RESTORATION_STORAGE_KEY
  591. )}, ${JSON.stringify(ssrKey)})`
  592. }
  593. }
  594. );
  595. }
  596. ScrollRestoration.displayName = "ScrollRestoration";
  597. function getDataRouterConsoleError(hookName) {
  598. return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
  599. }
  600. function useDataRouterContext(hookName) {
  601. let ctx = React.useContext(_chunkRBZI3ZHDjs.DataRouterContext);
  602. _chunkRBZI3ZHDjs.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
  603. return ctx;
  604. }
  605. function useDataRouterState(hookName) {
  606. let state = React.useContext(_chunkRBZI3ZHDjs.DataRouterStateContext);
  607. _chunkRBZI3ZHDjs.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
  608. return state;
  609. }
  610. function useLinkClickHandler(to, {
  611. target,
  612. replace: replaceProp,
  613. state,
  614. preventScrollReset,
  615. relative,
  616. viewTransition,
  617. unstable_useTransitions
  618. } = {}) {
  619. let navigate = _chunkRBZI3ZHDjs.useNavigate.call(void 0, );
  620. let location = _chunkRBZI3ZHDjs.useLocation.call(void 0, );
  621. let path = _chunkRBZI3ZHDjs.useResolvedPath.call(void 0, to, { relative });
  622. return React.useCallback(
  623. (event) => {
  624. if (shouldProcessLinkClick(event, target)) {
  625. event.preventDefault();
  626. let replace = replaceProp !== void 0 ? replaceProp : _chunkRBZI3ZHDjs.createPath.call(void 0, location) === _chunkRBZI3ZHDjs.createPath.call(void 0, path);
  627. let doNavigate = () => navigate(to, {
  628. replace,
  629. state,
  630. preventScrollReset,
  631. relative,
  632. viewTransition
  633. });
  634. if (unstable_useTransitions) {
  635. React.startTransition(() => doNavigate());
  636. } else {
  637. doNavigate();
  638. }
  639. }
  640. },
  641. [
  642. location,
  643. navigate,
  644. path,
  645. replaceProp,
  646. state,
  647. target,
  648. to,
  649. preventScrollReset,
  650. relative,
  651. viewTransition,
  652. unstable_useTransitions
  653. ]
  654. );
  655. }
  656. function useSearchParams(defaultInit) {
  657. _chunkRBZI3ZHDjs.warning.call(void 0,
  658. typeof URLSearchParams !== "undefined",
  659. `You cannot use the \`useSearchParams\` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.`
  660. );
  661. let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
  662. let hasSetSearchParamsRef = React.useRef(false);
  663. let location = _chunkRBZI3ZHDjs.useLocation.call(void 0, );
  664. let searchParams = React.useMemo(
  665. () => (
  666. // Only merge in the defaults if we haven't yet called setSearchParams.
  667. // Once we call that we want those to take precedence, otherwise you can't
  668. // remove a param with setSearchParams({}) if it has an initial value
  669. getSearchParamsForLocation(
  670. location.search,
  671. hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
  672. )
  673. ),
  674. [location.search]
  675. );
  676. let navigate = _chunkRBZI3ZHDjs.useNavigate.call(void 0, );
  677. let setSearchParams = React.useCallback(
  678. (nextInit, navigateOptions) => {
  679. const newSearchParams = createSearchParams(
  680. typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit
  681. );
  682. hasSetSearchParamsRef.current = true;
  683. navigate("?" + newSearchParams, navigateOptions);
  684. },
  685. [navigate, searchParams]
  686. );
  687. return [searchParams, setSearchParams];
  688. }
  689. var fetcherId = 0;
  690. var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
  691. function useSubmit() {
  692. let { router } = useDataRouterContext("useSubmit" /* UseSubmit */);
  693. let { basename } = React.useContext(_chunkRBZI3ZHDjs.NavigationContext);
  694. let currentRouteId = _chunkRBZI3ZHDjs.useRouteId.call(void 0, );
  695. let routerFetch = router.fetch;
  696. let routerNavigate = router.navigate;
  697. return React.useCallback(
  698. async (target, options = {}) => {
  699. let { action, method, encType, formData, body } = getFormSubmissionInfo(
  700. target,
  701. basename
  702. );
  703. if (options.navigate === false) {
  704. let key = options.fetcherKey || getUniqueFetcherId();
  705. await routerFetch(key, currentRouteId, options.action || action, {
  706. preventScrollReset: options.preventScrollReset,
  707. formData,
  708. body,
  709. formMethod: options.method || method,
  710. formEncType: options.encType || encType,
  711. flushSync: options.flushSync
  712. });
  713. } else {
  714. await routerNavigate(options.action || action, {
  715. preventScrollReset: options.preventScrollReset,
  716. formData,
  717. body,
  718. formMethod: options.method || method,
  719. formEncType: options.encType || encType,
  720. replace: options.replace,
  721. state: options.state,
  722. fromRouteId: currentRouteId,
  723. flushSync: options.flushSync,
  724. viewTransition: options.viewTransition
  725. });
  726. }
  727. },
  728. [routerFetch, routerNavigate, basename, currentRouteId]
  729. );
  730. }
  731. function useFormAction(action, { relative } = {}) {
  732. let { basename } = React.useContext(_chunkRBZI3ZHDjs.NavigationContext);
  733. let routeContext = React.useContext(_chunkRBZI3ZHDjs.RouteContext);
  734. _chunkRBZI3ZHDjs.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
  735. let [match] = routeContext.matches.slice(-1);
  736. let path = { ..._chunkRBZI3ZHDjs.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
  737. let location = _chunkRBZI3ZHDjs.useLocation.call(void 0, );
  738. if (action == null) {
  739. path.search = location.search;
  740. let params = new URLSearchParams(path.search);
  741. let indexValues = params.getAll("index");
  742. let hasNakedIndexParam = indexValues.some((v) => v === "");
  743. if (hasNakedIndexParam) {
  744. params.delete("index");
  745. indexValues.filter((v) => v).forEach((v) => params.append("index", v));
  746. let qs = params.toString();
  747. path.search = qs ? `?${qs}` : "";
  748. }
  749. }
  750. if ((!action || action === ".") && match.route.index) {
  751. path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
  752. }
  753. if (basename !== "/") {
  754. path.pathname = path.pathname === "/" ? basename : _chunkRBZI3ZHDjs.joinPaths.call(void 0, [basename, path.pathname]);
  755. }
  756. return _chunkRBZI3ZHDjs.createPath.call(void 0, path);
  757. }
  758. function useFetcher({
  759. key
  760. } = {}) {
  761. let { router } = useDataRouterContext("useFetcher" /* UseFetcher */);
  762. let state = useDataRouterState("useFetcher" /* UseFetcher */);
  763. let fetcherData = React.useContext(_chunkRBZI3ZHDjs.FetchersContext);
  764. let route = React.useContext(_chunkRBZI3ZHDjs.RouteContext);
  765. let routeId = _optionalChain([route, 'access', _23 => _23.matches, 'access', _24 => _24[route.matches.length - 1], 'optionalAccess', _25 => _25.route, 'access', _26 => _26.id]);
  766. _chunkRBZI3ZHDjs.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
  767. _chunkRBZI3ZHDjs.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
  768. _chunkRBZI3ZHDjs.invariant.call(void 0,
  769. routeId != null,
  770. `useFetcher can only be used on routes that contain a unique "id"`
  771. );
  772. let defaultKey = React.useId();
  773. let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
  774. if (key && key !== fetcherKey) {
  775. setFetcherKey(key);
  776. }
  777. let { deleteFetcher, getFetcher, resetFetcher, fetch: routerFetch } = router;
  778. React.useEffect(() => {
  779. getFetcher(fetcherKey);
  780. return () => deleteFetcher(fetcherKey);
  781. }, [deleteFetcher, getFetcher, fetcherKey]);
  782. let load = React.useCallback(
  783. async (href, opts) => {
  784. _chunkRBZI3ZHDjs.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
  785. await routerFetch(fetcherKey, routeId, href, opts);
  786. },
  787. [fetcherKey, routeId, routerFetch]
  788. );
  789. let submitImpl = useSubmit();
  790. let submit = React.useCallback(
  791. async (target, opts) => {
  792. await submitImpl(target, {
  793. ...opts,
  794. navigate: false,
  795. fetcherKey
  796. });
  797. },
  798. [fetcherKey, submitImpl]
  799. );
  800. let reset = React.useCallback(
  801. (opts) => resetFetcher(fetcherKey, opts),
  802. [resetFetcher, fetcherKey]
  803. );
  804. let FetcherForm = React.useMemo(() => {
  805. let FetcherForm2 = React.forwardRef(
  806. (props, ref) => {
  807. return /* @__PURE__ */ React.createElement(Form, { ...props, navigate: false, fetcherKey, ref });
  808. }
  809. );
  810. FetcherForm2.displayName = "fetcher.Form";
  811. return FetcherForm2;
  812. }, [fetcherKey]);
  813. let fetcher = state.fetchers.get(fetcherKey) || _chunkRBZI3ZHDjs.IDLE_FETCHER;
  814. let data = fetcherData.get(fetcherKey);
  815. let fetcherWithComponents = React.useMemo(
  816. () => ({
  817. Form: FetcherForm,
  818. submit,
  819. load,
  820. reset,
  821. ...fetcher,
  822. data
  823. }),
  824. [FetcherForm, submit, load, reset, fetcher, data]
  825. );
  826. return fetcherWithComponents;
  827. }
  828. function useFetchers() {
  829. let state = useDataRouterState("useFetchers" /* UseFetchers */);
  830. return Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
  831. ...fetcher,
  832. key
  833. }));
  834. }
  835. var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
  836. var savedScrollPositions = {};
  837. function getScrollRestorationKey(location, matches, basename, getKey) {
  838. let key = null;
  839. if (getKey) {
  840. if (basename !== "/") {
  841. key = getKey(
  842. {
  843. ...location,
  844. pathname: _chunkRBZI3ZHDjs.stripBasename.call(void 0, location.pathname, basename) || location.pathname
  845. },
  846. matches
  847. );
  848. } else {
  849. key = getKey(location, matches);
  850. }
  851. }
  852. if (key == null) {
  853. key = location.key;
  854. }
  855. return key;
  856. }
  857. function useScrollRestoration({
  858. getKey,
  859. storageKey
  860. } = {}) {
  861. let { router } = useDataRouterContext("useScrollRestoration" /* UseScrollRestoration */);
  862. let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
  863. "useScrollRestoration" /* UseScrollRestoration */
  864. );
  865. let { basename } = React.useContext(_chunkRBZI3ZHDjs.NavigationContext);
  866. let location = _chunkRBZI3ZHDjs.useLocation.call(void 0, );
  867. let matches = _chunkRBZI3ZHDjs.useMatches.call(void 0, );
  868. let navigation = _chunkRBZI3ZHDjs.useNavigation.call(void 0, );
  869. React.useEffect(() => {
  870. window.history.scrollRestoration = "manual";
  871. return () => {
  872. window.history.scrollRestoration = "auto";
  873. };
  874. }, []);
  875. usePageHide(
  876. React.useCallback(() => {
  877. if (navigation.state === "idle") {
  878. let key = getScrollRestorationKey(location, matches, basename, getKey);
  879. savedScrollPositions[key] = window.scrollY;
  880. }
  881. try {
  882. sessionStorage.setItem(
  883. storageKey || SCROLL_RESTORATION_STORAGE_KEY,
  884. JSON.stringify(savedScrollPositions)
  885. );
  886. } catch (error) {
  887. _chunkRBZI3ZHDjs.warning.call(void 0,
  888. false,
  889. `Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
  890. );
  891. }
  892. window.history.scrollRestoration = "auto";
  893. }, [navigation.state, getKey, basename, location, matches, storageKey])
  894. );
  895. if (typeof document !== "undefined") {
  896. React.useLayoutEffect(() => {
  897. try {
  898. let sessionPositions = sessionStorage.getItem(
  899. storageKey || SCROLL_RESTORATION_STORAGE_KEY
  900. );
  901. if (sessionPositions) {
  902. savedScrollPositions = JSON.parse(sessionPositions);
  903. }
  904. } catch (e) {
  905. }
  906. }, [storageKey]);
  907. React.useLayoutEffect(() => {
  908. let disableScrollRestoration = _optionalChain([router, 'optionalAccess', _27 => _27.enableScrollRestoration, 'call', _28 => _28(
  909. savedScrollPositions,
  910. () => window.scrollY,
  911. getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
  912. )]);
  913. return () => disableScrollRestoration && disableScrollRestoration();
  914. }, [router, basename, getKey]);
  915. React.useLayoutEffect(() => {
  916. if (restoreScrollPosition === false) {
  917. return;
  918. }
  919. if (typeof restoreScrollPosition === "number") {
  920. window.scrollTo(0, restoreScrollPosition);
  921. return;
  922. }
  923. try {
  924. if (location.hash) {
  925. let el = document.getElementById(
  926. decodeURIComponent(location.hash.slice(1))
  927. );
  928. if (el) {
  929. el.scrollIntoView();
  930. return;
  931. }
  932. }
  933. } catch (e2) {
  934. _chunkRBZI3ZHDjs.warning.call(void 0,
  935. false,
  936. `"${location.hash.slice(
  937. 1
  938. )}" is not a decodable element ID. The view will not scroll to it.`
  939. );
  940. }
  941. if (preventScrollReset === true) {
  942. return;
  943. }
  944. window.scrollTo(0, 0);
  945. }, [location, restoreScrollPosition, preventScrollReset]);
  946. }
  947. }
  948. function useBeforeUnload(callback, options) {
  949. let { capture } = options || {};
  950. React.useEffect(() => {
  951. let opts = capture != null ? { capture } : void 0;
  952. window.addEventListener("beforeunload", callback, opts);
  953. return () => {
  954. window.removeEventListener("beforeunload", callback, opts);
  955. };
  956. }, [callback, capture]);
  957. }
  958. function usePageHide(callback, options) {
  959. let { capture } = options || {};
  960. React.useEffect(() => {
  961. let opts = capture != null ? { capture } : void 0;
  962. window.addEventListener("pagehide", callback, opts);
  963. return () => {
  964. window.removeEventListener("pagehide", callback, opts);
  965. };
  966. }, [callback, capture]);
  967. }
  968. function usePrompt({
  969. when,
  970. message
  971. }) {
  972. let blocker = _chunkRBZI3ZHDjs.useBlocker.call(void 0, when);
  973. React.useEffect(() => {
  974. if (blocker.state === "blocked") {
  975. let proceed = window.confirm(message);
  976. if (proceed) {
  977. setTimeout(blocker.proceed, 0);
  978. } else {
  979. blocker.reset();
  980. }
  981. }
  982. }, [blocker, message]);
  983. React.useEffect(() => {
  984. if (blocker.state === "blocked" && !when) {
  985. blocker.reset();
  986. }
  987. }, [blocker, when]);
  988. }
  989. function useViewTransitionState(to, { relative } = {}) {
  990. let vtContext = React.useContext(_chunkRBZI3ZHDjs.ViewTransitionContext);
  991. _chunkRBZI3ZHDjs.invariant.call(void 0,
  992. vtContext != null,
  993. "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
  994. );
  995. let { basename } = useDataRouterContext(
  996. "useViewTransitionState" /* useViewTransitionState */
  997. );
  998. let path = _chunkRBZI3ZHDjs.useResolvedPath.call(void 0, to, { relative });
  999. if (!vtContext.isTransitioning) {
  1000. return false;
  1001. }
  1002. let currentPath = _chunkRBZI3ZHDjs.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
  1003. let nextPath = _chunkRBZI3ZHDjs.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
  1004. return _chunkRBZI3ZHDjs.matchPath.call(void 0, path.pathname, nextPath) != null || _chunkRBZI3ZHDjs.matchPath.call(void 0, path.pathname, currentPath) != null;
  1005. }
  1006. // lib/dom/server.tsx
  1007. function StaticRouter({
  1008. basename,
  1009. children,
  1010. location: locationProp = "/"
  1011. }) {
  1012. if (typeof locationProp === "string") {
  1013. locationProp = _chunkRBZI3ZHDjs.parsePath.call(void 0, locationProp);
  1014. }
  1015. let action = "POP" /* Pop */;
  1016. let location = {
  1017. pathname: locationProp.pathname || "/",
  1018. search: locationProp.search || "",
  1019. hash: locationProp.hash || "",
  1020. state: locationProp.state != null ? locationProp.state : null,
  1021. key: locationProp.key || "default"
  1022. };
  1023. let staticNavigator = getStatelessNavigator();
  1024. return /* @__PURE__ */ React2.createElement(
  1025. _chunkRBZI3ZHDjs.Router,
  1026. {
  1027. basename,
  1028. children,
  1029. location,
  1030. navigationType: action,
  1031. navigator: staticNavigator,
  1032. static: true,
  1033. unstable_useTransitions: false
  1034. }
  1035. );
  1036. }
  1037. function StaticRouterProvider({
  1038. context,
  1039. router,
  1040. hydrate = true,
  1041. nonce
  1042. }) {
  1043. _chunkRBZI3ZHDjs.invariant.call(void 0,
  1044. router && context,
  1045. "You must provide `router` and `context` to <StaticRouterProvider>"
  1046. );
  1047. let dataRouterContext = {
  1048. router,
  1049. navigator: getStatelessNavigator(),
  1050. static: true,
  1051. staticContext: context,
  1052. basename: context.basename || "/"
  1053. };
  1054. let fetchersContext = /* @__PURE__ */ new Map();
  1055. let hydrateScript = "";
  1056. if (hydrate !== false) {
  1057. let data = {
  1058. loaderData: context.loaderData,
  1059. actionData: context.actionData,
  1060. errors: serializeErrors(context.errors)
  1061. };
  1062. let json = htmlEscape(JSON.stringify(JSON.stringify(data)));
  1063. hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
  1064. }
  1065. let { state } = dataRouterContext.router;
  1066. return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(_chunkRBZI3ZHDjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React2.createElement(_chunkRBZI3ZHDjs.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React2.createElement(_chunkRBZI3ZHDjs.FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React2.createElement(_chunkRBZI3ZHDjs.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React2.createElement(
  1067. _chunkRBZI3ZHDjs.Router,
  1068. {
  1069. basename: dataRouterContext.basename,
  1070. location: state.location,
  1071. navigationType: state.historyAction,
  1072. navigator: dataRouterContext.navigator,
  1073. static: dataRouterContext.static,
  1074. unstable_useTransitions: false
  1075. },
  1076. /* @__PURE__ */ React2.createElement(
  1077. DataRoutes,
  1078. {
  1079. routes: router.routes,
  1080. future: router.future,
  1081. state
  1082. }
  1083. )
  1084. ))))), hydrateScript ? /* @__PURE__ */ React2.createElement(
  1085. "script",
  1086. {
  1087. suppressHydrationWarning: true,
  1088. nonce,
  1089. dangerouslySetInnerHTML: { __html: hydrateScript }
  1090. }
  1091. ) : null);
  1092. }
  1093. function DataRoutes({
  1094. routes,
  1095. future,
  1096. state
  1097. }) {
  1098. return _chunkRBZI3ZHDjs.useRoutesImpl.call(void 0, routes, void 0, state, void 0, future);
  1099. }
  1100. function serializeErrors(errors) {
  1101. if (!errors) return null;
  1102. let entries = Object.entries(errors);
  1103. let serialized = {};
  1104. for (let [key, val] of entries) {
  1105. if (_chunkRBZI3ZHDjs.isRouteErrorResponse.call(void 0, val)) {
  1106. serialized[key] = { ...val, __type: "RouteErrorResponse" };
  1107. } else if (val instanceof Error) {
  1108. serialized[key] = {
  1109. message: val.message,
  1110. __type: "Error",
  1111. // If this is a subclass (i.e., ReferenceError), send up the type so we
  1112. // can re-create the same type during hydration.
  1113. ...val.name !== "Error" ? {
  1114. __subType: val.name
  1115. } : {}
  1116. };
  1117. } else {
  1118. serialized[key] = val;
  1119. }
  1120. }
  1121. return serialized;
  1122. }
  1123. function getStatelessNavigator() {
  1124. return {
  1125. createHref,
  1126. encodeLocation,
  1127. push(to) {
  1128. throw new Error(
  1129. `You cannot use navigator.push() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)})\` somewhere in your app.`
  1130. );
  1131. },
  1132. replace(to) {
  1133. throw new Error(
  1134. `You cannot use navigator.replace() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${JSON.stringify(to)}, { replace: true })\` somewhere in your app.`
  1135. );
  1136. },
  1137. go(delta) {
  1138. throw new Error(
  1139. `You cannot use navigator.go() on the server because it is a stateless environment. This error was probably triggered when you did a \`navigate(${delta})\` somewhere in your app.`
  1140. );
  1141. },
  1142. back() {
  1143. throw new Error(
  1144. `You cannot use navigator.back() on the server because it is a stateless environment.`
  1145. );
  1146. },
  1147. forward() {
  1148. throw new Error(
  1149. `You cannot use navigator.forward() on the server because it is a stateless environment.`
  1150. );
  1151. }
  1152. };
  1153. }
  1154. function createStaticHandler2(routes, opts) {
  1155. return _chunkRBZI3ZHDjs.createStaticHandler.call(void 0, routes, {
  1156. ...opts,
  1157. mapRouteProperties: _chunkRBZI3ZHDjs.mapRouteProperties
  1158. });
  1159. }
  1160. function createStaticRouter(routes, context, opts = {}) {
  1161. let manifest = {};
  1162. let dataRoutes = _chunkRBZI3ZHDjs.convertRoutesToDataRoutes.call(void 0,
  1163. routes,
  1164. _chunkRBZI3ZHDjs.mapRouteProperties,
  1165. void 0,
  1166. manifest
  1167. );
  1168. let matches = context.matches.map((match) => {
  1169. let route = manifest[match.route.id] || match.route;
  1170. return {
  1171. ...match,
  1172. route
  1173. };
  1174. });
  1175. let msg = (method) => `You cannot use router.${method}() on the server because it is a stateless environment`;
  1176. return {
  1177. get basename() {
  1178. return context.basename;
  1179. },
  1180. get future() {
  1181. return {
  1182. v8_middleware: false,
  1183. ..._optionalChain([opts, 'optionalAccess', _29 => _29.future])
  1184. };
  1185. },
  1186. get state() {
  1187. return {
  1188. historyAction: "POP" /* Pop */,
  1189. location: context.location,
  1190. matches,
  1191. loaderData: context.loaderData,
  1192. actionData: context.actionData,
  1193. errors: context.errors,
  1194. initialized: true,
  1195. navigation: _chunkRBZI3ZHDjs.IDLE_NAVIGATION,
  1196. restoreScrollPosition: null,
  1197. preventScrollReset: false,
  1198. revalidation: "idle",
  1199. fetchers: /* @__PURE__ */ new Map(),
  1200. blockers: /* @__PURE__ */ new Map()
  1201. };
  1202. },
  1203. get routes() {
  1204. return dataRoutes;
  1205. },
  1206. get window() {
  1207. return void 0;
  1208. },
  1209. initialize() {
  1210. throw msg("initialize");
  1211. },
  1212. subscribe() {
  1213. throw msg("subscribe");
  1214. },
  1215. enableScrollRestoration() {
  1216. throw msg("enableScrollRestoration");
  1217. },
  1218. navigate() {
  1219. throw msg("navigate");
  1220. },
  1221. fetch() {
  1222. throw msg("fetch");
  1223. },
  1224. revalidate() {
  1225. throw msg("revalidate");
  1226. },
  1227. createHref,
  1228. encodeLocation,
  1229. getFetcher() {
  1230. return _chunkRBZI3ZHDjs.IDLE_FETCHER;
  1231. },
  1232. deleteFetcher() {
  1233. throw msg("deleteFetcher");
  1234. },
  1235. resetFetcher() {
  1236. throw msg("resetFetcher");
  1237. },
  1238. dispose() {
  1239. throw msg("dispose");
  1240. },
  1241. getBlocker() {
  1242. return _chunkRBZI3ZHDjs.IDLE_BLOCKER;
  1243. },
  1244. deleteBlocker() {
  1245. throw msg("deleteBlocker");
  1246. },
  1247. patchRoutes() {
  1248. throw msg("patchRoutes");
  1249. },
  1250. _internalFetchControllers: /* @__PURE__ */ new Map(),
  1251. _internalSetRoutes() {
  1252. throw msg("_internalSetRoutes");
  1253. },
  1254. _internalSetStateDoNotUseOrYouWillBreakYourApp() {
  1255. throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
  1256. }
  1257. };
  1258. }
  1259. function createHref(to) {
  1260. return typeof to === "string" ? to : _chunkRBZI3ZHDjs.createPath.call(void 0, to);
  1261. }
  1262. function encodeLocation(to) {
  1263. let href = typeof to === "string" ? to : _chunkRBZI3ZHDjs.createPath.call(void 0, to);
  1264. href = href.replace(/ $/, "%20");
  1265. let encoded = ABSOLUTE_URL_REGEX2.test(href) ? new URL(href) : new URL(href, "http://localhost");
  1266. return {
  1267. pathname: encoded.pathname,
  1268. search: encoded.search,
  1269. hash: encoded.hash
  1270. };
  1271. }
  1272. var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
  1273. var ESCAPE_LOOKUP = {
  1274. "&": "\\u0026",
  1275. ">": "\\u003e",
  1276. "<": "\\u003c",
  1277. "\u2028": "\\u2028",
  1278. "\u2029": "\\u2029"
  1279. };
  1280. var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
  1281. function htmlEscape(str) {
  1282. return str.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
  1283. }
  1284. exports.createSearchParams = createSearchParams; exports.createBrowserRouter = createBrowserRouter; exports.createHashRouter = createHashRouter; exports.BrowserRouter = BrowserRouter; exports.HashRouter = HashRouter; exports.HistoryRouter = HistoryRouter; exports.Link = Link; exports.NavLink = NavLink; exports.Form = Form; exports.ScrollRestoration = ScrollRestoration; exports.useLinkClickHandler = useLinkClickHandler; exports.useSearchParams = useSearchParams; exports.useSubmit = useSubmit; exports.useFormAction = useFormAction; exports.useFetcher = useFetcher; exports.useFetchers = useFetchers; exports.useScrollRestoration = useScrollRestoration; exports.useBeforeUnload = useBeforeUnload; exports.usePrompt = usePrompt; exports.useViewTransitionState = useViewTransitionState; exports.StaticRouter = StaticRouter; exports.StaticRouterProvider = StaticRouterProvider; exports.createStaticHandler = createStaticHandler2; exports.createStaticRouter = createStaticRouter;