@workflow/web 4.1.28 → 4.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/build/client/assets/{encryption-CVDhlDp_.js → encryption-Cu4jq70Y.js} +2 -2
  2. package/build/client/assets/{entry.client-C_C46bD6.js → entry.client-C7XgFTHI.js} +7 -205
  3. package/build/client/assets/{highlighted-body-B3W2YXNL-DNE7dweN.js → highlighted-body-B3W2YXNL-B6-MkXV1.js} +2 -2
  4. package/build/client/assets/{home-BcCTbe4i.js → home-Yy5gk_jJ.js} +4 -4
  5. package/build/client/assets/{index-BsV8i_Jn.js → index-BQ-Xa8kF.js} +769 -330
  6. package/build/client/assets/{index-DhdkuKp5.js → index-CXBr7N7m.js} +1 -1
  7. package/build/client/assets/{manifest-f88c7f34.js → manifest-e13ef35a.js} +1 -1
  8. package/build/client/assets/{mermaid-3ZIDBTTL-B1-N6W83.js → mermaid-3ZIDBTTL-DV4S4pTo.js} +7 -7
  9. package/build/client/assets/{root-C2Eu3fUP.js → root-DQQlQnXn.js} +2 -2
  10. package/build/client/assets/{run-detail-CyImB2zR.js → run-detail-rocfw9Z5.js} +5 -5
  11. package/build/client/assets/{workflow-graph-viewer-lj3vdGSs.js → workflow-graph-viewer-De_-9tJh.js} +3 -3
  12. package/build/server/assets/{app-BAmhYum_.js → app-juehGONX.js} +891 -613
  13. package/build/server/assets/{highlighted-body-B3W2YXNL-D2bE_zLh.js → highlighted-body-B3W2YXNL-DgD9LFQJ.js} +4 -2
  14. package/build/server/assets/index-BUlN7QFn.js +1164 -0
  15. package/build/server/assets/{index-Tv6_4f6I.js → index-C1by_z-e.js} +5 -3
  16. package/build/server/assets/{mermaid-3ZIDBTTL-Dn3iLq1N.js → mermaid-3ZIDBTTL-DBfS-ZH8.js} +4 -2
  17. package/build/server/assets/{server-build-D38evYCr.js → server-build-CgjoLYPd.js} +1797 -68
  18. package/build/server/assets/{token-lgwgo3i8.js → token-CP9u68ZL.js} +2 -2
  19. package/build/server/assets/{token-util-BzAlruRH.js → token-util-BrBJCxub.js} +2 -2
  20. package/build/server/index.js +2 -2
  21. package/package.json +9 -9
  22. package/build/server/assets/index-hBO56emR.js +0 -1286
@@ -26,6 +26,7 @@ function _mergeNamespaces(n, m) {
26
26
  }
27
27
  return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
28
28
  }
29
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
29
30
  function getDefaultExportFromCjs(x) {
30
31
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
31
32
  }
@@ -92,13 +93,13 @@ function requireReact_production() {
92
93
  assign(pureComponentPrototype, Component.prototype);
93
94
  pureComponentPrototype.isPureReactComponent = true;
94
95
  var isArrayImpl = Array.isArray, ReactSharedInternals = { H: null, A: null, T: null, S: null, V: null }, hasOwnProperty = Object.prototype.hasOwnProperty;
95
- function ReactElement(type, key, self, source, owner, props) {
96
- self = props.ref;
96
+ function ReactElement(type, key, self2, source, owner, props) {
97
+ self2 = props.ref;
97
98
  return {
98
99
  $$typeof: REACT_ELEMENT_TYPE,
99
100
  type,
100
101
  key,
101
- ref: void 0 !== self ? self : null,
102
+ ref: void 0 !== self2 ? self2 : null,
102
103
  props
103
104
  };
104
105
  }
@@ -641,8 +642,8 @@ function requireReact_development() {
641
642
  componentName = this.props.ref;
642
643
  return void 0 !== componentName ? componentName : null;
643
644
  }
644
- function ReactElement(type, key, self, source, owner, props, debugStack, debugTask) {
645
- self = props.ref;
645
+ function ReactElement(type, key, self2, source, owner, props, debugStack, debugTask) {
646
+ self2 = props.ref;
646
647
  type = {
647
648
  $$typeof: REACT_ELEMENT_TYPE,
648
649
  type,
@@ -650,7 +651,7 @@ function requireReact_development() {
650
651
  props,
651
652
  _owner: owner
652
653
  };
653
- null !== (void 0 !== self ? self : null) ? Object.defineProperty(type, "ref", {
654
+ null !== (void 0 !== self2 ? self2 : null) ? Object.defineProperty(type, "ref", {
654
655
  enumerable: false,
655
656
  get: elementRefGetterWithDeprecationWarning
656
657
  }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
@@ -1439,7 +1440,7 @@ const React = /* @__PURE__ */ _mergeNamespaces({
1439
1440
  default: ReactExports
1440
1441
  }, [reactExports]);
1441
1442
  /**
1442
- * react-router v7.13.1
1443
+ * react-router v7.18.4
1443
1444
  *
1444
1445
  * Copyright (c) Remix Software Inc.
1445
1446
  *
@@ -1454,6 +1455,11 @@ var __typeError = (msg) => {
1454
1455
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
1455
1456
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
1456
1457
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
1458
+ var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i;
1459
+ var PROTOCOL_RELATIVE_URL_REGEX = /^[\\/]{2}/;
1460
+ function normalizeProtocolRelativeUrl(url, protocol) {
1461
+ return protocol + url.replace(/\\/g, "/");
1462
+ }
1457
1463
  function invariant$1(value, message) {
1458
1464
  if (value === false || value === null || typeof value === "undefined") {
1459
1465
  throw new Error(message);
@@ -1471,7 +1477,7 @@ function warning(cond, message) {
1471
1477
  function createKey() {
1472
1478
  return Math.random().toString(36).substring(2, 10);
1473
1479
  }
1474
- function createLocation(current, to, state = null, key, unstable_mask) {
1480
+ function createLocation(current, to, state = null, key, mask) {
1475
1481
  let location = {
1476
1482
  pathname: typeof current === "string" ? current : current.pathname,
1477
1483
  search: "",
@@ -1483,7 +1489,7 @@ function createLocation(current, to, state = null, key, unstable_mask) {
1483
1489
  // But that's a pretty big refactor to the current test suite so going to
1484
1490
  // keep as is for the time being and just let any incoming keys take precedence
1485
1491
  key: to && to.key || key || createKey(),
1486
- unstable_mask
1492
+ mask
1487
1493
  };
1488
1494
  return location;
1489
1495
  }
@@ -1650,17 +1656,16 @@ function mergeRouteUpdates(route, updates) {
1650
1656
  function matchRoutes(routes, locationArg, basename = "/") {
1651
1657
  return matchRoutesImpl(routes, locationArg, basename, false);
1652
1658
  }
1653
- function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
1659
+ function matchRoutesImpl(routes, locationArg, basename, allowPartial, precomputedBranches) {
1654
1660
  let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
1655
1661
  let pathname = stripBasename(location.pathname || "/", basename);
1656
1662
  if (pathname == null) {
1657
1663
  return null;
1658
1664
  }
1659
- let branches = flattenRoutes(routes);
1660
- rankRouteBranches(branches);
1665
+ let branches = precomputedBranches ?? flattenAndRankRoutes(routes);
1661
1666
  let matches = null;
1667
+ let decoded = decodePath(pathname);
1662
1668
  for (let i = 0; matches == null && i < branches.length; ++i) {
1663
- let decoded = decodePath(pathname);
1664
1669
  matches = matchRouteBranch(
1665
1670
  branches[i],
1666
1671
  decoded,
@@ -1680,6 +1685,11 @@ function convertRouteMatchToUiMatch(match, loaderData) {
1680
1685
  handle: route.handle
1681
1686
  };
1682
1687
  }
1688
+ function flattenAndRankRoutes(routes) {
1689
+ let branches = flattenRoutes(routes);
1690
+ rankRouteBranches(branches);
1691
+ return branches;
1692
+ }
1683
1693
  function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
1684
1694
  let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
1685
1695
  let meta = {
@@ -1721,7 +1731,18 @@ function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "",
1721
1731
  branches.push({
1722
1732
  path,
1723
1733
  score: computeScore(path, route.index),
1724
- routesMeta
1734
+ routesMeta: routesMeta.map((meta2, i) => {
1735
+ let [matcher, params] = compilePath(
1736
+ meta2.relativePath,
1737
+ meta2.caseSensitive,
1738
+ i === routesMeta.length - 1
1739
+ );
1740
+ return {
1741
+ ...meta2,
1742
+ matcher,
1743
+ compiledParams: params
1744
+ };
1745
+ })
1725
1746
  });
1726
1747
  };
1727
1748
  routes.forEach((route, index) => {
@@ -1811,9 +1832,19 @@ function matchRouteBranch(branch, pathname, allowPartial = false) {
1811
1832
  let meta = routesMeta[i];
1812
1833
  let end = i === routesMeta.length - 1;
1813
1834
  let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
1814
- let match = matchPath(
1815
- { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
1816
- remainingPathname
1835
+ let pattern = {
1836
+ path: meta.relativePath,
1837
+ caseSensitive: meta.caseSensitive,
1838
+ end
1839
+ };
1840
+ let match = (
1841
+ // Use precomputed matcher if it exists
1842
+ meta.matcher && meta.compiledParams ? matchPathImpl(
1843
+ pattern,
1844
+ remainingPathname,
1845
+ meta.matcher,
1846
+ meta.compiledParams
1847
+ ) : matchPath(pattern, remainingPathname)
1817
1848
  );
1818
1849
  let route = meta.route;
1819
1850
  if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
@@ -1854,16 +1885,22 @@ function matchPath(pattern, pathname) {
1854
1885
  pattern.caseSensitive,
1855
1886
  pattern.end
1856
1887
  );
1888
+ return matchPathImpl(pattern, pathname, matcher, compiledParams);
1889
+ }
1890
+ function matchPathImpl(pattern, pathname, matcher, compiledParams) {
1857
1891
  let match = pathname.match(matcher);
1858
1892
  if (!match) return null;
1859
1893
  let matchedPathname = match[0];
1860
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
1894
+ let pathnameBase = removeTrailingSlash(matchedPathname, 1);
1861
1895
  let captureGroups = match.slice(1);
1862
1896
  let params = compiledParams.reduce(
1863
1897
  (memo2, { paramName, isOptional }, index) => {
1864
1898
  if (paramName === "*") {
1865
1899
  let splatValue = captureGroups[index] || "";
1866
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
1900
+ pathnameBase = removeTrailingSlash(
1901
+ matchedPathname.slice(0, matchedPathname.length - splatValue.length),
1902
+ 1
1903
+ );
1867
1904
  }
1868
1905
  const value = captureGroups[index];
1869
1906
  if (isOptional && !value) {
@@ -1942,7 +1979,6 @@ function prependBasename({
1942
1979
  }) {
1943
1980
  return pathname === "/" ? basename : joinPaths([basename, pathname]);
1944
1981
  }
1945
- var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1946
1982
  var isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX.test(url);
1947
1983
  function resolvePath(to, fromPathname = "/") {
1948
1984
  let {
@@ -1952,8 +1988,8 @@ function resolvePath(to, fromPathname = "/") {
1952
1988
  } = typeof to === "string" ? parsePath(to) : to;
1953
1989
  let pathname;
1954
1990
  if (toPathname) {
1955
- toPathname = toPathname.replace(/\/\/+/g, "/");
1956
- if (toPathname.startsWith("/")) {
1991
+ toPathname = removeDoubleSlashes(toPathname);
1992
+ if (toPathname.startsWith("/") || toPathname.startsWith("\\")) {
1957
1993
  pathname = resolvePathname(toPathname.substring(1), "/");
1958
1994
  } else {
1959
1995
  pathname = resolvePathname(toPathname, fromPathname);
@@ -1968,7 +2004,7 @@ function resolvePath(to, fromPathname = "/") {
1968
2004
  };
1969
2005
  }
1970
2006
  function resolvePathname(relativePath, fromPathname) {
1971
- let segments = fromPathname.replace(/\/+$/, "").split("/");
2007
+ let segments = removeTrailingSlash(fromPathname).split("/");
1972
2008
  let relativeSegments = relativePath.split("/");
1973
2009
  relativeSegments.forEach((segment) => {
1974
2010
  if (segment === "..") {
@@ -2039,8 +2075,16 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = fal
2039
2075
  }
2040
2076
  return path;
2041
2077
  }
2042
- var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
2043
- var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
2078
+ var removeDoubleSlashes = (path) => path.replace(/[\\/]{2,}/g, "/");
2079
+ var joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
2080
+ function removeTrailingSlash(path, minLength = 0) {
2081
+ let end = path.length;
2082
+ while (end > minLength && path.charCodeAt(end - 1) === 47) {
2083
+ end--;
2084
+ }
2085
+ return end === path.length ? path : path.slice(0, end);
2086
+ }
2087
+ var normalizePathname = (pathname) => removeTrailingSlash(pathname).replace(/^\/*/, "/");
2044
2088
  var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
2045
2089
  var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
2046
2090
  var redirect = (url, init = 302) => {
@@ -2064,6 +2108,14 @@ var replace = (url, init) => {
2064
2108
  response.headers.set("X-Remix-Replace", "true");
2065
2109
  return response;
2066
2110
  };
2111
+ var SUPPORTED_ERROR_TYPES = [
2112
+ "EvalError",
2113
+ "RangeError",
2114
+ "ReferenceError",
2115
+ "SyntaxError",
2116
+ "TypeError",
2117
+ "URIError"
2118
+ ];
2067
2119
  var ErrorResponseImpl = class {
2068
2120
  constructor(status, statusText, data2, internal = false) {
2069
2121
  this.status = status;
@@ -2081,7 +2133,8 @@ function isRouteErrorResponse(error) {
2081
2133
  return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
2082
2134
  }
2083
2135
  function getRoutePattern(matches) {
2084
- return matches.map((m) => m.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
2136
+ let parts = matches.map((m) => m.route.path).filter(Boolean);
2137
+ return joinPaths(parts) || "/";
2085
2138
  }
2086
2139
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
2087
2140
  function parseToInfo(_to, basename) {
@@ -2098,7 +2151,7 @@ function parseToInfo(_to, basename) {
2098
2151
  if (isBrowser) {
2099
2152
  try {
2100
2153
  let currentUrl = new URL(window.location.href);
2101
- let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
2154
+ let targetUrl = PROTOCOL_RELATIVE_URL_REGEX.test(to) ? new URL(normalizeProtocolRelativeUrl(to, currentUrl.protocol)) : new URL(to);
2102
2155
  let path = stripBasename(targetUrl.pathname, basename);
2103
2156
  if (targetUrl.origin === currentUrl.origin && path != null) {
2104
2157
  to = path + targetUrl.search + targetUrl.hash;
@@ -2290,11 +2343,11 @@ async function recurseRight(impls, info, handler, index) {
2290
2343
  };
2291
2344
  }
2292
2345
  function getHandlerInfo(args) {
2293
- let { request, context, params, unstable_pattern } = args;
2346
+ let { request, context, params, pattern } = args;
2294
2347
  return {
2295
2348
  request: getReadonlyRequest(request),
2296
2349
  params: { ...params },
2297
- unstable_pattern,
2350
+ pattern,
2298
2351
  context: getReadonlyContext(context)
2299
2352
  };
2300
2353
  }
@@ -2326,6 +2379,49 @@ function isPlainObject(thing) {
2326
2379
  const proto = Object.getPrototypeOf(thing);
2327
2380
  return proto === Object.prototype || proto === null || Object.getOwnPropertyNames(proto).sort().join("\0") === objectProtoNames;
2328
2381
  }
2382
+ var DEFAULT_NAVIGATION_URL = new URL("http://localhost");
2383
+ function getNavigatorCurrentUrl(navigator) {
2384
+ if (navigator.createURL) {
2385
+ return navigator.createURL("/");
2386
+ }
2387
+ try {
2388
+ return new URL(navigator.createHref("/"), DEFAULT_NAVIGATION_URL);
2389
+ } catch {
2390
+ return DEFAULT_NAVIGATION_URL;
2391
+ }
2392
+ }
2393
+ function isSameOrigin(a, b) {
2394
+ return a.origin === b.origin && (a.origin !== "null" || a.protocol === b.protocol && a.host === b.host);
2395
+ }
2396
+ function isExplicitUrl(destination, target) {
2397
+ if (destination.startsWith("//")) {
2398
+ return true;
2399
+ }
2400
+ let protocol = target.protocol.toLowerCase();
2401
+ if (!destination.toLowerCase().startsWith(protocol)) {
2402
+ return false;
2403
+ }
2404
+ return target.host === "" || destination.slice(protocol.length).startsWith("//");
2405
+ }
2406
+ function validateNavigationTarget(original, resolved, currentUrl, externalPolicy) {
2407
+ let originalUrl = null;
2408
+ try {
2409
+ originalUrl = original == null ? null : new URL(original, currentUrl);
2410
+ } catch {
2411
+ }
2412
+ let resolvedUrl = new URL(resolved, currentUrl);
2413
+ let originalIsExternal = originalUrl != null && !isSameOrigin(originalUrl, currentUrl);
2414
+ let resolvedIsExternal = !isSameOrigin(resolvedUrl, currentUrl);
2415
+ if (externalPolicy === "reject") {
2416
+ if (originalIsExternal || resolvedIsExternal) {
2417
+ throw new Error("External navigation is not allowed");
2418
+ }
2419
+ } else if (resolvedIsExternal) {
2420
+ if (originalUrl == null || !isExplicitUrl(original, originalUrl) || !isSameOrigin(originalUrl, resolvedUrl)) {
2421
+ throw new Error("External navigation is not allowed");
2422
+ }
2423
+ }
2424
+ }
2329
2425
  var validMutationMethodsArr = [
2330
2426
  "POST",
2331
2427
  "PUT",
@@ -2344,6 +2440,8 @@ var redirectStatusCodes = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
2344
2440
  var IDLE_NAVIGATION = {
2345
2441
  state: "idle",
2346
2442
  location: void 0,
2443
+ matches: void 0,
2444
+ historyAction: void 0,
2347
2445
  formMethod: void 0,
2348
2446
  formAction: void 0,
2349
2447
  formEncType: void 0,
@@ -2380,8 +2478,11 @@ function createStaticHandler(routes, opts) {
2380
2478
  let basename = (opts ? opts.basename : null) || "/";
2381
2479
  let _mapRouteProperties = (opts == null ? void 0 : opts.mapRouteProperties) || defaultMapRouteProperties;
2382
2480
  let mapRouteProperties2 = _mapRouteProperties;
2383
- if (opts == null ? void 0 : opts.unstable_instrumentations) {
2384
- let instrumentations = opts.unstable_instrumentations;
2481
+ ({
2482
+ ...opts == null ? void 0 : opts.future
2483
+ });
2484
+ if (opts == null ? void 0 : opts.instrumentations) {
2485
+ let instrumentations = opts.instrumentations;
2385
2486
  mapRouteProperties2 = (route) => {
2386
2487
  return {
2387
2488
  ..._mapRouteProperties(route),
@@ -2398,18 +2499,31 @@ function createStaticHandler(routes, opts) {
2398
2499
  void 0,
2399
2500
  manifest
2400
2501
  );
2502
+ let routeBranches = flattenAndRankRoutes(dataRoutes);
2401
2503
  async function query(request, {
2402
2504
  requestContext,
2403
2505
  filterMatchesToLoad,
2404
2506
  skipLoaderErrorBubbling,
2405
2507
  skipRevalidation,
2406
2508
  dataStrategy,
2407
- generateMiddlewareResponse
2509
+ generateMiddlewareResponse,
2510
+ normalizePath
2408
2511
  } = {}) {
2409
- let url = new URL(request.url);
2512
+ let normalizePathImpl = normalizePath || defaultNormalizePath;
2410
2513
  let method = request.method;
2411
- let location = createLocation("", createPath(url), null, "default");
2412
- let matches = matchRoutes(dataRoutes, location, basename);
2514
+ let location = createLocation(
2515
+ "",
2516
+ normalizePathImpl(request),
2517
+ null,
2518
+ "default"
2519
+ );
2520
+ let matches = matchRoutesImpl(
2521
+ dataRoutes,
2522
+ location,
2523
+ basename,
2524
+ false,
2525
+ routeBranches
2526
+ );
2413
2527
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
2414
2528
  if (!isValidMethod(method) && method !== "HEAD") {
2415
2529
  let error = getInternalRouterError(405, { method });
@@ -2461,7 +2575,8 @@ function createStaticHandler(routes, opts) {
2461
2575
  let response = await runServerMiddlewarePipeline(
2462
2576
  {
2463
2577
  request,
2464
- unstable_pattern: getRoutePattern(matches),
2578
+ url: createDataFunctionUrl(request, location),
2579
+ pattern: getRoutePattern(matches),
2465
2580
  matches,
2466
2581
  params: matches[0].params,
2467
2582
  // If we're calling middleware then it must be enabled so we can cast
@@ -2578,12 +2693,24 @@ function createStaticHandler(routes, opts) {
2578
2693
  routeId,
2579
2694
  requestContext,
2580
2695
  dataStrategy,
2581
- generateMiddlewareResponse
2696
+ generateMiddlewareResponse,
2697
+ normalizePath
2582
2698
  } = {}) {
2583
- let url = new URL(request.url);
2699
+ let normalizePathImpl = normalizePath || defaultNormalizePath;
2584
2700
  let method = request.method;
2585
- let location = createLocation("", createPath(url), null, "default");
2586
- let matches = matchRoutes(dataRoutes, location, basename);
2701
+ let location = createLocation(
2702
+ "",
2703
+ normalizePathImpl(request),
2704
+ null,
2705
+ "default"
2706
+ );
2707
+ let matches = matchRoutesImpl(
2708
+ dataRoutes,
2709
+ location,
2710
+ basename,
2711
+ false,
2712
+ routeBranches
2713
+ );
2587
2714
  requestContext = requestContext != null ? requestContext : new RouterContextProvider();
2588
2715
  if (!isValidMethod(method) && method !== "HEAD" && method !== "OPTIONS") {
2589
2716
  throw getInternalRouterError(405, { method });
@@ -2608,7 +2735,8 @@ function createStaticHandler(routes, opts) {
2608
2735
  let response = await runServerMiddlewarePipeline(
2609
2736
  {
2610
2737
  request,
2611
- unstable_pattern: getRoutePattern(matches),
2738
+ url: createDataFunctionUrl(request, location),
2739
+ pattern: getRoutePattern(matches),
2612
2740
  matches,
2613
2741
  params: matches[0].params,
2614
2742
  // If we're calling middleware then it must be enabled so we can cast
@@ -2685,6 +2813,7 @@ function createStaticHandler(routes, opts) {
2685
2813
  if (isMutationMethod(request.method)) {
2686
2814
  let result2 = await submit(
2687
2815
  request,
2816
+ location,
2688
2817
  matches,
2689
2818
  routeMatch || getTargetMatch(matches, location),
2690
2819
  requestContext,
@@ -2698,6 +2827,7 @@ function createStaticHandler(routes, opts) {
2698
2827
  }
2699
2828
  let result = await loadRouteData(
2700
2829
  request,
2830
+ location,
2701
2831
  matches,
2702
2832
  requestContext,
2703
2833
  dataStrategy,
@@ -2723,7 +2853,7 @@ function createStaticHandler(routes, opts) {
2723
2853
  throw e;
2724
2854
  }
2725
2855
  }
2726
- async function submit(request, matches, actionMatch, requestContext, dataStrategy, skipLoaderErrorBubbling, isRouteRequest, filterMatchesToLoad, skipRevalidation) {
2856
+ async function submit(request, location, matches, actionMatch, requestContext, dataStrategy, skipLoaderErrorBubbling, isRouteRequest, filterMatchesToLoad, skipRevalidation) {
2727
2857
  let result;
2728
2858
  if (!actionMatch.route.action && !actionMatch.route.lazy) {
2729
2859
  let error = getInternalRouterError(405, {
@@ -2743,6 +2873,7 @@ function createStaticHandler(routes, opts) {
2743
2873
  mapRouteProperties2,
2744
2874
  manifest,
2745
2875
  request,
2876
+ location,
2746
2877
  matches,
2747
2878
  actionMatch,
2748
2879
  [],
@@ -2750,6 +2881,7 @@ function createStaticHandler(routes, opts) {
2750
2881
  );
2751
2882
  let results = await callDataStrategy(
2752
2883
  request,
2884
+ location,
2753
2885
  dsMatches,
2754
2886
  isRouteRequest,
2755
2887
  requestContext,
@@ -2823,6 +2955,7 @@ function createStaticHandler(routes, opts) {
2823
2955
  let boundaryMatch = skipLoaderErrorBubbling ? actionMatch : findNearestBoundary(matches, actionMatch.route.id);
2824
2956
  let handlerContext2 = await loadRouteData(
2825
2957
  loaderRequest,
2958
+ location,
2826
2959
  matches,
2827
2960
  requestContext,
2828
2961
  dataStrategy,
@@ -2842,6 +2975,7 @@ function createStaticHandler(routes, opts) {
2842
2975
  }
2843
2976
  let handlerContext = await loadRouteData(
2844
2977
  loaderRequest,
2978
+ location,
2845
2979
  matches,
2846
2980
  requestContext,
2847
2981
  dataStrategy,
@@ -2859,7 +2993,7 @@ function createStaticHandler(routes, opts) {
2859
2993
  actionHeaders: result.headers ? { [actionMatch.route.id]: result.headers } : {}
2860
2994
  };
2861
2995
  }
2862
- async function loadRouteData(request, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, pendingActionResult) {
2996
+ async function loadRouteData(request, location, matches, requestContext, dataStrategy, skipLoaderErrorBubbling, routeMatch, filterMatchesToLoad, pendingActionResult) {
2863
2997
  let isRouteRequest = routeMatch != null;
2864
2998
  if (isRouteRequest && !(routeMatch == null ? void 0 : routeMatch.route.loader) && !(routeMatch == null ? void 0 : routeMatch.route.lazy)) {
2865
2999
  throw getInternalRouterError(400, {
@@ -2874,6 +3008,7 @@ function createStaticHandler(routes, opts) {
2874
3008
  mapRouteProperties2,
2875
3009
  manifest,
2876
3010
  request,
3011
+ location,
2877
3012
  matches,
2878
3013
  routeMatch,
2879
3014
  [],
@@ -2891,6 +3026,7 @@ function createStaticHandler(routes, opts) {
2891
3026
  mapRouteProperties2,
2892
3027
  manifest,
2893
3028
  request,
3029
+ location,
2894
3030
  pattern,
2895
3031
  match,
2896
3032
  [],
@@ -2902,6 +3038,7 @@ function createStaticHandler(routes, opts) {
2902
3038
  mapRouteProperties2,
2903
3039
  manifest,
2904
3040
  request,
3041
+ location,
2905
3042
  pattern,
2906
3043
  match,
2907
3044
  [],
@@ -2923,6 +3060,7 @@ function createStaticHandler(routes, opts) {
2923
3060
  }
2924
3061
  let results = await callDataStrategy(
2925
3062
  request,
3063
+ location,
2926
3064
  dsMatches,
2927
3065
  isRouteRequest,
2928
3066
  requestContext,
@@ -2943,10 +3081,11 @@ function createStaticHandler(routes, opts) {
2943
3081
  matches
2944
3082
  };
2945
3083
  }
2946
- async function callDataStrategy(request, matches, isRouteRequest, requestContext, dataStrategy) {
3084
+ async function callDataStrategy(request, location, matches, isRouteRequest, requestContext, dataStrategy) {
2947
3085
  let results = await callDataStrategyImpl(
2948
3086
  dataStrategy || defaultDataStrategy,
2949
3087
  request,
3088
+ location,
2950
3089
  matches,
2951
3090
  null,
2952
3091
  requestContext
@@ -2982,6 +3121,7 @@ function createStaticHandler(routes, opts) {
2982
3121
  }
2983
3122
  return {
2984
3123
  dataRoutes,
3124
+ _internalRouteBranches: routeBranches,
2985
3125
  query,
2986
3126
  queryRoute
2987
3127
  };
@@ -3005,6 +3145,14 @@ function throwStaticHandlerAbortedError(request, isRouteRequest) {
3005
3145
  `${method}() call aborted without an \`AbortSignal.reason\`: ${request.method} ${request.url}`
3006
3146
  );
3007
3147
  }
3148
+ function defaultNormalizePath(request) {
3149
+ let url = new URL(request.url);
3150
+ return {
3151
+ pathname: url.pathname,
3152
+ search: url.search,
3153
+ hash: url.hash
3154
+ };
3155
+ }
3008
3156
  function normalizeTo(location, matches, basename, to, fromRouteId, relative) {
3009
3157
  let contextualMatches;
3010
3158
  let activeRouteMatch;
@@ -3242,17 +3390,12 @@ function runServerMiddlewarePipeline(args, handler, errorHandler) {
3242
3390
  }
3243
3391
  }
3244
3392
  async function runMiddlewarePipeline(args, handler, processResult, isResult, errorHandler) {
3245
- let { matches, request, params, context, unstable_pattern } = args;
3393
+ let { matches, ...dataFnArgs } = args;
3246
3394
  let tuples = matches.flatMap(
3247
3395
  (m) => m.route.middleware ? m.route.middleware.map((fn) => [m.route.id, fn]) : []
3248
3396
  );
3249
3397
  let result = await callRouteMiddleware(
3250
- {
3251
- request,
3252
- params,
3253
- context,
3254
- unstable_pattern
3255
- },
3398
+ dataFnArgs,
3256
3399
  tuples,
3257
3400
  handler,
3258
3401
  processResult,
@@ -3330,7 +3473,7 @@ function getDataStrategyMatchLazyPromises(mapRouteProperties2, manifest, request
3330
3473
  handler: lazyRoutePromises.lazyHandlerPromise
3331
3474
  };
3332
3475
  }
3333
- function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
3476
+ function getDataStrategyMatch(mapRouteProperties2, manifest, request, path, pattern, match, lazyRoutePropertiesToSkip, scopedContext, shouldLoad, shouldRevalidateArgs = null, callSiteDefaultShouldRevalidate) {
3334
3477
  let isUsingNewApi = false;
3335
3478
  let _lazyPromises = getDataStrategyMatchLazyPromises(
3336
3479
  mapRouteProperties2,
@@ -3364,7 +3507,8 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
3364
3507
  if (callHandler && (isMutationMethod(request.method) || !isMiddlewareOnlyRoute)) {
3365
3508
  return callLoaderOrAction({
3366
3509
  request,
3367
- unstable_pattern,
3510
+ path,
3511
+ pattern,
3368
3512
  match,
3369
3513
  lazyHandlerPromise: _lazyPromises == null ? void 0 : _lazyPromises.handler,
3370
3514
  lazyRoutePromise: _lazyPromises == null ? void 0 : _lazyPromises.route,
@@ -3376,7 +3520,7 @@ function getDataStrategyMatch(mapRouteProperties2, manifest, request, unstable_p
3376
3520
  }
3377
3521
  };
3378
3522
  }
3379
- function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
3523
+ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request, path, matches, targetMatch, lazyRoutePropertiesToSkip, scopedContext, shouldRevalidateArgs = null) {
3380
3524
  return matches.map((match) => {
3381
3525
  if (match.route.id !== targetMatch.route.id) {
3382
3526
  return {
@@ -3398,6 +3542,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
3398
3542
  mapRouteProperties2,
3399
3543
  manifest,
3400
3544
  request,
3545
+ path,
3401
3546
  getRoutePattern(matches),
3402
3547
  match,
3403
3548
  lazyRoutePropertiesToSkip,
@@ -3407,7 +3552,7 @@ function getTargetedDataStrategyMatches(mapRouteProperties2, manifest, request,
3407
3552
  );
3408
3553
  });
3409
3554
  }
3410
- async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherKey, scopedContext, isStaticHandler) {
3555
+ async function callDataStrategyImpl(dataStrategyImpl, request, path, matches, fetcherKey, scopedContext, isStaticHandler) {
3411
3556
  if (matches.some((m) => {
3412
3557
  var _a;
3413
3558
  return (_a = m._lazyPromises) == null ? void 0 : _a.middleware;
@@ -3419,7 +3564,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
3419
3564
  }
3420
3565
  let dataStrategyArgs = {
3421
3566
  request,
3422
- unstable_pattern: getRoutePattern(matches),
3567
+ url: createDataFunctionUrl(request, path),
3568
+ pattern: getRoutePattern(matches),
3423
3569
  params: matches[0].params,
3424
3570
  context: scopedContext,
3425
3571
  matches
@@ -3450,7 +3596,8 @@ async function callDataStrategyImpl(dataStrategyImpl, request, matches, fetcherK
3450
3596
  }
3451
3597
  async function callLoaderOrAction({
3452
3598
  request,
3453
- unstable_pattern,
3599
+ path,
3600
+ pattern,
3454
3601
  match,
3455
3602
  lazyHandlerPromise,
3456
3603
  lazyRoutePromise,
@@ -3477,7 +3624,8 @@ async function callLoaderOrAction({
3477
3624
  return handler(
3478
3625
  {
3479
3626
  request,
3480
- unstable_pattern,
3627
+ url: createDataFunctionUrl(request, path),
3628
+ pattern,
3481
3629
  params: match.params,
3482
3630
  context: scopedContext
3483
3631
  },
@@ -3635,6 +3783,44 @@ function normalizeRelativeRoutingRedirectResponse(response, request, routeId, ma
3635
3783
  }
3636
3784
  return response;
3637
3785
  }
3786
+ var invalidProtocols = [
3787
+ "about:",
3788
+ "blob:",
3789
+ "chrome:",
3790
+ "chrome-untrusted:",
3791
+ "content:",
3792
+ "data:",
3793
+ "devtools:",
3794
+ "file:",
3795
+ "filesystem:",
3796
+ // eslint-disable-next-line no-script-url
3797
+ "javascript:"
3798
+ ];
3799
+ function hasInvalidProtocol(location) {
3800
+ try {
3801
+ return invalidProtocols.includes(new URL(location).protocol);
3802
+ } catch {
3803
+ return false;
3804
+ }
3805
+ }
3806
+ function createDataFunctionUrl(request, path) {
3807
+ let url = new URL(request.url);
3808
+ let parsed = typeof path === "string" ? parsePath(path) : path;
3809
+ url.pathname = parsed.pathname || "/";
3810
+ if (parsed.search) {
3811
+ let searchParams = new URLSearchParams(parsed.search);
3812
+ let indexValues = searchParams.getAll("index");
3813
+ searchParams.delete("index");
3814
+ for (let value of indexValues.filter(Boolean)) {
3815
+ searchParams.append("index", value);
3816
+ }
3817
+ url.search = searchParams.size ? `?${searchParams.toString()}` : "";
3818
+ } else {
3819
+ url.search = "";
3820
+ }
3821
+ url.hash = parsed.hash || "";
3822
+ return url;
3823
+ }
3638
3824
  function processRouteLoaderData(matches, results, pendingActionResult, isStaticHandler = false, skipLoaderErrorBubbling = false) {
3639
3825
  let loaderData = {};
3640
3826
  let errors = null;
@@ -3945,6 +4131,12 @@ function useNavigateUnstable() {
3945
4131
  if (dataRouterContext == null && basename !== "/") {
3946
4132
  path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
3947
4133
  }
4134
+ validateNavigationTarget(
4135
+ typeof to === "string" ? to : createPath(to),
4136
+ navigator.createHref(path),
4137
+ getNavigatorCurrentUrl(navigator),
4138
+ "reject"
4139
+ );
3948
4140
  (!!options.replace ? navigator.replace : navigator.push)(
3949
4141
  path,
3950
4142
  options.state,
@@ -3972,7 +4164,7 @@ function useOutlet(context) {
3972
4164
  function useParams() {
3973
4165
  let { matches } = reactExports.useContext(RouteContext);
3974
4166
  let routeMatch = matches[matches.length - 1];
3975
- return routeMatch ? routeMatch.params : {};
4167
+ return (routeMatch == null ? void 0 : routeMatch.params) ?? {};
3976
4168
  }
3977
4169
  function useResolvedPath(to, { relative } = {}) {
3978
4170
  let { matches } = reactExports.useContext(RouteContext);
@@ -4024,7 +4216,15 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
4024
4216
  let segments = pathname.replace(/^\//, "").split("/");
4025
4217
  remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
4026
4218
  }
4027
- let matches = matchRoutes(routes, { pathname: remainingPathname });
4219
+ let matches = dataRouterOpts && dataRouterOpts.state.matches.length ? (
4220
+ // If we're in a data router, use the matches we've already identified but ensure
4221
+ // we have the latest route instances from the manifest in case elements have changed
4222
+ dataRouterOpts.state.matches.map(
4223
+ (m) => Object.assign(m, {
4224
+ route: dataRouterOpts.manifest[m.route.id] || m.route
4225
+ })
4226
+ )
4227
+ ) : matchRoutes(routes, { pathname: remainingPathname });
4028
4228
  {
4029
4229
  warning(
4030
4230
  parentRoute || matches != null,
@@ -4042,21 +4242,21 @@ Please change the parent <Route path="${parentPath}"> to <Route path="${parentPa
4042
4242
  pathname: joinPaths([
4043
4243
  parentPathnameBase,
4044
4244
  // Re-encode pathnames that were decoded inside matchRoutes.
4045
- // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
4245
+ // Pre-encode `%`, `?` and `#` ahead of `encodeLocation` because it uses
4046
4246
  // `new URL()` internally and we need to prevent it from treating
4047
4247
  // them as separators
4048
4248
  navigator.encodeLocation ? navigator.encodeLocation(
4049
- match.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")
4249
+ match.pathname.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")
4050
4250
  ).pathname : match.pathname
4051
4251
  ]),
4052
4252
  pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
4053
4253
  parentPathnameBase,
4054
4254
  // Re-encode pathnames that were decoded inside matchRoutes
4055
- // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
4255
+ // Pre-encode `%`, `?` and `#` ahead of `encodeLocation` because it uses
4056
4256
  // `new URL()` internally and we need to prevent it from treating
4057
4257
  // them as separators
4058
4258
  navigator.encodeLocation ? navigator.encodeLocation(
4059
- match.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")
4259
+ match.pathnameBase.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")
4060
4260
  ).pathname : match.pathnameBase
4061
4261
  ])
4062
4262
  })
@@ -4145,16 +4345,26 @@ function RSCErrorHandler({
4145
4345
  children,
4146
4346
  error
4147
4347
  }) {
4148
- let { basename } = reactExports.useContext(NavigationContext);
4348
+ let { basename, navigator } = reactExports.useContext(NavigationContext);
4149
4349
  if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
4150
4350
  let redirect2 = decodeRedirectErrorDigest(error.digest);
4151
4351
  if (redirect2) {
4152
4352
  let existingRedirect = errorRedirectHandledMap.get(error);
4153
4353
  if (existingRedirect) throw existingRedirect;
4154
4354
  let parsed = parseToInfo(redirect2.location, basename);
4355
+ let target = parsed.absoluteURL || parsed.to;
4356
+ validateNavigationTarget(
4357
+ redirect2.location,
4358
+ target,
4359
+ getNavigatorCurrentUrl(navigator),
4360
+ "allow-explicit"
4361
+ );
4362
+ if (hasInvalidProtocol(target)) {
4363
+ throw new Error("Invalid redirect location");
4364
+ }
4155
4365
  if (isBrowser && !errorRedirectHandledMap.get(error)) {
4156
4366
  if (parsed.isExternal || redirect2.reloadDocument) {
4157
- window.location.href = parsed.absoluteURL || parsed.to;
4367
+ window.location.href = target;
4158
4368
  } else {
4159
4369
  const redirectPromise = Promise.resolve().then(
4160
4370
  () => window.__reactRouterDataRouter.navigate(parsed.to, {
@@ -4165,13 +4375,7 @@ function RSCErrorHandler({
4165
4375
  throw redirectPromise;
4166
4376
  }
4167
4377
  }
4168
- return /* @__PURE__ */ reactExports.createElement(
4169
- "meta",
4170
- {
4171
- httpEquiv: "refresh",
4172
- content: `0;url=${parsed.absoluteURL || parsed.to}`
4173
- }
4174
- );
4378
+ return /* @__PURE__ */ reactExports.createElement("meta", { httpEquiv: "refresh", content: `0;url=${target}` });
4175
4379
  }
4176
4380
  }
4177
4381
  return children;
@@ -4246,7 +4450,7 @@ function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
4246
4450
  onErrorHandler(error, {
4247
4451
  location: dataRouterState.location,
4248
4452
  params: ((_b = (_a = dataRouterState.matches) == null ? void 0 : _a[0]) == null ? void 0 : _b.params) ?? {},
4249
- unstable_pattern: getRoutePattern(dataRouterState.matches),
4453
+ pattern: getRoutePattern(dataRouterState.matches),
4250
4454
  errorInfo
4251
4455
  });
4252
4456
  } : void 0;
@@ -4355,7 +4559,10 @@ function useNavigation() {
4355
4559
  "useNavigation"
4356
4560
  /* UseNavigation */
4357
4561
  );
4358
- return state.navigation;
4562
+ return reactExports.useMemo(() => {
4563
+ let { matches, historyAction, ...rest } = state.navigation;
4564
+ return rest;
4565
+ }, [state.navigation]);
4359
4566
  }
4360
4567
  function useMatches() {
4361
4568
  let { matches, loaderData } = useDataRouterState(
@@ -4496,15 +4703,21 @@ function mapRouteProperties(route) {
4496
4703
  }
4497
4704
  return updates;
4498
4705
  }
4499
- reactExports.memo(DataRoutes);
4500
- function DataRoutes({
4706
+ reactExports.memo(DataRoutes2);
4707
+ function DataRoutes2({
4501
4708
  routes,
4709
+ manifest,
4502
4710
  future,
4503
4711
  state,
4504
4712
  isStatic,
4505
4713
  onError
4506
4714
  }) {
4507
- return useRoutesImpl(routes, void 0, { state, isStatic, onError });
4715
+ return useRoutesImpl(routes, void 0, {
4716
+ manifest,
4717
+ state,
4718
+ isStatic,
4719
+ onError
4720
+ });
4508
4721
  }
4509
4722
  function Outlet(props) {
4510
4723
  return useOutlet(props.context);
@@ -4516,7 +4729,7 @@ function Router({
4516
4729
  navigationType = "POP",
4517
4730
  navigator,
4518
4731
  static: staticProp = false,
4519
- unstable_useTransitions
4732
+ useTransitions
4520
4733
  }) {
4521
4734
  invariant$1(
4522
4735
  !useInRouterContext(),
@@ -4528,10 +4741,10 @@ function Router({
4528
4741
  basename,
4529
4742
  navigator,
4530
4743
  static: staticProp,
4531
- unstable_useTransitions,
4744
+ useTransitions,
4532
4745
  future: {}
4533
4746
  }),
4534
- [basename, navigator, staticProp, unstable_useTransitions]
4747
+ [basename, navigator, staticProp, useTransitions]
4535
4748
  );
4536
4749
  if (typeof locationProp === "string") {
4537
4750
  locationProp = parsePath(locationProp);
@@ -4542,7 +4755,7 @@ function Router({
4542
4755
  hash = "",
4543
4756
  state = null,
4544
4757
  key = "default",
4545
- unstable_mask
4758
+ mask
4546
4759
  } = locationProp;
4547
4760
  let locationContext = reactExports.useMemo(() => {
4548
4761
  let trailingPathname = stripBasename(pathname, basename);
@@ -4556,20 +4769,11 @@ function Router({
4556
4769
  hash,
4557
4770
  state,
4558
4771
  key,
4559
- unstable_mask
4772
+ mask
4560
4773
  },
4561
4774
  navigationType
4562
4775
  };
4563
- }, [
4564
- basename,
4565
- pathname,
4566
- search,
4567
- hash,
4568
- state,
4569
- key,
4570
- navigationType,
4571
- unstable_mask
4572
- ]);
4776
+ }, [basename, pathname, search, hash, state, key, navigationType, mask]);
4573
4777
  warning(
4574
4778
  locationContext != null,
4575
4779
  `<Router basename="${basename}"> is not able to match the URL "${pathname}${search}${hash}" because it does not start with the basename, so the <Router> won't render anything.`
@@ -4778,7 +4982,10 @@ function createLineSplittingTransform() {
4778
4982
  }
4779
4983
  });
4780
4984
  }
4781
- function flatten(input) {
4985
+ var TIME_LIMIT_MS = 1;
4986
+ var getNow = () => Date.now();
4987
+ var yieldToMain = () => new Promise((resolve) => setTimeout(resolve, 0));
4988
+ async function flatten(input) {
4782
4989
  const { indices } = this;
4783
4990
  const existing = indices.get(input);
4784
4991
  if (existing) return [existing];
@@ -4790,55 +4997,76 @@ function flatten(input) {
4790
4997
  if (input === 0 && 1 / input < 0) return NEGATIVE_ZERO;
4791
4998
  const index = this.index++;
4792
4999
  indices.set(input, index);
4793
- stringify.call(this, input, index);
5000
+ const stack = [[input, index]];
5001
+ await stringify.call(this, stack);
4794
5002
  return index;
4795
5003
  }
4796
- function stringify(input, index) {
4797
- const { deferred, plugins, postPlugins } = this;
5004
+ async function stringify(stack) {
5005
+ const { deferred, indices, plugins, postPlugins } = this;
4798
5006
  const str = this.stringified;
4799
- const stack = [[input, index]];
5007
+ let lastYieldTime = getNow();
5008
+ const flattenValue = (value) => {
5009
+ const existing = indices.get(value);
5010
+ if (existing) return [existing];
5011
+ if (value === void 0) return UNDEFINED;
5012
+ if (value === null) return NULL;
5013
+ if (Number.isNaN(value)) return NAN;
5014
+ if (value === Number.POSITIVE_INFINITY) return POSITIVE_INFINITY;
5015
+ if (value === Number.NEGATIVE_INFINITY) return NEGATIVE_INFINITY;
5016
+ if (value === 0 && 1 / value < 0) return NEGATIVE_ZERO;
5017
+ const index = this.index++;
5018
+ indices.set(value, index);
5019
+ stack.push([value, index]);
5020
+ return index;
5021
+ };
5022
+ let i = 0;
4800
5023
  while (stack.length > 0) {
4801
- const [input2, index2] = stack.pop();
4802
- const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flatten.call(this, k)}":${flatten.call(this, obj[k])}`).join(",");
5024
+ const now = getNow();
5025
+ if (++i % 6e3 === 0 && now - lastYieldTime >= TIME_LIMIT_MS) {
5026
+ await yieldToMain();
5027
+ lastYieldTime = getNow();
5028
+ }
5029
+ const [input, index] = stack.pop();
5030
+ const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flattenValue(k)}":${flattenValue(obj[k])}`).join(",");
4803
5031
  let error = null;
4804
- switch (typeof input2) {
5032
+ switch (typeof input) {
4805
5033
  case "boolean":
4806
5034
  case "number":
4807
5035
  case "string":
4808
- str[index2] = JSON.stringify(input2);
5036
+ str[index] = JSON.stringify(input);
4809
5037
  break;
4810
5038
  case "bigint":
4811
- str[index2] = `["${TYPE_BIGINT}","${input2}"]`;
5039
+ str[index] = `["${TYPE_BIGINT}","${input}"]`;
4812
5040
  break;
4813
5041
  case "symbol": {
4814
- const keyFor = Symbol.keyFor(input2);
5042
+ const keyFor = Symbol.keyFor(input);
4815
5043
  if (!keyFor) {
4816
5044
  error = new Error(
4817
5045
  "Cannot encode symbol unless created with Symbol.for()"
4818
5046
  );
4819
5047
  } else {
4820
- str[index2] = `["${TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
5048
+ str[index] = `["${TYPE_SYMBOL}",${JSON.stringify(keyFor)}]`;
4821
5049
  }
4822
5050
  break;
4823
5051
  }
4824
5052
  case "object": {
4825
- if (!input2) {
4826
- str[index2] = `${NULL}`;
5053
+ if (!input) {
5054
+ str[index] = `${NULL}`;
4827
5055
  break;
4828
5056
  }
4829
- const isArray = Array.isArray(input2);
5057
+ const isArray = Array.isArray(input);
4830
5058
  let pluginHandled = false;
4831
5059
  if (!isArray && plugins) {
4832
5060
  for (const plugin of plugins) {
4833
- const pluginResult = plugin(input2);
5061
+ const pluginResult = plugin(input);
4834
5062
  if (Array.isArray(pluginResult)) {
4835
5063
  pluginHandled = true;
4836
5064
  const [pluginIdentifier, ...rest] = pluginResult;
4837
- str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
5065
+ str[index] = `[${JSON.stringify(pluginIdentifier)}`;
4838
5066
  if (rest.length > 0) {
4839
- str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
5067
+ str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
4840
5068
  }
4841
- str[index2] += "]";
5069
+ str[index] += "]";
4842
5070
  break;
4843
5071
  }
4844
5072
  }
@@ -4846,46 +5074,43 @@ function stringify(input, index) {
4846
5074
  if (!pluginHandled) {
4847
5075
  let result = isArray ? "[" : "{";
4848
5076
  if (isArray) {
4849
- for (let i = 0; i < input2.length; i++)
4850
- result += (i ? "," : "") + (i in input2 ? flatten.call(this, input2[i]) : HOLE);
4851
- str[index2] = `${result}]`;
4852
- } else if (input2 instanceof Date) {
4853
- const dateTime = input2.getTime();
4854
- str[index2] = `["${TYPE_DATE}",${Number.isNaN(dateTime) ? JSON.stringify("invalid") : dateTime}]`;
4855
- } else if (input2 instanceof URL) {
4856
- str[index2] = `["${TYPE_URL}",${JSON.stringify(input2.href)}]`;
4857
- } else if (input2 instanceof RegExp) {
4858
- str[index2] = `["${TYPE_REGEXP}",${JSON.stringify(
4859
- input2.source
4860
- )},${JSON.stringify(input2.flags)}]`;
4861
- } else if (input2 instanceof Set) {
4862
- if (input2.size > 0) {
4863
- str[index2] = `["${TYPE_SET}",${[...input2].map((val) => flatten.call(this, val)).join(",")}]`;
5077
+ for (let i2 = 0; i2 < input.length; i2++)
5078
+ result += (i2 ? "," : "") + (i2 in input ? flattenValue(input[i2]) : HOLE);
5079
+ str[index] = `${result}]`;
5080
+ } else if (input instanceof Date) {
5081
+ const dateTime = input.getTime();
5082
+ str[index] = `["${TYPE_DATE}",${Number.isNaN(dateTime) ? JSON.stringify("invalid") : dateTime}]`;
5083
+ } else if (input instanceof URL) {
5084
+ str[index] = `["${TYPE_URL}",${JSON.stringify(input.href)}]`;
5085
+ } else if (input instanceof RegExp) {
5086
+ str[index] = `["${TYPE_REGEXP}",${JSON.stringify(
5087
+ input.source
5088
+ )},${JSON.stringify(input.flags)}]`;
5089
+ } else if (input instanceof Set) {
5090
+ if (input.size > 0) {
5091
+ str[index] = `["${TYPE_SET}",${[...input].map((val) => flattenValue(val)).join(",")}]`;
4864
5092
  } else {
4865
- str[index2] = `["${TYPE_SET}"]`;
5093
+ str[index] = `["${TYPE_SET}"]`;
4866
5094
  }
4867
- } else if (input2 instanceof Map) {
4868
- if (input2.size > 0) {
4869
- str[index2] = `["${TYPE_MAP}",${[...input2].flatMap(([k, v]) => [
4870
- flatten.call(this, k),
4871
- flatten.call(this, v)
4872
- ]).join(",")}]`;
5095
+ } else if (input instanceof Map) {
5096
+ if (input.size > 0) {
5097
+ str[index] = `["${TYPE_MAP}",${[...input].flatMap(([k, v]) => [flattenValue(k), flattenValue(v)]).join(",")}]`;
4873
5098
  } else {
4874
- str[index2] = `["${TYPE_MAP}"]`;
5099
+ str[index] = `["${TYPE_MAP}"]`;
4875
5100
  }
4876
- } else if (input2 instanceof Promise) {
4877
- str[index2] = `["${TYPE_PROMISE}",${index2}]`;
4878
- deferred[index2] = input2;
4879
- } else if (input2 instanceof Error) {
4880
- str[index2] = `["${TYPE_ERROR}",${JSON.stringify(input2.message)}`;
4881
- if (input2.name !== "Error") {
4882
- str[index2] += `,${JSON.stringify(input2.name)}`;
5101
+ } else if (input instanceof Promise) {
5102
+ str[index] = `["${TYPE_PROMISE}",${index}]`;
5103
+ deferred[index] = input;
5104
+ } else if (input instanceof Error) {
5105
+ str[index] = `["${TYPE_ERROR}",${JSON.stringify(input.message)}`;
5106
+ if (input.name !== "Error") {
5107
+ str[index] += `,${JSON.stringify(input.name)}`;
4883
5108
  }
4884
- str[index2] += "]";
4885
- } else if (Object.getPrototypeOf(input2) === null) {
4886
- str[index2] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input2)}}]`;
4887
- } else if (isPlainObject2(input2)) {
4888
- str[index2] = `{${partsForObj(input2)}}`;
5109
+ str[index] += "]";
5110
+ } else if (Object.getPrototypeOf(input) === null) {
5111
+ str[index] = `["${TYPE_NULL_OBJECT}",{${partsForObj(input)}}]`;
5112
+ } else if (isPlainObject2(input)) {
5113
+ str[index] = `{${partsForObj(input)}}`;
4889
5114
  } else {
4890
5115
  error = new Error("Cannot encode object with prototype");
4891
5116
  }
@@ -4893,19 +5118,19 @@ function stringify(input, index) {
4893
5118
  break;
4894
5119
  }
4895
5120
  default: {
4896
- const isArray = Array.isArray(input2);
5121
+ const isArray = Array.isArray(input);
4897
5122
  let pluginHandled = false;
4898
5123
  if (!isArray && plugins) {
4899
5124
  for (const plugin of plugins) {
4900
- const pluginResult = plugin(input2);
5125
+ const pluginResult = plugin(input);
4901
5126
  if (Array.isArray(pluginResult)) {
4902
5127
  pluginHandled = true;
4903
5128
  const [pluginIdentifier, ...rest] = pluginResult;
4904
- str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
5129
+ str[index] = `[${JSON.stringify(pluginIdentifier)}`;
4905
5130
  if (rest.length > 0) {
4906
- str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
5131
+ str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
4907
5132
  }
4908
- str[index2] += "]";
5133
+ str[index] += "]";
4909
5134
  break;
4910
5135
  }
4911
5136
  }
@@ -4919,15 +5144,15 @@ function stringify(input, index) {
4919
5144
  let pluginHandled = false;
4920
5145
  if (postPlugins) {
4921
5146
  for (const plugin of postPlugins) {
4922
- const pluginResult = plugin(input2);
5147
+ const pluginResult = plugin(input);
4923
5148
  if (Array.isArray(pluginResult)) {
4924
5149
  pluginHandled = true;
4925
5150
  const [pluginIdentifier, ...rest] = pluginResult;
4926
- str[index2] = `[${JSON.stringify(pluginIdentifier)}`;
5151
+ str[index] = `[${JSON.stringify(pluginIdentifier)}`;
4927
5152
  if (rest.length > 0) {
4928
- str[index2] += `,${rest.map((v) => flatten.call(this, v)).join(",")}`;
5153
+ str[index] += `,${rest.map((v) => flattenValue(v)).join(",")}`;
4929
5154
  }
4930
- str[index2] += "]";
5155
+ str[index] += "]";
4931
5156
  break;
4932
5157
  }
4933
5158
  }
@@ -5087,7 +5312,7 @@ function hydrate(index) {
5087
5312
  continue;
5088
5313
  case TYPE_ERROR:
5089
5314
  const [, message, errorType] = value;
5090
- let error = errorType && globalObj && globalObj[errorType] ? new globalObj[errorType](message) : new Error(message);
5315
+ let error = errorType && globalObj && SUPPORTED_ERROR_TYPES.includes(errorType) && errorType in globalObj && typeof globalObj[errorType] === "function" ? new globalObj[errorType](message) : new Error(message);
5091
5316
  hydrated[index2] = error;
5092
5317
  set(error);
5093
5318
  continue;
@@ -5260,7 +5485,7 @@ async function decodeDeferred(reader) {
5260
5485
  }
5261
5486
  }
5262
5487
  function encode(input, options) {
5263
- const { plugins, postPlugins, signal, onComplete } = options ?? {};
5488
+ const { onComplete, plugins, postPlugins, signal } = options ?? {};
5264
5489
  const encoder = {
5265
5490
  deferred: {},
5266
5491
  index: 0,
@@ -5274,7 +5499,7 @@ function encode(input, options) {
5274
5499
  let lastSentIndex = 0;
5275
5500
  const readable = new ReadableStream({
5276
5501
  async start(controller) {
5277
- const id = flatten.call(encoder, input);
5502
+ const id = await flatten.call(encoder, input);
5278
5503
  if (Array.isArray(id)) {
5279
5504
  throw new Error("This should never happen");
5280
5505
  }
@@ -5289,6 +5514,7 @@ function encode(input, options) {
5289
5514
  lastSentIndex = encoder.stringified.length - 1;
5290
5515
  }
5291
5516
  const seenPromises = /* @__PURE__ */ new WeakSet();
5517
+ let processingChain = Promise.resolve();
5292
5518
  if (Object.keys(encoder.deferred).length) {
5293
5519
  let raceDone;
5294
5520
  const racePromise = new Promise((resolve, reject) => {
@@ -5316,65 +5542,71 @@ function encode(input, options) {
5316
5542
  deferred
5317
5543
  ]).then(
5318
5544
  (resolved) => {
5319
- const id2 = flatten.call(encoder, resolved);
5320
- if (Array.isArray(id2)) {
5321
- controller.enqueue(
5322
- textEncoder.encode(
5323
- `${TYPE_PROMISE}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
5545
+ processingChain = processingChain.then(async () => {
5546
+ const id2 = await flatten.call(encoder, resolved);
5547
+ if (Array.isArray(id2)) {
5548
+ controller.enqueue(
5549
+ textEncoder.encode(
5550
+ `${TYPE_PROMISE}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
5324
5551
  `
5325
- )
5326
- );
5327
- encoder.index++;
5328
- lastSentIndex++;
5329
- } else if (id2 < 0) {
5330
- controller.enqueue(
5331
- textEncoder.encode(
5332
- `${TYPE_PROMISE}${deferredId}:${id2}
5552
+ )
5553
+ );
5554
+ encoder.index++;
5555
+ lastSentIndex++;
5556
+ } else if (id2 < 0) {
5557
+ controller.enqueue(
5558
+ textEncoder.encode(
5559
+ `${TYPE_PROMISE}${deferredId}:${id2}
5333
5560
  `
5334
- )
5335
- );
5336
- } else {
5337
- const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
5338
- controller.enqueue(
5339
- textEncoder.encode(
5340
- `${TYPE_PROMISE}${deferredId}:[${values}]
5561
+ )
5562
+ );
5563
+ } else {
5564
+ const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
5565
+ controller.enqueue(
5566
+ textEncoder.encode(
5567
+ `${TYPE_PROMISE}${deferredId}:[${values}]
5341
5568
  `
5342
- )
5343
- );
5344
- lastSentIndex = encoder.stringified.length - 1;
5345
- }
5569
+ )
5570
+ );
5571
+ lastSentIndex = encoder.stringified.length - 1;
5572
+ }
5573
+ });
5574
+ return processingChain;
5346
5575
  },
5347
5576
  (reason) => {
5348
- if (!reason || typeof reason !== "object" || !(reason instanceof Error)) {
5349
- reason = new Error("An unknown error occurred");
5350
- }
5351
- const id2 = flatten.call(encoder, reason);
5352
- if (Array.isArray(id2)) {
5353
- controller.enqueue(
5354
- textEncoder.encode(
5355
- `${TYPE_ERROR}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
5577
+ processingChain = processingChain.then(async () => {
5578
+ if (!reason || typeof reason !== "object" || !(reason instanceof Error)) {
5579
+ reason = new Error("An unknown error occurred");
5580
+ }
5581
+ const id2 = await flatten.call(encoder, reason);
5582
+ if (Array.isArray(id2)) {
5583
+ controller.enqueue(
5584
+ textEncoder.encode(
5585
+ `${TYPE_ERROR}${deferredId}:[["${TYPE_PREVIOUS_RESOLVED}",${id2[0]}]]
5356
5586
  `
5357
- )
5358
- );
5359
- encoder.index++;
5360
- lastSentIndex++;
5361
- } else if (id2 < 0) {
5362
- controller.enqueue(
5363
- textEncoder.encode(
5364
- `${TYPE_ERROR}${deferredId}:${id2}
5587
+ )
5588
+ );
5589
+ encoder.index++;
5590
+ lastSentIndex++;
5591
+ } else if (id2 < 0) {
5592
+ controller.enqueue(
5593
+ textEncoder.encode(
5594
+ `${TYPE_ERROR}${deferredId}:${id2}
5365
5595
  `
5366
- )
5367
- );
5368
- } else {
5369
- const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
5370
- controller.enqueue(
5371
- textEncoder.encode(
5372
- `${TYPE_ERROR}${deferredId}:[${values}]
5596
+ )
5597
+ );
5598
+ } else {
5599
+ const values = encoder.stringified.slice(lastSentIndex + 1).join(",");
5600
+ controller.enqueue(
5601
+ textEncoder.encode(
5602
+ `${TYPE_ERROR}${deferredId}:[${values}]
5373
5603
  `
5374
- )
5375
- );
5376
- lastSentIndex = encoder.stringified.length - 1;
5377
- }
5604
+ )
5605
+ );
5606
+ lastSentIndex = encoder.stringified.length - 1;
5607
+ }
5608
+ });
5609
+ return processingChain;
5378
5610
  }
5379
5611
  ).finally(() => {
5380
5612
  delete encoder.deferred[Number(deferredId)];
@@ -5386,8 +5618,9 @@ function encode(input, options) {
5386
5618
  raceDone();
5387
5619
  }
5388
5620
  await Promise.all(Object.values(encoder.deferred));
5389
- onComplete == null ? void 0 : onComplete();
5621
+ await processingChain;
5390
5622
  controller.close();
5623
+ onComplete == null ? void 0 : onComplete();
5391
5624
  }
5392
5625
  });
5393
5626
  return readable;
@@ -5494,9 +5727,9 @@ function singleFetchUrl(reqUrl, basename, trailingSlashAware, extension) {
5494
5727
  if (url.pathname === "/") {
5495
5728
  url.pathname = `_root.${extension}`;
5496
5729
  } else if (basename && stripBasename(url.pathname, basename) === "/") {
5497
- url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
5730
+ url.pathname = `${removeTrailingSlash(basename)}/_root.${extension}`;
5498
5731
  } else {
5499
- url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
5732
+ url.pathname = `${removeTrailingSlash(url.pathname)}.${extension}`;
5500
5733
  }
5501
5734
  }
5502
5735
  return url;
@@ -5508,7 +5741,8 @@ function decodeViaTurboStream(body, global2) {
5508
5741
  if (type === "SanitizedError") {
5509
5742
  let [name, message, stack] = rest;
5510
5743
  let Constructor = Error;
5511
- if (name && name in global2 && typeof global2[name] === "function") {
5744
+ if (name && SUPPORTED_ERROR_TYPES.includes(name) && name in global2 && // @ts-expect-error
5745
+ typeof global2[name] === "function") {
5512
5746
  Constructor = global2[name];
5513
5747
  }
5514
5748
  let error = new Constructor(message);
@@ -5699,9 +5933,11 @@ function dedupeLinkDescriptors(descriptors, preloads) {
5699
5933
  }, []);
5700
5934
  }
5701
5935
  function RemixRootDefaultHydrateFallback() {
5936
+ let { nonce } = useFrameworkContext();
5702
5937
  return /* @__PURE__ */ reactExports.createElement(BoundaryShell, { title: "Loading...", renderScripts: true }, /* @__PURE__ */ reactExports.createElement(
5703
5938
  "script",
5704
5939
  {
5940
+ nonce,
5705
5941
  dangerouslySetInnerHTML: {
5706
5942
  __html: `
5707
5943
  console.log(
@@ -5797,6 +6033,7 @@ function getRouteModuleComponent(routeModule) {
5797
6033
  function shouldHydrateRouteLoader(routeId, clientLoader, hasLoader, isSpaMode) {
5798
6034
  return isSpaMode && routeId !== "root" || clientLoader != null && (clientLoader.hydrate === true || hasLoader !== true);
5799
6035
  }
6036
+ var URL_LIMIT = 7680;
5800
6037
  function isFogOfWarEnabled(routeDiscovery, ssr) {
5801
6038
  return routeDiscovery.mode === "lazy" && ssr === true;
5802
6039
  }
@@ -5810,7 +6047,13 @@ function getPartialManifest({ sri, ...manifest }, router) {
5810
6047
  segments.pop();
5811
6048
  }
5812
6049
  paths.forEach((path) => {
5813
- let matches = matchRoutes(router.routes, path, router.basename);
6050
+ let matches = matchRoutesImpl(
6051
+ router.routes,
6052
+ path,
6053
+ router.basename || "/",
6054
+ false,
6055
+ router.branches
6056
+ );
5814
6057
  if (matches) {
5815
6058
  matches.forEach((m) => routeIds.add(m.route.id));
5816
6059
  }
@@ -5827,10 +6070,7 @@ function getPartialManifest({ sri, ...manifest }, router) {
5827
6070
  }
5828
6071
  function getManifestPath(_manifestPath, basename) {
5829
6072
  let manifestPath = _manifestPath || "/__manifest";
5830
- if (basename == null) {
5831
- return manifestPath;
5832
- }
5833
- return `${basename}${manifestPath}`.replace(/\/+/g, "/");
6073
+ return basename == null ? manifestPath : joinPaths([basename, manifestPath]);
5834
6074
  }
5835
6075
  function useDataRouterContext2() {
5836
6076
  let context = reactExports.useContext(DataRouterContext);
@@ -5936,13 +6176,22 @@ function getActiveMatches(matches, errors, isSpaMode) {
5936
6176
  }
5937
6177
  var CRITICAL_CSS_DATA_ATTRIBUTE = "data-react-router-critical-css";
5938
6178
  function Links({ nonce, crossOrigin }) {
5939
- let { isSpaMode, manifest, routeModules, criticalCss } = useFrameworkContext();
6179
+ let {
6180
+ isSpaMode,
6181
+ manifest,
6182
+ routeModules,
6183
+ criticalCss,
6184
+ nonce: contextNonce
6185
+ } = useFrameworkContext();
5940
6186
  let { errors, matches: routerMatches } = useDataRouterStateContext();
5941
6187
  let matches = getActiveMatches(routerMatches, errors, isSpaMode);
5942
6188
  let keyedLinks = reactExports.useMemo(
5943
6189
  () => getKeyedLinksForMatches(matches, routeModules, manifest),
5944
6190
  [matches, routeModules, manifest]
5945
6191
  );
6192
+ if (nonce == null && contextNonce) {
6193
+ nonce = contextNonce;
6194
+ }
5946
6195
  return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, typeof criticalCss === "string" ? /* @__PURE__ */ reactExports.createElement(
5947
6196
  "style",
5948
6197
  {
@@ -5980,6 +6229,8 @@ function Links({ nonce, crossOrigin }) {
5980
6229
  ));
5981
6230
  }
5982
6231
  function PrefetchPageLinks({ page, ...linkProps }) {
6232
+ let rsc = useIsRSCRouterContext();
6233
+ let { nonce: contextNonce } = useFrameworkContext();
5983
6234
  let { router } = useDataRouterContext2();
5984
6235
  let matches = reactExports.useMemo(
5985
6236
  () => matchRoutes(router.routes, page, router.basename),
@@ -5988,6 +6239,12 @@ function PrefetchPageLinks({ page, ...linkProps }) {
5988
6239
  if (!matches) {
5989
6240
  return null;
5990
6241
  }
6242
+ if (linkProps.nonce == null && contextNonce) {
6243
+ linkProps = { ...linkProps, nonce: contextNonce };
6244
+ }
6245
+ if (rsc) {
6246
+ return /* @__PURE__ */ reactExports.createElement(RSCPrefetchPageLinksImpl, { page, matches, ...linkProps });
6247
+ }
5991
6248
  return /* @__PURE__ */ reactExports.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
5992
6249
  }
5993
6250
  function useKeyedPrefetchLinks(matches) {
@@ -6008,6 +6265,46 @@ function useKeyedPrefetchLinks(matches) {
6008
6265
  }, [matches, manifest, routeModules]);
6009
6266
  return keyedPrefetchLinks;
6010
6267
  }
6268
+ function RSCPrefetchPageLinksImpl({
6269
+ page,
6270
+ matches: nextMatches,
6271
+ ...linkProps
6272
+ }) {
6273
+ let location = useLocation();
6274
+ let { future } = useFrameworkContext();
6275
+ let { basename } = useDataRouterContext2();
6276
+ let dataHrefs = reactExports.useMemo(() => {
6277
+ if (page === location.pathname + location.search + location.hash) {
6278
+ return [];
6279
+ }
6280
+ let url = singleFetchUrl(
6281
+ page,
6282
+ basename,
6283
+ future.v8_trailingSlashAwareDataRequests,
6284
+ "rsc"
6285
+ );
6286
+ let hasSomeRoutesWithShouldRevalidate = false;
6287
+ let targetRoutes = [];
6288
+ for (let match of nextMatches) {
6289
+ if (typeof match.route.shouldRevalidate === "function") {
6290
+ hasSomeRoutesWithShouldRevalidate = true;
6291
+ } else {
6292
+ targetRoutes.push(match.route.id);
6293
+ }
6294
+ }
6295
+ if (hasSomeRoutesWithShouldRevalidate && targetRoutes.length > 0) {
6296
+ url.searchParams.set("_routes", targetRoutes.join(","));
6297
+ }
6298
+ return [url.pathname + url.search];
6299
+ }, [
6300
+ basename,
6301
+ future.v8_trailingSlashAwareDataRequests,
6302
+ page,
6303
+ location,
6304
+ nextMatches
6305
+ ]);
6306
+ return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ reactExports.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })));
6307
+ }
6011
6308
  function PrefetchPageLinksImpl({
6012
6309
  page,
6013
6310
  matches: nextMatches,
@@ -6065,7 +6362,7 @@ function PrefetchPageLinksImpl({
6065
6362
  let url = singleFetchUrl(
6066
6363
  page,
6067
6364
  basename,
6068
- future.unstable_trailingSlashAwareDataRequests,
6365
+ future.v8_trailingSlashAwareDataRequests,
6069
6366
  "data"
6070
6367
  );
6071
6368
  if (foundOptOutRoute && routesParams.size > 0) {
@@ -6077,7 +6374,7 @@ function PrefetchPageLinksImpl({
6077
6374
  return [url.pathname + url.search];
6078
6375
  }, [
6079
6376
  basename,
6080
- future.unstable_trailingSlashAwareDataRequests,
6377
+ future.v8_trailingSlashAwareDataRequests,
6081
6378
  loaderData,
6082
6379
  location,
6083
6380
  manifest,
@@ -6198,7 +6495,7 @@ function Meta() {
6198
6495
  dangerouslySetInnerHTML: { __html: escapeHtml(json) }
6199
6496
  }
6200
6497
  );
6201
- } catch (err) {
6498
+ } catch (e) {
6202
6499
  return null;
6203
6500
  }
6204
6501
  }
@@ -6219,12 +6516,16 @@ function Scripts(scriptProps) {
6219
6516
  isSpaMode,
6220
6517
  renderMeta,
6221
6518
  routeDiscovery,
6222
- ssr
6519
+ ssr,
6520
+ nonce: contextNonce
6223
6521
  } = useFrameworkContext();
6224
6522
  let { router, static: isStatic, staticContext } = useDataRouterContext2();
6225
6523
  let { matches: routerMatches } = useDataRouterStateContext();
6226
6524
  let isRSCRouterContext = useIsRSCRouterContext();
6227
6525
  let enableFogOfWar = isFogOfWarEnabled(routeDiscovery, ssr);
6526
+ if (scriptProps.nonce == null && contextNonce) {
6527
+ scriptProps = { ...scriptProps, nonce: contextNonce };
6528
+ }
6228
6529
  if (renderMeta) {
6229
6530
  renderMeta.didRenderScripts = true;
6230
6531
  }
@@ -6315,13 +6616,16 @@ import(${JSON.stringify(manifest.entry.module)});`;
6315
6616
  }
6316
6617
  ));
6317
6618
  }, []);
6318
- let preloads = isHydrated || isRSCRouterContext ? [] : dedupe(
6319
- manifest.entry.imports.concat(
6320
- getModuleLinkHrefs(matches, manifest, {
6321
- includeHydrateFallback: true
6322
- })
6619
+ let preloads = isHydrated || isRSCRouterContext ? [] : [
6620
+ // Dedupe through a Set
6621
+ ...new Set(
6622
+ manifest.entry.imports.concat(
6623
+ getModuleLinkHrefs(matches, manifest, {
6624
+ includeHydrateFallback: true
6625
+ })
6626
+ )
6323
6627
  )
6324
- );
6628
+ ];
6325
6629
  let sri = typeof manifest.sri === "object" ? manifest.sri : {};
6326
6630
  warnOnce(
6327
6631
  !isRSCRouterContext,
@@ -6347,6 +6651,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
6347
6651
  href: manifest.url,
6348
6652
  crossOrigin: scriptProps.crossOrigin,
6349
6653
  integrity: sri[manifest.url],
6654
+ nonce: scriptProps.nonce,
6350
6655
  suppressHydrationWarning: true
6351
6656
  }
6352
6657
  ) : null, /* @__PURE__ */ reactExports.createElement(
@@ -6356,6 +6661,7 @@ import(${JSON.stringify(manifest.entry.module)});`;
6356
6661
  href: manifest.entry.module,
6357
6662
  crossOrigin: scriptProps.crossOrigin,
6358
6663
  integrity: sri[manifest.entry.module],
6664
+ nonce: scriptProps.nonce,
6359
6665
  suppressHydrationWarning: true
6360
6666
  }
6361
6667
  ), preloads.map((path) => /* @__PURE__ */ reactExports.createElement(
@@ -6366,13 +6672,11 @@ import(${JSON.stringify(manifest.entry.module)});`;
6366
6672
  href: path,
6367
6673
  crossOrigin: scriptProps.crossOrigin,
6368
6674
  integrity: sri[path],
6675
+ nonce: scriptProps.nonce,
6369
6676
  suppressHydrationWarning: true
6370
6677
  }
6371
6678
  )), initialScripts);
6372
6679
  }
6373
- function dedupe(array) {
6374
- return [...new Set(array)];
6375
- }
6376
6680
  function mergeRefs(...refs) {
6377
6681
  return (value) => {
6378
6682
  refs.forEach((ref) => {
@@ -6416,10 +6720,12 @@ function RemixRootDefaultErrorBoundary({
6416
6720
  error,
6417
6721
  isOutsideRemixApp
6418
6722
  }) {
6723
+ let { nonce } = useFrameworkContext();
6419
6724
  console.error(error);
6420
6725
  let heyDeveloper = /* @__PURE__ */ reactExports.createElement(
6421
6726
  "script",
6422
6727
  {
6728
+ nonce,
6423
6729
  dangerouslySetInnerHTML: {
6424
6730
  __html: `
6425
6731
  console.log(
@@ -6484,11 +6790,10 @@ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "un
6484
6790
  try {
6485
6791
  if (isBrowser2) {
6486
6792
  window.__reactRouterVersion = // @ts-expect-error
6487
- "7.13.1";
6793
+ "7.18.4";
6488
6794
  }
6489
6795
  } catch (e) {
6490
6796
  }
6491
- var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
6492
6797
  var Link = reactExports.forwardRef(
6493
6798
  function LinkWithRef({
6494
6799
  onClick,
@@ -6497,27 +6802,27 @@ var Link = reactExports.forwardRef(
6497
6802
  relative,
6498
6803
  reloadDocument,
6499
6804
  replace: replace2,
6500
- unstable_mask,
6805
+ mask,
6501
6806
  state,
6502
6807
  target,
6503
6808
  to,
6504
6809
  preventScrollReset,
6505
6810
  viewTransition,
6506
- unstable_defaultShouldRevalidate,
6811
+ defaultShouldRevalidate,
6507
6812
  ...rest
6508
6813
  }, forwardedRef) {
6509
- let { basename, navigator, unstable_useTransitions } = reactExports.useContext(NavigationContext);
6510
- let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
6814
+ let { basename, navigator, useTransitions } = reactExports.useContext(NavigationContext);
6815
+ let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX.test(to);
6511
6816
  let parsed = parseToInfo(to, basename);
6512
6817
  to = parsed.to;
6513
6818
  let href = useHref(to, { relative });
6514
6819
  let location = useLocation();
6515
6820
  let maskedHref = null;
6516
- if (unstable_mask) {
6821
+ if (mask) {
6517
6822
  let resolved = resolveTo(
6518
- unstable_mask,
6823
+ mask,
6519
6824
  [],
6520
- location.unstable_mask ? location.unstable_mask.pathname : "/",
6825
+ location.mask ? location.mask.pathname : "/",
6521
6826
  true
6522
6827
  );
6523
6828
  if (basename !== "/") {
@@ -6531,14 +6836,14 @@ var Link = reactExports.forwardRef(
6531
6836
  );
6532
6837
  let internalOnClick = useLinkClickHandler(to, {
6533
6838
  replace: replace2,
6534
- unstable_mask,
6839
+ mask,
6535
6840
  state,
6536
6841
  target,
6537
6842
  preventScrollReset,
6538
6843
  relative,
6539
6844
  viewTransition,
6540
- unstable_defaultShouldRevalidate,
6541
- unstable_useTransitions
6845
+ defaultShouldRevalidate,
6846
+ useTransitions
6542
6847
  });
6543
6848
  function handleClick(event) {
6544
6849
  if (onClick) onClick(event);
@@ -6647,14 +6952,14 @@ var Form = reactExports.forwardRef(
6647
6952
  relative,
6648
6953
  preventScrollReset,
6649
6954
  viewTransition,
6650
- unstable_defaultShouldRevalidate,
6955
+ defaultShouldRevalidate,
6651
6956
  ...props
6652
6957
  }, forwardedRef) => {
6653
- let { unstable_useTransitions } = reactExports.useContext(NavigationContext);
6958
+ let { useTransitions } = reactExports.useContext(NavigationContext);
6654
6959
  let submit = useSubmit();
6655
6960
  let formAction = useFormAction(action, { relative });
6656
6961
  let formMethod = method.toLowerCase() === "get" ? "get" : "post";
6657
- let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
6962
+ let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX.test(action);
6658
6963
  let submitHandler = (event) => {
6659
6964
  onSubmit && onSubmit(event);
6660
6965
  if (event.defaultPrevented) return;
@@ -6670,9 +6975,9 @@ var Form = reactExports.forwardRef(
6670
6975
  relative,
6671
6976
  preventScrollReset,
6672
6977
  viewTransition,
6673
- unstable_defaultShouldRevalidate
6978
+ defaultShouldRevalidate
6674
6979
  });
6675
- if (unstable_useTransitions && navigate !== false) {
6980
+ if (useTransitions && navigate !== false) {
6676
6981
  reactExports.startTransition(() => doSubmit());
6677
6982
  } else {
6678
6983
  doSubmit();
@@ -6736,6 +7041,9 @@ function ScrollRestoration({
6736
7041
  sessionStorage.removeItem(storageKey2);
6737
7042
  }
6738
7043
  }).toString();
7044
+ if (props.nonce == null && (remixContext == null ? void 0 : remixContext.nonce)) {
7045
+ props.nonce = remixContext.nonce;
7046
+ }
6739
7047
  return /* @__PURE__ */ reactExports.createElement(
6740
7048
  "script",
6741
7049
  {
@@ -6766,13 +7074,13 @@ function useDataRouterState2(hookName) {
6766
7074
  function useLinkClickHandler(to, {
6767
7075
  target,
6768
7076
  replace: replaceProp,
6769
- unstable_mask,
7077
+ mask,
6770
7078
  state,
6771
7079
  preventScrollReset,
6772
7080
  relative,
6773
7081
  viewTransition,
6774
- unstable_defaultShouldRevalidate,
6775
- unstable_useTransitions
7082
+ defaultShouldRevalidate,
7083
+ useTransitions
6776
7084
  } = {}) {
6777
7085
  let navigate = useNavigate();
6778
7086
  let location = useLocation();
@@ -6784,14 +7092,14 @@ function useLinkClickHandler(to, {
6784
7092
  let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
6785
7093
  let doNavigate = () => navigate(to, {
6786
7094
  replace: replace2,
6787
- unstable_mask,
7095
+ mask,
6788
7096
  state,
6789
7097
  preventScrollReset,
6790
7098
  relative,
6791
7099
  viewTransition,
6792
- unstable_defaultShouldRevalidate
7100
+ defaultShouldRevalidate
6793
7101
  });
6794
- if (unstable_useTransitions) {
7102
+ if (useTransitions) {
6795
7103
  reactExports.startTransition(() => doNavigate());
6796
7104
  } else {
6797
7105
  doNavigate();
@@ -6803,15 +7111,15 @@ function useLinkClickHandler(to, {
6803
7111
  navigate,
6804
7112
  path,
6805
7113
  replaceProp,
6806
- unstable_mask,
7114
+ mask,
6807
7115
  state,
6808
7116
  target,
6809
7117
  to,
6810
7118
  preventScrollReset,
6811
7119
  relative,
6812
7120
  viewTransition,
6813
- unstable_defaultShouldRevalidate,
6814
- unstable_useTransitions
7121
+ defaultShouldRevalidate,
7122
+ useTransitions
6815
7123
  ]
6816
7124
  );
6817
7125
  }
@@ -6868,7 +7176,7 @@ function useSubmit() {
6868
7176
  if (options.navigate === false) {
6869
7177
  let key = options.fetcherKey || getUniqueFetcherId();
6870
7178
  await routerFetch(key, currentRouteId, options.action || action, {
6871
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
7179
+ defaultShouldRevalidate: options.defaultShouldRevalidate,
6872
7180
  preventScrollReset: options.preventScrollReset,
6873
7181
  formData,
6874
7182
  body,
@@ -6878,7 +7186,7 @@ function useSubmit() {
6878
7186
  });
6879
7187
  } else {
6880
7188
  await routerNavigate(options.action || action, {
6881
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
7189
+ defaultShouldRevalidate: options.defaultShouldRevalidate,
6882
7190
  preventScrollReset: options.preventScrollReset,
6883
7191
  formData,
6884
7192
  body,
@@ -7090,7 +7398,7 @@ function StaticRouterProvider({
7090
7398
  let data2 = {
7091
7399
  loaderData: context.loaderData,
7092
7400
  actionData: context.actionData,
7093
- errors: serializeErrors$1(context.errors)
7401
+ errors: serializeErrors(context.errors)
7094
7402
  };
7095
7403
  let json = escapeHtml(JSON.stringify(JSON.stringify(data2)));
7096
7404
  hydrateScript = `window.__staticRouterHydrationData = JSON.parse(${json});`;
@@ -7104,11 +7412,12 @@ function StaticRouterProvider({
7104
7412
  navigationType: state.historyAction,
7105
7413
  navigator: dataRouterContext.navigator,
7106
7414
  static: dataRouterContext.static,
7107
- unstable_useTransitions: false
7415
+ useTransitions: false
7108
7416
  },
7109
7417
  /* @__PURE__ */ reactExports.createElement(
7110
- DataRoutes,
7418
+ DataRoutes2,
7111
7419
  {
7420
+ manifest: router.manifest,
7112
7421
  routes: router.routes,
7113
7422
  future: router.future,
7114
7423
  state,
@@ -7124,7 +7433,7 @@ function StaticRouterProvider({
7124
7433
  }
7125
7434
  ) : null);
7126
7435
  }
7127
- function serializeErrors$1(errors) {
7436
+ function serializeErrors(errors) {
7128
7437
  if (!errors) return null;
7129
7438
  let entries = Object.entries(errors);
7130
7439
  let serialized = {};
@@ -7201,6 +7510,8 @@ function createStaticRouter(routes, context, opts = {}) {
7201
7510
  get future() {
7202
7511
  return {
7203
7512
  v8_middleware: false,
7513
+ v8_passThroughRequests: false,
7514
+ v8_trailingSlashAwareDataRequests: false,
7204
7515
  ...opts == null ? void 0 : opts.future
7205
7516
  };
7206
7517
  },
@@ -7225,6 +7536,12 @@ function createStaticRouter(routes, context, opts = {}) {
7225
7536
  get routes() {
7226
7537
  return dataRoutes;
7227
7538
  },
7539
+ get branches() {
7540
+ return opts.branches;
7541
+ },
7542
+ get manifest() {
7543
+ return manifest;
7544
+ },
7228
7545
  get window() {
7229
7546
  return void 0;
7230
7547
  },
@@ -7284,174 +7601,13 @@ function createHref(to) {
7284
7601
  function encodeLocation(to) {
7285
7602
  let href = typeof to === "string" ? to : createPath(to);
7286
7603
  href = href.replace(/ $/, "%20");
7287
- let encoded = ABSOLUTE_URL_REGEX3.test(href) ? new URL(href) : new URL(href, "http://localhost");
7604
+ let encoded = ABSOLUTE_URL_REGEX.test(href) ? new URL(href) : new URL(href, "http://localhost");
7288
7605
  return {
7289
7606
  pathname: encoded.pathname,
7290
7607
  search: encoded.search,
7291
7608
  hash: encoded.hash
7292
7609
  };
7293
7610
  }
7294
- var ABSOLUTE_URL_REGEX3 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
7295
- var dist = {};
7296
- var hasRequiredDist;
7297
- function requireDist() {
7298
- if (hasRequiredDist) return dist;
7299
- hasRequiredDist = 1;
7300
- Object.defineProperty(dist, "__esModule", { value: true });
7301
- dist.parse = parse;
7302
- dist.serialize = serialize;
7303
- const cookieNameRegExp = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/;
7304
- const cookieValueRegExp = /^[\u0021-\u003A\u003C-\u007E]*$/;
7305
- const domainValueRegExp = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i;
7306
- const pathValueRegExp = /^[\u0020-\u003A\u003D-\u007E]*$/;
7307
- const __toString = Object.prototype.toString;
7308
- const NullObject = /* @__PURE__ */ (() => {
7309
- const C = function() {
7310
- };
7311
- C.prototype = /* @__PURE__ */ Object.create(null);
7312
- return C;
7313
- })();
7314
- function parse(str, options) {
7315
- const obj = new NullObject();
7316
- const len = str.length;
7317
- if (len < 2)
7318
- return obj;
7319
- const dec = (options == null ? void 0 : options.decode) || decode2;
7320
- let index = 0;
7321
- do {
7322
- const eqIdx = str.indexOf("=", index);
7323
- if (eqIdx === -1)
7324
- break;
7325
- const colonIdx = str.indexOf(";", index);
7326
- const endIdx = colonIdx === -1 ? len : colonIdx;
7327
- if (eqIdx > endIdx) {
7328
- index = str.lastIndexOf(";", eqIdx - 1) + 1;
7329
- continue;
7330
- }
7331
- const keyStartIdx = startIndex(str, index, eqIdx);
7332
- const keyEndIdx = endIndex(str, eqIdx, keyStartIdx);
7333
- const key = str.slice(keyStartIdx, keyEndIdx);
7334
- if (obj[key] === void 0) {
7335
- let valStartIdx = startIndex(str, eqIdx + 1, endIdx);
7336
- let valEndIdx = endIndex(str, endIdx, valStartIdx);
7337
- const value = dec(str.slice(valStartIdx, valEndIdx));
7338
- obj[key] = value;
7339
- }
7340
- index = endIdx + 1;
7341
- } while (index < len);
7342
- return obj;
7343
- }
7344
- function startIndex(str, index, max) {
7345
- do {
7346
- const code = str.charCodeAt(index);
7347
- if (code !== 32 && code !== 9)
7348
- return index;
7349
- } while (++index < max);
7350
- return max;
7351
- }
7352
- function endIndex(str, index, min) {
7353
- while (index > min) {
7354
- const code = str.charCodeAt(--index);
7355
- if (code !== 32 && code !== 9)
7356
- return index + 1;
7357
- }
7358
- return min;
7359
- }
7360
- function serialize(name, val, options) {
7361
- const enc = (options == null ? void 0 : options.encode) || encodeURIComponent;
7362
- if (!cookieNameRegExp.test(name)) {
7363
- throw new TypeError(`argument name is invalid: ${name}`);
7364
- }
7365
- const value = enc(val);
7366
- if (!cookieValueRegExp.test(value)) {
7367
- throw new TypeError(`argument val is invalid: ${val}`);
7368
- }
7369
- let str = name + "=" + value;
7370
- if (!options)
7371
- return str;
7372
- if (options.maxAge !== void 0) {
7373
- if (!Number.isInteger(options.maxAge)) {
7374
- throw new TypeError(`option maxAge is invalid: ${options.maxAge}`);
7375
- }
7376
- str += "; Max-Age=" + options.maxAge;
7377
- }
7378
- if (options.domain) {
7379
- if (!domainValueRegExp.test(options.domain)) {
7380
- throw new TypeError(`option domain is invalid: ${options.domain}`);
7381
- }
7382
- str += "; Domain=" + options.domain;
7383
- }
7384
- if (options.path) {
7385
- if (!pathValueRegExp.test(options.path)) {
7386
- throw new TypeError(`option path is invalid: ${options.path}`);
7387
- }
7388
- str += "; Path=" + options.path;
7389
- }
7390
- if (options.expires) {
7391
- if (!isDate(options.expires) || !Number.isFinite(options.expires.valueOf())) {
7392
- throw new TypeError(`option expires is invalid: ${options.expires}`);
7393
- }
7394
- str += "; Expires=" + options.expires.toUTCString();
7395
- }
7396
- if (options.httpOnly) {
7397
- str += "; HttpOnly";
7398
- }
7399
- if (options.secure) {
7400
- str += "; Secure";
7401
- }
7402
- if (options.partitioned) {
7403
- str += "; Partitioned";
7404
- }
7405
- if (options.priority) {
7406
- const priority = typeof options.priority === "string" ? options.priority.toLowerCase() : void 0;
7407
- switch (priority) {
7408
- case "low":
7409
- str += "; Priority=Low";
7410
- break;
7411
- case "medium":
7412
- str += "; Priority=Medium";
7413
- break;
7414
- case "high":
7415
- str += "; Priority=High";
7416
- break;
7417
- default:
7418
- throw new TypeError(`option priority is invalid: ${options.priority}`);
7419
- }
7420
- }
7421
- if (options.sameSite) {
7422
- const sameSite = typeof options.sameSite === "string" ? options.sameSite.toLowerCase() : options.sameSite;
7423
- switch (sameSite) {
7424
- case true:
7425
- case "strict":
7426
- str += "; SameSite=Strict";
7427
- break;
7428
- case "lax":
7429
- str += "; SameSite=Lax";
7430
- break;
7431
- case "none":
7432
- str += "; SameSite=None";
7433
- break;
7434
- default:
7435
- throw new TypeError(`option sameSite is invalid: ${options.sameSite}`);
7436
- }
7437
- }
7438
- return str;
7439
- }
7440
- function decode2(str) {
7441
- if (str.indexOf("%") === -1)
7442
- return str;
7443
- try {
7444
- return decodeURIComponent(str);
7445
- } catch (e) {
7446
- return str;
7447
- }
7448
- }
7449
- function isDate(val) {
7450
- return __toString.call(val) === "[object Date]";
7451
- }
7452
- return dist;
7453
- }
7454
- requireDist();
7455
7611
  var setCookie = { exports: {} };
7456
7612
  var hasRequiredSetCookie;
7457
7613
  function requireSetCookie() {
@@ -7637,7 +7793,7 @@ function requireSetCookie() {
7637
7793
  }
7638
7794
  var setCookieExports = /* @__PURE__ */ requireSetCookie();
7639
7795
  /**
7640
- * react-router v7.13.1
7796
+ * react-router v7.18.4
7641
7797
  *
7642
7798
  * Copyright (c) Remix Software Inc.
7643
7799
  *
@@ -7677,7 +7833,9 @@ function ServerRouter({
7677
7833
  delete context.staticHandlerContext.loaderData[routeId];
7678
7834
  }
7679
7835
  }
7680
- let router = createStaticRouter(routes, context.staticHandlerContext);
7836
+ let router = createStaticRouter(routes, context.staticHandlerContext, {
7837
+ branches: context.branches
7838
+ });
7681
7839
  return /* @__PURE__ */ reactExports.createElement(reactExports.Fragment, null, /* @__PURE__ */ reactExports.createElement(
7682
7840
  FrameworkContext.Provider,
7683
7841
  {
@@ -7690,6 +7848,7 @@ function ServerRouter({
7690
7848
  ssr: context.ssr,
7691
7849
  isSpaMode: context.isSpaMode,
7692
7850
  routeDiscovery: context.routeDiscovery,
7851
+ nonce,
7693
7852
  serializeError: context.serializeError,
7694
7853
  renderMeta: context.renderMeta
7695
7854
  }
@@ -7745,52 +7904,43 @@ function serializeError(error, serverMode) {
7745
7904
  stack: sanitized.stack
7746
7905
  };
7747
7906
  }
7748
- function serializeErrors(errors, serverMode) {
7749
- if (!errors) return null;
7750
- let entries = Object.entries(errors);
7751
- let serialized = {};
7752
- for (let [key, val] of entries) {
7753
- if (isRouteErrorResponse(val)) {
7754
- serialized[key] = { ...val, __type: "RouteErrorResponse" };
7755
- } else if (val instanceof Error) {
7756
- let sanitized = sanitizeError(val, serverMode);
7757
- serialized[key] = {
7758
- message: sanitized.message,
7759
- stack: sanitized.stack,
7760
- __type: "Error",
7761
- // If this is a subclass (i.e., ReferenceError), send up the type so we
7762
- // can re-create the same type during hydration. This will only apply
7763
- // in dev mode since all production errors are sanitized to normal
7764
- // Error instances
7765
- ...sanitized.name !== "Error" ? {
7766
- __subType: sanitized.name
7767
- } : {}
7768
- };
7769
- } else {
7770
- serialized[key] = val;
7771
- }
7907
+ function invariant(value, message) {
7908
+ if (value === false || value === null || typeof value === "undefined") {
7909
+ console.error(
7910
+ "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
7911
+ );
7912
+ throw new Error(message);
7772
7913
  }
7773
- return serialized;
7774
7914
  }
7775
- function matchServerRoutes(routes, pathname, basename) {
7776
- let matches = matchRoutes(
7777
- routes,
7915
+ function matchServerRoutes(manifest, dataRoutes, branches, pathname, basename) {
7916
+ let matches = matchRoutesImpl(
7917
+ dataRoutes,
7778
7918
  pathname,
7779
- basename
7919
+ basename ?? "/",
7920
+ false,
7921
+ branches
7780
7922
  );
7781
7923
  if (!matches) return null;
7782
- return matches.map((match) => ({
7783
- params: match.params,
7784
- pathname: match.pathname,
7785
- route: match.route
7786
- }));
7924
+ return matches.map((match) => {
7925
+ let route = manifest[match.route.id];
7926
+ invariant(
7927
+ route,
7928
+ `Route with id "${match.route.id}" not found in manifest.`
7929
+ );
7930
+ return {
7931
+ params: match.params,
7932
+ pathname: match.pathname,
7933
+ route
7934
+ };
7935
+ });
7787
7936
  }
7788
- async function callRouteHandler(handler, args) {
7937
+ async function callRouteHandler(handler, args, future) {
7789
7938
  let result = await handler({
7790
- request: stripRoutesParam(stripIndexParam(args.request)),
7939
+ request: future.v8_passThroughRequests ? args.request : stripRoutesParam(stripIndexParam(args.request)),
7940
+ url: args.url,
7791
7941
  params: args.params,
7792
7942
  context: args.context,
7793
- unstable_pattern: args.unstable_pattern
7943
+ pattern: args.pattern
7794
7944
  });
7795
7945
  if (isDataWithResponseInit(result) && result.init && result.init.status && isRedirectStatusCode(result.init.status)) {
7796
7946
  throw new Response(null, result.init);
@@ -7835,23 +7985,14 @@ function stripRoutesParam(request) {
7835
7985
  }
7836
7986
  return new Request(url.href, init);
7837
7987
  }
7838
- function invariant(value, message) {
7839
- if (value === false || value === null || typeof value === "undefined") {
7840
- console.error(
7841
- "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
7842
- );
7843
- throw new Error(message);
7844
- }
7845
- }
7846
7988
  var globalDevServerHooksKey = "__reactRouterDevServerHooks";
7847
7989
  function getDevServerHooks() {
7848
7990
  return globalThis[globalDevServerHooksKey];
7849
7991
  }
7850
7992
  function getBuildTimeHeader(request, headerName) {
7851
- var _a;
7852
7993
  if (typeof process !== "undefined") {
7853
7994
  try {
7854
- if (((_a = process.env) == null ? void 0 : _a.IS_RR_BUILD_REQUEST) === "yes") {
7995
+ if (process.env.hasOwnProperty("IS_RR_BUILD_REQUEST") && process.env.IS_RR_BUILD_REQUEST === "yes") {
7855
7996
  return request.headers.get(headerName);
7856
7997
  }
7857
7998
  } catch (e) {
@@ -7872,12 +8013,6 @@ function groupRoutesByParentId(manifest) {
7872
8013
  });
7873
8014
  return routes;
7874
8015
  }
7875
- function createRoutes(manifest, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) {
7876
- return (routesByParentId[parentId] || []).map((route) => ({
7877
- ...route,
7878
- children: createRoutes(manifest, route.id, routesByParentId)
7879
- }));
7880
- }
7881
8016
  function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesByParentId = groupRoutesByParentId(manifest)) {
7882
8017
  return (routesByParentId[parentId] || []).map((route) => {
7883
8018
  let commonRoute = {
@@ -7928,10 +8063,14 @@ function createStaticHandlerDataRoutes(manifest, future, parentId = "", routesBy
7928
8063
  return result.data;
7929
8064
  }
7930
8065
  }
7931
- let val = await callRouteHandler(route.module.loader, args);
8066
+ let val = await callRouteHandler(
8067
+ route.module.loader,
8068
+ args,
8069
+ future
8070
+ );
7932
8071
  return val;
7933
8072
  } : void 0,
7934
- action: route.module.action ? (args) => callRouteHandler(route.module.action, args) : void 0,
8073
+ action: route.module.action ? (args) => callRouteHandler(route.module.action, args, future) : void 0,
7935
8074
  handle: route.module.handle
7936
8075
  };
7937
8076
  return route.index ? {
@@ -8021,28 +8160,29 @@ function prependCookies(parentHeaders, childHeaders) {
8021
8160
  });
8022
8161
  }
8023
8162
  }
8024
- function throwIfPotentialCSRFAttack(headers, allowedActionOrigins) {
8025
- let originHeader = headers.get("origin");
8163
+ function throwIfPotentialCSRFAttack(request, allowedActionOrigins) {
8164
+ let originHeader = request.headers.get("origin");
8026
8165
  let originDomain = null;
8166
+ let originUrl = null;
8027
8167
  try {
8028
- originDomain = typeof originHeader === "string" && originHeader !== "null" ? new URL(originHeader).host : originHeader;
8168
+ if (typeof originHeader === "string" && originHeader !== "null") {
8169
+ originUrl = new URL(originHeader);
8170
+ originDomain = originUrl.host;
8171
+ } else {
8172
+ originDomain = originHeader;
8173
+ }
8029
8174
  } catch {
8030
8175
  throw new Error(
8031
8176
  `\`origin\` header is not a valid URL. Aborting the action.`
8032
8177
  );
8033
8178
  }
8034
- let host = parseHostHeader(headers);
8035
- if (originDomain && (!host || originDomain !== host.value)) {
8179
+ let requestUrl = new URL(request.url);
8180
+ let originMatchesRequest = originUrl ? originUrl.origin === requestUrl.origin : originDomain === requestUrl.host;
8181
+ if (originDomain && !originMatchesRequest) {
8036
8182
  if (!isAllowedOrigin(originDomain, allowedActionOrigins)) {
8037
- if (host) {
8038
- throw new Error(
8039
- `${host.type} header does not match \`origin\` header from a forwarded action request. Aborting the action.`
8040
- );
8041
- } else {
8042
- throw new Error(
8043
- "`x-forwarded-host` or `host` headers are not provided. One of these is needed to compare the `origin` header from a forwarded action request. Aborting the action."
8044
- );
8045
- }
8183
+ throw new Error(
8184
+ "The `request.url` origin does not match `origin` header from a forwarded action request. Aborting the action."
8185
+ );
8046
8186
  }
8047
8187
  }
8048
8188
  }
@@ -8090,18 +8230,38 @@ function isAllowedOrigin(originDomain, allowedActionOrigins = []) {
8090
8230
  (allowedOrigin) => allowedOrigin && (allowedOrigin === originDomain || matchWildcardDomain(originDomain, allowedOrigin))
8091
8231
  );
8092
8232
  }
8093
- function parseHostHeader(headers) {
8094
- var _a;
8095
- let forwardedHostHeader = headers.get("x-forwarded-host");
8096
- let forwardedHostValue = (_a = forwardedHostHeader == null ? void 0 : forwardedHostHeader.split(",")[0]) == null ? void 0 : _a.trim();
8097
- let hostHeader = headers.get("host");
8098
- return forwardedHostValue ? {
8099
- type: "x-forwarded-host",
8100
- value: forwardedHostValue
8101
- } : hostHeader ? {
8102
- type: "host",
8103
- value: hostHeader
8104
- } : void 0;
8233
+ function getNormalizedPath(request, basename, future) {
8234
+ basename = basename || "/";
8235
+ let url = new URL(request.url);
8236
+ let pathname = url.pathname;
8237
+ if (future == null ? void 0 : future.v8_trailingSlashAwareDataRequests) {
8238
+ if (pathname.endsWith("/_.data")) {
8239
+ pathname = pathname.replace(/_\.data$/, "");
8240
+ } else {
8241
+ pathname = pathname.replace(/\.data$/, "");
8242
+ }
8243
+ } else {
8244
+ if (stripBasename(pathname, basename) === "/_root.data") {
8245
+ pathname = basename;
8246
+ } else if (pathname.endsWith(".data")) {
8247
+ pathname = pathname.replace(/\.data$/, "");
8248
+ }
8249
+ if (stripBasename(pathname, basename) !== "/" && pathname.endsWith("/")) {
8250
+ pathname = pathname.slice(0, -1);
8251
+ }
8252
+ }
8253
+ let searchParams = new URLSearchParams(url.search);
8254
+ searchParams.delete("_routes");
8255
+ let search = searchParams.toString();
8256
+ if (search) {
8257
+ search = `?${search}`;
8258
+ }
8259
+ return {
8260
+ pathname,
8261
+ search,
8262
+ // No hashes on the server
8263
+ hash: ""
8264
+ };
8105
8265
  }
8106
8266
  var SERVER_NO_BODY_STATUS_CODES = /* @__PURE__ */ new Set([
8107
8267
  ...NO_BODY_STATUS_CODES,
@@ -8111,13 +8271,13 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
8111
8271
  try {
8112
8272
  try {
8113
8273
  throwIfPotentialCSRFAttack(
8114
- request.headers,
8274
+ request,
8115
8275
  Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []
8116
8276
  );
8117
8277
  } catch (e) {
8118
8278
  return handleQueryError(new Error("Bad Request"), 400);
8119
8279
  }
8120
- let handlerRequest = new Request(handlerUrl, {
8280
+ let handlerRequest = build.future.v8_passThroughRequests ? request : new Request(handlerUrl, {
8121
8281
  method: request.method,
8122
8282
  body: request.body,
8123
8283
  headers: request.headers,
@@ -8135,7 +8295,8 @@ async function singleFetchAction(build, serverMode, staticHandler, request, hand
8135
8295
  } catch (error) {
8136
8296
  return handleQueryError(error);
8137
8297
  }
8138
- } : void 0
8298
+ } : void 0,
8299
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
8139
8300
  });
8140
8301
  return handleQueryResult(result);
8141
8302
  } catch (error) {
@@ -8184,7 +8345,7 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
8184
8345
  let routesParam = new URL(request.url).searchParams.get("_routes");
8185
8346
  let loadRouteIds = routesParam ? new Set(routesParam.split(",")) : null;
8186
8347
  try {
8187
- let handlerRequest = new Request(handlerUrl, {
8348
+ let handlerRequest = build.future.v8_passThroughRequests ? request : new Request(handlerUrl, {
8188
8349
  headers: request.headers,
8189
8350
  signal: request.signal
8190
8351
  });
@@ -8199,7 +8360,8 @@ async function singleFetchLoaders(build, serverMode, staticHandler, request, han
8199
8360
  } catch (error) {
8200
8361
  return handleQueryError(error);
8201
8362
  }
8202
- } : void 0
8363
+ } : void 0,
8364
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
8203
8365
  });
8204
8366
  return handleQueryResult(result);
8205
8367
  } catch (error) {
@@ -8317,14 +8479,24 @@ function getSingleFetchRedirect(status, headers, basename) {
8317
8479
  function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode) {
8318
8480
  let controller = new AbortController();
8319
8481
  let timeoutId = setTimeout(
8320
- () => controller.abort(new Error("Server Timeout")),
8482
+ () => {
8483
+ controller.abort(new Error("Server Timeout"));
8484
+ cleanupCallbacks();
8485
+ },
8321
8486
  typeof streamTimeout === "number" ? streamTimeout : 4950
8322
8487
  );
8323
- let clearStreamTimeout = () => clearTimeout(timeoutId);
8324
- requestSignal.addEventListener("abort", clearStreamTimeout);
8488
+ let abortControllerOnRequestAbort = () => {
8489
+ controller.abort(requestSignal.reason);
8490
+ cleanupCallbacks();
8491
+ };
8492
+ requestSignal.addEventListener("abort", abortControllerOnRequestAbort);
8493
+ let cleanupCallbacks = () => {
8494
+ clearTimeout(timeoutId);
8495
+ requestSignal.removeEventListener("abort", abortControllerOnRequestAbort);
8496
+ };
8325
8497
  return encode(data2, {
8326
8498
  signal: controller.signal,
8327
- onComplete: clearStreamTimeout,
8499
+ onComplete: cleanupCallbacks,
8328
8500
  plugins: [
8329
8501
  (value) => {
8330
8502
  if (value instanceof Error) {
@@ -8354,12 +8526,12 @@ function encodeViaTurboStream(data2, requestSignal, streamTimeout, serverMode) {
8354
8526
  });
8355
8527
  }
8356
8528
  function derive(build, mode) {
8357
- let routes = createRoutes(build.routes);
8358
8529
  let dataRoutes = createStaticHandlerDataRoutes(build.routes, build.future);
8359
8530
  let serverMode = isServerMode(mode) ? mode : "production";
8360
8531
  let staticHandler = createStaticHandler(dataRoutes, {
8361
8532
  basename: build.basename,
8362
- unstable_instrumentations: build.entry.module.unstable_instrumentations
8533
+ instrumentations: build.entry.module.instrumentations,
8534
+ future: build.future
8363
8535
  });
8364
8536
  let errorHandler = build.entry.module.handleError || ((error, { request }) => {
8365
8537
  if (serverMode !== "test" && !request.signal.aborted) {
@@ -8396,36 +8568,23 @@ function derive(build, mode) {
8396
8568
  } else {
8397
8569
  loadContext = initialContext || {};
8398
8570
  }
8399
- let url = new URL(request.url);
8400
- let normalizedBasename = build.basename || "/";
8401
- let normalizedPath = url.pathname;
8402
- if (build.future.unstable_trailingSlashAwareDataRequests) {
8403
- if (normalizedPath.endsWith("/_.data")) {
8404
- normalizedPath = normalizedPath.replace(/_.data$/, "");
8405
- } else {
8406
- normalizedPath = normalizedPath.replace(/\.data$/, "");
8407
- }
8408
- } else {
8409
- if (stripBasename(normalizedPath, normalizedBasename) === "/_root.data") {
8410
- normalizedPath = normalizedBasename;
8411
- } else if (normalizedPath.endsWith(".data")) {
8412
- normalizedPath = normalizedPath.replace(/\.data$/, "");
8413
- }
8414
- if (stripBasename(normalizedPath, normalizedBasename) !== "/" && normalizedPath.endsWith("/")) {
8415
- normalizedPath = normalizedPath.slice(0, -1);
8416
- }
8417
- }
8571
+ let requestUrl = new URL(request.url);
8572
+ let normalizedPathname = getNormalizedPath(
8573
+ request,
8574
+ build.basename,
8575
+ build.future
8576
+ ).pathname;
8418
8577
  let isSpaMode = getBuildTimeHeader(request, "X-React-Router-SPA-Mode") === "yes";
8419
8578
  if (!build.ssr) {
8420
- let decodedPath = decodeURI(normalizedPath);
8421
- if (normalizedBasename !== "/") {
8422
- let strippedPath = stripBasename(decodedPath, normalizedBasename);
8579
+ let decodedPath = decodeURI(normalizedPathname);
8580
+ if (build.basename && build.basename !== "/") {
8581
+ let strippedPath = stripBasename(decodedPath, build.basename);
8423
8582
  if (strippedPath == null) {
8424
8583
  errorHandler(
8425
8584
  new ErrorResponseImpl(
8426
8585
  404,
8427
8586
  "Not Found",
8428
- `Refusing to prerender the \`${decodedPath}\` path because it does not start with the basename \`${normalizedBasename}\``
8587
+ `Refusing to prerender the \`${decodedPath}\` path because it does not start with the basename \`${build.basename}\``
8429
8588
  ),
8430
8589
  {
8431
8590
  context: loadContext,
@@ -8442,8 +8601,8 @@ function derive(build, mode) {
8442
8601
  }
8443
8602
  if (build.prerender.length === 0) {
8444
8603
  isSpaMode = true;
8445
- } else if (!build.prerender.includes(decodedPath) && !build.prerender.includes(decodedPath + "/")) {
8446
- if (url.pathname.endsWith(".data")) {
8604
+ } else if (!build.prerender.includes(decodedPath.replace(/\/$/, "")) && !build.prerender.includes(decodedPath.replace(/[^/]$/, "/"))) {
8605
+ if (requestUrl.pathname.endsWith(".data")) {
8447
8606
  errorHandler(
8448
8607
  new ErrorResponseImpl(
8449
8608
  404,
@@ -8467,36 +8626,40 @@ function derive(build, mode) {
8467
8626
  }
8468
8627
  let manifestUrl = getManifestPath(
8469
8628
  build.routeDiscovery.manifestPath,
8470
- normalizedBasename
8629
+ build.basename
8471
8630
  );
8472
- if (url.pathname === manifestUrl) {
8631
+ if (build.routeDiscovery.mode === "lazy" && requestUrl.pathname === manifestUrl) {
8473
8632
  try {
8474
- let res = await handleManifestRequest(build, routes, url);
8633
+ let res = await handleManifestRequest(
8634
+ build,
8635
+ staticHandler.dataRoutes,
8636
+ staticHandler._internalRouteBranches,
8637
+ requestUrl
8638
+ );
8475
8639
  return res;
8476
8640
  } catch (e) {
8477
8641
  handleError(e);
8478
8642
  return new Response("Unknown Server Error", { status: 500 });
8479
8643
  }
8480
8644
  }
8481
- let matches = matchServerRoutes(routes, normalizedPath, build.basename);
8645
+ let matches = matchServerRoutes(
8646
+ build.routes,
8647
+ staticHandler.dataRoutes,
8648
+ staticHandler._internalRouteBranches,
8649
+ normalizedPathname,
8650
+ build.basename
8651
+ );
8482
8652
  if (matches && matches.length > 0) {
8483
8653
  Object.assign(params, matches[0].params);
8484
8654
  }
8485
8655
  let response;
8486
- if (url.pathname.endsWith(".data")) {
8487
- let handlerUrl = new URL(request.url);
8488
- handlerUrl.pathname = normalizedPath;
8489
- let singleFetchMatches = matchServerRoutes(
8490
- routes,
8491
- handlerUrl.pathname,
8492
- build.basename
8493
- );
8656
+ if (requestUrl.pathname.endsWith(".data")) {
8494
8657
  response = await handleSingleFetchRequest(
8495
8658
  serverMode,
8496
8659
  build,
8497
8660
  staticHandler,
8498
8661
  request,
8499
- handlerUrl,
8662
+ normalizedPathname,
8500
8663
  loadContext,
8501
8664
  handleError
8502
8665
  );
@@ -8511,7 +8674,7 @@ function derive(build, mode) {
8511
8674
  if (build.entry.module.handleDataRequest) {
8512
8675
  response = await build.entry.module.handleDataRequest(response, {
8513
8676
  context: loadContext,
8514
- params: singleFetchMatches ? singleFetchMatches[0].params : {},
8677
+ params: matches ? matches[0].params : {},
8515
8678
  request
8516
8679
  });
8517
8680
  if (isRedirectResponse(response)) {
@@ -8534,7 +8697,7 @@ function derive(build, mode) {
8534
8697
  handleError
8535
8698
  );
8536
8699
  } else {
8537
- let { pathname } = url;
8700
+ let { pathname } = requestUrl;
8538
8701
  let criticalCss = void 0;
8539
8702
  if (build.unstable_getCriticalCss) {
8540
8703
  criticalCss = await build.unstable_getCriticalCss({ pathname });
@@ -8561,15 +8724,13 @@ function derive(build, mode) {
8561
8724
  }
8562
8725
  return response;
8563
8726
  };
8564
- if (build.entry.module.unstable_instrumentations) {
8727
+ if (build.entry.module.instrumentations) {
8565
8728
  requestHandler = instrumentHandler(
8566
8729
  requestHandler,
8567
- build.entry.module.unstable_instrumentations.map((i) => i.handler).filter(Boolean)
8730
+ build.entry.module.instrumentations.map((i) => i.handler).filter(Boolean)
8568
8731
  );
8569
8732
  }
8570
8733
  return {
8571
- routes,
8572
- dataRoutes,
8573
8734
  serverMode,
8574
8735
  staticHandler,
8575
8736
  errorHandler,
@@ -8578,7 +8739,6 @@ function derive(build, mode) {
8578
8739
  }
8579
8740
  var createRequestHandler$1 = (build, mode) => {
8580
8741
  let _build;
8581
- let routes;
8582
8742
  let serverMode;
8583
8743
  let staticHandler;
8584
8744
  let errorHandler;
@@ -8587,14 +8747,12 @@ var createRequestHandler$1 = (build, mode) => {
8587
8747
  _build = typeof build === "function" ? await build() : build;
8588
8748
  if (typeof build === "function") {
8589
8749
  let derived = derive(_build, mode);
8590
- routes = derived.routes;
8591
8750
  serverMode = derived.serverMode;
8592
8751
  staticHandler = derived.staticHandler;
8593
8752
  errorHandler = derived.errorHandler;
8594
8753
  _requestHandler = derived.requestHandler;
8595
- } else if (!routes || !serverMode || !staticHandler || !errorHandler || !_requestHandler) {
8754
+ } else if (!serverMode || !staticHandler || !errorHandler || !_requestHandler) {
8596
8755
  let derived = derive(_build, mode);
8597
- routes = derived.routes;
8598
8756
  serverMode = derived.serverMode;
8599
8757
  staticHandler = derived.staticHandler;
8600
8758
  errorHandler = derived.errorHandler;
@@ -8603,7 +8761,13 @@ var createRequestHandler$1 = (build, mode) => {
8603
8761
  return _requestHandler(request, initialContext);
8604
8762
  };
8605
8763
  };
8606
- async function handleManifestRequest(build, routes, url) {
8764
+ async function handleManifestRequest(build, dataRoutes, branches, url) {
8765
+ if (url.toString().length > URL_LIMIT) {
8766
+ return new Response(null, {
8767
+ statusText: "Bad Request",
8768
+ status: 400
8769
+ });
8770
+ }
8607
8771
  if (build.assets.version !== url.searchParams.get("version")) {
8608
8772
  return new Response(null, {
8609
8773
  status: 204,
@@ -8614,21 +8778,19 @@ async function handleManifestRequest(build, routes, url) {
8614
8778
  }
8615
8779
  let patches = {};
8616
8780
  if (url.searchParams.has("paths")) {
8617
- let paths = /* @__PURE__ */ new Set();
8618
8781
  let pathParam = url.searchParams.get("paths") || "";
8619
- let requestedPaths = pathParam.split(",").filter(Boolean);
8620
- requestedPaths.forEach((path) => {
8782
+ let paths = new Set(pathParam.split(",").filter(Boolean));
8783
+ for (let path of paths) {
8621
8784
  if (!path.startsWith("/")) {
8622
8785
  path = `/${path}`;
8623
8786
  }
8624
- let segments = path.split("/").slice(1);
8625
- segments.forEach((_, i) => {
8626
- let partialPath = segments.slice(0, i + 1).join("/");
8627
- paths.add(`/${partialPath}`);
8628
- });
8629
- });
8630
- for (let path of paths) {
8631
- let matches = matchServerRoutes(routes, path, build.basename);
8787
+ let matches = matchServerRoutes(
8788
+ build.routes,
8789
+ dataRoutes,
8790
+ branches,
8791
+ path,
8792
+ build.basename
8793
+ );
8632
8794
  if (matches) {
8633
8795
  for (let match of matches) {
8634
8796
  let routeId = match.route.id;
@@ -8647,8 +8809,10 @@ async function handleManifestRequest(build, routes, url) {
8647
8809
  }
8648
8810
  return new Response("Invalid Request", { status: 400 });
8649
8811
  }
8650
- async function handleSingleFetchRequest(serverMode, build, staticHandler, request, handlerUrl, loadContext, handleError) {
8651
- let response = request.method !== "GET" ? await singleFetchAction(
8812
+ async function handleSingleFetchRequest(serverMode, build, staticHandler, request, normalizedPath, loadContext, handleError) {
8813
+ let handlerUrl = new URL(request.url);
8814
+ handlerUrl.pathname = normalizedPath;
8815
+ let response = isMutationMethod(request.method) ? await singleFetchAction(
8652
8816
  build,
8653
8817
  serverMode,
8654
8818
  staticHandler,
@@ -8669,10 +8833,10 @@ async function handleSingleFetchRequest(serverMode, build, staticHandler, reques
8669
8833
  }
8670
8834
  async function handleDocumentRequest(serverMode, build, staticHandler, request, loadContext, handleError, isSpaMode, criticalCss) {
8671
8835
  try {
8672
- if (request.method === "POST") {
8836
+ if (isMutationMethod(request.method)) {
8673
8837
  try {
8674
8838
  throwIfPotentialCSRFAttack(
8675
- request.headers,
8839
+ request,
8676
8840
  Array.isArray(build.allowedActionOrigins) ? build.allowedActionOrigins : []
8677
8841
  );
8678
8842
  } catch (e) {
@@ -8693,7 +8857,8 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
8693
8857
  handleError(error);
8694
8858
  return new Response(null, { status: 500 });
8695
8859
  }
8696
- } : void 0
8860
+ } : void 0,
8861
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
8697
8862
  });
8698
8863
  if (!isResponse(result)) {
8699
8864
  result = await renderHtml(result, isSpaMode);
@@ -8719,7 +8884,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
8719
8884
  let state = {
8720
8885
  loaderData: context.loaderData,
8721
8886
  actionData: context.actionData,
8722
- errors: serializeErrors(context.errors, serverMode)
8887
+ errors: context.errors
8723
8888
  };
8724
8889
  let baseServerHandoff = {
8725
8890
  basename: build.basename,
@@ -8730,6 +8895,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
8730
8895
  };
8731
8896
  let entryContext = {
8732
8897
  manifest: build.assets,
8898
+ branches: staticHandler._internalRouteBranches,
8733
8899
  routeModules: createEntryRouteModules(build.routes),
8734
8900
  staticHandlerContext: context,
8735
8901
  criticalCss,
@@ -8784,7 +8950,7 @@ async function handleDocumentRequest(serverMode, build, staticHandler, request,
8784
8950
  let state2 = {
8785
8951
  loaderData: context.loaderData,
8786
8952
  actionData: context.actionData,
8787
- errors: serializeErrors(context.errors, serverMode)
8953
+ errors: context.errors
8788
8954
  };
8789
8955
  entryContext = {
8790
8956
  ...entryContext,
@@ -8825,7 +8991,8 @@ async function handleResourceRequest(serverMode, build, staticHandler, routeId,
8825
8991
  } catch (error) {
8826
8992
  return handleQueryRouteError(error);
8827
8993
  }
8828
- } : void 0
8994
+ } : void 0,
8995
+ normalizePath: (r) => getNormalizedPath(r, build.basename, build.future)
8829
8996
  });
8830
8997
  return handleQueryRouteResult(result);
8831
8998
  } catch (error) {
@@ -8984,7 +9151,7 @@ function RSCDefaultRootErrorBoundaryImpl({
8984
9151
  ), heyDeveloper);
8985
9152
  }
8986
9153
  /**
8987
- * @react-router/node v7.13.1
9154
+ * @react-router/node v7.18.4
8988
9155
  *
8989
9156
  * Copyright (c) Remix Software Inc.
8990
9157
  *
@@ -8996,22 +9163,117 @@ function RSCDefaultRootErrorBoundaryImpl({
8996
9163
  async function writeReadableStreamToWritable(stream, writable) {
8997
9164
  let reader = stream.getReader();
8998
9165
  let flushable = writable;
9166
+ let writableError = monitorWritableError(writable);
8999
9167
  try {
9000
9168
  while (true) {
9001
- let { done, value } = await reader.read();
9169
+ writableError.throwIfClosed();
9170
+ let { done, value } = await writableError.race(reader.read());
9002
9171
  if (done) {
9003
9172
  writable.end();
9004
9173
  break;
9005
9174
  }
9006
- writable.write(value);
9175
+ writableError.throwIfClosed();
9176
+ let canContinueWriting = writable.write(value);
9007
9177
  if (typeof flushable.flush === "function") {
9008
9178
  flushable.flush();
9009
9179
  }
9180
+ if (!canContinueWriting) {
9181
+ await waitForDrain(writable, writableError);
9182
+ }
9010
9183
  }
9011
9184
  } catch (error) {
9012
- writable.destroy(error);
9185
+ try {
9186
+ reader.cancel(error instanceof WritableClosedError ? void 0 : error).catch(() => {
9187
+ });
9188
+ } catch {
9189
+ }
9190
+ destroyWritable(writable, error);
9013
9191
  throw error;
9192
+ } finally {
9193
+ writableError.cleanup();
9194
+ try {
9195
+ reader.releaseLock();
9196
+ } catch {
9197
+ }
9198
+ }
9199
+ }
9200
+ var WritableClosedError = class extends Error {
9201
+ };
9202
+ function destroyWritable(writable, error) {
9203
+ if (error instanceof WritableClosedError || writable.destroyed) {
9204
+ return;
9014
9205
  }
9206
+ writable.once("error", () => {
9207
+ });
9208
+ writable.destroy(error);
9209
+ }
9210
+ function monitorWritableError(writable) {
9211
+ let writableStartedDestroyed = writable.destroyed;
9212
+ let settled = false;
9213
+ let writableErrorEmitted = false;
9214
+ let writableError;
9215
+ let rejectWritableError;
9216
+ let writableErrorPromise = new Promise((_, reject2) => {
9217
+ rejectWritableError = reject2;
9218
+ });
9219
+ writableErrorPromise.catch(() => {
9220
+ });
9221
+ function cleanup() {
9222
+ if (!writableStartedDestroyed && writable.destroyed && writable.errored && !writableErrorEmitted) {
9223
+ return;
9224
+ }
9225
+ writable.off("error", onError);
9226
+ writable.off("close", onClose);
9227
+ }
9228
+ function reject(error) {
9229
+ if (settled) {
9230
+ return;
9231
+ }
9232
+ settled = true;
9233
+ writableError = error;
9234
+ cleanup();
9235
+ rejectWritableError(error);
9236
+ }
9237
+ function onError(error) {
9238
+ writableErrorEmitted = true;
9239
+ reject(error);
9240
+ }
9241
+ function onClose() {
9242
+ reject(new WritableClosedError("Writable closed before stream finished"));
9243
+ }
9244
+ writable.once("error", onError);
9245
+ writable.once("close", onClose);
9246
+ return {
9247
+ cleanup,
9248
+ race(promise) {
9249
+ return Promise.race([promise, writableErrorPromise]);
9250
+ },
9251
+ throwIfClosed() {
9252
+ if (writableError) {
9253
+ throw writableError;
9254
+ }
9255
+ if (writable.destroyed || writable.writableEnded) {
9256
+ throw new WritableClosedError(
9257
+ "Cannot write to a destroyed or ended writable stream"
9258
+ );
9259
+ }
9260
+ }
9261
+ };
9262
+ }
9263
+ function waitForDrain(writable, writableError) {
9264
+ let cleanup = () => {
9265
+ };
9266
+ let drainPromise = new Promise((resolve) => {
9267
+ function onDrain() {
9268
+ cleanup();
9269
+ resolve();
9270
+ }
9271
+ cleanup = function cleanup2() {
9272
+ writable.off("drain", onDrain);
9273
+ };
9274
+ writable.once("drain", onDrain);
9275
+ });
9276
+ return writableError.race(drainPromise).finally(cleanup);
9015
9277
  }
9016
9278
  var createReadableStreamFromReadable = (source) => {
9017
9279
  let pump = new StreamPump(source);
@@ -9062,7 +9324,7 @@ var StreamPump = class {
9062
9324
  if (available <= 0) {
9063
9325
  this.pause();
9064
9326
  }
9065
- } catch (error) {
9327
+ } catch (e) {
9066
9328
  this.controller.error(
9067
9329
  new Error(
9068
9330
  "Could not create Buffer, chunk must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object"
@@ -9096,7 +9358,7 @@ var StreamPump = class {
9096
9358
  }
9097
9359
  };
9098
9360
  /**
9099
- * @react-router/express v7.13.1
9361
+ * @react-router/express v7.18.4
9100
9362
  *
9101
9363
  * Copyright (c) Remix Software Inc.
9102
9364
  *
@@ -9138,13 +9400,14 @@ function createRemixHeaders(requestHeaders) {
9138
9400
  return headers;
9139
9401
  }
9140
9402
  function createRemixRequest(req, res) {
9141
- var _a, _b;
9142
- let [, hostnamePortStr] = ((_a = req.get("X-Forwarded-Host")) == null ? void 0 : _a.split(":")) ?? [];
9143
- let [, hostPortStr] = ((_b = req.get("host")) == null ? void 0 : _b.split(":")) ?? [];
9403
+ var _a, _b, _c;
9404
+ let [, hostnamePortStr] = ((_a = req.app) == null ? void 0 : _a.enabled("trust proxy")) ? ((_b = req.get("X-Forwarded-Host")) == null ? void 0 : _b.split(":")) ?? [] : [];
9405
+ let [, hostPortStr] = ((_c = req.get("host")) == null ? void 0 : _c.split(":")) ?? [];
9144
9406
  let hostnamePort = Number.parseInt(hostnamePortStr, 10);
9145
9407
  let hostPort = Number.parseInt(hostPortStr, 10);
9146
9408
  let port = Number.isSafeInteger(hostnamePort) ? hostnamePort : Number.isSafeInteger(hostPort) ? hostPort : "";
9147
- let resolvedHost = `${req.hostname}${port ? `:${port}` : ""}`;
9409
+ let hostname = req.hostname.split(/[\\/?#@]/)[0] || "localhost";
9410
+ let resolvedHost = `${hostname}${port ? `:${port}` : ""}`;
9148
9411
  let url = new URL(`${req.protocol}://${resolvedHost}${req.originalUrl}`);
9149
9412
  let controller = new AbortController();
9150
9413
  let init = {
@@ -9161,26 +9424,40 @@ function createRemixRequest(req, res) {
9161
9424
  return new Request(url.href, init);
9162
9425
  }
9163
9426
  async function sendRemixResponse(res, nodeResponse) {
9164
- var _a;
9427
+ var _a, _b;
9428
+ if (isResponseClosed(res)) {
9429
+ await ((_a = nodeResponse.body) == null ? void 0 : _a.cancel());
9430
+ return;
9431
+ }
9165
9432
  res.statusMessage = nodeResponse.statusText;
9166
9433
  res.status(nodeResponse.status);
9167
9434
  for (let [key, value] of nodeResponse.headers.entries()) {
9168
9435
  res.append(key, value);
9169
9436
  }
9170
- if ((_a = nodeResponse.headers.get("Content-Type")) == null ? void 0 : _a.match(/text\/event-stream/i)) {
9437
+ if ((_b = nodeResponse.headers.get("Content-Type")) == null ? void 0 : _b.match(/text\/event-stream/i)) {
9171
9438
  res.flushHeaders();
9172
9439
  }
9173
9440
  if (nodeResponse.body) {
9174
- await writeReadableStreamToWritable(nodeResponse.body, res);
9441
+ try {
9442
+ await writeReadableStreamToWritable(nodeResponse.body, res);
9443
+ } catch (error) {
9444
+ if (isResponseClosed(res)) {
9445
+ return;
9446
+ }
9447
+ throw error;
9448
+ }
9175
9449
  } else {
9176
9450
  res.end();
9177
9451
  }
9178
9452
  }
9453
+ function isResponseClosed(res) {
9454
+ return res.destroyed || res.writableEnded;
9455
+ }
9179
9456
  const app = express();
9180
9457
  app.all(
9181
9458
  "/{*splat}",
9182
9459
  createRequestHandler({
9183
- build: () => import("./server-build-D38evYCr.js").then((n) => n.a7)
9460
+ build: () => import("./server-build-CgjoLYPd.js").then((n) => n.a7)
9184
9461
  })
9185
9462
  );
9186
9463
  app.use(
@@ -9200,17 +9477,18 @@ export {
9200
9477
  requireReact as a,
9201
9478
  ReactExports as b,
9202
9479
  createReadableStreamFromReadable as c,
9203
- withErrorBoundaryProps as d,
9204
- ScrollRestoration as e,
9205
- Scripts as f,
9480
+ commonjsGlobal as d,
9481
+ withErrorBoundaryProps as e,
9482
+ ScrollRestoration as f,
9206
9483
  getDefaultExportFromCjs as g,
9207
- useSearchParams as h,
9208
- Link as i,
9209
- useRouteError as j,
9210
- isRouteErrorResponse as k,
9211
- useLocation as l,
9212
- useParams as m,
9213
- app as n,
9484
+ Scripts as h,
9485
+ useSearchParams as i,
9486
+ Link as j,
9487
+ useRouteError as k,
9488
+ isRouteErrorResponse as l,
9489
+ useLocation as m,
9490
+ useParams as n,
9491
+ app as o,
9214
9492
  reactExports as r,
9215
9493
  useNavigate as u,
9216
9494
  withComponentProps as w