vue3-router-tab 1.3.4 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import './vue3-router-tab.css';
2
- import { reactive as pe, ref as S, shallowRef as bt, computed as k, watch as P, nextTick as j, inject as Ke, getCurrentInstance as je, onMounted as ge, defineComponent as Oe, provide as pt, onBeforeUnmount as gt, resolveComponent as mt, createElementBlock as $, openBlock as K, createElementVNode as L, withDirectives as vt, normalizeClass as H, renderSlot as le, createVNode as Pe, TransitionGroup as yt, mergeProps as se, withCtx as ue, Fragment as Ae, renderList as Ee, withModifiers as ce, createCommentVNode as q, toDisplayString as Ie, createBlock as J, normalizeProps as ht, Transition as Tt, resolveDynamicComponent as fe, KeepAlive as kt, normalizeStyle as wt, vShow as Ct, isRef as Rt, isReadonly as Kt } from "vue";
3
- import { RouterView as Pt } from "vue-router";
4
- function At(e = {}) {
2
+ import { reactive as ye, ref as D, shallowRef as mt, computed as R, watch as K, nextTick as B, inject as $e, getCurrentInstance as Ne, onMounted as Te, defineComponent as ze, provide as ht, onErrorCaptured as yt, onBeforeUnmount as Tt, resolveComponent as wt, createElementBlock as M, openBlock as P, createElementVNode as j, withDirectives as kt, normalizeClass as J, renderSlot as fe, createVNode as xe, TransitionGroup as Rt, mergeProps as de, withCtx as be, Fragment as De, renderList as Be, withModifiers as pe, createCommentVNode as Z, toDisplayString as Se, createBlock as G, normalizeProps as Ct, Transition as Et, resolveDynamicComponent as ge, KeepAlive as At, normalizeStyle as Pt, vShow as Kt, isRef as It, isReadonly as $t } from "vue";
3
+ import { RouterView as xt } from "vue-router";
4
+ function Dt(e = {}) {
5
5
  return {
6
6
  initialTabs: e.initialTabs ?? [],
7
7
  keepAlive: e.keepAlive ?? !0,
@@ -11,80 +11,80 @@ function At(e = {}) {
11
11
  defaultRoute: e.defaultRoute ?? "/"
12
12
  };
13
13
  }
14
- function V(e, n) {
15
- const o = e.resolve(n);
16
- if (!o || !o.matched.length)
17
- throw new Error(`[RouterTabs] Unable to resolve route: ${String(n)}`);
18
- return o;
14
+ function N(e, r) {
15
+ const n = e.resolve(r);
16
+ if (!n || !n.matched.length)
17
+ throw new Error(`[RouterTabs] Unable to resolve route: ${String(r)}`);
18
+ return n;
19
19
  }
20
- const Et = {
20
+ const Bt = {
21
21
  path: (e) => e.path,
22
22
  fullpath: (e) => e.fullPath,
23
23
  fullname: (e) => e.fullPath,
24
24
  full: (e) => e.fullPath,
25
25
  name: (e) => e.name ? String(e.name) : e.fullPath
26
26
  };
27
- function N(e) {
28
- const n = e.meta?.key;
29
- if (typeof n == "function") {
30
- const o = n(e);
31
- if (typeof o == "string" && o.length) return o;
32
- } else if (typeof n == "string" && n.length) {
33
- const o = Et[n.toLowerCase()];
34
- return o ? o(e) : n;
27
+ function z(e) {
28
+ const r = e.meta?.key;
29
+ if (typeof r == "function") {
30
+ const n = r(e);
31
+ if (typeof n == "string" && n.length) return n;
32
+ } else if (typeof r == "string" && r.length) {
33
+ const n = Bt[r.toLowerCase()];
34
+ return n ? n(e) : r;
35
35
  }
36
36
  return e.fullPath;
37
37
  }
38
- function me(e, n) {
39
- const o = e.meta?.keepAlive;
40
- return typeof o == "boolean" ? o : n;
38
+ function we(e, r) {
39
+ const n = e.meta?.keepAlive;
40
+ return typeof n == "boolean" ? n : r;
41
41
  }
42
- function ve(e, n) {
43
- const o = e.meta?.reuse;
44
- return typeof o == "boolean" ? o : n;
42
+ function ke(e, r) {
43
+ const n = e.meta?.reuse;
44
+ return typeof n == "boolean" ? n : r;
45
45
  }
46
- function Ue(e) {
47
- const n = e.meta ?? {}, o = {};
48
- return "title" in n && (o.title = n.title), "tips" in n && (o.tips = n.tips), "icon" in n && (o.icon = n.icon), "closable" in n && (o.closable = n.closable), "tabClass" in n && (o.tabClass = n.tabClass), "target" in n && (o.target = n.target), "href" in n && (o.href = n.href), o;
46
+ function Ye(e) {
47
+ const r = e.meta ?? {}, n = {};
48
+ return "title" in r && (n.title = r.title), "tips" in r && (n.tips = r.tips), "icon" in r && (n.icon = r.icon), "closable" in r && (n.closable = r.closable), "tabClass" in r && (n.tabClass = r.tabClass), "target" in r && (n.target = r.target), "href" in r && (n.href = r.href), n;
49
49
  }
50
- function Q(e, n, o) {
51
- const l = Ue(e);
50
+ function ee(e, r, n) {
51
+ const i = Ye(e);
52
52
  return {
53
- id: N(e),
53
+ id: z(e),
54
54
  to: e.fullPath,
55
55
  fullPath: e.fullPath,
56
56
  matched: e,
57
- alive: me(e, o),
58
- reusable: ve(e, !1),
59
- closable: l.closable ?? !0,
60
- renderKey: typeof n.renderKey == "number" ? n.renderKey : 0,
61
- ...l,
62
- ...n
57
+ alive: we(e, n),
58
+ reusable: ke(e, !1),
59
+ closable: i.closable ?? !0,
60
+ renderKey: typeof r.renderKey == "number" ? r.renderKey : 0,
61
+ ...i,
62
+ ...r
63
63
  };
64
64
  }
65
- function de(e, n, o, l) {
66
- if (!e.find((p) => p.id === n.id)) {
67
- if (o === "next" && l) {
68
- const p = e.findIndex((T) => T.id === l);
69
- if (p !== -1) {
70
- e.splice(p + 1, 0, n);
65
+ function ve(e, r, n, i) {
66
+ if (!e.find((g) => g.id === r.id)) {
67
+ if (n === "next" && i) {
68
+ const g = e.findIndex((y) => y.id === i);
69
+ if (g !== -1) {
70
+ e.splice(g + 1, 0, r);
71
71
  return;
72
72
  }
73
73
  }
74
- e.push(n);
74
+ e.push(r);
75
75
  }
76
76
  }
77
- function xe(e, n, o) {
78
- if (!n || n <= 0) return;
79
- const l = e.filter((r) => r.alive);
80
- for (; l.length > n; ) {
81
- const r = l.shift();
82
- if (!r || r.id === o) continue;
83
- const p = e.findIndex((T) => T.id === r.id);
84
- p > -1 && (e[p].alive = !1);
77
+ function me(e, r, n) {
78
+ if (!r || r <= 0) return;
79
+ const i = e.filter((a) => a.alive);
80
+ for (; i.length > r; ) {
81
+ const a = i.shift();
82
+ if (!a || a.id === n) continue;
83
+ const g = e.findIndex((y) => y.id === a.id);
84
+ g > -1 && (e[g].alive = !1);
85
85
  }
86
86
  }
87
- function It(e) {
87
+ function St(e) {
88
88
  return {
89
89
  to: e.to,
90
90
  title: e.title,
@@ -95,177 +95,200 @@ function It(e) {
95
95
  renderKey: e.renderKey
96
96
  };
97
97
  }
98
- function xt(e) {
99
- const n = {};
100
- return "title" in e && (n.title = e.title), "tips" in e && (n.tips = e.tips), "icon" in e && (n.icon = e.icon), "tabClass" in e && (n.tabClass = e.tabClass), "closable" in e && (n.closable = e.closable), "renderKey" in e && typeof e.renderKey == "number" && (n.renderKey = e.renderKey), n;
98
+ function Mt(e) {
99
+ const r = {};
100
+ return "title" in e && (r.title = e.title), "tips" in e && (r.tips = e.tips), "icon" in e && (r.icon = e.icon), "tabClass" in e && (r.tabClass = e.tabClass), "closable" in e && (r.closable = e.closable), "renderKey" in e && typeof e.renderKey == "number" && (r.renderKey = e.renderKey), r;
101
101
  }
102
- function Dt(e, n = {}) {
103
- const o = At(n), l = pe([]), r = S(null), p = bt(), T = S(null), s = k(
104
- () => l.filter((i) => i.alive).map((i) => `${i.id}::${i.renderKey ?? 0}`)
102
+ function Lt(e, r = {}) {
103
+ const n = Dt(r), i = ye([]), a = D(null), g = mt(), y = D(null), s = R(
104
+ () => i.filter((l) => l.alive).map((l) => `${l.id}::${l.renderKey ?? 0}`)
105
105
  );
106
- let c = !1;
107
- function g(i) {
108
- const b = typeof i.matched == "object" ? i : V(e, i);
106
+ let f = !1;
107
+ function m(l) {
108
+ const d = typeof l.matched == "object" ? l : N(e, l);
109
109
  return {
110
- key: N(b),
111
- fullPath: b.fullPath,
112
- alive: me(b, o.keepAlive),
113
- reusable: ve(b, !1),
114
- matched: b
110
+ key: z(d),
111
+ fullPath: d.fullPath,
112
+ alive: we(d, n.keepAlive),
113
+ reusable: ke(d, !1),
114
+ matched: d
115
115
  };
116
116
  }
117
- function R(i) {
118
- const b = N(i);
119
- let d = l.find((h) => h.id === b);
120
- return d ? (d.fullPath = i.fullPath, d.to = i.fullPath, d.matched = i, d.alive = me(i, o.keepAlive), d.reusable = ve(i, d.reusable), typeof d.renderKey != "number" && (d.renderKey = 0), Object.assign(d, Ue(i)), d) : (d = Q(i, {}, o.keepAlive), de(l, d, o.appendPosition, r.value), xe(l, o.maxAlive, r.value), d);
117
+ function E(l) {
118
+ const d = z(l);
119
+ let b = i.find((h) => h.id === d);
120
+ return b ? (b.fullPath = l.fullPath, b.to = l.fullPath, b.matched = l, b.alive = we(l, n.keepAlive), b.reusable = ke(l, b.reusable), typeof b.renderKey != "number" && (b.renderKey = 0), Object.assign(b, Ye(l)), b) : (b = ee(l, {}, n.keepAlive), ve(i, b, n.appendPosition, a.value), me(i, n.maxAlive, a.value), b);
121
121
  }
122
- async function x(i, b = !1, d = !0) {
123
- const h = V(e, i), w = N(h), A = r.value === w;
124
- d === "sameTab" && (d = A), d && await O(w, !0), await e[b ? "replace" : "push"](h), A && await y();
122
+ async function I(l, d = !1, b = !0) {
123
+ const h = N(e, l), k = z(h), x = a.value === k;
124
+ b === "sameTab" && (b = x), b && await U(k, !0), await e[d ? "replace" : "push"](h), x && await _();
125
125
  }
126
- function B(i) {
127
- const b = l.findIndex((I) => I.id === i);
128
- if (b === -1) return o.defaultRoute;
129
- const d = l[b + 1], h = l[b - 1], w = l.find((I) => I.id !== i), A = d || h || w;
130
- return A ? A.to : o.defaultRoute;
126
+ function L(l) {
127
+ const d = i.findIndex((C) => C.id === l);
128
+ if (d === -1) return n.defaultRoute;
129
+ const b = i[d + 1], h = i[d - 1], k = i.find((C) => C.id !== l), x = b || h || k;
130
+ return x ? x.to : n.defaultRoute;
131
131
  }
132
- async function z(i = r.value, b = {}) {
133
- if (!i) return;
134
- if (!b.force && o.keepLastTab && l.length === 1)
132
+ async function Y(l = a.value, d = {}) {
133
+ if (!l) return;
134
+ if (!d.force && n.keepLastTab && i.length === 1)
135
135
  throw new Error("[RouterTabs] Unable to close the final tab when keepLastTab is true.");
136
- const h = r.value === i && b.redirect !== null, w = h ? b.redirect ?? B(i) : null;
137
- await Y(i, { force: b.force }), b.redirect !== null && h && w && await e.replace(w);
136
+ const h = a.value === l && d.redirect !== null, k = h ? d.redirect ?? L(l) : null;
137
+ await $(l, { force: d.force }), d.redirect !== null && h && k && await e.replace(k);
138
+ }
139
+ async function $(l, d = {}) {
140
+ const b = i.findIndex((h) => h.id === l);
141
+ b !== -1 && (i.splice(b, 1), y.value === l && (y.value = null), a.value === l && (a.value = null, g.value = void 0));
138
142
  }
139
- async function Y(i, b = {}) {
140
- const d = l.findIndex((h) => h.id === i);
141
- d !== -1 && (l.splice(d, 1), T.value === i && (T.value = null), r.value === i && (r.value = null, p.value = void 0));
143
+ async function U(l = a.value ?? void 0, d = !1) {
144
+ if (!l) return;
145
+ const b = i.find((k) => k.id === l);
146
+ if (!b) return;
147
+ const h = n.keepAlive && b.alive;
148
+ h && (b.alive = !1, await B()), b.renderKey = (b.renderKey ?? 0) + 1, h && (b.alive = !0), y.value = l, await B(), d || await B(), y.value = null;
142
149
  }
143
- async function O(i = r.value ?? void 0, b = !1) {
144
- if (!i) return;
145
- const d = l.find((w) => w.id === i);
146
- if (!d) return;
147
- const h = o.keepAlive && d.alive;
148
- h && (d.alive = !1, await j()), d.renderKey = (d.renderKey ?? 0) + 1, h && (d.alive = !0), T.value = i, await j(), b || await j(), T.value = null;
150
+ async function re(l = !1) {
151
+ for (const d of i)
152
+ await U(d.id, l);
149
153
  }
150
- async function ne(i = !1) {
151
- for (const b of l)
152
- await O(b.id, i);
154
+ function ae(l, d) {
155
+ const b = i.find((h) => h.id === l);
156
+ b && (b.alive = !!d, b.alive && me(i, n.maxAlive, a.value));
153
157
  }
154
- async function oe(i = o.defaultRoute) {
155
- l.splice(0, l.length), r.value = null, p.value = void 0;
156
- for (const b of o.initialTabs) {
157
- const d = V(e, b.to), h = Q(d, b, o.keepAlive);
158
- l.push(h);
158
+ function T(l) {
159
+ const d = i.find((b) => b.id === l);
160
+ d && (d.alive && (d.alive = !1), d.renderKey = (d.renderKey ?? 0) + 1);
161
+ }
162
+ function q() {
163
+ i.forEach((l) => {
164
+ l.alive = !1;
165
+ });
166
+ }
167
+ function O() {
168
+ return s.value.slice();
169
+ }
170
+ async function S(l = n.defaultRoute) {
171
+ i.splice(0, i.length), a.value = null, g.value = void 0;
172
+ for (const d of n.initialTabs) {
173
+ const b = N(e, d.to), h = ee(b, d, n.keepAlive);
174
+ i.push(h);
159
175
  }
160
- await e.replace(i);
176
+ await e.replace(l);
161
177
  }
162
- async function y() {
163
- const i = r.value;
164
- i && await O(i, !0);
178
+ async function _() {
179
+ const l = a.value;
180
+ l && await U(l, !0);
165
181
  }
166
- function G(i) {
167
- return typeof i.matched == "object" ? N(i) : N(V(e, i));
182
+ function F(l) {
183
+ return typeof l.matched == "object" ? z(l) : z(N(e, l));
168
184
  }
169
- function M() {
170
- const i = l.find((b) => b.id === r.value);
185
+ function w() {
186
+ const l = i.find((d) => d.id === a.value);
171
187
  return {
172
- tabs: l.map(It),
173
- active: i ? i.to : null
188
+ tabs: i.map(St),
189
+ active: l ? l.to : null
174
190
  };
175
191
  }
176
- async function D(i) {
177
- c = !0, l.splice(0, l.length), r.value = null, p.value = void 0;
178
- const b = i?.tabs ?? [];
179
- for (const h of b)
192
+ async function ie(l) {
193
+ f = !0, i.splice(0, i.length), a.value = null, g.value = void 0;
194
+ const d = l?.tabs ?? [];
195
+ for (const h of d)
180
196
  try {
181
- const w = V(e, h.to), A = xt(h), I = Q(w, A, o.keepAlive);
182
- de(l, I, "last", null);
183
- } catch {
197
+ const k = N(e, h.to), x = Mt(h), C = ee(k, x, n.keepAlive);
198
+ ve(i, C, "last", null);
199
+ } catch (k) {
200
+ console.warn("[RouterTabs] Failed to restore tab", h, k);
184
201
  }
185
- c = !1;
186
- const d = i?.active ?? b[b.length - 1]?.to ?? o.defaultRoute;
187
- if (d)
202
+ f = !1;
203
+ const b = l?.active ?? d[d.length - 1]?.to ?? n.defaultRoute;
204
+ if (b)
188
205
  try {
189
- await e.replace(d);
190
- } catch {
206
+ await e.replace(b);
207
+ } catch (h) {
208
+ console.warn("[RouterTabs] Failed to navigate to restored route", b, h);
191
209
  }
192
210
  }
193
- return P(
211
+ return K(
194
212
  () => e.currentRoute.value,
195
- (i) => {
196
- if (c) return;
197
- const b = R(i);
198
- r.value = b.id, p.value = b, xe(l, o.maxAlive, r.value);
213
+ (l) => {
214
+ if (f) return;
215
+ const d = E(l);
216
+ a.value = d.id, g.value = d, me(i, n.maxAlive, a.value);
199
217
  },
200
218
  { immediate: !0 }
201
- ), o.initialTabs.length && o.initialTabs.forEach((i) => {
202
- const b = V(e, i.to), d = Q(b, i, o.keepAlive);
203
- de(l, d, "last", null);
219
+ ), n.initialTabs.length && n.initialTabs.forEach((l) => {
220
+ const d = N(e, l.to), b = ee(d, l, n.keepAlive);
221
+ ve(i, b, "last", null);
204
222
  }), {
205
- options: o,
206
- tabs: l,
207
- activeId: r,
208
- current: p,
223
+ options: n,
224
+ tabs: i,
225
+ activeId: a,
226
+ current: g,
209
227
  includeKeys: s,
210
- refreshingKey: T,
211
- openTab: x,
212
- closeTab: z,
213
- removeTab: Y,
214
- refreshTab: O,
215
- refreshAll: ne,
216
- reset: oe,
217
- reload: y,
218
- getRouteKey: G,
219
- matchRoute: g,
220
- snapshot: M,
221
- hydrate: D
228
+ refreshingKey: y,
229
+ openTab: I,
230
+ closeTab: Y,
231
+ removeTab: $,
232
+ refreshTab: U,
233
+ refreshAll: re,
234
+ setTabAlive: ae,
235
+ evictCache: T,
236
+ clearCache: q,
237
+ getCacheKeys: O,
238
+ reset: S,
239
+ reload: _,
240
+ getRouteKey: F,
241
+ matchRoute: m,
242
+ snapshot: w,
243
+ hydrate: ie,
244
+ ensureTab: E
222
245
  };
223
246
  }
224
- function De(e) {
247
+ function Me(e) {
225
248
  return e ? typeof e == "string" ? { name: e } : e : {};
226
249
  }
227
- const te = Symbol("RouterTabsContext"), ee = "router-tabs:snapshot";
228
- function $e(e = {}) {
229
- const { optional: n = !1 } = e, o = Ke(te, null);
230
- if (o) return o;
231
- const l = Ke("$tabs", null);
232
- if (l) return l;
233
- const p = je()?.appContext.config.globalProperties.$tabs;
234
- if (p) return p;
235
- if (!n)
250
+ const oe = Symbol("RouterTabsContext"), ne = "router-tabs:snapshot";
251
+ function Le(e = {}) {
252
+ const { optional: r = !1 } = e, n = $e(oe, null);
253
+ if (n) return n;
254
+ const i = $e("$tabs", null);
255
+ if (i) return i;
256
+ const g = Ne()?.appContext.config.globalProperties.$tabs;
257
+ if (g) return g;
258
+ if (!r)
236
259
  throw new Error("[RouterTabs] useRouterTabs must be used within <router-tab>.");
237
260
  return null;
238
261
  }
239
- const $t = 864e5;
240
- function St(e) {
262
+ const Ot = 864e5;
263
+ function jt(e) {
241
264
  if (typeof document > "u") return null;
242
- const n = `${encodeURIComponent(e)}=`, o = document.cookie ? document.cookie.split("; ") : [];
243
- for (const l of o)
244
- if (l.startsWith(n))
245
- return decodeURIComponent(l.slice(n.length));
265
+ const r = `${encodeURIComponent(e)}=`, n = document.cookie ? document.cookie.split("; ") : [];
266
+ for (const i of n)
267
+ if (i.startsWith(r))
268
+ return decodeURIComponent(i.slice(r.length));
246
269
  return null;
247
270
  }
248
- function Se(e, n, o) {
271
+ function Oe(e, r, n) {
249
272
  if (typeof document > "u") return;
250
273
  const {
251
- expiresInDays: l = 7,
252
- path: r = "/",
253
- domain: p,
254
- secure: T,
274
+ expiresInDays: i = 7,
275
+ path: a = "/",
276
+ domain: g,
277
+ secure: y,
255
278
  sameSite: s = "lax"
256
- } = o, c = [`${encodeURIComponent(e)}=${encodeURIComponent(n)}`];
257
- if (l !== 1 / 0) {
258
- const g = new Date(Date.now() + l * $t).toUTCString();
259
- c.push(`Expires=${g}`);
279
+ } = n, f = [`${encodeURIComponent(e)}=${encodeURIComponent(r)}`];
280
+ if (i !== 1 / 0) {
281
+ const m = new Date(Date.now() + i * Ot).toUTCString();
282
+ f.push(`Expires=${m}`);
260
283
  }
261
- r && c.push(`Path=${r}`), p && c.push(`Domain=${p}`), T && c.push("Secure"), s && c.push(`SameSite=${s.charAt(0).toUpperCase()}${s.slice(1)}`), document.cookie = c.join("; ");
284
+ a && f.push(`Path=${a}`), g && f.push(`Domain=${g}`), y && f.push("Secure"), s && f.push(`SameSite=${s.charAt(0).toUpperCase()}${s.slice(1)}`), document.cookie = f.join("; ");
262
285
  }
263
- function Be(e, n) {
286
+ function je(e, r) {
264
287
  if (typeof document > "u") return;
265
- const { path: o = "/", domain: l } = n, r = [`${encodeURIComponent(e)}=`];
266
- r.push("Expires=Thu, 01 Jan 1970 00:00:01 GMT"), o && r.push(`Path=${o}`), l && r.push(`Domain=${l}`), document.cookie = r.join("; ");
288
+ const { path: n = "/", domain: i } = r, a = [`${encodeURIComponent(e)}=`];
289
+ a.push("Expires=Thu, 01 Jan 1970 00:00:01 GMT"), n && a.push(`Path=${n}`), i && a.push(`Domain=${i}`), document.cookie = a.join("; ");
267
290
  }
268
- const Bt = (e) => JSON.stringify(e ?? null), Mt = (e) => {
291
+ const Ut = (e) => JSON.stringify(e ?? null), Vt = (e) => {
269
292
  if (!e) return null;
270
293
  try {
271
294
  return JSON.parse(e);
@@ -273,65 +296,65 @@ const Bt = (e) => JSON.stringify(e ?? null), Mt = (e) => {
273
296
  return null;
274
297
  }
275
298
  };
276
- function Ve(e = {}) {
299
+ function _e(e = {}) {
277
300
  const {
278
- cookieKey: n = ee,
279
- serialize: o = Bt,
280
- deserialize: l = Mt
281
- } = e, r = $e({ optional: !0 }), p = S(!0), T = (s) => {
282
- ge(async () => {
283
- const c = l(St(n));
284
- if (c && c.tabs?.length)
301
+ cookieKey: r = ne,
302
+ serialize: n = Ut,
303
+ deserialize: i = Vt
304
+ } = e, a = Le({ optional: !0 }), g = D(!0), y = (s) => {
305
+ Te(async () => {
306
+ const f = i(jt(r));
307
+ if (f && f.tabs?.length)
285
308
  try {
286
- if (p.value = !0, await s.hydrate(c), c.active) {
287
- await j();
288
- const R = s.tabs.find((x) => x.to === c.active);
289
- R && (s.activeId.value = R.id, s.current.value = R);
309
+ if (g.value = !0, await s.hydrate(f), f.active) {
310
+ await B();
311
+ const E = s.tabs.find((I) => I.to === f.active);
312
+ E && (s.activeId.value = E.id, s.current.value = E);
290
313
  }
291
314
  } finally {
292
- p.value = !1;
315
+ g.value = !1;
293
316
  }
294
317
  else if (Object.prototype.hasOwnProperty.call(e, "fallbackRoute"))
295
318
  try {
296
- p.value = !0;
297
- const R = e.fallbackRoute ?? s.options.defaultRoute;
298
- await s.reset(R);
319
+ g.value = !0;
320
+ const E = e.fallbackRoute ?? s.options.defaultRoute;
321
+ await s.reset(E);
299
322
  } finally {
300
- p.value = !1;
323
+ g.value = !1;
301
324
  }
302
325
  else
303
- p.value = !1;
304
- const g = s.snapshot();
305
- g.tabs.length ? Se(n, o(g), e) : Be(n, e), p.value = !1;
306
- }), P(
326
+ g.value = !1;
327
+ const m = s.snapshot();
328
+ m.tabs.length ? Oe(r, n(m), e) : je(r, e), g.value = !1;
329
+ }), K(
307
330
  () => ({
308
- tabs: s.tabs.map((c) => ({
309
- to: c.to,
310
- title: c.title,
311
- tips: c.tips,
312
- icon: c.icon,
313
- tabClass: c.tabClass,
314
- closable: c.closable,
315
- renderKey: c.renderKey
331
+ tabs: s.tabs.map((f) => ({
332
+ to: f.to,
333
+ title: f.title,
334
+ tips: f.tips,
335
+ icon: f.icon,
336
+ tabClass: f.tabClass,
337
+ closable: f.closable,
338
+ renderKey: f.renderKey
316
339
  })),
317
340
  active: s.activeId.value
318
341
  }),
319
342
  () => {
320
- if (p.value) return;
321
- const c = s.snapshot();
322
- c.tabs.length ? Se(n, o(c), e) : Be(n, e);
343
+ if (g.value) return;
344
+ const f = s.snapshot();
345
+ f.tabs.length ? Oe(r, n(f), e) : je(r, e);
323
346
  },
324
347
  { deep: !0 }
325
348
  );
326
349
  };
327
- r ? T(r) : ge(() => {
328
- const s = $e({ optional: !0 });
329
- s && T(s);
350
+ a ? y(a) : Te(() => {
351
+ const s = Le({ optional: !0 });
352
+ s && y(s);
330
353
  });
331
354
  }
332
- const Lt = Oe({
355
+ const Nt = ze({
333
356
  name: "RouterTab",
334
- components: { RouterView: Pt },
357
+ components: { RouterView: xt },
335
358
  props: {
336
359
  tabs: {
337
360
  type: Array,
@@ -371,7 +394,7 @@ const Lt = Oe({
371
394
  },
372
395
  cookieKey: {
373
396
  type: String,
374
- default: ee
397
+ default: ne
375
398
  },
376
399
  persistence: {
377
400
  type: Object,
@@ -383,14 +406,14 @@ const Lt = Oe({
383
406
  }
384
407
  },
385
408
  emits: ["tab-sort", "tab-sorted"],
386
- setup(e, { emit: n }) {
387
- const o = je();
388
- if (!o)
409
+ setup(e, { emit: r }) {
410
+ const n = Ne();
411
+ if (!n)
389
412
  throw new Error("[RouterTab] component must be used within a Vue application context.");
390
- const l = o.appContext.app.config.globalProperties.$router;
391
- if (!l)
413
+ const i = n.appContext.app.config.globalProperties.$router;
414
+ if (!i)
392
415
  throw new Error("[RouterTab] Vue Router is required. Make sure to call app.use(router) before RouterTab.");
393
- const r = Dt(l, {
416
+ const a = Lt(i, {
394
417
  initialTabs: e.tabs,
395
418
  keepAlive: e.keepAlive,
396
419
  maxAlive: e.maxAlive,
@@ -398,105 +421,148 @@ const Lt = Oe({
398
421
  appendPosition: e.append,
399
422
  defaultRoute: e.defaultPage
400
423
  });
401
- pt(te, r), o.appContext.config.globalProperties.$tabs = r;
402
- const p = k(() => !!o?.slots?.default), T = k(() => !!o?.slots?.start), s = k(() => !!o?.slots?.end), c = S(0), g = k(() => {
403
- c.value;
424
+ ht(oe, a), n.appContext.config.globalProperties.$tabs = a;
425
+ const g = R(() => !!n?.slots?.default), y = R(() => !!n?.slots?.start), s = R(() => !!n?.slots?.end), f = D(0), m = R(() => {
426
+ f.value;
404
427
  const t = {};
405
- return r.tabs.forEach((a) => {
406
- const f = typeof a.title == "string" ? a.title : String(a.title || ae(a));
407
- t[a.id] = f;
428
+ return a.tabs.forEach((o) => {
429
+ const u = typeof o.title == "string" ? o.title : String(o.title || le(o));
430
+ t[o.id] = u;
408
431
  }), t;
409
432
  });
410
- function R() {
411
- c.value++;
433
+ function E() {
434
+ f.value++;
412
435
  }
413
- const x = /* @__PURE__ */ new Map(), B = /* @__PURE__ */ new Map();
414
- function z(t, a) {
415
- if (!a || x.has(t)) return;
416
- x.set(t, a);
417
- const f = r.tabs.find((v) => r.getRouteKey(v.to) === t);
418
- if (!f) return;
419
- const m = [];
420
- if (a.routeTabTitle !== void 0) {
421
- const v = P(
422
- () => {
423
- const u = a.routeTabTitle;
424
- return u && typeof u == "object" && "value" in u ? u.value : u;
425
- },
426
- (u) => {
427
- if (u != null) {
428
- const U = String(u);
429
- f.title = U, R();
436
+ const I = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map();
437
+ function Y(t, o) {
438
+ if (!(!o || I.has(t)))
439
+ try {
440
+ I.set(t, o);
441
+ const u = a.tabs.find((p) => a.getRouteKey(p.to) === t);
442
+ if (!u) {
443
+ console.warn(`[RouterTab] Cannot setup watching: tab not found for ${t}`);
444
+ return;
445
+ }
446
+ const v = [];
447
+ if (o.routeTabTitle !== void 0)
448
+ try {
449
+ const p = K(
450
+ () => {
451
+ const c = o.routeTabTitle;
452
+ return c && typeof c == "object" && "value" in c ? c.value : c;
453
+ },
454
+ (c) => {
455
+ if (c != null) {
456
+ const V = String(c);
457
+ u.title = V, E();
458
+ }
459
+ },
460
+ { immediate: !0 }
461
+ );
462
+ v.push(p);
463
+ } catch (p) {
464
+ console.error(`[RouterTab] Error watching routeTabTitle for ${t}:`, p);
430
465
  }
431
- },
432
- { immediate: !0 }
433
- );
434
- m.push(v);
435
- }
436
- if (a.routeTabIcon !== void 0) {
437
- const v = P(
438
- () => {
439
- const u = a.routeTabIcon;
440
- return u && typeof u == "object" && "value" in u ? u.value : u;
441
- },
442
- (u) => {
443
- u != null && (f.icon = String(u), R());
444
- },
445
- { immediate: !0 }
446
- );
447
- m.push(v);
448
- }
449
- if (a.routeTabClosable !== void 0) {
450
- const v = P(
451
- () => {
452
- const u = a.routeTabClosable;
453
- return u && typeof u == "object" && "value" in u ? u.value : u;
454
- },
455
- (u) => {
456
- u != null && (f.closable = !!u, R());
457
- },
458
- { immediate: !0 }
459
- );
460
- m.push(v);
461
- }
462
- if (a.routeTabMeta !== void 0) {
463
- const v = P(
464
- () => {
465
- const u = a.routeTabMeta;
466
- return u && typeof u == "object" && "value" in u ? u.value : u;
467
- },
468
- (u) => {
469
- u && typeof u == "object" && (Object.assign(f, u), R());
470
- },
471
- { immediate: !0, deep: !0 }
472
- );
473
- m.push(v);
474
- }
475
- B.set(t, m);
466
+ if (o.routeTabIcon !== void 0)
467
+ try {
468
+ const p = K(
469
+ () => {
470
+ const c = o.routeTabIcon;
471
+ return c && typeof c == "object" && "value" in c ? c.value : c;
472
+ },
473
+ (c) => {
474
+ c != null && (u.icon = String(c), E());
475
+ },
476
+ { immediate: !0 }
477
+ );
478
+ v.push(p);
479
+ } catch (p) {
480
+ console.error(`[RouterTab] Error watching routeTabIcon for ${t}:`, p);
481
+ }
482
+ if (o.routeTabClosable !== void 0)
483
+ try {
484
+ const p = K(
485
+ () => {
486
+ const c = o.routeTabClosable;
487
+ return c && typeof c == "object" && "value" in c ? c.value : c;
488
+ },
489
+ (c) => {
490
+ c != null && (u.closable = !!c, E());
491
+ },
492
+ { immediate: !0 }
493
+ );
494
+ v.push(p);
495
+ } catch (p) {
496
+ console.error(`[RouterTab] Error watching routeTabClosable for ${t}:`, p);
497
+ }
498
+ if (o.routeTabMeta !== void 0)
499
+ try {
500
+ const p = K(
501
+ () => {
502
+ const c = o.routeTabMeta;
503
+ return c && typeof c == "object" && "value" in c ? c.value : c;
504
+ },
505
+ (c) => {
506
+ c && typeof c == "object" && (Object.assign(u, c), E());
507
+ },
508
+ { immediate: !0, deep: !0 }
509
+ );
510
+ v.push(p);
511
+ } catch (p) {
512
+ console.error(`[RouterTab] Error watching routeTabMeta for ${t}:`, p);
513
+ }
514
+ L.set(t, v);
515
+ } catch (u) {
516
+ console.error(`[RouterTab] Error in setupComponentWatching for ${t}:`, u), $(t);
517
+ }
476
518
  }
477
- function Y(t) {
478
- const a = B.get(t);
479
- a && (a.forEach((f) => f()), B.delete(t)), x.delete(t);
519
+ function $(t) {
520
+ try {
521
+ const o = L.get(t);
522
+ o && (o.forEach((u) => {
523
+ try {
524
+ u();
525
+ } catch (v) {
526
+ console.error(`[RouterTab] Error cleaning up watcher for ${t}:`, v);
527
+ }
528
+ }), L.delete(t)), I.delete(t);
529
+ } catch (o) {
530
+ console.error(`[RouterTab] Error in cleanupComponentWatching for ${t}:`, o);
531
+ }
480
532
  }
481
- function O(t, a) {
482
- t ? t.routeTabTitle !== void 0 || t.routeTabIcon !== void 0 || t.routeTabClosable !== void 0 ? z(a, t) : t.$ && (t.$.routeTabTitle !== void 0 || t.$.routeTabIcon !== void 0 || t.$.routeTabClosable !== void 0) && z(a, t.$) : t === null && Y(a);
533
+ function U(t, o) {
534
+ try {
535
+ t ? t.routeTabTitle !== void 0 || t.routeTabIcon !== void 0 || t.routeTabClosable !== void 0 ? Y(o, t) : t.$ && (t.$.routeTabTitle !== void 0 || t.$.routeTabIcon !== void 0 || t.$.routeTabClosable !== void 0) && Y(o, t.$) : t === null && $(o);
536
+ } catch (u) {
537
+ console.error(`[RouterTab] Error handling component ref for ${o}:`, u), $(o);
538
+ }
483
539
  }
484
- if (e.cookieKey !== null || e.persistence) {
540
+ if (yt((t, o, u) => {
541
+ if (console.error("[RouterTab] Error captured from component:", t, u), o && a.activeId.value) {
542
+ const v = a.activeId.value;
543
+ $(v);
544
+ const p = a.tabs.find((c) => c.id === v);
545
+ p && p.alive && (console.warn(`[RouterTab] Removing errored component ${v} from KeepAlive cache`), p.alive = !1, B(() => {
546
+ p.alive = !0;
547
+ }));
548
+ }
549
+ return !1;
550
+ }), e.cookieKey !== null || e.persistence) {
485
551
  const t = {
486
552
  ...e.persistence ?? {}
487
553
  };
488
- e.cookieKey !== null ? t.cookieKey = e.cookieKey || ee : t.cookieKey || (t.cookieKey = ee), Ve(t);
554
+ e.cookieKey !== null ? t.cookieKey = e.cookieKey || ne : t.cookieKey || (t.cookieKey = ne), _e(t);
489
555
  }
490
- const ne = k(() => De(e.tabTransition)), oe = k(() => De(e.pageTransition)), y = pe({
556
+ const re = R(() => Me(e.tabTransition)), ae = R(() => Me(e.pageTransition)), T = ye({
491
557
  visible: !1,
492
558
  target: null,
493
559
  position: { x: 0, y: 0 }
494
- }), G = S(null), M = S([]), D = S(-1), i = pe({
560
+ }), q = D(null), O = D([]), S = D(-1), _ = D(null), F = /* @__PURE__ */ new Map(), w = ye({
495
561
  dragging: !1,
496
562
  dragIndex: -1,
497
563
  dropIndex: -1,
498
564
  dragTab: null
499
- }), b = [
565
+ }), ie = [
500
566
  "refresh",
501
567
  "refreshAll",
502
568
  "close",
@@ -504,135 +570,135 @@ const Lt = Oe({
504
570
  "closeRights",
505
571
  "closeOthers"
506
572
  ];
507
- function d(t) {
508
- return r.tabs.findIndex((a) => a.id === t);
573
+ function l(t) {
574
+ return a.tabs.findIndex((o) => o.id === t);
509
575
  }
510
- function h(t) {
511
- const a = d(t.id);
512
- return a > 0 ? r.tabs.slice(0, a) : [];
576
+ function d(t) {
577
+ const o = l(t.id);
578
+ return o > 0 ? a.tabs.slice(0, o) : [];
513
579
  }
514
- function w(t) {
515
- const a = d(t.id);
516
- return a > -1 ? r.tabs.slice(a + 1) : [];
580
+ function b(t) {
581
+ const o = l(t.id);
582
+ return o > -1 ? a.tabs.slice(o + 1) : [];
517
583
  }
518
- function A(t) {
519
- return r.tabs.filter((a) => a.id !== t.id);
584
+ function h(t) {
585
+ return a.tabs.filter((o) => o.id !== t.id);
520
586
  }
521
- async function I(t, a) {
522
- const f = t.filter((m) => m.closable !== !1);
523
- if (f.length) {
524
- for (const m of f)
525
- r.activeId.value === m.id ? await r.closeTab(m.id, { redirect: a.to, force: !0 }) : await r.removeTab(m.id, { force: !0 });
526
- r.activeId.value !== a.id && await r.openTab(a.to, !0, !1);
587
+ async function k(t, o) {
588
+ const u = t.filter((v) => v.closable !== !1);
589
+ if (u.length) {
590
+ for (const v of u)
591
+ a.activeId.value === v.id ? await a.closeTab(v.id, { redirect: o.to, force: !0 }) : await a.removeTab(v.id, { force: !0 });
592
+ a.activeId.value !== o.id && await a.openTab(o.to, !0, !1);
527
593
  }
528
594
  }
529
- const Fe = {
595
+ const x = {
530
596
  refresh: {
531
597
  label: "Refresh",
532
598
  handler: async ({ target: t }) => {
533
- await r.refreshTab(t.id, !0);
599
+ await a.refreshTab(t.id, !0);
534
600
  }
535
601
  },
536
602
  refreshAll: {
537
603
  label: "Refresh All",
538
604
  handler: async () => {
539
- await r.refreshAll(!0);
605
+ await a.refreshAll(!0);
540
606
  }
541
607
  },
542
608
  close: {
543
609
  label: "Close",
544
610
  handler: async ({ target: t }) => {
545
- await r.closeTab(t.id);
611
+ await a.closeTab(t.id);
546
612
  },
547
- enable: ({ target: t }) => re(t)
613
+ enable: ({ target: t }) => se(t)
548
614
  },
549
615
  closeLefts: {
550
616
  label: "Close to the Left",
551
617
  handler: async ({ target: t }) => {
552
- await I(h(t), t);
618
+ await k(d(t), t);
553
619
  },
554
- enable: ({ target: t }) => h(t).some((a) => a.closable !== !1)
620
+ enable: ({ target: t }) => d(t).some((o) => o.closable !== !1)
555
621
  },
556
622
  closeRights: {
557
623
  label: "Close to the Right",
558
624
  handler: async ({ target: t }) => {
559
- await I(w(t), t);
625
+ await k(b(t), t);
560
626
  },
561
- enable: ({ target: t }) => w(t).some((a) => a.closable !== !1)
627
+ enable: ({ target: t }) => b(t).some((o) => o.closable !== !1)
562
628
  },
563
629
  closeOthers: {
564
630
  label: "Close Others",
565
631
  handler: async ({ target: t }) => {
566
- await I(A(t), t);
632
+ await k(h(t), t);
567
633
  },
568
- enable: ({ target: t }) => A(t).some((a) => a.closable !== !1)
634
+ enable: ({ target: t }) => h(t).some((o) => o.closable !== !1)
569
635
  }
570
636
  };
571
- function E() {
572
- y.visible = !1, y.target = null, D.value = -1, M.value = [];
637
+ function C() {
638
+ T.visible = !1, T.target = null, S.value = -1, O.value = [];
573
639
  }
574
- function He(t, a) {
575
- e.contextmenu && (y.target = t, y.position.x = a.clientX, y.position.y = a.clientY, j(() => {
576
- y.visible = !0, document.addEventListener("click", E, { once: !0 }), j(() => {
577
- We();
640
+ function Ge(t, o) {
641
+ e.contextmenu && (T.target = t, T.position.x = o.clientX, T.position.y = o.clientY, B(() => {
642
+ T.visible = !0, document.addEventListener("click", C, { once: !0 }), B(() => {
643
+ qe();
578
644
  });
579
645
  }));
580
646
  }
581
- function Je(t, a) {
582
- const f = typeof t == "string" ? { id: t } : t, m = Fe[f.id], v = f.label ?? m?.label ?? String(f.id), u = f.visible ?? m?.visible ?? !0;
583
- if (!(typeof u == "function" ? u(a) : u !== !1)) return null;
584
- const ie = f.enable ?? m?.enable ?? !0, ft = typeof ie == "function" ? ie(a) : ie !== !1, Re = f.handler ?? m?.handler;
585
- if (!Re) return null;
586
- const dt = async () => {
587
- await Promise.resolve(Re(a));
647
+ function Xe(t, o) {
648
+ const u = typeof t == "string" ? { id: t } : t, v = x[u.id], p = u.label ?? v?.label ?? String(u.id), c = u.visible ?? v?.visible ?? !0;
649
+ if (!(typeof c == "function" ? c(o) : c !== !1)) return null;
650
+ const ce = u.enable ?? v?.enable ?? !0, gt = typeof ce == "function" ? ce(o) : ce !== !1, Ie = u.handler ?? v?.handler;
651
+ if (!Ie) return null;
652
+ const vt = async () => {
653
+ await Promise.resolve(Ie(o));
588
654
  };
589
655
  return {
590
- id: String(f.id),
591
- label: v,
592
- disabled: !ft,
593
- action: dt
656
+ id: String(u.id),
657
+ label: p,
658
+ disabled: !gt,
659
+ action: vt
594
660
  };
595
661
  }
596
- const _ = k(() => {
597
- if (!y.visible || !y.target || e.contextmenu === !1) return [];
598
- const t = Array.isArray(e.contextmenu) ? e.contextmenu : b, a = { target: y.target, controller: r };
599
- return t.map((f) => Je(f, a)).filter((f) => !!f);
662
+ const H = R(() => {
663
+ if (!T.visible || !T.target || e.contextmenu === !1) return [];
664
+ const t = Array.isArray(e.contextmenu) ? e.contextmenu : ie, o = { target: T.target, controller: a };
665
+ return t.map((u) => Xe(u, o)).filter((u) => !!u);
600
666
  });
601
- function We() {
602
- const t = G.value;
667
+ function qe() {
668
+ const t = q.value;
603
669
  if (!t) return;
604
- const a = 8, { innerWidth: f, innerHeight: m } = window, v = t.getBoundingClientRect();
605
- let u = y.position.x, U = y.position.y;
606
- v.right > f - a && (u = Math.max(a, f - v.width - a)), v.bottom > m - a && (U = Math.max(a, m - v.height - a)), (u !== y.position.x || U !== y.position.y) && (y.position.x = u, y.position.y = U);
670
+ const o = 8, { innerWidth: u, innerHeight: v } = window, p = t.getBoundingClientRect();
671
+ let c = T.position.x, V = T.position.y;
672
+ p.right > u - o && (c = Math.max(o, u - p.width - o)), p.bottom > v - o && (V = Math.max(o, v - p.height - o)), (c !== T.position.x || V !== T.position.y) && (T.position.x = c, T.position.y = V);
607
673
  }
608
- function Ge(t, a) {
609
- M.value[a] = t ?? null;
674
+ function Qe(t, o) {
675
+ O.value[o] = t ?? null;
610
676
  }
611
- function Xe(t) {
677
+ function Ze(t) {
612
678
  if (t < 0) return;
613
- M.value[t]?.focus({ preventScroll: !0 });
679
+ O.value[t]?.focus({ preventScroll: !0 });
614
680
  }
615
- function X(t, a, f = _.value) {
616
- if (!f.length) return -1;
617
- const m = f.length;
618
- let v = t;
619
- for (let u = 0; u < m; u++)
620
- if (v = (v + a + m) % m, !f[v].disabled) return v;
681
+ function Q(t, o, u = H.value) {
682
+ if (!u.length) return -1;
683
+ const v = u.length;
684
+ let p = t;
685
+ for (let c = 0; c < v; c++)
686
+ if (p = (p + o + v) % v, !u[p].disabled) return p;
621
687
  return -1;
622
688
  }
623
- function F(t) {
624
- D.value = t, !(t < 0) && j(() => Xe(t));
689
+ function W(t) {
690
+ S.value = t, !(t < 0) && B(() => Ze(t));
625
691
  }
626
- function Te(t) {
627
- const a = X(D.value, t);
628
- a !== -1 && F(a);
692
+ function Ee(t) {
693
+ const o = Q(S.value, t);
694
+ o !== -1 && W(o);
629
695
  }
630
- function qe(t) {
631
- if (!y.visible) return;
632
- const a = t.key, f = _.value;
633
- if (!f.length) return;
634
- if (a === "Tab") {
635
- E();
696
+ function et(t) {
697
+ if (!T.visible) return;
698
+ const o = t.key, u = H.value;
699
+ if (!u.length) return;
700
+ if (o === "Tab") {
701
+ C();
636
702
  return;
637
703
  }
638
704
  if ([
@@ -646,284 +712,324 @@ const Lt = Oe({
646
712
  " ",
647
713
  "Spacebar",
648
714
  "Escape"
649
- ].includes(a))
650
- switch (t.preventDefault(), a) {
715
+ ].includes(o))
716
+ switch (t.preventDefault(), o) {
651
717
  case "ArrowDown":
652
718
  case "ArrowRight":
653
- Te(1);
719
+ Ee(1);
654
720
  break;
655
721
  case "ArrowUp":
656
722
  case "ArrowLeft":
657
- Te(-1);
723
+ Ee(-1);
658
724
  break;
659
725
  case "Home":
660
- F(X(-1, 1));
726
+ W(Q(-1, 1));
661
727
  break;
662
728
  case "End":
663
- F(X(f.length, -1));
729
+ W(Q(u.length, -1));
664
730
  break;
665
731
  case "Enter":
666
732
  case " ":
667
733
  case "Spacebar": {
668
- const v = D.value;
669
- if (v > -1) {
670
- const u = f[v];
671
- u.disabled || ke(u);
734
+ const p = S.value;
735
+ if (p > -1) {
736
+ const c = u[p];
737
+ c.disabled || Ae(c);
672
738
  }
673
739
  break;
674
740
  }
675
741
  case "Escape":
676
- E();
742
+ C();
677
743
  break;
678
744
  }
679
745
  }
680
- async function ke(t) {
681
- t.disabled || (E(), await t.action());
746
+ async function Ae(t) {
747
+ t.disabled || (C(), await t.action());
682
748
  }
683
- function ae(t) {
749
+ function le(t) {
684
750
  return typeof t.title == "string" && t.title.trim() ? t.title : Array.isArray(t.title) && t.title.length && String(t.title[0]).trim() ? String(t.title[0]) : "Untitled";
685
751
  }
686
- function Qe(t) {
687
- return g.value[t.id] || ae(t);
752
+ function tt(t) {
753
+ return m.value[t.id] || le(t);
688
754
  }
689
- function we(t) {
690
- const a = r.getRouteKey(t), f = r.tabs.find((v) => v.id === a);
691
- if (!f)
692
- return console.warn("[RouterTab] Tab not found for route:", a), `${a}::0`;
693
- const m = f.renderKey ?? 0;
694
- return `${a}::${m}`;
755
+ function Pe(t) {
756
+ const o = a.getRouteKey(t), u = a.tabs.find((p) => p.id === o);
757
+ if (!u)
758
+ return console.warn("[RouterTab] Tab not found for route:", o), `${o}::0`;
759
+ const v = u.renderKey ?? 0;
760
+ return `${o}::${v}`;
695
761
  }
696
- function Ze(t) {
697
- return `${we(t)}::refresh`;
762
+ function nt(t) {
763
+ return `${Pe(t)}::refresh`;
698
764
  }
699
- function re(t) {
700
- return !(t.closable === !1 || r.options.keepLastTab && r.tabs.length <= 1);
765
+ function se(t) {
766
+ return !(t.closable === !1 || a.options.keepLastTab && a.tabs.length <= 1);
701
767
  }
702
- async function et(t) {
703
- await r.closeTab(t.id);
768
+ async function ot(t) {
769
+ await a.closeTab(t.id);
704
770
  }
705
- function tt(t) {
771
+ function rt(t, o) {
772
+ o ? F.set(t, o) : F.delete(t);
773
+ }
774
+ function ue(t) {
775
+ B(() => {
776
+ const o = F.get(t), u = _.value;
777
+ if (o && u) {
778
+ const v = o.getBoundingClientRect(), p = u.getBoundingClientRect();
779
+ (v.left < p.left || v.right > p.right) && o.scrollIntoView({
780
+ behavior: "smooth",
781
+ block: "nearest",
782
+ inline: "nearest"
783
+ });
784
+ }
785
+ });
786
+ }
787
+ function at(t) {
706
788
  if (t.href && typeof window < "u") {
707
789
  t.target && t.target !== "_self" ? window.open(t.href, t.target) : window.location.assign(t.href);
708
790
  return;
709
791
  }
710
- r.activeId.value !== t.id && r.openTab(t.to, !1);
792
+ a.activeId.value !== t.id && (a.openTab(t.to, !1), ue(t.id));
711
793
  }
712
- function nt(t) {
794
+ function it(t) {
713
795
  return [
714
796
  "router-tab__item",
715
797
  {
716
- "is-active": r.activeId.value === t.id,
717
- "is-closable": re(t),
718
- "is-dragging": i.dragging && i.dragTab?.id === t.id,
719
- "is-drag-over": i.dropIndex === d(t.id)
798
+ "is-active": a.activeId.value === t.id,
799
+ "is-closable": se(t),
800
+ "is-dragging": w.dragging && w.dragTab?.id === t.id,
801
+ "is-drag-over": w.dropIndex === l(t.id)
720
802
  },
721
803
  t.tabClass
722
804
  ];
723
805
  }
724
- function ot(t) {
725
- return r.refreshingKey.value === r.getRouteKey(t);
806
+ function lt(t) {
807
+ return a.refreshingKey.value === a.getRouteKey(t);
726
808
  }
727
- function at(t) {
728
- const a = r.getRouteKey(t);
729
- return r.tabs.some((f) => f.id === a);
809
+ function st(t) {
810
+ const o = a.getRouteKey(t), u = a.tabs.find((v) => v.id === o);
811
+ return u ? a.options.keepAlive ? u.alive : !0 : !1;
730
812
  }
731
- function rt(t, a, f) {
732
- e.sortable && (i.dragging = !0, i.dragIndex = a, i.dragTab = t, f.dataTransfer && (f.dataTransfer.effectAllowed = "move", f.dataTransfer.setData("text/plain", t.id)), n("tab-sort", { tab: t, index: a }));
813
+ function ut(t, o, u) {
814
+ e.sortable && (w.dragging = !0, w.dragIndex = o, w.dragTab = t, u.dataTransfer && (u.dataTransfer.effectAllowed = "move", u.dataTransfer.setData("text/plain", t.id)), r("tab-sort", { tab: t, index: o }));
733
815
  }
734
- function it(t, a) {
735
- !e.sortable || !i.dragging || (a.preventDefault(), a.dataTransfer && (a.dataTransfer.dropEffect = "move"));
816
+ function ct(t, o) {
817
+ !e.sortable || !w.dragging || (o.preventDefault(), o.dataTransfer && (o.dataTransfer.dropEffect = "move"));
736
818
  }
737
- function lt(t) {
738
- !e.sortable || !i.dragging || (i.dropIndex = t);
819
+ function ft(t) {
820
+ !e.sortable || !w.dragging || (w.dropIndex = t);
739
821
  }
740
- function st() {
741
- !e.sortable || i.dragging;
822
+ function dt() {
823
+ !e.sortable || w.dragging;
742
824
  }
743
- function ut(t, a) {
744
- if (!(!e.sortable || !i.dragging)) {
745
- if (a.preventDefault(), i.dragIndex !== -1 && i.dragIndex !== t) {
746
- const f = r.tabs.splice(i.dragIndex, 1)[0];
747
- r.tabs.splice(t, 0, f), n("tab-sorted", {
748
- tab: f,
749
- fromIndex: i.dragIndex,
825
+ function bt(t, o) {
826
+ if (!(!e.sortable || !w.dragging)) {
827
+ if (o.preventDefault(), w.dragIndex !== -1 && w.dragIndex !== t) {
828
+ const u = a.tabs.splice(w.dragIndex, 1)[0];
829
+ a.tabs.splice(t, 0, u), r("tab-sorted", {
830
+ tab: u,
831
+ fromIndex: w.dragIndex,
750
832
  toIndex: t
751
833
  });
752
834
  }
753
- Ce();
835
+ Ke();
754
836
  }
755
837
  }
756
- function Ce() {
757
- i.dragging = !1, i.dragIndex = -1, i.dropIndex = -1, i.dragTab = null;
838
+ function Ke() {
839
+ w.dragging = !1, w.dragIndex = -1, w.dropIndex = -1, w.dragTab = null;
758
840
  }
759
- ge(() => {
760
- document.addEventListener("keydown", E);
761
- }), gt(() => {
762
- document.removeEventListener("keydown", E), o.appContext.config.globalProperties.$tabs = null, B.forEach((t) => {
763
- t.forEach((a) => a());
764
- }), B.clear(), x.clear();
765
- }), P(
841
+ Te(() => {
842
+ document.addEventListener("keydown", C);
843
+ }), Tt(() => {
844
+ document.removeEventListener("keydown", C), n.appContext.config.globalProperties.$tabs = null, L.forEach((t) => {
845
+ t.forEach((o) => {
846
+ try {
847
+ o();
848
+ } catch (u) {
849
+ console.error("[RouterTab] Error during cleanup:", u);
850
+ }
851
+ });
852
+ }), L.clear(), I.clear();
853
+ }), K(
766
854
  () => e.keepAlive,
767
855
  (t) => {
768
- r.options.keepAlive = t;
856
+ a.options.keepAlive = t;
857
+ }
858
+ ), K(
859
+ () => a.activeId.value,
860
+ (t) => {
861
+ t && ue(t), C();
862
+ }
863
+ ), K(
864
+ () => a.tabs.length,
865
+ () => {
866
+ const t = new Set(a.tabs.map((u) => u.id));
867
+ Array.from(I.keys()).forEach((u) => {
868
+ t.has(u) || (console.log(`[RouterTab] Cleaning up stale component instance: ${u}`), $(u));
869
+ });
769
870
  }
770
- ), P(
771
- () => r.activeId.value,
772
- () => E()
773
- ), P(
871
+ ), K(
774
872
  () => e.contextmenu,
775
873
  (t) => {
776
- t || E();
874
+ t || C();
777
875
  }
778
- ), P(
779
- () => _.value.length,
876
+ ), K(
877
+ () => H.value.length,
780
878
  (t) => {
781
- y.visible && t === 0 && E();
879
+ T.visible && t === 0 && C();
782
880
  },
783
881
  { flush: "post" }
784
882
  // Run after component updates to prevent blocking render
785
- ), P(_, (t) => {
786
- if (!y.visible) return;
787
- M.value = new Array(t.length).fill(null);
788
- const a = X(-1, 1, t);
789
- F(a);
790
- }, { flush: "post" }), P(
791
- () => y.visible,
883
+ ), K(H, (t) => {
884
+ if (!T.visible) return;
885
+ O.value = new Array(t.length).fill(null);
886
+ const o = Q(-1, 1, t);
887
+ W(o);
888
+ }, { flush: "post" }), K(
889
+ () => T.visible,
792
890
  (t) => {
793
- t || (D.value = -1, M.value = []);
891
+ t || (S.value = -1, O.value = []);
794
892
  }
795
893
  );
796
- const ct = r.includeKeys;
894
+ const pt = a.includeKeys;
797
895
  return {
798
- controller: r,
799
- tabs: r.tabs,
800
- includeKeys: ct,
801
- tabTransitionProps: ne,
802
- pageTransitionProps: oe,
803
- buildTabClass: nt,
804
- activate: tt,
805
- close: et,
806
- context: y,
807
- menuItems: _,
808
- handleMenuAction: ke,
809
- showContextMenu: He,
810
- hideContextMenu: E,
811
- getTabTitle: ae,
812
- isClosable: re,
813
- isRefreshing: ot,
814
- isTabReady: at,
815
- hasCustomSlot: p,
816
- hasStartSlot: T,
896
+ controller: a,
897
+ tabs: a.tabs,
898
+ includeKeys: pt,
899
+ tabTransitionProps: re,
900
+ pageTransitionProps: ae,
901
+ buildTabClass: it,
902
+ activate: at,
903
+ close: ot,
904
+ context: T,
905
+ menuItems: H,
906
+ handleMenuAction: Ae,
907
+ showContextMenu: Ge,
908
+ hideContextMenu: C,
909
+ getTabTitle: le,
910
+ isClosable: se,
911
+ isRefreshing: lt,
912
+ isTabReady: st,
913
+ hasCustomSlot: g,
914
+ hasStartSlot: y,
817
915
  hasEndSlot: s,
818
- onDragStart: rt,
819
- onDragOver: it,
820
- onDragEnter: lt,
821
- onDragLeave: st,
822
- onDrop: ut,
823
- onDragEnd: Ce,
824
- setupComponentWatching: z,
825
- cleanupComponentWatching: Y,
826
- handleComponentRef: O,
827
- getReactiveTabTitle: Qe,
828
- getComponentCacheKey: we,
829
- getRefreshComponentKey: Ze,
830
- triggerTabUpdate: R,
831
- menuRef: G,
832
- highlightedIndex: D,
833
- setMenuItemRef: Ge,
834
- onMenuKeydown: qe,
835
- highlightMenuIndex: F
916
+ onDragStart: ut,
917
+ onDragOver: ct,
918
+ onDragEnter: ft,
919
+ onDragLeave: dt,
920
+ onDrop: bt,
921
+ onDragEnd: Ke,
922
+ setupComponentWatching: Y,
923
+ cleanupComponentWatching: $,
924
+ handleComponentRef: U,
925
+ getReactiveTabTitle: tt,
926
+ getComponentCacheKey: Pe,
927
+ getRefreshComponentKey: nt,
928
+ triggerTabUpdate: E,
929
+ menuRef: q,
930
+ highlightedIndex: S,
931
+ setMenuItemRef: Qe,
932
+ onMenuKeydown: et,
933
+ highlightMenuIndex: W,
934
+ scrollContainer: _,
935
+ setTabRef: rt,
936
+ scrollTabIntoView: ue
836
937
  };
837
938
  }
838
- }), jt = (e, n) => {
839
- const o = e.__vccOpts || e;
840
- for (const [l, r] of n)
841
- o[l] = r;
842
- return o;
843
- }, Ot = { class: "router-tab" }, Ut = { class: "router-tab__header" }, Vt = { class: "router-tab__scroll" }, Nt = ["data-title", "draggable", "onClick", "onAuxclick", "onContextmenu", "onDragstart", "onDragover", "onDragenter", "onDrop"], zt = ["title"], Yt = ["onClick"], _t = { class: "router-tab__container" }, Ft = ["aria-disabled", "disabled", "tabindex", "onMouseenter", "onClick"];
844
- function Ht(e, n, o, l, r, p) {
845
- const T = mt("RouterView");
846
- return K(), $("div", Ot, [
847
- L("header", Ut, [
848
- L("div", {
849
- class: H(["router-tab__slot-start", { "has-content": e.hasStartSlot }])
939
+ }), zt = (e, r) => {
940
+ const n = e.__vccOpts || e;
941
+ for (const [i, a] of r)
942
+ n[i] = a;
943
+ return n;
944
+ }, Yt = { class: "router-tab" }, _t = { class: "router-tab__header" }, Ft = {
945
+ class: "router-tab__scroll",
946
+ ref: "scrollContainer"
947
+ }, Ht = ["data-title", "draggable", "onClick", "onAuxclick", "onContextmenu", "onDragstart", "onDragover", "onDragenter", "onDrop"], Wt = ["title"], Jt = ["onClick"], Gt = { class: "router-tab__container" }, Xt = ["aria-disabled", "disabled", "tabindex", "onMouseenter", "onClick"];
948
+ function qt(e, r, n, i, a, g) {
949
+ const y = wt("RouterView");
950
+ return P(), M("div", Yt, [
951
+ j("header", _t, [
952
+ j("div", {
953
+ class: J(["router-tab__slot-start", { "has-content": e.hasStartSlot }])
850
954
  }, [
851
- le(e.$slots, "start")
955
+ fe(e.$slots, "start")
852
956
  ], 2),
853
- L("div", Vt, [
854
- Pe(yt, se({
957
+ j("div", Ft, [
958
+ xe(Rt, de({
855
959
  tag: "ul",
856
960
  class: "router-tab__nav"
857
961
  }, e.tabTransitionProps), {
858
- default: ue(() => [
859
- (K(!0), $(Ae, null, Ee(e.tabs, (s, c) => (K(), $("li", {
962
+ default: be(() => [
963
+ (P(!0), M(De, null, Be(e.tabs, (s, f) => (P(), M("li", {
860
964
  key: s.id,
861
- class: H(e.buildTabClass(s)),
965
+ class: J(e.buildTabClass(s)),
862
966
  "data-title": e.getTabTitle(s),
863
967
  draggable: e.sortable,
864
- onClick: (g) => e.activate(s),
865
- onAuxclick: ce((g) => e.close(s), ["middle", "prevent"]),
866
- onContextmenu: ce((g) => e.showContextMenu(s, g), ["prevent"]),
867
- onDragstart: (g) => e.onDragStart(s, c, g),
868
- onDragover: (g) => e.onDragOver(c, g),
869
- onDragenter: (g) => e.onDragEnter(c),
870
- onDragleave: n[0] || (n[0] = (...g) => e.onDragLeave && e.onDragLeave(...g)),
871
- onDrop: (g) => e.onDrop(c, g),
872
- onDragend: n[1] || (n[1] = (...g) => e.onDragEnd && e.onDragEnd(...g))
968
+ ref_for: !0,
969
+ ref: (m) => e.setTabRef(s.id, m),
970
+ onClick: (m) => e.activate(s),
971
+ onAuxclick: pe((m) => e.close(s), ["middle", "prevent"]),
972
+ onContextmenu: pe((m) => e.showContextMenu(s, m), ["prevent"]),
973
+ onDragstart: (m) => e.onDragStart(s, f, m),
974
+ onDragover: (m) => e.onDragOver(f, m),
975
+ onDragenter: (m) => e.onDragEnter(f),
976
+ onDragleave: r[0] || (r[0] = (...m) => e.onDragLeave && e.onDragLeave(...m)),
977
+ onDrop: (m) => e.onDrop(f, m),
978
+ onDragend: r[1] || (r[1] = (...m) => e.onDragEnd && e.onDragEnd(...m))
873
979
  }, [
874
- s.icon ? (K(), $("i", {
980
+ s.icon ? (P(), M("i", {
875
981
  key: 0,
876
- class: H(["router-tab__item-icon", s.icon])
877
- }, null, 2)) : q("", !0),
878
- L("span", {
982
+ class: J(["router-tab__item-icon", s.icon])
983
+ }, null, 2)) : Z("", !0),
984
+ j("span", {
879
985
  class: "router-tab__item-title",
880
986
  title: e.getReactiveTabTitle(s)
881
- }, Ie(e.getReactiveTabTitle(s)), 9, zt),
882
- e.isClosable(s) ? (K(), $("a", {
987
+ }, Se(e.getReactiveTabTitle(s)), 9, Wt),
988
+ e.isClosable(s) ? (P(), M("a", {
883
989
  key: 1,
884
990
  class: "router-tab__item-close",
885
- onClick: ce((g) => e.close(s), ["stop"])
886
- }, null, 8, Yt)) : q("", !0)
887
- ], 42, Nt))), 128))
991
+ onClick: pe((m) => e.close(s), ["stop"])
992
+ }, null, 8, Jt)) : Z("", !0)
993
+ ], 42, Ht))), 128))
888
994
  ]),
889
995
  _: 1
890
996
  }, 16)
891
- ]),
892
- L("div", {
893
- class: H(["router-tab__slot-end", { "has-content": e.hasEndSlot }])
997
+ ], 512),
998
+ j("div", {
999
+ class: J(["router-tab__slot-end", { "has-content": e.hasEndSlot }])
894
1000
  }, [
895
- le(e.$slots, "end")
1001
+ fe(e.$slots, "end")
896
1002
  ], 2)
897
1003
  ]),
898
- L("div", _t, [
899
- Pe(T, null, {
900
- default: ue((s) => [
901
- e.hasCustomSlot ? le(e.$slots, "default", ht(se({ key: 0 }, {
1004
+ j("div", Gt, [
1005
+ xe(y, null, {
1006
+ default: be((s) => [
1007
+ e.hasCustomSlot ? fe(e.$slots, "default", Ct(de({ key: 0 }, {
902
1008
  ...s,
903
1009
  controller: e.controller,
904
1010
  // Expose a ref binder so custom slots can keep reactivity
905
- pageRef: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route))
906
- }))) : (K(), J(Tt, se({ key: 1 }, e.pageTransitionProps, { appear: "" }), {
907
- default: ue(() => [
908
- e.isRefreshing(s.route) ? (K(), J(fe(s.Component), {
1011
+ pageRef: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route))
1012
+ }))) : (P(), G(Et, de({ key: 1 }, e.pageTransitionProps, { appear: "" }), {
1013
+ default: be(() => [
1014
+ e.isRefreshing(s.route) ? (P(), G(ge(s.Component), {
909
1015
  key: e.getRefreshComponentKey(s.route),
910
- ref: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route)),
1016
+ ref: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route)),
911
1017
  class: "router-tab-page"
912
- })) : e.controller.options.keepAlive ? (K(), J(kt, {
1018
+ })) : e.controller.options.keepAlive ? (P(), G(At, {
913
1019
  key: 1,
914
1020
  include: e.includeKeys,
915
1021
  max: e.controller.options.maxAlive || void 0
916
1022
  }, [
917
- e.isTabReady(s.route) ? (K(), J(fe(s.Component), {
1023
+ e.isTabReady(s.route) ? (P(), G(ge(s.Component), {
918
1024
  key: e.getComponentCacheKey(s.route),
919
- ref: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route)),
1025
+ ref: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route)),
920
1026
  class: "router-tab-page"
921
- })) : q("", !0)
922
- ], 1032, ["include", "max"])) : e.isTabReady(s.route) ? (K(), J(fe(s.Component), {
1027
+ })) : Z("", !0)
1028
+ ], 1032, ["include", "max"])) : e.isTabReady(s.route) ? (P(), G(ge(s.Component), {
923
1029
  key: e.getComponentCacheKey(s.route),
924
- ref: (c) => e.handleComponentRef(c, e.controller.getRouteKey(s.route)),
1030
+ ref: (f) => e.handleComponentRef(f, e.controller.getRouteKey(s.route)),
925
1031
  class: "router-tab-page"
926
- })) : q("", !0)
1032
+ })) : Z("", !0)
927
1033
  ]),
928
1034
  _: 2
929
1035
  }, 1040))
@@ -931,34 +1037,34 @@ function Ht(e, n, o, l, r, p) {
931
1037
  _: 3
932
1038
  })
933
1039
  ]),
934
- vt(L("div", {
1040
+ kt(j("div", {
935
1041
  ref: "menuRef",
936
1042
  class: "router-tab__contextmenu",
937
1043
  role: "menu",
938
- onKeydown: n[2] || (n[2] = (...s) => e.onMenuKeydown && e.onMenuKeydown(...s)),
939
- style: wt({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
1044
+ onKeydown: r[2] || (r[2] = (...s) => e.onMenuKeydown && e.onMenuKeydown(...s)),
1045
+ style: Pt({ left: e.context.position.x + "px", top: e.context.position.y + "px" })
940
1046
  }, [
941
- (K(!0), $(Ae, null, Ee(e.menuItems, (s, c) => (K(), $("a", {
1047
+ (P(!0), M(De, null, Be(e.menuItems, (s, f) => (P(), M("a", {
942
1048
  key: s.id,
943
1049
  role: "menuitem",
944
- class: H(["router-tab__contextmenu-item", { "is-focused": c === e.highlightedIndex }]),
1050
+ class: J(["router-tab__contextmenu-item", { "is-focused": f === e.highlightedIndex }]),
945
1051
  "aria-disabled": s.disabled,
946
1052
  disabled: s.disabled,
947
- tabindex: s.disabled ? -1 : c === e.highlightedIndex ? 0 : -1,
1053
+ tabindex: s.disabled ? -1 : f === e.highlightedIndex ? 0 : -1,
948
1054
  ref_for: !0,
949
- ref: (g) => e.setMenuItemRef(g, c),
950
- onMouseenter: (g) => !s.disabled && e.highlightMenuIndex(c),
951
- onClick: (g) => e.handleMenuAction(s)
952
- }, Ie(s.label), 43, Ft))), 128))
1055
+ ref: (m) => e.setMenuItemRef(m, f),
1056
+ onMouseenter: (m) => !s.disabled && e.highlightMenuIndex(f),
1057
+ onClick: (m) => e.handleMenuAction(s)
1058
+ }, Se(s.label), 43, Xt))), 128))
953
1059
  ], 36), [
954
- [Ct, e.context.visible && e.context.target]
1060
+ [Kt, e.context.visible && e.context.target]
955
1061
  ])
956
1062
  ]);
957
1063
  }
958
- const Me = /* @__PURE__ */ jt(Lt, [["render", Ht]]), Jt = {
1064
+ const Ue = /* @__PURE__ */ zt(Nt, [["render", qt]]), Qt = {
959
1065
  class: "router-tabs",
960
1066
  "aria-hidden": "true"
961
- }, be = /* @__PURE__ */ Oe({
1067
+ }, he = /* @__PURE__ */ ze({
962
1068
  name: "RouterTabs",
963
1069
  __name: "RouterTabs",
964
1070
  props: {
@@ -973,11 +1079,11 @@ const Me = /* @__PURE__ */ jt(Lt, [["render", Ht]]), Jt = {
973
1079
  fallbackRoute: {}
974
1080
  },
975
1081
  setup(e) {
976
- return Ve(e), (o, l) => (K(), $("span", Jt));
1082
+ return _e(e), (n, i) => (P(), M("span", Qt));
977
1083
  }
978
- }), Ne = "tab-theme-style", ze = "tab-theme-primary-color", Wt = "system", Ye = "(prefers-color-scheme: dark)";
979
- let W = null;
980
- const C = {
1084
+ }), Fe = "tab-theme-style", He = "tab-theme-primary-color", Zt = "system", We = "(prefers-color-scheme: dark)";
1085
+ let X = null;
1086
+ const A = {
981
1087
  primary: "#034960",
982
1088
  background: "#ffffff",
983
1089
  text: "#1e293b",
@@ -991,7 +1097,7 @@ const C = {
991
1097
  activeButtonBackground: "#034960",
992
1098
  activeButtonColor: "#ffffff",
993
1099
  iconColor: "#475569"
994
- }, Gt = {
1100
+ }, en = {
995
1101
  primary: "#38bdf8",
996
1102
  background: "#0f172a",
997
1103
  text: "#f1f5f9",
@@ -1007,155 +1113,155 @@ const C = {
1007
1113
  activeButtonColor: "#0f172a",
1008
1114
  iconColor: "#cbd5e1"
1009
1115
  };
1010
- function Xt(e) {
1116
+ function tn(e) {
1011
1117
  if (typeof window > "u") return null;
1012
- const n = window.localStorage.getItem(e);
1013
- if (!n) return null;
1118
+ const r = window.localStorage.getItem(e);
1119
+ if (!r) return null;
1014
1120
  try {
1015
- const o = JSON.parse(n);
1016
- return o && typeof o == "object" ? o : null;
1121
+ const n = JSON.parse(r);
1122
+ return n && typeof n == "object" ? n : null;
1017
1123
  } catch {
1018
1124
  return null;
1019
1125
  }
1020
1126
  }
1021
- function ye(e) {
1022
- typeof document > "u" || (document.documentElement.style.setProperty("--router-tab-primary", e.primary ?? C.primary), document.documentElement.style.setProperty("--router-tab-header-bg", e.headerBackground ?? C.headerBackground), document.documentElement.style.setProperty("--router-tab-background", e.background ?? C.background), document.documentElement.style.setProperty("--router-tab-active-background", e.activeBackground ?? C.activeBackground), document.documentElement.style.setProperty("--router-tab-text", e.text ?? C.text), document.documentElement.style.setProperty("--router-tab-active-text", e.activeText ?? C.activeText), document.documentElement.style.setProperty("--router-tab-border", e.border ?? C.border), document.documentElement.style.setProperty("--router-tab-active-border", e.activeBorder ?? C.activeBorder), document.documentElement.style.setProperty("--router-tab-button-color", e.buttonColor ?? C.buttonColor), document.documentElement.style.setProperty("--router-tab-active-button-color", e.activeButtonColor ?? C.activeButtonColor), document.documentElement.style.setProperty("--router-tab-button-background", e.buttonBackground ?? C.buttonBackground), document.documentElement.style.setProperty("--router-tab-active-button-background", e.activeButtonBackground ?? C.activeButtonBackground), document.documentElement.style.setProperty("--router-tab-icon-color", e.iconColor ?? C.iconColor));
1127
+ function Re(e) {
1128
+ typeof document > "u" || (document.documentElement.style.setProperty("--router-tab-primary", e.primary ?? A.primary), document.documentElement.style.setProperty("--router-tab-header-bg", e.headerBackground ?? A.headerBackground), document.documentElement.style.setProperty("--router-tab-background", e.background ?? A.background), document.documentElement.style.setProperty("--router-tab-active-background", e.activeBackground ?? A.activeBackground), document.documentElement.style.setProperty("--router-tab-text", e.text ?? A.text), document.documentElement.style.setProperty("--router-tab-active-text", e.activeText ?? A.activeText), document.documentElement.style.setProperty("--router-tab-border", e.border ?? A.border), document.documentElement.style.setProperty("--router-tab-active-border", e.activeBorder ?? A.activeBorder), document.documentElement.style.setProperty("--router-tab-button-color", e.buttonColor ?? A.buttonColor), document.documentElement.style.setProperty("--router-tab-active-button-color", e.activeButtonColor ?? A.activeButtonColor), document.documentElement.style.setProperty("--router-tab-button-background", e.buttonBackground ?? A.buttonBackground), document.documentElement.style.setProperty("--router-tab-active-button-background", e.activeButtonBackground ?? A.activeButtonBackground), document.documentElement.style.setProperty("--router-tab-icon-color", e.iconColor ?? A.iconColor));
1023
1129
  }
1024
- function _e(e) {
1130
+ function Je(e) {
1025
1131
  if (typeof document > "u") return;
1026
- const n = document.documentElement, o = window.matchMedia(Ye), l = () => {
1027
- n.dataset.theme = o.matches ? "dark" : "light";
1132
+ const r = document.documentElement, n = window.matchMedia(We), i = () => {
1133
+ r.dataset.theme = n.matches ? "dark" : "light";
1028
1134
  };
1029
- W && (o.removeEventListener("change", W), W = null), e === "system" ? (l(), W = () => l(), o.addEventListener("change", W)) : n.dataset.theme = e;
1135
+ X && (n.removeEventListener("change", X), X = null), e === "system" ? (i(), X = () => i(), n.addEventListener("change", X)) : r.dataset.theme = e;
1030
1136
  }
1031
- function qt(e = {}) {
1137
+ function nn(e = {}) {
1032
1138
  if (typeof window > "u") return;
1033
1139
  const {
1034
- styleKey: n = Ne,
1035
- primaryKey: o = ze,
1036
- defaultStyle: l = Wt,
1037
- defaultPrimary: r
1038
- } = e, p = window.localStorage.getItem(n) ?? l;
1039
- _e(p);
1040
- const s = p === "dark" || p === "system" && window.matchMedia(Ye).matches ? { ...Gt } : { ...C };
1041
- r && (s.primary = r);
1042
- const c = Xt(o);
1043
- ye(c ? {
1140
+ styleKey: r = Fe,
1141
+ primaryKey: n = He,
1142
+ defaultStyle: i = Zt,
1143
+ defaultPrimary: a
1144
+ } = e, g = window.localStorage.getItem(r) ?? i;
1145
+ Je(g);
1146
+ const s = g === "dark" || g === "system" && window.matchMedia(We).matches ? { ...en } : { ...A };
1147
+ a && (s.primary = a);
1148
+ const f = tn(n);
1149
+ Re(f ? {
1044
1150
  ...s,
1045
- ...c
1151
+ ...f
1046
1152
  } : s);
1047
1153
  }
1048
- function en(e, n) {
1154
+ function an(e, r) {
1049
1155
  if (typeof window > "u") return;
1050
- const o = n?.styleKey ?? Ne;
1051
- window.localStorage.setItem(o, e), _e(e);
1156
+ const n = r?.styleKey ?? Fe;
1157
+ window.localStorage.setItem(n, e), Je(e);
1052
1158
  }
1053
- function tn(e, n) {
1159
+ function ln(e, r) {
1054
1160
  if (typeof window > "u") return;
1055
- const o = n?.primaryKey ?? ze;
1056
- window.localStorage.setItem(o, JSON.stringify(e)), ye(e);
1161
+ const n = r?.primaryKey ?? He;
1162
+ window.localStorage.setItem(n, JSON.stringify(e)), Re(e);
1057
1163
  }
1058
- function Z(e, n) {
1059
- if (Rt(e)) {
1060
- const l = !Kt(e);
1164
+ function te(e, r) {
1165
+ if (It(e)) {
1166
+ const i = !$t(e);
1061
1167
  return {
1062
1168
  value: e,
1063
- update: l ? (r) => {
1064
- e.value = r;
1169
+ update: i ? (a) => {
1170
+ e.value = a;
1065
1171
  } : () => {
1066
1172
  }
1067
1173
  };
1068
1174
  }
1069
1175
  if (typeof e == "function")
1070
1176
  return {
1071
- value: k(e),
1177
+ value: R(e),
1072
1178
  update: () => {
1073
1179
  }
1074
1180
  };
1075
- const o = S(
1076
- e === void 0 ? n : e
1181
+ const n = D(
1182
+ e === void 0 ? r : e
1077
1183
  );
1078
1184
  return {
1079
- value: o,
1080
- update: (l) => {
1081
- o.value = l;
1185
+ value: n,
1186
+ update: (i) => {
1187
+ n.value = i;
1082
1188
  }
1083
1189
  };
1084
1190
  }
1085
- function he(e = {}) {
1086
- const n = Z(e.title, "Untitled"), o = Z(e.icon, ""), l = Z(e.closable, !0), r = Z(e.meta, {});
1191
+ function Ce(e = {}) {
1192
+ const r = te(e.title, "Untitled"), n = te(e.icon, ""), i = te(e.closable, !0), a = te(e.meta, {});
1087
1193
  return {
1088
- routeTabTitle: n.value,
1089
- routeTabIcon: o.value,
1090
- routeTabClosable: l.value,
1091
- routeTabMeta: r.value,
1092
- updateTitle: n.update,
1093
- updateIcon: o.update,
1094
- updateClosable: l.update,
1095
- updateMeta: r.update
1194
+ routeTabTitle: r.value,
1195
+ routeTabIcon: n.value,
1196
+ routeTabClosable: i.value,
1197
+ routeTabMeta: a.value,
1198
+ updateTitle: r.update,
1199
+ updateIcon: n.update,
1200
+ updateClosable: i.update,
1201
+ updateMeta: a.update
1096
1202
  };
1097
1203
  }
1098
- function nn(e, n = "Page") {
1099
- return he({
1100
- title: k(() => e.value ? "Loading..." : n),
1101
- icon: k(() => e.value ? "mdi-loading mdi-spin" : "mdi-page"),
1102
- closable: k(() => !e.value)
1204
+ function sn(e, r = "Page") {
1205
+ return Ce({
1206
+ title: R(() => e.value ? "Loading..." : r),
1207
+ icon: R(() => e.value ? "mdi-loading mdi-spin" : "mdi-page"),
1208
+ closable: R(() => !e.value)
1103
1209
  });
1104
1210
  }
1105
- function on(e, n = "Page", o = "mdi-page") {
1106
- return he({
1107
- title: k(() => e.value > 0 ? `${n} (${e.value})` : n),
1108
- icon: k(() => e.value > 0 ? "mdi-bell-badge" : o)
1211
+ function un(e, r = "Page", n = "mdi-page") {
1212
+ return Ce({
1213
+ title: R(() => e.value > 0 ? `${r} (${e.value})` : r),
1214
+ icon: R(() => e.value > 0 ? "mdi-bell-badge" : n)
1109
1215
  });
1110
1216
  }
1111
- function an(e, n = "Page") {
1112
- const o = {
1217
+ function cn(e, r = "Page") {
1218
+ const n = {
1113
1219
  normal: { suffix: "", icon: "mdi-page" },
1114
1220
  loading: { suffix: " - Loading", icon: "mdi-loading mdi-spin" },
1115
1221
  error: { suffix: " - Error", icon: "mdi-alert" },
1116
1222
  success: { suffix: " - Success", icon: "mdi-check-circle" }
1117
1223
  };
1118
- return he({
1119
- title: k(() => n + o[e.value].suffix),
1120
- icon: k(() => o[e.value].icon),
1121
- closable: k(() => e.value !== "loading")
1224
+ return Ce({
1225
+ title: R(() => r + n[e.value].suffix),
1226
+ icon: R(() => n[e.value].icon),
1227
+ closable: R(() => e.value !== "loading")
1122
1228
  });
1123
1229
  }
1124
- let Le = !1;
1125
- const rn = {
1126
- install(e, n) {
1127
- if (Le) return;
1128
- Le = !0;
1230
+ let Ve = !1;
1231
+ const fn = {
1232
+ install(e, r) {
1233
+ if (Ve) return;
1234
+ Ve = !0;
1129
1235
  const {
1130
- initTheme: o = !0,
1131
- themeOptions: l,
1132
- componentName: r = Me.name || "RouterTab",
1133
- tabsComponentName: p = be.name || "RouterTabs"
1134
- } = n ?? {};
1135
- o && qt(l ?? {}), e.component(r, Me), e.component(p, be), p.toLowerCase() !== "router-tabs" && e.component("router-tabs", be), Object.defineProperty(e.config.globalProperties, "$tabs", {
1236
+ initTheme: n = !0,
1237
+ themeOptions: i,
1238
+ componentName: a = Ue.name || "RouterTab",
1239
+ tabsComponentName: g = he.name || "RouterTabs"
1240
+ } = r ?? {};
1241
+ n && nn(i ?? {}), e.component(a, Ue), e.component(g, he), g.toLowerCase() !== "router-tabs" && e.component("router-tabs", he), Object.defineProperty(e.config.globalProperties, "$tabs", {
1136
1242
  configurable: !0,
1137
1243
  enumerable: !1,
1138
1244
  get() {
1139
- return e._context.provides[te];
1245
+ return e._context.provides[oe];
1140
1246
  },
1141
- set(T) {
1142
- T && e.provide(te, T);
1247
+ set(y) {
1248
+ y && e.provide(oe, y);
1143
1249
  }
1144
1250
  });
1145
1251
  }
1146
1252
  };
1147
1253
  export {
1148
- Me as RouterTab,
1149
- be as RouterTabs,
1150
- rn as default,
1151
- qt as initRouterTabsTheme,
1152
- te as routerTabsKey,
1153
- tn as setRouterTabsPrimary,
1154
- en as setRouterTabsTheme,
1155
- nn as useLoadingTab,
1156
- on as useNotificationTab,
1157
- he as useReactiveTab,
1158
- $e as useRouterTabs,
1159
- Ve as useRouterTabsPersistence,
1160
- an as useStatusTab
1254
+ Ue as RouterTab,
1255
+ he as RouterTabs,
1256
+ fn as default,
1257
+ nn as initRouterTabsTheme,
1258
+ oe as routerTabsKey,
1259
+ ln as setRouterTabsPrimary,
1260
+ an as setRouterTabsTheme,
1261
+ sn as useLoadingTab,
1262
+ un as useNotificationTab,
1263
+ Ce as useReactiveTab,
1264
+ Le as useRouterTabs,
1265
+ _e as useRouterTabsPersistence,
1266
+ cn as useStatusTab
1161
1267
  };