@wsxjs/wsx-router 0.0.24 → 0.0.26

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.
package/dist/index.js CHANGED
@@ -1,277 +1,143 @@
1
- import { autoRegister as ce, LightComponent as re, jsx as te, WebComponent as le } from "@wsxjs/wsx-core";
2
- var We = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
3
- function Ae(r) {
4
- return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
5
- }
6
- var we = { exports: {} };
7
- (function(r) {
8
- (function(e, t) {
9
- r.exports ? r.exports = t() : e.log = t();
10
- })(We, function() {
11
- var e = function() {
12
- }, t = "undefined", n = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), g = [
13
- "trace",
14
- "debug",
15
- "info",
16
- "warn",
17
- "error"
18
- ], p = {}, f = null;
19
- function _(o, c) {
20
- var i = o[c];
21
- if (typeof i.bind == "function")
22
- return i.bind(o);
23
- try {
24
- return Function.prototype.bind.call(i, o);
25
- } catch {
26
- return function() {
27
- return Function.prototype.apply.apply(i, [o, arguments]);
28
- };
29
- }
30
- }
31
- function y() {
32
- console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
33
- }
34
- function T(o) {
35
- return o === "debug" && (o = "log"), typeof console === t ? !1 : o === "trace" && n ? y : console[o] !== void 0 ? _(console, o) : console.log !== void 0 ? _(console, "log") : e;
36
- }
37
- function O() {
38
- for (var o = this.getLevel(), c = 0; c < g.length; c++) {
39
- var i = g[c];
40
- this[i] = c < o ? e : this.methodFactory(i, o, this.name);
41
- }
42
- if (this.log = this.debug, typeof console === t && o < this.levels.SILENT)
43
- return "No console available for logging";
44
- }
45
- function V(o) {
46
- return function() {
47
- typeof console !== t && (O.call(this), this[o].apply(this, arguments));
48
- };
49
- }
50
- function M(o, c, i) {
51
- return T(o) || V.apply(this, arguments);
52
- }
53
- function H(o, c) {
54
- var i = this, u, A, k, L = "loglevel";
55
- typeof o == "string" ? L += ":" + o : typeof o == "symbol" && (L = void 0);
56
- function P(h) {
57
- var l = (g[h] || "silent").toUpperCase();
58
- if (!(typeof window === t || !L)) {
59
- try {
60
- window.localStorage[L] = l;
61
- return;
62
- } catch {
63
- }
64
- try {
65
- window.document.cookie = encodeURIComponent(L) + "=" + l + ";";
66
- } catch {
67
- }
68
- }
69
- }
70
- function C() {
71
- var h;
72
- if (!(typeof window === t || !L)) {
73
- try {
74
- h = window.localStorage[L];
75
- } catch {
76
- }
77
- if (typeof h === t)
78
- try {
79
- var l = window.document.cookie, x = encodeURIComponent(L), $ = l.indexOf(x + "=");
80
- $ !== -1 && (h = /^([^;]+)/.exec(
81
- l.slice($ + x.length + 1)
82
- )[1]);
83
- } catch {
84
- }
85
- return i.levels[h] === void 0 && (h = void 0), h;
86
- }
87
- }
88
- function R() {
89
- if (!(typeof window === t || !L)) {
90
- try {
91
- window.localStorage.removeItem(L);
92
- } catch {
93
- }
94
- try {
95
- window.document.cookie = encodeURIComponent(L) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
96
- } catch {
97
- }
98
- }
99
- }
100
- function v(h) {
101
- var l = h;
102
- if (typeof l == "string" && i.levels[l.toUpperCase()] !== void 0 && (l = i.levels[l.toUpperCase()]), typeof l == "number" && l >= 0 && l <= i.levels.SILENT)
103
- return l;
104
- throw new TypeError("log.setLevel() called with invalid level: " + h);
105
- }
106
- i.name = o, i.levels = {
107
- TRACE: 0,
108
- DEBUG: 1,
109
- INFO: 2,
110
- WARN: 3,
111
- ERROR: 4,
112
- SILENT: 5
113
- }, i.methodFactory = c || M, i.getLevel = function() {
114
- return k ?? A ?? u;
115
- }, i.setLevel = function(h, l) {
116
- return k = v(h), l !== !1 && P(k), O.call(i);
117
- }, i.setDefaultLevel = function(h) {
118
- A = v(h), C() || i.setLevel(h, !1);
119
- }, i.resetLevel = function() {
120
- k = null, R(), O.call(i);
121
- }, i.enableAll = function(h) {
122
- i.setLevel(i.levels.TRACE, h);
123
- }, i.disableAll = function(h) {
124
- i.setLevel(i.levels.SILENT, h);
125
- }, i.rebuild = function() {
126
- if (f !== i && (u = v(f.getLevel())), O.call(i), f === i)
127
- for (var h in p)
128
- p[h].rebuild();
129
- }, u = v(
130
- f ? f.getLevel() : "WARN"
131
- );
132
- var m = C();
133
- m != null && (k = v(m)), O.call(i);
134
- }
135
- f = new H(), f.getLogger = function(c) {
136
- if (typeof c != "symbol" && typeof c != "string" || c === "")
137
- throw new TypeError("You must supply a name when creating a logger.");
138
- var i = p[c];
139
- return i || (i = p[c] = new H(
140
- c,
141
- f.methodFactory
142
- )), i;
143
- };
144
- var s = typeof window !== t ? window.log : void 0;
145
- return f.noConflict = function() {
146
- return typeof window !== t && window.log === f && (window.log = s), f;
147
- }, f.getLoggers = function() {
148
- return p;
149
- }, f.default = f, f;
150
- });
151
- })(we);
152
- var Te = we.exports;
153
- const Oe = /* @__PURE__ */ Ae(Te), ye = {
154
- trace: "trace",
155
- debug: "debug",
156
- info: "info",
157
- warn: "warn",
158
- error: "error",
159
- silent: "silent"
160
- }, je = {
161
- 0: "trace",
162
- 1: "debug",
163
- 2: "info",
164
- 3: "warn",
165
- 4: "error",
166
- 5: "silent"
1
+ import { autoRegister as ct, LightComponent as nt, jsx as tt, WebComponent as lt } from "@wsxjs/wsx-core";
2
+ const it = {
3
+ trace: 0,
4
+ debug: 1,
5
+ info: 2,
6
+ warn: 3,
7
+ error: 4,
8
+ silent: 5
167
9
  };
168
- function ae() {
169
- var r, e;
10
+ function at() {
11
+ var r, t;
170
12
  if (typeof process < "u")
171
13
  return process.env.NODE_ENV === "production" || process.env.MODE === "production";
172
14
  try {
173
- const t = globalThis;
174
- if ((e = (r = t.import) == null ? void 0 : r.meta) != null && e.env) {
175
- const n = t.import.meta.env;
15
+ const e = globalThis;
16
+ if ((t = (r = e.import) == null ? void 0 : r.meta) != null && t.env) {
17
+ const n = e.import.meta.env;
176
18
  return n.MODE === "production" || n.PROD === !0;
177
19
  }
178
20
  } catch {
179
21
  }
180
22
  return !1;
181
23
  }
182
- const ee = {
24
+ const ut = {
183
25
  name: "WSX",
184
- level: ae() ? "info" : "debug",
185
- pretty: !ae()
26
+ level: at() ? "info" : "debug",
27
+ pretty: !at()
186
28
  };
187
- function De(r = {}) {
188
- const { name: e, level: t } = { ...ee, ...r }, n = e || ee.name, g = Oe.getLogger(n), p = t || ee.level;
189
- return g.setLevel(ye[p]), g;
29
+ function G(r, t) {
30
+ return r ? `[${r}] ${t}` : t;
190
31
  }
191
- function X(r, e) {
192
- return r ? `[${r}] ${e}` : e;
193
- }
194
- class be {
195
- constructor(e = {}) {
196
- this.isProd = ae(), this.name = e.name || ee.name, this.currentLevel = e.level || ee.level, this.logInstance = De(e);
32
+ class Wt {
33
+ constructor(t, e) {
34
+ this.name = t, this.level = e, this.levelValue = it[e], this.isProd = at();
35
+ }
36
+ /**
37
+ * Check if a log level should be logged
38
+ */
39
+ shouldLog(t) {
40
+ return this.level === "silent" ? !1 : it[t] >= this.levelValue;
41
+ }
42
+ trace(t, ...e) {
43
+ if (!this.isProd || this.shouldLog("trace")) {
44
+ const n = G(this.name, t);
45
+ e.length > 0 ? console.debug(n, ...e) : console.debug(n);
46
+ }
197
47
  }
198
- debug(e, ...t) {
48
+ debug(t, ...e) {
199
49
  if (!this.isProd || this.shouldLog("debug")) {
200
- const n = X(this.name, e);
201
- t.length > 0 ? this.logInstance.debug(n, ...t) : this.logInstance.debug(n);
50
+ const n = G(this.name, t);
51
+ e.length > 0 ? console.debug(n, ...e) : console.debug(n);
202
52
  }
203
53
  }
204
- info(e, ...t) {
54
+ info(t, ...e) {
205
55
  if (this.shouldLog("info")) {
206
- const n = X(this.name, e);
207
- t.length > 0 ? this.logInstance.info(n, ...t) : this.logInstance.info(n);
56
+ const n = G(this.name, t);
57
+ e.length > 0 ? console.info(n, ...e) : console.info(n);
208
58
  }
209
59
  }
210
- warn(e, ...t) {
211
- const n = X(this.name, e);
212
- t.length > 0 ? this.logInstance.warn(n, ...t) : this.logInstance.warn(n);
213
- }
214
- error(e, ...t) {
215
- const n = X(this.name, e);
216
- t.length > 0 ? this.logInstance.error(n, ...t) : this.logInstance.error(n);
217
- }
218
- fatal(e, ...t) {
219
- const n = X(this.name, e);
220
- t.length > 0 ? this.logInstance.error(`[FATAL] ${n}`, ...t) : this.logInstance.error(`[FATAL] ${n}`);
60
+ warn(t, ...e) {
61
+ if (this.shouldLog("warn")) {
62
+ const n = G(this.name, t);
63
+ e.length > 0 ? console.warn(n, ...e) : console.warn(n);
64
+ }
221
65
  }
222
- trace(e, ...t) {
223
- if (!this.isProd || this.shouldLog("trace")) {
224
- const n = X(this.name, e);
225
- t.length > 0 ? this.logInstance.trace(n, ...t) : this.logInstance.trace(n);
66
+ error(t, ...e) {
67
+ if (this.shouldLog("error")) {
68
+ const n = G(this.name, t);
69
+ e.length > 0 ? console.error(n, ...e) : console.error(n);
226
70
  }
227
71
  }
228
72
  /**
229
- * Check if a log level should be logged based on current level
73
+ * Set the log level dynamically
230
74
  */
231
- shouldLog(e) {
232
- const t = ["trace", "debug", "info", "warn", "error", "silent"], n = t.indexOf(this.currentLevel);
233
- return t.indexOf(e) >= n;
75
+ setLevel(t) {
76
+ this.level = t, this.levelValue = it[t];
234
77
  }
235
78
  /**
236
- * Get the underlying loglevel logger instance
79
+ * Get the current log level
237
80
  */
238
- getLoglevelLogger() {
239
- return this.logInstance;
81
+ getLevel() {
82
+ return this.level;
83
+ }
84
+ }
85
+ class wt {
86
+ constructor(t = {}) {
87
+ this.name = t.name || ut.name, this.currentLevel = t.level || ut.level, this.nativeLogger = new Wt(this.name, this.currentLevel);
88
+ }
89
+ debug(t, ...e) {
90
+ this.nativeLogger.debug(t, ...e);
91
+ }
92
+ info(t, ...e) {
93
+ this.nativeLogger.info(t, ...e);
94
+ }
95
+ warn(t, ...e) {
96
+ this.nativeLogger.warn(t, ...e);
97
+ }
98
+ error(t, ...e) {
99
+ this.nativeLogger.error(t, ...e);
100
+ }
101
+ fatal(t, ...e) {
102
+ const n = G(this.name, `[FATAL] ${t}`);
103
+ e.length > 0 ? console.error(n, ...e) : console.error(n);
104
+ }
105
+ trace(t, ...e) {
106
+ this.nativeLogger.trace(t, ...e);
240
107
  }
241
108
  /**
242
109
  * Set the log level dynamically
243
110
  */
244
- setLevel(e) {
245
- this.currentLevel = e, this.logInstance.setLevel(ye[e]);
111
+ setLevel(t) {
112
+ this.currentLevel = t, this.nativeLogger.setLevel(t);
246
113
  }
247
114
  /**
248
115
  * Get the current log level
249
116
  */
250
117
  getLevel() {
251
- const e = this.logInstance.getLevel();
252
- return je[e] || this.currentLevel;
118
+ return this.nativeLogger.getLevel();
253
119
  }
254
120
  }
255
- new be();
256
- function ie(r, e = {}) {
257
- return new be({
258
- ...e,
259
- name: e.name || `WSX:${r}`
121
+ new wt();
122
+ function rt(r, t = {}) {
123
+ return new wt({
124
+ ...t,
125
+ name: t.name || `WSX:${r}`
260
126
  });
261
127
  }
262
- const Me = ie("RouterUtils"), Y = class Y {
128
+ const jt = rt("RouterUtils"), J = class J {
263
129
  /**
264
130
  * 设置当前路由信息(由 WsxRouter 内部调用)
265
131
  * @internal
266
132
  */
267
- static _setCurrentRoute(e) {
268
- Y._currentRoute = e;
133
+ static _setCurrentRoute(t) {
134
+ J._currentRoute = t;
269
135
  }
270
136
  /**
271
137
  * 编程式导航
272
138
  */
273
- static navigate(e, t = !1) {
274
- t ? window.history.replaceState(null, "", e) : window.history.pushState(null, "", e), window.dispatchEvent(new PopStateEvent("popstate")), Me.debug(`Navigated to: ${e} (replace: ${t})`);
139
+ static navigate(t, e = !1) {
140
+ e ? window.history.replaceState(null, "", t) : window.history.pushState(null, "", t), window.dispatchEvent(new PopStateEvent("popstate")), jt.debug(`Navigated to: ${t} (replace: ${e})`);
275
141
  }
276
142
  /**
277
143
  * 获取当前路由信息
@@ -279,52 +145,52 @@ const Me = ie("RouterUtils"), Y = class Y {
279
145
  * 否则返回基础路由信息(参数为空对象)
280
146
  */
281
147
  static getCurrentRoute() {
282
- if (Y._currentRoute)
283
- return Y._currentRoute;
284
- const e = new URL(window.location.href);
148
+ if (J._currentRoute)
149
+ return J._currentRoute;
150
+ const t = new URL(window.location.href);
285
151
  return {
286
- path: e.pathname,
152
+ path: t.pathname,
287
153
  params: {},
288
- query: Object.fromEntries(e.searchParams.entries()),
289
- hash: e.hash.slice(1)
154
+ query: Object.fromEntries(t.searchParams.entries()),
155
+ hash: t.hash.slice(1)
290
156
  // 移除 # 号
291
157
  };
292
158
  }
293
159
  /**
294
160
  * 解析路由路径,提取参数
295
161
  */
296
- static parseRoute(e, t) {
162
+ static parseRoute(t, e) {
297
163
  var n;
298
- if (e === t)
164
+ if (t === e)
299
165
  return {
300
- route: e,
166
+ route: t,
301
167
  params: {},
302
168
  exact: !0
303
169
  };
304
- if (e === "*")
170
+ if (t === "*")
305
171
  return {
306
- route: e,
172
+ route: t,
307
173
  params: {},
308
174
  exact: !1
309
175
  };
310
- if (e.includes(":")) {
311
- const g = ((n = e.match(/:([^/]+)/g)) == null ? void 0 : n.map((y) => y.slice(1))) || [], p = e.replace(/:[^/]+/g, "([^/]+)"), f = new RegExp(`^${p}$`), _ = t.match(f);
312
- if (_ && g.length > 0) {
313
- const y = {};
314
- return g.forEach((T, O) => {
315
- y[T] = _[O + 1];
176
+ if (t.includes(":")) {
177
+ const f = ((n = t.match(/:([^/]+)/g)) == null ? void 0 : n.map((b) => b.slice(1))) || [], v = t.replace(/:[^/]+/g, "([^/]+)"), y = new RegExp(`^${v}$`), k = e.match(y);
178
+ if (k && f.length > 0) {
179
+ const b = {};
180
+ return f.forEach((j, z) => {
181
+ b[j] = k[z + 1];
316
182
  }), {
317
- route: e,
318
- params: y,
183
+ route: t,
184
+ params: b,
319
185
  exact: !0
320
186
  };
321
187
  }
322
188
  }
323
- if (e.endsWith("/*")) {
324
- const g = e.slice(0, -2);
325
- if (t.startsWith(g))
189
+ if (t.endsWith("/*")) {
190
+ const f = t.slice(0, -2);
191
+ if (e.startsWith(f))
326
192
  return {
327
- route: e,
193
+ route: t,
328
194
  params: {},
329
195
  exact: !1
330
196
  };
@@ -334,67 +200,67 @@ const Me = ie("RouterUtils"), Y = class Y {
334
200
  /**
335
201
  * 构建路由路径,替换参数
336
202
  */
337
- static buildPath(e, t = {}) {
338
- let n = e;
339
- return Object.entries(t).forEach(([g, p]) => {
340
- n = n.replace(`:${g}`, encodeURIComponent(p));
203
+ static buildPath(t, e = {}) {
204
+ let n = t;
205
+ return Object.entries(e).forEach(([f, v]) => {
206
+ n = n.replace(`:${f}`, encodeURIComponent(v));
341
207
  }), n;
342
208
  }
343
209
  /**
344
210
  * 检查路由是否匹配当前路径
345
211
  */
346
- static isRouteActive(e, t = !1) {
212
+ static isRouteActive(t, e = !1) {
347
213
  const n = window.location.pathname;
348
- return t ? n === e : e === "/" ? n === "/" : n.startsWith(e);
214
+ return e ? n === t : t === "/" ? n === "/" : n.startsWith(t);
349
215
  }
350
216
  /**
351
217
  * 获取路由层级
352
218
  */
353
- static getRouteDepth(e) {
354
- return e.split("/").filter((t) => t.length > 0).length;
219
+ static getRouteDepth(t) {
220
+ return t.split("/").filter((e) => e.length > 0).length;
355
221
  }
356
222
  /**
357
223
  * 获取父级路由
358
224
  */
359
- static getParentRoute(e) {
360
- const t = e.split("/").filter((n) => n.length > 0);
361
- return t.length <= 1 ? "/" : (t.pop(), "/" + t.join("/"));
225
+ static getParentRoute(t) {
226
+ const e = t.split("/").filter((n) => n.length > 0);
227
+ return e.length <= 1 ? "/" : (e.pop(), "/" + e.join("/"));
362
228
  }
363
229
  /**
364
230
  * 合并路由路径
365
231
  */
366
- static joinPaths(...e) {
367
- return e.map((t) => t.replace(/^\/+|\/+$/g, "")).filter((t) => t.length > 0).join("/").replace(/^/, "/");
232
+ static joinPaths(...t) {
233
+ return t.map((e) => e.replace(/^\/+|\/+$/g, "")).filter((e) => e.length > 0).join("/").replace(/^/, "/");
368
234
  }
369
235
  /**
370
236
  * 检查是否为外部链接
371
237
  */
372
- static isExternalUrl(e) {
373
- return /^https?:\/\//.test(e) || /^mailto:/.test(e) || /^tel:/.test(e);
238
+ static isExternalUrl(t) {
239
+ return /^https?:\/\//.test(t) || /^mailto:/.test(t) || /^tel:/.test(t);
374
240
  }
375
241
  /**
376
242
  * 获取查询参数
377
243
  */
378
- static getQueryParam(e) {
379
- return new URL(window.location.href).searchParams.get(e);
244
+ static getQueryParam(t) {
245
+ return new URL(window.location.href).searchParams.get(t);
380
246
  }
381
247
  /**
382
248
  * 设置查询参数
383
249
  */
384
- static setQueryParam(e, t, n = !1) {
385
- const g = new URL(window.location.href);
386
- g.searchParams.set(e, t);
387
- const p = g.pathname + g.search + g.hash;
388
- this.navigate(p, n);
250
+ static setQueryParam(t, e, n = !1) {
251
+ const f = new URL(window.location.href);
252
+ f.searchParams.set(t, e);
253
+ const v = f.pathname + f.search + f.hash;
254
+ this.navigate(v, n);
389
255
  }
390
256
  /**
391
257
  * 删除查询参数
392
258
  */
393
- static removeQueryParam(e, t = !1) {
259
+ static removeQueryParam(t, e = !1) {
394
260
  const n = new URL(window.location.href);
395
- n.searchParams.delete(e);
396
- const g = n.pathname + n.search + n.hash;
397
- this.navigate(g, t);
261
+ n.searchParams.delete(t);
262
+ const f = n.pathname + n.search + n.hash;
263
+ this.navigate(f, e);
398
264
  }
399
265
  /**
400
266
  * 返回上一页
@@ -411,8 +277,8 @@ const Me = ie("RouterUtils"), Y = class Y {
411
277
  /**
412
278
  * 替换当前页面
413
279
  */
414
- static replace(e) {
415
- this.navigate(e, !0);
280
+ static replace(t) {
281
+ this.navigate(t, !0);
416
282
  }
417
283
  /**
418
284
  * 获取历史记录长度
@@ -431,488 +297,488 @@ const Me = ie("RouterUtils"), Y = class Y {
431
297
  *
432
298
  * @see RFC-0035: 路由导航竞态条件修复
433
299
  */
434
- static onRouteChange(e) {
435
- const t = () => {
300
+ static onRouteChange(t) {
301
+ const e = () => {
436
302
  const n = this.getCurrentRoute();
437
- e(n);
303
+ t(n);
438
304
  };
439
- return document.addEventListener("route-changed", t), () => {
440
- document.removeEventListener("route-changed", t);
305
+ return document.addEventListener("route-changed", e), () => {
306
+ document.removeEventListener("route-changed", e);
441
307
  };
442
308
  }
443
309
  };
444
- Y._currentRoute = null;
445
- let ne = Y;
446
- const ue = ":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";
447
- var Re;
448
- let Le, xe;
449
- function F(r, e, t) {
450
- return (e = Ee(e)) in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
310
+ J._currentRoute = null;
311
+ let et = J;
312
+ const ht = ":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";
313
+ var yt;
314
+ let Rt, xt;
315
+ function U(r, t, e) {
316
+ return (t = $t(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
451
317
  }
452
- function Pe(r, e, t, n, g, p) {
453
- function f(s, o, c) {
454
- return function(i, u) {
455
- return c && c(i), s[o].call(i, u);
318
+ function At(r, t, e, n, f, v) {
319
+ function y(i, c, u) {
320
+ return function(s, a) {
321
+ return u && u(s), i[c].call(s, a);
456
322
  };
457
323
  }
458
- function _(s, o) {
459
- for (var c = 0; c < s.length; c++) s[c].call(o);
460
- return o;
324
+ function k(i, c) {
325
+ for (var u = 0; u < i.length; u++) i[u].call(c);
326
+ return c;
461
327
  }
462
- function y(s, o, c, i) {
463
- if (typeof s != "function" && (i || s !== void 0)) throw new TypeError(o + " must " + (c || "be") + " a function" + (i ? "" : " or undefined"));
464
- return s;
328
+ function b(i, c, u, s) {
329
+ if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
330
+ return i;
465
331
  }
466
- function T(s, o, c, i, u, A, k, L, P, C, R, v, m) {
467
- function h(d) {
468
- if (!m(d)) throw new TypeError("Attempted to access private element on non-instance");
332
+ function j(i, c, u, s, a, A, O, S, D, x, w, g, m) {
333
+ function $(l) {
334
+ if (!m(l)) throw new TypeError("Attempted to access private element on non-instance");
469
335
  }
470
- var l, x = o[0], $ = o[3], W = !L;
336
+ var h, C = c[0], E = c[3], W = !S;
471
337
  if (!W) {
472
- c || Array.isArray(x) || (x = [x]);
473
- var a = {}, I = [], b = u === 3 ? "get" : u === 4 || v ? "set" : "value";
474
- C ? (R || v ? a = { get: he(function() {
475
- return $(this);
476
- }, i, "get"), set: function(d) {
477
- o[4](this, d);
478
- } } : a[b] = $, R || he(a[b], i, u === 2 ? "" : b)) : R || (a = Object.getOwnPropertyDescriptor(s, i));
338
+ u || Array.isArray(C) || (C = [C]);
339
+ var o = {}, L = [], p = a === 3 ? "get" : a === 4 || g ? "set" : "value";
340
+ x ? (w || g ? o = { get: dt(function() {
341
+ return E(this);
342
+ }, s, "get"), set: function(l) {
343
+ c[4](this, l);
344
+ } } : o[p] = E, w || dt(o[p], s, a === 2 ? "" : p)) : w || (o = Object.getOwnPropertyDescriptor(i, s));
479
345
  }
480
- for (var w = s, U = x.length - 1; U >= 0; U -= c ? 2 : 1) {
481
- var B = x[U], G = c ? x[U - 1] : void 0, K = {}, j = { kind: ["field", "accessor", "method", "getter", "setter", "class"][u], name: i, metadata: A, addInitializer: (function(d, S) {
482
- if (d.v) throw Error("attempted to call addInitializer after decoration was finished");
483
- y(S, "An initializer", "be", !0), k.push(S);
346
+ for (var d = i, P = C.length - 1; P >= 0; P -= u ? 2 : 1) {
347
+ var B = C[P], F = u ? C[P - 1] : void 0, K = {}, T = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: A, addInitializer: (function(l, _) {
348
+ if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
349
+ b(_, "An initializer", "be", !0), O.push(_);
484
350
  }).bind(null, K) };
485
351
  try {
486
- if (W) (l = y(B.call(G, w, j), "class decorators", "return")) && (w = l);
352
+ if (W) (h = b(B.call(F, d, T), "class decorators", "return")) && (d = h);
487
353
  else {
488
- var D, z;
489
- j.static = P, j.private = C, C ? u === 2 ? D = function(d) {
490
- return h(d), a.value;
491
- } : (u < 4 && (D = f(a, "get", h)), u !== 3 && (z = f(a, "set", h))) : (D = function(d) {
492
- return d[i];
493
- }, (u < 2 || u === 4) && (z = function(d, S) {
494
- d[i] = S;
354
+ var I, M;
355
+ T.static = D, T.private = x, x ? a === 2 ? I = function(l) {
356
+ return $(l), o.value;
357
+ } : (a < 4 && (I = y(o, "get", $)), a !== 3 && (M = y(o, "set", $))) : (I = function(l) {
358
+ return l[s];
359
+ }, (a < 2 || a === 4) && (M = function(l, _) {
360
+ l[s] = _;
495
361
  }));
496
- var J = j.access = { has: C ? m.bind() : function(d) {
497
- return i in d;
362
+ var Q = T.access = { has: x ? m.bind() : function(l) {
363
+ return s in l;
498
364
  } };
499
- if (D && (J.get = D), z && (J.set = z), w = B.call(G, v ? { get: a.get, set: a.set } : a[b], j), v) {
500
- if (typeof w == "object" && w) (l = y(w.get, "accessor.get")) && (a.get = l), (l = y(w.set, "accessor.set")) && (a.set = l), (l = y(w.init, "accessor.init")) && I.push(l);
501
- else if (w !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
502
- } else y(w, (R ? "field" : "method") + " decorators", "return") && (R ? I.push(w) : a[b] = w);
365
+ if (I && (Q.get = I), M && (Q.set = M), d = B.call(F, g ? { get: o.get, set: o.set } : o[p], T), g) {
366
+ if (typeof d == "object" && d) (h = b(d.get, "accessor.get")) && (o.get = h), (h = b(d.set, "accessor.set")) && (o.set = h), (h = b(d.init, "accessor.init")) && L.push(h);
367
+ else if (d !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
368
+ } else b(d, (w ? "field" : "method") + " decorators", "return") && (w ? L.push(d) : o[p] = d);
503
369
  }
504
370
  } finally {
505
371
  K.v = !0;
506
372
  }
507
373
  }
508
- return (R || v) && L.push(function(d, S) {
509
- for (var N = I.length - 1; N >= 0; N--) S = I[N].call(d, S);
510
- return S;
511
- }), R || W || (C ? v ? L.push(f(a, "get"), f(a, "set")) : L.push(u === 2 ? a[b] : f.call.bind(a[b])) : Object.defineProperty(s, i, a)), w;
512
- }
513
- function O(s, o) {
514
- return Object.defineProperty(s, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: o });
515
- }
516
- if (arguments.length >= 6) var V = p[Symbol.metadata || Symbol.for("Symbol.metadata")];
517
- var M = Object.create(V ?? null), H = function(s, o, c, i) {
518
- var u, A, k = [], L = function(b) {
519
- return Ue(b) === s;
520
- }, P = /* @__PURE__ */ new Map();
521
- function C(b) {
522
- b && k.push(_.bind(null, b));
374
+ return (w || g) && S.push(function(l, _) {
375
+ for (var N = L.length - 1; N >= 0; N--) _ = L[N].call(l, _);
376
+ return _;
377
+ }), w || W || (x ? g ? S.push(y(o, "get"), y(o, "set")) : S.push(a === 2 ? o[p] : y.call.bind(o[p])) : Object.defineProperty(i, s, o)), d;
378
+ }
379
+ function z(i, c) {
380
+ return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
381
+ }
382
+ if (arguments.length >= 6) var q = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
383
+ var V = Object.create(q ?? null), Y = function(i, c, u, s) {
384
+ var a, A, O = [], S = function(p) {
385
+ return Tt(p) === i;
386
+ }, D = /* @__PURE__ */ new Map();
387
+ function x(p) {
388
+ p && O.push(k.bind(null, p));
523
389
  }
524
- for (var R = 0; R < o.length; R++) {
525
- var v = o[R];
526
- if (Array.isArray(v)) {
527
- var m = v[1], h = v[2], l = v.length > 3, x = 16 & m, $ = !!(8 & m), W = (m &= 7) == 0, a = h + "/" + $;
528
- if (!W && !l) {
529
- var I = P.get(a);
530
- if (I === !0 || I === 3 && m !== 4 || I === 4 && m !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
531
- P.set(a, !(m > 2) || m);
390
+ for (var w = 0; w < c.length; w++) {
391
+ var g = c[w];
392
+ if (Array.isArray(g)) {
393
+ var m = g[1], $ = g[2], h = g.length > 3, C = 16 & m, E = !!(8 & m), W = (m &= 7) == 0, o = $ + "/" + E;
394
+ if (!W && !h) {
395
+ var L = D.get(o);
396
+ if (L === !0 || L === 3 && m !== 4 || L === 4 && m !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + $);
397
+ D.set(o, !(m > 2) || m);
532
398
  }
533
- T($ ? s : s.prototype, v, x, l ? "#" + h : Ee(h), m, i, $ ? A = A || [] : u = u || [], k, $, l, W, m === 1, $ && l ? L : c);
399
+ j(E ? i : i.prototype, g, C, h ? "#" + $ : $t($), m, s, E ? A = A || [] : a = a || [], O, E, h, W, m === 1, E && h ? S : u);
534
400
  }
535
401
  }
536
- return C(u), C(A), k;
537
- }(r, e, g, M);
538
- return t.length || O(r, M), { e: H, get c() {
539
- var s = [];
540
- return t.length && [O(T(r, [t], n, r.name, 5, M, s), M), _.bind(null, s, r)];
402
+ return x(a), x(A), O;
403
+ }(r, t, f, V);
404
+ return e.length || z(r, V), { e: Y, get c() {
405
+ var i = [];
406
+ return e.length && [z(j(r, [e], n, r.name, 5, V, i), V), k.bind(null, i, r)];
541
407
  } };
542
408
  }
543
- function Ee(r) {
544
- var e = Ve(r, "string");
545
- return typeof e == "symbol" ? e : e + "";
409
+ function $t(r) {
410
+ var t = Ot(r, "string");
411
+ return typeof t == "symbol" ? t : t + "";
546
412
  }
547
- function Ve(r, e) {
413
+ function Ot(r, t) {
548
414
  if (typeof r != "object" || !r) return r;
549
- var t = r[Symbol.toPrimitive];
550
- if (t !== void 0) {
551
- var n = t.call(r, e);
415
+ var e = r[Symbol.toPrimitive];
416
+ if (e !== void 0) {
417
+ var n = e.call(r, t);
552
418
  if (typeof n != "object") return n;
553
419
  throw new TypeError("@@toPrimitive must return a primitive value.");
554
420
  }
555
421
  return String(r);
556
422
  }
557
- function he(r, e, t) {
558
- typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
423
+ function dt(r, t, e) {
424
+ typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
559
425
  try {
560
- Object.defineProperty(r, "name", { configurable: !0, value: t ? t + " " + e : e });
426
+ Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
561
427
  } catch {
562
428
  }
563
429
  return r;
564
430
  }
565
- function Ue(r) {
431
+ function Tt(r) {
566
432
  if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
567
433
  return r;
568
434
  }
569
- const E = ie("WsxRouter");
570
- xe = [ce({
435
+ const R = rt("WsxRouter");
436
+ xt = [ct({
571
437
  tagName: "wsx-router"
572
438
  })];
573
- let ze;
574
- class Ne extends re {
439
+ let It;
440
+ class Vt extends nt {
575
441
  constructor() {
576
442
  super({
577
- styles: ue,
443
+ styles: ht,
578
444
  styleName: "wsx-router"
579
- }), F(this, "_autoStyles", ue), F(this, "views", /* @__PURE__ */ new Map()), F(this, "currentView", null), F(this, "currentPath", ""), F(this, "isHandlingRoute", !1), F(this, "compiledRoutes", /* @__PURE__ */ new Map()), F(this, "matchCache", /* @__PURE__ */ new Map()), F(this, "enableViewTransitions", !0), F(this, "scrollRestoration", "manual"), F(this, "handleRouteChange", () => {
445
+ }), U(this, "_autoStyles", ht), U(this, "views", /* @__PURE__ */ new Map()), U(this, "currentView", null), U(this, "currentPath", ""), U(this, "isHandlingRoute", !1), U(this, "compiledRoutes", /* @__PURE__ */ new Map()), U(this, "matchCache", /* @__PURE__ */ new Map()), U(this, "enableViewTransitions", !0), U(this, "scrollRestoration", "manual"), U(this, "handleRouteChange", () => {
580
446
  if (this.isHandlingRoute) {
581
- E.debug("Route change already in progress, skipping");
447
+ R.debug("Route change already in progress, skipping");
582
448
  return;
583
449
  }
584
- this.views.size === 0 && (this.collectViews(), E.debug(`WsxRouter re-collected views: ${this.views.size}`)), this.isHandlingRoute = !0;
450
+ this.views.size === 0 && (this.collectViews(), R.debug(`WsxRouter re-collected views: ${this.views.size}`)), this.isHandlingRoute = !0;
585
451
  try {
586
- const e = window.location.pathname;
587
- E.debug(`WsxRouter: Route changed to: ${e}`);
588
- const t = new CustomEvent("before-navigate", {
452
+ const t = window.location.pathname;
453
+ R.debug(`WsxRouter: Route changed to: ${t}`);
454
+ const e = new CustomEvent("before-navigate", {
589
455
  detail: {
590
- to: e,
456
+ to: t,
591
457
  from: this.currentPath
592
458
  },
593
459
  bubbles: !0,
594
460
  cancelable: !0
595
461
  });
596
- if (!this.dispatchEvent(t)) {
597
- E.debug(`Navigation to ${e} was cancelled`);
462
+ if (!this.dispatchEvent(e)) {
463
+ R.debug(`Navigation to ${t} was cancelled`);
598
464
  return;
599
465
  }
600
- this.performNavigation(e);
466
+ this.performNavigation(t);
601
467
  } finally {
602
468
  requestAnimationFrame(() => {
603
469
  this.isHandlingRoute = !1;
604
470
  });
605
471
  }
606
- }), F(this, "interceptLinks", (e) => {
607
- const t = e.target.closest("a");
608
- if (!t) return;
609
- const n = t.getAttribute("href");
610
- !n || n.startsWith("http") || n.startsWith("#") || (e.preventDefault(), this.navigate(n));
472
+ }), U(this, "interceptLinks", (t) => {
473
+ const e = t.target.closest("a");
474
+ if (!e) return;
475
+ const n = e.getAttribute("href");
476
+ !n || n.startsWith("http") || n.startsWith("#") || (t.preventDefault(), this.navigate(n));
611
477
  });
612
478
  }
613
479
  render() {
614
- return /* @__PURE__ */ te("div", { class: "router-outlet" });
480
+ return /* @__PURE__ */ tt("div", { class: "router-outlet" });
615
481
  }
616
482
  onRendered() {
617
- var e;
618
- (e = super.onRendered) == null || e.call(this), this.views.size === 0 && (this.collectViews(), E.debug("WsxRouter collected views in onRendered:", this.views.size)), this.views.size > 0 && !this.currentView && requestAnimationFrame(() => {
483
+ var t;
484
+ (t = super.onRendered) == null || t.call(this), this.views.size === 0 && (this.collectViews(), R.debug("WsxRouter collected views in onRendered:", this.views.size)), this.views.size > 0 && !this.currentView && requestAnimationFrame(() => {
619
485
  this.handleRouteChange();
620
486
  });
621
487
  }
622
488
  onConnected() {
623
- var e;
624
- (e = super.onConnected) == null || e.call(this), E.debug("WsxRouter connected to DOM"), "scrollRestoration" in history && (history.scrollRestoration = this.scrollRestoration), window.addEventListener("popstate", this.handleRouteChange), this.addEventListener("click", this.interceptLinks), requestAnimationFrame(() => {
625
- this.views.size === 0 && (this.collectViews(), E.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)), requestAnimationFrame(() => {
626
- E.debug(`WsxRouter handling initial route: ${window.location.pathname}`), this.handleRouteChange();
489
+ var t;
490
+ (t = super.onConnected) == null || t.call(this), R.debug("WsxRouter connected to DOM"), "scrollRestoration" in history && (history.scrollRestoration = this.scrollRestoration), window.addEventListener("popstate", this.handleRouteChange), this.addEventListener("click", this.interceptLinks), requestAnimationFrame(() => {
491
+ this.views.size === 0 && (this.collectViews(), R.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)), requestAnimationFrame(() => {
492
+ R.debug(`WsxRouter handling initial route: ${window.location.pathname}`), this.handleRouteChange();
627
493
  });
628
494
  });
629
495
  }
630
496
  onDisconnected() {
631
- var e;
632
- (e = super.onDisconnected) == null || e.call(this), window.removeEventListener("popstate", this.handleRouteChange);
497
+ var t;
498
+ (t = super.onDisconnected) == null || t.call(this), window.removeEventListener("popstate", this.handleRouteChange);
633
499
  }
634
500
  collectViews() {
635
- const e = Array.from(this.children).filter((t) => t.tagName.toLowerCase() === "wsx-view");
636
- E.debug(`WsxRouter found ${e.length} views`), this.views.clear(), this.compiledRoutes.clear(), this.matchCache.clear(), e.forEach((t) => {
637
- const n = t.getAttribute("route") || "/";
638
- if (this.views.set(n, t), E.debug(`WsxRouter registered route: ${n}`), n.includes(":")) {
639
- const g = n.replace(/:[^/]+/g, "([^/]+)"), p = new RegExp(`^${g}$`);
640
- this.compiledRoutes.set(n, p), E.debug(`WsxRouter compiled regex for route: ${n} -> ${p}`);
501
+ const t = Array.from(this.children).filter((e) => e.tagName.toLowerCase() === "wsx-view");
502
+ R.debug(`WsxRouter found ${t.length} views`), this.views.clear(), this.compiledRoutes.clear(), this.matchCache.clear(), t.forEach((e) => {
503
+ const n = e.getAttribute("route") || "/";
504
+ if (this.views.set(n, e), R.debug(`WsxRouter registered route: ${n}`), n.includes(":")) {
505
+ const f = n.replace(/:[^/]+/g, "([^/]+)"), v = new RegExp(`^${f}$`);
506
+ this.compiledRoutes.set(n, v), R.debug(`WsxRouter compiled regex for route: ${n} -> ${v}`);
641
507
  }
642
- t.style.display = "none";
508
+ e.style.display = "none";
643
509
  });
644
510
  }
645
511
  /**
646
512
  * RFC 0033: 执行导航(带 View Transitions 支持)
647
513
  */
648
- performNavigation(e) {
649
- const t = () => {
650
- const n = this.matchRoute(e);
514
+ performNavigation(t) {
515
+ const e = () => {
516
+ const n = this.matchRoute(t);
651
517
  if (n) {
652
518
  n.style.display = "block", n.style.visibility = "visible";
653
- const g = n.getAttribute("route") || "/";
654
- E.debug(`Showing view for route: ${g}`);
655
- for (const [O, V] of this.views)
656
- V !== n && (V.style.display = "none", V.style.visibility = "");
519
+ const f = n.getAttribute("route") || "/";
520
+ R.debug(`Showing view for route: ${f}`);
521
+ for (const [z, q] of this.views)
522
+ q !== n && (q.style.display = "none", q.style.visibility = "");
657
523
  this.currentView = n;
658
- const p = this.extractParams(g, e);
659
- E.debug(`Extracted params for route ${g} and path ${e}:`, p), p && requestAnimationFrame(() => {
660
- n.setAttribute("params", JSON.stringify(p)), E.debug(`Set params attribute on view: ${JSON.stringify(p)}`);
524
+ const v = this.extractParams(f, t);
525
+ R.debug(`Extracted params for route ${f} and path ${t}:`, v), v && requestAnimationFrame(() => {
526
+ n.setAttribute("params", JSON.stringify(v)), R.debug(`Set params attribute on view: ${JSON.stringify(v)}`);
661
527
  });
662
- const f = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, _ = new URL(f, window.location.origin || "http://localhost"), y = {
663
- path: e,
664
- params: p || {},
665
- query: Object.fromEntries(_.searchParams.entries()),
666
- hash: _.hash.slice(1)
528
+ const y = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, k = new URL(y, window.location.origin || "http://localhost"), b = {
529
+ path: t,
530
+ params: v || {},
531
+ query: Object.fromEntries(k.searchParams.entries()),
532
+ hash: k.hash.slice(1)
667
533
  };
668
- ne._setCurrentRoute(y), E.debug("Updated RouterUtils._currentRoute:", y);
669
- const T = new CustomEvent("route-changed", {
670
- detail: y,
534
+ et._setCurrentRoute(b), R.debug("Updated RouterUtils._currentRoute:", b);
535
+ const j = new CustomEvent("route-changed", {
536
+ detail: b,
671
537
  bubbles: !0
672
538
  });
673
- document.dispatchEvent(T);
539
+ document.dispatchEvent(j);
674
540
  } else {
675
- for (const [y, T] of this.views)
676
- T.style.display = "none";
677
- this.currentView = null, E.warn(`No view found for path: ${e}`);
678
- const g = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, p = new URL(g, window.location.origin || "http://localhost"), f = {
679
- path: e,
541
+ for (const [b, j] of this.views)
542
+ j.style.display = "none";
543
+ this.currentView = null, R.warn(`No view found for path: ${t}`);
544
+ const f = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, v = new URL(f, window.location.origin || "http://localhost"), y = {
545
+ path: t,
680
546
  params: {},
681
- query: Object.fromEntries(p.searchParams.entries()),
682
- hash: p.hash.slice(1)
547
+ query: Object.fromEntries(v.searchParams.entries()),
548
+ hash: v.hash.slice(1)
683
549
  };
684
- ne._setCurrentRoute(f);
685
- const _ = new CustomEvent("route-changed", {
686
- detail: f,
550
+ et._setCurrentRoute(y);
551
+ const k = new CustomEvent("route-changed", {
552
+ detail: y,
687
553
  bubbles: !0
688
554
  });
689
- document.dispatchEvent(_);
555
+ document.dispatchEvent(k);
690
556
  }
691
- this.handleScrollRestoration(e), this.dispatchEvent(new CustomEvent("after-navigate", {
557
+ this.handleScrollRestoration(t), this.dispatchEvent(new CustomEvent("after-navigate", {
692
558
  detail: {
693
- to: e,
559
+ to: t,
694
560
  from: this.currentPath
695
561
  },
696
562
  bubbles: !0
697
- })), this.currentPath = e;
563
+ })), this.currentPath = t;
698
564
  };
699
- this.enableViewTransitions && "startViewTransition" in document ? document.startViewTransition(t) : t();
565
+ this.enableViewTransitions && "startViewTransition" in document ? document.startViewTransition(e) : e();
700
566
  }
701
567
  /**
702
568
  * RFC 0033: 滚动恢复处理
703
569
  */
704
- handleScrollRestoration(e) {
705
- this.scrollRestoration === "manual" && (this.isBackNavigation() || (window.scrollTo(0, 0), E.debug("Scrolled to top for forward navigation")));
570
+ handleScrollRestoration(t) {
571
+ this.scrollRestoration === "manual" && (this.isBackNavigation() || (window.scrollTo(0, 0), R.debug("Scrolled to top for forward navigation")));
706
572
  }
707
573
  /**
708
574
  * RFC 0033: 检测是否是后退导航
709
575
  */
710
576
  isBackNavigation() {
711
- var e;
712
- return "navigation" in performance && performance.navigation ? performance.navigation.type === 2 : ((e = window.history.state) == null ? void 0 : e.navigationType) === "back";
577
+ var t;
578
+ return "navigation" in performance && performance.navigation ? performance.navigation.type === 2 : ((t = window.history.state) == null ? void 0 : t.navigationType) === "back";
713
579
  }
714
- matchRoute(e) {
715
- if (E.warn(`matchRoute called for path: ${e}, views count: ${this.views.size}`), this.matchCache.has(e)) {
716
- const n = this.matchCache.get(e);
717
- return E.warn(`matchRoute: found in cache, route: ${n}`), this.views.get(n) || null;
580
+ matchRoute(t) {
581
+ if (R.warn(`matchRoute called for path: ${t}, views count: ${this.views.size}`), this.matchCache.has(t)) {
582
+ const n = this.matchCache.get(t);
583
+ return R.warn(`matchRoute: found in cache, route: ${n}`), this.views.get(n) || null;
718
584
  }
719
- if (this.views.has(e))
720
- return this.matchCache.set(e, e), E.warn(`matchRoute: exact match found for ${e}`), this.views.get(e);
721
- for (const [n, g] of this.views)
585
+ if (this.views.has(t))
586
+ return this.matchCache.set(t, t), R.warn(`matchRoute: exact match found for ${t}`), this.views.get(t);
587
+ for (const [n, f] of this.views)
722
588
  if (n.endsWith("/*")) {
723
- const p = n.slice(0, -2);
724
- if (e.startsWith(p))
725
- return this.matchCache.set(e, n), E.warn(`matchRoute: prefix match found, route: ${n}, path: ${e}`), g;
589
+ const v = n.slice(0, -2);
590
+ if (t.startsWith(v))
591
+ return this.matchCache.set(t, n), R.warn(`matchRoute: prefix match found, route: ${n}, path: ${t}`), f;
726
592
  }
727
- E.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);
728
- for (const [n, g] of this.views)
593
+ R.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);
594
+ for (const [n, f] of this.views)
729
595
  if (n.includes(":")) {
730
- const p = this.compiledRoutes.get(n);
731
- if (p) {
732
- const f = p.test(e);
733
- if (E.warn(`matchRoute: testing route ${n} against ${e}, matches: ${f}`), f)
734
- return this.matchCache.set(e, n), E.warn(`matchRoute: parameter match found, route: ${n}, path: ${e}`), g;
596
+ const v = this.compiledRoutes.get(n);
597
+ if (v) {
598
+ const y = v.test(t);
599
+ if (R.warn(`matchRoute: testing route ${n} against ${t}, matches: ${y}`), y)
600
+ return this.matchCache.set(t, n), R.warn(`matchRoute: parameter match found, route: ${n}, path: ${t}`), f;
735
601
  } else
736
- E.warn(`matchRoute: route ${n} has ':' but no compiled regex found`);
602
+ R.warn(`matchRoute: route ${n} has ':' but no compiled regex found`);
737
603
  }
738
- const t = this.views.get("*") || null;
739
- return t ? (this.matchCache.set(e, "*"), E.warn(`matchRoute: wildcard match found for ${e}`)) : E.warn(`matchRoute: no match found for ${e}, no wildcard view available`), t;
740
- }
741
- extractParams(e, t) {
742
- var y;
743
- if (!e.includes(":")) return null;
744
- const n = ((y = e.match(/:([^/]+)/g)) == null ? void 0 : y.map((T) => T.slice(1))) || [], g = e.replace(/:[^/]+/g, "([^/]+)"), p = new RegExp(`^${g}$`), f = t.match(p);
745
- if (!f || !n.length) return null;
746
- const _ = {};
747
- return n.forEach((T, O) => {
748
- _[T] = f[O + 1];
749
- }), _;
604
+ const e = this.views.get("*") || null;
605
+ return e ? (this.matchCache.set(t, "*"), R.warn(`matchRoute: wildcard match found for ${t}`)) : R.warn(`matchRoute: no match found for ${t}, no wildcard view available`), e;
606
+ }
607
+ extractParams(t, e) {
608
+ var b;
609
+ if (!t.includes(":")) return null;
610
+ const n = ((b = t.match(/:([^/]+)/g)) == null ? void 0 : b.map((j) => j.slice(1))) || [], f = t.replace(/:[^/]+/g, "([^/]+)"), v = new RegExp(`^${f}$`), y = e.match(v);
611
+ if (!y || !n.length) return null;
612
+ const k = {};
613
+ return n.forEach((j, z) => {
614
+ k[j] = y[z + 1];
615
+ }), k;
750
616
  }
751
617
  /**
752
618
  * RFC 0032: 清除匹配缓存
753
619
  * 当路由配置变更时调用,确保使用最新的路由规则
754
620
  */
755
621
  clearMatchCache() {
756
- this.matchCache.clear(), E.debug("WsxRouter cleared match cache");
622
+ this.matchCache.clear(), R.debug("WsxRouter cleared match cache");
757
623
  }
758
624
  /**
759
625
  * RFC 0033: 配置 View Transitions
760
626
  */
761
- setViewTransitions(e) {
762
- this.enableViewTransitions = e, E.debug(`View Transitions ${e ? "enabled" : "disabled"}`);
627
+ setViewTransitions(t) {
628
+ this.enableViewTransitions = t, R.debug(`View Transitions ${t ? "enabled" : "disabled"}`);
763
629
  }
764
630
  /**
765
631
  * RFC 0033: 配置 Scroll Restoration
766
632
  */
767
- setScrollRestoration(e) {
768
- this.scrollRestoration = e, "scrollRestoration" in history && (history.scrollRestoration = e), E.debug(`Scroll Restoration set to ${e}`);
633
+ setScrollRestoration(t) {
634
+ this.scrollRestoration = t, "scrollRestoration" in history && (history.scrollRestoration = t), R.debug(`Scroll Restoration set to ${t}`);
769
635
  }
770
636
  /**
771
637
  * 编程式导航 - 使用原生 History API
772
638
  */
773
- navigate(e) {
774
- window.history.pushState(null, "", e), this.handleRouteChange();
639
+ navigate(t) {
640
+ window.history.pushState(null, "", t), this.handleRouteChange();
775
641
  }
776
642
  }
777
- Re = Ne;
778
- [ze, Le] = Pe(Re, [], xe, 0, void 0, re).c;
779
- Le();
780
- const Fe = ":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";
781
- var Ce;
782
- let $e, _e;
783
- function Z(r, e, t) {
784
- return (e = Ie(e)) in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
643
+ yt = Vt;
644
+ [It, Rt] = At(yt, [], xt, 0, void 0, nt).c;
645
+ Rt();
646
+ const Dt = ":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";
647
+ var Ct;
648
+ let Et, Lt;
649
+ function Z(r, t, e) {
650
+ return (t = _t(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
785
651
  }
786
- function qe(r, e, t, n, g, p) {
787
- function f(s, o, c) {
788
- return function(i, u) {
789
- return c && c(i), s[o].call(i, u);
652
+ function Pt(r, t, e, n, f, v) {
653
+ function y(i, c, u) {
654
+ return function(s, a) {
655
+ return u && u(s), i[c].call(s, a);
790
656
  };
791
657
  }
792
- function _(s, o) {
793
- for (var c = 0; c < s.length; c++) s[c].call(o);
794
- return o;
658
+ function k(i, c) {
659
+ for (var u = 0; u < i.length; u++) i[u].call(c);
660
+ return c;
795
661
  }
796
- function y(s, o, c, i) {
797
- if (typeof s != "function" && (i || s !== void 0)) throw new TypeError(o + " must " + (c || "be") + " a function" + (i ? "" : " or undefined"));
798
- return s;
662
+ function b(i, c, u, s) {
663
+ if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
664
+ return i;
799
665
  }
800
- function T(s, o, c, i, u, A, k, L, P, C, R, v, m) {
801
- function h(d) {
802
- if (!m(d)) throw new TypeError("Attempted to access private element on non-instance");
666
+ function j(i, c, u, s, a, A, O, S, D, x, w, g, m) {
667
+ function $(l) {
668
+ if (!m(l)) throw new TypeError("Attempted to access private element on non-instance");
803
669
  }
804
- var l, x = o[0], $ = o[3], W = !L;
670
+ var h, C = c[0], E = c[3], W = !S;
805
671
  if (!W) {
806
- c || Array.isArray(x) || (x = [x]);
807
- var a = {}, I = [], b = u === 3 ? "get" : u === 4 || v ? "set" : "value";
808
- C ? (R || v ? a = { get: fe(function() {
809
- return $(this);
810
- }, i, "get"), set: function(d) {
811
- o[4](this, d);
812
- } } : a[b] = $, R || fe(a[b], i, u === 2 ? "" : b)) : R || (a = Object.getOwnPropertyDescriptor(s, i));
672
+ u || Array.isArray(C) || (C = [C]);
673
+ var o = {}, L = [], p = a === 3 ? "get" : a === 4 || g ? "set" : "value";
674
+ x ? (w || g ? o = { get: ft(function() {
675
+ return E(this);
676
+ }, s, "get"), set: function(l) {
677
+ c[4](this, l);
678
+ } } : o[p] = E, w || ft(o[p], s, a === 2 ? "" : p)) : w || (o = Object.getOwnPropertyDescriptor(i, s));
813
679
  }
814
- for (var w = s, U = x.length - 1; U >= 0; U -= c ? 2 : 1) {
815
- var B = x[U], G = c ? x[U - 1] : void 0, K = {}, j = { kind: ["field", "accessor", "method", "getter", "setter", "class"][u], name: i, metadata: A, addInitializer: (function(d, S) {
816
- if (d.v) throw Error("attempted to call addInitializer after decoration was finished");
817
- y(S, "An initializer", "be", !0), k.push(S);
680
+ for (var d = i, P = C.length - 1; P >= 0; P -= u ? 2 : 1) {
681
+ var B = C[P], F = u ? C[P - 1] : void 0, K = {}, T = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: A, addInitializer: (function(l, _) {
682
+ if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
683
+ b(_, "An initializer", "be", !0), O.push(_);
818
684
  }).bind(null, K) };
819
685
  try {
820
- if (W) (l = y(B.call(G, w, j), "class decorators", "return")) && (w = l);
686
+ if (W) (h = b(B.call(F, d, T), "class decorators", "return")) && (d = h);
821
687
  else {
822
- var D, z;
823
- j.static = P, j.private = C, C ? u === 2 ? D = function(d) {
824
- return h(d), a.value;
825
- } : (u < 4 && (D = f(a, "get", h)), u !== 3 && (z = f(a, "set", h))) : (D = function(d) {
826
- return d[i];
827
- }, (u < 2 || u === 4) && (z = function(d, S) {
828
- d[i] = S;
688
+ var I, M;
689
+ T.static = D, T.private = x, x ? a === 2 ? I = function(l) {
690
+ return $(l), o.value;
691
+ } : (a < 4 && (I = y(o, "get", $)), a !== 3 && (M = y(o, "set", $))) : (I = function(l) {
692
+ return l[s];
693
+ }, (a < 2 || a === 4) && (M = function(l, _) {
694
+ l[s] = _;
829
695
  }));
830
- var J = j.access = { has: C ? m.bind() : function(d) {
831
- return i in d;
696
+ var Q = T.access = { has: x ? m.bind() : function(l) {
697
+ return s in l;
832
698
  } };
833
- if (D && (J.get = D), z && (J.set = z), w = B.call(G, v ? { get: a.get, set: a.set } : a[b], j), v) {
834
- if (typeof w == "object" && w) (l = y(w.get, "accessor.get")) && (a.get = l), (l = y(w.set, "accessor.set")) && (a.set = l), (l = y(w.init, "accessor.init")) && I.push(l);
835
- else if (w !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
836
- } else y(w, (R ? "field" : "method") + " decorators", "return") && (R ? I.push(w) : a[b] = w);
699
+ if (I && (Q.get = I), M && (Q.set = M), d = B.call(F, g ? { get: o.get, set: o.set } : o[p], T), g) {
700
+ if (typeof d == "object" && d) (h = b(d.get, "accessor.get")) && (o.get = h), (h = b(d.set, "accessor.set")) && (o.set = h), (h = b(d.init, "accessor.init")) && L.push(h);
701
+ else if (d !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
702
+ } else b(d, (w ? "field" : "method") + " decorators", "return") && (w ? L.push(d) : o[p] = d);
837
703
  }
838
704
  } finally {
839
705
  K.v = !0;
840
706
  }
841
707
  }
842
- return (R || v) && L.push(function(d, S) {
843
- for (var N = I.length - 1; N >= 0; N--) S = I[N].call(d, S);
844
- return S;
845
- }), R || W || (C ? v ? L.push(f(a, "get"), f(a, "set")) : L.push(u === 2 ? a[b] : f.call.bind(a[b])) : Object.defineProperty(s, i, a)), w;
846
- }
847
- function O(s, o) {
848
- return Object.defineProperty(s, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: o });
849
- }
850
- if (arguments.length >= 6) var V = p[Symbol.metadata || Symbol.for("Symbol.metadata")];
851
- var M = Object.create(V ?? null), H = function(s, o, c, i) {
852
- var u, A, k = [], L = function(b) {
853
- return Be(b) === s;
854
- }, P = /* @__PURE__ */ new Map();
855
- function C(b) {
856
- b && k.push(_.bind(null, b));
708
+ return (w || g) && S.push(function(l, _) {
709
+ for (var N = L.length - 1; N >= 0; N--) _ = L[N].call(l, _);
710
+ return _;
711
+ }), w || W || (x ? g ? S.push(y(o, "get"), y(o, "set")) : S.push(a === 2 ? o[p] : y.call.bind(o[p])) : Object.defineProperty(i, s, o)), d;
712
+ }
713
+ function z(i, c) {
714
+ return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
715
+ }
716
+ if (arguments.length >= 6) var q = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
717
+ var V = Object.create(q ?? null), Y = function(i, c, u, s) {
718
+ var a, A, O = [], S = function(p) {
719
+ return zt(p) === i;
720
+ }, D = /* @__PURE__ */ new Map();
721
+ function x(p) {
722
+ p && O.push(k.bind(null, p));
857
723
  }
858
- for (var R = 0; R < o.length; R++) {
859
- var v = o[R];
860
- if (Array.isArray(v)) {
861
- var m = v[1], h = v[2], l = v.length > 3, x = 16 & m, $ = !!(8 & m), W = (m &= 7) == 0, a = h + "/" + $;
862
- if (!W && !l) {
863
- var I = P.get(a);
864
- if (I === !0 || I === 3 && m !== 4 || I === 4 && m !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
865
- P.set(a, !(m > 2) || m);
724
+ for (var w = 0; w < c.length; w++) {
725
+ var g = c[w];
726
+ if (Array.isArray(g)) {
727
+ var m = g[1], $ = g[2], h = g.length > 3, C = 16 & m, E = !!(8 & m), W = (m &= 7) == 0, o = $ + "/" + E;
728
+ if (!W && !h) {
729
+ var L = D.get(o);
730
+ if (L === !0 || L === 3 && m !== 4 || L === 4 && m !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + $);
731
+ D.set(o, !(m > 2) || m);
866
732
  }
867
- T($ ? s : s.prototype, v, x, l ? "#" + h : Ie(h), m, i, $ ? A = A || [] : u = u || [], k, $, l, W, m === 1, $ && l ? L : c);
733
+ j(E ? i : i.prototype, g, C, h ? "#" + $ : _t($), m, s, E ? A = A || [] : a = a || [], O, E, h, W, m === 1, E && h ? S : u);
868
734
  }
869
735
  }
870
- return C(u), C(A), k;
871
- }(r, e, g, M);
872
- return t.length || O(r, M), { e: H, get c() {
873
- var s = [];
874
- return t.length && [O(T(r, [t], n, r.name, 5, M, s), M), _.bind(null, s, r)];
736
+ return x(a), x(A), O;
737
+ }(r, t, f, V);
738
+ return e.length || z(r, V), { e: Y, get c() {
739
+ var i = [];
740
+ return e.length && [z(j(r, [e], n, r.name, 5, V, i), V), k.bind(null, i, r)];
875
741
  } };
876
742
  }
877
- function Ie(r) {
878
- var e = He(r, "string");
879
- return typeof e == "symbol" ? e : e + "";
743
+ function _t(r) {
744
+ var t = Mt(r, "string");
745
+ return typeof t == "symbol" ? t : t + "";
880
746
  }
881
- function He(r, e) {
747
+ function Mt(r, t) {
882
748
  if (typeof r != "object" || !r) return r;
883
- var t = r[Symbol.toPrimitive];
884
- if (t !== void 0) {
885
- var n = t.call(r, e);
749
+ var e = r[Symbol.toPrimitive];
750
+ if (e !== void 0) {
751
+ var n = e.call(r, t);
886
752
  if (typeof n != "object") return n;
887
753
  throw new TypeError("@@toPrimitive must return a primitive value.");
888
754
  }
889
755
  return String(r);
890
756
  }
891
- function fe(r, e, t) {
892
- typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
757
+ function ft(r, t, e) {
758
+ typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
893
759
  try {
894
- Object.defineProperty(r, "name", { configurable: !0, value: t ? t + " " + e : e });
760
+ Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
895
761
  } catch {
896
762
  }
897
763
  return r;
898
764
  }
899
- function Be(r) {
765
+ function zt(r) {
900
766
  if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
901
767
  return r;
902
768
  }
903
- const q = ie("WsxView");
904
- _e = [ce({
769
+ const H = rt("WsxView");
770
+ Lt = [ct({
905
771
  tagName: "wsx-view"
906
772
  })];
907
- let Ge;
908
- class Ke extends re {
773
+ let qt;
774
+ class Nt extends nt {
909
775
  constructor() {
910
- super(), Z(this, "_autoStyles", Fe), Z(this, "_component", ""), Z(this, "params", void 0), Z(this, "componentInstance", null), Z(this, "isLoading", !1);
911
- let e = this.reactive({});
776
+ super(), Z(this, "_autoStyles", Dt), Z(this, "_component", ""), Z(this, "params", void 0), Z(this, "componentInstance", null), Z(this, "isLoading", !1);
777
+ let t = this.reactive({});
912
778
  Object.defineProperty(this, "params", {
913
- get: () => e,
914
- set: (t) => {
915
- e = t !== null && typeof t < "u" && (Array.isArray(t) || typeof t == "object") ? this.reactive(t) : t, this.scheduleRerender();
779
+ get: () => t,
780
+ set: (e) => {
781
+ t = e !== null && typeof e < "u" && (Array.isArray(e) || typeof e == "object") ? this.reactive(e) : e, this.scheduleRerender();
916
782
  },
917
783
  enumerable: !0,
918
784
  configurable: !0
@@ -921,218 +787,218 @@ class Ke extends re {
921
787
  get component() {
922
788
  return this._component;
923
789
  }
924
- set component(e) {
925
- this._component = e || "", this._component && requestAnimationFrame(() => {
790
+ set component(t) {
791
+ this._component = t || "", this._component && requestAnimationFrame(() => {
926
792
  this.connected && !this.componentInstance && !this.isLoading && this.loadComponent(this._component || "");
927
793
  });
928
794
  }
929
795
  // 防止重复加载的标志
930
796
  render() {
931
- return /* @__PURE__ */ te("div", { class: "route-view" });
797
+ return /* @__PURE__ */ tt("div", { class: "route-view" });
932
798
  }
933
799
  onConnected() {
934
- var e;
935
- (e = super.onConnected) == null || e.call(this), requestAnimationFrame(() => {
800
+ var t;
801
+ (t = super.onConnected) == null || t.call(this), requestAnimationFrame(() => {
936
802
  !this.connected || this.isLoading || this.componentInstance || this.component && this.loadComponent(this.component);
937
803
  });
938
804
  }
939
- async loadComponent(e) {
805
+ async loadComponent(t) {
940
806
  if (!(!this.connected || this.isLoading || this.componentInstance)) {
941
807
  this.isLoading = !0;
942
808
  try {
943
- const t = this.componentInstance;
944
- if (t && (t.remove(), this.componentInstance = null), !customElements.get(e)) {
945
- q.warn(`Component ${e} not found in customElements registry`), this.isLoading = !1;
809
+ const e = this.componentInstance;
810
+ if (e && (e.remove(), this.componentInstance = null), !customElements.get(t)) {
811
+ H.warn(`Component ${t} not found in customElements registry`), this.isLoading = !1;
946
812
  return;
947
813
  }
948
- q.warn(`WsxView: Creating instance of ${e}`), this.componentInstance = document.createElement(e), Object.keys(this.params).length > 0 && (q.warn(`WsxView: Setting initial params on ${e}:`, this.params), Object.entries(this.params).forEach(([p, f]) => {
949
- this.componentInstance.setAttribute(p, f);
814
+ H.warn(`WsxView: Creating instance of ${t}`), this.componentInstance = document.createElement(t), Object.keys(this.params).length > 0 && (H.warn(`WsxView: Setting initial params on ${t}:`, this.params), Object.entries(this.params).forEach(([v, y]) => {
815
+ this.componentInstance.setAttribute(v, y);
950
816
  }));
951
- const g = this.querySelector(".route-view");
952
- if (g) {
953
- if (q.warn(`WsxView: Appending ${e} to container`), !customElements.get(e)) {
954
- q.error(`WsxView: Component ${e} is not registered in customElements registry!`), this.isLoading = !1, this.componentInstance = null;
817
+ const f = this.querySelector(".route-view");
818
+ if (f) {
819
+ if (H.warn(`WsxView: Appending ${t} to container`), !customElements.get(t)) {
820
+ H.error(`WsxView: Component ${t} is not registered in customElements registry!`), this.isLoading = !1, this.componentInstance = null;
955
821
  return;
956
822
  }
957
- g.appendChild(this.componentInstance), q.warn(`WsxView: Component ${e} appended successfully, waiting for connectedCallback...`), setTimeout(() => {
958
- this.componentInstance && this.componentInstance.isConnected ? q.warn(`WsxView: Component ${e} is now connected to DOM`) : q.error(`WsxView: Component ${e} was not connected to DOM!`);
823
+ f.appendChild(this.componentInstance), H.warn(`WsxView: Component ${t} appended successfully, waiting for connectedCallback...`), setTimeout(() => {
824
+ this.componentInstance && this.componentInstance.isConnected ? H.warn(`WsxView: Component ${t} is now connected to DOM`) : H.error(`WsxView: Component ${t} was not connected to DOM!`);
959
825
  }, 0);
960
826
  } else
961
- q.error("WsxView: Route view container not found"), this.componentInstance = null;
962
- } catch (t) {
963
- q.warn(`Error loading component ${e}:`, t), this.componentInstance = null;
827
+ H.error("WsxView: Route view container not found"), this.componentInstance = null;
828
+ } catch (e) {
829
+ H.warn(`Error loading component ${t}:`, e), this.componentInstance = null;
964
830
  } finally {
965
- this.isLoading = !1, q.warn(`WsxView: loadComponent for ${e} completed, isLoading=${this.isLoading}`);
831
+ this.isLoading = !1, H.warn(`WsxView: loadComponent for ${t} completed, isLoading=${this.isLoading}`);
966
832
  }
967
833
  }
968
834
  }
969
835
  onDisconnected() {
970
- var e;
971
- (e = super.onDisconnected) == null || e.call(this), this.componentInstance && (this.componentInstance.remove(), this.componentInstance = null);
836
+ var t;
837
+ (t = super.onDisconnected) == null || t.call(this), this.componentInstance && (this.componentInstance.remove(), this.componentInstance = null);
972
838
  }
973
839
  }
974
- Ce = Ke;
975
- [Ge, $e] = qe(Ce, [], _e, 0, void 0, re).c;
976
- $e();
977
- const Je = ':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, var(--focus-color, #dc2626));outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';
978
- var oe, se;
979
- let de, Se, ge;
980
- function Q(r, e, t) {
981
- return (e = ke(e)) in r ? Object.defineProperty(r, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : r[e] = t, r;
840
+ Ct = Nt;
841
+ [qt, Et] = Pt(Ct, [], Lt, 0, void 0, nt).c;
842
+ Et();
843
+ const Ut = ':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, var(--focus-color, #dc2626));outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';
844
+ var ot, st;
845
+ let gt, kt, mt;
846
+ function X(r, t, e) {
847
+ return (t = St(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
982
848
  }
983
- function Qe(r, e, t, n, g, p) {
984
- function f(s, o, c) {
985
- return function(i, u) {
986
- return c && c(i), s[o].call(i, u);
849
+ function Ht(r, t, e, n, f, v) {
850
+ function y(i, c, u) {
851
+ return function(s, a) {
852
+ return u && u(s), i[c].call(s, a);
987
853
  };
988
854
  }
989
- function _(s, o) {
990
- for (var c = 0; c < s.length; c++) s[c].call(o);
991
- return o;
855
+ function k(i, c) {
856
+ for (var u = 0; u < i.length; u++) i[u].call(c);
857
+ return c;
992
858
  }
993
- function y(s, o, c, i) {
994
- if (typeof s != "function" && (i || s !== void 0)) throw new TypeError(o + " must " + (c || "be") + " a function" + (i ? "" : " or undefined"));
995
- return s;
859
+ function b(i, c, u, s) {
860
+ if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
861
+ return i;
996
862
  }
997
- function T(s, o, c, i, u, A, k, L, P, C, R, v, m) {
998
- function h(d) {
999
- if (!m(d)) throw new TypeError("Attempted to access private element on non-instance");
863
+ function j(i, c, u, s, a, A, O, S, D, x, w, g, m) {
864
+ function $(l) {
865
+ if (!m(l)) throw new TypeError("Attempted to access private element on non-instance");
1000
866
  }
1001
- var l, x = o[0], $ = o[3], W = !L;
867
+ var h, C = c[0], E = c[3], W = !S;
1002
868
  if (!W) {
1003
- c || Array.isArray(x) || (x = [x]);
1004
- var a = {}, I = [], b = u === 3 ? "get" : u === 4 || v ? "set" : "value";
1005
- C ? (R || v ? a = { get: pe(function() {
1006
- return $(this);
1007
- }, i, "get"), set: function(d) {
1008
- o[4](this, d);
1009
- } } : a[b] = $, R || pe(a[b], i, u === 2 ? "" : b)) : R || (a = Object.getOwnPropertyDescriptor(s, i));
869
+ u || Array.isArray(C) || (C = [C]);
870
+ var o = {}, L = [], p = a === 3 ? "get" : a === 4 || g ? "set" : "value";
871
+ x ? (w || g ? o = { get: pt(function() {
872
+ return E(this);
873
+ }, s, "get"), set: function(l) {
874
+ c[4](this, l);
875
+ } } : o[p] = E, w || pt(o[p], s, a === 2 ? "" : p)) : w || (o = Object.getOwnPropertyDescriptor(i, s));
1010
876
  }
1011
- for (var w = s, U = x.length - 1; U >= 0; U -= c ? 2 : 1) {
1012
- var B = x[U], G = c ? x[U - 1] : void 0, K = {}, j = { kind: ["field", "accessor", "method", "getter", "setter", "class"][u], name: i, metadata: A, addInitializer: (function(d, S) {
1013
- if (d.v) throw Error("attempted to call addInitializer after decoration was finished");
1014
- y(S, "An initializer", "be", !0), k.push(S);
877
+ for (var d = i, P = C.length - 1; P >= 0; P -= u ? 2 : 1) {
878
+ var B = C[P], F = u ? C[P - 1] : void 0, K = {}, T = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: A, addInitializer: (function(l, _) {
879
+ if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
880
+ b(_, "An initializer", "be", !0), O.push(_);
1015
881
  }).bind(null, K) };
1016
882
  try {
1017
- if (W) (l = y(B.call(G, w, j), "class decorators", "return")) && (w = l);
883
+ if (W) (h = b(B.call(F, d, T), "class decorators", "return")) && (d = h);
1018
884
  else {
1019
- var D, z;
1020
- j.static = P, j.private = C, C ? u === 2 ? D = function(d) {
1021
- return h(d), a.value;
1022
- } : (u < 4 && (D = f(a, "get", h)), u !== 3 && (z = f(a, "set", h))) : (D = function(d) {
1023
- return d[i];
1024
- }, (u < 2 || u === 4) && (z = function(d, S) {
1025
- d[i] = S;
885
+ var I, M;
886
+ T.static = D, T.private = x, x ? a === 2 ? I = function(l) {
887
+ return $(l), o.value;
888
+ } : (a < 4 && (I = y(o, "get", $)), a !== 3 && (M = y(o, "set", $))) : (I = function(l) {
889
+ return l[s];
890
+ }, (a < 2 || a === 4) && (M = function(l, _) {
891
+ l[s] = _;
1026
892
  }));
1027
- var J = j.access = { has: C ? m.bind() : function(d) {
1028
- return i in d;
893
+ var Q = T.access = { has: x ? m.bind() : function(l) {
894
+ return s in l;
1029
895
  } };
1030
- if (D && (J.get = D), z && (J.set = z), w = B.call(G, v ? { get: a.get, set: a.set } : a[b], j), v) {
1031
- if (typeof w == "object" && w) (l = y(w.get, "accessor.get")) && (a.get = l), (l = y(w.set, "accessor.set")) && (a.set = l), (l = y(w.init, "accessor.init")) && I.push(l);
1032
- else if (w !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1033
- } else y(w, (R ? "field" : "method") + " decorators", "return") && (R ? I.push(w) : a[b] = w);
896
+ if (I && (Q.get = I), M && (Q.set = M), d = B.call(F, g ? { get: o.get, set: o.set } : o[p], T), g) {
897
+ if (typeof d == "object" && d) (h = b(d.get, "accessor.get")) && (o.get = h), (h = b(d.set, "accessor.set")) && (o.set = h), (h = b(d.init, "accessor.init")) && L.push(h);
898
+ else if (d !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
899
+ } else b(d, (w ? "field" : "method") + " decorators", "return") && (w ? L.push(d) : o[p] = d);
1034
900
  }
1035
901
  } finally {
1036
902
  K.v = !0;
1037
903
  }
1038
904
  }
1039
- return (R || v) && L.push(function(d, S) {
1040
- for (var N = I.length - 1; N >= 0; N--) S = I[N].call(d, S);
1041
- return S;
1042
- }), R || W || (C ? v ? L.push(f(a, "get"), f(a, "set")) : L.push(u === 2 ? a[b] : f.call.bind(a[b])) : Object.defineProperty(s, i, a)), w;
1043
- }
1044
- function O(s, o) {
1045
- return Object.defineProperty(s, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: o });
1046
- }
1047
- if (arguments.length >= 6) var V = p[Symbol.metadata || Symbol.for("Symbol.metadata")];
1048
- var M = Object.create(V ?? null), H = function(s, o, c, i) {
1049
- var u, A, k = [], L = function(b) {
1050
- return Ye(b) === s;
1051
- }, P = /* @__PURE__ */ new Map();
1052
- function C(b) {
1053
- b && k.push(_.bind(null, b));
905
+ return (w || g) && S.push(function(l, _) {
906
+ for (var N = L.length - 1; N >= 0; N--) _ = L[N].call(l, _);
907
+ return _;
908
+ }), w || W || (x ? g ? S.push(y(o, "get"), y(o, "set")) : S.push(a === 2 ? o[p] : y.call.bind(o[p])) : Object.defineProperty(i, s, o)), d;
909
+ }
910
+ function z(i, c) {
911
+ return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
912
+ }
913
+ if (arguments.length >= 6) var q = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
914
+ var V = Object.create(q ?? null), Y = function(i, c, u, s) {
915
+ var a, A, O = [], S = function(p) {
916
+ return Ft(p) === i;
917
+ }, D = /* @__PURE__ */ new Map();
918
+ function x(p) {
919
+ p && O.push(k.bind(null, p));
1054
920
  }
1055
- for (var R = 0; R < o.length; R++) {
1056
- var v = o[R];
1057
- if (Array.isArray(v)) {
1058
- var m = v[1], h = v[2], l = v.length > 3, x = 16 & m, $ = !!(8 & m), W = (m &= 7) == 0, a = h + "/" + $;
1059
- if (!W && !l) {
1060
- var I = P.get(a);
1061
- if (I === !0 || I === 3 && m !== 4 || I === 4 && m !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + h);
1062
- P.set(a, !(m > 2) || m);
921
+ for (var w = 0; w < c.length; w++) {
922
+ var g = c[w];
923
+ if (Array.isArray(g)) {
924
+ var m = g[1], $ = g[2], h = g.length > 3, C = 16 & m, E = !!(8 & m), W = (m &= 7) == 0, o = $ + "/" + E;
925
+ if (!W && !h) {
926
+ var L = D.get(o);
927
+ if (L === !0 || L === 3 && m !== 4 || L === 4 && m !== 3) throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " + $);
928
+ D.set(o, !(m > 2) || m);
1063
929
  }
1064
- T($ ? s : s.prototype, v, x, l ? "#" + h : ke(h), m, i, $ ? A = A || [] : u = u || [], k, $, l, W, m === 1, $ && l ? L : c);
930
+ j(E ? i : i.prototype, g, C, h ? "#" + $ : St($), m, s, E ? A = A || [] : a = a || [], O, E, h, W, m === 1, E && h ? S : u);
1065
931
  }
1066
932
  }
1067
- return C(u), C(A), k;
1068
- }(r, e, g, M);
1069
- return t.length || O(r, M), { e: H, get c() {
1070
- var s = [];
1071
- return t.length && [O(T(r, [t], n, r.name, 5, M, s), M), _.bind(null, s, r)];
933
+ return x(a), x(A), O;
934
+ }(r, t, f, V);
935
+ return e.length || z(r, V), { e: Y, get c() {
936
+ var i = [];
937
+ return e.length && [z(j(r, [e], n, r.name, 5, V, i), V), k.bind(null, i, r)];
1072
938
  } };
1073
939
  }
1074
- function ke(r) {
1075
- var e = Xe(r, "string");
1076
- return typeof e == "symbol" ? e : e + "";
940
+ function St(r) {
941
+ var t = Bt(r, "string");
942
+ return typeof t == "symbol" ? t : t + "";
1077
943
  }
1078
- function Xe(r, e) {
944
+ function Bt(r, t) {
1079
945
  if (typeof r != "object" || !r) return r;
1080
- var t = r[Symbol.toPrimitive];
1081
- if (t !== void 0) {
1082
- var n = t.call(r, e);
946
+ var e = r[Symbol.toPrimitive];
947
+ if (e !== void 0) {
948
+ var n = e.call(r, t);
1083
949
  if (typeof n != "object") return n;
1084
950
  throw new TypeError("@@toPrimitive must return a primitive value.");
1085
951
  }
1086
- return (e === "string" ? String : Number)(r);
952
+ return (t === "string" ? String : Number)(r);
1087
953
  }
1088
- function pe(r, e, t) {
1089
- typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
954
+ function pt(r, t, e) {
955
+ typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
1090
956
  try {
1091
- Object.defineProperty(r, "name", { configurable: !0, value: t ? t + " " + e : e });
957
+ Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
1092
958
  } catch {
1093
959
  }
1094
960
  return r;
1095
961
  }
1096
- function Ye(r) {
962
+ function Ft(r) {
1097
963
  if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
1098
964
  return r;
1099
965
  }
1100
- function Ze(r) {
966
+ function Kt(r) {
1101
967
  return r;
1102
968
  }
1103
- const ve = ie("WsxLink");
1104
- Se = [ce({
969
+ const vt = rt("WsxLink");
970
+ kt = [ct({
1105
971
  tagName: "wsx-link"
1106
972
  })];
1107
- let me;
1108
- new (ge = (se = class extends le {
973
+ let bt;
974
+ new (mt = (st = class extends lt {
1109
975
  constructor() {
1110
- super(), Q(this, "_autoStyles", Je), Q(this, "to", void 0), Q(this, "activeClass", void 0), Q(this, "handleClick", (p) => {
1111
- if (p.preventDefault(), !this.to) {
1112
- ve.warn("No 'to' attribute specified");
976
+ super(), X(this, "_autoStyles", Ut), X(this, "to", void 0), X(this, "activeClass", void 0), X(this, "handleClick", (v) => {
977
+ if (v.preventDefault(), !this.to) {
978
+ vt.warn("No 'to' attribute specified");
1113
979
  return;
1114
980
  }
1115
981
  if (this.isExternalLink(this.to)) {
1116
982
  window.open(this.to, "_blank");
1117
983
  return;
1118
984
  }
1119
- this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")), ve.debug(`Navigated to: ${this.to}`);
1120
- }), Q(this, "updateActiveState", () => {
1121
- var y;
1122
- const p = window.location.pathname, f = this.exact ? p === this.to : p.startsWith(this.to) && this.to !== "/", _ = (y = this.shadowRoot) == null ? void 0 : y.querySelector("a");
1123
- _ && (f ? (_.classList.add(this.activeClass), this.setAttribute("active", "")) : (_.classList.remove(this.activeClass), this.removeAttribute("active")));
985
+ this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")), vt.debug(`Navigated to: ${this.to}`);
986
+ }), X(this, "updateActiveState", () => {
987
+ var b;
988
+ const v = window.location.pathname, y = this.exact ? v === this.to : v.startsWith(this.to) && this.to !== "/", k = (b = this.shadowRoot) == null ? void 0 : b.querySelector("a");
989
+ k && (y ? (k.classList.add(this.activeClass), this.setAttribute("active", "")) : (k.classList.remove(this.activeClass), this.removeAttribute("active")));
1124
990
  });
1125
- const [e, t] = this.useState("to", "");
991
+ const [t, e] = this.useState("to", "");
1126
992
  Object.defineProperty(this, "to", {
1127
- get: e,
1128
- set: t,
993
+ get: t,
994
+ set: e,
1129
995
  enumerable: !0,
1130
996
  configurable: !0
1131
997
  });
1132
- const [n, g] = this.useState("activeClass", "active");
998
+ const [n, f] = this.useState("activeClass", "active");
1133
999
  Object.defineProperty(this, "activeClass", {
1134
1000
  get: n,
1135
- set: g,
1001
+ set: f,
1136
1002
  enumerable: !0,
1137
1003
  configurable: !0
1138
1004
  });
@@ -1144,20 +1010,20 @@ new (ge = (se = class extends le {
1144
1010
  return this.hasAttribute("exact");
1145
1011
  }
1146
1012
  render() {
1147
- return /* @__PURE__ */ te("a", { href: this.to, class: "wsx-link", onClick: this.handleClick, part: "link" }, /* @__PURE__ */ te("slot", null));
1013
+ return /* @__PURE__ */ tt("a", { href: this.to, class: "wsx-link", onClick: this.handleClick, part: "link" }, /* @__PURE__ */ tt("slot", null));
1148
1014
  }
1149
1015
  onConnected() {
1150
- var t;
1151
- (t = super.onConnected) == null || t.call(this), this.to = this.to || "", this.activeClass = this.activeClass || "active";
1152
- const e = this.shadowRoot.querySelector(".wsx-link");
1153
- e && (e.href = this.to), window.addEventListener("popstate", this.updateActiveState), document.addEventListener("route-changed", this.updateActiveState), this.updateActiveState();
1016
+ var e;
1017
+ (e = super.onConnected) == null || e.call(this), this.to = this.to || "", this.activeClass = this.activeClass || "active";
1018
+ const t = this.shadowRoot.querySelector(".wsx-link");
1019
+ t && (t.href = this.to), window.addEventListener("popstate", this.updateActiveState), document.addEventListener("route-changed", this.updateActiveState), this.updateActiveState();
1154
1020
  }
1155
1021
  onDisconnected() {
1156
- var e;
1157
- (e = super.onDisconnected) == null || e.call(this), window.removeEventListener("popstate", this.updateActiveState), document.removeEventListener("route-changed", this.updateActiveState);
1022
+ var t;
1023
+ (t = super.onDisconnected) == null || t.call(this), window.removeEventListener("popstate", this.updateActiveState), document.removeEventListener("route-changed", this.updateActiveState);
1158
1024
  }
1159
- onAttributeChanged(e, t, n) {
1160
- switch (e) {
1025
+ onAttributeChanged(t, e, n) {
1026
+ switch (t) {
1161
1027
  case "to":
1162
1028
  this.to = n || "", this.updateActiveState();
1163
1029
  break;
@@ -1172,8 +1038,8 @@ new (ge = (se = class extends le {
1172
1038
  break;
1173
1039
  }
1174
1040
  }
1175
- isExternalLink(e) {
1176
- return e.startsWith("http://") || e.startsWith("https://") || e.startsWith("mailto:") || e.startsWith("tel:");
1041
+ isExternalLink(t) {
1042
+ return t.startsWith("http://") || t.startsWith("https://") || t.startsWith("mailto:") || t.startsWith("tel:");
1177
1043
  }
1178
1044
  /**
1179
1045
  * 编程式导航
@@ -1184,14 +1050,14 @@ new (ge = (se = class extends le {
1184
1050
  cancelable: !0
1185
1051
  }));
1186
1052
  }
1187
- }, [me, de] = Qe(se, [], Se, 0, void 0, le).c, se), oe = class extends Ze {
1053
+ }, [bt, gt] = Ht(st, [], kt, 0, void 0, lt).c, st), ot = class extends Kt {
1188
1054
  constructor() {
1189
- super(me), Q(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), de();
1055
+ super(bt), X(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), gt();
1190
1056
  }
1191
- }, Q(oe, ge, void 0), oe)();
1057
+ }, X(ot, mt, void 0), ot)();
1192
1058
  export {
1193
- ne as RouterUtils,
1194
- me as WsxLink,
1195
- ze as WsxRouter,
1196
- Ge as WsxView
1059
+ et as RouterUtils,
1060
+ bt as WsxLink,
1061
+ It as WsxRouter,
1062
+ qt as WsxView
1197
1063
  };