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