@hmlr/govuk-react-components-library 1.2.1 → 1.2.2

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.cjs.js CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var govukFrontend = require('govuk-frontend');
5
- var React3 = require('react');
5
+ var reactRouter = require('react-router');
6
+ var React = require('react');
6
7
 
7
8
  function _interopNamespaceDefault(e) {
8
9
  var n = Object.create(null);
@@ -21,7 +22,7 @@ function _interopNamespaceDefault(e) {
21
22
  return Object.freeze(n);
22
23
  }
23
24
 
24
- var React3__namespace = /*#__PURE__*/_interopNamespaceDefault(React3);
25
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
25
26
 
26
27
  function ConfigureOverallAccordion($scope, config) {
27
28
  if (JSON.stringify(config) === JSON.stringify({})) {
@@ -97,1962 +98,9 @@ const Accordion = ({ headingLevel: HeadingLevel = "h2", items = [], className, i
97
98
  return (jsxRuntime.jsx("div", { ...remainingAttributes, id: id, className: `govuk-accordion ${className || ""}`, "data-module": "govuk-accordion", children: items.filter(Boolean).map((item, index) => (jsxRuntime.jsxs("div", { className: `govuk-accordion__section ${item.expanded ? "govuk-accordion__section--expanded" : ""}`, children: [jsxRuntime.jsxs("div", { className: "govuk-accordion__section-header", children: [jsxRuntime.jsx(HeadingLevel, { className: "govuk-accordion__section-heading", children: jsxRuntime.jsx("span", { className: "govuk-accordion__section-button", id: `${id}-heading-${index + 1}`, children: item.heading?.children }) }), item.summary && (jsxRuntime.jsx("div", { className: "govuk-accordion__section-summary govuk-body", id: `${id}-summary-${index + 1}`, children: item.summary.children }))] }), jsxRuntime.jsx("div", { id: `${id}-content-${index + 1}`, className: "govuk-accordion__section-content", "aria-labelledby": `${id}-heading-${index + 1}`, children: item.content?.children })] }, item.reactListKey || index))) }));
98
99
  };
99
100
 
100
- /**
101
- * react-router v7.13.2
102
- *
103
- * Copyright (c) Remix Software Inc.
104
- *
105
- * This source code is licensed under the MIT license found in the
106
- * LICENSE.md file in the root directory of this source tree.
107
- *
108
- * @license MIT
109
- */
110
- function invariant(value, message) {
111
- if (value === false || value === null || typeof value === "undefined") {
112
- throw new Error(message);
113
- }
114
- }
115
- function warning(cond, message) {
116
- if (!cond) {
117
- if (typeof console !== "undefined") console.warn(message);
118
- try {
119
- throw new Error(message);
120
- } catch (e) {
121
- }
122
- }
123
- }
124
- function createPath({
125
- pathname = "/",
126
- search = "",
127
- hash = ""
128
- }) {
129
- if (search && search !== "?")
130
- pathname += search.charAt(0) === "?" ? search : "?" + search;
131
- if (hash && hash !== "#")
132
- pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
133
- return pathname;
134
- }
135
- function parsePath(path) {
136
- let parsedPath = {};
137
- if (path) {
138
- let hashIndex = path.indexOf("#");
139
- if (hashIndex >= 0) {
140
- parsedPath.hash = path.substring(hashIndex);
141
- path = path.substring(0, hashIndex);
142
- }
143
- let searchIndex = path.indexOf("?");
144
- if (searchIndex >= 0) {
145
- parsedPath.search = path.substring(searchIndex);
146
- path = path.substring(0, searchIndex);
147
- }
148
- if (path) {
149
- parsedPath.pathname = path;
150
- }
151
- }
152
- return parsedPath;
153
- }
154
- function matchRoutes(routes, locationArg, basename = "/") {
155
- return matchRoutesImpl(routes, locationArg, basename, false);
156
- }
157
- function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
158
- let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
159
- let pathname = stripBasename(location.pathname || "/", basename);
160
- if (pathname == null) {
161
- return null;
162
- }
163
- let branches = flattenRoutes(routes);
164
- rankRouteBranches(branches);
165
- let matches = null;
166
- for (let i = 0; matches == null && i < branches.length; ++i) {
167
- let decoded = decodePath(pathname);
168
- matches = matchRouteBranch(
169
- branches[i],
170
- decoded,
171
- allowPartial
172
- );
173
- }
174
- return matches;
175
- }
176
- function flattenRoutes(routes, branches = [], parentsMeta = [], parentPath = "", _hasParentOptionalSegments = false) {
177
- let flattenRoute = (route, index, hasParentOptionalSegments = _hasParentOptionalSegments, relativePath) => {
178
- let meta = {
179
- relativePath: relativePath === void 0 ? route.path || "" : relativePath,
180
- caseSensitive: route.caseSensitive === true,
181
- childrenIndex: index,
182
- route
183
- };
184
- if (meta.relativePath.startsWith("/")) {
185
- if (!meta.relativePath.startsWith(parentPath) && hasParentOptionalSegments) {
186
- return;
187
- }
188
- invariant(
189
- meta.relativePath.startsWith(parentPath),
190
- `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.`
191
- );
192
- meta.relativePath = meta.relativePath.slice(parentPath.length);
193
- }
194
- let path = joinPaths([parentPath, meta.relativePath]);
195
- let routesMeta = parentsMeta.concat(meta);
196
- if (route.children && route.children.length > 0) {
197
- invariant(
198
- // Our types know better, but runtime JS may not!
199
- // @ts-expect-error
200
- route.index !== true,
201
- `Index routes must not have child routes. Please remove all child routes from route path "${path}".`
202
- );
203
- flattenRoutes(
204
- route.children,
205
- branches,
206
- routesMeta,
207
- path,
208
- hasParentOptionalSegments
209
- );
210
- }
211
- if (route.path == null && !route.index) {
212
- return;
213
- }
214
- branches.push({
215
- path,
216
- score: computeScore(path, route.index),
217
- routesMeta
218
- });
219
- };
220
- routes.forEach((route, index) => {
221
- if (route.path === "" || !route.path?.includes("?")) {
222
- flattenRoute(route, index);
223
- } else {
224
- for (let exploded of explodeOptionalSegments(route.path)) {
225
- flattenRoute(route, index, true, exploded);
226
- }
227
- }
228
- });
229
- return branches;
230
- }
231
- function explodeOptionalSegments(path) {
232
- let segments = path.split("/");
233
- if (segments.length === 0) return [];
234
- let [first, ...rest] = segments;
235
- let isOptional = first.endsWith("?");
236
- let required = first.replace(/\?$/, "");
237
- if (rest.length === 0) {
238
- return isOptional ? [required, ""] : [required];
239
- }
240
- let restExploded = explodeOptionalSegments(rest.join("/"));
241
- let result = [];
242
- result.push(
243
- ...restExploded.map(
244
- (subpath) => subpath === "" ? required : [required, subpath].join("/")
245
- )
246
- );
247
- if (isOptional) {
248
- result.push(...restExploded);
249
- }
250
- return result.map(
251
- (exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded
252
- );
253
- }
254
- function rankRouteBranches(branches) {
255
- branches.sort(
256
- (a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(
257
- a.routesMeta.map((meta) => meta.childrenIndex),
258
- b.routesMeta.map((meta) => meta.childrenIndex)
259
- )
260
- );
261
- }
262
- var paramRe = /^:[\w-]+$/;
263
- var dynamicSegmentValue = 3;
264
- var indexRouteValue = 2;
265
- var emptySegmentValue = 1;
266
- var staticSegmentValue = 10;
267
- var splatPenalty = -2;
268
- var isSplat = (s) => s === "*";
269
- function computeScore(path, index) {
270
- let segments = path.split("/");
271
- let initialScore = segments.length;
272
- if (segments.some(isSplat)) {
273
- initialScore += splatPenalty;
274
- }
275
- if (index) {
276
- initialScore += indexRouteValue;
277
- }
278
- return segments.filter((s) => !isSplat(s)).reduce(
279
- (score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
280
- initialScore
281
- );
282
- }
283
- function compareIndexes(a, b) {
284
- let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
285
- return siblings ? (
286
- // If two routes are siblings, we should try to match the earlier sibling
287
- // first. This allows people to have fine-grained control over the matching
288
- // behavior by simply putting routes with identical paths in the order they
289
- // want them tried.
290
- a[a.length - 1] - b[b.length - 1]
291
- ) : (
292
- // Otherwise, it doesn't really make sense to rank non-siblings by index,
293
- // so they sort equally.
294
- 0
295
- );
296
- }
297
- function matchRouteBranch(branch, pathname, allowPartial = false) {
298
- let { routesMeta } = branch;
299
- let matchedParams = {};
300
- let matchedPathname = "/";
301
- let matches = [];
302
- for (let i = 0; i < routesMeta.length; ++i) {
303
- let meta = routesMeta[i];
304
- let end = i === routesMeta.length - 1;
305
- let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
306
- let match = matchPath(
307
- { path: meta.relativePath, caseSensitive: meta.caseSensitive, end },
308
- remainingPathname
309
- );
310
- let route = meta.route;
311
- if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
312
- match = matchPath(
313
- {
314
- path: meta.relativePath,
315
- caseSensitive: meta.caseSensitive,
316
- end: false
317
- },
318
- remainingPathname
319
- );
320
- }
321
- if (!match) {
322
- return null;
323
- }
324
- Object.assign(matchedParams, match.params);
325
- matches.push({
326
- // TODO: Can this as be avoided?
327
- params: matchedParams,
328
- pathname: joinPaths([matchedPathname, match.pathname]),
329
- pathnameBase: normalizePathname(
330
- joinPaths([matchedPathname, match.pathnameBase])
331
- ),
332
- route
333
- });
334
- if (match.pathnameBase !== "/") {
335
- matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
336
- }
337
- }
338
- return matches;
339
- }
340
- function matchPath(pattern, pathname) {
341
- if (typeof pattern === "string") {
342
- pattern = { path: pattern, caseSensitive: false, end: true };
343
- }
344
- let [matcher, compiledParams] = compilePath(
345
- pattern.path,
346
- pattern.caseSensitive,
347
- pattern.end
348
- );
349
- let match = pathname.match(matcher);
350
- if (!match) return null;
351
- let matchedPathname = match[0];
352
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
353
- let captureGroups = match.slice(1);
354
- let params = compiledParams.reduce(
355
- (memo2, { paramName, isOptional }, index) => {
356
- if (paramName === "*") {
357
- let splatValue = captureGroups[index] || "";
358
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
359
- }
360
- const value = captureGroups[index];
361
- if (isOptional && !value) {
362
- memo2[paramName] = void 0;
363
- } else {
364
- memo2[paramName] = (value || "").replace(/%2F/g, "/");
365
- }
366
- return memo2;
367
- },
368
- {}
369
- );
370
- return {
371
- params,
372
- pathname: matchedPathname,
373
- pathnameBase,
374
- pattern
375
- };
376
- }
377
- function compilePath(path, caseSensitive = false, end = true) {
378
- warning(
379
- path === "*" || !path.endsWith("*") || path.endsWith("/*"),
380
- `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(/\*$/, "/*")}".`
381
- );
382
- let params = [];
383
- let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
384
- /\/:([\w-]+)(\?)?/g,
385
- (match, paramName, isOptional, index, str) => {
386
- params.push({ paramName, isOptional: isOptional != null });
387
- if (isOptional) {
388
- let nextChar = str.charAt(index + match.length);
389
- if (nextChar && nextChar !== "/") {
390
- return "/([^\\/]*)";
391
- }
392
- return "(?:/([^\\/]*))?";
393
- }
394
- return "/([^\\/]+)";
395
- }
396
- ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
397
- if (path.endsWith("*")) {
398
- params.push({ paramName: "*" });
399
- regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
400
- } else if (end) {
401
- regexpSource += "\\/*$";
402
- } else if (path !== "" && path !== "/") {
403
- regexpSource += "(?:(?=\\/|$))";
404
- } else ;
405
- let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
406
- return [matcher, params];
407
- }
408
- function decodePath(value) {
409
- try {
410
- return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
411
- } catch (error) {
412
- warning(
413
- false,
414
- `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}).`
415
- );
416
- return value;
417
- }
418
- }
419
- function stripBasename(pathname, basename) {
420
- if (basename === "/") return pathname;
421
- if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
422
- return null;
423
- }
424
- let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
425
- let nextChar = pathname.charAt(startIndex);
426
- if (nextChar && nextChar !== "/") {
427
- return null;
428
- }
429
- return pathname.slice(startIndex) || "/";
430
- }
431
- var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
432
- function resolvePath(to, fromPathname = "/") {
433
- let {
434
- pathname: toPathname,
435
- search = "",
436
- hash = ""
437
- } = typeof to === "string" ? parsePath(to) : to;
438
- let pathname;
439
- if (toPathname) {
440
- toPathname = toPathname.replace(/\/\/+/g, "/");
441
- if (toPathname.startsWith("/")) {
442
- pathname = resolvePathname(toPathname.substring(1), "/");
443
- } else {
444
- pathname = resolvePathname(toPathname, fromPathname);
445
- }
446
- } else {
447
- pathname = fromPathname;
448
- }
449
- return {
450
- pathname,
451
- search: normalizeSearch(search),
452
- hash: normalizeHash(hash)
453
- };
454
- }
455
- function resolvePathname(relativePath, fromPathname) {
456
- let segments = fromPathname.replace(/\/+$/, "").split("/");
457
- let relativeSegments = relativePath.split("/");
458
- relativeSegments.forEach((segment) => {
459
- if (segment === "..") {
460
- if (segments.length > 1) segments.pop();
461
- } else if (segment !== ".") {
462
- segments.push(segment);
463
- }
464
- });
465
- return segments.length > 1 ? segments.join("/") : "/";
466
- }
467
- function getInvalidPathError(char, field, dest, path) {
468
- return `Cannot include a '${char}' character in a manually specified \`to.${field}\` field [${JSON.stringify(
469
- path
470
- )}]. 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.`;
471
- }
472
- function getPathContributingMatches(matches) {
473
- return matches.filter(
474
- (match, index) => index === 0 || match.route.path && match.route.path.length > 0
475
- );
476
- }
477
- function getResolveToMatches(matches) {
478
- let pathMatches = getPathContributingMatches(matches);
479
- return pathMatches.map(
480
- (match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase
481
- );
482
- }
483
- function resolveTo(toArg, routePathnames, locationPathname, isPathRelative = false) {
484
- let to;
485
- if (typeof toArg === "string") {
486
- to = parsePath(toArg);
487
- } else {
488
- to = { ...toArg };
489
- invariant(
490
- !to.pathname || !to.pathname.includes("?"),
491
- getInvalidPathError("?", "pathname", "search", to)
492
- );
493
- invariant(
494
- !to.pathname || !to.pathname.includes("#"),
495
- getInvalidPathError("#", "pathname", "hash", to)
496
- );
497
- invariant(
498
- !to.search || !to.search.includes("#"),
499
- getInvalidPathError("#", "search", "hash", to)
500
- );
501
- }
502
- let isEmptyPath = toArg === "" || to.pathname === "";
503
- let toPathname = isEmptyPath ? "/" : to.pathname;
504
- let from;
505
- if (toPathname == null) {
506
- from = locationPathname;
507
- } else {
508
- let routePathnameIndex = routePathnames.length - 1;
509
- if (!isPathRelative && toPathname.startsWith("..")) {
510
- let toSegments = toPathname.split("/");
511
- while (toSegments[0] === "..") {
512
- toSegments.shift();
513
- routePathnameIndex -= 1;
514
- }
515
- to.pathname = toSegments.join("/");
516
- }
517
- from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
518
- }
519
- let path = resolvePath(to, from);
520
- let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
521
- let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
522
- if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
523
- path.pathname += "/";
524
- }
525
- return path;
526
- }
527
- var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
528
- var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
529
- var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
530
- var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
531
- var ErrorResponseImpl = class {
532
- constructor(status, statusText, data2, internal = false) {
533
- this.status = status;
534
- this.statusText = statusText || "";
535
- this.internal = internal;
536
- if (data2 instanceof Error) {
537
- this.data = data2.toString();
538
- this.error = data2;
539
- } else {
540
- this.data = data2;
541
- }
542
- }
543
- };
544
- function isRouteErrorResponse(error) {
545
- return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
546
- }
547
- function getRoutePattern(matches) {
548
- return matches.map((m) => m.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
549
- }
550
- var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
551
- function parseToInfo(_to, basename) {
552
- let to = _to;
553
- if (typeof to !== "string" || !ABSOLUTE_URL_REGEX.test(to)) {
554
- return {
555
- absoluteURL: void 0,
556
- isExternal: false,
557
- to
558
- };
559
- }
560
- let absoluteURL = to;
561
- let isExternal = false;
562
- if (isBrowser) {
563
- try {
564
- let currentUrl = new URL(window.location.href);
565
- let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
566
- let path = stripBasename(targetUrl.pathname, basename);
567
- if (targetUrl.origin === currentUrl.origin && path != null) {
568
- to = path + targetUrl.search + targetUrl.hash;
569
- } else {
570
- isExternal = true;
571
- }
572
- } catch (e) {
573
- warning(
574
- false,
575
- `<Link to="${to}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
576
- );
577
- }
578
- }
579
- return {
580
- absoluteURL,
581
- isExternal,
582
- to
583
- };
584
- }
585
- Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
586
-
587
- // lib/router/router.ts
588
- var validMutationMethodsArr = [
589
- "POST",
590
- "PUT",
591
- "PATCH",
592
- "DELETE"
593
- ];
594
- new Set(
595
- validMutationMethodsArr
596
- );
597
- var validRequestMethodsArr = [
598
- "GET",
599
- ...validMutationMethodsArr
600
- ];
601
- new Set(validRequestMethodsArr);
602
- var DataRouterContext = React3__namespace.createContext(null);
603
- DataRouterContext.displayName = "DataRouter";
604
- var DataRouterStateContext = React3__namespace.createContext(null);
605
- DataRouterStateContext.displayName = "DataRouterState";
606
- var RSCRouterContext = React3__namespace.createContext(false);
607
- var ViewTransitionContext = React3__namespace.createContext({
608
- isTransitioning: false
609
- });
610
- ViewTransitionContext.displayName = "ViewTransition";
611
- var FetchersContext = React3__namespace.createContext(
612
- /* @__PURE__ */ new Map()
613
- );
614
- FetchersContext.displayName = "Fetchers";
615
- var AwaitContext = React3__namespace.createContext(null);
616
- AwaitContext.displayName = "Await";
617
- var NavigationContext = React3__namespace.createContext(
618
- null
619
- );
620
- NavigationContext.displayName = "Navigation";
621
- var LocationContext = React3__namespace.createContext(
622
- null
623
- );
624
- LocationContext.displayName = "Location";
625
- var RouteContext = React3__namespace.createContext({
626
- outlet: null,
627
- matches: [],
628
- isDataRoute: false
629
- });
630
- RouteContext.displayName = "Route";
631
- var RouteErrorContext = React3__namespace.createContext(null);
632
- RouteErrorContext.displayName = "RouteError";
633
-
634
- // lib/errors.ts
635
- var ERROR_DIGEST_BASE = "REACT_ROUTER_ERROR";
636
- var ERROR_DIGEST_REDIRECT = "REDIRECT";
637
- var ERROR_DIGEST_ROUTE_ERROR_RESPONSE = "ROUTE_ERROR_RESPONSE";
638
- function decodeRedirectErrorDigest(digest) {
639
- if (digest.startsWith(`${ERROR_DIGEST_BASE}:${ERROR_DIGEST_REDIRECT}:{`)) {
640
- try {
641
- let parsed = JSON.parse(digest.slice(28));
642
- if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string" && typeof parsed.location === "string" && typeof parsed.reloadDocument === "boolean" && typeof parsed.replace === "boolean") {
643
- return parsed;
644
- }
645
- } catch {
646
- }
647
- }
648
- }
649
- function decodeRouteErrorResponseDigest(digest) {
650
- if (digest.startsWith(
651
- `${ERROR_DIGEST_BASE}:${ERROR_DIGEST_ROUTE_ERROR_RESPONSE}:{`
652
- )) {
653
- try {
654
- let parsed = JSON.parse(digest.slice(40));
655
- if (typeof parsed === "object" && parsed && typeof parsed.status === "number" && typeof parsed.statusText === "string") {
656
- return new ErrorResponseImpl(
657
- parsed.status,
658
- parsed.statusText,
659
- parsed.data
660
- );
661
- }
662
- } catch {
663
- }
664
- }
665
- }
666
-
667
- // lib/hooks.tsx
668
- function useHref(to, { relative } = {}) {
669
- invariant(
670
- useInRouterContext(),
671
- // TODO: This error is probably because they somehow have 2 versions of the
672
- // router loaded. We can help them understand how to avoid that.
673
- `useHref() may be used only in the context of a <Router> component.`
674
- );
675
- let { basename, navigator } = React3__namespace.useContext(NavigationContext);
676
- let { hash, pathname, search } = useResolvedPath(to, { relative });
677
- let joinedPathname = pathname;
678
- if (basename !== "/") {
679
- joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
680
- }
681
- return navigator.createHref({ pathname: joinedPathname, search, hash });
682
- }
683
- function useInRouterContext() {
684
- return React3__namespace.useContext(LocationContext) != null;
685
- }
686
- function useLocation() {
687
- invariant(
688
- useInRouterContext(),
689
- // TODO: This error is probably because they somehow have 2 versions of the
690
- // router loaded. We can help them understand how to avoid that.
691
- `useLocation() may be used only in the context of a <Router> component.`
692
- );
693
- return React3__namespace.useContext(LocationContext).location;
694
- }
695
- var navigateEffectWarning = `You should call navigate() in a React.useEffect(), not when your component is first rendered.`;
696
- function useIsomorphicLayoutEffect(cb) {
697
- let isStatic = React3__namespace.useContext(NavigationContext).static;
698
- if (!isStatic) {
699
- React3__namespace.useLayoutEffect(cb);
700
- }
701
- }
702
- function useNavigate() {
703
- let { isDataRoute } = React3__namespace.useContext(RouteContext);
704
- return isDataRoute ? useNavigateStable() : useNavigateUnstable();
705
- }
706
- function useNavigateUnstable() {
707
- invariant(
708
- useInRouterContext(),
709
- // TODO: This error is probably because they somehow have 2 versions of the
710
- // router loaded. We can help them understand how to avoid that.
711
- `useNavigate() may be used only in the context of a <Router> component.`
712
- );
713
- let dataRouterContext = React3__namespace.useContext(DataRouterContext);
714
- let { basename, navigator } = React3__namespace.useContext(NavigationContext);
715
- let { matches } = React3__namespace.useContext(RouteContext);
716
- let { pathname: locationPathname } = useLocation();
717
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
718
- let activeRef = React3__namespace.useRef(false);
719
- useIsomorphicLayoutEffect(() => {
720
- activeRef.current = true;
721
- });
722
- let navigate = React3__namespace.useCallback(
723
- (to, options = {}) => {
724
- warning(activeRef.current, navigateEffectWarning);
725
- if (!activeRef.current) return;
726
- if (typeof to === "number") {
727
- navigator.go(to);
728
- return;
729
- }
730
- let path = resolveTo(
731
- to,
732
- JSON.parse(routePathnamesJson),
733
- locationPathname,
734
- options.relative === "path"
735
- );
736
- if (dataRouterContext == null && basename !== "/") {
737
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
738
- }
739
- (!!options.replace ? navigator.replace : navigator.push)(
740
- path,
741
- options.state,
742
- options
743
- );
744
- },
745
- [
746
- basename,
747
- navigator,
748
- routePathnamesJson,
749
- locationPathname,
750
- dataRouterContext
751
- ]
752
- );
753
- return navigate;
754
- }
755
- React3__namespace.createContext(null);
756
- function useResolvedPath(to, { relative } = {}) {
757
- let { matches } = React3__namespace.useContext(RouteContext);
758
- let { pathname: locationPathname } = useLocation();
759
- let routePathnamesJson = JSON.stringify(getResolveToMatches(matches));
760
- return React3__namespace.useMemo(
761
- () => resolveTo(
762
- to,
763
- JSON.parse(routePathnamesJson),
764
- locationPathname,
765
- relative === "path"
766
- ),
767
- [to, routePathnamesJson, locationPathname, relative]
768
- );
769
- }
770
- function useRoutesImpl(routes, locationArg, dataRouterOpts) {
771
- invariant(
772
- useInRouterContext(),
773
- // TODO: This error is probably because they somehow have 2 versions of the
774
- // router loaded. We can help them understand how to avoid that.
775
- `useRoutes() may be used only in the context of a <Router> component.`
776
- );
777
- let { navigator } = React3__namespace.useContext(NavigationContext);
778
- let { matches: parentMatches } = React3__namespace.useContext(RouteContext);
779
- let routeMatch = parentMatches[parentMatches.length - 1];
780
- let parentParams = routeMatch ? routeMatch.params : {};
781
- let parentPathname = routeMatch ? routeMatch.pathname : "/";
782
- let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
783
- let parentRoute = routeMatch && routeMatch.route;
784
- {
785
- let parentPath = parentRoute && parentRoute.path || "";
786
- warningOnce(
787
- parentPathname,
788
- !parentRoute || parentPath.endsWith("*") || parentPath.endsWith("*?"),
789
- `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.
790
-
791
- Please change the parent <Route path="${parentPath}"> to <Route path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`
792
- );
793
- }
794
- let locationFromContext = useLocation();
795
- let location;
796
- {
797
- location = locationFromContext;
798
- }
799
- let pathname = location.pathname || "/";
800
- let remainingPathname = pathname;
801
- if (parentPathnameBase !== "/") {
802
- let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
803
- let segments = pathname.replace(/^\//, "").split("/");
804
- remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
805
- }
806
- let matches = matchRoutes(routes, { pathname: remainingPathname });
807
- {
808
- warning(
809
- parentRoute || matches != null,
810
- `No routes matched location "${location.pathname}${location.search}${location.hash}" `
811
- );
812
- warning(
813
- 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,
814
- `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.`
815
- );
816
- }
817
- let renderedMatches = _renderMatches(
818
- matches && matches.map(
819
- (match) => Object.assign({}, match, {
820
- params: Object.assign({}, parentParams, match.params),
821
- pathname: joinPaths([
822
- parentPathnameBase,
823
- // Re-encode pathnames that were decoded inside matchRoutes.
824
- // Pre-encode `%`, `?` and `#` ahead of `encodeLocation` because it uses
825
- // `new URL()` internally and we need to prevent it from treating
826
- // them as separators
827
- navigator.encodeLocation ? navigator.encodeLocation(
828
- match.pathname.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")
829
- ).pathname : match.pathname
830
- ]),
831
- pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
832
- parentPathnameBase,
833
- // Re-encode pathnames that were decoded inside matchRoutes
834
- // Pre-encode `%`, `?` and `#` ahead of `encodeLocation` because it uses
835
- // `new URL()` internally and we need to prevent it from treating
836
- // them as separators
837
- navigator.encodeLocation ? navigator.encodeLocation(
838
- match.pathnameBase.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")
839
- ).pathname : match.pathnameBase
840
- ])
841
- })
842
- ),
843
- parentMatches,
844
- dataRouterOpts
845
- );
846
- return renderedMatches;
847
- }
848
- function DefaultErrorComponent() {
849
- let error = useRouteError();
850
- let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
851
- let stack = error instanceof Error ? error.stack : null;
852
- let lightgrey = "rgba(200,200,200, 0.5)";
853
- let preStyles = { padding: "0.5rem", backgroundColor: lightgrey };
854
- let codeStyles = { padding: "2px 4px", backgroundColor: lightgrey };
855
- let devInfo = null;
856
- {
857
- console.error(
858
- "Error handled by React Router default ErrorBoundary:",
859
- error
860
- );
861
- devInfo = /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement("p", null, "\u{1F4BF} Hey developer \u{1F44B}"), /* @__PURE__ */ React3__namespace.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React3__namespace.createElement("code", { style: codeStyles }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React3__namespace.createElement("code", { style: codeStyles }, "errorElement"), " prop on your route."));
862
- }
863
- return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, /* @__PURE__ */ React3__namespace.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React3__namespace.createElement("h3", { style: { fontStyle: "italic" } }, message), stack ? /* @__PURE__ */ React3__namespace.createElement("pre", { style: preStyles }, stack) : null, devInfo);
864
- }
865
- var defaultErrorElement = /* @__PURE__ */ React3__namespace.createElement(DefaultErrorComponent, null);
866
- var RenderErrorBoundary = class extends React3__namespace.Component {
867
- constructor(props) {
868
- super(props);
869
- this.state = {
870
- location: props.location,
871
- revalidation: props.revalidation,
872
- error: props.error
873
- };
874
- }
875
- static getDerivedStateFromError(error) {
876
- return { error };
877
- }
878
- static getDerivedStateFromProps(props, state) {
879
- if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
880
- return {
881
- error: props.error,
882
- location: props.location,
883
- revalidation: props.revalidation
884
- };
885
- }
886
- return {
887
- error: props.error !== void 0 ? props.error : state.error,
888
- location: state.location,
889
- revalidation: props.revalidation || state.revalidation
890
- };
891
- }
892
- componentDidCatch(error, errorInfo) {
893
- if (this.props.onError) {
894
- this.props.onError(error, errorInfo);
895
- } else {
896
- console.error(
897
- "React Router caught the following error during render",
898
- error
899
- );
900
- }
901
- }
902
- render() {
903
- let error = this.state.error;
904
- if (this.context && typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
905
- const decoded = decodeRouteErrorResponseDigest(error.digest);
906
- if (decoded) error = decoded;
907
- }
908
- let result = error !== void 0 ? /* @__PURE__ */ React3__namespace.createElement(RouteContext.Provider, { value: this.props.routeContext }, /* @__PURE__ */ React3__namespace.createElement(
909
- RouteErrorContext.Provider,
910
- {
911
- value: error,
912
- children: this.props.component
913
- }
914
- )) : this.props.children;
915
- if (this.context) {
916
- return /* @__PURE__ */ React3__namespace.createElement(RSCErrorHandler, { error }, result);
917
- }
918
- return result;
919
- }
920
- };
921
- RenderErrorBoundary.contextType = RSCRouterContext;
922
- var errorRedirectHandledMap = /* @__PURE__ */ new WeakMap();
923
- function RSCErrorHandler({
924
- children,
925
- error
926
- }) {
927
- let { basename } = React3__namespace.useContext(NavigationContext);
928
- if (typeof error === "object" && error && "digest" in error && typeof error.digest === "string") {
929
- let redirect2 = decodeRedirectErrorDigest(error.digest);
930
- if (redirect2) {
931
- let existingRedirect = errorRedirectHandledMap.get(error);
932
- if (existingRedirect) throw existingRedirect;
933
- let parsed = parseToInfo(redirect2.location, basename);
934
- if (isBrowser && !errorRedirectHandledMap.get(error)) {
935
- if (parsed.isExternal || redirect2.reloadDocument) {
936
- window.location.href = parsed.absoluteURL || parsed.to;
937
- } else {
938
- const redirectPromise = Promise.resolve().then(
939
- () => window.__reactRouterDataRouter.navigate(parsed.to, {
940
- replace: redirect2.replace
941
- })
942
- );
943
- errorRedirectHandledMap.set(error, redirectPromise);
944
- throw redirectPromise;
945
- }
946
- }
947
- return /* @__PURE__ */ React3__namespace.createElement(
948
- "meta",
949
- {
950
- httpEquiv: "refresh",
951
- content: `0;url=${parsed.absoluteURL || parsed.to}`
952
- }
953
- );
954
- }
955
- }
956
- return children;
957
- }
958
- function RenderedRoute({ routeContext, match, children }) {
959
- let dataRouterContext = React3__namespace.useContext(DataRouterContext);
960
- if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
961
- dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
962
- }
963
- return /* @__PURE__ */ React3__namespace.createElement(RouteContext.Provider, { value: routeContext }, children);
964
- }
965
- function _renderMatches(matches, parentMatches = [], dataRouterOpts) {
966
- let dataRouterState = dataRouterOpts?.state;
967
- if (matches == null) {
968
- if (!dataRouterState) {
969
- return null;
970
- }
971
- if (dataRouterState.errors) {
972
- matches = dataRouterState.matches;
973
- } else if (parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
974
- matches = dataRouterState.matches;
975
- } else {
976
- return null;
977
- }
978
- }
979
- let renderedMatches = matches;
980
- let errors = dataRouterState?.errors;
981
- if (errors != null) {
982
- let errorIndex = renderedMatches.findIndex(
983
- (m) => m.route.id && errors?.[m.route.id] !== void 0
984
- );
985
- invariant(
986
- errorIndex >= 0,
987
- `Could not find a matching route for errors on route IDs: ${Object.keys(
988
- errors
989
- ).join(",")}`
990
- );
991
- renderedMatches = renderedMatches.slice(
992
- 0,
993
- Math.min(renderedMatches.length, errorIndex + 1)
994
- );
995
- }
996
- let renderFallback = false;
997
- let fallbackIndex = -1;
998
- if (dataRouterOpts && dataRouterState) {
999
- renderFallback = dataRouterState.renderFallback;
1000
- for (let i = 0; i < renderedMatches.length; i++) {
1001
- let match = renderedMatches[i];
1002
- if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
1003
- fallbackIndex = i;
1004
- }
1005
- if (match.route.id) {
1006
- let { loaderData, errors: errors2 } = dataRouterState;
1007
- let needsToRunLoader = match.route.loader && !loaderData.hasOwnProperty(match.route.id) && (!errors2 || errors2[match.route.id] === void 0);
1008
- if (match.route.lazy || needsToRunLoader) {
1009
- if (dataRouterOpts.isStatic) {
1010
- renderFallback = true;
1011
- }
1012
- if (fallbackIndex >= 0) {
1013
- renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
1014
- } else {
1015
- renderedMatches = [renderedMatches[0]];
1016
- }
1017
- break;
1018
- }
1019
- }
1020
- }
1021
- }
1022
- let onErrorHandler = dataRouterOpts?.onError;
1023
- let onError = dataRouterState && onErrorHandler ? (error, errorInfo) => {
1024
- onErrorHandler(error, {
1025
- location: dataRouterState.location,
1026
- params: dataRouterState.matches?.[0]?.params ?? {},
1027
- unstable_pattern: getRoutePattern(dataRouterState.matches),
1028
- errorInfo
1029
- });
1030
- } : void 0;
1031
- return renderedMatches.reduceRight(
1032
- (outlet, match, index) => {
1033
- let error;
1034
- let shouldRenderHydrateFallback = false;
1035
- let errorElement = null;
1036
- let hydrateFallbackElement = null;
1037
- if (dataRouterState) {
1038
- error = errors && match.route.id ? errors[match.route.id] : void 0;
1039
- errorElement = match.route.errorElement || defaultErrorElement;
1040
- if (renderFallback) {
1041
- if (fallbackIndex < 0 && index === 0) {
1042
- warningOnce(
1043
- "route-fallback",
1044
- false,
1045
- "No `HydrateFallback` element provided to render during initial hydration"
1046
- );
1047
- shouldRenderHydrateFallback = true;
1048
- hydrateFallbackElement = null;
1049
- } else if (fallbackIndex === index) {
1050
- shouldRenderHydrateFallback = true;
1051
- hydrateFallbackElement = match.route.hydrateFallbackElement || null;
1052
- }
1053
- }
1054
- }
1055
- let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
1056
- let getChildren = () => {
1057
- let children;
1058
- if (error) {
1059
- children = errorElement;
1060
- } else if (shouldRenderHydrateFallback) {
1061
- children = hydrateFallbackElement;
1062
- } else if (match.route.Component) {
1063
- children = /* @__PURE__ */ React3__namespace.createElement(match.route.Component, null);
1064
- } else if (match.route.element) {
1065
- children = match.route.element;
1066
- } else {
1067
- children = outlet;
1068
- }
1069
- return /* @__PURE__ */ React3__namespace.createElement(
1070
- RenderedRoute,
1071
- {
1072
- match,
1073
- routeContext: {
1074
- outlet,
1075
- matches: matches2,
1076
- isDataRoute: dataRouterState != null
1077
- },
1078
- children
1079
- }
1080
- );
1081
- };
1082
- return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React3__namespace.createElement(
1083
- RenderErrorBoundary,
1084
- {
1085
- location: dataRouterState.location,
1086
- revalidation: dataRouterState.revalidation,
1087
- component: errorElement,
1088
- error,
1089
- children: getChildren(),
1090
- routeContext: { outlet: null, matches: matches2, isDataRoute: true },
1091
- onError
1092
- }
1093
- ) : getChildren();
1094
- },
1095
- null
1096
- );
1097
- }
1098
- function getDataRouterConsoleError(hookName) {
1099
- return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
1100
- }
1101
- function useDataRouterContext(hookName) {
1102
- let ctx = React3__namespace.useContext(DataRouterContext);
1103
- invariant(ctx, getDataRouterConsoleError(hookName));
1104
- return ctx;
1105
- }
1106
- function useDataRouterState(hookName) {
1107
- let state = React3__namespace.useContext(DataRouterStateContext);
1108
- invariant(state, getDataRouterConsoleError(hookName));
1109
- return state;
1110
- }
1111
- function useRouteContext(hookName) {
1112
- let route = React3__namespace.useContext(RouteContext);
1113
- invariant(route, getDataRouterConsoleError(hookName));
1114
- return route;
1115
- }
1116
- function useCurrentRouteId(hookName) {
1117
- let route = useRouteContext(hookName);
1118
- let thisRoute = route.matches[route.matches.length - 1];
1119
- invariant(
1120
- thisRoute.route.id,
1121
- `${hookName} can only be used on routes that contain a unique "id"`
1122
- );
1123
- return thisRoute.route.id;
1124
- }
1125
- function useRouteId() {
1126
- return useCurrentRouteId("useRouteId" /* UseRouteId */);
1127
- }
1128
- function useRouteError() {
1129
- let error = React3__namespace.useContext(RouteErrorContext);
1130
- let state = useDataRouterState("useRouteError" /* UseRouteError */);
1131
- let routeId = useCurrentRouteId("useRouteError" /* UseRouteError */);
1132
- if (error !== void 0) {
1133
- return error;
1134
- }
1135
- return state.errors?.[routeId];
1136
- }
1137
- function useNavigateStable() {
1138
- let { router } = useDataRouterContext("useNavigate" /* UseNavigateStable */);
1139
- let id = useCurrentRouteId("useNavigate" /* UseNavigateStable */);
1140
- let activeRef = React3__namespace.useRef(false);
1141
- useIsomorphicLayoutEffect(() => {
1142
- activeRef.current = true;
1143
- });
1144
- let navigate = React3__namespace.useCallback(
1145
- async (to, options = {}) => {
1146
- warning(activeRef.current, navigateEffectWarning);
1147
- if (!activeRef.current) return;
1148
- if (typeof to === "number") {
1149
- await router.navigate(to);
1150
- } else {
1151
- await router.navigate(to, { fromRouteId: id, ...options });
1152
- }
1153
- },
1154
- [router, id]
1155
- );
1156
- return navigate;
1157
- }
1158
- var alreadyWarned = {};
1159
- function warningOnce(key, cond, message) {
1160
- if (!cond && !alreadyWarned[key]) {
1161
- alreadyWarned[key] = true;
1162
- warning(false, message);
1163
- }
1164
- }
1165
- React3__namespace.memo(DataRoutes);
1166
- function DataRoutes({
1167
- routes,
1168
- future,
1169
- state,
1170
- isStatic,
1171
- onError
1172
- }) {
1173
- return useRoutesImpl(routes, void 0, { state, isStatic, onError});
1174
- }
1175
-
1176
- // lib/dom/dom.ts
1177
- var defaultMethod = "get";
1178
- var defaultEncType = "application/x-www-form-urlencoded";
1179
- function isHtmlElement(object) {
1180
- return typeof HTMLElement !== "undefined" && object instanceof HTMLElement;
1181
- }
1182
- function isButtonElement(object) {
1183
- return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
1184
- }
1185
- function isFormElement(object) {
1186
- return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
1187
- }
1188
- function isInputElement(object) {
1189
- return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
1190
- }
1191
- function isModifiedEvent(event) {
1192
- return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
1193
- }
1194
- function shouldProcessLinkClick(event, target) {
1195
- return event.button === 0 && // Ignore everything but left clicks
1196
- (!target || target === "_self") && // Let browser handle "target=_blank" etc.
1197
- !isModifiedEvent(event);
1198
- }
1199
- var _formDataSupportsSubmitter = null;
1200
- function isFormDataSubmitterSupported() {
1201
- if (_formDataSupportsSubmitter === null) {
1202
- try {
1203
- new FormData(
1204
- document.createElement("form"),
1205
- // @ts-expect-error if FormData supports the submitter parameter, this will throw
1206
- 0
1207
- );
1208
- _formDataSupportsSubmitter = false;
1209
- } catch (e) {
1210
- _formDataSupportsSubmitter = true;
1211
- }
1212
- }
1213
- return _formDataSupportsSubmitter;
1214
- }
1215
- var supportedFormEncTypes = /* @__PURE__ */ new Set([
1216
- "application/x-www-form-urlencoded",
1217
- "multipart/form-data",
1218
- "text/plain"
1219
- ]);
1220
- function getFormEncType(encType) {
1221
- if (encType != null && !supportedFormEncTypes.has(encType)) {
1222
- warning(
1223
- false,
1224
- `"${encType}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${defaultEncType}"`
1225
- );
1226
- return null;
1227
- }
1228
- return encType;
1229
- }
1230
- function getFormSubmissionInfo(target, basename) {
1231
- let method;
1232
- let action;
1233
- let encType;
1234
- let formData;
1235
- let body;
1236
- if (isFormElement(target)) {
1237
- let attr = target.getAttribute("action");
1238
- action = attr ? stripBasename(attr, basename) : null;
1239
- method = target.getAttribute("method") || defaultMethod;
1240
- encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
1241
- formData = new FormData(target);
1242
- } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
1243
- let form = target.form;
1244
- if (form == null) {
1245
- throw new Error(
1246
- `Cannot submit a <button> or <input type="submit"> without a <form>`
1247
- );
1248
- }
1249
- let attr = target.getAttribute("formaction") || form.getAttribute("action");
1250
- action = attr ? stripBasename(attr, basename) : null;
1251
- method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
1252
- encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
1253
- formData = new FormData(form, target);
1254
- if (!isFormDataSubmitterSupported()) {
1255
- let { name, type, value } = target;
1256
- if (type === "image") {
1257
- let prefix = name ? `${name}.` : "";
1258
- formData.append(`${prefix}x`, "0");
1259
- formData.append(`${prefix}y`, "0");
1260
- } else if (name) {
1261
- formData.append(name, value);
1262
- }
1263
- }
1264
- } else if (isHtmlElement(target)) {
1265
- throw new Error(
1266
- `Cannot submit element that is not <form>, <button>, or <input type="submit|image">`
1267
- );
1268
- } else {
1269
- method = defaultMethod;
1270
- action = null;
1271
- encType = defaultEncType;
1272
- body = target;
1273
- }
1274
- if (formData && encType === "text/plain") {
1275
- body = formData;
1276
- formData = void 0;
1277
- }
1278
- return { action, method: method.toLowerCase(), encType, formData, body };
1279
- }
1280
- Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
1281
-
1282
- // lib/dom/ssr/invariant.ts
1283
- function invariant2(value, message) {
1284
- if (value === false || value === null || typeof value === "undefined") {
1285
- throw new Error(message);
1286
- }
1287
- }
1288
- function singleFetchUrl(reqUrl, basename, trailingSlashAware, extension) {
1289
- let url = typeof reqUrl === "string" ? new URL(
1290
- reqUrl,
1291
- // This can be called during the SSR flow via PrefetchPageLinksImpl so
1292
- // don't assume window is available
1293
- typeof window === "undefined" ? "server://singlefetch/" : window.location.origin
1294
- ) : reqUrl;
1295
- if (trailingSlashAware) {
1296
- if (url.pathname.endsWith("/")) {
1297
- url.pathname = `${url.pathname}_.${extension}`;
1298
- } else {
1299
- url.pathname = `${url.pathname}.${extension}`;
1300
- }
1301
- } else {
1302
- if (url.pathname === "/") {
1303
- url.pathname = `_root.${extension}`;
1304
- } else if (basename && stripBasename(url.pathname, basename) === "/") {
1305
- url.pathname = `${basename.replace(/\/$/, "")}/_root.${extension}`;
1306
- } else {
1307
- url.pathname = `${url.pathname.replace(/\/$/, "")}.${extension}`;
1308
- }
1309
- }
1310
- return url;
1311
- }
1312
-
1313
- // lib/dom/ssr/routeModules.ts
1314
- async function loadRouteModule(route, routeModulesCache) {
1315
- if (route.id in routeModulesCache) {
1316
- return routeModulesCache[route.id];
1317
- }
1318
- try {
1319
- let routeModule = await import(
1320
- /* @vite-ignore */
1321
- /* webpackIgnore: true */
1322
- route.module
1323
- );
1324
- routeModulesCache[route.id] = routeModule;
1325
- return routeModule;
1326
- } catch (error) {
1327
- console.error(
1328
- `Error loading route module \`${route.module}\`, reloading page...`
1329
- );
1330
- console.error(error);
1331
- if (window.__reactRouterContext && window.__reactRouterContext.isSpaMode && // @ts-expect-error
1332
- undefined) {
1333
- throw error;
1334
- }
1335
- window.location.reload();
1336
- return new Promise(() => {
1337
- });
1338
- }
1339
- }
1340
- function isHtmlLinkDescriptor(object) {
1341
- if (object == null) {
1342
- return false;
1343
- }
1344
- if (object.href == null) {
1345
- return object.rel === "preload" && typeof object.imageSrcSet === "string" && typeof object.imageSizes === "string";
1346
- }
1347
- return typeof object.rel === "string" && typeof object.href === "string";
1348
- }
1349
- async function getKeyedPrefetchLinks(matches, manifest, routeModules) {
1350
- let links = await Promise.all(
1351
- matches.map(async (match) => {
1352
- let route = manifest.routes[match.route.id];
1353
- if (route) {
1354
- let mod = await loadRouteModule(route, routeModules);
1355
- return mod.links ? mod.links() : [];
1356
- }
1357
- return [];
1358
- })
1359
- );
1360
- return dedupeLinkDescriptors(
1361
- links.flat(1).filter(isHtmlLinkDescriptor).filter((link) => link.rel === "stylesheet" || link.rel === "preload").map(
1362
- (link) => link.rel === "stylesheet" ? { ...link, rel: "prefetch", as: "style" } : { ...link, rel: "prefetch" }
1363
- )
1364
- );
1365
- }
1366
- function getNewMatchesForLinks(page, nextMatches, currentMatches, manifest, location, mode) {
1367
- let isNew = (match, index) => {
1368
- if (!currentMatches[index]) return true;
1369
- return match.route.id !== currentMatches[index].route.id;
1370
- };
1371
- let matchPathChanged = (match, index) => {
1372
- return (
1373
- // param change, /users/123 -> /users/456
1374
- currentMatches[index].pathname !== match.pathname || // splat param changed, which is not present in match.path
1375
- // e.g. /files/images/avatar.jpg -> files/finances.xls
1376
- currentMatches[index].route.path?.endsWith("*") && currentMatches[index].params["*"] !== match.params["*"]
1377
- );
1378
- };
1379
- if (mode === "assets") {
1380
- return nextMatches.filter(
1381
- (match, index) => isNew(match, index) || matchPathChanged(match, index)
1382
- );
1383
- }
1384
- if (mode === "data") {
1385
- return nextMatches.filter((match, index) => {
1386
- let manifestRoute = manifest.routes[match.route.id];
1387
- if (!manifestRoute || !manifestRoute.hasLoader) {
1388
- return false;
1389
- }
1390
- if (isNew(match, index) || matchPathChanged(match, index)) {
1391
- return true;
1392
- }
1393
- if (match.route.shouldRevalidate) {
1394
- let routeChoice = match.route.shouldRevalidate({
1395
- currentUrl: new URL(
1396
- location.pathname + location.search + location.hash,
1397
- window.origin
1398
- ),
1399
- currentParams: currentMatches[0]?.params || {},
1400
- nextUrl: new URL(page, window.origin),
1401
- nextParams: match.params,
1402
- defaultShouldRevalidate: true
1403
- });
1404
- if (typeof routeChoice === "boolean") {
1405
- return routeChoice;
1406
- }
1407
- }
1408
- return true;
1409
- });
1410
- }
1411
- return [];
1412
- }
1413
- function getModuleLinkHrefs(matches, manifest, { includeHydrateFallback } = {}) {
1414
- return dedupeHrefs(
1415
- matches.map((match) => {
1416
- let route = manifest.routes[match.route.id];
1417
- if (!route) return [];
1418
- let hrefs = [route.module];
1419
- if (route.clientActionModule) {
1420
- hrefs = hrefs.concat(route.clientActionModule);
1421
- }
1422
- if (route.clientLoaderModule) {
1423
- hrefs = hrefs.concat(route.clientLoaderModule);
1424
- }
1425
- if (includeHydrateFallback && route.hydrateFallbackModule) {
1426
- hrefs = hrefs.concat(route.hydrateFallbackModule);
1427
- }
1428
- if (route.imports) {
1429
- hrefs = hrefs.concat(route.imports);
1430
- }
1431
- return hrefs;
1432
- }).flat(1)
1433
- );
1434
- }
1435
- function dedupeHrefs(hrefs) {
1436
- return [...new Set(hrefs)];
1437
- }
1438
- function sortKeys(obj) {
1439
- let sorted = {};
1440
- let keys = Object.keys(obj).sort();
1441
- for (let key of keys) {
1442
- sorted[key] = obj[key];
1443
- }
1444
- return sorted;
1445
- }
1446
- function dedupeLinkDescriptors(descriptors, preloads) {
1447
- let set = /* @__PURE__ */ new Set();
1448
- new Set(preloads);
1449
- return descriptors.reduce((deduped, descriptor) => {
1450
- let key = JSON.stringify(sortKeys(descriptor));
1451
- if (!set.has(key)) {
1452
- set.add(key);
1453
- deduped.push({ key, link: descriptor });
1454
- }
1455
- return deduped;
1456
- }, []);
1457
- }
1458
-
1459
- // lib/dom/ssr/components.tsx
1460
- function useDataRouterContext2() {
1461
- let context = React3__namespace.useContext(DataRouterContext);
1462
- invariant2(
1463
- context,
1464
- "You must render this element inside a <DataRouterContext.Provider> element"
1465
- );
1466
- return context;
1467
- }
1468
- function useDataRouterStateContext() {
1469
- let context = React3__namespace.useContext(DataRouterStateContext);
1470
- invariant2(
1471
- context,
1472
- "You must render this element inside a <DataRouterStateContext.Provider> element"
1473
- );
1474
- return context;
1475
- }
1476
- var FrameworkContext = React3__namespace.createContext(void 0);
1477
- FrameworkContext.displayName = "FrameworkContext";
1478
- function useFrameworkContext() {
1479
- let context = React3__namespace.useContext(FrameworkContext);
1480
- invariant2(
1481
- context,
1482
- "You must render this element inside a <HydratedRouter> element"
1483
- );
1484
- return context;
1485
- }
1486
- function usePrefetchBehavior(prefetch, theirElementProps) {
1487
- let frameworkContext = React3__namespace.useContext(FrameworkContext);
1488
- let [maybePrefetch, setMaybePrefetch] = React3__namespace.useState(false);
1489
- let [shouldPrefetch, setShouldPrefetch] = React3__namespace.useState(false);
1490
- let { onFocus, onBlur, onMouseEnter, onMouseLeave, onTouchStart } = theirElementProps;
1491
- let ref = React3__namespace.useRef(null);
1492
- React3__namespace.useEffect(() => {
1493
- if (prefetch === "render") {
1494
- setShouldPrefetch(true);
1495
- }
1496
- if (prefetch === "viewport") {
1497
- let callback = (entries) => {
1498
- entries.forEach((entry) => {
1499
- setShouldPrefetch(entry.isIntersecting);
1500
- });
1501
- };
1502
- let observer = new IntersectionObserver(callback, { threshold: 0.5 });
1503
- if (ref.current) observer.observe(ref.current);
1504
- return () => {
1505
- observer.disconnect();
1506
- };
1507
- }
1508
- }, [prefetch]);
1509
- React3__namespace.useEffect(() => {
1510
- if (maybePrefetch) {
1511
- let id = setTimeout(() => {
1512
- setShouldPrefetch(true);
1513
- }, 100);
1514
- return () => {
1515
- clearTimeout(id);
1516
- };
1517
- }
1518
- }, [maybePrefetch]);
1519
- let setIntent = () => {
1520
- setMaybePrefetch(true);
1521
- };
1522
- let cancelIntent = () => {
1523
- setMaybePrefetch(false);
1524
- setShouldPrefetch(false);
1525
- };
1526
- if (!frameworkContext) {
1527
- return [false, ref, {}];
1528
- }
1529
- if (prefetch !== "intent") {
1530
- return [shouldPrefetch, ref, {}];
1531
- }
1532
- return [
1533
- shouldPrefetch,
1534
- ref,
1535
- {
1536
- onFocus: composeEventHandlers(onFocus, setIntent),
1537
- onBlur: composeEventHandlers(onBlur, cancelIntent),
1538
- onMouseEnter: composeEventHandlers(onMouseEnter, setIntent),
1539
- onMouseLeave: composeEventHandlers(onMouseLeave, cancelIntent),
1540
- onTouchStart: composeEventHandlers(onTouchStart, setIntent)
1541
- }
1542
- ];
1543
- }
1544
- function composeEventHandlers(theirHandler, ourHandler) {
1545
- return (event) => {
1546
- theirHandler && theirHandler(event);
1547
- if (!event.defaultPrevented) {
1548
- ourHandler(event);
1549
- }
1550
- };
1551
- }
1552
- function PrefetchPageLinks({ page, ...linkProps }) {
1553
- let { router } = useDataRouterContext2();
1554
- let matches = React3__namespace.useMemo(
1555
- () => matchRoutes(router.routes, page, router.basename),
1556
- [router.routes, page, router.basename]
1557
- );
1558
- if (!matches) {
1559
- return null;
1560
- }
1561
- return /* @__PURE__ */ React3__namespace.createElement(PrefetchPageLinksImpl, { page, matches, ...linkProps });
1562
- }
1563
- function useKeyedPrefetchLinks(matches) {
1564
- let { manifest, routeModules } = useFrameworkContext();
1565
- let [keyedPrefetchLinks, setKeyedPrefetchLinks] = React3__namespace.useState([]);
1566
- React3__namespace.useEffect(() => {
1567
- let interrupted = false;
1568
- void getKeyedPrefetchLinks(matches, manifest, routeModules).then(
1569
- (links) => {
1570
- if (!interrupted) {
1571
- setKeyedPrefetchLinks(links);
1572
- }
1573
- }
1574
- );
1575
- return () => {
1576
- interrupted = true;
1577
- };
1578
- }, [matches, manifest, routeModules]);
1579
- return keyedPrefetchLinks;
1580
- }
1581
- function PrefetchPageLinksImpl({
1582
- page,
1583
- matches: nextMatches,
1584
- ...linkProps
1585
- }) {
1586
- let location = useLocation();
1587
- let { future, manifest, routeModules } = useFrameworkContext();
1588
- let { basename } = useDataRouterContext2();
1589
- let { loaderData, matches } = useDataRouterStateContext();
1590
- let newMatchesForData = React3__namespace.useMemo(
1591
- () => getNewMatchesForLinks(
1592
- page,
1593
- nextMatches,
1594
- matches,
1595
- manifest,
1596
- location,
1597
- "data"
1598
- ),
1599
- [page, nextMatches, matches, manifest, location]
1600
- );
1601
- let newMatchesForAssets = React3__namespace.useMemo(
1602
- () => getNewMatchesForLinks(
1603
- page,
1604
- nextMatches,
1605
- matches,
1606
- manifest,
1607
- location,
1608
- "assets"
1609
- ),
1610
- [page, nextMatches, matches, manifest, location]
1611
- );
1612
- let dataHrefs = React3__namespace.useMemo(() => {
1613
- if (page === location.pathname + location.search + location.hash) {
1614
- return [];
1615
- }
1616
- let routesParams = /* @__PURE__ */ new Set();
1617
- let foundOptOutRoute = false;
1618
- nextMatches.forEach((m) => {
1619
- let manifestRoute = manifest.routes[m.route.id];
1620
- if (!manifestRoute || !manifestRoute.hasLoader) {
1621
- return;
1622
- }
1623
- if (!newMatchesForData.some((m2) => m2.route.id === m.route.id) && m.route.id in loaderData && routeModules[m.route.id]?.shouldRevalidate) {
1624
- foundOptOutRoute = true;
1625
- } else if (manifestRoute.hasClientLoader) {
1626
- foundOptOutRoute = true;
1627
- } else {
1628
- routesParams.add(m.route.id);
1629
- }
1630
- });
1631
- if (routesParams.size === 0) {
1632
- return [];
1633
- }
1634
- let url = singleFetchUrl(
1635
- page,
1636
- basename,
1637
- future.unstable_trailingSlashAwareDataRequests,
1638
- "data"
1639
- );
1640
- if (foundOptOutRoute && routesParams.size > 0) {
1641
- url.searchParams.set(
1642
- "_routes",
1643
- nextMatches.filter((m) => routesParams.has(m.route.id)).map((m) => m.route.id).join(",")
1644
- );
1645
- }
1646
- return [url.pathname + url.search];
1647
- }, [
1648
- basename,
1649
- future.unstable_trailingSlashAwareDataRequests,
1650
- loaderData,
1651
- location,
1652
- manifest,
1653
- newMatchesForData,
1654
- nextMatches,
1655
- page,
1656
- routeModules
1657
- ]);
1658
- let moduleHrefs = React3__namespace.useMemo(
1659
- () => getModuleLinkHrefs(newMatchesForAssets, manifest),
1660
- [newMatchesForAssets, manifest]
1661
- );
1662
- let keyedPrefetchLinks = useKeyedPrefetchLinks(newMatchesForAssets);
1663
- return /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, dataHrefs.map((href) => /* @__PURE__ */ React3__namespace.createElement("link", { key: href, rel: "prefetch", as: "fetch", href, ...linkProps })), moduleHrefs.map((href) => /* @__PURE__ */ React3__namespace.createElement("link", { key: href, rel: "modulepreload", href, ...linkProps })), keyedPrefetchLinks.map(({ key, link }) => (
1664
- // these don't spread `linkProps` because they are full link descriptors
1665
- // already with their own props
1666
- /* @__PURE__ */ React3__namespace.createElement(
1667
- "link",
1668
- {
1669
- key,
1670
- nonce: linkProps.nonce,
1671
- ...link,
1672
- crossOrigin: link.crossOrigin ?? linkProps.crossOrigin
1673
- }
1674
- )
1675
- )));
1676
- }
1677
- function mergeRefs(...refs) {
1678
- return (value) => {
1679
- refs.forEach((ref) => {
1680
- if (typeof ref === "function") {
1681
- ref(value);
1682
- } else if (ref != null) {
1683
- ref.current = value;
1684
- }
1685
- });
1686
- };
1687
- }
1688
- var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
1689
- try {
1690
- if (isBrowser2) {
1691
- window.__reactRouterVersion = // @ts-expect-error
1692
- "7.13.2";
1693
- }
1694
- } catch (e) {
1695
- }
1696
- var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1697
- var Link = React3__namespace.forwardRef(
1698
- function LinkWithRef({
1699
- onClick,
1700
- discover = "render",
1701
- prefetch = "none",
1702
- relative,
1703
- reloadDocument,
1704
- replace: replace2,
1705
- unstable_mask,
1706
- state,
1707
- target,
1708
- to,
1709
- preventScrollReset,
1710
- viewTransition,
1711
- unstable_defaultShouldRevalidate,
1712
- ...rest
1713
- }, forwardedRef) {
1714
- let { basename, navigator, unstable_useTransitions } = React3__namespace.useContext(NavigationContext);
1715
- let isAbsolute = typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to);
1716
- let parsed = parseToInfo(to, basename);
1717
- to = parsed.to;
1718
- let href = useHref(to, { relative });
1719
- let location = useLocation();
1720
- let maskedHref = null;
1721
- if (unstable_mask) {
1722
- let resolved = resolveTo(
1723
- unstable_mask,
1724
- [],
1725
- location.unstable_mask ? location.unstable_mask.pathname : "/",
1726
- true
1727
- );
1728
- if (basename !== "/") {
1729
- resolved.pathname = resolved.pathname === "/" ? basename : joinPaths([basename, resolved.pathname]);
1730
- }
1731
- maskedHref = navigator.createHref(resolved);
1732
- }
1733
- let [shouldPrefetch, prefetchRef, prefetchHandlers] = usePrefetchBehavior(
1734
- prefetch,
1735
- rest
1736
- );
1737
- let internalOnClick = useLinkClickHandler(to, {
1738
- replace: replace2,
1739
- unstable_mask,
1740
- state,
1741
- target,
1742
- preventScrollReset,
1743
- relative,
1744
- viewTransition,
1745
- unstable_defaultShouldRevalidate,
1746
- unstable_useTransitions
1747
- });
1748
- function handleClick(event) {
1749
- if (onClick) onClick(event);
1750
- if (!event.defaultPrevented) {
1751
- internalOnClick(event);
1752
- }
1753
- }
1754
- let isSpaLink = !(parsed.isExternal || reloadDocument);
1755
- let link = (
1756
- // eslint-disable-next-line jsx-a11y/anchor-has-content
1757
- /* @__PURE__ */ React3__namespace.createElement(
1758
- "a",
1759
- {
1760
- ...rest,
1761
- ...prefetchHandlers,
1762
- href: (isSpaLink ? maskedHref : void 0) || parsed.absoluteURL || href,
1763
- onClick: isSpaLink ? handleClick : onClick,
1764
- ref: mergeRefs(forwardedRef, prefetchRef),
1765
- target,
1766
- "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
1767
- }
1768
- )
1769
- );
1770
- return shouldPrefetch && !isAbsolute ? /* @__PURE__ */ React3__namespace.createElement(React3__namespace.Fragment, null, link, /* @__PURE__ */ React3__namespace.createElement(PrefetchPageLinks, { page: href })) : link;
1771
- }
1772
- );
1773
- Link.displayName = "Link";
1774
- var NavLink = React3__namespace.forwardRef(
1775
- function NavLinkWithRef({
1776
- "aria-current": ariaCurrentProp = "page",
1777
- caseSensitive = false,
1778
- className: classNameProp = "",
1779
- end = false,
1780
- style: styleProp,
1781
- to,
1782
- viewTransition,
1783
- children,
1784
- ...rest
1785
- }, ref) {
1786
- let path = useResolvedPath(to, { relative: rest.relative });
1787
- let location = useLocation();
1788
- let routerState = React3__namespace.useContext(DataRouterStateContext);
1789
- let { navigator, basename } = React3__namespace.useContext(NavigationContext);
1790
- let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
1791
- // eslint-disable-next-line react-hooks/rules-of-hooks
1792
- useViewTransitionState(path) && viewTransition === true;
1793
- let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
1794
- let locationPathname = location.pathname;
1795
- let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
1796
- if (!caseSensitive) {
1797
- locationPathname = locationPathname.toLowerCase();
1798
- nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
1799
- toPathname = toPathname.toLowerCase();
1800
- }
1801
- if (nextLocationPathname && basename) {
1802
- nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
1803
- }
1804
- const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
1805
- let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
1806
- let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
1807
- let renderProps = {
1808
- isActive,
1809
- isPending,
1810
- isTransitioning
1811
- };
1812
- let ariaCurrent = isActive ? ariaCurrentProp : void 0;
1813
- let className;
1814
- if (typeof classNameProp === "function") {
1815
- className = classNameProp(renderProps);
1816
- } else {
1817
- className = [
1818
- classNameProp,
1819
- isActive ? "active" : null,
1820
- isPending ? "pending" : null,
1821
- isTransitioning ? "transitioning" : null
1822
- ].filter(Boolean).join(" ");
1823
- }
1824
- let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
1825
- return /* @__PURE__ */ React3__namespace.createElement(
1826
- Link,
1827
- {
1828
- ...rest,
1829
- "aria-current": ariaCurrent,
1830
- className,
1831
- ref,
1832
- style,
1833
- to,
1834
- viewTransition
1835
- },
1836
- typeof children === "function" ? children(renderProps) : children
1837
- );
1838
- }
1839
- );
1840
- NavLink.displayName = "NavLink";
1841
- var Form = React3__namespace.forwardRef(
1842
- ({
1843
- discover = "render",
1844
- fetcherKey,
1845
- navigate,
1846
- reloadDocument,
1847
- replace: replace2,
1848
- state,
1849
- method = defaultMethod,
1850
- action,
1851
- onSubmit,
1852
- relative,
1853
- preventScrollReset,
1854
- viewTransition,
1855
- unstable_defaultShouldRevalidate,
1856
- ...props
1857
- }, forwardedRef) => {
1858
- let { unstable_useTransitions } = React3__namespace.useContext(NavigationContext);
1859
- let submit = useSubmit();
1860
- let formAction = useFormAction(action, { relative });
1861
- let formMethod = method.toLowerCase() === "get" ? "get" : "post";
1862
- let isAbsolute = typeof action === "string" && ABSOLUTE_URL_REGEX2.test(action);
1863
- let submitHandler = (event) => {
1864
- onSubmit && onSubmit(event);
1865
- if (event.defaultPrevented) return;
1866
- event.preventDefault();
1867
- let submitter = event.nativeEvent.submitter;
1868
- let submitMethod = submitter?.getAttribute("formmethod") || method;
1869
- let doSubmit = () => submit(submitter || event.currentTarget, {
1870
- fetcherKey,
1871
- method: submitMethod,
1872
- navigate,
1873
- replace: replace2,
1874
- state,
1875
- relative,
1876
- preventScrollReset,
1877
- viewTransition,
1878
- unstable_defaultShouldRevalidate
1879
- });
1880
- if (unstable_useTransitions && navigate !== false) {
1881
- React3__namespace.startTransition(() => doSubmit());
1882
- } else {
1883
- doSubmit();
1884
- }
1885
- };
1886
- return /* @__PURE__ */ React3__namespace.createElement(
1887
- "form",
1888
- {
1889
- ref: forwardedRef,
1890
- method: formMethod,
1891
- action: formAction,
1892
- onSubmit: reloadDocument ? onSubmit : submitHandler,
1893
- ...props,
1894
- "data-discover": !isAbsolute && discover === "render" ? "true" : void 0
1895
- }
1896
- );
1897
- }
1898
- );
1899
- Form.displayName = "Form";
1900
- function getDataRouterConsoleError2(hookName) {
1901
- return `${hookName} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
1902
- }
1903
- function useDataRouterContext3(hookName) {
1904
- let ctx = React3__namespace.useContext(DataRouterContext);
1905
- invariant(ctx, getDataRouterConsoleError2(hookName));
1906
- return ctx;
1907
- }
1908
- function useLinkClickHandler(to, {
1909
- target,
1910
- replace: replaceProp,
1911
- unstable_mask,
1912
- state,
1913
- preventScrollReset,
1914
- relative,
1915
- viewTransition,
1916
- unstable_defaultShouldRevalidate,
1917
- unstable_useTransitions
1918
- } = {}) {
1919
- let navigate = useNavigate();
1920
- let location = useLocation();
1921
- let path = useResolvedPath(to, { relative });
1922
- return React3__namespace.useCallback(
1923
- (event) => {
1924
- if (shouldProcessLinkClick(event, target)) {
1925
- event.preventDefault();
1926
- let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
1927
- let doNavigate = () => navigate(to, {
1928
- replace: replace2,
1929
- unstable_mask,
1930
- state,
1931
- preventScrollReset,
1932
- relative,
1933
- viewTransition,
1934
- unstable_defaultShouldRevalidate
1935
- });
1936
- if (unstable_useTransitions) {
1937
- React3__namespace.startTransition(() => doNavigate());
1938
- } else {
1939
- doNavigate();
1940
- }
1941
- }
1942
- },
1943
- [
1944
- location,
1945
- navigate,
1946
- path,
1947
- replaceProp,
1948
- unstable_mask,
1949
- state,
1950
- target,
1951
- to,
1952
- preventScrollReset,
1953
- relative,
1954
- viewTransition,
1955
- unstable_defaultShouldRevalidate,
1956
- unstable_useTransitions
1957
- ]
1958
- );
1959
- }
1960
- var fetcherId = 0;
1961
- var getUniqueFetcherId = () => `__${String(++fetcherId)}__`;
1962
- function useSubmit() {
1963
- let { router } = useDataRouterContext3("useSubmit" /* UseSubmit */);
1964
- let { basename } = React3__namespace.useContext(NavigationContext);
1965
- let currentRouteId = useRouteId();
1966
- let routerFetch = router.fetch;
1967
- let routerNavigate = router.navigate;
1968
- return React3__namespace.useCallback(
1969
- async (target, options = {}) => {
1970
- let { action, method, encType, formData, body } = getFormSubmissionInfo(
1971
- target,
1972
- basename
1973
- );
1974
- if (options.navigate === false) {
1975
- let key = options.fetcherKey || getUniqueFetcherId();
1976
- await routerFetch(key, currentRouteId, options.action || action, {
1977
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
1978
- preventScrollReset: options.preventScrollReset,
1979
- formData,
1980
- body,
1981
- formMethod: options.method || method,
1982
- formEncType: options.encType || encType,
1983
- flushSync: options.flushSync
1984
- });
1985
- } else {
1986
- await routerNavigate(options.action || action, {
1987
- unstable_defaultShouldRevalidate: options.unstable_defaultShouldRevalidate,
1988
- preventScrollReset: options.preventScrollReset,
1989
- formData,
1990
- body,
1991
- formMethod: options.method || method,
1992
- formEncType: options.encType || encType,
1993
- replace: options.replace,
1994
- state: options.state,
1995
- fromRouteId: currentRouteId,
1996
- flushSync: options.flushSync,
1997
- viewTransition: options.viewTransition
1998
- });
1999
- }
2000
- },
2001
- [routerFetch, routerNavigate, basename, currentRouteId]
2002
- );
2003
- }
2004
- function useFormAction(action, { relative } = {}) {
2005
- let { basename } = React3__namespace.useContext(NavigationContext);
2006
- let routeContext = React3__namespace.useContext(RouteContext);
2007
- invariant(routeContext, "useFormAction must be used inside a RouteContext");
2008
- let [match] = routeContext.matches.slice(-1);
2009
- let path = { ...useResolvedPath(action ? action : ".", { relative }) };
2010
- let location = useLocation();
2011
- if (action == null) {
2012
- path.search = location.search;
2013
- let params = new URLSearchParams(path.search);
2014
- let indexValues = params.getAll("index");
2015
- let hasNakedIndexParam = indexValues.some((v) => v === "");
2016
- if (hasNakedIndexParam) {
2017
- params.delete("index");
2018
- indexValues.filter((v) => v).forEach((v) => params.append("index", v));
2019
- let qs = params.toString();
2020
- path.search = qs ? `?${qs}` : "";
2021
- }
2022
- }
2023
- if ((!action || action === ".") && match.route.index) {
2024
- path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
2025
- }
2026
- if (basename !== "/") {
2027
- path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
2028
- }
2029
- return createPath(path);
2030
- }
2031
- function useViewTransitionState(to, { relative } = {}) {
2032
- let vtContext = React3__namespace.useContext(ViewTransitionContext);
2033
- invariant(
2034
- vtContext != null,
2035
- "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
2036
- );
2037
- let { basename } = useDataRouterContext3(
2038
- "useViewTransitionState" /* useViewTransitionState */
2039
- );
2040
- let path = useResolvedPath(to, { relative });
2041
- if (!vtContext.isTransitioning) {
2042
- return false;
2043
- }
2044
- let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
2045
- let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
2046
- return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
2047
- }
2048
-
2049
- function getDefaultExportFromCjs (x) {
2050
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2051
- }
2052
-
2053
101
  const LinkWithRef = ({ children, to, href, forwardedRef = null, ...attributes }) => {
2054
102
  if (to) {
2055
- return (jsxRuntime.jsx(Link, { ref: forwardedRef, to: to, ...attributes, children: children }));
103
+ return (jsxRuntime.jsx(reactRouter.Link, { ref: forwardedRef, to: to, ...attributes, children: children }));
2056
104
  }
2057
105
  return (jsxRuntime.jsx("a", { ref: forwardedRef, href: href || "#", ...attributes, children: children }));
2058
106
  };
@@ -2155,7 +203,7 @@ const Boolean$1 = ({ className, errorMessage, fieldset, formGroup, hint, idPrefi
2155
203
  if (item.divider) {
2156
204
  return (jsxRuntime.jsx("div", { className: `govuk-${controlType}__divider`, children: item.divider }, reactListKey || index));
2157
205
  }
2158
- return (jsxRuntime.jsxs(React3.Fragment, { children: [jsxRuntime.jsxs("div", { className: `govuk-${controlType}__item`, children: [jsxRuntime.jsx("input", { className: `govuk-${controlType}__input`, id: idValue, name: nameValue, type: controlType === "radios" ? "radio" : "checkbox", "data-aria-controls": conditionalId, "aria-describedby": itemDescribedBy || undefined, onChange: onChange, onBlur: onBlur, "data-behaviour": behaviour, ...itemAttributes }), jsxRuntime.jsx(Label, { ...label,
206
+ return (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsxs("div", { className: `govuk-${controlType}__item`, children: [jsxRuntime.jsx("input", { className: `govuk-${controlType}__input`, id: idValue, name: nameValue, type: controlType === "radios" ? "radio" : "checkbox", "data-aria-controls": conditionalId, "aria-describedby": itemDescribedBy || undefined, onChange: onChange, onBlur: onBlur, "data-behaviour": behaviour, ...itemAttributes }), jsxRuntime.jsx(Label, { ...label,
2159
207
  className: `govuk-${controlType}__label ${label?.className || ""}`,
2160
208
  htmlFor: idValue,
2161
209
  isPageHeading: false, children: children }), itemHint ? (jsxRuntime.jsx(Hint, { ...itemHint,
@@ -2243,6 +291,10 @@ function ConfigureOverallButton($scope, config) {
2243
291
  govukFrontend.createAll(govukFrontend.Button, config, $scope);
2244
292
  }
2245
293
 
294
+ function getDefaultExportFromCjs (x) {
295
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
296
+ }
297
+
2246
298
  var classnames = {exports: {}};
2247
299
 
2248
300
  /*!
@@ -2332,7 +384,7 @@ var classNames = /*@__PURE__*/getDefaultExportFromCjs(classnamesExports);
2332
384
 
2333
385
  const DEFAULT_BREAKPOINTS = ['xxl', 'xl', 'lg', 'md', 'sm', 'xs'];
2334
386
  const DEFAULT_MIN_BREAKPOINT = 'xs';
2335
- const ThemeContext = /*#__PURE__*/React3__namespace.createContext({
387
+ const ThemeContext = /*#__PURE__*/React__namespace.createContext({
2336
388
  prefixes: {},
2337
389
  breakpoints: DEFAULT_BREAKPOINTS,
2338
390
  minBreakpoint: DEFAULT_MIN_BREAKPOINT
@@ -2344,11 +396,11 @@ const {
2344
396
  function useBootstrapPrefix(prefix, defaultPrefix) {
2345
397
  const {
2346
398
  prefixes
2347
- } = React3.useContext(ThemeContext);
399
+ } = React.useContext(ThemeContext);
2348
400
  return prefix || prefixes[defaultPrefix] || defaultPrefix;
2349
401
  }
2350
402
 
2351
- const CardBody = /*#__PURE__*/React3__namespace.forwardRef(({
403
+ const CardBody = /*#__PURE__*/React__namespace.forwardRef(({
2352
404
  className,
2353
405
  bsPrefix,
2354
406
  as: Component = 'div',
@@ -2363,7 +415,7 @@ const CardBody = /*#__PURE__*/React3__namespace.forwardRef(({
2363
415
  });
2364
416
  CardBody.displayName = 'CardBody';
2365
417
 
2366
- const CardFooter = /*#__PURE__*/React3__namespace.forwardRef(({
418
+ const CardFooter = /*#__PURE__*/React__namespace.forwardRef(({
2367
419
  className,
2368
420
  bsPrefix,
2369
421
  as: Component = 'div',
@@ -2378,10 +430,10 @@ const CardFooter = /*#__PURE__*/React3__namespace.forwardRef(({
2378
430
  });
2379
431
  CardFooter.displayName = 'CardFooter';
2380
432
 
2381
- const context = /*#__PURE__*/React3__namespace.createContext(null);
433
+ const context = /*#__PURE__*/React__namespace.createContext(null);
2382
434
  context.displayName = 'CardHeaderContext';
2383
435
 
2384
- const CardHeader = /*#__PURE__*/React3__namespace.forwardRef(({
436
+ const CardHeader = /*#__PURE__*/React__namespace.forwardRef(({
2385
437
  bsPrefix,
2386
438
  className,
2387
439
  // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
@@ -2389,7 +441,7 @@ const CardHeader = /*#__PURE__*/React3__namespace.forwardRef(({
2389
441
  ...props
2390
442
  }, ref) => {
2391
443
  const prefix = useBootstrapPrefix(bsPrefix, 'card-header');
2392
- const contextValue = React3.useMemo(() => ({
444
+ const contextValue = React.useMemo(() => ({
2393
445
  cardHeaderBsPrefix: prefix
2394
446
  }), [prefix]);
2395
447
  return /*#__PURE__*/jsxRuntime.jsx(context.Provider, {
@@ -2403,7 +455,7 @@ const CardHeader = /*#__PURE__*/React3__namespace.forwardRef(({
2403
455
  });
2404
456
  CardHeader.displayName = 'CardHeader';
2405
457
 
2406
- const CardImg = /*#__PURE__*/React3__namespace.forwardRef(
458
+ const CardImg = /*#__PURE__*/React__namespace.forwardRef(
2407
459
  // Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
2408
460
  ({
2409
461
  bsPrefix,
@@ -2421,7 +473,7 @@ const CardImg = /*#__PURE__*/React3__namespace.forwardRef(
2421
473
  });
2422
474
  CardImg.displayName = 'CardImg';
2423
475
 
2424
- const CardImgOverlay = /*#__PURE__*/React3__namespace.forwardRef(({
476
+ const CardImgOverlay = /*#__PURE__*/React__namespace.forwardRef(({
2425
477
  className,
2426
478
  bsPrefix,
2427
479
  as: Component = 'div',
@@ -2436,7 +488,7 @@ const CardImgOverlay = /*#__PURE__*/React3__namespace.forwardRef(({
2436
488
  });
2437
489
  CardImgOverlay.displayName = 'CardImgOverlay';
2438
490
 
2439
- const CardLink = /*#__PURE__*/React3__namespace.forwardRef(({
491
+ const CardLink = /*#__PURE__*/React__namespace.forwardRef(({
2440
492
  className,
2441
493
  bsPrefix,
2442
494
  as: Component = 'a',
@@ -2454,14 +506,14 @@ CardLink.displayName = 'CardLink';
2454
506
  var divWithClassName = (className =>
2455
507
  /*#__PURE__*/
2456
508
  // eslint-disable-next-line react/display-name
2457
- React3__namespace.forwardRef((p, ref) => /*#__PURE__*/jsxRuntime.jsx("div", {
509
+ React__namespace.forwardRef((p, ref) => /*#__PURE__*/jsxRuntime.jsx("div", {
2458
510
  ...p,
2459
511
  ref: ref,
2460
512
  className: classNames(p.className, className)
2461
513
  })));
2462
514
 
2463
515
  const DivStyledAsH6 = divWithClassName('h6');
2464
- const CardSubtitle = /*#__PURE__*/React3__namespace.forwardRef(({
516
+ const CardSubtitle = /*#__PURE__*/React__namespace.forwardRef(({
2465
517
  className,
2466
518
  bsPrefix,
2467
519
  as: Component = DivStyledAsH6,
@@ -2476,7 +528,7 @@ const CardSubtitle = /*#__PURE__*/React3__namespace.forwardRef(({
2476
528
  });
2477
529
  CardSubtitle.displayName = 'CardSubtitle';
2478
530
 
2479
- const CardText = /*#__PURE__*/React3__namespace.forwardRef(({
531
+ const CardText = /*#__PURE__*/React__namespace.forwardRef(({
2480
532
  className,
2481
533
  bsPrefix,
2482
534
  as: Component = 'p',
@@ -2492,7 +544,7 @@ const CardText = /*#__PURE__*/React3__namespace.forwardRef(({
2492
544
  CardText.displayName = 'CardText';
2493
545
 
2494
546
  const DivStyledAsH5 = divWithClassName('h5');
2495
- const CardTitle = /*#__PURE__*/React3__namespace.forwardRef(({
547
+ const CardTitle = /*#__PURE__*/React__namespace.forwardRef(({
2496
548
  className,
2497
549
  bsPrefix,
2498
550
  as: Component = DivStyledAsH5,
@@ -2507,7 +559,7 @@ const CardTitle = /*#__PURE__*/React3__namespace.forwardRef(({
2507
559
  });
2508
560
  CardTitle.displayName = 'CardTitle';
2509
561
 
2510
- const Card = /*#__PURE__*/React3__namespace.forwardRef(({
562
+ const Card = /*#__PURE__*/React__namespace.forwardRef(({
2511
563
  bsPrefix,
2512
564
  className,
2513
565
  bg,
@@ -2554,7 +606,7 @@ const CardColumn = (props) => {
2554
606
  ...(hoverColor && { "--card-hover-color": hoverColor }),
2555
607
  }
2556
608
  : undefined;
2557
- return (jsxRuntime.jsx("div", { className: "col", children: jsxRuntime.jsxs(Card$1, { className: "card-styles", style: inlineVars, children: [jsxRuntime.jsx(Link, { to: link, children: jsxRuntime.jsx(Card$1.Header, { className: "card-header govuk-!-font-size-27 govuk-!-font-weight-bold", children: header }) }), jsxRuntime.jsx(Card$1.Body, { className: "govuk-!-font-size-19", children: body })] }) }));
609
+ return (jsxRuntime.jsx("div", { className: "col", children: jsxRuntime.jsxs(Card$1, { className: "card-styles", style: inlineVars, children: [jsxRuntime.jsx(reactRouter.Link, { to: link, children: jsxRuntime.jsx(Card$1.Header, { className: "card-header govuk-!-font-size-27 govuk-!-font-weight-bold", children: header }) }), jsxRuntime.jsx(Card$1.Body, { className: "govuk-!-font-size-19", children: body })] }) }));
2558
610
  };
2559
611
 
2560
612
  const CardLayout = (props) => {
@@ -2562,7 +614,7 @@ const CardLayout = (props) => {
2562
614
  const divideByColumn = [];
2563
615
  let accumulator = [];
2564
616
  children.map((child, index) => {
2565
- accumulator.push(React3.createElement(CardColumn, { ...child, key: `card-column-${index}` }));
617
+ accumulator.push(React.createElement(CardColumn, { ...child, key: `card-column-${index}` }));
2566
618
  if (index % numberOfGridColumns === numberOfGridColumns - 1) {
2567
619
  divideByColumn.push(jsxRuntime.jsx("div", { className: `row row-cols-1 row-cols-md-${numberOfGridColumns} govuk-!-margin-bottom-8`, children: accumulator }, `card-layout-${index}`));
2568
620
  accumulator = [];
@@ -2580,7 +632,7 @@ const defaultProps$1 = {
2580
632
  id: "",
2581
633
  name: "",
2582
634
  };
2583
- const Textarea = React3.forwardRef((props = defaultProps$1, ref) => {
635
+ const Textarea = React.forwardRef((props = defaultProps$1, ref) => {
2584
636
  const { className, "aria-describedby": describedBy, errorMessage, formGroup, hint, label, id, ...attributes } = props;
2585
637
  let describedByValue = describedBy || "";
2586
638
  let hintComponent = null;
@@ -2648,7 +700,7 @@ const DataNavigation = ({ dataId, setDataFocus, previousText = "Previous", previ
2648
700
  const defaultProps = {
2649
701
  type: "text",
2650
702
  };
2651
- const Input = React3.forwardRef((props = defaultProps, ref) => {
703
+ const Input = React.forwardRef((props = defaultProps, ref) => {
2652
704
  const { className, "aria-describedby": describedBy, errorMessage, formGroup, hint, label, name, id, prefix, suffix, ...attributes } = props;
2653
705
  let describedByValue = describedBy || "";
2654
706
  let hintComponent = null;
@@ -2769,7 +821,7 @@ const DifferenceNavigation = ({ differenceId, setDifferenceFocus, totalDifferenc
2769
821
  const Main = ({ children, backLink = "", backLinkState = null, }) => (jsxRuntime.jsx("div", { className: "govuk-width-container", children: jsxRuntime.jsxs("main", { className: "govuk-main-wrapper", id: "main-content", "data-testid": "main-content", children: [backLink && (jsxRuntime.jsx("div", { className: "govuk-grid-row", children: jsxRuntime.jsx("div", { className: "govuk-grid-column-two-thirds", children: jsxRuntime.jsx(BackLink, { to: { pathname: backLink }, state: backLinkState }) }) })), children && jsxRuntime.jsx("div", { children: children })] }) }));
2770
822
 
2771
823
  const ProblemWithService = ({ message = "", applicationName = "Document and plan retrieval system", applicationRoute = "/", reportingLink = "http://marval-live/MSMselfservice/AutoGen.aspx?page=1268", basePageName = "dashboard", }) => {
2772
- const { state } = useLocation();
824
+ const { state } = reactRouter.useLocation();
2773
825
  const determineMessage = state?.message || message;
2774
826
  const determineApplicationName = state?.applicationName || applicationName;
2775
827
  const refreshPage = () => {
@@ -2780,7 +832,7 @@ const ProblemWithService = ({ message = "", applicationName = "Document and plan
2780
832
  return (jsxRuntime.jsxs(Main, { children: [jsxRuntime.jsx("h1", { className: "govuk-heading-xl", children: "Sorry, there is a problem with the service" }), hasMessage() && (jsxRuntime.jsx("div", { className: "govuk-error-summary", "aria-labelledby": "error-summary-title", role: "alert", tabIndex: -1, "data-module": "govuk-error-summary", children: jsxRuntime.jsx("div", { className: "govuk-error-summary__body", children: jsxRuntime.jsx("p", { children: determineMessage }) }) })), jsxRuntime.jsx("p", { className: "govuk-body", children: "Try again later." }), jsxRuntime.jsxs("p", { className: "govuk-body", children: ["You can go back to", " ", jsxRuntime.jsx(LinkWithRef, { className: "govuk-link", to: applicationRoute, onClick: refreshPage, children: determineApplicationName }), " ", basePageName, "."] }), jsxRuntime.jsxs("p", { className: "govuk-body", children: ["If the problem continues\u00A0", jsxRuntime.jsxs("a", { href: reportingLink, className: "govuk-link", target: "_blank", rel: "noreferrer", children: ["contact support", jsxRuntime.jsx("span", { className: "nav-panel__text opens-in-new-window" }), jsxRuntime.jsx("span", { className: "visually-hidden", children: "(Opens in a new window or tab)" })] }), "."] })] }));
2781
833
  };
2782
834
 
2783
- class ErrorBoundary extends React3.Component {
835
+ class ErrorBoundary extends React.Component {
2784
836
  constructor(props) {
2785
837
  super(props);
2786
838
  this.state = {
@@ -2871,7 +923,7 @@ const Footer = (props) => {
2871
923
  if (navigation && navigation.length > 0) {
2872
924
  navigationComponent = (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "govuk-footer__navigation", children: navigation.map((nav, navIndex) => (jsxRuntime.jsxs("div", { className: `govuk-footer__section govuk-grid-column-${nav.width ? nav.width : "full"}`, children: [jsxRuntime.jsx("h2", { className: "govuk-footer__heading govuk-heading-m", children: nav.title }), nav.items && nav.items.length > 0 ? (jsxRuntime.jsx("ul", { className: `govuk-footer__list ${nav.columns ? `govuk-footer__list--columns-${nav.columns}` : ""}`, children: nav.items.map((item, index) => {
2873
925
  const { className: itemClassName, children: itemChildren, reactListKey, ...itemAttributes } = item;
2874
- return (jsxRuntime.jsx(React3.Fragment, { children: (item.href || item.to) && itemChildren && (jsxRuntime.jsx("li", { className: "govuk-footer__list-item", children: jsxRuntime.jsx(LinkWithRef, { className: `govuk-footer__link ${itemClassName || ""}`, ...itemAttributes, children: itemChildren }) })) }, reactListKey || index));
926
+ return (jsxRuntime.jsx(React.Fragment, { children: (item.href || item.to) && itemChildren && (jsxRuntime.jsx("li", { className: "govuk-footer__list-item", children: jsxRuntime.jsx(LinkWithRef, { className: `govuk-footer__link ${itemClassName || ""}`, ...itemAttributes, children: itemChildren }) })) }, reactListKey || index));
2875
927
  }) })) : null] }, nav.reactListKey || navIndex))) }), jsxRuntime.jsx("hr", { className: "govuk-footer__section-break" })] }));
2876
928
  }
2877
929
  if (meta) {
@@ -2936,7 +988,7 @@ const InsetText = ({ className, children, ...attributes }) => {
2936
988
 
2937
989
  const Landing = (props) => {
2938
990
  const { to = "/" } = props;
2939
- return (jsxRuntime.jsx(Main, { children: jsxRuntime.jsx("div", { className: "govuk-grid-row", children: jsxRuntime.jsx("div", { className: "govuk-hint govuk-grid-column-full", children: jsxRuntime.jsx("div", { className: "centered-wheel", children: jsxRuntime.jsx("h2", { className: "govuk-heading-m", children: jsxRuntime.jsx(Link, { to: to, children: "Single sign on" }) }) }) }) }) }));
991
+ return (jsxRuntime.jsx(Main, { children: jsxRuntime.jsx("div", { className: "govuk-grid-row", children: jsxRuntime.jsx("div", { className: "govuk-hint govuk-grid-column-full", children: jsxRuntime.jsx("div", { className: "centered-wheel", children: jsxRuntime.jsx("h2", { className: "govuk-heading-m", children: jsxRuntime.jsx(reactRouter.Link, { to: to, children: "Single sign on" }) }) }) }) }) }));
2940
992
  };
2941
993
 
2942
994
  const Loading = ({ message = null, html = null }) => {
@@ -2984,7 +1036,7 @@ const UsePagination = ({ totalCount, pageSize, siblingCount = 1, currentPage, })
2984
1036
  const range = (start, end) => {
2985
1037
  return Array.from({ length: end - start + 1 }, (_, idx) => idx + start);
2986
1038
  };
2987
- const paginationRange = React3.useMemo(() => {
1039
+ const paginationRange = React.useMemo(() => {
2988
1040
  const totalPages = Math.ceil(totalCount / pageSize);
2989
1041
  const visiblePages = siblingCount + 10;
2990
1042
  // Case 1: Show all pages when total pages is less than the number of visible pages
@@ -3029,7 +1081,7 @@ const Panel = (props) => {
3029
1081
  return (jsxRuntime.jsxs("div", { className: `govuk-panel govuk-panel--confirmation ${className || ""}`, ...attributes, children: [jsxRuntime.jsx(HeadingLevel, { className: "govuk-panel__title", children: titleChildren }), innerHtml] }));
3030
1082
  };
3031
1083
 
3032
- const PasswordInput = React3.forwardRef((props, ref) => {
1084
+ const PasswordInput = React.forwardRef((props, ref) => {
3033
1085
  const { className, "aria-describedby": describedBy, errorMessage, formGroup, hint, label, name, id, autoComplete = "current-password", showPasswordText = "Show", hidePasswordText = "Hide", showPasswordAriaLabelText = "Show password", hidePasswordAriaLabelText = "Hide password", passwordShownAnnouncementText, passwordHiddenAnnouncementText, ...attributes } = props;
3034
1086
  let describedByValue = describedBy || "";
3035
1087
  let hintComponent = null;
@@ -3188,24 +1240,24 @@ const ResolvePDFSource = (source) => {
3188
1240
  };
3189
1241
 
3190
1242
  const PDFViewer = (props) => {
3191
- const viewerRef = React3.useRef(null);
1243
+ const viewerRef = React.useRef(null);
3192
1244
  const { iframeId, src, viewerLocation, documentName, documentNameColour, backend, toolbar = "minimal", additionalBackendAttributes,
3193
1245
  // optional: lets callers skip client-side fetch for remote resources
3194
1246
  disableClientFetch = false, ...attributes } = props;
3195
- const [loading, setLoading] = React3.useState(false);
1247
+ const [loading, setLoading] = React.useState(false);
3196
1248
  // ref for object URL (either created by ResolvePDFSource or by us after fetching)
3197
- const objectUrlRef = React3.useRef(null);
1249
+ const objectUrlRef = React.useRef(null);
3198
1250
  // did ResolvePDFSource create the object URL? (helps understanding where to revoke)
3199
- const createdByResolveRef = React3.useRef(false);
1251
+ const createdByResolveRef = React.useRef(false);
3200
1252
  // fetch abort controller for cross-origin remote fetches
3201
- const fetchControllerRef = React3.useRef(null);
1253
+ const fetchControllerRef = React.useRef(null);
3202
1254
  const isRemoteUrl = (url) => {
3203
1255
  if (!url)
3204
1256
  return false;
3205
1257
  // Check if it's an HTTP(S) URL
3206
1258
  return /^https?:\/\//i.test(url);
3207
1259
  };
3208
- React3.useEffect(() => {
1260
+ React.useEffect(() => {
3209
1261
  let mounted = true;
3210
1262
  setLoading(true);
3211
1263
  const element = viewerRef.current;
@@ -3459,7 +1511,7 @@ const Select = (props) => {
3459
1511
  .filter((item) => item)
3460
1512
  .map((option, index) => {
3461
1513
  const { reactListKey, children, ...optionAttributes } = option;
3462
- return (React3.createElement("option", { ...optionAttributes, key: reactListKey || index }, children));
1514
+ return (React.createElement("option", { ...optionAttributes, key: reactListKey || index }, children));
3463
1515
  })
3464
1516
  : null;
3465
1517
  return (jsxRuntime.jsxs("div", { className: `govuk-form-group${errorMessage ? " govuk-form-group--error" : ""} ${formGroup?.className || ""}`, children: [jsxRuntime.jsx(Label, { ...label, htmlFor: id }), hintComponent, errorMessageComponent, jsxRuntime.jsx("select", { className: `govuk-select ${className || ""}${errorMessage ? " govuk-select--error" : ""}`, id: id, "aria-describedby": describedByValue || undefined, ...attributes, children: options })] }));
@@ -3505,11 +1557,11 @@ const SummaryList = (props) => {
3505
1557
 
3506
1558
  const Table = ({ caption, captionClassName, className, firstCellIsHeader, head, rows, footer, ...attributes }) => {
3507
1559
  // Memoize caption component to avoid re-renders if it doesn't change
3508
- const captionComponent = React3.useMemo(() => caption && (jsxRuntime.jsx("caption", { className: `govuk-table__caption ${captionClassName || ""}`, children: caption })), [caption, captionClassName]);
1560
+ const captionComponent = React.useMemo(() => caption && (jsxRuntime.jsx("caption", { className: `govuk-table__caption ${captionClassName || ""}`, children: caption })), [caption, captionClassName]);
3509
1561
  // Memoize head component
3510
- const headComponent = React3.useMemo(() => head && (jsxRuntime.jsx("thead", { className: "govuk-table__head", children: jsxRuntime.jsx("tr", { className: "govuk-table__row", children: head.map(({ className, format, children, reactListKey, ...itemAttributes }, index) => (jsxRuntime.jsx("th", { scope: "col", className: `govuk-table__header ${format ? `govuk-table__header--${format}` : ""} ${className || ""}`, ...itemAttributes, children: children }, reactListKey || index))) }) })), [head]);
1562
+ const headComponent = React.useMemo(() => head && (jsxRuntime.jsx("thead", { className: "govuk-table__head", children: jsxRuntime.jsx("tr", { className: "govuk-table__row", children: head.map(({ className, format, children, reactListKey, ...itemAttributes }, index) => (jsxRuntime.jsx("th", { scope: "col", className: `govuk-table__header ${format ? `govuk-table__header--${format}` : ""} ${className || ""}`, ...itemAttributes, children: children }, reactListKey || index))) }) })), [head]);
3511
1563
  // Memoize footer component
3512
- const footerComponent = React3.useMemo(() => footer && (jsxRuntime.jsx("tfoot", { className: "govuk-table__head", children: jsxRuntime.jsx("tr", { className: "govuk-table__row", children: footer.map(({ className, format, children, reactListKey, ...itemAttributes }, index) => (jsxRuntime.jsx("th", { scope: "col", className: `govuk-table__header ${format ? `govuk-table__header--${format}` : ""} ${className || ""}`, ...itemAttributes, children: children }, reactListKey || index))) }) })), [footer]);
1564
+ const footerComponent = React.useMemo(() => footer && (jsxRuntime.jsx("tfoot", { className: "govuk-table__head", children: jsxRuntime.jsx("tr", { className: "govuk-table__row", children: footer.map(({ className, format, children, reactListKey, ...itemAttributes }, index) => (jsxRuntime.jsx("th", { scope: "col", className: `govuk-table__header ${format ? `govuk-table__header--${format}` : ""} ${className || ""}`, ...itemAttributes, children: children }, reactListKey || index))) }) })), [footer]);
3513
1565
  // Filter rows that contain cells
3514
1566
  const filteredRows = rows?.filter((row) => row.cells) || [];
3515
1567
  return (jsxRuntime.jsxs("table", { className: `govuk-table ${className}`, ...attributes, children: [captionComponent, headComponent, jsxRuntime.jsx("tbody", { className: "govuk-table__body", children: filteredRows.map(({ cells, reactListKey }, rowIndex) => (jsxRuntime.jsx("tr", { className: "govuk-table__row", children: cells.map(({ className, children, format, reactListKey, ...cellAttributes }, cellIndex) => {
@@ -3554,7 +1606,7 @@ const TaskList = (props) => {
3554
1606
 
3555
1607
  const WarningInfo = ({ messageHeading = "Warning or Info Heading", message = "Warning or Info Heading message", advice = "Try again later.", applicationName = "Document and plan retrieval system", applicationRoute = "/", basePageName = "dashboard", }) => {
3556
1608
  let determineMessage;
3557
- const { state } = useLocation();
1609
+ const { state } = reactRouter.useLocation();
3558
1610
  if (state && state.message) {
3559
1611
  determineMessage = state.message;
3560
1612
  }