droplinked-chatbot-next 1.0.3 → 1.0.5

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.
package/dist/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import * as Chakra from '@chakra-ui/react';
3
- import { VStack, Text, Box, Input, Button, HStack, Image as Image$1, Spacer, IconButton, Link as Link$1, Grid, Flex, Tooltip as Tooltip$1, Center, DrawerHeader, useDisclosure, DrawerBody } from '@chakra-ui/react';
4
- import * as React3 from 'react';
5
- import React3__default, { useState, useMemo, useRef, useEffect, useCallback } from 'react';
3
+ import { VStack, Text, Box, Input, Button, HStack, Image as Image$1, Spacer, IconButton, Link, Grid, Flex, Tooltip as Tooltip$1, Center, DrawerHeader, useDisclosure, DrawerBody } from '@chakra-ui/react';
4
+ import * as React from 'react';
5
+ import React__default, { useState, useMemo, useRef, useEffect, useCallback } from 'react';
6
6
 
7
7
  function _arrayLikeToArray(r, a) {
8
8
  (null == a || a > r.length) && (a = r.length);
@@ -5054,9 +5054,9 @@ if (typeof document !== "undefined" && !document.getElementById("typing-indicato
5054
5054
  styleElement.textContent = typingIndicatorStyles;
5055
5055
  document.head.appendChild(styleElement);
5056
5056
  }
5057
- var TypingIndicator = /*#__PURE__*/React3__default.memo(function TypingIndicator(_ref) {
5057
+ var TypingIndicator = /*#__PURE__*/React__default.memo(function TypingIndicator(_ref) {
5058
5058
  var isVisible = _ref.isVisible;
5059
- var getDotStyle = React3__default.useMemo(function () {
5059
+ var getDotStyle = React__default.useMemo(function () {
5060
5060
  return function (index, delay) {
5061
5061
  var animationDelay = "".concat(index * 0.2 + delay * 0.5, "s");
5062
5062
  return {
@@ -5070,11 +5070,11 @@ var TypingIndicator = /*#__PURE__*/React3__default.memo(function TypingIndicator
5070
5070
  animation: isVisible ? 'scaleIn 0.5s ease-out forwards' : 'scaleOut 0.5s ease-in forwards',
5071
5071
  transformOrigin: 'bottom left'
5072
5072
  };
5073
- var _React$useState = React3__default.useState(isVisible),
5073
+ var _React$useState = React__default.useState(isVisible),
5074
5074
  _React$useState2 = _slicedToArray(_React$useState, 2),
5075
5075
  shouldRender = _React$useState2[0],
5076
5076
  setShouldRender = _React$useState2[1];
5077
- React3__default.useEffect(function () {
5077
+ React__default.useEffect(function () {
5078
5078
  var timer = null;
5079
5079
  if (isVisible) {
5080
5080
  setShouldRender(true);
@@ -5090,8 +5090,8 @@ var TypingIndicator = /*#__PURE__*/React3__default.memo(function TypingIndicator
5090
5090
  };
5091
5091
  }, [isVisible]);
5092
5092
  if (!shouldRender) return null;
5093
- var TypingDots = React3__default.useMemo(function () {
5094
- return /*#__PURE__*/React3__default.memo(function (_ref2) {
5093
+ var TypingDots = React__default.useMemo(function () {
5094
+ return /*#__PURE__*/React__default.memo(function (_ref2) {
5095
5095
  var _ref2$delay = _ref2.delay,
5096
5096
  delay = _ref2$delay === void 0 ? 0 : _ref2$delay;
5097
5097
  return jsx(HStack, {
@@ -41368,7 +41368,7 @@ function MarkdownRenderer(_ref) {
41368
41368
  a: function a(_ref3) {
41369
41369
  var href = _ref3.href,
41370
41370
  children = _ref3.children;
41371
- return jsx(Link$1, {
41371
+ return jsx(Link, {
41372
41372
  href: href,
41373
41373
  color: "#179EF8",
41374
41374
  textDecoration: "underline",
@@ -58943,7 +58943,7 @@ function requireIndex_umd () {
58943
58943
  hasRequiredIndex_umd = 1;
58944
58944
  (function (module, exports) {
58945
58945
  (function (global, factory) {
58946
- factory(exports, /*@__PURE__*/ requireLottie(), React3__default) ;
58946
+ factory(exports, /*@__PURE__*/ requireLottie(), React__default) ;
58947
58947
  })(index_umd, (function (exports, lottie, React) {
58948
58948
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
58949
58949
 
@@ -65793,1735 +65793,6 @@ function ChatPage(_ref) {
65793
65793
  });
65794
65794
  }
65795
65795
 
65796
- /**
65797
- * react-router v7.8.2
65798
- *
65799
- * Copyright (c) Remix Software Inc.
65800
- *
65801
- * This source code is licensed under the MIT license found in the
65802
- * LICENSE.md file in the root directory of this source tree.
65803
- *
65804
- * @license MIT
65805
- */
65806
- function invariant(value, message) {
65807
- if (value === false || value === null || typeof value === "undefined") {
65808
- throw new Error(message);
65809
- }
65810
- }
65811
- function warning(cond, message) {
65812
- if (!cond) {
65813
- if (typeof console !== "undefined") console.warn(message);
65814
- try {
65815
- throw new Error(message);
65816
- } catch (e) {
65817
- }
65818
- }
65819
- }
65820
- function createPath({
65821
- pathname = "/",
65822
- search = "",
65823
- hash = ""
65824
- }) {
65825
- if (search && search !== "?")
65826
- pathname += search.charAt(0) === "?" ? search : "?" + search;
65827
- if (hash && hash !== "#")
65828
- pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
65829
- return pathname;
65830
- }
65831
- function parsePath(path) {
65832
- let parsedPath = {};
65833
- if (path) {
65834
- let hashIndex = path.indexOf("#");
65835
- if (hashIndex >= 0) {
65836
- parsedPath.hash = path.substring(hashIndex);
65837
- path = path.substring(0, hashIndex);
65838
- }
65839
- let searchIndex = path.indexOf("?");
65840
- if (searchIndex >= 0) {
65841
- parsedPath.search = path.substring(searchIndex);
65842
- path = path.substring(0, searchIndex);
65843
- }
65844
- if (path) {
65845
- parsedPath.pathname = path;
65846
- }
65847
- }
65848
- return parsedPath;
65849
- }
65850
- function matchRoutes(routes, locationArg, basename = "/") {
65851
- return matchRoutesImpl(routes, locationArg, basename, false);
65852
- }
65853
- function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
65854
- let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
65855
- let pathname = stripBasename(location.pathname || "/", basename);
65856
- if (pathname == null) {
65857
- return null;
65858
- }
65859
- let branches = flattenRoutes(routes);
65860
- rankRouteBranches(branches);
65861
- let matches = null;
65862
- for (let i = 0; matches == null && i < branches.length; ++i) {
65863
- let decoded = decodePath(pathname);
65864
- matches = matchRouteBranch(
65865
- branches[i],
65866
- decoded,
65867
- allowPartial
65868
- );
65869
- }
65870
- return matches;
65871
- }
65872
- function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
65873
- let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
65874
- let meta = {
65875
- relativePath: relativePath === void 0 ? route.path || "" : relativePath,
65876
- caseSensitive: route.caseSensitive === true,
65877
- childrenIndex: index,
65878
- route
65879
- };
65880
- if (meta.relativePath.startsWith("/")) {
65881
- if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
65882
- return;
65883
- }
65884
- invariant(
65885
- meta.relativePath.startsWith(parentPath),
65886
- `Absolute route path "${meta.relativePath}" nested under path "${parentPath}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
65887
- );
65888
- meta.relativePath = meta.relativePath.slice(parentPath.length);
65889
- }
65890
- let path = joinPaths([parentPath, meta.relativePath]);
65891
- let routesMeta = parentsMeta.concat(meta);
65892
- if (route.children && route.children.length > 0) {
65893
- invariant(
65894
- // Our types know better, but runtime JS may not!
65895
- // @ts-expect-error
65896
- route.index !== true,
65897
- `Index routes must not have child routes. Please remove all child routes from route path "${path}".`
65898
- );
65899
- flattenRoutes(
65900
- route.children,
65901
- branches,
65902
- routesMeta,
65903
- path,
65904
- hasParentOptionalSegments
65905
- );
65906
- }
65907
- if (route.path == null && !route.index) {
65908
- return;
65909
- }
65910
- branches.push({
65911
- path,
65912
- score: computeScore(path, route.index),
65913
- routesMeta
65914
- });
65915
- };
65916
- routes.forEach((route, index) => {
65917
- if (route.path === "" || !route.path?.includes("?")) {
65918
- flattenRoute(route, index);
65919
- } else {
65920
- for (let exploded of explodeOptionalSegments(route.path)) {
65921
- flattenRoute(route, index, true, exploded);
65922
- }
65923
- }
65924
- });
65925
- return branches;
65926
- }
65927
- function explodeOptionalSegments(path) {
65928
- let segments = path.split("/");
65929
- if (segments.length === 0) return [];
65930
- let [first, ...rest] = segments;
65931
- let isOptional = first.endsWith("?");
65932
- let required = first.replace(/\?$/, "");
65933
- if (rest.length === 0) {
65934
- return isOptional ? [required, ""] : [required];
65935
- }
65936
- let restExploded = explodeOptionalSegments(rest.join("/"));
65937
- let result = [];
65938
- result.push(
65939
- ...restExploded.map(
65940
- (subpath) => subpath === "" ? required : [required, subpath].join("/")
65941
- )
65942
- );
65943
- if (isOptional) {
65944
- result.push(...restExploded);
65945
- }
65946
- return result.map(
65947
- (exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded
65948
- );
65949
- }
65950
- function rankRouteBranches(branches) {
65951
- branches.sort(
65952
- (a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(
65953
- a.routesMeta.map((meta) => meta.childrenIndex),
65954
- b.routesMeta.map((meta) => meta.childrenIndex)
65955
- )
65956
- );
65957
- }
65958
- var paramRe = /^:[\w-]+$/;
65959
- var dynamicSegmentValue = 3;
65960
- var indexRouteValue = 2;
65961
- var emptySegmentValue = 1;
65962
- var staticSegmentValue = 10;
65963
- var splatPenalty = -2;
65964
- var isSplat = (s) => s === "*";
65965
- function computeScore(path, index) {
65966
- let segments = path.split("/");
65967
- let initialScore = segments.length;
65968
- if (segments.some(isSplat)) {
65969
- initialScore += splatPenalty;
65970
- }
65971
- if (index) {
65972
- initialScore += indexRouteValue;
65973
- }
65974
- return segments.filter((s) => !isSplat(s)).reduce(
65975
- (score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
65976
- initialScore
65977
- );
65978
- }
65979
- function compareIndexes(a, b) {
65980
- let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
65981
- return siblings ? (
65982
- // If two routes are siblings, we should try to match the earlier sibling
65983
- // first. This allows people to have fine-grained control over the matching
65984
- // behavior by simply putting routes with identical paths in the order they
65985
- // want them tried.
65986
- a[a.length - 1] - b[b.length - 1]
65987
- ) : (
65988
- // Otherwise, it doesn't really make sense to rank non-siblings by index,
65989
- // so they sort equally.
65990
- 0
65991
- );
65992
- }
65993
- function matchRouteBranch(branch, pathname, allowPartial = false) {
65994
- let { routesMeta } = branch;
65995
- let matchedParams = {};
65996
- let matchedPathname = "/";
65997
- let matches = [];
65998
- for (let i = 0; i < routesMeta.length; ++i) {
65999
- let meta = routesMeta[i];
66000
- let end = i === routesMeta.length - 1;
66001
- let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
66002
- let match = matchPath(
66003
- { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
66004
- remainingPathname
66005
- );
66006
- let route = meta.route;
66007
- if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
66008
- match = matchPath(
66009
- {
66010
- path: meta.relativePath,
66011
- caseSensitive: meta.caseSensitive,
66012
- end: false
66013
- },
66014
- remainingPathname
66015
- );
66016
- }
66017
- if (!match) {
66018
- return null;
66019
- }
66020
- Object.assign(matchedParams, match.params);
66021
- matches.push({
66022
- // TODO: Can this as be avoided?
66023
- params: matchedParams,
66024
- pathname: joinPaths([matchedPathname, match.pathname]),
66025
- pathnameBase: normalizePathname(
66026
- joinPaths([matchedPathname, match.pathnameBase])
66027
- ),
66028
- route
66029
- });
66030
- if (match.pathnameBase !== "/") {
66031
- matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
66032
- }
66033
- }
66034
- return matches;
66035
- }
66036
- function matchPath(pattern, pathname) {
66037
- if (typeof pattern === "string") {
66038
- pattern = { path: pattern, caseSensitive: false, end: true };
66039
- }
66040
- let [matcher, compiledParams] = compilePath(
66041
- pattern.path,
66042
- pattern.caseSensitive,
66043
- pattern.end
66044
- );
66045
- let match = pathname.match(matcher);
66046
- if (!match) return null;
66047
- let matchedPathname = match[0];
66048
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
66049
- let captureGroups = match.slice(1);
66050
- let params = compiledParams.reduce(
66051
- (memo2, { paramName, isOptional }, index) => {
66052
- if (paramName === "*") {
66053
- let splatValue = captureGroups[index] || "";
66054
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
66055
- }
66056
- const value = captureGroups[index];
66057
- if (isOptional && !value) {
66058
- memo2[paramName] = void 0;
66059
- } else {
66060
- memo2[paramName] = (value || "").replace(/%2F/g, "/");
66061
- }
66062
- return memo2;
66063
- },
66064
- {}
66065
- );
66066
- return {
66067
- params,
66068
- pathname: matchedPathname,
66069
- pathnameBase,
66070
- pattern
66071
- };
66072
- }
66073
- function compilePath(path, caseSensitive = false, end = true) {
66074
- warning(
66075
- path === "*" || !path.endsWith("*") || path.endsWith("/*"),
66076
- `Route path "${path}" will be treated as if it were "${path.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${path.replace(/\*$/, "/*")}".`
66077
- );
66078
- let params = [];
66079
- let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
66080
- /\/:([\w-]+)(\?)?/g,
66081
- (_, paramName, isOptional) => {
66082
- params.push({ paramName, isOptional: isOptional != null });
66083
- return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
66084
- }
66085
- ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
66086
- if (path.endsWith("*")) {
66087
- params.push({ paramName: "*" });
66088
- regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
66089
- } else if (end) {
66090
- regexpSource += "\\/*$";
66091
- } else if (path !== "" && path !== "/") {
66092
- regexpSource += "(?:(?=\\/|$))";
66093
- } else ;
66094
- let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
66095
- return [matcher, params];
66096
- }
66097
- function decodePath(value) {
66098
- try {
66099
- return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
66100
- } catch (error) {
66101
- warning(
66102
- false,
66103
- `The URL path "${value}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${error}).`
66104
- );
66105
- return value;
66106
- }
66107
- }
66108
- function stripBasename(pathname, basename) {
66109
- if (basename === "/") return pathname;
66110
- if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
66111
- return null;
66112
- }
66113
- let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
66114
- let nextChar = pathname.charAt(startIndex);
66115
- if (nextChar && nextChar !== "/") {
66116
- return null;
66117
- }
66118
- return pathname.slice(startIndex) || "/";
66119
- }
66120
- function resolvePath(to, fromPathname = "/") {
66121
- let {
66122
- pathname: toPathname,
66123
- search = "",
66124
- hash = ""
66125
- } = typeof to === "string" ? parsePath(to) : to;
66126
- let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname(toPathname, fromPathname) : fromPathname;
66127
- return {
66128
- pathname,
66129
- search: normalizeSearch(search),
66130
- hash: normalizeHash(hash)
66131
- };
66132
- }
66133
- function resolvePathname(relativePath, fromPathname) {
66134
- let segments = fromPathname.replace(/\/+$/, "").split("/");
66135
- let relativeSegments = relativePath.split("/");
66136
- relativeSegments.forEach((segment) => {
66137
- if (segment === "..") {
66138
- if (segments.length > 1) segments.pop();
66139
- } else if (segment !== ".") {
66140
- segments.push(segment);
66141
- }
66142
- });
66143
- return segments.length > 1 ? segments.join("/") : "/";
66144
- }
66145
- function getInvalidPathError(char, field, dest, path) {
66146
- return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(
66147
- path
66148
- )}]. Please separate it out to the \`to.${dest}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
66149
- }
66150
- function getPathContributingMatches(matches) {
66151
- return matches.filter(
66152
- (match, index) => index === 0 || match.route.path && match.route.path.length > 0
66153
- );
66154
- }
66155
- function getResolveToMatches(matches) {
66156
- let pathMatches = getPathContributingMatches(matches);
66157
- return pathMatches.map(
66158
- (match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase
66159
- );
66160
- }
66161
- function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
66162
- let to;
66163
- if (typeof toArg === "string") {
66164
- to = parsePath(toArg);
66165
- } else {
66166
- to = { ...toArg };
66167
- invariant(
66168
- !to.pathname || !to.pathname.includes("?"),
66169
- getInvalidPathError("?", "pathname", "search", to)
66170
- );
66171
- invariant(
66172
- !to.pathname || !to.pathname.includes("#"),
66173
- getInvalidPathError("#", "pathname", "hash", to)
66174
- );
66175
- invariant(
66176
- !to.search || !to.search.includes("#"),
66177
- getInvalidPathError("#", "search", "hash", to)
66178
- );
66179
- }
66180
- let isEmptyPath = toArg === "" || to.pathname === "";
66181
- let toPathname = isEmptyPath ? "/" : to.pathname;
66182
- let from;
66183
- if (toPathname == null) {
66184
- from = locationPathname;
66185
- } else {
66186
- let routePathnameIndex = routePathnames.length - 1;
66187
- if (!isPathRelative && toPathname.startsWith("..")) {
66188
- let toSegments = toPathname.split("/");
66189
- while (toSegments[0] === "..") {
66190
- toSegments.shift();
66191
- routePathnameIndex -= 1;
66192
- }
66193
- to.pathname = toSegments.join("/");
66194
- }
66195
- from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
66196
- }
66197
- let path = resolvePath(to, from);
66198
- let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
66199
- let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
66200
- if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
66201
- path.pathname += "/";
66202
- }
66203
- return path;
66204
- }
66205
- var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
66206
- var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
66207
- var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
66208
- var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
66209
- function isRouteErrorResponse(error) {
66210
- return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
66211
- }
66212
-
66213
- // lib/router/router.ts
66214
- var validMutationMethodsArr = [
66215
- "POST",
66216
- "PUT",
66217
- "PATCH",
66218
- "DELETE"
66219
- ];
66220
- new Set(
66221
- validMutationMethodsArr
66222
- );
66223
- var validRequestMethodsArr = [
66224
- "GET",
66225
- ...validMutationMethodsArr
66226
- ];
66227
- new Set(validRequestMethodsArr);
66228
- var DataRouterContext = React3.createContext(null);
66229
- DataRouterContext.displayName = "DataRouter";
66230
- var DataRouterStateContext = React3.createContext(null);
66231
- DataRouterStateContext.displayName = "DataRouterState";
66232
- React3.createContext(false);
66233
- var ViewTransitionContext = React3.createContext({
66234
- isTransitioning: false
66235
- });
66236
- ViewTransitionContext.displayName = "ViewTransition";
66237
- var FetchersContext = React3.createContext(
66238
- /* @__PURE__ */ new Map()
66239
- );
66240
- FetchersContext.displayName = "Fetchers";
66241
- var AwaitContext = React3.createContext(null);
66242
- AwaitContext.displayName = "Await";
66243
- var NavigationContext = React3.createContext(
66244
- null
66245
- );
66246
- NavigationContext.displayName = "Navigation";
66247
- var LocationContext = React3.createContext(
66248
- null
66249
- );
66250
- LocationContext.displayName = "Location";
66251
- var RouteContext = React3.createContext({
66252
- outlet: null,
66253
- matches: [],
66254
- isDataRoute: false
66255
- });
66256
- RouteContext.displayName = "Route";
66257
- var RouteErrorContext = React3.createContext(null);
66258
- RouteErrorContext.displayName = "RouteError";
66259
- function useHref(to, { relative } = {}) {
66260
- invariant(
66261
- useInRouterContext(),
66262
- // TODO: This error is probably because they somehow have 2 versions of the
66263
- // router loaded. We can help them understand how to avoid that.
66264
- `useHref() may be used only in the context of a <Router> component.`
66265
- );
66266
- let { basename, navigator } = React3.useContext(NavigationContext);
66267
- let { hash, pathname, search } = useResolvedPath(to, { relative });
66268
- let joinedPathname = pathname;
66269
- if (basename !== "/") {
66270
- joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
66271
- }
66272
- return navigator.createHref({ pathname: joinedPathname, search, hash });
66273
- }
66274
- function useInRouterContext() {
66275
- return React3.useContext(LocationContext) != null;
66276
- }
66277
- function useLocation() {
66278
- invariant(
66279
- useInRouterContext(),
66280
- // TODO: This error is probably because they somehow have 2 versions of the
66281
- // router loaded. We can help them understand how to avoid that.
66282
- `useLocation() may be used only in the context of a <Router> component.`
66283
- );
66284
- return React3.useContext(LocationContext).location;
66285
- }
66286
- var navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when your component is first rendered.`;
66287
- function useIsomorphicLayoutEffect(cb) {
66288
- let isStatic = React3.useContext(NavigationContext).static;
66289
- if (!isStatic) {
66290
- React3.useLayoutEffect(cb);
66291
- }
66292
- }
66293
- function useNavigate() {
66294
- let { isDataRoute } = React3.useContext(RouteContext);
66295
- return isDataRoute ? useNavigateStable() : useNavigateUnstable();
66296
- }
66297
- function useNavigateUnstable() {
66298
- invariant(
66299
- useInRouterContext(),
66300
- // TODO: This error is probably because they somehow have 2 versions of the
66301
- // router loaded. We can help them understand how to avoid that.
66302
- `useNavigate() may be used only in the context of a <Router> component.`
66303
- );
66304
- let dataRouterContext = React3.useContext(DataRouterContext);
66305
- let { basename, navigator } = React3.useContext(NavigationContext);
66306
- let { matches } = React3.useContext(RouteContext);
66307
- let { pathname: locationPathname } = useLocation();
66308
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
66309
- let activeRef = React3.useRef(false);
66310
- useIsomorphicLayoutEffect(() => {
66311
- activeRef.current = true;
66312
- });
66313
- let navigate = React3.useCallback(
66314
- (to, options = {}) => {
66315
- warning(activeRef.current, navigateEffectWarning);
66316
- if (!activeRef.current) return;
66317
- if (typeof to === "number") {
66318
- navigator.go(to);
66319
- return;
66320
- }
66321
- let path = resolveTo(
66322
- to,
66323
- JSON.parse(routePathnamesJson),
66324
- locationPathname,
66325
- options.relative === "path"
66326
- );
66327
- if (dataRouterContext == null && basename !== "/") {
66328
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
66329
- }
66330
- (!!options.replace ? navigator.replace : navigator.push)(
66331
- path,
66332
- options.state,
66333
- options
66334
- );
66335
- },
66336
- [
66337
- basename,
66338
- navigator,
66339
- routePathnamesJson,
66340
- locationPathname,
66341
- dataRouterContext
66342
- ]
66343
- );
66344
- return navigate;
66345
- }
66346
- React3.createContext(null);
66347
- function useResolvedPath(to, { relative } = {}) {
66348
- let { matches } = React3.useContext(RouteContext);
66349
- let { pathname: locationPathname } = useLocation();
66350
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
66351
- return React3.useMemo(
66352
- () => resolveTo(
66353
- to,
66354
- JSON.parse(routePathnamesJson),
66355
- locationPathname,
66356
- relative === "path"
66357
- ),
66358
- [to, routePathnamesJson, locationPathname, relative]
66359
- );
66360
- }
66361
- function useRoutesImpl(routes, locationArg, dataRouterState, unstable_onError, future) {
66362
- invariant(
66363
- useInRouterContext(),
66364
- // TODO: This error is probably because they somehow have 2 versions of the
66365
- // router loaded. We can help them understand how to avoid that.
66366
- `useRoutes() may be used only in the context of a <Router> component.`
66367
- );
66368
- let { navigator } = React3.useContext(NavigationContext);
66369
- let { matches: parentMatches } = React3.useContext(RouteContext);
66370
- let routeMatch = parentMatches[parentMatches.length - 1];
66371
- let parentParams = routeMatch ? routeMatch.params : {};
66372
- let parentPathname = routeMatch ? routeMatch.pathname : "/";
66373
- let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
66374
- let parentRoute = routeMatch && routeMatch.route;
66375
- {
66376
- let parentPath = parentRoute && parentRoute.path || "";
66377
- warningOnce(
66378
- parentPathname,
66379
- !parentRoute || parentPath.endsWith("*") || parentPath.endsWith("*?"),
66380
- `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${parentPathname}" (under <Route path="${parentPath}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
66381
-
66382
- Please change the parent <Route path="${parentPath}"> to <Route path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`
66383
- );
66384
- }
66385
- let locationFromContext = useLocation();
66386
- let location;
66387
- {
66388
- location = locationFromContext;
66389
- }
66390
- let pathname = location.pathname || "/";
66391
- let remainingPathname = pathname;
66392
- if (parentPathnameBase !== "/") {
66393
- let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
66394
- let segments = pathname.replace(/^\//, "").split("/");
66395
- remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
66396
- }
66397
- let matches = matchRoutes(routes, { pathname: remainingPathname });
66398
- {
66399
- warning(
66400
- parentRoute || matches != null,
66401
- `No routes matched location "${location.pathname}${location.search}${location.hash}" `
66402
- );
66403
- warning(
66404
- matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0,
66405
- `Matched leaf route at location "${location.pathname}${location.search}${location.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
66406
- );
66407
- }
66408
- let renderedMatches = _renderMatches(
66409
- matches && matches.map(
66410
- (match) => Object.assign({}, match, {
66411
- params: Object.assign({}, parentParams, match.params),
66412
- pathname: joinPaths([
66413
- parentPathnameBase,
66414
- // Re-encode pathnames that were decoded inside matchRoutes
66415
- navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
66416
- ]),
66417
- pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
66418
- parentPathnameBase,
66419
- // Re-encode pathnames that were decoded inside matchRoutes
66420
- navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
66421
- ])
66422
- })
66423
- ),
66424
- parentMatches,
66425
- dataRouterState,
66426
- unstable_onError,
66427
- future
66428
- );
66429
- return renderedMatches;
66430
- }
66431
- function DefaultErrorComponent() {
66432
- let error = useRouteError();
66433
- let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
66434
- let stack = error instanceof Error ? error.stack : null;
66435
- let lightgrey = "rgba(200,200,200, 0.5)";
66436
- let preStyles = { padding: "0.5rem", backgroundColor: lightgrey };
66437
- let codeStyles = { padding: "2px 4px", backgroundColor: lightgrey };
66438
- let devInfo = null;
66439
- {
66440
- console.error(
66441
- "Error handled by React Router default ErrorBoundary:",
66442
- error
66443
- );
66444
- devInfo = /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("p", null, "\u{1F4BF} Hey developer \u{1F44B}"), /* @__PURE__ */ React3.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React3.createElement("code", { style: codeStyles }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React3.createElement("code", { style: codeStyles }, "errorElement"), " prop on your route."));
66445
- }
66446
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React3.createElement("h3", { style: { fontStyle: "italic" } }, message), stack ? /* @__PURE__ */ React3.createElement("pre", { style: preStyles }, stack) : null, devInfo);
66447
- }
66448
- var defaultErrorElement = /* @__PURE__ */ React3.createElement(DefaultErrorComponent, null);
66449
- var RenderErrorBoundary = class extends React3.Component {
66450
- constructor(props) {
66451
- super(props);
66452
- this.state = {
66453
- location: props.location,
66454
- revalidation: props.revalidation,
66455
- error: props.error
66456
- };
66457
- }
66458
- static getDerivedStateFromError(error) {
66459
- return { error };
66460
- }
66461
- static getDerivedStateFromProps(props, state) {
66462
- if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
66463
- return {
66464
- error: props.error,
66465
- location: props.location,
66466
- revalidation: props.revalidation
66467
- };
66468
- }
66469
- return {
66470
- error: props.error !== void 0 ? props.error : state.error,
66471
- location: state.location,
66472
- revalidation: props.revalidation || state.revalidation
66473
- };
66474
- }
66475
- componentDidCatch(error, errorInfo) {
66476
- if (this.props.unstable_onError) {
66477
- this.props.unstable_onError(error, errorInfo);
66478
- } else {
66479
- console.error(
66480
- "React Router caught the following error during render",
66481
- error
66482
- );
66483
- }
66484
- }
66485
- render() {
66486
- return this.state.error !== void 0 ? /* @__PURE__ */ React3.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React3.createElement(
66487
- RouteErrorContext.Provider,
66488
- {
66489
- value: this.state.error,
66490
- children: this.props.component
66491
- }
66492
- )) : this.props.children;
66493
- }
66494
- };
66495
- function RenderedRoute({ routeContext, match, children }) {
66496
- let dataRouterContext = React3.useContext(DataRouterContext);
66497
- if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
66498
- dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
66499
- }
66500
- return /* @__PURE__ */ React3.createElement(RouteContext.Provider, { value: routeContext }, children);
66501
- }
66502
- function _renderMatches(matches, parentMatches = [], dataRouterState = null, unstable_onError = null, future = null) {
66503
- if (matches == null) {
66504
- if (!dataRouterState) {
66505
- return null;
66506
- }
66507
- if (dataRouterState.errors) {
66508
- matches = dataRouterState.matches;
66509
- } else if (parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
66510
- matches = dataRouterState.matches;
66511
- } else {
66512
- return null;
66513
- }
66514
- }
66515
- let renderedMatches = matches;
66516
- let errors = dataRouterState?.errors;
66517
- if (errors != null) {
66518
- let errorIndex = renderedMatches.findIndex(
66519
- (m) => m.route.id && errors?.[m.route.id] !== void 0
66520
- );
66521
- invariant(
66522
- errorIndex >= 0,
66523
- `Could not find a matching route for errors on route IDs: ${Object.keys(
66524
- errors
66525
- ).join(",")}`
66526
- );
66527
- renderedMatches = renderedMatches.slice(
66528
- 0,
66529
- Math.min(renderedMatches.length, errorIndex + 1)
66530
- );
66531
- }
66532
- let renderFallback = false;
66533
- let fallbackIndex = -1;
66534
- if (dataRouterState) {
66535
- for (let i = 0; i < renderedMatches.length; i++) {
66536
- let match = renderedMatches[i];
66537
- if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
66538
- fallbackIndex = i;
66539
- }
66540
- if (match.route.id) {
66541
- let { loaderData, errors: errors2 } = dataRouterState;
66542
- let needsToRunLoader = match.route.loader && !loaderData.hasOwnProperty(match.route.id) && (!errors2 || errors2[match.route.id] === void 0);
66543
- if (match.route.lazy || needsToRunLoader) {
66544
- renderFallback = true;
66545
- if (fallbackIndex >= 0) {
66546
- renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
66547
- } else {
66548
- renderedMatches = [renderedMatches[0]];
66549
- }
66550
- break;
66551
- }
66552
- }
66553
- }
66554
- }
66555
- return renderedMatches.reduceRight(
66556
- (outlet, match, index) => {
66557
- let error;
66558
- let shouldRenderHydrateFallback = false;
66559
- let errorElement = null;
66560
- let hydrateFallbackElement = null;
66561
- if (dataRouterState) {
66562
- error = errors && match.route.id ? errors[match.route.id] : void 0;
66563
- errorElement = match.route.errorElement || defaultErrorElement;
66564
- if (renderFallback) {
66565
- if (fallbackIndex < 0 && index === 0) {
66566
- warningOnce(
66567
- "route-fallback",
66568
- false,
66569
- "No `HydrateFallback` element provided to render during initial hydration"
66570
- );
66571
- shouldRenderHydrateFallback = true;
66572
- hydrateFallbackElement = null;
66573
- } else if (fallbackIndex === index) {
66574
- shouldRenderHydrateFallback = true;
66575
- hydrateFallbackElement = match.route.hydrateFallbackElement || null;
66576
- }
66577
- }
66578
- }
66579
- let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
66580
- let getChildren = () => {
66581
- let children;
66582
- if (error) {
66583
- children = errorElement;
66584
- } else if (shouldRenderHydrateFallback) {
66585
- children = hydrateFallbackElement;
66586
- } else if (match.route.Component) {
66587
- children = /* @__PURE__ */ React3.createElement(match.route.Component, null);
66588
- } else if (match.route.element) {
66589
- children = match.route.element;
66590
- } else {
66591
- children = outlet;
66592
- }
66593
- return /* @__PURE__ */ React3.createElement(
66594
- RenderedRoute,
66595
- {
66596
- match,
66597
- routeContext: {
66598
- outlet,
66599
- matches: matches2,
66600
- isDataRoute: dataRouterState != null
66601
- },
66602
- children
66603
- }
66604
- );
66605
- };
66606
- return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React3.createElement(
66607
- RenderErrorBoundary,
66608
- {
66609
- location: dataRouterState.location,
66610
- revalidation: dataRouterState.revalidation,
66611
- component: errorElement,
66612
- error,
66613
- children: getChildren(),
66614
- routeContext: { outlet: null, matches: matches2, isDataRoute: true },
66615
- unstable_onError
66616
- }
66617
- ) : getChildren();
66618
- },
66619
- null
66620
- );
66621
- }
66622
- function getDataRouterConsoleError(hookName) {
66623
- return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
66624
- }
66625
- function useDataRouterContext(hookName) {
66626
- let ctx = React3.useContext(DataRouterContext);
66627
- invariant(ctx, getDataRouterConsoleError(hookName));
66628
- return ctx;
66629
- }
66630
- function useDataRouterState(hookName) {
66631
- let state = React3.useContext(DataRouterStateContext);
66632
- invariant(state, getDataRouterConsoleError(hookName));
66633
- return state;
66634
- }
66635
- function useRouteContext(hookName) {
66636
- let route = React3.useContext(RouteContext);
66637
- invariant(route, getDataRouterConsoleError(hookName));
66638
- return route;
66639
- }
66640
- function useCurrentRouteId(hookName) {
66641
- let route = useRouteContext(hookName);
66642
- let thisRoute = route.matches[route.matches.length - 1];
66643
- invariant(
66644
- thisRoute.route.id,
66645
- `${hookName} can only be used on routes that contain a unique "id"`
66646
- );
66647
- return thisRoute.route.id;
66648
- }
66649
- function useRouteId() {
66650
- return useCurrentRouteId("useRouteId" /* UseRouteId */);
66651
- }
66652
- function useRouteError() {
66653
- let error = React3.useContext(RouteErrorContext);
66654
- let state = useDataRouterState("useRouteError" /* UseRouteError */);
66655
- let routeId = useCurrentRouteId("useRouteError" /* UseRouteError */);
66656
- if (error !== void 0) {
66657
- return error;
66658
- }
66659
- return state.errors?.[routeId];
66660
- }
66661
- function useNavigateStable() {
66662
- let { router } = useDataRouterContext("useNavigate" /* UseNavigateStable */);
66663
- let id = useCurrentRouteId("useNavigate" /* UseNavigateStable */);
66664
- let activeRef = React3.useRef(false);
66665
- useIsomorphicLayoutEffect(() => {
66666
- activeRef.current = true;
66667
- });
66668
- let navigate = React3.useCallback(
66669
- async (to, options = {}) => {
66670
- warning(activeRef.current, navigateEffectWarning);
66671
- if (!activeRef.current) return;
66672
- if (typeof to === "number") {
66673
- router.navigate(to);
66674
- } else {
66675
- await router.navigate(to, { fromRouteId: id, ...options });
66676
- }
66677
- },
66678
- [router, id]
66679
- );
66680
- return navigate;
66681
- }
66682
- var alreadyWarned = {};
66683
- function warningOnce(key, cond, message) {
66684
- if (!cond && !alreadyWarned[key]) {
66685
- alreadyWarned[key] = true;
66686
- warning(false, message);
66687
- }
66688
- }
66689
- React3.memo(DataRoutes);
66690
- function DataRoutes({
66691
- routes,
66692
- future,
66693
- state,
66694
- unstable_onError
66695
- }) {
66696
- return useRoutesImpl(routes, void 0, state, unstable_onError, future);
66697
- }
66698
-
66699
- // lib/dom/dom.ts
66700
- var defaultMethod = "get";
66701
- var defaultEncType = "application/x-www-form-urlencoded";
66702
- function isHtmlElement(object) {
66703
- return object != null && typeof object.tagName === "string";
66704
- }
66705
- function isButtonElement(object) {
66706
- return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
66707
- }
66708
- function isFormElement(object) {
66709
- return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
66710
- }
66711
- function isInputElement(object) {
66712
- return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
66713
- }
66714
- function isModifiedEvent(event) {
66715
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
66716
- }
66717
- function shouldProcessLinkClick(event, target) {
66718
- return event.button === 0 && // Ignore everything but left clicks
66719
- (!target || target === "_self") && // Let browser handle "target=_blank" etc.
66720
- !isModifiedEvent(event);
66721
- }
66722
- var _formDataSupportsSubmitter = null;
66723
- function isFormDataSubmitterSupported() {
66724
- if (_formDataSupportsSubmitter === null) {
66725
- try {
66726
- new FormData(
66727
- document.createElement("form"),
66728
- // @ts-expect-error if FormData supports the submitter parameter, this will throw
66729
- 0
66730
- );
66731
- _formDataSupportsSubmitter = false;
66732
- } catch (e) {
66733
- _formDataSupportsSubmitter = true;
66734
- }
66735
- }
66736
- return _formDataSupportsSubmitter;
66737
- }
66738
- var supportedFormEncTypes = /* @__PURE__ */ new Set([
66739
- "application/x-www-form-urlencoded",
66740
- "multipart/form-data",
66741
- "text/plain"
66742
- ]);
66743
- function getFormEncType(encType) {
66744
- if (encType != null && !supportedFormEncTypes.has(encType)) {
66745
- warning(
66746
- false,
66747
- `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
66748
- );
66749
- return null;
66750
- }
66751
- return encType;
66752
- }
66753
- function getFormSubmissionInfo(target, basename) {
66754
- let method;
66755
- let action;
66756
- let encType;
66757
- let formData;
66758
- let body;
66759
- if (isFormElement(target)) {
66760
- let attr = target.getAttribute("action");
66761
- action = attr ? stripBasename(attr, basename) : null;
66762
- method = target.getAttribute("method") || defaultMethod;
66763
- encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
66764
- formData = new FormData(target);
66765
- } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
66766
- let form = target.form;
66767
- if (form == null) {
66768
- throw new Error(
66769
- `Cannot submit a <button> or <input type="submit"> without a <form>`
66770
- );
66771
- }
66772
- let attr = target.getAttribute("formaction") || form.getAttribute("action");
66773
- action = attr ? stripBasename(attr, basename) : null;
66774
- method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
66775
- encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
66776
- formData = new FormData(form, target);
66777
- if (!isFormDataSubmitterSupported()) {
66778
- let { name, type, value } = target;
66779
- if (type === "image") {
66780
- let prefix = name ? `${name}.` : "";
66781
- formData.append(`${prefix}x`, "0");
66782
- formData.append(`${prefix}y`, "0");
66783
- } else if (name) {
66784
- formData.append(name, value);
66785
- }
66786
- }
66787
- } else if (isHtmlElement(target)) {
66788
- throw new Error(
66789
- `Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
66790
- );
66791
- } else {
66792
- method = defaultMethod;
66793
- action = null;
66794
- encType = defaultEncType;
66795
- body = target;
66796
- }
66797
- if (formData && encType === "text/plain") {
66798
- body = formData;
66799
- formData = void 0;
66800
- }
66801
- return { action, method: method.toLowerCase(), encType, formData, body };
66802
- }
66803
- Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
66804
-
66805
- // lib/dom/ssr/invariant.ts
66806
- function invariant2(value, message) {
66807
- if (value === false || value === null || typeof value === "undefined") {
66808
- throw new Error(message);
66809
- }
66810
- }
66811
- function singleFetchUrl(reqUrl, basename, extension) {
66812
- let url = typeof reqUrl === "string" ? new URL(
66813
- reqUrl,
66814
- // This can be called during the SSR flow via PrefetchPageLinksImpl so
66815
- // don't assume window is available
66816
- typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
66817
- ) : reqUrl;
66818
- if (url.pathname === "/") {
66819
- url.pathname = `_root.${extension}`;
66820
- } else if (basename && stripBasename(url.pathname, basename) === "/") {
66821
- url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
66822
- } else {
66823
- url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
66824
- }
66825
- return url;
66826
- }
66827
-
66828
- // lib/dom/ssr/routeModules.ts
66829
- async function loadRouteModule(route, routeModulesCache) {
66830
- if (route.id in routeModulesCache) {
66831
- return routeModulesCache[route.id];
66832
- }
66833
- try {
66834
- let routeModule = await import(
66835
- /* @vite-ignore */
66836
- /* webpackIgnore: true */
66837
- route.module
66838
- );
66839
- routeModulesCache[route.id] = routeModule;
66840
- return routeModule;
66841
- } catch (error) {
66842
- console.error(
66843
- `Error loading route module \`${route.module}\`, reloading page...`
66844
- );
66845
- console.error(error);
66846
- if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
66847
- import.meta.hot) {
66848
- throw error;
66849
- }
66850
- window.location.reload();
66851
- return new Promise(() => {
66852
- });
66853
- }
66854
- }
66855
- function isHtmlLinkDescriptor(object) {
66856
- if (object == null) {
66857
- return false;
66858
- }
66859
- if (object.href == null) {
66860
- return object.rel === "preload" && typeof object.imageSrcSet === "string" && typeof object.imageSizes === "string";
66861
- }
66862
- return typeof object.rel === "string" && typeof object.href === "string";
66863
- }
66864
- async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
66865
- let links = await Promise.all(
66866
- matches.map(async (match) => {
66867
- let route = manifest.routes[match.route.id];
66868
- if (route) {
66869
- let mod = await loadRouteModule(route, routeModules);
66870
- return mod.links ? mod.links() : [];
66871
- }
66872
- return [];
66873
- })
66874
- );
66875
- return dedupeLinkDescriptors(
66876
- links.flat(1).filter(isHtmlLinkDescriptor).filter((link) => link.rel === "stylesheet" || link.rel === "preload").map(
66877
- (link) => link.rel === "stylesheet" ? { ...link, rel: "prefetch", as: "style" } : { ...link, rel: "prefetch" }
66878
- )
66879
- );
66880
- }
66881
- function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
66882
- let isNew = (match, index) => {
66883
- if (!currentMatches[index]) return true;
66884
- return match.route.id !== currentMatches[index].route.id;
66885
- };
66886
- let matchPathChanged = (match, index) => {
66887
- return (
66888
- // param change, /users/123 -> /users/456
66889
- currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
66890
- // e.g. /files/images/avatar.jpg -> files/finances.xls
66891
- currentMatches[index].route.path?.endsWith("*") && currentMatches[index].params["*"] !== match.params["*"]
66892
- );
66893
- };
66894
- if (mode === "assets") {
66895
- return nextMatches.filter(
66896
- (match, index) => isNew(match, index) || matchPathChanged(match, index)
66897
- );
66898
- }
66899
- if (mode === "data") {
66900
- return nextMatches.filter((match, index) => {
66901
- let manifestRoute = manifest.routes[match.route.id];
66902
- if (!manifestRoute || !manifestRoute.hasLoader) {
66903
- return false;
66904
- }
66905
- if (isNew(match, index) || matchPathChanged(match, index)) {
66906
- return true;
66907
- }
66908
- if (match.route.shouldRevalidate) {
66909
- let routeChoice = match.route.shouldRevalidate({
66910
- currentUrl: new URL(
66911
- location.pathname + location.search + location.hash,
66912
- window.origin
66913
- ),
66914
- currentParams: currentMatches[0]?.params || {},
66915
- nextUrl: new URL(page, window.origin),
66916
- nextParams: match.params,
66917
- defaultShouldRevalidate: true
66918
- });
66919
- if (typeof routeChoice === "boolean") {
66920
- return routeChoice;
66921
- }
66922
- }
66923
- return true;
66924
- });
66925
- }
66926
- return [];
66927
- }
66928
- function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
66929
- return dedupeHrefs(
66930
- matches.map((match) => {
66931
- let route = manifest.routes[match.route.id];
66932
- if (!route) return [];
66933
- let hrefs = [route.module];
66934
- if (route.clientActionModule) {
66935
- hrefs = hrefs.concat(route.clientActionModule);
66936
- }
66937
- if (route.clientLoaderModule) {
66938
- hrefs = hrefs.concat(route.clientLoaderModule);
66939
- }
66940
- if (includeHydrateFallback && route.hydrateFallbackModule) {
66941
- hrefs = hrefs.concat(route.hydrateFallbackModule);
66942
- }
66943
- if (route.imports) {
66944
- hrefs = hrefs.concat(route.imports);
66945
- }
66946
- return hrefs;
66947
- }).flat(1)
66948
- );
66949
- }
66950
- function dedupeHrefs(hrefs) {
66951
- return [...new Set(hrefs)];
66952
- }
66953
- function sortKeys(obj) {
66954
- let sorted = {};
66955
- let keys = Object.keys(obj).sort();
66956
- for (let key of keys) {
66957
- sorted[key] = obj[key];
66958
- }
66959
- return sorted;
66960
- }
66961
- function dedupeLinkDescriptors(descriptors, preloads) {
66962
- let set = /* @__PURE__ */ new Set();
66963
- new Set(preloads);
66964
- return descriptors.reduce((deduped, descriptor) => {
66965
- let key = JSON.stringify(sortKeys(descriptor));
66966
- if (!set.has(key)) {
66967
- set.add(key);
66968
- deduped.push({ key, link: descriptor });
66969
- }
66970
- return deduped;
66971
- }, []);
66972
- }
66973
-
66974
- // lib/dom/ssr/components.tsx
66975
- function useDataRouterContext2() {
66976
- let context = React3.useContext(DataRouterContext);
66977
- invariant2(
66978
- context,
66979
- "You must render this element inside a <DataRouterContext.Provider> element"
66980
- );
66981
- return context;
66982
- }
66983
- function useDataRouterStateContext() {
66984
- let context = React3.useContext(DataRouterStateContext);
66985
- invariant2(
66986
- context,
66987
- "You must render this element inside a <DataRouterStateContext.Provider> element"
66988
- );
66989
- return context;
66990
- }
66991
- var FrameworkContext = React3.createContext(void 0);
66992
- FrameworkContext.displayName = "FrameworkContext";
66993
- function useFrameworkContext() {
66994
- let context = React3.useContext(FrameworkContext);
66995
- invariant2(
66996
- context,
66997
- "You must render this element inside a <HydratedRouter> element"
66998
- );
66999
- return context;
67000
- }
67001
- function usePrefetchBehavior(prefetch, theirElementProps) {
67002
- let frameworkContext = React3.useContext(FrameworkContext);
67003
- let [maybePrefetch, setMaybePrefetch] = React3.useState(false);
67004
- let [shouldPrefetch, setShouldPrefetch] = React3.useState(false);
67005
- let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
67006
- let ref = React3.useRef(null);
67007
- React3.useEffect(() => {
67008
- if (prefetch === "render") {
67009
- setShouldPrefetch(true);
67010
- }
67011
- if (prefetch === "viewport") {
67012
- let callback = (entries) => {
67013
- entries.forEach((entry) => {
67014
- setShouldPrefetch(entry.isIntersecting);
67015
- });
67016
- };
67017
- let observer = new IntersectionObserver(callback, { threshold: 0.5 });
67018
- if (ref.current) observer.observe(ref.current);
67019
- return () => {
67020
- observer.disconnect();
67021
- };
67022
- }
67023
- }, [prefetch]);
67024
- React3.useEffect(() => {
67025
- if (maybePrefetch) {
67026
- let id = setTimeout(() => {
67027
- setShouldPrefetch(true);
67028
- }, 100);
67029
- return () => {
67030
- clearTimeout(id);
67031
- };
67032
- }
67033
- }, [maybePrefetch]);
67034
- let setIntent = () => {
67035
- setMaybePrefetch(true);
67036
- };
67037
- let cancelIntent = () => {
67038
- setMaybePrefetch(false);
67039
- setShouldPrefetch(false);
67040
- };
67041
- if (!frameworkContext) {
67042
- return [false, ref, {}];
67043
- }
67044
- if (prefetch !== "intent") {
67045
- return [shouldPrefetch, ref, {}];
67046
- }
67047
- return [
67048
- shouldPrefetch,
67049
- ref,
67050
- {
67051
- onFocus: composeEventHandlers(onFocus, setIntent),
67052
- onBlur: composeEventHandlers(onBlur, cancelIntent),
67053
- onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
67054
- onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
67055
- onTouchStart: composeEventHandlers(onTouchStart, setIntent)
67056
- }
67057
- ];
67058
- }
67059
- function composeEventHandlers(theirHandler, ourHandler) {
67060
- return (event) => {
67061
- theirHandler && theirHandler(event);
67062
- if (!event.defaultPrevented) {
67063
- ourHandler(event);
67064
- }
67065
- };
67066
- }
67067
- function PrefetchPageLinks({ page, ...linkProps }) {
67068
- let { router } = useDataRouterContext2();
67069
- let matches = React3.useMemo(
67070
- () => matchRoutes(router.routes, page, router.basename),
67071
- [router.routes, page, router.basename]
67072
- );
67073
- if (!matches) {
67074
- return null;
67075
- }
67076
- return /* @__PURE__ */ React3.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
67077
- }
67078
- function useKeyedPrefetchLinks(matches) {
67079
- let { manifest, routeModules } = useFrameworkContext();
67080
- let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React3.useState([]);
67081
- React3.useEffect(() => {
67082
- let interrupted = false;
67083
- void getKeyedPrefetchLinks(matches, manifest, routeModules).then(
67084
- (links) => {
67085
- if (!interrupted) {
67086
- setKeyedPrefetchLinks(links);
67087
- }
67088
- }
67089
- );
67090
- return () => {
67091
- interrupted = true;
67092
- };
67093
- }, [matches, manifest, routeModules]);
67094
- return keyedPrefetchLinks;
67095
- }
67096
- function PrefetchPageLinksImpl({
67097
- page,
67098
- matches: nextMatches,
67099
- ...linkProps
67100
- }) {
67101
- let location = useLocation();
67102
- let { manifest, routeModules } = useFrameworkContext();
67103
- let { basename } = useDataRouterContext2();
67104
- let { loaderData, matches } = useDataRouterStateContext();
67105
- let newMatchesForData = React3.useMemo(
67106
- () => getNewMatchesForLinks(
67107
- page,
67108
- nextMatches,
67109
- matches,
67110
- manifest,
67111
- location,
67112
- "data"
67113
- ),
67114
- [page, nextMatches, matches, manifest, location]
67115
- );
67116
- let newMatchesForAssets = React3.useMemo(
67117
- () => getNewMatchesForLinks(
67118
- page,
67119
- nextMatches,
67120
- matches,
67121
- manifest,
67122
- location,
67123
- "assets"
67124
- ),
67125
- [page, nextMatches, matches, manifest, location]
67126
- );
67127
- let dataHrefs = React3.useMemo(() => {
67128
- if (page === location.pathname + location.search + location.hash) {
67129
- return [];
67130
- }
67131
- let routesParams = /* @__PURE__ */ new Set();
67132
- let foundOptOutRoute = false;
67133
- nextMatches.forEach((m) => {
67134
- let manifestRoute = manifest.routes[m.route.id];
67135
- if (!manifestRoute || !manifestRoute.hasLoader) {
67136
- return;
67137
- }
67138
- if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && routeModules[m.route.id]?.shouldRevalidate) {
67139
- foundOptOutRoute = true;
67140
- } else if (manifestRoute.hasClientLoader) {
67141
- foundOptOutRoute = true;
67142
- } else {
67143
- routesParams.add(m.route.id);
67144
- }
67145
- });
67146
- if (routesParams.size === 0) {
67147
- return [];
67148
- }
67149
- let url = singleFetchUrl(page, basename, "data");
67150
- if (foundOptOutRoute && routesParams.size > 0) {
67151
- url.searchParams.set(
67152
- "_routes",
67153
- nextMatches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
67154
- );
67155
- }
67156
- return [url.pathname + url.search];
67157
- }, [
67158
- basename,
67159
- loaderData,
67160
- location,
67161
- manifest,
67162
- newMatchesForData,
67163
- nextMatches,
67164
- page,
67165
- routeModules
67166
- ]);
67167
- let moduleHrefs = React3.useMemo(
67168
- () => getModuleLinkHrefs(newMatchesForAssets, manifest),
67169
- [newMatchesForAssets, manifest]
67170
- );
67171
- let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
67172
- return /* @__PURE__ */ React3.createElement(React3.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React3.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React3.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
67173
- // these don't spread `linkProps` because they are full link descriptors
67174
- // already with their own props
67175
- /* @__PURE__ */ React3.createElement("link", { key, nonce: linkProps.nonce, ...link })
67176
- )));
67177
- }
67178
- function mergeRefs(...refs) {
67179
- return (value) => {
67180
- refs.forEach((ref) => {
67181
- if (typeof ref === "function") {
67182
- ref(value);
67183
- } else if (ref != null) {
67184
- ref.current = value;
67185
- }
67186
- });
67187
- };
67188
- }
67189
- var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
67190
- try {
67191
- if (isBrowser) {
67192
- window.__reactRouterVersion = // @ts-expect-error
67193
- "7.8.2";
67194
- }
67195
- } catch (e) {
67196
- }
67197
- var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
67198
- var Link = React3.forwardRef(
67199
- function LinkWithRef({
67200
- onClick,
67201
- discover = "render",
67202
- prefetch = "none",
67203
- relative,
67204
- reloadDocument,
67205
- replace: replace2,
67206
- state,
67207
- target,
67208
- to,
67209
- preventScrollReset,
67210
- viewTransition,
67211
- ...rest
67212
- }, forwardedRef) {
67213
- let { basename } = React3.useContext(NavigationContext);
67214
- let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
67215
- let absoluteHref;
67216
- let isExternal = false;
67217
- if (typeof to === "string" && isAbsolute) {
67218
- absoluteHref = to;
67219
- if (isBrowser) {
67220
- try {
67221
- let currentUrl = new URL(window.location.href);
67222
- let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
67223
- let path = stripBasename(targetUrl.pathname, basename);
67224
- if (targetUrl.origin === currentUrl.origin && path != null) {
67225
- to = path + targetUrl.search + targetUrl.hash;
67226
- } else {
67227
- isExternal = true;
67228
- }
67229
- } catch (e) {
67230
- warning(
67231
- false,
67232
- `<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
67233
- );
67234
- }
67235
- }
67236
- }
67237
- let href = useHref(to, { relative });
67238
- let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
67239
- prefetch,
67240
- rest
67241
- );
67242
- let internalOnClick = useLinkClickHandler(to, {
67243
- replace: replace2,
67244
- state,
67245
- target,
67246
- preventScrollReset,
67247
- relative,
67248
- viewTransition
67249
- });
67250
- function handleClick(event) {
67251
- if (onClick) onClick(event);
67252
- if (!event.defaultPrevented) {
67253
- internalOnClick(event);
67254
- }
67255
- }
67256
- let link = (
67257
- // eslint-disable-next-line jsx-a11y/anchor-has-content
67258
- /* @__PURE__ */ React3.createElement(
67259
- "a",
67260
- {
67261
- ...rest,
67262
- ...prefetchHandlers,
67263
- href: absoluteHref || href,
67264
- onClick: isExternal || reloadDocument ? onClick : handleClick,
67265
- ref: mergeRefs(forwardedRef, prefetchRef),
67266
- target,
67267
- "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
67268
- }
67269
- )
67270
- );
67271
- return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, link, /* @__PURE__ */ React3.createElement(PrefetchPageLinks, { page: href })) : link;
67272
- }
67273
- );
67274
- Link.displayName = "Link";
67275
- var NavLink = React3.forwardRef(
67276
- function NavLinkWithRef({
67277
- "aria-current": ariaCurrentProp = "page",
67278
- caseSensitive = false,
67279
- className: classNameProp = "",
67280
- end = false,
67281
- style: styleProp,
67282
- to,
67283
- viewTransition,
67284
- children,
67285
- ...rest
67286
- }, ref) {
67287
- let path = useResolvedPath(to, { relative: rest.relative });
67288
- let location = useLocation();
67289
- let routerState = React3.useContext(DataRouterStateContext);
67290
- let { navigator, basename } = React3.useContext(NavigationContext);
67291
- let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
67292
- // eslint-disable-next-line react-hooks/rules-of-hooks
67293
- useViewTransitionState(path) && viewTransition === true;
67294
- let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
67295
- let locationPathname = location.pathname;
67296
- let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
67297
- if (!caseSensitive) {
67298
- locationPathname = locationPathname.toLowerCase();
67299
- nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
67300
- toPathname = toPathname.toLowerCase();
67301
- }
67302
- if (nextLocationPathname && basename) {
67303
- nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
67304
- }
67305
- const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
67306
- let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
67307
- let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
67308
- let renderProps = {
67309
- isActive,
67310
- isPending,
67311
- isTransitioning
67312
- };
67313
- let ariaCurrent = isActive ? ariaCurrentProp : void 0;
67314
- let className;
67315
- if (typeof classNameProp === "function") {
67316
- className = classNameProp(renderProps);
67317
- } else {
67318
- className = [
67319
- classNameProp,
67320
- isActive ? "active" : null,
67321
- isPending ? "pending" : null,
67322
- isTransitioning ? "transitioning" : null
67323
- ].filter(Boolean).join(" ");
67324
- }
67325
- let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
67326
- return /* @__PURE__ */ React3.createElement(
67327
- Link,
67328
- {
67329
- ...rest,
67330
- "aria-current": ariaCurrent,
67331
- className,
67332
- ref,
67333
- style,
67334
- to,
67335
- viewTransition
67336
- },
67337
- typeof children === "function" ? children(renderProps) : children
67338
- );
67339
- }
67340
- );
67341
- NavLink.displayName = "NavLink";
67342
- var Form = React3.forwardRef(
67343
- ({
67344
- discover = "render",
67345
- fetcherKey,
67346
- navigate,
67347
- reloadDocument,
67348
- replace: replace2,
67349
- state,
67350
- method = defaultMethod,
67351
- action,
67352
- onSubmit,
67353
- relative,
67354
- preventScrollReset,
67355
- viewTransition,
67356
- ...props
67357
- }, forwardedRef) => {
67358
- let submit = useSubmit();
67359
- let formAction = useFormAction(action, { relative });
67360
- let formMethod = method.toLowerCase() === "get" ? "get" : "post";
67361
- let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
67362
- let submitHandler = (event) => {
67363
- onSubmit && onSubmit(event);
67364
- if (event.defaultPrevented) return;
67365
- event.preventDefault();
67366
- let submitter = event.nativeEvent.submitter;
67367
- let submitMethod = submitter?.getAttribute("formmethod") || method;
67368
- submit(submitter || event.currentTarget, {
67369
- fetcherKey,
67370
- method: submitMethod,
67371
- navigate,
67372
- replace: replace2,
67373
- state,
67374
- relative,
67375
- preventScrollReset,
67376
- viewTransition
67377
- });
67378
- };
67379
- return /* @__PURE__ */ React3.createElement(
67380
- "form",
67381
- {
67382
- ref: forwardedRef,
67383
- method: formMethod,
67384
- action: formAction,
67385
- onSubmit: reloadDocument ? onSubmit : submitHandler,
67386
- ...props,
67387
- "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
67388
- }
67389
- );
67390
- }
67391
- );
67392
- Form.displayName = "Form";
67393
- function getDataRouterConsoleError2(hookName) {
67394
- return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
67395
- }
67396
- function useDataRouterContext3(hookName) {
67397
- let ctx = React3.useContext(DataRouterContext);
67398
- invariant(ctx, getDataRouterConsoleError2(hookName));
67399
- return ctx;
67400
- }
67401
- function useLinkClickHandler(to, {
67402
- target,
67403
- replace: replaceProp,
67404
- state,
67405
- preventScrollReset,
67406
- relative,
67407
- viewTransition
67408
- } = {}) {
67409
- let navigate = useNavigate();
67410
- let location = useLocation();
67411
- let path = useResolvedPath(to, { relative });
67412
- return React3.useCallback(
67413
- (event) => {
67414
- if (shouldProcessLinkClick(event, target)) {
67415
- event.preventDefault();
67416
- let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
67417
- navigate(to, {
67418
- replace: replace2,
67419
- state,
67420
- preventScrollReset,
67421
- relative,
67422
- viewTransition
67423
- });
67424
- }
67425
- },
67426
- [
67427
- location,
67428
- navigate,
67429
- path,
67430
- replaceProp,
67431
- state,
67432
- target,
67433
- to,
67434
- preventScrollReset,
67435
- relative,
67436
- viewTransition
67437
- ]
67438
- );
67439
- }
67440
- var fetcherId = 0;
67441
- var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
67442
- function useSubmit() {
67443
- let { router } = useDataRouterContext3("useSubmit" /* UseSubmit */);
67444
- let { basename } = React3.useContext(NavigationContext);
67445
- let currentRouteId = useRouteId();
67446
- return React3.useCallback(
67447
- async (target, options = {}) => {
67448
- let { action, method, encType, formData, body } = getFormSubmissionInfo(
67449
- target,
67450
- basename
67451
- );
67452
- if (options.navigate === false) {
67453
- let key = options.fetcherKey || getUniqueFetcherId();
67454
- await router.fetch(key, currentRouteId, options.action || action, {
67455
- preventScrollReset: options.preventScrollReset,
67456
- formData,
67457
- body,
67458
- formMethod: options.method || method,
67459
- formEncType: options.encType || encType,
67460
- flushSync: options.flushSync
67461
- });
67462
- } else {
67463
- await router.navigate(options.action || action, {
67464
- preventScrollReset: options.preventScrollReset,
67465
- formData,
67466
- body,
67467
- formMethod: options.method || method,
67468
- formEncType: options.encType || encType,
67469
- replace: options.replace,
67470
- state: options.state,
67471
- fromRouteId: currentRouteId,
67472
- flushSync: options.flushSync,
67473
- viewTransition: options.viewTransition
67474
- });
67475
- }
67476
- },
67477
- [router, basename, currentRouteId]
67478
- );
67479
- }
67480
- function useFormAction(action, { relative } = {}) {
67481
- let { basename } = React3.useContext(NavigationContext);
67482
- let routeContext = React3.useContext(RouteContext);
67483
- invariant(routeContext, "useFormAction must be used inside a RouteContext");
67484
- let [match] = routeContext.matches.slice(-1);
67485
- let path = { ...useResolvedPath(action ? action : ".", { relative }) };
67486
- let location = useLocation();
67487
- if (action == null) {
67488
- path.search = location.search;
67489
- let params = new URLSearchParams(path.search);
67490
- let indexValues = params.getAll("index");
67491
- let hasNakedIndexParam = indexValues.some((v) => v === "");
67492
- if (hasNakedIndexParam) {
67493
- params.delete("index");
67494
- indexValues.filter((v) => v).forEach((v) => params.append("index", v));
67495
- let qs = params.toString();
67496
- path.search = qs ? `?${qs}` : "";
67497
- }
67498
- }
67499
- if ((!action || action === ".") && match.route.index) {
67500
- path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
67501
- }
67502
- if (basename !== "/") {
67503
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
67504
- }
67505
- return createPath(path);
67506
- }
67507
- function useViewTransitionState(to, { relative } = {}) {
67508
- let vtContext = React3.useContext(ViewTransitionContext);
67509
- invariant(
67510
- vtContext != null,
67511
- "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
67512
- );
67513
- let { basename } = useDataRouterContext3(
67514
- "useViewTransitionState" /* useViewTransitionState */
67515
- );
67516
- let path = useResolvedPath(to, { relative });
67517
- if (!vtContext.isTransitioning) {
67518
- return false;
67519
- }
67520
- let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
67521
- let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
67522
- return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
67523
- }
67524
-
67525
65796
  var _excluded$6 = ["color"];
67526
65797
  var ExternalarrowMd = function ExternalarrowMd(_ref) {
67527
65798
  var _ref$color = _ref.color,
@@ -67549,7 +65820,7 @@ function RuledGrid(_ref) {
67549
65820
  var columns = _ref.columns,
67550
65821
  children = _ref.children,
67551
65822
  rest = _objectWithoutProperties(_ref, _excluded$5);
67552
- var childrenArray = React3__default.Children.toArray(children);
65823
+ var childrenArray = React__default.Children.toArray(children);
67553
65824
  return jsx(Grid, _objectSpread2(_objectSpread2({
67554
65825
  templateColumns: "repeat(".concat(columns, ", 1fr)"),
67555
65826
  border: "1px solid",
@@ -67572,7 +65843,9 @@ function HelloPage(_ref) {
67572
65843
  var userName = _ref.userName,
67573
65844
  onStartChat = _ref.onStartChat,
67574
65845
  _ref$isStartingChat = _ref.isStartingChat,
67575
- isStartingChat = _ref$isStartingChat === void 0 ? false : _ref$isStartingChat;
65846
+ isStartingChat = _ref$isStartingChat === void 0 ? false : _ref$isStartingChat,
65847
+ LinkComponent = _ref.LinkComponent;
65848
+ var hasRouterLink = Boolean(LinkComponent);
67576
65849
  var navigationItems = [{
67577
65850
  label: "Documentation",
67578
65851
  href: "https://droplinked.gitbook.io/droplinked-store-front-help-center",
@@ -67627,8 +65900,9 @@ function HelloPage(_ref) {
67627
65900
  },
67628
65901
  children: jsxs(VStack, {
67629
65902
  align: "stretch",
67630
- justify: "flex-start",
65903
+ justify: "flex-end",
67631
65904
  gap: 4,
65905
+ minH: "full",
67632
65906
  children: [jsxs(Flex, {
67633
65907
  flexDirection: "column",
67634
65908
  justifyContent: "flex-end",
@@ -67708,7 +65982,7 @@ function HelloPage(_ref) {
67708
65982
  borderRadius: 16,
67709
65983
  bg: "#222",
67710
65984
  children: navigationItems.map(function (item, index) {
67711
- return jsxs(Link$1, {
65985
+ return jsxs(Link, {
67712
65986
  display: "flex",
67713
65987
  justifyContent: "space-between",
67714
65988
  alignItems: "center",
@@ -67718,9 +65992,9 @@ function HelloPage(_ref) {
67718
65992
  fontWeight: 500,
67719
65993
  color: "white",
67720
65994
  textDecoration: "none",
67721
- as: item.isExternal ? undefined : Link,
67722
- to: item.isExternal ? undefined : item.href,
67723
- href: item.isExternal ? item.href : undefined,
65995
+ as: !item.isExternal && hasRouterLink ? LinkComponent : undefined,
65996
+ to: !item.isExternal && hasRouterLink ? item.href : undefined,
65997
+ href: item.isExternal || !hasRouterLink ? item.href : undefined,
67724
65998
  isExternal: item.isExternal,
67725
65999
  children: [item.label, jsx(ExternalarrowMd, {
67726
66000
  color: "white"
@@ -67900,7 +66174,7 @@ var TooltipMd = function TooltipMd(_ref) {
67900
66174
  };
67901
66175
 
67902
66176
  var _excluded = ["showArrow", "children", "disabled", "portalled", "content", "portalRef", "placement"];
67903
- var Tooltip = /*#__PURE__*/React3.forwardRef(function Tooltip(_ref2, _ref) {
66177
+ var Tooltip = /*#__PURE__*/React.forwardRef(function Tooltip(_ref2, _ref) {
67904
66178
  var showArrow = _ref2.showArrow,
67905
66179
  children = _ref2.children,
67906
66180
  disabled = _ref2.disabled;