likec4 1.22.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3032 +0,0 @@
1
- import { jsx as C, jsxs as et, Fragment as Ft } from "react/jsx-runtime";
2
- import * as b from "react";
3
- import yt, { useRef as Tt } from "react";
4
- import { flushSync as Bt } from "react-dom";
5
- const de = "__TSR_index", dt = "popstate", ht = "beforeunload";
6
- function St(t) {
7
- let n = t.getLocation();
8
- const e = /* @__PURE__ */ new Set(), o = (i) => {
9
- n = t.getLocation(), e.forEach((a) => a({ location: n, action: i }));
10
- }, r = (i) => {
11
- t.notifyOnIndexChange ?? !0 ? o(i) : n = t.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 = t.getBlockers) == null ? void 0 : c.call(t)) ?? [], f = u.type === "PUSH" || u.type === "REPLACE";
23
- if (typeof document < "u" && h.length && f)
24
- for (const p of h) {
25
- const S = ye(u.path, u.state);
26
- if (await p.blockerFn({
27
- currentLocation: n,
28
- nextLocation: S,
29
- action: u.type
30
- })) {
31
- (d = t.onBlocked) == null || d.call(t);
32
- return;
33
- }
34
- }
35
- i();
36
- };
37
- return {
38
- get location() {
39
- return n;
40
- },
41
- get length() {
42
- return t.getLength();
43
- },
44
- subscribers: e,
45
- subscribe: (i) => (e.add(i), () => {
46
- e.delete(i);
47
- }),
48
- push: (i, a, u) => {
49
- const c = n.state[de];
50
- a = tt(c + 1, a), s({
51
- task: () => {
52
- t.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[de];
62
- a = tt(c, a), s({
63
- task: () => {
64
- t.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
- t.go(i), r({ type: "GO", index: i });
76
- },
77
- navigateOpts: a,
78
- type: "GO"
79
- });
80
- },
81
- back: (i) => {
82
- s({
83
- task: () => {
84
- t.back(i?.ignoreBlocker ?? !1), r({ type: "BACK" });
85
- },
86
- navigateOpts: i,
87
- type: "BACK"
88
- });
89
- },
90
- forward: (i) => {
91
- s({
92
- task: () => {
93
- t.forward(i?.ignoreBlocker ?? !1), r({ type: "FORWARD" });
94
- },
95
- navigateOpts: i,
96
- type: "FORWARD"
97
- });
98
- },
99
- canGoBack: () => n.state[de] !== 0,
100
- createHref: (i) => t.createHref(i),
101
- block: (i) => {
102
- var a;
103
- if (!t.setBlockers) return () => {
104
- };
105
- const u = ((a = t.getBlockers) == null ? void 0 : a.call(t)) ?? [];
106
- return t.setBlockers([...u, i]), () => {
107
- var c, d;
108
- const l = ((c = t.getBlockers) == null ? void 0 : c.call(t)) ?? [];
109
- (d = t.setBlockers) == null || d.call(t, l.filter((h) => h !== i));
110
- };
111
- },
112
- flush: () => {
113
- var i;
114
- return (i = t.flush) == null ? void 0 : i.call(t);
115
- },
116
- destroy: () => {
117
- var i;
118
- return (i = t.destroy) == null ? void 0 : i.call(t);
119
- },
120
- notify: o
121
- };
122
- }
123
- function tt(t, n) {
124
- return n || (n = {}), {
125
- ...n,
126
- key: Ot(),
127
- [de]: t
128
- };
129
- }
130
- function _t(t) {
131
- const n = t?.window ?? (typeof document < "u" ? window : void 0), e = n.history.pushState, o = n.history.replaceState;
132
- let r = [];
133
- const s = () => r, i = (y) => r = y, a = t?.createHref ?? ((y) => y), u = t?.parseLocation ?? (() => ye(
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 = ye(_, 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[de] - c.state[de], 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 = St({
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 = e, n.history.replaceState = o, n.removeEventListener(ht, x, {
222
- capture: !0
223
- }), n.removeEventListener(dt, 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(ht, x, { capture: !0 }), n.addEventListener(dt, v), n.history.pushState = function(...y) {
233
- const _ = e.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(t) {
241
- const n = typeof document < "u" ? window : void 0;
242
- return _t({
243
- window: n,
244
- parseLocation: () => {
245
- const e = n.location.hash.split("#").slice(1).join("#") ?? "/";
246
- return ye(e, n.history.state);
247
- },
248
- createHref: (e) => `${n.location.pathname}${n.location.search}#${e}`
249
- });
250
- }
251
- function Dt(t = {
252
- initialEntries: ["/"]
253
- }) {
254
- const n = t.initialEntries;
255
- let e = t.initialIndex ? Math.min(Math.max(t.initialIndex, 0), n.length - 1) : n.length - 1;
256
- const o = n.map(
257
- (s, i) => tt(i, void 0)
258
- );
259
- return St({
260
- getLocation: () => ye(n[e], o[e]),
261
- getLength: () => n.length,
262
- pushState: (s, i) => {
263
- e < n.length - 1 && (n.splice(e + 1), o.splice(e + 1)), o.push(i), n.push(s), e = Math.max(n.length - 1, 0);
264
- },
265
- replaceState: (s, i) => {
266
- o[e] = i, n[e] = s;
267
- },
268
- back: () => {
269
- e = Math.max(e - 1, 0);
270
- },
271
- forward: () => {
272
- e = Math.min(e + 1, n.length - 1);
273
- },
274
- go: (s) => {
275
- e = Math.min(Math.max(e + s, 0), n.length - 1);
276
- },
277
- createHref: (s) => s
278
- });
279
- }
280
- function ye(t, n) {
281
- const e = t.indexOf("#"), o = t.indexOf("?");
282
- return {
283
- href: t,
284
- pathname: t.substring(
285
- 0,
286
- e > 0 ? o > 0 ? Math.min(e, o) : e : o > 0 ? o : t.length
287
- ),
288
- hash: e > -1 ? t.substring(e) : "",
289
- search: o > -1 ? t.slice(o, e === -1 ? void 0 : e) : "",
290
- state: n || { [de]: 0 }
291
- };
292
- }
293
- function Ot() {
294
- return (Math.random() + 1).toString(36).substring(7);
295
- }
296
- var Vt = !0, We = "Invariant failed";
297
- function te(t, n) {
298
- if (!t) {
299
- if (Vt)
300
- throw new Error(We);
301
- var e = typeof n == "function" ? n() : n, o = e ? "".concat(We, ": ").concat(e) : We;
302
- throw new Error(o);
303
- }
304
- }
305
- var At = !0;
306
- function Me(t, n) {
307
- if (!At) {
308
- if (t)
309
- return;
310
- var e = "Warning: " + n;
311
- typeof console < "u" && console.warn(e);
312
- try {
313
- throw Error(e);
314
- } catch {
315
- }
316
- }
317
- }
318
- var st = { exports: {} }, wt = {}, it = { exports: {} }, Pt = {};
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 Se = yt;
329
- function Nt(t, n) {
330
- return t === n && (t !== 0 || 1 / t === 1 / n) || t !== t && n !== n;
331
- }
332
- var $t = typeof Object.is == "function" ? Object.is : Nt, Kt = Se.useState, Ut = Se.useEffect, zt = Se.useLayoutEffect, Wt = Se.useDebugValue;
333
- function Ht(t, n) {
334
- var e = n(), o = Kt({ inst: { value: e, getSnapshot: n } }), r = o[0].inst, s = o[1];
335
- return zt(
336
- function() {
337
- r.value = e, r.getSnapshot = n, He(r) && s({ inst: r });
338
- },
339
- [t, e, n]
340
- ), Ut(
341
- function() {
342
- return He(r) && s({ inst: r }), t(function() {
343
- He(r) && s({ inst: r });
344
- });
345
- },
346
- [t]
347
- ), Wt(e), e;
348
- }
349
- function He(t) {
350
- var n = t.getSnapshot;
351
- t = t.value;
352
- try {
353
- var e = n();
354
- return !$t(t, e);
355
- } catch {
356
- return !0;
357
- }
358
- }
359
- function jt(t, n) {
360
- return n();
361
- }
362
- var Gt = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? jt : Ht;
363
- Pt.useSyncExternalStore = Se.useSyncExternalStore !== void 0 ? Se.useSyncExternalStore : Gt;
364
- it.exports;
365
- it.exports = Pt;
366
- var Xt = it.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 Ne = yt, qt = Xt;
377
- function Jt(t, n) {
378
- return t === n && (t !== 0 || 1 / t === 1 / n) || t !== t && n !== n;
379
- }
380
- var Yt = typeof Object.is == "function" ? Object.is : Jt, Qt = qt.useSyncExternalStore, Zt = Ne.useRef, en = Ne.useEffect, tn = Ne.useMemo, nn = Ne.useDebugValue;
381
- wt.useSyncExternalStoreWithSelector = function(t, n, e, o, r) {
382
- var s = Zt(null);
383
- if (s.current === null) {
384
- var i = { hasValue: !1, value: null };
385
- s.current = i;
386
- } else i = s.current;
387
- s = tn(
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, Yt(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 = e === void 0 ? null : e;
403
- return [
404
- function() {
405
- return u(n());
406
- },
407
- h === null ? void 0 : function() {
408
- return u(h());
409
- }
410
- ];
411
- },
412
- [n, e, o, r]
413
- );
414
- var a = Qt(t, s[0], s[1]);
415
- return en(
416
- function() {
417
- i.hasValue = !0, i.value = a;
418
- },
419
- [a]
420
- ), nn(a), a;
421
- };
422
- st.exports;
423
- st.exports = wt;
424
- var on = st.exports;
425
- const me = /* @__PURE__ */ new WeakMap(), Te = /* @__PURE__ */ new WeakMap(), De = {
426
- current: []
427
- };
428
- let je = !1, Ce = 0;
429
- const be = /* @__PURE__ */ new Set(), Ie = /* @__PURE__ */ new Map();
430
- function bt(t) {
431
- const n = Array.from(t).sort((e, o) => e instanceof ve && e.options.deps.includes(o) ? 1 : o instanceof ve && o.options.deps.includes(e) ? -1 : 0);
432
- for (const e of n) {
433
- if (De.current.includes(e))
434
- continue;
435
- De.current.push(e), e.recompute();
436
- const o = Te.get(e);
437
- if (o)
438
- for (const r of o) {
439
- const s = me.get(r);
440
- s && bt(s);
441
- }
442
- }
443
- }
444
- function rn(t) {
445
- t.listeners.forEach(
446
- (n) => n({
447
- prevVal: t.prevState,
448
- currentVal: t.state
449
- })
450
- );
451
- }
452
- function sn(t) {
453
- t.listeners.forEach(
454
- (n) => n({
455
- prevVal: t.prevState,
456
- currentVal: t.state
457
- })
458
- );
459
- }
460
- function Rt(t) {
461
- if (Ce > 0 && !Ie.has(t) && Ie.set(t, t.prevState), be.add(t), !(Ce > 0) && !je)
462
- try {
463
- for (je = !0; be.size > 0; ) {
464
- const n = Array.from(be);
465
- be.clear();
466
- for (const e of n) {
467
- const o = Ie.get(e) ?? e.prevState;
468
- e.prevState = o, rn(e);
469
- }
470
- for (const e of n) {
471
- const o = me.get(e);
472
- o && (De.current.push(e), bt(o));
473
- }
474
- for (const e of n) {
475
- const o = me.get(e);
476
- if (o)
477
- for (const r of o)
478
- sn(r);
479
- }
480
- }
481
- } finally {
482
- je = !1, De.current = [], Ie.clear();
483
- }
484
- }
485
- function Ge(t) {
486
- Ce++;
487
- try {
488
- t();
489
- } finally {
490
- if (Ce--, Ce === 0) {
491
- const n = Array.from(be)[0];
492
- n && Rt(n);
493
- }
494
- }
495
- }
496
- class nt {
497
- constructor(n, e) {
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), Rt(this);
508
- }, this.prevState = n, this.state = n, this.options = e;
509
- }
510
- }
511
- class ve {
512
- constructor(n) {
513
- this.listeners = /* @__PURE__ */ new Set(), this._subscriptions = [], this.lastSeenDepValues = [], this.getDepVals = () => {
514
- const e = [], o = [];
515
- for (const r of this.options.deps)
516
- e.push(r.prevState), o.push(r.state);
517
- return this.lastSeenDepValues = o, {
518
- prevDepVals: e,
519
- currDepVals: o,
520
- prevVal: this.prevState ?? void 0
521
- };
522
- }, this.recompute = () => {
523
- var e, 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 = (e = this.options).onUpdate) == null || o.call(e);
531
- }, this.checkIfRecalculationNeededDeeply = () => {
532
- for (const s of this.options.deps)
533
- s instanceof ve && s.checkIfRecalculationNeededDeeply();
534
- let e = !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
- e = !0;
539
- break;
540
- }
541
- e && this.recompute();
542
- }, this.mount = () => (this.registerOnGraph(), this.checkIfRecalculationNeededDeeply(), () => {
543
- this.unregisterFromGraph();
544
- for (const e of this._subscriptions)
545
- e();
546
- }), this.subscribe = (e) => {
547
- var o, r;
548
- this.listeners.add(e);
549
- const s = (r = (o = this.options).onSubscribe) == null ? void 0 : r.call(o, e, this);
550
- return () => {
551
- this.listeners.delete(e), 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 e of n)
561
- if (e instanceof ve)
562
- e.registerOnGraph(), this.registerOnGraph(e.options.deps);
563
- else if (e instanceof nt) {
564
- let o = me.get(e);
565
- o || (o = /* @__PURE__ */ new Set(), me.set(e, o)), o.add(this);
566
- let r = Te.get(this);
567
- r || (r = /* @__PURE__ */ new Set(), Te.set(this, r)), r.add(e);
568
- }
569
- }
570
- unregisterFromGraph(n = this.options.deps) {
571
- for (const e of n)
572
- if (e instanceof ve)
573
- this.unregisterFromGraph(e.options.deps);
574
- else if (e instanceof nt) {
575
- const o = me.get(e);
576
- o && o.delete(this);
577
- const r = Te.get(this);
578
- r && r.delete(e);
579
- }
580
- }
581
- }
582
- function an(t, n = (e) => e) {
583
- return on.useSyncExternalStoreWithSelector(
584
- t.subscribe,
585
- () => t.state,
586
- () => t.state,
587
- n,
588
- cn
589
- );
590
- }
591
- function cn(t, n) {
592
- if (Object.is(t, n))
593
- return !0;
594
- if (typeof t != "object" || t === null || typeof n != "object" || n === null)
595
- return !1;
596
- if (t instanceof Map && n instanceof Map) {
597
- if (t.size !== n.size) return !1;
598
- for (const [o, r] of t)
599
- if (!n.has(o) || !Object.is(r, n.get(o))) return !1;
600
- return !0;
601
- }
602
- if (t instanceof Set && n instanceof Set) {
603
- if (t.size !== n.size) return !1;
604
- for (const o of t)
605
- if (!n.has(o)) return !1;
606
- return !0;
607
- }
608
- const e = Object.keys(t);
609
- if (e.length !== Object.keys(n).length)
610
- return !1;
611
- for (let o = 0; o < e.length; o++)
612
- if (!Object.prototype.hasOwnProperty.call(n, e[o]) || !Object.is(t[e[o]], n[e[o]]))
613
- return !1;
614
- return !0;
615
- }
616
- const H = "__root__";
617
- function ln(t, n) {
618
- let e, o, r, s = "";
619
- for (e in t)
620
- if ((r = t[e]) !== void 0)
621
- if (Array.isArray(r))
622
- for (o = 0; o < r.length; o++)
623
- s && (s += "&"), s += encodeURIComponent(e) + "=" + encodeURIComponent(r[o]);
624
- else
625
- s && (s += "&"), s += encodeURIComponent(e) + "=" + encodeURIComponent(r);
626
- return "" + s;
627
- }
628
- function ft(t) {
629
- if (!t) return "";
630
- const n = decodeURIComponent(t);
631
- return n === "false" ? !1 : n === "true" ? !0 : +n * 0 === 0 && +n + "" === n ? +n : n;
632
- }
633
- function un(t, n) {
634
- let e, o;
635
- const r = {}, s = t.split("&");
636
- for (; e = s.shift(); ) {
637
- const i = e.indexOf("=");
638
- if (i !== -1) {
639
- o = e.slice(0, i), o = decodeURIComponent(o);
640
- const a = e.slice(i + 1);
641
- r[o] !== void 0 ? r[o] = [].concat(r[o], ft(a)) : r[o] = ft(a);
642
- } else
643
- o = e, 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(t) {
652
- return (n) => {
653
- n.substring(0, 1) === "?" && (n = n.substring(1));
654
- const e = un(n);
655
- for (const o in e) {
656
- const r = e[o];
657
- if (typeof r == "string")
658
- try {
659
- e[o] = t(r);
660
- } catch {
661
- }
662
- }
663
- return e;
664
- };
665
- }
666
- function pn(t, n) {
667
- function e(o) {
668
- if (typeof o == "object" && o !== null)
669
- try {
670
- return t(o);
671
- } catch {
672
- }
673
- else if (typeof o == "string" && typeof n == "function")
674
- try {
675
- return n(o), t(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] = e(i);
684
- });
685
- const r = ln(o).toString();
686
- return r ? `?${r}` : "";
687
- };
688
- }
689
- function Le(t) {
690
- return t[t.length - 1];
691
- }
692
- function mn(t) {
693
- return typeof t == "function";
694
- }
695
- function le(t, n) {
696
- return mn(t) ? t(n) : t;
697
- }
698
- function ot(t, n) {
699
- return n.reduce((e, o) => (e[o] = t[o], e), {});
700
- }
701
- function X(t, n) {
702
- if (t === n)
703
- return t;
704
- const e = n, o = mt(t) && mt(e);
705
- if (o || Oe(t) && Oe(e)) {
706
- const r = o ? t : Object.keys(t), s = r.length, i = o ? e : Object.keys(e), 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) && t[l] === void 0 && e[l] === void 0 ? (u[l] = void 0, c++) : (u[l] = X(t[l], e[l]), u[l] === t[l] && t[l] !== void 0 && c++);
711
- }
712
- return s === a && c === s ? t : u;
713
- }
714
- return e;
715
- }
716
- function Oe(t) {
717
- if (!pt(t))
718
- return !1;
719
- const n = t.constructor;
720
- if (typeof n > "u")
721
- return !0;
722
- const e = n.prototype;
723
- return !(!pt(e) || !e.hasOwnProperty("isPrototypeOf"));
724
- }
725
- function pt(t) {
726
- return Object.prototype.toString.call(t) === "[object Object]";
727
- }
728
- function mt(t) {
729
- return Array.isArray(t) && t.length === Object.keys(t).length;
730
- }
731
- function vt(t, n) {
732
- let e = Object.keys(t);
733
- return n && (e = e.filter((o) => t[o] !== void 0)), e;
734
- }
735
- function ge(t, n, e) {
736
- if (t === n)
737
- return !0;
738
- if (typeof t != typeof n)
739
- return !1;
740
- if (Oe(t) && Oe(n)) {
741
- const o = e?.ignoreUndefined ?? !0, r = vt(t, o), s = vt(n, o);
742
- return !e?.partial && r.length !== s.length ? !1 : s.every((i) => ge(t[i], n[i], e));
743
- }
744
- return Array.isArray(t) && Array.isArray(n) ? t.length !== n.length ? !1 : !t.some((o, r) => !ge(o, n[r], e)) : !1;
745
- }
746
- const Re = typeof window < "u" ? b.useLayoutEffect : b.useEffect;
747
- function pe(t) {
748
- let n, e;
749
- const o = new Promise((r, s) => {
750
- n = r, e = s;
751
- });
752
- return o.status = "pending", o.resolve = (r) => {
753
- o.status = "resolved", o.value = r, n(r), t?.(r);
754
- }, o.reject = (r) => {
755
- o.status = "rejected", e(r);
756
- }, o;
757
- }
758
- function Xe(t) {
759
- const n = b.useRef({
760
- value: t,
761
- prev: null
762
- }), e = n.current.value;
763
- return t !== e && (n.current = {
764
- value: t,
765
- prev: e
766
- }), n.current.prev;
767
- }
768
- function vn(t, n, e = {}, o = {}) {
769
- const r = b.useRef(
770
- typeof IntersectionObserver == "function"
771
- ), s = b.useRef(null);
772
- return b.useEffect(() => {
773
- if (!(!t.current || !r.current || o.disabled))
774
- return s.current = new IntersectionObserver(([i]) => {
775
- n(i);
776
- }, e), s.current.observe(t.current), () => {
777
- var i;
778
- (i = s.current) == null || i.disconnect();
779
- };
780
- }, [n, e, o.disabled, t]), s.current;
781
- }
782
- function gn(t) {
783
- const n = b.useRef(null);
784
- return b.useEffect(() => {
785
- t && (typeof t == "function" ? t(n.current) : t.current = n.current);
786
- }), n;
787
- }
788
- function oe(t) {
789
- return $e(
790
- t.filter((n) => n !== void 0).join("/")
791
- );
792
- }
793
- function $e(t) {
794
- return t.replace(/\/{2,}/g, "/");
795
- }
796
- function at(t) {
797
- return t === "/" ? t : t.replace(/^\/{1,}/, "");
798
- }
799
- function ue(t) {
800
- return t === "/" ? t : t.replace(/\/{1,}$/, "");
801
- }
802
- function yn(t) {
803
- return ue(at(t));
804
- }
805
- function Ve(t, n) {
806
- return t.endsWith("/") && t !== "/" && t !== `${n}/` ? t.slice(0, -1) : t;
807
- }
808
- function Sn(t, n, e) {
809
- return Ve(t, e) === Ve(n, e);
810
- }
811
- function _n({
812
- basepath: t,
813
- base: n,
814
- to: e,
815
- trailingSlash: o = "never",
816
- caseSensitive: r
817
- }) {
818
- var s, i;
819
- n = Ae(t, n, r), e = Ae(t, e, r);
820
- let a = _e(n);
821
- const u = _e(e);
822
- a.length > 1 && ((s = Le(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 = Le(a)) == null ? void 0 : i.value) === "/" ? o === "never" && a.pop() : o === "always" && a.push({ type: "pathname", value: "/" }));
825
- const c = oe([t, ...a.map((d) => d.value)]);
826
- return $e(c);
827
- }
828
- function _e(t) {
829
- if (!t)
830
- return [];
831
- t = $e(t);
832
- const n = [];
833
- if (t.slice(0, 1) === "/" && (t = t.substring(1), n.push({
834
- type: "pathname",
835
- value: "/"
836
- })), !t)
837
- return n;
838
- const e = t.split("/").filter(Boolean);
839
- return n.push(
840
- ...e.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
- ), t.slice(-1) === "/" && (t = t.substring(1), n.push({
851
- type: "pathname",
852
- value: "/"
853
- })), n;
854
- }
855
- function ke({
856
- path: t,
857
- params: n,
858
- leaveWildcards: e,
859
- leaveParams: o,
860
- decodeCharMap: r
861
- }) {
862
- const s = _e(t), 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 oe(
868
- s.map((a) => {
869
- if (a.type === "wildcard") {
870
- const u = i._splat;
871
- return e ? `${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(t, n) {
885
- let e = encodeURIComponent(t);
886
- if (n)
887
- for (const [o, r] of n)
888
- e = e.replaceAll(o, r);
889
- return e;
890
- }
891
- function Fe(t, n, e) {
892
- const o = Pn(t, n, e);
893
- if (!(e.to && !o))
894
- return o ?? {};
895
- }
896
- function Ae(t, n, e = !1) {
897
- const o = e ? t : t.toLowerCase(), r = e ? n : n.toLowerCase();
898
- switch (!0) {
899
- case o === "/":
900
- return n;
901
- case r === o:
902
- return "";
903
- case n.length < t.length:
904
- return n;
905
- case r[o.length] !== "/":
906
- return n;
907
- case r.startsWith(o):
908
- return n.slice(t.length);
909
- default:
910
- return n;
911
- }
912
- }
913
- function Pn(t, n, e) {
914
- if (t !== "/" && !n.startsWith(t))
915
- return;
916
- n = Ae(t, n, e.caseSensitive);
917
- const o = Ae(
918
- t,
919
- `${e.to ?? "$"}`,
920
- e.caseSensitive
921
- ), r = _e(n), s = _e(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
- oe(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 (e.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["**"] = oe(r.slice(u + 1).map((f) => f.value)), !!e.fuzzy && d?.value !== "/";
963
- }
964
- return !0;
965
- })() ? i : void 0;
966
- }
967
- function ce(t) {
968
- return !!t?.isRedirect;
969
- }
970
- function qe(t) {
971
- return !!t?.isRedirect && t.href;
972
- }
973
- function ct(t) {
974
- const n = t.errorComponent ?? Ke;
975
- return /* @__PURE__ */ C(
976
- bn,
977
- {
978
- getResetKey: t.getResetKey,
979
- onCatch: t.onCatch,
980
- children: ({ error: e, reset: o }) => e ? b.createElement(n, {
981
- error: e,
982
- reset: o
983
- }) : t.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, e) {
1001
- e.error && e.resetKey !== this.state.resetKey && this.reset();
1002
- }
1003
- componentDidCatch(n, e) {
1004
- this.props.onCatch && this.props.onCatch(n, e);
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 Ke({ error: t }) {
1016
- const [n, e] = b.useState(!1);
1017
- return /* @__PURE__ */ et("div", { style: { padding: ".5rem", maxWidth: "100%" }, children: [
1018
- /* @__PURE__ */ et("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: () => e((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: t.message ? /* @__PURE__ */ C("code", { children: t.message }) : null
1049
- }
1050
- ) }) : null
1051
- ] });
1052
- }
1053
- const Je = b.createContext(null);
1054
- function Ct() {
1055
- return typeof document > "u" ? Je : window.__TSR_ROUTER_CONTEXT__ ? window.__TSR_ROUTER_CONTEXT__ : (window.__TSR_ROUTER_CONTEXT__ = Je, Je);
1056
- }
1057
- function re(t) {
1058
- const n = b.useContext(Ct());
1059
- return Me(
1060
- !((t?.warn ?? !0) && !n),
1061
- "useRouter must be used inside a <RouterProvider> component!"
1062
- ), n;
1063
- }
1064
- function z(t) {
1065
- const n = re({
1066
- warn: t?.router === void 0
1067
- }), e = t?.router || n, o = Tt(void 0);
1068
- return an(e.__store, (r) => {
1069
- if (t?.select) {
1070
- if (t.structuralSharing ?? e.options.defaultStructuralSharing) {
1071
- const s = X(
1072
- o.current,
1073
- t.select(r)
1074
- );
1075
- return o.current = s, s;
1076
- }
1077
- return t.select(r);
1078
- }
1079
- return r;
1080
- });
1081
- }
1082
- function ro(t = {}) {
1083
- if (t.isNotFound = !0, t.throw) throw t;
1084
- return t;
1085
- }
1086
- function ee(t) {
1087
- return !!t?.isNotFound;
1088
- }
1089
- function Rn(t) {
1090
- const n = z({
1091
- select: (e) => `not-found-${e.location.pathname}-${e.status}`
1092
- });
1093
- return /* @__PURE__ */ C(
1094
- ct,
1095
- {
1096
- getResetKey: () => n,
1097
- onCatch: (e, o) => {
1098
- var r;
1099
- if (ee(e))
1100
- (r = t.onCatch) == null || r.call(t, e, o);
1101
- else
1102
- throw e;
1103
- },
1104
- errorComponent: ({ error: e }) => {
1105
- var o;
1106
- if (ee(e))
1107
- return (o = t.fallback) == null ? void 0 : o.call(t, e);
1108
- throw e;
1109
- },
1110
- children: t.children
1111
- }
1112
- );
1113
- }
1114
- function Cn() {
1115
- return /* @__PURE__ */ C("p", { children: "Not Found" });
1116
- }
1117
- const Lt = [
1118
- "component",
1119
- "errorComponent",
1120
- "pendingComponent",
1121
- "notFoundComponent"
1122
- ];
1123
- function Ln(t) {
1124
- var n;
1125
- for (const e of Lt)
1126
- if ((n = t.options[e]) != null && n.preload)
1127
- return !0;
1128
- return !1;
1129
- }
1130
- function Ye(t, n) {
1131
- if (t == null) return {};
1132
- if ("~standard" in t) {
1133
- const e = t["~standard"].validate(n);
1134
- if (e instanceof Promise)
1135
- throw new rt("Async validation not supported");
1136
- if (e.issues)
1137
- throw new rt(JSON.stringify(e.issues, void 0, 2));
1138
- return e.value;
1139
- }
1140
- return "parse" in t ? t.parse(n) : typeof t == "function" ? t(n) : {};
1141
- }
1142
- function so(t) {
1143
- return new Mn(t);
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 = (e) => e(), this.update = (e) => {
1153
- var o;
1154
- e.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
- ...e
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 || e.basepath && e.basepath !== r.basepath) && (e.basepath === void 0 || e.basepath === "" || e.basepath === "/" ? this.basepath = "/" : this.basepath = `/${yn(e.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 ? Dt({
1168
- initialEntries: [this.basepath || "/"]
1169
- }) : _t()), this.latestLocation = this.parseLocation()), this.options.routeTree !== this.routeTree && (this.routeTree = this.options.routeTree, this.buildRouteTree()), this.__store || (this.__store = new nt(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 e = this.options.notFoundRoute;
1185
- e && (e.init({
1186
- originalIndex: 99999999999,
1187
- defaultSsr: this.options.defaultSsr
1188
- }), this.routesById[e.id] = e);
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 (te(
1197
- !c,
1198
- `Duplicate routes found with id: ${String(a.id)}`
1199
- ), this.routesById[a.id] = a, !a.isRoot && a.path) {
1200
- const l = ue(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 = at(i.fullPath), d = _e(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 = (e, o) => {
1231
- const r = {
1232
- eventType: e,
1233
- fn: o
1234
- };
1235
- return this.subscribers.add(r), () => {
1236
- this.subscribers.delete(r);
1237
- };
1238
- }, this.emit = (e) => {
1239
- this.subscribers.forEach((o) => {
1240
- o.eventType === e.type && o.fn(e);
1241
- });
1242
- }, this.parseLocation = (e, 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(e?.search, h),
1254
- hash: d.split("#").reverse()[0] ?? "",
1255
- href: `${u}${f}${d}`,
1256
- state: X(e?.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 = (e, o) => _n({
1268
- basepath: this.basepath,
1269
- base: e,
1270
- to: $e(o),
1271
- trailingSlash: this.options.trailingSlash,
1272
- caseSensitive: this.options.caseSensitive
1273
- }), this.getMatchedRoutes = (e, o) => {
1274
- let r = {};
1275
- const s = ue(e.pathname), i = (d) => Fe(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 = (e) => {
1291
- const o = this.getMatch(e);
1292
- o && (o.abortController.abort(), clearTimeout(o.pendingTimeout));
1293
- }, this.cancelMatches = () => {
1294
- var e;
1295
- (e = this.state.pendingMatches) == null || e.forEach((o) => {
1296
- this.cancelMatch(o.id);
1297
- });
1298
- }, this.buildLocation = (e) => {
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) => Fe(this.basepath, ue(m.pathname), {
1303
- to: s.from,
1304
- caseSensitive: !1,
1305
- fuzzy: !1
1306
- })
1307
- ) : void 0, S = p?.pathname || this.latestLocation.pathname;
1308
- te(
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 = Le(this.state.pendingMatches)) == null ? void 0 : u.search : ((c = Le(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 = ke({
1321
- path: w.fullPath,
1322
- params: i?.routeParams ?? {},
1323
- decodeCharMap: this.pathParamsDecodeCharMap
1324
- });
1325
- return oe([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 = Le(f)) == null ? void 0 : l.params };
1333
- let P = (s.params ?? !0) === !0 ? L : {
1334
- ...L,
1335
- ...le(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 = ke({
1343
- path: R,
1344
- params: P ?? {},
1345
- leaveWildcards: !1,
1346
- leaveParams: e.leaveParams,
1347
- decodeCharMap: this.pathParamsDecodeCharMap
1348
- });
1349
- let v = g;
1350
- if (e._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
- ...Ye(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: ne
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 = ne(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 (e._includeValidateSearch && D.options.validateSearch) {
1391
- const J = ({ search: j, next: ne }) => {
1392
- try {
1393
- const O = ne(j);
1394
- return {
1395
- ...O,
1396
- ...Ye(
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 : le(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 ? le(s.hash, this.latestLocation.hash) : void 0, _ = y ? `#${y}` : "";
1420
- let E = s.state === !0 ? this.latestLocation.state : s.state ? le(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 = Fe(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
- ...ot(e, ["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 e.mask ? r(e, {
1461
- ...ot(e, ["from"]),
1462
- ...e.mask
1463
- }) : r(e);
1464
- }, this.commitLocation = ({
1465
- viewTransition: e,
1466
- ignoreBlocker: o,
1467
- ...r
1468
- }) => {
1469
- const s = () => {
1470
- r.state.key = this.latestLocation.state.key;
1471
- const u = ge(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 = pe(() => {
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 = e, 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: e,
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 = ye(a, {
1514
- __TSR_index: e ? 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: e,
1526
- resetScroll: o,
1527
- hashScrollIntoView: r,
1528
- ignoreBlocker: i
1529
- });
1530
- }, this.navigate = ({ to: e, reloadDocument: o, href: r, ...s }) => {
1531
- if (o) {
1532
- r || (r = this.buildLocation({ to: e, ...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: e
1539
- });
1540
- }, this.load = async (e) => {
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
- Ge(() => {
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: e?.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
- Ge(() => {
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
- qe(u) ? (o = u, this.isServer || this.navigate({
1616
- ...o,
1617
- replace: !0,
1618
- ignoreBlocker: !0
1619
- })) : ee(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 = (e) => {
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: e,
1635
- types: o.types
1636
- } : r = e, document.startViewTransition(r);
1637
- } else
1638
- e();
1639
- }, this.updateMatch = (e, o) => {
1640
- var r;
1641
- let s;
1642
- const i = (r = this.state.pendingMatches) == null ? void 0 : r.find((d) => d.id === e), a = this.state.matches.find((d) => d.id === e), u = this.state.cachedMatches.find((d) => d.id === e), 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 === e ? s = o(h) : h
1649
- )
1650
- };
1651
- }), s;
1652
- }, this.getMatch = (e) => [
1653
- ...this.state.cachedMatches,
1654
- ...this.state.pendingMatches ?? [],
1655
- ...this.state.matches
1656
- ].find((o) => o.id === e), this.loadMatches = async ({
1657
- location: e,
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 (qe(p) && !p.reloadDocument)
1672
- throw p;
1673
- if (ce(p) || ee(p)) {
1674
- if (i(f.id, (R) => ({
1675
- ...R,
1676
- status: ce(p) ? "redirected" : ee(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(), ce(p))
1682
- throw c = !0, p = this.resolveRedirect({ ...p, _fromLocation: e }), p;
1683
- if (ee(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: pe(() => {
1735
- var G;
1736
- (G = N.loadPromise) == null || G.resolve();
1737
- }),
1738
- beforeLoadPromise: pe()
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: ne, cause: O } = this.getMatch(x), K = l(x), V = {
1763
- search: J,
1764
- abortController: T,
1765
- params: j,
1766
- preload: K,
1767
- context: ne,
1768
- location: e,
1769
- navigate: (N) => this.navigate({ ...N, _fromLocation: e }),
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
- (ce(A) || ee(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: e,
1824
- navigate: (Y) => this.navigate({ ...Y, _fromLocation: e }),
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: pe(),
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, xe, Ee;
1836
- try {
1837
- const ie = async () => {
1838
- const U = this.getMatch(v);
1839
- U.minPendingPromise && await U.minPendingPromise;
1840
- };
1841
- try {
1842
- this.loadRouteChunk(w), i(v, (fe) => ({
1843
- ...fe,
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 ie();
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
- }), se = Q?.meta, ae = Q?.links, we = Q?.scripts, Pe = (G = (N = w.options).headers) == null ? void 0 : G.call(N, {
1857
- loaderData: U
1858
- });
1859
- i(v, (fe) => ({
1860
- ...fe,
1861
- error: void 0,
1862
- status: "success",
1863
- isFetching: !1,
1864
- updatedAt: Date.now(),
1865
- loaderData: U,
1866
- meta: se,
1867
- links: ae,
1868
- scripts: we,
1869
- headers: Pe
1870
- }));
1871
- } catch (U) {
1872
- let Q = U;
1873
- await ie(), h(this.getMatch(v), U);
1874
- try {
1875
- (xe = (Y = w.options).onError) == null || xe.call(Y, U);
1876
- } catch (se) {
1877
- Q = se, h(
1878
- this.getMatch(v),
1879
- se
1880
- );
1881
- }
1882
- i(v, (se) => ({
1883
- ...se,
1884
- error: Q,
1885
- status: "error",
1886
- isFetching: !1
1887
- }));
1888
- }
1889
- (Ee = this.serverSsr) == null || Ee.onMatchSettled({
1890
- router: this,
1891
- match: this.getMatch(v)
1892
- }), await w._componentsPromise;
1893
- } catch (ie) {
1894
- i(v, (U) => ({
1895
- ...U,
1896
- loaderPromise: void 0
1897
- })), h(this.getMatch(v), ie);
1898
- }
1899
- }, { status: j, invalid: ne } = this.getMatch(v);
1900
- _ = j === "success" && (ne || (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
- qe(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 (ce(f) || ee(f))
1933
- throw ee(f) && !r && await d(), f;
1934
- }
1935
- return o;
1936
- }, this.invalidate = (e) => {
1937
- const o = (r) => {
1938
- var s;
1939
- return ((s = e?.filter) == null ? void 0 : s.call(e, 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: e?.sync });
1954
- }, this.resolveRedirect = (e) => {
1955
- const o = e;
1956
- return o.href || (o.href = this.buildLocation(o).href), o;
1957
- }, this.clearCache = (e) => {
1958
- const o = e?.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 e = (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: e });
1977
- }, this.loadRouteChunk = (e) => (e._lazyPromise === void 0 && (e.lazyFn ? e._lazyPromise = e.lazyFn().then((o) => {
1978
- const { id: r, ...s } = o.options;
1979
- Object.assign(e.options, s);
1980
- }) : e._lazyPromise = Promise.resolve()), e._componentsPromise === void 0 && (e._componentsPromise = e._lazyPromise.then(
1981
- () => Promise.all(
1982
- Lt.map(async (o) => {
1983
- const r = e.options[o];
1984
- r?.preload && await r.preload();
1985
- })
1986
- )
1987
- )), e._componentsPromise), this.preloadRoute = async (e) => {
1988
- const o = this.buildLocation(e);
1989
- let r = this.matchRoutes(o, {
1990
- throwOnError: !0,
1991
- preload: !0,
1992
- dest: e
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
- Ge(() => {
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 (ce(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 = (e, o) => {
2029
- const r = {
2030
- ...e,
2031
- to: e.to ? this.resolvePathWithBase(
2032
- e.from || "",
2033
- e.to
2034
- ) : void 0,
2035
- params: e.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 = Fe(this.basepath, a.pathname, {
2041
- ...o,
2042
- to: s.pathname
2043
- });
2044
- return !u || e.params && !ge(u, e.params, { partial: !0 }) ? !1 : u && (o?.includeSearch ?? !0) ? ge(a.search, s.search, { partial: !0 }) ? u : !1 : u;
2045
- }, this._handleNotFound = (e, o, {
2046
- updateMatch: r = this.updateMatch
2047
- } = {}) => {
2048
- const s = Object.fromEntries(
2049
- e.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, te(
2054
- i,
2055
- "Found invalid route tree while trying to find not-found handler."
2056
- );
2057
- const a = s[i.id];
2058
- te(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(e, o, {
2064
- updateMatch: r
2065
- }));
2066
- }, this.hasNotFoundMatch = () => this.__store.state.matches.some(
2067
- (e) => e.status === "notFound" || e.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, e, o) {
2087
- return typeof n == "string" ? this.matchRoutesInternal(
2088
- {
2089
- pathname: n,
2090
- search: e
2091
- },
2092
- o
2093
- ) : this.matchRoutesInternal(n, e);
2094
- }
2095
- matchRoutesInternal(n, e) {
2096
- const { foundRoute: o, matchedRoutes: r, routeParams: s } = this.getMatchedRoutes(
2097
- n,
2098
- e?.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
- ue(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
- }), e?.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 = Ye(l.options.validateSearch, k) ?? {};
2138
- return [
2139
- {
2140
- ...k,
2141
- ...T
2142
- },
2143
- void 0
2144
- ];
2145
- } catch (T) {
2146
- const I = new rt(T.message, {
2147
- cause: T
2148
- });
2149
- if (e?.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 = ke({
2156
- path: l.fullPath,
2157
- params: s,
2158
- decodeCharMap: this.pathParamsDecodeCharMap
2159
- }), F = ke({
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: oe([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: pe(),
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
- })), e?.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) && e?._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 rt extends Error {
2249
- }
2250
- class xn extends Error {
2251
- }
2252
- function En(t) {
2253
- return {
2254
- loadedAt: 0,
2255
- isLoading: !1,
2256
- isTransitioning: !1,
2257
- status: "idle",
2258
- resolvedLocation: { ...t },
2259
- location: t,
2260
- matches: [],
2261
- pendingMatches: [],
2262
- cachedMatches: [],
2263
- statusCode: 200
2264
- };
2265
- }
2266
- const Ue = b.createContext(void 0), In = b.createContext(
2267
- void 0
2268
- );
2269
- function he(t) {
2270
- const n = b.useContext(
2271
- t.from ? In : Ue
2272
- );
2273
- return z({
2274
- select: (o) => {
2275
- const r = o.matches.find(
2276
- (s) => t.from ? t.from === s.routeId : s.id === n
2277
- );
2278
- if (te(
2279
- !((t.shouldThrow ?? !0) && !r),
2280
- `Could not find ${t.from ? `an active match from "${t.from}"` : "a nearest match!"}`
2281
- ), r !== void 0)
2282
- return t.select ? t.select(r) : r;
2283
- },
2284
- structuralSharing: t.structuralSharing
2285
- });
2286
- }
2287
- function kn(t) {
2288
- return he({
2289
- from: t.from,
2290
- strict: t.strict,
2291
- structuralSharing: t.structuralSharing,
2292
- select: (n) => t.select ? t.select(n.loaderData) : n.loaderData
2293
- });
2294
- }
2295
- function Fn(t) {
2296
- const { select: n, ...e } = t;
2297
- return he({
2298
- ...e,
2299
- select: (o) => n ? n(o.loaderDeps) : o.loaderDeps
2300
- });
2301
- }
2302
- function Tn(t) {
2303
- return he({
2304
- from: t.from,
2305
- strict: t.strict,
2306
- structuralSharing: t.structuralSharing,
2307
- select: (n) => t.select ? t.select(n.params) : n.params
2308
- });
2309
- }
2310
- function Bn(t) {
2311
- return he({
2312
- from: t.from,
2313
- strict: t.strict,
2314
- structuralSharing: t.structuralSharing,
2315
- select: (n) => t.select ? t.select(n.search) : n.search
2316
- });
2317
- }
2318
- function Dn(t) {
2319
- const { navigate: n } = re();
2320
- return b.useCallback(
2321
- (e) => n({
2322
- ...e
2323
- }),
2324
- [n]
2325
- );
2326
- }
2327
- class Mt {
2328
- /**
2329
- * @deprecated Use the `createRoute` function instead.
2330
- */
2331
- constructor(n) {
2332
- this.init = (e) => {
2333
- var o, r;
2334
- this.originalIndex = e.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 : te(
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 = at(a));
2342
- const u = s?.id || a;
2343
- let c = i ? H : oe([
2344
- this.parentRoute.id === H ? "" : this.parentRoute.id,
2345
- u
2346
- ]);
2347
- a === H && (a = "/"), c !== H && (c = oe(["/", c]));
2348
- const d = c === H ? "/" : oe([this.parentRoute.fullPath, a]);
2349
- this._path = a, this._id = c, this._fullPath = d, this._to = d, this._ssr = s?.ssr ?? e.defaultSsr ?? !0;
2350
- }, this.updateLoader = (e) => (Object.assign(this.options, e), this), this.update = (e) => (Object.assign(this.options, e), this), this.lazy = (e) => (this.lazyFn = e, this), this.useMatch = (e) => he({
2351
- select: e?.select,
2352
- from: this.id,
2353
- structuralSharing: e?.structuralSharing
2354
- }), this.useRouteContext = (e) => he({
2355
- ...e,
2356
- from: this.id,
2357
- select: (o) => e?.select ? e.select(o.context) : o.context
2358
- }), this.useSearch = (e) => Bn({
2359
- select: e?.select,
2360
- structuralSharing: e?.structuralSharing,
2361
- from: this.id
2362
- }), this.useParams = (e) => Tn({
2363
- select: e?.select,
2364
- structuralSharing: e?.structuralSharing,
2365
- from: this.id
2366
- }), this.useLoaderDeps = (e) => Fn({ ...e, from: this.id }), this.useLoaderData = (e) => kn({ ...e, from: this.id }), this.useNavigate = () => Dn({ from: this.id }), this.options = n || {}, this.isRoot = !n?.getParentRoute, te(
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(t) {
2394
- return new Mt(t);
2395
- }
2396
- function io() {
2397
- return (t) => An(t);
2398
- }
2399
- class Vn extends Mt {
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(t) {
2417
- return new Vn(t);
2418
- }
2419
- function ao(t) {
2420
- return new Nn(t, {
2421
- silent: !0
2422
- }).createRoute;
2423
- }
2424
- class Nn {
2425
- constructor(n, e) {
2426
- this.path = n, this.createRoute = (o) => {
2427
- Me(
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 = e?.silent;
2434
- }
2435
- }
2436
- function Be(t) {
2437
- return /* @__PURE__ */ C(Ft, { children: t.children });
2438
- }
2439
- function xt(t, n, e) {
2440
- return n.options.notFoundComponent ? /* @__PURE__ */ C(n.options.notFoundComponent, { data: e }) : t.options.defaultNotFoundComponent ? /* @__PURE__ */ C(t.options.defaultNotFoundComponent, { data: e }) : /* @__PURE__ */ C(Cn, {});
2441
- }
2442
- const Et = b.memo(function({
2443
- matchId: n
2444
- }) {
2445
- var e, o;
2446
- const r = re(), 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
- te(
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 ?? ((e = r.options.notFoundRoute) == null ? void 0 : e.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 : Be
2462
- ), f = c ? ct : Be, p = l ? Rn : Be, S = z({
2463
- select: (g) => g.loadedAt
2464
- });
2465
- return /* @__PURE__ */ C(Ue.Provider, { value: n, children: /* @__PURE__ */ C(h, { fallback: u, children: /* @__PURE__ */ C(
2466
- f,
2467
- {
2468
- getResetKey: () => S,
2469
- errorComponent: c || Ke,
2470
- onCatch: (g, M) => {
2471
- if (ee(g)) throw g;
2472
- Me(!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 e, o, r;
2491
- const s = re(), { 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: ot(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) || Ke;
2505
- if (i.status === "notFound")
2506
- return te(ee(i.error), "Expected a notFound error"), xt(s, c, i.error);
2507
- if (i.status === "redirected")
2508
- throw te(ce(i.error), "Expected a redirect error"), (e = s.getMatch(i.id)) == null ? void 0 : e.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 = pe();
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 = re(), e = b.useContext(Ue), o = z({
2543
- select: (c) => {
2544
- var d;
2545
- return (d = c.matches.find((l) => l.id === e)) == 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 === e);
2550
- return te(
2551
- l,
2552
- `Could not find parent match for matchId "${e}"`
2553
- ), l.globalNotFound;
2554
- }
2555
- }), i = z({
2556
- select: (c) => {
2557
- var d;
2558
- const l = c.matches, h = l.findIndex((f) => f.id === e);
2559
- return (d = l[h + 1]) == null ? void 0 : d.id;
2560
- }
2561
- });
2562
- if (s)
2563
- return xt(n, r, void 0);
2564
- if (!i)
2565
- return null;
2566
- const a = /* @__PURE__ */ C(Et, { matchId: i }), u = n.options.defaultPendingComponent ? /* @__PURE__ */ C(n.options.defaultPendingComponent, {}) : null;
2567
- return e === H ? /* @__PURE__ */ C(b.Suspense, { fallback: u, children: a }) : a;
2568
- }), Un = "Error preloading route! ☝️";
2569
- function zn(t, n) {
2570
- const e = re(), [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
- } = t, {
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, ne = 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
- t = {
2616
- from: he({ strict: !1, select: (B) => B.pathname }),
2617
- ...t
2618
- };
2619
- const V = b.useMemo(
2620
- () => e.buildLocation(t),
2621
- [e, t, O]
2622
- ), A = b.useMemo(() => t.reloadDocument ? !1 : l ?? e.options.defaultPreload, [e.options.defaultPreload, l, t.reloadDocument]), N = h ?? e.options.defaultPreloadDelay ?? 0, G = z({
2623
- select: (B) => {
2624
- if (c?.exact) {
2625
- if (!Sn(
2626
- B.location.pathname,
2627
- V.pathname,
2628
- e.basepath
2629
- ))
2630
- return !1;
2631
- } else {
2632
- const $ = Ve(
2633
- B.location.pathname,
2634
- e.basepath
2635
- ).split("/");
2636
- if (!Ve(
2637
- V.pathname,
2638
- e.basepath
2639
- ).split("/").every(
2640
- (It, kt) => It === $[kt]
2641
- ))
2642
- return !1;
2643
- }
2644
- return (c?.includeSearch ?? !0) && !ge(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
- e.preloadRoute(t).catch((B) => {
2651
- console.warn(B), console.warn(Un);
2652
- });
2653
- }, [t, e]), xe = b.useCallback(
2654
- (B) => {
2655
- B?.isIntersecting && Y();
2656
- },
2657
- [Y]
2658
- );
2659
- if (vn(
2660
- i,
2661
- xe,
2662
- { rootMargin: "100px" },
2663
- { disabled: !!P || A !== "viewport" }
2664
- ), Re(() => {
2665
- s.current || !P && A === "render" && (Y(), s.current = !0);
2666
- }, [P, Y, A]), ne === "external")
2667
- return {
2668
- ...j,
2669
- ref: i,
2670
- type: ne,
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 Ee = (B) => {
2684
- if (!P && !Wn(B) && !B.defaultPrevented && (!L || L === "_self") && B.button === 0) {
2685
- B.preventDefault(), Bt(() => {
2686
- r(!0);
2687
- });
2688
- const $ = e.subscribe("onResolved", () => {
2689
- $(), r(!1);
2690
- });
2691
- return e.navigate({
2692
- ...t,
2693
- replace: p,
2694
- resetScroll: g,
2695
- hashScrollIntoView: f,
2696
- startTransition: S,
2697
- viewTransition: M,
2698
- ignoreBlocker: w
2699
- });
2700
- }
2701
- }, ie = (B) => {
2702
- P || A && Y();
2703
- }, U = ie, 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
- }, se = (B) => {
2714
- if (P) return;
2715
- const $ = B.target || {};
2716
- $.preloadTimeout && (clearTimeout($.preloadTimeout), $.preloadTimeout = null);
2717
- }, ae = (B) => ($) => {
2718
- var ze;
2719
- (ze = $.persist) == null || ze.call($), B.filter(Boolean).forEach((ut) => {
2720
- $.defaultPrevented || ut($);
2721
- });
2722
- }, we = G ? le(a, {}) ?? {} : {}, Pe = G ? {} : le(u, {}), fe = [
2723
- x,
2724
- we.className,
2725
- Pe.className
2726
- ].filter(Boolean).join(" "), lt = {
2727
- ...v,
2728
- ...we.style,
2729
- ...Pe.style
2730
- };
2731
- return {
2732
- ...j,
2733
- ...we,
2734
- ...Pe,
2735
- href: P ? void 0 : V.maskedLocation ? e.history.createHref(V.maskedLocation.href) : e.history.createHref(V.href),
2736
- ref: i,
2737
- onClick: ae([F, Ee]),
2738
- onFocus: ae([y, ie]),
2739
- onMouseEnter: ae([_, Q]),
2740
- onMouseLeave: ae([E, se]),
2741
- onTouchStart: ae([m, U]),
2742
- disabled: !!P,
2743
- target: L,
2744
- ...Object.keys(lt).length && { style: lt },
2745
- ...fe && { className: fe },
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
- (t, n) => {
2756
- const { _asChild: e, ...o } = t, {
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 e > "u" && delete i.disabled, b.createElement(
2764
- e || "a",
2765
- {
2766
- ...i,
2767
- ref: s
2768
- },
2769
- a
2770
- );
2771
- }
2772
- );
2773
- function Wn(t) {
2774
- return !!(t.metaKey || t.altKey || t.ctrlKey || t.shiftKey);
2775
- }
2776
- function Hn() {
2777
- const t = re(), n = b.useRef({ router: t, mounted: !1 }), e = 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 = Xe(e), a = e || o || s, u = Xe(a), c = e || s, d = Xe(c);
2783
- return t.isServer || (t.startReactTransition = (l) => {
2784
- r(!0), b.startTransition(() => {
2785
- l(), r(!1);
2786
- });
2787
- }), b.useEffect(() => {
2788
- const l = t.history.subscribe(t.load), h = t.buildLocation({
2789
- to: t.latestLocation.pathname,
2790
- search: !0,
2791
- params: !0,
2792
- hash: !0,
2793
- state: !0,
2794
- _includeValidateSearch: !0
2795
- });
2796
- return ue(t.latestLocation.href) !== ue(h.href) && t.commitLocation({ ...h, replace: !0 }), () => {
2797
- l();
2798
- };
2799
- }, [t, t.history]), Re(() => {
2800
- if (typeof window < "u" && t.clientSsr || n.current.router === t && n.current.mounted)
2801
- return;
2802
- n.current = { router: t, mounted: !0 }, (async () => {
2803
- try {
2804
- await t.load();
2805
- } catch (h) {
2806
- console.error(h);
2807
- }
2808
- })();
2809
- }, [t]), Re(() => {
2810
- if (i && !e) {
2811
- const l = t.state.location, h = t.state.resolvedLocation, f = h.pathname !== l.pathname, p = h.href !== l.href;
2812
- t.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, t, e]), Re(() => {
2822
- if (d && !c) {
2823
- const l = t.state.location, h = t.state.resolvedLocation, f = h.pathname !== l.pathname, p = h.href !== l.href;
2824
- t.emit({
2825
- type: "onBeforeRouteMount",
2826
- fromLocation: h,
2827
- toLocation: l,
2828
- pathChanged: f,
2829
- hrefChanged: p
2830
- });
2831
- }
2832
- }, [c, d, t]), Re(() => {
2833
- if (u && !a) {
2834
- const l = t.state.location, h = t.state.resolvedLocation, f = h.pathname !== l.pathname, p = h.href !== l.href;
2835
- if (t.emit({
2836
- type: "onResolved",
2837
- fromLocation: h,
2838
- toLocation: l,
2839
- pathChanged: f,
2840
- hrefChanged: p
2841
- }), t.__store.setState((S) => ({
2842
- ...S,
2843
- status: "idle",
2844
- resolvedLocation: S.location
2845
- })), typeof document < "u" && document.querySelector) {
2846
- const S = t.state.location.state.__hashScrollIntoViewOptions ?? !0;
2847
- if (S && t.state.location.hash !== "") {
2848
- const g = document.getElementById(t.state.location.hash);
2849
- g && g.scrollIntoView(S);
2850
- }
2851
- }
2852
- }
2853
- }, [a, u, t]), null;
2854
- }
2855
- function jn() {
2856
- const t = re(), n = t.options.defaultPendingComponent ? /* @__PURE__ */ C(t.options.defaultPendingComponent, {}) : null, e = t.isServer || typeof document < "u" && t.clientSsr ? Be : b.Suspense, o = /* @__PURE__ */ et(e, { fallback: n, children: [
2857
- /* @__PURE__ */ C(Hn, {}),
2858
- /* @__PURE__ */ C(Gn, {})
2859
- ] });
2860
- return t.options.InnerWrap ? /* @__PURE__ */ C(t.options.InnerWrap, { children: o }) : o;
2861
- }
2862
- function Gn() {
2863
- const t = z({
2864
- select: (e) => {
2865
- var o;
2866
- return (o = e.matches[0]) == null ? void 0 : o.id;
2867
- }
2868
- }), n = z({
2869
- select: (e) => e.loadedAt
2870
- });
2871
- return /* @__PURE__ */ C(Ue.Provider, { value: t, children: /* @__PURE__ */ C(
2872
- ct,
2873
- {
2874
- getResetKey: () => n,
2875
- errorComponent: Ke,
2876
- onCatch: (e) => {
2877
- Me(
2878
- !1,
2879
- "The following error wasn't caught by any route! At the very least, consider setting an 'errorComponent' in your RootRoute!"
2880
- ), Me(!1, e.message || e.toString());
2881
- },
2882
- children: t ? /* @__PURE__ */ C(Et, { matchId: t }) : null
2883
- }
2884
- ) });
2885
- }
2886
- function Xn({
2887
- router: t,
2888
- children: n,
2889
- ...e
2890
- }) {
2891
- t.update({
2892
- ...t.options,
2893
- ...e,
2894
- context: {
2895
- ...t.options.context,
2896
- ...e.context
2897
- }
2898
- });
2899
- const o = Ct(), r = /* @__PURE__ */ C(o.Provider, { value: t, children: n });
2900
- return t.options.Wrap ? /* @__PURE__ */ C(t.options.Wrap, { children: r }) : r;
2901
- }
2902
- function lo({ router: t, ...n }) {
2903
- return /* @__PURE__ */ C(Xn, { router: t, ...n, children: /* @__PURE__ */ C(jn, {}) });
2904
- }
2905
- const qn = typeof window < "u" ? b.useLayoutEffect : b.useEffect, Qe = "window", gt = "___";
2906
- let Ze = /* @__PURE__ */ new WeakSet();
2907
- const Jn = typeof window < "u" && window.sessionStorage, Z = Jn ? (() => {
2908
- const t = "tsr-scroll-restoration-v2";
2909
- return {
2910
- state: JSON.parse(
2911
- window.sessionStorage.getItem(t) || "null"
2912
- ) || { cached: {}, next: {} },
2913
- set: (e) => {
2914
- Z.state = le(e, Z.state), window.sessionStorage.setItem(t, JSON.stringify(Z.state));
2915
- }
2916
- };
2917
- })() : void 0, Yn = (t) => t.state.key || t.href;
2918
- function Qn(t) {
2919
- const n = re();
2920
- qn(() => {
2921
- const e = t?.getKey || Yn, { history: o } = window;
2922
- o.scrollRestoration = "manual";
2923
- const r = (a) => {
2924
- if (Ze.has(a.target)) return;
2925
- Ze.add(a.target);
2926
- let u = "";
2927
- if (a.target === document || a.target === window)
2928
- u = Qe;
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 = e(a.fromLocation);
2950
- for (const c in Z.state.next) {
2951
- const d = Z.state.next[c];
2952
- if (c === Qe)
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(gt)]: 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 = e(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(gt);
2982
- if (h === u) {
2983
- if (f === Qe)
2984
- c = !0, window.scrollTo({
2985
- top: l.scrollY,
2986
- left: l.scrollX,
2987
- behavior: t?.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: {} })), Ze = /* @__PURE__ */ new WeakSet();
2996
- }
2997
- }
2998
- );
2999
- return () => {
3000
- document.removeEventListener("scroll", r), s(), i();
3001
- };
3002
- }, [t?.getKey, n]);
3003
- }
3004
- function uo(t) {
3005
- return Qn(t), null;
3006
- }
3007
- function Zn(t) {
3008
- const n = [];
3009
- let e;
3010
- for (; e = t.parentNode; )
3011
- n.unshift(
3012
- `${t.tagName}:nth-child(${[].indexOf.call(e.children, t) + 1})`
3013
- ), t = e;
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
- _t as g,
3028
- ee as i,
3029
- ro as n,
3030
- re as u,
3031
- on as w
3032
- };