likec4 1.20.0 → 1.20.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.
@@ -1,3032 +0,0 @@
1
- import { jsxs as te, jsx as C, Fragment as Fe } from "react/jsx-runtime";
2
- import * as b from "react";
3
- import ye, { useRef as Te } from "react";
4
- import { flushSync as Be } from "react-dom";
5
- const dt = "__TSR_index", de = "popstate", he = "beforeunload";
6
- function Se(e) {
7
- let n = e.getLocation();
8
- const t = /* @__PURE__ */ new Set(), o = (i) => {
9
- n = e.getLocation(), t.forEach((a) => a({ location: n, action: i }));
10
- }, r = (i) => {
11
- e.notifyOnIndexChange ?? !0 ? o(i) : n = e.getLocation();
12
- }, s = async ({
13
- task: i,
14
- navigateOpts: a,
15
- ...u
16
- }) => {
17
- var c, d;
18
- if (a?.ignoreBlocker ?? !1) {
19
- i();
20
- return;
21
- }
22
- const h = ((c = e.getBlockers) == null ? void 0 : c.call(e)) ?? [], f = u.type === "PUSH" || u.type === "REPLACE";
23
- if (typeof document < "u" && h.length && f)
24
- for (const p of h) {
25
- const S = yt(u.path, u.state);
26
- if (await p.blockerFn({
27
- currentLocation: n,
28
- nextLocation: S,
29
- action: u.type
30
- })) {
31
- (d = e.onBlocked) == null || d.call(e);
32
- return;
33
- }
34
- }
35
- i();
36
- };
37
- return {
38
- get location() {
39
- return n;
40
- },
41
- get length() {
42
- return e.getLength();
43
- },
44
- subscribers: t,
45
- subscribe: (i) => (t.add(i), () => {
46
- t.delete(i);
47
- }),
48
- push: (i, a, u) => {
49
- const c = n.state[dt];
50
- a = ee(c + 1, a), s({
51
- task: () => {
52
- e.pushState(i, a), o({ type: "PUSH" });
53
- },
54
- navigateOpts: u,
55
- type: "PUSH",
56
- path: i,
57
- state: a
58
- });
59
- },
60
- replace: (i, a, u) => {
61
- const c = n.state[dt];
62
- a = ee(c, a), s({
63
- task: () => {
64
- e.replaceState(i, a), o({ type: "REPLACE" });
65
- },
66
- navigateOpts: u,
67
- type: "REPLACE",
68
- path: i,
69
- state: a
70
- });
71
- },
72
- go: (i, a) => {
73
- s({
74
- task: () => {
75
- e.go(i), r({ type: "GO", index: i });
76
- },
77
- navigateOpts: a,
78
- type: "GO"
79
- });
80
- },
81
- back: (i) => {
82
- s({
83
- task: () => {
84
- e.back(i?.ignoreBlocker ?? !1), r({ type: "BACK" });
85
- },
86
- navigateOpts: i,
87
- type: "BACK"
88
- });
89
- },
90
- forward: (i) => {
91
- s({
92
- task: () => {
93
- e.forward(i?.ignoreBlocker ?? !1), r({ type: "FORWARD" });
94
- },
95
- navigateOpts: i,
96
- type: "FORWARD"
97
- });
98
- },
99
- canGoBack: () => n.state[dt] !== 0,
100
- createHref: (i) => e.createHref(i),
101
- block: (i) => {
102
- var a;
103
- if (!e.setBlockers) return () => {
104
- };
105
- const u = ((a = e.getBlockers) == null ? void 0 : a.call(e)) ?? [];
106
- return e.setBlockers([...u, i]), () => {
107
- var c, d;
108
- const l = ((c = e.getBlockers) == null ? void 0 : c.call(e)) ?? [];
109
- (d = e.setBlockers) == null || d.call(e, l.filter((h) => h !== i));
110
- };
111
- },
112
- flush: () => {
113
- var i;
114
- return (i = e.flush) == null ? void 0 : i.call(e);
115
- },
116
- destroy: () => {
117
- var i;
118
- return (i = e.destroy) == null ? void 0 : i.call(e);
119
- },
120
- notify: o
121
- };
122
- }
123
- function ee(e, n) {
124
- return n || (n = {}), {
125
- ...n,
126
- key: Oe(),
127
- [dt]: e
128
- };
129
- }
130
- function _e(e) {
131
- const n = e?.window ?? (typeof document < "u" ? window : void 0), t = n.history.pushState, o = n.history.replaceState;
132
- let r = [];
133
- const s = () => r, i = (y) => r = y, a = e?.createHref ?? ((y) => y), u = e?.parseLocation ?? (() => yt(
134
- `${n.location.pathname}${n.location.search}${n.location.hash}`,
135
- n.history.state
136
- ));
137
- let c = u(), d, l = !1, h = !1, f = !1, p = !1;
138
- const S = () => c;
139
- let g, M;
140
- const R = () => {
141
- g && (F._ignoreSubscribers = !0, (g.isPush ? n.history.pushState : n.history.replaceState)(
142
- g.state,
143
- "",
144
- g.href
145
- ), F._ignoreSubscribers = !1, g = void 0, M = void 0, d = void 0);
146
- }, L = (y, _, E) => {
147
- const m = a(_);
148
- M || (d = c), c = yt(_, E), g = {
149
- href: m,
150
- state: E,
151
- isPush: g?.isPush || y === "push"
152
- }, M || (M = Promise.resolve().then(() => R()));
153
- }, P = (y) => {
154
- c = u(), F.notify({ type: y });
155
- }, v = async () => {
156
- if (h) {
157
- h = !1;
158
- return;
159
- }
160
- const y = u(), _ = y.state[dt] - c.state[dt], E = _ === 1, m = _ === -1, w = !E && !m || l;
161
- l = !1;
162
- const k = w ? "GO" : m ? "BACK" : "FORWARD", T = w ? {
163
- type: "GO",
164
- index: _
165
- } : {
166
- type: m ? "BACK" : "FORWARD"
167
- };
168
- if (f)
169
- f = !1;
170
- else {
171
- const I = s();
172
- if (typeof document < "u" && I.length) {
173
- for (const D of I)
174
- if (await D.blockerFn({
175
- currentLocation: c,
176
- nextLocation: y,
177
- action: k
178
- })) {
179
- h = !0, n.history.go(1), F.notify(T);
180
- return;
181
- }
182
- }
183
- }
184
- c = u(), F.notify(T);
185
- }, x = (y) => {
186
- if (p) {
187
- p = !1;
188
- return;
189
- }
190
- let _ = !1;
191
- const E = s();
192
- if (typeof document < "u" && E.length)
193
- for (const m of E) {
194
- const w = m.enableBeforeUnload ?? !0;
195
- if (w === !0) {
196
- _ = !0;
197
- break;
198
- }
199
- if (typeof w == "function" && w() === !0) {
200
- _ = !0;
201
- break;
202
- }
203
- }
204
- if (_)
205
- return y.preventDefault(), y.returnValue = "";
206
- }, F = Se({
207
- getLocation: S,
208
- getLength: () => n.history.length,
209
- pushState: (y, _) => L("push", y, _),
210
- replaceState: (y, _) => L("replace", y, _),
211
- back: (y) => (y && (f = !0), p = !0, n.history.back()),
212
- forward: (y) => {
213
- y && (f = !0), p = !0, n.history.forward();
214
- },
215
- go: (y) => {
216
- l = !0, n.history.go(y);
217
- },
218
- createHref: (y) => a(y),
219
- flush: R,
220
- destroy: () => {
221
- n.history.pushState = t, n.history.replaceState = o, n.removeEventListener(he, x, {
222
- capture: !0
223
- }), n.removeEventListener(de, v);
224
- },
225
- onBlocked: () => {
226
- d && c !== d && (c = d);
227
- },
228
- getBlockers: s,
229
- setBlockers: i,
230
- notifyOnIndexChange: !1
231
- });
232
- return n.addEventListener(he, x, { capture: !0 }), n.addEventListener(de, v), n.history.pushState = function(...y) {
233
- const _ = t.apply(n.history, y);
234
- return F._ignoreSubscribers || P("PUSH"), _;
235
- }, n.history.replaceState = function(...y) {
236
- const _ = o.apply(n.history, y);
237
- return F._ignoreSubscribers || P("REPLACE"), _;
238
- }, F;
239
- }
240
- function oo(e) {
241
- const n = typeof document < "u" ? window : void 0;
242
- return _e({
243
- window: n,
244
- parseLocation: () => {
245
- const t = n.location.hash.split("#").slice(1).join("#") ?? "/";
246
- return yt(t, n.history.state);
247
- },
248
- createHref: (t) => `${n.location.pathname}${n.location.search}#${t}`
249
- });
250
- }
251
- function De(e = {
252
- initialEntries: ["/"]
253
- }) {
254
- const n = e.initialEntries;
255
- let t = e.initialIndex ? Math.min(Math.max(e.initialIndex, 0), n.length - 1) : n.length - 1;
256
- const o = n.map(
257
- (s, i) => ee(i, void 0)
258
- );
259
- return Se({
260
- getLocation: () => yt(n[t], o[t]),
261
- getLength: () => n.length,
262
- pushState: (s, i) => {
263
- t < n.length - 1 && (n.splice(t + 1), o.splice(t + 1)), o.push(i), n.push(s), t = Math.max(n.length - 1, 0);
264
- },
265
- replaceState: (s, i) => {
266
- o[t] = i, n[t] = s;
267
- },
268
- back: () => {
269
- t = Math.max(t - 1, 0);
270
- },
271
- forward: () => {
272
- t = Math.min(t + 1, n.length - 1);
273
- },
274
- go: (s) => {
275
- t = Math.min(Math.max(t + s, 0), n.length - 1);
276
- },
277
- createHref: (s) => s
278
- });
279
- }
280
- function yt(e, n) {
281
- const t = e.indexOf("#"), o = e.indexOf("?");
282
- return {
283
- href: e,
284
- pathname: e.substring(
285
- 0,
286
- t > 0 ? o > 0 ? Math.min(t, o) : t : o > 0 ? o : e.length
287
- ),
288
- hash: t > -1 ? e.substring(t) : "",
289
- search: o > -1 ? e.slice(o, t === -1 ? void 0 : t) : "",
290
- state: n || { [dt]: 0 }
291
- };
292
- }
293
- function Oe() {
294
- return (Math.random() + 1).toString(36).substring(7);
295
- }
296
- var Ve = !0, Wt = "Invariant failed";
297
- function et(e, n) {
298
- if (!e) {
299
- if (Ve)
300
- throw new Error(Wt);
301
- var t = typeof n == "function" ? n() : n, o = t ? "".concat(Wt, ": ").concat(t) : Wt;
302
- throw new Error(o);
303
- }
304
- }
305
- var Ae = !0;
306
- function Mt(e, n) {
307
- if (!Ae) {
308
- if (e)
309
- return;
310
- var t = "Warning: " + n;
311
- typeof console < "u" && console.warn(t);
312
- try {
313
- throw Error(t);
314
- } catch {
315
- }
316
- }
317
- }
318
- var se = { exports: {} }, we = {}, ie = { exports: {} }, Pe = {};
319
- /**
320
- * @license React
321
- * use-sync-external-store-shim.production.js
322
- *
323
- * Copyright (c) Meta Platforms, Inc. and affiliates.
324
- *
325
- * This source code is licensed under the MIT license found in the
326
- * LICENSE file in the root directory of this source tree.
327
- */
328
- var St = ye;
329
- function Ne(e, n) {
330
- return e === n && (e !== 0 || 1 / e === 1 / n) || e !== e && n !== n;
331
- }
332
- var $e = typeof Object.is == "function" ? Object.is : Ne, Ke = St.useState, Ue = St.useEffect, ze = St.useLayoutEffect, We = St.useDebugValue;
333
- function He(e, n) {
334
- var t = n(), o = Ke({ inst: { value: t, getSnapshot: n } }), r = o[0].inst, s = o[1];
335
- return ze(
336
- function() {
337
- r.value = t, r.getSnapshot = n, Ht(r) && s({ inst: r });
338
- },
339
- [e, t, n]
340
- ), Ue(
341
- function() {
342
- return Ht(r) && s({ inst: r }), e(function() {
343
- Ht(r) && s({ inst: r });
344
- });
345
- },
346
- [e]
347
- ), We(t), t;
348
- }
349
- function Ht(e) {
350
- var n = e.getSnapshot;
351
- e = e.value;
352
- try {
353
- var t = n();
354
- return !$e(e, t);
355
- } catch {
356
- return !0;
357
- }
358
- }
359
- function je(e, n) {
360
- return n();
361
- }
362
- var Ge = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? je : He;
363
- Pe.useSyncExternalStore = St.useSyncExternalStore !== void 0 ? St.useSyncExternalStore : Ge;
364
- ie.exports;
365
- ie.exports = Pe;
366
- var Xe = ie.exports;
367
- /**
368
- * @license React
369
- * use-sync-external-store-shim/with-selector.production.js
370
- *
371
- * Copyright (c) Meta Platforms, Inc. and affiliates.
372
- *
373
- * This source code is licensed under the MIT license found in the
374
- * LICENSE file in the root directory of this source tree.
375
- */
376
- var Nt = ye, qe = Xe;
377
- function Je(e, n) {
378
- return e === n && (e !== 0 || 1 / e === 1 / n) || e !== e && n !== n;
379
- }
380
- var Ye = typeof Object.is == "function" ? Object.is : Je, Qe = qe.useSyncExternalStore, Ze = Nt.useRef, tn = Nt.useEffect, en = Nt.useMemo, nn = Nt.useDebugValue;
381
- we.useSyncExternalStoreWithSelector = function(e, n, t, o, r) {
382
- var s = Ze(null);
383
- if (s.current === null) {
384
- var i = { hasValue: !1, value: null };
385
- s.current = i;
386
- } else i = s.current;
387
- s = en(
388
- function() {
389
- function u(f) {
390
- if (!c) {
391
- if (c = !0, d = f, f = o(f), r !== void 0 && i.hasValue) {
392
- var p = i.value;
393
- if (r(p, f))
394
- return l = p;
395
- }
396
- return l = f;
397
- }
398
- if (p = l, Ye(d, f)) return p;
399
- var S = o(f);
400
- return r !== void 0 && r(p, S) ? (d = f, p) : (d = f, l = S);
401
- }
402
- var c = !1, d, l, h = t === void 0 ? null : t;
403
- return [
404
- function() {
405
- return u(n());
406
- },
407
- h === null ? void 0 : function() {
408
- return u(h());
409
- }
410
- ];
411
- },
412
- [n, t, o, r]
413
- );
414
- var a = Qe(e, s[0], s[1]);
415
- return tn(
416
- function() {
417
- i.hasValue = !0, i.value = a;
418
- },
419
- [a]
420
- ), nn(a), a;
421
- };
422
- se.exports;
423
- se.exports = we;
424
- var on = se.exports;
425
- const mt = /* @__PURE__ */ new WeakMap(), Tt = /* @__PURE__ */ new WeakMap(), Dt = {
426
- current: []
427
- };
428
- let jt = !1, Ct = 0;
429
- const bt = /* @__PURE__ */ new Set(), It = /* @__PURE__ */ new Map();
430
- function be(e) {
431
- const n = Array.from(e).sort((t, o) => t instanceof vt && t.options.deps.includes(o) ? 1 : o instanceof vt && o.options.deps.includes(t) ? -1 : 0);
432
- for (const t of n) {
433
- if (Dt.current.includes(t))
434
- continue;
435
- Dt.current.push(t), t.recompute();
436
- const o = Tt.get(t);
437
- if (o)
438
- for (const r of o) {
439
- const s = mt.get(r);
440
- s && be(s);
441
- }
442
- }
443
- }
444
- function rn(e) {
445
- e.listeners.forEach(
446
- (n) => n({
447
- prevVal: e.prevState,
448
- currentVal: e.state
449
- })
450
- );
451
- }
452
- function sn(e) {
453
- e.listeners.forEach(
454
- (n) => n({
455
- prevVal: e.prevState,
456
- currentVal: e.state
457
- })
458
- );
459
- }
460
- function Re(e) {
461
- if (Ct > 0 && !It.has(e) && It.set(e, e.prevState), bt.add(e), !(Ct > 0) && !jt)
462
- try {
463
- for (jt = !0; bt.size > 0; ) {
464
- const n = Array.from(bt);
465
- bt.clear();
466
- for (const t of n) {
467
- const o = It.get(t) ?? t.prevState;
468
- t.prevState = o, rn(t);
469
- }
470
- for (const t of n) {
471
- const o = mt.get(t);
472
- o && (Dt.current.push(t), be(o));
473
- }
474
- for (const t of n) {
475
- const o = mt.get(t);
476
- if (o)
477
- for (const r of o)
478
- sn(r);
479
- }
480
- }
481
- } finally {
482
- jt = !1, Dt.current = [], It.clear();
483
- }
484
- }
485
- function Gt(e) {
486
- Ct++;
487
- try {
488
- e();
489
- } finally {
490
- if (Ct--, Ct === 0) {
491
- const n = Array.from(bt)[0];
492
- n && Re(n);
493
- }
494
- }
495
- }
496
- class ne {
497
- constructor(n, t) {
498
- this.listeners = /* @__PURE__ */ new Set(), this.subscribe = (o) => {
499
- var r, s;
500
- this.listeners.add(o);
501
- const i = (s = (r = this.options) == null ? void 0 : r.onSubscribe) == null ? void 0 : s.call(r, o, this);
502
- return () => {
503
- this.listeners.delete(o), i?.();
504
- };
505
- }, this.setState = (o) => {
506
- var r, s, i;
507
- this.prevState = this.state, this.state = (r = this.options) != null && r.updateFn ? this.options.updateFn(this.prevState)(o) : o(this.prevState), (i = (s = this.options) == null ? void 0 : s.onUpdate) == null || i.call(s), Re(this);
508
- }, this.prevState = n, this.state = n, this.options = t;
509
- }
510
- }
511
- class vt {
512
- constructor(n) {
513
- this.listeners = /* @__PURE__ */ new Set(), this._subscriptions = [], this.lastSeenDepValues = [], this.getDepVals = () => {
514
- const t = [], o = [];
515
- for (const r of this.options.deps)
516
- t.push(r.prevState), o.push(r.state);
517
- return this.lastSeenDepValues = o, {
518
- prevDepVals: t,
519
- currDepVals: o,
520
- prevVal: this.prevState ?? void 0
521
- };
522
- }, this.recompute = () => {
523
- var t, o;
524
- this.prevState = this.state;
525
- const { prevDepVals: r, currDepVals: s, prevVal: i } = this.getDepVals();
526
- this.state = this.options.fn({
527
- prevDepVals: r,
528
- currDepVals: s,
529
- prevVal: i
530
- }), (o = (t = this.options).onUpdate) == null || o.call(t);
531
- }, this.checkIfRecalculationNeededDeeply = () => {
532
- for (const s of this.options.deps)
533
- s instanceof vt && s.checkIfRecalculationNeededDeeply();
534
- let t = !1;
535
- const o = this.lastSeenDepValues, { currDepVals: r } = this.getDepVals();
536
- for (let s = 0; s < r.length; s++)
537
- if (r[s] !== o[s]) {
538
- t = !0;
539
- break;
540
- }
541
- t && this.recompute();
542
- }, this.mount = () => (this.registerOnGraph(), this.checkIfRecalculationNeededDeeply(), () => {
543
- this.unregisterFromGraph();
544
- for (const t of this._subscriptions)
545
- t();
546
- }), this.subscribe = (t) => {
547
- var o, r;
548
- this.listeners.add(t);
549
- const s = (r = (o = this.options).onSubscribe) == null ? void 0 : r.call(o, t, this);
550
- return () => {
551
- this.listeners.delete(t), s?.();
552
- };
553
- }, this.options = n, this.state = n.fn({
554
- prevDepVals: void 0,
555
- prevVal: void 0,
556
- currDepVals: this.getDepVals().currDepVals
557
- });
558
- }
559
- registerOnGraph(n = this.options.deps) {
560
- for (const t of n)
561
- if (t instanceof vt)
562
- t.registerOnGraph(), this.registerOnGraph(t.options.deps);
563
- else if (t instanceof ne) {
564
- let o = mt.get(t);
565
- o || (o = /* @__PURE__ */ new Set(), mt.set(t, o)), o.add(this);
566
- let r = Tt.get(this);
567
- r || (r = /* @__PURE__ */ new Set(), Tt.set(this, r)), r.add(t);
568
- }
569
- }
570
- unregisterFromGraph(n = this.options.deps) {
571
- for (const t of n)
572
- if (t instanceof vt)
573
- this.unregisterFromGraph(t.options.deps);
574
- else if (t instanceof ne) {
575
- const o = mt.get(t);
576
- o && o.delete(this);
577
- const r = Tt.get(this);
578
- r && r.delete(t);
579
- }
580
- }
581
- }
582
- function an(e, n = (t) => t) {
583
- return on.useSyncExternalStoreWithSelector(
584
- e.subscribe,
585
- () => e.state,
586
- () => e.state,
587
- n,
588
- cn
589
- );
590
- }
591
- function cn(e, n) {
592
- if (Object.is(e, n))
593
- return !0;
594
- if (typeof e != "object" || e === null || typeof n != "object" || n === null)
595
- return !1;
596
- if (e instanceof Map && n instanceof Map) {
597
- if (e.size !== n.size) return !1;
598
- for (const [o, r] of e)
599
- if (!n.has(o) || !Object.is(r, n.get(o))) return !1;
600
- return !0;
601
- }
602
- if (e instanceof Set && n instanceof Set) {
603
- if (e.size !== n.size) return !1;
604
- for (const o of e)
605
- if (!n.has(o)) return !1;
606
- return !0;
607
- }
608
- const t = Object.keys(e);
609
- if (t.length !== Object.keys(n).length)
610
- return !1;
611
- for (let o = 0; o < t.length; o++)
612
- if (!Object.prototype.hasOwnProperty.call(n, t[o]) || !Object.is(e[t[o]], n[t[o]]))
613
- return !1;
614
- return !0;
615
- }
616
- const H = "__root__";
617
- function ln(e, n) {
618
- let t, o, r, s = "";
619
- for (t in e)
620
- if ((r = e[t]) !== void 0)
621
- if (Array.isArray(r))
622
- for (o = 0; o < r.length; o++)
623
- s && (s += "&"), s += encodeURIComponent(t) + "=" + encodeURIComponent(r[o]);
624
- else
625
- s && (s += "&"), s += encodeURIComponent(t) + "=" + encodeURIComponent(r);
626
- return "" + s;
627
- }
628
- function fe(e) {
629
- if (!e) return "";
630
- const n = decodeURIComponent(e);
631
- return n === "false" ? !1 : n === "true" ? !0 : +n * 0 === 0 && +n + "" === n ? +n : n;
632
- }
633
- function un(e, n) {
634
- let t, o;
635
- const r = {}, s = e.split("&");
636
- for (; t = s.shift(); ) {
637
- const i = t.indexOf("=");
638
- if (i !== -1) {
639
- o = t.slice(0, i), o = decodeURIComponent(o);
640
- const a = t.slice(i + 1);
641
- r[o] !== void 0 ? r[o] = [].concat(r[o], fe(a)) : r[o] = fe(a);
642
- } else
643
- o = t, o = decodeURIComponent(o), r[o] = "";
644
- }
645
- return r;
646
- }
647
- const dn = fn(JSON.parse), hn = pn(
648
- JSON.stringify,
649
- JSON.parse
650
- );
651
- function fn(e) {
652
- return (n) => {
653
- n.substring(0, 1) === "?" && (n = n.substring(1));
654
- const t = un(n);
655
- for (const o in t) {
656
- const r = t[o];
657
- if (typeof r == "string")
658
- try {
659
- t[o] = e(r);
660
- } catch {
661
- }
662
- }
663
- return t;
664
- };
665
- }
666
- function pn(e, n) {
667
- function t(o) {
668
- if (typeof o == "object" && o !== null)
669
- try {
670
- return e(o);
671
- } catch {
672
- }
673
- else if (typeof o == "string" && typeof n == "function")
674
- try {
675
- return n(o), e(o);
676
- } catch {
677
- }
678
- return o;
679
- }
680
- return (o) => {
681
- o = { ...o }, Object.keys(o).forEach((s) => {
682
- const i = o[s];
683
- typeof i > "u" || i === void 0 ? delete o[s] : o[s] = t(i);
684
- });
685
- const r = ln(o).toString();
686
- return r ? `?${r}` : "";
687
- };
688
- }
689
- function Lt(e) {
690
- return e[e.length - 1];
691
- }
692
- function mn(e) {
693
- return typeof e == "function";
694
- }
695
- function lt(e, n) {
696
- return mn(e) ? e(n) : e;
697
- }
698
- function oe(e, n) {
699
- return n.reduce((t, o) => (t[o] = e[o], t), {});
700
- }
701
- function X(e, n) {
702
- if (e === n)
703
- return e;
704
- const t = n, o = me(e) && me(t);
705
- if (o || Ot(e) && Ot(t)) {
706
- const r = o ? e : Object.keys(e), s = r.length, i = o ? t : Object.keys(t), a = i.length, u = o ? [] : {};
707
- let c = 0;
708
- for (let d = 0; d < a; d++) {
709
- const l = o ? d : i[d];
710
- (!o && r.includes(l) || o) && e[l] === void 0 && t[l] === void 0 ? (u[l] = void 0, c++) : (u[l] = X(e[l], t[l]), u[l] === e[l] && e[l] !== void 0 && c++);
711
- }
712
- return s === a && c === s ? e : u;
713
- }
714
- return t;
715
- }
716
- function Ot(e) {
717
- if (!pe(e))
718
- return !1;
719
- const n = e.constructor;
720
- if (typeof n > "u")
721
- return !0;
722
- const t = n.prototype;
723
- return !(!pe(t) || !t.hasOwnProperty("isPrototypeOf"));
724
- }
725
- function pe(e) {
726
- return Object.prototype.toString.call(e) === "[object Object]";
727
- }
728
- function me(e) {
729
- return Array.isArray(e) && e.length === Object.keys(e).length;
730
- }
731
- function ve(e, n) {
732
- let t = Object.keys(e);
733
- return n && (t = t.filter((o) => e[o] !== void 0)), t;
734
- }
735
- function gt(e, n, t) {
736
- if (e === n)
737
- return !0;
738
- if (typeof e != typeof n)
739
- return !1;
740
- if (Ot(e) && Ot(n)) {
741
- const o = t?.ignoreUndefined ?? !0, r = ve(e, o), s = ve(n, o);
742
- return !t?.partial && r.length !== s.length ? !1 : s.every((i) => gt(e[i], n[i], t));
743
- }
744
- return Array.isArray(e) && Array.isArray(n) ? e.length !== n.length ? !1 : !e.some((o, r) => !gt(o, n[r], t)) : !1;
745
- }
746
- const Rt = typeof window < "u" ? b.useLayoutEffect : b.useEffect;
747
- function pt(e) {
748
- let n, t;
749
- const o = new Promise((r, s) => {
750
- n = r, t = s;
751
- });
752
- return o.status = "pending", o.resolve = (r) => {
753
- o.status = "resolved", o.value = r, n(r), e?.(r);
754
- }, o.reject = (r) => {
755
- o.status = "rejected", t(r);
756
- }, o;
757
- }
758
- function Xt(e) {
759
- const n = b.useRef({
760
- value: e,
761
- prev: null
762
- }), t = n.current.value;
763
- return e !== t && (n.current = {
764
- value: e,
765
- prev: t
766
- }), n.current.prev;
767
- }
768
- function vn(e, n, t = {}, o = {}) {
769
- const r = b.useRef(
770
- typeof IntersectionObserver == "function"
771
- ), s = b.useRef(null);
772
- return b.useEffect(() => {
773
- if (!(!e.current || !r.current || o.disabled))
774
- return s.current = new IntersectionObserver(([i]) => {
775
- n(i);
776
- }, t), s.current.observe(e.current), () => {
777
- var i;
778
- (i = s.current) == null || i.disconnect();
779
- };
780
- }, [n, t, o.disabled, e]), s.current;
781
- }
782
- function gn(e) {
783
- const n = b.useRef(null);
784
- return b.useEffect(() => {
785
- e && (typeof e == "function" ? e(n.current) : e.current = n.current);
786
- }), n;
787
- }
788
- function ot(e) {
789
- return $t(
790
- e.filter((n) => n !== void 0).join("/")
791
- );
792
- }
793
- function $t(e) {
794
- return e.replace(/\/{2,}/g, "/");
795
- }
796
- function ae(e) {
797
- return e === "/" ? e : e.replace(/^\/{1,}/, "");
798
- }
799
- function ut(e) {
800
- return e === "/" ? e : e.replace(/\/{1,}$/, "");
801
- }
802
- function yn(e) {
803
- return ut(ae(e));
804
- }
805
- function Vt(e, n) {
806
- return e.endsWith("/") && e !== "/" && e !== `${n}/` ? e.slice(0, -1) : e;
807
- }
808
- function Sn(e, n, t) {
809
- return Vt(e, t) === Vt(n, t);
810
- }
811
- function _n({
812
- basepath: e,
813
- base: n,
814
- to: t,
815
- trailingSlash: o = "never",
816
- caseSensitive: r
817
- }) {
818
- var s, i;
819
- n = At(e, n, r), t = At(e, t, r);
820
- let a = _t(n);
821
- const u = _t(t);
822
- a.length > 1 && ((s = Lt(a)) == null ? void 0 : s.value) === "/" && a.pop(), u.forEach((d, l) => {
823
- d.value === "/" ? l ? l === u.length - 1 && a.push(d) : a = [d] : d.value === ".." ? a.pop() : d.value === "." || a.push(d);
824
- }), a.length > 1 && (((i = Lt(a)) == null ? void 0 : i.value) === "/" ? o === "never" && a.pop() : o === "always" && a.push({ type: "pathname", value: "/" }));
825
- const c = ot([e, ...a.map((d) => d.value)]);
826
- return $t(c);
827
- }
828
- function _t(e) {
829
- if (!e)
830
- return [];
831
- e = $t(e);
832
- const n = [];
833
- if (e.slice(0, 1) === "/" && (e = e.substring(1), n.push({
834
- type: "pathname",
835
- value: "/"
836
- })), !e)
837
- return n;
838
- const t = e.split("/").filter(Boolean);
839
- return n.push(
840
- ...t.map((o) => o === "$" || o === "*" ? {
841
- type: "wildcard",
842
- value: o
843
- } : o.charAt(0) === "$" ? {
844
- type: "param",
845
- value: o
846
- } : {
847
- type: "pathname",
848
- value: decodeURI(o)
849
- })
850
- ), e.slice(-1) === "/" && (e = e.substring(1), n.push({
851
- type: "pathname",
852
- value: "/"
853
- })), n;
854
- }
855
- function kt({
856
- path: e,
857
- params: n,
858
- leaveWildcards: t,
859
- leaveParams: o,
860
- decodeCharMap: r
861
- }) {
862
- const s = _t(e), i = {};
863
- for (const [a, u] of Object.entries(n)) {
864
- const c = typeof u == "string";
865
- ["*", "_splat"].includes(a) ? i[a] = c ? encodeURI(u) : u : i[a] = c ? wn(u, r) : u;
866
- }
867
- return ot(
868
- s.map((a) => {
869
- if (a.type === "wildcard") {
870
- const u = i._splat;
871
- return t ? `${a.value}${u ?? ""}` : u;
872
- }
873
- if (a.type === "param") {
874
- if (o) {
875
- const u = i[a.value];
876
- return `${a.value}${u ?? ""}`;
877
- }
878
- return i[a.value.substring(1)] ?? "undefined";
879
- }
880
- return a.value;
881
- })
882
- );
883
- }
884
- function wn(e, n) {
885
- let t = encodeURIComponent(e);
886
- if (n)
887
- for (const [o, r] of n)
888
- t = t.replaceAll(o, r);
889
- return t;
890
- }
891
- function Ft(e, n, t) {
892
- const o = Pn(e, n, t);
893
- if (!(t.to && !o))
894
- return o ?? {};
895
- }
896
- function At(e, n, t = !1) {
897
- const o = t ? e : e.toLowerCase(), r = t ? n : n.toLowerCase();
898
- switch (!0) {
899
- case o === "/":
900
- return n;
901
- case r === o:
902
- return "";
903
- case n.length < e.length:
904
- return n;
905
- case r[o.length] !== "/":
906
- return n;
907
- case r.startsWith(o):
908
- return n.slice(e.length);
909
- default:
910
- return n;
911
- }
912
- }
913
- function Pn(e, n, t) {
914
- if (e !== "/" && !n.startsWith(e))
915
- return;
916
- n = At(e, n, t.caseSensitive);
917
- const o = At(
918
- e,
919
- `${t.to ?? "$"}`,
920
- t.caseSensitive
921
- ), r = _t(n), s = _t(o);
922
- n.startsWith("/") || r.unshift({
923
- type: "pathname",
924
- value: "/"
925
- }), o.startsWith("/") || s.unshift({
926
- type: "pathname",
927
- value: "/"
928
- });
929
- const i = {};
930
- return (() => {
931
- for (let u = 0; u < Math.max(r.length, s.length); u++) {
932
- const c = r[u], d = s[u], l = u >= r.length - 1, h = u >= s.length - 1;
933
- if (d) {
934
- if (d.type === "wildcard") {
935
- const f = decodeURI(
936
- ot(r.slice(u).map((p) => p.value))
937
- );
938
- return i["*"] = f, i._splat = f, !0;
939
- }
940
- if (d.type === "pathname") {
941
- if (d.value === "/" && !c?.value)
942
- return !0;
943
- if (c) {
944
- if (t.caseSensitive) {
945
- if (d.value !== c.value)
946
- return !1;
947
- } else if (d.value.toLowerCase() !== c.value.toLowerCase())
948
- return !1;
949
- }
950
- }
951
- if (!c)
952
- return !1;
953
- if (d.type === "param") {
954
- if (c.value === "/")
955
- return !1;
956
- c.value.charAt(0) !== "$" && (i[d.value.substring(1)] = decodeURIComponent(
957
- c.value
958
- ));
959
- }
960
- }
961
- if (!l && h)
962
- return i["**"] = ot(r.slice(u + 1).map((f) => f.value)), !!t.fuzzy && d?.value !== "/";
963
- }
964
- return !0;
965
- })() ? i : void 0;
966
- }
967
- function ct(e) {
968
- return !!e?.isRedirect;
969
- }
970
- function qt(e) {
971
- return !!e?.isRedirect && e.href;
972
- }
973
- function ce(e) {
974
- const n = e.errorComponent ?? Kt;
975
- return /* @__PURE__ */ C(
976
- bn,
977
- {
978
- getResetKey: e.getResetKey,
979
- onCatch: e.onCatch,
980
- children: ({ error: t, reset: o }) => t ? b.createElement(n, {
981
- error: t,
982
- reset: o
983
- }) : e.children
984
- }
985
- );
986
- }
987
- class bn extends b.Component {
988
- constructor() {
989
- super(...arguments), this.state = { error: null };
990
- }
991
- static getDerivedStateFromProps(n) {
992
- return { resetKey: n.getResetKey() };
993
- }
994
- static getDerivedStateFromError(n) {
995
- return { error: n };
996
- }
997
- reset() {
998
- this.setState({ error: null });
999
- }
1000
- componentDidUpdate(n, t) {
1001
- t.error && t.resetKey !== this.state.resetKey && this.reset();
1002
- }
1003
- componentDidCatch(n, t) {
1004
- this.props.onCatch && this.props.onCatch(n, t);
1005
- }
1006
- render() {
1007
- return this.props.children({
1008
- error: this.state.resetKey !== this.props.getResetKey() ? null : this.state.error,
1009
- reset: () => {
1010
- this.reset();
1011
- }
1012
- });
1013
- }
1014
- }
1015
- function Kt({ error: e }) {
1016
- const [n, t] = b.useState(!1);
1017
- return /* @__PURE__ */ te("div", { style: { padding: ".5rem", maxWidth: "100%" }, children: [
1018
- /* @__PURE__ */ te("div", { style: { display: "flex", alignItems: "center", gap: ".5rem" }, children: [
1019
- /* @__PURE__ */ C("strong", { style: { fontSize: "1rem" }, children: "Something went wrong!" }),
1020
- /* @__PURE__ */ C(
1021
- "button",
1022
- {
1023
- style: {
1024
- appearance: "none",
1025
- fontSize: ".6em",
1026
- border: "1px solid currentColor",
1027
- padding: ".1rem .2rem",
1028
- fontWeight: "bold",
1029
- borderRadius: ".25rem"
1030
- },
1031
- onClick: () => t((o) => !o),
1032
- children: n ? "Hide Error" : "Show Error"
1033
- }
1034
- )
1035
- ] }),
1036
- /* @__PURE__ */ C("div", { style: { height: ".25rem" } }),
1037
- n ? /* @__PURE__ */ C("div", { children: /* @__PURE__ */ C(
1038
- "pre",
1039
- {
1040
- style: {
1041
- fontSize: ".7em",
1042
- border: "1px solid red",
1043
- borderRadius: ".25rem",
1044
- padding: ".3rem",
1045
- color: "red",
1046
- overflow: "auto"
1047
- },
1048
- children: e.message ? /* @__PURE__ */ C("code", { children: e.message }) : null
1049
- }
1050
- ) }) : null
1051
- ] });
1052
- }
1053
- const Jt = b.createContext(null);
1054
- function Ce() {
1055
- return typeof document > "u" ? Jt : window.__TSR_ROUTER_CONTEXT__ ? window.__TSR_ROUTER_CONTEXT__ : (window.__TSR_ROUTER_CONTEXT__ = Jt, Jt);
1056
- }
1057
- function rt(e) {
1058
- const n = b.useContext(Ce());
1059
- return Mt(
1060
- !((e?.warn ?? !0) && !n),
1061
- "useRouter must be used inside a <RouterProvider> component!"
1062
- ), n;
1063
- }
1064
- function z(e) {
1065
- const n = rt({
1066
- warn: e?.router === void 0
1067
- }), t = e?.router || n, o = Te(void 0);
1068
- return an(t.__store, (r) => {
1069
- if (e?.select) {
1070
- if (e.structuralSharing ?? t.options.defaultStructuralSharing) {
1071
- const s = X(
1072
- o.current,
1073
- e.select(r)
1074
- );
1075
- return o.current = s, s;
1076
- }
1077
- return e.select(r);
1078
- }
1079
- return r;
1080
- });
1081
- }
1082
- function ro(e = {}) {
1083
- if (e.isNotFound = !0, e.throw) throw e;
1084
- return e;
1085
- }
1086
- function tt(e) {
1087
- return !!e?.isNotFound;
1088
- }
1089
- function Rn(e) {
1090
- const n = z({
1091
- select: (t) => `not-found-${t.location.pathname}-${t.status}`
1092
- });
1093
- return /* @__PURE__ */ C(
1094
- ce,
1095
- {
1096
- getResetKey: () => n,
1097
- onCatch: (t, o) => {
1098
- var r;
1099
- if (tt(t))
1100
- (r = e.onCatch) == null || r.call(e, t, o);
1101
- else
1102
- throw t;
1103
- },
1104
- errorComponent: ({ error: t }) => {
1105
- var o;
1106
- if (tt(t))
1107
- return (o = e.fallback) == null ? void 0 : o.call(e, t);
1108
- throw t;
1109
- },
1110
- children: e.children
1111
- }
1112
- );
1113
- }
1114
- function Cn() {
1115
- return /* @__PURE__ */ C("p", { children: "Not Found" });
1116
- }
1117
- const Le = [
1118
- "component",
1119
- "errorComponent",
1120
- "pendingComponent",
1121
- "notFoundComponent"
1122
- ];
1123
- function Ln(e) {
1124
- var n;
1125
- for (const t of Le)
1126
- if ((n = e.options[t]) != null && n.preload)
1127
- return !0;
1128
- return !1;
1129
- }
1130
- function Yt(e, n) {
1131
- if (e == null) return {};
1132
- if ("~standard" in e) {
1133
- const t = e["~standard"].validate(n);
1134
- if (t instanceof Promise)
1135
- throw new re("Async validation not supported");
1136
- if (t.issues)
1137
- throw new re(JSON.stringify(t.issues, void 0, 2));
1138
- return t.value;
1139
- }
1140
- return "parse" in e ? e.parse(n) : typeof e == "function" ? e(n) : {};
1141
- }
1142
- function so(e) {
1143
- return new Mn(e);
1144
- }
1145
- class Mn {
1146
- /**
1147
- * @deprecated Use the `createRouter` function instead
1148
- */
1149
- constructor(n) {
1150
- this.tempLocationKey = `${Math.round(
1151
- Math.random() * 1e7
1152
- )}`, this.resetNextScroll = !0, this.shouldViewTransition = void 0, this.isViewTransitionTypesSupported = void 0, this.subscribers = /* @__PURE__ */ new Set(), this.startReactTransition = (t) => t(), this.update = (t) => {
1153
- var o;
1154
- t.notFoundRoute && console.warn(
1155
- "The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info."
1156
- );
1157
- const r = this.options;
1158
- this.options = {
1159
- ...this.options,
1160
- ...t
1161
- }, this.isServer = this.options.isServer ?? typeof document > "u", this.pathParamsDecodeCharMap = this.options.pathParamsAllowedCharacters ? new Map(
1162
- this.options.pathParamsAllowedCharacters.map((s) => [
1163
- encodeURIComponent(s),
1164
- s
1165
- ])
1166
- ) : void 0, (!this.basepath || t.basepath && t.basepath !== r.basepath) && (t.basepath === void 0 || t.basepath === "" || t.basepath === "/" ? this.basepath = "/" : this.basepath = `/${yn(t.basepath)}`), // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1167
- (!this.history || this.options.history && this.options.history !== this.history) && (this.history = this.options.history ?? (this.isServer ? De({
1168
- initialEntries: [this.basepath || "/"]
1169
- }) : _e()), this.latestLocation = this.parseLocation()), this.options.routeTree !== this.routeTree && (this.routeTree = this.options.routeTree, this.buildRouteTree()), this.__store || (this.__store = new ne(En(this.latestLocation), {
1170
- onUpdate: () => {
1171
- this.__store.state = {
1172
- ...this.state,
1173
- cachedMatches: this.state.cachedMatches.filter(
1174
- (s) => !["redirected"].includes(s.status)
1175
- )
1176
- };
1177
- }
1178
- })), typeof window < "u" && "CSS" in window && // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
1179
- typeof ((o = window.CSS) == null ? void 0 : o.supports) == "function" && (this.isViewTransitionTypesSupported = window.CSS.supports(
1180
- "selector(:active-view-transition-type(a)"
1181
- ));
1182
- }, this.buildRouteTree = () => {
1183
- this.routesById = {}, this.routesByPath = {};
1184
- const t = this.options.notFoundRoute;
1185
- t && (t.init({
1186
- originalIndex: 99999999999,
1187
- defaultSsr: this.options.defaultSsr
1188
- }), this.routesById[t.id] = t);
1189
- const o = (i) => {
1190
- i.forEach((a, u) => {
1191
- a.init({
1192
- originalIndex: u,
1193
- defaultSsr: this.options.defaultSsr
1194
- });
1195
- const c = this.routesById[a.id];
1196
- if (et(
1197
- !c,
1198
- `Duplicate routes found with id: ${String(a.id)}`
1199
- ), this.routesById[a.id] = a, !a.isRoot && a.path) {
1200
- const l = ut(a.fullPath);
1201
- (!this.routesByPath[l] || a.fullPath.endsWith("/")) && (this.routesByPath[l] = a);
1202
- }
1203
- const d = a.children;
1204
- d?.length && o(d);
1205
- });
1206
- };
1207
- o([this.routeTree]);
1208
- const r = [];
1209
- Object.values(this.routesById).forEach((i, a) => {
1210
- var u;
1211
- if (i.isRoot || !i.path)
1212
- return;
1213
- const c = ae(i.fullPath), d = _t(c);
1214
- for (; d.length > 1 && ((u = d[0]) == null ? void 0 : u.value) === "/"; )
1215
- d.shift();
1216
- const l = d.map((h) => h.value === "/" ? 0.75 : h.type === "param" ? 0.5 : h.type === "wildcard" ? 0.25 : 1);
1217
- r.push({ child: i, trimmed: c, parsed: d, index: a, scores: l });
1218
- }), this.flatRoutes = r.sort((i, a) => {
1219
- const u = Math.min(i.scores.length, a.scores.length);
1220
- for (let c = 0; c < u; c++)
1221
- if (i.scores[c] !== a.scores[c])
1222
- return a.scores[c] - i.scores[c];
1223
- if (i.scores.length !== a.scores.length)
1224
- return a.scores.length - i.scores.length;
1225
- for (let c = 0; c < u; c++)
1226
- if (i.parsed[c].value !== a.parsed[c].value)
1227
- return i.parsed[c].value > a.parsed[c].value ? 1 : -1;
1228
- return i.index - a.index;
1229
- }).map((i, a) => (i.child.rank = a, i.child));
1230
- }, this.subscribe = (t, o) => {
1231
- const r = {
1232
- eventType: t,
1233
- fn: o
1234
- };
1235
- return this.subscribers.add(r), () => {
1236
- this.subscribers.delete(r);
1237
- };
1238
- }, this.emit = (t) => {
1239
- this.subscribers.forEach((o) => {
1240
- o.eventType === t.type && o.fn(t);
1241
- });
1242
- }, this.parseLocation = (t, o) => {
1243
- const r = ({
1244
- pathname: u,
1245
- search: c,
1246
- hash: d,
1247
- state: l
1248
- }) => {
1249
- const h = this.options.parseSearch(c), f = this.options.stringifySearch(h);
1250
- return {
1251
- pathname: u,
1252
- searchStr: f,
1253
- search: X(t?.search, h),
1254
- hash: d.split("#").reverse()[0] ?? "",
1255
- href: `${u}${f}${d}`,
1256
- state: X(t?.state, l)
1257
- };
1258
- }, s = r(o ?? this.history.location), { __tempLocation: i, __tempKey: a } = s.state;
1259
- if (i && (!a || a === this.tempLocationKey)) {
1260
- const u = r(i);
1261
- return u.state.key = s.state.key, delete u.state.__tempLocation, {
1262
- ...u,
1263
- maskedLocation: s
1264
- };
1265
- }
1266
- return s;
1267
- }, this.resolvePathWithBase = (t, o) => _n({
1268
- basepath: this.basepath,
1269
- base: t,
1270
- to: $t(o),
1271
- trailingSlash: this.options.trailingSlash,
1272
- caseSensitive: this.options.caseSensitive
1273
- }), this.getMatchedRoutes = (t, o) => {
1274
- let r = {};
1275
- const s = ut(t.pathname), i = (d) => Ft(this.basepath, s, {
1276
- to: d.fullPath,
1277
- caseSensitive: d.options.caseSensitive ?? this.options.caseSensitive,
1278
- fuzzy: !0
1279
- });
1280
- let a = o?.to !== void 0 ? this.routesByPath[o.to] : void 0;
1281
- a ? r = i(a) : a = this.flatRoutes.find((d) => {
1282
- const l = i(d);
1283
- return l ? (r = l, !0) : !1;
1284
- });
1285
- let u = a || this.routesById[H];
1286
- const c = [u];
1287
- for (; u.parentRoute; )
1288
- u = u.parentRoute, c.unshift(u);
1289
- return { matchedRoutes: c, routeParams: r, foundRoute: a };
1290
- }, this.cancelMatch = (t) => {
1291
- const o = this.getMatch(t);
1292
- o && (o.abortController.abort(), clearTimeout(o.pendingTimeout));
1293
- }, this.cancelMatches = () => {
1294
- var t;
1295
- (t = this.state.pendingMatches) == null || t.forEach((o) => {
1296
- this.cancelMatch(o.id);
1297
- });
1298
- }, this.buildLocation = (t) => {
1299
- const o = (s = {}, i) => {
1300
- var a, u, c, d, l, h;
1301
- const f = s._fromLocation ? this.matchRoutes(s._fromLocation, { _buildLocation: !0 }) : this.state.matches, p = s.from != null ? f.find(
1302
- (m) => Ft(this.basepath, ut(m.pathname), {
1303
- to: s.from,
1304
- caseSensitive: !1,
1305
- fuzzy: !1
1306
- })
1307
- ) : void 0, S = p?.pathname || this.latestLocation.pathname;
1308
- et(
1309
- s.from == null || p != null,
1310
- "Could not find match for from: " + s.from
1311
- );
1312
- const g = (a = this.state.pendingMatches) != null && a.length ? (u = Lt(this.state.pendingMatches)) == null ? void 0 : u.search : ((c = Lt(f)) == null ? void 0 : c.search) || this.latestLocation.search, M = i?.matchedRoutes.filter(
1313
- (m) => f.find((w) => w.routeId === m.id)
1314
- );
1315
- let R;
1316
- if (s.to)
1317
- R = this.resolvePathWithBase(S, `${s.to}`);
1318
- else {
1319
- const m = this.routesById[(d = M?.find((w) => {
1320
- const k = kt({
1321
- path: w.fullPath,
1322
- params: i?.routeParams ?? {},
1323
- decodeCharMap: this.pathParamsDecodeCharMap
1324
- });
1325
- return ot([this.basepath, k]) === S;
1326
- })) == null ? void 0 : d.id];
1327
- R = this.resolvePathWithBase(
1328
- S,
1329
- m?.to ?? S
1330
- );
1331
- }
1332
- const L = { ...(l = Lt(f)) == null ? void 0 : l.params };
1333
- let P = (s.params ?? !0) === !0 ? L : {
1334
- ...L,
1335
- ...lt(s.params, L)
1336
- };
1337
- Object.keys(P).length > 0 && i?.matchedRoutes.map((m) => {
1338
- var w;
1339
- return ((w = m.options.params) == null ? void 0 : w.stringify) ?? m.options.stringifyParams;
1340
- }).filter(Boolean).forEach((m) => {
1341
- P = { ...P, ...m(P) };
1342
- }), R = kt({
1343
- path: R,
1344
- params: P ?? {},
1345
- leaveWildcards: !1,
1346
- leaveParams: t.leaveParams,
1347
- decodeCharMap: this.pathParamsDecodeCharMap
1348
- });
1349
- let v = g;
1350
- if (t._includeValidateSearch && ((h = this.options.search) != null && h.strict)) {
1351
- let m = {};
1352
- i?.matchedRoutes.forEach((w) => {
1353
- try {
1354
- w.options.validateSearch && (m = {
1355
- ...m,
1356
- ...Yt(w.options.validateSearch, {
1357
- ...m,
1358
- ...v
1359
- }) ?? {}
1360
- });
1361
- } catch {
1362
- }
1363
- }), v = m;
1364
- }
1365
- v = ((m) => {
1366
- const w = i?.matchedRoutes.reduce(
1367
- (I, D) => {
1368
- var W;
1369
- const q = [];
1370
- if ("search" in D.options)
1371
- (W = D.options.search) != null && W.middlewares && q.push(...D.options.search.middlewares);
1372
- else if (D.options.preSearchFilters || D.options.postSearchFilters) {
1373
- const J = ({
1374
- search: j,
1375
- next: nt
1376
- }) => {
1377
- let O = j;
1378
- "preSearchFilters" in D.options && D.options.preSearchFilters && (O = D.options.preSearchFilters.reduce(
1379
- (V, A) => A(V),
1380
- j
1381
- ));
1382
- const K = nt(O);
1383
- return "postSearchFilters" in D.options && D.options.postSearchFilters ? D.options.postSearchFilters.reduce(
1384
- (V, A) => A(V),
1385
- K
1386
- ) : K;
1387
- };
1388
- q.push(J);
1389
- }
1390
- if (t._includeValidateSearch && D.options.validateSearch) {
1391
- const J = ({ search: j, next: nt }) => {
1392
- try {
1393
- const O = nt(j);
1394
- return {
1395
- ...O,
1396
- ...Yt(
1397
- D.options.validateSearch,
1398
- O
1399
- ) ?? {}
1400
- };
1401
- } catch {
1402
- }
1403
- };
1404
- q.push(J);
1405
- }
1406
- return I.concat(q);
1407
- },
1408
- []
1409
- ) ?? [], k = ({ search: I }) => s.search ? s.search === !0 ? I : lt(s.search, I) : {};
1410
- w.push(k);
1411
- const T = (I, D) => {
1412
- if (I >= w.length)
1413
- return D;
1414
- const W = w[I];
1415
- return W({ search: D, next: (J) => T(I + 1, J) });
1416
- };
1417
- return T(0, m);
1418
- })(v), v = X(g, v);
1419
- const F = this.options.stringifySearch(v), y = s.hash === !0 ? this.latestLocation.hash : s.hash ? lt(s.hash, this.latestLocation.hash) : void 0, _ = y ? `#${y}` : "";
1420
- let E = s.state === !0 ? this.latestLocation.state : s.state ? lt(s.state, this.latestLocation.state) : {};
1421
- return E = X(this.latestLocation.state, E), {
1422
- pathname: R,
1423
- search: v,
1424
- searchStr: F,
1425
- state: E,
1426
- hash: y ?? "",
1427
- href: `${R}${F}${_}`,
1428
- unmaskOnReload: s.unmaskOnReload
1429
- };
1430
- }, r = (s = {}, i) => {
1431
- var a;
1432
- const u = o(s);
1433
- let c = i ? o(i) : void 0;
1434
- if (!c) {
1435
- let h = {};
1436
- const f = (a = this.options.routeMasks) == null ? void 0 : a.find((p) => {
1437
- const S = Ft(this.basepath, u.pathname, {
1438
- to: p.from,
1439
- caseSensitive: !1,
1440
- fuzzy: !1
1441
- });
1442
- return S ? (h = S, !0) : !1;
1443
- });
1444
- if (f) {
1445
- const { from: p, ...S } = f;
1446
- i = {
1447
- ...oe(t, ["from"]),
1448
- ...S,
1449
- params: h
1450
- }, c = o(i);
1451
- }
1452
- }
1453
- const d = this.getMatchedRoutes(u, s), l = o(s, d);
1454
- if (c) {
1455
- const h = this.getMatchedRoutes(c, i), f = o(i, h);
1456
- l.maskedLocation = f;
1457
- }
1458
- return l;
1459
- };
1460
- return t.mask ? r(t, {
1461
- ...oe(t, ["from"]),
1462
- ...t.mask
1463
- }) : r(t);
1464
- }, this.commitLocation = ({
1465
- viewTransition: t,
1466
- ignoreBlocker: o,
1467
- ...r
1468
- }) => {
1469
- const s = () => {
1470
- r.state.key = this.latestLocation.state.key;
1471
- const u = gt(r.state, this.latestLocation.state);
1472
- return delete r.state.key, u;
1473
- }, i = this.latestLocation.href === r.href, a = this.commitLocationPromise;
1474
- if (this.commitLocationPromise = pt(() => {
1475
- a?.resolve();
1476
- }), i && s())
1477
- this.load();
1478
- else {
1479
- let { maskedLocation: u, hashScrollIntoView: c, ...d } = r;
1480
- u && (d = {
1481
- ...u,
1482
- state: {
1483
- ...u.state,
1484
- __tempKey: void 0,
1485
- __tempLocation: {
1486
- ...d,
1487
- search: d.searchStr,
1488
- state: {
1489
- ...d.state,
1490
- __tempKey: void 0,
1491
- __tempLocation: void 0,
1492
- key: void 0
1493
- }
1494
- }
1495
- }
1496
- }, (d.unmaskOnReload ?? this.options.unmaskOnReload ?? !1) && (d.state.__tempKey = this.tempLocationKey)), d.state.__hashScrollIntoViewOptions = c ?? this.options.defaultHashScrollIntoView ?? !0, this.shouldViewTransition = t, this.history[r.replace ? "replace" : "push"](
1497
- d.href,
1498
- d.state,
1499
- { ignoreBlocker: o }
1500
- );
1501
- }
1502
- return this.resetNextScroll = r.resetScroll ?? !0, this.history.subscribers.size || this.load(), this.commitLocationPromise;
1503
- }, this.buildAndCommitLocation = ({
1504
- replace: t,
1505
- resetScroll: o,
1506
- hashScrollIntoView: r,
1507
- viewTransition: s,
1508
- ignoreBlocker: i,
1509
- href: a,
1510
- ...u
1511
- } = {}) => {
1512
- if (a) {
1513
- const d = this.history.location.state.__TSR_index, l = yt(a, {
1514
- __TSR_index: t ? d : d + 1
1515
- });
1516
- u.to = l.pathname, u.search = this.options.parseSearch(l.search), u.hash = l.hash.slice(1);
1517
- }
1518
- const c = this.buildLocation({
1519
- ...u,
1520
- _includeValidateSearch: !0
1521
- });
1522
- return this.commitLocation({
1523
- ...c,
1524
- viewTransition: s,
1525
- replace: t,
1526
- resetScroll: o,
1527
- hashScrollIntoView: r,
1528
- ignoreBlocker: i
1529
- });
1530
- }, this.navigate = ({ to: t, reloadDocument: o, href: r, ...s }) => {
1531
- if (o) {
1532
- r || (r = this.buildLocation({ to: t, ...s }).href), s.replace ? window.location.replace(r) : window.location.href = r;
1533
- return;
1534
- }
1535
- return this.buildAndCommitLocation({
1536
- ...s,
1537
- href: r,
1538
- to: t
1539
- });
1540
- }, this.load = async (t) => {
1541
- this.latestLocation = this.parseLocation(this.latestLocation);
1542
- let o, r, s;
1543
- for (s = new Promise((i) => {
1544
- this.startReactTransition(async () => {
1545
- var a;
1546
- try {
1547
- const u = this.latestLocation, c = this.state.resolvedLocation, d = c.href !== u.href, l = c.pathname !== u.pathname;
1548
- this.cancelMatches();
1549
- let h;
1550
- Gt(() => {
1551
- h = this.matchRoutes(u), this.__store.setState((f) => ({
1552
- ...f,
1553
- status: "pending",
1554
- isLoading: !0,
1555
- location: u,
1556
- pendingMatches: h,
1557
- // If a cached moved to pendingMatches, remove it from cachedMatches
1558
- cachedMatches: f.cachedMatches.filter((p) => !h.find((S) => S.id === p.id))
1559
- }));
1560
- }), this.state.redirect || this.emit({
1561
- type: "onBeforeNavigate",
1562
- fromLocation: c,
1563
- toLocation: u,
1564
- pathChanged: l,
1565
- hrefChanged: d
1566
- }), this.emit({
1567
- type: "onBeforeLoad",
1568
- fromLocation: c,
1569
- toLocation: u,
1570
- pathChanged: l,
1571
- hrefChanged: d
1572
- }), await this.loadMatches({
1573
- sync: t?.sync,
1574
- matches: h,
1575
- location: u,
1576
- // eslint-disable-next-line @typescript-eslint/require-await
1577
- onReady: async () => {
1578
- this.startViewTransition(async () => {
1579
- let f, p, S;
1580
- Gt(() => {
1581
- this.__store.setState((g) => {
1582
- const M = g.matches, R = g.pendingMatches || g.matches;
1583
- return f = M.filter(
1584
- (L) => !R.find((P) => P.id === L.id)
1585
- ), p = R.filter(
1586
- (L) => !M.find((P) => P.id === L.id)
1587
- ), S = M.filter(
1588
- (L) => R.find((P) => P.id === L.id)
1589
- ), {
1590
- ...g,
1591
- isLoading: !1,
1592
- loadedAt: Date.now(),
1593
- matches: R,
1594
- pendingMatches: void 0,
1595
- cachedMatches: [
1596
- ...g.cachedMatches,
1597
- ...f.filter((L) => L.status !== "error")
1598
- ]
1599
- };
1600
- }), this.clearExpiredCache();
1601
- }), [
1602
- [f, "onLeave"],
1603
- [p, "onEnter"],
1604
- [S, "onStay"]
1605
- ].forEach(([g, M]) => {
1606
- g.forEach((R) => {
1607
- var L, P;
1608
- (P = (L = this.looseRoutesById[R.routeId].options)[M]) == null || P.call(L, R);
1609
- });
1610
- });
1611
- });
1612
- }
1613
- });
1614
- } catch (u) {
1615
- qt(u) ? (o = u, this.isServer || this.navigate({
1616
- ...o,
1617
- replace: !0,
1618
- ignoreBlocker: !0
1619
- })) : tt(u) && (r = u), this.__store.setState((c) => ({
1620
- ...c,
1621
- statusCode: o ? o.statusCode : r ? 404 : c.matches.some((d) => d.status === "error") ? 500 : 200,
1622
- redirect: o
1623
- }));
1624
- }
1625
- this.latestLoadPromise === s && ((a = this.commitLocationPromise) == null || a.resolve(), this.latestLoadPromise = void 0, this.commitLocationPromise = void 0), i();
1626
- });
1627
- }), this.latestLoadPromise = s, await s; this.latestLoadPromise && s !== this.latestLoadPromise; )
1628
- await this.latestLoadPromise;
1629
- }, this.startViewTransition = (t) => {
1630
- const o = this.shouldViewTransition ?? this.options.defaultViewTransition;
1631
- if (delete this.shouldViewTransition, o && typeof document < "u" && "startViewTransition" in document && typeof document.startViewTransition == "function") {
1632
- let r;
1633
- typeof o == "object" && this.isViewTransitionTypesSupported ? r = {
1634
- update: t,
1635
- types: o.types
1636
- } : r = t, document.startViewTransition(r);
1637
- } else
1638
- t();
1639
- }, this.updateMatch = (t, o) => {
1640
- var r;
1641
- let s;
1642
- const i = (r = this.state.pendingMatches) == null ? void 0 : r.find((d) => d.id === t), a = this.state.matches.find((d) => d.id === t), u = this.state.cachedMatches.find((d) => d.id === t), c = i ? "pendingMatches" : a ? "matches" : u ? "cachedMatches" : "";
1643
- return c && this.__store.setState((d) => {
1644
- var l;
1645
- return {
1646
- ...d,
1647
- [c]: (l = d[c]) == null ? void 0 : l.map(
1648
- (h) => h.id === t ? s = o(h) : h
1649
- )
1650
- };
1651
- }), s;
1652
- }, this.getMatch = (t) => [
1653
- ...this.state.cachedMatches,
1654
- ...this.state.pendingMatches ?? [],
1655
- ...this.state.matches
1656
- ].find((o) => o.id === t), this.loadMatches = async ({
1657
- location: t,
1658
- matches: o,
1659
- preload: r,
1660
- onReady: s,
1661
- updateMatch: i = this.updateMatch,
1662
- sync: a
1663
- }) => {
1664
- let u, c = !1;
1665
- const d = async () => {
1666
- c || (c = !0, await s?.());
1667
- }, l = (f) => !!(r && !this.state.matches.find((p) => p.id === f));
1668
- !this.isServer && !this.state.matches.length && d();
1669
- const h = (f, p) => {
1670
- var S, g, M;
1671
- if (qt(p) && !p.reloadDocument)
1672
- throw p;
1673
- if (ct(p) || tt(p)) {
1674
- if (i(f.id, (R) => ({
1675
- ...R,
1676
- status: ct(p) ? "redirected" : tt(p) ? "notFound" : "error",
1677
- isFetching: !1,
1678
- error: p,
1679
- beforeLoadPromise: void 0,
1680
- loaderPromise: void 0
1681
- })), p.routeId || (p.routeId = f.routeId), (S = f.beforeLoadPromise) == null || S.resolve(), (g = f.loaderPromise) == null || g.resolve(), (M = f.loadPromise) == null || M.resolve(), ct(p))
1682
- throw c = !0, p = this.resolveRedirect({ ...p, _fromLocation: t }), p;
1683
- if (tt(p))
1684
- throw this._handleNotFound(o, p, {
1685
- updateMatch: i
1686
- }), p;
1687
- }
1688
- };
1689
- try {
1690
- await new Promise((f, p) => {
1691
- (async () => {
1692
- var S, g, M;
1693
- try {
1694
- const R = (v, x, F) => {
1695
- var y, _;
1696
- const { id: E, routeId: m } = o[v], w = this.looseRoutesById[m];
1697
- if (x instanceof Promise)
1698
- throw x;
1699
- x.routerCode = F, u = u ?? v, h(this.getMatch(E), x);
1700
- try {
1701
- (_ = (y = w.options).onError) == null || _.call(y, x);
1702
- } catch (k) {
1703
- x = k, h(this.getMatch(E), x);
1704
- }
1705
- i(E, (k) => {
1706
- var T, I;
1707
- return (T = k.beforeLoadPromise) == null || T.resolve(), (I = k.loadPromise) == null || I.resolve(), {
1708
- ...k,
1709
- error: x,
1710
- status: "error",
1711
- isFetching: !1,
1712
- updatedAt: Date.now(),
1713
- abortController: new AbortController(),
1714
- beforeLoadPromise: void 0
1715
- };
1716
- });
1717
- };
1718
- for (const [v, { id: x, routeId: F }] of o.entries()) {
1719
- const y = this.getMatch(x), _ = (S = o[v - 1]) == null ? void 0 : S.id, E = this.looseRoutesById[F], m = E.options.pendingMs ?? this.options.defaultPendingMs, w = !!(s && !this.isServer && !l(x) && (E.options.loader || E.options.beforeLoad) && typeof m == "number" && m !== 1 / 0 && (E.options.pendingComponent ?? this.options.defaultPendingComponent));
1720
- let k = !0;
1721
- if (
1722
- // If we are in the middle of a load, either of these will be present
1723
- // (not to be confused with `loadPromise`, which is always defined)
1724
- (y.beforeLoadPromise || y.loaderPromise) && (w && setTimeout(() => {
1725
- try {
1726
- d();
1727
- } catch {
1728
- }
1729
- }, m), await y.beforeLoadPromise, k = this.getMatch(x).status !== "success"), k
1730
- ) {
1731
- try {
1732
- i(x, (N) => ({
1733
- ...N,
1734
- loadPromise: pt(() => {
1735
- var G;
1736
- (G = N.loadPromise) == null || G.resolve();
1737
- }),
1738
- beforeLoadPromise: pt()
1739
- }));
1740
- const T = new AbortController();
1741
- let I;
1742
- w && (I = setTimeout(() => {
1743
- try {
1744
- d();
1745
- } catch {
1746
- }
1747
- }, m));
1748
- const { paramsError: D, searchError: W } = this.getMatch(x);
1749
- D && R(v, D, "PARSE_PARAMS"), W && R(v, W, "VALIDATE_SEARCH");
1750
- const q = () => _ ? this.getMatch(_).context : this.options.context ?? {};
1751
- i(x, (N) => ({
1752
- ...N,
1753
- isFetching: "beforeLoad",
1754
- fetchCount: N.fetchCount + 1,
1755
- abortController: T,
1756
- pendingTimeout: I,
1757
- context: {
1758
- ...q(),
1759
- ...N.__routeContext
1760
- }
1761
- }));
1762
- const { search: J, params: j, context: nt, cause: O } = this.getMatch(x), K = l(x), V = {
1763
- search: J,
1764
- abortController: T,
1765
- params: j,
1766
- preload: K,
1767
- context: nt,
1768
- location: t,
1769
- navigate: (N) => this.navigate({ ...N, _fromLocation: t }),
1770
- buildLocation: this.buildLocation,
1771
- cause: K ? "preload" : O,
1772
- matches: o
1773
- }, A = await ((M = (g = E.options).beforeLoad) == null ? void 0 : M.call(g, V)) ?? {};
1774
- (ct(A) || tt(A)) && R(v, A, "BEFORE_LOAD"), i(x, (N) => ({
1775
- ...N,
1776
- __beforeLoadContext: A,
1777
- context: {
1778
- ...q(),
1779
- ...N.__routeContext,
1780
- ...A
1781
- },
1782
- abortController: T
1783
- }));
1784
- } catch (T) {
1785
- R(v, T, "BEFORE_LOAD");
1786
- }
1787
- i(x, (T) => {
1788
- var I;
1789
- return (I = T.beforeLoadPromise) == null || I.resolve(), {
1790
- ...T,
1791
- beforeLoadPromise: void 0,
1792
- isFetching: !1
1793
- };
1794
- });
1795
- }
1796
- }
1797
- const L = o.slice(0, u), P = [];
1798
- L.forEach(({ id: v, routeId: x }, F) => {
1799
- P.push(
1800
- (async () => {
1801
- const { loaderPromise: y } = this.getMatch(v);
1802
- let _ = !1, E = !1;
1803
- if (y) {
1804
- await y;
1805
- const m = this.getMatch(v);
1806
- m.error && h(m, m.error);
1807
- } else {
1808
- const m = P[F - 1], w = this.looseRoutesById[x], k = () => {
1809
- const {
1810
- params: O,
1811
- loaderDeps: K,
1812
- abortController: V,
1813
- context: A,
1814
- cause: N
1815
- } = this.getMatch(v), G = l(v);
1816
- return {
1817
- params: O,
1818
- deps: K,
1819
- preload: !!G,
1820
- parentMatchPromise: m,
1821
- abortController: V,
1822
- context: A,
1823
- location: t,
1824
- navigate: (Y) => this.navigate({ ...Y, _fromLocation: t }),
1825
- cause: G ? "preload" : N,
1826
- route: w
1827
- };
1828
- }, T = Date.now() - this.getMatch(v).updatedAt, I = l(v), D = I ? w.options.preloadStaleTime ?? this.options.defaultPreloadStaleTime ?? 3e4 : w.options.staleTime ?? this.options.defaultStaleTime ?? 0, W = w.options.shouldReload, q = typeof W == "function" ? W(k()) : W;
1829
- i(v, (O) => ({
1830
- ...O,
1831
- loaderPromise: pt(),
1832
- preload: !!I && !this.state.matches.find((K) => K.id === v)
1833
- }));
1834
- const J = async () => {
1835
- var O, K, V, A, N, G, Y, xt, Et;
1836
- try {
1837
- const it = async () => {
1838
- const U = this.getMatch(v);
1839
- U.minPendingPromise && await U.minPendingPromise;
1840
- };
1841
- try {
1842
- this.loadRouteChunk(w), i(v, (ft) => ({
1843
- ...ft,
1844
- isFetching: "loader"
1845
- }));
1846
- const U = await ((K = (O = w.options).loader) == null ? void 0 : K.call(O, k()));
1847
- h(
1848
- this.getMatch(v),
1849
- U
1850
- ), await w._lazyPromise, await it();
1851
- const Q = (A = (V = w.options).head) == null ? void 0 : A.call(V, {
1852
- matches: o,
1853
- match: this.getMatch(v),
1854
- params: this.getMatch(v).params,
1855
- loaderData: U
1856
- }), st = Q?.meta, at = Q?.links, wt = Q?.scripts, Pt = (G = (N = w.options).headers) == null ? void 0 : G.call(N, {
1857
- loaderData: U
1858
- });
1859
- i(v, (ft) => ({
1860
- ...ft,
1861
- error: void 0,
1862
- status: "success",
1863
- isFetching: !1,
1864
- updatedAt: Date.now(),
1865
- loaderData: U,
1866
- meta: st,
1867
- links: at,
1868
- scripts: wt,
1869
- headers: Pt
1870
- }));
1871
- } catch (U) {
1872
- let Q = U;
1873
- await it(), h(this.getMatch(v), U);
1874
- try {
1875
- (xt = (Y = w.options).onError) == null || xt.call(Y, U);
1876
- } catch (st) {
1877
- Q = st, h(
1878
- this.getMatch(v),
1879
- st
1880
- );
1881
- }
1882
- i(v, (st) => ({
1883
- ...st,
1884
- error: Q,
1885
- status: "error",
1886
- isFetching: !1
1887
- }));
1888
- }
1889
- (Et = this.serverSsr) == null || Et.onMatchSettled({
1890
- router: this,
1891
- match: this.getMatch(v)
1892
- }), await w._componentsPromise;
1893
- } catch (it) {
1894
- i(v, (U) => ({
1895
- ...U,
1896
- loaderPromise: void 0
1897
- })), h(this.getMatch(v), it);
1898
- }
1899
- }, { status: j, invalid: nt } = this.getMatch(v);
1900
- _ = j === "success" && (nt || (q ?? T > D)), I && w.options.preload === !1 || (_ && !a ? (E = !0, (async () => {
1901
- try {
1902
- await J();
1903
- const { loaderPromise: O, loadPromise: K } = this.getMatch(v);
1904
- O?.resolve(), K?.resolve(), i(v, (V) => ({
1905
- ...V,
1906
- loaderPromise: void 0
1907
- }));
1908
- } catch (O) {
1909
- qt(O) && await this.navigate(O);
1910
- }
1911
- })()) : (j !== "success" || _ && a) && await J());
1912
- }
1913
- if (!E) {
1914
- const { loaderPromise: m, loadPromise: w } = this.getMatch(v);
1915
- m?.resolve(), w?.resolve();
1916
- }
1917
- return i(v, (m) => ({
1918
- ...m,
1919
- isFetching: E ? m.isFetching : !1,
1920
- loaderPromise: E ? m.loaderPromise : void 0,
1921
- invalid: !1
1922
- })), this.getMatch(v);
1923
- })()
1924
- );
1925
- }), await Promise.all(P), f();
1926
- } catch (R) {
1927
- p(R);
1928
- }
1929
- })();
1930
- }), await d();
1931
- } catch (f) {
1932
- if (ct(f) || tt(f))
1933
- throw tt(f) && !r && await d(), f;
1934
- }
1935
- return o;
1936
- }, this.invalidate = (t) => {
1937
- const o = (r) => {
1938
- var s;
1939
- return ((s = t?.filter) == null ? void 0 : s.call(t, r)) ?? !0 ? {
1940
- ...r,
1941
- invalid: !0,
1942
- ...r.status === "error" ? { status: "pending", error: void 0 } : {}
1943
- } : r;
1944
- };
1945
- return this.__store.setState((r) => {
1946
- var s;
1947
- return {
1948
- ...r,
1949
- matches: r.matches.map(o),
1950
- cachedMatches: r.cachedMatches.map(o),
1951
- pendingMatches: (s = r.pendingMatches) == null ? void 0 : s.map(o)
1952
- };
1953
- }), this.load({ sync: t?.sync });
1954
- }, this.resolveRedirect = (t) => {
1955
- const o = t;
1956
- return o.href || (o.href = this.buildLocation(o).href), o;
1957
- }, this.clearCache = (t) => {
1958
- const o = t?.filter;
1959
- o !== void 0 ? this.__store.setState((r) => ({
1960
- ...r,
1961
- cachedMatches: r.cachedMatches.filter(
1962
- (s) => !o(s)
1963
- )
1964
- })) : this.__store.setState((r) => ({
1965
- ...r,
1966
- cachedMatches: []
1967
- }));
1968
- }, this.clearExpiredCache = () => {
1969
- const t = (o) => {
1970
- const r = this.looseRoutesById[o.routeId];
1971
- if (!r.options.loader)
1972
- return !0;
1973
- const s = (o.preload ? r.options.preloadGcTime ?? this.options.defaultPreloadGcTime : r.options.gcTime ?? this.options.defaultGcTime) ?? 5 * 60 * 1e3;
1974
- return !(o.status !== "error" && Date.now() - o.updatedAt < s);
1975
- };
1976
- this.clearCache({ filter: t });
1977
- }, this.loadRouteChunk = (t) => (t._lazyPromise === void 0 && (t.lazyFn ? t._lazyPromise = t.lazyFn().then((o) => {
1978
- const { id: r, ...s } = o.options;
1979
- Object.assign(t.options, s);
1980
- }) : t._lazyPromise = Promise.resolve()), t._componentsPromise === void 0 && (t._componentsPromise = t._lazyPromise.then(
1981
- () => Promise.all(
1982
- Le.map(async (o) => {
1983
- const r = t.options[o];
1984
- r?.preload && await r.preload();
1985
- })
1986
- )
1987
- )), t._componentsPromise), this.preloadRoute = async (t) => {
1988
- const o = this.buildLocation(t);
1989
- let r = this.matchRoutes(o, {
1990
- throwOnError: !0,
1991
- preload: !0,
1992
- dest: t
1993
- });
1994
- const s = new Set(
1995
- [...this.state.matches, ...this.state.pendingMatches ?? []].map(
1996
- (a) => a.id
1997
- )
1998
- ), i = /* @__PURE__ */ new Set([
1999
- ...s,
2000
- ...this.state.cachedMatches.map((a) => a.id)
2001
- ]);
2002
- Gt(() => {
2003
- r.forEach((a) => {
2004
- i.has(a.id) || this.__store.setState((u) => ({
2005
- ...u,
2006
- cachedMatches: [...u.cachedMatches, a]
2007
- }));
2008
- });
2009
- });
2010
- try {
2011
- return r = await this.loadMatches({
2012
- matches: r,
2013
- location: o,
2014
- preload: !0,
2015
- updateMatch: (a, u) => {
2016
- s.has(a) ? r = r.map((c) => c.id === a ? u(c) : c) : this.updateMatch(a, u);
2017
- }
2018
- }), r;
2019
- } catch (a) {
2020
- if (ct(a))
2021
- return a.reloadDocument ? void 0 : await this.preloadRoute({
2022
- ...a,
2023
- _fromLocation: o
2024
- });
2025
- console.error(a);
2026
- return;
2027
- }
2028
- }, this.matchRoute = (t, o) => {
2029
- const r = {
2030
- ...t,
2031
- to: t.to ? this.resolvePathWithBase(
2032
- t.from || "",
2033
- t.to
2034
- ) : void 0,
2035
- params: t.params || {},
2036
- leaveParams: !0
2037
- }, s = this.buildLocation(r);
2038
- if (o?.pending && this.state.status !== "pending")
2039
- return !1;
2040
- const a = (o?.pending === void 0 ? !this.state.isLoading : o.pending) ? this.latestLocation : this.state.resolvedLocation, u = Ft(this.basepath, a.pathname, {
2041
- ...o,
2042
- to: s.pathname
2043
- });
2044
- return !u || t.params && !gt(u, t.params, { partial: !0 }) ? !1 : u && (o?.includeSearch ?? !0) ? gt(a.search, s.search, { partial: !0 }) ? u : !1 : u;
2045
- }, this._handleNotFound = (t, o, {
2046
- updateMatch: r = this.updateMatch
2047
- } = {}) => {
2048
- const s = Object.fromEntries(
2049
- t.map((u) => [u.routeId, u])
2050
- );
2051
- let i = (o.global ? this.looseRoutesById[H] : this.looseRoutesById[o.routeId]) || this.looseRoutesById[H];
2052
- for (; !i.options.notFoundComponent && !this.options.defaultNotFoundComponent && i.id !== H; )
2053
- i = i.parentRoute, et(
2054
- i,
2055
- "Found invalid route tree while trying to find not-found handler."
2056
- );
2057
- const a = s[i.id];
2058
- et(a, "Could not find match for route: " + i.id), r(a.id, (u) => ({
2059
- ...u,
2060
- status: "notFound",
2061
- error: o,
2062
- isFetching: !1
2063
- })), o.routerCode === "BEFORE_LOAD" && i.parentRoute && (o.routeId = i.parentRoute.id, this._handleNotFound(t, o, {
2064
- updateMatch: r
2065
- }));
2066
- }, this.hasNotFoundMatch = () => this.__store.state.matches.some(
2067
- (t) => t.status === "notFound" || t.globalNotFound
2068
- ), this.update({
2069
- defaultPreloadDelay: 50,
2070
- defaultPendingMs: 1e3,
2071
- defaultPendingMinMs: 500,
2072
- context: void 0,
2073
- ...n,
2074
- caseSensitive: n.caseSensitive ?? !1,
2075
- notFoundMode: n.notFoundMode ?? "fuzzy",
2076
- stringifySearch: n.stringifySearch ?? hn,
2077
- parseSearch: n.parseSearch ?? dn
2078
- }), typeof document < "u" && (window.__TSR_ROUTER__ = this);
2079
- }
2080
- get state() {
2081
- return this.__store.state;
2082
- }
2083
- get looseRoutesById() {
2084
- return this.routesById;
2085
- }
2086
- matchRoutes(n, t, o) {
2087
- return typeof n == "string" ? this.matchRoutesInternal(
2088
- {
2089
- pathname: n,
2090
- search: t
2091
- },
2092
- o
2093
- ) : this.matchRoutesInternal(n, t);
2094
- }
2095
- matchRoutesInternal(n, t) {
2096
- const { foundRoute: o, matchedRoutes: r, routeParams: s } = this.getMatchedRoutes(
2097
- n,
2098
- t?.dest
2099
- );
2100
- let i = !1;
2101
- // If we found a route, and it's not an index route and we have left over path
2102
- (o ? o.path !== "/" && s["**"] : (
2103
- // Or if we didn't find a route and we have left over path
2104
- ut(n.pathname)
2105
- )) && (this.options.notFoundRoute ? r.push(this.options.notFoundRoute) : i = !0);
2106
- const a = (() => {
2107
- if (i) {
2108
- if (this.options.notFoundMode !== "root")
2109
- for (let l = r.length - 1; l >= 0; l--) {
2110
- const h = r[l];
2111
- if (h.children)
2112
- return h.id;
2113
- }
2114
- return H;
2115
- }
2116
- })(), u = r.map((l) => {
2117
- var h;
2118
- let f;
2119
- const p = ((h = l.options.params) == null ? void 0 : h.parse) ?? l.options.parseParams;
2120
- if (p)
2121
- try {
2122
- const S = p(s);
2123
- Object.assign(s, S);
2124
- } catch (S) {
2125
- if (f = new xn(S.message, {
2126
- cause: S
2127
- }), t?.throwOnError)
2128
- throw f;
2129
- return f;
2130
- }
2131
- }), c = [], d = (l) => l?.id ? l.context ?? this.options.context ?? {} : this.options.context ?? {};
2132
- return r.forEach((l, h) => {
2133
- var f, p, S, g;
2134
- const M = c[h - 1], [R, L] = (() => {
2135
- const k = M?.search ?? n.search;
2136
- try {
2137
- const T = Yt(l.options.validateSearch, k) ?? {};
2138
- return [
2139
- {
2140
- ...k,
2141
- ...T
2142
- },
2143
- void 0
2144
- ];
2145
- } catch (T) {
2146
- const I = new re(T.message, {
2147
- cause: T
2148
- });
2149
- if (t?.throwOnError)
2150
- throw I;
2151
- return [k, I];
2152
- }
2153
- })(), P = ((p = (f = l.options).loaderDeps) == null ? void 0 : p.call(f, {
2154
- search: R
2155
- })) ?? "", v = P ? JSON.stringify(P) : "", x = kt({
2156
- path: l.fullPath,
2157
- params: s,
2158
- decodeCharMap: this.pathParamsDecodeCharMap
2159
- }), F = kt({
2160
- path: l.id,
2161
- params: s,
2162
- leaveWildcards: !0,
2163
- decodeCharMap: this.pathParamsDecodeCharMap
2164
- }) + v, y = this.getMatch(F), _ = this.state.matches.find(
2165
- (k) => k.routeId === l.id
2166
- ), E = _ ? "stay" : "enter";
2167
- let m;
2168
- if (y)
2169
- m = {
2170
- ...y,
2171
- cause: E,
2172
- params: _ ? X(_.params, s) : s,
2173
- search: X(_ ? _.search : y.search, R)
2174
- };
2175
- else {
2176
- const k = l.options.loader || l.options.beforeLoad || l.lazyFn || Ln(l) ? "pending" : "success";
2177
- m = {
2178
- id: F,
2179
- index: h,
2180
- routeId: l.id,
2181
- params: _ ? X(_.params, s) : s,
2182
- pathname: ot([this.basepath, x]),
2183
- updatedAt: Date.now(),
2184
- search: _ ? X(_.search, R) : R,
2185
- searchError: void 0,
2186
- status: k,
2187
- isFetching: !1,
2188
- error: void 0,
2189
- paramsError: u[h],
2190
- __routeContext: {},
2191
- __beforeLoadContext: {},
2192
- context: {},
2193
- abortController: new AbortController(),
2194
- fetchCount: 0,
2195
- cause: E,
2196
- loaderDeps: _ ? X(_.loaderDeps, P) : P,
2197
- invalid: !1,
2198
- preload: !1,
2199
- links: void 0,
2200
- scripts: void 0,
2201
- meta: void 0,
2202
- staticData: l.options.staticData || {},
2203
- loadPromise: pt(),
2204
- fullPath: l.fullPath
2205
- };
2206
- }
2207
- m.status === "success" && (m.headers = (g = (S = l.options).headers) == null ? void 0 : g.call(S, {
2208
- loaderData: m.loaderData
2209
- })), t?.preload || (m.globalNotFound = a === l.id), m.searchError = L;
2210
- const w = d(M);
2211
- m.context = {
2212
- ...w,
2213
- ...m.__routeContext,
2214
- ...m.__beforeLoadContext
2215
- }, c.push(m);
2216
- }), c.forEach((l, h) => {
2217
- var f, p, S, g;
2218
- const M = this.looseRoutesById[l.routeId];
2219
- if (!this.getMatch(l.id) && t?._buildLocation !== !0) {
2220
- const P = c[h - 1], v = d(P), x = {
2221
- deps: l.loaderDeps,
2222
- params: l.params,
2223
- context: v,
2224
- location: n,
2225
- navigate: (F) => this.navigate({ ...F, _fromLocation: n }),
2226
- buildLocation: this.buildLocation,
2227
- cause: l.cause,
2228
- abortController: l.abortController,
2229
- preload: !!l.preload,
2230
- matches: c
2231
- };
2232
- l.__routeContext = ((p = (f = M.options).context) == null ? void 0 : p.call(f, x)) ?? {}, l.context = {
2233
- ...v,
2234
- ...l.__routeContext,
2235
- ...l.__beforeLoadContext
2236
- };
2237
- }
2238
- const L = (g = (S = M.options).head) == null ? void 0 : g.call(S, {
2239
- matches: c,
2240
- match: l,
2241
- params: l.params,
2242
- loaderData: l.loaderData ?? void 0
2243
- });
2244
- l.links = L?.links, l.scripts = L?.scripts, l.meta = L?.meta;
2245
- }), c;
2246
- }
2247
- }
2248
- class re extends Error {
2249
- }
2250
- class xn extends Error {
2251
- }
2252
- function En(e) {
2253
- return {
2254
- loadedAt: 0,
2255
- isLoading: !1,
2256
- isTransitioning: !1,
2257
- status: "idle",
2258
- resolvedLocation: { ...e },
2259
- location: e,
2260
- matches: [],
2261
- pendingMatches: [],
2262
- cachedMatches: [],
2263
- statusCode: 200
2264
- };
2265
- }
2266
- const Ut = b.createContext(void 0), In = b.createContext(
2267
- void 0
2268
- );
2269
- function ht(e) {
2270
- const n = b.useContext(
2271
- e.from ? In : Ut
2272
- );
2273
- return z({
2274
- select: (o) => {
2275
- const r = o.matches.find(
2276
- (s) => e.from ? e.from === s.routeId : s.id === n
2277
- );
2278
- if (et(
2279
- !((e.shouldThrow ?? !0) && !r),
2280
- `Could not find ${e.from ? `an active match from "${e.from}"` : "a nearest match!"}`
2281
- ), r !== void 0)
2282
- return e.select ? e.select(r) : r;
2283
- },
2284
- structuralSharing: e.structuralSharing
2285
- });
2286
- }
2287
- function kn(e) {
2288
- return ht({
2289
- from: e.from,
2290
- strict: e.strict,
2291
- structuralSharing: e.structuralSharing,
2292
- select: (n) => e.select ? e.select(n.loaderData) : n.loaderData
2293
- });
2294
- }
2295
- function Fn(e) {
2296
- const { select: n, ...t } = e;
2297
- return ht({
2298
- ...t,
2299
- select: (o) => n ? n(o.loaderDeps) : o.loaderDeps
2300
- });
2301
- }
2302
- function Tn(e) {
2303
- return ht({
2304
- from: e.from,
2305
- strict: e.strict,
2306
- structuralSharing: e.structuralSharing,
2307
- select: (n) => e.select ? e.select(n.params) : n.params
2308
- });
2309
- }
2310
- function Bn(e) {
2311
- return ht({
2312
- from: e.from,
2313
- strict: e.strict,
2314
- structuralSharing: e.structuralSharing,
2315
- select: (n) => e.select ? e.select(n.search) : n.search
2316
- });
2317
- }
2318
- function Dn(e) {
2319
- const { navigate: n } = rt();
2320
- return b.useCallback(
2321
- (t) => n({
2322
- ...t
2323
- }),
2324
- [n]
2325
- );
2326
- }
2327
- class Me {
2328
- /**
2329
- * @deprecated Use the `createRoute` function instead.
2330
- */
2331
- constructor(n) {
2332
- this.init = (t) => {
2333
- var o, r;
2334
- this.originalIndex = t.originalIndex;
2335
- const s = this.options, i = !s?.path && !s?.id;
2336
- this.parentRoute = (r = (o = this.options).getParentRoute) == null ? void 0 : r.call(o), i ? this._path = H : et(
2337
- this.parentRoute,
2338
- "Child Route instances must pass a 'getParentRoute: () => ParentRoute' option that returns a Route instance."
2339
- );
2340
- let a = i ? H : s.path;
2341
- a && a !== "/" && (a = ae(a));
2342
- const u = s?.id || a;
2343
- let c = i ? H : ot([
2344
- this.parentRoute.id === H ? "" : this.parentRoute.id,
2345
- u
2346
- ]);
2347
- a === H && (a = "/"), c !== H && (c = ot(["/", c]));
2348
- const d = c === H ? "/" : ot([this.parentRoute.fullPath, a]);
2349
- this._path = a, this._id = c, this._fullPath = d, this._to = d, this._ssr = s?.ssr ?? t.defaultSsr ?? !0;
2350
- }, this.updateLoader = (t) => (Object.assign(this.options, t), this), this.update = (t) => (Object.assign(this.options, t), this), this.lazy = (t) => (this.lazyFn = t, this), this.useMatch = (t) => ht({
2351
- select: t?.select,
2352
- from: this.id,
2353
- structuralSharing: t?.structuralSharing
2354
- }), this.useRouteContext = (t) => ht({
2355
- ...t,
2356
- from: this.id,
2357
- select: (o) => t?.select ? t.select(o.context) : o.context
2358
- }), this.useSearch = (t) => Bn({
2359
- select: t?.select,
2360
- structuralSharing: t?.structuralSharing,
2361
- from: this.id
2362
- }), this.useParams = (t) => Tn({
2363
- select: t?.select,
2364
- structuralSharing: t?.structuralSharing,
2365
- from: this.id
2366
- }), this.useLoaderDeps = (t) => Fn({ ...t, from: this.id }), this.useLoaderData = (t) => kn({ ...t, from: this.id }), this.useNavigate = () => Dn({ from: this.id }), this.options = n || {}, this.isRoot = !n?.getParentRoute, et(
2367
- !(n?.id && n?.path),
2368
- "Route cannot have both an 'id' and a 'path' option."
2369
- ), this.$$typeof = Symbol.for("react.memo");
2370
- }
2371
- get to() {
2372
- return this._to;
2373
- }
2374
- get id() {
2375
- return this._id;
2376
- }
2377
- get path() {
2378
- return this._path;
2379
- }
2380
- get fullPath() {
2381
- return this._fullPath;
2382
- }
2383
- get ssr() {
2384
- return this._ssr;
2385
- }
2386
- addChildren(n) {
2387
- return this._addFileChildren(n);
2388
- }
2389
- _addFileChildren(n) {
2390
- return Array.isArray(n) && (this.children = n), typeof n == "object" && n !== null && (this.children = Object.values(n)), this;
2391
- }
2392
- }
2393
- function On(e) {
2394
- return new Me(e);
2395
- }
2396
- function io() {
2397
- return (e) => An(e);
2398
- }
2399
- class Vn extends Me {
2400
- /**
2401
- * @deprecated `RootRoute` is now an internal implementation detail. Use `createRootRoute()` instead.
2402
- */
2403
- constructor(n) {
2404
- super(n);
2405
- }
2406
- addChildren(n) {
2407
- return super.addChildren(n), this;
2408
- }
2409
- _addFileChildren(n) {
2410
- return super._addFileChildren(n), this;
2411
- }
2412
- _addFileTypes() {
2413
- return this;
2414
- }
2415
- }
2416
- function An(e) {
2417
- return new Vn(e);
2418
- }
2419
- function ao(e) {
2420
- return new Nn(e, {
2421
- silent: !0
2422
- }).createRoute;
2423
- }
2424
- class Nn {
2425
- constructor(n, t) {
2426
- this.path = n, this.createRoute = (o) => {
2427
- Mt(
2428
- this.silent,
2429
- "FileRoute is deprecated and will be removed in the next major version. Use the createFileRoute(path)(options) function instead."
2430
- );
2431
- const r = On(o);
2432
- return r.isRoot = !1, r;
2433
- }, this.silent = t?.silent;
2434
- }
2435
- }
2436
- function Bt(e) {
2437
- return /* @__PURE__ */ C(Fe, { children: e.children });
2438
- }
2439
- function xe(e, n, t) {
2440
- return n.options.notFoundComponent ? /* @__PURE__ */ C(n.options.notFoundComponent, { data: t }) : e.options.defaultNotFoundComponent ? /* @__PURE__ */ C(e.options.defaultNotFoundComponent, { data: t }) : /* @__PURE__ */ C(Cn, {});
2441
- }
2442
- const Ee = b.memo(function({
2443
- matchId: n
2444
- }) {
2445
- var t, o;
2446
- const r = rt(), s = z({
2447
- select: (g) => {
2448
- var M;
2449
- return (M = g.matches.find((R) => R.id === n)) == null ? void 0 : M.routeId;
2450
- }
2451
- });
2452
- et(
2453
- s,
2454
- `Could not find routeId for matchId "${n}". Please file an issue!`
2455
- );
2456
- const i = r.routesById[s], a = i.options.pendingComponent ?? r.options.defaultPendingComponent, u = a ? /* @__PURE__ */ C(a, {}) : null, c = i.options.errorComponent ?? r.options.defaultErrorComponent, d = i.options.onCatch ?? r.options.defaultOnCatch, l = i.isRoot ? (
2457
- // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component
2458
- i.options.notFoundComponent ?? ((t = r.options.notFoundRoute) == null ? void 0 : t.options.component)
2459
- ) : i.options.notFoundComponent, h = (
2460
- // If we're on the root route, allow forcefully wrapping in suspense
2461
- (!i.isRoot || i.options.wrapInSuspense) && (i.options.wrapInSuspense ?? a ?? ((o = i.options.errorComponent) == null ? void 0 : o.preload)) ? b.Suspense : Bt
2462
- ), f = c ? ce : Bt, p = l ? Rn : Bt, S = z({
2463
- select: (g) => g.loadedAt
2464
- });
2465
- return /* @__PURE__ */ C(Ut.Provider, { value: n, children: /* @__PURE__ */ C(h, { fallback: u, children: /* @__PURE__ */ C(
2466
- f,
2467
- {
2468
- getResetKey: () => S,
2469
- errorComponent: c || Kt,
2470
- onCatch: (g, M) => {
2471
- if (tt(g)) throw g;
2472
- Mt(!1, `Error in route match: ${n}`), d?.(g, M);
2473
- },
2474
- children: /* @__PURE__ */ C(
2475
- p,
2476
- {
2477
- fallback: (g) => {
2478
- if (!l || g.routeId && g.routeId !== s || !g.routeId && !i.isRoot)
2479
- throw g;
2480
- return b.createElement(l, g);
2481
- },
2482
- children: /* @__PURE__ */ C($n, { matchId: n })
2483
- }
2484
- )
2485
- }
2486
- ) }) });
2487
- }), $n = b.memo(function({
2488
- matchId: n
2489
- }) {
2490
- var t, o, r;
2491
- const s = rt(), { match: i, matchIndex: a, routeId: u } = z({
2492
- select: (h) => {
2493
- const f = h.matches.findIndex((g) => g.id === n), p = h.matches[f];
2494
- return {
2495
- routeId: p.routeId,
2496
- matchIndex: f,
2497
- match: oe(p, ["id", "status", "error"])
2498
- };
2499
- },
2500
- structuralSharing: !0
2501
- }), c = s.routesById[u], d = b.useMemo(() => {
2502
- const h = c.options.component ?? s.options.defaultComponent;
2503
- return h ? /* @__PURE__ */ C(h, {}) : /* @__PURE__ */ C(Kn, {});
2504
- }, [c.options.component, s.options.defaultComponent]), l = (c.options.errorComponent ?? s.options.defaultErrorComponent) || Kt;
2505
- if (i.status === "notFound")
2506
- return et(tt(i.error), "Expected a notFound error"), xe(s, c, i.error);
2507
- if (i.status === "redirected")
2508
- throw et(ct(i.error), "Expected a redirect error"), (t = s.getMatch(i.id)) == null ? void 0 : t.loadPromise;
2509
- if (i.status === "error") {
2510
- if (s.isServer)
2511
- return /* @__PURE__ */ C(
2512
- l,
2513
- {
2514
- error: i.error,
2515
- info: {
2516
- componentStack: ""
2517
- }
2518
- }
2519
- );
2520
- throw i.error;
2521
- }
2522
- if (i.status === "pending") {
2523
- const h = c.options.pendingMinMs ?? s.options.defaultPendingMinMs;
2524
- if (h && !((o = s.getMatch(i.id)) != null && o.minPendingPromise) && !s.isServer) {
2525
- const f = pt();
2526
- Promise.resolve().then(() => {
2527
- s.updateMatch(i.id, (p) => ({
2528
- ...p,
2529
- minPendingPromise: f
2530
- }));
2531
- }), setTimeout(() => {
2532
- f.resolve(), s.updateMatch(i.id, (p) => ({
2533
- ...p,
2534
- minPendingPromise: void 0
2535
- }));
2536
- }, h);
2537
- }
2538
- throw (r = s.getMatch(i.id)) == null ? void 0 : r.loadPromise;
2539
- }
2540
- return d;
2541
- }), Kn = b.memo(function() {
2542
- const n = rt(), t = b.useContext(Ut), o = z({
2543
- select: (c) => {
2544
- var d;
2545
- return (d = c.matches.find((l) => l.id === t)) == null ? void 0 : d.routeId;
2546
- }
2547
- }), r = n.routesById[o], s = z({
2548
- select: (c) => {
2549
- const l = c.matches.find((h) => h.id === t);
2550
- return et(
2551
- l,
2552
- `Could not find parent match for matchId "${t}"`
2553
- ), l.globalNotFound;
2554
- }
2555
- }), i = z({
2556
- select: (c) => {
2557
- var d;
2558
- const l = c.matches, h = l.findIndex((f) => f.id === t);
2559
- return (d = l[h + 1]) == null ? void 0 : d.id;
2560
- }
2561
- });
2562
- if (s)
2563
- return xe(n, r, void 0);
2564
- if (!i)
2565
- return null;
2566
- const a = /* @__PURE__ */ C(Ee, { matchId: i }), u = n.options.defaultPendingComponent ? /* @__PURE__ */ C(n.options.defaultPendingComponent, {}) : null;
2567
- return t === H ? /* @__PURE__ */ C(b.Suspense, { fallback: u, children: a }) : a;
2568
- }), Un = "Error preloading route! ☝️";
2569
- function zn(e, n) {
2570
- const t = rt(), [o, r] = b.useState(!1), s = b.useRef(!1), i = gn(n), {
2571
- // custom props
2572
- activeProps: a = () => ({ className: "active" }),
2573
- inactiveProps: u = () => ({}),
2574
- activeOptions: c,
2575
- to: d,
2576
- preload: l,
2577
- preloadDelay: h,
2578
- hashScrollIntoView: f,
2579
- replace: p,
2580
- startTransition: S,
2581
- resetScroll: g,
2582
- viewTransition: M,
2583
- // element props
2584
- children: R,
2585
- target: L,
2586
- disabled: P,
2587
- style: v,
2588
- className: x,
2589
- onClick: F,
2590
- onFocus: y,
2591
- onMouseEnter: _,
2592
- onMouseLeave: E,
2593
- onTouchStart: m,
2594
- ignoreBlocker: w,
2595
- ...k
2596
- } = e, {
2597
- // prevent these from being returned
2598
- params: T,
2599
- search: I,
2600
- hash: D,
2601
- state: W,
2602
- mask: q,
2603
- reloadDocument: J,
2604
- ...j
2605
- } = k, nt = b.useMemo(() => {
2606
- try {
2607
- return new URL(`${d}`), "external";
2608
- } catch {
2609
- }
2610
- return "internal";
2611
- }, [d]), O = z({
2612
- select: (B) => B.location.search,
2613
- structuralSharing: !0
2614
- });
2615
- e = {
2616
- from: ht({ strict: !1, select: (B) => B.pathname }),
2617
- ...e
2618
- };
2619
- const V = b.useMemo(
2620
- () => t.buildLocation(e),
2621
- [t, e, O]
2622
- ), A = b.useMemo(() => e.reloadDocument ? !1 : l ?? t.options.defaultPreload, [t.options.defaultPreload, l, e.reloadDocument]), N = h ?? t.options.defaultPreloadDelay ?? 0, G = z({
2623
- select: (B) => {
2624
- if (c?.exact) {
2625
- if (!Sn(
2626
- B.location.pathname,
2627
- V.pathname,
2628
- t.basepath
2629
- ))
2630
- return !1;
2631
- } else {
2632
- const $ = Vt(
2633
- B.location.pathname,
2634
- t.basepath
2635
- ).split("/");
2636
- if (!Vt(
2637
- V.pathname,
2638
- t.basepath
2639
- ).split("/").every(
2640
- (Ie, ke) => Ie === $[ke]
2641
- ))
2642
- return !1;
2643
- }
2644
- return (c?.includeSearch ?? !0) && !gt(B.location.search, V.search, {
2645
- partial: !c?.exact,
2646
- ignoreUndefined: !c?.explicitUndefined
2647
- }) ? !1 : c?.includeHash ? B.location.hash === V.hash : !0;
2648
- }
2649
- }), Y = b.useCallback(() => {
2650
- t.preloadRoute(e).catch((B) => {
2651
- console.warn(B), console.warn(Un);
2652
- });
2653
- }, [e, t]), xt = b.useCallback(
2654
- (B) => {
2655
- B?.isIntersecting && Y();
2656
- },
2657
- [Y]
2658
- );
2659
- if (vn(
2660
- i,
2661
- xt,
2662
- { rootMargin: "100px" },
2663
- { disabled: !!P || A !== "viewport" }
2664
- ), Rt(() => {
2665
- s.current || !P && A === "render" && (Y(), s.current = !0);
2666
- }, [P, Y, A]), nt === "external")
2667
- return {
2668
- ...j,
2669
- ref: i,
2670
- type: nt,
2671
- href: d,
2672
- ...R && { children: R },
2673
- ...L && { target: L },
2674
- ...P && { disabled: P },
2675
- ...v && { style: v },
2676
- ...x && { className: x },
2677
- ...F && { onClick: F },
2678
- ...y && { onFocus: y },
2679
- ..._ && { onMouseEnter: _ },
2680
- ...E && { onMouseLeave: E },
2681
- ...m && { onTouchStart: m }
2682
- };
2683
- const Et = (B) => {
2684
- if (!P && !Wn(B) && !B.defaultPrevented && (!L || L === "_self") && B.button === 0) {
2685
- B.preventDefault(), Be(() => {
2686
- r(!0);
2687
- });
2688
- const $ = t.subscribe("onResolved", () => {
2689
- $(), r(!1);
2690
- });
2691
- return t.navigate({
2692
- ...e,
2693
- replace: p,
2694
- resetScroll: g,
2695
- hashScrollIntoView: f,
2696
- startTransition: S,
2697
- viewTransition: M,
2698
- ignoreBlocker: w
2699
- });
2700
- }
2701
- }, it = (B) => {
2702
- P || A && Y();
2703
- }, U = it, Q = (B) => {
2704
- if (P) return;
2705
- const $ = B.target || {};
2706
- if (A) {
2707
- if ($.preloadTimeout)
2708
- return;
2709
- $.preloadTimeout = setTimeout(() => {
2710
- $.preloadTimeout = null, Y();
2711
- }, N);
2712
- }
2713
- }, st = (B) => {
2714
- if (P) return;
2715
- const $ = B.target || {};
2716
- $.preloadTimeout && (clearTimeout($.preloadTimeout), $.preloadTimeout = null);
2717
- }, at = (B) => ($) => {
2718
- var zt;
2719
- (zt = $.persist) == null || zt.call($), B.filter(Boolean).forEach((ue) => {
2720
- $.defaultPrevented || ue($);
2721
- });
2722
- }, wt = G ? lt(a, {}) ?? {} : {}, Pt = G ? {} : lt(u, {}), ft = [
2723
- x,
2724
- wt.className,
2725
- Pt.className
2726
- ].filter(Boolean).join(" "), le = {
2727
- ...v,
2728
- ...wt.style,
2729
- ...Pt.style
2730
- };
2731
- return {
2732
- ...j,
2733
- ...wt,
2734
- ...Pt,
2735
- href: P ? void 0 : V.maskedLocation ? t.history.createHref(V.maskedLocation.href) : t.history.createHref(V.href),
2736
- ref: i,
2737
- onClick: at([F, Et]),
2738
- onFocus: at([y, it]),
2739
- onMouseEnter: at([_, Q]),
2740
- onMouseLeave: at([E, st]),
2741
- onTouchStart: at([m, U]),
2742
- disabled: !!P,
2743
- target: L,
2744
- ...Object.keys(le).length && { style: le },
2745
- ...ft && { className: ft },
2746
- ...P && {
2747
- role: "link",
2748
- "aria-disabled": !0
2749
- },
2750
- ...G && { "data-status": "active", "aria-current": "page" },
2751
- ...o && { "data-transitioning": "transitioning" }
2752
- };
2753
- }
2754
- const co = b.forwardRef(
2755
- (e, n) => {
2756
- const { _asChild: t, ...o } = e, {
2757
- type: r,
2758
- ref: s,
2759
- ...i
2760
- } = zn(o, n), a = typeof o.children == "function" ? o.children({
2761
- isActive: i["data-status"] === "active"
2762
- }) : o.children;
2763
- return typeof t > "u" && delete i.disabled, b.createElement(
2764
- t || "a",
2765
- {
2766
- ...i,
2767
- ref: s
2768
- },
2769
- a
2770
- );
2771
- }
2772
- );
2773
- function Wn(e) {
2774
- return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
2775
- }
2776
- function Hn() {
2777
- const e = rt(), n = b.useRef({ router: e, mounted: !1 }), t = z({
2778
- select: ({ isLoading: l }) => l
2779
- }), [o, r] = b.useState(!1), s = z({
2780
- select: (l) => l.matches.some((h) => h.status === "pending"),
2781
- structuralSharing: !0
2782
- }), i = Xt(t), a = t || o || s, u = Xt(a), c = t || s, d = Xt(c);
2783
- return e.isServer || (e.startReactTransition = (l) => {
2784
- r(!0), b.startTransition(() => {
2785
- l(), r(!1);
2786
- });
2787
- }), b.useEffect(() => {
2788
- const l = e.history.subscribe(e.load), h = e.buildLocation({
2789
- to: e.latestLocation.pathname,
2790
- search: !0,
2791
- params: !0,
2792
- hash: !0,
2793
- state: !0,
2794
- _includeValidateSearch: !0
2795
- });
2796
- return ut(e.latestLocation.href) !== ut(h.href) && e.commitLocation({ ...h, replace: !0 }), () => {
2797
- l();
2798
- };
2799
- }, [e, e.history]), Rt(() => {
2800
- if (typeof window < "u" && e.clientSsr || n.current.router === e && n.current.mounted)
2801
- return;
2802
- n.current = { router: e, mounted: !0 }, (async () => {
2803
- try {
2804
- await e.load();
2805
- } catch (h) {
2806
- console.error(h);
2807
- }
2808
- })();
2809
- }, [e]), Rt(() => {
2810
- if (i && !t) {
2811
- const l = e.state.location, h = e.state.resolvedLocation, f = h.pathname !== l.pathname, p = h.href !== l.href;
2812
- e.emit({
2813
- type: "onLoad",
2814
- // When the new URL has committed, when the new matches have been loaded into state.matches
2815
- fromLocation: h,
2816
- toLocation: l,
2817
- pathChanged: f,
2818
- hrefChanged: p
2819
- });
2820
- }
2821
- }, [i, e, t]), Rt(() => {
2822
- if (d && !c) {
2823
- const l = e.state.location, h = e.state.resolvedLocation, f = h.pathname !== l.pathname, p = h.href !== l.href;
2824
- e.emit({
2825
- type: "onBeforeRouteMount",
2826
- fromLocation: h,
2827
- toLocation: l,
2828
- pathChanged: f,
2829
- hrefChanged: p
2830
- });
2831
- }
2832
- }, [c, d, e]), Rt(() => {
2833
- if (u && !a) {
2834
- const l = e.state.location, h = e.state.resolvedLocation, f = h.pathname !== l.pathname, p = h.href !== l.href;
2835
- if (e.emit({
2836
- type: "onResolved",
2837
- fromLocation: h,
2838
- toLocation: l,
2839
- pathChanged: f,
2840
- hrefChanged: p
2841
- }), e.__store.setState((S) => ({
2842
- ...S,
2843
- status: "idle",
2844
- resolvedLocation: S.location
2845
- })), typeof document < "u" && document.querySelector) {
2846
- const S = e.state.location.state.__hashScrollIntoViewOptions ?? !0;
2847
- if (S && e.state.location.hash !== "") {
2848
- const g = document.getElementById(e.state.location.hash);
2849
- g && g.scrollIntoView(S);
2850
- }
2851
- }
2852
- }
2853
- }, [a, u, e]), null;
2854
- }
2855
- function jn() {
2856
- const e = rt(), n = e.options.defaultPendingComponent ? /* @__PURE__ */ C(e.options.defaultPendingComponent, {}) : null, t = e.isServer || typeof document < "u" && e.clientSsr ? Bt : b.Suspense, o = /* @__PURE__ */ te(t, { fallback: n, children: [
2857
- /* @__PURE__ */ C(Hn, {}),
2858
- /* @__PURE__ */ C(Gn, {})
2859
- ] });
2860
- return e.options.InnerWrap ? /* @__PURE__ */ C(e.options.InnerWrap, { children: o }) : o;
2861
- }
2862
- function Gn() {
2863
- const e = z({
2864
- select: (t) => {
2865
- var o;
2866
- return (o = t.matches[0]) == null ? void 0 : o.id;
2867
- }
2868
- }), n = z({
2869
- select: (t) => t.loadedAt
2870
- });
2871
- return /* @__PURE__ */ C(Ut.Provider, { value: e, children: /* @__PURE__ */ C(
2872
- ce,
2873
- {
2874
- getResetKey: () => n,
2875
- errorComponent: Kt,
2876
- onCatch: (t) => {
2877
- Mt(
2878
- !1,
2879
- "The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!"
2880
- ), Mt(!1, t.message || t.toString());
2881
- },
2882
- children: e ? /* @__PURE__ */ C(Ee, { matchId: e }) : null
2883
- }
2884
- ) });
2885
- }
2886
- function Xn({
2887
- router: e,
2888
- children: n,
2889
- ...t
2890
- }) {
2891
- e.update({
2892
- ...e.options,
2893
- ...t,
2894
- context: {
2895
- ...e.options.context,
2896
- ...t.context
2897
- }
2898
- });
2899
- const o = Ce(), r = /* @__PURE__ */ C(o.Provider, { value: e, children: n });
2900
- return e.options.Wrap ? /* @__PURE__ */ C(e.options.Wrap, { children: r }) : r;
2901
- }
2902
- function lo({ router: e, ...n }) {
2903
- return /* @__PURE__ */ C(Xn, { router: e, ...n, children: /* @__PURE__ */ C(jn, {}) });
2904
- }
2905
- const qn = typeof window < "u" ? b.useLayoutEffect : b.useEffect, Qt = "window", ge = "___";
2906
- let Zt = /* @__PURE__ */ new WeakSet();
2907
- const Jn = typeof window < "u" && window.sessionStorage, Z = Jn ? (() => {
2908
- const e = "tsr-scroll-restoration-v2";
2909
- return {
2910
- state: JSON.parse(
2911
- window.sessionStorage.getItem(e) || "null"
2912
- ) || { cached: {}, next: {} },
2913
- set: (t) => {
2914
- Z.state = lt(t, Z.state), window.sessionStorage.setItem(e, JSON.stringify(Z.state));
2915
- }
2916
- };
2917
- })() : void 0, Yn = (e) => e.state.key || e.href;
2918
- function Qn(e) {
2919
- const n = rt();
2920
- qn(() => {
2921
- const t = e?.getKey || Yn, { history: o } = window;
2922
- o.scrollRestoration = "manual";
2923
- const r = (a) => {
2924
- if (Zt.has(a.target)) return;
2925
- Zt.add(a.target);
2926
- let u = "";
2927
- if (a.target === document || a.target === window)
2928
- u = Qt;
2929
- else {
2930
- const c = a.target.getAttribute(
2931
- "data-scroll-restoration-id"
2932
- );
2933
- c ? u = `[data-scroll-restoration-id="${c}"]` : u = Zn(a.target);
2934
- }
2935
- Z.state.next[u] || Z.set((c) => ({
2936
- ...c,
2937
- next: {
2938
- ...c.next,
2939
- [u]: {
2940
- scrollX: NaN,
2941
- scrollY: NaN
2942
- }
2943
- }
2944
- }));
2945
- };
2946
- typeof document < "u" && document.addEventListener("scroll", r, !0);
2947
- const s = n.subscribe("onBeforeLoad", (a) => {
2948
- if (a.hrefChanged) {
2949
- const u = t(a.fromLocation);
2950
- for (const c in Z.state.next) {
2951
- const d = Z.state.next[c];
2952
- if (c === Qt)
2953
- d.scrollX = window.scrollX || 0, d.scrollY = window.scrollY || 0;
2954
- else if (c) {
2955
- const l = document.querySelector(c);
2956
- d.scrollX = l?.scrollLeft || 0, d.scrollY = l?.scrollTop || 0;
2957
- }
2958
- Z.set((l) => {
2959
- const h = { ...l.next };
2960
- return delete h[c], {
2961
- ...l,
2962
- next: h,
2963
- cached: {
2964
- ...l.cached,
2965
- [[u, c].join(ge)]: d
2966
- }
2967
- };
2968
- });
2969
- }
2970
- }
2971
- }), i = n.subscribe(
2972
- "onBeforeRouteMount",
2973
- (a) => {
2974
- if (a.hrefChanged) {
2975
- if (!n.resetNextScroll)
2976
- return;
2977
- n.resetNextScroll = !0;
2978
- const u = t(a.toLocation);
2979
- let c = !1;
2980
- for (const d in Z.state.cached) {
2981
- const l = Z.state.cached[d], [h, f] = d.split(ge);
2982
- if (h === u) {
2983
- if (f === Qt)
2984
- c = !0, window.scrollTo({
2985
- top: l.scrollY,
2986
- left: l.scrollX,
2987
- behavior: e?.scrollBehavior
2988
- });
2989
- else if (f) {
2990
- const p = document.querySelector(f);
2991
- p && (p.scrollLeft = l.scrollX, p.scrollTop = l.scrollY);
2992
- }
2993
- }
2994
- }
2995
- c || window.scrollTo(0, 0), Z.set((d) => ({ ...d, next: {} })), Zt = /* @__PURE__ */ new WeakSet();
2996
- }
2997
- }
2998
- );
2999
- return () => {
3000
- document.removeEventListener("scroll", r), s(), i();
3001
- };
3002
- }, [e?.getKey, n]);
3003
- }
3004
- function uo(e) {
3005
- return Qn(e), null;
3006
- }
3007
- function Zn(e) {
3008
- const n = [];
3009
- let t;
3010
- for (; t = e.parentNode; )
3011
- n.unshift(
3012
- `${e.tagName}:nth-child(${[].indexOf.call(t.children, e) + 1})`
3013
- ), e = t;
3014
- return `${n.join(" > ")}`.toLowerCase();
3015
- }
3016
- export {
3017
- co as L,
3018
- Kn as O,
3019
- lo as R,
3020
- uo as S,
3021
- ao as a,
3022
- Tn as b,
3023
- io as c,
3024
- z as d,
3025
- so as e,
3026
- oo as f,
3027
- _e as g,
3028
- tt as i,
3029
- ro as n,
3030
- rt as u,
3031
- on as w
3032
- };