driftjs-router 0.0.8

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,1206 @@
1
+ import { createContext as e, onUnmount as t } from "driftjs-shared";
2
+ //#region src/path.ts
3
+ function n(e) {
4
+ if (!e || e === "/") return "/";
5
+ let t = e.replace(/\/+/g, "/");
6
+ return t.startsWith("/") || (t = "/" + t), t.length > 1 && t.endsWith("/") && (t = t.slice(0, -1)), t;
7
+ }
8
+ function r(e) {
9
+ if (!e) return "";
10
+ let t = e.trim();
11
+ return t.startsWith("/") || (t = "/" + t), t.length > 1 && t.endsWith("/") && (t = t.slice(0, -1)), t === "/" ? "" : t;
12
+ }
13
+ function i(e, t) {
14
+ if (!t) return e;
15
+ if (e.startsWith(t)) {
16
+ let n = e.slice(t.length);
17
+ return n.startsWith("/") ? n : "/" + n;
18
+ }
19
+ return e;
20
+ }
21
+ function a(e, t) {
22
+ let n = t.startsWith("/") ? t : "/" + t;
23
+ return e ? e + n : n;
24
+ }
25
+ function o(e, t) {
26
+ let n = t.startsWith("/") ? t : "/" + t;
27
+ return (e || "") + "#" + n;
28
+ }
29
+ //#endregion
30
+ //#region src/history.ts
31
+ function s() {
32
+ let e = [];
33
+ return {
34
+ get list() {
35
+ return e;
36
+ },
37
+ listen(t) {
38
+ return e.push(t), () => {
39
+ let n = e.indexOf(t);
40
+ n !== -1 && e.splice(n, 1);
41
+ };
42
+ },
43
+ notify(t, n, r) {
44
+ for (let i of e) i(t, n, r);
45
+ },
46
+ clear() {
47
+ e.length = 0;
48
+ }
49
+ };
50
+ }
51
+ function c(e) {
52
+ if (typeof window > "u") return null;
53
+ let t = e ?? window.history.state;
54
+ if (!t || typeof t != "object") return t ?? null;
55
+ let { __drift_pos: n, __drift_has_data: r, ...i } = t;
56
+ return Object.keys(i).length > 0 || r ? i : null;
57
+ }
58
+ function l(e, t) {
59
+ return {
60
+ ...e || {},
61
+ __drift_pos: t,
62
+ ...e === void 0 ? {} : { __drift_has_data: !0 }
63
+ };
64
+ }
65
+ function u(e = "") {
66
+ let t = r(e), n = s(), o = () => typeof window > "u" ? "/" : window.location.pathname + window.location.search + window.location.hash, u = () => i(o(), t) || "/", d = u(), f = typeof window < "u" && window.history.state && typeof window.history.state.__drift_pos == "number" ? window.history.state.__drift_pos : 0;
67
+ if (typeof window < "u" && (window.history.state == null || typeof window.history.state.__drift_pos != "number")) {
68
+ let e = window.history.state || {};
69
+ window.history.replaceState({
70
+ ...e,
71
+ __drift_pos: f
72
+ }, "", a(t, d));
73
+ }
74
+ let p = (e) => {
75
+ let t = d, r = u();
76
+ d = r;
77
+ let i = typeof window < "u" && window.history.state || e.state || null, a = i && typeof i.__drift_pos == "number" ? i.__drift_pos : f, o = a - f;
78
+ f = a;
79
+ let s = {
80
+ direction: o > 0 ? "forward" : o < 0 ? "back" : "unknown",
81
+ delta: o,
82
+ type: "pop"
83
+ };
84
+ n.notify(r, t, s);
85
+ };
86
+ return typeof window < "u" && window.addEventListener("popstate", p), {
87
+ get base() {
88
+ return t;
89
+ },
90
+ get location() {
91
+ return u();
92
+ },
93
+ get state() {
94
+ return c(window.history.state);
95
+ },
96
+ listen(e) {
97
+ return n.listen(e);
98
+ },
99
+ push(e, n) {
100
+ if (typeof window > "u") return;
101
+ f++;
102
+ let r = a(t, e), i = l(n, f);
103
+ window.history.pushState(i, "", r), d = e;
104
+ },
105
+ replace(e, n) {
106
+ if (typeof window > "u") return;
107
+ let r = a(t, e), i = l(n, f);
108
+ window.history.replaceState(i, "", r), d = e;
109
+ },
110
+ go(e) {
111
+ typeof window < "u" && window.history.go(e);
112
+ },
113
+ destroy() {
114
+ typeof window < "u" && window.removeEventListener("popstate", p), n.clear();
115
+ }
116
+ };
117
+ }
118
+ function d(e = "") {
119
+ let t = r(e), n = s(), i = () => {
120
+ if (typeof window > "u") return "/";
121
+ let e = window.location.hash;
122
+ if (!e || e === "#") return "/";
123
+ let t = e.startsWith("#") ? e.slice(1) : e;
124
+ return t.startsWith("/") ? t : "/" + t;
125
+ }, a = i(), u = typeof window < "u" && window.history.state && typeof window.history.state.__drift_pos == "number" ? window.history.state.__drift_pos : 0;
126
+ if (typeof window < "u" && (window.history.state == null || typeof window.history.state.__drift_pos != "number")) {
127
+ let e = window.history.state || {};
128
+ window.history.replaceState({
129
+ ...e,
130
+ __drift_pos: u
131
+ }, "", o(t, a));
132
+ }
133
+ let d = (e) => {
134
+ let t = i();
135
+ if (t === a) return;
136
+ let r = a;
137
+ a = t;
138
+ let o = typeof window < "u" && window.history.state || null, s = o && typeof o.__drift_pos == "number" ? o.__drift_pos : u, c = s - u;
139
+ u = s;
140
+ let l = {
141
+ direction: c > 0 ? "forward" : c < 0 ? "back" : "unknown",
142
+ delta: c,
143
+ type: "pop"
144
+ };
145
+ n.notify(t, r, l);
146
+ };
147
+ return typeof window < "u" && (window.addEventListener("popstate", d), window.addEventListener("hashchange", d)), {
148
+ get base() {
149
+ return t;
150
+ },
151
+ get location() {
152
+ return i();
153
+ },
154
+ get state() {
155
+ return c(window.history.state);
156
+ },
157
+ listen(e) {
158
+ return n.listen(e);
159
+ },
160
+ push(e, n) {
161
+ if (typeof window > "u") return;
162
+ u++;
163
+ let r = o(t, e), i = l(n, u);
164
+ window.history.pushState(i, "", r), a = e;
165
+ },
166
+ replace(e, n) {
167
+ if (typeof window > "u") return;
168
+ let r = o(t, e), i = l(n, u);
169
+ window.history.replaceState(i, "", r), a = e;
170
+ },
171
+ go(e) {
172
+ typeof window < "u" && window.history.go(e);
173
+ },
174
+ destroy() {
175
+ typeof window < "u" && (window.removeEventListener("popstate", d), window.removeEventListener("hashchange", d)), n.clear();
176
+ }
177
+ };
178
+ }
179
+ function f(e = "/", t = "") {
180
+ let n = r(t), a = [i(e.startsWith("/") ? e : "/" + e, n) || "/"], o = [null], s = 0, c = [];
181
+ return {
182
+ get base() {
183
+ return n;
184
+ },
185
+ get location() {
186
+ return a[s] ?? "/";
187
+ },
188
+ get state() {
189
+ return o[s] ?? null;
190
+ },
191
+ listen(e) {
192
+ return c.push(e), () => {
193
+ let t = c.indexOf(e);
194
+ t !== -1 && c.splice(t, 1);
195
+ };
196
+ },
197
+ push(e, t) {
198
+ let n = e.startsWith("/") ? e : "/" + e;
199
+ a.splice(s + 1), o.splice(s + 1), a.push(n), o.push(t || null), s++;
200
+ },
201
+ replace(e, t) {
202
+ let n = e.startsWith("/") ? e : "/" + e;
203
+ a[s] = n, o[s] = t || null;
204
+ },
205
+ go(e) {
206
+ let t = a[s] ?? "/", n = s + e;
207
+ if (n >= 0 && n < a.length) {
208
+ s = n;
209
+ let r = a[s] ?? "/", i = {
210
+ direction: e > 0 ? "forward" : e < 0 ? "back" : "unknown",
211
+ delta: e,
212
+ type: "pop"
213
+ };
214
+ for (let e of c) e(r, t, i);
215
+ }
216
+ },
217
+ destroy() {
218
+ c.length = 0, a.length = 0, o.length = 0, s = 0;
219
+ }
220
+ };
221
+ }
222
+ //#endregion
223
+ //#region ../../node_modules/.pnpm/path-to-regexp@6.3.0/node_modules/path-to-regexp/dist.es2015/index.js
224
+ function p(e) {
225
+ for (var t = [], n = 0; n < e.length;) {
226
+ var r = e[n];
227
+ if (r === "*" || r === "+" || r === "?") {
228
+ t.push({
229
+ type: "MODIFIER",
230
+ index: n,
231
+ value: e[n++]
232
+ });
233
+ continue;
234
+ }
235
+ if (r === "\\") {
236
+ t.push({
237
+ type: "ESCAPED_CHAR",
238
+ index: n++,
239
+ value: e[n++]
240
+ });
241
+ continue;
242
+ }
243
+ if (r === "{") {
244
+ t.push({
245
+ type: "OPEN",
246
+ index: n,
247
+ value: e[n++]
248
+ });
249
+ continue;
250
+ }
251
+ if (r === "}") {
252
+ t.push({
253
+ type: "CLOSE",
254
+ index: n,
255
+ value: e[n++]
256
+ });
257
+ continue;
258
+ }
259
+ if (r === ":") {
260
+ for (var i = "", a = n + 1; a < e.length;) {
261
+ var o = e.charCodeAt(a);
262
+ if (o >= 48 && o <= 57 || o >= 65 && o <= 90 || o >= 97 && o <= 122 || o === 95) {
263
+ i += e[a++];
264
+ continue;
265
+ }
266
+ break;
267
+ }
268
+ if (!i) throw TypeError(`Missing parameter name at ${n}`);
269
+ t.push({
270
+ type: "NAME",
271
+ index: n,
272
+ value: i
273
+ }), n = a;
274
+ continue;
275
+ }
276
+ if (r === "(") {
277
+ var s = 1, c = "", a = n + 1;
278
+ if (e[a] === "?") throw TypeError(`Pattern cannot start with "?" at ${a}`);
279
+ for (; a < e.length;) {
280
+ if (e[a] === "\\") {
281
+ c += e[a++] + e[a++];
282
+ continue;
283
+ }
284
+ if (e[a] === ")") {
285
+ if (s--, s === 0) {
286
+ a++;
287
+ break;
288
+ }
289
+ } else if (e[a] === "(" && (s++, e[a + 1] !== "?")) throw TypeError(`Capturing groups are not allowed at ${a}`);
290
+ c += e[a++];
291
+ }
292
+ if (s) throw TypeError(`Unbalanced pattern at ${n}`);
293
+ if (!c) throw TypeError(`Missing pattern at ${n}`);
294
+ t.push({
295
+ type: "PATTERN",
296
+ index: n,
297
+ value: c
298
+ }), n = a;
299
+ continue;
300
+ }
301
+ t.push({
302
+ type: "CHAR",
303
+ index: n,
304
+ value: e[n++]
305
+ });
306
+ }
307
+ return t.push({
308
+ type: "END",
309
+ index: n,
310
+ value: ""
311
+ }), t;
312
+ }
313
+ function m(e, t) {
314
+ t === void 0 && (t = {});
315
+ for (var n = p(e), r = t.prefixes, i = r === void 0 ? "./" : r, a = t.delimiter, o = a === void 0 ? "/#?" : a, s = [], c = 0, l = 0, u = "", d = function(e) {
316
+ if (l < n.length && n[l].type === e) return n[l++].value;
317
+ }, f = function(e) {
318
+ var t = d(e);
319
+ if (t !== void 0) return t;
320
+ var r = n[l], i = r.type, a = r.index;
321
+ throw TypeError(`Unexpected ${i} at ${a}, expected ${e}`);
322
+ }, m = function() {
323
+ for (var e = "", t; t = d("CHAR") || d("ESCAPED_CHAR");) e += t;
324
+ return e;
325
+ }, h = function(e) {
326
+ for (var t = 0, n = o; t < n.length; t++) {
327
+ var r = n[t];
328
+ if (e.indexOf(r) > -1) return !0;
329
+ }
330
+ return !1;
331
+ }, g = function(e) {
332
+ var t = s[s.length - 1], n = e || (t && typeof t == "string" ? t : "");
333
+ if (t && !n) throw TypeError(`Must have text between two parameters, missing text after "${t.name}"`);
334
+ return !n || h(n) ? `[^${_(o)}]+?` : `(?:(?!${_(n)})[^${_(o)}])+?`;
335
+ }; l < n.length;) {
336
+ var v = d("CHAR"), y = d("NAME"), b = d("PATTERN");
337
+ if (y || b) {
338
+ var x = v || "";
339
+ i.indexOf(x) === -1 && (u += x, x = ""), u &&= (s.push(u), ""), s.push({
340
+ name: y || c++,
341
+ prefix: x,
342
+ suffix: "",
343
+ pattern: b || g(x),
344
+ modifier: d("MODIFIER") || ""
345
+ });
346
+ continue;
347
+ }
348
+ var S = v || d("ESCAPED_CHAR");
349
+ if (S) {
350
+ u += S;
351
+ continue;
352
+ }
353
+ if (u &&= (s.push(u), ""), d("OPEN")) {
354
+ var x = m(), C = d("NAME") || "", w = d("PATTERN") || "", T = m();
355
+ f("CLOSE"), s.push({
356
+ name: C || (w ? c++ : ""),
357
+ pattern: C && !w ? g(x) : w,
358
+ prefix: x,
359
+ suffix: T,
360
+ modifier: d("MODIFIER") || ""
361
+ });
362
+ continue;
363
+ }
364
+ f("END");
365
+ }
366
+ return s;
367
+ }
368
+ function h(e, t) {
369
+ return g(m(e, t), t);
370
+ }
371
+ function g(e, t) {
372
+ t === void 0 && (t = {});
373
+ var n = v(t), r = t.encode, i = r === void 0 ? function(e) {
374
+ return e;
375
+ } : r, a = t.validate, o = a === void 0 || a, s = e.map(function(e) {
376
+ if (typeof e == "object") return RegExp(`^(?:${e.pattern})\$`, n);
377
+ });
378
+ return function(t) {
379
+ for (var n = "", r = 0; r < e.length; r++) {
380
+ var a = e[r];
381
+ if (typeof a == "string") {
382
+ n += a;
383
+ continue;
384
+ }
385
+ var c = t ? t[a.name] : void 0, l = a.modifier === "?" || a.modifier === "*", u = a.modifier === "*" || a.modifier === "+";
386
+ if (Array.isArray(c)) {
387
+ if (!u) throw TypeError(`Expected "${a.name}" to not repeat, but got an array`);
388
+ if (c.length === 0) {
389
+ if (l) continue;
390
+ throw TypeError(`Expected "${a.name}" to not be empty`);
391
+ }
392
+ for (var d = 0; d < c.length; d++) {
393
+ var f = i(c[d], a);
394
+ if (o && !s[r].test(f)) throw TypeError(`Expected all "${a.name}" to match "${a.pattern}", but got "${f}"`);
395
+ n += a.prefix + f + a.suffix;
396
+ }
397
+ continue;
398
+ }
399
+ if (typeof c == "string" || typeof c == "number") {
400
+ var f = i(String(c), a);
401
+ if (o && !s[r].test(f)) throw TypeError(`Expected "${a.name}" to match "${a.pattern}", but got "${f}"`);
402
+ n += a.prefix + f + a.suffix;
403
+ continue;
404
+ }
405
+ if (!l) {
406
+ var p = u ? "an array" : "a string";
407
+ throw TypeError(`Expected "${a.name}" to be ${p}`);
408
+ }
409
+ }
410
+ return n;
411
+ };
412
+ }
413
+ function _(e) {
414
+ return e.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
415
+ }
416
+ function v(e) {
417
+ return e && e.sensitive ? "" : "i";
418
+ }
419
+ function y(e, t) {
420
+ if (!t) return e;
421
+ for (var n = /\((?:\?<(.*?)>)?(?!\?)/g, r = 0, i = n.exec(e.source); i;) t.push({
422
+ name: i[1] || r++,
423
+ prefix: "",
424
+ suffix: "",
425
+ modifier: "",
426
+ pattern: ""
427
+ }), i = n.exec(e.source);
428
+ return e;
429
+ }
430
+ function b(e, t, n) {
431
+ var r = e.map(function(e) {
432
+ return C(e, t, n).source;
433
+ });
434
+ return RegExp(`(?:${r.join("|")})`, v(n));
435
+ }
436
+ function x(e, t, n) {
437
+ return S(m(e, n), t, n);
438
+ }
439
+ function S(e, t, n) {
440
+ n === void 0 && (n = {});
441
+ for (var r = n.strict, i = r !== void 0 && r, a = n.start, o = a === void 0 || a, s = n.end, c = s === void 0 || s, l = n.encode, u = l === void 0 ? function(e) {
442
+ return e;
443
+ } : l, d = n.delimiter, f = d === void 0 ? "/#?" : d, p = n.endsWith, m = `[${_(p === void 0 ? "" : p)}]|\$`, h = `[${_(f)}]`, g = o ? "^" : "", y = 0, b = e; y < b.length; y++) {
444
+ var x = b[y];
445
+ if (typeof x == "string") g += _(u(x));
446
+ else {
447
+ var S = _(u(x.prefix)), C = _(u(x.suffix));
448
+ if (x.pattern) if (t && t.push(x), S || C) if (x.modifier === "+" || x.modifier === "*") {
449
+ var w = x.modifier === "*" ? "?" : "";
450
+ g += `(?:${S}((?:${x.pattern})(?:${C}${S}(?:${x.pattern}))*)${C})${w}`;
451
+ } else g += `(?:${S}(${x.pattern})${C})${x.modifier}`;
452
+ else {
453
+ if (x.modifier === "+" || x.modifier === "*") throw TypeError(`Can not repeat "${x.name}" without a prefix and suffix`);
454
+ g += `(${x.pattern})${x.modifier}`;
455
+ }
456
+ else g += `(?:${S}${C})${x.modifier}`;
457
+ }
458
+ }
459
+ if (c) i || (g += `${h}?`), g += n.endsWith ? `(?=${m})` : "$";
460
+ else {
461
+ var T = e[e.length - 1], E = typeof T == "string" ? h.indexOf(T[T.length - 1]) > -1 : T === void 0;
462
+ i || (g += `(?:${h}(?=${m}))?`), E || (g += `(?=${h}|${m})`);
463
+ }
464
+ return new RegExp(g, v(n));
465
+ }
466
+ function C(e, t, n) {
467
+ return e instanceof RegExp ? y(e, t) : Array.isArray(e) ? b(e, t, n) : x(e, t, n);
468
+ }
469
+ //#endregion
470
+ //#region src/matcher.ts
471
+ function w(e) {
472
+ try {
473
+ return decodeURIComponent(e);
474
+ } catch {
475
+ return e;
476
+ }
477
+ }
478
+ function T(e) {
479
+ let t = Object.create(null);
480
+ if (!e) return t;
481
+ let n = e.startsWith("?") ? e.slice(1) : e;
482
+ if (!n) return t;
483
+ let r = new URLSearchParams(n), i = /* @__PURE__ */ new Set();
484
+ for (let e of r.keys()) {
485
+ if (e === "__proto__" || e === "constructor" || e === "prototype" || i.has(e)) continue;
486
+ i.add(e);
487
+ let n = r.getAll(e);
488
+ t[e] = n.length > 1 ? n : n[0] ?? null;
489
+ }
490
+ for (let e of n.split("&")) if (e && e.indexOf("=") === -1) try {
491
+ let n = decodeURIComponent(e);
492
+ n !== "__proto__" && n !== "constructor" && n !== "prototype" && t[n] === "" && (t[n] = null);
493
+ } catch {
494
+ e !== "__proto__" && e !== "constructor" && e !== "prototype" && t[e] === "" && (t[e] = null);
495
+ }
496
+ return t;
497
+ }
498
+ function E(e) {
499
+ let t = Object.keys(e);
500
+ if (t.length === 0) return "";
501
+ let n = [];
502
+ for (let r of t) {
503
+ if (r === "__proto__") continue;
504
+ let t = e[r];
505
+ if (t === void 0) continue;
506
+ let i = encodeURIComponent(r);
507
+ if (t === null) n.push(i);
508
+ else if (Array.isArray(t)) for (let e of t) e == null ? n.push(i) : n.push(`${i}=${encodeURIComponent(e)}`);
509
+ else n.push(`${i}=${encodeURIComponent(t)}`);
510
+ }
511
+ return n.length > 0 ? "?" + n.join("&") : "";
512
+ }
513
+ function D(e) {
514
+ let t = e.replace(/\/\*$/, "/(.*)"), n = 0, r = "";
515
+ for (; n < t.length;) if (t[n] === ":" && /[a-zA-Z0-9_$]/.test(t[n + 1] || "")) {
516
+ let e = "";
517
+ for (n++; n < t.length && /[a-zA-Z0-9_$]/.test(t[n]);) e += t[n], n++;
518
+ if (t[n] === "(") {
519
+ let i = 1, a = "";
520
+ for (n++; n < t.length && i > 0;) {
521
+ if (t[n] === "\\") {
522
+ a += t[n] + (t[n + 1] || ""), n += 2;
523
+ continue;
524
+ }
525
+ if (t[n] === "(") {
526
+ i++, a += "(?:", n++;
527
+ continue;
528
+ }
529
+ if (t[n] === ")" && (i--, i === 0)) {
530
+ n++;
531
+ break;
532
+ }
533
+ a += t[n], n++;
534
+ }
535
+ r += `:${e}(${a})`;
536
+ } else r += `:${e}`;
537
+ } else r += t[n], n++;
538
+ return r;
539
+ }
540
+ function O(e, t) {
541
+ let n = {};
542
+ for (let [e, r] of Object.entries(t)) r != null && (n[e] = r);
543
+ try {
544
+ return h(D(e.replace(/\/\*$/, "/:pathMatch(.*)")), {
545
+ validate: !1,
546
+ encode: (e) => e
547
+ })(n);
548
+ } catch {
549
+ let t = e;
550
+ for (let [e, r] of Object.entries(n)) t = e === "pathMatch" ? t.replace(/\/\*$/, "/" + (Array.isArray(r) ? r.join("/") : String(r))) : t.replace(RegExp(`:${e}\\b(?:\\([^)]+\\))?[?*+]?`, "g"), Array.isArray(r) ? r.join("/") : String(r));
551
+ return t = t.replace(/\/:[a-zA-Z0-9_$]+\?/g, "").replace(/:[a-zA-Z0-9_$]+\?/g, ""), t;
552
+ }
553
+ }
554
+ function k(e) {
555
+ if (e === "/" || e === "") return {
556
+ regex: /^\/?$/,
557
+ paramNames: [],
558
+ score: 1e3
559
+ };
560
+ let t = D(e), n = [], r = C(t, n, {
561
+ sensitive: !1,
562
+ strict: !1,
563
+ end: !0
564
+ }), i = n.map((e) => typeof e.name == "number" ? "pathMatch" : String(e.name)), a = 0;
565
+ for (let t of e.split("/").filter(Boolean)) t === "*" || t.includes("(.*)") ? a += 1 : t.includes(":") ? t.includes("(") ? a += 30 : t.includes("?") ? a += 15 : a += 20 : a += 100;
566
+ return {
567
+ regex: r,
568
+ paramNames: i,
569
+ score: a
570
+ };
571
+ }
572
+ function A(e, t) {
573
+ let r = e.path;
574
+ r = t ? e.path.startsWith("/") ? n(e.path) : n(`${t.path === "/" ? "" : t.path}/${e.path}`) : n(e.path);
575
+ let { regex: i, paramNames: a, score: o } = k(r), s = {};
576
+ e.components ? Object.assign(s, e.components) : e.component && (s.default = e.component);
577
+ let c = e.beforeEnter ? Array.isArray(e.beforeEnter) ? e.beforeEnter : [e.beforeEnter] : void 0, l = {};
578
+ typeof e.props == "boolean" || typeof e.props == "function" ? l.default = e.props : e.props && typeof e.props == "object" && (l = e.props);
579
+ let u = {
580
+ path: r,
581
+ name: e.name,
582
+ components: s,
583
+ children: [],
584
+ meta: e.meta || {},
585
+ beforeEnter: c,
586
+ props: l,
587
+ parent: t,
588
+ regex: i,
589
+ paramNames: a,
590
+ score: o,
591
+ redirect: e.redirect
592
+ };
593
+ return e.children && e.children.length > 0 && (u.children = e.children.map((e) => A(e, u))), u;
594
+ }
595
+ function j(e) {
596
+ let t = [], r = /* @__PURE__ */ new Map(), i = [];
597
+ function a(e, t) {
598
+ t.push(e), e.name && r.set(e.name, e);
599
+ for (let n of e.children) a(n, t);
600
+ }
601
+ function o() {
602
+ r.clear();
603
+ let e = [];
604
+ for (let t of i) a(t, e);
605
+ t = e.sort((e, t) => {
606
+ let n = e.score ?? 0;
607
+ return (t.score ?? 0) - n;
608
+ });
609
+ }
610
+ for (let t of e) i.push(A(t));
611
+ o();
612
+ function s(e) {
613
+ let r = n(e);
614
+ for (let e of t) {
615
+ let t = r.match(e.regex);
616
+ if (t) {
617
+ let n = {};
618
+ for (let r = 0; r < e.paramNames.length; r++) {
619
+ let i = e.paramNames[r], a = t[r + 1];
620
+ n[i] = a === void 0 ? "" : w(a);
621
+ }
622
+ return {
623
+ record: e,
624
+ params: n
625
+ };
626
+ }
627
+ }
628
+ return {
629
+ record: null,
630
+ params: {}
631
+ };
632
+ }
633
+ function c(e, t) {
634
+ let i = "/", a = {}, o = "", c = {}, l;
635
+ if (typeof e == "string") {
636
+ let t = e.indexOf("#"), n = e;
637
+ t !== -1 && (o = e.slice(t), n = e.slice(0, t));
638
+ let r = n.indexOf("?");
639
+ r === -1 ? i = n : (a = T(n.slice(r)), i = n.slice(0, r));
640
+ } else {
641
+ if (e.name) {
642
+ l = e.name;
643
+ let t = r.get(l);
644
+ t && (i = t.path, c = { ...e.params || {} }, i = O(i, c));
645
+ } else e.path && (i = e.path);
646
+ e.query && (a = { ...e.query }), e.hash && (o = e.hash.startsWith("#") ? e.hash : "#" + e.hash), e.params && (c = {
647
+ ...c,
648
+ ...e.params
649
+ });
650
+ }
651
+ i = n(i);
652
+ let { record: u, params: d } = s(i), f = {
653
+ ...d,
654
+ ...c
655
+ }, p = [];
656
+ if (u) {
657
+ let e = u;
658
+ for (; e;) p.unshift(e), e = e.parent;
659
+ }
660
+ let m = E(a), h = i + m + o;
661
+ return {
662
+ path: i,
663
+ fullPath: h,
664
+ query: a,
665
+ hash: o,
666
+ params: f,
667
+ name: u?.name || l,
668
+ matched: p,
669
+ meta: u?.meta || {},
670
+ href: h
671
+ };
672
+ }
673
+ return {
674
+ resolve: c,
675
+ addRoute(e, t) {
676
+ if (typeof e == "string" && t) {
677
+ let n = r.get(e);
678
+ if (n) {
679
+ let e = A(t, n);
680
+ return n.children.push(e), o(), () => {
681
+ let t = n.children.indexOf(e);
682
+ t !== -1 && (n.children.splice(t, 1), o());
683
+ };
684
+ }
685
+ } else if (typeof e == "object") {
686
+ let t = A(e);
687
+ return i.push(t), o(), () => {
688
+ let e = i.indexOf(t);
689
+ e !== -1 && (i.splice(e, 1), o());
690
+ };
691
+ }
692
+ return () => {};
693
+ },
694
+ removeRoute(e) {
695
+ let t = r.get(e);
696
+ if (t) {
697
+ if (t.parent) {
698
+ let e = t.parent.children.indexOf(t);
699
+ e !== -1 && t.parent.children.splice(e, 1);
700
+ } else {
701
+ let e = i.indexOf(t);
702
+ e !== -1 && i.splice(e, 1);
703
+ }
704
+ o();
705
+ }
706
+ },
707
+ hasRoute(e) {
708
+ return r.has(e);
709
+ },
710
+ getRoutes() {
711
+ return [...t];
712
+ }
713
+ };
714
+ }
715
+ //#endregion
716
+ //#region types/index.ts
717
+ var M = /* @__PURE__ */ function(e) {
718
+ return e[e.aborted = 4] = "aborted", e[e.cancelled = 8] = "cancelled", e[e.duplicated = 16] = "duplicated", e;
719
+ }({}), N = e(void 0, "DriftRouter"), P = e(void 0, "DriftRoute"), F = e(0, "DriftRouterDepth"), I = Object.freeze({
720
+ path: "/",
721
+ fullPath: "/",
722
+ query: {},
723
+ hash: "",
724
+ params: {},
725
+ name: void 0,
726
+ matched: [],
727
+ meta: {},
728
+ href: "/"
729
+ });
730
+ function L(e, t, n, r) {
731
+ let i = "Navigation failed";
732
+ e === M.aborted ? i = `Navigation aborted from "${t.fullPath}" to "${n.fullPath}" via a navigation guard.` : e === M.cancelled ? i = `Navigation cancelled from "${t.fullPath}" to "${n.fullPath}" with a newer navigation.` : e === M.duplicated && (i = `Avoided redundant navigation to current location: "${n.fullPath}".`);
733
+ let a = Error(r || i);
734
+ return a.name = "NavigationFailure", a.type = e, a.from = t, a.to = n, a;
735
+ }
736
+ function R(e, t) {
737
+ return !e || typeof e != "object" || e.name !== "NavigationFailure" || typeof e.type != "number" ? !1 : t === void 0 || e.type === t;
738
+ }
739
+ async function z(e) {
740
+ for (let t of e) for (let e of Object.keys(t.components)) {
741
+ let n = t.components[e];
742
+ if (typeof n == "function" && !("__drift_fn__" in n) && !n.bytecode) try {
743
+ let r = await n();
744
+ t.components[e] = r?.default || r;
745
+ } catch (e) {
746
+ throw console.error(`[DriftRouter] Failed to resolve async route component for path "${t.path}":`, e), e;
747
+ }
748
+ }
749
+ }
750
+ async function B(e, t, n) {
751
+ for (let r of e) {
752
+ let e;
753
+ try {
754
+ if (r.length >= 3) e = await new Promise((e, i) => {
755
+ let a = !1, o = (t) => {
756
+ a || (a = !0, e(t));
757
+ };
758
+ try {
759
+ let s = r(t, n, o);
760
+ s instanceof Promise && s.then((t) => {
761
+ a || (a = !0, e(t));
762
+ }).catch(i);
763
+ } catch (e) {
764
+ i(e);
765
+ }
766
+ });
767
+ else {
768
+ let i = r(t, n, () => {});
769
+ e = i instanceof Promise ? await i : i;
770
+ }
771
+ } catch (e) {
772
+ return e instanceof Error ? e : Error(String(e));
773
+ }
774
+ if (e !== void 0 && e !== !0) return e;
775
+ }
776
+ return !0;
777
+ }
778
+ function V(e) {
779
+ let { history: t, routes: n, scrollBehavior: r, linkActiveClass: i, linkExactActiveClass: a } = e, o = j(n), s = [], c = [], l = [], u = [], d = [], f = I, p = null, m = null, h = null;
780
+ p = new Promise((e, t) => {
781
+ m = e, h = t;
782
+ });
783
+ let g = 0;
784
+ function _(e) {
785
+ if (u.length > 0) for (let t of u) t(e);
786
+ }
787
+ function v(e, t, n) {
788
+ if (!(typeof window > "u" || !r)) try {
789
+ let i = r(e, t, n);
790
+ if (!i) return;
791
+ let a = (e) => {
792
+ if ("el" in e) {
793
+ let t = typeof e.el == "string" ? document.querySelector(e.el) : e.el;
794
+ t && t.scrollIntoView({ behavior: e.behavior || "auto" });
795
+ } else window.scrollTo({
796
+ left: e.left ?? window.scrollX,
797
+ top: e.top ?? window.scrollY,
798
+ behavior: e.behavior || "auto"
799
+ });
800
+ };
801
+ i instanceof Promise ? i.then((e) => {
802
+ e && a(e);
803
+ }) : a(i);
804
+ } catch {}
805
+ }
806
+ async function y(e, n = !1, r = !1, i = 0) {
807
+ if (i > 20) {
808
+ let t = o.resolve(e, f);
809
+ return L(M.aborted, f, t, "Infinite redirect loop detected");
810
+ }
811
+ let a = o.resolve(e, f), u = f;
812
+ if (a.matched.length > 0) {
813
+ let e = a.matched[a.matched.length - 1];
814
+ if (e.redirect) return y(typeof e.redirect == "function" ? e.redirect(a) : e.redirect, !0, r, i + 1);
815
+ }
816
+ if (u.fullPath === a.fullPath && u !== I) return L(M.duplicated, u, a);
817
+ let p = ++g, m = [...s];
818
+ for (let e of a.matched) e.beforeEnter && m.push(...e.beforeEnter);
819
+ let h = await B(m, a, u);
820
+ if (p !== g) return L(M.cancelled, u, a);
821
+ if (h === !1) return L(M.aborted, u, a);
822
+ if (h instanceof Error) return _(h), L(M.aborted, u, a, h.message);
823
+ if (typeof h == "string" || typeof h == "object" && h) return y(h, n, r, i + 1);
824
+ try {
825
+ await z(a.matched);
826
+ } catch (e) {
827
+ return _(e), L(M.aborted, u, a, String(e));
828
+ }
829
+ if (p !== g) return L(M.cancelled, u, a);
830
+ if (c.length > 0) {
831
+ let e = await B(c, a, u);
832
+ if (p !== g) return L(M.cancelled, u, a);
833
+ if (e === !1) return L(M.aborted, u, a);
834
+ if (e instanceof Error) return _(e), L(M.aborted, u, a, e.message);
835
+ if (typeof e == "string" || typeof e == "object" && e) return y(e, n, r, i + 1);
836
+ }
837
+ r || (n ? t.replace(a.fullPath) : t.push(a.fullPath));
838
+ let b = f;
839
+ f = Object.freeze(a), v(f, b, t.state);
840
+ for (let e of l) try {
841
+ e(f, b);
842
+ } catch (e) {
843
+ _(e);
844
+ }
845
+ for (let e of d) try {
846
+ e(f, b);
847
+ } catch (e) {
848
+ _(e);
849
+ }
850
+ }
851
+ let b = t.listen(async (e, n, r) => {
852
+ let i = await y(e, !1, r.type === "pop");
853
+ i && R(i, M.aborted) && r.delta && t.go(-r.delta);
854
+ });
855
+ return y(t.location || "/", !0, !0).then((e) => {
856
+ e && e.type === M.aborted ? (h && h(e), _(e)) : m && m();
857
+ }).catch((e) => {
858
+ h && h(e), _(e);
859
+ }), {
860
+ get currentRoute() {
861
+ return f;
862
+ },
863
+ get options() {
864
+ return e;
865
+ },
866
+ push(e) {
867
+ return y(e, !1);
868
+ },
869
+ replace(e) {
870
+ return y(e, !0);
871
+ },
872
+ go(e) {
873
+ t.go(e);
874
+ },
875
+ back() {
876
+ t.go(-1);
877
+ },
878
+ forward() {
879
+ t.go(1);
880
+ },
881
+ beforeEach(e) {
882
+ return s.push(e), () => {
883
+ let t = s.indexOf(e);
884
+ t !== -1 && s.splice(t, 1);
885
+ };
886
+ },
887
+ beforeResolve(e) {
888
+ return c.push(e), () => {
889
+ let t = c.indexOf(e);
890
+ t !== -1 && c.splice(t, 1);
891
+ };
892
+ },
893
+ afterEach(e) {
894
+ return l.push(e), () => {
895
+ let t = l.indexOf(e);
896
+ t !== -1 && l.splice(t, 1);
897
+ };
898
+ },
899
+ onError(e) {
900
+ return u.push(e), () => {
901
+ let t = u.indexOf(e);
902
+ t !== -1 && u.splice(t, 1);
903
+ };
904
+ },
905
+ isReady() {
906
+ return p;
907
+ },
908
+ resolve(e, t) {
909
+ return o.resolve(e, t || f);
910
+ },
911
+ addRoute(e, t) {
912
+ return o.addRoute(e, t);
913
+ },
914
+ removeRoute(e) {
915
+ o.removeRoute(e);
916
+ },
917
+ hasRoute(e) {
918
+ return o.hasRoute(e);
919
+ },
920
+ getRoutes() {
921
+ return o.getRoutes();
922
+ },
923
+ subscribe(e) {
924
+ return d.push(e), () => {
925
+ let t = d.indexOf(e);
926
+ t !== -1 && d.splice(t, 1);
927
+ };
928
+ },
929
+ destroy() {
930
+ b(), s.length = 0, c.length = 0, l.length = 0, u.length = 0, d.length = 0, t.destroy();
931
+ }
932
+ };
933
+ }
934
+ //#endregion
935
+ //#region src/components/RouterView.drift
936
+ var H = {
937
+ bytecode: new Uint32Array([
938
+ 6,
939
+ 0,
940
+ 12,
941
+ 0,
942
+ 1,
943
+ 1,
944
+ 1,
945
+ 5,
946
+ 1,
947
+ 2,
948
+ 3,
949
+ 0,
950
+ 13,
951
+ 1,
952
+ 6,
953
+ 4,
954
+ 255,
955
+ 5,
956
+ 4,
957
+ 0,
958
+ 1,
959
+ 0,
960
+ 0
961
+ ]),
962
+ constants: [
963
+ { __drift_fn__: (e, t, n, r, i, a) => {
964
+ if ((e || {}).router = (typeof a == "function" ? a(e, "RouterContext") : typeof r == "function" && r(e, "RouterContext") ? e.RouterContext : typeof globalThis < "u" && globalThis && "RouterContext" in globalThis ? globalThis.RouterContext : (e || {}).RouterContext).inject(), (e || {}).depth = (typeof a == "function" ? a(e, "RouterDepthContext") : typeof r == "function" && r(e, "RouterDepthContext") ? e.RouterDepthContext : typeof globalThis < "u" && globalThis && "RouterDepthContext" in globalThis ? globalThis.RouterDepthContext : (e || {}).RouterDepthContext).inject(0), (e || {}).CurrentComponent = null, (typeof a == "function" ? a(e, "RouterDepthContext") : typeof r == "function" && r(e, "RouterDepthContext") ? e.RouterDepthContext : typeof globalThis < "u" && globalThis && "RouterDepthContext" in globalThis ? globalThis.RouterDepthContext : (e || {}).RouterDepthContext).provide((typeof a == "function" ? a(e, "depth") : typeof r == "function" && r(e, "depth") ? e.depth : typeof globalThis < "u" && globalThis && "depth" in globalThis ? globalThis.depth : (e || {}).depth) + 1), (e || {}).updateCurrentComponent = function() {
965
+ if (!(typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router) || !(typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute || !(typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.matched || !(typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.matched[typeof a == "function" ? a(e, "depth") : typeof r == "function" && r(e, "depth") ? e.depth : typeof globalThis < "u" && globalThis && "depth" in globalThis ? globalThis.depth : (e || {}).depth]) {
966
+ (typeof a == "function" ? a(e, "CurrentComponent") : typeof r == "function" && r(e, "CurrentComponent") ? e.CurrentComponent : typeof globalThis < "u" && globalThis && "CurrentComponent" in globalThis ? globalThis.CurrentComponent : (e || {}).CurrentComponent) !== null && (typeof n == "function" ? n(e, "CurrentComponent", null) : (e || {}).CurrentComponent = null);
967
+ return;
968
+ }
969
+ (typeof a == "function" ? a(e, "CurrentComponent") : typeof r == "function" && r(e, "CurrentComponent") ? e.CurrentComponent : typeof globalThis < "u" && globalThis && "CurrentComponent" in globalThis ? globalThis.CurrentComponent : (e || {}).CurrentComponent) !== ((typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.matched[typeof a == "function" ? a(e, "depth") : typeof r == "function" && r(e, "depth") ? e.depth : typeof globalThis < "u" && globalThis && "depth" in globalThis ? globalThis.depth : (e || {}).depth].components?.default || (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.matched[typeof a == "function" ? a(e, "depth") : typeof r == "function" && r(e, "depth") ? e.depth : typeof globalThis < "u" && globalThis && "depth" in globalThis ? globalThis.depth : (e || {}).depth].component || null) && (typeof n == "function" ? n(e, "CurrentComponent", (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.matched[typeof a == "function" ? a(e, "depth") : typeof r == "function" && r(e, "depth") ? e.depth : typeof globalThis < "u" && globalThis && "depth" in globalThis ? globalThis.depth : (e || {}).depth].components?.default || (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.matched[typeof a == "function" ? a(e, "depth") : typeof r == "function" && r(e, "depth") ? e.depth : typeof globalThis < "u" && globalThis && "depth" in globalThis ? globalThis.depth : (e || {}).depth].component || null) : (e || {}).CurrentComponent = (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.matched[typeof a == "function" ? a(e, "depth") : typeof r == "function" && r(e, "depth") ? e.depth : typeof globalThis < "u" && globalThis && "depth" in globalThis ? globalThis.depth : (e || {}).depth].components?.default || (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.matched[typeof a == "function" ? a(e, "depth") : typeof r == "function" && r(e, "depth") ? e.depth : typeof globalThis < "u" && globalThis && "depth" in globalThis ? globalThis.depth : (e || {}).depth].component || null);
970
+ }, (typeof a == "function" ? a(e, "updateCurrentComponent") : typeof r == "function" && r(e, "updateCurrentComponent") ? e.updateCurrentComponent : typeof globalThis < "u" && globalThis && "updateCurrentComponent" in globalThis ? globalThis.updateCurrentComponent : (e || {}).updateCurrentComponent)(), (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router) && typeof (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).subscribe == "function") {
971
+ let t = (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).subscribe((() => {
972
+ (typeof a == "function" ? a(e, "updateCurrentComponent") : typeof r == "function" && r(e, "updateCurrentComponent") ? e.updateCurrentComponent : typeof globalThis < "u" && globalThis && "updateCurrentComponent" in globalThis ? globalThis.updateCurrentComponent : (e || {}).updateCurrentComponent)();
973
+ }));
974
+ typeof (typeof a == "function" ? a(e, "onUnmount") : typeof r == "function" && r(e, "onUnmount") ? e.onUnmount : typeof globalThis < "u" && globalThis && "onUnmount" in globalThis ? globalThis.onUnmount : (e || {}).onUnmount) == "function" && (typeof a == "function" ? a(e, "onUnmount") : typeof r == "function" && r(e, "onUnmount") ? e.onUnmount : typeof globalThis < "u" && globalThis && "onUnmount" in globalThis ? globalThis.onUnmount : (e || {}).onUnmount)((() => {
975
+ t();
976
+ }));
977
+ }
978
+ } },
979
+ "div",
980
+ "class",
981
+ "drift-router-view",
982
+ {
983
+ bytecode: [
984
+ 6,
985
+ 0,
986
+ 15,
987
+ 1,
988
+ 0,
989
+ 255,
990
+ 4,
991
+ 0,
992
+ 1,
993
+ 0,
994
+ 0
995
+ ],
996
+ constants: ["CurrentComponent"],
997
+ reactiveBindings: []
998
+ },
999
+ ["CurrentComponent"],
1000
+ { __drift_fn__: (e, t, n, r, i, a) => typeof a == "function" ? a(e, "CurrentComponent") : typeof r == "function" && r(e, "CurrentComponent") ? e.CurrentComponent : typeof globalThis < "u" && globalThis && "CurrentComponent" in globalThis ? globalThis.CurrentComponent : (e || {}).CurrentComponent }
1001
+ ],
1002
+ reactiveBindings: [],
1003
+ declaredVars: [
1004
+ "RouterContext",
1005
+ "RouterDepthContext",
1006
+ "onUnmount",
1007
+ "router",
1008
+ "depth",
1009
+ "CurrentComponent",
1010
+ "updateCurrentComponent"
1011
+ ],
1012
+ derived: [],
1013
+ scope: {
1014
+ RouterContext: N,
1015
+ RouterDepthContext: F,
1016
+ onUnmount: t
1017
+ }
1018
+ }, U = {
1019
+ bytecode: new Uint32Array([
1020
+ 6,
1021
+ 0,
1022
+ 12,
1023
+ 0,
1024
+ 1,
1025
+ 1,
1026
+ 1,
1027
+ 5,
1028
+ 1,
1029
+ 2,
1030
+ 3,
1031
+ 1,
1032
+ 5,
1033
+ 1,
1034
+ 4,
1035
+ 5,
1036
+ 1,
1037
+ 5,
1038
+ 1,
1039
+ 6,
1040
+ 7,
1041
+ 1,
1042
+ 5,
1043
+ 1,
1044
+ 8,
1045
+ 9,
1046
+ 1,
1047
+ 5,
1048
+ 1,
1049
+ 10,
1050
+ 11,
1051
+ 1,
1052
+ 7,
1053
+ 2,
1054
+ 12,
1055
+ 4,
1056
+ 1,
1057
+ 2,
1058
+ 4,
1059
+ 0,
1060
+ 1,
1061
+ 0,
1062
+ 0
1063
+ ]),
1064
+ constants: [
1065
+ { __drift_fn__: (e, t, n, r, i, a) => {
1066
+ if ((e || {}).router = (typeof a == "function" ? a(e, "RouterContext") : typeof r == "function" && r(e, "RouterContext") ? e.RouterContext : typeof globalThis < "u" && globalThis && "RouterContext" in globalThis ? globalThis.RouterContext : (e || {}).RouterContext).inject(), (e || {}).to = (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).to || "/", (e || {}).replace = (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).replace || !1, (e || {}).target = (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).target || "_self", (e || {}).rel = (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).rel || "", (e || {}).customClass = (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).class || "", (e || {}).label = (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).label || (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).title || "", (e || {}).currentPath = (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router) && (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute ? (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.path : "", (e || {}).getHref = function(e, t) {
1067
+ let n = e || "/";
1068
+ return t ? t.resolve(n).href : typeof n == "string" ? n : n && n.path ? n.path : "#";
1069
+ }, (e || {}).getActiveClass = function(e, t, n, r, i, a) {
1070
+ let o = n || "";
1071
+ if (!t) return o;
1072
+ let s = e || "/", c = t.resolve(s).path, l = t.currentRoute.path, u = r || t.options && t.options.linkActiveClass || "router-link-active", d = i || t.options && t.options.linkExactActiveClass || "router-link-exact-active";
1073
+ return l === c ? (o ? o + " " : "") + u + " " + d : c !== "/" && l.startsWith(c.endsWith("/") ? c : c + "/") ? (o ? o + " " : "") + u : o;
1074
+ }, (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router) && typeof (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).subscribe == "function") {
1075
+ let t = (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).subscribe((() => {
1076
+ typeof n == "function" ? n(e, "currentPath", (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.path) : (e || {}).currentPath = (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).currentRoute.path, typeof (typeof a == "function" ? a(e, "__drift_mark_dirty__") : typeof r == "function" && r(e, "__drift_mark_dirty__") ? e.__drift_mark_dirty__ : typeof globalThis < "u" && globalThis && "__drift_mark_dirty__" in globalThis ? globalThis.__drift_mark_dirty__ : (e || {}).__drift_mark_dirty__) == "function" && (typeof a == "function" ? a(e, "__drift_mark_dirty__") : typeof r == "function" && r(e, "__drift_mark_dirty__") ? e.__drift_mark_dirty__ : typeof globalThis < "u" && globalThis && "__drift_mark_dirty__" in globalThis ? globalThis.__drift_mark_dirty__ : (e || {}).__drift_mark_dirty__)("currentPath");
1077
+ }));
1078
+ typeof (typeof a == "function" ? a(e, "onUnmount") : typeof r == "function" && r(e, "onUnmount") ? e.onUnmount : typeof globalThis < "u" && globalThis && "onUnmount" in globalThis ? globalThis.onUnmount : (e || {}).onUnmount) == "function" && (typeof a == "function" ? a(e, "onUnmount") : typeof r == "function" && r(e, "onUnmount") ? e.onUnmount : typeof globalThis < "u" && globalThis && "onUnmount" in globalThis ? globalThis.onUnmount : (e || {}).onUnmount)((() => {
1079
+ t();
1080
+ }));
1081
+ }
1082
+ (e || {}).handleClick = function(t) {
1083
+ if (t.defaultPrevented || t.button !== 0) return;
1084
+ let i = (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).target || (typeof a == "function" ? a(e, "target") : typeof r == "function" && r(e, "target") ? e.target : typeof globalThis < "u" && globalThis && "target" in globalThis ? globalThis.target : (e || {}).target);
1085
+ if (i && i !== "_self" || t.metaKey || t.altKey || t.ctrlKey || t.shiftKey || (t.preventDefault(), !(typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router))) return;
1086
+ let o = (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).to || (typeof a == "function" ? a(e, "to") : typeof r == "function" && r(e, "to") ? e.to : typeof globalThis < "u" && globalThis && "to" in globalThis ? globalThis.to : (e || {}).to) || "/";
1087
+ (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).replace || (typeof a == "function" ? a(e, "replace") : typeof r == "function" && r(e, "replace") ? e.replace : typeof globalThis < "u" && globalThis && "replace" in globalThis ? globalThis.replace : (e || {}).replace) ? (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).replace(o) : (() => {
1088
+ let t = (typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router).push(o);
1089
+ return typeof n == "function" && e && typeof r == "function" && r(e, "router") && n(e, "router", e.router), t;
1090
+ })();
1091
+ };
1092
+ } },
1093
+ "a",
1094
+ "href",
1095
+ { __drift_fn__: (e, t, n, r, i, a) => (typeof a == "function" ? a(e, "getHref") : typeof r == "function" && r(e, "getHref") ? e.getHref : typeof globalThis < "u" && globalThis && "getHref" in globalThis ? globalThis.getHref : (e || {}).getHref)((typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).to || (typeof a == "function" ? a(e, "to") : typeof r == "function" && r(e, "to") ? e.to : typeof globalThis < "u" && globalThis && "to" in globalThis ? globalThis.to : (e || {}).to), typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router) },
1096
+ "class",
1097
+ { __drift_fn__: (e, t, n, r, i, a) => (typeof a == "function" ? a(e, "getActiveClass") : typeof r == "function" && r(e, "getActiveClass") ? e.getActiveClass : typeof globalThis < "u" && globalThis && "getActiveClass" in globalThis ? globalThis.getActiveClass : (e || {}).getActiveClass)((typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).to || (typeof a == "function" ? a(e, "to") : typeof r == "function" && r(e, "to") ? e.to : typeof globalThis < "u" && globalThis && "to" in globalThis ? globalThis.to : (e || {}).to), typeof a == "function" ? a(e, "router") : typeof r == "function" && r(e, "router") ? e.router : typeof globalThis < "u" && globalThis && "router" in globalThis ? globalThis.router : (e || {}).router, (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).class || (typeof a == "function" ? a(e, "customClass") : typeof r == "function" && r(e, "customClass") ? e.customClass : typeof globalThis < "u" && globalThis && "customClass" in globalThis ? globalThis.customClass : (e || {}).customClass), (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).activeClass, (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).exactActiveClass, typeof a == "function" ? a(e, "currentPath") : typeof r == "function" && r(e, "currentPath") ? e.currentPath : typeof globalThis < "u" && globalThis && "currentPath" in globalThis ? globalThis.currentPath : (e || {}).currentPath) },
1098
+ "target",
1099
+ { __drift_fn__: (e, t, n, r, i, a) => (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).target || (typeof a == "function" ? a(e, "target") : typeof r == "function" && r(e, "target") ? e.target : typeof globalThis < "u" && globalThis && "target" in globalThis ? globalThis.target : (e || {}).target) },
1100
+ "rel",
1101
+ { __drift_fn__: (e, t, n, r, i, a) => (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).rel || (typeof a == "function" ? a(e, "rel") : typeof r == "function" && r(e, "rel") ? e.rel : typeof globalThis < "u" && globalThis && "rel" in globalThis ? globalThis.rel : (e || {}).rel) },
1102
+ "onclick",
1103
+ { __drift_fn__: (e, t, n, r, i, a) => typeof a == "function" ? a(e, "handleClick") : typeof r == "function" && r(e, "handleClick") ? e.handleClick : typeof globalThis < "u" && globalThis && "handleClick" in globalThis ? globalThis.handleClick : (e || {}).handleClick },
1104
+ { __drift_fn__: (e, t, n, r, i, a) => (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).label || (typeof a == "function" ? a(e, "props") : typeof r == "function" && r(e, "props") ? e.props : typeof globalThis < "u" && globalThis && "props" in globalThis ? globalThis.props : (e || {}).props).title || (typeof a == "function" ? a(e, "label") : typeof r == "function" && r(e, "label") ? e.label : typeof globalThis < "u" && globalThis && "label" in globalThis ? globalThis.label : (e || {}).label) }
1105
+ ],
1106
+ reactiveBindings: [
1107
+ {
1108
+ variable: "getHref",
1109
+ positions: [{
1110
+ pc: 7,
1111
+ opcode: 5
1112
+ }]
1113
+ },
1114
+ {
1115
+ variable: "to",
1116
+ positions: [{
1117
+ pc: 7,
1118
+ opcode: 5
1119
+ }, {
1120
+ pc: 12,
1121
+ opcode: 5
1122
+ }]
1123
+ },
1124
+ {
1125
+ variable: "router",
1126
+ positions: [{
1127
+ pc: 7,
1128
+ opcode: 5
1129
+ }, {
1130
+ pc: 12,
1131
+ opcode: 5
1132
+ }]
1133
+ },
1134
+ {
1135
+ variable: "getActiveClass",
1136
+ positions: [{
1137
+ pc: 12,
1138
+ opcode: 5
1139
+ }]
1140
+ },
1141
+ {
1142
+ variable: "customClass",
1143
+ positions: [{
1144
+ pc: 12,
1145
+ opcode: 5
1146
+ }]
1147
+ },
1148
+ {
1149
+ variable: "currentPath",
1150
+ positions: [{
1151
+ pc: 12,
1152
+ opcode: 5
1153
+ }]
1154
+ },
1155
+ {
1156
+ variable: "target",
1157
+ positions: [{
1158
+ pc: 17,
1159
+ opcode: 5
1160
+ }]
1161
+ },
1162
+ {
1163
+ variable: "rel",
1164
+ positions: [{
1165
+ pc: 22,
1166
+ opcode: 5
1167
+ }]
1168
+ },
1169
+ {
1170
+ variable: "handleClick",
1171
+ positions: [{
1172
+ pc: 27,
1173
+ opcode: 5
1174
+ }]
1175
+ },
1176
+ {
1177
+ variable: "label",
1178
+ positions: [{
1179
+ pc: 32,
1180
+ opcode: 7
1181
+ }]
1182
+ }
1183
+ ],
1184
+ declaredVars: [
1185
+ "RouterContext",
1186
+ "onUnmount",
1187
+ "router",
1188
+ "to",
1189
+ "replace",
1190
+ "target",
1191
+ "rel",
1192
+ "customClass",
1193
+ "label",
1194
+ "currentPath",
1195
+ "getHref",
1196
+ "getActiveClass",
1197
+ "handleClick"
1198
+ ],
1199
+ derived: [],
1200
+ scope: {
1201
+ RouterContext: N,
1202
+ onUnmount: t
1203
+ }
1204
+ };
1205
+ //#endregion
1206
+ export { U as Link, P as RouteContext, N as RouterContext, F as RouterDepthContext, H as RouterView, I as START_LOCATION_NORMALIZED, l as buildHistoryState, k as compilePathToRegex, s as createHistoryListeners, a as createHref, j as createMatcher, f as createMemoryHistory, L as createNavigationFailure, V as createRouter, d as createWebHashHistory, u as createWebHistory, c as extractHistoryState, o as formatHashHref, R as isNavigationFailure, r as normalizeBase, n as normalizePath, A as normalizeRouteRecord, T as parseQuery, E as stringifyQuery, i as stripBase };