@wsxjs/wsx-router 0.0.23 → 0.0.25

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(n) {
4
- return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
5
- }
6
- var ye = { exports: {} };
7
- (function(n) {
8
- (function(e, t) {
9
- n.exports ? n.exports = t() : e.log = t();
10
- })(We, function() {
11
- var e = function() {
12
- }, t = "undefined", r = 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
- ], v = {}, d = 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 b() {
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" && r ? b : 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 E() {
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), C = l.indexOf(x + "=");
80
- C !== -1 && (h = /^([^;]+)/.exec(
81
- l.slice(C + 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 p(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 = p(h), l !== !1 && P(k), O.call(i);
117
- }, i.setDefaultLevel = function(h) {
118
- A = p(h), E() || 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 (d !== i && (u = p(d.getLevel())), O.call(i), d === i)
127
- for (var h in v)
128
- v[h].rebuild();
129
- }, u = p(
130
- d ? d.getLevel() : "WARN"
131
- );
132
- var m = E();
133
- m != null && (k = p(m)), O.call(i);
134
- }
135
- d = new H(), d.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 = v[c];
139
- return i || (i = v[c] = new H(
140
- c,
141
- d.methodFactory
142
- )), i;
143
- };
144
- var s = typeof window !== t ? window.log : void 0;
145
- return d.noConflict = function() {
146
- return typeof window !== t && window.log === d && (window.log = s), d;
147
- }, d.getLoggers = function() {
148
- return v;
149
- }, d.default = d, d;
150
- });
151
- })(ye);
152
- var Te = ye.exports;
153
- const Oe = /* @__PURE__ */ Ae(Te), be = {
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 n, 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 = (n = t.import) == null ? void 0 : n.meta) != null && e.env) {
175
- const r = t.import.meta.env;
176
- return r.MODE === "production" || r.PROD === !0;
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;
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(n = {}) {
188
- const { name: e, level: t } = { ...ee, ...n }, r = e || ee.name, g = Oe.getLogger(r), v = t || ee.level;
189
- return g.setLevel(be[v]), g;
29
+ function G(r, t) {
30
+ return r ? `[${r}] ${t}` : t;
190
31
  }
191
- function X(n, e) {
192
- return n ? `[${n}] ${e}` : e;
193
- }
194
- class we {
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;
197
41
  }
198
- debug(e, ...t) {
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
+ }
47
+ }
48
+ debug(t, ...e) {
199
49
  if (!this.isProd || this.shouldLog("debug")) {
200
- const r = X(this.name, e);
201
- t.length > 0 ? this.logInstance.debug(r, ...t) : this.logInstance.debug(r);
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 r = X(this.name, e);
207
- t.length > 0 ? this.logInstance.info(r, ...t) : this.logInstance.info(r);
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 r = X(this.name, e);
212
- t.length > 0 ? this.logInstance.warn(r, ...t) : this.logInstance.warn(r);
213
- }
214
- error(e, ...t) {
215
- const r = X(this.name, e);
216
- t.length > 0 ? this.logInstance.error(r, ...t) : this.logInstance.error(r);
217
- }
218
- fatal(e, ...t) {
219
- const r = X(this.name, e);
220
- t.length > 0 ? this.logInstance.error(`[FATAL] ${r}`, ...t) : this.logInstance.error(`[FATAL] ${r}`);
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 r = X(this.name, e);
225
- t.length > 0 ? this.logInstance.trace(r, ...t) : this.logInstance.trace(r);
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"], r = t.indexOf(this.currentLevel);
233
- return t.indexOf(e) >= r;
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(be[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 we();
256
- function ie(n, e = {}) {
257
- return new we({
258
- ...e,
259
- name: e.name || `WSX:${n}`
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) {
297
- var r;
298
- if (e === t)
162
+ static parseRoute(t, e) {
163
+ var n;
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 = ((r = e.match(/:([^/]+)/g)) == null ? void 0 : r.map((b) => b.slice(1))) || [], v = e.replace(/:[^/]+/g, "([^/]+)"), d = new RegExp(`^${v}$`), _ = t.match(d);
312
- if (_ && g.length > 0) {
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) {
313
179
  const b = {};
314
- return g.forEach((T, O) => {
315
- b[T] = _[O + 1];
180
+ return f.forEach((j, z) => {
181
+ b[j] = k[z + 1];
316
182
  }), {
317
- route: e,
183
+ route: t,
318
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 r = e;
339
- return Object.entries(t).forEach(([g, v]) => {
340
- r = r.replace(`:${g}`, encodeURIComponent(v));
341
- }), r;
203
+ static buildPath(t, e = {}) {
204
+ let n = t;
205
+ return Object.entries(e).forEach(([f, v]) => {
206
+ n = n.replace(`:${f}`, encodeURIComponent(v));
207
+ }), n;
342
208
  }
343
209
  /**
344
210
  * 检查路由是否匹配当前路径
345
211
  */
346
- static isRouteActive(e, t = !1) {
347
- const r = window.location.pathname;
348
- return t ? r === e : e === "/" ? r === "/" : r.startsWith(e);
212
+ static isRouteActive(t, e = !1) {
213
+ const n = window.location.pathname;
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((r) => r.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, r = !1) {
385
- const g = new URL(window.location.href);
386
- g.searchParams.set(e, t);
387
- const v = g.pathname + g.search + g.hash;
388
- this.navigate(v, r);
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) {
394
- const r = new URL(window.location.href);
395
- r.searchParams.delete(e);
396
- const g = r.pathname + r.search + r.hash;
397
- this.navigate(g, t);
259
+ static removeQueryParam(t, e = !1) {
260
+ const n = new URL(window.location.href);
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,482 +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 = () => {
436
- const r = this.getCurrentRoute();
437
- e(r);
300
+ static onRouteChange(t) {
301
+ const e = () => {
302
+ const n = this.getCurrentRoute();
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(n, e, t) {
450
- return (e = Ee(e)) in n ? Object.defineProperty(n, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : n[e] = t, n;
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(n, e, t, r, g, v) {
453
- function d(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 b(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, E, R, p, m) {
467
- function h(f) {
468
- if (!m(f)) 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], C = 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 = [], w = u === 3 ? "get" : u === 4 || p ? "set" : "value";
474
- E ? (R || p ? a = { get: he(function() {
475
- return C(this);
476
- }, i, "get"), set: function(f) {
477
- o[4](this, f);
478
- } } : a[w] = C, R || he(a[w], i, u === 2 ? "" : w)) : 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 y = 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(f, S) {
482
- if (f.v) throw Error("attempted to call addInitializer after decoration was finished");
483
- b(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 = b(B.call(G, y, j), "class decorators", "return")) && (y = 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 = E, E ? u === 2 ? D = function(f) {
490
- return h(f), a.value;
491
- } : (u < 4 && (D = d(a, "get", h)), u !== 3 && (z = d(a, "set", h))) : (D = function(f) {
492
- return f[i];
493
- }, (u < 2 || u === 4) && (z = function(f, S) {
494
- f[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: E ? m.bind() : function(f) {
497
- return i in f;
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), y = B.call(G, p ? { get: a.get, set: a.set } : a[w], j), p) {
500
- if (typeof y == "object" && y) (l = b(y.get, "accessor.get")) && (a.get = l), (l = b(y.set, "accessor.set")) && (a.set = l), (l = b(y.init, "accessor.init")) && I.push(l);
501
- else if (y !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
502
- } else b(y, (R ? "field" : "method") + " decorators", "return") && (R ? I.push(y) : a[w] = y);
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 || p) && L.push(function(f, S) {
509
- for (var N = I.length - 1; N >= 0; N--) S = I[N].call(f, S);
510
- return S;
511
- }), R || W || (E ? p ? L.push(d(a, "get"), d(a, "set")) : L.push(u === 2 ? a[w] : d.call.bind(a[w])) : Object.defineProperty(s, i, a)), y;
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 = v[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(w) {
519
- return Ue(w) === s;
520
- }, P = /* @__PURE__ */ new Map();
521
- function E(w) {
522
- w && k.push(_.bind(null, w));
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 p = o[R];
526
- if (Array.isArray(p)) {
527
- var m = p[1], h = p[2], l = p.length > 3, x = 16 & m, C = !!(8 & m), W = (m &= 7) == 0, a = h + "/" + C;
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(C ? s : s.prototype, p, x, l ? "#" + h : Ee(h), m, i, C ? A = A || [] : u = u || [], k, C, l, W, m === 1, C && 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 E(u), E(A), k;
537
- }(n, e, g, M);
538
- return t.length || O(n, M), { e: H, get c() {
539
- var s = [];
540
- return t.length && [O(T(n, [t], r, n.name, 5, M, s), M), _.bind(null, s, n)];
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(n) {
544
- var e = Ve(n, "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(n, e) {
548
- if (typeof n != "object" || !n) return n;
549
- var t = n[Symbol.toPrimitive];
550
- if (t !== void 0) {
551
- var r = t.call(n, e);
552
- if (typeof r != "object") return r;
413
+ function Ot(r, t) {
414
+ if (typeof r != "object" || !r) return r;
415
+ var e = r[Symbol.toPrimitive];
416
+ if (e !== void 0) {
417
+ var n = e.call(r, t);
418
+ if (typeof n != "object") return n;
553
419
  throw new TypeError("@@toPrimitive must return a primitive value.");
554
420
  }
555
- return String(n);
421
+ return String(r);
556
422
  }
557
- function he(n, 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(n, "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
- return n;
429
+ return r;
564
430
  }
565
- function Ue(n) {
566
- if (Object(n) !== n) throw TypeError("right-hand side of 'in' should be an object, got " + (n !== null ? typeof n : "null"));
567
- return n;
431
+ function Tt(r) {
432
+ if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
433
+ return r;
568
434
  }
569
- const $ = 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
- $.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(), $.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
- $.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
- $.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 r = t.getAttribute("href");
610
- !r || r.startsWith("http") || r.startsWith("#") || (e.preventDefault(), this.navigate(r));
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(), $.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), $.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(), $.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)), requestAnimationFrame(() => {
626
- $.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
- $.debug(`WsxRouter found ${e.length} views`), this.views.clear(), this.compiledRoutes.clear(), this.matchCache.clear(), e.forEach((t) => {
637
- const r = t.getAttribute("route") || "/";
638
- if (this.views.set(r, t), $.debug(`WsxRouter registered route: ${r}`), r.includes(":")) {
639
- const g = r.replace(/:[^/]+/g, "([^/]+)"), v = new RegExp(`^${g}$`);
640
- this.compiledRoutes.set(r, v), $.debug(`WsxRouter compiled regex for route: ${r} -> ${v}`);
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 r = this.matchRoute(e);
651
- if (r) {
652
- r.style.display = "block", r.style.visibility = "visible";
653
- const g = r.getAttribute("route") || "/";
654
- $.debug(`Showing view for route: ${g}`);
655
- for (const [O, V] of this.views)
656
- V !== r && (V.style.display = "none", V.style.visibility = "");
657
- this.currentView = r;
658
- const v = this.extractParams(g, e);
659
- $.debug(`Extracted params for route ${g} and path ${e}:`, v), v && requestAnimationFrame(() => {
660
- r.setAttribute("params", JSON.stringify(v)), $.debug(`Set params attribute on view: ${JSON.stringify(v)}`);
514
+ performNavigation(t) {
515
+ const e = () => {
516
+ const n = this.matchRoute(t);
517
+ if (n) {
518
+ n.style.display = "block", n.style.visibility = "visible";
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 = "");
523
+ this.currentView = n;
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 d = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, _ = new URL(d, window.location.origin || "http://localhost"), b = {
663
- path: e,
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,
664
530
  params: v || {},
665
- query: Object.fromEntries(_.searchParams.entries()),
666
- hash: _.hash.slice(1)
531
+ query: Object.fromEntries(k.searchParams.entries()),
532
+ hash: k.hash.slice(1)
667
533
  };
668
- ne._setCurrentRoute(b), $.debug("Updated RouterUtils._currentRoute:", b);
669
- const T = new CustomEvent("route-changed", {
534
+ et._setCurrentRoute(b), R.debug("Updated RouterUtils._currentRoute:", b);
535
+ const j = new CustomEvent("route-changed", {
670
536
  detail: b,
671
537
  bubbles: !0
672
538
  });
673
- document.dispatchEvent(T);
539
+ document.dispatchEvent(j);
674
540
  } else {
675
- for (const [b, T] of this.views)
676
- T.style.display = "none";
677
- this.currentView = null, $.warn(`No view found for path: ${e}`);
678
- const g = window.location.href || `${window.location.pathname}${window.location.search}${window.location.hash}`, v = new URL(g, window.location.origin || "http://localhost"), d = {
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
547
  query: Object.fromEntries(v.searchParams.entries()),
682
548
  hash: v.hash.slice(1)
683
549
  };
684
- ne._setCurrentRoute(d);
685
- const _ = new CustomEvent("route-changed", {
686
- detail: d,
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), $.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 ($.warn(`matchRoute called for path: ${e}, views count: ${this.views.size}`), this.matchCache.has(e)) {
716
- const r = this.matchCache.get(e);
717
- return $.warn(`matchRoute: found in cache, route: ${r}`), this.views.get(r) || 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), $.warn(`matchRoute: exact match found for ${e}`), this.views.get(e);
721
- $.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);
722
- for (const [r, g] of this.views)
723
- if (r.includes(":")) {
724
- const v = this.compiledRoutes.get(r);
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)
588
+ if (n.endsWith("/*")) {
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;
592
+ }
593
+ R.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);
594
+ for (const [n, f] of this.views)
595
+ if (n.includes(":")) {
596
+ const v = this.compiledRoutes.get(n);
725
597
  if (v) {
726
- const d = v.test(e);
727
- if ($.warn(`matchRoute: testing route ${r} against ${e}, matches: ${d}`), d)
728
- return this.matchCache.set(e, r), $.warn(`matchRoute: parameter match found, route: ${r}, path: ${e}`), g;
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;
729
601
  } else
730
- $.warn(`matchRoute: route ${r} has ':' but no compiled regex found`);
602
+ R.warn(`matchRoute: route ${n} has ':' but no compiled regex found`);
731
603
  }
732
- const t = this.views.get("*") || null;
733
- return t ? (this.matchCache.set(e, "*"), $.warn(`matchRoute: wildcard match found for ${e}`)) : $.warn(`matchRoute: no match found for ${e}, no wildcard view available`), t;
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;
734
606
  }
735
- extractParams(e, t) {
607
+ extractParams(t, e) {
736
608
  var b;
737
- if (!e.includes(":")) return null;
738
- const r = ((b = e.match(/:([^/]+)/g)) == null ? void 0 : b.map((T) => T.slice(1))) || [], g = e.replace(/:[^/]+/g, "([^/]+)"), v = new RegExp(`^${g}$`), d = t.match(v);
739
- if (!d || !r.length) return null;
740
- const _ = {};
741
- return r.forEach((T, O) => {
742
- _[T] = d[O + 1];
743
- }), _;
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;
744
616
  }
745
617
  /**
746
618
  * RFC 0032: 清除匹配缓存
747
619
  * 当路由配置变更时调用,确保使用最新的路由规则
748
620
  */
749
621
  clearMatchCache() {
750
- this.matchCache.clear(), $.debug("WsxRouter cleared match cache");
622
+ this.matchCache.clear(), R.debug("WsxRouter cleared match cache");
751
623
  }
752
624
  /**
753
625
  * RFC 0033: 配置 View Transitions
754
626
  */
755
- setViewTransitions(e) {
756
- this.enableViewTransitions = e, $.debug(`View Transitions ${e ? "enabled" : "disabled"}`);
627
+ setViewTransitions(t) {
628
+ this.enableViewTransitions = t, R.debug(`View Transitions ${t ? "enabled" : "disabled"}`);
757
629
  }
758
630
  /**
759
631
  * RFC 0033: 配置 Scroll Restoration
760
632
  */
761
- setScrollRestoration(e) {
762
- this.scrollRestoration = e, "scrollRestoration" in history && (history.scrollRestoration = 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}`);
763
635
  }
764
636
  /**
765
637
  * 编程式导航 - 使用原生 History API
766
638
  */
767
- navigate(e) {
768
- window.history.pushState(null, "", e), this.handleRouteChange();
639
+ navigate(t) {
640
+ window.history.pushState(null, "", t), this.handleRouteChange();
769
641
  }
770
642
  }
771
- Re = Ne;
772
- [ze, Le] = Pe(Re, [], xe, 0, void 0, re).c;
773
- Le();
774
- 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}}";
775
- var Ce;
776
- let $e, _e;
777
- function Z(n, e, t) {
778
- return (e = Ie(e)) in n ? Object.defineProperty(n, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : n[e] = t, n;
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;
779
651
  }
780
- function qe(n, e, t, r, g, v) {
781
- function d(s, o, c) {
782
- return function(i, u) {
783
- 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);
784
656
  };
785
657
  }
786
- function _(s, o) {
787
- for (var c = 0; c < s.length; c++) s[c].call(o);
788
- return o;
658
+ function k(i, c) {
659
+ for (var u = 0; u < i.length; u++) i[u].call(c);
660
+ return c;
789
661
  }
790
- function b(s, o, c, i) {
791
- if (typeof s != "function" && (i || s !== void 0)) throw new TypeError(o + " must " + (c || "be") + " a function" + (i ? "" : " or undefined"));
792
- 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;
793
665
  }
794
- function T(s, o, c, i, u, A, k, L, P, E, R, p, m) {
795
- function h(f) {
796
- if (!m(f)) 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");
797
669
  }
798
- var l, x = o[0], C = o[3], W = !L;
670
+ var h, C = c[0], E = c[3], W = !S;
799
671
  if (!W) {
800
- c || Array.isArray(x) || (x = [x]);
801
- var a = {}, I = [], w = u === 3 ? "get" : u === 4 || p ? "set" : "value";
802
- E ? (R || p ? a = { get: de(function() {
803
- return C(this);
804
- }, i, "get"), set: function(f) {
805
- o[4](this, f);
806
- } } : a[w] = C, R || de(a[w], i, u === 2 ? "" : w)) : 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));
807
679
  }
808
- for (var y = s, U = x.length - 1; U >= 0; U -= c ? 2 : 1) {
809
- 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(f, S) {
810
- if (f.v) throw Error("attempted to call addInitializer after decoration was finished");
811
- b(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(_);
812
684
  }).bind(null, K) };
813
685
  try {
814
- if (W) (l = b(B.call(G, y, j), "class decorators", "return")) && (y = l);
686
+ if (W) (h = b(B.call(F, d, T), "class decorators", "return")) && (d = h);
815
687
  else {
816
- var D, z;
817
- j.static = P, j.private = E, E ? u === 2 ? D = function(f) {
818
- return h(f), a.value;
819
- } : (u < 4 && (D = d(a, "get", h)), u !== 3 && (z = d(a, "set", h))) : (D = function(f) {
820
- return f[i];
821
- }, (u < 2 || u === 4) && (z = function(f, S) {
822
- f[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] = _;
823
695
  }));
824
- var J = j.access = { has: E ? m.bind() : function(f) {
825
- return i in f;
696
+ var Q = T.access = { has: x ? m.bind() : function(l) {
697
+ return s in l;
826
698
  } };
827
- if (D && (J.get = D), z && (J.set = z), y = B.call(G, p ? { get: a.get, set: a.set } : a[w], j), p) {
828
- if (typeof y == "object" && y) (l = b(y.get, "accessor.get")) && (a.get = l), (l = b(y.set, "accessor.set")) && (a.set = l), (l = b(y.init, "accessor.init")) && I.push(l);
829
- else if (y !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
830
- } else b(y, (R ? "field" : "method") + " decorators", "return") && (R ? I.push(y) : a[w] = y);
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);
831
703
  }
832
704
  } finally {
833
705
  K.v = !0;
834
706
  }
835
707
  }
836
- return (R || p) && L.push(function(f, S) {
837
- for (var N = I.length - 1; N >= 0; N--) S = I[N].call(f, S);
838
- return S;
839
- }), R || W || (E ? p ? L.push(d(a, "get"), d(a, "set")) : L.push(u === 2 ? a[w] : d.call.bind(a[w])) : Object.defineProperty(s, i, a)), y;
840
- }
841
- function O(s, o) {
842
- return Object.defineProperty(s, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: o });
843
- }
844
- if (arguments.length >= 6) var V = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
845
- var M = Object.create(V ?? null), H = function(s, o, c, i) {
846
- var u, A, k = [], L = function(w) {
847
- return Be(w) === s;
848
- }, P = /* @__PURE__ */ new Map();
849
- function E(w) {
850
- w && k.push(_.bind(null, w));
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));
851
723
  }
852
- for (var R = 0; R < o.length; R++) {
853
- var p = o[R];
854
- if (Array.isArray(p)) {
855
- var m = p[1], h = p[2], l = p.length > 3, x = 16 & m, C = !!(8 & m), W = (m &= 7) == 0, a = h + "/" + C;
856
- if (!W && !l) {
857
- var I = P.get(a);
858
- 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);
859
- 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);
860
732
  }
861
- T(C ? s : s.prototype, p, x, l ? "#" + h : Ie(h), m, i, C ? A = A || [] : u = u || [], k, C, l, W, m === 1, C && 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);
862
734
  }
863
735
  }
864
- return E(u), E(A), k;
865
- }(n, e, g, M);
866
- return t.length || O(n, M), { e: H, get c() {
867
- var s = [];
868
- return t.length && [O(T(n, [t], r, n.name, 5, M, s), M), _.bind(null, s, n)];
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)];
869
741
  } };
870
742
  }
871
- function Ie(n) {
872
- var e = He(n, "string");
873
- return typeof e == "symbol" ? e : e + "";
743
+ function _t(r) {
744
+ var t = Mt(r, "string");
745
+ return typeof t == "symbol" ? t : t + "";
874
746
  }
875
- function He(n, e) {
876
- if (typeof n != "object" || !n) return n;
877
- var t = n[Symbol.toPrimitive];
878
- if (t !== void 0) {
879
- var r = t.call(n, e);
880
- if (typeof r != "object") return r;
747
+ function Mt(r, t) {
748
+ if (typeof r != "object" || !r) return r;
749
+ var e = r[Symbol.toPrimitive];
750
+ if (e !== void 0) {
751
+ var n = e.call(r, t);
752
+ if (typeof n != "object") return n;
881
753
  throw new TypeError("@@toPrimitive must return a primitive value.");
882
754
  }
883
- return String(n);
755
+ return String(r);
884
756
  }
885
- function de(n, e, t) {
886
- typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
757
+ function ft(r, t, e) {
758
+ typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
887
759
  try {
888
- Object.defineProperty(n, "name", { configurable: !0, value: t ? t + " " + e : e });
760
+ Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
889
761
  } catch {
890
762
  }
891
- return n;
763
+ return r;
892
764
  }
893
- function Be(n) {
894
- if (Object(n) !== n) throw TypeError("right-hand side of 'in' should be an object, got " + (n !== null ? typeof n : "null"));
895
- return n;
765
+ function zt(r) {
766
+ if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
767
+ return r;
896
768
  }
897
- const q = ie("WsxView");
898
- _e = [ce({
769
+ const H = rt("WsxView");
770
+ Lt = [ct({
899
771
  tagName: "wsx-view"
900
772
  })];
901
- let Ge;
902
- class Ke extends re {
773
+ let qt;
774
+ class Nt extends nt {
903
775
  constructor() {
904
- super(), Z(this, "_autoStyles", Fe), Z(this, "_component", ""), Z(this, "params", void 0), Z(this, "componentInstance", null), Z(this, "isLoading", !1);
905
- 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({});
906
778
  Object.defineProperty(this, "params", {
907
- get: () => e,
908
- set: (t) => {
909
- 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();
910
782
  },
911
783
  enumerable: !0,
912
784
  configurable: !0
@@ -915,218 +787,218 @@ class Ke extends re {
915
787
  get component() {
916
788
  return this._component;
917
789
  }
918
- set component(e) {
919
- this._component = e || "", this._component && requestAnimationFrame(() => {
790
+ set component(t) {
791
+ this._component = t || "", this._component && requestAnimationFrame(() => {
920
792
  this.connected && !this.componentInstance && !this.isLoading && this.loadComponent(this._component || "");
921
793
  });
922
794
  }
923
795
  // 防止重复加载的标志
924
796
  render() {
925
- return /* @__PURE__ */ te("div", { class: "route-view" });
797
+ return /* @__PURE__ */ tt("div", { class: "route-view" });
926
798
  }
927
799
  onConnected() {
928
- var e;
929
- (e = super.onConnected) == null || e.call(this), requestAnimationFrame(() => {
800
+ var t;
801
+ (t = super.onConnected) == null || t.call(this), requestAnimationFrame(() => {
930
802
  !this.connected || this.isLoading || this.componentInstance || this.component && this.loadComponent(this.component);
931
803
  });
932
804
  }
933
- async loadComponent(e) {
805
+ async loadComponent(t) {
934
806
  if (!(!this.connected || this.isLoading || this.componentInstance)) {
935
807
  this.isLoading = !0;
936
808
  try {
937
- const t = this.componentInstance;
938
- if (t && (t.remove(), this.componentInstance = null), !customElements.get(e)) {
939
- 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;
940
812
  return;
941
813
  }
942
- 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(([v, d]) => {
943
- this.componentInstance.setAttribute(v, d);
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);
944
816
  }));
945
- const g = this.querySelector(".route-view");
946
- if (g) {
947
- if (q.warn(`WsxView: Appending ${e} to container`), !customElements.get(e)) {
948
- 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;
949
821
  return;
950
822
  }
951
- g.appendChild(this.componentInstance), q.warn(`WsxView: Component ${e} appended successfully, waiting for connectedCallback...`), setTimeout(() => {
952
- 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!`);
953
825
  }, 0);
954
826
  } else
955
- q.error("WsxView: Route view container not found"), this.componentInstance = null;
956
- } catch (t) {
957
- 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;
958
830
  } finally {
959
- 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}`);
960
832
  }
961
833
  }
962
834
  }
963
835
  onDisconnected() {
964
- var e;
965
- (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);
966
838
  }
967
839
  }
968
- Ce = Ke;
969
- [Ge, $e] = qe(Ce, [], _e, 0, void 0, re).c;
970
- $e();
971
- 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)}';
972
- var oe, se;
973
- let fe, Se, ge;
974
- function Q(n, e, t) {
975
- return (e = ke(e)) in n ? Object.defineProperty(n, e, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : n[e] = t, n;
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;
976
848
  }
977
- function Qe(n, e, t, r, g, v) {
978
- function d(s, o, c) {
979
- return function(i, u) {
980
- 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);
981
853
  };
982
854
  }
983
- function _(s, o) {
984
- for (var c = 0; c < s.length; c++) s[c].call(o);
985
- return o;
855
+ function k(i, c) {
856
+ for (var u = 0; u < i.length; u++) i[u].call(c);
857
+ return c;
986
858
  }
987
- function b(s, o, c, i) {
988
- if (typeof s != "function" && (i || s !== void 0)) throw new TypeError(o + " must " + (c || "be") + " a function" + (i ? "" : " or undefined"));
989
- 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;
990
862
  }
991
- function T(s, o, c, i, u, A, k, L, P, E, R, p, m) {
992
- function h(f) {
993
- if (!m(f)) 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");
994
866
  }
995
- var l, x = o[0], C = o[3], W = !L;
867
+ var h, C = c[0], E = c[3], W = !S;
996
868
  if (!W) {
997
- c || Array.isArray(x) || (x = [x]);
998
- var a = {}, I = [], w = u === 3 ? "get" : u === 4 || p ? "set" : "value";
999
- E ? (R || p ? a = { get: pe(function() {
1000
- return C(this);
1001
- }, i, "get"), set: function(f) {
1002
- o[4](this, f);
1003
- } } : a[w] = C, R || pe(a[w], i, u === 2 ? "" : w)) : 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));
1004
876
  }
1005
- for (var y = s, U = x.length - 1; U >= 0; U -= c ? 2 : 1) {
1006
- 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(f, S) {
1007
- if (f.v) throw Error("attempted to call addInitializer after decoration was finished");
1008
- b(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(_);
1009
881
  }).bind(null, K) };
1010
882
  try {
1011
- if (W) (l = b(B.call(G, y, j), "class decorators", "return")) && (y = l);
883
+ if (W) (h = b(B.call(F, d, T), "class decorators", "return")) && (d = h);
1012
884
  else {
1013
- var D, z;
1014
- j.static = P, j.private = E, E ? u === 2 ? D = function(f) {
1015
- return h(f), a.value;
1016
- } : (u < 4 && (D = d(a, "get", h)), u !== 3 && (z = d(a, "set", h))) : (D = function(f) {
1017
- return f[i];
1018
- }, (u < 2 || u === 4) && (z = function(f, S) {
1019
- f[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] = _;
1020
892
  }));
1021
- var J = j.access = { has: E ? m.bind() : function(f) {
1022
- return i in f;
893
+ var Q = T.access = { has: x ? m.bind() : function(l) {
894
+ return s in l;
1023
895
  } };
1024
- if (D && (J.get = D), z && (J.set = z), y = B.call(G, p ? { get: a.get, set: a.set } : a[w], j), p) {
1025
- if (typeof y == "object" && y) (l = b(y.get, "accessor.get")) && (a.get = l), (l = b(y.set, "accessor.set")) && (a.set = l), (l = b(y.init, "accessor.init")) && I.push(l);
1026
- else if (y !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
1027
- } else b(y, (R ? "field" : "method") + " decorators", "return") && (R ? I.push(y) : a[w] = y);
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);
1028
900
  }
1029
901
  } finally {
1030
902
  K.v = !0;
1031
903
  }
1032
904
  }
1033
- return (R || p) && L.push(function(f, S) {
1034
- for (var N = I.length - 1; N >= 0; N--) S = I[N].call(f, S);
1035
- return S;
1036
- }), R || W || (E ? p ? L.push(d(a, "get"), d(a, "set")) : L.push(u === 2 ? a[w] : d.call.bind(a[w])) : Object.defineProperty(s, i, a)), y;
1037
- }
1038
- function O(s, o) {
1039
- return Object.defineProperty(s, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: o });
1040
- }
1041
- if (arguments.length >= 6) var V = v[Symbol.metadata || Symbol.for("Symbol.metadata")];
1042
- var M = Object.create(V ?? null), H = function(s, o, c, i) {
1043
- var u, A, k = [], L = function(w) {
1044
- return Ye(w) === s;
1045
- }, P = /* @__PURE__ */ new Map();
1046
- function E(w) {
1047
- w && k.push(_.bind(null, w));
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));
1048
920
  }
1049
- for (var R = 0; R < o.length; R++) {
1050
- var p = o[R];
1051
- if (Array.isArray(p)) {
1052
- var m = p[1], h = p[2], l = p.length > 3, x = 16 & m, C = !!(8 & m), W = (m &= 7) == 0, a = h + "/" + C;
1053
- if (!W && !l) {
1054
- var I = P.get(a);
1055
- 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);
1056
- 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);
1057
929
  }
1058
- T(C ? s : s.prototype, p, x, l ? "#" + h : ke(h), m, i, C ? A = A || [] : u = u || [], k, C, l, W, m === 1, C && 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);
1059
931
  }
1060
932
  }
1061
- return E(u), E(A), k;
1062
- }(n, e, g, M);
1063
- return t.length || O(n, M), { e: H, get c() {
1064
- var s = [];
1065
- return t.length && [O(T(n, [t], r, n.name, 5, M, s), M), _.bind(null, s, n)];
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)];
1066
938
  } };
1067
939
  }
1068
- function ke(n) {
1069
- var e = Xe(n, "string");
1070
- return typeof e == "symbol" ? e : e + "";
940
+ function St(r) {
941
+ var t = Bt(r, "string");
942
+ return typeof t == "symbol" ? t : t + "";
1071
943
  }
1072
- function Xe(n, e) {
1073
- if (typeof n != "object" || !n) return n;
1074
- var t = n[Symbol.toPrimitive];
1075
- if (t !== void 0) {
1076
- var r = t.call(n, e);
1077
- if (typeof r != "object") return r;
944
+ function Bt(r, t) {
945
+ if (typeof r != "object" || !r) return r;
946
+ var e = r[Symbol.toPrimitive];
947
+ if (e !== void 0) {
948
+ var n = e.call(r, t);
949
+ if (typeof n != "object") return n;
1078
950
  throw new TypeError("@@toPrimitive must return a primitive value.");
1079
951
  }
1080
- return (e === "string" ? String : Number)(n);
952
+ return (t === "string" ? String : Number)(r);
1081
953
  }
1082
- function pe(n, e, t) {
1083
- typeof e == "symbol" && (e = (e = e.description) ? "[" + e + "]" : "");
954
+ function pt(r, t, e) {
955
+ typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
1084
956
  try {
1085
- Object.defineProperty(n, "name", { configurable: !0, value: t ? t + " " + e : e });
957
+ Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
1086
958
  } catch {
1087
959
  }
1088
- return n;
960
+ return r;
1089
961
  }
1090
- function Ye(n) {
1091
- if (Object(n) !== n) throw TypeError("right-hand side of 'in' should be an object, got " + (n !== null ? typeof n : "null"));
1092
- return n;
962
+ function Ft(r) {
963
+ if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
964
+ return r;
1093
965
  }
1094
- function Ze(n) {
1095
- return n;
966
+ function Kt(r) {
967
+ return r;
1096
968
  }
1097
- const ve = ie("WsxLink");
1098
- Se = [ce({
969
+ const vt = rt("WsxLink");
970
+ kt = [ct({
1099
971
  tagName: "wsx-link"
1100
972
  })];
1101
- let me;
1102
- new (ge = (se = class extends le {
973
+ let bt;
974
+ new (mt = (st = class extends lt {
1103
975
  constructor() {
1104
- super(), Q(this, "_autoStyles", Je), Q(this, "to", void 0), Q(this, "activeClass", void 0), Q(this, "handleClick", (v) => {
976
+ super(), X(this, "_autoStyles", Ut), X(this, "to", void 0), X(this, "activeClass", void 0), X(this, "handleClick", (v) => {
1105
977
  if (v.preventDefault(), !this.to) {
1106
- ve.warn("No 'to' attribute specified");
978
+ vt.warn("No 'to' attribute specified");
1107
979
  return;
1108
980
  }
1109
981
  if (this.isExternalLink(this.to)) {
1110
982
  window.open(this.to, "_blank");
1111
983
  return;
1112
984
  }
1113
- 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}`);
1114
- }), Q(this, "updateActiveState", () => {
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", () => {
1115
987
  var b;
1116
- const v = window.location.pathname, d = this.exact ? v === this.to : v.startsWith(this.to) && this.to !== "/", _ = (b = this.shadowRoot) == null ? void 0 : b.querySelector("a");
1117
- _ && (d ? (_.classList.add(this.activeClass), this.setAttribute("active", "")) : (_.classList.remove(this.activeClass), this.removeAttribute("active")));
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")));
1118
990
  });
1119
- const [e, t] = this.useState("to", "");
991
+ const [t, e] = this.useState("to", "");
1120
992
  Object.defineProperty(this, "to", {
1121
- get: e,
1122
- set: t,
993
+ get: t,
994
+ set: e,
1123
995
  enumerable: !0,
1124
996
  configurable: !0
1125
997
  });
1126
- const [r, g] = this.useState("activeClass", "active");
998
+ const [n, f] = this.useState("activeClass", "active");
1127
999
  Object.defineProperty(this, "activeClass", {
1128
- get: r,
1129
- set: g,
1000
+ get: n,
1001
+ set: f,
1130
1002
  enumerable: !0,
1131
1003
  configurable: !0
1132
1004
  });
@@ -1138,36 +1010,36 @@ new (ge = (se = class extends le {
1138
1010
  return this.hasAttribute("exact");
1139
1011
  }
1140
1012
  render() {
1141
- 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));
1142
1014
  }
1143
1015
  onConnected() {
1144
- var t;
1145
- (t = super.onConnected) == null || t.call(this), this.to = this.to || "", this.activeClass = this.activeClass || "active";
1146
- const e = this.shadowRoot.querySelector(".wsx-link");
1147
- 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();
1148
1020
  }
1149
1021
  onDisconnected() {
1150
- var e;
1151
- (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);
1152
1024
  }
1153
- onAttributeChanged(e, t, r) {
1154
- switch (e) {
1025
+ onAttributeChanged(t, e, n) {
1026
+ switch (t) {
1155
1027
  case "to":
1156
- this.to = r || "", this.updateActiveState();
1028
+ this.to = n || "", this.updateActiveState();
1157
1029
  break;
1158
1030
  case "replace":
1159
- this.replace = r !== null && r !== "false";
1031
+ this.replace = n !== null && n !== "false";
1160
1032
  break;
1161
1033
  case "active-class":
1162
- this.activeClass = r || "active", this.updateActiveState();
1034
+ this.activeClass = n || "active", this.updateActiveState();
1163
1035
  break;
1164
1036
  case "exact":
1165
- this.exact = r !== null && r !== "false", this.updateActiveState();
1037
+ this.exact = n !== null && n !== "false", this.updateActiveState();
1166
1038
  break;
1167
1039
  }
1168
1040
  }
1169
- isExternalLink(e) {
1170
- 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:");
1171
1043
  }
1172
1044
  /**
1173
1045
  * 编程式导航
@@ -1178,14 +1050,14 @@ new (ge = (se = class extends le {
1178
1050
  cancelable: !0
1179
1051
  }));
1180
1052
  }
1181
- }, [me, fe] = 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 {
1182
1054
  constructor() {
1183
- super(me), Q(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), fe();
1055
+ super(bt), X(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), gt();
1184
1056
  }
1185
- }, Q(oe, ge, void 0), oe)();
1057
+ }, X(ot, mt, void 0), ot)();
1186
1058
  export {
1187
- ne as RouterUtils,
1188
- me as WsxLink,
1189
- ze as WsxRouter,
1190
- Ge as WsxView
1059
+ et as RouterUtils,
1060
+ bt as WsxLink,
1061
+ It as WsxRouter,
1062
+ qt as WsxView
1191
1063
  };