🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

react-router

Package Overview
Dependencies
Maintainers
2
Versions
1173
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-router - npm Package Compare versions

Comparing version
7.18.0
to
7.18.1
+188
dist/development/chunk-EVX4J2F5.js
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/**
* react-router v7.18.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
var _chunkSA4DP3SFjs = require('./chunk-SA4DP3SF.js');
// lib/dom/ssr/hydration.tsx
function getHydrationData({
state,
routes,
getRouteInfo,
location,
basename,
isSpaMode
}) {
let hydrationData = {
...state,
loaderData: { ...state.loaderData }
};
let initialMatches = _chunkSA4DP3SFjs.matchRoutes.call(void 0, routes, location, basename);
if (initialMatches) {
for (let match of initialMatches) {
let routeId = match.route.id;
let routeInfo = getRouteInfo(routeId);
if (_chunkSA4DP3SFjs.shouldHydrateRouteLoader.call(void 0,
routeId,
routeInfo.clientLoader,
routeInfo.hasLoader,
isSpaMode
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
delete hydrationData.loaderData[routeId];
} else if (!routeInfo.hasLoader) {
hydrationData.loaderData[routeId] = null;
}
}
}
return hydrationData;
}
// lib/rsc/errorBoundaries.tsx
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
var RSCRouterGlobalErrorBoundary = class extends _react2.default.Component {
constructor(props) {
super(props);
this.state = { error: null, location: props.location };
}
static getDerivedStateFromError(error) {
return { error };
}
static getDerivedStateFromProps(props, state) {
if (state.location !== props.location) {
return { error: null, location: props.location };
}
return { error: state.error, location: state.location };
}
render() {
if (this.state.error) {
return /* @__PURE__ */ _react2.default.createElement(
RSCDefaultRootErrorBoundaryImpl,
{
error: this.state.error,
renderAppShell: true
}
);
} else {
return this.props.children;
}
}
};
function ErrorWrapper({
renderAppShell,
title,
children
}) {
if (!renderAppShell) {
return children;
}
return /* @__PURE__ */ _react2.default.createElement("html", { lang: "en" }, /* @__PURE__ */ _react2.default.createElement("head", null, /* @__PURE__ */ _react2.default.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ _react2.default.createElement(
"meta",
{
name: "viewport",
content: "width=device-width,initial-scale=1,viewport-fit=cover"
}
), /* @__PURE__ */ _react2.default.createElement("title", null, title)), /* @__PURE__ */ _react2.default.createElement("body", null, /* @__PURE__ */ _react2.default.createElement("main", { style: { fontFamily: "system-ui, sans-serif", padding: "2rem" } }, children)));
}
function RSCDefaultRootErrorBoundaryImpl({
error,
renderAppShell
}) {
console.error(error);
let heyDeveloper = /* @__PURE__ */ _react2.default.createElement(
"script",
{
dangerouslySetInnerHTML: {
__html: `
console.log(
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
);
`
}
}
);
if (_chunkSA4DP3SFjs.isRouteErrorResponse.call(void 0, error)) {
return /* @__PURE__ */ _react2.default.createElement(
ErrorWrapper,
{
renderAppShell,
title: "Unhandled Thrown Response!"
},
/* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
_chunkSA4DP3SFjs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
);
}
let errorInstance;
if (error instanceof Error) {
errorInstance = error;
} else {
let errorString = error == null ? "Unknown Error" : typeof error === "object" && "toString" in error ? error.toString() : JSON.stringify(error);
errorInstance = new Error(errorString);
}
return /* @__PURE__ */ _react2.default.createElement(ErrorWrapper, { renderAppShell, title: "Application Error!" }, /* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, "Application Error"), /* @__PURE__ */ _react2.default.createElement(
"pre",
{
style: {
padding: "2rem",
background: "hsla(10, 50%, 50%, 0.1)",
color: "red",
overflow: "auto"
}
},
errorInstance.stack
), heyDeveloper);
}
function RSCDefaultRootErrorBoundary({
hasRootLayout
}) {
let error = _chunkSA4DP3SFjs.useRouteError.call(void 0, );
if (hasRootLayout === void 0) {
throw new Error("Missing 'hasRootLayout' prop");
}
return /* @__PURE__ */ _react2.default.createElement(
RSCDefaultRootErrorBoundaryImpl,
{
renderAppShell: !hasRootLayout,
error
}
);
}
// lib/rsc/route-modules.ts
function createRSCRouteModules(payload) {
const routeModules = {};
for (const match of payload.matches) {
populateRSCRouteModules(routeModules, match);
}
return routeModules;
}
function populateRSCRouteModules(routeModules, matches) {
matches = Array.isArray(matches) ? matches : [matches];
for (const match of matches) {
routeModules[match.id] = {
links: match.links,
meta: match.meta,
default: noopComponent
};
}
}
var noopComponent = () => null;
exports.getHydrationData = getHydrationData; exports.RSCRouterGlobalErrorBoundary = RSCRouterGlobalErrorBoundary; exports.RSCDefaultRootErrorBoundary = RSCDefaultRootErrorBoundary; exports.createRSCRouteModules = createRSCRouteModules; exports.populateRSCRouteModules = populateRSCRouteModules;
"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; }/**
* react-router v7.18.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
var _chunkSA4DP3SFjs = require('./chunk-SA4DP3SF.js');
// lib/dom/dom.ts
var defaultMethod = "get";
var defaultEncType = "application/x-www-form-urlencoded";
function isHtmlElement(object) {
return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
}
function isButtonElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
}
function isFormElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
}
function isInputElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
}
function isModifiedEvent(event) {
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
}
function shouldProcessLinkClick(event, target) {
return event.button === 0 && // Ignore everything but left clicks
(!target || target === "_self") && // Let browser handle "target=_blank" etc.
!isModifiedEvent(event);
}
function createSearchParams(init = "") {
return new URLSearchParams(
typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
let value = init[key];
return memo.concat(
Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]
);
}, [])
);
}
function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
let searchParams = createSearchParams(locationSearch);
if (defaultSearchParams) {
defaultSearchParams.forEach((_, key) => {
if (!searchParams.has(key)) {
defaultSearchParams.getAll(key).forEach((value) => {
searchParams.append(key, value);
});
}
});
}
return searchParams;
}
var _formDataSupportsSubmitter = null;
function isFormDataSubmitterSupported() {
if (_formDataSupportsSubmitter === null) {
try {
new FormData(
document.createElement("form"),
// @ts-expect-error if FormData supports the submitter parameter, this will throw
0
);
_formDataSupportsSubmitter = false;
} catch (e) {
_formDataSupportsSubmitter = true;
}
}
return _formDataSupportsSubmitter;
}
var supportedFormEncTypes = /* @__PURE__ */ new Set([
"application/x-www-form-urlencoded",
"multipart/form-data",
"text/plain"
]);
function getFormEncType(encType) {
if (encType != null && !supportedFormEncTypes.has(encType)) {
_chunkSA4DP3SFjs.warning.call(void 0,
false,
`"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
);
return null;
}
return encType;
}
function getFormSubmissionInfo(target, basename) {
let method;
let action;
let encType;
let formData;
let body;
if (isFormElement(target)) {
let attr = target.getAttribute("action");
action = attr ? _chunkSA4DP3SFjs.stripBasename.call(void 0, attr, basename) : null;
method = target.getAttribute("method") || defaultMethod;
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
formData = new FormData(target);
} else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
let form = target.form;
if (form == null) {
throw new Error(
`Cannot submit a <button> or <input type="submit"> without a <form>`
);
}
let attr = target.getAttribute("formaction") || form.getAttribute("action");
action = attr ? _chunkSA4DP3SFjs.stripBasename.call(void 0, attr, basename) : null;
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
formData = new FormData(form, target);
if (!isFormDataSubmitterSupported()) {
let { name, type, value } = target;
if (type === "image") {
let prefix = name ? `${name}.` : "";
formData.append(`${prefix}x`, "0");
formData.append(`${prefix}y`, "0");
} else if (name) {
formData.append(name, value);
}
}
} else if (isHtmlElement(target)) {
throw new Error(
`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
);
} else {
method = defaultMethod;
action = null;
encType = defaultEncType;
body = target;
}
if (formData && encType === "text/plain") {
body = formData;
formData = void 0;
}
return { action, method: method.toLowerCase(), encType, formData, body };
}
// lib/dom/lib.tsx
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
try {
if (isBrowser) {
window.__reactRouterVersion = // @ts-expect-error
"7.18.1";
}
} catch (e) {
}
function createBrowserRouter(routes, opts) {
return _chunkSA4DP3SFjs.createRouter.call(void 0, {
basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
history: _chunkSA4DP3SFjs.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _5 => _5.window]) }),
hydrationData: _optionalChain([opts, 'optionalAccess', _6 => _6.hydrationData]) || parseHydrationData(),
routes,
mapRouteProperties: _chunkSA4DP3SFjs.mapRouteProperties,
hydrationRouteProperties: _chunkSA4DP3SFjs.hydrationRouteProperties,
dataStrategy: _optionalChain([opts, 'optionalAccess', _7 => _7.dataStrategy]),
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _8 => _8.patchRoutesOnNavigation]),
window: _optionalChain([opts, 'optionalAccess', _9 => _9.window]),
instrumentations: _optionalChain([opts, 'optionalAccess', _10 => _10.instrumentations])
}).initialize();
}
function createHashRouter(routes, opts) {
return _chunkSA4DP3SFjs.createRouter.call(void 0, {
basename: _optionalChain([opts, 'optionalAccess', _11 => _11.basename]),
getContext: _optionalChain([opts, 'optionalAccess', _12 => _12.getContext]),
future: _optionalChain([opts, 'optionalAccess', _13 => _13.future]),
history: _chunkSA4DP3SFjs.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _14 => _14.window]) }),
hydrationData: _optionalChain([opts, 'optionalAccess', _15 => _15.hydrationData]) || parseHydrationData(),
routes,
mapRouteProperties: _chunkSA4DP3SFjs.mapRouteProperties,
hydrationRouteProperties: _chunkSA4DP3SFjs.hydrationRouteProperties,
dataStrategy: _optionalChain([opts, 'optionalAccess', _16 => _16.dataStrategy]),
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _17 => _17.patchRoutesOnNavigation]),
window: _optionalChain([opts, 'optionalAccess', _18 => _18.window]),
instrumentations: _optionalChain([opts, 'optionalAccess', _19 => _19.instrumentations])
}).initialize();
}
function parseHydrationData() {
let state = _optionalChain([window, 'optionalAccess', _20 => _20.__staticRouterHydrationData]);
if (state && state.errors) {
state = {
...state,
errors: deserializeErrors(state.errors)
};
}
return state;
}
function deserializeErrors(errors) {
if (!errors) return null;
let entries = Object.entries(errors);
let serialized = {};
for (let [key, val] of entries) {
if (val && val.__type === "RouteErrorResponse") {
serialized[key] = new (0, _chunkSA4DP3SFjs.ErrorResponseImpl)(
val.status,
val.statusText,
val.data,
val.internal === true
);
} else if (val && val.__type === "Error") {
if (typeof val.__subType === "string" && _chunkSA4DP3SFjs.SUPPORTED_ERROR_TYPES.includes(val.__subType)) {
let ErrorConstructor = window[val.__subType];
if (typeof ErrorConstructor === "function") {
try {
let error = new ErrorConstructor(val.message);
error.stack = "";
serialized[key] = error;
} catch (e) {
}
}
}
if (serialized[key] == null) {
let error = new Error(val.message);
error.stack = "";
serialized[key] = error;
}
} else {
serialized[key] = val;
}
}
return serialized;
}
function BrowserRouter({
basename,
children,
useTransitions,
window: window2
}) {
let historyRef = React.useRef();
if (historyRef.current == null) {
historyRef.current = _chunkSA4DP3SFjs.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
}
let history = historyRef.current;
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkSA4DP3SFjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
function HashRouter({
basename,
children,
useTransitions,
window: window2
}) {
let historyRef = React.useRef();
if (historyRef.current == null) {
historyRef.current = _chunkSA4DP3SFjs.createHashHistory.call(void 0, { window: window2, v5Compat: true });
}
let history = historyRef.current;
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkSA4DP3SFjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
function HistoryRouter({
basename,
children,
history,
useTransitions
}) {
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkSA4DP3SFjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
HistoryRouter.displayName = "unstable_HistoryRouter";
var Link = React.forwardRef(
function LinkWithRef({
onClick,
discover = "render",
prefetch = "none",
relative,
reloadDocument,
replace,
mask,
state,
target,
to,
preventScrollReset,
viewTransition,
defaultShouldRevalidate,
...rest
}, forwardedRef) {
let { basename, navigator, useTransitions } = React.useContext(_chunkSA4DP3SFjs.NavigationContext);
let isAbsolute = typeof to === "string" && _chunkSA4DP3SFjs.ABSOLUTE_URL_REGEX.test(to);
let parsed = _chunkSA4DP3SFjs.parseToInfo.call(void 0, to, basename);
to = parsed.to;
let href = _chunkSA4DP3SFjs.useHref.call(void 0, to, { relative });
let location = _chunkSA4DP3SFjs.useLocation.call(void 0, );
let maskedHref = null;
if (mask) {
let resolved = _chunkSA4DP3SFjs.resolveTo.call(void 0,
mask,
[],
location.mask ? location.mask.pathname : "/",
true
);
if (basename !== "/") {
resolved.pathname = resolved.pathname === "/" ? basename : _chunkSA4DP3SFjs.joinPaths.call(void 0, [basename, resolved.pathname]);
}
maskedHref = navigator.createHref(resolved);
}
let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkSA4DP3SFjs.usePrefetchBehavior.call(void 0,
prefetch,
rest
);
let internalOnClick = useLinkClickHandler(to, {
replace,
mask,
state,
target,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
});
function handleClick(event) {
if (onClick) onClick(event);
if (!event.defaultPrevented) {
internalOnClick(event);
}
}
let isSpaLink = !(parsed.isExternal || reloadDocument);
let link = (
// eslint-disable-next-line jsx-a11y/anchor-has-content
/* @__PURE__ */ React.createElement(
"a",
{
...rest,
...prefetchHandlers,
href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
onClick: isSpaLink ? handleClick : onClick,
ref: _chunkSA4DP3SFjs.mergeRefs.call(void 0, forwardedRef, prefetchRef),
target,
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
}
)
);
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(_chunkSA4DP3SFjs.PrefetchPageLinks, { page: href })) : link;
}
);
Link.displayName = "Link";
var NavLink = React.forwardRef(
function NavLinkWithRef({
"aria-current": ariaCurrentProp = "page",
caseSensitive = false,
className: classNameProp = "",
end = false,
style: styleProp,
to,
viewTransition,
children,
...rest
}, ref) {
let path = _chunkSA4DP3SFjs.useResolvedPath.call(void 0, to, { relative: rest.relative });
let location = _chunkSA4DP3SFjs.useLocation.call(void 0, );
let routerState = React.useContext(_chunkSA4DP3SFjs.DataRouterStateContext);
let { navigator, basename } = React.useContext(_chunkSA4DP3SFjs.NavigationContext);
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
// eslint-disable-next-line react-hooks/rules-of-hooks
useViewTransitionState(path) && viewTransition === true;
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
let locationPathname = location.pathname;
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
if (!caseSensitive) {
locationPathname = locationPathname.toLowerCase();
nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
toPathname = toPathname.toLowerCase();
}
if (nextLocationPathname && basename) {
nextLocationPathname = _chunkSA4DP3SFjs.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
}
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
let renderProps = {
isActive,
isPending,
isTransitioning
};
let ariaCurrent = isActive ? ariaCurrentProp : void 0;
let className;
if (typeof classNameProp === "function") {
className = classNameProp(renderProps);
} else {
className = [
classNameProp,
isActive ? "active" : null,
isPending ? "pending" : null,
isTransitioning ? "transitioning" : null
].filter(Boolean).join(" ");
}
let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
return /* @__PURE__ */ React.createElement(
Link,
{
...rest,
"aria-current": ariaCurrent,
className,
ref,
style,
to,
viewTransition
},
typeof children === "function" ? children(renderProps) : children
);
}
);
NavLink.displayName = "NavLink";
var Form = React.forwardRef(
({
discover = "render",
fetcherKey,
navigate,
reloadDocument,
replace,
state,
method = defaultMethod,
action,
onSubmit,
relative,
preventScrollReset,
viewTransition,
defaultShouldRevalidate,
...props
}, forwardedRef) => {
let { useTransitions } = React.useContext(_chunkSA4DP3SFjs.NavigationContext);
let submit = useSubmit();
let formAction = useFormAction(action, { relative });
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
let isAbsolute = typeof action === "string" && _chunkSA4DP3SFjs.ABSOLUTE_URL_REGEX.test(action);
let submitHandler = (event) => {
onSubmit && onSubmit(event);
if (event.defaultPrevented) return;
event.preventDefault();
let submitter = event.nativeEvent.submitter;
let submitMethod = _optionalChain([submitter, 'optionalAccess', _21 => _21.getAttribute, 'call', _22 => _22("formmethod")]) || method;
let doSubmit = () => submit(submitter || event.currentTarget, {
fetcherKey,
method: submitMethod,
navigate,
replace,
state,
relative,
preventScrollReset,
viewTransition,
defaultShouldRevalidate
});
if (useTransitions && navigate !== false) {
React.startTransition(() => doSubmit());
} else {
doSubmit();
}
};
return /* @__PURE__ */ React.createElement(
"form",
{
ref: forwardedRef,
method: formMethod,
action: formAction,
onSubmit: reloadDocument ? onSubmit : submitHandler,
...props,
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
}
);
}
);
Form.displayName = "Form";
function ScrollRestoration({
getKey,
storageKey,
...props
}) {
let remixContext = React.useContext(_chunkSA4DP3SFjs.FrameworkContext);
let { basename } = React.useContext(_chunkSA4DP3SFjs.NavigationContext);
let location = _chunkSA4DP3SFjs.useLocation.call(void 0, );
let matches = _chunkSA4DP3SFjs.useMatches.call(void 0, );
useScrollRestoration({ getKey, storageKey });
let ssrKey = React.useMemo(
() => {
if (!remixContext || !getKey) return null;
let userKey = getScrollRestorationKey(
location,
matches,
basename,
getKey
);
return userKey !== location.key ? userKey : null;
},
// Nah, we only need this the first time for the SSR render
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
if (!remixContext || remixContext.isSpaMode) {
return null;
}
let restoreScroll = ((storageKey2, restoreKey) => {
if (!window.history.state || !window.history.state.key) {
let key = Math.random().toString(32).slice(2);
window.history.replaceState({ key }, "");
}
try {
let positions = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
let storedY = positions[restoreKey || window.history.state.key];
if (typeof storedY === "number") {
window.scrollTo(0, storedY);
}
} catch (error) {
console.error(error);
sessionStorage.removeItem(storageKey2);
}
}).toString();
if (props.nonce == null && _optionalChain([remixContext, 'optionalAccess', _23 => _23.nonce])) {
props.nonce = remixContext.nonce;
}
return /* @__PURE__ */ React.createElement(
"script",
{
...props,
suppressHydrationWarning: true,
dangerouslySetInnerHTML: {
__html: `(${restoreScroll})(${_chunkSA4DP3SFjs.escapeHtml.call(void 0,
JSON.stringify(storageKey || SCROLL_RESTORATION_STORAGE_KEY)
)}, ${_chunkSA4DP3SFjs.escapeHtml.call(void 0, JSON.stringify(ssrKey))})`
}
}
);
}
ScrollRestoration.displayName = "ScrollRestoration";
function getDataRouterConsoleError(hookName) {
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
}
function useDataRouterContext(hookName) {
let ctx = React.useContext(_chunkSA4DP3SFjs.DataRouterContext);
_chunkSA4DP3SFjs.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
return ctx;
}
function useDataRouterState(hookName) {
let state = React.useContext(_chunkSA4DP3SFjs.DataRouterStateContext);
_chunkSA4DP3SFjs.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
return state;
}
function useLinkClickHandler(to, {
target,
replace: replaceProp,
mask,
state,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
} = {}) {
let navigate = _chunkSA4DP3SFjs.useNavigate.call(void 0, );
let location = _chunkSA4DP3SFjs.useLocation.call(void 0, );
let path = _chunkSA4DP3SFjs.useResolvedPath.call(void 0, to, { relative });
return React.useCallback(
(event) => {
if (shouldProcessLinkClick(event, target)) {
event.preventDefault();
let replace = replaceProp !== void 0 ? replaceProp : _chunkSA4DP3SFjs.createPath.call(void 0, location) === _chunkSA4DP3SFjs.createPath.call(void 0, path);
let doNavigate = () => navigate(to, {
replace,
mask,
state,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate
});
if (useTransitions) {
React.startTransition(() => doNavigate());
} else {
doNavigate();
}
}
},
[
location,
navigate,
path,
replaceProp,
mask,
state,
target,
to,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
]
);
}
function useSearchParams(defaultInit) {
_chunkSA4DP3SFjs.warning.call(void 0,
typeof URLSearchParams !== "undefined",
`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.`
);
let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
let hasSetSearchParamsRef = React.useRef(false);
let location = _chunkSA4DP3SFjs.useLocation.call(void 0, );
let searchParams = React.useMemo(
() => (
// Only merge in the defaults if we haven't yet called setSearchParams.
// Once we call that we want those to take precedence, otherwise you can't
// remove a param with setSearchParams({}) if it has an initial value
getSearchParamsForLocation(
location.search,
hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
)
),
[location.search]
);
let navigate = _chunkSA4DP3SFjs.useNavigate.call(void 0, );
let setSearchParams = React.useCallback(
(nextInit, navigateOptions) => {
const newSearchParams = createSearchParams(
typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit
);
hasSetSearchParamsRef.current = true;
navigate("?" + newSearchParams, navigateOptions);
},
[navigate, searchParams]
);
return [searchParams, setSearchParams];
}
var fetcherId = 0;
var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
function useSubmit() {
let { router } = useDataRouterContext("useSubmit" /* UseSubmit */);
let { basename } = React.useContext(_chunkSA4DP3SFjs.NavigationContext);
let currentRouteId = _chunkSA4DP3SFjs.useRouteId.call(void 0, );
let routerFetch = router.fetch;
let routerNavigate = router.navigate;
return React.useCallback(
async (target, options = {}) => {
let { action, method, encType, formData, body } = getFormSubmissionInfo(
target,
basename
);
if (options.navigate === false) {
let key = options.fetcherKey || getUniqueFetcherId();
await routerFetch(key, currentRouteId, options.action || action, {
defaultShouldRevalidate: options.defaultShouldRevalidate,
preventScrollReset: options.preventScrollReset,
formData,
body,
formMethod: options.method || method,
formEncType: options.encType || encType,
flushSync: options.flushSync
});
} else {
await routerNavigate(options.action || action, {
defaultShouldRevalidate: options.defaultShouldRevalidate,
preventScrollReset: options.preventScrollReset,
formData,
body,
formMethod: options.method || method,
formEncType: options.encType || encType,
replace: options.replace,
state: options.state,
fromRouteId: currentRouteId,
flushSync: options.flushSync,
viewTransition: options.viewTransition
});
}
},
[routerFetch, routerNavigate, basename, currentRouteId]
);
}
function useFormAction(action, { relative } = {}) {
let { basename } = React.useContext(_chunkSA4DP3SFjs.NavigationContext);
let routeContext = React.useContext(_chunkSA4DP3SFjs.RouteContext);
_chunkSA4DP3SFjs.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
let [match] = routeContext.matches.slice(-1);
let path = { ..._chunkSA4DP3SFjs.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
let location = _chunkSA4DP3SFjs.useLocation.call(void 0, );
if (action == null) {
path.search = location.search;
let params = new URLSearchParams(path.search);
let indexValues = params.getAll("index");
let hasNakedIndexParam = indexValues.some((v) => v === "");
if (hasNakedIndexParam) {
params.delete("index");
indexValues.filter((v) => v).forEach((v) => params.append("index", v));
let qs = params.toString();
path.search = qs ? `?${qs}` : "";
}
}
if ((!action || action === ".") && match.route.index) {
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
}
if (basename !== "/") {
path.pathname = path.pathname === "/" ? basename : _chunkSA4DP3SFjs.joinPaths.call(void 0, [basename, path.pathname]);
}
return _chunkSA4DP3SFjs.createPath.call(void 0, path);
}
function useFetcher({
key
} = {}) {
let { router } = useDataRouterContext("useFetcher" /* UseFetcher */);
let state = useDataRouterState("useFetcher" /* UseFetcher */);
let fetcherData = React.useContext(_chunkSA4DP3SFjs.FetchersContext);
let route = React.useContext(_chunkSA4DP3SFjs.RouteContext);
let routeId = _optionalChain([route, 'access', _24 => _24.matches, 'access', _25 => _25[route.matches.length - 1], 'optionalAccess', _26 => _26.route, 'access', _27 => _27.id]);
_chunkSA4DP3SFjs.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
_chunkSA4DP3SFjs.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
_chunkSA4DP3SFjs.invariant.call(void 0,
routeId != null,
`useFetcher can only be used on routes that contain a unique "id"`
);
let defaultKey = React.useId();
let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
if (key && key !== fetcherKey) {
setFetcherKey(key);
}
let { deleteFetcher, getFetcher, resetFetcher, fetch: routerFetch } = router;
React.useEffect(() => {
getFetcher(fetcherKey);
return () => deleteFetcher(fetcherKey);
}, [deleteFetcher, getFetcher, fetcherKey]);
let load = React.useCallback(
async (href, opts) => {
_chunkSA4DP3SFjs.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
await routerFetch(fetcherKey, routeId, href, opts);
},
[fetcherKey, routeId, routerFetch]
);
let submitImpl = useSubmit();
let submit = React.useCallback(
async (target, opts) => {
await submitImpl(target, {
...opts,
navigate: false,
fetcherKey
});
},
[fetcherKey, submitImpl]
);
let reset = React.useCallback(
(opts) => resetFetcher(fetcherKey, opts),
[resetFetcher, fetcherKey]
);
let FetcherForm = React.useMemo(() => {
let FetcherForm2 = React.forwardRef(
(props, ref) => {
return /* @__PURE__ */ React.createElement(Form, { ...props, navigate: false, fetcherKey, ref });
}
);
FetcherForm2.displayName = "fetcher.Form";
return FetcherForm2;
}, [fetcherKey]);
let fetcher = state.fetchers.get(fetcherKey) || _chunkSA4DP3SFjs.IDLE_FETCHER;
let data = fetcherData.get(fetcherKey);
let fetcherWithComponents = React.useMemo(
() => ({
Form: FetcherForm,
submit,
load,
reset,
...fetcher,
data
}),
[FetcherForm, submit, load, reset, fetcher, data]
);
return fetcherWithComponents;
}
function useFetchers() {
let state = useDataRouterState("useFetchers" /* UseFetchers */);
return React.useMemo(
() => Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
...fetcher,
key
})),
[state.fetchers]
);
}
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
var savedScrollPositions = {};
function getScrollRestorationKey(location, matches, basename, getKey) {
let key = null;
if (getKey) {
if (basename !== "/") {
key = getKey(
{
...location,
pathname: _chunkSA4DP3SFjs.stripBasename.call(void 0, location.pathname, basename) || location.pathname
},
matches
);
} else {
key = getKey(location, matches);
}
}
if (key == null) {
key = location.key;
}
return key;
}
function useScrollRestoration({
getKey,
storageKey
} = {}) {
let { router } = useDataRouterContext("useScrollRestoration" /* UseScrollRestoration */);
let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
"useScrollRestoration" /* UseScrollRestoration */
);
let { basename } = React.useContext(_chunkSA4DP3SFjs.NavigationContext);
let location = _chunkSA4DP3SFjs.useLocation.call(void 0, );
let matches = _chunkSA4DP3SFjs.useMatches.call(void 0, );
let navigation = _chunkSA4DP3SFjs.useNavigation.call(void 0, );
React.useEffect(() => {
window.history.scrollRestoration = "manual";
return () => {
window.history.scrollRestoration = "auto";
};
}, []);
usePageHide(
React.useCallback(() => {
if (navigation.state === "idle") {
let key = getScrollRestorationKey(location, matches, basename, getKey);
savedScrollPositions[key] = window.scrollY;
}
try {
sessionStorage.setItem(
storageKey || SCROLL_RESTORATION_STORAGE_KEY,
JSON.stringify(savedScrollPositions)
);
} catch (error) {
_chunkSA4DP3SFjs.warning.call(void 0,
false,
`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
);
}
window.history.scrollRestoration = "auto";
}, [navigation.state, getKey, basename, location, matches, storageKey])
);
if (typeof document !== "undefined") {
React.useLayoutEffect(() => {
try {
let sessionPositions = sessionStorage.getItem(
storageKey || SCROLL_RESTORATION_STORAGE_KEY
);
if (sessionPositions) {
savedScrollPositions = JSON.parse(sessionPositions);
}
} catch (e) {
}
}, [storageKey]);
React.useLayoutEffect(() => {
let disableScrollRestoration = _optionalChain([router, 'optionalAccess', _28 => _28.enableScrollRestoration, 'call', _29 => _29(
savedScrollPositions,
() => window.scrollY,
getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
)]);
return () => disableScrollRestoration && disableScrollRestoration();
}, [router, basename, getKey]);
React.useLayoutEffect(() => {
if (restoreScrollPosition === false) {
return;
}
if (typeof restoreScrollPosition === "number") {
window.scrollTo(0, restoreScrollPosition);
return;
}
try {
if (location.hash) {
let el = document.getElementById(
decodeURIComponent(location.hash.slice(1))
);
if (el) {
el.scrollIntoView();
return;
}
}
} catch (e2) {
_chunkSA4DP3SFjs.warning.call(void 0,
false,
`"${location.hash.slice(
1
)}" is not a decodable element ID. The view will not scroll to it.`
);
}
if (preventScrollReset === true) {
return;
}
window.scrollTo(0, 0);
}, [location, restoreScrollPosition, preventScrollReset]);
}
}
function useBeforeUnload(callback, options) {
let { capture } = options || {};
React.useEffect(() => {
let opts = capture != null ? { capture } : void 0;
window.addEventListener("beforeunload", callback, opts);
return () => {
window.removeEventListener("beforeunload", callback, opts);
};
}, [callback, capture]);
}
function usePageHide(callback, options) {
let { capture } = options || {};
React.useEffect(() => {
let opts = capture != null ? { capture } : void 0;
window.addEventListener("pagehide", callback, opts);
return () => {
window.removeEventListener("pagehide", callback, opts);
};
}, [callback, capture]);
}
function usePrompt({
when,
message
}) {
let blocker = _chunkSA4DP3SFjs.useBlocker.call(void 0, when);
React.useEffect(() => {
if (blocker.state === "blocked") {
let proceed = window.confirm(message);
if (proceed) {
setTimeout(blocker.proceed, 0);
} else {
blocker.reset();
}
}
}, [blocker, message]);
React.useEffect(() => {
if (blocker.state === "blocked" && !when) {
blocker.reset();
}
}, [blocker, when]);
}
function useViewTransitionState(to, { relative } = {}) {
let vtContext = React.useContext(_chunkSA4DP3SFjs.ViewTransitionContext);
_chunkSA4DP3SFjs.invariant.call(void 0,
vtContext != null,
"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
);
let { basename } = useDataRouterContext(
"useViewTransitionState" /* useViewTransitionState */
);
let path = _chunkSA4DP3SFjs.useResolvedPath.call(void 0, to, { relative });
if (!vtContext.isTransitioning) {
return false;
}
let currentPath = _chunkSA4DP3SFjs.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
let nextPath = _chunkSA4DP3SFjs.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
return _chunkSA4DP3SFjs.matchPath.call(void 0, path.pathname, nextPath) != null || _chunkSA4DP3SFjs.matchPath.call(void 0, path.pathname, currentPath) != null;
}
// lib/dom/server.tsx
function StaticRouter({
basename,
children,
location: locationProp = "/"
}) {
if (typeof locationProp === "string") {
locationProp = _chunkSA4DP3SFjs.parsePath.call(void 0, locationProp);
}
let action = "POP" /* Pop */;
let location = {
pathname: locationProp.pathname || "/",
search: locationProp.search || "",
hash: locationProp.hash || "",
state: locationProp.state != null ? locationProp.state : null,
key: locationProp.key || "default",
mask: void 0
};
let staticNavigator = getStatelessNavigator();
return /* @__PURE__ */ React2.createElement(
_chunkSA4DP3SFjs.Router,
{
basename,
children,
location,
navigationType: action,
navigator: staticNavigator,
static: true,
useTransitions: false
}
);
}
function StaticRouterProvider({
context,
router,
hydrate = true,
nonce
}) {
_chunkSA4DP3SFjs.invariant.call(void 0,
router && context,
"You must provide `router` and `context` to <StaticRouterProvider>"
);
let dataRouterContext = {
router,
navigator: getStatelessNavigator(),
static: true,
staticContext: context,
basename: context.basename || "/"
};
let fetchersContext = /* @__PURE__ */ new Map();
let hydrateScript = "";
if (hydrate !== false) {
let data = {
loaderData: context.loaderData,
actionData: context.actionData,
errors: serializeErrors(context.errors)
};
let json = _chunkSA4DP3SFjs.escapeHtml.call(void 0, JSON.stringify(JSON.stringify(data)));
hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
}
let { state } = dataRouterContext.router;
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(_chunkSA4DP3SFjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React2.createElement(_chunkSA4DP3SFjs.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React2.createElement(_chunkSA4DP3SFjs.FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React2.createElement(_chunkSA4DP3SFjs.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React2.createElement(
_chunkSA4DP3SFjs.Router,
{
basename: dataRouterContext.basename,
location: state.location,
navigationType: state.historyAction,
navigator: dataRouterContext.navigator,
static: dataRouterContext.static,
useTransitions: false
},
/* @__PURE__ */ React2.createElement(
_chunkSA4DP3SFjs.DataRoutes,
{
manifest: router.manifest,
routes: router.routes,
future: router.future,
state,
isStatic: true
}
)
))))), hydrateScript ? /* @__PURE__ */ React2.createElement(
"script",
{
suppressHydrationWarning: true,
nonce,
dangerouslySetInnerHTML: { __html: hydrateScript }
}
) : null);
}
function serializeErrors(errors) {
if (!errors) return null;
let entries = Object.entries(errors);
let serialized = {};
for (let [key, val] of entries) {
if (_chunkSA4DP3SFjs.isRouteErrorResponse.call(void 0, val)) {
serialized[key] = { ...val, __type: "RouteErrorResponse" };
} else if (val instanceof Error) {
serialized[key] = {
message: val.message,
__type: "Error",
// If this is a subclass (i.e., ReferenceError), send up the type so we
// can re-create the same type during hydration.
...val.name !== "Error" ? {
__subType: val.name
} : {}
};
} else {
serialized[key] = val;
}
}
return serialized;
}
function getStatelessNavigator() {
return {
createHref,
encodeLocation,
push(to) {
throw new Error(
`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.`
);
},
replace(to) {
throw new Error(
`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.`
);
},
go(delta) {
throw new Error(
`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.`
);
},
back() {
throw new Error(
`You cannot use navigator.back() on the server because it is a stateless environment.`
);
},
forward() {
throw new Error(
`You cannot use navigator.forward() on the server because it is a stateless environment.`
);
}
};
}
function createStaticHandler2(routes, opts) {
return _chunkSA4DP3SFjs.createStaticHandler.call(void 0, routes, {
...opts,
mapRouteProperties: _chunkSA4DP3SFjs.mapRouteProperties
});
}
function createStaticRouter(routes, context, opts = {}) {
let manifest = {};
let dataRoutes = _chunkSA4DP3SFjs.convertRoutesToDataRoutes.call(void 0,
routes,
_chunkSA4DP3SFjs.mapRouteProperties,
void 0,
manifest
);
let matches = context.matches.map((match) => {
let route = manifest[match.route.id] || match.route;
return {
...match,
route
};
});
let msg = (method) => `You cannot use router.${method}() on the server because it is a stateless environment`;
return {
get basename() {
return context.basename;
},
get future() {
return {
v8_middleware: false,
v8_passThroughRequests: false,
v8_trailingSlashAwareDataRequests: false,
..._optionalChain([opts, 'optionalAccess', _30 => _30.future])
};
},
get state() {
return {
historyAction: "POP" /* Pop */,
location: context.location,
matches,
loaderData: context.loaderData,
actionData: context.actionData,
errors: context.errors,
initialized: true,
renderFallback: false,
navigation: _chunkSA4DP3SFjs.IDLE_NAVIGATION,
restoreScrollPosition: null,
preventScrollReset: false,
revalidation: "idle",
fetchers: /* @__PURE__ */ new Map(),
blockers: /* @__PURE__ */ new Map()
};
},
get routes() {
return dataRoutes;
},
get branches() {
return opts.branches;
},
get manifest() {
return manifest;
},
get window() {
return void 0;
},
initialize() {
throw msg("initialize");
},
subscribe() {
throw msg("subscribe");
},
enableScrollRestoration() {
throw msg("enableScrollRestoration");
},
navigate() {
throw msg("navigate");
},
fetch() {
throw msg("fetch");
},
revalidate() {
throw msg("revalidate");
},
createHref,
encodeLocation,
getFetcher() {
return _chunkSA4DP3SFjs.IDLE_FETCHER;
},
deleteFetcher() {
throw msg("deleteFetcher");
},
resetFetcher() {
throw msg("resetFetcher");
},
dispose() {
throw msg("dispose");
},
getBlocker() {
return _chunkSA4DP3SFjs.IDLE_BLOCKER;
},
deleteBlocker() {
throw msg("deleteBlocker");
},
patchRoutes() {
throw msg("patchRoutes");
},
_internalFetchControllers: /* @__PURE__ */ new Map(),
_internalSetRoutes() {
throw msg("_internalSetRoutes");
},
_internalSetStateDoNotUseOrYouWillBreakYourApp() {
throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
}
};
}
function createHref(to) {
return typeof to === "string" ? to : _chunkSA4DP3SFjs.createPath.call(void 0, to);
}
function encodeLocation(to) {
let href = typeof to === "string" ? to : _chunkSA4DP3SFjs.createPath.call(void 0, to);
href = href.replace(/ $/, "%20");
let encoded = _chunkSA4DP3SFjs.ABSOLUTE_URL_REGEX.test(href) ? new URL(href) : new URL(href, "http://localhost");
return {
pathname: encoded.pathname,
search: encoded.search,
hash: encoded.hash
};
}
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;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/**
* react-router v7.18.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
var _chunkIEF7VMTAjs = require('./chunk-IEF7VMTA.js');
// lib/dom/ssr/hydration.tsx
function getHydrationData({
state,
routes,
getRouteInfo,
location,
basename,
isSpaMode
}) {
let hydrationData = {
...state,
loaderData: { ...state.loaderData }
};
let initialMatches = _chunkIEF7VMTAjs.matchRoutes.call(void 0, routes, location, basename);
if (initialMatches) {
for (let match of initialMatches) {
let routeId = match.route.id;
let routeInfo = getRouteInfo(routeId);
if (_chunkIEF7VMTAjs.shouldHydrateRouteLoader.call(void 0,
routeId,
routeInfo.clientLoader,
routeInfo.hasLoader,
isSpaMode
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
delete hydrationData.loaderData[routeId];
} else if (!routeInfo.hasLoader) {
hydrationData.loaderData[routeId] = null;
}
}
}
return hydrationData;
}
// lib/rsc/errorBoundaries.tsx
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
var RSCRouterGlobalErrorBoundary = class extends _react2.default.Component {
constructor(props) {
super(props);
this.state = { error: null, location: props.location };
}
static getDerivedStateFromError(error) {
return { error };
}
static getDerivedStateFromProps(props, state) {
if (state.location !== props.location) {
return { error: null, location: props.location };
}
return { error: state.error, location: state.location };
}
render() {
if (this.state.error) {
return /* @__PURE__ */ _react2.default.createElement(
RSCDefaultRootErrorBoundaryImpl,
{
error: this.state.error,
renderAppShell: true
}
);
} else {
return this.props.children;
}
}
};
function ErrorWrapper({
renderAppShell,
title,
children
}) {
if (!renderAppShell) {
return children;
}
return /* @__PURE__ */ _react2.default.createElement("html", { lang: "en" }, /* @__PURE__ */ _react2.default.createElement("head", null, /* @__PURE__ */ _react2.default.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ _react2.default.createElement(
"meta",
{
name: "viewport",
content: "width=device-width,initial-scale=1,viewport-fit=cover"
}
), /* @__PURE__ */ _react2.default.createElement("title", null, title)), /* @__PURE__ */ _react2.default.createElement("body", null, /* @__PURE__ */ _react2.default.createElement("main", { style: { fontFamily: "system-ui, sans-serif", padding: "2rem" } }, children)));
}
function RSCDefaultRootErrorBoundaryImpl({
error,
renderAppShell
}) {
console.error(error);
let heyDeveloper = /* @__PURE__ */ _react2.default.createElement(
"script",
{
dangerouslySetInnerHTML: {
__html: `
console.log(
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
);
`
}
}
);
if (_chunkIEF7VMTAjs.isRouteErrorResponse.call(void 0, error)) {
return /* @__PURE__ */ _react2.default.createElement(
ErrorWrapper,
{
renderAppShell,
title: "Unhandled Thrown Response!"
},
/* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
_chunkIEF7VMTAjs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
);
}
let errorInstance;
if (error instanceof Error) {
errorInstance = error;
} else {
let errorString = error == null ? "Unknown Error" : typeof error === "object" && "toString" in error ? error.toString() : JSON.stringify(error);
errorInstance = new Error(errorString);
}
return /* @__PURE__ */ _react2.default.createElement(ErrorWrapper, { renderAppShell, title: "Application Error!" }, /* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, "Application Error"), /* @__PURE__ */ _react2.default.createElement(
"pre",
{
style: {
padding: "2rem",
background: "hsla(10, 50%, 50%, 0.1)",
color: "red",
overflow: "auto"
}
},
errorInstance.stack
), heyDeveloper);
}
function RSCDefaultRootErrorBoundary({
hasRootLayout
}) {
let error = _chunkIEF7VMTAjs.useRouteError.call(void 0, );
if (hasRootLayout === void 0) {
throw new Error("Missing 'hasRootLayout' prop");
}
return /* @__PURE__ */ _react2.default.createElement(
RSCDefaultRootErrorBoundaryImpl,
{
renderAppShell: !hasRootLayout,
error
}
);
}
// lib/rsc/route-modules.ts
function createRSCRouteModules(payload) {
const routeModules = {};
for (const match of payload.matches) {
populateRSCRouteModules(routeModules, match);
}
return routeModules;
}
function populateRSCRouteModules(routeModules, matches) {
matches = Array.isArray(matches) ? matches : [matches];
for (const match of matches) {
routeModules[match.id] = {
links: match.links,
meta: match.meta,
default: noopComponent
};
}
}
var noopComponent = () => null;
exports.getHydrationData = getHydrationData; exports.RSCRouterGlobalErrorBoundary = RSCRouterGlobalErrorBoundary; exports.RSCDefaultRootErrorBoundary = RSCDefaultRootErrorBoundary; exports.createRSCRouteModules = createRSCRouteModules; exports.populateRSCRouteModules = populateRSCRouteModules;

Sorry, the diff of this file is too big to display

"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; }/**
* react-router v7.18.1
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
var _chunkIEF7VMTAjs = require('./chunk-IEF7VMTA.js');
// lib/dom/dom.ts
var defaultMethod = "get";
var defaultEncType = "application/x-www-form-urlencoded";
function isHtmlElement(object) {
return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
}
function isButtonElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
}
function isFormElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
}
function isInputElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
}
function isModifiedEvent(event) {
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
}
function shouldProcessLinkClick(event, target) {
return event.button === 0 && // Ignore everything but left clicks
(!target || target === "_self") && // Let browser handle "target=_blank" etc.
!isModifiedEvent(event);
}
function createSearchParams(init = "") {
return new URLSearchParams(
typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
let value = init[key];
return memo.concat(
Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]
);
}, [])
);
}
function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
let searchParams = createSearchParams(locationSearch);
if (defaultSearchParams) {
defaultSearchParams.forEach((_, key) => {
if (!searchParams.has(key)) {
defaultSearchParams.getAll(key).forEach((value) => {
searchParams.append(key, value);
});
}
});
}
return searchParams;
}
var _formDataSupportsSubmitter = null;
function isFormDataSubmitterSupported() {
if (_formDataSupportsSubmitter === null) {
try {
new FormData(
document.createElement("form"),
// @ts-expect-error if FormData supports the submitter parameter, this will throw
0
);
_formDataSupportsSubmitter = false;
} catch (e) {
_formDataSupportsSubmitter = true;
}
}
return _formDataSupportsSubmitter;
}
var supportedFormEncTypes = /* @__PURE__ */ new Set([
"application/x-www-form-urlencoded",
"multipart/form-data",
"text/plain"
]);
function getFormEncType(encType) {
if (encType != null && !supportedFormEncTypes.has(encType)) {
_chunkIEF7VMTAjs.warning.call(void 0,
false,
`"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
);
return null;
}
return encType;
}
function getFormSubmissionInfo(target, basename) {
let method;
let action;
let encType;
let formData;
let body;
if (isFormElement(target)) {
let attr = target.getAttribute("action");
action = attr ? _chunkIEF7VMTAjs.stripBasename.call(void 0, attr, basename) : null;
method = target.getAttribute("method") || defaultMethod;
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
formData = new FormData(target);
} else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
let form = target.form;
if (form == null) {
throw new Error(
`Cannot submit a <button> or <input type="submit"> without a <form>`
);
}
let attr = target.getAttribute("formaction") || form.getAttribute("action");
action = attr ? _chunkIEF7VMTAjs.stripBasename.call(void 0, attr, basename) : null;
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
formData = new FormData(form, target);
if (!isFormDataSubmitterSupported()) {
let { name, type, value } = target;
if (type === "image") {
let prefix = name ? `${name}.` : "";
formData.append(`${prefix}x`, "0");
formData.append(`${prefix}y`, "0");
} else if (name) {
formData.append(name, value);
}
}
} else if (isHtmlElement(target)) {
throw new Error(
`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
);
} else {
method = defaultMethod;
action = null;
encType = defaultEncType;
body = target;
}
if (formData && encType === "text/plain") {
body = formData;
formData = void 0;
}
return { action, method: method.toLowerCase(), encType, formData, body };
}
// lib/dom/lib.tsx
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
try {
if (isBrowser) {
window.__reactRouterVersion = // @ts-expect-error
"7.18.1";
}
} catch (e) {
}
function createBrowserRouter(routes, opts) {
return _chunkIEF7VMTAjs.createRouter.call(void 0, {
basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
history: _chunkIEF7VMTAjs.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _5 => _5.window]) }),
hydrationData: _optionalChain([opts, 'optionalAccess', _6 => _6.hydrationData]) || parseHydrationData(),
routes,
mapRouteProperties: _chunkIEF7VMTAjs.mapRouteProperties,
hydrationRouteProperties: _chunkIEF7VMTAjs.hydrationRouteProperties,
dataStrategy: _optionalChain([opts, 'optionalAccess', _7 => _7.dataStrategy]),
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _8 => _8.patchRoutesOnNavigation]),
window: _optionalChain([opts, 'optionalAccess', _9 => _9.window]),
instrumentations: _optionalChain([opts, 'optionalAccess', _10 => _10.instrumentations])
}).initialize();
}
function createHashRouter(routes, opts) {
return _chunkIEF7VMTAjs.createRouter.call(void 0, {
basename: _optionalChain([opts, 'optionalAccess', _11 => _11.basename]),
getContext: _optionalChain([opts, 'optionalAccess', _12 => _12.getContext]),
future: _optionalChain([opts, 'optionalAccess', _13 => _13.future]),
history: _chunkIEF7VMTAjs.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _14 => _14.window]) }),
hydrationData: _optionalChain([opts, 'optionalAccess', _15 => _15.hydrationData]) || parseHydrationData(),
routes,
mapRouteProperties: _chunkIEF7VMTAjs.mapRouteProperties,
hydrationRouteProperties: _chunkIEF7VMTAjs.hydrationRouteProperties,
dataStrategy: _optionalChain([opts, 'optionalAccess', _16 => _16.dataStrategy]),
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _17 => _17.patchRoutesOnNavigation]),
window: _optionalChain([opts, 'optionalAccess', _18 => _18.window]),
instrumentations: _optionalChain([opts, 'optionalAccess', _19 => _19.instrumentations])
}).initialize();
}
function parseHydrationData() {
let state = _optionalChain([window, 'optionalAccess', _20 => _20.__staticRouterHydrationData]);
if (state && state.errors) {
state = {
...state,
errors: deserializeErrors(state.errors)
};
}
return state;
}
function deserializeErrors(errors) {
if (!errors) return null;
let entries = Object.entries(errors);
let serialized = {};
for (let [key, val] of entries) {
if (val && val.__type === "RouteErrorResponse") {
serialized[key] = new (0, _chunkIEF7VMTAjs.ErrorResponseImpl)(
val.status,
val.statusText,
val.data,
val.internal === true
);
} else if (val && val.__type === "Error") {
if (typeof val.__subType === "string" && _chunkIEF7VMTAjs.SUPPORTED_ERROR_TYPES.includes(val.__subType)) {
let ErrorConstructor = window[val.__subType];
if (typeof ErrorConstructor === "function") {
try {
let error = new ErrorConstructor(val.message);
error.stack = "";
serialized[key] = error;
} catch (e) {
}
}
}
if (serialized[key] == null) {
let error = new Error(val.message);
error.stack = "";
serialized[key] = error;
}
} else {
serialized[key] = val;
}
}
return serialized;
}
function BrowserRouter({
basename,
children,
useTransitions,
window: window2
}) {
let historyRef = React.useRef();
if (historyRef.current == null) {
historyRef.current = _chunkIEF7VMTAjs.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
}
let history = historyRef.current;
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkIEF7VMTAjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
function HashRouter({
basename,
children,
useTransitions,
window: window2
}) {
let historyRef = React.useRef();
if (historyRef.current == null) {
historyRef.current = _chunkIEF7VMTAjs.createHashHistory.call(void 0, { window: window2, v5Compat: true });
}
let history = historyRef.current;
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkIEF7VMTAjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
function HistoryRouter({
basename,
children,
history,
useTransitions
}) {
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkIEF7VMTAjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
HistoryRouter.displayName = "unstable_HistoryRouter";
var Link = React.forwardRef(
function LinkWithRef({
onClick,
discover = "render",
prefetch = "none",
relative,
reloadDocument,
replace,
mask,
state,
target,
to,
preventScrollReset,
viewTransition,
defaultShouldRevalidate,
...rest
}, forwardedRef) {
let { basename, navigator, useTransitions } = React.useContext(_chunkIEF7VMTAjs.NavigationContext);
let isAbsolute = typeof to === "string" && _chunkIEF7VMTAjs.ABSOLUTE_URL_REGEX.test(to);
let parsed = _chunkIEF7VMTAjs.parseToInfo.call(void 0, to, basename);
to = parsed.to;
let href = _chunkIEF7VMTAjs.useHref.call(void 0, to, { relative });
let location = _chunkIEF7VMTAjs.useLocation.call(void 0, );
let maskedHref = null;
if (mask) {
let resolved = _chunkIEF7VMTAjs.resolveTo.call(void 0,
mask,
[],
location.mask ? location.mask.pathname : "/",
true
);
if (basename !== "/") {
resolved.pathname = resolved.pathname === "/" ? basename : _chunkIEF7VMTAjs.joinPaths.call(void 0, [basename, resolved.pathname]);
}
maskedHref = navigator.createHref(resolved);
}
let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkIEF7VMTAjs.usePrefetchBehavior.call(void 0,
prefetch,
rest
);
let internalOnClick = useLinkClickHandler(to, {
replace,
mask,
state,
target,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
});
function handleClick(event) {
if (onClick) onClick(event);
if (!event.defaultPrevented) {
internalOnClick(event);
}
}
let isSpaLink = !(parsed.isExternal || reloadDocument);
let link = (
// eslint-disable-next-line jsx-a11y/anchor-has-content
/* @__PURE__ */ React.createElement(
"a",
{
...rest,
...prefetchHandlers,
href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
onClick: isSpaLink ? handleClick : onClick,
ref: _chunkIEF7VMTAjs.mergeRefs.call(void 0, forwardedRef, prefetchRef),
target,
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
}
)
);
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(_chunkIEF7VMTAjs.PrefetchPageLinks, { page: href })) : link;
}
);
Link.displayName = "Link";
var NavLink = React.forwardRef(
function NavLinkWithRef({
"aria-current": ariaCurrentProp = "page",
caseSensitive = false,
className: classNameProp = "",
end = false,
style: styleProp,
to,
viewTransition,
children,
...rest
}, ref) {
let path = _chunkIEF7VMTAjs.useResolvedPath.call(void 0, to, { relative: rest.relative });
let location = _chunkIEF7VMTAjs.useLocation.call(void 0, );
let routerState = React.useContext(_chunkIEF7VMTAjs.DataRouterStateContext);
let { navigator, basename } = React.useContext(_chunkIEF7VMTAjs.NavigationContext);
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
// eslint-disable-next-line react-hooks/rules-of-hooks
useViewTransitionState(path) && viewTransition === true;
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
let locationPathname = location.pathname;
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
if (!caseSensitive) {
locationPathname = locationPathname.toLowerCase();
nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
toPathname = toPathname.toLowerCase();
}
if (nextLocationPathname && basename) {
nextLocationPathname = _chunkIEF7VMTAjs.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
}
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
let renderProps = {
isActive,
isPending,
isTransitioning
};
let ariaCurrent = isActive ? ariaCurrentProp : void 0;
let className;
if (typeof classNameProp === "function") {
className = classNameProp(renderProps);
} else {
className = [
classNameProp,
isActive ? "active" : null,
isPending ? "pending" : null,
isTransitioning ? "transitioning" : null
].filter(Boolean).join(" ");
}
let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
return /* @__PURE__ */ React.createElement(
Link,
{
...rest,
"aria-current": ariaCurrent,
className,
ref,
style,
to,
viewTransition
},
typeof children === "function" ? children(renderProps) : children
);
}
);
NavLink.displayName = "NavLink";
var Form = React.forwardRef(
({
discover = "render",
fetcherKey,
navigate,
reloadDocument,
replace,
state,
method = defaultMethod,
action,
onSubmit,
relative,
preventScrollReset,
viewTransition,
defaultShouldRevalidate,
...props
}, forwardedRef) => {
let { useTransitions } = React.useContext(_chunkIEF7VMTAjs.NavigationContext);
let submit = useSubmit();
let formAction = useFormAction(action, { relative });
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
let isAbsolute = typeof action === "string" && _chunkIEF7VMTAjs.ABSOLUTE_URL_REGEX.test(action);
let submitHandler = (event) => {
onSubmit && onSubmit(event);
if (event.defaultPrevented) return;
event.preventDefault();
let submitter = event.nativeEvent.submitter;
let submitMethod = _optionalChain([submitter, 'optionalAccess', _21 => _21.getAttribute, 'call', _22 => _22("formmethod")]) || method;
let doSubmit = () => submit(submitter || event.currentTarget, {
fetcherKey,
method: submitMethod,
navigate,
replace,
state,
relative,
preventScrollReset,
viewTransition,
defaultShouldRevalidate
});
if (useTransitions && navigate !== false) {
React.startTransition(() => doSubmit());
} else {
doSubmit();
}
};
return /* @__PURE__ */ React.createElement(
"form",
{
ref: forwardedRef,
method: formMethod,
action: formAction,
onSubmit: reloadDocument ? onSubmit : submitHandler,
...props,
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
}
);
}
);
Form.displayName = "Form";
function ScrollRestoration({
getKey,
storageKey,
...props
}) {
let remixContext = React.useContext(_chunkIEF7VMTAjs.FrameworkContext);
let { basename } = React.useContext(_chunkIEF7VMTAjs.NavigationContext);
let location = _chunkIEF7VMTAjs.useLocation.call(void 0, );
let matches = _chunkIEF7VMTAjs.useMatches.call(void 0, );
useScrollRestoration({ getKey, storageKey });
let ssrKey = React.useMemo(
() => {
if (!remixContext || !getKey) return null;
let userKey = getScrollRestorationKey(
location,
matches,
basename,
getKey
);
return userKey !== location.key ? userKey : null;
},
// Nah, we only need this the first time for the SSR render
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
if (!remixContext || remixContext.isSpaMode) {
return null;
}
let restoreScroll = ((storageKey2, restoreKey) => {
if (!window.history.state || !window.history.state.key) {
let key = Math.random().toString(32).slice(2);
window.history.replaceState({ key }, "");
}
try {
let positions = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
let storedY = positions[restoreKey || window.history.state.key];
if (typeof storedY === "number") {
window.scrollTo(0, storedY);
}
} catch (error) {
console.error(error);
sessionStorage.removeItem(storageKey2);
}
}).toString();
if (props.nonce == null && _optionalChain([remixContext, 'optionalAccess', _23 => _23.nonce])) {
props.nonce = remixContext.nonce;
}
return /* @__PURE__ */ React.createElement(
"script",
{
...props,
suppressHydrationWarning: true,
dangerouslySetInnerHTML: {
__html: `(${restoreScroll})(${_chunkIEF7VMTAjs.escapeHtml.call(void 0,
JSON.stringify(storageKey || SCROLL_RESTORATION_STORAGE_KEY)
)}, ${_chunkIEF7VMTAjs.escapeHtml.call(void 0, JSON.stringify(ssrKey))})`
}
}
);
}
ScrollRestoration.displayName = "ScrollRestoration";
function getDataRouterConsoleError(hookName) {
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
}
function useDataRouterContext(hookName) {
let ctx = React.useContext(_chunkIEF7VMTAjs.DataRouterContext);
_chunkIEF7VMTAjs.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
return ctx;
}
function useDataRouterState(hookName) {
let state = React.useContext(_chunkIEF7VMTAjs.DataRouterStateContext);
_chunkIEF7VMTAjs.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
return state;
}
function useLinkClickHandler(to, {
target,
replace: replaceProp,
mask,
state,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
} = {}) {
let navigate = _chunkIEF7VMTAjs.useNavigate.call(void 0, );
let location = _chunkIEF7VMTAjs.useLocation.call(void 0, );
let path = _chunkIEF7VMTAjs.useResolvedPath.call(void 0, to, { relative });
return React.useCallback(
(event) => {
if (shouldProcessLinkClick(event, target)) {
event.preventDefault();
let replace = replaceProp !== void 0 ? replaceProp : _chunkIEF7VMTAjs.createPath.call(void 0, location) === _chunkIEF7VMTAjs.createPath.call(void 0, path);
let doNavigate = () => navigate(to, {
replace,
mask,
state,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate
});
if (useTransitions) {
React.startTransition(() => doNavigate());
} else {
doNavigate();
}
}
},
[
location,
navigate,
path,
replaceProp,
mask,
state,
target,
to,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
]
);
}
function useSearchParams(defaultInit) {
_chunkIEF7VMTAjs.warning.call(void 0,
typeof URLSearchParams !== "undefined",
`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.`
);
let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
let hasSetSearchParamsRef = React.useRef(false);
let location = _chunkIEF7VMTAjs.useLocation.call(void 0, );
let searchParams = React.useMemo(
() => (
// Only merge in the defaults if we haven't yet called setSearchParams.
// Once we call that we want those to take precedence, otherwise you can't
// remove a param with setSearchParams({}) if it has an initial value
getSearchParamsForLocation(
location.search,
hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
)
),
[location.search]
);
let navigate = _chunkIEF7VMTAjs.useNavigate.call(void 0, );
let setSearchParams = React.useCallback(
(nextInit, navigateOptions) => {
const newSearchParams = createSearchParams(
typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit
);
hasSetSearchParamsRef.current = true;
navigate("?" + newSearchParams, navigateOptions);
},
[navigate, searchParams]
);
return [searchParams, setSearchParams];
}
var fetcherId = 0;
var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
function useSubmit() {
let { router } = useDataRouterContext("useSubmit" /* UseSubmit */);
let { basename } = React.useContext(_chunkIEF7VMTAjs.NavigationContext);
let currentRouteId = _chunkIEF7VMTAjs.useRouteId.call(void 0, );
let routerFetch = router.fetch;
let routerNavigate = router.navigate;
return React.useCallback(
async (target, options = {}) => {
let { action, method, encType, formData, body } = getFormSubmissionInfo(
target,
basename
);
if (options.navigate === false) {
let key = options.fetcherKey || getUniqueFetcherId();
await routerFetch(key, currentRouteId, options.action || action, {
defaultShouldRevalidate: options.defaultShouldRevalidate,
preventScrollReset: options.preventScrollReset,
formData,
body,
formMethod: options.method || method,
formEncType: options.encType || encType,
flushSync: options.flushSync
});
} else {
await routerNavigate(options.action || action, {
defaultShouldRevalidate: options.defaultShouldRevalidate,
preventScrollReset: options.preventScrollReset,
formData,
body,
formMethod: options.method || method,
formEncType: options.encType || encType,
replace: options.replace,
state: options.state,
fromRouteId: currentRouteId,
flushSync: options.flushSync,
viewTransition: options.viewTransition
});
}
},
[routerFetch, routerNavigate, basename, currentRouteId]
);
}
function useFormAction(action, { relative } = {}) {
let { basename } = React.useContext(_chunkIEF7VMTAjs.NavigationContext);
let routeContext = React.useContext(_chunkIEF7VMTAjs.RouteContext);
_chunkIEF7VMTAjs.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
let [match] = routeContext.matches.slice(-1);
let path = { ..._chunkIEF7VMTAjs.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
let location = _chunkIEF7VMTAjs.useLocation.call(void 0, );
if (action == null) {
path.search = location.search;
let params = new URLSearchParams(path.search);
let indexValues = params.getAll("index");
let hasNakedIndexParam = indexValues.some((v) => v === "");
if (hasNakedIndexParam) {
params.delete("index");
indexValues.filter((v) => v).forEach((v) => params.append("index", v));
let qs = params.toString();
path.search = qs ? `?${qs}` : "";
}
}
if ((!action || action === ".") && match.route.index) {
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
}
if (basename !== "/") {
path.pathname = path.pathname === "/" ? basename : _chunkIEF7VMTAjs.joinPaths.call(void 0, [basename, path.pathname]);
}
return _chunkIEF7VMTAjs.createPath.call(void 0, path);
}
function useFetcher({
key
} = {}) {
let { router } = useDataRouterContext("useFetcher" /* UseFetcher */);
let state = useDataRouterState("useFetcher" /* UseFetcher */);
let fetcherData = React.useContext(_chunkIEF7VMTAjs.FetchersContext);
let route = React.useContext(_chunkIEF7VMTAjs.RouteContext);
let routeId = _optionalChain([route, 'access', _24 => _24.matches, 'access', _25 => _25[route.matches.length - 1], 'optionalAccess', _26 => _26.route, 'access', _27 => _27.id]);
_chunkIEF7VMTAjs.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
_chunkIEF7VMTAjs.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
_chunkIEF7VMTAjs.invariant.call(void 0,
routeId != null,
`useFetcher can only be used on routes that contain a unique "id"`
);
let defaultKey = React.useId();
let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
if (key && key !== fetcherKey) {
setFetcherKey(key);
}
let { deleteFetcher, getFetcher, resetFetcher, fetch: routerFetch } = router;
React.useEffect(() => {
getFetcher(fetcherKey);
return () => deleteFetcher(fetcherKey);
}, [deleteFetcher, getFetcher, fetcherKey]);
let load = React.useCallback(
async (href, opts) => {
_chunkIEF7VMTAjs.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
await routerFetch(fetcherKey, routeId, href, opts);
},
[fetcherKey, routeId, routerFetch]
);
let submitImpl = useSubmit();
let submit = React.useCallback(
async (target, opts) => {
await submitImpl(target, {
...opts,
navigate: false,
fetcherKey
});
},
[fetcherKey, submitImpl]
);
let reset = React.useCallback(
(opts) => resetFetcher(fetcherKey, opts),
[resetFetcher, fetcherKey]
);
let FetcherForm = React.useMemo(() => {
let FetcherForm2 = React.forwardRef(
(props, ref) => {
return /* @__PURE__ */ React.createElement(Form, { ...props, navigate: false, fetcherKey, ref });
}
);
FetcherForm2.displayName = "fetcher.Form";
return FetcherForm2;
}, [fetcherKey]);
let fetcher = state.fetchers.get(fetcherKey) || _chunkIEF7VMTAjs.IDLE_FETCHER;
let data = fetcherData.get(fetcherKey);
let fetcherWithComponents = React.useMemo(
() => ({
Form: FetcherForm,
submit,
load,
reset,
...fetcher,
data
}),
[FetcherForm, submit, load, reset, fetcher, data]
);
return fetcherWithComponents;
}
function useFetchers() {
let state = useDataRouterState("useFetchers" /* UseFetchers */);
return React.useMemo(
() => Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
...fetcher,
key
})),
[state.fetchers]
);
}
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
var savedScrollPositions = {};
function getScrollRestorationKey(location, matches, basename, getKey) {
let key = null;
if (getKey) {
if (basename !== "/") {
key = getKey(
{
...location,
pathname: _chunkIEF7VMTAjs.stripBasename.call(void 0, location.pathname, basename) || location.pathname
},
matches
);
} else {
key = getKey(location, matches);
}
}
if (key == null) {
key = location.key;
}
return key;
}
function useScrollRestoration({
getKey,
storageKey
} = {}) {
let { router } = useDataRouterContext("useScrollRestoration" /* UseScrollRestoration */);
let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
"useScrollRestoration" /* UseScrollRestoration */
);
let { basename } = React.useContext(_chunkIEF7VMTAjs.NavigationContext);
let location = _chunkIEF7VMTAjs.useLocation.call(void 0, );
let matches = _chunkIEF7VMTAjs.useMatches.call(void 0, );
let navigation = _chunkIEF7VMTAjs.useNavigation.call(void 0, );
React.useEffect(() => {
window.history.scrollRestoration = "manual";
return () => {
window.history.scrollRestoration = "auto";
};
}, []);
usePageHide(
React.useCallback(() => {
if (navigation.state === "idle") {
let key = getScrollRestorationKey(location, matches, basename, getKey);
savedScrollPositions[key] = window.scrollY;
}
try {
sessionStorage.setItem(
storageKey || SCROLL_RESTORATION_STORAGE_KEY,
JSON.stringify(savedScrollPositions)
);
} catch (error) {
_chunkIEF7VMTAjs.warning.call(void 0,
false,
`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
);
}
window.history.scrollRestoration = "auto";
}, [navigation.state, getKey, basename, location, matches, storageKey])
);
if (typeof document !== "undefined") {
React.useLayoutEffect(() => {
try {
let sessionPositions = sessionStorage.getItem(
storageKey || SCROLL_RESTORATION_STORAGE_KEY
);
if (sessionPositions) {
savedScrollPositions = JSON.parse(sessionPositions);
}
} catch (e) {
}
}, [storageKey]);
React.useLayoutEffect(() => {
let disableScrollRestoration = _optionalChain([router, 'optionalAccess', _28 => _28.enableScrollRestoration, 'call', _29 => _29(
savedScrollPositions,
() => window.scrollY,
getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
)]);
return () => disableScrollRestoration && disableScrollRestoration();
}, [router, basename, getKey]);
React.useLayoutEffect(() => {
if (restoreScrollPosition === false) {
return;
}
if (typeof restoreScrollPosition === "number") {
window.scrollTo(0, restoreScrollPosition);
return;
}
try {
if (location.hash) {
let el = document.getElementById(
decodeURIComponent(location.hash.slice(1))
);
if (el) {
el.scrollIntoView();
return;
}
}
} catch (e2) {
_chunkIEF7VMTAjs.warning.call(void 0,
false,
`"${location.hash.slice(
1
)}" is not a decodable element ID. The view will not scroll to it.`
);
}
if (preventScrollReset === true) {
return;
}
window.scrollTo(0, 0);
}, [location, restoreScrollPosition, preventScrollReset]);
}
}
function useBeforeUnload(callback, options) {
let { capture } = options || {};
React.useEffect(() => {
let opts = capture != null ? { capture } : void 0;
window.addEventListener("beforeunload", callback, opts);
return () => {
window.removeEventListener("beforeunload", callback, opts);
};
}, [callback, capture]);
}
function usePageHide(callback, options) {
let { capture } = options || {};
React.useEffect(() => {
let opts = capture != null ? { capture } : void 0;
window.addEventListener("pagehide", callback, opts);
return () => {
window.removeEventListener("pagehide", callback, opts);
};
}, [callback, capture]);
}
function usePrompt({
when,
message
}) {
let blocker = _chunkIEF7VMTAjs.useBlocker.call(void 0, when);
React.useEffect(() => {
if (blocker.state === "blocked") {
let proceed = window.confirm(message);
if (proceed) {
setTimeout(blocker.proceed, 0);
} else {
blocker.reset();
}
}
}, [blocker, message]);
React.useEffect(() => {
if (blocker.state === "blocked" && !when) {
blocker.reset();
}
}, [blocker, when]);
}
function useViewTransitionState(to, { relative } = {}) {
let vtContext = React.useContext(_chunkIEF7VMTAjs.ViewTransitionContext);
_chunkIEF7VMTAjs.invariant.call(void 0,
vtContext != null,
"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
);
let { basename } = useDataRouterContext(
"useViewTransitionState" /* useViewTransitionState */
);
let path = _chunkIEF7VMTAjs.useResolvedPath.call(void 0, to, { relative });
if (!vtContext.isTransitioning) {
return false;
}
let currentPath = _chunkIEF7VMTAjs.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
let nextPath = _chunkIEF7VMTAjs.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
return _chunkIEF7VMTAjs.matchPath.call(void 0, path.pathname, nextPath) != null || _chunkIEF7VMTAjs.matchPath.call(void 0, path.pathname, currentPath) != null;
}
// lib/dom/server.tsx
function StaticRouter({
basename,
children,
location: locationProp = "/"
}) {
if (typeof locationProp === "string") {
locationProp = _chunkIEF7VMTAjs.parsePath.call(void 0, locationProp);
}
let action = "POP" /* Pop */;
let location = {
pathname: locationProp.pathname || "/",
search: locationProp.search || "",
hash: locationProp.hash || "",
state: locationProp.state != null ? locationProp.state : null,
key: locationProp.key || "default",
mask: void 0
};
let staticNavigator = getStatelessNavigator();
return /* @__PURE__ */ React2.createElement(
_chunkIEF7VMTAjs.Router,
{
basename,
children,
location,
navigationType: action,
navigator: staticNavigator,
static: true,
useTransitions: false
}
);
}
function StaticRouterProvider({
context,
router,
hydrate = true,
nonce
}) {
_chunkIEF7VMTAjs.invariant.call(void 0,
router && context,
"You must provide `router` and `context` to <StaticRouterProvider>"
);
let dataRouterContext = {
router,
navigator: getStatelessNavigator(),
static: true,
staticContext: context,
basename: context.basename || "/"
};
let fetchersContext = /* @__PURE__ */ new Map();
let hydrateScript = "";
if (hydrate !== false) {
let data = {
loaderData: context.loaderData,
actionData: context.actionData,
errors: serializeErrors(context.errors)
};
let json = _chunkIEF7VMTAjs.escapeHtml.call(void 0, JSON.stringify(JSON.stringify(data)));
hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
}
let { state } = dataRouterContext.router;
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(_chunkIEF7VMTAjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React2.createElement(_chunkIEF7VMTAjs.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React2.createElement(_chunkIEF7VMTAjs.FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React2.createElement(_chunkIEF7VMTAjs.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React2.createElement(
_chunkIEF7VMTAjs.Router,
{
basename: dataRouterContext.basename,
location: state.location,
navigationType: state.historyAction,
navigator: dataRouterContext.navigator,
static: dataRouterContext.static,
useTransitions: false
},
/* @__PURE__ */ React2.createElement(
_chunkIEF7VMTAjs.DataRoutes,
{
manifest: router.manifest,
routes: router.routes,
future: router.future,
state,
isStatic: true
}
)
))))), hydrateScript ? /* @__PURE__ */ React2.createElement(
"script",
{
suppressHydrationWarning: true,
nonce,
dangerouslySetInnerHTML: { __html: hydrateScript }
}
) : null);
}
function serializeErrors(errors) {
if (!errors) return null;
let entries = Object.entries(errors);
let serialized = {};
for (let [key, val] of entries) {
if (_chunkIEF7VMTAjs.isRouteErrorResponse.call(void 0, val)) {
serialized[key] = { ...val, __type: "RouteErrorResponse" };
} else if (val instanceof Error) {
serialized[key] = {
message: val.message,
__type: "Error",
// If this is a subclass (i.e., ReferenceError), send up the type so we
// can re-create the same type during hydration.
...val.name !== "Error" ? {
__subType: val.name
} : {}
};
} else {
serialized[key] = val;
}
}
return serialized;
}
function getStatelessNavigator() {
return {
createHref,
encodeLocation,
push(to) {
throw new Error(
`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.`
);
},
replace(to) {
throw new Error(
`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.`
);
},
go(delta) {
throw new Error(
`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.`
);
},
back() {
throw new Error(
`You cannot use navigator.back() on the server because it is a stateless environment.`
);
},
forward() {
throw new Error(
`You cannot use navigator.forward() on the server because it is a stateless environment.`
);
}
};
}
function createStaticHandler2(routes, opts) {
return _chunkIEF7VMTAjs.createStaticHandler.call(void 0, routes, {
...opts,
mapRouteProperties: _chunkIEF7VMTAjs.mapRouteProperties
});
}
function createStaticRouter(routes, context, opts = {}) {
let manifest = {};
let dataRoutes = _chunkIEF7VMTAjs.convertRoutesToDataRoutes.call(void 0,
routes,
_chunkIEF7VMTAjs.mapRouteProperties,
void 0,
manifest
);
let matches = context.matches.map((match) => {
let route = manifest[match.route.id] || match.route;
return {
...match,
route
};
});
let msg = (method) => `You cannot use router.${method}() on the server because it is a stateless environment`;
return {
get basename() {
return context.basename;
},
get future() {
return {
v8_middleware: false,
v8_passThroughRequests: false,
v8_trailingSlashAwareDataRequests: false,
..._optionalChain([opts, 'optionalAccess', _30 => _30.future])
};
},
get state() {
return {
historyAction: "POP" /* Pop */,
location: context.location,
matches,
loaderData: context.loaderData,
actionData: context.actionData,
errors: context.errors,
initialized: true,
renderFallback: false,
navigation: _chunkIEF7VMTAjs.IDLE_NAVIGATION,
restoreScrollPosition: null,
preventScrollReset: false,
revalidation: "idle",
fetchers: /* @__PURE__ */ new Map(),
blockers: /* @__PURE__ */ new Map()
};
},
get routes() {
return dataRoutes;
},
get branches() {
return opts.branches;
},
get manifest() {
return manifest;
},
get window() {
return void 0;
},
initialize() {
throw msg("initialize");
},
subscribe() {
throw msg("subscribe");
},
enableScrollRestoration() {
throw msg("enableScrollRestoration");
},
navigate() {
throw msg("navigate");
},
fetch() {
throw msg("fetch");
},
revalidate() {
throw msg("revalidate");
},
createHref,
encodeLocation,
getFetcher() {
return _chunkIEF7VMTAjs.IDLE_FETCHER;
},
deleteFetcher() {
throw msg("deleteFetcher");
},
resetFetcher() {
throw msg("resetFetcher");
},
dispose() {
throw msg("dispose");
},
getBlocker() {
return _chunkIEF7VMTAjs.IDLE_BLOCKER;
},
deleteBlocker() {
throw msg("deleteBlocker");
},
patchRoutes() {
throw msg("patchRoutes");
},
_internalFetchControllers: /* @__PURE__ */ new Map(),
_internalSetRoutes() {
throw msg("_internalSetRoutes");
},
_internalSetStateDoNotUseOrYouWillBreakYourApp() {
throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
}
};
}
function createHref(to) {
return typeof to === "string" ? to : _chunkIEF7VMTAjs.createPath.call(void 0, to);
}
function encodeLocation(to) {
let href = typeof to === "string" ? to : _chunkIEF7VMTAjs.createPath.call(void 0, to);
href = href.replace(/ $/, "%20");
let encoded = _chunkIEF7VMTAjs.ABSOLUTE_URL_REGEX.test(href) ? new URL(href) : new URL(href, "http://localhost");
return {
pathname: encoded.pathname,
search: encoded.search,
hash: encoded.hash
};
}
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;
+32
-32
"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 _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -16,3 +16,3 @@ * Copyright (c) Remix Software Inc.

var _chunkWW7PN6QIjs = require('./chunk-WW7PN6QI.js');
var _chunkEVX4J2F5js = require('./chunk-EVX4J2F5.js');

@@ -41,3 +41,3 @@

var _chunkU7ORXROYjs = require('./chunk-U7ORXROY.js');
var _chunkSA4DP3SFjs = require('./chunk-SA4DP3SF.js');

@@ -218,3 +218,3 @@ // lib/dom-export/dom-router-provider.tsx

if (process.env.NODE_ENV === "development" && criticalCss === void 0) {
document.querySelectorAll(`[${_chunkU7ORXROYjs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
document.querySelectorAll(`[${_chunkSA4DP3SFjs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
}

@@ -314,3 +314,3 @@ }, [criticalCss]);

if (payload.reload || isExternalLocation(location2)) {
if (_chunkU7ORXROYjs.hasInvalidProtocol.call(void 0, location2)) {
if (_chunkSA4DP3SFjs.hasInvalidProtocol.call(void 0, location2)) {
throw new Error("Invalid redirect location");

@@ -336,3 +336,3 @@ }

if (rerender.reload || isExternalLocation(location2)) {
if (_chunkU7ORXROYjs.hasInvalidProtocol.call(void 0, location2)) {
if (_chunkSA4DP3SFjs.hasInvalidProtocol.call(void 0, location2)) {
throw new Error("Invalid redirect location");

@@ -402,3 +402,3 @@ }

globalVar.__reactRouterRouteModules = _nullishCoalesce(globalVar.__reactRouterRouteModules, () => ( {}));
_chunkWW7PN6QIjs.populateRSCRouteModules.call(void 0, globalVar.__reactRouterRouteModules, payload.matches);
_chunkEVX4J2F5js.populateRSCRouteModules.call(void 0, globalVar.__reactRouterRouteModules, payload.matches);
let routes = payload.matches.reduceRight((previous, match) => {

@@ -417,8 +417,8 @@ const route = createRouteFromServerManifest(

let applyPatchesPromise;
globalVar.__reactRouterDataRouter = _chunkU7ORXROYjs.createRouter.call(void 0, {
globalVar.__reactRouterDataRouter = _chunkSA4DP3SFjs.createRouter.call(void 0, {
routes,
getContext,
basename: payload.basename,
history: _chunkU7ORXROYjs.createBrowserHistory.call(void 0, ),
hydrationData: _chunkWW7PN6QIjs.getHydrationData.call(void 0, {
history: _chunkSA4DP3SFjs.createBrowserHistory.call(void 0, ),
hydrationData: _chunkEVX4J2F5js.getHydrationData.call(void 0, {
state: {

@@ -432,3 +432,3 @@ loaderData: payload.loaderData,

let match = payload.matches.find((m) => m.id === routeId);
_chunkU7ORXROYjs.invariant.call(void 0, match, "Route not found in payload");
_chunkSA4DP3SFjs.invariant.call(void 0, match, "Route not found in payload");
return {

@@ -548,5 +548,5 @@ clientLoader: match.clientLoader,

}
var renderedRoutesContext = _chunkU7ORXROYjs.createContext.call(void 0, );
var renderedRoutesContext = _chunkSA4DP3SFjs.createContext.call(void 0, );
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
let dataStrategy = _chunkU7ORXROYjs.getSingleFetchDataStrategyImpl.call(void 0,
let dataStrategy = _chunkSA4DP3SFjs.getSingleFetchDataStrategyImpl.call(void 0,
getRouter,

@@ -608,5 +608,5 @@ (match) => {

let { request, context } = args;
let url = _chunkU7ORXROYjs.singleFetchUrl.call(void 0, request.url, basename, trailingSlashAware, "rsc");
let url = _chunkSA4DP3SFjs.singleFetchUrl.call(void 0, request.url, basename, trailingSlashAware, "rsc");
if (request.method === "GET") {
url = _chunkU7ORXROYjs.stripIndexParam.call(void 0, url);
url = _chunkSA4DP3SFjs.stripIndexParam.call(void 0, url);
if (targetRoutes) {

@@ -617,8 +617,8 @@ url.searchParams.set("_routes", targetRoutes.join(","));

let res = await fetchImplementation(
new Request(url, await _chunkU7ORXROYjs.createRequestInit.call(void 0, request))
new Request(url, await _chunkSA4DP3SFjs.createRequestInit.call(void 0, request))
);
if (res.status >= 400 && !res.headers.has("X-Remix-Response")) {
throw new (0, _chunkU7ORXROYjs.ErrorResponseImpl)(res.status, res.statusText, await res.text());
throw new (0, _chunkSA4DP3SFjs.ErrorResponseImpl)(res.status, res.statusText, await res.text());
}
_chunkU7ORXROYjs.invariant.call(void 0, res.body, "No response body to decode");
_chunkSA4DP3SFjs.invariant.call(void 0, res.body, "No response body to decode");
try {

@@ -647,3 +647,3 @@ const payload = await createFromReadableStream(res.body, {

let results = { routes: {} };
const dataKey = _chunkU7ORXROYjs.isMutationMethod.call(void 0, request.method) ? "actionData" : "loaderData";
const dataKey = _chunkSA4DP3SFjs.isMutationMethod.call(void 0, request.method) ? "actionData" : "loaderData";
for (let [routeId, data] of Object.entries(payload[dataKey] || {})) {

@@ -681,3 +681,3 @@ results.routes[routeId] = { data };

React3.useEffect(() => {
_chunkU7ORXROYjs.setIsHydrated.call(void 0, );
_chunkSA4DP3SFjs.setIsHydrated.call(void 0, );
}, []);

@@ -790,4 +790,4 @@ React3.useLayoutEffect(() => {

};
return /* @__PURE__ */ React3.createElement(_chunkU7ORXROYjs.RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React3.createElement(_chunkWW7PN6QIjs.RSCRouterGlobalErrorBoundary, { location: state.location }, /* @__PURE__ */ React3.createElement(_chunkU7ORXROYjs.FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React3.createElement(
_chunkU7ORXROYjs.RouterProvider,
return /* @__PURE__ */ React3.createElement(_chunkSA4DP3SFjs.RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React3.createElement(_chunkEVX4J2F5js.RSCRouterGlobalErrorBoundary, { location: state.location }, /* @__PURE__ */ React3.createElement(_chunkSA4DP3SFjs.FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React3.createElement(
_chunkSA4DP3SFjs.RouterProvider,
{

@@ -808,4 +808,4 @@ router: transitionEnabledRouter,

match.hasComponent && !match.element;
_chunkU7ORXROYjs.invariant.call(void 0, window.__reactRouterRouteModules);
_chunkWW7PN6QIjs.populateRSCRouteModules.call(void 0, window.__reactRouterRouteModules, match);
_chunkSA4DP3SFjs.invariant.call(void 0, window.__reactRouterRouteModules);
_chunkEVX4J2F5js.populateRSCRouteModules.call(void 0, window.__reactRouterRouteModules, match);
let dataRoute = {

@@ -858,3 +858,3 @@ id: match.id,

}) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : () => {
throw _chunkU7ORXROYjs.noActionDefinedError.call(void 0, "action", match.id);
throw _chunkSA4DP3SFjs.noActionDefinedError.call(void 0, "action", match.id);
},

@@ -871,3 +871,3 @@ path: match.path,

if (typeof dataRoute.loader === "function") {
dataRoute.loader.hydrate = _chunkU7ORXROYjs.shouldHydrateRouteLoader.call(void 0,
dataRoute.loader.hydrate = _chunkSA4DP3SFjs.shouldHydrateRouteLoader.call(void 0,
match.id,

@@ -882,3 +882,3 @@ match.clientLoader,

function callSingleFetch(singleFetch) {
_chunkU7ORXROYjs.invariant.call(void 0, typeof singleFetch === "function", "Invalid singleFetch parameter");
_chunkSA4DP3SFjs.invariant.call(void 0, typeof singleFetch === "function", "Invalid singleFetch parameter");
return singleFetch();

@@ -891,3 +891,3 @@ }

console.error(msg);
throw new (0, _chunkU7ORXROYjs.ErrorResponseImpl)(400, "Bad Request", new Error(msg), true);
throw new (0, _chunkSA4DP3SFjs.ErrorResponseImpl)(400, "Bad Request", new Error(msg), true);
}

@@ -915,3 +915,3 @@ }

async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fetchImplementation, signal) {
paths = _chunkU7ORXROYjs.getPathsWithAncestors.call(void 0, paths);
paths = _chunkSA4DP3SFjs.getPathsWithAncestors.call(void 0, paths);
let url = getManifestUrl(paths);

@@ -921,3 +921,3 @@ if (url == null) {

}
if (url.toString().length > _chunkU7ORXROYjs.URL_LIMIT) {
if (url.toString().length > _chunkSA4DP3SFjs.URL_LIMIT) {
nextPaths.clear();

@@ -966,4 +966,4 @@ return;

function normalizeRedirectLocation(location2) {
if (_chunkU7ORXROYjs.PROTOCOL_RELATIVE_URL_REGEX.test(location2)) {
let path = _chunkU7ORXROYjs.resolvePath.call(void 0, location2);
if (_chunkSA4DP3SFjs.PROTOCOL_RELATIVE_URL_REGEX.test(location2)) {
let path = _chunkSA4DP3SFjs.resolvePath.call(void 0, location2);
return path.pathname + path.search + path.hash;

@@ -970,0 +970,0 @@ }

/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -16,3 +16,3 @@ * Copyright (c) Remix Software Inc.

populateRSCRouteModules
} from "./chunk-E4MTK73K.mjs";
} from "./chunk-IJF3QNGC.mjs";
import {

@@ -50,3 +50,3 @@ CRITICAL_CSS_DATA_ATTRIBUTE,

useFogOFWarDiscovery
} from "./chunk-4ZMWKKQ3.mjs";
} from "./chunk-KS7C4IRE.mjs";

@@ -53,0 +53,0 @@ // lib/dom-export/dom-router-provider.tsx

"use strict";Object.defineProperty(exports, "__esModule", {value: true});/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -22,3 +22,3 @@ * Copyright (c) Remix Software Inc.

var _chunkYL5M26XIjs = require('./chunk-YL5M26XI.js');
var _chunkG5KIBF6Ujs = require('./chunk-G5KIBF6U.js');

@@ -38,3 +38,3 @@

var _chunkU7ORXROYjs = require('./chunk-U7ORXROY.js');
var _chunkSA4DP3SFjs = require('./chunk-SA4DP3SF.js');

@@ -63,2 +63,2 @@

exports.BrowserRouter = _chunkYL5M26XIjs.BrowserRouter; exports.Form = _chunkYL5M26XIjs.Form; exports.HashRouter = _chunkYL5M26XIjs.HashRouter; exports.Link = _chunkYL5M26XIjs.Link; exports.Links = _chunkU7ORXROYjs.Links; exports.MemoryRouter = _chunkU7ORXROYjs.MemoryRouter; exports.Meta = _chunkU7ORXROYjs.Meta; exports.NavLink = _chunkYL5M26XIjs.NavLink; exports.Navigate = _chunkU7ORXROYjs.Navigate; exports.Outlet = _chunkU7ORXROYjs.Outlet; exports.Route = _chunkU7ORXROYjs.Route; exports.Router = _chunkU7ORXROYjs.Router; exports.RouterProvider = _chunkU7ORXROYjs.RouterProvider; exports.Routes = _chunkU7ORXROYjs.Routes; exports.ScrollRestoration = _chunkYL5M26XIjs.ScrollRestoration; exports.StaticRouter = _chunkYL5M26XIjs.StaticRouter; exports.StaticRouterProvider = _chunkYL5M26XIjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkU7ORXROYjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkU7ORXROYjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkU7ORXROYjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkU7ORXROYjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkYL5M26XIjs.HistoryRouter;
exports.BrowserRouter = _chunkG5KIBF6Ujs.BrowserRouter; exports.Form = _chunkG5KIBF6Ujs.Form; exports.HashRouter = _chunkG5KIBF6Ujs.HashRouter; exports.Link = _chunkG5KIBF6Ujs.Link; exports.Links = _chunkSA4DP3SFjs.Links; exports.MemoryRouter = _chunkSA4DP3SFjs.MemoryRouter; exports.Meta = _chunkSA4DP3SFjs.Meta; exports.NavLink = _chunkG5KIBF6Ujs.NavLink; exports.Navigate = _chunkSA4DP3SFjs.Navigate; exports.Outlet = _chunkSA4DP3SFjs.Outlet; exports.Route = _chunkSA4DP3SFjs.Route; exports.Router = _chunkSA4DP3SFjs.Router; exports.RouterProvider = _chunkSA4DP3SFjs.RouterProvider; exports.Routes = _chunkSA4DP3SFjs.Routes; exports.ScrollRestoration = _chunkG5KIBF6Ujs.ScrollRestoration; exports.StaticRouter = _chunkG5KIBF6Ujs.StaticRouter; exports.StaticRouterProvider = _chunkG5KIBF6Ujs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkSA4DP3SFjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkSA4DP3SFjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkSA4DP3SFjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkSA4DP3SFjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkG5KIBF6Ujs.HistoryRouter;
/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -35,3 +35,3 @@ * Copyright (c) Remix Software Inc.

WithHydrateFallbackProps
} from "./chunk-4ZMWKKQ3.mjs";
} from "./chunk-KS7C4IRE.mjs";
export {

@@ -38,0 +38,0 @@ BrowserRouter,

/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -30,3 +30,3 @@ * Copyright (c) Remix Software Inc.

setDevServerHooks
} from "./chunk-E4MTK73K.mjs";
} from "./chunk-IJF3QNGC.mjs";
import {

@@ -145,3 +145,3 @@ Action,

withHydrateFallbackProps
} from "./chunk-4ZMWKKQ3.mjs";
} from "./chunk-KS7C4IRE.mjs";
export {

@@ -148,0 +148,0 @@ Await,

"use strict";/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc.

/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc.

"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 _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; }/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -16,3 +16,3 @@ * Copyright (c) Remix Software Inc.

var _chunk3Z6WS2WZjs = require('./chunk-3Z6WS2WZ.js');
var _chunkGOIER6MLjs = require('./chunk-GOIER6ML.js');

@@ -41,3 +41,3 @@

var _chunkIUPBOWYOjs = require('./chunk-IUPBOWYO.js');
var _chunkIEF7VMTAjs = require('./chunk-IEF7VMTA.js');

@@ -218,3 +218,3 @@ // lib/dom-export/dom-router-provider.tsx

if (process.env.NODE_ENV === "development" && criticalCss === void 0) {
document.querySelectorAll(`[${_chunkIUPBOWYOjs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
document.querySelectorAll(`[${_chunkIEF7VMTAjs.CRITICAL_CSS_DATA_ATTRIBUTE}]`).forEach((element) => element.remove());
}

@@ -314,3 +314,3 @@ }, [criticalCss]);

if (payload.reload || isExternalLocation(location2)) {
if (_chunkIUPBOWYOjs.hasInvalidProtocol.call(void 0, location2)) {
if (_chunkIEF7VMTAjs.hasInvalidProtocol.call(void 0, location2)) {
throw new Error("Invalid redirect location");

@@ -336,3 +336,3 @@ }

if (rerender.reload || isExternalLocation(location2)) {
if (_chunkIUPBOWYOjs.hasInvalidProtocol.call(void 0, location2)) {
if (_chunkIEF7VMTAjs.hasInvalidProtocol.call(void 0, location2)) {
throw new Error("Invalid redirect location");

@@ -402,3 +402,3 @@ }

globalVar.__reactRouterRouteModules = _nullishCoalesce(globalVar.__reactRouterRouteModules, () => ( {}));
_chunk3Z6WS2WZjs.populateRSCRouteModules.call(void 0, globalVar.__reactRouterRouteModules, payload.matches);
_chunkGOIER6MLjs.populateRSCRouteModules.call(void 0, globalVar.__reactRouterRouteModules, payload.matches);
let routes = payload.matches.reduceRight((previous, match) => {

@@ -417,8 +417,8 @@ const route = createRouteFromServerManifest(

let applyPatchesPromise;
globalVar.__reactRouterDataRouter = _chunkIUPBOWYOjs.createRouter.call(void 0, {
globalVar.__reactRouterDataRouter = _chunkIEF7VMTAjs.createRouter.call(void 0, {
routes,
getContext,
basename: payload.basename,
history: _chunkIUPBOWYOjs.createBrowserHistory.call(void 0, ),
hydrationData: _chunk3Z6WS2WZjs.getHydrationData.call(void 0, {
history: _chunkIEF7VMTAjs.createBrowserHistory.call(void 0, ),
hydrationData: _chunkGOIER6MLjs.getHydrationData.call(void 0, {
state: {

@@ -432,3 +432,3 @@ loaderData: payload.loaderData,

let match = payload.matches.find((m) => m.id === routeId);
_chunkIUPBOWYOjs.invariant.call(void 0, match, "Route not found in payload");
_chunkIEF7VMTAjs.invariant.call(void 0, match, "Route not found in payload");
return {

@@ -548,5 +548,5 @@ clientLoader: match.clientLoader,

}
var renderedRoutesContext = _chunkIUPBOWYOjs.createContext.call(void 0, );
var renderedRoutesContext = _chunkIEF7VMTAjs.createContext.call(void 0, );
function getRSCSingleFetchDataStrategy(getRouter, ssr, basename, createFromReadableStream, fetchImplementation) {
let dataStrategy = _chunkIUPBOWYOjs.getSingleFetchDataStrategyImpl.call(void 0,
let dataStrategy = _chunkIEF7VMTAjs.getSingleFetchDataStrategyImpl.call(void 0,
getRouter,

@@ -608,5 +608,5 @@ (match) => {

let { request, context } = args;
let url = _chunkIUPBOWYOjs.singleFetchUrl.call(void 0, request.url, basename, trailingSlashAware, "rsc");
let url = _chunkIEF7VMTAjs.singleFetchUrl.call(void 0, request.url, basename, trailingSlashAware, "rsc");
if (request.method === "GET") {
url = _chunkIUPBOWYOjs.stripIndexParam.call(void 0, url);
url = _chunkIEF7VMTAjs.stripIndexParam.call(void 0, url);
if (targetRoutes) {

@@ -617,8 +617,8 @@ url.searchParams.set("_routes", targetRoutes.join(","));

let res = await fetchImplementation(
new Request(url, await _chunkIUPBOWYOjs.createRequestInit.call(void 0, request))
new Request(url, await _chunkIEF7VMTAjs.createRequestInit.call(void 0, request))
);
if (res.status >= 400 && !res.headers.has("X-Remix-Response")) {
throw new (0, _chunkIUPBOWYOjs.ErrorResponseImpl)(res.status, res.statusText, await res.text());
throw new (0, _chunkIEF7VMTAjs.ErrorResponseImpl)(res.status, res.statusText, await res.text());
}
_chunkIUPBOWYOjs.invariant.call(void 0, res.body, "No response body to decode");
_chunkIEF7VMTAjs.invariant.call(void 0, res.body, "No response body to decode");
try {

@@ -647,3 +647,3 @@ const payload = await createFromReadableStream(res.body, {

let results = { routes: {} };
const dataKey = _chunkIUPBOWYOjs.isMutationMethod.call(void 0, request.method) ? "actionData" : "loaderData";
const dataKey = _chunkIEF7VMTAjs.isMutationMethod.call(void 0, request.method) ? "actionData" : "loaderData";
for (let [routeId, data] of Object.entries(payload[dataKey] || {})) {

@@ -681,3 +681,3 @@ results.routes[routeId] = { data };

React3.useEffect(() => {
_chunkIUPBOWYOjs.setIsHydrated.call(void 0, );
_chunkIEF7VMTAjs.setIsHydrated.call(void 0, );
}, []);

@@ -790,4 +790,4 @@ React3.useLayoutEffect(() => {

};
return /* @__PURE__ */ React3.createElement(_chunkIUPBOWYOjs.RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React3.createElement(_chunk3Z6WS2WZjs.RSCRouterGlobalErrorBoundary, { location: state.location }, /* @__PURE__ */ React3.createElement(_chunkIUPBOWYOjs.FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React3.createElement(
_chunkIUPBOWYOjs.RouterProvider,
return /* @__PURE__ */ React3.createElement(_chunkIEF7VMTAjs.RSCRouterContext.Provider, { value: true }, /* @__PURE__ */ React3.createElement(_chunkGOIER6MLjs.RSCRouterGlobalErrorBoundary, { location: state.location }, /* @__PURE__ */ React3.createElement(_chunkIEF7VMTAjs.FrameworkContext.Provider, { value: frameworkContext }, /* @__PURE__ */ React3.createElement(
_chunkIEF7VMTAjs.RouterProvider,
{

@@ -808,4 +808,4 @@ router: transitionEnabledRouter,

match.hasComponent && !match.element;
_chunkIUPBOWYOjs.invariant.call(void 0, window.__reactRouterRouteModules);
_chunk3Z6WS2WZjs.populateRSCRouteModules.call(void 0, window.__reactRouterRouteModules, match);
_chunkIEF7VMTAjs.invariant.call(void 0, window.__reactRouterRouteModules);
_chunkGOIER6MLjs.populateRSCRouteModules.call(void 0, window.__reactRouterRouteModules, match);
let dataRoute = {

@@ -858,3 +858,3 @@ id: match.id,

}) : match.hasAction ? (_, singleFetch) => callSingleFetch(singleFetch) : () => {
throw _chunkIUPBOWYOjs.noActionDefinedError.call(void 0, "action", match.id);
throw _chunkIEF7VMTAjs.noActionDefinedError.call(void 0, "action", match.id);
},

@@ -871,3 +871,3 @@ path: match.path,

if (typeof dataRoute.loader === "function") {
dataRoute.loader.hydrate = _chunkIUPBOWYOjs.shouldHydrateRouteLoader.call(void 0,
dataRoute.loader.hydrate = _chunkIEF7VMTAjs.shouldHydrateRouteLoader.call(void 0,
match.id,

@@ -882,3 +882,3 @@ match.clientLoader,

function callSingleFetch(singleFetch) {
_chunkIUPBOWYOjs.invariant.call(void 0, typeof singleFetch === "function", "Invalid singleFetch parameter");
_chunkIEF7VMTAjs.invariant.call(void 0, typeof singleFetch === "function", "Invalid singleFetch parameter");
return singleFetch();

@@ -891,3 +891,3 @@ }

console.error(msg);
throw new (0, _chunkIUPBOWYOjs.ErrorResponseImpl)(400, "Bad Request", new Error(msg), true);
throw new (0, _chunkIEF7VMTAjs.ErrorResponseImpl)(400, "Bad Request", new Error(msg), true);
}

@@ -915,3 +915,3 @@ }

async function fetchAndApplyManifestPatches(paths, createFromReadableStream, fetchImplementation, signal) {
paths = _chunkIUPBOWYOjs.getPathsWithAncestors.call(void 0, paths);
paths = _chunkIEF7VMTAjs.getPathsWithAncestors.call(void 0, paths);
let url = getManifestUrl(paths);

@@ -921,3 +921,3 @@ if (url == null) {

}
if (url.toString().length > _chunkIUPBOWYOjs.URL_LIMIT) {
if (url.toString().length > _chunkIEF7VMTAjs.URL_LIMIT) {
nextPaths.clear();

@@ -966,4 +966,4 @@ return;

function normalizeRedirectLocation(location2) {
if (_chunkIUPBOWYOjs.PROTOCOL_RELATIVE_URL_REGEX.test(location2)) {
let path = _chunkIUPBOWYOjs.resolvePath.call(void 0, location2);
if (_chunkIEF7VMTAjs.PROTOCOL_RELATIVE_URL_REGEX.test(location2)) {
let path = _chunkIEF7VMTAjs.resolvePath.call(void 0, location2);
return path.pathname + path.search + path.hash;

@@ -970,0 +970,0 @@ }

/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -16,3 +16,3 @@ * Copyright (c) Remix Software Inc.

populateRSCRouteModules
} from "./chunk-EGOTSXNH.mjs";
} from "./chunk-3MA7PLKB.mjs";
import {

@@ -50,3 +50,3 @@ CRITICAL_CSS_DATA_ATTRIBUTE,

useFogOFWarDiscovery
} from "./chunk-M7NGGUU6.mjs";
} from "./chunk-3WDNQUW5.mjs";

@@ -53,0 +53,0 @@ // lib/dom-export/dom-router-provider.tsx

"use strict";Object.defineProperty(exports, "__esModule", {value: true});/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -22,3 +22,3 @@ * Copyright (c) Remix Software Inc.

var _chunkBIP66BKVjs = require('./chunk-BIP66BKV.js');
var _chunkWICLSFKLjs = require('./chunk-WICLSFKL.js');

@@ -38,3 +38,3 @@

var _chunkIUPBOWYOjs = require('./chunk-IUPBOWYO.js');
var _chunkIEF7VMTAjs = require('./chunk-IEF7VMTA.js');

@@ -63,2 +63,2 @@

exports.BrowserRouter = _chunkBIP66BKVjs.BrowserRouter; exports.Form = _chunkBIP66BKVjs.Form; exports.HashRouter = _chunkBIP66BKVjs.HashRouter; exports.Link = _chunkBIP66BKVjs.Link; exports.Links = _chunkIUPBOWYOjs.Links; exports.MemoryRouter = _chunkIUPBOWYOjs.MemoryRouter; exports.Meta = _chunkIUPBOWYOjs.Meta; exports.NavLink = _chunkBIP66BKVjs.NavLink; exports.Navigate = _chunkIUPBOWYOjs.Navigate; exports.Outlet = _chunkIUPBOWYOjs.Outlet; exports.Route = _chunkIUPBOWYOjs.Route; exports.Router = _chunkIUPBOWYOjs.Router; exports.RouterProvider = _chunkIUPBOWYOjs.RouterProvider; exports.Routes = _chunkIUPBOWYOjs.Routes; exports.ScrollRestoration = _chunkBIP66BKVjs.ScrollRestoration; exports.StaticRouter = _chunkBIP66BKVjs.StaticRouter; exports.StaticRouterProvider = _chunkBIP66BKVjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkIUPBOWYOjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkIUPBOWYOjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkIUPBOWYOjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkIUPBOWYOjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkBIP66BKVjs.HistoryRouter;
exports.BrowserRouter = _chunkWICLSFKLjs.BrowserRouter; exports.Form = _chunkWICLSFKLjs.Form; exports.HashRouter = _chunkWICLSFKLjs.HashRouter; exports.Link = _chunkWICLSFKLjs.Link; exports.Links = _chunkIEF7VMTAjs.Links; exports.MemoryRouter = _chunkIEF7VMTAjs.MemoryRouter; exports.Meta = _chunkIEF7VMTAjs.Meta; exports.NavLink = _chunkWICLSFKLjs.NavLink; exports.Navigate = _chunkIEF7VMTAjs.Navigate; exports.Outlet = _chunkIEF7VMTAjs.Outlet; exports.Route = _chunkIEF7VMTAjs.Route; exports.Router = _chunkIEF7VMTAjs.Router; exports.RouterProvider = _chunkIEF7VMTAjs.RouterProvider; exports.Routes = _chunkIEF7VMTAjs.Routes; exports.ScrollRestoration = _chunkWICLSFKLjs.ScrollRestoration; exports.StaticRouter = _chunkWICLSFKLjs.StaticRouter; exports.StaticRouterProvider = _chunkWICLSFKLjs.StaticRouterProvider; exports.UNSAFE_AwaitContextProvider = _chunkIEF7VMTAjs.AwaitContextProvider; exports.UNSAFE_WithComponentProps = _chunkIEF7VMTAjs.WithComponentProps; exports.UNSAFE_WithErrorBoundaryProps = _chunkIEF7VMTAjs.WithErrorBoundaryProps; exports.UNSAFE_WithHydrateFallbackProps = _chunkIEF7VMTAjs.WithHydrateFallbackProps; exports.unstable_HistoryRouter = _chunkWICLSFKLjs.HistoryRouter;
/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -35,3 +35,3 @@ * Copyright (c) Remix Software Inc.

WithHydrateFallbackProps
} from "./chunk-M7NGGUU6.mjs";
} from "./chunk-3WDNQUW5.mjs";
export {

@@ -38,0 +38,0 @@ BrowserRouter,

/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -30,3 +30,3 @@ * Copyright (c) Remix Software Inc.

setDevServerHooks
} from "./chunk-EGOTSXNH.mjs";
} from "./chunk-3MA7PLKB.mjs";
import {

@@ -145,3 +145,3 @@ Action,

withHydrateFallbackProps
} from "./chunk-M7NGGUU6.mjs";
} from "./chunk-3WDNQUW5.mjs";
export {

@@ -148,0 +148,0 @@ Await,

"use strict";/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc.

/**
* react-router v7.18.0
* react-router v7.18.1
*

@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc.

@@ -57,3 +57,3 @@ ---

// throw to ErrorBoundary
throw data(null, { status: 404 });
throw data("Not Found", { status: 404 });
}

@@ -60,0 +60,0 @@ return project;

---
title: Future Flags
title: Future Changes
order: 1
---
# Future Flags and Deprecations
# Future Changes
This guide walks you through the process of adopting future flags in your React Router app. By following this strategy, you will be able to upgrade to the next major version of React Router with minimal changes. To read more about future flags see [API Development Strategy][api-development-strategy].
We try our best to keep major version upgrades simple and boring through the use of opt-in APIs and [Future Flags][api-development-strategy]. Future flags are used to gate breaking changes that don't otherwise have a good call-site opt-in strategy. By adopting all opt-in APIs and future flags, you should be able to upgrade to the next major version of React Router with minimal changes.
We highly recommend you make a commit after each step and ship it instead of doing everything all at once. Most flags can be adopted in any order, with exceptions noted below.
## Minimum Versions
[MODES: framework, data, declarative]
<br/>
<br/>
React Router v8 will require the following minimum versions. You can prepare for the upgrade by updating them while still on v7:
- `node@22.22+`
- `react@19.2.7+`/`react-dom@19.2.7+`
Framework mode will also require:
- `vite@7+` (requires `future.v8_viteEnvironmentApi`)
- also make sure any custom Vite plugins or config are compatible with Vite 7.
## Update to latest v7.x
First update to the latest minor version of v7.x to have the latest future flags. You may see a number of deprecation warnings as you upgrade, which we'll cover below.
Before adopting any future flags or call-site opt-in changes, you should update to the latest minor version of v7.x to make sure you have access to the latest flags. You may see a number of deprecation warnings as you upgrade, which we'll cover below.

@@ -22,4 +39,6 @@ 👉 Update to latest v7

## `future.v8_middleware`
## Future Flags
### `future.v8_middleware`
[MODES: framework, data]

@@ -51,3 +70,3 @@

```ts
import { createBrowserRouter } from "react-router/dom";
import { createBrowserRouter } from "react-router";

@@ -68,3 +87,3 @@ const router = createBrowserRouter(routes, {

## `future.v8_splitRouteModules`
### `future.v8_splitRouteModules`

@@ -98,3 +117,3 @@ [MODES: framework]

## `future.v8_viteEnvironmentApi`
### `future.v8_viteEnvironmentApi`

@@ -157,3 +176,3 @@ [MODES: framework]

## `future.v8_passThroughRequests`
### `future.v8_passThroughRequests`

@@ -221,3 +240,3 @@ [MODES: framework]

## `future.v8_trailingSlashAwareDataRequests`
### `future.v8_trailingSlashAwareDataRequests`

@@ -275,8 +294,198 @@ [MODES: framework]

## Other Planned Breaking Changes
The changes in this section are not controlled by future flags, but you can update your code in v7 to be ready for v8.
### `meta` `data` Argument
[MODES: framework]
<br/>
<br/>
**Background**
The `data` fields passed to route module `meta` functions are deprecated and will be removed in React Router v8. Use `loaderData` instead on `MetaArgs` and each item in `MetaArgs.matches`.
👉 **Update your Code**
Replace `data` with `loaderData` in your `meta` functions:
```diff
export function meta({
- data,
+ loaderData,
matches,
}: Route.MetaArgs) {
return [
{
- title: data.title,
+ title: loaderData.title,
},
];
}
```
If you read data from parent matches, update those references too:
```diff
export function meta({ matches }: Route.MetaArgs) {
let rootMatch = matches.find((match) => match.id === "root");
- let rootData = rootMatch?.data;
+ let rootData = rootMatch?.loaderData;
return [{ title: rootData?.siteTitle }];
}
```
### `react-router-dom`
[MODES: framework, data, declarative]
<br/>
<br/>
**Background**
React Router v8 will remove the `react-router-dom` re-export package. In v8, you should import DOM-specific APIs from `react-router/dom` and everything else from `react-router`.
👉 **Update your Code**
Uninstall `react-router-dom`:
```sh
npm uninstall react-router-dom
```
Replace `react-router-dom` imports with `react-router` imports:
```diff
-import { Link, useLocation } from "react-router-dom";
+import { Link, useLocation } from "react-router";
```
For DOM-specific APIs, import from `react-router/dom`:
```diff
-import { RouterProvider } from "react-router-dom";
+import { RouterProvider } from "react-router/dom";
```
### Cloudflare Vite Plugin
[MODES: framework]
<br/>
<br/>
**Background**
React Router v8 will remove the React Router Cloudflare dev proxy. Cloudflare projects should use [`@cloudflare/vite-plugin`][cloudflare-vite-plugin] instead.
👉 **Update your Code**
Replace `cloudflareDevProxy` with `cloudflare`:
```diff filename=vite.config.ts
import { reactRouter } from "@react-router/dev/vite";
-import { cloudflareDevProxy } from "@react-router/dev/vite/cloudflare";
+import { cloudflare } from "@cloudflare/vite-plugin";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
- cloudflareDevProxy(),
+ cloudflare(),
reactRouter(),
],
});
```
### `@react-router/architect` `useRequestContextDomainName`
[MODES: framework]
<br/>
<br/>
**Background**
The `@react-router/architect` adapter currently uses `X-Forwarded-Host` when creating the `request`, falling back to the `Host` header. In React Router v8, the adapter will use `event.requestContext.domainName` by default, falling back to the `Host` header.
👉 **Update your Code**
Opt in to the v8 behavior now by passing `useRequestContextDomainName: true`:
```ts
import { createRequestHandler } from "@react-router/architect";
import * as build from "./build/server";
export const handler = createRequestHandler({
build,
useRequestContextDomainName: true,
});
```
This option will be removed in v8 once the `event.requestContext.domainName` behavior is the default.
## Unstable Future Flags (Optional)
We document some [unstable] flags here as a reference for folks contributing to the project via beta testing, but they are not generally recommended for production use and may having breaking changes patch/minor releases - adopt with caution!
We document some [unstable] flags here as a reference for folks contributing to the project via beta testing, but they are not generally recommended for production use and may have breaking changes in patch or minor releases - adopt with caution!
_No current unstable flags to document_
### `future.unstable_optimizeDeps`
[MODES: framework]
<br/>
<br/>
**Background**
This flag lets React Router provide Vite's dependency optimizer with the client entry file and route module files. This can improve dependency optimization in development, but the behavior is still experimental.
👉 **Enable the Flag**
```ts filename=react-router.config.ts
import type { Config } from "@react-router/dev/config";
export default {
future: {
unstable_optimizeDeps: true,
},
} satisfies Config;
```
**Update your Code**
No code changes are required. If you run into dependency optimization issues after enabling this flag, remove the flag and restart the dev server.
### `future.unstable_previewServerPrerendering`
[MODES: framework]
<br/>
<br/>
**Background**
This flag switches prerendering to use Vite's preview-server request flow instead of the current build-time prerendering path so that it works in non-Node environments such as `workerd`. Enabling this flag also enables `future.v8_viteEnvironmentApi`, so you should review the `future.v8_viteEnvironmentApi` guidance above before adopting it.
<docs-info>You do not have to adopt this flag ahead of your upgrade to v8 since it only changes the underlying prerender implementation. There is at least one known bug fixed in v8 where your `react-router.config.ts` `buildEnd` hook would run prior to prerendered files being written to disk.</docs-info>
👉 **Enable the Flag**
```ts filename=react-router.config.ts
import type { Config } from "@react-router/dev/config";
export default {
future: {
unstable_previewServerPrerendering: true,
},
} satisfies Config;
```
**Update your Code**
No code changes are required unless your app has a custom Vite configuration that is affected by `future.v8_viteEnvironmentApi`.
[api-development-strategy]: ../community/api-development-strategy

@@ -288,1 +497,2 @@ [unstable]: ../community/api-development-strategy#unstable-flags

[node-custom-server-template]: https://github.com/remix-run/react-router-templates/blob/7c617a435510bc3add3a5395c07bc65328b65e9e/node-custom-server/vite.config.ts
[cloudflare-vite-plugin]: https://developers.cloudflare.com/workers/vite-plugin/
---
title: Upgrading from Remix
title: Upgrading from Remix v2
order: 3
---
# Upgrading from Remix
# Upgrading from Remix v2

@@ -8,0 +8,0 @@ <docs-info>

{
"name": "react-router",
"version": "7.18.0",
"version": "7.18.1",
"description": "Declarative routing for React",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/**
* react-router v7.18.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
var _chunkU7ORXROYjs = require('./chunk-U7ORXROY.js');
// lib/dom/ssr/hydration.tsx
function getHydrationData({
state,
routes,
getRouteInfo,
location,
basename,
isSpaMode
}) {
let hydrationData = {
...state,
loaderData: { ...state.loaderData }
};
let initialMatches = _chunkU7ORXROYjs.matchRoutes.call(void 0, routes, location, basename);
if (initialMatches) {
for (let match of initialMatches) {
let routeId = match.route.id;
let routeInfo = getRouteInfo(routeId);
if (_chunkU7ORXROYjs.shouldHydrateRouteLoader.call(void 0,
routeId,
routeInfo.clientLoader,
routeInfo.hasLoader,
isSpaMode
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
delete hydrationData.loaderData[routeId];
} else if (!routeInfo.hasLoader) {
hydrationData.loaderData[routeId] = null;
}
}
}
return hydrationData;
}
// lib/rsc/errorBoundaries.tsx
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
var RSCRouterGlobalErrorBoundary = class extends _react2.default.Component {
constructor(props) {
super(props);
this.state = { error: null, location: props.location };
}
static getDerivedStateFromError(error) {
return { error };
}
static getDerivedStateFromProps(props, state) {
if (state.location !== props.location) {
return { error: null, location: props.location };
}
return { error: state.error, location: state.location };
}
render() {
if (this.state.error) {
return /* @__PURE__ */ _react2.default.createElement(
RSCDefaultRootErrorBoundaryImpl,
{
error: this.state.error,
renderAppShell: true
}
);
} else {
return this.props.children;
}
}
};
function ErrorWrapper({
renderAppShell,
title,
children
}) {
if (!renderAppShell) {
return children;
}
return /* @__PURE__ */ _react2.default.createElement("html", { lang: "en" }, /* @__PURE__ */ _react2.default.createElement("head", null, /* @__PURE__ */ _react2.default.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ _react2.default.createElement(
"meta",
{
name: "viewport",
content: "width=device-width,initial-scale=1,viewport-fit=cover"
}
), /* @__PURE__ */ _react2.default.createElement("title", null, title)), /* @__PURE__ */ _react2.default.createElement("body", null, /* @__PURE__ */ _react2.default.createElement("main", { style: { fontFamily: "system-ui, sans-serif", padding: "2rem" } }, children)));
}
function RSCDefaultRootErrorBoundaryImpl({
error,
renderAppShell
}) {
console.error(error);
let heyDeveloper = /* @__PURE__ */ _react2.default.createElement(
"script",
{
dangerouslySetInnerHTML: {
__html: `
console.log(
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
);
`
}
}
);
if (_chunkU7ORXROYjs.isRouteErrorResponse.call(void 0, error)) {
return /* @__PURE__ */ _react2.default.createElement(
ErrorWrapper,
{
renderAppShell,
title: "Unhandled Thrown Response!"
},
/* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
_chunkU7ORXROYjs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
);
}
let errorInstance;
if (error instanceof Error) {
errorInstance = error;
} else {
let errorString = error == null ? "Unknown Error" : typeof error === "object" && "toString" in error ? error.toString() : JSON.stringify(error);
errorInstance = new Error(errorString);
}
return /* @__PURE__ */ _react2.default.createElement(ErrorWrapper, { renderAppShell, title: "Application Error!" }, /* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, "Application Error"), /* @__PURE__ */ _react2.default.createElement(
"pre",
{
style: {
padding: "2rem",
background: "hsla(10, 50%, 50%, 0.1)",
color: "red",
overflow: "auto"
}
},
errorInstance.stack
), heyDeveloper);
}
function RSCDefaultRootErrorBoundary({
hasRootLayout
}) {
let error = _chunkU7ORXROYjs.useRouteError.call(void 0, );
if (hasRootLayout === void 0) {
throw new Error("Missing 'hasRootLayout' prop");
}
return /* @__PURE__ */ _react2.default.createElement(
RSCDefaultRootErrorBoundaryImpl,
{
renderAppShell: !hasRootLayout,
error
}
);
}
// lib/rsc/route-modules.ts
function createRSCRouteModules(payload) {
const routeModules = {};
for (const match of payload.matches) {
populateRSCRouteModules(routeModules, match);
}
return routeModules;
}
function populateRSCRouteModules(routeModules, matches) {
matches = Array.isArray(matches) ? matches : [matches];
for (const match of matches) {
routeModules[match.id] = {
links: match.links,
meta: match.meta,
default: noopComponent
};
}
}
var noopComponent = () => null;
exports.getHydrationData = getHydrationData; exports.RSCRouterGlobalErrorBoundary = RSCRouterGlobalErrorBoundary; exports.RSCDefaultRootErrorBoundary = RSCDefaultRootErrorBoundary; exports.createRSCRouteModules = createRSCRouteModules; exports.populateRSCRouteModules = populateRSCRouteModules;
"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; }/**
* react-router v7.18.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
var _chunkU7ORXROYjs = require('./chunk-U7ORXROY.js');
// lib/dom/dom.ts
var defaultMethod = "get";
var defaultEncType = "application/x-www-form-urlencoded";
function isHtmlElement(object) {
return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
}
function isButtonElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
}
function isFormElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
}
function isInputElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
}
function isModifiedEvent(event) {
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
}
function shouldProcessLinkClick(event, target) {
return event.button === 0 && // Ignore everything but left clicks
(!target || target === "_self") && // Let browser handle "target=_blank" etc.
!isModifiedEvent(event);
}
function createSearchParams(init = "") {
return new URLSearchParams(
typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
let value = init[key];
return memo.concat(
Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]
);
}, [])
);
}
function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
let searchParams = createSearchParams(locationSearch);
if (defaultSearchParams) {
defaultSearchParams.forEach((_, key) => {
if (!searchParams.has(key)) {
defaultSearchParams.getAll(key).forEach((value) => {
searchParams.append(key, value);
});
}
});
}
return searchParams;
}
var _formDataSupportsSubmitter = null;
function isFormDataSubmitterSupported() {
if (_formDataSupportsSubmitter === null) {
try {
new FormData(
document.createElement("form"),
// @ts-expect-error if FormData supports the submitter parameter, this will throw
0
);
_formDataSupportsSubmitter = false;
} catch (e) {
_formDataSupportsSubmitter = true;
}
}
return _formDataSupportsSubmitter;
}
var supportedFormEncTypes = /* @__PURE__ */ new Set([
"application/x-www-form-urlencoded",
"multipart/form-data",
"text/plain"
]);
function getFormEncType(encType) {
if (encType != null && !supportedFormEncTypes.has(encType)) {
_chunkU7ORXROYjs.warning.call(void 0,
false,
`"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
);
return null;
}
return encType;
}
function getFormSubmissionInfo(target, basename) {
let method;
let action;
let encType;
let formData;
let body;
if (isFormElement(target)) {
let attr = target.getAttribute("action");
action = attr ? _chunkU7ORXROYjs.stripBasename.call(void 0, attr, basename) : null;
method = target.getAttribute("method") || defaultMethod;
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
formData = new FormData(target);
} else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
let form = target.form;
if (form == null) {
throw new Error(
`Cannot submit a <button> or <input type="submit"> without a <form>`
);
}
let attr = target.getAttribute("formaction") || form.getAttribute("action");
action = attr ? _chunkU7ORXROYjs.stripBasename.call(void 0, attr, basename) : null;
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
formData = new FormData(form, target);
if (!isFormDataSubmitterSupported()) {
let { name, type, value } = target;
if (type === "image") {
let prefix = name ? `${name}.` : "";
formData.append(`${prefix}x`, "0");
formData.append(`${prefix}y`, "0");
} else if (name) {
formData.append(name, value);
}
}
} else if (isHtmlElement(target)) {
throw new Error(
`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
);
} else {
method = defaultMethod;
action = null;
encType = defaultEncType;
body = target;
}
if (formData && encType === "text/plain") {
body = formData;
formData = void 0;
}
return { action, method: method.toLowerCase(), encType, formData, body };
}
// lib/dom/lib.tsx
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
try {
if (isBrowser) {
window.__reactRouterVersion = // @ts-expect-error
"7.18.0";
}
} catch (e) {
}
function createBrowserRouter(routes, opts) {
return _chunkU7ORXROYjs.createRouter.call(void 0, {
basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
history: _chunkU7ORXROYjs.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _5 => _5.window]) }),
hydrationData: _optionalChain([opts, 'optionalAccess', _6 => _6.hydrationData]) || parseHydrationData(),
routes,
mapRouteProperties: _chunkU7ORXROYjs.mapRouteProperties,
hydrationRouteProperties: _chunkU7ORXROYjs.hydrationRouteProperties,
dataStrategy: _optionalChain([opts, 'optionalAccess', _7 => _7.dataStrategy]),
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _8 => _8.patchRoutesOnNavigation]),
window: _optionalChain([opts, 'optionalAccess', _9 => _9.window]),
instrumentations: _optionalChain([opts, 'optionalAccess', _10 => _10.instrumentations])
}).initialize();
}
function createHashRouter(routes, opts) {
return _chunkU7ORXROYjs.createRouter.call(void 0, {
basename: _optionalChain([opts, 'optionalAccess', _11 => _11.basename]),
getContext: _optionalChain([opts, 'optionalAccess', _12 => _12.getContext]),
future: _optionalChain([opts, 'optionalAccess', _13 => _13.future]),
history: _chunkU7ORXROYjs.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _14 => _14.window]) }),
hydrationData: _optionalChain([opts, 'optionalAccess', _15 => _15.hydrationData]) || parseHydrationData(),
routes,
mapRouteProperties: _chunkU7ORXROYjs.mapRouteProperties,
hydrationRouteProperties: _chunkU7ORXROYjs.hydrationRouteProperties,
dataStrategy: _optionalChain([opts, 'optionalAccess', _16 => _16.dataStrategy]),
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _17 => _17.patchRoutesOnNavigation]),
window: _optionalChain([opts, 'optionalAccess', _18 => _18.window]),
instrumentations: _optionalChain([opts, 'optionalAccess', _19 => _19.instrumentations])
}).initialize();
}
function parseHydrationData() {
let state = _optionalChain([window, 'optionalAccess', _20 => _20.__staticRouterHydrationData]);
if (state && state.errors) {
state = {
...state,
errors: deserializeErrors(state.errors)
};
}
return state;
}
function deserializeErrors(errors) {
if (!errors) return null;
let entries = Object.entries(errors);
let serialized = {};
for (let [key, val] of entries) {
if (val && val.__type === "RouteErrorResponse") {
serialized[key] = new (0, _chunkU7ORXROYjs.ErrorResponseImpl)(
val.status,
val.statusText,
val.data,
val.internal === true
);
} else if (val && val.__type === "Error") {
if (typeof val.__subType === "string" && _chunkU7ORXROYjs.SUPPORTED_ERROR_TYPES.includes(val.__subType)) {
let ErrorConstructor = window[val.__subType];
if (typeof ErrorConstructor === "function") {
try {
let error = new ErrorConstructor(val.message);
error.stack = "";
serialized[key] = error;
} catch (e) {
}
}
}
if (serialized[key] == null) {
let error = new Error(val.message);
error.stack = "";
serialized[key] = error;
}
} else {
serialized[key] = val;
}
}
return serialized;
}
function BrowserRouter({
basename,
children,
useTransitions,
window: window2
}) {
let historyRef = React.useRef();
if (historyRef.current == null) {
historyRef.current = _chunkU7ORXROYjs.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
}
let history = historyRef.current;
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkU7ORXROYjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
function HashRouter({
basename,
children,
useTransitions,
window: window2
}) {
let historyRef = React.useRef();
if (historyRef.current == null) {
historyRef.current = _chunkU7ORXROYjs.createHashHistory.call(void 0, { window: window2, v5Compat: true });
}
let history = historyRef.current;
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkU7ORXROYjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
function HistoryRouter({
basename,
children,
history,
useTransitions
}) {
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkU7ORXROYjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
HistoryRouter.displayName = "unstable_HistoryRouter";
var Link = React.forwardRef(
function LinkWithRef({
onClick,
discover = "render",
prefetch = "none",
relative,
reloadDocument,
replace,
mask,
state,
target,
to,
preventScrollReset,
viewTransition,
defaultShouldRevalidate,
...rest
}, forwardedRef) {
let { basename, navigator, useTransitions } = React.useContext(_chunkU7ORXROYjs.NavigationContext);
let isAbsolute = typeof to === "string" && _chunkU7ORXROYjs.ABSOLUTE_URL_REGEX.test(to);
let parsed = _chunkU7ORXROYjs.parseToInfo.call(void 0, to, basename);
to = parsed.to;
let href = _chunkU7ORXROYjs.useHref.call(void 0, to, { relative });
let location = _chunkU7ORXROYjs.useLocation.call(void 0, );
let maskedHref = null;
if (mask) {
let resolved = _chunkU7ORXROYjs.resolveTo.call(void 0,
mask,
[],
location.mask ? location.mask.pathname : "/",
true
);
if (basename !== "/") {
resolved.pathname = resolved.pathname === "/" ? basename : _chunkU7ORXROYjs.joinPaths.call(void 0, [basename, resolved.pathname]);
}
maskedHref = navigator.createHref(resolved);
}
let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkU7ORXROYjs.usePrefetchBehavior.call(void 0,
prefetch,
rest
);
let internalOnClick = useLinkClickHandler(to, {
replace,
mask,
state,
target,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
});
function handleClick(event) {
if (onClick) onClick(event);
if (!event.defaultPrevented) {
internalOnClick(event);
}
}
let isSpaLink = !(parsed.isExternal || reloadDocument);
let link = (
// eslint-disable-next-line jsx-a11y/anchor-has-content
/* @__PURE__ */ React.createElement(
"a",
{
...rest,
...prefetchHandlers,
href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
onClick: isSpaLink ? handleClick : onClick,
ref: _chunkU7ORXROYjs.mergeRefs.call(void 0, forwardedRef, prefetchRef),
target,
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
}
)
);
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(_chunkU7ORXROYjs.PrefetchPageLinks, { page: href })) : link;
}
);
Link.displayName = "Link";
var NavLink = React.forwardRef(
function NavLinkWithRef({
"aria-current": ariaCurrentProp = "page",
caseSensitive = false,
className: classNameProp = "",
end = false,
style: styleProp,
to,
viewTransition,
children,
...rest
}, ref) {
let path = _chunkU7ORXROYjs.useResolvedPath.call(void 0, to, { relative: rest.relative });
let location = _chunkU7ORXROYjs.useLocation.call(void 0, );
let routerState = React.useContext(_chunkU7ORXROYjs.DataRouterStateContext);
let { navigator, basename } = React.useContext(_chunkU7ORXROYjs.NavigationContext);
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
// eslint-disable-next-line react-hooks/rules-of-hooks
useViewTransitionState(path) && viewTransition === true;
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
let locationPathname = location.pathname;
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
if (!caseSensitive) {
locationPathname = locationPathname.toLowerCase();
nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
toPathname = toPathname.toLowerCase();
}
if (nextLocationPathname && basename) {
nextLocationPathname = _chunkU7ORXROYjs.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
}
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
let renderProps = {
isActive,
isPending,
isTransitioning
};
let ariaCurrent = isActive ? ariaCurrentProp : void 0;
let className;
if (typeof classNameProp === "function") {
className = classNameProp(renderProps);
} else {
className = [
classNameProp,
isActive ? "active" : null,
isPending ? "pending" : null,
isTransitioning ? "transitioning" : null
].filter(Boolean).join(" ");
}
let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
return /* @__PURE__ */ React.createElement(
Link,
{
...rest,
"aria-current": ariaCurrent,
className,
ref,
style,
to,
viewTransition
},
typeof children === "function" ? children(renderProps) : children
);
}
);
NavLink.displayName = "NavLink";
var Form = React.forwardRef(
({
discover = "render",
fetcherKey,
navigate,
reloadDocument,
replace,
state,
method = defaultMethod,
action,
onSubmit,
relative,
preventScrollReset,
viewTransition,
defaultShouldRevalidate,
...props
}, forwardedRef) => {
let { useTransitions } = React.useContext(_chunkU7ORXROYjs.NavigationContext);
let submit = useSubmit();
let formAction = useFormAction(action, { relative });
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
let isAbsolute = typeof action === "string" && _chunkU7ORXROYjs.ABSOLUTE_URL_REGEX.test(action);
let submitHandler = (event) => {
onSubmit && onSubmit(event);
if (event.defaultPrevented) return;
event.preventDefault();
let submitter = event.nativeEvent.submitter;
let submitMethod = _optionalChain([submitter, 'optionalAccess', _21 => _21.getAttribute, 'call', _22 => _22("formmethod")]) || method;
let doSubmit = () => submit(submitter || event.currentTarget, {
fetcherKey,
method: submitMethod,
navigate,
replace,
state,
relative,
preventScrollReset,
viewTransition,
defaultShouldRevalidate
});
if (useTransitions && navigate !== false) {
React.startTransition(() => doSubmit());
} else {
doSubmit();
}
};
return /* @__PURE__ */ React.createElement(
"form",
{
ref: forwardedRef,
method: formMethod,
action: formAction,
onSubmit: reloadDocument ? onSubmit : submitHandler,
...props,
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
}
);
}
);
Form.displayName = "Form";
function ScrollRestoration({
getKey,
storageKey,
...props
}) {
let remixContext = React.useContext(_chunkU7ORXROYjs.FrameworkContext);
let { basename } = React.useContext(_chunkU7ORXROYjs.NavigationContext);
let location = _chunkU7ORXROYjs.useLocation.call(void 0, );
let matches = _chunkU7ORXROYjs.useMatches.call(void 0, );
useScrollRestoration({ getKey, storageKey });
let ssrKey = React.useMemo(
() => {
if (!remixContext || !getKey) return null;
let userKey = getScrollRestorationKey(
location,
matches,
basename,
getKey
);
return userKey !== location.key ? userKey : null;
},
// Nah, we only need this the first time for the SSR render
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
if (!remixContext || remixContext.isSpaMode) {
return null;
}
let restoreScroll = ((storageKey2, restoreKey) => {
if (!window.history.state || !window.history.state.key) {
let key = Math.random().toString(32).slice(2);
window.history.replaceState({ key }, "");
}
try {
let positions = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
let storedY = positions[restoreKey || window.history.state.key];
if (typeof storedY === "number") {
window.scrollTo(0, storedY);
}
} catch (error) {
console.error(error);
sessionStorage.removeItem(storageKey2);
}
}).toString();
if (props.nonce == null && _optionalChain([remixContext, 'optionalAccess', _23 => _23.nonce])) {
props.nonce = remixContext.nonce;
}
return /* @__PURE__ */ React.createElement(
"script",
{
...props,
suppressHydrationWarning: true,
dangerouslySetInnerHTML: {
__html: `(${restoreScroll})(${_chunkU7ORXROYjs.escapeHtml.call(void 0,
JSON.stringify(storageKey || SCROLL_RESTORATION_STORAGE_KEY)
)}, ${_chunkU7ORXROYjs.escapeHtml.call(void 0, JSON.stringify(ssrKey))})`
}
}
);
}
ScrollRestoration.displayName = "ScrollRestoration";
function getDataRouterConsoleError(hookName) {
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
}
function useDataRouterContext(hookName) {
let ctx = React.useContext(_chunkU7ORXROYjs.DataRouterContext);
_chunkU7ORXROYjs.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
return ctx;
}
function useDataRouterState(hookName) {
let state = React.useContext(_chunkU7ORXROYjs.DataRouterStateContext);
_chunkU7ORXROYjs.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
return state;
}
function useLinkClickHandler(to, {
target,
replace: replaceProp,
mask,
state,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
} = {}) {
let navigate = _chunkU7ORXROYjs.useNavigate.call(void 0, );
let location = _chunkU7ORXROYjs.useLocation.call(void 0, );
let path = _chunkU7ORXROYjs.useResolvedPath.call(void 0, to, { relative });
return React.useCallback(
(event) => {
if (shouldProcessLinkClick(event, target)) {
event.preventDefault();
let replace = replaceProp !== void 0 ? replaceProp : _chunkU7ORXROYjs.createPath.call(void 0, location) === _chunkU7ORXROYjs.createPath.call(void 0, path);
let doNavigate = () => navigate(to, {
replace,
mask,
state,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate
});
if (useTransitions) {
React.startTransition(() => doNavigate());
} else {
doNavigate();
}
}
},
[
location,
navigate,
path,
replaceProp,
mask,
state,
target,
to,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
]
);
}
function useSearchParams(defaultInit) {
_chunkU7ORXROYjs.warning.call(void 0,
typeof URLSearchParams !== "undefined",
`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.`
);
let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
let hasSetSearchParamsRef = React.useRef(false);
let location = _chunkU7ORXROYjs.useLocation.call(void 0, );
let searchParams = React.useMemo(
() => (
// Only merge in the defaults if we haven't yet called setSearchParams.
// Once we call that we want those to take precedence, otherwise you can't
// remove a param with setSearchParams({}) if it has an initial value
getSearchParamsForLocation(
location.search,
hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
)
),
[location.search]
);
let navigate = _chunkU7ORXROYjs.useNavigate.call(void 0, );
let setSearchParams = React.useCallback(
(nextInit, navigateOptions) => {
const newSearchParams = createSearchParams(
typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit
);
hasSetSearchParamsRef.current = true;
navigate("?" + newSearchParams, navigateOptions);
},
[navigate, searchParams]
);
return [searchParams, setSearchParams];
}
var fetcherId = 0;
var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
function useSubmit() {
let { router } = useDataRouterContext("useSubmit" /* UseSubmit */);
let { basename } = React.useContext(_chunkU7ORXROYjs.NavigationContext);
let currentRouteId = _chunkU7ORXROYjs.useRouteId.call(void 0, );
let routerFetch = router.fetch;
let routerNavigate = router.navigate;
return React.useCallback(
async (target, options = {}) => {
let { action, method, encType, formData, body } = getFormSubmissionInfo(
target,
basename
);
if (options.navigate === false) {
let key = options.fetcherKey || getUniqueFetcherId();
await routerFetch(key, currentRouteId, options.action || action, {
defaultShouldRevalidate: options.defaultShouldRevalidate,
preventScrollReset: options.preventScrollReset,
formData,
body,
formMethod: options.method || method,
formEncType: options.encType || encType,
flushSync: options.flushSync
});
} else {
await routerNavigate(options.action || action, {
defaultShouldRevalidate: options.defaultShouldRevalidate,
preventScrollReset: options.preventScrollReset,
formData,
body,
formMethod: options.method || method,
formEncType: options.encType || encType,
replace: options.replace,
state: options.state,
fromRouteId: currentRouteId,
flushSync: options.flushSync,
viewTransition: options.viewTransition
});
}
},
[routerFetch, routerNavigate, basename, currentRouteId]
);
}
function useFormAction(action, { relative } = {}) {
let { basename } = React.useContext(_chunkU7ORXROYjs.NavigationContext);
let routeContext = React.useContext(_chunkU7ORXROYjs.RouteContext);
_chunkU7ORXROYjs.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
let [match] = routeContext.matches.slice(-1);
let path = { ..._chunkU7ORXROYjs.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
let location = _chunkU7ORXROYjs.useLocation.call(void 0, );
if (action == null) {
path.search = location.search;
let params = new URLSearchParams(path.search);
let indexValues = params.getAll("index");
let hasNakedIndexParam = indexValues.some((v) => v === "");
if (hasNakedIndexParam) {
params.delete("index");
indexValues.filter((v) => v).forEach((v) => params.append("index", v));
let qs = params.toString();
path.search = qs ? `?${qs}` : "";
}
}
if ((!action || action === ".") && match.route.index) {
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
}
if (basename !== "/") {
path.pathname = path.pathname === "/" ? basename : _chunkU7ORXROYjs.joinPaths.call(void 0, [basename, path.pathname]);
}
return _chunkU7ORXROYjs.createPath.call(void 0, path);
}
function useFetcher({
key
} = {}) {
let { router } = useDataRouterContext("useFetcher" /* UseFetcher */);
let state = useDataRouterState("useFetcher" /* UseFetcher */);
let fetcherData = React.useContext(_chunkU7ORXROYjs.FetchersContext);
let route = React.useContext(_chunkU7ORXROYjs.RouteContext);
let routeId = _optionalChain([route, 'access', _24 => _24.matches, 'access', _25 => _25[route.matches.length - 1], 'optionalAccess', _26 => _26.route, 'access', _27 => _27.id]);
_chunkU7ORXROYjs.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
_chunkU7ORXROYjs.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
_chunkU7ORXROYjs.invariant.call(void 0,
routeId != null,
`useFetcher can only be used on routes that contain a unique "id"`
);
let defaultKey = React.useId();
let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
if (key && key !== fetcherKey) {
setFetcherKey(key);
}
let { deleteFetcher, getFetcher, resetFetcher, fetch: routerFetch } = router;
React.useEffect(() => {
getFetcher(fetcherKey);
return () => deleteFetcher(fetcherKey);
}, [deleteFetcher, getFetcher, fetcherKey]);
let load = React.useCallback(
async (href, opts) => {
_chunkU7ORXROYjs.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
await routerFetch(fetcherKey, routeId, href, opts);
},
[fetcherKey, routeId, routerFetch]
);
let submitImpl = useSubmit();
let submit = React.useCallback(
async (target, opts) => {
await submitImpl(target, {
...opts,
navigate: false,
fetcherKey
});
},
[fetcherKey, submitImpl]
);
let reset = React.useCallback(
(opts) => resetFetcher(fetcherKey, opts),
[resetFetcher, fetcherKey]
);
let FetcherForm = React.useMemo(() => {
let FetcherForm2 = React.forwardRef(
(props, ref) => {
return /* @__PURE__ */ React.createElement(Form, { ...props, navigate: false, fetcherKey, ref });
}
);
FetcherForm2.displayName = "fetcher.Form";
return FetcherForm2;
}, [fetcherKey]);
let fetcher = state.fetchers.get(fetcherKey) || _chunkU7ORXROYjs.IDLE_FETCHER;
let data = fetcherData.get(fetcherKey);
let fetcherWithComponents = React.useMemo(
() => ({
Form: FetcherForm,
submit,
load,
reset,
...fetcher,
data
}),
[FetcherForm, submit, load, reset, fetcher, data]
);
return fetcherWithComponents;
}
function useFetchers() {
let state = useDataRouterState("useFetchers" /* UseFetchers */);
return React.useMemo(
() => Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
...fetcher,
key
})),
[state.fetchers]
);
}
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
var savedScrollPositions = {};
function getScrollRestorationKey(location, matches, basename, getKey) {
let key = null;
if (getKey) {
if (basename !== "/") {
key = getKey(
{
...location,
pathname: _chunkU7ORXROYjs.stripBasename.call(void 0, location.pathname, basename) || location.pathname
},
matches
);
} else {
key = getKey(location, matches);
}
}
if (key == null) {
key = location.key;
}
return key;
}
function useScrollRestoration({
getKey,
storageKey
} = {}) {
let { router } = useDataRouterContext("useScrollRestoration" /* UseScrollRestoration */);
let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
"useScrollRestoration" /* UseScrollRestoration */
);
let { basename } = React.useContext(_chunkU7ORXROYjs.NavigationContext);
let location = _chunkU7ORXROYjs.useLocation.call(void 0, );
let matches = _chunkU7ORXROYjs.useMatches.call(void 0, );
let navigation = _chunkU7ORXROYjs.useNavigation.call(void 0, );
React.useEffect(() => {
window.history.scrollRestoration = "manual";
return () => {
window.history.scrollRestoration = "auto";
};
}, []);
usePageHide(
React.useCallback(() => {
if (navigation.state === "idle") {
let key = getScrollRestorationKey(location, matches, basename, getKey);
savedScrollPositions[key] = window.scrollY;
}
try {
sessionStorage.setItem(
storageKey || SCROLL_RESTORATION_STORAGE_KEY,
JSON.stringify(savedScrollPositions)
);
} catch (error) {
_chunkU7ORXROYjs.warning.call(void 0,
false,
`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
);
}
window.history.scrollRestoration = "auto";
}, [navigation.state, getKey, basename, location, matches, storageKey])
);
if (typeof document !== "undefined") {
React.useLayoutEffect(() => {
try {
let sessionPositions = sessionStorage.getItem(
storageKey || SCROLL_RESTORATION_STORAGE_KEY
);
if (sessionPositions) {
savedScrollPositions = JSON.parse(sessionPositions);
}
} catch (e) {
}
}, [storageKey]);
React.useLayoutEffect(() => {
let disableScrollRestoration = _optionalChain([router, 'optionalAccess', _28 => _28.enableScrollRestoration, 'call', _29 => _29(
savedScrollPositions,
() => window.scrollY,
getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
)]);
return () => disableScrollRestoration && disableScrollRestoration();
}, [router, basename, getKey]);
React.useLayoutEffect(() => {
if (restoreScrollPosition === false) {
return;
}
if (typeof restoreScrollPosition === "number") {
window.scrollTo(0, restoreScrollPosition);
return;
}
try {
if (location.hash) {
let el = document.getElementById(
decodeURIComponent(location.hash.slice(1))
);
if (el) {
el.scrollIntoView();
return;
}
}
} catch (e2) {
_chunkU7ORXROYjs.warning.call(void 0,
false,
`"${location.hash.slice(
1
)}" is not a decodable element ID. The view will not scroll to it.`
);
}
if (preventScrollReset === true) {
return;
}
window.scrollTo(0, 0);
}, [location, restoreScrollPosition, preventScrollReset]);
}
}
function useBeforeUnload(callback, options) {
let { capture } = options || {};
React.useEffect(() => {
let opts = capture != null ? { capture } : void 0;
window.addEventListener("beforeunload", callback, opts);
return () => {
window.removeEventListener("beforeunload", callback, opts);
};
}, [callback, capture]);
}
function usePageHide(callback, options) {
let { capture } = options || {};
React.useEffect(() => {
let opts = capture != null ? { capture } : void 0;
window.addEventListener("pagehide", callback, opts);
return () => {
window.removeEventListener("pagehide", callback, opts);
};
}, [callback, capture]);
}
function usePrompt({
when,
message
}) {
let blocker = _chunkU7ORXROYjs.useBlocker.call(void 0, when);
React.useEffect(() => {
if (blocker.state === "blocked") {
let proceed = window.confirm(message);
if (proceed) {
setTimeout(blocker.proceed, 0);
} else {
blocker.reset();
}
}
}, [blocker, message]);
React.useEffect(() => {
if (blocker.state === "blocked" && !when) {
blocker.reset();
}
}, [blocker, when]);
}
function useViewTransitionState(to, { relative } = {}) {
let vtContext = React.useContext(_chunkU7ORXROYjs.ViewTransitionContext);
_chunkU7ORXROYjs.invariant.call(void 0,
vtContext != null,
"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
);
let { basename } = useDataRouterContext(
"useViewTransitionState" /* useViewTransitionState */
);
let path = _chunkU7ORXROYjs.useResolvedPath.call(void 0, to, { relative });
if (!vtContext.isTransitioning) {
return false;
}
let currentPath = _chunkU7ORXROYjs.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
let nextPath = _chunkU7ORXROYjs.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
return _chunkU7ORXROYjs.matchPath.call(void 0, path.pathname, nextPath) != null || _chunkU7ORXROYjs.matchPath.call(void 0, path.pathname, currentPath) != null;
}
// lib/dom/server.tsx
function StaticRouter({
basename,
children,
location: locationProp = "/"
}) {
if (typeof locationProp === "string") {
locationProp = _chunkU7ORXROYjs.parsePath.call(void 0, locationProp);
}
let action = "POP" /* Pop */;
let location = {
pathname: locationProp.pathname || "/",
search: locationProp.search || "",
hash: locationProp.hash || "",
state: locationProp.state != null ? locationProp.state : null,
key: locationProp.key || "default",
mask: void 0
};
let staticNavigator = getStatelessNavigator();
return /* @__PURE__ */ React2.createElement(
_chunkU7ORXROYjs.Router,
{
basename,
children,
location,
navigationType: action,
navigator: staticNavigator,
static: true,
useTransitions: false
}
);
}
function StaticRouterProvider({
context,
router,
hydrate = true,
nonce
}) {
_chunkU7ORXROYjs.invariant.call(void 0,
router && context,
"You must provide `router` and `context` to <StaticRouterProvider>"
);
let dataRouterContext = {
router,
navigator: getStatelessNavigator(),
static: true,
staticContext: context,
basename: context.basename || "/"
};
let fetchersContext = /* @__PURE__ */ new Map();
let hydrateScript = "";
if (hydrate !== false) {
let data = {
loaderData: context.loaderData,
actionData: context.actionData,
errors: serializeErrors(context.errors)
};
let json = _chunkU7ORXROYjs.escapeHtml.call(void 0, JSON.stringify(JSON.stringify(data)));
hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
}
let { state } = dataRouterContext.router;
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(_chunkU7ORXROYjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React2.createElement(_chunkU7ORXROYjs.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React2.createElement(_chunkU7ORXROYjs.FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React2.createElement(_chunkU7ORXROYjs.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React2.createElement(
_chunkU7ORXROYjs.Router,
{
basename: dataRouterContext.basename,
location: state.location,
navigationType: state.historyAction,
navigator: dataRouterContext.navigator,
static: dataRouterContext.static,
useTransitions: false
},
/* @__PURE__ */ React2.createElement(
_chunkU7ORXROYjs.DataRoutes,
{
manifest: router.manifest,
routes: router.routes,
future: router.future,
state,
isStatic: true
}
)
))))), hydrateScript ? /* @__PURE__ */ React2.createElement(
"script",
{
suppressHydrationWarning: true,
nonce,
dangerouslySetInnerHTML: { __html: hydrateScript }
}
) : null);
}
function serializeErrors(errors) {
if (!errors) return null;
let entries = Object.entries(errors);
let serialized = {};
for (let [key, val] of entries) {
if (_chunkU7ORXROYjs.isRouteErrorResponse.call(void 0, val)) {
serialized[key] = { ...val, __type: "RouteErrorResponse" };
} else if (val instanceof Error) {
serialized[key] = {
message: val.message,
__type: "Error",
// If this is a subclass (i.e., ReferenceError), send up the type so we
// can re-create the same type during hydration.
...val.name !== "Error" ? {
__subType: val.name
} : {}
};
} else {
serialized[key] = val;
}
}
return serialized;
}
function getStatelessNavigator() {
return {
createHref,
encodeLocation,
push(to) {
throw new Error(
`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.`
);
},
replace(to) {
throw new Error(
`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.`
);
},
go(delta) {
throw new Error(
`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.`
);
},
back() {
throw new Error(
`You cannot use navigator.back() on the server because it is a stateless environment.`
);
},
forward() {
throw new Error(
`You cannot use navigator.forward() on the server because it is a stateless environment.`
);
}
};
}
function createStaticHandler2(routes, opts) {
return _chunkU7ORXROYjs.createStaticHandler.call(void 0, routes, {
...opts,
mapRouteProperties: _chunkU7ORXROYjs.mapRouteProperties
});
}
function createStaticRouter(routes, context, opts = {}) {
let manifest = {};
let dataRoutes = _chunkU7ORXROYjs.convertRoutesToDataRoutes.call(void 0,
routes,
_chunkU7ORXROYjs.mapRouteProperties,
void 0,
manifest
);
let matches = context.matches.map((match) => {
let route = manifest[match.route.id] || match.route;
return {
...match,
route
};
});
let msg = (method) => `You cannot use router.${method}() on the server because it is a stateless environment`;
return {
get basename() {
return context.basename;
},
get future() {
return {
v8_middleware: false,
v8_passThroughRequests: false,
v8_trailingSlashAwareDataRequests: false,
..._optionalChain([opts, 'optionalAccess', _30 => _30.future])
};
},
get state() {
return {
historyAction: "POP" /* Pop */,
location: context.location,
matches,
loaderData: context.loaderData,
actionData: context.actionData,
errors: context.errors,
initialized: true,
renderFallback: false,
navigation: _chunkU7ORXROYjs.IDLE_NAVIGATION,
restoreScrollPosition: null,
preventScrollReset: false,
revalidation: "idle",
fetchers: /* @__PURE__ */ new Map(),
blockers: /* @__PURE__ */ new Map()
};
},
get routes() {
return dataRoutes;
},
get branches() {
return opts.branches;
},
get manifest() {
return manifest;
},
get window() {
return void 0;
},
initialize() {
throw msg("initialize");
},
subscribe() {
throw msg("subscribe");
},
enableScrollRestoration() {
throw msg("enableScrollRestoration");
},
navigate() {
throw msg("navigate");
},
fetch() {
throw msg("fetch");
},
revalidate() {
throw msg("revalidate");
},
createHref,
encodeLocation,
getFetcher() {
return _chunkU7ORXROYjs.IDLE_FETCHER;
},
deleteFetcher() {
throw msg("deleteFetcher");
},
resetFetcher() {
throw msg("resetFetcher");
},
dispose() {
throw msg("dispose");
},
getBlocker() {
return _chunkU7ORXROYjs.IDLE_BLOCKER;
},
deleteBlocker() {
throw msg("deleteBlocker");
},
patchRoutes() {
throw msg("patchRoutes");
},
_internalFetchControllers: /* @__PURE__ */ new Map(),
_internalSetRoutes() {
throw msg("_internalSetRoutes");
},
_internalSetStateDoNotUseOrYouWillBreakYourApp() {
throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
}
};
}
function createHref(to) {
return typeof to === "string" ? to : _chunkU7ORXROYjs.createPath.call(void 0, to);
}
function encodeLocation(to) {
let href = typeof to === "string" ? to : _chunkU7ORXROYjs.createPath.call(void 0, to);
href = href.replace(/ $/, "%20");
let encoded = _chunkU7ORXROYjs.ABSOLUTE_URL_REGEX.test(href) ? new URL(href) : new URL(href, "http://localhost");
return {
pathname: encoded.pathname,
search: encoded.search,
hash: encoded.hash
};
}
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;
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/**
* react-router v7.18.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
var _chunkIUPBOWYOjs = require('./chunk-IUPBOWYO.js');
// lib/dom/ssr/hydration.tsx
function getHydrationData({
state,
routes,
getRouteInfo,
location,
basename,
isSpaMode
}) {
let hydrationData = {
...state,
loaderData: { ...state.loaderData }
};
let initialMatches = _chunkIUPBOWYOjs.matchRoutes.call(void 0, routes, location, basename);
if (initialMatches) {
for (let match of initialMatches) {
let routeId = match.route.id;
let routeInfo = getRouteInfo(routeId);
if (_chunkIUPBOWYOjs.shouldHydrateRouteLoader.call(void 0,
routeId,
routeInfo.clientLoader,
routeInfo.hasLoader,
isSpaMode
) && (routeInfo.hasHydrateFallback || !routeInfo.hasLoader)) {
delete hydrationData.loaderData[routeId];
} else if (!routeInfo.hasLoader) {
hydrationData.loaderData[routeId] = null;
}
}
}
return hydrationData;
}
// lib/rsc/errorBoundaries.tsx
var _react = require('react'); var _react2 = _interopRequireDefault(_react);
var RSCRouterGlobalErrorBoundary = class extends _react2.default.Component {
constructor(props) {
super(props);
this.state = { error: null, location: props.location };
}
static getDerivedStateFromError(error) {
return { error };
}
static getDerivedStateFromProps(props, state) {
if (state.location !== props.location) {
return { error: null, location: props.location };
}
return { error: state.error, location: state.location };
}
render() {
if (this.state.error) {
return /* @__PURE__ */ _react2.default.createElement(
RSCDefaultRootErrorBoundaryImpl,
{
error: this.state.error,
renderAppShell: true
}
);
} else {
return this.props.children;
}
}
};
function ErrorWrapper({
renderAppShell,
title,
children
}) {
if (!renderAppShell) {
return children;
}
return /* @__PURE__ */ _react2.default.createElement("html", { lang: "en" }, /* @__PURE__ */ _react2.default.createElement("head", null, /* @__PURE__ */ _react2.default.createElement("meta", { charSet: "utf-8" }), /* @__PURE__ */ _react2.default.createElement(
"meta",
{
name: "viewport",
content: "width=device-width,initial-scale=1,viewport-fit=cover"
}
), /* @__PURE__ */ _react2.default.createElement("title", null, title)), /* @__PURE__ */ _react2.default.createElement("body", null, /* @__PURE__ */ _react2.default.createElement("main", { style: { fontFamily: "system-ui, sans-serif", padding: "2rem" } }, children)));
}
function RSCDefaultRootErrorBoundaryImpl({
error,
renderAppShell
}) {
console.error(error);
let heyDeveloper = /* @__PURE__ */ _react2.default.createElement(
"script",
{
dangerouslySetInnerHTML: {
__html: `
console.log(
"\u{1F4BF} Hey developer \u{1F44B}. You can provide a way better UX than this when your app throws errors. Check out https://reactrouter.com/how-to/error-boundary for more information."
);
`
}
}
);
if (_chunkIUPBOWYOjs.isRouteErrorResponse.call(void 0, error)) {
return /* @__PURE__ */ _react2.default.createElement(
ErrorWrapper,
{
renderAppShell,
title: "Unhandled Thrown Response!"
},
/* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, error.status, " ", error.statusText),
_chunkIUPBOWYOjs.ENABLE_DEV_WARNINGS ? heyDeveloper : null
);
}
let errorInstance;
if (error instanceof Error) {
errorInstance = error;
} else {
let errorString = error == null ? "Unknown Error" : typeof error === "object" && "toString" in error ? error.toString() : JSON.stringify(error);
errorInstance = new Error(errorString);
}
return /* @__PURE__ */ _react2.default.createElement(ErrorWrapper, { renderAppShell, title: "Application Error!" }, /* @__PURE__ */ _react2.default.createElement("h1", { style: { fontSize: "24px" } }, "Application Error"), /* @__PURE__ */ _react2.default.createElement(
"pre",
{
style: {
padding: "2rem",
background: "hsla(10, 50%, 50%, 0.1)",
color: "red",
overflow: "auto"
}
},
errorInstance.stack
), heyDeveloper);
}
function RSCDefaultRootErrorBoundary({
hasRootLayout
}) {
let error = _chunkIUPBOWYOjs.useRouteError.call(void 0, );
if (hasRootLayout === void 0) {
throw new Error("Missing 'hasRootLayout' prop");
}
return /* @__PURE__ */ _react2.default.createElement(
RSCDefaultRootErrorBoundaryImpl,
{
renderAppShell: !hasRootLayout,
error
}
);
}
// lib/rsc/route-modules.ts
function createRSCRouteModules(payload) {
const routeModules = {};
for (const match of payload.matches) {
populateRSCRouteModules(routeModules, match);
}
return routeModules;
}
function populateRSCRouteModules(routeModules, matches) {
matches = Array.isArray(matches) ? matches : [matches];
for (const match of matches) {
routeModules[match.id] = {
links: match.links,
meta: match.meta,
default: noopComponent
};
}
}
var noopComponent = () => null;
exports.getHydrationData = getHydrationData; exports.RSCRouterGlobalErrorBoundary = RSCRouterGlobalErrorBoundary; exports.RSCDefaultRootErrorBoundary = RSCDefaultRootErrorBoundary; exports.createRSCRouteModules = createRSCRouteModules; exports.populateRSCRouteModules = populateRSCRouteModules;
"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; }/**
* react-router v7.18.0
*
* Copyright (c) Remix Software Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
var _chunkIUPBOWYOjs = require('./chunk-IUPBOWYO.js');
// lib/dom/dom.ts
var defaultMethod = "get";
var defaultEncType = "application/x-www-form-urlencoded";
function isHtmlElement(object) {
return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
}
function isButtonElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
}
function isFormElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
}
function isInputElement(object) {
return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
}
function isModifiedEvent(event) {
return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
}
function shouldProcessLinkClick(event, target) {
return event.button === 0 && // Ignore everything but left clicks
(!target || target === "_self") && // Let browser handle "target=_blank" etc.
!isModifiedEvent(event);
}
function createSearchParams(init = "") {
return new URLSearchParams(
typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
let value = init[key];
return memo.concat(
Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]
);
}, [])
);
}
function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
let searchParams = createSearchParams(locationSearch);
if (defaultSearchParams) {
defaultSearchParams.forEach((_, key) => {
if (!searchParams.has(key)) {
defaultSearchParams.getAll(key).forEach((value) => {
searchParams.append(key, value);
});
}
});
}
return searchParams;
}
var _formDataSupportsSubmitter = null;
function isFormDataSubmitterSupported() {
if (_formDataSupportsSubmitter === null) {
try {
new FormData(
document.createElement("form"),
// @ts-expect-error if FormData supports the submitter parameter, this will throw
0
);
_formDataSupportsSubmitter = false;
} catch (e) {
_formDataSupportsSubmitter = true;
}
}
return _formDataSupportsSubmitter;
}
var supportedFormEncTypes = /* @__PURE__ */ new Set([
"application/x-www-form-urlencoded",
"multipart/form-data",
"text/plain"
]);
function getFormEncType(encType) {
if (encType != null && !supportedFormEncTypes.has(encType)) {
_chunkIUPBOWYOjs.warning.call(void 0,
false,
`"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
);
return null;
}
return encType;
}
function getFormSubmissionInfo(target, basename) {
let method;
let action;
let encType;
let formData;
let body;
if (isFormElement(target)) {
let attr = target.getAttribute("action");
action = attr ? _chunkIUPBOWYOjs.stripBasename.call(void 0, attr, basename) : null;
method = target.getAttribute("method") || defaultMethod;
encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
formData = new FormData(target);
} else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
let form = target.form;
if (form == null) {
throw new Error(
`Cannot submit a <button> or <input type="submit"> without a <form>`
);
}
let attr = target.getAttribute("formaction") || form.getAttribute("action");
action = attr ? _chunkIUPBOWYOjs.stripBasename.call(void 0, attr, basename) : null;
method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
formData = new FormData(form, target);
if (!isFormDataSubmitterSupported()) {
let { name, type, value } = target;
if (type === "image") {
let prefix = name ? `${name}.` : "";
formData.append(`${prefix}x`, "0");
formData.append(`${prefix}y`, "0");
} else if (name) {
formData.append(name, value);
}
}
} else if (isHtmlElement(target)) {
throw new Error(
`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
);
} else {
method = defaultMethod;
action = null;
encType = defaultEncType;
body = target;
}
if (formData && encType === "text/plain") {
body = formData;
formData = void 0;
}
return { action, method: method.toLowerCase(), encType, formData, body };
}
// lib/dom/lib.tsx
var _react = require('react'); var React = _interopRequireWildcard(_react); var React2 = _interopRequireWildcard(_react);
var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
try {
if (isBrowser) {
window.__reactRouterVersion = // @ts-expect-error
"7.18.0";
}
} catch (e) {
}
function createBrowserRouter(routes, opts) {
return _chunkIUPBOWYOjs.createRouter.call(void 0, {
basename: _optionalChain([opts, 'optionalAccess', _2 => _2.basename]),
getContext: _optionalChain([opts, 'optionalAccess', _3 => _3.getContext]),
future: _optionalChain([opts, 'optionalAccess', _4 => _4.future]),
history: _chunkIUPBOWYOjs.createBrowserHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _5 => _5.window]) }),
hydrationData: _optionalChain([opts, 'optionalAccess', _6 => _6.hydrationData]) || parseHydrationData(),
routes,
mapRouteProperties: _chunkIUPBOWYOjs.mapRouteProperties,
hydrationRouteProperties: _chunkIUPBOWYOjs.hydrationRouteProperties,
dataStrategy: _optionalChain([opts, 'optionalAccess', _7 => _7.dataStrategy]),
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _8 => _8.patchRoutesOnNavigation]),
window: _optionalChain([opts, 'optionalAccess', _9 => _9.window]),
instrumentations: _optionalChain([opts, 'optionalAccess', _10 => _10.instrumentations])
}).initialize();
}
function createHashRouter(routes, opts) {
return _chunkIUPBOWYOjs.createRouter.call(void 0, {
basename: _optionalChain([opts, 'optionalAccess', _11 => _11.basename]),
getContext: _optionalChain([opts, 'optionalAccess', _12 => _12.getContext]),
future: _optionalChain([opts, 'optionalAccess', _13 => _13.future]),
history: _chunkIUPBOWYOjs.createHashHistory.call(void 0, { window: _optionalChain([opts, 'optionalAccess', _14 => _14.window]) }),
hydrationData: _optionalChain([opts, 'optionalAccess', _15 => _15.hydrationData]) || parseHydrationData(),
routes,
mapRouteProperties: _chunkIUPBOWYOjs.mapRouteProperties,
hydrationRouteProperties: _chunkIUPBOWYOjs.hydrationRouteProperties,
dataStrategy: _optionalChain([opts, 'optionalAccess', _16 => _16.dataStrategy]),
patchRoutesOnNavigation: _optionalChain([opts, 'optionalAccess', _17 => _17.patchRoutesOnNavigation]),
window: _optionalChain([opts, 'optionalAccess', _18 => _18.window]),
instrumentations: _optionalChain([opts, 'optionalAccess', _19 => _19.instrumentations])
}).initialize();
}
function parseHydrationData() {
let state = _optionalChain([window, 'optionalAccess', _20 => _20.__staticRouterHydrationData]);
if (state && state.errors) {
state = {
...state,
errors: deserializeErrors(state.errors)
};
}
return state;
}
function deserializeErrors(errors) {
if (!errors) return null;
let entries = Object.entries(errors);
let serialized = {};
for (let [key, val] of entries) {
if (val && val.__type === "RouteErrorResponse") {
serialized[key] = new (0, _chunkIUPBOWYOjs.ErrorResponseImpl)(
val.status,
val.statusText,
val.data,
val.internal === true
);
} else if (val && val.__type === "Error") {
if (typeof val.__subType === "string" && _chunkIUPBOWYOjs.SUPPORTED_ERROR_TYPES.includes(val.__subType)) {
let ErrorConstructor = window[val.__subType];
if (typeof ErrorConstructor === "function") {
try {
let error = new ErrorConstructor(val.message);
error.stack = "";
serialized[key] = error;
} catch (e) {
}
}
}
if (serialized[key] == null) {
let error = new Error(val.message);
error.stack = "";
serialized[key] = error;
}
} else {
serialized[key] = val;
}
}
return serialized;
}
function BrowserRouter({
basename,
children,
useTransitions,
window: window2
}) {
let historyRef = React.useRef();
if (historyRef.current == null) {
historyRef.current = _chunkIUPBOWYOjs.createBrowserHistory.call(void 0, { window: window2, v5Compat: true });
}
let history = historyRef.current;
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkIUPBOWYOjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
function HashRouter({
basename,
children,
useTransitions,
window: window2
}) {
let historyRef = React.useRef();
if (historyRef.current == null) {
historyRef.current = _chunkIUPBOWYOjs.createHashHistory.call(void 0, { window: window2, v5Compat: true });
}
let history = historyRef.current;
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkIUPBOWYOjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
function HistoryRouter({
basename,
children,
history,
useTransitions
}) {
let [state, setStateImpl] = React.useState({
action: history.action,
location: history.location
});
let setState = React.useCallback(
(newState) => {
if (useTransitions === false) {
setStateImpl(newState);
} else {
React.startTransition(() => setStateImpl(newState));
}
},
[useTransitions]
);
React.useLayoutEffect(() => history.listen(setState), [history, setState]);
return /* @__PURE__ */ React.createElement(
_chunkIUPBOWYOjs.Router,
{
basename,
children,
location: state.location,
navigationType: state.action,
navigator: history,
useTransitions
}
);
}
HistoryRouter.displayName = "unstable_HistoryRouter";
var Link = React.forwardRef(
function LinkWithRef({
onClick,
discover = "render",
prefetch = "none",
relative,
reloadDocument,
replace,
mask,
state,
target,
to,
preventScrollReset,
viewTransition,
defaultShouldRevalidate,
...rest
}, forwardedRef) {
let { basename, navigator, useTransitions } = React.useContext(_chunkIUPBOWYOjs.NavigationContext);
let isAbsolute = typeof to === "string" && _chunkIUPBOWYOjs.ABSOLUTE_URL_REGEX.test(to);
let parsed = _chunkIUPBOWYOjs.parseToInfo.call(void 0, to, basename);
to = parsed.to;
let href = _chunkIUPBOWYOjs.useHref.call(void 0, to, { relative });
let location = _chunkIUPBOWYOjs.useLocation.call(void 0, );
let maskedHref = null;
if (mask) {
let resolved = _chunkIUPBOWYOjs.resolveTo.call(void 0,
mask,
[],
location.mask ? location.mask.pathname : "/",
true
);
if (basename !== "/") {
resolved.pathname = resolved.pathname === "/" ? basename : _chunkIUPBOWYOjs.joinPaths.call(void 0, [basename, resolved.pathname]);
}
maskedHref = navigator.createHref(resolved);
}
let [shouldPrefetch, prefetchRef, prefetchHandlers] = _chunkIUPBOWYOjs.usePrefetchBehavior.call(void 0,
prefetch,
rest
);
let internalOnClick = useLinkClickHandler(to, {
replace,
mask,
state,
target,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
});
function handleClick(event) {
if (onClick) onClick(event);
if (!event.defaultPrevented) {
internalOnClick(event);
}
}
let isSpaLink = !(parsed.isExternal || reloadDocument);
let link = (
// eslint-disable-next-line jsx-a11y/anchor-has-content
/* @__PURE__ */ React.createElement(
"a",
{
...rest,
...prefetchHandlers,
href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
onClick: isSpaLink ? handleClick : onClick,
ref: _chunkIUPBOWYOjs.mergeRefs.call(void 0, forwardedRef, prefetchRef),
target,
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
}
)
);
return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React.createElement(React.Fragment, null, link, /* @__PURE__ */ React.createElement(_chunkIUPBOWYOjs.PrefetchPageLinks, { page: href })) : link;
}
);
Link.displayName = "Link";
var NavLink = React.forwardRef(
function NavLinkWithRef({
"aria-current": ariaCurrentProp = "page",
caseSensitive = false,
className: classNameProp = "",
end = false,
style: styleProp,
to,
viewTransition,
children,
...rest
}, ref) {
let path = _chunkIUPBOWYOjs.useResolvedPath.call(void 0, to, { relative: rest.relative });
let location = _chunkIUPBOWYOjs.useLocation.call(void 0, );
let routerState = React.useContext(_chunkIUPBOWYOjs.DataRouterStateContext);
let { navigator, basename } = React.useContext(_chunkIUPBOWYOjs.NavigationContext);
let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
// eslint-disable-next-line react-hooks/rules-of-hooks
useViewTransitionState(path) && viewTransition === true;
let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
let locationPathname = location.pathname;
let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
if (!caseSensitive) {
locationPathname = locationPathname.toLowerCase();
nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
toPathname = toPathname.toLowerCase();
}
if (nextLocationPathname && basename) {
nextLocationPathname = _chunkIUPBOWYOjs.stripBasename.call(void 0, nextLocationPathname, basename) || nextLocationPathname;
}
const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
let renderProps = {
isActive,
isPending,
isTransitioning
};
let ariaCurrent = isActive ? ariaCurrentProp : void 0;
let className;
if (typeof classNameProp === "function") {
className = classNameProp(renderProps);
} else {
className = [
classNameProp,
isActive ? "active" : null,
isPending ? "pending" : null,
isTransitioning ? "transitioning" : null
].filter(Boolean).join(" ");
}
let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
return /* @__PURE__ */ React.createElement(
Link,
{
...rest,
"aria-current": ariaCurrent,
className,
ref,
style,
to,
viewTransition
},
typeof children === "function" ? children(renderProps) : children
);
}
);
NavLink.displayName = "NavLink";
var Form = React.forwardRef(
({
discover = "render",
fetcherKey,
navigate,
reloadDocument,
replace,
state,
method = defaultMethod,
action,
onSubmit,
relative,
preventScrollReset,
viewTransition,
defaultShouldRevalidate,
...props
}, forwardedRef) => {
let { useTransitions } = React.useContext(_chunkIUPBOWYOjs.NavigationContext);
let submit = useSubmit();
let formAction = useFormAction(action, { relative });
let formMethod = method.toLowerCase() === "get" ? "get" : "post";
let isAbsolute = typeof action === "string" && _chunkIUPBOWYOjs.ABSOLUTE_URL_REGEX.test(action);
let submitHandler = (event) => {
onSubmit && onSubmit(event);
if (event.defaultPrevented) return;
event.preventDefault();
let submitter = event.nativeEvent.submitter;
let submitMethod = _optionalChain([submitter, 'optionalAccess', _21 => _21.getAttribute, 'call', _22 => _22("formmethod")]) || method;
let doSubmit = () => submit(submitter || event.currentTarget, {
fetcherKey,
method: submitMethod,
navigate,
replace,
state,
relative,
preventScrollReset,
viewTransition,
defaultShouldRevalidate
});
if (useTransitions && navigate !== false) {
React.startTransition(() => doSubmit());
} else {
doSubmit();
}
};
return /* @__PURE__ */ React.createElement(
"form",
{
ref: forwardedRef,
method: formMethod,
action: formAction,
onSubmit: reloadDocument ? onSubmit : submitHandler,
...props,
"data-discover": !isAbsolute && discover === "render" ? "true" : void 0
}
);
}
);
Form.displayName = "Form";
function ScrollRestoration({
getKey,
storageKey,
...props
}) {
let remixContext = React.useContext(_chunkIUPBOWYOjs.FrameworkContext);
let { basename } = React.useContext(_chunkIUPBOWYOjs.NavigationContext);
let location = _chunkIUPBOWYOjs.useLocation.call(void 0, );
let matches = _chunkIUPBOWYOjs.useMatches.call(void 0, );
useScrollRestoration({ getKey, storageKey });
let ssrKey = React.useMemo(
() => {
if (!remixContext || !getKey) return null;
let userKey = getScrollRestorationKey(
location,
matches,
basename,
getKey
);
return userKey !== location.key ? userKey : null;
},
// Nah, we only need this the first time for the SSR render
// eslint-disable-next-line react-hooks/exhaustive-deps
[]
);
if (!remixContext || remixContext.isSpaMode) {
return null;
}
let restoreScroll = ((storageKey2, restoreKey) => {
if (!window.history.state || !window.history.state.key) {
let key = Math.random().toString(32).slice(2);
window.history.replaceState({ key }, "");
}
try {
let positions = JSON.parse(sessionStorage.getItem(storageKey2) || "{}");
let storedY = positions[restoreKey || window.history.state.key];
if (typeof storedY === "number") {
window.scrollTo(0, storedY);
}
} catch (error) {
console.error(error);
sessionStorage.removeItem(storageKey2);
}
}).toString();
if (props.nonce == null && _optionalChain([remixContext, 'optionalAccess', _23 => _23.nonce])) {
props.nonce = remixContext.nonce;
}
return /* @__PURE__ */ React.createElement(
"script",
{
...props,
suppressHydrationWarning: true,
dangerouslySetInnerHTML: {
__html: `(${restoreScroll})(${_chunkIUPBOWYOjs.escapeHtml.call(void 0,
JSON.stringify(storageKey || SCROLL_RESTORATION_STORAGE_KEY)
)}, ${_chunkIUPBOWYOjs.escapeHtml.call(void 0, JSON.stringify(ssrKey))})`
}
}
);
}
ScrollRestoration.displayName = "ScrollRestoration";
function getDataRouterConsoleError(hookName) {
return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
}
function useDataRouterContext(hookName) {
let ctx = React.useContext(_chunkIUPBOWYOjs.DataRouterContext);
_chunkIUPBOWYOjs.invariant.call(void 0, ctx, getDataRouterConsoleError(hookName));
return ctx;
}
function useDataRouterState(hookName) {
let state = React.useContext(_chunkIUPBOWYOjs.DataRouterStateContext);
_chunkIUPBOWYOjs.invariant.call(void 0, state, getDataRouterConsoleError(hookName));
return state;
}
function useLinkClickHandler(to, {
target,
replace: replaceProp,
mask,
state,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
} = {}) {
let navigate = _chunkIUPBOWYOjs.useNavigate.call(void 0, );
let location = _chunkIUPBOWYOjs.useLocation.call(void 0, );
let path = _chunkIUPBOWYOjs.useResolvedPath.call(void 0, to, { relative });
return React.useCallback(
(event) => {
if (shouldProcessLinkClick(event, target)) {
event.preventDefault();
let replace = replaceProp !== void 0 ? replaceProp : _chunkIUPBOWYOjs.createPath.call(void 0, location) === _chunkIUPBOWYOjs.createPath.call(void 0, path);
let doNavigate = () => navigate(to, {
replace,
mask,
state,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate
});
if (useTransitions) {
React.startTransition(() => doNavigate());
} else {
doNavigate();
}
}
},
[
location,
navigate,
path,
replaceProp,
mask,
state,
target,
to,
preventScrollReset,
relative,
viewTransition,
defaultShouldRevalidate,
useTransitions
]
);
}
function useSearchParams(defaultInit) {
_chunkIUPBOWYOjs.warning.call(void 0,
typeof URLSearchParams !== "undefined",
`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.`
);
let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
let hasSetSearchParamsRef = React.useRef(false);
let location = _chunkIUPBOWYOjs.useLocation.call(void 0, );
let searchParams = React.useMemo(
() => (
// Only merge in the defaults if we haven't yet called setSearchParams.
// Once we call that we want those to take precedence, otherwise you can't
// remove a param with setSearchParams({}) if it has an initial value
getSearchParamsForLocation(
location.search,
hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current
)
),
[location.search]
);
let navigate = _chunkIUPBOWYOjs.useNavigate.call(void 0, );
let setSearchParams = React.useCallback(
(nextInit, navigateOptions) => {
const newSearchParams = createSearchParams(
typeof nextInit === "function" ? nextInit(new URLSearchParams(searchParams)) : nextInit
);
hasSetSearchParamsRef.current = true;
navigate("?" + newSearchParams, navigateOptions);
},
[navigate, searchParams]
);
return [searchParams, setSearchParams];
}
var fetcherId = 0;
var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
function useSubmit() {
let { router } = useDataRouterContext("useSubmit" /* UseSubmit */);
let { basename } = React.useContext(_chunkIUPBOWYOjs.NavigationContext);
let currentRouteId = _chunkIUPBOWYOjs.useRouteId.call(void 0, );
let routerFetch = router.fetch;
let routerNavigate = router.navigate;
return React.useCallback(
async (target, options = {}) => {
let { action, method, encType, formData, body } = getFormSubmissionInfo(
target,
basename
);
if (options.navigate === false) {
let key = options.fetcherKey || getUniqueFetcherId();
await routerFetch(key, currentRouteId, options.action || action, {
defaultShouldRevalidate: options.defaultShouldRevalidate,
preventScrollReset: options.preventScrollReset,
formData,
body,
formMethod: options.method || method,
formEncType: options.encType || encType,
flushSync: options.flushSync
});
} else {
await routerNavigate(options.action || action, {
defaultShouldRevalidate: options.defaultShouldRevalidate,
preventScrollReset: options.preventScrollReset,
formData,
body,
formMethod: options.method || method,
formEncType: options.encType || encType,
replace: options.replace,
state: options.state,
fromRouteId: currentRouteId,
flushSync: options.flushSync,
viewTransition: options.viewTransition
});
}
},
[routerFetch, routerNavigate, basename, currentRouteId]
);
}
function useFormAction(action, { relative } = {}) {
let { basename } = React.useContext(_chunkIUPBOWYOjs.NavigationContext);
let routeContext = React.useContext(_chunkIUPBOWYOjs.RouteContext);
_chunkIUPBOWYOjs.invariant.call(void 0, routeContext, "useFormAction must be used inside a RouteContext");
let [match] = routeContext.matches.slice(-1);
let path = { ..._chunkIUPBOWYOjs.useResolvedPath.call(void 0, action ? action : ".", { relative }) };
let location = _chunkIUPBOWYOjs.useLocation.call(void 0, );
if (action == null) {
path.search = location.search;
let params = new URLSearchParams(path.search);
let indexValues = params.getAll("index");
let hasNakedIndexParam = indexValues.some((v) => v === "");
if (hasNakedIndexParam) {
params.delete("index");
indexValues.filter((v) => v).forEach((v) => params.append("index", v));
let qs = params.toString();
path.search = qs ? `?${qs}` : "";
}
}
if ((!action || action === ".") && match.route.index) {
path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
}
if (basename !== "/") {
path.pathname = path.pathname === "/" ? basename : _chunkIUPBOWYOjs.joinPaths.call(void 0, [basename, path.pathname]);
}
return _chunkIUPBOWYOjs.createPath.call(void 0, path);
}
function useFetcher({
key
} = {}) {
let { router } = useDataRouterContext("useFetcher" /* UseFetcher */);
let state = useDataRouterState("useFetcher" /* UseFetcher */);
let fetcherData = React.useContext(_chunkIUPBOWYOjs.FetchersContext);
let route = React.useContext(_chunkIUPBOWYOjs.RouteContext);
let routeId = _optionalChain([route, 'access', _24 => _24.matches, 'access', _25 => _25[route.matches.length - 1], 'optionalAccess', _26 => _26.route, 'access', _27 => _27.id]);
_chunkIUPBOWYOjs.invariant.call(void 0, fetcherData, `useFetcher must be used inside a FetchersContext`);
_chunkIUPBOWYOjs.invariant.call(void 0, route, `useFetcher must be used inside a RouteContext`);
_chunkIUPBOWYOjs.invariant.call(void 0,
routeId != null,
`useFetcher can only be used on routes that contain a unique "id"`
);
let defaultKey = React.useId();
let [fetcherKey, setFetcherKey] = React.useState(key || defaultKey);
if (key && key !== fetcherKey) {
setFetcherKey(key);
}
let { deleteFetcher, getFetcher, resetFetcher, fetch: routerFetch } = router;
React.useEffect(() => {
getFetcher(fetcherKey);
return () => deleteFetcher(fetcherKey);
}, [deleteFetcher, getFetcher, fetcherKey]);
let load = React.useCallback(
async (href, opts) => {
_chunkIUPBOWYOjs.invariant.call(void 0, routeId, "No routeId available for fetcher.load()");
await routerFetch(fetcherKey, routeId, href, opts);
},
[fetcherKey, routeId, routerFetch]
);
let submitImpl = useSubmit();
let submit = React.useCallback(
async (target, opts) => {
await submitImpl(target, {
...opts,
navigate: false,
fetcherKey
});
},
[fetcherKey, submitImpl]
);
let reset = React.useCallback(
(opts) => resetFetcher(fetcherKey, opts),
[resetFetcher, fetcherKey]
);
let FetcherForm = React.useMemo(() => {
let FetcherForm2 = React.forwardRef(
(props, ref) => {
return /* @__PURE__ */ React.createElement(Form, { ...props, navigate: false, fetcherKey, ref });
}
);
FetcherForm2.displayName = "fetcher.Form";
return FetcherForm2;
}, [fetcherKey]);
let fetcher = state.fetchers.get(fetcherKey) || _chunkIUPBOWYOjs.IDLE_FETCHER;
let data = fetcherData.get(fetcherKey);
let fetcherWithComponents = React.useMemo(
() => ({
Form: FetcherForm,
submit,
load,
reset,
...fetcher,
data
}),
[FetcherForm, submit, load, reset, fetcher, data]
);
return fetcherWithComponents;
}
function useFetchers() {
let state = useDataRouterState("useFetchers" /* UseFetchers */);
return React.useMemo(
() => Array.from(state.fetchers.entries()).map(([key, fetcher]) => ({
...fetcher,
key
})),
[state.fetchers]
);
}
var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
var savedScrollPositions = {};
function getScrollRestorationKey(location, matches, basename, getKey) {
let key = null;
if (getKey) {
if (basename !== "/") {
key = getKey(
{
...location,
pathname: _chunkIUPBOWYOjs.stripBasename.call(void 0, location.pathname, basename) || location.pathname
},
matches
);
} else {
key = getKey(location, matches);
}
}
if (key == null) {
key = location.key;
}
return key;
}
function useScrollRestoration({
getKey,
storageKey
} = {}) {
let { router } = useDataRouterContext("useScrollRestoration" /* UseScrollRestoration */);
let { restoreScrollPosition, preventScrollReset } = useDataRouterState(
"useScrollRestoration" /* UseScrollRestoration */
);
let { basename } = React.useContext(_chunkIUPBOWYOjs.NavigationContext);
let location = _chunkIUPBOWYOjs.useLocation.call(void 0, );
let matches = _chunkIUPBOWYOjs.useMatches.call(void 0, );
let navigation = _chunkIUPBOWYOjs.useNavigation.call(void 0, );
React.useEffect(() => {
window.history.scrollRestoration = "manual";
return () => {
window.history.scrollRestoration = "auto";
};
}, []);
usePageHide(
React.useCallback(() => {
if (navigation.state === "idle") {
let key = getScrollRestorationKey(location, matches, basename, getKey);
savedScrollPositions[key] = window.scrollY;
}
try {
sessionStorage.setItem(
storageKey || SCROLL_RESTORATION_STORAGE_KEY,
JSON.stringify(savedScrollPositions)
);
} catch (error) {
_chunkIUPBOWYOjs.warning.call(void 0,
false,
`Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (${error}).`
);
}
window.history.scrollRestoration = "auto";
}, [navigation.state, getKey, basename, location, matches, storageKey])
);
if (typeof document !== "undefined") {
React.useLayoutEffect(() => {
try {
let sessionPositions = sessionStorage.getItem(
storageKey || SCROLL_RESTORATION_STORAGE_KEY
);
if (sessionPositions) {
savedScrollPositions = JSON.parse(sessionPositions);
}
} catch (e) {
}
}, [storageKey]);
React.useLayoutEffect(() => {
let disableScrollRestoration = _optionalChain([router, 'optionalAccess', _28 => _28.enableScrollRestoration, 'call', _29 => _29(
savedScrollPositions,
() => window.scrollY,
getKey ? (location2, matches2) => getScrollRestorationKey(location2, matches2, basename, getKey) : void 0
)]);
return () => disableScrollRestoration && disableScrollRestoration();
}, [router, basename, getKey]);
React.useLayoutEffect(() => {
if (restoreScrollPosition === false) {
return;
}
if (typeof restoreScrollPosition === "number") {
window.scrollTo(0, restoreScrollPosition);
return;
}
try {
if (location.hash) {
let el = document.getElementById(
decodeURIComponent(location.hash.slice(1))
);
if (el) {
el.scrollIntoView();
return;
}
}
} catch (e2) {
_chunkIUPBOWYOjs.warning.call(void 0,
false,
`"${location.hash.slice(
1
)}" is not a decodable element ID. The view will not scroll to it.`
);
}
if (preventScrollReset === true) {
return;
}
window.scrollTo(0, 0);
}, [location, restoreScrollPosition, preventScrollReset]);
}
}
function useBeforeUnload(callback, options) {
let { capture } = options || {};
React.useEffect(() => {
let opts = capture != null ? { capture } : void 0;
window.addEventListener("beforeunload", callback, opts);
return () => {
window.removeEventListener("beforeunload", callback, opts);
};
}, [callback, capture]);
}
function usePageHide(callback, options) {
let { capture } = options || {};
React.useEffect(() => {
let opts = capture != null ? { capture } : void 0;
window.addEventListener("pagehide", callback, opts);
return () => {
window.removeEventListener("pagehide", callback, opts);
};
}, [callback, capture]);
}
function usePrompt({
when,
message
}) {
let blocker = _chunkIUPBOWYOjs.useBlocker.call(void 0, when);
React.useEffect(() => {
if (blocker.state === "blocked") {
let proceed = window.confirm(message);
if (proceed) {
setTimeout(blocker.proceed, 0);
} else {
blocker.reset();
}
}
}, [blocker, message]);
React.useEffect(() => {
if (blocker.state === "blocked" && !when) {
blocker.reset();
}
}, [blocker, when]);
}
function useViewTransitionState(to, { relative } = {}) {
let vtContext = React.useContext(_chunkIUPBOWYOjs.ViewTransitionContext);
_chunkIUPBOWYOjs.invariant.call(void 0,
vtContext != null,
"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
);
let { basename } = useDataRouterContext(
"useViewTransitionState" /* useViewTransitionState */
);
let path = _chunkIUPBOWYOjs.useResolvedPath.call(void 0, to, { relative });
if (!vtContext.isTransitioning) {
return false;
}
let currentPath = _chunkIUPBOWYOjs.stripBasename.call(void 0, vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
let nextPath = _chunkIUPBOWYOjs.stripBasename.call(void 0, vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
return _chunkIUPBOWYOjs.matchPath.call(void 0, path.pathname, nextPath) != null || _chunkIUPBOWYOjs.matchPath.call(void 0, path.pathname, currentPath) != null;
}
// lib/dom/server.tsx
function StaticRouter({
basename,
children,
location: locationProp = "/"
}) {
if (typeof locationProp === "string") {
locationProp = _chunkIUPBOWYOjs.parsePath.call(void 0, locationProp);
}
let action = "POP" /* Pop */;
let location = {
pathname: locationProp.pathname || "/",
search: locationProp.search || "",
hash: locationProp.hash || "",
state: locationProp.state != null ? locationProp.state : null,
key: locationProp.key || "default",
mask: void 0
};
let staticNavigator = getStatelessNavigator();
return /* @__PURE__ */ React2.createElement(
_chunkIUPBOWYOjs.Router,
{
basename,
children,
location,
navigationType: action,
navigator: staticNavigator,
static: true,
useTransitions: false
}
);
}
function StaticRouterProvider({
context,
router,
hydrate = true,
nonce
}) {
_chunkIUPBOWYOjs.invariant.call(void 0,
router && context,
"You must provide `router` and `context` to <StaticRouterProvider>"
);
let dataRouterContext = {
router,
navigator: getStatelessNavigator(),
static: true,
staticContext: context,
basename: context.basename || "/"
};
let fetchersContext = /* @__PURE__ */ new Map();
let hydrateScript = "";
if (hydrate !== false) {
let data = {
loaderData: context.loaderData,
actionData: context.actionData,
errors: serializeErrors(context.errors)
};
let json = _chunkIUPBOWYOjs.escapeHtml.call(void 0, JSON.stringify(JSON.stringify(data)));
hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
}
let { state } = dataRouterContext.router;
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(_chunkIUPBOWYOjs.DataRouterContext.Provider, { value: dataRouterContext }, /* @__PURE__ */ React2.createElement(_chunkIUPBOWYOjs.DataRouterStateContext.Provider, { value: state }, /* @__PURE__ */ React2.createElement(_chunkIUPBOWYOjs.FetchersContext.Provider, { value: fetchersContext }, /* @__PURE__ */ React2.createElement(_chunkIUPBOWYOjs.ViewTransitionContext.Provider, { value: { isTransitioning: false } }, /* @__PURE__ */ React2.createElement(
_chunkIUPBOWYOjs.Router,
{
basename: dataRouterContext.basename,
location: state.location,
navigationType: state.historyAction,
navigator: dataRouterContext.navigator,
static: dataRouterContext.static,
useTransitions: false
},
/* @__PURE__ */ React2.createElement(
_chunkIUPBOWYOjs.DataRoutes,
{
manifest: router.manifest,
routes: router.routes,
future: router.future,
state,
isStatic: true
}
)
))))), hydrateScript ? /* @__PURE__ */ React2.createElement(
"script",
{
suppressHydrationWarning: true,
nonce,
dangerouslySetInnerHTML: { __html: hydrateScript }
}
) : null);
}
function serializeErrors(errors) {
if (!errors) return null;
let entries = Object.entries(errors);
let serialized = {};
for (let [key, val] of entries) {
if (_chunkIUPBOWYOjs.isRouteErrorResponse.call(void 0, val)) {
serialized[key] = { ...val, __type: "RouteErrorResponse" };
} else if (val instanceof Error) {
serialized[key] = {
message: val.message,
__type: "Error",
// If this is a subclass (i.e., ReferenceError), send up the type so we
// can re-create the same type during hydration.
...val.name !== "Error" ? {
__subType: val.name
} : {}
};
} else {
serialized[key] = val;
}
}
return serialized;
}
function getStatelessNavigator() {
return {
createHref,
encodeLocation,
push(to) {
throw new Error(
`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.`
);
},
replace(to) {
throw new Error(
`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.`
);
},
go(delta) {
throw new Error(
`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.`
);
},
back() {
throw new Error(
`You cannot use navigator.back() on the server because it is a stateless environment.`
);
},
forward() {
throw new Error(
`You cannot use navigator.forward() on the server because it is a stateless environment.`
);
}
};
}
function createStaticHandler2(routes, opts) {
return _chunkIUPBOWYOjs.createStaticHandler.call(void 0, routes, {
...opts,
mapRouteProperties: _chunkIUPBOWYOjs.mapRouteProperties
});
}
function createStaticRouter(routes, context, opts = {}) {
let manifest = {};
let dataRoutes = _chunkIUPBOWYOjs.convertRoutesToDataRoutes.call(void 0,
routes,
_chunkIUPBOWYOjs.mapRouteProperties,
void 0,
manifest
);
let matches = context.matches.map((match) => {
let route = manifest[match.route.id] || match.route;
return {
...match,
route
};
});
let msg = (method) => `You cannot use router.${method}() on the server because it is a stateless environment`;
return {
get basename() {
return context.basename;
},
get future() {
return {
v8_middleware: false,
v8_passThroughRequests: false,
v8_trailingSlashAwareDataRequests: false,
..._optionalChain([opts, 'optionalAccess', _30 => _30.future])
};
},
get state() {
return {
historyAction: "POP" /* Pop */,
location: context.location,
matches,
loaderData: context.loaderData,
actionData: context.actionData,
errors: context.errors,
initialized: true,
renderFallback: false,
navigation: _chunkIUPBOWYOjs.IDLE_NAVIGATION,
restoreScrollPosition: null,
preventScrollReset: false,
revalidation: "idle",
fetchers: /* @__PURE__ */ new Map(),
blockers: /* @__PURE__ */ new Map()
};
},
get routes() {
return dataRoutes;
},
get branches() {
return opts.branches;
},
get manifest() {
return manifest;
},
get window() {
return void 0;
},
initialize() {
throw msg("initialize");
},
subscribe() {
throw msg("subscribe");
},
enableScrollRestoration() {
throw msg("enableScrollRestoration");
},
navigate() {
throw msg("navigate");
},
fetch() {
throw msg("fetch");
},
revalidate() {
throw msg("revalidate");
},
createHref,
encodeLocation,
getFetcher() {
return _chunkIUPBOWYOjs.IDLE_FETCHER;
},
deleteFetcher() {
throw msg("deleteFetcher");
},
resetFetcher() {
throw msg("resetFetcher");
},
dispose() {
throw msg("dispose");
},
getBlocker() {
return _chunkIUPBOWYOjs.IDLE_BLOCKER;
},
deleteBlocker() {
throw msg("deleteBlocker");
},
patchRoutes() {
throw msg("patchRoutes");
},
_internalFetchControllers: /* @__PURE__ */ new Map(),
_internalSetRoutes() {
throw msg("_internalSetRoutes");
},
_internalSetStateDoNotUseOrYouWillBreakYourApp() {
throw msg("_internalSetStateDoNotUseOrYouWillBreakYourApp");
}
};
}
function createHref(to) {
return typeof to === "string" ? to : _chunkIUPBOWYOjs.createPath.call(void 0, to);
}
function encodeLocation(to) {
let href = typeof to === "string" ? to : _chunkIUPBOWYOjs.createPath.call(void 0, to);
href = href.replace(/ $/, "%20");
let encoded = _chunkIUPBOWYOjs.ABSOLUTE_URL_REGEX.test(href) ? new URL(href) : new URL(href, "http://localhost");
return {
pathname: encoded.pathname,
search: encoded.search,
hash: encoded.hash
};
}
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;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display