strapi-plugin-hubspot 0.6.0 → 0.7.0

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 (33) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/_chunks/{Forms-CW1KFO9U.mjs → Forms-CKA6ukB6.mjs} +5 -4
  3. package/dist/_chunks/{Forms-BF4_zA-m.js → Forms-HMZbTk_B.js} +30 -29
  4. package/dist/_chunks/HubspotFormInput-BequMb12.js +79 -0
  5. package/dist/_chunks/HubspotFormInput-CKYRcNNU.mjs +61 -0
  6. package/dist/_chunks/{HubspotObjectInput-hjAYWtaU.js → HubspotObjectInput-D-FGwsyS.js} +8 -7
  7. package/dist/_chunks/{HubspotObjectInput-CpxeM2J0.mjs → HubspotObjectInput-V3uhGK8k.mjs} +4 -3
  8. package/dist/_chunks/{HubspotPropertyInput-OSeIBaRC.js → HubspotPropertyInput-Dn1QvOcu.js} +18 -17
  9. package/dist/_chunks/{HubspotPropertyInput-C-52Lu24.mjs → HubspotPropertyInput-DrBsx9jQ.mjs} +4 -3
  10. package/dist/_chunks/{Settings-2V7TH5CX.mjs → Settings-BjkNbyna.mjs} +4 -3
  11. package/dist/_chunks/{Settings-DcA9M5Tw.js → Settings-Cgp7M1Cv.js} +8 -7
  12. package/dist/_chunks/{en-CJ9wYHgN.mjs → en-Cun5LoUP.mjs} +8 -1
  13. package/dist/_chunks/{en-C_-N8cjv.js → en-D5Ch9YFo.js} +8 -1
  14. package/dist/_chunks/{fr-DttDn-2Y.mjs → fr-ClOWflse.mjs} +8 -1
  15. package/dist/_chunks/{fr-BHObPoUp.js → fr-CqlhHltZ.js} +8 -1
  16. package/dist/_chunks/{objectLabels-D9UEuOGr.mjs → index-CEh8vkxY.mjs} +0 -14
  17. package/dist/_chunks/{index-CMzg-x5i.js → index-D2Q34BuH.js} +21 -5
  18. package/dist/_chunks/{objectLabels-Th7aYW-B.js → index-DkTxsEqL.js} +0 -14
  19. package/dist/_chunks/{index-DkGOTp8p.mjs → index-FKsiOEPB.mjs} +21 -5
  20. package/dist/_chunks/objectLabels-DBKevJle.mjs +16 -0
  21. package/dist/_chunks/objectLabels-LAQ0M6-a.js +15 -0
  22. package/dist/_chunks/{useHubspotSchema-DQkQcA_V.mjs → useHubspotSchema-BC0Od-Wl.mjs} +1 -1
  23. package/dist/_chunks/{useHubspotSchema-Bgrgg8Mt.js → useHubspotSchema-C08qBAyy.js} +1 -1
  24. package/dist/admin/index.js +1 -1
  25. package/dist/admin/index.mjs +1 -1
  26. package/dist/admin/src/components/HubspotFormInput.d.ts +29 -0
  27. package/dist/server/index.js +33 -0
  28. package/dist/server/index.mjs +33 -0
  29. package/dist/server/src/formsAdmin.d.ts +7 -0
  30. package/dist/server/src/index.d.ts +1 -0
  31. package/package.json +3 -2
  32. package/dist/_chunks/index-C1UJXE_o.mjs +0 -1552
  33. package/dist/_chunks/index-Dgbid2LK.js +0 -1569
@@ -1,1569 +0,0 @@
1
- "use strict";
2
- const React = require("react");
3
- require("react-dom");
4
- function _interopNamespace(e) {
5
- if (e && e.__esModule) return e;
6
- const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
7
- if (e) {
8
- for (const k in e) {
9
- if (k !== "default") {
10
- const d = Object.getOwnPropertyDescriptor(e, k);
11
- Object.defineProperty(n, k, d.get ? d : {
12
- enumerable: true,
13
- get: () => e[k]
14
- });
15
- }
16
- }
17
- }
18
- n.default = e;
19
- return Object.freeze(n);
20
- }
21
- const React__namespace = /* @__PURE__ */ _interopNamespace(React);
22
- /**
23
- * @remix-run/router v1.23.3
24
- *
25
- * Copyright (c) Remix Software Inc.
26
- *
27
- * This source code is licensed under the MIT license found in the
28
- * LICENSE.md file in the root directory of this source tree.
29
- *
30
- * @license MIT
31
- */
32
- function _extends$2() {
33
- return _extends$2 = Object.assign ? Object.assign.bind() : function(n) {
34
- for (var e = 1; e < arguments.length; e++) {
35
- var t = arguments[e];
36
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
37
- }
38
- return n;
39
- }, _extends$2.apply(null, arguments);
40
- }
41
- var Action;
42
- (function(Action2) {
43
- Action2["Pop"] = "POP";
44
- Action2["Push"] = "PUSH";
45
- Action2["Replace"] = "REPLACE";
46
- })(Action || (Action = {}));
47
- function invariant(value, message) {
48
- if (value === false || value === null || typeof value === "undefined") {
49
- throw new Error(message);
50
- }
51
- }
52
- function warning(cond, message) {
53
- if (!cond) {
54
- if (typeof console !== "undefined") console.warn(message);
55
- try {
56
- throw new Error(message);
57
- } catch (e) {
58
- }
59
- }
60
- }
61
- function createPath(_ref) {
62
- let {
63
- pathname = "/",
64
- search = "",
65
- hash = ""
66
- } = _ref;
67
- if (search && search !== "?") pathname += search.charAt(0) === "?" ? search : "?" + search;
68
- if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
69
- return pathname;
70
- }
71
- function parsePath(path) {
72
- let parsedPath = {};
73
- if (path) {
74
- let hashIndex = path.indexOf("#");
75
- if (hashIndex >= 0) {
76
- parsedPath.hash = path.substr(hashIndex);
77
- path = path.substr(0, hashIndex);
78
- }
79
- let searchIndex = path.indexOf("?");
80
- if (searchIndex >= 0) {
81
- parsedPath.search = path.substr(searchIndex);
82
- path = path.substr(0, searchIndex);
83
- }
84
- if (path) {
85
- parsedPath.pathname = path;
86
- }
87
- }
88
- return parsedPath;
89
- }
90
- var ResultType;
91
- (function(ResultType2) {
92
- ResultType2["data"] = "data";
93
- ResultType2["deferred"] = "deferred";
94
- ResultType2["redirect"] = "redirect";
95
- ResultType2["error"] = "error";
96
- })(ResultType || (ResultType = {}));
97
- function matchRoutes(routes, locationArg, basename) {
98
- if (basename === void 0) {
99
- basename = "/";
100
- }
101
- return matchRoutesImpl(routes, locationArg, basename);
102
- }
103
- function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
104
- let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
105
- let pathname = stripBasename(location.pathname || "/", basename);
106
- if (pathname == null) {
107
- return null;
108
- }
109
- let branches = flattenRoutes(routes);
110
- rankRouteBranches(branches);
111
- let matches = null;
112
- let decoded = decodePath(pathname);
113
- for (let i = 0; matches == null && i < branches.length; ++i) {
114
- matches = matchRouteBranch(branches[i], decoded);
115
- }
116
- return matches;
117
- }
118
- function flattenRoutes(routes, branches, parentsMeta, parentPath) {
119
- if (branches === void 0) {
120
- branches = [];
121
- }
122
- if (parentsMeta === void 0) {
123
- parentsMeta = [];
124
- }
125
- if (parentPath === void 0) {
126
- parentPath = "";
127
- }
128
- let flattenRoute = (route, index, relativePath) => {
129
- let meta = {
130
- relativePath: relativePath === void 0 ? route.path || "" : relativePath,
131
- caseSensitive: route.caseSensitive === true,
132
- childrenIndex: index,
133
- route
134
- };
135
- if (meta.relativePath.startsWith("/")) {
136
- invariant(meta.relativePath.startsWith(parentPath), '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.");
137
- meta.relativePath = meta.relativePath.slice(parentPath.length);
138
- }
139
- let path = joinPaths([parentPath, meta.relativePath]);
140
- let routesMeta = parentsMeta.concat(meta);
141
- if (route.children && route.children.length > 0) {
142
- invariant(
143
- // Our types know better, but runtime JS may not!
144
- // @ts-expect-error
145
- route.index !== true,
146
- "Index routes must not have child routes. Please remove " + ('all child routes from route path "' + path + '".')
147
- );
148
- flattenRoutes(route.children, branches, routesMeta, path);
149
- }
150
- if (route.path == null && !route.index) {
151
- return;
152
- }
153
- branches.push({
154
- path,
155
- score: computeScore(path, route.index),
156
- routesMeta
157
- });
158
- };
159
- routes.forEach((route, index) => {
160
- var _route$path;
161
- if (route.path === "" || !((_route$path = route.path) != null && _route$path.includes("?"))) {
162
- flattenRoute(route, index);
163
- } else {
164
- for (let exploded of explodeOptionalSegments(route.path)) {
165
- flattenRoute(route, index, exploded);
166
- }
167
- }
168
- });
169
- return branches;
170
- }
171
- function explodeOptionalSegments(path) {
172
- let segments = path.split("/");
173
- if (segments.length === 0) return [];
174
- let [first, ...rest] = segments;
175
- let isOptional = first.endsWith("?");
176
- let required = first.replace(/\?$/, "");
177
- if (rest.length === 0) {
178
- return isOptional ? [required, ""] : [required];
179
- }
180
- let restExploded = explodeOptionalSegments(rest.join("/"));
181
- let result = [];
182
- result.push(...restExploded.map((subpath) => subpath === "" ? required : [required, subpath].join("/")));
183
- if (isOptional) {
184
- result.push(...restExploded);
185
- }
186
- return result.map((exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded);
187
- }
188
- function rankRouteBranches(branches) {
189
- branches.sort((a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(a.routesMeta.map((meta) => meta.childrenIndex), b.routesMeta.map((meta) => meta.childrenIndex)));
190
- }
191
- const paramRe = /^:[\w-]+$/;
192
- const dynamicSegmentValue = 3;
193
- const indexRouteValue = 2;
194
- const emptySegmentValue = 1;
195
- const staticSegmentValue = 10;
196
- const splatPenalty = -2;
197
- const isSplat = (s) => s === "*";
198
- function computeScore(path, index) {
199
- let segments = path.split("/");
200
- let initialScore = segments.length;
201
- if (segments.some(isSplat)) {
202
- initialScore += splatPenalty;
203
- }
204
- if (index) {
205
- initialScore += indexRouteValue;
206
- }
207
- return segments.filter((s) => !isSplat(s)).reduce((score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue), initialScore);
208
- }
209
- function compareIndexes(a, b) {
210
- let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
211
- return siblings ? (
212
- // If two routes are siblings, we should try to match the earlier sibling
213
- // first. This allows people to have fine-grained control over the matching
214
- // behavior by simply putting routes with identical paths in the order they
215
- // want them tried.
216
- a[a.length - 1] - b[b.length - 1]
217
- ) : (
218
- // Otherwise, it doesn't really make sense to rank non-siblings by index,
219
- // so they sort equally.
220
- 0
221
- );
222
- }
223
- function matchRouteBranch(branch, pathname, allowPartial) {
224
- let {
225
- routesMeta
226
- } = branch;
227
- let matchedParams = {};
228
- let matchedPathname = "/";
229
- let matches = [];
230
- for (let i = 0; i < routesMeta.length; ++i) {
231
- let meta = routesMeta[i];
232
- let end = i === routesMeta.length - 1;
233
- let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
234
- let match = matchPath({
235
- path: meta.relativePath,
236
- caseSensitive: meta.caseSensitive,
237
- end
238
- }, remainingPathname);
239
- let route = meta.route;
240
- if (!match) {
241
- return null;
242
- }
243
- Object.assign(matchedParams, match.params);
244
- matches.push({
245
- // TODO: Can this as be avoided?
246
- params: matchedParams,
247
- pathname: joinPaths([matchedPathname, match.pathname]),
248
- pathnameBase: normalizePathname(joinPaths([matchedPathname, match.pathnameBase])),
249
- route
250
- });
251
- if (match.pathnameBase !== "/") {
252
- matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
253
- }
254
- }
255
- return matches;
256
- }
257
- function matchPath(pattern, pathname) {
258
- if (typeof pattern === "string") {
259
- pattern = {
260
- path: pattern,
261
- caseSensitive: false,
262
- end: true
263
- };
264
- }
265
- let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
266
- let match = pathname.match(matcher);
267
- if (!match) return null;
268
- let matchedPathname = match[0];
269
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
270
- let captureGroups = match.slice(1);
271
- let params = compiledParams.reduce((memo, _ref, index) => {
272
- let {
273
- paramName,
274
- isOptional
275
- } = _ref;
276
- if (paramName === "*") {
277
- let splatValue = captureGroups[index] || "";
278
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
279
- }
280
- const value = captureGroups[index];
281
- if (isOptional && !value) {
282
- memo[paramName] = void 0;
283
- } else {
284
- memo[paramName] = (value || "").replace(/%2F/g, "/");
285
- }
286
- return memo;
287
- }, {});
288
- return {
289
- params,
290
- pathname: matchedPathname,
291
- pathnameBase,
292
- pattern
293
- };
294
- }
295
- function compilePath(path, caseSensitive, end) {
296
- if (caseSensitive === void 0) {
297
- caseSensitive = false;
298
- }
299
- if (end === void 0) {
300
- end = true;
301
- }
302
- warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), '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(/\*$/, "/*") + '".'));
303
- let params = [];
304
- let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional) => {
305
- params.push({
306
- paramName,
307
- isOptional: isOptional != null
308
- });
309
- return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
310
- });
311
- if (path.endsWith("*")) {
312
- params.push({
313
- paramName: "*"
314
- });
315
- regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
316
- } else if (end) {
317
- regexpSource += "\\/*$";
318
- } else if (path !== "" && path !== "/") {
319
- regexpSource += "(?:(?=\\/|$))";
320
- } else ;
321
- let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
322
- return [matcher, params];
323
- }
324
- function decodePath(value) {
325
- try {
326
- return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
327
- } catch (error) {
328
- warning(false, 'The URL path "' + value + '" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent ' + ("encoding (" + error + ")."));
329
- return value;
330
- }
331
- }
332
- function stripBasename(pathname, basename) {
333
- if (basename === "/") return pathname;
334
- if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
335
- return null;
336
- }
337
- let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
338
- let nextChar = pathname.charAt(startIndex);
339
- if (nextChar && nextChar !== "/") {
340
- return null;
341
- }
342
- return pathname.slice(startIndex) || "/";
343
- }
344
- const ABSOLUTE_URL_REGEX$1 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
345
- const isAbsoluteUrl = (url) => ABSOLUTE_URL_REGEX$1.test(url);
346
- function resolvePath(to, fromPathname) {
347
- if (fromPathname === void 0) {
348
- fromPathname = "/";
349
- }
350
- let {
351
- pathname: toPathname,
352
- search = "",
353
- hash = ""
354
- } = typeof to === "string" ? parsePath(to) : to;
355
- let pathname;
356
- if (toPathname) {
357
- if (isAbsoluteUrl(toPathname)) {
358
- pathname = toPathname;
359
- } else {
360
- if (toPathname.includes("//")) {
361
- let oldPathname = toPathname;
362
- toPathname = removeDoubleSlashes(toPathname);
363
- warning(false, "Pathnames cannot have embedded double slashes - normalizing " + (oldPathname + " -> " + toPathname));
364
- }
365
- if (toPathname.startsWith("/")) {
366
- pathname = resolvePathname(toPathname.substring(1), "/");
367
- } else {
368
- pathname = resolvePathname(toPathname, fromPathname);
369
- }
370
- }
371
- } else {
372
- pathname = fromPathname;
373
- }
374
- return {
375
- pathname,
376
- search: normalizeSearch(search),
377
- hash: normalizeHash(hash)
378
- };
379
- }
380
- function resolvePathname(relativePath, fromPathname) {
381
- let segments = fromPathname.replace(/\/+$/, "").split("/");
382
- let relativeSegments = relativePath.split("/");
383
- relativeSegments.forEach((segment) => {
384
- if (segment === "..") {
385
- if (segments.length > 1) segments.pop();
386
- } else if (segment !== ".") {
387
- segments.push(segment);
388
- }
389
- });
390
- return segments.length > 1 ? segments.join("/") : "/";
391
- }
392
- function getInvalidPathError(char, field, dest, path) {
393
- return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path) + "]. 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.';
394
- }
395
- function getPathContributingMatches(matches) {
396
- return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
397
- }
398
- function getResolveToMatches(matches, v7_relativeSplatPath) {
399
- let pathMatches = getPathContributingMatches(matches);
400
- if (v7_relativeSplatPath) {
401
- return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
402
- }
403
- return pathMatches.map((match) => match.pathnameBase);
404
- }
405
- function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
406
- if (isPathRelative === void 0) {
407
- isPathRelative = false;
408
- }
409
- let to;
410
- if (typeof toArg === "string") {
411
- to = parsePath(toArg);
412
- } else {
413
- to = _extends$2({}, toArg);
414
- invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
415
- invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
416
- invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
417
- }
418
- let isEmptyPath = toArg === "" || to.pathname === "";
419
- let toPathname = isEmptyPath ? "/" : to.pathname;
420
- let from;
421
- if (toPathname == null) {
422
- from = locationPathname;
423
- } else {
424
- let routePathnameIndex = routePathnames.length - 1;
425
- if (!isPathRelative && toPathname.startsWith("..")) {
426
- let toSegments = toPathname.split("/");
427
- while (toSegments[0] === "..") {
428
- toSegments.shift();
429
- routePathnameIndex -= 1;
430
- }
431
- to.pathname = toSegments.join("/");
432
- }
433
- from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
434
- }
435
- let path = resolvePath(to, from);
436
- let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
437
- let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
438
- if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
439
- path.pathname += "/";
440
- }
441
- return path;
442
- }
443
- const removeDoubleSlashes = (path) => path.replace(/\/\/+/g, "/");
444
- const joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
445
- const normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
446
- const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
447
- const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
448
- function isRouteErrorResponse(error) {
449
- return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
450
- }
451
- const validMutationMethodsArr = ["post", "put", "patch", "delete"];
452
- new Set(validMutationMethodsArr);
453
- const validRequestMethodsArr = ["get", ...validMutationMethodsArr];
454
- new Set(validRequestMethodsArr);
455
- /**
456
- * React Router v6.30.4
457
- *
458
- * Copyright (c) Remix Software Inc.
459
- *
460
- * This source code is licensed under the MIT license found in the
461
- * LICENSE.md file in the root directory of this source tree.
462
- *
463
- * @license MIT
464
- */
465
- function _extends$1() {
466
- return _extends$1 = Object.assign ? Object.assign.bind() : function(n) {
467
- for (var e = 1; e < arguments.length; e++) {
468
- var t = arguments[e];
469
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
470
- }
471
- return n;
472
- }, _extends$1.apply(null, arguments);
473
- }
474
- const DataRouterContext = /* @__PURE__ */ React__namespace.createContext(null);
475
- if (process.env.NODE_ENV !== "production") {
476
- DataRouterContext.displayName = "DataRouter";
477
- }
478
- const DataRouterStateContext = /* @__PURE__ */ React__namespace.createContext(null);
479
- if (process.env.NODE_ENV !== "production") {
480
- DataRouterStateContext.displayName = "DataRouterState";
481
- }
482
- const AwaitContext = /* @__PURE__ */ React__namespace.createContext(null);
483
- if (process.env.NODE_ENV !== "production") {
484
- AwaitContext.displayName = "Await";
485
- }
486
- const NavigationContext = /* @__PURE__ */ React__namespace.createContext(null);
487
- if (process.env.NODE_ENV !== "production") {
488
- NavigationContext.displayName = "Navigation";
489
- }
490
- const LocationContext = /* @__PURE__ */ React__namespace.createContext(null);
491
- if (process.env.NODE_ENV !== "production") {
492
- LocationContext.displayName = "Location";
493
- }
494
- const RouteContext = /* @__PURE__ */ React__namespace.createContext({
495
- outlet: null,
496
- matches: [],
497
- isDataRoute: false
498
- });
499
- if (process.env.NODE_ENV !== "production") {
500
- RouteContext.displayName = "Route";
501
- }
502
- const RouteErrorContext = /* @__PURE__ */ React__namespace.createContext(null);
503
- if (process.env.NODE_ENV !== "production") {
504
- RouteErrorContext.displayName = "RouteError";
505
- }
506
- function useHref(to, _temp) {
507
- let {
508
- relative
509
- } = _temp === void 0 ? {} : _temp;
510
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
511
- false,
512
- // TODO: This error is probably because they somehow have 2 versions of the
513
- // router loaded. We can help them understand how to avoid that.
514
- "useHref() may be used only in the context of a <Router> component."
515
- ) : invariant(false) : void 0;
516
- let {
517
- basename,
518
- navigator
519
- } = React__namespace.useContext(NavigationContext);
520
- let {
521
- hash,
522
- pathname,
523
- search
524
- } = useResolvedPath(to, {
525
- relative
526
- });
527
- let joinedPathname = pathname;
528
- if (basename !== "/") {
529
- joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
530
- }
531
- return navigator.createHref({
532
- pathname: joinedPathname,
533
- search,
534
- hash
535
- });
536
- }
537
- function useInRouterContext() {
538
- return React__namespace.useContext(LocationContext) != null;
539
- }
540
- function useLocation() {
541
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
542
- false,
543
- // TODO: This error is probably because they somehow have 2 versions of the
544
- // router loaded. We can help them understand how to avoid that.
545
- "useLocation() may be used only in the context of a <Router> component."
546
- ) : invariant(false) : void 0;
547
- return React__namespace.useContext(LocationContext).location;
548
- }
549
- const navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
550
- function useIsomorphicLayoutEffect(cb) {
551
- let isStatic = React__namespace.useContext(NavigationContext).static;
552
- if (!isStatic) {
553
- React__namespace.useLayoutEffect(cb);
554
- }
555
- }
556
- function useNavigate() {
557
- let {
558
- isDataRoute
559
- } = React__namespace.useContext(RouteContext);
560
- return isDataRoute ? useNavigateStable() : useNavigateUnstable();
561
- }
562
- function useNavigateUnstable() {
563
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
564
- false,
565
- // TODO: This error is probably because they somehow have 2 versions of the
566
- // router loaded. We can help them understand how to avoid that.
567
- "useNavigate() may be used only in the context of a <Router> component."
568
- ) : invariant(false) : void 0;
569
- let dataRouterContext = React__namespace.useContext(DataRouterContext);
570
- let {
571
- basename,
572
- future,
573
- navigator
574
- } = React__namespace.useContext(NavigationContext);
575
- let {
576
- matches
577
- } = React__namespace.useContext(RouteContext);
578
- let {
579
- pathname: locationPathname
580
- } = useLocation();
581
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
582
- let activeRef = React__namespace.useRef(false);
583
- useIsomorphicLayoutEffect(() => {
584
- activeRef.current = true;
585
- });
586
- let navigate = React__namespace.useCallback(function(to, options) {
587
- if (options === void 0) {
588
- options = {};
589
- }
590
- process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
591
- if (!activeRef.current) return;
592
- if (typeof to === "number") {
593
- navigator.go(to);
594
- return;
595
- }
596
- let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
597
- if (dataRouterContext == null && basename !== "/") {
598
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
599
- }
600
- (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
601
- }, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
602
- return navigate;
603
- }
604
- function useParams() {
605
- let {
606
- matches
607
- } = React__namespace.useContext(RouteContext);
608
- let routeMatch = matches[matches.length - 1];
609
- return routeMatch ? routeMatch.params : {};
610
- }
611
- function useResolvedPath(to, _temp2) {
612
- let {
613
- relative
614
- } = _temp2 === void 0 ? {} : _temp2;
615
- let {
616
- future
617
- } = React__namespace.useContext(NavigationContext);
618
- let {
619
- matches
620
- } = React__namespace.useContext(RouteContext);
621
- let {
622
- pathname: locationPathname
623
- } = useLocation();
624
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
625
- return React__namespace.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
626
- }
627
- function useRoutes(routes, locationArg) {
628
- return useRoutesImpl(routes, locationArg);
629
- }
630
- function useRoutesImpl(routes, locationArg, dataRouterState, future) {
631
- !useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
632
- false,
633
- // TODO: This error is probably because they somehow have 2 versions of the
634
- // router loaded. We can help them understand how to avoid that.
635
- "useRoutes() may be used only in the context of a <Router> component."
636
- ) : invariant(false) : void 0;
637
- let {
638
- navigator
639
- } = React__namespace.useContext(NavigationContext);
640
- let {
641
- matches: parentMatches
642
- } = React__namespace.useContext(RouteContext);
643
- let routeMatch = parentMatches[parentMatches.length - 1];
644
- let parentParams = routeMatch ? routeMatch.params : {};
645
- let parentPathname = routeMatch ? routeMatch.pathname : "/";
646
- let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
647
- let parentRoute = routeMatch && routeMatch.route;
648
- if (process.env.NODE_ENV !== "production") {
649
- let parentPath = parentRoute && parentRoute.path || "";
650
- warningOnce(parentPathname, !parentRoute || parentPath.endsWith("*"), "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.
651
-
652
- ` + ('Please change the parent <Route path="' + parentPath + '"> to <Route ') + ('path="' + (parentPath === "/" ? "*" : parentPath + "/*") + '">.'));
653
- }
654
- let locationFromContext = useLocation();
655
- let location;
656
- if (locationArg) {
657
- var _parsedLocationArg$pa;
658
- let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
659
- !(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? process.env.NODE_ENV !== "production" ? invariant(false, "When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, the location pathname must begin with the portion of the URL pathname that was " + ('matched by all parent routes. The current pathname base is "' + parentPathnameBase + '" ') + ('but pathname "' + parsedLocationArg.pathname + '" was given in the `location` prop.')) : invariant(false) : void 0;
660
- location = parsedLocationArg;
661
- } else {
662
- location = locationFromContext;
663
- }
664
- let pathname = location.pathname || "/";
665
- let remainingPathname = pathname;
666
- if (parentPathnameBase !== "/") {
667
- let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
668
- let segments = pathname.replace(/^\//, "").split("/");
669
- remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
670
- }
671
- let matches = matchRoutes(routes, {
672
- pathname: remainingPathname
673
- });
674
- if (process.env.NODE_ENV !== "production") {
675
- process.env.NODE_ENV !== "production" ? warning(parentRoute || matches != null, 'No routes matched location "' + location.pathname + location.search + location.hash + '" ') : void 0;
676
- process.env.NODE_ENV !== "production" ? warning(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, '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.') : void 0;
677
- }
678
- let renderedMatches = _renderMatches(matches && matches.map((match) => Object.assign({}, match, {
679
- params: Object.assign({}, parentParams, match.params),
680
- pathname: joinPaths([
681
- parentPathnameBase,
682
- // Re-encode pathnames that were decoded inside matchRoutes
683
- navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
684
- ]),
685
- pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
686
- parentPathnameBase,
687
- // Re-encode pathnames that were decoded inside matchRoutes
688
- navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
689
- ])
690
- })), parentMatches, dataRouterState, future);
691
- if (locationArg && renderedMatches) {
692
- return /* @__PURE__ */ React__namespace.createElement(LocationContext.Provider, {
693
- value: {
694
- location: _extends$1({
695
- pathname: "/",
696
- search: "",
697
- hash: "",
698
- state: null,
699
- key: "default"
700
- }, location),
701
- navigationType: Action.Pop
702
- }
703
- }, renderedMatches);
704
- }
705
- return renderedMatches;
706
- }
707
- function DefaultErrorComponent() {
708
- let error = useRouteError();
709
- let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
710
- let stack = error instanceof Error ? error.stack : null;
711
- let lightgrey = "rgba(200,200,200, 0.5)";
712
- let preStyles = {
713
- padding: "0.5rem",
714
- backgroundColor: lightgrey
715
- };
716
- let codeStyles = {
717
- padding: "2px 4px",
718
- backgroundColor: lightgrey
719
- };
720
- let devInfo = null;
721
- if (process.env.NODE_ENV !== "production") {
722
- console.error("Error handled by React Router default ErrorBoundary:", error);
723
- devInfo = /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ React__namespace.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React__namespace.createElement("code", {
724
- style: codeStyles
725
- }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React__namespace.createElement("code", {
726
- style: codeStyles
727
- }, "errorElement"), " prop on your route."));
728
- }
729
- return /* @__PURE__ */ React__namespace.createElement(React__namespace.Fragment, null, /* @__PURE__ */ React__namespace.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React__namespace.createElement("h3", {
730
- style: {
731
- fontStyle: "italic"
732
- }
733
- }, message), stack ? /* @__PURE__ */ React__namespace.createElement("pre", {
734
- style: preStyles
735
- }, stack) : null, devInfo);
736
- }
737
- const defaultErrorElement = /* @__PURE__ */ React__namespace.createElement(DefaultErrorComponent, null);
738
- class RenderErrorBoundary extends React__namespace.Component {
739
- constructor(props) {
740
- super(props);
741
- this.state = {
742
- location: props.location,
743
- revalidation: props.revalidation,
744
- error: props.error
745
- };
746
- }
747
- static getDerivedStateFromError(error) {
748
- return {
749
- error
750
- };
751
- }
752
- static getDerivedStateFromProps(props, state) {
753
- if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
754
- return {
755
- error: props.error,
756
- location: props.location,
757
- revalidation: props.revalidation
758
- };
759
- }
760
- return {
761
- error: props.error !== void 0 ? props.error : state.error,
762
- location: state.location,
763
- revalidation: props.revalidation || state.revalidation
764
- };
765
- }
766
- componentDidCatch(error, errorInfo) {
767
- console.error("React Router caught the following error during render", error, errorInfo);
768
- }
769
- render() {
770
- return this.state.error !== void 0 ? /* @__PURE__ */ React__namespace.createElement(RouteContext.Provider, {
771
- value: this.props.routeContext
772
- }, /* @__PURE__ */ React__namespace.createElement(RouteErrorContext.Provider, {
773
- value: this.state.error,
774
- children: this.props.component
775
- })) : this.props.children;
776
- }
777
- }
778
- function RenderedRoute(_ref) {
779
- let {
780
- routeContext,
781
- match,
782
- children
783
- } = _ref;
784
- let dataRouterContext = React__namespace.useContext(DataRouterContext);
785
- if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
786
- dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
787
- }
788
- return /* @__PURE__ */ React__namespace.createElement(RouteContext.Provider, {
789
- value: routeContext
790
- }, children);
791
- }
792
- function _renderMatches(matches, parentMatches, dataRouterState, future) {
793
- var _dataRouterState;
794
- if (parentMatches === void 0) {
795
- parentMatches = [];
796
- }
797
- if (dataRouterState === void 0) {
798
- dataRouterState = null;
799
- }
800
- if (future === void 0) {
801
- future = null;
802
- }
803
- if (matches == null) {
804
- var _future;
805
- if (!dataRouterState) {
806
- return null;
807
- }
808
- if (dataRouterState.errors) {
809
- matches = dataRouterState.matches;
810
- } else if ((_future = future) != null && _future.v7_partialHydration && parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
811
- matches = dataRouterState.matches;
812
- } else {
813
- return null;
814
- }
815
- }
816
- let renderedMatches = matches;
817
- let errors = (_dataRouterState = dataRouterState) == null ? void 0 : _dataRouterState.errors;
818
- if (errors != null) {
819
- let errorIndex = renderedMatches.findIndex((m) => m.route.id && (errors == null ? void 0 : errors[m.route.id]) !== void 0);
820
- !(errorIndex >= 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not find a matching route for errors on route IDs: " + Object.keys(errors).join(",")) : invariant(false) : void 0;
821
- renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
822
- }
823
- let renderFallback = false;
824
- let fallbackIndex = -1;
825
- if (dataRouterState && future && future.v7_partialHydration) {
826
- for (let i = 0; i < renderedMatches.length; i++) {
827
- let match = renderedMatches[i];
828
- if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
829
- fallbackIndex = i;
830
- }
831
- if (match.route.id) {
832
- let {
833
- loaderData,
834
- errors: errors2
835
- } = dataRouterState;
836
- let needsToRunLoader = match.route.loader && loaderData[match.route.id] === void 0 && (!errors2 || errors2[match.route.id] === void 0);
837
- if (match.route.lazy || needsToRunLoader) {
838
- renderFallback = true;
839
- if (fallbackIndex >= 0) {
840
- renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
841
- } else {
842
- renderedMatches = [renderedMatches[0]];
843
- }
844
- break;
845
- }
846
- }
847
- }
848
- }
849
- return renderedMatches.reduceRight((outlet, match, index) => {
850
- let error;
851
- let shouldRenderHydrateFallback = false;
852
- let errorElement = null;
853
- let hydrateFallbackElement = null;
854
- if (dataRouterState) {
855
- error = errors && match.route.id ? errors[match.route.id] : void 0;
856
- errorElement = match.route.errorElement || defaultErrorElement;
857
- if (renderFallback) {
858
- if (fallbackIndex < 0 && index === 0) {
859
- warningOnce("route-fallback", false, "No `HydrateFallback` element provided to render during initial hydration");
860
- shouldRenderHydrateFallback = true;
861
- hydrateFallbackElement = null;
862
- } else if (fallbackIndex === index) {
863
- shouldRenderHydrateFallback = true;
864
- hydrateFallbackElement = match.route.hydrateFallbackElement || null;
865
- }
866
- }
867
- }
868
- let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
869
- let getChildren = () => {
870
- let children;
871
- if (error) {
872
- children = errorElement;
873
- } else if (shouldRenderHydrateFallback) {
874
- children = hydrateFallbackElement;
875
- } else if (match.route.Component) {
876
- children = /* @__PURE__ */ React__namespace.createElement(match.route.Component, null);
877
- } else if (match.route.element) {
878
- children = match.route.element;
879
- } else {
880
- children = outlet;
881
- }
882
- return /* @__PURE__ */ React__namespace.createElement(RenderedRoute, {
883
- match,
884
- routeContext: {
885
- outlet,
886
- matches: matches2,
887
- isDataRoute: dataRouterState != null
888
- },
889
- children
890
- });
891
- };
892
- return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React__namespace.createElement(RenderErrorBoundary, {
893
- location: dataRouterState.location,
894
- revalidation: dataRouterState.revalidation,
895
- component: errorElement,
896
- error,
897
- children: getChildren(),
898
- routeContext: {
899
- outlet: null,
900
- matches: matches2,
901
- isDataRoute: true
902
- }
903
- }) : getChildren();
904
- }, null);
905
- }
906
- var DataRouterHook$1 = /* @__PURE__ */ function(DataRouterHook2) {
907
- DataRouterHook2["UseBlocker"] = "useBlocker";
908
- DataRouterHook2["UseRevalidator"] = "useRevalidator";
909
- DataRouterHook2["UseNavigateStable"] = "useNavigate";
910
- return DataRouterHook2;
911
- }(DataRouterHook$1 || {});
912
- var DataRouterStateHook$1 = /* @__PURE__ */ function(DataRouterStateHook2) {
913
- DataRouterStateHook2["UseBlocker"] = "useBlocker";
914
- DataRouterStateHook2["UseLoaderData"] = "useLoaderData";
915
- DataRouterStateHook2["UseActionData"] = "useActionData";
916
- DataRouterStateHook2["UseRouteError"] = "useRouteError";
917
- DataRouterStateHook2["UseNavigation"] = "useNavigation";
918
- DataRouterStateHook2["UseRouteLoaderData"] = "useRouteLoaderData";
919
- DataRouterStateHook2["UseMatches"] = "useMatches";
920
- DataRouterStateHook2["UseRevalidator"] = "useRevalidator";
921
- DataRouterStateHook2["UseNavigateStable"] = "useNavigate";
922
- DataRouterStateHook2["UseRouteId"] = "useRouteId";
923
- return DataRouterStateHook2;
924
- }(DataRouterStateHook$1 || {});
925
- function getDataRouterConsoleError$1(hookName) {
926
- return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
927
- }
928
- function useDataRouterContext$1(hookName) {
929
- let ctx = React__namespace.useContext(DataRouterContext);
930
- !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
931
- return ctx;
932
- }
933
- function useDataRouterState(hookName) {
934
- let state = React__namespace.useContext(DataRouterStateContext);
935
- !state ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
936
- return state;
937
- }
938
- function useRouteContext(hookName) {
939
- let route = React__namespace.useContext(RouteContext);
940
- !route ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
941
- return route;
942
- }
943
- function useCurrentRouteId(hookName) {
944
- let route = useRouteContext(hookName);
945
- let thisRoute = route.matches[route.matches.length - 1];
946
- !thisRoute.route.id ? process.env.NODE_ENV !== "production" ? invariant(false, hookName + ' can only be used on routes that contain a unique "id"') : invariant(false) : void 0;
947
- return thisRoute.route.id;
948
- }
949
- function useRouteId() {
950
- return useCurrentRouteId(DataRouterStateHook$1.UseRouteId);
951
- }
952
- function useRouteError() {
953
- var _state$errors;
954
- let error = React__namespace.useContext(RouteErrorContext);
955
- let state = useDataRouterState(DataRouterStateHook$1.UseRouteError);
956
- let routeId = useCurrentRouteId(DataRouterStateHook$1.UseRouteError);
957
- if (error !== void 0) {
958
- return error;
959
- }
960
- return (_state$errors = state.errors) == null ? void 0 : _state$errors[routeId];
961
- }
962
- function useNavigateStable() {
963
- let {
964
- router
965
- } = useDataRouterContext$1(DataRouterHook$1.UseNavigateStable);
966
- let id = useCurrentRouteId(DataRouterStateHook$1.UseNavigateStable);
967
- let activeRef = React__namespace.useRef(false);
968
- useIsomorphicLayoutEffect(() => {
969
- activeRef.current = true;
970
- });
971
- let navigate = React__namespace.useCallback(function(to, options) {
972
- if (options === void 0) {
973
- options = {};
974
- }
975
- process.env.NODE_ENV !== "production" ? warning(activeRef.current, navigateEffectWarning) : void 0;
976
- if (!activeRef.current) return;
977
- if (typeof to === "number") {
978
- router.navigate(to);
979
- } else {
980
- router.navigate(to, _extends$1({
981
- fromRouteId: id
982
- }, options));
983
- }
984
- }, [router, id]);
985
- return navigate;
986
- }
987
- const alreadyWarned$1 = {};
988
- function warningOnce(key, cond, message) {
989
- if (!cond && !alreadyWarned$1[key]) {
990
- alreadyWarned$1[key] = true;
991
- process.env.NODE_ENV !== "production" ? warning(false, message) : void 0;
992
- }
993
- }
994
- function Route(_props) {
995
- process.env.NODE_ENV !== "production" ? invariant(false, "A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.") : invariant(false);
996
- }
997
- function Routes(_ref6) {
998
- let {
999
- children,
1000
- location
1001
- } = _ref6;
1002
- return useRoutes(createRoutesFromChildren(children), location);
1003
- }
1004
- new Promise(() => {
1005
- });
1006
- function createRoutesFromChildren(children, parentPath) {
1007
- if (parentPath === void 0) {
1008
- parentPath = [];
1009
- }
1010
- let routes = [];
1011
- React__namespace.Children.forEach(children, (element, index) => {
1012
- if (!/* @__PURE__ */ React__namespace.isValidElement(element)) {
1013
- return;
1014
- }
1015
- let treePath = [...parentPath, index];
1016
- if (element.type === React__namespace.Fragment) {
1017
- routes.push.apply(routes, createRoutesFromChildren(element.props.children, treePath));
1018
- return;
1019
- }
1020
- !(element.type === Route) ? process.env.NODE_ENV !== "production" ? invariant(false, "[" + (typeof element.type === "string" ? element.type : element.type.name) + "] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>") : invariant(false) : void 0;
1021
- !(!element.props.index || !element.props.children) ? process.env.NODE_ENV !== "production" ? invariant(false, "An index route cannot have child routes.") : invariant(false) : void 0;
1022
- let route = {
1023
- id: element.props.id || treePath.join("-"),
1024
- caseSensitive: element.props.caseSensitive,
1025
- element: element.props.element,
1026
- Component: element.props.Component,
1027
- index: element.props.index,
1028
- path: element.props.path,
1029
- loader: element.props.loader,
1030
- action: element.props.action,
1031
- errorElement: element.props.errorElement,
1032
- ErrorBoundary: element.props.ErrorBoundary,
1033
- hasErrorBoundary: element.props.ErrorBoundary != null || element.props.errorElement != null,
1034
- shouldRevalidate: element.props.shouldRevalidate,
1035
- handle: element.props.handle,
1036
- lazy: element.props.lazy
1037
- };
1038
- if (element.props.children) {
1039
- route.children = createRoutesFromChildren(element.props.children, treePath);
1040
- }
1041
- routes.push(route);
1042
- });
1043
- return routes;
1044
- }
1045
- /**
1046
- * React Router DOM v6.30.4
1047
- *
1048
- * Copyright (c) Remix Software Inc.
1049
- *
1050
- * This source code is licensed under the MIT license found in the
1051
- * LICENSE.md file in the root directory of this source tree.
1052
- *
1053
- * @license MIT
1054
- */
1055
- function _extends() {
1056
- return _extends = Object.assign ? Object.assign.bind() : function(n) {
1057
- for (var e = 1; e < arguments.length; e++) {
1058
- var t = arguments[e];
1059
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
1060
- }
1061
- return n;
1062
- }, _extends.apply(null, arguments);
1063
- }
1064
- function _objectWithoutPropertiesLoose(r, e) {
1065
- if (null == r) return {};
1066
- var t = {};
1067
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
1068
- if (-1 !== e.indexOf(n)) continue;
1069
- t[n] = r[n];
1070
- }
1071
- return t;
1072
- }
1073
- const defaultMethod = "get";
1074
- const defaultEncType = "application/x-www-form-urlencoded";
1075
- function isHtmlElement(object) {
1076
- return object != null && typeof object.tagName === "string";
1077
- }
1078
- function isButtonElement(object) {
1079
- return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
1080
- }
1081
- function isFormElement(object) {
1082
- return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
1083
- }
1084
- function isInputElement(object) {
1085
- return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
1086
- }
1087
- function isModifiedEvent(event) {
1088
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
1089
- }
1090
- function shouldProcessLinkClick(event, target) {
1091
- return event.button === 0 && // Ignore everything but left clicks
1092
- (!target || target === "_self") && // Let browser handle "target=_blank" etc.
1093
- !isModifiedEvent(event);
1094
- }
1095
- function createSearchParams(init) {
1096
- if (init === void 0) {
1097
- init = "";
1098
- }
1099
- return new URLSearchParams(typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
1100
- let value = init[key];
1101
- return memo.concat(Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]);
1102
- }, []));
1103
- }
1104
- function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
1105
- let searchParams = createSearchParams(locationSearch);
1106
- if (defaultSearchParams) {
1107
- defaultSearchParams.forEach((_, key) => {
1108
- if (!searchParams.has(key)) {
1109
- defaultSearchParams.getAll(key).forEach((value) => {
1110
- searchParams.append(key, value);
1111
- });
1112
- }
1113
- });
1114
- }
1115
- return searchParams;
1116
- }
1117
- let _formDataSupportsSubmitter = null;
1118
- function isFormDataSubmitterSupported() {
1119
- if (_formDataSupportsSubmitter === null) {
1120
- try {
1121
- new FormData(
1122
- document.createElement("form"),
1123
- // @ts-expect-error if FormData supports the submitter parameter, this will throw
1124
- 0
1125
- );
1126
- _formDataSupportsSubmitter = false;
1127
- } catch (e) {
1128
- _formDataSupportsSubmitter = true;
1129
- }
1130
- }
1131
- return _formDataSupportsSubmitter;
1132
- }
1133
- const supportedFormEncTypes = /* @__PURE__ */ new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
1134
- function getFormEncType(encType) {
1135
- if (encType != null && !supportedFormEncTypes.has(encType)) {
1136
- process.env.NODE_ENV !== "production" ? warning(false, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType + '"')) : void 0;
1137
- return null;
1138
- }
1139
- return encType;
1140
- }
1141
- function getFormSubmissionInfo(target, basename) {
1142
- let method;
1143
- let action;
1144
- let encType;
1145
- let formData;
1146
- let body;
1147
- if (isFormElement(target)) {
1148
- let attr = target.getAttribute("action");
1149
- action = attr ? stripBasename(attr, basename) : null;
1150
- method = target.getAttribute("method") || defaultMethod;
1151
- encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
1152
- formData = new FormData(target);
1153
- } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
1154
- let form = target.form;
1155
- if (form == null) {
1156
- throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');
1157
- }
1158
- let attr = target.getAttribute("formaction") || form.getAttribute("action");
1159
- action = attr ? stripBasename(attr, basename) : null;
1160
- method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
1161
- encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
1162
- formData = new FormData(form, target);
1163
- if (!isFormDataSubmitterSupported()) {
1164
- let {
1165
- name,
1166
- type,
1167
- value
1168
- } = target;
1169
- if (type === "image") {
1170
- let prefix = name ? name + "." : "";
1171
- formData.append(prefix + "x", "0");
1172
- formData.append(prefix + "y", "0");
1173
- } else if (name) {
1174
- formData.append(name, value);
1175
- }
1176
- }
1177
- } else if (isHtmlElement(target)) {
1178
- throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
1179
- } else {
1180
- method = defaultMethod;
1181
- action = null;
1182
- encType = defaultEncType;
1183
- body = target;
1184
- }
1185
- if (formData && encType === "text/plain") {
1186
- body = formData;
1187
- formData = void 0;
1188
- }
1189
- return {
1190
- action,
1191
- method: method.toLowerCase(),
1192
- encType,
1193
- formData,
1194
- body
1195
- };
1196
- }
1197
- const _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "viewTransition"], _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "viewTransition", "children"], _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "viewTransition"];
1198
- const REACT_ROUTER_VERSION = "6";
1199
- try {
1200
- window.__reactRouterVersion = REACT_ROUTER_VERSION;
1201
- } catch (e) {
1202
- }
1203
- const ViewTransitionContext = /* @__PURE__ */ React__namespace.createContext({
1204
- isTransitioning: false
1205
- });
1206
- if (process.env.NODE_ENV !== "production") {
1207
- ViewTransitionContext.displayName = "ViewTransition";
1208
- }
1209
- const FetchersContext = /* @__PURE__ */ React__namespace.createContext(/* @__PURE__ */ new Map());
1210
- if (process.env.NODE_ENV !== "production") {
1211
- FetchersContext.displayName = "Fetchers";
1212
- }
1213
- if (process.env.NODE_ENV !== "production") ;
1214
- const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
1215
- const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1216
- const Link = /* @__PURE__ */ React__namespace.forwardRef(function LinkWithRef(_ref7, ref) {
1217
- let {
1218
- onClick,
1219
- relative,
1220
- reloadDocument,
1221
- replace,
1222
- state,
1223
- target,
1224
- to,
1225
- preventScrollReset,
1226
- viewTransition
1227
- } = _ref7, rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
1228
- let {
1229
- basename
1230
- } = React__namespace.useContext(NavigationContext);
1231
- let absoluteHref;
1232
- let isExternal = false;
1233
- if (typeof to === "string" && ABSOLUTE_URL_REGEX.test(to)) {
1234
- absoluteHref = to;
1235
- if (isBrowser) {
1236
- try {
1237
- let currentUrl = new URL(window.location.href);
1238
- let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
1239
- let path = stripBasename(targetUrl.pathname, basename);
1240
- if (targetUrl.origin === currentUrl.origin && path != null) {
1241
- to = path + targetUrl.search + targetUrl.hash;
1242
- } else {
1243
- isExternal = true;
1244
- }
1245
- } catch (e) {
1246
- process.env.NODE_ENV !== "production" ? warning(false, '<Link to="' + to + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.') : void 0;
1247
- }
1248
- }
1249
- }
1250
- let href = useHref(to, {
1251
- relative
1252
- });
1253
- let internalOnClick = useLinkClickHandler(to, {
1254
- replace,
1255
- state,
1256
- target,
1257
- preventScrollReset,
1258
- relative,
1259
- viewTransition
1260
- });
1261
- function handleClick(event) {
1262
- if (onClick) onClick(event);
1263
- if (!event.defaultPrevented) {
1264
- internalOnClick(event);
1265
- }
1266
- }
1267
- return (
1268
- // eslint-disable-next-line jsx-a11y/anchor-has-content
1269
- /* @__PURE__ */ React__namespace.createElement("a", _extends({}, rest, {
1270
- href: absoluteHref || href,
1271
- onClick: isExternal || reloadDocument ? onClick : handleClick,
1272
- ref,
1273
- target
1274
- }))
1275
- );
1276
- });
1277
- if (process.env.NODE_ENV !== "production") {
1278
- Link.displayName = "Link";
1279
- }
1280
- const NavLink = /* @__PURE__ */ React__namespace.forwardRef(function NavLinkWithRef(_ref8, ref) {
1281
- let {
1282
- "aria-current": ariaCurrentProp = "page",
1283
- caseSensitive = false,
1284
- className: classNameProp = "",
1285
- end = false,
1286
- style: styleProp,
1287
- to,
1288
- viewTransition,
1289
- children
1290
- } = _ref8, rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
1291
- let path = useResolvedPath(to, {
1292
- relative: rest.relative
1293
- });
1294
- let location = useLocation();
1295
- let routerState = React__namespace.useContext(DataRouterStateContext);
1296
- let {
1297
- navigator,
1298
- basename
1299
- } = React__namespace.useContext(NavigationContext);
1300
- let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
1301
- // eslint-disable-next-line react-hooks/rules-of-hooks
1302
- useViewTransitionState(path) && viewTransition === true;
1303
- let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
1304
- let locationPathname = location.pathname;
1305
- let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
1306
- if (!caseSensitive) {
1307
- locationPathname = locationPathname.toLowerCase();
1308
- nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
1309
- toPathname = toPathname.toLowerCase();
1310
- }
1311
- if (nextLocationPathname && basename) {
1312
- nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
1313
- }
1314
- const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
1315
- let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
1316
- let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
1317
- let renderProps = {
1318
- isActive,
1319
- isPending,
1320
- isTransitioning
1321
- };
1322
- let ariaCurrent = isActive ? ariaCurrentProp : void 0;
1323
- let className;
1324
- if (typeof classNameProp === "function") {
1325
- className = classNameProp(renderProps);
1326
- } else {
1327
- className = [classNameProp, isActive ? "active" : null, isPending ? "pending" : null, isTransitioning ? "transitioning" : null].filter(Boolean).join(" ");
1328
- }
1329
- let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
1330
- return /* @__PURE__ */ React__namespace.createElement(Link, _extends({}, rest, {
1331
- "aria-current": ariaCurrent,
1332
- className,
1333
- ref,
1334
- style,
1335
- to,
1336
- viewTransition
1337
- }), typeof children === "function" ? children(renderProps) : children);
1338
- });
1339
- if (process.env.NODE_ENV !== "production") {
1340
- NavLink.displayName = "NavLink";
1341
- }
1342
- const Form = /* @__PURE__ */ React__namespace.forwardRef((_ref9, forwardedRef) => {
1343
- let {
1344
- fetcherKey,
1345
- navigate,
1346
- reloadDocument,
1347
- replace,
1348
- state,
1349
- method = defaultMethod,
1350
- action,
1351
- onSubmit,
1352
- relative,
1353
- preventScrollReset,
1354
- viewTransition
1355
- } = _ref9, props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
1356
- let submit = useSubmit();
1357
- let formAction = useFormAction(action, {
1358
- relative
1359
- });
1360
- let formMethod = method.toLowerCase() === "get" ? "get" : "post";
1361
- let submitHandler = (event) => {
1362
- onSubmit && onSubmit(event);
1363
- if (event.defaultPrevented) return;
1364
- event.preventDefault();
1365
- let submitter = event.nativeEvent.submitter;
1366
- let submitMethod = (submitter == null ? void 0 : submitter.getAttribute("formmethod")) || method;
1367
- submit(submitter || event.currentTarget, {
1368
- fetcherKey,
1369
- method: submitMethod,
1370
- navigate,
1371
- replace,
1372
- state,
1373
- relative,
1374
- preventScrollReset,
1375
- viewTransition
1376
- });
1377
- };
1378
- return /* @__PURE__ */ React__namespace.createElement("form", _extends({
1379
- ref: forwardedRef,
1380
- method: formMethod,
1381
- action: formAction,
1382
- onSubmit: reloadDocument ? onSubmit : submitHandler
1383
- }, props));
1384
- });
1385
- if (process.env.NODE_ENV !== "production") {
1386
- Form.displayName = "Form";
1387
- }
1388
- if (process.env.NODE_ENV !== "production") ;
1389
- var DataRouterHook;
1390
- (function(DataRouterHook2) {
1391
- DataRouterHook2["UseScrollRestoration"] = "useScrollRestoration";
1392
- DataRouterHook2["UseSubmit"] = "useSubmit";
1393
- DataRouterHook2["UseSubmitFetcher"] = "useSubmitFetcher";
1394
- DataRouterHook2["UseFetcher"] = "useFetcher";
1395
- DataRouterHook2["useViewTransitionState"] = "useViewTransitionState";
1396
- })(DataRouterHook || (DataRouterHook = {}));
1397
- var DataRouterStateHook;
1398
- (function(DataRouterStateHook2) {
1399
- DataRouterStateHook2["UseFetcher"] = "useFetcher";
1400
- DataRouterStateHook2["UseFetchers"] = "useFetchers";
1401
- DataRouterStateHook2["UseScrollRestoration"] = "useScrollRestoration";
1402
- })(DataRouterStateHook || (DataRouterStateHook = {}));
1403
- function getDataRouterConsoleError(hookName) {
1404
- return hookName + " must be used within a data router. See https://reactrouter.com/v6/routers/picking-a-router.";
1405
- }
1406
- function useDataRouterContext(hookName) {
1407
- let ctx = React__namespace.useContext(DataRouterContext);
1408
- !ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
1409
- return ctx;
1410
- }
1411
- function useLinkClickHandler(to, _temp) {
1412
- let {
1413
- target,
1414
- replace: replaceProp,
1415
- state,
1416
- preventScrollReset,
1417
- relative,
1418
- viewTransition
1419
- } = _temp === void 0 ? {} : _temp;
1420
- let navigate = useNavigate();
1421
- let location = useLocation();
1422
- let path = useResolvedPath(to, {
1423
- relative
1424
- });
1425
- return React__namespace.useCallback((event) => {
1426
- if (shouldProcessLinkClick(event, target)) {
1427
- event.preventDefault();
1428
- let replace = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
1429
- navigate(to, {
1430
- replace,
1431
- state,
1432
- preventScrollReset,
1433
- relative,
1434
- viewTransition
1435
- });
1436
- }
1437
- }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, viewTransition]);
1438
- }
1439
- function useSearchParams(defaultInit) {
1440
- process.env.NODE_ENV !== "production" ? warning(typeof URLSearchParams !== "undefined", "You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.") : void 0;
1441
- let defaultSearchParamsRef = React__namespace.useRef(createSearchParams(defaultInit));
1442
- let hasSetSearchParamsRef = React__namespace.useRef(false);
1443
- let location = useLocation();
1444
- let searchParams = React__namespace.useMemo(() => (
1445
- // Only merge in the defaults if we haven't yet called setSearchParams.
1446
- // Once we call that we want those to take precedence, otherwise you can't
1447
- // remove a param with setSearchParams({}) if it has an initial value
1448
- getSearchParamsForLocation(location.search, hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current)
1449
- ), [location.search]);
1450
- let navigate = useNavigate();
1451
- let setSearchParams = React__namespace.useCallback((nextInit, navigateOptions) => {
1452
- const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(searchParams) : nextInit);
1453
- hasSetSearchParamsRef.current = true;
1454
- navigate("?" + newSearchParams, navigateOptions);
1455
- }, [navigate, searchParams]);
1456
- return [searchParams, setSearchParams];
1457
- }
1458
- function validateClientSideSubmission() {
1459
- if (typeof document === "undefined") {
1460
- throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
1461
- }
1462
- }
1463
- let fetcherId = 0;
1464
- let getUniqueFetcherId = () => "__" + String(++fetcherId) + "__";
1465
- function useSubmit() {
1466
- let {
1467
- router
1468
- } = useDataRouterContext(DataRouterHook.UseSubmit);
1469
- let {
1470
- basename
1471
- } = React__namespace.useContext(NavigationContext);
1472
- let currentRouteId = useRouteId();
1473
- return React__namespace.useCallback(function(target, options) {
1474
- if (options === void 0) {
1475
- options = {};
1476
- }
1477
- validateClientSideSubmission();
1478
- let {
1479
- action,
1480
- method,
1481
- encType,
1482
- formData,
1483
- body
1484
- } = getFormSubmissionInfo(target, basename);
1485
- if (options.navigate === false) {
1486
- let key = options.fetcherKey || getUniqueFetcherId();
1487
- router.fetch(key, currentRouteId, options.action || action, {
1488
- preventScrollReset: options.preventScrollReset,
1489
- formData,
1490
- body,
1491
- formMethod: options.method || method,
1492
- formEncType: options.encType || encType,
1493
- flushSync: options.flushSync
1494
- });
1495
- } else {
1496
- router.navigate(options.action || action, {
1497
- preventScrollReset: options.preventScrollReset,
1498
- formData,
1499
- body,
1500
- formMethod: options.method || method,
1501
- formEncType: options.encType || encType,
1502
- replace: options.replace,
1503
- state: options.state,
1504
- fromRouteId: currentRouteId,
1505
- flushSync: options.flushSync,
1506
- viewTransition: options.viewTransition
1507
- });
1508
- }
1509
- }, [router, basename, currentRouteId]);
1510
- }
1511
- function useFormAction(action, _temp2) {
1512
- let {
1513
- relative
1514
- } = _temp2 === void 0 ? {} : _temp2;
1515
- let {
1516
- basename
1517
- } = React__namespace.useContext(NavigationContext);
1518
- let routeContext = React__namespace.useContext(RouteContext);
1519
- !routeContext ? process.env.NODE_ENV !== "production" ? invariant(false, "useFormAction must be used inside a RouteContext") : invariant(false) : void 0;
1520
- let [match] = routeContext.matches.slice(-1);
1521
- let path = _extends({}, useResolvedPath(action ? action : ".", {
1522
- relative
1523
- }));
1524
- let location = useLocation();
1525
- if (action == null) {
1526
- path.search = location.search;
1527
- let params = new URLSearchParams(path.search);
1528
- let indexValues = params.getAll("index");
1529
- let hasNakedIndexParam = indexValues.some((v) => v === "");
1530
- if (hasNakedIndexParam) {
1531
- params.delete("index");
1532
- indexValues.filter((v) => v).forEach((v) => params.append("index", v));
1533
- let qs = params.toString();
1534
- path.search = qs ? "?" + qs : "";
1535
- }
1536
- }
1537
- if ((!action || action === ".") && match.route.index) {
1538
- path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
1539
- }
1540
- if (basename !== "/") {
1541
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
1542
- }
1543
- return createPath(path);
1544
- }
1545
- function useViewTransitionState(to, opts) {
1546
- if (opts === void 0) {
1547
- opts = {};
1548
- }
1549
- let vtContext = React__namespace.useContext(ViewTransitionContext);
1550
- !(vtContext != null) ? process.env.NODE_ENV !== "production" ? invariant(false, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?") : invariant(false) : void 0;
1551
- let {
1552
- basename
1553
- } = useDataRouterContext(DataRouterHook.useViewTransitionState);
1554
- let path = useResolvedPath(to, {
1555
- relative: opts.relative
1556
- });
1557
- if (!vtContext.isTransitioning) {
1558
- return false;
1559
- }
1560
- let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
1561
- let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
1562
- return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
1563
- }
1564
- exports.Link = Link;
1565
- exports.Route = Route;
1566
- exports.Routes = Routes;
1567
- exports.useNavigate = useNavigate;
1568
- exports.useParams = useParams;
1569
- exports.useSearchParams = useSearchParams;